You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4160b6b
Browse filesBrowse the repository at this point in the historyBrowse files
fix(agent): make opencode-worker the only caller of MCP delegate
Restore upstream's flow: the main thread spawns the background
opencode-worker, which calls MCP delegate, verifies the changes and
iterates at most twice. A PreToolUse guard denies delegate and
delegate_async on the main thread (no agent_id), where they block the
session and async tasks are lost when the MCP server restarts.
| Hook |`scripts/route-to-opencode.sh`, `plugin-hooks/hooks.json`| PreToolUse `Agent\|Task`: rewrites only built-in subagent calls (general-purpose, claude, Explore, Plan, claude-code-guide, statusline-setup) to `opencode-worker` on Haiku (Explore/Plan/claude-code-guide forced read-only); custom, plugin, reviewer and SDD agents never routed; pass-through guards: `OPENCODE_DELEGATE_ROUTE=off`, missing opencode, `[no-opencode]`, no `jq`|
24
-
| MCP |`plugin.json``mcpServers`, `src/index.ts`, `dist/index.js`|`opencode` MCP server (stdio, `bun ${CLAUDE_PLUGIN_ROOT}/dist/index.js`) exposing `delegate`, `delegate_async`, `task_result`, `task_list`, `task_cancel`, `list_models`, `list_sessions` to the main thread; its `instructions` (always in the system prompt) make delegation the default for implementation |
25
-
| Manifests |`.claude-plugin/plugin.json`, `marketplace.json`| Plugin identity; `plugin.json` carries homepage/repository shown by Claude Code |
26
-
27
-
`src/` backs the MCP server (`src/index.ts`). The installed plugin cache has no `node_modules`, so what runs is the committed bundle `dist/index.js`: changing `src/` changes plugin behaviour only after `bun run build`, and CI fails if `dist/` is stale. Its exports (`delegate`, `resolveModel`, `buildArgs`, `EventCollector`) are also the reference for how `opencode run` must be invoked and how its JSON stream is parsed; `opencode-worker`shells out to `opencode run` itself, so keep its command consistent with `buildArgs`.
| Skill |`skills/opencode-delegate/SKILL.md`| Model picking, brief template, review-after-return rules|
21
+
| Agent |`agents/opencode-worker.md`| Supervisor (`model: haiku`, `background: true`, inherits all tools incl. MCP): the only caller of MCP `delegate`; verifies git changes and tests, iterates at most twice, reports |
| Hook |`scripts/route-to-opencode.sh`, `scripts/guard-main-thread-mcp.sh`, `plugin-hooks/hooks.json`| PreToolUse `Agent\|Task`: rewrites only built-in subagent calls (general-purpose, claude, Explore, Plan, claude-code-guide, statusline-setup) to `opencode-worker` on Haiku (Explore/Plan/claude-code-guide forced read-only); custom, plugin, reviewer and SDD agents never routed; pass-through guards: `OPENCODE_DELEGATE_ROUTE=off`, missing opencode, `[no-opencode]`, no `jq`. Second PreToolUse entry (`guard-main-thread-mcp.sh`) denies this plugin's MCP `delegate`/`delegate_async` when the input has no `agent_id` (main thread); calls from `opencode-worker` pass|
24
+
| MCP |`plugin.json``mcpServers`, `src/index.ts`, `dist/index.js`|`opencode` MCP server (stdio, `bun ${CLAUDE_PLUGIN_ROOT}/dist/index.js`) exposing `delegate`, `delegate_async`, `task_result`, `task_list`, `task_cancel`, `list_models`, `list_sessions` to the worker (the main thread never calls them); its `instructions` (always in the system prompt) make spawning the background worker the default for implementation|
25
+
| Manifests |`.claude-plugin/plugin.json`, `marketplace.json`| Plugin identity; `plugin.json` carries homepage/repository shown by Claude Code|
26
+
27
+
`src/` backs the MCP server (`src/index.ts`). The installed plugin cache has no `node_modules`, so what runs is the committed bundle `dist/index.js`: changing `src/` changes plugin behaviour only after `bun run build`, and CI fails if `dist/` is stale. Its exports (`delegate`, `resolveModel`, `buildArgs`, `EventCollector`) are also the reference for how `opencode run` must be invoked and how its JSON stream is parsed; `opencode-worker`calls the MCP `delegate` tool, which uses them.
28
28
29
29
-`plugin-hooks/` holds the plugin's Claude Code hooks (registered via the `hooks` field in `plugin.json`); `hooks/` holds this repo's git hooks. Never put `hooks.json` in `hooks/`. The routing script is tested by `test/route-hook.test.ts`.
0 commit comments