Documentation
¶
Overview ¶
Package sanitize cleans raw Claude Code transcript text BEFORE it is redacted, hashed, or stored (CAPQ-4 / FR-Q3). Real transcripts leak terminal control codes, Claude Code command wrappers, and literal escape sequences into the captured text; if those reach the marketplace they produce garbage titles and unreadable bodies, and — worse — they can hide secrets from the redactor.
The contractual pipeline order is: sanitize → redact → hash/store. Sanitizing first guarantees the redactor sees plain text (so a secret buried inside an ANSI escape or a <command-*> wrapper is still caught) and that the canonical content hash is stable across re-runs.
Sanitize applies, in this exact internal order:
(a) strip ANSI/C0 control sequences (CSI/SGR escapes, OSC, lone ESC, and the
remaining C0 control bytes \x00–\x1f except \n and \t; bare \r dropped);
(b) DROP the entire <local-command-caveat>…</local-command-caveat> block
(inner text included) — its body is always Claude Code boilerplate
("Caveat: The messages below were generated by the user while running
local commands…"), never genuine user content (CAPQ D2). Then unwrap the
remaining Claude Code wrappers (<command-name>, <command-message>,
<command-args>, <local-command-stdout>, <local-command-stderr>,
<task-notification>) — keep inner text, drop tags;
(c) unescape literal escape sequences that leaked as text: \n → newline,
\t → tab.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.