fix(cli): count the full-output envelope for TOON/YAML token counts

With --token-count --full-output, TOON and YAML results were delegated
to Incur before the envelope-aware count branch, so Incur counted only
the selected data (13) instead of the emitted full document (31).
Keep that combination on the REA output boundary so the count covers
the envelope and metadata, matching the docs/cli.md contract. Bare
counts stay delegated to Incur and are unchanged.

Fixes #7271
Supersedes #7278

Co-authored-by: Saim Shafique <128062316+sx4im@users.noreply.github.com>
Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
This commit is contained in:
authored and Ysopwnable committed 2026-11-14 14:16:39 +01:00
1 parent 86799f919d
commit a02202aba2
2 files changed
+70 -2

No files matched your search

+5 -2
View File
@@ -632,7 +632,9 @@ export const createCliResultOutput = (
format !== "json" &&
format !== "jsonl";
// Delegate other human formats to Incur. Markdown stays here so admission
// and emitted table text use the same safe formatter.
// and emitted table text use the same safe formatter. A full-output token
// count stays here too: Incur counts only the selected data, so delegating
// it would report the bare result instead of the emitted envelope.
if (
!metadata.forceOutput &&
format !== "md" &&
@@ -640,7 +642,8 @@ export const createCliResultOutput = (
format !== "jsonl" &&
operationFailure === undefined &&
!ownsFilteredOutput &&
!ownsSuccessfulTokenWindow
!ownsSuccessfulTokenWindow &&
!(options.tokenCount && options.fullOutput)
)
return false;
if (format === "jsonl") {