@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
@@ -0,0 +1,341 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+
5
+ import { err, info, ok } from './log.ts';
6
+ import { needsShell, resolveCommandFromAbsolutePath } from './run/host.ts';
7
+
8
+ type CommandResult = {
9
+ status: number | null;
10
+ signal?: NodeJS.Signals | null;
11
+ stdout?: string;
12
+ stderr?: string;
13
+ error?: Error;
14
+ };
15
+
16
+ export type SelfUpdateOptions = Readonly<{
17
+ platform?: NodeJS.Platform;
18
+ env?: NodeJS.ProcessEnv;
19
+ argv?: readonly string[];
20
+ run?: (command: readonly string[]) => CommandResult;
21
+ }>;
22
+
23
+ export type UpdateSource = Readonly<{
24
+ kind: 'npm' | 'brew';
25
+ managerPath: string;
26
+ packageRoot: string;
27
+ updateArgs: readonly string[];
28
+ }>;
29
+
30
+ export type UpdateSourceResult = Readonly<{
31
+ source: UpdateSource | null;
32
+ error?: string;
33
+ }>;
34
+
35
+ type PackageInfo = Readonly<{
36
+ root: string;
37
+ name: string;
38
+ }>;
39
+
40
+ function canonicalPath(target: string): string | null {
41
+ try {
42
+ return fs.realpathSync.native(target);
43
+ } catch {
44
+ return null;
45
+ }
46
+ }
47
+
48
+ function comparable(target: string, platform: NodeJS.Platform): string {
49
+ const resolved = path.resolve(target).replaceAll('\\', '/');
50
+ return platform === 'win32' ? resolved.toLowerCase() : resolved;
51
+ }
52
+
53
+ function samePath(left: string, right: string, platform: NodeJS.Platform): boolean {
54
+ return comparable(left, platform) === comparable(right, platform);
55
+ }
56
+
57
+ function isWithin(root: string, target: string, platform: NodeJS.Platform): boolean {
58
+ const normalizedRoot = comparable(root, platform).replace(/\/$/, '');
59
+ const normalizedTarget = comparable(target, platform).replace(/\/$/, '');
60
+ return normalizedTarget === normalizedRoot
61
+ || normalizedTarget.startsWith(`${normalizedRoot}/`);
62
+ }
63
+
64
+ function packageInfoFromRoot(root: string): PackageInfo | null {
65
+ try {
66
+ const packageJson = JSON.parse(
67
+ fs.readFileSync(path.join(root, 'package.json'), 'utf8')
68
+ ) as { name?: unknown };
69
+ return typeof packageJson.name === 'string'
70
+ ? { root, name: packageJson.name }
71
+ : null;
72
+ } catch {
73
+ return null;
74
+ }
75
+ }
76
+
77
+ function findPackageInfo(entry: string, platform: NodeJS.Platform): PackageInfo | null {
78
+ const canonicalEntry = canonicalPath(entry);
79
+ if (!canonicalEntry) return null;
80
+
81
+ let current = path.dirname(canonicalEntry);
82
+ while (true) {
83
+ const canonicalRoot = canonicalPath(current);
84
+ const info = canonicalRoot ? packageInfoFromRoot(canonicalRoot) : null;
85
+ if (info && isWithin(info.root, canonicalEntry, platform)) return info;
86
+ const parent = path.dirname(current);
87
+ if (parent === current) return null;
88
+ current = parent;
89
+ }
90
+ }
91
+
92
+ function packageInfoFromCommand(commandPath: string, platform: NodeJS.Platform): PackageInfo | null {
93
+ const direct = findPackageInfo(commandPath, platform);
94
+ if (direct) return direct;
95
+ if (!/\.(?:cmd|bat)$/i.test(commandPath)) return null;
96
+
97
+ const globalPackageRoot = canonicalPath(path.join(
98
+ path.dirname(commandPath),
99
+ 'node_modules',
100
+ '@fitlab-ai',
101
+ 'agent-infra'
102
+ ));
103
+ return globalPackageRoot ? packageInfoFromRoot(globalPackageRoot) : null;
104
+ }
105
+
106
+ function visibleAliasError(
107
+ packageRoot: string,
108
+ platform: NodeJS.Platform,
109
+ env: NodeJS.ProcessEnv
110
+ ): string | null {
111
+ for (const alias of ['ai', 'agent-infra']) {
112
+ const absolute = resolveCommandFromAbsolutePath(alias, platform, env);
113
+ if (!absolute) continue;
114
+ if (!canonicalPath(absolute)) continue;
115
+ const info = packageInfoFromCommand(absolute, platform);
116
+ if (info && !samePath(info.root, packageRoot, platform)) {
117
+ return `PATH shadowing detected: ${alias} resolves to ${info.root}, not ${packageRoot}.`;
118
+ }
119
+ }
120
+ return null;
121
+ }
122
+
123
+ function resolveManager(
124
+ name: string,
125
+ expectedBasenames: readonly string[],
126
+ platform: NodeJS.Platform,
127
+ env: NodeJS.ProcessEnv
128
+ ): { path: string } | { error: string } | null {
129
+ const absolute = resolveCommandFromAbsolutePath(name, platform, env);
130
+ if (!absolute) {
131
+ return { error: `${name} manager was not found on PATH.` };
132
+ }
133
+ let stat: fs.Stats;
134
+ try {
135
+ stat = fs.statSync(absolute);
136
+ } catch {
137
+ return { error: `Cannot inspect manager executable: ${absolute}.` };
138
+ }
139
+ if (!stat.isFile()) return { error: `Manager executable is not a regular file: ${absolute}.` };
140
+ if (!expectedBasenames.includes(path.basename(absolute).toLowerCase())) {
141
+ return { error: `Unexpected manager executable: ${absolute}.` };
142
+ }
143
+ const canonical = canonicalPath(absolute);
144
+ return canonical ? { path: canonical } : null;
145
+ }
146
+
147
+ function defaultRun(command: readonly string[], platform: NodeJS.Platform): CommandResult {
148
+ const [file, ...args] = command;
149
+ if (!file) return { status: null, error: new Error('run: missing command') };
150
+ const result = spawnSync(file, args, {
151
+ encoding: 'utf8',
152
+ shell: needsShell(file, platform),
153
+ stdio: ['ignore', 'pipe', 'pipe']
154
+ });
155
+ return {
156
+ status: result.status,
157
+ signal: result.signal,
158
+ stdout: result.stdout || '',
159
+ stderr: result.stderr || '',
160
+ error: result.error
161
+ };
162
+ }
163
+
164
+ function runCommand(
165
+ command: readonly string[],
166
+ options: SelfUpdateOptions,
167
+ platform: NodeJS.Platform
168
+ ): CommandResult {
169
+ return options.run ? options.run(command) : defaultRun(command, platform);
170
+ }
171
+
172
+ function probe(
173
+ command: readonly string[],
174
+ options: SelfUpdateOptions,
175
+ platform: NodeJS.Platform,
176
+ label: string
177
+ ): string | { error: string } {
178
+ const result = runCommand(command, options, platform);
179
+ if (result.error) return { error: `${label} failed: ${result.error.message}` };
180
+ if (result.signal) return { error: `${label} terminated by ${result.signal}.` };
181
+ if (result.status !== 0) {
182
+ const detail = result.stderr?.trim();
183
+ return { error: `${label} exited with ${result.status ?? 1}${detail ? `: ${detail}` : '.'}` };
184
+ }
185
+ const output = result.stdout?.trim() || '';
186
+ return output ? output : { error: `${label} returned no path.` };
187
+ }
188
+
189
+ function npmSource(
190
+ packageInfo: PackageInfo,
191
+ options: SelfUpdateOptions,
192
+ platform: NodeJS.Platform,
193
+ env: NodeJS.ProcessEnv
194
+ ): UpdateSource | { error: string } | null {
195
+ const manager = resolveManager(
196
+ 'npm',
197
+ platform === 'win32' ? ['npm.cmd', 'npm.bat'] : ['npm'],
198
+ platform,
199
+ env
200
+ );
201
+ if (!manager) return null;
202
+ if ('error' in manager) return manager;
203
+
204
+ const prefixOutput = probe([manager.path, 'prefix', '--global'], options, platform, 'npm prefix --global');
205
+ if (typeof prefixOutput !== 'string') return prefixOutput;
206
+ const rootOutput = probe([manager.path, 'root', '--global'], options, platform, 'npm root --global');
207
+ if (typeof rootOutput !== 'string') return rootOutput;
208
+ const prefix = canonicalPath(prefixOutput);
209
+ const globalRoot = canonicalPath(rootOutput);
210
+ if (!prefix || !globalRoot) return { error: 'npm global prefix or root is not an existing directory.' };
211
+ if (!isWithin(prefix, globalRoot, platform)) {
212
+ return { error: `npm global root ${globalRoot} is outside prefix ${prefix}.` };
213
+ }
214
+ const expectedPackageRoot = canonicalPath(path.join(globalRoot, '@fitlab-ai', 'agent-infra'));
215
+ if (!expectedPackageRoot || !samePath(expectedPackageRoot, packageInfo.root, platform)) {
216
+ return { error: `Current CLI package is not owned by npm global root ${globalRoot}.` };
217
+ }
218
+ if (packageInfo.name !== '@fitlab-ai/agent-infra') {
219
+ return { error: `Unexpected package name at ${packageInfo.root}: ${packageInfo.name}.` };
220
+ }
221
+ if (platform !== 'win32' && !isWithin(prefix, manager.path, platform)) {
222
+ return { error: `npm manager ${manager.path} is outside global prefix ${prefix}.` };
223
+ }
224
+ return {
225
+ kind: 'npm',
226
+ managerPath: manager.path,
227
+ packageRoot: packageInfo.root,
228
+ updateArgs: ['update', '--global', '@fitlab-ai/agent-infra']
229
+ };
230
+ }
231
+
232
+ function brewSource(
233
+ packageInfo: PackageInfo,
234
+ options: SelfUpdateOptions,
235
+ platform: NodeJS.Platform,
236
+ env: NodeJS.ProcessEnv
237
+ ): UpdateSource | { error: string } | null {
238
+ const manager = resolveManager('brew', ['brew', 'brew.exe', 'brew.cmd'], platform, env);
239
+ if (!manager) return null;
240
+ if ('error' in manager) return manager;
241
+
242
+ const homebrewOutput = probe([manager.path, '--prefix'], options, platform, 'brew --prefix');
243
+ if (typeof homebrewOutput !== 'string') return homebrewOutput;
244
+ const formulaOutput = probe([manager.path, '--prefix', 'agent-infra'], options, platform, 'brew --prefix agent-infra');
245
+ if (typeof formulaOutput !== 'string') return formulaOutput;
246
+ const homebrewRoot = canonicalPath(homebrewOutput);
247
+ const formulaRoot = canonicalPath(formulaOutput);
248
+ if (!homebrewRoot || !formulaRoot) return { error: 'Homebrew prefix is not an existing directory.' };
249
+ if (!isWithin(homebrewRoot, manager.path, platform)) {
250
+ return { error: `brew manager ${manager.path} is outside Homebrew prefix ${homebrewRoot}.` };
251
+ }
252
+ if (!isWithin(homebrewRoot, formulaRoot, platform)) {
253
+ return { error: `agent-infra formula prefix ${formulaRoot} is outside Homebrew prefix ${homebrewRoot}.` };
254
+ }
255
+ if (!isWithin(formulaRoot, packageInfo.root, platform)) {
256
+ return { error: `Current CLI package is outside agent-infra formula prefix ${formulaRoot}.` };
257
+ }
258
+ if (packageInfo.name !== '@fitlab-ai/agent-infra') {
259
+ return { error: `Unexpected package name at ${packageInfo.root}: ${packageInfo.name}.` };
260
+ }
261
+ return {
262
+ kind: 'brew',
263
+ managerPath: manager.path,
264
+ packageRoot: packageInfo.root,
265
+ updateArgs: ['upgrade', 'agent-infra']
266
+ };
267
+ }
268
+
269
+ export function detectUpdateSource(options: SelfUpdateOptions = {}): UpdateSourceResult {
270
+ const platform = options.platform ?? process.platform;
271
+ const env = options.env ?? process.env;
272
+ const entry = options.argv?.[1] ?? process.argv[1];
273
+ if (!entry) return { source: null, error: 'Cannot determine the running CLI entry.' };
274
+ const packageInfo = findPackageInfo(entry, platform);
275
+ if (!packageInfo || packageInfo.name !== '@fitlab-ai/agent-infra') {
276
+ return { source: null, error: 'Running CLI is not a persistent @fitlab-ai/agent-infra package installation.' };
277
+ }
278
+ const aliasError = visibleAliasError(packageInfo.root, platform, env);
279
+ if (aliasError) return { source: null, error: aliasError };
280
+
281
+ const candidates: UpdateSource[] = [];
282
+ const errors: string[] = [];
283
+ for (const candidate of [
284
+ npmSource(packageInfo, options, platform, env),
285
+ brewSource(packageInfo, options, platform, env)
286
+ ]) {
287
+ if (!candidate) continue;
288
+ if ('error' in candidate) errors.push(candidate.error);
289
+ else candidates.push(candidate);
290
+ }
291
+ if (candidates.length === 1) {
292
+ const [source] = candidates;
293
+ if (source) return { source };
294
+ }
295
+ if (candidates.length > 1) return { source: null, error: 'Multiple package managers claim the running CLI; refusing to choose.' };
296
+ return {
297
+ source: null,
298
+ error: errors.length > 0
299
+ ? errors.join(' ')
300
+ : 'No supported persistent npm or Homebrew installation owns the running CLI.'
301
+ };
302
+ }
303
+
304
+ function managerStable(source: UpdateSource, platform: NodeJS.Platform): boolean {
305
+ const current = canonicalPath(source.managerPath);
306
+ return current !== null && samePath(current, source.managerPath, platform);
307
+ }
308
+
309
+ export async function cmdUpdate(options: SelfUpdateOptions = {}): Promise<number> {
310
+ const platform = options.platform ?? process.platform;
311
+ const detected = detectUpdateSource(options);
312
+ if (!detected.source) {
313
+ err(`Cannot update agent-infra CLI: ${detected.error ?? 'unknown source'}`);
314
+ err('Install persistently with "npm install -g @fitlab-ai/agent-infra" or "brew install fitlab-ai/tap/agent-infra".');
315
+ return 1;
316
+ }
317
+
318
+ const source = detected.source;
319
+ if (!managerStable(source, platform)) {
320
+ err(`Cannot update agent-infra CLI: manager path changed: ${source.managerPath}.`);
321
+ return 1;
322
+ }
323
+ info(`Updating agent-infra CLI via ${source.kind}.`);
324
+ const result = runCommand([source.managerPath, ...source.updateArgs], options, platform);
325
+ if (result.error) {
326
+ err(`agent-infra CLI update failed: ${result.error.message}`);
327
+ return 1;
328
+ }
329
+ if (result.signal) {
330
+ err(`agent-infra CLI update terminated by ${result.signal}.`);
331
+ return 1;
332
+ }
333
+ if (result.status !== 0) {
334
+ err(`agent-infra CLI update failed with exit code ${result.status ?? 1}.`);
335
+ const detail = result.stderr?.trim();
336
+ if (detail) err(detail);
337
+ return result.status && result.status > 0 ? result.status : 1;
338
+ }
339
+ ok('agent-infra CLI updated successfully!');
340
+ return 0;
341
+ }
@@ -85,8 +85,8 @@ export function isProcessAlive(pid: number, platform: NodeJS.Platform = process.
85
85
  }
86
86
  }
87
87
 
88
- function parseDarwinStartTime(output: string): number | null {
89
- const match = output.trim().match(/^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat) ([A-Z][a-z]{2}) (\d{1,2}) (\d{2}):(\d{2}):(\d{2}) (\d{4})$/);
88
+ export function parseDarwinStartTime(output: string): number | null {
89
+ const match = output.trim().match(/^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat) ([A-Z][a-z]{2})\s+(\d{1,2}) (\d{2}):(\d{2}):(\d{2}) (\d{4})$/);
90
90
  if (!match) return null;
91
91
  const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
92
92
  const month = months.indexOf(match[1]!);
@@ -31,16 +31,16 @@ export function commandHelp(): string {
31
31
  '/sandbox ls',
32
32
  '/sandbox show {ref}',
33
33
  '/sandbox vm status',
34
- '/task decisions [--task {ref}] [--item {selector}]',
35
- '/task log [--task {ref}]',
34
+ '/task decisions [--task {ref} | -t {ref}] [--item {selector} | -i {selector}]',
35
+ '/task log [--task {ref} | -t {ref}]',
36
36
  '/task ls',
37
- '/task show [--task {ref}]',
38
- '/task status [--task {ref}]',
37
+ '/task show [--task {ref} | -t {ref}]',
38
+ '/task status [--task {ref} | -t {ref}]',
39
39
  'Write:',
40
40
  '/sandbox create {ref}',
41
41
  '/sandbox start {ref}',
42
42
  'Exec:',
43
- '/decide [--task {ref}] --item {ordinal|ledger-id} [--needs-implementation true|false] {decision}',
43
+ '/decide [--task {ref} | -t {ref}] (--item {ordinal|ledger-id} | -i {ordinal|ledger-id}) [--needs-implementation true|false] {decision}',
44
44
  '/run create-task {description}',
45
45
  '/run {skill} {task-ref}'
46
46
  ].join('\n');
@@ -89,6 +89,10 @@ function pairEntries(entries: LogEntry[]): StepRow[] {
89
89
  return rows;
90
90
  }
91
91
 
92
+ function startedBackedRows(rows: StepRow[]): StepRow[] {
93
+ return rows.filter((row) => row.started !== '');
94
+ }
95
+
92
96
  export {
93
97
  activityAttempt,
94
98
  appendActivityEntry,
@@ -96,6 +100,7 @@ export {
96
100
  locateActivityLog,
97
101
  pairEntries,
98
102
  parseActivityLog,
99
- parseCommitAttemptStarted
103
+ parseCommitAttemptStarted,
104
+ startedBackedRows
100
105
  };
101
106
  export type { ActivityLogSection, CommitAttempt, LogEntry, StepRow };
@@ -46,7 +46,8 @@ type ArtifactErrorCode =
46
46
  | 'ARTIFACT_TOPOLOGY_CONFLICT' | 'ARTIFACT_INPUT_MISSING'
47
47
  | 'ARTIFACT_REFERENCE_INVALID' | 'ARTIFACT_PATH_INVALID'
48
48
  | 'ARTIFACT_IDENTITY_INVALID' | 'ARTIFACT_NOT_FOUND'
49
- | 'ARTIFACT_NOT_REGULAR' | 'ARTIFACT_NOT_READABLE' | 'ARTIFACT_MODE_REFUSED';
49
+ | 'ARTIFACT_NOT_REGULAR' | 'ARTIFACT_NOT_READABLE' | 'ARTIFACT_VERDICT_INVALID'
50
+ | 'ARTIFACT_MODE_REFUSED';
50
51
  type ArtifactError = { code: ArtifactErrorCode; message: string };
51
52
  type ArtifactInventoryResult = {
52
53
  status: 'ready' | 'failed';
@@ -357,7 +358,7 @@ function resolveCodeContext(inventory: ArtifactInventoryResult, options: Inspect
357
358
  return contextFailure(inventory, 'ARTIFACT_INPUT_MISSING', `latest plan '${plan.latest.name}' requires a matching approved review-plan`);
358
359
  }
359
360
  const verdict = parseVerdict(reviewPlan.latest.path);
360
- if (!verdict.ok) return contextFailure(inventory, 'ARTIFACT_REFERENCE_INVALID', verdict.message, reviewPlan.latest.name);
361
+ if (!verdict.ok) return contextFailure(inventory, 'ARTIFACT_VERDICT_INVALID', `${verdict.code}: ${verdict.message}`, reviewPlan.latest.name);
361
362
  if (verdict.verdict !== 'Approved') {
362
363
  return contextFailure(inventory, 'ARTIFACT_REFERENCE_INVALID', `latest ${reviewPlan.latest.name} is not approved`, reviewPlan.latest.name);
363
364
  }
@@ -373,6 +374,7 @@ function resolveCodeContext(inventory: ArtifactInventoryResult, options: Inspect
373
374
  }
374
375
  if (reviewPlan.latest && reviewPlan.reviewedInput?.name === plan.latest.name) {
375
376
  const verdict = parseVerdict(reviewPlan.latest.path);
377
+ if (!verdict.ok) return contextFailure(inventory, 'ARTIFACT_VERDICT_INVALID', `${verdict.code}: ${verdict.message}`, reviewPlan.latest.name);
376
378
  const reviewedPlanSha256 = sha256File(reviewPlan.reviewedInput.path);
377
379
  if (verdict.ok && verdict.verdict === 'Approved' && (
378
380
  codePlanInput.input.name !== plan.latest.name || codePlanInput.inputSha256 !== reviewedPlanSha256
@@ -388,7 +390,7 @@ function resolveCodeContext(inventory: ArtifactInventoryResult, options: Inspect
388
390
  const review = reviewCode.latest;
389
391
  if (!review) return contextFailure(inventory, 'ARTIFACT_INPUT_MISSING', 'latest review-code artifact is required');
390
392
  const verdict = parseVerdict(review.path);
391
- if (!verdict.ok) return contextFailure(inventory, 'ARTIFACT_REFERENCE_INVALID', verdict.message);
393
+ if (!verdict.ok) return contextFailure(inventory, 'ARTIFACT_VERDICT_INVALID', `${verdict.code}: ${verdict.message}`, review.name);
392
394
  if (verdict.verdict === 'Approved') {
393
395
  const decision = resolveDecisionImplementationInput(inventory, review);
394
396
  if ('error' in decision) return contextFailure(inventory, 'ARTIFACT_REFERENCE_INVALID', decision.error, review.name);
@@ -480,9 +482,9 @@ function buildArtifactLinkSection(content: string, artifact: ArtifactIdentity):
480
482
  const label = english
481
483
  ? `${spec.labels[1]} (Round ${artifact.round})`
482
484
  : `${spec.labels[0]}(Round ${artifact.round})`;
483
- const link = `[${label}](${artifact.name})`;
485
+ const link = `${label}:\`${artifact.name}\``;
484
486
  let body = extractSection(content, aliases);
485
- if (body.includes(`](${artifact.name})`)) return { aliases, heading, body };
487
+ if (body.includes(link)) return { aliases, heading, body };
486
488
  const placeholders = new Set([
487
489
  '[分析阶段的发现。哪些文件受影响?范围是什么?]',
488
490
  '[Findings from the analysis phase. Which files are affected? What is the scope?]',
@@ -45,6 +45,7 @@ type CodexBridgeOptions = Readonly<{
45
45
  capabilityStore?: CapabilityStore;
46
46
  buildIdentity?: LifecycleBuildIdentity;
47
47
  orchestrationOptions?: OrchestrationOptions;
48
+ controllerBinding?: Readonly<{ instanceDigest: string; controlGeneration: string }>;
48
49
  }>;
49
50
 
50
51
  type CodexSpawnIdentity = Readonly<{
@@ -142,7 +143,7 @@ async function prepareCodexOrchestrationDelegation(
142
143
  );
143
144
  }
144
145
  const buildIdentity = options.buildIdentity ?? computeLifecycleBuildIdentity(repoRoot);
145
- const brokerController = brokerControllerBinding();
146
+ const brokerController = options.controllerBinding ?? brokerControllerBinding();
146
147
  const contextPath = process.env.AGENT_INFRA_CODEX_CONTROLLER_CONTEXT;
147
148
  const contextVerification = contextPath
148
149
  ? (brokerController
@@ -15,8 +15,7 @@ function parseTaskScope(args: string[]): TaskScope {
15
15
  value = args[++index];
16
16
  if (value === undefined || value === '' || value.startsWith('-')) throw new Error(`${arg} requires a value`);
17
17
  } else if (arg.startsWith('--task=')) {
18
- value = arg.slice('--task='.length);
19
- if (value === '') throw new Error('--task requires a value');
18
+ throw new Error("--task=... is not supported; use --task <ref> or -t <ref>");
20
19
  } else {
21
20
  positionals.push(arg);
22
21
  continue;
@@ -5,11 +5,9 @@ import { resolveArtifact } from '../artifacts.ts';
5
5
 
6
6
  const USAGE = `Usage: ai task cat <artifact | N>
7
7
  ai task cat (--task <ref> | -t <ref>) <artifact | N>
8
- ai task cat <ref> <artifact | N>
9
8
 
10
9
  Prints a task artifact's raw content to stdout.
11
10
  One positional Uses current task context and treats the operand as the artifact.
12
- <ref> Bare numeric short id, or a full TASK-YYYYMMDD-HHMMSS id.
13
11
  <artifact | N> Artifact filename (with or without '.md'), or the number from 'ai task files'.
14
12
  `;
15
13
 
@@ -29,8 +27,6 @@ function cat(args: string[] = []): void {
29
27
  taskRef = scope.taskRef; artifact = scope.positionals[0];
30
28
  } else if (scope.positionals.length === 1) {
31
29
  artifact = scope.positionals[0];
32
- } else if (scope.positionals.length === 2) {
33
- [taskRef, artifact] = scope.positionals;
34
30
  } else { process.stdout.write(USAGE); process.exitCode = 1; return; }
35
31
  const resolved = resolveTaskContext(taskRef);
36
32
  if (!resolved.ok) {