Files
ECC/.opencode/plugins
MohammadAminDHM 03cfca273b fix(opencode): migrate hooks plugin to V2 API and stop duplicate registrations
OpenCode 2.x only runs V2 plugin definitions ({ id, setup(ctx) }); the V1
function-export form failed schema validation at load with
"PluginModule.LoadError: Plugin must export a default definition with an id
and an effect or setup function".

- Rewrite .opencode/plugins/ecc-hooks.ts as a native V2 plugin: V1 hook keys
  now register on their V2 domains (ctx.tool.hook execute.before/after,
  ctx.shell.hook create.before, ctx.permission.hook evaluate,
  ctx.session.hook compaction, ctx.event.subscribe for file/session/todo
  events, ctx.tool.transform for custom tools). Windows-safe: replaces Bun
  dollar-shell and grep with child_process.spawn + fs; every callback is
  try/catch wrapped and every domain registration is guarded so a missing
  capability degrades instead of crashing setup.
- Stop registering the same plugin id three times: OpenCode scans root-level
  plugin files AND loads the directory through index.ts, so the directory
  form of the plugin config produced two red "Duplicate plugin ID:
  ecc-hooks" entries in the TUI panel. Config now points directly at
  ./plugins/ecc-hooks.ts and plugins/index.ts becomes an inert distinct-id
  stub (kept on disk because install/uninstall plans and consent safety
  tests reference it).
- Document the failure modes and the /api/plugin plus "opencode plugin list"
  diagnostic playbook in TROUBLESHOOTING.md; align .opencode/README.md.

Verified: hook-consent, opencode-hook-consent-safety, install-lifecycle,
install-executor, harness-adapter-compliance tests pass (197 assertions);
check-hooks-schema-keys, validate-install-manifests, validate-hooks and
unicode-safety CI validators pass.
2026-11-03 16:58:51 +03:30
..