Skip to content

CLI: expose session/model usage report as JSON (headless stats command) #3253

Description

@emiliano-go

What feature would you like to see?

The TUI already aggregates per-session and per-model token usage (/usage, UsagePanelComponent, SDK SessionUsage/TokenUsage). External tooling has no access to this, it currently requires parsing raw wire.jsonl files and re-implementing usage.record accounting (inputOther/output/cacheRead/cacheCreation, turn-scoped).

Proposal

A headless flag/command, e.g. kimi stats --json or --usage-report=json, reusing the same internal aggregation that feeds /usage. Shape would mirror what the TUI renders plus recent-day buckets.

Motivation: dashboards/status bars tracking agent spend across agents (concrete consumer: Omarchy's system panel aggregating OpenCode/Kimi/Claude usage uniformly).

Happy to send a PR, as the changes have already been done in my local fork for personal usage.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions