Skip to content

fix(opencode): declare @opencode-ai/plugin as optional peer dependency - #3816

Closed
alakmar344 wants to merge 1 commit into
affaan-m:mainfrom
alakmar344:fix/opencode-peer-dependency
Closed

alakmar344 wants to merge 1 commit into
affaan-m:mainfrom
alakmar344:fix/opencode-peer-dependency

Conversation

@alakmar344

Copy link
Copy Markdown

Summary

Installing ecc-universal as an OpenCode plugin from npm ("plugins": ["ecc-universal"]) fails during load time because the compiled plugin entrypoint (.opencode/dist/index.js and tools) imports @opencode-ai/plugin at runtime, but the package only declared it in devDependencies.

Because devDependencies are omitted in consumer npm installations, the OpenCode plugin loader throws:

Cannot find package '@opencode-ai/plugin'

Solution

Declare @opencode-ai/plugin in peerDependencies with peerDependenciesMeta set to optional: true:

  • For OpenCode users, npm >= 7 and modern package managers automatically resolve/install the peer dependency.
  • Setting optional: true ensures that non-OpenCode harnesses (Claude Code, Codex, Pi, Cursor) are not burdened or failed if they do not have @opencode-ai/plugin.
  • Keeps the devDependency entry so local repository compilation and type checks (build:opencode) continue to work seamlessly.

Fixes #3810

When installing ecc-universal as an OpenCode plugin from npm, loading fails with 'Cannot find package @opencode-ai/plugin' because the plugin imports it at runtime but it was only declared in devDependencies.
@alakmar344
alakmar344 requested a review from affaan-m as a code owner October 30, 2026 11:56
Copilot AI balanced review requested due to automatic review settings October 30, 2026 11:56
@ecc-tools

ecc-tools Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / Security Evidence

Commit: 5518e7fde9f4c5a63c2653db8a4735f5c45e10d3

Security evidence gate passed (success)

No security-sensitive scanner-evidence gap detected.

Mode: enforce

Scanned 1 changed file(s). No missing scanner-evidence signal was detected.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / PR Risk Taxonomy

Commit: 5518e7fde9f4c5a63c2653db8a4735f5c45e10d3

PR taxonomy review recommended (neutral)

Detected 2 PR taxonomy bucket(s): Install Manifest Integrity, CI/CD Recommendation.

Scanned 1 changed file(s).

Roadmap taxonomy buckets:

Install Manifest Integrity

Install manifests, plugin metadata, and shipped skills should stay synchronized with user-facing setup guidance.

Signals:

  • 1 install or manifest path(s) changed

Paths:

  • package.json

CI/CD Recommendation

CI, dependency, coverage, and contract signals should be routed into follow-up checks or verification work.

Signals:

  • Dependency or CI drift could surface after merge
  • 1 CI or workflow path(s) changed

Paths:

  • package.json

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / Reference Set Readiness

Commit: 5518e7fde9f4c5a63c2653db8a4735f5c45e10d3

Reference set readiness gaps detected (neutral)

Reference evidence present for 0/7 areas (0%) across 1 changed file(s).

This check is based on files changed in this PR. Repository-level readiness is still reported by /ecc-tools analyze comments and generated manifests.

Area Status Evidence / Next Step
Deep analyzer corpus Missing Add analyzer fixture, golden, benchmark, or reference-set files that can catch analyzer regressions.
RAG/evaluator comparison Missing Add retrieval or evaluator reference-set comparison fixtures with expected ranking behavior.
PR salvage/review corpus Missing Add stale-PR, review-thread, reopen-flow, or salvage reference cases for queue cleanup automation.
Discussion triage corpus Missing Add public discussion triage fixtures, golden cases, or reference sets for informational, answered, and no-response classifications.
Harness compatibility Missing Add cross-harness, adapter-compliance, or harness-audit evidence for Claude, Codex, OpenCode, Zed, dmux, and agent surfaces.
Security evidence Missing Attach security evidence such as SBOMs, SARIF, audit reports, or AgentShield evidence packs.
CI failure-mode evidence Missing Add captured CI failure logs, dry-run fixtures, or troubleshooting docs for common workflow failure modes.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / Hosted Promotion Readiness

Commit: 5518e7fde9f4c5a63c2653db8a4735f5c45e10d3

Hosted promotion readiness passed (success)

No hosted promotion evidence gaps detected across 1 changed file(s); 0 corpus scenarios had matching evidence.

This check compares PR file changes against the evaluator/RAG promotion corpus in src/analyzers/fixtures/evaluator-rag-corpus.ts.
Hosted output scoring inspected 0 completed cached hosted job results.

No evaluator corpus scenarios matched this PR.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: affaan-m/ECC
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: b38be6a
  • Layers: Repository YAML
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 511caa88-4d10-46e0-adb2-c3fea5fe623f
Commits

Reviewing files that changed from the base of the PR and between b38be6a and 5518e7f.

Files selected for processing: 1
  • package.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Recent review details
Context from checks skipped due to timeout: 2
  • GitHub Check: CodeRabbit
  • GitHub Check: Greptile Review
Additional context used
Code guidelines: 5
.cursor/rules/common-patterns.md — auto-discovered
.cursor/rules/kotlin-testing.md — auto-discovered
.cursor/rules/python-coding-style.md — auto-discovered
.cursor/rules/swift-patterns.md — auto-discovered
.cursor/rules/common-testing.md — auto-discovered
Path-based instructions: 5
Source excerpt: Encapsulate data access behind a consistent interface: Define standard operations: findAll, findById, create, update, delete Concrete implementations handle storage details (database, API, file, etc.) Business logic depends...

CodeRabbit inference engine (.cursor/rules/common-patterns.md)

Files:

  • package.json
Source excerpt: Use **Kotest** with spec styles (StringSpec, FunSpec, BehaviorSpec) and **MockK** for mocking.

CodeRabbit inference engine (.cursor/rules/kotlin-testing.md)

Files:

  • package.json
Source excerpt: Follow **PEP 8** conventions Source excerpt: Use **type annotations** on all function signatures Source excerpt: Prefer immutable data structures: Source excerpt: **black** for code formatting Source excerpt: **isort** for i...

CodeRabbit inference engine (.cursor/rules/python-coding-style.md)

Files:

  • package.json
Source excerpt: Define small, focused protocols.

CodeRabbit inference engine (.cursor/rules/swift-patterns.md)

Files:

  • package.json
Source excerpt: Test Types (ALL required): **Unit Tests** - Individual functions, utilities, components **Integration Tests** - API endpoints, database operations **E2E Tests** - Critical user flows (framework chosen per language)

CodeRabbit inference engine (.cursor/rules/common-testing.md)

Files:

  • package.json
📝 Summary

Summary by CodeRabbit

  • Chores
    • Updated integration compatibility requirements. No end-user-facing changes are included in this release.

The package metadata now declares @opencode-ai/plugin as an optional peer dependency with a version requirement of >=1.0.0.

Changes: OpenCode plugin dependency

Layer / File(s) Summary
Declare the runtime peer dependency
package.json
Adds @opencode-ai/plugin as an optional peer dependency with a version requirement of >=1.0.0.

Priority: Normal

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • affaan-m/ECC#3668 — Reports OpenCode plugin load failures involving the missing @opencode-ai/plugin package.
  • affaan-m/ECC#3745 — Reports the same missing-package error during published OpenCode plugin loading.

Possibly related PRs

  • affaan-m/ECC#3654 — Changes OpenCode runtime packaging and addresses the same published-plugin dependency resolution problem.
  • affaan-m/ECC#3806 — Adds a runtime packaging check that requires imported packages to be declared as dependencies or peer dependencies.
  • affaan-m/ECC#3676 — Changes the published OpenCode entrypoint and plugin loading implementation.

Suggested reviewers: affaan-m, haelyra

Merge Risk: Minimal · up to 5518e

This change declares the OpenCode plugin package as an optional peer dependency. The compiled bundle has no runtime import of that package, so the declaration is low risk and can be merged.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Linked Issues check Warning The change adds @opencode-ai/plugin as an optional peer dependency, as described for #3810. npm does not automatically install an optional peer dependency when it is absent. Therefore, a consumer in… Use a regular runtime dependency, a non-optional peer dependency, or bundle the required helper so the published plugin can resolve @opencode-ai/plugin without a separately installed package. Add a packed-tarball smoke test that imports t…
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: declaring @opencode-ai/plugin as an optional peer dependency.
Description check Passed The description explains the OpenCode plugin load failure and the proposed optional peer dependency fix. It is directly related to the changeset.
Out of Scope Changes check Passed The reviewed change is limited to package.json dependency metadata. The change directly targets the missing runtime dependency reported by #3810. No unrelated source, test, or configuration changes …
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Out of Scope Changes check

Explanation

The reviewed change is limited to package.json dependency metadata. The change directly targets the missing runtime dependency reported by #3810. No unrelated source, test, or configuration changes are present in the supplied change summary.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

Full details: Linked Issues check

Explanation

The change adds @opencode-ai/plugin as an optional peer dependency, as described for #3810. npm does not automatically install an optional peer dependency when it is absent. Therefore, a consumer installation can still omit @opencode-ai/plugin, and the runtime import failure can remain. The separate default-export defect in #3810 is not part of this PR's stated objective.

Resolution

Use a regular runtime dependency, a non-optional peer dependency, or bundle the required helper so the published plugin can resolve @opencode-ai/plugin without a separately installed package. Add a packed-tarball smoke test that imports the published OpenCode entrypoint without development dependencies.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] Safe to merge: isolated production installations passed the compiled plugin and tool checks before and after the metadata change.

Summary

Declares @opencode-ai/plugin as an optional peer dependency while keeping the existing development dependency. Consumers can provide the package without requiring every harness to install it.

Production npm installations of both the baseline and updated packages successfully loaded the compiled plugin, initialized its hooks, loaded all eight tool exports, and executed the exercised tools without @opencode-ai/plugin installed. The OpenCode imports are type-only; the tool helper uses zod, which remains a regular dependency.

One clarification to the PR description: npm does not automatically install an absent optional peer. The verified plugin-loading paths do not require it at runtime.

No actionable issues were found. The change is safe to merge based on the verified behavior.

  • OpenCode installs can resolve the plugin package they need.

Reviews (1) · Last reviewed commit: "fix(opencode): declare @opencode-ai/plug..." · Reviewed by Greptile

@haelyra

haelyra commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

Thank you for investigating the OpenCode tool-loading failure. Keeping the installed plugin usable without development dependencies is the right goal. Current main already addresses this in 87e8d734: the tools use a local runtime wrapper and import the plugin SDK only as a TypeScript type. Our fresh packed-production check executed changed-files successfully with @opencode-ai/plugin physically absent.

I am closing this dependency-only alternative because the source fix makes the optional peer unnecessary. Published 2.2.3 can still differ from current main; this does not claim a new package release. Thank you for flagging that distribution gap, and please keep sending focused runtime reproductions like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[OpenCode] Published plugin cannot load: @opencode-ai/plugin imported at runtime but only a devDependency -> "Cannot find package '@opencode-ai/plugin'"

3 participants