kimi-session-restore 0.1.0

List and load Kimi Code CLI session files (wire.jsonl) for context restoration
kimi-session-restore-0.1.0 is not a library.

kimi-session-restore — list and load Kimi Code CLI sessions for context restoration.

Session layout (under ~/.kimi-code/, overridable with --home or $KIMI_CODE_HOME): sessions/<wd_key>/<session_id>/state.json — title, workDir, createdAt/updatedAt, agents, lastPrompt sessions/<wd_key>/<session_id>/agents//wire.jsonl — event stream

wire.jsonl event types read here: turn.prompt / turn.steer {input:[{type:"text",text}], origin:{kind}, time} context.append_loop_event {event:{type: content.part|tool.call, ...}} context.apply_compaction {summary, tokensBefore, tokensAfter, keptUserMessageCount, time}

Topic selection

state.json's own title wins when non-empty. Otherwise the topic falls back to the first genuine human prompt — the first turn.prompt event whose origin.kind == "user" — never a turn.steer (cron fires, task notifications) and never a turn.prompt from a non-user origin (agent bootstrap turns, etc.). Those stay in the Steers/Notifications counter.

Digest is verbatim, not a summary

load's report never paraphrases: the last human prompts, the last assistant texts, and the last tool operations are printed as direct quotes from the transcript, in chronological order, newest last.

Reads are byte-budgeted, not full-file scans

Both the digest scan (read_tail_lines) and the title/first-prompt fallback scan (read_head_lines) read a bounded window with a single seek plus one read, so a multi-gigabyte wire.jsonl still loads in well under a second. When the tail window doesn't cover the whole file, the report says so instead of silently pretending the digest is complete.