Skip to content

[codex] add Kimi CLI provider support - #3

Merged
aGamingGod1234 merged 17 commits into
mainfrom
feat/kimi-provider
Aug 11, 2026
Merged

aGamingGod1234 merged 17 commits into
mainfrom
feat/kimi-provider

Conversation

@aGamingGod1234

@aGamingGod1234 aGamingGod1234 commented Aug 11, 2026 •

Copy link
Copy Markdown
Owner

Problem

T3 Code could not run Kimi Code CLI as a first-party provider. Users with a Kimi subscription had no provider settings, runtime adapter, model discovery, or client entry point, so they could not start or continue Kimi sessions from T3 Code.

Root cause

The provider registry and clients had no Kimi driver, and the shared ACP runtime was missing the small pieces needed by Kimi's current ACP implementation: resume-first continuation and retained command updates.

Fix

Add Kimi as an Early Access provider using the official kimi acp transport. The implementation registers a per-instance Kimi driver and adds:

  • CLI health and authentication checks, dynamic model/configuration discovery, modes, slash commands, and skills
  • streamed assistant, plan, and tool events through the canonical provider runtime
  • session start, interruption, stop, continuation, attachments, MCP forwarding, and in-session model changes
  • supervised, auto-accept-edits, auto, full-access, and plan mode mapping based on capabilities advertised by Kimi
  • approval requests and Kimi's permission-based structured question bridge
  • background thread title, branch, commit message, and pull-request text generation
  • web, desktop, mobile, multiple-instance, remote-server, and user documentation support

Unsupported ACP operations such as provider-side rollback remain explicit rather than being simulated. Kimi is labeled Early Access while the upstream ACP surface continues to evolve.

Verification

  • 172 focused tests passed across contracts, server, web, and mobile
  • Server, contracts, web, and mobile typechecks passed
  • Formatting passed for all 42 changed files
  • A live non-prompting probe passed against authenticated Kimi Code CLI 0.29.1, covering ACP initialization, authentication, and session creation

Model: GPT-5.6 Sol
Harness: Codex in T3 Code

Summary by CodeRabbit

  • New Features

    • Added Early Access support for the Kimi provider, including model discovery, sessions, permissions, skills, commands, and text generation.
    • Added Kimi configuration options, provider status reporting, authentication handling, and dedicated icons across web and mobile.
    • Added session resumption and live available-command updates.
    • Added “Copy thread ID” to the thread action menu.
    • Shift-clicking New Thread now creates it directly in the current project.
  • Documentation

    • Added Kimi setup and provider documentation, including installation, authentication, hosting, and supported capabilities.

Copilot AI lite review requested due to automatic review settings August 11, 2026 13:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@aGamingGod1234, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 27 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bc295765-727f-461d-8e48-7207a148110f

📥 Commits

Reviewing files that changed from the base of the PR and between 63895951e90cf8c9a8eac7e0c1c7794411ab31ed and dbb795d.

📒 Files selected for processing (19)
  • apps/mobile/src/features/threads/ThreadSettingsSheet.tsx
  • apps/mobile/src/features/threads/thread-settings-sheet-state.test.ts
  • apps/mobile/src/lib/modelOptions.test.ts
  • apps/mobile/src/lib/modelOptions.ts
  • apps/server/scripts/acp-mock-agent.ts
  • apps/server/src/provider/Drivers/KimiDriver.ts
  • apps/server/src/provider/Drivers/KimiHome.test.ts
  • apps/server/src/provider/Drivers/KimiHome.ts
  • apps/server/src/provider/Drivers/KimiSkills.ts
  • apps/server/src/provider/Layers/KimiAdapter.test.ts
  • apps/server/src/provider/Layers/KimiAdapter.ts
  • apps/server/src/provider/Layers/KimiProvider.test.ts
  • apps/server/src/provider/Layers/KimiProvider.ts
  • apps/server/src/provider/acp/AcpJsonRpcConnection.test.ts
  • apps/server/src/provider/acp/AcpSessionRuntime.ts
  • apps/server/src/provider/acp/KimiAcpSupport.test.ts
  • apps/server/src/provider/acp/KimiUserInput.test.ts
  • apps/server/src/provider/acp/KimiUserInput.ts
  • docs/internals/overview.md
📝 Walkthrough

Walkthrough

This change adds Kimi as an Early Access provider. It includes server-side ACP integration, provider discovery, session handling, text generation, settings contracts, web and mobile presentation, documentation, and regression coverage. It also adds thread-ID copying and Shift-click thread creation behavior.

Changes

Kimi provider integration

Layer / File(s) Summary
Contracts and Kimi runtime foundations
packages/contracts/..., apps/server/src/provider/Drivers/..., apps/server/src/provider/acp/Kimi...
Adds Kimi settings, display metadata, home and skill discovery, ACP launch configuration, model selection, and permission-question handling.
ACP resume and command state
apps/server/src/provider/acp/Acp..., apps/server/scripts/acp-mock-agent.ts
Adds normalized available-command events, command-state tracking, resume-first startup, fallback behavior, and mock-agent scenarios.
Provider discovery and session adapter
apps/server/src/provider/Layers/Kimi..., apps/server/src/provider/Drivers/KimiDriver.ts, apps/server/src/provider/builtInDrivers.ts
Adds Kimi health checks, capability discovery, multi-instance driver wiring, ACP sessions, turns, permissions, attachments, interruption, cleanup, and provider events.
Kimi text generation
apps/server/src/textGeneration/...
Adds ACP-backed generation for commit messages, pull requests, branch names, and thread titles with timeout, validation, error mapping, and sanitization.
Client presentation and documentation
apps/web/..., apps/mobile/..., docs/..., .gitignore
Adds Kimi icons, provider metadata, model labels, settings presentation, sidebar behavior, thread-ID copying, installation guidance, provider documentation, and internal design records.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant KimiDriver
  participant KimiProvider
  participant KimiAdapter
  participant KimiACP
  Client->>KimiDriver: configure Kimi provider
  KimiDriver->>KimiProvider: check status and discover capabilities
  KimiProvider->>KimiACP: start ACP discovery session
  KimiACP-->>KimiProvider: models, options, commands, and skills
  Client->>KimiAdapter: start session and send turn
  KimiAdapter->>KimiACP: prompt with permissions and attachments
  KimiACP-->>KimiAdapter: runtime events and completion
  KimiAdapter-->>Client: normalized provider events
Loading

Suggested reviewers: juliusmarminge, t3dotgg

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the primary change: adding Kimi CLI provider support.
Description check ✅ Passed The description clearly explains the problem, fix, UI scope, and verification, but it does not use the template headings or include the checklist.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/kimi-provider

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (5)
apps/server/src/provider/acp/KimiAcpSupport.test.ts (1)

7-22: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add a case for the default binary and empty settings.

buildKimiAcpSpawnInput falls back to kimi when kimiSettings is null or undefined. No test covers that path or the omission of env when environment is absent. Add one case to lock the default behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/server/src/provider/acp/KimiAcpSupport.test.ts` around lines 7 - 22, Add
a test case in the buildKimiAcpSpawnInput suite covering null or undefined
kimiSettings, asserting the default command is "kimi", args contains only "acp",
and env is omitted when no environment is provided.
apps/server/src/provider/Layers/KimiAdapter.ts (2)

165-172: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Read the prompt capability through the typed initialize result.

initializedPromptSupportsImages accepts unknown and casts to a hand-written shape. started.initializeResult is already typed by effect-acp. The cast removes compile-time checking, so a schema rename silently disables image attachments and sendTurn falls back to path-only text at Line 664. Type the parameter as EffectAcpSchema.InitializeResponse and read the field directly.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/server/src/provider/Layers/KimiAdapter.ts` around lines 165 - 172,
Update initializedPromptSupportsImages to accept
EffectAcpSchema.InitializeResponse instead of unknown, remove the hand-written
cast, and read agentCapabilities.promptCapabilities.image directly from the
typed initialize result. Ensure the existing true-only capability check remains
unchanged so sendTurn preserves image attachments when supported.

606-738: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract the shared model-selection and mode setup.

Lines 616-630 repeat the applyKimiAcpModelSelection call, its mapAcpToAdapterError mapping, and the applyKimiMode call from Lines 461-475 in startSession. Extract one helper that takes the runtime, the selection, and the interaction mode. This keeps the two entry points aligned when the selection rules change.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/server/src/provider/Layers/KimiAdapter.ts` around lines 606 - 738,
Extract the repeated model-selection and mode setup into a shared helper used by
both sendTurn and startSession. The helper should accept the ACP runtime,
optional model selection, and interaction mode, apply applyKimiAcpModelSelection
with the existing mapAcpToAdapterError handling, then applyKimiMode; replace the
duplicated blocks while preserving their current selection and error behavior.
apps/server/src/provider/acp/KimiUserInput.test.ts (1)

81-126: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Cover the rawInput permission path and array answers.

The tests exercise only the fallback bridge (title, text content, allow_once names). Two production paths remain untested: extractKimiPermissionQuestions returning questions from toolCall.rawInput, and selectedLabels handling an array or an { answers: [...] } object. Add cases for both.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/server/src/provider/acp/KimiUserInput.test.ts` around lines 81 - 126,
Extend the Kimi ACP permission tests around extractKimiPermissionQuestions and
selectedLabels handling to cover toolCall.rawInput-based question extraction,
including its expected question and options, and add resolution cases where
answers are provided as a label array and as an object containing an answers
array. Verify both forms map selected labels to the corresponding opaque ACP
option IDs.
apps/server/src/provider/acp/AcpSessionRuntime.ts (1)

615-627: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Reuse the shared started-state construction.

Lines 618-626 repeat the mode-state write, config-option write, and AcpStartedState construction that lines 710-719 already perform. Extract one helper and call it from both paths. This keeps future startup-state fields consistent across resume and load.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/server/src/provider/acp/AcpSessionRuntime.ts` around lines 615 - 627,
Extract the repeated startup-state setup from the resume branch and the existing
load path into a shared helper, including the modeStateRef and configOptionsRef
writes and AcpStartedState construction. Update both branches around the resumed
handling and the existing startup logic to call this helper, preserving each
branch’s sessionSetupResult and sessionId values while keeping future state
fields centralized.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/mobile/src/lib/modelOptions.test.ts`:
- Around line 13-36: The mobile model-options flow must preserve Kimi’s
ServerProvider.badgeLabel through buildModelOptions and groupByProvider, then
pass and render it in ProviderHeader. Update the regression test to assert the
grouped provider badgeLabel is "Early Access" alongside the existing
providerLabel assertion.

In `@apps/server/src/provider/acp/KimiUserInput.ts`:
- Around line 122-131: Update the option lookup in
resolveKimiQuestionPermissionOption to compare trimmed values on both sides:
trim entry.name before comparing it with label, while preserving the existing
allow_once filter and optionId return behavior.

In `@apps/server/src/provider/Layers/KimiAdapter.ts`:
- Around line 506-578: Update the notification drain after Stream.runDrain in
the session startup flow to use Effect.forkIn(scope) instead of
Effect.forkChild. Keep the existing catch behavior and ensure the notification
fiber remains active until stopSessionInternal closes the session scope.

In `@docs/internals/overview.md`:
- Around line 109-110: Update the built-in driver count in the overview
documentation from “Five” to “Six” so it matches the six drivers listed under
BUILT_IN_DRIVERS, including Kimi.

---

Nitpick comments:
In `@apps/server/src/provider/acp/AcpSessionRuntime.ts`:
- Around line 615-627: Extract the repeated startup-state setup from the resume
branch and the existing load path into a shared helper, including the
modeStateRef and configOptionsRef writes and AcpStartedState construction.
Update both branches around the resumed handling and the existing startup logic
to call this helper, preserving each branch’s sessionSetupResult and sessionId
values while keeping future state fields centralized.

In `@apps/server/src/provider/acp/KimiAcpSupport.test.ts`:
- Around line 7-22: Add a test case in the buildKimiAcpSpawnInput suite covering
null or undefined kimiSettings, asserting the default command is "kimi", args
contains only "acp", and env is omitted when no environment is provided.

In `@apps/server/src/provider/acp/KimiUserInput.test.ts`:
- Around line 81-126: Extend the Kimi ACP permission tests around
extractKimiPermissionQuestions and selectedLabels handling to cover
toolCall.rawInput-based question extraction, including its expected question and
options, and add resolution cases where answers are provided as a label array
and as an object containing an answers array. Verify both forms map selected
labels to the corresponding opaque ACP option IDs.

In `@apps/server/src/provider/Layers/KimiAdapter.ts`:
- Around line 165-172: Update initializedPromptSupportsImages to accept
EffectAcpSchema.InitializeResponse instead of unknown, remove the hand-written
cast, and read agentCapabilities.promptCapabilities.image directly from the
typed initialize result. Ensure the existing true-only capability check remains
unchanged so sendTurn preserves image attachments when supported.
- Around line 606-738: Extract the repeated model-selection and mode setup into
a shared helper used by both sendTurn and startSession. The helper should accept
the ACP runtime, optional model selection, and interaction mode, apply
applyKimiAcpModelSelection with the existing mapAcpToAdapterError handling, then
applyKimiMode; replace the duplicated blocks while preserving their current
selection and error behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f88d38f1-91f5-4924-a5cf-03794573589d

📥 Commits

Reviewing files that changed from the base of the PR and between f5fce74 and 63895951e90cf8c9a8eac7e0c1c7794411ab31ed.

📒 Files selected for processing (51)
  • .gitignore
  • apps/mobile/src/components/ProviderIcon.tsx
  • apps/mobile/src/lib/modelOptions.test.ts
  • apps/mobile/src/lib/modelOptions.ts
  • apps/server/scripts/acp-mock-agent.ts
  • apps/server/src/provider/Drivers/KimiDriver.ts
  • apps/server/src/provider/Drivers/KimiHome.test.ts
  • apps/server/src/provider/Drivers/KimiHome.ts
  • apps/server/src/provider/Drivers/KimiSkills.test.ts
  • apps/server/src/provider/Drivers/KimiSkills.ts
  • apps/server/src/provider/Layers/KimiAdapter.test.ts
  • apps/server/src/provider/Layers/KimiAdapter.ts
  • apps/server/src/provider/Layers/KimiProvider.test.ts
  • apps/server/src/provider/Layers/KimiProvider.ts
  • apps/server/src/provider/Services/KimiAdapter.ts
  • apps/server/src/provider/acp/AcpJsonRpcConnection.test.ts
  • apps/server/src/provider/acp/AcpRuntimeModel.test.ts
  • apps/server/src/provider/acp/AcpRuntimeModel.ts
  • apps/server/src/provider/acp/AcpSessionRuntime.ts
  • apps/server/src/provider/acp/KimiAcpCliProbe.test.ts
  • apps/server/src/provider/acp/KimiAcpSupport.test.ts
  • apps/server/src/provider/acp/KimiAcpSupport.ts
  • apps/server/src/provider/acp/KimiUserInput.test.ts
  • apps/server/src/provider/acp/KimiUserInput.ts
  • apps/server/src/provider/builtInDrivers.ts
  • apps/server/src/textGeneration/KimiTextGeneration.test.ts
  • apps/server/src/textGeneration/KimiTextGeneration.ts
  • apps/server/src/textGeneration/TextGeneration.ts
  • apps/web/src/components/Icons.tsx
  • apps/web/src/components/Sidebar.logic.test.ts
  • apps/web/src/components/Sidebar.logic.ts
  • apps/web/src/components/Sidebar.tsx
  • apps/web/src/components/chat/providerIconUtils.test.ts
  • apps/web/src/components/chat/providerIconUtils.ts
  • apps/web/src/components/settings/providerDriverMeta.test.ts
  • apps/web/src/components/settings/providerDriverMeta.ts
  • apps/web/src/components/threadActionMenu.logic.test.ts
  • apps/web/src/components/threadActionMenu.logic.ts
  • apps/web/src/hooks/useThreadActionMenu.ts
  • apps/web/src/session-logic.ts
  • docs/internals/glossary.md
  • docs/internals/overview.md
  • docs/internals/providers.md
  • docs/superpowers/plans/2026-08-11-kimi-provider.md
  • docs/superpowers/specs/2026-08-11-kimi-provider-design.md
  • docs/user/install.md
  • docs/user/providers-kimi.md
  • packages/contracts/src/model.test.ts
  • packages/contracts/src/model.ts
  • packages/contracts/src/settings.test.ts
  • packages/contracts/src/settings.ts

Comment thread apps/mobile/src/lib/modelOptions.test.ts
Comment thread apps/server/src/provider/acp/KimiUserInput.ts
Comment thread apps/server/src/provider/Layers/KimiAdapter.ts
Comment thread docs/internals/overview.md Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 63895951e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/server/src/provider/Layers/KimiAdapter.ts
Comment thread apps/server/src/provider/Drivers/KimiHome.ts
Comment thread apps/server/src/provider/Layers/KimiAdapter.ts Outdated
Comment thread apps/server/src/provider/acp/KimiUserInput.ts
Comment thread apps/server/src/provider/Layers/KimiAdapter.ts
Comment thread apps/server/src/provider/Layers/KimiProvider.ts Outdated
Comment thread apps/server/src/provider/Layers/KimiAdapter.ts
@aGamingGod1234

Copy link
Copy Markdown
Owner Author

Review audit after dbb795d:

Implemented the actionable review items: mobile badge propagation/rendering, trimmed permission matching, session-scoped notification draining, corrected driver count, pre-prompt interruption gating, effective Kimi home identity, mode fallback, representable question-shape constraints, pre-completion ACP draining, per-model capability discovery, and standard ACP model-switch fallback. I also added the requested default spawn-input, typed image-capability, raw-input, and answer-shape coverage.

Intentional non-changes / false positives:

  • I did not extract the two small model/mode setup sequences. Their inputs are derived differently at session start vs. turn send, and a helper would add indirection without changing behavior.
  • I did not extract the duplicated resume/load started-state block in AcpSessionRuntime. It is a short, branch-local setup and there is no demonstrated divergence; the requested abstraction is unrelated to Kimi correctness.
  • I did not add docstrings to reach CodeRabbit's generic 80% threshold. This repository has no such threshold and its contributor guidance favors comments only where they explain usage; mass docstrings would be noise.
  • The Copilot quota notice is an external reviewer-account limitation, not a code finding.

Verification on the pushed commit: 59 focused server tests and 8 focused mobile tests pass; server and mobile typechecks pass; all 19 changed review-fix files pass the formatter and git diff check. The branch was also rebased onto this fork's actual main, removing the unrelated upstream thread/sidebar changes from the PR diff.

@aGamingGod1234
aGamingGod1234 merged commit c02b9b5 into main Aug 11, 2026
1 check passed
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.

2 participants