Expand description
Source-code compressor — keep signatures, collapse bodies.
Inspired by Headroom’s CodeCompressor. The goal is to keep the structural
skeleton an agent needs to navigate a file — imports, type/function/class
signatures, top-level constants — while collapsing the deep bodies that
dominate byte count.
This module currently ships the language-agnostic brace-depth heuristic:
lines at brace nesting depth 0–1 are kept; deeper bodies collapse to a
{ … N lines … } placeholder. Lines carrying error/TODO markers are always
kept. A higher-fidelity tree-sitter path (Rust/TS/Python) is layered on in a
follow-up slice and selected by language; until then every language uses the
heuristic. The router offloads the original to CCR for exact recovery.
Structs§
Constants§
- MIN_
BODY_ LINES_ TO_ COLLAPSE - Bodies with more than this many collapsed lines get a placeholder; shorter ones are kept verbatim (collapsing tiny bodies isn’t worth the marker).
Functions§
- compress_
heuristic - Language-agnostic brace-depth compressor. Keeps lines at depth ≤ 1, collapses
deeper runs. Returns
Noneif it wouldn’t shrink the content.