feat(server): add Kimi Code CLI provider over ACP - #5243
Conversation
Bring Kimi into the built-in provider set with full ACP session support, prefixed model catalog (kimi-code/*), thinking effort options, thought-chunk worklog projection, and assistant streaming. Wire settings, web picker/icon, docs, and focused tests.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Opened an issue first per CONTRIBUTING: #5244 |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 989ef3a. Configure here.
ApprovabilityVerdict: Needs human review This PR adds a new provider (Kimi Code CLI) with ~3600 lines of new code including driver, adapter, ACP integration, text generation, and UI components. New feature additions of this scope introducing new user-facing capabilities warrant human review. You can customize Macroscope's approvability policy. Learn more. |
Cap and clear per-turn reasoning buffers, only open Thinking tasks on visible text, flatten grouped ACP model select entries, forward text-generation policy for branch/title, and fix the built-in driver count in overview docs. Made with Grok Build.
|
Addressed the automated review findings on
Focused Kimi provider/adapter/ACP tests pass. One pre-existing |
There was a problem hiding this comment.
Reviewed the new Kimi provider modules (KimiDriver, KimiAdapter, KimiProvider, KimiAcpSupport, KimiTextGeneration) plus the touched ACP/ingestion code against the Effect service conventions. Dependencies are acquired from the environment (yield* Crypto.Crypto, ChildProcessSpawner, ServerSettingsService, Effect.service(ServerConfig)), Effect modules are imported as subpath namespaces, no ManagedRuntime/runPromise leaks into service construction, and error handling uses Schema.TaggedErrorClass types with Effect.catchTags. One finding below on a duplicated service shape.
Posted via Macroscope — Effect Service Conventions
Forward modelSelection options into applyKimiAcpModelSelection for headless text gen, type the ACP runtime param from AcpSessionRuntime Service, teach the ACP mock agent kimi-code/* model ids so Kimi text-gen tests match resolveKimiAcpBaseModelId, and drop the incorrect branch/title policy wiring (those service inputs have no policy field). Made with Grok Build.
Review pass complete (
|
| Finding | Resolution |
|---|---|
| Reasoning buffer unbounded (High) | Cap at 24k chars |
| Whitespace Thinking task stale (Medium / Bugbot) | Only start on non-whitespace; only advance lastPublishedLength on published progress; always complete if started |
clearTurnStateForSession missed reasoning cache (Medium) |
Invalidate bufferedReasoningByTurnKey |
| Grouped ACP model entries dropped (Medium) | Flatten { options: [...] } in model discovery |
| Docs driver count 5→6 (Low) | Fixed |
Text gen ignores modelSelection.options (Medium, new) |
Pass selections: modelSelection.options into applyKimiAcpModelSelection |
| Structural ACP runtime type (Effect conventions) | Type as Pick/Partial of AcpSessionRuntime.Service |
| Kimi text-gen test mock model id | Mock agent accepts kimi-code/* ids; assertion expects prefixed id |
False positive / out of scope
| Finding | Why |
|---|---|
Pass policy to branch/title generation |
Incorrect. BranchNameGenerationInput / ThreadTitleGenerationInput have no policy field (only commit/PR do). Passing it fails typecheck. Prompt helpers accept optional policy for future use, but the service contract does not. Other providers (Claude/Codex/Cursor/Grok) also omit it. Reverted. |
Verification
- Focused tests: Kimi provider, adapter, ACP support, text generation — 19/19 pass
- CodeRabbit auto-review is disabled on this repo (settings); happy to re-trigger with
@coderabbitai reviewif maintainers want
Scope note (unchanged)
Still a large feature PR; issue #5244 remains the tracking entry. Ready for human review of the adapter surface.
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== Fixup commit summary =='
git show --stat --oneline 7eb874d56
echo
echo '== Candidate files =='
fd -t f . | rg '(Kimi|ProviderRuntimeIngestion|AcpRuntimeModel|README|install|internals)' | head -200
echo
echo '== Relevant definitions and usages =='
rg -n -C 3 \
'bufferedReasoningByTurnKey|lastPublishedLength|MAX_.*REASONING|24000|24_000|clearTurnStateForSession|buildKimiDiscoveredModelsFromConfigOptions|applyKimiAcpModelSelection|selections: modelSelection\.options|AcpSessionRuntime\.Service|kimi-code/grok-mock-alt|built-in.*driver|driver.*[56]' \
. \
-g '!node_modules/**' -g '!dist/**' -g '!build/**' | head -500
echo
echo '== Fixup diff for the reported areas =='
git show --format=fuller --find-renames 7eb874d56 -- \
':!node_modules' ':!dist' ':!build' | sed -n '1,1400p'Length of output: 44358 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== Symbol map =='
ast-grep outline apps/server/src/provider/Layers/KimiProvider.ts \
--items all --type function --match 'buildKimiDiscoveredModelsFromConfigOptions|buildKimiThinkingCapabilitiesFromConfigOptions'
ast-grep outline apps/server/src/textGeneration/KimiTextGeneration.ts \
--items all --type function --match 'generateBranchName|generateThreadTitle|buildBranchNamePrompt|buildThreadTitlePrompt'
ast-grep outline apps/server/src/provider/Layers/KimiProvider.test.ts \
--items all --type function --match 'discover|config|group'
echo
echo '== Grouped ACP option implementation and tests =='
sed -n '185,255p' apps/server/src/provider/Layers/KimiProvider.ts
rg -n -C 5 'group|options: \[|configOptions|discovered model' \
apps/server/src/provider/Layers/KimiProvider.test.ts \
apps/server/src/provider/acp/KimiAcpSupport.test.ts
echo
echo '== Branch/title generation input contracts and peer-provider calls =='
rg -n -C 5 \
'interface BranchNameGenerationInput|type BranchNameGenerationInput|interface ThreadTitleGenerationInput|type ThreadTitleGenerationInput|generateBranchName|generateThreadTitle' \
apps/server/src/textGeneration \
packages \
-g '*.ts' | head -550
echo
echo '== Reasoning ingestion tests =='
rg -n -C 4 \
'reasoning|Thinking|24_000|24000|whitespace|clearTurnStateForSession' \
apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts \
apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.approval.test.tsLength of output: 4442 🏁 Script executed: #!/bin/bash
set -u
echo '== Branch and title input contracts =='
rg -n -C 6 \
'BranchNameGenerationInput|ThreadTitleGenerationInput|generateBranchName|generateThreadTitle' \
. -g '*.ts' -g '!node_modules/**' -g '!dist/**' -g '!build/**' | head -700 || true
echo
echo '== Kimi model-discovery tests =='
rg -n -C 6 \
'configOptions|availableModels|group|models.*discover|discover.*models|model.*select' \
apps/server/src/provider/Layers/KimiProvider.test.ts \
apps/server/src/provider/acp/KimiAcpSupport.test.ts || true
echo
echo '== Reasoning-ingestion test coverage =='
rg -n -C 6 \
'reasoning|Thinking|whitespace|24_000|24000|session\.exited|clear.*session' \
apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts \
apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.approval.test.ts || true
echo
echo '== Kimi text-generation option propagation test coverage =='
rg -n -C 6 \
'options|thinking|set_config_option|setConfigOption|session/set_config_option' \
apps/server/src/textGeneration/KimiTextGeneration.test.ts \
apps/server/src/provider/acp/KimiAcpSupport.test.ts || trueLength of output: 84109
The I could not execute the focused tests in this environment. I found no remaining source-level issue in the addressed findings. ✏️ Learnings added
You are interacting with an AI system. |

Summary
Adds optional Kimi Code CLI support as a first-class built-in provider, following the same ACP adapter pattern as Cursor/Grok.
kimi acpfor sessions, prompts, interrupts, approvals, resume, and text generationkimi-code/*models, thinking low/high/max)agent_thought_chunkinto thinking worklog activity and streams assistant textWhy this exists
Kimi Code CLI is a real terminal agent with official ACP support (
kimi acp). T3 already wraps multiple BYO CLIs; this fills that gap without requiring a separate product surface.Scope / CONTRIBUTING note
I read CONTRIBUTING.md. This is larger than the “small fixes only” bar you currently prefer, and I understand you may close or defer large external feature PRs. Opening this so maintainers can decide, request a split, or take the idea in-house if useful.
Happy to:
How to test
kimi→/loginkimi-code/kimi-for-coding(or K3)Test plan
kimi acpprobe: auth, model list, thought + message chunksMade with Grok Build.
Note
Medium Risk
Large new provider surface (adapter + ingestion + shared ACP
streamKindcontract) touches turn lifecycle and all ACP adapters; regressions would show up in streaming/thinking UX rather than auth/data paths.Overview
Adds Kimi Code CLI as a sixth built-in provider, wired like Cursor/Grok through
kimi acp: driver, adapter, provider health/model discovery, headless text generation, contracts, web picker, and docs.The Kimi adapter handles sessions, prompts, steering (in-flight prompts reuse the active turn), interrupt/cancel settlement, approvals, resume, and model/thinking config via
session/set_modelandsession/set_config_option, withkimi-code/*model id normalization.ACP streaming now distinguishes
agent_thought_chunkasreasoning_textdeltas (Cursor/Grok adapters passstreamKindthrough). Orchestration ingestion buffers those chunks into Thinking worklog tasks (capped, progress-throttled) and closes them when assistant text starts or the turn completes.Contracts/settings add
KimiSettings, default models, and slug aliases; web adds Kimi icon and Early Access in picker/settings.Reviewed by Cursor Bugbot for commit 7eb874d. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add Kimi Code CLI as a built-in provider over ACP
makeKimiTextGeneration(KimiTextGeneration.ts) for commit messages, PR content, branch names, and thread titles via ACP-backed JSON prompts with a 180s timeout.agent_thought_chunkevents, emittingContentDeltawithstreamKind: "reasoning_text"alongside the existingassistant_textkind.Macroscope summarized 7eb874d.