fix(md): --all should emit the whole page instead of stopping at the default budget - #54
Merged
Merged
Conversation
--md passed `budget: opts.budget || 2000` to emitLines regardless of --all, and cap() only skips --limit for --all, so `--md --all` was still cut at ~2000 tokens — and the truncation note pointed at --all, which was already set. Apply the 2000-token default only when neither --all nor an explicit --budget is given; an explicit --budget keeps winning, as on every other emit path. Also document the default in --help, since it is now conditional. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Owner
|
@kiakiraki This is an actual bug. Nice fix. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
--mdalways passesbudget: opts.budget || 2000toemitLines, andcap()insrc/lib/emit.tsonly skips--limitwhen--allis set — the budget is appliedeither way. So
--md --allis still cut at ~2000 tokens, and the truncation notepoints the user at
--all, which is already set:Every other mode (
--row,--table,--text,--outline) emits everything under--all;--mdwas the only asymmetric one. The only way to read a long page infull was to guess a large explicit
--budget.Fix
Treat the 2000 tokens as a default, not a floor —
src/commands/root.ts:--all→ no budget, whole page (and no note claiming something is hidden)--budget T→ T wins, as on every other path throughcap()--helpnow states the default on the--mdline, since it is conditional.I did not make
cap()ignore the budget when--allis set:--all(drop theresult-count cap) and
--budget(token ceiling) are orthogonal, and that changewould silently alter
--row --all --budget Tfor every mode.Verification
300 paragraphs of ~60 chars:
--md --all357 more result(s) hidden--md--limit 50)--md --all --budget 200Tests
Two cases in
test/cli.test.ts(147 pass,oxfmt --checkandtsc --noEmitclean):--md --allemits the whole page with no note, and--all --budget 200still truncates--mdalone stays capped by the default budget — long-prose fixture whose line countnever reaches
--limit 50, so a regression that drops the default would fail here🤖 Generated with Claude Code