Skip to content

cc-economics: ccusage JSON parse fails (expects month, ccusage now emits period) #2731

Description

@mvanhorn

What happens

rtk cc-economics errors out:

Failed to parse ccusage JSON output: Invalid JSON structure for monthly data: missing field `month`

(rtk 0.43.0 / master, ccusage fetched via npx.)

Cause

Current ccusage emits period as the per-record key. Its monthly --json record keys are now:

period, inputTokens, outputTokens, cacheCreationTokens, cacheReadTokens, totalTokens, totalCost, ...

In src/analytics/ccusage.rs, the deserializer still requires the old key names:

  • MonthlyEntry.month
  • DailyEntry.date
  • WeeklyEntry.week

Since ccusage renamed the key to period, every record fails to deserialize and the whole feature is unusable. All three granularities are affected, not just monthly.

Expected vs actual

  • Expected: cc-economics renders spend-vs-savings.
  • Actual: hard parse error.

Suggested fix

Accept period as an alias for the existing key field on each granularity (backward-compatible with older ccusage that still emits month/date/week). PR incoming.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions