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 e3fdc90
Browse filesBrowse the repository at this point in the historyBrowse files
fix(rescue): inline forwarding into the slash command (closes#17)
The /opencode:rescue --background path was broken because plugin-scoped
subagents cannot use permissionMode: bypassPermissions, and Claude Code
does not propagate the command's allowed-tools grant to a subagent it
spawns. Background-mode subagents have no way to prompt for Bash
permission, so the forwarder was auto-denied and returned an error
instead of OpenCode's output.
Eliminate the subagent layer entirely. The command's own context
already has Bash(node:*), so commands/rescue.md now invokes
opencode-companion.mjs task ... directly. --background maps 1:1 to the
companion's existing detach-a-worker mode, which removes the ambiguity
between "Claude backgrounds the subagent" and "the companion detaches a
worker" that has plagued every related issue (#16, #37). The command
keeps context: fork so OpenCode stdout still lands in a forked context
rather than the parent thread.
Deletes:
- plugins/opencode/agents/opencode-rescue.md (sole-purpose forwarder)
- plugins/opencode/skills/opencode-runtime/ (only used by the deleted
subagent; marked user-invocable: false)
README.md updated to drop the subagent reference from the slash-command
list and the project structure tree.
All 172 tests pass.
Copy file name to clipboardExpand all lines: README.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,7 +99,7 @@ To check your configured providers:
99
99
100
100
-`/opencode:review` -- Normal OpenCode code review (read-only). Supports `--base <ref>`, `--pr <number>`, `--model <provider/model>`, `--free`, `--wait`, and `--background`.
101
101
-`/opencode:adversarial-review` -- Steerable review that challenges implementation and design decisions. Supports `--base <ref>`, `--pr <number>`, `--model <provider/model>`, `--free`, `--wait`, `--background`, and custom focus text.
102
-
-`/opencode:rescue` -- Delegates a task to OpenCode via the `opencode:opencode-rescue` subagent. Supports `--model`, `--free`, `--agent`, `--resume`, `--fresh`, `--worktree`, `--wait`, and `--background`.
102
+
-`/opencode:rescue` -- Delegates a task to OpenCode via a direct call to the companion's `task` runtime. Supports `--model`, `--free`, `--agent`, `--resume`, `--fresh`, `--worktree`, and `--background`. Foreground is the default; `--background` detaches a worker and returns a job id you can poll with `/opencode:status`.
103
103
-`/opencode:status` -- Shows running/recent OpenCode jobs for the current repo.
104
104
-`/opencode:result` -- Shows final output for a finished job, including OpenCode session ID for resuming.
105
105
-`/opencode:cancel` -- Cancels an active OpenCode job.
Copy file name to clipboardExpand all lines: plugins/opencode/commands/rescue.md
+24-24Lines changed: 24 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,25 @@
1
1
---
2
-
description: Delegate investigation, an explicit fix request, or follow-up rescue work to the OpenCode rescue subagent
3
-
argument-hint: "[--background|--wait] [--worktree] [--resume|--fresh] [--model <provider/model> | --free] [--agent <build|plan>] [what OpenCode should investigate, solve, or continue]"
2
+
description: Delegate investigation, an explicit fix request, or follow-up rescue work to OpenCode
3
+
argument-hint: "[--background] [--worktree] [--resume|--fresh] [--model <provider/model> | --free] [--agent <build|plan>] [what OpenCode should investigate, solve, or continue]"
4
4
context: fork
5
5
allowed-tools: Bash(node:*), AskUserQuestion
6
6
---
7
7
8
-
Route this request to the `opencode:opencode-rescue` subagent.
9
-
The final user-visible response must be OpenCode's output verbatim.
8
+
Forward this request to the OpenCode companion's `task` runtime via a single Bash call.
9
+
The final user-visible response must be the companion's stdout verbatim — no commentary, summary, or paraphrase before or after it.
10
10
11
11
Raw user request:
12
12
$ARGUMENTS
13
13
14
14
Execution mode:
15
15
16
-
- If the request includes `--background`, run the `opencode:opencode-rescue` subagent in the background.
17
-
- If the request includes `--wait`, run the `opencode:opencode-rescue` subagent in the foreground.
18
-
- If neither flag is present, default to foreground.
19
-
-`--background` and `--wait` are execution flags for Claude Code. Do not forward them to `task`, and do not treat them as part of the natural-language task text.
20
-
-`--model`, `--free`, and `--agent` are runtime-selection flags. Preserve them for the forwarded `task` call, but do not treat them as part of the natural-language task text. `--free` tells the companion to pick a random first-party `opencode/*` free-tier model from `opencode models`; it is restricted to `opencode/*` because OpenRouter free models have inconsistent tool-use support. `--free` is mutually exclusive with `--model`.
21
-
-`--worktree` is an isolation flag. Preserve it for the forwarded `task` call, but do not treat it as part of the natural-language task text. When present, OpenCode runs in an isolated git worktree instead of editing the working directory in-place.
22
-
- If the request includes `--resume`, do not ask whether to continue. The user already chose.
23
-
- If the request includes `--fresh`, do not ask whether to continue. The user already chose.
24
-
- Otherwise, before starting OpenCode, check for a resumable rescue session from this Claude session by running:
16
+
- Default to foreground: run `node "${CLAUDE_PLUGIN_ROOT}/scripts/opencode-companion.mjs" task ...` and wait for it to finish. The Bash call must run in the foreground — never set `run_in_background: true` on the Bash tool, even when the user asks for `--background`.
17
+
- If the request includes `--background`, append `--background` to the `task` invocation. The companion will spawn a detached worker and return a job id immediately; you then return that job id (with the `Check /opencode:status for progress.` line the companion prints) verbatim.
18
+
-`--background` is the only execution-mode flag. Strip it from the natural-language task text before forwarding. `--wait` is accepted as a no-op alias for the default (foreground) mode and must also be stripped from the task text — do not forward it to `task`.
19
+
-`--model`, `--free`, and `--agent` are runtime-selection flags. Strip them from the task text and forward each to `task` unchanged. `--free` tells the companion to pick a random first-party `opencode/*` free-tier model from `opencode models`; it is restricted to `opencode/*` because OpenRouter free models have inconsistent tool-use support. `--free` is mutually exclusive with `--model`.
20
+
-`--worktree` is an isolation flag. Strip it from the task text and forward it to `task`. When present, OpenCode runs in an isolated git worktree instead of editing the working directory in-place.
21
+
-`--resume` and `--fresh` are routing controls. Strip them from the task text. `--resume` becomes `--resume-last` on the forwarded `task` call. `--fresh` means do not add `--resume-last`, regardless of how the natural-language request reads.
22
+
- If neither `--resume` nor `--fresh` is present, before starting OpenCode, check for a resumable rescue session from this Claude session by running:
- If the user is clearly giving a follow-up instruction such as "continue", "keep going", "resume", "apply the top fix", or "dig deeper", put `Continue current OpenCode session (Recommended)` first.
35
33
- Otherwise put `Start a new OpenCode session (Recommended)` first.
36
-
- If the user chooses continue, add `--resume` before routing to the subagent.
37
-
- If the user chooses a new session, add `--fresh` before routing to the subagent.
38
-
- If the helper reports `available: false`, do not ask. Route normally.
34
+
- If the user chooses continue, add `--resume-last`to the forwarded `task` call.
35
+
- If the user chooses a new session, do not add `--resume-last`.
36
+
- If the helper reports `available: false`, do not ask. Forward normally.
39
37
40
-
Operating rules:
38
+
Forwarding rules:
41
39
42
-
-The subagent is a thin forwarder only. It should use one `Bash` call to invoke `node "${CLAUDE_PLUGIN_ROOT}/scripts/opencode-companion.mjs" task ...` and return that command's stdout as-is.
43
-
-Return the OpenCode companion stdout verbatim to the user.
44
-
-Do not paraphrase, summarize, rewrite, or add commentary before or after it.
45
-
-Do not ask the subagent to inspect files, monitor progress, poll `/opencode:status`, fetch `/opencode:result`, call`/opencode:cancel`, summarize output, or do follow-up work of its own.
40
+
-Use exactly one foreground Bash call to invoke `node "${CLAUDE_PLUGIN_ROOT}/scripts/opencode-companion.mjs" task ...`.
41
+
-Pass the user's task text as a single positional argument to `task`, after all flags. Preserve it as-is apart from stripping the routing flags listed above.
42
+
-If the user is clearly asking to continue prior OpenCode work in this repository (such as "continue", "keep going", "resume", "apply the top fix", or "dig deeper") and `--fresh` is not present, add `--resume-last` even if neither `--resume` nor the resume prompt above produced one.
43
+
-Rescue is always write-capable. The companion's `task` runtime defaults to write mode and has no read-only switch. If the user wants a read-only diagnosis, point them at `/opencode:review` or`/opencode:adversarial-review` instead.
46
44
- Leave `--agent` unset unless the user explicitly asks for a specific agent (build or plan).
47
-
- Leave the model unset unless the user explicitly asks for a specific model or `--free`.
48
-
- Leave `--resume` and `--fresh` in the forwarded request. The subagent handles that routing when it builds the `task` command.
49
-
- If the helper reports that OpenCode is missing or unauthenticated, stop and tell the user to run `/opencode:setup`.
45
+
- Leave the model unset unless the user explicitly asks for a specific model or `--free`. `--free` and `--model` are mutually exclusive — if both are present, return nothing and tell the user to pick one.
46
+
- Return the stdout of the `task` command exactly as-is.
47
+
- Do not paraphrase, summarize, rewrite, or add commentary before or after it.
48
+
- Do not inspect the repository, read files, grep, monitor progress, poll `/opencode:status`, fetch `/opencode:result`, call `/opencode:cancel`, summarize output, or do any follow-up work of your own.
49
+
- If the Bash call fails or OpenCode cannot be invoked, return the failure stderr verbatim. If the helper reports that OpenCode is missing or unauthenticated, stop and tell the user to run `/opencode:setup`.
50
50
- If the user did not supply a request, check for a saved review from `/opencode:review` or `/opencode:adversarial-review`:
0 commit comments