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
@@ -8,27 +8,97 @@ function nowOrExisting(value, fallback) {
8
8
  return trimmed || fallback;
9
9
  }
10
10
  export function buildOpenedPrMeta(opts) {
11
+ const nextBase = opts.base ?? opts.previousMeta?.base;
12
+ const nextHeadSha = opts.headSha ?? opts.previousMeta?.head_sha;
13
+ const changed = opts.previousMeta === null ||
14
+ (opts.previousMeta.branch ?? null) !== opts.branch ||
15
+ (opts.previousMeta.base ?? null) !== (nextBase ?? null) ||
16
+ (opts.previousMeta.head_sha ?? null) !== (nextHeadSha ?? null);
11
17
  return {
12
18
  schema_version: 1,
13
19
  task_id: opts.taskId,
14
20
  branch: opts.branch,
21
+ pr_number: opts.previousMeta?.pr_number,
22
+ pr_url: opts.previousMeta?.pr_url,
15
23
  created_at: opts.previousMeta?.created_at ?? opts.at,
16
- updated_at: opts.at,
24
+ updated_at: changed ? opts.at : (opts.previousMeta?.updated_at ?? opts.at),
25
+ status: opts.previousMeta?.status,
26
+ merge_strategy: opts.previousMeta?.merge_strategy,
27
+ merged_at: opts.previousMeta?.merged_at,
28
+ merge_commit: opts.previousMeta?.merge_commit,
17
29
  last_verified_sha: opts.previousMeta?.last_verified_sha ?? null,
18
30
  last_verified_at: opts.previousMeta?.last_verified_at ?? null,
19
31
  verify: opts.previousMeta?.verify ?? { status: "skipped" },
20
- base: opts.previousMeta?.base,
32
+ base: nextBase,
33
+ head_sha: nextHeadSha,
21
34
  };
22
35
  }
23
36
  export function buildUpdatedPrMeta(opts) {
37
+ const nextBase = opts.base ?? opts.meta.base;
38
+ const nextHeadSha = opts.headSha ?? opts.meta.head_sha;
39
+ const changed = (opts.meta.branch ?? null) !== opts.branch ||
40
+ (opts.meta.base ?? null) !== (nextBase ?? null) ||
41
+ (opts.meta.head_sha ?? null) !== (nextHeadSha ?? null);
24
42
  return {
25
43
  ...opts.meta,
26
44
  branch: opts.branch,
27
- updated_at: opts.at,
45
+ base: nextBase,
46
+ head_sha: nextHeadSha,
47
+ updated_at: changed ? opts.at : opts.meta.updated_at,
28
48
  last_verified_sha: opts.meta.last_verified_sha ?? null,
29
49
  last_verified_at: opts.meta.last_verified_at ?? null,
30
50
  };
31
51
  }
52
+ export function resolvePrArtifactHeadSha(opts) {
53
+ const previousHeadSha = asNonEmptyString(opts.previousHeadSha);
54
+ const currentHeadSha = asNonEmptyString(opts.currentHeadSha);
55
+ if (opts.preservePrevious && previousHeadSha)
56
+ return previousHeadSha;
57
+ return currentHeadSha ?? previousHeadSha;
58
+ }
59
+ export function buildObservedGithubPrMeta(opts) {
60
+ const nextStatus = opts.observed.status;
61
+ const nextHeadSha = opts.meta.head_sha ?? opts.observed.headSha ?? undefined;
62
+ const nextMeta = {
63
+ ...opts.meta,
64
+ pr_number: opts.observed.prNumber,
65
+ pr_url: opts.observed.prUrl ?? opts.meta.pr_url,
66
+ status: nextStatus,
67
+ base: opts.observed.base ?? opts.meta.base,
68
+ head_sha: nextHeadSha,
69
+ updated_at: opts.meta.updated_at,
70
+ };
71
+ if (nextStatus === "MERGED") {
72
+ nextMeta.merged_at = opts.observed.mergedAt ?? opts.meta.merged_at;
73
+ nextMeta.merge_commit = opts.observed.mergeCommit ?? opts.meta.merge_commit;
74
+ }
75
+ else {
76
+ delete nextMeta.merged_at;
77
+ delete nextMeta.merge_commit;
78
+ delete nextMeta.merge_strategy;
79
+ }
80
+ const changed = nextMeta.pr_number !== opts.meta.pr_number ||
81
+ (nextMeta.pr_url ?? null) !== (opts.meta.pr_url ?? null) ||
82
+ nextMeta.status !== opts.meta.status ||
83
+ (nextMeta.base ?? null) !== (opts.meta.base ?? null) ||
84
+ (nextMeta.head_sha ?? null) !== (opts.meta.head_sha ?? null) ||
85
+ (nextMeta.merged_at ?? null) !== (opts.meta.merged_at ?? null) ||
86
+ (nextMeta.merge_commit ?? null) !== (opts.meta.merge_commit ?? null);
87
+ if (changed) {
88
+ nextMeta.updated_at = opts.at;
89
+ }
90
+ return nextMeta;
91
+ }
92
+ export function buildVerifiedPrMeta(opts) {
93
+ const verifiedSha = opts.meta.head_sha ?? null;
94
+ return {
95
+ ...opts.meta,
96
+ updated_at: opts.meta.updated_at,
97
+ last_verified_sha: verifiedSha,
98
+ last_verified_at: opts.at,
99
+ verify: opts.meta.verify ? { ...opts.meta.verify, status: opts.state } : { status: opts.state },
100
+ };
101
+ }
32
102
  export function buildIntegratedPrMeta(opts) {
33
103
  const nextMeta = {
34
104
  ...opts.meta,
@@ -72,6 +142,85 @@ export function parsePrMeta(raw, taskId) {
72
142
  throw new Error("pr/meta.json task_id mismatch");
73
143
  return meta;
74
144
  }
145
+ function asNonEmptyString(value) {
146
+ if (typeof value !== "string")
147
+ return undefined;
148
+ const trimmed = value.trim();
149
+ return trimmed.length > 0 ? trimmed : undefined;
150
+ }
151
+ function asOptionalInteger(value) {
152
+ return Number.isInteger(value) && Number(value) > 0 ? Number(value) : undefined;
153
+ }
154
+ function asVerifyStatus(value) {
155
+ if (!value || typeof value !== "object")
156
+ return undefined;
157
+ const status = asNonEmptyString(value.status);
158
+ if (status !== "pass" && status !== "fail" && status !== "skipped")
159
+ return undefined;
160
+ const command = asNonEmptyString(value.command);
161
+ return command ? { status, command } : { status };
162
+ }
163
+ function asMergeStrategy(value) {
164
+ const strategy = asNonEmptyString(value);
165
+ return strategy === "squash" || strategy === "merge" || strategy === "rebase"
166
+ ? strategy
167
+ : undefined;
168
+ }
169
+ function buildForwardCompatiblePrMeta(parsed, taskId) {
170
+ if (parsed.schema_version !== 1)
171
+ return null;
172
+ if (asNonEmptyString(parsed.task_id) !== taskId)
173
+ return null;
174
+ const branch = asNonEmptyString(parsed.branch);
175
+ const createdAt = asNonEmptyString(parsed.created_at);
176
+ const updatedAt = asNonEmptyString(parsed.updated_at);
177
+ if (!branch || !createdAt || !updatedAt)
178
+ return null;
179
+ const statusCandidate = asNonEmptyString(parsed.status);
180
+ const status = statusCandidate === "OPEN" || statusCandidate === "CLOSED" || statusCandidate === "MERGED"
181
+ ? statusCandidate
182
+ : undefined;
183
+ return {
184
+ schema_version: 1,
185
+ task_id: taskId,
186
+ branch,
187
+ pr_number: asOptionalInteger(parsed.pr_number),
188
+ pr_url: asNonEmptyString(parsed.pr_url),
189
+ created_at: createdAt,
190
+ updated_at: updatedAt,
191
+ status,
192
+ merge_strategy: asMergeStrategy(parsed.merge_strategy),
193
+ merged_at: asNonEmptyString(parsed.merged_at),
194
+ merge_commit: asNonEmptyString(parsed.merge_commit),
195
+ last_verified_sha: asNonEmptyString(parsed.last_verified_sha),
196
+ last_verified_at: asNonEmptyString(parsed.last_verified_at),
197
+ verify: asVerifyStatus(parsed.verify) ?? { status: "skipped" },
198
+ base: asNonEmptyString(parsed.base),
199
+ head_sha: asNonEmptyString(parsed.head_sha),
200
+ };
201
+ }
202
+ export function parsePrMetaForwardCompatible(raw, taskId) {
203
+ let parsed;
204
+ try {
205
+ parsed = JSON.parse(raw);
206
+ }
207
+ catch (err) {
208
+ const message = err instanceof Error ? err.message : String(err);
209
+ throw new Error(`JSON Parse error: ${message}`);
210
+ }
211
+ try {
212
+ const meta = validateTaskPrMeta(parsed);
213
+ if (meta.task_id !== taskId)
214
+ throw new Error("pr/meta.json task_id mismatch");
215
+ return meta;
216
+ }
217
+ catch (err) {
218
+ const compat = buildForwardCompatiblePrMeta(parsed, taskId);
219
+ if (compat)
220
+ return compat;
221
+ throw err;
222
+ }
223
+ }
75
224
  export function extractLastVerifiedSha(logText) {
76
225
  const regex = /verified_sha=([0-9a-f]{7,40})/gi;
77
226
  let match = null;
@@ -1,4 +1,5 @@
1
1
  import { type AgentplaneConfig, type ResolvedProject } from "@agentplaneorg/core";
2
+ import type { ResolvedHarnessContract } from "../../runtime/harness/index.js";
2
3
  import { loadTaskBackend, type TaskBackend, type TaskData, type TaskSummary } from "../../backends/task-backend.js";
3
4
  import { GitContext } from "./git-context.js";
4
5
  export type CommandMemo = {
@@ -6,6 +7,7 @@ export type CommandMemo = {
6
7
  changedPaths?: Promise<string[]>;
7
8
  headCommit?: Promise<string>;
8
9
  agentIds?: Promise<string[]>;
10
+ harness?: Promise<ResolvedHarnessContract>;
9
11
  };
10
12
  export type CommandContext = {
11
13
  resolvedProject: Awaited<ReturnType<typeof loadTaskBackend>>["resolved"];
@@ -27,11 +29,18 @@ export declare function loadCommandContext(opts: {
27
29
  export declare function loadTaskFromContext(opts: {
28
30
  ctx: CommandContext;
29
31
  taskId: string;
32
+ preferBranchSnapshot?: boolean;
33
+ branchSnapshotBranch?: string | null;
30
34
  }): Promise<TaskData>;
35
+ export declare function resolveTaskBranchFromContext(opts: {
36
+ ctx: CommandContext;
37
+ taskId: string;
38
+ }): Promise<string | null>;
31
39
  export declare function loadTaskFromBranchSnapshot(opts: {
32
40
  ctx: CommandContext;
33
41
  taskId: string;
34
42
  readmePath: string;
43
+ branch?: string | null;
35
44
  }): Promise<TaskData | null>;
36
45
  export declare function loadBackendTask(opts: {
37
46
  ctx?: CommandContext;
@@ -1 +1 @@
1
- {"version":3,"file":"task-backend.d.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C,QAAQ,GAAG,IAAI,CAAC,CAoC3B;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE;IAC1C,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC;IACV,OAAO,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAC;IAC5C,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;IACjC,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC,CAaD;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,YAAY,CAAC,EACtD,KAAK,EAAE,SAAS,QAAQ,EAAE,GACzB,OAAO,CAAC,IAAI,CAAC,CASf;AAED,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAgBvF;AAED,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,CAQ3F;AAED,wBAAsB,4BAA4B,CAAC,IAAI,EAAE;IACvD,GAAG,EAAE,cAAc,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,IAAI,CAAC,CAchB"}
@@ -79,29 +79,56 @@ export async function loadCommandContext(opts) {
79
79
  };
80
80
  }
81
81
  export async function loadTaskFromContext(opts) {
82
- const task = await opts.ctx.taskBackend.getTask(opts.taskId);
83
- if (task)
84
- return task;
85
82
  const tasksDir = path.join(opts.ctx.resolvedProject.gitRoot, opts.ctx.config.paths.workflow_dir);
86
83
  const readmePath = path.join(tasksDir, opts.taskId, "README.md");
87
- const branchFallback = await loadTaskFromBranchSnapshot({
84
+ const branchFallback = () => loadTaskFromBranchSnapshot({
88
85
  ctx: opts.ctx,
89
86
  taskId: opts.taskId,
90
87
  readmePath,
88
+ branch: opts.branchSnapshotBranch ?? null,
91
89
  });
92
- if (branchFallback)
93
- return branchFallback;
90
+ if (opts.preferBranchSnapshot) {
91
+ const preferredBranchTask = await branchFallback();
92
+ if (preferredBranchTask)
93
+ return preferredBranchTask;
94
+ }
95
+ const task = await opts.ctx.taskBackend.getTask(opts.taskId);
96
+ if (task)
97
+ return task;
98
+ const fallbackTask = await branchFallback();
99
+ if (fallbackTask)
100
+ return fallbackTask;
94
101
  throw new CliError({
95
102
  exitCode: 4,
96
103
  code: "E_IO",
97
104
  message: `ENOENT: no such file or directory, open '${readmePath}'`,
98
105
  });
99
106
  }
107
+ export async function resolveTaskBranchFromContext(opts) {
108
+ if (opts.ctx.backendId !== "local") {
109
+ return null;
110
+ }
111
+ const prefix = opts.ctx.config.branch.task_prefix;
112
+ const branches = await gitListTaskBranches(opts.ctx.resolvedProject.gitRoot, prefix);
113
+ const matches = branches.filter((branch) => parseTaskIdFromBranch(prefix, branch) === opts.taskId);
114
+ if (matches.length === 1)
115
+ return matches[0] ?? null;
116
+ if (matches.length > 1) {
117
+ throw new CliError({
118
+ exitCode: 3,
119
+ code: "E_VALIDATION",
120
+ message: `Multiple task branches match ${opts.taskId}: ${matches.join(", ")}`,
121
+ });
122
+ }
123
+ return null;
124
+ }
100
125
  export async function loadTaskFromBranchSnapshot(opts) {
101
126
  if (opts.ctx.backendId !== "local") {
102
127
  return null;
103
128
  }
104
- const branch = await resolveSingleTaskBranch(opts.ctx, opts.taskId);
129
+ const branch = typeof opts.branch === "string" && opts.branch.trim().length > 0
130
+ ? opts.branch.trim()
131
+ : await resolveTaskBranchFromContext({ ctx: opts.ctx, taskId: opts.taskId });
105
132
  if (!branch)
106
133
  return null;
107
134
  const relReadmePath = toGitPath(path.relative(opts.ctx.resolvedProject.gitRoot, opts.readmePath));
@@ -126,21 +153,6 @@ export async function loadTaskFromBranchSnapshot(opts) {
126
153
  readmePath: opts.readmePath,
127
154
  });
128
155
  }
129
- async function resolveSingleTaskBranch(ctx, taskId) {
130
- const prefix = ctx.config.branch.task_prefix;
131
- const branches = await gitListTaskBranches(ctx.resolvedProject.gitRoot, prefix);
132
- const matches = branches.filter((branch) => parseTaskIdFromBranch(prefix, branch) === taskId);
133
- if (matches.length === 1)
134
- return matches[0] ?? null;
135
- if (matches.length > 1) {
136
- throw new CliError({
137
- exitCode: 3,
138
- code: "E_VALIDATION",
139
- message: `Multiple task branches match ${taskId}: ${matches.join(", ")}`,
140
- });
141
- }
142
- return null;
143
- }
144
156
  export async function loadBackendTask(opts) {
145
157
  const ctx = opts.ctx ??
146
158
  (await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
@@ -0,0 +1,13 @@
1
+ export declare function isTaskLocalAdvancePath(opts: {
2
+ workflowDir: string;
3
+ taskId: string;
4
+ relPath: string;
5
+ }): boolean;
6
+ export declare function isTaskLocalOnlyAdvance(opts: {
7
+ gitRoot: string;
8
+ workflowDir: string;
9
+ taskId: string;
10
+ fromRef: string | null;
11
+ toRef: string;
12
+ }): Promise<boolean>;
13
+ //# sourceMappingURL=task-local-freshness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-local-freshness.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/task-local-freshness.ts"],"names":[],"mappings":"AAQA,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAEV;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,OAAO,CAAC,CAenB"}
@@ -0,0 +1,20 @@
1
+ import path from "node:path";
2
+ import { gitDiffNames, toGitPath } from "./git-diff.js";
3
+ function taskRootPrefix(workflowDir, taskId) {
4
+ return `${toGitPath(path.join(workflowDir, taskId))}/`;
5
+ }
6
+ export function isTaskLocalAdvancePath(opts) {
7
+ return opts.relPath.startsWith(taskRootPrefix(opts.workflowDir, opts.taskId));
8
+ }
9
+ export async function isTaskLocalOnlyAdvance(opts) {
10
+ if (!opts.fromRef || opts.fromRef === opts.toRef) {
11
+ return false;
12
+ }
13
+ const changedPaths = await gitDiffNames(opts.gitRoot, opts.fromRef, opts.toRef);
14
+ return (changedPaths.length > 0 &&
15
+ changedPaths.every((relPath) => isTaskLocalAdvancePath({
16
+ workflowDir: opts.workflowDir,
17
+ taskId: opts.taskId,
18
+ relPath,
19
+ })));
20
+ }
@@ -1,4 +1,5 @@
1
1
  import type { TaskData, TaskWriteOptions } from "../../backends/task-backend.js";
2
+ import type { PolicyActionId } from "../../policy/taxonomy.js";
2
3
  import { type CommandContext } from "./task-backend.js";
3
4
  import { getTaskStore, type TaskStoreIntentResult } from "./task-store.js";
4
5
  export type TaskMutationPlan = {
@@ -19,6 +20,7 @@ export declare function withTaskMutationStorage<TResult>(opts: {
19
20
  export declare function applyTaskMutation(opts: {
20
21
  ctx: CommandContext;
21
22
  taskId: string;
23
+ policyAction?: PolicyActionId;
22
24
  build: (current: TaskData) => Promise<TaskMutationPlan | null | undefined> | TaskMutationPlan | null | undefined;
23
25
  writeOptions?: TaskWriteOptions;
24
26
  }): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"task-mutation.d.ts","sourceRoot":"","sources":["../../../src/commands/shared/task-mutation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACjF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EAAE,CAAC,OAAO,EAAE,cAAc,CAAC,aAAa,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;CAChF,GAAG,OAAO,CAAC,OAAO,CAAC,CAKnB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC5C,GAAG,EAAE,cAAc,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,cAAc,CAAC;IAC9B,KAAK,EAAE,CACL,OAAO,EAAE,QAAQ,KACd,OAAO,CAAC,gBAAgB,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,gBAAgB,GAAG,IAAI,GAAG,SAAS,CAAC;IACxF,YAAY,CAAC,EAAE,gBAAgB,CAAC;CACjC,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,aAAa,GAAG,SAAS,CAAA;CAAE,CAAC,CA8DjF;AAED,wBAAsB,2BAA2B,CAAC,OAAO,EAAE,IAAI,EAAE;IAC/D,GAAG,EAAE,cAAc,CAAC;IACpB,KAAK,EAAE,CACL,OAAO,EAAE,QAAQ,EAAE,KAChB,OAAO,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC,GAAG,0BAA0B,CAAC,OAAO,CAAC,CAAC;CACzF,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,QAAQ,EAAE,CAAA;CAAE,CAAC,CAQzD"}
@@ -1,3 +1,4 @@
1
+ import { PolicyEngine } from "../../policy/engine.js";
1
2
  import { loadTaskFromContext, writeTasksOrFallback } from "./task-backend.js";
2
3
  import { applyTaskStoreIntentsToTask, backendIsLocalFileBackend, getTaskStore, } from "./task-store.js";
3
4
  export async function withTaskMutationStorage(opts) {
@@ -7,6 +8,12 @@ export async function withTaskMutationStorage(opts) {
7
8
  return await opts.remote(opts.ctx.taskBackend);
8
9
  }
9
10
  export async function applyTaskMutation(opts) {
11
+ void new PolicyEngine().evaluate({
12
+ action: opts.policyAction ?? "task_mutation",
13
+ config: opts.ctx.config,
14
+ taskId: opts.taskId,
15
+ git: { stagedPaths: [] },
16
+ });
10
17
  if (backendIsLocalFileBackend(opts.ctx)) {
11
18
  const store = getTaskStore(opts.ctx);
12
19
  const result = await store.update(opts.taskId, async (current) => {
@@ -1 +1 @@
1
- {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../src/commands/task/block.ts"],"names":[],"mappings":"AAKA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAWpF,wBAAsB,QAAQ,CAAC,IAAI,EAAE;IACnC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,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,mBAAmB,EAAE,OAAO,CAAC;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CA+ElB"}
1
+ {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../src/commands/task/block.ts"],"names":[],"mappings":"AAKA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAWpF,wBAAsB,QAAQ,CAAC,IAAI,EAAE;IACnC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,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,mBAAmB,EAAE,OAAO,CAAC;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAgFlB"}
@@ -29,6 +29,7 @@ export async function cmdBlock(opts) {
29
29
  ctx,
30
30
  taskId: opts.taskId,
31
31
  quiet: opts.quiet,
32
+ policyAction: "task_block",
32
33
  build: () => ({
33
34
  at,
34
35
  toStatus: "BLOCKED",
@@ -1 +1 @@
1
- {"version":3,"file":"close-duplicate.d.ts","sourceRoot":"","sources":["../../../src/commands/task/close-duplicate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGrF,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,GAAG,EAAE,cAAc,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAoDlB"}
1
+ {"version":3,"file":"close-duplicate.d.ts","sourceRoot":"","sources":["../../../src/commands/task/close-duplicate.ts"],"names":[],"mappings":"AAUA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AAgDnC,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,GAAG,EAAE,cAAc,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAqDlB"}
@@ -1,8 +1,40 @@
1
+ import { mkdir, readFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { renderTaskReadme } from "@agentplaneorg/core";
1
4
  import { mapBackendError } from "../../cli/error-map.js";
5
+ import { fileExists } from "../../cli/fs-utils.js";
2
6
  import { CliError } from "../../shared/errors.js";
7
+ import { writeTextIfChanged } from "../../shared/write-if-changed.js";
3
8
  import { ensureActionApproved } from "../shared/approval-requirements.js";
4
- import { loadTaskFromContext } from "../shared/task-backend.js";
9
+ import { loadTaskFromContext, taskDataToFrontmatter, } from "../shared/task-backend.js";
10
+ import { listWorktrees, parseTaskIdFromBranch } from "../shared/git-worktree.js";
5
11
  import { recordVerifiedNoopClosure } from "./close-shared.js";
12
+ async function ensureLocalTaskReadmeHydrated(opts) {
13
+ const workflowDir = opts.ctx.config.paths.workflow_dir;
14
+ const targetReadmePath = path.join(opts.ctx.resolvedProject.gitRoot, workflowDir, opts.taskId, "README.md");
15
+ if (await fileExists(targetReadmePath))
16
+ return;
17
+ const worktrees = await listWorktrees(opts.ctx.resolvedProject.gitRoot).catch(() => []);
18
+ const matchingTaskWorktrees = worktrees.filter((entry) => typeof entry.branch === "string" &&
19
+ parseTaskIdFromBranch(opts.ctx.config.branch.task_prefix, entry.branch) === opts.taskId);
20
+ if (matchingTaskWorktrees.length === 1) {
21
+ const sourceReadmePath = path.join(matchingTaskWorktrees[0].path, workflowDir, opts.taskId, "README.md");
22
+ if (await fileExists(sourceReadmePath)) {
23
+ const text = await readFile(sourceReadmePath, "utf8");
24
+ await mkdir(path.dirname(targetReadmePath), { recursive: true });
25
+ await writeTextIfChanged(targetReadmePath, text);
26
+ return;
27
+ }
28
+ }
29
+ const task = await loadTaskFromContext({
30
+ ctx: opts.ctx,
31
+ taskId: opts.taskId,
32
+ preferBranchSnapshot: true,
33
+ });
34
+ const rendered = renderTaskReadme(taskDataToFrontmatter(task), task.doc ?? "");
35
+ await mkdir(path.dirname(targetReadmePath), { recursive: true });
36
+ await writeTextIfChanged(targetReadmePath, rendered);
37
+ }
6
38
  export async function cmdTaskCloseDuplicate(opts) {
7
39
  try {
8
40
  const sourceId = opts.taskId.trim();
@@ -30,6 +62,7 @@ export async function cmdTaskCloseDuplicate(opts) {
30
62
  });
31
63
  }
32
64
  const canonical = await loadTaskFromContext({ ctx: opts.ctx, taskId: duplicateOf });
65
+ await ensureLocalTaskReadmeHydrated({ ctx: opts.ctx, taskId: sourceId });
33
66
  const reason = opts.note?.trim();
34
67
  const canonicalTitle = canonical.title?.trim() ? ` (${canonical.title.trim()})` : "";
35
68
  const baseBody = `Verified: ${sourceId} is a bookkeeping duplicate of ${duplicateOf}${canonicalTitle}; ` +
@@ -1 +1 @@
1
- {"version":3,"file":"close-shared.d.ts","sourceRoot":"","sources":["../../../src/commands/task/close-shared.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAIhE,wBAAsB,yBAAyB,CAAC,IAAI,EAAE;IACpD,GAAG,EAAE,cAAc,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyChB"}
1
+ {"version":3,"file":"close-shared.d.ts","sourceRoot":"","sources":["../../../src/commands/task/close-shared.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAIhE,wBAAsB,yBAAyB,CAAC,IAAI,EAAE;IACpD,GAAG,EAAE,cAAc,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0ChB"}
@@ -8,6 +8,7 @@ export async function recordVerifiedNoopClosure(opts) {
8
8
  await applyTaskMutation({
9
9
  ctx: opts.ctx,
10
10
  taskId: opts.taskId,
11
+ policyAction: "task_finish",
11
12
  build: async (task) => {
12
13
  if (!opts.force && String(task.status || "TODO").toUpperCase() === "DONE") {
13
14
  throw new CliError({
@@ -61,7 +61,7 @@ export async function cmdTaskDerive(opts) {
61
61
  primary: primary.primary,
62
62
  verifyCommands: opts.verify,
63
63
  }));
64
- process.stderr.write(`${warnMessage("task requires Verify Steps by primary tag; seeded a default ## Verify Steps section in README (review and refine before approval/start)")}\n`);
64
+ process.stderr.write(`${warnMessage("task requires Verify Steps by primary tag; seeded a concrete ## Verify Steps section in README (refine it only if the task needs stricter acceptance coverage)")}\n`);
65
65
  }
66
66
  const hasSpike = opts.tags.some((tag) => tag.trim().toLowerCase() === spikeTag);
67
67
  if (hasSpike && requiresVerifySteps) {
@@ -1 +1 @@
1
- {"version":3,"file":"doc-template.d.ts","sourceRoot":"","sources":["../../../src/commands/task/doc-template.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,IAAI,CAAC;AA2DrC,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAkCrF;AAED,wBAAgB,8BAA8B,CAAC,IAAI,EAAE;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,GAAG,MAAM,CA2BT"}
1
+ {"version":3,"file":"doc-template.d.ts","sourceRoot":"","sources":["../../../src/commands/task/doc-template.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAyDrC,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAsCrF;AAED,wBAAgB,8BAA8B,CAAC,IAAI,EAAE;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,GAAG,MAAM,CAyBT"}
@@ -31,13 +31,11 @@ function buildDefaultPlan(opts) {
31
31
  "3. Finalize task findings and finish with traceable commit metadata.",
32
32
  ].join("\n");
33
33
  }
34
- function buildDefaultVerifyStepsTemplate() {
34
+ function buildDefaultVerifyStepsTemplate(opts) {
35
35
  return [
36
- "<!-- TODO: REPLACE WITH TASK-SPECIFIC ACCEPTANCE STEPS -->",
37
- "",
38
- "1. <Action>. Expected: <observable result>.",
39
- "2. <Action>. Expected: <observable result>.",
40
- "3. <Action>. Expected: <observable result>.",
36
+ `1. Review the requested outcome for "${opts.title}". Expected: the visible result matches ## Summary and stays inside approved scope.`,
37
+ "2. Run the most relevant validation step for this task. Expected: it succeeds without unexpected regressions in touched behavior.",
38
+ "3. Compare the final result against ## Scope and record any residual follow-up in ## Findings. Expected: open edges are explicit rather than implicit.",
41
39
  ].join("\n");
42
40
  }
43
41
  function buildDefaultVerificationTemplate() {
@@ -69,7 +67,7 @@ export function defaultTaskDocV3(opts) {
69
67
  body = setMarkdownSection(body, "Summary", buildDefaultSummary({ title: opts.title, description: opts.description }));
70
68
  body = setMarkdownSection(body, "Scope", buildDefaultScope({ title: opts.title, description: opts.description }));
71
69
  body = setMarkdownSection(body, "Plan", buildDefaultPlan({ title: opts.title }));
72
- body = setMarkdownSection(body, "Verify Steps", buildDefaultVerifyStepsTemplate());
70
+ body = setMarkdownSection(body, "Verify Steps", buildDefaultVerifyStepsTemplate({ title: opts.title }));
73
71
  body = setMarkdownSection(body, "Verification", buildDefaultVerificationTemplate());
74
72
  body = setMarkdownSection(body, "Rollback Plan", buildDefaultRollbackPlan());
75
73
  body = setMarkdownSection(body, "Findings", "");
@@ -85,10 +83,8 @@ export function buildDefaultVerifyStepsSection(opts) {
85
83
  ];
86
84
  if (commandSteps.length === 0) {
87
85
  return [
88
- "<!-- TODO: REPLACE WITH TASK-SPECIFIC ACCEPTANCE STEPS -->",
89
- "",
90
- "1. Review the changed artifact or behavior. Expected: the requested outcome is visible and matches the approved scope.",
91
- "2. Run the most relevant validation step for this task. Expected: it succeeds without unexpected regressions in touched scope.",
86
+ `1. Review the changed artifact or behavior for the \`${opts.primary}\` task. Expected: the requested outcome is visible and matches the approved scope.`,
87
+ `2. Run the most relevant validation step for the \`${opts.primary}\` task. Expected: it succeeds without unexpected regressions in touched scope.`,
92
88
  "3. Compare the final result against the task summary and scope. Expected: any remaining follow-up is explicit in ## Findings.",
93
89
  ].join("\n");
94
90
  }
@@ -0,0 +1,20 @@
1
+ import type { CommandCtx, CommandSpec } from "../../cli/spec/spec.js";
2
+ import type { CommandContext } from "../shared/task-backend.js";
3
+ export type TaskFindingsAddParsed = {
4
+ taskId: string;
5
+ observation: string;
6
+ impact: string;
7
+ resolution: string;
8
+ promote: boolean;
9
+ external: boolean;
10
+ fixability: "external" | "repo-fixable" | null;
11
+ incidentScope?: string;
12
+ incidentTags: string[];
13
+ incidentMatch: string[];
14
+ incidentAdvice?: string;
15
+ incidentRule?: string;
16
+ updatedBy?: string;
17
+ };
18
+ export declare const taskFindingsAddSpec: CommandSpec<TaskFindingsAddParsed>;
19
+ export declare function makeRunTaskFindingsAddHandler(getCtx: (cmd: string) => Promise<CommandContext>): (ctx: CommandCtx, p: TaskFindingsAddParsed) => Promise<number>;
20
+ //# sourceMappingURL=findings-add.command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findings-add.command.d.ts","sourceRoot":"","sources":["../../../src/commands/task/findings-add.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAIhE,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,UAAU,GAAG,cAAc,GAAG,IAAI,CAAC;IAC/C,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,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,qBAAqB,CAqJlE,CAAC;AAEF,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,IAC9E,KAAK,UAAU,EAAE,GAAG,qBAAqB,KAAG,OAAO,CAAC,MAAM,CAAC,CAoB1E"}