🔥 MoonshotAI/kimi-cli:你的下一代终端 AI 代理
英文标题:🔥 MoonshotAI/kimi-cli
Kimi CLI 是一款运行在终端中的 AI 代理,能够阅读和编辑代码、执行 shell 命令、搜索网页并自主规划执行过程。该项目正逐步演变为 Kimi Code CLI,安装新版本可自动迁移原有配置和会话。Kimi CLI 支持 VS Code 扩展、Agent Client Protocol、Zsh 插件以及 MCP 工具集成,为开发者提供了丰富的终端 AI 能力。这些特性有助于将 AI 深度融入日常开发工作流,提升效率并降低操作门槛。
3.5 MB
189.1 KB
4.5 MB
71.2 KB
中文
Kimi Code | Documentation | 文档
重要
Kimi CLI 正在演变为 Kimi Code CLI —— 来自同一团队的下一代终端 AI 代理。安装 Kimi Code CLI 将自动迁移你的配置和会话。本项目将逐步终止;文档和现有安装仍然可用。
Kimi CLI 是一个在终端中运行的 AI 代理,可帮助你完成软件开发任务和终端操作。它能阅读和编辑代码、执行 shell 命令、搜索和获取网页,并在执行过程中自主规划与调整操作。
请参阅 入门指南 了解如何安装和开始使用 Kimi CLI。
Kimi CLI 不仅是一个编程代理,还是一个 shell。你可以按 Ctrl-X 切换到 shell 命令模式。在此模式下,无需离开 Kimi CLI 即可直接运行 shell 命令。
注意
尚不支持如
cd的内置 shell 命令。
你可以通过 Kimi Code VS Code 扩展 将 Kimi CLI 与 Visual Studio Code 集成。
Kimi CLI 开箱即用地支持 Agent Client Protocol。你可以将它与任何兼容 ACP 的编辑器或 IDE 结合使用。
要在 ACP 客户端中使用 Kimi CLI,请确保先在终端中运行 Kimi CLI 并发送 /login 完成登录。然后,你可以在 ACP 客户端中将 Kimi CLI 配置为 ACP 代理服务器,命令为 kimi acp。
例如,要将 Kimi CLI 与 Zed 或 JetBrains 配合使用,请将以下配置添加到你的 ~/.config/zed/settings.json 或 ~/.jetbrains/acp.json 文件中:
{ "agent_servers": { "Kimi CLI": { "type": "custom", "command": "kimi", "args": ["acp"], "env": {} } } }
然后你就可以在 IDE 的代理面板中创建 Kimi CLI 线程。
你可以将 Kimi CLI 与 Zsh 配合使用,用 AI 代理能力增强你的 shell 体验。
通过以下方式安装 zsh-kimi-cli 插件:
git clone https://github.com/MoonshotAI/zsh-kimi-cli.git
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/kimi-cli
注意
如果你使用的不是 Oh My Zsh 的插件管理器,可能需要参考插件的 README 了解安装说明。
然后在 ~/.zshrc 中将 kimi-cli 添加到 Zsh 插件列表中:
重新启动 Zsh 后,你可以按 Ctrl-X 切换到代理模式。
Kimi CLI 支持 MCP(Model Context Protocol)工具。
kimi mcp 子命令组
你可以使用 kimi mcp 子命令组管理 MCP 服务器。例如:
添加流式 HTTP 服务器:
kimi mcp add --transport http context7 https://mcp.context7.com/mcp --header "CONTEXT7_API_KEY: ctx7sk-your-key"
添加带 OAuth 授权的流式 HTTP 服务器:
kimi mcp add --transport http --auth oauth linear https://mcp.linear.app/mcp
添加 stdio 服务器:
kimi mcp add --transport stdio chrome-devtools -- npx chrome-devtools-mcp@latest
列出已添加的 MCP 服务器:
kimi mcp list
移除一个 MCP 服务器:
kimi mcp remove chrome-devtools
授权一个 MCP 服务器:
kimi mcp auth linear
临时 MCP 配置
Kimi CLI 也支持通过 CLI 选项进行临时 MCP 服务器配置。
给定一个符合常见 MCP 配置格式的配置文件,例如:
{ "mcpServers": { "context7": { "url": "https://mcp.context7.com/mcp", "headers": { "CONTEXT7_API_KEY": "YOUR_API_KEY" } }, "chrome-devtools": { "command": "npx", "args": ["-y", "chrome-devtools-mcp@latest"] } } }
使用 --mcp-config-file 选项运行 kimi 即可连接到指定的 MCP 服务器:
kimi --mcp-config-file /path/to/mcp.json
更多特性请参阅 文档。
要开发 Kimi CLI,运行:
git clone https://github.com/MoonshotAI/kimi-cli.git cd kimi-cli
make prepare # 准备开发环境
然后你就可以开始开发 Kimi CLI。
进行修改后,可参考以下命令:
uv run kimi # 运行 Kimi CLI
make format # 格式化代码 make check # 运行 lint 和类型检查 make test # 运行测试 make test-kimi-cli # 仅运行 Kimi CLI 测试 make test-kosong # 仅运行 kosong 测试 make test-pykaos # 仅运行 pykaos 测试 make build-web # 构建 Web UI 并将其同步到包中(需要 Node.js/npm) make build # 构建 Python 包 make build-bin # 构建独立二进制文件 make help # 显示所有 make 目标
注意:make build 和 make build-bin 会自动运行 make build-web 以嵌入 Web UI。
English / 原文
Kimi Code | Documentation | 文档
Important
Kimi CLI is evolving intoKimi Code CLI — the next-generation terminal AI agent from the same team. Installing Kimi Code CLI automatically migrates your configuration and sessions. This project will be gradually wound down; the docs and existing installations remain available.
Kimi CLI is an AI agent that runs in the terminal, helping you complete software development tasks and terminal operations. It can read and edit code, execute shell commands, search and fetch web pages, and autonomously plan and adjust actions during execution.
See Getting Started for how to install and start using Kimi CLI.
Kimi CLI is not only a coding agent, but also a shell. You can switch the shell command mode by pressing Ctrl-X. In this mode, you can directly run shell commands without leaving Kimi CLI.
Note
Built-in shell commands like cd are not supported yet.
Kimi CLI can be integrated with Visual Studio Code via the Kimi Code VS Code Extension.
Kimi CLI supports Agent Client Protocol out of the box. You can use it together with any ACP-compatible editor or IDE.
To use Kimi CLI with ACP clients, make sure to run Kimi CLI in the terminal and send /login to complete the login first. Then, you can configure your ACP client to start Kimi CLI as an ACP agent server with command kimi acp.
For example, to use Kimi CLI with Zed or JetBrains, add the following configuration to your ~/.config/zed/settings.json or ~/.jetbrains/acp.json file:
{
"agent_servers": {
"Kimi CLI": {
"type": "custom",
"command": "kimi",
"args": ["acp"],
"env": {}
}
}
}
Then you can create Kimi CLI threads in IDE's agent panel.
You can use Kimi CLI together with Zsh, to empower your shell experience with AI agent capabilities.
Install the zsh-kimi-cli plugin via:
git clone https://github.com/MoonshotAI/zsh-kimi-cli.git \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/kimi-cli
Note
If you are using a plugin manager other than Oh My Zsh, you may need to refer to the plugin's README for installation instructions.
Then add kimi-cli to your Zsh plugin list in ~/.zshrc:
After restarting Zsh, you can switch to agent mode by pressing Ctrl-X.
Kimi CLI supports MCP (Model Context Protocol) tools.
kimi mcp sub-command group
You can manage MCP servers with kimi mcp sub-command group. For example:
# Add streamable HTTP server:
kimi mcp add --transport http context7 https://mcp.context7.com/mcp --header "CONTEXT7_API_KEY: ctx7sk-your-key"
# Add streamable HTTP server with OAuth authorization:
kimi mcp add --transport http --auth oauth linear https://mcp.linear.app/mcp
# Add stdio server:
kimi mcp add --transport stdio chrome-devtools -- npx chrome-devtools-mcp@latest
# List added MCP servers:
kimi mcp list
# Remove an MCP server:
kimi mcp remove chrome-devtools
# Authorize an MCP server:
kimi mcp auth linear
Ad-hoc MCP configuration
Kimi CLI also supports ad-hoc MCP server configuration via CLI option.
Given an MCP config file in the well-known MCP config format like the following:
{
"mcpServers": {
"context7": {
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
},
"chrome-devtools": {
"command": "npx",
"args": ["-y", "chrome-devtools-mcp@latest"]
}
}
}
Run kimi with --mcp-config-file option to connect to the specified MCP servers:
kimi --mcp-config-file /path/to/mcp.json
See more features in the Documentation.
To develop Kimi CLI, run:
git clone https://github.com/MoonshotAI/kimi-cli.git
cd kimi-cli
make prepare # prepare the development environment
Then you can start working on Kimi CLI.
Refer to the following commands after you make changes:
uv run kimi # run Kimi CLI
make format # format code
make check # run linting and type checking
make test # run tests
make test-kimi-cli # run Kimi CLI tests only
make test-kosong # run kosong tests only
make test-pykaos # run pykaos tests only
make build-web # build the web UI and sync it into the package (requires Node.js/npm)
make build # build python packages
make build-bin # build standalone binary
make help # show all make targets
Note: make build and make build-bin automatically run make build-web to embed the web UI.


