You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/opencode/specs/tui-plugins.md
+19-9Lines changed: 19 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,6 +88,7 @@ export default plugin
88
88
- If package `exports` exists, loader only resolves `./tui` or `./server`; it never falls back to `exports["."]`.
89
89
- For npm package specs, TUI does not use `package.json``main` as a fallback entry.
90
90
-`package.json``main` is only used for server plugin entrypoint resolution.
91
+
- If a configured plugin has no target-specific entrypoint, it is skipped with a warning (not a load failure).
91
92
- 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.
92
93
- File/path plugins must export a non-empty `id`.
93
94
- npm plugins may omit `id`; package `name` is used.
@@ -100,22 +101,31 @@ export default plugin
100
101
101
102
## Package manifest and install
102
103
103
-
Package manifest is read from `package.json` field `oc-plugin`.
104
+
Install target detection is inferred from `package.json` entrypoints:
105
+
106
+
-`server` target when `exports["./server"]` exists or `main` is set.
107
+
-`tui` target when `exports["./tui"]` exists.
104
108
105
109
Example:
106
110
107
111
```json
108
112
{
109
113
"name": "@acme/opencode-plugin",
110
114
"type": "module",
111
-
"main": "./dist/index.js",
115
+
"main": "./dist/server.js",
116
+
"exports": {
117
+
"./server": {
118
+
"import": "./dist/server.js",
119
+
"config": { "custom": true }
120
+
},
121
+
"./tui": {
122
+
"import": "./dist/tui.js",
123
+
"config": { "compact": true }
124
+
}
125
+
},
112
126
"engines": {
113
127
"opencode": "^1.0.0"
114
-
},
115
-
"oc-plugin": [
116
-
["server", { "custom": true }],
117
-
["tui", { "compact": true }]
118
-
]
128
+
}
119
129
}
120
130
```
121
131
@@ -144,11 +154,12 @@ npm plugins can declare a version compatibility range in `package.json` using th
144
154
- Local installs resolve target dir inside `patchPluginConfig`.
145
155
- For local scope, path is `<worktree>/.opencode` only when VCS is git and `worktree !== "/"`; otherwise `<directory>/.opencode`.
146
156
- Root-worktree fallback (`worktree === "/"` uses `<directory>/.opencode`) is covered by regression tests.
147
-
-`patchPluginConfig` applies all declared manifest targets (`server` and/or `tui`) in one call.
157
+
-`patchPluginConfig` applies all detected targets (`server` and/or `tui`) in one call.
148
158
-`patchPluginConfig` returns structured result unions (`ok`, `code`, fields by error kind) instead of custom thrown errors.
149
159
-`patchPluginConfig` serializes per-target config writes with `Flock.acquire(...)`.
150
160
-`patchPluginConfig` uses targeted `jsonc-parser` edits, so existing JSONC comments are preserved when plugin entries are added or replaced.
151
161
- npm plugin package installs are executed with `--ignore-scripts`, so package `install` / `postinstall` lifecycle scripts are not run.
162
+
-`exports["./server"].config` and `exports["./tui"].config` can provide default plugin options written on first install.
152
163
- Without `--force`, an already-configured npm package name is a no-op.
153
164
- With `--force`, replacement matches by package name. If the existing row is `[spec, options]`, those tuple options are kept.
154
165
- Explicit npm specs with a version suffix (for example `pkg@1.2.3`) are pinned. Runtime install requests that exact version and does not run stale/latest checks for newer registry versions.
@@ -320,7 +331,6 @@ Slot notes:
320
331
-`api.plugins.install(spec, { global? })` runs install -> manifest read -> config patch using the same helper flow as CLI install.
321
332
-`api.plugins.install(...)` returns either `{ ok: false, message, missing? }` or `{ ok: true, dir, tui }`.
322
333
-`api.plugins.install(...)` does not load plugins into the current session. Call `api.plugins.add(spec)` to load after install.
323
-
- For packages that declare a tuple `tui` target in `oc-plugin`, `api.plugins.install(...)` stages those tuple options so a following `api.plugins.add(spec)` uses them.
324
334
- If activation fails, the plugin can remain `enabled=true` and `active=false`.
325
335
-`api.lifecycle.signal` is aborted before cleanup runs.
326
336
-`api.lifecycle.onDispose(fn)` registers cleanup and returns an unregister function.
0 commit comments