@fitlab-ai/agent-infra 0.9.0 → 0.9.2

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 (327) hide show
  1. package/README.md +22 -5
  2. package/README.zh-CN.md +21 -5
  3. package/bin/cli.ts +12 -0
  4. package/dist/bin/cli.js +14 -0
  5. package/dist/bin/internal-cli.js +20 -0
  6. package/dist/lib/agent-client.js +163 -0
  7. package/dist/lib/agent-clients/adapter.js +294 -0
  8. package/dist/lib/agent-clients/adapters/claude-code.js +62 -0
  9. package/dist/lib/agent-clients/adapters/codex-sandbox.js +210 -0
  10. package/dist/lib/agent-clients/adapters/codex.js +54 -0
  11. package/dist/lib/agent-clients/adapters/gemini-cli.js +64 -0
  12. package/dist/lib/agent-clients/adapters/index.js +20 -0
  13. package/dist/lib/agent-clients/adapters/opencode.js +64 -0
  14. package/dist/lib/agent-clients/config.js +177 -0
  15. package/dist/lib/agent-clients/custom-tuis.js +99 -0
  16. package/dist/lib/agent-clients/invocation.js +9 -0
  17. package/dist/lib/agent-clients/next-steps.js +38 -0
  18. package/dist/lib/agent-clients/project-assets.js +45 -0
  19. package/dist/lib/agent-clients/reconcile.js +235 -0
  20. package/dist/lib/agent-clients/registry.js +72 -0
  21. package/dist/lib/agent-clients/schema.js +57 -0
  22. package/dist/lib/agent-clients/types.js +29 -0
  23. package/dist/lib/builtin-tuis.js +9 -14
  24. package/dist/lib/defaults.json +85 -73
  25. package/dist/lib/git/review-snapshot.js +25 -10
  26. package/dist/lib/git/reviewed-commit-equivalence.js +110 -0
  27. package/dist/lib/init.js +47 -91
  28. package/dist/lib/internal/agent-client.js +117 -0
  29. package/dist/lib/internal/git-workflow.js +1 -1
  30. package/dist/lib/internal/platform-release-notes.js +53 -0
  31. package/dist/lib/internal/release-workflow.js +175 -17
  32. package/dist/lib/internal/task-orchestration.js +151 -0
  33. package/dist/lib/internal/task-review.js +65 -0
  34. package/dist/lib/merge.js +2 -1
  35. package/dist/lib/platform/adapters.js +38 -1
  36. package/dist/lib/platform/change-request-git-evidence.js +113 -0
  37. package/dist/lib/platform/github-release-notes.js +96 -0
  38. package/dist/lib/platform/issues.js +4 -2
  39. package/dist/lib/platform/merged-pr-equivalence.js +84 -0
  40. package/dist/lib/platform/pr-checks.js +43 -15
  41. package/dist/lib/platform/pull-requests.js +113 -7
  42. package/dist/lib/platform/release-notes.js +143 -0
  43. package/dist/lib/platform/releases.js +1 -1
  44. package/dist/lib/platform/verification-required.js +31 -9
  45. package/dist/lib/prompt.js +15 -3
  46. package/dist/lib/release/channels.js +4 -1
  47. package/dist/lib/release/workflow.js +4 -2
  48. package/dist/lib/remove-dir.js +25 -0
  49. package/dist/lib/run/tui.js +8 -2
  50. package/dist/lib/sandbox/agent-client-reconciler.js +234 -0
  51. package/dist/lib/sandbox/build-proxy.js +63 -0
  52. package/dist/lib/sandbox/clipboard/linux.js +2 -1
  53. package/dist/lib/sandbox/commands/create.js +133 -189
  54. package/dist/lib/sandbox/commands/enter.js +17 -1
  55. package/dist/lib/sandbox/commands/prune.js +2 -2
  56. package/dist/lib/sandbox/commands/rebuild.js +24 -7
  57. package/dist/lib/sandbox/commands/rm.js +3 -2
  58. package/dist/lib/sandbox/config.js +21 -4
  59. package/dist/lib/sandbox/constants.js +3 -0
  60. package/dist/lib/sandbox/dockerfile.js +2 -1
  61. package/dist/lib/sandbox/image-build.js +2 -1
  62. package/dist/lib/sandbox/managed-fs.js +10 -5
  63. package/dist/lib/sandbox/recovery.js +52 -36
  64. package/dist/lib/sandbox/runtimes/ai-tools.dockerfile +24 -3
  65. package/dist/lib/sandbox/runtimes/base.dockerfile +8 -1
  66. package/dist/lib/sandbox/runtimes/java17.dockerfile +8 -1
  67. package/dist/lib/sandbox/runtimes/java21.dockerfile +8 -1
  68. package/dist/lib/sandbox/runtimes/node20.dockerfile +8 -1
  69. package/dist/lib/sandbox/runtimes/node22.dockerfile +8 -1
  70. package/dist/lib/sandbox/runtimes/python3.dockerfile +8 -1
  71. package/dist/lib/sandbox/shell.js +3 -2
  72. package/dist/lib/sandbox/tool-types.js +8 -0
  73. package/dist/lib/sandbox/tools.js +2 -126
  74. package/dist/lib/task/artifact-lifecycle.js +1 -49
  75. package/dist/lib/task/commands/decisions.js +50 -20
  76. package/dist/lib/task/commands/issue-body.js +10 -5
  77. package/dist/lib/task/delegation-receipts.js +107 -0
  78. package/dist/lib/task/events.js +101 -2
  79. package/dist/lib/task/issue-form.js +2 -0
  80. package/dist/lib/task/orchestration.js +420 -0
  81. package/dist/lib/task/review-artifacts.js +143 -59
  82. package/dist/lib/task/review-finalization.js +166 -0
  83. package/dist/lib/task/review-fingerprint.js +13 -0
  84. package/dist/lib/task/verification-checks.js +2 -1
  85. package/dist/lib/task/verification-engine.js +168 -23
  86. package/dist/lib/task/verification-review.js +1 -1
  87. package/dist/lib/task/verification.js +4 -2
  88. package/dist/lib/task/workspace-snapshot.js +34 -0
  89. package/dist/lib/update.js +42 -161
  90. package/lib/agent-client.ts +214 -0
  91. package/lib/agent-clients/adapter.ts +461 -0
  92. package/lib/agent-clients/adapters/claude-code.ts +70 -0
  93. package/lib/agent-clients/adapters/codex-sandbox.ts +245 -0
  94. package/lib/agent-clients/adapters/codex.ts +58 -0
  95. package/lib/agent-clients/adapters/gemini-cli.ts +65 -0
  96. package/lib/agent-clients/adapters/index.ts +27 -0
  97. package/lib/agent-clients/adapters/opencode.ts +66 -0
  98. package/lib/agent-clients/config.ts +278 -0
  99. package/lib/agent-clients/custom-tuis.ts +149 -0
  100. package/lib/agent-clients/invocation.ts +19 -0
  101. package/lib/agent-clients/next-steps.ts +72 -0
  102. package/lib/agent-clients/project-assets.ts +96 -0
  103. package/lib/agent-clients/reconcile.ts +324 -0
  104. package/lib/agent-clients/registry.ts +144 -0
  105. package/lib/agent-clients/schema.ts +62 -0
  106. package/lib/agent-clients/types.ts +78 -0
  107. package/lib/benchmark/schemas/v1.0.0/case-manifest.schema.json +120 -0
  108. package/lib/benchmark/schemas/v1.0.0/common.schema.json +109 -0
  109. package/lib/benchmark/schemas/v1.0.0/grader-result.schema.json +160 -0
  110. package/lib/benchmark/schemas/v1.0.0/run-manifest.schema.json +122 -0
  111. package/lib/benchmark/schemas/v1.0.0/subject.schema.json +227 -0
  112. package/lib/builtin-tuis.ts +16 -15
  113. package/lib/defaults.json +24 -12
  114. package/lib/git/review-snapshot.ts +39 -9
  115. package/lib/git/reviewed-commit-equivalence.ts +135 -0
  116. package/lib/init.ts +53 -121
  117. package/lib/internal/agent-client.ts +131 -0
  118. package/lib/internal/git-workflow.ts +1 -1
  119. package/lib/internal/platform-release-notes.ts +55 -0
  120. package/lib/internal/release-workflow.ts +172 -18
  121. package/lib/internal/task-orchestration.ts +132 -0
  122. package/lib/internal/task-review.ts +65 -0
  123. package/lib/merge.ts +2 -1
  124. package/lib/platform/adapters.ts +142 -3
  125. package/lib/platform/change-request-git-evidence.ts +159 -0
  126. package/lib/platform/github-release-notes.ts +132 -0
  127. package/lib/platform/issues.ts +6 -4
  128. package/lib/platform/merged-pr-equivalence.ts +107 -0
  129. package/lib/platform/pr-checks.ts +57 -28
  130. package/lib/platform/pull-requests.ts +140 -25
  131. package/lib/platform/release-notes.ts +167 -0
  132. package/lib/platform/releases.ts +1 -1
  133. package/lib/platform/verification-required.ts +37 -9
  134. package/lib/prompt.ts +16 -3
  135. package/lib/release/channels.ts +4 -1
  136. package/lib/release/workflow.ts +4 -3
  137. package/lib/remove-dir.ts +28 -0
  138. package/lib/run/tui.ts +9 -1
  139. package/lib/sandbox/agent-client-reconciler.ts +378 -0
  140. package/lib/sandbox/build-proxy.ts +94 -0
  141. package/lib/sandbox/clipboard/linux.ts +2 -1
  142. package/lib/sandbox/commands/create.ts +188 -203
  143. package/lib/sandbox/commands/enter.ts +23 -1
  144. package/lib/sandbox/commands/prune.ts +2 -2
  145. package/lib/sandbox/commands/rebuild.ts +29 -7
  146. package/lib/sandbox/commands/rm.ts +3 -2
  147. package/lib/sandbox/config.ts +31 -4
  148. package/lib/sandbox/constants.ts +6 -0
  149. package/lib/sandbox/dockerfile.ts +2 -1
  150. package/lib/sandbox/image-build.ts +4 -1
  151. package/lib/sandbox/managed-fs.ts +18 -5
  152. package/lib/sandbox/recovery.ts +98 -67
  153. package/lib/sandbox/runtimes/ai-tools.dockerfile +24 -3
  154. package/lib/sandbox/runtimes/base.dockerfile +8 -1
  155. package/lib/sandbox/runtimes/java17.dockerfile +8 -1
  156. package/lib/sandbox/runtimes/java21.dockerfile +8 -1
  157. package/lib/sandbox/runtimes/node20.dockerfile +8 -1
  158. package/lib/sandbox/runtimes/node22.dockerfile +8 -1
  159. package/lib/sandbox/runtimes/python3.dockerfile +8 -1
  160. package/lib/sandbox/shell.ts +4 -2
  161. package/lib/sandbox/tool-types.ts +143 -0
  162. package/lib/sandbox/tools.ts +5 -157
  163. package/lib/task/artifact-lifecycle.ts +1 -38
  164. package/lib/task/commands/decisions.ts +53 -20
  165. package/lib/task/commands/issue-body.ts +10 -5
  166. package/lib/task/delegation-receipts.ts +170 -0
  167. package/lib/task/events.ts +111 -3
  168. package/lib/task/issue-form.ts +4 -0
  169. package/lib/task/orchestration.ts +543 -0
  170. package/lib/task/review-artifacts.ts +201 -69
  171. package/lib/task/review-finalization.ts +275 -0
  172. package/lib/task/review-fingerprint.ts +15 -1
  173. package/lib/task/verification-checks.ts +2 -1
  174. package/lib/task/verification-engine.ts +190 -25
  175. package/lib/task/verification-review.ts +2 -0
  176. package/lib/task/verification.ts +6 -3
  177. package/lib/task/workspace-snapshot.ts +36 -0
  178. package/lib/update.ts +48 -184
  179. package/package.json +2 -2
  180. package/templates/.agents/README.en.md +21 -20
  181. package/templates/.agents/README.zh-CN.md +21 -20
  182. package/templates/.agents/hooks/lifecycle-delegation.js +64 -0
  183. package/templates/.agents/rules/README.en.md +2 -0
  184. package/templates/.agents/rules/README.zh-CN.md +2 -0
  185. package/templates/.agents/rules/commit-and-pr.en.md +1 -0
  186. package/templates/.agents/rules/commit-and-pr.zh-CN.md +1 -0
  187. package/templates/.agents/rules/human-decision-context.en.md +14 -12
  188. package/templates/.agents/rules/human-decision-context.zh-CN.md +14 -12
  189. package/templates/.agents/rules/lifecycle-orchestration.en.md +21 -0
  190. package/templates/.agents/rules/lifecycle-orchestration.zh-CN.md +21 -0
  191. package/templates/.agents/rules/next-step-output.en.md +16 -0
  192. package/templates/.agents/rules/next-step-output.zh-CN.md +16 -0
  193. package/templates/.agents/rules/no-mid-flow-questions.en.md +2 -0
  194. package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +2 -0
  195. package/templates/.agents/rules/release-commands.en.md +2 -2
  196. package/templates/.agents/rules/release-commands.github.en.md +15 -39
  197. package/templates/.agents/rules/release-commands.github.zh-CN.md +14 -38
  198. package/templates/.agents/rules/release-commands.zh-CN.md +2 -2
  199. package/templates/.agents/rules/review-handshake.en.md +4 -3
  200. package/templates/.agents/rules/review-handshake.zh-CN.md +4 -3
  201. package/templates/.agents/rules/review-method.en.md +113 -0
  202. package/templates/.agents/rules/review-method.zh-CN.md +98 -0
  203. package/templates/.agents/rules/testing-discipline.en.md +20 -2
  204. package/templates/.agents/rules/testing-discipline.zh-CN.md +20 -2
  205. package/templates/.agents/skills/analyze-task/SKILL.en.md +9 -6
  206. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +9 -6
  207. package/templates/.agents/skills/block-task/SKILL.en.md +4 -4
  208. package/templates/.agents/skills/block-task/SKILL.zh-CN.md +4 -4
  209. package/templates/.agents/skills/cancel-task/SKILL.en.md +4 -4
  210. package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +5 -5
  211. package/templates/.agents/skills/check-task/SKILL.en.md +16 -16
  212. package/templates/.agents/skills/check-task/SKILL.zh-CN.md +16 -16
  213. package/templates/.agents/skills/close-codescan/SKILL.en.md +4 -4
  214. package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +4 -4
  215. package/templates/.agents/skills/close-dependabot/SKILL.en.md +4 -4
  216. package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +4 -4
  217. package/templates/.agents/skills/code-task/SKILL.en.md +1 -1
  218. package/templates/.agents/skills/code-task/SKILL.zh-CN.md +2 -2
  219. package/templates/.agents/skills/code-task/reference/fix-mode.en.md +14 -16
  220. package/templates/.agents/skills/code-task/reference/fix-mode.zh-CN.md +14 -16
  221. package/templates/.agents/skills/code-task/reference/output-template.en.md +3 -3
  222. package/templates/.agents/skills/code-task/reference/output-template.zh-CN.md +3 -3
  223. package/templates/.agents/skills/commit/SKILL.en.md +11 -1
  224. package/templates/.agents/skills/commit/SKILL.zh-CN.md +11 -1
  225. package/templates/.agents/skills/commit/reference/task-status-update.en.md +24 -28
  226. package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +24 -28
  227. package/templates/.agents/skills/complete-task/SKILL.en.md +3 -3
  228. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +3 -3
  229. package/templates/.agents/skills/complete-task/config/verify.en.json +0 -1
  230. package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +0 -1
  231. package/templates/.agents/skills/create-pr/SKILL.en.md +10 -10
  232. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +10 -10
  233. package/templates/.agents/skills/create-pr/reference/pr-body-template.en.md +3 -3
  234. package/templates/.agents/skills/create-pr/reference/pr-body-template.zh-CN.md +3 -3
  235. package/templates/.agents/skills/create-release-note/SKILL.en.md +17 -38
  236. package/templates/.agents/skills/create-release-note/SKILL.zh-CN.md +16 -37
  237. package/templates/.agents/skills/create-task/SKILL.en.md +15 -11
  238. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +15 -11
  239. package/templates/.agents/skills/create-task/reference/context-capture.en.md +29 -0
  240. package/templates/.agents/skills/create-task/reference/context-capture.zh-CN.md +29 -0
  241. package/templates/.agents/skills/import-codescan/SKILL.en.md +5 -5
  242. package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +5 -5
  243. package/templates/.agents/skills/import-dependabot/SKILL.en.md +5 -5
  244. package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +5 -5
  245. package/templates/.agents/skills/import-issue/SKILL.en.md +5 -5
  246. package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +5 -5
  247. package/templates/.agents/skills/init-labels/SKILL.en.md +4 -4
  248. package/templates/.agents/skills/init-labels/SKILL.zh-CN.md +4 -4
  249. package/templates/.agents/skills/init-milestones/SKILL.en.md +4 -4
  250. package/templates/.agents/skills/init-milestones/SKILL.zh-CN.md +4 -4
  251. package/templates/.agents/skills/plan-task/SKILL.en.md +5 -5
  252. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +5 -5
  253. package/templates/.agents/skills/refine-title/SKILL.en.md +1 -1
  254. package/templates/.agents/skills/refine-title/SKILL.zh-CN.md +1 -1
  255. package/templates/.agents/skills/release/SKILL.en.md +1 -1
  256. package/templates/.agents/skills/review-analysis/SKILL.en.md +13 -2
  257. package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +14 -3
  258. package/templates/.agents/skills/review-analysis/config/verify.en.json +6 -0
  259. package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +6 -0
  260. package/templates/.agents/skills/review-analysis/reference/output-templates.en.md +13 -15
  261. package/templates/.agents/skills/review-analysis/reference/output-templates.zh-CN.md +13 -15
  262. package/templates/.agents/skills/review-analysis/reference/report-template.en.md +51 -5
  263. package/templates/.agents/skills/review-analysis/reference/report-template.zh-CN.md +52 -6
  264. package/templates/.agents/skills/review-analysis/reference/review-criteria.en.md +25 -22
  265. package/templates/.agents/skills/review-analysis/reference/review-criteria.zh-CN.md +25 -22
  266. package/templates/.agents/skills/review-code/SKILL.en.md +28 -8
  267. package/templates/.agents/skills/review-code/SKILL.zh-CN.md +28 -8
  268. package/templates/.agents/skills/review-code/config/verify.en.json +7 -0
  269. package/templates/.agents/skills/review-code/config/verify.zh-CN.json +7 -0
  270. package/templates/.agents/skills/review-code/reference/concurrency-risks.en.md +25 -0
  271. package/templates/.agents/skills/review-code/reference/concurrency-risks.zh-CN.md +25 -0
  272. package/templates/.agents/skills/review-code/reference/cross-platform-risks.en.md +27 -0
  273. package/templates/.agents/skills/review-code/reference/cross-platform-risks.zh-CN.md +27 -0
  274. package/templates/.agents/skills/review-code/reference/documentation-antipatterns.en.md +13 -0
  275. package/templates/.agents/skills/review-code/reference/documentation-antipatterns.zh-CN.md +13 -0
  276. package/templates/.agents/skills/review-code/reference/migration-risks.en.md +25 -0
  277. package/templates/.agents/skills/review-code/reference/migration-risks.zh-CN.md +25 -0
  278. package/templates/.agents/skills/review-code/reference/output-templates.en.md +22 -24
  279. package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +22 -24
  280. package/templates/.agents/skills/review-code/reference/report-template.en.md +54 -7
  281. package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +54 -7
  282. package/templates/.agents/skills/review-code/reference/review-criteria.en.md +29 -24
  283. package/templates/.agents/skills/review-code/reference/review-criteria.zh-CN.md +29 -24
  284. package/templates/.agents/skills/review-code/reference/security-risks.en.md +25 -0
  285. package/templates/.agents/skills/review-code/reference/security-risks.zh-CN.md +25 -0
  286. package/templates/.agents/skills/review-plan/SKILL.en.md +13 -2
  287. package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +14 -3
  288. package/templates/.agents/skills/review-plan/config/verify.en.json +6 -0
  289. package/templates/.agents/skills/review-plan/config/verify.zh-CN.json +6 -0
  290. package/templates/.agents/skills/review-plan/reference/output-templates.en.md +13 -15
  291. package/templates/.agents/skills/review-plan/reference/output-templates.zh-CN.md +13 -15
  292. package/templates/.agents/skills/review-plan/reference/report-template.en.md +61 -5
  293. package/templates/.agents/skills/review-plan/reference/report-template.zh-CN.md +61 -5
  294. package/templates/.agents/skills/review-plan/reference/review-criteria.en.md +21 -24
  295. package/templates/.agents/skills/review-plan/reference/review-criteria.zh-CN.md +21 -24
  296. package/templates/.agents/skills/run-task/SKILL.en.md +22 -0
  297. package/templates/.agents/skills/run-task/SKILL.zh-CN.md +22 -0
  298. package/templates/.agents/skills/run-task/config/verify.en.json +9 -0
  299. package/templates/.agents/skills/run-task/config/verify.zh-CN.json +9 -0
  300. package/templates/.agents/skills/test/SKILL.en.md +4 -4
  301. package/templates/.agents/skills/test/SKILL.zh-CN.md +4 -4
  302. package/templates/.agents/skills/test-integration/SKILL.en.md +4 -4
  303. package/templates/.agents/skills/test-integration/SKILL.zh-CN.md +4 -4
  304. package/templates/.agents/skills/update-agent-infra/SKILL.en.md +5 -5
  305. package/templates/.agents/skills/update-agent-infra/SKILL.zh-CN.md +5 -5
  306. package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +647 -203
  307. package/templates/.agents/skills/upgrade-dependency/SKILL.en.md +4 -4
  308. package/templates/.agents/skills/upgrade-dependency/SKILL.zh-CN.md +4 -4
  309. package/templates/.agents/skills/watch-pr/SKILL.en.md +8 -8
  310. package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +8 -8
  311. package/templates/.agents/templates/task.en.md +18 -0
  312. package/templates/.agents/templates/task.zh-CN.md +18 -0
  313. package/templates/.claude/agents/agent-infra-lifecycle-executor.en.md +6 -0
  314. package/templates/.claude/agents/agent-infra-lifecycle-executor.zh-CN.md +6 -0
  315. package/templates/.claude/agents/agent-infra-lifecycle-reviewer.en.md +6 -0
  316. package/templates/.claude/agents/agent-infra-lifecycle-reviewer.zh-CN.md +6 -0
  317. package/templates/.claude/commands/run-task.en.md +8 -0
  318. package/templates/.claude/commands/run-task.zh-CN.md +8 -0
  319. package/templates/.claude/settings.json +24 -0
  320. package/templates/.codex/agents/agent-infra-lifecycle-executor.en.toml +3 -0
  321. package/templates/.codex/agents/agent-infra-lifecycle-executor.zh-CN.toml +3 -0
  322. package/templates/.codex/agents/agent-infra-lifecycle-reviewer.en.toml +3 -0
  323. package/templates/.codex/agents/agent-infra-lifecycle-reviewer.zh-CN.toml +3 -0
  324. package/templates/.gemini/commands/_project_/run-task.en.toml +8 -0
  325. package/templates/.gemini/commands/_project_/run-task.zh-CN.toml +8 -0
  326. package/templates/.opencode/commands/run-task.en.md +11 -0
  327. package/templates/.opencode/commands/run-task.zh-CN.md +11 -0
@@ -4,32 +4,34 @@
4
4
 
5
5
  ## 自足性要求
6
6
 
7
- 详情必须让维护者无需模型二次推理即可理解并裁决。每项必须明确说明背景、裁决目标、影响范围、风险、推荐方案与推荐理由,并至少提供两个可选方案;每个方案都必须同时列出收益和代价。
7
+ 详情必须让维护者不需要了解内部流程,也不需要再问模型,就能看懂并做选择。先用大白话说明为什么现在需要决定、具体要选什么、建议选哪个以及原因;再说明会影响什么、选错或暂不处理会怎样。
8
+
9
+ 每项至少提供两个有简短名称的方案,并分别写清好处和代价。第一次出现 stage、severity、evidence 等内部术语时,必须顺手解释它们的意思;ID 和 evidence 只用于后续查找和排查,不能代替问题说明。
8
10
 
9
11
  ## 规范结构
10
12
 
11
13
  ```markdown
12
14
  ### {AN-N|PL-N|CD-N|HD-N}:{标题} [needs-human-decision]
13
15
 
14
- - **背景**:{为何需要裁决;已知事实与约束}
15
- - **裁决目标**:{本次必须确定的唯一选择}
16
- - **影响范围**:{受影响的功能、文件、用户或后续先例}
17
- - **风险**:{错误选择、延期或不裁决的风险}
18
- - **推荐方案**:{方案 A/B/...}
19
- - **推荐理由**:{基于收益、代价和约束的理由}
16
+ - **为什么现在要决定**:{用大白话说明已知情况、限制,以及为什么不能直接继续}
17
+ - **要决定什么**:{本次只需要选定的一件事}
18
+ - **建议选哪个**:{方案 A/B/...}
19
+ - **为什么这样建议**:{结合好处、代价和现有限制说明原因}
20
+ - **会影响什么**:{会受影响的功能、文件、用户或后续做法}
21
+ - **如果选错或暂不处理**:{可能出现的问题}
20
22
 
21
23
  #### 方案 A:{名称}
22
24
 
23
- - **收益**:{选择该方案的收益}
24
- - **代价**:{选择该方案的成本与局限}
25
+ - **好处**:{选择该方案能得到什么}
26
+ - **代价**:{选择该方案要付出什么、有哪些局限}
25
27
 
26
28
  #### 方案 B:{名称}
27
29
 
28
- - **收益**:{选择该方案的收益}
29
- - **代价**:{选择该方案的成本与局限}
30
+ - **好处**:{选择该方案能得到什么}
31
+ - **代价**:{选择该方案要付出什么、有哪些局限}
30
32
  ```
31
33
 
32
- 可增加方案 C 或补充证据,但不得省略上述字段或把多个方案压缩为无法分别比较的一行。标题 ID 必须与 task.md `## 审查分歧账本` 行一致,evidence 必须指向该标题的稳定锚点。
34
+ 可增加方案 C 或补充证据,但不得省略上述信息或把多个方案压缩为无法分别比较的一行。标题 ID 必须与 task.md `## 审查分歧账本` 行一致;evidence(用于定位原始说明的引用)必须指向该标题的稳定锚点。
33
35
 
34
36
  ## 裁决闭环
35
37
 
@@ -0,0 +1,21 @@
1
+ # Common Rule - Lifecycle Orchestration
2
+
3
+ ## Guarantee Boundary
4
+
5
+ - The orchestrator only routes and delegates. Stage skills remain the single source of truth for behavior and artifacts.
6
+ - Every stage and rework round uses a fresh executor. Every review uses a fresh reviewer; follow-up reuse is forbidden.
7
+ - A reviewer may only write its review artifact and core-generated task metadata. Business-code, HEAD, or index changes invalidate the receipt.
8
+ - An active run has one pending delegation. Missing, mismatched, forked, replayed, hook-less, or drifted evidence pauses the run.
9
+ - The first release ends after one existing safely gated `commit`; it does not create a PR, monitor checks, or complete the task.
10
+
11
+ ## Recovery
12
+
13
+ `orchestration.json` is the detailed state source. Re-entry reconciles first: completed runs return idempotently; recoverable pauses continue only after the blocker clears; unproven children, unsealed receipts, and baseline drift stay paused. Reviewer identities are never reused.
14
+
15
+ ## Model Policy
16
+
17
+ Prefer a reviewer model different from the preceding executor. Same-model fallback must record requested model, actual model, and reason; an unrecorded fallback fails closed.
18
+
19
+ ## Stable Pause Conditions
20
+
21
+ Human decisions, manual validation, handshake or step limits, permissions/network failures, worktree conflicts, unsupported client capability, and unknown hook schemas are persisted as pauses. The orchestrator must not ask mid-flow or degrade to same-context self-review.
@@ -0,0 +1,21 @@
1
+ # 通用规则 - 生命周期总控
2
+
3
+ ## 保证边界
4
+
5
+ - 总控只路由和委派;阶段技能仍是业务规则与产物格式的单一事实源。
6
+ - 每个阶段和每轮返工都创建 fresh executor;每轮审查创建 fresh reviewer,禁止 follow-up 复用。
7
+ - reviewer 只能写当前审查产物和核心生成的任务元数据。业务代码、HEAD 或暂存区变化会使 receipt 失效。
8
+ - active run 中只有一个 pending delegation。缺失、错配、fork、重放、hook 不可用或工作区漂移一律暂停。
9
+ - 首版成功终点是一次通过既有安全门禁的 `commit`;不创建 PR、不监控 checks、不执行 `complete-task`。
10
+
11
+ ## 恢复语义
12
+
13
+ `orchestration.json` 是详细状态源。重复入口先 reconcile:已完成 run 幂等返回;可恢复暂停在阻塞解除后继续;无法证明已停止的 child、未封存 receipt 或基线漂移继续保持暂停。旧 reviewer identity 永不复用。
14
+
15
+ ## 模型策略
16
+
17
+ reviewer 优先选择与上一 executor 不同的模型。若客户端只能使用同模型,必须记录 requested model、actual model 和降级原因;缺少降级理由时失败关闭。
18
+
19
+ ## 稳定暂停条件
20
+
21
+ 人工裁决、人工验证、握手或总步骤上限、权限/网络失败、用户工作区冲突、客户端 capability 不支持及未知 hook schema 都持久化为暂停原因。总控不得中途询问或降级为同上下文自审。
@@ -20,6 +20,22 @@ This file defines four **independent** rules for a skill's "notify-user / Next s
20
20
  - **"Task info" / "Task status" structured field lines** → show full id and short id together: `- Task ID: {task-id} (short id {task-ref})`.
21
21
  - **Report titles** (`Task {task-id} ... completed`) and **artifact paths** (`.agents/workspace/active/{task-id}/...`) → keep the full `{task-id}` (physical path and archive key, must not change).
22
22
 
23
+ ## Unified Client Command Rendering
24
+
25
+ Next-step client commands must come from the shared helper; skills and output templates must not assemble client command tables themselves:
26
+
27
+ ```bash
28
+ agent-infra-internal agent-client next-steps \
29
+ --skill {next-skill-name} \
30
+ [--task-ref {task-ref}]
31
+ ```
32
+
33
+ - Pass the next skill name for the already-selected scenario. Include `--task-ref` only when that command needs a task reference.
34
+ - The helper lists only built-in clients enabled in `.agents/.airc.json` `agentClients`, followed by valid `customTUIs` in configuration order.
35
+ - Insert non-empty stdout verbatim at `{next-step-commands}` below the current "Next steps" heading. When stdout is empty, omit the client command block while still rendering reminders, warnings, and `Completed at`.
36
+ - If the helper writes stderr or exits non-zero, use the current skill's error path and stop; never fall back to a hard-coded client table.
37
+ - A complex skill selects one scenario first and invokes the helper once for that scenario; it must not pre-render every branch.
38
+
23
39
  ## Obtaining the short id (`{task-ref}`)
24
40
 
25
41
  The single source of truth for short ids is the registry `.agents/workspace/active/.short-ids.json` (via `task-short-id.js`). **Never** read the `short_id` field from task.md frontmatter (that field is not authoritative).
@@ -20,6 +20,22 @@
20
20
  - **「任务信息」/「任务状态」结构化字段行** → 完整 ID 与短号同显:`- 任务 ID:{task-id}(短号 {task-ref})`。
21
21
  - **报告标题**(`任务 {task-id} ... 完成`)与**产出文件路径**(`.agents/workspace/active/{task-id}/...`)→ 保持完整 `{task-id}`(物理路径与归档键,不可改)。
22
22
 
23
+ ## 统一客户端命令渲染
24
+
25
+ 下一步客户端命令必须由统一 helper 生成,skill 和输出模板不得自行拼接客户端命令表:
26
+
27
+ ```bash
28
+ agent-infra-internal agent-client next-steps \
29
+ --skill {next-skill-name} \
30
+ [--task-ref {task-ref}]
31
+ ```
32
+
33
+ - 静态传入当前已选场景的下一 skill 名;只有命令需要任务引用时才传 `--task-ref`。
34
+ - helper 只展示 `.agents/.airc.json` 中 `agentClients` 已启用的内建客户端,并在其后按配置顺序追加合法的 `customTUIs`。
35
+ - 将非空 stdout 原样放入当前“下一步”标题后的 `{next-step-commands}`;stdout 为空时省略整个客户端命令块,但继续输出提醒、告警和 `Completed at`。
36
+ - helper 写 stderr 或返回非零时,按当前 skill 的错误路径报告并停止;禁止回退到硬编码客户端表。
37
+ - 复杂 skill 先选定唯一场景,再只为该场景调用一次 helper,不得提前渲染所有分支。
38
+
23
39
  ## 取短号(`{task-ref}`)
24
40
 
25
41
  短号唯一真源是注册表 `.agents/workspace/active/.short-ids.json`(经 `task-short-id.js`)。**禁止**读取 task.md frontmatter 的 `short_id` 字段(该字段不可信)。
@@ -78,6 +78,8 @@ A mandatory human review checkpoint means:
78
78
 
79
79
  If a key decision needs human judgment during execution, follow the rule above and register the detail identity through the structured `decision-next-id` / `decision-upsert` commands for the user to address at the review checkpoint; ordinary open questions still go to `## Open Questions` / `未决问题`.
80
80
 
81
+ The `run-task` orchestrator may continue after a child skill artifact only when core mechanical state permits it; this does not bypass human decisions. When core reports a human decision, manual validation, or another stable pause condition, the orchestrator must stop without asking mid-flow or approving it itself.
82
+
81
83
  ## Anchor Location
82
84
 
83
85
  This rule's sole global anchor lives in the project-level AGENTS.md "AI Behavior Principles" preamble, which every AI tool loads. Individual SKILL.md files no longer reference this rule, so no per-skill duplicate bullet needs to be maintained.
@@ -78,6 +78,8 @@
78
78
 
79
79
  如果在执行过程中发现需要用户裁定的关键决策,按上文「关键设计决策标记与落账」处理:通过 `decision-next-id` / `decision-upsert` 结构化命令登记详情块与账本身份,由用户在审查检查点统一回应;普通未决问题仍写 `## 未决问题` / `Open Questions`。
80
80
 
81
+ `run-task` 总控可以在子技能产出后依据核心机械状态继续到下一阶段;这不构成绕过人工裁决。只要核心返回人工裁决、人工验证或其他稳定暂停条件,总控必须停止,不能向用户中途提问,也不能自行批准。
82
+
81
83
  ## 锚点位置
82
84
 
83
85
  本规则的唯一全局锚点在项目级 AGENTS.md 的「AI 行为准则」preamble,所有 AI 工具加载 AGENTS.md 时即可见。各 SKILL.md 不再单独引用本规则,避免在每个 SKILL 顶部维护重复 bullet。
@@ -1,5 +1,5 @@
1
1
  # Release Commands
2
2
 
3
- This code platform does not provide built-in release commands.
3
+ This code platform does not provide a release-note adapter.
4
4
 
5
- Remote release automation is skipped for custom platforms unless you provide matching `.{platform}.en.md` rule templates and scripts. Continue using local release artifacts or your platform-specific release process.
5
+ Use `agent-infra-internal platform-release-notes context` to receive a structured `PLATFORM_RELEASE_NOTES_UNSUPPORTED` no-op. Do not probe another platform client. Publishing remains a no-op until an adapter is provided.
@@ -1,52 +1,28 @@
1
1
  # Release Platform Commands
2
2
 
3
- Read this file before loading release history, querying merged PRs, or publishing the Release notes.
3
+ Release-note platform operations use a typed internal intent. Callers consume structured JSON and do not interpret platform commands, raw fields, identity email rules, or authentication errors.
4
4
 
5
- ## Query Releases
5
+ ## Collect Release-note Context
6
6
 
7
7
  ```bash
8
- gh release list --limit {limit} --json tagName,isDraft,isPrerelease
9
- gh release view "{tag}" --json body,url
8
+ agent-infra-internal platform-release-notes context \
9
+ --from-tag "v{prev-version}" \
10
+ --to-tag "v{version}" \
11
+ --branch "{branch}" \
12
+ --history-limit 3
10
13
  ```
11
14
 
12
- ## Query Merged PRs
15
+ The result contains `history`, `pullRequests`, `closingIssues`, and commit `authors` with normalized `login` / `resolution` values. `status: no-op` with error code `PLATFORM_RELEASE_NOTES_UNSUPPORTED` means the current platform does not support remote release-note operations.
13
16
 
14
- ```bash
15
- gh pr list --state merged --base "{branch}" --json number,title,mergedAt,labels
16
- ```
17
-
18
- When needed, read the linked Issue:
19
-
20
- ```bash
21
- gh issue view {issue-number} --json number,title,labels,url
22
- ```
23
-
24
- ## Contributor Mapping Helpers
25
-
26
- Merged PR queries used for release notes should include authors when contributors are needed:
27
-
28
- ```bash
29
- gh pr list --state merged --base "{branch}" --json number,title,mergedAt,labels,author
30
- ```
31
-
32
- Linked Issue queries used for reporter attribution should include the author:
33
-
34
- ```bash
35
- gh issue view {issue-number} --json number,title,labels,url,author
36
- ```
37
-
38
- Map GitHub no-reply emails with this rule: if `Name <email>` contains an email matching `(\d+\+)?(\S+?)@users\.noreply\.github\.com`, use the second capture group lowercased as the login. This covers both `{id}+{login}@users.noreply.github.com` and `{login}@users.noreply.github.com`.
39
-
40
- ## Publish the Release Notes
17
+ ## Publish Release Notes
41
18
 
42
- The GitHub Release for `v{version}` is created and published automatically by the release workflow so Homebrew bottles have a stable upload target. This command writes the curated notes onto that existing Release, falling back to creating it if it does not exist yet.
19
+ Call this only after user confirmation:
43
20
 
44
21
  ```bash
45
- if gh release view "v{version}" >/dev/null 2>&1; then
46
- gh release edit "v{version}" --notes-file "{notes-file}"
47
- else
48
- gh release create "v{version}" --title "v{version}" --notes-file "{notes-file}"
49
- fi
22
+ agent-infra-internal platform-release-notes publish \
23
+ --tag "v{version}" \
24
+ --title "v{version}" \
25
+ --notes-file "{notes-file}"
50
26
  ```
51
27
 
52
- If commands fail, stop or escalate according to the calling skill.
28
+ The command updates an existing Release or creates it when missing; `--dry-run` returns only the planned operation. Exit code `0` means success, `1` means a stable failure, and `2` means a network or platform block.
@@ -1,52 +1,28 @@
1
1
  # Release 平台命令
2
2
 
3
- 在读取历史 release、查询已合并 PR,或发布 Release notes 前先读取本文件。
3
+ 发布说明平台操作统一使用 typed internal intent。调用方只解释结构化 JSON,不解析平台命令、原始字段、身份邮箱规则或认证错误。
4
4
 
5
- ## Release 查询
5
+ ## 收集发布说明上下文
6
6
 
7
7
  ```bash
8
- gh release list --limit {limit} --json tagName,isDraft,isPrerelease
9
- gh release view "{tag}" --json body,url
8
+ agent-infra-internal platform-release-notes context \
9
+ --from-tag "v{prev-version}" \
10
+ --to-tag "v{version}" \
11
+ --branch "{branch}" \
12
+ --history-limit 3
10
13
  ```
11
14
 
12
- ## 已合并 PR 查询
13
-
14
- ```bash
15
- gh pr list --state merged --base "{branch}" --json number,title,mergedAt,labels
16
- ```
17
-
18
- 必要时读取关联 Issue:
19
-
20
- ```bash
21
- gh issue view {issue-number} --json number,title,labels,url
22
- ```
23
-
24
- ## Contributor 映射辅助规则
25
-
26
- release notes 需要 contributors 时,已合并 PR 查询应包含 author:
27
-
28
- ```bash
29
- gh pr list --state merged --base "{branch}" --json number,title,mergedAt,labels,author
30
- ```
31
-
32
- 关联 Issue 用于 reporter 归因时,查询应包含 author:
33
-
34
- ```bash
35
- gh issue view {issue-number} --json number,title,labels,url,author
36
- ```
37
-
38
- GitHub no-reply 邮箱映射规则:如果 `Name <email>` 中的 email 匹配 `(\d+\+)?(\S+?)@users\.noreply\.github\.com`,使用第二个捕获组的小写形式作为 login。该规则同时覆盖 `{id}+{login}@users.noreply.github.com` 和 `{login}@users.noreply.github.com`。
15
+ 结果包含 `history`、`pullRequests`、`closingIssues` 和带规范化 `login` / `resolution` 的 commit `authors`。`status: no-op` 且错误码为 `PLATFORM_RELEASE_NOTES_UNSUPPORTED` 表示当前平台不支持远端发布说明能力。
39
16
 
40
17
  ## 发布 Release notes
41
18
 
42
- `v{version}` 的 GitHub Release 由 release 工作流自动创建并发布,为 Homebrew bottle 提供稳定的上传落点。本命令把精修后的 notes 写到这个已存在的 Release 上;若 Release 尚不存在则兜底创建。
19
+ 用户确认后调用:
43
20
 
44
21
  ```bash
45
- if gh release view "v{version}" >/dev/null 2>&1; then
46
- gh release edit "v{version}" --notes-file "{notes-file}"
47
- else
48
- gh release create "v{version}" --title "v{version}" --notes-file "{notes-file}"
49
- fi
22
+ agent-infra-internal platform-release-notes publish \
23
+ --tag "v{version}" \
24
+ --title "v{version}" \
25
+ --notes-file "{notes-file}"
50
26
  ```
51
27
 
52
- 失败时按调用方规则停止或提示人工介入。
28
+ 命令会更新已存在的 Release,缺失时创建;`--dry-run` 只返回 planned operation。退出码为 `0` 时成功,`1` 表示稳定失败,`2` 表示网络或平台阻塞。
@@ -1,5 +1,5 @@
1
1
  # Release 命令
2
2
 
3
- 当前代码平台未内置发布命令支持。
3
+ 当前代码平台未提供发布说明 adapter。
4
4
 
5
- 自定义平台会跳过远端发布自动化,除非你提供匹配的 `.{platform}.zh-CN.md` 规则模板和脚本。请继续使用本地发布产物或你的平台专属发布流程。
5
+ 调用 `agent-infra-internal platform-release-notes context` 会返回结构化的 `PLATFORM_RELEASE_NOTES_UNSUPPORTED` no-op,不得探测其他平台 client。在提供 adapter 前,发布操作同样保持 no-op。
@@ -84,15 +84,16 @@ When an executor judges an item to be a key design decision that needs human rul
84
84
  - `evidence` points to the stable anchor `<artifact>#HD-N` (e.g. `plan-r2.md#HD-1`), not a drift-prone line number.
85
85
  - A human records the ruling with `ai decide <task-ref> <ordinal|ledger-id> <decision>`; the command flips the target row to `human-decided` and points `evidence` to an independent `HDR-N` ruling record.
86
86
 
87
- > Viewing, deciding, and typed verification share the `lib/task/ledger.ts` domain semantics.
87
+ > Viewing, deciding, and typed verification share the `lib/task/ledger.ts` domain semantics; no second parser is maintained.
88
88
 
89
89
  ## post-review commit gate (code stage only)
90
90
 
91
- - `review-code` captures the review baseline `R` (diff base), full-worktree diff fingerprint `F`, and normalized snapshot tree `T`. An Approved clean snapshot may set `B=R`; an Approved snapshot with uncommitted changes clears or omits `B`.
91
+ - `review-code` captures the reviewed commit `R` (this round's HEAD) and an independent diff base `D` exactly once. `F` covers the complete difference from D to the current worktree, while normalized snapshot tree `T` represents the current worktree. An Approved snapshot with `T == R^{tree}` may set `B=R`; an Approved snapshot with uncommitted changes clears or omits `B`.
92
92
  - `commit` reads only the highest-round Approved `review-code` artifact. Before committing it requires `pre_head == R`, complete worktree tree `W == T`, and normalized staged tree `S == T`; any mismatch blocks before `git commit` and reports added, missing, and different paths for both comparisons.
93
93
  - After a successful commit it sets `B=last_reviewed_commit=<new_head>`; B means only a reviewed snapshot anchored to a Git commit.
94
94
  - The `complete-task` `post-review-commit` gate uses only B. When B is absent, malformed, or missing as a Git object, it reports `reviewed snapshot was not anchored` and never falls back to R.
95
- - If new commits touch code / rule paths after B, the gate blocks and requires a fresh `review-code`.
95
+ - If new commits touch code / rule paths after B, the gate blocks and requires a fresh `review-code`. Automatic exceptions are limited to: (1) a bound platform change request (PR/MR) is merged and its platform adapter supplies an authoritative snapshot plus remote Git evidence refs; the gate fetches the reviewed head and target branch into an isolated temporary repository and proves B is the original change-request head, its merge commit is in authoritative target history, its reviewed changes exactly match the normalized patch of a single-parent squash commit, and its protected paths have no later commits; or (2) no valid change request, exactly one protected-path commit after B, that commit is a single-parent local rewrite in HEAD history, it has the same full tree or protected content as B, and no protected-path commits follow it. An unsupported adapter capability, missing required platform / Git evidence, or Git credentials that cannot read those remote refs fails closed.
96
+ - Required checks remain a pre-merge responsibility of branch protection / rulesets and the `review-code` / `watch-pr` routes. The post-review-commit gate still applies the applicable strict, PR-squash, or local-rewrite equivalence independently.
96
97
  - **Exemption**: append a ledger row `| PRC-1 | post-review-commit | - | - | human-decided | <ruling note> |` recording that a human explicitly allowed those commits without re-review.
97
98
 
98
99
  ## Gate behavior cheat sheet
@@ -84,15 +84,16 @@
84
84
  - `evidence` 指向稳定锚点 `<artifact>#HD-N`(如 `plan-r2.md#HD-1`),不依赖易漂移的行号。
85
85
  - 人工使用 `ai decide <task-ref> <序号|账本ID> <裁决内容>` 记录裁定;命令把目标行翻为 `human-decided`,并让 `evidence` 指向独立 `HDR-N` 裁定记录。
86
86
 
87
- > 查看、裁决与 typed verification 共用 `lib/task/ledger.ts` 的领域语义。
87
+ > 查看、裁决与 typed verification 共用 `lib/task/ledger.ts` 的领域语义,不维护第二 parser。
88
88
 
89
89
  ## post-review commit 门禁(仅 code 阶段)
90
90
 
91
- - `review-code` 一次性捕获审查基线 `R`(diff base)、完整工作区差异指纹 `F` 与规范化快照树 `T`;Approved 且快照干净时可令 `B=R`,Approved 且含未提交差异时清除/不写 `B`。
91
+ - `review-code` 一次性捕获审查提交 `R`(本轮 HEAD)与独立差异基线 `D`;`F` 覆盖 `D` 到当前工作区的完整差异,规范化快照树 `T` 表示当前工作区。Approved 且 `T == R^{tree}` 时可令 `B=R`,Approved 且含未提交差异时清除/不写 `B`。
92
92
  - `commit` 只读取最高轮 Approved `review-code` 产物;提交前比较 `pre_head == R`、完整工作区树 `W == T`、规范化暂存树 `S == T`,任一失配都在 `git commit` 前阻断并报告两组 added/missing/different 路径。
93
93
  - 成功提交后令 `B=last_reviewed_commit=<new_head>`;`B` 只表示已经落到 Git commit 的审查锚点。
94
94
  - `complete-task` 的 `post-review-commit` gate 只使用 B;B 缺失、畸形或对象不存在时报告 `reviewed snapshot was not anchored`,不得回退 R。
95
- - 若 B 之后代码 / 规则路径出现新提交,gate 会拦截,要求重新 `review-code`。
95
+ - 若 B 之后代码 / 规则路径出现新提交,gate 会拦截,要求重新 `review-code`。自动例外仅限两类:(1) 绑定的平台变更请求(PR/MR)已合并,且平台适配器提供权威快照与远端 Git 证据引用;gate 在隔离的临时仓库中抓取受审查 head 与目标分支,证明 B 是原变更请求 head、merge commit 位于权威目标分支历史中、受审查变更与单父 squash commit 的规范化补丁完全一致,并且 merge 后受保护路径没有新提交;(2) 无有效变更请求,B 后恰有一个受保护路径提交,该提交是本地 HEAD 历史中的单父重写,且它与 B 的完整 tree 相同或受保护内容相同,重写后也没有受保护路径提交。适配器不支持该能力,缺少所需平台 / Git 证据,或当前 Git 凭据不能读取这些远端 refs 时 fail closed。
96
+ - required checks 由合并前的分支保护 / ruleset 与 `review-code` / `watch-pr` 路由负责。post-review-commit 仍独立执行适用的严格 / PR squash / 本地重写等价判定。
96
97
  - **豁免**:在账本追加一行 `| PRC-1 | post-review-commit | - | - | human-decided | <裁定说明> |`,记录人工明确允许该批提交免复审。
97
98
 
98
99
  ## gate 行为速查
@@ -0,0 +1,113 @@
1
+ # Shared Review Method
2
+
3
+ This rule defines the lightweight review protocol shared by the `analysis`, `plan`,
4
+ and `code` stages. Stage-specific checks remain in each skill's
5
+ `reference/review-criteria.md`; finding state, human decisions, and ledger writes
6
+ remain governed by [review-handshake.md](review-handshake.md); risk lenses only route
7
+ an observed risk to references that must then be loaded.
8
+
9
+ ## Responsibility Boundary
10
+
11
+ - This rule defines review order, evidence shape, and completion conditions without duplicating stage checklists.
12
+ - Observable evidence triggers risk lenses; every matched reference must be read and recorded in the report.
13
+ - Automation supplies facts; the reviewer judges completeness, impact, severity, confidence, and counterevidence.
14
+ - Report structure makes review claims traceable; it does not automatically prove that semantic judgments are correct.
15
+
16
+ ## Readiness
17
+
18
+ Before forming candidate findings, confirm that:
19
+
20
+ 1. The task, input artifact, upstream sources, and review scope are resolved and readable.
21
+ 2. The state snapshot, diff, or other factual evidence required by the skill has been captured.
22
+ 3. The reviewed artifact, baseline, and context boundary can be identified accurately in the report.
23
+
24
+ If any prerequisite is missing, an Approved verdict is forbidden; follow the owning
25
+ skill's blocked or failure path.
26
+
27
+ ## Multi-pass Review Protocol
28
+
29
+ Run these five passes in order. Record each pass's scope, evidence, result, and
30
+ gaps/assumptions in the report coverage table.
31
+
32
+ 1. **Pass 1 — Raw evidence**: read source requests, upstream artifacts, changes, and tests before executor summaries can anchor the review; form independent candidate issues.
33
+ 2. **Pass 2 — Traceability and boundaries**: map source → requirement → plan → implementation → test, looking for omissions, broken links, and unexpected scope.
34
+ 3. **Pass 3 — Risk lenses**: evaluate every registry trigger against the complete context, load every matched reference, and record trigger evidence and results.
35
+ 4. **Pass 4 — Counterevidence**: seek evidence that disproves or downgrades each candidate finding and counterexamples that could invalidate an approval.
36
+ 5. **Pass 5 — Classification and convergence**: classify issues as findings, manual-validation, or advisories; reconcile evidence contracts, ledger intents, unverified assumptions, and the verdict.
37
+
38
+ ## Risk Lens Registry
39
+
40
+ Registry rows use stable fields: `lens_id` identifies the lens, `stages` limits its
41
+ scope, `observable_trigger` states observable evidence, `required_reference` is
42
+ mandatory when matched, and `report_evidence` defines the audit trail.
43
+
44
+ | lens_id | stages | observable_trigger | required_reference | report_evidence |
45
+ |---------|--------|--------------------|--------------------|-----------------|
46
+ | documentation-antipatterns | code | The complete change context touches Markdown, rules, skills, CLI help, or user documentation that describes current behavior | `.agents/skills/review-code/reference/documentation-antipatterns.md` | Record triggering files, `loaded=yes`, and the lens result |
47
+ | testing-discipline | code | The complete change context touches tests, fixtures, snapshots, or test helpers | `.agents/rules/testing-discipline.md` | Record triggering files, `loaded=yes`, and the test-discipline result |
48
+ | security-risks | code | Authentication, authorization, untrusted input, sensitive data, credentials, cryptography, dependencies, or system boundaries change | `.agents/skills/review-code/reference/security-risks.md` | Record the changed security boundary, `loaded=yes`, and the lens result |
49
+ | migration-risks | code | Persistent formats, schemas, configuration/frontmatter, compatibility reads, migrations, or rollback behavior change | `.agents/skills/review-code/reference/migration-risks.md` | Record compatibility or migration evidence, `loaded=yes`, and the lens result |
50
+ | concurrency-risks | code | Async coordination, shared state, locks, retries, idempotency, races, cancellation, or timeouts change | `.agents/skills/review-code/reference/concurrency-risks.md` | Record the concurrency path, `loaded=yes`, and the lens result |
51
+ | cross-platform-risks | code | OS branches, paths, shells, permissions, symlinks, newlines, signals, or cross-platform behavior change | `.agents/skills/review-code/reference/cross-platform-risks.md` | Record platform evidence, `loaded=yes`, and the lens result |
52
+
53
+ Unmatched lenses still require reproducible non-trigger evidence. `loaded` accepts
54
+ only `yes`, `no`, or `not-applicable`; a matched but unloaded lens forbids approval.
55
+
56
+ ## Automation and Semantic Judgment
57
+
58
+ | Source | Facts it can support | Semantic judgment it cannot replace |
59
+ |--------|----------------------|-------------------------------------|
60
+ | snapshot, diff, link, test, artifact gate | files, scope, command results, reference existence, section existence | requirement completeness, design soundness, implementation correctness |
61
+ | traceability matrix | explicit mappings and visible gaps | mapping sufficiency, gap impact, priority |
62
+ | risk-lens record | trigger evidence, load status, lens result entry point | acceptable risk, finding severity, confidence |
63
+
64
+ When automated facts and semantic conclusions diverge, record each separately.
65
+ Never present a passing structural gate as proof of semantic completeness.
66
+
67
+ ## Context Coverage and Traceability Contract
68
+
69
+ Reports must contain both coverage tables:
70
+
71
+ | pass_id | scope | evidence | result | gaps_or_assumptions |
72
+ |---------|-------|----------|--------|---------------------|
73
+ | pass-1..5 | scope actually reviewed in this pass | locatable artifact, file, command, or line | finding or conclusion | uncovered item, gap, or assumption |
74
+
75
+ | lens_id | trigger_evidence | loaded | result |
76
+ |---------|------------------|--------|--------|
77
+ | registry token | reproducible trigger or non-trigger evidence | yes / no / not-applicable | lens conclusion |
78
+
79
+ Reports must also contain the shared traceability matrix:
80
+
81
+ | source_id | upstream | reviewed_target | verification | status_or_gap |
82
+ |-----------|----------|-----------------|--------------|---------------|
83
+ | stable source identifier | upstream requirement, decision, or step | object reviewed at this stage | automated or human evidence | covered / gap and impact |
84
+
85
+ Analysis traces sources to requirements, acceptance, impact, and risk. Plan traces
86
+ approved requirements to decisions, implementation steps, and test strategy. Code
87
+ traces requirements and plan steps to the diff and automated tests or human checks.
88
+
89
+ ## Finding Evidence Contract
90
+
91
+ Every blocker or major finding must include:
92
+
93
+ 1. **Scenario**: preconditions and the path that triggers the problem.
94
+ 2. **Impact**: concrete consequences for correctness, security, delivery, or acceptance.
95
+ 3. **Evidence**: reproducible artifact, `file:line`, command, and raw result.
96
+ 4. **Confidence**: stable token `high`, `medium`, or `low`.
97
+ 5. **Unverified assumptions**: claims not directly proven that would change the conclusion if disproved; explicitly state none when empty.
98
+ 6. **Fix direction**: the smallest actionable repair goal without redesigning outside the executor's authority.
99
+
100
+ Minor findings stay lightweight but still need a specific location and actionable
101
+ advice. The finding ledger's `evidence` continues to point to a stable report anchor;
102
+ no ledger fields are added. Handle manual-validation, advisories, and
103
+ `needs-human-decision` through the review handshake and stage rules.
104
+
105
+ ## Completion
106
+
107
+ A final verdict is allowed only when:
108
+
109
+ - All five passes record scope, evidence, result, and gaps/assumptions.
110
+ - Every risk trigger has a decision, and every matched lens was loaded and recorded.
111
+ - The traceability matrix covers the stage responsibility, with gaps classified as a finding, manual-validation, advisory, or explicit assumption.
112
+ - Every blocker/major satisfies the evidence contract and every candidate finding received a counterevidence pass.
113
+ - Ledger intents, manual checks, pending decisions, unverified assumptions, and finding counts agree.
@@ -0,0 +1,98 @@
1
+ # 通用检视方法
2
+
3
+ 本规则定义 `analysis`、`plan` 和 `code` 三个审查阶段共用的轻量检视协议。阶段专属检查项留在各 skill 的 `reference/review-criteria.md`;finding 状态机、人工裁决和账本写入继续以 [review-handshake.md](review-handshake.md) 为准;风险镜头只承载命中某类风险后必须加载的专项 reference。
4
+
5
+ ## 职责边界
6
+
7
+ - 本规则规定审查顺序、证据形状和完成条件,不复制阶段 checklist。
8
+ - 风险镜头由可观察证据触发;命中后必须读取全部对应 reference,并在报告留证。
9
+ - 自动化检查提供事实,reviewer 负责完整性、影响、严重度、置信度和反证等语义判断。
10
+ - 报告结构证明审查声明可追溯,不等于自动证明语义判断正确。
11
+
12
+ ## Readiness
13
+
14
+ 形成候选 finding 前必须确认:
15
+
16
+ 1. 任务、输入 artifact、上游来源和审查范围已解析且可读。
17
+ 2. skill 要求的状态快照、差异或其他事实证据已捕获。
18
+ 3. 本轮实际审查的 artifact、基线和上下文边界可在报告中准确标识。
19
+
20
+ 任一前置项缺失时,不得给出通过结论;按所属 skill 的阻塞或失败路径处理。
21
+
22
+ ## 多遍检视协议
23
+
24
+ 按顺序执行以下五遍;每遍都在报告的检视覆盖表中记录范围、证据、结果与缺口/假设。
25
+
26
+ 1. **Pass 1 — 原始证据**:先读任务来源、上游 artifact、变更和测试等原始证据,独立形成候选问题,避免被执行方摘要锚定。
27
+ 2. **Pass 2 — 追踪与边界**:建立来源—需求—方案—实现—测试追踪,识别遗漏、断链和意外范围扩张。
28
+ 3. **Pass 3 — 风险镜头**:依据完整上下文逐项判断注册表触发器,加载所有命中的专项 reference,并记录命中证据与结果。
29
+ 4. **Pass 4 — 反证**:主动寻找能推翻或降级每个候选 finding 的证据,并检查放行结论可能失败的反例。
30
+ 5. **Pass 5 — 归类与收敛**:将问题归为 finding、manual-validation 或 advisory,核对证据契约、账本意图、未验证假设和 verdict。
31
+
32
+ ## 风险镜头注册表
33
+
34
+ 注册行使用稳定字段:`lens_id` 标识镜头,`stages` 限定阶段,`observable_trigger` 给出可观察触发条件,`required_reference` 是命中后必读路径,`report_evidence` 规定报告留证。
35
+
36
+ | lens_id | stages | observable_trigger | required_reference | report_evidence |
37
+ |---------|--------|--------------------|--------------------|-----------------|
38
+ | documentation-antipatterns | code | 完整变更上下文触及描述当前行为的 Markdown、规则、skill、CLI 帮助或用户文档 | `.agents/skills/review-code/reference/documentation-antipatterns.md` | 记录触发文件、`loaded=yes` 与检视结果 |
39
+ | testing-discipline | code | 完整变更上下文触及测试、fixture、snapshot 或测试 helper | `.agents/rules/testing-discipline.md` | 记录触发文件、`loaded=yes` 与测试纪律结论 |
40
+ | security-risks | code | 认证授权、非可信输入、敏感数据、凭据、加密、依赖或系统边界发生变化 | `.agents/skills/review-code/reference/security-risks.md` | 记录安全边界变化、`loaded=yes` 与检视结果 |
41
+ | migration-risks | code | 持久化格式、schema、配置/frontmatter、兼容读取或迁移/回滚发生变化 | `.agents/skills/review-code/reference/migration-risks.md` | 记录兼容或迁移触发证据、`loaded=yes` 与检视结果 |
42
+ | concurrency-risks | code | 异步协调、共享状态、锁、重试、幂等、竞态、取消或超时发生变化 | `.agents/skills/review-code/reference/concurrency-risks.md` | 记录并发触发路径、`loaded=yes` 与检视结果 |
43
+ | cross-platform-risks | code | OS 分支、路径、shell、权限、符号链接、换行、信号或跨平台行为发生变化 | `.agents/skills/review-code/reference/cross-platform-risks.md` | 记录平台触发证据、`loaded=yes` 与检视结果 |
44
+
45
+ 未命中镜头也必须记录可复核的未命中证据。`loaded` 只使用 `yes`、`no`、`not-applicable`;命中但未加载时不得给出通过结论。
46
+
47
+ ## 自动化与语义判断
48
+
49
+ | 来源 | 可支持的事实 | 不可替代的语义判断 |
50
+ |------|--------------|--------------------|
51
+ | snapshot、diff、link、test、artifact gate | 文件、范围、命令结果、引用存在、章节存在 | 需求是否完整、设计是否合理、实现是否正确 |
52
+ | 追踪矩阵 | 显式映射及可见缺口 | 映射是否充分、缺口影响和优先级 |
53
+ | 风险镜头记录 | 触发证据、加载状态、专项结果入口 | 风险是否可接受、finding 严重度与置信度 |
54
+
55
+ 自动化结果与语义结论冲突时,报告必须分别记录事实与推理,不得把结构 gate 的通过写成语义完整性的证明。
56
+
57
+ ## 上下文覆盖与追踪契约
58
+
59
+ 报告必须包含两张覆盖表:
60
+
61
+ | pass_id | scope | evidence | result | gaps_or_assumptions |
62
+ |---------|-------|----------|--------|---------------------|
63
+ | pass-1..5 | 本遍实际覆盖范围 | 可定位的 artifact、文件、命令或行号 | 发现或结论 | 未覆盖项、缺口或假设 |
64
+
65
+ | lens_id | trigger_evidence | loaded | result |
66
+ |---------|------------------|--------|--------|
67
+ | 注册表 token | 命中或未命中的可复核证据 | yes / no / not-applicable | 专项检视结论 |
68
+
69
+ 并包含统一追踪矩阵:
70
+
71
+ | source_id | upstream | reviewed_target | verification | status_or_gap |
72
+ |-----------|----------|-----------------|--------------|---------------|
73
+ | 稳定来源标识 | 上游需求、决策或步骤 | 本阶段被审对象 | 自动化或人工证据 | covered / gap 及影响 |
74
+
75
+ analysis 阶段追踪来源到需求、验收、影响和风险;plan 阶段追踪已批准需求到设计决策、步骤和测试策略;code 阶段追踪需求/方案到 diff 与自动化测试或人工校验。
76
+
77
+ ## Finding 证据契约
78
+
79
+ 每个 blocker 或 major finding 必须包含:
80
+
81
+ 1. **场景**:触发问题的前置条件和路径。
82
+ 2. **影响**:对正确性、安全、交付或验收的具体后果。
83
+ 3. **证据**:可复现的 artifact、`file:line`、命令和原始结果。
84
+ 4. **置信度**:稳定 token `high`、`medium` 或 `low`。
85
+ 5. **未验证假设**:尚未直接证明、若被推翻会改变结论的假设;没有则明确写无。
86
+ 6. **修复方向**:可执行的最小修复目标,不替执行方越权重设计。
87
+
88
+ minor 保持轻量,但仍须提供具体位置和可执行建议。finding ledger 的 `evidence` 继续指向报告中的稳定锚点,不新增账本字段。manual-validation、advisory 和 `needs-human-decision` 按 review handshake 与阶段规则处理。
89
+
90
+ ## Completion
91
+
92
+ 只有同时满足以下条件才可形成最终 verdict:
93
+
94
+ - 五遍检视均已记录范围、证据、结果和缺口/假设。
95
+ - 所有风险触发器均有命中判断,命中镜头均已加载并留证。
96
+ - 追踪矩阵覆盖本阶段职责,缺口已进入 finding、manual-validation、advisory 或明确假设。
97
+ - 所有 blocker/major 满足统一证据契约,候选 finding 已完成反证检视。
98
+ - 账本意图、人工校验、待裁决项、未验证假设与问题计数一致。
@@ -41,6 +41,24 @@ This mirrors "Goal-Driven Execution" in AGENTS.md: define a verifiable success c
41
41
 
42
42
  ## Project-specific test policy
43
43
 
44
- Keep repository-specific commands, directory conventions, coverage thresholds, CI integration, and reporting services in the project's own test documentation. Before adding a test, inspect that local policy and place the test in the layer that matches its observable scope and runtime cost.
44
+ Complete each item below for this repository. Record the chosen behavior and its boundaries so contributors can select and validate tests consistently.
45
45
 
46
- If the project does not define a layered test suite, use its complete test command for RED and GREEN verification. Do not invent a test hierarchy or coverage gate as part of an unrelated change.
46
+ ### 1. Test commands
47
+
48
+ > TODO: Document the complete test command and any faster commands used during development.
49
+
50
+ ### 2. Test directories or tiers
51
+
52
+ > TODO: Document the test directories or tiers and the rule for choosing among them.
53
+
54
+ ### 3. Coverage
55
+
56
+ > TODO: Document how coverage is collected, any thresholds, and whether coverage blocks changes.
57
+
58
+ ### 4. Continuous integration
59
+
60
+ > TODO: Document which CI checks run tests and which checks are blocking or informational.
61
+
62
+ ### 5. Reporting services
63
+
64
+ > TODO: Document any external reporting services, badges, or artifacts and whether they affect acceptance.