PostCompact hook stdin can be invalid JSON (unescaped \. in compact_summary)
The PostCompact hook receives a JSON payload on stdin including a compact_summary field with the auto-generated compaction summary text. When that summary text quotes something containing a backslash followed by a character that isn't a legal JSON string escape (e.g. \., from quoting a sed pattern like s/[\/\.]/-/g), the emitted payload is not valid JSON — \. is not one of \" \\ \/ \b \f \n \r \t \uXXXX.
Repro:
{"session_id":"test","transcript_path":"/tmp/test.jsonl","cwd":"/tmp","hook_event_name":"PostCompact","trigger":"manual","compact_summary":"Discussed sed pattern `s/[\/\.]/-/g` and a literal\nnewline in prior turn text."}
$ jq . repro.json
jq: parse error: Invalid escape at line 1, column 220
Impact: any PostCompact hook that parses stdin with a standard JSON parser (jq, python -m json, etc.) fails silently if downstream error handling doesn't check exit codes — the hook can report "completed successfully" while doing nothing.
Suggested fix: properly JSON-escape all backslashes when serializing summary/transcript text into the hook payload.