From a1fe7c7a8770775952dccab6fbfe9ae5add4ac0c Mon Sep 17 00:00:00 2001 From: "nhat.nguyenhong" Date: Thu, 24 Sep 2026 07:53:03 +0000 Subject: [PATCH] Load tui plugin via direct src/tui.tsx file spec instead of repo root --- AGENTS.md | 11 ++++++++--- README.md | 27 +++++++++++++++++++++------ package.json | 3 --- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 41e9ad8..a4b384e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -130,9 +130,14 @@ These are load-bearing. Breaking one causes silent failures in opencode. `provider.commandcode.models` in `opencode.json` and never asks a custom `file://` provider to discover models (only internal providers can register `discoverModels`). Refresh the map with `npm run sync-models`; do not expect a discovery hook in `src/` to populate it. -13. **The TUI plugin lives outside the provider entrypoint.** `src/tui.tsx` is loaded from - **source** (not `dist/`) via `opencode plugin `, which writes a `tui.json` `plugin` - entry; it is exposed as `./tui` in `package.json`. opencode compiles the `.tsx` at load with + 13. **The TUI plugin lives outside the provider entrypoint.** `src/tui.tsx` is loaded from + **source** (not `dist/`) via a `tui.json` `plugin` entry that must be a **direct `file://` URL + to `src/tui.tsx`** (global `~/.config/opencode/tui.json` or project `.opencode/tui.json`), + wired by hand: `opencode plugin ` cannot install a bare `.tsx` (it needs a `package.json` + manifest next to the target), and the spec must never point at the **repo root** — a directory + spec is also picked up as a server plugin via `package.json` `main` → `dist/index.js` (the + provider, not a plugin). Do not re-add a `./tui` export for this; it is deliberately removed. + opencode compiles the `.tsx` at load with its Bun/Solid transform and maps `solid-js` / `@opentui/solid` to its internal modules, so the package stays dependency-free — do not add a build step or real imports of those packages. `src/tui-shims.d.ts` is the only local stand-in for types; keep it in sync with what the file diff --git a/README.md b/README.md index baa533b..9375f44 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ npm run build "provider": { "commandcode": { "name": "Command Code", - "npm": "file:///C:/DevTools/pienv/ccprovider/dist/index.js", + "npm": "file:///C:/dev/opencode-commandcode-provider/dist/index.js", "options": { "apiKey": "{env:COMMANDCODE_API_KEY}" }, @@ -188,14 +188,28 @@ the current state. The file is `~/.config/opencode/commandcode-toggles.json` (ov These commands come from a small TUI plugin shipped in this package (`src/tui.tsx`). It is loaded from **source** — opencode compiles the TSX and provides the Solid runtime itself — so there is no -build step and no runtime dependency for it. Register it once: +build step and no runtime dependency for it. Register it once by adding the plugin file's absolute +`file://` URL to the `plugin` list in `tui.json` (global `~/.config/opencode/tui.json`, or +project-local `.opencode/tui.json`): -```powershell -opencode plugin file:///C:/DevTools/pienv/ccprovider/src/tui.tsx +```jsonc +// tui.json +{ + "plugin": ["file:///C:/dev/opencode-commandcode-provider/src/tui.tsx"] +} ``` -That writes a `tui.json` `plugin` entry (project-local `.opencode/tui.json`, or global with -`--global`). Restart opencode after installing; then type `/cc-` for autocomplete. The plugin also +Use an absolute path with forward slashes (`file:///C:/...` on Windows, `file:///home/...` on +Linux/macOS). Two rules for the entry: + +- It must point at **`src/tui.tsx` itself**. `opencode plugin ` cannot install this form: + the CLI requires a `package.json` manifest next to the target, so a bare `.tsx` must be wired in + by hand as above. +- Never point `plugin` at the **repo root**. A directory spec makes opencode also treat the package + as a server plugin (via `package.json` `main` → `dist/index.js`), which is the AI SDK provider, + not a plugin — it loads as dead weight into every session. + +Restart opencode after registering the plugin; then type `/cc-` for autocomplete. The plugin also renders a **CommandCode panel in the session sidebar** (`zdr` / `debug`, plus live quota, above the built-in panels) that updates live as you toggle. Note that in opencode 1.x the slash menu and the `Ctrl+P` palette read the same command registry, so these entries appear in both. If you run opencode @@ -363,6 +377,7 @@ opencode run "Use the glob tool to list *.mjs and report the filenames." -m comm | Need to see what the provider sends/receives | Set `COMMANDCODE_DEBUG=1` and read the appended log file (see [Debug tracing](#debug-tracing)). | | `tool_choice` seemingly ignored | Expected for `required`; upstream cannot force a call. `none` and named-tool are emulated via the tool list. | | Config change had no effect | opencode reads config once at startup. Restart it. | +| `/cc-*` commands and the sidebar panel are missing | TUI plugin not registered: add a direct `file://` URL to `src/tui.tsx` in `tui.json` (see [Runtime toggles](#runtime-toggles)). A repo-root or `src/tui.tsx`-less entry does not load. | ## Security diff --git a/package.json b/package.json index 2eadab9..2400bbd 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,6 @@ ".": { "import": "./dist/index.js", "types": "./dist/index.d.ts" - }, - "./tui": { - "import": "./src/tui.tsx" } }, "files": [