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
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  ensureWebMonitor
4
- } from "./chunk-2SUFAE6X.js";
4
+ } from "./chunk-PHPAK2L6.js";
5
+ import {
6
+ groupBy,
7
+ summarize
8
+ } from "./chunk-E2H3JV2E.js";
5
9
  import {
6
10
  applyAcceptanceToPlan,
7
11
  resolveIssueDir,
8
12
  runAcceptanceGate
9
- } from "./chunk-6YQT3SSM.js";
10
- import {
11
- groupBy,
12
- summarize
13
- } from "./chunk-CRGIQFUQ.js";
13
+ } from "./chunk-IQYXXFRC.js";
14
14
  import {
15
15
  EXECUTE_PHASE,
16
16
  elapsedSecondsSince,
@@ -18,35 +18,32 @@ import {
18
18
  publishIterationMetrics,
19
19
  publishStoryMetrics,
20
20
  resolvePolicyPlaceholders
21
- } from "./chunk-HLAPOUEM.js";
21
+ } from "./chunk-WB2FVIUS.js";
22
22
  import {
23
23
  applyPlaceholders,
24
24
  loadPrompt
25
- } from "./chunk-7F7LGMVO.js";
25
+ } from "./chunk-XKR3VD2Z.js";
26
26
  import {
27
27
  invokeSelectedAgent
28
- } from "./chunk-UK4E2FUA.js";
29
- import {
30
- getPackageVersion
31
- } from "./chunk-C5TL7T4V.js";
28
+ } from "./chunk-MQTVMB7W.js";
32
29
  import {
33
30
  archiveFolderName,
34
31
  commitMessage
35
- } from "./chunk-E6KXCV3T.js";
32
+ } from "./chunk-2Q6PG3MT.js";
33
+ import {
34
+ getPackageVersion
35
+ } from "./chunk-2YM2VH6R.js";
36
36
  import {
37
37
  createConfig,
38
38
  getActiveResilienceConfig,
39
39
  getShutdownSignal,
40
- loadGlobalConfig,
41
40
  loadWebConfig,
42
41
  resolveAgentFor,
43
42
  resolvePaths,
44
43
  validateDependencies
45
- } from "./chunk-HY5HLFDU.js";
46
- import {
47
- resolveIssuePaths
48
- } from "./chunk-DV7HUC4Z.js";
44
+ } from "./chunk-UHDXXLYH.js";
49
45
  import {
46
+ MultiPublisher,
50
47
  formatDuration,
51
48
  getIcons,
52
49
  getInactivityTimeout,
@@ -55,33 +52,30 @@ import {
55
52
  getStoryUpdateCallback,
56
53
  getTermWidth,
57
54
  isVerbose,
55
+ loadGlobalConfig,
58
56
  printError,
59
57
  printInfo,
60
58
  printRetry,
61
59
  printSuccess,
62
60
  printWarning,
61
+ resolveIssuePaths,
63
62
  useColor,
64
63
  useUnicode
65
- } from "./chunk-XZUEFTUP.js";
66
- import {
67
- committedStoryIds,
68
- fixedBackoffPolicy,
69
- getBaseBranch,
70
- isWorkingTreeClean,
71
- resolvePolicy,
72
- withRetry
73
- } from "./chunk-YVPZUN6X.js";
64
+ } from "./chunk-J6VJ5M2U.js";
74
65
  import {
66
+ DEFAULT_SESSION_HEARTBEAT_MS,
75
67
  FilePublisher,
68
+ MemoryPublisher,
76
69
  NullPublisher,
77
70
  getSessionPublisher,
78
71
  setSessionPublisher
79
- } from "./chunk-DUS5ZNKL.js";
72
+ } from "./chunk-DIMDAYZS.js";
80
73
  import {
81
74
  allStoriesPass,
82
75
  applyStoryMetrics,
83
76
  clearLastError,
84
77
  divideUsage,
78
+ executionCompletion,
85
79
  formatTokens,
86
80
  hasPendingCorrection,
87
81
  initializeState,
@@ -93,18 +87,39 @@ import {
93
87
  selectActiveStory,
94
88
  setLastError,
95
89
  trimErrorMessage
96
- } from "./chunk-SOM4QA6C.js";
90
+ } from "./chunk-GD7JZMSJ.js";
97
91
  import {
98
- classify
99
- } from "./chunk-XEYH6ZZI.js";
92
+ executionContext,
93
+ inspectTaskPlan
94
+ } from "./chunk-NP47HRX2.js";
95
+ import {
96
+ getLastBranchRepository,
97
+ getPlanRepository,
98
+ ingestAgentPlan,
99
+ loadStoredLastBranch,
100
+ saveSessionEvent,
101
+ saveStoredLastBranch,
102
+ setAgentProjectionWindow,
103
+ touchStoredSession
104
+ } from "./chunk-7MJGYPHF.js";
105
+ import {
106
+ classify,
107
+ committedStoryIds,
108
+ fixedBackoffPolicy,
109
+ getBaseBranch,
110
+ getCurrentBranch,
111
+ isWorkingTreeClean,
112
+ resolvePolicy,
113
+ withRetry
114
+ } from "./chunk-TJVX42KY.js";
100
115
 
101
116
  // src/commands/execute.ts
102
- import { randomUUID } from "crypto";
117
+ import { randomUUID } from "node:crypto";
103
118
 
104
119
  // src/core/engine.ts
105
- import { existsSync } from "fs";
106
- import { cp, mkdir, readFile, writeFile } from "fs/promises";
107
- import { join } from "path";
120
+ import { existsSync } from "node:fs";
121
+ import { cp, mkdir, readFile, writeFile } from "node:fs/promises";
122
+ import { join } from "node:path";
108
123
 
109
124
  // src/ui/progress.ts
110
125
  import chalk from "chalk";
@@ -602,16 +617,17 @@ Started: ${(/* @__PURE__ */ new Date()).toString()}
602
617
  }
603
618
  async function archiveIfBranchChanged(plan, paths) {
604
619
  const { lastBranchFile, archiveDir, prdFile, progressFile } = paths;
605
- if (!existsSync(lastBranchFile)) {
606
- return;
607
- }
608
620
  const currentBranch = plan.branchName ?? "";
609
- let lastBranch = "";
610
- try {
611
- lastBranch = (await readFile(lastBranchFile, "utf-8")).trim();
612
- } catch {
613
- return;
621
+ const repository = getLastBranchRepository(lastBranchFile);
622
+ let lastBranch = repository === void 0 ? null : await loadStoredLastBranch(repository);
623
+ if (lastBranch === null && existsSync(lastBranchFile)) {
624
+ try {
625
+ lastBranch = (await readFile(lastBranchFile, "utf-8")).trim() || null;
626
+ } catch {
627
+ return;
628
+ }
614
629
  }
630
+ if (lastBranch === null) return;
615
631
  if (currentBranch && lastBranch && currentBranch !== lastBranch) {
616
632
  const dateStr = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
617
633
  const folderName = archiveFolderName(lastBranch);
@@ -638,10 +654,26 @@ Started: ${(/* @__PURE__ */ new Date()).toString()}
638
654
  async function trackBranch(plan, lastBranchFile) {
639
655
  const branch = plan.branchName ?? "";
640
656
  if (branch) {
657
+ const repository = getLastBranchRepository(lastBranchFile);
658
+ if (repository !== void 0) {
659
+ await saveStoredLastBranch(repository, branch);
660
+ return;
661
+ }
641
662
  await writeFile(lastBranchFile, `${branch}
642
663
  `, "utf-8");
643
664
  }
644
665
  }
666
+ async function validateExecutionInput(plan) {
667
+ const result = inspectTaskPlan(plan);
668
+ if (!result.ok) return result.errors.map((error) => `${error.code}: ${error.message}`).join("\n");
669
+ if (plan.userStories.length === 0) return "Task plan has no stories";
670
+ if (plan.noBranch === true) {
671
+ const branch = await getCurrentBranch().catch(() => "");
672
+ if (!branch || branch !== plan.branchName)
673
+ return `Current branch must match ${plan.branchName}; refusing to switch in no-branch mode`;
674
+ }
675
+ return null;
676
+ }
645
677
  async function runEngine(config, paths) {
646
678
  if (!existsSync(paths.prdFile)) {
647
679
  printError(`PRD file not found at ${paths.prdFile}`);
@@ -651,11 +683,17 @@ async function runEngine(config, paths) {
651
683
  return 1;
652
684
  }
653
685
  let plan = await loadTaskPlan(paths.prdFile);
686
+ const closure = { closeIssue: plan.closeIssue, issueClosedAt: plan.issueClosedAt };
687
+ const inputError = await validateExecutionInput(plan);
688
+ if (inputError) {
689
+ printError(inputError);
690
+ return 1;
691
+ }
654
692
  plan = initializeState(plan);
655
693
  await saveTaskPlan(paths.prdFile, plan);
656
- if (plan.issueStatus === "completed" && allStoriesPass(plan) && !hasPendingCorrection(plan)) {
694
+ if (plan.issueStatus === "completed" && allStoriesPass(plan) && !hasPendingCorrection(plan) && !plan.lastError) {
657
695
  emitLog(`Issue already marked complete in ${paths.prdFile}`);
658
- return 0;
696
+ return finishWithAcceptance(config, paths, plan);
659
697
  }
660
698
  if (plan.issueStatus === "completed" && !allStoriesPass(plan)) {
661
699
  printWarning(
@@ -669,9 +707,9 @@ async function runEngine(config, paths) {
669
707
  );
670
708
  await saveTaskPlan(paths.prdFile, plan);
671
709
  }
672
- if (allStoriesPass(plan) && !hasPendingCorrection(plan)) {
710
+ if (allStoriesPass(plan) && !hasPendingCorrection(plan) && !plan.lastError) {
673
711
  emitLog("All user stories already pass. Marking issue as completed.");
674
- plan = markIssueCompleted(plan);
712
+ plan = executionCompletion(markIssueCompleted(plan), config.inPipeline === true);
675
713
  await saveTaskPlan(paths.prdFile, plan);
676
714
  return finishWithAcceptance(config, paths, plan);
677
715
  }
@@ -679,7 +717,7 @@ async function runEngine(config, paths) {
679
717
  await trackBranch(plan, paths.lastBranchFile);
680
718
  await ensureProgressFile(paths.progressFile);
681
719
  const promptTemplate = await loadPrompt("execute", { projectRoot: paths.projectRoot });
682
- const policy = await resolvePolicyPlaceholders({ root: paths.projectRoot });
720
+ const policy = await resolvePolicyPlaceholders({ root: paths.projectRoot, phase: "execute" });
683
721
  const signoff = (await loadGlobalConfig()).commit?.signoff === true;
684
722
  const executeAgent = await resolveAgentFor("execute");
685
723
  printStartupHeader(config, plan, {
@@ -701,13 +739,15 @@ async function runEngine(config, paths) {
701
739
  `Adopting ${adopted.join(", ")}: already committed on this branch with a clean tree.`
702
740
  );
703
741
  plan = await loadTaskPlan(paths.prdFile);
704
- if (plan.userStories.every((story) => story.passes) && plan.lastReviewFindings === null) {
742
+ if (plan.userStories.every((story) => story.passes) && plan.lastReviewFindings === null && !plan.lastError) {
705
743
  break;
706
744
  }
707
745
  }
708
746
  const attempted = await withRetry(
709
747
  async () => {
710
748
  plan = await loadTaskPlan(paths.prdFile);
749
+ const inputError2 = await validateExecutionInput(plan);
750
+ if (inputError2) throw new Error(`Invalid task plan: ${inputError2}`);
711
751
  if (plan.userStories.length > 0) {
712
752
  getSessionPublisher().publish({
713
753
  type: "stories:update",
@@ -716,7 +756,8 @@ async function runEngine(config, paths) {
716
756
  });
717
757
  }
718
758
  const storiesBefore = plan.userStories;
719
- const activeStoryId = selectActiveStory(plan.userStories)?.id;
759
+ const lastErrorBefore = plan.lastError;
760
+ const activeStoryId = hasPendingCorrection(plan) ? void 0 : selectActiveStory(plan.userStories)?.id;
720
761
  getSessionPublisher().publish({
721
762
  type: "iteration:start",
722
763
  at: isoNow(),
@@ -728,6 +769,10 @@ async function runEngine(config, paths) {
728
769
  printIterationHeader(i, config.maxIterations, plan.userStories, activeStoryId);
729
770
  }
730
771
  const prompt = applyPlaceholders(promptTemplate, {
772
+ __EXECUTION_CONTEXT__: JSON.stringify(executionContext(plan)),
773
+ __CORRECTION_MODE__: hasPendingCorrection(plan) ? "enabled" : "",
774
+ __ACTIVE_STORY__: activeStoryId ?? "Address pending review findings",
775
+ __EXECUTION_SCOPE__: config.inPipeline ? "This is one pipeline phase: keep issueStatus=in_progress and completedAt=null." : "Standalone execution may mark the issue completed after verification.",
731
776
  __PRD_FILE__: paths.prdFile,
732
777
  __PROGRESS_FILE__: paths.progressFile,
733
778
  ...policy,
@@ -743,17 +788,30 @@ async function runEngine(config, paths) {
743
788
  plan = markIssueInProgress(plan, startedAt);
744
789
  await saveTaskPlan(paths.prdFile, plan);
745
790
  const startedAtMs = Date.now();
746
- const result2 = await executeClaude(prompt, {
747
- ...inactivityOptions(),
748
- iteration: i,
749
- correctionCycle: plan.correctionCycle,
750
- ...activeStoryId === void 0 ? {} : { storyIds: [activeStoryId] }
751
- });
791
+ setAgentProjectionWindow(paths.prdFile, true);
792
+ let result2;
793
+ try {
794
+ result2 = await executeClaude(prompt, {
795
+ ...inactivityOptions(),
796
+ iteration: i,
797
+ correctionCycle: plan.correctionCycle,
798
+ ...activeStoryId === void 0 ? {} : { storyIds: [activeStoryId] }
799
+ });
800
+ } finally {
801
+ setAgentProjectionWindow(paths.prdFile, false);
802
+ }
803
+ const repository = getPlanRepository(paths.prdFile);
804
+ if (repository !== void 0) {
805
+ plan = await ingestAgentPlan(repository, plan);
806
+ } else {
807
+ plan = { ...await loadTaskPlan(paths.prdFile), ...closure };
808
+ await saveTaskPlan(paths.prdFile, plan);
809
+ }
752
810
  const seconds = elapsedSecondsSince(startedAtMs);
753
811
  if (result2.exitCode !== 0) {
754
812
  publishIterationMetrics(i, result2.cost, seconds);
755
813
  }
756
- return { result: result2, startedAt, seconds, storiesBefore };
814
+ return { result: result2, startedAt, seconds, storiesBefore, lastErrorBefore };
757
815
  },
758
816
  {
759
817
  policy: executeRetryPolicy(config),
@@ -831,6 +889,22 @@ async function runEngine(config, paths) {
831
889
  return result.exitCode;
832
890
  }
833
891
  plan = await loadTaskPlan(paths.prdFile);
892
+ const outputError = await validateExecutionInput(plan);
893
+ if (outputError) {
894
+ printError(`Invalid execution result: ${outputError}`);
895
+ return 1;
896
+ }
897
+ if (plan.lastError && (JSON.stringify(plan.lastError) !== JSON.stringify(attempted.value.lastErrorBefore) || ![
898
+ "fatal_claude_failure",
899
+ "transient_claude_failure",
900
+ "invalid_completion_signal",
901
+ "task_execution"
902
+ ].includes(plan.lastError.category))) {
903
+ publishIterationMetrics(i, result.cost, iterationSeconds);
904
+ getSessionPublisher().publish({ type: "iteration:end", at: isoNow(), iteration: i });
905
+ printError(`Execution blocked: ${plan.lastError.message}`);
906
+ return 1;
907
+ }
834
908
  plan = clearLastError(plan, iterationStartedAt);
835
909
  await saveTaskPlan(paths.prdFile, plan);
836
910
  const storyUpdateCb = getStoryUpdateCallback();
@@ -861,7 +935,7 @@ async function runEngine(config, paths) {
861
935
  if (result.output.includes("<promise>COMPLETE</promise>")) {
862
936
  plan = await loadTaskPlan(paths.prdFile);
863
937
  if (allStoriesPass(plan) && !hasPendingCorrection(plan)) {
864
- plan = markIssueCompleted(plan);
938
+ plan = executionCompletion(markIssueCompleted(plan), config.inPipeline === true);
865
939
  await saveTaskPlan(paths.prdFile, plan);
866
940
  const elapsed2 = Math.floor((Date.now() - startTime) / 1e3);
867
941
  printSummaryBox(
@@ -916,9 +990,61 @@ async function finishWithAcceptance(config, paths, plan) {
916
990
  await saveTaskPlan(paths.prdFile, applied.plan);
917
991
  return 1;
918
992
  }
993
+ await saveTaskPlan(
994
+ paths.prdFile,
995
+ executionCompletion(markIssueCompleted(applied.plan), config.inPipeline === true)
996
+ );
919
997
  return 0;
920
998
  }
921
999
 
1000
+ // src/storage/db/session-publisher.ts
1001
+ var SqliteSessionPublisher = class extends MemoryPublisher {
1002
+ context;
1003
+ writeChain = Promise.resolve();
1004
+ heartbeatTimer;
1005
+ closed = false;
1006
+ constructor(context, options = {}) {
1007
+ super(options);
1008
+ this.context = context;
1009
+ this.heartbeatTimer = setInterval(() => this.enqueueHeartbeat(), DEFAULT_SESSION_HEARTBEAT_MS);
1010
+ this.heartbeatTimer.unref();
1011
+ }
1012
+ afterPublish(event) {
1013
+ if (this.closed) return;
1014
+ const sessionId = this.snapshot().sessionId;
1015
+ if (sessionId === null) return;
1016
+ const snapshot = this.snapshot();
1017
+ const sequence = this.version();
1018
+ this.writeChain = this.writeChain.then(async () => {
1019
+ try {
1020
+ await saveSessionEvent(this.context, { sessionId, sequence, event, snapshot });
1021
+ } catch (error) {
1022
+ this.warnOnce(error);
1023
+ }
1024
+ });
1025
+ }
1026
+ async flush() {
1027
+ await this.writeChain;
1028
+ }
1029
+ async close() {
1030
+ this.closed = true;
1031
+ clearInterval(this.heartbeatTimer);
1032
+ await this.flush();
1033
+ }
1034
+ enqueueHeartbeat() {
1035
+ if (this.closed) return;
1036
+ const sessionId = this.snapshot().sessionId;
1037
+ if (sessionId === null || this.snapshot().status !== "running") return;
1038
+ this.writeChain = this.writeChain.then(async () => {
1039
+ try {
1040
+ await touchStoredSession(this.context, sessionId);
1041
+ } catch (error) {
1042
+ this.warnOnce(error);
1043
+ }
1044
+ });
1045
+ }
1046
+ };
1047
+
922
1048
  // src/commands/execute.ts
923
1049
  async function runExecute(positionalMaxIter, options) {
924
1050
  const errors = await validateDependencies();
@@ -932,6 +1058,7 @@ async function runExecute(positionalMaxIter, options) {
932
1058
  const maxIterations = options.maxIterations ?? positionalMaxIter;
933
1059
  const config = createConfig({
934
1060
  issueNumber: options.issue,
1061
+ inPipeline: options.inPipeline,
935
1062
  maxIterations,
936
1063
  retryLimit: options.retryLimit,
937
1064
  retryForever: options.retryForever,
@@ -945,13 +1072,22 @@ async function runExecute(positionalMaxIter, options) {
945
1072
  const issuePaths = await resolveIssuePaths(config.issueNumber, {
946
1073
  projectRoot: paths.projectRoot
947
1074
  });
948
- standalonePublisher = new FilePublisher(issuePaths.sessionFile, {
1075
+ const filePublisher = new FilePublisher(issuePaths.sessionFile, {
949
1076
  logLimit: webConfig.logLimit,
950
1077
  includeLogs: webConfig.includeLogs
951
1078
  });
952
- setSessionPublisher(standalonePublisher);
1079
+ const repository = getPlanRepository(issuePaths.tasksFile);
1080
+ const publisher = repository === void 0 ? filePublisher : new MultiPublisher([
1081
+ new SqliteSessionPublisher(repository, {
1082
+ logLimit: webConfig.logLimit,
1083
+ includeLogs: webConfig.includeLogs
1084
+ }),
1085
+ filePublisher
1086
+ ]);
1087
+ standalonePublisher = publisher;
1088
+ setSessionPublisher(publisher);
953
1089
  const numericIssue2 = /^\d+$/.test(config.issueNumber) ? Number(config.issueNumber) : null;
954
- standalonePublisher.publish({
1090
+ publisher.publish({
955
1091
  type: "session:start",
956
1092
  at: isoNow(),
957
1093
  sessionId: randomUUID(),
@@ -967,10 +1103,10 @@ async function runExecute(positionalMaxIter, options) {
967
1103
  cliVersion: getPackageVersion()
968
1104
  }
969
1105
  });
970
- standalonePublisher.publish({ type: "phase:start", at: isoNow(), phase: "execute" });
1106
+ publisher.publish({ type: "phase:start", at: isoNow(), phase: "execute" });
971
1107
  await ensureWebMonitor(
972
1108
  {
973
- publisher: standalonePublisher,
1109
+ publisher,
974
1110
  port: webConfig.port,
975
1111
  host: webConfig.host,
976
1112
  refreshSeconds: webConfig.refreshSeconds
@@ -1017,6 +1153,7 @@ export {
1017
1153
  printQueueSummary,
1018
1154
  printRunSummary,
1019
1155
  stripMarkdown,
1156
+ SqliteSessionPublisher,
1020
1157
  runExecute
1021
1158
  };
1022
- //# sourceMappingURL=chunk-KZXQWC7U.js.map
1159
+ //# sourceMappingURL=chunk-XHCP6ZNO.js.map