Skip to content

fix(md): --all should emit the whole page instead of stopping at the default budget - #54

Merged
yusukebe merged 1 commit into
yusukebe:mainfrom
kiakiraki:fix/md-all-budget
Jul 25, 2026
Merged

fix(md): --all should emit the whole page instead of stopping at the default budget#54
yusukebe merged 1 commit into
yusukebe:mainfrom
kiakiraki:fix/md-all-budget

Conversation

@kiakiraki

Copy link
Copy Markdown
Contributor

Problem

--md always passes budget: opts.budget || 2000 to emitLines, and cap() in
src/lib/emit.ts only skips --limit when --all is set — the budget is applied
either way. So --md --all is still cut at ~2000 tokens, and the truncation note
points the user at --all, which is already set:

$ ax big.html --md --all | grep -c 'paragraph number'   # page has 300 paragraphs
121
$ ax big.html --md --all 1>/dev/null
ax: note: 357 more result(s) hidden — continue with --offset 242 (or --all, --limit N, --budget T)

Every other mode (--row, --table, --text, --outline) emits everything under
--all; --md was the only asymmetric one. The only way to read a long page in
full was to guess a large explicit --budget.

Fix

Treat the 2000 tokens as a default, not a floor — src/commands/root.ts:

const budget = opts.all || opts.budget > 0 ? opts.budget : 2000
return emitLines(md.split('\n'), { ...opts, budget })
  • --all → no budget, whole page (and no note claiming something is hidden)
  • explicit --budget T → T wins, as on every other path through cap()
  • neither → unchanged, ~2000 tokens

--help now states the default on the --md line, since it is conditional.

I did not make cap() ignore the budget when --all is set: --all (drop the
result-count cap) and --budget (token ceiling) are orthogonal, and that change
would silently alter --row --all --budget T for every mode.

Verification

300 paragraphs of ~60 chars:

command before after
--md --all 121 paragraphs + 357 more result(s) hidden 300 paragraphs, no note
--md 25 paragraphs (--limit 50) unchanged
--md --all --budget 200 12 paragraphs unchanged (explicit budget respected)

Tests

Two cases in test/cli.test.ts (147 pass, oxfmt --check and tsc --noEmit clean):

  • --md --all emits the whole page with no note, and --all --budget 200 still truncates
  • --md alone stays capped by the default budget — long-prose fixture whose line count
    never reaches --limit 50, so a regression that drops the default would fail here

🤖 Generated with Claude Code

--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>

@yusukebe yusukebe left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yusukebe

Copy link
Copy Markdown
Owner

@kiakiraki This is an actual bug. Nice fix. Thanks!

@yusukebe
yusukebe merged commit fca619c into yusukebe:main Jul 25, 2026
3 checks passed
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.

2 participants