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 9be5126
Browse filesBrowse the repository at this point in the historyBrowse files
fix(v2): register pty tools, slash commands and exit notifications via the V2 plugin SDK (#61)
* fix(v2): register pty tools and slash commands via editor add()
The V2 setup registered neither tools nor commands with OpenCode:
- Tools: `ptyTools` was exported but never passed to `ctx.tool.transform`,
so no `pty_*` tool ever reached OpenCode. Issue #55 explicitly asked to
"register PTY tools through the V2 tool transform/registration surface".
- Commands: `registerV2Commands` called `draft.update(name, cb)`, but
OpenCode v2's CommandEditor exposes `add(definition)` only. The guard
`typeof draft.update === 'function'` therefore always short-circuited and
the slash commands never appeared in the "/" menu.
Adapts the V1 tool definitions ({ description, args, execute }) to V2
Tool.Info ({ name, input, description, execute }), registers them through
ctx.tool.transform, and switches commands to draft.add() with an execute
handler. Tests now assert real registration (mocking add()) instead of
mere module-level existence.
* refactor(v2): derive tool input schemas as JSON Schema
opencode v2's Tool.Info expects a JSON Schema for `input` (see the
plugins docs), not a Zod schema. Convert the V1 Zod args via Zod v4's
`toJSONSchema` instead of passing the Zod object through.
* style(v2): collapse execute call to satisfy biome format check
The PR CI (test (format), Devenv CI) failed because biome wants the
definition.execute(...) call on a single line.
* chore(deps): modernize plugin SDK to @opencode/plugin 2 and @opencode-ai/* 1.18
- add @opencode/plugin@^2.0.10 (V2 plugin SDK: Plugin.Context with the
session domain, used to type ctx.session in src/v2)
- bump @opencode-ai/plugin + @opencode-ai/sdk from ^1.3.13 to ^1.18
(kept for the V1 entry point); ToolResult is now string | { output },
adjusted the spawn integration test accordingly
* fix(v2): deliver exit notifications via ctx.session.prompt
The V2 entry point never wired a SessionNotifier: createV2Adapter() was
called without options, so installHostAdapter skipped setNotifier and the
fallback NotificationManager had no client - <pty_exited> was silently
never sent, leaving agents that were told to wait for it stuck.
- src/v2/notifier.ts: V2SessionNotifier delivers through the plugin
context's session domain (ctx.session.prompt) with a deterministic
message id (pty_<id>_exited) so admission.reconcile makes repeated
deliveries idempotent. opencode v2 resolves the run with the session's
current model, so the V1 setAgentModel clobber (#57) does not apply.
- src/v2/index.ts: build the notifier from ctx in setup, guarded by
typeof ctx.session?.prompt; hosts without the session domain get a
visible warning instead of dead silence (#54)
- src/plugin/pty/notification-manager.ts: export buildExitNotification
so both notifiers share the message format
- tests: live integration covers notification delivery + the no-session
fallback
0 commit comments