agentplane 0.3.7 → 0.3.9

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 (619) 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 +692 -337
  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 +122 -12
  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/hooks/index.d.ts.map +1 -1
  183. package/dist/commands/hooks/index.js +8 -4
  184. package/dist/commands/pr/check.d.ts.map +1 -1
  185. package/dist/commands/pr/check.js +90 -18
  186. package/dist/commands/pr/integrate/cmd.d.ts.map +1 -1
  187. package/dist/commands/pr/integrate/cmd.js +31 -3
  188. package/dist/commands/pr/integrate/internal/cleanup.d.ts +12 -0
  189. package/dist/commands/pr/integrate/internal/cleanup.d.ts.map +1 -0
  190. package/dist/commands/pr/integrate/internal/cleanup.js +46 -0
  191. package/dist/commands/pr/integrate/internal/finalize.d.ts +4 -0
  192. package/dist/commands/pr/integrate/internal/finalize.d.ts.map +1 -1
  193. package/dist/commands/pr/integrate/internal/finalize.js +34 -40
  194. package/dist/commands/pr/integrate/internal/merge.d.ts +6 -0
  195. package/dist/commands/pr/integrate/internal/merge.d.ts.map +1 -1
  196. package/dist/commands/pr/integrate/internal/merge.js +92 -0
  197. package/dist/commands/pr/integrate/internal/prepare.d.ts +1 -0
  198. package/dist/commands/pr/integrate/internal/prepare.d.ts.map +1 -1
  199. package/dist/commands/pr/integrate/internal/prepare.js +1 -0
  200. package/dist/commands/pr/integrate/verify.d.ts.map +1 -1
  201. package/dist/commands/pr/integrate/verify.js +4 -3
  202. package/dist/commands/pr/note.d.ts.map +1 -1
  203. package/dist/commands/pr/note.js +3 -2
  204. package/dist/commands/pr/open.d.ts.map +1 -1
  205. package/dist/commands/pr/open.js +9 -12
  206. package/dist/commands/pr/pr.command.d.ts +3 -4
  207. package/dist/commands/pr/pr.command.d.ts.map +1 -1
  208. package/dist/commands/pr/pr.command.js +6 -11
  209. package/dist/commands/pr/update.d.ts.map +1 -1
  210. package/dist/commands/pr/update.js +5 -10
  211. package/dist/commands/recipes/cache.command.d.ts +3 -4
  212. package/dist/commands/recipes/cache.command.d.ts.map +1 -1
  213. package/dist/commands/recipes/cache.command.js +8 -26
  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/installed-recipes.d.ts.map +1 -1
  217. package/dist/commands/recipes/impl/installed-recipes.js +1 -1
  218. package/dist/commands/recipes/impl/manifest.d.ts.map +1 -1
  219. package/dist/commands/recipes/impl/manifest.js +0 -10
  220. package/dist/commands/recipes/impl/project-installed-recipes.d.ts.map +1 -1
  221. package/dist/commands/recipes/impl/project-installed-recipes.js +1 -1
  222. package/dist/commands/recipes/impl/resolver.d.ts +1 -1
  223. package/dist/commands/recipes/impl/resolver.d.ts.map +1 -1
  224. package/dist/commands/recipes/impl/resolver.js +26 -16
  225. package/dist/commands/recipes/impl/scenario.d.ts.map +1 -1
  226. package/dist/commands/recipes/impl/scenario.js +80 -0
  227. package/dist/commands/recipes/impl/types.d.ts +27 -13
  228. package/dist/commands/recipes/impl/types.d.ts.map +1 -1
  229. package/dist/commands/recipes/recipes.command.d.ts +3 -4
  230. package/dist/commands/recipes/recipes.command.d.ts.map +1 -1
  231. package/dist/commands/recipes/recipes.command.js +8 -34
  232. package/dist/commands/recipes.d.ts.map +1 -1
  233. package/dist/commands/recipes.test-helpers.d.ts +17 -0
  234. package/dist/commands/recipes.test-helpers.d.ts.map +1 -1
  235. package/dist/commands/recipes.test-helpers.js +56 -2
  236. package/dist/commands/release/apply.command.d.ts.map +1 -1
  237. package/dist/commands/release/apply.command.js +77 -56
  238. package/dist/commands/release/plan.command.d.ts.map +1 -1
  239. package/dist/commands/release/plan.command.js +7 -3
  240. package/dist/commands/release/release.command.d.ts +3 -3
  241. package/dist/commands/release/release.command.d.ts.map +1 -1
  242. package/dist/commands/release/release.command.js +9 -11
  243. package/dist/commands/release.test-helpers.d.ts +34 -0
  244. package/dist/commands/release.test-helpers.d.ts.map +1 -0
  245. package/dist/commands/release.test-helpers.js +48 -0
  246. package/dist/commands/runtime.command.d.ts +7 -7
  247. package/dist/commands/runtime.command.d.ts.map +1 -1
  248. package/dist/commands/runtime.command.js +29 -33
  249. package/dist/commands/scenario/execute.command.d.ts +8 -0
  250. package/dist/commands/scenario/execute.command.d.ts.map +1 -0
  251. package/dist/commands/scenario/execute.command.js +117 -0
  252. package/dist/commands/scenario/impl/commands.d.ts.map +1 -1
  253. package/dist/commands/scenario/impl/commands.js +45 -32
  254. package/dist/commands/scenario/run.command.js +2 -2
  255. package/dist/commands/scenario/scenario.command.d.ts +3 -4
  256. package/dist/commands/scenario/scenario.command.d.ts.map +1 -1
  257. package/dist/commands/scenario/scenario.command.js +8 -26
  258. package/dist/commands/shared/git-context.d.ts +1 -0
  259. package/dist/commands/shared/git-context.d.ts.map +1 -1
  260. package/dist/commands/shared/git-context.js +4 -2
  261. package/dist/commands/shared/git-ops.d.ts +1 -0
  262. package/dist/commands/shared/git-ops.d.ts.map +1 -1
  263. package/dist/commands/shared/git-ops.js +13 -0
  264. package/dist/commands/shared/operator-pipeline.d.ts +10 -0
  265. package/dist/commands/shared/operator-pipeline.d.ts.map +1 -0
  266. package/dist/commands/shared/operator-pipeline.js +16 -0
  267. package/dist/commands/shared/pr-meta.d.ts +32 -12
  268. package/dist/commands/shared/pr-meta.d.ts.map +1 -1
  269. package/dist/commands/shared/pr-meta.js +49 -14
  270. package/dist/commands/shared/reconcile-check.d.ts.map +1 -1
  271. package/dist/commands/shared/reconcile-check.js +28 -3
  272. package/dist/commands/shared/task-backend.d.ts +10 -6
  273. package/dist/commands/shared/task-backend.d.ts.map +1 -1
  274. package/dist/commands/shared/task-backend.js +99 -25
  275. package/dist/commands/shared/task-handoff.d.ts +64 -0
  276. package/dist/commands/shared/task-handoff.d.ts.map +1 -0
  277. package/dist/commands/shared/task-handoff.js +151 -0
  278. package/dist/commands/shared/task-mutation.d.ts +36 -0
  279. package/dist/commands/shared/task-mutation.d.ts.map +1 -0
  280. package/dist/commands/shared/task-mutation.js +67 -0
  281. package/dist/commands/shared/task-store.d.ts +5 -1
  282. package/dist/commands/shared/task-store.d.ts.map +1 -1
  283. package/dist/commands/shared/task-store.js +72 -92
  284. package/dist/commands/task/add.d.ts.map +1 -1
  285. package/dist/commands/task/add.js +41 -39
  286. package/dist/commands/task/block.d.ts.map +1 -1
  287. package/dist/commands/task/block.js +31 -110
  288. package/dist/commands/task/close-duplicate.d.ts.map +1 -1
  289. package/dist/commands/task/close-duplicate.js +0 -7
  290. package/dist/commands/task/close-noop.d.ts.map +1 -1
  291. package/dist/commands/task/close-noop.js +0 -21
  292. package/dist/commands/task/close-shared.d.ts +0 -2
  293. package/dist/commands/task/close-shared.d.ts.map +1 -1
  294. package/dist/commands/task/close-shared.js +25 -55
  295. package/dist/commands/task/comment.d.ts.map +1 -1
  296. package/dist/commands/task/comment.js +48 -37
  297. package/dist/commands/task/derive.d.ts.map +1 -1
  298. package/dist/commands/task/derive.js +14 -7
  299. package/dist/commands/task/doc.command.d.ts.map +1 -1
  300. package/dist/commands/task/doc.command.js +7 -6
  301. package/dist/commands/task/doc.d.ts.map +1 -1
  302. package/dist/commands/task/doc.js +58 -62
  303. package/dist/commands/task/finish-shared.d.ts +60 -0
  304. package/dist/commands/task/finish-shared.d.ts.map +1 -0
  305. package/dist/commands/task/finish-shared.js +181 -0
  306. package/dist/commands/task/finish.d.ts +1 -0
  307. package/dist/commands/task/finish.d.ts.map +1 -1
  308. package/dist/commands/task/finish.js +79 -210
  309. package/dist/commands/task/handoff-record.command.d.ts +17 -0
  310. package/dist/commands/task/handoff-record.command.d.ts.map +1 -0
  311. package/dist/commands/task/handoff-record.command.js +140 -0
  312. package/dist/commands/task/handoff-show.command.d.ts +8 -0
  313. package/dist/commands/task/handoff-show.command.d.ts.map +1 -0
  314. package/dist/commands/task/handoff-show.command.js +77 -0
  315. package/dist/commands/task/handoff.command.d.ts +7 -0
  316. package/dist/commands/task/handoff.command.d.ts.map +1 -0
  317. package/dist/commands/task/handoff.command.js +21 -0
  318. package/dist/commands/task/handoff.shared.d.ts +39 -0
  319. package/dist/commands/task/handoff.shared.d.ts.map +1 -0
  320. package/dist/commands/task/handoff.shared.js +134 -0
  321. package/dist/commands/task/hosted-close.command.d.ts +9 -0
  322. package/dist/commands/task/hosted-close.command.d.ts.map +1 -0
  323. package/dist/commands/task/hosted-close.command.js +190 -0
  324. package/dist/commands/task/hosted-merge-sync.d.ts +40 -0
  325. package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -0
  326. package/dist/commands/task/hosted-merge-sync.js +277 -0
  327. package/dist/commands/task/list.d.ts.map +1 -1
  328. package/dist/commands/task/list.js +7 -24
  329. package/dist/commands/task/new.d.ts.map +1 -1
  330. package/dist/commands/task/new.js +26 -6
  331. package/dist/commands/task/next.d.ts.map +1 -1
  332. package/dist/commands/task/next.js +10 -28
  333. package/dist/commands/task/normalize.command.d.ts +1 -0
  334. package/dist/commands/task/normalize.command.d.ts.map +1 -1
  335. package/dist/commands/task/normalize.command.js +12 -0
  336. package/dist/commands/task/normalize.d.ts +1 -0
  337. package/dist/commands/task/normalize.d.ts.map +1 -1
  338. package/dist/commands/task/normalize.js +21 -9
  339. package/dist/commands/task/plan.command.d.ts +3 -4
  340. package/dist/commands/task/plan.command.d.ts.map +1 -1
  341. package/dist/commands/task/plan.command.js +6 -12
  342. package/dist/commands/task/plan.d.ts.map +1 -1
  343. package/dist/commands/task/plan.js +96 -103
  344. package/dist/commands/task/reclaim.command.d.ts +11 -0
  345. package/dist/commands/task/reclaim.command.d.ts.map +1 -0
  346. package/dist/commands/task/reclaim.command.js +102 -0
  347. package/dist/commands/task/resume-context.command.d.ts +9 -0
  348. package/dist/commands/task/resume-context.command.d.ts.map +1 -0
  349. package/dist/commands/task/resume-context.command.js +60 -0
  350. package/dist/commands/task/run-cancel.command.d.ts +6 -0
  351. package/dist/commands/task/run-cancel.command.d.ts.map +1 -0
  352. package/dist/commands/task/run-cancel.command.js +45 -0
  353. package/dist/commands/task/run-cancel.spec.d.ts +7 -0
  354. package/dist/commands/task/run-cancel.spec.d.ts.map +1 -0
  355. package/dist/commands/task/run-cancel.spec.js +20 -0
  356. package/dist/commands/task/run-resume.command.d.ts +6 -0
  357. package/dist/commands/task/run-resume.command.d.ts.map +1 -0
  358. package/dist/commands/task/run-resume.command.js +55 -0
  359. package/dist/commands/task/run-resume.spec.d.ts +7 -0
  360. package/dist/commands/task/run-resume.spec.d.ts.map +1 -0
  361. package/dist/commands/task/run-resume.spec.js +20 -0
  362. package/dist/commands/task/run-retry.command.d.ts +6 -0
  363. package/dist/commands/task/run-retry.command.d.ts.map +1 -0
  364. package/dist/commands/task/run-retry.command.js +56 -0
  365. package/dist/commands/task/run-retry.spec.d.ts +7 -0
  366. package/dist/commands/task/run-retry.spec.d.ts.map +1 -0
  367. package/dist/commands/task/run-retry.spec.js +20 -0
  368. package/dist/commands/task/run-show.command.d.ts +6 -0
  369. package/dist/commands/task/run-show.command.d.ts.map +1 -0
  370. package/dist/commands/task/run-show.command.js +133 -0
  371. package/dist/commands/task/run-show.spec.d.ts +8 -0
  372. package/dist/commands/task/run-show.spec.d.ts.map +1 -0
  373. package/dist/commands/task/run-show.spec.js +44 -0
  374. package/dist/commands/task/run-tail.command.d.ts +6 -0
  375. package/dist/commands/task/run-tail.command.d.ts.map +1 -0
  376. package/dist/commands/task/run-tail.command.js +26 -0
  377. package/dist/commands/task/run-tail.spec.d.ts +8 -0
  378. package/dist/commands/task/run-tail.spec.d.ts.map +1 -0
  379. package/dist/commands/task/run-tail.spec.js +51 -0
  380. package/dist/commands/task/run-trace.command.d.ts +6 -0
  381. package/dist/commands/task/run-trace.command.d.ts.map +1 -0
  382. package/dist/commands/task/run-trace.command.js +25 -0
  383. package/dist/commands/task/run-trace.spec.d.ts +7 -0
  384. package/dist/commands/task/run-trace.spec.d.ts.map +1 -0
  385. package/dist/commands/task/run-trace.spec.js +31 -0
  386. package/dist/commands/task/run.command.d.ts +6 -0
  387. package/dist/commands/task/run.command.d.ts.map +1 -0
  388. package/dist/commands/task/run.command.js +74 -0
  389. package/dist/commands/task/run.spec.d.ts +7 -0
  390. package/dist/commands/task/run.spec.d.ts.map +1 -0
  391. package/dist/commands/task/run.spec.js +26 -0
  392. package/dist/commands/task/scaffold.d.ts.map +1 -1
  393. package/dist/commands/task/scaffold.js +4 -2
  394. package/dist/commands/task/scrub.d.ts.map +1 -1
  395. package/dist/commands/task/scrub.js +27 -24
  396. package/dist/commands/task/search.d.ts.map +1 -1
  397. package/dist/commands/task/search.js +21 -31
  398. package/dist/commands/task/set-status.d.ts.map +1 -1
  399. package/dist/commands/task/set-status.js +36 -152
  400. package/dist/commands/task/shared/dependencies.d.ts +4 -4
  401. package/dist/commands/task/shared/dependencies.d.ts.map +1 -1
  402. package/dist/commands/task/shared/dependencies.js +10 -2
  403. package/dist/commands/task/shared/docs.d.ts +6 -1
  404. package/dist/commands/task/shared/docs.d.ts.map +1 -1
  405. package/dist/commands/task/shared/docs.js +13 -0
  406. package/dist/commands/task/shared/listing.d.ts +16 -2
  407. package/dist/commands/task/shared/listing.d.ts.map +1 -1
  408. package/dist/commands/task/shared/listing.js +56 -0
  409. package/dist/commands/task/shared/transition-command.d.ts +15 -0
  410. package/dist/commands/task/shared/transition-command.d.ts.map +1 -0
  411. package/dist/commands/task/shared/transition-command.js +43 -0
  412. package/dist/commands/task/shared/transitions.d.ts +39 -0
  413. package/dist/commands/task/shared/transitions.d.ts.map +1 -1
  414. package/dist/commands/task/shared/transitions.js +62 -1
  415. package/dist/commands/task/shared/workflow-transition-service.d.ts +75 -0
  416. package/dist/commands/task/shared/workflow-transition-service.d.ts.map +1 -0
  417. package/dist/commands/task/shared/workflow-transition-service.js +226 -0
  418. package/dist/commands/task/shared.d.ts +5 -3
  419. package/dist/commands/task/shared.d.ts.map +1 -1
  420. package/dist/commands/task/shared.js +5 -3
  421. package/dist/commands/task/show.d.ts.map +1 -1
  422. package/dist/commands/task/show.js +37 -3
  423. package/dist/commands/task/start.d.ts.map +1 -1
  424. package/dist/commands/task/start.js +33 -119
  425. package/dist/commands/task/task.command.d.ts +3 -4
  426. package/dist/commands/task/task.command.d.ts.map +1 -1
  427. package/dist/commands/task/task.command.js +22 -37
  428. package/dist/commands/task/verify-record.d.ts.map +1 -1
  429. package/dist/commands/task/verify-record.js +16 -141
  430. package/dist/commands/task/verify.command.d.ts.map +1 -1
  431. package/dist/commands/task/verify.command.js +7 -6
  432. package/dist/commands/task.test-helpers.d.ts +13 -0
  433. package/dist/commands/task.test-helpers.d.ts.map +1 -0
  434. package/dist/commands/task.test-helpers.js +65 -0
  435. package/dist/commands/upgrade/materialize.d.ts +28 -0
  436. package/dist/commands/upgrade/materialize.d.ts.map +1 -0
  437. package/dist/commands/upgrade/materialize.js +154 -0
  438. package/dist/commands/upgrade/plan.d.ts +18 -0
  439. package/dist/commands/upgrade/plan.d.ts.map +1 -0
  440. package/dist/commands/upgrade/plan.js +219 -0
  441. package/dist/commands/upgrade/policy.d.ts +24 -0
  442. package/dist/commands/upgrade/policy.d.ts.map +1 -0
  443. package/dist/commands/upgrade/policy.js +182 -0
  444. package/dist/commands/upgrade/report.d.ts.map +1 -1
  445. package/dist/commands/upgrade/report.js +7 -5
  446. package/dist/commands/upgrade.d.ts.map +1 -1
  447. package/dist/commands/upgrade.js +154 -642
  448. package/dist/commands/workflow.command.d.ts +3 -4
  449. package/dist/commands/workflow.command.d.ts.map +1 -1
  450. package/dist/commands/workflow.command.js +8 -25
  451. package/dist/ports/task-backend-port.d.ts +3 -1
  452. package/dist/ports/task-backend-port.d.ts.map +1 -1
  453. package/dist/runner/adapters/codex.d.ts +9 -0
  454. package/dist/runner/adapters/codex.d.ts.map +1 -0
  455. package/dist/runner/adapters/codex.js +414 -0
  456. package/dist/runner/adapters/custom.d.ts +12 -0
  457. package/dist/runner/adapters/custom.d.ts.map +1 -0
  458. package/dist/runner/adapters/custom.js +512 -0
  459. package/dist/runner/adapters/index.d.ts +8 -0
  460. package/dist/runner/adapters/index.d.ts.map +1 -0
  461. package/dist/runner/adapters/index.js +15 -0
  462. package/dist/runner/adapters/recipe-run-profile.d.ts +8 -0
  463. package/dist/runner/adapters/recipe-run-profile.d.ts.map +1 -0
  464. package/dist/runner/adapters/recipe-run-profile.js +53 -0
  465. package/dist/runner/adapters/shared.d.ts +45 -0
  466. package/dist/runner/adapters/shared.d.ts.map +1 -0
  467. package/dist/runner/adapters/shared.js +58 -0
  468. package/dist/runner/artifacts.d.ts +31 -0
  469. package/dist/runner/artifacts.d.ts.map +1 -0
  470. package/dist/runner/artifacts.js +153 -0
  471. package/dist/runner/codex-approval-probe.d.ts +23 -0
  472. package/dist/runner/codex-approval-probe.d.ts.map +1 -0
  473. package/dist/runner/codex-approval-probe.js +55 -0
  474. package/dist/runner/codex-smoke.d.ts +11 -0
  475. package/dist/runner/codex-smoke.d.ts.map +1 -0
  476. package/dist/runner/codex-smoke.js +45 -0
  477. package/dist/runner/config.d.ts +6 -0
  478. package/dist/runner/config.d.ts.map +1 -0
  479. package/dist/runner/config.js +15 -0
  480. package/dist/runner/context/base-prompts.d.ts +10 -0
  481. package/dist/runner/context/base-prompts.d.ts.map +1 -0
  482. package/dist/runner/context/base-prompts.js +255 -0
  483. package/dist/runner/context/recipe-context.d.ts +17 -0
  484. package/dist/runner/context/recipe-context.d.ts.map +1 -0
  485. package/dist/runner/context/recipe-context.js +48 -0
  486. package/dist/runner/context/task-context.d.ts +24 -0
  487. package/dist/runner/context/task-context.d.ts.map +1 -0
  488. package/dist/runner/context/task-context.js +266 -0
  489. package/dist/runner/index.d.ts +12 -0
  490. package/dist/runner/index.d.ts.map +1 -0
  491. package/dist/runner/index.js +11 -0
  492. package/dist/runner/policy-decision.d.ts +12 -0
  493. package/dist/runner/policy-decision.d.ts.map +1 -0
  494. package/dist/runner/policy-decision.js +89 -0
  495. package/dist/runner/policy-display.d.ts +4 -0
  496. package/dist/runner/policy-display.d.ts.map +1 -0
  497. package/dist/runner/policy-display.js +41 -0
  498. package/dist/runner/process-supervision.d.ts +48 -0
  499. package/dist/runner/process-supervision.d.ts.map +1 -0
  500. package/dist/runner/process-supervision.js +490 -0
  501. package/dist/runner/result-manifest-policy.d.ts +9 -0
  502. package/dist/runner/result-manifest-policy.d.ts.map +1 -0
  503. package/dist/runner/result-manifest-policy.js +96 -0
  504. package/dist/runner/result-manifest.d.ts +30 -0
  505. package/dist/runner/result-manifest.d.ts.map +1 -0
  506. package/dist/runner/result-manifest.js +322 -0
  507. package/dist/runner/run-id.d.ts +2 -0
  508. package/dist/runner/run-id.d.ts.map +1 -0
  509. package/dist/runner/run-id.js +3 -0
  510. package/dist/runner/run-repository.d.ts +51 -0
  511. package/dist/runner/run-repository.d.ts.map +1 -0
  512. package/dist/runner/run-repository.js +222 -0
  513. package/dist/runner/task-run-paths.d.ts +19 -0
  514. package/dist/runner/task-run-paths.d.ts.map +1 -0
  515. package/dist/runner/task-run-paths.js +25 -0
  516. package/dist/runner/task-state.d.ts +9 -0
  517. package/dist/runner/task-state.d.ts.map +1 -0
  518. package/dist/runner/task-state.js +354 -0
  519. package/dist/runner/test-helpers.d.ts +30 -0
  520. package/dist/runner/test-helpers.d.ts.map +1 -0
  521. package/dist/runner/test-helpers.js +97 -0
  522. package/dist/runner/trace-artifacts.d.ts +14 -0
  523. package/dist/runner/trace-artifacts.d.ts.map +1 -0
  524. package/dist/runner/trace-artifacts.js +80 -0
  525. package/dist/runner/trace.d.ts +10 -0
  526. package/dist/runner/trace.d.ts.map +1 -0
  527. package/dist/runner/trace.js +37 -0
  528. package/dist/runner/types.d.ts +317 -0
  529. package/dist/runner/types.d.ts.map +1 -0
  530. package/dist/runner/types.js +3 -0
  531. package/dist/runner/usecases/scenario-materialize-task.d.ts +29 -0
  532. package/dist/runner/usecases/scenario-materialize-task.d.ts.map +1 -0
  533. package/dist/runner/usecases/scenario-materialize-task.js +151 -0
  534. package/dist/runner/usecases/task-run-inspect.d.ts +41 -0
  535. package/dist/runner/usecases/task-run-inspect.d.ts.map +1 -0
  536. package/dist/runner/usecases/task-run-inspect.js +74 -0
  537. package/dist/runner/usecases/task-run-lifecycle-cancel.d.ts +10 -0
  538. package/dist/runner/usecases/task-run-lifecycle-cancel.d.ts.map +1 -0
  539. package/dist/runner/usecases/task-run-lifecycle-cancel.js +172 -0
  540. package/dist/runner/usecases/task-run-lifecycle-replay.d.ts +18 -0
  541. package/dist/runner/usecases/task-run-lifecycle-replay.d.ts.map +1 -0
  542. package/dist/runner/usecases/task-run-lifecycle-replay.js +128 -0
  543. package/dist/runner/usecases/task-run-lifecycle-shared.d.ts +45 -0
  544. package/dist/runner/usecases/task-run-lifecycle-shared.d.ts.map +1 -0
  545. package/dist/runner/usecases/task-run-lifecycle-shared.js +172 -0
  546. package/dist/runner/usecases/task-run-lifecycle.d.ts +4 -0
  547. package/dist/runner/usecases/task-run-lifecycle.d.ts.map +1 -0
  548. package/dist/runner/usecases/task-run-lifecycle.js +2 -0
  549. package/dist/runner/usecases/task-run.d.ts +32 -0
  550. package/dist/runner/usecases/task-run.d.ts.map +1 -0
  551. package/dist/runner/usecases/task-run.js +278 -0
  552. package/dist/shared/agent-emoji.d.ts.map +1 -1
  553. package/dist/shared/agent-emoji.js +1 -0
  554. package/dist/shared/errors.d.ts +1 -1
  555. package/dist/shared/errors.d.ts.map +1 -1
  556. package/dist/shared/guards.d.ts.map +1 -1
  557. package/dist/shared/guards.js +1 -0
  558. package/dist/shared/repo-cli-version.d.ts.map +1 -1
  559. package/dist/shared/repo-cli-version.js +7 -5
  560. package/dist/shared/task-doc-conflicts.d.ts +12 -0
  561. package/dist/shared/task-doc-conflicts.d.ts.map +1 -0
  562. package/dist/shared/task-doc-conflicts.js +40 -0
  563. package/dist/shared/task-doc-state.d.ts +10 -0
  564. package/dist/shared/task-doc-state.d.ts.map +1 -0
  565. package/dist/shared/task-doc-state.js +15 -0
  566. package/dist/test-helpers/fs.d.ts +2 -0
  567. package/dist/test-helpers/fs.d.ts.map +1 -0
  568. package/dist/test-helpers/fs.js +9 -0
  569. package/dist/usecases/context/resolve-context.d.ts +2 -0
  570. package/dist/usecases/context/resolve-context.d.ts.map +1 -1
  571. package/dist/usecases/context/resolve-context.js +4 -1
  572. package/dist/usecases/task/task-list-usecase.d.ts.map +1 -1
  573. package/dist/usecases/task/task-list-usecase.js +2 -8
  574. package/dist/workflow-runtime/fix.d.ts +9 -1
  575. package/dist/workflow-runtime/fix.d.ts.map +1 -1
  576. package/dist/workflow-runtime/fix.js +9 -1
  577. package/package.json +2 -2
  578. package/dist/backends/task-backend.test-helpers.d.ts +0 -4
  579. package/dist/backends/task-backend.test-helpers.d.ts.map +0 -1
  580. package/dist/backends/task-backend.test-helpers.js +0 -33
  581. package/dist/cli/run-cli/catalog.d.ts +0 -7
  582. package/dist/cli/run-cli/catalog.d.ts.map +0 -1
  583. package/dist/cli/run-cli/catalog.js +0 -22
  584. package/dist/cli/run-cli.core.pr-flow.test-helpers.d.ts +0 -3
  585. package/dist/cli/run-cli.core.pr-flow.test-helpers.d.ts.map +0 -1
  586. package/dist/cli/run-cli.core.pr-flow.test-helpers.js +0 -41
  587. package/dist/cli/run-cli.core.tasks.test-helpers.d.ts +0 -2
  588. package/dist/cli/run-cli.core.tasks.test-helpers.d.ts.map +0 -1
  589. package/dist/cli/run-cli.core.tasks.test-helpers.js +0 -6
  590. package/dist/commands/block.command.d.ts +0 -4
  591. package/dist/commands/block.command.d.ts.map +0 -1
  592. package/dist/commands/block.command.js +0 -2
  593. package/dist/commands/doctor.command.d.ts +0 -3
  594. package/dist/commands/doctor.command.d.ts.map +0 -1
  595. package/dist/commands/doctor.command.js +0 -2
  596. package/dist/commands/finish.command.d.ts +0 -4
  597. package/dist/commands/finish.command.d.ts.map +0 -1
  598. package/dist/commands/finish.command.js +0 -2
  599. package/dist/commands/recipes/install.command.d.ts +0 -3
  600. package/dist/commands/recipes/install.command.d.ts.map +0 -1
  601. package/dist/commands/recipes/install.command.js +0 -2
  602. package/dist/commands/start.command.d.ts +0 -4
  603. package/dist/commands/start.command.d.ts.map +0 -1
  604. package/dist/commands/start.command.js +0 -2
  605. package/dist/commands/task/list.command.d.ts +0 -4
  606. package/dist/commands/task/list.command.d.ts.map +0 -1
  607. package/dist/commands/task/list.command.js +0 -2
  608. package/dist/commands/task/next.command.d.ts +0 -4
  609. package/dist/commands/task/next.command.d.ts.map +0 -1
  610. package/dist/commands/task/next.command.js +0 -2
  611. package/dist/commands/task/search.command.d.ts +0 -4
  612. package/dist/commands/task/search.command.d.ts.map +0 -1
  613. package/dist/commands/task/search.command.js +0 -2
  614. package/dist/commands/task/show.command.d.ts +0 -4
  615. package/dist/commands/task/show.command.d.ts.map +0 -1
  616. package/dist/commands/task/show.command.js +0 -2
  617. package/dist/commands/verify.command.d.ts +0 -4
  618. package/dist/commands/verify.command.d.ts.map +0 -1
  619. package/dist/commands/verify.command.js +0 -2
@@ -0,0 +1,140 @@
1
+ import { usageError } from "../../cli/spec/errors.js";
2
+ import { createCliEmitter, infoMessage } from "../../cli/output.js";
3
+ import { buildRecordedTaskHandoff } from "./handoff.shared.js";
4
+ import { resolveTaskHandoffPaths, writeTaskHandoff } from "../shared/task-handoff.js";
5
+ export const taskHandoffRecordSpec = {
6
+ id: ["task", "handoff", "record"],
7
+ group: "Task",
8
+ summary: "Record a task handoff snapshot with runner recovery hints.",
9
+ args: [{ name: "task-id", required: true, valueHint: "<task-id>" }],
10
+ options: [
11
+ {
12
+ kind: "string",
13
+ name: "from",
14
+ valueHint: "<role>",
15
+ description: "Role handing off the task.",
16
+ },
17
+ {
18
+ kind: "string",
19
+ name: "to",
20
+ valueHint: "<role>",
21
+ description: "Optional. Intended receiving role.",
22
+ },
23
+ {
24
+ kind: "string",
25
+ name: "reason",
26
+ valueHint: "<text>",
27
+ description: "Why the handoff is happening.",
28
+ },
29
+ {
30
+ kind: "string",
31
+ name: "note",
32
+ valueHint: "<text>",
33
+ description: "Optional. Free-form handoff note.",
34
+ },
35
+ {
36
+ kind: "string",
37
+ name: "run-id",
38
+ valueHint: "<run-id>",
39
+ description: "Optional. Pin handoff hints to a specific runner run.",
40
+ },
41
+ {
42
+ kind: "string",
43
+ name: "next-action",
44
+ valueHint: "<text>",
45
+ repeatable: true,
46
+ description: "Repeatable. Human next actions for the receiving agent.",
47
+ },
48
+ {
49
+ kind: "string",
50
+ name: "risk",
51
+ valueHint: "<text>",
52
+ repeatable: true,
53
+ description: "Repeatable. Risks or watch-outs that remain open.",
54
+ },
55
+ {
56
+ kind: "string",
57
+ name: "question",
58
+ valueHint: "<text>",
59
+ repeatable: true,
60
+ description: "Repeatable. Open questions for the next agent.",
61
+ },
62
+ {
63
+ kind: "string",
64
+ name: "evidence-path",
65
+ valueHint: "<path>",
66
+ repeatable: true,
67
+ description: "Repeatable. Relevant evidence or artifact paths.",
68
+ },
69
+ {
70
+ kind: "boolean",
71
+ name: "json",
72
+ default: false,
73
+ description: "Emit the persisted handoff snapshot as JSON.",
74
+ },
75
+ ],
76
+ validateRaw: (raw) => {
77
+ for (const key of ["from", "reason"]) {
78
+ const value = raw.opts[key];
79
+ if (typeof value !== "string" || value.trim() === "") {
80
+ throw usageError({
81
+ spec: taskHandoffRecordSpec,
82
+ message: `Missing required option: --${key}.`,
83
+ });
84
+ }
85
+ }
86
+ },
87
+ parse: (raw) => ({
88
+ taskId: String(raw.args["task-id"]),
89
+ fromRole: String(raw.opts.from),
90
+ toRole: typeof raw.opts.to === "string" ? raw.opts.to : undefined,
91
+ reason: String(raw.opts.reason),
92
+ note: typeof raw.opts.note === "string" ? raw.opts.note : undefined,
93
+ runId: typeof raw.opts["run-id"] === "string" ? raw.opts["run-id"] : undefined,
94
+ nextActions: raw.opts["next-action"] ?? [],
95
+ risks: raw.opts.risk ?? [],
96
+ openQuestions: raw.opts.question ?? [],
97
+ evidencePaths: raw.opts["evidence-path"] ?? [],
98
+ json: raw.opts.json === true,
99
+ }),
100
+ };
101
+ const emitter = createCliEmitter();
102
+ export const runTaskHandoffRecord = async (ctx, parsed) => {
103
+ const built = await buildRecordedTaskHandoff({
104
+ cwd: ctx.cwd,
105
+ rootOverride: ctx.rootOverride ?? null,
106
+ task_id: parsed.taskId,
107
+ from_role: parsed.fromRole,
108
+ to_role: parsed.toRole,
109
+ reason: parsed.reason,
110
+ note: parsed.note,
111
+ run_id: parsed.runId,
112
+ next_actions: parsed.nextActions,
113
+ risks: parsed.risks,
114
+ open_questions: parsed.openQuestions,
115
+ evidence_paths: parsed.evidencePaths,
116
+ });
117
+ const paths = resolveTaskHandoffPaths({
118
+ git_root: built.ctx.resolvedProject.gitRoot,
119
+ workflow_dir: built.ctx.config.paths.workflow_dir,
120
+ task_id: parsed.taskId,
121
+ });
122
+ await writeTaskHandoff({ paths, handoff: built.handoff });
123
+ if (parsed.json) {
124
+ emitter.json(built.handoff);
125
+ return 0;
126
+ }
127
+ const entries = [
128
+ { label: "from", value: built.handoff.from_role },
129
+ { label: "to", value: built.handoff.to_role ?? "unassigned" },
130
+ { label: "reason", value: built.handoff.reason },
131
+ ];
132
+ if (built.handoff.runner?.run_id) {
133
+ entries.push({ label: "run_id", value: built.handoff.runner.run_id }, { label: "runner_status", value: built.handoff.runner.status ?? "unknown" }, { label: "runner_next_action", value: built.handoff.runner.next_action ?? "none" });
134
+ }
135
+ entries.push({ label: "latest", value: paths.latest_path });
136
+ emitter.report(entries, {
137
+ header: infoMessage(`task handoff recorded: ${parsed.taskId}`),
138
+ });
139
+ return 0;
140
+ };
@@ -0,0 +1,8 @@
1
+ import type { CommandCtx, CommandSpec } from "../../cli/spec/spec.js";
2
+ export type TaskHandoffShowParsed = {
3
+ taskId: string;
4
+ json: boolean;
5
+ };
6
+ export declare const taskHandoffShowSpec: CommandSpec<TaskHandoffShowParsed>;
7
+ export declare const runTaskHandoffShow: (ctx: CommandCtx, parsed: TaskHandoffShowParsed) => Promise<number>;
8
+ //# sourceMappingURL=handoff-show.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handoff-show.command.d.ts","sourceRoot":"","sources":["../../../src/commands/task/handoff-show.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAOtE,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,qBAAqB,CAiBlE,CAAC;AAIF,eAAO,MAAM,kBAAkB,GAAU,KAAK,UAAU,EAAE,QAAQ,qBAAqB,oBAsDtF,CAAC"}
@@ -0,0 +1,77 @@
1
+ import { createCliEmitter, infoMessage } from "../../cli/output.js";
2
+ import { loadCommandContext } from "../shared/task-backend.js";
3
+ import { readTaskHandoffLatestRequired, resolveTaskHandoffPaths } from "../shared/task-handoff.js";
4
+ export const taskHandoffShowSpec = {
5
+ id: ["task", "handoff", "show"],
6
+ group: "Task",
7
+ summary: "Show the latest persisted task handoff snapshot.",
8
+ args: [{ name: "task-id", required: true, valueHint: "<task-id>" }],
9
+ options: [
10
+ {
11
+ kind: "boolean",
12
+ name: "json",
13
+ default: false,
14
+ description: "Emit machine-readable handoff JSON.",
15
+ },
16
+ ],
17
+ parse: (raw) => ({
18
+ taskId: String(raw.args["task-id"]),
19
+ json: raw.opts.json === true,
20
+ }),
21
+ };
22
+ const emitter = createCliEmitter();
23
+ export const runTaskHandoffShow = async (ctx, parsed) => {
24
+ const commandCtx = await loadCommandContext({
25
+ cwd: ctx.cwd,
26
+ rootOverride: ctx.rootOverride ?? null,
27
+ });
28
+ const paths = resolveTaskHandoffPaths({
29
+ git_root: commandCtx.resolvedProject.gitRoot,
30
+ workflow_dir: commandCtx.config.paths.workflow_dir,
31
+ task_id: parsed.taskId,
32
+ });
33
+ const handoff = await readTaskHandoffLatestRequired({
34
+ task_id: parsed.taskId,
35
+ paths,
36
+ });
37
+ if (parsed.json) {
38
+ emitter.json(handoff);
39
+ return 0;
40
+ }
41
+ const entries = [
42
+ { label: "from", value: handoff.from_role },
43
+ { label: "to", value: handoff.to_role ?? "unassigned" },
44
+ { label: "created_at", value: handoff.created_at },
45
+ { label: "reason", value: handoff.reason },
46
+ ];
47
+ if (handoff.branch)
48
+ entries.push({ label: "branch", value: handoff.branch });
49
+ if (handoff.base_branch)
50
+ entries.push({ label: "base_branch", value: handoff.base_branch });
51
+ if (handoff.head_sha)
52
+ entries.push({ label: "head_sha", value: handoff.head_sha });
53
+ if (handoff.pr_branch)
54
+ entries.push({ label: "pr_branch", value: handoff.pr_branch });
55
+ if (handoff.runner?.run_id) {
56
+ entries.push({ label: "run_id", value: handoff.runner.run_id }, { label: "runner_status", value: handoff.runner.status ?? "unknown" }, { label: "runner_next_action", value: handoff.runner.next_action ?? "none" });
57
+ if (handoff.runner.next_command) {
58
+ entries.push({ label: "runner_next_command", value: handoff.runner.next_command });
59
+ }
60
+ }
61
+ for (const action of handoff.next_actions ?? []) {
62
+ entries.push({ label: "next_action", value: action });
63
+ }
64
+ for (const risk of handoff.risks ?? []) {
65
+ entries.push({ label: "risk", value: risk });
66
+ }
67
+ for (const question of handoff.open_questions ?? []) {
68
+ entries.push({ label: "open_question", value: question });
69
+ }
70
+ for (const evidence of handoff.evidence_paths ?? []) {
71
+ entries.push({ label: "evidence_path", value: evidence });
72
+ }
73
+ emitter.report(entries, {
74
+ header: infoMessage(`task handoff show: ${parsed.taskId}`),
75
+ });
76
+ return 0;
77
+ };
@@ -0,0 +1,7 @@
1
+ import type { CommandCtx, CommandSpec } from "../../cli/spec/spec.js";
2
+ export type TaskHandoffParsed = {
3
+ subcommand?: string;
4
+ };
5
+ export declare const taskHandoffSpec: CommandSpec<TaskHandoffParsed>;
6
+ export declare function runTaskHandoff(_ctx: CommandCtx, p: TaskHandoffParsed): Promise<number>;
7
+ //# sourceMappingURL=handoff.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handoff.command.d.ts","sourceRoot":"","sources":["../../../src/commands/task/handoff.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGtE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,iBAAiB,CAY1D,CAAC;AAEF,wBAAsB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CAM5F"}
@@ -0,0 +1,21 @@
1
+ import { loadDirectSubcommandNames, throwGroupCommandUsage } from "../../cli/group-command.js";
2
+ export const taskHandoffSpec = {
3
+ id: ["task", "handoff"],
4
+ group: "Task",
5
+ summary: "Task handoff commands (record/show).",
6
+ synopsis: [
7
+ "agentplane task handoff record <task-id> --from <role> --reason <text> [--to <role>] [--run-id <id>]",
8
+ "agentplane task handoff show <task-id> [--json]",
9
+ ],
10
+ args: [{ name: "subcommand", required: false, valueHint: "<record|show>" }],
11
+ parse: (raw) => ({
12
+ subcommand: typeof raw.args.subcommand === "string" ? raw.args.subcommand : undefined,
13
+ }),
14
+ };
15
+ export async function runTaskHandoff(_ctx, p) {
16
+ throwGroupCommandUsage({
17
+ spec: taskHandoffSpec,
18
+ cmd: p.subcommand ? [p.subcommand] : [],
19
+ subcommands: await loadDirectSubcommandNames(["task", "handoff"]),
20
+ });
21
+ }
@@ -0,0 +1,39 @@
1
+ import { type CommandContext } from "../shared/task-backend.js";
2
+ import { type TaskHandoffArtifact, type TaskHandoffRunnerHint } from "../shared/task-handoff.js";
3
+ export type TaskResumeContext = {
4
+ task_id: string;
5
+ task_status: string;
6
+ branch: string | null;
7
+ base_branch: string | null;
8
+ head_sha: string | null;
9
+ workspace_root: string;
10
+ pr_branch: string | null;
11
+ latest_handoff: TaskHandoffArtifact | null;
12
+ runner: TaskHandoffRunnerHint;
13
+ };
14
+ export declare function buildTaskResumeContext(opts: {
15
+ ctx?: CommandContext;
16
+ cwd: string;
17
+ rootOverride?: string | null;
18
+ task_id: string;
19
+ run_id?: string;
20
+ }): Promise<TaskResumeContext>;
21
+ export declare function buildRecordedTaskHandoff(opts: {
22
+ ctx?: CommandContext;
23
+ cwd: string;
24
+ rootOverride?: string | null;
25
+ task_id: string;
26
+ from_role: string;
27
+ to_role?: string | null;
28
+ reason: string;
29
+ note?: string;
30
+ next_actions?: string[];
31
+ risks?: string[];
32
+ open_questions?: string[];
33
+ evidence_paths?: string[];
34
+ run_id?: string;
35
+ }): Promise<{
36
+ ctx: CommandContext;
37
+ handoff: TaskHandoffArtifact;
38
+ }>;
39
+ //# sourceMappingURL=handoff.shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handoff.shared.d.ts","sourceRoot":"","sources":["../../../src/commands/task/handoff.shared.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAOL,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC3B,MAAM,2BAA2B,CAAC;AAKnC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,cAAc,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC3C,MAAM,EAAE,qBAAqB,CAAC;CAC/B,CAAC;AAaF,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAsF7B;AAED,wBAAsB,wBAAwB,CAAC,IAAI,EAAE;IACnD,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC;IAAE,GAAG,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,mBAAmB,CAAA;CAAE,CAAC,CAiCjE"}
@@ -0,0 +1,134 @@
1
+ import { resolveBaseBranch } from "@agentplaneorg/core";
2
+ import { loadCommandContext, loadTaskFromContext, } from "../shared/task-backend.js";
3
+ import { buildRunnerHintCommands, buildTaskHandoffArtifact, currentGitBranch, readTaskHandoffLatest, readTaskPrMetaSummary, resolveTaskHandoffPaths, } from "../shared/task-handoff.js";
4
+ import { isProcessAlive } from "../../runner/process-supervision.js";
5
+ import { loadTaskRunnerInspection } from "../../runner/usecases/task-run-inspect.js";
6
+ import { CliError } from "../../shared/errors.js";
7
+ function taskStatus(task) {
8
+ return String(task.status || "TODO")
9
+ .trim()
10
+ .toUpperCase();
11
+ }
12
+ function nullIfCliIo(err) {
13
+ if (err instanceof CliError && err.code === "E_IO")
14
+ return null;
15
+ throw err;
16
+ }
17
+ export async function buildTaskResumeContext(opts) {
18
+ const ctx = opts.ctx ??
19
+ (await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
20
+ const task = await loadTaskFromContext({ ctx, taskId: opts.task_id });
21
+ const handoffPaths = resolveTaskHandoffPaths({
22
+ git_root: ctx.resolvedProject.gitRoot,
23
+ workflow_dir: ctx.config.paths.workflow_dir,
24
+ task_id: opts.task_id,
25
+ });
26
+ const [branch, latest_handoff, prMeta] = await Promise.all([
27
+ currentGitBranch(ctx.resolvedProject.gitRoot),
28
+ readTaskHandoffLatest(handoffPaths),
29
+ readTaskPrMetaSummary({ ctx, task_id: opts.task_id }),
30
+ ]);
31
+ const head_sha = await ctx.git.headCommit().catch(() => null);
32
+ const base_branch = prMeta.base ??
33
+ (await resolveBaseBranch({
34
+ cwd: ctx.resolvedProject.gitRoot,
35
+ rootOverride: ctx.resolvedProject.gitRoot,
36
+ mode: ctx.config.workflow_mode,
37
+ }).catch(() => null));
38
+ let runner;
39
+ try {
40
+ const inspection = await loadTaskRunnerInspection({
41
+ ctx,
42
+ cwd: opts.cwd,
43
+ rootOverride: opts.rootOverride ?? null,
44
+ task_id: opts.task_id,
45
+ run_id: opts.run_id,
46
+ });
47
+ const commands = buildRunnerHintCommands({
48
+ task_id: opts.task_id,
49
+ run_id: inspection.run_id,
50
+ status: inspection.state.status,
51
+ });
52
+ runner = {
53
+ run_id: inspection.run_id,
54
+ status: inspection.state.status,
55
+ heartbeat_at: inspection.state.supervision?.heartbeat_at ?? null,
56
+ state_path: inspection.paths.state_path,
57
+ trace_path: inspection.paths.trace_path,
58
+ ...commands,
59
+ };
60
+ if (inspection.state.status === "running") {
61
+ const pid = inspection.state.supervision?.pid;
62
+ if (typeof pid === "number") {
63
+ const alive = isProcessAlive(pid);
64
+ runner.next_action = alive ? "wait" : "cancel_then_resume";
65
+ runner.next_command = alive
66
+ ? null
67
+ : `agentplane task run cancel ${opts.task_id} ${inspection.run_id} && agentplane task run resume ${opts.task_id} ${inspection.run_id}`;
68
+ }
69
+ else {
70
+ runner.next_action = "cancel_then_resume";
71
+ runner.next_command = `agentplane task run cancel ${opts.task_id} ${inspection.run_id} && agentplane task run resume ${opts.task_id} ${inspection.run_id}`;
72
+ }
73
+ }
74
+ }
75
+ catch (err) {
76
+ const noRun = nullIfCliIo(err);
77
+ runner = {
78
+ run_id: null,
79
+ status: null,
80
+ heartbeat_at: null,
81
+ state_path: null,
82
+ trace_path: null,
83
+ ...buildRunnerHintCommands({
84
+ task_id: opts.task_id,
85
+ run_id: noRun,
86
+ status: null,
87
+ }),
88
+ };
89
+ }
90
+ return {
91
+ task_id: opts.task_id,
92
+ task_status: taskStatus(task),
93
+ branch,
94
+ base_branch,
95
+ head_sha,
96
+ workspace_root: ctx.resolvedProject.gitRoot,
97
+ pr_branch: prMeta.branch,
98
+ latest_handoff,
99
+ runner,
100
+ };
101
+ }
102
+ export async function buildRecordedTaskHandoff(opts) {
103
+ const ctx = opts.ctx ??
104
+ (await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
105
+ await loadTaskFromContext({ ctx, taskId: opts.task_id });
106
+ const resume = await buildTaskResumeContext({
107
+ ctx,
108
+ cwd: opts.cwd,
109
+ rootOverride: opts.rootOverride ?? null,
110
+ task_id: opts.task_id,
111
+ run_id: opts.run_id,
112
+ });
113
+ return {
114
+ ctx,
115
+ handoff: buildTaskHandoffArtifact({
116
+ task_id: opts.task_id,
117
+ created_at: new Date().toISOString(),
118
+ from_role: opts.from_role,
119
+ to_role: opts.to_role,
120
+ reason: opts.reason,
121
+ note: opts.note,
122
+ branch: resume.branch,
123
+ base_branch: resume.base_branch,
124
+ head_sha: resume.head_sha,
125
+ workspace_root: resume.workspace_root,
126
+ pr_branch: resume.pr_branch,
127
+ runner: resume.runner,
128
+ next_actions: opts.next_actions,
129
+ risks: opts.risks,
130
+ open_questions: opts.open_questions,
131
+ evidence_paths: opts.evidence_paths,
132
+ }),
133
+ };
134
+ }
@@ -0,0 +1,9 @@
1
+ import type { CommandCtx, CommandSpec } from "../../cli/spec/spec.js";
2
+ import { type CommandContext } from "../shared/task-backend.js";
3
+ export type TaskHostedCloseParsed = {
4
+ eventJson: string;
5
+ quiet: boolean;
6
+ };
7
+ export declare const taskHostedCloseSpec: CommandSpec<TaskHostedCloseParsed>;
8
+ export declare function makeRunTaskHostedCloseHandler(getCtx: (cmd: string) => Promise<CommandContext>): (ctx: CommandCtx, parsed: TaskHostedCloseParsed) => Promise<number>;
9
+ //# sourceMappingURL=hosted-close.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-close.command.d.ts","sourceRoot":"","sources":["../../../src/commands/task/hosted-close.command.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAStE,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAKrF,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,qBAAqB,CAqClE,CAAC;AAyIF,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,IAC9E,KAAK,UAAU,EAAE,QAAQ,qBAAqB,KAAG,OAAO,CAAC,MAAM,CAAC,CA2B/E"}
@@ -0,0 +1,190 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { usageError } from "../../cli/spec/errors.js";
4
+ import { infoMessage, successMessage } from "../../cli/output.js";
5
+ import { mapBackendError } from "../../cli/error-map.js";
6
+ import { fileExists } from "../../cli/fs-utils.js";
7
+ import { CliError } from "../../shared/errors.js";
8
+ import { writeJsonStableIfChanged } from "../../shared/write-if-changed.js";
9
+ import { execFileAsync } from "../shared/git.js";
10
+ import { buildIntegratedPrMeta, parsePrMeta } from "../shared/pr-meta.js";
11
+ import { loadTaskFromContext } from "../shared/task-backend.js";
12
+ import { createTaskCloseCommit, writeFinishedTasks } from "./finish-shared.js";
13
+ import { resolveHostedMergeTargetFromEvent } from "./hosted-merge-sync.js";
14
+ import { readCommitInfo } from "./shared.js";
15
+ export const taskHostedCloseSpec = {
16
+ id: ["task", "hosted-close"],
17
+ group: "Task",
18
+ summary: "Close a branch_pr task on the current branch from a merged hosted PR event payload.",
19
+ options: [
20
+ {
21
+ kind: "string",
22
+ name: "event-json",
23
+ valueHint: "<path>",
24
+ description: "Path to the GitHub pull_request closed event payload.",
25
+ },
26
+ {
27
+ kind: "boolean",
28
+ name: "quiet",
29
+ default: false,
30
+ description: "Suppress normal output (still prints errors).",
31
+ },
32
+ ],
33
+ validateRaw: (raw) => {
34
+ const value = raw.opts["event-json"];
35
+ if (typeof value !== "string" || value.trim() === "") {
36
+ throw usageError({
37
+ spec: taskHostedCloseSpec,
38
+ message: "Missing required option: --event-json.",
39
+ });
40
+ }
41
+ },
42
+ examples: [
43
+ {
44
+ cmd: 'agentplane task hosted-close --event-json "$GITHUB_EVENT_PATH"',
45
+ why: "Apply the canonical branch_pr closure payload on an automation branch after a hosted PR merge.",
46
+ },
47
+ ],
48
+ parse: (raw) => ({
49
+ eventJson: String(raw.opts["event-json"]),
50
+ quiet: raw.opts.quiet === true,
51
+ }),
52
+ };
53
+ async function hasTaskArtifactChanges(opts) {
54
+ const { stdout } = await execFileAsync("git", ["status", "--short", "--", opts.taskDirRelative], {
55
+ cwd: opts.gitRoot,
56
+ env: process.env,
57
+ });
58
+ return stdout.trim().length > 0;
59
+ }
60
+ async function closeHostedTask(opts) {
61
+ const rawEvent = await readFile(opts.eventJson, "utf8");
62
+ const parsedEvent = JSON.parse(rawEvent);
63
+ const target = resolveHostedMergeTargetFromEvent({
64
+ event: parsedEvent,
65
+ branchPrefix: opts.ctx.config.branch.task_prefix,
66
+ });
67
+ if (!target?.mergedPr.mergeCommit?.oid) {
68
+ return { outcome: "noop", detail: "event is not a merged task PR" };
69
+ }
70
+ const gitRoot = opts.ctx.resolvedProject.gitRoot;
71
+ const taskDirRelative = path.join(opts.ctx.config.paths.workflow_dir, target.taskId);
72
+ const task = await loadTaskFromContext({ ctx: opts.ctx, taskId: target.taskId });
73
+ const metaPath = path.join(gitRoot, taskDirRelative, "pr", "meta.json");
74
+ if (!(await fileExists(metaPath))) {
75
+ throw new CliError({
76
+ exitCode: 3,
77
+ code: "E_VALIDATION",
78
+ message: `Hosted task closure could not find pr/meta.json for ${target.taskId}`,
79
+ });
80
+ }
81
+ const rawMeta = await readFile(metaPath, "utf8");
82
+ const meta = parsePrMeta(rawMeta, target.taskId);
83
+ const alreadyClosed = String(task.status || "TODO").toUpperCase() === "DONE" &&
84
+ (task.commit?.hash ?? "") === target.mergedPr.mergeCommit.oid &&
85
+ meta.status === "MERGED" &&
86
+ (meta.merge_commit ?? "") === target.mergedPr.mergeCommit.oid;
87
+ if (String(task.status || "TODO").toUpperCase() === "DONE" &&
88
+ (task.commit?.hash ?? "") !== "" &&
89
+ (task.commit?.hash ?? "") !== target.mergedPr.mergeCommit.oid) {
90
+ throw new CliError({
91
+ exitCode: 3,
92
+ code: "E_VALIDATION",
93
+ message: `Hosted task closure found a conflicting DONE commit for ${target.taskId}: ` +
94
+ `${task.commit?.hash} != ${target.mergedPr.mergeCommit.oid}`,
95
+ });
96
+ }
97
+ const nextMeta = buildIntegratedPrMeta({
98
+ meta,
99
+ branch: target.branch,
100
+ base: target.mergedPr.baseRefName ?? meta.base ?? "main",
101
+ mergeStrategy: meta.merge_strategy ?? "squash",
102
+ mergeHash: target.mergedPr.mergeCommit.oid,
103
+ branchHeadSha: target.mergedPr.headRefOid ?? meta.head_sha ?? target.mergedPr.mergeCommit.oid,
104
+ at: target.mergedPr.mergedAt ?? new Date().toISOString(),
105
+ verifyCommands: [],
106
+ shouldRunVerify: false,
107
+ alreadyVerifiedSha: null,
108
+ });
109
+ await writeJsonStableIfChanged(metaPath, nextMeta);
110
+ if (alreadyClosed) {
111
+ if (!(await hasTaskArtifactChanges({ gitRoot, taskDirRelative }))) {
112
+ return {
113
+ outcome: "noop",
114
+ detail: `${target.taskId} is already closed for merge ${target.mergedPr.mergeCommit.oid.slice(0, 12)}`,
115
+ };
116
+ }
117
+ await createTaskCloseCommit({
118
+ ctx: opts.ctx,
119
+ cwd: opts.cwd,
120
+ rootOverride: opts.rootOverride,
121
+ taskId: target.taskId,
122
+ baseBranchOverride: target.mergedPr.baseRefName ?? meta.base ?? "main",
123
+ quiet: opts.quiet,
124
+ });
125
+ return {
126
+ outcome: "meta-only",
127
+ taskId: target.taskId,
128
+ mergeHash: target.mergedPr.mergeCommit.oid,
129
+ };
130
+ }
131
+ const taskCommitInfo = await readCommitInfo(gitRoot, target.mergedPr.mergeCommit.oid);
132
+ const prLabel = `PR #${target.mergedPr.number}`;
133
+ const finishBody = `Verified: ${prLabel} merged on GitHub ${target.mergedPr.baseRefName ?? "main"}; ` +
134
+ "hosted closure automation recorded canonical task artifacts.";
135
+ await writeFinishedTasks({
136
+ ctx: opts.ctx,
137
+ loadedTasks: [{ taskId: target.taskId, task }],
138
+ metaTaskId: target.taskId,
139
+ author: "INTEGRATOR",
140
+ body: finishBody,
141
+ force: false,
142
+ resultProvided: true,
143
+ resultSummary: `Merged via ${prLabel}.`,
144
+ riskLevel: undefined,
145
+ breaking: false,
146
+ taskCommitInfo,
147
+ });
148
+ await createTaskCloseCommit({
149
+ ctx: opts.ctx,
150
+ cwd: opts.cwd,
151
+ rootOverride: opts.rootOverride,
152
+ taskId: target.taskId,
153
+ baseBranchOverride: target.mergedPr.baseRefName ?? meta.base ?? "main",
154
+ quiet: opts.quiet,
155
+ });
156
+ return {
157
+ outcome: "closed",
158
+ taskId: target.taskId,
159
+ mergeHash: target.mergedPr.mergeCommit.oid,
160
+ };
161
+ }
162
+ export function makeRunTaskHostedCloseHandler(getCtx) {
163
+ return async (ctx, parsed) => {
164
+ try {
165
+ const commandCtx = await getCtx("task hosted-close");
166
+ const outcome = await closeHostedTask({
167
+ ctx: commandCtx,
168
+ cwd: ctx.cwd,
169
+ rootOverride: ctx.rootOverride ?? undefined,
170
+ eventJson: parsed.eventJson,
171
+ quiet: parsed.quiet,
172
+ });
173
+ if (parsed.quiet)
174
+ return 0;
175
+ if (outcome.outcome === "noop") {
176
+ process.stdout.write(`${infoMessage(`hosted close skipped: ${outcome.detail}`)}\n`);
177
+ return 0;
178
+ }
179
+ const detail = `merge=${outcome.mergeHash.slice(0, 12)}`;
180
+ process.stdout.write(`${successMessage("task hosted close", outcome.taskId, detail)}\n`);
181
+ if (outcome.outcome === "meta-only") {
182
+ process.stdout.write(`${infoMessage("task was already DONE; committed only the missing hosted PR metadata")}\n`);
183
+ }
184
+ return 0;
185
+ }
186
+ catch (err) {
187
+ throw mapBackendError(err, { command: "task hosted-close", root: ctx.rootOverride ?? null });
188
+ }
189
+ };
190
+ }