fix(count-tokens): include the prompt in the total when --mcp is used (#399)
ContextManager.makeSession deliberately excludes the final prompt from its transcript entries -- generation sends it separately -- so every other call site wraps the result in sessionInputEntries(builtEntries:finalPrompt:options:) to add it back (Handlers.swift, ResponsesHandlers.swift, Benchmark.swift). The --mcp branch of countTokens assigned the raw entries instead. So `apfel --count-tokens --mcp <server> "<prompt>"` reported the same total no matter how long the prompt was, which makes both the `fits` verdict and the reported budget headroom wrong -- exactly when a user is asking the one question this command exists to answer. Verified against the release binary with the calculator MCP server: short prompt: 794/3584 tokens 400 words: 1194/3584 tokens a delta of 400 where it was previously 0. Both the tools and no-tools entry sets are wrapped, so the mcp_tool_tokens subtraction stays consistent. Diff taken from candidate PR #417. Closes #399 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011ccLBbEaVVd4sJyUd5wyhA
A
Arthur Ficial committed
64966552c56b116a0bf5054bd2a50d54731396a9
Parent: 2350c08