@wwkit/harness 1.0.18 → 1.0.20

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 (52) hide show
  1. package/README.md +2 -2
  2. package/agents/fastcode.md +130 -0
  3. package/agents/scrum.md +65 -0
  4. package/package.json +4 -2
  5. package/readme/development.md +1 -1
  6. package/scripts/postinstall.js +41 -0
  7. package/skills/query/SKILL.md +112 -0
  8. package/skills/query/references/input.schema.json5 +25 -0
  9. package/skills/read-docs/references/superpowers/comparison.md +1 -1
  10. package/skills/read-docs/references/superpowers/index.md +1 -1
  11. package/agents/query.md +0 -42
  12. package/agents/todo.md +0 -119
  13. package/agents/work-explore.md +0 -50
  14. package/agents/work-general.md +0 -44
  15. package/agents/work.md +0 -188
  16. package/plugins/work-bootstrap.js +0 -77
  17. package/scripts/work-review-package +0 -50
  18. package/scripts/work-task-brief +0 -27
  19. package/scripts/work-workspace +0 -31
  20. package/skills/todo-dispatch/SKILL.md +0 -211
  21. package/skills/todo-finalize/SKILL.md +0 -238
  22. package/skills/todo-plan/SKILL.md +0 -174
  23. package/skills/todo-recovery/SKILL.md +0 -179
  24. package/skills/todo-review/SKILL.md +0 -259
  25. package/skills/work-dispatch/SKILL.md +0 -91
  26. package/skills/work-dispatch/references/dispatch-prompt.md +0 -96
  27. package/skills/work-dispatch/references/explore-prompt.md +0 -74
  28. package/skills/work-dispatch/references/prepare.md +0 -25
  29. package/skills/work-dispatch/references/report-handling.md +0 -65
  30. package/skills/work-finalize/SKILL.md +0 -83
  31. package/skills/work-finalize/references/acceptance.md +0 -19
  32. package/skills/work-finalize/references/final-review.md +0 -55
  33. package/skills/work-finalize/references/handover.md +0 -36
  34. package/skills/work-ledger/SKILL.md +0 -73
  35. package/skills/work-ledger/references/bootstrap.md +0 -36
  36. package/skills/work-ledger/references/layout.md +0 -25
  37. package/skills/work-ledger/references/ledger-format.md +0 -57
  38. package/skills/work-plan/SKILL.md +0 -81
  39. package/skills/work-plan/references/plan-file.md +0 -29
  40. package/skills/work-plan/references/self-review.md +0 -18
  41. package/skills/work-plan/references/split-rules.md +0 -23
  42. package/skills/work-plan/references/task-fields.md +0 -44
  43. package/skills/work-recovery/SKILL.md +0 -80
  44. package/skills/work-recovery/references/budget.md +0 -39
  45. package/skills/work-recovery/references/replan.md +0 -21
  46. package/skills/work-recovery/references/rollback.md +0 -20
  47. package/skills/work-review/SKILL.md +0 -95
  48. package/skills/work-review/references/breaker.md +0 -26
  49. package/skills/work-review/references/fix-loop.md +0 -123
  50. package/skills/work-review/references/review-package.md +0 -24
  51. package/skills/work-review/references/reviewer-prompt.md +0 -77
  52. package/skills/work-review/references/verdict-handling.md +0 -25
@@ -1,259 +0,0 @@
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
@@ -1,91 +0,0 @@
1
- ---
2
- name: work-dispatch
3
- description: |
4
- [work 专属 runbook] 仅供 work agent 通过 skill 工具显式调用(name=work-dispatch),其他 agent / 普通对话禁止触发
5
- 派发阶段技能:4.1 准备(记录 BASE、Ledger 写 base+session、渲染 task brief、指定 report 路径);
6
- 4.2 渲染自包含派发 prompt(任务详情/上下文/约束/执行边界 50 次+防循环/自审/报告格式);
7
- 4.3 处理 implementer 返回(status 表 DONE/DONE_WITH_CONCERNS/NEEDS_CONTEXT/BLOCKED/ESCALATE + 异常表 + 重试上限 1 次 + background 派发与串行衔接)。
8
- 适用:work agent 第四步「派发 implementer」。
9
- 不适用:规划(用 work-plan);产物目录与 Ledger 维护(用 work-ledger);审查与 fix loop(用 work-review);非 work 流程的普通派发。
10
- license: MIT
11
- metadata:
12
- workflow: sequential
13
- ---
14
-
15
- # work-dispatch 技能
16
-
17
- ## 触发时机
18
-
19
- work agent 完成第三步「产物目录与 Ledger」、并已通过 work-plan 落单任务后,进入第四步「派发 implementer」时加载本技能。每派发一个任务加载一次;恢复场景下按 Ledger `T<N>: base=`/`T<N>: session=` 条目恢复派发上下文。
20
-
21
- ## 输入
22
-
23
- 从 work.md 流程传入:
24
-
25
- | 输入 | 说明 |
26
- |------|------|
27
- | `doc_dir` | 产物目录绝对路径(来自 work-ledger),brief/report/diff 文件均写其下 |
28
- | `plan.md` | 任务计划文件(位于 `<doc_dir>/plan.md`),派发以其中该任务条目为准 |
29
- | `task_id` (`T<N>`) | 当前任务编号 |
30
- | `root_dir` | 工程根目录,prompt 内路径与 bash 命令的基准 |
31
- | `constraints` | 全局约束,展开为每个任务 `forbidden` 的至少内容 |
32
- | Ledger 句柄 | 派发前后需写 `T<N>: base=`/`T<N>: session=`/状态行 |
33
-
34
- ## 工作流程
35
-
36
- ### 阶段 1:加载 references
37
-
38
- 用 `read` 工具加载本技能 `references/` 下的全部流程文件(相对路径基于本 skill 目录):
39
-
40
- - `references/prepare.md` → 4.1 准备(BASE 记录、Ledger 写 base+session、brief 渲染、report 路径指定)
41
- - `references/dispatch-prompt.md` → 4.2 派发 prompt 模板(自包含结构 + 执行边界 50 次 + 防循环 + 自审 + 报告格式)与「禁止」清单
42
- - `references/explore-prompt.md` → 只读调研 prompt 模板(explore 专属,执行边界 30 次 + 只读约束 + 报告格式)
43
- - `references/report-handling.md` → 4.3 status 处理表 + 异常返回表 + 重试上限 1 次 + background 派发与串行衔接
44
-
45
- ### 阶段 2:派发前准备
46
-
47
- 按 `references/prepare.md`:记录 `BASE = $(git rev-parse HEAD)`;写 Ledger `T<N>: base=<BASE>`;以 `plan.md` 中该任务条目渲染 `<doc_dir>/task-<N>-brief.md`;在 prompt 中告知 implementer report 路径 `<doc_dir>/task-<N>-report.md`。
48
-
49
- ### 阶段 3:派发 implementer
50
-
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 混合并行。
63
-
64
- ### 阶段 4:处理返回
65
-
66
- implementer 返回后立即按 `references/report-handling.md` 写 Ledger 状态行,再按 status 表分派动作;异常返回按异常表处理,空输出/无 status 最多重试 1 次。background 派发时遵循串行衔接规则:派发后记 Ledger → 做本地工作 → 收到通知 → 处理 → review close 后才派下一个 general;等待期间不派下一个。
67
-
68
- ## 输出
69
-
70
- - `<doc_dir>/task-<N>-brief.md`(派发前渲染)
71
- - Ledger 中 `T<N>: base=`/`T<N>: session=`/状态行条目
72
- - 触发下一步:status=DONE/DONE_WITH_CONCERNS → 生成 review package 并交 work-review;其他 status 按表分派
73
- - 本技能**不审查、不 fix**(审查与 fix loop 属 work-review)
74
-
75
- ## 约束
76
-
77
- - prompt 必须自包含:subagent 看不到主 agent 历史,所有占位符(`<BRIEF_FILE>`/`<REPORT_FILE>`/`<doc_dir>/...` 等)一律展开为绝对路径。
78
- - 派发前禁止:粘贴计划全文到 prompt、粘贴之前任务摘要到后续 prompt、让 subagent 读整个计划文件、在 prompt 中重复 brief 的 accept/verify。
79
- - 异常处理纪律:绝不忽略升级或强制同一模型无变化重试;空输出/无 status 最多重试 1 次,再失败按 BLOCKED 处理。
80
- - 串行硬规则:下一个 `work-general` 必须在上一任务 review close 后才派发,且 `BASE` 自动等于上一任务 `HEAD`;`work-explore` 可并行且 ≤5 个/轮。
81
- - 本技能只派发与处理返回,不审查、不 fix、不改源码。
82
-
83
- ## 资源目录
84
-
85
- ```
86
- references/
87
- ├── prepare.md # 4.1 准备(BASE/Ledger/brief/report 路径)
88
- ├── dispatch-prompt.md # 4.2 派发 prompt 模板 + 禁止清单
89
- ├── explore-prompt.md # 只读调研 prompt 模板(explore 专属)
90
- └── report-handling.md # 4.3 status 表 + 异常表 + 重试上限 + 串行衔接
91
- ```
@@ -1,96 +0,0 @@
1
- # 4.2 派发 prompt 模板
2
-
3
- 使用 `task` 工具,`subagent_type` 取 `work-explore`(只读)或 `work-general`(可写)。
4
-
5
- - **所有 task 派发必须传 `background=true`**:subagent 异步运行,主 agent 不阻塞,完成时自动通知。这是防止主 agent 卡死的硬性约束。
6
-
7
- ## 自包含原则
8
-
9
- > 派发前,prompt 中所有占位符(`<BRIEF_FILE>`、`<REPORT_FILE>`、`<doc_dir>/...` 等)一律展开为绝对路径,subagent 直接可读,不再含任何待解引用符号。
10
-
11
- subagent 看不到主 agent 历史,prompt 必须自包含。
12
-
13
- ## prompt 结构
14
-
15
- ```
16
- 你是一个被派发的执行者。你的任务是实现 T<N>: <task name>
17
-
18
- ## 任务详情
19
-
20
- 读取你的任务 brief:<BRIEF_FILE>
21
- 它包含完整任务文本:goal、files、interfaces、accept(验收标准)、verify(验证命令)、约束。
22
- brief 是你的唯一需求来源——不要假设 brief 之外的任何上下文。
23
-
24
- ## 上下文
25
-
26
- <场景设置:任务在项目中的位置、依赖、架构上下文>
27
- <接口信息:前序任务产出的接口、类型、签名——从 plan.md 的 interfaces 字段提取>
28
-
29
- ## 约束
30
-
31
- - 可写文件白名单:<writable>
32
- - 禁改文件:<forbidden>(含 constraints)
33
- - 工作目录:<root_dir>
34
-
35
- ## 执行边界(硬约束)
36
-
37
- - **最多 50 次工具调用**:每调用一次工具(read/write/edit/bash/grep/glob 等)计一次。到 50 次仍未完成必须停止并报告 ESCALATE。
38
- - **禁止无限循环**:同一个文件不要读超过 3 次;同一个测试不要连续运行超过 3 次;同一个错误不要重试超过 2 次。
39
- - **进度自检**:每 10 次工具调用后,评估剩余工作是否还能在剩余调用次数内完成。不能则立即停止并报告 ESCALATE。
40
- - **遇到以下情况立即停止并报告**:
41
- - 任务需要架构决策(多种有效方案)→ BLOCKED
42
- - 你无法理解代码且无法找到清晰说明 → BLOCKED
43
- - 任务涉及计划未预见的大量重构 → ESCALATE
44
- - 你不确定你的方法是否正确 → ESCALATE
45
- - 工具调用次数即将耗尽且未完成 → ESCALATE
46
-
47
- ## 你的工作
48
-
49
- 1. 按 brief 实现指定内容
50
- 2. 写测试(如 brief 要求 TDD)
51
- 3. 运行 brief 中的 verify 命令验证实现可用
52
- 4. 对照 brief 中的 accept 验收标准逐条自检
53
- 5. 提交你的工作
54
- 6. 自审(见下方)
55
- 7. 报告
56
-
57
- ## 自审
58
-
59
- 报告前检查:
60
- - 完整性:brief 中的 accept 每条是否满足?
61
- - 质量:命名是否清晰?代码是否可维护?
62
- - 纪律:是否避免了过度构建(YAGNI)?
63
- - 测试:测试是否验证真实行为(不是 Mock 行为)?
64
-
65
- ## 报告格式
66
-
67
- 将完整报告写入 <REPORT_FILE>:
68
- - 实现了什么
69
- - 验证结果(verify 命令输出 + 测试结果)
70
- - accept 逐条对照结果
71
- - 变更文件
72
- - 自审发现
73
- - 顾虑或问题
74
-
75
- 然后用 ≤15 行回报(详情在报告文件中):
76
- - Status: DONE | DONE_WITH_CONCERNS | BLOCKED | NEEDS_CONTEXT | ESCALATE
77
- - Commits(短 SHA + subject)
78
- - 一行验证摘要(如 "14/14 passing")
79
- - 工具调用次数(如 "used 18/50")
80
- - 顾虑(如有)
81
- - 报告文件路径
82
- ```
83
-
84
- ## 禁止
85
-
86
- - 粘贴计划全文到 prompt(brief 文件是单一来源)
87
- - 粘贴之前任务的摘要到后续任务的 prompt
88
- - 让 subagent 读整个计划文件
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 串行链。
@@ -1,74 +0,0 @@
1
- # 4.3 只读调研 prompt 模板
2
-
3
- 使用 `task` 工具,`subagent_type` 取 `work-explore`(只读)。
4
-
5
- - **所有 task 派发必须传 `background=true`**:subagent 异步运行,主 agent 不阻塞,完成时自动通知。这是防止主 agent 卡死的硬性约束。
6
-
7
- ## 自包含原则
8
-
9
- > 派发前,prompt 中所有占位符(`<BRIEF_FILE>`、`<REPORT_FILE>`、`<doc_dir>/...` 等)一律展开为绝对路径,subagent 直接可读,不再含任何待解引用符号。
10
-
11
- subagent 看不到主 agent 历史,prompt 必须自包含。
12
-
13
- ## prompt 结构
14
-
15
- ```
16
- 你是一个被派发的只读调研者。你的任务是执行 T<N>: <task name>
17
-
18
- ## 任务详情
19
-
20
- 读取你的任务 brief:<BRIEF_FILE>
21
- 它包含完整任务文本:goal、files、accept(验收标准)、verify、约束。
22
- brief 是你的唯一需求来源——不要假设 brief 之外的任何上下文。
23
-
24
- ## 上下文
25
-
26
- <场景设置:任务在项目中的位置、依赖、架构上下文>
27
- <接口信息:前序任务产出的接口、类型、签名——从 plan.md 的 interfaces 字段提取>
28
-
29
- ## 约束
30
-
31
- - 只读:绝不提交、绝不改写工作树/index/HEAD
32
- - 工作目录:<root_dir>
33
-
34
- ## 执行边界(硬约束)
35
-
36
- - **最多 30 次工具调用**:每调用一次工具(read/grep/glob/bash 等)计一次。到 30 次仍未完成必须停止并报告 ESCALATE。
37
- - **禁止无限循环**:同一个文件不要读超过 3 次;同一个搜索不要连续运行超过 3 次。
38
- - **进度自检**:每 10 次工具调用后,评估剩余工作是否还能在剩余调用次数内完成。不能则立即停止并报告 ESCALATE。
39
- - **范围**:只调研 brief 指定范围,不发散。
40
- - **遇到以下情况立即停止并报告**:
41
- - 无法理解代码(已读 3 次仍不明确)→ BLOCKED
42
- - 调研范围超出 brief 预期 → BLOCKED
43
- - 工具调用次数即将耗尽且未完成 → ESCALATE
44
-
45
- ## 你的工作
46
-
47
- 1. 按 brief 执行调研/搜索/验证
48
- 2. 收集 file:line 证据
49
- 3. 对照 brief 中的 accept 验收标准逐条自检
50
- 4. 报告
51
-
52
- ## 报告格式
53
-
54
- 将完整报告写入 <REPORT_FILE>:
55
- - 调研发现
56
- - 关键 file:line 证据
57
- - accept 逐条对照结果
58
- - 顾虑或问题
59
-
60
- 然后用 ≤10 行回报(详情在报告文件中):
61
- - Status: DONE | DONE_WITH_CONCERNS | BLOCKED | NEEDS_CONTEXT | ESCALATE
62
- - 一行结论摘要
63
- - 关键 file:line 证据(≤5 条)
64
- - 工具调用次数(如 "used 12/30")
65
- - 报告文件路径
66
- ```
67
-
68
- ## 禁止
69
-
70
- - 黏贴计划全文到 prompt(brief 文件是单一来源)
71
- - 黏贴之前任务的摘要到后续任务的 prompt
72
- - 让 subagent 读整个计划文件
73
- - 在 prompt 中重复 brief 的 accept/verify(implementer 自己读 brief)
74
- - 写代码、改文件、跑测试(只读场景)
@@ -1,25 +0,0 @@
1
- # 4.1 派发前准备
2
-
3
- 按以下顺序执行,每步产物供后续阶段与 work-review 使用。
4
-
5
- ## 步骤
6
-
7
- 1. **记录 BASE**:`BASE = $(git rev-parse HEAD)`(当前 HEAD,作为本任务的 diff 起点与下一任务 `BASE` 的来源)。
8
- 2. **写 Ledger**:`T<N>: base=<BASE>`(compaction 后恢复用;恢复时以此条目为准,不以记忆为准)。
9
- 3. **渲染 task brief**:以 `<doc_dir>/plan.md` 中该任务条目为准,渲染为 `<doc_dir>/task-<N>-brief.md`,包含完整任务文本:`goal`/`files`/`interfaces`/`accept`(验收标准)/`verify`(验证命令)/`约束`。
10
- 4. **指定 report 路径**:`<doc_dir>/task-<N>-report.md`,在 prompt 中告知 implementer(implementer 把完整报告写入此文件)。
11
-
12
- ## 产物
13
-
14
- | 产物 | 位置 | 用途 |
15
- |------|------|------|
16
- | `BASE` 值 | 内存 + Ledger | review package 的 diff 起点;下一任务 `BASE` |
17
- | `T<N>: base=` | Ledger | compaction 恢复入口 |
18
- | `task-<N>-brief.md` | `<doc_dir>/` | implementer 的唯一需求来源 |
19
- | `task-<N>-report.md` 路径 | prompt 中告知 | implementer 写报告的目标文件 |
20
-
21
- ## 约束
22
-
23
- - brief 文件是单一来源:不要在 prompt 中重复 brief 的 `accept`/`verify`,implementer 自己读 brief。
24
- - `BASE` 取 7 位短 SHA 用于 Ledger 显示,但 diff 计算用完整 SHA。
25
- - 恢复场景:若 Ledger 已有 `T<N>: base=`,跳过步骤 1-2,直接以该值作为 `BASE`。
@@ -1,65 +0,0 @@
1
- # 4.3 处理 implementer 返回
2
-
3
- implementer 返回后,**立即写入 Ledger** 状态行,然后按 status 处理。
4
-
5
- ## 任务后工作区验证(强制)
6
-
7
- > **explore 豁免**:`work-explore`(只读)返回时**跳过工作区验证**——explore 不产生任何 git 变更,无需检查 `git status --porcelain`。仅 `work-general`(可写)返回时执行以下工作区验证。
8
-
9
- implementer 返回后、按 status 处理前,执行工作区干净检查:
10
-
11
- 1. 检查 `git status --porcelain`:
12
- - **空(干净)**:继续按 status 处理
13
- - **非空(脏)**:
14
- - 如果脏文件全部在 implementer 的 writable 白名单内 → implementer 忘记提交 → **主 agent 自动提交**(`git add <writable files> && git commit -m "<task_id>: auto-commit uncommitted writable files"`),记 Ledger `T<N>: auto-committed uncommitted writable`,继续按 status 处理
15
- - 如果脏文件有不在 writable 白名单内的 → **forbidden 文件被改** → 记 Critical finding,强制 `git checkout -- <file>` 恢复,记 Ledger `T<N>: reverted forbidden <file>`
16
-
17
- ## status 处理表
18
-
19
- | Status | Ledger 记录 | 动作 |
20
- |--------|------------|------|
21
- | `DONE` | `T<N>: implementer done (commits <base7>..<head7>)` | 生成 review package,派发 task reviewer |
22
- | `DONE_WITH_CONCERNS` | `T<N>: implementer done_with_concerns (<concern one-liner>)` | 读**回报文本中的顾虑段(≤15 行,不读完整 report 文件)**,正确性/范围问题先处理,观察类问题记录后进入 review |
23
- | `NEEDS_CONTEXT` | `T<N>: needs_context` | 补充上下文,重新派发(复用 session_ref 或新开会话;task_id 不变) |
24
- | `BLOCKED` | `T<N>: blocked (<reason>)` | 评估:上下文问题→补充重派;推理不足→换更强模型;任务过大→拆分;计划错误→重规划(见「重规划」节) |
25
- | `ESCALATE` | `T<N>: escalate (<reason>)` | 停止该分支。如实向用户说明为何超出边界/需人工介入,不再重试。如果是工具调用耗尽,考虑拆分任务后重新派发 |
26
-
27
- ## explore 专用处理路径
28
-
29
- `work-explore`(只读)的返回处理与 `work-general` 不同——explore 不产生 git 变更,无需 BASE/HEAD 记录:
30
-
31
- | explore 返回 | 处理 |
32
- |-------------|------|
33
- | `DONE` | 直接进入 review(review 范围 = 报告内容,无 diff)。review 标准:brief 的 accept 是否满足 + 证据是否充分(file:line) |
34
- | `DONE_WITH_CONCERNS` | 读报告中的顾虑段,正确性/范围问题先处理,观察类问题记录后进入 review |
35
- | `NEEDS_CONTEXT` / `BLOCKED` / `ESCALATE` | 同 status 处理表 |
36
-
37
- - explore **不生成 review package**(无 BASE/HEAD diff),review 直接基于报告文件内容。
38
- - explore **无 Commits 字段**属正常(只读,不提交),不按"无 status"处理。
39
-
40
- ## 异常返回处理
41
-
42
- subagent 返回不符合预期时按以下表处理:
43
-
44
- | 异常情况 | 检测方式 | 处理 |
45
- |---------|---------|------|
46
- | 空输出 | 返回文本为空或仅空白 | 记 Ledger `T<N>: empty output`,新开会话重新派发(task_id 不变),最多重试 1 次 |
47
- | 无 status 行 | 返回文本不含 Status 关键字 | 计 Ledger `T<N>: no status`,从 report 文件读取实际状态;report 文件也无 → 按 BLOCKED 处理 |
48
- | 报告文件未写入 | report 文件不存在或为空 | 记 Ledger `T<N>: report missing`,按 BLOCKED 处理 |
49
- | task 工具返回错误 | task 工具返回 state="error" | 记 Ledger `T<N>: task error (<error>)`,评估错误类型后决定重派或升级 |
50
- | explore 返回脏工作区 | `git status --porcelain` 非空且 subagent_type=work-explore | 不应发生(只读权限)。若发生记 Critical finding,强制 `git checkout -- <file>` 恢复,记 Ledger `T<N>: explore dirty workspace (reverted)` |
51
- | explore 无 Commits 字段 | 返回文本不含 Commits 关键字且 subagent_type=work-explore | 正常(只读不提交),不按"无 status"处理,直接按 status 行处理 |
52
-
53
- ## 重试上限
54
-
55
- **绝不**忽略升级或强制同一模型无变化重试。空输出/无 status 最多重试 1 次,再失败则按 BLOCKED 处理。
56
-
57
- ## background 派发与串行衔接
58
-
59
- 派发后记 Ledger → 做本地工作 → 收到通知 → 处理 → review close 后才派下一个 `work-general`;等待期间不派下一个。
60
-
61
- - 派发后:立即写 Ledger `T<N>: session=` 与状态行,不要等返回。
62
- - 等待期间:可做不依赖该任务产物的本地工作(如准备下一任务 brief、整理 Ledger),但**不派发下一个 `work-general`**。
63
- - 收到通知:按上方 status 处理表分派动作。
64
- - review close 后:下一任务的 `BASE` 自动等于本任务 `HEAD`,才派发下一个 `work-general`。
65
- - `work-explore`(只读)可并行且 ≤5 个/轮,不受串行约束限制。