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
@@ -6,23 +6,20 @@ import { exitCodeForError } from "../../../../cli/exit-codes.js";
6
6
  import { unknownEntityMessage, workflowModeMessage } from "../../../../cli/output.js";
7
7
  import { CliError } from "../../../../shared/errors.js";
8
8
  import { ensureGitClean } from "../../../guard/index.js";
9
- import { gitDiffNames, gitShowFile, toGitPath } from "../../../shared/git-diff.js";
9
+ import { gitDiffNames } from "../../../shared/git-diff.js";
10
10
  import { gitBranchExists, gitCurrentBranch, gitRevParse } from "../../../shared/git-ops.js";
11
- import { loadBackendTask, loadCommandContext, } from "../../../shared/task-backend.js";
11
+ import { findWorktreeForBranch } from "../../../shared/git-worktree.js";
12
+ import { loadCommandContext, loadTaskFromContext, resolveTaskBranchFromContext, } from "../../../shared/task-backend.js";
12
13
  import { ensurePlanApprovedIfRequired, ensureVerificationSatisfiedIfRequired, } from "../../../task/shared.js";
13
- import { resolvePrPaths } from "../../internal/pr-paths.js";
14
- import { readAndValidatePrArtifacts } from "../artifacts.js";
14
+ import { readPrArtifact, resolvePrPaths } from "../../internal/pr-paths.js";
15
+ import { ensurePrArtifactsSynced } from "../../internal/sync.js";
16
+ import { readAndValidatePrArtifacts, ensureCommittedPrArtifactsOnBranch } from "../artifacts.js";
15
17
  import { computeVerifyState } from "../verify.js";
16
- import { parsePrMeta } from "../../../shared/pr-meta.js";
18
+ import { parsePrMetaForwardCompatible } from "../../../shared/pr-meta.js";
19
+ import { assessPrArtifactFreshness } from "../../internal/freshness.js";
17
20
  export async function prepareIntegrate(opts) {
18
21
  const ctx = opts.ctx ??
19
22
  (await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
20
- const { task } = await loadBackendTask({
21
- ctx,
22
- cwd: opts.cwd,
23
- rootOverride: opts.rootOverride,
24
- taskId: opts.taskId,
25
- });
26
23
  const resolved = ctx.resolvedProject;
27
24
  const loadedConfig = ctx.config;
28
25
  if (loadedConfig.workflow_mode !== "branch_pr") {
@@ -32,8 +29,6 @@ export async function prepareIntegrate(opts) {
32
29
  message: workflowModeMessage(loadedConfig.workflow_mode, "branch_pr"),
33
30
  });
34
31
  }
35
- ensurePlanApprovedIfRequired(task, loadedConfig);
36
- ensureVerificationSatisfiedIfRequired(task, loadedConfig);
37
32
  await ensureGitClean({ cwd: opts.cwd, rootOverride: opts.rootOverride });
38
33
  if (opts.base?.trim().length === 0) {
39
34
  throw new CliError({
@@ -72,10 +67,16 @@ export async function prepareIntegrate(opts) {
72
67
  let meta = null;
73
68
  let branch = (opts.branch ?? "").trim();
74
69
  if (await fileExists(metaPath)) {
75
- meta = parsePrMeta(await readFile(metaPath, "utf8"), task.id);
70
+ meta = parsePrMetaForwardCompatible(await readFile(metaPath, "utf8"), opts.taskId);
76
71
  if (!branch)
77
72
  branch = (meta.branch ?? "").trim();
78
73
  }
74
+ if (!branch) {
75
+ const inferredBranch = await resolveTaskBranchFromContext({ ctx, taskId: opts.taskId });
76
+ if (inferredBranch) {
77
+ branch = inferredBranch;
78
+ }
79
+ }
79
80
  if (!branch) {
80
81
  throw new CliError({
81
82
  exitCode: 2,
@@ -90,8 +91,27 @@ export async function prepareIntegrate(opts) {
90
91
  message: unknownEntityMessage("branch", branch),
91
92
  });
92
93
  }
93
- const metaSource = meta ??
94
- parsePrMeta(await gitShowFile(resolved.gitRoot, branch, toGitPath(path.relative(resolved.gitRoot, metaPath))), task.id);
94
+ await ensureCommittedPrArtifactsOnBranch({
95
+ resolved,
96
+ prDir,
97
+ branch,
98
+ });
99
+ const worktreePath = await findWorktreeForBranch(resolved.gitRoot, branch);
100
+ const metaText = await readPrArtifact({
101
+ resolved,
102
+ prDir,
103
+ fileName: "meta.json",
104
+ branch,
105
+ worktreePath,
106
+ });
107
+ if (!metaText) {
108
+ throw new CliError({
109
+ exitCode: 4,
110
+ code: "E_IO",
111
+ message: `PR artifacts missing: ${path.relative(resolved.gitRoot, metaPath)} (run \`agentplane pr open\`)`,
112
+ });
113
+ }
114
+ let metaSource = parsePrMetaForwardCompatible(metaText, opts.taskId);
95
115
  const baseCandidate = opts.base ?? metaSource.base ?? baseBranch;
96
116
  const base = typeof baseCandidate === "string" && baseCandidate.trim().length > 0
97
117
  ? baseCandidate.trim()
@@ -102,10 +122,16 @@ export async function prepareIntegrate(opts) {
102
122
  prDir,
103
123
  metaPath,
104
124
  branch,
105
- taskId: task.id,
125
+ taskId: opts.taskId,
106
126
  });
107
127
  // readAndValidatePrArtifacts() throws if verify.log is missing; keep this non-null downstream.
108
- const verifyLogText = verifyLogTextMaybe;
128
+ let verifyLogText = verifyLogTextMaybe;
129
+ const task = await loadTaskFromContext({
130
+ ctx,
131
+ taskId: opts.taskId,
132
+ preferBranchSnapshot: true,
133
+ branchSnapshotBranch: branch,
134
+ });
109
135
  const changedPaths = await gitDiffNames(resolved.gitRoot, base, branch);
110
136
  const tasksPath = loadedConfig.paths.tasks_path;
111
137
  if (changedPaths.includes(tasksPath)) {
@@ -116,9 +142,71 @@ export async function prepareIntegrate(opts) {
116
142
  });
117
143
  }
118
144
  const branchHeadSha = await gitRevParse(resolved.gitRoot, [branch]);
145
+ let freshness = await assessPrArtifactFreshness({
146
+ gitRoot: resolved.gitRoot,
147
+ workflowDir: loadedConfig.paths.workflow_dir,
148
+ taskId: opts.taskId,
149
+ branchHeadSha,
150
+ metaHeadSha: metaSource.head_sha ?? null,
151
+ metaLastVerifiedSha: metaSource.last_verified_sha ?? null,
152
+ metaVerifyStatus: metaSource.verify?.status ?? null,
153
+ taskVerificationState: task.verification?.state ?? null,
154
+ verifyLogText,
155
+ requiresVerify: Boolean(task.verify && task.verify.length > 0),
156
+ });
157
+ if (!freshness.reviewFresh && worktreePath) {
158
+ await ensurePrArtifactsSynced({
159
+ cwd: worktreePath,
160
+ taskId: opts.taskId,
161
+ branch,
162
+ });
163
+ const repairedMetaText = await readPrArtifact({
164
+ resolved,
165
+ prDir,
166
+ fileName: "meta.json",
167
+ branch,
168
+ worktreePath,
169
+ });
170
+ if (repairedMetaText) {
171
+ const repairedMetaSource = parsePrMetaForwardCompatible(repairedMetaText, opts.taskId);
172
+ const repairedArtifacts = await readAndValidatePrArtifacts({
173
+ ctx,
174
+ resolved,
175
+ prDir,
176
+ metaPath,
177
+ branch,
178
+ taskId: opts.taskId,
179
+ });
180
+ verifyLogText = repairedArtifacts.verifyLogText ?? verifyLogText;
181
+ freshness = await assessPrArtifactFreshness({
182
+ gitRoot: resolved.gitRoot,
183
+ workflowDir: loadedConfig.paths.workflow_dir,
184
+ taskId: opts.taskId,
185
+ branchHeadSha,
186
+ metaHeadSha: repairedMetaSource.head_sha ?? null,
187
+ metaLastVerifiedSha: repairedMetaSource.last_verified_sha ?? null,
188
+ metaVerifyStatus: repairedMetaSource.verify?.status ?? null,
189
+ taskVerificationState: task.verification?.state ?? null,
190
+ verifyLogText,
191
+ requiresVerify: Boolean(task.verify && task.verify.length > 0),
192
+ });
193
+ meta = repairedMetaSource;
194
+ metaSource = repairedMetaSource;
195
+ }
196
+ }
197
+ if (!freshness.reviewFresh) {
198
+ throw new CliError({
199
+ exitCode: exitCodeForError("E_VALIDATION"),
200
+ code: "E_VALIDATION",
201
+ message: `PR artifacts stale for ${opts.taskId}: meta.head_sha=${metaSource.head_sha ?? "<missing>"} ` +
202
+ `current_head=${branchHeadSha} (refresh the task branch artifacts before integrate)`,
203
+ });
204
+ }
205
+ ensurePlanApprovedIfRequired(task, loadedConfig);
206
+ ensureVerificationSatisfiedIfRequired(task, loadedConfig);
119
207
  const initialVerifyState = computeVerifyState({
120
208
  rawVerify: task.verify,
121
- metaLastVerifiedSha: metaSource?.last_verified_sha ?? null,
209
+ metaLastVerifiedSha: freshness.effectiveVerifiedSha,
122
210
  verifyLogText,
123
211
  branchHeadSha,
124
212
  runVerify: opts.runVerify,
@@ -0,0 +1,20 @@
1
+ export type PrArtifactFreshness = {
2
+ reviewFresh: boolean;
3
+ verifyFresh: boolean;
4
+ verifySatisfied: boolean;
5
+ verifyLogSha: string | null;
6
+ effectiveVerifiedSha: string | null;
7
+ };
8
+ export declare function assessPrArtifactFreshness(opts: {
9
+ gitRoot: string;
10
+ workflowDir: string;
11
+ taskId: string;
12
+ branchHeadSha: string;
13
+ metaHeadSha: unknown;
14
+ metaLastVerifiedSha: unknown;
15
+ metaVerifyStatus: unknown;
16
+ taskVerificationState: unknown;
17
+ verifyLogText: string | null;
18
+ requiresVerify: boolean;
19
+ }): Promise<PrArtifactFreshness>;
20
+ //# sourceMappingURL=freshness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"freshness.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/internal/freshness.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC,CAAC;AAEF,wBAAsB,yBAAyB,CAAC,IAAI,EAAE;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,cAAc,EAAE,OAAO,CAAC;CACzB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAgD/B"}
@@ -0,0 +1,50 @@
1
+ import { extractLastVerifiedSha } from "../../shared/pr-meta.js";
2
+ import { isTaskLocalOnlyAdvance } from "../../shared/task-local-freshness.js";
3
+ function normalizeSha(value) {
4
+ if (typeof value !== "string")
5
+ return null;
6
+ const trimmed = value.trim();
7
+ return trimmed.length > 0 ? trimmed : null;
8
+ }
9
+ export async function assessPrArtifactFreshness(opts) {
10
+ const metaHeadSha = normalizeSha(opts.metaHeadSha);
11
+ const metaLastVerifiedSha = normalizeSha(opts.metaLastVerifiedSha);
12
+ const verifyLogSha = normalizeSha(extractLastVerifiedSha(opts.verifyLogText ?? ""));
13
+ const metaVerifyPassed = opts.metaVerifyStatus === "pass";
14
+ const reviewFresh = metaHeadSha === opts.branchHeadSha ||
15
+ (await isTaskLocalOnlyAdvance({
16
+ gitRoot: opts.gitRoot,
17
+ workflowDir: opts.workflowDir,
18
+ taskId: opts.taskId,
19
+ fromRef: metaHeadSha,
20
+ toRef: opts.branchHeadSha,
21
+ }));
22
+ if (!opts.requiresVerify) {
23
+ return {
24
+ reviewFresh,
25
+ verifyFresh: true,
26
+ verifySatisfied: true,
27
+ verifyLogSha,
28
+ effectiveVerifiedSha: null,
29
+ };
30
+ }
31
+ const verifiedFromMeta = metaVerifyPassed &&
32
+ (metaLastVerifiedSha === opts.branchHeadSha ||
33
+ (await isTaskLocalOnlyAdvance({
34
+ gitRoot: opts.gitRoot,
35
+ workflowDir: opts.workflowDir,
36
+ taskId: opts.taskId,
37
+ fromRef: metaLastVerifiedSha,
38
+ toRef: opts.branchHeadSha,
39
+ })));
40
+ const verifiedFromLog = verifyLogSha === opts.branchHeadSha;
41
+ const verifiedFromTaskState = opts.taskVerificationState === "ok" && reviewFresh && metaLastVerifiedSha === null;
42
+ const verifySatisfied = verifiedFromMeta || verifiedFromLog || verifiedFromTaskState;
43
+ return {
44
+ reviewFresh,
45
+ verifyFresh: verifySatisfied,
46
+ verifySatisfied,
47
+ verifyLogSha,
48
+ effectiveVerifiedSha: verifySatisfied ? opts.branchHeadSha : metaLastVerifiedSha,
49
+ };
50
+ }
@@ -0,0 +1,6 @@
1
+ export declare function ghEnv(): NodeJS.ProcessEnv;
2
+ export declare function resolveDefaultGithubRepo(cwd: string): Promise<string>;
3
+ export declare function runGhApiJson<T>(cwd: string, args: string[]): Promise<T>;
4
+ export declare function runGhApiNoOutput(cwd: string, args: string[]): Promise<void>;
5
+ export declare function isGhNotFound(err: unknown): boolean;
6
+ //# sourceMappingURL=gh-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gh-api.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/internal/gh-api.ts"],"names":[],"mappings":"AAqBA,wBAAgB,KAAK,IAAI,MAAM,CAAC,UAAU,CAiBzC;AAED,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAe3E;AAED,wBAAsB,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAa7E;AAED,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAYjF;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAElD"}
@@ -0,0 +1,80 @@
1
+ import { execFile } from "node:child_process";
2
+ import { promisify } from "node:util";
3
+ import { exitCodeForError } from "../../../cli/exit-codes.js";
4
+ import { CliError } from "../../../shared/errors.js";
5
+ import { isDotEnvLoadedKey } from "../../../shared/env.js";
6
+ import { gitEnv } from "../../shared/git.js";
7
+ import { normalizeGhTransportError, withGhTransportRetry } from "../../shared/gh-transport.js";
8
+ const execFileAsyncRaw = promisify(execFile);
9
+ function parseGithubRepoFromRemoteUrl(remoteUrl) {
10
+ const trimmed = remoteUrl.trim();
11
+ if (!trimmed)
12
+ return null;
13
+ const httpsMatch = /^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/.exec(trimmed);
14
+ if (httpsMatch)
15
+ return `${httpsMatch[1]}/${httpsMatch[2]}`;
16
+ const sshMatch = /^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?$/.exec(trimmed);
17
+ if (sshMatch)
18
+ return `${sshMatch[1]}/${sshMatch[2]}`;
19
+ return null;
20
+ }
21
+ export function ghEnv() {
22
+ const env = gitEnv();
23
+ // Preserve explicit shell/CI auth, but do not let repo-local `.env` tokens override
24
+ // a valid gh keyring session for nested CLI invocations.
25
+ if (isDotEnvLoadedKey("GH_TOKEN"))
26
+ delete env.GH_TOKEN;
27
+ if (isDotEnvLoadedKey("GITHUB_TOKEN"))
28
+ delete env.GITHUB_TOKEN;
29
+ if (typeof process.env.GH_TOKEN === "string" && !isDotEnvLoadedKey("GH_TOKEN")) {
30
+ env.GH_TOKEN = process.env.GH_TOKEN;
31
+ }
32
+ if (typeof process.env.GITHUB_TOKEN === "string" && !isDotEnvLoadedKey("GITHUB_TOKEN")) {
33
+ env.GITHUB_TOKEN = process.env.GITHUB_TOKEN;
34
+ }
35
+ if (typeof process.env.GH_CONFIG_DIR === "string")
36
+ env.GH_CONFIG_DIR = process.env.GH_CONFIG_DIR;
37
+ if (typeof process.env.XDG_CONFIG_HOME === "string")
38
+ env.XDG_CONFIG_HOME = process.env.XDG_CONFIG_HOME;
39
+ if (typeof process.env.HOME === "string")
40
+ env.HOME = process.env.HOME;
41
+ return env;
42
+ }
43
+ export async function resolveDefaultGithubRepo(cwd) {
44
+ const { stdout } = await execFileAsyncRaw("git", ["remote", "get-url", "origin"], {
45
+ cwd,
46
+ env: gitEnv(),
47
+ maxBuffer: 10 * 1024 * 1024,
48
+ });
49
+ const repo = parseGithubRepoFromRemoteUrl(stdout);
50
+ if (!repo) {
51
+ throw new CliError({
52
+ exitCode: exitCodeForError("E_VALIDATION"),
53
+ code: "E_VALIDATION",
54
+ message: "Could not derive GitHub owner/repo from git remote origin.",
55
+ });
56
+ }
57
+ return repo;
58
+ }
59
+ export async function runGhApiJson(cwd, args) {
60
+ const { stdout } = await withGhTransportRetry(() => execFileAsyncRaw("gh", ["api", ...args], {
61
+ cwd,
62
+ env: ghEnv(),
63
+ maxBuffer: 10 * 1024 * 1024,
64
+ }), {
65
+ label: `running gh api ${args[0] ?? ""}`,
66
+ });
67
+ return JSON.parse(stdout);
68
+ }
69
+ export async function runGhApiNoOutput(cwd, args) {
70
+ await withGhTransportRetry(() => execFileAsyncRaw("gh", ["api", ...args], {
71
+ cwd,
72
+ env: ghEnv(),
73
+ maxBuffer: 10 * 1024 * 1024,
74
+ }), {
75
+ label: `running gh api ${args[0] ?? ""}`,
76
+ });
77
+ }
78
+ export function isGhNotFound(err) {
79
+ return /\b404\b/.test(normalizeGhTransportError(err));
80
+ }
@@ -0,0 +1,18 @@
1
+ export type PrHandoffNote = {
2
+ schema_version: 1;
3
+ created_at: string;
4
+ author: string;
5
+ body: string;
6
+ };
7
+ export declare function buildPrHandoffNote(opts: {
8
+ createdAt: string;
9
+ author: string;
10
+ body: string;
11
+ }): PrHandoffNote;
12
+ export declare function parsePrHandoffNotes(raw: string): PrHandoffNote[];
13
+ export declare function readPrHandoffNotes(notesPath: string): Promise<PrHandoffNote[]>;
14
+ export declare function appendPrHandoffNote(opts: {
15
+ notesPath: string;
16
+ note: PrHandoffNote;
17
+ }): Promise<void>;
18
+ //# sourceMappingURL=note-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"note-store.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/internal/note-store.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG;IAC1B,cAAc,EAAE,CAAC,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAaF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,aAAa,CAOhB;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,EAAE,CA2BhE;AAED,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAQpF;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,aAAa,CAAC;CACrB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhB"}
@@ -0,0 +1,66 @@
1
+ import { appendFile, mkdir, readFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ function invalidNote(index, message) {
4
+ return new Error(`Invalid pr/notes.jsonl entry ${index + 1}: ${message}`);
5
+ }
6
+ function trimRequired(value, field, index) {
7
+ if (typeof value !== "string")
8
+ throw invalidNote(index, `${field} must be a string`);
9
+ const trimmed = value.trim();
10
+ if (!trimmed)
11
+ throw invalidNote(index, `${field} must not be empty`);
12
+ return trimmed;
13
+ }
14
+ export function buildPrHandoffNote(opts) {
15
+ return {
16
+ schema_version: 1,
17
+ created_at: opts.createdAt,
18
+ author: opts.author.trim(),
19
+ body: opts.body.trim(),
20
+ };
21
+ }
22
+ export function parsePrHandoffNotes(raw) {
23
+ if (!raw.trim())
24
+ return [];
25
+ return raw
26
+ .split(/\r?\n/)
27
+ .filter((line) => line.trim().length > 0)
28
+ .map((line, index) => {
29
+ let parsed;
30
+ try {
31
+ parsed = JSON.parse(line);
32
+ }
33
+ catch (err) {
34
+ const message = err instanceof Error ? err.message : String(err);
35
+ throw invalidNote(index, `invalid JSON (${message})`);
36
+ }
37
+ const record = parsed;
38
+ if (!record || typeof record !== "object") {
39
+ throw invalidNote(index, "entry must be an object");
40
+ }
41
+ if ((record.schema_version ?? 1) !== 1) {
42
+ throw invalidNote(index, "unsupported schema_version");
43
+ }
44
+ return {
45
+ schema_version: 1,
46
+ created_at: trimRequired(record.created_at, "created_at", index),
47
+ author: trimRequired(record.author, "author", index),
48
+ body: trimRequired(record.body, "body", index),
49
+ };
50
+ });
51
+ }
52
+ export async function readPrHandoffNotes(notesPath) {
53
+ try {
54
+ return parsePrHandoffNotes(await readFile(notesPath, "utf8"));
55
+ }
56
+ catch (err) {
57
+ const code = err?.code;
58
+ if (code === "ENOENT")
59
+ return [];
60
+ throw err;
61
+ }
62
+ }
63
+ export async function appendPrHandoffNote(opts) {
64
+ await mkdir(path.dirname(opts.notesPath), { recursive: true });
65
+ await appendFile(opts.notesPath, `${JSON.stringify(opts.note)}\n`, "utf8");
66
+ }
@@ -9,8 +9,11 @@ export type ResolvedPrPaths = {
9
9
  prDir: string;
10
10
  metaPath: string;
11
11
  diffstatPath: string;
12
+ notesPath: string;
12
13
  verifyLogPath: string;
13
14
  reviewPath: string;
15
+ githubTitlePath: string;
16
+ githubBodyPath: string;
14
17
  };
15
18
  export declare function resolvePrPaths(opts: {
16
19
  ctx?: CommandContext;
@@ -25,5 +28,15 @@ export declare function readPrArtifact(opts: {
25
28
  prDir: string;
26
29
  fileName: string;
27
30
  branch: string;
31
+ worktreePath?: string | null;
32
+ }): Promise<string | null>;
33
+ export declare function readPrArtifactFromBranch(opts: {
34
+ resolved: {
35
+ gitRoot: string;
36
+ };
37
+ prDir: string;
38
+ fileName: string;
39
+ branch: string;
40
+ worktreePath?: string | null;
28
41
  }): Promise<string | null>;
29
42
  //# sourceMappingURL=pr-paths.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pr-paths.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/internal/pr-paths.ts"],"names":[],"mappings":"AAGA,OAAO,EAA8B,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIxF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,eAAe,CAAC,CAoB3B;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWzB"}
1
+ {"version":3,"file":"pr-paths.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/internal/pr-paths.ts"],"names":[],"mappings":"AAGA,OAAO,EAA8B,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIxF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,eAAe,CAAC,CAuB3B;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAMzB;AAED,wBAAsB,wBAAwB,CAAC,IAAI,EAAE;IACnD,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiBzB"}
@@ -19,8 +19,11 @@ export async function resolvePrPaths(opts) {
19
19
  prDir,
20
20
  metaPath: path.join(prDir, "meta.json"),
21
21
  diffstatPath: path.join(prDir, "diffstat.txt"),
22
+ notesPath: path.join(prDir, "notes.jsonl"),
22
23
  verifyLogPath: path.join(prDir, "verify.log"),
23
24
  reviewPath: path.join(prDir, "review.md"),
25
+ githubTitlePath: path.join(prDir, "github-title.txt"),
26
+ githubBodyPath: path.join(prDir, "github-body.md"),
24
27
  };
25
28
  }
26
29
  export async function readPrArtifact(opts) {
@@ -28,6 +31,16 @@ export async function readPrArtifact(opts) {
28
31
  if (await fileExists(filePath)) {
29
32
  return await readFile(filePath, "utf8");
30
33
  }
34
+ return await readPrArtifactFromBranch(opts);
35
+ }
36
+ export async function readPrArtifactFromBranch(opts) {
37
+ const filePath = path.join(opts.prDir, opts.fileName);
38
+ if (opts.worktreePath) {
39
+ const worktreeFilePath = path.join(opts.worktreePath, path.relative(opts.resolved.gitRoot, filePath));
40
+ if (await fileExists(worktreeFilePath)) {
41
+ return await readFile(worktreeFilePath, "utf8");
42
+ }
43
+ }
31
44
  const rel = toGitPath(path.relative(opts.resolved.gitRoot, filePath));
32
45
  try {
33
46
  return await gitShowFile(opts.resolved.gitRoot, opts.branch, rel);
@@ -1,9 +1,29 @@
1
- export declare function renderPrReviewTemplate(opts: {
2
- author: string;
3
- createdAt: string;
1
+ import type { TaskData } from "../../../backends/task-backend.js";
2
+ import type { PrHandoffNote } from "./note-store.js";
3
+ export declare function buildGithubPrTitle(task: TaskData): string;
4
+ export declare function renderPrAutoSummary(opts: {
5
+ updatedAt: string;
4
6
  branch: string;
7
+ headSha: string | null;
8
+ diffstat: string;
5
9
  }): string;
6
10
  export declare function updateAutoSummaryBlock(text: string, summary: string): string;
7
- export declare function appendHandoffNote(review: string, note: string): string;
11
+ export declare function extractAutoSummaryBlock(text: string): string | null;
12
+ export declare function renderPrHandoffNotes(notes: PrHandoffNote[]): string[];
13
+ export declare function updateHandoffNotesBlock(text: string, notes: PrHandoffNote[]): string;
14
+ export declare function renderPrReviewDocument(opts: {
15
+ task: TaskData;
16
+ author?: string;
17
+ createdAt: string;
18
+ branch: string;
19
+ handoffNotes?: PrHandoffNote[];
20
+ autoSummary: string;
21
+ }): string;
22
+ export declare function renderGithubPrBody(opts: {
23
+ task: TaskData;
24
+ handoffNotes?: PrHandoffNote[];
25
+ autoSummary: string;
26
+ }): string;
8
27
  export declare function validateReviewContents(review: string, errors: string[]): void;
28
+ export declare function validateGithubPrBodyContents(body: string, errors: string[]): void;
9
29
  //# sourceMappingURL=review-template.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"review-template.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/internal/review-template.ts"],"names":[],"mappings":"AAAA,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,MAAM,CA0BT;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAW5E;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAQtE;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAW7E"}
1
+ {"version":3,"file":"review-template.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/internal/review-template.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAoJrD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAKzD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,CAeT;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAS5E;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKnE;AAMD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,MAAM,EAAE,CAOrE;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,MAAM,CAgBpF;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,aAAa,EAAE,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,MAAM,CAgBT;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,IAAI,EAAE,QAAQ,CAAC;IACf,YAAY,CAAC,EAAE,aAAa,EAAE,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,MAAM,CAST;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAiB7E;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAajF"}