Skip to content

feat(server): add Kimi Code CLI provider over ACP - #5243

Open
maiconfontana wants to merge 3 commits into
pingdotgg:mainfrom
atplus-digital:feat/kimi-code-cli-provider
Open

feat(server): add Kimi Code CLI provider over ACP#5243
maiconfontana wants to merge 3 commits into
pingdotgg:mainfrom
atplus-digital:feat/kimi-code-cli-provider

Conversation

@maiconfontana

@maiconfontana maiconfontana commented Aug 2, 2026

Copy link
Copy Markdown

Summary

Adds optional Kimi Code CLI support as a first-class built-in provider, following the same ACP adapter pattern as Cursor/Grok.

  • Spawns kimi acp for sessions, prompts, interrupts, approvals, resume, and text generation
  • Uses the live catalog / config options from Kimi (kimi-code/* models, thinking low/high/max)
  • Projects agent_thought_chunk into thinking worklog activity and streams assistant text
  • Wires contracts/settings, web picker + icon, install docs, and focused tests

Why 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:

  • open an issue first and close this if preferred
  • split into smaller follow-ups (adapter-only, models/settings, UI chrome, docs)
  • drop UI chrome / docs if you only want the server adapter path

How to test

  1. Install Kimi Code CLI and run kimi/login
  2. Checkout this branch; start T3; confirm Kimi in the model picker / Settings
  3. Enable Settings → Assistant output for token streaming if desired
  4. Start a thread on kimi-code/kimi-for-coding (or K3)
  5. Confirm thinking appears in the worklog and assistant text streams; approvals still work

Test plan

  • Focused unit tests for Kimi ACP support / provider / adapter / text generation
  • Live kimi acp probe: auth, model list, thought + message chunks
  • Manual UI session against authenticated local Kimi

Made with Grok Build.


Note

Medium Risk
Large new provider surface (adapter + ingestion + shared ACP streamKind contract) 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_model and session/set_config_option, with kimi-code/* model id normalization.

ACP streaming now distinguishes agent_thought_chunk as reasoning_text deltas (Cursor/Grok adapters pass streamKind through). 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

  • Adds a full Kimi provider driver (KimiDriver.ts) with session adapter, text generation service, ACP runtime wiring, model discovery, and provider health checks.
  • Introduces makeKimiTextGeneration (KimiTextGeneration.ts) for commit messages, PR content, branch names, and thread titles via ACP-backed JSON prompts with a 180s timeout.
  • Extends ACP session parsing to handle agent_thought_chunk events, emitting ContentDelta with streamKind: "reasoning_text" alongside the existing assistant_text kind.
  • The ingestion layer (ProviderRuntimeIngestion.ts) now buffers per-turn reasoning streams, surfacing a 'Thinking' task with progress updates (every ~280 chars, capped at 24,000 chars) and completing it when assistant text starts or the turn ends.
  • Kimi appears in the provider picker with a 'new' badge, its own icon, and configurable settings (binary path, custom models) in the settings UI.

Macroscope summarized 7eb874d.

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.
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9fc7f7d8-4b00-4db5-af78-e5645b92f9df

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XXL 1,000+ changed lines (additions + deletions). labels Aug 2, 2026
@maiconfontana

Copy link
Copy Markdown
Author

Opened an issue first per CONTRIBUTING: #5244

Comment thread docs/internals/overview.md
Comment thread apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts Outdated
Comment thread apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts
Comment thread apps/server/src/provider/Layers/KimiProvider.ts Outdated
Comment thread apps/server/src/textGeneration/KimiTextGeneration.ts
Comment thread apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts
@macroscopeapp

macroscopeapp Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.
@maiconfontana

Copy link
Copy Markdown
Author

Addressed the automated review findings on c8a863902:

  • Reasoning buffer (High): cap at 24k chars; only open a Thinking task once non-whitespace content arrives; only advance lastPublishedLength when progress is published; always complete an opened task; clear bufferedReasoningByTurnKey in clearTurnStateForSession
  • Grouped models (Medium): flatten ACP select groups in buildKimiDiscoveredModelsFromConfigOptions
  • Text gen policy (Medium): forward input.policy for branch name + thread title
  • Docs (Low): built-in driver count 5 → 6

Focused Kimi provider/adapter/ACP tests pass. One pre-existing KimiTextGeneration mock model id flake (kimi-code/grok-mock-alt) is unrelated to these changes.

Comment thread apps/server/src/textGeneration/KimiTextGeneration.ts

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread apps/server/src/provider/acp/KimiAcpSupport.ts Outdated
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.
@maiconfontana

Copy link
Copy Markdown
Author

Review pass complete (7eb874d56)

Addressed the remaining open bot findings after the first fixup. Summary of all review threads:

Fixed (valid)

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 review if maintainers want

Scope note (unchanged)

Still a large feature PR; issue #5244 remains the tracking entry. Ready for human review of the adapter surface.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

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.ts

Length 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 || true

Length of output: 84109


@maiconfontana Static verification supports the reported resolutions.

  • The reasoning buffer is capped at 24,000 characters. Session cleanup invalidates its cache.
  • Grouped ACP model entries are flattened before model discovery.
  • Kimi text generation forwards modelSelection.options.
  • The ACP runtime parameter now uses the AcpSessionRuntime service type.
  • The mock model IDs and the test assertion use the kimi-code/* prefix.

The policy revert is correct. BranchNameGenerationInput and ThreadTitleGenerationInput do not define policy. The other providers also omit it for branch-name and thread-title generation.

I could not execute the focused tests in this environment. I found no remaining source-level issue in the addressed findings.


✏️ Learnings added
Learnt from: maiconfontana
URL: https://github.com/pingdotgg/t3code/pull/5243

Timestamp: 2026-08-02T21:05:47.216Z
Learning: In `apps/server/src/textGeneration/TextGeneration.ts`, `BranchNameGenerationInput` and `ThreadTitleGenerationInput` do not have a `policy` field. Text-generation providers, including Kimi, Claude, Cursor, and Grok, must not forward `input.policy` to `buildBranchNamePrompt` or `buildThreadTitlePrompt` unless the service contracts add that field.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

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

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant