Skip to main content

Module report

Module report 

Source
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.
ReportOptions
Filtering options shared by the report builders.
ReportRow
One rendered row. Columns are selected per ReportKind by the renderer.

Enums§

AgentFilter
Which agents to include.
Period
Time grouping for time_report.
ReportKind
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 --instances view.
model_report
Per-model breakdown (global, both agents merged by model id).
normalize_date_arg
Normalize a user date arg (YYYYMMDD or YYYY-MM-DD) to YYYY-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.