Files
ECC/.opencode/plugins/index.ts
T
MohammadAminDHM 6286b7c2f1 fix(opencode): address review findings T01-T15 on the V2 plugin surface
P0: spawnCommand() replaces shell:true (cmd-shim routing with /d /s /c, quoted argv, windowsVerbatimArguments); permission.ask no longer auto-approves formatter/test shell prefixes; detached spawns register the error listener before resolving.

P1: loadToolModule probes .js then .ts for dist and source layouts; V2 setup() tests via mock ctx; installer recognizes every historical plugin registration (./plugins and plugins/ecc-hooks.*) via shared isOpenCodeHookConfigRegistration(); ecc-universal ./plugins export repointed to the live dist/plugins/ecc-hooks.js; opencode.json drops the file-path plugin entry OpenCode 2.x ignores, docs updated.

P2: setup() rolls back registrations and releases the directory guard on mid-setup failure; prettier non-zero exits reported as warn; subscription errors discriminated against abort; disposals awaited without unhandled rejections; windowsHide on all spawns; TROUBLESHOOTING curl passes location[directory].

Tests: opencode-plugin-hooks 22/22 (new T01/T02/T03/T05/T10/T11/T13/T14 coverage), build-opencode 11/11 (new T08 export test), hook-consent 12/12, install-executor 26/26, install-lifecycle 73/73, plugin-manifest 71/71.
2026-11-03 18:59:18 +03:30

30 lines
1.2 KiB
TypeScript

/**
* ECC plugins directory entry for OpenCode 2.x.
*
* This file is intentionally inert in normal installs. OpenCode 2.x loads
* plugins by scanning every root-level file in a plugins directory, so
* re-exporting the real plugin from here would register the id `ecc-hooks`
* twice — once per discovered entry — and OpenCode would mark the extra
* entries `failed: Duplicate plugin ID` (shown in red in the TUI plugins
* panel).
*
* `.opencode/opencode.json` carries no `plugin` entry at all: OpenCode 2.x
* ignores configured file paths ("configured plugin path must be a
* directory"), so `./plugins/ecc-hooks.ts` is discovered from the directory.
* This stub keeps:
* - the file present for the installer/uninstall plan (`ecc repair`), and
* - a distinct id so a stray directory load can never collide with or
* shadow the real hooks plugin, and never throws the V2 schema error
* ("Plugin must export a default definition with an id and an effect or
* setup function") that a plain non-plugin module would cause.
*
* Do not add hook logic here; it belongs in `ecc-hooks.ts` only.
*/
export default {
id: "ecc-hooks-entry",
setup() {
return () => {}
},
}