@fitlab-ai/agent-infra 0.6.4 → 0.7.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 (193) hide show
  1. package/README.md +63 -27
  2. package/README.zh-CN.md +61 -25
  3. package/bin/cli.ts +18 -6
  4. package/dist/bin/cli.js +20 -6
  5. package/dist/lib/cp.js +127 -0
  6. package/dist/lib/defaults.json +1 -0
  7. package/dist/lib/init.js +3 -0
  8. package/dist/lib/sandbox/clipboard/bridge.js +23 -4
  9. package/dist/lib/sandbox/clipboard/index.js +12 -3
  10. package/dist/lib/sandbox/commands/create.js +11 -2
  11. package/dist/lib/sandbox/commands/enter.js +29 -6
  12. package/dist/lib/sandbox/commands/list-running.js +108 -0
  13. package/dist/lib/sandbox/commands/ls.js +24 -45
  14. package/dist/lib/sandbox/commands/rebuild.js +15 -7
  15. package/dist/lib/sandbox/config.js +3 -0
  16. package/dist/lib/sandbox/index.js +6 -4
  17. package/dist/lib/sandbox/readme-scaffold.js +148 -0
  18. package/dist/lib/sandbox/runtimes/ai-tools.dockerfile +12 -6
  19. package/dist/lib/sandbox/runtimes/base.dockerfile +3 -3
  20. package/dist/lib/sandbox/tools.js +213 -8
  21. package/dist/lib/update.js +12 -1
  22. package/lib/cp.ts +177 -0
  23. package/lib/defaults.json +1 -0
  24. package/lib/init.ts +10 -0
  25. package/lib/sandbox/clipboard/bridge.ts +23 -4
  26. package/lib/sandbox/clipboard/index.ts +12 -3
  27. package/lib/sandbox/commands/create.ts +18 -2
  28. package/lib/sandbox/commands/enter.ts +48 -6
  29. package/lib/sandbox/commands/list-running.ts +135 -0
  30. package/lib/sandbox/commands/ls.ts +28 -49
  31. package/lib/sandbox/commands/rebuild.ts +24 -7
  32. package/lib/sandbox/config.ts +7 -0
  33. package/lib/sandbox/index.ts +6 -4
  34. package/lib/sandbox/readme-scaffold.ts +177 -0
  35. package/lib/sandbox/runtimes/ai-tools.dockerfile +12 -6
  36. package/lib/sandbox/runtimes/base.dockerfile +3 -3
  37. package/lib/sandbox/tools.ts +248 -9
  38. package/lib/update.ts +15 -1
  39. package/package.json +1 -1
  40. package/templates/.agents/QUICKSTART.en.md +1 -1
  41. package/templates/.agents/QUICKSTART.zh-CN.md +1 -1
  42. package/templates/.agents/README.en.md +79 -2
  43. package/templates/.agents/README.zh-CN.md +79 -2
  44. package/templates/.agents/rules/create-issue.en.md +1 -1
  45. package/templates/.agents/rules/create-issue.github.en.md +1 -1
  46. package/templates/.agents/rules/create-issue.github.zh-CN.md +1 -1
  47. package/templates/.agents/rules/create-issue.zh-CN.md +1 -1
  48. package/templates/.agents/rules/issue-sync.github.en.md +6 -5
  49. package/templates/.agents/rules/issue-sync.github.zh-CN.md +6 -5
  50. package/templates/.agents/rules/milestone-inference.github.en.md +2 -2
  51. package/templates/.agents/rules/milestone-inference.github.zh-CN.md +2 -2
  52. package/templates/.agents/rules/no-mid-flow-questions.en.md +57 -0
  53. package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +57 -0
  54. package/templates/.agents/rules/pr-sync.github.en.md +4 -5
  55. package/templates/.agents/rules/pr-sync.github.zh-CN.md +4 -5
  56. package/templates/.agents/rules/task-management.en.md +9 -6
  57. package/templates/.agents/rules/task-management.zh-CN.md +9 -6
  58. package/templates/.agents/rules/testing-discipline.en.md +2 -2
  59. package/templates/.agents/rules/testing-discipline.zh-CN.md +2 -2
  60. package/templates/.agents/scripts/validate-artifact.js +1 -1
  61. package/templates/.agents/skills/analyze-task/SKILL.en.md +16 -4
  62. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +16 -4
  63. package/templates/.agents/skills/check-task/SKILL.en.md +43 -32
  64. package/templates/.agents/skills/check-task/SKILL.zh-CN.md +42 -31
  65. package/templates/.agents/skills/code-task/SKILL.en.md +117 -0
  66. package/templates/.agents/skills/{implement-task → code-task}/SKILL.zh-CN.md +51 -24
  67. package/templates/.agents/skills/{implement-task → code-task}/config/verify.en.json +4 -4
  68. package/templates/.agents/skills/{implement-task → code-task}/config/verify.zh-CN.json +4 -4
  69. package/templates/.agents/skills/{implement-task → code-task}/reference/branch-management.zh-CN.md +2 -2
  70. package/templates/.agents/skills/{implement-task/reference/implementation-rules.en.md → code-task/reference/code-rules.en.md} +6 -6
  71. package/templates/.agents/skills/{implement-task/reference/implementation-rules.zh-CN.md → code-task/reference/code-rules.zh-CN.md} +3 -3
  72. package/templates/.agents/skills/code-task/reference/dual-mode.en.md +69 -0
  73. package/templates/.agents/skills/code-task/reference/dual-mode.zh-CN.md +69 -0
  74. package/templates/.agents/skills/{refine-task/reference/fix-workflow.en.md → code-task/reference/fix-mode.en.md} +12 -12
  75. package/templates/.agents/skills/{refine-task/reference/fix-workflow.zh-CN.md → code-task/reference/fix-mode.zh-CN.md} +8 -8
  76. package/templates/.agents/skills/code-task/reference/output-template.en.md +20 -0
  77. package/templates/.agents/skills/code-task/reference/output-template.zh-CN.md +20 -0
  78. package/templates/.agents/skills/{implement-task → code-task}/reference/report-template.en.md +4 -4
  79. package/templates/.agents/skills/{implement-task → code-task}/reference/report-template.zh-CN.md +3 -3
  80. package/templates/.agents/skills/code-task/scripts/detect-mode.js +370 -0
  81. package/templates/.agents/skills/commit/SKILL.en.md +2 -2
  82. package/templates/.agents/skills/commit/SKILL.zh-CN.md +2 -2
  83. package/templates/.agents/skills/commit/reference/task-status-update.en.md +10 -6
  84. package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +10 -6
  85. package/templates/.agents/skills/complete-task/SKILL.en.md +5 -3
  86. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +5 -3
  87. package/templates/.agents/skills/create-pr/SKILL.en.md +17 -1
  88. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +17 -1
  89. package/templates/.agents/skills/import-codescan/SKILL.en.md +1 -1
  90. package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +1 -1
  91. package/templates/.agents/skills/import-dependabot/SKILL.en.md +2 -2
  92. package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +2 -2
  93. package/templates/.agents/skills/import-issue/SKILL.en.md +3 -3
  94. package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +3 -3
  95. package/templates/.agents/skills/plan-task/SKILL.en.md +4 -4
  96. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +4 -4
  97. package/templates/.agents/skills/restore-task/SKILL.en.md +4 -3
  98. package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +4 -3
  99. package/templates/.agents/skills/review-analysis/SKILL.en.md +76 -0
  100. package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +102 -0
  101. package/templates/.agents/skills/review-analysis/config/verify.en.json +51 -0
  102. package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +51 -0
  103. package/templates/.agents/skills/review-analysis/reference/output-templates.en.md +87 -0
  104. package/templates/.agents/skills/review-analysis/reference/output-templates.zh-CN.md +87 -0
  105. package/templates/.agents/skills/review-analysis/reference/report-template.en.md +90 -0
  106. package/templates/.agents/skills/review-analysis/reference/report-template.zh-CN.md +91 -0
  107. package/templates/.agents/skills/review-analysis/reference/review-criteria.en.md +47 -0
  108. package/templates/.agents/skills/review-analysis/reference/review-criteria.zh-CN.md +47 -0
  109. package/templates/.agents/skills/{review-task → review-code}/SKILL.en.md +11 -9
  110. package/templates/.agents/skills/{review-task → review-code}/SKILL.zh-CN.md +15 -9
  111. package/templates/.agents/skills/{review-task → review-code}/config/verify.en.json +7 -5
  112. package/templates/.agents/skills/{review-task → review-code}/config/verify.zh-CN.json +6 -4
  113. package/templates/.agents/skills/{review-task → review-code}/reference/output-templates.en.md +21 -17
  114. package/templates/.agents/skills/{review-task → review-code}/reference/output-templates.zh-CN.md +19 -15
  115. package/templates/.agents/skills/{review-task → review-code}/reference/report-template.en.md +5 -6
  116. package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +91 -0
  117. package/templates/.agents/skills/review-code/reference/review-criteria.en.md +48 -0
  118. package/templates/.agents/skills/{review-task → review-code}/reference/review-criteria.zh-CN.md +10 -4
  119. package/templates/.agents/skills/review-plan/SKILL.en.md +76 -0
  120. package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +102 -0
  121. package/templates/.agents/skills/{refine-task → review-plan}/config/verify.en.json +14 -10
  122. package/templates/.agents/skills/{refine-task → review-plan}/config/verify.zh-CN.json +14 -10
  123. package/templates/.agents/skills/review-plan/reference/output-templates.en.md +87 -0
  124. package/templates/.agents/skills/review-plan/reference/output-templates.zh-CN.md +87 -0
  125. package/templates/.agents/skills/review-plan/reference/report-template.en.md +90 -0
  126. package/templates/.agents/skills/{review-task → review-plan}/reference/report-template.zh-CN.md +3 -3
  127. package/templates/.agents/skills/review-plan/reference/review-criteria.en.md +47 -0
  128. package/templates/.agents/skills/review-plan/reference/review-criteria.zh-CN.md +47 -0
  129. package/templates/.agents/skills/test/SKILL.en.md +2 -2
  130. package/templates/.agents/skills/test/SKILL.zh-CN.md +13 -31
  131. package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +1 -0
  132. package/templates/.agents/templates/task.en.md +3 -3
  133. package/templates/.agents/templates/task.zh-CN.md +2 -2
  134. package/templates/.agents/workflows/bug-fix.en.yaml +126 -80
  135. package/templates/.agents/workflows/bug-fix.zh-CN.yaml +90 -44
  136. package/templates/.agents/workflows/feature-development.en.yaml +115 -70
  137. package/templates/.agents/workflows/feature-development.zh-CN.yaml +92 -47
  138. package/templates/.agents/workflows/refactoring.en.yaml +123 -78
  139. package/templates/.agents/workflows/refactoring.zh-CN.yaml +89 -44
  140. package/templates/.claude/commands/code-task.en.md +8 -0
  141. package/templates/.claude/commands/code-task.zh-CN.md +8 -0
  142. package/templates/.claude/commands/review-analysis.en.md +8 -0
  143. package/templates/.claude/commands/review-analysis.zh-CN.md +8 -0
  144. package/templates/.claude/commands/review-code.en.md +8 -0
  145. package/templates/.claude/commands/review-code.zh-CN.md +8 -0
  146. package/templates/.claude/commands/review-plan.en.md +8 -0
  147. package/templates/.claude/commands/review-plan.zh-CN.md +8 -0
  148. package/templates/.gemini/commands/_project_/archive-tasks.zh-CN.toml +1 -1
  149. package/templates/.gemini/commands/_project_/code-task.en.toml +8 -0
  150. package/templates/.gemini/commands/_project_/code-task.zh-CN.toml +8 -0
  151. package/templates/.gemini/commands/_project_/init-labels.zh-CN.toml +1 -1
  152. package/templates/.gemini/commands/_project_/init-milestones.zh-CN.toml +1 -1
  153. package/templates/.gemini/commands/_project_/review-analysis.en.toml +8 -0
  154. package/templates/.gemini/commands/_project_/review-analysis.zh-CN.toml +8 -0
  155. package/templates/.gemini/commands/_project_/review-code.en.toml +8 -0
  156. package/templates/.gemini/commands/_project_/review-code.zh-CN.toml +8 -0
  157. package/templates/.gemini/commands/_project_/review-plan.en.toml +8 -0
  158. package/templates/.gemini/commands/_project_/review-plan.zh-CN.toml +8 -0
  159. package/templates/.opencode/commands/code-task.en.md +11 -0
  160. package/templates/.opencode/commands/code-task.zh-CN.md +11 -0
  161. package/templates/.opencode/commands/review-analysis.en.md +11 -0
  162. package/templates/.opencode/commands/review-analysis.zh-CN.md +11 -0
  163. package/templates/.opencode/commands/review-code.en.md +11 -0
  164. package/templates/.opencode/commands/review-code.zh-CN.md +11 -0
  165. package/templates/.opencode/commands/review-plan.en.md +11 -0
  166. package/templates/.opencode/commands/review-plan.zh-CN.md +11 -0
  167. package/templates/.agents/skills/implement-task/SKILL.en.md +0 -173
  168. package/templates/.agents/skills/implement-task/reference/output-template.en.md +0 -20
  169. package/templates/.agents/skills/implement-task/reference/output-template.zh-CN.md +0 -20
  170. package/templates/.agents/skills/refine-task/SKILL.en.md +0 -153
  171. package/templates/.agents/skills/refine-task/SKILL.zh-CN.md +0 -153
  172. package/templates/.agents/skills/refine-task/reference/report-template.en.md +0 -64
  173. package/templates/.agents/skills/refine-task/reference/report-template.zh-CN.md +0 -64
  174. package/templates/.agents/skills/review-task/reference/review-criteria.en.md +0 -42
  175. package/templates/.claude/commands/implement-task.en.md +0 -8
  176. package/templates/.claude/commands/implement-task.zh-CN.md +0 -8
  177. package/templates/.claude/commands/refine-task.en.md +0 -8
  178. package/templates/.claude/commands/refine-task.zh-CN.md +0 -8
  179. package/templates/.claude/commands/review-task.en.md +0 -8
  180. package/templates/.claude/commands/review-task.zh-CN.md +0 -8
  181. package/templates/.gemini/commands/_project_/implement-task.en.toml +0 -8
  182. package/templates/.gemini/commands/_project_/implement-task.zh-CN.toml +0 -8
  183. package/templates/.gemini/commands/_project_/refine-task.en.toml +0 -8
  184. package/templates/.gemini/commands/_project_/refine-task.zh-CN.toml +0 -8
  185. package/templates/.gemini/commands/_project_/review-task.en.toml +0 -8
  186. package/templates/.gemini/commands/_project_/review-task.zh-CN.toml +0 -8
  187. package/templates/.opencode/commands/implement-task.en.md +0 -11
  188. package/templates/.opencode/commands/implement-task.zh-CN.md +0 -11
  189. package/templates/.opencode/commands/refine-task.en.md +0 -11
  190. package/templates/.opencode/commands/refine-task.zh-CN.md +0 -11
  191. package/templates/.opencode/commands/review-task.en.md +0 -11
  192. package/templates/.opencode/commands/review-task.zh-CN.md +0 -11
  193. /package/templates/.agents/skills/{implement-task → code-task}/reference/branch-management.en.md +0 -0
@@ -0,0 +1,69 @@
1
+ # code-task 双模式判定
2
+
3
+ 本文件说明 `scripts/detect-mode.js` 的行为。脚本是单点真相;修改脚本时必须同步更新本文档。
4
+
5
+ ## 输入
6
+
7
+ ```bash
8
+ node .agents/skills/code-task/scripts/detect-mode.js .agents/workspace/active/{task-id}
9
+ ```
10
+
11
+ 脚本扫描任务目录中的 `plan.md` / `plan-r{N}.md`、`review-plan.md` / `review-plan-r{N}.md`、`code.md` / `code-r{N}.md` 和 `review-code.md` / `review-code-r{N}.md`。
12
+
13
+ ## 8 个分支
14
+
15
+ > 分支按表中自上而下的顺序评估,命中即返回;后续分支不再判定。
16
+
17
+ | 条件 | mode | exit | 行为 |
18
+ |---|---|---:|---|
19
+ | 无 code 产物 | `init` | 0 | 初次实现,产物为 `code.md` |
20
+ | 最新 review-plan 已批准(`通过` 或 `通过 + major/minor 建议`,即 `Approved` 或 `Approved-with-issues`),且其「审查输入」/「Review Input」字段引用的 plan 文件 == 任务目录中最新的 `plan(-r{N})?.md`,且最新 review-plan 的 mtime > 最新 code 的 mtime | `init` | 0 | plan 已在 code 之后被批准;进入新一轮实现,`next_round = code_max + 1`、`next_artifact = code-r{next_round}.md`。**不论 review-code 是否已审**,本分支均先命中。plan 与 review-plan 的轮次独立递增(如 `plan-r5` 可被 `review-plan-r4` 批准),通过 review-plan 的「审查输入」字段建立批准关系,不要求同号 |
21
+ | `rev_max < code_max` | `error` | 2 | 最新代码未审查,先运行 `review-code` |
22
+ | `rev_max > code_max` | `error` | 2 | 数据状态异常,需要人工检查 |
23
+ | 最新 review-code 为 Approved 且 0/0/0 | `refused` | 1 | 已通过,无需再次运行 `code-task` |
24
+ | 最新 review-code 为 Approved 但有 major/minor | `fix` | 0 | 可选修复模式 |
25
+ | 最新 review-code 为 Changes Requested | `fix` | 0 | 必需修复模式 |
26
+ | 最新 review-code 为 Rejected | `refused` | 1 | 需要重新设计,不进入局部修复 |
27
+
28
+ ## verdict 解析
29
+
30
+ 脚本支持中文和英文 review-code 报告:
31
+
32
+ | 语义 | 中文 | 英文 |
33
+ |---|---|---|
34
+ | 摘要段落 | `## 审查摘要` | `## Review Summary` |
35
+ | 总体结论字段 | `**总体结论**:` | `**Overall Verdict**:` |
36
+ | 发现统计字段 | `**发现(AI 可处理)**:` | `**Findings (AI-actionable)**:` |
37
+
38
+ 结论映射:
39
+
40
+ - `通过` / `Approved` -> `Approved`,再按 blocker/major/minor 计数拆成 `Approved` 或 `Approved-with-issues`
41
+ - `需要修改` / `Changes Requested` -> `Changes Requested`
42
+ - `拒绝` / `Rejected` -> `Rejected`
43
+
44
+ env-blocked 计数不参与 mode 判定。
45
+
46
+ ## 输出契约
47
+
48
+ 脚本输出 JSON:
49
+
50
+ ```json
51
+ {
52
+ "mode": "init",
53
+ "code_max": 0,
54
+ "rev_max": 0,
55
+ "verdict": null,
56
+ "next_round": 1,
57
+ "next_artifact": "code.md",
58
+ "review_artifact": null,
59
+ "message": "..."
60
+ }
61
+ ```
62
+
63
+ `review_artifact` 字段在第 2 分支(replan-driven init)下指向触发的 `review-plan-r{N}.md` 而非 review-code 产物,用于追溯触发原因。
64
+
65
+ exit code:
66
+
67
+ - `0`:可继续,`mode` 为 `init` 或 `fix`
68
+ - `1`:拒绝继续,`mode` 为 `refused`
69
+ - `2`:状态异常,`mode` 为 `error`
@@ -1,6 +1,6 @@
1
1
  # Fix Workflow
2
2
 
3
- Read this file before changing code during refinement.
3
+ Read this file before changing code during fix mode.
4
4
 
5
5
  ## Plan the Fixes
6
6
 
@@ -24,7 +24,7 @@ Detailed priority rules:
24
24
 
25
25
  env-blocked findings are outside the repair scope. Handling rules:
26
26
  - do not write code changes for these findings
27
- - list them unchanged in the refinement report's "Environment-Blocked Handling" section and mark them "outside AI repair scope"
27
+ - list them unchanged in the code report's "Environment-Blocked Handling" section and mark them "outside AI repair scope"
28
28
  - do not repeat them under unresolved issues, to avoid visually double-counting them
29
29
  - their destination is the PR description, where maintainers carry them as a "manual verification required" checklist
30
30
 
@@ -38,7 +38,7 @@ For each fix:
38
38
 
39
39
  ## Run Test Verification
40
40
 
41
- Before writing the refinement report, run the project's **core subset** as final verification and confirm that all required tests still pass. If the project does not have layered scripts, fall back to the full project test command.
41
+ Before writing the code report, run the project's **core subset** as final verification and confirm that all required tests still pass. If the project does not have layered scripts, fall back to the full project test command.
42
42
 
43
43
  ## Choose the Next-Step Branch
44
44
 
@@ -53,22 +53,22 @@ Prohibition:
53
53
  Required output template:
54
54
 
55
55
  ```text
56
- Task {task-id} refinement completed.
56
+ Task {task-id} fix completed.
57
57
 
58
- Refinement status:
58
+ Fix status:
59
59
  - Blockers fixed: {fixed-blockers}/{total-blockers}
60
60
  - Major issues fixed: {fixed-majors}/{total-majors}
61
61
  - Minor issues fixed: {fixed-minors}/{total-minors}
62
62
  - [If env-blocked > 0] env-blocked skipped: {count}
63
63
  - All tests passing: {yes/no}
64
64
  - Review input: {review-artifact}
65
- - Refinement artifact: {refinement-artifact}
65
+ - Code artifact: {code-artifact}
66
66
 
67
67
  Next step - re-review or commit:
68
68
  - Re-review (always recommended):
69
- - Claude Code / OpenCode: /review-task {task-id}
70
- - Gemini CLI: /agent-infra:review-task {task-id}
71
- - Codex CLI: $review-task {task-id}
69
+ - Claude Code / OpenCode: /review-code {task-id}
70
+ - Gemini CLI: /agent-infra:review-code {task-id}
71
+ - Codex CLI: $review-code {task-id}
72
72
  - Commit directly (optional; only when all issues are resolved and changes are low risk):
73
73
  - Claude Code / OpenCode: /commit
74
74
  - Gemini CLI: /agent-infra:commit
@@ -77,9 +77,9 @@ Next step - re-review or commit:
77
77
 
78
78
  ## Notes
79
79
 
80
- 1. **Prerequisite**: a review artifact must exist (`review.md` or `review-r{N}.md`)
80
+ 1. **Prerequisite**: a code review artifact must exist (`review-code.md` or `review-code-r{N}.md`)
81
81
  2. **No auto-commit**: do not run `git commit`
82
82
  3. **Scope discipline**: only fix reviewed issues
83
83
  4. **Disagreement handling**: record any disagreement in the report
84
- 5. **Re-review**: always recommend `review-task` as the default next step after refinement
85
- 6. **Consistency**: the latest review artifact, Activity Log entry, and refinement report must reference the same round
84
+ 5. **Re-review**: always recommend `review-code` as the default next step after fix mode
85
+ 6. **Consistency**: the latest review artifact, Activity Log entry, and code report must reference the same round
@@ -24,7 +24,7 @@
24
24
 
25
25
  env-blocked 项不在修复范围。处理规则:
26
26
  - 不要为这些项编写代码改动
27
- - 在 refinement 报告的「环境性遗留处理」段落原样列出,标注「不在 AI 修复范围」
27
+ - 在 code 报告的「环境性遗留处理」段落原样列出,标注「不在 AI 修复范围」
28
28
  - 不要在 unresolved 段落里重复列出(避免视觉计数翻倍)
29
29
  - 这些项的去向:维护者在 PR description 中以「待人工验证」清单承接
30
30
 
@@ -38,7 +38,7 @@ env-blocked 项不在修复范围。处理规则:
38
38
 
39
39
  ## 运行测试验证
40
40
 
41
- refinement 报告前,运行项目测试的 **core 子集**做最终验证,确保所有必需测试仍然通过。如果项目没有分层 script,回退到完整项目测试命令。
41
+ code 报告前,运行项目测试的 **core 子集**做最终验证,确保所有必需测试仍然通过。如果项目没有分层 script,回退到完整项目测试命令。
42
42
 
43
43
  ## 选择下一步分支
44
44
 
@@ -62,13 +62,13 @@ env-blocked 项不在修复范围。处理规则:
62
62
  - [如 env-blocked > 0] 环境性遗留跳过:{数量}
63
63
  - 所有测试通过:{是/否}
64
64
  - 审查输入:{review-artifact}
65
- - 修复产物:{refinement-artifact}
65
+ - 修复产物:{code-artifact}
66
66
 
67
67
  下一步 - 重新审查或提交:
68
68
  - 重新审查(始终推荐):
69
- - Claude Code / OpenCode:/review-task {task-id}
70
- - Gemini CLI:/agent-infra:review-task {task-id}
71
- - Codex CLI:$review-task {task-id}
69
+ - Claude Code / OpenCode:/review-code {task-id}
70
+ - Gemini CLI:/agent-infra:review-code {task-id}
71
+ - Codex CLI:$review-code {task-id}
72
72
  - 直接提交(可选;仅在所有问题已解决且风险可控时):
73
73
  - Claude Code / OpenCode:/commit
74
74
  - Gemini CLI:/agent-infra:commit
@@ -77,9 +77,9 @@ env-blocked 项不在修复范围。处理规则:
77
77
 
78
78
  ## 注意事项
79
79
 
80
- 1. **前置条件**:必须存在审查产物(`review.md` 或 `review-r{N}.md`)
80
+ 1. **前置条件**:必须存在代码审查产物(`review-code.md` 或 `review-code-r{N}.md`)
81
81
  2. **禁止自动提交**:不要执行 `git commit`
82
82
  3. **范围约束**:只修复审查中列出的问题
83
83
  4. **分歧处理**:如果不同意审查意见,要在报告里明确记录
84
- 5. **重新审查**:修复后始终推荐执行 `review-task`
84
+ 5. **重新审查**:修复后始终推荐执行 `review-code`
85
85
  6. **一致性**:最新审查产物、Activity Log 记录和修复报告必须引用同一轮次
@@ -0,0 +1,20 @@
1
+ # Output Template
2
+
3
+ When reporting that implementation is complete, use the following standard format:
4
+
5
+ ```text
6
+ Task {task-id} code implementation complete.
7
+
8
+ Summary:
9
+ - Implementation round: Round {code-round}
10
+ - Files modified: {count}
11
+ - All tests passed: {yes/no}
12
+
13
+ Output files:
14
+ - Code report: .agents/workspace/active/{task-id}/{code-artifact}
15
+
16
+ Next step - code review:
17
+ - Claude Code / OpenCode: /review-code {task-id}
18
+ - Gemini CLI: /{{project}}:review-code {task-id}
19
+ - Codex CLI: $review-code {task-id}
20
+ ```
@@ -0,0 +1,20 @@
1
+ # 输出模板
2
+
3
+ 向用户汇报实现完成时,使用以下标准格式:
4
+
5
+ ```text
6
+ 任务 {task-id} 实现完成。
7
+
8
+ 摘要:
9
+ - 实现轮次:Round {code-round}
10
+ - 修改文件:{数量}
11
+ - 所有测试通过:{是/否}
12
+
13
+ 产出文件:
14
+ - 实现报告:.agents/workspace/active/{task-id}/{code-artifact}
15
+
16
+ 下一步 - 代码审查:
17
+ - Claude Code / OpenCode:/review-code {task-id}
18
+ - Gemini CLI:/agent-infra:review-code {task-id}
19
+ - Codex CLI:$review-code {task-id}
20
+ ```
@@ -1,14 +1,14 @@
1
- # Implementation Report Template
1
+ # Code Report Template
2
2
 
3
- Use this structure when creating `implementation.md` or `implementation-r{N}.md`.
3
+ Use this structure when creating `code.md` or `code-r{N}.md`.
4
4
 
5
5
  ## Output Template
6
6
 
7
7
  ```markdown
8
8
  # Implementation Report
9
9
 
10
- - **Implementation Round**: Round {implementation-round}
11
- - **Artifact File**: `{implementation-artifact}`
10
+ - **Implementation Round**: Round {code-round}
11
+ - **Artifact File**: `{code-artifact}`
12
12
 
13
13
  ## State Check
14
14
 
@@ -1,14 +1,14 @@
1
1
  # 实现报告模板
2
2
 
3
- 创建 `implementation.md` 或 `implementation-r{N}.md` 时,使用以下结构。
3
+ 创建 `code.md` 或 `code-r{N}.md` 时,使用以下结构。
4
4
 
5
5
  ## 输出模板
6
6
 
7
7
  ```markdown
8
8
  # 实现报告
9
9
 
10
- - **实现轮次**: Round {implementation-round}
11
- - **产物文件**: `{implementation-artifact}`
10
+ - **实现轮次**: Round {code-round}
11
+ - **产物文件**: `{code-artifact}`
12
12
 
13
13
  ## 状态核对
14
14
 
@@ -0,0 +1,370 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import process from "node:process";
4
+
5
+ function main() {
6
+ const taskDir = process.argv[2];
7
+ if (!taskDir) {
8
+ writeResult({
9
+ mode: "error",
10
+ code_max: 0,
11
+ rev_max: 0,
12
+ verdict: null,
13
+ next_round: null,
14
+ next_artifact: null,
15
+ review_artifact: null,
16
+ message: "Task directory argument is required."
17
+ }, 2);
18
+ return;
19
+ }
20
+
21
+ try {
22
+ const resolvedTaskDir = path.resolve(taskDir);
23
+ const taskId = path.basename(resolvedTaskDir);
24
+ const entries = fs.readdirSync(resolvedTaskDir);
25
+ const codeMax = maxRound(entries, "code");
26
+ const revMax = maxRound(entries, "review-code");
27
+
28
+ if (codeMax === 0) {
29
+ writeResult({
30
+ mode: "init",
31
+ code_max: codeMax,
32
+ rev_max: revMax,
33
+ verdict: null,
34
+ next_round: 1,
35
+ next_artifact: "code.md",
36
+ review_artifact: null,
37
+ message: "No prior code artifact. Starting initial implementation (round 1 -> code.md)."
38
+ }, 0);
39
+ return;
40
+ }
41
+
42
+ // replan-precedes-unreviewed-code:
43
+ // 第 8 分支(replan)必须在第 2 分支(revMax < codeMax → error)之前评估。
44
+ // 依据 task.md 盲区 B 修法 B1:「不论 review-code 状态如何(包括未审)」,
45
+ // 只要最新 review-plan 已批准且 mtime > code,就进入新一轮实现。
46
+ const planMax = maxRound(entries, "plan");
47
+ const reviewPlanMax = maxRound(entries, "review-plan");
48
+ const replanCheck = checkPlanAheadOfCode({
49
+ resolvedTaskDir,
50
+ codeMax,
51
+ planMax,
52
+ reviewPlanMax
53
+ });
54
+ if (replanCheck.replan) {
55
+ const nextRound = codeMax + 1;
56
+ const nextArtifact = artifactName("code", nextRound);
57
+ writeResult({
58
+ mode: "init",
59
+ code_max: codeMax,
60
+ rev_max: revMax,
61
+ verdict: null,
62
+ next_round: nextRound,
63
+ next_artifact: nextArtifact,
64
+ review_artifact: replanCheck.reviewPlanArtifact,
65
+ message: `Latest ${replanCheck.reviewPlanArtifact} is approved and its mtime is newer than the latest code artifact. Entering replan-driven init (round ${nextRound} -> ${nextArtifact}).`
66
+ }, 0);
67
+ return;
68
+ }
69
+
70
+ if (revMax < codeMax) {
71
+ const expected = artifactName("review-code", codeMax);
72
+ writeResult({
73
+ mode: "error",
74
+ code_max: codeMax,
75
+ rev_max: revMax,
76
+ verdict: null,
77
+ next_round: null,
78
+ next_artifact: null,
79
+ review_artifact: expected,
80
+ message: `Code round ${codeMax} has no matching review-code artifact (${expected} expected). Run /review-code ${taskId} first.`
81
+ }, 2);
82
+ return;
83
+ }
84
+
85
+ if (revMax > codeMax) {
86
+ writeResult({
87
+ mode: "error",
88
+ code_max: codeMax,
89
+ rev_max: revMax,
90
+ verdict: null,
91
+ next_round: null,
92
+ next_artifact: null,
93
+ review_artifact: artifactName("review-code", revMax),
94
+ message: `Inconsistent state: review-code round ${revMax} > code round ${codeMax}. Manual inspection required.`
95
+ }, 2);
96
+ return;
97
+ }
98
+
99
+ const reviewArtifact = artifactName("review-code", revMax);
100
+ const verdictResult = parseVerdict(path.join(resolvedTaskDir, reviewArtifact));
101
+ if (!verdictResult.ok) {
102
+ writeResult({
103
+ mode: "error",
104
+ code_max: codeMax,
105
+ rev_max: revMax,
106
+ verdict: verdictResult.verdict ?? null,
107
+ next_round: null,
108
+ next_artifact: null,
109
+ review_artifact: reviewArtifact,
110
+ message: verdictResult.message
111
+ }, 2);
112
+ return;
113
+ }
114
+
115
+ const verdict = verdictResult.verdict;
116
+ if (verdict === "Approved") {
117
+ writeResult({
118
+ mode: "refused",
119
+ code_max: codeMax,
120
+ rev_max: revMax,
121
+ verdict,
122
+ next_round: null,
123
+ next_artifact: null,
124
+ review_artifact: reviewArtifact,
125
+ message: `Latest ${reviewArtifact} verdict is Approved with no findings. Nothing to fix. Run /commit to proceed.`
126
+ }, 1);
127
+ return;
128
+ }
129
+
130
+ if (verdict === "Rejected") {
131
+ writeResult({
132
+ mode: "refused",
133
+ code_max: codeMax,
134
+ rev_max: revMax,
135
+ verdict,
136
+ next_round: null,
137
+ next_artifact: null,
138
+ review_artifact: reviewArtifact,
139
+ message: `Latest ${reviewArtifact} verdict is Rejected. This requires a fresh implementation strategy; re-plan or discuss with maintainers before re-running /code-task ${taskId}.`
140
+ }, 1);
141
+ return;
142
+ }
143
+
144
+ const nextRound = codeMax + 1;
145
+ const nextArtifact = artifactName("code", nextRound);
146
+ const optional = verdict === "Approved-with-issues";
147
+ writeResult({
148
+ mode: "fix",
149
+ code_max: codeMax,
150
+ rev_max: revMax,
151
+ verdict,
152
+ next_round: nextRound,
153
+ next_artifact: nextArtifact,
154
+ review_artifact: reviewArtifact,
155
+ message: optional
156
+ ? `Latest ${reviewArtifact} approved with non-blocking findings. Entering optional fix mode (round ${nextRound} -> ${nextArtifact}).`
157
+ : `Latest ${reviewArtifact} requests changes. Entering required fix mode (round ${nextRound} -> ${nextArtifact}).`
158
+ }, 0);
159
+ } catch (error) {
160
+ writeResult({
161
+ mode: "error",
162
+ code_max: 0,
163
+ rev_max: 0,
164
+ verdict: null,
165
+ next_round: null,
166
+ next_artifact: null,
167
+ review_artifact: null,
168
+ message: `Mode detection failed: ${error instanceof Error ? error.message : String(error)}`
169
+ }, 2);
170
+ }
171
+ }
172
+
173
+ function maxRound(entries, stem) {
174
+ let max = 0;
175
+ for (const entry of entries) {
176
+ if (entry === `${stem}.md`) {
177
+ max = Math.max(max, 1);
178
+ continue;
179
+ }
180
+
181
+ const match = entry.match(new RegExp(`^${escapeRegExp(stem)}-r(\\d+)\\.md$`));
182
+ if (match) {
183
+ max = Math.max(max, Number(match[1]));
184
+ }
185
+ }
186
+ return max;
187
+ }
188
+
189
+ function artifactName(stem, round) {
190
+ return round === 1 ? `${stem}.md` : `${stem}-r${round}.md`;
191
+ }
192
+
193
+ function checkPlanAheadOfCode({ resolvedTaskDir, codeMax, planMax, reviewPlanMax }) {
194
+ if (planMax === 0 || reviewPlanMax === 0) {
195
+ return { replan: false };
196
+ }
197
+
198
+ // plan 和 review-plan 轮次独立递增(plan-r5 可被 review-plan-r4 批准),不能假设同号。
199
+ // 用最新 review-plan 产物的「审查输入」/「Review Input」段落里引用的 plan 文件名
200
+ // 作为真正被批准的 plan;若该 plan 文件名不等于目录里最新 plan-rN.md,
201
+ // 说明最新 plan 还未被审查,不触发 replan。
202
+ const reviewPlanArtifact = artifactName("review-plan", reviewPlanMax);
203
+ const reviewPlanPath = path.join(resolvedTaskDir, reviewPlanArtifact);
204
+ if (!fs.existsSync(reviewPlanPath)) {
205
+ return { replan: false };
206
+ }
207
+
208
+ const reviewedPlan = parseReviewedPlan(reviewPlanPath);
209
+ if (!reviewedPlan) {
210
+ return { replan: false };
211
+ }
212
+ const latestPlanArtifact = artifactName("plan", planMax);
213
+ if (reviewedPlan !== latestPlanArtifact) {
214
+ return { replan: false };
215
+ }
216
+
217
+ // review-plan 的「通过 + 主要/次要建议」(Approved-with-issues)仍是已批准,
218
+ // 区别于 review-code(Approved-with-issues 触发 optional fix)。replan 检测对
219
+ // review-plan 放宽到 Approved + Approved-with-issues 二者均放行。
220
+ const APPROVED_PLAN_VERDICTS = new Set(["Approved", "Approved-with-issues"]);
221
+ const reviewVerdict = parseVerdict(reviewPlanPath);
222
+ if (!reviewVerdict.ok || !APPROVED_PLAN_VERDICTS.has(reviewVerdict.verdict)) {
223
+ return { replan: false };
224
+ }
225
+
226
+ const codeArtifact = artifactName("code", codeMax);
227
+ const codeStat = safeStat(path.join(resolvedTaskDir, codeArtifact));
228
+ const reviewPlanStat = safeStat(reviewPlanPath);
229
+ if (!codeStat || !reviewPlanStat) {
230
+ return { replan: false };
231
+ }
232
+
233
+ // 严格 `>`:同秒回退到既有 7 分支逻辑(保守,参见 plan-r5.md Q2 决议)
234
+ if (reviewPlanStat.mtimeMs > codeStat.mtimeMs) {
235
+ return { replan: true, reviewPlanArtifact };
236
+ }
237
+ return { replan: false };
238
+ }
239
+
240
+ function parseReviewedPlan(reviewPlanPath) {
241
+ let content;
242
+ try {
243
+ content = fs.readFileSync(reviewPlanPath, "utf8");
244
+ } catch {
245
+ return null;
246
+ }
247
+ const lines = content.split(/\r?\n/);
248
+ const headerPattern = /^[-*]\s*\*\*(?:审查输入|Review Input)\*\*[::]/;
249
+ const planFilePattern = /`(plan(?:-r\d+)?\.md)`/;
250
+ let inHeader = false;
251
+ for (const line of lines) {
252
+ if (headerPattern.test(line)) {
253
+ inHeader = true;
254
+ const inline = line.match(planFilePattern);
255
+ if (inline) return inline[1];
256
+ continue;
257
+ }
258
+ if (!inHeader) continue;
259
+ if (/^\s*[-*]\s/.test(line)) {
260
+ const match = line.match(planFilePattern);
261
+ if (match) return match[1];
262
+ continue;
263
+ }
264
+ if (line.trim() === "") continue;
265
+ break;
266
+ }
267
+ return null;
268
+ }
269
+
270
+ function safeStat(filePath) {
271
+ try {
272
+ return fs.statSync(filePath);
273
+ } catch {
274
+ return null;
275
+ }
276
+ }
277
+
278
+ function parseVerdict(reviewPath) {
279
+ if (!fs.existsSync(reviewPath)) {
280
+ return { ok: false, verdict: null, message: `Review artifact not found: ${path.basename(reviewPath)}` };
281
+ }
282
+
283
+ const content = fs.readFileSync(reviewPath, "utf8");
284
+ const summary = extractSection(content, ["审查摘要", "Review Summary"]);
285
+ const fileName = path.basename(reviewPath);
286
+ if (!summary) {
287
+ return { ok: false, verdict: null, message: `cannot locate review summary section in ${fileName}` };
288
+ }
289
+
290
+ const verdictMatch = summary.match(/^[-*]?\s*\*\*(?:总体结论|Overall Verdict)\*\*[::]\s*(.+?)\s*$/im);
291
+ if (!verdictMatch) {
292
+ return { ok: false, verdict: null, message: `cannot parse verdict in ${fileName}` };
293
+ }
294
+
295
+ const verdict = normalizeVerdict(verdictMatch[1]);
296
+ if (!verdict) {
297
+ return {
298
+ ok: false,
299
+ verdict: null,
300
+ message: `unrecognized verdict '${verdictMatch[1].trim()}' in ${fileName}`
301
+ };
302
+ }
303
+
304
+ if (verdict !== "Approved") {
305
+ return { ok: true, verdict };
306
+ }
307
+
308
+ const findingsMatch = summary.match(/^[-*]?\s*\*\*(?:发现(AI 可处理)|Findings \(AI-actionable\))\*\*[::]\s*(.+?)\s*$/im);
309
+ if (!findingsMatch) {
310
+ return { ok: false, verdict, message: `cannot parse findings count in ${fileName}` };
311
+ }
312
+
313
+ const counts = findingsMatch[1].match(/(\d+)\s*(?:阻塞项|blockers?).*?(\d+)\s*(?:主要|majors?).*?(\d+)\s*(?:次要|minors?)/i);
314
+ if (!counts) {
315
+ return { ok: false, verdict, message: `cannot parse findings count in ${fileName}` };
316
+ }
317
+
318
+ const [, blockers, majors, minors] = counts.map(Number);
319
+ return {
320
+ ok: true,
321
+ verdict: blockers === 0 && majors === 0 && minors === 0 ? "Approved" : "Approved-with-issues"
322
+ };
323
+ }
324
+
325
+ function normalizeVerdict(raw) {
326
+ const value = String(raw).trim().toLowerCase();
327
+ if (value === "通过" || value === "approved") {
328
+ return "Approved";
329
+ }
330
+ if (value === "需要修改" || value === "changes requested") {
331
+ return "Changes Requested";
332
+ }
333
+ if (value === "拒绝" || value === "rejected") {
334
+ return "Rejected";
335
+ }
336
+ return "";
337
+ }
338
+
339
+ function extractSection(content, names) {
340
+ const lines = content.split(/\r?\n/);
341
+ const nameSet = new Set(names);
342
+ const start = lines.findIndex((line) => {
343
+ const match = line.trim().match(/^##\s+(.+?)\s*$/);
344
+ return match ? nameSet.has(match[1]) : false;
345
+ });
346
+
347
+ if (start === -1) {
348
+ return "";
349
+ }
350
+
351
+ const sectionLines = [];
352
+ for (let index = start + 1; index < lines.length; index += 1) {
353
+ if (/^##\s+/.test(lines[index])) {
354
+ break;
355
+ }
356
+ sectionLines.push(lines[index]);
357
+ }
358
+ return sectionLines.join("\n");
359
+ }
360
+
361
+ function writeResult(result, code) {
362
+ process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
363
+ process.exitCode = code;
364
+ }
365
+
366
+ function escapeRegExp(value) {
367
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
368
+ }
369
+
370
+ main();
@@ -59,8 +59,8 @@ date "+%Y-%m-%d %H:%M:%S%:z"
59
59
  Append the Commit Activity Log entry and choose exactly one next-step case:
60
60
  - final commit -> `complete-task {task-id}`
61
61
  - more work remains -> update task.md and stop
62
- - ready for review -> `review-task {task-id}`
63
- - ready for PR -> `create-pr`
62
+ - ready for review -> `review-code {task-id}`
63
+ - ready for PR (only when the project enables the PR flow, i.e. `requiresPullRequest !== false`) -> `create-pr`
64
64
 
65
65
  ## 6. Sync Issue Metadata When Applicable
66
66
 
@@ -59,8 +59,8 @@ date "+%Y-%m-%d %H:%M:%S%:z"
59
59
  追加 Commit 的 Activity Log,并且只能选择一个下一步分支:
60
60
  - 最终提交 -> `complete-task {task-id}`
61
61
  - 还有后续工作 -> 更新 task.md 后停止
62
- - 准备审查 -> `review-task {task-id}`
63
- - 准备创建 PR -> `create-pr`
62
+ - 准备审查 -> `review-code {task-id}`
63
+ - 准备创建 PR(仅项目启用 PR 流程,即 `requiresPullRequest !== false`)-> `create-pr`
64
64
 
65
65
  ## 6. 同步 Issue 元数据(按需)
66
66