MoonshotAI / MoonshotAI/kimi-code
CLI: expose session/model usage report as JSON (headless stats command)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the /usage flow through UsagePanelComponent and the SDK SessionUsage/TokenUsage types, then compare it with usage.record accounting in wire.jsonl. Define a headless stats entry point and JSON shape that matches the TUI’s per-session and per-model report, including recent-day buckets; done means external tooling can consume the report without parsing wire.jsonl.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- analytics, cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100