feat(import): add ccusage import format (#1128)
Adds `--format ccusage` to `tokscale import`, alongside the clawdboard importer. Part of #888. `ccusage daily --json` is the export most people already have on disk, and it usually outlives `~/.claude/projects` after rotation — so it is the common recovery path for history that can no longer be re-scanned. Attribution resolves per model rather than per row, since a unified ccusage day merges every agent that ran into one row and names the participants only in `metadata.agents`. A model matching no listed agent is surfaced as `unknown` rather than folded into the first agent, because the leaderboard rejects `unknown` and a clean-looking wrong import is worse than a visible gap. Followed by a maintainer commit validating the parser against a real `cc.json` and against ccusage's documented schemas, which corrected four divergences: reasoning tokens counted twice (ccusage's `totalTokens` never includes them, so the buckets now hold the non-reasoning output remainder); reasoning read only from the flat spelling when the unified report nests it under `metadata`; an empty day-in-range row minting a phantom `unknown` client with a spurious rejection warning; and `ccusage-codex`'s `costUSD` spelling importing as $0. Agent names keeping a CLI suffix (`gemini-cli`) also failed to match their own models. The row's declared `totalTokens` is now reconciled as a cross-check. Known limit, documented in `resolve_client`: attribution splits by model family, not by the client that made the call, so a day listing both `claude` and `opencode` puts all Claude models on `claude`. Exact splitting needs ccusage's `--by-agent` rows. Verified: a real 14-day export round-trips to 267,186,765 tokens / $453.81, matching the file's own totals exactly. `cargo test --workspace` 3065 passed / 0 failed; clippy `-D warnings` and `cargo fmt --check` clean. Co-authored-by: Aron Lee <hello@intframe.com>
A
Aron Lee committed
25df658c08ca18ec07415d6495d06143fa29a52f
Parent: 9ba3bf7
Committed by GitHub <noreply@github.com>
on 8/15/2026, 4:56:28 PM