@fitlab-ai/agent-infra 0.9.10 → 0.9.12

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 (375) hide show
  1. package/README.md +19 -9
  2. package/README.zh-CN.md +19 -9
  3. package/bin/cli.ts +17 -4
  4. package/dist/bin/cli.js +19 -4
  5. package/dist/bin/internal-cli.js +55 -4
  6. package/dist/lib/agent-client.js +0 -1
  7. package/dist/lib/agent-clients/adapters/codex-lifecycle/build-identity.js +71 -10
  8. package/dist/lib/agent-clients/adapters/opencode-sandbox.js +0 -4
  9. package/dist/lib/agent-clients/adapters/traecli.js +7 -8
  10. package/dist/lib/agent-clients/config.js +14 -99
  11. package/dist/lib/agent-clients/reconcile.js +1 -11
  12. package/dist/lib/agent-clients/schema.js +5 -4
  13. package/dist/lib/agent-clients/tokens.js +5 -15
  14. package/dist/lib/decide.js +14 -30
  15. package/dist/lib/defaults.json +8 -0
  16. package/dist/lib/git/workflow.js +43 -1
  17. package/dist/lib/init.js +3 -2
  18. package/dist/lib/internal/git-workflow.js +8 -1
  19. package/dist/lib/internal/platform-pr.js +8 -2
  20. package/dist/lib/internal/release-workflow.js +0 -1
  21. package/dist/lib/internal/task-delivery.js +59 -0
  22. package/dist/lib/internal/task-finalization.js +19 -9
  23. package/dist/lib/internal/task-ledger.js +8 -2
  24. package/dist/lib/internal/task-lifecycle.js +17 -93
  25. package/dist/lib/internal/task-orchestration.js +30 -216
  26. package/dist/lib/internal/task-validate.js +2 -1
  27. package/dist/lib/merge.js +205 -103
  28. package/dist/lib/platform/github-client.js +7 -1
  29. package/dist/lib/platform/pr-checks.js +8 -5
  30. package/dist/lib/platform/pr-summary.js +12 -8
  31. package/dist/lib/platform/pull-requests.js +393 -91
  32. package/dist/lib/platform/verification-required.js +13 -2
  33. package/dist/lib/platform/verification-sync.js +9 -4
  34. package/dist/lib/pr-review/evidence-grading.js +12 -4
  35. package/dist/lib/process-data/normalize.js +2 -9
  36. package/dist/lib/run/host.js +46 -16
  37. package/dist/lib/sandbox/agent-client-reconciler.js +4 -12
  38. package/dist/lib/sandbox/commands/create.js +3 -3
  39. package/dist/lib/sandbox/commands/enter.js +18 -4
  40. package/dist/lib/sandbox/config.js +8 -12
  41. package/dist/lib/sandbox/control/executor.js +131 -39
  42. package/dist/lib/sandbox/control/lifecycle.js +55 -24
  43. package/dist/lib/sandbox/control/server.js +18 -16
  44. package/dist/lib/sandbox/mounts.js +3 -2
  45. package/dist/lib/sandbox/recovery.js +123 -22
  46. package/dist/lib/sandbox/workspace-identity.js +14 -0
  47. package/dist/lib/sandbox/workspace-view.js +8 -9
  48. package/dist/lib/self-update.js +278 -0
  49. package/dist/lib/server/process-state.js +2 -2
  50. package/dist/lib/server/protocol.js +5 -5
  51. package/dist/lib/task/activity-log.js +4 -1
  52. package/dist/lib/task/artifact-lifecycle.js +6 -4
  53. package/dist/lib/task/codex-orchestration.js +1 -1
  54. package/dist/lib/task/command-options.js +1 -3
  55. package/dist/lib/task/commands/cat.js +0 -5
  56. package/dist/lib/task/commands/decisions.js +76 -92
  57. package/dist/lib/task/commands/files.js +6 -6
  58. package/dist/lib/task/commands/grep.js +25 -61
  59. package/dist/lib/task/commands/issue-body.js +6 -6
  60. package/dist/lib/task/commands/log.js +25 -10
  61. package/dist/lib/task/commands/show.js +5 -6
  62. package/dist/lib/task/commands/status.js +8 -8
  63. package/dist/lib/task/commit-intent.js +100 -0
  64. package/dist/lib/task/commit-operation.js +181 -91
  65. package/dist/lib/task/commit-policy.js +1 -1
  66. package/dist/lib/task/control-authority.js +431 -0
  67. package/dist/lib/task/create.js +39 -8
  68. package/dist/lib/task/current-contract.js +35 -0
  69. package/dist/lib/task/decision-details.js +218 -0
  70. package/dist/lib/task/decision-intents.js +5 -2
  71. package/dist/lib/task/delivery-target.js +97 -0
  72. package/dist/lib/task/delivery.js +153 -0
  73. package/dist/lib/task/events.js +11 -5
  74. package/dist/lib/task/human-override.js +5 -2
  75. package/dist/lib/task/index.js +19 -20
  76. package/dist/lib/task/ledger-intents.js +8 -9
  77. package/dist/lib/task/ledger.js +13 -6
  78. package/dist/lib/task/lifecycle.js +122 -9
  79. package/dist/lib/task/orchestration.js +105 -75
  80. package/dist/lib/task/pr-delivery-fact.js +182 -0
  81. package/dist/lib/task/review-artifacts.js +31 -12
  82. package/dist/lib/task/review-finalization.js +13 -4
  83. package/dist/lib/task/review-fingerprint.js +8 -0
  84. package/dist/lib/task/verification-engine.js +86 -39
  85. package/dist/lib/task/verification-review.js +2 -2
  86. package/dist/lib/task/workspace-snapshot.js +5 -11
  87. package/dist/lib/task/write.js +11 -1
  88. package/dist/lib/update.js +13 -35
  89. package/dist/lib/version.js +5 -1
  90. package/dist/lifecycle-build-manifest.json +3 -3
  91. package/lib/agent-client.ts +0 -1
  92. package/lib/agent-clients/adapters/codex-lifecycle/build-identity.ts +105 -10
  93. package/lib/agent-clients/adapters/codex-lifecycle/manifest-files.json +12 -1
  94. package/lib/agent-clients/adapters/opencode-sandbox.ts +0 -5
  95. package/lib/agent-clients/adapters/traecli.ts +7 -8
  96. package/lib/agent-clients/config.ts +14 -144
  97. package/lib/agent-clients/reconcile.ts +1 -12
  98. package/lib/agent-clients/schema.ts +5 -4
  99. package/lib/agent-clients/tokens.ts +5 -18
  100. package/lib/decide.ts +12 -22
  101. package/lib/defaults.json +8 -0
  102. package/lib/git/workflow.ts +38 -1
  103. package/lib/init.ts +5 -2
  104. package/lib/internal/git-workflow.ts +7 -1
  105. package/lib/internal/platform-pr.ts +8 -1
  106. package/lib/internal/release-workflow.ts +0 -1
  107. package/lib/internal/task-delivery.ts +53 -0
  108. package/lib/internal/task-finalization.ts +27 -13
  109. package/lib/internal/task-ledger.ts +8 -2
  110. package/lib/internal/task-lifecycle.ts +33 -76
  111. package/lib/internal/task-orchestration.ts +33 -190
  112. package/lib/internal/task-validate.ts +3 -2
  113. package/lib/merge.ts +236 -120
  114. package/lib/platform/github-client.ts +8 -1
  115. package/lib/platform/pr-checks.ts +7 -5
  116. package/lib/platform/pr-summary.ts +10 -7
  117. package/lib/platform/pull-requests.ts +425 -87
  118. package/lib/platform/verification-required.ts +12 -2
  119. package/lib/platform/verification-sync.ts +9 -4
  120. package/lib/pr-review/evidence-grading.ts +7 -4
  121. package/lib/process-data/normalize.ts +2 -8
  122. package/lib/run/host.ts +63 -14
  123. package/lib/sandbox/agent-client-reconciler.ts +5 -15
  124. package/lib/sandbox/commands/create.ts +4 -4
  125. package/lib/sandbox/commands/enter.ts +24 -4
  126. package/lib/sandbox/config.ts +9 -14
  127. package/lib/sandbox/control/container-identity.ts +2 -2
  128. package/lib/sandbox/control/executor.ts +148 -51
  129. package/lib/sandbox/control/lifecycle.ts +59 -31
  130. package/lib/sandbox/control/protocol.ts +1 -3
  131. package/lib/sandbox/control/server.ts +15 -12
  132. package/lib/sandbox/control/state.ts +7 -7
  133. package/lib/sandbox/mounts.ts +4 -3
  134. package/lib/sandbox/recovery.ts +162 -34
  135. package/lib/sandbox/tools.ts +1 -1
  136. package/lib/sandbox/workspace-identity.ts +28 -0
  137. package/lib/sandbox/workspace-view.ts +14 -10
  138. package/lib/self-update.ts +341 -0
  139. package/lib/server/process-state.ts +2 -2
  140. package/lib/server/protocol.ts +5 -5
  141. package/lib/task/activity-log.ts +6 -1
  142. package/lib/task/artifact-lifecycle.ts +7 -5
  143. package/lib/task/codex-orchestration.ts +2 -1
  144. package/lib/task/command-options.ts +1 -2
  145. package/lib/task/commands/cat.ts +0 -4
  146. package/lib/task/commands/decisions.ts +80 -75
  147. package/lib/task/commands/files.ts +6 -6
  148. package/lib/task/commands/grep.ts +23 -51
  149. package/lib/task/commands/issue-body.ts +6 -6
  150. package/lib/task/commands/log.ts +22 -10
  151. package/lib/task/commands/show.ts +5 -6
  152. package/lib/task/commands/status.ts +8 -8
  153. package/lib/task/commit-intent.ts +137 -0
  154. package/lib/task/commit-operation.ts +161 -79
  155. package/lib/task/commit-policy.ts +1 -2
  156. package/lib/task/control-authority.ts +563 -0
  157. package/lib/task/create.ts +40 -10
  158. package/lib/task/current-contract.ts +49 -0
  159. package/lib/task/decision-details.ts +280 -0
  160. package/lib/task/decision-intents.ts +7 -2
  161. package/lib/task/delivery-target.ts +130 -0
  162. package/lib/task/delivery.ts +160 -0
  163. package/lib/task/events.ts +10 -5
  164. package/lib/task/human-override.ts +5 -2
  165. package/lib/task/index.ts +19 -20
  166. package/lib/task/ledger-intents.ts +6 -8
  167. package/lib/task/ledger.ts +17 -7
  168. package/lib/task/lifecycle.ts +113 -4
  169. package/lib/task/orchestration.ts +102 -80
  170. package/lib/task/pr-delivery-fact.ts +254 -0
  171. package/lib/task/review-artifacts.ts +53 -15
  172. package/lib/task/review-finalization.ts +21 -5
  173. package/lib/task/review-fingerprint.ts +10 -0
  174. package/lib/task/verification-engine.ts +78 -46
  175. package/lib/task/verification-review.ts +3 -1
  176. package/lib/task/workspace-snapshot.ts +4 -13
  177. package/lib/task/write.ts +20 -1
  178. package/lib/update.ts +14 -38
  179. package/lib/version.ts +6 -1
  180. package/package.json +1 -1
  181. package/templates/.agents/README.en.md +5 -3
  182. package/templates/.agents/README.zh-CN.md +5 -3
  183. package/templates/.agents/rules/README.en.md +4 -2
  184. package/templates/.agents/rules/README.zh-CN.md +4 -2
  185. package/templates/.agents/rules/compatibility-policy.en.md +5 -4
  186. package/templates/.agents/rules/compatibility-policy.zh-CN.md +5 -4
  187. package/templates/.agents/rules/create-issue.en.md +11 -2
  188. package/templates/.agents/rules/create-issue.zh-CN.md +24 -2
  189. package/templates/.agents/rules/human-decision-context.en.md +9 -7
  190. package/templates/.agents/rules/human-decision-context.zh-CN.md +9 -7
  191. package/templates/.agents/rules/{issue-fields.github.en.md → issue-fields.en.md} +1 -1
  192. package/templates/.agents/rules/{issue-fields.github.zh-CN.md → issue-fields.zh-CN.md} +1 -1
  193. package/templates/.agents/rules/issue-pr-commands.en.md +5 -18
  194. package/templates/.agents/rules/issue-pr-commands.zh-CN.md +1 -1
  195. package/templates/.agents/rules/issue-sync.en.md +26 -5
  196. package/templates/.agents/rules/issue-sync.zh-CN.md +62 -5
  197. package/templates/.agents/rules/label-milestone-setup.en.md +15 -2
  198. package/templates/.agents/rules/label-milestone-setup.zh-CN.md +15 -2
  199. package/templates/.agents/rules/local-artifact-repair.en.md +46 -0
  200. package/templates/.agents/rules/local-artifact-repair.zh-CN.md +46 -0
  201. package/templates/.agents/rules/milestone-inference.en.md +12 -2
  202. package/templates/.agents/rules/milestone-inference.zh-CN.md +25 -3
  203. package/templates/.agents/rules/next-step-output.en.md +3 -3
  204. package/templates/.agents/rules/next-step-output.zh-CN.md +3 -3
  205. package/templates/.agents/rules/no-mid-flow-questions.en.md +1 -1
  206. package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +1 -1
  207. package/templates/.agents/rules/pr-sync.en.md +23 -14
  208. package/templates/.agents/rules/pr-sync.zh-CN.md +23 -2
  209. package/templates/.agents/rules/release-commands.en.md +42 -3
  210. package/templates/.agents/rules/release-commands.zh-CN.md +42 -3
  211. package/templates/.agents/rules/review-handshake.en.md +1 -1
  212. package/templates/.agents/rules/review-handshake.zh-CN.md +1 -1
  213. package/templates/.agents/rules/security-alerts.en.md +17 -2
  214. package/templates/.agents/rules/security-alerts.zh-CN.md +17 -2
  215. package/templates/.agents/rules/sync-content-generation.en.md +8 -0
  216. package/templates/.agents/rules/sync-content-generation.zh-CN.md +8 -0
  217. package/templates/.agents/rules/task-management.en.md +2 -3
  218. package/templates/.agents/rules/task-management.zh-CN.md +2 -3
  219. package/templates/.agents/scripts/security-alerts.github.sh +151 -0
  220. package/templates/.agents/scripts/security-alerts.sh +31 -0
  221. package/templates/.agents/skills/analyze-task/SKILL.en.md +4 -3
  222. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +4 -3
  223. package/templates/.agents/skills/block-task/SKILL.en.md +2 -2
  224. package/templates/.agents/skills/block-task/SKILL.zh-CN.md +2 -2
  225. package/templates/.agents/skills/cancel-task/SKILL.en.md +2 -2
  226. package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +2 -2
  227. package/templates/.agents/skills/check-task/SKILL.en.md +2 -2
  228. package/templates/.agents/skills/check-task/SKILL.zh-CN.md +2 -2
  229. package/templates/.agents/skills/close-codescan/SKILL.en.md +3 -3
  230. package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +3 -3
  231. package/templates/.agents/skills/close-dependabot/SKILL.en.md +3 -3
  232. package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +3 -3
  233. package/templates/.agents/skills/code-task/SKILL.en.md +8 -5
  234. package/templates/.agents/skills/code-task/SKILL.zh-CN.md +9 -6
  235. package/templates/.agents/skills/commit/SKILL.en.md +30 -10
  236. package/templates/.agents/skills/commit/SKILL.zh-CN.md +6 -7
  237. package/templates/.agents/skills/commit/config/verify.json +1 -1
  238. package/templates/.agents/skills/commit/reference/commit-orchestration.en.md +3 -3
  239. package/templates/.agents/skills/commit/reference/commit-orchestration.zh-CN.md +3 -3
  240. package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +1 -1
  241. package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +1 -1
  242. package/templates/.agents/skills/commit/reference/task-status-update.en.md +2 -2
  243. package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +2 -2
  244. package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +7 -6
  245. package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +7 -6
  246. package/templates/.agents/skills/complete-manual-validation/config/verify.en.json +1 -1
  247. package/templates/.agents/skills/complete-manual-validation/config/verify.zh-CN.json +1 -1
  248. package/templates/.agents/skills/complete-manual-validation/reference/summary-update.en.md +1 -1
  249. package/templates/.agents/skills/complete-manual-validation/reference/summary-update.zh-CN.md +1 -1
  250. package/templates/.agents/skills/complete-task/SKILL.en.md +13 -13
  251. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +13 -13
  252. package/templates/.agents/skills/complete-task/reference/external-delivery.en.md +2 -2
  253. package/templates/.agents/skills/complete-task/reference/external-delivery.zh-CN.md +2 -2
  254. package/templates/.agents/skills/create-pr/SKILL.en.md +9 -11
  255. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +9 -11
  256. package/templates/.agents/skills/create-pr/reference/change-report.en.md +9 -4
  257. package/templates/.agents/skills/create-pr/reference/change-report.zh-CN.md +9 -4
  258. package/templates/.agents/skills/create-pr/scripts/change-report.mjs +203 -0
  259. package/templates/.agents/skills/create-release-note/SKILL.en.md +5 -6
  260. package/templates/.agents/skills/create-release-note/SKILL.zh-CN.md +5 -6
  261. package/templates/.agents/skills/create-task/SKILL.en.md +2 -1
  262. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +2 -1
  263. package/templates/.agents/skills/import-codescan/SKILL.en.md +1 -1
  264. package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +1 -1
  265. package/templates/.agents/skills/import-dependabot/SKILL.en.md +1 -1
  266. package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +1 -1
  267. package/templates/.agents/skills/import-issue/SKILL.en.md +1 -1
  268. package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +1 -1
  269. package/templates/.agents/skills/init-labels/SKILL.en.md +9 -10
  270. package/templates/.agents/skills/init-labels/SKILL.zh-CN.md +9 -10
  271. package/templates/.agents/skills/init-labels/scripts/init-labels.github.sh +57 -1
  272. package/templates/.agents/skills/init-labels/scripts/init-labels.sh +27 -1
  273. package/templates/.agents/skills/init-milestones/SKILL.en.md +3 -5
  274. package/templates/.agents/skills/init-milestones/SKILL.zh-CN.md +3 -5
  275. package/templates/.agents/skills/plan-task/SKILL.en.md +4 -3
  276. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +4 -3
  277. package/templates/.agents/skills/restore-task/SKILL.en.md +1 -1
  278. package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +1 -1
  279. package/templates/.agents/skills/review-analysis/SKILL.en.md +8 -5
  280. package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +8 -5
  281. package/templates/.agents/skills/review-analysis/config/verify.en.json +1 -0
  282. package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +1 -0
  283. package/templates/.agents/skills/review-analysis/reference/output-templates.en.md +18 -0
  284. package/templates/.agents/skills/review-analysis/reference/output-templates.zh-CN.md +18 -0
  285. package/templates/.agents/skills/review-code/SKILL.en.md +11 -8
  286. package/templates/.agents/skills/review-code/SKILL.zh-CN.md +11 -8
  287. package/templates/.agents/skills/review-code/config/verify.en.json +1 -0
  288. package/templates/.agents/skills/review-code/config/verify.zh-CN.json +1 -0
  289. package/templates/.agents/skills/review-code/reference/migration-risks.en.md +2 -1
  290. package/templates/.agents/skills/review-code/reference/migration-risks.zh-CN.md +2 -1
  291. package/templates/.agents/skills/review-code/reference/output-templates.en.md +19 -1
  292. package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +19 -1
  293. package/templates/.agents/skills/review-code/reference/report-template.en.md +4 -2
  294. package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +4 -2
  295. package/templates/.agents/skills/review-plan/SKILL.en.md +8 -5
  296. package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +8 -5
  297. package/templates/.agents/skills/review-plan/config/verify.en.json +1 -0
  298. package/templates/.agents/skills/review-plan/config/verify.zh-CN.json +1 -0
  299. package/templates/.agents/skills/review-plan/reference/output-templates.en.md +18 -0
  300. package/templates/.agents/skills/review-plan/reference/output-templates.zh-CN.md +18 -0
  301. package/templates/.agents/skills/review-pr/SKILL.en.md +1 -0
  302. package/templates/.agents/skills/review-pr/SKILL.zh-CN.md +1 -0
  303. package/templates/.agents/skills/review-pr/reference/evidence-grading.en.md +2 -2
  304. package/templates/.agents/skills/review-pr/reference/evidence-grading.zh-CN.md +2 -2
  305. package/templates/.agents/skills/run-manual-validation/SKILL.en.md +5 -0
  306. package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +5 -0
  307. package/templates/.agents/skills/run-task/SKILL.en.md +5 -1
  308. package/templates/.agents/skills/run-task/SKILL.zh-CN.md +5 -1
  309. package/templates/.agents/skills/update-agent-infra/SKILL.en.md +2 -2
  310. package/templates/.agents/skills/update-agent-infra/SKILL.zh-CN.md +2 -2
  311. package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +144 -109
  312. package/templates/.agents/skills/watch-pr/SKILL.en.md +5 -5
  313. package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +5 -5
  314. package/templates/.agents/templates/task.en.md +6 -2
  315. package/templates/.agents/templates/task.zh-CN.md +6 -2
  316. package/templates/.agents/workflows/bug-fix.en.yaml +9 -8
  317. package/templates/.agents/workflows/bug-fix.zh-CN.yaml +9 -8
  318. package/templates/.agents/workflows/feature-development.en.yaml +9 -8
  319. package/templates/.agents/workflows/feature-development.zh-CN.yaml +9 -8
  320. package/templates/.agents/workflows/refactoring.en.yaml +9 -8
  321. package/templates/.agents/workflows/refactoring.zh-CN.yaml +9 -8
  322. package/templates/.claude/commands/analyze-task.en.md +1 -1
  323. package/templates/.claude/commands/analyze-task.zh-CN.md +1 -1
  324. package/templates/.claude/commands/block-task.en.md +1 -1
  325. package/templates/.claude/commands/block-task.zh-CN.md +1 -1
  326. package/templates/.claude/commands/cancel-task.en.md +1 -1
  327. package/templates/.claude/commands/cancel-task.zh-CN.md +1 -1
  328. package/templates/.claude/commands/check-task.en.md +1 -1
  329. package/templates/.claude/commands/check-task.zh-CN.md +1 -1
  330. package/templates/.claude/commands/code-task.en.md +1 -1
  331. package/templates/.claude/commands/code-task.zh-CN.md +1 -1
  332. package/templates/.claude/commands/commit.en.md +1 -1
  333. package/templates/.claude/commands/commit.zh-CN.md +1 -1
  334. package/templates/.claude/commands/complete-manual-validation.en.md +1 -1
  335. package/templates/.claude/commands/complete-manual-validation.zh-CN.md +1 -1
  336. package/templates/.claude/commands/complete-task.en.md +1 -1
  337. package/templates/.claude/commands/complete-task.zh-CN.md +1 -1
  338. package/templates/.claude/commands/create-pr.en.md +1 -1
  339. package/templates/.claude/commands/create-pr.zh-CN.md +1 -1
  340. package/templates/.claude/commands/plan-task.en.md +1 -1
  341. package/templates/.claude/commands/plan-task.zh-CN.md +1 -1
  342. package/templates/.claude/commands/review-analysis.en.md +1 -1
  343. package/templates/.claude/commands/review-analysis.zh-CN.md +1 -1
  344. package/templates/.claude/commands/review-code.en.md +1 -1
  345. package/templates/.claude/commands/review-code.zh-CN.md +1 -1
  346. package/templates/.claude/commands/review-plan.en.md +1 -1
  347. package/templates/.claude/commands/review-plan.zh-CN.md +1 -1
  348. package/templates/.claude/commands/run-manual-validation.en.md +1 -1
  349. package/templates/.claude/commands/run-manual-validation.zh-CN.md +1 -1
  350. package/templates/.claude/commands/run-task.en.md +1 -1
  351. package/templates/.claude/commands/run-task.zh-CN.md +1 -1
  352. package/templates/.claude/commands/watch-pr.en.md +1 -1
  353. package/templates/.claude/commands/watch-pr.zh-CN.md +1 -1
  354. package/templates/{.trae/skills → .traecli/commands}/update-agent-infra.en.md +0 -1
  355. package/templates/{.trae/skills → .traecli/commands}/update-agent-infra.zh-CN.md +0 -1
  356. package/dist/lib/builtin-tuis.js +0 -40
  357. package/lib/builtin-tuis.ts +0 -56
  358. package/templates/.agents/rules/create-issue.github.en.md +0 -14
  359. package/templates/.agents/rules/create-issue.github.zh-CN.md +0 -27
  360. package/templates/.agents/rules/issue-pr-commands.github.en.md +0 -34
  361. package/templates/.agents/rules/issue-pr-commands.github.zh-CN.md +0 -49
  362. package/templates/.agents/rules/issue-sync.github.en.md +0 -40
  363. package/templates/.agents/rules/issue-sync.github.zh-CN.md +0 -76
  364. package/templates/.agents/rules/label-milestone-setup.github.en.md +0 -60
  365. package/templates/.agents/rules/label-milestone-setup.github.zh-CN.md +0 -60
  366. package/templates/.agents/rules/milestone-inference.github.en.md +0 -15
  367. package/templates/.agents/rules/milestone-inference.github.zh-CN.md +0 -27
  368. package/templates/.agents/rules/pr-checks-commands.github.en.md +0 -18
  369. package/templates/.agents/rules/pr-checks-commands.github.zh-CN.md +0 -34
  370. package/templates/.agents/rules/pr-sync.github.en.md +0 -43
  371. package/templates/.agents/rules/pr-sync.github.zh-CN.md +0 -69
  372. package/templates/.agents/rules/release-commands.github.en.md +0 -38
  373. package/templates/.agents/rules/release-commands.github.zh-CN.md +0 -38
  374. package/templates/.agents/rules/security-alerts.github.en.md +0 -43
  375. package/templates/.agents/rules/security-alerts.github.zh-CN.md +0 -43
@@ -8,12 +8,17 @@ description: >
8
8
 
9
9
  # 运行人工校验
10
10
 
11
+ ## 任务上下文解析
12
+
13
+ 入口可省略 task ref;显式 task scope 仅接受 `--task <ref>` 或 `-t <ref>`,不再解释位置 task ref。先解析 `--scope`、`--timeout`、`--format`,在 `--` 后原样保留用户命令,再调用 `agent-infra-internal task-context resolve {task-scope}`。解析失败时透传非零退出码,不自行扫描任务。内部 `task-validate` 协议仍使用位置 task ref。
14
+
11
15
  ## 行为边界
12
16
 
13
17
  - 本技能负责选择校验模式、调用唯一机械入口并记录证据;不把 PR 人工校验标为完成。
14
18
  - `complete-manual-validation` 仍是维护者确认覆盖充分后的最终登记入口。
15
19
  - 禁止直接操作临时 worktree、lease 或 container;只调用 `agent-infra-internal task-validate`。
16
20
  - 产物不得记录 token、环境变量、完整 argv、绝对用户路径或原始 transcript。
21
+ - 生成会同步到 Issue 的验证 artifact Markdown 前,先读取 `.agents/rules/sync-content-generation.md` 并遵循其中的生成端约束;Issue 同步保持透明,不解析或改写正文。
17
22
 
18
23
  ## 第 0 步:状态核对(执行前硬约束)
19
24
 
@@ -7,6 +7,10 @@ description: >
7
7
 
8
8
  # Run Task Lifecycle
9
9
 
10
+ ## Task Context Resolution
11
+
12
+ The entry point may omit the task ref; explicit task scope accepts only `--task <ref>` or `-t <ref>`, and positional task refs are not interpreted. Preserve the four policy options and their values, then call `agent-infra-internal task-context resolve {task-scope}`. Pass through resolution failures without scanning tasks locally. The internal orchestration protocol continues to use a positional task ref.
13
+
10
14
  The orchestrator delegates only and never executes a stage skill itself. First read `.agents/rules/no-mid-flow-questions.md`, `.agents/rules/lifecycle-orchestration.md`, and `reference/host-validation.md`.
11
15
 
12
16
  1. Resolve the canonical task ID, current Agent Client, and optional atomic policy flags, then run `task-snapshot`. If one explicit role field is present, all four are required.
@@ -14,7 +18,7 @@ The orchestrator delegates only and never executes a stage skill itself. First r
14
18
  3. Run `task-orchestration {task-id} begin-or-resume --client {client}` with the complete explicit policy. With no explicit policy, core reads that client's configured policy; existing runs use persisted policy. Disk state outside the complete current structure fails closed without rewriting; finish or clear active runs before upgrading. Stop on paused/completed results.
15
19
  4. Run `route`. On `completed`, run `agent-infra-internal task-verify {task-id} run-task.completed --format text` and stop. Only a `running` result with non-null `next` supplies action, role, round, artifact, requested model, and requested effort.
16
20
  5. Codex runs `codex-lifecycle capability-arm --task-id {task-id}` once. The current loop's real PostToolUse must attest that ordinary tool response. Pass its marker token, the exact routed model, and the exact routed reasoning effort to `prepare --client {client} --requested-model {requestedModel} --requested-reasoning-effort {requestedReasoningEffort} --capability-token {token}`. Core first validates the exact routed model/effort, capability provenance, and controller binding, then captures a read-only snapshot, builds an in-memory prepared receipt, atomically consumes the token, and saves the prepared state with the capability session, turn, and tool-use origin. Activation then verifies that spawn belongs to the same session and turn and uses a distinct tool-use. Other clients use the same prepare without a token. Failure creates no baseline, receipt, or child.
17
- 6. After prepare, run `task-orchestration <task-ref> dispatch` immediately before calling the fresh native child, then use route's exact model/effort and only the short task ref, skill, `--orchestrated`, and stage identity. The trusted hook-spawn first-observation time must fall between dispatch and the deadline. Its first provenance-sensitive command must be `await-activation --stage ... --round ... --artifact ... --role ...`; before `running`, it must not snapshot, emit stage-started, write business files, or start commit. Only explicit `recover-prepared` may clear an expired orphan when the task fingerprint is exact and no matching unconsumed active lifecycle evidence remains.
21
+ 6. After prepare, run `task-orchestration <task-ref> dispatch` immediately before calling the fresh native child, then use route's exact model/effort and only the short task ref, skill, `--orchestrated`, and stage identity. The trusted hook-spawn first-observation time must fall between dispatch and the deadline. Its first provenance-sensitive command must be `await-activation --stage ... --round ... --artifact ... --role ...`; before `running`, it must not snapshot, emit stage-started, or write business files. The code stage may create a local checkpoint only through code-task's durable intent core; it must not delegate a separate commit stage or push. Only explicit `recover-prepared` may clear an expired orphan when the task fingerprint is exact and no matching unconsumed active lifecycle evidence remains.
18
22
  7. Codex uses SubagentStart/Stop and App Server actual evidence to activate, consume, and seal one receipt; trusted parent fallback must produce the same complete provenance. Timed-out waits do nothing. Advance only a sealed receipt and repeat step 4 only while running.
19
23
  8. Create a fresh child each round and never follow up with an old reviewer. Each requested/actual mismatch needs its own host fallback reason. Protocol, capability, receipt hook/evidence binding, source, controller, identity, ledger, or fingerprint failure pauses and fails closed; cross-root package/build/contract or hook/profile content drift is delivered as a warning instead of blocking natural evolution.
20
24
  9. On pause or completion, run the matching typed verification and report the structured endpoint.
@@ -7,6 +7,10 @@ description: >
7
7
 
8
8
  # 运行任务生命周期
9
9
 
10
+ ## 任务上下文解析
11
+
12
+ 入口可省略 task ref;显式 task scope 仅接受 `--task <ref>` 或 `-t <ref>`,不再解释位置 task ref。保留四个策略选项及其值,再调用 `agent-infra-internal task-context resolve {task-scope}`。解析失败时透传非零退出码,不自行扫描任务。内部 orchestration 协议仍使用位置 task ref。
13
+
10
14
  总控只编排,不直接执行任何阶段技能。执行前先读取 `.agents/rules/no-mid-flow-questions.md`、`.agents/rules/lifecycle-orchestration.md` 与 `reference/host-validation.md`。
11
15
 
12
16
  1. 解析规范任务 ID、当前 Agent Client,以及可选的原子策略 `--executor-model`、`--executor-reasoning-effort`、`--reviewer-model`、`--reviewer-reasoning-effort`,并执行 `agent-infra-internal task-snapshot {task-id} --format text`。任一显式策略字段出现时四个 role 字段必须完整,不得与配置拼接;两个角色可以使用同一模型。
@@ -14,7 +18,7 @@ description: >
14
18
  3. 调用 `agent-infra-internal task-orchestration {task-id} begin-or-resume --client {client}` 并转发完整显式策略。完全没有显式策略时由核心读取当前 client 的 `agentClients[].orchestration`;existing run 使用持久化策略。磁盘状态不符合当前完整结构时核心失败关闭且不改写;升级前必须完成或清空 active run。仅当核心返回 `ORCHESTRATION_MODEL_POLICY_REQUIRED` 时,先用 `agent-client model-selection` 展示 complete/partial/interactive-only 来源,再一次收集完整策略;未回答则不创建 run。若为 paused/completed,按结构化结果停止。
15
19
  4. 调用 `route` 并读取结构化结果。若返回 `completed`,立即运行 `agent-infra-internal task-verify {task-id} run-task.completed --format text` 并停止;仅当返回 `running` 且 `next` 非空时读取唯一 action、role、round、artifact、`requestedModel` 和 `requestedReasoningEffort`,不得自行推断。
16
20
  5. Codex 先调用一次 `agent-infra-internal codex-lifecycle capability-arm --task-id {task-id}`。该普通工具调用必须由当前 loop 的真实 PostToolUse 回写 attestation;把 route 返回的精确 model、effort 和 marker 中 token 一并传给 `prepare --client {client} --requested-model {requestedModel} --requested-reasoning-effort {requestedReasoningEffort} --capability-token {token}`。核心先校验精确的 model/effort、capability provenance 与 controller binding,再只读捕获快照、构造内存中的 prepared receipt,最后原子消费 token 并保存 prepared 状态,同时持久化 capability 的 session、turn、tool-use 来源。activation 再校验 spawn 与该来源属于同一 session/turn,且 spawn 使用独立的 tool-use。其他客户端直接调用同一 prepare(无 token)。任一失败不得创建 baseline、receipt 或 child。
17
- 6. prepare 成功后,在调用 fresh 原生子 Agent 的紧邻前一步执行 `task-orchestration <task-ref> dispatch`,再显式覆盖 route 返回的 model/effort;只传短任务引用、skill 名、`--orchestrated` 与 stage/round/artifact/role。可信 hook-spawn 首次观察时间必须位于 dispatch 与 deadline 之间。child 的第一条 provenance-sensitive 命令必须是 `await-activation --stage ... --round ... --artifact ... --role ...`;返回 running 前禁止 snapshot、阶段 started、业务写入或 commit。超时由核心暂停;崩溃遗留 prepared receipt 只能在 exact workspace fingerprint、无匹配的未消费 active lifecycle evidence 且 deadline 已过时显式 `recover-prepared`。
21
+ 6. prepare 成功后,在调用 fresh 原生子 Agent 的紧邻前一步执行 `task-orchestration <task-ref> dispatch`,再显式覆盖 route 返回的 model/effort;只传短任务引用、skill 名、`--orchestrated` 与 stage/round/artifact/role。可信 hook-spawn 首次观察时间必须位于 dispatch 与 deadline 之间。child 的第一条 provenance-sensitive 命令必须是 `await-activation --stage ... --round ... --artifact ... --role ...`;返回 running 前禁止 snapshot、阶段 started 或业务写入;代码阶段的本地 checkpoint 只能通过 code-task 的持久化 intent 核心完成,禁止单独委派 commit 阶段或推送。超时由核心暂停;崩溃遗留 prepared receipt 只能在 exact workspace fingerprint、无匹配的未消费 active lifecycle evidence 且 deadline 已过时显式 `recover-prepared`。
18
22
  7. Codex 用 SubagentStart/Stop 与 App Server actual evidence 激活、消费并封存唯一 receipt;受信 parent fallback 仍必须形成相同的完整 provenance。timed-out wait 无动作;只有 empty turns 或协议 `inProgress` 可等待,malformed、身份/传输错误或异常 terminal 均暂停。子 Agent 返回后只对 sealed receipt 调用 `advance`;只有 `running` 才重复步骤 4。
19
23
  8. 每轮创建新 child;禁止 follow-up 复用 reviewer。actual model/effort 与 requested 不同时必须有各自的宿主降级理由。protocol、capability、receipt 内 hook/evidence binding、source、controller、身份、账本或 fingerprint 异常都调用 `pause` 并失败关闭;跨根 package/build/contract 或 hook/profile 内容漂移按 warning 交付,不把自然演进差异当成硬失败。
20
24
  9. 完成或暂停后运行对应 typed verification,并把结构化 run 摘要、暂停原因、commit 终点或 clean completion evidence 告知用户。
@@ -51,7 +51,7 @@ The script outputs JSON to stdout. Parse and record the report.
51
51
  - `managed.conflicts`: guarded managed files with unknown origin, two-sided changes, or ownership that cannot be proven during a platform switch; list each target, reason, and three-way hash
52
52
  - `managed.removed`: deleted managed files (including old paths removed during template migrations)
53
53
  - `managed.skippedPlatform`: managed / merged entries skipped because they belong to a different platform
54
- - `managed.skippedTUI`: managed / merged entries skipped because they are owned by a built-in Agent Client whose `agentClients[].enabled` is `false` (legacy `tuis` is migration-only; customTUI command files under the same path prefix are preserved)
54
+ - `managed.skippedTUI`: managed / merged entries skipped because they are owned by a built-in Agent Client whose `agentClients[].enabled` is `false` (customTUI command files under the same path prefix are preserved)
55
55
  - `merged.pending`: list of merged files for AI to process
56
56
  - Each item has `target` (project-relative path) and `template` (template-root-relative path)
57
57
  - `registryAdded`: newly added file registry entries
@@ -131,7 +131,7 @@ warning to the end of the report:
131
131
  > **Rationale**: The current execution used the old skill logic; the new version
132
132
  > may contain additional processing steps. Running again ensures the new logic
133
133
  > is fully applied.
134
- > Alternatively, users can run `ai update` before executing the skill to
134
+ > Alternatively, users can run `ai sync` before executing the skill to
135
135
  > pre-update the seed files and avoid the need for a second run.
136
136
 
137
137
  ### Output report
@@ -43,7 +43,7 @@ node .agents/skills/update-agent-infra/scripts/sync-templates.js
43
43
  - `managed.conflicts`:来源未知、双边修改或平台切换时无法证明官方所有权的 guarded managed 冲突;必须逐项展示 target、reason 与三方哈希
44
44
  - `managed.removed`:被删除的 managed 文件(包括模板迁移时移除的旧路径)
45
45
  - `managed.skippedPlatform`:因归属其他平台而被跳过的 managed / merged 条目
46
- - `managed.skippedTUI`:因对应内建 Agent Client 的 `agentClients[].enabled` 为 `false` 而被跳过的 managed / merged 条目(旧 `tuis` 仅用于迁移;落在同一路径前缀下的 customTUI 命令文件会被保留)
46
+ - `managed.skippedTUI`:因对应内建 Agent Client 的 `agentClients[].enabled` 为 `false` 而被跳过的 managed / merged 条目(落在同一路径前缀下的 customTUI 命令文件会被保留)
47
47
  - `merged.pending`:需要 AI 处理的 merged 文件列表
48
48
  - 每项包含 `target`(项目中的目标路径)和 `template`(模板根目录下的相对路径)
49
49
  - `registryAdded`:新增的文件注册条目
@@ -116,7 +116,7 @@ node .agents/skills/update-agent-infra/scripts/sync-templates.js
116
116
 
117
117
  > **原因**:本次执行使用的是旧版技能逻辑,新版技能可能包含额外的处理步骤。
118
118
  > 再次执行可确保新逻辑完整应用。
119
- > 用户也可以在执行前先运行 `ai update` 来预先更新技能文件,避免需要两次执行。
119
+ > 用户也可以在执行前先运行 `ai sync` 来预先更新技能文件,避免需要两次执行。
120
120
 
121
121
  ### 输出报告
122
122
 
@@ -74,6 +74,10 @@ const DEFAULTS = {
74
74
  "task": {
75
75
  "shortIdLength": 2
76
76
  },
77
+ "delivery": {
78
+ "remote": "origin",
79
+ "baseRef": "main"
80
+ },
77
81
  "labels": {
78
82
  "in": {}
79
83
  },
@@ -116,6 +120,10 @@ const DEFAULTS = {
116
120
  ],
117
121
  "ejected": [],
118
122
  "retiredManaged": [
123
+ {
124
+ "path": ".trae/skills/",
125
+ "templateHashes": []
126
+ },
119
127
  {
120
128
  "path": ".agents/workspace/README.md",
121
129
  "templateHashes": [
@@ -200,18 +208,17 @@ const AGENT_CLIENT_MANIFEST = [
200
208
  "displayName": "TraeCode CLI",
201
209
  "invocation": "/${skillName}",
202
210
  "ownedPathPrefixes": [
203
- ".trae/"
211
+ ".traecli/"
204
212
  ],
205
213
  "managed": [
206
- ".trae/skills/"
214
+ ".traecli/commands/"
207
215
  ],
208
216
  "merged": [],
209
217
  "ejected": [],
210
218
  "customCommand": {
211
- "target": ".trae/skills/${skillName}.md",
219
+ "target": ".traecli/commands/${skillName}.md",
212
220
  "frontmatter": {},
213
- "includeUsage": true,
214
- "inheritDisableModelInvocation": true
221
+ "argumentsToken": "$ARGUMENTS"
215
222
  }
216
223
  }
217
224
  ];
@@ -230,84 +237,19 @@ const CUSTOM_TUI_CONTRACT = {
230
237
  const KNOWN_PLATFORMS = new Set(['github', 'none']);
231
238
  const KNOWN_LANGUAGES = new Set(['en', 'zh-CN']);
232
239
 
233
- const BUILTIN_TUI_IDS = AGENT_CLIENT_MANIFEST.map((entry) => entry.id);
240
+ const AGENT_CLIENT_IDS = AGENT_CLIENT_MANIFEST.map((entry) => entry.id);
234
241
 
235
242
  function normalizeAgentClientConfig(cfg) {
236
243
  const own = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
237
- const diagnostics = [];
238
244
  const failure = (code, path) => ({
239
- source: null,
240
245
  state: null,
241
246
  canonical: null,
242
- remainingSandboxTools: undefined,
243
- removeLegacyTuis: false,
244
- changed: false,
245
- diagnostics,
246
247
  error: `${code} at ${path}`,
247
248
  errorCode: code,
248
249
  errorPath: path
249
250
  });
250
- const projectTuis = (value) => {
251
- if (!Array.isArray(value)) {
252
- return Object.fromEntries(BUILTIN_TUI_IDS.map((id) => [id, true]));
253
- }
254
- const enabled = new Set();
255
- for (const [index, candidate] of value.entries()) {
256
- if (BUILTIN_TUI_IDS.includes(candidate)) enabled.add(candidate);
257
- else diagnostics.push({ code: 'LEGACY_VALUE_IGNORED', path: `tuis[${index}]` });
258
- }
259
- return Object.fromEntries(BUILTIN_TUI_IDS.map((id) => [id, enabled.has(id)]));
260
- };
261
- const projectSandbox = (value) => {
262
- if (!Array.isArray(value) || value.length === 0) {
263
- return {
264
- installed: Object.fromEntries(BUILTIN_TUI_IDS.map((id) => [id, true])),
265
- clientSignals: new Set(),
266
- remainingTools: Array.isArray(value) ? [] : undefined
267
- };
268
- }
269
- const installed = new Set();
270
- const remainingTools = [];
271
- for (const [index, candidate] of value.entries()) {
272
- if (BUILTIN_TUI_IDS.includes(candidate)) installed.add(candidate);
273
- else if (typeof candidate === 'string') remainingTools.push(candidate);
274
- else diagnostics.push({ code: 'LEGACY_VALUE_IGNORED', path: `sandbox.tools[${index}]` });
275
- }
276
- return {
277
- installed: Object.fromEntries(BUILTIN_TUI_IDS.map((id) => [id, installed.has(id)])),
278
- clientSignals: installed,
279
- remainingTools
280
- };
281
- };
282
- const serialize = (state) => BUILTIN_TUI_IDS.map((id) => ({ id, ...state[id] }));
283
- const hasCanonical = own(cfg, 'agentClients');
284
- const hasLegacyTuis = own(cfg, 'tuis');
285
- const sandbox = cfg.sandbox && typeof cfg.sandbox === 'object' && !Array.isArray(cfg.sandbox)
286
- ? cfg.sandbox
287
- : undefined;
288
- const hasSandboxTools = sandbox !== undefined && own(sandbox, 'tools');
289
- const tuiProjection = projectTuis(cfg.tuis);
290
- const sandboxProjection = projectSandbox(sandbox?.tools);
291
-
292
- if (!hasCanonical) {
293
- const state = Object.fromEntries(BUILTIN_TUI_IDS.map((id) => [id, {
294
- enabled: tuiProjection[id],
295
- installInSandbox: sandboxProjection.installed[id]
296
- }]));
297
- return {
298
- source: 'legacy',
299
- state,
300
- canonical: serialize(state),
301
- remainingSandboxTools: sandboxProjection.remainingTools,
302
- removeLegacyTuis: hasLegacyTuis,
303
- changed: true,
304
- diagnostics,
305
- error: null,
306
- errorCode: null,
307
- errorPath: null
308
- };
309
- }
310
-
251
+ const serialize = (state) => AGENT_CLIENT_IDS.map((id) => ({ id, ...state[id] }));
252
+ if (!own(cfg, 'agentClients')) return failure('MISSING_AGENT_CLIENT', 'agentClients');
311
253
  if (!Array.isArray(cfg.agentClients)) return failure('INVALID_AGENT_CLIENTS', 'agentClients');
312
254
  const entries = new Map();
313
255
  for (const [index, candidate] of cfg.agentClients.entries()) {
@@ -325,7 +267,7 @@ function normalizeAgentClientConfig(cfg) {
325
267
  ) {
326
268
  return failure('INVALID_AGENT_CLIENTS', entryPath);
327
269
  }
328
- if (!BUILTIN_TUI_IDS.includes(candidate.id)) {
270
+ if (!AGENT_CLIENT_IDS.includes(candidate.id)) {
329
271
  return failure('UNKNOWN_AGENT_CLIENT', `${entryPath}.id`);
330
272
  }
331
273
  if (entries.has(candidate.id)) return failure('DUPLICATE_AGENT_CLIENT', `${entryPath}.id`);
@@ -335,24 +277,44 @@ function normalizeAgentClientConfig(cfg) {
335
277
  let orchestration;
336
278
  if (own(candidate, 'orchestration')) {
337
279
  const policy = candidate.orchestration;
338
- const exact = (value) => typeof value === 'string' && value.length > 0 && value.trim() === value;
339
- const validRole = (role) => role
340
- && typeof role === 'object'
341
- && !Array.isArray(role)
342
- && Object.keys(role).length === 2
343
- && exact(role.model)
344
- && exact(role.reasoningEffort);
345
280
  if (
346
281
  !policy
347
282
  || typeof policy !== 'object'
348
283
  || Array.isArray(policy)
349
284
  || Object.keys(policy).length !== 2
350
- || !validRole(policy.executor)
351
- || !validRole(policy.reviewer)
285
+ || !own(policy, 'executor')
286
+ || !own(policy, 'reviewer')
352
287
  ) {
353
288
  return failure('INVALID_AGENT_CLIENTS', `${entryPath}.orchestration`);
354
289
  }
355
- orchestration = structuredClone(policy);
290
+ const parseExact = (value, path) => {
291
+ if (typeof value !== 'string' || value.length === 0 || value.trim() !== value) {
292
+ return failure('INVALID_AGENT_CLIENTS', path);
293
+ }
294
+ return value;
295
+ };
296
+ const parseRole = (role, rolePath) => {
297
+ if (
298
+ !role
299
+ || typeof role !== 'object'
300
+ || Array.isArray(role)
301
+ || Object.keys(role).length !== 2
302
+ || !own(role, 'model')
303
+ || !own(role, 'reasoningEffort')
304
+ ) {
305
+ return failure('INVALID_AGENT_CLIENTS', rolePath);
306
+ }
307
+ const model = parseExact(role.model, `${rolePath}.model`);
308
+ if (typeof model !== 'string') return model;
309
+ const reasoningEffort = parseExact(role.reasoningEffort, `${rolePath}.reasoningEffort`);
310
+ if (typeof reasoningEffort !== 'string') return reasoningEffort;
311
+ return { model, reasoningEffort };
312
+ };
313
+ const executor = parseRole(policy.executor, `${entryPath}.orchestration.executor`);
314
+ if (executor.errorCode) return executor;
315
+ const reviewer = parseRole(policy.reviewer, `${entryPath}.orchestration.reviewer`);
316
+ if (reviewer.errorCode) return reviewer;
317
+ orchestration = { executor, reviewer };
356
318
  }
357
319
  entries.set(candidate.id, {
358
320
  enabled: candidate.enabled,
@@ -360,25 +322,29 @@ function normalizeAgentClientConfig(cfg) {
360
322
  ...(orchestration ? { orchestration } : {})
361
323
  });
362
324
  }
363
- if (BUILTIN_TUI_IDS.some((id) => !entries.has(id))) {
325
+ if (AGENT_CLIENT_IDS.some((id) => !entries.has(id))) {
364
326
  return failure('MISSING_AGENT_CLIENT', 'agentClients');
365
327
  }
366
- const state = Object.fromEntries(BUILTIN_TUI_IDS.map((id) => [id, entries.get(id)]));
367
- if (hasLegacyTuis && BUILTIN_TUI_IDS.some((id) => state[id].enabled !== tuiProjection[id])) {
368
- return failure('LEGACY_CONFLICT', 'tuis');
328
+ for (const [index, id] of AGENT_CLIENT_IDS.entries()) {
329
+ if (cfg.agentClients[index]?.id !== id) {
330
+ return failure('INVALID_AGENT_CLIENTS', `agentClients[${index}].id`);
331
+ }
369
332
  }
370
- if ([...sandboxProjection.clientSignals].some((id) => !state[id].installInSandbox)) {
371
- return failure('LEGACY_CONFLICT', 'sandbox.tools');
333
+ if (own(cfg, 'tuis')) return failure('INVALID_AGENT_CLIENTS', 'tuis');
334
+ const sandbox = cfg.sandbox && typeof cfg.sandbox === 'object' && !Array.isArray(cfg.sandbox)
335
+ ? cfg.sandbox
336
+ : undefined;
337
+ if (Array.isArray(sandbox?.tools)) {
338
+ for (const [index, tool] of sandbox.tools.entries()) {
339
+ if (AGENT_CLIENT_IDS.includes(tool)) {
340
+ return failure('INVALID_AGENT_CLIENTS', `sandbox.tools[${index}]`);
341
+ }
342
+ }
372
343
  }
373
- const sameOrder = cfg.agentClients.every((entry, index) => entry.id === BUILTIN_TUI_IDS[index]);
344
+ const state = Object.fromEntries(AGENT_CLIENT_IDS.map((id) => [id, entries.get(id)]));
374
345
  return {
375
- source: 'canonical',
376
346
  state,
377
347
  canonical: serialize(state),
378
- remainingSandboxTools: hasSandboxTools ? sandboxProjection.remainingTools : undefined,
379
- removeLegacyTuis: hasLegacyTuis,
380
- changed: hasLegacyTuis || sandboxProjection.clientSignals.size > 0 || !sameOrder,
381
- diagnostics,
382
348
  error: null,
383
349
  errorCode: null,
384
350
  errorPath: null
@@ -387,16 +353,6 @@ function normalizeAgentClientConfig(cfg) {
387
353
 
388
354
  function materializeAgentClientConfig(cfg, normalized) {
389
355
  cfg.agentClients = normalized.canonical;
390
- delete cfg.tuis;
391
- if (normalized.remainingSandboxTools !== undefined) {
392
- cfg.sandbox = {
393
- ...(cfg.sandbox || {}),
394
- tools: [
395
- 'agent-infra',
396
- ...normalized.remainingSandboxTools.filter((tool) => tool !== 'agent-infra')
397
- ]
398
- };
399
- }
400
356
  }
401
357
 
402
358
  function assetMatches(entry, target) {
@@ -483,6 +439,17 @@ function isInsideProject(projectRoot, relativePath) {
483
439
  return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel);
484
440
  }
485
441
 
442
+ function isInsideProjectDirectory(projectRoot, directory, relativePath) {
443
+ if (!isInsideProject(projectRoot, directory) || !isInsideProject(projectRoot, relativePath)) {
444
+ return false;
445
+ }
446
+
447
+ const root = path.resolve(projectRoot, directory);
448
+ const resolved = path.resolve(projectRoot, relativePath);
449
+ const rel = path.relative(root, resolved);
450
+ return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel);
451
+ }
452
+
486
453
  function isPathOwnedByOtherPlatform(relativePath, platformType) {
487
454
  const normalized = norm(relativePath).replace(/^\.\//, '');
488
455
  const top = normalized.split('/')[0];
@@ -1310,7 +1277,7 @@ function syncTemplates(projectRoot, templateRootOverride) {
1310
1277
  return { error: enabledResolution.error };
1311
1278
  }
1312
1279
  const enabledTUIs = new Set(
1313
- BUILTIN_TUI_IDS.filter((id) => enabledResolution.state[id].enabled)
1280
+ AGENT_CLIENT_IDS.filter((id) => enabledResolution.state[id].enabled)
1314
1281
  );
1315
1282
  materializeAgentClientConfig(cfg, enabledResolution);
1316
1283
  const customTUIsConfig = Array.isArray(cfg.customTUIs) ? cfg.customTUIs : [];
@@ -1330,6 +1297,10 @@ function syncTemplates(projectRoot, templateRootOverride) {
1330
1297
  (descriptor.templateHashes || []).map(trustedBaseline).filter(Boolean)
1331
1298
  )];
1332
1299
  }));
1300
+ const retiredManagedForTarget = (target) => [...retiredManaged.entries()].find(
1301
+ ([entry]) => assetMatches(entry, target)
1302
+ && (!entry.endsWith('/') || isInsideProjectDirectory(projectRoot, entry, target))
1303
+ );
1333
1304
  const planningRegistry = {
1334
1305
  ...currentRegistry,
1335
1306
  managed: currentRegistry.managed.filter((entry) => !retiredManaged.has(norm(entry)))
@@ -1358,7 +1329,7 @@ function syncTemplates(projectRoot, templateRootOverride) {
1358
1329
  for (const target of Object.keys(managedBaselines)) {
1359
1330
  if (
1360
1331
  !guardedManaged.has(norm(target))
1361
- && !retiredManaged.has(norm(target))
1332
+ && !retiredManagedForTarget(target)
1362
1333
  && !allClientManaged.some((entry) => assetMatches(entry, target))
1363
1334
  ) {
1364
1335
  delete managedBaselines[target];
@@ -1434,8 +1405,72 @@ function syncTemplates(projectRoot, templateRootOverride) {
1434
1405
  );
1435
1406
 
1436
1407
  for (const [entry, historicalTemplateHashes] of retiredManaged) {
1437
- const target = path.join(projectRoot, entry);
1408
+ const target = path.join(projectRoot, entry.endsWith('/') ? entry.slice(0, -1) : entry);
1438
1409
  const owned = currentRegistry.managed.some((candidate) => norm(candidate) === entry);
1410
+ if (entry.endsWith('/')) {
1411
+ if (fs.existsSync(target)) {
1412
+ const targetStat = fs.lstatSync(target);
1413
+ if (!targetStat.isDirectory() || targetStat.isSymbolicLink()) {
1414
+ report.managed.protected.push({
1415
+ target: entry,
1416
+ reason: 'invalid-type',
1417
+ baseline: null,
1418
+ local: null,
1419
+ template: null
1420
+ });
1421
+ continue;
1422
+ }
1423
+ }
1424
+ const candidates = new Set(
1425
+ Object.keys(managedBaselines).filter((candidate) =>
1426
+ assetMatches(entry, candidate)
1427
+ && isInsideProjectDirectory(projectRoot, entry, candidate)
1428
+ )
1429
+ );
1430
+ if (owned && fs.existsSync(target)) {
1431
+ for (const filePath of walkDir(target)) {
1432
+ candidates.add(norm(path.relative(projectRoot, filePath)));
1433
+ }
1434
+ }
1435
+
1436
+ for (const candidate of candidates) {
1437
+ const candidatePath = path.join(projectRoot, candidate);
1438
+ const baseline = trustedBaseline(managedBaselines[candidate]);
1439
+ if (!fs.existsSync(candidatePath)) {
1440
+ if (Object.prototype.hasOwnProperty.call(managedBaselines, candidate)) {
1441
+ delete managedBaselines[candidate];
1442
+ baselinesChanged = true;
1443
+ }
1444
+ continue;
1445
+ }
1446
+ const stat = fs.lstatSync(candidatePath);
1447
+ const localHash = stat.isFile() && !stat.isSymbolicLink()
1448
+ ? sha256(fs.readFileSync(candidatePath))
1449
+ : null;
1450
+ const safeToRemove = localHash !== null
1451
+ && (localHash === baseline || historicalTemplateHashes.has(localHash));
1452
+ if (safeToRemove) {
1453
+ fs.unlinkSync(candidatePath);
1454
+ report.managed.removed.push(candidate);
1455
+ } else {
1456
+ report.managed.protected.push({
1457
+ target: candidate,
1458
+ reason: localHash === null
1459
+ ? 'invalid-type'
1460
+ : (baseline !== null ? 'user-modified' : 'unknown-origin'),
1461
+ baseline,
1462
+ local: localHash,
1463
+ template: null
1464
+ });
1465
+ }
1466
+ if (Object.prototype.hasOwnProperty.call(managedBaselines, candidate)) {
1467
+ delete managedBaselines[candidate];
1468
+ baselinesChanged = true;
1469
+ }
1470
+ }
1471
+ removeEmptyDirs(target);
1472
+ continue;
1473
+ }
1439
1474
  if (!fs.existsSync(target)) continue;
1440
1475
  const stat = fs.lstatSync(target);
1441
1476
  const baseline = trustedBaseline(managedBaselines[entry]);
@@ -21,7 +21,7 @@ Version stamp rule: before creating or updating `task.md` frontmatter, read `.ag
21
21
 
22
22
  ## Task Context Resolution
23
23
 
24
- > Keep `--pr <number>` and PR URLs on the existing PR-anchored path. Otherwise, the task path may omit the task ref and also accepts a legacy positional ref or `--task <ref>` / `-t <ref>`. Separate task scope from the full arguments, then call `agent-infra-internal task-context resolve {task-scope}` and bind `{task-id}` to the returned full `taskId`. A PR anchor and task scope are mutually exclusive.
24
+ > Keep `--pr <number>` and PR URLs on the existing PR-anchored path. Otherwise, the task path may omit the task ref; explicit task scope accepts only `--task <ref>` or `-t <ref>`, and positional task refs are not interpreted. Separate task scope from the full arguments, then call `agent-infra-internal task-context resolve {task-scope}` and bind `{task-id}` to the returned full `taskId`. A PR anchor and task scope are mutually exclusive.
25
25
 
26
26
  ## Step Start: Write the started Marker
27
27
 
@@ -39,8 +39,8 @@ After prerequisites pass and before this round's first artifact action, append a
39
39
 
40
40
  Resolve the target PR number `{pr#}` and an optional `{task-id}` via these deterministic branches:
41
41
 
42
- - Scenario A (argument omitted): reverse-lookup the active task from the current branch, then read its `pr_number`.
43
- - Scenario B (omitted task ref, positional task ref, or `--task/-t`, **task-anchored primary path**): resolve the full `{task-id}` via "Task Context Resolution" and read `.agents/workspace/active/{task-id}/task.md` for `pr_number` as `{pr#}`; if `pr_number` is empty, follow "Error Handling" to prompt running `create-pr` first, then stop.
42
+ - Scenario A (argument omitted): reverse-lookup the active task from the current branch, then read its verified `pr_delivery_fact.identity.number`.
43
+ - Scenario B (omitted task ref or `--task/-t`, **task-anchored primary path**): resolve the full `{task-id}` via "Task Context Resolution" and read `.agents/workspace/active/{task-id}/task.md` for verified `pr_delivery_fact.identity.number` as `{pr#}`; if the fact is unbound, follow "Error Handling" to prompt running `create-pr` first, then stop.
44
44
  - Scenario C (`--pr <number>` or a PR URL): use that PR number directly as `{pr#}`; then determine `{task-id}` via "Reverse-lookup task".
45
45
  - Reverse-lookup task (scenarios A / C): use task context/query capabilities to find the unique active task bound to `{pr#}`. If none exists, stop and request binding first; the typed checks intent does not create a second taskless state machine.
46
46
 
@@ -74,7 +74,7 @@ Update `.agents/workspace/active/{task-id}/task.md`:
74
74
  - `assigned_to`: {current agent}
75
75
  - `updated_at`: {current time}
76
76
  - `agent_infra_version`: per `.agents/rules/version-stamp.md`
77
- - **Do not change** `pr_status` (keep `created`) or `current_step`
77
+ - **Do not change** `pr_delivery_fact` or `current_step`
78
78
  - **Append** to `## Activity Log` (do not overwrite prior entries; `{N}` = number of existing Watch PR entries for this task + 1):
79
79
  ```
80
80
  - {YYYY-MM-DD HH:mm:ss±HH:MM} — **Watch PR (Round {N})** by {agent} — {success: PR ready, repair commits: {k} [{SHA summary}] / blocked: blocked: {summary}}
@@ -148,6 +148,6 @@ Stop immediately after the checklist. The green exit waits for the user to run `
148
148
 
149
149
  ## Error Handling
150
150
 
151
- - Cannot locate a PR (task short id resolves but task.md has no `pr_number`, and no `--pr` was passed and the current branch has no PR): prompt "Run `create-pr` first, or specify the PR with `--pr <number>`", then stop.
151
+ - Cannot locate a PR (task short id resolves but task.md has no verified bound `pr_delivery_fact`, and no `--pr` was passed and the current branch has no PR): prompt "Run `create-pr` first, or specify the PR with `--pr <number>`", then stop.
152
152
  - Platform CLI not authenticated or API unavailable: prompt that manual intervention is needed, then stop.
153
153
  - Short-id resolution failure: pass through `task-short-id.js`'s exit code and error message; do not rewrite it.
@@ -21,7 +21,7 @@ description: >
21
21
 
22
22
  ## 任务上下文解析
23
23
 
24
- > 入口允许省略 task ref,也接受旧位置 task ref 或 `--task <ref>` / `-t <ref>`。先从完整参数中分离 task scope 并原样保留其他业务操作数,再调用 `agent-infra-internal task-context resolve {task-scope}`;`{task-scope}` 为空、位置 ref 或 task flag 之一。只读取结构化结果的 `taskId`,后续把 `{task-id}` 绑定为该完整 `TASK-YYYYMMDD-HHMMSS`。解析失败时透传非零退出码,不自行扫描任务。
24
+ > 入口允许省略 task ref,也接受 `--task <ref>` / `-t <ref>`。先从完整参数中分离 task scope 并原样保留其他业务操作数,再调用 `agent-infra-internal task-context resolve {task-scope}`;`{task-scope}` 为空或 task flag 之一。只读取结构化结果的 `taskId`,后续把 `{task-id}` 绑定为该完整 `TASK-YYYYMMDD-HHMMSS`。解析失败时透传非零退出码,不自行扫描任务。
25
25
 
26
26
  ## 步骤开始:写入 started 标记
27
27
 
@@ -39,8 +39,8 @@ description: >
39
39
 
40
40
  按以下确定性分支解析出目标 PR 号 `{pr#}` 与可选 `{task-id}`:
41
41
 
42
- - 场景 A(省略入参):从当前分支反查 active task;定位后读取其 `pr_number`。
43
- - 场景 B(省略 task ref、旧位置 task ref 或 `--task/-t`,**任务锚定主路径**):按「任务上下文解析」取得完整 `{task-id}`。读 `.agents/workspace/active/{task-id}/task.md` 取 `pr_number` 作为 `{pr#}`;`pr_number` 为空时按「错误处理」提示先 `create-pr`,停止。
42
+ - 场景 A(省略入参):从当前分支反查 active task;定位后读取其 verified `pr_delivery_fact.identity.number`。
43
+ - 场景 B(省略 task ref 或 `--task/-t`,**任务锚定主路径**):按「任务上下文解析」取得完整 `{task-id}`。读 `.agents/workspace/active/{task-id}/task.md` 取 verified `pr_delivery_fact.identity.number` 作为 `{pr#}`;fact 未绑定时按「错误处理」提示先 `create-pr`,停止。
44
44
  - 场景 C(`--pr <number>` 或 PR URL):直接取该 PR 号为 `{pr#}`;随后按「反查任务」确定 `{task-id}`。
45
45
  - 反查任务(场景 A / C):通过任务上下文/任务查询取得与 `{pr#}` 唯一绑定的 active task。未命中时停止并提示先绑定 PR;typed checks intent 不建立第二套无任务状态机。
46
46
 
@@ -74,7 +74,7 @@ date "+%Y-%m-%d %H:%M:%S%z" | sed 's/\([+-][0-9][0-9]\)\([0-9][0-9]\)$/\1:\2/'
74
74
  - `assigned_to`:{当前代理}
75
75
  - `updated_at`:{当前时间}
76
76
  - `agent_infra_version`:按 `.agents/rules/version-stamp.md` 取值
77
- - **不改** `pr_status`(保持 `created`)与 `current_step`
77
+ - **不改** `pr_delivery_fact` 与 `current_step`
78
78
  - **追加**到 `## 活动日志`(不要覆盖之前的记录;`{N}` = 本任务已有 Watch PR 条目数 + 1):
79
79
  ```
80
80
  - {YYYY-MM-DD HH:mm:ss±HH:MM} — **Watch PR (Round {N})** by {agent} — {成功:PR ready, repair commits: {k} [{sha 摘要}] / 阻塞:blocked: {简述}}
@@ -148,6 +148,6 @@ agent-infra-internal task-verify {task-id} watch-pr.completed --format text
148
148
 
149
149
  ## 错误处理
150
150
 
151
- - 无法定位 PR(任务短号命中但 task.md 无 `pr_number`,且未传 `--pr`、当前分支也无 PR):提示「请先运行 `create-pr`,或用 `--pr <number>` 指定 PR」,停止。
151
+ - 无法定位 PR(任务短号命中但 task.md 无 verified bound `pr_delivery_fact`,且未传 `--pr`、当前分支也无 PR):提示「请先运行 `create-pr`,或用 `--pr <number>` 指定 PR」,停止。
152
152
  - 平台 CLI 未认证或 API 不可用:提示需人工介入,停止。
153
153
  - 短号解析失败:透传 `task-short-id.js` 的退出码与错误信息,不重写。
@@ -13,7 +13,11 @@ start_date: # Optional Issue field for Feature: YYYY-MM-DD
13
13
  target_date: # Optional Issue field for Feature: YYYY-MM-DD
14
14
  current_step: requirement-analysis # requirement-analysis | requirement-analysis-review | technical-design | technical-design-review | code | code-review | completed
15
15
  assigned_to: # claude | codex | antigravity | opencode | human
16
- pr_status: pending # PR status: pending (default) | created (PR created) | skipped (explicitly skipped)
16
+ pr_delivery_fact: '{"version":1,"state":"unbound","reason":"initial"}'
17
+ delivery_remote: origin # Git remote used to deliver the task branch
18
+ delivery_base_ref: main # Target branch for the task PR
19
+ checkpoint_commit: # Most recent local checkpoint commit
20
+ delivery_remote_head: # Most recent successfully delivered task branch SHA
17
21
  ---
18
22
 
19
23
  # Task: [Title]
@@ -80,7 +84,7 @@ pr_status: pending # PR status: pending (default) | created (PR crea
80
84
 
81
85
  ## Human Rulings
82
86
 
83
- <!-- Use ai decide <task-ref> <ordinal|ledger-id> [--needs-implementation true|false] <decision> for needs-human-decision rulings; upstream AI predeclares implementation intent for new code decisions, while the explicit option remains for legacy tasks or consistency checks. -->
87
+ <!-- Use ai decide [--task <ref> | -t <ref>] (--item <ordinal|ledger-id> | -i <ordinal|ledger-id>) [--needs-implementation true|false] <decision> for needs-human-decision rulings; upstream AI predeclares implementation intent for new code decisions, while the explicit option remains for legacy tasks or consistency checks. -->
84
88
 
85
89
  ## Implementation Inputs
86
90
 
@@ -13,7 +13,11 @@ start_date: # Feature 可选 Issue 字段:YYYY-MM-DD
13
13
  target_date: # Feature 可选 Issue 字段:YYYY-MM-DD
14
14
  current_step: requirement-analysis # requirement-analysis | requirement-analysis-review | technical-design | technical-design-review | code | code-review | completed
15
15
  assigned_to: # claude | codex | antigravity | opencode | human
16
- pr_status: pending # PR 状态:pending(默认)| created(已创建 PR)| skipped(显式跳过)
16
+ pr_delivery_fact: '{"version":1,"state":"unbound","reason":"initial"}'
17
+ delivery_remote: origin # 任务分支交付使用的 Git remote
18
+ delivery_base_ref: main # 任务 PR 的目标分支
19
+ checkpoint_commit: # 最近一次本地 checkpoint commit
20
+ delivery_remote_head: # 最近一次成功交付到 remote 的任务分支 SHA
17
21
  ---
18
22
 
19
23
  # 任务:[标题]
@@ -80,7 +84,7 @@ pr_status: pending # PR 状态:pending(默认)| created(已
80
84
 
81
85
  ## 人工裁决
82
86
 
83
- <!-- 使用 ai decide <task-ref> <序号|账本ID> [--needs-implementation true|false] <裁决内容> 写入 needs-human-decision 裁定;新建 code 裁决的实现意图由上游 AI 预先声明,显式参数仅用于历史任务兼容或一致性复核。 -->
87
+ <!-- 使用 ai decide [--task <ref> | -t <ref>] (--item <序号|账本ID> | -i <序号|账本ID>) [--needs-implementation true|false] <裁决内容> 写入 needs-human-decision 裁定;新建 code 裁决的实现意图由上游 AI 预先声明,显式参数仅用于历史任务兼容或一致性复核。 -->
84
88
 
85
89
  ## 实现输入
86
90