kimi-delegate

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Kimi Delegate

Kimi 任务委托

You are the orchestrator. Hand a bounded coding task to a separate implementer - the Kimi Code CLI - then review what it produced and land it yourself. You write the brief and own the judgment; Kimi does the typing in its own session; you verify and commit.
The loop needs only a shell command and file access, so any comparable orchestrator can drive it.
你作为协调者,将一个明确范围的编码任务交给独立的实现工具——Kimi Code CLI——之后审核其产出内容并自行完成提交。由你撰写任务简报并负责判断;Kimi在独立会话中完成代码编写;你进行验证并提交。
此流程仅需要shell命令和文件访问权限,因此任何类似的协调工具都可以驱动它。

When NOT to use this

何时不使用此方法

  • The task is small enough to do inline; delegation overhead is not worth it.
  • The
    kimi
    CLI is not installed or authenticated.
  • You need a CLI-enforced read-only implementer. Headless Kimi has no read-only mode.
  • 任务规模小到足以直接完成;委托的开销得不偿失。
  • 未安装或未认证
    kimi
    CLI。
  • 你需要一个CLI强制的只读实现工具。无头模式的Kimi没有只读模式。

Prerequisites (check once)

前提条件(仅需检查一次)

  1. Install Kimi Code with
    brew install kimi-code
    on macOS/Linux, or use the native installer from the official Kimi Code documentation.
  2. Authenticate with
    kimi login
    (device-code flow, no TUI), or use
    /login
    in the TUI.
  3. Confirm
    kimi --version
    succeeds.
  4. Work in, or point
    --cd
    at, the target git repository.
  1. 在macOS/Linux上使用
    brew install kimi-code
    安装Kimi Code,或从Kimi Code官方文档下载原生安装包。
  2. 使用
    kimi login
    进行认证(设备码流程,无TUI),或在TUI中使用
    /login
  3. 确认
    kimi --version
    命令执行成功。
  4. 在目标git仓库中工作,或使用
    --cd
    参数指定目标git仓库路径。

Choose the model alias

选择模型别名

Kimi uses
default_model
from its
config.toml
when
--model
is omitted. To choose another model alias, pass
--model <alias from your kimi config>
. Model aliases are user-defined config keys; use one the human has configured rather than inventing one.
当省略
--model
参数时,Kimi会使用其
config.toml
中的
default_model
。要选择其他模型别名,请传递
--model <你的kimi配置中的别名>
。模型别名是用户自定义的配置键;请使用人类已配置的别名,而非自行创建。

The loop

流程循环

Run these five steps per task. Steps 1, 4, and 5 require judgment; 2 and 3 are mechanical.
每个任务都需要执行以下五个步骤。步骤1、4和5需要判断;步骤2和3是机械操作。

1. Write the brief

1. 撰写任务简报

Kimi sees only the text you send plus what it can inspect in the workspace - no chat history or shared context. Include the goal, current state, what to change, what to leave untouched, the project's actual gates, and a report contract. Tell Kimi not to commit. Keep one task per brief. See references/writing-the-brief.md.
Kimi只能看到你发送的文本以及它可以在工作区中检查的内容——无聊天历史或共享上下文。请包含目标、当前状态、需要修改的内容、需要保留不变的内容、项目的实际准入标准,以及报告约定。告知Kimi不要提交。每个简报对应一个任务。详见references/writing-the-brief.md

2. Dispatch

2. 分发任务

Use the bundled helper. It wraps Kimi's headless prompt mode, captures the structured event stream, and writes
result.json
. (
<skill-dir>
is the installed folder containing this
SKILL.md
.)
bash
node "<skill-dir>/scripts/relay.mjs" --brief brief.txt --cd /path/to/repo
使用内置的辅助工具。它封装了Kimi的无头提示模式,捕获结构化事件流,并写入
result.json
。(
<skill-dir>
是包含此
SKILL.md
的安装文件夹。)
bash
node "<skill-dir>/scripts/relay.mjs" --brief brief.txt --cd /path/to/repo

choose a configured model alias: add --model <alias from your kimi config>

选择已配置的模型别名: 添加 --model <你的kimi配置中的别名>

resume the most recent session: add --resume-last (delta brief only)

恢复最近的会话: 添加 --resume-last (仅需增量简报)

resume a specific session: add --session <id> (delta brief only)

恢复特定会话: 添加 --session <id>(仅需增量简报)

hard time limit (watchdog): add --timeout 2h (the 30m default suits short runs; implementation briefs routinely need 1-2h)

硬时间限制(监控机制): 添加 --timeout 2h (默认30分钟适合短任务;实现类简报通常需要1-2小时)

see all options: node .../relay.mjs --help

查看所有选项: node .../relay.mjs --help


The child process's cwd pins the workspace. Use repeatable `--add-dir` flags only for extra workspace
directories. The relay writes artifacts under the system temp dir by default and never commits. See
[references/dispatch-and-poll.md](references/dispatch-and-poll.md).

子进程的当前工作目录固定为工作区。仅当需要额外工作区目录时,使用可重复的`--add-dir`参数。默认情况下,中继工具会将产物写入系统临时目录,且绝不会提交。详见[references/dispatch-and-poll.md](references/dispatch-and-poll.md)。

3. Wait for completion

3. 等待完成

The helper blocks until Kimi finishes. Run it with the orchestrator's background-command facility, or background it in the shell and poll for
result.json
. A pre-run usage error exits 2 and writes no result; a missing
kimi
exits 127 and writes
status: "kimi_unavailable"
.
Trust process state and the working tree over a progress display. Completion means the process exited and
result.json
exists. Kimi's full report is the
finalMessage
field in
result.json
(also printed in full on stdout between the report markers).
辅助工具会阻塞直到Kimi完成任务。可以使用协调工具的后台命令功能运行它,或在shell中将其置于后台并轮询
result.json
。预运行时的使用错误会以状态码2退出且不写入结果;若缺少
kimi
则以状态码127退出并写入
status: "kimi_unavailable"
优先信任进程状态和工作树而非进度显示。完成意味着进程已退出且
result.json
已存在。Kimi的完整报告位于
result.json
finalMessage
字段中(也会在报告标记之间完整打印到标准输出)。

4. Review - do not trust the self-report

4. 审核——不要信任自我报告

Treat Kimi's final message and gate claims as claims:
  • Re-run the project's gates yourself.
  • Read the diff against the brief, starting with
    touchedFiles
    .
  • Run relevant guard skills if installed.
  • Round-trip migrations and grep for dangling references after removals or renames.
See references/review-and-land.md.
将Kimi的最终消息和准入标准声明视为待验证的主张:
  • 自行重新运行项目的准入标准检查。
  • 根据任务简报阅读代码差异,从
    touchedFiles
    开始。
  • 若已安装相关防护工具,则运行它们。
  • 在删除或重命名后,往返迁移并 grep 查找悬空引用。
详见references/review-and-land.md

5. Land it

5. 完成提交

The implementer edits the working tree; the orchestrator commits. Commit only after the gates pass and the diff holds. If rework is needed, send a delta brief with
--resume-last
or
--session <id>
, then review again.
实现工具会编辑工作树;由协调者提交。仅当准入标准检查通过且代码差异符合要求时再提交。若需要返工,请使用
--resume-last
--session <id>
发送增量简报,之后再次审核。

Autonomy and permissions

自主性与权限

In headless
-p
mode, Kimi always runs in auto permission mode and never asks for approval. Kimi rejects
--prompt
combined with
--yolo
,
--auto
, or
--plan
, so the relay passes none of them and offers no
--read-only
or
--full-access
option. There is no CLI-enforced read-only mode: inspect
touchedFiles
and the diff after every run. That diff, not a flag, is the guarantee of what changed.
在无头
-p
模式下,Kimi始终运行在自动权限模式,绝不会请求批准。Kimi拒绝将
--prompt
--yolo
--auto
--plan
结合使用,因此中继工具不会传递这些参数,也不提供
--read-only
--full-access
选项。不存在CLI强制的只读模式:每次运行后检查
touchedFiles
和代码差异。该差异而非某个标志,才是变更内容的保障。

Authorization model

授权模型

Delegation is something the human opts into. Once they have ("run this queue", "proceed"), committing verified, gate-passing work is the agreed contract. Two limits remain: surface, don't absorb (report Kimi's design decisions, defensible-but-unasked turns, and non-blocking nitpicks) and stop for scope changes (if correct completion needs going beyond the brief, ask instead of expanding the mandate). See references/review-and-land.md.
委托是人类主动选择的操作。一旦他们选择(如“运行此队列”、“继续”),提交经过验证且符合准入标准的工作就是约定的契约。仍有两个限制:披露而非隐瞒(报告Kimi的设计决策、合理但未被要求的变更,以及不影响功能的小问题)和范围变更时停止(若正确完成任务需要超出简报范围,应先询问而非扩大任务权限)。详见references/review-and-land.md

References

参考资料

  • references/writing-the-brief.md - structure, report contract, real gates, argv delivery, and delta briefs.
  • references/dispatch-and-poll.md - flags, artifacts,
    result.json
    , polling, and failure recovery.
  • references/review-and-land.md - review checklist, commit boundary, and rework through Kimi sessions.
  • references/multi-task-queues.md - sequential queues, constraint carry-forward, progress tracking, and the final coherence pass.
  • references/writing-the-brief.md - 结构、报告约定、实际准入标准、参数传递和增量简报。
  • references/dispatch-and-poll.md - 参数、产物、
    result.json
    、轮询和故障恢复。
  • references/review-and-land.md - 审核清单、提交边界,以及通过Kimi会话进行返工。
  • references/multi-task-queues.md - 顺序队列、约束传递、进度跟踪和最终一致性检查。