Repository navigation
Commit f268798
fix(cli): apply source-specific config in unified reports (ccusage#1959)
* fix(cli): carry per-source options on unified report args
A unified report loads every source, and the config can address one
source at a time through `<source>.defaults`,
`<source>.commands.<report>` and `commands.<source>:<report>`. Give
`AgentCommandArgs` a place for the options each source resolves to,
keyed by agent name, so the binary can fill it and the unified loader
can read it. Nothing fills it yet, so behavior is unchanged.
Refs ccusage#1957
* fix(config): expose a source's view of the config for unified reports
`option_maps` reads `<agent>.defaults`, `<agent>.commands.<report>` and
`commands.<agent>:<report>` only when the parsed command names an
agent, so a unified report never sees them. Add
`ConfigContext::for_source`, which returns the config as
`ccusage <agent> <report>` reads it, and `None` when the file does not
address that agent. The binary uses it to resolve the options each
source of a unified report loads with.
Refs ccusage#1957
* fix(cli): resolve source config sections for unified reports
`ccusage daily` and the other unified reports handed every source the
same shared options, so `<source>.defaults`,
`<source>.commands.<report>` and `commands.<source>:<report>` only
reached the focused `ccusage <source> <report>`. The docs describe
those sections as applying to unified reports too, and the TypeScript
CLI merged one option set per agent before loading.
The binary now resolves one `SourceArgs` per source the config
addresses: the same command line parsed against that source's view of
the config, so flags keep precedence over config as they do for the
focused command, and `--last` and the timezone check apply per source.
The Codex speed and the pi and OpenClaw paths come from the same view.
A bare `ccusage` is resolved into the unified daily command in the
binary before the sources are attached, so `main` dispatches on a
`Command` rather than on an optional one.
Refs ccusage#1957
* fix(cli): load each unified source with its own options
Hand the per-source options resolved by the binary to the unified
loader: each source loads with its own shared options (date window,
cost mode, timezone, debug), Codex uses the configured speed, and pi
and OpenClaw read their configured paths, so `ccusage daily` sees a
source the way `ccusage <source> daily` does. A source the config does
not address keeps the unified options, and the pricing table the
sources share is still built from the unified options.
Closes ccusage#1957
* docs(config): say where unified reports read pricing options from
Unified reports now apply source sections, as the config guide already
says, but the pricing table the sources share is built from the
unified options. Tell readers to keep `offline` and `pricingOverrides`
under `defaults` or `commands.<report>` when they should reach every
source.
Refs ccusage#1957
* test(cli): cover unified source config across report modes
Verify source defaults, report sections, colon command sections, and command-line precedence for unified reports.
Co-authored-by: viniciusdsandrade <[email protected]>
* chore: format imported source configuration changes
Apply the repository formatter to the imported config and unified report tests.
Co-authored-by: viniciusdsandrade <[email protected]>
* fix(cli): honor source pricing and validate custom pi stores
Cache pricing by resolved source options so offline mode and overrides
reach each loader without leaking rates between sources. Keep named pi
stores on unified options and reject overlaps with the configured pi path.
Cover Fast Codex pricing with and without date bounds, independent source
rates, OpenClaw paths, pi collisions, and named-store behavior with fixtures.
Co-authored-by: viniciusdsandrade <[email protected]>
* docs(config): clarify unified source pricing and section options
Describe source pricing overrides, timezone grouping, and the invoked-command settings used by additional report sections.
Co-authored-by: viniciusdsandrade <[email protected]>
* test(cli): isolate unified report fixtures from host data
Keep source directories and XDG paths inside each fixture so local tests cannot scan or count usage from the host environment.
Co-authored-by: viniciusdsandrade <[email protected]>
* docs: clarify unified source configuration contracts
List the public source options, document colon-form config precedence,
and state the override-free base requirement for pricing copies.
Co-authored-by: viniciusdsandrade <[email protected]>
* fix(cli): preserve unified source configuration semantics
Use unified week starts for source windows and name the source in config
errors. Carry Claude project filters and skip unused shared pricing maps.
Cover source-aware sections and space-form config, and clarify named pi
store settings. Keep existing report failure and section behavior.
Co-authored-by: viniciusdsandrade <[email protected]>
* fix(cli): apply global agent defaults to unified sources
Seed Codex speed and Pi/OpenClaw paths from global config before applying
source-specific sections. Preserve shared CLI options and avoid creating
entries for unrelated sources.
Cover default and named reports, global report options, and precedence.
Co-authored-by: viniciusdsandrade <[email protected]>
---------
Co-authored-by: Vinícius DS Andrade <[email protected]>1 parent ae3e07d commit f268798
15 files changed
Lines changed: 1827 additions & 145 deletions
File tree
- docs/guide
- rust/crates
- ccusage-adapter-all/src
- ccusage-cli-parser/src
- ccusage-cli
- src
- ccusage-config/src
- ccusage-core/src
- ccusage/src
- cli
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
| 290 | + | |
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
295 | 297 | | |
296 | 298 | | |
297 | 299 | | |
298 | | - | |
299 | | - | |
300 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
301 | 304 | | |
302 | 305 | | |
303 | 306 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | | - | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | | - | |
| 66 | + | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| |||
0 commit comments