Skip to content

Commit fa95a61

Browse files
authored
Refactor into plugin loader and do not enforce (anomalyco#20112)
1 parent 9f3c2bd commit fa95a61

17 files changed

Lines changed: 1055 additions & 350 deletions

packages/opencode/specs/tui-plugins.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,18 @@ export default plugin
8484
- TUI shape is `default export { id?, tui }`; including `server` is rejected.
8585
- A single module cannot export both `server` and `tui`.
8686
- `tui` signature is `(api, options, meta) => Promise<void>`.
87-
- If package `exports` contains `./tui`, the loader resolves that entrypoint. Otherwise it uses the resolved package target.
87+
- If package `exports` contains `./tui`, the loader resolves that entrypoint.
88+
- If package `exports` exists, loader only resolves `./tui` or `./server`; it never falls back to `exports["."]`.
89+
- For npm package specs, TUI does not use `package.json` `main` as a fallback entry.
90+
- `package.json` `main` is only used for server plugin entrypoint resolution.
8891
- 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.
8992
- File/path plugins must export a non-empty `id`.
9093
- npm plugins may omit `id`; package `name` is used.
9194
- Runtime identity is the resolved plugin id. Later plugins with the same id are rejected, including collisions with internal plugin ids.
92-
- If a path spec points at a directory, that directory must have `package.json` with `main`.
95+
- If a path spec points at a directory, server loading can use `package.json` `main`.
96+
- TUI path loading never uses `package.json` `main`.
97+
- Legacy compatibility: path specs like `./plugin` can resolve to `./plugin/index.ts` (or `index.js`) when `package.json` is missing.
98+
- The `./plugin -> ./plugin/index.*` fallback applies to both server and TUI v1 loading.
9399
- There is no directory auto-discovery for TUI plugins; they must be listed in `tui.json`.
94100

95101
## Package manifest and install

0 commit comments

Comments
 (0)