agentplane 0.3.9 → 0.3.11

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 (404) hide show
  1. package/assets/AGENTS.md +4 -2
  2. package/assets/agents/CODER.json +1 -1
  3. package/assets/policy/dod.core.md +1 -1
  4. package/assets/policy/governance.md +5 -3
  5. package/assets/policy/incidents.md +19 -77
  6. package/assets/policy/workflow.branch_pr.md +2 -0
  7. package/assets/policy/workflow.direct.md +3 -1
  8. package/bin/agentplane.js +56 -1
  9. package/bin/runtime-watch.js +1 -0
  10. package/bin/stale-dist-policy.d.ts +1 -1
  11. package/bin/stale-dist-policy.js +13 -0
  12. package/dist/.build-manifest.json +462 -202
  13. package/dist/cli/bootstrap-guide.d.ts +1 -0
  14. package/dist/cli/bootstrap-guide.d.ts.map +1 -1
  15. package/dist/cli/bootstrap-guide.js +20 -1
  16. package/dist/cli/command-guide.d.ts.map +1 -1
  17. package/dist/cli/command-guide.js +2 -1
  18. package/dist/cli/command-invocations.d.ts.map +1 -1
  19. package/dist/cli/command-invocations.js +6 -1
  20. package/dist/cli/command-snippets.d.ts +2 -0
  21. package/dist/cli/command-snippets.d.ts.map +1 -1
  22. package/dist/cli/command-snippets.js +2 -0
  23. package/dist/cli/run-cli/command-catalog/core.d.ts +1 -1
  24. package/dist/cli/run-cli/command-catalog/core.d.ts.map +1 -1
  25. package/dist/cli/run-cli/command-catalog/core.js +10 -0
  26. package/dist/cli/run-cli/command-catalog/project.d.ts +1 -1
  27. package/dist/cli/run-cli/command-catalog/project.d.ts.map +1 -1
  28. package/dist/cli/run-cli/command-catalog/project.js +3 -1
  29. package/dist/cli/run-cli/command-catalog/task.d.ts +1 -1
  30. package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -1
  31. package/dist/cli/run-cli/command-catalog/task.js +10 -0
  32. package/dist/cli/run-cli/command-catalog.d.ts +1 -1
  33. package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
  34. package/dist/cli/run-cli/commands/config.d.ts.map +1 -1
  35. package/dist/cli/run-cli/commands/config.js +13 -0
  36. package/dist/cli/run-cli/commands/core/preflight.d.ts.map +1 -1
  37. package/dist/cli/run-cli/commands/core/preflight.js +44 -1
  38. package/dist/cli/run-cli.js +2 -2
  39. package/dist/cli/run-cli.test-helpers.d.ts.map +1 -1
  40. package/dist/cli/run-cli.test-helpers.js +12 -0
  41. package/dist/commands/backend.d.ts.map +1 -1
  42. package/dist/commands/backend.js +4 -0
  43. package/dist/commands/branch/cleanup-merged.d.ts +2 -0
  44. package/dist/commands/branch/cleanup-merged.d.ts.map +1 -1
  45. package/dist/commands/branch/cleanup-merged.js +132 -28
  46. package/dist/commands/branch/work-start.d.ts.map +1 -1
  47. package/dist/commands/branch/work-start.js +60 -1
  48. package/dist/commands/cleanup/merged.command.d.ts +2 -0
  49. package/dist/commands/cleanup/merged.command.d.ts.map +1 -1
  50. package/dist/commands/cleanup/merged.command.js +24 -0
  51. package/dist/commands/doctor/branch-pr.d.ts +4 -0
  52. package/dist/commands/doctor/branch-pr.d.ts.map +1 -0
  53. package/dist/commands/doctor/branch-pr.js +96 -0
  54. package/dist/commands/doctor/fixes.d.ts +5 -0
  55. package/dist/commands/doctor/fixes.d.ts.map +1 -1
  56. package/dist/commands/doctor/fixes.js +70 -0
  57. package/dist/commands/doctor.run.d.ts.map +1 -1
  58. package/dist/commands/doctor.run.js +6 -1
  59. package/dist/commands/finish.run.d.ts.map +1 -1
  60. package/dist/commands/finish.run.js +11 -0
  61. package/dist/commands/finish.spec.d.ts +11 -0
  62. package/dist/commands/finish.spec.d.ts.map +1 -1
  63. package/dist/commands/finish.spec.js +51 -0
  64. package/dist/commands/guard/impl/close-message.d.ts.map +1 -1
  65. package/dist/commands/guard/impl/close-message.js +23 -6
  66. package/dist/commands/guard/impl/commands.d.ts.map +1 -1
  67. package/dist/commands/guard/impl/commands.js +24 -2
  68. package/dist/commands/guard/impl/env.d.ts +1 -0
  69. package/dist/commands/guard/impl/env.d.ts.map +1 -1
  70. package/dist/commands/guard/impl/env.js +1 -0
  71. package/dist/commands/hooks/index.d.ts.map +1 -1
  72. package/dist/commands/hooks/index.js +98 -1
  73. package/dist/commands/incidents/advise.command.d.ts +15 -0
  74. package/dist/commands/incidents/advise.command.d.ts.map +1 -0
  75. package/dist/commands/incidents/advise.command.js +139 -0
  76. package/dist/commands/incidents/collect.command.d.ts +11 -0
  77. package/dist/commands/incidents/collect.command.d.ts.map +1 -0
  78. package/dist/commands/incidents/collect.command.js +72 -0
  79. package/dist/commands/incidents/incidents.command.d.ts +5 -0
  80. package/dist/commands/incidents/incidents.command.d.ts.map +1 -0
  81. package/dist/commands/incidents/incidents.command.js +21 -0
  82. package/dist/commands/incidents/shared.d.ts +76 -0
  83. package/dist/commands/incidents/shared.d.ts.map +1 -0
  84. package/dist/commands/incidents/shared.js +261 -0
  85. package/dist/commands/pr/check.d.ts.map +1 -1
  86. package/dist/commands/pr/check.js +249 -75
  87. package/dist/commands/pr/close-superseded.d.ts +9 -0
  88. package/dist/commands/pr/close-superseded.d.ts.map +1 -0
  89. package/dist/commands/pr/close-superseded.js +129 -0
  90. package/dist/commands/pr/close.d.ts +11 -0
  91. package/dist/commands/pr/close.d.ts.map +1 -0
  92. package/dist/commands/pr/close.js +116 -0
  93. package/dist/commands/pr/index.d.ts +2 -0
  94. package/dist/commands/pr/index.d.ts.map +1 -1
  95. package/dist/commands/pr/index.js +2 -0
  96. package/dist/commands/pr/integrate/artifacts.d.ts +7 -0
  97. package/dist/commands/pr/integrate/artifacts.d.ts.map +1 -1
  98. package/dist/commands/pr/integrate/artifacts.js +66 -1
  99. package/dist/commands/pr/integrate/cmd.d.ts.map +1 -1
  100. package/dist/commands/pr/integrate/cmd.js +20 -0
  101. package/dist/commands/pr/integrate/internal/bootstrap-guidance.d.ts +8 -0
  102. package/dist/commands/pr/integrate/internal/bootstrap-guidance.d.ts.map +1 -0
  103. package/dist/commands/pr/integrate/internal/bootstrap-guidance.js +59 -0
  104. package/dist/commands/pr/integrate/internal/finalize.d.ts.map +1 -1
  105. package/dist/commands/pr/integrate/internal/finalize.js +40 -12
  106. package/dist/commands/pr/integrate/internal/merge.d.ts +4 -0
  107. package/dist/commands/pr/integrate/internal/merge.d.ts.map +1 -1
  108. package/dist/commands/pr/integrate/internal/merge.js +59 -15
  109. package/dist/commands/pr/integrate/internal/post-integrate-bootstrap.d.ts +13 -0
  110. package/dist/commands/pr/integrate/internal/post-integrate-bootstrap.d.ts.map +1 -0
  111. package/dist/commands/pr/integrate/internal/post-integrate-bootstrap.js +25 -0
  112. package/dist/commands/pr/integrate/internal/prepare.d.ts +3 -2
  113. package/dist/commands/pr/integrate/internal/prepare.d.ts.map +1 -1
  114. package/dist/commands/pr/integrate/internal/prepare.js +107 -19
  115. package/dist/commands/pr/internal/freshness.d.ts +20 -0
  116. package/dist/commands/pr/internal/freshness.d.ts.map +1 -0
  117. package/dist/commands/pr/internal/freshness.js +50 -0
  118. package/dist/commands/pr/internal/gh-api.d.ts +6 -0
  119. package/dist/commands/pr/internal/gh-api.d.ts.map +1 -0
  120. package/dist/commands/pr/internal/gh-api.js +80 -0
  121. package/dist/commands/pr/internal/note-store.d.ts +18 -0
  122. package/dist/commands/pr/internal/note-store.d.ts.map +1 -0
  123. package/dist/commands/pr/internal/note-store.js +66 -0
  124. package/dist/commands/pr/internal/pr-paths.d.ts +13 -0
  125. package/dist/commands/pr/internal/pr-paths.d.ts.map +1 -1
  126. package/dist/commands/pr/internal/pr-paths.js +13 -0
  127. package/dist/commands/pr/internal/review-template.d.ts +24 -4
  128. package/dist/commands/pr/internal/review-template.d.ts.map +1 -1
  129. package/dist/commands/pr/internal/review-template.js +221 -33
  130. package/dist/commands/pr/internal/sync.d.ts +41 -0
  131. package/dist/commands/pr/internal/sync.d.ts.map +1 -0
  132. package/dist/commands/pr/internal/sync.js +598 -0
  133. package/dist/commands/pr/note.d.ts.map +1 -1
  134. package/dist/commands/pr/note.js +37 -4
  135. package/dist/commands/pr/open.d.ts +1 -0
  136. package/dist/commands/pr/open.d.ts.map +1 -1
  137. package/dist/commands/pr/open.js +18 -54
  138. package/dist/commands/pr/pr.command.d.ts +15 -0
  139. package/dist/commands/pr/pr.command.d.ts.map +1 -1
  140. package/dist/commands/pr/pr.command.js +124 -5
  141. package/dist/commands/pr/update.d.ts.map +1 -1
  142. package/dist/commands/pr/update.js +58 -74
  143. package/dist/commands/recipes/impl/commands/cache-prune.d.ts.map +1 -1
  144. package/dist/commands/recipes/impl/commands/cache-prune.js +14 -0
  145. package/dist/commands/recipes/impl/commands/install.js +1 -1
  146. package/dist/commands/recipes/impl/commands/list-remote.d.ts.map +1 -1
  147. package/dist/commands/recipes/impl/commands/list-remote.js +1 -0
  148. package/dist/commands/recipes/impl/commands/remove.d.ts.map +1 -1
  149. package/dist/commands/recipes/impl/commands/remove.js +9 -1
  150. package/dist/commands/release/apply.command.d.ts.map +1 -1
  151. package/dist/commands/release/apply.command.js +12 -17
  152. package/dist/commands/release/apply.preflight.d.ts.map +1 -1
  153. package/dist/commands/release/apply.preflight.js +1 -1
  154. package/dist/commands/shared/approval-requirements.d.ts +5 -7
  155. package/dist/commands/shared/approval-requirements.d.ts.map +1 -1
  156. package/dist/commands/shared/approval-requirements.js +3 -73
  157. package/dist/commands/shared/gh-transport.d.ts +16 -0
  158. package/dist/commands/shared/gh-transport.d.ts.map +1 -0
  159. package/dist/commands/shared/gh-transport.js +71 -0
  160. package/dist/commands/shared/git-diff.d.ts +3 -1
  161. package/dist/commands/shared/git-diff.d.ts.map +1 -1
  162. package/dist/commands/shared/git-diff.js +10 -2
  163. package/dist/commands/shared/git-ops.d.ts +1 -0
  164. package/dist/commands/shared/git-ops.d.ts.map +1 -1
  165. package/dist/commands/shared/git-ops.js +15 -0
  166. package/dist/commands/shared/git-worktree.d.ts +2 -0
  167. package/dist/commands/shared/git-worktree.d.ts.map +1 -1
  168. package/dist/commands/shared/git-worktree.js +22 -2
  169. package/dist/commands/shared/network-approval.d.ts +2 -0
  170. package/dist/commands/shared/network-approval.d.ts.map +1 -1
  171. package/dist/commands/shared/network-approval.js +1 -1
  172. package/dist/commands/shared/post-commit-pr-artifacts.d.ts +9 -0
  173. package/dist/commands/shared/post-commit-pr-artifacts.d.ts.map +1 -0
  174. package/dist/commands/shared/post-commit-pr-artifacts.js +22 -0
  175. package/dist/commands/shared/pr-meta.d.ts +29 -0
  176. package/dist/commands/shared/pr-meta.d.ts.map +1 -1
  177. package/dist/commands/shared/pr-meta.js +152 -3
  178. package/dist/commands/shared/task-backend.d.ts +9 -0
  179. package/dist/commands/shared/task-backend.d.ts.map +1 -1
  180. package/dist/commands/shared/task-backend.js +34 -22
  181. package/dist/commands/shared/task-local-freshness.d.ts +13 -0
  182. package/dist/commands/shared/task-local-freshness.d.ts.map +1 -0
  183. package/dist/commands/shared/task-local-freshness.js +20 -0
  184. package/dist/commands/shared/task-mutation.d.ts +2 -0
  185. package/dist/commands/shared/task-mutation.d.ts.map +1 -1
  186. package/dist/commands/shared/task-mutation.js +7 -0
  187. package/dist/commands/task/block.d.ts.map +1 -1
  188. package/dist/commands/task/block.js +1 -0
  189. package/dist/commands/task/close-duplicate.d.ts.map +1 -1
  190. package/dist/commands/task/close-duplicate.js +34 -1
  191. package/dist/commands/task/close-shared.d.ts.map +1 -1
  192. package/dist/commands/task/close-shared.js +1 -0
  193. package/dist/commands/task/derive.js +1 -1
  194. package/dist/commands/task/doc-template.d.ts.map +1 -1
  195. package/dist/commands/task/doc-template.js +7 -11
  196. package/dist/commands/task/findings-add.command.d.ts +20 -0
  197. package/dist/commands/task/findings-add.command.d.ts.map +1 -0
  198. package/dist/commands/task/findings-add.command.js +165 -0
  199. package/dist/commands/task/findings.command.d.ts +7 -0
  200. package/dist/commands/task/findings.command.d.ts.map +1 -0
  201. package/dist/commands/task/findings.command.js +20 -0
  202. package/dist/commands/task/findings.d.ts +63 -0
  203. package/dist/commands/task/findings.d.ts.map +1 -0
  204. package/dist/commands/task/findings.js +188 -0
  205. package/dist/commands/task/finish-shared.d.ts +1 -0
  206. package/dist/commands/task/finish-shared.d.ts.map +1 -1
  207. package/dist/commands/task/finish-shared.js +60 -3
  208. package/dist/commands/task/finish.d.ts +10 -0
  209. package/dist/commands/task/finish.d.ts.map +1 -1
  210. package/dist/commands/task/finish.js +143 -0
  211. package/dist/commands/task/hosted-close-pr.command.d.ts +11 -0
  212. package/dist/commands/task/hosted-close-pr.command.d.ts.map +1 -0
  213. package/dist/commands/task/hosted-close-pr.command.js +414 -0
  214. package/dist/commands/task/hosted-close.command.d.ts.map +1 -1
  215. package/dist/commands/task/hosted-close.command.js +49 -1
  216. package/dist/commands/task/hosted-merge-sync.d.ts +38 -0
  217. package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -1
  218. package/dist/commands/task/hosted-merge-sync.js +249 -17
  219. package/dist/commands/task/index.d.ts +1 -0
  220. package/dist/commands/task/index.d.ts.map +1 -1
  221. package/dist/commands/task/index.js +1 -0
  222. package/dist/commands/task/new.d.ts +1 -0
  223. package/dist/commands/task/new.d.ts.map +1 -1
  224. package/dist/commands/task/new.js +140 -30
  225. package/dist/commands/task/new.spec.d.ts.map +1 -1
  226. package/dist/commands/task/new.spec.js +7 -0
  227. package/dist/commands/task/normalize.command.d.ts +2 -0
  228. package/dist/commands/task/normalize.command.d.ts.map +1 -1
  229. package/dist/commands/task/normalize.command.js +45 -0
  230. package/dist/commands/task/normalize.d.ts +2 -0
  231. package/dist/commands/task/normalize.d.ts.map +1 -1
  232. package/dist/commands/task/normalize.js +85 -8
  233. package/dist/commands/task/plan.d.ts.map +1 -1
  234. package/dist/commands/task/plan.js +7 -10
  235. package/dist/commands/task/set-status.d.ts.map +1 -1
  236. package/dist/commands/task/set-status.js +1 -0
  237. package/dist/commands/task/shared/docs.d.ts +6 -0
  238. package/dist/commands/task/shared/docs.d.ts.map +1 -1
  239. package/dist/commands/task/shared/docs.js +14 -0
  240. package/dist/commands/task/shared/transition-command.d.ts +2 -0
  241. package/dist/commands/task/shared/transition-command.d.ts.map +1 -1
  242. package/dist/commands/task/shared/transition-command.js +1 -0
  243. package/dist/commands/task/shared/transitions.d.ts.map +1 -1
  244. package/dist/commands/task/shared/transitions.js +11 -1
  245. package/dist/commands/task/shared.d.ts +1 -1
  246. package/dist/commands/task/shared.d.ts.map +1 -1
  247. package/dist/commands/task/shared.js +1 -1
  248. package/dist/commands/task/start-ready.d.ts.map +1 -1
  249. package/dist/commands/task/start-ready.js +98 -1
  250. package/dist/commands/task/start.d.ts.map +1 -1
  251. package/dist/commands/task/start.js +18 -10
  252. package/dist/commands/task/task.command.d.ts.map +1 -1
  253. package/dist/commands/task/task.command.js +4 -0
  254. package/dist/commands/task/verify-command-shared.d.ts +19 -0
  255. package/dist/commands/task/verify-command-shared.d.ts.map +1 -1
  256. package/dist/commands/task/verify-command-shared.js +152 -1
  257. package/dist/commands/task/verify-ok.command.d.ts.map +1 -1
  258. package/dist/commands/task/verify-ok.command.js +15 -2
  259. package/dist/commands/task/verify-record.d.ts +36 -0
  260. package/dist/commands/task/verify-record.d.ts.map +1 -1
  261. package/dist/commands/task/verify-record.js +193 -11
  262. package/dist/commands/task/verify-rework.command.d.ts.map +1 -1
  263. package/dist/commands/task/verify-rework.command.js +15 -2
  264. package/dist/commands/task/verify-show.command.d.ts +1 -1
  265. package/dist/commands/task/verify-show.command.d.ts.map +1 -1
  266. package/dist/commands/task/verify-show.command.js +28 -1
  267. package/dist/commands/upgrade.d.ts.map +1 -1
  268. package/dist/commands/upgrade.js +6 -1
  269. package/dist/commands/verify.run.d.ts.map +1 -1
  270. package/dist/commands/verify.run.js +12 -0
  271. package/dist/commands/verify.spec.d.ts +2 -6
  272. package/dist/commands/verify.spec.d.ts.map +1 -1
  273. package/dist/commands/verify.spec.js +30 -3
  274. package/dist/policy/engine.d.ts +3 -1
  275. package/dist/policy/engine.d.ts.map +1 -1
  276. package/dist/policy/engine.js +5 -6
  277. package/dist/policy/taxonomy.d.ts +17 -0
  278. package/dist/policy/taxonomy.d.ts.map +1 -0
  279. package/dist/policy/taxonomy.js +302 -0
  280. package/dist/policy/types.d.ts +2 -1
  281. package/dist/policy/types.d.ts.map +1 -1
  282. package/dist/runner/artifacts.d.ts.map +1 -1
  283. package/dist/runner/artifacts.js +2 -0
  284. package/dist/runner/context/base-prompts.d.ts +25 -0
  285. package/dist/runner/context/base-prompts.d.ts.map +1 -1
  286. package/dist/runner/context/base-prompts.js +182 -54
  287. package/dist/runner/context/recipe-context.d.ts.map +1 -1
  288. package/dist/runner/context/recipe-context.js +5 -0
  289. package/dist/runner/types.d.ts +12 -0
  290. package/dist/runner/types.d.ts.map +1 -1
  291. package/dist/runner/usecases/scenario-materialize-task.d.ts.map +1 -1
  292. package/dist/runner/usecases/scenario-materialize-task.js +81 -11
  293. package/dist/runner/usecases/task-run-inspect.d.ts.map +1 -1
  294. package/dist/runner/usecases/task-run-inspect.js +9 -7
  295. package/dist/runner/usecases/task-run-lifecycle-shared.d.ts.map +1 -1
  296. package/dist/runner/usecases/task-run-lifecycle-shared.js +8 -6
  297. package/dist/runner/usecases/task-run.d.ts.map +1 -1
  298. package/dist/runner/usecases/task-run.js +59 -12
  299. package/dist/runtime/approvals/index.d.ts +3 -0
  300. package/dist/runtime/approvals/index.d.ts.map +1 -0
  301. package/dist/runtime/approvals/index.js +1 -0
  302. package/dist/runtime/approvals/runtime.d.ts +12 -0
  303. package/dist/runtime/approvals/runtime.d.ts.map +1 -0
  304. package/dist/runtime/approvals/runtime.js +154 -0
  305. package/dist/runtime/approvals/types.d.ts +31 -0
  306. package/dist/runtime/approvals/types.d.ts.map +1 -0
  307. package/dist/runtime/approvals/types.js +1 -0
  308. package/dist/runtime/behavior/index.d.ts +3 -0
  309. package/dist/runtime/behavior/index.d.ts.map +1 -0
  310. package/dist/runtime/behavior/index.js +1 -0
  311. package/dist/runtime/behavior/resolve.d.ts +7 -0
  312. package/dist/runtime/behavior/resolve.d.ts.map +1 -0
  313. package/dist/runtime/behavior/resolve.js +66 -0
  314. package/dist/runtime/behavior/types.d.ts +25 -0
  315. package/dist/runtime/behavior/types.d.ts.map +1 -0
  316. package/dist/runtime/behavior/types.js +1 -0
  317. package/dist/runtime/capabilities/backend.d.ts +7 -0
  318. package/dist/runtime/capabilities/backend.d.ts.map +1 -0
  319. package/dist/runtime/capabilities/backend.js +104 -0
  320. package/dist/runtime/capabilities/index.d.ts +6 -0
  321. package/dist/runtime/capabilities/index.d.ts.map +1 -0
  322. package/dist/runtime/capabilities/index.js +4 -0
  323. package/dist/runtime/capabilities/recipe.d.ts +10 -0
  324. package/dist/runtime/capabilities/recipe.d.ts.map +1 -0
  325. package/dist/runtime/capabilities/recipe.js +123 -0
  326. package/dist/runtime/capabilities/registry.d.ts +6 -0
  327. package/dist/runtime/capabilities/registry.d.ts.map +1 -0
  328. package/dist/runtime/capabilities/registry.js +69 -0
  329. package/dist/runtime/capabilities/runner.d.ts +8 -0
  330. package/dist/runtime/capabilities/runner.d.ts.map +1 -0
  331. package/dist/runtime/capabilities/runner.js +73 -0
  332. package/dist/runtime/capabilities/types.d.ts +28 -0
  333. package/dist/runtime/capabilities/types.d.ts.map +1 -0
  334. package/dist/runtime/capabilities/types.js +1 -0
  335. package/dist/runtime/execution-profile/index.d.ts +3 -0
  336. package/dist/runtime/execution-profile/index.d.ts.map +1 -0
  337. package/dist/runtime/execution-profile/index.js +1 -0
  338. package/dist/runtime/execution-profile/resolve.d.ts +9 -0
  339. package/dist/runtime/execution-profile/resolve.d.ts.map +1 -0
  340. package/dist/runtime/execution-profile/resolve.js +80 -0
  341. package/dist/runtime/execution-profile/types.d.ts +27 -0
  342. package/dist/runtime/execution-profile/types.d.ts.map +1 -0
  343. package/dist/runtime/execution-profile/types.js +1 -0
  344. package/dist/runtime/explain/index.d.ts +3 -0
  345. package/dist/runtime/explain/index.d.ts.map +1 -0
  346. package/dist/runtime/explain/index.js +1 -0
  347. package/dist/runtime/explain/resolve.d.ts +14 -0
  348. package/dist/runtime/explain/resolve.d.ts.map +1 -0
  349. package/dist/runtime/explain/resolve.js +50 -0
  350. package/dist/runtime/explain/types.d.ts +28 -0
  351. package/dist/runtime/explain/types.d.ts.map +1 -0
  352. package/dist/runtime/explain/types.js +1 -0
  353. package/dist/runtime/harness/index.d.ts +4 -0
  354. package/dist/runtime/harness/index.d.ts.map +1 -0
  355. package/dist/runtime/harness/index.js +2 -0
  356. package/dist/runtime/harness/resolve-from-command-context.d.ts +4 -0
  357. package/dist/runtime/harness/resolve-from-command-context.d.ts.map +1 -0
  358. package/dist/runtime/harness/resolve-from-command-context.js +11 -0
  359. package/dist/runtime/harness/resolve.d.ts +13 -0
  360. package/dist/runtime/harness/resolve.d.ts.map +1 -0
  361. package/dist/runtime/harness/resolve.js +146 -0
  362. package/dist/runtime/harness/types.d.ts +65 -0
  363. package/dist/runtime/harness/types.d.ts.map +1 -0
  364. package/dist/runtime/harness/types.js +1 -0
  365. package/dist/runtime/incidents/index.d.ts +3 -0
  366. package/dist/runtime/incidents/index.d.ts.map +1 -0
  367. package/dist/runtime/incidents/index.js +1 -0
  368. package/dist/runtime/incidents/resolve.d.ts +26 -0
  369. package/dist/runtime/incidents/resolve.d.ts.map +1 -0
  370. package/dist/runtime/incidents/resolve.js +683 -0
  371. package/dist/runtime/incidents/types.d.ts +84 -0
  372. package/dist/runtime/incidents/types.d.ts.map +1 -0
  373. package/dist/runtime/incidents/types.js +1 -0
  374. package/dist/runtime/protocol/index.d.ts +3 -0
  375. package/dist/runtime/protocol/index.d.ts.map +1 -0
  376. package/dist/runtime/protocol/index.js +2 -0
  377. package/dist/runtime/protocol/resolve.d.ts +16 -0
  378. package/dist/runtime/protocol/resolve.d.ts.map +1 -0
  379. package/dist/runtime/protocol/resolve.js +36 -0
  380. package/dist/runtime/protocol/types.d.ts +36 -0
  381. package/dist/runtime/protocol/types.d.ts.map +1 -0
  382. package/dist/runtime/protocol/types.js +1 -0
  383. package/dist/runtime/task-intake/index.d.ts +3 -0
  384. package/dist/runtime/task-intake/index.d.ts.map +1 -0
  385. package/dist/runtime/task-intake/index.js +1 -0
  386. package/dist/runtime/task-intake/resolve.d.ts +48 -0
  387. package/dist/runtime/task-intake/resolve.d.ts.map +1 -0
  388. package/dist/runtime/task-intake/resolve.js +316 -0
  389. package/dist/runtime/task-intake/types.d.ts +117 -0
  390. package/dist/runtime/task-intake/types.d.ts.map +1 -0
  391. package/dist/runtime/task-intake/types.js +1 -0
  392. package/dist/shared/env.d.ts +1 -0
  393. package/dist/shared/env.d.ts.map +1 -1
  394. package/dist/shared/env.js +22 -1
  395. package/dist/shared/protected-paths.d.ts +4 -0
  396. package/dist/shared/protected-paths.d.ts.map +1 -1
  397. package/dist/shared/protected-paths.js +8 -4
  398. package/dist/usecases/context/resolve-context.d.ts +55 -6
  399. package/dist/usecases/context/resolve-context.d.ts.map +1 -1
  400. package/dist/usecases/context/resolve-context.js +96 -6
  401. package/dist/usecases/task/task-list-usecase.d.ts.map +1 -1
  402. package/dist/usecases/task/task-list-usecase.js +8 -2
  403. package/dist/usecases/task/task-new-usecase.js +4 -4
  404. package/package.json +2 -2
@@ -1,3 +1,4 @@
1
+ import { readFile } from "node:fs/promises";
1
2
  import path from "node:path";
2
3
  import { resolveBaseBranch } from "@agentplaneorg/core";
3
4
  import { mapBackendError } from "../../cli/error-map.js";
@@ -6,12 +7,109 @@ import { CliError } from "../../shared/errors.js";
6
7
  import { ensureGitClean } from "../guard/index.js";
7
8
  import { execFileAsync, gitEnv } from "../shared/git.js";
8
9
  import { gitDiffNames } from "../shared/git-diff.js";
9
- import { gitBranchExists, gitCurrentBranch } from "../shared/git-ops.js";
10
- import { findWorktreeForBranch, gitListTaskBranches, parseTaskIdFromBranch, } from "../shared/git-worktree.js";
10
+ import { gitBranchExists, gitCurrentBranch, gitIsAncestor } from "../shared/git-ops.js";
11
+ import { findWorktreeForBranch, gitListBranchesByPrefixes, parseTaskIdFromCloseBranch, parseTaskIdFromBranch, } from "../shared/git-worktree.js";
11
12
  import { isPathWithin, resolvePathFallback } from "../shared/path.js";
12
- import { listTaskProjection, loadCommandContext, } from "../shared/task-backend.js";
13
+ import { parsePrMeta } from "../shared/pr-meta.js";
14
+ import { loadTaskFromContext, loadCommandContext, } from "../shared/task-backend.js";
13
15
  import { archivePrArtifacts } from "./internal/archive-pr.js";
14
16
  const output = createCliEmitter();
17
+ function resolveCleanupBranchTaskId(opts) {
18
+ const taskId = parseTaskIdFromBranch(opts.prefix, opts.branch);
19
+ if (taskId)
20
+ return { taskId, kind: "task" };
21
+ const closeTaskId = parseTaskIdFromCloseBranch(opts.branch);
22
+ if (closeTaskId)
23
+ return { taskId: closeTaskId, kind: "task-close" };
24
+ return null;
25
+ }
26
+ async function readCleanupPrMetaIfPresent(opts) {
27
+ const metaPath = path.join(opts.gitRoot, opts.workflowDir, opts.taskId, "pr", "meta.json");
28
+ try {
29
+ const raw = await readFile(metaPath, "utf8");
30
+ return parsePrMeta(raw, opts.taskId);
31
+ }
32
+ catch {
33
+ return null;
34
+ }
35
+ }
36
+ async function taskLifecycleIsOnBase(opts) {
37
+ const taskCommitHash = opts.task.commit?.hash?.trim() ?? "";
38
+ if (taskCommitHash && (await gitIsAncestor(opts.gitRoot, taskCommitHash, opts.baseBranch))) {
39
+ return true;
40
+ }
41
+ const meta = await readCleanupPrMetaIfPresent({
42
+ gitRoot: opts.gitRoot,
43
+ workflowDir: opts.workflowDir,
44
+ taskId: opts.taskId,
45
+ });
46
+ const mergeCommit = meta?.status === "MERGED" ? (meta.merge_commit?.trim() ?? "") : "";
47
+ return (mergeCommit.length > 0 && (await gitIsAncestor(opts.gitRoot, mergeCommit, opts.baseBranch)));
48
+ }
49
+ async function resolveCleanupCandidates(opts) {
50
+ const prefix = opts.ctx.config.branch.task_prefix;
51
+ const branches = await gitListBranchesByPrefixes(opts.gitRoot, [prefix, "task-close"]);
52
+ const taskCache = new Map();
53
+ const candidates = [];
54
+ for (const branch of branches) {
55
+ if (branch === opts.baseBranch)
56
+ continue;
57
+ const target = resolveCleanupBranchTaskId({ branch, prefix });
58
+ if (!target)
59
+ continue;
60
+ let task = taskCache.get(target.taskId) ?? null;
61
+ if (!taskCache.has(target.taskId)) {
62
+ try {
63
+ task = await loadTaskFromContext({ ctx: opts.ctx, taskId: target.taskId });
64
+ }
65
+ catch {
66
+ task = null;
67
+ }
68
+ taskCache.set(target.taskId, task);
69
+ }
70
+ if (!task)
71
+ continue;
72
+ const status = String(task.status || "").toUpperCase();
73
+ if (status !== "DONE")
74
+ continue;
75
+ const diff = await gitDiffNames(opts.gitRoot, opts.baseBranch, branch);
76
+ const lifecycleOnBase = await taskLifecycleIsOnBase({
77
+ gitRoot: opts.gitRoot,
78
+ workflowDir: opts.workflowDir,
79
+ baseBranch: opts.baseBranch,
80
+ task,
81
+ taskId: target.taskId,
82
+ });
83
+ if (diff.length > 0 && !lifecycleOnBase)
84
+ continue;
85
+ const worktreePath = await findWorktreeForBranch(opts.gitRoot, branch);
86
+ candidates.push({ taskId: target.taskId, branch, worktreePath });
87
+ }
88
+ return candidates;
89
+ }
90
+ function isMissingRemoteBranchDelete(error) {
91
+ const stdout = String(error?.stdout ?? "");
92
+ const stderr = String(error?.stderr ?? "");
93
+ const text = `${stdout}\n${stderr}`;
94
+ return (text.includes("remote ref does not exist") ||
95
+ text.includes("unable to delete") ||
96
+ text.includes("remote reference is not a full refname"));
97
+ }
98
+ async function deleteRemoteBranchIfPresent(gitRoot, branch) {
99
+ try {
100
+ await execFileAsync("git", ["push", "origin", "--delete", branch], {
101
+ cwd: gitRoot,
102
+ env: gitEnv(),
103
+ });
104
+ return true;
105
+ }
106
+ catch (error) {
107
+ if (isMissingRemoteBranchDelete(error)) {
108
+ return false;
109
+ }
110
+ throw error;
111
+ }
112
+ }
15
113
  export async function cmdCleanupMerged(opts) {
16
114
  try {
17
115
  const ctx = opts.ctx ??
@@ -26,6 +124,12 @@ export async function cmdCleanupMerged(opts) {
26
124
  });
27
125
  }
28
126
  await ensureGitClean({ cwd: opts.cwd, rootOverride: opts.rootOverride });
127
+ if (opts.fetch) {
128
+ await execFileAsync("git", ["fetch", "--prune", "origin"], {
129
+ cwd: resolved.gitRoot,
130
+ env: gitEnv(),
131
+ });
132
+ }
29
133
  const baseBranch = await resolveBaseBranch({
30
134
  cwd: opts.cwd,
31
135
  rootOverride: opts.rootOverride ?? null,
@@ -55,33 +159,18 @@ export async function cmdCleanupMerged(opts) {
55
159
  });
56
160
  }
57
161
  const repoRoot = await resolvePathFallback(resolved.gitRoot);
58
- const tasks = (await listTaskProjection(ctx)) ?? [];
59
- const tasksById = new Map(tasks.map((task) => [task.id, task]));
60
- const prefix = config.branch.task_prefix;
61
- const branches = await gitListTaskBranches(resolved.gitRoot, prefix);
62
- const candidates = [];
63
- for (const branch of branches) {
64
- if (branch === baseBranch)
65
- continue;
66
- const taskId = parseTaskIdFromBranch(prefix, branch);
67
- if (!taskId)
68
- continue;
69
- const task = tasksById.get(taskId);
70
- if (!task)
71
- continue;
72
- const status = String(task.status || "").toUpperCase();
73
- if (status !== "DONE")
74
- continue;
75
- const diff = await gitDiffNames(resolved.gitRoot, baseBranch, branch);
76
- if (diff.length > 0)
77
- continue;
78
- const worktreePath = await findWorktreeForBranch(resolved.gitRoot, branch);
79
- candidates.push({ taskId, branch, worktreePath });
80
- }
162
+ const candidates = await resolveCleanupCandidates({
163
+ ctx,
164
+ gitRoot: resolved.gitRoot,
165
+ workflowDir: config.paths.workflow_dir,
166
+ baseBranch,
167
+ });
81
168
  const sortedCandidates = candidates.toSorted((a, b) => a.taskId.localeCompare(b.taskId));
82
169
  if (!opts.quiet) {
83
170
  const archiveLabel = opts.archive ? " archive=on" : "";
84
- output.line(`cleanup merged (base=${baseBranch}${archiveLabel})`);
171
+ const fetchLabel = opts.fetch ? " fetch=on" : "";
172
+ const remoteLabel = opts.deleteRemoteBranches ? " remote=delete" : "";
173
+ output.line(`cleanup merged (base=${baseBranch}${archiveLabel}${fetchLabel}${remoteLabel})`);
85
174
  if (sortedCandidates.length === 0) {
86
175
  output.line("no candidates");
87
176
  return 0;
@@ -96,6 +185,7 @@ export async function cmdCleanupMerged(opts) {
96
185
  }
97
186
  return 0;
98
187
  }
188
+ let deletedRemoteBranches = 0;
99
189
  for (const item of sortedCandidates) {
100
190
  const worktreePath = item.worktreePath ? await resolvePathFallback(item.worktreePath) : null;
101
191
  if (worktreePath) {
@@ -128,9 +218,23 @@ export async function cmdCleanupMerged(opts) {
128
218
  cwd: resolved.gitRoot,
129
219
  env: gitEnv(),
130
220
  });
221
+ if (opts.deleteRemoteBranches) {
222
+ deletedRemoteBranches += (await deleteRemoteBranchIfPresent(resolved.gitRoot, item.branch))
223
+ ? 1
224
+ : 0;
225
+ }
226
+ }
227
+ if (opts.deleteRemoteBranches) {
228
+ await execFileAsync("git", ["fetch", "--prune", "origin"], {
229
+ cwd: resolved.gitRoot,
230
+ env: gitEnv(),
231
+ });
131
232
  }
132
233
  if (!opts.quiet) {
133
- output.success("cleanup merged", undefined, `deleted=${candidates.length}`);
234
+ const remoteDetail = opts.deleteRemoteBranches
235
+ ? ` remote_deleted=${deletedRemoteBranches}`
236
+ : "";
237
+ output.success("cleanup merged", undefined, `deleted=${candidates.length}${remoteDetail}`);
134
238
  }
135
239
  return 0;
136
240
  }
@@ -1 +1 @@
1
- {"version":3,"file":"work-start.d.ts","sourceRoot":"","sources":["../../../src/commands/branch/work-start.ts"],"names":[],"mappings":"AAeA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AAiInC,wBAAsB,YAAY,CAAC,IAAI,EAAE;IACvC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;CACnB,GAAG,OAAO,CAAC,MAAM,CAAC,CAqJlB"}
1
+ {"version":3,"file":"work-start.d.ts","sourceRoot":"","sources":["../../../src/commands/branch/work-start.ts"],"names":[],"mappings":"AAeA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AAkMnC,wBAAsB,YAAY,CAAC,IAAI,EAAE;IACvC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;CACnB,GAAG,OAAO,CAAC,MAAM,CAAC,CA6JlB"}
@@ -1,4 +1,4 @@
1
- import { copyFile, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
1
+ import { copyFile, cp, mkdir, readFile, readdir, symlink, writeFile } from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { resolveBaseBranch } from "@agentplaneorg/core";
4
4
  import { LocalBackend } from "../../backends/task-backend.js";
@@ -62,6 +62,57 @@ async function materializeLocalBackendReadmesForWorktree(opts) {
62
62
  await copyFile(sourceReadme, targetReadme);
63
63
  }
64
64
  }
65
+ async function materializeRepoLocalDistForWorktree(opts) {
66
+ const sourceRoots = [path.resolve(opts.repoRoot), path.resolve(process.cwd())];
67
+ const copyTargets = [
68
+ ["packages/core/dist", "packages/core/dist"],
69
+ ["packages/agentplane/dist", "packages/agentplane/dist"],
70
+ ["packages/agentplane/bin", "packages/agentplane/bin"],
71
+ ];
72
+ for (const [sourceRelativePath, targetRelativePath] of copyTargets) {
73
+ let sourcePath = "";
74
+ for (const sourceRoot of sourceRoots) {
75
+ const candidate = path.join(sourceRoot, sourceRelativePath);
76
+ if (await fileExists(candidate)) {
77
+ sourcePath = candidate;
78
+ break;
79
+ }
80
+ }
81
+ if (!sourcePath)
82
+ continue;
83
+ const targetPath = path.join(opts.worktreePath, targetRelativePath);
84
+ if (await fileExists(targetPath))
85
+ continue;
86
+ await mkdir(path.dirname(targetPath), { recursive: true });
87
+ await cp(sourcePath, targetPath, { recursive: true });
88
+ }
89
+ }
90
+ async function linkDirectoryIntoWorktree(opts) {
91
+ const sourcePath = path.join(opts.repoRoot, opts.relativePath);
92
+ if (!(await fileExists(sourcePath)))
93
+ return false;
94
+ const targetPath = path.join(opts.worktreePath, opts.relativePath);
95
+ if (await fileExists(targetPath))
96
+ return false;
97
+ await mkdir(path.dirname(targetPath), { recursive: true });
98
+ await symlink(sourcePath, targetPath, process.platform === "win32" ? "junction" : "dir");
99
+ return true;
100
+ }
101
+ async function materializeRepoLocalInstallLayoutForWorktree(opts) {
102
+ const linkTargets = [
103
+ "node_modules",
104
+ path.join("packages", "core", "node_modules"),
105
+ path.join("packages", "agentplane", "node_modules"),
106
+ "agentplane-recipes",
107
+ ];
108
+ for (const relativePath of linkTargets) {
109
+ await linkDirectoryIntoWorktree({
110
+ repoRoot: opts.repoRoot,
111
+ worktreePath: opts.worktreePath,
112
+ relativePath,
113
+ });
114
+ }
115
+ }
65
116
  async function ensureGitClean(gitRoot) {
66
117
  const { stdout } = await execFileAsync("git", ["status", "--porcelain"], {
67
118
  cwd: gitRoot,
@@ -228,6 +279,14 @@ export async function cmdWorkStart(opts) {
228
279
  repoRoot: resolved.gitRoot,
229
280
  worktreePath,
230
281
  });
282
+ await materializeRepoLocalDistForWorktree({
283
+ repoRoot: resolved.gitRoot,
284
+ worktreePath,
285
+ });
286
+ await materializeRepoLocalInstallLayoutForWorktree({
287
+ repoRoot: resolved.gitRoot,
288
+ worktreePath,
289
+ });
231
290
  }
232
291
  else {
233
292
  if (branchExists) {
@@ -7,6 +7,8 @@ export type CleanupMergedParsed = {
7
7
  base: string | null;
8
8
  yes: boolean;
9
9
  archive: boolean;
10
+ deleteRemoteBranches: boolean;
11
+ fetch: boolean;
10
12
  quiet: boolean;
11
13
  };
12
14
  export declare const cleanupMergedSpec: CommandSpec<CleanupMergedParsed>;
@@ -1 +1 @@
1
- {"version":3,"file":"merged.command.d.ts","sourceRoot":"","sources":["../../../src/commands/cleanup/merged.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAIhE,KAAK,kBAAkB,GAAG,kBAAkB,CAAC;AAE7C,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,kBAAkB,CAUvD,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,mBAAmB,CAkC9D,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,cAAc,CAAC,kBAAkB,CAQzD,CAAC;AAEF,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,IAC5E,KAAK,UAAU,EAAE,GAAG,mBAAmB,KAAG,OAAO,CAAC,MAAM,CAAC,CAWxE"}
1
+ {"version":3,"file":"merged.command.d.ts","sourceRoot":"","sources":["../../../src/commands/cleanup/merged.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAIhE,KAAK,kBAAkB,GAAG,kBAAkB,CAAC;AAE7C,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,kBAAkB,CAUvD,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,mBAAmB,CAwD9D,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,cAAc,CAAC,kBAAkB,CAQzD,CAAC;AAEF,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,IAC5E,KAAK,UAAU,EAAE,GAAG,mBAAmB,KAAG,OAAO,CAAC,MAAM,CAAC,CAaxE"}
@@ -25,6 +25,18 @@ export const cleanupMergedSpec = {
25
25
  default: false,
26
26
  description: "Archive PR artifacts before deletion.",
27
27
  },
28
+ {
29
+ kind: "boolean",
30
+ name: "delete-remote-branches",
31
+ default: false,
32
+ description: "Also delete matching remote task branches on origin.",
33
+ },
34
+ {
35
+ kind: "boolean",
36
+ name: "fetch",
37
+ default: false,
38
+ description: "Fetch and prune origin before candidate resolution.",
39
+ },
28
40
  { kind: "boolean", name: "quiet", default: false, description: "Reduce output noise." },
29
41
  ],
30
42
  examples: [
@@ -33,6 +45,14 @@ export const cleanupMergedSpec = {
33
45
  cmd: "agentplane cleanup merged --yes --archive",
34
46
  why: "Delete candidates and archive PR artifacts.",
35
47
  },
48
+ {
49
+ cmd: "agentplane cleanup merged --yes --delete-remote-branches",
50
+ why: "Delete candidates and matching remote task branches on origin.",
51
+ },
52
+ {
53
+ cmd: "agentplane cleanup merged --fetch",
54
+ why: "Refresh origin before evaluating cleanup candidates.",
55
+ },
36
56
  ],
37
57
  validateRaw: (raw) => {
38
58
  const base = typeof raw.opts.base === "string" ? raw.opts.base.trim() : "";
@@ -44,6 +64,8 @@ export const cleanupMergedSpec = {
44
64
  base: typeof raw.opts.base === "string" ? raw.opts.base : null,
45
65
  yes: raw.opts.yes === true,
46
66
  archive: raw.opts.archive === true,
67
+ deleteRemoteBranches: raw.opts["delete-remote-branches"] === true,
68
+ fetch: raw.opts.fetch === true,
47
69
  quiet: raw.opts.quiet === true,
48
70
  }),
49
71
  };
@@ -65,6 +87,8 @@ export function makeRunCleanupMergedHandler(getCtx) {
65
87
  base: p.base ?? undefined,
66
88
  yes: p.yes,
67
89
  archive: p.archive,
90
+ deleteRemoteBranches: p.deleteRemoteBranches,
91
+ fetch: p.fetch,
68
92
  quiet: p.quiet,
69
93
  });
70
94
  };
@@ -0,0 +1,4 @@
1
+ import type { CommandContext } from "../shared/task-backend.js";
2
+ export declare function checkBranchPrShippedTaskDrift(ctx?: CommandContext): Promise<string[]>;
3
+ export declare function checkBranchPrDoneTaskOpenPrDrift(ctx?: CommandContext): Promise<string[]>;
4
+ //# sourceMappingURL=branch-pr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"branch-pr.d.ts","sourceRoot":"","sources":["../../../src/commands/doctor/branch-pr.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAMhE,wBAAsB,6BAA6B,CAAC,GAAG,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAuC3F;AAED,wBAAsB,gCAAgC,CAAC,GAAG,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAkC9F"}
@@ -0,0 +1,96 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { renderDiagnosticFinding } from "../../shared/diagnostics.js";
4
+ import { findDoneBranchPrTasksWithOpenPrArtifacts, findLocallyShippedBranchPrTasks, } from "../task/hosted-merge-sync.js";
5
+ export async function checkBranchPrShippedTaskDrift(ctx) {
6
+ if (ctx?.backendId !== "local" || ctx.config.workflow_mode !== "branch_pr")
7
+ return [];
8
+ let tasks = [];
9
+ try {
10
+ tasks = await ctx.taskBackend.listTasks();
11
+ }
12
+ catch {
13
+ return [];
14
+ }
15
+ if (tasks.length === 0)
16
+ return [];
17
+ const matches = await findLocallyShippedBranchPrTasks({ ctx, tasks });
18
+ if (matches.length === 0)
19
+ return [];
20
+ const examples = matches
21
+ .slice(0, 5)
22
+ .map((entry) => `${entry.taskId}@${entry.base}:${entry.commitHash.slice(0, 12)} verified_via=${entry.verificationSource}`)
23
+ .join(", ");
24
+ return [
25
+ renderDiagnosticFinding({
26
+ severity: "WARN",
27
+ state: "branch_pr tasks appear shipped on the base branch but remain open",
28
+ likelyCause: "the verified task commit already landed on the base branch, but canonical task closure artifacts were never reconciled",
29
+ nextAction: {
30
+ command: "agentplane task normalize --sync-branch-pr-state",
31
+ reason: "mark locally shipped branch_pr tasks as DONE in the task projection before committing the reconciled task artifacts on the base branch",
32
+ },
33
+ details: [
34
+ `Affected tasks: ${matches.length}`,
35
+ examples ? `Examples: ${examples}` : "Examples unavailable.",
36
+ ],
37
+ }),
38
+ ];
39
+ }
40
+ export async function checkBranchPrDoneTaskOpenPrDrift(ctx) {
41
+ if (ctx?.backendId !== "local" || ctx.config.workflow_mode !== "branch_pr")
42
+ return [];
43
+ const tasks = await readDoneTaskSnapshot(ctx);
44
+ if (tasks.length === 0)
45
+ return [];
46
+ const matches = await findDoneBranchPrTasksWithOpenPrArtifacts({ ctx, tasks });
47
+ if (matches.length === 0)
48
+ return [];
49
+ const examples = matches
50
+ .slice(0, 5)
51
+ .map((entry) => `${entry.taskId}@${entry.base}:${entry.commitHash.slice(0, 12)} branch=${entry.branch}`)
52
+ .join(", ");
53
+ return [
54
+ renderDiagnosticFinding({
55
+ severity: "WARN",
56
+ state: "DONE branch_pr tasks still have open or unmerged PR artifacts",
57
+ likelyCause: "the task was marked DONE, but its branch_pr PR artifacts were never reconciled to MERGED and the task branch still exists",
58
+ nextAction: {
59
+ command: "agentplane task normalize --sync-hosted-merges --task-id <task-id>",
60
+ reason: "reconcile the shipped task's branch_pr PR artifacts to MERGED without scanning unrelated task history",
61
+ },
62
+ details: [
63
+ `Affected tasks: ${matches.length}`,
64
+ examples ? `Examples: ${examples}` : "Examples unavailable.",
65
+ ],
66
+ }),
67
+ ];
68
+ }
69
+ async function readDoneTaskSnapshot(ctx) {
70
+ try {
71
+ const tasks = await ctx.taskBackend.listTasks();
72
+ if (tasks.length > 0) {
73
+ return tasks;
74
+ }
75
+ }
76
+ catch {
77
+ // Fall back to the legacy export snapshot when the live backend read is unavailable.
78
+ }
79
+ const tasksJsonPath = path.join(ctx.resolvedProject.agentplaneDir, "tasks.json");
80
+ try {
81
+ const raw = await readFile(tasksJsonPath, "utf8");
82
+ const parsed = JSON.parse(raw);
83
+ if (!Array.isArray(parsed.tasks))
84
+ return [];
85
+ return parsed.tasks.filter((task) => isTaskDataLike(task));
86
+ }
87
+ catch {
88
+ return [];
89
+ }
90
+ }
91
+ function isTaskDataLike(value) {
92
+ if (!value || typeof value !== "object" || Array.isArray(value))
93
+ return false;
94
+ const record = value;
95
+ return typeof record.id === "string" && typeof record.status === "string";
96
+ }
@@ -1,3 +1,4 @@
1
+ import type { CommandContext } from "../shared/task-backend.js";
1
2
  export declare function safeFixGitignore(repoRoot: string): Promise<{
2
3
  changed: boolean;
3
4
  note: string;
@@ -6,4 +7,8 @@ export declare function safeFixTaskIndex(repoRoot: string): Promise<{
6
7
  changed: boolean;
7
8
  note: string;
8
9
  }>;
10
+ export declare function safeFixLegacyUntrackedTaskReadmes(repoRoot: string, ctx?: CommandContext): Promise<{
11
+ changed: boolean;
12
+ note: string;
13
+ }>;
9
14
  //# sourceMappingURL=fixes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fixes.d.ts","sourceRoot":"","sources":["../../../src/commands/doctor/fixes.ts"],"names":[],"mappings":"AAMA,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAyB7C;AAED,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAQ7C"}
1
+ {"version":3,"file":"fixes.d.ts","sourceRoot":"","sources":["../../../src/commands/doctor/fixes.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAyB7C;AAED,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAQ7C;AAED,wBAAsB,iCAAiC,CACrD,QAAQ,EAAE,MAAM,EAChB,GAAG,CAAC,EAAE,cAAc,GACnB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CA8E7C"}
@@ -1,6 +1,8 @@
1
1
  import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
+ import { parseTaskReadme } from "@agentplaneorg/core";
3
4
  import { RUNTIME_GITIGNORE_LINES } from "../../shared/runtime-artifacts.js";
5
+ import { GitContext } from "../shared/git-context.js";
4
6
  import { loadCommandContext } from "../shared/task-backend.js";
5
7
  export async function safeFixGitignore(repoRoot) {
6
8
  const gitignorePath = path.join(repoRoot, ".gitignore");
@@ -38,3 +40,71 @@ export async function safeFixTaskIndex(repoRoot) {
38
40
  return { changed: false, note: "Skip: could not rebuild tasks index cache." };
39
41
  }
40
42
  }
43
+ export async function safeFixLegacyUntrackedTaskReadmes(repoRoot, ctx) {
44
+ const commandCtx = ctx ??
45
+ (await loadCommandContext({
46
+ cwd: repoRoot,
47
+ rootOverride: null,
48
+ }));
49
+ const workflowDir = (commandCtx.config.paths.workflow_dir ?? ".agentplane/tasks").replaceAll("\\", "/");
50
+ const git = commandCtx.git ?? new GitContext({ gitRoot: repoRoot });
51
+ let untracked = [];
52
+ try {
53
+ untracked = await git.statusUntrackedPaths();
54
+ }
55
+ catch {
56
+ return { changed: false, note: "Skip: could not inspect untracked task README collisions." };
57
+ }
58
+ const candidates = untracked.filter((relPath) => relPath.startsWith(`${workflowDir}/`) && relPath.endsWith("/README.md"));
59
+ if (candidates.length === 0) {
60
+ return { changed: false, note: "OK: no legacy untracked task README collisions." };
61
+ }
62
+ const removed = [];
63
+ for (const relPath of candidates) {
64
+ const absPath = path.join(repoRoot, relPath);
65
+ let text = "";
66
+ try {
67
+ text = await fs.readFile(absPath, "utf8");
68
+ }
69
+ catch {
70
+ continue;
71
+ }
72
+ let parsed;
73
+ try {
74
+ parsed = parseTaskReadme(text);
75
+ }
76
+ catch {
77
+ continue;
78
+ }
79
+ const taskId = path.basename(path.dirname(absPath));
80
+ const parsedId = typeof parsed.frontmatter.id === "string" && parsed.frontmatter.id.trim().length > 0
81
+ ? parsed.frontmatter.id.trim()
82
+ : taskId;
83
+ const status = typeof parsed.frontmatter.status === "string"
84
+ ? parsed.frontmatter.status.trim().toUpperCase()
85
+ : "";
86
+ if (parsedId !== taskId || status !== "DONE")
87
+ continue;
88
+ await fs.rm(absPath, { force: true });
89
+ try {
90
+ const remaining = await fs.readdir(path.dirname(absPath));
91
+ if (remaining.length === 0) {
92
+ await fs.rmdir(path.dirname(absPath));
93
+ }
94
+ }
95
+ catch {
96
+ // Ignore cleanup failures for parent directories; the file removal is the actual fix.
97
+ }
98
+ removed.push(taskId);
99
+ }
100
+ if (removed.length === 0) {
101
+ return {
102
+ changed: false,
103
+ note: "OK: no safe-to-remove legacy untracked DONE task README collisions.",
104
+ };
105
+ }
106
+ return {
107
+ changed: true,
108
+ note: `Fixed: removed legacy untracked DONE task README collisions (${removed.join(", ")}).`,
109
+ };
110
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"doctor.run.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.run.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAarD,eAAO,MAAM,SAAS,EAAE,cAAc,CAAC,YAAY,CA6DlD,CAAC"}
1
+ {"version":3,"file":"doctor.run.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.run.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAqBrD,eAAO,MAAM,SAAS,EAAE,cAAc,CAAC,YAAY,CAiElD,CAAC"}
@@ -2,7 +2,8 @@ import { loadConfig, resolveProject } from "@agentplaneorg/core";
2
2
  import { warnMessage, successMessage } from "../cli/output.js";
3
3
  import { loadCommandContext } from "./shared/task-backend.js";
4
4
  import { checkDoneTaskCommitInvariants } from "./doctor/archive.js";
5
- import { safeFixGitignore, safeFixTaskIndex } from "./doctor/fixes.js";
5
+ import { checkBranchPrDoneTaskOpenPrDrift, checkBranchPrShippedTaskDrift, } from "./doctor/branch-pr.js";
6
+ import { safeFixGitignore, safeFixLegacyUntrackedTaskReadmes, safeFixTaskIndex, } from "./doctor/fixes.js";
6
7
  import { checkLayering } from "./doctor/layering.js";
7
8
  import { checkRuntimeSourceFacts, findingSeverity } from "./doctor/runtime.js";
8
9
  import { checkWorkspace } from "./doctor/workspace.js";
@@ -21,6 +22,8 @@ export const runDoctor = async (ctx, p) => {
21
22
  const runChecks = async () => {
22
23
  let checks = [
23
24
  ...(await checkWorkspace(repoRoot, { ctx: commandCtx })),
25
+ ...(await checkBranchPrShippedTaskDrift(commandCtx)),
26
+ ...(await checkBranchPrDoneTaskOpenPrDrift(commandCtx)),
24
27
  ...checkRuntimeSourceFacts(ctx.cwd, loadedConfig.config),
25
28
  ...(await checkDoneTaskCommitInvariants(repoRoot, { fullArchive: p.archiveFull })),
26
29
  ];
@@ -38,6 +41,8 @@ export const runDoctor = async (ctx, p) => {
38
41
  if (p.fix) {
39
42
  const fix = await safeFixGitignore(repoRoot);
40
43
  console.log(successMessage("doctor fix", undefined, fix.note));
44
+ const legacyTaskReadmes = await safeFixLegacyUntrackedTaskReadmes(repoRoot, commandCtx);
45
+ console.log(successMessage("doctor fix", undefined, legacyTaskReadmes.note));
41
46
  const idx = await safeFixTaskIndex(repoRoot);
42
47
  console.log(successMessage("doctor fix", undefined, idx.note));
43
48
  const workflowFix = await safeFixWorkflow(repoRoot);
@@ -1 +1 @@
1
- {"version":3,"file":"finish.run.d.ts","sourceRoot":"","sources":["../../src/commands/finish.run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEjE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,IACrE,KAAK,UAAU,EAAE,GAAG,YAAY,KAAG,OAAO,CAAC,MAAM,CAAC,CAuCjE"}
1
+ {"version":3,"file":"finish.run.d.ts","sourceRoot":"","sources":["../../src/commands/finish.run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEjE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,IACrE,KAAK,UAAU,EAAE,GAAG,YAAY,KAAG,OAAO,CAAC,MAAM,CAAC,CAkDjE"}
@@ -38,6 +38,17 @@ export function makeRunFinishHandler(getCtx) {
38
38
  closeCommit: p.closeCommit,
39
39
  noCloseCommit: p.noCloseCommit,
40
40
  closeUnstageOthers: p.closeUnstageOthers,
41
+ baseBranchOverride: p.baseBranchOverride,
42
+ observation: p.observation,
43
+ impact: p.impact,
44
+ resolution: p.resolution,
45
+ localOnly: p.localOnly,
46
+ repoFixable: p.repoFixable,
47
+ incidentScope: p.incidentScope,
48
+ incidentTags: p.incidentTags,
49
+ incidentMatch: p.incidentMatch,
50
+ incidentAdvice: p.incidentAdvice,
51
+ incidentRule: p.incidentRule,
41
52
  quiet: p.quiet,
42
53
  });
43
54
  };
@@ -24,6 +24,17 @@ export type FinishParsed = {
24
24
  closeCommit: boolean;
25
25
  noCloseCommit: boolean;
26
26
  closeUnstageOthers: boolean;
27
+ baseBranchOverride?: string;
28
+ observation?: string;
29
+ impact?: string;
30
+ resolution?: string;
31
+ localOnly: boolean;
32
+ repoFixable: boolean;
33
+ incidentScope?: string;
34
+ incidentTags: string[];
35
+ incidentMatch: string[];
36
+ incidentAdvice?: string;
37
+ incidentRule?: string;
27
38
  quiet: boolean;
28
39
  };
29
40
  export declare const finishSpec: CommandSpec<FinishParsed>;
@@ -1 +1 @@
1
- {"version":3,"file":"finish.spec.d.ts","sourceRoot":"","sources":["../../src/commands/finish.spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AASvD,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,OAAO,CAAC;IACb,iBAAiB,EAAE,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,wBAAwB,EAAE,OAAO,CAAC;IAClC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC,YAAY,CAqUhD,CAAC"}
1
+ {"version":3,"file":"finish.spec.d.ts","sourceRoot":"","sources":["../../src/commands/finish.spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAUvD,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,OAAO,CAAC;IACb,iBAAiB,EAAE,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,wBAAwB,EAAE,OAAO,CAAC;IAClC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,OAAO,CAAC;IACvB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC,YAAY,CA4XhD,CAAC"}