@staff0rd/assist 0.1143.1 → 0.1143.3

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 (606) hide show
  1. package/dist/acceptanceCriteria-CJ4GRITK.js +44 -0
  2. package/dist/activity-2SEJVUW5.js +73 -0
  3. package/dist/add-HXSZYGPR.js +51 -0
  4. package/dist/add-QQQ472AZ.js +250 -0
  5. package/dist/add-XWJN42HG.js +140 -0
  6. package/dist/addActivity-XDHJ7CV5.js +120 -0
  7. package/dist/addPhase-XZO6BH26.js +152 -0
  8. package/dist/addRule-J432LIS3.js +102 -0
  9. package/dist/addUserRule-XO2BNQFH.js +136 -0
  10. package/dist/adviceFragments-5XVE6JXX.js +41 -0
  11. package/dist/advise-YDAJA5NI.js +96 -0
  12. package/dist/analyze-2ECBFV3E.js +63 -0
  13. package/dist/ask-ESCDDQH5.js +47 -0
  14. package/dist/askCheck-WILQF3JN.js +303 -0
  15. package/dist/askDesign-RDIXLTMM.js +137 -0
  16. package/dist/askQuestion-EQV37YPA.js +149 -0
  17. package/dist/associateGithub-VYQUEKWJ.js +95 -0
  18. package/dist/associateJira-EUNZOJJC.js +83 -0
  19. package/dist/backup-3SNDW5JN.js +64 -0
  20. package/dist/blockCodeComments-PZHXN2WG.js +311 -0
  21. package/dist/branch-7NZ5K4AI.js +98 -0
  22. package/dist/browserConsole-6ZRED7DG.js +50 -0
  23. package/dist/browserInspect-2IOKKWOF.js +42 -0
  24. package/dist/browserRun-JJVVNL6H.js +52 -0
  25. package/dist/browserSnapshot-Q3DUNUYP.js +32 -0
  26. package/dist/browserStatus-MEQAEC3K.js +38 -0
  27. package/dist/built-version +1 -1
  28. package/dist/chart-4G75ADCW.js +80 -0
  29. package/dist/check-QRHG4J7G.js +219 -0
  30. package/dist/checkBuildLocks-UBGUSNX5.js +9 -0
  31. package/dist/chunk-2DCOBBPI.js +50 -0
  32. package/dist/chunk-2EW62DM5.js +17 -0
  33. package/dist/chunk-2HT3GIJD.js +130 -0
  34. package/dist/chunk-2JYMVJGZ.js +21 -0
  35. package/dist/chunk-2KG6ZPX4.js +52 -0
  36. package/dist/chunk-2O7TIRCQ.js +39 -0
  37. package/dist/chunk-3E7RVOMC.js +27 -0
  38. package/dist/chunk-3FSX26XC.js +25 -0
  39. package/dist/chunk-3JXMQFUS.js +14 -0
  40. package/dist/chunk-3KLTYFPV.js +57 -0
  41. package/dist/chunk-3NK55YVZ.js +48 -0
  42. package/dist/chunk-3OMKOT6D.js +14 -0
  43. package/dist/chunk-3PM5JCHE.js +72 -0
  44. package/dist/chunk-3QKE2ONF.js +39 -0
  45. package/dist/chunk-3XQHTIHW.js +20 -0
  46. package/dist/chunk-43GYFW24.js +170 -0
  47. package/dist/chunk-46B7OBV4.js +21 -0
  48. package/dist/chunk-4BVUY25U.js +21 -0
  49. package/dist/chunk-4GMAYXOS.js +18 -0
  50. package/dist/chunk-4HKB2TAG.js +11 -0
  51. package/dist/chunk-4JIXM5NT.js +21 -0
  52. package/dist/chunk-4L7TQE67.js +22 -0
  53. package/dist/chunk-4TIDERIW.js +12 -0
  54. package/dist/chunk-4XHBAEMS.js +37 -0
  55. package/dist/chunk-4Y4ADPEK.js +10 -0
  56. package/dist/chunk-4YAIQN3S.js +77 -0
  57. package/dist/chunk-4YHDWC5E.js +33 -0
  58. package/dist/chunk-547VKFOA.js +15 -0
  59. package/dist/chunk-54QTHCXV.js +12 -0
  60. package/dist/chunk-556BOFTS.js +44 -0
  61. package/dist/chunk-5CCCIT5E.js +33 -0
  62. package/dist/chunk-5G5VG5P7.js +14 -0
  63. package/dist/chunk-5JOVEUBS.js +17 -0
  64. package/dist/chunk-5KSIOK73.js +25 -0
  65. package/dist/chunk-5MFQ7T3G.js +40 -0
  66. package/dist/chunk-5PKWV3WT.js +8 -0
  67. package/dist/chunk-5VW2GS73.js +42 -0
  68. package/dist/chunk-5WQDLREX.js +40 -0
  69. package/dist/chunk-66EUBGD6.js +193 -0
  70. package/dist/chunk-6DGPQ67E.js +26 -0
  71. package/dist/chunk-6EYCU3MQ.js +41 -0
  72. package/dist/chunk-6G2ADBNV.js +19 -0
  73. package/dist/chunk-6H4DP3ZG.js +14 -0
  74. package/dist/chunk-6MNOEMDU.js +45 -0
  75. package/dist/chunk-6NDXAN45.js +90 -0
  76. package/dist/chunk-6NXP34PE.js +20 -0
  77. package/dist/chunk-6PF5BEEE.js +37 -0
  78. package/dist/chunk-6SOPR77J.js +12 -0
  79. package/dist/chunk-6T53CG7D.js +56 -0
  80. package/dist/chunk-7CEIET2O.js +31 -0
  81. package/dist/chunk-7DSWCPDZ.js +225 -0
  82. package/dist/chunk-7HNRCA3N.js +12 -0
  83. package/dist/chunk-7MUAIGYQ.js +56 -0
  84. package/dist/chunk-7NPZZRMK.js +77 -0
  85. package/dist/chunk-7O466DJY.js +36 -0
  86. package/dist/chunk-7TT6C4IC.js +100 -0
  87. package/dist/chunk-7ZN4KX7V.js +26 -0
  88. package/dist/chunk-ABLDOQ4B.js +42 -0
  89. package/dist/chunk-ADIYP3KC.js +11 -0
  90. package/dist/chunk-ADLCDG2V.js +61 -0
  91. package/dist/chunk-AKF654AT.js +32 -0
  92. package/dist/chunk-ALAS5LZJ.js +22 -0
  93. package/dist/chunk-ANCYNQJA.js +16 -0
  94. package/dist/chunk-APS7GTRT.js +23 -0
  95. package/dist/chunk-APZ6ZTDA.js +8 -0
  96. package/dist/chunk-AVLELL42.js +34 -0
  97. package/dist/chunk-AWAUWR2H.js +258 -0
  98. package/dist/chunk-B3JSQA5D.js +25 -0
  99. package/dist/chunk-B5ZOANOD.js +51 -0
  100. package/dist/chunk-B6RAZW2L.js +14 -0
  101. package/dist/chunk-B7B26YPF.js +6 -0
  102. package/dist/chunk-BAHQJHYD.js +16 -0
  103. package/dist/chunk-BBXEZVRL.js +38 -0
  104. package/dist/chunk-BFQSGIN6.js +37 -0
  105. package/dist/chunk-BJDGVLYX.js +20 -0
  106. package/dist/chunk-BO5JCCC5.js +17 -0
  107. package/dist/chunk-BV2V6RTH.js +89 -0
  108. package/dist/chunk-BVHK2VVT.js +31 -0
  109. package/dist/chunk-C3MGHR3N.js +25 -0
  110. package/dist/chunk-CDD4ZTG7.js +31 -0
  111. package/dist/chunk-CDU6M5IX.js +50 -0
  112. package/dist/chunk-CGYVYHMM.js +49 -0
  113. package/dist/chunk-CSQLE62N.js +7450 -0
  114. package/dist/chunk-CXJJGUTK.js +44 -0
  115. package/dist/chunk-D7UZLH36.js +8 -0
  116. package/dist/chunk-DBQTGW7F.js +48 -0
  117. package/dist/chunk-DIAC4XYA.js +29 -0
  118. package/dist/chunk-DISNKALJ.js +74 -0
  119. package/dist/chunk-DS2YJZZY.js +34 -0
  120. package/dist/chunk-DZGYHAE7.js +31 -0
  121. package/dist/chunk-E36L7ASL.js +19 -0
  122. package/dist/chunk-E7AZAWIV.js +478 -0
  123. package/dist/chunk-EF7AXKON.js +187 -0
  124. package/dist/chunk-EHRQ6OST.js +53 -0
  125. package/dist/chunk-ENBVLWTC.js +25 -0
  126. package/dist/chunk-ENTJ2N5Y.js +34 -0
  127. package/dist/chunk-ERAGZGT5.js +166 -0
  128. package/dist/chunk-ERG23IG5.js +12 -0
  129. package/dist/chunk-EW2ZM2PC.js +6 -0
  130. package/dist/chunk-EYM57SNL.js +60 -0
  131. package/dist/chunk-F2GXOU5H.js +171 -0
  132. package/dist/chunk-F2LP5MBV.js +26 -0
  133. package/dist/chunk-FFKJYEDJ.js +73 -0
  134. package/dist/chunk-FOPR6LRY.js +121 -0
  135. package/dist/chunk-FPWL4VRC.js +12 -0
  136. package/dist/chunk-FVZP4ULO.js +14 -0
  137. package/dist/chunk-FYYZG4GY.js +47 -0
  138. package/dist/chunk-G3ROBZ4I.js +31 -0
  139. package/dist/chunk-G44QYJ57.js +106 -0
  140. package/dist/chunk-GF4MNBOX.js +95 -0
  141. package/dist/chunk-GL5GKF5A.js +68 -0
  142. package/dist/chunk-GLIYWSW7.js +208 -0
  143. package/dist/chunk-GOGGPW2L.js +143 -0
  144. package/dist/chunk-GQF23TWI.js +14 -0
  145. package/dist/chunk-GQMP5NS4.js +15 -0
  146. package/dist/chunk-GRXFWFGP.js +49 -0
  147. package/dist/chunk-GVI4JSG7.js +13 -0
  148. package/dist/chunk-GVVK5XFZ.js +42 -0
  149. package/dist/chunk-GYAXLTV6.js +37 -0
  150. package/dist/chunk-H6LFISSF.js +40 -0
  151. package/dist/chunk-HCANRBFK.js +19 -0
  152. package/dist/chunk-HHKS3UZB.js +16 -0
  153. package/dist/chunk-HKGCLAZ7.js +8 -0
  154. package/dist/chunk-HN7MFXZ7.js +46 -0
  155. package/dist/chunk-HSWDSL22.js +50 -0
  156. package/dist/chunk-I2ZQXBOS.js +108 -0
  157. package/dist/chunk-I3TEQBTO.js +88 -0
  158. package/dist/chunk-I5MLH7WJ.js +27 -0
  159. package/dist/chunk-IBPSXDUB.js +8 -0
  160. package/dist/chunk-IDFJE5DP.js +224 -0
  161. package/dist/chunk-IEK6CQQH.js +23 -0
  162. package/dist/chunk-IIFOAUOM.js +34 -0
  163. package/dist/chunk-IMKMNPRL.js +114 -0
  164. package/dist/chunk-INBM4BQQ.js +27 -0
  165. package/dist/chunk-IOKBCYSG.js +29 -0
  166. package/dist/chunk-IOYGR6YV.js +23 -0
  167. package/dist/chunk-IRUDR6GR.js +63 -0
  168. package/dist/chunk-IV7Z4UVQ.js +150 -0
  169. package/dist/chunk-IVBWOIGE.js +33 -0
  170. package/dist/chunk-IYTAHYEL.js +98 -0
  171. package/dist/chunk-IZBQH3LW.js +17 -0
  172. package/dist/chunk-J3C454L5.js +741 -0
  173. package/dist/chunk-J3GISX67.js +23 -0
  174. package/dist/chunk-J7XASX4N.js +733 -0
  175. package/dist/chunk-JHBA5IZR.js +20 -0
  176. package/dist/chunk-JHIGA7GN.js +43 -0
  177. package/dist/chunk-JIWFLALZ.js +269 -0
  178. package/dist/chunk-JM57BCD6.js +30 -0
  179. package/dist/chunk-JNCFHWBK.js +30 -0
  180. package/dist/chunk-JNEYUOQ3.js +83 -0
  181. package/dist/chunk-JPM7HCLI.js +23 -0
  182. package/dist/chunk-JPRADR2E.js +10 -0
  183. package/dist/chunk-JRK7JDU4.js +30 -0
  184. package/dist/chunk-JVG5AJA2.js +29 -0
  185. package/dist/chunk-JVTCXR7C.js +72 -0
  186. package/dist/chunk-JW6QOUMN.js +18 -0
  187. package/dist/chunk-K45LIKCT.js +37 -0
  188. package/dist/chunk-K4T24UGW.js +18 -0
  189. package/dist/chunk-K4TQJQWA.js +44 -0
  190. package/dist/chunk-K5LOYASR.js +18 -0
  191. package/dist/chunk-K6NKWRK4.js +30 -0
  192. package/dist/chunk-KD2PWI4Z.js +48 -0
  193. package/dist/chunk-KGFZYUE2.js +54 -0
  194. package/dist/chunk-KLEL6TMJ.js +22 -0
  195. package/dist/chunk-KNXHXMFT.js +77 -0
  196. package/dist/chunk-KP5S3FE5.js +13 -0
  197. package/dist/chunk-KUCVY5R7.js +40 -0
  198. package/dist/chunk-KY77XKAU.js +26 -0
  199. package/dist/chunk-L363MNYZ.js +14 -0
  200. package/dist/chunk-LBAPKP6M.js +473 -0
  201. package/dist/chunk-LBPOEGTS.js +271 -0
  202. package/dist/chunk-LDVATRUW.js +23 -0
  203. package/dist/chunk-LFRSZIAS.js +13 -0
  204. package/dist/chunk-LGMCQUJJ.js +40 -0
  205. package/dist/chunk-LKDW2GWH.js +9 -0
  206. package/dist/chunk-LMHILP5H.js +36 -0
  207. package/dist/chunk-LMUTL44M.js +58 -0
  208. package/dist/chunk-LOP6Y256.js +18 -0
  209. package/dist/chunk-LSBUNT4X.js +32 -0
  210. package/dist/chunk-M3O2BTJG.js +12 -0
  211. package/dist/chunk-M3QEBIQL.js +855 -0
  212. package/dist/chunk-MBPVW7BY.js +63 -0
  213. package/dist/chunk-MELBVXKL.js +36 -0
  214. package/dist/chunk-MJ44T7R4.js +28 -0
  215. package/dist/chunk-MJ4RLQ5N.js +177 -0
  216. package/dist/chunk-MJLABLH5.js +58 -0
  217. package/dist/chunk-MODUPHYS.js +20 -0
  218. package/dist/chunk-MRUIXQXS.js +29 -0
  219. package/dist/chunk-MSKC2RCS.js +17 -0
  220. package/dist/chunk-MY4TNZNI.js +36 -0
  221. package/dist/chunk-N65VOEFI.js +23 -0
  222. package/dist/chunk-N755UYFK.js +58 -0
  223. package/dist/chunk-NBADZOXB.js +24 -0
  224. package/dist/chunk-NGTSPXSJ.js +9 -0
  225. package/dist/chunk-NGYZK6AF.js +18 -0
  226. package/dist/chunk-NH33OKZQ.js +23 -0
  227. package/dist/chunk-NOHNPOQK.js +49 -0
  228. package/dist/chunk-NPQGX4IO.js +16 -0
  229. package/dist/chunk-NWNODYLQ.js +25 -0
  230. package/dist/chunk-NYEGRDOK.js +191 -0
  231. package/dist/chunk-NZYSENRR.js +50 -0
  232. package/dist/chunk-O5JIFWMQ.js +39 -0
  233. package/dist/chunk-O5NYB4W5.js +31 -0
  234. package/dist/chunk-O6GPPB6G.js +26 -0
  235. package/dist/chunk-O6HFT23O.js +39 -0
  236. package/dist/chunk-OBC245PJ.js +39 -0
  237. package/dist/chunk-ODLSWRTS.js +21 -0
  238. package/dist/chunk-OGJ6AZK4.js +9 -0
  239. package/dist/chunk-ONODYZ2H.js +146 -0
  240. package/dist/chunk-ORSRBZ2X.js +15 -0
  241. package/dist/chunk-OU6Q5ZS3.js +16 -0
  242. package/dist/chunk-OUT62LF4.js +111 -0
  243. package/dist/chunk-OZNYQOQK.js +25 -0
  244. package/dist/chunk-P253KAVC.js +75 -0
  245. package/dist/chunk-P26XSDFU.js +91 -0
  246. package/dist/chunk-P3RGVQ5B.js +12 -0
  247. package/dist/chunk-P7FVAGFQ.js +52 -0
  248. package/dist/chunk-PCF66ALO.js +39 -0
  249. package/dist/chunk-PD2BTMEY.js +598 -0
  250. package/dist/chunk-PGQK356A.js +22 -0
  251. package/dist/chunk-PIDKNOD6.js +25 -0
  252. package/dist/chunk-PNOSR4S4.js +152 -0
  253. package/dist/chunk-PRYIRRAS.js +21 -0
  254. package/dist/chunk-PURNABFX.js +22 -0
  255. package/dist/chunk-PXQTFJ2N.js +216 -0
  256. package/dist/chunk-PYACTCZ2.js +13 -0
  257. package/dist/chunk-PZAEU7LL.js +23 -0
  258. package/dist/chunk-Q35724GR.js +51 -0
  259. package/dist/chunk-Q55RN3EG.js +43 -0
  260. package/dist/chunk-Q7RUUXND.js +40 -0
  261. package/dist/chunk-Q7YVMIA3.js +32 -0
  262. package/dist/chunk-QAJUCN3A.js +76 -0
  263. package/dist/chunk-QDQ6A2MZ.js +23 -0
  264. package/dist/chunk-QJRCKXTM.js +38 -0
  265. package/dist/chunk-QKHOYKUQ.js +362 -0
  266. package/dist/chunk-QPRFHNX7.js +24 -0
  267. package/dist/chunk-QR7KY3Y6.js +19 -0
  268. package/dist/chunk-QU6OQZJ2.js +56 -0
  269. package/dist/chunk-QVQ2OJXX.js +144 -0
  270. package/dist/chunk-R2HLLDFE.js +36 -0
  271. package/dist/chunk-R33SW6V2.js +104 -0
  272. package/dist/chunk-R72E45HQ.js +506 -0
  273. package/dist/chunk-RFMBA6WA.js +18 -0
  274. package/dist/chunk-RIMA7EFJ.js +35 -0
  275. package/dist/chunk-RNFWWESE.js +9 -0
  276. package/dist/chunk-ROBNJX4W.js +68 -0
  277. package/dist/chunk-ROCHUNJI.js +36 -0
  278. package/dist/chunk-RPRL6G4R.js +218 -0
  279. package/dist/chunk-RSLB4ODM.js +30 -0
  280. package/dist/chunk-RTYIICCX.js +24 -0
  281. package/dist/chunk-RVABNGZW.js +46 -0
  282. package/dist/chunk-RXKI4XAU.js +21 -0
  283. package/dist/chunk-S3I6PZTN.js +438 -0
  284. package/dist/chunk-S4S2DD5Z.js +16 -0
  285. package/dist/chunk-S4Y7TLRT.js +12 -0
  286. package/dist/chunk-S6FVZYHH.js +16 -0
  287. package/dist/chunk-S6XYTJU2.js +37 -0
  288. package/dist/chunk-SB4BG7PH.js +159 -0
  289. package/dist/chunk-SDMBTSYP.js +15 -0
  290. package/dist/chunk-SDOEWLEE.js +22 -0
  291. package/dist/chunk-SEXIHLGA.js +16 -0
  292. package/dist/chunk-SSKHLBQB.js +15 -0
  293. package/dist/chunk-STUWMYJ3.js +3941 -0
  294. package/dist/chunk-SW7FSLHP.js +26 -0
  295. package/dist/chunk-T2DY3T55.js +10 -0
  296. package/dist/chunk-T4TPIDXO.js +111 -0
  297. package/dist/chunk-T5WE33UZ.js +70 -0
  298. package/dist/chunk-T7ZPGAB5.js +192 -0
  299. package/dist/chunk-TCTX3UXU.js +19 -0
  300. package/dist/chunk-TJGF3Z72.js +12 -0
  301. package/dist/chunk-TK4AJIJZ.js +47 -0
  302. package/dist/chunk-TQCCEWWN.js +89 -0
  303. package/dist/chunk-TUPSNHFZ.js +49 -0
  304. package/dist/chunk-TVQY3HPZ.js +43 -0
  305. package/dist/chunk-TZ5PVDAR.js +48 -0
  306. package/dist/chunk-U732RAGX.js +240 -0
  307. package/dist/chunk-UEWARAPX.js +37 -0
  308. package/dist/chunk-UGGH3MEX.js +26 -0
  309. package/dist/chunk-UJAMN3ML.js +85 -0
  310. package/dist/chunk-UJBW7FVI.js +384 -0
  311. package/dist/chunk-UJX7N737.js +101 -0
  312. package/dist/chunk-UN4ABKA7.js +48 -0
  313. package/dist/chunk-UP6QV5BJ.js +14 -0
  314. package/dist/chunk-US6TNW5V.js +28 -0
  315. package/dist/chunk-USKD27FY.js +11 -0
  316. package/dist/chunk-USVQT2SR.js +94 -0
  317. package/dist/chunk-UU77KEL6.js +20 -0
  318. package/dist/chunk-UYD7R4HL.js +26 -0
  319. package/dist/chunk-VABNWHSE.js +31 -0
  320. package/dist/chunk-VAGZIGNN.js +54 -0
  321. package/dist/chunk-VDE2QVT4.js +14 -0
  322. package/dist/chunk-VDXS55BC.js +62 -0
  323. package/dist/chunk-VEZ3FL5H.js +16 -0
  324. package/dist/chunk-VF2SKQIN.js +79 -0
  325. package/dist/chunk-VNPRH5XZ.js +143 -0
  326. package/dist/chunk-VPMI4LV2.js +25 -0
  327. package/dist/chunk-VQZVG7KJ.js +46 -0
  328. package/dist/chunk-VRQ4WDF7.js +22 -0
  329. package/dist/chunk-W5FPQALS.js +36 -0
  330. package/dist/chunk-W6UBSIJA.js +50 -0
  331. package/dist/chunk-W7TRZLEM.js +23 -0
  332. package/dist/chunk-WDODIKZ4.js +72 -0
  333. package/dist/chunk-WG3TXZMV.js +70 -0
  334. package/dist/chunk-WG4UDKA2.js +12 -0
  335. package/dist/chunk-WGV2ELBS.js +41 -0
  336. package/dist/chunk-WIG7VKXE.js +92 -0
  337. package/dist/chunk-WOGUXGZS.js +32 -0
  338. package/dist/chunk-WUG2UGQC.js +136 -0
  339. package/dist/chunk-WXQ3EA5H.js +12 -0
  340. package/dist/chunk-WYNRHOR7.js +69 -0
  341. package/dist/chunk-WYVUP7Z3.js +33 -0
  342. package/dist/chunk-X44VETJF.js +13 -0
  343. package/dist/chunk-X6ETCS7E.js +656 -0
  344. package/dist/chunk-XA3VSUG6.js +72 -0
  345. package/dist/chunk-XADYGSUA.js +25 -0
  346. package/dist/chunk-XDIVXGPQ.js +73 -0
  347. package/dist/chunk-XEJODD6D.js +6 -0
  348. package/dist/chunk-XGG4NZLE.js +210 -0
  349. package/dist/chunk-XSJGIJEE.js +8 -0
  350. package/dist/chunk-XT3AOF2P.js +16 -0
  351. package/dist/chunk-XTPBXBZA.js +11 -0
  352. package/dist/chunk-XV2STPP6.js +45 -0
  353. package/dist/chunk-XV6BO5MK.js +28 -0
  354. package/dist/chunk-XXXMWMVQ.js +208 -0
  355. package/dist/chunk-XY5OS2GH.js +147 -0
  356. package/dist/chunk-XZFSW5AY.js +217 -0
  357. package/dist/chunk-Y2KEHWBZ.js +35 -0
  358. package/dist/chunk-Y3JV5CEL.js +19 -0
  359. package/dist/chunk-Y3R4C2P7.js +231 -0
  360. package/dist/chunk-Y46IKU4U.js +46 -0
  361. package/dist/chunk-YC3CIJQN.js +22 -0
  362. package/dist/chunk-YDA62L6J.js +147 -0
  363. package/dist/chunk-YIBSK5OC.js +13 -0
  364. package/dist/chunk-YJ72SXVD.js +12 -0
  365. package/dist/chunk-YKVLG4SZ.js +12 -0
  366. package/dist/chunk-YNHPTUHS.js +75 -0
  367. package/dist/chunk-YOFY27RM.js +10 -0
  368. package/dist/chunk-YPQ6OZFB.js +103 -0
  369. package/dist/chunk-YQ3CNWB3.js +54 -0
  370. package/dist/chunk-YS3HSXSJ.js +16 -0
  371. package/dist/chunk-YSNIMCKC.js +8 -0
  372. package/dist/chunk-YTIVOMM3.js +22 -0
  373. package/dist/chunk-YVL3NXEB.js +6 -0
  374. package/dist/chunk-YXXKT6LL.js +513 -0
  375. package/dist/chunk-YZ5KJFYU.js +8 -0
  376. package/dist/chunk-Z2YQQYCQ.js +64 -0
  377. package/dist/chunk-Z64YKE5O.js +208 -0
  378. package/dist/chunk-Z76MGO4R.js +284 -0
  379. package/dist/chunk-ZABRGL2F.js +45 -0
  380. package/dist/chunk-ZAMEG3EN.js +470 -0
  381. package/dist/chunk-ZDSSSQZZ.js +12 -0
  382. package/dist/chunk-ZFX4EZMW.js +20 -0
  383. package/dist/chunk-ZKVDVSCE.js +61 -0
  384. package/dist/chunk-ZLRZR64W.js +36 -0
  385. package/dist/chunk-ZMH7UZNP.js +14 -0
  386. package/dist/chunk-ZO7NYS25.js +18 -0
  387. package/dist/chunk-ZSHH4XS6.js +11 -0
  388. package/dist/chunk-ZWTRFLA6.js +31 -0
  389. package/dist/chunk-ZYE25KR3.js +12 -0
  390. package/dist/chunk-ZYK7V4PG.js +22 -0
  391. package/dist/clean-W43XKMR2.js +49 -0
  392. package/dist/cliHook-QGUENERI.js +96 -0
  393. package/dist/cliHookCheck-VLLUDLZD.js +74 -0
  394. package/dist/cloneRepo-LSIV3K3X.js +80 -0
  395. package/dist/closeSession-I2J2ICU4.js +30 -0
  396. package/dist/codeCommentConfirm-LGYBP6JX.js +69 -0
  397. package/dist/codeCommentSet-2YWQJXI2.js +115 -0
  398. package/dist/codexHook-24HGGAM3.js +200 -0
  399. package/dist/codexHookTrust-YYBCCR7P.js +59 -0
  400. package/dist/commands/sessions/web/bundle.js +257 -257
  401. package/dist/comment-R5MBHRIJ.js +46 -0
  402. package/dist/comment-SAOYKB2J.js +17 -0
  403. package/dist/commentIssue-PDIQVTZM.js +43 -0
  404. package/dist/comments-ABF3S3O5.js +56 -0
  405. package/dist/commit-OWV2KIOD.js +511 -0
  406. package/dist/commits-QFWMYJC5.js +146 -0
  407. package/dist/configGet-42P4ONFD.js +94 -0
  408. package/dist/configImportRepos-ZIUYOKHH.js +142 -0
  409. package/dist/configImportUser-NWUPLRQE.js +177 -0
  410. package/dist/configKeys-HFGEHZBT.js +69 -0
  411. package/dist/configKeys-OGJBDYG6.js +73 -0
  412. package/dist/configList-CBYHO432.js +75 -0
  413. package/dist/configSet-3UHHWKDP.js +136 -0
  414. package/dist/configUnset-LYGRTYB3.js +121 -0
  415. package/dist/configure-ETWPCRNG.js +86 -0
  416. package/dist/coverage-G7J25BUX.js +17 -0
  417. package/dist/createIssue-AIQ3U4LC.js +357 -0
  418. package/dist/cyclomatic-7ZFTN5VN.js +18 -0
  419. package/dist/daemonStatus-YXGIS55D.js +112 -0
  420. package/dist/del-NHH7NU3Y.js +44 -0
  421. package/dist/deleteCommentCmd-SAG7WMDV.js +73 -0
  422. package/dist/denyAdd-YXXNFWMO.js +29 -0
  423. package/dist/denyList-IZVZEOSD.js +43 -0
  424. package/dist/denyRemove-4IUYBEMU.js +30 -0
  425. package/dist/deps-RSUOIZPE.js +117 -0
  426. package/dist/docsConfirm-2LAEAX3R.js +97 -0
  427. package/dist/docsUnlock-SCPIWHT5.js +93 -0
  428. package/dist/doctorNodes-KURLWXJF.js +131 -0
  429. package/dist/done-ZQCDA2OJ.js +92 -0
  430. package/dist/drainDaemon-LCQQ3EP4.js +96 -0
  431. package/dist/dropRetiredTables-JBLALSG5.js +31 -0
  432. package/dist/edit-CFPOK62A.js +133 -0
  433. package/dist/editHook-YPYSRJLU.js +388 -0
  434. package/dist/editIssue-C2G7D3VJ.js +281 -0
  435. package/dist/editIssueComment-5SIYQKI6.js +68 -0
  436. package/dist/exportBacklog-NGFOXXUG.js +24 -0
  437. package/dist/extension-YYRD5EM6.js +32 -0
  438. package/dist/extract-SGYOCBTT.js +688 -0
  439. package/dist/fixConflict-SW33MRTL.js +66 -0
  440. package/dist/fixStructure-4UTN5ED6.js +436 -0
  441. package/dist/fixed-OTDA7M25.js +72 -0
  442. package/dist/forbiddenStrings-GVXIN7QW.js +88 -0
  443. package/dist/formatConfiguredCommands-WI25I2JJ.js +19 -0
  444. package/dist/getBacklogDir-AVGEKM42.js +18 -0
  445. package/dist/halstead-CMFRMXT6.js +18 -0
  446. package/dist/hardcodedColors-4NBF5Z53.js +61 -0
  447. package/dist/harnessFollowUps-PNR55PM4.js +87 -0
  448. package/dist/ignore-7E4ZV5XH.js +30 -0
  449. package/dist/importBacklog-FOGUOAIJ.js +228 -0
  450. package/dist/inSln-G4VRY7VM.js +22 -0
  451. package/dist/index.js +2832 -10
  452. package/dist/indexRules-65H3IE33.js +31 -0
  453. package/dist/init-2WH6WD64.js +9 -0
  454. package/dist/init-6Y2TC67U.js +23 -0
  455. package/dist/init-BELQ3LDU.js +25 -0
  456. package/dist/init-BNY2X74K.js +9 -0
  457. package/dist/init-PZIM2TEG.js +9 -0
  458. package/dist/inspect-OI5K5KSG.js +368 -0
  459. package/dist/jiraAuth-4Z5EVL7A.js +51 -0
  460. package/dist/launchMode-VKS5XM4V.js +85 -0
  461. package/dist/link-JDJBEJCL.js +124 -0
  462. package/dist/link-LYQZULAX.js +59 -0
  463. package/dist/linkNode-IZ7TMIBN.js +88 -0
  464. package/dist/lint-5AA42LMF.js +418 -0
  465. package/dist/list-BM6RD4CP.js +43 -0
  466. package/dist/list-GCJ6WCKC.js +34 -0
  467. package/dist/list-HCOU6YAY.js +28 -0
  468. package/dist/list-OWWW2G36.js +100 -0
  469. package/dist/list-ZR6AEAER.js +33 -0
  470. package/dist/list-ZVSHR4AA.js +113 -0
  471. package/dist/listComments-CTM5UMWI.js +203 -0
  472. package/dist/listModels-2US52LRW.js +74 -0
  473. package/dist/listNodes-HNKK3LEQ.js +54 -0
  474. package/dist/listRules-XBWM5DPH.js +41 -0
  475. package/dist/maintainability-P55FDYZW.js +19 -0
  476. package/dist/merge-MVMNYPO2.js +196 -0
  477. package/dist/mermaidExport-DKB3X763.js +108 -0
  478. package/dist/migrate-XZ562LTJ.js +37 -0
  479. package/dist/migrations-CSVJKLQC.js +206 -0
  480. package/dist/move-XAN7VFR4.js +63 -0
  481. package/dist/movePhase-AK3F6A6P.js +103 -0
  482. package/dist/moveRepo-P7LPCWIL.js +109 -0
  483. package/dist/netcap-FIHYF3LK.js +203 -0
  484. package/dist/netcapExtract-KAFERZ6V.js +462 -0
  485. package/dist/newCli-2HD56JUI.js +132 -0
  486. package/dist/newProject-5UN6N4MS.js +70 -0
  487. package/dist/next-FAAUSQLC.js +145 -0
  488. package/dist/next-XRXA7ZLN.js +83 -0
  489. package/dist/noVenv-DONW2S6P.js +34 -0
  490. package/dist/nodeLogs-NNLS5TNI.js +64 -0
  491. package/dist/notify-NRLRUDFI.js +66 -0
  492. package/dist/permitCliReads-RSRMZMGS.js +313 -0
  493. package/dist/phaseDone-FBAQDO3S.js +99 -0
  494. package/dist/piHook-WWYLIELZ.js +89 -0
  495. package/dist/plan-GBSJWMXP.js +51 -0
  496. package/dist/postSlackMessage-SJQGYGJQ.js +21 -0
  497. package/dist/posted-ZNKIE73Q.js +76 -0
  498. package/dist/printComments-7ROHUEPO.js +169 -0
  499. package/dist/printExtensionUrl-IW2WTSNS.js +19 -0
  500. package/dist/prompts-SL6SHWOA.js +55 -0
  501. package/dist/propose-PYAPK2PU.js +307 -0
  502. package/dist/prs-2SRUKVTI.js +138 -0
  503. package/dist/prsSlackChannel-DY35HNQF.js +28 -0
  504. package/dist/prsStatus-6G3ZTK36.js +319 -0
  505. package/dist/pullIfConfigured-V2H6IFDQ.js +18 -0
  506. package/dist/raise-OBGNVBLZ.js +330 -0
  507. package/dist/raiseHelpText-6TECFMWR.js +148 -0
  508. package/dist/ravendbAuth-53OAERB3.js +147 -0
  509. package/dist/ravendbCollections-2NZYZR5P.js +35 -0
  510. package/dist/ravendbQuery-EY2XGKEK.js +89 -0
  511. package/dist/ravendbSetConnection-U7X27AIP.js +16 -0
  512. package/dist/readBodyArgument-NZG3GJMF.js +7 -0
  513. package/dist/readTime-23CA6JVM.js +168 -0
  514. package/dist/recordSlack-TZH2THZH.js +60 -0
  515. package/dist/redirect-G7WS7LDE.js +32 -0
  516. package/dist/refine-NAJUWIFV.js +87 -0
  517. package/dist/refreshDocs-A5S2NQ5Z.js +65 -0
  518. package/dist/releasesConfigure-JA7QNAJF.js +211 -0
  519. package/dist/releasesList-EETLBTD2.js +39 -0
  520. package/dist/remove-CSUOZRGT.js +96 -0
  521. package/dist/remove-VIGXH42Y.js +43 -0
  522. package/dist/removePhase-S4WFO6PT.js +62 -0
  523. package/dist/rename-PM5VQUCY.js +96 -0
  524. package/dist/renameSession-IQ6RHQUJ.js +30 -0
  525. package/dist/renameSymbol-OOIIGF3B.js +78 -0
  526. package/dist/reply-4VV4LEYF.js +65 -0
  527. package/dist/reportCliError-6UDOLAIT.js +42 -0
  528. package/dist/repos-JP75ZTBU.js +130 -0
  529. package/dist/resolveHarness-A3F7CDF2.js +17 -0
  530. package/dist/resolveModel-GHXLN2T4.js +27 -0
  531. package/dist/restartDaemon-YSKQMKEQ.js +9 -0
  532. package/dist/restartNode-GAM4QS3V.js +59 -0
  533. package/dist/restructure-FJ3BME7E.js +760 -0
  534. package/dist/review-IXQ67Q2I.js +3870 -0
  535. package/dist/reviewPrComments-YELGPQIH.js +80 -0
  536. package/dist/rewindPhase-RKEURCE5.js +82 -0
  537. package/dist/run-JEUQGX5U.js +78 -0
  538. package/dist/run-KI7FYVOY.js +178 -0
  539. package/dist/runDaemon-WNUM5HUG.js +9292 -0
  540. package/dist/runExtract-IUEUT2IK.js +568 -0
  541. package/dist/runRefine-DWJATWCB.js +99 -0
  542. package/dist/runScope-LCAGTKGG.js +39 -0
  543. package/dist/scan-VM2LYP6W.js +74 -0
  544. package/dist/scheduleBackup-3UZQU67U.js +200 -0
  545. package/dist/schemaConfirm-WZCBGM7A.js +171 -0
  546. package/dist/schemaUnlock-JKXSG6BI.js +135 -0
  547. package/dist/screenshot-ARSOZ2M6.js +182 -0
  548. package/dist/search-HLB25O4S.js +79 -0
  549. package/dist/seqAuth-6IPD5OPG.js +50 -0
  550. package/dist/seqQuery-HL6H4PMX.js +233 -0
  551. package/dist/seqSetConnection-IUCGBTON.js +30 -0
  552. package/dist/sessionOutput-NXHUXIKC.js +92 -0
  553. package/dist/setSessionStatus-HPHBUHVB.js +12 -0
  554. package/dist/setStatusCommand-WBRJ4BTB.js +61 -0
  555. package/dist/show-65RGZKWW.js +327 -0
  556. package/dist/show-SPEIA7AL.js +186 -0
  557. package/dist/showClaudeCodeIcon-E4SAM3GN.js +12 -0
  558. package/dist/showCodexIcon-YUAKV4NI.js +11 -0
  559. package/dist/signExtension-VF34F7UR.js +182 -0
  560. package/dist/simulateDivergence-VB4UL4UR.js +27 -0
  561. package/dist/skip-ZZHUH3MU.js +76 -0
  562. package/dist/slack-74LWSKRK.js +221 -0
  563. package/dist/sloc-KPIIBOMR.js +18 -0
  564. package/dist/sqlAuth-IN4PYCIX.js +59 -0
  565. package/dist/sqlColumns-SNPMTHHK.js +50 -0
  566. package/dist/sqlMutate-4QC4IT4E.js +43 -0
  567. package/dist/sqlQuery-OAXPQJPY.js +53 -0
  568. package/dist/sqlSetConnection-UAX7TRB4.js +30 -0
  569. package/dist/sqlTables-ZM2PUJ7N.js +39 -0
  570. package/dist/star-2GG4JB3K.js +46 -0
  571. package/dist/start-BUUHD4ZQ.js +44 -0
  572. package/dist/startIssue-JSVKGZZR.js +135 -0
  573. package/dist/status-63OT6MGQ.js +38 -0
  574. package/dist/{chunk-W7ZLVOL6.js → statusLine-TK2QPCQO.js} +9 -4
  575. package/dist/stop-HG3UZOI6.js +52 -0
  576. package/dist/stopClaudeCodeIcon-P4AVHUOL.js +12 -0
  577. package/dist/stopCodexIcon-7O6D2SEH.js +11 -0
  578. package/dist/stopDaemon-XIYQ6SAW.js +8 -0
  579. package/dist/sync-HAAAJ4LC.js +826 -0
  580. package/dist/testflightAdd-MBJAAJGR.js +37 -0
  581. package/dist/unassignIssue-OXNUC2QQ.js +37 -0
  582. package/dist/unlink-TLLWWJIG.js +71 -0
  583. package/dist/unlinkNode-O7IZD5BN.js +41 -0
  584. package/dist/unstar-EEKVLJQI.js +46 -0
  585. package/dist/update-6NKPYHDT.js +72 -0
  586. package/dist/update-E72CS3ZO.js +160 -0
  587. package/dist/updateNode-4IYWN3MS.js +99 -0
  588. package/dist/updatePhase-USTBTRW4.js +163 -0
  589. package/dist/updatePlan-RV77RV4J.js +315 -0
  590. package/dist/version-4E3HWTDD.js +47 -0
  591. package/dist/viewIssue-CYHIPCFO.js +36 -0
  592. package/dist/watchLoop-MV7DVGC6.js +30 -0
  593. package/dist/watchReport-A4W7UOAJ.js +23 -0
  594. package/dist/watchWait-FF65XUH2.js +538 -0
  595. package/dist/web-3X54NV64.js +178 -0
  596. package/dist/web-XW33SYEX.js +169 -0
  597. package/dist/withPool-APJFDKR2.js +18 -0
  598. package/dist/wontdo-KOV5YLR6.js +52 -0
  599. package/dist/wontfix-UZTOERNG.js +79 -0
  600. package/dist/write-PH5YX6V5.js +132 -0
  601. package/dist/writeSignal-NGH5I4AX.js +8 -0
  602. package/package.json +1 -1
  603. package/dist/chunk-MYJJAJB7.js +0 -113
  604. package/dist/runCli-OSXLT6CQ.js +0 -65704
  605. package/dist/runStatusLine-6VBMFNUZ.js +0 -17
  606. package/dist/statusLine-PWO6JAR2.js +0 -7
@@ -0,0 +1,3870 @@
1
+ import {
2
+ countReadingWords
3
+ } from "./chunk-O6HFT23O.js";
4
+ import {
5
+ parseRepoScopeFlag,
6
+ writeConfigKeys
7
+ } from "./chunk-VF2SKQIN.js";
8
+ import {
9
+ fetchThreadIds
10
+ } from "./chunk-S6XYTJU2.js";
11
+ import {
12
+ comment
13
+ } from "./chunk-KNXHXMFT.js";
14
+ import {
15
+ parsePrBody
16
+ } from "./chunk-ENTJ2N5Y.js";
17
+ import {
18
+ announcePr
19
+ } from "./chunk-YTIVOMM3.js";
20
+ import "./chunk-SDOEWLEE.js";
21
+ import {
22
+ checkoutPr
23
+ } from "./chunk-NYEGRDOK.js";
24
+ import "./chunk-ZAMEG3EN.js";
25
+ import "./chunk-ERAGZGT5.js";
26
+ import "./chunk-RSLB4ODM.js";
27
+ import "./chunk-UN4ABKA7.js";
28
+ import "./chunk-XT3AOF2P.js";
29
+ import {
30
+ runGhGraphql
31
+ } from "./chunk-ZLRZR64W.js";
32
+ import {
33
+ promptInput
34
+ } from "./chunk-RFMBA6WA.js";
35
+ import {
36
+ findCurrentPrNumber,
37
+ getCurrentPrNodeId,
38
+ getCurrentPrNumber,
39
+ getRepoInfo,
40
+ isGhNotInstalled
41
+ } from "./chunk-2HT3GIJD.js";
42
+ import {
43
+ coerceCliConfigValue
44
+ } from "./chunk-6MNOEMDU.js";
45
+ import {
46
+ exitWithConfigErrors
47
+ } from "./chunk-JPRADR2E.js";
48
+ import "./chunk-HKGCLAZ7.js";
49
+ import "./chunk-C3MGHR3N.js";
50
+ import "./chunk-B3JSQA5D.js";
51
+ import {
52
+ awaitHarness
53
+ } from "./chunk-ZYK7V4PG.js";
54
+ import {
55
+ preassignedId
56
+ } from "./chunk-PYACTCZ2.js";
57
+ import {
58
+ emitActivity
59
+ } from "./chunk-4YAIQN3S.js";
60
+ import {
61
+ launchBlocker
62
+ } from "./chunk-NWNODYLQ.js";
63
+ import {
64
+ OneShotUnavailableError,
65
+ resolveOneShotHarness,
66
+ runOneShotPrompt
67
+ } from "./chunk-Q55RN3EG.js";
68
+ import {
69
+ setSessionStatus
70
+ } from "./chunk-UJAMN3ML.js";
71
+ import {
72
+ startChainedSession
73
+ } from "./chunk-YS3HSXSJ.js";
74
+ import {
75
+ awaitPreviewApproval
76
+ } from "./chunk-RPRL6G4R.js";
77
+ import "./chunk-BAHQJHYD.js";
78
+ import {
79
+ isAgentHarness
80
+ } from "./chunk-6SOPR77J.js";
81
+ import "./chunk-NGYZK6AF.js";
82
+ import {
83
+ configEntryLayers,
84
+ ghFailure
85
+ } from "./chunk-ZABRGL2F.js";
86
+ import {
87
+ stripAnsi
88
+ } from "./chunk-YJ72SXVD.js";
89
+ import "./chunk-PGQK356A.js";
90
+ import "./chunk-FYYZG4GY.js";
91
+ import "./chunk-WYNRHOR7.js";
92
+ import "./chunk-PIDKNOD6.js";
93
+ import {
94
+ readRawConfigLayers
95
+ } from "./chunk-INBM4BQQ.js";
96
+ import "./chunk-P3RGVQ5B.js";
97
+ import {
98
+ runGhOrThrow
99
+ } from "./chunk-JHBA5IZR.js";
100
+ import "./chunk-ZFX4EZMW.js";
101
+ import "./chunk-IV7Z4UVQ.js";
102
+ import "./chunk-OU6Q5ZS3.js";
103
+ import "./chunk-Q35724GR.js";
104
+ import "./chunk-VPMI4LV2.js";
105
+ import "./chunk-BBXEZVRL.js";
106
+ import "./chunk-7CEIET2O.js";
107
+ import "./chunk-YOFY27RM.js";
108
+ import "./chunk-7TT6C4IC.js";
109
+ import "./chunk-B5ZOANOD.js";
110
+ import "./chunk-3XQHTIHW.js";
111
+ import "./chunk-HSWDSL22.js";
112
+ import "./chunk-MBPVW7BY.js";
113
+ import "./chunk-YNHPTUHS.js";
114
+ import "./chunk-XZFSW5AY.js";
115
+ import "./chunk-QAJUCN3A.js";
116
+ import "./chunk-NOHNPOQK.js";
117
+ import {
118
+ requestAssistSession
119
+ } from "./chunk-YC3CIJQN.js";
120
+ import "./chunk-2DCOBBPI.js";
121
+ import "./chunk-DISNKALJ.js";
122
+ import "./chunk-4GMAYXOS.js";
123
+ import "./chunk-2EW62DM5.js";
124
+ import {
125
+ getDb,
126
+ jobRuns
127
+ } from "./chunk-PD2BTMEY.js";
128
+ import "./chunk-3QKE2ONF.js";
129
+ import "./chunk-O5JIFWMQ.js";
130
+ import "./chunk-LMUTL44M.js";
131
+ import "./chunk-6NDXAN45.js";
132
+ import "./chunk-LKDW2GWH.js";
133
+ import {
134
+ formatUnavailable,
135
+ resolveFeature
136
+ } from "./chunk-MELBVXKL.js";
137
+ import "./chunk-OGJ6AZK4.js";
138
+ import {
139
+ harnessAdapter,
140
+ printReviewerFailure,
141
+ resolveCodexModel,
142
+ reviewerLabel
143
+ } from "./chunk-STUWMYJ3.js";
144
+ import "./chunk-MRUIXQXS.js";
145
+ import "./chunk-66EUBGD6.js";
146
+ import "./chunk-DIAC4XYA.js";
147
+ import "./chunk-UU77KEL6.js";
148
+ import "./chunk-W7TRZLEM.js";
149
+ import "./chunk-P26XSDFU.js";
150
+ import {
151
+ harnessLabel
152
+ } from "./chunk-K6NKWRK4.js";
153
+ import "./chunk-BFQSGIN6.js";
154
+ import "./chunk-D7UZLH36.js";
155
+ import "./chunk-EW2ZM2PC.js";
156
+ import "./chunk-QKHOYKUQ.js";
157
+ import {
158
+ highLevelGlobsFeature,
159
+ highLevelReviewFeature,
160
+ reviewApplyFeature,
161
+ reviewBacklogFeature,
162
+ reviewCheckoutFeature,
163
+ reviewRefineFeature,
164
+ reviewSynthesisFeature,
165
+ reviewerFeature
166
+ } from "./chunk-XA3VSUG6.js";
167
+ import {
168
+ addressCommentsChainFeature
169
+ } from "./chunk-GVVK5XFZ.js";
170
+ import "./chunk-XDIVXGPQ.js";
171
+ import {
172
+ loadConfig
173
+ } from "./chunk-KGFZYUE2.js";
174
+ import "./chunk-LBAPKP6M.js";
175
+ import "./chunk-GRXFWFGP.js";
176
+ import "./chunk-TVQY3HPZ.js";
177
+ import {
178
+ getStoreDir
179
+ } from "./chunk-CGYVYHMM.js";
180
+ import {
181
+ findRepoRoot
182
+ } from "./chunk-WXQ3EA5H.js";
183
+ import "./chunk-YXXKT6LL.js";
184
+ import "./chunk-USKD27FY.js";
185
+ import "./chunk-HN7MFXZ7.js";
186
+ import {
187
+ defaultCriticalPaths
188
+ } from "./chunk-DZGYHAE7.js";
189
+ import "./chunk-UGGH3MEX.js";
190
+ import "./chunk-IEK6CQQH.js";
191
+ import {
192
+ promptConfirm
193
+ } from "./chunk-6DGPQ67E.js";
194
+ import {
195
+ exitOnCancel
196
+ } from "./chunk-SSKHLBQB.js";
197
+
198
+ // src/commands/review/checkoutPrSession.ts
199
+ async function checkoutPrSession(number, { harness, skill } = {}) {
200
+ await checkoutPr(number);
201
+ const adapter = harnessAdapter(harness);
202
+ const conversationId = preassignedId(adapter);
203
+ emitActivity({
204
+ kind: "command",
205
+ name: "review",
206
+ ...adapter.activityIdentity(conversationId)
207
+ });
208
+ const options = { conversationId, cwd: process.cwd(), allowEdits: true };
209
+ const { done } = skill ? adapter.launchSkill(skill.name, skill.args, options) : adapter.launchPrompt("", options);
210
+ await awaitHarness(done, `PR #${number}`, adapter.label);
211
+ }
212
+
213
+ // src/commands/review/highLevel/configureHighLevelReview.ts
214
+ import chalk4 from "chalk";
215
+
216
+ // src/commands/config/promptConfigScope.ts
217
+ import Enquirer from "enquirer";
218
+ var prompts = Enquirer;
219
+ async function promptConfigScope() {
220
+ const answer = await exitOnCancel(
221
+ new prompts.Select({
222
+ name: "scope",
223
+ message: "Where should these values be written?",
224
+ choices: [
225
+ {
226
+ name: "repo",
227
+ message: "repo (db): this repo's override in the shared db \u2014 personal, seen by every node, as 'config set --repo' writes it"
228
+ },
229
+ {
230
+ name: "project",
231
+ message: "repo (git): assist.yml in this repo \u2014 checked in, shared with the team"
232
+ }
233
+ ]
234
+ }).run()
235
+ );
236
+ return answer === "project" ? "project" : "repo";
237
+ }
238
+
239
+ // src/commands/config/resolveConfigKeyAnswer.ts
240
+ import chalk from "chalk";
241
+ async function resolveConfigKeyAnswer(question, supplied) {
242
+ if (supplied !== void 0) return coerceSupplied(question.key, supplied);
243
+ for (; ; ) {
244
+ const answer = (await promptInput(question.key, question.question, question.suggest)).trim();
245
+ if (answer === "") return void 0;
246
+ const coercion = coerceCliConfigValue(question.key, answer);
247
+ if (coercion.ok) return coercion.value;
248
+ console.error(chalk.red(coercion.error));
249
+ }
250
+ }
251
+ function coerceSupplied(key, supplied) {
252
+ if (supplied.trim() === "") return void 0;
253
+ const coercion = coerceCliConfigValue(key, supplied.trim());
254
+ if (!coercion.ok) exitWithConfigErrors([coercion.error]);
255
+ return coercion.value;
256
+ }
257
+
258
+ // src/commands/config/configureConfigKeys.ts
259
+ async function configureConfigKeys(questions, options = {}) {
260
+ const scope = options.scope ?? await promptConfigScope();
261
+ const written = [];
262
+ const skipped = [];
263
+ for (const question of questions) {
264
+ const value = await resolveConfigKeyAnswer(
265
+ question,
266
+ options.answers?.[question.key]
267
+ );
268
+ if (value === void 0) skipped.push(question.key);
269
+ else written.push({ key: question.key, value });
270
+ }
271
+ const result = await writeConfigKeys(written, scope, options.cwd);
272
+ if (!result.ok) exitWithConfigErrors(result.errors);
273
+ return { scope, target: result.target, written, skipped };
274
+ }
275
+
276
+ // src/commands/config/isConfigKeySet.ts
277
+ function isConfigKeySet(key, cwd = process.cwd()) {
278
+ const layers = configEntryLayers(key, readRawConfigLayers(cwd), void 0);
279
+ return Object.keys(layers).length > 0;
280
+ }
281
+
282
+ // src/commands/review/highLevel/highLevelConfigKeys.ts
283
+ var highLevelConfigKeys = {
284
+ criticalPaths: "review.highLevel.criticalPaths",
285
+ uiPaths: "review.highLevel.uiPaths",
286
+ descriptionWordCap: "review.highLevel.descriptionWordCap",
287
+ collapsedPaths: "review.highLevel.collapsedPaths"
288
+ };
289
+
290
+ // src/commands/review/highLevel/buildHighLevelQuestions.ts
291
+ function buildHighLevelQuestions(current, proposed) {
292
+ return [
293
+ {
294
+ key: highLevelConfigKeys.criticalPaths,
295
+ question: "Critical paths \u2014 comma-separated globs whose full diffs the review shows (blank to leave unset)",
296
+ suggest: suggestCriticalPaths(
297
+ current.criticalPaths,
298
+ proposed.criticalPaths
299
+ )
300
+ },
301
+ {
302
+ key: highLevelConfigKeys.uiPaths,
303
+ question: "UI paths \u2014 comma-separated globs that make a change a UI change, so a screenshot or video is required (blank to leave unset)",
304
+ suggest: suggestGlobs(current.uiPaths, proposed.uiPaths)
305
+ },
306
+ {
307
+ key: highLevelConfigKeys.descriptionWordCap,
308
+ question: "Description word cap (blank to leave unset)",
309
+ suggest: String(current.descriptionWordCap)
310
+ },
311
+ {
312
+ key: highLevelConfigKeys.collapsedPaths,
313
+ question: "Collapsed paths \u2014 comma-separated globs whose files start collapsed in the changed-files tree (blank to leave unset)",
314
+ suggest: suggestGlobs(current.collapsedPaths, [])
315
+ }
316
+ ];
317
+ }
318
+ function suggestCriticalPaths(current, proposed) {
319
+ if (current) return suggestGlobs(current, []);
320
+ return [.../* @__PURE__ */ new Set([...defaultCriticalPaths, ...proposed])].join(",");
321
+ }
322
+ function suggestGlobs(current, proposed) {
323
+ const globs = current.length > 0 ? current : proposed;
324
+ return globs.length > 0 ? globs.join(",") : void 0;
325
+ }
326
+
327
+ // src/commands/review/highLevel/parseConfigureAnswers.ts
328
+ import chalk2 from "chalk";
329
+ function parseConfigureAnswers(answers) {
330
+ const known = Object.values(highLevelConfigKeys);
331
+ const parsed = {};
332
+ for (const answer of answers) {
333
+ const separator = answer.indexOf("=");
334
+ if (separator <= 0) exitWith(`--answer expects key=value, got '${answer}'`);
335
+ const key = answer.slice(0, separator).trim();
336
+ if (!known.includes(key))
337
+ exitWith(`--answer key '${key}' is not one of ${known.join(", ")}`);
338
+ parsed[key] = answer.slice(separator + 1);
339
+ }
340
+ return parsed;
341
+ }
342
+ function answersCoverEveryKey(answers) {
343
+ return Object.values(highLevelConfigKeys).every((key) => key in answers);
344
+ }
345
+ function exitWith(message) {
346
+ console.error(chalk2.red(`Error: ${message}.`));
347
+ process.exit(1);
348
+ }
349
+
350
+ // src/commands/review/highLevel/proposeHighLevelGlobs.ts
351
+ import chalk3 from "chalk";
352
+
353
+ // src/commands/review/highLevel/buildGlobProposalPrompt.ts
354
+ function buildGlobProposalPrompt(tree) {
355
+ return [
356
+ "You are proposing configuration for a high-level PR review checklist in a repository.",
357
+ "",
358
+ "criticalPaths: globs matching files where a wrong line is expensive and an LLM reviewer cannot judge it \u2014 schema and API definitions, translation catalogues, database migrations, infrastructure and deployment definitions, dependency and permission manifests. Their full diffs are shown to the human reviewer, so keep the set small.",
359
+ `These criticalPaths defaults are already included, so propose only this repository's own additions and never repeat them: ${defaultCriticalPaths.join(", ")}`,
360
+ "uiPaths: globs matching the files that render the user interface, so that touching one requires a screenshot or video on the PR. Exclude tests and stories.",
361
+ "",
362
+ "Below is every tracked directory in this repository with the extensions of the files in it. Propose globs that match this repository's own files \u2014 never generic guesses at files it does not have.",
363
+ "",
364
+ tree,
365
+ "",
366
+ 'Reply with JSON only, no prose and no code fence: {"criticalPaths": ["..."], "uiPaths": ["..."]}. Use an empty array where nothing fits. At most 8 globs each.'
367
+ ].join("\n");
368
+ }
369
+
370
+ // src/commands/review/highLevel/parseProposedGlobs.ts
371
+ var MAX_GLOBS = 8;
372
+ function parseProposedGlobs(output) {
373
+ const parsed = parseJsonObject(output);
374
+ return {
375
+ criticalPaths: readGlobs(parsed?.criticalPaths),
376
+ uiPaths: readGlobs(parsed?.uiPaths)
377
+ };
378
+ }
379
+ function parseJsonObject(output) {
380
+ const start = output.indexOf("{");
381
+ const end = output.lastIndexOf("}");
382
+ if (start === -1 || end <= start) return void 0;
383
+ try {
384
+ const parsed = JSON.parse(output.slice(start, end + 1));
385
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
386
+ return void 0;
387
+ return parsed;
388
+ } catch {
389
+ return void 0;
390
+ }
391
+ }
392
+ function readGlobs(value) {
393
+ if (!Array.isArray(value)) return [];
394
+ const globs = value.filter((item) => typeof item === "string").map((item) => item.trim()).filter((item) => item !== "");
395
+ return [...new Set(globs)].slice(0, MAX_GLOBS);
396
+ }
397
+
398
+ // src/commands/review/highLevel/summariseRepoTree.ts
399
+ import { execFileSync } from "child_process";
400
+ import { dirname, extname } from "path";
401
+ var MAX_DIRECTORIES = 200;
402
+ var MAX_EXTENSIONS_PER_DIRECTORY = 6;
403
+ function summariseRepoTree(cwd = process.cwd()) {
404
+ const directories = countByDirectory(listTrackedFiles(cwd));
405
+ return [...directories.entries()].map(([directory, extensions]) => ({
406
+ directory,
407
+ extensions: [...extensions.entries()].sort((a, b) => b[1] - a[1]),
408
+ total: [...extensions.values()].reduce((sum3, count) => sum3 + count, 0)
409
+ })).sort((a, b) => b.total - a.total || a.directory.localeCompare(b.directory)).slice(0, MAX_DIRECTORIES).map(
410
+ (entry) => `${entry.directory} \u2014 ${entry.total} files: ${formatExtensions(entry.extensions)}`
411
+ ).join("\n");
412
+ }
413
+ function listTrackedFiles(cwd) {
414
+ try {
415
+ return execFileSync("git", ["ls-files"], {
416
+ cwd,
417
+ encoding: "utf8",
418
+ maxBuffer: 64 * 1024 * 1024
419
+ }).split("\n").filter((line) => line !== "");
420
+ } catch {
421
+ return [];
422
+ }
423
+ }
424
+ function countByDirectory(files) {
425
+ const directories = /* @__PURE__ */ new Map();
426
+ for (const file of files) {
427
+ const directory = dirname(file) === "." ? "(repo root)" : dirname(file);
428
+ const extensions = directories.get(directory) ?? /* @__PURE__ */ new Map();
429
+ const extension = extname(file) === "" ? "(no extension)" : extname(file);
430
+ extensions.set(extension, (extensions.get(extension) ?? 0) + 1);
431
+ directories.set(directory, extensions);
432
+ }
433
+ return directories;
434
+ }
435
+ function formatExtensions(extensions) {
436
+ return extensions.slice(0, MAX_EXTENSIONS_PER_DIRECTORY).map(([extension, count]) => `${extension}(${count})`).join(", ");
437
+ }
438
+
439
+ // src/commands/review/highLevel/proposeHighLevelGlobs.ts
440
+ var NOTHING_PROPOSED = { criticalPaths: [], uiPaths: [] };
441
+ async function proposeHighLevelGlobs(cwd = process.cwd()) {
442
+ const tree = summariseRepoTree(cwd);
443
+ if (tree === "") return NOTHING_PROPOSED;
444
+ const harness = resolveOneShotHarness();
445
+ const label = harnessLabel(harness);
446
+ console.log(
447
+ chalk3.dim(`Asking ${label} to propose globs from the repo's own tree...`)
448
+ );
449
+ try {
450
+ const output = await runOneShotPrompt(
451
+ buildGlobProposalPrompt(tree),
452
+ highLevelGlobsFeature,
453
+ { harness, timeout: 12e4, effort: "medium", cwd }
454
+ );
455
+ return parseProposedGlobs(output);
456
+ } catch (error) {
457
+ if (error instanceof OneShotUnavailableError)
458
+ console.log(chalk3.yellow(error.message));
459
+ console.log(
460
+ chalk3.yellow(
461
+ `${label} proposed nothing; answer each key from its current value.`
462
+ )
463
+ );
464
+ return NOTHING_PROPOSED;
465
+ }
466
+ }
467
+
468
+ // src/commands/review/highLevel/resolveHighLevelConfig.ts
469
+ var DEFAULT_DESCRIPTION_WORD_CAP = 300;
470
+ var DEFAULT_TEST_PATHS = ["**/*.{test,spec}.{ts,tsx,js,jsx}"];
471
+ var DEFAULT_COLLAPSED_PATHS = ["**/*.test.*", "**/generated/**"];
472
+ function resolveHighLevelConfig(config) {
473
+ const highLevel = config.review?.highLevel;
474
+ return {
475
+ criticalPaths: highLevel?.criticalPaths ?? defaultCriticalPaths,
476
+ uiPaths: highLevel?.uiPaths ?? [],
477
+ descriptionWordCap: highLevel?.descriptionWordCap ?? DEFAULT_DESCRIPTION_WORD_CAP,
478
+ testPaths: highLevel?.testPaths ?? DEFAULT_TEST_PATHS,
479
+ collapsedPaths: highLevel?.collapsedPaths ?? DEFAULT_COLLAPSED_PATHS
480
+ };
481
+ }
482
+
483
+ // src/commands/review/highLevel/configureHighLevelReview.ts
484
+ var NOTHING_PROPOSED2 = { criticalPaths: [], uiPaths: [] };
485
+ async function configureHighLevelReview(options = {}) {
486
+ const answers = parseConfigureAnswers(options.answer ?? []);
487
+ const proposed = answersCoverEveryKey(answers) ? NOTHING_PROPOSED2 : await proposeHighLevelGlobs();
488
+ const current = resolveHighLevelConfig(loadConfig());
489
+ const questions = buildHighLevelQuestions(
490
+ {
491
+ ...current,
492
+ criticalPaths: isConfigKeySet(highLevelConfigKeys.criticalPaths) ? current.criticalPaths : void 0
493
+ },
494
+ proposed
495
+ );
496
+ const scope = parseRepoScopeFlag(options.scope);
497
+ reportConfigured(
498
+ await configureConfigKeys(questions, {
499
+ answers,
500
+ ...scope ? { scope } : {}
501
+ })
502
+ );
503
+ }
504
+ function reportConfigured(result) {
505
+ for (const write of result.written)
506
+ console.log(
507
+ chalk4.green(`Set ${write.key} = ${JSON.stringify(write.value)}`)
508
+ );
509
+ for (const key of result.skipped) console.log(chalk4.dim(`Left ${key} unset`));
510
+ console.log(chalk4.dim(`Written to ${result.target}`));
511
+ }
512
+
513
+ // src/commands/review/highLevel/announceSavedReview.ts
514
+ import chalk5 from "chalk";
515
+ function savedMessage(subject) {
516
+ const head = subject.headSha.slice(0, 7);
517
+ if (subject.draft)
518
+ return `Reopening the review left open for ${head} at ${subject.draft.savedAt}; pass --force to start fresh.`;
519
+ if (subject.saved)
520
+ return `Reopening the review saved for ${head} at ${subject.saved.reviewedAt} (${subject.saved.verdict}); pass --force to start fresh.`;
521
+ return void 0;
522
+ }
523
+ function announceSavedReview(subject, force) {
524
+ const message = savedMessage(subject);
525
+ if (message) console.log(chalk5.dim(message));
526
+ else if (force)
527
+ console.log(
528
+ chalk5.dim(
529
+ `Discarding any review saved for ${subject.headSha.slice(0, 7)} and starting fresh (--force).`
530
+ )
531
+ );
532
+ }
533
+
534
+ // src/commands/review/highLevel/groupFilesByDirectory.ts
535
+ var emptyDirectoryGroup = () => ({
536
+ dirs: /* @__PURE__ */ new Map(),
537
+ files: []
538
+ });
539
+ function place(root, file) {
540
+ const segments = file.path.split("/").filter(Boolean);
541
+ segments.pop();
542
+ let at = root;
543
+ for (const segment of segments) {
544
+ const next = at.dirs.get(segment) ?? emptyDirectoryGroup();
545
+ at.dirs.set(segment, next);
546
+ at = next;
547
+ }
548
+ at.files.push(file);
549
+ }
550
+ function groupFilesByDirectory(files) {
551
+ const root = emptyDirectoryGroup();
552
+ for (const file of files) place(root, file);
553
+ return root;
554
+ }
555
+
556
+ // src/commands/review/highLevel/buildHighLevelTree.ts
557
+ function basename(path) {
558
+ return path.slice(path.lastIndexOf("/") + 1);
559
+ }
560
+ function sum(nodes, key) {
561
+ return nodes.reduce((total, node) => total + node[key], 0);
562
+ }
563
+ function byName(a, b) {
564
+ return a.name.localeCompare(b.name);
565
+ }
566
+ function nodesOf(at, prefix) {
567
+ const dirs = [...at.dirs].map(
568
+ ([name2, child]) => collapsedDirNode(name2, child, prefix)
569
+ );
570
+ const files = at.files.map((file) => ({
571
+ kind: "file",
572
+ name: basename(file.path),
573
+ ...file
574
+ }));
575
+ return [...dirs.sort(byName), ...files.sort(byName)];
576
+ }
577
+ function collapsedDirNode(name2, at, prefix) {
578
+ let label = name2;
579
+ let path = prefix ? `${prefix}/${name2}` : name2;
580
+ let node = at;
581
+ while (node.files.length === 0 && node.dirs.size === 1) {
582
+ const [childName, child] = [...node.dirs][0];
583
+ label = `${label}/${childName}`;
584
+ path = `${path}/${childName}`;
585
+ node = child;
586
+ }
587
+ const children = nodesOf(node, path);
588
+ return {
589
+ kind: "dir",
590
+ name: label,
591
+ path,
592
+ additions: sum(children, "additions"),
593
+ deletions: sum(children, "deletions"),
594
+ children
595
+ };
596
+ }
597
+ function buildHighLevelTree(files) {
598
+ return nodesOf(groupFilesByDirectory(files), "");
599
+ }
600
+
601
+ // src/commands/review/highLevel/buildHighLevelStructure.ts
602
+ function sum2(files, key) {
603
+ return files.reduce((total, file) => total + file[key], 0);
604
+ }
605
+ function countOf(files, status) {
606
+ return files.filter((file) => file.status === status).length;
607
+ }
608
+ function buildHighLevelStructure(files) {
609
+ return {
610
+ tree: buildHighLevelTree(files),
611
+ added: countOf(files, "added"),
612
+ removed: countOf(files, "removed"),
613
+ modified: countOf(files, "modified"),
614
+ additions: sum2(files, "additions"),
615
+ deletions: sum2(files, "deletions")
616
+ };
617
+ }
618
+
619
+ // src/commands/review/highLevel/capHighLevelPatches.ts
620
+ import { minimatch } from "minimatch";
621
+
622
+ // src/commands/review/highLevel/hunksOf.ts
623
+ function hunksOf(patch2) {
624
+ const hunks = [];
625
+ for (const line of patch2.split("\n")) {
626
+ const last = hunks[hunks.length - 1];
627
+ if (line.startsWith("@@") || last === void 0) hunks.push(line);
628
+ else hunks[hunks.length - 1] = `${last}
629
+ ${line}`;
630
+ }
631
+ return hunks;
632
+ }
633
+
634
+ // src/commands/review/highLevel/capPatchToBudget.ts
635
+ function capPatchToBudget(patch2, budget) {
636
+ const kept = [];
637
+ let lines = 0;
638
+ for (const hunk of hunksOf(patch2)) {
639
+ const size = hunk.split("\n").length;
640
+ if (lines + size > budget)
641
+ return {
642
+ ...kept.length > 0 ? { patch: kept.join("\n") } : {},
643
+ truncated: true
644
+ };
645
+ kept.push(hunk);
646
+ lines += size;
647
+ }
648
+ return { patch: patch2, truncated: false };
649
+ }
650
+
651
+ // src/commands/review/highLevel/capHighLevelPatches.ts
652
+ var MAX_FILE_PATCH_LINES = 1500;
653
+ var MAX_TOTAL_PATCH_LINES = 2e4;
654
+ function criticalFirst(files, criticalPaths) {
655
+ const isCritical = (file) => criticalPaths.some((glob) => minimatch(file.path, glob));
656
+ return [...files].sort(
657
+ (a, b) => Number(isCritical(b)) - Number(isCritical(a))
658
+ );
659
+ }
660
+ function capped(file, budget) {
661
+ if (file.patch === void 0) return file;
662
+ const { patch: patch2, truncated } = capPatchToBudget(file.patch, budget);
663
+ const { patch: _dropped, ...rest } = file;
664
+ return {
665
+ ...rest,
666
+ ...patch2 === void 0 ? {} : { patch: patch2 },
667
+ ...truncated ? { truncated: true } : {}
668
+ };
669
+ }
670
+ function capHighLevelPatches(files, criticalPaths) {
671
+ let remaining = MAX_TOTAL_PATCH_LINES;
672
+ const byPath = /* @__PURE__ */ new Map();
673
+ for (const file of criticalFirst(files, criticalPaths)) {
674
+ const result = capped(file, Math.min(MAX_FILE_PATCH_LINES, remaining));
675
+ remaining -= result.patch?.split("\n").length ?? 0;
676
+ byPath.set(file.path, result);
677
+ }
678
+ return files.map((file) => byPath.get(file.path) ?? file);
679
+ }
680
+
681
+ // src/commands/review/highLevel/checkDescriptionLinksIssue.ts
682
+ var ISSUE_URL_PATTERN = /https?:\/\/github\.com\/[\w.-]+\/[\w.-]+\/issues\/\d+/g;
683
+ var CROSS_REPO_PATTERN = /\b[\w.-]+\/[\w.-]+#\d+/g;
684
+ var SAME_REPO_PATTERN = /(?<![\w/#-])#\d+\b/g;
685
+ function firstMatch(body, pattern) {
686
+ return body.match(pattern)?.[0] ?? null;
687
+ }
688
+ function checkDescriptionLinksIssue(body, linkedIssues) {
689
+ if (linkedIssues[0])
690
+ return {
691
+ status: "pass",
692
+ reason: `Development-linked to ${linkedIssues[0]}`
693
+ };
694
+ const reference = firstMatch(body, ISSUE_URL_PATTERN) ?? firstMatch(body, CROSS_REPO_PATTERN) ?? firstMatch(body, SAME_REPO_PATTERN);
695
+ if (!reference)
696
+ return {
697
+ status: "fail",
698
+ reason: "no GitHub issue reference (`#123`, `owner/repo#123`, or an issue URL) in the description and no Development-linked issue"
699
+ };
700
+ return { status: "pass", reason: `links ${reference}` };
701
+ }
702
+
703
+ // src/commands/review/highLevel/checkDescriptionSections.ts
704
+ function sectionContent(body, heading) {
705
+ const section = parsePrBody(body).find(
706
+ (candidate) => candidate.heading.trim().toLowerCase() === heading
707
+ );
708
+ return section ? section.content.trim() : null;
709
+ }
710
+ function describe(heading, content) {
711
+ if (content === null) return `no \`## ${heading}\` section`;
712
+ if (content === "") return `\`## ${heading}\` is empty`;
713
+ return null;
714
+ }
715
+ function checkDescriptionSections(body) {
716
+ const problems = [
717
+ describe("What", sectionContent(body, "what")),
718
+ describe("Why", sectionContent(body, "why"))
719
+ ].filter((problem) => problem !== null);
720
+ if (problems.length > 0)
721
+ return { status: "fail", reason: problems.join("; ") };
722
+ const how = sectionContent(body, "how");
723
+ const optional = how ? ", plus an optional `## How`" : "";
724
+ return {
725
+ status: "pass",
726
+ reason: `\`## What\` and \`## Why\` are both present${optional}`
727
+ };
728
+ }
729
+
730
+ // src/commands/review/highLevel/checkDescriptionWordCap.ts
731
+ function checkDescriptionWordCap(body, cap) {
732
+ const { prose, code } = countReadingWords(body);
733
+ const words = prose + code;
734
+ if (words > cap)
735
+ return {
736
+ status: "fail",
737
+ reason: `${words} words, ${words - cap} over the ${cap}-word cap`
738
+ };
739
+ return { status: "pass", reason: `${words} of ${cap} words` };
740
+ }
741
+
742
+ // src/commands/review/highLevel/checkNoMergeConflicts.ts
743
+ function checkNoMergeConflicts(mergeable, baseRef) {
744
+ if (mergeable === "MERGEABLE")
745
+ return { status: "pass", reason: `merges cleanly into ${baseRef}` };
746
+ if (mergeable === "CONFLICTING")
747
+ return {
748
+ status: "fail",
749
+ reason: `branch has merge conflicts with ${baseRef}`
750
+ };
751
+ return {
752
+ status: "fail",
753
+ reason: `GitHub could not determine whether the branch merges cleanly into ${baseRef}`
754
+ };
755
+ }
756
+
757
+ // src/commands/review/highLevel/checkUiEvidence.ts
758
+ import { minimatch as minimatch2 } from "minimatch";
759
+ var EVIDENCE_PATTERNS = [
760
+ /!\[[^\]]*\]\([^)]+\)/g,
761
+ /<(?:img|video)\b[^>]*>/gi,
762
+ /https?:\/\/github\.com\/user-attachments\/assets\/\S+/g,
763
+ /https?:\/\/\S+\.(?:png|jpe?g|gif|webp|avif|svg|mp4|mov|webm)\b/gi
764
+ ];
765
+ function countEvidence(body) {
766
+ return EVIDENCE_PATTERNS.reduce(
767
+ (total, pattern) => total + (body.match(pattern)?.length ?? 0),
768
+ 0
769
+ );
770
+ }
771
+ function plural(count, noun) {
772
+ return `${count} ${noun}${count === 1 ? "" : "s"}`;
773
+ }
774
+ function checkUiEvidence(body, changedFiles, uiPaths) {
775
+ if (uiPaths.length === 0)
776
+ return {
777
+ status: "pass",
778
+ reason: "review.highLevel.uiPaths is unset, so no UI evidence is required"
779
+ };
780
+ const touched = changedFiles.filter(
781
+ (file) => uiPaths.some((glob) => minimatch2(file, glob))
782
+ );
783
+ if (touched.length === 0)
784
+ return {
785
+ status: "pass",
786
+ reason: "no changed file matches review.highLevel.uiPaths"
787
+ };
788
+ const evidence = countEvidence(body);
789
+ if (evidence === 0)
790
+ return {
791
+ status: "fail",
792
+ reason: `${plural(touched.length, "UI file")} changed (${touched[0]}) but no screenshot or video in the description`
793
+ };
794
+ const shown = evidence === 1 ? "1 screenshot or video" : `${evidence} screenshots or videos`;
795
+ return {
796
+ status: "pass",
797
+ reason: `${shown} for ${plural(touched.length, "changed UI file")}`
798
+ };
799
+ }
800
+
801
+ // src/commands/review/highLevel/highLevelChecklist.ts
802
+ var highLevelChecklist = [
803
+ {
804
+ id: "description-what-why",
805
+ kind: "deterministic",
806
+ title: "Description has a What and a Why",
807
+ backing: "The PR body's `## What` and `## Why` sections"
808
+ },
809
+ {
810
+ id: "description-word-cap",
811
+ kind: "deterministic",
812
+ title: "Description is under the word cap",
813
+ backing: "The PR body's word count against review.highLevel.descriptionWordCap"
814
+ },
815
+ {
816
+ id: "description-links-issue",
817
+ kind: "deterministic",
818
+ title: "PR links the GitHub issue it resolves",
819
+ backing: "A Development-linked issue or a GitHub issue reference in the PR body"
820
+ },
821
+ {
822
+ id: "ui-evidence",
823
+ kind: "deterministic",
824
+ title: "UI changes are evidenced by a screenshot or video",
825
+ backing: "Images and videos in the PR body, when a changed file matches review.highLevel.uiPaths"
826
+ },
827
+ {
828
+ id: "no-merge-conflicts",
829
+ kind: "deterministic",
830
+ title: "No merge conflicts",
831
+ backing: "GitHub's mergeable state for the PR against its base branch"
832
+ },
833
+ {
834
+ id: "structure-sensible",
835
+ kind: "manual",
836
+ title: "The structure of the change is sensible",
837
+ short: "Structure",
838
+ backing: "The changed-file tree with add/delete/modify counts and per-file GitHub diff links"
839
+ },
840
+ {
841
+ id: "critical-diffs-correct",
842
+ kind: "manual",
843
+ title: "The critical-file diffs are correct",
844
+ short: "Critical diffs",
845
+ backing: "Full diffs of files matching review.highLevel.criticalPaths"
846
+ },
847
+ {
848
+ id: "tests-worth-having",
849
+ kind: "manual",
850
+ title: "The tests are worth having",
851
+ short: "Tests",
852
+ backing: "The describe/it hierarchy of changed tests in files matching review.highLevel.testPaths"
853
+ },
854
+ {
855
+ id: "manual-testing",
856
+ kind: "manual",
857
+ title: "The change can be exercised by hand",
858
+ short: "Manual testing",
859
+ backing: "Setup and numbered action \u2192 expected steps written by the slicing agent"
860
+ },
861
+ {
862
+ id: "backend-pr-linked",
863
+ kind: "manual",
864
+ title: "The backend PR is linked, if the change needs backend work",
865
+ short: "Backend PR",
866
+ backing: "The PR body"
867
+ }
868
+ ];
869
+
870
+ // src/commands/review/highLevel/evaluateHighLevelChecks.ts
871
+ var evaluators = {
872
+ "description-what-why": (subject) => checkDescriptionSections(subject.body),
873
+ "description-word-cap": (subject) => checkDescriptionWordCap(subject.body, subject.config.descriptionWordCap),
874
+ "description-links-issue": (subject) => checkDescriptionLinksIssue(subject.body, subject.linkedIssues),
875
+ "ui-evidence": (subject) => checkUiEvidence(subject.body, subject.changedFiles, subject.config.uiPaths),
876
+ "no-merge-conflicts": (subject) => checkNoMergeConflicts(subject.mergeable, subject.baseRef)
877
+ };
878
+ function evaluateHighLevelChecks(subject) {
879
+ const checks = subject.sliced ? highLevelChecklist : highLevelChecklist.filter((check) => check.id !== "manual-testing");
880
+ return checks.map((check) => {
881
+ if (check.kind === "manual")
882
+ return { ...check, status: "manual", reason: check.backing };
883
+ return { ...check, ...evaluators[check.id](subject) };
884
+ });
885
+ }
886
+
887
+ // src/commands/review/highLevel/fetchHighLevelFiles.ts
888
+ import { execFileSync as execFileSync2 } from "child_process";
889
+ import { createHash } from "crypto";
890
+ var JQ = ".[] | {filename,status,additions,deletions,patch} | @json";
891
+ function toStatus(status) {
892
+ if (status === "added") return "added";
893
+ if (status === "removed") return "removed";
894
+ return "modified";
895
+ }
896
+ function diffUrl(repo, prNumber, path) {
897
+ const anchor = createHash("sha256").update(path).digest("hex");
898
+ return `https://github.com/${repo}/pull/${prNumber}/files#diff-${anchor}`;
899
+ }
900
+ function fetchHighLevelFiles(prNumber, repo) {
901
+ const out = execFileSync2(
902
+ "gh",
903
+ ["api", `repos/${repo}/pulls/${prNumber}/files`, "--paginate", "--jq", JQ],
904
+ { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }
905
+ );
906
+ return out.trim().split("\n").filter(Boolean).map((line) => {
907
+ const file = JSON.parse(line);
908
+ return {
909
+ path: file.filename,
910
+ status: toStatus(file.status),
911
+ additions: file.additions,
912
+ deletions: file.deletions,
913
+ diffUrl: diffUrl(repo, prNumber, file.filename),
914
+ ...file.patch ? { patch: file.patch } : {}
915
+ };
916
+ });
917
+ }
918
+
919
+ // src/commands/review/highLevel/fetchHighLevelPr.ts
920
+ import { execSync } from "child_process";
921
+
922
+ // src/commands/review/highLevel/waitForMergeable.ts
923
+ var MAX_ATTEMPTS = 5;
924
+ var DELAY_MS = 2e3;
925
+ function sleepSync(ms) {
926
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
927
+ }
928
+ function waitForMergeable(initial, refetch, delayMs = DELAY_MS) {
929
+ let mergeable = initial;
930
+ for (let attempt = 1; mergeable === "UNKNOWN" && attempt < MAX_ATTEMPTS; attempt++) {
931
+ sleepSync(delayMs);
932
+ mergeable = refetch();
933
+ }
934
+ return mergeable;
935
+ }
936
+
937
+ // src/commands/review/highLevel/fetchHighLevelPr.ts
938
+ function ghPrView(prNumber, repo, fields) {
939
+ const raw = execSync(
940
+ `gh pr view ${prNumber} --json ${fields} -R ${repo.org}/${repo.repo}`,
941
+ { encoding: "utf8" }
942
+ );
943
+ return JSON.parse(raw);
944
+ }
945
+ function fetchHighLevelPr(prNumber, repo) {
946
+ const pr = ghPrView(
947
+ prNumber,
948
+ repo,
949
+ "title,body,headRefName,headRefOid,baseRefName,mergeable,closingIssuesReferences"
950
+ );
951
+ return {
952
+ title: pr.title ?? "",
953
+ body: pr.body ?? "",
954
+ headRef: pr.headRefName,
955
+ headSha: pr.headRefOid,
956
+ baseRef: pr.baseRefName,
957
+ mergeable: waitForMergeable(
958
+ pr.mergeable,
959
+ () => ghPrView(prNumber, repo, "mergeable").mergeable
960
+ ),
961
+ linkedIssues: pr.closingIssuesReferences.map(
962
+ (issue) => `${issue.repository.owner.login}/${issue.repository.name}#${issue.number}`
963
+ )
964
+ };
965
+ }
966
+
967
+ // src/commands/review/highLevel/gatherHighLevelSlices.ts
968
+ import { readFileSync as readFileSync2 } from "fs";
969
+
970
+ // src/commands/review/highLevel/formatSlicingRequest.ts
971
+ var RULES = [
972
+ "Each slice is one behaviour end to end: the code, wiring, config, tests and docs that deliver it, so a reviewer can judge whether that behaviour is right.",
973
+ "Never split one behaviour by layer or file type: its command, workflow, generated output, tests and docs stay in one slice.",
974
+ "Split only where the PR does independent things a reviewer could accept or reject separately. Most PRs need one to three slices.",
975
+ "A refactor or move with no behaviour change gets its own slice.",
976
+ "A hunk may appear in more than one slice.",
977
+ "Generated files such as lockfiles get their own slice unless they belong with a specific change.",
978
+ "List slices in reading order."
979
+ ];
980
+ var MANUAL_TESTING_RULES = [
981
+ "Write PR-wide steps for only what needs a human: looking at a UI, clicking through a page, judging how something reads or looks, or acting in a system an agent cannot drive.",
982
+ "Leave out anything an agent could run and check itself: CLI commands with checkable output, test runs, builds, lint, API or HTTP calls, reading files.",
983
+ "When nothing in the PR needs a human, write `steps: []` and `setup: []`.",
984
+ "`setup` lists what the reviewer must do first: branches to check out, servers or daemons to restart, config to set, data to seed. Keep each entry short.",
985
+ "Each step's `action` says exactly what to open and do: the URL or page and what to click or enter.",
986
+ "Each step's `expect` says what the reviewer should see when the change works.",
987
+ "Name repo files by their path from the repo root, and give URLs in full."
988
+ ];
989
+ var EXAMPLE = {
990
+ slices: [
991
+ {
992
+ title: "Short imperative title",
993
+ summary: "One or two sentences on what the slice changes.",
994
+ hunks: ["path/to/file.ts#0"]
995
+ }
996
+ ],
997
+ manualTesting: {
998
+ setup: ["Restart the web server"],
999
+ steps: [
1000
+ {
1001
+ action: "Open http://localhost:3000/settings",
1002
+ expect: "The new toggle shows under Display"
1003
+ }
1004
+ ]
1005
+ }
1006
+ };
1007
+ function formatSlicingRequest(hunks) {
1008
+ return [
1009
+ "Slicing required: this PR must be split into slices before the review opens.",
1010
+ "",
1011
+ "Write the slices and the manual testing steps as JSON to a scratch file, then re-run this command with the same arguments plus `--slices <file>`:",
1012
+ "",
1013
+ JSON.stringify(EXAMPLE, null, 2),
1014
+ "",
1015
+ 'Refer to hunks by the `path#index` labels below. Unknown refs are dropped, and every hunk no slice claims goes into an "Everything else" slice.',
1016
+ "",
1017
+ "Slicing rules:",
1018
+ ...RULES.map((rule) => `- ${rule}`),
1019
+ "",
1020
+ "Manual testing rules:",
1021
+ ...MANUAL_TESTING_RULES.map((rule) => `- ${rule}`),
1022
+ "",
1023
+ `Hunks (${hunks.length}):`,
1024
+ ...hunks.flatMap((hunk) => ["", `### ${hunk.ref}`, hunk.text])
1025
+ ].join("\n");
1026
+ }
1027
+
1028
+ // src/commands/review/highLevel/highLevelReviewPath.ts
1029
+ import { join } from "path";
1030
+ function slug(value) {
1031
+ return value.replace(/[^\w.-]+/g, "-");
1032
+ }
1033
+ function highLevelReviewPath(repo, headRef, headSha) {
1034
+ return join(
1035
+ getStoreDir(),
1036
+ "high-level-reviews",
1037
+ slug(repo),
1038
+ `${slug(headRef)}-${headSha}.json`
1039
+ );
1040
+ }
1041
+
1042
+ // src/commands/review/highLevel/highLevelSlicesPath.ts
1043
+ function highLevelSlicesPath(repo, headRef, headSha) {
1044
+ return highLevelReviewPath(repo, headRef, headSha).replace(
1045
+ /\.json$/,
1046
+ ".slices.json"
1047
+ );
1048
+ }
1049
+
1050
+ // src/commands/review/highLevel/countHunkLines.ts
1051
+ function countHunkLines(text, prefix) {
1052
+ return text.split("\n").filter((line) => line.startsWith(prefix)).length;
1053
+ }
1054
+
1055
+ // src/commands/review/highLevel/hunkTextsOf.ts
1056
+ function hunkTextsOf(patch2) {
1057
+ return hunksOf(patch2 ?? "").filter((text) => text.startsWith("@@"));
1058
+ }
1059
+
1060
+ // src/commands/review/highLevel/listHighLevelHunks.ts
1061
+ function hunksOfFile(file) {
1062
+ const texts = hunkTextsOf(file.patch);
1063
+ if (texts.length === 0)
1064
+ return [
1065
+ {
1066
+ ref: `${file.path}#0`,
1067
+ path: file.path,
1068
+ text: `(no patch shown: binary, too large or over the review budget; ${file.status}, +${file.additions} \u2212${file.deletions})`,
1069
+ additions: file.additions,
1070
+ deletions: file.deletions
1071
+ }
1072
+ ];
1073
+ return texts.map((text, index) => ({
1074
+ ref: `${file.path}#${index}`,
1075
+ path: file.path,
1076
+ text,
1077
+ additions: countHunkLines(text, "+"),
1078
+ deletions: countHunkLines(text, "-")
1079
+ }));
1080
+ }
1081
+ function listHighLevelHunks(files) {
1082
+ return files.flatMap(hunksOfFile);
1083
+ }
1084
+
1085
+ // src/commands/review/highLevel/readJsonFile.ts
1086
+ import { existsSync, readFileSync } from "fs";
1087
+ function readJsonFile(path) {
1088
+ if (!existsSync(path)) return void 0;
1089
+ try {
1090
+ return JSON.parse(readFileSync(path, "utf8"));
1091
+ } catch {
1092
+ return void 0;
1093
+ }
1094
+ }
1095
+
1096
+ // src/commands/review/highLevel/parseHighLevelSlicesInput.ts
1097
+ import { z } from "zod";
1098
+ var slicesSchema = z.array(
1099
+ z.object({
1100
+ title: z.string().min(1),
1101
+ summary: z.string(),
1102
+ hunks: z.array(z.string())
1103
+ })
1104
+ );
1105
+ var manualTestingSchema = z.object({
1106
+ setup: z.array(z.string()),
1107
+ steps: z.array(z.object({ action: z.string(), expect: z.string() }))
1108
+ });
1109
+ var slicesInputSchema = z.union([
1110
+ slicesSchema.transform((slices) => ({ slices })),
1111
+ z.object({ slices: slicesSchema, manualTesting: manualTestingSchema })
1112
+ ]);
1113
+ function parseHighLevelSlicesInput(raw) {
1114
+ const parsed = slicesInputSchema.safeParse(raw);
1115
+ if (!parsed.success)
1116
+ throw new Error(
1117
+ `slices must be a JSON array of {title, summary, hunks[]}, or {slices: [...], manualTesting: {setup[], steps[{action, expect}]}}: ${parsed.error.message}`
1118
+ );
1119
+ return parsed.data;
1120
+ }
1121
+
1122
+ // src/commands/review/highLevel/sliceTotals.ts
1123
+ function sliceTotals(refs, byRef) {
1124
+ let additions = 0;
1125
+ let deletions = 0;
1126
+ for (const ref of refs) {
1127
+ const hunk = byRef.get(ref);
1128
+ additions += hunk?.additions ?? 0;
1129
+ deletions += hunk?.deletions ?? 0;
1130
+ }
1131
+ return { additions, deletions };
1132
+ }
1133
+
1134
+ // src/commands/review/highLevel/resolveHighLevelSlices.ts
1135
+ function knownRefs(input, byRef, warnings) {
1136
+ return [...new Set(input.hunks)].filter((ref) => {
1137
+ if (byRef.has(ref)) return true;
1138
+ warnings.push(`Dropped unknown hunk ${ref} from "${input.title}".`);
1139
+ return false;
1140
+ });
1141
+ }
1142
+ function resolveHighLevelSlices(raw, hunks) {
1143
+ const byRef = new Map(hunks.map((hunk) => [hunk.ref, hunk]));
1144
+ const claimed = /* @__PURE__ */ new Set();
1145
+ const warnings = [];
1146
+ const slices = [];
1147
+ const add = (title, summary, refs) => slices.push({ title, summary, hunks: refs, ...sliceTotals(refs, byRef) });
1148
+ const { slices: inputs, manualTesting } = parseHighLevelSlicesInput(raw);
1149
+ for (const input of inputs) {
1150
+ const known = knownRefs(input, byRef, warnings);
1151
+ if (known.length === 0)
1152
+ warnings.push(`Dropped slice "${input.title}": it has no known hunks.`);
1153
+ else add(input.title, input.summary, known);
1154
+ for (const ref of known) claimed.add(ref);
1155
+ }
1156
+ const rest = [...byRef.keys()].filter((ref) => !claimed.has(ref));
1157
+ if (rest.length > 0)
1158
+ slices.push({
1159
+ title: "Everything else",
1160
+ summary: "Hunks no slice claimed.",
1161
+ hunks: rest,
1162
+ ...sliceTotals(rest, byRef),
1163
+ rest: true
1164
+ });
1165
+ return { slices, ...manualTesting ? { manualTesting } : {}, warnings };
1166
+ }
1167
+
1168
+ // src/commands/review/highLevel/writeJsonFile.ts
1169
+ import { mkdirSync, writeFileSync } from "fs";
1170
+ import { dirname as dirname2 } from "path";
1171
+ function writeJsonFile(path, data) {
1172
+ mkdirSync(dirname2(path), { recursive: true });
1173
+ writeFileSync(path, `${JSON.stringify(data, null, 2)}
1174
+ `);
1175
+ return path;
1176
+ }
1177
+
1178
+ // src/commands/review/highLevel/gatherHighLevelSlices.ts
1179
+ function readSlicesFile(file) {
1180
+ try {
1181
+ return JSON.parse(readFileSync2(file, "utf8"));
1182
+ } catch (error) {
1183
+ throw new Error(
1184
+ `could not read slices from ${file}: ${error instanceof Error ? error.message : String(error)}`
1185
+ );
1186
+ }
1187
+ }
1188
+ function sliceFromFile(file, files, path) {
1189
+ const { warnings, ...set } = resolveHighLevelSlices(
1190
+ readSlicesFile(file),
1191
+ listHighLevelHunks(files)
1192
+ );
1193
+ for (const warning of warnings) console.warn(`Warning: ${warning}`);
1194
+ writeJsonFile(path, set);
1195
+ return set;
1196
+ }
1197
+ function readSavedSlices(path) {
1198
+ const saved = readJsonFile(path);
1199
+ return Array.isArray(saved) ? { slices: saved } : saved;
1200
+ }
1201
+ function gatherHighLevelSlices(head, files, slicing) {
1202
+ const path = highLevelSlicesPath(head.repo, head.headRef, head.headSha);
1203
+ if (slicing.slicesFile) return sliceFromFile(slicing.slicesFile, files, path);
1204
+ const saved = slicing.force ? void 0 : readSavedSlices(path);
1205
+ if (saved) return saved;
1206
+ console.log(formatSlicingRequest(listHighLevelHunks(files)));
1207
+ process.exit(2);
1208
+ }
1209
+
1210
+ // src/commands/review/highLevel/testChangeExcerpts.ts
1211
+ var CONTEXT_LINES = 3;
1212
+ function testChangeExcerpts(source, line, changedLines2) {
1213
+ const lines = source.split("\n");
1214
+ const windows = [];
1215
+ for (const changed of [...changedLines2].sort((a, b) => a - b)) {
1216
+ const start = Math.max(0, changed - line - CONTEXT_LINES);
1217
+ const end = Math.min(lines.length - 1, changed - line + CONTEXT_LINES);
1218
+ const last = windows.at(-1);
1219
+ if (last && start <= last.end + 1) last.end = Math.max(last.end, end);
1220
+ else windows.push({ start, end });
1221
+ }
1222
+ return windows.map(({ start, end }) => ({
1223
+ line: line + start,
1224
+ source: lines.slice(start, end + 1).join("\n")
1225
+ }));
1226
+ }
1227
+
1228
+ // src/commands/review/highLevel/shownForm.ts
1229
+ var MAX_TEST_SOURCE_LINES = 200;
1230
+ function shownForm(test) {
1231
+ const { source, changedLines: changedLines2, ...rest } = test;
1232
+ if (source === void 0) return void 0;
1233
+ const lines = lineCount(source);
1234
+ if (lines <= MAX_TEST_SOURCE_LINES)
1235
+ return { lines, shown: { ...rest, source } };
1236
+ if (!changedLines2) return void 0;
1237
+ const excerpts = testChangeExcerpts(source, test.line, changedLines2);
1238
+ const excerptLines = excerpts.reduce(
1239
+ (sum3, excerpt) => sum3 + lineCount(excerpt.source),
1240
+ 0
1241
+ );
1242
+ return excerptLines <= MAX_TEST_SOURCE_LINES ? { lines: excerptLines, shown: { ...rest, excerpts } } : void 0;
1243
+ }
1244
+ function lineCount(text) {
1245
+ return text.split("\n").length;
1246
+ }
1247
+
1248
+ // src/commands/review/highLevel/capHighLevelTestSources.ts
1249
+ var MAX_TOTAL_SOURCE_LINES = 5e3;
1250
+ function collectCases(nodes) {
1251
+ return nodes.flatMap(
1252
+ (node) => node.kind === "it" ? [node] : collectCases(node.children)
1253
+ );
1254
+ }
1255
+ function shippedForms(files) {
1256
+ const sized = files.flatMap((file) => collectCases(file.tests)).flatMap((test) => {
1257
+ const form = shownForm(test);
1258
+ return form ? [{ test, form }] : [];
1259
+ }).sort((a, b) => a.form.lines - b.form.lines);
1260
+ const shipped = /* @__PURE__ */ new Map();
1261
+ let remaining = MAX_TOTAL_SOURCE_LINES;
1262
+ for (const { test, form } of sized) {
1263
+ if (form.lines > remaining) break;
1264
+ remaining -= form.lines;
1265
+ shipped.set(test, form);
1266
+ }
1267
+ return shipped;
1268
+ }
1269
+ function capHighLevelTestSources(files) {
1270
+ const shipped = shippedForms(files);
1271
+ const capCase = (test) => {
1272
+ const form = shipped.get(test);
1273
+ if (form) return form.shown;
1274
+ const { source, changedLines: _changedLines, ...rest } = test;
1275
+ if (source === void 0) return rest;
1276
+ return shownForm(test) ? { ...rest, overBudget: true } : { ...rest, truncated: true };
1277
+ };
1278
+ const capNode = (node) => node.kind === "it" ? capCase(node) : { ...node, children: node.children.map(capNode) };
1279
+ return files.map((file) => ({ ...file, tests: file.tests.map(capNode) }));
1280
+ }
1281
+
1282
+ // src/commands/review/highLevel/collectHighLevelTests.ts
1283
+ import { minimatch as minimatch3 } from "minimatch";
1284
+
1285
+ // src/commands/review/highLevel/extractTestHierarchy.ts
1286
+ import { Node as Node3, Project } from "ts-morph";
1287
+
1288
+ // src/commands/review/highLevel/classifyTestCall.ts
1289
+ import { Node } from "ts-morph";
1290
+ var SUITE_ROOTS = /* @__PURE__ */ new Set(["describe", "context", "suite"]);
1291
+ var CASE_ROOTS = /* @__PURE__ */ new Set(["it", "test", "specify"]);
1292
+ function calleeChain(expression) {
1293
+ if (Node.isIdentifier(expression)) return [expression.getText()];
1294
+ if (Node.isPropertyAccessExpression(expression))
1295
+ return [...calleeChain(expression.getExpression()), expression.getName()];
1296
+ if (Node.isCallExpression(expression))
1297
+ return calleeChain(expression.getExpression());
1298
+ return [];
1299
+ }
1300
+ function hasName(call) {
1301
+ const [first] = call.getArguments();
1302
+ return first !== void 0 && !Node.isFunctionLikeDeclaration(first) && !Node.isObjectLiteralExpression(first);
1303
+ }
1304
+ function classifyTestCall(call) {
1305
+ const [root, ...rest] = calleeChain(call.getExpression());
1306
+ if (root === void 0 || !hasName(call)) return void 0;
1307
+ if (SUITE_ROOTS.has(root) || rest.includes("describe")) return "describe";
1308
+ if (CASE_ROOTS.has(root)) return "it";
1309
+ return void 0;
1310
+ }
1311
+
1312
+ // src/commands/review/highLevel/testName.ts
1313
+ import { Node as Node2 } from "ts-morph";
1314
+ function testName(call) {
1315
+ const [first] = call.getArguments();
1316
+ if (Node2.isStringLiteral(first) || Node2.isNoSubstitutionTemplateLiteral(first))
1317
+ return first.getLiteralValue();
1318
+ if (Node2.isTemplateExpression(first)) return first.getText().slice(1, -1);
1319
+ return first?.getText() ?? "";
1320
+ }
1321
+
1322
+ // src/commands/review/highLevel/dedentedSource.ts
1323
+ function dedentedSource(call) {
1324
+ const text = call.getSourceFile().getFullText();
1325
+ const lineStart = text.lastIndexOf("\n", call.getStart()) + 1;
1326
+ const indent = /^\s*/.exec(text.slice(lineStart, call.getStart()))?.[0] ?? "";
1327
+ return call.getText().split("\n").map((line) => line.startsWith(indent) ? line.slice(indent.length) : line).join("\n");
1328
+ }
1329
+
1330
+ // src/commands/review/highLevel/visitCase.ts
1331
+ function visitCase(call, context) {
1332
+ if (!context.changed) return [toCase(call, context)];
1333
+ const lines = changedLines(call, context.changed);
1334
+ if (lines.length === 0) return [];
1335
+ const total = call.getEndLineNumber() - call.getStartLineNumber() + 1;
1336
+ return [
1337
+ toCase(
1338
+ call,
1339
+ context,
1340
+ lines.length === total ? { change: "added" } : { change: "modified", changedLines: lines }
1341
+ )
1342
+ ];
1343
+ }
1344
+ function toCase(call, context, change = {}) {
1345
+ const line = call.getStartLineNumber();
1346
+ return {
1347
+ kind: "it",
1348
+ id: `${context.path}:${line}`,
1349
+ name: testName(call),
1350
+ line,
1351
+ ...change,
1352
+ source: dedentedSource(call)
1353
+ };
1354
+ }
1355
+ function changedLines(call, changed) {
1356
+ const lines = [];
1357
+ for (let line = call.getStartLineNumber(); line <= call.getEndLineNumber(); line++)
1358
+ if (changed.has(line)) lines.push(line);
1359
+ return lines;
1360
+ }
1361
+
1362
+ // src/commands/review/highLevel/extractTestHierarchy.ts
1363
+ function collect(node, context) {
1364
+ const found = [];
1365
+ node.forEachChild((child) => {
1366
+ found.push(...visit(child, context));
1367
+ });
1368
+ return found;
1369
+ }
1370
+ function visit(node, context) {
1371
+ if (!Node3.isCallExpression(node)) return collect(node, context);
1372
+ const kind = classifyTestCall(node);
1373
+ if (kind === "it") return visitCase(node, context);
1374
+ if (kind === void 0) return collect(node, context);
1375
+ const children = node.getArguments().slice(1).flatMap((argument) => visit(argument, context));
1376
+ if (children.length === 0) return [];
1377
+ return [
1378
+ {
1379
+ kind: "describe",
1380
+ name: testName(node),
1381
+ line: node.getStartLineNumber(),
1382
+ children
1383
+ }
1384
+ ];
1385
+ }
1386
+ function extractTestHierarchy(path, text, changed) {
1387
+ const project = new Project({
1388
+ useInMemoryFileSystem: true,
1389
+ compilerOptions: { allowJs: true }
1390
+ });
1391
+ const source = project.createSourceFile(`/${path}`, text);
1392
+ return collect(source, { path, ...changed ? { changed } : {} });
1393
+ }
1394
+
1395
+ // src/commands/review/highLevel/patchAddedLines.ts
1396
+ var HUNK_HEADER = /^@@ -\d+(?:,\d+)? \+(\d+)/;
1397
+ function patchAddedLines(patch2) {
1398
+ const added = /* @__PURE__ */ new Set();
1399
+ let next = 0;
1400
+ for (const line of patch2.split("\n")) {
1401
+ const header = HUNK_HEADER.exec(line);
1402
+ if (header) next = Number(header[1]);
1403
+ else if (line.startsWith("+")) added.add(next++);
1404
+ else if (!line.startsWith("-") && !line.startsWith("\\")) next++;
1405
+ }
1406
+ return added;
1407
+ }
1408
+
1409
+ // src/commands/review/highLevel/collectHighLevelTests.ts
1410
+ function testFile(file, readSource) {
1411
+ const changed = file.patch === void 0 ? void 0 : patchAddedLines(file.patch);
1412
+ const tests = extractTestHierarchy(file.path, readSource(file.path), changed);
1413
+ if (tests.length === 0) return [];
1414
+ const { path, status, additions, deletions, diffUrl: diffUrl2 } = file;
1415
+ return [{ path, status, additions, deletions, diffUrl: diffUrl2, tests }];
1416
+ }
1417
+ function collectHighLevelTests(files, testPaths, readSource) {
1418
+ return files.filter(
1419
+ (file) => file.status !== "removed" && testPaths.some((glob) => minimatch3(file.path, glob))
1420
+ ).flatMap((file) => testFile(file, readSource));
1421
+ }
1422
+
1423
+ // src/commands/review/highLevel/fetchFileAtSha.ts
1424
+ import { execFileSync as execFileSync3 } from "child_process";
1425
+ function fetchFileAtSha(repo, sha, path) {
1426
+ const encodedPath = path.split("/").map(encodeURIComponent).join("/");
1427
+ try {
1428
+ return execFileSync3(
1429
+ "gh",
1430
+ [
1431
+ "api",
1432
+ "-H",
1433
+ "Accept: application/vnd.github.raw",
1434
+ `repos/${repo}/contents/${encodedPath}?ref=${sha}`
1435
+ ],
1436
+ {
1437
+ encoding: "utf8",
1438
+ maxBuffer: 64 * 1024 * 1024,
1439
+ stdio: ["ignore", "pipe", "pipe"]
1440
+ }
1441
+ );
1442
+ } catch (error) {
1443
+ throw new Error(
1444
+ `Could not read ${path} at PR head ${sha.slice(0, 7)}: ${ghFailure(error)}`
1445
+ );
1446
+ }
1447
+ }
1448
+
1449
+ // src/commands/review/highLevel/gatherHighLevelTests.ts
1450
+ function gatherHighLevelTests(files, testPaths, repo, headSha) {
1451
+ return capHighLevelTestSources(
1452
+ collectHighLevelTests(
1453
+ files,
1454
+ testPaths,
1455
+ (path) => fetchFileAtSha(repo, headSha, path)
1456
+ )
1457
+ );
1458
+ }
1459
+
1460
+ // src/commands/review/highLevel/highLevelDraftPath.ts
1461
+ function highLevelDraftPath(repo, headRef, headSha) {
1462
+ return highLevelReviewPath(repo, headRef, headSha).replace(
1463
+ /\.json$/,
1464
+ ".draft.json"
1465
+ );
1466
+ }
1467
+
1468
+ // src/commands/review/highLevel/loadHighLevelDraft.ts
1469
+ function loadHighLevelDraft(repo, headRef, headSha) {
1470
+ return readJsonFile(highLevelDraftPath(repo, headRef, headSha));
1471
+ }
1472
+
1473
+ // src/commands/review/highLevel/loadHighLevelReview.ts
1474
+ function loadHighLevelReview(repo, headRef, headSha) {
1475
+ return readJsonFile(highLevelReviewPath(repo, headRef, headSha));
1476
+ }
1477
+
1478
+ // src/commands/review/highLevel/loadReopenedReview.ts
1479
+ function loadReopenedReview(repo, headRef, headSha) {
1480
+ const saved = loadHighLevelReview(repo, headRef, headSha);
1481
+ const draft = loadHighLevelDraft(repo, headRef, headSha);
1482
+ return {
1483
+ ...saved ? { saved } : {},
1484
+ ...draft ? { draft } : {}
1485
+ };
1486
+ }
1487
+
1488
+ // src/commands/review/highLevel/selectCriticalDiffs.ts
1489
+ import { minimatch as minimatch4 } from "minimatch";
1490
+ function selectCriticalDiffs(files, criticalPaths) {
1491
+ if (criticalPaths.length === 0) return [];
1492
+ return files.filter((file) => criticalPaths.some((glob) => minimatch4(file.path, glob))).map(
1493
+ ({ path, status, additions, deletions, diffUrl: diffUrl2, patch: patch2, truncated }) => ({
1494
+ path,
1495
+ status,
1496
+ additions,
1497
+ deletions,
1498
+ diffUrl: diffUrl2,
1499
+ patch: patch2 ?? null,
1500
+ ...truncated ? { truncated: true } : {}
1501
+ })
1502
+ );
1503
+ }
1504
+
1505
+ // src/commands/review/highLevel/gatherHighLevelSubject.ts
1506
+ function gatherHighLevelSubject(prNumber, force, slicing) {
1507
+ const { org, repo } = getRepoInfo();
1508
+ const slug2 = `${org}/${repo}`;
1509
+ const pr = fetchHighLevelPr(prNumber, { org, repo });
1510
+ const config = resolveHighLevelConfig(loadConfig());
1511
+ const fetched = fetchHighLevelFiles(prNumber, slug2);
1512
+ const files = capHighLevelPatches(fetched, config.criticalPaths);
1513
+ const head = { repo: slug2, headRef: pr.headRef, headSha: pr.headSha };
1514
+ const sliced = slicing ? gatherHighLevelSlices(head, files, slicing) : void 0;
1515
+ return {
1516
+ ...head,
1517
+ prNumber,
1518
+ title: pr.title,
1519
+ checks: evaluateHighLevelChecks({
1520
+ ...pr,
1521
+ changedFiles: files.map((file) => file.path),
1522
+ config,
1523
+ sliced: sliced !== void 0
1524
+ }),
1525
+ structure: buildHighLevelStructure(files),
1526
+ criticalDiffs: selectCriticalDiffs(files, config.criticalPaths),
1527
+ criticalPaths: config.criticalPaths,
1528
+ tests: gatherHighLevelTests(fetched, config.testPaths, slug2, pr.headSha),
1529
+ testPaths: config.testPaths,
1530
+ collapsedPaths: config.collapsedPaths,
1531
+ ...sliced,
1532
+ ...force ? {} : loadReopenedReview(slug2, pr.headRef, pr.headSha)
1533
+ };
1534
+ }
1535
+
1536
+ // src/commands/review/highLevel/openHighLevelOverlay.ts
1537
+ import { randomUUID } from "crypto";
1538
+
1539
+ // src/commands/review/highLevel/isHighLevelSliceCheck.ts
1540
+ var SLICE_CHECKS = /* @__PURE__ */ new Set([
1541
+ "structure-sensible",
1542
+ "tests-worth-having",
1543
+ "critical-diffs-correct"
1544
+ ]);
1545
+ function isHighLevelSliceCheck(id) {
1546
+ return SLICE_CHECKS.has(id);
1547
+ }
1548
+
1549
+ // src/commands/review/highLevel/highLevelProgress.ts
1550
+ function toItem(check, decision, slice) {
1551
+ const ticked = decision.checklist?.find(
1552
+ (entry) => entry.id === check.id && entry.slice === slice?.number
1553
+ );
1554
+ const comment2 = ticked?.comment?.trim();
1555
+ return {
1556
+ id: check.id,
1557
+ kind: check.kind,
1558
+ title: check.title,
1559
+ status: check.status,
1560
+ reason: check.reason,
1561
+ ticked: ticked?.ticked ?? check.status === "pass",
1562
+ ...comment2 ? { comment: comment2 } : {},
1563
+ ...slice ? { slice: slice.number, sliceTitle: slice.title } : {}
1564
+ };
1565
+ }
1566
+ function itemsOf(check, decision, slices) {
1567
+ if (!slices || !isHighLevelSliceCheck(check.id))
1568
+ return [toItem(check, decision)];
1569
+ return slices.map(
1570
+ (slice, index) => toItem(check, decision, { number: index + 1, title: slice.title })
1571
+ );
1572
+ }
1573
+ function highLevelProgress(checks, decision, slices) {
1574
+ const reviewComments = decision.reviewComments ?? [];
1575
+ return {
1576
+ items: checks.flatMap((check) => itemsOf(check, decision, slices)),
1577
+ ...reviewComments.length > 0 ? { reviewComments } : {}
1578
+ };
1579
+ }
1580
+
1581
+ // src/commands/review/highLevel/buildHighLevelDraft.ts
1582
+ function buildHighLevelDraft(subject, decision) {
1583
+ const { checks, repo, prNumber, headRef, headSha } = subject;
1584
+ return {
1585
+ repo,
1586
+ prNumber,
1587
+ headRef,
1588
+ headSha,
1589
+ savedAt: (/* @__PURE__ */ new Date()).toISOString(),
1590
+ ...highLevelProgress(checks, decision, subject.slices)
1591
+ };
1592
+ }
1593
+
1594
+ // src/commands/review/highLevel/highLevelReviewEvent.ts
1595
+ function highLevelReviewEvent(decision) {
1596
+ if (decision.reviewEvent) return decision.reviewEvent;
1597
+ return decision.decision === "approve" ? "APPROVE" : "REQUEST_CHANGES";
1598
+ }
1599
+
1600
+ // src/commands/review/highLevel/buildHighLevelRecord.ts
1601
+ var VERDICTS = {
1602
+ APPROVE: "approve",
1603
+ COMMENT: "comment",
1604
+ REQUEST_CHANGES: "request-changes"
1605
+ };
1606
+ function buildHighLevelRecord(subject, decision) {
1607
+ const { checks, repo, prNumber, headRef, headSha } = subject;
1608
+ return {
1609
+ repo,
1610
+ prNumber,
1611
+ headRef,
1612
+ headSha,
1613
+ verdict: VERDICTS[highLevelReviewEvent(decision)],
1614
+ reviewedAt: (/* @__PURE__ */ new Date()).toISOString(),
1615
+ ...highLevelProgress(checks, decision, subject.slices)
1616
+ };
1617
+ }
1618
+
1619
+ // src/commands/review/highLevel/clearHighLevelDraft.ts
1620
+ import { rmSync } from "fs";
1621
+ function clearHighLevelDraft(repo, headRef, headSha) {
1622
+ rmSync(highLevelDraftPath(repo, headRef, headSha), { force: true });
1623
+ }
1624
+
1625
+ // src/commands/review/highLevel/discardHighLevelProgress.ts
1626
+ import { rmSync as rmSync2 } from "fs";
1627
+ function discardHighLevelProgress(repo, headRef, headSha) {
1628
+ clearHighLevelDraft(repo, headRef, headSha);
1629
+ rmSync2(highLevelReviewPath(repo, headRef, headSha), { force: true });
1630
+ }
1631
+
1632
+ // src/commands/review/highLevel/saveHighLevelDraft.ts
1633
+ function saveHighLevelDraft(draft) {
1634
+ return writeJsonFile(
1635
+ highLevelDraftPath(draft.repo, draft.headRef, draft.headSha),
1636
+ draft
1637
+ );
1638
+ }
1639
+
1640
+ // src/commands/review/highLevel/highLevelPreviewMetadata.ts
1641
+ function reopenedFrom(subject) {
1642
+ const at = subject.draft?.savedAt ?? subject.saved?.reviewedAt;
1643
+ return at ? [{ label: "Reopened from", value: at }] : [];
1644
+ }
1645
+ function highLevelPreviewMetadata(subject) {
1646
+ return [
1647
+ { label: "Branch", value: subject.headRef },
1648
+ { label: "Head", value: subject.headSha.slice(0, 7) },
1649
+ ...reopenedFrom(subject)
1650
+ ];
1651
+ }
1652
+
1653
+ // src/commands/review/highLevel/highLevelPreviewPayload.ts
1654
+ function highLevelPreviewPayload(subject) {
1655
+ const {
1656
+ repo,
1657
+ prNumber,
1658
+ headSha,
1659
+ checks,
1660
+ structure,
1661
+ criticalDiffs,
1662
+ criticalPaths,
1663
+ tests,
1664
+ testPaths,
1665
+ collapsedPaths,
1666
+ slices,
1667
+ manualTesting,
1668
+ saved,
1669
+ draft
1670
+ } = subject;
1671
+ return {
1672
+ repo,
1673
+ prNumber,
1674
+ headSha,
1675
+ checks,
1676
+ structure,
1677
+ criticalDiffs,
1678
+ criticalPaths,
1679
+ tests,
1680
+ testPaths,
1681
+ collapsedPaths,
1682
+ ...slices ? { slices } : {},
1683
+ ...manualTesting ? { manualTesting } : {},
1684
+ ...saved ? { saved } : {},
1685
+ ...draft ? { draft } : {}
1686
+ };
1687
+ }
1688
+
1689
+ // src/commands/review/highLevel/saveHighLevelReview.ts
1690
+ function saveHighLevelReview(record) {
1691
+ return writeJsonFile(
1692
+ highLevelReviewPath(record.repo, record.headRef, record.headSha),
1693
+ record
1694
+ );
1695
+ }
1696
+
1697
+ // src/commands/review/highLevel/formatReviewComment.ts
1698
+ function formatReviewComment({
1699
+ path,
1700
+ startLine,
1701
+ endLine,
1702
+ quote,
1703
+ note
1704
+ }) {
1705
+ const lines = startLine === endLine ? `${startLine}` : `${startLine}-${endLine}`;
1706
+ return `- \`${path}:${lines}\` ${quote}: ${note.replace(/\n/g, "\n ")}`;
1707
+ }
1708
+
1709
+ // src/commands/review/highLevel/formatHighLevelReviewBody.ts
1710
+ var statusMarkers = {
1711
+ fail: "\u274C",
1712
+ manual: "\u{1F4AC}",
1713
+ pass: "\u2705"
1714
+ };
1715
+ function formatItem(item) {
1716
+ if (!item.comment) return void 0;
1717
+ const comment2 = item.comment.replace(/\n/g, "\n ");
1718
+ return `- ${statusMarkers[item.status]} **${item.title}** \u2014 ${comment2}`;
1719
+ }
1720
+ function findings(items) {
1721
+ const lines = items.map(formatItem).filter((line) => line !== void 0);
1722
+ return lines.length > 0 ? lines.join("\n") : void 0;
1723
+ }
1724
+ function sliceSections(items) {
1725
+ const bySlice = /* @__PURE__ */ new Map();
1726
+ for (const item of items)
1727
+ if (item.slice !== void 0)
1728
+ bySlice.set(item.slice, [...bySlice.get(item.slice) ?? [], item]);
1729
+ return [...bySlice].flatMap(([number, sliceItems]) => {
1730
+ const lines = findings(sliceItems);
1731
+ if (!lines) return [];
1732
+ const title = sliceItems[0]?.sliceTitle;
1733
+ return [`**Slice ${number}${title ? `: ${title}` : ""}**
1734
+
1735
+ ${lines}`];
1736
+ });
1737
+ }
1738
+ function formatHighLevelReviewBody(items, reviewComments = []) {
1739
+ const sections = [];
1740
+ const prWide = findings(items.filter((item) => item.slice === void 0));
1741
+ if (prWide) sections.push(prWide);
1742
+ sections.push(...sliceSections(items));
1743
+ if (reviewComments.length > 0)
1744
+ sections.push(
1745
+ `**Comments**
1746
+
1747
+ ${reviewComments.map(formatReviewComment).join("\n")}`
1748
+ );
1749
+ return sections.join("\n\n");
1750
+ }
1751
+
1752
+ // src/commands/review/highLevel/postHighLevelReview.ts
1753
+ function toLineComment(comment2) {
1754
+ const side = comment2.side ?? "RIGHT";
1755
+ const startSide = comment2.startSide ?? "RIGHT";
1756
+ const single = comment2.startLine === comment2.endLine && startSide === side;
1757
+ return {
1758
+ path: comment2.path,
1759
+ body: comment2.note,
1760
+ line: comment2.endLine,
1761
+ side,
1762
+ ...single ? {} : { start_line: comment2.startLine, start_side: startSide }
1763
+ };
1764
+ }
1765
+ function postHighLevelReview(repo, prNumber, { event, body, comments }) {
1766
+ const payload = {
1767
+ event,
1768
+ ...body ? { body } : {},
1769
+ comments: comments.map(toLineComment)
1770
+ };
1771
+ runGhOrThrow(
1772
+ [
1773
+ "api",
1774
+ `repos/${repo}/pulls/${prNumber}/reviews`,
1775
+ "--method",
1776
+ "POST",
1777
+ "--input",
1778
+ "-"
1779
+ ],
1780
+ `Could not review ${repo}#${prNumber}`,
1781
+ JSON.stringify(payload)
1782
+ );
1783
+ }
1784
+
1785
+ // src/commands/review/highLevel/patchHunkLines.ts
1786
+ var HUNK_HEADER2 = /^@@ -(\d+)(?:,\d+)? \+(\d+)/;
1787
+ function patchHunkLines(patch2) {
1788
+ const hunks = [];
1789
+ let current;
1790
+ let left = 0;
1791
+ let right = 0;
1792
+ for (const line of patch2.split("\n")) {
1793
+ const header = HUNK_HEADER2.exec(line);
1794
+ if (header) {
1795
+ current = { LEFT: /* @__PURE__ */ new Set(), RIGHT: /* @__PURE__ */ new Set() };
1796
+ hunks.push(current);
1797
+ left = Number(header[1]);
1798
+ right = Number(header[2]);
1799
+ } else if (!current || line.startsWith("\\")) continue;
1800
+ else if (line.startsWith("+")) current.RIGHT.add(right++);
1801
+ else if (line.startsWith("-")) current.LEFT.add(left++);
1802
+ else {
1803
+ current.LEFT.add(left++);
1804
+ current.RIGHT.add(right++);
1805
+ }
1806
+ }
1807
+ return hunks;
1808
+ }
1809
+
1810
+ // src/commands/review/highLevel/splitHighLevelReviewComments.ts
1811
+ function inHunk(comment2, hunk) {
1812
+ return hunk[comment2.startSide ?? "RIGHT"].has(comment2.startLine) && hunk[comment2.side ?? "RIGHT"].has(comment2.endLine);
1813
+ }
1814
+ function splitHighLevelReviewComments(comments, files) {
1815
+ const hunks = new Map(
1816
+ files.map((file) => [file.path, patchHunkLines(file.patch ?? "")])
1817
+ );
1818
+ const split = { lineLevel: [], remainder: [] };
1819
+ for (const comment2 of comments) {
1820
+ const onDiff = hunks.get(comment2.path)?.some((hunk) => inHunk(comment2, hunk));
1821
+ (onDiff ? split.lineLevel : split.remainder).push(comment2);
1822
+ }
1823
+ return split;
1824
+ }
1825
+
1826
+ // src/commands/review/highLevel/splitQueuedComments.ts
1827
+ function splitQueuedComments(record) {
1828
+ const queued = record.reviewComments ?? [];
1829
+ if (queued.length === 0) return { lineLevel: [], remainder: [] };
1830
+ try {
1831
+ const files = fetchHighLevelFiles(record.prNumber, record.repo);
1832
+ return splitHighLevelReviewComments(queued, files);
1833
+ } catch (error) {
1834
+ console.error(
1835
+ `Could not read the PR diff, so every comment goes in the PR-level body: ${error.message}`
1836
+ );
1837
+ return { lineLevel: [], remainder: queued };
1838
+ }
1839
+ }
1840
+
1841
+ // src/commands/review/highLevel/submitHighLevelReview.ts
1842
+ var EVENTS = {
1843
+ approve: "APPROVE",
1844
+ comment: "COMMENT",
1845
+ "request-changes": "REQUEST_CHANGES"
1846
+ };
1847
+ function submitHighLevelReview(record) {
1848
+ const { lineLevel, remainder } = splitQueuedComments(record);
1849
+ const submission = {
1850
+ event: EVENTS[record.verdict],
1851
+ body: formatHighLevelReviewBody(record.items, remainder),
1852
+ comments: lineLevel
1853
+ };
1854
+ const hasContent = submission.body || lineLevel.length > 0;
1855
+ if (submission.event !== "APPROVE" && !hasContent) {
1856
+ console.log("Nothing was posted to GitHub.");
1857
+ return;
1858
+ }
1859
+ const target = `${record.repo}#${record.prNumber}`;
1860
+ try {
1861
+ postHighLevelReview(record.repo, record.prNumber, submission);
1862
+ } catch (error) {
1863
+ console.error(
1864
+ `Could not post the review to ${target}: ${error.message}`
1865
+ );
1866
+ process.exit(1);
1867
+ }
1868
+ console.log(`Review (${submission.event}) posted to ${target}.`);
1869
+ }
1870
+
1871
+ // src/commands/review/highLevel/openHighLevelOverlay.ts
1872
+ async function openHighLevelOverlay(sessionId2, subject, onRestart = async () => {
1873
+ }) {
1874
+ const decision = await awaitPreviewApproval(
1875
+ "High-level review",
1876
+ {
1877
+ sessionId: sessionId2,
1878
+ requestId: randomUUID(),
1879
+ title: `${subject.repo}#${subject.prNumber} \u2014 ${subject.title}`,
1880
+ body: JSON.stringify(highLevelPreviewPayload(subject)),
1881
+ prNumber: subject.prNumber,
1882
+ kind: "high-level-review",
1883
+ metadata: highLevelPreviewMetadata(subject)
1884
+ },
1885
+ { rejectIsOutcome: true }
1886
+ );
1887
+ if (decision.restart) {
1888
+ discardHighLevelProgress(subject.repo, subject.headRef, subject.headSha);
1889
+ await onRestart();
1890
+ return void 0;
1891
+ }
1892
+ if (decision.dismissed) {
1893
+ saveHighLevelDraft(buildHighLevelDraft(subject, decision));
1894
+ console.log(
1895
+ "Review closed without a verdict. Your progress is kept for when you reopen it; nothing was posted."
1896
+ );
1897
+ return void 0;
1898
+ }
1899
+ const record = buildHighLevelRecord(subject, decision);
1900
+ saveHighLevelReview(record);
1901
+ clearHighLevelDraft(record.repo, record.headRef, record.headSha);
1902
+ console.log(`Verdict: ${record.verdict}`);
1903
+ submitHighLevelReview(record);
1904
+ return record;
1905
+ }
1906
+
1907
+ // src/commands/review/highLevel/printHighLevelChecklist.ts
1908
+ import chalk10 from "chalk";
1909
+
1910
+ // src/commands/review/highLevel/formatCriticalDiffs.ts
1911
+ import chalk6 from "chalk";
1912
+ var PATCH_LINE_COLOURS = {
1913
+ "+": chalk6.green,
1914
+ "-": chalk6.red,
1915
+ "@": chalk6.cyan
1916
+ };
1917
+ function formatPatch(patch2) {
1918
+ return patch2.split("\n").map(
1919
+ (line) => ` ${(PATCH_LINE_COLOURS[line[0] ?? ""] ?? chalk6.dim)(line)}`
1920
+ );
1921
+ }
1922
+ function formatDiff(diff) {
1923
+ return [
1924
+ "",
1925
+ ` ${chalk6.bold(diff.path)} ${chalk6.dim(`(${diff.status})`)} ${chalk6.green(`+${diff.additions}`)} ${chalk6.red(`-${diff.deletions}`)}`,
1926
+ ...diff.patch === null ? [` ${chalk6.dim(`no diff available; see ${diff.diffUrl}`)}`] : formatPatch(diff.patch)
1927
+ ];
1928
+ }
1929
+ function formatCriticalDiffs(diffs, criticalPaths) {
1930
+ if (criticalPaths.length === 0)
1931
+ return `${chalk6.bold.underline("Critical diffs")}
1932
+ ${chalk6.dim("review.highLevel.criticalPaths is empty, so no diffs are shown")}`;
1933
+ if (diffs.length === 0)
1934
+ return `${chalk6.bold.underline("Critical diffs")}
1935
+ ${chalk6.dim(`no changed file matches ${criticalPaths.join(", ")}`)}`;
1936
+ return [
1937
+ chalk6.bold.underline("Critical diffs"),
1938
+ ...diffs.flatMap(formatDiff)
1939
+ ].join("\n");
1940
+ }
1941
+
1942
+ // src/commands/review/highLevel/formatHighLevelChecklist.ts
1943
+ import chalk7 from "chalk";
1944
+ var MARKERS = {
1945
+ pass: () => chalk7.green("\u2714"),
1946
+ fail: () => chalk7.red("\u2718"),
1947
+ manual: () => chalk7.yellow("\u25A1")
1948
+ };
1949
+ function formatCheck(check) {
1950
+ const title = check.status === "fail" ? chalk7.red(check.title) : chalk7.bold(check.title);
1951
+ return ` ${MARKERS[check.status]()} ${title}
1952
+ ${chalk7.dim(check.reason)}`;
1953
+ }
1954
+ function formatGroup(heading, checks) {
1955
+ if (checks.length === 0) return [];
1956
+ return ["", chalk7.bold.underline(heading), ...checks.map(formatCheck)];
1957
+ }
1958
+ function formatHighLevelChecklist(checks) {
1959
+ const deterministic = checks.filter(
1960
+ (check) => check.kind === "deterministic"
1961
+ );
1962
+ const failed2 = deterministic.filter(
1963
+ (check) => check.status === "fail"
1964
+ ).length;
1965
+ const summary = failed2 === 0 ? chalk7.green(`All ${deterministic.length} deterministic checks pass`) : chalk7.red(
1966
+ `${failed2} of ${deterministic.length} deterministic checks fail`
1967
+ );
1968
+ return [
1969
+ ...formatGroup("Deterministic", deterministic),
1970
+ ...formatGroup(
1971
+ "Manual",
1972
+ checks.filter((check) => check.kind === "manual")
1973
+ ),
1974
+ "",
1975
+ summary
1976
+ ].join("\n");
1977
+ }
1978
+
1979
+ // src/commands/review/highLevel/formatHighLevelStructure.ts
1980
+ import chalk8 from "chalk";
1981
+ var STATUS_MARKERS = {
1982
+ added: () => chalk8.green("A"),
1983
+ removed: () => chalk8.red("D"),
1984
+ modified: () => chalk8.yellow("M")
1985
+ };
1986
+ function counts(additions, deletions) {
1987
+ return `${chalk8.green(`+${additions}`)} ${chalk8.red(`-${deletions}`)}`;
1988
+ }
1989
+ function formatNode(node, indent) {
1990
+ if (node.kind === "file")
1991
+ return [
1992
+ `${indent}${STATUS_MARKERS[node.status]()} ${node.name} ${chalk8.dim(counts(node.additions, node.deletions))}`
1993
+ ];
1994
+ const dir = node;
1995
+ return [
1996
+ `${indent}${chalk8.bold(`${dir.name}/`)} ${chalk8.dim(counts(dir.additions, dir.deletions))}`,
1997
+ ...dir.children.flatMap((child) => formatNode(child, `${indent} `))
1998
+ ];
1999
+ }
2000
+ function formatHighLevelStructure(structure) {
2001
+ const summary = `${structure.added} added \xB7 ${structure.removed} deleted \xB7 ${structure.modified} modified \xB7 ${counts(structure.additions, structure.deletions)}`;
2002
+ return [
2003
+ chalk8.bold.underline("Structure"),
2004
+ ` ${summary}`,
2005
+ ...structure.tree.flatMap((node) => formatNode(node, " "))
2006
+ ].join("\n");
2007
+ }
2008
+
2009
+ // src/commands/review/highLevel/formatHighLevelTests.ts
2010
+ import chalk9 from "chalk";
2011
+ function changeMarker(change) {
2012
+ if (change === "added") return "A";
2013
+ if (change === "modified") return "M";
2014
+ return "\xB7";
2015
+ }
2016
+ function formatNode2(node, depth) {
2017
+ const indent = " ".repeat(depth + 2);
2018
+ if (node.kind === "it")
2019
+ return [`${indent}${chalk9.dim(changeMarker(node.change))} ${node.name}`];
2020
+ return [
2021
+ `${indent}${chalk9.bold(node.name)}`,
2022
+ ...node.children.flatMap((child) => formatNode2(child, depth + 1))
2023
+ ];
2024
+ }
2025
+ function formatHighLevelTests(files, testPaths) {
2026
+ const heading = chalk9.bold.underline("Changed tests");
2027
+ if (files.length === 0)
2028
+ return `${heading}
2029
+ ${chalk9.dim(`no changed test in files matching ${testPaths.join(", ")}`)}`;
2030
+ return [
2031
+ heading,
2032
+ ...files.flatMap((file) => [
2033
+ "",
2034
+ ` ${chalk9.bold(file.path)} ${chalk9.dim(`(${file.status})`)}`,
2035
+ ...file.tests.flatMap((node) => formatNode2(node, 0))
2036
+ ])
2037
+ ].join("\n");
2038
+ }
2039
+
2040
+ // src/commands/review/highLevel/highLevelChangedFileCount.ts
2041
+ function highLevelChangedFileCount(structure) {
2042
+ return structure.added + structure.removed + structure.modified;
2043
+ }
2044
+
2045
+ // src/commands/review/highLevel/printHighLevelChecklist.ts
2046
+ function printHighLevelChecklist(subject) {
2047
+ console.log(
2048
+ chalk10.bold(
2049
+ `High-level review of ${subject.repo}#${subject.prNumber} \u2014 ${subject.title}`
2050
+ ),
2051
+ chalk10.dim(
2052
+ `\xB7 ${highLevelChangedFileCount(subject.structure)} changed files`
2053
+ )
2054
+ );
2055
+ console.log(formatHighLevelChecklist(subject.checks));
2056
+ console.log("");
2057
+ console.log(formatHighLevelStructure(subject.structure));
2058
+ console.log("");
2059
+ console.log(
2060
+ formatCriticalDiffs(subject.criticalDiffs, subject.criticalPaths)
2061
+ );
2062
+ console.log("");
2063
+ console.log(formatHighLevelTests(subject.tests, subject.testPaths));
2064
+ console.log(
2065
+ chalk10.dim(
2066
+ "\nManual items are for the reviewer to judge; see docs/high-level-review.md."
2067
+ )
2068
+ );
2069
+ console.log(
2070
+ chalk10.dim(
2071
+ "Run this inside an assist session to step through the checklist in the web overlay."
2072
+ )
2073
+ );
2074
+ }
2075
+
2076
+ // src/commands/review/highLevel/runHighLevelReview.ts
2077
+ function resolvePrNumber(number) {
2078
+ if (number === void 0) return getCurrentPrNumber();
2079
+ const parsed = Number(number);
2080
+ if (!Number.isInteger(parsed) || parsed <= 0) {
2081
+ console.error(`Error: \`${number}\` is not a pull request number.`);
2082
+ process.exit(1);
2083
+ }
2084
+ return parsed;
2085
+ }
2086
+ function gatherSubject(prNumber, force, slicing) {
2087
+ try {
2088
+ return gatherHighLevelSubject(prNumber, force, slicing);
2089
+ } catch (error) {
2090
+ console.error(
2091
+ `Error: ${error instanceof Error ? error.message : String(error)}`
2092
+ );
2093
+ process.exit(1);
2094
+ }
2095
+ }
2096
+ function sessionId() {
2097
+ const id = process.env.ASSIST_SESSION_ID;
2098
+ return process.env.ASSIST_SESSION === "1" && id ? id : void 0;
2099
+ }
2100
+ async function runHighLevelReview(number, options = {}) {
2101
+ const force = options.force === true;
2102
+ const session = sessionId();
2103
+ const slicing = session ? { force, ...options.slices ? { slicesFile: options.slices } : {} } : void 0;
2104
+ const subject = gatherSubject(resolvePrNumber(number), force, slicing);
2105
+ announceSavedReview(subject, force);
2106
+ if (!session) return printHighLevelChecklist(subject);
2107
+ await openHighLevelOverlay(
2108
+ session,
2109
+ subject,
2110
+ () => runHighLevelReview(number, { force: true })
2111
+ );
2112
+ }
2113
+
2114
+ // src/commands/review/reviewPr.ts
2115
+ import { basename as basename3 } from "path";
2116
+ import chalk13 from "chalk";
2117
+
2118
+ // src/commands/review/resolveSynthesisHarness.ts
2119
+ var DEFAULT_SYNTHESIS_HARNESS = "claude";
2120
+ function resolveSynthesisHarness() {
2121
+ return loadConfig().review?.synthesisHarness ?? DEFAULT_SYNTHESIS_HARNESS;
2122
+ }
2123
+
2124
+ // src/commands/review/reviewModel.ts
2125
+ function reviewModel(harness) {
2126
+ const models = {
2127
+ codex: resolveCodexModel(loadConfig().review?.codexModel)
2128
+ };
2129
+ return models[harness];
2130
+ }
2131
+
2132
+ // src/commands/review/runSynthesisReviewer.ts
2133
+ var name = "synthesis";
2134
+ function synthesisBlocker(harness) {
2135
+ return launchBlocker(harnessAdapter(harness), reviewSynthesisFeature);
2136
+ }
2137
+ function runSynthesisReviewer(spec) {
2138
+ const blocker = synthesisBlocker(spec.harness);
2139
+ if (blocker)
2140
+ return Promise.resolve({
2141
+ name,
2142
+ outputPath: spec.outputPath,
2143
+ exitCode: 1,
2144
+ stderr: blocker
2145
+ });
2146
+ const { multi } = spec;
2147
+ const tag = spec.harness === DEFAULT_SYNTHESIS_HARNESS ? void 0 : spec.harness;
2148
+ return harnessAdapter(spec.harness).structured({
2149
+ name,
2150
+ stdin: spec.stdin,
2151
+ outputPath: spec.outputPath,
2152
+ readDir: spec.reviewDir,
2153
+ model: reviewModel(spec.harness),
2154
+ spinner: multi && ((model) => multi.create(`${reviewerLabel(name, model ?? tag)} \u2014 starting`))
2155
+ });
2156
+ }
2157
+
2158
+ // src/commands/review/MultiSpinner.ts
2159
+ import { createLogUpdate } from "log-update";
2160
+
2161
+ // src/commands/review/renderEntries.ts
2162
+ var SPINNER_FRAMES = [
2163
+ "\u280B",
2164
+ "\u2819",
2165
+ "\u2839",
2166
+ "\u2838",
2167
+ "\u283C",
2168
+ "\u2834",
2169
+ "\u2826",
2170
+ "\u2827",
2171
+ "\u2807",
2172
+ "\u280F"
2173
+ ];
2174
+ function refreshElapsedText(entry) {
2175
+ if (entry.elapsedStart === void 0 || entry.state !== "running") return;
2176
+ const seconds = Math.round((Date.now() - entry.elapsedStart) / 1e3);
2177
+ entry.text = `${entry.elapsedPrefix ?? "elapsed"}: ${seconds}s`;
2178
+ }
2179
+ function renderEntries(entries, frame) {
2180
+ const sorted = [...entries].sort(
2181
+ (a, b) => Number(Boolean(a.footer)) - Number(Boolean(b.footer))
2182
+ );
2183
+ for (const entry of sorted) refreshElapsedText(entry);
2184
+ return sorted.map((e) => renderEntry(e, frame)).join("\n");
2185
+ }
2186
+ function renderEntry(entry, frame) {
2187
+ if (entry.state === "succeeded") return `\u2714 ${entry.text}`;
2188
+ if (entry.state === "failed") return `\u2716 ${entry.text}`;
2189
+ return `${SPINNER_FRAMES[frame]} ${entry.text}`;
2190
+ }
2191
+
2192
+ // src/commands/review/startReviewLog.ts
2193
+ import { format } from "util";
2194
+
2195
+ // src/commands/review/createReviewLogSink.ts
2196
+ import { appendFileSync, mkdirSync as mkdirSync2 } from "fs";
2197
+ import { join as join2 } from "path";
2198
+ var LOG_FILE = "review.log";
2199
+ function createReviewLogSink() {
2200
+ let logPath;
2201
+ let buffered = [];
2202
+ return {
2203
+ append(line) {
2204
+ const stripped = stripAnsi(line);
2205
+ if (!logPath) {
2206
+ buffered.push(stripped);
2207
+ return;
2208
+ }
2209
+ appendFileSync(logPath, `${stripped}
2210
+ `);
2211
+ },
2212
+ attach(reviewDir) {
2213
+ mkdirSync2(reviewDir, { recursive: true });
2214
+ logPath = join2(reviewDir, LOG_FILE);
2215
+ const lines = [
2216
+ "",
2217
+ `=== ${(/* @__PURE__ */ new Date()).toISOString()} ===`,
2218
+ `$ ${process.argv.slice(1).join(" ")}`,
2219
+ ...buffered
2220
+ ];
2221
+ buffered = [];
2222
+ appendFileSync(logPath, `${lines.join("\n")}
2223
+ `);
2224
+ }
2225
+ };
2226
+ }
2227
+
2228
+ // src/commands/review/startReviewLog.ts
2229
+ var sink = createReviewLogSink();
2230
+ var patched = false;
2231
+ function appendReviewLog(line) {
2232
+ sink.append(line);
2233
+ }
2234
+ function attachReviewLog(reviewDir) {
2235
+ sink.attach(reviewDir);
2236
+ }
2237
+ function patch(method) {
2238
+ const original = console[method].bind(console);
2239
+ console[method] = (...args) => {
2240
+ original(...args);
2241
+ appendReviewLog(format(...args));
2242
+ };
2243
+ }
2244
+ function startReviewLog() {
2245
+ if (patched) return;
2246
+ patched = true;
2247
+ patch("log");
2248
+ patch("error");
2249
+ patch("warn");
2250
+ }
2251
+
2252
+ // src/commands/review/MultiSpinner.ts
2253
+ var TICK_MS = 80;
2254
+ var MultiSpinner = class {
2255
+ entries = [];
2256
+ log = createLogUpdate(process.stdout);
2257
+ timer;
2258
+ frame = 0;
2259
+ finished = false;
2260
+ create(initialText) {
2261
+ return this.add({ state: "running", text: initialText });
2262
+ }
2263
+ addElapsed(prefix = "elapsed") {
2264
+ return this.add({
2265
+ state: "running",
2266
+ text: `${prefix}: 0s`,
2267
+ footer: true,
2268
+ elapsedStart: Date.now(),
2269
+ elapsedPrefix: prefix
2270
+ });
2271
+ }
2272
+ failRemaining(text) {
2273
+ for (const entry of this.entries) {
2274
+ if (entry.state === "running") this.resolve(entry, "failed", text);
2275
+ }
2276
+ }
2277
+ add(entry) {
2278
+ this.entries.push(entry);
2279
+ this.ensureTicking();
2280
+ return {
2281
+ get text() {
2282
+ return entry.text;
2283
+ },
2284
+ set text(value) {
2285
+ entry.text = value;
2286
+ },
2287
+ succeed: (text) => this.resolve(entry, "succeeded", text),
2288
+ fail: (text) => this.resolve(entry, "failed", text)
2289
+ };
2290
+ }
2291
+ resolve(entry, state, text) {
2292
+ if (entry.state !== "running") return;
2293
+ entry.state = state;
2294
+ if (text !== void 0) entry.text = text;
2295
+ entry.elapsedStart = void 0;
2296
+ appendReviewLog(renderEntry(entry, 0));
2297
+ this.render();
2298
+ this.maybeFinish();
2299
+ }
2300
+ ensureTicking() {
2301
+ if (this.timer || this.finished) return;
2302
+ this.render();
2303
+ this.timer = setInterval(() => {
2304
+ this.frame = (this.frame + 1) % SPINNER_FRAMES.length;
2305
+ this.render();
2306
+ }, TICK_MS);
2307
+ }
2308
+ render() {
2309
+ this.log(renderEntries(this.entries, this.frame));
2310
+ }
2311
+ maybeFinish() {
2312
+ if (this.entries.some((e) => e.state === "running")) return;
2313
+ if (this.timer) clearInterval(this.timer);
2314
+ this.timer = void 0;
2315
+ this.finished = true;
2316
+ this.render();
2317
+ this.log.done();
2318
+ }
2319
+ };
2320
+
2321
+ // src/commands/review/cachedReviewerResult.ts
2322
+ import { statSync } from "fs";
2323
+ function cachedReviewerResult(name2, outputPath) {
2324
+ let size;
2325
+ try {
2326
+ size = statSync(outputPath).size;
2327
+ } catch {
2328
+ return null;
2329
+ }
2330
+ if (size === 0) return null;
2331
+ console.log(`[${name2}] cached \u2192 ${outputPath} (${size} bytes)`);
2332
+ return { name: name2, outputPath, exitCode: 0, stderr: "" };
2333
+ }
2334
+
2335
+ // src/commands/review/reviewerAvailable.ts
2336
+ async function reviewerAvailable(slot) {
2337
+ const adapter = harnessAdapter(slot.harness);
2338
+ const resolution = resolveFeature(reviewerFeature, adapter);
2339
+ if (resolution.available) return true;
2340
+ const onlyUndetected = resolution.reasons.every(
2341
+ (r) => r.capability === "harness.detected"
2342
+ );
2343
+ if (onlyUndetected && adapter.offerInstall)
2344
+ return await adapter.offerInstall() && resolveFeature(reviewerFeature, adapter).available;
2345
+ console.log(
2346
+ formatUnavailable(
2347
+ `The ${slot.name} reviewer`,
2348
+ adapter.label,
2349
+ resolution.reasons
2350
+ )
2351
+ );
2352
+ return false;
2353
+ }
2354
+
2355
+ // src/commands/review/planReviewers.ts
2356
+ async function planReviewer(slot) {
2357
+ const cached = cachedReviewerResult(slot.name, slot.outputPath);
2358
+ if (cached) return { kind: "cached", cached };
2359
+ if (await reviewerAvailable(slot)) return { kind: "run" };
2360
+ console.log(`Skipping ${slot.name} reviewer.`);
2361
+ return { kind: "skipped" };
2362
+ }
2363
+ async function planReviewers(slots) {
2364
+ const planned = [];
2365
+ for (const slot of slots)
2366
+ planned.push({ slot, plan: await planReviewer(slot) });
2367
+ return planned;
2368
+ }
2369
+
2370
+ // src/commands/review/reviewerHarnesses.ts
2371
+ var reviewerHarnesses = [
2372
+ "claude",
2373
+ "codex"
2374
+ ];
2375
+ var reviewerNameWords = {
2376
+ claude: ["claude", "opus"],
2377
+ codex: ["codex"]
2378
+ };
2379
+
2380
+ // src/commands/review/reviewerSlots.ts
2381
+ function reviewerSlots(paths) {
2382
+ const outputPaths = {
2383
+ claude: paths.claudePath,
2384
+ codex: paths.codexPath
2385
+ };
2386
+ return reviewerHarnesses.map((harness) => ({
2387
+ name: harness,
2388
+ harness,
2389
+ outputPath: outputPaths[harness]
2390
+ }));
2391
+ }
2392
+
2393
+ // src/commands/review/buildReviewerStdin.ts
2394
+ var REVIEW_PROMPT = `You are acting as a reviewer for a proposed code change made by another engineer. The full review request \u2014 branch, base, changed files, and unified diff \u2014 is in the request file whose absolute path is given below.
2395
+
2396
+ Your working directory is the repository under review, so you can read any file in it for context beyond the diff.
2397
+
2398
+ Read the request file, then produce a thorough code review in Markdown.
2399
+
2400
+ ## When to flag a finding
2401
+
2402
+ A finding is worth raising only if all of the following hold:
2403
+
2404
+ 1. It meaningfully impacts the accuracy, performance, security, or maintainability of the code.
2405
+ 2. The issue is discrete and actionable \u2014 not a vague observation about the codebase or a tangle of several things.
2406
+ 3. Fixing it does not demand more rigour than the rest of the codebase already shows (e.g. don't ask for exhaustive input validation in a repo of one-off scripts).
2407
+ 4. The issue was introduced by this change. Do not flag pre-existing bugs.
2408
+ 5. The original author would likely fix it if made aware.
2409
+ 6. It does not rely on unstated assumptions about the codebase or author's intent.
2410
+ 7. You can name the concretely affected code path. Speculation that a change *might* disrupt something elsewhere is not enough \u2014 identify the other code that is provably affected.
2411
+ 8. It is clearly not an intentional change by the author.
2412
+
2413
+ ## Never recommend adding a code comment
2414
+
2415
+ This codebase enforces self-documenting code. Never raise a finding whose recommendation is to add a code comment \u2014 including a comment that restates what the code does, labels a block, or narrates why the change was made. The absence of comments is never a defect: do not ask for explanatory comments, doc comments, or TODOs, and do not list "missing comments" as an observation.
2416
+
2417
+ Two cases are still legitimate findings:
2418
+
2419
+ 1. A comment this change made stale or wrong. Recommend removing or correcting it.
2420
+ 2. Genuinely misleading code. You may raise it, but the recommendation must be a clearer name, a smaller function, or a test. Only as a last resort, when none of those can carry the meaning, may you mention that \`assist code-comment\` exists for a single short comment.
2421
+
2422
+ ## Tautological and vacuous tests
2423
+
2424
+ Flag tests added or changed by this change that cannot fail when the behaviour they claim to cover breaks. Do not flag pre-existing tests the change left untouched. Patterns:
2425
+
2426
+ 1. Asserting a mock returns what it was stubbed to return.
2427
+ 2. Computing the expected value with the code under test, or with a copy of its logic.
2428
+ 3. Asserting only that a mocked function was called, when that mock is the whole subject of the test.
2429
+ 4. Any test that would still pass if the implementation were broken.
2430
+ 5. No assertions, or only \`toBeDefined\`/truthy checks.
2431
+ 6. Snapshots of mocked output.
2432
+
2433
+ Recommendation: assert against an independent expected value (a literal or a hand-derived result) or real behaviour, or delete the test. Severity is **minor** by default; **major** when the test is the sole coverage of a behaviour this change introduces or modifies, since that behaviour is then effectively untested.
2434
+
2435
+ ## How to write the comment (Impact + Recommendation)
2436
+
2437
+ 1. Make clear *why* the issue is a bug.
2438
+ 2. Communicate severity accurately \u2014 do not inflate.
2439
+ 3. Keep it brief: at most one paragraph of prose. Avoid line breaks inside the natural-language flow unless needed for a code fragment.
2440
+ 4. Do not paste code chunks longer than 3 lines. Wrap short snippets in inline code or a fenced block.
2441
+ 5. State explicitly the scenarios, environments, or inputs needed for the bug to manifest \u2014 and signal up front that severity depends on those factors.
2442
+ 6. Tone is matter-of-fact: not accusatory, not gushing. Read as a helpful assistant, not a performative human reviewer.
2443
+ 7. Write so the author grasps the point on first read.
2444
+ 8. Avoid flattery and filler ("Great job\u2026", "Thanks for\u2026"). They are not useful to the author.
2445
+
2446
+ Ignore trivial style unless it obscures meaning or violates a documented standard. One finding per distinct issue.
2447
+
2448
+ ## How many findings to return
2449
+
2450
+ List every finding that the original author would want to know about and fix. Do not stop at the first qualifying one. If nothing clears the bar above, return no findings \u2014 empty is better than padded.
2451
+
2452
+ ## Output format
2453
+
2454
+ For each finding include:
2455
+ - Severity (blocker, major, minor, nit) \u2014 see rubric below
2456
+ - File and line (e.g. \`src/foo.ts:42\`) when the finding is tied to a specific location. Take the line number from the diff's left gutter (its line in the new file); never count lines in the request file.
2457
+ - Impact: what could go wrong, including the conditions under which it manifests
2458
+ - Recommendation: a concrete change
2459
+
2460
+ Severity rubric:
2461
+ - **blocker** \u2014 ships broken behaviour: crash, data loss, security hole, breaks the build or existing tests, or violates a stated requirement.
2462
+ - **major** \u2014 likely bug, missing error handling on a real failure mode, or a regression in existing behaviour. Not "this could be cleaner" or "this might be slow."
2463
+ - **minor** \u2014 narrow correctness or clarity issue with limited blast radius; worth fixing but not urgent.
2464
+ - **nit** \u2014 style, naming, micro-refactors, comment wording; reviewer would not block on it.
2465
+
2466
+ Default to the lower tier when uncertain. Code-style preferences, refactor suggestions, and "I would have written it differently" belong in nit \u2014 not major. A finding is only major if you can name a concrete failure mode or regression.
2467
+
2468
+ Group findings by severity. If you have no findings in a category, omit it. End with a short overall summary.
2469
+
2470
+ Output only the review Markdown. Do not include any preamble or commentary about the process.`;
2471
+ function buildReviewerStdin(requestPath) {
2472
+ return `${REVIEW_PROMPT}
2473
+
2474
+ The review request is at: ${requestPath}
2475
+ `;
2476
+ }
2477
+
2478
+ // src/shared/db/recordJobRun.ts
2479
+ async function recordJobRun(db, run) {
2480
+ await db.insert(jobRuns).values(run);
2481
+ }
2482
+
2483
+ // src/commands/review/recordReviewerRuns.ts
2484
+ function toJobRun(result, target, startedAt, now) {
2485
+ const durationMs = result.elapsedMs ?? now.getTime() - startedAt.getTime();
2486
+ const failed2 = result.exitCode !== 0;
2487
+ return {
2488
+ kind: "review",
2489
+ trigger: "manual",
2490
+ model: result.model ?? null,
2491
+ startedAt,
2492
+ finishedAt: new Date(startedAt.getTime() + durationMs),
2493
+ durationMs,
2494
+ inputTokens: result.usage?.input ?? 0,
2495
+ outputTokens: result.usage?.output ?? 0,
2496
+ cacheReadTokens: result.usage?.cacheRead ?? 0,
2497
+ cacheWriteTokens: result.usage?.cacheWrite ?? 0,
2498
+ costUsd: null,
2499
+ status: failed2 ? "failed" : "finished",
2500
+ detail: failed2 ? `exit ${result.exitCode}` : null,
2501
+ repo: target.repo,
2502
+ prNumber: target.prNumber,
2503
+ reviewer: result.name
2504
+ };
2505
+ }
2506
+ async function recordReviewerRuns(fresh, target, startedAt, openDb = getDb) {
2507
+ if (fresh.length === 0) return;
2508
+ const now = /* @__PURE__ */ new Date();
2509
+ try {
2510
+ const db = await openDb();
2511
+ for (const result of fresh)
2512
+ await recordJobRun(db, toJobRun(result, target, startedAt, now));
2513
+ } catch (error) {
2514
+ const message = error instanceof Error ? error.message : String(error);
2515
+ console.error(`Could not record reviewer runs: ${message}`);
2516
+ }
2517
+ }
2518
+
2519
+ // src/commands/review/runPlannedReviewer.ts
2520
+ function runPlannedReviewer({ slot, plan }, { reviewDir, stdin, multi }) {
2521
+ if (plan.kind === "cached") return Promise.resolve(plan.cached);
2522
+ if (plan.kind === "skipped")
2523
+ return Promise.resolve({
2524
+ name: slot.name,
2525
+ outputPath: slot.outputPath,
2526
+ exitCode: 0,
2527
+ stderr: "",
2528
+ skipped: true
2529
+ });
2530
+ return harnessAdapter(slot.harness).structured({
2531
+ name: slot.name,
2532
+ stdin,
2533
+ outputPath: slot.outputPath,
2534
+ readDir: reviewDir,
2535
+ model: reviewModel(slot.harness),
2536
+ spinner: multi && ((model) => multi.create(`${reviewerLabel(slot.name, model)} \u2014 starting`))
2537
+ });
2538
+ }
2539
+
2540
+ // src/commands/review/runReviewers.ts
2541
+ async function runReviewers(reviewers, context) {
2542
+ const results = await Promise.all(
2543
+ reviewers.map((reviewer) => runPlannedReviewer(reviewer, context))
2544
+ );
2545
+ return {
2546
+ results,
2547
+ anyFresh: reviewers.some(({ plan }) => plan.kind !== "cached"),
2548
+ fresh: results.filter((_, i) => reviewers[i].plan.kind === "run")
2549
+ };
2550
+ }
2551
+
2552
+ // src/commands/review/synthesiseAfterReviewers.ts
2553
+ import { existsSync as existsSync2, unlinkSync } from "fs";
2554
+
2555
+ // src/commands/review/synthesise.ts
2556
+ import { readFileSync as readFileSync3 } from "fs";
2557
+
2558
+ // src/commands/review/carriedUnanchoredFindings.ts
2559
+ function carriedUnanchoredFindings(unanchored) {
2560
+ return unanchored.filter((finding) => finding.source !== "already-raised");
2561
+ }
2562
+
2563
+ // src/commands/review/findingSourceValues.ts
2564
+ var findingSourceValues = [
2565
+ "confirmed",
2566
+ "disputed",
2567
+ ...reviewerHarnesses.map((harness) => `${harness}-only`),
2568
+ "already-raised"
2569
+ ];
2570
+ var findingSourceEnum = findingSourceValues.join(" | ");
2571
+
2572
+ // src/commands/review/parseFindings.ts
2573
+ var SEVERITIES = ["blocker", "major", "minor", "nit"];
2574
+ function isSeverity(value) {
2575
+ return SEVERITIES.includes(value);
2576
+ }
2577
+ function isSource(value) {
2578
+ return findingSourceValues.includes(value);
2579
+ }
2580
+ function extractField(block, field) {
2581
+ const re = new RegExp(`^-\\s+${field}:\\s*(.*)$`, "im");
2582
+ const match = block.match(re);
2583
+ return match ? match[1].trim() : "";
2584
+ }
2585
+ function stripBackticks(value) {
2586
+ return value.replace(/^`+|`+$/g, "").trim();
2587
+ }
2588
+ function parseFindingBlock(block) {
2589
+ const newlineIndex = block.indexOf("\n");
2590
+ const title = newlineIndex === -1 ? block.trim() : block.slice(0, newlineIndex).trim();
2591
+ const body = newlineIndex === -1 ? "" : block.slice(newlineIndex + 1);
2592
+ const severityRaw = extractField(body, "Severity").toLowerCase();
2593
+ const sourceRaw = extractField(body, "Source").toLowerCase();
2594
+ return {
2595
+ title,
2596
+ severity: isSeverity(severityRaw) ? severityRaw : null,
2597
+ source: isSource(sourceRaw) ? sourceRaw : null,
2598
+ location: stripBackticks(extractField(body, "Location")),
2599
+ impact: extractField(body, "Impact"),
2600
+ recommendation: extractField(body, "Recommendation")
2601
+ };
2602
+ }
2603
+ function parseFindings(markdown) {
2604
+ return markdown.split(/^###\s+Finding:\s*/m).slice(1).map(parseFindingBlock);
2605
+ }
2606
+
2607
+ // src/commands/review/summariseSynthesis.ts
2608
+ var SEVERITIES2 = ["blocker", "major", "minor", "nit"];
2609
+ function isSeverity2(value) {
2610
+ return SEVERITIES2.includes(value);
2611
+ }
2612
+ function extractSummary(markdown) {
2613
+ const match = markdown.match(
2614
+ /^##\s+Summary\s*\n([\s\S]*?)(?=\n##\s|\n###\s|$)/m
2615
+ );
2616
+ if (!match) return "";
2617
+ return match[1].trim();
2618
+ }
2619
+ function countBySeverity(markdown) {
2620
+ const totals = { blocker: 0, major: 0, minor: 0, nit: 0 };
2621
+ const regex = /^-\s+Severity:\s*([a-zA-Z]+)/gm;
2622
+ for (const match of markdown.matchAll(regex)) {
2623
+ const severity = match[1].toLowerCase();
2624
+ if (isSeverity2(severity)) totals[severity]++;
2625
+ }
2626
+ return totals;
2627
+ }
2628
+ function summariseSynthesis(markdown) {
2629
+ const totals = countBySeverity(markdown);
2630
+ const findingCount = totals.blocker + totals.major + totals.minor + totals.nit;
2631
+ return { summary: extractSummary(markdown), totals, findingCount };
2632
+ }
2633
+ function formatSynthesisSummary(summary) {
2634
+ const lines = [];
2635
+ const { totals, findingCount } = summary;
2636
+ lines.push(
2637
+ `Findings: ${findingCount} (blocker ${totals.blocker}, major ${totals.major}, minor ${totals.minor}, nit ${totals.nit})`
2638
+ );
2639
+ if (summary.summary) lines.push("", summary.summary);
2640
+ return lines.join("\n");
2641
+ }
2642
+
2643
+ // src/commands/review/buildReviewSummary.ts
2644
+ var UNANCHOR_REASONS = {
2645
+ "out-of-diff": "its line falls outside the PR diff",
2646
+ unlocated: "it has no parseable file:line",
2647
+ "comment-rejected": "GitHub rejected its line comment"
2648
+ };
2649
+ function formatFindingLine(finding) {
2650
+ const severity = finding.severity ?? "finding";
2651
+ return `- **${severity}: ${finding.title}**`;
2652
+ }
2653
+ function formatLocation(finding) {
2654
+ const location = finding.location.trim();
2655
+ if (!location || location.toLowerCase() === "n/a") return "no location";
2656
+ return `\`${location}\``;
2657
+ }
2658
+ function formatUnanchoredFinding(finding) {
2659
+ const lines = [
2660
+ `${formatFindingLine(finding)} \u2014 ${formatLocation(finding)}`,
2661
+ ` - Not anchored: ${UNANCHOR_REASONS[finding.reason]}`
2662
+ ];
2663
+ if (finding.impact) lines.push(` - Impact: ${finding.impact}`);
2664
+ if (finding.recommendation)
2665
+ lines.push(` - Recommendation: ${finding.recommendation}`);
2666
+ return lines;
2667
+ }
2668
+ function buildReviewSummary(markdown, unanchored = []) {
2669
+ const summary = summariseSynthesis(markdown);
2670
+ const findings2 = parseFindings(markdown);
2671
+ const lines = ["## Code review summary", "", formatSynthesisSummary(summary)];
2672
+ if (findings2.length > 0) {
2673
+ lines.push("", "### Findings", "");
2674
+ for (const finding of findings2) lines.push(formatFindingLine(finding));
2675
+ }
2676
+ const carried = carriedUnanchoredFindings(unanchored);
2677
+ if (carried.length > 0) {
2678
+ lines.push(
2679
+ "",
2680
+ "### Findings not anchored to the diff",
2681
+ "",
2682
+ "No line comment could be attached to these, so the detail is here instead.",
2683
+ ""
2684
+ );
2685
+ for (const finding of carried)
2686
+ lines.push(...formatUnanchoredFinding(finding));
2687
+ }
2688
+ return lines.join("\n");
2689
+ }
2690
+
2691
+ // src/commands/review/buildSynthesisStdin.ts
2692
+ var SYNTHESIS_PROMPT = `You are consolidating two independent code reviews of the same change. The original review request is in request.md. The two reviews are in claude.md and codex.md in the current working directory.
2693
+
2694
+ If either claude.md or codex.md does not exist on disk, that reviewer was skipped (its harness was unavailable). In that case, work from the other review alone; treat every finding as coming only from the reviewer that ran ('claude-only' or 'codex-only'), do not mark anything 'confirmed' or attribute anything to the skipped reviewer, and add a note in the Summary naming the reviewer that was skipped.
2695
+
2696
+ Read all available review files, deduplicate findings, and produce a single consolidated review in Markdown with this exact structure:
2697
+
2698
+ # Code review synthesis
2699
+
2700
+ ## Summary
2701
+
2702
+ A 2-3 sentence overall summary of the change's quality and the most important risks.
2703
+
2704
+ ## Findings
2705
+
2706
+ For each finding, emit one block in this exact format:
2707
+
2708
+ ### Finding: <short title>
2709
+ - Severity: blocker | major | minor | nit
2710
+ - Source: ${findingSourceEnum}
2711
+ - Location: \`path/to/file.ext:LINE\` or \`n/a\` when not tied to a specific line
2712
+ - Impact: one sentence on what could go wrong
2713
+ - Recommendation: one or two sentences with a concrete change
2714
+
2715
+ Severity rubric (recalibrate each finding against this \u2014 reviewers tend to inflate):
2716
+ - **blocker** \u2014 ships broken behaviour: crash, data loss, security hole, breaks the build or existing tests, or violates a stated requirement.
2717
+ - **major** \u2014 likely bug, missing error handling on a real failure mode, or a regression in existing behaviour. Not "this could be cleaner" or "this might be slow."
2718
+ - **minor** \u2014 narrow correctness or clarity issue with limited blast radius; worth fixing but not urgent.
2719
+ - **nit** \u2014 style, naming, micro-refactors, comment wording; reviewer would not block on it.
2720
+
2721
+ Default to the lower tier when uncertain. Code-style preferences, refactor suggestions, and "I would have written it differently" belong in nit \u2014 not major. A finding is only major if you can name a concrete failure mode or regression. If a reviewer marked something major but the impact reads as taste or hypothetical, downgrade it.
2722
+
2723
+ ## Keep tautological-test findings
2724
+
2725
+ A finding that a test added or changed by this change is tautological or vacuous \u2014 it asserts a mock returns its stub, computes its expected value with the code under test, only checks a mock was called, has no real assertions, snapshots mocked output, or would still pass if the implementation broke \u2014 is a legitimate defect, not taste. Keep it even when only one reviewer raised it, and do not downgrade it below minor. Keep major when the test is the sole coverage of a behaviour the change introduces or modifies.
2726
+
2727
+ Rules:
2728
+ - \`confirmed\` = both reviewers raised it.
2729
+ - \`disputed\` = the reviewers disagreed on the diagnosis or fix.
2730
+ - \`claude-only\` / \`codex-only\` = only one reviewer raised it.
2731
+ - \`already-raised\` = a prior review comment in request.md (under "Prior review comments") substantively covers this finding \u2014 same file, same defect or recommendation. Use this even when the prior thread is resolved or outdated. Cosmetic overlap is not enough; the prior comment must address the same underlying issue. Prefer \`already-raised\` over the other source values when it applies.
2732
+ - Order findings by severity (blocker, major, minor, nit), then by source (confirmed first).
2733
+ - If a finding has no specific file:line, set Location to \`n/a\` exactly.
2734
+ - Do not invent findings beyond what the two reviews support.
2735
+
2736
+ ## Drop comment-adding findings
2737
+
2738
+ This codebase enforces self-documenting code, so a recommendation to add a code comment cannot be applied. Omit from the consolidated output entirely any finding whose recommendation is to add a code comment \u2014 including a comment that restates what the code does, labels a block, or narrates why the change was made \u2014 and any finding whose defect is that comments are absent. Omit it, do not downgrade it to nit: drop it even when only one reviewer raised it, and even when both reviewers agreed on it.
2739
+
2740
+ Two cases survive consolidation and must be kept:
2741
+
2742
+ 1. A finding about a comment this change made stale or wrong, where the recommendation is to remove or correct it.
2743
+ 2. A finding about genuinely misleading code, where the recommendation is a clearer name, a smaller function, or a test. If the recommendation is instead to add a comment, drop it.
2744
+
2745
+ Output only the consolidated Markdown. No preamble, no commentary about your process.`;
2746
+ function buildSynthesisStdin(requestPath, claudePath, codexPath) {
2747
+ return `${SYNTHESIS_PROMPT}
2748
+
2749
+ Files:
2750
+ - Request: ${requestPath}
2751
+ - Claude review: ${claudePath}
2752
+ - Codex review: ${codexPath}
2753
+ `;
2754
+ }
2755
+
2756
+ // src/commands/review/synthesise.ts
2757
+ function printSummary(synthesisPath) {
2758
+ const markdown = readFileSync3(synthesisPath, "utf8");
2759
+ console.log("");
2760
+ console.log(buildReviewSummary(markdown));
2761
+ console.log("");
2762
+ }
2763
+ async function synthesise(paths, options) {
2764
+ const cached = cachedReviewerResult("synthesis", paths.synthesisPath);
2765
+ if (cached) {
2766
+ printSummary(paths.synthesisPath);
2767
+ return cached;
2768
+ }
2769
+ const result = await runSynthesisReviewer({
2770
+ harness: resolveSynthesisHarness(),
2771
+ reviewDir: paths.reviewDir,
2772
+ stdin: buildSynthesisStdin(
2773
+ paths.requestPath,
2774
+ paths.claudePath,
2775
+ paths.codexPath
2776
+ ),
2777
+ outputPath: paths.synthesisPath,
2778
+ multi: options.multi
2779
+ });
2780
+ if (result.exitCode === 0) printSummary(paths.synthesisPath);
2781
+ return result;
2782
+ }
2783
+
2784
+ // src/commands/review/synthesiseAfterReviewers.ts
2785
+ async function synthesiseAfterReviewers(input) {
2786
+ const { paths, failures } = input;
2787
+ if (input.anyFresh && existsSync2(paths.synthesisPath)) {
2788
+ unlinkSync(paths.synthesisPath);
2789
+ }
2790
+ const synthesisResult = await synthesise(paths, { multi: input.multi });
2791
+ if (synthesisResult.exitCode !== 0) failures.push(synthesisResult);
2792
+ return {
2793
+ ok: synthesisResult.exitCode === 0,
2794
+ failures,
2795
+ slots: [...input.results, synthesisResult]
2796
+ };
2797
+ }
2798
+
2799
+ // src/commands/review/skipReason.ts
2800
+ function skipReason(results, failures) {
2801
+ if (failures.length === results.length)
2802
+ return "Both reviewers failed; skipping synthesis.";
2803
+ if (results.every((r) => r.exitCode !== 0 || r.skipped))
2804
+ return "No reviewer produced a review; skipping synthesis.";
2805
+ return void 0;
2806
+ }
2807
+
2808
+ // src/commands/review/runAndSynthesise.ts
2809
+ function failed(results) {
2810
+ return results.filter((r) => r.exitCode !== 0);
2811
+ }
2812
+ async function runAndSynthesise(args) {
2813
+ const { paths, multi } = args;
2814
+ const startedAt = /* @__PURE__ */ new Date();
2815
+ const { results, anyFresh, fresh } = await runReviewers(args.reviewers, {
2816
+ reviewDir: paths.reviewDir,
2817
+ stdin: buildReviewerStdin(paths.requestPath),
2818
+ multi
2819
+ });
2820
+ if (args.job) await recordReviewerRuns(fresh, args.job, startedAt);
2821
+ const failures = failed(results);
2822
+ const reason = skipReason(results, failures);
2823
+ if (reason) {
2824
+ console.error(reason);
2825
+ return { ok: false, failures, slots: results };
2826
+ }
2827
+ return synthesiseAfterReviewers({
2828
+ paths,
2829
+ results,
2830
+ failures,
2831
+ anyFresh,
2832
+ multi
2833
+ });
2834
+ }
2835
+
2836
+ // src/commands/review/useSpinnerUi.ts
2837
+ function useSpinnerUi(verbose) {
2838
+ if (verbose) return false;
2839
+ return Boolean(process.stdout.isTTY);
2840
+ }
2841
+
2842
+ // src/commands/review/printReviewerFailures.ts
2843
+ function printReviewerFailures(results) {
2844
+ for (const r of results) printReviewerFailure(r);
2845
+ }
2846
+
2847
+ // src/commands/review/reportFailures.ts
2848
+ function reportFailures(failures, usingSpinner) {
2849
+ if (failures.length === 0) return;
2850
+ if (!usingSpinner) return;
2851
+ printReviewerFailures(failures);
2852
+ }
2853
+
2854
+ // src/commands/review/runReviewPipeline.ts
2855
+ function createUi(spinnerUi) {
2856
+ const startedAt = Date.now();
2857
+ if (!spinnerUi) return { multi: void 0, elapsed: void 0, startedAt };
2858
+ const multi = new MultiSpinner();
2859
+ return { multi, elapsed: multi.addElapsed("total"), startedAt };
2860
+ }
2861
+ function finishUi(ui, ok) {
2862
+ if (!ui.elapsed) return;
2863
+ const seconds = Math.round((Date.now() - ui.startedAt) / 1e3);
2864
+ const label = `total: ${seconds}s`;
2865
+ if (ok) ui.elapsed.succeed(label);
2866
+ else ui.elapsed.fail(label);
2867
+ }
2868
+ async function runReviewPipeline(paths, options) {
2869
+ const reviewers = await planReviewers(reviewerSlots(paths));
2870
+ const ui = createUi(useSpinnerUi(options.verbose));
2871
+ try {
2872
+ const outcome = await runAndSynthesise({
2873
+ paths,
2874
+ reviewers,
2875
+ multi: ui.multi,
2876
+ job: options.job
2877
+ });
2878
+ finishUi(ui, outcome.ok);
2879
+ reportFailures(outcome.failures, ui.multi !== void 0);
2880
+ return outcome;
2881
+ } catch (error) {
2882
+ ui.multi?.failRemaining();
2883
+ throw error;
2884
+ }
2885
+ }
2886
+
2887
+ // src/commands/review/annotateDiffWithLineNumbers.ts
2888
+ var FILE_HEADER = /^\+\+\+ (?:b\/)?(.+)$/;
2889
+ var HUNK_HEADER3 = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
2890
+ var GUTTER_WIDTH = 6;
2891
+ function gutter(lineNumber) {
2892
+ const label = lineNumber === null ? "" : String(lineNumber);
2893
+ return `${label.padStart(GUTTER_WIDTH, " ")} `;
2894
+ }
2895
+ function annotateDiffWithLineNumbers(diff) {
2896
+ let inFile = false;
2897
+ let newLine = 0;
2898
+ return diff.split("\n").map((line) => {
2899
+ if (FILE_HEADER.test(line)) {
2900
+ inFile = true;
2901
+ return gutter(null) + line;
2902
+ }
2903
+ const hunkMatch = line.match(HUNK_HEADER3);
2904
+ if (hunkMatch) {
2905
+ newLine = Number(hunkMatch[1]);
2906
+ return gutter(null) + line;
2907
+ }
2908
+ if (!inFile) return gutter(null) + line;
2909
+ if (line.startsWith("+") || line.startsWith(" ")) {
2910
+ const annotated = gutter(newLine) + line;
2911
+ newLine++;
2912
+ return annotated;
2913
+ }
2914
+ return gutter(null) + line;
2915
+ }).join("\n");
2916
+ }
2917
+
2918
+ // src/commands/review/formatPriorComments.ts
2919
+ function threadKey(c, byId) {
2920
+ if (c.threadId) return c.threadId;
2921
+ if (c.inReplyToId !== null && byId.has(c.inReplyToId)) {
2922
+ return `root-${c.inReplyToId}`;
2923
+ }
2924
+ return `root-${c.id}`;
2925
+ }
2926
+ function groupIntoThreads(comments) {
2927
+ const byId = new Map(comments.map((c) => [c.id, c]));
2928
+ const threads = /* @__PURE__ */ new Map();
2929
+ for (const c of comments) {
2930
+ const key = threadKey(c, byId);
2931
+ const existing = threads.get(key);
2932
+ const parent = c.inReplyToId !== null ? byId.get(c.inReplyToId) : void 0;
2933
+ if (existing) {
2934
+ if (parent) existing.replies.push(c);
2935
+ } else if (parent) {
2936
+ threads.set(key, { root: parent, replies: [c] });
2937
+ } else {
2938
+ threads.set(key, { root: c, replies: [] });
2939
+ }
2940
+ }
2941
+ return [...threads.values()];
2942
+ }
2943
+ function headerFor(c) {
2944
+ const location = c.line !== null ? `${c.file}:${c.line}` : c.file;
2945
+ const tags = [c.resolved && "resolved", c.outdated && "outdated"].filter(Boolean).join(", ");
2946
+ return tags ? `### ${location} [${tags}]` : `### ${location}`;
2947
+ }
2948
+ function formatThread(thread) {
2949
+ const lines = [
2950
+ headerFor(thread.root),
2951
+ `**${thread.root.author}**: ${thread.root.body.trim()}`,
2952
+ ...thread.replies.map((r) => `**${r.author}** (reply): ${r.body.trim()}`)
2953
+ ];
2954
+ return lines.join("\n\n");
2955
+ }
2956
+ var INTRO = `The PR already has the review comments below (including resolved and outdated threads). Avoid re-raising findings that a prior comment substantively covers.`;
2957
+ function formatPriorComments(comments) {
2958
+ if (comments.length === 0) return "";
2959
+ const blocks = groupIntoThreads(comments).map(formatThread);
2960
+ return `## Prior review comments
2961
+
2962
+ ${INTRO}
2963
+
2964
+ ${blocks.join("\n\n")}`;
2965
+ }
2966
+
2967
+ // src/commands/review/buildRequest.ts
2968
+ function formatFiles(files) {
2969
+ if (files.length === 0) return "(none)";
2970
+ return files.map((file) => `- ${file}`).join("\n");
2971
+ }
2972
+ function buildRequest(context, priorComments = null) {
2973
+ const priorSection = priorComments ? formatPriorComments(priorComments) : "";
2974
+ const priorBlock = priorSection ? `
2975
+ ${priorSection}
2976
+ ` : "";
2977
+ return `# Code review request
2978
+
2979
+ - PR: #${context.prNumber}
2980
+ - Branch: \`${context.branch}\` (head ref: \`${context.headRef}\`)
2981
+ - Base ref: \`${context.baseRef}\`
2982
+ - Base SHA: \`${context.baseSha}\`
2983
+ - Head SHA: \`${context.headSha}\`
2984
+
2985
+ ## Changed files
2986
+
2987
+ ${formatFiles(context.changedFiles)}
2988
+ ${priorBlock}
2989
+ ## Diff (PR #${context.prNumber}: ${context.baseSha}..${context.headSha})
2990
+
2991
+ Each added or context line is prefixed with a left gutter showing its line number in the new file. When citing a finding as \`file:line\`, use that gutter number \u2014 do **not** count lines in this document. Removed lines (\`-\`) and headers have a blank gutter and cannot be commented on.
2992
+
2993
+ \`\`\`diff
2994
+ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
2995
+ \`\`\`
2996
+ `;
2997
+ }
2998
+
2999
+ // src/commands/review/buildReviewPaths.ts
3000
+ import { homedir } from "os";
3001
+ import { basename as basename2, join as join3 } from "path";
3002
+ function buildReviewPaths(repoRoot, key) {
3003
+ const reviewDir = join3(
3004
+ homedir(),
3005
+ ".assist",
3006
+ "reviews",
3007
+ basename2(repoRoot),
3008
+ key
3009
+ );
3010
+ return {
3011
+ reviewDir,
3012
+ requestPath: join3(reviewDir, "request.md"),
3013
+ claudePath: join3(reviewDir, "claude.md"),
3014
+ codexPath: join3(reviewDir, "codex.md"),
3015
+ synthesisPath: join3(reviewDir, "synthesis.md")
3016
+ };
3017
+ }
3018
+
3019
+ // src/commands/review/fetchExistingComments.ts
3020
+ import { execSync as execSync2 } from "child_process";
3021
+ function fetchRawComments(org, repo, prNumber) {
3022
+ const out = execSync2(
3023
+ `gh api --paginate repos/${org}/${repo}/pulls/${prNumber}/comments`,
3024
+ { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }
3025
+ );
3026
+ if (!out.trim()) return [];
3027
+ return JSON.parse(out);
3028
+ }
3029
+ function fetchExistingComments() {
3030
+ const prNumber = findCurrentPrNumber();
3031
+ if (prNumber === null) return null;
3032
+ const { org, repo } = getRepoInfo();
3033
+ const raw = fetchRawComments(org, repo, prNumber);
3034
+ if (raw.length === 0) return [];
3035
+ const threadInfo = fetchThreadIds(org, repo, prNumber);
3036
+ return raw.map((c) => {
3037
+ const threadId = threadInfo.threadMap.get(c.id) ?? "";
3038
+ return {
3039
+ id: c.id,
3040
+ threadId,
3041
+ file: c.path,
3042
+ line: c.line ?? c.original_line ?? null,
3043
+ author: c.user.login,
3044
+ body: c.body,
3045
+ inReplyToId: c.in_reply_to_id ?? null,
3046
+ resolved: threadId !== "" && threadInfo.resolvedThreadIds.has(threadId),
3047
+ outdated: c.position === null
3048
+ };
3049
+ });
3050
+ }
3051
+
3052
+ // src/commands/review/prepareReviewDir.ts
3053
+ import { existsSync as existsSync3, mkdirSync as mkdirSync3, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "fs";
3054
+ function clearReviewFiles(paths) {
3055
+ for (const path of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
3056
+ if (existsSync3(path)) unlinkSync2(path);
3057
+ }
3058
+ }
3059
+ function prepareReviewDir(paths, requestBody, force) {
3060
+ mkdirSync3(paths.reviewDir, { recursive: true });
3061
+ if (force) clearReviewFiles(paths);
3062
+ writeFileSync2(paths.requestPath, requestBody);
3063
+ }
3064
+
3065
+ // src/commands/review/setupReviewDir.ts
3066
+ function setupReviewDir(repoRoot, context, force) {
3067
+ const paths = buildReviewPaths(
3068
+ repoRoot,
3069
+ `${context.branch}-${context.shortSha}`
3070
+ );
3071
+ const priorComments = fetchExistingComments();
3072
+ logPriorComments(priorComments?.length ?? 0);
3073
+ prepareReviewDir(paths, buildRequest(context, priorComments), force);
3074
+ console.log(`Review folder: ${paths.reviewDir}`);
3075
+ return paths;
3076
+ }
3077
+ function logPriorComments(count) {
3078
+ if (count === 0) return;
3079
+ console.log(`Including ${count} prior review comment(s) in request.md.`);
3080
+ }
3081
+
3082
+ // src/commands/review/gatherContext.ts
3083
+ import { execSync as execSync5 } from "child_process";
3084
+
3085
+ // src/commands/review/fetchPrDiff.ts
3086
+ import { execSync as execSync3 } from "child_process";
3087
+ function fetchPrDiff(prNumber, baseSha, headSha) {
3088
+ const { org, repo } = getRepoInfo();
3089
+ try {
3090
+ return execSync3(`gh pr diff ${prNumber} -R ${org}/${repo}`, {
3091
+ encoding: "utf8",
3092
+ maxBuffer: 256 * 1024 * 1024,
3093
+ stdio: ["ignore", "pipe", "pipe"]
3094
+ });
3095
+ } catch (error) {
3096
+ if (!isDiffTooLarge(error)) throw error;
3097
+ return fetchDiffViaGit(baseSha, headSha);
3098
+ }
3099
+ }
3100
+ function isDiffTooLarge(error) {
3101
+ return error instanceof Error && (error.message.includes("too_large") || error.message.includes("maximum number of files"));
3102
+ }
3103
+ function fetchDiffViaGit(baseSha, headSha) {
3104
+ try {
3105
+ execSync3(`git fetch origin ${baseSha} ${headSha}`, { stdio: "ignore" });
3106
+ } catch {
3107
+ }
3108
+ return execSync3(`git diff ${baseSha}...${headSha}`, {
3109
+ encoding: "utf8",
3110
+ maxBuffer: 256 * 1024 * 1024
3111
+ });
3112
+ }
3113
+
3114
+ // src/commands/review/fetchPrDiffInfo.ts
3115
+ import { execSync as execSync4 } from "child_process";
3116
+ function getCurrentBranch() {
3117
+ return execSync4("git rev-parse --abbrev-ref HEAD", {
3118
+ encoding: "utf8"
3119
+ }).trim();
3120
+ }
3121
+ var FIELDS = "number,baseRefName,baseRefOid,headRefName,headRefOid";
3122
+ function runGh(command) {
3123
+ return execSync4(command, {
3124
+ encoding: "utf8",
3125
+ stdio: ["ignore", "pipe", "pipe"]
3126
+ });
3127
+ }
3128
+ function fetchRawPr(org, repo, branch) {
3129
+ const parsed = JSON.parse(
3130
+ runGh(
3131
+ `gh pr list --state open --head ${branch} --json ${FIELDS} -R ${org}/${repo}`
3132
+ )
3133
+ );
3134
+ return parsed[0];
3135
+ }
3136
+ function fetchPrDiffInfo() {
3137
+ const { org, repo } = getRepoInfo();
3138
+ const branch = getCurrentBranch();
3139
+ const pr = fetchRawPr(org, repo, branch);
3140
+ if (!pr) {
3141
+ console.error(
3142
+ `Error: No open pull request found for branch \`${branch}\`. Open a PR for this branch before running \`assist review\`.`
3143
+ );
3144
+ process.exit(1);
3145
+ }
3146
+ return {
3147
+ prNumber: pr.number,
3148
+ baseRef: pr.baseRefName,
3149
+ baseSha: pr.baseRefOid,
3150
+ headRef: pr.headRefName,
3151
+ headSha: pr.headRefOid
3152
+ };
3153
+ }
3154
+ function fetchPrChangedFiles(prNumber) {
3155
+ const { org, repo } = getRepoInfo();
3156
+ const out = execSync4(
3157
+ `gh api repos/${org}/${repo}/pulls/${prNumber}/files --paginate --jq ".[].filename"`,
3158
+ {
3159
+ encoding: "utf8",
3160
+ maxBuffer: 64 * 1024 * 1024
3161
+ }
3162
+ );
3163
+ return out.trim().split("\n").filter(Boolean);
3164
+ }
3165
+
3166
+ // src/commands/review/gatherContext.ts
3167
+ function gatherContext() {
3168
+ const branch = execSync5("git rev-parse --abbrev-ref HEAD", {
3169
+ encoding: "utf8"
3170
+ }).trim();
3171
+ const sha = execSync5("git rev-parse HEAD", { encoding: "utf8" }).trim();
3172
+ const shortSha = execSync5("git rev-parse --short=7 HEAD", {
3173
+ encoding: "utf8"
3174
+ }).trim();
3175
+ const prInfo = fetchPrDiffInfo();
3176
+ const changedFiles = fetchPrChangedFiles(prInfo.prNumber);
3177
+ const diff = fetchPrDiff(prInfo.prNumber, prInfo.baseSha, prInfo.headSha);
3178
+ return {
3179
+ branch,
3180
+ sha,
3181
+ shortSha,
3182
+ prNumber: prInfo.prNumber,
3183
+ baseRef: prInfo.baseRef,
3184
+ baseSha: prInfo.baseSha,
3185
+ headRef: prInfo.headRef,
3186
+ headSha: prInfo.headSha,
3187
+ changedFiles,
3188
+ diff
3189
+ };
3190
+ }
3191
+
3192
+ // src/commands/review/gatherChangedContext.ts
3193
+ function gatherChangedContext() {
3194
+ const context = gatherContext();
3195
+ if (context.changedFiles.length > 0) return context;
3196
+ console.error(
3197
+ `Error: PR #${context.prNumber} has no changed files \u2014 nothing to review.`
3198
+ );
3199
+ process.exit(1);
3200
+ }
3201
+
3202
+ // src/commands/review/applySession.ts
3203
+ function buildApplyPrompt(synthesisPath) {
3204
+ return `You are helping the user apply fixes for a code review with each finding decided one at a time.
3205
+
3206
+ Read ${synthesisPath}. It contains a list of findings under the \`## Findings\` heading. Each finding is a block in this exact format:
3207
+
3208
+ ### Finding: <short title>
3209
+ - Severity: blocker | major | minor | nit
3210
+ - Source: ${findingSourceEnum}
3211
+ - Location: \`path/to/file.ext:LINE\` or \`n/a\` when not tied to a specific line
3212
+ - Impact: one sentence on what could go wrong
3213
+ - Recommendation: one or two sentences with a concrete change
3214
+
3215
+ For every finding whose Source is NOT \`already-raised\`, walk through it with the user one at a time:
3216
+ 1. Read the referenced file/lines (use the Location field) and any nearby code needed to understand the impact.
3217
+ 2. Present a short assessment (one or two sentences) of whether the finding is real and what the right fix is.
3218
+ 3. Ask the user: apply or skip?
3219
+ - On 'apply': edit the relevant file(s) in place to fix the issue, then remove that finding's entire \`### Finding:\` block from ${synthesisPath} (including any blank line that separated it from the next block).
3220
+ - On 'skip': leave the finding block in ${synthesisPath} unchanged and move on.
3221
+
3222
+ Skip findings whose Source is \`already-raised\` entirely \u2014 do not present them and do not remove them from ${synthesisPath}.
3223
+
3224
+ Important constraints:
3225
+ - Do not stage, commit, or push any changes. Leave all code edits unstaged in the working tree.
3226
+ - Do not post anything to a PR.
3227
+ - Only modify ${synthesisPath} by removing the blocks for findings the user chose to apply. Do not edit the wording of any remaining finding block.
3228
+ - When every non-already-raised finding has been decided, briefly summarise what was applied vs skipped and exit.`;
3229
+ }
3230
+ var applySession = {
3231
+ feature: reviewApplyFeature,
3232
+ launch: (adapter, synthesisPath) => adapter.launchPrompt(buildApplyPrompt(synthesisPath), {
3233
+ cwd: process.cwd(),
3234
+ allowEdits: true
3235
+ })
3236
+ };
3237
+
3238
+ // src/commands/review/backlogSession.ts
3239
+ function buildBacklogArgs(synthesisPath) {
3240
+ return `add each finding in ${synthesisPath} as a phase
3241
+
3242
+ Read ${synthesisPath}. It contains a list of findings under the \`## Findings\` heading, each in a \`### Finding:\` block with Severity, Source, Location, Impact, and Recommendation fields.
3243
+
3244
+ File ONE bug backlog item covering the review findings:
3245
+ - Include EVERY finding in the file as a phase on that single item \u2014 including findings whose Source is \`already-raised\`.
3246
+ - Each phase should be named after its finding's title and its tasks should capture the finding's Location, Impact, and Recommendation.
3247
+ - File the item with \`assist backlog propose\`, then apply the whole plan with a single \`assist backlog update-plan <id> --json -\` call whose payload lists every finding as a phase. Do not run \`assist backlog add-phase\` per finding \u2014 the plan lands in one preview, or not at all.
3248
+
3249
+ Important constraints:
3250
+ - Do not edit ${synthesisPath} \u2014 leave it untouched.
3251
+ - Do not post anything to a PR.
3252
+ - Do not stage, commit, or push any changes.`;
3253
+ }
3254
+ var backlogSession = {
3255
+ feature: reviewBacklogFeature,
3256
+ launch: (adapter, synthesisPath) => adapter.launchSkill("bug", buildBacklogArgs(synthesisPath), {
3257
+ cwd: process.cwd(),
3258
+ allowEdits: true
3259
+ })
3260
+ };
3261
+
3262
+ // src/commands/review/refineSession.ts
3263
+ function buildRefinePrompt(synthesisPath) {
3264
+ return `You are refining a code review synthesis with the user.
3265
+
3266
+ Read ${synthesisPath} and walk the user through each finding one at a time. Before asking the user what to do with a finding, do some investigation so you can give an informed opinion:
3267
+ - Read the referenced file/lines (use the Location field) to confirm the issue is real and current.
3268
+ - Check nearby code, callers, or related files when the impact depends on context.
3269
+ - Form a view on whether the finding is applicable, whether the stated severity is right, and whether the recommendation actually fixes the problem.
3270
+
3271
+ Then present your assessment briefly (one or two sentences) and ask the user whether to keep it as-is, edit it (e.g. adjust severity, sharpen the recommendation), or drop it. After all existing findings are reviewed, ask whether to add any new findings.
3272
+
3273
+ Edit ${synthesisPath} in place so the resulting file is the user's final list:
3274
+ - To drop a finding, remove its entire \`### Finding:\` block.
3275
+ - To edit a finding, modify only the fields the user wants changed.
3276
+ - To add a new finding, append a block in the exact format below under the \`## Findings\` heading.
3277
+
3278
+ Each finding block must use this exact format so it parses correctly:
3279
+
3280
+ ### Finding: <short title>
3281
+ - Severity: blocker | major | minor | nit
3282
+ - Source: ${findingSourceEnum}
3283
+ - Location: \`path/to/file.ext:LINE\` or \`n/a\` when not tied to a specific line
3284
+ - Impact: one sentence on what could go wrong
3285
+ - Recommendation: one or two sentences with a concrete change
3286
+
3287
+ User-supplied findings should use Source: \`confirmed\`. Use Location \`n/a\` only when the finding is not tied to a specific line.
3288
+
3289
+ Do not post anything to a PR; only edit ${synthesisPath}. When the user is done, exit.`;
3290
+ }
3291
+ var refineSession = {
3292
+ feature: reviewRefineFeature,
3293
+ launch: (adapter, synthesisPath) => adapter.launchPrompt(buildRefinePrompt(synthesisPath), {
3294
+ cwd: process.cwd(),
3295
+ allowEdits: true
3296
+ })
3297
+ };
3298
+
3299
+ // src/commands/review/postSynthesisSession.ts
3300
+ function postSynthesisSession(modes) {
3301
+ if (modes.backlog) return backlogSession;
3302
+ if (modes.apply) return applySession;
3303
+ if (modes.refine) return refineSession;
3304
+ return null;
3305
+ }
3306
+
3307
+ // src/commands/review/postReviewToPr.ts
3308
+ import { readFileSync as readFileSync4 } from "fs";
3309
+
3310
+ // src/commands/review/chainAddressComments.ts
3311
+ function chainAddressComments(prNumber, announce, harness) {
3312
+ const args = ["review-pr-comments", String(prNumber)];
3313
+ if (harness) args.push("--harness", harness);
3314
+ if (announce) args.push("--announce");
3315
+ return startChainedSession(
3316
+ `an Address Comments session for PR #${prNumber}`,
3317
+ () => requestAssistSession(args, process.cwd(), { inPlace: true })
3318
+ );
3319
+ }
3320
+
3321
+ // src/commands/review/chainAfterReview.ts
3322
+ async function chainAfterReview(prNumber, outcome, options) {
3323
+ const raisedComments = outcome.posted > 0 && outcome.submitted;
3324
+ if (options.addressComments && raisedComments) {
3325
+ await chainAddressComments(prNumber, options.announce, options.harness);
3326
+ return;
3327
+ }
3328
+ if (options.announce) await announcePr(prNumber);
3329
+ }
3330
+
3331
+ // src/commands/review/sanitiseReviewerNames.ts
3332
+ var REVIEWER_LABEL = "the reviewer";
3333
+ var NAME_PATTERNS = reviewerHarnesses.flatMap((harness) => reviewerNameWords[harness]).map((word) => new RegExp(`\\b${word}\\b`, "gi"));
3334
+ function sanitiseReviewerNames(value) {
3335
+ return NAME_PATTERNS.reduce(
3336
+ (text, pattern) => text.replace(pattern, REVIEWER_LABEL),
3337
+ value
3338
+ );
3339
+ }
3340
+
3341
+ // src/commands/review/postFindings.ts
3342
+ function buildCommentBody(finding) {
3343
+ const lines = [];
3344
+ const severityLabel = finding.severity ?? "finding";
3345
+ lines.push(`**${severityLabel}: ${finding.title}**`);
3346
+ if (finding.impact) lines.push("", `Impact: ${finding.impact}`);
3347
+ if (finding.recommendation)
3348
+ lines.push("", `Recommendation: ${finding.recommendation}`);
3349
+ return sanitiseReviewerNames(lines.join("\n"));
3350
+ }
3351
+ async function postFindings(findings2) {
3352
+ let posted = 0;
3353
+ const failed2 = [];
3354
+ for (const finding of findings2) {
3355
+ const body = buildCommentBody(finding);
3356
+ try {
3357
+ await comment(finding.file, finding.line, body, {
3358
+ startLine: finding.startLine,
3359
+ skipPreview: true
3360
+ });
3361
+ posted++;
3362
+ } catch (error) {
3363
+ failed2.push(finding);
3364
+ const message = error instanceof Error ? error.message : String(error);
3365
+ console.error(
3366
+ `Failed to post comment on ${finding.file}:${finding.line}: ${message}`
3367
+ );
3368
+ }
3369
+ }
3370
+ return { posted, failed: failed2 };
3371
+ }
3372
+
3373
+ // src/commands/review/buildReviewBody.ts
3374
+ function buildReviewBody(markdown, unanchored) {
3375
+ return sanitiseReviewerNames(buildReviewSummary(markdown, unanchored));
3376
+ }
3377
+
3378
+ // src/commands/review/runReviewSubmission.ts
3379
+ function runReviewSubmission(mutation, body) {
3380
+ try {
3381
+ const prId = getCurrentPrNodeId();
3382
+ runGhGraphql(mutation, { prId, body });
3383
+ console.log("Submitted review.");
3384
+ return true;
3385
+ } catch (error) {
3386
+ if (isGhNotInstalled(error)) {
3387
+ console.error("Error: GitHub CLI (gh) is not installed.");
3388
+ return false;
3389
+ }
3390
+ const message = error instanceof Error ? error.message : String(error);
3391
+ console.error(`Failed to submit review: ${message}`);
3392
+ return false;
3393
+ }
3394
+ }
3395
+
3396
+ // src/commands/review/submitBodyOnlyReview.ts
3397
+ var MUTATION = `mutation($prId: ID!, $body: String) { addPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
3398
+ function submitBodyOnlyReview(body) {
3399
+ return runReviewSubmission(MUTATION, body);
3400
+ }
3401
+
3402
+ // src/commands/review/submitPendingReview.ts
3403
+ var MUTATION2 = `mutation($prId: ID!, $body: String) { submitPullRequestReview(input: { pullRequestId: $prId, event: COMMENT, body: $body }) { pullRequestReview { id } } }`;
3404
+ function submitPendingReview(body) {
3405
+ return runReviewSubmission(MUTATION2, body);
3406
+ }
3407
+
3408
+ // src/commands/review/submitReview.ts
3409
+ function submitReview(body, result) {
3410
+ if (result.posted > 0) return submitPendingReview(body);
3411
+ if (submitPendingLeftByFailedThreads(body, result)) return true;
3412
+ return submitBodyOnlyReview(body);
3413
+ }
3414
+ function submitPendingLeftByFailedThreads(body, result) {
3415
+ return result.failed > 0 && submitPendingReview(body);
3416
+ }
3417
+
3418
+ // src/commands/review/withRejectedFindings.ts
3419
+ function withRejectedFindings(unanchored, rejected) {
3420
+ return [
3421
+ ...unanchored,
3422
+ ...rejected.map((finding) => ({
3423
+ ...finding,
3424
+ reason: "comment-rejected"
3425
+ }))
3426
+ ];
3427
+ }
3428
+
3429
+ // src/commands/review/postAndMaybeSubmit.ts
3430
+ async function decideSubmit(options) {
3431
+ if (!options.prompt) return options.submit;
3432
+ await setSessionStatus("waiting");
3433
+ try {
3434
+ return await promptConfirm("Submit the pending review?", options.submit);
3435
+ } finally {
3436
+ await setSessionStatus("running");
3437
+ }
3438
+ }
3439
+ async function postAndMaybeSubmit(lineBound, unanchored, markdown, options) {
3440
+ const { posted, failed: failed2 } = await postFindings(lineBound);
3441
+ const failedSuffix = failed2.length > 0 ? `, ${failed2.length} failed` : "";
3442
+ console.log(`Posted ${posted} comment(s)${failedSuffix}.`);
3443
+ const withRejected = withRejectedFindings(unanchored, failed2);
3444
+ const carried = carriedUnanchoredFindings(withRejected);
3445
+ if (posted === 0 && carried.length === 0)
3446
+ return { posted: 0, submitted: false };
3447
+ const shouldSubmit = await decideSubmit(options);
3448
+ if (shouldSubmit) {
3449
+ const submitted = submitReview(buildReviewBody(markdown, withRejected), {
3450
+ posted,
3451
+ failed: failed2.length
3452
+ });
3453
+ return { posted, submitted };
3454
+ }
3455
+ console.log("Leaving the review unsubmitted.");
3456
+ return { posted, submitted: false };
3457
+ }
3458
+
3459
+ // src/commands/review/partitionFindings.ts
3460
+ function isValidLine(n) {
3461
+ return Number.isInteger(n) && n >= 1;
3462
+ }
3463
+ function toLineBound(finding) {
3464
+ if (!finding.location || finding.location.toLowerCase() === "n/a") {
3465
+ return null;
3466
+ }
3467
+ const match = finding.location.match(/^(.+):(\d+)(?:-(\d+))?$/);
3468
+ if (!match) return null;
3469
+ const startLine = Number.parseInt(match[2], 10);
3470
+ const endLine = match[3] ? Number.parseInt(match[3], 10) : startLine;
3471
+ if (!isValidLine(startLine) || !isValidLine(endLine)) return null;
3472
+ if (endLine < startLine) return null;
3473
+ const base = { ...finding, file: match[1], line: endLine };
3474
+ return startLine === endLine ? base : { ...base, startLine };
3475
+ }
3476
+ function partitionFindings(findings2) {
3477
+ const lineBound = [];
3478
+ const unlocated = [];
3479
+ const alreadyRaised = [];
3480
+ for (const finding of findings2) {
3481
+ if (finding.source === "already-raised") {
3482
+ alreadyRaised.push(finding);
3483
+ continue;
3484
+ }
3485
+ const bound = toLineBound(finding);
3486
+ if (bound) lineBound.push(bound);
3487
+ else unlocated.push(finding);
3488
+ }
3489
+ return { lineBound, unlocated, alreadyRaised };
3490
+ }
3491
+
3492
+ // src/commands/review/buildDiffLineIndex.ts
3493
+ var FILE_HEADER2 = /^\+\+\+ (?:b\/)?(.+)$/;
3494
+ var HUNK_HEADER4 = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
3495
+ function buildDiffLineIndex(diff) {
3496
+ const index = /* @__PURE__ */ new Map();
3497
+ let currentFile = null;
3498
+ let newLine = 0;
3499
+ for (const line of diff.split("\n")) {
3500
+ const fileMatch = line.match(FILE_HEADER2);
3501
+ if (fileMatch) {
3502
+ currentFile = fileMatch[1] === "/dev/null" ? null : fileMatch[1];
3503
+ continue;
3504
+ }
3505
+ const hunkMatch = line.match(HUNK_HEADER4);
3506
+ if (hunkMatch) {
3507
+ newLine = Number(hunkMatch[1]);
3508
+ continue;
3509
+ }
3510
+ if (currentFile === null) continue;
3511
+ if (line.startsWith("-")) continue;
3512
+ if (line.startsWith("+") || line.startsWith(" ")) {
3513
+ let set = index.get(currentFile);
3514
+ if (!set) {
3515
+ set = /* @__PURE__ */ new Set();
3516
+ index.set(currentFile, set);
3517
+ }
3518
+ set.add(newLine);
3519
+ newLine++;
3520
+ }
3521
+ }
3522
+ return index;
3523
+ }
3524
+
3525
+ // src/commands/review/partitionFindingsByDiff.ts
3526
+ function isWithinDiff(finding, index) {
3527
+ const lines = index.get(finding.file);
3528
+ if (!lines) return false;
3529
+ if (!lines.has(finding.line)) return false;
3530
+ if (finding.startLine !== void 0 && !lines.has(finding.startLine)) {
3531
+ return false;
3532
+ }
3533
+ return true;
3534
+ }
3535
+ function partitionFindingsByDiff(findings2, index) {
3536
+ const inDiff = [];
3537
+ const outOfDiff = [];
3538
+ for (const finding of findings2) {
3539
+ if (isWithinDiff(finding, index)) inDiff.push(finding);
3540
+ else outOfDiff.push(finding);
3541
+ }
3542
+ return { inDiff, outOfDiff };
3543
+ }
3544
+
3545
+ // src/commands/review/warnOutOfDiff.ts
3546
+ import chalk11 from "chalk";
3547
+ function warnOutOfDiff(outOfDiff) {
3548
+ if (outOfDiff.length === 0) return;
3549
+ console.warn(
3550
+ chalk11.yellow(
3551
+ `Moved ${outOfDiff.length} finding(s) whose lines fall outside the PR diff into the review body (GitHub cannot anchor a comment on these):`
3552
+ )
3553
+ );
3554
+ for (const finding of outOfDiff) {
3555
+ const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
3556
+ console.warn(
3557
+ ` ${chalk11.yellow("\xB7")} ${finding.title} ${chalk11.dim(
3558
+ `(${finding.file}:${range})`
3559
+ )}`
3560
+ );
3561
+ }
3562
+ }
3563
+
3564
+ // src/commands/review/selectInDiffFindings.ts
3565
+ function selectInDiffFindings(lineBound, prDiff) {
3566
+ const diff = fetchPrDiff(prDiff.prNumber, prDiff.baseSha, prDiff.headSha);
3567
+ const { inDiff, outOfDiff } = partitionFindingsByDiff(
3568
+ lineBound,
3569
+ buildDiffLineIndex(diff)
3570
+ );
3571
+ warnOutOfDiff(outOfDiff);
3572
+ return {
3573
+ inDiff,
3574
+ unanchored: outOfDiff.map((finding) => ({
3575
+ ...finding,
3576
+ reason: "out-of-diff"
3577
+ }))
3578
+ };
3579
+ }
3580
+
3581
+ // src/commands/review/warnUnlocated.ts
3582
+ import chalk12 from "chalk";
3583
+ function warnUnlocated(unlocated) {
3584
+ if (unlocated.length === 0) return;
3585
+ console.warn(
3586
+ chalk12.yellow(
3587
+ `Moved ${unlocated.length} finding(s) without a parseable file:line into the review body:`
3588
+ )
3589
+ );
3590
+ for (const finding of unlocated) {
3591
+ const where = finding.location || chalk12.dim("missing");
3592
+ console.warn(
3593
+ ` ${chalk12.yellow("\xB7")} ${finding.title} ${chalk12.dim(`(${where})`)}`
3594
+ );
3595
+ }
3596
+ }
3597
+
3598
+ // src/commands/review/selectPostableFindings.ts
3599
+ function selectPostableFindings(markdown, prInfo) {
3600
+ const findings2 = parseFindings(markdown);
3601
+ if (findings2.length === 0) {
3602
+ console.log("Synthesis contains no findings; nothing to post.");
3603
+ return { inDiff: [], unanchored: [] };
3604
+ }
3605
+ const { lineBound, unlocated, alreadyRaised } = partitionFindings(findings2);
3606
+ warnUnlocated(unlocated);
3607
+ if (alreadyRaised.length > 0) {
3608
+ console.log(
3609
+ `Skipped ${alreadyRaised.length} finding(s) already raised by prior comments.`
3610
+ );
3611
+ }
3612
+ const carriedUnlocated = unlocated.map((finding) => ({
3613
+ ...finding,
3614
+ reason: "unlocated"
3615
+ }));
3616
+ if (lineBound.length === 0) {
3617
+ console.log("No line-bound findings to comment on.");
3618
+ return { inDiff: [], unanchored: carriedUnlocated };
3619
+ }
3620
+ const { inDiff, unanchored } = selectInDiffFindings(lineBound, prInfo);
3621
+ if (inDiff.length === 0)
3622
+ console.log(
3623
+ "No findings fall within the PR diff; no line comments to post."
3624
+ );
3625
+ return { inDiff, unanchored: [...carriedUnlocated, ...unanchored] };
3626
+ }
3627
+
3628
+ // src/commands/review/stillOnReviewedPr.ts
3629
+ function currentPrNumber() {
3630
+ try {
3631
+ return findCurrentPrNumber();
3632
+ } catch (error) {
3633
+ console.error(
3634
+ `Error: could not confirm which PR this tree is on: ${error instanceof Error ? error.message : String(error)}`
3635
+ );
3636
+ return null;
3637
+ }
3638
+ }
3639
+ function stillOnReviewedPr(prNumber) {
3640
+ const current = currentPrNumber();
3641
+ if (current === prNumber) return true;
3642
+ console.error(
3643
+ `Error: this tree is now on ${current === null ? "a branch with no open PR" : `PR #${current}`}, not the reviewed PR #${prNumber}; skipping the post and any chained sessions.`
3644
+ );
3645
+ return false;
3646
+ }
3647
+
3648
+ // src/commands/review/describeWork.ts
3649
+ function describeWork(comments, carried) {
3650
+ const parts = [];
3651
+ if (comments > 0) parts.push(`${comments} line comment(s)`);
3652
+ if (carried > 0) parts.push(`${carried} finding(s) in the review body`);
3653
+ return parts.join(" and ");
3654
+ }
3655
+
3656
+ // src/commands/review/postReviewToPr.ts
3657
+ var NOTHING_POSTED = { posted: 0, submitted: false };
3658
+ async function confirmPost(prNumber, work, options) {
3659
+ if (!options.prompt) return true;
3660
+ return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
3661
+ }
3662
+ async function postFindingsToPr(prInfo, synthesisPath, options) {
3663
+ const markdown = readFileSync4(synthesisPath, "utf8");
3664
+ const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
3665
+ const carried = carriedUnanchoredFindings(unanchored);
3666
+ if (inDiff.length === 0 && carried.length === 0) return NOTHING_POSTED;
3667
+ const work = describeWork(inDiff.length, carried.length);
3668
+ console.log(`Found PR #${prInfo.prNumber} with ${work} to post.`);
3669
+ const confirmed = await confirmPost(prInfo.prNumber, work, options);
3670
+ if (!confirmed) {
3671
+ console.log("Skipped posting.");
3672
+ return NOTHING_POSTED;
3673
+ }
3674
+ return postAndMaybeSubmit(inDiff, unanchored, markdown, options);
3675
+ }
3676
+ async function postReviewToPr(synthesisPath, prInfo, options) {
3677
+ if (!stillOnReviewedPr(prInfo.prNumber)) return;
3678
+ const outcome = await postFindingsToPr(prInfo, synthesisPath, options);
3679
+ await chainAfterReview(prInfo.prNumber, outcome, options);
3680
+ }
3681
+
3682
+ // src/commands/review/runReviewSession.ts
3683
+ async function runReviewSession(session, synthesisPath, harness) {
3684
+ const adapter = harnessAdapter(harness);
3685
+ const { done } = session.launch(adapter, synthesisPath);
3686
+ await awaitHarness(done, session.feature.label, adapter.label);
3687
+ }
3688
+
3689
+ // src/commands/review/handlePostSynthesis.ts
3690
+ async function handlePostSynthesis(synthesisPath, prInfo, options) {
3691
+ const session = postSynthesisSession(options);
3692
+ if (!session) {
3693
+ await postReviewToPr(synthesisPath, prInfo, {
3694
+ prompt: options.prompt,
3695
+ submit: options.submit,
3696
+ addressComments: options.addressComments,
3697
+ announce: options.announce,
3698
+ harness: options.harness
3699
+ });
3700
+ return;
3701
+ }
3702
+ await runReviewSession(session, synthesisPath, options.harness);
3703
+ if (options.announce) await announcePr(prInfo.prNumber);
3704
+ }
3705
+
3706
+ // src/commands/review/runPostSynthesis.ts
3707
+ function runPostSynthesis(synthesisPath, prInfo, options) {
3708
+ return handlePostSynthesis(synthesisPath, prInfo, {
3709
+ refine: options.refine ?? false,
3710
+ apply: options.apply ?? false,
3711
+ backlog: options.backlog ?? false,
3712
+ prompt: options.prompt ?? true,
3713
+ submit: options.submit ?? false,
3714
+ addressComments: options.addressComments ?? false,
3715
+ announce: options.announce ?? false,
3716
+ harness: options.harness
3717
+ });
3718
+ }
3719
+
3720
+ // src/commands/review/reviewPr.ts
3721
+ async function reviewPr(repoRoot, options) {
3722
+ const blocker = synthesisBlocker(resolveSynthesisHarness());
3723
+ if (blocker) {
3724
+ console.error(chalk13.red(blocker));
3725
+ process.exitCode = 1;
3726
+ return;
3727
+ }
3728
+ const context = gatherChangedContext();
3729
+ const paths = setupReviewDir(repoRoot, context, options.force ?? false);
3730
+ attachReviewLog(paths.reviewDir);
3731
+ const outcome = await runReviewPipeline(paths, {
3732
+ verbose: options.verbose ?? false,
3733
+ job: { repo: basename3(repoRoot), prNumber: context.prNumber }
3734
+ });
3735
+ if (outcome.ok) await runPostSynthesis(paths.synthesisPath, context, options);
3736
+ console.log(`Done. Review folder: ${paths.reviewDir}`);
3737
+ }
3738
+
3739
+ // src/commands/review/validateConfigureOptions.ts
3740
+ function validateConfigureOptions(options) {
3741
+ if (!options.configure) {
3742
+ if (options.scope || (options.answer ?? []).length > 0) {
3743
+ console.error("Error: --scope and --answer require --configure.");
3744
+ process.exit(1);
3745
+ }
3746
+ return;
3747
+ }
3748
+ if (!options.highLevel) {
3749
+ console.error("Error: --configure requires --high-level.");
3750
+ process.exit(1);
3751
+ }
3752
+ if (options.number) {
3753
+ console.error("Error: --configure takes no PR number.");
3754
+ process.exit(1);
3755
+ }
3756
+ if (options.scope && !parseRepoScopeFlag(options.scope)) {
3757
+ console.error("Error: --scope must be 'git' or 'db'.");
3758
+ process.exit(1);
3759
+ }
3760
+ }
3761
+
3762
+ // src/commands/review/validateReviewOptions.ts
3763
+ function validateReviewOptions(options) {
3764
+ if (options.apply && options.refine) {
3765
+ console.error("Error: --apply cannot be combined with --refine.");
3766
+ process.exit(1);
3767
+ }
3768
+ if (options.backlog && (options.refine || options.apply)) {
3769
+ console.error(
3770
+ "Error: --backlog cannot be combined with --refine or --apply."
3771
+ );
3772
+ process.exit(1);
3773
+ }
3774
+ validateCheckoutOnly(options);
3775
+ validateHighLevel(options);
3776
+ validateConfigureOptions(options);
3777
+ }
3778
+ function validateCheckoutOnly(options) {
3779
+ if (!options.checkoutOnly) return;
3780
+ if (!options.number) {
3781
+ console.error("Error: --checkout-only requires a PR number.");
3782
+ process.exit(1);
3783
+ }
3784
+ if (options.refine || options.apply || options.backlog || options.submit) {
3785
+ console.error(
3786
+ "Error: --checkout-only cannot be combined with --refine, --apply, --backlog or --submit."
3787
+ );
3788
+ process.exit(1);
3789
+ }
3790
+ }
3791
+ function validateHighLevel(options) {
3792
+ if (options.slices && (!options.highLevel || options.configure)) {
3793
+ console.error(
3794
+ "Error: --slices requires --high-level and cannot be combined with --configure."
3795
+ );
3796
+ process.exit(1);
3797
+ }
3798
+ if (!options.highLevel) return;
3799
+ if (options.refine || options.apply || options.backlog || options.submit || options.checkoutOnly) {
3800
+ console.error(
3801
+ "Error: --high-level cannot be combined with --refine, --apply, --backlog, --submit or --checkout-only."
3802
+ );
3803
+ process.exit(1);
3804
+ }
3805
+ }
3806
+
3807
+ // src/commands/review/sessionBlocked.ts
3808
+ import chalk14 from "chalk";
3809
+
3810
+ // src/commands/review/reviewSessionFeature.ts
3811
+ function reviewSessionFeature(options) {
3812
+ if (options.checkoutOnly) return reviewCheckoutFeature;
3813
+ if (options.highLevel)
3814
+ return options.number && !isAgentHarness() ? highLevelReviewFeature : void 0;
3815
+ const session = postSynthesisSession(options)?.feature;
3816
+ if (session) return session;
3817
+ return options.submit && options.addressComments ? addressCommentsChainFeature : void 0;
3818
+ }
3819
+
3820
+ // src/commands/review/sessionBlocked.ts
3821
+ function sessionBlocked(options) {
3822
+ const feature = reviewSessionFeature(options);
3823
+ if (!feature) return false;
3824
+ const blocker = launchBlocker(harnessAdapter(options.harness), feature);
3825
+ if (!blocker) return false;
3826
+ console.error(chalk14.red(blocker));
3827
+ process.exitCode = 1;
3828
+ return true;
3829
+ }
3830
+
3831
+ // src/commands/review/review.ts
3832
+ function resolveRepoRoot() {
3833
+ const repoRoot = findRepoRoot(process.cwd());
3834
+ if (repoRoot) return repoRoot;
3835
+ console.error("Error: not inside a git repository.");
3836
+ process.exit(1);
3837
+ }
3838
+ async function review(options = {}) {
3839
+ validateReviewOptions(options);
3840
+ if (options.configure)
3841
+ return configureHighLevelReview({
3842
+ scope: options.scope,
3843
+ answer: options.answer
3844
+ });
3845
+ if (sessionBlocked(options)) return;
3846
+ startReviewLog();
3847
+ const invokedIn = resolveRepoRoot();
3848
+ const { harness } = options;
3849
+ if (options.checkoutOnly && options.number)
3850
+ return checkoutPrSession(options.number, { harness });
3851
+ if (options.highLevel && options.number && !isAgentHarness())
3852
+ return checkoutPrSession(options.number, {
3853
+ harness,
3854
+ skill: {
3855
+ name: "review-high-level",
3856
+ args: `${options.number}${options.force ? " --force" : ""}`
3857
+ }
3858
+ });
3859
+ emitActivity({ kind: "command", name: "review" });
3860
+ const highLevelOptions = { force: options.force, slices: options.slices };
3861
+ if (!options.number)
3862
+ return options.highLevel ? runHighLevelReview(void 0, highLevelOptions) : reviewPr(invokedIn, options);
3863
+ await checkoutPr(options.number);
3864
+ if (options.highLevel)
3865
+ return runHighLevelReview(options.number, highLevelOptions);
3866
+ return reviewPr(resolveRepoRoot(), options);
3867
+ }
3868
+ export {
3869
+ review
3870
+ };