agentplane 0.3.7 → 0.3.8

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 (625) hide show
  1. package/assets/AGENTS.md +11 -1
  2. package/assets/RUNNER.md +17 -0
  3. package/bin/agentplane.js +16 -7
  4. package/bin/framework-dev-contract.d.ts +6 -0
  5. package/bin/framework-dev-contract.js +13 -0
  6. package/bin/stale-dist-policy.js +6 -1
  7. package/dist/.build-manifest.json +694 -339
  8. package/dist/adapters/task-backend/task-backend-adapter.d.ts +3 -1
  9. package/dist/adapters/task-backend/task-backend-adapter.d.ts.map +1 -1
  10. package/dist/adapters/task-backend/task-backend-adapter.js +13 -0
  11. package/dist/backends/task-backend/local-backend-doc.d.ts +5 -0
  12. package/dist/backends/task-backend/local-backend-doc.d.ts.map +1 -0
  13. package/dist/backends/task-backend/local-backend-doc.js +98 -0
  14. package/dist/backends/task-backend/local-backend-read.d.ts +7 -0
  15. package/dist/backends/task-backend/local-backend-read.d.ts.map +1 -0
  16. package/dist/backends/task-backend/local-backend-read.js +186 -0
  17. package/dist/backends/task-backend/local-backend-state.d.ts +17 -0
  18. package/dist/backends/task-backend/local-backend-state.d.ts.map +1 -0
  19. package/dist/backends/task-backend/local-backend-state.js +50 -0
  20. package/dist/backends/task-backend/local-backend-write.d.ts +15 -0
  21. package/dist/backends/task-backend/local-backend-write.d.ts.map +1 -0
  22. package/dist/backends/task-backend/local-backend-write.js +254 -0
  23. package/dist/backends/task-backend/local-backend.d.ts +4 -2
  24. package/dist/backends/task-backend/local-backend.d.ts.map +1 -1
  25. package/dist/backends/task-backend/local-backend.js +26 -403
  26. package/dist/backends/task-backend/redmine/backend-cache-doc.d.ts +40 -0
  27. package/dist/backends/task-backend/redmine/backend-cache-doc.d.ts.map +1 -0
  28. package/dist/backends/task-backend/redmine/backend-cache-doc.js +178 -0
  29. package/dist/backends/task-backend/redmine/backend-report.d.ts +10 -0
  30. package/dist/backends/task-backend/redmine/backend-report.d.ts.map +1 -0
  31. package/dist/backends/task-backend/redmine/backend-report.js +43 -0
  32. package/dist/backends/task-backend/redmine/backend-sync.d.ts +67 -0
  33. package/dist/backends/task-backend/redmine/backend-sync.d.ts.map +1 -0
  34. package/dist/backends/task-backend/redmine/backend-sync.js +367 -0
  35. package/dist/backends/task-backend/redmine/mapping.d.ts +2 -1
  36. package/dist/backends/task-backend/redmine/mapping.d.ts.map +1 -1
  37. package/dist/backends/task-backend/redmine/mapping.js +12 -2
  38. package/dist/backends/task-backend/redmine/parse.d.ts +2 -1
  39. package/dist/backends/task-backend/redmine/parse.d.ts.map +1 -1
  40. package/dist/backends/task-backend/redmine/parse.js +5 -3
  41. package/dist/backends/task-backend/redmine/state.d.ts +2 -0
  42. package/dist/backends/task-backend/redmine/state.d.ts.map +1 -1
  43. package/dist/backends/task-backend/redmine/state.js +15 -1
  44. package/dist/backends/task-backend/redmine-backend.d.ts +5 -2
  45. package/dist/backends/task-backend/redmine-backend.d.ts.map +1 -1
  46. package/dist/backends/task-backend/redmine-backend.js +88 -536
  47. package/dist/backends/task-backend/shared/constants.d.ts +2 -1
  48. package/dist/backends/task-backend/shared/constants.d.ts.map +1 -1
  49. package/dist/backends/task-backend/shared/doc.d.ts.map +1 -1
  50. package/dist/backends/task-backend/shared/doc.js +25 -39
  51. package/dist/backends/task-backend/shared/export.d.ts +2 -9
  52. package/dist/backends/task-backend/shared/export.d.ts.map +1 -1
  53. package/dist/backends/task-backend/shared/export.js +73 -8
  54. package/dist/backends/task-backend/shared/normalize.d.ts +5 -1
  55. package/dist/backends/task-backend/shared/normalize.d.ts.map +1 -1
  56. package/dist/backends/task-backend/shared/normalize.js +166 -0
  57. package/dist/backends/task-backend/shared/record.d.ts +1 -1
  58. package/dist/backends/task-backend/shared/record.d.ts.map +1 -1
  59. package/dist/backends/task-backend/shared/record.js +7 -2
  60. package/dist/backends/task-backend/shared/types.d.ts +38 -36
  61. package/dist/backends/task-backend/shared/types.d.ts.map +1 -1
  62. package/dist/backends/task-backend/shared.d.ts +2 -2
  63. package/dist/backends/task-backend/shared.d.ts.map +1 -1
  64. package/dist/backends/task-backend/shared.js +1 -1
  65. package/dist/backends/task-backend.d.ts +1 -1
  66. package/dist/backends/task-backend.d.ts.map +1 -1
  67. package/dist/backends/task-backend.js +1 -1
  68. package/dist/backends/task-index.d.ts +2 -2
  69. package/dist/backends/task-index.d.ts.map +1 -1
  70. package/dist/backends/task-index.js +9 -6
  71. package/dist/cli/bootstrap-guide.d.ts +2 -2
  72. package/dist/cli/bootstrap-guide.d.ts.map +1 -1
  73. package/dist/cli/bootstrap-guide.js +10 -10
  74. package/dist/cli/command-guide.d.ts.map +1 -1
  75. package/dist/cli/command-guide.js +11 -9
  76. package/dist/cli/command-invocations.d.ts +4 -0
  77. package/dist/cli/command-invocations.d.ts.map +1 -0
  78. package/dist/cli/command-invocations.js +35 -0
  79. package/dist/cli/command-snippets.d.ts +12 -8
  80. package/dist/cli/command-snippets.d.ts.map +1 -1
  81. package/dist/cli/command-snippets.js +14 -8
  82. package/dist/cli/exit-codes.d.ts.map +1 -1
  83. package/dist/cli/exit-codes.js +1 -0
  84. package/dist/cli/group-command.d.ts +18 -0
  85. package/dist/cli/group-command.d.ts.map +1 -0
  86. package/dist/cli/group-command.js +45 -0
  87. package/dist/cli/output.d.ts +29 -0
  88. package/dist/cli/output.d.ts.map +1 -1
  89. package/dist/cli/output.js +76 -0
  90. package/dist/cli/prompts.d.ts.map +1 -1
  91. package/dist/cli/prompts.js +5 -1
  92. package/dist/cli/run-cli/command-catalog/core.d.ts.map +1 -1
  93. package/dist/cli/run-cli/command-catalog/core.js +38 -29
  94. package/dist/cli/run-cli/command-catalog/lifecycle.d.ts.map +1 -1
  95. package/dist/cli/run-cli/command-catalog/lifecycle.js +9 -6
  96. package/dist/cli/run-cli/command-catalog/project.d.ts +1 -1
  97. package/dist/cli/run-cli/command-catalog/project.d.ts.map +1 -1
  98. package/dist/cli/run-cli/command-catalog/project.js +8 -6
  99. package/dist/cli/run-cli/command-catalog/shared.d.ts +12 -3
  100. package/dist/cli/run-cli/command-catalog/shared.d.ts.map +1 -1
  101. package/dist/cli/run-cli/command-catalog/shared.js +6 -3
  102. package/dist/cli/run-cli/command-catalog/task.d.ts +1 -1
  103. package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -1
  104. package/dist/cli/run-cli/command-catalog/task.js +46 -11
  105. package/dist/cli/run-cli/command-catalog.d.ts +11 -1
  106. package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
  107. package/dist/cli/run-cli/command-catalog.js +29 -0
  108. package/dist/cli/run-cli/commands/config.d.ts.map +1 -1
  109. package/dist/cli/run-cli/commands/config.js +52 -6
  110. package/dist/cli/run-cli/commands/core/agent-profiles.d.ts +34 -0
  111. package/dist/cli/run-cli/commands/core/agent-profiles.d.ts.map +1 -0
  112. package/dist/cli/run-cli/commands/core/agent-profiles.js +97 -0
  113. package/dist/cli/run-cli/commands/core/agents.d.ts +7 -0
  114. package/dist/cli/run-cli/commands/core/agents.d.ts.map +1 -0
  115. package/dist/cli/run-cli/commands/core/agents.js +97 -0
  116. package/dist/cli/run-cli/commands/core/preflight.d.ts +10 -0
  117. package/dist/cli/run-cli/commands/core/preflight.d.ts.map +1 -0
  118. package/dist/cli/run-cli/commands/core/preflight.js +286 -0
  119. package/dist/cli/run-cli/commands/core/quickstart.d.ts +8 -0
  120. package/dist/cli/run-cli/commands/core/quickstart.d.ts.map +1 -0
  121. package/dist/cli/run-cli/commands/core/quickstart.js +43 -0
  122. package/dist/cli/run-cli/commands/core/role.d.ts +9 -0
  123. package/dist/cli/run-cli/commands/core/role.d.ts.map +1 -0
  124. package/dist/cli/run-cli/commands/core/role.js +128 -0
  125. package/dist/cli/run-cli/commands/core.d.ts +4 -24
  126. package/dist/cli/run-cli/commands/core.d.ts.map +1 -1
  127. package/dist/cli/run-cli/commands/core.js +4 -630
  128. package/dist/cli/run-cli/error-guidance.js +10 -0
  129. package/dist/cli/run-cli/globals.d.ts +5 -2
  130. package/dist/cli/run-cli/globals.d.ts.map +1 -1
  131. package/dist/cli/run-cli/globals.js +82 -86
  132. package/dist/cli/run-cli.d.ts.map +1 -1
  133. package/dist/cli/run-cli.js +137 -100
  134. package/dist/cli/run-cli.test-helpers.d.ts +21 -0
  135. package/dist/cli/run-cli.test-helpers.d.ts.map +1 -1
  136. package/dist/cli/run-cli.test-helpers.js +88 -4
  137. package/dist/cli/spec/help.d.ts +10 -2
  138. package/dist/cli/spec/help.d.ts.map +1 -1
  139. package/dist/cli/spec/help.js +7 -5
  140. package/dist/cli/spec/registry.d.ts +27 -1
  141. package/dist/cli/spec/registry.d.ts.map +1 -1
  142. package/dist/cli/spec/registry.js +98 -25
  143. package/dist/commands/backend/sync.command.d.ts +3 -5
  144. package/dist/commands/backend/sync.command.d.ts.map +1 -1
  145. package/dist/commands/backend/sync.command.js +9 -12
  146. package/dist/commands/backend.d.ts.map +1 -1
  147. package/dist/commands/backend.js +8 -7
  148. package/dist/commands/branch/base.command.d.ts +2 -3
  149. package/dist/commands/branch/base.command.d.ts.map +1 -1
  150. package/dist/commands/branch/base.command.js +8 -12
  151. package/dist/commands/branch/base.d.ts.map +1 -1
  152. package/dist/commands/branch/base.js +11 -7
  153. package/dist/commands/branch/cleanup-merged.d.ts.map +1 -1
  154. package/dist/commands/branch/cleanup-merged.js +9 -8
  155. package/dist/commands/branch/remove.d.ts.map +1 -1
  156. package/dist/commands/branch/remove.js +4 -3
  157. package/dist/commands/branch/status.d.ts.map +1 -1
  158. package/dist/commands/branch/status.js +4 -3
  159. package/dist/commands/branch/work-start.d.ts.map +1 -1
  160. package/dist/commands/branch/work-start.js +48 -5
  161. package/dist/commands/cleanup/merged.command.d.ts +2 -3
  162. package/dist/commands/cleanup/merged.command.d.ts.map +1 -1
  163. package/dist/commands/cleanup/merged.command.js +8 -12
  164. package/dist/commands/docs/cli.command.js +2 -2
  165. package/dist/commands/doctor/runtime.js +1 -1
  166. package/dist/commands/doctor/workflow.d.ts.map +1 -1
  167. package/dist/commands/doctor/workflow.js +10 -1
  168. package/dist/commands/finish.spec.d.ts.map +1 -1
  169. package/dist/commands/finish.spec.js +7 -0
  170. package/dist/commands/guard/guard.command.d.ts +3 -3
  171. package/dist/commands/guard/guard.command.d.ts.map +1 -1
  172. package/dist/commands/guard/guard.command.js +9 -14
  173. package/dist/commands/guard/impl/commands.d.ts +2 -0
  174. package/dist/commands/guard/impl/commands.d.ts.map +1 -1
  175. package/dist/commands/guard/impl/commands.js +55 -7
  176. package/dist/commands/guard/impl/policy.d.ts +1 -0
  177. package/dist/commands/guard/impl/policy.d.ts.map +1 -1
  178. package/dist/commands/guard/impl/policy.js +9 -6
  179. package/dist/commands/hooks/hooks.command.d.ts +3 -3
  180. package/dist/commands/hooks/hooks.command.d.ts.map +1 -1
  181. package/dist/commands/hooks/hooks.command.js +9 -11
  182. package/dist/commands/pr/check.d.ts.map +1 -1
  183. package/dist/commands/pr/check.js +90 -18
  184. package/dist/commands/pr/integrate/cmd.d.ts.map +1 -1
  185. package/dist/commands/pr/integrate/cmd.js +31 -3
  186. package/dist/commands/pr/integrate/internal/cleanup.d.ts +12 -0
  187. package/dist/commands/pr/integrate/internal/cleanup.d.ts.map +1 -0
  188. package/dist/commands/pr/integrate/internal/cleanup.js +46 -0
  189. package/dist/commands/pr/integrate/internal/finalize.d.ts +4 -0
  190. package/dist/commands/pr/integrate/internal/finalize.d.ts.map +1 -1
  191. package/dist/commands/pr/integrate/internal/finalize.js +34 -40
  192. package/dist/commands/pr/integrate/internal/merge.d.ts +6 -0
  193. package/dist/commands/pr/integrate/internal/merge.d.ts.map +1 -1
  194. package/dist/commands/pr/integrate/internal/merge.js +92 -0
  195. package/dist/commands/pr/integrate/internal/prepare.d.ts +1 -0
  196. package/dist/commands/pr/integrate/internal/prepare.d.ts.map +1 -1
  197. package/dist/commands/pr/integrate/internal/prepare.js +1 -0
  198. package/dist/commands/pr/integrate/verify.d.ts.map +1 -1
  199. package/dist/commands/pr/integrate/verify.js +4 -3
  200. package/dist/commands/pr/note.d.ts.map +1 -1
  201. package/dist/commands/pr/note.js +3 -2
  202. package/dist/commands/pr/open.d.ts.map +1 -1
  203. package/dist/commands/pr/open.js +9 -12
  204. package/dist/commands/pr/pr.command.d.ts +3 -4
  205. package/dist/commands/pr/pr.command.d.ts.map +1 -1
  206. package/dist/commands/pr/pr.command.js +6 -11
  207. package/dist/commands/pr/update.d.ts.map +1 -1
  208. package/dist/commands/pr/update.js +5 -10
  209. package/dist/commands/recipes/cache.command.d.ts +3 -4
  210. package/dist/commands/recipes/cache.command.d.ts.map +1 -1
  211. package/dist/commands/recipes/cache.command.js +8 -26
  212. package/dist/commands/recipes/impl/apply.d.ts +1 -1
  213. package/dist/commands/recipes/impl/apply.d.ts.map +1 -1
  214. package/dist/commands/recipes/impl/apply.js +1 -1
  215. package/dist/commands/recipes/impl/commands/explain.js +1 -1
  216. package/dist/commands/recipes/impl/commands/install.d.ts.map +1 -1
  217. package/dist/commands/recipes/impl/commands/install.js +1 -2
  218. package/dist/commands/recipes/impl/installed-recipes.d.ts +1 -1
  219. package/dist/commands/recipes/impl/installed-recipes.d.ts.map +1 -1
  220. package/dist/commands/recipes/impl/installed-recipes.js +1 -2
  221. package/dist/commands/recipes/impl/manifest.d.ts.map +1 -1
  222. package/dist/commands/recipes/impl/manifest.js +0 -10
  223. package/dist/commands/recipes/impl/project-installed-recipes.d.ts +1 -1
  224. package/dist/commands/recipes/impl/project-installed-recipes.d.ts.map +1 -1
  225. package/dist/commands/recipes/impl/project-installed-recipes.js +1 -2
  226. package/dist/commands/recipes/impl/resolver.d.ts +1 -1
  227. package/dist/commands/recipes/impl/resolver.d.ts.map +1 -1
  228. package/dist/commands/recipes/impl/resolver.js +26 -16
  229. package/dist/commands/recipes/impl/scenario.d.ts.map +1 -1
  230. package/dist/commands/recipes/impl/scenario.js +80 -0
  231. package/dist/commands/recipes/impl/types.d.ts +27 -13
  232. package/dist/commands/recipes/impl/types.d.ts.map +1 -1
  233. package/dist/commands/recipes/recipes.command.d.ts +3 -4
  234. package/dist/commands/recipes/recipes.command.d.ts.map +1 -1
  235. package/dist/commands/recipes/recipes.command.js +8 -34
  236. package/dist/commands/recipes.d.ts +4 -4
  237. package/dist/commands/recipes.d.ts.map +1 -1
  238. package/dist/commands/recipes.js +3 -3
  239. package/dist/commands/recipes.test-helpers.d.ts +17 -0
  240. package/dist/commands/recipes.test-helpers.d.ts.map +1 -1
  241. package/dist/commands/recipes.test-helpers.js +56 -2
  242. package/dist/commands/release/apply.command.d.ts.map +1 -1
  243. package/dist/commands/release/apply.command.js +77 -56
  244. package/dist/commands/release/plan.command.d.ts.map +1 -1
  245. package/dist/commands/release/plan.command.js +7 -3
  246. package/dist/commands/release/release.command.d.ts +3 -3
  247. package/dist/commands/release/release.command.d.ts.map +1 -1
  248. package/dist/commands/release/release.command.js +9 -11
  249. package/dist/commands/release.test-helpers.d.ts +20 -0
  250. package/dist/commands/release.test-helpers.d.ts.map +1 -0
  251. package/dist/commands/release.test-helpers.js +37 -0
  252. package/dist/commands/runtime.command.d.ts +7 -7
  253. package/dist/commands/runtime.command.d.ts.map +1 -1
  254. package/dist/commands/runtime.command.js +29 -33
  255. package/dist/commands/scenario/execute.command.d.ts +8 -0
  256. package/dist/commands/scenario/execute.command.d.ts.map +1 -0
  257. package/dist/commands/scenario/execute.command.js +117 -0
  258. package/dist/commands/scenario/impl/commands.d.ts.map +1 -1
  259. package/dist/commands/scenario/impl/commands.js +45 -32
  260. package/dist/commands/scenario/run.command.js +2 -2
  261. package/dist/commands/scenario/scenario.command.d.ts +3 -4
  262. package/dist/commands/scenario/scenario.command.d.ts.map +1 -1
  263. package/dist/commands/scenario/scenario.command.js +8 -26
  264. package/dist/commands/shared/git-context.d.ts +1 -0
  265. package/dist/commands/shared/git-context.d.ts.map +1 -1
  266. package/dist/commands/shared/git-context.js +4 -2
  267. package/dist/commands/shared/git-ops.d.ts +1 -0
  268. package/dist/commands/shared/git-ops.d.ts.map +1 -1
  269. package/dist/commands/shared/git-ops.js +13 -0
  270. package/dist/commands/shared/operator-pipeline.d.ts +10 -0
  271. package/dist/commands/shared/operator-pipeline.d.ts.map +1 -0
  272. package/dist/commands/shared/operator-pipeline.js +16 -0
  273. package/dist/commands/shared/pr-meta.d.ts +32 -12
  274. package/dist/commands/shared/pr-meta.d.ts.map +1 -1
  275. package/dist/commands/shared/pr-meta.js +49 -14
  276. package/dist/commands/shared/reconcile-check.d.ts.map +1 -1
  277. package/dist/commands/shared/reconcile-check.js +28 -3
  278. package/dist/commands/shared/task-backend.d.ts +10 -6
  279. package/dist/commands/shared/task-backend.d.ts.map +1 -1
  280. package/dist/commands/shared/task-backend.js +99 -25
  281. package/dist/commands/shared/task-handoff.d.ts +64 -0
  282. package/dist/commands/shared/task-handoff.d.ts.map +1 -0
  283. package/dist/commands/shared/task-handoff.js +151 -0
  284. package/dist/commands/shared/task-mutation.d.ts +36 -0
  285. package/dist/commands/shared/task-mutation.d.ts.map +1 -0
  286. package/dist/commands/shared/task-mutation.js +67 -0
  287. package/dist/commands/shared/task-store.d.ts +5 -1
  288. package/dist/commands/shared/task-store.d.ts.map +1 -1
  289. package/dist/commands/shared/task-store.js +72 -92
  290. package/dist/commands/task/add.d.ts.map +1 -1
  291. package/dist/commands/task/add.js +41 -39
  292. package/dist/commands/task/block.d.ts.map +1 -1
  293. package/dist/commands/task/block.js +31 -110
  294. package/dist/commands/task/close-duplicate.d.ts.map +1 -1
  295. package/dist/commands/task/close-duplicate.js +0 -7
  296. package/dist/commands/task/close-noop.d.ts.map +1 -1
  297. package/dist/commands/task/close-noop.js +0 -21
  298. package/dist/commands/task/close-shared.d.ts +0 -2
  299. package/dist/commands/task/close-shared.d.ts.map +1 -1
  300. package/dist/commands/task/close-shared.js +25 -55
  301. package/dist/commands/task/comment.d.ts.map +1 -1
  302. package/dist/commands/task/comment.js +48 -37
  303. package/dist/commands/task/derive.d.ts.map +1 -1
  304. package/dist/commands/task/derive.js +14 -7
  305. package/dist/commands/task/doc.command.d.ts.map +1 -1
  306. package/dist/commands/task/doc.command.js +7 -6
  307. package/dist/commands/task/doc.d.ts.map +1 -1
  308. package/dist/commands/task/doc.js +58 -62
  309. package/dist/commands/task/finish-shared.d.ts +60 -0
  310. package/dist/commands/task/finish-shared.d.ts.map +1 -0
  311. package/dist/commands/task/finish-shared.js +181 -0
  312. package/dist/commands/task/finish.d.ts +1 -0
  313. package/dist/commands/task/finish.d.ts.map +1 -1
  314. package/dist/commands/task/finish.js +79 -210
  315. package/dist/commands/task/handoff-record.command.d.ts +17 -0
  316. package/dist/commands/task/handoff-record.command.d.ts.map +1 -0
  317. package/dist/commands/task/handoff-record.command.js +140 -0
  318. package/dist/commands/task/handoff-show.command.d.ts +8 -0
  319. package/dist/commands/task/handoff-show.command.d.ts.map +1 -0
  320. package/dist/commands/task/handoff-show.command.js +77 -0
  321. package/dist/commands/task/handoff.command.d.ts +7 -0
  322. package/dist/commands/task/handoff.command.d.ts.map +1 -0
  323. package/dist/commands/task/handoff.command.js +21 -0
  324. package/dist/commands/task/handoff.shared.d.ts +39 -0
  325. package/dist/commands/task/handoff.shared.d.ts.map +1 -0
  326. package/dist/commands/task/handoff.shared.js +134 -0
  327. package/dist/commands/task/hosted-close.command.d.ts +9 -0
  328. package/dist/commands/task/hosted-close.command.d.ts.map +1 -0
  329. package/dist/commands/task/hosted-close.command.js +190 -0
  330. package/dist/commands/task/hosted-merge-sync.d.ts +40 -0
  331. package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -0
  332. package/dist/commands/task/hosted-merge-sync.js +277 -0
  333. package/dist/commands/task/list.d.ts.map +1 -1
  334. package/dist/commands/task/list.js +7 -24
  335. package/dist/commands/task/new.d.ts.map +1 -1
  336. package/dist/commands/task/new.js +26 -6
  337. package/dist/commands/task/next.d.ts.map +1 -1
  338. package/dist/commands/task/next.js +10 -28
  339. package/dist/commands/task/normalize.command.d.ts +1 -0
  340. package/dist/commands/task/normalize.command.d.ts.map +1 -1
  341. package/dist/commands/task/normalize.command.js +12 -0
  342. package/dist/commands/task/normalize.d.ts +1 -0
  343. package/dist/commands/task/normalize.d.ts.map +1 -1
  344. package/dist/commands/task/normalize.js +21 -9
  345. package/dist/commands/task/plan.command.d.ts +3 -4
  346. package/dist/commands/task/plan.command.d.ts.map +1 -1
  347. package/dist/commands/task/plan.command.js +6 -12
  348. package/dist/commands/task/plan.d.ts.map +1 -1
  349. package/dist/commands/task/plan.js +96 -103
  350. package/dist/commands/task/reclaim.command.d.ts +11 -0
  351. package/dist/commands/task/reclaim.command.d.ts.map +1 -0
  352. package/dist/commands/task/reclaim.command.js +102 -0
  353. package/dist/commands/task/resume-context.command.d.ts +9 -0
  354. package/dist/commands/task/resume-context.command.d.ts.map +1 -0
  355. package/dist/commands/task/resume-context.command.js +60 -0
  356. package/dist/commands/task/run-cancel.command.d.ts +6 -0
  357. package/dist/commands/task/run-cancel.command.d.ts.map +1 -0
  358. package/dist/commands/task/run-cancel.command.js +45 -0
  359. package/dist/commands/task/run-cancel.spec.d.ts +7 -0
  360. package/dist/commands/task/run-cancel.spec.d.ts.map +1 -0
  361. package/dist/commands/task/run-cancel.spec.js +20 -0
  362. package/dist/commands/task/run-resume.command.d.ts +6 -0
  363. package/dist/commands/task/run-resume.command.d.ts.map +1 -0
  364. package/dist/commands/task/run-resume.command.js +55 -0
  365. package/dist/commands/task/run-resume.spec.d.ts +7 -0
  366. package/dist/commands/task/run-resume.spec.d.ts.map +1 -0
  367. package/dist/commands/task/run-resume.spec.js +20 -0
  368. package/dist/commands/task/run-retry.command.d.ts +6 -0
  369. package/dist/commands/task/run-retry.command.d.ts.map +1 -0
  370. package/dist/commands/task/run-retry.command.js +56 -0
  371. package/dist/commands/task/run-retry.spec.d.ts +7 -0
  372. package/dist/commands/task/run-retry.spec.d.ts.map +1 -0
  373. package/dist/commands/task/run-retry.spec.js +20 -0
  374. package/dist/commands/task/run-show.command.d.ts +6 -0
  375. package/dist/commands/task/run-show.command.d.ts.map +1 -0
  376. package/dist/commands/task/run-show.command.js +133 -0
  377. package/dist/commands/task/run-show.spec.d.ts +8 -0
  378. package/dist/commands/task/run-show.spec.d.ts.map +1 -0
  379. package/dist/commands/task/run-show.spec.js +44 -0
  380. package/dist/commands/task/run-tail.command.d.ts +6 -0
  381. package/dist/commands/task/run-tail.command.d.ts.map +1 -0
  382. package/dist/commands/task/run-tail.command.js +26 -0
  383. package/dist/commands/task/run-tail.spec.d.ts +8 -0
  384. package/dist/commands/task/run-tail.spec.d.ts.map +1 -0
  385. package/dist/commands/task/run-tail.spec.js +51 -0
  386. package/dist/commands/task/run-trace.command.d.ts +6 -0
  387. package/dist/commands/task/run-trace.command.d.ts.map +1 -0
  388. package/dist/commands/task/run-trace.command.js +25 -0
  389. package/dist/commands/task/run-trace.spec.d.ts +7 -0
  390. package/dist/commands/task/run-trace.spec.d.ts.map +1 -0
  391. package/dist/commands/task/run-trace.spec.js +31 -0
  392. package/dist/commands/task/run.command.d.ts +6 -0
  393. package/dist/commands/task/run.command.d.ts.map +1 -0
  394. package/dist/commands/task/run.command.js +74 -0
  395. package/dist/commands/task/run.spec.d.ts +7 -0
  396. package/dist/commands/task/run.spec.d.ts.map +1 -0
  397. package/dist/commands/task/run.spec.js +26 -0
  398. package/dist/commands/task/scaffold.d.ts.map +1 -1
  399. package/dist/commands/task/scaffold.js +4 -2
  400. package/dist/commands/task/scrub.d.ts.map +1 -1
  401. package/dist/commands/task/scrub.js +27 -24
  402. package/dist/commands/task/search.d.ts.map +1 -1
  403. package/dist/commands/task/search.js +21 -31
  404. package/dist/commands/task/set-status.d.ts.map +1 -1
  405. package/dist/commands/task/set-status.js +36 -152
  406. package/dist/commands/task/shared/dependencies.d.ts +4 -4
  407. package/dist/commands/task/shared/dependencies.d.ts.map +1 -1
  408. package/dist/commands/task/shared/dependencies.js +10 -2
  409. package/dist/commands/task/shared/docs.d.ts +6 -1
  410. package/dist/commands/task/shared/docs.d.ts.map +1 -1
  411. package/dist/commands/task/shared/docs.js +13 -0
  412. package/dist/commands/task/shared/listing.d.ts +16 -2
  413. package/dist/commands/task/shared/listing.d.ts.map +1 -1
  414. package/dist/commands/task/shared/listing.js +56 -0
  415. package/dist/commands/task/shared/transition-command.d.ts +15 -0
  416. package/dist/commands/task/shared/transition-command.d.ts.map +1 -0
  417. package/dist/commands/task/shared/transition-command.js +43 -0
  418. package/dist/commands/task/shared/transitions.d.ts +39 -0
  419. package/dist/commands/task/shared/transitions.d.ts.map +1 -1
  420. package/dist/commands/task/shared/transitions.js +62 -1
  421. package/dist/commands/task/shared/workflow-transition-service.d.ts +75 -0
  422. package/dist/commands/task/shared/workflow-transition-service.d.ts.map +1 -0
  423. package/dist/commands/task/shared/workflow-transition-service.js +226 -0
  424. package/dist/commands/task/shared.d.ts +5 -3
  425. package/dist/commands/task/shared.d.ts.map +1 -1
  426. package/dist/commands/task/shared.js +5 -3
  427. package/dist/commands/task/show.d.ts.map +1 -1
  428. package/dist/commands/task/show.js +37 -3
  429. package/dist/commands/task/start.d.ts.map +1 -1
  430. package/dist/commands/task/start.js +33 -119
  431. package/dist/commands/task/task.command.d.ts +3 -4
  432. package/dist/commands/task/task.command.d.ts.map +1 -1
  433. package/dist/commands/task/task.command.js +22 -37
  434. package/dist/commands/task/verify-record.d.ts.map +1 -1
  435. package/dist/commands/task/verify-record.js +16 -141
  436. package/dist/commands/task/verify.command.d.ts.map +1 -1
  437. package/dist/commands/task/verify.command.js +7 -6
  438. package/dist/commands/task.test-helpers.d.ts +13 -0
  439. package/dist/commands/task.test-helpers.d.ts.map +1 -0
  440. package/dist/commands/task.test-helpers.js +65 -0
  441. package/dist/commands/upgrade/materialize.d.ts +28 -0
  442. package/dist/commands/upgrade/materialize.d.ts.map +1 -0
  443. package/dist/commands/upgrade/materialize.js +154 -0
  444. package/dist/commands/upgrade/plan.d.ts +18 -0
  445. package/dist/commands/upgrade/plan.d.ts.map +1 -0
  446. package/dist/commands/upgrade/plan.js +219 -0
  447. package/dist/commands/upgrade/policy.d.ts +24 -0
  448. package/dist/commands/upgrade/policy.d.ts.map +1 -0
  449. package/dist/commands/upgrade/policy.js +182 -0
  450. package/dist/commands/upgrade/report.d.ts.map +1 -1
  451. package/dist/commands/upgrade/report.js +7 -5
  452. package/dist/commands/upgrade.d.ts.map +1 -1
  453. package/dist/commands/upgrade.js +154 -642
  454. package/dist/commands/workflow.command.d.ts +3 -4
  455. package/dist/commands/workflow.command.d.ts.map +1 -1
  456. package/dist/commands/workflow.command.js +8 -25
  457. package/dist/ports/task-backend-port.d.ts +3 -1
  458. package/dist/ports/task-backend-port.d.ts.map +1 -1
  459. package/dist/runner/adapters/codex.d.ts +9 -0
  460. package/dist/runner/adapters/codex.d.ts.map +1 -0
  461. package/dist/runner/adapters/codex.js +414 -0
  462. package/dist/runner/adapters/custom.d.ts +12 -0
  463. package/dist/runner/adapters/custom.d.ts.map +1 -0
  464. package/dist/runner/adapters/custom.js +512 -0
  465. package/dist/runner/adapters/index.d.ts +8 -0
  466. package/dist/runner/adapters/index.d.ts.map +1 -0
  467. package/dist/runner/adapters/index.js +15 -0
  468. package/dist/runner/adapters/recipe-run-profile.d.ts +8 -0
  469. package/dist/runner/adapters/recipe-run-profile.d.ts.map +1 -0
  470. package/dist/runner/adapters/recipe-run-profile.js +53 -0
  471. package/dist/runner/adapters/shared.d.ts +45 -0
  472. package/dist/runner/adapters/shared.d.ts.map +1 -0
  473. package/dist/runner/adapters/shared.js +58 -0
  474. package/dist/runner/artifacts.d.ts +31 -0
  475. package/dist/runner/artifacts.d.ts.map +1 -0
  476. package/dist/runner/artifacts.js +153 -0
  477. package/dist/runner/codex-approval-probe.d.ts +23 -0
  478. package/dist/runner/codex-approval-probe.d.ts.map +1 -0
  479. package/dist/runner/codex-approval-probe.js +55 -0
  480. package/dist/runner/codex-smoke.d.ts +11 -0
  481. package/dist/runner/codex-smoke.d.ts.map +1 -0
  482. package/dist/runner/codex-smoke.js +45 -0
  483. package/dist/runner/config.d.ts +6 -0
  484. package/dist/runner/config.d.ts.map +1 -0
  485. package/dist/runner/config.js +15 -0
  486. package/dist/runner/context/base-prompts.d.ts +10 -0
  487. package/dist/runner/context/base-prompts.d.ts.map +1 -0
  488. package/dist/runner/context/base-prompts.js +255 -0
  489. package/dist/runner/context/recipe-context.d.ts +17 -0
  490. package/dist/runner/context/recipe-context.d.ts.map +1 -0
  491. package/dist/runner/context/recipe-context.js +48 -0
  492. package/dist/runner/context/task-context.d.ts +24 -0
  493. package/dist/runner/context/task-context.d.ts.map +1 -0
  494. package/dist/runner/context/task-context.js +266 -0
  495. package/dist/runner/index.d.ts +12 -0
  496. package/dist/runner/index.d.ts.map +1 -0
  497. package/dist/runner/index.js +11 -0
  498. package/dist/runner/policy-decision.d.ts +12 -0
  499. package/dist/runner/policy-decision.d.ts.map +1 -0
  500. package/dist/runner/policy-decision.js +89 -0
  501. package/dist/runner/policy-display.d.ts +4 -0
  502. package/dist/runner/policy-display.d.ts.map +1 -0
  503. package/dist/runner/policy-display.js +41 -0
  504. package/dist/runner/process-supervision.d.ts +48 -0
  505. package/dist/runner/process-supervision.d.ts.map +1 -0
  506. package/dist/runner/process-supervision.js +490 -0
  507. package/dist/runner/result-manifest-policy.d.ts +9 -0
  508. package/dist/runner/result-manifest-policy.d.ts.map +1 -0
  509. package/dist/runner/result-manifest-policy.js +96 -0
  510. package/dist/runner/result-manifest.d.ts +30 -0
  511. package/dist/runner/result-manifest.d.ts.map +1 -0
  512. package/dist/runner/result-manifest.js +322 -0
  513. package/dist/runner/run-id.d.ts +2 -0
  514. package/dist/runner/run-id.d.ts.map +1 -0
  515. package/dist/runner/run-id.js +3 -0
  516. package/dist/runner/run-repository.d.ts +51 -0
  517. package/dist/runner/run-repository.d.ts.map +1 -0
  518. package/dist/runner/run-repository.js +222 -0
  519. package/dist/runner/task-run-paths.d.ts +19 -0
  520. package/dist/runner/task-run-paths.d.ts.map +1 -0
  521. package/dist/runner/task-run-paths.js +25 -0
  522. package/dist/runner/task-state.d.ts +9 -0
  523. package/dist/runner/task-state.d.ts.map +1 -0
  524. package/dist/runner/task-state.js +354 -0
  525. package/dist/runner/test-helpers.d.ts +30 -0
  526. package/dist/runner/test-helpers.d.ts.map +1 -0
  527. package/dist/runner/test-helpers.js +97 -0
  528. package/dist/runner/trace-artifacts.d.ts +14 -0
  529. package/dist/runner/trace-artifacts.d.ts.map +1 -0
  530. package/dist/runner/trace-artifacts.js +80 -0
  531. package/dist/runner/trace.d.ts +10 -0
  532. package/dist/runner/trace.d.ts.map +1 -0
  533. package/dist/runner/trace.js +37 -0
  534. package/dist/runner/types.d.ts +317 -0
  535. package/dist/runner/types.d.ts.map +1 -0
  536. package/dist/runner/types.js +3 -0
  537. package/dist/runner/usecases/scenario-materialize-task.d.ts +29 -0
  538. package/dist/runner/usecases/scenario-materialize-task.d.ts.map +1 -0
  539. package/dist/runner/usecases/scenario-materialize-task.js +151 -0
  540. package/dist/runner/usecases/task-run-inspect.d.ts +41 -0
  541. package/dist/runner/usecases/task-run-inspect.d.ts.map +1 -0
  542. package/dist/runner/usecases/task-run-inspect.js +74 -0
  543. package/dist/runner/usecases/task-run-lifecycle-cancel.d.ts +10 -0
  544. package/dist/runner/usecases/task-run-lifecycle-cancel.d.ts.map +1 -0
  545. package/dist/runner/usecases/task-run-lifecycle-cancel.js +172 -0
  546. package/dist/runner/usecases/task-run-lifecycle-replay.d.ts +18 -0
  547. package/dist/runner/usecases/task-run-lifecycle-replay.d.ts.map +1 -0
  548. package/dist/runner/usecases/task-run-lifecycle-replay.js +128 -0
  549. package/dist/runner/usecases/task-run-lifecycle-shared.d.ts +45 -0
  550. package/dist/runner/usecases/task-run-lifecycle-shared.d.ts.map +1 -0
  551. package/dist/runner/usecases/task-run-lifecycle-shared.js +172 -0
  552. package/dist/runner/usecases/task-run-lifecycle.d.ts +4 -0
  553. package/dist/runner/usecases/task-run-lifecycle.d.ts.map +1 -0
  554. package/dist/runner/usecases/task-run-lifecycle.js +2 -0
  555. package/dist/runner/usecases/task-run.d.ts +32 -0
  556. package/dist/runner/usecases/task-run.d.ts.map +1 -0
  557. package/dist/runner/usecases/task-run.js +278 -0
  558. package/dist/shared/agent-emoji.d.ts.map +1 -1
  559. package/dist/shared/agent-emoji.js +1 -0
  560. package/dist/shared/errors.d.ts +1 -1
  561. package/dist/shared/errors.d.ts.map +1 -1
  562. package/dist/shared/guards.d.ts.map +1 -1
  563. package/dist/shared/guards.js +1 -0
  564. package/dist/shared/repo-cli-version.d.ts.map +1 -1
  565. package/dist/shared/repo-cli-version.js +7 -5
  566. package/dist/shared/task-doc-conflicts.d.ts +12 -0
  567. package/dist/shared/task-doc-conflicts.d.ts.map +1 -0
  568. package/dist/shared/task-doc-conflicts.js +40 -0
  569. package/dist/shared/task-doc-state.d.ts +10 -0
  570. package/dist/shared/task-doc-state.d.ts.map +1 -0
  571. package/dist/shared/task-doc-state.js +15 -0
  572. package/dist/test-helpers/fs.d.ts +2 -0
  573. package/dist/test-helpers/fs.d.ts.map +1 -0
  574. package/dist/test-helpers/fs.js +9 -0
  575. package/dist/usecases/context/resolve-context.d.ts +2 -0
  576. package/dist/usecases/context/resolve-context.d.ts.map +1 -1
  577. package/dist/usecases/context/resolve-context.js +4 -1
  578. package/dist/usecases/task/task-list-usecase.d.ts.map +1 -1
  579. package/dist/usecases/task/task-list-usecase.js +2 -8
  580. package/dist/workflow-runtime/fix.d.ts +9 -1
  581. package/dist/workflow-runtime/fix.d.ts.map +1 -1
  582. package/dist/workflow-runtime/fix.js +9 -1
  583. package/package.json +3 -2
  584. package/dist/backends/task-backend.test-helpers.d.ts +0 -4
  585. package/dist/backends/task-backend.test-helpers.d.ts.map +0 -1
  586. package/dist/backends/task-backend.test-helpers.js +0 -33
  587. package/dist/cli/run-cli/catalog.d.ts +0 -7
  588. package/dist/cli/run-cli/catalog.d.ts.map +0 -1
  589. package/dist/cli/run-cli/catalog.js +0 -22
  590. package/dist/cli/run-cli.core.pr-flow.test-helpers.d.ts +0 -3
  591. package/dist/cli/run-cli.core.pr-flow.test-helpers.d.ts.map +0 -1
  592. package/dist/cli/run-cli.core.pr-flow.test-helpers.js +0 -41
  593. package/dist/cli/run-cli.core.tasks.test-helpers.d.ts +0 -2
  594. package/dist/cli/run-cli.core.tasks.test-helpers.d.ts.map +0 -1
  595. package/dist/cli/run-cli.core.tasks.test-helpers.js +0 -6
  596. package/dist/commands/block.command.d.ts +0 -4
  597. package/dist/commands/block.command.d.ts.map +0 -1
  598. package/dist/commands/block.command.js +0 -2
  599. package/dist/commands/doctor.command.d.ts +0 -3
  600. package/dist/commands/doctor.command.d.ts.map +0 -1
  601. package/dist/commands/doctor.command.js +0 -2
  602. package/dist/commands/finish.command.d.ts +0 -4
  603. package/dist/commands/finish.command.d.ts.map +0 -1
  604. package/dist/commands/finish.command.js +0 -2
  605. package/dist/commands/recipes/install.command.d.ts +0 -3
  606. package/dist/commands/recipes/install.command.d.ts.map +0 -1
  607. package/dist/commands/recipes/install.command.js +0 -2
  608. package/dist/commands/start.command.d.ts +0 -4
  609. package/dist/commands/start.command.d.ts.map +0 -1
  610. package/dist/commands/start.command.js +0 -2
  611. package/dist/commands/task/list.command.d.ts +0 -4
  612. package/dist/commands/task/list.command.d.ts.map +0 -1
  613. package/dist/commands/task/list.command.js +0 -2
  614. package/dist/commands/task/next.command.d.ts +0 -4
  615. package/dist/commands/task/next.command.d.ts.map +0 -1
  616. package/dist/commands/task/next.command.js +0 -2
  617. package/dist/commands/task/search.command.d.ts +0 -4
  618. package/dist/commands/task/search.command.d.ts.map +0 -1
  619. package/dist/commands/task/search.command.js +0 -2
  620. package/dist/commands/task/show.command.d.ts +0 -4
  621. package/dist/commands/task/show.command.d.ts.map +0 -1
  622. package/dist/commands/task/show.command.js +0 -2
  623. package/dist/commands/verify.command.d.ts +0 -4
  624. package/dist/commands/verify.command.d.ts.map +0 -1
  625. package/dist/commands/verify.command.js +0 -2
@@ -1,202 +1,23 @@
1
- import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
2
- import os from "node:os";
1
+ import { mkdir, rm, writeFile } from "node:fs/promises";
3
2
  import path from "node:path";
4
- import { fileURLToPath } from "node:url";
5
3
  import { loadConfig, resolveProject } from "@agentplaneorg/core";
6
- import { fileExists, getPathKind } from "../cli/fs-utils.js";
7
- import { downloadToFile, fetchJson } from "../cli/http.js";
8
- import { parseSha256Text, sha256File } from "../cli/checksum.js";
9
- import { extractArchive } from "../cli/archive.js";
4
+ import { fileExists } from "../cli/fs-utils.js";
10
5
  import { exitCodeForError } from "../cli/exit-codes.js";
11
6
  import { warnMessage } from "../cli/output.js";
12
7
  import { CliError } from "../shared/errors.js";
13
8
  import { ensureWorkflowArtifacts } from "../shared/workflow-artifacts.js";
14
9
  import { checkTaskReadmeMigrationState } from "./doctor/workspace.js";
10
+ import { runOperatorPipeline } from "./shared/operator-pipeline.js";
15
11
  import { loadCommandContext } from "./shared/task-backend.js";
16
12
  import { ensureNetworkApproved } from "./shared/network-approval.js";
17
13
  import { migrateTaskDocsInWorkspace } from "./task/migrate-doc.js";
18
- import { getVersion } from "../meta/version.js";
19
14
  import { applyManagedFiles, cleanupAutoUpgradeArtifacts, createUpgradeCommit, ensureCleanTrackedTreeForUpgrade, persistUpgradeState, } from "./upgrade/apply.js";
15
+ import { materializeUpgradeSource } from "./upgrade/materialize.js";
16
+ import { planManagedUpgrade } from "./upgrade/plan.js";
17
+ import { CONFIG_REL_PATH, normalizeVersionForConfig, toUpgradeBaselineKey, } from "./upgrade/policy.js";
20
18
  import { printUpgradeDryRun, writeUpgradeAgentReview } from "./upgrade/report.js";
21
- import { describeUpgradeSource, loadFrameworkManifestFromPath, normalizeFrameworkSourceForUpgrade, resolveRepoTarballUrl, resolveUpgradeDownloadFromRelease, resolveUpgradeRoot, } from "./upgrade/source.js";
22
- const DEFAULT_UPGRADE_ASSET = "agentplane-upgrade.tar.gz";
23
- const DEFAULT_UPGRADE_CHECKSUM_ASSET = "agentplane-upgrade.tar.gz.sha256";
24
- const UPGRADE_DOWNLOAD_TIMEOUT_MS = 60_000;
25
- const UPGRADE_RELEASE_METADATA_TIMEOUT_MS = 15_000;
19
+ import { describeUpgradeSource } from "./upgrade/source.js";
26
20
  const ASSETS_DIR_URL = new URL("../../assets/", import.meta.url);
27
- function isDeniedUpgradePath(relPath) {
28
- if (relPath === ".agentplane/config.json")
29
- return true;
30
- if (relPath === ".agentplane/tasks.json")
31
- return true;
32
- if (relPath.startsWith(".agentplane/backends/"))
33
- return true;
34
- if (relPath.startsWith(".agentplane/worktrees/"))
35
- return true;
36
- if (relPath.startsWith(".agentplane/recipes/"))
37
- return true;
38
- if (relPath.startsWith(".agentplane/tasks/"))
39
- return true;
40
- if (relPath.startsWith(".agentplane/.upgrade/"))
41
- return true;
42
- if (relPath === ".git" || relPath.startsWith(".git/"))
43
- return true;
44
- return false;
45
- }
46
- function isAllowedUpgradePath(relPath) {
47
- if (relPath === "AGENTS.md")
48
- return true;
49
- if (relPath === "CLAUDE.md")
50
- return true;
51
- if (relPath.startsWith(".agentplane/agents/") && relPath.endsWith(".json"))
52
- return true;
53
- if (relPath.startsWith(".agentplane/policy/") &&
54
- (relPath.endsWith(".md") ||
55
- relPath.endsWith(".ts") ||
56
- relPath.endsWith(".js") ||
57
- relPath.endsWith(".mjs"))) {
58
- return true;
59
- }
60
- return false;
61
- }
62
- const INCIDENTS_POLICY_PATH = ".agentplane/policy/incidents.md";
63
- const INCIDENTS_APPEND_MARKER = "<!-- AGENTPLANE:UPGRADE-APPEND incidents.md -->";
64
- const CONFIG_REL_PATH = ".agentplane/config.json";
65
- function isJsonRecord(value) {
66
- return !!value && typeof value === "object" && !Array.isArray(value);
67
- }
68
- function canonicalizeJson(value) {
69
- if (Array.isArray(value))
70
- return value.map((v) => canonicalizeJson(v));
71
- if (isJsonRecord(value)) {
72
- const out = {};
73
- for (const k of Object.keys(value).toSorted()) {
74
- out[k] = canonicalizeJson(value[k]);
75
- }
76
- return out;
77
- }
78
- return value;
79
- }
80
- function jsonEqual(a, b) {
81
- const ca = JSON.stringify(canonicalizeJson(a)) ?? "__undefined__";
82
- const cb = JSON.stringify(canonicalizeJson(b)) ?? "__undefined__";
83
- return ca === cb;
84
- }
85
- function textChangedForType(opts) {
86
- if (opts.aText === null && opts.bText === null)
87
- return false;
88
- if (opts.aText === null || opts.bText === null)
89
- return true;
90
- if (opts.type === "json") {
91
- try {
92
- const a = JSON.parse(opts.aText);
93
- const b = JSON.parse(opts.bText);
94
- return !jsonEqual(a, b);
95
- }
96
- catch {
97
- return opts.aText.trim() !== opts.bText.trim();
98
- }
99
- }
100
- return opts.aText.trimEnd() !== opts.bText.trimEnd();
101
- }
102
- function parseIncidentEntryBlocks(entriesBody) {
103
- const lines = entriesBody.replaceAll("\r\n", "\n").split("\n");
104
- const starts = [];
105
- for (const [index, line] of lines.entries()) {
106
- if (/^\s*-\s*id:\s+/i.test(line ?? ""))
107
- starts.push(index);
108
- }
109
- const blocks = [];
110
- for (const [idx, start] of starts.entries()) {
111
- const end = starts.at(idx + 1) ?? lines.length;
112
- const slice = lines.slice(start, end);
113
- while (slice.length > 0 && !(slice[0] ?? "").trim())
114
- slice.shift();
115
- while (slice.length > 0 && !(slice.at(-1) ?? "").trim())
116
- slice.pop();
117
- const block = slice.join("\n").trim();
118
- if (block)
119
- blocks.push(block);
120
- }
121
- return blocks;
122
- }
123
- function normalizeEntryBlock(block) {
124
- return block
125
- .replaceAll("\r\n", "\n")
126
- .split("\n")
127
- .map((line) => line.trimEnd())
128
- .join("\n")
129
- .trim();
130
- }
131
- function splitEntriesSection(text) {
132
- const lines = text.replaceAll("\r\n", "\n").split("\n");
133
- const headingIndex = lines.findIndex((line) => /^\s*##\s+Entries\s*$/i.test(line));
134
- if (headingIndex === -1)
135
- return null;
136
- let nextHeadingIndex = lines.length;
137
- for (let i = headingIndex + 1; i < lines.length; i++) {
138
- if (/^\s*##\s+/.test(lines[i] ?? "")) {
139
- nextHeadingIndex = i;
140
- break;
141
- }
142
- }
143
- return {
144
- before: lines.slice(0, headingIndex + 1).join("\n"),
145
- entriesBody: lines.slice(headingIndex + 1, nextHeadingIndex).join("\n"),
146
- after: lines.slice(nextHeadingIndex).join("\n"),
147
- };
148
- }
149
- function mergeIncidentsPolicy(opts) {
150
- const incomingTrimmed = opts.incomingText.trim();
151
- if (!incomingTrimmed)
152
- return { nextText: opts.currentText, appended: false, appendedCount: 0 };
153
- const incomingSection = splitEntriesSection(opts.incomingText);
154
- const currentSection = splitEntriesSection(opts.currentText);
155
- if (!incomingSection || !currentSection) {
156
- return { nextText: opts.incomingText, appended: false, appendedCount: 0 };
157
- }
158
- const incomingBlocks = parseIncidentEntryBlocks(incomingSection.entriesBody).map((block) => normalizeEntryBlock(block));
159
- const currentBlocks = parseIncidentEntryBlocks(currentSection.entriesBody).map((block) => normalizeEntryBlock(block));
160
- if (currentBlocks.length === 0) {
161
- return { nextText: opts.incomingText, appended: false, appendedCount: 0 };
162
- }
163
- const baselineSection = opts.baselineText ? splitEntriesSection(opts.baselineText) : null;
164
- const baselineBlocks = baselineSection
165
- ? parseIncidentEntryBlocks(baselineSection.entriesBody).map((block) => normalizeEntryBlock(block))
166
- : [];
167
- const baselineSet = new Set(baselineBlocks);
168
- const incomingSet = new Set(incomingBlocks);
169
- const userAdded = currentBlocks.filter((block) => {
170
- if (baselineSet.size > 0 && baselineSet.has(block))
171
- return false;
172
- return true;
173
- });
174
- const toAppend = userAdded.filter((block) => !incomingSet.has(block));
175
- if (toAppend.length === 0) {
176
- return { nextText: opts.incomingText, appended: false, appendedCount: 0 };
177
- }
178
- const mergedBlocks = [...incomingBlocks, ...toAppend];
179
- const renderedEntries = mergedBlocks.length > 0 ? `\n\n${mergedBlocks.join("\n\n")}\n` : "\n\n- None yet.\n";
180
- const afterSuffix = incomingSection.after ? `\n${incomingSection.after.trimStart()}` : "";
181
- const nextText = `${incomingSection.before.trimEnd()}` +
182
- `${renderedEntries}` +
183
- `${INCIDENTS_APPEND_MARKER}\n` +
184
- `${afterSuffix}` +
185
- `\n`;
186
- return { nextText, appended: true, appendedCount: toAppend.length };
187
- }
188
- function normalizeUpgradeVersionLabel(input) {
189
- const trimmed = input.trim();
190
- if (!trimmed)
191
- return "unknown";
192
- if (/^v\d/i.test(trimmed))
193
- return trimmed;
194
- return `v${trimmed}`;
195
- }
196
- function normalizeVersionForConfig(input) {
197
- const trimmed = input.trim().replace(/^v/i, "");
198
- return trimmed.length > 0 ? trimmed : null;
199
- }
200
21
  export async function cmdUpgradeParsed(opts) {
201
22
  const flags = opts.flags;
202
23
  if ((flags.bundle && !flags.checksum) || (!flags.bundle && flags.checksum)) {
@@ -250,482 +71,173 @@ export async function cmdUpgradeParsed(opts) {
250
71
  Boolean(flags.asset) ||
251
72
  Boolean(flags.checksumAsset);
252
73
  const useRemote = flags.remote === true || hasRemoteHints;
253
- let tempRoot = null;
254
- let extractRoot = null;
255
74
  const createdBackups = [];
256
- try {
257
- tempRoot = await mkdtemp(path.join(os.tmpdir(), "agentplane-upgrade-"));
258
- let bundlePath = "";
259
- let checksumPath = "";
260
- let bundleLayout = "upgrade_bundle";
261
- let bundleRoot = "";
262
- let normalizedSourceToPersist = null;
263
- let upgradeVersionLabel = normalizeUpgradeVersionLabel(getVersion());
264
- if (!hasBundle && !useRemote) {
265
- bundleLayout = "local_assets";
266
- bundleRoot = fileURLToPath(ASSETS_DIR_URL);
267
- }
268
- else if (flags.bundle) {
269
- const isUrl = flags.bundle.startsWith("http://") || flags.bundle.startsWith("https://");
270
- bundlePath = isUrl ? path.join(tempRoot, "bundle.tar.gz") : path.resolve(flags.bundle);
271
- if (isUrl) {
272
- await ensureApproved("upgrade downloads the bundle/checksum from the network");
273
- await downloadToFile(flags.bundle, bundlePath, UPGRADE_DOWNLOAD_TIMEOUT_MS);
274
- }
275
- const checksumValue = flags.checksum ?? "";
276
- const checksumIsUrl = checksumValue.startsWith("http://") || checksumValue.startsWith("https://");
277
- checksumPath = checksumIsUrl
278
- ? path.join(tempRoot, "bundle.tar.gz.sha256")
279
- : path.resolve(checksumValue);
280
- if (checksumIsUrl) {
281
- await ensureApproved("upgrade downloads the bundle/checksum from the network");
282
- await downloadToFile(checksumValue, checksumPath, UPGRADE_DOWNLOAD_TIMEOUT_MS);
283
- }
284
- }
285
- else {
286
- const sourceFromFlags = typeof flags.source === "string" && flags.source.trim().length > 0;
287
- const originalSource = flags.source ?? loaded.config.framework.source;
288
- const normalized = normalizeFrameworkSourceForUpgrade(originalSource);
289
- if (!sourceFromFlags && normalized.migrated) {
290
- normalizedSourceToPersist = normalized.source;
291
- }
292
- if (normalized.migrated) {
293
- process.stderr.write(`${warnMessage(`config.framework.source uses deprecated repo basilisk-labs/agent-plane; using ${normalized.source}`)}\n`);
294
- }
295
- const { owner, repo } = normalized;
296
- const releaseUrl = flags.tag
297
- ? `https://api.github.com/repos/${owner}/${repo}/releases/tags/${flags.tag}`
298
- : `https://api.github.com/repos/${owner}/${repo}/releases/latest`;
299
- await ensureApproved("upgrade fetches release metadata and downloads assets from the network");
300
- const assetName = flags.asset ?? DEFAULT_UPGRADE_ASSET;
301
- const checksumName = flags.checksumAsset ?? DEFAULT_UPGRADE_CHECKSUM_ASSET;
302
- const release = (await fetchJson(releaseUrl, UPGRADE_RELEASE_METADATA_TIMEOUT_MS));
303
- const releaseTag = (typeof release.tag_name === "string" && release.tag_name.trim()) ||
304
- (typeof flags.tag === "string" && flags.tag.trim()) ||
305
- "";
306
- if (releaseTag) {
307
- upgradeVersionLabel = normalizeUpgradeVersionLabel(releaseTag);
308
- }
309
- const download = resolveUpgradeDownloadFromRelease({
310
- release,
311
- owner,
312
- repo,
313
- assetName,
314
- checksumName,
315
- });
316
- if (download.kind === "assets") {
317
- bundlePath = path.join(tempRoot, assetName);
318
- checksumPath = path.join(tempRoot, checksumName);
319
- await downloadToFile(download.bundleUrl, bundlePath, UPGRADE_DOWNLOAD_TIMEOUT_MS);
320
- await downloadToFile(download.checksumUrl, checksumPath, UPGRADE_DOWNLOAD_TIMEOUT_MS);
321
- }
322
- else {
323
- if (!flags.allowTarball) {
324
- throw new CliError({
325
- exitCode: exitCodeForError("E_NETWORK"),
326
- code: "E_NETWORK",
327
- message: `Upgrade assets ${assetName}/${checksumName} not found in ${owner}/${repo} release. ` +
328
- "Publish the upgrade bundle assets, or re-run with --allow-tarball to download a repo tarball (no checksum verification).",
329
- });
330
- }
331
- process.stderr.write(`${warnMessage(`upgrade release does not include ${assetName}/${checksumName}; falling back to repo tarball without checksum verification`)}\n`);
332
- bundleLayout = "repo_tarball";
333
- bundlePath = path.join(tempRoot, "source.tar.gz");
334
- const tarballUrl = resolveRepoTarballUrl({
335
- release,
336
- owner,
337
- repo,
338
- explicitTag: flags.tag,
339
- });
340
- await downloadToFile(tarballUrl, bundlePath, UPGRADE_DOWNLOAD_TIMEOUT_MS);
341
- checksumPath = "";
342
- }
343
- }
344
- if (bundleLayout !== "local_assets" && checksumPath) {
345
- const expected = parseSha256Text(await readFile(checksumPath, "utf8"));
346
- if (!expected) {
347
- throw new CliError({
348
- exitCode: 3,
349
- code: "E_VALIDATION",
350
- message: "Upgrade checksum file is empty or invalid",
351
- });
352
- }
353
- const actual = await sha256File(bundlePath);
354
- if (actual !== expected) {
355
- throw new CliError({
356
- exitCode: 3,
357
- code: "E_VALIDATION",
358
- message: `Upgrade checksum mismatch (expected ${expected}, got ${actual})`,
359
- });
360
- }
361
- }
362
- if (bundleLayout !== "local_assets") {
363
- extractRoot = await mkdtemp(path.join(os.tmpdir(), "agentplane-upgrade-extract-"));
364
- await extractArchive({
365
- archivePath: bundlePath,
366
- destDir: extractRoot,
75
+ let materialized = null;
76
+ return await runOperatorPipeline({
77
+ init: () => null,
78
+ materialize: async () => {
79
+ materialized = await materializeUpgradeSource({
80
+ flags,
81
+ frameworkSource: loaded.config.framework.source,
82
+ assetsDirUrl: ASSETS_DIR_URL,
83
+ ensureApproved,
367
84
  });
368
- const extractedRoot = await resolveUpgradeRoot(extractRoot);
369
- bundleRoot =
370
- bundleLayout === "repo_tarball"
371
- ? path.join(extractedRoot, "packages", "agentplane", "assets")
372
- : extractedRoot;
373
- }
374
- const manifestPath = bundleLayout === "local_assets"
375
- ? fileURLToPath(new URL("../../assets/framework.manifest.json", import.meta.url))
376
- : path.join(bundleRoot, "framework.manifest.json");
377
- const manifest = await loadFrameworkManifestFromPath(manifestPath);
378
- const modeLabel = flags.dryRun ? "dry-run" : flags.mode === "agent" ? "review" : "apply";
379
- process.stdout.write(`Upgrade source: ${describeUpgradeSource({
380
- bundleLayout,
381
- hasExplicitBundle: hasBundle,
382
- useRemote,
383
- })}\n` +
384
- `Upgrade version: ${upgradeVersionLabel}\n` +
385
- `Upgrade mode: ${modeLabel}\n`);
386
- const additions = [];
387
- const updates = [];
388
- const skipped = [];
389
- const fileContents = new Map();
390
- const merged = [];
391
- const missingRequired = [];
392
- const reviewRecords = [];
393
- let incidentsAppendedCount = 0;
394
- const readBaselineText = async (baselineKey) => {
395
- try {
396
- return await readFile(path.join(baselineDirNew, baselineKey), "utf8");
397
- }
398
- catch {
399
- // Back-compat: older upgrades wrote baselines under .agentplane/upgrade/baseline.
400
- try {
401
- return await readFile(path.join(baselineDirLegacy, baselineKey), "utf8");
402
- }
403
- catch {
404
- return null;
405
- }
406
- }
407
- };
408
- const toBaselineKey = (rel) => {
409
- if (rel === "AGENTS.md")
410
- return "AGENTS.md";
411
- if (rel === "CLAUDE.md")
412
- return "CLAUDE.md";
413
- if (rel.startsWith(".agentplane/"))
414
- return rel.slice(".agentplane/".length);
415
- return null;
416
- };
417
- const policyGatewayRel = (await fileExists(path.join(resolved.gitRoot, "AGENTS.md")))
418
- ? "AGENTS.md"
419
- : (await fileExists(path.join(resolved.gitRoot, "CLAUDE.md")))
420
- ? "CLAUDE.md"
421
- : "AGENTS.md";
422
- const remapManagedGatewayRel = (rel) => {
423
- if (rel === "AGENTS.md" && policyGatewayRel === "CLAUDE.md")
424
- return "CLAUDE.md";
425
- return rel;
426
- };
427
- for (const entry of manifest.files) {
428
- const relRaw = entry.path.replaceAll("\\", "/").trim();
429
- if (!relRaw || relRaw.startsWith("..") || path.isAbsolute(relRaw)) {
430
- throw new CliError({
431
- exitCode: 3,
432
- code: "E_VALIDATION",
433
- message: `Invalid manifest path: ${entry.path}`,
434
- });
435
- }
436
- if (isDeniedUpgradePath(relRaw)) {
437
- throw new CliError({
438
- exitCode: 3,
439
- code: "E_VALIDATION",
440
- message: `Manifest includes a denied path: ${relRaw}`,
441
- });
442
- }
443
- if (!isAllowedUpgradePath(relRaw)) {
444
- throw new CliError({
445
- exitCode: 3,
446
- code: "E_VALIDATION",
447
- message: `Manifest path not allowed: ${relRaw}`,
448
- });
449
- }
450
- const rel = remapManagedGatewayRel(relRaw);
451
- const destPath = path.join(resolved.gitRoot, rel);
452
- const kind = await getPathKind(destPath);
453
- if (kind === "dir") {
85
+ const modeLabel = flags.dryRun ? "dry-run" : flags.mode === "agent" ? "review" : "apply";
86
+ process.stdout.write(`Upgrade source: ${describeUpgradeSource({
87
+ bundleLayout: materialized.bundleLayout,
88
+ hasExplicitBundle: hasBundle,
89
+ useRemote,
90
+ })}\n` +
91
+ `Upgrade version: ${materialized.upgradeVersionLabel}\n` +
92
+ `Upgrade mode: ${modeLabel}\n`);
93
+ },
94
+ execute: async () => {
95
+ if (!materialized) {
454
96
  throw new CliError({
455
97
  exitCode: exitCodeForError("E_IO"),
456
98
  code: "E_IO",
457
- message: `Upgrade target is a directory: ${rel}`,
458
- });
459
- }
460
- let data;
461
- {
462
- const sourceRelRaw = (entry.source_path ?? entry.path).replaceAll("\\", "/").trim();
463
- const mappedSourceRel = rel === "CLAUDE.md" && sourceRelRaw === "AGENTS.md" ? "CLAUDE.md" : sourceRelRaw;
464
- const sourceCandidates = [...new Set([mappedSourceRel, sourceRelRaw])];
465
- let loaded = null;
466
- for (const candidate of sourceCandidates) {
467
- try {
468
- loaded = await readFile(path.join(bundleRoot, candidate));
469
- break;
470
- }
471
- catch {
472
- // try next candidate
473
- }
474
- }
475
- if (!loaded) {
476
- if (entry.required)
477
- missingRequired.push(rel);
478
- continue;
479
- }
480
- data = loaded;
481
- }
482
- let existingBuf = null;
483
- let existingText = null;
484
- if (kind !== null) {
485
- existingBuf = await readFile(destPath);
486
- }
487
- const incomingTextOriginal = data.toString("utf8");
488
- const currentTextForReview = existingBuf ? existingBuf.toString("utf8") : null;
489
- const baselineKey = toBaselineKey(rel);
490
- const baselineText = baselineKey ? await readBaselineText(baselineKey) : null;
491
- const hasBaseline = baselineText !== null;
492
- const changedCurrentVsBaseline = hasBaseline && currentTextForReview !== null
493
- ? textChangedForType({
494
- type: entry.type,
495
- aText: currentTextForReview,
496
- bText: baselineText,
497
- })
498
- : null;
499
- const changedIncomingVsBaseline = hasBaseline
500
- ? textChangedForType({
501
- type: entry.type,
502
- aText: incomingTextOriginal,
503
- bText: baselineText,
504
- })
505
- : null;
506
- const currentAndIncomingEqual = currentTextForReview === null
507
- ? false
508
- : textChangedForType({
509
- type: entry.type,
510
- aText: currentTextForReview,
511
- bText: incomingTextOriginal,
512
- }) === false;
513
- // Fast-path: incoming already equals local.
514
- if (currentTextForReview !== null && currentAndIncomingEqual) {
515
- skipped.push(rel);
516
- reviewRecords.push({
517
- relPath: rel,
518
- mergeStrategy: entry.merge_strategy,
519
- hasBaseline,
520
- changedCurrentVsBaseline,
521
- changedIncomingVsBaseline,
522
- currentDiffersFromIncoming: false,
523
- needsSemanticReview: false,
524
- mergeApplied: false,
525
- mergePath: "none",
99
+ message: "Upgrade bundle did not materialize correctly",
526
100
  });
527
- continue;
528
101
  }
529
- // No local edits vs baseline: file can be safely replaced with incoming.
530
- if (currentTextForReview !== null && changedCurrentVsBaseline === false) {
531
- updates.push(rel);
532
- fileContents.set(rel, data);
533
- reviewRecords.push({
534
- relPath: rel,
535
- mergeStrategy: entry.merge_strategy,
536
- hasBaseline,
537
- changedCurrentVsBaseline,
538
- changedIncomingVsBaseline,
539
- currentDiffersFromIncoming: true,
540
- needsSemanticReview: false,
541
- mergeApplied: false,
542
- mergePath: "none",
543
- });
544
- continue;
102
+ const { additions, updates, skipped, merged, fileContents, reviewRecords, incidentsAppendedCount, } = await planManagedUpgrade({
103
+ gitRoot: resolved.gitRoot,
104
+ manifest: materialized.manifest,
105
+ bundleRoot: materialized.bundleRoot,
106
+ baselineDirNew,
107
+ baselineDirLegacy,
108
+ });
109
+ if (flags.dryRun) {
110
+ printUpgradeDryRun({ additions, updates, skipped, merged });
111
+ return 0;
545
112
  }
546
- let mergeApplied = false;
547
- let mergePath = "none";
548
- // Simplified policy for upgrade:
549
- // - All managed files are replaced with incoming bundle content.
550
- // - incidents.md is append-only when local file already has content.
551
- if (existingBuf && rel === INCIDENTS_POLICY_PATH) {
552
- existingText = existingBuf.toString("utf8");
553
- const mergedIncidents = mergeIncidentsPolicy({
554
- incomingText: data.toString("utf8"),
555
- currentText: existingText,
556
- baselineText,
557
- });
558
- data = Buffer.from(mergedIncidents.nextText, "utf8");
559
- if (mergedIncidents.appended) {
560
- merged.push(rel);
561
- mergeApplied = true;
562
- mergePath = "incidentsAppend";
563
- incidentsAppendedCount += mergedIncidents.appendedCount;
113
+ const needsReview = reviewRecords.filter((r) => r.needsSemanticReview);
114
+ if (flags.mode === "agent") {
115
+ // Fast no-op path: nothing to apply and no semantic review candidates.
116
+ // Skip generating per-run artifacts to keep agent-mode upgrades cheap.
117
+ if (additions.length === 0 && updates.length === 0 && needsReview.length === 0) {
118
+ process.stdout.write("Upgrade plan: no managed changes detected\n");
119
+ return 0;
564
120
  }
565
- }
566
- const currentDiffersFromIncoming = currentTextForReview === null
567
- ? false
568
- : textChangedForType({
569
- type: entry.type,
570
- aText: currentTextForReview,
571
- bText: incomingTextOriginal,
121
+ const { relRunDir, needsReviewCount } = await writeUpgradeAgentReview({
122
+ gitRoot: resolved.gitRoot,
123
+ runRoot: path.join(upgradeStateDir, "agent"),
124
+ manifest: materialized.manifest,
125
+ additions,
126
+ updates,
127
+ skipped,
128
+ merged,
129
+ reviewRecords,
572
130
  });
573
- const needsSemanticReview = false;
574
- reviewRecords.push({
575
- relPath: rel,
576
- mergeStrategy: entry.merge_strategy,
577
- hasBaseline,
578
- changedCurrentVsBaseline,
579
- changedIncomingVsBaseline,
580
- currentDiffersFromIncoming,
581
- needsSemanticReview,
582
- mergeApplied,
583
- mergePath,
584
- });
585
- fileContents.set(rel, data);
586
- if (kind === null)
587
- additions.push(rel);
588
- else if (existingBuf && Buffer.compare(existingBuf, data) === 0)
589
- skipped.push(rel);
590
- else
591
- updates.push(rel);
592
- }
593
- if (missingRequired.length > 0) {
594
- throw new CliError({
595
- exitCode: 3,
596
- code: "E_VALIDATION",
597
- message: `Upgrade bundle is missing required managed files: ${missingRequired.join(", ")}`,
598
- });
599
- }
600
- if (flags.dryRun) {
601
- printUpgradeDryRun({ additions, updates, skipped, merged });
602
- return 0;
603
- }
604
- const needsReview = reviewRecords.filter((r) => r.needsSemanticReview);
605
- if (flags.mode === "agent") {
606
- // Fast no-op path: nothing to apply and no semantic review candidates.
607
- // Skip generating per-run artifacts to keep agent-mode upgrades cheap.
608
- if (additions.length === 0 && updates.length === 0 && needsReview.length === 0) {
609
- process.stdout.write("Upgrade plan: no managed changes detected\n");
131
+ process.stdout.write(`Upgrade plan written: ${relRunDir}\n`);
132
+ process.stdout.write(`Review-required files: ${needsReviewCount}\n`);
610
133
  return 0;
611
134
  }
612
- const { relRunDir, needsReviewCount } = await writeUpgradeAgentReview({
135
+ await applyManagedFiles({
613
136
  gitRoot: resolved.gitRoot,
614
- runRoot: path.join(upgradeStateDir, "agent"),
615
- manifest,
616
137
  additions,
617
138
  updates,
618
- skipped,
619
- merged,
139
+ backup: flags.backup,
140
+ fileContents,
141
+ baselineDir: baselineDirNew,
142
+ createdBackups,
143
+ toBaselineKey: toUpgradeBaselineKey,
144
+ });
145
+ const migratedTaskDocs = flags.migrateTaskDocs
146
+ ? await migrateTaskDocsInWorkspace({
147
+ cwd: opts.cwd,
148
+ rootOverride: opts.rootOverride ?? null,
149
+ all: true,
150
+ taskIds: [],
151
+ resolvedProject: resolved,
152
+ config: loaded.config,
153
+ ctx: commandCtx,
154
+ })
155
+ : { changed: 0, changedPaths: [] };
156
+ if (flags.migrateTaskDocs) {
157
+ const details = migratedTaskDocs.changed > 0 ? `changed=${migratedTaskDocs.changed}` : "already current";
158
+ process.stdout.write(`Task README migration: ${details}\n`);
159
+ }
160
+ const hasManagedMutations = additions.length > 0 || updates.length > 0;
161
+ const shouldMutateConfig = await persistUpgradeState({
162
+ agentplaneDir: resolved.agentplaneDir,
163
+ rawConfig: loaded.raw,
164
+ normalizedSourceToPersist: materialized.normalizedSourceToPersist,
165
+ expectedCliVersionToPersist: normalizeVersionForConfig(materialized.upgradeVersionLabel),
166
+ hasManagedMutations,
167
+ statePath,
168
+ upgradeStateDir,
169
+ source: materialized.bundleLayout,
620
170
  reviewRecords,
171
+ additions: additions.length,
172
+ updates: updates.length,
173
+ skipped: skipped.length,
621
174
  });
622
- process.stdout.write(`Upgrade plan written: ${relRunDir}\n`);
623
- process.stdout.write(`Review-required files: ${needsReviewCount}\n`);
624
- return 0;
625
- }
626
- await applyManagedFiles({
627
- gitRoot: resolved.gitRoot,
628
- additions,
629
- updates,
630
- backup: flags.backup,
631
- fileContents,
632
- baselineDir: baselineDirNew,
633
- createdBackups,
634
- toBaselineKey,
635
- });
636
- const migratedTaskDocs = flags.migrateTaskDocs
637
- ? await migrateTaskDocsInWorkspace({
638
- cwd: opts.cwd,
639
- rootOverride: opts.rootOverride ?? null,
640
- all: true,
641
- taskIds: [],
642
- resolvedProject: resolved,
643
- config: loaded.config,
644
- ctx: commandCtx,
645
- })
646
- : { changed: 0, changedPaths: [] };
647
- if (flags.migrateTaskDocs) {
648
- const details = migratedTaskDocs.changed > 0 ? `changed=${migratedTaskDocs.changed}` : "already current";
649
- process.stdout.write(`Task README migration: ${details}\n`);
650
- }
651
- const hasManagedMutations = additions.length > 0 || updates.length > 0;
652
- const shouldMutateConfig = await persistUpgradeState({
653
- agentplaneDir: resolved.agentplaneDir,
654
- rawConfig: loaded.raw,
655
- normalizedSourceToPersist,
656
- expectedCliVersionToPersist: normalizeVersionForConfig(upgradeVersionLabel),
657
- hasManagedMutations,
658
- statePath,
659
- upgradeStateDir,
660
- source: bundleLayout,
661
- reviewRecords,
662
- additions: additions.length,
663
- updates: updates.length,
664
- skipped: skipped.length,
665
- });
666
- const orchestratorProfilePath = path.join(resolved.agentplaneDir, "agents", "ORCHESTRATOR.json");
667
- const workflowArtifacts = (await fileExists(orchestratorProfilePath))
668
- ? await ensureWorkflowArtifacts({
175
+ const orchestratorProfilePath = path.join(resolved.agentplaneDir, "agents", "ORCHESTRATOR.json");
176
+ const workflowArtifacts = (await fileExists(orchestratorProfilePath))
177
+ ? await ensureWorkflowArtifacts({
178
+ gitRoot: resolved.gitRoot,
179
+ workflowMode: loaded.config.workflow_mode,
180
+ approvals: {
181
+ requirePlanApproval: loaded.config.agents?.approvals?.require_plan ?? true,
182
+ requireVerifyApproval: loaded.config.agents?.approvals?.require_verify ?? true,
183
+ requireNetworkApproval: loaded.config.agents?.approvals?.require_network ?? true,
184
+ },
185
+ })
186
+ : { installPaths: [], commitPaths: [], changedPaths: [] };
187
+ const commitPaths = [
188
+ ...new Set([
189
+ ...additions,
190
+ ...updates,
191
+ ...migratedTaskDocs.changedPaths,
192
+ ...workflowArtifacts.commitPaths,
193
+ ...(shouldMutateConfig ? [CONFIG_REL_PATH] : []),
194
+ ]),
195
+ ];
196
+ const commit = await createUpgradeCommit({
669
197
  gitRoot: resolved.gitRoot,
670
- workflowMode: loaded.config.workflow_mode,
671
- approvals: {
672
- requirePlanApproval: loaded.config.agents?.approvals?.require_plan ?? true,
673
- requireVerifyApproval: loaded.config.agents?.approvals?.require_verify ?? true,
674
- requireNetworkApproval: loaded.config.agents?.approvals?.require_network ?? true,
675
- },
676
- })
677
- : { installPaths: [], commitPaths: [], changedPaths: [] };
678
- const commitPaths = [
679
- ...new Set([
680
- ...additions,
681
- ...updates,
682
- ...migratedTaskDocs.changedPaths,
683
- ...workflowArtifacts.commitPaths,
684
- ...(shouldMutateConfig ? [CONFIG_REL_PATH] : []),
685
- ]),
686
- ];
687
- const commit = await createUpgradeCommit({
688
- gitRoot: resolved.gitRoot,
689
- paths: commitPaths,
690
- tasksPath: loaded.config.paths.tasks_path,
691
- workflowDir: loaded.config.paths.workflow_dir,
692
- versionLabel: upgradeVersionLabel,
693
- source: bundleLayout,
694
- additions: additions.length,
695
- updates: updates.length,
696
- unchanged: skipped.length,
697
- incidentsAppendedCount,
698
- });
699
- await cleanupAutoUpgradeArtifacts({ upgradeStateDir, createdBackups });
700
- process.stdout.write(`Upgrade applied: ${additions.length} add, ${updates.length} update, ${skipped.length} unchanged\n`);
701
- if (workflowArtifacts.changedPaths.length > 0) {
702
- process.stdout.write(`Workflow artifacts refreshed: ${workflowArtifacts.commitPaths.join(", ")}\n`);
703
- }
704
- if (commit) {
705
- process.stdout.write(`Upgrade commit: ${commit.hash.slice(0, 12)} ${commit.subject}\n`);
706
- }
707
- const taskReadmeMigrationFindings = await checkTaskReadmeMigrationState(resolved.gitRoot, commandCtx);
708
- if (taskReadmeMigrationFindings.length > 0) {
709
- process.stderr.write(`${warnMessage("upgrade post-check: task README migration follow-up detected")}\n`);
710
- for (const finding of taskReadmeMigrationFindings) {
711
- process.stderr.write(`- ${finding}\n`);
198
+ paths: commitPaths,
199
+ tasksPath: loaded.config.paths.tasks_path,
200
+ workflowDir: loaded.config.paths.workflow_dir,
201
+ versionLabel: materialized.upgradeVersionLabel,
202
+ source: materialized.bundleLayout,
203
+ additions: additions.length,
204
+ updates: updates.length,
205
+ unchanged: skipped.length,
206
+ incidentsAppendedCount,
207
+ });
208
+ await cleanupAutoUpgradeArtifacts({ upgradeStateDir, createdBackups });
209
+ process.stdout.write(`Upgrade applied: ${additions.length} add, ${updates.length} update, ${skipped.length} unchanged\n`);
210
+ if (workflowArtifacts.changedPaths.length > 0) {
211
+ process.stdout.write(`Workflow artifacts refreshed: ${workflowArtifacts.commitPaths.join(", ")}\n`);
212
+ }
213
+ if (commit) {
214
+ process.stdout.write(`Upgrade commit: ${commit.hash.slice(0, 12)} ${commit.subject}\n`);
215
+ }
216
+ const taskReadmeMigrationFindings = await checkTaskReadmeMigrationState(resolved.gitRoot, commandCtx);
217
+ if (taskReadmeMigrationFindings.length > 0) {
218
+ process.stderr.write(`${warnMessage("upgrade post-check: task README migration follow-up detected")}\n`);
219
+ for (const finding of taskReadmeMigrationFindings) {
220
+ process.stderr.write(`- ${finding}\n`);
221
+ }
712
222
  }
713
- }
714
- return 0;
715
- }
716
- finally {
717
- if (extractRoot)
718
- await rm(extractRoot, { recursive: true, force: true });
719
- if (tempRoot)
720
- await rm(tempRoot, { recursive: true, force: true });
721
- if (lockAcquired) {
722
- try {
723
- await rm(lockPath, { force: true });
223
+ return 0;
224
+ },
225
+ cleanup: async () => {
226
+ if (materialized?.extractRoot) {
227
+ await rm(materialized.extractRoot, { recursive: true, force: true });
724
228
  }
725
- catch {
726
- // best-effort cleanup
229
+ if (materialized?.tempRoot) {
230
+ await rm(materialized.tempRoot, { recursive: true, force: true });
727
231
  }
728
- }
729
- }
232
+ if (lockAcquired) {
233
+ try {
234
+ await rm(lockPath, { force: true });
235
+ }
236
+ catch {
237
+ // best-effort cleanup
238
+ }
239
+ }
240
+ },
241
+ });
730
242
  }
731
243
  export { normalizeFrameworkSourceForUpgrade, resolveRepoTarballUrl, resolveUpgradeDownloadFromRelease, } from "./upgrade/source.js";