@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
package/README.md CHANGED
@@ -71,11 +71,11 @@ Just fix it at the application layer in LoginService.
71
71
  > AI re-runs `/plan-task` to update the plan accordingly and confirms.
72
72
 
73
73
  ```bash
74
- /code-task <task-id> # AI writes the fix, adds a test for user+tag@example.com — green
74
+ /code-task <task-id> # AI writes the fix, tests it, and creates a local checkpoint commit
75
75
  /review-code <task-id> # A fresh isolated reviewer reports one minor finding
76
- /code-task <task-id> # AI fixes the minor issue and re-validates
77
- /commit
78
- /create-pr <task-id> # PR opened, auto-linked to issue #42
76
+ /code-task <task-id> # AI fixes the minor issue, re-validates, and creates a new checkpoint
77
+ /review-code <task-id> # The reviewer approves the current checkpoint
78
+ /create-pr <task-id> # The reviewed branch is published to its task-bound target; PR links issue #42
79
79
  /complete-task <task-id> # task archived
80
80
  ```
81
81
 
@@ -121,6 +121,15 @@ brew install fitlab-ai/tap/agent-infra
121
121
 
122
122
  ### Updating agent-infra
123
123
 
124
+ ```bash
125
+ ai update
126
+ ```
127
+
128
+ `ai update` updates the installed agent-infra CLI. In an initialized project,
129
+ use `ai sync` to refresh project seed files and the file registry.
130
+
131
+ The equivalent package-manager commands remain:
132
+
124
133
  ```bash
125
134
  npm update -g @fitlab-ai/agent-infra
126
135
  # or, if installed via Homebrew:
@@ -142,7 +151,7 @@ ai init
142
151
  # or: agent-infra init
143
152
  ```
144
153
 
145
- The CLI collects project metadata, lets you select the enabled Agent Clients, installs their `update-agent-infra` seed commands, and generates `.agents/.airc.json`.
154
+ The CLI collects project metadata, lets you select the enabled Agent Clients, installs any client-specific `update-agent-infra` seed commands, and generates `.agents/.airc.json`.
146
155
 
147
156
  > `ai` is a shorthand for `agent-infra`. Both commands are equivalent.
148
157
 
@@ -156,12 +165,13 @@ Open the project in any AI TUI and run `update-agent-infra`:
156
165
  | Codex | `$update-agent-infra` |
157
166
  | Antigravity CLI | `/update-agent-infra` |
158
167
  | OpenCode | `/update-agent-infra` |
168
+ | TraeCode CLI | `/update-agent-infra` |
159
169
 
160
170
  This detects the packaged template version and renders all managed files. The same command is used both for first-time setup and for future template upgrades.
161
171
 
162
172
  ## Core Commands
163
173
 
164
- Manage the four built-in Agent Clients independently from the project lifecycle:
174
+ Manage the five built-in Agent Clients independently from the project lifecycle:
165
175
 
166
176
  ```bash
167
177
  ai agent-client list
@@ -171,7 +181,7 @@ ai agent-client disable antigravity-cli
171
181
  ai agent-client configure
172
182
  ```
173
183
 
174
- The most-used lifecycle commands, in delivery order. The command prefix varies by TUI (`/skill` in Claude Code/Antigravity/OpenCode and `$skill` in Codex); the workflow semantics stay the same.
184
+ The most-used lifecycle commands, in delivery order. The command prefix varies by TUI (`/skill` in Claude Code/Antigravity/OpenCode/TraeCode and `$skill` in Codex); the workflow semantics stay the same.
175
185
 
176
186
  | Command | Purpose |
177
187
  |---------|---------|
@@ -179,8 +189,8 @@ The most-used lifecycle commands, in delivery order. The command prefix varies b
179
189
  | `run-task` | Resume the lifecycle with fresh isolated executors/reviewers when the selected client exposes verified actual model/effort evidence; Codex now has an experimental Hooks + App Server evidence channel, but orchestration remains disabled until that channel is connected to delegation receipts |
180
190
  | `analyze-task` → `review-analysis` | Capture scope and risks, then review the analysis |
181
191
  | `plan-task` → `review-plan` | Design the approach, then review the plan |
182
- | `code-task` → `review-code` | Implement and test, then run a structured code review |
183
- | `commit` → `create-pr` → `complete-task` | Commit, open a PR, and archive the task |
192
+ | `code-task` → `review-code` | Implement and test; `code-task` creates a local checkpoint, then a structured review checks that checkpoint |
193
+ | `create-pr` → `complete-task` | Publish the approved checkpoint to the task-bound target branch, then archive after merge and final gates |
184
194
 
185
195
  Start with one atomic role policy, for example: `$run-task 42 --executor-model <id> --executor-reasoning-effort <value> --reviewer-model <id> --reviewer-reasoning-effort <value>`. Both roles may use the same model. With no explicit policy, `run-task` reads the current Agent Client's optional `agentClients[].orchestration`; if neither source is complete, it shows the host model-selection guidance before creating any run. Re-entry uses the persisted run policy. Finish or clear active runs before upgrading agent-infra; unsupported disk state fails closed without rewriting.
186
196
 
package/README.zh-CN.md CHANGED
@@ -70,11 +70,11 @@ agent-infra 的目标就是把这层共享基础设施标准化。它为所有
70
70
  > AI 按你的要求重跑 `/plan-task` 更新方案并确认。
71
71
 
72
72
  ```bash
73
- /code-task <task-id> # AI 编写修复代码,添加 user+tag@example.com 测试 —— 通过
73
+ /code-task <task-id> # AI 编写修复代码、测试,并创建本地 checkpoint commit
74
74
  /review-code <task-id> # fresh 隔离 reviewer 报告一个次要问题
75
- /code-task <task-id> # AI 修复次要问题并重新验证
76
- /commit
77
- /create-pr <task-id> # PR 已创建,自动关联 Issue #42
75
+ /code-task <task-id> # AI 修复次要问题、重新验证,并创建新的 checkpoint
76
+ /review-code <task-id> # reviewer 审查并通过当前 checkpoint
77
+ /create-pr <task-id> # 将已审查分支发布到任务绑定目标分支;PR 自动关联 Issue #42
78
78
  /complete-task <task-id> # 任务归档
79
79
  ```
80
80
 
@@ -120,6 +120,15 @@ brew install fitlab-ai/tap/agent-infra
120
120
 
121
121
  ### 更新 agent-infra
122
122
 
123
+ ```bash
124
+ ai update
125
+ ```
126
+
127
+ `ai update` 用于更新已安装的 agent-infra CLI。在已初始化项目中,使用
128
+ `ai sync` 刷新项目 seed files 和文件注册表。
129
+
130
+ 对应的包管理器命令仍然是:
131
+
123
132
  ```bash
124
133
  npm update -g @fitlab-ai/agent-infra
125
134
  # 或者通过 Homebrew 安装时:
@@ -141,7 +150,7 @@ ai init
141
150
  # 或:agent-infra init
142
151
  ```
143
152
 
144
- CLI 会收集项目元数据,让你选择启用的 Agent Client,为其安装 `update-agent-infra` 种子命令,并生成 `.agents/.airc.json`。
153
+ CLI 会收集项目元数据,让你选择启用的 Agent Client,安装该客户端需要的 `update-agent-infra` 种子命令,并生成 `.agents/.airc.json`。
145
154
 
146
155
  > `ai` 是 `agent-infra` 的简写命令,两者等价。
147
156
 
@@ -155,12 +164,13 @@ CLI 会收集项目元数据,让你选择启用的 Agent Client,为其安装
155
164
  | Codex | `$update-agent-infra` |
156
165
  | Antigravity CLI | `/update-agent-infra` |
157
166
  | OpenCode | `/update-agent-infra` |
167
+ | TraeCode CLI | `/update-agent-infra` |
158
168
 
159
169
  该命令会检测当前打包模板版本并渲染所有受管理文件。首次安装和后续升级都使用同一条命令。
160
170
 
161
171
  ## 核心命令
162
172
 
163
- 以下命令用于独立管理四个内建 Agent Client:
173
+ 以下命令用于独立管理五个内建 Agent Client:
164
174
 
165
175
  ```bash
166
176
  ai agent-client list
@@ -170,7 +180,7 @@ ai agent-client disable antigravity-cli
170
180
  ai agent-client configure
171
181
  ```
172
182
 
173
- 最常用的生命周期命令,按交付顺序排列。命令前缀因 TUI 而异(Claude Code/Antigravity/OpenCode 用 `/skill`,Codex 用 `$skill`),工作流语义保持一致。
183
+ 最常用的生命周期命令,按交付顺序排列。命令前缀因 TUI 而异(Claude Code/Antigravity/OpenCode/TraeCode 用 `/skill`,Codex 用 `$skill`),工作流语义保持一致。
174
184
 
175
185
  | 命令 | 用途 |
176
186
  |------|------|
@@ -178,8 +188,8 @@ ai agent-client configure
178
188
  | `run-task` | 当所选客户端能提供已验证的 actual model/effort 证据时,用 fresh 隔离 executor/reviewer 续跑生命周期;Codex 现已具备实验性的 Hooks + App Server 证据通道,但在该通道接入 delegation receipt 前仍不会启用 orchestration |
179
189
  | `analyze-task` → `review-analysis` | 明确范围与风险,再审查分析 |
180
190
  | `plan-task` → `review-plan` | 设计实现路径,再审查方案 |
181
- | `code-task` → `review-code` | 实现并测试,再执行结构化代码审查 |
182
- | `commit` → `create-pr` → `complete-task` | 提交、创建 PR、归档任务 |
191
+ | `code-task` → `review-code` | 实现并测试;`code-task` 创建本地 checkpoint,再由结构化审查检视该 checkpoint |
192
+ | `create-pr` → `complete-task` | 将已通过审查的 checkpoint 发布到任务绑定目标分支,并在合并和最终门禁通过后归档 |
183
193
 
184
194
  启动时可提供原子角色策略,例如:`$run-task 42 --executor-model <id> --executor-reasoning-effort <值> --reviewer-model <id> --reviewer-reasoning-effort <值>`。两个角色可以使用同一模型。完全没有显式策略时,`run-task` 读取当前 Agent Client 可选的 `agentClients[].orchestration`;两个来源都不完整时,会在创建任何 run 前展示宿主模型选择指引。重入使用已持久化的 run 策略。升级 agent-infra 前必须完成或清空 active run;不受支持的磁盘状态会失败关闭且不改写。
185
195
 
package/bin/cli.ts CHANGED
@@ -21,12 +21,13 @@ Commands:
21
21
  decide Record a ruling; code-stage decisions require explicit implementation intent
22
22
  help Show this help message
23
23
  init Initialize a new project with update-agent-infra seed command
24
- merge Merge tasks from another workspace directory (active/blocked/completed/archive)
24
+ merge Merge tasks from another current workspace directory (active/blocked/completed/archive)
25
25
  run Schedule a lifecycle skill in the task sandbox tmux session
26
26
  sandbox, s Manage Docker-based AI sandboxes
27
27
  server Run the local AI collaboration daemon (start/stop/status/logs)
28
28
  task, t Read-only views of .agents/workspace tasks
29
- update Update seed files and sync file registry for an existing project
29
+ sync Update seed files and sync file registry for an existing project
30
+ update Update the agent-infra CLI itself
30
31
  version Show version
31
32
 
32
33
  'ai' and 'agent-infra' are interchangeable; 'ai' is the shorter form.
@@ -171,10 +172,22 @@ switch (command) {
171
172
  break;
172
173
  }
173
174
  case 'update': {
174
- const imported = await importCommand('../lib/update.ts');
175
+ const imported = await importCommand('../lib/self-update.ts');
175
176
  if (!imported) break;
176
177
  const { cmdUpdate } = imported;
177
- await cmdUpdate().catch((e: unknown) => {
178
+ const code = await cmdUpdate().catch((e: unknown) => {
179
+ process.stderr.write(`Error: ${errorMessage(e)}\n`);
180
+ process.exitCode = 1;
181
+ return 1;
182
+ });
183
+ if (code !== 0) process.exitCode = code;
184
+ break;
185
+ }
186
+ case 'sync': {
187
+ const imported = await importCommand('../lib/update.ts');
188
+ if (!imported) break;
189
+ const { cmdSync } = imported;
190
+ await cmdSync().catch((e: unknown) => {
178
191
  process.stderr.write(`Error: ${errorMessage(e)}\n`);
179
192
  process.exitCode = 1;
180
193
  });
package/dist/bin/cli.js CHANGED
@@ -25,12 +25,13 @@ Commands:
25
25
  decide Record a ruling; code-stage decisions require explicit implementation intent
26
26
  help Show this help message
27
27
  init Initialize a new project with update-agent-infra seed command
28
- merge Merge tasks from another workspace directory (active/blocked/completed/archive)
28
+ merge Merge tasks from another current workspace directory (active/blocked/completed/archive)
29
29
  run Schedule a lifecycle skill in the task sandbox tmux session
30
30
  sandbox, s Manage Docker-based AI sandboxes
31
31
  server Run the local AI collaboration daemon (start/stop/status/logs)
32
32
  task, t Read-only views of .agents/workspace tasks
33
- update Update seed files and sync file registry for an existing project
33
+ sync Update seed files and sync file registry for an existing project
34
+ update Update the agent-infra CLI itself
34
35
  version Show version
35
36
 
36
37
  'ai' and 'agent-infra' are interchangeable; 'ai' is the shorter form.
@@ -182,11 +183,25 @@ switch (command) {
182
183
  break;
183
184
  }
184
185
  case 'update': {
185
- const imported = await importCommand('../lib/update.ts');
186
+ const imported = await importCommand('../lib/self-update.ts');
186
187
  if (!imported)
187
188
  break;
188
189
  const { cmdUpdate } = imported;
189
- await cmdUpdate().catch((e) => {
190
+ const code = await cmdUpdate().catch((e) => {
191
+ process.stderr.write(`Error: ${errorMessage(e)}\n`);
192
+ process.exitCode = 1;
193
+ return 1;
194
+ });
195
+ if (code !== 0)
196
+ process.exitCode = code;
197
+ break;
198
+ }
199
+ case 'sync': {
200
+ const imported = await importCommand('../lib/update.ts');
201
+ if (!imported)
202
+ break;
203
+ const { cmdSync } = imported;
204
+ await cmdSync().catch((e) => {
190
205
  process.stderr.write(`Error: ${errorMessage(e)}\n`);
191
206
  process.exitCode = 1;
192
207
  });
@@ -5,10 +5,56 @@ if (major < 22 || (major === 22 && minor < 9)) {
5
5
  process.exit(1);
6
6
  }
7
7
  const command = process.argv[2] || '';
8
- if (process.env.AGENT_INFRA_CONTROL_TOKEN
9
- && (command === 'task-lifecycle' || command === 'task-orchestration' || command === 'task-finalization')) {
10
- const { sandboxControl } = await import('../lib/internal/sandbox-control.js');
11
- await sandboxControl(['client', command, ...process.argv.slice(3)]);
8
+ const taskControlCommand = command === 'task-lifecycle' || command === 'task-orchestration' || command === 'task-finalization';
9
+ function taskControlTransportFailure(message) {
10
+ process.stdout.write(`${JSON.stringify({
11
+ status: 'failed', changed: false,
12
+ error: { code: 'TASK_CONTROL_TRANSPORT_INVALID', message }
13
+ })}\n`);
14
+ process.exit(1);
15
+ }
16
+ if (taskControlCommand) {
17
+ const env = process.env;
18
+ const executorMarked = Boolean(env.AGENT_INFRA_EXECUTOR_MANIFEST);
19
+ const controlKeys = [
20
+ 'AGENT_INFRA_CONTROL_TOKEN', 'AGENT_INFRA_CONTROL_GENERATION',
21
+ 'AGENT_INFRA_CONTROL_DIR', 'AGENT_INFRA_CONTROL_STATUS_DIR'
22
+ ];
23
+ const hasControlMarker = controlKeys.some((key) => Boolean(env[key]))
24
+ || Boolean(env.AGENT_INFRA_CONTROL_CONTROLLER_BINDING);
25
+ const taskBindingMarker = hasControlMarker && Boolean(env.AGENT_INFRA_TASK_ID);
26
+ const hasCompleteClientConfig = controlKeys.every((key) => Boolean(env[key]))
27
+ && !env.AGENT_INFRA_CONTROL_CONTROLLER_BINDING
28
+ && (!taskBindingMarker || Boolean(env.AGENT_INFRA_RUNTIME_DIR));
29
+ if (executorMarked) {
30
+ taskControlTransportFailure('executor context is only valid for sandbox-control execute');
31
+ }
32
+ if ((hasControlMarker || taskBindingMarker) && !hasCompleteClientConfig) {
33
+ taskControlTransportFailure('sandbox client control configuration is incomplete or conflicting');
34
+ }
35
+ if (hasCompleteClientConfig) {
36
+ const { sandboxControl } = await import('../lib/internal/sandbox-control.js');
37
+ await sandboxControl(['client', command, ...process.argv.slice(3)]);
38
+ }
39
+ else {
40
+ switch (command) {
41
+ case 'task-orchestration': {
42
+ const { taskOrchestration } = await import('../lib/internal/task-orchestration.js');
43
+ await taskOrchestration(process.argv.slice(3));
44
+ break;
45
+ }
46
+ case 'task-lifecycle': {
47
+ const { taskLifecycle } = await import('../lib/internal/task-lifecycle.js');
48
+ taskLifecycle(process.argv.slice(3));
49
+ break;
50
+ }
51
+ case 'task-finalization': {
52
+ const { taskFinalization } = await import('../lib/internal/task-finalization.js');
53
+ taskFinalization(process.argv.slice(3));
54
+ break;
55
+ }
56
+ }
57
+ }
12
58
  }
13
59
  else
14
60
  switch (command) {
@@ -42,6 +88,11 @@ else
42
88
  gitWorkflow(process.argv.slice(3));
43
89
  break;
44
90
  }
91
+ case 'task-delivery': {
92
+ const { taskDelivery } = await import('../lib/internal/task-delivery.js');
93
+ taskDelivery(process.argv.slice(3));
94
+ break;
95
+ }
45
96
  case 'release-workflow': {
46
97
  const { releaseWorkflow } = await import('../lib/internal/release-workflow.js');
47
98
  await releaseWorkflow(process.argv.slice(3));
@@ -96,7 +96,6 @@ async function cmdAgentClient(args) {
96
96
  throw new AgentClientCommandError('AGENT_CLIENT_ARGUMENT_INVALID', 'status accepts no arguments');
97
97
  }
98
98
  const plan = workflowPlan(projectRoot, config, { type: 'none' });
99
- process.stdout.write(`source: ${plan.source}\n`);
100
99
  printState(plan.desired);
101
100
  for (const seed of plan.seedOperations) {
102
101
  process.stdout.write(` seed ${seed.target}: ${seed.kind}\n`);
@@ -16,20 +16,63 @@ function isLifecycleProtocolVersion(value) {
16
16
  function normalizeRelativePath(value) {
17
17
  return value.replaceAll('\\', '/');
18
18
  }
19
+ function isSafeLifecyclePath(value) {
20
+ return exactText(value)
21
+ && value === normalizeRelativePath(value)
22
+ && !path.isAbsolute(value)
23
+ && !/^[A-Za-z]:[\\/]/u.test(value)
24
+ && !value.split('/').includes('..');
25
+ }
26
+ function isLifecycleLauncherLine(value) {
27
+ return typeof value === 'string'
28
+ && value.length > 1
29
+ && value.slice(0, -1).trim() === value.slice(0, -1)
30
+ && value.startsWith('#!')
31
+ && value.endsWith('\n')
32
+ && value.indexOf('\n') === value.length - 1
33
+ && !value.includes('\r');
34
+ }
35
+ function readLifecycleLauncherShebang(value, executableFiles) {
36
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
37
+ throw new Error('Lifecycle manifest launcher shebang policy is invalid');
38
+ }
39
+ const policy = value;
40
+ if (!isSafeLifecyclePath(policy.sourceFile)
41
+ || !isSafeLifecyclePath(policy.compiledFile)
42
+ || !isLifecycleLauncherLine(policy.canonicalLine)
43
+ || !Array.isArray(policy.acceptedLines)
44
+ || !policy.acceptedLines.every(isLifecycleLauncherLine)
45
+ || new Set(policy.acceptedLines).size !== policy.acceptedLines.length
46
+ || !policy.acceptedLines.includes(policy.canonicalLine)
47
+ || !executableFiles.includes(policy.sourceFile)
48
+ || policy.compiledFile !== normalizeRelativePath(path.join('dist', policy.sourceFile.endsWith('.ts')
49
+ ? policy.sourceFile.replace(/\.ts$/u, '.js')
50
+ : policy.sourceFile))) {
51
+ throw new Error('Lifecycle manifest launcher shebang policy is invalid');
52
+ }
53
+ return Object.freeze({
54
+ sourceFile: policy.sourceFile,
55
+ compiledFile: policy.compiledFile,
56
+ canonicalLine: policy.canonicalLine,
57
+ acceptedLines: Object.freeze([...policy.acceptedLines])
58
+ });
59
+ }
19
60
  function readLifecycleManifestFiles(packageRoot) {
20
61
  const file = path.join(packageRoot, 'lib', 'agent-clients', 'adapters', 'codex-lifecycle', 'manifest-files.json');
21
62
  const value = JSON.parse(fs.readFileSync(file, 'utf8'));
22
63
  if (!Array.isArray(value.executableFiles)
23
64
  || !Array.isArray(value.contractFiles)
24
- || !value.executableFiles.every(exactText)
25
- || !value.contractFiles.every(exactText)
65
+ || !value.executableFiles.every(isSafeLifecyclePath)
66
+ || !value.contractFiles.every(isSafeLifecyclePath)
26
67
  || new Set(value.executableFiles).size !== value.executableFiles.length
27
68
  || new Set(value.contractFiles).size !== value.contractFiles.length) {
28
69
  throw new Error('Lifecycle manifest file list is invalid');
29
70
  }
71
+ const executableFiles = Object.freeze([...value.executableFiles]);
30
72
  return Object.freeze({
31
- executableFiles: Object.freeze([...value.executableFiles]),
32
- contractFiles: Object.freeze([...value.contractFiles])
73
+ executableFiles,
74
+ contractFiles: Object.freeze([...value.contractFiles]),
75
+ launcherShebang: readLifecycleLauncherShebang(value.launcherShebang, executableFiles)
33
76
  });
34
77
  }
35
78
  function executablePackageRoot() {
@@ -47,7 +90,22 @@ function executablePackageRoot() {
47
90
  current = parent;
48
91
  }
49
92
  }
50
- function hashFiles(root, files) {
93
+ function normalizeLifecycleLauncherBytes(relative, content, policy) {
94
+ const normalized = normalizeRelativePath(relative);
95
+ if (normalized !== policy.sourceFile && normalized !== policy.compiledFile)
96
+ return content;
97
+ const lineEnd = content.indexOf(0x0a);
98
+ if (lineEnd < 0)
99
+ return content;
100
+ const firstLine = content.subarray(0, lineEnd + 1);
101
+ if (!policy.acceptedLines.some((line) => Buffer.from(line).equals(firstLine)))
102
+ return content;
103
+ return Buffer.concat([
104
+ Buffer.from(policy.canonicalLine),
105
+ content.subarray(lineEnd + 1)
106
+ ]);
107
+ }
108
+ function hashFiles(root, files, launcherShebang) {
51
109
  const hash = crypto.createHash('sha256');
52
110
  for (const relative of [...new Set(files.map(normalizeRelativePath))].sort()) {
53
111
  if (path.isAbsolute(relative) || relative.split(/[\\/]/u).includes('..')) {
@@ -60,7 +118,10 @@ function hashFiles(root, files) {
60
118
  }
61
119
  hash.update(relative);
62
120
  hash.update('\0');
63
- hash.update(fs.readFileSync(file));
121
+ const content = fs.readFileSync(file);
122
+ hash.update(launcherShebang
123
+ ? normalizeLifecycleLauncherBytes(relative, content, launcherShebang)
124
+ : content);
64
125
  hash.update('\0');
65
126
  }
66
127
  return hash.digest('hex');
@@ -107,7 +168,7 @@ function computeLifecycleBuildIdentity(repoRoot, options = {}) {
107
168
  throw new Error('Lifecycle package version is invalid');
108
169
  let internalExecutableBuildHash;
109
170
  if (options.executableFiles) {
110
- internalExecutableBuildHash = hashFiles(repoRoot, options.executableFiles);
171
+ internalExecutableBuildHash = hashFiles(repoRoot, options.executableFiles, defaults.launcherShebang);
111
172
  }
112
173
  else {
113
174
  const manifestFile = path.join(executableRoot, 'dist', 'lifecycle-build-manifest.json');
@@ -121,17 +182,17 @@ function computeLifecycleBuildIdentity(repoRoot, options = {}) {
121
182
  }
122
183
  if (fileURLToPath(import.meta.url).split(path.sep).includes('dist')) {
123
184
  const compiledFiles = defaults.executableFiles.map((file) => file.endsWith('.ts') ? path.join('dist', file.replace(/\.ts$/u, '.js')) : file);
124
- if (hashFiles(executableRoot, resolveLifecycleExecutableFiles(executableRoot, compiledFiles)) !== manifest.internalExecutableBuildHash) {
185
+ if (hashFiles(executableRoot, resolveLifecycleExecutableFiles(executableRoot, compiledFiles), defaults.launcherShebang) !== manifest.internalExecutableBuildHash) {
125
186
  throw new Error('Lifecycle compiled executable build does not match its manifest');
126
187
  }
127
188
  }
128
- else if (hashFiles(executableRoot, resolveLifecycleExecutableFiles(executableRoot, defaults.executableFiles)) !== manifest.sourceInputHash) {
189
+ else if (hashFiles(executableRoot, resolveLifecycleExecutableFiles(executableRoot, defaults.executableFiles), defaults.launcherShebang) !== manifest.sourceInputHash) {
129
190
  throw new Error('Lifecycle executable build manifest is stale or invalid');
130
191
  }
131
192
  internalExecutableBuildHash = manifest.internalExecutableBuildHash;
132
193
  }
133
194
  else
134
- internalExecutableBuildHash = hashFiles(executableRoot, resolveLifecycleExecutableFiles(executableRoot, defaults.executableFiles));
195
+ internalExecutableBuildHash = hashFiles(executableRoot, resolveLifecycleExecutableFiles(executableRoot, defaults.executableFiles), defaults.launcherShebang);
135
196
  }
136
197
  return Object.freeze({
137
198
  protocolVersion: LIFECYCLE_PROTOCOL_VERSION,
@@ -20,12 +20,8 @@ function ensureOpenCodeSandboxState(toolDir, hostHome, hostEnv = {}) {
20
20
  const canonicalConfigDir = path.join(toolDir, '.xdg', 'config', 'opencode');
21
21
  const canonicalStateDir = path.join(toolDir, '.xdg', 'state', 'opencode');
22
22
  const canonicalConfigPath = path.join(canonicalConfigDir, 'opencode.json');
23
- const legacyConfigPath = path.join(toolDir, 'opencode.json');
24
23
  fs.mkdirSync(canonicalConfigDir, { recursive: true });
25
24
  fs.mkdirSync(canonicalStateDir, { recursive: true });
26
- if (!fs.existsSync(canonicalConfigPath) && fs.existsSync(legacyConfigPath)) {
27
- fs.copyFileSync(legacyConfigPath, canonicalConfigPath, fs.constants.COPYFILE_EXCL);
28
- }
29
25
  const hostConfigRoot = resolveXdgRoot(hostEnv.XDG_CONFIG_HOME, path.join(hostHome, '.config'));
30
26
  const hostConfig = readJsonObject(path.join(hostConfigRoot, 'opencode', 'opencode.json'));
31
27
  if (!hostConfig) {
@@ -24,22 +24,21 @@ const traecliAdapter = defineAgentClientAdapter({
24
24
  actualReasoningEffort: 'unavailable'
25
25
  },
26
26
  project: {
27
- ownedPathPrefixes: ['.trae/'],
28
- managed: ['.trae/skills/'],
27
+ ownedPathPrefixes: ['.traecli/'],
28
+ managed: ['.traecli/commands/'],
29
29
  merged: [],
30
30
  ejected: [],
31
31
  seedCommands: [{
32
32
  templates: {
33
- en: '.trae/skills/update-agent-infra.en.md',
34
- 'zh-CN': '.trae/skills/update-agent-infra.zh-CN.md'
33
+ en: '.traecli/commands/update-agent-infra.en.md',
34
+ 'zh-CN': '.traecli/commands/update-agent-infra.zh-CN.md'
35
35
  },
36
- target: '.trae/skills/update-agent-infra.md'
36
+ target: '.traecli/commands/update-agent-infra.md'
37
37
  }],
38
38
  customCommand: {
39
- target: '.trae/skills/${skillName}.md',
39
+ target: '.traecli/commands/${skillName}.md',
40
40
  frontmatter: {},
41
- includeUsage: true,
42
- inheritDisableModelInvocation: true
41
+ argumentsToken: '$ARGUMENTS'
43
42
  }
44
43
  },
45
44
  sandbox: {
@@ -101,114 +101,29 @@ function serializeAgentClients(state) {
101
101
  : {})
102
102
  }));
103
103
  }
104
- function projectLegacyTuis(value, diagnostics) {
105
- if (!Array.isArray(value)) {
106
- return Object.fromEntries(AGENT_CLIENT_IDS.map((id) => [id, true]));
107
- }
108
- const enabled = new Set();
109
- for (const [index, candidate] of value.entries()) {
110
- if (isAgentClientId(candidate)) {
111
- enabled.add(candidate);
112
- }
113
- else {
114
- diagnostics.push({
115
- code: 'LEGACY_VALUE_IGNORED',
116
- path: `tuis[${index}]`
117
- });
118
- }
119
- }
120
- return Object.fromEntries(AGENT_CLIENT_IDS.map((id) => [id, enabled.has(id)]));
121
- }
122
- function projectLegacySandbox(value, diagnostics) {
123
- if (!Array.isArray(value) || value.length === 0) {
124
- return {
125
- installed: Object.fromEntries(AGENT_CLIENT_IDS.map((id) => [id, true])),
126
- clientSignals: new Set(),
127
- remainingTools: Array.isArray(value) ? [] : undefined
128
- };
129
- }
130
- const installed = new Set();
131
- const remainingTools = [];
132
- for (const [index, candidate] of value.entries()) {
133
- if (isAgentClientId(candidate)) {
134
- installed.add(candidate);
135
- }
136
- else if (typeof candidate === 'string') {
137
- remainingTools.push(candidate);
138
- }
139
- else {
140
- diagnostics.push({
141
- code: 'LEGACY_VALUE_IGNORED',
142
- path: `sandbox.tools[${index}]`
143
- });
144
- }
145
- }
146
- return {
147
- installed: Object.fromEntries(AGENT_CLIENT_IDS.map((id) => [id, installed.has(id)])),
148
- clientSignals: installed,
149
- remainingTools
150
- };
151
- }
152
- function stateFromLegacy(enabled, installed) {
153
- return Object.fromEntries(AGENT_CLIENT_IDS.map((id) => [
154
- id,
155
- {
156
- enabled: enabled[id],
157
- installInSandbox: installed[id]
158
- }
159
- ]));
160
- }
161
- function sameCanonicalOrder(value) {
162
- return Array.isArray(value)
163
- && value.every((entry, index) => isRecord(entry) && entry.id === AGENT_CLIENT_IDS[index]);
164
- }
165
104
  function normalizeAgentClients(input) {
166
- const diagnostics = [];
167
- const hasCanonical = hasOwn(input, 'agentClients');
168
- const hasLegacyTuis = hasOwn(input, 'tuis');
169
- const sandbox = isRecord(input.sandbox) ? input.sandbox : undefined;
170
- const hasLegacySandboxTools = sandbox !== undefined && hasOwn(sandbox, 'tools');
171
- const tuiProjection = projectLegacyTuis(input.tuis, diagnostics);
172
- const sandboxProjection = projectLegacySandbox(sandbox?.tools, diagnostics);
173
- if (!hasCanonical) {
174
- const state = stateFromLegacy(tuiProjection, sandboxProjection.installed);
175
- return {
176
- source: 'legacy',
177
- state,
178
- canonical: serializeAgentClients(state),
179
- remainingSandboxTools: sandboxProjection.remainingTools,
180
- removeLegacyTuis: hasLegacyTuis,
181
- changed: true,
182
- diagnostics
183
- };
184
- }
105
+ if (!hasOwn(input, 'agentClients'))
106
+ fail('MISSING_AGENT_CLIENT', 'agentClients');
185
107
  const state = parseCanonical(input.agentClients);
186
- if (hasLegacyTuis) {
187
- for (const id of AGENT_CLIENT_IDS) {
188
- if (state[id].enabled !== tuiProjection[id]) {
189
- fail('LEGACY_CONFLICT', 'tuis');
190
- }
108
+ for (const [index, id] of AGENT_CLIENT_IDS.entries()) {
109
+ const entry = Array.isArray(input.agentClients) ? input.agentClients[index] : undefined;
110
+ if (!isRecord(entry) || entry.id !== id) {
111
+ fail('INVALID_AGENT_CLIENTS', `agentClients[${index}].id`);
191
112
  }
192
113
  }
193
- if (hasLegacySandboxTools) {
194
- for (const id of sandboxProjection.clientSignals) {
195
- if (!state[id].installInSandbox) {
196
- fail('LEGACY_CONFLICT', 'sandbox.tools');
114
+ if (hasOwn(input, 'tuis'))
115
+ fail('INVALID_AGENT_CLIENTS', 'tuis');
116
+ const sandbox = isRecord(input.sandbox) ? input.sandbox : undefined;
117
+ if (Array.isArray(sandbox?.tools)) {
118
+ for (const [index, tool] of sandbox.tools.entries()) {
119
+ if (isAgentClientId(tool)) {
120
+ fail('INVALID_AGENT_CLIENTS', `sandbox.tools[${index}]`);
197
121
  }
198
122
  }
199
123
  }
200
124
  return {
201
- source: 'canonical',
202
125
  state,
203
- canonical: serializeAgentClients(state),
204
- remainingSandboxTools: hasLegacySandboxTools
205
- ? sandboxProjection.remainingTools
206
- : undefined,
207
- removeLegacyTuis: hasLegacyTuis,
208
- changed: hasLegacyTuis
209
- || sandboxProjection.clientSignals.size > 0
210
- || !sameCanonicalOrder(input.agentClients),
211
- diagnostics
126
+ canonical: serializeAgentClients(state)
212
127
  };
213
128
  }
214
129
  export { AgentClientConfigError, normalizeAgentClients, serializeAgentClients };
@@ -71,15 +71,6 @@ function planAgentClientReconciliation(input) {
71
71
  });
72
72
  const nextConfig = structuredClone(input.config);
73
73
  nextConfig.agentClients = serializeAgentClients(desired);
74
- delete nextConfig.tuis;
75
- if (normalized.remainingSandboxTools !== undefined) {
76
- const sandbox = isRecord(nextConfig.sandbox) ? { ...nextConfig.sandbox } : {};
77
- sandbox.tools = [
78
- 'agent-infra',
79
- ...normalized.remainingSandboxTools.filter((tool) => tool !== 'agent-infra')
80
- ];
81
- nextConfig.sandbox = sandbox;
82
- }
83
74
  const existingFiles = isRecord(nextConfig.files) ? nextConfig.files : {};
84
75
  const existingBaselines = isRecord(existingFiles.managedBaselines)
85
76
  ? existingFiles.managedBaselines
@@ -161,14 +152,13 @@ function planAgentClientReconciliation(input) {
161
152
  const changed = JSON.stringify(nextConfig) !== JSON.stringify(input.config)
162
153
  || actionableSeed;
163
154
  return Object.freeze({
164
- source: normalized.source,
165
155
  before: normalized.state,
166
156
  desired,
167
157
  nextConfig,
168
158
  projectAssets,
169
159
  seedOperations: Object.freeze(seedOperations),
170
160
  nextSteps,
171
- diagnostics: Object.freeze([...normalized.diagnostics, ...custom.diagnostics]),
161
+ diagnostics: Object.freeze([...custom.diagnostics]),
172
162
  changed,
173
163
  projectRoot: input.projectRoot,
174
164
  configPath: path.join(input.projectRoot, '.agents', '.airc.json')