Skip to content

kimi-code: first-class agent with usage + resume#50

Open
fkesheh wants to merge 3 commits into
mainfrom
feat/kimi-code
Open

kimi-code: first-class agent with usage + resume#50
fkesheh wants to merge 3 commits into
mainfrom
feat/kimi-code

Conversation

@fkesheh

@fkesheh fkesheh commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Adds the standalone Kimi Code CLI (code.kimi.com/kimi-code) as a first-class agent harness, distinct from the existing kimi provider-flavor (OAuth CLI vs claude-CLI-on-Moonshot — both kept). Two commits; bridge 519 tests + UI 110 green.

What it supports

Capability kimi-code grok (reference)
Launch + model picker (k3 / kimi-for-coding / highspeed)
Loop harness
Usage (tokens + per-model)
Resume after bridge restart
Hooks / mail-nudge ✗ (kimi has none)
Workflows ✗ (deliberate)

How

  • One registry entry + buildKimiCodeCommand drives every derived bridge union (ShellType/LoopHarness/etc.); UI + sibling CLIs mirror it by hand (picker, model dropdown, badge, LoopHarness).
  • Absolute binary path "$HOME/.kimi-code/bin/kimi" — the installer only adds the bin to .zshrc (interactive), but ftown launches via zsh -l -c (non-interactive login) which skips it, so a bare kimi would fail to resolve.
  • --yolo auto-approve, -m <model>; promptAsCliArg:false (its TUI takes no positional prompt — -p is one-shot only — so the prompt is typed after launch, like opencode).
  • Usage extracted from ~/.kimi-code/sessions/.../wire.jsonl usage.record events (resolved via session_index.jsonl by workingDir+createdAt, summed across main + sub-agents) into the same SessionUsage shape as claude/codex — shows in the terminal header, session rows, and ftown-sessions usage.
  • Resume via kimi's workdir-based -c (no native-id capture needed): canResumeStoredSession returns true, so resurrection after a restart continues the actual conversation.

All verified against real ~/.kimi-code data on the dev machine (session index, state.json, usage.record shapes).

Stacked conceptually on #49 (usage/security/e2e), which is already merged to main.

🤖 Generated with Claude Code

fkesheh added 2 commits July 18, 2026 05:50
Adds the standalone Kimi Code CLI as a harness alongside the existing
kimi provider-flavor (distinct products — OAuth CLI vs claude-CLI-on-
Moonshot). One registry entry + buildKimiCodeCommand drives every derived
bridge union; UI/sibling-CLI mirrors updated by hand (picker, model
aliases k3/kimi-for-coding[-highspeed], badge, command branch, LoopHarness).
Launches the absolute $HOME/.kimi-code/bin/kimi (installer only adds it to
.zshrc, which zsh -l -c skips), --yolo auto-approve, -m model; TUI takes
no positional prompt (promptAsCliArg:false, typed after launch like
opencode). grok-shaped limits: no hooks/workflow/provider-env; resume +
usage extraction deferred to follow-ups.
Usage: collect SessionUsage from ~/.kimi-code sessions — resolve the
session dir via session_index.jsonl by workingDir+createdAt, sum
usage.record events across all agents' wire.jsonl (inputOther/output/
inputCacheRead/inputCacheCreation → the four token classes, per-model).
kimi-code now reports usage like claude/codex.
Resume: buildKimiCodeCommand gains resume→'-c' (continue the workdir's
session), threaded through BuildCommandInput like claude's --resume;
canResumeStoredSession returns true for kimi-code, so resurrection after
a bridge restart continues the actual kimi conversation. No native id
field needed — kimi resume is workdir-based.
@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ftown Ready Ready Preview, Comment Jul 18, 2026 9:04am

Request Review

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant