Repository navigation
Closed
Labels
Description
Is your feature request related to a problem? Please describe.
The plugin currently targets the legacy OpenCode plugin API. OpenCode v2 changes plugin entrypoints, TUI APIs, configuration, event handling, storage, and server hooks.
Affected areas include:
model-usage.tsxmodel-usage-server.tsmodel-usage/sidebar.tsxmodel-usage/usage.tsxmodel-usage/analyze.tsxmodel-usage/wlib/- Global
tui.jsonandopencode.json - The related
persona-injectorplugin
Describe the solution you'd like
Migrate the plugin to the OpenCode v2 API while preserving as much functionality as possible.
Implementation plan:
- Replace legacy server exports with
Plugin.define({ id, setup }). - Replace legacy server hook registration with v2
session.hookandtool.hook. - Replace
experimental.chat.system.transformwith the v2 context hook where possible. - Decide how to handle system snapshot ordering and final prompt capture.
- Replace
tool.definitioncapture or remove the Tool Defs feature if no supported v2 API exists. - Replace the
{ id, tui }TUI module with the v2 CLI plugin setup API. - Replace
api.slots.registerwithcontext.ui.slot. - Replace
api.keymap.registerLayerwithcontext.keymap.layer. - Update command metadata and slash-command definitions.
- Replace legacy dialog APIs with
context.ui.dialog.show,set, andclear. - Update
wlibkeymap, dialog, theme, and export helpers. - Replace
api.stateandapi.eventusage with v2context.data. - Update event names and payload handling.
- Replace direct internal SQLite reads with supported v2 client/data APIs.
- Review plugin-owned JSON persistence and migrate to v2 storage where appropriate.
- Preserve or redesign the shared
persona-injectorsystem snapshot contract. - Replace
tui.jsonregistration with v2opencode.json,cli.json, orplugins/tui/discovery. - Migrate legacy configuration keys such as
agent,provider,permission, and MCP registration as required by v2. - Add or update package metadata if the plugin is distributed as an npm package.
- Run unit tests and typechecking.
- Verify loading and behavior with the exact
opencode2beta build. - Verify
/usage,/analyze, sidebar rendering, keyboard shortcuts, exports, and quota fetching.
Acceptance criteria
- The plugin loads without legacy API warnings or errors in
opencode2. -
/usageand/analyzeremain available. - Sidebar usage and quota indicators render correctly.
- Dialog navigation, resizing, scrolling, exports, and shortcuts work.
- Historical usage data works without relying on unstable internal database paths.
- Unsupported features are documented clearly.
- Existing tests pass.
Additional context
The v2 documentation is currently beta and may change:
- https://opencode.ai/v2/docs/plugins
- https://opencode.ai/v2/docs/build/plugins
- https://opencode.ai/v2/docs/build/plugins/cli
The tool.definition hook and exact final system-prompt observation semantics appear to have no direct v2 equivalent and require explicit design decisions.
Activity