# How Agent Client Protocol (ACP) Integrates with Zed and JetBrains in Kimi Code

> Discover how Kimi Code integrates Agent Client Protocol ACP with Zed and JetBrains IDEs. Learn to launch agent sessions, execute commands, and stream updates via the kimi acp sub-command.

- Repository: [Moonshot AI/kimi-code](https://github.com/MoonshotAI/kimi-code)
- Tags: deep-dive
- Published: 2026-07-22

---

**Kimi Code ships an ACP adapter that exposes a JSON-RPC interface over STDIO, enabling Zed and JetBrains IDEs to launch agent sessions, execute slash commands, and stream tool updates through the `kimi acp` sub-command.**

Kimi Code, developed by MoonshotAI, implements the **Agent Client Protocol (ACP)** 0.23 to turn compatible editors into interactive agent front-ends. The `@moonshot-ai/acp-adapter` package bridges the gap between IDE-specific interfaces and Kimi Code's internal services, allowing developers to drive AI-assisted coding directly from Zed or JetBrains.

## Architecture Overview

The integration operates through three distinct layers that translate IDE actions into Kimi Code operations.

### CLI Entry Point

The `kimi acp` command serves as the launch mechanism. Located at [`apps/kimi-code/src/cli/sub/acp.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-code/src/cli/sub/acp.ts), this entry point starts the ACP process, writes banner-less diagnostic logs to **stderr**, and reads the JSON-RPC request stream from **stdin**. This clean STDIO pipe ensures the IDE's JSON-RPC communication remains unobstructed by CLI output.

### ACP Adapter Core

The [`packages/acp-adapter/src/server.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/packages/acp-adapter/src/server.ts) module implements the JSON-RPC server that handles both **stable** methods (`session/new`, `session/load`, `session/ask`, `tool/call`) and **unstable** extensions (inline-edit prediction, document buffer sync). This server translates ACP requests into native Kimi Code API calls.

### Domain-Specific Glue

IDE-specific concepts map to Kimi Code internals through specialized modules:

- [`packages/acp-adapter/src/modes.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/packages/acp-adapter/src/modes.ts) — Exposes Zed-compatible mode dropdowns and thinking-effort pickers
- [`packages/acp-adapter/src/auth-methods.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/packages/acp-adapter/src/auth-methods.ts) — Handles terminal-based authentication for IDE login flows
- [`packages/acp-adapter/src/kaos-acp.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/packages/acp-adapter/src/kaos-acp.ts) — Bridges ACP's workspace view with the Kaos file system abstraction

## Initialization and Handshake

When an IDE launches `kimi acp`, the adapter executes a strict initialization sequence.

First, the process suppresses all banner output to keep the STDIO stream clean, routing diagnostics exclusively to stderr. The server then waits for an `initialize` request from the IDE, which may contain **agent-servers** configuration from Zed's `~/.config/zed/settings.json` or JetBrains' AI Chat settings.

Upon receiving the request, [`server.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/server.ts) registers capabilities and returns supported authentication methods and operational modes. The initialization response includes the **modes** payload that populates Zed's chip-strip dropdown and JetBrains' mode selectors.

## Session Management and UI Modes

Both Zed and JetBrains interact with Kimi Code through session-based messaging.

Zed consumes the `modes` field from `NewSessionResponse` to populate its **chip-strip** dropdown. The [`modes.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/modes.ts) module constructs this payload to match Zed's expected contract, ensuring the order and labeling of options render correctly in the UI. JetBrains receives the identical payload through the ACP channel, rendering comparable mode selectors in the AI Chat panel.

When users switch modes via the IDE UI, the client sends a `session/configOption` request. The adapter forwards this change to the underlying `Session` object, adjusting the agent's behavior (such as thinking effort or tool availability) in real time.

## Authentication Flow

Zed (without the `AcpBetaFeatureFlag`) and JetBrains rely on the **terminal-auth** method defined in [`packages/acp-adapter/src/auth-methods.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/packages/acp-adapter/src/auth-methods.ts). During initialization, the adapter advertises this method in the capabilities response.

The IDE presents a password-prompt UI to the user. When credentials arrive, the adapter forwards them to Kimi Code's OAuth manager (`packages/oauth`) and returns the resulting token to the IDE, establishing an authenticated session without leaving the editor.

## Slash Commands and Tool Execution

Users invoke capabilities by typing **slash commands** (e.g., `/list-files`) directly in the IDE's chat panel. The ACP client transmits these as plain-text `ContentBlock` objects. The [`packages/acp-adapter/src/session.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/packages/acp-adapter/src/session.ts) module parses these blocks and dispatches them to Kimi Code's internal slash-command router.

Long-running operations stream progress updates through **tool call updates** (`tool/callUpdate`). As implemented in [`session.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/session.ts), these incremental messages allow Zed to display real-time progress indicators while the agent generates responses or executes file operations.

## Workspace Integration via Kaos Bridge

The **Kaos-ACP bridge** ([`packages/acp-adapter/src/kaos-acp.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/packages/acp-adapter/src/kaos-acp.ts)) synchronizes the IDE's workspace state with Kimi Code's file system abstraction.

This bridge performs three critical functions:

- Converts ACP's **MCP server list** into Kaos `FileSystem` objects
- Emits file-change events so Kimi Code can resolve paths for tools that read or write files
- Allows the IDE to forward MCP servers (such as language servers) to the agent side

Through this bridge, Zed's "unsaved-buffer view" and JetBrains' project structure become accessible to Kimi Code tools, enabling the agent to run code, open files, and preview generated content without manual file synchronization.

## Lifecycle Management

When users close the Zed panel or stop a JetBrains run configuration, the IDE sends `session/close` or `session/end` messages. The ACP server listens for these lifecycle hooks—documented in [`packages/acp-adapter/src/server.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/packages/acp-adapter/src/server.ts)—and performs cleanup:

1. Terminates the associated `Session` object
2. Releases Kaos file-system resources
3. Closes any active MCP server connections

This ensures resources are properly released when the IDE disconnects, preventing orphaned processes or file locks.

## Configuring Zed and JetBrains

### Zed Configuration

Add the following block to `~/.config/zed/settings.json` to enable Kimi Code as an agent server:

```json
{
  "agent_servers": [
    {
      "type": "terminal",
      "command": ["kimi", "acp"],
      "env": {}
    }
  ]
}

```

Zed automatically launches `kimi acp` when opening the agent panel.

### JetBrains Configuration

In JetBrains AI Chat settings, configure the external agent to use the Kimi Code CLI:

```bash

# AI Chat > Settings > External Agent

Command: kimi acp

```

JetBrains will spawn the process and connect via STDIO when starting a new chat session.

## Summary

- **STDIO Transport**: Kimi Code uses clean STDIO pipes for JSON-RPC, with [`apps/kimi-code/src/cli/sub/acp.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/apps/kimi-code/src/cli/sub/acp.ts) handling banner-less startup and stderr logging.
- **Three-Layer Architecture**: The CLI entry point, ACP adapter server ([`packages/acp-adapter/src/server.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/packages/acp-adapter/src/server.ts)), and domain glue ([`modes.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/modes.ts), [`auth-methods.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/auth-methods.ts), [`kaos-acp.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/kaos-acp.ts)) form the complete integration stack.
- **IDE-Agnostic Protocol**: Both Zed and JetBrains communicate via ACP 0.23, receiving identical mode payloads and authentication flows while rendering them through their respective UI components.
- **Real-Time Streaming**: Tool execution progress streams back to IDEs via `tool/callUpdate` messages, enabling visual feedback during long operations.
- **Workspace Bridge**: The Kaos-ACP bridge maps IDE workspace views to Kimi Code's file system, supporting unsaved buffers and MCP server forwarding.

## Frequently Asked Questions

### What version of the Agent Client Protocol does Kimi Code support?

Kimi Code implements **ACP 0.23**, supporting both stable methods like `session/new` and `tool/call`, as well as unstable extensions for inline-edit prediction and document buffer synchronization.

### How does authentication work when using Zed or JetBrains with Kimi Code?

Both IDEs use the **terminal-auth** method advertised in [`packages/acp-adapter/src/auth-methods.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/packages/acp-adapter/src/auth-methods.ts). The IDE displays a password prompt, credentials are forwarded to Kimi Code's OAuth manager, and the resulting token is returned to the IDE for session authentication.

### Can Kimi Code handle unsaved files from Zed?

Yes. The **Kaos-ACP bridge** ([`packages/acp-adapter/src/kaos-acp.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/packages/acp-adapter/src/kaos-acp.ts)) exposes Zed's unsaved-buffer view to Kimi Code's tool system, allowing the agent to read and reference file content that exists only in the IDE's memory without requiring explicit saves.

### What is the difference between stable and unstable ACP methods in Kimi Code?

**Stable** methods (implemented in [`packages/acp-adapter/src/server.ts`](https://github.com/MoonshotAI/kimi-code/blob/main/packages/acp-adapter/src/server.ts)) include core functionality like session creation and tool calls guaranteed to maintain backward compatibility. **Unstable** methods cover experimental features such as inline-edit prediction and advanced buffer synchronization that may change in future releases.