harnessed 4.32.21 → 4.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +6 -6
  2. package/bin/harnessed-inject-state.mjs +16 -0
  3. package/dist/cli.mjs +1419 -276
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/index.mjs +1 -1
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/schemas/index.mjs.map +1 -1
  8. package/manifests/optional/chrome-devtools-mcp.yaml +60 -0
  9. package/manifests/optional/doc-discipline-gate.yaml +54 -0
  10. package/manifests/optional/ecc.yaml +28 -14
  11. package/manifests/tools/exa-mcp.yaml +51 -0
  12. package/manifests/tools/tavily-mcp.yaml +4 -4
  13. package/messages/en.json +11 -0
  14. package/messages/zh-Hans.json +11 -0
  15. package/package.json +1 -1
  16. package/routing/decision_rules.yaml +1 -1
  17. package/workflows/README.md +1 -1
  18. package/workflows/auto/SKILL.md +13 -9
  19. package/workflows/auto/SKILL.zh-Hans.md +13 -9
  20. package/workflows/capabilities.yaml +105 -45
  21. package/workflows/defaults.yaml +8 -2
  22. package/workflows/disciplines/karpathy.yaml +29 -0
  23. package/workflows/disciplines/karpathy.zh-Hans.yaml +27 -0
  24. package/workflows/disciplines/language.yaml +15 -10
  25. package/workflows/disciplines/operational.yaml +1 -1
  26. package/workflows/disciplines/operational.zh-Hans.yaml +1 -1
  27. package/workflows/disciplines/output-style.yaml +10 -2
  28. package/workflows/disciplines/output-style.zh-Hans.yaml +10 -2
  29. package/workflows/disciplines/priority.yaml +15 -2
  30. package/workflows/disciplines/priority.zh-Hans.yaml +15 -2
  31. package/workflows/discuss/auto/SKILL.md +4 -4
  32. package/workflows/discuss/auto/SKILL.zh-Hans.md +4 -4
  33. package/workflows/discuss/auto/workflow.yaml +16 -3
  34. package/workflows/discuss/phase/SKILL.md +1 -1
  35. package/workflows/discuss/phase/SKILL.zh-Hans.md +1 -1
  36. package/workflows/discuss/strategic/SKILL.md +1 -1
  37. package/workflows/discuss/strategic/SKILL.zh-Hans.md +1 -1
  38. package/workflows/discuss/subtask/SKILL.md +1 -1
  39. package/workflows/discuss/subtask/SKILL.zh-Hans.md +1 -1
  40. package/workflows/judgments/parallelism-gate.yaml +11 -6
  41. package/workflows/judgments/phase-gate.yaml +5 -1
  42. package/workflows/judgments/stage-routing.yaml +21 -26
  43. package/workflows/judgments/strategic-gate.yaml +30 -0
  44. package/workflows/judgments/user-overrides.yaml +7 -3
  45. package/workflows/judgments/web-search-routing.yaml +3 -3
  46. package/workflows/judgments/web-testing-routing.yaml +24 -7
  47. package/workflows/plan/architecture/SKILL.md +7 -3
  48. package/workflows/plan/architecture/SKILL.zh-Hans.md +7 -3
  49. package/workflows/plan/auto/SKILL.md +11 -7
  50. package/workflows/plan/auto/SKILL.zh-Hans.md +11 -7
  51. package/workflows/plan/phase/SKILL.md +7 -3
  52. package/workflows/plan/phase/SKILL.zh-Hans.md +7 -3
  53. package/workflows/research/SKILL.md +24 -9
  54. package/workflows/research/SKILL.zh-Hans.md +23 -9
  55. package/workflows/research/workflow.yaml +43 -3
  56. package/workflows/retro/SKILL.md +7 -3
  57. package/workflows/retro/SKILL.zh-Hans.md +7 -3
  58. package/workflows/role-prompts.yaml +28 -21
  59. package/workflows/role-prompts.zh-Hans.yaml +22 -17
  60. package/workflows/ship/auto/SKILL.md +11 -7
  61. package/workflows/ship/auto/SKILL.zh-Hans.md +11 -7
  62. package/workflows/ship/preflight/SKILL.md +7 -3
  63. package/workflows/ship/preflight/SKILL.zh-Hans.md +7 -3
  64. package/workflows/task/auto/SKILL.md +26 -16
  65. package/workflows/task/auto/SKILL.zh-Hans.md +26 -16
  66. package/workflows/task/auto/workflow.yaml +11 -4
  67. package/workflows/task/clarify/SKILL.md +1 -1
  68. package/workflows/task/clarify/SKILL.zh-Hans.md +1 -1
  69. package/workflows/task/code/SKILL.md +7 -3
  70. package/workflows/task/code/SKILL.zh-Hans.md +7 -3
  71. package/workflows/task/deliver/SKILL.md +53 -35
  72. package/workflows/task/deliver/SKILL.zh-Hans.md +54 -36
  73. package/workflows/task/deliver/workflow.yaml +32 -24
  74. package/workflows/task/test/SKILL.md +7 -3
  75. package/workflows/task/test/SKILL.zh-Hans.md +7 -3
  76. package/workflows/task/test/workflow.yaml +13 -0
  77. package/workflows/verify/auto/SKILL.md +12 -8
  78. package/workflows/verify/auto/SKILL.zh-Hans.md +12 -8
  79. package/workflows/verify/auto/workflow.yaml +3 -1
  80. package/workflows/verify/code-review/SKILL.md +7 -3
  81. package/workflows/verify/code-review/SKILL.zh-Hans.md +7 -3
  82. package/workflows/verify/design/SKILL.md +24 -10
  83. package/workflows/verify/design/SKILL.zh-Hans.md +24 -10
  84. package/workflows/verify/design/workflow.yaml +36 -7
  85. package/workflows/verify/eval-review/SKILL.md +7 -3
  86. package/workflows/verify/eval-review/SKILL.zh-Hans.md +7 -3
  87. package/workflows/verify/multispec/SKILL.md +17 -10
  88. package/workflows/verify/multispec/SKILL.zh-Hans.md +16 -10
  89. package/workflows/verify/multispec/workflow.yaml +7 -5
  90. package/workflows/verify/paranoid/SKILL.md +7 -3
  91. package/workflows/verify/paranoid/SKILL.zh-Hans.md +7 -3
  92. package/workflows/verify/progress/SKILL.md +7 -3
  93. package/workflows/verify/progress/SKILL.zh-Hans.md +7 -3
  94. package/workflows/verify/qa/SKILL.md +33 -14
  95. package/workflows/verify/qa/SKILL.zh-Hans.md +33 -14
  96. package/workflows/verify/qa/workflow.yaml +55 -2
  97. package/workflows/verify/security/SKILL.md +7 -3
  98. package/workflows/verify/security/SKILL.zh-Hans.md +7 -3
  99. package/workflows/verify/simplify/SKILL.md +7 -3
  100. package/workflows/verify/simplify/SKILL.zh-Hans.md +7 -3
  101. package/workflows/verify/validate-phase/SKILL.md +7 -3
  102. package/workflows/verify/validate-phase/SKILL.zh-Hans.md +7 -3
  103. package/manifests/skill-packs/karpathy-skills.yaml +0 -65
  104. package/manifests/tools/chrome-devtools-mcp.yaml +0 -64
  105. package/manifests/tools/ralph-loop.yaml +0 -46
@@ -120,24 +120,28 @@ Do NOT pipe to `harnessed run auto` — that is the CI/headless path (in-process
120
120
  that blocks the session, bypasses Agent Teams, and hangs inside Claude Code).
121
121
 
122
122
  1. FIRST run the discuss stage interactively in THIS session (spawned subagents cannot ask the user questions). Evaluate strategic / phase / subtask clarification criteria for "$ARGUMENTS"; dialogue with the user (AskUserQuestion) for each layer that fires, lock decisions, transparent-skip the rest. After locking blocking decisions, relay the deferrable set to the user in a single batched AskUserQuestion with each agent-recommended default pre-selected — deferrable defers scheduling, not user authority; only skip an item if the user explicitly defers it again. Produce a locked spec.
123
- 2. Bash: `harnessed gates auto --task "<locked spec>" --skip-sub discuss` → parse the JSON `{fire, skip, parallelism}`. This is the plan SoT (no spawn). Keep the verbatim JSON. For a small self-contained task (single-file / single-page class), the sanctioned lite path is adding `--skip-sub verify --skip-sub retro` (repeatable / comma-separated) — skipped subs are still recorded in the ledger with reasons; lite ≠ freestyle (the ledger/evidence IS the difference).
123
+ 1b. Bash: `harnessed facts auto --out .harnessed-facts.json` → it lists ONLY the facts this stage’s gates actually read: deterministic ones already filled (change size / files touched / stage, from git), judgement calls left `null` with a one-line hint of what to judge. Edit the file and replace each `null` in `facts` with your honest answer from the locked spec — leave one null only if you genuinely cannot judge it (it then falls back to the built-in default). Do NOT skip this step and do NOT invent facts the command did not ask for.
124
+ 2. Bash: `harnessed gates auto --task "<locked spec>" --context-file .harnessed-facts.json --skip-sub discuss` → parse the JSON `{fire, skip, parallelism}`. This is the plan SoT (no spawn). Keep the verbatim JSON. For a small self-contained task (single-file / single-page class), the sanctioned lite path is adding `--skip-sub verify --skip-sub retro` (repeatable / comma-separated) — skipped subs are still recorded in the ledger with reasons; lite ≠ freestyle (the ledger/evidence IS the difference).
124
125
  3. Bash: `harnessed checkpoint start auto --plan '<the verbatim gates JSON from step 2>'` → seeds the per-sub ledger so `harnessed status --recover` can re-orient you after compaction.
125
- 4. If `parallelism.escalate_to_teams === true`: read `~/.claude/rules/agent-teams.md`, then drive the fired subs as an Agent Team (`TeamCreate` → `Agent(name, team_name, …)` per sub with its `harnessed prompt <sub>` prompt → coordinate via `SendMessage` → `SendMessage shutdown_request` + `TeamDelete`). Still checkpoint each sub (`complete` / `fail`) as below.
126
- - **Teardown is a MUST-in-finally contract, not best-effort**: regardless of whether every sub reached COMPLETE, max_iterations was exhausted, or you consider the work done, before you end the run you MUST `SendMessage shutdown_request` to every teammate + `TeamDelete`. Skipping teardown leaves orphan teammate processes that hang the host (headless especially — issue #7: an 11h hang, work complete but the process never exited).
127
- - **Headless never spawns teams**: in a headless session (`claude -p`) `harnessed gates` already returns `escalate_to_teams: false` (Agent Teams are session-scoped — lost on `/resume`, incompatible with `-p`). Do NOT `TeamCreate` or background-`Agent` spawn in headless even if you think it would parallelize — run the fired subs sequentially in-session instead.
126
+ 4. If `parallelism.escalate_to_teams === true`: read `~/.claude/rules/agent-teams.md`, then drive the fired subs as an Agent Team. There is NO create step and no create tool — spawn one background teammate per fired sub with `Agent(name: <sub>, run_in_background: true, prompt: <that sub's `harnessed prompt <sub>` prompt>)` and the team forms implicitly on the FIRST spawn, with this session as lead (the `team_name` input is accepted but ignored — the name is session-derived). Coordinate via `SendMessage`; when a sub is finished, ask that teammate to shut down BY NAME (e.g. "ask the verify-qa teammate to shut down"). Still checkpoint each sub (`complete` / `fail`) as below.
127
+ - **Shut every teammate down before you finish — MUST-in-finally, not best-effort**: regardless of whether every sub reached COMPLETE, max_iterations was exhausted, or you consider the work done, ask each teammate to shut down by name before you end the run, and confirm it actually stopped. Shutdown is a REQUEST: the teammate finishes its current tool call first and may reject with a reason, so re-ask rather than assume. The team directory is removed automatically at session exit (there is no teardown tool), but a teammate you never stopped keeps consuming tokens and can hang the host (headless especially — issue #7: an 11h hang, work complete but the process never exited).
128
+ - **Headless never spawns teams**: in a headless session (`claude -p`) `harnessed gates` already returns `escalate_to_teams: false` (Agent Teams are session-scoped — lost on `/resume`, incompatible with `-p`). Do NOT spawn teammates or background-`Agent` in headless even if you think it would parallelize — run the fired subs sequentially in-session instead.
128
129
  5. Otherwise, for each fired sub in `order` (serial subs sequentially, parallel subs concurrently):
129
- - **If the entry has `is_master: true`** (a stage master — e.g. `/auto` firing `plan`/`task`/`verify`): do NOT prompt+spawn it. RECURSE: run that master’s own `harnessed gates <sub> --task "<spec>" --skip-sub discuss` → `harnessed checkpoint start <sub> --plan '<json>'` → repeat this loop for ITS fired subs.
130
+ - **If the entry has `is_master: true`** (a stage master — e.g. `/auto` firing `plan`/`task`/`verify`): do NOT prompt+spawn it. RECURSE: run that master’s own `harnessed facts <sub> --out .harnessed-facts.json` (fill the nulls) → `harnessed gates <sub> --task "<spec>" --context-file .harnessed-facts.json --skip-sub discuss` → `harnessed checkpoint start <sub> --plan '<json>'` → repeat this loop for ITS fired subs.
130
131
  - **Else (leaf sub):**
131
132
  a. Bash: `harnessed prompt <sub> --task "<spec>" --json` → parse `{prompt, max_iterations, model}`.
132
- b. Spawn a CC-native subagent (Task / Agent tool) with that `prompt` + `model`, wrapped in the ralph-loop plugin: `/ralph-loop "<prompt>" --max-iterations <max_iterations> --completion-promise "COMPLETE"`. If the plugin is absent, use the native goal gate instead (Claude Code 2.1.139+ / Codex): `/goal "this subtask is delivered: the subagent's final output contains verbatim <promise>COMPLETE</promise>; or stop after <max_iterations> turns"` then spawn the subagent and let the goal evaluator drive re-spawns until it clears. If `/goal` is unavailable too, self-loop: spawn → check output for `<promise>COMPLETE</promise>` → re-spawn with prior output appended (up to max_iterations). Set the goal only at the leaf subtask level — `/goal` is single-slot per session and a nested goal overwrites the outer one.
133
+ b. Spawn a CC-native subagent (Task / Agent tool) with that `prompt` and `model`, then drive delivery with harnessed's own completion gate:
134
+ - on return, write the subagent's final output to a file and run `harnessed checkpoint complete <sub> --result-file <path>` — it is fail-closed on the declared artifacts, the TDD boundary, and the verbatim `<promise>COMPLETE</promise>`.
135
+ - if it blocks, run `harnessed checkpoint fail <sub> --failing-tests <n>` to record the attempt; it prints BUDGET-EXHAUSTED / NO-PROGRESS / BREAK-LOOP when a stop condition is reached.
136
+ - respawn ONLY while none of those three has fired. Any one of them means stop: re-scope the subtask, fix the blocker, or escalate to the user. Never respawn past a stop directive.
133
137
  c. If the output contains `STATUS: NEEDS_CLARIFICATION` + questions: STOP, relay them verbatim via AskUserQuestion, append the answers to the spec, then re-spawn the same sub.
134
- d. On `<promise>COMPLETE</promise>`: Bash `harnessed checkpoint complete <sub> --summary "<one-line>"`. The evidence guard runs here (fail-CLOSED): if a declared `artifacts_expected` file is missing it exits non-zero — re-spawn to produce it, or pass `--force` only to deliberately override.
135
- e. If the sub cannot reach COMPLETE (max_iterations exhausted / unrecoverable error): Bash `harnessed checkpoint fail <sub> --summary "<why>"`, then STOP and report to the user.
138
+ d. On `<promise>COMPLETE</promise>`: write the subagent’s final output to a file, then Bash `harnessed checkpoint complete <sub> --result-file <path> --summary "<one-line>"`. Fail-CLOSED — it blocks unless every declared `artifacts_expected` file exists, the TDD boundary passes (non-empty evidence / both the red and green sides present / the test file was not deleted), and the result carries a verbatim `<promise>COMPLETE</promise>` (or a structured COMPLETE status). `--result <text>` is the inline variant; `--result-file` wins and is quoting-safe on Windows. On a non-zero exit the sub is NOT done — re-spawn to close the gap, or pass `--force` only to deliberately override (records `evidence_status=overridden`, an audited override rather than a silent pass).
139
+ e. If the complete gate blocked: Bash `harnessed checkpoint fail <sub> --failing-tests <n>` to record the attempt (omit the flag when the sub has no tests — the evidence-artifact digest is the fallback progress metric). It prints `BUDGET-EXHAUSTED` (attempts spent vs `workflows/defaults.yaml ralph_max_iterations`), `NO-PROGRESS` (no improvement for N consecutive attempts) or `BREAK-LOOP` (this sub failed >= the threshold) once a stop condition is reached. Respawn ONLY while none of those three has fired; any one of them means STOP — re-scope, fix the blocker, or escalate to the user, and report it.
136
140
  6. After all fired subs are `done` (or recorded `failed`), Bash `harnessed status --recover` to confirm the ledger and report a per-sub fired/skipped/done/failed summary to the user. Then run the `retro` stage to capture lessons.
137
141
 
138
142
  **If you lose context (compaction / resume):** run `harnessed status --recover` first — it reads the ledger and prints "you are here, this is next" so you resume at the first `pending` sub instead of restarting. If the ledger is empty, re-run steps 2-3.
139
143
 
140
- <!-- harnessed-generated:v4.9.3 -->
144
+ <!-- harnessed-generated:v4.12.0 -->
141
145
 
142
146
  ## References
143
147
 
@@ -118,24 +118,28 @@ Sister `workflows/capabilities.yaml`:
118
118
  session、绕过 Agent Teams,在 Claude Code 内部调用时会挂死)。
119
119
 
120
120
  1. 先在**本 session** 交互式跑 discuss 阶段(spawned subagent 无法向用户提问):对 "$ARGUMENTS" 评估 strategic / phase / subtask 澄清判据,对每个 fire 的层用 AskUserQuestion 与用户对话锁决策,其余透明 skip。blocking 集锁定后,把 deferrable 集以单轮批量 AskUserQuestion 转达给用户(各项 agent 推荐默认值预选)—— deferrable 推迟的是排期,不是用户决策权;仅当用户明确再次推迟才可跳过该项。产出 locked spec。
121
- 2. Bash: `harnessed gates auto --task "<locked spec>" --skip-sub discuss` → 解析 JSON `{fire, skip, parallelism}`。这是 plan SoT(不 spawn)。保留 verbatim JSON。自包含小任务(单文件/单页面级)的合规轻量路径:追加 `--skip-sub verify --skip-sub retro`(可重复/逗号分隔)——被 skip 的 sub 仍带原因进 ledger;lite ≠ freestyle(差别就在 ledger/evidence)。
121
+ 1b. Bash: `harnessed facts auto --out .harnessed-facts.json` → 它只列出**本阶段 gate 真正读取**的 fact:能确定性推导的已填好(改动行数 / 触及文件数 / stage,来自 git),判断题留 `null` 并附一行说明。编辑该文件,把 `facts` 里每个 `null` 按 locked spec 换成你的真实判断 —— 只有确实无法判断时才留 null(此时回退内置默认值)。**不要**跳过本步,也**不要**自行编造命令没问的 fact。
122
+ 2. Bash: `harnessed gates auto --task "<locked spec>" --context-file .harnessed-facts.json --skip-sub discuss` → 解析 JSON `{fire, skip, parallelism}`。这是 plan SoT(不 spawn)。保留 verbatim JSON。自包含小任务(单文件/单页面级)的合规轻量路径:追加 `--skip-sub verify --skip-sub retro`(可重复/逗号分隔)——被 skip 的 sub 仍带原因进 ledger;lite ≠ freestyle(差别就在 ledger/evidence)。
122
123
  3. Bash: `harnessed checkpoint start auto --plan '<step 2 的 verbatim gates JSON>'` → seed per-sub ledger,让 `harnessed status --recover` 能在 compaction 后给你重新定位。
123
- 4. 若 `parallelism.escalate_to_teams === true`:读 `~/.claude/rules/agent-teams.md`,然后把 fired subs 作为 Agent Team 驱动(`TeamCreate` → 每个 sub `Agent(name, team_name, …)` + 其 `harnessed prompt <sub>` prompt → 用 `SendMessage` 协调 → `SendMessage shutdown_request` + `TeamDelete`)。每个 sub 仍按下方 checkpoint(`complete` / `fail`)。
124
- - **teardown 是 finally 强制契约,非尽力而为**:无论是否每个 sub 都到达 COMPLETE、max_iterations 是否耗尽、或你是否认为工作已完成,收尾前你都**必须**对每个 teammate `SendMessage shutdown_request` + `TeamDelete`。跳过 teardown 会留下孤儿 teammate 进程挂起宿主(headless 尤甚 —— issue #7:挂 11 小时,工作已完成但进程从不退出)。
125
- - **headless 绝不 spawn team**:headless session(`claude -p`)下 `harnessed gates` 已返回 `escalate_to_teams: false`(Agent Teams 是 session-scoped —— `/resume` 即丢,与 `-p` 不兼容)。即使你认为能并行,headless 下也**不要** `TeamCreate` 或背景 `Agent` spawn —— 改为在 session 内顺序驱动 fired subs。
124
+ 4. 若 `parallelism.escalate_to_teams === true`:读 `~/.claude/rules/agent-teams.md`,然后把 fired subs 作为 Agent Team 驱动。**没有建团步骤、也没有建团工具** —— 对每个 fired sub 用 `Agent(name: <sub>, run_in_background: true, prompt: <该 sub 的 `harnessed prompt <sub>` prompt>)` spawn 一个后台 teammate,团在**第一个** spawn 时隐式形成,本 session 即 lead(`team_name` 入参被接受但忽略 —— 团名由 session 派生)。用 `SendMessage` 协调;某个 sub 完成后,**按名**请求该 teammate 关闭(例如「ask the verify-qa teammate to shut down」)。每个 sub 仍按下方 checkpoint(`complete` / `fail`)。
125
+ - **收尾前必须关闭每个 teammate —— finally 强制契约,非尽力而为**:无论是否每个 sub 都到达 COMPLETE、max_iterations 是否耗尽、或你是否认为工作已完成,收尾前都要**按名**请求每个 teammate 关闭,并确认它真的停了。关闭是**请求**:teammate 会先做完当前 tool call,也可能带理由拒绝 —— 所以要复查重发,不要假定。团目录在 session 退出时**自动**删除(没有 teardown 工具),但你没停掉的 teammate 会持续烧 token 并可能挂起宿主(headless 尤甚 —— issue #7:挂 11 小时,工作已完成但进程从不退出)。
126
+ - **headless 绝不 spawn team**:headless session(`claude -p`)下 `harnessed gates` 已返回 `escalate_to_teams: false`(Agent Teams 是 session-scoped —— `/resume` 即丢,与 `-p` 不兼容)。即使你认为能并行,headless 下也**不要** spawn teammate 或背景 `Agent` —— 改为在 session 内顺序驱动 fired subs。
126
127
  5. 否则,对 `order` 里每个 fired sub(serial 串行、parallel 并发):
127
- - **若该项 `is_master: true`**(本身是 stage master —— 如 `/auto` fire `plan`/`task`/`verify`):**不要**直接 prompt+spawn。RECURSE:跑该 master 自己的 `harnessed gates <sub> --task "<spec>" --skip-sub discuss` → `harnessed checkpoint start <sub> --plan '<json>'` → 对它的 fired subs 重复本循环。
128
+ - **若该项 `is_master: true`**(本身是 stage master —— 如 `/auto` fire `plan`/`task`/`verify`):**不要**直接 prompt+spawn。RECURSE:跑该 master 自己的 `harnessed facts <sub> --out .harnessed-facts.json`(填完 null)→ `harnessed gates <sub> --task "<spec>" --context-file .harnessed-facts.json --skip-sub discuss` → `harnessed checkpoint start <sub> --plan '<json>'` → 对它的 fired subs 重复本循环。
128
129
  - **否则(leaf sub):**
129
130
  a. Bash: `harnessed prompt <sub> --task "<spec>" --json` → 解析 `{prompt, max_iterations, model}`。
130
- b. 用 CC-native subagent(Task / Agent 工具)以该 `prompt` + `model` spawn,用 ralph-loop plugin 包裹:`/ralph-loop "<prompt>" --max-iterations <max_iterations> --completion-promise "COMPLETE"`。若 plugin 未装,改用原生 goal gate(Claude Code 2.1.139+ / Codex):`/goal "this subtask is delivered: the subagent's final output contains verbatim <promise>COMPLETE</promise>; or stop after <max_iterations> turns"`,随后 spawn subagent,由 goal 评估器驱动重 spawn 直到目标清除。若 `/goal` 也不可用,自循环:spawn → 检查输出 `<promise>COMPLETE</promise>` → 把上轮输出 append 后重 spawn(至多 max_iterations)。goal 只在叶子 subtask 层设置 — `/goal` 每 session 单槽,嵌套 goal 会覆盖外层。
131
+ b. 用 CC-native subagent(Task / Agent 工具)以该 `prompt` + `model` spawn,然后用 harnessed 自己的完成闸门驱动交付:
132
+ - subagent 返回后,把它的最终输出写入文件,跑 `harnessed checkpoint complete <sub> --result-file <path>` —— 该命令对声明的产物、TDD boundary、逐字 `<promise>COMPLETE</promise>` 三者 fail-closed。
133
+ - 若被拦下,跑 `harnessed checkpoint fail <sub> --failing-tests <n>` 记录本次尝试;命中停机条件时它会打印 BUDGET-EXHAUSTED / NO-PROGRESS / BREAK-LOOP。
134
+ - **仅当**这三者都未触发时才允许重 spawn。任一触发即停:重新收敛子任务范围、修掉阻塞点,或上报用户。绝不越过停机指令继续重 spawn。
131
135
  c. 若输出含 `STATUS: NEEDS_CLARIFICATION` + 问题列表:STOP,用 AskUserQuestion 原样转达,把答案 append 进 spec,再重 spawn 同一 sub。
132
- d. 命中 `<promise>COMPLETE</promise>`:Bash `harnessed checkpoint complete <sub> --summary "<one-line>"`。evidence guard 在此运行(fail-CLOSED):若声明的 `artifacts_expected` 文件缺失会 exit 非零 —— 重 spawn 产出它,或仅在刻意覆盖时传 `--force`。
133
- e. 若 sub 无法达到 COMPLETE(max_iterations 耗尽 / 不可恢复错误):Bash `harnessed checkpoint fail <sub> --summary "<why>"`,然后 STOP 并向用户报告。
136
+ d. 命中 `<promise>COMPLETE</promise>`:把 subagent 最终输出写入文件,再 Bash `harnessed checkpoint complete <sub> --result-file <path> --summary "<one-line>"`。fail-CLOSED —— 除非声明的 `artifacts_expected` 文件全部存在、TDD boundary 通过(证据非空 / 红绿两侧齐全 / 测试文件未被删除)、且结果含逐字 `<promise>COMPLETE</promise>`(或结构化 COMPLETE 状态),否则拦下。`--result <text>` 是内联变体;`--result-file` 优先且在 Windows 上引号安全。exit 非零即表示该 sub **未** done —— 重 spawn 补齐,或仅在刻意覆盖时传 `--force`(记录 `evidence_status=overridden`,是可审计的覆盖而非静默放行)。
137
+ e. 若 complete 闸门拦下:Bash `harnessed checkpoint fail <sub> --failing-tests <n>` 记录本次尝试(该 sub 无测试时省略该 flag —— 回退用证据产物摘要作进展度量)。命中停机条件时它会打印 `BUDGET-EXHAUSTED`(已用尝试次数 vs `workflows/defaults.yaml ralph_max_iterations`)、`NO-PROGRESS`(连续 N 次无进展)或 `BREAK-LOOP`(该 sub 失败次数达阈值)。**仅当**三者都未触发时才允许重 spawn;任一触发即 STOP —— 重新收敛范围、修掉阻塞点或上报用户,并说明情况。
134
138
  6. 所有 fired subs `done`(或记录 `failed`)后,Bash `harnessed status --recover` 确认 ledger,并向用户报告 per-sub fired/skipped/done/failed 摘要。 然后跑 `retro` 阶段沉淀 lessons。
135
139
 
136
140
  **若丢失上下文(compaction / resume):** 先跑 `harnessed status --recover` —— 它读 ledger 并打印「你在这里,下一步是什么」,让你从第一个 `pending` sub 续跑而非重启。若 ledger 为空,重跑 step 2-3。
137
141
 
138
- <!-- harnessed-generated:v4.9.3 -->
142
+ <!-- harnessed-generated:v4.12.0 -->
139
143
 
140
144
  ## 参考文档
141
145
 
@@ -24,7 +24,8 @@
24
24
  # gstack-design-review
25
25
  # 4. 核心 capability 4 — tdd (D-13 alias) / planning-with-files (D-15 +
26
26
  # Q-AUDIT-5a claude-code-plugin reframe) /
27
- # ralph-loop (D-10) / superpowers-brainstorming
27
+ # completion-gate (4.36.0 内置化,原 D-10
28
+ # ralph-loop 上游 plugin) / superpowers-brainstorming
28
29
  # 5. Agent Teams 3 (D-11 + Q-AUDIT-5b) — agent-teams-create / agent-teams-send-message /
29
30
  # agent-teams-shutdown
30
31
  schema_version: harnessed.capabilities.v1
@@ -137,12 +138,24 @@ capabilities:
137
138
  category: tool-slash-cmd
138
139
  description: verify-work parallel fan-out (multi-agent high-confidence findings)
139
140
  # ADR-0034 Finding 1 — ECC per-language reviewers收编 as verify-dimension aliases
140
- # (NOT a parallel Bucket 11 entry; runtime/priority.yaml picks the language-matching
141
- # one → single fire, no triple-review). Opt-in: no-op when ECC absent.
141
+ # (NOT parallel Bucket 11 entries — those would triple-fire in verify).
142
+ # 4.32.23 — the selection mechanism is now REAL and prose-level: `harnessed
143
+ # prompt` renders this alias list into the subagent's `## Tools` section with
144
+ # a single-fire + fallback instruction (src/cli/prompt.ts buildToolsSection),
145
+ # and the model matches the diff's language itself. (The pre-4.32.23 comment
146
+ # here promised a `runtime/priority.yaml` arbiter that never existed.)
147
+ # 4.32.23 — names corrected to the UPSTREAM AGENT FACE (ECC 2.1.0 实拉):
148
+ # `ecc:<lang>-review` is a thin COMMAND shell whose body just invokes the
149
+ # `<lang>-reviewer` agent, and the command face has coverage holes
150
+ # (no typescript/java/swift/php/csharp/fsharp) while the agent face covers
151
+ # 11 languages uniformly. Build-resolvers have NO command face at all, so the
152
+ # agent face is also the only way to keep review/build consistent.
153
+ # BONUS TIER: no-op when ECC absent — base `/code-review` is the chain tail.
142
154
  aliases:
143
- - { impl: ecc, cmd: "ecc:python-review" }
144
- - { impl: ecc, cmd: "ecc:rust-review" }
145
- - { impl: ecc, cmd: "ecc:go-review" }
155
+ - { impl: ecc, cmd: "ecc:python-reviewer" }
156
+ - { impl: ecc, cmd: "ecc:rust-reviewer" }
157
+ - { impl: ecc, cmd: "ecc:go-reviewer" }
158
+ - { impl: ecc, cmd: "ecc:typescript-reviewer" }
146
159
  fires_when:
147
160
  - phase.stage == 'verify'
148
161
 
@@ -241,7 +254,12 @@ capabilities:
241
254
  cmd: chrome-devtools
242
255
  since: v2.0
243
256
  category: tool-mcp
244
- description: 性能/a11y/内存泄漏诊断 (非功能性 only; NOT for E2E test)
257
+ # 4.32.22 终局 — provider 二选一: ecc (manifests/optional/ecc.yaml, bonus
258
+ # tier; ECC connector audit 后其唯一默认 MCP connector 即 chrome-devtools)
259
+ # 或 optional 自装 manifest (manifests/optional/chrome-devtools-mcp.yaml,
260
+ # mcp-stdio-add 兜底, 供不装 ecc 的用户)。双装会产生同名双前缀调用歧义
261
+ # (doctor `ecc` check 挡残留双装)。
262
+ description: "性能/a11y/内存泄漏诊断 (非功能性 only; NOT for E2E test); provider 二选一 — ecc (bonus tier, ECC 唯一默认 MCP connector) 或 optional 自装 manifest chrome-devtools-mcp (不装 ecc 的兜底); 双装 doctor warn; 两者都缺时本 capability 不可用"
245
263
  fires_when:
246
264
  - subtask.type in ['perf_diagnose', 'a11y_audit', 'memory_leak']
247
265
 
@@ -277,11 +295,11 @@ capabilities:
277
295
  cmd: web_fetch_exa
278
296
  since: v2.0
279
297
  category: tool-mcp
280
- # 4.32.21 — manifests/tools/exa-mcp.yaml 已删;provider = ECC MCP catalog
281
- # opt-in (mcp-configs/mcp-servers.json 手动拷入 .mcp.json, hosted
282
- # https://mcp.exa.ai/mcp, 同名工具 web_search_exa / web_fetch_exa;
283
- # ≤2.0.0-rc.1 旧版曾默认 bundle, 2026-06 MCP connector audit 后退役为 opt-in)。
284
- description: "描述式/学术 Web 搜索 (覆盖默认 Tavily 的场景 — 描述式查询 / 学术 / 批量抓多 URL); provider = ECC MCP catalog opt-in (mcp-configs/mcp-servers.json); 未 opt-in 时本 capability 不可用, fallback 走 tavily-mcp / 内置 WebSearch (web-search-routing 已有 fallback 分支)"
298
+ # 4.32.22 — 恢复 base 组件语义 (manifests/tools/exa-mcp.yaml 已恢复, 翻案
299
+ # 4.32.21 删除; ECC 侧 exa 2026-06 connector audit 后退役为 opt-in, 不构成
300
+ # 承接)。运行需 EXA_API_KEY (server 进程 env 读取; settings.json env 块 /
301
+ # OS env 配置)。
302
+ description: "描述式/学术 Web 搜索 (覆盖默认 Tavily 的场景 — 描述式查询 / 学术 / 批量抓多 URL); 需 EXA_API_KEY, 未配置时不可用, fallback 走 tavily-mcp / 内置 WebSearch (web-search-routing 已有 fallback 分支)"
285
303
  fires_when:
286
304
  - subtask.needs_web_search == true AND subtask.search_type in ['descriptive', 'academic']
287
305
 
@@ -327,16 +345,21 @@ capabilities:
327
345
  category: tool-slash-cmd
328
346
  description: GSD systematic debugging (overlap with mattpocock /diagnosing-bugs + superpowers systematic-debugging — alias)
329
347
  # ADR-0034 Finding 1 — ECC per-language build-resolvers收编 as debug/verify-dimension
330
- # aliases (build-failure fix; runtime picks language-matching one). Opt-in: no-op
331
- # when ECC absent.
348
+ # aliases (build-failure fix). Selection is prose-level per 4.32.23 (see the
349
+ # code-review entry above). Opt-in: no-op when ECC absent.
350
+ # 4.32.23 — the three ecc names below were WRONG: `ecc:rust-build` /
351
+ # `ecc:go-build` / `ecc:build-fix` do not exist upstream (ECC 2.1.0 实拉).
352
+ # Real agent names are `<lang>-build-resolver`, plus the generic
353
+ # `build-error-resolver` (build/TypeScript). Upstream has NO
354
+ # python-build-resolver (django/pytorch resolvers split that role).
332
355
  aliases:
333
356
  # v4.16.3 — 上游改名 diagnose → diagnosing-bugs
334
357
  - { impl: mattpocock-skills, cmd: /diagnosing-bugs }
335
358
  # v13.0 P43 — superpowers-native debug alias (双 impl 备选, sister tdd superpowers主/mattpocock备)
336
359
  - { impl: superpowers, cmd: "superpowers:systematic-debugging" }
337
- - { impl: ecc, cmd: "ecc:rust-build" }
338
- - { impl: ecc, cmd: "ecc:go-build" }
339
- - { impl: ecc, cmd: "ecc:build-fix" }
360
+ - { impl: ecc, cmd: "ecc:rust-build-resolver" }
361
+ - { impl: ecc, cmd: "ecc:go-build-resolver" }
362
+ - { impl: ecc, cmd: "ecc:build-error-resolver" }
340
363
  fires_when:
341
364
  - subtask.type == 'debug'
342
365
 
@@ -499,21 +522,23 @@ capabilities:
499
522
  fires_when:
500
523
  - phase.stage == 'plan' AND phase.requires_persisted_plan == true
501
524
 
502
- # D-10: ralph-loop 真接 SDK wrapper (NOT mock reference; sister Phase 2.2 v0.2.0 ship)
503
- # v3.4.2: ralph-loop is a claude-plugins-official plugin; cmd is the bare `/ralph-loop`
504
- # (verified: ralph-loop@claude-plugins-official in installed_plugins.json).
505
- # v4.15.0 (ADR 0036 amends D-10 interactive surface): 三级偏好链 — plugin 优先
506
- # (fail-closed verbatim match + 硬 max-iterations) → 未装时 native `/goal` gate
507
- # (CC 2.1.139+ / Codex 双平台内置) → self-loop 兜底。链条语义由各 workflow SKILL.md
508
- # 指令文本承载(不加 schema 字段);SDK 路径 ralphLoopWrap 不参与该链。
509
- ralph-loop:
510
- impl: plugin
511
- install_type: plugin
512
- plugin_id: ralph-loop
513
- cmd: /ralph-loop
514
- since: v2.0
515
- category: tool-bundled-skill
516
- description: Sub-task completion gate (plugin preferred; native /goal fallback on CC 2.1.139+ & Codex; self-loop last resort)
525
+ # 完成保证 (原 D-10 `ralph-loop`) — 4.35.0 起完全内置,4.36.0 摘除上游 plugin 依赖。
526
+ # 交互面 = harnessed 自己的 CLI,不再是 slash command:
527
+ # `harnessed checkpoint complete <sub> --result-file <path>` — 对 declared evidence
528
+ # artifacts / TDD boundary (src/checkpoint/tddBoundary.ts) / verbatim completion
529
+ # promise (src/checkpoint/completionClaim.ts) 三者 fail-closed。
530
+ # `harnessed checkpoint fail <sub> --failing-tests <n>` — 记一次 attempt 并在到达停机
531
+ # 条件时打印 BUDGET-EXHAUSTED (budget.ts) / NO-PROGRESS (progress.ts) / BREAK-LOOP
532
+ # (breakLoop.ts)。这三条停机理由 == 上游 `/ralph-loop --max-iterations
533
+ # --completion-promise` 曾提供的全部语义,且没有"装没装 plugin"这个可用性问题。
534
+ # SDK 路径 (src/workflow/lib/ralphLoop.ts ralphLoopWrap 硬上界) 是 harnessed 自有代码,
535
+ # 与上游 plugin 无关,保留不动;completionClaim.ts 复用其 isComplete。
536
+ completion-gate:
537
+ impl: harnessed-bundled
538
+ cmd: harnessed checkpoint complete
539
+ since: v4.36
540
+ category: tool-cli
541
+ description: 子任务完成保证 (fail-closed evidence + TDD boundary + verbatim COMPLETE; `checkpoint fail` 出 BUDGET-EXHAUSTED / NO-PROGRESS / BREAK-LOOP)
517
542
  sdk_ref: src/workflow/lib/ralphLoop.ts
518
543
  fires_when:
519
544
  - subtask.completion_required == true
@@ -532,7 +557,7 @@ capabilities:
532
557
 
533
558
  # v13.0 P42 (upstream re-sync) — superpowers task 级 per-claim 证据门 (evidence before
534
559
  # claims): 子任务声明 done/fixed/passing 前强制跑验证命令并贴 output。Pairs with
535
- # ralph-loop COMPLETE + karpathy 完成=验收通过 (sister CLAUDE.md 子任务交付铁律)。
560
+ # completion-gate COMPLETE + karpathy 完成=验收通过 (sister CLAUDE.md 子任务交付铁律)。
536
561
  verification-before-completion:
537
562
  impl: superpowers
538
563
  cmd: "superpowers:verification-before-completion"
@@ -544,12 +569,28 @@ capabilities:
544
569
 
545
570
  # ============================================================================
546
571
  # Bucket 5 — Agent Teams 3 升级触发 (per D-11 + Q-AUDIT-5b schema fix +
547
- # bundled Agent Teams prerequisite: CC 2.1.133+ + env var)
572
+ # bundled Agent Teams prerequisite: CC 2.1.178+ + env var)
548
573
  # ============================================================================
549
574
  #
550
575
  # Q-AUDIT-5b 2026-05-20 fix: settings_env_var root-level `env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS`
551
576
  # (NOT nested experimental.* — Wave A 本地 settings.json 实证修正 prior schema 错误)。
552
- # Per Q-AUDIT-2 D-11: harnessed doctor + setup 检查 env var present + cc_version ≥2.1.133。
577
+ # Per Q-AUDIT-2 D-11: harnessed doctor + setup 检查 env var present + cc_version ≥2.1.178。
578
+ #
579
+ # 2026-07-30 UPSTREAM API MIGRATION (code.claude.com/docs/en/agent-teams, CC v2.1.178):
580
+ # `TeamCreate` / `TeamDelete` 两个工具**已被上游删除**("Both tools no longer exist")。
581
+ # 新机制:
582
+ # - 建团:无建团步骤、无建团工具。设好 env var 后**第一个 spawn 出来的 teammate 即隐式成团**,
583
+ # 主 session = lead。`Agent` 工具的 `team_name` 入参"accepted but ignored"(团名由 session
584
+ # 派生 `session-<sessionId 前 8 位>`)。
585
+ # - 关闭:lead **按名**请求 teammate shut down;teammate 可 approve 优雅退出 / reject 带理由。
586
+ # - 清理:"cleaned up automatically when the session ends, so there's no separate cleanup step"。
587
+ # - 一 session 一团;无嵌套团队(teammate 不能再 spawn teammate)。
588
+ # 因此本 bucket 的 `cmd` 不再是"工具名":create = 一种 spawn 调用形态,shutdown = 一句按名请求。
589
+ #
590
+ # `requires.cc_version` 是 free-form String(src/workflow/schema/capabilities.ts L25),
591
+ # 目前**没有任何 consumer 解析它** —— 它是给人/模型读的声明。旧路径(2.1.133 ≤ v < 2.1.178,
592
+ # 走已删除的 TeamCreate/TeamDelete)harnessed 不再支持,故这里只声明新下界 `>=2.1.178`,
593
+ # 不写区间(区间会暗示存在双路径 dispatch,而引擎里并不存在)。
553
594
  #
554
595
  # 5 fires_when OR-chain (multi-select; Agent Teams upgrade triggers):
555
596
  # 1. teammate_send_message_needed — teammate 间需 SendMessage 互通 (NOT fire-and-forget)
@@ -559,13 +600,16 @@ capabilities:
559
600
  # 5. fullstack_three_way — 全栈三路协同 (前端 + 后端 + 测试同步 + API contract)
560
601
  agent-teams-create:
561
602
  impl: claude-platform
562
- cmd: TeamCreate
603
+ cmd: 'Agent(name, run_in_background=true)'
563
604
  since: v2.0
564
605
  category: agent-platform
565
- description: Agent Teams team 创建 (CC 2.1.133+ experimental)
606
+ description: >-
607
+ Agent Teams 成团 = 直接 spawn 后台 teammate,团在 first teammate spawn 时隐式形成
608
+ (implicit — CC 2.1.178+ 删除了 TeamCreate,无建团步骤);主 session = lead。
609
+ `team_name` 入参被接受但忽略(团名由 session 派生)。一 session 一团、无嵌套团队。
566
610
  requires:
567
611
  settings_env_var: env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS == "1"
568
- cc_version: ">=2.1.133"
612
+ cc_version: ">=2.1.178"
569
613
  fires_when:
570
614
  - teammate_send_message_needed == true
571
615
  - subagent_context_overflow == true
@@ -578,20 +622,26 @@ capabilities:
578
622
  cmd: SendMessage
579
623
  since: v2.0
580
624
  category: agent-platform
581
- description: Agent Teams teammate 间通信 (round-trip 已验证 2026-05-19)
625
+ description: >-
626
+ Agent Teams teammate 间通信 (round-trip 已验证 2026-05-19)。工具本身早于 2.1.178 即存在,
627
+ 但 harnessed 只支持 2.1.178+ 的隐式成团路径,故与 bucket 同下界;无广播,每个 recipient 单发。
582
628
  requires:
583
629
  settings_env_var: env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS == "1"
584
- cc_version: ">=2.1.133"
630
+ cc_version: ">=2.1.178"
585
631
 
586
632
  agent-teams-shutdown:
587
633
  impl: claude-platform
588
- cmd: TeamDelete
634
+ cmd: 'ask the <teammate-name> teammate to shut down'
589
635
  since: v2.0
590
636
  category: agent-platform
591
- description: Agent Teams cleanup (shutdown_request 之后 TeamDelete; mandatory cleanup discipline)
637
+ description: >-
638
+ Agent Teams 关闭 = lead 按名请求 teammate shut down(不是工具调用 —— CC 2.1.178+ 删除了
639
+ TeamDelete,无等价工具);teammate 可 approve 优雅退出 / reject 带理由,且会先做完当前
640
+ tool call。团的共享目录在 session 退出时自动清理,无独立 cleanup 步骤 —— 剩下的纪律是
641
+ 「别把 teammate 落在运行态」(未关闭的 teammate 持续烧 token、可能挂起宿主)。
592
642
  requires:
593
643
  settings_env_var: env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS == "1"
594
- cc_version: ">=2.1.133"
644
+ cc_version: ">=2.1.178"
595
645
 
596
646
  # ============================================================================
597
647
  # Bucket 6 — L0 Discipline Substrate behavioral ref (D-09 NEW v3, 6 entry)
@@ -607,7 +657,17 @@ capabilities:
607
657
  cmd: '<not-applicable-behavioral>'
608
658
  since: v2.0
609
659
  category: behavioral
610
- description: 4 心法 + ≤200L hard limit + no-feature-creep + trust-internal-code + no-comments-default
660
+ # T2.7 (4.34.x) — description reconciles 1:1 with the rule ids in the
661
+ # discipline_ref file, and tests/workflow/karpathy-discipline.test.ts locks
662
+ # that reconciliation. The pre-T2.7 text advertised `trust-internal-code` +
663
+ # `no-comments-default` with no rule behind them; keep the `<N> rules: <id> /
664
+ # <id> / ...` suffix shape when editing or the guard fails.
665
+ description: >-
666
+ Bundled karpathy coding discipline, applied by every workflow via
667
+ disciplines_applied (no upstream plugin required) — 7 rules:
668
+ think-before-coding / simplicity-first / surgical-changes /
669
+ goal-driven-execution / file-length-200-hard-limit / trust-internal-code /
670
+ no-comments-default
611
671
  discipline_ref: workflows/disciplines/karpathy.yaml
612
672
 
613
673
  output-style-discipline:
@@ -1207,7 +1267,7 @@ capabilities:
1207
1267
  # at ~/.claude/skills/<skill_dir>/ (2026-06-09).
1208
1268
  #
1209
1269
  # KEYSTONE: gsd-execute-phase is deliberately NOT wired — the execute mechanism stays
1210
- # harnessed self-owned (CC-native spawn + ralph-loop + v4.2 checkpoint ledger).
1270
+ # harnessed self-owned (CC-native spawn + completion-gate + v4.2 checkpoint ledger).
1211
1271
  #
1212
1272
  # 4 design-contract phase skills (spec/ui/secure/ai-integration) pair with sister
1213
1273
  # judgments triggers in workflows/judgments/stage-phase-gate.yaml.
@@ -1,13 +1,19 @@
1
1
  # harnessed v3.0 workflow defaults
2
2
  # Phase v2.0-2.3 W1.2 ship — ralph_max_iterations table per R20.10 + D-10 fallback abort path
3
+ # (legacy key name retained on purpose — see the note above the table below)
3
4
  # Phase v3.0-3.4 W2.2 extend — 18 v3 sub-workflow + retro standalone × phase entries
4
5
  # Sister Phase 2.2 STRIDE T-2.2-05 DoS mitigation: hard_upper_limit = 100 caps any user override
5
6
  # Phase 2.4 workflow.yaml v2 interpolation: {{ defaults.ralph_max_iterations.<workflow>.<phase> }}
6
7
 
7
8
  schema_version: harnessed.defaults.v1
8
9
 
9
- # Per-workflow per-phase ralph-loop iteration ceiling
10
- # Values balance: completion guarantee vs DoS prevention; sister ADR 0011 v0.2.0 ralph-loop SDK pattern
10
+ # Per-workflow per-phase attempt ceiling (completion guarantee vs DoS prevention;
11
+ # sister ADR 0011 SDK pattern)
12
+ # 4.36.0 — the upstream ralph-loop plugin dependency is gone, but this key keeps its
13
+ # LEGACY NAME deliberately: it is read by exact string in src/checkpoint/budget.ts
14
+ # (resolveAttemptBudget) and interpolated by name from workflow yaml
15
+ # (`{{ defaults.ralph_max_iterations.<workflow>.<phase> }}`). A rename buys nothing
16
+ # user-visible and risks a silent lookup miss. Do NOT rename.
11
17
  ralph_max_iterations:
12
18
  # v3 standalone (research v3 schema bump + retro NEW per Phase 3.4 W1.1+W1.2)
13
19
  research:
@@ -45,3 +45,32 @@ rules:
45
45
  check_method: external-cmd
46
46
  auto_fix_cmd: 'wc -l <file> | awk ''{if ($1>200) exit 1}'''
47
47
  # 实装 split helper pattern (sister fallbackHandlers.ts / sdkReconcile.ts ≤80L)
48
+
49
+ # ── T2.7 (4.34.x) — the 2 rules the `karpathy-guidelines` capability description
50
+ # had been claiming since v2.0 without a rule behind them. Added as the
51
+ # precondition for dropping the upstream `karpathy-skills` plugin: the plugin
52
+ # was already redundant (0 call sites), but摘除 without these two would have
53
+ # silently dropped the ideas. Both are judgment calls with no deterministic
54
+ # check → `warn`, never `halt`.
55
+
56
+ - id: trust-internal-code
57
+ description: Trust internal code — validate at the trust boundary (external input, parsed config, user data), not at every internal layer; do not add defensive re-checks or redundant assertions on call sites you control
58
+ enforcement: warn
59
+ trigger: subtask.type == 'code-write'
60
+ check_method: heuristic
61
+ # sister role-prompts.yaml task-code checklist "Trust internal code: don't
62
+ # re-validate already-checked inputs at every layer"
63
+
64
+ - id: no-comments-default
65
+ description: Comments explain WHY, not WHAT — delete comments that restate the code or that have drifted out of sync with it; a comment must add context the code cannot carry (rationale, constraint, upstream reference)
66
+ enforcement: warn
67
+ trigger: subtask.type == 'code-write'
68
+ check_method: llm-judge
69
+ # check_method='llm-judge' — sister simplicity-first: verify phase 的
70
+ # code-simplifier review 承接 (role-prompts.yaml verify-simplify checklist
71
+ # "Comments that lie or duplicate the code → delete").
72
+ #
73
+ # 上游 karpathy 原条是「默认不写注释」,这里 REWRITE 不照搬 (T2.7 OQ3 裁决):
74
+ # 照搬会与本仓的高注释密度基线冲突,更会伤到 bundled 资产 —— 普通用户没有作者
75
+ # 本机那份 ~/.claude/CLAUDE.md,yaml / SKILL 里的注释是他们理解这些资产的唯一
76
+ # 途径。所以规则约束的是注释的「质量」(why 而非 what),不是注释的「有无」。
@@ -45,3 +45,30 @@ rules:
45
45
  check_method: external-cmd
46
46
  auto_fix_cmd: 'wc -l <file> | awk ''{if ($1>200) exit 1}'''
47
47
  # 实装 split helper pattern (sister fallbackHandlers.ts / sdkReconcile.ts ≤80L)
48
+
49
+ # ── T2.7 (4.34.x) — capability description 自 v2.0 起就在声称、但一直没有规则
50
+ # 落地的两条。补齐是摘除上游 `karpathy-skills` plugin 的前置:plugin 本身早已
51
+ # 冗余(仓内 0 处调用),但不补这两条就摘,等于静默丢掉这两个思想。
52
+ # 两条都是判断题、无确定性检查 → `warn`,不给 `halt`。
53
+
54
+ - id: trust-internal-code
55
+ description: 信任内部代码 —— 只在信任边界(外部输入 / 解析后的配置 / 用户数据)做校验,不在每一层内部调用上重复防御;不给自己控制的调用点加冗余断言
56
+ enforcement: warn
57
+ trigger: subtask.type == 'code-write'
58
+ check_method: heuristic
59
+ # sister role-prompts.zh-Hans.yaml task-code checklist「信任内部代码:不在每层
60
+ # 重复校验已经检查过的输入」
61
+
62
+ - id: no-comments-default
63
+ description: 注释解释 WHY 不解释 WHAT —— 删掉复述代码的注释、以及已经与代码脱节的注释;一条注释必须补上代码本身承载不了的信息(设计理由 / 约束 / 上游出处)
64
+ enforcement: warn
65
+ trigger: subtask.type == 'code-write'
66
+ check_method: llm-judge
67
+ # check_method='llm-judge' — sister simplicity-first:由 verify 阶段的
68
+ # code-simplifier review 承接(role-prompts.zh-Hans.yaml verify-simplify
69
+ # checklist「撒谎或重复代码的注释 → 删」)。
70
+ #
71
+ # 上游 karpathy 原条是「默认不写注释」,这里 REWRITE 不照搬(T2.7 OQ3 裁决):
72
+ # 照搬会与本仓的高注释密度基线冲突,更会伤到 bundled 资产 —— 普通用户没有作者
73
+ # 本机那份 ~/.claude/CLAUDE.md,yaml / SKILL 里的注释是他们理解这些资产的唯一
74
+ # 途径。所以规则约束的是注释的「质量」(why 而非 what),不是注释的「有无」。
@@ -22,20 +22,25 @@ rules:
22
22
  trigger: every Claude response
23
23
  check_method: read env.HARNESSED_USER_LANG, validate output lang matches
24
24
 
25
+ # The 8 categories are DATA, not a comment: src/cli/prompt.ts buildLanguageSection
26
+ # parses the numbered lines below and renders them into the spawn prompt's
27
+ # `## Language` section. Keep one category per numbered line (`N. <sentence>`),
28
+ # language-agnostic (they apply to any env.HARNESSED_USER_LANG).
25
29
  - id: preserve-english-categories
26
- description: 8 类强制保留英文原文,不翻译不音译 (语言无关 — 任何 user_lang 都适用)
30
+ description: |-
31
+ 8 categories always stay in their original English form — never translate,
32
+ transliterate, or rewrite them:
33
+ 1. Code, commands, shell snippets, config file contents, regex, SQL
34
+ 2. File / directory / path names (e.g. `src/components/Button.tsx`, `.planning/STATE.md`)
35
+ 3. Tool / framework / library / product / company names (e.g. Claude Code, GSD, subagent, React, Anthropic)
36
+ 4. API / function / class / variable / field names, env vars, config keys (e.g. `buildAgentDef`, `HARNESSED_USER_LANG`)
37
+ 5. Error messages, stack traces, log output
38
+ 6. URLs, commit hashes, issue / PR numbers, version numbers, git refs
39
+ 7. Industry abbreviations and standard terms (TDD, CRUD, API, MCP, PR, CI/CD, a11y, ORM, RAG, token, context window, prompt, subagent)
40
+ 8. Quoted material — documents, errors, config examples, the user's own words — reproduced verbatim, with any explanation kept outside the quote
27
41
  enforcement: warn
28
42
  trigger: always-on
29
43
  check_method: heuristic
30
- # 8 类 (verbatim CLAUDE.md, language-agnostic):
31
- # 1. 代码/命令/shell/配置/正则/SQL / code / cmd / shell / config / regex / SQL
32
- # 2. 文件/目录/路径名 (src/components/Button.tsx 等)
33
- # 3. 工具/框架/库/产品/公司名 (Claude Code / GSD / React 等)
34
- # 4. API/函数/类/变量/字段/环境变量/配置键
35
- # 5. 错误信息/stack trace/log 输出
36
- # 6. URL / commit hash / issue / PR 编号 / 版本号 / git ref
37
- # 7. 业内固定缩写与通用术语 (TDD / CRUD / API / MCP / token 等)
38
- # 8. 引用原文 verbatim
39
44
 
40
45
  - id: cross-cultural-humor
41
46
  description: |-
@@ -36,7 +36,7 @@ rules:
36
36
  enforcement: halt
37
37
  trigger: cmd.type == 'git-push'
38
38
  check_method: external-cmd
39
- # ralph-loop / subagent 自动调 git push → halt;user explicit `git push` 在主 session 允许
39
+ # completion-gate loop / subagent 自动调 git push → halt;user explicit `git push` 在主 session 允许
40
40
 
41
41
  - id: no-skip-hooks
42
42
  description: |
@@ -36,7 +36,7 @@ rules:
36
36
  enforcement: halt
37
37
  trigger: cmd.type == 'git-push'
38
38
  check_method: external-cmd
39
- # ralph-loop / subagent 自动调 git push → halt;user explicit `git push` 在主 session 允许
39
+ # completion-gate loop / subagent 自动调 git push → halt;user explicit `git push` 在主 session 允许
40
40
 
41
41
  - id: no-skip-hooks
42
42
  description: |
@@ -9,10 +9,14 @@ enforcement_layer: output
9
9
  auto_enforce: true
10
10
 
11
11
  rules:
12
+ # Scope note (2026-07-30) — chat-scope rules carry `trigger: response.target == 'chat'`
13
+ # so src/cli/prompt.ts renders them under an explicit "chat replies ONLY" sub-block.
14
+ # `harnessed prompt` is the only channel through which a subagent receives these rules,
15
+ # so a wrong scope means the rule gets misapplied to the files the subagent authors.
12
16
  - id: bluf-conclusion-first
13
17
  description: Conclusion first (BLUF); each paragraph leads with one sentence giving the answer/judgment/recommendation, then expands the reasoning
14
18
  enforcement: warn
15
- trigger: always-on
19
+ trigger: response.target == 'chat'
16
20
  check_method: heuristic
17
21
  # heuristic — 第一句长度 ≤ 100 char + 含答案动词 ('是' / '不是' / '推荐' / '应该' / 'use X')
18
22
  # 失败 → warn 'BLUF missing: first sentence is not a conclusion'
@@ -20,7 +24,9 @@ rules:
20
24
  - id: no-sycophantic-open-close
21
25
  description: Remove opening/closing filler phrases like "good question / awesome / perfect / hope this helps / anything else"
22
26
  enforcement: auto-fix
23
- trigger: always-on
27
+ # chat-scope is load-bearing here: enforcement=auto-fix means strip-sycophantic
28
+ # rewrites text, and an unconditional trigger would let it rewrite delivered artifacts.
29
+ trigger: response.target == 'chat'
24
30
  check_method: regex
25
31
  auto_fix_cmd: 'strip-sycophantic'
26
32
  # NEW src/discipline/enforcement/strip-sycophantic.ts — regex strip 13 known phrase
@@ -40,6 +46,8 @@ rules:
40
46
  auto_fix_cmd: 'replace-em-dash'
41
47
  # auto-replace '——' → ', ' (单段内逗号);'—' → ':' OR ','
42
48
 
49
+ # Deliberately always-on (not chat-scope): project files want precise quantifiers too,
50
+ # and the rule only tightens a requirement — it never produces a wrong artifact.
43
51
  - id: precise-quantifier
44
52
  description: Precise quantifiers; when a concrete number/filename/line number/commit hash is available, do not say "some/a few/several"
45
53
  enforcement: info
@@ -9,10 +9,14 @@ enforcement_layer: output
9
9
  auto_enforce: true
10
10
 
11
11
  rules:
12
+ # scope 说明 (2026-07-30) — 对话层规则带 `trigger: response.target == 'chat'`,
13
+ # src/cli/prompt.ts 会把它们渲染到独立的 "chat replies ONLY" 子块下。
14
+ # `harnessed prompt` 是 subagent 拿到这批规则的唯一通道,scope 写错就等于让规则
15
+ # 被误用到 subagent 自己写的产物文件上。
12
16
  - id: bluf-conclusion-first
13
17
  description: 结论先行 (BLUF),每段先一句给答案/判断/推荐,再展开理由
14
18
  enforcement: warn
15
- trigger: always-on
19
+ trigger: response.target == 'chat'
16
20
  check_method: heuristic
17
21
  # heuristic — 第一句长度 ≤ 100 char + 含答案动词 ('是' / '不是' / '推荐' / '应该' / 'use X')
18
22
  # 失败 → warn 'BLUF missing: first sentence is not a conclusion'
@@ -20,7 +24,9 @@ rules:
20
24
  - id: no-sycophantic-open-close
21
25
  description: 删除"好问题/太棒了/完美/希望对你有帮助/还需要别的吗"等开场闭合套话
22
26
  enforcement: auto-fix
23
- trigger: always-on
27
+ # 这条的 chat-scope 是承重的:enforcement=auto-fix 意味着 strip-sycophantic 会真改文本,
28
+ # trigger 无条件生效就等于允许它改写已交付的产物文件文案。
29
+ trigger: response.target == 'chat'
24
30
  check_method: regex
25
31
  auto_fix_cmd: 'strip-sycophantic'
26
32
  # NEW src/discipline/enforcement/strip-sycophantic.ts — regex strip 13 known phrase
@@ -40,6 +46,8 @@ rules:
40
46
  auto_fix_cmd: 'replace-em-dash'
41
47
  # auto-replace '——' → ', ' (单段内逗号);'—' → ':' OR ','
42
48
 
49
+ # 故意保持 always-on (不改 chat-scope):产物文件也该用精确量词,
50
+ # 且这条只是把要求收紧,不会主动产生错误产物。
43
51
  - id: precise-quantifier
44
52
  description: 量词精确,能给具体数字/文件名/行号/commit hash 就不用"一些/几个/多个"
45
53
  enforcement: info
@@ -14,8 +14,21 @@ priority_hierarchy:
14
14
  - superpowers # 子任务执行质量
15
15
  - planning-with-files # 计划持久化
16
16
  - karpathy # 编码行为
17
- - mattpocock # 招式 by-demand
18
- - parallel # subagent / Agent Teams / ralph-loop 执行机制
17
+ # `mattpocock` = 「按需召唤的招式」层的落位 (/grill-with-docs、/diagnosing-bugs、
18
+ # /to-spec、/to-tickets、/tdd、/improve-codebase-architecture 等),排在 karpathy 与
19
+ # parallel 之间。
20
+ #
21
+ # 它 NOT 属于方法论优先级句原文的 6 tier
22
+ # (gstack > GSD > superpowers > planning-with-files > andrej-karpathy-skills >
23
+ # 子任务并行机制) —— 那句话不是穷举式 tier 定义,招式层需要一个显式 rank 才能
24
+ # 参与 before-spawn 仲裁。
25
+ #
26
+ # 请勿当作「偏差」删除:删掉后这批招式 capability 会 fall through 到
27
+ # MAX_SAFE_INTEGER rank,排到 parallel 之下变成全局最低优先。而
28
+ # workflows/discuss/subtask/workflow.yaml 与 workflows/task/code/workflow.yaml
29
+ # 真在消费同 tier 并发。
30
+ - mattpocock # 招式 by-demand (rationale 见上方注释)
31
+ - parallel # subagent / Agent Teams 执行机制 (完成保证是正交 wrapper, 见 judgments/parallelism-gate.yaml completion-gate-wrapper.wraps)
19
32
 
20
33
  rules:
21
34
  - id: multi-capability-arbitration