Skip to content

loongxjin/kimi-cli

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,389 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kimi Code CLI

[!NOTE] (Fork 修改说明) 本仓库 fork 自 MoonshotAI/kimi-cli,在原基础上做了以下适配修改:

  1. feat(tooling): 为 LLM 参数解析添加 JSON 字符串自动转换 — 某些 LLM 会将 list/dict 等复杂参数序列化为 JSON 字符串,新增 _coerce_json_strings 在 pydantic 校验前自动解析。(packages/kosong/src/kosong/tooling/__init__.py)
  2. fix(message): 合并 system message 和 text output 为单个 TextPart — 兼容 OpenAI 格式模型对 tool-role 消息内容的要求,避免 list-of-dicts 格式解析失败。(src/kimi_cli/soul/message.py)
  3. fix(aiohttp): 启用 trust_env=True — 使 aiohttp ClientSession 正确读取系统代理环境变量(HTTP_PROXY 等)。(src/kimi_cli/utils/aiohttp.py)
  4. feat(session): 使用 LLM 优化会话标题生成 — 在首回合对话结束后,后台异步调用 LLM 根据对话内容生成更准确的会话标题;提取 session_title.py 模块以复用 Web API 和 CLI 会话逻辑。(src/kimi_cli/session_title.py, src/kimi_cli/soul/kimisoul.py, src/kimi_cli/web/api/sessions.py)
  5. fix(shell): 改善 shell 命令失败时的错误信息 — 增加 Command 和 Working directory 便于定位问题;修复剪贴板仅含图片数据时 pyperclip.paste() 返回 None 导致的 TypeError。(src/kimi_cli/tools/shell/__init__.py, src/kimi_cli/ui/shell/prompt.py)
  6. feat(yolo): 修改 yolo mode 行为 — 允许在真正需要用户输入时调用 AskUserQuestion,而非完全禁止提问。(src/kimi_cli/soul/dynamic_injections/yolo_mode.py)
  7. feat(file-replace): 添加 whitespace-normalized 模糊匹配 — 当精确匹配失败时,自动尝试归一化空白字符后的模糊匹配,提升字符串替换成功率。(src/kimi_cli/tools/file/replace.py)
  8. fix(tooling): 改进 JSON 参数解析错误提示 — 增加对字符串闭合和特殊字符(引号、反斜杠、换行等)正确转义的指导。(packages/kosong/src/kosong/tooling/error.py)
  9. feat(toolset): 使用 streamingjson 修复流式输出中截断/不完整的 JSON — 提升工具调用在流式场景下的稳定性。(src/kimi_cli/soul/toolset.py)

Commit Activity Checks Version Downloads Ask DeepWiki

Kimi Code | Documentation | 文档

Kimi Code 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.

Getting Started

See Getting Started for how to install and start using Kimi Code CLI.

Key Features

Shell command mode

Kimi Code 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 Code CLI.

Note

Built-in shell commands like cd are not supported yet.

VS Code extension

Kimi Code CLI can be integrated with Visual Studio Code via the Kimi Code VS Code Extension.

VS Code Extension

IDE integration via ACP

Kimi Code CLI supports Agent Client Protocol out of the box. You can use it together with any ACP-compatible editor or IDE.

To use Kimi Code CLI with ACP clients, make sure to run Kimi Code CLI in the terminal and send /login to complete the login first. Then, you can configure your ACP client to start Kimi Code CLI as an ACP agent server with command kimi acp.

For example, to use Kimi Code CLI with Zed or JetBrains, add the following configuration to your ~/.config/zed/settings.json or ~/.jetbrains/acp.json file:

{
  "agent_servers": {
    "Kimi Code CLI": {
      "type": "custom",
      "command": "kimi",
      "args": ["acp"],
      "env": {}
    }
  }
}

Then you can create Kimi Code CLI threads in IDE's agent panel.

Zsh integration

You can use Kimi Code 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:

plugins=(... kimi-cli)

After restarting Zsh, you can switch to agent mode by pressing Ctrl-X.

MCP support

Kimi Code 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 Code 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

More

See more features in the Documentation.

Development

To develop Kimi Code 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 Code CLI.

Refer to the following commands after you make changes:

uv run kimi  # run Kimi Code CLI

make format  # format code
make check  # run linting and type checking
make test  # run tests
make test-kimi-cli  # run Kimi Code 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.

About

Kimi Code CLI is your next CLI agent.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 77.8%
  • TypeScript 21.1%
  • CSS 0.7%
  • Makefile 0.2%
  • Shell 0.1%
  • Nix 0.1%