@fitlab-ai/agent-infra 0.7.6 → 0.8.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 (173) hide show
  1. package/README.md +2 -0
  2. package/README.zh-CN.md +2 -0
  3. package/bin/cli.ts +53 -18
  4. package/dist/bin/cli.js +56 -19
  5. package/dist/lib/decide.js +110 -0
  6. package/dist/lib/run/host.js +39 -0
  7. package/dist/lib/run/index.js +102 -0
  8. package/dist/lib/run/prompt.js +2 -0
  9. package/dist/lib/run/skills.js +29 -0
  10. package/dist/lib/run/tui.js +35 -0
  11. package/dist/lib/sandbox/capture.js +49 -0
  12. package/dist/lib/sandbox/commands/create.js +55 -6
  13. package/dist/lib/sandbox/commands/ls.js +4 -33
  14. package/dist/lib/sandbox/commands/show.js +67 -0
  15. package/dist/lib/sandbox/index.js +7 -0
  16. package/dist/lib/server/adapters/_contract.js +9 -0
  17. package/dist/lib/server/adapters/feishu/index.js +40 -0
  18. package/dist/lib/server/adapters/feishu/transport.js +95 -0
  19. package/dist/lib/server/auth.js +19 -0
  20. package/dist/lib/server/config.js +183 -0
  21. package/dist/lib/server/daemon.js +96 -0
  22. package/dist/lib/server/index.js +47 -0
  23. package/dist/lib/server/logger.js +34 -0
  24. package/dist/lib/server/plugin-loader.js +73 -0
  25. package/dist/lib/server/process-control.js +200 -0
  26. package/dist/lib/server/protocol.js +69 -0
  27. package/dist/lib/server/redact.js +12 -0
  28. package/dist/lib/server/runner.js +75 -0
  29. package/dist/lib/server/streamer.js +44 -0
  30. package/dist/lib/task/commands/decisions.js +258 -0
  31. package/dist/lib/task/commands/issue-body.js +94 -0
  32. package/dist/lib/task/commands/log.js +67 -9
  33. package/dist/lib/task/index.js +17 -0
  34. package/dist/lib/task/issue-form.js +66 -0
  35. package/dist/lib/task/ledger.js +66 -0
  36. package/dist/lib/task/sections.js +73 -0
  37. package/lib/decide.ts +124 -0
  38. package/lib/run/host.ts +47 -0
  39. package/lib/run/index.ts +124 -0
  40. package/lib/run/prompt.ts +1 -0
  41. package/lib/run/skills.ts +34 -0
  42. package/lib/run/tui.ts +40 -0
  43. package/lib/sandbox/capture.ts +84 -0
  44. package/lib/sandbox/commands/create.ts +61 -9
  45. package/lib/sandbox/commands/ls.ts +4 -36
  46. package/lib/sandbox/commands/show.ts +80 -0
  47. package/lib/sandbox/index.ts +7 -0
  48. package/lib/server/adapters/_contract.ts +42 -0
  49. package/lib/server/adapters/feishu/index.ts +47 -0
  50. package/lib/server/adapters/feishu/transport.ts +128 -0
  51. package/lib/server/auth.ts +28 -0
  52. package/lib/server/config.ts +228 -0
  53. package/lib/server/daemon.ts +110 -0
  54. package/lib/server/index.ts +50 -0
  55. package/lib/server/logger.ts +48 -0
  56. package/lib/server/plugin-loader.ts +84 -0
  57. package/lib/server/process-control.ts +225 -0
  58. package/lib/server/protocol.ts +79 -0
  59. package/lib/server/redact.ts +12 -0
  60. package/lib/server/runner.ts +95 -0
  61. package/lib/server/server.schema.json +127 -0
  62. package/lib/server/streamer.ts +57 -0
  63. package/lib/task/commands/decisions.ts +272 -0
  64. package/lib/task/commands/issue-body.ts +102 -0
  65. package/lib/task/commands/log.ts +73 -9
  66. package/lib/task/index.ts +17 -0
  67. package/lib/task/issue-form.ts +77 -0
  68. package/lib/task/ledger.ts +73 -0
  69. package/lib/task/sections.ts +73 -0
  70. package/package.json +9 -4
  71. package/templates/.agents/QUICKSTART.zh-CN.md +2 -2
  72. package/templates/.agents/README.en.md +3 -1
  73. package/templates/.agents/README.zh-CN.md +3 -1
  74. package/templates/.agents/rules/create-issue.github.en.md +20 -29
  75. package/templates/.agents/rules/create-issue.github.zh-CN.md +20 -29
  76. package/templates/.agents/rules/issue-fields.github.en.md +1 -1
  77. package/templates/.agents/rules/issue-fields.github.zh-CN.md +1 -1
  78. package/templates/.agents/rules/issue-pr-commands.github.en.md +6 -0
  79. package/templates/.agents/rules/issue-pr-commands.github.zh-CN.md +6 -0
  80. package/templates/.agents/rules/next-step-output.en.md +30 -1
  81. package/templates/.agents/rules/next-step-output.zh-CN.md +30 -1
  82. package/templates/.agents/rules/no-mid-flow-questions.en.md +7 -2
  83. package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +7 -2
  84. package/templates/.agents/rules/review-handshake.en.md +5 -1
  85. package/templates/.agents/rules/review-handshake.zh-CN.md +5 -1
  86. package/templates/.agents/rules/task-management.en.md +3 -1
  87. package/templates/.agents/rules/task-management.zh-CN.md +3 -1
  88. package/templates/.agents/scripts/lib/post-review-commit.js +15 -18
  89. package/templates/.agents/scripts/validate-artifact.js +8 -0
  90. package/templates/.agents/skills/analyze-task/SKILL.en.md +18 -4
  91. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +18 -4
  92. package/templates/.agents/skills/analyze-task/config/verify.en.json +2 -1
  93. package/templates/.agents/skills/analyze-task/config/verify.zh-CN.json +2 -1
  94. package/templates/.agents/skills/archive-tasks/SKILL.en.md +3 -1
  95. package/templates/.agents/skills/archive-tasks/SKILL.zh-CN.md +3 -1
  96. package/templates/.agents/skills/block-task/SKILL.en.md +3 -1
  97. package/templates/.agents/skills/block-task/SKILL.zh-CN.md +3 -1
  98. package/templates/.agents/skills/cancel-task/SKILL.en.md +3 -1
  99. package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +3 -1
  100. package/templates/.agents/skills/check-task/SKILL.en.md +30 -81
  101. package/templates/.agents/skills/check-task/SKILL.zh-CN.md +30 -80
  102. package/templates/.agents/skills/close-codescan/SKILL.en.md +3 -1
  103. package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +3 -1
  104. package/templates/.agents/skills/close-dependabot/SKILL.en.md +3 -1
  105. package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +3 -1
  106. package/templates/.agents/skills/code-task/SKILL.en.md +4 -2
  107. package/templates/.agents/skills/code-task/SKILL.zh-CN.md +4 -2
  108. package/templates/.agents/skills/code-task/reference/dual-mode.en.md +7 -2
  109. package/templates/.agents/skills/code-task/reference/dual-mode.zh-CN.md +7 -2
  110. package/templates/.agents/skills/code-task/scripts/detect-mode.js +6 -14
  111. package/templates/.agents/skills/commit/SKILL.en.md +27 -5
  112. package/templates/.agents/skills/commit/SKILL.zh-CN.md +27 -5
  113. package/templates/.agents/skills/complete-task/SKILL.en.md +4 -1
  114. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +4 -1
  115. package/templates/.agents/skills/complete-task/config/verify.en.json +2 -1
  116. package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +2 -1
  117. package/templates/.agents/skills/create-pr/SKILL.en.md +3 -1
  118. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +3 -1
  119. package/templates/.agents/skills/create-release-note/SKILL.en.md +3 -1
  120. package/templates/.agents/skills/create-release-note/SKILL.zh-CN.md +3 -1
  121. package/templates/.agents/skills/create-task/SKILL.en.md +4 -4
  122. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +4 -4
  123. package/templates/.agents/skills/import-codescan/SKILL.en.md +3 -4
  124. package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +3 -4
  125. package/templates/.agents/skills/import-dependabot/SKILL.en.md +3 -2
  126. package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +3 -2
  127. package/templates/.agents/skills/import-issue/SKILL.en.md +20 -4
  128. package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +20 -4
  129. package/templates/.agents/skills/init-labels/SKILL.en.md +3 -1
  130. package/templates/.agents/skills/init-labels/SKILL.zh-CN.md +3 -1
  131. package/templates/.agents/skills/init-milestones/SKILL.en.md +3 -1
  132. package/templates/.agents/skills/init-milestones/SKILL.zh-CN.md +3 -1
  133. package/templates/.agents/skills/plan-task/SKILL.en.md +4 -3
  134. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +4 -3
  135. package/templates/.agents/skills/post-release/SKILL.en.md +3 -1
  136. package/templates/.agents/skills/post-release/SKILL.zh-CN.md +3 -1
  137. package/templates/.agents/skills/refine-title/SKILL.en.md +3 -1
  138. package/templates/.agents/skills/refine-title/SKILL.zh-CN.md +3 -1
  139. package/templates/.agents/skills/release/SKILL.en.md +3 -1
  140. package/templates/.agents/skills/release/SKILL.zh-CN.md +3 -1
  141. package/templates/.agents/skills/restore-task/SKILL.en.md +3 -1
  142. package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +3 -1
  143. package/templates/.agents/skills/review-analysis/SKILL.en.md +6 -2
  144. package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +6 -2
  145. package/templates/.agents/skills/review-analysis/reference/output-templates.en.md +1 -1
  146. package/templates/.agents/skills/review-analysis/reference/output-templates.zh-CN.md +1 -1
  147. package/templates/.agents/skills/review-analysis/reference/report-template.en.md +1 -1
  148. package/templates/.agents/skills/review-analysis/reference/report-template.zh-CN.md +1 -2
  149. package/templates/.agents/skills/review-code/SKILL.en.md +5 -2
  150. package/templates/.agents/skills/review-code/SKILL.zh-CN.md +5 -2
  151. package/templates/.agents/skills/review-code/reference/output-templates.en.md +1 -1
  152. package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +1 -1
  153. package/templates/.agents/skills/review-code/reference/report-template.en.md +1 -1
  154. package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +1 -2
  155. package/templates/.agents/skills/review-plan/SKILL.en.md +6 -2
  156. package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +6 -2
  157. package/templates/.agents/skills/review-plan/reference/output-templates.en.md +1 -1
  158. package/templates/.agents/skills/review-plan/reference/output-templates.zh-CN.md +1 -1
  159. package/templates/.agents/skills/review-plan/reference/report-template.en.md +1 -1
  160. package/templates/.agents/skills/review-plan/reference/report-template.zh-CN.md +1 -2
  161. package/templates/.agents/skills/test/SKILL.en.md +3 -1
  162. package/templates/.agents/skills/test/SKILL.zh-CN.md +1 -1
  163. package/templates/.agents/skills/test-integration/SKILL.en.md +3 -1
  164. package/templates/.agents/skills/test-integration/SKILL.zh-CN.md +3 -1
  165. package/templates/.agents/skills/update-agent-infra/SKILL.en.md +3 -1
  166. package/templates/.agents/skills/update-agent-infra/SKILL.zh-CN.md +3 -1
  167. package/templates/.agents/skills/upgrade-dependency/SKILL.en.md +3 -1
  168. package/templates/.agents/skills/upgrade-dependency/SKILL.zh-CN.md +3 -1
  169. package/templates/.agents/skills/watch-pr/SKILL.en.md +3 -1
  170. package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +3 -1
  171. package/templates/.agents/templates/task.en.md +3 -3
  172. package/templates/.agents/templates/task.zh-CN.md +3 -3
  173. package/templates/.github/workflows/metadata-sync.yml +0 -18
@@ -22,11 +22,11 @@
22
22
 
23
23
  从 `task.md` 提取以下字段:
24
24
 
25
- - 任务标题(首个 `# ` 标题,去掉 `任务:` / `Task:` 前缀)
26
- - `## Description` / `## 描述` 段落
27
- - `## Requirements` / `## 需求` 段落
25
+ - 任务标题(首个 `# ` 标题,去掉 `任务:` / `Task:` 前缀)—— 用于构造 Issue 标题
28
26
  - frontmatter 中的 `type` 与(可选的)`milestone`
29
27
 
28
+ > Issue **正文**不在此处手工提取。正文由 §3 调用 `ai task issue-body` 命令从 `## 描述` / `## 需求` 段确定性生成,调用方不得自行拼装。
29
+
30
30
  构造 Issue 标题:
31
31
 
32
32
  | task.md `type` | Conventional Commits type |
@@ -41,45 +41,35 @@ scope 推断:从 `.agents/.airc.json` 的 `labels.in` 字段读取已知模块
41
41
 
42
42
  ### 3. 构建 Issue 正文
43
43
 
44
+ > **机械化边界(必须遵守)**:Issue 正文一律由 `ai task issue-body` 命令确定性生成;调用方只把命令 stdout 作为 `gh issue create` 的 `--body-file` 传入,**不得**自行拼装、改写或截断正文。命令只输出 task 标题 / `## 描述` / `## 需求` 对应内容,task.md 其余脚手架段落永不进入 body。
45
+
44
46
  Issue 模板检测:按 `.agents/rules/issue-pr-commands.md` 的 "Issue 模板检测" 规则扫描 `.github/ISSUE_TEMPLATE/*.yml`(排除 `config.yml`)。
45
47
 
46
48
  #### 场景 A:检测到匹配模板
47
49
 
48
50
  按模板顶层 `name` 与任务类型挑选最匹配的 form(如任务 `type: bugfix` 优先选名称含 `bug` 的模板);找不到匹配时,回退到通用 form(如 `other.yml`),仍找不到时取目录中第一个 form。
49
51
 
50
- `.agents/rules/issue-pr-commands.md` "Issue 模板检测" 章节的字段处理规则填充 form:
51
-
52
- - `textarea` / `input` 字段:使用 `attributes.label` 作为 markdown 标题,从 task.md 取值
53
- - `markdown` 字段:跳过(说明文案)
54
- - `dropdown` / `checkboxes` 字段:跳过
52
+ 确定模板文件 `{form-path}` 后,由命令按该 Issue Form 渲染最终正文,并写入正文文件 `{body-file}` 供 §5 使用:
55
53
 
56
- 字段值映射(建议):
57
-
58
- | 模板字段提示 | task.md 来源 |
59
- |---|---|
60
- | `summary`, `title` | 任务标题 |
61
- | `description`, `problem`, `what happened`, `issue-description`, `current-content` | 任务描述 |
62
- | `solution`, `requirements`, `steps`, `suggested-content`, `impact`, `context`, `alternatives`, `expected` | 需求列表(已勾选与未勾选混合,原样保留) |
63
- | 其它 `textarea` / `input` 字段 | 任务描述;缺失时填 `N/A` |
54
+ ```bash
55
+ ai task issue-body {task-id} --template "{form-path}" > "{body-file}"
56
+ ```
64
57
 
65
- 任何字段在 task.md 中找不到合适值时,写入 `N/A`。
58
+ 命令跳过 `markdown` / `dropdown` / `checkboxes` 字段,对 `input` / `textarea` 字段以 `attributes.label` 作标题、按字段 `id` 确定性填入 task 标题 / 描述 / 需求,无可靠映射源的字段填 `N/A`(字段映射表是命令内的单一真源,不在本规则重述)。命令退出码非 0(文件缺失 / 非法 YAML / 无 `body`)时,改用场景 B 命令重新生成 `{body-file}`。
66
59
 
67
60
  #### 场景 B:无模板或解析失败
68
61
 
69
- 回退到默认正文:
70
-
71
- ```markdown
72
- ## Description
62
+ 由命令输出默认正文(仅 `## 描述` + `## 需求`,复选框逐字保留,缺失段落填 `N/A`),写入 `{body-file}`:
73
63
 
74
- {任务描述;缺失时填 N/A}
64
+ ```bash
65
+ ai task issue-body {task-id} > "{body-file}"
66
+ ```
75
67
 
76
- ## Requirements
68
+ #### 红线:禁止把整份 task.md 当 body
77
69
 
78
- - [ ] {requirement-1}
79
- - [ ] {requirement-2}
80
- ```
70
+ 无论场景 A / B,body 只能来自 `ai task issue-body` stdout,**只含 描述 + 需求两段内容**(场景 A 为按模板字段映射后的等价内容)。
81
71
 
82
- 需求列表为空时,整段写 `N/A`。
72
+ 错误示范(❌ 禁止):把含 `## 分析` / `## 设计` / `## 实现备注` / `## 审查反馈` / `## 审查分歧账本` / `## 人工裁决` / `## 活动日志` / `## 完成检查清单` 等脚手架段落、以及 `#XXX` 占位的整份 task.md 直接作为 Issue body。这些段落只走 `sync-issue:{task-id}:task` 评论,绝不进 body。
83
73
 
84
74
  ### 4. 解析 labels / Issue Type / milestone
85
75
 
@@ -137,17 +127,18 @@ Issue 模板检测:按 `.agents/rules/issue-pr-commands.md` 的 "Issue 模板
137
127
 
138
128
  ### 5. 调用 GitHub CLI 创建 Issue
139
129
 
140
- 按 `.agents/rules/issue-pr-commands.md` 中的 "创建 Issue" 命令执行:
130
+ 按 `.agents/rules/issue-pr-commands.md` 中的 "创建 Issue" 命令执行;正文统一用 §3 生成的 `{body-file}`,覆盖通用命令的 `--body`:
141
131
 
142
132
  ```bash
143
133
  gh issue create -R "$upstream_repo" \
144
134
  --title "{title}" \
145
- --body "{body}" \
135
+ --body-file "{body-file}" \
146
136
  --assignee @me \
147
137
  {label-args} \
148
138
  {milestone-arg}
149
139
  ```
150
140
 
141
+ - `{body-file}` 为 §3 由 `ai task issue-body` 生成的正文文件;**不得**改用 `--body` 自行拼装正文
151
142
  - `{label-args}` 由 §4 计算结果展开为多个 `--label "..."`;为空则整体省略
152
143
  - `{milestone-arg}` 仅当 `has_triage=true` 且 milestone 非空时展开为 `--milestone "..."`;否则整体省略
153
144
  - `--assignee @me` 不做权限预判,失败时静默跳过
@@ -29,7 +29,7 @@ Localized option input may be normalized before writing:
29
29
  | `中` | `Medium` |
30
30
  | `低` | `Low` |
31
31
 
32
- AI agents may infer `priority` and `effort` from the title and description when creating or refining tasks, but must keep date fields empty unless the user or source Issue provides explicit dates. Human edits in `task.md` take precedence.
32
+ AI agents may infer `priority` and `effort` from the title and description when creating or refining tasks. Date fields are factual, not estimated: `start_date` is written by the analyze stage (the analysis start date) and `target_date` by the complete stage (the completion date). Human edits in `task.md` take precedence.
33
33
 
34
34
  ## GraphQL Reference
35
35
 
@@ -29,7 +29,7 @@
29
29
  | `中` | `Medium` |
30
30
  | `低` | `Low` |
31
31
 
32
- AI agent 在创建或修订任务时可根据标题与描述推断 `priority` 和 `effort`,但除非用户或来源 Issue 明确提供日期,否则必须保持日期字段为空。`task.md` 中人工填写的值优先。
32
+ AI agent 在创建或修订任务时可根据标题与描述推断 `priority` 和 `effort`。日期字段为事实值、不估算:`start_date` analyze 阶段写入(= 分析开始日),`target_date` 由 complete 阶段写入(= 完成日)。`task.md` 中人工填写的值优先。
33
33
 
34
34
  ## GraphQL 参考
35
35
 
@@ -186,6 +186,12 @@ List PRs:
186
186
  gh pr list --state {state} --base {base-branch} --json number,title,url,headRefName,baseRefName
187
187
  ```
188
188
 
189
+ Find the open PR whose head is the current branch (used by the `commit` push wrap-up):
190
+
191
+ ```bash
192
+ gh pr list --head "{branch}" --state open --json number,url --jq '.[0].url // empty'
193
+ ```
194
+
189
195
  Create a PR:
190
196
 
191
197
  ```bash
@@ -186,6 +186,12 @@ gh pr view {pr-number} --json number,title,body,labels,state,milestone,url,files
186
186
  gh pr list --state {state} --base {base-branch} --json number,title,url,headRefName,baseRefName
187
187
  ```
188
188
 
189
+ 按 head 分支查询当前分支是否存在开放 PR(`commit` 推送收尾用):
190
+
191
+ ```bash
192
+ gh pr list --head "{branch}" --state open --json number,url --jq '.[0].url // empty'
193
+ ```
194
+
189
195
  创建 PR:
190
196
 
191
197
  ```bash
@@ -1,9 +1,10 @@
1
1
  # Next-Step Output Rule
2
2
 
3
- This file defines two **independent** rules for a skill's "notify-user / Next steps" output; read this file before rendering the final output and apply both:
3
+ This file defines three **independent** rules for a skill's "notify-user / Next steps" output (the 3rd applies to review-* only); read this file before rendering the final output and apply whichever rules apply:
4
4
 
5
5
  1. **Next-step output structure**: how "Next steps" commands and the "Task info" block present the task ID (placeholders / short-id lookup / fallback).
6
6
  2. **Agent output trailing line (Completed at)**: the **very last line** of user-facing output, **independent of the "Next steps" block**, applying to normal / error / early-return paths alike.
7
+ 3. **Pending human-decision pre-block**: applies only to `review-analysis` / `review-plan` / `review-code` when this stage has pending rulings (`{h} > 0`) — expand the pending items before the "Next steps" commands and prompt to resolve them first.
7
8
 
8
9
  ## Placeholder semantics
9
10
 
@@ -60,3 +61,31 @@ Completed at: YYYY-MM-DD HH:mm:ss
60
61
  - Value command (local timezone, no offset): `date "+%Y-%m-%d %H:%M:%S"`
61
62
  - Position: it must be the last line of the entire user-facing output, after all "Next steps" commands. If a scenario has a conditional reminder line after the commands (e.g. the env-blocked reminder), the completion line goes after that reminder.
62
63
  - This line is for terminal scanning only; it is never written to any artifact file or Issue/PR comment. The single source of truth for completion time remains the Activity Log in task.md.
64
+
65
+ ## Pending human-decision pre-block (review-* only, when {h} > 0)
66
+
67
+ This section is a **third standalone rule, co-equal with the two above**, used only by the "notify-user / report conclusion" step of `review-analysis` / `review-plan` / `review-code`.
68
+
69
+ `{h}` has the same meaning as the count line in each review skill's `reference/output-templates.md`: the number of rows in task.md `## 审查分歧账本` (Review Disagreement Ledger) for **this stage** (`stage ∈ {analysis|plan|code}`) whose `status = needs-human-decision` — **pending items only, excluding rows already `human-decided`**.
70
+
71
+ - **`{h} = 0`**: do not emit this block; render "Next steps" exactly as the selected output-templates scenario.
72
+ - **`{h} > 0`**: insert the block below **before** the selected scenario's "Next steps - <stage>" commands; the next-stage commands are still listed after the block.
73
+
74
+ ```text
75
+ ⚠️ Pending human decisions ({h}) — please rule on each before continuing to the next stage:
76
+ - {ledger-id} ({stage}/{severity}): {summary}
77
+ Location: the matching row in task.md `## 审查分歧账本` · Evidence: {evidence}
78
+ …(one entry per status=needs-human-decision row of this stage in task.md `## 审查分歧账本`)
79
+
80
+ View details:
81
+ - All pending decisions: ai task decisions {task-ref}
82
+ - A single item's full background/options/impact/recommendation: ai task decisions {task-ref} <ordinal|HD-id>
83
+
84
+ To resolve:
85
+ 1. In the task.md `## 人工裁决` section, record your ruling and rationale for each item above.
86
+ 2. Flip the status of the matching row in `## 审查分歧账本` from `needs-human-decision` to `human-decided`.
87
+
88
+ Note: until all those rows are flipped to `human-decided`, running the next-stage command directly will be blocked by gates such as complete-task (`needs-human-decision` is non-terminal). The next-stage commands are still listed below for use after the decisions are made.
89
+ ```
90
+
91
+ Field values: `{ledger-id}` / `{stage}` / `{severity}` / `{evidence}` come from the same-named columns of the matching `## 审查分歧账本` row; `{summary}` comes from the artifact anchor referenced by `{evidence}` (e.g. the decision title at `plan.md#HD-1`), falling back to a one-line summary of the finding when no anchor title exists.
@@ -1,9 +1,10 @@
1
1
  # 下一步输出规则
2
2
 
3
- 本文件定义 skill「告知用户 / 下一步」输出的两类**相互独立**的规则;渲染最终输出前先读取本文件并同时落实两者:
3
+ 本文件定义 skill「告知用户 / 下一步」输出的三类**相互独立**的规则(第 3 类仅 review-* 适用);渲染最终输出前先读取本文件并落实其中适用的规则:
4
4
 
5
5
  1. **下一步输出结构**:「下一步」命令与「任务信息」段如何呈现任务 ID 形态(占位符 / 取短号 / 回退)。
6
6
  2. **Agent 输出收尾行(Completed at)**:面向用户输出的**绝对最后一行**,**独立于「下一步」块**,正常 / 错误 / 早退路径都适用。
7
+ 3. **人工裁决待办前置块**:仅 `review-analysis` / `review-plan` / `review-code`,且本阶段存在待裁决项(`{h} > 0`)时适用——在「下一步」命令前展开待裁决项并提示先完成裁决。
7
8
 
8
9
  ## 占位符语义
9
10
 
@@ -60,3 +61,31 @@ Completed at: YYYY-MM-DD HH:mm:ss
60
61
  - 取值命令(本地时区、不带偏移):`date "+%Y-%m-%d %H:%M:%S"`
61
62
  - 位置:必须是整段面向用户输出的最后一行,排在所有「下一步」命令之后。若某场景在命令之后还有条件性提醒行(如 env-blocked 提醒),收尾行排在该提醒行之后。
62
63
  - 该行只用于终端扫视,不写入任何产物文件或 Issue/PR 评论;完成时刻的单一事实源仍是 task.md 的 Activity Log。
64
+
65
+ ## 人工裁决待办前置块(review-* 专用,{h} > 0 时)
66
+
67
+ 本节是与上面两类规则**并列的第三类独立规则**,仅 `review-analysis` / `review-plan` / `review-code` 的「向用户汇报结论」步骤使用。
68
+
69
+ `{h}` 含义与各 review 技能 `reference/output-templates.md` 计数行一致:task.md `## 审查分歧账本` 中**本阶段**(`stage ∈ {analysis|plan|code}`)`status = needs-human-decision` 的行数——**只含待裁决项,不含已 `human-decided`**。
70
+
71
+ - **`{h} = 0`**:不输出本块,「下一步」按 output-templates 选定场景原样渲染。
72
+ - **`{h} > 0`**:在选定场景的「下一步 - <阶段>」命令**之前**插入下面的块;下一阶段命令仍照常列在块之后。
73
+
74
+ ```text
75
+ ⚠️ 待人工裁决({h} 项)—— 请先逐项裁决,再继续下一阶段:
76
+ - {ledger-id}({stage}/{severity}):{摘要}
77
+ 位置:task.md `## 审查分歧账本` 对应行 · 证据:{evidence}
78
+ …(task.md `## 审查分歧账本` 中本阶段每个 status=needs-human-decision 行一条)
79
+
80
+ 查看详情:
81
+ - 全部待裁决项:ai task decisions {task-ref}
82
+ - 单项完整背景/选项/影响/建议:ai task decisions {task-ref} <序号|HD-id>
83
+
84
+ 完成裁决:
85
+ 1. 在 task.md `## 人工裁决` 段,逐项记录你对上述裁决项的裁定与理由。
86
+ 2. 把 `## 审查分歧账本` 中对应行的 status 由 `needs-human-decision` 翻为 `human-decided`。
87
+
88
+ 说明:在上述行全部翻为 `human-decided` 之前,直接执行下一阶段命令会被 complete-task 等 gate 拦截(`needs-human-decision` 为非终态)。下一阶段命令仍列在下方,供裁决完成后使用。
89
+ ```
90
+
91
+ 字段取值:`{ledger-id}` / `{stage}` / `{severity}` / `{evidence}` 直接取自 `## 审查分歧账本` 对应行的同名列;`{摘要}` 取自 `{evidence}` 指向的产物锚点条目(如 `plan.md#HD-1` 的决策标题),无锚点标题时用该 finding 的一句话概述。
@@ -55,7 +55,10 @@ For every SKILL execution context not covered by any exemption above, the defaul
55
55
 
56
56
  ## Key Design Decision Marking And Ledgering
57
57
 
58
- When an open question is a key design decision that needs human judgment, the executor must mark the item with `[needs-human-decision]` and write the matching `HD-` row to task.md `## Review Disagreement Ledger` according to `.agents/rules/review-handshake.md`.
58
+ When an open question is a key design decision that needs human judgment, the executor must:
59
+
60
+ 1. Write the decision's **detail block** (background / options / impact / recommendation) into the artifact's `## 人工裁决待办` (Pending Human Decisions) section, with a heading like `### HD-N:<title> [needs-human-decision]`; ordinary assumptions / open questions still go under `## Assumptions` / `## Open Questions` (`## 假设` / `## 未决问题`), and `## Open Questions` may keep a one-line pointer to the matching `### HD-N`.
61
+ 2. Upsert the matching `HD-` row in task.md `## Review Disagreement Ledger` according to `.agents/rules/review-handshake.md`, with `evidence` pointing to the stable anchor `<artifact>#HD-N`. The `HD-N` number is **globally unique** (scan existing `HD-(\d+)` in the ledger and take max+1, monotonically increasing across analysis / plan / code, never reused); see review-handshake.md for the allocation rule.
59
62
 
60
63
  Use these checks together:
61
64
 
@@ -64,6 +67,8 @@ Use these checks together:
64
67
  - **Small-impact exemption**: if it is only a local, reversible, low-cost execution detail, record it under `## Assumptions` instead of upgrading it to a human ruling.
65
68
  - **Fallback**: when unsure whether it is key, treat it as key; `review-*` must check whether the executor missed any `[needs-human-decision]` markings that should have been upgraded.
66
69
 
70
+ > Use `ai task decisions <task-ref>` to view all pending decisions of a task and their detail blocks.
71
+
67
72
  ## Human Review Checkpoint Semantics
68
73
 
69
74
  A mandatory human review checkpoint means:
@@ -71,7 +76,7 @@ A mandatory human review checkpoint means:
71
76
  - Stop after producing the artifact: once the skill finishes an artifact such as `plan.md`, end the current invocation and wait for the user to explicitly trigger the next skill command
72
77
  - Do not pause mid-process to ask for input: do not insert interruptions such as "Do you prefer option A or B?" between execution steps
73
78
 
74
- If a key decision needs human judgment during execution, follow the assumptions and open questions rule above: record it in the artifact's "Open Questions" / `未决问题` section for the user to address at the review checkpoint.
79
+ If a key decision needs human judgment during execution, follow the "Key Design Decision Marking And Ledgering" rule above: write the detail block into the artifact's `## 人工裁决待办` (Pending Human Decisions) section as `### HD-N` and upsert the `HD-` ledger row, for the user to address at the review checkpoint; ordinary open questions still go to `## Open Questions` / `未决问题`.
75
80
 
76
81
  ## Anchor Location
77
82
 
@@ -55,7 +55,10 @@
55
55
 
56
56
  ## 关键设计决策标记与落账
57
57
 
58
- 当未决问题属于需要人工裁定的关键设计决策时,执行方必须在该条目前标记 `[needs-human-decision]`,并按 `.agents/rules/review-handshake.md` 在 task.md `## 审查分歧账本` 写入 `HD-` 行。
58
+ 当未决问题属于需要人工裁定的关键设计决策时,执行方必须:
59
+
60
+ 1. 把该决策的**详情块**(背景 / 选项 / 影响 / 推荐)写入产物的 `## 人工裁决待办` 段,标题形如 `### HD-N:<标题> [needs-human-decision]`;普通假设 / 未决问题仍分别写 `## 假设` / `## 未决问题`(`## Assumptions` / `## Open Questions`),`## 未决问题` 可保留一行指针指向对应 `### HD-N`。
61
+ 2. 按 `.agents/rules/review-handshake.md` 在 task.md `## 审查分歧账本` upsert 对应 `HD-` 行,evidence 指向稳定锚点 `<artifact>#HD-N`。`HD-N` 编号**全局唯一**(扫描账本已有 `HD-(\d+)` 取 max+1,跨 analysis / plan / code 单调递增、禁止复用),分配规则详见 review-handshake.md。
59
62
 
60
63
  判定时同时使用以下检查:
61
64
 
@@ -64,6 +67,8 @@
64
67
  - **小影响豁免**:若它只是局部、可逆、低成本的执行细节,写入 `## 假设` 即可,不升级为人工裁决。
65
68
  - **兜底**:无法判断是否关键时按关键处理;`review-*` 需要复核执行方是否漏标应升级的 `[needs-human-decision]`。
66
69
 
70
+ > 用户可用 `ai task decisions <task-ref>` 查看某任务全部待裁决项及其详情块。
71
+
67
72
  ## 人工审查检查点语义
68
73
 
69
74
  「强制性人工审查检查点」(mandatory human review checkpoint)的语义是:
@@ -71,7 +76,7 @@
71
76
  - **产出后停止**:技能完成产物(如 `plan.md`)后立即结束本轮调用,等待用户主动触发下一个技能命令
72
77
  - **不是过程中暂停征求意见**:不允许在执行步骤之间插入「请问您倾向 A 还是 B?」之类的中断
73
78
 
74
- 如果在执行过程中发现需要用户裁定的关键决策,按上文「假设与未决问题」处理,记录到产物的「未决问题」/`Open Questions` 段落,由用户在审查检查点统一回应。
79
+ 如果在执行过程中发现需要用户裁定的关键决策,按上文「关键设计决策标记与落账」处理:详情块写入产物 `## 人工裁决待办` 的 `### HD-N`、回写 `HD-` 账本行,由用户在审查检查点统一回应;普通未决问题仍写 `## 未决问题` / `Open Questions`。
75
80
 
76
81
  ## 锚点位置
77
82
 
@@ -67,18 +67,22 @@ The single source of truth for disagreement state is the fixed `## 审查分歧
67
67
 
68
68
  ### Executor-raised human-ruling rows
69
69
 
70
- When an executor marks an item in the artifact `## Open Questions` section as `[needs-human-decision]`, it must upsert the matching `HD-` row in task.md `## Review Disagreement Ledger`:
70
+ When an executor judges an item to be a key design decision that needs human ruling, it must write the detail block (background / options / impact / recommendation) into the artifact's `## 人工裁决待办` (Pending Human Decisions) section with a heading like `### HD-N:<title> [needs-human-decision]`, and upsert the matching `HD-` row in task.md `## Review Disagreement Ledger`:
71
71
 
72
72
  ```markdown
73
73
  | HD-1 | plan | - | decision | needs-human-decision | plan.md#HD-1 |
74
74
  ```
75
75
 
76
+ - `id`: the `HD-N` number is **globally unique**. When adding a row, scan every `HD-(\d+)` in the ledger and take max+1 (start at `HD-1` when none exist); it increases monotonically across `analysis` / `plan` / `code` and is **never reused**, so selecting by `HD-id` is unambiguous.
76
77
  - `stage` is the stage where the decision arose: `analysis` / `plan` / `code`.
77
78
  - `round` is `-` because this is not a review-finding handshake round.
78
79
  - `severity` is always `decision`.
79
80
  - `status` starts as `needs-human-decision`, so the existing gate blocks it.
81
+ - `evidence` points to the stable anchor `<artifact>#HD-N` (e.g. `plan-r2.md#HD-1`), not a drift-prone line number.
80
82
  - After a human records the ruling in task.md `## Human Rulings`, flip the matching `HD-` row to `human-decided` and point `evidence` to that ruling.
81
83
 
84
+ > View: `ai task decisions <task-ref>` lists all pending decisions; `ai task decisions <task-ref> <ordinal|HD-id>` expands a single item's detail block. This command shares the ledger parser `lib/task/ledger.ts` with `ai task log`; the gate parser in `.agents/scripts/validate-artifact.js` is a separate implementation and the two must be kept semantically in sync by hand.
85
+
82
86
  ## post-review commit gate (code stage only)
83
87
 
84
88
  - The highest-round `review-code` report records `Review Baseline Commit` (R, `git rev-parse HEAD`) and `Reviewed Diff Fingerprint` (F, full worktree diff fingerprint).
@@ -67,18 +67,22 @@
67
67
 
68
68
  ### 执行方自提人工裁决行
69
69
 
70
- 当执行方在产物 `## 未决问题` 中标记 `[needs-human-decision]` 时,必须在 task.md `## 审查分歧账本` upsert 对应 `HD-` 行:
70
+ 当执行方判定某项为需人工裁定的关键设计决策时,必须把详情块(背景 / 选项 / 影响 / 推荐)写入产物的 `## 人工裁决待办` 段,标题形如 `### HD-N:<标题> [needs-human-decision]`,并在 task.md `## 审查分歧账本` upsert 对应 `HD-` 行:
71
71
 
72
72
  ```markdown
73
73
  | HD-1 | plan | - | decision | needs-human-decision | plan.md#HD-1 |
74
74
  ```
75
75
 
76
+ - `id`:`HD-N` 编号**全局唯一**。新增行时扫描账本中所有 `HD-(\d+)`,取最大值 + 1(账本无 `HD-` 行则从 `HD-1` 起);跨 `analysis` / `plan` / `code` 单调递增,**禁止复用**既有编号,避免按 `HD-id` 定位时歧义。
76
77
  - `stage` 填该决策产生的阶段:`analysis` / `plan` / `code`。
77
78
  - `round` 填 `-`,因为它不是 review finding 的握手轮次。
78
79
  - `severity` 固定填 `decision`。
79
80
  - `status` 初始填 `needs-human-decision`,因此会被现有 gate 阻塞。
81
+ - `evidence` 指向稳定锚点 `<artifact>#HD-N`(如 `plan-r2.md#HD-1`),不依赖易漂移的行号。
80
82
  - 人工在 task.md `## 人工裁决` 段记录裁定后,把对应 `HD-` 行翻为 `human-decided`,`evidence` 指向该裁定记录。
81
83
 
84
+ > 查看:`ai task decisions <task-ref>` 列出全部待裁决项;`ai task decisions <task-ref> <序号|HD-id>` 展开单项详情块。该命令的账本解析与 `ai task log` 共用 `lib/task/ledger.ts`;`.agents/scripts/validate-artifact.js` 的 gate 解析器是独立实现,二者语义须手工保持同步。
85
+
82
86
  ## post-review commit 门禁(仅 code 阶段)
83
87
 
84
88
  - `review-code` 在最高轮报告中记录 `审查基线提交`(R,`git rev-parse HEAD`)和 `审查差异指纹`(F,完整工作区 diff fingerprint)。
@@ -35,7 +35,7 @@ Map user intent to the corresponding workflow command:
35
35
  - `create-pr`: update `pr_number`, `updated_at`, `agent_infra_version`
36
36
  - `commit`: update `updated_at`, `agent_infra_version`; update `current_step` when needed (see `commit/reference/task-status-update.md`)
37
37
  - `complete-task`: update `status`, `current_step`, `completed_at`, `updated_at`, `agent_infra_version`
38
- - `block-task`: update `status`, `blocked_at`, `blocked_reason`, `updated_at`, `agent_infra_version`
38
+ - `block-task`: update `status`, `blocked_at`, `updated_at`, `agent_infra_version`
39
39
  - `cancel-task`: update `status`, `cancelled_at`, `cancel_reason`, `updated_at`, `agent_infra_version`
40
40
 
41
41
  ## Activity Log started / done dual-marker convention (single source of truth)
@@ -52,6 +52,8 @@ Map user intent to the corresponding workflow command:
52
52
 
53
53
  **Pairing and rendering** (`ai task log`): a started entry pairs with the next same-`{base}` done entry onto one row (repeated executions of the same base pair FIFO by ascending time). The STARTED column shows the start time, DONE the completion time; started with no done = in progress (DONE shows `(in progress)`); done with no started (legacy logs) = a standalone completed row. All three shapes are valid and never error.
54
54
 
55
+ **Human counts** (`ai task log`): review step rows fold two human counts into the NOTE verdict text, comma-separated, right after `blockers/major/minor`, with fixed English labels `Manual-verify: {e}, Human-decision: {h}`. `Human-decision` (`{h}`) maps canonical step prefixes (`Review Analysis` / `Review Plan` / `Review Code`) to `analysis` / `plan` / `code`, then counts current rows in `## Review Disagreement Ledger` / `## 审查分歧账本` for that stage with `status ∈ {needs-human-decision, human-decided}`. `Manual-verify` (`{e}`) parses `(+ {n} env-blocked)` from the review done note (de-duplicated from the display), defaulting to `0`. Non-review rows carry no human counts.
56
+
55
57
  **Gate** (`checkActivityLog`): when computing the "latest action / freshness" it skips `[started]` lines (ascending-order and format checks still cover every line), so a started marker never satisfies a skill's `expected_action_pattern`.
56
58
 
57
59
  **Skills that write started**: every workflow skill that **appends entries to a task's `## Activity Log`** writes started, so the STARTED column stays uniformly complete across the whole `ai task log` table. Two forms, depending on whether task.md already exists:
@@ -35,7 +35,7 @@
35
35
  - `create-pr`:更新 `pr_number`、`updated_at`、`agent_infra_version`
36
36
  - `commit`:更新 `updated_at`、`agent_infra_version`;必要时更新 `current_step`(详见 `commit/reference/task-status-update.md`)
37
37
  - `complete-task`:更新 `status`、`current_step`、`completed_at`、`updated_at`、`agent_infra_version`
38
- - `block-task`:更新 `status`、`blocked_at`、`blocked_reason`、`updated_at`、`agent_infra_version`
38
+ - `block-task`:更新 `status`、`blocked_at`、`updated_at`、`agent_infra_version`
39
39
  - `cancel-task`:更新 `status`、`cancelled_at`、`cancel_reason`、`updated_at`、`agent_infra_version`
40
40
 
41
41
  ## Activity Log started / done 双标记约定(单一事实源)
@@ -56,6 +56,8 @@
56
56
 
57
57
  **配对与渲染**(`ai task log`):按 `{基名}` 把 started 与其后最近的同名 done 配成一行(同基名多次执行按时间升序 FIFO 配对)。STARTED 列显示 started 时间、DONE 列显示 done 时间;只有 started 无 done = 进行中(DONE 显示 `(in progress)`);只有 done 无 started(历史日志)= 单态完成行。三种形态都合法、不报错。
58
58
 
59
+ **人工计数**(`ai task log`):审查步骤行把两项人工计数并入 NOTE 的 verdict 文本,逗号分隔、紧随 `blockers/major/minor`,固定英文标签 `Manual-verify: {e}, Human-decision: {h}`。`Human-decision`(`{h}`)按 canonical 步骤名前缀(`Review Analysis` / `Review Plan` / `Review Code`)映射到 `analysis` / `plan` / `code`,统计 `## 审查分歧账本` 中对应阶段 `status ∈ {needs-human-decision, human-decided}` 的当前累计数量;`Manual-verify`(`{e}`)解析 review done note 中的 `(+ {n} env-blocked)`(解析后从展示中去重),缺失为 `0`。非审查步骤不附加人工计数。
60
+
59
61
  **gate**(`checkActivityLog`):计算「最新 action / freshness」时跳过 `[started]` 行(升序与格式校验仍覆盖全部行),故 started 标记不会污染各 SKILL 的 `expected_action_pattern`。
60
62
 
61
63
  **写 started 的 SKILL**:所有**会向某个任务的 `## 活动日志` 追加条目**的工作流 SKILL 都写 started,保证 `ai task log` 整张表的 STARTED 列一致完整。两种写法按技能是否已有 task.md 区分:
@@ -3,25 +3,22 @@ import path from "node:path";
3
3
 
4
4
  import { artifactName, maxRound } from "./review-artifacts.js";
5
5
 
6
- export const DEFAULT_POST_REVIEW_GLOBS = [
7
- ".agents/skills",
8
- ".agents/scripts",
9
- ".agents/rules",
10
- ".agents/workflows",
11
- "bin",
12
- "lib",
13
- "src",
14
- "templates"
15
- ];
16
-
6
+ // Paths excluded from the post-review coverage gate. Fail-closed: the gate
7
+ // covers ALL tracked changes by default. This default denylist is EMPTY —
8
+ // projects opt into exclusions explicitly via review.post_review_exclude_globs.
9
+ export const DEFAULT_POST_REVIEW_EXCLUDES = [];
10
+
11
+ // Returns git pathspecs selecting "all tracked changes except project excludes".
12
+ // The leading ":/" makes coverage fail-closed (everything from the repo root);
13
+ // each exclude becomes a top-level negative pathspec. Projects extend the
14
+ // denylist via review.post_review_exclude_globs (union, deduped).
17
15
  export function resolvePostReviewGlobs(config = {}, reviewConfig = {}) {
18
- if (Array.isArray(config.post_review_globs)) {
19
- return config.post_review_globs;
20
- }
21
- if (Array.isArray(reviewConfig.post_review_globs)) {
22
- return reviewConfig.post_review_globs;
23
- }
24
- return DEFAULT_POST_REVIEW_GLOBS;
16
+ const projectExcludes = [
17
+ ...(Array.isArray(reviewConfig.post_review_exclude_globs) ? reviewConfig.post_review_exclude_globs : []),
18
+ ...(Array.isArray(config.post_review_exclude_globs) ? config.post_review_exclude_globs : [])
19
+ ];
20
+ const excludes = [...new Set([...DEFAULT_POST_REVIEW_EXCLUDES, ...projectExcludes])];
21
+ return [":/", ...excludes.map((p) => `:(top,exclude)${p}`)];
25
22
  }
26
23
 
27
24
  export function findAuthoritativeReviewCodeArtifact(taskDir) {
@@ -316,6 +316,14 @@ function checkTaskMeta({ taskDir, config }) {
316
316
  return failResult("task-meta", "Expected cancelled_at to be present");
317
317
  }
318
318
 
319
+ if (config.require_start_date && isBlank(metadata.start_date)) {
320
+ return failResult("task-meta", "Expected start_date to be present");
321
+ }
322
+
323
+ if (config.require_target_date && isBlank(metadata.target_date)) {
324
+ return failResult("task-meta", "Expected target_date to be present");
325
+ }
326
+
319
327
  if (config.match_task_dir !== false) {
320
328
  const expectedTaskId = path.basename(taskDir);
321
329
  if (metadata.id !== expectedTaskId) {
@@ -1,6 +1,8 @@
1
1
  ---
2
2
  name: analyze-task
3
- description: "Analyze a task and produce a requirements document"
3
+ description: >
4
+ Analyze a task and produce a requirements document.
5
+ Use when you need to understand a task's requirements, scope, and risks before designing a solution.
4
6
  ---
5
7
 
6
8
  # Analyze Task
@@ -110,10 +112,10 @@ Runs after Step 0 state check and Step 3 (questioning is an external-state actio
110
112
  1. Decide this round's question (consistent with 4.2):
111
113
  - if a `pending_question` already exists (the previous question is still unanswered) → restate that `pending_question`, do **not** modify it and do **not** increment `question_count`;
112
114
  - otherwise (no pending question) → pick the single highest-value question (acceptance criteria > scope > ambiguity) and write `## Brainstorming`: `status: asking`, `pending_question: <question>`, `question_count += 1`.
113
- 2. Update frontmatter: `current_step: requirement-analysis`, `assigned_to`, `updated_at`, `agent_infra_version` (read `.agents/rules/version-stamp.md` first).
115
+ 2. Update frontmatter: `current_step: requirement-analysis`, `assigned_to`, `updated_at`, `agent_infra_version` (read `.agents/rules/version-stamp.md` first); if `start_date` is empty, also write today's date (`date +%F`) to satisfy the required `start_date` check at the requirement-analysis stage.
114
116
  3. Append to Activity Log: `- {YYYY-MM-DD HH:mm:ss±HH:MM} — **Analyze Task (Brainstorming)** by {agent} — Asked Q{question_count}, awaiting answer`.
115
117
  4. Issue sync (when `issue_number` exists, skip on any failure): read `.agents/rules/issue-sync.md` first for upstream / permission detection; update only the **task comment** per the task.md comment sync rule; keep the `status` label at `pending-design-work`; do **not** publish an analysis artifact comment.
116
- 5. Verification (replaces the step 8 artifact gate): `node .agents/scripts/validate-artifact.js check task-meta .agents/workspace/active/{task-id} --skill analyze-task --format text` (the early-exit set `current_step: requirement-analysis`, so it should pass); also keep `rg -n 'Analyze Task \(Brainstorming\)' .agents/workspace/active/{task-id}/task.md` and the task-comment sync evidence. Do **not** run the artifact gate, nor `check activity-log` / `check platform-sync` (both bind to the analysis artifact path).
118
+ 5. Verification (replaces the step 8 artifact gate): `node .agents/scripts/validate-artifact.js check task-meta .agents/workspace/active/{task-id} --skill analyze-task --format text` (the early-exit set `current_step: requirement-analysis` and wrote `start_date`, so it should pass); also keep `rg -n 'Analyze Task \(Brainstorming\)' .agents/workspace/active/{task-id}/task.md` and the task-comment sync evidence. Do **not** run the artifact gate, nor `check activity-log` / `check platform-sync` (both bind to the analysis artifact path).
117
119
  6. User output: show only the current **single question** plus how to answer/continue (re-trigger `analyze-task {task-ref}` with the answer), and append the `Completed at` line per `.agents/rules/next-step-output.md`.
118
120
  7. **STOP** and wait for the answer. The next trigger returns to this step.
119
121
 
@@ -182,10 +184,22 @@ Create `.agents/workspace/active/{task-id}/{analysis-artifact}`.
182
184
  ## Open Questions
183
185
 
184
186
  > If there are unresolved questions for human review, list them here; omit this section if there are none.
185
- > Mark key design decisions with `[needs-human-decision]` and write `HD-` ledger rows according to `.agents/rules/no-mid-flow-questions.md`.
187
+ > Ordinary open questions go here; for key design decisions (per `.agents/rules/no-mid-flow-questions.md`), put the detail block under `## 人工裁决待办` (Pending Human Decisions) as `### HD-N` instead, and keep only a one-line pointer here.
186
188
 
187
189
  - {open question}
188
190
 
191
+ ## 人工裁决待办
192
+
193
+ > Write this section only when this round upgraded a `[needs-human-decision]` key design decision; omit otherwise.
194
+ > One `### HD-N` block per item (`HD-N` is globally unique, see `.agents/rules/review-handshake.md`), and upsert the matching `HD-` row in task.md `## Review Disagreement Ledger` (evidence pointing to `{analysis-artifact}#HD-N`).
195
+
196
+ ### HD-{N}:{title} [needs-human-decision]
197
+
198
+ - **Background**: {why it became a pending decision}
199
+ - **Options**: {A / B / …}
200
+ - **Impact**: {scope / boundaries / precedent}
201
+ - **Recommendation**: {recommended option and rationale}
202
+
189
203
  ## Effort and Complexity Assessment
190
204
  - Complexity: {High/Medium/Low}
191
205
  - Risk level: {High/Medium/Low}
@@ -1,6 +1,8 @@
1
1
  ---
2
2
  name: analyze-task
3
- description: "分析任务并输出需求分析文档"
3
+ description: >
4
+ 分析任务并输出需求分析文档。
5
+ 当需要在动手设计前厘清某个任务的需求、影响范围与风险时使用。
4
6
  ---
5
7
 
6
8
  # 分析任务
@@ -109,10 +111,10 @@ tail .agents/workspace/active/{task-id}/task.md
109
111
  1. 确定本轮要问的问题(与 4.2 保持一致):
110
112
  - 若已存在 `pending_question`(上一问尚未得到答案)→ 复述该 `pending_question`,**不**修改它、**不**增加 `question_count`;
111
113
  - 否则(无待答问题)→ 选最高价值的一个问题(验收标准 > 范围 > 歧义),写入 `## Brainstorming`:`status: asking`、`pending_question: <问题>`、`question_count += 1`。
112
- 2. 更新 frontmatter:`current_step: requirement-analysis`、`assigned_to`、`updated_at`、`agent_infra_version`(先读 `.agents/rules/version-stamp.md`)。
114
+ 2. 更新 frontmatter:`current_step: requirement-analysis`、`assigned_to`、`updated_at`、`agent_infra_version`(先读 `.agents/rules/version-stamp.md`);若 `start_date` 为空,同时写入当日日期(`date +%F`),以满足 requirement-analysis 阶段 `start_date` 必填校验。
113
115
  3. 追加 Activity Log:`- {YYYY-MM-DD HH:mm:ss±HH:MM} — **Analyze Task (Brainstorming)** by {agent} — Asked Q{question_count}, awaiting answer`。
114
116
  4. Issue 同步(存在 `issue_number` 时,任一失败跳过):先读 `.agents/rules/issue-sync.md` 完成 upstream / 权限检测;仅按 task.md 评论同步规则更新 **task 评论**;`status` label 维持 `pending-design-work`;**不**发布分析产物评论。
115
- 5. 校验(替代步骤 8 的 artifact gate):`node .agents/scripts/validate-artifact.js check task-meta .agents/workspace/active/{task-id} --skill analyze-task --format text`(早退已置 `current_step: requirement-analysis`,预期通过);并保留 `rg -n 'Analyze Task \(Brainstorming\)' .agents/workspace/active/{task-id}/task.md` 与 task 评论同步证据。**不**跑 artifact gate,也不跑 `check activity-log` / `check platform-sync`(二者绑定分析产物路径)。
117
+ 5. 校验(替代步骤 8 的 artifact gate):`node .agents/scripts/validate-artifact.js check task-meta .agents/workspace/active/{task-id} --skill analyze-task --format text`(早退已置 `current_step: requirement-analysis` 且已写入 `start_date`,预期通过);并保留 `rg -n 'Analyze Task \(Brainstorming\)' .agents/workspace/active/{task-id}/task.md` 与 task 评论同步证据。**不**跑 artifact gate,也不跑 `check activity-log` / `check platform-sync`(二者绑定分析产物路径)。
116
118
  6. 用户输出:只展示当前**单个问题** + 如何回答/继续(再次触发 `analyze-task {task-ref}` 并附答案),并按 `.agents/rules/next-step-output.md` 在末行追加 `Completed at`。
117
119
  7. **STOP**,等待回答。下一次触发回到本步骤。
118
120
 
@@ -181,10 +183,22 @@ tail .agents/workspace/active/{task-id}/task.md
181
183
  ## 未决问题
182
184
 
183
185
  > 如有需要人工裁定的未决问题,列在此处;没有则可省略本段。
184
- > 关键设计决策按 `.agents/rules/no-mid-flow-questions.md` 的判据标记 `[needs-human-decision]` 并回写 `HD-` 账本行。
186
+ > 普通未决问题列在本段;属关键设计决策的(按 `.agents/rules/no-mid-flow-questions.md` 判据),详情块改写入下方 `## 人工裁决待办` 的 `### HD-N`,本段仅保留一行指针。
185
187
 
186
188
  - {未决问题}
187
189
 
190
+ ## 人工裁决待办
191
+
192
+ > 仅当本轮升级了 `[needs-human-decision]` 关键设计决策时写本段;没有则省略。
193
+ > 每项一个 `### HD-N` 块(`HD-N` 全局唯一,见 `.agents/rules/review-handshake.md`),并在 task.md `## 审查分歧账本` upsert 对应 `HD-` 行(evidence 指向 `{analysis-artifact}#HD-N`)。
194
+
195
+ ### HD-{N}:{标题} [needs-human-decision]
196
+
197
+ - **背景**:{为何成为待裁决项}
198
+ - **选项**:{A / B / …}
199
+ - **影响**:{范围 / 边界 / 先例}
200
+ - **推荐**:{推荐选项及理由}
201
+
188
202
  ## 工作量和复杂度评估
189
203
  - 复杂度:{高/中/低}
190
204
  - 风险等级:{高/中/低}
@@ -13,7 +13,8 @@
13
13
  "current_step",
14
14
  "assigned_to"
15
15
  ],
16
- "expected_step": "requirement-analysis"
16
+ "expected_step": "requirement-analysis",
17
+ "require_start_date": true
17
18
  },
18
19
  "artifact": {
19
20
  "file_pattern": "analysis.md|analysis-r{N}.md",
@@ -13,7 +13,8 @@
13
13
  "current_step",
14
14
  "assigned_to"
15
15
  ],
16
- "expected_step": "requirement-analysis"
16
+ "expected_step": "requirement-analysis",
17
+ "require_start_date": true
17
18
  },
18
19
  "artifact": {
19
20
  "file_pattern": "analysis.md|analysis-r{N}.md",
@@ -1,6 +1,8 @@
1
1
  ---
2
2
  name: archive-tasks
3
- description: "Archive completed tasks into a date-organized workspace directory"
3
+ description: >
4
+ Archive completed tasks into a date-organized workspace directory.
5
+ Use when completed tasks have accumulated and you want to tidy them into the date-organized archive.
4
6
  ---
5
7
 
6
8
  # Archive Completed Tasks
@@ -1,6 +1,8 @@
1
1
  ---
2
2
  name: archive-tasks
3
- description: "归档已完成任务到按日期组织的目录"
3
+ description: >
4
+ 归档已完成任务到按日期组织的目录。
5
+ 当已完成任务在 completed 目录堆积、需要整理归档时使用。
4
6
  ---
5
7
 
6
8
  # 归档已完成任务
@@ -1,6 +1,8 @@
1
1
  ---
2
2
  name: block-task
3
- description: "Mark a task as blocked and record the reason"
3
+ description: >
4
+ Mark a task as blocked and record the reason.
5
+ Use when a task cannot proceed because of an external blocker and you need to park it with a reason.
4
6
  ---
5
7
 
6
8
  # Block Task
@@ -1,6 +1,8 @@
1
1
  ---
2
2
  name: block-task
3
- description: "标记任务为阻塞状态并记录原因"
3
+ description: >
4
+ 标记任务为阻塞状态并记录原因。
5
+ 当任务因外部阻塞无法推进、需要挂起并记录原因时使用。
4
6
  ---
5
7
 
6
8
  # 标记任务阻塞