Skip to content

Charge --ask tokens to the reserved budget - #4

Merged
fadiuniv1 merged 7 commits into
mainfrom
fix-budget-aware-ask
Nov 27, 2026
Merged

fadiuniv1 merged 7 commits into
mainfrom
fix-budget-aware-ask

Conversation

@fadiuniv1

@fadiuniv1 fadiuniv1 commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes #3.

--ask was appended after budgeting, so a long question could push the generated prompt past its token budget. The estimated tokens for the rendered question are now added to reserved, exposed as askTokens, and shown in the Markdown header.

Also fixes a pre-existing CI failure: changedFiles() computed the diff prefix with path.relative(), which can keep Windows 8.3 short names and disagree with Git's canonical root. It now asks Git for --show-toplevel and --show-prefix, then runs the diff from the repository root with a POSIX pathspec. --no-reserve and --budget 0 keep their existing behavior apart from the question itself being accounted for.

Tests

  • npm test — 48 passing on Windows, Node v24.15.0.
  • CI: 12/12 jobs green (Windows/macOS/Linux × Node 18/20/22/24).
  • Added three budget tests, an aliased-root regression and a subdirectory regression.
  • CLI smoke: node bin/contextpack.js . --budget 1000 --no-date --ask "<long question>" reports Reserved: ~385 tokens ... (includes ~265 for your question) with Estimated tokens: 612 / 1,000.
  • Updated README and CHANGELOG.

@fadiuniv1
fadiuniv1 merged commit ad09363 into main Nov 27, 2026
12 checks passed
@fadiuniv1
fadiuniv1 deleted the fix-budget-aware-ask branch November 27, 2026 15:30
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.

--ask text is not counted against the token budget

1 participant