Repository navigation
feat: support OpenCode 2 through a ./tui CLI plugin entrypoint - #28
NimbleAINinja wants to merge 1 commit into
Conversation
OpenCode 2 can't load the plugin (warpdotdev#27): it requires a default export with an id and setup(), and its server plugins run in a shared background service with no terminal, so they couldn't reach Warp anyway. Add a ./tui export that OpenCode 2 loads as a CLI plugin (cli.json) in the opencode process attached to the Warp pane. It maps OpenCode 2 events to the existing Warp payloads, only notifies for sessions the client is showing (the event bus is shared by every attached client), skips subagent sessions, and sends the session_start handshake at launch so Warp's setup chip clears before the first prompt. The main entry is unchanged, so OpenCode 1 keeps working. Fixes warpdotdev#27 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X3DNN9JJut23XgnZFwhXgm
|
Follow-up to #28, from a branch based on What
This adds one default export carrying both halves: export default {
id: "warp",
setup() {},
server: WarpPlugin,
}
On the trade-off called out here
Agreed on the mechanism, and it is the only one available: the host version can't be selected at resolve time, since Testing
|
What
OpenCode 2 can't load the plugin (#27): it requires a default export with an
idandsetup(), so0.1.7fails withPlugin must export a default definition with an id and an effect or setup function.Changing the export isn't enough on its own. OpenCode 2 runs
opencode.jsonplugins inside a shared background service (opencode serve --service) that has no controlling terminal, so a server plugin can't write the OSC 777 sequence to the Warp pane.How
New
./tuiexport (src/tui.ts, logic insrc/v2.ts). OpenCode 2 loads it as a CLI plugin fromcli.json, in the opencode process attached to the Warp pane, sowarpNotifyworks unchanged.Same Warp payloads as today. OpenCode 2 events are mapped onto the existing protocol:
session.execution.startedprompt_submit(last user message)session.execution.succeeded/interrupted/failed,session.idlestop(once per turn, with query/response)permission.askedpermission_requestpermission.replied(notreject)permission_repliedsession.tool.success/failedtool_complete(tool name fromsession.tool.input.started)form.createdquestion_asked(OpenCode 2 asks questions through forms, not thequestiontool)Only this client's sessions. The event bus is shared by every client attached to the service, so events are checked against the session the client is showing, or one of its open tabs. Otherwise every Warp pane running opencode would get every other pane's notifications.
Subagent sessions are skipped, as in fix: suppress stop notifications for subagent sessions #22.
session_starthandshake at launch. It goes out about 1s after startup, for the session on screen or the most recent root session in the working directory. Otherwise Warp's "Install Warp Plugin for OpenCode" chip stays up until the first prompt. This is the same problem fix: re-emit session_start after plugin init to fix missed handshake race #25 fixes for v1.OpenCode 1 is unchanged. The main entry still exports only
WarpPlugin. The version and title constants moved tosrc/constants.tsso both entries share them; they are still not re-exported fromindex.ts.No new dependencies. The small subset of the OpenCode 2 CLI plugin context that's used is typed locally, so the lockfile is untouched.
Trade-offs
cli.jsonby hand; the README now says so.opencode plugin addregisters any package with a server entry inopencode.json, and since the main entry is the v1 plugin, it would land where it fails to load. Making the main entry a dual v1/v2 object would fix that. But OpenCode only accepts object entrypoints from1.18.29, so it would break older v1 installs. That seemed like a call for you, so I left it out.Testing
bun run typecheckclean,bun test: 38 pass (12 new intests/v2.test.tscovering the event mapping, per-turnstopdedupe, subagent and other-client filtering, background tabs, and the launch handshake).npm packand installed into a scratch project.@warp-dot-dev/opencode-warp/tuiresolves todist/tui.js, the package root still resolves to the v1 entry, and it exports onlyWarpPlugin.v0.2026.09.16.08.27.stable_02). Loaded the packaged./tuifromcli.json. Notifications for prompt, permission, question, and completion appear in Warp, and the setup chip clears at launch. The same logic also runs on OpenCode 2.0.11.Fixes #27
🤖 Generated with Claude Code
https://claude.ai/code/session_01X3DNN9JJut23XgnZFwhXgm