Expand description
Tabular usage/cost reports built from a UsageSnapshot.
This is the data layer behind the terminal CLI’s daily / weekly /
monthly / session / --instances / --breakdown verbs (and reusable
by any other surface). It does no rendering and pulls in no terminal
crates — it only reshapes the engine’s already-priced buckets into rows.
Cost-model note (see docs/ai/COST_MODEL.md): the Total column here is
ccusage’s “Total Tokens” = input + output + cache_creation + cache_read,
which is DISTINCT from the Stats/HUD tokens total (fresh_in + output).
Per-row cost is the engine’s per-turn estimate, summed; we never re-price.
Structs§
- Metrics
- The four token buckets plus derived total and cost. Accumulates cleanly.
- Report
- A complete report: rows + grand total + pricing provenance.
- Report
Options - Filtering options shared by the report builders.
- Report
Row - One rendered row. Columns are selected per
ReportKindby the renderer.
Enums§
- Agent
Filter - Which agents to include.
- Period
- Time grouping for
time_report. - Report
Kind - What flavor of report this is — drives column selection in the renderer.
- RowKind
- Role of a row in the rendered table.
Functions§
- instances_
report - Per (date × project) report — the
better-ccusage daily --instancesview. - model_
report - Per-model breakdown (global, both agents merged by model id).
- normalize_
date_ arg - Normalize a user date arg (
YYYYMMDDorYYYY-MM-DD) toYYYY-MM-DD. - session_
report - Recent-sessions report (both agents merged, newest first).
- time_
report - Build a daily/weekly/monthly report: per-period “All” rows with per-agent sub-rows, sorted chronologically, ending in a grand-total row.