fix(opencode): resolve command agent ids to registered opencode agents - #2491
Conversation
affaan-m#2477) The `.opencode/commands/*.md` frontmatter referenced agents with the Claude Code plugin namespace (`agent: everything-claude-code:<name>`), but ECC's opencode integration registers its agents unscoped in `opencode.json`'s `agent` map (`code-reviewer`, `planner`, ...), and that file's own `command` section already references them unscoped. The `everything-claude-code:` scope resolves under no opencode config (the opencode plugin package is `ecc-universal`, and inline-config agents are bare), so subtask commands like `/code-review` hard-fail with `Agent not found: everything-claude-code:code-reviewer`. Non-subtask commands fall back to the default agent and appear to work — which is why only some commands failed. Strip the `everything-claude-code:` prefix from all 30 command frontmatter agent ids so they match the registered agents, fix the MIGRATION.md example, and replace the test that enforced the broken scoped invariant with one that asserts each command agent id is a registered opencode agent (fails on the old scoped ids, passes on the fix). Fixes affaan-m#2477
|
ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (29)
🧰 Additional context used📓 Path-based instructions (13)**/*.{js,ts,jsx,tsx,py,java,cs,go,rb,php,scala,kt}📄 CodeRabbit inference engine (.cursor/rules/common-coding-style.md)
Files:
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php,swift,kt,rs,c,cpp,h,hpp}📄 CodeRabbit inference engine (.cursor/rules/common-security.md)
Files:
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php}📄 CodeRabbit inference engine (.cursor/rules/common-security.md)
Files:
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php,sql}📄 CodeRabbit inference engine (.cursor/rules/common-security.md)
Files:
**/*.{js,ts,jsx,tsx,html,php,java,cs,rb,go}📄 CodeRabbit inference engine (.cursor/rules/common-security.md)
Files:
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php,swift,kt,rs,c,cpp,h,hpp,properties,yml,yaml,json,env,config}📄 CodeRabbit inference engine (.cursor/rules/common-security.md)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (.cursor/rules/typescript-coding-style.md)
Files:
**/*.{test,spec}.{js,ts,jsx,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{js,ts,jsx,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{js,ts,jsx,tsx,json,env*}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{js,ts}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{jsx,tsx,js,ts}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{js,ts,env*}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
🔇 Additional comments (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAll OpenCode command agent references were changed from plugin-scoped names to registered unscoped IDs. The configuration test now verifies that command agents are unscoped and exist in the registered agent map. ChangesOpenCode agent identifier migration
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/opencode-config.test.js`:
- Around line 104-110: Update the unscoped agent ID assertion in the
command-agent validation test to reject any colon-containing identifier, rather
than only the legacy “everything-claude-code:” prefix; retain the existing
registeredAgents check and update the failure message if needed to reflect the
general no-colon contract.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: b0a6df03-acd4-460c-b0d1-c512a36d296a
📒 Files selected for processing (32)
.opencode/MIGRATION.md.opencode/commands/build-fix.md.opencode/commands/checkpoint.md.opencode/commands/code-review.md.opencode/commands/e2e.md.opencode/commands/eval.md.opencode/commands/evolve.md.opencode/commands/go-build.md.opencode/commands/go-review.md.opencode/commands/go-test.md.opencode/commands/instinct-export.md.opencode/commands/instinct-import.md.opencode/commands/instinct-status.md.opencode/commands/learn.md.opencode/commands/orchestrate.md.opencode/commands/plan.md.opencode/commands/projects.md.opencode/commands/promote.md.opencode/commands/refactor-clean.md.opencode/commands/rust-build.md.opencode/commands/rust-review.md.opencode/commands/rust-test.md.opencode/commands/security-scan.md.opencode/commands/security.md.opencode/commands/setup-pm.md.opencode/commands/skill-create.md.opencode/commands/tdd.md.opencode/commands/test-coverage.md.opencode/commands/update-codemaps.md.opencode/commands/update-docs.md.opencode/commands/verify.mdtests/opencode-config.test.js
📜 Review details
⏰ Context from checks skipped due to timeout. (21)
- GitHub Check: CodeRabbit / Review
- GitHub Check: Greptile Review
- GitHub Check: CodeRabbit / Review
- GitHub Check: Test (ubuntu-latest, Node 18.x, yarn)
- GitHub Check: Test (ubuntu-latest, Node 18.x, npm)
- GitHub Check: Test (ubuntu-latest, Node 18.x, pnpm)
- GitHub Check: Test (macos-latest, Node 22.x, bun)
- GitHub Check: Test (windows-latest, Node 22.x, pnpm)
- GitHub Check: Test (windows-latest, Node 18.x, npm)
- GitHub Check: Test (windows-latest, Node 20.x, npm)
- GitHub Check: Test (windows-latest, Node 20.x, pnpm)
- GitHub Check: Test (macos-latest, Node 18.x, yarn)
- GitHub Check: Test (windows-latest, Node 22.x, yarn)
- GitHub Check: Test (windows-latest, Node 18.x, pnpm)
- GitHub Check: Test (macos-latest, Node 18.x, npm)
- GitHub Check: Test (windows-latest, Node 22.x, npm)
- GitHub Check: Test (windows-latest, Node 20.x, yarn)
- GitHub Check: Test (windows-latest, Node 18.x, yarn)
- GitHub Check: Test (macos-latest, Node 18.x, bun)
- GitHub Check: Test (macos-latest, Node 20.x, yarn)
- GitHub Check: Coverage
🧰 Additional context used
📓 Path-based instructions (13)
**/*.{js,ts,jsx,tsx,py,java,cs,go,rb,php,scala,kt}
📄 CodeRabbit inference engine (.cursor/rules/common-coding-style.md)
**/*.{js,ts,jsx,tsx,py,java,cs,go,rb,php,scala,kt}: Always create new objects, never mutate existing ones. Use immutable patterns to prevent hidden side effects and enable safe concurrency
Organize code into many small files (200-400 lines typical, 800 lines max) organized by feature/domain rather than by type
Always handle errors explicitly at every level and never silently swallow errors
Always validate all user input before processing at system boundaries
Use schema-based validation where available
Fail fast with clear error messages when validation fails
Never trust external data (API responses, user input, file content)
Ensure code is readable and well-named
Keep functions small (less than 50 lines)
Keep files focused (less than 800 lines)
Avoid deep nesting (more than 4 levels)
Do not use hardcoded values; use constants or configuration instead
Files:
tests/opencode-config.test.js
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php,swift,kt,rs,c,cpp,h,hpp}
📄 CodeRabbit inference engine (.cursor/rules/common-security.md)
No hardcoded secrets (API keys, passwords, tokens) - validate before any commit
Files:
tests/opencode-config.test.js
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php}
📄 CodeRabbit inference engine (.cursor/rules/common-security.md)
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php}: All user inputs must be validated
Enable CSRF protection on all state-changing endpoints
Verify authentication and authorization for all protected endpoints
Implement rate limiting on all endpoints to prevent abuse
Ensure error messages do not leak sensitive data in responses
Files:
tests/opencode-config.test.js
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php,sql}
📄 CodeRabbit inference engine (.cursor/rules/common-security.md)
Use parameterized queries to prevent SQL injection
Files:
tests/opencode-config.test.js
**/*.{js,ts,jsx,tsx,html,php,java,cs,rb,go}
📄 CodeRabbit inference engine (.cursor/rules/common-security.md)
Implement XSS prevention by sanitizing HTML output
Files:
tests/opencode-config.test.js
**/*.{js,ts,jsx,tsx,py,java,cs,rb,go,php,swift,kt,rs,c,cpp,h,hpp,properties,yml,yaml,json,env,config}
📄 CodeRabbit inference engine (.cursor/rules/common-security.md)
NEVER hardcode secrets in source code - ALWAYS use environment variables or a secret manager
Files:
tests/opencode-config.test.js
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/typescript-coding-style.md)
**/*.{ts,tsx,js,jsx}: Use spread operator for immutable updates in TypeScript/JavaScript instead of direct mutation
Use async/await with try-catch for error handling in TypeScript/JavaScript
Use Zod for schema-based input validation in TypeScript/JavaScript
No console.log statements in production code; use proper logging libraries instead
**/*.{ts,tsx,js,jsx}: Auto-format JavaScript/TypeScript files using Prettier after edit
Warn aboutconsole.logstatements in edited files
Check all modified files forconsole.logstatements before session ends
**/*.{ts,tsx,js,jsx}: Use the ApiResponse interface pattern with generic type parameter:interface ApiResponse<T> { success: boolean; data?: T; error?: string; meta?: { total: number; page: number; limit: number; } }
Implement custom React hooks following the pattern: export a named function with use prefix, generic type parameters, and proper useEffect cleanup for side effects
**/*.{ts,tsx,js,jsx}: Never hardcode secrets; always use environment variables for sensitive credentials like API keys
Throw an error when required environment variables are not configured to fail fast and ensure security prerequisites are metUse Playwright as the E2E testing framework for critical user flows in TypeScript/JavaScript
Files:
tests/opencode-config.test.js
**/*.{test,spec}.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{test,spec}.{js,ts,jsx,tsx}: Write tests before implementation (test-driven development); target 80%+ coverage
Achieve minimum 80% test coverage across all three layers: Unit, Integration, and E2E
Use AAA structure (Arrange / Act / Assert) in tests with descriptive test names that explain behavior under test
Files:
tests/opencode-config.test.js
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{js,ts,jsx,tsx}: Always create new objects and never mutate in place; return new copies instead
Keep files between 200–400 lines typical, with a maximum of 800 lines
Extract helpers when a file exceeds 200 lines
Handle errors explicitly at every level; never swallow errors silently
Validate all user input before processing; use schema-based validation where available
Never trust external data (API responses, file content, query params); always validate
All user inputs must be validated and sanitized
Error messages must be scrubbed of sensitive internals
Use readable, well-named identifiers in all code
Keep functions under 50 lines
Keep files under 800 lines
Avoid nesting deeper than 4 levels
Implement comprehensive error handling in all code
Do not hardcode values; use constants or environment configuration instead
Do not use in-place mutation; always return new objects or state
Files:
tests/opencode-config.test.js
**/*.{js,ts,jsx,tsx,json,env*}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Do not hardcode secrets, API keys, passwords, or tokens
Files:
tests/opencode-config.test.js
**/*.{js,ts}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{js,ts}: Use parameterized queries for all database writes (no string interpolation)
Auth/authz must be checked server-side for every sensitive path
Rate limiting must be applied to all public endpoints
Files:
tests/opencode-config.test.js
**/*.{jsx,tsx,js,ts}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
HTML output must be sanitized where applicable
Files:
tests/opencode-config.test.js
**/*.{js,ts,env*}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Required environment variables must be validated at startup
Files:
tests/opencode-config.test.js
🪛 ast-grep (0.44.1)
tests/opencode-config.test.js
[warning] 89-89: Filesystem path is not a string literal; a request-/variable-derived path can enable path traversal. Validate and normalize the path before use.
Context: fs.readFileSync(path.join(commandsDir, entry), 'utf8')
Note: [CWE-22] Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
(detect-non-literal-fs-filename)
🔇 Additional comments (31)
.opencode/MIGRATION.md (1)
187-187: LGTM!.opencode/commands/build-fix.md (1)
3-3: LGTM!.opencode/commands/checkpoint.md (1)
3-3: LGTM!.opencode/commands/code-review.md (1)
3-3: LGTM!.opencode/commands/security-scan.md (1)
3-3: LGTM!.opencode/commands/security.md (1)
3-3: LGTM!.opencode/commands/setup-pm.md (1)
3-3: LGTM!.opencode/commands/skill-create.md (1)
3-3: LGTM!.opencode/commands/e2e.md (1)
3-3: LGTM!.opencode/commands/eval.md (1)
3-3: LGTM!.opencode/commands/evolve.md (1)
3-3: LGTM!.opencode/commands/go-build.md (1)
3-3: LGTM!.opencode/commands/go-review.md (1)
3-3: LGTM!.opencode/commands/tdd.md (1)
3-3: LGTM!.opencode/commands/test-coverage.md (1)
3-3: LGTM!.opencode/commands/update-codemaps.md (1)
3-3: LGTM!.opencode/commands/go-test.md (1)
3-3: LGTM!.opencode/commands/instinct-export.md (1)
3-3: LGTM!.opencode/commands/instinct-import.md (1)
3-3: LGTM!.opencode/commands/instinct-status.md (1)
3-3: LGTM!.opencode/commands/learn.md (1)
3-3: LGTM!.opencode/commands/update-docs.md (1)
3-3: LGTM!.opencode/commands/verify.md (1)
3-3: LGTM!.opencode/commands/orchestrate.md (1)
3-3: LGTM!.opencode/commands/plan.md (1)
3-3: LGTM!.opencode/commands/projects.md (1)
3-3: LGTM!.opencode/commands/promote.md (1)
3-3: LGTM!.opencode/commands/refactor-clean.md (1)
3-3: LGTM!.opencode/commands/rust-build.md (1)
3-3: LGTM!.opencode/commands/rust-review.md (1)
3-3: LGTM!.opencode/commands/rust-test.md (1)
3-3: LGTM!
|
| Filename | Overview |
|---|---|
| tests/opencode-config.test.js | Test rewritten to assert correct invariant: agent ids must be unscoped and registered in opencode.json's agent map; non-.md entries now skipped; regression guard added for #2477. |
| .opencode/commands/code-review.md | agent: everything-claude-code:code-reviewer → agent: code-reviewer; fixes the reported hard-fail on /code-review (subtask: true command). |
| .opencode/commands/plan.md | agent: everything-claude-code:planner → agent: planner; planner is confirmed registered in opencode.json. |
| .opencode/MIGRATION.md | Example updated from scoped to unscoped agent form; aligns docs with the corrected command convention. |
Sequence Diagram
%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant User
participant OpenCode
participant AgentRegistry as opencode.json agent map
participant SubAgent as SubAgent (e.g. code-reviewer)
Note over User,SubAgent: Before fix — subtask commands hard-fail
User->>OpenCode: /code-review
OpenCode->>AgentRegistry: resolve "everything-claude-code:code-reviewer"
AgentRegistry-->>OpenCode: ❌ Agent not found
OpenCode-->>User: "Error #2477"
Note over User,SubAgent: After fix — agent resolves correctly
User->>OpenCode: /code-review
OpenCode->>AgentRegistry: resolve "code-reviewer"
AgentRegistry-->>OpenCode: ✅ Found (mode: subagent)
OpenCode->>SubAgent: spawn isolated subtask
SubAgent-->>User: Code review output
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant User
participant OpenCode
participant AgentRegistry as opencode.json agent map
participant SubAgent as SubAgent (e.g. code-reviewer)
Note over User,SubAgent: Before fix — subtask commands hard-fail
User->>OpenCode: /code-review
OpenCode->>AgentRegistry: resolve "everything-claude-code:code-reviewer"
AgentRegistry-->>OpenCode: ❌ Agent not found
OpenCode-->>User: "Error #2477"
Note over User,SubAgent: After fix — agent resolves correctly
User->>OpenCode: /code-review
OpenCode->>AgentRegistry: resolve "code-reviewer"
AgentRegistry-->>OpenCode: ✅ Found (mode: subagent)
OpenCode->>SubAgent: spawn isolated subtask
SubAgent-->>User: Code review output
Reviews (2): Last reviewed commit: "test(opencode): reject any namespace-sco..." | Re-trigger Greptile
…t the legacy prefix (affaan-m#2477) Address review: the frontmatter guard only rejected the `everything-claude-code:` prefix, so a hypothetical future `<other-plugin>:agent` value could slip through. opencode registers its inline agents unscoped, so assert the id carries no `:` at all — rejecting the whole scoped class — alongside the existing registered-agent-map membership check.
|
ECC bundle files are already tracked in this repository. Skipping generation of another bundle PR. |
|
Thank you for this! This cleanly aligns OpenCode command frontmatter with the agent IDs actually registered in opencode.json, and the regression test now rejects any namespace-scoped ID. All checks are green, and the combined current-main test run passes in full, so I’m merging it now. We appreciate the thorough follow-up on the review feedback. |
What Changed
everything-claude-code:) from theagent:frontmatter of all 30.opencode/commands/*.mdfiles, so eachcommand references an agent id that opencode actually registers
(e.g.
agent: everything-claude-code:code-reviewer→agent: code-reviewer)..opencode/MIGRATION.mdto the sameunscoped form so the docs stop teaching the failing convention.
tests/opencode-config.test.jsfrontmatter test: it previouslyrequired the scoped prefix (codifying the bug); it now asserts every
command's
agentid is a key inopencode.json'sagentmap.Why This Change
/code-reviewon opencode failed withAgent not found: "everything-claude-code:code-reviewer"(issue #2477), whilethe reporter's runtime "Available agents" list showed the agents unscoped
(
code-reviewer,planner, ...).Root cause: ECC's opencode integration defines its agents inline in
.opencode/opencode.json'sagentmap, where they are registered unscoped, andthat file's own
commandsection already references them unscoped(
"agent": "code-reviewer"). The command markdown, however, used the ClaudeCode plugin namespace. That
everything-claude-code:scope resolves under noopencode configuration — the opencode plugin package is
ecc-universal(a pluginscope would be
ecc-universal:), and inline-config agents are bare.subtask: truecommands spawn the named agent in an isolated subtask and hard-fail when it
can't be resolved; non-subtask commands fall back to the default agent and keep
working — which is exactly why "other commands work fine tho." The inconsistency
has existed since the
.opencode/integration was first added, and the testenforced the wrong invariant so CI never caught it.
This change is confined to
.opencode/(the opencode surface). The top-levelcommands/anddocs/<lang>/commands/— the Claude Code surface where theeverything-claude-code:namespace is correct — are untouched.Testing Done
node tests/run-all.js(clean env): 3105/3105 passed, 0 failed.tests/opencode-config.test.js: the rewritten test fails against the oldscoped frontmatter (
command agent must be an unscoped opencode agent id, got: everything-claude-code:build-error-resolver) and passes after the fix —a fails-before / passes-after regression guard for [BUG][OPENCODE] The
/code-reviewcommand onopencodedoes not work as expected, other commands works fine tho. #2477.node scripts/ci/validate-commands.js(94 command files) — pass.tests/ci/command-registry.test.js— pass (registry scans top-levelcommands//agents/, unaffected).tests/docs/install-identifiers.test.js— pass.opencode.json'sagentmap (0 unregistered).Type of Change
Security & Quality Checklist
commands/)Documentation
.opencode/MIGRATION.mdto theunscoped agent form. No other docs required changes.
Fixes #2477