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 8604a6d
Browse filesBrowse the repository at this point in the historyBrowse files
Ten fixes from review of the v2 adapter, each verified against the
installed @opencode/plugin and @opencode/client dists:
- isolation: move buildCoreContext/trimHostContext out of tools.ts (a
runtime import of the v1 SDK) into tool-defs.ts, so loading the v2
adapter no longer evaluates @opencode-ai/plugin - absent on v2 user
installs, which would kill the whole plugin load
- generate hook: inject nudges into the wire Message's content array
(there is no parts field; the stray property was silently dropped,
muting all per-message nudges on v2)
- session.get input is {sessionID}, not {id}; the adapter decodes input
before the host call, so the old shape always rejected
- extraction children: forward their events by ID - they are created in
the project directory, which the directory filter drops whenever
opencode is launched below the project root
- event pump: per-event try/catch so one handler throw cannot end the
loop for the process lifetime
- wrap-up commands: substitute the invocation prompt text for
ARGUMENTS (v2 does no template expansion; typed args were dropped)
- session messages: read via session.context (no message accessor on
the promise domain), restoring the wrap-up greenlight on v2
- compaction trigger: session.compact is not in the SessionDomain Pick;
degrade to a logged no-op instead of throwing
- tool buffering: flatten Tool.Result content arrays (text parts joined;
typed output is not a title - the buffer's deriveTitle synthesizes)
- stale wrap-up command files from v1 runs are removed on v2, since
syncCommandFiles never deletes and a file collides with the
code-registered command
| bus events |`event` hook |`event.subscribe` (raw SSE) | client-side location filter; location-less events drop (mirrors v1's server-side filter) |
61
-
| incoming message |`chat.message` hook |`session.hook("prompt")`| the hook awaits the runtime; injections append to `prompt.text`(v2 has no synthetic parts) |
60
+
| bus events |`event` hook |`event.subscribe` (raw SSE) | client-side location filter; location-less events resolve via `session.get` (`{sessionID}` input) and drop unresolvable (mirrors v1's server-side filter); events for plugin-created extraction children pass by ID (they live in the project directory, which differs from the instance directory on below-root launches) |
61
+
| incoming message |`chat.message` hook |`session.hook("prompt")`| the hook awaits the runtime; nudge injections append to the OUTBOUND request's last user message in the generate hook (v2 wire `Message` carries parts in `content`, not `parts`) |
62
62
| system prompt |`experimental.chat.system.transform`|`session.hook("context")`| mutates the request's system array; the runtime pushes a raw string where v2 types SystemPart (smoke-test-gated) |
| wrap-up commands |`command.execute.before` + command files |`command.transform` + `CommandEditor.add`| registered in code: `execute` arms the greenlight check (`armWrapUp`) and delivers the same prompt body the v1 file carries; the runtime installs only ACTION command files on v2 (a file and a registered command with the same name would collide) |
65
-
| tools |`hooks.tool` map via `tool()`|`tool.transform` + `ToolEditor.add`| zod shapes pass as Standard Schema; results wrap as `{ content }`|
66
-
| tool buffering |`tool.execute.after` hook |`tool.hook("execute.after")`| wired: feeds the same extraction buffer; result shape smoke-test-gated|
64
+
| wrap-up commands |`command.execute.before` + command files |`command.transform` + `CommandEditor.add`| registered in code: `execute` arms the greenlight check (`armWrapUp`) and delivers the same prompt body the v1 file carries, substituting the invocation's prompt text for `$ARGUMENTS` (v2's `session.prompt` does no template expansion); the runtime installs only ACTION command files on v2 and REMOVES stale wrap-up files from earlier v1 runs (a file and a registered command with the same name would collide) |
65
+
| tools |`hooks.tool` map via `tool()`|`tool.transform` + `ToolEditor.add`| zod shapes pre-converted to JSON Schema with our own zod (v2's `instanceof $ZodType` detection fails for ours and drops the schema); results wrap as `{ content }`|
66
+
| tool buffering |`tool.execute.after` hook |`tool.hook("execute.after")`| wired: feeds the same extraction buffer; `Tool.Result.content` is flattened (string passes through, content-part arrays contribute their text parts), title is left empty (the buffer's `deriveTitle` synthesizes one)|
67
67
| noReply deliveries |`promptAsync` with `noReply`| none | gated off via `HostCapabilities.noReplyDelivery` -- chat echoes and the session-start reminder are skipped on v2 (delivering them would start real model turns: a feedback loop) |
68
68
| synthetic wake deliveries |`promptAsync` with `synthetic` parts |`session.synthetic` endpoint | watcher + chat wake nudges route to v2's synthetic endpoint (TUI-hidden), matching v1 |
69
-
| child sessions |`client.session.create/promptAsync/prompt/delete`|`session.create/prompt`| create+prompt supported (shapes smoke-test-gated; a missing id throws into the extraction fallback); delete degrades (extraction children are not cleaned up on v2) |
69
+
| child sessions |`client.session.create/promptAsync/prompt/delete`|`session.create/prompt`| create+prompt supported (a missing id throws into the extraction fallback); delete degrades (extraction children are not cleaned up on v2 -- the session picker accumulates one `thatch-extraction` entry per extraction, and `-c` "continue last session" logic that picks the newest top-level session will land in an extraction child after any session that triggered extraction) |
70
70
| session status |`client.session.status`| none | returns `{}`; the wake gate treats unknown as idle and the event-fed status map does the gating |
71
-
| session list/messages |`client.session.list/messages`| none | degrade (`-c` resume listing + wrap-up greenlight lose their data source) |
71
+
| session messages |`client.session.messages`|`session.context`| mapped into the v1 `{info: {role}, parts}` shape, so the wrap-up greenlight check works (the promise domain has no `message` accessor) |
72
+
| session list |`client.session.list`| none | degrade (`-c` resume listing loses its data source) |
73
+
| compaction trigger |`client.tui.executeCommand("session_compact")`| none | degrade (the promise domain's SessionDomain Pick has no `session.compact`; the wrap-up checklist and flush still run, only the automatic compaction is skipped) |
72
74
| toasts |`client.tui.showToast`| none reachable | degrade (the `tui.toast.show` event has no producer surface from the promise context) |
| dispose |`dispose` hook | cleanup returned from `setup`| must be idempotent: v2 auto-reloads plugins on file change, and a non-idempotent cleanup doubles pollers/pumps/nudges |
0 commit comments