grok-delegate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGrok Delegate
Grok Delegate
Cross-harness orchestration of Grok Build native CLI only. Parent harness owns the macro graph; Grok executes micro nodes.
仅针对Grok Build原生CLI的跨工具编排。父工具负责宏图管理;Grok执行微节点任务。
Dispatch
调度
| $ARGUMENTS | Action |
|---|---|
| (empty) | Show pre-flight, wave taxonomy, critical rules, and reference index |
| Run |
| Run fast auth checks; show |
| Show Tier-T eligibility and single-node |
| Show command templates for scout / build / verify waves |
| Show session resume / delta prompt loop |
| Show leader pool lifecycle |
| Show session ledger schema |
| Show orchestrator Pattern A–F → Grok flag mapping |
| 参数 | 操作 |
|---|---|
| (空) | 显示预检信息、wave分类体系、关键规则及参考索引 |
| 运行 |
| 执行快速身份验证检查;展示 |
| 展示Tier-T资格条件及单节点 |
| 展示侦察/构建/验证wave的命令模板 |
| 展示会话恢复/增量提示循环流程 |
| 展示领导者池生命周期 |
| 展示会话账本 schema |
| 展示编排器Pattern A–F到Grok参数的映射关系 |
Classification Gate
分类准入规则
- Use when the parent harness owns a multi-node graph and at least one node should run on Grok Build via native CLI.
- Use when a gate failed and the parent needs tune passes on an existing ledger row.
-r <sessionId> - Tier-T default — use by default when fast preflight
trivial,okisgrok-auth-expiry, and the leaf is bounded (≤3 reads OR ≤1 file ≤80 LOC; no destructive/prod/git-push/secrets; no unresolved user-pivotal or subtask-pivotal uncertainty). Parent keeps synthesis.ok - Tier-T failure fallback — if the first native Tier-T dispatch fails for a parent work item, stop Tier-T for that item and continue locally.
grok -p - Do not use for Grok config/MCP sync, skill installs, or nested Grok-in-Grok orchestration.
- Do not use Tier-T for multi-node graphs, overlapping file writers, or unbounded parent work better done in-session; use /
wavefor valid multi-node Grok graphs.patterns - Malformed dispatch — without
waveis invalid; show valid tiers or the empty-args gallery. Never invent a default wave.0|1|2
- 适用场景:父工具管理多节点图,且至少一个节点需通过原生CLI在Grok Build上运行。
- 适用场景:准入检查失败,父工具需对现有账本记录执行调优操作。
-r <sessionId> - Tier-T默认规则:当快速预检通过、状态正常,且叶节点为受限任务(≤3次读取操作 或 ≤1个文件且代码行数≤80;无破坏性/生产环境/git推送/敏感信息操作;无未解决的用户关键或子任务关键不确定性)时,默认使用
grok-auth-expiry模式。父工具保留合成权限。trivial - Tier-T失败回退:若父工作项首次原生Tier-T调度失败,则终止该工作项的Tier-T流程,转为本地执行。
grok -p - 禁用场景:Grok配置/MCP同步、skill安装或嵌套Grok-in-Grok编排。
- Tier-T禁用场景:多节点图、重叠文件写入操作,或更适合在会话内完成的无界父工作任务;针对有效的多节点Grok图,使用/
wave模式。patterns - 格式错误调度:命令未指定
wave参数时无效;展示有效层级或空参数下的选项列表。不得自行默认wave层级。0|1|2
Operator Contract
操作协议
preflight
preflightpreflight
preflight- Run from any cwd (bundled
bash scripts/preflight.sh; optionaldoctor.pyfor target repo).--cwd - Stop fleet dispatch when JSON is false or any
ok/grok-auth-*check isgrok-binary.fail - Treat as advisory; any
warngrok-auth-expiry(expired, missing, or malformedfail) blocks fleet dispatch and Tier-T offload.expires_at
- 从任意工作目录运行(内置
bash scripts/preflight.sh;可通过doctor.py指定目标仓库)。--cwd - 当JSON输出中为false,或任何
ok/grok-auth-*检查失败时,终止集群调度。grok-binary - 将视为建议信息;任何
warn失败(过期、缺失或格式错误的grok-auth-expiry)将阻止集群调度和Tier-T任务卸载。expires_at
auth
authauth
auth- Run ; inspect
preflight.shchecks in JSON output.grok-auth-* - Load for OAuth-primary remediation (
references/auth.md).grok login - Optional deep smoke: .
bash scripts/auth_verify.sh --cwd <target>
- 运行;检查JSON输出中的
preflight.sh项。grok-auth-* - 加载获取基于OAuth的修复方案(
references/auth.md)。grok login - 可选深度验证:。
bash scripts/auth_verify.sh --cwd <target>
trivial
trivialtrivial
trivial- Confirm Tier-T eligibility (Classification Gate item 3).
- Run fast preflight; require and
ok: true(OAuth healthy).grok-auth-expiry: ok - For the one-file edit form, the parent must run normal branch and dirty-worktree safety checks before dispatch. Confirm the target file does not overlap unrelated dirty work and keep the parent responsible for review, synthesis, and validation.
- Dispatch one bounded node:
bash
grok --no-auto-update \
-p "<bounded self-contained task>" \
--cwd "<absolute-repo-path>" \
--output-format json \
--max-turns 10- If the native dispatch fails, record the failure, stop Tier-T for the current parent work item, and continue locally.
- 确认Tier-T资格(分类准入规则第3条)。
- 执行快速预检;要求且
ok: true(OAuth状态正常)。grok-auth-expiry: ok - 对于单文件编辑任务,父工具在调度前必须执行常规分支和工作区脏文件安全检查。确认目标文件未与无关脏文件重叠,并由父工具负责审核、合成和验证。
- 调度一个受限节点:
bash
grok --no-auto-update \
-p "<bounded self-contained task>" \
--cwd "<absolute-repo-path>" \
--output-format json \
--max-turns 10- 若原生调度失败,记录失败信息,终止当前父工作项的Tier-T流程,转为本地执行。
wave <0|1|2>
wave <0|1|2>wave <0|1|2>
wave <0|1|2>- Load references/command-templates.md for the requested tier.
- Assign distinct names and non-overlapping file ownership for wave 1.
-w w<wave>-<role>-<n> - State the parent gate that must pass before the next wave.
- 加载references/command-templates.md获取对应层级的内容。
- 为wave 1分配唯一的名称,并确保文件所有权不重叠。
-w w<wave>-<role>-<n> - 说明进入下一wave前必须通过的父工具准入检查。
tune
tunetune
tune- Load references/session-ledger.md and resume with .
-r <sessionId> - Prefix delta prompts with ; cap
Tune:at 3 perparent_tune_count.node_id - Never default .
--always-approve
- 加载references/session-ledger.md,通过恢复会话。
-r <sessionId> - 增量提示前缀添加;每个
Tune:的node_id上限为3次。parent_tune_count - 不得默认启用。
--always-approve
leader
leaderleader
leader- Load references/leader-lifecycle.md.
- Start one leader per cwd pool; kill orphans with after graph completion.
grok leader kill
- 加载references/leader-lifecycle.md。
- 每个工作目录池启动一个领导者;图任务完成后,通过终止孤立的领导者进程。
grok leader kill
ledger
ledgerledger
ledger- Load references/session-ledger.md.
- Require N terminal ledger rows before opening the next parent gate.
- 加载references/session-ledger.md。
- 开启下一个父工具准入检查前,需确保存在N条终端账本记录。
patterns
patternspatterns
patterns- Load references/graph-patterns.md and map to Pattern A–F.
/orchestrator - Keep parent accounting: N dispatched nodes = N resolved before synthesis.
- 加载references/graph-patterns.md,映射到的Pattern A–F。
/orchestrator - 父工具需记录:调度的节点数 = 合成前已解决的节点数。
(empty)
(空参数)
- Show pre-flight, wave taxonomy, critical rules, and the reference index.
- Run the Classification Gate on the current parent request before dispatching nodes.
- 展示预检信息、wave分类体系、关键规则及参考索引。
- 调度节点前,对当前父工具请求执行分类准入检查。
Canonical Vocabulary
标准术语表
| Term | Meaning |
|---|---|
| parent harness | Codex, OpenCode, Claude, or Cursor session owning the macro DAG |
| Tier-T | Default bounded trivial leaf offload via single |
| node | One |
| wave | Staged batch of nodes (0 scout, 1 build, 2 verify) |
| gate | Parent checkpoint before the next wave |
| tune | |
| ledger | |
| worktree | |
| leader pool | Shared |
| 术语 | 含义 |
|---|---|
| parent harness | 负责宏DAG的Codex、OpenCode、Claude或Cursor会话 |
| Tier-T | 快速预检通过且 |
| node | 针对图任务的一次 |
| wave | 分阶段的节点批次(0侦察、1构建、2验证) |
| gate | 进入下一wave前的父工具检查点 |
| tune | 对现有节点执行 |
| ledger | 跟踪每个节点 |
| worktree | 每个并行构建器的 |
| leader pool | 用于密集图任务的共享 |
Critical Rules
关键规则
- Native CLI only — no , MCP control server, or custom headless wrapper scripts.
bin/gk - Pre-flight mandatory — run before fleet dispatch or Tier-T offload.
scripts/preflight.sh - OAuth primary — default; API key only on explicit user request.
grok login - Parent owns the graph — Grok depth is 1; parallelize siblings via parent bash, not nested Grok orchestration.
- Never default for cross-harness delegation.
--always-approve - Always and explicit
--no-auto-updateon automation paths.--cwd - Accounting — N dispatched nodes = N terminal ledger rows before the next gate.
- One writer per worktree — non-overlapping file ownership across parallel wave 1 nodes.
- 仅使用原生CLI — 禁止使用、MCP控制服务器或自定义无头包装脚本。
bin/gk - 必须执行预检 — 集群调度或Tier-T任务卸载前,需运行。
scripts/preflight.sh - 优先使用OAuth — 默认使用;仅在用户明确请求时使用API密钥。
grok login - 父工具管理图 — Grok深度为1;通过父工具的bash脚本并行处理兄弟节点,而非嵌套Grok编排。
- 跨工具委托时不得默认启用。
--always-approve - 自动化路径中必须使用和显式
--no-auto-update。--cwd - 记录规则 — 调度的节点数 = 进入下一个准入检查前的终端账本记录数。
- 每个工作树仅一个写入者 — 并行wave 1节点间的文件所有权不得重叠。
When to use
适用场景
- Parent dispatches independent Grok nodes via bash (Pattern A/E).
- Tier-T bounded leaf offload by default when fast preflight and pass.
grok-auth-expiry - Tune-in-place after gate failure: .
-r <sessionId> - Parallel builders with worktrees or hypothesis
-w.--best-of-n
- 父工具通过bash调度独立的Grok节点(Pattern A/E)。
- 快速预检和通过时,默认使用Tier-T卸载受限叶节点。
grok-auth-expiry - 准入检查失败后原地调优:。
-r <sessionId> - 使用工作树或假设性
-w的并行构建器。--best-of-n
When NOT to use
禁用场景
- Multi-node graphs or overlapping writers (use waves, not Tier-T).
- Destructive, production, git-push, secret-reading, or broad implementation work.
- Grok config/MCP sync — .
/harness-master - Skill installs — Skills CLI dry-run preview only (no live unless maintainer requests).
--apply - Nested Grok-in-Grok graphs beyond platform depth 1.
- 多节点图或重叠写入操作(使用wave模式,而非Tier-T)。
- 破坏性、生产环境、git推送、读取敏感信息或大范围实现工作。
- Grok配置/MCP同步 — 使用。
/harness-master - Skill安装 — 仅使用Skills CLI干运行预览(除非维护者请求,否则不得执行实时)。
--apply - 平台深度超过1的嵌套Grok-in-Grok图。
Pre-flight
预检
Authoritative procedure: Operator Contract → / above.
preflightauthbash
bash skills/grok-delegate/scripts/preflight.shInspect target repo: ( has no flag).
cd <target-repo> && grok inspect --jsongrok inspect--cwd权威流程:操作协议 → 上述/部分。
preflightauthbash
bash skills/grok-delegate/scripts/preflight.sh检查目标仓库:(无参数)。
cd <target-repo> && grok inspect --jsongrok inspect--cwdThree-tier model
三层模型
- Parent — or OpenCode Ensemble owns waves and gates.
/orchestrator - This skill — templates, ledger, safety, recovery.
- Grok CLI — ,
-p, worktrees, leader, optional-r.grok agent stdio
- 父工具 — 或OpenCode Ensemble负责wave和准入检查。
/orchestrator - 本skill — 模板、账本、安全、恢复。
- Grok CLI — 、
-p、工作树、领导者、可选-r。grok agent stdio
Wave taxonomy
Wave分类体系
| Wave | Purpose | Typical | |
|---|---|---|---|
| 0 scout | Read-only exploration | | 8 |
| 1 build | Implementation | repo agent | 25 |
| 2 verify | Tests, review | | 10 |
| tune | Delta on session | inherit | 10 |
| hypothesis | Competing theories | | 12 |
Templates: references/command-templates.md.
| Wave | 用途 | 典型 | |
|---|---|---|---|
| 0 scout | 只读探索 | | 8 |
| 1 build | 实现开发 | repo agent | 25 |
| 2 verify | 测试、评审 | | 10 |
| tune | 会话增量调优 | 继承 | 10 |
| hypothesis | 竞争性方案验证 | | 12 |
模板:references/command-templates.md。
Single node
单节点
bash
grok --no-auto-update \
-p "<self-contained task>" \
--cwd "<absolute-repo-path>" \
--output-format json \
--max-turns 25 \
--agent "<agent-name>"Parse JSON per references/output-json.md. Append ledger row per references/session-ledger.md.
bash
grok --no-auto-update \
-p "<self-contained task>" \
--cwd "<absolute-repo-path>" \
--output-format json \
--max-turns 25 \
--agent "<agent-name>"根据references/output-json.md解析JSON。根据references/session-ledger.md追加账本记录。
Tune loop
调优循环
bash
grok --no-auto-update \
-r "<sessionId>" \
-p "Tune: <delta only>" \
--cwd "<same cwd>" \
--output-format json \
--max-turns 10Cap at 3 per .
parent_tune_countnode_idbash
grok --no-auto-update \
-r "<sessionId>" \
-p "Tune: <delta only>" \
--cwd "<same cwd>" \
--output-format json \
--max-turns 10每个的上限为3次。
node_idparent_tune_countParallel wave dispatch
并行Wave调度
Dispatch N independent bash subprocesses in one parent message. Each node gets unique and non-overlapping ownership. See references/concurrency.md.
-w w<wave>-<role>-<n>在一条父工具消息中调度N个独立的bash子进程。每个节点分配唯一的,且文件所有权不重叠。详情见references/concurrency.md。
-w w<wave>-<role>-<n>Leader pool
领导者池
bash
grok agent leader --no-exit-on-disconnect --no-auto-updateClients attach with . Details: references/leader-lifecycle.md.
grok agent --leaderbash
grok agent leader --no-exit-on-disconnect --no-auto-update客户端通过连接。详情:references/leader-lifecycle.md。
grok agent --leaderRecovery ladder
恢复阶梯
- Node fail → one retry; else ledger .
failed - JSON parse fail → triage.
--output-format plain - Leader dead → ; restart pool.
grok leader list - Auth fail → ; re-run preflight; stop fleet until
grok loginchecks pass.grok-auth-*
- 节点失败 → 重试一次;否则标记账本为。
failed - JSON解析失败 → 使用进行诊断。
--output-format plain - 领导者进程终止 → 执行;重启池。
grok leader list - 身份验证失败 → 执行;重新运行预检;集群调度需等待
grok login检查通过后方可恢复。grok-auth-*
Completion criteria
完成标准
- Pre-flight doctor JSON
ok: true - Every dispatched node has terminal ledger status
- Parent gate passed or explicit user abort recorded
- Orphan leaders killed:
grok leader kill
- 预检诊断JSON输出
ok: true - 所有调度节点均有终端账本状态
- 父工具准入检查通过,或已记录用户明确终止操作
- 孤立领导者已被终止:
grok leader kill
Validation
验证
check.pyparse_grok_jsonbash
uv run python skills/grok-delegate/scripts/check.py
uv run pytest tests/test_grok_delegate_*.py -q
uv run python skills/skill-creator/scripts/audit.py skills/grok-delegate
uv run python skills/skill-creator/scripts/package.py skills/grok-delegate --dry-runcheck.pyparse_grok_jsonbash
uv run python skills/grok-delegate/scripts/check.py
uv run pytest tests/test_grok_delegate_*.py -q
uv run python skills/skill-creator/scripts/audit.py skills/grok-delegate
uv run python skills/skill-creator/scripts/package.py skills/grok-delegate --dry-runReference index
参考索引
| File | Content |
|---|---|
| wave-dag.md | Wave gates on bash dispatch |
| graph-patterns.md | Orchestrator A–F + Tier-T mapping |
| command-templates.md | Copy-paste invocations |
| output-json.md | Headless JSON fields |
| session-ledger.md | Ledger schema |
| agent-map.md | Repo agents → |
| concurrency.md | Budgets, naming |
| leader-lifecycle.md | Leader start/stop |
| acp-driver.md | Official ACP stdio excerpt |
| safety-permissions.md | Permission matrix |
| auth.md | OAuth-primary auth and remediation |
| doctor-output.md | Bundled doctor JSON |
Official docs: https://docs.x.ai/build/cli/headless-scripting
| 文件 | 内容 |
|---|---|
| wave-dag.md | bash调度中的Wave准入检查 |
| graph-patterns.md | 编排器A–F + Tier-T映射关系 |
| command-templates.md | 可直接复制的调用命令 |
| output-json.md | 无头模式JSON字段说明 |
| session-ledger.md | 账本schema |
| agent-map.md | 仓库代理 → |
| concurrency.md | 预算、命名规则 |
| leader-lifecycle.md | 领导者进程启动/终止 |
| acp-driver.md | 官方ACP标准输入输出摘录 |
| safety-permissions.md | 权限矩阵 |
| auth.md | 基于OAuth的身份验证及修复方案 |
| doctor-output.md | 内置诊断工具JSON输出示例 |
Scope boundaries
范围边界
IS for: native Grok CLI delegation, wave templates, Tier-T trivial offload, session tune loops, parallel worktree dispatch, leader pool policy.
NOT for: Grok config sync, custom wrappers, MCP servers, or live unless the maintainer requests it.
skills sync --apply适用范围:原生Grok CLI委托、wave模板、Tier-T简单任务卸载、会话调优循环、并行工作树调度、领导者池策略。
禁用范围:Grok配置同步、自定义包装器、MCP服务器,或实时(除非维护者请求)。
skills sync --apply