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