copilot-delegate

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Copilot Delegate

Copilot 委托工作流程

You are the orchestrator. Delegate a bounded coding task to a separate implementer — the GitHub Copilot CLI — then review what it produced and land it yourself. You write the brief and own the judgment; the implementer makes changes in its own session in a clean working tree; you verify and commit.
The loop needs only a shell command and file access, so any comparable orchestrator can drive it.
你作为协调者,将一个边界清晰的编码任务委托给独立的实现工具——GitHub Copilot CLI,之后审核其产出内容并自行完成提交。你撰写任务简报并负责最终判断;实现工具会在干净的工作目录中独立会话进行修改;你负责验证并提交代码。
该流程仅需要Shell命令和文件访问权限,因此任何类似的协调工具都可以驱动它。

When NOT to use this

请勿使用此流程的场景

  • The task is small enough to do inline; delegation overhead is not worth it.
  • The
    copilot
    CLI is not installed or authenticated.
  • You need a hard sandbox. Copilot exposes sandbox controls, but they are upstream-experimental (MXC-based, controlled via the
    /sandbox
    command and settings, disabled by default) — this relay does not configure them.
    --read-only
    only disables edit tools (
    --mode plan
    ); shell commands still run. If project files must not change at all, dispatch against a clean or isolated worktree.
  • 任务足够简单可直接完成;委托带来的额外开销得不偿失。
  • 未安装或未认证
    copilot
    CLI。
  • 需要严格的沙箱环境。Copilot提供沙箱控制功能,但属于上游实验性特性(基于MXC,通过
    /sandbox
    命令和设置控制,默认禁用)——本中继工具不会配置这些特性。
    --read-only
    仅会禁用编辑工具(
    --mode plan
    模式);Shell命令仍可运行。如果项目文件绝对不能被修改,请在干净或隔离的工作目录中执行任务。

Prerequisites (check once)

前置条件(只需检查一次)

  1. Install
    copilot
    (
    npm install -g @github/copilot
    ; the CLI requires Node 22+, the relay itself runs on Node 18+ — the relay probes
    copilot version
    ).
  2. Authenticate: run
    copilot login
    (interactive web/device flow), or set
    COPILOT_GITHUB_TOKEN
    /
    GH_TOKEN
    /
    GITHUB_TOKEN
    in the environment.
  3. Confirm
    copilot version
    succeeds.
  4. Work in, or point
    --cd
    at, the target git repository.
  1. 安装
    copilot
    (执行
    npm install -g @github/copilot
    ;CLI需要Node 22+版本,中继工具本身可在Node 18+版本运行——中继工具会检测
    copilot version
    )。
  2. 认证:执行
    copilot login
    (交互式网页/设备验证流程),或在环境变量中设置
    COPILOT_GITHUB_TOKEN
    /
    GH_TOKEN
    /
    GITHUB_TOKEN
  3. 确认
    copilot version
    命令可成功执行。
  4. 在目标git仓库中工作,或通过
    --cd
    参数指定目标仓库路径。

Choose the model (optional)

选择模型(可选)

Copilot picks a default model (
auto
). To choose another, pass
--model <name>
. The relay accepts letters, digits, and
. _ : / -
only (the value reaches a shell on Windows).
Copilot会选择默认模型(
auto
)。如需选择其他模型,传递
--model <name>
参数。 中继工具仅接受字母、数字以及
. _ : / -
字符(该参数值会传递给Windows系统的Shell)。

Choose the effort (optional)

选择推理强度(可选)

Copilot supports a reasoning effort dial:
--effort <level>
with values
low
,
medium
,
high
,
xhigh
, or
max
. The relay rejects any other value before dispatch.
Copilot支持推理强度调节:使用
--effort <level>
参数,可选值为
low
medium
high
xhigh
max
。中继工具在执行前会拒绝其他任何值。

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 a brief

1. 撰写任务简报

Copilot sees only the text you send. It cannot read your conversation: the brief must stand alone with the goal, current state, what to change, what to leave untouched, the project's real gates, and a report contract. Keep each brief to a single task. Write it to a file and pass it as the relay's
--brief
. See references/writing-the-brief.md.
Copilot只能看到你发送的文本内容,无法读取你的对话记录:任务简报必须独立包含目标、当前状态、需要修改的内容、需要保留的内容、项目的实际校验规则,以及报告要求。每份简报对应单个任务。将简报写入文件并通过中继工具的
--brief
参数传递。详见references/writing-the-brief.md

2. Dispatch

2. 任务分发

Use the bundled relay. It runs
copilot -p
with
--output-format json --no-color --stream off
, captures the JSONL event stream, and writes
result.json
.
bash
node "<skill-dir>/scripts/relay.mjs" --brief brief.txt --cd /path/to/repo
使用内置的中继工具。它会运行
copilot -p
并附带
--output-format json --no-color --stream off
参数,捕获JSONL事件流并写入
result.json
文件。
bash
node "<skill-dir>/scripts/relay.mjs" --brief brief.txt --cd /path/to/repo

choose a model: add --model <name>

选择模型: 添加 --model <name>

set reasoning effort: add --effort <level>

设置推理强度: 添加 --effort <level>

read-only planning pass: add --read-only (forces --mode plan)

只读规划模式: 添加 --read-only (强制使用--mode plan模式)

full tool autonomy: add --allow-all-tools

完全工具自主权: 添加 --allow-all-tools

hard time limit (watchdog): add --timeout 2h (the 30m default suits brief runs)

强制时间限制(监控): 添加 --timeout 2h (默认30分钟适合短任务)

resume a session: add --session <id> or --resume-last

恢复会话: 添加 --session <id> 或 --resume-last

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

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


The child's cwd pins the workspace. 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).

子进程的当前工作目录会固定为目标工作区。中继工具默认将产物写入系统临时目录,且绝不会自动提交代码。详见[references/dispatch-and-poll.md](references/dispatch-and-poll.md)。

3. Wait for completion

3. 等待任务完成

The relay blocks until copilot 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
copilot
exits 127 and writes
status: "copilot_unavailable"
.
Completion means the process exited and
result.json
exists — trust process state and the working tree, not the progress display. Copilot's final assistant message is the
finalMessage
field of
result.json
.
中继工具会阻塞直到copilot完成任务。可通过协调工具的后台命令功能运行它,或在Shell中后台运行并轮询
result.json
文件。预运行时的使用错误会以退出码2结束且不会写入结果;若
copilot
未安装则以退出码127结束并写入
status: "copilot_unavailable"
任务完成意味着进程已退出且
result.json
文件存在——请以进程状态和工作目录为准,而非进度显示。Copilot的最终助手消息会存储在
result.json
finalMessage
字段中。

4. Review — do not trust the self-report

4. 审核——不要依赖自我报告

  • Re-run the project's gates yourself.
  • Read the diff against the brief, starting with
    touchedFiles
    .
  • Run relevant guard skills if installed.
See references/review-and-land.md.
  • 自行重新运行项目的校验规则。
  • 对照任务简报查看代码差异,从
    touchedFiles
    开始检查。
  • 如果已安装相关校验工具,运行它们。
详见references/review-and-land.md

5. Land it

5. 完成提交

If the work is good, commit it. The relay never commits — the diff and
result.json
are the record; run
git status
and
git diff
first to confirm exactly what changed. If the group has a PR flow, make the commit and push a branch; let human review happen. If the diff is wrong or incomplete, re-dispatch a corrected brief in a fresh run and review again.
如果工作成果符合要求,提交代码。中继工具绝不会自动提交——代码差异和
result.json
是记录;提交前请先运行
git status
git diff
确认具体修改内容。如果团队采用PR流程,请提交代码并推送分支,交由人工审核。如果代码差异有误或不完整,请在新的运行中重新分发修正后的任务简报并再次审核。

Autonomy and permissions

自主权与权限

Without
--allow-all-tools
, copilot auto-denies tool calls in headless mode: the process exits 0 but the relay detects the denial events and reports
status: "failed"
with the CLI's own error message and a hint to pass
--allow-all-tools
. This is the honest default — the orchestrator sees the failure rather than a silent no-op.
--allow-all-tools
explicitly grants full tool autonomy.
--read-only
selects
--mode plan
, which disables edit tools so project files can't be changed by direct edits; it works without
--allow-all-tools
. Shell commands still run in plan mode, so it guards against edits, not against everything. The two flags are mutually exclusive.
Copilot also exposes sandbox controls, but they are upstream-experimental (MXC-based, controlled via the
/sandbox
command and settings, disabled by default). This relay does not configure them.
如果未添加
--allow-all-tools
参数,copilot在无头模式下会自动拒绝工具调用:进程会以退出码0结束,但中继工具会检测到拒绝事件并报告
status: "failed"
,同时附带CLI自身的错误消息和添加
--allow-all-tools
参数的提示。这是默认的安全设置——协调工具会看到失败信息而非静默无操作。
--allow-all-tools
参数会明确授予完全的工具自主权。
--read-only
参数会选择
--mode plan
模式,该模式会禁用编辑工具,避免项目文件被直接修改;无需
--allow-all-tools
参数即可生效。规划模式下Shell命令仍可运行,因此该参数仅能防止文件编辑,而非所有操作。这两个参数互斥。
Copilot还提供沙箱控制功能,但属于上游实验性特性(基于MXC,通过
/sandbox
命令和设置控制,默认禁用)。本中继工具不会配置这些特性。

Authorization model

授权模型

Delegation is something the human opts into. Once briefed, copilot works as a tool you approved use of. The boundary is: do not accept conclusions from the self-report; verify everything on disk. For anything touching credentials, production data, or irreversible operations, stop and ask the human first instead of encoding it in a brief.
委托操作是由人工主动选择的。任务简报确认后,copilot作为你批准使用的工具开展工作。边界原则是:不要接受自我报告的结论;请验证磁盘上的所有内容。对于任何涉及凭证、生产数据或不可逆操作的任务,请先询问人工而非将其写入任务简报。

References

参考文档

  • references/writing-the-brief.md — structure, scope, gates, brief delivery.
  • references/dispatch-and-poll.md — flags, artifacts,
    result.json
    , and failure recovery.
  • references/review-and-land.md — what to verify before calling the diff done, at the end of a run.
  • 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 — 运行结束时,确认代码差异完成前需要验证的内容。
  • references/multi-task-queues.md — 顺序任务队列、约束传递、进度跟踪以及最终一致性检查。