Repository navigation
Conversation
V2 rewrites the plugin API and rejects V1 modules with "Invalid V2 TUI
plugin module", which disabled every command after upgrading.
- Entrypoint: Plugin.define({ id, setup }) via lib/plugin.js; index.js and
the new root tui.js cover package and local-path loading
- Commands/keybinds via context.keymap.layer, keeping slash names
- api.kv -> context.storage (lib/kv.js), DialogSelect -> ui.dialog.select
- Events/state: context.data.on, context.data.session.message
- STT delivery: client.session.prompt with submitOnStop and an edit dialog
fallback (the V2 composer is not exposed to plugins yet)
- question.asked -> form.created; logging via OPENCODE_VOICE_LOG
BREAKING CHANGE: requires OpenCode V2 (opencode-v2 2.0.x). V1 is no longer
supported.
Refs renjfk#24
Contributor
|
Hi @renjfk This is a important upgrade for this plugin while opencode version upgrade. So would u take some time to review and merge it? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports the plugin to the OpenCode V2 CLI plugin API. V2 rejects V1 plugin modules with
Invalid V2 TUI plugin module(see #24), soctrl+r, the/stt-*commands, and TTS all disappear on V2.Why the old implementation cannot load on V2
V2's loader requires the default export to carry a non-empty
idand asetupfunction (opencode-v22.0.27 source:packages/tui/src/plugin/context.tsx). The V1 shape —export default { id, tui(api, options) }withapi.kv,api.command.register,api.ui.DialogSelect,api.event.on— is rejected outright. V1 plugin code does not run on V2; the API must be ported (migration guide).Changes
Plugin.define({ id, setup(context) })from@opencode/plugin/tui(index.js+lib/plugin.js).tui.js. V2 resolves the TUI entry of a local path plugin by looking for atuifile (tui.ts/tui.tsx/tui.js); packageexportsonly apply to package-name targets. Without itopencode plugin listsilently reports the plugin as unsupported.context.keymap.layer(...)with stable IDs (opencode-voice.record, ...) and slash names unchanged (/stt-record, ...).api.kv→context.storage(lib/kv.jsadapter).api.ui.DialogSelect→ promise-basedcontext.ui.dialog.select.api.event.on→context.data.on;question.asked→form.created(V2 forms).api.state.session.messages/client.session.message→context.data.session.message.client.tui.appendPromptdoes not exist on V2 and the composer is not exposed to plugins yet (#51209, #51392), so transcriptions are sent withclient.session.prompt:submitOnStop: true→ send immediately (unchanged UX).submitOnStop: false(default) → prefilled edit dialog, Enter sends, Esc cancels.ctrl+rrecord (unchanged),ctrl+ycancel,<leader>vspeak,<leader>oTTS toggle;/stt-submitand/tts-stopremain command-only to avoid shadowing built-ins (<leader>r= redo,<leader>s= status,escape= interrupt). All overridable via plugin options.OPENCODE_VOICE_LOG(the V1client.app.logAPI no longer exists); README updated forcli.json.Testing
npm run check(oxlint + oxfmt) clean.npm test— all green, including new V2 port tests (test/v2-smoke.test.js): definition shape, all ten commands, storage wiring, and the TTSsession.status→session.idlepath. The module-shape check skips when@opencode/plugin/tuiis not installed (CI), every other test runs everywhere.opencode-v22.0.27:opencode plugin listdiscovers the local plugin and the TUI loads it (13 plugins, no reconciliation errors);ctrl+rrecords/transcribes/submits; TTS speaks on idle.Refs #24.