@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.
- package/README.md +6 -6
- package/agents/todo.md +119 -0
- package/agents/work-explore.md +50 -0
- package/agents/work-general.md +44 -0
- package/agents/work.md +55 -34
- package/commands/pytest.md +11 -0
- package/package.json +1 -1
- package/readme/development.md +1 -1
- package/skills/extract/SKILL.md +90 -28
- package/{agents/pyit.md → skills/pytest/SKILL.md} +223 -64
- package/skills/pytest-env-ensure/references/config.md +2 -2
- package/skills/pytest-sample/SKILL.md +3 -3
- package/skills/read-docs/references/superpowers/comparison.md +1 -1
- package/skills/read-docs/references/superpowers/index.md +1 -1
- package/skills/revise/SKILL.md +86 -25
- package/skills/todo-dispatch/SKILL.md +211 -0
- package/skills/todo-finalize/SKILL.md +238 -0
- package/skills/todo-plan/SKILL.md +174 -0
- package/skills/todo-recovery/SKILL.md +179 -0
- package/skills/todo-review/SKILL.md +259 -0
- package/skills/work-dispatch/SKILL.md +15 -2
- package/skills/work-dispatch/references/dispatch-prompt.md +10 -1
- package/skills/work-dispatch/references/explore-prompt.md +74 -0
- package/skills/work-dispatch/references/report-handling.md +31 -4
- package/skills/work-finalize/SKILL.md +2 -2
- package/skills/work-finalize/references/final-review.md +5 -3
- package/skills/work-finalize/references/handover.md +8 -0
- package/skills/work-ledger/SKILL.md +1 -1
- package/skills/work-ledger/references/bootstrap.md +12 -4
- package/skills/work-plan/SKILL.md +2 -2
- package/skills/work-plan/references/self-review.md +1 -1
- package/skills/work-plan/references/split-rules.md +1 -1
- package/skills/work-plan/references/task-fields.md +10 -10
- package/skills/work-recovery/SKILL.md +8 -8
- package/skills/work-recovery/references/budget.md +10 -11
- package/skills/work-recovery/references/rollback.md +4 -4
- package/skills/work-review/SKILL.md +2 -2
- package/skills/work-review/references/fix-loop.md +14 -9
- package/skills/work-review/references/reviewer-prompt.md +1 -1
- package/skills/work-review/references/verdict-handling.md +1 -1
- package/agents/extract.md +0 -26
- package/agents/pyut.md +0 -347
- package/agents/revise.md +0 -28
- package/commands/pyit.md +0 -6
- package/commands/pyut.md +0 -6
package/skills/revise/SKILL.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: revise
|
|
3
3
|
description: |
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
自包含内容创作 skill:解析入参(JSON/key=value/prose)→ 按 format 加载 prompt 生成 → schema 校验 → 写 output 文件或 stdout。
|
|
5
|
+
format=question/status/gallery/article。count 控制条目数(默认1),language 控制输出语言(默认中文)。
|
|
6
|
+
调用方直接传原始任务消息,skill 自解析自包含。内部用 todowrite 管理 6 步。禁止 WebFetch/网络请求。
|
|
7
7
|
适用:内容创作(question/status/gallery/article 等)。
|
|
8
8
|
license: MIT
|
|
9
9
|
metadata:
|
|
@@ -12,28 +12,71 @@ metadata:
|
|
|
12
12
|
|
|
13
13
|
# revise 技能
|
|
14
14
|
|
|
15
|
+
## 核心约束(最高优先级)
|
|
16
|
+
|
|
17
|
+
- **MUST**:收到任务消息后,先 todowrite 落单 6 步,再逐步执行。
|
|
18
|
+
- **MUST**:每步完成立即 todowrite 勾单。
|
|
19
|
+
- **禁止**:使用 WebFetch 或任何网络请求获取内容。
|
|
20
|
+
- **禁止**:写入 output 以外的任何文件;中间产物用临时文件,完成后清理。
|
|
21
|
+
- **禁止**:以任何形式使用未声明字段(url 等不属于 revise 的字段)。
|
|
22
|
+
|
|
23
|
+
## 第一步硬指令(自检)
|
|
24
|
+
|
|
25
|
+
解析入参前,强制自检:
|
|
26
|
+
> 我是否已用 todowrite 落单 6 步?
|
|
27
|
+
> - 未落单 → 立即 todowrite 创建清单。
|
|
28
|
+
> - 已落单 → 继续。
|
|
29
|
+
|
|
15
30
|
## 输入参数
|
|
16
31
|
|
|
17
|
-
|
|
32
|
+
入参为调用方传入的**原始任务消息**,可能是以下任一形态:
|
|
33
|
+
- **JSON 对象**:如 `{format, source, count, language, output}`,直接取字段值;
|
|
34
|
+
- **key=value**:如 `format=question, source=xxx`,按 `,` 和 `=` 拆分为字段;
|
|
35
|
+
- **纯文本 prose**:不做格式推断(同一 source 可有多种 format)。仅当文本命中 `references/format-aliases.json5` 中某 format 的 `terms`(如"问题/文章/图集/动态")时才翻译为该 format 标准值,`source` 取文本本身。
|
|
36
|
+
|
|
37
|
+
字段清单(字段/类型/必填)见 `references/input.schema.json5`。本技能仅使用 `source`、`format`、`count`、`language`、`output` 五个字段,忽略所有其他字段(如 `url`),不得读取、写入或据此推断任何行为。
|
|
18
38
|
|
|
19
39
|
## 输出
|
|
20
40
|
|
|
21
|
-
|
|
41
|
+
- 提供 `output` 参数:将 JSON 数组用 `write` 工具写入该文件,stdout 输出文件路径。
|
|
42
|
+
- 未提供 `output` 参数:将 JSON 数组直接输出到 stdout,**不写任何文件**。
|
|
43
|
+
- 校验失败未能产出数组:不写文件、不输出数组,将错误信息输出到 stderr 并结束。
|
|
22
44
|
|
|
23
45
|
## 工作流程
|
|
24
46
|
|
|
25
|
-
### 阶段
|
|
47
|
+
### 阶段 0:todowrite 落单
|
|
48
|
+
|
|
49
|
+
收到任务消息后,**先**用 `todowrite` 创建 6 步清单(status=pending):
|
|
50
|
+
|
|
51
|
+
1. 解析入参(JSON/key=value/prose → format/source/count/language/output)
|
|
52
|
+
2. 加载 references(format prompt 文件 + schema 文件)
|
|
53
|
+
3. 内容生成(LLM 创作)
|
|
54
|
+
4. Schema 校验
|
|
55
|
+
5. 校验失败修复重试(≤3 次)
|
|
56
|
+
6. 输出(写 output 文件或 stdout)
|
|
57
|
+
|
|
58
|
+
每步完成立即 todowrite 勾单(status=completed)。
|
|
59
|
+
|
|
60
|
+
### 阶段 1:解析入参
|
|
61
|
+
|
|
62
|
+
将第 1 步标记为 in_progress,解析原始任务消息:
|
|
26
63
|
|
|
27
|
-
- `
|
|
28
|
-
-
|
|
29
|
-
- `
|
|
30
|
-
- `{{ language }}`:输出内容语言,默认 `中文`。为空或仅含空白时按 `中文` 处理。
|
|
64
|
+
- **JSON 对象**:直接取 `format`/`source`/`count`/`language`/`output` 字段值。
|
|
65
|
+
- **key=value**:按 `,` 分割、按 `=` 拆分为键值对,取上述五字段。
|
|
66
|
+
- **纯文本 prose**:用 `read` 读取 `references/format-aliases.json5`,仅当文本命中某 format 的 `terms` 时翻译为该 format 标准值,`source` 取文本本身;未命中则 `format` 视为未提供。
|
|
31
67
|
|
|
32
|
-
|
|
68
|
+
解析后得到:
|
|
69
|
+
- `format`(必填,经别名表翻译为标准值)
|
|
70
|
+
- `source`(必填,素材文本或文件路径,原样透传由后续阶段解析)
|
|
71
|
+
- `count`(可选,数值,缺省透传空由阶段 3 按默认 1 处理)
|
|
72
|
+
- `language`(可选,缺省透传空由阶段 3 按默认 中文 处理)
|
|
73
|
+
- `output`(可选,输出文件路径)
|
|
33
74
|
|
|
34
|
-
|
|
75
|
+
**必填校验**:若无法解析出 `format` 或 `source`,将错误信息输出到 stderr 并结束,**禁止**继续执行。
|
|
35
76
|
|
|
36
|
-
|
|
77
|
+
**空 source 短路**:若 `source` 为空、null 或仅含空白:直接输出 `[]` 并结束,**禁止**继续执行。
|
|
78
|
+
|
|
79
|
+
完成后 todowrite 勾单第 1 步。
|
|
37
80
|
|
|
38
81
|
### 阶段 2:加载 Prompt 和 Schema
|
|
39
82
|
|
|
@@ -42,14 +85,18 @@ metadata:
|
|
|
42
85
|
- Prompt 文件:`references/{{ format }}.md` — LLM 创作指令
|
|
43
86
|
- Schema 文件:`references/{{ format }}.schema.json5` — 输出校验规则(JSON Schema)
|
|
44
87
|
|
|
45
|
-
用 `read` 工具读取两个文件内容,并**记录 schema 文件的绝对路径**(阶段 4
|
|
88
|
+
用 `read` 工具读取两个文件内容,并**记录 schema 文件的绝对路径**(阶段 4 校验时需要)。若 `format` 为空或对应 references 文件不存在:直接输出 `[]` 并结束。
|
|
89
|
+
|
|
90
|
+
完成后 todowrite 勾单第 2 步。
|
|
46
91
|
|
|
47
92
|
### 阶段 3:内容生成
|
|
48
93
|
|
|
49
|
-
先判断 `
|
|
94
|
+
先判断 `source` 是否为现有文件路径:若是则读取文件内容作为素材;否则直接以值作为素材。再判断素材是否为 JSON 字符串:若是则解析为结构化对象作为素材;否则直接作为文本素材。**禁止用 bash 解析 JSON**,直接依据内容理解处理。
|
|
50
95
|
|
|
51
96
|
将素材结合 Prompt 文件内容调用 LLM 生成符合格式的结果。**必须生成 `{{ count }}` 个 item,整体输出为 JSON 数组(即使 count=1)。** 内容语言使用 `{{ language }}`(默认中文)。
|
|
52
97
|
|
|
98
|
+
`count` 解析为整数,默认 1;为空、非整数或小于 1 时按 1 处理。`language` 为空或仅含空白时按 `中文` 处理。
|
|
99
|
+
|
|
53
100
|
生成时向 LLM 传入:
|
|
54
101
|
- 原始素材(完整 source,已解析为可读格式)
|
|
55
102
|
- Prompt 文件内容(创作指令)
|
|
@@ -57,6 +104,8 @@ metadata:
|
|
|
57
104
|
- `{{ language }}`(输出语言)
|
|
58
105
|
- 输出格式说明和示例
|
|
59
106
|
|
|
107
|
+
完成后 todowrite 勾单第 3 步。
|
|
108
|
+
|
|
60
109
|
### 阶段 4:Schema 校验
|
|
61
110
|
|
|
62
111
|
用 `write` 工具将待校验的 JSON 数组写入临时文件,再用 `write` 工具将 `{"data": <JSON 数组>, "schema_path": "<schema 绝对路径>"}` 写入 JSON 输入文件,stdin 重定向交给 Node.js 校验:
|
|
@@ -65,8 +114,8 @@ metadata:
|
|
|
65
114
|
node '<技能目录>/references/validate-schema.js' < <临时 JSON 输入文件>
|
|
66
115
|
```
|
|
67
116
|
|
|
68
|
-
-
|
|
69
|
-
-
|
|
117
|
+
- 若校验通过,todowrite 勾单第 4 步,跳过阶段 5,进入阶段 6
|
|
118
|
+
- 若校验失败,todowrite 勾单第 4 步,进入阶段 5 进行修复重试(最多 3 次)
|
|
70
119
|
|
|
71
120
|
### 阶段 5:校验失败时修复重试
|
|
72
121
|
|
|
@@ -80,19 +129,31 @@ node '<技能目录>/references/validate-schema.js' < <临时 JSON 输入文件>
|
|
|
80
129
|
|
|
81
130
|
重新生成后,再次执行阶段 4 校验。**最多重试 3 次**,超过则将最后一次重试的 schema 校验错误信息及「重试 {N} 次后 schema 校验仍然失败」输出到 stderr 并结束。
|
|
82
131
|
|
|
132
|
+
重试成功后 todowrite 勾单第 5 步,进入阶段 6。
|
|
133
|
+
|
|
83
134
|
### 阶段 6:输出
|
|
84
135
|
|
|
85
|
-
**若校验未通过(重试耗尽):** 将最后一次重试的 schema 校验错误信息及「重试 {N} 次后 schema 校验仍然失败」输出到 stderr
|
|
136
|
+
**若校验未通过(重试耗尽):** 将最后一次重试的 schema 校验错误信息及「重试 {N} 次后 schema 校验仍然失败」输出到 stderr 并结束,**不写任何文件**。
|
|
86
137
|
|
|
87
|
-
**若校验通过:**
|
|
138
|
+
**若校验通过:**
|
|
139
|
+
- 提供 `output` 参数:用 `write` 工具将最终 JSON 数组写入 `output` 指定文件(**禁止创建其他文件**),stdout 输出该文件路径。
|
|
140
|
+
- 未提供 `output` 参数:将最终 JSON 数组直接输出到 stdout,**不写任何文件**。
|
|
141
|
+
|
|
142
|
+
完成后 todowrite 勾单第 6 步。
|
|
143
|
+
|
|
144
|
+
## 工具使用约束
|
|
145
|
+
|
|
146
|
+
- 写文件一律用 `write` 工具;读文件用 `read` 工具。
|
|
147
|
+
- 需要中间数据时,用 `write` 工具写入临时文件,再以 stdin 重定向传给 node。
|
|
148
|
+
- 禁止使用未授权的 `cp`/`rm`/`mv` 等命令;需要复制、移动或删除临时文件时,一律用允许的 `node -e` 的 fs 模块完成。
|
|
149
|
+
- 除技能校验所需 node 外,禁止执行其他 shell。
|
|
88
150
|
|
|
89
151
|
## 约束
|
|
90
152
|
|
|
91
|
-
- 只处理已声明字段(source/format/count/language),忽略所有其他传入参数(如 `
|
|
92
|
-
-
|
|
93
|
-
-
|
|
94
|
-
-
|
|
95
|
-
- 内部重试步骤的中间产物禁止写入任何文件。
|
|
153
|
+
- 只处理已声明字段(source/format/count/language/output),忽略所有其他传入参数(如 `url`),**禁止**以任何形式使用它们。
|
|
154
|
+
- **禁止使用 WebFetch 或任何网络请求获取内容**;`source` 为空时必须输出 `[]`,绝不自行获取内容。
|
|
155
|
+
- 内部重试步骤的中间产物用临时文件,完成后清理,禁止写入 output 以外的任何持久文件。
|
|
156
|
+
- 禁止访问外部网络。
|
|
96
157
|
|
|
97
158
|
## references/ 目录结构
|
|
98
159
|
|
|
@@ -110,4 +171,4 @@ references/
|
|
|
110
171
|
├── article.md # 社交媒体图文文章 prompt
|
|
111
172
|
├── article.schema.json5
|
|
112
173
|
└── ...
|
|
113
|
-
```
|
|
174
|
+
```
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: todo-dispatch
|
|
3
|
+
description: 派发阶段:写 brief、记录 base、派发 implementer(explore 只读 / general 可写,background=true)、处理返回 status。主循环每派一个任务时加载。
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
workflow: sequential
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# todo-dispatch 技能
|
|
10
|
+
|
|
11
|
+
## 输入
|
|
12
|
+
|
|
13
|
+
| 输入 | 说明 |
|
|
14
|
+
|------|------|
|
|
15
|
+
| `doc_dir` | 产物目录绝对路径 |
|
|
16
|
+
| `plan.md` | 任务计划文件(`<doc_dir>/plan.md`) |
|
|
17
|
+
| `task_id` (`T<N>`) | 当前任务编号 |
|
|
18
|
+
| `root_dir` | 工程根目录 |
|
|
19
|
+
|
|
20
|
+
## 工作流程
|
|
21
|
+
|
|
22
|
+
### 步骤 1:派发前准备
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# 记录 base
|
|
26
|
+
base=$(git rev-parse --short=7 HEAD)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
写入 Ledger:`T<N>: base=<base>`
|
|
30
|
+
|
|
31
|
+
从 plan.md 提取当前任务条目,写入 brief 文件 `<doc_dir>/task-<N>-brief.md`:
|
|
32
|
+
|
|
33
|
+
```markdown
|
|
34
|
+
# Task <N>: <goal>
|
|
35
|
+
|
|
36
|
+
## Files
|
|
37
|
+
<files>
|
|
38
|
+
|
|
39
|
+
## Accept Criteria
|
|
40
|
+
<accept>
|
|
41
|
+
|
|
42
|
+
## Verify
|
|
43
|
+
<verify>
|
|
44
|
+
|
|
45
|
+
## Writable
|
|
46
|
+
<writable>
|
|
47
|
+
|
|
48
|
+
## Forbidden
|
|
49
|
+
<forbidden>
|
|
50
|
+
|
|
51
|
+
## Budget
|
|
52
|
+
<budget> tool calls max
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
指定 report 路径:`<doc_dir>/task-<N>-report.md`
|
|
56
|
+
|
|
57
|
+
**todowrite 全量替换**:派发当前任务前,用 `todowrite` 全量替换整个清单,把当前任务标 `in_progress`。
|
|
58
|
+
|
|
59
|
+
### 步骤 2:派发 implementer
|
|
60
|
+
|
|
61
|
+
用 `task` 工具派发,`background: true`。subagent 类型按任务 `readonly` 决定:`readonly=true` → `explore`(只读调研),`readonly=false` → `general`(可写实现)。
|
|
62
|
+
|
|
63
|
+
#### 只读调研(explore)prompt 模板
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
你是 explore 只读 subagent,执行代码库调研/搜索/理解工作。
|
|
67
|
+
|
|
68
|
+
## Task
|
|
69
|
+
Read your task brief first: <brief_file>
|
|
70
|
+
It contains the full task text.
|
|
71
|
+
|
|
72
|
+
## Constraints
|
|
73
|
+
1. **只读**:绝不提交、绝不改写工作树/index/HEAD,只做搜索/读取/理解。
|
|
74
|
+
2. **工具调用上限**:最多 <budget> 次。到限必须停止。
|
|
75
|
+
3. **证据要求**:返回结论时必须附 file:line 证据。
|
|
76
|
+
4. **范围**:只调研 brief 指定的范围,不发散。
|
|
77
|
+
5. **不派发 subagent**:你的工作不嵌套,不派发任何 subagent。
|
|
78
|
+
|
|
79
|
+
## Report Format
|
|
80
|
+
Write your full report to <report_file>:
|
|
81
|
+
- 调研发现
|
|
82
|
+
- 关键 file:line 证据
|
|
83
|
+
- accept 逐条对照结果
|
|
84
|
+
- 顾虑或问题
|
|
85
|
+
|
|
86
|
+
Then report back with ONLY (≤10 lines):
|
|
87
|
+
- Status: DONE | DONE_WITH_CONCERNS | BLOCKED | NEEDS_CONTEXT | ESCALATE
|
|
88
|
+
- 一行结论摘要
|
|
89
|
+
- 关键 file:line 证据(≤5 条)
|
|
90
|
+
- 工具调用次数(如 "used 12/<budget>")
|
|
91
|
+
- 报告文件路径
|
|
92
|
+
|
|
93
|
+
Work from: <root_dir>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### 可写实现 subagent prompt 模板
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
你是 general 可写 subagent,执行具体实现工作。
|
|
100
|
+
|
|
101
|
+
## Task
|
|
102
|
+
Read your task brief first: <brief_file>
|
|
103
|
+
It contains the full task text.
|
|
104
|
+
|
|
105
|
+
## Context
|
|
106
|
+
<一句话:此任务在项目中的位置>
|
|
107
|
+
|
|
108
|
+
## Constraints
|
|
109
|
+
1. **writable 白名单**:只 add/commit <writable> 中的文件。
|
|
110
|
+
2. **forbidden 清单**:不触碰 <forbidden> 中的文件和操作。
|
|
111
|
+
3. **工具调用上限**:最多 <budget> 次。到限必须停止并报告 ESCALATE。
|
|
112
|
+
4. **重复读取**:同一文件不读超过 3 次。
|
|
113
|
+
5. **重复测试**:同一测试不连续运行超过 3 次。
|
|
114
|
+
6. **不派发 subagent**:你的工作不嵌套,不派发任何 subagent。
|
|
115
|
+
7. **升级触发**:需要架构决策/无法理解代码/计划未预见的大量重构 → 停止报告 BLOCKED/ESCALATE。
|
|
116
|
+
|
|
117
|
+
## Your Job
|
|
118
|
+
1. Implement exactly what the task specifies
|
|
119
|
+
2. Write tests (following existing patterns)
|
|
120
|
+
3. Verify implementation works (run <verify>)
|
|
121
|
+
4. **Commit ALL your changes**——任务结束时该任务所有修改必须已提交(`git status` 干净),不残留脏文件给下一个任务
|
|
122
|
+
5. Self-review (read your own diff)
|
|
123
|
+
6. Report back
|
|
124
|
+
|
|
125
|
+
## Report Format
|
|
126
|
+
Write your full report to <report_file>:
|
|
127
|
+
- 实现了什么
|
|
128
|
+
- 验证结果(verify 命令输出 + 测试结果)
|
|
129
|
+
- accept 逐条对照结果
|
|
130
|
+
- 变更文件
|
|
131
|
+
- 自审发现
|
|
132
|
+
- 顾虑或问题
|
|
133
|
+
|
|
134
|
+
Then report back with ONLY (≤15 lines):
|
|
135
|
+
- Status: DONE | DONE_WITH_CONCERNS | BLOCKED | NEEDS_CONTEXT | ESCALATE
|
|
136
|
+
- Commits(短 SHA + subject)
|
|
137
|
+
- 一行验证摘要(如 "14/14 passing")
|
|
138
|
+
- 工具调用次数(如 "used 18/<budget>")
|
|
139
|
+
- 顾虑(如有)
|
|
140
|
+
- 报告文件路径
|
|
141
|
+
|
|
142
|
+
Work from: <root_dir>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### 步骤 3:并行派发(只读调研用 `explore`,MUST 并行)
|
|
146
|
+
|
|
147
|
+
**MUST**:plan.md 中存在多个可并行的只读任务(readonly=true,无依赖或依赖已满足)时,**不得逐个串行派发**——必须在同一条消息中一次性并行派发。
|
|
148
|
+
|
|
149
|
+
**并行单位**:一个 subagent = 一个任务。**绝不**把多个可并行任务合并进一个 subagent 的 prompt。
|
|
150
|
+
|
|
151
|
+
**分批规则**:可并行任务数 ≤5 → 一批并行派完;>5 → 分多批,每批 ≤5,同批一条消息并行发出,**前批全部返回后再派下一批**。
|
|
152
|
+
|
|
153
|
+
1. 在同一条消息中发出多个 `task` 调用,每个 `background=true`
|
|
154
|
+
2. 写 Ledger:每个任务各写 `T<N>: base=<base>`
|
|
155
|
+
3. 等待全部返回后再逐个处理
|
|
156
|
+
4. 不边收边派——全部返回后才进入下一步
|
|
157
|
+
|
|
158
|
+
> 可写任务(readonly=false)保持串行:派发后等 review close 才派下一个。
|
|
159
|
+
|
|
160
|
+
### 步骤 4:处理返回
|
|
161
|
+
|
|
162
|
+
subagent 返回后,**可写任务先做工作区验证**(见下),再写 Ledger 状态行、按 status 分派。
|
|
163
|
+
|
|
164
|
+
**工作区验证(仅可写任务,readonly=false,在判定 status 前执行)**:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
git status --porcelain
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
- 干净 → 按 status 表处理
|
|
171
|
+
- **脏 → 自动 commit 所有修改**:这些改动由本任务 subagent 产生,属 agent 自主提交,`git add -A && git commit -m "<T<N> auto-commit residual changes>"`,不残留给下一任务
|
|
172
|
+
- 脏文件超出 writable 白名单 → `git checkout -- <file>` 恢复,并在 report 记录 Critical finding
|
|
173
|
+
|
|
174
|
+
| Status | 动作 |
|
|
175
|
+
|--------|------|
|
|
176
|
+
| `DONE` | 生成 review package,进入 todo-review |
|
|
177
|
+
| `DONE_WITH_CONCERNS` | 读 report 中的顾虑,自主裁决:correctness/scope 问题先处理再 review;observation 类记录后继续 review |
|
|
178
|
+
| `NEEDS_CONTEXT` | 补充上下文,重新派发(同模型,最多 1 次) |
|
|
179
|
+
| `BLOCKED` | 评估阻塞:context 问题→补上下文重派;能力问题→换更强模型重派;任务太大→拆分后重派;计划错误→裁决修正后重派 |
|
|
180
|
+
| `ESCALATE` | 评估:换模型/拆任务/重规划(加载 todo-recovery) |
|
|
181
|
+
|
|
182
|
+
**异常处理**:
|
|
183
|
+
- 空输出/无 status → 重新派发(同模型,最多 1 次),再失败按 BLOCKED 处理
|
|
184
|
+
- 绝不忽略升级或强制同一模型无变化重试
|
|
185
|
+
|
|
186
|
+
### 步骤 5:有界等待(防超时卡死)
|
|
187
|
+
|
|
188
|
+
派发后不静默无限等待,也不短轮询:
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
有本地工作(更新 Ledger、准备下一个 review package)→ 继续做
|
|
192
|
+
真正空闲 → 等待 5-10 分钟
|
|
193
|
+
超时 → 检查 subagent 状态
|
|
194
|
+
- 完成 → 处理返回
|
|
195
|
+
- 未完成 → 标记 BLOCKED,走重试/换模型/拆任务
|
|
196
|
+
- 丢失 → 标记 ESCALATE,重规划
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## 输出
|
|
200
|
+
|
|
201
|
+
- `<doc_dir>/task-<N>-brief.md`(派发前渲染)
|
|
202
|
+
- `<doc_dir>/task-<N>-report.md`(subagent 写入)
|
|
203
|
+
- Ledger 中 `T<N>: base=` / 状态行
|
|
204
|
+
- 触发下一步:status=DONE/DONE_WITH_CONCERNS → 生成 review package → todo-review
|
|
205
|
+
|
|
206
|
+
## 约束
|
|
207
|
+
|
|
208
|
+
- prompt 必须自包含:所有占位符展开为绝对路径
|
|
209
|
+
- 禁止:粘贴计划全文到 prompt、粘贴之前任务摘要到后续 prompt、让 subagent 读整个计划文件
|
|
210
|
+
- 串行硬规则:下一个可写任务必须在上一任务 review close 后才派发,base = 上一任务 HEAD
|
|
211
|
+
- 只派发与处理返回,不审查、不 fix、不改源码
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: todo-finalize
|
|
3
|
+
description: 收尾阶段:全分支 Final Review + 最终验收 + 综合交付(整合产物 + 裁决清单 + 归档)。所有任务 review close 后加载。
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
workflow: sequential
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# todo-finalize 技能
|
|
10
|
+
|
|
11
|
+
## 输入
|
|
12
|
+
|
|
13
|
+
| 字段 | 说明 |
|
|
14
|
+
|------|------|
|
|
15
|
+
| `target` | 用户目标(验收标准) |
|
|
16
|
+
| `root_dir` | 工程根目录 |
|
|
17
|
+
| `doc_dir` | 本次 run 产物目录 |
|
|
18
|
+
| `initial_base` | 本次运行最初的 base |
|
|
19
|
+
| Ledger | `<doc_dir>/progress.md`,含全部进度 + rulings |
|
|
20
|
+
|
|
21
|
+
## 工作流程
|
|
22
|
+
|
|
23
|
+
### 步骤 1:Final Review
|
|
24
|
+
|
|
25
|
+
#### 1a:生成全分支 review package
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
merge_base=<initial_base> # 本次运行最初的 base
|
|
29
|
+
final_diff="<doc_dir>/final-review-<merge_base7>..<head7>.diff"
|
|
30
|
+
git log --oneline <merge_base>..HEAD > "$final_diff"
|
|
31
|
+
echo "" >> "$final_diff"
|
|
32
|
+
git diff --stat <merge_base>..HEAD >> "$final_diff"
|
|
33
|
+
echo "" >> "$final_diff"
|
|
34
|
+
git diff -U10 <merge_base>..HEAD >> "$final_diff"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
#### 1b:派发 final reviewer(串行:全分支一个 reviewer)
|
|
38
|
+
|
|
39
|
+
用 `task` 工具派发,`subagent_type: "general"`,`background: true`。
|
|
40
|
+
|
|
41
|
+
#### Final reviewer prompt 模板
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
你是最终审查 subagent,审查整个分支的全部改动。这是全分支审查,不是单任务审查。
|
|
45
|
+
|
|
46
|
+
## What Was Requested
|
|
47
|
+
Target: <target>
|
|
48
|
+
|
|
49
|
+
## Diff Under Review
|
|
50
|
+
Base: <merge_base>
|
|
51
|
+
Head: <HEAD>
|
|
52
|
+
Diff file: <final_diff>
|
|
53
|
+
|
|
54
|
+
Read the diff file once. Do not re-run git commands. Do not crawl the broader codebase.
|
|
55
|
+
|
|
56
|
+
## Ledger
|
|
57
|
+
Read the ledger for context on parked findings and rulings: <doc_dir>/progress.md
|
|
58
|
+
|
|
59
|
+
## Your Job
|
|
60
|
+
1. Review the full branch diff for correctness, completeness, and quality
|
|
61
|
+
2. Triage parked findings and deferred minors: which must be fixed before delivery?
|
|
62
|
+
3. Check cross-task interactions and integration issues
|
|
63
|
+
|
|
64
|
+
## You Do Not Dispatch Subagents
|
|
65
|
+
## Read-only review. Do not mutate the working tree, index, HEAD, or branch.
|
|
66
|
+
|
|
67
|
+
## Output
|
|
68
|
+
Write your review to <doc_dir>/final-review.md:
|
|
69
|
+
|
|
70
|
+
### Branch Review
|
|
71
|
+
- Overall assessment of the complete change
|
|
72
|
+
|
|
73
|
+
### Parked/Deferred Triage
|
|
74
|
+
For each parked/deferred item from the ledger: must fix before delivery | safe to defer
|
|
75
|
+
|
|
76
|
+
### Issues
|
|
77
|
+
#### Critical (Must Fix)
|
|
78
|
+
#### Important (Should Fix)
|
|
79
|
+
#### Minor (Nice to Have)
|
|
80
|
+
|
|
81
|
+
### Assessment
|
|
82
|
+
**Branch quality:** Approved | Needs fixes
|
|
83
|
+
**Reasoning:** [1-2 sentences]
|
|
84
|
+
|
|
85
|
+
Then report back with ONLY (≤15 lines):
|
|
86
|
+
- Verdict: Approved | Needs fixes
|
|
87
|
+
- Finding count (Critical/Important/Minor)
|
|
88
|
+
- One-line summary
|
|
89
|
+
- Review file path
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### 1c:处理 final review 结论
|
|
93
|
+
|
|
94
|
+
| 结论 | 动作 |
|
|
95
|
+
|------|------|
|
|
96
|
+
| Approved | 进入步骤 2 |
|
|
97
|
+
| Needs fixes | 一次 fix dispatch + 一次 scoped re-review |
|
|
98
|
+
|
|
99
|
+
#### 1d:Final fix(如有 findings)
|
|
100
|
+
|
|
101
|
+
只做**一次** fix dispatch(不是 per-finding)+ **一次** scoped re-review。
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
final_review_head=<HEAD at final review time>
|
|
105
|
+
fix_base=$final_review_head
|
|
106
|
+
# 派发 fix implementer(general, background=true)
|
|
107
|
+
# 生成 scoped diff: <doc_dir>/final-fix-review-<fix_base7>..<head7>.diff
|
|
108
|
+
# 派发 scoped re-reviewer(general, background=true)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
残留 load-bearing findings → 报告用户(这是唯一需要用户参与的情况)。
|
|
112
|
+
|
|
113
|
+
### 步骤 2:最终 target 验收(MUST 派 subagent 执行)
|
|
114
|
+
|
|
115
|
+
**MUST**:验收运行(跑测试 / 构建 / 执行 verify 命令)一律由 subagent 执行——这属于「跑测试」,主 agent 不亲自跑。
|
|
116
|
+
|
|
117
|
+
用 `task` 派发一个只读 verification subagent(`subagent_type: "general"`,`background=true`;单个,全 target 一个验证者,验收通常是整体命令,不并行):
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
你是只读验证 subagent,执行最终 target 级整体验收。
|
|
121
|
+
|
|
122
|
+
## Target
|
|
123
|
+
<target>
|
|
124
|
+
|
|
125
|
+
## Verify 命令
|
|
126
|
+
- 优先执行单一可执行验收命令
|
|
127
|
+
- 否则按 plan.md 汇总各任务 verify 命令,逐个执行
|
|
128
|
+
|
|
129
|
+
## Constraints
|
|
130
|
+
1. **只读**:不提交、不改写工作树/index/HEAD,只运行验证命令并记录结果
|
|
131
|
+
2. **不派发 subagent**:你的工作不嵌套
|
|
132
|
+
3. **工具调用上限**:最多 <N> 次,到限停止
|
|
133
|
+
|
|
134
|
+
## Report
|
|
135
|
+
把验收结果写入 <doc_dir>/final-verification.md:
|
|
136
|
+
- 每个 verify 命令的输出摘要(pass/fail + 关键行)
|
|
137
|
+
- 逐条对照 target 的验收结论
|
|
138
|
+
- 阻塞或顾虑
|
|
139
|
+
|
|
140
|
+
Then report back with ONLY (≤10 lines):
|
|
141
|
+
- Verdict: PASS | FAIL | BLOCKED
|
|
142
|
+
- 一行结论
|
|
143
|
+
- 报告文件路径
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
主 agent 读 `<doc_dir>/final-verification.md`,把结论写入 `final-review.md` 的「整体验收结果」段。
|
|
147
|
+
|
|
148
|
+
退出判据(三者缺一不可):
|
|
149
|
+
1. 所有任务 done + review 通过
|
|
150
|
+
2. final review 通过(或残留已报告用户)
|
|
151
|
+
3. 整体验收 PASS
|
|
152
|
+
|
|
153
|
+
### 步骤 3:综合交付
|
|
154
|
+
|
|
155
|
+
#### 3a:整合产物
|
|
156
|
+
|
|
157
|
+
收集提交历史 + diff 路径 + final-review 摘要:
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
提交历史: <initial_base7>..<head7>
|
|
161
|
+
全分支 diff: <doc_dir>/final-review-<merge_base7>..<head7>.diff
|
|
162
|
+
Final review: <doc_dir>/final-review.md
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
#### 3b:裁决清单
|
|
166
|
+
|
|
167
|
+
从 Ledger 收集全部 rulings,按发生顺序列出,每条附理由和代价:
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
## Rulings I made
|
|
171
|
+
|
|
172
|
+
1. Ruling: <决定> — <原因> — <错了的代价>
|
|
173
|
+
2. Ruling: <决定> — <原因> — <错了的代价>
|
|
174
|
+
...
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**这是用户审阅 agent 决策的唯一入口**——用户看到完整清单,可以逐条否决。
|
|
178
|
+
|
|
179
|
+
#### 3c:向用户输出
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
全部 N 个任务完成,最终审查通过。
|
|
183
|
+
|
|
184
|
+
提交历史: <initial_base7>..<head7>
|
|
185
|
+
分支: <branch>
|
|
186
|
+
diff: <doc_dir>/final-review-<merge_base7>..<head7>.diff
|
|
187
|
+
|
|
188
|
+
## Rulings I made
|
|
189
|
+
<裁决清单>
|
|
190
|
+
|
|
191
|
+
## 残留问题(如有)
|
|
192
|
+
<load-bearing findings that need user attention>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### 3d:归档
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# 保留关键产物到归档目录
|
|
199
|
+
archive="<root_dir>/.webwork/todo/archive/<run_id>/"
|
|
200
|
+
mkdir -p "$archive"
|
|
201
|
+
cp <doc_dir>/plan.md "$archive/"
|
|
202
|
+
cp <doc_dir>/progress.md "$archive/"
|
|
203
|
+
cp <doc_dir>/task-*-report.md "$archive/" 2>/dev/null
|
|
204
|
+
cp <doc_dir>/task-*-review.md "$archive/" 2>/dev/null
|
|
205
|
+
cp <doc_dir>/final-review.md "$archive/" 2>/dev/null
|
|
206
|
+
cp <doc_dir>/final-verification.md "$archive/" 2>/dev/null
|
|
207
|
+
cp <doc_dir>/final-fix-report.md "$archive/" 2>/dev/null
|
|
208
|
+
|
|
209
|
+
# 删除临时文件(brief、主 review diff、rereview、final diff)
|
|
210
|
+
rm -f <doc_dir>/task-*-brief.md
|
|
211
|
+
rm -f <doc_dir>/task-*-review-*.diff
|
|
212
|
+
rm -f <doc_dir>/task-*-rereview-*.md
|
|
213
|
+
rm -f <doc_dir>/task-*-rereview-*.diff
|
|
214
|
+
rm -f <doc_dir>/final-review-*.diff
|
|
215
|
+
rm -f <doc_dir>/final-fix-review-*.diff
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
默认保留归档;用户显式要求清理时才删除。
|
|
219
|
+
|
|
220
|
+
## 输出
|
|
221
|
+
|
|
222
|
+
- `<doc_dir>/final-review.md`(含整体验收结果段)
|
|
223
|
+
- `<doc_dir>/final-verification.md`(最终验收报告)
|
|
224
|
+
- `<doc_dir>/final-fix-report.md`(若有 findings)
|
|
225
|
+
- `<doc_dir>/final-fix-review-*.diff`(若 scoped re-review)
|
|
226
|
+
- 向用户输出的结果摘要 + 全部裁决清单
|
|
227
|
+
- 归档目录 `<root_dir>/.webwork/todo/archive/<run_id>/`
|
|
228
|
+
|
|
229
|
+
## 约束
|
|
230
|
+
|
|
231
|
+
- final reviewer 最多 30 次工具调用,到限必须停止
|
|
232
|
+
- final reviewer 写操作白名单 = 仅 `<doc_dir>/final-review.md`
|
|
233
|
+
- final reviewer 不重跑测试
|
|
234
|
+
- 有 findings 时只做一次 fix dispatch + 一次 scoped re-review,无第二次
|
|
235
|
+
- 最终 target 验收运行强制,且**必须派只读 subagent 执行**(主 agent 不亲自跑测试),三者缺一不可
|
|
236
|
+
- 不 push / 不 merge——交付即当前分支上的提交串,推送由用户决定
|
|
237
|
+
- 裁决清单必须显式列出,不随归档消失
|
|
238
|
+
- 归档即终止本 run
|