mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-18 10:33:15 +00:00
1.8 KiB
1.8 KiB
TUI Command Shim Removal
Problem:
- v1 keeps a deprecated
api.commandTUI plugin shim so older plugins do not fail during initialization - v2 should expose only the keymap command API
- tests and fixtures should not encode legacy command behavior as expected behavior
Remove Public Types
In packages/plugin/src/tui.ts, remove:
TuiCommandTuiCommandApiTuiPluginApi.command
Keep api.keymap as the only TUI command registration and execution surface.
Remove Runtime Shim
Delete packages/opencode/src/cli/cmd/tui/plugin/command-shim.ts.
In packages/opencode/src/cli/cmd/tui/plugin/api.tsx, remove:
- the
createCommandShimimport - the
command: createCommandShim(...)field fromcreateTuiApi(...)
In packages/opencode/src/cli/cmd/tui/plugin/runtime.ts, remove:
- the
createCommandShimimport - the
command: createCommandShim(...)field frompluginApi(...)
Migration Target
Plugin authors should replace old calls with keymap calls:
api.keymap.registerLayer({
commands: [
{
name: "plugin.command",
title: "Plugin Command",
namespace: "palette",
slashName: "plugin",
run() {
api.ui.dialog.clear()
},
},
],
bindings: [{ key: "ctrl+shift+p", cmd: "plugin.command" }],
})
Direct replacements:
api.command.register(cb)->api.keymap.registerLayer({ commands, bindings })api.command.trigger(name)->api.keymap.dispatchCommand(name)api.command.show()->api.keymap.dispatchCommand("command.palette.show")onSelect(dialog)-> useapi.ui.dialogfrom the plugin API closure
Verification
After removal, run from package directories:
bun typecheckinpackages/pluginbun typecheckinpackages/opencode- TUI plugin loader tests in
packages/opencodeif runtime plugin API wiring changed