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 9f4722f
Browse filesBrowse the repository at this point in the historyBrowse files
feat(hooks): route all Claude Code built-in subagents to opencode-worker
Allowlist: general-purpose, untyped, claude, Explore, Plan,
claude-code-guide and statusline-setup are routed. Explore, Plan and
claude-code-guide prompts get a read-only prefix, statusline-setup a
routed-from note. Custom, project, user and plugin agents, including
reviewers, SDD agents and the worker itself, stay on Claude.
| 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
+
| Manifests |`.claude-plugin/plugin.json`, `marketplace.json`| Plugin identity; `plugin.json` carries homepage/repository shown by Claude Code |
25
25
26
26
`src/` is a library that no plugin surface imports since the MCP server was removed; only the tests exercise it. Its exports (`delegate`, `resolveModel`, `buildArgs`, `EventCollector`) are the reference for how `opencode run` must be invoked and how its JSON stream is parsed. Changing behaviour in `src/` does NOT change what the plugin does — the markdown files do. `opencode-worker` shells out to `opencode run` itself; keep its command consistent with `buildArgs`.
No MCP server, no build step, no `dist/`. Claude Desktop is not supported.
22
22
@@ -42,12 +42,13 @@ The run uses your existing OpenCode auth, config, agents and permission rules.
42
42
43
43
## Automatic routing
44
44
45
-
A plugin PreToolUse hook (`scripts/route-to-opencode.sh`, wired by `plugin-hooks/hooks.json`) rewrites every `Agent`/`Task`call whose subagent is `general-purpose`, or untyped, into a call to `opencode-delegate:opencode-worker` on Haiku. The `prompt` and `description`(and any other input keys) are kept; the worker runs the task through `opencode run` using OpenCode's configured default model. Calls to `Explore`, `Plan`, `sdd-*` and any other named or plugin agent pass through untouched.
45
+
A plugin PreToolUse hook (`scripts/route-to-opencode.sh`, wired by `plugin-hooks/hooks.json`) rewrites `Agent`/`Task`calls to Claude Code's built-in subagents into a call to `opencode-delegate:opencode-worker` on Haiku. The `description` and any other input keys are kept; the worker runs the task through `opencode run` using OpenCode's configured default model. The prompt is kept as is for`general-purpose` and untyped calls. `Explore`, `Plan` and `claude-code-guide` calls get a `Read-only task (routed from the ... subagent).` prefix, which forces the worker into read-only mode. `statusline-setup` gets a `Routed from the ... subagent.` note;`claude` is kept as is. Only these built-ins are routed: custom, project, user and plugin agents (reviewers and SDD agents included, and `opencode-worker` itself) are never routed and stay on Claude.
46
46
47
47
The hook never blocks. It passes the call through unchanged when:
48
48
49
+
- The subagent is not a built-in one (custom, project, user or plugin agent, including reviewers and SDD agents).
49
50
- `OPENCODE_DELEGATE_ROUTE` is `0`, `false`, `no` or `off` (global opt-out;unset or empty means routing is on).
50
-
- `OPENCODE_BIN` (default `opencode`) cannot be found, so Claude falls back to its own general-purpose agent.
51
+
- `OPENCODE_BIN` (default `opencode`) cannot be found, so Claude keeps the original subagent.
51
52
- The prompt contains the literal `[no-opencode]` (per-task opt-out).
52
53
- `jq` is missing, or the hook input is not valid JSON.
Copy file name to clipboardExpand all lines: agents/opencode-worker.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,13 @@
1
1
---
2
2
name: opencode-worker
3
-
description: Forwards one scoped task to a model running in OpenCode (Grok, Kimi, GLM, Qwen, DeepSeek, …) through `opencode run` and reports what happened. Use when the user or caller explicitly asks for a task to be done by an OpenCode model, when fanning a task out to several OpenCode models in parallel from a workflow, or when a cheap or fast outside model should do grunt work under Claude's supervision. Also receives tasks automatically routed from the general-purpose subagent by the plugin's PreToolUse hook. Put the model name (e.g. "grok 4.7", "kimi k3"), if any, and the task in the prompt.
3
+
description: Forwards one scoped task to a model running in OpenCode (Grok, Kimi, GLM, Qwen, DeepSeek, …) through `opencode run` and reports what happened. Use when the user or caller explicitly asks for a task to be done by an OpenCode model, when fanning a task out to several OpenCode models in parallel from a workflow, or when a cheap or fast outside model should do grunt work under Claude's supervision. Also receives Claude Code's built-in subagent calls, which the plugin's PreToolUse hook routes here automatically. Put the model name (e.g. "grok 4.7", "kimi k3"), if any, and the task in the prompt.
4
4
tools: Bash
5
5
model: haiku
6
6
---
7
7
8
8
You are a thin forwarder. You run one `opencode run` command, then report. You do not gather context, review the result, fix anything or retry. The caller (Claude) reviews; iteration means the caller invokes you again with the session id and feedback.
9
9
10
-
Routed prompts were written for a general Claude agent, not for you: forward the task verbatimand infer the mode as described below (write by default; read-only for review, question, second opinion or an explicit "read-only").
10
+
Routed prompts come from Claude Code's built-in subagents and were written for a Claude agent, not for you: forward the task verbatim, including any "Routed from the ... subagent" note, and infer the mode as described below (write by default; read-only for review, question, second opinion, an explicit "read-only" or a "Read-only task" prefix, which means read-only mode).
11
11
12
12
OpenCode restores its own context from engram, Graphiti memory and codegraph, so the prompt you send stays short.
13
13
@@ -16,7 +16,7 @@ OpenCode restores its own context from engram, Graphiti memory and codegraph, so
16
16
1.**Parse** your instructions:
17
17
- model name, if any (may include `#variant`)
18
18
- the task, kept verbatim
19
-
- mode: **write** (default) or **read-only** (review, question, second opinion, or the caller says "read-only")
19
+
- mode: **write** (default) or **read-only** (review, question, second opinion, a "Read-only task" prefix, or the caller says "read-only")
20
20
- an optional session id to continue
21
21
2.**Resolve the model.**
22
22
- No model named: omit `-m`. OpenCode uses its configured default.
0 commit comments