issue-flow 0.17.0 → 0.19.1

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 (239) hide show
  1. package/README.md +34 -100
  2. package/dist/agent-EWKA7357.js +32 -0
  3. package/dist/{analyze-6M3KEOX7.js → analyze-Z7ODC27F.js} +42 -41
  4. package/dist/analyze-Z7ODC27F.js.map +1 -0
  5. package/dist/{apply-ADB3ZK7W.js → apply-VNSWQS6O.js} +22 -24
  6. package/dist/apply-VNSWQS6O.js.map +1 -0
  7. package/dist/artifacts-AMJQJFFV.js +82 -0
  8. package/dist/artifacts-AMJQJFFV.js.map +1 -0
  9. package/dist/{bench-FM7I7EIV.js → bench-ZJEIACUK.js} +42 -42
  10. package/dist/{chunk-RYOUZ6EK.js → chunk-23VHVVKW.js} +3 -3
  11. package/dist/chunk-2EYLOS5I.js +99 -0
  12. package/dist/chunk-2EYLOS5I.js.map +1 -0
  13. package/dist/{chunk-ANI2NTR4.js → chunk-2EZW4X57.js} +28 -25
  14. package/dist/chunk-2EZW4X57.js.map +1 -0
  15. package/dist/{chunk-E6KXCV3T.js → chunk-2Q6PG3MT.js} +15 -15
  16. package/dist/chunk-2Q6PG3MT.js.map +1 -0
  17. package/dist/{chunk-C5TL7T4V.js → chunk-2YM2VH6R.js} +2 -2
  18. package/dist/{chunk-LPWPFIIB.js → chunk-2YYP7AE6.js} +14 -16
  19. package/dist/{chunk-LPWPFIIB.js.map → chunk-2YYP7AE6.js.map} +1 -1
  20. package/dist/chunk-3JD25HHJ.js +278 -0
  21. package/dist/chunk-3JD25HHJ.js.map +1 -0
  22. package/dist/{chunk-ISZ54SVE.js → chunk-46S7APLQ.js} +41 -17
  23. package/dist/chunk-46S7APLQ.js.map +1 -0
  24. package/dist/chunk-6AOZCWN2.js +21 -0
  25. package/dist/chunk-6AOZCWN2.js.map +1 -0
  26. package/dist/{chunk-QPGEFLMY.js → chunk-7CMVL4X6.js} +7 -7
  27. package/dist/chunk-7MJGYPHF.js +1571 -0
  28. package/dist/chunk-7MJGYPHF.js.map +1 -0
  29. package/dist/chunk-7ZZUSMBJ.js +35 -0
  30. package/dist/chunk-7ZZUSMBJ.js.map +1 -0
  31. package/dist/{chunk-DUS5ZNKL.js → chunk-DIMDAYZS.js} +7 -6
  32. package/dist/{chunk-DGRTJD5R.js → chunk-DXH4TQRB.js} +7 -7
  33. package/dist/{chunk-CRGIQFUQ.js → chunk-E2H3JV2E.js} +3 -1
  34. package/dist/chunk-E2H3JV2E.js.map +1 -0
  35. package/dist/{chunk-YUNBOUQH.js → chunk-ERAG5IQB.js} +8 -8
  36. package/dist/{chunk-D6ZBGJ3L.js → chunk-F2NFJ27Z.js} +130 -36
  37. package/dist/chunk-F2NFJ27Z.js.map +1 -0
  38. package/dist/{chunk-SOM4QA6C.js → chunk-GD7JZMSJ.js} +93 -18
  39. package/dist/chunk-GD7JZMSJ.js.map +1 -0
  40. package/dist/{chunk-YII4U7ZD.js → chunk-HEHHQU4G.js} +70 -81
  41. package/dist/chunk-HEHHQU4G.js.map +1 -0
  42. package/dist/{chunk-KZ5EY5XX.js → chunk-HHXWAWU6.js} +159 -114
  43. package/dist/chunk-HHXWAWU6.js.map +1 -0
  44. package/dist/{chunk-SGTTR4XW.js → chunk-HWWB22HC.js} +152 -100
  45. package/dist/chunk-HWWB22HC.js.map +1 -0
  46. package/dist/chunk-IMB6FA2F.js +673 -0
  47. package/dist/chunk-IMB6FA2F.js.map +1 -0
  48. package/dist/{chunk-6YQT3SSM.js → chunk-IQYXXFRC.js} +22 -6
  49. package/dist/chunk-IQYXXFRC.js.map +1 -0
  50. package/dist/chunk-J6VJ5M2U.js +1201 -0
  51. package/dist/chunk-J6VJ5M2U.js.map +1 -0
  52. package/dist/{chunk-B3TSS7BT.js → chunk-KDQRNVBZ.js} +3 -3
  53. package/dist/{chunk-A4H7P7T7.js → chunk-LRWIP7QS.js} +41 -26
  54. package/dist/chunk-LRWIP7QS.js.map +1 -0
  55. package/dist/{chunk-DV7HUC4Z.js → chunk-LYC57OXF.js} +20 -117
  56. package/dist/chunk-LYC57OXF.js.map +1 -0
  57. package/dist/{chunk-HAKDLR6N.js → chunk-MAJ6QDRL.js} +65 -78
  58. package/dist/chunk-MAJ6QDRL.js.map +1 -0
  59. package/dist/{chunk-HJBF4WD2.js → chunk-MHA7Q3KU.js} +288 -108
  60. package/dist/chunk-MHA7Q3KU.js.map +1 -0
  61. package/dist/{chunk-UK4E2FUA.js → chunk-MQTVMB7W.js} +103 -76
  62. package/dist/chunk-MQTVMB7W.js.map +1 -0
  63. package/dist/chunk-NP47HRX2.js +136 -0
  64. package/dist/chunk-NP47HRX2.js.map +1 -0
  65. package/dist/{chunk-MI5TREN3.js → chunk-NYDAHE3Y.js} +52 -46
  66. package/dist/chunk-NYDAHE3Y.js.map +1 -0
  67. package/dist/{chunk-UWDCIFTP.js → chunk-P7ZYOC23.js} +41 -57
  68. package/dist/chunk-P7ZYOC23.js.map +1 -0
  69. package/dist/{chunk-3R27MJ5R.js → chunk-PFWHHYEO.js} +3 -3
  70. package/dist/{chunk-2SUFAE6X.js → chunk-PHPAK2L6.js} +44 -33
  71. package/dist/{chunk-2SUFAE6X.js.map → chunk-PHPAK2L6.js.map} +1 -1
  72. package/dist/{chunk-PPZ3K4YM.js → chunk-PRGPSNGA.js} +2 -2
  73. package/dist/{chunk-32JSYXEK.js → chunk-RGFMQFX7.js} +9 -23
  74. package/dist/{chunk-32JSYXEK.js.map → chunk-RGFMQFX7.js.map} +1 -1
  75. package/dist/{chunk-YVPZUN6X.js → chunk-TJVX42KY.js} +335 -38
  76. package/dist/chunk-TJVX42KY.js.map +1 -0
  77. package/dist/{chunk-RCZJQUTC.js → chunk-UDRAD7MF.js} +60 -27
  78. package/dist/chunk-UDRAD7MF.js.map +1 -0
  79. package/dist/{chunk-HY5HLFDU.js → chunk-UHDXXLYH.js} +148 -135
  80. package/dist/chunk-UHDXXLYH.js.map +1 -0
  81. package/dist/{chunk-RNFUVKC3.js → chunk-UPAAZU4W.js} +30 -13
  82. package/dist/chunk-UPAAZU4W.js.map +1 -0
  83. package/dist/{chunk-L6HSKTQE.js → chunk-W7LZLJAF.js} +4 -4
  84. package/dist/{chunk-HLAPOUEM.js → chunk-WB2FVIUS.js} +44 -12
  85. package/dist/chunk-WB2FVIUS.js.map +1 -0
  86. package/dist/{chunk-VE3IYNDN.js → chunk-WPHC6JBR.js} +9 -9
  87. package/dist/chunk-WPHC6JBR.js.map +1 -0
  88. package/dist/{chunk-KZXQWC7U.js → chunk-XHCP6ZNO.js} +201 -64
  89. package/dist/chunk-XHCP6ZNO.js.map +1 -0
  90. package/dist/{chunk-7F7LGMVO.js → chunk-XKR3VD2Z.js} +12 -12
  91. package/dist/{chunk-7F7LGMVO.js.map → chunk-XKR3VD2Z.js.map} +1 -1
  92. package/dist/{chunk-ICM463EO.js → chunk-XNK5UN2D.js} +5 -649
  93. package/dist/chunk-XNK5UN2D.js.map +1 -0
  94. package/dist/{chunk-Z5O2XBWA.js → chunk-XQLNZW7I.js} +40 -30
  95. package/dist/chunk-XQLNZW7I.js.map +1 -0
  96. package/dist/{chunk-QMIQR7EE.js → chunk-ZAYATXJD.js} +32 -316
  97. package/dist/chunk-ZAYATXJD.js.map +1 -0
  98. package/dist/cli.js +128 -60
  99. package/dist/cli.js.map +1 -1
  100. package/dist/compat-YPDZB34U.js +24 -0
  101. package/dist/{config-KGZUPAUP.js → config-56B4OHZE.js} +20 -17
  102. package/dist/{contract-JH2WBIO6.js → contract-HWLFFL3F.js} +2 -2
  103. package/dist/{conventions-RYN7OXJN.js → conventions-DW2CM5I3.js} +20 -16
  104. package/dist/{conventions-RYN7OXJN.js.map → conventions-DW2CM5I3.js.map} +1 -1
  105. package/dist/db-5NU77PJA.js +264 -0
  106. package/dist/db-5NU77PJA.js.map +1 -0
  107. package/dist/diagnostics-UCTS2VUF.js +25 -0
  108. package/dist/execute-R7AVOLNG.js +38 -0
  109. package/dist/{generate-CX6KNHZS.js → generate-O7GUXLN4.js} +46 -43
  110. package/dist/generate-O7GUXLN4.js.map +1 -0
  111. package/dist/{git-A2IP32PQ.js → git-LCG45YXD.js} +2 -3
  112. package/dist/history-6GSURU3H.js +101 -0
  113. package/dist/history-6GSURU3H.js.map +1 -0
  114. package/dist/init-DD6DBRC5.js +28 -0
  115. package/dist/{operations-CAKIT2BO.js → operations-HU5ZFEBA.js} +78 -52
  116. package/dist/operations-HU5ZFEBA.js.map +1 -0
  117. package/dist/{permissions-G4XCAESF.js → permissions-NNNSRC4P.js} +5 -6
  118. package/dist/plan-XR6B7EM3.js +38 -0
  119. package/dist/{policy-WX6O2JID.js → policy-RFJOJQL6.js} +17 -15
  120. package/dist/{policy-WX6O2JID.js.map → policy-RFJOJQL6.js.map} +1 -1
  121. package/dist/pr-OSCNJCOO.js +42 -0
  122. package/dist/pr-review-IKIYHFBO.js +33 -0
  123. package/dist/prd-HFDZJJQR.js +37 -0
  124. package/dist/{ps-76L6ZAZL.js → ps-AKRHGPSR.js} +26 -15
  125. package/dist/ps-AKRHGPSR.js.map +1 -0
  126. package/dist/{recorder-N7U66HCO.js → recorder-T7426CKV.js} +11 -7
  127. package/dist/registry-DWRKD65A.js +17 -0
  128. package/dist/repository-TABBRW2C.js +80 -0
  129. package/dist/resume-GDXKK5XP.js +278 -0
  130. package/dist/resume-GDXKK5XP.js.map +1 -0
  131. package/dist/review-JJHMQA2O.js +38 -0
  132. package/dist/routing-FPNUVE7T.js +35 -0
  133. package/dist/run-RLCURLLL.js +61 -0
  134. package/dist/{session-publisher-KAJQRHNZ.js → session-publisher-Q5TNEZPX.js} +3 -3
  135. package/dist/session-publisher-Q5TNEZPX.js.map +1 -0
  136. package/dist/{state-manager-UPHO2EA2.js → state-manager-IGNTD4AB.js} +9 -4
  137. package/dist/state-manager-IGNTD4AB.js.map +1 -0
  138. package/dist/{usage-U7QNGCPK.js → usage-XW27AL5K.js} +69 -63
  139. package/dist/usage-XW27AL5K.js.map +1 -0
  140. package/dist/web-NCDBVZ5Y.js +205 -0
  141. package/dist/web-NCDBVZ5Y.js.map +1 -0
  142. package/package.json +20 -7
  143. package/prompts/analyze.md +16 -19
  144. package/prompts/execute.md +73 -144
  145. package/prompts/generate.md +23 -10
  146. package/prompts/plan.md +32 -60
  147. package/prompts/pr-review.md +58 -40
  148. package/prompts/pr.md +50 -16
  149. package/prompts/prd.md +26 -19
  150. package/prompts/review.md +41 -18
  151. package/web/AGENTS.md +115 -7
  152. package/web/public/app.css +393 -245
  153. package/web/public/app.js +212 -143
  154. package/web/public/index.html +106 -78
  155. package/dist/agent-TB6W7PT7.js +0 -30
  156. package/dist/analyze-6M3KEOX7.js.map +0 -1
  157. package/dist/apply-ADB3ZK7W.js.map +0 -1
  158. package/dist/chunk-6YQT3SSM.js.map +0 -1
  159. package/dist/chunk-A4H7P7T7.js.map +0 -1
  160. package/dist/chunk-ANI2NTR4.js.map +0 -1
  161. package/dist/chunk-CRGIQFUQ.js.map +0 -1
  162. package/dist/chunk-D6ZBGJ3L.js.map +0 -1
  163. package/dist/chunk-DV7HUC4Z.js.map +0 -1
  164. package/dist/chunk-E6KXCV3T.js.map +0 -1
  165. package/dist/chunk-HAKDLR6N.js.map +0 -1
  166. package/dist/chunk-HJBF4WD2.js.map +0 -1
  167. package/dist/chunk-HLAPOUEM.js.map +0 -1
  168. package/dist/chunk-HY5HLFDU.js.map +0 -1
  169. package/dist/chunk-ICM463EO.js.map +0 -1
  170. package/dist/chunk-ISZ54SVE.js.map +0 -1
  171. package/dist/chunk-KZ5EY5XX.js.map +0 -1
  172. package/dist/chunk-KZXQWC7U.js.map +0 -1
  173. package/dist/chunk-MI5TREN3.js.map +0 -1
  174. package/dist/chunk-QMIQR7EE.js.map +0 -1
  175. package/dist/chunk-RCZJQUTC.js.map +0 -1
  176. package/dist/chunk-RNFUVKC3.js.map +0 -1
  177. package/dist/chunk-SGTTR4XW.js.map +0 -1
  178. package/dist/chunk-SOM4QA6C.js.map +0 -1
  179. package/dist/chunk-UK4E2FUA.js.map +0 -1
  180. package/dist/chunk-UWDCIFTP.js.map +0 -1
  181. package/dist/chunk-VE3IYNDN.js.map +0 -1
  182. package/dist/chunk-WCCZJL7W.js +0 -141
  183. package/dist/chunk-WCCZJL7W.js.map +0 -1
  184. package/dist/chunk-XEYH6ZZI.js +0 -289
  185. package/dist/chunk-XEYH6ZZI.js.map +0 -1
  186. package/dist/chunk-XZUEFTUP.js +0 -243
  187. package/dist/chunk-XZUEFTUP.js.map +0 -1
  188. package/dist/chunk-YII4U7ZD.js.map +0 -1
  189. package/dist/chunk-YVPZUN6X.js.map +0 -1
  190. package/dist/chunk-Z5O2XBWA.js.map +0 -1
  191. package/dist/diagnostics-HTCWF7F4.js +0 -23
  192. package/dist/execute-QL3ZQIAP.js +0 -37
  193. package/dist/generate-CX6KNHZS.js.map +0 -1
  194. package/dist/init-PDVQDRS6.js +0 -24
  195. package/dist/operations-CAKIT2BO.js.map +0 -1
  196. package/dist/plan-PRORGS3L.js +0 -34
  197. package/dist/pr-27RMQI5F.js +0 -39
  198. package/dist/pr-review-VNESMAMT.js +0 -32
  199. package/dist/prd-ZNC4T5BS.js +0 -33
  200. package/dist/ps-76L6ZAZL.js.map +0 -1
  201. package/dist/registry-XLHHYLTR.js +0 -15
  202. package/dist/resume-VLWIE264.js +0 -244
  203. package/dist/resume-VLWIE264.js.map +0 -1
  204. package/dist/review-7CREJDKB.js +0 -35
  205. package/dist/routing-VCDYHSXA.js +0 -33
  206. package/dist/run-3MPORLF5.js +0 -56
  207. package/dist/usage-U7QNGCPK.js.map +0 -1
  208. package/dist/web-HUNDHCJ4.js +0 -172
  209. package/dist/web-HUNDHCJ4.js.map +0 -1
  210. /package/dist/{agent-TB6W7PT7.js.map → agent-EWKA7357.js.map} +0 -0
  211. /package/dist/{bench-FM7I7EIV.js.map → bench-ZJEIACUK.js.map} +0 -0
  212. /package/dist/{chunk-RYOUZ6EK.js.map → chunk-23VHVVKW.js.map} +0 -0
  213. /package/dist/{chunk-C5TL7T4V.js.map → chunk-2YM2VH6R.js.map} +0 -0
  214. /package/dist/{chunk-QPGEFLMY.js.map → chunk-7CMVL4X6.js.map} +0 -0
  215. /package/dist/{chunk-DUS5ZNKL.js.map → chunk-DIMDAYZS.js.map} +0 -0
  216. /package/dist/{chunk-DGRTJD5R.js.map → chunk-DXH4TQRB.js.map} +0 -0
  217. /package/dist/{chunk-YUNBOUQH.js.map → chunk-ERAG5IQB.js.map} +0 -0
  218. /package/dist/{chunk-B3TSS7BT.js.map → chunk-KDQRNVBZ.js.map} +0 -0
  219. /package/dist/{chunk-3R27MJ5R.js.map → chunk-PFWHHYEO.js.map} +0 -0
  220. /package/dist/{chunk-PPZ3K4YM.js.map → chunk-PRGPSNGA.js.map} +0 -0
  221. /package/dist/{chunk-L6HSKTQE.js.map → chunk-W7LZLJAF.js.map} +0 -0
  222. /package/dist/{config-KGZUPAUP.js.map → compat-YPDZB34U.js.map} +0 -0
  223. /package/dist/{contract-JH2WBIO6.js.map → config-56B4OHZE.js.map} +0 -0
  224. /package/dist/{diagnostics-HTCWF7F4.js.map → contract-HWLFFL3F.js.map} +0 -0
  225. /package/dist/{execute-QL3ZQIAP.js.map → diagnostics-UCTS2VUF.js.map} +0 -0
  226. /package/dist/{git-A2IP32PQ.js.map → execute-R7AVOLNG.js.map} +0 -0
  227. /package/dist/{init-PDVQDRS6.js.map → git-LCG45YXD.js.map} +0 -0
  228. /package/dist/{permissions-G4XCAESF.js.map → init-DD6DBRC5.js.map} +0 -0
  229. /package/dist/{plan-PRORGS3L.js.map → permissions-NNNSRC4P.js.map} +0 -0
  230. /package/dist/{pr-27RMQI5F.js.map → plan-XR6B7EM3.js.map} +0 -0
  231. /package/dist/{pr-review-VNESMAMT.js.map → pr-OSCNJCOO.js.map} +0 -0
  232. /package/dist/{prd-ZNC4T5BS.js.map → pr-review-IKIYHFBO.js.map} +0 -0
  233. /package/dist/{recorder-N7U66HCO.js.map → prd-HFDZJJQR.js.map} +0 -0
  234. /package/dist/{registry-XLHHYLTR.js.map → recorder-T7426CKV.js.map} +0 -0
  235. /package/dist/{review-7CREJDKB.js.map → registry-DWRKD65A.js.map} +0 -0
  236. /package/dist/{routing-VCDYHSXA.js.map → repository-TABBRW2C.js.map} +0 -0
  237. /package/dist/{run-3MPORLF5.js.map → review-JJHMQA2O.js.map} +0 -0
  238. /package/dist/{session-publisher-KAJQRHNZ.js.map → routing-FPNUVE7T.js.map} +0 -0
  239. /package/dist/{state-manager-UPHO2EA2.js.map → run-RLCURLLL.js.map} +0 -0
@@ -3,26 +3,7 @@ import {
3
3
  formatPhaseLine,
4
4
  loadPhaseTiming,
5
5
  snapshotTimingFields
6
- } from "./chunk-B3TSS7BT.js";
7
- import {
8
- runPr
9
- } from "./chunk-LPWPFIIB.js";
10
- import {
11
- mostRecent,
12
- prReviewDir,
13
- readPrReviewIndex,
14
- runPrReview
15
- } from "./chunk-Z5O2XBWA.js";
16
- import {
17
- listPullRequests,
18
- publishGitState
19
- } from "./chunk-YUNBOUQH.js";
20
- import {
21
- runPrd
22
- } from "./chunk-ANI2NTR4.js";
23
- import {
24
- runReview
25
- } from "./chunk-MI5TREN3.js";
6
+ } from "./chunk-KDQRNVBZ.js";
26
7
  import {
27
8
  PIPELINE_PHASES,
28
9
  PIPELINE_PHASES_NO_BRANCH,
@@ -41,51 +22,71 @@ import {
41
22
  markQueueIssueInProgress,
42
23
  markQueueIssueSkipped,
43
24
  nextQueueIssue,
25
+ queueNeedsFinalization,
44
26
  saveExecutionPlan,
45
27
  setQueueBranch,
46
28
  setQueuePullRequest
47
- } from "./chunk-A4H7P7T7.js";
29
+ } from "./chunk-LRWIP7QS.js";
48
30
  import {
49
- runInit
50
- } from "./chunk-ISZ54SVE.js";
31
+ listStoredIssueEvents
32
+ } from "./chunk-2EYLOS5I.js";
51
33
  import {
34
+ SqliteSessionPublisher,
52
35
  printQueueSummary,
53
36
  printRunSummary,
54
37
  runExecute,
55
38
  stripMarkdown
56
- } from "./chunk-KZXQWC7U.js";
39
+ } from "./chunk-XHCP6ZNO.js";
57
40
  import {
58
41
  ensureWebMonitor
59
- } from "./chunk-2SUFAE6X.js";
42
+ } from "./chunk-PHPAK2L6.js";
60
43
  import {
61
44
  runPlan
62
- } from "./chunk-KZ5EY5XX.js";
45
+ } from "./chunk-HHXWAWU6.js";
46
+ import {
47
+ runPr
48
+ } from "./chunk-2YYP7AE6.js";
49
+ import {
50
+ mostRecent,
51
+ prReviewDir,
52
+ readPrReviewIndex,
53
+ runPrReview
54
+ } from "./chunk-XQLNZW7I.js";
55
+ import {
56
+ listPullRequests,
57
+ publishGitState
58
+ } from "./chunk-ERAG5IQB.js";
59
+ import {
60
+ runPrd
61
+ } from "./chunk-2EZW4X57.js";
62
+ import {
63
+ runReview
64
+ } from "./chunk-NYDAHE3Y.js";
63
65
  import {
64
66
  resolveCommandIssue
65
- } from "./chunk-VE3IYNDN.js";
67
+ } from "./chunk-WPHC6JBR.js";
68
+ import {
69
+ runInit
70
+ } from "./chunk-46S7APLQ.js";
66
71
  import {
67
72
  getProvider
68
- } from "./chunk-QMIQR7EE.js";
73
+ } from "./chunk-ZAYATXJD.js";
69
74
  import {
70
75
  beginUsageScope,
71
76
  getRunUsageTotals
72
- } from "./chunk-HLAPOUEM.js";
77
+ } from "./chunk-WB2FVIUS.js";
73
78
  import {
74
79
  assessDecomposition,
75
80
  buildDecompositionReport,
76
81
  proposeSubIssues,
77
82
  resetAgentInvocationState
78
- } from "./chunk-UK4E2FUA.js";
79
- import {
80
- JournalPublisher,
81
- MultiPublisher
82
- } from "./chunk-WCCZJL7W.js";
83
+ } from "./chunk-MQTVMB7W.js";
83
84
  import {
84
85
  recommendedTarget
85
- } from "./chunk-D6ZBGJ3L.js";
86
+ } from "./chunk-F2NFJ27Z.js";
86
87
  import {
87
88
  getPackageVersion
88
- } from "./chunk-C5TL7T4V.js";
89
+ } from "./chunk-2YM2VH6R.js";
89
90
  import {
90
91
  describeRunAgents,
91
92
  getActiveResilienceConfig,
@@ -97,13 +98,10 @@ import {
97
98
  loadRoutingConfig,
98
99
  loadWebConfig,
99
100
  onShutdown
100
- } from "./chunk-HY5HLFDU.js";
101
- import {
102
- resolveIssuePaths,
103
- resolveProjectPaths,
104
- resolveQueuePaths
105
- } from "./chunk-DV7HUC4Z.js";
101
+ } from "./chunk-UHDXXLYH.js";
106
102
  import {
103
+ JournalPublisher,
104
+ MultiPublisher,
107
105
  formatDuration,
108
106
  getIcons,
109
107
  getInactivityTimeout,
@@ -112,51 +110,60 @@ import {
112
110
  printInfo,
113
111
  printSuccess,
114
112
  printWarning,
113
+ resolveIssuePaths,
114
+ resolveProjectPaths,
115
+ resolveQueuePaths,
115
116
  setActivityCallback,
116
117
  setInactivityTimeout,
117
118
  setOutputCallback,
118
119
  setStoryStageCallback,
119
120
  setStoryUpdateCallback
120
- } from "./chunk-XZUEFTUP.js";
121
+ } from "./chunk-J6VJ5M2U.js";
121
122
  import {
122
123
  bindDiagnosticContext,
123
124
  flushDiagnostics,
124
125
  writeDiagnostic
125
- } from "./chunk-QPGEFLMY.js";
126
- import {
127
- committedStoryIds,
128
- describePreflight,
129
- getBaseBranch,
130
- getCurrentBranch,
131
- getHeadCommit,
132
- getProjectRoot,
133
- localBranchExists,
134
- preflightRepository,
135
- run
136
- } from "./chunk-YVPZUN6X.js";
126
+ } from "./chunk-7CMVL4X6.js";
137
127
  import {
138
128
  FilePublisher,
139
129
  MemoryPublisher,
140
130
  getSessionPublisher,
141
131
  setSessionPublisher
142
- } from "./chunk-DUS5ZNKL.js";
132
+ } from "./chunk-DIMDAYZS.js";
143
133
  import {
134
+ DEFAULT_MAX_CORRECTION_CYCLES,
135
+ allStoriesPass,
144
136
  isoNow,
145
137
  loadTaskPlan,
146
138
  saveTaskPlan
147
- } from "./chunk-SOM4QA6C.js";
139
+ } from "./chunk-GD7JZMSJ.js";
148
140
  import {
149
141
  acquireRunLock,
150
142
  describeRunLockOwner
151
- } from "./chunk-ICM463EO.js";
143
+ } from "./chunk-IMB6FA2F.js";
144
+ import {
145
+ getPlanRepository,
146
+ ingestGeneratedPlan
147
+ } from "./chunk-7MJGYPHF.js";
148
+ import {
149
+ committedStoryIds,
150
+ describePreflight,
151
+ getBaseBranch,
152
+ getCurrentBranch,
153
+ getHeadCommit,
154
+ getProjectRoot,
155
+ localBranchExists,
156
+ preflightRepository,
157
+ run
158
+ } from "./chunk-TJVX42KY.js";
152
159
 
153
160
  // src/execution/detach.ts
154
- import { spawn } from "child_process";
155
- import { mkdir, open } from "fs/promises";
156
- import { dirname } from "path";
161
+ import { spawn } from "node:child_process";
162
+ import { mkdir, open } from "node:fs/promises";
163
+ import { dirname } from "node:path";
157
164
 
158
165
  // src/storage/run-log.ts
159
- import { rename, stat } from "fs/promises";
166
+ import { rename, stat } from "node:fs/promises";
160
167
  var DEFAULT_RUN_LOG_MAX_BYTES = 5 * 1024 * 1024;
161
168
  async function rotateRunLogIfNeeded(filePath, rotatedPath, maxBytes = DEFAULT_RUN_LOG_MAX_BYTES) {
162
169
  if (maxBytes <= 0) return;
@@ -257,7 +264,7 @@ function parseIssueArguments(values) {
257
264
  }
258
265
 
259
266
  // src/execution/confirm.ts
260
- import { createInterface } from "readline";
267
+ import { createInterface } from "node:readline";
261
268
  var MAX_PROMPT_ATTEMPTS = 3;
262
269
  var QueueConfirmationError = class extends Error {
263
270
  exitCode;
@@ -513,12 +520,48 @@ async function loadResumableQueue(planFile, requested) {
513
520
  const sameRequest = plan.requested.length === requested.length && plan.requested.every((id, index) => id === requested[index]);
514
521
  return sameRequest ? plan : null;
515
522
  }
523
+ function executableGraphIds(graph, requested) {
524
+ const roots = new Set(requested);
525
+ return [...graph.nodes.values()].filter((node) => roots.has(node.id) || node.issue?.state !== "closed").map((node) => node.id);
526
+ }
527
+ async function reconcileClosedDiscoveredIssues(plan, warn) {
528
+ let next = plan;
529
+ const closed = [];
530
+ for (const entry of plan.issues) {
531
+ if (entry.origin !== "discovered" || entry.status === "completed") continue;
532
+ try {
533
+ const issue = await getProvider(entry.source).get(entry.id);
534
+ if (issue?.state !== "closed") continue;
535
+ next = markQueueIssueCompleted(next, entry.id);
536
+ closed.push(entry.id);
537
+ } catch (err) {
538
+ warn(
539
+ `Could not refresh issue #${entry.id} before resuming the queue: ${err instanceof Error ? err.message : String(err)}`
540
+ );
541
+ }
542
+ }
543
+ return { plan: next, closed };
544
+ }
516
545
  async function planQueue(input) {
517
546
  const info = input.info ?? printInfo;
518
547
  const warn = input.warn ?? printWarning;
519
548
  const single = input.requested.length === 1;
520
- const resumable = await loadResumableQueue(input.planFile, input.requested);
521
- if (resumable !== null && isQueueComplete(resumable)) {
549
+ let resumable = await loadResumableQueue(input.planFile, input.requested);
550
+ if (resumable !== null) {
551
+ if (input.closeIssue !== void 0) {
552
+ resumable.closeIssue = input.closeIssue;
553
+ await saveExecutionPlan(input.planFile, resumable);
554
+ }
555
+ const reconciled = await reconcileClosedDiscoveredIssues(resumable, warn);
556
+ resumable = reconciled.plan;
557
+ if (reconciled.closed.length > 0) {
558
+ await saveExecutionPlan(input.planFile, resumable);
559
+ info(
560
+ `Skipping already closed issue(s) in the resumed queue: ${reconciled.closed.map((id) => `#${id}`).join(", ")}.`
561
+ );
562
+ }
563
+ }
564
+ if (resumable !== null && isQueueComplete(resumable) && !queueNeedsFinalization(resumable)) {
522
565
  const pr = resumable.pullRequest?.url;
523
566
  info(
524
567
  `The execution queue of issue #${resumable.id} is already complete (${resumable.issues.length} issues)${pr === void 0 ? "" : ` \u2014 ${pr}`}. Nothing to run.`
@@ -543,10 +586,8 @@ async function planQueue(input) {
543
586
  known: input.known,
544
587
  warn
545
588
  });
546
- if (single && graph.nodes.size <= 1) {
547
- return { kind: "single" };
548
- }
549
- const suggested = computeExecutionOrder(graph);
589
+ const schedulable = executableGraphIds(graph, input.requested);
590
+ const suggested = computeExecutionOrder(graph, { include: schedulable });
550
591
  if (!suggested.ok) {
551
592
  if (single) {
552
593
  warn(
@@ -569,6 +610,9 @@ async function planQueue(input) {
569
610
  noBranch: input.noBranch,
570
611
  prReview: input.prReview
571
612
  });
613
+ if (single && suggestedPlan.issues.length === 1 && suggestedPlan.issues[0]?.role !== "container") {
614
+ return { kind: "single" };
615
+ }
572
616
  let choice;
573
617
  try {
574
618
  choice = await confirmQueue(suggestedPlan, requestedCount, {
@@ -588,7 +632,8 @@ async function planQueue(input) {
588
632
  }
589
633
  let plan = suggestedPlan;
590
634
  if (choice === "cascade") {
591
- const include = collectCascadeIds(graph, input.requested);
635
+ const eligible = new Set(schedulable);
636
+ const include = collectCascadeIds(graph, input.requested).filter((id) => eligible.has(id));
592
637
  const cascadeOrder = computeExecutionOrder(graph, { include });
593
638
  if (!cascadeOrder.ok) {
594
639
  warn(`Dependency cycle between issues: ${describeCycles(cascadeOrder.cycles)}.`);
@@ -638,10 +683,57 @@ async function planQueue(input) {
638
683
  })
639
684
  );
640
685
  }
686
+ if (input.closeIssue !== void 0) plan.closeIssue = input.closeIssue;
641
687
  await saveExecutionPlan(input.planFile, plan);
642
688
  return { kind: "queue", plan, resumed: false };
643
689
  }
644
690
 
691
+ // src/commands/run/closure.ts
692
+ function requestedPhasesComplete(plan) {
693
+ const phases = PIPELINE_PHASES.filter(
694
+ (phase) => !plan.noBranch || phase !== "pr"
695
+ );
696
+ if (plan.prReview?.enabled && !plan.noBranch) phases.push("pr-review");
697
+ return plan.userStories.length > 0 && new PipelineManager(plan, "", phases).getNextPhase() === null && allStoriesPass(plan) && !plan.lastReviewFindings;
698
+ }
699
+ async function closeAndConfirm(id, source) {
700
+ const provider = getProvider(source);
701
+ if ((await provider.get(id))?.state === "closed") return;
702
+ if (!provider.close) throw new Error(`Provider ${source} cannot close issues`);
703
+ await provider.close(id);
704
+ if ((await provider.get(id))?.state !== "closed")
705
+ throw new Error(`Could not confirm closure of ${id}`);
706
+ }
707
+ async function persistClosureChoice(path, choice) {
708
+ if (choice === void 0) return;
709
+ const plan = await loadTaskPlan(path);
710
+ plan.closeIssue = choice;
711
+ await saveTaskPlan(path, plan);
712
+ }
713
+ async function finishIssueClosure(path, id, source) {
714
+ const plan = await loadTaskPlan(path);
715
+ if (!requestedPhasesComplete(plan)) return 1;
716
+ if (plan.closeIssue && !plan.issueClosedAt) {
717
+ try {
718
+ await closeAndConfirm(id, source);
719
+ plan.issueClosedAt = isoNow();
720
+ } catch (error) {
721
+ const message = error instanceof Error ? error.message : String(error);
722
+ plan.lastError = { category: "issue_closure", message, at: isoNow() };
723
+ plan.issueStatus = "in_progress";
724
+ plan.completedAt = null;
725
+ await saveTaskPlan(path, plan);
726
+ printError(`Delivery complete; issue closure pending: ${message}`);
727
+ return 1;
728
+ }
729
+ }
730
+ plan.issueStatus = "completed";
731
+ plan.completedAt ??= isoNow();
732
+ if (plan.lastError?.category === "issue_closure") plan.lastError = null;
733
+ await saveTaskPlan(path, plan);
734
+ return 0;
735
+ }
736
+
645
737
  // src/commands/run/pull-request.ts
646
738
  async function primaryPrCreated(plan) {
647
739
  try {
@@ -706,17 +798,6 @@ async function propagatePullRequest(plan) {
706
798
  }
707
799
  return pullRequest;
708
800
  }
709
- async function closeIssue(issueNumber, source) {
710
- try {
711
- const provider = getProvider(source);
712
- if (provider.close !== void 0) {
713
- printInfo("Closing issue...");
714
- await provider.close(issueNumber);
715
- }
716
- } catch {
717
- printWarning("Failed to close issue automatically");
718
- }
719
- }
720
801
 
721
802
  // src/commands/run/queue-failure.ts
722
803
  async function handleQueueIssueFailure(input) {
@@ -794,6 +875,7 @@ async function decideQueue(input) {
794
875
  planFile: queuePaths.planFile,
795
876
  noBranch: input.noBranch,
796
877
  prReview: input.prReview,
878
+ closeIssue: input.runOptions.closeIssue,
797
879
  confirm: {
798
880
  yes: input.runOptions.yes,
799
881
  only: input.runOptions.only,
@@ -845,6 +927,10 @@ async function detachAfterConfirm(requested, noBranch, prReview, options) {
845
927
  }
846
928
  async function runQueue(initialPlan, options, resolvedPrimary, runIssueSession3) {
847
929
  const planFile = (await resolveQueuePaths(initialPlan.id)).planFile;
930
+ if (options.runOptions?.closeIssue !== void 0) {
931
+ initialPlan = { ...initialPlan, closeIssue: options.runOptions.closeIssue };
932
+ await saveExecutionPlan(planFile, initialPlan);
933
+ }
848
934
  const queueUsage = beginUsageScope();
849
935
  const startedAtMs = Date.now();
850
936
  const resilience = getActiveResilienceConfig();
@@ -1012,7 +1098,7 @@ async function finishQueue(plan, planFile, summaries, startedAtMs, queueUsage, o
1012
1098
  let current = plan;
1013
1099
  let review = null;
1014
1100
  const alreadyOpened = current.pullRequest !== void 0 || await primaryPrCreated(current);
1015
- if (!current.noBranch && options.noBranch !== true && !alreadyOpened) {
1101
+ if (!current.noBranch && options.noBranch !== true && (!alreadyOpened || current.prReview && !current.prReviewCompleted)) {
1016
1102
  const outcome = await runIssueSession3(current.id, options.mode, {
1017
1103
  prReview: options.prReview ?? current.prReview,
1018
1104
  queue: {
@@ -1028,17 +1114,43 @@ async function finishQueue(plan, planFile, summaries, startedAtMs, queueUsage, o
1028
1114
  await saveExecutionPlan(planFile, current);
1029
1115
  return outcome.code;
1030
1116
  }
1117
+ if (current.prReview) current.prReviewCompleted = review !== null && !review.requestedChanges;
1031
1118
  const pullRequest = await propagatePullRequest(current);
1032
1119
  if (pullRequest !== null) {
1033
1120
  current = setQueuePullRequest(current, pullRequest);
1034
1121
  }
1035
1122
  }
1036
1123
  await saveExecutionPlan(planFile, current);
1124
+ if (current.prReview && !current.prReviewCompleted && !review?.requestedChanges) {
1125
+ printError("Consolidated PR review is still pending; resume the queue.");
1126
+ return 1;
1127
+ }
1037
1128
  if (review?.requestedChanges === true) {
1038
1129
  printInfo("Issues left open until the review blockers are addressed.");
1039
- } else {
1130
+ } else if (current.closeIssue && (!current.prReview || current.prReviewCompleted)) {
1040
1131
  for (const entry of current.issues) {
1041
- await closeIssue(entry.id, entry.source);
1132
+ if (entry.status !== "completed" || (current.closedIssueIds ?? []).includes(entry.id))
1133
+ continue;
1134
+ try {
1135
+ await closeAndConfirm(entry.id, entry.source);
1136
+ current.closedIssueIds = [...current.closedIssueIds ?? [], entry.id];
1137
+ await saveExecutionPlan(planFile, current);
1138
+ } catch (error) {
1139
+ printError(`Issue #${entry.id} closure pending: ${String(error)}`);
1140
+ return 1;
1141
+ }
1142
+ }
1143
+ }
1144
+ if (!review?.requestedChanges && (!current.prReview || current.prReviewCompleted)) {
1145
+ for (const entry of current.issues.filter((entry2) => entry2.status === "completed")) {
1146
+ try {
1147
+ const paths = await resolveIssuePaths(entry.id);
1148
+ const task = await loadTaskPlan(paths.tasksFile);
1149
+ task.issueStatus = "completed";
1150
+ task.completedAt = (/* @__PURE__ */ new Date()).toISOString();
1151
+ await saveTaskPlan(paths.tasksFile, task);
1152
+ } catch {
1153
+ }
1042
1154
  }
1043
1155
  }
1044
1156
  printQueueSummary({
@@ -1342,7 +1454,7 @@ async function runPipelineWithRenderer(options) {
1342
1454
  import { execa } from "execa";
1343
1455
 
1344
1456
  // src/commands/run/publish.ts
1345
- import { join } from "path";
1457
+ import { join } from "node:path";
1346
1458
  function toIssueNumber(id) {
1347
1459
  const parsed = Number.parseInt(id, 10);
1348
1460
  return Number.isNaN(parsed) ? null : parsed;
@@ -1423,8 +1535,7 @@ async function readPrReviewOutcome(issue, tasksPath, requestedChanges) {
1423
1535
  }
1424
1536
 
1425
1537
  // src/commands/run/phase-finalize.ts
1426
- async function applyReviewOutcomeAndClose(input) {
1427
- const { issueNumber, resolvedIssue, review, inQueue } = input;
1538
+ function reportReviewOutcome(review) {
1428
1539
  if (review?.requestedChanges) {
1429
1540
  console.log("");
1430
1541
  printWarning("PR review requested changes \u2014 the Pull Request is not ready to merge.");
@@ -1434,8 +1545,6 @@ async function applyReviewOutcomeAndClose(input) {
1434
1545
  }
1435
1546
  if (review?.requestedChanges) {
1436
1547
  printInfo("Issue left open until the review blockers are addressed.");
1437
- } else if (!inQueue) {
1438
- await closeIssue(issueNumber, resolvedIssue.source);
1439
1548
  }
1440
1549
  }
1441
1550
  async function resolveSummaryPrUrl(input) {
@@ -1467,7 +1576,20 @@ async function finalizeSuccessfulIssueRun(input) {
1467
1576
  effectiveNoBranch,
1468
1577
  elapsedSeconds
1469
1578
  } = input;
1470
- await applyReviewOutcomeAndClose({ issueNumber, resolvedIssue, review, inQueue });
1579
+ reportReviewOutcome(review);
1580
+ const closurePlan = !inQueue ? await loadTaskPlan(tasksPath).catch(() => null) : null;
1581
+ if (!inQueue && !review?.requestedChanges && (closurePlan?.closeIssue || closurePlan?.lastError?.category === "issue_closure")) {
1582
+ const code = await finishIssueClosure(tasksPath, issueNumber, resolvedIssue.source);
1583
+ if (code !== 0)
1584
+ return {
1585
+ code,
1586
+ failedPhase: "close",
1587
+ branchName: producedBranch,
1588
+ storyCount: 0,
1589
+ elapsedSeconds,
1590
+ review
1591
+ };
1592
+ }
1471
1593
  let branchName = "unknown";
1472
1594
  try {
1473
1595
  const proc = await execa("git", ["branch", "--show-current"], { reject: false });
@@ -1481,7 +1603,7 @@ async function finalizeSuccessfulIssueRun(input) {
1481
1603
  storyCount = plan.userStories.length;
1482
1604
  planPrUrl = plan.pullRequest?.url ?? null;
1483
1605
  plan.lastAttemptAt = isoNow();
1484
- if (!review?.requestedChanges) {
1606
+ if (!review?.requestedChanges && !inQueue) {
1485
1607
  plan.issueStatus = "completed";
1486
1608
  plan.completedAt = isoNow();
1487
1609
  }
@@ -1530,7 +1652,7 @@ async function finalizeSuccessfulIssueRun(input) {
1530
1652
  }
1531
1653
 
1532
1654
  // src/commands/run/phase-bootstrap.ts
1533
- import { randomUUID } from "crypto";
1655
+ import { randomUUID } from "node:crypto";
1534
1656
 
1535
1657
  // src/commands/run/phase-config.ts
1536
1658
  async function buildAgentConfiguration(prReview) {
@@ -1580,8 +1702,10 @@ async function buildAgentConfiguration(prReview) {
1580
1702
  }
1581
1703
 
1582
1704
  // src/commands/run/types.ts
1583
- var RUNNABLE_PHASES = ["prd", "plan", "execute", "review", "pr"];
1584
- var RUNNABLE_PHASES_NO_BRANCH = ["prd", "plan", "execute", "review"];
1705
+ var RUNNABLE_PHASES = PIPELINE_PHASES.filter((phase) => phase !== "init");
1706
+ var RUNNABLE_PHASES_NO_BRANCH = RUNNABLE_PHASES.filter(
1707
+ (phase) => phase !== "pr"
1708
+ );
1585
1709
  var RUNNABLE_PHASES_WITH_PR_REVIEW = [...RUNNABLE_PHASES, "pr-review"];
1586
1710
  var QUEUE_PR_PHASES = ["init", "pr"];
1587
1711
  var QUEUE_PR_PHASES_WITH_REVIEW = [
@@ -2018,14 +2142,17 @@ async function preparePhaseRun(issueNumber, paths, mode, publisher, input) {
2018
2142
  };
2019
2143
  }
2020
2144
 
2145
+ // src/commands/run/phase-runners.ts
2146
+ import { existsSync } from "node:fs";
2147
+
2021
2148
  // src/commands/run/session.ts
2022
- import { mkdir as mkdir3 } from "fs/promises";
2149
+ import { mkdir as mkdir3 } from "node:fs/promises";
2023
2150
 
2024
2151
  // src/commands/run/oversized.ts
2025
- import { mkdir as mkdir2, readFile, writeFile } from "fs/promises";
2152
+ import { mkdir as mkdir2, readFile, writeFile } from "node:fs/promises";
2026
2153
  async function reportIfOversized(issueNumber, paths, result) {
2027
2154
  try {
2028
- const journal = `${await readFileIfPresent(paths.rotatedEventsFile)}${await readFileIfPresent(paths.eventsFile)}`;
2155
+ const journal = await readJournal(paths);
2029
2156
  const plan = await loadTaskPlan(paths.tasksFile).catch(() => null);
2030
2157
  const assessment = assessDecomposition({
2031
2158
  journal,
@@ -2064,6 +2191,18 @@ async function reportIfOversized(issueNumber, paths, result) {
2064
2191
  } catch {
2065
2192
  }
2066
2193
  }
2194
+ async function readJournal(paths) {
2195
+ const repository = getPlanRepository(paths.tasksFile);
2196
+ if (repository === void 0) {
2197
+ return `${await readFileIfPresent(paths.rotatedEventsFile)}${await readFileIfPresent(paths.eventsFile)}`;
2198
+ }
2199
+ const events = await listStoredIssueEvents({
2200
+ projectId: repository.projectId,
2201
+ issueId: repository.issueId,
2202
+ ...repository.databaseOptions === void 0 ? {} : { databaseOptions: repository.databaseOptions }
2203
+ });
2204
+ return events.map((entry) => JSON.stringify(entry)).join("\n");
2205
+ }
2067
2206
  async function maybeCreateSubIssues(issueNumber, plan, reportFile) {
2068
2207
  if (getActiveResilienceConfig().decompose?.auto !== true) {
2069
2208
  printInfo(`Nothing was split. Read ${reportFile} and decide.`);
@@ -2081,7 +2220,7 @@ async function maybeCreateSubIssues(issueNumber, plan, reportFile) {
2081
2220
  printInfo("Nothing left to split: no pending story.");
2082
2221
  return;
2083
2222
  }
2084
- const { runGenerate } = await import("./generate-CX6KNHZS.js");
2223
+ const { runGenerate } = await import("./generate-O7GUXLN4.js");
2085
2224
  for (const proposal of proposals) {
2086
2225
  const instruction = [
2087
2226
  `Create a sub-issue of #${issueNumber}: ${proposal.title}.`,
@@ -2167,6 +2306,15 @@ async function pauseIssue(tasksFile, issueNumber) {
2167
2306
  async function createSessionPublisher(input) {
2168
2307
  const { paths, persistSnapshot, journalEnabled, webConfig, maxFileBytes } = input;
2169
2308
  const surfaces = [];
2309
+ const repository = getPlanRepository(paths.tasksFile);
2310
+ if (repository !== void 0) {
2311
+ surfaces.push(
2312
+ new SqliteSessionPublisher(repository, {
2313
+ logLimit: webConfig.logLimit,
2314
+ includeLogs: webConfig.includeLogs
2315
+ })
2316
+ );
2317
+ }
2170
2318
  if (persistSnapshot || journalEnabled) {
2171
2319
  await mkdir3(paths.issueDir, { recursive: true });
2172
2320
  }
@@ -2341,6 +2489,11 @@ function createPlanRunner(input, makeRunner) {
2341
2489
  }),
2342
2490
  "plan"
2343
2491
  )();
2492
+ const repository = getPlanRepository(tasksPath);
2493
+ if (repository !== void 0 && existsSync(tasksPath)) {
2494
+ await ingestGeneratedPlan(repository);
2495
+ }
2496
+ await persistClosureChoice(tasksPath, input.closureChoice);
2344
2497
  try {
2345
2498
  const plan = await loadTaskPlan(tasksPath);
2346
2499
  if (!effectiveNoBranch) {
@@ -2372,14 +2525,20 @@ function createPlanRunner(input, makeRunner) {
2372
2525
  function createReviewRunner(input) {
2373
2526
  const { issueNumber, tasksPath, publisher, resolvedIssue, queueCommitScope, executeRetry } = input;
2374
2527
  return async () => {
2375
- let maxCycles = 3;
2528
+ let maxCycles = DEFAULT_MAX_CORRECTION_CYCLES;
2529
+ let cycle = 0;
2376
2530
  try {
2377
2531
  const plan = await loadTaskPlan(tasksPath);
2378
2532
  maxCycles = plan.maxCorrectionCycles;
2533
+ cycle = plan.correctionCycle;
2379
2534
  } catch {
2380
2535
  }
2381
2536
  let code = await runReview(issueNumber, resolvedIssue);
2382
- let cycle = 0;
2537
+ if (code !== 0 && (await loadTaskPlan(tasksPath)).lastError?.category === "review_protocol") {
2538
+ throw new Error(
2539
+ "Review returned an invalid result; resume review after correcting its output."
2540
+ );
2541
+ }
2383
2542
  while (code !== 0 && cycle < maxCycles) {
2384
2543
  cycle++;
2385
2544
  printWarning(`Review failed. Starting correction cycle ${cycle}/${maxCycles}...`);
@@ -2392,6 +2551,7 @@ function createReviewRunner(input) {
2392
2551
  }
2393
2552
  const execCode = await runExecute(void 0, {
2394
2553
  issue: issueNumber,
2554
+ inPipeline: true,
2395
2555
  commitScope: queueCommitScope,
2396
2556
  ...executeRetry
2397
2557
  });
@@ -2399,6 +2559,9 @@ function createReviewRunner(input) {
2399
2559
  throw new Error("Correction execution failed");
2400
2560
  }
2401
2561
  code = await runReview(issueNumber, resolvedIssue);
2562
+ if (code !== 0 && (await loadTaskPlan(tasksPath)).lastError?.category === "review_protocol") {
2563
+ throw new Error("Review returned an invalid result; no correction was scheduled.");
2564
+ }
2402
2565
  }
2403
2566
  if (code !== 0) {
2404
2567
  throw new Error(`Review failed after ${maxCycles} correction cycles`);
@@ -2459,18 +2622,25 @@ function buildInstrumentedPhaseRunners(input) {
2459
2622
  execute: makeRunner(
2460
2623
  () => runExecute(void 0, {
2461
2624
  issue: issueNumber,
2625
+ inPipeline: true,
2462
2626
  commitScope: queueCommitScope,
2463
2627
  ...executeRetry
2464
2628
  }),
2465
2629
  "execute"
2466
2630
  ),
2467
2631
  review: createReviewRunner(input),
2468
- pr: makeRunner(
2469
- // The options argument is omitted outside a queue so a standalone run
2470
- // calls `runPr` exactly as it always did.
2471
- () => finalPr === void 0 ? runPr(issueNumber, resolvedIssue) : runPr(issueNumber, resolvedIssue, { queue: finalPr }),
2472
- "pr"
2473
- )
2632
+ pr: async () => {
2633
+ await makeRunner(
2634
+ // The options argument is omitted outside a queue so a standalone run
2635
+ // calls `runPr` exactly as it always did.
2636
+ () => finalPr === void 0 ? runPr(issueNumber, resolvedIssue) : runPr(issueNumber, resolvedIssue, { queue: finalPr }),
2637
+ "pr"
2638
+ )();
2639
+ const repository = getPlanRepository(tasksPath);
2640
+ if (repository !== void 0 && existsSync(tasksPath)) {
2641
+ await ingestGeneratedPlan(repository);
2642
+ }
2643
+ }
2474
2644
  };
2475
2645
  const reviewBox = { outcome: null };
2476
2646
  if (effectivePrReview) {
@@ -2562,6 +2732,13 @@ async function runPipelinePhases(issueNumber, paths, mode, publisher, input) {
2562
2732
  queue
2563
2733
  } = prepared;
2564
2734
  let { producedBranch, plannedExecutionBranch, branchExistedBeforeExecution } = prepared;
2735
+ const closureChoice = queue ? void 0 : input.runOptions?.closeIssue;
2736
+ try {
2737
+ await persistClosureChoice(tasksPath, closureChoice);
2738
+ } catch (error) {
2739
+ if (error.code !== "ENOENT" && !String(error).includes("No SQLite task plan exists"))
2740
+ throw error;
2741
+ }
2565
2742
  const startResolved = await resolveStartPhase({
2566
2743
  from,
2567
2744
  activePhases,
@@ -2592,7 +2769,8 @@ async function runPipelinePhases(issueNumber, paths, mode, publisher, input) {
2592
2769
  effectivePrReview,
2593
2770
  initialBranch,
2594
2771
  queueCommitScope,
2595
- branchState
2772
+ branchState,
2773
+ closureChoice
2596
2774
  });
2597
2775
  const phaseSuffixes = phaseSuffixesFor(agentSummary);
2598
2776
  const result = await runPipelineWithRenderer({
@@ -2688,8 +2866,10 @@ async function runPipeline(issue, mode, from, noBranch, prReview, options = {})
2688
2866
  }
2689
2867
 
2690
2868
  export {
2869
+ persistClosureChoice,
2870
+ finishIssueClosure,
2691
2871
  publishStorySeed,
2692
2872
  publishIssueDetails,
2693
2873
  runPipeline
2694
2874
  };
2695
- //# sourceMappingURL=chunk-HJBF4WD2.js.map
2875
+ //# sourceMappingURL=chunk-MHA7Q3KU.js.map