ECC/scripts/hooks
Hiroshi Tanaka c2950121c9
feat(session): LLM-powered session summary via claude -p (#2388)
Replace mechanical text extraction in session-end.js and pre-compact.js
with LLM-generated summaries using `claude -p`. Summaries now capture
design decisions, resolved bugs, changed files, and carry-over context
rather than just truncated user message snippets.

- Add scripts/lib/llm-summary.js: generateSessionSummary, extractConversationText,
  getContextRemainingPct, getContextThreshold, getLLMModel
- Update scripts/hooks/session-end.js: trigger LLM when context < 20% or
  every 50 messages (env-configurable via ECC_LLM_SUMMARY_*)
- Update scripts/hooks/pre-compact.js: generate LLM summary right before
  compaction and write it to the active session .tmp file
- Add tests/lib/llm-summary.test.js: 18 unit tests
- Update tests/hooks/hooks.test.js: 3 integration tests for new behaviour

Recursion guard: sets ECC_SKIP_LLM_SUMMARY=1 in subprocess env so Stop
hooks fired by the claude -p subprocess do not re-enter summarisation.
Requires no ANTHROPIC_API_KEY — reuses Claude Code's own authentication.

Co-authored-by: Hiroshi Tanaka <hiroshi_tanaka@MBAM3.local>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 15:55:01 -07:00
..
auto-tmux-dev.js fix: consolidate bash hooks without fork storms 2026-04-14 21:23:57 -07:00
bash-hook-dispatcher.js fix(hooks): stop pre/post Bash dispatcher from echoing the input event (#2240) 2026-06-15 13:48:46 -04:00
block-no-verify.js fix: close block-no-verify bypass holes 2026-05-12 22:28:12 -04:00
check-console-log.js fix: stability batch — hook stdin truncation, Codex exa TOML, Stop hook JSON, GateGuard repetition (#2227) 2026-06-11 00:31:33 -04:00
check-hook-enabled.js feat: deliver v1.8.0 harness reliability and parity updates 2026-03-04 14:48:06 -08:00
config-protection.js fix: integrate recent hook and docs PRs (#1905) 2026-05-14 21:37:28 -04:00
cost-tracker.js fix: stability batch — hook stdin truncation, Codex exa TOML, Stop hook JSON, GateGuard repetition (#2227) 2026-06-11 00:31:33 -04:00
cursor-session-env.js feat: Cursor-independent ECC memory via ECC_AGENT_DATA_HOME (#2066) 2026-06-07 13:27:00 +08:00
design-quality-check.js feat: add web frontend rules and design quality hook 2026-04-02 17:33:17 -07:00
desktop-notify.js fix: stability batch — hook stdin truncation, Codex exa TOML, Stop hook JSON, GateGuard repetition (#2227) 2026-06-11 00:31:33 -04:00
doc-file-warning.js fix(hooks): guard doc-file-warning stdin listeners behind require.main (#2358) 2026-06-29 15:54:55 -07:00
ecc-context-monitor.js fix(context-monitor): make cost warnings informational, not commands (#2091) 2026-06-07 13:26:48 +08:00
ecc-metrics-bridge.js fix(hooks): stop false loop warnings and repeated identical context warnings (#2121) 2026-06-07 13:26:30 +08:00
ecc-statusline.js chore: update statusline ANSI color palette 2026-05-15 23:18:01 -04:00
evaluate-session.js Fix stdin overflow bug in hook scripts - truncate chunks to stay within MAX_STDIN limit 2026-02-18 07:40:12 +00:00
gateguard-fact-force.js fix(security): gateguard classifier bypasses (GHSA-4v57) + Windows CI + claw ReDoS 2026-06-18 20:02:30 -04:00
governance-capture.js fix: fold session manager blockers into one candidate 2026-03-24 23:08:27 -04:00
insaits-security-monitor.py test: cover hook bootstrap and InsAIts monitor 2026-04-29 17:45:22 -04:00
insaits-security-wrapper.js fix: fail open on insaits monitor errors 2026-04-29 18:03:33 -04:00
mcp-health-check.js fix(hooks): quote args when probing Windows .cmd MCP servers via shell (#2343) 2026-06-29 15:54:52 -07:00
observe-runner.js fix: route continuous learning observe hooks through node 2026-04-29 21:28:59 -04:00
plugin-hook-bootstrap.js fix(windows): prefer PowerShell over bash to prevent zombie process accumulation (#2346) 2026-06-29 15:54:58 -07:00
post-bash-build-complete.js fix: consolidate bash hooks without fork storms 2026-04-14 21:23:57 -07:00
post-bash-command-log.js fix: consolidate bash hooks without fork storms 2026-04-14 21:23:57 -07:00
post-bash-dispatcher.js fix: consolidate bash hooks without fork storms 2026-04-14 21:23:57 -07:00
post-bash-pr-created.js fix: consolidate bash hooks without fork storms 2026-04-14 21:23:57 -07:00
post-edit-accumulator.js perf(hooks): batch format+typecheck at Stop instead of per Edit (#746) 2026-03-31 14:12:12 -07:00
post-edit-console-warn.js Merge branch 'affaan-m:main' into main 2026-02-18 18:33:04 +05:30
post-edit-format.js fix: port Windows hook safety fixes (#1719) 2026-05-11 03:56:51 -04:00
post-edit-typecheck.js Fix stdin overflow bug in hook scripts - truncate chunks to stay within MAX_STDIN limit 2026-02-18 07:40:12 +00:00
pre-bash-commit-quality.js fix: run pre-bash linters through windows wrappers 2026-04-29 18:59:10 -04:00
pre-bash-dev-server-block.js fix(dev-server-block): stop blocking dev-<suffix> scripts (#2179) 2026-06-07 13:25:39 +08:00
pre-bash-dispatcher.js fix: consolidate bash hooks without fork storms 2026-04-14 21:23:57 -07:00
pre-bash-git-push-reminder.js fix: surface warn-only PreToolUse hooks (#2084) 2026-05-28 07:45:46 -04:00
pre-bash-tmux-reminder.js fix: surface warn-only PreToolUse hooks (#2084) 2026-05-28 07:45:46 -04:00
pre-compact.js feat(session): LLM-powered session summary via claude -p (#2388) 2026-06-29 15:55:01 -07:00
pre-write-doc-warn.js fix(hooks): guard doc-file-warning stdin listeners behind require.main (#2358) 2026-06-29 15:54:55 -07:00
pretooluse-visible-output.js fix: surface warn-only PreToolUse hooks (#2084) 2026-05-28 07:45:46 -04:00
quality-gate.js refactor: deduplicate config lists and unify resolveFormatterBin branches 2026-03-11 10:45:28 +09:00
run-with-flags-shell.sh fix(hooks): pass phase argument from hook ID to observe.sh (#1042) 2026-03-31 14:05:16 -07:00
run-with-flags.js docs+chore: add README Security section; fix lint regressions on main 2026-06-16 02:08:14 -04:00
session-activity-tracker.js Merge pull request #1384 from KeWang0622/fix/lint-md028-eqeqeq 2026-04-12 23:03:19 -07:00
session-end-marker.js fix: clean up observer sessions on lifecycle end 2026-04-02 18:02:29 -07:00
session-end.js feat(session): LLM-powered session summary via claude -p (#2388) 2026-06-29 15:55:01 -07:00
session-start-bootstrap.js fix: salvage remaining stale queue fixes (#1754) 2026-05-11 16:41:08 -04:00
session-start.js fix(session-start): support ECC_SESSION_RETENTION_DAYS opt-out + document env var (#2151) (#2163) 2026-06-07 13:01:33 +08:00
stop-format-typecheck.js fix: stability batch — hook stdin truncation, Codex exa TOML, Stop hook JSON, GateGuard repetition (#2227) 2026-06-11 00:31:33 -04:00
suggest-compact.js fix: context-size /compact trigger, Codex marketplace plugin path, live README badges (#2237) 2026-06-11 16:21:53 -04:00