@fitlab-ai/agent-infra 0.9.2 → 0.9.4

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 (428) hide show
  1. package/README.md +12 -9
  2. package/README.zh-CN.md +12 -9
  3. package/bin/cli.ts +12 -0
  4. package/dist/bin/cli.js +14 -0
  5. package/dist/bin/internal-cli.js +134 -108
  6. package/dist/lib/agent-clients/adapter.js +137 -4
  7. package/dist/lib/agent-clients/adapters/antigravity-cli.js +64 -0
  8. package/dist/lib/{sandbox/credentials.js → agent-clients/adapters/claude-code-credentials.js} +4 -14
  9. package/dist/lib/agent-clients/adapters/claude-code-refresh.js +85 -0
  10. package/dist/lib/agent-clients/adapters/claude-code-sandbox.js +247 -0
  11. package/dist/lib/agent-clients/adapters/claude-code.js +27 -4
  12. package/dist/lib/agent-clients/adapters/codex.js +9 -0
  13. package/dist/lib/agent-clients/adapters/index.js +2 -2
  14. package/dist/lib/agent-clients/adapters/opencode-sandbox.js +108 -0
  15. package/dist/lib/agent-clients/adapters/opencode.js +24 -3
  16. package/dist/lib/agent-clients/adapters/runtimes/claude-code.dockerfile +65 -0
  17. package/dist/lib/agent-clients/config.js +42 -4
  18. package/dist/lib/agent-clients/next-steps.js +11 -2
  19. package/dist/lib/agent-clients/reconcile.js +2 -1
  20. package/dist/lib/agent-clients/registry.js +16 -2
  21. package/dist/lib/agent-clients/schema.js +18 -0
  22. package/dist/lib/agent-clients/tokens.js +49 -0
  23. package/dist/lib/agent-clients/types.js +1 -1
  24. package/dist/lib/defaults.json +1 -1
  25. package/dist/lib/git/workflow.js +54 -1
  26. package/dist/lib/internal/agent-client.js +61 -4
  27. package/dist/lib/internal/git-workflow.js +6 -1
  28. package/dist/lib/internal/platform-checks.js +3 -3
  29. package/dist/lib/internal/platform-comment.js +29 -2
  30. package/dist/lib/internal/platform-issue.js +7 -0
  31. package/dist/lib/internal/platform-pr-review.js +132 -0
  32. package/dist/lib/internal/platform-pr.js +20 -2
  33. package/dist/lib/internal/platform-release-notes.js +52 -16
  34. package/dist/lib/internal/pr-review-grade.js +140 -0
  35. package/dist/lib/internal/release-workflow.js +13 -6
  36. package/dist/lib/internal/sandbox-control.js +24 -0
  37. package/dist/lib/internal/task-activity.js +105 -0
  38. package/dist/lib/internal/task-event.js +17 -1
  39. package/dist/lib/internal/task-ledger.js +12 -3
  40. package/dist/lib/internal/task-lifecycle.js +26 -1
  41. package/dist/lib/internal/task-orchestration.js +167 -18
  42. package/dist/lib/internal/task-review.js +8 -3
  43. package/dist/lib/platform/adapters.js +8 -1
  44. package/dist/lib/platform/completion-backfill.js +122 -0
  45. package/dist/lib/platform/github-client.js +19 -2
  46. package/dist/lib/platform/issue-comments.js +3 -2
  47. package/dist/lib/platform/merged-pr-equivalence.js +115 -5
  48. package/dist/lib/platform/pr-checks.js +65 -42
  49. package/dist/lib/platform/pr-review.js +166 -0
  50. package/dist/lib/platform/pull-requests.js +371 -4
  51. package/dist/lib/platform/release-notes.js +85 -3
  52. package/dist/lib/platform/releases.js +13 -5
  53. package/dist/lib/pr-review/evidence-grading.js +229 -0
  54. package/dist/lib/process-data/index.js +239 -0
  55. package/dist/lib/process-data/normalize.js +198 -0
  56. package/dist/lib/process-data/privacy.js +33 -0
  57. package/dist/lib/process-data/reconcile.js +95 -0
  58. package/dist/lib/process-data/repair.js +58 -0
  59. package/dist/lib/process-data/sources.js +345 -0
  60. package/dist/lib/process-data/store.js +282 -0
  61. package/dist/lib/process-data/types.js +2 -0
  62. package/dist/lib/run/index.js +4 -3
  63. package/dist/lib/run/tui.js +10 -13
  64. package/dist/lib/sandbox/agent-client-reconciler.js +26 -2
  65. package/dist/lib/sandbox/capture.js +7 -2
  66. package/dist/lib/sandbox/commands/create.js +109 -248
  67. package/dist/lib/sandbox/commands/enter.js +15 -47
  68. package/dist/lib/sandbox/commands/list-running.js +16 -6
  69. package/dist/lib/sandbox/commands/ls.js +10 -6
  70. package/dist/lib/sandbox/commands/rebuild.js +4 -3
  71. package/dist/lib/sandbox/commands/refresh.js +4 -84
  72. package/dist/lib/sandbox/commands/rm.js +24 -3
  73. package/dist/lib/sandbox/commands/show.js +13 -4
  74. package/dist/lib/sandbox/commands/start.js +7 -4
  75. package/dist/lib/sandbox/config.js +2 -0
  76. package/dist/lib/sandbox/constants.js +6 -0
  77. package/dist/lib/sandbox/control/client.js +44 -0
  78. package/dist/lib/sandbox/control/protocol.js +35 -0
  79. package/dist/lib/sandbox/control/server.js +109 -0
  80. package/dist/lib/sandbox/dockerfile.js +36 -13
  81. package/dist/lib/sandbox/mounts.js +17 -4
  82. package/dist/lib/sandbox/recovery.js +128 -5
  83. package/dist/lib/sandbox/redaction.js +12 -0
  84. package/dist/lib/sandbox/runtimes/base.dockerfile +24 -74
  85. package/dist/lib/sandbox/workspace-identity.js +95 -0
  86. package/dist/lib/sandbox/workspace-view.js +103 -0
  87. package/dist/lib/task/activity-intent.js +307 -0
  88. package/dist/lib/task/artifact-lifecycle.js +2 -1
  89. package/dist/lib/task/commands/log.js +15 -14
  90. package/dist/lib/task/commit-finalization.js +267 -0
  91. package/dist/lib/task/commit-intent.js +165 -0
  92. package/dist/lib/task/decision-intents.js +31 -17
  93. package/dist/lib/task/delegation-receipts.js +25 -4
  94. package/dist/lib/task/events.js +67 -28
  95. package/dist/lib/task/finalization-artifacts.js +35 -0
  96. package/dist/lib/task/implementation-inputs.js +54 -7
  97. package/dist/lib/task/ledger-intents.js +35 -1
  98. package/dist/lib/task/lifecycle-execution.js +46 -0
  99. package/dist/lib/task/orchestration.js +753 -54
  100. package/dist/lib/task/resolve-ref.js +41 -1
  101. package/dist/lib/task/review-finalization.js +29 -9
  102. package/dist/lib/task/task-execution-lock.js +231 -0
  103. package/dist/lib/task/verification-checks.js +1 -1
  104. package/dist/lib/task/verification-engine.js +218 -2
  105. package/dist/lib/task/verification.js +4 -3
  106. package/dist/lib/task/workspace-snapshot.js +17 -5
  107. package/lib/agent-clients/adapter.ts +201 -4
  108. package/lib/agent-clients/adapters/antigravity-cli.ts +65 -0
  109. package/lib/{sandbox/credentials.ts → agent-clients/adapters/claude-code-credentials.ts} +3 -18
  110. package/lib/agent-clients/adapters/claude-code-refresh.ts +128 -0
  111. package/lib/agent-clients/adapters/claude-code-sandbox.ts +295 -0
  112. package/lib/agent-clients/adapters/claude-code.ts +31 -4
  113. package/lib/agent-clients/adapters/codex.ts +9 -0
  114. package/lib/agent-clients/adapters/index.ts +2 -2
  115. package/lib/agent-clients/adapters/opencode-sandbox.ts +136 -0
  116. package/lib/agent-clients/adapters/opencode.ts +27 -3
  117. package/lib/agent-clients/adapters/runtimes/claude-code.dockerfile +65 -0
  118. package/lib/agent-clients/config.ts +49 -4
  119. package/lib/agent-clients/next-steps.ts +15 -2
  120. package/lib/agent-clients/reconcile.ts +2 -1
  121. package/lib/agent-clients/registry.ts +19 -1
  122. package/lib/agent-clients/schema.ts +18 -0
  123. package/lib/agent-clients/tokens.ts +53 -0
  124. package/lib/agent-clients/types.ts +15 -1
  125. package/lib/defaults.json +1 -1
  126. package/lib/git/workflow.ts +66 -2
  127. package/lib/internal/agent-client.ts +59 -4
  128. package/lib/internal/git-workflow.ts +5 -1
  129. package/lib/internal/platform-checks.ts +4 -4
  130. package/lib/internal/platform-comment.ts +17 -2
  131. package/lib/internal/platform-issue.ts +4 -0
  132. package/lib/internal/platform-pr-review.ts +104 -0
  133. package/lib/internal/platform-pr.ts +14 -1
  134. package/lib/internal/platform-release-notes.ts +59 -16
  135. package/lib/internal/pr-review-grade.ts +130 -0
  136. package/lib/internal/release-workflow.ts +13 -6
  137. package/lib/internal/sandbox-control.ts +24 -0
  138. package/lib/internal/task-activity.ts +91 -0
  139. package/lib/internal/task-event.ts +9 -1
  140. package/lib/internal/task-ledger.ts +12 -3
  141. package/lib/internal/task-lifecycle.ts +26 -1
  142. package/lib/internal/task-orchestration.ts +123 -14
  143. package/lib/internal/task-review.ts +8 -3
  144. package/lib/platform/adapters.ts +29 -2
  145. package/lib/platform/completion-backfill.ts +134 -0
  146. package/lib/platform/github-client.ts +20 -2
  147. package/lib/platform/issue-comments.ts +3 -2
  148. package/lib/platform/merged-pr-equivalence.ts +127 -5
  149. package/lib/platform/pr-checks.ts +73 -46
  150. package/lib/platform/pr-review.ts +201 -0
  151. package/lib/platform/pull-requests.ts +444 -3
  152. package/lib/platform/release-notes.ts +100 -4
  153. package/lib/platform/releases.ts +16 -4
  154. package/lib/pr-review/evidence-grading.ts +318 -0
  155. package/lib/process-data/index.ts +224 -0
  156. package/lib/process-data/normalize.ts +202 -0
  157. package/lib/process-data/privacy.ts +41 -0
  158. package/lib/process-data/reconcile.ts +110 -0
  159. package/lib/process-data/repair.ts +64 -0
  160. package/lib/process-data/sources.ts +354 -0
  161. package/lib/process-data/store.ts +315 -0
  162. package/lib/process-data/types.ts +135 -0
  163. package/lib/run/index.ts +5 -3
  164. package/lib/run/tui.ts +14 -12
  165. package/lib/sandbox/agent-client-reconciler.ts +44 -2
  166. package/lib/sandbox/capture.ts +9 -2
  167. package/lib/sandbox/commands/create.ts +126 -280
  168. package/lib/sandbox/commands/enter.ts +13 -59
  169. package/lib/sandbox/commands/list-running.ts +23 -6
  170. package/lib/sandbox/commands/ls.ts +22 -6
  171. package/lib/sandbox/commands/rebuild.ts +4 -3
  172. package/lib/sandbox/commands/refresh.ts +4 -126
  173. package/lib/sandbox/commands/rm.ts +24 -3
  174. package/lib/sandbox/commands/show.ts +30 -4
  175. package/lib/sandbox/commands/start.ts +6 -4
  176. package/lib/sandbox/config.ts +4 -0
  177. package/lib/sandbox/constants.ts +8 -0
  178. package/lib/sandbox/control/client.ts +55 -0
  179. package/lib/sandbox/control/protocol.ts +75 -0
  180. package/lib/sandbox/control/server.ts +117 -0
  181. package/lib/sandbox/dockerfile.ts +66 -13
  182. package/lib/sandbox/mounts.ts +24 -4
  183. package/lib/sandbox/recovery.ts +163 -6
  184. package/lib/sandbox/redaction.ts +14 -0
  185. package/lib/sandbox/runtimes/base.dockerfile +24 -74
  186. package/lib/sandbox/tool-types.ts +16 -0
  187. package/lib/sandbox/workspace-identity.ts +123 -0
  188. package/lib/sandbox/workspace-view.ts +143 -0
  189. package/lib/server/server.schema.json +2 -2
  190. package/lib/task/activity-intent.ts +417 -0
  191. package/lib/task/artifact-lifecycle.ts +2 -1
  192. package/lib/task/commands/log.ts +15 -14
  193. package/lib/task/commit-finalization.ts +356 -0
  194. package/lib/task/commit-intent.ts +230 -0
  195. package/lib/task/decision-intents.ts +32 -12
  196. package/lib/task/delegation-receipts.ts +34 -5
  197. package/lib/task/events.ts +75 -30
  198. package/lib/task/finalization-artifacts.ts +58 -0
  199. package/lib/task/implementation-inputs.ts +62 -8
  200. package/lib/task/ledger-intents.ts +43 -3
  201. package/lib/task/lifecycle-execution.ts +106 -0
  202. package/lib/task/orchestration.ts +1019 -72
  203. package/lib/task/resolve-ref.ts +46 -1
  204. package/lib/task/review-finalization.ts +40 -9
  205. package/lib/task/task-execution-lock.ts +296 -0
  206. package/lib/task/verification-checks.ts +1 -1
  207. package/lib/task/verification-engine.ts +249 -2
  208. package/lib/task/verification.ts +5 -3
  209. package/lib/task/workspace-snapshot.ts +26 -5
  210. package/package.json +3 -3
  211. package/templates/.agents/QUICKSTART.en.md +25 -8
  212. package/templates/.agents/QUICKSTART.zh-CN.md +25 -8
  213. package/templates/.agents/README.en.md +10 -7
  214. package/templates/.agents/README.zh-CN.md +10 -7
  215. package/templates/.agents/hooks/lifecycle-delegation.js +15 -4
  216. package/templates/.agents/rules/README.en.md +1 -1
  217. package/templates/.agents/rules/README.zh-CN.md +1 -1
  218. package/templates/.agents/rules/create-issue.github.en.md +4 -2
  219. package/templates/.agents/rules/create-issue.github.zh-CN.md +4 -2
  220. package/templates/.agents/rules/human-decision-context.en.md +11 -2
  221. package/templates/.agents/rules/human-decision-context.zh-CN.md +11 -2
  222. package/templates/.agents/rules/issue-fields.github.en.md +3 -1
  223. package/templates/.agents/rules/issue-fields.github.zh-CN.md +3 -1
  224. package/templates/.agents/rules/issue-pr-commands.en.md +5 -3
  225. package/templates/.agents/rules/issue-pr-commands.github.en.md +5 -3
  226. package/templates/.agents/rules/issue-pr-commands.github.zh-CN.md +5 -3
  227. package/templates/.agents/rules/issue-pr-commands.zh-CN.md +5 -3
  228. package/templates/.agents/rules/issue-sync.github.en.md +7 -3
  229. package/templates/.agents/rules/issue-sync.github.zh-CN.md +8 -4
  230. package/templates/.agents/rules/lifecycle-orchestration.en.md +5 -2
  231. package/templates/.agents/rules/lifecycle-orchestration.zh-CN.md +5 -2
  232. package/templates/.agents/rules/milestone-inference.github.en.md +4 -2
  233. package/templates/.agents/rules/milestone-inference.github.zh-CN.md +4 -2
  234. package/templates/.agents/rules/next-step-output.en.md +3 -1
  235. package/templates/.agents/rules/next-step-output.zh-CN.md +3 -1
  236. package/templates/.agents/rules/no-mid-flow-questions.en.md +17 -0
  237. package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +17 -0
  238. package/templates/.agents/rules/pr-checks-commands.en.md +3 -3
  239. package/templates/.agents/rules/pr-checks-commands.github.en.md +2 -2
  240. package/templates/.agents/rules/pr-checks-commands.github.zh-CN.md +3 -3
  241. package/templates/.agents/rules/pr-checks-commands.zh-CN.md +3 -3
  242. package/templates/.agents/rules/pr-sync.en.md +3 -1
  243. package/templates/.agents/rules/pr-sync.github.en.md +11 -1
  244. package/templates/.agents/rules/pr-sync.github.zh-CN.md +11 -1
  245. package/templates/.agents/rules/pr-sync.zh-CN.md +3 -1
  246. package/templates/.agents/rules/release-commands.en.md +1 -1
  247. package/templates/.agents/rules/release-commands.github.en.md +12 -2
  248. package/templates/.agents/rules/release-commands.github.zh-CN.md +12 -2
  249. package/templates/.agents/rules/release-commands.zh-CN.md +1 -1
  250. package/templates/.agents/rules/review-handshake.zh-CN.md +1 -1
  251. package/templates/.agents/rules/task-management.en.md +13 -0
  252. package/templates/.agents/rules/task-management.zh-CN.md +13 -0
  253. package/templates/.agents/skills/analyze-task/SKILL.en.md +10 -7
  254. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +10 -7
  255. package/templates/.agents/skills/block-task/SKILL.en.md +7 -5
  256. package/templates/.agents/skills/block-task/SKILL.zh-CN.md +7 -5
  257. package/templates/.agents/skills/cancel-task/SKILL.en.md +6 -4
  258. package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +6 -4
  259. package/templates/.agents/skills/close-codescan/SKILL.en.md +3 -1
  260. package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +3 -1
  261. package/templates/.agents/skills/close-dependabot/SKILL.en.md +3 -1
  262. package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +3 -1
  263. package/templates/.agents/skills/code-task/SKILL.en.md +10 -7
  264. package/templates/.agents/skills/code-task/SKILL.zh-CN.md +12 -9
  265. package/templates/.agents/skills/commit/SKILL.en.md +23 -11
  266. package/templates/.agents/skills/commit/SKILL.zh-CN.md +29 -11
  267. package/templates/.agents/skills/commit/reference/commit-message.en.md +1 -1
  268. package/templates/.agents/skills/commit/reference/commit-message.zh-CN.md +1 -1
  269. package/templates/.agents/skills/commit/reference/commit-orchestration.en.md +49 -0
  270. package/templates/.agents/skills/commit/reference/commit-orchestration.zh-CN.md +55 -0
  271. package/templates/.agents/skills/commit/reference/issue-metadata-sync.en.md +1 -1
  272. package/templates/.agents/skills/commit/reference/issue-metadata-sync.zh-CN.md +1 -1
  273. package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +1 -1
  274. package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +1 -1
  275. package/templates/.agents/skills/commit/reference/task-status-update.en.md +4 -4
  276. package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +4 -4
  277. package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +6 -4
  278. package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +6 -4
  279. package/templates/.agents/skills/complete-manual-validation/reference/summary-update.en.md +1 -1
  280. package/templates/.agents/skills/complete-manual-validation/reference/summary-update.zh-CN.md +1 -1
  281. package/templates/.agents/skills/complete-task/SKILL.en.md +22 -7
  282. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +22 -7
  283. package/templates/.agents/skills/complete-task/config/verify.en.json +1 -0
  284. package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +1 -0
  285. package/templates/.agents/skills/complete-task/reference/external-delivery.en.md +17 -0
  286. package/templates/.agents/skills/complete-task/reference/external-delivery.zh-CN.md +17 -0
  287. package/templates/.agents/skills/create-pr/SKILL.en.md +7 -5
  288. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +7 -5
  289. package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +1 -1
  290. package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +1 -1
  291. package/templates/.agents/skills/create-release-note/SKILL.en.md +17 -16
  292. package/templates/.agents/skills/create-release-note/SKILL.zh-CN.md +17 -16
  293. package/templates/.agents/skills/create-task/SKILL.en.md +5 -3
  294. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +5 -3
  295. package/templates/.agents/skills/create-task/reference/context-capture.en.md +34 -0
  296. package/templates/.agents/skills/create-task/reference/context-capture.zh-CN.md +34 -0
  297. package/templates/.agents/skills/import-issue/SKILL.en.md +5 -3
  298. package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +5 -3
  299. package/templates/.agents/skills/plan-task/SKILL.en.md +8 -5
  300. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +8 -5
  301. package/templates/.agents/skills/post-release/SKILL.en.md +2 -0
  302. package/templates/.agents/skills/post-release/SKILL.zh-CN.md +2 -0
  303. package/templates/.agents/skills/release/SKILL.en.md +16 -10
  304. package/templates/.agents/skills/release/SKILL.zh-CN.md +16 -10
  305. package/templates/.agents/skills/restore-task/SKILL.en.md +4 -1
  306. package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +4 -1
  307. package/templates/.agents/skills/review-analysis/SKILL.en.md +7 -4
  308. package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +7 -4
  309. package/templates/.agents/skills/review-code/SKILL.en.md +11 -8
  310. package/templates/.agents/skills/review-code/SKILL.zh-CN.md +11 -8
  311. package/templates/.agents/skills/review-code/reference/output-templates.en.md +1 -1
  312. package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +1 -1
  313. package/templates/.agents/skills/review-plan/SKILL.en.md +7 -4
  314. package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +7 -4
  315. package/templates/.agents/skills/review-pr/SKILL.en.md +186 -0
  316. package/templates/.agents/skills/review-pr/SKILL.zh-CN.md +186 -0
  317. package/templates/.agents/skills/review-pr/config/verify.en.json +37 -0
  318. package/templates/.agents/skills/review-pr/config/verify.zh-CN.json +37 -0
  319. package/templates/.agents/skills/review-pr/reference/evidence-grading.en.md +65 -0
  320. package/templates/.agents/skills/review-pr/reference/evidence-grading.zh-CN.md +65 -0
  321. package/templates/.agents/skills/review-pr/reference/output-guidance.en.md +18 -0
  322. package/templates/.agents/skills/review-pr/reference/output-guidance.zh-CN.md +18 -0
  323. package/templates/.agents/skills/review-pr/reference/report-template.en.md +85 -0
  324. package/templates/.agents/skills/review-pr/reference/report-template.zh-CN.md +85 -0
  325. package/templates/.agents/skills/run-task/SKILL.en.md +8 -8
  326. package/templates/.agents/skills/run-task/SKILL.zh-CN.md +8 -8
  327. package/templates/.agents/skills/run-task/config/verify.en.json +2 -1
  328. package/templates/.agents/skills/run-task/config/verify.zh-CN.json +2 -1
  329. package/templates/.agents/skills/run-task/reference/host-validation.en.md +20 -0
  330. package/templates/.agents/skills/run-task/reference/host-validation.zh-CN.md +20 -0
  331. package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +98 -107
  332. package/templates/.agents/skills/watch-pr/SKILL.en.md +13 -13
  333. package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +13 -13
  334. package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +27 -6
  335. package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +26 -5
  336. package/templates/.agents/templates/task.en.md +2 -2
  337. package/templates/.agents/templates/task.zh-CN.md +2 -2
  338. package/templates/.agents/workflows/bug-fix.en.yaml +3 -3
  339. package/templates/.agents/workflows/bug-fix.zh-CN.yaml +3 -3
  340. package/templates/.agents/workflows/code-review.en.yaml +1 -1
  341. package/templates/.agents/workflows/code-review.zh-CN.yaml +1 -1
  342. package/templates/.agents/workflows/feature-development.en.yaml +4 -4
  343. package/templates/.agents/workflows/feature-development.zh-CN.yaml +4 -4
  344. package/templates/.agents/workflows/refactoring.en.yaml +3 -3
  345. package/templates/.agents/workflows/refactoring.zh-CN.yaml +3 -3
  346. package/templates/.claude/commands/post-release.en.md +1 -0
  347. package/templates/.claude/commands/post-release.zh-CN.md +1 -0
  348. package/templates/.claude/commands/review-pr.en.md +8 -0
  349. package/templates/.claude/commands/review-pr.zh-CN.md +8 -0
  350. package/templates/.claude/commands/watch-pr.en.md +1 -1
  351. package/templates/.claude/commands/watch-pr.zh-CN.md +1 -1
  352. package/templates/.claude/rules/tool-preferences.en.md +20 -0
  353. package/templates/.claude/rules/tool-preferences.zh-CN.md +20 -0
  354. package/templates/.opencode/commands/post-release.en.md +2 -0
  355. package/templates/.opencode/commands/post-release.zh-CN.md +2 -0
  356. package/templates/.opencode/commands/review-pr.en.md +11 -0
  357. package/templates/.opencode/commands/review-pr.zh-CN.md +11 -0
  358. package/templates/.opencode/commands/watch-pr.en.md +1 -1
  359. package/templates/.opencode/commands/watch-pr.zh-CN.md +1 -1
  360. package/dist/lib/agent-clients/adapters/gemini-cli.js +0 -64
  361. package/lib/agent-clients/adapters/gemini-cli.ts +0 -65
  362. package/templates/.gemini/commands/_project_/analyze-task.en.toml +0 -10
  363. package/templates/.gemini/commands/_project_/analyze-task.zh-CN.toml +0 -10
  364. package/templates/.gemini/commands/_project_/archive-tasks.en.toml +0 -10
  365. package/templates/.gemini/commands/_project_/archive-tasks.zh-CN.toml +0 -10
  366. package/templates/.gemini/commands/_project_/block-task.en.toml +0 -10
  367. package/templates/.gemini/commands/_project_/block-task.zh-CN.toml +0 -10
  368. package/templates/.gemini/commands/_project_/cancel-task.en.toml +0 -10
  369. package/templates/.gemini/commands/_project_/cancel-task.zh-CN.toml +0 -10
  370. package/templates/.gemini/commands/_project_/check-task.en.toml +0 -10
  371. package/templates/.gemini/commands/_project_/check-task.zh-CN.toml +0 -10
  372. package/templates/.gemini/commands/_project_/close-codescan.en.toml +0 -8
  373. package/templates/.gemini/commands/_project_/close-codescan.zh-CN.toml +0 -8
  374. package/templates/.gemini/commands/_project_/close-dependabot.en.toml +0 -8
  375. package/templates/.gemini/commands/_project_/close-dependabot.zh-CN.toml +0 -8
  376. package/templates/.gemini/commands/_project_/code-task.en.toml +0 -10
  377. package/templates/.gemini/commands/_project_/code-task.zh-CN.toml +0 -10
  378. package/templates/.gemini/commands/_project_/commit.en.toml +0 -10
  379. package/templates/.gemini/commands/_project_/commit.zh-CN.toml +0 -10
  380. package/templates/.gemini/commands/_project_/complete-manual-validation.en.toml +0 -10
  381. package/templates/.gemini/commands/_project_/complete-manual-validation.zh-CN.toml +0 -10
  382. package/templates/.gemini/commands/_project_/complete-task.en.toml +0 -10
  383. package/templates/.gemini/commands/_project_/complete-task.zh-CN.toml +0 -10
  384. package/templates/.gemini/commands/_project_/create-pr.en.toml +0 -10
  385. package/templates/.gemini/commands/_project_/create-pr.zh-CN.toml +0 -10
  386. package/templates/.gemini/commands/_project_/create-release-note.en.toml +0 -8
  387. package/templates/.gemini/commands/_project_/create-release-note.zh-CN.toml +0 -8
  388. package/templates/.gemini/commands/_project_/create-task.en.toml +0 -8
  389. package/templates/.gemini/commands/_project_/create-task.zh-CN.toml +0 -8
  390. package/templates/.gemini/commands/_project_/import-codescan.en.toml +0 -8
  391. package/templates/.gemini/commands/_project_/import-codescan.zh-CN.toml +0 -8
  392. package/templates/.gemini/commands/_project_/import-dependabot.en.toml +0 -8
  393. package/templates/.gemini/commands/_project_/import-dependabot.zh-CN.toml +0 -8
  394. package/templates/.gemini/commands/_project_/import-issue.en.toml +0 -8
  395. package/templates/.gemini/commands/_project_/import-issue.zh-CN.toml +0 -8
  396. package/templates/.gemini/commands/_project_/init-labels.en.toml +0 -8
  397. package/templates/.gemini/commands/_project_/init-labels.zh-CN.toml +0 -8
  398. package/templates/.gemini/commands/_project_/init-milestones.en.toml +0 -10
  399. package/templates/.gemini/commands/_project_/init-milestones.zh-CN.toml +0 -10
  400. package/templates/.gemini/commands/_project_/plan-task.en.toml +0 -10
  401. package/templates/.gemini/commands/_project_/plan-task.zh-CN.toml +0 -10
  402. package/templates/.gemini/commands/_project_/post-release.en.toml +0 -6
  403. package/templates/.gemini/commands/_project_/post-release.zh-CN.toml +0 -6
  404. package/templates/.gemini/commands/_project_/refine-title.en.toml +0 -8
  405. package/templates/.gemini/commands/_project_/refine-title.zh-CN.toml +0 -8
  406. package/templates/.gemini/commands/_project_/release.en.toml +0 -8
  407. package/templates/.gemini/commands/_project_/release.zh-CN.toml +0 -8
  408. package/templates/.gemini/commands/_project_/restore-task.en.toml +0 -8
  409. package/templates/.gemini/commands/_project_/restore-task.zh-CN.toml +0 -8
  410. package/templates/.gemini/commands/_project_/review-analysis.en.toml +0 -10
  411. package/templates/.gemini/commands/_project_/review-analysis.zh-CN.toml +0 -10
  412. package/templates/.gemini/commands/_project_/review-code.en.toml +0 -10
  413. package/templates/.gemini/commands/_project_/review-code.zh-CN.toml +0 -10
  414. package/templates/.gemini/commands/_project_/review-plan.en.toml +0 -10
  415. package/templates/.gemini/commands/_project_/review-plan.zh-CN.toml +0 -10
  416. package/templates/.gemini/commands/_project_/run-task.en.toml +0 -8
  417. package/templates/.gemini/commands/_project_/run-task.zh-CN.toml +0 -8
  418. package/templates/.gemini/commands/_project_/test-integration.en.toml +0 -6
  419. package/templates/.gemini/commands/_project_/test-integration.zh-CN.toml +0 -6
  420. package/templates/.gemini/commands/_project_/test.en.toml +0 -6
  421. package/templates/.gemini/commands/_project_/test.zh-CN.toml +0 -6
  422. package/templates/.gemini/commands/_project_/update-agent-infra.en.toml +0 -6
  423. package/templates/.gemini/commands/_project_/update-agent-infra.zh-CN.toml +0 -6
  424. package/templates/.gemini/commands/_project_/upgrade-dependency.en.toml +0 -8
  425. package/templates/.gemini/commands/_project_/upgrade-dependency.zh-CN.toml +0 -8
  426. package/templates/.gemini/commands/_project_/watch-pr.en.toml +0 -10
  427. package/templates/.gemini/commands/_project_/watch-pr.zh-CN.toml +0 -10
  428. package/templates/.gemini/settings.json +0 -3
@@ -7,6 +7,9 @@ description: >
7
7
  ---
8
8
 
9
9
  # Technical Plan Review
10
+ > `--agent` values follow the "Collaborator Token Specification" in `.agents/rules/task-management.md`: standard AI short tokens (`claude`/`codex`/`antigravity`/`opencode`/`cursor`), long-name normalization (`claude-code`->`claude`, `antigravity-cli`->`antigravity`), or the `human` manual exception.
11
+
12
+ If the entry operands contain `--orchestrated`, bind `{execution-flag}` to `--orchestrated` and forward it unchanged to both the summary finalizer and completed event; otherwise bind it to an empty value. Never infer it from `orchestration.json`, environment variables, or prior artifacts.
10
13
 
11
14
  Review the latest plan artifact and produce `review-plan.md` or `review-plan-r{N}.md`.
12
15
 
@@ -35,7 +38,7 @@ agent-infra-internal task-snapshot {task-id} --format text
35
38
 
36
39
  ## Step Start: Write the started Marker
37
40
 
38
- After resolving the artifact context and before this round's first artifact action, run `agent-infra-internal task-event {task-id} review-plan.started --agent {agent}`.
41
+ After resolving the artifact context and before this round's first artifact action, run `agent-infra-internal task-event {task-id} review-plan.started --agent {standard-agent-token}`.
39
42
 
40
43
  ## Steps
41
44
 
@@ -66,7 +69,7 @@ Create `.agents/workspace/active/{task-id}/{review-artifact}`.
66
69
 
67
70
  ### 6. Update Task Status
68
71
 
69
- After the report, submit each new finding with `agent-infra-internal task-ledger {task-id} finding-upsert --stage plan --review-artifact {review-artifact} --ordinal {n} --severity {blocker|major|minor} --evidence {review-artifact}#{anchor}`; submit prior-response dispositions with `finding-review --id {ledger-id} --status {confirmed|closed|open|needs-human-decision} --evidence {evidence}`. Do not scan ids or edit ledger rows. After all ledger writes, call `agent-infra-internal task-review {task-id} finalize-summary --stage plan --artifact {review-artifact}` exactly once.
72
+ After the report, submit each new finding with `agent-infra-internal task-ledger {task-id} finding-upsert --stage plan --review-artifact {review-artifact} --ordinal {n} --severity {blocker|major|minor} --evidence {review-artifact}#{anchor}`; submit prior-response dispositions with `finding-review --id {ledger-id} --status {confirmed|closed|open|needs-human-decision} --evidence {evidence}`. Do not scan ids or edit ledger rows. After all ledger writes, call `agent-infra-internal task-review {task-id} finalize-summary --stage plan --artifact {review-artifact} {execution-flag}` exactly once.
70
73
 
71
74
  Bind and reuse this structured mapping from that one response:
72
75
 
@@ -76,11 +79,11 @@ Bind and reuse this structured mapping from that one response:
76
79
  {unresolved-minor} = stageStatus.unresolvedFindingCounts.minor
77
80
  ```
78
81
 
79
- The intent atomically finalizes the report summary and returns the same ledger snapshot. Do not call `stage-status`, replace placeholders manually, or rescan the finding list. If finalization fails or a response field is missing, stop before the completion event. Derive the verdict and next-step branch from the same response's `stageStatus.canAdvance`: only `canAdvance=true` permits `approved`; otherwise use `changes-requested` or `rejected`. Then run `agent-infra-internal task-event {task-id} review-plan.completed --agent {agent} --artifact {review-artifact} --verdict {approved|changes-requested|rejected} --blockers {unresolved-blockers} --major {unresolved-major} --minor {unresolved-minor} --manual-validation {n}`.
82
+ The intent atomically finalizes the report summary and returns the same ledger snapshot. Do not call `stage-status`, replace placeholders manually, or rescan the finding list. If finalization fails or a response field is missing, stop before the completion event. Derive the verdict and next-step branch from the same response's `stageStatus.canAdvance`: only `canAdvance=true` permits `approved`; otherwise use `changes-requested` or `rejected`. Then run `agent-infra-internal task-event {task-id} review-plan.completed --agent {standard-agent-token} --artifact {review-artifact} --verdict {approved|changes-requested|rejected} --blockers {unresolved-blockers} --major {unresolved-major} --minor {unresolved-minor} --manual-validation {n} {execution-flag}`.
80
83
 
81
84
  `manual-validation` is the data source for the `Manual-validation` count folded into review rows in `ai task log`; do not add a parallel manual-verification field.
82
85
 
83
- If task.md has a valid `issue_number`, run `agent-infra-internal platform-comment sync {task-id} --kind task --agent {agent}`, then `agent-infra-internal platform-comment sync {task-id} --kind artifact --artifact {review-artifact} --agent {agent}`.
86
+ If task.md has a valid `issue_number`, run `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}`, then `agent-infra-internal platform-comment sync {task-id} --kind artifact --artifact {review-artifact} --agent {standard-agent-token}`.
84
87
 
85
88
  ### 7. Run Completion Gate
86
89
 
@@ -7,6 +7,9 @@ description: >
7
7
  ---
8
8
 
9
9
  # 技术方案审查
10
+ > `--agent` 取值见 `.agents/rules/task-management.md`「合作者 token 规范」:标准 AI 短名(`claude`/`codex`/`antigravity`/`opencode`/`cursor`)、长名归一化(`claude-code`→`claude`、`antigravity-cli`→`antigravity`)或人工例外 `human`。
11
+
12
+ 若入口业务操作数包含 `--orchestrated`,绑定 `{execution-flag}` = `--orchestrated` 并原样转发给 summary finalizer 与 completed 事件;否则绑定为空。不得从 `orchestration.json`、环境变量或历史产物推断该标记。
10
13
 
11
14
  审查最新技术方案产物,并产出 `review-plan.md` 或 `review-plan-r{N}.md`。
12
15
 
@@ -37,7 +40,7 @@ agent-infra-internal task-snapshot {task-id} --format text
37
40
 
38
41
  ## 步骤开始:声明 started 事件
39
42
 
40
- 确认前置条件和产物上下文后、本轮第一个产出动作之前执行 `agent-infra-internal task-event {task-id} review-plan.started --agent {agent}`。
43
+ 确认前置条件和产物上下文后、本轮第一个产出动作之前执行 `agent-infra-internal task-event {task-id} review-plan.started --agent {standard-agent-token}`。
41
44
 
42
45
  ## 执行步骤
43
46
  ### 1. 验证前置条件
@@ -69,7 +72,7 @@ agent-infra-internal task-snapshot {task-id} --format text
69
72
 
70
73
  ### 6. 更新任务状态
71
74
 
72
- 报告完成后,新 finding 逐条调用 `agent-infra-internal task-ledger {task-id} finding-upsert --stage plan --review-artifact {review-artifact} --ordinal {n} --severity {blocker|major|minor} --evidence {review-artifact}#{anchor}`;复核上一轮响应时调用 `finding-review --id {ledger-id} --status {confirmed|closed|open|needs-human-decision} --evidence {相称证据}`。不得扫描编号或手写账本行。全部账本写入完成后只调用一次 `agent-infra-internal task-review {task-id} finalize-summary --stage plan --artifact {review-artifact}`。
75
+ 报告完成后,新 finding 逐条调用 `agent-infra-internal task-ledger {task-id} finding-upsert --stage plan --review-artifact {review-artifact} --ordinal {n} --severity {blocker|major|minor} --evidence {review-artifact}#{anchor}`;复核上一轮响应时调用 `finding-review --id {ledger-id} --status {confirmed|closed|open|needs-human-decision} --evidence {相称证据}`。不得扫描编号或手写账本行。全部账本写入完成后只调用一次 `agent-infra-internal task-review {task-id} finalize-summary --stage plan --artifact {review-artifact} {execution-flag}`。
73
76
 
74
77
  从该次返回值绑定并复用以下结构化映射:
75
78
 
@@ -79,11 +82,11 @@ agent-infra-internal task-snapshot {task-id} --format text
79
82
  {unresolved-minor} = stageStatus.unresolvedFindingCounts.minor
80
83
  ```
81
84
 
82
- 该 intent 原子最终化报告摘要并返回同一次账本快照;不得再调用 `stage-status`、手工替换占位符或扫描问题清单。最终化失败或返回字段缺失时,停止在完成事件之前。以同一次返回的 `stageStatus.canAdvance` 决定 verdict 和下一步:仅 `canAdvance=true` 可用 `approved`,否则必须用 `changes-requested` 或 `rejected`。随后执行 `agent-infra-internal task-event {task-id} review-plan.completed --agent {agent} --artifact {review-artifact} --verdict {approved|changes-requested|rejected} --blockers {unresolved-blockers} --major {unresolved-major} --minor {unresolved-minor} --manual-validation {n}`。
85
+ 该 intent 原子最终化报告摘要并返回同一次账本快照;不得再调用 `stage-status`、手工替换占位符或扫描问题清单。最终化失败或返回字段缺失时,停止在完成事件之前。以同一次返回的 `stageStatus.canAdvance` 决定 verdict 和下一步:仅 `canAdvance=true` 可用 `approved`,否则必须用 `changes-requested` 或 `rejected`。随后执行 `agent-infra-internal task-event {task-id} review-plan.completed --agent {standard-agent-token} --artifact {review-artifact} --verdict {approved|changes-requested|rejected} --blockers {unresolved-blockers} --major {unresolved-major} --minor {unresolved-minor} --manual-validation {n} {execution-flag}`。
83
86
 
84
87
  `manual-validation` 是 `ai task log` 中 review 行「人工校验点」(EN `Manual-validation`)计数的数据源;不要新增并行人工验证字段。
85
88
 
86
- 如果 task.md 中存在有效的 `issue_number`,调用 `agent-infra-internal platform-comment sync {task-id} --kind task --agent {agent}`,再调用 `agent-infra-internal platform-comment sync {task-id} --kind artifact --artifact {review-artifact} --agent {agent}`;失败按 `.agents/rules/issue-sync.md` 记录 warning。
89
+ 如果 task.md 中存在有效的 `issue_number`,调用 `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}`,再调用 `agent-infra-internal platform-comment sync {task-id} --kind artifact --artifact {review-artifact} --agent {standard-agent-token}`;失败按 `.agents/rules/issue-sync.md` 记录 warning。
87
90
 
88
91
  ### 7. 完成校验
89
92
 
@@ -0,0 +1,186 @@
1
+ ---
2
+ name: review-pr
3
+ description: >
4
+ Review a pull request by evidence grade and publish a formal PR review.
5
+ Use when a PR needs review (regardless of whether trusted lifecycle records exist).
6
+ Only invoke this skill automatically when the conversation includes a resolvable PR number or PR URL.
7
+ ---
8
+
9
+ # Review Pull Request
10
+
11
+ Based on the target PR's lifecycle-evidence completeness and change risk, select `verify` (lightweight recheck), `audit` (evidence audit), or `reconstruct` (reconstruction review), publish the actionable review conclusion as a formal PR Review on the target PR, and retain traceable review-process evidence (`pr-review.md` / `pr-review-r{N}.md`).
12
+
13
+ ## Boundary / Critical Rules
14
+
15
+ - Strictly follow the fixed evidence-grading decision flow: host resolution → evidence classification → freshness/alignment → risk grading → mode selection
16
+ - `pr-review*` is an independent artifact family: it does not join the analysis/plan/code stage chain and never changes `current_step`
17
+ - Only a formal PR Review (head SHA, conclusion, findings, receipt, Issue artifact link) is published on the PR; no second full process copy goes to a regular PR comment
18
+ - The full process copy and the reversible `task.md` mirror are synced only to the linked Issue; `restore-task` keeps its Issue-only contract
19
+ - Never backfill or fabricate `analysis`/`plan`/`code` lifecycle history for an external PR
20
+ - The head SHA is recorded only in `pr-review*` and the formal PR Review; on head drift you must start a new round and never reuse an old conclusion
21
+ - Review depth is driven by evidence completeness and change risk, never by the submitter's identity
22
+ - After executing this skill you **must** immediately update task.md (via the `task-activity` typed intent)
23
+ - Never run `git add` or `git commit` automatically
24
+ - The one-shot path (no task/Issue) uses `.agents/workspace/reviews/{pr-number}/` with `recoverable: false` and carries no recovery promise
25
+
26
+ ## Common Rationalizations and Rebuttals
27
+
28
+ | Rationalization | Rebuttal |
29
+ |-----------------|----------|
30
+ | "Just read the diff; no reconstruction needed" | Reading only the diff misses requirement boundaries, architecture choices, and migration strategy; `reconstruct` must first produce the minimum-sufficient reconstruction record. |
31
+ | "The PR has no linked task; just post a report" | Block by default and require linking an Issue/task first; only an explicit "one-shot review" takes the non-recoverable fallback path. |
32
+ | "Also post the full reconstruction to a regular PR comment for contributors" | The process copy is synced only to the Issue artifact comment; the PR keeps only the formal Review to avoid duplicate remote copies and restore-source confusion. |
33
+ | "Commit while I'm at it" | This skill never runs `git add`/`git commit`; committing is a separate, explicitly user-triggered step. |
34
+
35
+ ## Step 0: State Check (pre-execution hard gate)
36
+
37
+ Before making any task-state judgment or user-visible conclusion, run the state check:
38
+
39
+ ```bash
40
+ agent-infra-internal task-snapshot {task-id} --format text
41
+ ```
42
+
43
+ The task-anchored path records the current task directory and existing `pr-review*` rounds before starting; the one-shot path (no task) records the PR number and target directory. Paste the state-check output into the `## State Check` section of this round's `pr-review-rN.md`.
44
+
45
+ ## Steps
46
+
47
+ ### 1. Resolve the Input and the Host
48
+
49
+ Resolve the target PR number `{pr-number}` (`--pr <number>`, a PR URL, or by reverse lookup from the current branch). Run:
50
+
51
+ ```bash
52
+ agent-infra-internal platform-pr-review inspect --pr {pr-number} [--cwd <path>]
53
+ agent-infra-internal pr-review-grade resolve-host --pr {pr-number} [--cwd <path>]
54
+ ```
55
+
56
+ `resolve-host` returns a typed `HostResolution` (`unique` / `ambiguous` / `none`). Branch as follows:
57
+
58
+ - **Unique host**: bind `{task-id}`, call `task-activity pr-review-inspect` to obtain the canonical round, prepared/open state, and latest successful review identity, then start this round using the recovery rules below (go to step 2).
59
+ - **Ambiguous hosts**: `resolve-host` returns `ambiguous` and `decide` refuses to classify (fail closed). Stop and ask a human to pin the unique host; do not enter evidence classification.
60
+ - **No host**: block by default and require linking an Issue/task first (show linking guidance); never auto-create/import an Issue. Only when the user explicitly chooses a "one-shot review" do process files land in `.agents/workspace/reviews/{pr-number}/` (`recoverable: false`).
61
+
62
+ After the task-anchored path resolves the host and remote head, run:
63
+
64
+ ```bash
65
+ agent-infra-internal task-activity {task-id} pr-review-inspect
66
+ ```
67
+
68
+ - `prepared`: reuse that artifact; `open` with an unchanged head: replay start for the same artifact/head (a no-op) and resume the round.
69
+ - `open` with a changed head: first set the old artifact Formal Review Status to `superseded`, then terminate it using the old artifact/head; continue with the next round returned by inspect.
70
+ - No prepared/open round: create the next artifact skeleton from `reference/report-template.md`, initially recording the state check, identity, reviewed head, and `Formal Review Status: pending`.
71
+
72
+ After this branch and before step 2 evidence grading, write started:
73
+
74
+ ```bash
75
+ agent-infra-internal task-activity {task-id} pr-review-start --agent {agent} \
76
+ --artifact {pr-review-artifact} --head {head-sha}
77
+ ```
78
+
79
+ The one-shot path never calls `task-activity`. For a controlled failure after started where the formal Review is known not to have been published, first set the artifact status to `aborted`, then call `pr-review-terminate --outcome aborted --reason <single-line>` with the same artifact/head. If publication outcome is uncertain, leave the round open rather than guessing aborted.
80
+
81
+ ### 2. Single decide: evidence enumeration + classification + risk + mode
82
+
83
+ Write the host, artifact presence, head state, and the six pure-evidence risk factors to an input JSON. Use only the highest `applied` / `no-op` artifact returned by inspect as the prior review; pending/aborted/superseded/failed artifacts count only toward round continuity. Then call once:
84
+
85
+ ```bash
86
+ agent-infra-internal pr-review-grade decide --input-file {decide-input.json} [--cwd <path>]
87
+ ```
88
+
89
+ Returns the full `DecisionRecord` (`scenario` / `freshness` / `alignment` / `risk` / `mode` / `firstReview` / `reason`) in one call. Record the decision input and output verbatim in the `pr-review-rN.md` "Evidence List" section (AC3 traceability). When `host.kind === 'ambiguous'`, the command refuses; return to step 1's blocking exit.
90
+
91
+ ### 3. Generate `pr-review-rN.md`
92
+
93
+ Complete this round's artifact per `reference/report-template.md`; the task-anchored path preserves the identity/head/pending status written in step 1 and does not reallocate the round. In `reconstruct` mode (or `audit` with insufficient evidence), write a "Reconstruction Context" section (requirement boundary / architecture choices / impact surface / validation coverage, see `reference/evidence-grading.md`) before the line-level findings. Record `recoverable: true|false` in the frontmatter or header (the one-shot path sets `false`). After finalizing the findings list, freeze `{verdict, blockers, major, minor}` once; the formal Review body and step 6 complete payload must consume that same object directly, never recounting report prose.
94
+
95
+ ### 4. Sync the Issue artifact comments (task-anchored path)
96
+
97
+ Sync the task comment, then the artifact comment, and capture a stable comment URL:
98
+
99
+ ```bash
100
+ agent-infra-internal platform-comment sync {task-id} --kind task --agent {agent}
101
+ agent-infra-internal platform-comment sync {task-id} --kind artifact --artifact {pr-review-artifact} --agent {agent}
102
+ ```
103
+
104
+ The one-shot path (no task/Issue) skips this step.
105
+
106
+ ### 5. Recheck the head and publish the formal Review
107
+
108
+ Read the remote head again to confirm it did not drift during the review:
109
+
110
+ ```bash
111
+ agent-infra-internal platform-pr-review inspect --pr {pr-number} [--cwd <path>]
112
+ ```
113
+
114
+ If the head matches step 1, assemble the body (head SHA / conclusion / findings / receipt / Issue artifact link, **without a marker**) and publish the formal Review:
115
+
116
+ ```bash
117
+ agent-infra-internal platform-pr-review publish --pr {pr-number} --scope {taskId|pr{pr-number}} --round {round} \
118
+ --commit {head-sha} --event {COMMENT|APPROVE|REQUEST_CHANGES} --body-file {review-body.md} [--dry-run] [--cwd <path>]
119
+ ```
120
+
121
+ `publish` generates and validates the marker (first line) in core and is idempotent per marker + commit (replay is a no-op; marker hit on a different commit fails stably). On head drift, first set the old artifact status to `superseded`, then close the old round:
122
+
123
+ ```bash
124
+ agent-infra-internal task-activity {task-id} pr-review-terminate --agent {agent} \
125
+ --artifact {pr-review-artifact} --head {head-sha} \
126
+ --outcome superseded --reason "head changed before publish"
127
+ ```
128
+
129
+ After closure, re-run step 1 for the next canonical round; never start the new round first. If the remote outcome of `publish` is uncertain, keep the round open and recover through marker + commit idempotency on retry.
130
+
131
+ ### 6. Write back the publication result and task state
132
+
133
+ - **Task-anchored path**: after publish returns `applied` / `no-op`, write the Review ID/URL and matching Formal Review Status into the `pr-review-rN.md` "Publication Result" section, then close the Activity Log with the exact verdict/counts frozen in step 3:
134
+
135
+ ```bash
136
+ agent-infra-internal task-activity {task-id} pr-review-complete --agent {agent} \
137
+ --artifact {pr-review-artifact} --head {head-sha} --verdict {approved|changes-requested|commented} \
138
+ --blockers {blockers} --major {major} --minor {minor}
139
+ ```
140
+
141
+ `task-activity` generates `Verdict: <result>, blockers: N, major: N, minor: N → {pr-review-artifact}` from the typed payload and atomically writes the Activity Log, `## Review Feedback` link, and version stamp through `writeTask`. It never changes `current_step` or puts receipt/head/Review URL into the NOTE.
142
+
143
+ - **One-shot path (no task)**: write the Review ID/URL only into the `pr-review-rN.md` "Publication Result" section; do not call `task-activity`.
144
+
145
+ ### 7. Re-sync after write-back (task-anchored path)
146
+
147
+ Step 6 rewrote the local `pr-review-rN.md` "Publication Result" section and task.md (Activity Log), while step 4 synced the older snapshot. `verify_comment_content` / `verify_task_comment_content` compare full content, so you must re-sync first to align local and remote. Run in order:
148
+
149
+ ```bash
150
+ agent-infra-internal platform-comment sync {task-id} --kind task --agent {agent}
151
+ agent-infra-internal platform-comment sync {task-id} --kind artifact --artifact {pr-review-artifact} --agent {agent}
152
+ ```
153
+
154
+ `platform-comment sync` updates an existing marker comment in place (idempotent), so the comment URL is unchanged. The one-shot path has no task and skips this step.
155
+
156
+ ### 8. Run the completion verification
157
+
158
+ - **Task-anchored path**:
159
+
160
+ ```bash
161
+ agent-infra-internal task-verify {task-id} review-pr.completed --artifact {pr-review-artifact} --format text
162
+ ```
163
+
164
+ - **One-shot path**:
165
+
166
+ ```bash
167
+ agent-infra-internal pr-review-grade verify-artifact --artifact-file {pr-review-artifact} [--cwd <path>]
168
+ ```
169
+
170
+ Exit code 0 passes; 1 means fix per the output and re-run; 2 means stop and ask for human intervention.
171
+
172
+ ### 9. Inform the user
173
+
174
+ Pick the single exit branch per `reference/output-guidance.md` (published / blocked-requires-link / one-shot), and read `.agents/rules/next-step-output.md` before rendering the next step.
175
+
176
+ ## Completion Checklist
177
+
178
+ - [ ] Completed the evidence-graded PR review and produced `pr-review-rN.md`
179
+ - [ ] Published the formal Review on the target PR, bound to the reviewed head SHA
180
+ - [ ] Synced and re-synced the Issue artifact/task comments on the task-anchored path
181
+ - [ ] Ran the completion verification (`task-verify` or `verify-artifact`)
182
+ - [ ] Updated task.md and appended the Activity Log entry (task-anchored path)
183
+
184
+ ## Stop
185
+
186
+ Stop as soon as the checklist is complete. Do not commit automatically.
@@ -0,0 +1,186 @@
1
+ ---
2
+ name: review-pr
3
+ description: >
4
+ 按证据分级审查 PR 并发布正式 Review。
5
+ 当需要审查一个 PR(无论是否已有可信生命周期记录)时使用。
6
+ 仅当对话包含可解析的 PR 编号或 PR URL 时才可自动调用本技能。
7
+ ---
8
+
9
+ # 审查 PR
10
+
11
+ 根据目标 PR 的生命周期证据完整度与变更风险,选择 `verify`(轻量复核)、`audit`(证据审计)或 `reconstruct`(重建式审查),并把可执行的检视结论作为正式 PR Review 发布到目标 PR,同时保留可追溯的审查过程证据(`pr-review.md` / `pr-review-r{N}.md`)。
12
+
13
+ ## 行为边界 / 关键规则
14
+
15
+ - 严格遵循方案中固化的证据分级主决策流:宿主解析 → 证据分类 → 新鲜度/对齐 → 风险分级 → 模式选择
16
+ - `pr-review*` 是独立 artifact family:不接入 analysis/plan/code 阶段依赖链,不修改 `current_step`
17
+ - PR 上只发布正式 PR Review(head SHA、结论、finding、receipt、Issue artifact 链接),不发第二份完整过程原文到 PR 普通评论
18
+ - 完整过程原文与 `task.md` 的可逆镜像只在关联 Issue 上同步;`restore-task` 保持 Issue-only 契约
19
+ - 不得为外部 PR 倒填或伪造已发生的 `analysis`/`plan`/`code` 生命周期历史
20
+ - head SHA 唯一记录于 `pr-review*` 与正式 PR Review;head 漂移必须进入新轮次,不得沿用旧结论
21
+ - 审查深度由证据完整度和变更风险决定,不由提交者身份决定
22
+ - 执行本技能后,你**必须**立即更新 task.md(经 `task-activity` typed intent)
23
+ - 绝不自动执行 `git add` 或 `git commit`
24
+ - 一次性检视路径(无任务/Issue)走 `.agents/workspace/reviews/{pr-number}/`,标记 `recoverable: false`,不承担可恢复承诺
25
+
26
+ ## 常见违规借口与反驳
27
+
28
+ | 借口 | 反驳 |
29
+ |------|------|
30
+ | 「代码 diff 直接看就行了,不需要重建上下文」 | 仅看 diff 会遗漏需求边界、架构选择与迁移策略;`reconstruct` 必须先产出最低充分重建记录。 |
31
+ | 「PR 没有关联任务,直接写个报告发出去」 | 默认阻塞并要求先关联 Issue/task;只有显式「仅一次性检视」才走不可恢复降级路径。 |
32
+ | 「把完整重建过程也发到 PR 普通评论,方便贡献者看」 | 过程原文只同步到 Issue artifact 评论;PR 只保留正式 Review,避免重复远端副本与恢复源混淆。 |
33
+ | 「审查完了顺手提交一下」 | 本技能绝不执行 `git add`/`git commit`;提交是用户显式发起的独立步骤。 |
34
+
35
+ ## 第 0 步:状态核对(执行前硬约束)
36
+
37
+ 在加载本技能与相关规则后、做任何任务状态判断或用户可见结论之前,必须先执行状态核对:
38
+
39
+ ```bash
40
+ agent-infra-internal task-snapshot {task-id} --format text
41
+ ```
42
+
43
+ 任务锚定路径在开始前记录当前任务目录与既有 `pr-review*` 轮次;一次性路径(无任务)记录 PR 编号与目标目录。状态核对输出粘贴到本轮产物 `pr-review-rN.md` 的 `## 状态核对` 段。
44
+
45
+ ## 执行步骤
46
+
47
+ ### 1. 解析入参与宿主解析
48
+
49
+ 解析目标 PR 编号 `{pr-number}`(`--pr <number>`,或 PR URL,或省略时按当前分支反查)。执行:
50
+
51
+ ```bash
52
+ agent-infra-internal platform-pr-review inspect --pr {pr-number} [--cwd <path>]
53
+ agent-infra-internal pr-review-grade resolve-host --pr {pr-number} [--cwd <path>]
54
+ ```
55
+
56
+ `resolve-host` 输出 `HostResolution`(`unique` / `ambiguous` / `none`),按以下策略分流:
57
+
58
+ - **唯一宿主**:绑定 `{task-id}`,调用 `task-activity pr-review-inspect` 取得 canonical round、prepared/open 状态和最近成功审查身份,再按下述恢复规则开始本轮(进入步骤 2)。
59
+ - **多宿主歧义**:`resolve-host` 返回 `ambiguous`,`decide` 会拒绝分类(fail closed)。立即停止并提示人工指定唯一宿主;不进入证据分类。
60
+ - **无宿主**:默认阻塞,要求先建立 Issue/task 关联(给出关联指引),不自动创建/导入 Issue。仅当用户显式选择「仅一次性检视」时,过程文件写入 `.agents/workspace/reviews/{pr-number}/`(`recoverable: false`)。
61
+
62
+ 任务锚定路径在宿主与远端 head 确定后执行:
63
+
64
+ ```bash
65
+ agent-infra-internal task-activity {task-id} pr-review-inspect
66
+ ```
67
+
68
+ - `prepared`:复用该 artifact;`open` 且 head 未变:对同一 artifact/head 重放 start(no-op)并恢复该轮。
69
+ - `open` 且 head 已变:先把旧 artifact 的正式 Review 状态写为 `superseded`,再用旧 artifact/head 执行 terminate;随后使用 inspect 返回的 next round。
70
+ - 无 prepared/open:按 `reference/report-template.md` 创建 next artifact 骨架,先写状态核对、身份信息、被审 head 与 `正式 Review 状态: pending`。
71
+
72
+ 在上述分流完成后、步骤 2 证据分级开始前写 started:
73
+
74
+ ```bash
75
+ agent-infra-internal task-activity {task-id} pr-review-start --agent {agent} \
76
+ --artifact {pr-review-artifact} --head {head-sha}
77
+ ```
78
+
79
+ 一次性路径不调用 `task-activity`。任意 started 后、正式 Review 明确尚未发布的受控失败,都先把 artifact 状态写为 `aborted`,再以同一 artifact/head 调用 `pr-review-terminate --outcome aborted --reason <single-line>`;发布结果不确定时保持 open,不臆断 aborted。
80
+
81
+ ### 2. 单次 decide:证据枚举 + 场景分类 + 风险分级 + 模式选择
82
+
83
+ 把宿主、artifact 存在性、head 状态与六个纯证据风险因素写入输入 JSON。prior review 只使用 inspect 返回的最高 `applied` / `no-op` artifact;pending/aborted/superseded/failed 只参与 round 连续性,不作为既有结论。调用一次:
84
+
85
+ ```bash
86
+ agent-infra-internal pr-review-grade decide --input-file {decide-input.json} [--cwd <path>]
87
+ ```
88
+
89
+ 一次返回完整 `DecisionRecord`(`scenario` / `freshness` / `alignment` / `risk` / `mode` / `firstReview` / `reason`)。把决策输入与输出原样记录到 `pr-review-rN.md` 的「证据清单」段(AC3 可追溯)。`host.kind === 'ambiguous'` 时命令拒绝,回到步骤 1 的阻塞出口。
90
+
91
+ ### 3. 生成 `pr-review-rN.md`
92
+
93
+ 按 `reference/report-template.md` 完成本轮产物;任务锚定路径保留步骤 1 已写入的身份/head/pending 状态,不重新分配 round。`reconstruct`(或 `audit` 证据不足)时,在行级 finding 之前先写「重建上下文」段(需求边界 / 架构选择 / 影响面 / 验证覆盖,见 `reference/evidence-grading.md`)。frontmatter 或首部记录 `recoverable: true|false`(一次性路径为 `false`)。完成最终问题清单后,一次性冻结 `{verdict, blockers, major, minor}`;正式 Review 正文与步骤 6 的 complete payload 必须直接复用该对象,不从报告文案反向统计。
94
+
95
+ ### 4. 同步 Issue artifact 评论(任务锚定路径)
96
+
97
+ 依次同步 task 评论与 artifact 评论,取得稳定 comment URL:
98
+
99
+ ```bash
100
+ agent-infra-internal platform-comment sync {task-id} --kind task --agent {agent}
101
+ agent-infra-internal platform-comment sync {task-id} --kind artifact --artifact {pr-review-artifact} --agent {agent}
102
+ ```
103
+
104
+ 一次性路径(无任务/Issue)跳过本步。
105
+
106
+ ### 5. 核对 head 并发布正式 Review
107
+
108
+ 再次读取远端 head,确认未被审查期间漂移:
109
+
110
+ ```bash
111
+ agent-infra-internal platform-pr-review inspect --pr {pr-number} [--cwd <path>]
112
+ ```
113
+
114
+ 若 head 与步骤 1 记录一致,组装正文(head SHA / 结论 / finding / receipt / Issue artifact 链接,**不含 marker**),发布正式 Review:
115
+
116
+ ```bash
117
+ agent-infra-internal platform-pr-review publish --pr {pr-number} --scope {taskId|pr{pr-number}} --round {round} \
118
+ --commit {head-sha} --event {COMMENT|APPROVE|REQUEST_CHANGES} --body-file {review-body.md} [--dry-run] [--cwd <path>]
119
+ ```
120
+
121
+ `publish` 由 core 生成并校验 marker(首行),按 marker + commit 幂等(重放 no-op;marker 命中但 commit 不一致稳定失败)。head 漂移时,先把旧 artifact 状态写为 `superseded`,再闭合旧轮:
122
+
123
+ ```bash
124
+ agent-infra-internal task-activity {task-id} pr-review-terminate --agent {agent} \
125
+ --artifact {pr-review-artifact} --head {head-sha} \
126
+ --outcome superseded --reason "head changed before publish"
127
+ ```
128
+
129
+ 闭合成功后重新执行步骤 1,进入下一 canonical round;不得先写新轮 started。若 publish 调用的远端结果不确定,保留 open 并在重试时依赖 marker + commit 恢复。
130
+
131
+ ### 6. 回写发布结果与任务状态
132
+
133
+ - **任务锚定路径**:publish 返回 `applied` / `no-op` 后,把 Review ID/URL 与同名正式 Review 状态写入 `pr-review-rN.md`「发布结果」段,再以步骤 3 冻结的同一组 verdict/counts 闭合活动日志:
134
+
135
+ ```bash
136
+ agent-infra-internal task-activity {task-id} pr-review-complete --agent {agent} \
137
+ --artifact {pr-review-artifact} --head {head-sha} --verdict {approved|changes-requested|commented} \
138
+ --blockers {blockers} --major {major} --minor {minor}
139
+ ```
140
+
141
+ `task-activity` 由 typed payload 生成 `Verdict: <结论>, blockers: N, major: N, minor: N → {pr-review-artifact}`,并经 `writeTask` 原子完成 Activity Log、`## 审查反馈` 链接与版本戳刷新;不改 `current_step`,也不把 receipt/head/Review URL 写入 NOTE。
142
+
143
+ - **一次性路径(无任务)**:Review ID/URL 只写 `pr-review-rN.md`「发布结果」段,不调用 `task-activity`。
144
+
145
+ ### 7. 发布后回写再同步(任务锚定路径)
146
+
147
+ 步骤 6 已改写本地 `pr-review-rN.md`「发布结果」段与 task.md(活动日志),而步骤 4 同步的是旧快照。`verify_comment_content` / `verify_task_comment_content` 会全文比对,必须先再同步使本地与远端一致。依次调用:
148
+
149
+ ```bash
150
+ agent-infra-internal platform-comment sync {task-id} --kind task --agent {agent}
151
+ agent-infra-internal platform-comment sync {task-id} --kind artifact --artifact {pr-review-artifact} --agent {agent}
152
+ ```
153
+
154
+ `platform-comment sync` 对既有 marker 评论是幂等原地更新,comment URL 不变。一次性路径无任务,跳过本步。
155
+
156
+ ### 8. 完成校验
157
+
158
+ - **任务锚定路径**:
159
+
160
+ ```bash
161
+ agent-infra-internal task-verify {task-id} review-pr.completed --artifact {pr-review-artifact} --format text
162
+ ```
163
+
164
+ - **一次性路径**:
165
+
166
+ ```bash
167
+ agent-infra-internal pr-review-grade verify-artifact --artifact-file {pr-review-artifact} [--cwd <path>]
168
+ ```
169
+
170
+ 退出码 0 通过;1 按输出修复后重跑;2 停止并告知用户需要人工介入。
171
+
172
+ ### 9. 告知用户
173
+
174
+ 按 `reference/output-guidance.md` 选择唯一出口(正常发布 / 阻塞要求关联 / 一次性检视),渲染下一步前读取 `.agents/rules/next-step-output.md`。
175
+
176
+ ## 完成检查清单
177
+
178
+ - [ ] 已按证据分级完成 PR 审查并产出 `pr-review-rN.md`
179
+ - [ ] 正式 Review 已发布到目标 PR,绑定被审 head SHA
180
+ - [ ] 任务锚定路径的 Issue artifact/task 评论已同步并再同步
181
+ - [ ] 已完成校验(`task-verify` 或 `verify-artifact`)
182
+ - [ ] 已更新 task.md 并追加 Activity Log(任务锚定路径)
183
+
184
+ ## 停止
185
+
186
+ 完成检查清单后立即停止。不要自动提交。
@@ -0,0 +1,37 @@
1
+ {
2
+ "skill": "review-pr",
3
+ "checks": {
4
+ "artifact": {
5
+ "file_pattern": "pr-review.md|pr-review-r{N}.md",
6
+ "required_sections": [
7
+ "Identity",
8
+ "Evidence List",
9
+ "Coverage Matrix",
10
+ "Findings",
11
+ "Publication Result",
12
+ "State Check",
13
+ "Evidence"
14
+ ],
15
+ "required_patterns": [
16
+ "^\\$ ",
17
+ "^- \\*\\*Reviewed Head SHA\\*\\*[::]\\s*[0-9a-f]{40}\\s*$",
18
+ "^- \\*\\*Review Mode\\*\\*[::]\\s*(?:verify|audit|reconstruct)\\s*$",
19
+ "^- \\*\\*Evidence Scenario\\*\\*[::]\\s*S[123]\\s*$",
20
+ "^- \\*\\*receipt\\*\\*[::]\\s*\\S"
21
+ ]
22
+ },
23
+ "activity-log": {
24
+ "expected_action_pattern": "Review PR \\(Round \\d+\\)"
25
+ },
26
+ "platform-sync": {
27
+ "when": "issue_number_exists",
28
+ "expected_comment_marker": "<!-- sync-issue:{task-id}:{artifact-stem} -->",
29
+ "verify_comment_content": true,
30
+ "verify_task_comment_content": true,
31
+ "verify_issue_type": false,
32
+ "verify_issue_fields": false,
33
+ "verify_milestone": false,
34
+ "expected_comment_marker_key": "artifact"
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "skill": "review-pr",
3
+ "checks": {
4
+ "artifact": {
5
+ "file_pattern": "pr-review.md|pr-review-r{N}.md",
6
+ "required_sections": [
7
+ "身份信息",
8
+ "证据清单",
9
+ "覆盖矩阵",
10
+ "问题清单",
11
+ "发布结果",
12
+ "状态核对",
13
+ "证据原文"
14
+ ],
15
+ "required_patterns": [
16
+ "^\\$ ",
17
+ "^- \\*\\*被审 head SHA\\*\\*[::]\\s*[0-9a-f]{40}\\s*$",
18
+ "^- \\*\\*审查模式\\*\\*[::]\\s*(?:verify|audit|reconstruct)\\s*$",
19
+ "^- \\*\\*证据场景\\*\\*[::]\\s*S[123]\\s*$",
20
+ "^- \\*\\*receipt\\*\\*[::]\\s*\\S"
21
+ ]
22
+ },
23
+ "activity-log": {
24
+ "expected_action_pattern": "Review PR \\(Round \\d+\\)"
25
+ },
26
+ "platform-sync": {
27
+ "when": "issue_number_exists",
28
+ "expected_comment_marker": "<!-- sync-issue:{task-id}:{artifact-stem} -->",
29
+ "verify_comment_content": true,
30
+ "verify_task_comment_content": true,
31
+ "verify_issue_type": false,
32
+ "verify_issue_fields": false,
33
+ "verify_milestone": false,
34
+ "expected_comment_marker_key": "artifact"
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,65 @@
1
+ # Evidence Grading Reference
2
+
3
+ This file fixes the evidence-graded decision flow of `review-pr`. All determinations are executed mechanically by the typed-core pure functions (`lib/pr-review/evidence-grading.ts`); the skill's prompt layer only orchestrates. This file explains the criteria and rationale; it does not replace the core.
4
+
5
+ ## Main Decision Flow
6
+
7
+ ```text
8
+ Resolve PR base/head and linked Issue/task (host resolution)
9
+ ├─ Unique host → bind the task, enumerate artifact presence → evidence classification
10
+ ├─ Ambiguous hosts → fail closed (decide refuses to classify; require a human-pinned host)
11
+ └─ No host → block by default and require linking; explicit one-shot → reviews/{pr-number}/
12
+ ↓
13
+ Evidence scenario classification (S1/S2/S3) → freshness/alignment → risk grading → mode selection
14
+ ```
15
+
16
+ ## Host Resolution
17
+
18
+ - Exactly one hit → `unique`; multiple without a unique winner → `ambiguous` (candidate list); zero hits → `none`.
19
+ - Ambiguous hosts fail closed and never enter evidence classification. `pr-review-grade resolve-host --pr <N>` returns a typed `HostResolution`, and `decide` explicitly rejects `ambiguous`.
20
+ - `Closes/Fixes #N` in the PR body (case-insensitive, comma/space separated, lists supported) is parsed by `extractClosingIssueNumbers`; a local `active/*/task.md` `pr_number` hit takes priority over the `issue_number` reverse lookup, and a task hit via both paths deduplicates to a single candidate.
21
+
22
+ ## Evidence Scenario Classification (S1 → S2 → S3)
23
+
24
+ | Scenario | Criteria |
25
+ |----------|----------|
26
+ | S1 complete & trusted | unique task with matching issue_number + complete `analysis`/`plan`/`code` and all three review families + latest `pr-review*` reviewed head == current head + trusted source |
27
+ | S2 partial / suspect | task exists but key artifacts are missing, or the head drifted, or the source is untrusted / cannot prove alignment with the current head |
28
+ | S3 PR-only | no host; or unique task with no lifecycle artifacts at all and no prior `pr-review*` |
29
+
30
+ - S3(b) symmetric criterion: `!hasAnalysis && !hasPlan && !hasCode && !hasReviewAnalysis && !hasReviewPlan && !hasReviewCode && !hasPriorPrReview`. A malformed task with only one review family (review-analysis / review-plan / review-code) falls to S2 → audit.
31
+ - On first review (no prior `pr-review*`) S1(c) is unsatisfied, so a complete-lifecycle task falls to S2 → audit.
32
+
33
+ ## Freshness and Alignment
34
+
35
+ - Freshness benchmark = the reviewed head SHA recorded by the latest `pr-review*`, compared character-for-character with the current head: match → `fresh`, otherwise → `stale`.
36
+ - Alignment = freshness is `fresh` and the `issue_number` / `pr_number` match the resolution result.
37
+ - No prior `pr-review*` → `n/a` / `n/a` (first-review special case).
38
+
39
+ ## Risk Grading (pure evidence)
40
+
41
+ | Factor | LOW | HIGH |
42
+ |--------|-----|------|
43
+ | Change size | few files, small net additions | many files, large net additions |
44
+ | Change sensitivity | no protected paths touched | touches lifecycle / rule / skill / config / security / auth / idempotency / concurrency paths |
45
+ | Structural change | no schema/frontmatter/migration/interface-contract changes | involves schema / frontmatter / migration / interface contract |
46
+ | Test coverage | tests present and passing | no tests or tests missing/failing |
47
+ | Source credibility | a reviewable trusted lifecycle exists and aligns with the current head | no trusted record, or the source is not reviewable |
48
+ | Recovery/merge impact | recovery contract unaffected | may break the recovery contract or create a dual-write source |
49
+
50
+ Aggregation: any priority factor (sensitivity / source credibility) HIGH → HIGH; otherwise any HIGH → MEDIUM; all LOW → LOW. Identity factors never participate in any factor determination.
51
+
52
+ ## Mode Selection Matrix
53
+
54
+ | Evidence scenario | Freshness/alignment | Risk | Mode |
55
+ |-------------------|---------------------|------|------|
56
+ | S1 | fresh + aligned | LOW/MEDIUM | verify (lightweight recheck) |
57
+ | S1 | fresh + aligned | HIGH | audit (evidence audit) |
58
+ | S2 | stale / misaligned / partial-missing | any | audit |
59
+ | S3 | n/a | any | reconstruct (reconstruction review) |
60
+
61
+ Running `review-pr` on a complete-lifecycle task for the first time falls to S2 → audit because there is no prior head record; "trusted lifecycle records → verify" corresponds to the re-review case where a prior `pr-review*` exists and the head has not drifted.
62
+
63
+ ## Minimum-Sufficient Reconstruction
64
+
65
+ When the mode is `reconstruct` (or `audit` with insufficient evidence), form a reconstruction record before the line-level review covering at least: requirement boundary, architecture choices, impact surface, validation coverage; the on-disk order is "Reconstruction Context → Coverage Matrix → line-level Findings".