Kimi Code CLI 支持多种用户界面模式:
| 场景 | UI 模式 | 原因 |
|---|---|---|
| 日常开发 | Shell | 快速、高效、沉浸式 |
| CI/CD | 非交互式、可脚本化 | |
| IDE 集成 | ACP | 标准化协议、跨编辑器 |
| 远程访问 | Web | 跨平台、无需安装 |
┌─────────────┐ Wire 协议 ┌─────────────┐
│ UI 层 │ ◄─────────────────► │ 核心层 │
│ (Shell/ │ │ (KimiSoul) │
│ Print/ACP)│ │ │
└─────────────┘ └─────────────┘
消息类型:
TurnBegin, StepBegin, TurnEndTextPart, ToolCall, ToolResultApprovalRequest, ToolCallRequest实时渲染 LLM 输出和工具执行结果:
async def _execute(self, user_input: str):
async for msg in self._soul.run(user_input, cancel_event):
await self._render(msg)
async def _render(self, msg: WireMessage):
match msg:
case TextPart(text=text):
self._console.print(text, end="")
case ToolCall():
self._show_tool_call(msg)
case ApprovalRequest():
await self._handle_approval(msg)
ACP(Agent Client Protocol)是开放的协议标准:
// Zed 配置
{
"agent_servers": {
"Kimi Code CLI": {
"command": "kimi",
"args": ["acp"]
}
}
}
优先级(高 → 低)
命令行参数 → 环境变量 → 用户配置 → 项目配置 → 默认值
支持继承机制:
agent:
extend: default # 继承 default agent
name: MyCustomAgent
system_prompt_path: ./prompt.txt # 覆盖系统提示词
tools:
- kimi_cli.tools.shell:Shell
subagents:
coder:
path: ./agents/coder.yaml
description: A coding agent
Skill 是包含 SKILL.md 的目录:
---
name: gen-changelog
description: Generate changelog from git commits
type: standard
---
# Generate Changelog
1. Get commits since last tag
2. Categorize by type (feat, fix, docs)
3. Format according to Keep a Changelog
自动注册为斜杠命令:/skill:gen-changelog
# 添加 MCP 服务器
kimi mcp add --transport stdio my-server -- npx my-mcp-server
kimi mcp add --transport http my-server https://api.example.com/mcp
# 查看已添加的服务器
kimi mcp list
class MyCustomTool(CallableTool):
def __init__(self, config: Config):
super().__init__(
name="my_tool",
description="Does something useful",
parameters={...}
)
async def __call__(self, param1: str) -> ToolReturnValue:
try:
result = await self._process(param1)
return ToolOk(output=result)
except Exception as e:
return ToolError(message=str(e))
book/ 目录。
还没有人回复