release: v4.2.0 — real token counts, race-free hooks, cost-math fixes#42
Merged
Conversation
Ground truth: - New src/transcript-usage.js: budget hook reads exact API token usage from the session transcript (transcript_path); budget % and /cco show real context usage, chars-per-token estimation stays as fallback. Fixes: - /cco-digest printed $NaN in the whole cost table (tokens * MODEL_COSTS object) — same class as the earlier roi/report fixes; alias rows deduped, column alignment fixed. - /cco-export and /cco-claudemd overstated costs 3x (hardcoded legacy $15/M). - benchmark/run.js passed file contents where parseFileStructure() expects a path — every digest scenario measured an empty structure; results.json regenerated with honest numbers. - /cco-roi printed Infinityx at 100% waste — clamped. - tracker+budget hooks ran in parallel on the same PostToolUse matcher and raced on the shared notice ledger — serialized into one chained command (same for SessionEnd tracker → dashboard). - Concurrent session finalization clobbered global-stats/patterns (last-writer-wins) — guarded by an atomic mkdir-based file lock with stale-steal. - prompt-coach log: true appendFileSync instead of O(n²) read+rewrite. - read-cache: legacy entries without ranges/lines no longer throw and silently disable caching. - Session summaries: local wall-clock time instead of raw UTC. Perf: - getFileLines() estimates >1MB files from size instead of slurping them on the hook hot path. - Read token estimates capped by real file size + extension-aware ratio (~4x more accurate). - Bounded per-session state: budget filesLoaded (500), tracker search log (300). Honesty: - "Session pulse" goes through the notice ledger: respects the noise cap, counts as overhead in NET savings. Docs/packaging: - README: missing /cco-roi + tree entries added, stale v4.0.0 fixed here and in docs/index.html; POSIX-shell requirement documented. - sync-version.js also syncs marketplace.json and docs/index.html. - Junk CHANGELOG-notes.md removed; real CHANGELOG.md added. Tests: 139 → 150 (NaN-class regression, size-aware estimates, transcript usage parsing, file-lock exclusivity/stale-steal, tracker caps). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Full audit of the plugin (3 parallel deep reviews) + fixes + one new capability, shipped as v4.2.0.
Ground truth (new)
src/transcript-usage.js— the budget hook now reads exact API token usage from the Claude Code session transcript (transcript_pathis on every hook event). Budget % and the/ccoboard show real context usage; chars-per-token estimation remains the fallback. Real numbers drop the~prefix.Fixed
$NaNacross the/cco-digestcost table (same bug class as fix(report): repair cco-report crash (syntax error) and $NaN cost figures #29/fix(roi): repair $NaN / [object Object] in cco-roi cost table #31, missed in digest.js)/cco-export+/cco-claudemdoverstated costs 3× (hardcoded legacy $15/M vs $5/M source of truth)results.jsonregenerated honestlyInfinityxin/cco-roiat 100% wastePerf
Docs
CHANGELOG.md; README drift fixed (/cco-roi, trees, versions);sync-version.jsnow covers marketplace.json + docsTest plan
npm test: 150/150 (was 139), incl. new regressions for the NaN class, transcript parsing, lock exclusivity/stale-steal, tracker caps🤖 Generated with Claude Code