@fitlab-ai/agent-infra 0.3.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 (285) hide show
  1. package/License.txt +21 -0
  2. package/README.md +170 -0
  3. package/README.zh-CN.md +170 -0
  4. package/bin/cli.js +65 -0
  5. package/lib/defaults.json +45 -0
  6. package/lib/init.js +203 -0
  7. package/lib/log.js +27 -0
  8. package/lib/paths.js +48 -0
  9. package/lib/prompt.js +70 -0
  10. package/lib/render.js +99 -0
  11. package/lib/update.js +161 -0
  12. package/lib/version.js +7 -0
  13. package/package.json +48 -0
  14. package/templates/.agent-workspace/README.md +26 -0
  15. package/templates/.agent-workspace/README.zh-CN.md +26 -0
  16. package/templates/.agents/QUICKSTART.md +166 -0
  17. package/templates/.agents/QUICKSTART.zh-CN.md +166 -0
  18. package/templates/.agents/README.md +134 -0
  19. package/templates/.agents/README.zh-CN.md +134 -0
  20. package/templates/.agents/skills/analyze-task/SKILL.md +169 -0
  21. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +169 -0
  22. package/templates/.agents/skills/block-task/SKILL.md +164 -0
  23. package/templates/.agents/skills/block-task/SKILL.zh-CN.md +163 -0
  24. package/templates/.agents/skills/check-task/SKILL.md +122 -0
  25. package/templates/.agents/skills/check-task/SKILL.zh-CN.md +122 -0
  26. package/templates/.agents/skills/close-codescan/SKILL.md +122 -0
  27. package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +122 -0
  28. package/templates/.agents/skills/close-dependabot/SKILL.md +130 -0
  29. package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +130 -0
  30. package/templates/.agents/skills/commit/SKILL.md +218 -0
  31. package/templates/.agents/skills/commit/SKILL.zh-CN.md +217 -0
  32. package/templates/.agents/skills/complete-task/SKILL.md +139 -0
  33. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +137 -0
  34. package/templates/.agents/skills/create-pr/SKILL.md +126 -0
  35. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +125 -0
  36. package/templates/.agents/skills/create-release-note/SKILL.md +167 -0
  37. package/templates/.agents/skills/create-release-note/SKILL.zh-CN.md +166 -0
  38. package/templates/.agents/skills/create-task/SKILL.md +143 -0
  39. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +143 -0
  40. package/templates/.agents/skills/implement-task/SKILL.md +229 -0
  41. package/templates/.agents/skills/implement-task/SKILL.zh-CN.md +227 -0
  42. package/templates/.agents/skills/import-codescan/SKILL.md +103 -0
  43. package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +103 -0
  44. package/templates/.agents/skills/import-dependabot/SKILL.md +107 -0
  45. package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +107 -0
  46. package/templates/.agents/skills/import-issue/SKILL.md +119 -0
  47. package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +119 -0
  48. package/templates/.agents/skills/init-labels/SKILL.md +74 -0
  49. package/templates/.agents/skills/init-labels/SKILL.zh-CN.md +74 -0
  50. package/templates/.agents/skills/init-labels/scripts/init-labels.sh +111 -0
  51. package/templates/.agents/skills/init-milestones/SKILL.md +74 -0
  52. package/templates/.agents/skills/init-milestones/SKILL.zh-CN.md +74 -0
  53. package/templates/.agents/skills/init-milestones/scripts/init-milestones.sh +169 -0
  54. package/templates/.agents/skills/plan-task/SKILL.md +225 -0
  55. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +225 -0
  56. package/templates/.agents/skills/refine-task/SKILL.md +200 -0
  57. package/templates/.agents/skills/refine-task/SKILL.zh-CN.md +200 -0
  58. package/templates/.agents/skills/refine-title/SKILL.md +84 -0
  59. package/templates/.agents/skills/refine-title/SKILL.zh-CN.md +83 -0
  60. package/templates/.agents/skills/release/SKILL.md +142 -0
  61. package/templates/.agents/skills/release/SKILL.zh-CN.md +141 -0
  62. package/templates/.agents/skills/release/scripts/manage-milestones.sh +80 -0
  63. package/templates/.agents/skills/review-task/SKILL.md +276 -0
  64. package/templates/.agents/skills/review-task/SKILL.zh-CN.md +276 -0
  65. package/templates/.agents/skills/sync-issue/SKILL.md +569 -0
  66. package/templates/.agents/skills/sync-issue/SKILL.zh-CN.md +569 -0
  67. package/templates/.agents/skills/sync-pr/SKILL.md +142 -0
  68. package/templates/.agents/skills/sync-pr/SKILL.zh-CN.md +142 -0
  69. package/templates/.agents/skills/test/SKILL.md +61 -0
  70. package/templates/.agents/skills/test/SKILL.zh-CN.md +61 -0
  71. package/templates/.agents/skills/test-integration/SKILL.md +70 -0
  72. package/templates/.agents/skills/test-integration/SKILL.zh-CN.md +69 -0
  73. package/templates/.agents/skills/update-agent-infra/SKILL.md +136 -0
  74. package/templates/.agents/skills/update-agent-infra/SKILL.zh-CN.md +124 -0
  75. package/templates/.agents/skills/update-agent-infra/scripts/package.json +3 -0
  76. package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +469 -0
  77. package/templates/.agents/skills/upgrade-dependency/SKILL.md +88 -0
  78. package/templates/.agents/skills/upgrade-dependency/SKILL.zh-CN.md +87 -0
  79. package/templates/.agents/templates/handoff.md +60 -0
  80. package/templates/.agents/templates/handoff.zh-CN.md +60 -0
  81. package/templates/.agents/templates/review-report.md +67 -0
  82. package/templates/.agents/templates/review-report.zh-CN.md +67 -0
  83. package/templates/.agents/templates/task.md +65 -0
  84. package/templates/.agents/templates/task.zh-CN.md +65 -0
  85. package/templates/.agents/workflows/bug-fix.yaml +149 -0
  86. package/templates/.agents/workflows/bug-fix.zh-CN.yaml +149 -0
  87. package/templates/.agents/workflows/code-review.yaml +60 -0
  88. package/templates/.agents/workflows/code-review.zh-CN.yaml +60 -0
  89. package/templates/.agents/workflows/feature-development.yaml +150 -0
  90. package/templates/.agents/workflows/feature-development.zh-CN.yaml +150 -0
  91. package/templates/.agents/workflows/refactoring.yaml +154 -0
  92. package/templates/.agents/workflows/refactoring.zh-CN.yaml +154 -0
  93. package/templates/.claude/CLAUDE.md +163 -0
  94. package/templates/.claude/CLAUDE.zh-CN.md +163 -0
  95. package/templates/.claude/commands/analyze-task.md +8 -0
  96. package/templates/.claude/commands/analyze-task.zh-CN.md +8 -0
  97. package/templates/.claude/commands/block-task.md +8 -0
  98. package/templates/.claude/commands/block-task.zh-CN.md +8 -0
  99. package/templates/.claude/commands/check-task.md +8 -0
  100. package/templates/.claude/commands/check-task.zh-CN.md +8 -0
  101. package/templates/.claude/commands/close-codescan.md +8 -0
  102. package/templates/.claude/commands/close-codescan.zh-CN.md +8 -0
  103. package/templates/.claude/commands/close-dependabot.md +8 -0
  104. package/templates/.claude/commands/close-dependabot.zh-CN.md +8 -0
  105. package/templates/.claude/commands/commit.md +7 -0
  106. package/templates/.claude/commands/commit.zh-CN.md +7 -0
  107. package/templates/.claude/commands/complete-task.md +8 -0
  108. package/templates/.claude/commands/complete-task.zh-CN.md +8 -0
  109. package/templates/.claude/commands/create-pr.md +8 -0
  110. package/templates/.claude/commands/create-pr.zh-CN.md +8 -0
  111. package/templates/.claude/commands/create-release-note.md +8 -0
  112. package/templates/.claude/commands/create-release-note.zh-CN.md +8 -0
  113. package/templates/.claude/commands/create-task.md +8 -0
  114. package/templates/.claude/commands/create-task.zh-CN.md +8 -0
  115. package/templates/.claude/commands/implement-task.md +8 -0
  116. package/templates/.claude/commands/implement-task.zh-CN.md +8 -0
  117. package/templates/.claude/commands/import-codescan.md +8 -0
  118. package/templates/.claude/commands/import-codescan.zh-CN.md +8 -0
  119. package/templates/.claude/commands/import-dependabot.md +8 -0
  120. package/templates/.claude/commands/import-dependabot.zh-CN.md +8 -0
  121. package/templates/.claude/commands/import-issue.md +8 -0
  122. package/templates/.claude/commands/import-issue.zh-CN.md +8 -0
  123. package/templates/.claude/commands/init-labels.md +7 -0
  124. package/templates/.claude/commands/init-labels.zh-CN.md +7 -0
  125. package/templates/.claude/commands/init-milestones.md +8 -0
  126. package/templates/.claude/commands/init-milestones.zh-CN.md +8 -0
  127. package/templates/.claude/commands/plan-task.md +8 -0
  128. package/templates/.claude/commands/plan-task.zh-CN.md +8 -0
  129. package/templates/.claude/commands/refine-task.md +8 -0
  130. package/templates/.claude/commands/refine-task.zh-CN.md +8 -0
  131. package/templates/.claude/commands/refine-title.md +8 -0
  132. package/templates/.claude/commands/refine-title.zh-CN.md +8 -0
  133. package/templates/.claude/commands/release.md +8 -0
  134. package/templates/.claude/commands/release.zh-CN.md +8 -0
  135. package/templates/.claude/commands/review-task.md +8 -0
  136. package/templates/.claude/commands/review-task.zh-CN.md +8 -0
  137. package/templates/.claude/commands/sync-issue.md +8 -0
  138. package/templates/.claude/commands/sync-issue.zh-CN.md +8 -0
  139. package/templates/.claude/commands/sync-pr.md +8 -0
  140. package/templates/.claude/commands/sync-pr.zh-CN.md +8 -0
  141. package/templates/.claude/commands/test-integration.md +7 -0
  142. package/templates/.claude/commands/test-integration.zh-CN.md +7 -0
  143. package/templates/.claude/commands/test.md +7 -0
  144. package/templates/.claude/commands/test.zh-CN.md +7 -0
  145. package/templates/.claude/commands/update-agent-infra.md +7 -0
  146. package/templates/.claude/commands/update-agent-infra.zh-CN.md +7 -0
  147. package/templates/.claude/commands/upgrade-dependency.md +8 -0
  148. package/templates/.claude/commands/upgrade-dependency.zh-CN.md +8 -0
  149. package/templates/.claude/project-rules.md +65 -0
  150. package/templates/.claude/project-rules.zh-CN.md +65 -0
  151. package/templates/.claude/settings.json +20 -0
  152. package/templates/.codex/README.md +38 -0
  153. package/templates/.codex/README.zh-CN.md +37 -0
  154. package/templates/.editorconfig +15 -0
  155. package/templates/.gemini/commands/_project_/analyze-task.toml +8 -0
  156. package/templates/.gemini/commands/_project_/analyze-task.zh-CN.toml +8 -0
  157. package/templates/.gemini/commands/_project_/block-task.toml +8 -0
  158. package/templates/.gemini/commands/_project_/block-task.zh-CN.toml +8 -0
  159. package/templates/.gemini/commands/_project_/check-task.toml +8 -0
  160. package/templates/.gemini/commands/_project_/check-task.zh-CN.toml +8 -0
  161. package/templates/.gemini/commands/_project_/close-codescan.toml +8 -0
  162. package/templates/.gemini/commands/_project_/close-codescan.zh-CN.toml +8 -0
  163. package/templates/.gemini/commands/_project_/close-dependabot.toml +8 -0
  164. package/templates/.gemini/commands/_project_/close-dependabot.zh-CN.toml +8 -0
  165. package/templates/.gemini/commands/_project_/commit.toml +6 -0
  166. package/templates/.gemini/commands/_project_/commit.zh-CN.toml +6 -0
  167. package/templates/.gemini/commands/_project_/complete-task.toml +8 -0
  168. package/templates/.gemini/commands/_project_/complete-task.zh-CN.toml +8 -0
  169. package/templates/.gemini/commands/_project_/create-pr.toml +8 -0
  170. package/templates/.gemini/commands/_project_/create-pr.zh-CN.toml +8 -0
  171. package/templates/.gemini/commands/_project_/create-release-note.toml +8 -0
  172. package/templates/.gemini/commands/_project_/create-release-note.zh-CN.toml +8 -0
  173. package/templates/.gemini/commands/_project_/create-task.toml +8 -0
  174. package/templates/.gemini/commands/_project_/create-task.zh-CN.toml +8 -0
  175. package/templates/.gemini/commands/_project_/implement-task.toml +8 -0
  176. package/templates/.gemini/commands/_project_/implement-task.zh-CN.toml +8 -0
  177. package/templates/.gemini/commands/_project_/import-codescan.toml +8 -0
  178. package/templates/.gemini/commands/_project_/import-codescan.zh-CN.toml +8 -0
  179. package/templates/.gemini/commands/_project_/import-dependabot.toml +8 -0
  180. package/templates/.gemini/commands/_project_/import-dependabot.zh-CN.toml +8 -0
  181. package/templates/.gemini/commands/_project_/import-issue.toml +8 -0
  182. package/templates/.gemini/commands/_project_/import-issue.zh-CN.toml +8 -0
  183. package/templates/.gemini/commands/_project_/init-labels.toml +8 -0
  184. package/templates/.gemini/commands/_project_/init-labels.zh-CN.toml +8 -0
  185. package/templates/.gemini/commands/_project_/init-milestones.toml +10 -0
  186. package/templates/.gemini/commands/_project_/init-milestones.zh-CN.toml +10 -0
  187. package/templates/.gemini/commands/_project_/plan-task.toml +8 -0
  188. package/templates/.gemini/commands/_project_/plan-task.zh-CN.toml +8 -0
  189. package/templates/.gemini/commands/_project_/refine-task.toml +8 -0
  190. package/templates/.gemini/commands/_project_/refine-task.zh-CN.toml +8 -0
  191. package/templates/.gemini/commands/_project_/refine-title.toml +8 -0
  192. package/templates/.gemini/commands/_project_/refine-title.zh-CN.toml +8 -0
  193. package/templates/.gemini/commands/_project_/release.toml +8 -0
  194. package/templates/.gemini/commands/_project_/release.zh-CN.toml +8 -0
  195. package/templates/.gemini/commands/_project_/review-task.toml +8 -0
  196. package/templates/.gemini/commands/_project_/review-task.zh-CN.toml +8 -0
  197. package/templates/.gemini/commands/_project_/sync-issue.toml +8 -0
  198. package/templates/.gemini/commands/_project_/sync-issue.zh-CN.toml +8 -0
  199. package/templates/.gemini/commands/_project_/sync-pr.toml +8 -0
  200. package/templates/.gemini/commands/_project_/sync-pr.zh-CN.toml +8 -0
  201. package/templates/.gemini/commands/_project_/test-integration.toml +6 -0
  202. package/templates/.gemini/commands/_project_/test-integration.zh-CN.toml +6 -0
  203. package/templates/.gemini/commands/_project_/test.toml +6 -0
  204. package/templates/.gemini/commands/_project_/test.zh-CN.toml +6 -0
  205. package/templates/.gemini/commands/_project_/update-agent-infra.toml +6 -0
  206. package/templates/.gemini/commands/_project_/update-agent-infra.zh-CN.toml +6 -0
  207. package/templates/.gemini/commands/_project_/upgrade-dependency.toml +8 -0
  208. package/templates/.gemini/commands/_project_/upgrade-dependency.zh-CN.toml +8 -0
  209. package/templates/.gemini/settings.json +3 -0
  210. package/templates/.github/ISSUE_TEMPLATE/01_bug_report.yml +149 -0
  211. package/templates/.github/ISSUE_TEMPLATE/02_question.yml +101 -0
  212. package/templates/.github/ISSUE_TEMPLATE/03_feature_request.yml +131 -0
  213. package/templates/.github/ISSUE_TEMPLATE/04_documentation.yml +165 -0
  214. package/templates/.github/ISSUE_TEMPLATE/05_other.yml +147 -0
  215. package/templates/.github/ISSUE_TEMPLATE/config.yml +11 -0
  216. package/templates/.github/PULL_REQUEST_TEMPLATE.md +123 -0
  217. package/templates/.github/dependabot.yml +17 -0
  218. package/templates/.github/hooks/check-utf8-encoding.sh +25 -0
  219. package/templates/.github/release.yml +27 -0
  220. package/templates/.github/workflows/pr-title-check.yml +42 -0
  221. package/templates/.mailmap +4 -0
  222. package/templates/.opencode/COMMAND_STYLE_GUIDE.md +232 -0
  223. package/templates/.opencode/COMMAND_STYLE_GUIDE.zh-CN.md +232 -0
  224. package/templates/.opencode/README.md +76 -0
  225. package/templates/.opencode/README.zh-CN.md +77 -0
  226. package/templates/.opencode/commands/analyze-task.md +11 -0
  227. package/templates/.opencode/commands/analyze-task.zh-CN.md +11 -0
  228. package/templates/.opencode/commands/block-task.md +11 -0
  229. package/templates/.opencode/commands/block-task.zh-CN.md +11 -0
  230. package/templates/.opencode/commands/check-task.md +11 -0
  231. package/templates/.opencode/commands/check-task.zh-CN.md +11 -0
  232. package/templates/.opencode/commands/close-codescan.md +11 -0
  233. package/templates/.opencode/commands/close-codescan.zh-CN.md +11 -0
  234. package/templates/.opencode/commands/close-dependabot.md +11 -0
  235. package/templates/.opencode/commands/close-dependabot.zh-CN.md +11 -0
  236. package/templates/.opencode/commands/commit.md +9 -0
  237. package/templates/.opencode/commands/commit.zh-CN.md +9 -0
  238. package/templates/.opencode/commands/complete-task.md +11 -0
  239. package/templates/.opencode/commands/complete-task.zh-CN.md +11 -0
  240. package/templates/.opencode/commands/create-pr.md +11 -0
  241. package/templates/.opencode/commands/create-pr.zh-CN.md +11 -0
  242. package/templates/.opencode/commands/create-release-note.md +11 -0
  243. package/templates/.opencode/commands/create-release-note.zh-CN.md +11 -0
  244. package/templates/.opencode/commands/create-task.md +11 -0
  245. package/templates/.opencode/commands/create-task.zh-CN.md +11 -0
  246. package/templates/.opencode/commands/implement-task.md +11 -0
  247. package/templates/.opencode/commands/implement-task.zh-CN.md +11 -0
  248. package/templates/.opencode/commands/import-codescan.md +11 -0
  249. package/templates/.opencode/commands/import-codescan.zh-CN.md +11 -0
  250. package/templates/.opencode/commands/import-dependabot.md +11 -0
  251. package/templates/.opencode/commands/import-dependabot.zh-CN.md +11 -0
  252. package/templates/.opencode/commands/import-issue.md +11 -0
  253. package/templates/.opencode/commands/import-issue.zh-CN.md +11 -0
  254. package/templates/.opencode/commands/init-labels.md +9 -0
  255. package/templates/.opencode/commands/init-labels.zh-CN.md +9 -0
  256. package/templates/.opencode/commands/init-milestones.md +11 -0
  257. package/templates/.opencode/commands/init-milestones.zh-CN.md +11 -0
  258. package/templates/.opencode/commands/plan-task.md +11 -0
  259. package/templates/.opencode/commands/plan-task.zh-CN.md +11 -0
  260. package/templates/.opencode/commands/refine-task.md +11 -0
  261. package/templates/.opencode/commands/refine-task.zh-CN.md +11 -0
  262. package/templates/.opencode/commands/refine-title.md +11 -0
  263. package/templates/.opencode/commands/refine-title.zh-CN.md +11 -0
  264. package/templates/.opencode/commands/release.md +11 -0
  265. package/templates/.opencode/commands/release.zh-CN.md +11 -0
  266. package/templates/.opencode/commands/review-task.md +11 -0
  267. package/templates/.opencode/commands/review-task.zh-CN.md +11 -0
  268. package/templates/.opencode/commands/sync-issue.md +11 -0
  269. package/templates/.opencode/commands/sync-issue.zh-CN.md +11 -0
  270. package/templates/.opencode/commands/sync-pr.md +11 -0
  271. package/templates/.opencode/commands/sync-pr.zh-CN.md +11 -0
  272. package/templates/.opencode/commands/test-integration.md +9 -0
  273. package/templates/.opencode/commands/test-integration.zh-CN.md +9 -0
  274. package/templates/.opencode/commands/test.md +9 -0
  275. package/templates/.opencode/commands/test.zh-CN.md +9 -0
  276. package/templates/.opencode/commands/update-agent-infra.md +9 -0
  277. package/templates/.opencode/commands/update-agent-infra.zh-CN.md +9 -0
  278. package/templates/.opencode/commands/upgrade-dependency.md +11 -0
  279. package/templates/.opencode/commands/upgrade-dependency.zh-CN.md +11 -0
  280. package/templates/AGENTS.md +91 -0
  281. package/templates/AGENTS.zh-CN.md +91 -0
  282. package/templates/CONTRIBUTING.md +126 -0
  283. package/templates/CONTRIBUTING.zh-CN.md +124 -0
  284. package/templates/SECURITY.md +131 -0
  285. package/templates/SECURITY.zh-CN.md +131 -0
@@ -0,0 +1,569 @@
1
+ ---
2
+ name: sync-issue
3
+ description: >
4
+ 将任务处理进度同步到对应的 GitHub Issue 评论。
5
+ 当用户要求同步进度到 Issue 时触发。参数:task-id 或 issue-number。
6
+ ---
7
+
8
+ # 同步进度到 Issue
9
+
10
+ 将任务处理进度同步到关联的 GitHub Issue。参数:task-id 或 issue-number。
11
+
12
+ ## 执行流程
13
+
14
+ ### 1. 解析参数
15
+
16
+ 识别用户提供的参数:
17
+ - 纯数字(如 `123`)或 `#` + 数字(如 `#123`)-> 视为 issue number
18
+ - `TASK-` 开头 -> 视为 task-id(现有格式)
19
+
20
+ 如果参数是 issue number,使用 Bash 搜索关联任务(注意:`.agent-workspace` 是隐藏目录,Grep/Glob 工具会跳过,必须使用 Bash):
21
+
22
+ ```bash
23
+ grep -rl "^issue_number: {issue-number}$" \
24
+ .agent-workspace/active/ \
25
+ .agent-workspace/blocked/ \
26
+ .agent-workspace/completed/ \
27
+ 2>/dev/null | head -1
28
+ ```
29
+
30
+ - 如果返回文件路径(如 `.agent-workspace/completed/TASK-xxx/task.md`),从路径中提取 `{task-id}` 和任务目录,继续执行步骤 2
31
+ - 如果无返回,提示 `No task found associated with Issue #{issue-number}`
32
+
33
+ 如果参数是 task-id,继续执行步骤 2 的现有逻辑。
34
+
35
+ ### 2. 验证任务存在
36
+
37
+ 对于 `task-id` 路径,按优先顺序搜索任务:
38
+ - `.agent-workspace/active/{task-id}/task.md`
39
+ - `.agent-workspace/blocked/{task-id}/task.md`
40
+ - `.agent-workspace/completed/{task-id}/task.md`
41
+
42
+ 注意:`{task-id}` 格式为 `TASK-{yyyyMMdd-HHmmss}`,例如 `TASK-20260306-143022`
43
+
44
+ 如果步骤 1 已通过 issue number 找到匹配任务,则直接使用该任务目录继续后续步骤,无需再次扫描。
45
+
46
+ ### 3. 读取任务信息
47
+
48
+ 从 task.md 中提取:
49
+ - `issue_number`(必需 —— 如果缺失,提示用户)
50
+ - `type`
51
+ - 任务标题、描述、状态
52
+ - `current_step`、`created_at`、`updated_at`、`last_synced_at`(如存在)
53
+
54
+ ### 4. 读取上下文文件
55
+
56
+ 检查并读取(如存在):
57
+ - 最高轮次的 `analysis.md` / `analysis-r{N}.md` - 需求分析
58
+ - 最高轮次的 `plan.md` / `plan-r{N}.md` - 技术方案
59
+ - `implementation.md`、`implementation-r*.md` - 实现报告
60
+ - `refinement.md`、`refinement-r*.md` - 修复报告
61
+ - `review.md`、`review-r*.md` - 审查报告
62
+
63
+ ### 5. 探测交付状态
64
+
65
+ 依次执行以下探测;任一步失败时,降级到“模式 C:开发中”,不要编造无法确认的信息。
66
+
67
+ 在开始探测前,先获取仓库坐标和绝对 URL 前缀:
68
+
69
+ ```bash
70
+ repo="$(gh repo view --json nameWithOwner --jq '.nameWithOwner')"
71
+ owner="${repo%%/*}"
72
+ repo_url="https://github.com/$repo"
73
+ ```
74
+
75
+ **a) 提取 commit hash**
76
+
77
+ 从 task.md 的 `## Activity Log` 中匹配最后一条 `**Commit** by` 记录,活动日志格式固定为:
78
+
79
+ ```text
80
+ **Commit** by {agent} — {hash} {subject}
81
+ ```
82
+
83
+ 提取第一个词作为 commit hash;如果找不到,标记为“无 commit”。
84
+
85
+ **b) 检测 commit 是否在受保护分支上**
86
+
87
+ 如果存在 commit hash,执行:
88
+
89
+ ```bash
90
+ git branch -a --contains {commit-hash} 2>/dev/null
91
+ ```
92
+
93
+ 判断规则:
94
+ - 输出包含 `main` 或 `master` -> 已合入主分支,记录分支名
95
+ - 输出匹配 `{major}.{minor}.x` 模式的分支名 -> 已合入版本分支,记录分支名
96
+ - 都不匹配 -> 未合入受保护分支
97
+
98
+ **c) 检测关联 PR**
99
+
100
+ 检查 task.md 的 `pr_number` 字段;如果存在,执行:
101
+
102
+ ```bash
103
+ gh pr view {pr-number} --json state,mergedAt
104
+ ```
105
+
106
+ 根据返回结果识别 PR 是 `OPEN`、`MERGED` 还是其他状态。
107
+
108
+ **d) 检测 Issue 状态**
109
+
110
+ 执行:
111
+
112
+ ```bash
113
+ gh issue view {issue-number} --json state
114
+ ```
115
+
116
+ 记录 Issue 当前是 `OPEN` 还是 `CLOSED`。
117
+
118
+ **e) 综合判定交付模式**
119
+
120
+ 按以下优先级确定摘要模式:
121
+
122
+ | 条件 | 模式 |
123
+ |------|------|
124
+ | commit 已在受保护分支上 | 模式 A:已完成 |
125
+ | 有 PR,且状态为 `OPEN` 或 `MERGED` | 模式 B:PR 阶段 |
126
+ | 其他情况 | 模式 C:开发中 |
127
+
128
+ 优先级必须为 `模式 A > 模式 B > 模式 C`。即使存在 PR,只要 commit 已在受保护分支上,也按“已完成”处理。
129
+
130
+ 后续所有 commit / PR 链接必须使用绝对 URL:
131
+ - `https://github.com/{owner}/{repo}/commit/{commit-hash}`
132
+ - `https://github.com/{owner}/{repo}/pull/{pr-number}`
133
+
134
+ 不要再使用 `../../commit/...` 或 `../../pull/...` 这类相对路径。
135
+
136
+ ### 6. 同步 Labels 和 Issue Type
137
+
138
+ 基于步骤 5 的探测结果同步 Issue labels。
139
+
140
+ **a) 检查 label 体系是否已初始化**
141
+
142
+ 执行:
143
+
144
+ ```bash
145
+ gh label list --search "type:" --limit 1 --json name --jq 'length'
146
+ ```
147
+
148
+ 判断规则:
149
+ - 返回 `0` -> 说明标准 label 体系缺失。先执行 `init-labels` 技能(幂等),然后重新执行本步骤
150
+ - 返回非 `0` -> 继续后续 label 同步
151
+
152
+ **b) 同步 type label**
153
+
154
+ 根据 task.md 的 `type` 字段按下表映射:
155
+
156
+ | task.md type | GitHub label |
157
+ |---|---|
158
+ | bug、bugfix | `type: bug` |
159
+ | feature | `type: feature` |
160
+ | enhancement | `type: enhancement` |
161
+ | documentation | `type: documentation` |
162
+ | dependency-upgrade | `type: dependency-upgrade` |
163
+ | task | `type: task` |
164
+ | 其他(含 refactoring 等) | 跳过 |
165
+
166
+ 如果映射到具体 label,执行:
167
+
168
+ ```bash
169
+ gh issue edit {issue-number} --add-label "{type-label}"
170
+ ```
171
+
172
+ 未映射到标准 type label 时跳过,不创建新 label。
173
+
174
+ **c) 同步 status label**
175
+
176
+ 先读取 Issue 上已有的 `status:` labels:
177
+
178
+ ```bash
179
+ gh issue view {issue-number} --json labels --jq '.labels[].name | select(startswith("status:"))'
180
+ ```
181
+
182
+ 对每个已有的 `status:` label 执行移除:
183
+
184
+ ```bash
185
+ gh issue edit {issue-number} --remove-label "{status-label}"
186
+ ```
187
+
188
+ 然后按以下优先级决定是否添加新的 `status:` label:
189
+
190
+ | 条件 | 动作 |
191
+ |---|---|
192
+ | 任务位于 `blocked/` 目录 | 添加 `status: blocked` |
193
+ | 模式 A:已完成 | 不添加新的 status label |
194
+ | 模式 B:PR 已 MERGED | 不添加新的 status label |
195
+ | 模式 B:PR OPEN | 添加 `status: in-progress` |
196
+ | 模式 C + `current_step` ∈ {`requirement-analysis`, `technical-design`} | 添加 `status: pending-design-work` |
197
+ | 模式 C + `current_step` ∈ {`implementation`, `code-review`, `refinement`} | 添加 `status: in-progress` |
198
+
199
+ 如果需要添加新 label,执行:
200
+
201
+ ```bash
202
+ gh issue edit {issue-number} --add-label "{status-label}"
203
+ ```
204
+
205
+ **d) 同步 in: label**
206
+
207
+ 从实现报告(优先)或 `analysis.md` 中提取受影响文件路径:
208
+ - 优先读取 `implementation.md` 与 `implementation-r*.md` 中 `## 修改文件` / `## 新建文件` 的文件列表
209
+ - 如果实现报告不存在,则回退到分析报告中的受影响文件列表
210
+
211
+ 对每个文件路径:
212
+ 1. 取第一级目录作为模块名
213
+ 2. 去重
214
+ 3. 检查仓库中是否存在对应 label:
215
+
216
+ ```bash
217
+ gh label list --search "in: {module}" --limit 10 --json name --jq '.[].name'
218
+ ```
219
+
220
+ 4. 只有存在精确匹配的 `in: {module}` label 时才执行:
221
+
222
+ ```bash
223
+ gh issue edit {issue-number} --add-label "in: {module}"
224
+ ```
225
+
226
+ 5. **只添加,不移除**现有的 `in:` labels
227
+
228
+ **e) 同步 Issue Type 字段**
229
+
230
+ 根据 task.md 的 `type` 字段映射 GitHub 原生 Issue Type:
231
+
232
+ | task.md type | GitHub Issue Type |
233
+ |---|---|
234
+ | `bug`、`bugfix` | `Bug` |
235
+ | `feature`、`enhancement` | `Feature` |
236
+ | `task`、`documentation`、`dependency-upgrade`、`chore`、`docs`、`refactor`、`refactoring` 及其他值 | `Task` |
237
+
238
+ 先查询组织可用的 Issue Types:
239
+
240
+ ```bash
241
+ gh api "orgs/$owner/issue-types" --jq '.[].name'
242
+ ```
243
+
244
+ 然后仅在目标类型存在时执行:
245
+
246
+ ```bash
247
+ gh api "repos/$repo/issues/{issue-number}" -X PATCH -f type="{name}"
248
+ ```
249
+
250
+ 容错要求:
251
+ - 如果 API 返回 `404`、仓库 owner 不是组织,或仓库未启用 Issue Types,记录 `Issue Type: skipped (not enabled)` 并继续,不要让整个同步失败
252
+ - 如果目标类型不存在,记录 `Issue Type: skipped (type not available)`
253
+ - 不要尝试创建新的 Issue Type;只使用组织中已存在的类型名称
254
+
255
+ ### 7. 同步 Development
256
+
257
+ 如果 task.md 包含 `pr_number`,确保 PR body 关联当前 Issue。
258
+
259
+ 1. 读取 PR body:
260
+
261
+ ```bash
262
+ gh pr view {pr-number} --json body --jq '.body // ""'
263
+ ```
264
+
265
+ 2. 检查 body 是否已经包含以下任一关键词:
266
+ - `Closes #{issue-number}`
267
+ - `Fixes #{issue-number}`
268
+ - `Resolves #{issue-number}`
269
+
270
+ 3. 如果已存在任一关键词,跳过更新
271
+ 4. 如果不存在,在 body 末尾追加:
272
+
273
+ ```bash
274
+ gh pr edit {pr-number} --body "$(cat <<'EOF'
275
+ {existing-body}
276
+
277
+ Closes #{issue-number}
278
+ EOF
279
+ )"
280
+ ```
281
+
282
+ 5. 如果 task.md 不包含 `pr_number`,记录为 `Development: N/A`
283
+
284
+ ### 8. 同步 Milestone
285
+
286
+ 根据 Issue 当前状态、任务显式配置和分支策略,为 Issue 关联线里程碑。
287
+
288
+ **a) 检查 Issue 是否已有 Milestone**
289
+
290
+ 执行:
291
+
292
+ ```bash
293
+ gh issue view {issue-number} --json milestone --jq '.milestone.title // empty'
294
+ ```
295
+
296
+ 如果返回非空,保留现有里程碑并记录 `Milestone: {existing} (preserved)`,跳过后续里程碑同步步骤。
297
+
298
+ **b) 检查 task.md 是否显式指定 milestone**
299
+
300
+ 如果 task.md frontmatter 中存在非空 `milestone` 字段,优先使用该值作为目标里程碑。
301
+ 此字段应填写线里程碑标题或 `General Backlog`,不要自动指定具体版本里程碑。
302
+
303
+ **c) 推断目标线里程碑**
304
+
305
+ 当 task.md 未显式指定 `milestone` 时,按以下顺序推断:
306
+
307
+ 1. 检测当前分支:
308
+
309
+ ```bash
310
+ git branch --show-current
311
+ ```
312
+
313
+ - 如果分支名匹配 `{major}.{minor}.x`,目标里程碑为同名线里程碑 `{major}.{minor}.x`
314
+
315
+ 2. 如果当前分支是 `main` 或 `master`,检测现有版本分支:
316
+
317
+ ```bash
318
+ git branch -a | grep -oE '[0-9]+\.[0-9]+\.x' | sort -V | tail -1
319
+ ```
320
+
321
+ - 如果存在最高版本分支 `X.Y.x`,则目标里程碑为 `(X+1).0.x`
322
+ - 如果不存在版本分支,则读取最新 tag:
323
+
324
+ ```bash
325
+ git tag --list 'v*' --sort=-v:refname | head -1
326
+ ```
327
+
328
+ - 当最新 tag 存在且可解析为 `X.Y.Z` 时,目标里程碑为 `X.Y.x`
329
+
330
+ 3. 如果以上规则都无法得出结果,回退到 `General Backlog`
331
+
332
+ **d) 查找目标里程碑编号**
333
+
334
+ 执行:
335
+
336
+ ```bash
337
+ gh api "repos/$repo/milestones" --paginate \
338
+ --jq '.[] | select(.title=="{target}") | .number'
339
+ ```
340
+
341
+ - 如果目标里程碑不存在,则降级到查找 `General Backlog`
342
+ - 如果 `General Backlog` 也不存在,则记录 `Milestone: skipped (not found)` 并跳过关联
343
+
344
+ **e) 关联 Issue 到里程碑**
345
+
346
+ 一旦找到目标里程碑编号,执行:
347
+
348
+ ```bash
349
+ gh api "repos/$repo/issues/{issue-number}" -X PATCH -F milestone={milestone-number}
350
+ ```
351
+
352
+ 记录:
353
+ - `Milestone: {target} (assigned)` 或
354
+ - `Milestone: General Backlog (fallback)`
355
+
356
+ ### 9. 拉取已有评论并构建已发布文件集合
357
+
358
+ 一次性拉取 Issue 的全部评论,并基于隐藏标识构建“已发布文件 stem 集合”,同时在本地构建待发布的产物时间线。
359
+
360
+ 先拉取评论(保留 comment id 与 body):
361
+
362
+ ```bash
363
+ comments_jsonl="$(mktemp)"
364
+
365
+ gh api "repos/$repo/issues/{issue-number}/comments" \
366
+ --paginate \
367
+ --jq '.[] | {id, body}' > "$comments_jsonl"
368
+ ```
369
+
370
+ 从 `task.md` 的 Activity Log 中提取所有以 `→ {filename}` 结尾的记录。
371
+
372
+ 解析规则:
373
+ - 使用正则 `/→\s+(\S+\.md)\s*$/` 提取文件名
374
+ - 去掉 `.md` 后缀得到 `{file-stem}`
375
+ - 按 Activity Log 中的出现顺序构建产物时间线
376
+ - `summary` 仍作为最后一个固定产物追加到时间线末尾
377
+ - `summary` 始终排在最末
378
+
379
+ 仅当 Activity Log 引用的文件当前存在于任务目录中时,才纳入待发布集合;缺失文件跳过,不报错。
380
+
381
+ 每条同步评论的第一行必须插入隐藏标识:
382
+
383
+ ```html
384
+ <!-- sync-issue:{task-id}:{file-stem} -->
385
+ ```
386
+
387
+ 其中 `{file-stem}` 为去掉 `.md` 后缀后的文件名,例如 `analysis`、`plan`、`implementation`、`implementation-r2`、`review-r3`;`summary` 仍使用字面量 `summary`。
388
+
389
+ 时间线示例:
390
+ `analysis → plan → implementation → review → refinement → analysis-r2 → plan-r2 → implementation-r2 → review-r2 → summary`
391
+
392
+ 对每个 `{file-stem}`,用本地检索判断是否已发布:
393
+
394
+ ```bash
395
+ grep -qF "<!-- sync-issue:{task-id}:{file-stem} -->" "$comments_jsonl"
396
+ ```
397
+
398
+ - 匹配到:该产物已发布,后续默认跳过
399
+ - 未匹配:该产物尚未发布,可以创建新评论
400
+
401
+ 对 `summary` 产物,额外提取评论 id 以便后续更新:
402
+
403
+ ```bash
404
+ summary_comment_id="$(
405
+ jq -r 'select(.body | contains("<!-- sync-issue:{task-id}:summary -->")) | .id' \
406
+ "$comments_jsonl" | head -1
407
+ )"
408
+ ```
409
+
410
+ 幂等要求:
411
+ - 第一次执行时,只发布当前已存在产物对应的文件评论
412
+ - 第二次执行时,必须跳过已发布文件,只补发新增产物(例如 `implementation-r2`、`review-r2`)
413
+ - 如果所有产物文件评论都已发布,且 `summary` 内容没有变化,则本次不发布任何新评论
414
+ - 如果 `summary` 已发布但交付状态发生变化,只更新原评论,不新增第二条 summary 评论
415
+
416
+ ### 10. 按时间线逐条发布上下文文件
417
+
418
+ 按步骤 9 生成的已排序产物列表逐条处理,不要再使用固定 5 步骤,也不要把同类型多轮次产物合并到一条评论。
419
+
420
+ **a) 为每个产物准备评论内容**
421
+
422
+ - `analysis`:发布 `analysis.md` 原文
423
+ - `plan`:发布 `plan.md` 原文
424
+ - `analysis-r{N}`、`plan-r{N}`:每个文件各自发布一条评论,正文直接使用对应产物原文
425
+ - `implementation`、`implementation-r{N}`:每个文件各自发布一条评论,正文直接使用对应实现报告原文
426
+ - `refinement`、`refinement-r{N}`:每个文件各自发布一条评论,正文直接使用对应修复报告原文
427
+ - `review`、`review-r{N}`:每个文件各自发布一条评论,正文直接使用对应审查报告原文
428
+ - `summary`:生成精简交付摘要,只包含当前交付状态与 GitHub 上可访问的绝对链接
429
+
430
+ 除 `summary` 外,其余产物都应发布原文,不要再次压缩成摘要。
431
+
432
+ 每条评论统一格式:
433
+
434
+ ```markdown
435
+ <!-- sync-issue:{task-id}:{file-stem} -->
436
+ ## {产物标题}
437
+
438
+ {原文内容或 summary 内容}
439
+
440
+ ---
441
+ *由 AI 自动生成 · 内部追踪:{task-id}*
442
+ ```
443
+
444
+ 推荐标题映射:
445
+ - `analysis` -> `需求分析`
446
+ - `analysis-r2` -> `需求分析(Round 2)`
447
+ - `analysis-r{N}` -> `需求分析(Round {N})`
448
+ - `plan` -> `技术方案`
449
+ - `plan-r2` -> `技术方案(Round 2)`
450
+ - `plan-r{N}` -> `技术方案(Round {N})`
451
+ - `implementation` -> `实现报告(Round 1)`
452
+ - `implementation-r2` -> `实现报告(Round 2)`
453
+ - `implementation-r{N}` -> `实现报告(Round {N})`
454
+ - `refinement` -> `修复报告(Round 1)`
455
+ - `refinement-r2` -> `修复报告(Round 2)`
456
+ - `refinement-r{N}` -> `修复报告(Round {N})`
457
+ - `review` -> `审查报告(Round 1)`
458
+ - `review-r2` -> `审查报告(Round 2)`
459
+ - `review-r{N}` -> `审查报告(Round {N})`
460
+ - `summary` -> `交付摘要`
461
+
462
+ `summary` 评论建议格式:
463
+
464
+ ```markdown
465
+ <!-- sync-issue:{task-id}:summary -->
466
+ ## 交付摘要
467
+
468
+ **更新时间**:{当前时间}
469
+ **状态**:{模式化状态描述}
470
+
471
+ | 类型 | 内容 |
472
+ |---|---|
473
+ | 分支 | `{branch 或 N/A}` |
474
+ | Commit | [`{commit-short}`](https://github.com/{owner}/{repo}/commit/{commit-hash}) 或 `N/A` |
475
+ | PR | [#{pr-number}](https://github.com/{owner}/{repo}/pull/{pr-number}) 或 `N/A` |
476
+ | Issue | `{issue-state}` |
477
+
478
+ ---
479
+ *由 AI 自动生成 · 内部追踪:{task-id}*
480
+ ```
481
+
482
+ 模式化状态描述要求:
483
+ - 模式 A:`✅ 已完成,代码已合入 {branch}`
484
+ - 模式 B:`PR 阶段,当前为 #{pr-number}(OPEN 或 MERGED)`
485
+ - 模式 C:`开发中,当前步骤为 {current_step}`
486
+
487
+ **b) 跳过已发布或缺失的产物**
488
+
489
+ - 对于 `analysis.md`、`plan.md`、`implementation*.md`、`review*.md`:如果对应文件不存在,直接跳过,不报错
490
+ - 对于任意产物:如果标识已存在,默认跳过
491
+ - 对于 `summary`:即使标识已存在,也要重新生成候选内容,用于比较是否需要更新
492
+
493
+ **c) 发布新评论**
494
+
495
+ 当产物尚未发布时,执行:
496
+
497
+ ```bash
498
+ gh issue comment {issue-number} --body "$(cat <<'EOF'
499
+ {comment-body}
500
+ EOF
501
+ )"
502
+ ```
503
+
504
+ **d) 仅更新已有 summary 评论**
505
+
506
+ 如果 `summary` 标识已存在,且新生成内容与已有内容不同,则编辑原评论:
507
+
508
+ ```bash
509
+ gh api "repos/$repo/issues/comments/{comment-id}" -X PATCH -f body="$(cat <<'EOF'
510
+ {comment-body}
511
+ EOF
512
+ )"
513
+ ```
514
+
515
+ 如果内容相同,则不做任何操作。
516
+
517
+ **e) 零操作场景**
518
+
519
+ 如果所有产物都已同步,且 `summary` 无需更新:
520
+ - 不发布任何新评论
521
+ - 在最终告知用户时明确说明:`所有产物已同步,无新内容`
522
+
523
+ ### 11. 更新任务状态
524
+
525
+ 获取当前时间:
526
+
527
+ ```bash
528
+ date "+%Y-%m-%d %H:%M:%S"
529
+ ```
530
+
531
+ 在 task.md 中添加或更新 `last_synced_at` 字段为 `{当前时间}`。
532
+ - **追加**到 `## Activity Log`(不要覆盖之前的记录):
533
+ ```
534
+ - {yyyy-MM-dd HH:mm:ss} — **Sync to Issue** by {agent} — Progress synced to Issue #{issue-number}
535
+ ```
536
+
537
+ ### 12. 告知用户
538
+
539
+ ```
540
+ 进度已同步到 Issue #{issue-number}。
541
+
542
+ 同步结果:
543
+ - 新发布评论:{数量}
544
+ - 更新评论:{数量}
545
+ - 已跳过步骤:{步骤列表或 `无`}
546
+ - 当前状态:{状态}
547
+ - Labels:type={type-label 或 skipped},status={status-label 或 cleared},in:={新增数量}
548
+ - Issue Type:{Bug / Feature / Task / skipped}
549
+ - Milestone:{preserved / assigned / fallback / skipped}
550
+ - Development:{已追加 Closes 关联 / 已存在关联 / 无 PR,跳过}
551
+
552
+ 查看:https://github.com/{owner}/{repo}/issues/{issue-number}
553
+
554
+ 如果本次没有发布或更新任何评论,请明确说明:所有步骤已同步,无新内容。
555
+ ```
556
+
557
+ ## 注意事项
558
+
559
+ 1. **需要 Issue 编号**:任务的 task.md 中必须有 `issue_number`。如果缺失,提示用户。
560
+ 2. **受众**:`sync-issue` 技能面向利益相关者;`sync-pr` 技能面向代码审查者。关注点不同。
561
+ 3. **同步时机**:在完成重要阶段(分析、设计、实现、审查)或被阻塞时同步。
562
+ 4. **避免刷屏**:不要同步过于频繁。虽然本技能使用隐藏标识保证幂等,但仍应避免无意义重复同步。
563
+
564
+ ## 错误处理
565
+
566
+ - 任务未找到:提示 "Task {task-id} not found"
567
+ - 缺少 Issue 编号:提示 "Task has no issue_number field"
568
+ - Issue 未找到:提示 "Issue #{number} not found"
569
+ - gh 认证失败:提示 "Please check GitHub CLI authentication"
@@ -0,0 +1,142 @@
1
+ ---
2
+ name: sync-pr
3
+ description: >
4
+ 将任务处理进度同步到对应的 Pull Request 评论。
5
+ 当用户要求同步进度到 PR 时触发。参数:task-id。
6
+ ---
7
+
8
+ # 同步进度到 PR
9
+
10
+ 将任务处理进度同步到关联的 Pull Request。参数:task-id。
11
+
12
+ ## 执行流程
13
+
14
+ ### 1. 验证任务存在
15
+
16
+ 按优先顺序搜索任务:
17
+ - `.agent-workspace/active/{task-id}/task.md`
18
+ - `.agent-workspace/completed/{task-id}/task.md`
19
+ - `.agent-workspace/blocked/{task-id}/task.md`
20
+
21
+ 注意:`{task-id}` 格式为 `TASK-{yyyyMMdd-HHmmss}`,例如 `TASK-20260306-143022`
22
+
23
+ ### 2. 读取任务信息
24
+
25
+ 从 task.md 中提取:
26
+ - `pr_number`(必需 —— 如果缺失,提示用户)
27
+ - 任务标题、描述、状态
28
+ - `current_step`、`created_at`、`updated_at`
29
+ - `issue_number`(如适用)
30
+
31
+ ### 3. 读取上下文文件
32
+
33
+ 检查并读取(如存在):
34
+ - 最高轮次的 `analysis.md` / `analysis-r{N}.md` - 需求分析
35
+ - 最高轮次的 `plan.md` / `plan-r{N}.md` - 技术方案
36
+ - `implementation.md`、`implementation-r{N}.md` - 实现报告
37
+ - `refinement.md`、`refinement-r{N}.md` - 修复报告
38
+ - `review.md`、`review-r{N}.md` - 审查报告
39
+
40
+ ### 4. 生成进度摘要
41
+
42
+ 生成面向**代码审查者**的清晰进度摘要:
43
+
44
+ ```markdown
45
+ ## 开发进度更新
46
+
47
+ **任务 ID**:{task-id}
48
+ **更新时间**:{当前时间}
49
+ **状态**:{状态描述}
50
+
51
+ ### 已完成步骤
52
+
53
+ - [x] 需求分析 - {完成时间}
54
+ - {1-2 个关键要点}
55
+ - [x] 技术设计 - {完成时间}
56
+ - {关键决策}
57
+ - [x] 实现 - {完成时间}
58
+ - 修改文件数:{数量}
59
+ - 新增测试数:{数量}
60
+ - [ ] 代码审查(进行中)
61
+ - [ ] 最终合并
62
+
63
+ ### 当前进度
64
+
65
+ {当前步骤的详细描述}
66
+
67
+ ### 下一步
68
+
69
+ {接下来需要做什么}
70
+
71
+ ### 技术亮点
72
+
73
+ {供审查者参考的关键技术决策和实现细节}
74
+
75
+ ### 相关文档
76
+
77
+ - 任务:`.agent-workspace/{status}/{task-id}/task.md`
78
+ - 分析:`.agent-workspace/{status}/{task-id}/{analysis-artifact}`
79
+ - 方案:`.agent-workspace/{status}/{task-id}/{plan-artifact}`
80
+ - 实现:`.agent-workspace/{status}/{task-id}/{implementation-artifact}`
81
+ - 修复:`.agent-workspace/{status}/{task-id}/{refinement-artifact}`(如存在)
82
+
83
+ ---
84
+ *由 AI 自动生成 - [任务管理](.agents/README.md)*
85
+ ```
86
+
87
+ **摘要原则**:
88
+ - **面向审查者**:突出技术决策和实现细节
89
+ - **简洁**:每个阶段仅提取关键要点
90
+ - **逻辑清晰**:按时间顺序呈现进度
91
+ - **便于审查**:解释关键变更的原因
92
+
93
+ ### 5. 发布到 PR
94
+
95
+ ```bash
96
+ gh pr comment {pr-number} --body "$(cat <<'EOF'
97
+ {生成的摘要}
98
+ EOF
99
+ )"
100
+ ```
101
+
102
+ ### 6. 更新任务状态
103
+
104
+ 获取当前时间:
105
+
106
+ ```bash
107
+ date "+%Y-%m-%d %H:%M:%S"
108
+ ```
109
+
110
+ 在 task.md 中添加或更新 `last_synced_to_pr_at` 字段为 `{当前时间}`。
111
+ - **追加**到 `## Activity Log`(不要覆盖之前的记录):
112
+ ```
113
+ - {yyyy-MM-dd HH:mm:ss} — **Sync to PR** by {agent} — Progress synced to PR #{pr-number}
114
+ ```
115
+
116
+ ### 7. 告知用户
117
+
118
+ ```
119
+ 进度已同步到 PR #{pr-number}。
120
+
121
+ 已同步内容:
122
+ - 已完成步骤:{数量}
123
+ - 当前状态:{状态}
124
+ - 下一步:{描述}
125
+
126
+ 查看:https://github.com/{owner}/{repo}/pull/{pr-number}
127
+ ```
128
+
129
+ ## 注意事项
130
+
131
+ 1. **需要 PR 编号**:任务的 task.md 中必须有 `pr_number`。如果缺失,提示用户。
132
+ 2. **受众**:`sync-pr` 技能面向代码审查者;`sync-issue` 技能面向利益相关者。关注点不同。
133
+ 3. **同步时机**:在完成重要阶段后同步,而不是每个小变更后都同步。
134
+ 4. **避免刷屏**:不要同步过于频繁 —— 合并更新内容。
135
+
136
+ ## 错误处理
137
+
138
+ - 任务未找到:提示 "Task {task-id} not found"
139
+ - 缺少 PR 编号:提示 "Task has no pr_number field"
140
+ - PR 未找到:提示 "PR #{number} not found"
141
+ - PR 已关闭:提示 "PR #{number} is already closed"
142
+ - gh 认证失败:提示 "Please check GitHub CLI authentication"