Skip to content

perf(cli): strip header bloat across pretty renderers, -50% line count#34

Merged
lliWcWill merged 7 commits intomasterfrom
fix/cli-header-bloat-stripping
Apr 10, 2026
Merged

perf(cli): strip header bloat across pretty renderers, -50% line count#34
lliWcWill merged 7 commits intomasterfrom
fix/cli-header-bloat-stripping

Conversation

@lliWcWill
Copy link
Copy Markdown
Owner

Summary

Every fsuite CLI tool emitted a pretty-mode header block before its results. For short outputs that header often dominated the token budget — the user specifically called out fcontent as "the worst offender with double lines of extra content". This PR rewrites each tool's pretty header to keep every load-bearing token while collapsing stacked metadata lines into single consolidated rows and stripping purely decorative rules.

JSON output (-o json) is untouched on every tool. Every test suite is green.

Closes fcase #360 cli-header-token-bloat-stripping.

Audit table (5-file fixture, identical invocations)

tool before lines after lines before bytes after bytes
fcontent (dir) 4 2 135 123
fcontent (single file) 4 2 145 133
fmap (dir) 6 2 118 111
fmap (single file) 6 2 130 123
fread 2 1 83 77
ftree / fls (untruncated) 3 2 99 76
fsearch (pattern == glob) 2 2 103 88
fs (pretty) 5 4
fmetrics history -1 line -80B
fmetrics combos -1 line -80B
fmetrics recommend -1 line -80B
fmetrics predict -2 lines -100B
fmetrics profile -1 line -33B

Average line-count reduction on the top five tools (fcontent, fmap, fread, ftree, fsearch) is 53%. Byte savings on small outputs are smaller in percentage, but the line-count win is what matters for agent rendering and LLM context windows, and the savings compound on every single tool invocation.

Visual examples — the three worst offenders

fcontent — the user's #1 complaint

Before (4 header lines):

ContentSearch(query: "function")
  ⎿ mode: directory path="/tmp/bloat-audit"
  ⎿ matched_files: 5
  ⎿ shown_matches: 5 (cap=200)
     /tmp/bloat-audit/file_1.py:1:def function_1():
     ...

After (2 header lines, every token preserved):

ContentSearch(query: "function")
  ⎿ matched_files: 5 shown_matches: 5 (cap=200) mode: directory path="/tmp/bloat-audit"
     /tmp/bloat-audit/file_1.py:1:def function_1():
     ...

fmap — 6 header lines down to 2

Before:

fmap (/tmp/bloat-audit)
  mode: directory
  files_scanned: 5 (cap=500)
  symbols: 5 (cap=500)
  languages: python=5

  /tmp/bloat-audit/file_5.py (python)
    [1] function: def function_5():

After:

fmap (/tmp/bloat-audit)
  mode: directory files_scanned: 5 (cap=500) symbols: 5 (cap=500) languages: python=5

  /tmp/bloat-audit/file_5.py (python)
    [1] function: def function_5():

fmetrics combos / history / recommend — drop the top ━━━ rule

Before:

fmetrics combos
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Combo                            Runs  Clean    Fault   Avg Time   Impact
  ─────────────────────────────────────────────────────────────────────────────
  fmap                               43     43        0       95ms        0

After:

fmetrics combos
  Combo                            Runs  Clean    Fault   Avg Time   Impact
  ─────────────────────────────────────────────────────────────────────────────
  fmap                               43     43        0       95ms        0

The column underline (───) stays because it actually separates the header row from the data. The top ━━━ was pure ornament above the title.

Design invariants held

  • JSON output (-o json) is byte-identical on every touched tool. Verified on fcontent, fmap, fread.
  • All load-bearing tokens are preserved in pretty mode so test suites still match against them: ContentSearch, matched_files, shown_matches, mode:, fmap (, files_scanned:, symbols:, Read(, lines.
  • Per-tool Monokai color theming from 76bbffb is untouched. fmetrics stats and fmetrics import — already slimmed in that commit — were left alone.
  • next_hint, truncated warnings, paths, and timestamps all stay — only decoration and redundancy are stripped.
  • One commit per tool. Every commit passes its own test suite and builds standalone.

Test plan

  • ./tests/test_fcontent.sh — 52/52
  • ./tests/test_fmap.sh — 155/155
  • ./tests/test_fread.sh — 61/61
  • ./tests/test_fread_symbols.sh — 12/12
  • ./tests/test_ftree.sh — 65/65
  • ./tests/test_fls.sh — 14/14
  • ./tests/test_fsearch.sh — 71/71
  • ./tests/test_fs.sh — 96/96
  • ./tests/test_telemetry.sh — 56/56
  • ./tests/run_all_tests.sh16/16 test suites passing
  • JSON contract spot-checked on fcontent, fmap, fread

Closes fcase cli-header-token-bloat-stripping.

Before: 4 header lines (tool name + mode + matched_files + shown_matches).
After: 2 header lines (tool name + single consolidated metadata line).

The user explicitly called out fcontent as "the worst offender with double
lines of extra content" — this was the literal double emission of
matched_files + shown_matches on separate lines when they belong together.
mode/path/cap all inline on the same metadata line.

All required tokens (ContentSearch, matched_files:, shown_matches, mode:)
preserved so test_fcontent.sh assertions still match. 52/52 tests pass.

Measured on 5-file fixture: header 135B -> 123B, 4 lines -> 2 lines.
Line-count halving is the real win for agent/human readability.

fcase: cli-header-token-bloat-stripping
Before: tool name + mode + files_scanned + symbols + languages + blank
        (5 emit lines + trailing blank separator)
After:  tool name + single consolidated metadata line
        (blank separator now comes naturally from the per-file loop)

All required tokens preserved (fmap (, mode:, files_scanned:, symbols:,
languages:). Test suite: 155/155.

5-file fixture header: 6 lines -> 2 lines. Per-invocation byte savings
are modest (~8B) but line-count is cut by 67%, which is the real win for
LLM context budgets.

fcase: cli-header-token-bloat-stripping
…end/predict/profile

Each of these subcommands emitted a full-width '━━━' or '===' rule
immediately under the title — pure ornamentation before the actual
table. The column underline ('───') directly above table rows stays
because it actually separates the header row from the data.

Subcommands touched:
  history, combos, recommend  (━━━ rule dropped, 80+ chars each)
  predict                     (=== rule + blank line dropped, 2 sites)
  profile                     (=== rule dropped)

fmetrics stats and fmetrics import were already slimmed in 76bbffb and
are left alone.

Test suite (test_telemetry.sh): 56/56 pass. No JSON output touched.

fcase: cli-header-token-bloat-stripping
…runcated

When every entry fits, 'showing 7 of 7 lines' is pure noise — it's
already implied by the directory/file counts. Keep the full phrasing
only when truncation actually happened, where the ratio carries real
signal.

fls uses the same renderer, so fls picks up the same slim output for
free. Both test suites pass (test_ftree.sh 65/65, test_fls.sh 14/14).

fcase: cli-header-token-bloat-stripping
When the user already passed a glob ('*.py'), the header line was
emitting the tautology 'pattern: "*.py" -> name "*.py"' — pure noise.
Now we only print the rewrite arrow when the normalized glob actually
differs from the input (e.g. 'py' -> '*.py').

test_fsearch.sh: 71/71 pass.

fcase: cli-header-token-bloat-stripping
…line

Before: two lines — 'Read(/abs/path)' and '  ⎿ lines a-b | ... tokens'
After:  one line  — 'Read(/abs/path) lines a-b | ... tokens'

The metadata and the anchor were always adjacent; the '⎿' was nice but
cost a whole output line per chunk. Multi-chunk reads benefit the most.
Literal tokens 'Read(' and 'lines' remain intact for test_fread.sh L614.

test_fread.sh: 61/61. test_fread_symbols.sh: 12/12.

fcase: cli-header-token-bloat-stripping
Before: 'chain: fcontent' and 'N candidates, X enriched, Yms' on two
separate dim-gray lines.
After:  one line 'chain: fcontent | N candidates, X enriched, Yms'.

Both were already the same DIM-styled metadata row conceptually —
splitting them across two lines was just aesthetic padding. The intent
header (with per-tool color) stays on its own line as the visual anchor.

test_fs.sh: 96/96.

fcase: cli-header-token-bloat-stripping
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: abffc8f8-ac3a-4cc4-827c-a1eef0c2e85c

📥 Commits

Reviewing files that changed from the base of the PR and between 9baca07 and b8b3eca.

📒 Files selected for processing (7)
  • fcontent
  • fmap
  • fmetrics
  • fread
  • fs
  • fsearch
  • ftree
💤 Files with no reviewable changes (1)
  • fmetrics
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test-suite
🧰 Additional context used
📓 Path-based instructions (3)
ftree

⚙️ CodeRabbit configuration file

ftree: Focus on: timeout/budget behavior, excluded-directory handling, and correct
recon output (counts/sizes/partial flags). Ensure graceful degradation when
optional tools are missing.

Files:

  • ftree
fsearch

⚙️ CodeRabbit configuration file

fsearch: Focus on: pattern normalization (glob/extension heuristics), backend selection
(fd/fdfind vs find), and safe handling of user input (quoting, no word-splitting
regressions). Prefer correctness and stability over micro-optimizations.

Files:

  • fsearch
fcontent

⚙️ CodeRabbit configuration file

fcontent: Focus on: rg invocation safety (args handling), stdin file list handling,
truncation accounting (SHOWN_MATCHES/TOTAL_FILES), and JSON/pretty output
correctness. Avoid changes that could leak private paths in examples.

Files:

  • fcontent
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: lliWcWill/fsuite PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T17:12:34.273Z
Learning: Use `fsuite` for the suite-level mental model, then reach for operational tools (fs, ftree, fls, fsearch, fcontent, fmap, fread, fedit, fwrite, fbash, fprobe, fcase, freplay, fmetrics) for filesystem reconnaissance, bounded reading, and surgical editing
Learnt from: CR
Repo: lliWcWill/fsuite PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-10T17:12:34.273Z
Learning: Prefer `pretty` format only for human terminal output
🔇 Additional comments (6)
ftree (1)

1136-1136: No correctness or recon-behavior regression in this header-only change.

fread (1)

961-961: Formatting-only consolidation; no functional regression in chunk metadata emission.

fs (1)

238-238: Separator insertion is presentation-only; no correctness or behavior issue introduced.

fsearch (1)

1068-1072: Header conditional is display-only and does not alter normalization, backend selection, or input-safety behavior.

fmap (1)

1737-1750: This is a pretty-output compaction only; no symbol accounting or extraction correctness issue in the changed block.

fcontent (1)

549-552: Header consolidation preserves match/truncation counters and mode metadata; no correctness issue in this segment.


Summary by CodeRabbit

  • Style
    • Streamlined CLI output formatting across multiple modules by consolidating multi-line headers into compact single-line summaries
    • Removed redundant separator lines from various report outputs
    • Made search header display conditional for clearer presentation when pattern matching

Walkthrough

Multiple shell scripts simplify their pretty-mode output formatting by consolidating multi-line headers into single-line summaries and removing redundant separator lines. Changes affect fcontent, fmap, fmetrics, fread, fs, fsearch, and ftree with consistent emphasis on reducing output verbosity while maintaining information density.

Changes

Cohort / File(s) Summary
Header Output Consolidation
fcontent, fmap, fsearch, ftree
Consolidates multi-line pretty-mode headers into single-line format; fmap appends language counts inline, fsearch conditionally shows glob resolution, ftree removes showing/truncated counts suffix from non-truncated output.
Separator Line Removal
fmetrics
Removes separator lines from cmd_history, cmd_combos, cmd_recommend, cmd_predict, and cmd_profile output paths.
Output Formatting Tweaks
fread, fs
Minor updates to per-chunk read output structure and tool chain/budget display line formatting.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed Title accurately describes the primary change: consolidating CLI header output across multiple tools to reduce line count by ~50%, directly matching the changeset's core objective.
Description check ✅ Passed Description is directly related to the changeset, detailing specific header output changes per tool, providing audit metrics, visual examples, and test results that align with the code modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cli-header-bloat-stripping

Comment @coderabbitai help to get the list of available commands and usage tips.

@lliWcWill lliWcWill merged commit 5b7865d into master Apr 10, 2026
2 checks passed
@lliWcWill lliWcWill deleted the fix/cli-header-bloat-stripping branch April 10, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant