fix(opencode): resolve command agent ids to registered opencode agents (#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 #2477
This commit is contained in:
Gaurav Dubey 2026-07-10 09:46:40 +05:30
parent 40927950c4
commit 9d1ecb0754
32 changed files with 52 additions and 34 deletions

View file

@ -77,10 +77,16 @@ if (
else failed++;
if (
test('command markdown frontmatter uses plugin-scoped agent ids', () => {
test('command markdown frontmatter agent ids resolve to a registered opencode agent', () => {
const commandsDir = path.join(opencodeDir, 'commands');
const registeredAgents = new Set(Object.keys(config.agent || {}));
assert.ok(registeredAgents.size > 0, 'Expected opencode.json to register at least one agent');
for (const entry of fs.readdirSync(commandsDir)) {
if (!entry.endsWith('.md')) {
continue;
}
const body = fs.readFileSync(path.join(commandsDir, entry), 'utf8');
const match = body.match(/^agent:\s*(.+)$/m);
@ -88,9 +94,21 @@ if (
continue;
}
const agentId = match[1].trim().replace(/^['"]|['"]$/g, '');
// Regression guard for #2477: the Claude Code plugin namespace
// (`everything-claude-code:`) is not a valid opencode agent scope.
// OpenCode registers these agents unscoped in opencode.json's `agent`
// map, so a scoped id fails to resolve ("Agent not found") and hard-
// breaks subtask commands like /code-review on opencode.
assert.ok(
match[1].startsWith('everything-claude-code:'),
`Expected plugin-scoped agent id in ${entry}, got: ${match[1]}`
!agentId.includes('everything-claude-code:'),
`${entry}: command agent must be an unscoped opencode agent id, got: ${agentId}`
);
assert.ok(
registeredAgents.has(agentId),
`${entry}: command agent "${agentId}" is not registered in opencode.json's agent map`
);
}
})