Skip to content

fix: ccusage doesn't pick up kimi code #1247

Description

@nathanAtHeadfwd

What do you want to change?

While working with ccusage, my Kimi code usage wasn't picked up. I found that the one shipped looks in a directory that isn't available and that it looks for a different structure than what 0.14.0 is using.

The bigger issue, though, is that even if you pointed it at ~/.kimi-code with the env var, it still wouldn't work because the parser was built for a completely different wire format. It expected:

  {"message":{"type":"StatusUpdate","payload":{"token_usage":{"input_other":100,"output":50}}}}                                                                                                                                              

But Kimi Code CLI writes:

  {"type":"usage.record","usage":{"inputOther":100,"output":50},"time":1780925702183}                                                                                                                                                        

Why?

This Adds kimi code results with proper lookup and costs.

Image

How? (optional)

The fix extends the existing Kimi adapter to recognize both the legacy wire format and Kimi Code CLI's format.

  • Path resolution: search ~/.kimi-code in addition to ~/.kimi, and accept the deeper path nesting sessions/{workspace}/{session}/agents/{agent}/wire.jsonl.

  • Parser: handle two event shapes in the same wire file:
    • Legacy StatusUpdate with snake_case token_usage fields and second-based timestamps
    • Kimi Code CLI usage.record with camelCase usage fields (inputOther, inputCacheRead, etc.) and millisecond timestamps

  • Model mapping: strip the kimi-code/ prefix from model names so pricing lookups resolve correctly.

  • Session extraction: walk up from the sessions directory component so the session ID is correct for both flat and deep directory layouts.

Activity

  1. pullfrog commented on Jun 10, 2026

    @pullfrog
    Contributor
  2. github-actions commented on Jun 10, 2026

    @github-actions
    Contributor

    This issue was auto-closed. Issues from new contributors are auto-closed by default.

    Maintainers review auto-closed issues and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md may not be reopened or receive a reply.

    Keep the issue short, concrete, and written in your own voice.

    If a maintainer replies lgtmi, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open.

    See CONTRIBUTING.md.

  3. nathanAtHeadfwd commented on Jun 12, 2026

    @nathanAtHeadfwd
    Author

    https://github.com/ccusage/ccusage/compare/main...nathanAtHeadfwd:ccusage:fix/kimi-code-cli-support?w

    I have the fix for it here. Has been working on my machine for a few days now. If you want me to make a PR, just let me know.

  4. ryoppippi commented on Aug 31, 2026

    @ryoppippi
    Member

    Historical audit: this discussion was auto-closed by the legacy contributor gate. That closure did not assess technical importance.

    Audit result: maintainable candidate. The request fits the current ccusage scope and can be evaluated with repository-owned code or fixtures, without vendor credentials or platform-specific release infrastructure. It remains closed for now; reopen only after confirming current relevance and expected behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage:maintainableFits the repository's maintainable scope and needs review.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions