@fitlab-ai/agent-infra 0.8.5 → 0.9.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 (425) hide show
  1. package/bin/cli.ts +2 -2
  2. package/dist/bin/cli.js +2 -2
  3. package/dist/bin/internal-cli.js +98 -0
  4. package/dist/lib/decide.js +81 -90
  5. package/dist/lib/defaults.json +1 -0
  6. package/dist/lib/git/review-snapshot.js +79 -0
  7. package/dist/lib/git/workflow.js +101 -0
  8. package/dist/lib/internal/git-workflow.js +42 -0
  9. package/dist/lib/internal/platform-checks.js +119 -0
  10. package/dist/lib/internal/platform-comment.js +129 -0
  11. package/dist/lib/internal/platform-context.js +46 -0
  12. package/dist/lib/internal/platform-issue.js +142 -0
  13. package/dist/lib/internal/platform-pr.js +146 -0
  14. package/dist/lib/internal/release-workflow.js +217 -0
  15. package/dist/lib/internal/task-artifact.js +67 -0
  16. package/dist/lib/internal/task-context.js +43 -0
  17. package/dist/lib/internal/task-event.js +70 -0
  18. package/dist/lib/internal/task-ledger.js +114 -0
  19. package/dist/lib/internal/task-lifecycle.js +58 -0
  20. package/dist/lib/internal/task-short-id.js +83 -0
  21. package/dist/lib/internal/task-snapshot.js +47 -0
  22. package/dist/lib/internal/task-verify.js +50 -0
  23. package/dist/lib/internal/task-warning.js +74 -0
  24. package/dist/lib/platform/adapters.js +14 -0
  25. package/dist/lib/platform/context.js +146 -0
  26. package/dist/lib/platform/github-client.js +124 -0
  27. package/dist/lib/platform/issue-comments.js +409 -0
  28. package/dist/lib/platform/issue-metadata.js +183 -0
  29. package/dist/lib/platform/issues.js +617 -0
  30. package/dist/lib/platform/metadata-labels.js +28 -0
  31. package/dist/lib/platform/pr-checks.js +216 -0
  32. package/dist/lib/platform/pr-summary.js +88 -0
  33. package/dist/lib/platform/pull-request-metadata.js +38 -0
  34. package/dist/lib/platform/pull-requests.js +338 -0
  35. package/dist/lib/platform/releases.js +82 -0
  36. package/dist/lib/platform/types.js +22 -0
  37. package/dist/lib/platform/verification-required.js +78 -0
  38. package/dist/lib/platform/verification-sync.js +1014 -0
  39. package/dist/lib/platform/verification.js +6 -0
  40. package/dist/lib/release/channels.js +31 -0
  41. package/dist/lib/release/workflow.js +32 -0
  42. package/dist/lib/render.js +3 -2
  43. package/dist/lib/run/index.js +24 -7
  44. package/dist/lib/sandbox/capture.js +25 -3
  45. package/dist/lib/sandbox/commands/create.js +36 -22
  46. package/dist/lib/sandbox/commands/enter.js +34 -11
  47. package/dist/lib/sandbox/commands/list-running.js +10 -8
  48. package/dist/lib/sandbox/commands/show.js +2 -2
  49. package/dist/lib/sandbox/commands/start.js +53 -15
  50. package/dist/lib/sandbox/index.js +6 -6
  51. package/dist/lib/sandbox/mounts.js +36 -0
  52. package/dist/lib/sandbox/recovery.js +562 -0
  53. package/dist/lib/sandbox/task-resolver.js +5 -1
  54. package/dist/lib/sandbox/tools.js +19 -0
  55. package/dist/lib/server/protocol.js +5 -5
  56. package/dist/lib/task/activity-log.js +61 -0
  57. package/dist/lib/task/artifact-lifecycle.js +427 -0
  58. package/dist/lib/task/command-options.js +30 -0
  59. package/dist/lib/task/commands/cat.js +36 -6
  60. package/dist/lib/task/commands/decisions.js +80 -46
  61. package/dist/lib/task/commands/files.js +21 -7
  62. package/dist/lib/task/commands/grep.js +55 -7
  63. package/dist/lib/task/commands/issue-body.js +23 -14
  64. package/dist/lib/task/commands/log.js +27 -70
  65. package/dist/lib/task/commands/show.js +20 -7
  66. package/dist/lib/task/commands/status.js +18 -8
  67. package/dist/lib/task/decision-intents.js +154 -0
  68. package/dist/lib/task/decision-items.js +53 -0
  69. package/dist/lib/task/events.js +318 -0
  70. package/dist/lib/task/frontmatter.js +159 -1
  71. package/dist/lib/task/implementation-inputs.js +117 -0
  72. package/dist/lib/task/index.js +12 -9
  73. package/dist/lib/task/issue-form.js +19 -6
  74. package/dist/lib/task/ledger-intents.js +185 -0
  75. package/dist/lib/task/ledger.js +65 -35
  76. package/dist/lib/task/lifecycle.js +484 -0
  77. package/dist/lib/task/resolve-ref.js +152 -32
  78. package/dist/lib/task/review-artifacts.js +101 -0
  79. package/dist/lib/task/review-fingerprint.js +46 -0
  80. package/dist/lib/task/sections.js +358 -4
  81. package/dist/lib/task/short-id.js +292 -7
  82. package/dist/lib/task/snapshot.js +95 -0
  83. package/dist/lib/task/verification-checks.js +8 -0
  84. package/dist/lib/task/verification-config.js +14 -0
  85. package/dist/lib/task/verification-engine.js +906 -0
  86. package/dist/lib/task/verification-review.js +3 -0
  87. package/dist/lib/task/verification-types.js +2 -0
  88. package/dist/lib/task/verification.js +113 -0
  89. package/dist/lib/task/workflow-warning-intents.js +131 -0
  90. package/dist/lib/task/workflow-warnings.js +10 -78
  91. package/dist/lib/task/write.js +241 -0
  92. package/lib/decide.ts +57 -97
  93. package/lib/defaults.json +1 -0
  94. package/lib/git/review-snapshot.ts +73 -0
  95. package/lib/git/workflow.ts +101 -0
  96. package/lib/internal/git-workflow.ts +37 -0
  97. package/lib/internal/platform-checks.ts +101 -0
  98. package/lib/internal/platform-comment.ts +99 -0
  99. package/lib/internal/platform-context.ts +33 -0
  100. package/lib/internal/platform-issue.ts +116 -0
  101. package/lib/internal/platform-pr.ts +119 -0
  102. package/lib/internal/release-workflow.ts +186 -0
  103. package/lib/internal/task-artifact.ts +47 -0
  104. package/lib/internal/task-context.ts +35 -0
  105. package/lib/internal/task-event.ts +51 -0
  106. package/lib/internal/task-ledger.ts +86 -0
  107. package/lib/internal/task-lifecycle.ts +41 -0
  108. package/lib/internal/task-short-id.ts +55 -0
  109. package/lib/internal/task-snapshot.ts +32 -0
  110. package/lib/internal/task-verify.ts +33 -0
  111. package/lib/internal/task-warning.ts +50 -0
  112. package/lib/platform/adapters.ts +30 -0
  113. package/lib/platform/context.ts +164 -0
  114. package/lib/platform/github-client.ts +146 -0
  115. package/lib/platform/issue-comments.ts +479 -0
  116. package/lib/platform/issue-metadata.ts +250 -0
  117. package/lib/platform/issues.ts +691 -0
  118. package/lib/platform/metadata-labels.ts +33 -0
  119. package/lib/platform/pr-checks.ts +246 -0
  120. package/lib/platform/pr-summary.ts +90 -0
  121. package/lib/platform/pull-request-metadata.ts +69 -0
  122. package/lib/platform/pull-requests.ts +380 -0
  123. package/lib/platform/releases.ts +71 -0
  124. package/lib/platform/types.ts +74 -0
  125. package/lib/platform/verification-required.ts +83 -0
  126. package/{runtime/platform-adapters/platform-sync.github.js → lib/platform/verification-sync.ts} +198 -367
  127. package/lib/platform/verification.ts +11 -0
  128. package/lib/release/channels.ts +30 -0
  129. package/lib/release/workflow.ts +31 -0
  130. package/lib/render.ts +3 -2
  131. package/lib/run/index.ts +25 -7
  132. package/lib/sandbox/capture.ts +29 -3
  133. package/lib/sandbox/commands/create.ts +43 -25
  134. package/lib/sandbox/commands/enter.ts +38 -11
  135. package/lib/sandbox/commands/list-running.ts +10 -8
  136. package/lib/sandbox/commands/show.ts +2 -2
  137. package/lib/sandbox/commands/start.ts +50 -16
  138. package/lib/sandbox/index.ts +6 -6
  139. package/lib/sandbox/mounts.ts +55 -0
  140. package/lib/sandbox/recovery.ts +828 -0
  141. package/lib/sandbox/task-resolver.ts +5 -1
  142. package/lib/sandbox/tools.ts +31 -0
  143. package/lib/server/protocol.ts +5 -5
  144. package/lib/task/activity-log.ts +62 -0
  145. package/lib/task/artifact-lifecycle.ts +484 -0
  146. package/lib/task/command-options.ts +32 -0
  147. package/lib/task/commands/cat.ts +22 -9
  148. package/lib/task/commands/decisions.ts +49 -47
  149. package/lib/task/commands/files.ts +14 -6
  150. package/lib/task/commands/grep.ts +34 -7
  151. package/lib/task/commands/issue-body.ts +16 -16
  152. package/lib/task/commands/log.ts +17 -70
  153. package/lib/task/commands/show.ts +14 -6
  154. package/lib/task/commands/status.ts +17 -7
  155. package/lib/task/decision-intents.ts +163 -0
  156. package/lib/task/decision-items.ts +64 -0
  157. package/lib/task/events.ts +320 -0
  158. package/lib/task/frontmatter.ts +202 -2
  159. package/lib/task/implementation-inputs.ts +137 -0
  160. package/lib/task/index.ts +12 -9
  161. package/lib/task/issue-form.ts +20 -6
  162. package/lib/task/ledger-intents.ts +201 -0
  163. package/lib/task/ledger.ts +77 -31
  164. package/lib/task/lifecycle.ts +458 -0
  165. package/lib/task/resolve-ref.ts +197 -36
  166. package/{templates/.agents/scripts/lib/review-artifacts.js → lib/task/review-artifacts.ts} +11 -12
  167. package/{templates/.agents/scripts/lib/post-review-commit.js → lib/task/review-fingerprint.ts} +17 -12
  168. package/lib/task/sections.ts +486 -4
  169. package/lib/task/short-id.ts +403 -9
  170. package/lib/task/snapshot.ts +143 -0
  171. package/lib/task/verification-checks.ts +9 -0
  172. package/lib/task/verification-config.ts +20 -0
  173. package/{templates/.agents/scripts/validate-artifact.js → lib/task/verification-engine.ts} +199 -406
  174. package/lib/task/verification-review.ts +9 -0
  175. package/lib/task/verification-types.ts +29 -0
  176. package/lib/task/verification.ts +156 -0
  177. package/lib/task/workflow-warning-intents.ts +142 -0
  178. package/lib/task/workflow-warnings.ts +10 -78
  179. package/lib/task/write.ts +468 -0
  180. package/package.json +4 -2
  181. package/templates/.agents/README.en.md +4 -3
  182. package/templates/.agents/README.zh-CN.md +4 -3
  183. package/templates/.agents/rules/README.en.md +6 -5
  184. package/templates/.agents/rules/README.zh-CN.md +6 -5
  185. package/templates/.agents/rules/create-issue.en.md +1 -1
  186. package/templates/.agents/rules/create-issue.github.en.md +5 -184
  187. package/templates/.agents/rules/create-issue.github.zh-CN.md +12 -178
  188. package/templates/.agents/rules/create-issue.zh-CN.md +1 -1
  189. package/templates/.agents/rules/human-decision-context.en.md +36 -0
  190. package/templates/.agents/rules/human-decision-context.zh-CN.md +36 -0
  191. package/templates/.agents/rules/issue-fields.github.en.md +4 -148
  192. package/templates/.agents/rules/issue-fields.github.zh-CN.md +9 -144
  193. package/templates/.agents/rules/issue-pr-commands.en.md +43 -3
  194. package/templates/.agents/rules/issue-pr-commands.github.en.md +15 -220
  195. package/templates/.agents/rules/issue-pr-commands.github.zh-CN.md +23 -213
  196. package/templates/.agents/rules/issue-pr-commands.zh-CN.md +45 -3
  197. package/templates/.agents/rules/issue-sync.en.md +1 -1
  198. package/templates/.agents/rules/issue-sync.github.en.md +14 -301
  199. package/templates/.agents/rules/issue-sync.github.zh-CN.md +36 -287
  200. package/templates/.agents/rules/issue-sync.zh-CN.md +1 -1
  201. package/templates/.agents/rules/milestone-inference.en.md +1 -1
  202. package/templates/.agents/rules/milestone-inference.github.en.md +7 -119
  203. package/templates/.agents/rules/milestone-inference.github.zh-CN.md +8 -108
  204. package/templates/.agents/rules/milestone-inference.zh-CN.md +1 -1
  205. package/templates/.agents/rules/next-step-output.en.md +12 -11
  206. package/templates/.agents/rules/next-step-output.zh-CN.md +12 -11
  207. package/templates/.agents/rules/no-mid-flow-questions.en.md +3 -3
  208. package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +3 -3
  209. package/templates/.agents/rules/pr-checks-commands.en.md +16 -3
  210. package/templates/.agents/rules/pr-checks-commands.github.en.md +10 -54
  211. package/templates/.agents/rules/pr-checks-commands.github.zh-CN.md +19 -47
  212. package/templates/.agents/rules/pr-checks-commands.zh-CN.md +30 -3
  213. package/templates/.agents/rules/pr-sync.en.md +30 -3
  214. package/templates/.agents/rules/pr-sync.github.en.md +12 -115
  215. package/templates/.agents/rules/pr-sync.github.zh-CN.md +26 -104
  216. package/templates/.agents/rules/pr-sync.zh-CN.md +43 -3
  217. package/templates/.agents/rules/review-handshake.en.md +8 -5
  218. package/templates/.agents/rules/review-handshake.zh-CN.md +8 -5
  219. package/templates/.agents/rules/task-management.en.md +11 -2
  220. package/templates/.agents/rules/task-management.zh-CN.md +11 -3
  221. package/templates/.agents/rules/task-short-id.en.md +25 -29
  222. package/templates/.agents/rules/task-short-id.zh-CN.md +20 -23
  223. package/templates/.agents/scripts/lib/agent-infra-package.js +1 -9
  224. package/templates/.agents/scripts/task-short-id.js +71 -533
  225. package/templates/.agents/skills/analyze-task/SKILL.en.md +22 -55
  226. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +26 -59
  227. package/templates/.agents/skills/analyze-task/config/verify.en.json +1 -3
  228. package/templates/.agents/skills/analyze-task/config/verify.zh-CN.json +1 -3
  229. package/templates/.agents/skills/block-task/SKILL.en.md +21 -47
  230. package/templates/.agents/skills/block-task/SKILL.zh-CN.md +23 -47
  231. package/templates/.agents/skills/block-task/config/verify.json +1 -2
  232. package/templates/.agents/skills/cancel-task/SKILL.en.md +16 -45
  233. package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +16 -45
  234. package/templates/.agents/skills/cancel-task/config/verify.json +1 -2
  235. package/templates/.agents/skills/check-task/SKILL.en.md +6 -3
  236. package/templates/.agents/skills/check-task/SKILL.zh-CN.md +6 -3
  237. package/templates/.agents/skills/close-codescan/SKILL.en.md +6 -24
  238. package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +6 -24
  239. package/templates/.agents/skills/close-dependabot/SKILL.en.md +6 -24
  240. package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +6 -24
  241. package/templates/.agents/skills/code-task/SKILL.en.md +22 -35
  242. package/templates/.agents/skills/code-task/SKILL.zh-CN.md +28 -44
  243. package/templates/.agents/skills/code-task/config/verify.en.json +3 -3
  244. package/templates/.agents/skills/code-task/config/verify.zh-CN.json +3 -3
  245. package/templates/.agents/skills/code-task/reference/dual-mode.en.md +13 -9
  246. package/templates/.agents/skills/code-task/reference/dual-mode.zh-CN.md +13 -9
  247. package/templates/.agents/skills/code-task/reference/fix-mode.en.md +1 -1
  248. package/templates/.agents/skills/code-task/reference/fix-mode.zh-CN.md +1 -1
  249. package/templates/.agents/skills/code-task/reference/report-template.en.md +11 -1
  250. package/templates/.agents/skills/code-task/reference/report-template.zh-CN.md +11 -1
  251. package/templates/.agents/skills/commit/SKILL.en.md +13 -11
  252. package/templates/.agents/skills/commit/SKILL.zh-CN.md +13 -11
  253. package/templates/.agents/skills/commit/config/verify.json +1 -2
  254. package/templates/.agents/skills/commit/reference/commit-message.en.md +1 -11
  255. package/templates/.agents/skills/commit/reference/commit-message.zh-CN.md +1 -11
  256. package/templates/.agents/skills/commit/reference/issue-metadata-sync.en.md +4 -8
  257. package/templates/.agents/skills/commit/reference/issue-metadata-sync.zh-CN.md +4 -8
  258. package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +6 -18
  259. package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +5 -17
  260. package/templates/.agents/skills/commit/reference/task-status-update.en.md +13 -0
  261. package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +13 -0
  262. package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +13 -36
  263. package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +13 -36
  264. package/templates/.agents/skills/complete-manual-validation/config/verify.en.json +1 -3
  265. package/templates/.agents/skills/complete-manual-validation/config/verify.zh-CN.json +1 -3
  266. package/templates/.agents/skills/complete-manual-validation/reference/summary-update.en.md +10 -54
  267. package/templates/.agents/skills/complete-manual-validation/reference/summary-update.zh-CN.md +10 -79
  268. package/templates/.agents/skills/complete-task/SKILL.en.md +59 -63
  269. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +59 -63
  270. package/templates/.agents/skills/complete-task/config/verify.en.json +11 -7
  271. package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +11 -7
  272. package/templates/.agents/skills/create-pr/SKILL.en.md +19 -44
  273. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +19 -43
  274. package/templates/.agents/skills/create-pr/config/verify.json +1 -2
  275. package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +8 -12
  276. package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +7 -11
  277. package/templates/.agents/skills/create-task/SKILL.en.md +12 -13
  278. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +12 -13
  279. package/templates/.agents/skills/create-task/config/verify.json +1 -2
  280. package/templates/.agents/skills/import-codescan/SKILL.en.md +2 -2
  281. package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +2 -2
  282. package/templates/.agents/skills/import-codescan/config/verify.json +1 -2
  283. package/templates/.agents/skills/import-dependabot/SKILL.en.md +2 -2
  284. package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +2 -2
  285. package/templates/.agents/skills/import-dependabot/config/verify.json +1 -2
  286. package/templates/.agents/skills/import-issue/SKILL.en.md +9 -13
  287. package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +10 -14
  288. package/templates/.agents/skills/import-issue/config/verify.json +1 -2
  289. package/templates/.agents/skills/plan-task/SKILL.en.md +17 -42
  290. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +22 -49
  291. package/templates/.agents/skills/plan-task/config/verify.en.json +1 -3
  292. package/templates/.agents/skills/plan-task/config/verify.zh-CN.json +1 -3
  293. package/templates/.agents/skills/post-release/SKILL.en.md +11 -81
  294. package/templates/.agents/skills/post-release/SKILL.zh-CN.md +8 -78
  295. package/templates/.agents/skills/refine-title/SKILL.en.md +1 -1
  296. package/templates/.agents/skills/refine-title/SKILL.zh-CN.md +1 -1
  297. package/templates/.agents/skills/release/SKILL.en.md +16 -163
  298. package/templates/.agents/skills/release/SKILL.zh-CN.md +15 -162
  299. package/templates/.agents/skills/restore-task/SKILL.en.md +11 -29
  300. package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +11 -29
  301. package/templates/.agents/skills/restore-task/config/verify.json +1 -2
  302. package/templates/.agents/skills/review-analysis/SKILL.en.md +13 -25
  303. package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +13 -33
  304. package/templates/.agents/skills/review-analysis/config/verify.en.json +3 -4
  305. package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +3 -4
  306. package/templates/.agents/skills/review-analysis/reference/output-templates.en.md +9 -12
  307. package/templates/.agents/skills/review-analysis/reference/output-templates.zh-CN.md +9 -12
  308. package/templates/.agents/skills/review-analysis/reference/report-template.en.md +9 -2
  309. package/templates/.agents/skills/review-analysis/reference/report-template.zh-CN.md +9 -2
  310. package/templates/.agents/skills/review-analysis/reference/review-criteria.en.md +7 -0
  311. package/templates/.agents/skills/review-analysis/reference/review-criteria.zh-CN.md +7 -0
  312. package/templates/.agents/skills/review-code/SKILL.en.md +22 -36
  313. package/templates/.agents/skills/review-code/SKILL.zh-CN.md +23 -41
  314. package/templates/.agents/skills/review-code/config/verify.en.json +3 -4
  315. package/templates/.agents/skills/review-code/config/verify.zh-CN.json +3 -4
  316. package/templates/.agents/skills/review-code/reference/output-templates.en.md +56 -18
  317. package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +56 -18
  318. package/templates/.agents/skills/review-code/reference/report-template.en.md +11 -4
  319. package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +11 -4
  320. package/templates/.agents/skills/review-code/reference/review-criteria.en.md +7 -0
  321. package/templates/.agents/skills/review-code/reference/review-criteria.zh-CN.md +7 -0
  322. package/templates/.agents/skills/review-plan/SKILL.en.md +13 -25
  323. package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +13 -33
  324. package/templates/.agents/skills/review-plan/config/verify.en.json +3 -4
  325. package/templates/.agents/skills/review-plan/config/verify.zh-CN.json +3 -4
  326. package/templates/.agents/skills/review-plan/reference/output-templates.en.md +9 -12
  327. package/templates/.agents/skills/review-plan/reference/output-templates.zh-CN.md +9 -12
  328. package/templates/.agents/skills/review-plan/reference/report-template.en.md +9 -2
  329. package/templates/.agents/skills/review-plan/reference/report-template.zh-CN.md +9 -2
  330. package/templates/.agents/skills/review-plan/reference/review-criteria.en.md +7 -0
  331. package/templates/.agents/skills/review-plan/reference/review-criteria.zh-CN.md +7 -0
  332. package/templates/.agents/skills/update-agent-infra/SKILL.en.md +1 -2
  333. package/templates/.agents/skills/update-agent-infra/SKILL.zh-CN.md +1 -2
  334. package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +3 -15
  335. package/templates/.agents/skills/watch-pr/SKILL.en.md +24 -14
  336. package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +25 -15
  337. package/templates/.agents/skills/watch-pr/config/verify.json +1 -2
  338. package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +2 -2
  339. package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +2 -2
  340. package/templates/.agents/templates/task.en.md +6 -1
  341. package/templates/.agents/templates/task.zh-CN.md +6 -1
  342. package/templates/.claude/commands/analyze-task.en.md +1 -1
  343. package/templates/.claude/commands/analyze-task.zh-CN.md +1 -1
  344. package/templates/.claude/commands/block-task.en.md +1 -1
  345. package/templates/.claude/commands/block-task.zh-CN.md +1 -1
  346. package/templates/.claude/commands/cancel-task.en.md +1 -1
  347. package/templates/.claude/commands/cancel-task.zh-CN.md +1 -1
  348. package/templates/.claude/commands/check-task.en.md +1 -1
  349. package/templates/.claude/commands/check-task.zh-CN.md +1 -1
  350. package/templates/.claude/commands/code-task.en.md +1 -1
  351. package/templates/.claude/commands/code-task.zh-CN.md +1 -1
  352. package/templates/.claude/commands/commit.en.md +1 -0
  353. package/templates/.claude/commands/commit.zh-CN.md +1 -0
  354. package/templates/.claude/commands/complete-manual-validation.en.md +1 -1
  355. package/templates/.claude/commands/complete-manual-validation.zh-CN.md +1 -1
  356. package/templates/.claude/commands/complete-task.en.md +1 -1
  357. package/templates/.claude/commands/complete-task.zh-CN.md +1 -1
  358. package/templates/.claude/commands/create-pr.en.md +1 -1
  359. package/templates/.claude/commands/create-pr.zh-CN.md +1 -1
  360. package/templates/.claude/commands/plan-task.en.md +1 -1
  361. package/templates/.claude/commands/plan-task.zh-CN.md +1 -1
  362. package/templates/.claude/commands/review-analysis.en.md +1 -1
  363. package/templates/.claude/commands/review-analysis.zh-CN.md +1 -1
  364. package/templates/.claude/commands/review-code.en.md +1 -1
  365. package/templates/.claude/commands/review-code.zh-CN.md +1 -1
  366. package/templates/.claude/commands/review-plan.en.md +1 -1
  367. package/templates/.claude/commands/review-plan.zh-CN.md +1 -1
  368. package/templates/.claude/commands/watch-pr.en.md +1 -1
  369. package/templates/.claude/commands/watch-pr.zh-CN.md +1 -1
  370. package/templates/.gemini/commands/_project_/analyze-task.en.toml +2 -0
  371. package/templates/.gemini/commands/_project_/analyze-task.zh-CN.toml +2 -0
  372. package/templates/.gemini/commands/_project_/block-task.en.toml +2 -0
  373. package/templates/.gemini/commands/_project_/block-task.zh-CN.toml +2 -0
  374. package/templates/.gemini/commands/_project_/cancel-task.en.toml +2 -0
  375. package/templates/.gemini/commands/_project_/cancel-task.zh-CN.toml +2 -0
  376. package/templates/.gemini/commands/_project_/check-task.en.toml +2 -0
  377. package/templates/.gemini/commands/_project_/check-task.zh-CN.toml +2 -0
  378. package/templates/.gemini/commands/_project_/code-task.en.toml +2 -0
  379. package/templates/.gemini/commands/_project_/code-task.zh-CN.toml +2 -0
  380. package/templates/.gemini/commands/_project_/commit.en.toml +4 -0
  381. package/templates/.gemini/commands/_project_/commit.zh-CN.toml +4 -0
  382. package/templates/.gemini/commands/_project_/complete-manual-validation.en.toml +2 -0
  383. package/templates/.gemini/commands/_project_/complete-manual-validation.zh-CN.toml +2 -0
  384. package/templates/.gemini/commands/_project_/complete-task.en.toml +2 -0
  385. package/templates/.gemini/commands/_project_/complete-task.zh-CN.toml +2 -0
  386. package/templates/.gemini/commands/_project_/create-pr.en.toml +2 -0
  387. package/templates/.gemini/commands/_project_/create-pr.zh-CN.toml +2 -0
  388. package/templates/.gemini/commands/_project_/plan-task.en.toml +2 -0
  389. package/templates/.gemini/commands/_project_/plan-task.zh-CN.toml +2 -0
  390. package/templates/.gemini/commands/_project_/review-analysis.en.toml +2 -0
  391. package/templates/.gemini/commands/_project_/review-analysis.zh-CN.toml +2 -0
  392. package/templates/.gemini/commands/_project_/review-code.en.toml +2 -0
  393. package/templates/.gemini/commands/_project_/review-code.zh-CN.toml +2 -0
  394. package/templates/.gemini/commands/_project_/review-plan.en.toml +2 -0
  395. package/templates/.gemini/commands/_project_/review-plan.zh-CN.toml +2 -0
  396. package/templates/.gemini/commands/_project_/watch-pr.en.toml +2 -0
  397. package/templates/.gemini/commands/_project_/watch-pr.zh-CN.toml +2 -0
  398. package/templates/.git-hooks/check-large-files.cjs +92 -0
  399. package/templates/.git-hooks/check-version-format.sh +5 -1
  400. package/templates/.git-hooks/pre-commit +1 -0
  401. package/templates/.opencode/commands/analyze-task.en.md +1 -1
  402. package/templates/.opencode/commands/analyze-task.zh-CN.md +1 -1
  403. package/templates/.opencode/commands/check-task.en.md +1 -1
  404. package/templates/.opencode/commands/check-task.zh-CN.md +1 -1
  405. package/templates/.opencode/commands/code-task.en.md +1 -1
  406. package/templates/.opencode/commands/code-task.zh-CN.md +1 -1
  407. package/templates/.opencode/commands/commit.en.md +2 -0
  408. package/templates/.opencode/commands/commit.zh-CN.md +2 -0
  409. package/templates/.opencode/commands/complete-task.en.md +1 -1
  410. package/templates/.opencode/commands/complete-task.zh-CN.md +1 -1
  411. package/templates/.opencode/commands/plan-task.en.md +1 -1
  412. package/templates/.opencode/commands/plan-task.zh-CN.md +1 -1
  413. package/templates/.opencode/commands/review-analysis.en.md +1 -1
  414. package/templates/.opencode/commands/review-analysis.zh-CN.md +1 -1
  415. package/templates/.opencode/commands/review-code.en.md +1 -1
  416. package/templates/.opencode/commands/review-code.zh-CN.md +1 -1
  417. package/templates/.opencode/commands/review-plan.en.md +1 -1
  418. package/templates/.opencode/commands/review-plan.zh-CN.md +1 -1
  419. package/templates/.agents/scripts/platform-adapters/platform-sync.github.js +0 -40
  420. package/templates/.agents/scripts/platform-adapters/platform-sync.js +0 -13
  421. package/templates/.agents/scripts/review-diff-fingerprint.js +0 -170
  422. package/templates/.agents/scripts/workflow-warnings.js +0 -290
  423. package/templates/.agents/skills/code-task/scripts/detect-mode.js +0 -257
  424. package/templates/.agents/skills/release/scripts/manage-milestones.github.sh +0 -80
  425. package/templates/.agents/skills/release/scripts/manage-milestones.sh +0 -6
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Marker 注册表
4
4
 
5
- 以下隐藏标记是 Issue 同步的唯一权威注册表:
5
+ 以下 key 及格式是 Issue 评论身份的兼容契约;调用方只传 key/资源,不自行拼 marker。
6
6
 
7
7
  | Key | Marker |
8
8
  |---|---|
@@ -12,312 +12,61 @@
12
12
  | `summary` | `<!-- sync-issue:{task-id}:summary -->` |
13
13
  | `cancel` | `<!-- sync-issue:{task-id}:cancel -->` |
14
14
 
15
- Skill 正文应引用 marker key,具体 marker 字符串只保留在本规则或平台适配器默认值中。
15
+ `prSummary` 属于 `.agents/rules/pr-sync.md`,本规则不实现 PR 聚合。
16
16
 
17
- 在任务技能需要更新 GitHub Issue 时先读取本文件。
17
+ ## 平台 intent
18
18
 
19
- ## Upstream 仓库检测
20
-
21
- 外部开发者在 fork 仓库中执行 `gh` 命令时,默认目标会指向 fork,而不是原始仓库。所有后续 `gh issue` 和 `gh api "repos/..."` 操作都必须先检测 upstream 仓库,并统一复用 `upstream_repo`。
22
-
23
- ```bash
24
- upstream_repo=$(gh api "repos/$(gh repo view --json nameWithOwner -q .nameWithOwner)" \
25
- --jq 'if .fork then .parent.full_name else .full_name end' 2>/dev/null)
26
- ```
27
-
28
- - 非 fork 仓库:返回当前仓库自身的 `full_name`
29
- - fork 仓库:返回父仓库的 `full_name`
30
- - 后续所有 `gh issue` 命令统一使用 `-R "$upstream_repo"`
31
- - 后续所有 `gh api "repos/..."` 命令统一使用 `"repos/$upstream_repo/..."`
32
-
33
- ## 权限检测
34
-
35
- 所有需要写权限的操作都先对 upstream 仓库做一次权限检测。检测失败时按无权限处理,确保安全降级。
36
-
37
- ```bash
38
- repo_perms=$(gh api "repos/$upstream_repo" --jq '.permissions' 2>/dev/null || echo '{}')
39
- has_triage=$(printf '%s' "$repo_perms" | grep -q '"triage":true' 2>/dev/null && echo true || echo false)
40
- has_push=$(printf '%s' "$repo_perms" | grep -q '"push":true' 2>/dev/null && echo true || echo false)
41
- ```
42
-
43
- 操作与权限映射:
44
-
45
- | 操作 | 所需权限 | 说明 |
46
- |------|---------|------|
47
- | 设置/移除 label | `has_triage` | triage 是最低权限 |
48
- | 设置/移除 milestone | `has_triage` | 同上 |
49
- | 编辑 Issue body | `has_triage` | 需求复选框同步使用 |
50
- | 设置 Issue Type | `has_push` | 需要 write 权限 |
51
- | 设置 Issue 字段 | `has_push` | pinned custom fields;失败不阻断 |
52
- | 设置 assignee | 不检测 | 无权限时直接跳过 |
53
- | 发布/更新评论 | 无需检测 | 公开仓库中认证用户可执行 |
54
-
55
- ## 降级行为定义
56
-
57
- | 层级 | 操作类型 | 有权限 | 无权限 |
58
- |------|---------|--------|--------|
59
- | 静默降级 | label / milestone / Issue Type / Issue 字段 | 直接执行 `gh` 命令,同时更新 task 留言 | 跳过 `gh` 直接操作,仅更新 task 留言,由 bot 补位 |
60
- | 直接跳过 | assignee | 直接执行 `gh` 命令 | 不做任何替代 |
61
- | 正常执行 | 评论 | 正常执行 | 正常执行 |
62
-
63
- 关键原则:
64
-
65
- - 无论是否有写权限,task 留言同步都必须继续执行
66
- - 权限不足只影响直接写 Issue 元数据的步骤,不中断整个技能
67
- - 现有 `2>/dev/null || true` 容错模式保持不变
68
-
69
- 当调用方存在 `{task-id}` / task 目录时,权限降级或关键同步失败必须写入 `## 工作流告警`:
70
-
71
- ```bash
72
- node .agents/scripts/workflow-warnings.js add .agents/workspace/active/{task-id} \
73
- --step issue-sync --severity IMPORTANT --code PERMISSION_DEGRADED \
74
- --target "{operation}" --message "{reason}" \
75
- --action "等待 bot/维护者补位,或在具备权限后重跑对应 workflow 步骤"
76
- ```
77
-
78
- 评论创建 / 更新失败、网络重试耗尽等影响后续 reviewer 可见性的失败使用 `severity=ACTION_REQUIRED` 和 `code=COMMENT_SYNC_FAILED` 或 `NETWORK_RETRY_EXHAUSTED`。
79
-
80
- ## 外部开发者锁定机制
81
-
82
- 维护者(`has_triage=true`)不受限制。外部开发者(`has_triage=false`)在开始任务前,必须先检查 Issue 上是否已有当前任务的 `task` 留言作者。
83
-
84
- ```bash
85
- task_comment_author=$(gh api "repos/$upstream_repo/issues/{issue-number}/comments" \
86
- --paginate --jq '[.[] | select(.body | test("<!-- sync-issue:{task-id}:task -->")) | .user.login] | first' \
87
- 2>/dev/null || echo "")
88
- current_user=$(gh api user --jq '.login' 2>/dev/null || echo "")
89
- ```
90
-
91
- 判定规则:
92
-
93
- - 没有 `task` 留言:允许开始
94
- - `task` 留言作者等于当前用户:允许继续
95
- - `task` 留言作者不等于当前用户:立即停止,并提示先与维护者协调,避免多人同时接手同一任务
96
-
97
- ## status label 设置
98
-
99
- 算法说明:下面的流程与 `.github/scripts/sync-labels-to-set.sh` 保持一致(集合差集)。本章节是 AI Agent 侧的等价实现(`target_set = {"{target-status-label}"}` 的特例)。修改任一侧时,必须同步另一侧,避免 Agent 与 Bot 的行为漂移。
100
-
101
- 如果 task.md 中存在有效的 `issue_number`(非空、非 `N/A`),且 Issue 状态为 `OPEN`,则按幂等差集方式将 `status:` label 同步到目标值:
19
+ GitHub upstream、认证、capability、分页、marker 查找、幂等 create/update、分片、重试与错误分类由 typed platform core 统一处理:
102
20
 
103
21
  ```bash
104
- state=$(gh issue view {issue-number} -R "$upstream_repo" --json state --jq '.state' 2>/dev/null)
105
- if [ "$state" = "OPEN" ]; then
106
- current_status_labels=$(gh issue view {issue-number} -R "$upstream_repo" \
107
- --json labels --jq '.labels[].name | select(startswith("status:"))' 2>/dev/null || true)
108
- printf '%s\n' "$current_status_labels" | while IFS= read -r label; do
109
- [ -z "$label" ] && continue
110
- if [ "$label" != "{target-status-label}" ] && [ "$has_triage" = "true" ]; then
111
- gh issue edit {issue-number} -R "$upstream_repo" --remove-label "$label" 2>/dev/null || true
112
- fi
113
- done
114
- if [ "$has_triage" = "true" ] && ! printf '%s\n' "$current_status_labels" | grep -qxF "{target-status-label}"; then
115
- gh issue edit {issue-number} -R "$upstream_repo" --add-label "{target-status-label}" 2>/dev/null || true
116
- fi
117
- fi
22
+ agent-infra-internal platform-context resolve [--cwd <path>]
23
+ agent-infra-internal platform-comment list --issue <N> [--cwd <path>]
24
+ agent-infra-internal platform-comment owner <task-ref>
25
+ agent-infra-internal platform-comment sync <task-ref> \
26
+ --kind task|artifact|summary|cancel --agent <agent> \
27
+ [--artifact <canonical.md>] [--body-file <path|->] [--backfill]
118
28
  ```
119
29
 
120
- 使用 `while IFS= read -r label` 按行处理,可避免 `status: in-progress` 这类含空格 label 被 shell 按空格拆开。
121
-
122
- 如果 `has_triage=false`,则跳过直接设置 label,只更新 task 留言,由 bot 根据最新 task 元数据补位。
123
-
124
- 如果 `gh` 命令失败,跳过并继续,不中断技能执行。
125
-
126
- ## Assignee 同步
127
-
128
- 当技能创建或导入 Issue 时,自动将当前执行者添加为 assignee:
129
-
130
- - `create-task` 的平台规则触发 Issue 创建时:在 `gh issue create` 命令中使用 `--assignee @me` 参数,并附带 `-R "$upstream_repo"`
131
- - `import-issue`:导入后执行 `gh issue edit {issue-number} -R "$upstream_repo" --add-assignee @me 2>/dev/null || true`
30
+ - `applied|no-op|degraded` → exit 0;`failed` → exit 1;`blocked` → exit 2。
31
+ - task 评论保持 `<details>` frontmatter 可逆格式;artifact 原文内联并在超过 profile 上限时使用 `artifactChunk`。
32
+ - 相同 intent 重放必须收敛为 `no-op`;重复 marker 返回 `COMMENT_MARKER_CONFLICT` 且不写入。
33
+ - 外部贡献者锁定统一使用 `platform-comment owner`;不同作者且无 triage 时返回 `COMMENT_OWNER_CONFLICT`。
132
34
 
133
- `@me` 由 `gh` CLI 自动解析为当前认证用户。此操作是幂等的(重复添加不会报错)。如果命令失败(如权限不足),直接跳过,不做任何替代。
35
+ ## 降级与告警
134
36
 
135
- ## `in:` label 同步
37
+ 平台结果不直接写 task.md。调用方在有关联任务时把关键失败映射为 workflow warning:
136
38
 
137
- > **触发时机**:`in:` label 同步应在代码提交后(commit 技能)执行,不在 code-task 阶段执行。create-pr 阶段仅从 Issue 复制到 PR,不重新计算。
39
+ - capability 不足:`IMPORTANT / PERMISSION_DEGRADED`
40
+ - 评论同步永久失败:`ACTION_REQUIRED / COMMENT_SYNC_FAILED`
41
+ - 网络重试耗尽:`ACTION_REQUIRED / NETWORK_RETRY_EXHAUSTED`
138
42
 
139
- 读取 `.agents/.airc.json` 的 `labels.in` 映射。
43
+ 使用 `agent-infra-internal task-warning {task-id} add ...` 登记;不得手写 warning 表。
140
44
 
141
45
  ```bash
142
- git diff {base-branch}...HEAD --name-only
46
+ agent-infra-internal task-warning {task-id} add \
47
+ --step issue-sync --severity {severity} --code {code} \
48
+ --target {target} --message {message} --action {action}
143
49
  ```
144
50
 
145
- `{base-branch}` 通常为 `main`;如果在 PR 上下文中,则使用 PR 的 base branch。
51
+ ## Issue 元数据 intent
146
52
 
147
- ### 有映射时(精确增删)
148
-
149
- 1. 获取分支全部改动文件
150
- 2. 对每个文件按目录前缀匹配 `labels.in` 中的值,得到"应有的 `in:` labels"集合
151
- 3. 查询 Issue/PR 当前的 `in:` labels
152
- 4. 差集比较:
153
- - 应有但没有:仅当 `has_triage=true` 时执行 `gh issue edit {issue-number} -R "$upstream_repo" --add-label "in: {module}" 2>/dev/null || true`
154
- - 有但不应有:仅当 `has_triage=true` 时执行 `gh issue edit {issue-number} -R "$upstream_repo" --remove-label "in: {module}" 2>/dev/null || true`
155
-
156
- ### 无映射时(只增不删回退)
157
-
158
- 如果 `.airc.json` 中不存在 `labels.in` 或为空对象:
159
-
160
- 1. 查询仓库已有 `in:` labels
161
- 2. 从改动文件提取第一级目录
162
- 3. 仅当 `has_triage=true` 时添加匹配的 label,不移除已有 `in:` label
163
-
164
- 如果 `has_triage=false`,则跳过直接修改 `in:` label,只保留 task 留言同步,由后续自动化补位。
165
-
166
- ## 产物评论发布
167
-
168
- 隐藏标记必须保持兼容:
169
-
170
- ```html
171
- <!-- sync-issue:{task-id}:{file-stem} -->
172
- ```
173
-
174
- 发布前先检查是否已存在同标记评论:
53
+ 所有 Issue 元数据写入统一使用:
175
54
 
176
55
  ```bash
177
- gh api "repos/$upstream_repo/issues/{issue-number}/comments" \
178
- --paginate --jq '.[].body' \
179
- | grep -qF "<!-- sync-issue:{task-id}:{file-stem} -->"
56
+ agent-infra-internal platform-issue inspect {task-id}
57
+ agent-infra-internal platform-issue create {task-id} --agent {agent}
58
+ agent-infra-internal platform-issue bind {task-id} --issue {number} --agent {agent}
59
+ agent-infra-internal platform-issue sync {task-id} --agent {agent} {desired-state-flags}
180
60
  ```
181
61
 
182
- 如果已存在则跳过。
183
-
184
- 发布流程:
185
-
186
- 1. 先读取本地产物文件全文
187
- 2. 将文件全文作为 `{artifact body}` 原文内联到评论中
188
- 3. 禁止自行组织摘要、改写或截断正文
189
-
190
- 评论格式统一为:
191
-
192
- ```markdown
193
- <!-- sync-issue:{task-id}:{file-stem} -->
194
- ## {artifact-title}
195
-
196
- > **{agent}** · {task-id}
197
-
198
- {artifact body}
199
-
200
- ---
201
- *由 {agent} 自动生成 · 内部追踪:{task-id}*
202
- ```
203
-
204
- 其中 `{agent}` 使用当前执行该技能的 AI 代理名称(如 `claude`、`codex`、`gemini`)。
205
-
206
- `summary` 评论需要额外处理:
207
-
208
- - 先查找已有 `<!-- sync-issue:{task-id}:summary -->` 评论的 ID
209
- - 不存在则创建
210
- - 已存在且正文有变化时,使用 `gh api "repos/$upstream_repo/issues/comments/{comment-id}" -X PATCH -f body=...` 原地更新
211
-
212
- ```bash
213
- summary_comment_id=$(gh api "repos/$upstream_repo/issues/{issue-number}/comments" \
214
- --paginate --jq '.[] | select(.body | startswith("<!-- sync-issue:{task-id}:summary -->")) | .id' \
215
- | head -n 1)
216
- gh api "repos/$upstream_repo/issues/comments/{comment-id}" -X PATCH -f body="$(cat <<'EOF'
217
- {comment-body}
218
- EOF
219
- )"
220
- ```
221
-
222
- 评论发布不受 `has_triage` / `has_push` 限制,认证用户可正常执行。
223
-
224
- 若评论查询、创建或更新失败且调用方有关联任务目录,记录 Workflow Warning(`step=issue-sync`、`severity=ACTION_REQUIRED`、`code=COMMENT_SYNC_FAILED`、`target={file-stem}`),并在最终输出的 Workflow Warnings 块提示人工处理。
225
-
226
- ## task.md 评论同步
227
-
228
- 隐藏标记:
229
-
230
- ```html
231
- <!-- sync-issue:{task-id}:task -->
232
- ```
233
-
234
- `task.md` 使用幂等更新路径:
235
-
236
- 1. 读取 `task.md` 全文
237
- 2. 将 YAML frontmatter(`---` 到 `---` 之间的内容)包裹在 `<details><summary>元数据 (frontmatter)</summary>` 和 `` ```yaml `` 代码块中,其余正文保持原样作为 Markdown 渲染
238
- 3. 使用 `task` 作为 `{file-stem}`
239
- 4. 查找已有标记评论 ID
240
- 5. 不存在则创建
241
- 6. 已存在且正文有变化则 PATCH 原地更新
242
- 7. 已存在且正文相同则跳过
243
-
244
- task.md 评论格式:
245
-
246
- ```markdown
247
- <!-- sync-issue:{task-id}:task -->
248
- ## 任务文件
249
-
250
- > **{agent}** · {task-id}
251
-
252
- <details><summary>元数据 (frontmatter)</summary>
253
-
254
- ​```yaml
255
- ---
256
- {frontmatter fields}
257
- ---
258
- ​```
259
-
260
- </details>
261
-
262
- {task.md body after frontmatter}
263
-
264
- ---
265
- *由 {agent} 自动生成 · 内部追踪:{task-id}*
266
- ```
267
-
268
- 还原时,从 `<details>` 块中提取 frontmatter,与正文拼合恢复为原始 `task.md`。
269
-
270
- 评论标题映射:
271
-
272
- - `task` -> `任务文件`
273
-
274
- task 留言同步始终执行,不受权限降级影响。
275
-
276
- ## 补发规则(`/complete-task` 归档前执行)
277
-
278
- - 扫描任务目录中的 `task.md`、`analysis*.md`、`review-analysis*.md`、`plan*.md`、`review-plan*.md`、`code*.md`、`review-code*.md`
279
- - 对每个 `{file-stem}` 用隐藏标记检查是否已发布;未发布则补发,已发布则跳过
280
- - 补发只追加缺失评论,不删除或重排已有评论
281
- - 补发评论的 `{agent}` 按以下顺序确定:
282
- 1. 从 Activity Log 中匹配对应产物文件名(如 `→ analysis.md`),提取 `by {agent}` 中的执行者
283
- 2. 若未匹配到,则回退到 task.md frontmatter 的 `assigned_to`
284
- 3. 若 `assigned_to` 也不可用,则使用当前执行补发的 agent
285
- - 位置说明从 Activity Log 推导时间线中的前后邻居,并加在评论标题下方:
286
-
287
- ```markdown
288
- > ⚠️ 本评论为补发产物,按时间线应位于「{前一个产物标题}」之后、「{后一个产物标题}」之前。
289
- ```
290
-
291
- - 如果只有前邻居或后邻居,仅保留存在的一侧说明;如果两侧都不存在,则不添加位置说明
292
-
293
- 标题映射:
294
-
295
- - `task` -> `任务文件`
296
- - `analysis` / `analysis-r{N}` -> `需求分析` / `需求分析(Round {N})`
297
- - `review-analysis` / `review-analysis-r{N}` -> `需求分析审查(Round 1)` / `需求分析审查(Round {N})`
298
- - `plan` / `plan-r{N}` -> `技术方案` / `技术方案(Round {N})`
299
- - `review-plan` / `review-plan-r{N}` -> `技术方案审查(Round 1)` / `技术方案审查(Round {N})`
300
- - `code` / `code-r{N}` -> `实现报告(Round 1)` / `实现报告(Round {N})`
301
- - `review-code` / `review-code-r{N}` -> `代码审查(Round 1)` / `代码审查(Round {N})`
302
- - `summary` -> `交付摘要`
303
-
304
- 补发评论同样不受 `has_triage` / `has_push` 限制。
305
-
306
- ## 需求复选框同步
307
-
308
- 从 task.md 的 `## 需求` 段落提取已勾选的 `- [x]` 条目;如果没有,跳过。
309
-
310
- 读取 Issue 当前正文:
311
-
312
- ```bash
313
- gh issue view {issue-number} -R "$upstream_repo" --json body --jq '.body'
314
- ```
62
+ `sync` 支持 status/in labels、assignee、milestone、Issue Type、pinned fields、需求复选框与 Issue state。省略 flag 表示 preserve,`none` 表示显式清空。适配层统一处理集合差集、动态 schema、权限降级、dry-run、重试、错误分类与幂等重放;SKILL 不得拼装 `gh issue`、GraphQL 或权限分支。
315
63
 
316
- 按复选框文本匹配,将对应的 `- [ ] {text}` 单向替换为 `- [x] {text}`。只有正文实际变化且 `has_triage=true` 时,才使用 `gh api` PATCH 更新完整 body。
64
+ - `planned|applied|no-op|degraded` → exit 0
65
+ - `failed` → exit 1
66
+ - `blocked` → exit 2
317
67
 
318
- 如果 `has_triage=false`,则跳过正文 PATCH,只更新 task 留言,由 bot 根据最新任务状态补位。
68
+ status labels 始终至多一个;关闭后不保留 status label。`in:` labels 只从项目允许映射与仓库实际 labels 交集产生。需求复选框以 task.md 原文为身份,歧义时 fail closed。
319
69
 
320
- ## Shell 安全规则
70
+ ## 补发
321
71
 
322
- 1. 先用 Read 工具读取产物全文,再把实际文本内联到 heredoc 中;禁止在 `<<'EOF'` 内使用命令替换或变量展开。
323
- 2. 构造含 `<!-- -->` 的内容时禁止使用 `echo`;统一使用 `cat <<'EOF'` heredoc 或 `printf '%s\n'`。
72
+ complete-task 按 artifact catalog 时间线遍历本地已有产物:task 使用 `--kind task`,其余使用 `--kind artifact --artifact <file> --backfill`;最后用 `--kind summary --body-file <path>` 原地同步交付摘要。artifact backfill 在远端缺少 marker 时创建带“历史产物补发”提示的评论;已存在合法 marker 集合时保持原评论和分片不变并返回 `no-op`;marker 冲突仍失败。该判定由 core 完成,不由 Skill 扫描评论或拼标题。
@@ -14,6 +14,6 @@
14
14
 
15
15
  Skill 正文应引用 marker key,具体 marker 字符串只保留在本规则或平台适配器默认值中。
16
16
 
17
- 当前代码平台未内置 Issue 同步支持。
17
+ 当前代码平台未提供 Issue 适配器;`platform-issue` 返回结构化 no-op/degraded operations。
18
18
 
19
19
  自定义平台会跳过 Issue 元数据、标签、里程碑、负责人和评论同步,除非你提供匹配的 `.{platform}.zh-CN.md` 规则模板和平台适配器。请继续正常写入本地任务产物。
@@ -1,5 +1,5 @@
1
1
  # Milestone Inference
2
2
 
3
- This code platform does not provide built-in milestone inference.
3
+ This code platform does not provide milestone inference; `platform-issue sync --milestone ...` returns a structured no-op/degraded result.
4
4
 
5
5
  Milestone narrowing and reuse are skipped for custom platforms unless you provide matching `.{platform}.en.md` rule templates. Do not block task progress when no platform-specific milestone implementation is available.
@@ -1,125 +1,13 @@
1
- # Milestone Inference Rules
1
+ # Milestone Inference
2
2
 
3
- Read this file before the `create-task` platform rule, `code-task`, or `create-pr` handles a milestone.
4
-
5
- ## General Principles
6
-
7
- - Narrow the milestone over the skill lifecycle: release line -> concrete version -> reuse
8
- - Every phase must fall back safely instead of blocking the skill
9
- - If `gh` is unavailable, unauthenticated, or the GitHub API call fails, skip milestone handling and continue
10
- - Before any repository-scoped `gh api`, `gh issue edit`, or Issue lookup runs, the caller must resolve `upstream_repo` and `has_triage`
11
- - Only use milestones that actually exist in the repository; if a target milestone is unavailable, apply the fallback for that phase
12
-
13
- ## Branch Mode Detection
14
-
15
- Use the following command to detect whether the repository has remote release-line branches:
16
-
17
- ```bash
18
- git branch -r | grep -v 'HEAD' | grep -E 'origin/[0-9]+\.[0-9]+\.x$'
19
- ```
20
-
21
- - Any output: multi-version branch mode
22
- - No output: trunk mode
23
-
24
- ## Phase 1: `create-task` (when the platform rule creates an Issue)
25
-
26
- Goal: choose a coarse-grained release line when the Issue is created.
27
-
28
- Priority:
29
- 1. If task.md provides a valid explicit `milestone`, use it
30
- 2. Otherwise infer a release line:
31
- - Trunk mode: query open `X.Y.x` milestones and choose the lowest release line
32
- - Multi-version branch mode: try open `X.Y.x` milestones and choose the lowest release line; if that is not reliable, fall back to `General Backlog`
33
- 3. If the inferred release line does not exist, fall back to `General Backlog`
34
- 4. If `General Backlog` also does not exist, omit `--milestone`
35
-
36
- Suggested release-line query:
37
-
38
- ```bash
39
- gh api "repos/$upstream_repo/milestones?state=open&per_page=100" \
40
- --jq '.[].title'
41
- ```
42
-
43
- Only match titles in `X.Y.x` format and choose the smallest major/minor pair numerically.
44
-
45
- Direct milestone writes are triage-gated. When the caller detected `has_triage=false`, omit `--milestone` and continue.
46
-
47
- ### Backfill when called from `import-issue`
48
-
49
- When `import-issue` imports an existing Issue whose current milestone is empty, infer a release line using the priority above, including the `General Backlog` fallback. When a non-empty release line is found, write it back to the remote Issue:
50
-
51
- ```bash
52
- if [ "$has_triage" = "true" ]; then
53
- gh issue edit {issue-number} -R "$upstream_repo" --milestone "{version}" 2>/dev/null || true
54
- fi
55
- ```
56
-
57
- If `has_triage=false`, inference returns empty, or `gh issue edit` fails, skip and continue without blocking the `import-issue` workflow.
58
-
59
- ## Phase 2: `code-task`
60
-
61
- Goal: narrow the Issue milestone from a release line to a concrete version when implementation starts.
62
-
63
- Preconditions:
64
- - task.md contains a valid `issue_number`
65
- - the current Issue milestone matches the release-line format `X.Y.x` or is `General Backlog`
66
-
67
- Sequence:
68
- 1. Query the current Issue milestone
69
- 2. If it is `General Backlog`, re-infer the release line using Phase 1, then try to narrow it to a concrete version; if inference fails, keep `General Backlog` unchanged
70
- 3. If it is not in `X.Y.x` format, treat it as already specific enough and keep it unchanged
71
- 4. If it is in `X.Y.x` format, narrow it according to branch mode:
72
- - Trunk mode: query open concrete-version milestones on that release line (for example `0.4.4`) and choose the latest one
73
- - Multi-version branch mode:
74
- - If the task branch was created from `origin/X.Y.x`, choose the latest concrete version on that line
75
- - If the task branch was created from `main`, find the highest release line and choose the latest concrete version on that line
76
- 5. When a target concrete version is found, run:
77
-
78
- ```bash
79
- if [ "$has_triage" = "true" ]; then
80
- gh issue edit {issue-number} -R "$upstream_repo" --milestone "{version}"
81
- fi
82
- ```
83
-
84
- 6. Keep the original milestone unchanged only in the following cases (otherwise narrow per step 5):
85
- - Trunk mode with no open concrete version under the release line — the `code-task` / `create-pr` `verify_milestone_specific` gate will fail and prompt maintainers to create the missing concrete version
86
- - Multi-release-line mode when both `git merge-base --is-ancestor` checks are unreliable or the remote refs are missing
87
- - In any mode, `has_triage=false` (the bot will reconcile later)
88
-
89
- Suggested concrete-version query:
90
-
91
- ```bash
92
- gh api "repos/$upstream_repo/milestones?state=open&per_page=100" \
93
- --jq '.[].title'
94
- ```
95
-
96
- - Release-line match: `^X\.Y\.x$`
97
- - Concrete-version match: `^X\.Y\.[0-9]+$`
98
- - "Latest" means the largest patch number
99
-
100
- Suggested branch-origin checks:
3
+ Milestones narrow through declarative Issue intents:
101
4
 
102
5
  ```bash
103
- git merge-base --is-ancestor origin/{release-line} HEAD
104
- git merge-base --is-ancestor origin/main HEAD
105
- ```
106
-
107
- If neither check is reliable or the remote refs are unavailable, keep the original milestone and avoid guessing.
6
+ # create/import phase
7
+ agent-infra-internal platform-issue sync {task-id} --agent {agent} --milestone initial
108
8
 
109
- ## Phase 3: `create-pr`
110
-
111
- Goal: reuse the linked Issue milestone on the PR instead of inferring a new one.
112
-
113
- Sequence:
114
- 1. If `issue_number` exists, query the Issue milestone
115
- 2. If the Issue has a milestone, run:
116
-
117
- ```bash
118
- if [ "$has_triage" = "true" ]; then
119
- gh pr edit {pr-number} --milestone "{milestone}"
120
- fi
9
+ # code phase
10
+ agent-infra-internal platform-issue sync {task-id} --agent {agent} --milestone specific
121
11
  ```
122
12
 
123
- 3. If the Issue has no milestone, or `has_triage=false`, skip PR milestone assignment
124
-
125
- Do not infer a PR milestone separately from task.md, branch names, tags, or `General Backlog`.
13
+ `initial` prefers a valid task milestone, otherwise the lowest open `X.Y.x`, then `General Backlog`. `specific` narrows a release line to the highest open patch version using main/release-line ancestry. Missing facts or triage permission preserve the remote value and return skipped/degraded. `create-pr` reuses the Issue milestone in the 09/10 PR adapter.
@@ -1,125 +1,25 @@
1
1
  # Milestone 推断规则
2
2
 
3
- 在 `create-task` 的平台规则、`code-task` 或 `create-pr` 处理 milestone 之前先读取本文件。
3
+ Milestone 继续按生命周期逐步收窄,但候选读取、分支判断、权限降级和写入统一由 `platform-issue` 处理。
4
4
 
5
- ## 通用原则
6
-
7
- - milestone 在技能生命周期中逐步收窄:版本线 -> 具体版本 -> 复用
8
- - 任一步骤推断失败时都必须回退,不得阻塞技能执行
9
- - 如果 `gh` CLI 不可用、未认证,或 GitHub API 请求失败,跳过 milestone 处理并继续
10
- - 在执行 repo 级 `gh api`、`gh issue edit` 或 Issue 查询前,调用方必须先完成 `upstream_repo` / `has_triage` 检测
11
- - 只使用仓库中实际存在的 milestone;目标 milestone 不存在时按各阶段 fallback 处理
12
-
13
- ## 分支模式检测
14
-
15
- 使用以下命令检测仓库是否存在远程 release line 分支:
16
-
17
- ```bash
18
- git branch -r | grep -v 'HEAD' | grep -E 'origin/[0-9]+\.[0-9]+\.x$'
19
- ```
20
-
21
- - 有输出:多版本分支模式
22
- - 无输出:主干模式
23
-
24
- ## 阶段 1:`create-task`(平台规则创建 Issue 时)
25
-
26
- 目标:在创建 Issue 时先确定粗粒度版本线。
27
-
28
- 优先级:
29
- 1. `task.md` 显式存在 `milestone` 字段且值有效 -> 直接使用
30
- 2. 否则推断版本线:
31
- - 主干模式:查询 open 的 `X.Y.x` 里程碑,取最低版本线
32
- - 多版本分支模式:优先查询 open 的 `X.Y.x` 里程碑,取最低版本线;如果无法确定则回退到 `General Backlog`
33
- 3. 推断出的版本线不存在 -> 回退到 `General Backlog`
34
- 4. `General Backlog` 也不存在 -> 省略 `--milestone`
35
-
36
- 版本线查询建议:
37
-
38
- ```bash
39
- gh api "repos/$upstream_repo/milestones?state=open&per_page=100" \
40
- --jq '.[].title'
41
- ```
42
-
43
- 只匹配 `X.Y.x` 格式的标题;按 major、minor 数值升序取最小版本线。
44
-
45
- Milestone 设置属于 `has_triage` 权限范围;如果调用方检测到 `has_triage=false`,则省略 `--milestone` 并继续。
46
-
47
- ### `import-issue` 调用时的兜底
48
-
49
- `import-issue` 导入既有 Issue 时,若 Issue 当前 milestone 为空,按上述优先级推断版本线(含 `General Backlog` 回退)。命中非空版本线后,回写到远端 Issue:
5
+ ## 阶段 1:创建或导入
50
6
 
51
7
  ```bash
52
- if [ "$has_triage" = "true" ]; then
53
- gh issue edit {issue-number} -R "$upstream_repo" --milestone "{version}" 2>/dev/null || true
54
- fi
8
+ agent-infra-internal platform-issue sync {task-id} --agent {agent} --milestone initial
55
9
  ```
56
10
 
57
- 如果 `has_triage=false`、推断结果为空、或 `gh issue edit` 失败,跳过并继续,不阻断 `import-issue` 工作流。
11
+ 优先使用 task.md 中存在且有效的显式 milestone;否则从 open milestones 选择最低 `X.Y.x` 版本线,最后回退 `General Backlog`。`triage=false` 或外部事实不足时保持远端值并返回 skipped/degraded。
58
12
 
59
13
  ## 阶段 2:`code-task`
60
14
 
61
- 目标:开始开发时,把 Issue milestone 从版本线收窄到具体版本。
62
-
63
- 前置条件:
64
- - `task.md` 存在有效 `issue_number`
65
- - 当前 Issue milestone 为版本线格式 `X.Y.x` 或 `General Backlog`
66
-
67
- 执行顺序:
68
- 1. 查询 Issue 当前 milestone
69
- 2. 如果 milestone 是 `General Backlog` -> 按阶段 1 规则重新推断版本线,再尝试收窄到具体版本;如果推断失败则保持 `General Backlog` 不变
70
- 3. 如果 milestone 不是 `X.Y.x` 格式 -> 视为已足够具体,保持不变
71
- 4. 如果 milestone 是 `X.Y.x` -> 按分支模式收窄:
72
- - 主干模式:查询该版本线下 open 的具体版本 milestone(如 `0.4.4`),取最新版本
73
- - 多版本分支模式:
74
- - 当前任务分支来自 `origin/X.Y.x` release line -> 在该版本线下取最新具体版本
75
- - 当前任务分支来自 `main` -> 找最高版本线,再取该版本线下的最新具体版本
76
- 5. 找到目标具体版本后,执行:
77
-
78
- ```bash
79
- if [ "$has_triage" = "true" ]; then
80
- gh issue edit {issue-number} -R "$upstream_repo" --milestone "{version}"
81
- fi
82
- ```
83
-
84
- 6. 仅在以下情况保持原 milestone 不变(其余情形必须按步骤 5 收窄):
85
- - 主干模式下版本线下没有 open 具体版本 —— `code-task` / `create-pr` 的 `verify_milestone_specific` gate 会 FAIL,提醒维护者补建具体版本
86
- - 多版本分支模式下 `git merge-base --is-ancestor` 两条判断都不可靠或远程引用缺失
87
- - 任意模式下 `has_triage=false`(由 bot 后补)
88
-
89
- 具体版本查询建议:
90
-
91
- ```bash
92
- gh api "repos/$upstream_repo/milestones?state=open&per_page=100" \
93
- --jq '.[].title'
94
- ```
95
-
96
- - 版本线匹配:`^X\.Y\.x$`
97
- - 具体版本匹配:`^X\.Y\.[0-9]+$`
98
- - “最新”按 patch 数值最大确定
99
-
100
- 分支来源判断建议:
101
-
102
15
  ```bash
103
- git merge-base --is-ancestor origin/{release-line} HEAD
104
- git merge-base --is-ancestor origin/main HEAD
16
+ agent-infra-internal platform-issue sync {task-id} --agent {agent} --milestone specific
105
17
  ```
106
18
 
107
- 如果两个判断都不可靠或远程引用缺失,保持原 milestone,不做错误推断。
19
+ 版本线收窄规则保持不变:主干模式在当前版本线取最高 patch;多版本分支模式依据 release-line/main 祖先关系选择版本线。无法可靠判断时保持原值。完成门禁仍拒绝 `X.Y.x`。
108
20
 
109
21
  ## 阶段 3:`create-pr`
110
22
 
111
- 目标:PR 直接复用关联 Issue 的 milestone,不再独立推断。
112
-
113
- 执行顺序:
114
- 1. 如果存在 `issue_number`,查询 Issue milestone
115
- 2. Issue 有 milestone -> 执行:
116
-
117
- ```bash
118
- if [ "$has_triage" = "true" ]; then
119
- gh pr edit {pr-number} --milestone "{milestone}"
120
- fi
121
- ```
122
-
123
- 3. Issue 没有 milestone,或 `has_triage=false` -> 跳过,不设置 PR milestone
23
+ PR 只复用关联 Issue 的具体 milestone;该 PR 资源写入属于 09/10,不在 `platform-issue` 中实现。
124
24
 
125
- 不要再使用 `task.md`、分支名、tag 或 `General Backlog` 为 PR 单独推断 milestone。
25
+ 调用方不得重新实现 milestone 列表、排序、分支祖先或 `gh issue edit` 逻辑。
@@ -1,5 +1,5 @@
1
1
  # Milestone 推断
2
2
 
3
- 当前代码平台未内置里程碑推断支持。
3
+ 当前代码平台未提供里程碑推断;`platform-issue sync --milestone ...` 返回结构化 no-op/degraded 结果。
4
4
 
5
5
  自定义平台会跳过里程碑收窄和复用逻辑,除非你提供匹配的 `.{platform}.zh-CN.md` 规则模板。没有平台专属里程碑实现时,不要阻塞任务推进。