Skip to main content

Module compressor

Module compressor 

Source

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.
lightweight_cleanup
Lightweight post-processing cleanup: collapses consecutive closing braces, removes whitespace-only lines, and limits consecutive blank lines to 1.
safeguard_ratio
Safeguard: ensures compression ratio stays within safe bounds. Returns the compressed content if ratio is in [0.15, 1.0], otherwise the original.
strip_ansi
Removes ANSI escape codes from a string, returning clean text.
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.