Skip to content

How compression works

Every command runs through the same eight pure-function stages:

  1. strip_ansi — remove escape sequences.
  2. pattern_replace — rewrite known noise (download progress, hashes).
  3. output_match — keep only lines matching configured patterns (errors, summaries).
  4. line_select — apply per-rule include/exclude.
  5. truncate_lines — cap individual line length.
  6. head_tail_window — keep the first N and last M lines of long blocks.
  7. hard_cap — enforce a global maximum byte budget.
  8. empty_message — substitute a friendly summary if everything was stripped.

Each stage is a pure fn(&str) -> String, so the pipeline is trivially testable and can be replayed offline against captured fixtures.

If any stage errors, tok0 falls back to passing the raw output through unchanged. You never get blocked.