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.
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.
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.
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.