Per-session Claude Code token report WITH an estimated-thinking column.
The CCAssist dashboard (and the session files themselves) expose only the four
API usage fields: ``input_tokens``, ``output_tokens``,
``cache_creation_input_tokens``, ``cache_read_input_tokens``. Extended-thinking
tokens are billed INSIDE ``output_tokens`` and are recorded in no separate
field, so no subtraction of listed columns can recover them. This tool derives
the missing column with the residual method, verified empirically 2026-07-09
(session ``4f696339``: turns with ``output_tokens=39,365`` carrying only ~16k
tokens of visible text -> ~23k thinking; session-wide thinking ~= 83% of
output):
thinking(turn) ~= output_tokens - visible_chars/4 (floored at 0)
Two correctness details the naive approach gets wrong:
1. **Stream dedup.** Streamed assistant turns are appended to the session file
repeatedly with cumulative usage snapshots; summing every usage block
over-counts ~2.6x. We dedupe by ``message.id``, keeping the max
``output_tokens`` snapshot and the max visible-content length per turn.
2. **Visible content** = text blocks + serialized ``tool_use`` inputs (both are
billed output); thinking blocks are excluded (that is the point).
Usage:
python tools/cc_thinking_report.py # all projects
python tools/cc_thinking_report.py <project-dir> # one project dir name
# (e.g. g--PythonApps-OC-Chat)
Output: one row per session file (newest first) + a grand-total row.
Estimates are ~4 chars/token heuristics — a reporting aid, not billing truth.
Origin: operator question 2026-07-09 ("does total - sum(parts) give thinking?"
-- it cannot; this derives the real number). Kept as a reusable monitor.