diff options
| author | GoldJohnKing <GoldJohnKing@live.cn> | 2026-09-10 09:00:50 +0800 |
|---|---|---|
| committer | GoldJohnKing <GoldJohnKing@live.cn> | 2026-09-10 09:00:50 +0800 |
| commit | ca380ba48876148518a393b0e87c3e2a25fd3bcf (patch) | |
| tree | 55b55a7d53bfd600e3e7a55e3fdfaf44f464bd28 /docs/README.opencode.md | |
| parent | aeba3ee2fd6dfc750827dfc3d3624ff505f94b59 (diff) | |
fix(opencode): differentiate tool mapping by host flavor and harden child detection
Current opencode2 builds renamed the model-facing tools (bash→shell,
task→subagent with `agent` instead of `subagent_type`, apply_patch→
patch/patchText) and removed todowrite entirely, so the single v1
mapping injected on v2 hosts taught the model stale tool names.
- export V1_MAPPING/V2_MAPPING and inject the flavor-correct one on
each path (v1 messages.transform → V1; v2 ctx.session.hook("context")
→ V2, incl. no-todo-tool guidance and sessionID continuation)
- child-session detection now keys on parentID presence (primary
signal on both flavors) with dual-shape unwrapping preserved; v1
#2160 behavior unchanged
- mirror surfaces updated: INSTALL.md dual mapping tables,
README.opencode.md host-flavor notes, test-bootstrap-caching.mjs
asserts both mappings + drives the v2 context hook end-to-end
- skills: add OpenCode to executing-plans' subagent-capable list,
accurate OpenCode worktree status (git fallback; TUI dialogs are
user-side only), generalized live-subagent resume guidance
Diffstat (limited to 'docs/README.opencode.md')
| -rw-r--r-- | docs/README.opencode.md | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/docs/README.opencode.md b/docs/README.opencode.md index 316f3ea..fd1a292 100644 --- a/docs/README.opencode.md +++ b/docs/README.opencode.md @@ -96,18 +96,20 @@ To pin a specific version, use a branch or tag: ## How It Works -The plugin does two things: +The plugin does two things, using host-flavor-specific APIs: 1. **Registers the skills directory** so OpenCode discovers all superpowers skills without symlinks or manual config. - - **V1:** via the `config` hook, injecting into `config.skills.paths` - - **V2:** via the `setup()` function using `ctx.skill.transform()` (V2 native API, confirmed active at runtime) -2. **Injects bootstrap context** into the first user message of each conversation, adding superpowers awareness. - - **V1:** via `experimental.chat.messages.transform` hook - - **V2:** via `ctx.session.hook("context")` — the V2 equivalent (confirmed active at runtime) + - **V1:** via the `config` hook, injecting into `config.skills.paths` + - **V2:** via the `setup()` function using `ctx.skill.transform()` (V2 native API, confirmed active at runtime) +2. **Injects bootstrap context** into the first user message of each conversation, adding superpowers awareness. The bootstrap includes a tool mapping that is also flavor-specific: V1 sessions get the V1 tool names below, V2 sessions get the V2 names. + - **V1:** via `experimental.chat.messages.transform` hook + - **V2:** via `ctx.session.hook("context")` — the V2 equivalent (confirmed active at runtime) ### Tool Mapping -Skills speak in actions rather than naming any one runtime's tools. On OpenCode these resolve to: +Skills speak in actions rather than naming any one runtime's tools. The bootstrap maps them to the tools your OpenCode flavor actually exposes. + +**V1 (`opencode` 1.x):** - "Create a todo" / "mark complete in todo list" → `todowrite` - `Subagent (general-purpose):` template → OpenCode's `task` tool with `subagent_type: "general"` (or `"explore"` for codebase exploration) @@ -118,7 +120,20 @@ Skills speak in actions rather than naming any one runtime's tools. On OpenCode - "Search file contents" / "find files by name" → `grep`, `glob` - "Fetch a URL" → `webfetch` -(Verified against the installed OpenCode CLI's tool inventory.) +**V2 (`opencode2` beta):** + +- "Create a todo" → V2 has no todo tool of any kind; the mapping tells the model to track the plan in a markdown file (or the harness's plan facility) instead +- `Subagent (general-purpose):` template → OpenCode's `subagent` tool with `agent: "general"` (or `"explore"`); pass `sessionID` to continue a previous subagent +- "Invoke a skill" → OpenCode's native `skill` tool +- "Read a file" → `read` +- "Create a file" / "edit a file" / "delete a file" → `patch` with `patchText` (same patch format as V1's `apply_patch`) +- "Run a shell command" → `shell` (`command`, `workdir`, `timeout`, `background`) +- "Search file contents" / "find files by name" → `grep`, `glob` +- "Fetch a URL" → `webfetch` + +In short, V2 renamed `task` → `subagent` (the agent name moved from `subagent_type` to `agent`, and continuation happens by re-invoking with `sessionID`), `apply_patch` → `patch`, and `bash` → `shell`, and it dropped the todo tool entirely; `read`, `grep`, `glob`, `webfetch`, and `skill` keep their V1 names. + +(V1 list verified against the installed OpenCode 1.18.x CLI's tool inventory; V2 list verified against the V2 source at `dbd9b18`.) ## Troubleshooting |
