perf(cli): strip header bloat across pretty renderers, -50% line count#34
perf(cli): strip header bloat across pretty renderers, -50% line count#34
Conversation
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
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (7)
💤 Files with no reviewable changes (1)
📜 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)
🧰 Additional context used📓 Path-based instructions (3)ftree⚙️ CodeRabbit configuration file
Files:
fsearch⚙️ CodeRabbit configuration file
Files:
fcontent⚙️ CodeRabbit configuration file
Files:
🧠 Learnings (1)📓 Common learnings🔇 Additional comments (6)
Summary by CodeRabbit
WalkthroughMultiple 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
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
fcontentas "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)
fcontent(dir)fcontent(single file)fmap(dir)fmap(single file)freadftree/fls(untruncated)fsearch(pattern == glob)fs(pretty)fmetrics historyfmetrics combosfmetrics recommendfmetrics predictfmetrics profileAverage 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):
After (2 header lines, every token preserved):
fmap — 6 header lines down to 2
Before:
After:
fmetrics combos / history / recommend — drop the top
━━━ruleBefore:
After:
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
-o json) is byte-identical on every touched tool. Verified on fcontent, fmap, fread.ContentSearch,matched_files,shown_matches,mode:,fmap (,files_scanned:,symbols:,Read(,lines.76bbffbis untouched.fmetrics statsandfmetrics import— already slimmed in that commit — were left alone.next_hint,truncatedwarnings, paths, and timestamps all stay — only decoration and redundancy are stripped.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.sh— 16/16 test suites passingCloses fcase
cli-header-token-bloat-stripping.