Repository navigation
Support Kimi Code CLI as a builder #1201
Copy link
Copy link
Open
Labels
area/towerArea: Tower server / agent farm CLIArea: Tower server / agent farm CLI
Description
Summary
Add the Kimi Code CLI (kimi) as a supported builder harness, so .codev/config.json shell.builder: "kimi" / builderHarness: "kimi" produces a working builder. Scope is the builder MVI validated by spike task-Iptx; Kimi as an architect is explicitly out of scope (stage 2).
Spike findings (verdict: Feasible with Caveats, POC-validated end-to-end):
https://github.com/mohidmakhdoomi/codev/blob/builder/task-Iptx/codev/spikes/task-Iptx-kimi-code-cli-support.md
(reproducible probes: codev/spikes/task-Iptx-kimi-poc.sh on the same branch)
What breaks today
detectHarnessFromCommand('kimi')is unrecognized → falls through to the Claude harness (Harden harness resolution: unrecognized override command defaults to claude harness (residual --resume crash-loop) #1062): the builder script appends--append-system-promptand a positional prompt, both of whichkimirejects (exit 1) → shellper restart loop.- The false Claude harness also exposes Claude session capabilities, so a stale Claude
.jsonlcan route--resume <claude-uuid>intokimi(the pre-Supportcodexas an architect #929 crash-loop class).
Validated approach (spike POC)
Seed-session bootstrap — solves role injection, initial-prompt delivery, and session identity in one pattern:
- Seed:
kimi -p "<role + task briefing, ack-and-wait wrapper>" --output-format stream-jsonin the worktree; capture the session id from the machine-readablesession.resume_hintmeta line. - Persist the id (
.builder-kimi-session) and loop the TUI withkimi -S <id> --yolo— role/task context survives inner restarts. - Readiness barrier (required): script prints a
__CODEV_KIMI_SEED_DONE__ <id>sentinel before exec'ing the TUI; Tower gates delivery on sentinel + grace, then sends a single-lineBEGINkick with store-verified delivery (poll the session'sstate.json; re-send Enter on timeout; retry once; loud warning after).
Scope (builder MVI)
-
KIMI_HARNESSinharness.ts+detectHarnessFromCommandrecognizingkimi - Provider-owned builder launch shape (seed +
-Sloop) branched inspawn-worktree.ts - Readiness barrier + store-verified BEGIN delivery (per spike addendum — required scope)
-
buildResumeforafx spawn --resume(explicit-ID from the Kimi session store,state.json.workDirexact match; null → fresh-with-role fallback) +verifyOwnership -
message-write.tsper-harness Enter-delay knob (Kimi: 80ms fails, 1s works — bisect and pin) -
codev doctor:kimipresence/version, truthful auth heuristic (no billed probe) +kimi loginguidance - Docs:
arch.mdharness section,.codev/config.jsonexamples, skeleton mirror where framework files change - Tests per the spike's test matrix (incl. the Support
codexas an architect #929-class regression:kimi+ stale Claude jsonl must never yield--resume <claude-uuid>or--append-system-prompt)
Out of scope
- Kimi as architect (needs async
seedSessioncapability + async-buildableCrashLoopFallbackper the spike addendum — stage 2, separate issue) - ACP /
kimi serveradapter - Write-guard parity (Kimi has no documented hook seam; must be documented as a caveat)
Caveats (carry into spec/plan)
- Role rides a user turn, not a system prompt (same tradeoff that deferred agy, Support
agy(Antigravity CLI) as an architect #1063). - Reliance on undocumented surfaces (session store layout,
session_index.jsonl,session.resume_hint): pin kimi ≥ 0.27.0 and add a session-store smoke probe. - Documented-Kimi-behavior claims cite only the command reference: https://www.kimi.com/code/docs/en/kimi-code-cli/reference/kimi-command.html
References
- Spike: task-Iptx (branch
builder/task-Iptxon the fork above) - Prior art: PR Support codex as an architect (PIR #929) #1059 (codex architect, PIR Support
codexas an architect #929); issues Multi-architect conversation resume: disambiguate via per-architect session UUID #832, codev adopt / launchInstance: main architect hijacks an unrelated Claude Code session instead of spawning fresh #1145, Tower recovery: Claude architect crash-loops on stale --resume with no user escape #1149, afx: removed sibling architect resurrects after Tower recovery — reconciliation trusts persisted row without liveness check #1150, Harden harness resolution: unrecognized override command defaults to claude harness (residual --resume crash-loop) #1062, Builder worktree write-guard: prevent writes anchored at the main checkout root #1018
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area/towerArea: Tower server / agent farm CLIArea: Tower server / agent farm CLI
Activity
mohidmakhdoomi commentedon Jul 18, 2026
On it! Working on this with the PIR protocol (plan + dev-approval gates before PR).
[PIR cluesmith#1201] Plan draft
[PIR cluesmith#1201] Kimi harness: detection, seed-session launch scr…
[PIR cluesmith#1201] Tower: sentinel-gated BEGIN delivery + per-harne…
[PIR cluesmith#1201] doctor: kimi presence, truthful auth heuristic, …
[PIR cluesmith#1201] Docs: kimi builder harness (arch.md + config exa…
[PIR cluesmith#1201] Pacing resolution is fully best-effort; widen cr…
[PIR cluesmith#1201] Pin Kimi Enter delay with live bisect evidence
[PIR cluesmith#1201] Live demo driver + results (all 5 checklist step…
[PIR cluesmith#1201] Review + retrospective (lessons routed to cold t…
[PIR cluesmith#1201] Fix seed-kick confirmation false-positive (codex…
[PIR cluesmith#1201] Thread: review phase + CMAP disposition logged
[PIR cluesmith#1201] Thread: pr gate approved, porch wrapped; PR open…
[PIR cluesmith#1201] Record CMAP iter-1 disposition (codex finding ac…
[PIR cluesmith#1201] Fix: persist the Kimi pacing marker on the bare …
[PIR cluesmith#1201] Test: pin touch-before-loop ordering in bare-sha…
[PIR cluesmith#1201] Test: complete existence guards on ordering asse…
[PIR cluesmith#1201] Thread: CMAP loop converged (iter 3 — 3x APPROVE…
Merge origin/main into builder/pir-1201
[PIR cluesmith#1201] Adopt shared LAUNCH_LOOP_TAIL (cluesmith#1244) i…
[PIR cluesmith#1201] Thread: CMAP + live kimi verification of loop-ta…
Merge origin/main into builder/pir-1201; redesign the Kimi builder on…
[PIR cluesmith#1620] Re-derive the Kimi pacing seam onto the post-clu…