Skip to main content

Module table_compactor

Module table_compactor 

Source
Expand description

Generic aligned-column table compactor.

Many CLIs pad output into aligned columns (docker ps, kubectl get, ps aux, database shells). The padding is pure token waste: the alignment carries no information a model needs. This stage detects a shared column grid and collapses each separator run to exactly two spaces, preserving every cell byte-for-byte — cells keep their single internal spaces, so columns stay parseable.

The detector is deliberately strict so indentation-significant content (source code, YAML, diffs, pretty JSON) never triggers it:

  • at least 5 non-empty lines, none starting with whitespace
  • a column position must be gap-covered by every line (or past the line’s end) to count as a separator
  • at least one separator band where 80% of lines have a real run of two or more spaces

Structs§

TableCompactResult
Result of a successful compaction.

Functions§

compact_aligned_table
Detect an aligned-column table in text and collapse the alignment padding. Returns None when the content does not look like a table or when compaction would not shrink it.