mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-05-16 19:44:14 +00:00
2.5 KiB
2.5 KiB
Kimi
Kimi Code CLI session parser.
- Source:
src/providers/kimi.ts - Loading: eager (
src/providers/index.ts) - Test:
tests/providers/kimi.test.ts
Where it reads from
$KIMI_SHARE_DIR/sessions/ if set, otherwise ~/.kimi/sessions/.
Kimi stores sessions by work-directory hash:
~/.kimi/
kimi.json
config.toml
sessions/
<workdir-md5>/
<session-id>/
context.jsonl
wire.jsonl
state.json
subagents/
<agent-id>/
context.jsonl
wire.jsonl
kimi.json maps each work-directory hash back to the original working path. CodeBurn uses that to display the project basename; if the metadata file is missing, the hash directory name is used.
Storage Format
CodeBurn reads wire.jsonl. Each data line is a persisted wire record:
{"timestamp":1776162403,"message":{"type":"StatusUpdate","payload":{"message_id":"msg-1","token_usage":{"input_other":100,"input_cache_read":25,"input_cache_creation":10,"output":40}}}}
TurnBegin / SteerInput provide the user prompt, ToolCall / ToolCallRequest provide tool names and shell commands, and StatusUpdate.token_usage provides the billable token counts.
Caching
None.
Deduplication
Per kimi:<session-id>:<message_id>, falling back to the status-update line index if the message id is absent.
Quirks
- Kimi's official
TokenUsageseparatesinput_other,input_cache_read,input_cache_creation, andoutput. CodeBurn maps those directly into input, cache read, cache write, and output. - The current Kimi wire schema does not persist the model on every usage update. CodeBurn uses
KIMI_MODEL_NAMEwhen set, then the active~/.kimi/config.tomldefault model, thenkimi-auto. kimi-auto,kimi-code, andkimi-for-codingare priced askimi-k2-thinkingso managed Kimi Code sessions do not show as$0when the exact backend model is hidden.- Subagent sessions are discovered from
subagents/<agent-id>/wire.jsonland parsed as separate Kimi sessions under the same project.
When Fixing A Bug Here
- Reproduce with a tiny
wire.jsonlfixture intests/providers/kimi.test.ts. - If token totals look wrong, inspect
StatusUpdate.token_usagefirst;context.jsonlonly stores context checkpoints and cumulative counts, not per-step billing detail. - If tools are missing, check whether Kimi emitted
ToolCall,ToolCallRequest, or nestedSubagentEvent; CodeBurn intentionally counts subagent wire files separately to avoid double-counting parent mirrors.