Expand description
Generic text compressors.
The compressors live in the lean-ctx-compress crate and are re-exported
here unchanged. This facade adds what needs the engine: compression steered
by the active task intent.
Functionsยง
- aggressive_
compress - Strips comments, blank lines, and normalizes indentation for maximum token savings.
- ansi_
density - Returns the ratio of ANSI escape characters to total string length.
- diff_
content - Produces a compact unified diff between old and new content with line numbers.
- is_
yaml_ ext - True for a YAML file extension (
.yaml/.yml). - lightweight_
cleanup - Lightweight post-processing cleanup: collapses consecutive closing braces, removes whitespace-only lines, and limits consecutive blank lines to 1.
- safeguard_
ratio - Safeguard: prevents compression from inflating output or destroying small outputs. For small outputs (<2000 tokens), rejects extreme compression (>95% reduction) that likely lost important content. For large outputs, trusts the pattern.
- strip_
ansi - Removes ANSI escape codes from a string, returning clean text.
- tabular_
delimiter - Delimiter for a delimited-table extension, or
Nonefor non-tabular files. - task_
aware_ compress - Compresses content using the active task intent to preserve task-relevant sections.
- verbatim_
compact - Deduplicates repeated lines, strips boilerplate, and normalizes timestamps/hashes.