Repository navigation
Commit 791b377
feat(adapter/all): surface Copilot AI Credits as first-class field in --all aggregator
Plumbs Copilot's `totalNanoAiu`-derived credits through the
`ccusage daily --all` (and weekly / monthly / session) cross-source
aggregator as a first-class `credits: Option<f64>` field on
`AllRow` and `AllAccumulator`, so post-cutover AI-Credit-only days
no longer get silently dropped from `--all` totals.
Before this commit:
* `summary_rows` filter rejected any summary with `total_tokens == 0`,
which silently omitted Copilot's credit-only sessions
(`session.shutdown` events with zero tokens but positive
`totalNanoAiu` are real charges).
* `AllAccumulator::into_row` reset `metadata: None`, so credits
threaded through per-source loader metadata also got dropped on
aggregation.
After:
* **`summary_rows` filter relaxed** to drop only fully-empty
summaries (zero tokens AND zero cost AND zero/absent credits).
This is an **intentional cross-adapter behavior change** — it
also affects Claude (per-message `costUSD`) and Hermes
(`actual_cost`), which can produce zero-token + positive-cost
rows that were previously silently dropped from `--all`. The
invariant is pinned by
`summary_rows_relaxed_filter_applies_uniformly_across_non_copilot_agents`.
Worth a release-notes line since it changes existing non-Copilot
totals.
* **`AllRow::credits: Option<f64>`** — first-class field threaded
through `add_row`, `into_row`, and `merge_agent_breakdown`.
`Option` preserves the absent-vs-explicit-zero channel
distinction at the row layer.
* **`build_row_metadata` + `totals_json` credit injection** — the
JSON renderer surfaces `metadata.credits` per row (gated on
`Option::is_some`) and `totals.credits` (gated on SUM > 0.0,
raw `json!` for `5.0`-not-`5` byte-parity with the direct
per-agent renderer at `output.rs::totals_json`).
* **`load_copilot_rows`** — wraps the Copilot loader to run the
date filter inside `copilot::load_entries` before passing rows
on (required because the credit-only dedup key is content-based
and omits event_id, so the standard post-collapse filter could
silently drop in-range twins of out-of-range collisions).
OR-s `copilot::has_data()` into `detected` so the on-disk
signal survives the pre-filter, mirroring `qwen::has_data()`.
* **`finalize_session_mode_rows` helper** extracted from the
inline `kind == Session` clear so the renderer-side invariant
("no `agents` key in session-mode --all --json output") is
pinned by a dedicated test that mutation-fails when the clear
is removed.
Pinned by `summary_rows_keeps_zero_token_summaries_when_cost_or_credits_present`,
`summary_rows_treats_zero_credits_same_as_absent_credits`,
`summary_rows_relaxed_filter_applies_uniformly_across_non_copilot_agents`,
`totals_json_credits_uses_float_representation_matching_direct_renderer`,
`totals_json_omits_credits_when_all_credits_sum_to_zero`,
`build_row_metadata_does_not_inject_agents_for_session_mode_rows`,
`build_row_metadata_injects_agents_for_aggregated_all_rows`,
`finalize_session_mode_rows_clears_metadata_agents`,
`load_copilot_rows_keeps_copilot_in_detected_when_date_filter_excludes_all_data`,
and `load_copilot_rows_reports_not_detected_when_no_session_state_files_exist`.
Co-authored-by: Copilot <[email protected]>1 parent 2edea71 commit 791b377
6 files changed
Lines changed: 886 additions & 31 deletions
0 commit comments