@wwkit/harness 1.0.16 → 1.0.18

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 (45) hide show
  1. package/README.md +6 -6
  2. package/agents/todo.md +119 -0
  3. package/agents/work-explore.md +50 -0
  4. package/agents/work-general.md +44 -0
  5. package/agents/work.md +55 -34
  6. package/commands/pytest.md +11 -0
  7. package/package.json +1 -1
  8. package/readme/development.md +1 -1
  9. package/skills/extract/SKILL.md +90 -28
  10. package/{agents/pyit.md → skills/pytest/SKILL.md} +223 -64
  11. package/skills/pytest-env-ensure/references/config.md +2 -2
  12. package/skills/pytest-sample/SKILL.md +3 -3
  13. package/skills/read-docs/references/superpowers/comparison.md +1 -1
  14. package/skills/read-docs/references/superpowers/index.md +1 -1
  15. package/skills/revise/SKILL.md +86 -25
  16. package/skills/todo-dispatch/SKILL.md +211 -0
  17. package/skills/todo-finalize/SKILL.md +238 -0
  18. package/skills/todo-plan/SKILL.md +174 -0
  19. package/skills/todo-recovery/SKILL.md +179 -0
  20. package/skills/todo-review/SKILL.md +259 -0
  21. package/skills/work-dispatch/SKILL.md +15 -2
  22. package/skills/work-dispatch/references/dispatch-prompt.md +10 -1
  23. package/skills/work-dispatch/references/explore-prompt.md +74 -0
  24. package/skills/work-dispatch/references/report-handling.md +31 -4
  25. package/skills/work-finalize/SKILL.md +2 -2
  26. package/skills/work-finalize/references/final-review.md +5 -3
  27. package/skills/work-finalize/references/handover.md +8 -0
  28. package/skills/work-ledger/SKILL.md +1 -1
  29. package/skills/work-ledger/references/bootstrap.md +12 -4
  30. package/skills/work-plan/SKILL.md +2 -2
  31. package/skills/work-plan/references/self-review.md +1 -1
  32. package/skills/work-plan/references/split-rules.md +1 -1
  33. package/skills/work-plan/references/task-fields.md +10 -10
  34. package/skills/work-recovery/SKILL.md +8 -8
  35. package/skills/work-recovery/references/budget.md +10 -11
  36. package/skills/work-recovery/references/rollback.md +4 -4
  37. package/skills/work-review/SKILL.md +2 -2
  38. package/skills/work-review/references/fix-loop.md +14 -9
  39. package/skills/work-review/references/reviewer-prompt.md +1 -1
  40. package/skills/work-review/references/verdict-handling.md +1 -1
  41. package/agents/extract.md +0 -26
  42. package/agents/pyut.md +0 -347
  43. package/agents/revise.md +0 -28
  44. package/commands/pyit.md +0 -6
  45. package/commands/pyut.md +0 -6
@@ -0,0 +1,174 @@
1
+ ---
2
+ name: todo-plan
3
+ description: 规划阶段:创建 doc_dir + Ledger、探索(派 explore)、拆分任务、写 plan.md、计划自审、todowrite 落单。解析 target 后、派发任何 subagent 前加载。
4
+ license: MIT
5
+ metadata:
6
+ workflow: sequential
7
+ ---
8
+
9
+ # todo-plan 技能
10
+
11
+ ## 输入
12
+
13
+ | 字段 | 说明 | 默认 |
14
+ |------|------|------|
15
+ | `target` | 要达成的目标 | 必填 |
16
+ | `root_dir` | 工程根目录 | 当前工作目录 |
17
+ | `constraints` | 约束(不改的文件、禁止的操作) | 无 |
18
+
19
+ ## 工作流程
20
+
21
+ ### 步骤 1:创建产物目录
22
+
23
+ ```bash
24
+ # 生成 run_id(纯时间戳;目录已在 .webwork/todo/ 下,无需再前缀)
25
+ run_id="$(date +%Y%m%d-%H%M%S)"
26
+ doc_dir="<root_dir>/.webwork/todo/${run_id}"
27
+ mkdir -p "${doc_dir}"
28
+
29
+ # 写 .gitignore(如果不存在)
30
+ echo -e '*\n!.gitignore' > <root_dir>/.webwork/todo/.gitignore
31
+ ```
32
+
33
+ ### 步骤 2:起始检查
34
+
35
+ ```bash
36
+ # 确认在 Git 仓库内
37
+ git rev-parse --is-inside-work-tree
38
+
39
+ # 记录运行元数据
40
+ branch=$(git branch --show-current)
41
+ initial_base=$(git rev-parse --short=7 HEAD)
42
+ ```
43
+
44
+ **起始工作树检查(人工介入点)**:
45
+ - 干净(`git status --porcelain` 空)→ 继续
46
+ - **不干净 → 停止,报告脏文件并让人工介入处理**(由用户决定 stash / 保留 / 放弃)。这是**唯一的起始人工介入点**——之后的代码都是 agent 自主修改,提交也由 agent 自己完成,不再为工作树状态问用户
47
+
48
+ ### 步骤 3:写 Ledger
49
+
50
+ 写入 `<doc_dir>/progress.md`:
51
+
52
+ ```
53
+ target: <用户目标摘要>
54
+ doc_dir: <doc_dir 绝对路径>
55
+ branch: <branch>
56
+ initial_base: <initial_base>
57
+ ```
58
+
59
+ ### 步骤 4:探索代码库(MUST 派 `explore`)
60
+
61
+ 拆分任务前,只要 `target` 需要理解现有代码、文件结构、既有模式才能产出准确的 `files`/`accept`/`verify`,**你必须派发 `explore` subagent 去调研,绝不自己读源码**。
62
+
63
+ - 有 1% 需要读源码的可能 → 就派 subagent(禁止「我凭记忆/凭感觉能拆」的借口)
64
+ - 多个独立方向的调研 → **同一消息并行派发 ≤5 个 `explore` subagent**,每个 `background=true`
65
+ - 每个 explore 沿用 `todo-dispatch` 的「只读调研 prompt 模板」约束(只读、不提交、附 file:line 证据)
66
+ - 各 explore 结论写入报告文件;据此拆分任务,报告文件路径记入 Ledger
67
+
68
+ ### 步骤 5:拆分任务
69
+
70
+ 把 `target` 拆成任务列表,每个任务:
71
+ - ≤10 分钟可完成
72
+ - 能独立写出可布尔判定的 `accept`
73
+ - 有明确的 `verify` 命令
74
+
75
+ **拆分规则(强制)**:
76
+ - 第一约束:每个任务 ≤10 分钟 + 可独立验收
77
+ - **粒度强制**:任何任务拆出后若预估 >10 分钟,或包含多个可独立验收的子目标,**必须继续拆细,绝不塞给一个 subagent**
78
+ - **并行分型强制**:拆分时对每个任务判定 `readonly`——只读 + 无依赖的任务**必须**标 `readonly=true`(可并行),不得一律标可写串行
79
+ - 反模式:按 TDD 步骤拆 / 按文件数硬拆 / 一个任务塞多个不相关目标 / 把多个任务合并进一个 subagent
80
+ - 不需要拆分的情况:target 本身就是单个 ≤10 分钟可验收的任务
81
+
82
+ **并行分组**:拆分后把无依赖的 `readonly=true` 任务归组,作为 dispatch 并行派发依据(≤5 一批,见 todo-dispatch 步骤 3)。
83
+
84
+ **任务字段**(每个任务):
85
+
86
+ | 字段 | 说明 |
87
+ |------|------|
88
+ | `task_id` | T1, T2, ... |
89
+ | `goal` | 一句话目标 |
90
+ | `files` | 涉及文件 |
91
+ | `accept` | 可布尔判定的验收标准 |
92
+ | `verify` | 验证命令 |
93
+ | `agent` | `explore` / `general`(由 `readonly` 决定) |
94
+ | `readonly` | true=只读调研,false=可写实现 |
95
+ | `writable` | 可写文件白名单(readonly=false 时) |
96
+ | `forbidden` | 禁止改动的文件/操作(至少包含 constraints) |
97
+ | `depends` | 依赖的任务编号 |
98
+ | `budget` | 工具调用上限(默认 readonly=30, 可写=50) |
99
+
100
+ ### 步骤 6:写 plan.md
101
+
102
+ 写入 `<doc_dir>/plan.md`:
103
+
104
+ ```markdown
105
+ # <target 摘要>
106
+
107
+ ## Global Constraints
108
+ <constraints>
109
+
110
+ ### T1: <goal>
111
+ - files: <files>
112
+ - accept: <accept>
113
+ - verify: <verify>
114
+ - agent: general
115
+ - readonly: true/false
116
+ - writable: <writable>
117
+ - forbidden: <forbidden>
118
+ - depends: -
119
+ - budget: <N>
120
+
121
+ ### T2: <goal>
122
+ ...
123
+ ```
124
+
125
+ ### 步骤 7:计划自审
126
+
127
+ 产出 plan.md 后、todowrite 落单前,逐项自审。**任何一项不通过 → 修正计划后再继续,不派发**。
128
+
129
+ **范围闸门**:任务数 >20,或 `target` 无法在 ≤20 个独立验收单元内覆盖 → **自主裁决**:本次只规划第一批 ≤20 个任务,剩余范围记入 Ledger 待重规划(`Ruling: 缩小范围 — 本次先做前 20 个任务 — 错了的代价=余下目标延迟`)。不等待用户。
130
+
131
+ **逐项自检(8 项)**:
132
+
133
+ 1. **Spec 覆盖**:`target` 每个要求都有对应任务?补上未被覆盖的 gap。
134
+ 2. **接口一致性**:跨任务的类型名 / 函数签名 / 属性名是否一致(如 T1 产出的 `clearLayers()` 在 T3 也同名)?
135
+ 3. **占位符扫描**:有无 "TBD"、"加错误处理"、"类似 T1"、"按需实现" 等模糊描述?有则写具体。
136
+ 4. **依赖完整性**:`depends` 引用的 `task_id` 是否存在?无循环依赖?有依赖的任务是否串行?
137
+ 5. **文件所有权分区**:只读任务(`readonly=true`)不产生变更;可写任务串行无写冲突;`files`/`writable` 不落在 `constraints` 禁改范围。
138
+ 6. **路径合规**:`writable`/`forbidden`/`files` 都落在 `root_dir` 内且不与 `constraints` 冲突。
139
+ 7. **验收可判定**:每条 `accept` 可布尔判定?`verify` 命令具体可执行?
140
+ 8. **工时约束**:每个任务预估 ≤10 分钟?超出的必须继续拆。
141
+
142
+ ### 步骤 8:todowrite 落单
143
+
144
+ 用 `todowrite` 创建任务清单。每个任务一个 todo 项:
145
+
146
+ ```json
147
+ [
148
+ {"content": "T1: <goal>", "status": "pending", "priority": "high"},
149
+ {"content": "T2: <goal>", "status": "pending", "priority": "high"}
150
+ ]
151
+ ```
152
+
153
+ ### 步骤 9:输出进度
154
+
155
+ ```
156
+ 计划完成:T1 <goal> / T2 <goal> / ...(共 N 个任务)
157
+ 工作区就绪:branch=<branch>, initial_base=<base7>(doc_dir=<doc_dir>)
158
+ ```
159
+
160
+ ## 并发规则
161
+
162
+ | 任务类型 | 并发 | 条件 |
163
+ |---------|------|------|
164
+ | 只读调研(readonly=true) | **必须并行 ≤5** | 无写冲突;多个独立调研不得串行 |
165
+ | 可写实现(readonly=false) | 必须串行 | 上一任务 review close 后才派下一个 |
166
+ | Review | 与下一个可写实现串行 | 并行会污染 HEAD,使 review diff 范围漂移 |
167
+
168
+ **串行纪律**:下一个可写任务的 base = 上一任务的 HEAD。
169
+
170
+ ## 约束
171
+
172
+ - 不读写代码、不跑验证、不派发实现 subagent,只产出:产物目录 + Ledger + plan.md + todowrite 清单
173
+ - **MUST**:需探索代码库才能拆分时派 `explore` 调研(步骤 4),绝不自己读源码
174
+ - 短 SHA 一律取 7 位
@@ -0,0 +1,179 @@
1
+ ---
2
+ name: todo-recovery
3
+ description: 恢复与护栏:崩溃/compaction 恢复、重规划(≤3 轮)、退出条件、预算与超时、中断与回滚、防失控护栏。运行期遇上下文丢失、计划级失败、超时、中断、需回滚时加载。
4
+ license: MIT
5
+ metadata:
6
+ workflow: on-demand
7
+ ---
8
+
9
+ # todo-recovery 技能
10
+
11
+ ## 触发场景
12
+
13
+ - compaction / 会话重启 / 上下文丢失 → 步骤 0 恢复
14
+ - 计划级失败(多任务失败 / 反复失败 / 依赖断裂)→ 步骤 1 重规划
15
+ - 判定退出(target 验收 / 重规划超限 / 阻塞 / 预算超限 / ESCALATE)→ 步骤 2 退出条件
16
+ - 单任务超时 / 总预算护栏触顶 → 步骤 3 预算与超时
17
+ - 用户中断 / 需回滚 / forbidden 文件被改 → 步骤 4 中断与回滚
18
+ - 防失控周期自检 → 步骤 5 护栏
19
+
20
+ ## 输入
21
+
22
+ | 字段 | 说明 | 默认 |
23
+ |------|------|------|
24
+ | `target` | 用户目标 | 必填 |
25
+ | `root_dir` | 工程根目录 | 当前工作目录 |
26
+ | `doc_dir` | 产物目录 | 必填 |
27
+ | `run_id` | run id(重规划复用) | 必填 |
28
+ | `initial_base` | 本次运行最初的 base(回滚绝不 reset 早于它) | 必填 |
29
+ | `constraints` | 全局禁改/禁操作清单 | 无 |
30
+
31
+ ## 工作流程
32
+
33
+ ### 0. 恢复(compaction / 崩溃 / 上下文丢失后)
34
+
35
+ compaction、会话重启、或任何上下文丢失后,按本 SOP **无损续跑**:不重做已完成任务、不丢未提交改动、不误判在途任务。
36
+
37
+ 1. **定位 doc_dir**:优先读 Ledger `doc_dir=` 绝对路径;读不到则退化 `<root_dir>/.webwork/todo/` 下时间戳最新目录。
38
+ 2. **读 Ledger + plan.md**:Ledger 首行元数据(`target`/`doc_dir`/`branch`/`initial_base`)+ 全部任务条目 + `plan.md` 任务清单。
39
+ 3. **工作树校验**(`git status --porcelain`):
40
+ - 干净 → 继续。
41
+ - 脏 → 判归属:脏文件落在「最近进行中任务」的 writable 白名单内 → 自动 `git add -A && git commit -m "resume: residual changes"`(不丢改动);超出白名单 → `git checkout -- <file>` 丢弃并记 Ruling。
42
+ - **绝不 `reset --hard`**(会连同未提交改动一起丢)。
43
+ 4. **推断当前任务状态**(Ledger 与 `git log`/`git status` 交叉验证,**信任 git 胜过记忆**):
44
+ - 已 `complete` 的任务不改不动。
45
+ - 找 Ledger 最后一个有 `base=` 但无 `complete` 的任务 = 当前进行中。
46
+ - `git log <base>..HEAD` 有 commit 且无 review 结论 → 已实现,生成 review package 进入 todo-review。
47
+ - 无 commit 且工作树干净 → 无产出,重新派发该任务。
48
+ - 全部任务 `complete` → 进入 todo-finalize。
49
+ 5. **todowrite 重建清单**:全量替换,已完成 `completed`、当前任务 `in_progress`。
50
+ 6. **继续主循环派发**,**绝不直接实现**——从推断出的状态点续跑,不从头重做。
51
+
52
+ ### 1. 重规划
53
+
54
+ #### 触发条件(3 种)
55
+
56
+ 1. 多任务失败(≥2 个任务 BLOCKED 且无法通过换模型/拆任务解决)
57
+ 2. 某任务反复失败(fix loop 5 轮 + Breaker STOP)
58
+ 3. 计划自审结构性冲突在实现后成真(任务间依赖断裂)
59
+
60
+ #### 规则
61
+
62
+ - **复用同一 `run_id`/`doc_dir`/Ledger**——不新开 run
63
+ - **增量调整**——只对未完成目标重新拆分,已完成任务保留标记 done 不重派发
64
+ - 更新 `plan.md`,`todowrite` 重建清单(全量替换,仅未完成 + 新拆分的任务)
65
+ - Ledger 记 `replan round <R>/3`
66
+ - **最多 3 轮**,超限升级用户不再自动继续
67
+
68
+ #### 重规划流程
69
+
70
+ ```
71
+ 1. 读 Ledger 确认已完成任务(T<N>: complete 的不重派发)
72
+ 2. 读 plan.md + 已有 explore 报告确认未完成任务及拆分依据
73
+ 3. 对未完成目标重新拆分(遵循 todo-plan 的拆分规则)
74
+ 4. 重新拆分若需探索代码库(已有报告不足)→ 派只读 explore subagent(遵循 todo-plan 步骤 4:只读、不提交、附 file:line 证据)
75
+ 5. 更新 plan.md(追加新任务,标记旧任务为 superseded)
76
+ 6. todowrite 重建清单(全量替换)
77
+ 7. Ledger 记 replan round <R>/3
78
+ 8. 继续主循环派发
79
+ ```
80
+
81
+ ### 2. 退出条件(5 种)
82
+
83
+ | 条件 | 动作 |
84
+ |------|------|
85
+ | target 验收通过 | 正常交付(todo-finalize) |
86
+ | 重规划 ≤3 轮仍失败 | 停止,报告用户:已尝试 N 轮重规划,以下任务仍无法完成 |
87
+ | 阻塞无法解除(含与 constraints 不可调和) | 停止,报告用户:阻塞原因 + 已尝试方案 |
88
+ | 总预算超限(见下) | 停止,报告用户:预算超限详情 |
89
+ | subagent ESCALATE 且无法通过拆分/换模型解决 | 停止,报告用户:升级原因 |
90
+
91
+ 退出时 Ledger 记最终状态,向用户输出:
92
+ ```
93
+ 任务未完成,已停止。
94
+
95
+ 已完成: T1, T2 (review clean)
96
+ 未完成: T3 (BLOCKED: <reason>), T4 (not started)
97
+
98
+ Rulings I made:
99
+ <裁决清单>
100
+
101
+ 建议下一步: <建议>
102
+ ```
103
+
104
+ ### 3. 预算与超时
105
+
106
+ #### 单任务超时
107
+
108
+ - prompt 软上限:只读调研 ≤30 次工具调用,可写实现 ≤50,fix ≤20,reviewer ≤15
109
+ - 超时立即记 Ledger `T<N>: timeout`,标 BLOCKED/ESCALATE
110
+ - 不无限同步等待
111
+
112
+ #### 等待纪律(有界等待)
113
+
114
+ - background 模式下主 agent 不阻塞
115
+ - 派发后继续做本地工作(写 Ledger、准备下一个 review package、读已返回的报告)
116
+ - 收到 subagent 完成通知后处理返回
117
+ - subagent 异常长时间未返回(超过该任务预算对应的 2 倍时长,或绝对上限 10 分钟,取先到者)→ 记 Ledger `T<N>: timeout` 并标 BLOCKED/ESCALATE
118
+
119
+ #### 总预算护栏(3 项)
120
+
121
+ | 护栏 | 上限 | 超限动作 |
122
+ |------|------|---------|
123
+ | 总任务数 | ≤20 | 记 Ledger,报告用户,停止派发 |
124
+ | 总运行时长 | ≤30 分钟 | 记 Ledger,报告用户,停止派发 |
125
+ | 最大并行 | ≤5(只读) | 记 Ledger,等待在途返回 |
126
+
127
+ 每项超限如实写进 Ledger 并报告,不静默续跑。
128
+
129
+ ### 4. 中断与回滚
130
+
131
+ #### 用户中断
132
+
133
+ - 立即停止派发 + cancel 在途 subagent
134
+ - 记 Ledger `T<N>: interrupted by user`
135
+ - 保留现场,不删除产物目录
136
+ - 向用户输出当前进度
137
+
138
+ #### 回滚规则
139
+
140
+ - **回滚仅限本任务 `base..HEAD`**(base 从 Ledger `T<N>: base=` 读取)
141
+ - 工作树脏时禁 `git reset --hard`,改用 `git revert` 或 `git reset --soft` + 手动 checkout
142
+ - forbidden 文件被改 → 强制 `git checkout -- <file>` 恢复
143
+ - **绝不 `reset` 到早于 `initial_base`**
144
+
145
+ ```
146
+ 回滚步骤:
147
+ 1. 读 Ledger T<N>: base=<base>
148
+ 2. git revert <base>..HEAD (或 git reset --soft <base> + git checkout -- .)
149
+ 3. forbidden 文件: git checkout -- <forbidden_file>
150
+ 4. 记 Ledger T<N>: reverted to <base>
151
+ 5. 重新规划该任务(拆分/换模型/调整方案)
152
+ ```
153
+
154
+ ### 5. 防失控护栏(5 条)
155
+
156
+ | # | 护栏 | 检查 |
157
+ |---|------|------|
158
+ | 1 | 并发分型 | 只读任务可并行 ≤5;可写任务必须串行;下一个可写 base = 上一 HEAD |
159
+ | 2 | task 预算 | 每个 task ≤10 分钟;失败先换模型/拆任务再重规划 |
160
+ | 3 | scoped re-review | 每轮 fix 后必须 scoped re-review,不跳过 |
161
+ | 4 | Round 5 后才裁决 | Breaker 绝不在 Round 5 前提前裁决;每条裁决都是 Ledger 条目,禁止静默丢弃 |
162
+ | 5 | 外部信息 | 需要外部信息用 `explore` 调研,不嵌套再派发 |
163
+
164
+ ## 输出
165
+
166
+ - Ledger 条目(`replan round <R>/3` / `T<N>: timeout` / `T<N>: interrupted` / `T<N>: reverted to <sha>` / 总预算超限记录)
167
+ - 更新后的 `plan.md`(重规划时)
168
+ - 不派发实现/任务 subagent(重规划后的派发由主流程按新 plan.md 进行);重新拆分若需探索代码库,按 todo-plan 步骤 4 派只读 explore subagent
169
+ - 不 push / 不 merge / 不 reset 早于 initial_base
170
+
171
+ ## 约束
172
+
173
+ - 重规划复用同一 run,是增量调整,不重做已完成任务
174
+ - 退出条件 5 种,命中即停止并如实报告
175
+ - 单任务超时不无限等待
176
+ - 总预算护栏 3 项超限即停
177
+ - 用户中断保留现场
178
+ - 回滚仅限本任务范围,绝不 reset 早于 initial_base
179
+ - 防失控护栏 5 条周期自检
@@ -0,0 +1,259 @@
1
+ ---
2
+ name: todo-review
3
+ description: 审查与修复阶段:生成 review package、派发 reviewer(Spec+Quality 两阶段)、处理结论、fix loop(≤5 轮)+ scoped re-review、Breaker 裁决。implementer 返回 DONE/DONE_WITH_CONCERNS 后加载。
4
+ license: MIT
5
+ metadata:
6
+ workflow: sequential
7
+ ---
8
+
9
+ # todo-review 技能
10
+
11
+ ## 输入
12
+
13
+ | 输入 | 说明 |
14
+ |------|------|
15
+ | `doc_dir` | 产物目录绝对路径 |
16
+ | `task_id` (`T<N>`) | 当前任务编号 |
17
+ | `base` | Ledger 中该任务的 `base=` 值 |
18
+ | `HEAD` | 当前 HEAD |
19
+ | `brief_file` | `<doc_dir>/task-<N>-brief.md` |
20
+ | `report_file` | `<doc_dir>/task-<N>-report.md` |
21
+
22
+ ## 工作流程
23
+
24
+ ### 步骤 1:生成 review package
25
+
26
+ ```bash
27
+ # 生成 diff 包(commits + stat + full diff with 10 lines context)
28
+ diff_file="<doc_dir>/task-<N>-review-<base7>..<head7>.diff"
29
+ git log --oneline <base>..<HEAD> > "$diff_file"
30
+ echo "" >> "$diff_file"
31
+ git diff --stat <base>..<HEAD> >> "$diff_file"
32
+ echo "" >> "$diff_file"
33
+ git diff -U10 <base>..<HEAD> >> "$diff_file"
34
+ ```
35
+
36
+ 写入 Ledger:`T<N>: reviewed_head=<HEAD7>`
37
+
38
+ ### 步骤 2:派发 reviewer(串行:一个任务一个 reviewer)
39
+
40
+ 一次任务级审查 = 一个 reviewer subagent,不并行拆分(多个 reviewer 重复读同一 diff,无并行收益)。用 `task` 工具派发,`subagent_type: "general"`,`background: true`。
41
+
42
+ #### Reviewer prompt 模板
43
+
44
+ ```
45
+ 你是审查 subagent,审查一个任务的实现。这是任务级审查,不是合并审查。
46
+
47
+ ## What Was Requested
48
+ Read the task brief: <brief_file>
49
+
50
+ Global constraints: <constraints>
51
+
52
+ ## What the Implementer Claims
53
+ Read the implementer's report: <report_file>
54
+
55
+ ## Diff Under Review
56
+ Base: <base>
57
+ Head: <HEAD>
58
+ Diff file: <diff_file>
59
+
60
+ Read the diff file once — it contains the commit list, stat summary, and full diff
61
+ with context. Do not re-run git commands. Do not crawl the broader codebase.
62
+
63
+ Your review is read-only. Do not mutate the working tree, index, HEAD, or branch.
64
+
65
+ ## You Do Not Dispatch Subagents
66
+ Do all review yourself. Never spawn a subagent.
67
+
68
+ ## Do Not Trust the Report
69
+ Treat the implementer's report as unverified claims. Verify against the diff.
70
+
71
+ ## Tests
72
+ The implementer already ran tests. Do not re-run the suite. Run a focused test only
73
+ when reading the code raises a specific doubt.
74
+
75
+ ## Part 1: Spec Compliance
76
+ - Missing: requirements skipped or claimed without implementing
77
+ - Extra: features not requested, over-engineering
78
+ - Misunderstood: right feature built the wrong way
79
+
80
+ ## Part 2: Code Quality
81
+ - Clean separation of concerns?
82
+ - Proper error handling?
83
+ - DRY without premature abstraction?
84
+ - Edge cases handled?
85
+ - Tests verify real behavior, not mocks?
86
+
87
+ ## Output Format
88
+ Write your review to <review_file> (<doc_dir>/task-<N>-review.md):
89
+
90
+ ### Spec Compliance
91
+ - ✅ Spec compliant | ❌ Issues found: [what's missing/extra/misunderstood, with file:line]
92
+
93
+ ### Strengths
94
+ [What's well done? Be specific.]
95
+
96
+ ### Issues
97
+ #### Critical (Must Fix)
98
+ #### Important (Should Fix)
99
+ #### Minor (Nice to Have)
100
+ For each issue: file:line, what's wrong, why it matters, how to fix.
101
+
102
+ ### Assessment
103
+ **Task quality:** Approved | Needs fixes
104
+ **Reasoning:** [1-2 sentence technical assessment]
105
+
106
+ Then report back with ONLY (≤15 lines):
107
+ - Spec: ✅/❌
108
+ - Quality: Approved/Needs fixes
109
+ - Finding count (Critical/Important/Minor)
110
+ - One-line summary
111
+ - Review file path
112
+ ```
113
+
114
+ ### 步骤 3:处理结论
115
+
116
+ 读取 `<doc_dir>/task-<N>-review.md`,按结论分派:
117
+
118
+ | 结论 | 动作 |
119
+ |------|------|
120
+ | ✅ Spec + Approved | 任务完成,写 Ledger `T<N>: complete (commits <base7>..<head7>, review clean)`,勾单 |
121
+ | ❌ 或有 Critical/Important | 进入 fix loop |
122
+ | ⚠️ Cannot verify | 主 agent 不得读源码核实——派只读 verify subagent 运行聚焦验证,据报告裁决(详见下) |
123
+ | Minor only | 记录 Ledger `T<N>: minor (deferred): <one-liner>`,任务完成,勾单 |
124
+ | Plan-mandated | 主 agent 裁决:weigh finding against plan text,record `Ruling: <决定> — <原因> — <代价>`,不打断流程 |
125
+
126
+ **⚠️ Cannot verify 的处理**:reviewer 无法只凭 diff 判断某点时,主 agent **绝不自己读源码 / 跑测试核实**。派发一个只读 verify subagent(`subagent_type: "general"`,`background=true`),prompt 约束:只运行 reviewer 指出的聚焦验证命令(focused test / 单条命令),只读相关文件 + 附 file:line 证据,不提交、不改工作树、不嵌套派发。据其报告裁决:
127
+ - 聚焦验证 PASS → 记录 `Ruling: <点> 验证通过 — 聚焦测试 PASS — cost if wrong low`,任务完成,勾单
128
+ - 聚焦验证 FAIL → 视为 spec ❌,进入 fix loop
129
+ - 仍无法判定(需环境/需 implementer 补证据)→ 视为 spec ❌,退回 implementer 补证据后重审
130
+
131
+ **勾单语义**:`todowrite` 全量替换整个清单——当前任务标 `completed`(下一个任务的 `in_progress` 由 todo-dispatch 派发时统一标记)。绝不只改一项。
132
+
133
+ ### 步骤 4:Fix Loop(如触发)
134
+
135
+ 最多 5 轮,每轮 = 一次 fix dispatch + 一次 scoped re-review。
136
+
137
+ #### 轮次策略
138
+
139
+ | 轮次 | Implementer | 理由 |
140
+ |------|-------------|------|
141
+ | 1-3 | 恢复原 implementer(context 完整) | 它知道任务、代码、自己的选择 |
142
+ | 4-5 | 新 implementer + 更详细 brief | fresh eyes,原 implementer 可能看不到自己的问题 |
143
+
144
+ #### 每轮流程
145
+
146
+ 1. **Fix dispatch(串行)**:派发 fix implementer(`general`, `background=true`)——一个 fix subagent 修本轮全部 findings(findings 常共享文件,并行修复会冲突)。prompt 包含:
147
+ - brief_file 路径
148
+ - report_file 路径(fix 报告 append 到同一文件)
149
+ - open findings(逐条列出)
150
+ - "Fix these findings, re-run covering tests, append fix report to <report_file>"
151
+
152
+ 2. **生成 scoped review package**:
153
+ ```bash
154
+ fix_base=<上一轮 reviewed_head>
155
+ scope_diff="<doc_dir>/task-<N>-rereview-<R>-<fix_base7>..<head7>.diff"
156
+ git log --oneline <fix_base>..<HEAD> > "$scope_diff"
157
+ git diff --stat <fix_base>..<HEAD> >> "$scope_diff"
158
+ git diff -U10 <fix_base>..<HEAD> >> "$scope_diff"
159
+ ```
160
+
161
+ 3. **Scoped re-review**:派发 re-reviewer(`general`, `background=true`),prompt 包含:
162
+ - brief_file 路径
163
+ - findings 列表
164
+ - report_file 路径
165
+ - scope_diff 路径
166
+ - "Verdict each finding: ADDRESSED / NOT ADDRESSED. Check fix diff for new breakage only."
167
+
168
+ 4. **写 Ledger**:
169
+ ```
170
+ T<N>: fix round <R>/5 (<X> addressed, <Y> open — <finding one-liners>; commits <base7>..<head7>)
171
+ ```
172
+
173
+ 5. **判断**:
174
+ - 全部 ADDRESSED + 无新 Critical/Important → 任务完成,勾单
175
+ - 有 open findings 且 R < 5 → 下一轮
176
+ - 有 open findings 且 R = 5 → Breaker
177
+
178
+ #### Re-reviewer prompt 模板
179
+
180
+ ```
181
+ 你是 scoped re-review subagent。验证上一轮 review 的 findings 是否已解决,检查 fix diff 是否引入新问题。
182
+
183
+ ## The Task
184
+ Read the task brief: <brief_file>
185
+
186
+ ## The Findings Under Verification
187
+ <findings — 逐条列出>
188
+
189
+ ## The Fix
190
+ Read the implementer's report (fix reports appended at end): <report_file>
191
+
192
+ Fix base: <fix_base>
193
+ Head: <HEAD>
194
+ Diff file: <scope_diff>
195
+
196
+ Read the diff file once. Do not re-run git commands. Read-only review.
197
+
198
+ ## Scope
199
+ Your scope is the findings list and the fix diff. Verdict every finding.
200
+ Inspect the fix diff for new problems only. Do NOT re-review code the fix did not touch.
201
+ Out-of-scope observations → report as non-blocking, do not extend the loop.
202
+
203
+ ## You Do Not Dispatch Subagents
204
+
205
+ ## Output Format
206
+ Write your re-review to <rereview_file> (<doc_dir>/task-<N>-rereview-<R>.md):
207
+
208
+ ### Finding Verdicts
209
+ For each finding, in order:
210
+ - **<finding one-liner>** — ADDRESSED | NOT ADDRESSED, with file:line evidence
211
+
212
+ ### New Breakage in the Fix Diff
213
+ Anything the fix broke. "None" if clean.
214
+
215
+ ### Out-of-Scope Observations
216
+ Non-blocking. "None" if none.
217
+
218
+ ### Verdict
219
+ **Fix round:** All findings addressed, no new Critical/Important breakage | Findings remain open — list them
220
+
221
+ Then report back with ONLY (≤10 lines):
222
+ - Verdict: All addressed | <N> open
223
+ - New breakage: None | <count>
224
+ - Re-review file path
225
+ ```
226
+
227
+ ### 步骤 5:Breaker(Round 5 仍有 open findings)
228
+
229
+ **绝不**在 Round 5 前提前裁决。只有 Round 5 re-review 仍有 open findings 时才触发。
230
+
231
+ 主 agent 裁决每条 open finding:
232
+
233
+ | 情况 | 裁决 | Ledger 记录 |
234
+ |------|------|------------|
235
+ | reviewer 错误/可争议 | park with ruling | `T<N>: parked — <finding> — Ruling: <why code stands>` |
236
+ | 真问题但不 load-bearing | park with ruling | `T<N>: parked — <finding> — Ruling: real but deferred` |
237
+ | 真问题且 load-bearing | 最小修复裁决 | `T<N>: Ruling: <finding> — <what you decided> — <cost if wrong>` |
238
+ | 每条路都是猜测 | STOP | `T<N>: BLOCKED — <reason>` |
239
+
240
+ 裁决后:
241
+ - 全部 parked → 任务完成,勾单
242
+ - 有 load-bearing ruling → 继续执行裁决的修复
243
+ - STOP → 加载 todo-recovery
244
+
245
+ ## 输出
246
+
247
+ - `<doc_dir>/task-<N>-review-<base7>..<head7>.diff`(review package)
248
+ - `<doc_dir>/task-<N>-review.md`(reviewer 报告)
249
+ - fix loop 期间:scoped diff + `<doc_dir>/task-<N>-rereview-<R>.md`
250
+ - Ledger 条目:`T<N>: reviewed_head=` / `T<N>: complete` / `T<N>: fix round <R>/5` / `T<N>: minor (deferred)` / `T<N>: parked` / `Ruling:`
251
+
252
+ ## 约束
253
+
254
+ - reviewer/re-reviewer 只读约束写在 prompt 里,不得改源码、不得 add/commit
255
+ - reviewer 不重跑测试:信任 implementer 报告的测试结果
256
+ - fix prompt **内联 open findings(verbatim)+ 引用 review 文件路径**(implementer 需更多上下文时自读完整 review),与 superpowers 一致
257
+ - fix 轮次硬上限 5 轮;Breaker 绝不在 Round 5 前提前裁决
258
+ - 主 agent 不自己 fix findings——controller fixes skip review
259
+ - 只审查与 fix,不规划、不派发初次 implementer
@@ -39,6 +39,7 @@ work agent 完成第三步「产物目录与 Ledger」、并已通过 work-plan
39
39
 
40
40
  - `references/prepare.md` → 4.1 准备(BASE 记录、Ledger 写 base+session、brief 渲染、report 路径指定)
41
41
  - `references/dispatch-prompt.md` → 4.2 派发 prompt 模板(自包含结构 + 执行边界 50 次 + 防循环 + 自审 + 报告格式)与「禁止」清单
42
+ - `references/explore-prompt.md` → 只读调研 prompt 模板(explore 专属,执行边界 30 次 + 只读约束 + 报告格式)
42
43
  - `references/report-handling.md` → 4.3 status 处理表 + 异常返回表 + 重试上限 1 次 + background 派发与串行衔接
43
44
 
44
45
  ### 阶段 2:派发前准备
@@ -47,7 +48,18 @@ work agent 完成第三步「产物目录与 Ledger」、并已通过 work-plan
47
48
 
48
49
  ### 阶段 3:派发 implementer
49
50
 
50
- 按 `references/dispatch-prompt.md` 渲染自包含 prompt(所有占位符展开为绝对路径),用 `task` 工具派发,`subagent_type` 取 `explore`(只读)或 `general`(可写)。写 Ledger `T<N>: session=<session_ref>`。
51
+ 按 `references/dispatch-prompt.md` 渲染自包含 prompt(所有占位符展开为绝对路径),用 `task` 工具派发,`subagent_type` 取 `work-explore`(只读)或 `work-general`(可写)。写 Ledger `T<N>: session=<session_ref>`。
52
+
53
+ ### 阶段 3a:并行派发 explore(可选)
54
+
55
+ 当 plan.md 中存在多个可并行的 `work-explore`(只读)任务时,按以下流程批量派发:
56
+
57
+ 1. **识别可并行任务**:从 plan.md 中筛选出当前轮次可同时执行的 explore 任务(无依赖或依赖已满足)。
58
+ 2. **批量派发 ≤5**:在同一条消息中发出多个 `task` 调用,`subagent_type=work-explore`,`background=true`,每个使用 `references/explore-prompt.md` 模板渲染 prompt。写 Ledger `T<N>: session=<session_ref>`(每个任务各写一行)。
59
+ 3. **等待全部返回**:所有 explore 任务返回后再逐个处理,不边收边派。
60
+ 4. **逐个处理返回**:对每个 explore 返回按 `references/report-handling.md` 写 Ledger 状态行并分派动作。
61
+
62
+ > general 任务仍保持串行:派发后等 review close 才派下一个 general,不与 explore 混合并行。
51
63
 
52
64
  ### 阶段 4:处理返回
53
65
 
@@ -65,7 +77,7 @@ implementer 返回后立即按 `references/report-handling.md` 写 Ledger 状态
65
77
  - prompt 必须自包含:subagent 看不到主 agent 历史,所有占位符(`<BRIEF_FILE>`/`<REPORT_FILE>`/`<doc_dir>/...` 等)一律展开为绝对路径。
66
78
  - 派发前禁止:粘贴计划全文到 prompt、粘贴之前任务摘要到后续 prompt、让 subagent 读整个计划文件、在 prompt 中重复 brief 的 accept/verify。
67
79
  - 异常处理纪律:绝不忽略升级或强制同一模型无变化重试;空输出/无 status 最多重试 1 次,再失败按 BLOCKED 处理。
68
- - 串行硬规则:下一个 `general` 必须在上一任务 review close 后才派发,且 `BASE` 自动等于上一任务 `HEAD`;`explore` 可并行且 ≤5 个/轮。
80
+ - 串行硬规则:下一个 `work-general` 必须在上一任务 review close 后才派发,且 `BASE` 自动等于上一任务 `HEAD`;`work-explore` 可并行且 ≤5 个/轮。
69
81
  - 本技能只派发与处理返回,不审查、不 fix、不改源码。
70
82
 
71
83
  ## 资源目录
@@ -74,5 +86,6 @@ implementer 返回后立即按 `references/report-handling.md` 写 Ledger 状态
74
86
  references/
75
87
  ├── prepare.md # 4.1 准备(BASE/Ledger/brief/report 路径)
76
88
  ├── dispatch-prompt.md # 4.2 派发 prompt 模板 + 禁止清单
89
+ ├── explore-prompt.md # 只读调研 prompt 模板(explore 专属)
77
90
  └── report-handling.md # 4.3 status 表 + 异常表 + 重试上限 + 串行衔接
78
91
  ```
@@ -1,6 +1,8 @@
1
1
  # 4.2 派发 prompt 模板
2
2
 
3
- 使用 `task` 工具,`subagent_type` 取 `explore`(只读)或 `general`(可写)。
3
+ 使用 `task` 工具,`subagent_type` 取 `work-explore`(只读)或 `work-general`(可写)。
4
+
5
+ - **所有 task 派发必须传 `background=true`**:subagent 异步运行,主 agent 不阻塞,完成时自动通知。这是防止主 agent 卡死的硬性约束。
4
6
 
5
7
  ## 自包含原则
6
8
 
@@ -85,3 +87,10 @@ brief 是你的唯一需求来源——不要假设 brief 之外的任何上下
85
87
  - 粘贴之前任务的摘要到后续任务的 prompt
86
88
  - 让 subagent 读整个计划文件
87
89
  - 在 prompt 中重复 brief 的 accept/verify(implementer 自己读 brief)
90
+
91
+ ## 并行派发
92
+
93
+ - **explore 任务可同轮批量派发(≤5)**:当存在多个可并行的只读调研任务时,在同一条消息中发出多个 `task` 调用,`subagent_type=work-explore`,`background=true`,每个使用 `references/explore-prompt.md` 模板渲染 prompt。
94
+ - **general 任务必须串行**:使用本文件(dispatch-prompt.md)模板,派发后等 review close 才派下一个 general。
95
+ - **批量派发 explore 时**:同一条消息发出多个 task 调用,全部 `background=true`;等待全部 explore 返回后再逐个处理返回,不边收边派。
96
+ - **explore 与 general 衔接**:所有 explore 返回并处理完毕后,再进入 general 串行链。