ECC/commands
JongHyeok Park 0071fa5c3c
refactor(hooks): consolidate PostToolUse hooks into sync/async dispatchers (#2494)
* refactor(hooks): consolidate PostToolUse hooks into sync/async dispatchers

Replace 10 individual PostToolUse entries in hooks.json with two
consolidated dispatcher entries (post:dispatcher:sync /
post:dispatcher:async). The dispatcher's internal registry preserves
every hook ID, matcher, and profile, so ECC_DISABLED_HOOKS and
ECC_HOOK_PROFILE gating behave exactly as before.

Performance (Edit event, actual hooks.json commands spawned in
parallel like the harness does, median of 7 runs):
- Blocking hook latency: 81ms -> 49ms (~40% faster; 7 blocking
  processes -> 1 sync dispatcher)
- Node processes per tool call: 10 -> 2 (7 blocking + 3 async
  -> 1 sync + 1 async)
- observe-runner now runs in-process (~370ms) inside the async
  dispatcher, which stays backgrounded (async: true, timeout 45s),
  so it adds no user-facing latency.

Also:
- dashboard-web lists dispatcher-managed child hooks so the hook
  inventory stays complete
- post-edit-console-warn refactored to export run() for in-process
  dispatch while keeping standalone stdin behavior
- dispatcher stdin reading is multi-byte safe (StringDecoder) and
  child hook exit codes propagate to the dispatcher exit code

* test(hooks): replace emoji literal with unicode escape for CI unicode safety check

* fix(hooks): adopt explicit cli() entrypoint and merge multi-hook stdout

Address Greptile review on #2494:

- Replace the non-standard 'require.main === undefined' guard with an
  explicit exported cli(). The hooks.json bootstraps now call
  require(s).cli(), so merely requiring the module (dashboard-web,
  test runners, Jest, worker threads) can never trigger dispatch,
  attach stdin listeners, or set process.exitCode.
- Replace last-writer-wins stdout with mergeHookStdout(): when several
  hooks emit additionalContext envelopes they merge into a single
  PostToolUse envelope; non-mergeable raw stdout keeps the last hook's
  output and emits a stderr warning naming the dropped hook IDs, so
  nothing is lost silently.

Also includes local formatter reformatting of the dispatcher and its
test file (no behavioral changes beyond the above).

* fix(hooks): keep post:bash:dispatcher phase reachable in minimal profile

The Greptile P1 premise was partially incorrect: sub-hooks without
explicit profiles default to standard,strict via parseProfiles()
(scripts/lib/hook-flags.js), so audit/cost logs never ran under the
minimal profile on main either — there is no user-visible regression.

However, main did spawn the bash dispatcher phase unconditionally and
let each sub-hook gate itself. Restore that semantic by opening the
outer registry gate to minimal,standard,strict so a future sub-hook
that opts into minimal is not silently blocked at the phase level.
Adds the previously missing minimal-profile async dry-run test.

* test(hooks): assert failing hook exit code propagates to real process status

Spawns the actual dispatcher subprocess with an injected failing hook
and asserts the OS-level exit status, stderr diagnostic, and suppressed
pass-through — closing the E2E gap CodeRabbit flagged on #2494.

* chore: retrigger CI (flaky windows powershell bootstrap test)
2026-07-19 15:47:10 -04:00
..
aside.md fix: harden unicode safety checks 2026-03-29 21:21:18 -04:00
auto-update.md refactor: consolidate duplicated hook-root resolver into shared resolveEccRoot() (#2368) (#2410) 2026-07-03 20:01:17 -07:00
build-fix.md fix: add command metadata frontmatter 2026-04-30 03:41:18 -04:00
checkpoint.md fix: add command metadata frontmatter 2026-04-30 03:41:18 -04:00
code-review.md feat: add PRD planning command flow 2026-05-12 00:06:41 -04:00
cost-report.md fix: resolve four bug reports (#2290, #2282, #2276, #2272) 2026-06-18 16:49:58 -04:00
cpp-build.md fix: retire legacy command shims from default surface 2026-04-29 23:56:40 -04:00
cpp-review.md fix: harden unicode safety checks 2026-03-29 21:21:18 -04:00
cpp-test.md fix: retire legacy command shims from default surface 2026-04-29 23:56:40 -04:00
ecc-guide.md docs: salvage ECC onboarding guide commands 2026-05-11 21:09:20 -04:00
epic-claim.md feat: add github-native coordination (epic-* commands + scripts + tests) 2026-06-11 12:58:11 -04:00
epic-decompose.md feat: add github-native coordination (epic-* commands + scripts + tests) 2026-06-11 12:58:11 -04:00
epic-publish.md feat: add github-native coordination (epic-* commands + scripts + tests) 2026-06-11 12:58:11 -04:00
epic-review.md feat: add github-native coordination (epic-* commands + scripts + tests) 2026-06-11 12:58:11 -04:00
epic-sync.md feat: add github-native coordination (epic-* commands + scripts + tests) 2026-06-11 12:58:11 -04:00
epic-unblock.md feat: add github-native coordination (epic-* commands + scripts + tests) 2026-06-11 12:58:11 -04:00
epic-validate.md feat: add github-native coordination (epic-* commands + scripts + tests) 2026-06-11 12:58:11 -04:00
evolve.md feat: project-scoped instinct isolation 2026-03-01 12:07:13 -08:00
fastapi-review.md docs: salvage FastAPI review patterns 2026-05-11 07:44:26 -04:00
feature-dev.md feat: restore review and planning bundles 2026-04-05 17:51:56 -07:00
flutter-build.md fix: retire legacy command shims from default surface 2026-04-29 23:56:40 -04:00
flutter-review.md feat: add C# and Dart language support 2026-04-02 17:48:43 -07:00
flutter-test.md fix: retire legacy command shims from default surface 2026-04-29 23:56:40 -04:00
gan-build.md fix: add command metadata frontmatter 2026-04-30 03:41:18 -04:00
gan-design.md fix: add command metadata frontmatter 2026-04-30 03:41:18 -04:00
go-build.md fix: retire legacy command shims from default surface 2026-04-29 23:56:40 -04:00
go-review.md fix: harden unicode safety checks 2026-03-29 21:21:18 -04:00
go-test.md fix: retire legacy command shims from default surface 2026-04-29 23:56:40 -04:00
gradle-build.md feat: add Kotlin, Android, and KMP rules, agent, skills, and command 2026-03-10 20:53:39 -07:00
harness-audit.md feat: extend harness audit integration scoring (#1990) 2026-05-19 06:20:54 -04:00
hookify-configure.md feat: restore hookify command bundle 2026-04-05 17:50:31 -07:00
hookify-help.md feat: restore hookify command bundle 2026-04-05 17:50:31 -07:00
hookify-list.md feat: restore hookify command bundle 2026-04-05 17:50:31 -07:00
hookify.md feat: restore hookify command bundle 2026-04-05 17:50:31 -07:00
instinct-export.md feat: project-scoped instinct isolation 2026-03-01 12:07:13 -08:00
instinct-import.md fix: harden unicode safety checks 2026-03-29 21:21:18 -04:00
instinct-status.md refactor: consolidate duplicated hook-root resolver into shared resolveEccRoot() (#2368) (#2410) 2026-07-03 20:01:17 -07:00
jira.md fix: retire legacy command shims from default surface 2026-04-29 23:56:40 -04:00
kotlin-build.md fix: retire legacy command shims from default surface 2026-04-29 23:56:40 -04:00
kotlin-review.md fix: harden unicode safety checks 2026-03-29 21:21:18 -04:00
kotlin-test.md fix: retire legacy command shims from default surface 2026-04-29 23:56:40 -04:00
learn-eval.md refactor(commands): remove duplicated content in skill-create and learn-eval (#2348) 2026-06-29 18:38:36 -07:00
learn.md fix: add command metadata frontmatter 2026-04-30 03:41:18 -04:00
loop-start.md fix: add command metadata frontmatter 2026-04-30 03:41:18 -04:00
loop-status.md feat: write loop-status snapshots 2026-04-30 12:25:14 -04:00
marketing-campaign.md feat: add marketing campaign agent skill and command (#2031) 2026-05-25 14:10:35 -04:00
model-route.md fix: add command metadata frontmatter 2026-04-30 03:41:18 -04:00
multi-backend.md docs: align command docs with shipped behavior (#2169) 2026-06-07 13:25:58 +08:00
multi-execute.md docs: align command docs with shipped behavior (#2169) 2026-06-07 13:25:58 +08:00
multi-frontend.md docs: align command docs with shipped behavior (#2169) 2026-06-07 13:25:58 +08:00
multi-plan.md docs: align command docs with shipped behavior (#2169) 2026-06-07 13:25:58 +08:00
multi-workflow.md docs: align command docs with shipped behavior (#2169) 2026-06-07 13:25:58 +08:00
orch-add-feature.md feat: add orch-* orchestrator skill family (#2153) 2026-06-07 16:15:31 +08:00
orch-build-mvp.md chore: reconcile publish/agent surfaces after PR batch 2026-06-15 14:21:28 -04:00
orch-change-feature.md feat: add orch-* orchestrator skill family (#2153) 2026-06-07 16:15:31 +08:00
orch-fix-defect.md feat: add orch-* orchestrator skill family (#2153) 2026-06-07 16:15:31 +08:00
orch-refine-code.md feat: add orch-* orchestrator skill family (#2153) 2026-06-07 16:15:31 +08:00
orch-review.md feat(workflows): re-land orch-review workflow + add /orch-review command (#2400) 2026-07-03 20:26:40 -07:00
plan-canvas.md feat: Plan Canvas, a browser review canvas for plans (#2467) 2026-07-08 17:12:48 -04:00
plan-prd.md feat: add PRD planning command flow 2026-05-12 00:06:41 -04:00
plan.md feat: Plan Canvas, a browser review canvas for plans (#2467) 2026-07-08 17:12:48 -04:00
pm2.md fix: add command metadata frontmatter 2026-04-30 03:41:18 -04:00
pr.md feat: add PRD planning command flow 2026-05-12 00:06:41 -04:00
project-init.md docs: salvage ECC onboarding guide commands 2026-05-11 21:09:20 -04:00
projects.md fix: resolve CI failures on main — lint, hooks validator, and test alignment 2026-03-02 22:15:46 -08:00
promote.md fix: resolve CI failures on main — lint, hooks validator, and test alignment 2026-03-02 22:15:46 -08:00
prp-commit.md fix: harden claude plugin manifest surfaces 2026-04-08 16:27:30 -07:00
prp-implement.md fix: harden install planning and sync tracked catalogs 2026-03-31 22:57:48 -07:00
prp-plan.md feat: add PRP workflow commands adapted from PRPs-agentic-eng (#848) 2026-03-31 14:12:23 -07:00
prp-pr.md fix: harden claude plugin manifest surfaces 2026-04-08 16:27:30 -07:00
prp-prd.md fix: harden claude plugin manifest surfaces 2026-04-08 16:27:30 -07:00
prune.md feat: pending instinct TTL pruning and /prune command (#725) 2026-03-22 15:40:58 -07:00
python-review.md fix: retire legacy command shims from default surface 2026-04-29 23:56:40 -04:00
quality-gate.md refactor(hooks): consolidate PostToolUse hooks into sync/async dispatchers (#2494) 2026-07-19 15:47:10 -04:00
react-build.md Add React language track with agents, skills, rules, and commands (#2024) 2026-05-28 07:32:52 -04:00
react-review.md Add React language track with agents, skills, rules, and commands (#2024) 2026-05-28 07:32:52 -04:00
react-test.md Add React language track with agents, skills, rules, and commands (#2024) 2026-05-28 07:32:52 -04:00
refactor-clean.md fix: add command metadata frontmatter 2026-04-30 03:41:18 -04:00
resume-session.md fix: harden unicode safety checks 2026-03-29 21:21:18 -04:00
review-pr.md feat: restore review and planning bundles 2026-04-05 17:51:56 -07:00
rust-build.md fix: retire legacy command shims from default surface 2026-04-29 23:56:40 -04:00
rust-review.md feat(agents): add Rust language support (#523) 2026-03-16 13:34:25 -07:00
rust-test.md fix: retire legacy command shims from default surface 2026-04-29 23:56:40 -04:00
santa-loop.md feat(commands): add santa-loop adversarial review command (#1052) 2026-03-31 14:05:31 -07:00
save-session.md fix: harden unicode safety checks 2026-03-29 21:21:18 -04:00
security-scan.md fix(plan-orchestrate): detect ecc@ecc marketplace + emit ecc: agent prefix (#2316) (#2409) 2026-07-03 20:00:51 -07:00
sessions.md refactor: consolidate duplicated hook-root resolver into shared resolveEccRoot() (#2368) (#2410) 2026-07-03 20:01:17 -07:00
setup-pm.md Revert "feat(ecc): prune plugin 43→12 items, promote 7 rules to .claude/rules/ (#245)" 2026-02-20 01:11:30 -08:00
skill-create.md refactor(commands): remove duplicated content in skill-create and learn-eval (#2348) 2026-06-29 18:38:36 -07:00
skill-health.md refactor: consolidate duplicated hook-root resolver into shared resolveEccRoot() (#2368) (#2410) 2026-07-03 20:01:17 -07:00
test-coverage.md fix: add command metadata frontmatter 2026-04-30 03:41:18 -04:00
update-codemaps.md fix: add command metadata frontmatter 2026-04-30 03:41:18 -04:00
update-docs.md fix: add command metadata frontmatter 2026-04-30 03:41:18 -04:00
vue-review.md fix: address Vue review PR feedback 2026-06-12 19:44:39 +08:00