Commit Graph
14 Commits
Author SHA1 Message Date
haelyra ab47b22ad8 Merge remote-tracking branch 'origin/pr-3935' into stewardship/20261116
# Conflicts:
#	.opencode/plugins/ecc-hooks.ts
2026-11-16 13:23:43 -05:00
bigwalkdoe 9ce5cd92e7 fix(opencode): guard hooks against undefined output to prevent compaction crash
The shell.env and experimental.session.compacting hooks dereferenced
output.env and output.prompt unconditionally. When OpenCode invokes a
hook without an output object, this threw TypeError: undefined is not an
object and aborted compaction entirely.

- shell.env: early-return when output is undefined
- experimental.session.compacting: guard the output.prompt/output.context
  branches so a missing output no-ops instead of throwing

Add regression tests for both hooks covering the undefined-output case.

Fixes #3934
2026-11-14 12:24:38 +05:00
haelyra 8da4a5f858 fix: preserve reviewed OpenCode install migration 2026-11-05 23:40:25 -05:00
MohammadAminDHM 76f8ea4bd3 fix(opencode): address round-2 review findings on the hooks surface
- R2-1: the V2 execute.after adapter passed { result: ... } as the tool
  output; skill-run-tracker derives outcomes from error fields on the
  response itself, so failed skills recorded as successes. The adapter
  now forwards the raw event.result ?? event.output. Covered by a T05
  assertion that an is_error skill event records outcome failure and a
  clean event still records success.
- R2-2: cmd.exe expands %VAR% and honors embedded quotes even inside
  double quotes, so escaping " was unsafe. spawnCommand now refuses
  arguments carrying ", %, CR or LF (nothing spawns; the rejection
  surfaces through the formatter's catch) and emits the canonical /s
  form with one outer quote pair around the whole command. T01 asserts
  the outer pair, strips it before inspecting the inner quoting, and
  covers two refusal payloads.
- R2-3: repo review rules ban console.log; the client-less log fallback
  and the startup line now use console.info (identical stdout behavior).
- R2-4: declined installs recorded before the barrel split retained the
  old module/factory stub in plugins/index.ts, and a later selective
  install (e.g. commands-core) has no operation rewriting it, so the
  strict deactivation gate failed the install after all writes landed.
  The strict branch now migrates such retained files in place only when
  ownership is proven twice (managed-recorded contentSha256 matches disk
  AND disk equals an exact historical disabled-stub payload), written
  through writeFileNoFollow with that digest as expectedContent;
  anything else keeps failing closed. The preflight branch accepts an
  already-inactive recorded config under the same digest-verified
  condition, since selective installs legitimately plan no .opencode
  writes. New lifecycle test covers both the migration (install ok,
  doctor clean, ownership retained) and the refusal path (mis-recorded
  digest never grants a rewrite).
2026-11-03 20:13:58 +03:30
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
haelyra 74aace4071 fix(opencode): preserve CommonJS runtime scope and user script ownership 2026-10-10 18:53:22 -04:00
haelyra 27875bfd02 Merge PR #3444: track OpenCode skill runs and report measurement gaps 2026-10-10 17:37:11 -04:00
YogurDungeon b4943a5e4b fix: record skill runs under OpenCode and report unmeasured skills honestly
Under OpenCode the skill-health dashboard had no writer and no honest
fallback, so it reported every discovered skill as healthy (#2463).

Root cause: `post:skill:track` is only wired for Claude Code, where
`posttooluse-dispatcher.js` fans the event out to `skill-run-tracker.js`.
The OpenCode plugin re-implements the harness events instead of reusing that
dispatcher, so nothing ever wrote `skill-runs.jsonl` — and the tracker's
matcher only accepted the exact Claude Code tool name `Skill`, while OpenCode
calls the tool `skill`, so even wiring it would have dropped every event.
Commands that locate ECC through the inlined resolver in
`scripts/lib/resolve-ecc-root.js` also fell back to `~/.claude`, which does
not contain ECC, so they could not find their scripts.

Changes:

- `.opencode/plugins/ecc-hooks.ts`: dispatch `post:skill:track` from
  `tool.execute.after`. The tracker module is imported lazily and behind
  try/catch, matching the existing `changed-files-store` pattern: this file is
  OpenCode's startup entry point, so a static import failure would crash the
  session before any hook runs (#2530). The module is reused rather than
  reimplemented, keeping its identifier validation, length bounds and
  "never persist prompt text" guarantees.
- `scripts/hooks/skill-run-tracker.js`: match the tool name case-insensitively
  so `Skill` and `skill` are both accepted.
- `scripts/lib/skill-evolution/health.js`: split the summary into
  measured/healthy/declining/unmeasured instead of deriving `healthy = total -
  declining`, which turned "no telemetry" into "everything is fine" for every
  skill.
- `scripts/lib/skill-evolution/dashboard.js`: show the breakdown and warn
  explicitly when skills have no recorded runs, since absence of telemetry is
  not a health signal.

Under OpenCode the resolver also needs `CLAUDE_PLUGIN_ROOT`, which only the
plugin can supply: `shell.env` exports it when a root is found, without
replacing a root the user set or one an earlier plugin already put in
`output.env`.

Root discovery is per capability and probes required runtime files — never
optional content. Probing for `skills/continuous-learning-v2` (the
`workflow-quality` module) rejected supported modular installs that ship the
plugin and tracker without that optional module, disabling telemetry and the
root export for exactly those users.

Also fixes an incidental bug: the compiled plugin bundle is ESM, where
`__dirname` is undefined, so the ECC version lookup silently fell back to its
default. The module directory is now derived from `import.meta.url`.

Tests: `tests/opencode-plugin-hooks.test.js` covers the telemetry dispatch
(skill tool recorded, other tools ignored, minimal profile respected), a
modular install without the optional skills module, the root export and both
override paths; `tests/hooks/skill-run-tracker.test.js` covers the
case-insensitive matcher; `tests/lib/skill-evolution.test.js` and
`tests/lib/skill-dashboard.test.js` cover the unmeasured bucket, the warning
and the aged-out-coverage wording.

Refs #2463, #2530
2026-10-07 19:45:21 -05:00
kapelame 2cdc218c45 fix(opencode): preserve ECC guidance in custom compaction prompts 2026-09-15 12:20:14 -04:00
kapelame 5929d24694 fix(opencode): write hook results through the output contract 2026-09-14 11:29:49 -04:00
Shanujan Sureshandhaelyra 591ab5cbd3 fix(opencode): don't crash the whole session when plugins/lib is missing (#2538)
* fix(opencode): don't crash the whole session when plugins/lib is missing (#2530)

* fix: address review feedback (trailing newlines, symptom wording)

* fix(opencode): also lazy-load the store in ecc-hooks.ts plugin entrypoint

* test(opencode): add regression coverage for missing/present plugins/lib in ecc-hooks

* fix(opencode): guard diagnostic log() against unhandled rejection; tighten test assertion

* fix(opencode): only publish store after init succeeds; scrub loader errors from warning; catch sync log throws

* fix(opencode): scrub raw loader error from changed-files tool; add tool-level regression tests

* fix(ci): make OpenCode checks cross-platform

---------

Co-authored-by: haelyra <49814733+haelyra@users.noreply.github.com>
2026-07-28 21:37:41 -04:00
cogiwimute367-createandPual-LI-6 3a08b0c7a8 feat(opencode): 全面升级OpenCode集成 (#2251)
- 修复ecc-hooks.ts中的硬编码ECC_VERSION(从package.json读取)
- 改进错误处理机制(统一模式、详细错误信息)
- 增强类型安全(添加ToolArgs、ToolInput等类型定义)
- 改进跨平台兼容性(支持macOS、Windows、Linux)
- 添加dependency-analyzer工具(依赖分析)
- 改进format-code工具(错误处理、跨平台支持)
- 改进lint-check工具(错误处理、跨平台支持)
- 更新文档(代理26个、工具8个、命令26个)
- 添加工具测试(6个测试用例)
- 改进现有测试(7个测试用例)

所有测试通过(16/16)

Co-authored-by: Pual-LI-6 <dj2112236494@outlook.com>
2026-06-15 14:01:34 -04:00
Affaan Mustafa 6d613f67dd fix: harden opencode project file probes 2026-05-11 22:40:19 -04:00
Affaan Mustafa affbd33485 fix: avoid opencode shell file probes 2026-04-29 23:26:10 -04:00