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.
This commit is contained in:
MohammadAminDHM committed 2026-11-03 18:59:18 +03:30
1 parent 03cfca273b
commit 6286b7c2f1
13 files changed
+1539 -661

No files matched your search

File diff suppressed because it is too large. Load diff
+9 -7
View File
@@ -2,14 +2,16 @@
* ECC plugins directory entry for OpenCode 2.x.
*
* This file is intentionally inert in normal installs. OpenCode 2.x loads
* every root-level `.ts` file in a plugins directory AND the directory
* itself through this entry point, so re-exporting the real plugin from
* here would register the id `ecc-hooks` twice and OpenCode would mark the
* extra entries `failed: Duplicate plugin ID` (shown in red in the TUI
* plugins panel).
* 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).
*
* The configuration in `.opencode/opencode.json` therefore points directly
* at `./plugins/ecc-hooks.ts`. This stub keeps:
* `.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