SIGN IN SIGN UP

feat: Re-derive cost math to match ccusage 18.0.11 exactly

The in-app cost number drifted from `npx ccusage daily` by up to ~10% on
heavy days. Reverse-engineered ccusage's published bundle and rebuilt
the math from scratch to remove the ambiguity.

  • New SessionParseCacheV2 — global first-wins dedup on
    (message.id, requestId) across ALL files in earliest-timestamp
    order. Old cache double-counted ~70 resume-duplicated requests.
  • New PricingService — bundle + background-fresh hybrid sourcing from
    LiteLLM, with 200k-tier pricing and fast-mode multiplier (neither
    were modeled in the hardcoded table).
  • Subagent JSONLs (~/.claude/projects/<id>/subagents/*.jsonl) now
    counted toward cost. They were silently invisible before.
  • Tools/recalc_cost.swift — standalone reference impl, verified
    against ccusage row-by-row, cent-by-cent across 30 days.
  • Tools/verify_cost.sh — runnable pre-release gate. Stamps
    CCSwitcher/Resources/verified-against.json on PASS so the Cost tab
    can show "Verified against ccusage X on Y".
  • COST_VERIFICATION.md + docs/cost-verification-journey.html document
    the algorithm + all the surprising gotchas (published-vs-HEAD
    divergence, dead costUSD field, etc.).

Old SessionParseCache.swift kept compiled (no live callers) for one
release in case fast rollback is needed.
X
XueshiQiao committed
1822db3dd995182c8179d4fcfa4d699a65104d70
Parent: d3cc091