Use pathToFileURL for dynamic imports instead of raw file paths, which
fixes "hook error" on Windows where backslash paths break ESM imports.
Add suppressOutput: true to empty hook responses to mitigate the known
Claude Code "hook error" display bug (#10936).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
All 13 remaining hook scripts used `for await (process.stdin)` which
blocks indefinitely when the parent process doesn't close stdin. On
Windows 11 with Claude Code 2.1.27+, pipe behavior changed causing
every hook to hang until its timeout kills it, making CC appear frozen.
Migrate all scripts to the shared timeout-protected readStdin() from
scripts/lib/stdin.mjs (created for #240 but only applied to 2 scripts).
The CJS persistent-mode.cjs gets an inlined version since it can't use
ESM imports.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implement 5 new hook modules for Claude Code's async hook lifecycle:
- SubagentStart/SubagentStop: Track active subagents with parent mode context
- PreCompact: Preserve critical state before context compaction
- Setup: Directory structure initialization and periodic maintenance
- PermissionRequest: Smart auto-approval for safe commands during active modes
- SessionEnd: Record metrics, cleanup transient state, export summaries
Wire all hooks into bridge.ts routing and hooks.json configuration.
Add standalone .mjs entry scripts for each hook type.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>