GeezerVison is showing github.com — Single target plugin entrypoints (#19467) · nathanhinish/opencode@f3997d8
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .opencode/plugins/tui-smoke.tsx +12-3Lines changed: 12 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | /** @jsxImportSource @opentui/solid */ | 2 | 2 | import { useKeyboard, useTerminalDimensions } from "@opentui/solid" | 3 | 3 | import { RGBA, VignetteEffect } from "@opentui/core" | 4 | | -import type { TuiKeybindSet, TuiPluginApi, TuiPluginMeta, TuiSlotPlugin } from "@opencode-ai/plugin/tui" | | 4 | +import type { | | 5 | + TuiKeybindSet, | | 6 | + TuiPlugin, | | 7 | + TuiPluginApi, | | 8 | + TuiPluginMeta, | | 9 | + TuiPluginModule, | | 10 | + TuiSlotPlugin, | | 11 | +} from "@opencode-ai/plugin/tui" | 5 | 12 |
| 6 | 13 | const tabs = ["overview", "counter", "help"] | 7 | 14 | const bind = { | @@ -813,7 +820,7 @@ const reg = (api: TuiPluginApi, input: Cfg, keys: Keys) => { | 813 | 820 | ]) | 814 | 821 | } | 815 | 822 |
| 816 | | -const tui = async (api: TuiPluginApi, options: Record<string, unknown> | null, meta: TuiPluginMeta) => { | | 823 | +const tui: TuiPlugin = async (api, options, meta) => { | 817 | 824 | if (options?.enabled === false) return | 818 | 825 |
| 819 | 826 | await api.theme.install("./smoke-theme.json") | @@ -846,7 +853,9 @@ const tui = async (api: TuiPluginApi, options: Record<string, unknown> | null, m | 846 | 853 | } | 847 | 854 | } | 848 | 855 |
| 849 | | -export default { | | 856 | +const plugin: TuiPluginModule & { id: string } = { | 850 | 857 | id: "tui-smoke", | 851 | 858 | tui, | 852 | 859 | } | | 860 | + | | 861 | +export default plugin |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/specs/tui-plugins.md +11-3Lines changed: 11 additions & 3 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -8,6 +8,8 @@ Technical reference for the current TUI plugin system. | 8 | 8 | - Author package entrypoint is `@opencode-ai/plugin/tui`. | 9 | 9 | - Internal plugins load inside the CLI app the same way external TUI plugins do. | 10 | 10 | - Package plugins can be installed from CLI or TUI. | | 11 | +- v1 plugin modules are target-exclusive: a module can export `server` or `tui`, never both. | | 12 | +- Server runtime keeps v0 legacy fallback (function exports / enumerated exports) after v1 parsing. | 11 | 13 |
| 12 | 14 | ## TUI config | 13 | 15 |
| @@ -27,6 +29,7 @@ Example: | 27 | 29 | - `plugin` entries can be either a string spec or `[spec, options]`. | 28 | 30 | - Plugin specs can be npm specs, `file://` URLs, relative paths, or absolute paths. | 29 | 31 | - Relative path specs are resolved relative to the config file that declared them. | | 32 | +- A file module listed in `tui.json` must be a TUI module (`default export { id?, tui }`) and must not export `server`. | 30 | 33 | - Duplicate npm plugins are deduped by package name; higher-precedence config wins. | 31 | 34 | - Duplicate file plugins are deduped by exact resolved file spec. This happens while merging config, before plugin modules are loaded. | 32 | 35 | - `plugin_enabled` is keyed by plugin id, not by plugin spec. | @@ -46,7 +49,7 @@ Minimal module shape: | 46 | 49 |
| 47 | 50 | ```tsx | 48 | 51 | /** @jsxImportSource @opentui/solid */ | 49 | | -import type { TuiPlugin } from "@opencode-ai/plugin/tui" | | 52 | +import type { TuiPlugin, TuiPluginModule } from "@opencode-ai/plugin/tui" | 50 | 53 |
| 51 | 54 | const tui: TuiPlugin = async (api, options, meta) => { | 52 | 55 | api.command.register(() => [ | @@ -69,16 +72,20 @@ const tui: TuiPlugin = async (api, options, meta) => { | 69 | 72 | ]) | 70 | 73 | } | 71 | 74 |
| 72 | | -export default { | | 75 | +const plugin: TuiPluginModule & { id: string } = { | 73 | 76 | id: "acme.demo", | 74 | 77 | tui, | 75 | 78 | } | | 79 | + | | 80 | +export default plugin | 76 | 81 | ``` | 77 | 82 |
| 78 | 83 | - Loader only reads the module default export object. Named exports are ignored. | 79 | | -- TUI shape is `default export { id?, tui }`. | | 84 | +- TUI shape is `default export { id?, tui }`; including `server` is rejected. | | 85 | +- A single module cannot export both `server` and `tui`. | 80 | 86 | - `tui` signature is `(api, options, meta) => Promise<void>`. | 81 | 87 | - If package `exports` contains `./tui`, the loader resolves that entrypoint. Otherwise it uses the resolved package target. | | 88 | +- If a package supports both server and TUI, use separate files and package `exports` (`./server` and `./tui`) so each target resolves to a target-only module. | 82 | 89 | - File/path plugins must export a non-empty `id`. | 83 | 90 | - npm plugins may omit `id`; package `name` is used. | 84 | 91 | - Runtime identity is the resolved plugin id. Later plugins with the same id are rejected, including collisions with internal plugin ids. | @@ -137,6 +144,7 @@ npm plugins can declare a version compatibility range in `package.json` using th | 137 | 144 | - With `--force`, replacement matches by package name. If the existing row is `[spec, options]`, those tuple options are kept. | 138 | 145 | - Tuple targets in `oc-plugin` provide default options written into config. | 139 | 146 | - A package can target `server`, `tui`, or both. | | 147 | +- If a package targets both, each target must still resolve to a separate target-only module. Do not export `{ server, tui }` from one module. | 140 | 148 | - There is no uninstall, list, or update CLI command for external plugins. | 141 | 149 | - Local file plugins are configured directly in `tui.json`. | 142 | 150 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/tui/feature-plugins/home/tips.tsx +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import type { TuiPlugin } from "@opencode-ai/plugin/tui" | | 1 | +import type { TuiPlugin, TuiPluginModule } from "@opencode-ai/plugin/tui" | 2 | 2 | import { createMemo, Show } from "solid-js" | 3 | 3 | import { Tips } from "./tips-view" | 4 | 4 |
| @@ -42,7 +42,9 @@ const tui: TuiPlugin = async (api) => { | 42 | 42 | }) | 43 | 43 | } | 44 | 44 |
| 45 | | -export default { | | 45 | +const plugin: TuiPluginModule & { id: string } = { | 46 | 46 | id, | 47 | 47 | tui, | 48 | 48 | } | | 49 | + | | 50 | +export default plugin |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/tui/feature-plugins/sidebar/context.tsx +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import type { AssistantMessage } from "@opencode-ai/sdk/v2" | 2 | | -import type { TuiPlugin, TuiPluginApi } from "@opencode-ai/plugin/tui" | | 2 | +import type { TuiPlugin, TuiPluginApi, TuiPluginModule } from "@opencode-ai/plugin/tui" | 3 | 3 | import { createMemo } from "solid-js" | 4 | 4 |
| 5 | 5 | const id = "internal:sidebar-context" | @@ -55,7 +55,9 @@ const tui: TuiPlugin = async (api) => { | 55 | 55 | }) | 56 | 56 | } | 57 | 57 |
| 58 | | -export default { | | 58 | +const plugin: TuiPluginModule & { id: string } = { | 59 | 59 | id, | 60 | 60 | tui, | 61 | 61 | } | | 62 | + | | 63 | +export default plugin |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/tui/feature-plugins/sidebar/files.tsx +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import type { TuiPlugin, TuiPluginApi } from "@opencode-ai/plugin/tui" | | 1 | +import type { TuiPlugin, TuiPluginApi, TuiPluginModule } from "@opencode-ai/plugin/tui" | 2 | 2 | import { createMemo, For, Show, createSignal } from "solid-js" | 3 | 3 |
| 4 | 4 | const id = "internal:sidebar-files" | @@ -54,7 +54,9 @@ const tui: TuiPlugin = async (api) => { | 54 | 54 | }) | 55 | 55 | } | 56 | 56 |
| 57 | | -export default { | | 57 | +const plugin: TuiPluginModule & { id: string } = { | 58 | 58 | id, | 59 | 59 | tui, | 60 | 60 | } | | 61 | + | | 62 | +export default plugin |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/tui/feature-plugins/sidebar/footer.tsx +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import type { TuiPlugin, TuiPluginApi } from "@opencode-ai/plugin/tui" | | 1 | +import type { TuiPlugin, TuiPluginApi, TuiPluginModule } from "@opencode-ai/plugin/tui" | 2 | 2 | import { createMemo, Show } from "solid-js" | 3 | 3 | import { Global } from "@/global" | 4 | 4 |
| @@ -85,7 +85,9 @@ const tui: TuiPlugin = async (api) => { | 85 | 85 | }) | 86 | 86 | } | 87 | 87 |
| 88 | | -export default { | | 88 | +const plugin: TuiPluginModule & { id: string } = { | 89 | 89 | id, | 90 | 90 | tui, | 91 | 91 | } | | 92 | + | | 93 | +export default plugin |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/tui/feature-plugins/sidebar/lsp.tsx +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import type { TuiPlugin, TuiPluginApi } from "@opencode-ai/plugin/tui" | | 1 | +import type { TuiPlugin, TuiPluginApi, TuiPluginModule } from "@opencode-ai/plugin/tui" | 2 | 2 | import { createMemo, For, Show, createSignal } from "solid-js" | 3 | 3 |
| 4 | 4 | const id = "internal:sidebar-lsp" | @@ -58,7 +58,9 @@ const tui: TuiPlugin = async (api) => { | 58 | 58 | }) | 59 | 59 | } | 60 | 60 |
| 61 | | -export default { | | 61 | +const plugin: TuiPluginModule & { id: string } = { | 62 | 62 | id, | 63 | 63 | tui, | 64 | 64 | } | | 65 | + | | 66 | +export default plugin |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/tui/feature-plugins/sidebar/mcp.tsx +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import type { TuiPlugin, TuiPluginApi } from "@opencode-ai/plugin/tui" | | 1 | +import type { TuiPlugin, TuiPluginApi, TuiPluginModule } from "@opencode-ai/plugin/tui" | 2 | 2 | import { createMemo, For, Match, Show, Switch, createSignal } from "solid-js" | 3 | 3 |
| 4 | 4 | const id = "internal:sidebar-mcp" | @@ -88,7 +88,9 @@ const tui: TuiPlugin = async (api) => { | 88 | 88 | }) | 89 | 89 | } | 90 | 90 |
| 91 | | -export default { | | 91 | +const plugin: TuiPluginModule & { id: string } = { | 92 | 92 | id, | 93 | 93 | tui, | 94 | 94 | } | | 95 | + | | 96 | +export default plugin |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/tui/feature-plugins/sidebar/todo.tsx +4-2Lines changed: 4 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import type { TuiPlugin, TuiPluginApi } from "@opencode-ai/plugin/tui" | | 1 | +import type { TuiPlugin, TuiPluginApi, TuiPluginModule } from "@opencode-ai/plugin/tui" | 2 | 2 | import { createMemo, For, Show, createSignal } from "solid-js" | 3 | 3 | import { TodoItem } from "../../component/todo-item" | 4 | 4 |
| @@ -40,7 +40,9 @@ const tui: TuiPlugin = async (api) => { | 40 | 40 | }) | 41 | 41 | } | 42 | 42 |
| 43 | | -export default { | | 43 | +const plugin: TuiPluginModule & { id: string } = { | 44 | 44 | id, | 45 | 45 | tui, | 46 | 46 | } | | 47 | + | | 48 | +export default plugin |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/tui/feature-plugins/system/plugins.tsx +13-5Lines changed: 13 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { Keybind } from "@/util/keybind" | 2 | | -import type { TuiPlugin, TuiPluginApi, TuiPluginStatus } from "@opencode-ai/plugin/tui" | | 2 | +import type { TuiPlugin, TuiPluginApi, TuiPluginModule, TuiPluginStatus } from "@opencode-ai/plugin/tui" | 3 | 3 | import { useKeyboard, useTerminalDimensions } from "@opentui/solid" | 4 | 4 | import { fileURLToPath } from "url" | 5 | 5 | import { DialogSelect, type DialogSelectOption } from "@tui/ui/dialog-select" | 6 | | -import { createEffect, createMemo, createSignal } from "solid-js" | | 6 | +import { Show, createEffect, createMemo, createSignal } from "solid-js" | 7 | 7 |
| 8 | 8 | const id = "internal:plugin-manager" | 9 | 9 | const key = Keybind.parse("space").at(0) | @@ -53,11 +53,17 @@ function Install(props: { api: TuiPluginApi }) { | 53 | 53 | <props.api.ui.DialogPrompt | 54 | 54 | title="Install plugin" | 55 | 55 | placeholder="npm package name" | | 56 | + busy={busy()} | | 57 | + busyText="Installing plugin..." | 56 | 58 | description={() => ( | 57 | 59 | <box flexDirection="row" gap={1}> | 58 | 60 | <text fg={props.api.theme.current.textMuted}>scope:</text> | 59 | | - <text fg={props.api.theme.current.text}>{global() ? "global" : "local"}</text> | 60 | | - <text fg={props.api.theme.current.textMuted}>({Keybind.toString(tab)} toggle)</text> | | 61 | + <text fg={busy() ? props.api.theme.current.textMuted : props.api.theme.current.text}> | | 62 | + {global() ? "global" : "local"} | | 63 | + </text> | | 64 | + <Show when={!busy()}> | | 65 | + <text fg={props.api.theme.current.textMuted}>({Keybind.toString(tab)} toggle)</text> | | 66 | + </Show> | 61 | 67 | </box> | 62 | 68 | )} | 63 | 69 | onConfirm={(raw) => { | @@ -256,7 +262,9 @@ const tui: TuiPlugin = async (api) => { | 256 | 262 | ]) | 257 | 263 | } | 258 | 264 |
| 259 | | -export default { | | 265 | +const plugin: TuiPluginModule & { id: string } = { | 260 | 266 | id, | 261 | 267 | tui, | 262 | 268 | } | | 269 | + | | 270 | +export default plugin |
|