What do you want to change?
Two additive flags on the unified commands:
--sections daily,monthly,session — emit several groupings in one JSON envelope from a single run, instead of one invocation per section.
--by-agent — include the per-agent breakdown on each unified row, instead of one invocation per agent.
With no flags, output stays byte-identical to today.
Why?
I poll ccusage from an app that wants daily, monthly, and session views plus per-agent detail. Today that's 3 unified invocations plus one per agent — each one re-scanning every store, re-parsing every file, and re-loading pricing, even though daily/weekly/monthly are all derived from the same entries. With a dozen agents that's ~15 full pipeline runs per refresh, and it gets slower as stores grow.
There's also a consistency problem: agents append to their stores constantly, so sections fetched by separate invocations can disagree with each other (the session total moves between call 1 and call 3). One invocation reads the stores once, so everything in the envelope is from the same snapshot.
The per-agent side is the same story: the unified run already computes per-agent breakdowns internally and throws them away at serialization time.
How? (optional)
--sections maps to at most two store scans (daily/weekly/monthly share one load; session adds one), and each section is produced by the same code path its standalone command uses, so section output matches a standalone run exactly. --by-agent serializes the existing internal per-agent accumulator as an agents array on daily/weekly/monthly rows (session rows are already per-agent). Table output renders requested sections sequentially; --by-agent is JSON-only.
I have this implemented — tests include fixture equivalence against standalone runs and a no-flags byte-identical check — and can open a PR.
What do you want to change?
Two additive flags on the unified commands:
--sections daily,monthly,session— emit several groupings in one JSON envelope from a single run, instead of one invocation per section.--by-agent— include the per-agent breakdown on each unified row, instead of one invocation per agent.With no flags, output stays byte-identical to today.
Why?
I poll ccusage from an app that wants daily, monthly, and session views plus per-agent detail. Today that's 3 unified invocations plus one per agent — each one re-scanning every store, re-parsing every file, and re-loading pricing, even though daily/weekly/monthly are all derived from the same entries. With a dozen agents that's ~15 full pipeline runs per refresh, and it gets slower as stores grow.
There's also a consistency problem: agents append to their stores constantly, so sections fetched by separate invocations can disagree with each other (the session total moves between call 1 and call 3). One invocation reads the stores once, so everything in the envelope is from the same snapshot.
The per-agent side is the same story: the unified run already computes per-agent breakdowns internally and throws them away at serialization time.
How? (optional)
--sectionsmaps to at most two store scans (daily/weekly/monthly share one load; session adds one), and each section is produced by the same code path its standalone command uses, so section output matches a standalone run exactly.--by-agentserializes the existing internal per-agent accumulator as anagentsarray on daily/weekly/monthly rows (session rows are already per-agent). Table output renders requested sections sequentially;--by-agentis JSON-only.I have this implemented — tests include fixture equivalence against standalone runs and a no-flags byte-identical check — and can open a PR.