MoonshotAI / MoonshotAI/kimi-code

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

Open
#3,253 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.