@testmuai/kane-cli 0.10.0-rc.3 → 0.10.0

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 (375) hide show
  1. package/dist/ChatSurface-XUV3EQPZ.js +2 -0
  2. package/dist/{ChromeProfilePicker-M4WXOB5O.js → ChromeProfilePicker-FWPUDKD6.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-6MJA7DF6.js → CliFeedbackPrompt-D5L2DO6A.js} +1 -1
  4. package/dist/{CliUploadProgress-6NLS7XHH.js → CliUploadProgress-HQX57WE6.js} +1 -1
  5. package/dist/{ConfigView-O4WKZ5PU.js → ConfigView-DGQXKEON.js} +1 -1
  6. package/dist/EvidenceViewOffer-EIANIYN7.js +2 -0
  7. package/dist/FolderPicker-XOA7FTHF.js +2 -0
  8. package/dist/InfoBox-OBH7SUGC.js +2 -0
  9. package/dist/{LinksBox-DXP66H3H.js → LinksBox-WZ4RAMSH.js} +1 -1
  10. package/dist/{ProfilesView-TWOY5PVC.js → ProfilesView-AGRNPGSW.js} +1 -1
  11. package/dist/ProjectPicker-6KRLKV4U.js +2 -0
  12. package/dist/SaveSessionPrompt-J2OPDEOO.js +2 -0
  13. package/dist/SingleShotApp-QI4B2TSL.js +2 -0
  14. package/dist/{SummaryBox-IA2KS6GT.js → SummaryBox-XQJUZBAN.js} +1 -1
  15. package/dist/TestMdRunView-I4MV54FB.js +2 -0
  16. package/dist/TestrunEvidenceTable-WEIUSW3E.js +2 -0
  17. package/dist/{WhoamiView-SNL75TEF.js → WhoamiView-JQCURK2M.js} +1 -1
  18. package/dist/{app-download-UI4ABEIX.js → app-download-OU6AGH2X.js} +1 -1
  19. package/dist/{assurance-job-FFSSS4XV.js → assurance-job-ZI3L6I4F.js} +1 -1
  20. package/dist/{binary-THPLXCOD.js → binary-S5YL5GJD.js} +1 -1
  21. package/dist/bind-LIV72SEZ.js +2 -0
  22. package/dist/bootstrap-3V6TOO6I.js +2 -0
  23. package/dist/{bridge-T6QMYKED.js → bridge-SDEP7Y33.js} +1 -1
  24. package/dist/{catalog-MYPS2BXY.js → catalog-I3PC6LT6.js} +1 -1
  25. package/dist/catalog-client-WKYG3JN6.js +2 -0
  26. package/dist/{changelog-SU674BVE.js → changelog-IHNWFYWY.js} +1 -1
  27. package/dist/chat-committer-FM5NG46O.js +2 -0
  28. package/dist/{chat-controller-XINCDH6Z.js → chat-controller-FWFQVZTB.js} +1 -1
  29. package/dist/child-H2YSDFCG.js +2 -0
  30. package/dist/{chunk-QDFY5GGO.js → chunk-252GEI3H.js} +1 -1
  31. package/dist/{chunk-TNORODUF.js → chunk-2B75UL7Y.js} +1 -1
  32. package/dist/{chunk-FWDUVFS6.js → chunk-2EVP636F.js} +17 -17
  33. package/dist/{chunk-7XBNMOH4.js → chunk-2GE5X2A5.js} +1 -1
  34. package/dist/{chunk-DJC7NTLA.js → chunk-2L3A5NKZ.js} +1 -1
  35. package/dist/{chunk-CUXY6KQ2.js → chunk-2N75WO7Y.js} +1 -1
  36. package/dist/{chunk-CGITGJ3I.js → chunk-2PZKMT3I.js} +1 -1
  37. package/dist/{chunk-M43WH5DQ.js → chunk-2SY2NCOP.js} +1 -1
  38. package/dist/{chunk-Q3C6NDGI.js → chunk-32Y6QVFG.js} +1 -1
  39. package/dist/{chunk-734ORT6O.js → chunk-3OVFKUXV.js} +1 -1
  40. package/dist/{chunk-IGEAET7M.js → chunk-3T2TYDPT.js} +1 -1
  41. package/dist/{chunk-TU42YZOJ.js → chunk-3UHPVQLU.js} +1 -1
  42. package/dist/{chunk-WEIPY3CI.js → chunk-3ZPEQDXZ.js} +1 -1
  43. package/dist/{chunk-RHGW7B5Q.js → chunk-436FZ4KG.js} +1 -1
  44. package/dist/{chunk-YQ5C6UDG.js → chunk-4523YDTG.js} +1 -1
  45. package/dist/{chunk-7SY34IIL.js → chunk-45URQUAK.js} +1 -1
  46. package/dist/{chunk-VSVWNRI2.js → chunk-4BUEOKFV.js} +1 -1
  47. package/dist/{chunk-NZ6AV2TA.js → chunk-4JWJH6TB.js} +1 -1
  48. package/dist/{chunk-YPFQ4UGF.js → chunk-4MNSP4EO.js} +1 -1
  49. package/dist/{chunk-ZFMRQ57Y.js → chunk-4NUSW4A2.js} +1 -1
  50. package/dist/{chunk-FSYOTRMC.js → chunk-4R4YUOVY.js} +1 -1
  51. package/dist/{chunk-FWUPJORV.js → chunk-4SJAOAYY.js} +1 -1
  52. package/dist/{chunk-SMTBOSEJ.js → chunk-52VCA4K2.js} +1 -1
  53. package/dist/{chunk-4YW767UV.js → chunk-567D5ZTO.js} +7 -7
  54. package/dist/{chunk-W4QSZNMB.js → chunk-5IO5ZC4S.js} +1 -1
  55. package/dist/{chunk-LSDJOVWW.js → chunk-5R3ODQHH.js} +1 -1
  56. package/dist/{chunk-WXJCJL5L.js → chunk-5T6II7VN.js} +1 -1
  57. package/dist/{chunk-3YTCKCBG.js → chunk-65BG6GAE.js} +1 -1
  58. package/dist/{chunk-LAOTVZHV.js → chunk-6DZ7LVOG.js} +1 -1
  59. package/dist/chunk-6K5BEEAJ.js +2 -0
  60. package/dist/{chunk-42PALMW2.js → chunk-6TNLITJO.js} +1 -1
  61. package/dist/{chunk-VXGN3IV7.js → chunk-7C4IEL5V.js} +1 -1
  62. package/dist/{chunk-PUVMC4PX.js → chunk-7V34ZMMS.js} +1 -1
  63. package/dist/{chunk-DDZLCAEO.js → chunk-7ZJWUWSN.js} +1 -1
  64. package/dist/{chunk-ICLUC44J.js → chunk-A3TCFSCK.js} +1 -1
  65. package/dist/{chunk-F5NHG7VB.js → chunk-A4BB6GLN.js} +1 -1
  66. package/dist/{chunk-AVSMXDTX.js → chunk-AG5XJWEV.js} +1 -1
  67. package/dist/{chunk-GQRU3B54.js → chunk-AGXAJ2II.js} +1 -1
  68. package/dist/{chunk-6UVIY56J.js → chunk-AIGQCMGY.js} +1 -1
  69. package/dist/{chunk-RX6776AI.js → chunk-AU26ZZTX.js} +1 -1
  70. package/dist/{chunk-CCP4X75B.js → chunk-AUBSLPJZ.js} +1 -1
  71. package/dist/{chunk-XQMWHPZI.js → chunk-B2WFW74J.js} +1 -1
  72. package/dist/{chunk-NXRF7FFS.js → chunk-B7JLM3IX.js} +1 -1
  73. package/dist/{chunk-LUZBGTYB.js → chunk-BRVIK3BU.js} +1 -1
  74. package/dist/{chunk-URH4FX3H.js → chunk-BY2B4YJN.js} +1 -1
  75. package/dist/{chunk-Y7E5L42F.js → chunk-CBVHP7JB.js} +1 -1
  76. package/dist/{chunk-ZFM77AQU.js → chunk-CJE7PKRV.js} +1 -1
  77. package/dist/{chunk-2DYHAP4E.js → chunk-CJQUVHHS.js} +1 -1
  78. package/dist/{chunk-OFSDB7B4.js → chunk-COJINPOK.js} +2 -2
  79. package/dist/{chunk-JZP3Y4ZM.js → chunk-D6CS62O7.js} +1 -1
  80. package/dist/{chunk-457Y5TEC.js → chunk-DBTMKBHU.js} +1 -1
  81. package/dist/{chunk-CM4CHYSN.js → chunk-DHYGCHKB.js} +1 -1
  82. package/dist/{chunk-DZOYYWOW.js → chunk-DTYT6KBO.js} +1 -1
  83. package/dist/{chunk-6EB5VRAN.js → chunk-EC5IP5HZ.js} +1 -1
  84. package/dist/{chunk-35ECWCCK.js → chunk-EH43VWVR.js} +1 -1
  85. package/dist/{chunk-HQ2E2XCU.js → chunk-ENG2UTMX.js} +1 -1
  86. package/dist/{chunk-VUFIL5VR.js → chunk-EPJ5SJL2.js} +2 -2
  87. package/dist/{chunk-YHFZFV3A.js → chunk-EQWMOGLO.js} +9 -9
  88. package/dist/{chunk-XLEGGC4Y.js → chunk-EVZLINBN.js} +1 -1
  89. package/dist/{chunk-44B6THYK.js → chunk-EX6ORR7P.js} +1 -1
  90. package/dist/{chunk-EBPRPNSA.js → chunk-FBQ7PQJV.js} +1 -1
  91. package/dist/{chunk-AEWNWAXW.js → chunk-FLOQ5NZL.js} +2 -2
  92. package/dist/{chunk-LCSJ7GOG.js → chunk-FPPVNF53.js} +1 -1
  93. package/dist/{chunk-F22K3RRX.js → chunk-FPVGA6XT.js} +1 -1
  94. package/dist/{chunk-IJ2AHSWW.js → chunk-FVYIV36L.js} +1 -1
  95. package/dist/chunk-FYCD765R.js +161 -0
  96. package/dist/{chunk-AVI5H4UM.js → chunk-G2KTWFMU.js} +1 -1
  97. package/dist/{chunk-ACMBMZDQ.js → chunk-G3CYFCSR.js} +1 -1
  98. package/dist/{chunk-JNSWKGTB.js → chunk-G3J4XY3Z.js} +1 -1
  99. package/dist/{chunk-KXHJMAZU.js → chunk-GET4DINR.js} +2 -2
  100. package/dist/{chunk-54XA5MZH.js → chunk-GGS3ATPB.js} +1 -1
  101. package/dist/{chunk-C2RUDJ46.js → chunk-GGV336P5.js} +1 -1
  102. package/dist/{chunk-L5DALV5N.js → chunk-GI2JPIX5.js} +1 -1
  103. package/dist/{chunk-HAW5WEKT.js → chunk-GRO6DLN3.js} +1 -1
  104. package/dist/{chunk-3RJHXOZH.js → chunk-GXMD23XB.js} +1 -1
  105. package/dist/chunk-GYDJO32R.js +2 -0
  106. package/dist/{chunk-W7FLXW6Q.js → chunk-H4KPNGY4.js} +1 -1
  107. package/dist/{chunk-PAWQ4AKN.js → chunk-HBVHIEPB.js} +1 -1
  108. package/dist/{chunk-EF47KRUK.js → chunk-HGVM2OZU.js} +1 -1
  109. package/dist/{chunk-4QFTHUJA.js → chunk-HMQ5M4JJ.js} +1 -1
  110. package/dist/{chunk-ZTHYAHDN.js → chunk-I2VU2DTS.js} +1 -1
  111. package/dist/{chunk-7NCJMWFX.js → chunk-J4LQAT5P.js} +1 -1
  112. package/dist/{chunk-HK62JVQM.js → chunk-JCSVBD4F.js} +1 -1
  113. package/dist/{chunk-7AET4JKQ.js → chunk-JFBEHCJN.js} +1 -1
  114. package/dist/{chunk-EECDDDSB.js → chunk-JGLADDRH.js} +1 -1
  115. package/dist/{chunk-I4WXALQR.js → chunk-JOCEZK2M.js} +1 -1
  116. package/dist/{chunk-5AKJPYUW.js → chunk-JQ7ZZQXC.js} +3 -3
  117. package/dist/{chunk-C62QWG4B.js → chunk-JRSEAXFE.js} +1 -1
  118. package/dist/{chunk-D7U2M26S.js → chunk-JSLKCCD2.js} +1 -1
  119. package/dist/{chunk-RTVHJ23A.js → chunk-JT6WLJSV.js} +1 -1
  120. package/dist/{chunk-P3JXJ4BW.js → chunk-JTJ7IPNI.js} +1 -1
  121. package/dist/{chunk-ZTRRFG52.js → chunk-JX5NVKTV.js} +1 -1
  122. package/dist/{chunk-QBYENBMB.js → chunk-K2PLULJD.js} +1 -1
  123. package/dist/{chunk-RF37IJNN.js → chunk-K3OSK6PB.js} +1 -1
  124. package/dist/{chunk-3GXN6VF6.js → chunk-KDR662D2.js} +1 -1
  125. package/dist/{chunk-NLZZLANH.js → chunk-KRRZCY7U.js} +1 -1
  126. package/dist/{chunk-KODJVOCN.js → chunk-LHQUCRCH.js} +1 -1
  127. package/dist/{chunk-WOSANGV6.js → chunk-LNHBZEDC.js} +1 -1
  128. package/dist/{chunk-PZA3BSOE.js → chunk-LXM7VHYN.js} +1 -1
  129. package/dist/{chunk-D7TKE7LK.js → chunk-MHB6DMKZ.js} +1 -1
  130. package/dist/{chunk-W6HZF56M.js → chunk-MJKRJGER.js} +1 -1
  131. package/dist/{chunk-V7USCQWO.js → chunk-MKPDF26Q.js} +1 -1
  132. package/dist/{chunk-VLDCHFXF.js → chunk-MPEIMWQI.js} +1 -1
  133. package/dist/{chunk-YIKF4ERQ.js → chunk-MW2WNYJO.js} +2 -2
  134. package/dist/{chunk-MYVKUJGS.js → chunk-N3KTLWJL.js} +1 -1
  135. package/dist/{chunk-QDXKEOKI.js → chunk-NJCN6LP5.js} +6 -6
  136. package/dist/{chunk-IUQOG7Z5.js → chunk-NOFJXCYP.js} +1 -1
  137. package/dist/{chunk-I4RVVBG3.js → chunk-NTXFPNAP.js} +1 -1
  138. package/dist/{chunk-XZGEN4NU.js → chunk-ONZ2CSTZ.js} +1 -1
  139. package/dist/{chunk-UYDHOHSZ.js → chunk-OR2B6T3B.js} +1 -1
  140. package/dist/{chunk-UUJIGOEO.js → chunk-ORNVIEUA.js} +1 -1
  141. package/dist/{chunk-R7KXAISS.js → chunk-P2LDAW3C.js} +1 -1
  142. package/dist/{chunk-ECPFI75W.js → chunk-PBWYQR5I.js} +1 -1
  143. package/dist/{chunk-O3HHTKZ5.js → chunk-PCDIEYV6.js} +1 -1
  144. package/dist/{chunk-EZN7CF45.js → chunk-PL3SG3M2.js} +1 -1
  145. package/dist/{chunk-NXAJBSIF.js → chunk-PQXYHI5W.js} +1 -1
  146. package/dist/{chunk-WAOUE7MP.js → chunk-PTISAIZW.js} +1 -1
  147. package/dist/{chunk-XZYA7DNH.js → chunk-PVN64537.js} +1 -1
  148. package/dist/{chunk-NIVFEACM.js → chunk-QECTIQAC.js} +1 -1
  149. package/dist/chunk-QMOGBKJM.js +2 -0
  150. package/dist/{chunk-ZU4W2QGM.js → chunk-QQI6N3FO.js} +1 -1
  151. package/dist/{chunk-7RWP4Y3H.js → chunk-QVP4FSKT.js} +1 -1
  152. package/dist/{chunk-OCDBTAYS.js → chunk-QWZJ5QDO.js} +2 -2
  153. package/dist/{chunk-YLXWAY7D.js → chunk-RARD6TC6.js} +1 -1
  154. package/dist/chunk-RDH3E25Q.js +27 -0
  155. package/dist/{chunk-AZLNLHUA.js → chunk-RLOJH5O6.js} +1 -1
  156. package/dist/{chunk-RPRXRKKR.js → chunk-RQKMSNEU.js} +1 -1
  157. package/dist/{chunk-R4JUKTDO.js → chunk-SB6P5EQH.js} +1 -1
  158. package/dist/{chunk-TU7TVFBK.js → chunk-SBR6D6GS.js} +1 -1
  159. package/dist/{chunk-7HMSMAUG.js → chunk-TLOYTGVT.js} +5 -5
  160. package/dist/{chunk-LUR7JFPP.js → chunk-TZVPDGJD.js} +1 -1
  161. package/dist/{chunk-D756UWY2.js → chunk-U7NRZBB5.js} +1 -1
  162. package/dist/{chunk-72RC7JSA.js → chunk-UEPJ26X2.js} +1 -1
  163. package/dist/chunk-UJLULWSR.js +21 -0
  164. package/dist/{chunk-LQQNPMOD.js → chunk-ULGBK4NS.js} +1 -1
  165. package/dist/{chunk-6DZX5HLZ.js → chunk-UNWPBMVM.js} +1 -1
  166. package/dist/chunk-URAYFJGM.js +87 -0
  167. package/dist/{chunk-FIP5L6LV.js → chunk-USJ3LUAL.js} +1 -1
  168. package/dist/chunk-UUWSULIM.js +101 -0
  169. package/dist/chunk-UX2CDUPE.js +9 -0
  170. package/dist/{chunk-GXKY5A46.js → chunk-VA3BSIUQ.js} +1 -1
  171. package/dist/chunk-VQZOKTJ2.js +12 -0
  172. package/dist/{chunk-36N3EHW5.js → chunk-VVCZRCRD.js} +1 -1
  173. package/dist/{chunk-HJMCXSUJ.js → chunk-VZA7BPCK.js} +1 -1
  174. package/dist/{chunk-LIGTP3A3.js → chunk-W3NWHWK2.js} +1 -1
  175. package/dist/{chunk-E6KSRQXL.js → chunk-WERIGVOH.js} +1 -1
  176. package/dist/{chunk-ETZMFRD6.js → chunk-WKZLK57W.js} +1 -1
  177. package/dist/{chunk-3OQW2GTA.js → chunk-WQR2GYP7.js} +1 -1
  178. package/dist/{chunk-SGPAM5DZ.js → chunk-WX4VGH5Q.js} +1 -1
  179. package/dist/{chunk-OJ33Q6DU.js → chunk-WZLDFEWR.js} +1 -1
  180. package/dist/{chunk-ZAFJQ3SM.js → chunk-X3J4CC27.js} +1 -1
  181. package/dist/chunk-XLQ4F6BI.js +9 -0
  182. package/dist/{chunk-XRNQSXOM.js → chunk-XMALVGH7.js} +2 -2
  183. package/dist/{chunk-TW5AA5A7.js → chunk-Y3YULFCK.js} +1 -1
  184. package/dist/{chunk-7YT4TTKL.js → chunk-YGMQXS2J.js} +1 -1
  185. package/dist/{chunk-RDP7GWSY.js → chunk-YH4VZVHJ.js} +1 -1
  186. package/dist/{chunk-YGRULEZY.js → chunk-YI4ESDAX.js} +1 -1
  187. package/dist/{chunk-YAW6JW6D.js → chunk-YKL5H4K6.js} +1 -1
  188. package/dist/{chunk-VX657KIK.js → chunk-YKOEABP2.js} +1 -1
  189. package/dist/{chunk-3E4ZO73O.js → chunk-YYVBE6W2.js} +1 -1
  190. package/dist/{chunk-MEKPGQAM.js → chunk-Z5BFCTHI.js} +2 -2
  191. package/dist/{chunk-UEE3RZN4.js → chunk-Z777GGHB.js} +1 -1
  192. package/dist/{chunk-7NPTL66J.js → chunk-ZGQM6KWN.js} +1 -1
  193. package/dist/{chunk-QENCC2ZS.js → chunk-ZI3X7DI2.js} +1 -1
  194. package/dist/{chunk-3F5FMH76.js → chunk-ZKPY3AXW.js} +1 -1
  195. package/dist/chunk-ZRDX2ARO.js +4 -0
  196. package/dist/{chunk-MNBGG4H3.js → chunk-ZTAZ2R5Z.js} +1 -1
  197. package/dist/{chunk-LKQFG4RW.js → chunk-ZY65IZJR.js} +1 -1
  198. package/dist/{chunk-WZXPF3BI.js → chunk-ZZNQIFFI.js} +1 -1
  199. package/dist/commands-QOORPTSI.js +2 -0
  200. package/dist/{committer-JGY66PFM.js → committer-26UZDYSA.js} +1 -1
  201. package/dist/{config-754B73XK.js → config-B472DZSR.js} +1 -1
  202. package/dist/{cover-cmd-NBNZCR6C.js → cover-cmd-3VO6QC5Y.js} +1 -1
  203. package/dist/{credentials-F7DYLVWY.js → credentials-TLT3RQOO.js} +1 -1
  204. package/dist/{deps-bundle-PW3WEQJ7.js → deps-bundle-CMTIWBS5.js} +1 -1
  205. package/dist/{deps-resolve-SQYVN76L.js → deps-resolve-XLFZK74A.js} +1 -1
  206. package/dist/{design-chat-F3OEZPNJ.js → design-chat-I7X3QDDY.js} +1 -1
  207. package/dist/design-committer-Y7R56RFZ.js +2 -0
  208. package/dist/design-headless-HUQOXLZB.js +2 -0
  209. package/dist/{design-remote-2BEGCVCX.js → design-remote-UDC5FP45.js} +2 -2
  210. package/dist/device-env-MMGISNHN.js +2 -0
  211. package/dist/dispatch-P2445PUU.js +2 -0
  212. package/dist/{doctor-XY26Z35T.js → doctor-UHFCIM4B.js} +1 -1
  213. package/dist/{docx-convert-6IZO5P5K.js → docx-convert-N4KMLLKO.js} +1 -1
  214. package/dist/{dossier-NROC2MCY.js → dossier-6KMKEIXV.js} +1 -1
  215. package/dist/evidence-M3JTOJNL.js +2 -0
  216. package/dist/{evidence-presentation-YYTIDCBS.js → evidence-presentation-DV3DRB4S.js} +1 -1
  217. package/dist/evolve-cmd-K3JXACMN.js +2 -0
  218. package/dist/{evolve-remote-WLVY3QID.js → evolve-remote-CUDVV2O2.js} +1 -1
  219. package/dist/{exit-manager-EDHCETUN.js → exit-manager-EGWAZHCR.js} +1 -1
  220. package/dist/{explain-cmd-OP5I5W3O.js → explain-cmd-235TY7QX.js} +1 -1
  221. package/dist/{explain-cmd-VYAANFFZ.js → explain-cmd-R67B4YR3.js} +1 -1
  222. package/dist/explore-UDD5FHXW.js +2 -0
  223. package/dist/{explore-context-tty-RZ7D2TBV.js → explore-context-tty-YXEFT32U.js} +1 -1
  224. package/dist/{explore-entry-EKXJ67BD.js → explore-entry-V6L5FSP4.js} +4 -4
  225. package/dist/{explore-live-2YVRAQZO.js → explore-live-N5VBLBUI.js} +1 -1
  226. package/dist/{explore-run-tty-D47FGPX7.js → explore-run-tty-ZZQ33GNA.js} +2 -2
  227. package/dist/{extract-bind-W2NET364.js → extract-bind-BTINHHE5.js} +3 -3
  228. package/dist/{extract-chat-M65NWGUK.js → extract-chat-ABZ5S7UU.js} +1 -1
  229. package/dist/{extract-cmd-FTFLETOP.js → extract-cmd-45OZETCM.js} +2 -2
  230. package/dist/extract-headless-ALEFAMVS.js +2 -0
  231. package/dist/{feeder-NY45UFJK.js → feeder-L55TH2NC.js} +1 -1
  232. package/dist/folder-flags-HTKJCXKB.js +2 -0
  233. package/dist/{gaps-cmd-OIDDLRYL.js → gaps-cmd-ROGQWK5X.js} +1 -1
  234. package/dist/{gate-WISOUTHQ.js → gate-QA5J7UZA.js} +1 -1
  235. package/dist/gate-XFFFX5ZF.js +2 -0
  236. package/dist/{generate-headless-RURIEKVS.js → generate-headless-DAH3HHRQ.js} +2 -2
  237. package/dist/hold-passthrough-K5PP26CP.js +2 -0
  238. package/dist/impact-cmd-3VFJAKYK.js +11 -0
  239. package/dist/index.js +171 -165
  240. package/dist/ingest-S5R736ZV.js +2 -0
  241. package/dist/{ingest-cmd-4G2AK4Y2.js → ingest-cmd-YSEH5EPU.js} +3 -3
  242. package/dist/ingest-remote-C6AP2Q7E.js +2 -0
  243. package/dist/install-B26Y2NU4.js +2 -0
  244. package/dist/{interactive-bind-SI2ZS55Q.js → interactive-bind-P3GTFIZM.js} +4 -4
  245. package/dist/{interactive-remote-J56EWJGA.js → interactive-remote-PBRQHTAF.js} +2 -2
  246. package/dist/lane-7IEAE6AC.js +2 -0
  247. package/dist/lattice-auth-7EL4ET3P.js +2 -0
  248. package/dist/{lifecycle-cmd-HJ37LTXE.js → lifecycle-cmd-PUNFWKV5.js} +1 -1
  249. package/dist/{list-cmd-6XL2FYLQ.js → list-cmd-RD7YBF4S.js} +1 -1
  250. package/dist/list-commands-UZELZAB3.js +2 -0
  251. package/dist/{list-remote-LXPQNXYN.js → list-remote-KGKXPCQA.js} +1 -1
  252. package/dist/{locks-cmd-JJ2QNTNY.js → locks-cmd-LXZ6I4QG.js} +1 -1
  253. package/dist/{logical-ids-RXAQJZ3T.js → logical-ids-D5PFYY4C.js} +1 -1
  254. package/dist/login-flow-CHLGQGHK.js +2 -0
  255. package/dist/{maintenance-cmd-BXXHP36K.js → maintenance-cmd-WRWBCP3R.js} +1 -1
  256. package/dist/{mobile-prompts-CECJ5UY2.js → mobile-prompts-Z7NQHRGP.js} +1 -1
  257. package/dist/{onboarding-PDVYMTY5.js → onboarding-ZP4XDYEO.js} +1 -1
  258. package/dist/{open-provider-OZAG6WZS.js → open-provider-U26BBVUE.js} +1 -1
  259. package/dist/pdf-convert-LMKOKLXT.js +2 -0
  260. package/dist/{persist-recorded-session-A3ID7JFA.js → persist-recorded-session-4IRYG5CJ.js} +1 -1
  261. package/dist/phase-seed-2H6OXZXT.js +2 -0
  262. package/dist/pipeline-U7D25NST.js +2 -0
  263. package/dist/policy-commands-TY6WOR73.js +8 -0
  264. package/dist/prepare-target-EVL2QSXA.js +2 -0
  265. package/dist/{pull-cmd-UPFQYUND.js → pull-cmd-QJQANBAW.js} +1 -1
  266. package/dist/pull-route-AIOTLA3D.js +2 -0
  267. package/dist/{readmodel-INMP6MNW.js → readmodel-KXCFPL2M.js} +1 -1
  268. package/dist/real-device-run-QODMDUXF.js +2 -0
  269. package/dist/{reconcile-cmd-JBH365JL.js → reconcile-cmd-IJTQAJZX.js} +4 -4
  270. package/dist/reconcile-deps-2CTIFXDR.js +2 -0
  271. package/dist/{reconcile-remote-BCX6SWFC.js → reconcile-remote-23D6SXXT.js} +2 -2
  272. package/dist/{recording-banner-YKBAL6UB.js → recording-banner-MNRMMEX4.js} +1 -1
  273. package/dist/registry-MZYBLEW2.js +2 -0
  274. package/dist/remote-entry-DW2J56N4.js +2 -0
  275. package/dist/remote-mode-AFNCN6EE.js +4 -0
  276. package/dist/{remote-words-YVB66R3F.js → remote-words-RCNFI2TQ.js} +1 -1
  277. package/dist/{require-project-folder-MLMEQJYP.js → require-project-folder-7UH43GHI.js} +1 -1
  278. package/dist/{resolve-run-intent-PC7TQZUL.js → resolve-run-intent-XEWFYMGN.js} +1 -1
  279. package/dist/{resolver-EID34LQE.js → resolver-QMPX6RBR.js} +1 -1
  280. package/dist/{revert-FHOBLZWF.js → revert-37346WLE.js} +1 -1
  281. package/dist/{review-cmd-EUHFLFMY.js → review-cmd-2OECKNL5.js} +1 -1
  282. package/dist/run-JWOHNWA3.js +2 -0
  283. package/dist/run-QFJ6ZRVD.js +2 -0
  284. package/dist/run-remote-66QTUQ2M.js +2 -0
  285. package/dist/{run-startup-gate-YO66G6LS.js → run-startup-gate-USQFSW47.js} +1 -1
  286. package/dist/run-test-md-7DRWCSQE.js +19 -0
  287. package/dist/session-worker.js +2 -2
  288. package/dist/{sessions-cmd-S7WZBUCN.js → sessions-cmd-LQ2LZQOC.js} +2 -2
  289. package/dist/{sessions-remote-IWHWIQ2T.js → sessions-remote-H7CQST42.js} +1 -1
  290. package/dist/{skill-installer-MAVQY6GW.js → skill-installer-LKYY6XFJ.js} +1 -1
  291. package/dist/{store-MSA7KASS.js → store-KM5MG3XB.js} +1 -1
  292. package/dist/store-choice-4J2NN6OQ.js +2 -0
  293. package/dist/store-guard-34GG2TW2.js +2 -0
  294. package/dist/{store-site-KA2DNBGY.js → store-site-ZSFINU6C.js} +1 -1
  295. package/dist/stream-warnings-N4KVVWXV.js +2 -0
  296. package/dist/sync-cmd-3CHSWWWW.js +2 -0
  297. package/dist/{sync-setup-RBRDUV7Q.js → sync-setup-QQXYO6R4.js} +1 -1
  298. package/dist/tcg-generate-IPD5FQUW.js +2 -0
  299. package/dist/{test-definition-VRI4YIYL.js → test-definition-53XNBEDE.js} +1 -1
  300. package/dist/testmd-actions-V7P7BMKE.js +2 -0
  301. package/dist/{testmd-sync-UPAA5UMD.js → testmd-sync-PQ4GFKHB.js} +1 -1
  302. package/dist/tms-client-XWCR7O7J.js +2 -0
  303. package/dist/token-refresh-LR33BKAB.js +2 -0
  304. package/dist/{use-case-ref-NE4X4MZN.js → use-case-ref-NA3IXGQW.js} +1 -1
  305. package/dist/{validate-basic-M5JHHNZA.js → validate-basic-3DX3MMC7.js} +1 -1
  306. package/dist/verdicts-7GKZEDHV.js +2 -0
  307. package/dist/{version-check-Q737BE65.js → version-check-OV6AOVED.js} +1 -1
  308. package/dist/{view-cmd-XSNL5DGI.js → view-cmd-QDKBBNIU.js} +1 -1
  309. package/dist/{walk-session-SHGYLFRB.js → walk-session-BAYYPIKN.js} +1 -1
  310. package/dist/with-telemetry-62LW4VFI.js +2 -0
  311. package/package.json +12 -12
  312. package/dist/ChatSurface-6NZGMNHL.js +0 -2
  313. package/dist/EvidenceViewOffer-WIEWCZUP.js +0 -2
  314. package/dist/FolderPicker-AF7ZMV3M.js +0 -2
  315. package/dist/InfoBox-D7GGZJU4.js +0 -2
  316. package/dist/ProjectPicker-OBYHJJLU.js +0 -2
  317. package/dist/SaveSessionPrompt-7XSHS4NL.js +0 -2
  318. package/dist/SingleShotApp-XQUDR36R.js +0 -2
  319. package/dist/TestMdRunView-LS2QUFWR.js +0 -2
  320. package/dist/TestrunEvidenceTable-HNDVJDIF.js +0 -2
  321. package/dist/bind-4XWK3DG2.js +0 -2
  322. package/dist/bootstrap-6ACT4ALI.js +0 -2
  323. package/dist/chat-committer-ZCSRJEUB.js +0 -2
  324. package/dist/child-G2GCW73X.js +0 -2
  325. package/dist/chunk-65VANXOF.js +0 -147
  326. package/dist/chunk-C6HI6Y3S.js +0 -2
  327. package/dist/chunk-D36V5OX6.js +0 -2
  328. package/dist/chunk-HCJ2N3XB.js +0 -12
  329. package/dist/chunk-NC7D7GOM.js +0 -21
  330. package/dist/chunk-OGFU4YY4.js +0 -2
  331. package/dist/chunk-VZ4A6WMK.js +0 -97
  332. package/dist/chunk-W54OT2FU.js +0 -9
  333. package/dist/chunk-W72ACCFL.js +0 -27
  334. package/dist/design-committer-TRYP3LOZ.js +0 -2
  335. package/dist/design-headless-OTHYOX3E.js +0 -2
  336. package/dist/device-env-CHFRRV6W.js +0 -2
  337. package/dist/dispatch-DVQ3H7EJ.js +0 -2
  338. package/dist/evidence-P6FFKC7B.js +0 -2
  339. package/dist/evolve-cmd-WWOB3QJR.js +0 -2
  340. package/dist/explore-K5YBGHK6.js +0 -2
  341. package/dist/extract-headless-G6W6JQ27.js +0 -2
  342. package/dist/folder-flags-KKIH654K.js +0 -2
  343. package/dist/gate-7AKRPRMK.js +0 -2
  344. package/dist/hold-passthrough-IOWPVB4W.js +0 -2
  345. package/dist/ingest-PDGS5ZTL.js +0 -2
  346. package/dist/ingest-remote-SSLUHQVG.js +0 -2
  347. package/dist/install-ZVBHPXGP.js +0 -2
  348. package/dist/lane-AQYRIW24.js +0 -2
  349. package/dist/lattice-auth-6FEVSR7E.js +0 -2
  350. package/dist/list-commands-5DCCKU3L.js +0 -2
  351. package/dist/login-flow-WEK3E476.js +0 -2
  352. package/dist/pdf-convert-447ACUB3.js +0 -2
  353. package/dist/phase-seed-LCJ4WSYV.js +0 -2
  354. package/dist/pipeline-GX3LKPI5.js +0 -2
  355. package/dist/prepare-target-FMT6QFHZ.js +0 -2
  356. package/dist/pull-route-FWBXJMR7.js +0 -2
  357. package/dist/real-device-run-X7JJWOIK.js +0 -2
  358. package/dist/reconcile-deps-TWJ3FTSU.js +0 -2
  359. package/dist/registry-VQC757MJ.js +0 -2
  360. package/dist/remote-entry-X6JMPC2K.js +0 -2
  361. package/dist/remote-mode-FDPA7EWG.js +0 -4
  362. package/dist/run-5RQUCNYP.js +0 -2
  363. package/dist/run-PC5YO4AS.js +0 -2
  364. package/dist/run-remote-SJCRTL7O.js +0 -2
  365. package/dist/run-test-md-BLNBK4MH.js +0 -17
  366. package/dist/store-choice-3OJCV26J.js +0 -2
  367. package/dist/store-guard-OOSDLMEC.js +0 -2
  368. package/dist/stream-warnings-GEQKKJU7.js +0 -2
  369. package/dist/sync-cmd-RDFDMVKQ.js +0 -2
  370. package/dist/tcg-generate-KIECTZ2C.js +0 -2
  371. package/dist/testmd-actions-CMAG6HWI.js +0 -2
  372. package/dist/tms-client-NXAB6VJD.js +0 -2
  373. package/dist/token-refresh-KP3AYMYK.js +0 -2
  374. package/dist/verdicts-XK3GAUX3.js +0 -2
  375. package/dist/with-telemetry-PM2HVN2B.js +0 -2
@@ -1,15 +1,15 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Ee,b as te}from"./chunk-GFLB2SHW.js";import{a as ee}from"./chunk-2TVPA3LL.js";import{c as G}from"./chunk-22PIMG52.js";import{a as v,b as be,d as B,e as Te}from"./chunk-I2MC6VVX.js";import{a as z}from"./chunk-RPRXRKKR.js";import{a as M}from"./chunk-QXQ7KVEN.js";import{a as Se}from"./chunk-7AET4JKQ.js";import{b as we,c as ye,d as Re,e as Z,f as $e}from"./chunk-DJC7NTLA.js";import{na as ve,oa as P}from"./chunk-UEE3RZN4.js";import{g as fe}from"./chunk-NC7D7GOM.js";import{basename as wt,relative as ce}from"path";function Vt(e){return e.scope?.state==="finalized"?"saved":e.scope?.state==="discarded"?"discarded":e.ended==="complete"?"ready_to_save":e.ended==="failed"||e.status==="failed"?"failed":e.status==="paused"||e.status==="needs_attention"?"paused":"running"}var ne=["useCases","criteria","scenarios","tests","openQuestions","sources","styleNotes"],H=new Set(["sources","styleNotes"]);function xe(e){return ne.reduce((t,n)=>t+(H.has(n)?0:e[n]??0),0)}var nt=new Set(["NO_CASE","CASE_BROKEN","TEST_FILE_STALE","CASE_ARCHIVED"]),D=e=>typeof e=="string"?e:null;function st(e){let t=e.extra;switch(e.code){case"CASE_BROKEN":return{code:"CASE_BROKEN",session:D(t.session),caseId:D(t.caseId)??"",reason:t.reason==="moved"?"moved":"deleted"};case"CASE_ARCHIVED":return{code:"CASE_ARCHIVED",caseId:D(t.caseId)??"",internalId:D(t.internalId)??""};default:return{code:e.code,session:D(t.session),useCase:D(t.useCase)}}}function Jt(e){return(Array.isArray(e.nodes)?e.nodes:[]).filter(n=>typeof n.cid=="string"&&typeof n.label=="string").map(n=>({cid:n.cid,label:n.label,content:typeof n.content=="object"&&n.content!==null?n.content:{}}))}function qt(e){return(Array.isArray(e.names)?e.names:[]).filter(n=>typeof n.cid=="string"&&typeof n.slug=="string").map(n=>({cid:n.cid,slug:n.slug}))}function Kt(e){return(Array.isArray(e.supersessions)?e.supersessions:[]).filter(n=>n.kind==="node"&&typeof n.old=="string").map(n=>({old:n.old,new:typeof n.new=="string"?n.new:null}))}function Yt(e){let{request:t,exchange:n}=B(e),o=(s,r)=>`/v1/projects/${encodeURIComponent(s)}/uploads/${r}`,d=s=>`/v1/sessions/${encodeURIComponent(s)}`,a=async(s,r=null)=>{let l=[],m=r;do{let c=await t("GET",`${s}${m===null?"":`&after=${encodeURIComponent(m)}`}`);l.push(...c.items),m=c.next}while(m!==null);return l},i=async(s,r)=>{let l=await t("GET",`/v1/projects/${encodeURIComponent(s)}/sessions/${encodeURIComponent(r)}`),{proposes:m,heldChanges:c,changes:p,approves:u,archives:g,removes:w,chatTurns:h,uncounted:f}=l.drafts;return{proposes:m,heldChanges:c??0,changes:p??{},approves:u??{},archives:g??{},removes:w??{},chatTurns:h??0,uncounted:typeof f=="number"?f:null}};return{async*projects(){for(let s=1;s!==null;){let r=await t("GET",`/v1/projects?page=${s}`);r.items.length>0&&(yield r.items.map(({projectId:l,name:m,marked:c})=>({projectId:l,name:m,marked:c}))),s=r.next}},async project(s){let l=(await t("GET",`/v1/projects?projectId=${encodeURIComponent(s)}`)).items.find(m=>m.projectId===s);return l===void 0?null:{projectId:s,marked:l.marked===!0,mainPosition:l.context?.mainPosition??null}},async testCase(s,r,l){try{let m=await t("GET",`/v1/projects/${encodeURIComponent(s)}/tests/${encodeURIComponent(r)}/case?base=${encodeURIComponent(l)}`),{test:c,scenario:p,useCase:u,caseId:g,internalId:w,title:h,current:f,counts:$,canAttach:S}=m;return{linked:{test:c,scenario:p,useCase:u,caseId:g,internalId:w,title:h,current:f,counts:$,canAttach:S}}}catch(m){if(m instanceof v&&m.status===409&&nt.has(m.code))return{refused:st(m)};throw m}},async createSession(s){return(await t("POST","/v1/sessions",s)).session},async sources(s){let r=[],l=null;do{let m=`limit=1000${l===null?"":`&after=${encodeURIComponent(l)}`}`,c=await t("GET",`/v1/internal/projects/${encodeURIComponent(s)}/sources?${m}`);r.push(...c.items.map(({sourceId:p,head:u,completeness:g,origin:w,media:h})=>({sourceId:p,head:u,completeness:g,...w!==void 0?{origin:w}:{},...h!==void 0?{media:h}:{}}))),l=c.next}while(l!==null);return r},async mainRecord(s,r){let l=await t("GET",`/v1/internal/projects/${encodeURIComponent(s)}/positions/${r}`);return{position:l.position,record:l.record}},async mainNode(s,r){let l=await t("GET",`/v1/internal/projects/${encodeURIComponent(s)}/nodes/${encodeURIComponent(r)}`);return{cid:l.cid,name:l.name,label:l.label,content:l.content??{},supersededBy:l.supersededBy??null,edgesOut:(l.edgesOut??[]).map(({type:m,dst:c,other:p})=>({type:m,dst:c,other:p??null}))}},nodes:(s,r)=>a(`/v1/internal/projects/${encodeURIComponent(s)}/nodes?label=${encodeURIComponent(r)}&limit=1000`),async testsWithContent(s){let r=`/v1/internal/projects/${encodeURIComponent(s)}/nodes?label=test&content=1&limit=200`,l;try{l=await t("GET",r)}catch(c){if(c instanceof v&&c.status===400&&c.code==="BAD_REQUEST"&&c.message.includes('Unrecognized key: "content"'))return null;throw c}let m=l.next===null?[]:await a(r,l.next);return[...l.items,...m].map(c=>({...c,content:c.content??{}}))},edges:(s,r)=>a(`/v1/internal/projects/${encodeURIComponent(s)}/edges?type=${encodeURIComponent(r)}&limit=1000`),stale:s=>a(`/v1/internal/projects/${encodeURIComponent(s)}/stale?limit=1000`),async listSessions(s,r={}){let l=[],m=null,c=`${r.sourceId?`&sourceId=${encodeURIComponent(r.sourceId)}`:""}${r.useCase?`&useCase=${encodeURIComponent(r.useCase)}`:""}`;do{let p=`projectId=${encodeURIComponent(s)}${c}${m===null?"":`&after=${encodeURIComponent(m)}`}`,u=await t("GET",`/v1/sessions?${p}`);l.push(...u.items),m=u.next}while(m!==null);return l},getSession:s=>t("GET",d(s)),setStatus:(s,r)=>t("PATCH",d(s),{status:r}),land:(s,r)=>t("POST",`${d(s)}/land`,{generation:r}),discard:(s,r)=>t("POST",`${d(s)}/discard`,r===void 0?{}:{generation:r}),proposes:async(s,r)=>(await i(s,r)).proposes,counts:i,openUpload:(s,r)=>t("POST",`/v1/projects/${encodeURIComponent(s)}/uploads`,r),putUpload:async(s,r,l,m)=>{let{response:c,bytes:p}=await n("PUT",s,l,{headers:r,route:"PUT upload",...m?{onSend:m}:{}}),u=c.headers.get("etag");if(p.length>0)try{let g=JSON.parse(p.toString("utf8"));typeof g.etag=="string"&&(u=g.etag)}catch{}if(!u)throw new v(c.status,"BAD_RESPONSE","the upload's store answered no etag");return{etag:u}},completeUpload:(s,r,l)=>t("POST",`${o(s,r)}/complete`,{etag:l}),getUpload:(s,r)=>t("GET",o(s,r)),uploadResult:(s,r,l)=>t("POST",`${o(s,r)}/result`,l),async projectCoverage(s){let{state:r,doc:l}=await t("GET",`/v1/projects/${encodeURIComponent(s)}/coverage`);return{state:r,doc:l}},async coverageRun(s,r){return{pack:(await t("POST",`/v1/projects/${encodeURIComponent(s)}/coverage/run`,r)).pack}}}}import{isMainThread as lt}from"worker_threads";import{createHash as dt}from"crypto";function se(e){return e instanceof Error?e.message:String(e)}var ke="SUPERSEDED_WRITER",en="LEASE_LAPSED";function tn(e){let t=`/v1/sessions/${encodeURIComponent(e.sessionId)}/host`,{exchange:n,request:o}=B(e),d=i=>i===null?"limit=1000":`after=${encodeURIComponent(i)}&limit=1000`,a=i=>i===void 0?t:`${t}/children/${encodeURIComponent(i)}`;return{claim:()=>o("POST",`${t}/claim`,{forms:1}),session:()=>o("GET",t),renewLease:i=>o("POST",`${t}/lease`,{generation:i}),save:i=>o("PATCH",t,i),checkpointRows:i=>o("GET",`${a(i)}/checkpoints`,void 0,!0),async readCheckpointRow(i,s){return(await o("GET",`${a(s)}/checkpoints/${i}`,void 0,!0)).text},async writeCheckpointRow(i,s,r,{ifAbsent:l=!1,childId:m}={}){let c=`${a(m)}/checkpoints/${s}${l?"?ifAbsent=true":""}`;return(await o("PUT",c,{generation:i,text:r})).stored},async removeCheckpointRow(i,s,r){await o("DELETE",`${a(r)}/checkpoints/${s}?generation=${i}`)},registerChild:(i,s,r)=>o("POST",`${t}/children`,{generation:i,childId:s,...r?{useCase:r}:{}}),async sessionSide(){return(await o("GET",`${t}/side`)).text},async putSessionSide(i,s){await o("PUT",`${t}/side`,{generation:i,text:s})},saveChildPointer:(i,s,r,l)=>o("PATCH",a(s),{generation:i,checkpoint:r,state:l}),async sessionState(i){let{text:s}=await o("GET",`${a(i)}/state`);return s===null?null:JSON.parse(s)},async putSessionState(i,s,r){await o("PUT",`${a(r)}/state`,{generation:i,text:JSON.stringify(s)})},scope:()=>o("GET",`${t}/scope`),draftsPage:i=>o("GET",`${t}/scope/drafts?${d(i)}`,void 0,!0),appendDraft:(i,s)=>o("POST",`${t}/scope/drafts`,{generation:i,...s}),mainNodes:(i,s)=>o("POST",`${t}/main/nodes`,{position:i,cids:s}),async mainHistory(){let{response:i,bytes:s}=await n("GET",`${t}/main/history`,void 0,{headers:{"accept-encoding":"gzip"},bulk:!0}),r=Number(i.headers.get("lattice-history-position")),l=i.headers.get("lattice-history-hash");if(!Number.isInteger(r)||r<0||!l)throw new v(i.status,"UNEXPECTED_ANSWER",`GET ${t}/main/history answered without its Lattice-History-Position and Lattice-History-Hash headers`);return{position:r,hash:l,forms:be(i,"lattice-history-forms"),json:s}},async getBlob(i){try{return(await n("GET",`${t}/blobs/${encodeURIComponent(i)}`,void 0,{bulk:!0})).bytes}catch(s){if(s instanceof v&&s.code==="NOT_FOUND")return null;throw s}},putBlob:(i,s)=>o("PUT",`${t}/blobs?generation=${i}`,s),async files(i){return(await o("GET",`${t}/files?prefix=${encodeURIComponent(i)}`)).items},async readFile(i){try{let{response:s,bytes:r}=await n("GET",`${t}/file?name=${encodeURIComponent(i)}`,void 0,{bulk:!0}),l=Number(s.headers.get("lattice-file-version"));if(!Number.isInteger(l)||l<1)throw new v(s.status,"UNEXPECTED_ANSWER",`GET ${t}/file answered ${i} without a Lattice-File-Version header`);return{text:r.toString("utf8"),version:l}}catch(s){if(s instanceof v&&s.code==="NOT_FOUND")return null;throw s}},async embeddings(i,s){let r=`alias=${encodeURIComponent(i)}&purpose=${encodeURIComponent(s)}`,{bytes:l}=await n("GET",`${t}/embeddings?${r}`,void 0,{headers:{"accept-encoding":"gzip"},bulk:!0});return JSON.parse(l.toString("utf8"))},putEmbeddings:(i,s)=>o("POST",`${t}/embeddings`,{generation:i,...s}),putFile:(i,s,r,l)=>o("PUT",`${t}/file?name=${encodeURIComponent(s)}&generation=${i}&version=${r}`,l),appendEvents:(i,s)=>o("POST",`${t}/events`,{generation:i,events:s}),async eventsAfter(i){let s=[],r=null;do{let l=r===null?`after=${i}&limit=1000`:`after=${encodeURIComponent(r)}&limit=1000`,m=await o("GET",`${t}/events?${l}`);s.push(...m.items),r=m.next}while(r!==null);return s}}}var re="the session cannot go on: the project's context is being imported; it is served once an import of it completes",ot=5*6e4,Ce=2e3,it=15e3;function _e(e){return e instanceof v&&e.code==="CONTEXT_IMPORTING"}function Ie(){return new v(409,"CONTEXT_IMPORTING",re)}function on(e={}){let t=e.sleep??(a=>new Promise(i=>setTimeout(i,a))),n=e.budgetMs??ot,o=0,d=Ce;return{async wait(){let a=n-o;if(a<=0)return!1;let i=Math.min(d,a);return await t(i),o+=i,d=Math.min(d*2,it),!0},answered(){o=0,d=Ce}}}var R={scope:"store.scope",mainNodes:"store.mainNodes",mainNodesAhead:"store.mainNodesAhead",mainHistory:"store.mainHistory",drafts:"store.drafts",appendDraft:"store.appendDraft",vectorsRead:"store.vectorsRead",vectorsWrite:"store.vectorsWrite",getBlob:"store.getBlob",putBlob:"store.putBlob",chainRead:"chain.read",chainList:"chain.list",chainWrite:"chain.write",chainWriteIfAbsent:"chain.writeIfAbsent",chainRemove:"chain.remove",filesRead:"files.read",filesList:"files.list",filesWrite:"files.write",pointer:"session.pointer",stateGet:"session.stateGet",statePut:"session.statePut",acknowledge:"session.acknowledge",registerChild:"session.registerChild",children:"session.children",sideGet:"session.sideGet",sideSave:"session.sideSave"};var Pe=3e4,L=class extends Error{constructor(n,o,d,a=null){super(`Lattice refused ${n} (${o}): ${d}`);this.op=n;this.code=o;this.requestId=a;this.name="StepRefusedError"}};function ct(e){return e.status!==0?"not_ready":/no answer within/.test(e.message)?"timeout":"unreachable"}var Oe=new Set([ke,"SESSION_ENDED","PROJECT_NOT_MARKED"]);function fn(e,t){let n=t.sleep??(c=>new Promise(p=>setTimeout(p,c))),o=t.retryDeadlineMs??12e4,d=new Map((t.children??[]).map(c=>[c.childId,c.checkpoint?.pointer??null]));async function a(c,p){let u=Te(o,n,t.now);for(;;)try{let g=await p();return t.imports?.answered(),g}catch(g){if(!(g instanceof v))throw g;if(_e(g)&&t.imports){if(await t.imports.wait())continue;throw t.onStopped?.(Ie()),te(new Error(`Lattice refused ${c}: ${re}`),g)}if(Oe.has(g.code)&&t.onStopped?.(g),!g.retryable)throw new L(c,g.code,g.message,g.requestId);let w=h=>t.onRetry?.({op:c,attempt:u.attempt,nextInMs:h,giveUpAt:u.endsAt()??0,cause:ct(g)});if(!await u.again(w))throw t.onStopped?.(new v(g.status,g.code,`Lattice did not take ${c} within ${o/1e3} s: ${g.message}`,null,null,{},g.requestId)),te(new Error(`Lattice refused ${c} (${g.code}, still after ${o/1e3} s): ${g.message}`),g)}}async function i(c,p){try{return await p()}catch(u){throw u instanceof v?(Oe.has(u.code)&&t.onStopped?.(u),new L(c,u.code,u.message,u.requestId)):u}}async function s(c,p){let u=R.acknowledge,g=t.log;if(!g)throw new Error("the checkpoint barrier needs the session log, and this host gave it none");let w=Date.now()+Pe;for(;g.lastSeq()<c.eventSeq;){if(Date.now()>w)throw new Error(`the session log reached event ${g.lastSeq()}, not ${c.eventSeq}, within ${Pe/1e3} s; the checkpoint is not acknowledged`);await n(5)}await ut(g.flush(),o),await a(u,()=>e.writeCheckpointRow(t.generation,`side-${c.pointer.seq}.json`,JSON.stringify(c.side),{childId:p}));let h={pointer:c.pointer,covers:{eventSeq:c.eventSeq,scope:c.scope}},f=JSON.stringify(c.state);p===void 0?await a(u,()=>e.save({generation:t.generation,checkpoint:h,state:f})):d.set(p,(await a(u,()=>e.saveChildPointer(t.generation,p,h,f))).checkpoint.pointer)}async function r(){let c=await a(R.mainHistory,()=>e.mainHistory()),p=dt("sha256").update(c.json).digest("hex");if(p!==c.hash)throw new Error(`main's history from Lattice hashes to ${p}, not to ${c.hash}, the hash Lattice gave for it`);if(t.historyForms!==void 0&&c.forms!==t.historyForms){let u=`main's history pack was built at engine forms ${c.forms??"none named"}, not at ${t.historyForms}, the forms of the Lattice that took this host's claim: another Lattice served it`;throw t.onStopped?.(new v(409,"HISTORY_FORMS_MISMATCH",u)),new Error(u)}return c.json.toString("utf8")}let l=new Map,m=c=>`${Number(c.position)}:${c.cids.join(",")}`;return async(c,p)=>{let u=p??{},g=u.after??null,w=typeof u.childId=="string"?u.childId:void 0;switch(c){case R.scope:return await a(c,()=>e.scope());case R.mainHistory:return{json:await r()};case R.mainNodesAhead:{let h=e.mainNodes(Number(u.position),u.cids);return h.catch(()=>{}),l.set(m(u),h),null}case R.mainNodes:{let h=l.get(m(u));if(l.delete(m(u)),h)try{return await h}catch{}return await a(c,()=>e.mainNodes(Number(u.position),u.cids))}case R.drafts:return await a(c,()=>e.draftsPage(g));case R.appendDraft:{let h={eventId:u.eventId??null,record:u.record??null,envelope:u.envelope??null};return await a(c,()=>e.appendDraft(t.generation,h))}case R.filesRead:return(await a(c,()=>e.readFile(W(u.name))))?.text??null;case R.filesList:{let h=`${W(u.folder)}/`;return(await a(c,()=>e.files(h))).map($=>$.name.slice(h.length)).filter($=>!$.includes("/"))}case R.filesWrite:{if(!String(u.name).startsWith("rationale/"))throw new Error(`the host writes only test rationales; ${W(u.name)} is a configuration file, written by an operator`);try{return await a(c,()=>e.putFile(t.generation,W(u.name),0,Buffer.from(String(u.text),"utf8"))),{written:!0}}catch(h){if(/\(FILE_CHANGED\)/.test(se(h)))return{written:!1,message:se(h)};throw h}}case R.vectorsRead:return await i(c,()=>e.embeddings(String(u.alias),String(u.purpose)));case R.vectorsWrite:{let h={alias:String(u.alias),purpose:String(u.purpose),dims:Number(u.dims),vectors:u.vectors??{}};return await i(c,()=>e.putEmbeddings(t.generation,h))}case R.getBlob:{let h=await a(c,()=>e.getBlob(String(u.fingerprint)));return{bytes:h===null?null:h.toString("base64")}}case R.putBlob:return await a(c,()=>e.putBlob(t.generation,Buffer.from(String(u.bytes),"base64")));case R.chainRead:return await a(c,()=>e.readCheckpointRow(String(u.name),w));case R.chainList:return await a(c,()=>e.checkpointRows(w));case R.chainWrite:return await a(c,()=>e.writeCheckpointRow(t.generation,String(u.name),String(u.text),{childId:w})),null;case R.chainWriteIfAbsent:return await a(c,()=>e.writeCheckpointRow(t.generation,String(u.name),String(u.text),{ifAbsent:!0,childId:w}));case R.chainRemove:return await a(c,()=>e.removeCheckpointRow(t.generation,String(u.name),w)),null;case R.pointer:return w!==void 0?d.get(w)??null:(await a(c,()=>e.session())).checkpoint?.pointer??null;case R.stateGet:return await a(c,()=>e.sessionState(w));case R.statePut:return await a(c,()=>e.putSessionState(t.generation,u.state??null,w)),null;case R.acknowledge:return await s(u,w),null;case R.children:return[...(t.children??[]).map(h=>h.childId)];case R.sideGet:return await a(c,()=>e.sessionSide());case R.sideSave:return await a(c,()=>e.putSessionSide(t.generation,String(u.text))),{saved:!0};case R.registerChild:{let h=typeof u.useCase=="string"?u.useCase:void 0,f=await a(c,async()=>{try{return await e.registerChild(t.generation,String(u.childId),h)}catch($){throw $ instanceof v&&$.code==="SESSION_CLASH"?new Ee($.message,$.code,{heldBy:$.extra.heldBy??null},$.requestId):$}});return d.set(f.childId,f.checkpoint?.pointer??null),null}default:throw new Error(`the session thread asked for ${c}, which the main thread does not answer`)}}}function W(e){return`design/${String(e)}`}async function ut(e,t){let n,o=new Promise((d,a)=>{n=setTimeout(()=>a(new Error(`the session's events were not stored within ${t/1e3} s; the checkpoint is not acknowledged`)),t)});try{await Promise.race([e,o])}finally{clearTimeout(n)}}var x={verb:"remote",mode:"interactive"},oe=null,Ne=new Set;function Tn(e){x={...x,...e}}function V(e,t){return Ae(e,t),z()}function Ae(e,t){if(!(!Z()||Ne.has(e))){Ne.add(e);try{oe??=$e({verb:x.verb,mode:x.mode,contextRoot:null,env:Re(),sessionId:z(),errorsOnly:!0}),Object.assign(oe.ids,{...x.projectId?{project_id:x.projectId}:{},...x.latticeSessionId?{lattice_session_id:x.latticeSessionId}:{}}),oe.spoolError(e,t?{request_id:t}:{})}catch{}}}function gt(e){return e instanceof v||e instanceof L?`lattice_${e.code}`:"cli_crash"}function mt(e){let t=e?.requestId;return typeof t=="string"&&t?t:null}async function ht(){!Z()||!lt||await Promise.race([fe(ye()).catch(()=>{}),new Promise(e=>setTimeout(e,we).unref())])}async function xn(e,t){return e instanceof v&&Ae(gt(e),mt(e)),await ht(),t}import{isAbsolute as pt,relative as Le}from"path";var k=e=>" ".repeat(e);function ft(e){return e.length<2?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}var J=e=>e===1?"this test runs":"these tests run";function De(e,t,n){if(n===void 0||t+e.length<=n)return[k(t)+e];let o=[],d="";for(let a of e.split(" "))d&&t+d.length+1+a.length>n?(o.push(k(t)+d),d=a):d=d?`${d} ${a}`:a;return[...o,k(t)+d]}function _n(e,t){let n=e.variables.length;if(n===0)return[];let o=n===1?`\u2692 1 variable needs a value before ${J(t.tests)}; fill it in:`:`\u2692 ${n} variables need values before ${J(t.tests)}; fill them in:`,d=[k(t.indent)+o,k(t.indent+4)+(Le(t.cwd,e.file)||e.file)],a=e.variables.filter(i=>i.start_page).map(i=>i.name);return a.length===1?d.push(...De(`${a[0]} is the page ${t.tests===1?"it starts":"they start"} on`,t.indent+4,t.columns)):a.length>1&&d.push(...De(`${ft(a)} are the pages they start on`,t.indent+4,t.columns)),d}function Ue(e,t){let n=t.cwd??process.cwd(),o=s=>pt(s)&&Le(n,s)||s,d=e.length;if(d===0)return[];let a=d===1?"\u2692 1 test has no start page yet, so it can't run as it is:":`\u2692 ${d} tests have no start page yet, so they can't run as they are:`,i=d===1?"name the page in its first step, or run it with --url <the page>":"name the page in each one's first step, or run them with --url <the page>";return[k(t.indent)+a,...e.map(s=>k(t.indent+4)+(s.file?o(s.file):`${s.test} ${s.title}`)),k(t.indent+4)+i]}function je(e,t){let n=e.variables.length,o=e.noStartPage.length;return[...n===0?[]:[n===1?`1 variable needs a value before ${J(t.tests)}`:`${n} variables need values before ${J(t.tests)}`],...o===0?[]:[o===1?"1 test has no start page yet":`${o} tests have no start page yet`]]}function Bn(e,t="--mode agent"){if(!e.next)return e.remedy?{remedy:e.remedy}:{};let n=(e.remedy??"").split(`
2
+ import{a as Ee,b as te}from"./chunk-GFLB2SHW.js";import{a as ee}from"./chunk-2TVPA3LL.js";import{c as G}from"./chunk-22PIMG52.js";import{a as z}from"./chunk-RQKMSNEU.js";import{a as v,b as be,d as B,e as Te}from"./chunk-I2MC6VVX.js";import{a as M}from"./chunk-QXQ7KVEN.js";import{a as Se}from"./chunk-JFBEHCJN.js";import{b as we,c as ye,d as Re,e as Z,f as $e}from"./chunk-2L3A5NKZ.js";import{na as ve,oa as P}from"./chunk-Z777GGHB.js";import{g as fe}from"./chunk-UJLULWSR.js";import{basename as wt,relative as ce}from"path";function Vt(e){return e.scope?.state==="finalized"?"saved":e.scope?.state==="discarded"?"discarded":e.ended==="complete"?"ready_to_save":e.ended==="failed"||e.status==="failed"?"failed":e.status==="paused"||e.status==="needs_attention"?"paused":"running"}var ne=["useCases","criteria","scenarios","tests","openQuestions","sources","styleNotes"],H=new Set(["sources","styleNotes"]);function xe(e){return ne.reduce((t,n)=>t+(H.has(n)?0:e[n]??0),0)}var nt=new Set(["NO_CASE","CASE_BROKEN","TEST_FILE_STALE","CASE_ARCHIVED"]),U=e=>typeof e=="string"?e:null;function st(e){let t=e.extra;switch(e.code){case"CASE_BROKEN":return{code:"CASE_BROKEN",session:U(t.session),caseId:U(t.caseId)??"",reason:t.reason==="moved"?"moved":"deleted"};case"CASE_ARCHIVED":return{code:"CASE_ARCHIVED",caseId:U(t.caseId)??"",internalId:U(t.internalId)??""};default:return{code:e.code,session:U(t.session),useCase:U(t.useCase)}}}function Jt(e){return(Array.isArray(e.nodes)?e.nodes:[]).filter(n=>typeof n.cid=="string"&&typeof n.label=="string").map(n=>({cid:n.cid,label:n.label,content:typeof n.content=="object"&&n.content!==null?n.content:{}}))}function qt(e){return(Array.isArray(e.names)?e.names:[]).filter(n=>typeof n.cid=="string"&&typeof n.slug=="string").map(n=>({cid:n.cid,slug:n.slug}))}function Kt(e){return(Array.isArray(e.supersessions)?e.supersessions:[]).filter(n=>n.kind==="node"&&typeof n.old=="string").map(n=>({old:n.old,new:typeof n.new=="string"?n.new:null}))}function Yt(e){let{request:t,exchange:n}=B(e),o=(s,r)=>`/v1/projects/${encodeURIComponent(s)}/uploads/${r}`,d=s=>`/v1/sessions/${encodeURIComponent(s)}`,a=async(s,r=null)=>{let l=[],g=r;do{let c=await t("GET",`${s}${g===null?"":`&after=${encodeURIComponent(g)}`}`);l.push(...c.items),g=c.next}while(g!==null);return l},i=async(s,r)=>{let l=await t("GET",`/v1/projects/${encodeURIComponent(s)}/sessions/${encodeURIComponent(r)}`),{proposes:g,heldChanges:c,changes:p,approves:u,archives:m,removes:w,chatTurns:h,uncounted:f}=l.drafts;return{proposes:g,heldChanges:c??0,changes:p??{},approves:u??{},archives:m??{},removes:w??{},chatTurns:h??0,uncounted:typeof f=="number"?f:null}};return{async*projects(){for(let s=1;s!==null;){let r=await t("GET",`/v1/projects?page=${s}`);r.items.length>0&&(yield r.items.map(({projectId:l,name:g,marked:c})=>({projectId:l,name:g,marked:c}))),s=r.next}},async project(s){let l=(await t("GET",`/v1/projects?projectId=${encodeURIComponent(s)}`)).items.find(g=>g.projectId===s);return l===void 0?null:{projectId:s,marked:l.marked===!0,mainPosition:l.context?.mainPosition??null}},async testCase(s,r,l){try{let g=await t("GET",`/v1/projects/${encodeURIComponent(s)}/tests/${encodeURIComponent(r)}/case?base=${encodeURIComponent(l)}`),{test:c,scenario:p,useCase:u,caseId:m,internalId:w,title:h,current:f,counts:$,canAttach:S}=g;return{linked:{test:c,scenario:p,useCase:u,caseId:m,internalId:w,title:h,current:f,counts:$,canAttach:S}}}catch(g){if(g instanceof v&&g.status===409&&nt.has(g.code))return{refused:st(g)};throw g}},async testCases(s){let r=await t("GET",`/v1/projects/${encodeURIComponent(s)}/graph?project=1&types=testCase`),l=g=>g.linkState==="linked"&&typeof g.internalId=="string"&&/^TC-\d+$/.test(g.internalId)?g.internalId:null;return new Map(r.nodes.filter(g=>g.type==="testCase").map(g=>[g.id,l(g.data)]))},async createSession(s){return(await t("POST","/v1/sessions",s)).session},async sources(s){let r=[],l=null;do{let g=`limit=1000${l===null?"":`&after=${encodeURIComponent(l)}`}`,c=await t("GET",`/v1/internal/projects/${encodeURIComponent(s)}/sources?${g}`);r.push(...c.items.map(({sourceId:p,head:u,completeness:m,origin:w,media:h})=>({sourceId:p,head:u,completeness:m,...w!==void 0?{origin:w}:{},...h!==void 0?{media:h}:{}}))),l=c.next}while(l!==null);return r},async mainRecord(s,r){let l=await t("GET",`/v1/internal/projects/${encodeURIComponent(s)}/positions/${r}`);return{position:l.position,record:l.record}},async mainNode(s,r){let l=await t("GET",`/v1/internal/projects/${encodeURIComponent(s)}/nodes/${encodeURIComponent(r)}`);return{cid:l.cid,name:l.name,label:l.label,content:l.content??{},supersededBy:l.supersededBy??null,edgesOut:(l.edgesOut??[]).map(({type:g,dst:c,other:p})=>({type:g,dst:c,other:p??null}))}},nodes:(s,r)=>a(`/v1/internal/projects/${encodeURIComponent(s)}/nodes?label=${encodeURIComponent(r)}&limit=1000`),async testsWithContent(s){let r=`/v1/internal/projects/${encodeURIComponent(s)}/nodes?label=test&content=1&limit=200`,l;try{l=await t("GET",r)}catch(c){if(c instanceof v&&c.status===400&&c.code==="BAD_REQUEST"&&c.message.includes('Unrecognized key: "content"'))return null;throw c}let g=l.next===null?[]:await a(r,l.next);return[...l.items,...g].map(c=>({...c,content:c.content??{}}))},edges:(s,r)=>a(`/v1/internal/projects/${encodeURIComponent(s)}/edges?type=${encodeURIComponent(r)}&limit=1000`),stale:s=>a(`/v1/internal/projects/${encodeURIComponent(s)}/stale?limit=1000`),async listSessions(s,r={}){let l=[],g=null,c=`${r.sourceId?`&sourceId=${encodeURIComponent(r.sourceId)}`:""}${r.useCase?`&useCase=${encodeURIComponent(r.useCase)}`:""}`;do{let p=`projectId=${encodeURIComponent(s)}${c}${g===null?"":`&after=${encodeURIComponent(g)}`}`,u=await t("GET",`/v1/sessions?${p}`);l.push(...u.items),g=u.next}while(g!==null);return l},getSession:s=>t("GET",d(s)),setStatus:(s,r)=>t("PATCH",d(s),{status:r}),land:(s,r)=>t("POST",`${d(s)}/land`,{generation:r}),discard:(s,r)=>t("POST",`${d(s)}/discard`,r===void 0?{}:{generation:r}),proposes:async(s,r)=>(await i(s,r)).proposes,counts:i,openUpload:(s,r)=>t("POST",`/v1/projects/${encodeURIComponent(s)}/uploads`,r),putUpload:async(s,r,l,g)=>{let{response:c,bytes:p}=await n("PUT",s,l,{headers:r,route:"PUT upload",...g?{onSend:g}:{}}),u=c.headers.get("etag");if(p.length>0)try{let m=JSON.parse(p.toString("utf8"));typeof m.etag=="string"&&(u=m.etag)}catch{}if(!u)throw new v(c.status,"BAD_RESPONSE","the upload's store answered no etag");return{etag:u}},completeUpload:(s,r,l)=>t("POST",`${o(s,r)}/complete`,{etag:l}),getUpload:(s,r)=>t("GET",o(s,r)),uploadResult:(s,r,l)=>t("POST",`${o(s,r)}/result`,l),async projectCoverage(s){let{state:r,doc:l}=await t("GET",`/v1/projects/${encodeURIComponent(s)}/coverage`);return{state:r,doc:l}},async coverageRun(s,r){return{pack:(await t("POST",`/v1/projects/${encodeURIComponent(s)}/coverage/run`,r)).pack}}}}import{isMainThread as lt}from"worker_threads";import{createHash as dt}from"crypto";function se(e){return e instanceof Error?e.message:String(e)}var ke="SUPERSEDED_WRITER",en="LEASE_LAPSED";function tn(e){let t=`/v1/sessions/${encodeURIComponent(e.sessionId)}/host`,{exchange:n,request:o}=B(e),d=i=>i===null?"limit=1000":`after=${encodeURIComponent(i)}&limit=1000`,a=i=>i===void 0?t:`${t}/children/${encodeURIComponent(i)}`;return{claim:()=>o("POST",`${t}/claim`,{forms:1}),session:()=>o("GET",t),renewLease:i=>o("POST",`${t}/lease`,{generation:i}),save:i=>o("PATCH",t,i),checkpointRows:i=>o("GET",`${a(i)}/checkpoints`,void 0,!0),async readCheckpointRow(i,s){return(await o("GET",`${a(s)}/checkpoints/${i}`,void 0,!0)).text},async writeCheckpointRow(i,s,r,{ifAbsent:l=!1,childId:g}={}){let c=`${a(g)}/checkpoints/${s}${l?"?ifAbsent=true":""}`;return(await o("PUT",c,{generation:i,text:r})).stored},async removeCheckpointRow(i,s,r){await o("DELETE",`${a(r)}/checkpoints/${s}?generation=${i}`)},registerChild:(i,s,r)=>o("POST",`${t}/children`,{generation:i,childId:s,...r?{useCase:r}:{}}),async sessionSide(){return(await o("GET",`${t}/side`)).text},async putSessionSide(i,s){await o("PUT",`${t}/side`,{generation:i,text:s})},saveChildPointer:(i,s,r,l)=>o("PATCH",a(s),{generation:i,checkpoint:r,state:l}),async sessionState(i){let{text:s}=await o("GET",`${a(i)}/state`);return s===null?null:JSON.parse(s)},async putSessionState(i,s,r){await o("PUT",`${a(r)}/state`,{generation:i,text:JSON.stringify(s)})},scope:()=>o("GET",`${t}/scope`),draftsPage:i=>o("GET",`${t}/scope/drafts?${d(i)}`,void 0,!0),appendDraft:(i,s)=>o("POST",`${t}/scope/drafts`,{generation:i,...s}),mainNodes:(i,s)=>o("POST",`${t}/main/nodes`,{position:i,cids:s}),async mainHistory(){let{response:i,bytes:s}=await n("GET",`${t}/main/history`,void 0,{headers:{"accept-encoding":"gzip"},bulk:!0}),r=Number(i.headers.get("lattice-history-position")),l=i.headers.get("lattice-history-hash");if(!Number.isInteger(r)||r<0||!l)throw new v(i.status,"UNEXPECTED_ANSWER",`GET ${t}/main/history answered without its Lattice-History-Position and Lattice-History-Hash headers`);return{position:r,hash:l,forms:be(i,"lattice-history-forms"),json:s}},async getBlob(i){try{return(await n("GET",`${t}/blobs/${encodeURIComponent(i)}`,void 0,{bulk:!0})).bytes}catch(s){if(s instanceof v&&s.code==="NOT_FOUND")return null;throw s}},putBlob:(i,s)=>o("PUT",`${t}/blobs?generation=${i}`,s),async files(i){return(await o("GET",`${t}/files?prefix=${encodeURIComponent(i)}`)).items},async readFile(i){try{let{response:s,bytes:r}=await n("GET",`${t}/file?name=${encodeURIComponent(i)}`,void 0,{bulk:!0}),l=Number(s.headers.get("lattice-file-version"));if(!Number.isInteger(l)||l<1)throw new v(s.status,"UNEXPECTED_ANSWER",`GET ${t}/file answered ${i} without a Lattice-File-Version header`);return{text:r.toString("utf8"),version:l}}catch(s){if(s instanceof v&&s.code==="NOT_FOUND")return null;throw s}},async embeddings(i,s){let r=`alias=${encodeURIComponent(i)}&purpose=${encodeURIComponent(s)}`,{bytes:l}=await n("GET",`${t}/embeddings?${r}`,void 0,{headers:{"accept-encoding":"gzip"},bulk:!0});return JSON.parse(l.toString("utf8"))},putEmbeddings:(i,s)=>o("POST",`${t}/embeddings`,{generation:i,...s}),putFile:(i,s,r,l)=>o("PUT",`${t}/file?name=${encodeURIComponent(s)}&generation=${i}&version=${r}`,l),appendEvents:(i,s)=>o("POST",`${t}/events`,{generation:i,events:s}),async eventsAfter(i){let s=[],r=null;do{let l=r===null?`after=${i}&limit=1000`:`after=${encodeURIComponent(r)}&limit=1000`,g=await o("GET",`${t}/events?${l}`);s.push(...g.items),r=g.next}while(r!==null);return s}}}var re="the session cannot go on: the project's context is being imported; it is served once an import of it completes",ot=5*6e4,Ce=2e3,it=15e3;function _e(e){return e instanceof v&&e.code==="CONTEXT_IMPORTING"}function Ie(){return new v(409,"CONTEXT_IMPORTING",re)}function on(e={}){let t=e.sleep??(a=>new Promise(i=>setTimeout(i,a))),n=e.budgetMs??ot,o=0,d=Ce;return{async wait(){let a=n-o;if(a<=0)return!1;let i=Math.min(d,a);return await t(i),o+=i,d=Math.min(d*2,it),!0},answered(){o=0,d=Ce}}}var R={scope:"store.scope",mainNodes:"store.mainNodes",mainNodesAhead:"store.mainNodesAhead",mainHistory:"store.mainHistory",drafts:"store.drafts",appendDraft:"store.appendDraft",vectorsRead:"store.vectorsRead",vectorsWrite:"store.vectorsWrite",getBlob:"store.getBlob",putBlob:"store.putBlob",chainRead:"chain.read",chainList:"chain.list",chainWrite:"chain.write",chainWriteIfAbsent:"chain.writeIfAbsent",chainRemove:"chain.remove",filesRead:"files.read",filesList:"files.list",filesWrite:"files.write",pointer:"session.pointer",stateGet:"session.stateGet",statePut:"session.statePut",acknowledge:"session.acknowledge",registerChild:"session.registerChild",children:"session.children",sideGet:"session.sideGet",sideSave:"session.sideSave"};var Pe=3e4,D=class extends Error{constructor(n,o,d,a=null){super(`Lattice refused ${n} (${o}): ${d}`);this.op=n;this.code=o;this.requestId=a;this.name="StepRefusedError"}};function ct(e){return e.status!==0?"not_ready":/no answer within/.test(e.message)?"timeout":"unreachable"}var Oe=new Set([ke,"SESSION_ENDED","PROJECT_NOT_MARKED"]);function fn(e,t){let n=t.sleep??(c=>new Promise(p=>setTimeout(p,c))),o=t.retryDeadlineMs??12e4,d=new Map((t.children??[]).map(c=>[c.childId,c.checkpoint?.pointer??null]));async function a(c,p){let u=Te(o,n,t.now);for(;;)try{let m=await p();return t.imports?.answered(),m}catch(m){if(!(m instanceof v))throw m;if(_e(m)&&t.imports){if(await t.imports.wait())continue;throw t.onStopped?.(Ie()),te(new Error(`Lattice refused ${c}: ${re}`),m)}if(Oe.has(m.code)&&t.onStopped?.(m),!m.retryable)throw new D(c,m.code,m.message,m.requestId);let w=h=>t.onRetry?.({op:c,attempt:u.attempt,nextInMs:h,giveUpAt:u.endsAt()??0,cause:ct(m)});if(!await u.again(w))throw t.onStopped?.(new v(m.status,m.code,`Lattice did not take ${c} within ${o/1e3} s: ${m.message}`,null,null,{},m.requestId)),te(new Error(`Lattice refused ${c} (${m.code}, still after ${o/1e3} s): ${m.message}`),m)}}async function i(c,p){try{return await p()}catch(u){throw u instanceof v?(Oe.has(u.code)&&t.onStopped?.(u),new D(c,u.code,u.message,u.requestId)):u}}async function s(c,p){let u=R.acknowledge,m=t.log;if(!m)throw new Error("the checkpoint barrier needs the session log, and this host gave it none");let w=Date.now()+Pe;for(;m.lastSeq()<c.eventSeq;){if(Date.now()>w)throw new Error(`the session log reached event ${m.lastSeq()}, not ${c.eventSeq}, within ${Pe/1e3} s; the checkpoint is not acknowledged`);await n(5)}await ut(m.flush(),o),await a(u,()=>e.writeCheckpointRow(t.generation,`side-${c.pointer.seq}.json`,JSON.stringify(c.side),{childId:p}));let h={pointer:c.pointer,covers:{eventSeq:c.eventSeq,scope:c.scope}},f=JSON.stringify(c.state);p===void 0?await a(u,()=>e.save({generation:t.generation,checkpoint:h,state:f})):d.set(p,(await a(u,()=>e.saveChildPointer(t.generation,p,h,f))).checkpoint.pointer)}async function r(){let c=await a(R.mainHistory,()=>e.mainHistory()),p=dt("sha256").update(c.json).digest("hex");if(p!==c.hash)throw new Error(`main's history from Lattice hashes to ${p}, not to ${c.hash}, the hash Lattice gave for it`);if(t.historyForms!==void 0&&c.forms!==t.historyForms){let u=`main's history pack was built at engine forms ${c.forms??"none named"}, not at ${t.historyForms}, the forms of the Lattice that took this host's claim: another Lattice served it`;throw t.onStopped?.(new v(409,"HISTORY_FORMS_MISMATCH",u)),new Error(u)}return c.json.toString("utf8")}let l=new Map,g=c=>`${Number(c.position)}:${c.cids.join(",")}`;return async(c,p)=>{let u=p??{},m=u.after??null,w=typeof u.childId=="string"?u.childId:void 0;switch(c){case R.scope:return await a(c,()=>e.scope());case R.mainHistory:return{json:await r()};case R.mainNodesAhead:{let h=e.mainNodes(Number(u.position),u.cids);return h.catch(()=>{}),l.set(g(u),h),null}case R.mainNodes:{let h=l.get(g(u));if(l.delete(g(u)),h)try{return await h}catch{}return await a(c,()=>e.mainNodes(Number(u.position),u.cids))}case R.drafts:return await a(c,()=>e.draftsPage(m));case R.appendDraft:{let h={eventId:u.eventId??null,record:u.record??null,envelope:u.envelope??null};return await a(c,()=>e.appendDraft(t.generation,h))}case R.filesRead:return(await a(c,()=>e.readFile(W(u.name))))?.text??null;case R.filesList:{let h=`${W(u.folder)}/`;return(await a(c,()=>e.files(h))).map($=>$.name.slice(h.length)).filter($=>!$.includes("/"))}case R.filesWrite:{if(!String(u.name).startsWith("rationale/"))throw new Error(`the host writes only test rationales; ${W(u.name)} is a configuration file, written by an operator`);try{return await a(c,()=>e.putFile(t.generation,W(u.name),0,Buffer.from(String(u.text),"utf8"))),{written:!0}}catch(h){if(/\(FILE_CHANGED\)/.test(se(h)))return{written:!1,message:se(h)};throw h}}case R.vectorsRead:return await i(c,()=>e.embeddings(String(u.alias),String(u.purpose)));case R.vectorsWrite:{let h={alias:String(u.alias),purpose:String(u.purpose),dims:Number(u.dims),vectors:u.vectors??{}};return await i(c,()=>e.putEmbeddings(t.generation,h))}case R.getBlob:{let h=await a(c,()=>e.getBlob(String(u.fingerprint)));return{bytes:h===null?null:h.toString("base64")}}case R.putBlob:return await a(c,()=>e.putBlob(t.generation,Buffer.from(String(u.bytes),"base64")));case R.chainRead:return await a(c,()=>e.readCheckpointRow(String(u.name),w));case R.chainList:return await a(c,()=>e.checkpointRows(w));case R.chainWrite:return await a(c,()=>e.writeCheckpointRow(t.generation,String(u.name),String(u.text),{childId:w})),null;case R.chainWriteIfAbsent:return await a(c,()=>e.writeCheckpointRow(t.generation,String(u.name),String(u.text),{ifAbsent:!0,childId:w}));case R.chainRemove:return await a(c,()=>e.removeCheckpointRow(t.generation,String(u.name),w)),null;case R.pointer:return w!==void 0?d.get(w)??null:(await a(c,()=>e.session())).checkpoint?.pointer??null;case R.stateGet:return await a(c,()=>e.sessionState(w));case R.statePut:return await a(c,()=>e.putSessionState(t.generation,u.state??null,w)),null;case R.acknowledge:return await s(u,w),null;case R.children:return[...(t.children??[]).map(h=>h.childId)];case R.sideGet:return await a(c,()=>e.sessionSide());case R.sideSave:return await a(c,()=>e.putSessionSide(t.generation,String(u.text))),{saved:!0};case R.registerChild:{let h=typeof u.useCase=="string"?u.useCase:void 0,f=await a(c,async()=>{try{return await e.registerChild(t.generation,String(u.childId),h)}catch($){throw $ instanceof v&&$.code==="SESSION_CLASH"?new Ee($.message,$.code,{heldBy:$.extra.heldBy??null},$.requestId):$}});return d.set(f.childId,f.checkpoint?.pointer??null),null}default:throw new Error(`the session thread asked for ${c}, which the main thread does not answer`)}}}function W(e){return`design/${String(e)}`}async function ut(e,t){let n,o=new Promise((d,a)=>{n=setTimeout(()=>a(new Error(`the session's events were not stored within ${t/1e3} s; the checkpoint is not acknowledged`)),t)});try{await Promise.race([e,o])}finally{clearTimeout(n)}}var x={verb:"remote",mode:"interactive"},oe=null,Ne=new Set;function Tn(e){x={...x,...e}}function V(e,t){return Ae(e,t),z()}function Ae(e,t){if(!(!Z()||Ne.has(e))){Ne.add(e);try{oe??=$e({verb:x.verb,mode:x.mode,contextRoot:null,env:Re(),sessionId:z(),errorsOnly:!0}),Object.assign(oe.ids,{...x.projectId?{project_id:x.projectId}:{},...x.latticeSessionId?{lattice_session_id:x.latticeSessionId}:{}}),oe.spoolError(e,t?{request_id:t}:{})}catch{}}}function gt(e){return e instanceof v||e instanceof D?`lattice_${e.code}`:"cli_crash"}function mt(e){let t=e?.requestId;return typeof t=="string"&&t?t:null}async function ht(){!Z()||!lt||await Promise.race([fe(ye()).catch(()=>{}),new Promise(e=>setTimeout(e,we).unref())])}async function xn(e,t){return e instanceof v&&Ae(gt(e),mt(e)),await ht(),t}import{isAbsolute as pt,relative as De}from"path";var k=e=>" ".repeat(e);function ft(e){return e.length<2?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}var J=e=>e===1?"this test runs":"these tests run";function Ue(e,t,n){if(n===void 0||t+e.length<=n)return[k(t)+e];let o=[],d="";for(let a of e.split(" "))d&&t+d.length+1+a.length>n?(o.push(k(t)+d),d=a):d=d?`${d} ${a}`:a;return[...o,k(t)+d]}function _n(e,t){let n=e.variables.length;if(n===0)return[];let o=n===1?`\u2692 1 variable needs a value before ${J(t.tests)}; fill it in:`:`\u2692 ${n} variables need values before ${J(t.tests)}; fill them in:`,d=[k(t.indent)+o,k(t.indent+4)+(De(t.cwd,e.file)||e.file)],a=e.variables.filter(i=>i.start_page).map(i=>i.name);return a.length===1?d.push(...Ue(`${a[0]} is the page ${t.tests===1?"it starts":"they start"} on`,t.indent+4,t.columns)):a.length>1&&d.push(...Ue(`${ft(a)} are the pages they start on`,t.indent+4,t.columns)),d}function Le(e,t){let n=t.cwd??process.cwd(),o=s=>pt(s)&&De(n,s)||s,d=e.length;if(d===0)return[];let a=d===1?"\u2692 1 test has no start page yet, so it can't run as it is:":`\u2692 ${d} tests have no start page yet, so they can't run as they are:`,i=d===1?"name the page in its first step, or run it with --url <the page>":"name the page in each one's first step, or run them with --url <the page>";return[k(t.indent)+a,...e.map(s=>k(t.indent+4)+(s.file?o(s.file):`${s.test} ${s.title}`)),k(t.indent+4)+i]}function je(e,t){let n=e.variables.length,o=e.noStartPage.length;return[...n===0?[]:[n===1?`1 variable needs a value before ${J(t.tests)}`:`${n} variables need values before ${J(t.tests)}`],...o===0?[]:[o===1?"1 test has no start page yet":`${o} tests have no start page yet`]]}function Bn(e,t="--mode agent"){if(!e.next)return e.remedy?{remedy:e.remedy}:{};let n=(e.remedy??"").split(`
3
3
  `).filter(o=>!/^\s+kane-cli /.test(o)).join(" ").replace(/(, run)?:$/,"").replace(/[,;]\s*(then\s+)?run:\s*kane-cli\b.*$/,"").trim();return{...n?{remedy:n}:{},next:e.next.map(o=>({cmd:`${o.cmd} ${t}`,why:o.why}))}}function Gn(e){let t=e;return!t||typeof t.sessionId!="string"||typeof t.verb!="string"?null:{sessionId:t.sessionId,verb:t.verb,useCase:typeof t.useCase=="string"?t.useCase:null,mine:t.mine===!0,status:typeof t.status=="string"?t.status:"running"}}var Hn=e=>({sid:e.sessionId,verb:e.verb,use_case:e.useCase,mine:e.mine,status:e.status}),yt={useCases:["use-case","use-cases"],criteria:["acceptance criterion","acceptance criteria"],scenarios:["scenario","scenarios"],tests:["test","tests"],openQuestions:["open question","open questions"],sources:["source","sources"],styleNotes:["style note","style notes"]},ue=ne.map(e=>[e,...yt[e]]),X=(e,t=H)=>{let n=ue.filter(([d])=>(e[d]??0)>0),o=n.filter(([d])=>!t.has(d));return o.length>0?o:n},Rt=new Set(["styleNotes"]),le=e=>e?ue.filter(([t])=>(e[t]??0)>0).map(([t,n,o])=>`${e[t]} ${e[t]===1?n:o}`):[];function $t(e){let t=o=>o?I(X(o).map(([d,a,i])=>`${o[d]} ${o[d]===1?a:i}`)):"",n=[[t(e),"added"],...Ve.map(({key:o,done:d})=>[t(e[o]),o==="changes"?"changed":d])].filter(([o])=>o!=="").map(([o,d])=>`${o} ${d}`);return N(e)>0&&n.push(Ke(N(e))),n.length>0?n.join(", "):null}function Wn(e){let t=$t(e.counts),n=[G(e.durS),...t?[t]:[],...e.credits!==void 0?[`${e.credits.toFixed(1)} credits`]:[]].join(" \xB7 "),o=e.title?`"${e.title}"`:P(e.id??"");return t||(e.counts.uncounted??0)>0?`\u25CF updated ${o} \u2014 ${n}`:`\u25CF nothing changed in ${o} \u2014 ${n}`}function Vn(e){let t=e.title?`"${e.title}"`:P(e.id??""),n=[G(e.durS),`${e.tests} ${e.tests===1?"test":"tests"}`,...e.credits!==void 0?[`${e.credits.toFixed(1)} credits`]:[]];return`\u25CF designed ${t} \u2014 ${n.join(" \xB7 ")}`}function Jn(e){return`\u25CF finished ${e.title?`"${e.title}"`:P(e.id??"")} \u2014 ${[G(e.durS),...e.credits!==void 0?[`${e.credits.toFixed(1)} credits`]:[]].join(" \xB7 ")}`}var I=e=>e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`,Ve=[{key:"changes",row:"updates",done:"updated",saving:"updates"},{key:"approves",row:"approves",done:"approved",saving:"approves"},{key:"archives",row:"archives",done:"archived",saving:"archives"},{key:"replaces",row:"replaces",done:"replaced",saving:"replaces"},{key:"removes",row:"removes",done:"removed",saving:"removes"}],Q=e=>Ve.filter(({key:t})=>j(e[t])),Je=e=>Q(e).length>0,ge=e=>e===1?"1 test":`${e} tests`,vt=e=>[...Q(e).map(({key:t,done:n})=>`${I(le(e[t]))} ${n}`),...e.keeps?[`${ge(e.keeps)} marked up to date`]:[]],qn=e=>[...Q(e).map(({key:t,saving:n})=>`saving it ${n} ${I(le(e[t]))}${t==="removes"?" from the project":""}`),...e.keeps?[`saving it marks ${ge(e.keeps)} up to date`]:[]],Kn=e=>[...vt(e),...N(e)>0?[Ye(N(e))]:[]],Yn=e=>ue.reduce((t,[n])=>t+(H.has(n)?0:e.changes?.[n]??0),0),Xn=e=>xe(e),bt=e=>F(e)!==""||j(e.changes)||j(e.approves)||j(e.archives),St="this session's work",Qn=e=>F(e)?"throw away what this session added":me(e)?"throw away this session's chat":"throw away this session's work",zn="already discarded \u2014 nothing was saved",Zn=e=>bt(e)?"your team can see it now":me(e)?Et:xt(e)?St:"",Et="this session's chat";function es(e,t){let n=t.removes;if(e==="extract"||!n||!((n.scenarios??0)>0||(n.tests??0)>0))return t;let o={...(n.scenarios??0)>0?{scenarios:n.scenarios}:{},...(n.tests??0)>0?{tests:n.tests}:{}},{scenarios:d,tests:a,...i}=n,{removes:s,...r}=t;return{...r,replaces:o,...j(i)?{removes:i}:{}}}function ts(e){let t=new Map;for(let n of e){if(n.kind!=="evolve_diff")continue;let o=n.payload??n.body;if(typeof o?.use_case!="string")continue;let d=o.repinned?.tests;typeof d=="number"&&d>0?t.set(o.use_case,d):t.delete(o.use_case)}return t}function ns(e,t){let n=[...t.values()].reduce((i,s)=>i+s,0);if(n===0)return e;let o=Math.max(0,(e.uncounted??0)-t.size),{uncounted:d,...a}=e;return{...a,keeps:n,...o>0?{uncounted:o}:{}}}var Tt=["changes","approves","archives","removes"],N=e=>e.heldChanges??0,j=e=>Object.values(e??{}).some(t=>(t??0)>0),qe=e=>!(e.adds??F(e))&&!Je(e)&&N(e)===0&&(e.keeps??0)===0,me=e=>qe(e)&&(e.chatTurns??0)>0&&(e.uncounted??0)===0,xt=e=>qe(e)&&!me(e);async function ss(e,t,n){let o=await e.counts(t,n),{proposes:d,heldChanges:a,chatTurns:i,uncounted:s}=o;return{...d,...a>0?{heldChanges:a}:{},...Object.fromEntries(Tt.flatMap(r=>j(o[r])?[[r,o[r]]]:[])),...i&&i>0?{chatTurns:i}:{},...typeof s=="number"?{exact:!0}:{},...typeof s=="number"&&s>0?{uncounted:s}:{}}}function Ke(e){return e===1?"1 change to an existing use-case":`${e} changes to existing use-cases`}function Ye(e){return`${Ke(e)}, saved but not applied`}var kt=e=>F(e)!==""||Je(e)||N(e)>0||(e.keeps??0)>0||(e.chatTurns??0)>0||(e.uncounted??0)>0,rs=(e,t)=>e.exact?kt(e):t;function os(e,t){let n=F(e),o=N(e),d=[];n&&d.push(["adds",n]);for(let{key:s,row:r}of Q(e))d.push([r,le(e[s]).join(", ")]);e.keeps&&d.push(["keeps",`${ge(e.keeps)}, marked up to date`]),o>0&&d.push(["held",Ye(o)]);let a=(e.chatTurns??0)>0;((e.uncounted??0)>0||!e.exact&&d.length===0&&!a)&&d.push(["other","work not counted here"]),a&&d.push(["chat","saved with the session; your team can read it"]),d.push(["project",t?"changed since this session started":"no changes since this session started"]);let i=s=>(s?.scenarios??0)+(s?.tests??0);return i(e)+i(e.changes)>0&&d.push(["then","its test cases are created or updated in Test Manager"]),d}function F(e){return X(e,Rt).map(([t,n,o])=>`${e[t]} ${e[t]===1?n:o}`).join(", ")}function is(e){let t=X(e);if(t.length!==1)return"your work is";let[n,o,d]=t[0];return e[n]===1?`your ${o} is`:`your ${e[n]} ${d} are`}function Ct(e,t=[]){return t.length>0?`start a new session from the latest project, adding this session's documents again; run:
4
4
  ${Xe(t)}`:`${e.startsWith("kane-cli design tests")?"to design it again from the latest project":"to start a new session from the latest project"}, run:
5
- ${e}`}var Xe=e=>`kane-cli context ingest ${e.map(Y).join(" ")}`;function as(e,t){return e.length>0?[...new Set(e)]:_t(t)}function _t(e){return[...new Set((e.uploads??[]).filter(t=>t.outcome==="created"&&t.filename).map(t=>t.filename))]}function It(e){let t=X(e);if(t.length!==1)return"its work";let[n,o,d]=t[0];return e[n]===1?`its ${o}`:`its ${e[n]} ${d}`}function ds(e){return e.replace(/\s*\([^()]*→[^()]*\)/g,"")}function cs(e,t,n){return`kane-cli ${e==="design"?"design tests":"context extract"} --resume ${t}${n?" --mode agent":""}`}var Me=e=>`updating kane-cli won't help \u2014 share this id with support: ${V(`refused_${e}`)}`,q="in a folder linked to a shared project",U="check the file, then run the command again",ie=e=>[`${e} has more inside it than kane-cli can read`,"save a smaller copy, or a PDF of it, then run the command again"],Pt={PDF_ENCRYPTED:e=>[`${e} is password-protected`,"remove the password, then run the command again"],PDF_NO_TEXT_LAYER:e=>[`${e} has no text to read; scanned PDFs aren't supported yet`,"use a PDF with text in it, then run the command again"],PDF_UNREADABLE:e=>[`${e} can't be read as a PDF`,U],DOCX_UNREADABLE:e=>[`${e} can't be read as a Word document`,U],DOCX_NOT_WORDPROCESSING:e=>[`${e} can't be read as a Word document`,U],DOCX_NO_TEXT:e=>[`${e} has no text to add`,U],DOCX_ENCRYPTED_OR_LEGACY:e=>[`${e} is password-protected or in the old Word format`,"save it as a .docx without a password, then run the command again"],DOCX_PART_TOO_LARGE:ie,DOCX_TOO_MANY_PARTS:ie,DOCX_BOMB:ie,SOURCE_ID_OWNED:e=>[`${e} can't become a version of that source: a source plugin reads it`,"add it under another id with --as <id>, then run the command again"]},Ot={changed_both_sides:"it was changed in Test Manager too; choose there which steps to keep",not_pushable:"its steps can't be changed from here; change them in Test Manager",archived:"it's archived in Test Manager; restore it there first",busy:"a test run is using it; wait until the run ends",not_accepted:"Test Manager has different steps for it; choose there which to keep"},O=e=>`${e} ${e===1?"test case":"test cases"}`,Fe={test_on_older_version:"it changed after its test was designed",test_unreadable:"its test can't be read",test_has_no_steps:"its test has no steps"},Qe=e=>ve.test(e)?e.toLowerCase():e,ze=e=>Object.hasOwn(Fe,e)?Fe[e]:void 0,Ze=e=>e.useCase&&ze(e.reason)!==void 0&&e.reason!=="test_unreadable"?Qe(e.useCase):null;function us(e){if(!e||e==="unread")return;let t=new Map([...e.wrote,...e.unchanged??[]].map(n=>[n.id.toLowerCase(),n.path]));for(let n of e.refused)n.file&&t.set(n.id.toLowerCase(),n.file);return n=>t.get(n.toLowerCase())}var de=e=>e.reason==="test_unreadable";function Nt(e,t){let n=ze(e.reason);if(n===void 0)return[{text:" it can't be sent to Test Manager yet",tone:"detail"}];if(e.reason==="test_unreadable"){let d=t?.(e.test);return[{text:` ${n}${d?`: ${pe(d)}`:""}`,tone:"detail"}]}let o=Ze(e);return o===null?[{text:` ${n}`,tone:"detail"}]:[{text:` ${n}; to design its tests again, run:`,tone:"detail"},{text:` kane-cli design tests --use-case ${o}`,tone:"detail",command:!0}]}var K=(e,t)=>t===void 0||typeof e.useCase!="string"||t.has(Qe(e.useCase));function At(e,t,n){let o=e===1,d=`to see ${o?"its use-case":"their use-cases"}, run: kane-cli context list --stale`,a=o?"1 scenario of another use-case":`${e} scenarios of other use-cases`;return n?[{text:` ${a} ${o?"isn't":"aren't"} in Test Manager either`,tone:"detail"},{text:` ${d}`,tone:"detail"}]:[{text:`${a} in ${y(t)} ${o?"isn't":"aren't"} in Test Manager`,tone:"detail"},{text:` ${d}`,tone:"detail"}]}var C="some test cases may not be there yet";function he(e,t){switch(e){case"TEST_MANAGER_TIMEOUT":return{why:`Test Manager took too long, so ${C}`,lead:`Test Manager took too long; ${C}`,next:"to finish them (nothing is saved twice), run:",remedy:!1,support:!1,agentCode:"TEST_MANAGER_TIMED_OUT"};case"FORGE_UNAVAILABLE":return{why:`Test Manager couldn't be reached, so ${C}`,lead:`Test Manager couldn't be reached; ${C}`,next:"to finish them (nothing is saved twice), run:",remedy:!1,support:!0,agentCode:"TEST_MANAGER_UNREACHABLE"};case"FORGE_REFUSED":return{why:`Test Manager refused your account, so ${C}`,lead:`Test Manager refused your account; ${C}`,next:"ask a Test Manager admin to grant your account access, then run:",remedy:!0,support:!1,agentCode:"PROJECT_NO_ACCESS"};case"PROJECT_NOT_MARKED":return{why:`assurance is now off for "${t}", so ${C}`,lead:`assurance is now off for "${t}"; ${C}`,next:"to try them again later (nothing is saved twice), run:",remedy:!0,support:!1,agentCode:"ASSURANCE_OFF"};default:return{why:"some test cases couldn't be created or updated in Test Manager",lead:"some test cases couldn't be created or updated in Test Manager",next:"to try them again (nothing is saved twice), run:",remedy:!1,support:!0,agentCode:"TEST_MANAGER_FAILED"}}}function ls(e,t,n,o,d){let a={receipt:null,summary:null,lines:[],support:!1};if(!e)return a;let{made:i,updated:s,waiting:r,error:l}=e,m=e.nextRun??[],c=e.notCovered??[],p=c.filter(b=>K(b,o)),u=c.length-p.length;if(i===0&&s===0&&r===0&&l===null&&m.length===0&&c.length===0)return a;let g=i>0&&s>0?`${O(i)} created and ${s} updated in Test Manager`:i>0?`${O(i)} created in Test Manager`:s>0?`${O(s)} updated in Test Manager`:null,w={text:` kane-cli context sessions save ${t}`,tone:"plain"},h=b=>b===1?"wasn't":"weren't",f=[];if(m.length>0){let b=m.length===1;f.push({text:`${O(m.length)} in Test Manager ${b?"updates on its":"update on their"} next kane-cli run:`,tone:"plain"});for(let A of m)f.push({text:` "${A.title}"`,tone:"detail"});(r>0||l!==null||c.length>0)&&f.push({text:"",tone:"plain"})}if(r>0){f.push({text:`warning: ${O(r)} in Test Manager ${h(r)} updated`,tone:"warning"});for(let b of e.waitingOn)f.push({text:` "${b.title}"`,tone:"detail"},{text:` ${Ot[b.reason]}`,tone:"detail"})}if(p.length>0){let b=p.length;f.push({text:`warning: ${b} ${b===1?"scenario wasn't":"scenarios weren't"} sent to Test Manager`,tone:"warning"});for(let A of p)f.push({text:` "${A.title}"`,tone:"detail"},...Nt(A,d))}u>0&&f.push(...At(u,n,p.length>0));let $=l===null?null:he(l.code,n);$&&f.push({text:`warning: the session was saved, but ${$.why}`,tone:"warning"});let S=$?$.remedy||r===0?$.next:"then, to finish them (nothing is saved twice), run:":r>0?`then, to update ${r===1?"it":"them"} (nothing is saved twice), run:`:null;S!==null&&f.push({text:`next: ${S}`,tone:"plain"},w);let E=[];if(g!==null&&E.push(g),r>0&&E.push(g!==null?`${r} ${h(r)} updated yet`:`${O(r)} in Test Manager ${h(r)} updated yet`),p.length>0){let b=p.length;E.push(`${E.length>0?b:`${b} ${b===1?"scenario":"scenarios"}`} ${b===1?"wasn't":"weren't"} sent to Test Manager`)}return $&&E.push(E.length>0?"some may not be there yet":$.lead),{receipt:g,summary:E.length>0?E.join("; "):null,...m.length>0?{nextRunSummary:`${O(m.length)} ${m.length===1?"updates on its":"update on their"} next kane-cli run`}:{},lines:f,support:($?.support??!1)||p.some(de)}}function gs(e,t,n,o){if(!e)return;let d=e.notCovered??[],a=[...new Set(d.flatMap(s=>{let r=K(s,n)?Ze(s):null;return r===null?[]:[r]}))],i=[...e.error!==null?[{cmd:`kane-cli context sessions save ${t} --mode agent`,why:"finishes the test cases that may not be there yet"}]:[],...a.map(s=>({cmd:`kane-cli design tests --use-case ${s} --force --mode agent`,why:"designs the use case's tests again, so its scenarios reach Test Manager"}))];return{total:e.total,created:e.made,updated:e.updated,already_there:e.linked,waiting:e.waiting,waiting_on:e.waitingOn.map(({scenario:s,title:r,reason:l})=>({scenario:s,title:r,reason:l})),next_run:(e.nextRun??[]).map(({scenario:s,title:r})=>({scenario:s,title:r})),...d.length>0?{not_covered:d.map(s=>{let r=de(s)?o?.(s.test):void 0;return{scenario:s.scenario,title:s.title,test:s.test,reason:s.reason,in_session:K(s,n),...r?{file:pe(r)}:{}}})}:{},...e.error!==null?{error:he(e.error.code,"").agentCode}:{},...d.some(s=>K(s,n)&&de(s))?{support_id:V("refused_TEST_UNREADABLE")}:{},...i.length>0?{next:i}:{}}}var Be=new Set(["duplicate","unwritable"]),et=e=>Be.has(e.kind)||e.kind==="import"&&e.via!==void 0&&Be.has(e.via),Dt=new Set(["unreadable","unresolved"]);function Lt(e,t){return!e||e.variables.length===0&&e.noStartPage.length===0?{}:{needed:{...e,tests:t},neededFacts:je(e,{tests:t})}}function Ut(e){if(!e||e.length===0)return{};let t=e.length===1?"1 test file here was replaced and won't run any more":`${e.length} test files here were replaced and won't run any more`;return{replacedHead:`\u2692 ${t}:`,replaced:e.map(n=>({file:ce(process.cwd(),n.file)||n.file,by:n.replacedBy.map(o=>wt(o))})),replacedSummary:t}}function jt(e){return e!=null&&e.error===null}var tt=(e,t)=>{if(!jt(t)||t.waitingOn.length>0)return[];let n=new Set((t.notCovered??[]).map(o=>o.test.toLowerCase()));return e.filter(o=>o.file&&!n.has(o.id.toLowerCase()))},pe=e=>M(ce(process.cwd(),e)||e);function ms(e,t,n,o={}){let d={text:` kane-cli context sessions save ${t}`,tone:"plain"};if(e==="unread")return{line:null,lines:[{text:"warning: the session was saved, but its test files couldn't be written here",tone:"warning"},{text:"next: to write them (nothing is saved twice), run:",tone:"plain"},d],support:!0,summary:"its test files aren't written here yet",kept:null,again:"all"};let a=e.wrote.length,i=e.refused.length,s=a+(e.unchanged?.length??0),r=s+i,l=e.saved?new Set(e.saved):null,m=l?e.wrote.filter(S=>!l.has(S.id)).length:0,c=S=>`${m} ${m===1?"test":"tests"} ${S?"it imports":"they import"}`,p=a===0?null:n||i===0&&s>a?`\u2692 wrote ${a===1?"1 test file that was":`${a} test files that were`} missing or out of date here`:i>0?`\u2692 wrote ${a} of the ${r} test files`:m>0?`\u2692 wrote ${a} test files, for ${a-m===1?`the saved test and ${c(!0)}`:`${a-m} saved tests and ${c(!1)}`}`:a===1?"\u2692 wrote 1 test file, for the saved test":`\u2692 wrote ${a} test files, one for each saved test`,u={...Ut(e.replaced),...Lt(e.needed,e.saved?.length??r)};if(i===0)return{line:p,lines:[],support:!1,summary:null,kept:null,again:0,...u};let w=[{text:`warning: ${i===r?`${i===1?"1 test file wasn't":`${i} test files weren't`} written`:`${i} of the ${r} test files ${i===1?"wasn't":"weren't"} written`}`,tone:"warning"}];for(let S of e.refused)w.push({text:S.title?` "${S.title}"`:" a test with no title",tone:"detail"},{text:` ${ee(S)}`,tone:"detail"});let h=e.refused.filter(et).length;h>0&&w.push({text:`next: then, to write ${h===1?"it":"them"} (nothing is saved twice), run:`,tone:"plain"},d);let f=e.refused.filter(S=>S.kind==="edited");if(f.length>0){let S=f.length===1,E=tt(f,o.testManager);if(E.length>0){w.push({text:E.length===1?"next: to send your edit to its test case in Test Manager, run:":"next: to send your edits to their test cases in Test Manager, run:",tone:"plain"});for(let A of E)w.push({text:` kane-cli testmd run ${pe(A.file)}`,tone:"plain"})}let b=`${E.length>0?"or, to":"next: to"} get the project's ${S?"version, move it":"versions, move them"} out of this folder`;h>0?w.push({text:`${b} and save again`,tone:"plain"}):w.push({text:`${b}, then run:`,tone:"plain"},d)}let $=i-f.length;return{line:p,lines:w,support:e.refused.some(S=>Dt.has(S.kind)),summary:s>0?`${s} of the ${r} test files written here`:$===0?null:f.length>0?`${$} of the ${r} test files ${$===1?"isn't":"aren't"} written here yet`:r===1?"its test file isn't written here yet":"its test files aren't written here yet",kept:f.length===0?null:f.length>1?`${f.length} test files here keep your edits`:r===1?"its test file here keeps your edit":"1 test file here keeps your edit",again:h,...u}}function hs(e,t,n){if(!e||!t||t.again===0)return null;let o=`write ${t.again===1?"the test file":"the test files"}`;return e.error!==null?he(e.error.code,n).remedy?null:`next: to finish them and ${o} (nothing is saved twice), run:`:e.waiting>0?`next: then, to update ${e.waiting===1?"the test case":"the test cases"} and ${o} (nothing is saved twice), run:`:null}function ps(e,t,n={}){let o=`kane-cli context sessions save ${t} --mode agent`;if(e==="unread")return{written:[],refused:[],error:"TEST_FILES_NOT_WRITTEN",next:[{cmd:o,why:"writes the test files here"}]};let d=e.refused.some(et),a=e.refused.filter(r=>r.kind==="edited"),i=a.length===0?"":a.length===1?", and the project's version of a kept file once it's moved out of its folder":", and the project's version of the kept files once they're moved out of their folder",s=[...d?[{cmd:o,why:`writes the test files not written here${i}`}]:[],...tt(a,n.testManager).map(r=>({cmd:`kane-cli testmd run ${M(r.file)} --agent`,why:"sends your edit to its test case in Test Manager"})),...a.length>0&&!d?[{cmd:o,why:"writes the project's version, once the file is moved out of its folder"}]:[]];return{written:e.wrote.map(r=>r.path),refused:e.refused.map(r=>({test:r.id,title:r.title,reason:ee(r),...r.kind==="edited"&&r.file?{file:r.file}:{}})),...e.replaced?.length?{replaced:e.replaced.map(r=>({test:r.test,file:r.file,replaced_by:r.replacedBy}))}:{},...e.needed?.variables.length?{variables_needed:{file:e.needed.file,variables:e.needed.variables}}:{},...e.needed?.noStartPage.length?{no_start_page:e.needed.noStartPage.map(r=>({test:r.test,...r.file?{file:r.file}:{}}))}:{},...s.length>0?{next:s}:{}}}var Mt={ac:"an acceptance criterion",scenario:"a scenario",test:"a test",gap:"an open question",source:"a source",stylenote:"a style note"},T=(e,t)=>e?`"${e}"`:P(t),Ge=(e,t,n)=>`${e} ${e===1?t:n}`,fs={trusted:"approved",derived:"proposed",archived:"archived"},ws={yes:"yes",source_changed:"no: its source changed",source_removed:"no: its source was removed",tests_out_of_date:"no: its tests are out of date",designed_from_changed:"no: what it was designed from changed",archived:"-"},ys={source_changed:"its source changed",source_removed:"its source was removed",tests_out_of_date:"changed after its tests were designed"},y=e=>e?`"${e}"`:"this session's project",_=(e,t)=>`kane-cli design tests --use-case ${e}${t}`,ae=e=>e?"its source's change was put off in an earlier review; to take it up":"to review its source's change",He=e=>e.split(`
5
+ ${e}`}var Xe=e=>`kane-cli context ingest ${e.map(Y).join(" ")}`;function as(e,t){return e.length>0?[...new Set(e)]:_t(t)}function _t(e){return[...new Set((e.uploads??[]).filter(t=>t.outcome==="created"&&t.filename).map(t=>t.filename))]}function It(e){let t=X(e);if(t.length!==1)return"its work";let[n,o,d]=t[0];return e[n]===1?`its ${o}`:`its ${e[n]} ${d}`}function ds(e){return e.replace(/\s*\([^()]*→[^()]*\)/g,"")}function cs(e,t,n){return`kane-cli ${e==="design"?"design tests":"context extract"} --resume ${t}${n?" --mode agent":""}`}var Me=e=>`updating kane-cli won't help \u2014 share this id with support: ${V(`refused_${e}`)}`,q="in a folder linked to a shared project",L="check the file, then run the command again",ie=e=>[`${e} has more inside it than kane-cli can read`,"save a smaller copy, or a PDF of it, then run the command again"],Pt={PDF_ENCRYPTED:e=>[`${e} is password-protected`,"remove the password, then run the command again"],PDF_NO_TEXT_LAYER:e=>[`${e} has no text to read; scanned PDFs aren't supported yet`,"use a PDF with text in it, then run the command again"],PDF_UNREADABLE:e=>[`${e} can't be read as a PDF`,L],DOCX_UNREADABLE:e=>[`${e} can't be read as a Word document`,L],DOCX_NOT_WORDPROCESSING:e=>[`${e} can't be read as a Word document`,L],DOCX_NO_TEXT:e=>[`${e} has no text to add`,L],DOCX_ENCRYPTED_OR_LEGACY:e=>[`${e} is password-protected or in the old Word format`,"save it as a .docx without a password, then run the command again"],DOCX_PART_TOO_LARGE:ie,DOCX_TOO_MANY_PARTS:ie,DOCX_BOMB:ie,SOURCE_ID_OWNED:e=>[`${e} can't become a version of that source: a source plugin reads it`,"add it under another id with --as <id>, then run the command again"]},Ot={changed_both_sides:"it was changed in Test Manager too; choose there which steps to keep",not_pushable:"its steps can't be changed from here; change them in Test Manager",archived:"it's archived in Test Manager; restore it there first",busy:"a test run is using it; wait until the run ends",not_accepted:"Test Manager has different steps for it; choose there which to keep"},O=e=>`${e} ${e===1?"test case":"test cases"}`,Fe={test_on_older_version:"it changed after its test was designed",test_unreadable:"its test can't be read",test_has_no_steps:"its test has no steps"},Qe=e=>ve.test(e)?e.toLowerCase():e,ze=e=>Object.hasOwn(Fe,e)?Fe[e]:void 0,Ze=e=>e.useCase&&ze(e.reason)!==void 0&&e.reason!=="test_unreadable"?Qe(e.useCase):null;function us(e){if(!e||e==="unread")return;let t=new Map([...e.wrote,...e.unchanged??[]].map(n=>[n.id.toLowerCase(),n.path]));for(let n of e.refused)n.file&&t.set(n.id.toLowerCase(),n.file);return n=>t.get(n.toLowerCase())}var de=e=>e.reason==="test_unreadable";function Nt(e,t){let n=ze(e.reason);if(n===void 0)return[{text:" it can't be sent to Test Manager yet",tone:"detail"}];if(e.reason==="test_unreadable"){let d=t?.(e.test);return[{text:` ${n}${d?`: ${pe(d)}`:""}`,tone:"detail"}]}let o=Ze(e);return o===null?[{text:` ${n}`,tone:"detail"}]:[{text:` ${n}; to design its tests again, run:`,tone:"detail"},{text:` kane-cli design tests --use-case ${o}`,tone:"detail",command:!0}]}var K=(e,t)=>t===void 0||typeof e.useCase!="string"||t.has(Qe(e.useCase));function At(e,t,n){let o=e===1,d=`to see ${o?"its use-case":"their use-cases"}, run: kane-cli context list --stale`,a=o?"1 scenario of another use-case":`${e} scenarios of other use-cases`;return n?[{text:` ${a} ${o?"isn't":"aren't"} in Test Manager either`,tone:"detail"},{text:` ${d}`,tone:"detail"}]:[{text:`${a} in ${y(t)} ${o?"isn't":"aren't"} in Test Manager`,tone:"detail"},{text:` ${d}`,tone:"detail"}]}var C="some test cases may not be there yet";function he(e,t){switch(e){case"TEST_MANAGER_TIMEOUT":return{why:`Test Manager took too long, so ${C}`,lead:`Test Manager took too long; ${C}`,next:"to finish them (nothing is saved twice), run:",remedy:!1,support:!1,agentCode:"TEST_MANAGER_TIMED_OUT"};case"FORGE_UNAVAILABLE":return{why:`Test Manager couldn't be reached, so ${C}`,lead:`Test Manager couldn't be reached; ${C}`,next:"to finish them (nothing is saved twice), run:",remedy:!1,support:!0,agentCode:"TEST_MANAGER_UNREACHABLE"};case"FORGE_REFUSED":return{why:`Test Manager refused your account, so ${C}`,lead:`Test Manager refused your account; ${C}`,next:"ask a Test Manager admin to grant your account access, then run:",remedy:!0,support:!1,agentCode:"PROJECT_NO_ACCESS"};case"PROJECT_NOT_MARKED":return{why:`assurance is now off for "${t}", so ${C}`,lead:`assurance is now off for "${t}"; ${C}`,next:"to try them again later (nothing is saved twice), run:",remedy:!0,support:!1,agentCode:"ASSURANCE_OFF"};default:return{why:"some test cases couldn't be created or updated in Test Manager",lead:"some test cases couldn't be created or updated in Test Manager",next:"to try them again (nothing is saved twice), run:",remedy:!1,support:!0,agentCode:"TEST_MANAGER_FAILED"}}}function ls(e,t,n,o,d){let a={receipt:null,summary:null,lines:[],support:!1};if(!e)return a;let{made:i,updated:s,waiting:r,error:l}=e,g=e.nextRun??[],c=e.notCovered??[],p=c.filter(b=>K(b,o)),u=c.length-p.length;if(i===0&&s===0&&r===0&&l===null&&g.length===0&&c.length===0)return a;let m=i>0&&s>0?`${O(i)} created and ${s} updated in Test Manager`:i>0?`${O(i)} created in Test Manager`:s>0?`${O(s)} updated in Test Manager`:null,w={text:` kane-cli context sessions save ${t}`,tone:"plain"},h=b=>b===1?"wasn't":"weren't",f=[];if(g.length>0){let b=g.length===1;f.push({text:`${O(g.length)} in Test Manager ${b?"updates on its":"update on their"} next kane-cli run:`,tone:"plain"});for(let A of g)f.push({text:` "${A.title}"`,tone:"detail"});(r>0||l!==null||c.length>0)&&f.push({text:"",tone:"plain"})}if(r>0){f.push({text:`warning: ${O(r)} in Test Manager ${h(r)} updated`,tone:"warning"});for(let b of e.waitingOn)f.push({text:` "${b.title}"`,tone:"detail"},{text:` ${Ot[b.reason]}`,tone:"detail"})}if(p.length>0){let b=p.length;f.push({text:`warning: ${b} ${b===1?"scenario wasn't":"scenarios weren't"} sent to Test Manager`,tone:"warning"});for(let A of p)f.push({text:` "${A.title}"`,tone:"detail"},...Nt(A,d))}u>0&&f.push(...At(u,n,p.length>0));let $=l===null?null:he(l.code,n);$&&f.push({text:`warning: the session was saved, but ${$.why}`,tone:"warning"});let S=$?$.remedy||r===0?$.next:"then, to finish them (nothing is saved twice), run:":r>0?`then, to update ${r===1?"it":"them"} (nothing is saved twice), run:`:null;S!==null&&f.push({text:`next: ${S}`,tone:"plain"},w);let E=[];if(m!==null&&E.push(m),r>0&&E.push(m!==null?`${r} ${h(r)} updated yet`:`${O(r)} in Test Manager ${h(r)} updated yet`),p.length>0){let b=p.length;E.push(`${E.length>0?b:`${b} ${b===1?"scenario":"scenarios"}`} ${b===1?"wasn't":"weren't"} sent to Test Manager`)}return $&&E.push(E.length>0?"some may not be there yet":$.lead),{receipt:m,summary:E.length>0?E.join("; "):null,...g.length>0?{nextRunSummary:`${O(g.length)} ${g.length===1?"updates on its":"update on their"} next kane-cli run`}:{},lines:f,support:($?.support??!1)||p.some(de)}}function gs(e,t,n,o){if(!e)return;let d=e.notCovered??[],a=[...new Set(d.flatMap(s=>{let r=K(s,n)?Ze(s):null;return r===null?[]:[r]}))],i=[...e.error!==null?[{cmd:`kane-cli context sessions save ${t} --mode agent`,why:"finishes the test cases that may not be there yet"}]:[],...a.map(s=>({cmd:`kane-cli design tests --use-case ${s} --force --mode agent`,why:"designs the use case's tests again, so its scenarios reach Test Manager"}))];return{total:e.total,created:e.made,updated:e.updated,already_there:e.linked,waiting:e.waiting,waiting_on:e.waitingOn.map(({scenario:s,title:r,reason:l})=>({scenario:s,title:r,reason:l})),next_run:(e.nextRun??[]).map(({scenario:s,title:r})=>({scenario:s,title:r})),...d.length>0?{not_covered:d.map(s=>{let r=de(s)?o?.(s.test):void 0;return{scenario:s.scenario,title:s.title,test:s.test,reason:s.reason,in_session:K(s,n),...r?{file:pe(r)}:{}}})}:{},...e.error!==null?{error:he(e.error.code,"").agentCode}:{},...d.some(s=>K(s,n)&&de(s))?{support_id:V("refused_TEST_UNREADABLE")}:{},...i.length>0?{next:i}:{}}}var Be=new Set(["duplicate","unwritable"]),et=e=>Be.has(e.kind)||e.kind==="import"&&e.via!==void 0&&Be.has(e.via),Ut=new Set(["unreadable","unresolved"]);function Dt(e,t){return!e||e.variables.length===0&&e.noStartPage.length===0?{}:{needed:{...e,tests:t},neededFacts:je(e,{tests:t})}}function Lt(e){if(!e||e.length===0)return{};let t=e.length===1?"1 test file here was replaced and won't run any more":`${e.length} test files here were replaced and won't run any more`;return{replacedHead:`\u2692 ${t}:`,replaced:e.map(n=>({file:ce(process.cwd(),n.file)||n.file,by:n.replacedBy.map(o=>wt(o))})),replacedSummary:t}}function jt(e){return e!=null&&e.error===null}var tt=(e,t)=>{if(!jt(t)||t.waitingOn.length>0)return[];let n=new Set((t.notCovered??[]).map(o=>o.test.toLowerCase()));return e.filter(o=>o.file&&!n.has(o.id.toLowerCase()))},pe=e=>M(ce(process.cwd(),e)||e);function ms(e,t,n,o={}){let d={text:` kane-cli context sessions save ${t}`,tone:"plain"};if(e==="unread")return{line:null,lines:[{text:"warning: the session was saved, but its test files couldn't be written here",tone:"warning"},{text:"next: to write them (nothing is saved twice), run:",tone:"plain"},d],support:!0,summary:"its test files aren't written here yet",kept:null,again:"all"};let a=e.wrote.length,i=e.refused.length,s=a+(e.unchanged?.length??0),r=s+i,l=e.saved?new Set(e.saved):null,g=l?e.wrote.filter(S=>!l.has(S.id)).length:0,c=S=>`${g} ${g===1?"test":"tests"} ${S?"it imports":"they import"}`,p=a===0?null:n||i===0&&s>a?`\u2692 wrote ${a===1?"1 test file that was":`${a} test files that were`} missing or out of date here`:i>0?`\u2692 wrote ${a} of the ${r} test files`:g>0?`\u2692 wrote ${a} test files, for ${a-g===1?`the saved test and ${c(!0)}`:`${a-g} saved tests and ${c(!1)}`}`:a===1?"\u2692 wrote 1 test file, for the saved test":`\u2692 wrote ${a} test files, one for each saved test`,u={...Lt(e.replaced),...Dt(e.needed,e.saved?.length??r)};if(i===0)return{line:p,lines:[],support:!1,summary:null,kept:null,again:0,...u};let w=[{text:`warning: ${i===r?`${i===1?"1 test file wasn't":`${i} test files weren't`} written`:`${i} of the ${r} test files ${i===1?"wasn't":"weren't"} written`}`,tone:"warning"}];for(let S of e.refused)w.push({text:S.title?` "${S.title}"`:" a test with no title",tone:"detail"},{text:` ${ee(S)}`,tone:"detail"});let h=e.refused.filter(et).length;h>0&&w.push({text:`next: then, to write ${h===1?"it":"them"} (nothing is saved twice), run:`,tone:"plain"},d);let f=e.refused.filter(S=>S.kind==="edited");if(f.length>0){let S=f.length===1,E=tt(f,o.testManager);if(E.length>0){w.push({text:E.length===1?"next: to send your edit to its test case in Test Manager, run:":"next: to send your edits to their test cases in Test Manager, run:",tone:"plain"});for(let A of E)w.push({text:` kane-cli testmd run ${pe(A.file)}`,tone:"plain"})}let b=`${E.length>0?"or, to":"next: to"} get the project's ${S?"version, move it":"versions, move them"} out of this folder`;h>0?w.push({text:`${b} and save again`,tone:"plain"}):w.push({text:`${b}, then run:`,tone:"plain"},d)}let $=i-f.length;return{line:p,lines:w,support:e.refused.some(S=>Ut.has(S.kind)),summary:s>0?`${s} of the ${r} test files written here`:$===0?null:f.length>0?`${$} of the ${r} test files ${$===1?"isn't":"aren't"} written here yet`:r===1?"its test file isn't written here yet":"its test files aren't written here yet",kept:f.length===0?null:f.length>1?`${f.length} test files here keep your edits`:r===1?"its test file here keeps your edit":"1 test file here keeps your edit",again:h,...u}}function hs(e,t,n){if(!e||!t||t.again===0)return null;let o=`write ${t.again===1?"the test file":"the test files"}`;return e.error!==null?he(e.error.code,n).remedy?null:`next: to finish them and ${o} (nothing is saved twice), run:`:e.waiting>0?`next: then, to update ${e.waiting===1?"the test case":"the test cases"} and ${o} (nothing is saved twice), run:`:null}function ps(e,t,n={}){let o=`kane-cli context sessions save ${t} --mode agent`;if(e==="unread")return{written:[],refused:[],error:"TEST_FILES_NOT_WRITTEN",next:[{cmd:o,why:"writes the test files here"}]};let d=e.refused.some(et),a=e.refused.filter(r=>r.kind==="edited"),i=a.length===0?"":a.length===1?", and the project's version of a kept file once it's moved out of its folder":", and the project's version of the kept files once they're moved out of their folder",s=[...d?[{cmd:o,why:`writes the test files not written here${i}`}]:[],...tt(a,n.testManager).map(r=>({cmd:`kane-cli testmd run ${M(r.file)} --agent`,why:"sends your edit to its test case in Test Manager"})),...a.length>0&&!d?[{cmd:o,why:"writes the project's version, once the file is moved out of its folder"}]:[]];return{written:e.wrote.map(r=>r.path),refused:e.refused.map(r=>({test:r.id,title:r.title,reason:ee(r),...r.kind==="edited"&&r.file?{file:r.file}:{}})),...e.replaced?.length?{replaced:e.replaced.map(r=>({test:r.test,file:r.file,replaced_by:r.replacedBy}))}:{},...e.needed?.variables.length?{variables_needed:{file:e.needed.file,variables:e.needed.variables}}:{},...e.needed?.noStartPage.length?{no_start_page:e.needed.noStartPage.map(r=>({test:r.test,...r.file?{file:r.file}:{}}))}:{},...s.length>0?{next:s}:{}}}var Mt={ac:"an acceptance criterion",scenario:"a scenario",test:"a test",gap:"an open question",source:"a source",stylenote:"a style note"},T=(e,t)=>e?`"${e}"`:P(t),Ge=(e,t,n)=>`${e} ${e===1?t:n}`,fs={trusted:"approved",derived:"proposed",archived:"archived"},ws={yes:"yes",source_changed:"no: its source changed",source_removed:"no: its source was removed",tests_out_of_date:"no: its tests are out of date",designed_from_changed:"no: what it was designed from changed",archived:"-"},ys={source_changed:"its source changed",source_removed:"its source was removed",tests_out_of_date:"changed after its tests were designed"},y=e=>e?`"${e}"`:"this session's project",_=(e,t)=>`kane-cli design tests --use-case ${e}${t}`,ae=e=>e?"its source's change was put off in an earlier review; to take it up":"to review its source's change",He=e=>e.split(`
6
6
  `).map(t=>({text:` ${t.trim()}`,dim:!0})),Rs={nothingChanged:(e,t)=>({code:"NOTHING_CHANGED",message:`${T(e,t)} hasn't changed since its tests were designed`,remedy:`to design them again anyway, run:
7
7
  ${_(t,"")}`,next:[{cmd:_(t," --mode agent"),why:"designs its tests again anyway"}]}),noTests:(e,t)=>({code:"NO_TESTS_YET",message:`${T(e,t)} has no tests yet, so there's nothing to update`,remedy:`to design them, run:
8
8
  ${_(t,"")}`,next:[{cmd:_(t," --mode agent"),why:"designs its tests"}]}),unreviewed:(e,t)=>({code:"UC_UNREVIEWED",message:We.unapproved(e,t,!0).message,remedy:`to design its tests again anyway, run:
9
9
  ${_(t," --allow-unreviewed")}`,next:[{cmd:_(t," --force --allow-unreviewed --mode agent"),why:"designs its tests again anyway"}]}),archived:(e,t,n)=>({code:"UC_ARCHIVED",message:We.archived(e,t,n).message}),unknownRef:(e,t)=>({message:`${y(t)} has no ${Ft[Bt(e)]??"item"} ${e}`}),ambiguousRef:(e,t)=>({message:`${e} names more than one item in ${y(t)}; run the command again with more of its id`}),notInUseCase:e=>({message:`${e} isn't part of a use case whose tests can be updated`}),held:(e,t,n)=>[{text:` \u2717 the tests of "${t}" can't be updated now: ${e?"you're designing them in another session":"someone else is designing them"}`},{text:" to update them later, run:",dim:!0},{text:` kane-cli maintain evolve ${n}`,dim:!0}],later:e=>[{text:"next: to update them later, run:"},{text:` kane-cli maintain evolve ${e}`}],changedCount:e=>e===1?"1 use-case changed after its tests were designed":`${e} use-cases changed after their tests were designed`,cantUpdate:(e,t)=>[{text:` \u2717 the tests of "${e}" can't be updated: it isn't approved yet`},{text:" to design its tests again anyway, run:",dim:!0},{text:` kane-cli design tests --use-case ${t} --allow-unreviewed`,dim:!0}],upToDate:e=>`everything in ${y(e)} is up to date, so there's nothing to update`,resumingBatch:(e,t)=>`\u25CF resuming the update of ${e===1?"1 use-case":`${e} use-cases`} \u2014 ${t} updated, ${e-t} to go`,resumingOne:(e,t,n)=>`\u25CF resuming the update of "${e}" \u2014 ${t} of ${n} phases done`,upToDateNow:e=>({text:` "${e}" is up to date now, so it's left out`,dim:!0}),upToDateNothing:e=>({text:` "${e}" is up to date now, so there's nothing to update`,dim:!0}),moreAnswers:e=>e===1?"1 more use-case needs your answer before the update goes on":`${e} more use-cases need your answers before the update goes on`,stillOutOfDate:e=>[e===1?"next: 1 use-case still isn't up to date; to update it, run:":`next: ${e} use-cases still aren't up to date; to update them, run:`," kane-cli maintain evolve --from-stale"],nothingToSave:"nothing to save \u2014 this session changed nothing",notYet:e=>`${I(e.map(t=>`"${t}"`))} ${e.length===1?"wasn't":"weren't"} updated`,notUpdatedNext:e=>[`next: to update ${e.length===1?"the use-case":`the ${e.length} use-cases`} this didn't, run:`,...e.map(t=>` kane-cli maintain evolve ${t}`)],notUpdated:e=>I(e.map(t=>`"${t}"`)),reviewSource:(e,t,n=!1)=>e!==null?`${ae(n)}, run:
10
10
  ${e}`:`${ae(n)}, run this with that source's file:
11
11
  kane-cli maintain reconcile --from <file> --source-id ${t}`,reviewSourceAgent:(e=!1)=>ae(e),sourceChanged:(e,t,n)=>({message:`${T(e,t)} is out of date because its source changed, and an update can't change that`,...n}),leftOutSourceChanged:(e,t,n)=>[{text:`${T(e,t)} is left out: it's out of date because its source changed`},...He(n)],stillSourceChanged:e=>He(e),listNext:(e,t)=>[`next: for ${P(e)} "${t}", run:`,` kane-cli maintain evolve ${e}`],listAgentNext:e=>[{cmd:`kane-cli maintain evolve ${e} --mode agent`,why:"update its tests"}]},Ft={uc:"use case",sc:"scenario",ac:"acceptance criterion",t:"test",gap:"open question",sty:"style note"},Bt=e=>/^([a-z]+)-\d+$/i.exec(e)?.[1]?.toLowerCase()??"",We={unapproved:(e,t,n)=>({code:"UC_UNREVIEWED",message:`${T(e,t)} isn't approved yet`,next:{lead:"to design its tests anyway, run:",cmd:_(t,`${n?" --mode agent":""} --allow-unreviewed`),why:"designs its tests though it isn't approved yet"}}),archived:(e,t,n)=>({code:"UC_ARCHIVED",message:`${T(e,t)} is archived in ${y(n)}, so its tests can't be designed`}),designed:(e,t,n)=>({message:n?`${T(e,t)} changed after its tests were designed; --force designs them again, replacing the ones it has`:`${T(e,t)} already has tests; --force designs them again, replacing the ones it has`,next:{lead:"to design them again, run:",cmd:_(t," --force --mode agent"),why:"designs its tests again, replacing the ones it has"},...n?{more:[{cmd:`kane-cli maintain evolve ${t} --mode agent`,why:"updates only the tests its change touches"}]}:{}}),wallUpdate:e=>`next: to update only what its change touches, run:
12
- kane-cli maintain evolve ${e}`,wallHead:(e,t,n,o=2)=>n?`${T(e,t)} changed after its ${o===1?"test was":"tests were"} designed`:`${T(e,t)} already has ${o===1?"a test":"tests"}`,wallAgain:e=>e===1?" 1. design it again \u2014 replaces it if it no longer fits; you'll be asked why":` 1. design them again \u2014 ${e>0?"replaces any that no longer fit; ":""}you'll be asked why`,wallStop:" 2. stop here \u2014 nothing is started",wallWhy:e=>e===1?"why design it again? ":"why design them again? ",wallStopped:"nothing was started",wallNoReason:"nothing was started: designing them again needs a reason",unknown:(e,t,n)=>({message:`${y(t)} has no use case ${e}`,...n.length>0?{next:{lead:`its use cases include ${I(n)}; run the command again with one of them`}}:{}}),removed:(e,t)=>({message:`${e} was removed from ${y(t)}, so it has no tests to design`}),notUseCase:(e,t)=>{let n=t!==void 0?Mt[t]:void 0;return{message:n?`${e} is ${n}, not a use case`:`${e} isn't a use case`}}},Gt=new Set(["CHECKPOINT_PROTOCOL","SESSION_KEPT_NOTHING","SESSION_MISSING"]),$s=e=>{let t=/^error: ([A-Z_]+): /.exec(e)?.[1];return t!==void 0&&Gt.has(t)},Y=e=>{let t=e.startsWith("-")?`./${e}`:e;return/^[A-Za-z0-9_./:@%+=,\\-]+$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`};function vs(e,t){let n=g=>e.tests.filter(w=>w.outcome===g).length,[o,d,a,i]=[n("new"),n("updated"),n("unchanged"),n("kept")],s=o+d+a,r=[],l=[o?`${o} new`:"",d?`${d} updated`:"",a?`${a} already up to date`:""].filter(Boolean);s>0&&r.push(`\u2713 "${t.project}": ${s} test${s===1?"":"s"} here \u2014 ${l.join(", ")}`);for(let g of e.tests)g.outcome==="new"?r.push(` new ${g.file}${g.imported?" (a test above uses it)":""}`):g.outcome==="updated"?r.push(` updated ${g.file}`):g.outcome==="kept"?r.push(` kept ${g.file} \u2014 you changed it here`):g.outcome==="replaced"&&r.push(` replaced ${g.file} \u2014 your changes were replaced with the project's`);let m=e.tests.filter(g=>g.outcome==="not_written");if(m.length>0){r.push(`warning: ${m.length===1?"1 test file wasn't":`${m.length} test files weren't`} written`);for(let g of m)r.push(g.title?` "${g.title}"`:" a test with no title",` ${g.reason??""}`)}let c=e.tests.filter(g=>g.outcome!=="not_written"&&g.file!==void 0).length,p=e.tests.filter(g=>g.outcome!=="not_written"&&g.firstRun).length;p===1?r.push("1 of these tests hasn't run in this folder yet: its first run writes its steps in a real browser, which takes a few minutes and uses more credits; later runs replay it"):p>1&&r.push(`${p} of these tests haven't run in this folder yet: the first run of each writes its steps in a real browser, which takes a few minutes and uses more credits; later runs replay them`);let u=e.needed;if(u&&u.variables.length>0){let g=u.variables.length,w=c===1?"this test runs":"these tests run";r.push(`\u2692 ${g===1?"1 variable needs a value":`${g} variables need values`} before ${w}: ${I(u.variables.map(f=>f.name))}`),r.push(` add ${g===1?"it":"them"} to ${ce(t.cwd,u.file)||u.file}`);let h=u.variables.filter(f=>f.start_page).map(f=>f.name);h.length===1?r.push(` ${h[0]} is the page ${c===1?"it starts":"they start"} on`):h.length>1&&r.push(` ${I(h)} are the pages they start on`)}return u&&u.noStartPage.length>0&&r.push(...Ue(u.noStartPage,{indent:0,cwd:t.cwd})),c>0&&r.push(`next: to run ${c===1?"it":"them"}, run:`," kane-cli testrun run"),i>0&&r.push(`next: to replace ${i===1?"it":"them"} with the project's ${i===1?"version":"versions"}, run:`,` kane-cli context pull --overwrite${t.useCase?` --use-case ${t.useCase}`:""}`),r}var Ht={savedBefore:"this session was already saved",pullLocationLinked:e=>({code:"PULL_LOCATION_LINKED",message:`this folder takes its tests from "${e}", not from a location`,remedy:`to bring the project's tests here, run:
12
+ kane-cli maintain evolve ${e}`,wallHead:(e,t,n,o=2)=>n?`${T(e,t)} changed after its ${o===1?"test was":"tests were"} designed`:`${T(e,t)} already has ${o===1?"a test":"tests"}`,wallAgain:e=>e===1?" 1. design it again \u2014 replaces it if it no longer fits; you'll be asked why":` 1. design them again \u2014 ${e>0?"replaces any that no longer fit; ":""}you'll be asked why`,wallStop:" 2. stop here \u2014 nothing is started",wallWhy:e=>e===1?"why design it again? ":"why design them again? ",wallStopped:"nothing was started",wallNoReason:"nothing was started: designing them again needs a reason",unknown:(e,t,n)=>({message:`${y(t)} has no use case ${e}`,...n.length>0?{next:{lead:`its use cases include ${I(n)}; run the command again with one of them`}}:{}}),removed:(e,t)=>({message:`${e} was removed from ${y(t)}, so it has no tests to design`}),notUseCase:(e,t)=>{let n=t!==void 0?Mt[t]:void 0;return{message:n?`${e} is ${n}, not a use case`:`${e} isn't a use case`}}},Gt=new Set(["CHECKPOINT_PROTOCOL","SESSION_KEPT_NOTHING","SESSION_MISSING"]),$s=e=>{let t=/^error: ([A-Z_]+): /.exec(e)?.[1];return t!==void 0&&Gt.has(t)},Y=e=>{let t=e.startsWith("-")?`./${e}`:e;return/^[A-Za-z0-9_./:@%+=,\\-]+$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`};function vs(e,t){let n=m=>e.tests.filter(w=>w.outcome===m).length,[o,d,a,i]=[n("new"),n("updated"),n("unchanged"),n("kept")],s=o+d+a,r=[],l=[o?`${o} new`:"",d?`${d} updated`:"",a?`${a} already up to date`:""].filter(Boolean);s>0&&r.push(`\u2713 "${t.project}": ${s} test${s===1?"":"s"} here \u2014 ${l.join(", ")}`);for(let m of e.tests)m.outcome==="new"?r.push(` new ${m.file}${m.imported?" (a test above uses it)":""}`):m.outcome==="updated"?r.push(` updated ${m.file}`):m.outcome==="kept"?r.push(` kept ${m.file} \u2014 you changed it here`):m.outcome==="replaced"&&r.push(` replaced ${m.file} \u2014 your changes were replaced with the project's`);let g=e.tests.filter(m=>m.outcome==="not_written");if(g.length>0){r.push(`warning: ${g.length===1?"1 test file wasn't":`${g.length} test files weren't`} written`);for(let m of g)r.push(m.title?` "${m.title}"`:" a test with no title",` ${m.reason??""}`)}let c=e.tests.filter(m=>m.outcome!=="not_written"&&m.file!==void 0).length,p=e.tests.filter(m=>m.outcome!=="not_written"&&m.firstRun).length;p===1?r.push("1 of these tests hasn't run in this folder yet: its first run writes its steps in a real browser, which takes a few minutes and uses more credits; later runs replay it"):p>1&&r.push(`${p} of these tests haven't run in this folder yet: the first run of each writes its steps in a real browser, which takes a few minutes and uses more credits; later runs replay them`);let u=e.needed;if(u&&u.variables.length>0){let m=u.variables.length,w=c===1?"this test runs":"these tests run";r.push(`\u2692 ${m===1?"1 variable needs a value":`${m} variables need values`} before ${w}: ${I(u.variables.map(f=>f.name))}`),r.push(` add ${m===1?"it":"them"} to ${ce(t.cwd,u.file)||u.file}`);let h=u.variables.filter(f=>f.start_page).map(f=>f.name);h.length===1?r.push(` ${h[0]} is the page ${c===1?"it starts":"they start"} on`):h.length>1&&r.push(` ${I(h)} are the pages they start on`)}return u&&u.noStartPage.length>0&&r.push(...Le(u.noStartPage,{indent:0,cwd:t.cwd})),c>0&&r.push(`next: to run ${c===1?"it":"them"}, run:`," kane-cli testrun run"),i>0&&r.push(`next: to replace ${i===1?"it":"them"} with the project's ${i===1?"version":"versions"}, run:`,` kane-cli context pull --overwrite${t.useCase?` --use-case ${t.useCase}`:""}`),r}var Ht={savedBefore:"this session was already saved",pullLocationLinked:e=>({code:"PULL_LOCATION_LINKED",message:`this folder takes its tests from "${e}", not from a location`,remedy:`to bring the project's tests here, run:
13
13
  kane-cli context pull`}),pullFlagsMixed:()=>({code:"PULL_FLAGS_MIXED",message:"--project, --use-case and --overwrite bring a shared project's tests; a location name, --rebase, --yes and --answer take work from a location",remedy:"use one or the other"}),pullFlagsLinkedOnly:()=>({code:"PULL_FLAGS_LINKED_ONLY",message:"--use-case and --overwrite work in a folder linked to a shared project",remedy:`to take the new work shared at a location, run:
14
14
  kane-cli context pull [name]`}),useCaseUnknown:(e,t)=>({code:"USE_CASE_UNKNOWN",message:`"${e}" has no use-case ${t}`,remedy:`to see its use-cases, run:
15
15
  kane-cli context list`}),pullFailed:e=>({code:"PULL_FAILED",message:`the tests of "${e}" couldn't be read, so none was written`,remedy:`to try again, run:
@@ -22,8 +22,8 @@ or, ${o}
22
22
  kane-cli maintain reconcile --from <file> --source-id ${e}`}),reconcileRefUnrouted:(e,t,n,o)=>({code:"SOURCE_REF_UNROUTED",message:`source '${e}' was read by plugin ${t} from '${n}', which this build routes to ${o===null?"no plugin":`plugin ${o}`}`,remedy:`reconcile it with a build whose plugin ${t} claims that reference`}),reconcileRefOtherId:(e,t,n,o)=>({code:"SOURCE_ID_MISMATCH",message:`--source-id '${e}' does not match the source plugin ${t} reads '${n}' as, '${o}'`,remedy:`re-run with --source-id ${o}`}),reconcileNeeds:(e,t)=>({code:"REMOTE_UNSUPPORTED",message:"kane-cli maintain reconcile needs --from <file> and --source-id <id>",remedy:t?`to see the sources ${y(e)} holds, run: kane-cli context list --type source --mode agent`:`to see the sources ${y(e)} holds, run:
23
23
  kane-cli context list --type source`}),listHeadline:(e,t)=>{let n=(d,a,i)=>d===void 0?null:Ge(d,t.proposed?`proposed ${a}`:a,t.proposed?`proposed ${i}`:i),o=[t.sources!==void 0?Ge(t.sources,"source","sources"):null,n(t.useCases,"use-case","use-cases"),n(t.scenarios,"scenario","scenarios"),n(t.tests,"test","tests")].filter(d=>d!==null);return`${y(e)} holds ${o.length>1?`${o.slice(0,-1).join(", ")} and ${o[o.length-1]}`:o[0]??""}`},listStaleHeadline:(e,t,n)=>n===1?`the 1 use-case in ${y(e)} isn't up to date`:`${t} of the ${n} use-cases in ${y(e)} ${t===1?"isn't":"aren't"} up to date`,listNothing:(e,t)=>t?`everything in ${y(e)} is up to date`:`nothing in ${y(e)} matches`,listReadFailed:()=>({code:"LIST_FAILED",message:"couldn't load this project's list",remedy:"run the command again",support:!0}),coverComputing:e=>`coverage: ${y(e)} is still working it out; run the command again in a moment`,coverReadFailed:e=>({code:"COVERAGE_FAILED",message:`couldn't load ${y(e)}'s coverage`,remedy:"run the command again",support:!0}),assuranceOff:e=>({code:"ASSURANCE_OFF",message:`assurance isn't available for ${y(e)}`,remedy:"run the command in a folder that isn't linked to a project"}),noAccess:e=>({code:"PROJECT_NO_ACCESS",message:e===""?"you don't have access to this session's project":`you don't have access to "${e}", the project this folder is linked to`,remedy:"ask a Test Manager admin to grant your account access, then run the command again"}),bothStores:e=>({code:"BOTH_STORES",message:`this folder has its own context store and is also linked to ${e===null?"a project":`"${e}"`}`,remedy:"to work locally, remove .testmuai/assurance.json; to work in the project, move the context store (.context) out of this folder"}),linkUnreadable:()=>({code:"PROJECT_FILE_UNREADABLE",message:"this folder's link to its project could not be read",remedy:"remove .testmuai/assurance.json, then choose the project again with: kane-cli context extract"}),markRefused:(e,t)=>({code:"PERMISSION_REQUIRED",message:`you can't start the first session in ${y(e)}: it needs permission to create test cases`,remedy:t?"ask a Test Manager admin for that permission, or run the command again and pick another project":"ask a Test Manager admin for that permission, or someone who has it to start the first session; then run the command again"}),confirmRequired:e=>({code:"CONFIRM_REQUIRED",message:"refusing to save this session without --yes (no terminal to confirm)",remedy:"add --yes",...e?{next:[{cmd:`kane-cli context sessions save ${e} --yes`,why:"save it to the project"}]}:{}}),noConnectionAtStart:()=>({code:"CONNECTION_FAILED",message:"couldn't connect for 2 minutes, so nothing was started",remedy:"check your connection, then run the command again",support:!0}),folderFlagsBoth:()=>({code:"FOLDER_USAGE",message:"--project and --local can't be used together",remedy:"use one: --project <id> to share this folder's work, or --local to keep it here"}),folderFlagWithResume:e=>({code:"FOLDER_USAGE",message:`${e} can't be used with --resume; a session stays where it started`,remedy:`run it again without ${e}`}),projectIdUnknown:(e,t)=>({code:"PROJECT_NO_ACCESS",message:`you don't have a project with the id "${e}"`,remedy:t?"to find a project's id, run: kane-cli projects list --search <name> --agent":`to find a project's id, run:
24
24
  kane-cli projects list --search <name>`}),projectFileUnwritable:e=>({code:"PROJECT_FILE_UNWRITABLE",message:"this folder's link to its project could not be written",remedy:e?"move the file named .testmuai out of this folder, then run the command again":"check that you can write to this folder, then run the command again"}),folderWorksLocally:()=>({code:"FOLDER_CHOSEN",message:"this folder works locally, so --project can't link it to a project",remedy:"run it without --project; to share instead, move the context store (.context) out of this folder first"}),folderLinkedElsewhere:e=>({code:"FOLDER_CHOSEN",message:`this folder is linked to ${y(e)}, not to the project given`,remedy:"run it without --project; to link it to another project, remove .testmuai/assurance.json first"}),folderLinkedNotLocal:e=>({code:"FOLDER_CHOSEN",message:`this folder is linked to ${y(e)}, so --local can't keep it local`,remedy:"run it without --local; to work locally, remove .testmuai/assurance.json first"}),noConnection:()=>({code:"CONNECTION_FAILED",message:"couldn't connect, so nothing was started",remedy:"check your connection, then run the command again",support:!0}),credentialsMissing:()=>({code:"CREDENTIALS_MISSING",message:"you're not logged in",remedy:"in a terminal, log in with: kane-cli login"}),loginUnconfirmed:()=>({code:"CREDENTIALS_MISSING",message:"couldn't confirm your login for shared projects",remedy:"run the command again; if this keeps failing, log in with your username and access key: kane-cli login --username <user> --access-key <key>"}),credentialsRejected:()=>({code:"CREDENTIALS_REJECTED",message:"your credentials were rejected",remedy:"in a terminal, log in again with: kane-cli login"}),noSuchSession:e=>({code:"SESSION_NOT_FOUND",message:`no session ${e} of yours`,remedy:"to see your sessions, run: kane-cli context sessions"}),sessionFinished:e=>({code:"SESSION_FINISHED",message:`session ${e} is finished, so it can't be resumed`,remedy:`to save what it added, run: kane-cli context sessions save ${e}`,next:[{cmd:`kane-cli context sessions save ${e} --yes`,why:"save what it added"}]}),sessionFailed:e=>({code:"SESSION_FAILED",message:`session ${e} ended with an error, so it can't be resumed or saved`,remedy:"start a new session with: kane-cli context extract",support:!0}),resumeUnreadable:(e,t,n,o)=>({code:e,message:`session ${t} can't be resumed, because its last step can't be read`,remedy:`start a new session with: ${n==="design"&&o?`kane-cli design tests --use-case ${o}`:"kane-cli context extract"}`,support:!0}),reviewOnlyFiles:(e,t,n)=>{let o=`${Xe([e])}${n?` --as ${Y(n)}`:""}`;return{code:"REMOTE_UNSUPPORTED",message:"--from takes only a file yet in a folder linked to a shared project",remedy:t?`to add the page's new version, run: ${o} --mode agent`:`to add the page's new version, run:
25
- ${o}`}},ingestTooLarge:(e,t,n)=>({code:"FILE_TOO_LARGE",message:`${e} is too large \u2014 ${t}; the limit is ${n}`,remedy:"use a smaller file, then run the command again"}),ingestUnsupported:e=>({code:"UNSUPPORTED_MEDIA",message:e,remedy:"use one of those file types, then run the command again"}),ingestTextTooLarge:e=>({code:"PROJECTION_TOO_LARGE",message:`${e}'s text is too large to add`,remedy:"shorten the document, then run the command again"}),ingestUnreadable:(e,t)=>({code:e,message:t,remedy:"check the file, then run the command again"}),conversionRefused:(e,t)=>{let n=Pt[t]?.(e);return n?{code:t,message:n[0],remedy:n[1]}:{code:t,message:`${e} couldn't be added`,remedy:U,support:!0}},ingestBadSourceId:e=>({code:"BAD_SOURCE_ID",message:`${e} isn't a source id: use letters, digits, ".", "_" or "-", and start with a letter or digit`,remedy:"pick another id, then run the command again"}),ingestNoFile:e=>({code:"FILE_NOT_FOUND",message:`there's no file at ${e}`,remedy:"check the path, then run the command again"}),ingestNotItsType:(e,t)=>({code:"MEDIA_SNIFF_MISMATCH",message:`${e}'s content doesn't match its .${t} name`,remedy:U}),ingestCantOpen:e=>({code:"FILE_UNREADABLE",message:`${e} can't be read`,remedy:"check that you can open the file, then run the command again"}),ingestNoSourceId:e=>({code:"BAD_SOURCE_ID",message:`${e} can't be added: its name needs at least one letter a-z or digit`,remedy:"rename the file, then run the command again"}),uploadStalled:e=>({code:"UPLOAD_STALLED",message:`the upload of ${e} stopped, so nothing was added`,remedy:"check your connection, then run the command again",support:!0}),uploadDropped:e=>({code:"CONNECTION_FAILED",message:`the connection dropped while uploading ${e}, so nothing was added`,remedy:"check your connection, then run the command again"}),uploadExpired:e=>({code:"UPLOAD_EXPIRED",message:`the upload of ${e} took too long, so nothing was added`,remedy:"run the command again"}),uploadNotTaken:e=>({code:"UPLOAD_NOT_TAKEN",message:`the shared project couldn't take ${e}, so nothing was added`,remedy:"run the command again",support:!0}),resultRefused:e=>({code:"RESULT_REFUSED",message:`the shared project didn't take ${e}, so nothing was added`,remedy:"run the command again",support:!0}),alreadySaved:()=>({code:"ALREADY_SAVED",message:"this session was already saved, so there's nothing to discard"}),savedOrDiscarded:()=>({code:"ALREADY_ENDED",message:"this session was already saved or discarded; there's nothing to discard"}),goingOnElsewhere:e=>({code:"SESSION_ELSEWHERE",message:"this session goes on in another terminal, so it can't be discarded now",remedy:`stop it there, or wait 3 minutes if that terminal was closed; then run: kane-cli context sessions discard ${e}`,next:[{cmd:`kane-cli context sessions discard ${e} --yes`,why:"throw away what this session added"}]}),discardFailed:()=>({code:"DISCARD_FAILED",message:"couldn't discard this session, so it's kept as it is",remedy:"run the command again",support:!0}),discardUnconfirmed:()=>({code:"CONNECTION_FAILED",message:"the connection dropped during the discard, so it couldn't be confirmed",remedy:"check your connection, then run the command again; it's safe to repeat",support:!0}),confirmDiscardRequired:e=>({code:"CONFIRM_REQUIRED",message:"refusing to discard this session without --yes (no terminal to confirm)",remedy:"add --yes",...e?{next:[{cmd:`kane-cli context sessions discard ${e} --yes`,why:"throw away what this session added"}]}:{}}),notFinished:(e,t)=>({code:"SESSION_NOT_FINISHED",message:`session ${e} isn't finished yet, and only a finished session can be saved`,remedy:`resume it and finish it first: ${t}`}),versionCliOlder:()=>({code:"VERSION_MISMATCH",message:"this version of kane-cli is too old to work with shared projects",remedy:`to update kane-cli, run: ${Se()}`}),versionServiceOlder:()=>({code:"VERSION_MISMATCH",message:"shared projects don't support this version of kane-cli yet",remedy:Me("VERSION_MISMATCH")}),openFailed:()=>({code:"SESSION_OPEN_FAILED",message:"the session couldn't be opened",remedy:"run the command again",support:!0}),projectBusy:e=>{let t=y(e.project),n=e.held,o=e.useCase??n.useCase,d=e.title?`"${e.title}"`:o?P(o):"this use case",a=e.agent?"wait for it to finish, then run the command again":`wait for it to finish, then run the command again; to see the project's sessions, run:
25
+ ${o}`}},ingestTooLarge:(e,t,n)=>({code:"FILE_TOO_LARGE",message:`${e} is too large \u2014 ${t}; the limit is ${n}`,remedy:"use a smaller file, then run the command again"}),ingestUnsupported:e=>({code:"UNSUPPORTED_MEDIA",message:e,remedy:"use one of those file types, then run the command again"}),ingestTextTooLarge:e=>({code:"PROJECTION_TOO_LARGE",message:`${e}'s text is too large to add`,remedy:"shorten the document, then run the command again"}),ingestUnreadable:(e,t)=>({code:e,message:t,remedy:"check the file, then run the command again"}),conversionRefused:(e,t)=>{let n=Pt[t]?.(e);return n?{code:t,message:n[0],remedy:n[1]}:{code:t,message:`${e} couldn't be added`,remedy:L,support:!0}},ingestBadSourceId:e=>({code:"BAD_SOURCE_ID",message:`${e} isn't a source id: use letters, digits, ".", "_" or "-", and start with a letter or digit`,remedy:"pick another id, then run the command again"}),ingestNoFile:e=>({code:"FILE_NOT_FOUND",message:`there's no file at ${e}`,remedy:"check the path, then run the command again"}),ingestNotItsType:(e,t)=>({code:"MEDIA_SNIFF_MISMATCH",message:`${e}'s content doesn't match its .${t} name`,remedy:L}),ingestCantOpen:e=>({code:"FILE_UNREADABLE",message:`${e} can't be read`,remedy:"check that you can open the file, then run the command again"}),ingestNoSourceId:e=>({code:"BAD_SOURCE_ID",message:`${e} can't be added: its name needs at least one letter a-z or digit`,remedy:"rename the file, then run the command again"}),uploadStalled:e=>({code:"UPLOAD_STALLED",message:`the upload of ${e} stopped, so nothing was added`,remedy:"check your connection, then run the command again",support:!0}),uploadDropped:e=>({code:"CONNECTION_FAILED",message:`the connection dropped while uploading ${e}, so nothing was added`,remedy:"check your connection, then run the command again"}),uploadExpired:e=>({code:"UPLOAD_EXPIRED",message:`the upload of ${e} took too long, so nothing was added`,remedy:"run the command again"}),uploadNotTaken:e=>({code:"UPLOAD_NOT_TAKEN",message:`the shared project couldn't take ${e}, so nothing was added`,remedy:"run the command again",support:!0}),resultRefused:e=>({code:"RESULT_REFUSED",message:`the shared project didn't take ${e}, so nothing was added`,remedy:"run the command again",support:!0}),alreadySaved:()=>({code:"ALREADY_SAVED",message:"this session was already saved, so there's nothing to discard"}),savedOrDiscarded:()=>({code:"ALREADY_ENDED",message:"this session was already saved or discarded; there's nothing to discard"}),goingOnElsewhere:e=>({code:"SESSION_ELSEWHERE",message:"this session goes on in another terminal, so it can't be discarded now",remedy:`stop it there, or wait 3 minutes if that terminal was closed; then run: kane-cli context sessions discard ${e}`,next:[{cmd:`kane-cli context sessions discard ${e} --yes`,why:"throw away what this session added"}]}),discardFailed:()=>({code:"DISCARD_FAILED",message:"couldn't discard this session, so it's kept as it is",remedy:"run the command again",support:!0}),discardUnconfirmed:()=>({code:"CONNECTION_FAILED",message:"the connection dropped during the discard, so it couldn't be confirmed",remedy:"check your connection, then run the command again; it's safe to repeat",support:!0}),confirmDiscardRequired:e=>({code:"CONFIRM_REQUIRED",message:"refusing to discard this session without --yes (no terminal to confirm)",remedy:"add --yes",...e?{next:[{cmd:`kane-cli context sessions discard ${e} --yes`,why:"throw away what this session added"}]}:{}}),notFinished:(e,t)=>({code:"SESSION_NOT_FINISHED",message:`session ${e} isn't finished yet, and only a finished session can be saved`,remedy:`resume it and finish it first: ${t}`}),versionCliOlder:()=>({code:"VERSION_MISMATCH",message:"this version of kane-cli is too old to work with shared projects",remedy:`to update kane-cli, run: ${Se()}`}),versionServiceOlder:()=>({code:"VERSION_MISMATCH",message:"shared projects don't support this version of kane-cli yet",remedy:Me("VERSION_MISMATCH")}),openFailed:()=>({code:"SESSION_OPEN_FAILED",message:"the session couldn't be opened",remedy:"run the command again",support:!0}),projectBusy:e=>{let t=y(e.project),n=e.held,o=e.useCase??n.useCase,d=e.title?`"${e.title}"`:o?P(o):"this use case",a=e.agent?"wait for it to finish, then run the command again":`wait for it to finish, then run the command again; to see the project's sessions, run:
26
26
  kane-cli context sessions`,i=l=>e.agent?`to go on with it here (the other terminal then stops), run: ${l} --mode agent`:`to go on with it here (the other terminal then stops), run:
27
27
  ${l}`,s=n.verb==="design"||n.verb==="evolve",r=s?n.mine?`you're already designing tests for ${d} in another session`:`someone else is designing tests for ${d} right now`:`${n.mine?e.verb==="extract"?"your other":"your":"someone else's"} extract is ${n.status==="queued"?"about to start":"running"} in ${t}`;return e.resume?{code:"PROJECT_BUSY",message:`${r}, so this session can't go on yet; it stays as it was`,remedy:"wait for it to finish, then run the command again",heldBy:n}:s?n.mine?{code:"PROJECT_BUSY",message:r,remedy:i(`kane-cli design tests --resume ${n.sessionId}`),heldBy:n}:{code:"PROJECT_BUSY",message:`${r}, so this design can't start`,remedy:a,heldBy:n}:e.verb==="design"?{code:"PROJECT_BUSY",message:`${r}, so a design can't start until it finishes`,remedy:a,heldBy:n}:n.mine?{code:"PROJECT_BUSY",message:`${r}, so this one can't start`,remedy:i(`kane-cli context extract --resume ${n.sessionId}`),heldBy:n}:{code:"PROJECT_BUSY",message:`${r}, so this one can't start`,remedy:a,heldBy:n}},nothingNewInSession:"nothing new to extract: every source is already in a session",nothingNewRead:["nothing new to extract: every source is already read","next: to add more, run:"," kane-cli context ingest <files>"],testCaseMissing:e=>({ownLine:!0,code:"TEST_CASE_MISSING",message:"this test isn't in Test Manager yet, so it can't run",remedy:e?`save the session that designed it, then run the test again; to save the session (nothing is saved twice), run: kane-cli context sessions save ${e}`:"save the session that designed it, then run the test again; to find it, run: kane-cli context sessions"}),testCaseGone:e=>({ownLine:!0,code:"TEST_CASE_GONE",message:"this test's test case was deleted or moved to another project in Test Manager, so it can't run",remedy:e?`save the session that designed it, then run the test again; to save the session (it makes a new test case), run: kane-cli context sessions save ${e}`:"save the session that designed it, then run the test again; to find it, run: kane-cli context sessions"}),testCaseArchived:()=>({code:"TEST_CASE_ARCHIVED",message:"this test's test case is archived in Test Manager, so it can't run",remedy:"restore it in Test Manager, then run the test again"}),testNotInProject:(e,t)=>({ownLine:!0,code:"TEST_NOT_IN_PROJECT",message:`this test isn't in ${y(e)}, and the session that designed it can't be saved anymore`,remedy:t?`design the test again, then save that session; to start, run: kane-cli design tests --use-case ${t}`:"find its use case on the project's page in Test Manager, then design the test again and save it; to start, run: kane-cli design tests --use-case <use-case>"}),testProjectHasNoWork:e=>({ownLine:!0,code:"TEST_NOT_IN_PROJECT",message:`this test isn't in ${y(e)}, which has no use cases or tests yet`,remedy:"run it in the folder linked to the project it was designed in; or, to start this project's work, run: kane-cli context ingest <files>"}),testManagerOutdated:()=>({code:"TEST_MANAGER_OUTDATED",message:"Test Manager can't add this test's runs to its test case yet, so the run didn't start",remedy:"run the test again once Test Manager is updated",support:!0}),testManagerMadeItsOwn:()=>({code:"TEST_MANAGER_OUTDATED",message:"Test Manager made a test case of its own for this run instead of using this test's, so the run stopped",remedy:"you can delete that test case in Test Manager; run the test again once Test Manager is updated",support:!0}),testRunNotSaved:(e,t,n)=>({ownLine:!0,code:"TEST_RUN_NOT_SAVED",message:`Test Manager couldn't save this run, so ${e??"its test case"} doesn't have it yet; the test itself ${t?"passed":"failed"}`,remedy:`the test's next run tries again; to try now, run: kane-cli testmd run ${n}`,support:!0}),remoteKaneNotPublished:()=>({code:"REMOTE_KANE_NOT_PUBLISHED",message:"tests linked to Test Manager need a published kane-cli on the grid, and this one isn't, so nothing was sent",remedy:`run the command with kane-cli installed from npm, or add one of these:
28
28
  --kane-version <version> a published version for the grid to install
29
- --kane-dist <dir> this build, sent with the tests`}),dispatchStopped:e=>`error: ${e} ${e===1?"test":"tests"} can't run yet, so nothing was sent to the grid`,dispatchNext:e=>`next: then run the command again, or leave ${e===1?"it":"them"} out with --match or --tags`,dispatchTestManagerOutdated:()=>({code:"TEST_MANAGER_OUTDATED",message:"Test Manager can't add these tests' runs to their test cases yet, so nothing was sent to the grid",remedy:"run the command again once Test Manager is updated",support:!0}),dispatchProjectHasNoWork:e=>({ownLine:!0,code:"TEST_NOT_IN_PROJECT",message:`these tests aren't in ${y(e)}, which has no use cases or tests yet, so nothing was sent to the grid`,remedy:"run them in the folder linked to the project they were designed in; or, to start this project's work, run: kane-cli context ingest <files>"}),testCaseAttachFailed:()=>({code:"TEST_CASE_ATTACH_FAILED",message:"Test Manager couldn't add this test to its test case, so the run didn't start",remedy:"run the test again",support:!0}),preflight:e=>{switch(e){case"unreachable":return{code:"PREFLIGHT",message:"couldn't connect, so nothing was started",remedy:"check your connection, then run the command again",support:!0};case"login_unchecked":return{code:"PREFLIGHT",message:"couldn't confirm your login, so nothing was started",remedy:"run the command again; if this keeps failing, in a terminal, log in again with: kane-cli login",support:!0};case"rejected":return{code:"PREFLIGHT",message:"your credentials were rejected",remedy:"in a terminal, log in again with: kane-cli login"};case"unsupported":return{code:"PREFLIGHT",message:"assurance sessions aren't available here yet, so nothing was started",remedy:Me("PREFLIGHT")}}},nothingToSave:"nothing to save \u2014 this session added nothing",assuranceOffOr:(e,t,n)=>e?.code==="PROJECT_NOT_MARKED"?Ht.assuranceOff(t):n,projectChanged:(e,t,n,o=[])=>({code:"PROJECT_CHANGED",message:`not saved \u2014 "${e}" changed after this session started`,detail:`this session can't be saved now, so ${It(t)} won't reach the project`,remedy:Ct(n,o)}),saveFailed:e=>({code:"SAVE_FAILED",message:`not saved \u2014 something in this session can't be saved to the project; ${e} still in this session`,remedy:`saving again won't help \u2014 share this id with support: ${V("refused_SAVE_FAILED")}`}),listFailed:()=>({code:"LIST_FAILED",message:"couldn't load this project's sessions",remedy:"run the command again",support:!0}),noConnectionToSave:()=>({code:"CONNECTION_FAILED",message:"couldn't connect, so nothing was saved",remedy:"check your connection, then run the command again",support:!0}),saveUnconfirmed:()=>({code:"CONNECTION_FAILED",message:"the connection dropped during the save, so it couldn't be confirmed",remedy:"check your connection, then run the command again; nothing is saved twice",support:!0}),stepRefused:"the shared project didn't take this step; the work so far is kept in the session",runStopped:e=>`${e==="reconcile"?"the review":e==="evolve"?"the update":e} stopped before it finished; the work so far is kept in the session`};export{Vt as a,xe as b,Jt as c,qt as d,Kt as e,Yt as f,se as g,ke as h,en as i,tn as j,_e as k,Ie as l,on as m,R as n,L as o,ct as p,fn as q,Tn as r,V as s,Ae as t,gt as u,mt as v,ht as w,xn as x,_n as y,Ue as z,je as A,Bn as B,Gn as C,Hn as D,$t as E,Wn as F,Vn as G,Jn as H,I,Je as J,vt as K,qn as L,Kn as M,Yn as N,Xn as O,bt as P,St as Q,Qn as R,zn as S,Zn as T,Et as U,es as V,ts as W,ns as X,Tt as Y,N as Z,j as _,me as $,xt as aa,ss as ba,Ke as ca,Ye as da,kt as ea,rs as fa,os as ga,F as ha,is as ia,Ct as ja,Xe as ka,as as la,_t as ma,It as na,ds as oa,cs as pa,us as qa,ls as ra,gs as sa,jt as ta,ms as ua,hs as va,ps as wa,fs as xa,ws as ya,ys as za,y as Aa,Rs as Ba,We as Ca,Gt as Da,$s as Ea,Y as Fa,vs as Ga,Ht as Ha};
29
+ --kane-dist <dir> this build, sent with the tests`}),dispatchStopped:e=>`error: ${e} ${e===1?"test":"tests"} can't run yet, so nothing was sent to the grid`,dispatchNext:e=>`next: then run the command again, or leave ${e===1?"it":"them"} out with --match or --tags`,dispatchTestManagerOutdated:()=>({code:"TEST_MANAGER_OUTDATED",message:"Test Manager can't add these tests' runs to their test cases yet, so nothing was sent to the grid",remedy:"run the command again once Test Manager is updated",support:!0}),dispatchProjectHasNoWork:e=>({ownLine:!0,code:"TEST_NOT_IN_PROJECT",message:`these tests aren't in ${y(e)}, which has no use cases or tests yet, so nothing was sent to the grid`,remedy:"run them in the folder linked to the project they were designed in; or, to start this project's work, run: kane-cli context ingest <files>"}),testCaseAttachFailed:()=>({code:"TEST_CASE_ATTACH_FAILED",message:"Test Manager couldn't add this test to its test case, so the run didn't start",remedy:"run the test again",support:!0}),preflight:e=>{switch(e){case"unreachable":return{code:"PREFLIGHT",message:"couldn't connect, so nothing was started",remedy:"check your connection, then run the command again",support:!0};case"login_unchecked":return{code:"PREFLIGHT",message:"couldn't confirm your login, so nothing was started",remedy:"run the command again; if this keeps failing, in a terminal, log in again with: kane-cli login",support:!0};case"rejected":return{code:"PREFLIGHT",message:"your credentials were rejected",remedy:"in a terminal, log in again with: kane-cli login"};case"unsupported":return{code:"PREFLIGHT",message:"assurance sessions aren't available here yet, so nothing was started",remedy:Me("PREFLIGHT")}}},nothingToSave:"nothing to save \u2014 this session added nothing",assuranceOffOr:(e,t,n)=>e?.code==="PROJECT_NOT_MARKED"?Ht.assuranceOff(t):n,projectChanged:(e,t,n,o=[])=>({code:"PROJECT_CHANGED",message:`not saved \u2014 "${e}" changed after this session started`,detail:`this session can't be saved now, so ${It(t)} won't reach the project`,remedy:Ct(n,o)}),saveFailed:e=>({code:"SAVE_FAILED",message:`not saved \u2014 something in this session can't be saved to the project; ${e} still in this session`,remedy:`saving again won't help \u2014 share this id with support: ${V("refused_SAVE_FAILED")}`}),listFailed:()=>({code:"LIST_FAILED",message:"couldn't load this project's sessions",remedy:"run the command again",support:!0}),noConnectionToSave:()=>({code:"CONNECTION_FAILED",message:"couldn't connect, so nothing was saved",remedy:"check your connection, then run the command again",support:!0}),saveUnconfirmed:()=>({code:"CONNECTION_FAILED",message:"the connection dropped during the save, so it couldn't be confirmed",remedy:"check your connection, then run the command again; nothing is saved twice",support:!0}),stepRefused:"the shared project didn't take this step; the work so far is kept in the session",runStopped:e=>`${e==="reconcile"?"the review":e==="evolve"?"the update":e} stopped before it finished; the work so far is kept in the session`};export{Vt as a,xe as b,Jt as c,qt as d,Kt as e,Yt as f,se as g,ke as h,en as i,tn as j,_e as k,Ie as l,on as m,R as n,D as o,ct as p,fn as q,Tn as r,V as s,Ae as t,gt as u,mt as v,ht as w,xn as x,_n as y,Le as z,je as A,Bn as B,Gn as C,Hn as D,$t as E,Wn as F,Vn as G,Jn as H,I,Je as J,vt as K,qn as L,Kn as M,Yn as N,Xn as O,bt as P,St as Q,Qn as R,zn as S,Zn as T,Et as U,es as V,ts as W,ns as X,Tt as Y,N as Z,j as _,me as $,xt as aa,ss as ba,Ke as ca,Ye as da,kt as ea,rs as fa,os as ga,F as ha,is as ia,Ct as ja,Xe as ka,as as la,_t as ma,It as na,ds as oa,cs as pa,us as qa,ls as ra,gs as sa,jt as ta,ms as ua,hs as va,ps as wa,fs as xa,ws as ya,ys as za,y as Aa,Rs as Ba,We as Ca,Gt as Da,$s as Ea,Y as Fa,vs as Ga,Ht as Ha};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as c}from"./chunk-C2RUDJ46.js";import{a as n}from"./chunk-RZ4F3BHX.js";import{v as s,w as a}from"./chunk-D36V5OX6.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l as a};
2
+ import{a as c}from"./chunk-GGV336P5.js";import{a as n}from"./chunk-RZ4F3BHX.js";import{w as s,x as a}from"./chunk-QMOGBKJM.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l as a};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as bt}from"./chunk-LX2I4JEH.js";import{a as St}from"./chunk-O3HHTKZ5.js";import{a as gt,b as mt,d as ht,e as _t}from"./chunk-3GXN6VF6.js";import{F as ct,H as dt,L as at,M as ft,P as le,W as ut,a as st,b as Ie,ba as pt,f as nt,g as it,oa as X,pa as lt,r as ot,v as rt}from"./chunk-UEE3RZN4.js";import{d as pe,e as W,f as _,g,h as Ze,i as et,j as tt}from"./chunk-KU3YHPWZ.js";var Pt=/\s@verifies\s+(ac-[\w.:\/-]+(?:\s*,\s*ac-[\w.:\/-]+)*)\s*$/,Lt=new Set([g.EXERCISES,g.VERIFIES,g.SCOPED_TO]),Y=n=>({record:null,errors:n,minted:{},logicalIds:{},superseded:[],warnings:[],finalizedTests:{}});function J(n){return n.toLowerCase().trim().replace(/\s+/g," ")}function yt(n,E,t,l,f){return y=>{if(!f||!W.has(String(y.kind))||!(y.kind==="unmeasurable"||l==="tests")||y.ref&&(t.scenarios??[]).some(T=>T.temp_ref===y.ref))return!0;let O=y.ref?n.resolve(y.ref):null;return!!(O&&n.nodeLabel.get(O.cid)===_.SCENARIO&&!n.superseded.has(n.tipOf(O.cid))&&n.edgesFrom(n.tipOf(O.cid)).some(T=>T.type===g.BELONGS_TO&&n.tipOf(T.dst)===E))}}function Ot(n){let E=new Set;return n.sections.scenarios?.length&&E.add(_.SCENARIO),n.sections.tests?.length&&E.add(_.TEST),n.gen8&&(n.sections.tests?.length||n.phase==="tests"&&n.gapsToMint.some(t=>W.has(String(t.kind))))&&(E.add(_.TEST),E.add(_.GAP)),E}function Et(n,E,t){let l=new Set,f=[];for(let y of E)n.superseded.has(y)||(t.has(n.nodeLabel.get(y)??"")?l.add(y):f.push(y));return{retired:l,remaining:f}}function ss(n,E){let t=n.tokenAt(E.seq),l=t===null?null:n.intentOf(t);if(l===null)return null;let f=l.args,y=l.pins.forceScope;if(l.verb!=="design"||f.forceScope==null||!Array.isArray(y)||!f.sections||!f.ucRef)return;let O=E.seq>1?n.tokenAt(E.seq-1):null;if(O===null)return null;let T=ft(n,{token:O}),F=le(T,f.ucRef);if(!F.ok)return null;let R=pe(f.templateVersion)>=8,C=(f.sections.gaps??[]).filter(yt(T,F.cid,f.sections,f.phase,R));return Et(T,y,Ot({sections:f.sections,phase:f.phase,gen8:R,gapsToMint:C})).remaining}function Ft(n,E,t={}){let l=le(n,E);if(!l.ok)return[];let f=new Set,y=new Set;for(let{cid:O}of n.byLabel(_.SCENARIO))if(!n.superseded.has(O)&&n.edgesFrom(O).some(T=>T.type===g.BELONGS_TO&&n.tipOf(T.dst)===l.cid)){f.add(O),y.add(O),y.add(n.tipOf(O));for(let T of n.edgesInto(O))T.type!==g.AUTOMATES||n.superseded.has(T.src)||f.add(T.src)}if(t.blockerGaps){let O=new Set([l.cid,n.tipOf(l.cid)]);for(let{cid:T,content:F}of n.byLabel(_.GAP)){if(n.superseded.has(T)||n.trust.get(T)==="archived"||!W.has(String(F.kind??"")))continue;let R=typeof F.uc=="string"?F.uc:"";if(!O.has(R)&&!O.has(n.tipOf(R)))continue;let C=F.ref,k=typeof C=="string"&&C?n.resolve(C):null;k&&(y.has(k.cid)||y.has(n.tipOf(k.cid)))&&f.add(T)}}return[...f]}function ns(n){let{store:E,graph:t,sections:l,by:f}=n,y=n.engine??"design@1",O=E.head(),T=E.serialize(O);if(!E.sameToken(E.parse(t.latestHash),O))return Y([{code:"STALE_BASIS",detail:`graph opened at ${String(t.latestHash)} but chain head is ${String(T)} \u2014 re-open and retry`}]);let F=le(t,n.ucRef);if(!F.ok)return Y([{code:"UNKNOWN_UC",detail:`${n.ucRef} is not a live use-case`}]);let R=F.cid,C={ucRef:R,automates:{},verifies:{},reuses:{},scope:{},depends_on:{},exercises:[],scoped_to_repoints:[],judgements:[],body_tags:{},forceScope:[]},k=[],Ae=/^design@(\d+)$/.exec(n.templateVersion??""),Q=pe(n.templateVersion)>=8,Ne=yt(t,R,l,n.phase,Q),te=(l.gaps??[]).filter(Ne),Tt=Ae!==null&&Number.parseInt(Ae[1],10)>=3,De=new Map,$t=(e,i)=>{let s=De.get(e.source_cid);if(s===void 0){let p=rt(E,t,e.source_cid);s=p?St(p.toString("utf8")):null,De.set(e.source_cid,s)}if(s===null)return k.push({code:"CITE_UNVERIFIED",detail:`${i}: source ${e.source_id} (${e.source_cid.slice(0,19)}) has no citable text to verify against`}),!1;let u=ct(t.mediaOf(e.source_cid),e,s);if(u.length>0){for(let p of u)k.push({code:"CITE_UNVERIFIED",detail:`${i}: ${p.code}: ${p.detail}`});return!1}return!0},xe=pe(n.templateVersion)>=9,kt=(e,i)=>{let s=e.source_cid?t.mediaOf(e.source_cid):void 0;if(!e.source_cid||!t.hasNode(e.source_cid)&&s==null)return{code:"CITE_SOURCE_UNKNOWN",detail:`${i}: there is no source ${e.source_id} in this store to cite \u2014 cite a source the use case reads, by its id`};if(s?.plugin?.cites_deep===!0)return null;let u=s?.format==="plugin"?`version ${e.source_cid.slice(0,19)} of ${e.source_id} was stored before its plugin allowed citations below the use case (or by a plugin that does not allow them) \u2014 re-ingest it, or cite it at the use case`:`${e.source_id} is not a source-plugin source that allows citations below the use case \u2014 cite it at the use case instead, or leave this item's cites out`;return{code:"CITE_DEPTH_UNSUPPORTED",detail:`${i}: ${u}`}},ge=(e,i,s,u,p)=>{for(let m of i??[]){if(u){let a=kt(m,`${s}.cite`);if(a){k.push(a);continue}}if(Tt&&!$t(m,`${s}.cite`))continue;let x={source_id:m.source_id,source_cid:m.source_cid,anchor:m.anchor,...m.quote?{quote:m.quote}:{}},G=Ct.one(e,x,p);if("fault"in G){k.push(G.fault);continue}B(g.DERIVES,m.source_cid,e,G.props,`${s}.cite`)}},vt=()=>xe?bt(t,R):[],P=[],M=[],N=[],me=[],re=[],w={},q={},he={},L=[],Z=[],H=[],Pe=new Set,_e=[],ce=new Set,Le=n.forceScope??(n.force?Ft(t,n.ucRef,{blockerGaps:Q}):[]);C.forceScope=[...Le];let{retired:U,remaining:Fe}=Et(t,Le,Ot({sections:l,phase:n.phase,gen8:Q,gapsToMint:te})),V=new Set,be=e=>!t.superseded.has(e)&&(!U.has(e)||V.has(e)),j=(e,i,s)=>{if(w[e])return w[e];let u=t.resolve(e),p=u?be(u.cid)?u.cid:t.tipOf(u.cid):null;return!u||!p||!be(p)?(k.push({code:"UNKNOWN_REF",detail:`${i}: '${e}' is neither in this payload nor a live committed node`}),null):s&&t.nodeLabel.get(p)!==s?(k.push({code:"ILLEGAL_EDGE",detail:`${i}: '${e}' is a ${t.nodeLabel.get(p)}, expected ${s}`}),null):p},Rt=(e,i,s,u)=>{if(t.nameOf.has(i)){q[u]=t.nameOf.get(i);return}let p=lt(e,m=>Pe.has(m),t.names.keys());p!==null&&(Pe.add(p),me.push({cid:i,slug:p,by:f}),q[u]=p)},de=(e,i,s,u)=>{for(let m of Ze(e,s))k.push({code:m.code,detail:`${i}: ${m.detail}`});let p=st(e,s);if(t.hasNode(p)&&!t.superseded.has(p))return U.has(p)&&V.add(p),w[i]=p,p;if(t.hasNode(p)&&t.superseded.has(p)){let m=X(t.nameOf.get(p)??p),x=t.tipOf(p),G=x!==p&&!t.superseded.has(x);return k.push(G?{code:"NODE_SUPERSEDED",detail:`${i}: '${u}' is ${m} as it was before it was replaced by ${X(t.nameOf.get(x)??x)} \u2014 refer to ${X(t.nameOf.get(x)??x)} to keep it, or send it changed`}:{code:"NODE_TOMBSTONED",detail:`${i}: '${u}' is ${m}, which was retired \u2014 a retired item can't come back as it was; send it changed (it is then a new item), or leave it out`}),null}return P.push({cid:p,label:e,content:s}),w[i]=p,Rt(e,p,u,i),p},Ct=it(nt(E,t)),B=(e,i,s,u,p)=>{let m=Ie(e,i,s,u);if(t.edgesFrom(i).some(d=>d.ecid===m&&!t.superseded.has(d.ecid))){e===g.AUTOMATES&&ce.add(s);return}if(t.superseded.has(m)){k.push({code:"EDGE_RETRACTED",detail:`${p}: this ${e} edge was retracted (${m}) \u2014 retraction is terminal for commits. Add a NEW relationship (different endpoint or props), redesign, or revert the retracting record`});return}if(Lt.has(e)&&t.hasNode(i)&&!t.superseded.has(i)&&t.hasNode(s)&&!t.superseded.has(s)){let d=t.displayNameOf(s);for(let c of t.edgesFrom(i))c.type!==e||c.dst===s||t.superseded.has(c.ecid)||!t.superseded.has(c.dst)||t.tipOf(c.dst)!==s||d===null||t.displayNameOf(c.dst)!==d||N.some(v=>v.kind==="edge"&&v.ecid===c.ecid)||N.push({kind:"edge",ecid:c.ecid,reason:`re-pinned onto ${s} (the same link to its live version) by ${f.id}`,by:f})}let x=t.nodeLabel.get(i)??P.find(d=>d.cid===i)?.label??"(unknown)",G=t.nodeLabel.get(s)??P.find(d=>d.cid===s)?.label??"(unknown)";for(let d of tt(e,x,G,u))k.push({code:d.code,detail:`${p}: ${d.detail}`});let a=ut(t,e,i,s,_e);if(a){k.push({code:a.code,detail:`${p}: ${a.detail}`});return}if(e===g.BELONGS_TO||e===g.SCOPED_TO){let d=dt(t,{type:e,src:i,dst:s},{pending:_e,retracted:new Set(N.flatMap(c=>c.kind==="edge"?[c.ecid]:[])),freed:new Set([...U].filter(c=>!V.has(c)))},p);if(d){k.push(d);return}}if(e===g.AUTOMATES){if(ce.has(s)){k.push({code:"CARDINALITY_VIOLATION",detail:`${p}: two automates onto ${s} in one record (strict 1:1)`});return}if(ce.add(s),!U.has(s)||V.has(s)){let d=h=>U.has(h)&&!V.has(h);if(t.edgesFrom(i).some(h=>h.type===g.AUTOMATES&&h.dst!==s&&!t.superseded.has(h.dst)&&!d(h.dst))&&t.hasNode(i)){k.push({code:"CARDINALITY_VIOLATION",detail:`${p}: automates from ${i} already has a live edge \u2014 supersede it first`});return}if(t.edgesInto(s).some(h=>h.type===g.AUTOMATES&&h.src!==i&&!t.superseded.has(h.src)&&!d(h.src))){k.push({code:"CARDINALITY_VIOLATION",detail:`${p}: automates onto ${s} already has a live edge \u2014 strict 1:1, supersede it first`});return}}}M.push({ecid:Ie(e,i,s,u),type:e,src:i,dst:s,props:u}),_e.push({src:i,dst:s,type:e})},Se=new Set;for(let e of te)e.kind==="budget-evicted"&&e.ref&&Se.add(e.ref);let K=[];for(let[e,i]of(l.gaps??[]).entries()){if(Ne(i))continue;let s=i.temp_ref??i.ref??"gap";K.push(e),L.push(`${s} not committed: a ${i.kind} gap stands in for a scenario's test \u2014 ref must be that scenario's committed id (sc-N) or its temp_ref in this payload; got ${i.ref?`'${i.ref}'`:"no ref"}`)}let Me=()=>{for(let e of te){let i=e.temp_ref??e.ref??"gap",s=e.question;if(!s||typeof s!="object"||!s.header||!Array.isArray(s.options)||s.options.length===0||!Number.isInteger(s.recommended_index)){k.push({code:"GAP_QUESTION_INCOMPLETE",detail:`${i}: design gaps carry a full ranked question object (header/options/recommended_index)`});continue}let u=e.ref?Q?w[e.ref]??e.ref:e.ref:void 0,p={kind:e.kind,question:s,derived:!0,uc:R,...e.risk?{risk:e.risk}:{},...e.risk_rationale?{risk_rationale:e.risk_rationale}:{},...e.text?{text:e.text}:{},...u?{ref:u}:{}};de(_.GAP,i,p,String(s.header))}};Q||Me();let ae=n.lineage===2,D={reuseOf:{seen:0,honored:0,linked:0,unresolved:0},byPair:0,byCriteria:0,byTitle:0},fe=[],ye={},Oe=new Map;if(ae)for(let e of l.scenarios??[]){if(typeof e.reuse_of!="string"||!e.reuse_of)continue;D.reuseOf.seen+=1;let i=t.resolve(e.reuse_of),s=i?t.superseded.has(i.cid)?t.tipOf(i.cid):i.cid:null;if(!(s!==null&&!t.superseded.has(s)&&t.nodeLabel.get(s)===_.SCENARIO&&t.edgesFrom(s).some(p=>p.type===g.BELONGS_TO&&t.tipOf(p.dst)===R))){D.reuseOf.unresolved+=1,fe.push(`${e.temp_ref}: reuse_of '${e.reuse_of}' names no scenario of this use case \u2014 saved as a new scenario`);continue}Oe.set(e.temp_ref,s),ye[e.temp_ref]=s}let Ge=new Map;for(let{cid:e,content:i}of t.byLabel(_.SCENARIO))be(e)&&t.edgesFrom(e).some(s=>s.type===g.BELONGS_TO&&t.tipOf(s.dst)===R)&&Ge.set(J(String(i.title??"")),e);for(let e of l.scenarios??[]){let i=Oe.get(e.temp_ref);if(i!==void 0&&!U.has(i))if(t.edgesInto(i).some(m=>m.type===g.AUTOMATES&&!t.superseded.has(m.ecid)&&!t.superseded.has(m.src))&&(l.tests??[]).some(m=>m.automates===e.temp_ref))fe.push(`${e.temp_ref}: reuse_of '${e.reuse_of}' names a scenario that already has its test \u2014 saved as a new scenario`);else{w[e.temp_ref]=i;let m=t.displayNameOf(i);m&&(q[e.temp_ref]=m),D.reuseOf.linked+=1;continue}let s=Ge.get(J(e.title));if(s){k.push({code:"DUPLICATE_SCENARIO",detail:`${e.temp_ref}: '${e.title}' duplicates live scenario ${t.nameOf.get(s)??s} \u2014 exercise/link it instead (reuse before minting)`});continue}let u={title:e.title,intent:e.intent,case_type:e.case_type,derived:!0,...e.technique_notes?{technique_notes:e.technique_notes}:{},...e.description?{description:e.description}:{},...e.parameters?{parameters:e.parameters}:{},...e.tags?{tags:e.tags}:{}};de(_.SCENARIO,e.temp_ref,u,e.title)}for(let e of l.scenarios??[]){let i=w[e.temp_ref];if(i){B(g.BELONGS_TO,i,R,{},e.temp_ref);for(let s of e.depends_on??[]){let u=j(s,`${e.temp_ref}.depends_on`,_.SCENARIO);u&&((C.depends_on[e.temp_ref]??=[]).push(u),B(g.DEPENDS_ON,i,u,{},`${e.temp_ref}.depends_on`))}ge(i,e.cites,e.temp_ref,!0,M)}}for(let e of l.acs??[]){let i={text:e.text,kind:e.kind,risk:e.risk,derived:!0,...e.expected_answer?{expected_answer:e.expected_answer}:{},...e.measurable!==void 0?{measurable:e.measurable}:{}},s=de(_.AC,e.temp_ref,i,e.text);if(!s)continue;let u=e.scope?.type==="scenario"&&e.scope.ref?j(e.scope.ref,`${e.temp_ref}.scope`,_.SCENARIO):R;u&&u!==R&&(C.scope[e.temp_ref]=u),u&&!t.edgesFrom(s).some(p=>p.type===g.SCOPED_TO&&!t.superseded.has(p.ecid))&&B(g.SCOPED_TO,s,u,{},`${e.temp_ref}.scope`),ge(s,e.cites,e.temp_ref,xe,M)}for(let e of l.exercises??[]){let i=j(e.scenario,"exercises.scenario",_.SCENARIO),s=j(e.ac,"exercises.ac",_.AC);!i||!s||(C.exercises.push({scenario:i,ac:s}),B(g.EXERCISES,i,s,{},`exercises ${e.scenario}\u2192${e.ac}`))}let Be=0;for(let e of l.scoped_to_repoints??[]){let i=j(e.ac,"scoped_to_repoints.ac",_.AC),s=j(e.to,"scoped_to_repoints.to");if(!i||!s)continue;C.scoped_to_repoints.push({ac:i,to:s});let u=t.edgesFrom(i).find(p=>p.type===g.SCOPED_TO&&!t.superseded.has(p.ecid));if(u&&u.dst===s){Be+=1,L.push(`scoped_to_repoints ${e.ac}: already scoped to ${e.to} \u2014 no-op`);continue}u&&N.push({kind:"edge",ecid:u.ecid,reason:`re-scoped to ${e.to} by ${f.id}`,by:f}),B(g.SCOPED_TO,i,s,{},`scoped_to_repoints ${e.ac}`)}let Ue=new Map;if(n.finalizeTestBody)for(let[e,i]of t.nameOf)Ue.set(t.tipOf(e),i);let je=e=>t.nameOf.get(e)??Ue.get(t.tipOf(e))??null,Ee=e=>{if(w[e])return w[e];let i=t.resolve(e);return i?t.names.has(e)&&!t.superseded.has(i.cid)?i.cid:t.tipOf(i.cid):null},wt=e=>{let i=Ee(e);if(!i&&n.strict)throw new Error(`UNMAPPED_REF: '${e}' resolves to nothing on this graph`);return i?w[e]?q[e]??je(i):t.names.has(e)?e:je(i):null};Q&&Me();for(let e of l.tests??[]){for(let a of e.reuses??[])Se.has(a)&&k.push({code:"REUSES_EVICTED",detail:`${e.temp_ref}: reuses '${a}' which was budget-evicted \u2014 drop the edge; the dependent gap names the missing @import`});{let a=c=>c==="emulator"||c==="simulator"?c:"web",d=c=>{let v=(l.tests??[]).find(z=>z.temp_ref===c);if(v)return a(v.target);let h=t.resolve(c),b=h?t.getNode(t.tipOf(h.cid)??h.cid)?.content:void 0;if(typeof b?.target=="string")return a(String(b.target));let I=/^\s*\[mobile:\s*(emulator|simulator)\]/m.exec(String(b?.test_md_blob??""));return I?I[1]:"web"};for(let c of e.reuses??[]){let v=a(e.target),h=d(c);v!==h&&k.push({code:"REUSES_CROSS_SURFACE",detail:`${e.temp_ref}: reuses '${c}' which runs on ${h} while this test runs on ${v} \u2014 a test imports only same-surface units`})}}let i=e.test_md_blob,s=e.definitionId,u=e.objectives_blob;if(n.finalizeTestBody){let a;try{a=n.finalizeTestBody({temp_ref:e.temp_ref,test_md_blob:e.test_md_blob,verifies:e.verifies,reuses:e.reuses??[]},wt)}catch(d){return Y([{code:"FINALIZE_BODY",detail:`${e.temp_ref}: ${d instanceof Error?d.message:String(d)}`}])}a&&(i=a.test_md_blob,s=a.definitionId,u=a.objectives_blob??u,he[e.temp_ref]=s)}let p={title:e.title,check:e.check,definitionId:s,derived:!0,...e.config?{config:e.config}:{},...i?{test_md_blob:i}:{},...u?{objectives_blob:u}:{},...e.surface_required!==void 0?{surface_required:e.surface_required}:{},...e.target?{target:e.target}:{},...e.app&&e.target?{app:e.app}:{}},m=de(_.TEST,e.temp_ref,p,e.title);if(!m)continue;ge(m,e.cites,e.temp_ref,!0,M);let x=j(e.automates,`${e.temp_ref}.automates`,_.SCENARIO);x&&(C.automates[e.temp_ref]=x,B(g.AUTOMATES,m,x,{},`${e.temp_ref}.automates`)),C.verifies[e.temp_ref]=[];for(let a of e.verifies){let d=j(a,`${e.temp_ref}.verifies`,_.AC);d&&(C.verifies[e.temp_ref].push(d),B(g.VERIFIES,m,d,{},`${e.temp_ref}.verifies`))}C.reuses[e.temp_ref]=[];for(let a of e.reuses??[]){if(Se.has(a))continue;let d=j(a,`${e.temp_ref}.reuses`,_.TEST);d&&(C.reuses[e.temp_ref].push(d),B(g.REUSES,m,d,{},`${e.temp_ref}.reuses`))}for(let a of e.verifies){let d=Ee(a)??void 0;d&&(t.trust.get(d)??"derived")==="derived"&&!P.some(c=>c.cid===d)?(L.push(`${e.temp_ref}: verifies ${a} which is still DERIVED (unapproved) \u2014 committed anyway; approve it in chat or via review`),Z.push({test:e.temp_ref,criterion:d})):d&&w[a]===d&&(l.acs??[]).some(c=>c.temp_ref===a)&&(L.push(`${e.temp_ref}: verifies ${a} minted in this same record (unapproved) \u2014 committed anyway; approve it in chat`),Z.push({test:e.temp_ref,criterion:d}))}if(!String(e.test_md_blob??"").split(`
2
+ import{a as bt}from"./chunk-LX2I4JEH.js";import{a as St}from"./chunk-PCDIEYV6.js";import{a as gt,b as mt,d as ht,e as _t}from"./chunk-KDR662D2.js";import{F as ct,H as dt,L as at,M as ft,P as le,W as ut,a as st,b as Ie,ba as pt,f as nt,g as it,oa as X,pa as lt,r as ot,v as rt}from"./chunk-Z777GGHB.js";import{d as pe,e as W,f as _,g,h as Ze,i as et,j as tt}from"./chunk-KU3YHPWZ.js";var Pt=/\s@verifies\s+(ac-[\w.:\/-]+(?:\s*,\s*ac-[\w.:\/-]+)*)\s*$/,Lt=new Set([g.EXERCISES,g.VERIFIES,g.SCOPED_TO]),Y=n=>({record:null,errors:n,minted:{},logicalIds:{},superseded:[],warnings:[],finalizedTests:{}});function J(n){return n.toLowerCase().trim().replace(/\s+/g," ")}function yt(n,E,t,l,f){return y=>{if(!f||!W.has(String(y.kind))||!(y.kind==="unmeasurable"||l==="tests")||y.ref&&(t.scenarios??[]).some(T=>T.temp_ref===y.ref))return!0;let O=y.ref?n.resolve(y.ref):null;return!!(O&&n.nodeLabel.get(O.cid)===_.SCENARIO&&!n.superseded.has(n.tipOf(O.cid))&&n.edgesFrom(n.tipOf(O.cid)).some(T=>T.type===g.BELONGS_TO&&n.tipOf(T.dst)===E))}}function Ot(n){let E=new Set;return n.sections.scenarios?.length&&E.add(_.SCENARIO),n.sections.tests?.length&&E.add(_.TEST),n.gen8&&(n.sections.tests?.length||n.phase==="tests"&&n.gapsToMint.some(t=>W.has(String(t.kind))))&&(E.add(_.TEST),E.add(_.GAP)),E}function Et(n,E,t){let l=new Set,f=[];for(let y of E)n.superseded.has(y)||(t.has(n.nodeLabel.get(y)??"")?l.add(y):f.push(y));return{retired:l,remaining:f}}function ss(n,E){let t=n.tokenAt(E.seq),l=t===null?null:n.intentOf(t);if(l===null)return null;let f=l.args,y=l.pins.forceScope;if(l.verb!=="design"||f.forceScope==null||!Array.isArray(y)||!f.sections||!f.ucRef)return;let O=E.seq>1?n.tokenAt(E.seq-1):null;if(O===null)return null;let T=ft(n,{token:O}),F=le(T,f.ucRef);if(!F.ok)return null;let R=pe(f.templateVersion)>=8,C=(f.sections.gaps??[]).filter(yt(T,F.cid,f.sections,f.phase,R));return Et(T,y,Ot({sections:f.sections,phase:f.phase,gen8:R,gapsToMint:C})).remaining}function Ft(n,E,t={}){let l=le(n,E);if(!l.ok)return[];let f=new Set,y=new Set;for(let{cid:O}of n.byLabel(_.SCENARIO))if(!n.superseded.has(O)&&n.edgesFrom(O).some(T=>T.type===g.BELONGS_TO&&n.tipOf(T.dst)===l.cid)){f.add(O),y.add(O),y.add(n.tipOf(O));for(let T of n.edgesInto(O))T.type!==g.AUTOMATES||n.superseded.has(T.src)||f.add(T.src)}if(t.blockerGaps){let O=new Set([l.cid,n.tipOf(l.cid)]);for(let{cid:T,content:F}of n.byLabel(_.GAP)){if(n.superseded.has(T)||n.trust.get(T)==="archived"||!W.has(String(F.kind??"")))continue;let R=typeof F.uc=="string"?F.uc:"";if(!O.has(R)&&!O.has(n.tipOf(R)))continue;let C=F.ref,k=typeof C=="string"&&C?n.resolve(C):null;k&&(y.has(k.cid)||y.has(n.tipOf(k.cid)))&&f.add(T)}}return[...f]}function ns(n){let{store:E,graph:t,sections:l,by:f}=n,y=n.engine??"design@1",O=E.head(),T=E.serialize(O);if(!E.sameToken(E.parse(t.latestHash),O))return Y([{code:"STALE_BASIS",detail:`graph opened at ${String(t.latestHash)} but chain head is ${String(T)} \u2014 re-open and retry`}]);let F=le(t,n.ucRef);if(!F.ok)return Y([{code:"UNKNOWN_UC",detail:`${n.ucRef} is not a live use-case`}]);let R=F.cid,C={ucRef:R,automates:{},verifies:{},reuses:{},scope:{},depends_on:{},exercises:[],scoped_to_repoints:[],judgements:[],body_tags:{},forceScope:[]},k=[],Ae=/^design@(\d+)$/.exec(n.templateVersion??""),Q=pe(n.templateVersion)>=8,Ne=yt(t,R,l,n.phase,Q),te=(l.gaps??[]).filter(Ne),Tt=Ae!==null&&Number.parseInt(Ae[1],10)>=3,De=new Map,$t=(e,i)=>{let s=De.get(e.source_cid);if(s===void 0){let p=rt(E,t,e.source_cid);s=p?St(p.toString("utf8")):null,De.set(e.source_cid,s)}if(s===null)return k.push({code:"CITE_UNVERIFIED",detail:`${i}: source ${e.source_id} (${e.source_cid.slice(0,19)}) has no citable text to verify against`}),!1;let u=ct(t.mediaOf(e.source_cid),e,s);if(u.length>0){for(let p of u)k.push({code:"CITE_UNVERIFIED",detail:`${i}: ${p.code}: ${p.detail}`});return!1}return!0},xe=pe(n.templateVersion)>=9,kt=(e,i)=>{let s=e.source_cid?t.mediaOf(e.source_cid):void 0;if(!e.source_cid||!t.hasNode(e.source_cid)&&s==null)return{code:"CITE_SOURCE_UNKNOWN",detail:`${i}: there is no source ${e.source_id} in this store to cite \u2014 cite a source the use case reads, by its id`};if(s?.plugin?.cites_deep===!0)return null;let u=s?.format==="plugin"?`version ${e.source_cid.slice(0,19)} of ${e.source_id} was stored before its plugin allowed citations below the use case (or by a plugin that does not allow them) \u2014 re-ingest it, or cite it at the use case`:`${e.source_id} is not a source-plugin source that allows citations below the use case \u2014 cite it at the use case instead, or leave this item's cites out`;return{code:"CITE_DEPTH_UNSUPPORTED",detail:`${i}: ${u}`}},ge=(e,i,s,u,p)=>{for(let m of i??[]){if(u){let a=kt(m,`${s}.cite`);if(a){k.push(a);continue}}if(Tt&&!$t(m,`${s}.cite`))continue;let x={source_id:m.source_id,source_cid:m.source_cid,anchor:m.anchor,...m.quote?{quote:m.quote}:{}},G=Ct.one(e,x,p);if("fault"in G){k.push(G.fault);continue}B(g.DERIVES,m.source_cid,e,G.props,`${s}.cite`)}},vt=()=>xe?bt(t,R):[],P=[],M=[],N=[],me=[],re=[],w={},q={},he={},L=[],Z=[],H=[],Pe=new Set,_e=[],ce=new Set,Le=n.forceScope??(n.force?Ft(t,n.ucRef,{blockerGaps:Q}):[]);C.forceScope=[...Le];let{retired:U,remaining:Fe}=Et(t,Le,Ot({sections:l,phase:n.phase,gen8:Q,gapsToMint:te})),V=new Set,be=e=>!t.superseded.has(e)&&(!U.has(e)||V.has(e)),j=(e,i,s)=>{if(w[e])return w[e];let u=t.resolve(e),p=u?be(u.cid)?u.cid:t.tipOf(u.cid):null;return!u||!p||!be(p)?(k.push({code:"UNKNOWN_REF",detail:`${i}: '${e}' is neither in this payload nor a live committed node`}),null):s&&t.nodeLabel.get(p)!==s?(k.push({code:"ILLEGAL_EDGE",detail:`${i}: '${e}' is a ${t.nodeLabel.get(p)}, expected ${s}`}),null):p},Rt=(e,i,s,u)=>{if(t.nameOf.has(i)){q[u]=t.nameOf.get(i);return}let p=lt(e,m=>Pe.has(m),t.names.keys());p!==null&&(Pe.add(p),me.push({cid:i,slug:p,by:f}),q[u]=p)},de=(e,i,s,u)=>{for(let m of Ze(e,s))k.push({code:m.code,detail:`${i}: ${m.detail}`});let p=st(e,s);if(t.hasNode(p)&&!t.superseded.has(p))return U.has(p)&&V.add(p),w[i]=p,p;if(t.hasNode(p)&&t.superseded.has(p)){let m=X(t.nameOf.get(p)??p),x=t.tipOf(p),G=x!==p&&!t.superseded.has(x);return k.push(G?{code:"NODE_SUPERSEDED",detail:`${i}: '${u}' is ${m} as it was before it was replaced by ${X(t.nameOf.get(x)??x)} \u2014 refer to ${X(t.nameOf.get(x)??x)} to keep it, or send it changed`}:{code:"NODE_TOMBSTONED",detail:`${i}: '${u}' is ${m}, which was retired \u2014 a retired item can't come back as it was; send it changed (it is then a new item), or leave it out`}),null}return P.push({cid:p,label:e,content:s}),w[i]=p,Rt(e,p,u,i),p},Ct=it(nt(E,t)),B=(e,i,s,u,p)=>{let m=Ie(e,i,s,u);if(t.edgesFrom(i).some(d=>d.ecid===m&&!t.superseded.has(d.ecid))){e===g.AUTOMATES&&ce.add(s);return}if(t.superseded.has(m)){k.push({code:"EDGE_RETRACTED",detail:`${p}: this ${e} edge was retracted (${m}) \u2014 retraction is terminal for commits. Add a NEW relationship (different endpoint or props), redesign, or revert the retracting record`});return}if(Lt.has(e)&&t.hasNode(i)&&!t.superseded.has(i)&&t.hasNode(s)&&!t.superseded.has(s)){let d=t.displayNameOf(s);for(let c of t.edgesFrom(i))c.type!==e||c.dst===s||t.superseded.has(c.ecid)||!t.superseded.has(c.dst)||t.tipOf(c.dst)!==s||d===null||t.displayNameOf(c.dst)!==d||N.some(v=>v.kind==="edge"&&v.ecid===c.ecid)||N.push({kind:"edge",ecid:c.ecid,reason:`re-pinned onto ${s} (the same link to its live version) by ${f.id}`,by:f})}let x=t.nodeLabel.get(i)??P.find(d=>d.cid===i)?.label??"(unknown)",G=t.nodeLabel.get(s)??P.find(d=>d.cid===s)?.label??"(unknown)";for(let d of tt(e,x,G,u))k.push({code:d.code,detail:`${p}: ${d.detail}`});let a=ut(t,e,i,s,_e);if(a){k.push({code:a.code,detail:`${p}: ${a.detail}`});return}if(e===g.BELONGS_TO||e===g.SCOPED_TO){let d=dt(t,{type:e,src:i,dst:s},{pending:_e,retracted:new Set(N.flatMap(c=>c.kind==="edge"?[c.ecid]:[])),freed:new Set([...U].filter(c=>!V.has(c)))},p);if(d){k.push(d);return}}if(e===g.AUTOMATES){if(ce.has(s)){k.push({code:"CARDINALITY_VIOLATION",detail:`${p}: two automates onto ${s} in one record (strict 1:1)`});return}if(ce.add(s),!U.has(s)||V.has(s)){let d=h=>U.has(h)&&!V.has(h);if(t.edgesFrom(i).some(h=>h.type===g.AUTOMATES&&h.dst!==s&&!t.superseded.has(h.dst)&&!d(h.dst))&&t.hasNode(i)){k.push({code:"CARDINALITY_VIOLATION",detail:`${p}: automates from ${i} already has a live edge \u2014 supersede it first`});return}if(t.edgesInto(s).some(h=>h.type===g.AUTOMATES&&h.src!==i&&!t.superseded.has(h.src)&&!d(h.src))){k.push({code:"CARDINALITY_VIOLATION",detail:`${p}: automates onto ${s} already has a live edge \u2014 strict 1:1, supersede it first`});return}}}M.push({ecid:Ie(e,i,s,u),type:e,src:i,dst:s,props:u}),_e.push({src:i,dst:s,type:e})},Se=new Set;for(let e of te)e.kind==="budget-evicted"&&e.ref&&Se.add(e.ref);let K=[];for(let[e,i]of(l.gaps??[]).entries()){if(Ne(i))continue;let s=i.temp_ref??i.ref??"gap";K.push(e),L.push(`${s} not committed: a ${i.kind} gap stands in for a scenario's test \u2014 ref must be that scenario's committed id (sc-N) or its temp_ref in this payload; got ${i.ref?`'${i.ref}'`:"no ref"}`)}let Me=()=>{for(let e of te){let i=e.temp_ref??e.ref??"gap",s=e.question;if(!s||typeof s!="object"||!s.header||!Array.isArray(s.options)||s.options.length===0||!Number.isInteger(s.recommended_index)){k.push({code:"GAP_QUESTION_INCOMPLETE",detail:`${i}: design gaps carry a full ranked question object (header/options/recommended_index)`});continue}let u=e.ref?Q?w[e.ref]??e.ref:e.ref:void 0,p={kind:e.kind,question:s,derived:!0,uc:R,...e.risk?{risk:e.risk}:{},...e.risk_rationale?{risk_rationale:e.risk_rationale}:{},...e.text?{text:e.text}:{},...u?{ref:u}:{}};de(_.GAP,i,p,String(s.header))}};Q||Me();let ae=n.lineage===2,D={reuseOf:{seen:0,honored:0,linked:0,unresolved:0},byPair:0,byCriteria:0,byTitle:0},fe=[],ye={},Oe=new Map;if(ae)for(let e of l.scenarios??[]){if(typeof e.reuse_of!="string"||!e.reuse_of)continue;D.reuseOf.seen+=1;let i=t.resolve(e.reuse_of),s=i?t.superseded.has(i.cid)?t.tipOf(i.cid):i.cid:null;if(!(s!==null&&!t.superseded.has(s)&&t.nodeLabel.get(s)===_.SCENARIO&&t.edgesFrom(s).some(p=>p.type===g.BELONGS_TO&&t.tipOf(p.dst)===R))){D.reuseOf.unresolved+=1,fe.push(`${e.temp_ref}: reuse_of '${e.reuse_of}' names no scenario of this use case \u2014 saved as a new scenario`);continue}Oe.set(e.temp_ref,s),ye[e.temp_ref]=s}let Ge=new Map;for(let{cid:e,content:i}of t.byLabel(_.SCENARIO))be(e)&&t.edgesFrom(e).some(s=>s.type===g.BELONGS_TO&&t.tipOf(s.dst)===R)&&Ge.set(J(String(i.title??"")),e);for(let e of l.scenarios??[]){let i=Oe.get(e.temp_ref);if(i!==void 0&&!U.has(i))if(t.edgesInto(i).some(m=>m.type===g.AUTOMATES&&!t.superseded.has(m.ecid)&&!t.superseded.has(m.src))&&(l.tests??[]).some(m=>m.automates===e.temp_ref))fe.push(`${e.temp_ref}: reuse_of '${e.reuse_of}' names a scenario that already has its test \u2014 saved as a new scenario`);else{w[e.temp_ref]=i;let m=t.displayNameOf(i);m&&(q[e.temp_ref]=m),D.reuseOf.linked+=1;continue}let s=Ge.get(J(e.title));if(s){k.push({code:"DUPLICATE_SCENARIO",detail:`${e.temp_ref}: '${e.title}' duplicates live scenario ${t.nameOf.get(s)??s} \u2014 exercise/link it instead (reuse before minting)`});continue}let u={title:e.title,intent:e.intent,case_type:e.case_type,derived:!0,...e.technique_notes?{technique_notes:e.technique_notes}:{},...e.description?{description:e.description}:{},...e.parameters?{parameters:e.parameters}:{},...e.tags?{tags:e.tags}:{}};de(_.SCENARIO,e.temp_ref,u,e.title)}for(let e of l.scenarios??[]){let i=w[e.temp_ref];if(i){B(g.BELONGS_TO,i,R,{},e.temp_ref);for(let s of e.depends_on??[]){let u=j(s,`${e.temp_ref}.depends_on`,_.SCENARIO);u&&((C.depends_on[e.temp_ref]??=[]).push(u),B(g.DEPENDS_ON,i,u,{},`${e.temp_ref}.depends_on`))}ge(i,e.cites,e.temp_ref,!0,M)}}for(let e of l.acs??[]){let i={text:e.text,kind:e.kind,risk:e.risk,derived:!0,...e.expected_answer?{expected_answer:e.expected_answer}:{},...e.measurable!==void 0?{measurable:e.measurable}:{}},s=de(_.AC,e.temp_ref,i,e.text);if(!s)continue;let u=e.scope?.type==="scenario"&&e.scope.ref?j(e.scope.ref,`${e.temp_ref}.scope`,_.SCENARIO):R;u&&u!==R&&(C.scope[e.temp_ref]=u),u&&!t.edgesFrom(s).some(p=>p.type===g.SCOPED_TO&&!t.superseded.has(p.ecid))&&B(g.SCOPED_TO,s,u,{},`${e.temp_ref}.scope`),ge(s,e.cites,e.temp_ref,xe,M)}for(let e of l.exercises??[]){let i=j(e.scenario,"exercises.scenario",_.SCENARIO),s=j(e.ac,"exercises.ac",_.AC);!i||!s||(C.exercises.push({scenario:i,ac:s}),B(g.EXERCISES,i,s,{},`exercises ${e.scenario}\u2192${e.ac}`))}let Be=0;for(let e of l.scoped_to_repoints??[]){let i=j(e.ac,"scoped_to_repoints.ac",_.AC),s=j(e.to,"scoped_to_repoints.to");if(!i||!s)continue;C.scoped_to_repoints.push({ac:i,to:s});let u=t.edgesFrom(i).find(p=>p.type===g.SCOPED_TO&&!t.superseded.has(p.ecid));if(u&&u.dst===s){Be+=1,L.push(`scoped_to_repoints ${e.ac}: already scoped to ${e.to} \u2014 no-op`);continue}u&&N.push({kind:"edge",ecid:u.ecid,reason:`re-scoped to ${e.to} by ${f.id}`,by:f}),B(g.SCOPED_TO,i,s,{},`scoped_to_repoints ${e.ac}`)}let Ue=new Map;if(n.finalizeTestBody)for(let[e,i]of t.nameOf)Ue.set(t.tipOf(e),i);let je=e=>t.nameOf.get(e)??Ue.get(t.tipOf(e))??null,Ee=e=>{if(w[e])return w[e];let i=t.resolve(e);return i?t.names.has(e)&&!t.superseded.has(i.cid)?i.cid:t.tipOf(i.cid):null},wt=e=>{let i=Ee(e);if(!i&&n.strict)throw new Error(`UNMAPPED_REF: '${e}' resolves to nothing on this graph`);return i?w[e]?q[e]??je(i):t.names.has(e)?e:je(i):null};Q&&Me();for(let e of l.tests??[]){for(let a of e.reuses??[])Se.has(a)&&k.push({code:"REUSES_EVICTED",detail:`${e.temp_ref}: reuses '${a}' which was budget-evicted \u2014 drop the edge; the dependent gap names the missing @import`});{let a=c=>c==="emulator"||c==="simulator"?c:"web",d=c=>{let v=(l.tests??[]).find(z=>z.temp_ref===c);if(v)return a(v.target);let h=t.resolve(c),b=h?t.getNode(t.tipOf(h.cid)??h.cid)?.content:void 0;if(typeof b?.target=="string")return a(String(b.target));let I=/^\s*\[mobile:\s*(emulator|simulator)\]/m.exec(String(b?.test_md_blob??""));return I?I[1]:"web"};for(let c of e.reuses??[]){let v=a(e.target),h=d(c);v!==h&&k.push({code:"REUSES_CROSS_SURFACE",detail:`${e.temp_ref}: reuses '${c}' which runs on ${h} while this test runs on ${v} \u2014 a test imports only same-surface units`})}}let i=e.test_md_blob,s=e.definitionId,u=e.objectives_blob;if(n.finalizeTestBody){let a;try{a=n.finalizeTestBody({temp_ref:e.temp_ref,test_md_blob:e.test_md_blob,verifies:e.verifies,reuses:e.reuses??[]},wt)}catch(d){return Y([{code:"FINALIZE_BODY",detail:`${e.temp_ref}: ${d instanceof Error?d.message:String(d)}`}])}a&&(i=a.test_md_blob,s=a.definitionId,u=a.objectives_blob??u,he[e.temp_ref]=s)}let p={title:e.title,check:e.check,definitionId:s,derived:!0,...e.config?{config:e.config}:{},...i?{test_md_blob:i}:{},...u?{objectives_blob:u}:{},...e.surface_required!==void 0?{surface_required:e.surface_required}:{},...e.target?{target:e.target}:{},...e.app&&e.target?{app:e.app}:{}},m=de(_.TEST,e.temp_ref,p,e.title);if(!m)continue;ge(m,e.cites,e.temp_ref,!0,M);let x=j(e.automates,`${e.temp_ref}.automates`,_.SCENARIO);x&&(C.automates[e.temp_ref]=x,B(g.AUTOMATES,m,x,{},`${e.temp_ref}.automates`)),C.verifies[e.temp_ref]=[];for(let a of e.verifies){let d=j(a,`${e.temp_ref}.verifies`,_.AC);d&&(C.verifies[e.temp_ref].push(d),B(g.VERIFIES,m,d,{},`${e.temp_ref}.verifies`))}C.reuses[e.temp_ref]=[];for(let a of e.reuses??[]){if(Se.has(a))continue;let d=j(a,`${e.temp_ref}.reuses`,_.TEST);d&&(C.reuses[e.temp_ref].push(d),B(g.REUSES,m,d,{},`${e.temp_ref}.reuses`))}for(let a of e.verifies){let d=Ee(a)??void 0;d&&(t.trust.get(d)??"derived")==="derived"&&!P.some(c=>c.cid===d)?(L.push(`${e.temp_ref}: verifies ${a} which is still DERIVED (unapproved) \u2014 committed anyway; approve it in chat or via review`),Z.push({test:e.temp_ref,criterion:d})):d&&w[a]===d&&(l.acs??[]).some(c=>c.temp_ref===a)&&(L.push(`${e.temp_ref}: verifies ${a} minted in this same record (unapproved) \u2014 committed anyway; approve it in chat`),Z.push({test:e.temp_ref,criterion:d}))}if(!String(e.test_md_blob??"").split(`
3
3
  `).some(a=>/^##\s/.test(a)&&!/—\s?assert/.test(a)&&Pt.test(a))&&e.verifies.length>1){let a=e.check?.verified_against;L.push(`${e.temp_ref}: verifies ${e.verifies.length} ACs but machine-asserts only 1 (check.verified_against=${a!=null?String(a):"?"}) \u2014 the rest ride prose only`)}}let se=[];for(let e of l.tests??[]){let i={};for(let s of Gt(e.test_md_blob,e.objectives_blob)){let u=Ee(s);u?i[s]=u:se.push(`${e.temp_ref}: body tag '${s}' resolves to nothing`)}C.body_tags[e.temp_ref]=i,se.push(...Mt(e.temp_ref,i,[...C.verifies[e.temp_ref]??[],...C.reuses[e.temp_ref]??[]]))}if(se.length>0){if(n.strict)return Y(se.map(e=>({code:"BODY_EDGE_MISMATCH",detail:e})));L.push(...se.map(e=>`integrity: ${e}`))}let ee=[];{let e=(a,d)=>`${a??""}\0${J(String(d??""))}`,i=(a,d)=>n.reason?`${n.reason} \u2014 evolve by ${f.id}${d?` (${d})`:""}`:a,s=a=>t.edgesFrom(a).some(d=>d.type!==g.SCOPED_TO?!1:d.dst===R||t.tipOf(d.dst)===R?!0:t.nodeLabel.get(d.dst)===_.SCENARIO&&t.edgesFrom(d.dst).some(c=>c.type===g.BELONGS_TO&&t.tipOf(c.dst)===R)),u=new Map;for(let{cid:a,content:d}of t.byLabel(_.AC)){if(t.superseded.has(a)||!s(a))continue;let c=J(String(d.text??""));u.set(c,[...u.get(c)??[],a])}let p=new Map;for(let a of P){if(a.label!==_.AC)continue;let d=J(String(a.content.text??""));p.set(d,[...p.get(d)??[],a.cid])}let m=[];for(let[a,d]of u){let c=p.get(a)??[];d.length!==1||c.length!==1||m.push([d[0],c[0]])}if(ae){let a=new Map(m),d=[...U].filter(o=>!V.has(o)),c=new Map,v=new Set,h=(o,r,S)=>{c.set(o,{cid:r,tag:S}),v.add(r)},b=(o,r)=>{let S=new Map;for(let A of o){let oe=r(A);oe&&S.set(oe,[...S.get(oe)??[],A])}return S},I=(o,r,S)=>{let A=0;for(let[oe,Je]of o){let Qe=r.get(oe)??[];Je.length===1&&Qe.length===1&&(h(Je[0],Qe[0],S),A+=1)}return A},z=new Map,$e=new Set;for(let[o,r]of Oe){let S=w[o];!U.has(r)||V.has(r)||!S||!P.some(A=>A.cid===S)||($e.add(S),z.set(r,[...z.get(r)??[],S]))}let $=new Set,It=o=>J(String(P.find(r=>r.cid===o)?.content.title??""));for(let[o,r]of z){if(r.length===1){h(o,r[0],"reuse_of successor"),D.reuseOf.honored+=1;continue}$.add(o);let S=r.filter(A=>It(A)===J(String(t.getNode(o)?.content.title??"")));S.length===1&&(h(o,S[0],"title-matched successor"),D.byTitle+=1)}let ke=o=>d.filter(r=>t.nodeLabel.get(r)===o&&!c.has(r)&&!$.has(r)),ve=o=>P.filter(r=>r.label===o&&!v.has(r.cid)&&!$e.has(r.cid)).map(r=>r.cid),ze=o=>[...new Set(o.map(r=>a.get(t.tipOf(r))??t.tipOf(r)))].sort().join(`
4
4
  `),At=o=>t.edgesFrom(o).filter(r=>r.type===g.EXERCISES&&!t.superseded.has(r.ecid)).map(r=>r.dst),Nt=o=>M.filter(r=>r.type===g.EXERCISES&&r.src===o).map(r=>r.dst);D.byCriteria+=I(b(ke(_.SCENARIO),o=>ze(At(o))),b(ve(_.SCENARIO),o=>ze(Nt(o))),"same-criteria successor");let He=(o,r)=>e(t.nodeLabel.get(o)??P.find(S=>S.cid===o)?.label,(r??t.getNode(o)?.content)?.title),Re=new Map(P.map(o=>[o.cid,o.content])),Ke=o=>I(b(ke(o),r=>He(r)),b(ve(o),r=>He(r,Re.get(r))),"title-matched successor");D.byTitle+=Ke(_.SCENARIO);let Dt=o=>{let r=t.edgesFrom(o).find(A=>A.type===g.AUTOMATES&&!t.superseded.has(A.ecid));if(!r)return"";let S=t.tipOf(r.dst);return c.get(r.dst)?.cid??c.get(S)?.cid??S};D.byPair+=I(b(ke(_.TEST),Dt),b(ve(_.TEST),o=>M.find(r=>r.type===g.AUTOMATES&&r.src===o)?.dst??""),"paired test successor"),D.byTitle+=Ke(_.TEST);let Ce=new Set(d),ue=o=>{let r=c.get(o)?.cid??c.get(t.tipOf(o))?.cid??t.tipOf(o);return t.superseded.has(r)&&!Re.has(r)||Ce.has(r)&&!c.has(r)?null:r},we=new Set;for(let o of M)o.type===g.AUTOMATES&&Re.has(o.src)&&we.add(ue(o.dst)??o.dst);for(let{cid:o}of t.byLabel(_.TEST))if(!(t.superseded.has(o)||Ce.has(o)))for(let r of t.edgesFrom(o))r.type===g.AUTOMATES&&!t.superseded.has(r.ecid)&&we.add(ue(r.dst)??r.dst);let xt=!l.tests?.length&&te.some(o=>W.has(String(o.kind))),We=new Set,Xe=o=>{if(typeof o!="string"||!o)return;let r=w[o]??t.resolve(o)?.cid,S=r?ue(r):null;S!==null&&We.add(S)};for(let o of te)W.has(String(o.kind))&&Xe(o.ref);for(let{cid:o,content:r}of t.byLabel(_.GAP))t.superseded.has(o)||Ce.has(o)||t.trust.get(o)==="archived"||W.has(String(r.kind??""))&&Xe(r.ref);let ie=new Map,Ye=new Set;for(let o of xt?[]:d){if(t.nodeLabel.get(o)!==_.TEST||c.has(o))continue;let r=t.edgesFrom(o).find(A=>A.type===g.AUTOMATES&&!t.superseded.has(A.ecid)),S=r?ue(r.dst):null;!r||S===null||we.has(S)||Ye.has(S)||We.has(S)||(ie.set(o,{edge:r,scenario:S}),Ye.add(S))}for(let o of d){if(ie.has(o))continue;let r=c.get(o);r?(N.push({kind:"node",old:o,new:r.cid,reason:i(`--force redesign of ${n.ucRef} by ${f.id} (${r.tag})`,r.tag),by:f}),ee.push({old:o,next:r.cid})):N.push({kind:"node",old:o,new:null,reason:i(`--force redesign of ${n.ucRef} by ${f.id}`),by:f}),H.push(o)}for(let[o,{edge:r,scenario:S}]of ie)r.dst===S||ee.some(A=>A.old===r.dst)||(N.push({kind:"edge",ecid:r.ecid,reason:`re-blessed onto ${S} (its test kept by the redesign of ${n.ucRef}) by ${f.id}`,by:f}),B(g.AUTOMATES,o,S,r.props,`keep ${t.nameOf.get(o)??o}`));ie.size>0&&(D.keptTests=ie.size)}else{let a=new Map;for(let c of P){if(c.label!==_.SCENARIO&&c.label!==_.TEST)continue;let v=e(c.label,c.content.title);a.set(v,[...a.get(v)??[],c.cid])}let d=new Map;for(let c of U){if(V.has(c))continue;let v=e(t.nodeLabel.get(c),t.getNode(c)?.content.title);d.set(v,[...d.get(v)??[],c])}for(let[c,v]of d){let h=a.get(c)??[],b=v.length===1&&h.length===1;for(let I of v)b?(N.push({kind:"node",old:I,new:h[0],reason:i(`--force redesign of ${n.ucRef} by ${f.id} (title-matched successor)`,"title-matched successor"),by:f}),ee.push({old:I,next:h[0]})):N.push({kind:"node",old:I,new:null,reason:i(`--force redesign of ${n.ucRef} by ${f.id}`),by:f}),H.push(I)}}for(let[a,d]of m)N.push({kind:"node",old:a,new:d,reason:i(`AC re-emitted with changed content by ${f.id} (text-matched successor)`,"AC text-matched successor"),by:f}),ee.push({old:a,next:d}),H.push(a);if(n.force||n.forceScope){let a=new Set(H),d=new Map(ee.map(b=>[b.old,b.next])),c=new Set(P.map(b=>b.cid)),v=b=>{if(c.has(b))return!0;let I=d.get(b)??t.tipOf(b);return c.has(I)||!t.superseded.has(I)&&!a.has(I)},h=new Set(N.flatMap(b=>b.kind==="edge"?[b.ecid]:[]));for(let{cid:b}of t.byLabel(_.AC)){if(t.superseded.has(b)||a.has(b)||!s(b))continue;let I=t.edgesFrom(b).filter($=>$.type===g.SCOPED_TO&&!t.superseded.has($.ecid)&&!h.has($.ecid)).map($=>$.dst);if(I.length===0||I.some(v))continue;let z=I.map($=>t.nameOf.get($)??t.nameOf.get(t.tipOf($))??$).join(", ");if([...t.edgesInto(b).filter($=>($.type===g.EXERCISES||$.type===g.VERIFIES)&&!t.superseded.has($.ecid)&&!h.has($.ecid)).map($=>$.src),...M.filter($=>($.type===g.EXERCISES||$.type===g.VERIFIES)&&$.dst===b).map($=>$.src)].some($=>v($))){L.push(`ORPHANED_CRITERION: ${X(t.nameOf.get(b)??b)} is scoped to ${z}, which is retired, and a live scenario or test still rests on it \u2014 kept; re-scope it (scoped_to_repoints) to the scenario or use case it belongs to`);continue}N.push({kind:"node",old:b,new:null,reason:i(`orphaned: its scenario ${z} was retired; retired with it by the redesign of ${n.ucRef} (${f.id})`,"orphaned criterion"),by:f}),H.push(b)}}let x=new Set(H),G=new Set;for(let a of N)a.kind==="edge"&&G.add(a.ecid);for(let{old:a,next:d}of ee)for(let c of t.edgesInto(a))et(c.type)?.pin?.comparesTo!=="dst_tip"||t.superseded.has(c.src)||x.has(c.src)||G.has(c.ecid)||(N.push({kind:"edge",ecid:c.ecid,reason:`re-blessed onto ${d} (redirect successor of ${a}) by ${f.id}`,by:f}),G.add(c.ecid),M.some(h=>h.type===c.type&&h.src===c.src&&h.dst===d)||t.edgesFrom(c.src).some(h=>h.type===c.type&&h.dst===d))||c.type===g.AUTOMATES&&ce.has(d)||B(c.type,c.src,d,c.props,`rebless ${c.type} from ${t.nameOf.get(c.src)??c.src}`)}let ne=vt();if(ne.length>0){let e=s=>[...M.filter(u=>u.dst===s),...t.edgesInto(s).filter(u=>!t.superseded.has(u.ecid))].some(u=>u.type===g.DERIVES&&ne.includes(String(u.props.source_id))),i=[...(l.scenarios??[]).map(s=>({label:"scenario",temp_ref:s.temp_ref,title:s.title})),...(l.tests??[]).map(s=>({label:"test",temp_ref:s.temp_ref,title:s.title}))];for(let s of i){let u=w[s.temp_ref];!u||e(u)||L.push(`CITE_MISSING: ${s.label} ${X(q[s.temp_ref]??t.nameOf.get(u)??s.temp_ref)} "${s.title}" cites nothing of ${ne.join(", ")}, whose plugin asks each scenario and test to cite what it rests on \u2014 committed anyway; cite its screens and flows so a change to them marks exactly this ${s.label} stale`)}}if(ne.length>0)for(let e of n.droppedCriterionCites??[]){let i=w[e.temp_ref],s=X(q[e.temp_ref]??(i?t.nameOf.get(i):void 0)??e.temp_ref);L.push(`CITE_DROPPED: criterion ${s} \u2014 a cite was dropped: ${e.why}; the criterion is committed without it. A criterion cites only into ${ne.join(", ")}, whose plugin asks each item to cite what it rests on`)}if(k.length>0)return Y(k);let qe=ae&&(D.reuseOf.seen>0||D.byPair+D.byCriteria+D.byTitle+(D.keptTests??0)>0)?{lineage:D}:{},Ve=fe.length?{modelWarnings:fe}:{};if(P.length===0&&M.length===0&&N.length===0&&re.length===0)return Object.keys(w).length>0||Be>0?(L.push("everything in this phase is already current \u2014 nothing re-committed"),{record:null,errors:null,minted:w,logicalIds:q,superseded:[],warnings:L,finalizedTests:he,unchanged:!0,...K.length?{droppedBlockers:K}:{},...Z.length?{awaitingApproval:Z}:{},...qe,...Ve,...n.force||n.forceScope?{forceScopeRemaining:Fe}:{}}):{...Y([{code:"EMPTY_DESIGN",detail:"finalize_design produced nothing to commit"}]),warnings:L,...K.length?{droppedBlockers:K}:{}};if(n.generationTicket){let e=ht(t,n.generationTicket);if(e!==null)return Y([e])}let Te=n.eventIds&&n.eventIds.length>0?n.eventIds:n.sid?pt(t,n.sid,"design",1):null;return{record:at(E,{ts:new Date().toISOString(),proposal_id:null,nodes:P,edges:M,review:[],supersessions:N,source_head_moves:{},...me.length>0?{names:me}:{},...(()=>{for(let e of l.judgements??[]){let i=e.target?w[e.target]??t.resolve(e.target)?.tip??R:R;C.judgements.push(i),re.push({about:i,rationale:`[${e.kind}] ${e.rationale}`,by:f})}return re.length>0?{judgements:re}:{}})(),design_of:{uc_cid:R,engine:y},...n.generationTicket?{design_generation:_t(n.generationTicket,R,f)}:{},...Te?{event_ids:Te}:{},...n.sid?{sid:n.sid}:{},...n.phase?{design_phase:{uc_root:gt(t,t.resolve(n.ucRef)?.cid??R),generation:n.generationTicket?.next_gen??mt(t,n.ucRef)?.gen??1,phase:n.phase,completeness:n.phaseCompleteness??"complete",...n.payloadDigest?{payload_digest:n.payloadDigest}:{}}}:{}},{graph:t,scope:{ucTargets:[{ref:R}],...n.generationTicket?{generationTicket:{uc_root:n.generationTicket.uc_root,next_gen:n.generationTicket.next_gen}}:{}},expectPrev:t.latestHash,intent:{v:1,verb:"design",args:ot({ucRef:n.ucRef,sections:l,by:f,engine:y,force:n.force??!1,forceScope:n.forceScope??null,reason:n.reason??null,generationTicket:n.generationTicket??null,templateVersion:n.templateVersion??null,phase:n.phase??null,phaseCompleteness:n.phaseCompleteness??null,eventIds:Te,sid:n.sid??null,...ae?{lineage:2}:{}}),pins:Object.keys(ye).length?{...C,reuse_of:ye}:C},provenance:n.provenance}).record,errors:null,minted:w,logicalIds:q,superseded:H,warnings:L,finalizedTests:he,...K.length?{droppedBlockers:K}:{},...Z.length?{awaitingApproval:Z}:{},...n.force||n.forceScope?{forceScopeRemaining:Fe}:{},...qe,...Ve}}function Mt(n,E,t){let l=new Set(Object.values(E));if(l.size===0)return[];let f=new Set(t),y=[];for(let[O,T]of Object.entries(E))f.has(T)||y.push(`${n}: body tag '${O}' has no verifies or reuses edge`);for(let O of f)l.has(O)||y.push(`${n}: edge to ${O} has no body tag`);return y}function Gt(n,E){let t=[];for(let f of(n??"").split(`
5
5
  `)){let y=/^##\s.*?\s@verifies\s+(.+?)\s*$/.exec(f);y&&t.push(...y[1].split(",").map(T=>T.trim()).filter(Boolean));let O=/^@import\s+(\S+)\s*$/.exec(f.trim())??/^## Import: (\S+)\s*$/.exec(f);O&&t.push(O[1])}let l=null;for(let f of(E??"").split(`
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as d,g as B,k as re}from"./chunk-CB4ARIHR.js";import{a as te}from"./chunk-4IEQNX7F.js";import{fb as ee}from"./chunk-UEE3RZN4.js";import{a as Z}from"./chunk-7DFBOVUB.js";import{g as A}from"./chunk-4I7YN6YY.js";import{createHash as ve,randomBytes as F}from"crypto";import{mkdirSync as ke,mkdtempSync as P,rmSync as $,existsSync as Oe,renameSync as Re}from"fs";import{tmpdir as j}from"os";import{join as _,dirname as de}from"path";import{spawn as ie}from"child_process";function N(n,e=process.env){let t=n.replace(/https?:\/\/[^\s/@]+:[^\s/@]+@/gi,"https://[redacted]@").replace(/(authorization\s*[:=])[^\r\n]+/gi,"$1 [redacted]"),r=e.KANE_SYNC_GIT_TOKEN;if(r)for(let i of[r,Buffer.from(`x-access-token:${r}`).toString("base64")])t=t.split(i).join("[redacted]");return t}function Ae(n,e){if(n.GIT_SSH_COMMAND)return ne(n.GIT_SSH_COMMAND);if(!n.GIT_SSH)return e?ne(e):"ssh -o BatchMode=yes"}function ne(n){return/(^|\s)-o\s*BatchMode=yes(\s|$)/.test(n)?n:`${n} -o BatchMode=yes`}var Ce=/^(?:ssh:\/\/|[^/\s@:]+@[^/\s:]+:)/i,se=new Map;function Ne(n,e){let t=[e??"",n.GIT_CONFIG_GLOBAL??"",n.HOME??""].join("\0"),r=se.get(t);return r===void 0&&(r=ae(["config","--get","core.sshCommand"],n,e,12e4).then(i=>i.code===0&&i.stdout.toString().trim()||void 0,()=>{}),se.set(t,r)),r}var oe=new Set(["fetch","push","clone","ls-remote"]);function xe(n,e,t){if(t!==void 0)return t;if(!n.some(i=>oe.has(i)))return 12e4;let r=e.KANE_SYNC_GIT_TRANSFER_TIMEOUT_SECONDS;if(r!==void 0){if(!/^\d+$/.test(r)||Number(r)<60||Number(r)>3600)throw new Error("KANE_SYNC_GIT_TRANSFER_TIMEOUT_SECONDS must be 60 to 3600");return Number(r)*1e3}return 9e5}function Ie(n){if(n.some(t=>/^(--force(?:-with-lease|-if-includes)?(?:=|$)|--mirror(?:=|$)|--delete(?:=|$)|-f$)/.test(t)))throw new Error("Git location cannot force, mirror or delete");let e=n.indexOf("push");if(e>=0){let t=n.slice(e+1);if(t.length!==3||t[0]!=="--porcelain"||!/^[0-9a-f]{40,64}:refs\/(heads|kane\/probe)\/[A-Za-z0-9._/-]+$/.test(t[2]))throw new Error("Git location requires an exact commit SHA and explicit ref")}}var H=async(n,e={})=>{Ie(n);let t={...process.env,...e.env};for(let h of["GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_CONFIG_PARAMETERS"])delete t[h];e.env?.GIT_INDEX_FILE&&(t.GIT_INDEX_FILE=e.env.GIT_INDEX_FILE);let r=[["core.autocrlf","false"],["core.eol","lf"],["core.symlinks","false"],["core.hooksPath","/dev/null"],["gc.autoDetach","false"],["gc.pruneExpire","3.days.ago"],["maintenance.auto","false"],["push.followTags","false"],["push.gpgSign","false"],["commit.gpgSign","false"]],i=t.KANE_SYNC_GIT_HTTP_POST_BUFFER;if(i!==void 0){if(!/^\d+$/.test(i)||Number(i)<1048576||Number(i)>536870912)throw new Error("KANE_SYNC_GIT_HTTP_POST_BUFFER must be 1048576 to 536870912 bytes; use it only for a proxy that rejects chunked uploads");r.push(["http.postBuffer",i])}for(let h of Object.keys(t))h.startsWith("GIT_TRACE")&&delete t[h];let s=n.find(h=>h.startsWith("https://"));if(t.KANE_SYNC_GIT_TOKEN&&s){let h=new URL(s);r.push([`http.${h.origin}${h.pathname}.extraheader`,""],[`http.${h.origin}${h.pathname}.extraheader`,`AUTHORIZATION: basic ${Buffer.from(`x-access-token:${t.KANE_SYNC_GIT_TOKEN}`).toString("base64")}`],["credential.helper",""])}for(let h of Object.keys(t))/^GIT_CONFIG_(COUNT|KEY_\d+|VALUE_\d+)$/.test(h)&&delete t[h];let a=!t.GIT_SSH_COMMAND&&!t.GIT_SSH&&n.some(h=>oe.has(h))&&n.some(h=>Ce.test(h))?await Ne({...t},e.cwd):void 0;r.forEach(([h,u],g)=>{t[`GIT_CONFIG_KEY_${g}`]=h,t[`GIT_CONFIG_VALUE_${g}`]=u}),t.GIT_CONFIG_COUNT=String(r.length),t.GIT_TERMINAL_PROMPT="0",t.GCM_INTERACTIVE="never",t.GIT_ASKPASS="",t.SSH_ASKPASS="";let c=Ae(t,a);return c!==void 0&&(t.GIT_SSH_COMMAND=c),t.GIT_NO_REPLACE_OBJECTS="1",ae(n,t,e.cwd,xe(n,t,e.timeout),e.input)};function ae(n,e,t,r,i){return new Promise((s,o)=>{let a=ie("git",n,{cwd:t,env:e,windowsHide:!0,detached:process.platform!=="win32",stdio:["pipe","pipe","pipe"]}),c=[],h=0,u="",g=!1,w=()=>{if(process.platform==="win32"&&a.pid)ie("taskkill",["/pid",String(a.pid),"/t","/f"],{windowsHide:!0,stdio:"ignore"}).on("error",()=>a.kill("SIGKILL"));else try{a.pid&&process.kill(-a.pid,"SIGKILL")}catch{a.kill("SIGKILL")}},S=setTimeout(()=>{g=!0,w()},r);a.stdout.on("data",l=>{h+=l.length,h>128*1024*1024?w():c.push(l)}),a.stderr.on("data",l=>{u.length<64e3&&(u+=l.toString())}),a.stdin.on("error",()=>{}),a.on("error",l=>{clearTimeout(S),o(new d("SYNC_GIT_REQUIRED",`Git could not start: ${N(l.message,e)}`,"Install Git 2.31 or newer, then run the command again: https://git-scm.com/downloads"))}),a.on("close",l=>{clearTimeout(S),s({code:g||h>128*1024*1024?124:l??1,stdout:Buffer.concat(c),stderr:N(g?"Git operation timed out":u,e)})}),a.stdin.end(i)})}async function ce(n=H){let e=await n(["--version"],{timeout:1e4}),t=/git version (\d+)\.(\d+)/.exec(e.stdout.toString());if(e.code||!t||+t[1]<2||+t[1]==2&&+t[2]<31)throw new d("SYNC_GIT_REQUIRED","This location needs Git 2.31 or newer.","Install or update Git, then run setup again: https://git-scm.com/downloads")}function he(n){let e=/^([^/@:]+)@([^/:]+):/.exec(n);if(e)return{user:e[1],host:e[2]};try{let t=new URL(n);return{host:t.hostname||"the server",user:t.username||"git",port:t.port||void 0}}catch{return{host:"the server",user:"git"}}}function yt(n){let e=/^[^/@:]+@([^/:]+):/.exec(n);if(e)return e[1].toLowerCase();try{return new URL(n).hostname.toLowerCase()}catch{return""}}function Y(n,e){let{host:t,user:r,port:i}=he(e),s=N(n).trim().split(`
2
+ import{a as d,g as B,k as re}from"./chunk-CB4ARIHR.js";import{a as te}from"./chunk-4IEQNX7F.js";import{fb as ee}from"./chunk-Z777GGHB.js";import{a as Z}from"./chunk-7DFBOVUB.js";import{g as A}from"./chunk-4I7YN6YY.js";import{createHash as ve,randomBytes as F}from"crypto";import{mkdirSync as ke,mkdtempSync as P,rmSync as $,existsSync as Oe,renameSync as Re}from"fs";import{tmpdir as j}from"os";import{join as _,dirname as de}from"path";import{spawn as ie}from"child_process";function N(n,e=process.env){let t=n.replace(/https?:\/\/[^\s/@]+:[^\s/@]+@/gi,"https://[redacted]@").replace(/(authorization\s*[:=])[^\r\n]+/gi,"$1 [redacted]"),r=e.KANE_SYNC_GIT_TOKEN;if(r)for(let i of[r,Buffer.from(`x-access-token:${r}`).toString("base64")])t=t.split(i).join("[redacted]");return t}function Ae(n,e){if(n.GIT_SSH_COMMAND)return ne(n.GIT_SSH_COMMAND);if(!n.GIT_SSH)return e?ne(e):"ssh -o BatchMode=yes"}function ne(n){return/(^|\s)-o\s*BatchMode=yes(\s|$)/.test(n)?n:`${n} -o BatchMode=yes`}var Ce=/^(?:ssh:\/\/|[^/\s@:]+@[^/\s:]+:)/i,se=new Map;function Ne(n,e){let t=[e??"",n.GIT_CONFIG_GLOBAL??"",n.HOME??""].join("\0"),r=se.get(t);return r===void 0&&(r=ae(["config","--get","core.sshCommand"],n,e,12e4).then(i=>i.code===0&&i.stdout.toString().trim()||void 0,()=>{}),se.set(t,r)),r}var oe=new Set(["fetch","push","clone","ls-remote"]);function xe(n,e,t){if(t!==void 0)return t;if(!n.some(i=>oe.has(i)))return 12e4;let r=e.KANE_SYNC_GIT_TRANSFER_TIMEOUT_SECONDS;if(r!==void 0){if(!/^\d+$/.test(r)||Number(r)<60||Number(r)>3600)throw new Error("KANE_SYNC_GIT_TRANSFER_TIMEOUT_SECONDS must be 60 to 3600");return Number(r)*1e3}return 9e5}function Ie(n){if(n.some(t=>/^(--force(?:-with-lease|-if-includes)?(?:=|$)|--mirror(?:=|$)|--delete(?:=|$)|-f$)/.test(t)))throw new Error("Git location cannot force, mirror or delete");let e=n.indexOf("push");if(e>=0){let t=n.slice(e+1);if(t.length!==3||t[0]!=="--porcelain"||!/^[0-9a-f]{40,64}:refs\/(heads|kane\/probe)\/[A-Za-z0-9._/-]+$/.test(t[2]))throw new Error("Git location requires an exact commit SHA and explicit ref")}}var H=async(n,e={})=>{Ie(n);let t={...process.env,...e.env};for(let h of["GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_CONFIG_PARAMETERS"])delete t[h];e.env?.GIT_INDEX_FILE&&(t.GIT_INDEX_FILE=e.env.GIT_INDEX_FILE);let r=[["core.autocrlf","false"],["core.eol","lf"],["core.symlinks","false"],["core.hooksPath","/dev/null"],["gc.autoDetach","false"],["gc.pruneExpire","3.days.ago"],["maintenance.auto","false"],["push.followTags","false"],["push.gpgSign","false"],["commit.gpgSign","false"]],i=t.KANE_SYNC_GIT_HTTP_POST_BUFFER;if(i!==void 0){if(!/^\d+$/.test(i)||Number(i)<1048576||Number(i)>536870912)throw new Error("KANE_SYNC_GIT_HTTP_POST_BUFFER must be 1048576 to 536870912 bytes; use it only for a proxy that rejects chunked uploads");r.push(["http.postBuffer",i])}for(let h of Object.keys(t))h.startsWith("GIT_TRACE")&&delete t[h];let s=n.find(h=>h.startsWith("https://"));if(t.KANE_SYNC_GIT_TOKEN&&s){let h=new URL(s);r.push([`http.${h.origin}${h.pathname}.extraheader`,""],[`http.${h.origin}${h.pathname}.extraheader`,`AUTHORIZATION: basic ${Buffer.from(`x-access-token:${t.KANE_SYNC_GIT_TOKEN}`).toString("base64")}`],["credential.helper",""])}for(let h of Object.keys(t))/^GIT_CONFIG_(COUNT|KEY_\d+|VALUE_\d+)$/.test(h)&&delete t[h];let a=!t.GIT_SSH_COMMAND&&!t.GIT_SSH&&n.some(h=>oe.has(h))&&n.some(h=>Ce.test(h))?await Ne({...t},e.cwd):void 0;r.forEach(([h,u],g)=>{t[`GIT_CONFIG_KEY_${g}`]=h,t[`GIT_CONFIG_VALUE_${g}`]=u}),t.GIT_CONFIG_COUNT=String(r.length),t.GIT_TERMINAL_PROMPT="0",t.GCM_INTERACTIVE="never",t.GIT_ASKPASS="",t.SSH_ASKPASS="";let c=Ae(t,a);return c!==void 0&&(t.GIT_SSH_COMMAND=c),t.GIT_NO_REPLACE_OBJECTS="1",ae(n,t,e.cwd,xe(n,t,e.timeout),e.input)};function ae(n,e,t,r,i){return new Promise((s,o)=>{let a=ie("git",n,{cwd:t,env:e,windowsHide:!0,detached:process.platform!=="win32",stdio:["pipe","pipe","pipe"]}),c=[],h=0,u="",g=!1,w=()=>{if(process.platform==="win32"&&a.pid)ie("taskkill",["/pid",String(a.pid),"/t","/f"],{windowsHide:!0,stdio:"ignore"}).on("error",()=>a.kill("SIGKILL"));else try{a.pid&&process.kill(-a.pid,"SIGKILL")}catch{a.kill("SIGKILL")}},S=setTimeout(()=>{g=!0,w()},r);a.stdout.on("data",l=>{h+=l.length,h>128*1024*1024?w():c.push(l)}),a.stderr.on("data",l=>{u.length<64e3&&(u+=l.toString())}),a.stdin.on("error",()=>{}),a.on("error",l=>{clearTimeout(S),o(new d("SYNC_GIT_REQUIRED",`Git could not start: ${N(l.message,e)}`,"Install Git 2.31 or newer, then run the command again: https://git-scm.com/downloads"))}),a.on("close",l=>{clearTimeout(S),s({code:g||h>128*1024*1024?124:l??1,stdout:Buffer.concat(c),stderr:N(g?"Git operation timed out":u,e)})}),a.stdin.end(i)})}async function ce(n=H){let e=await n(["--version"],{timeout:1e4}),t=/git version (\d+)\.(\d+)/.exec(e.stdout.toString());if(e.code||!t||+t[1]<2||+t[1]==2&&+t[2]<31)throw new d("SYNC_GIT_REQUIRED","This location needs Git 2.31 or newer.","Install or update Git, then run setup again: https://git-scm.com/downloads")}function he(n){let e=/^([^/@:]+)@([^/:]+):/.exec(n);if(e)return{user:e[1],host:e[2]};try{let t=new URL(n);return{host:t.hostname||"the server",user:t.username||"git",port:t.port||void 0}}catch{return{host:"the server",user:"git"}}}function yt(n){let e=/^[^/@:]+@([^/:]+):/.exec(n);if(e)return e[1].toLowerCase();try{return new URL(n).hostname.toLowerCase()}catch{return""}}function Y(n,e){let{host:t,user:r,port:i}=he(e),s=N(n).trim().split(`
3
3
  `).slice(-2).join(" ").trim();return/Host key verification failed|REMOTE HOST IDENTIFICATION HAS CHANGED/i.test(n)?{code:"SYNC_LOCATION_DENIED",message:`this computer has not accepted ${t}'s SSH host key yet`,remedy:`in a terminal run: ssh -T ${i?`-p ${i} `:""}${r}@${t} and answer yes, then run the command again`,diagnostic:s}:/Permission denied \(publickey/i.test(n)?{code:"SYNC_LOCATION_DENIED",message:`${t} did not accept your SSH key`,remedy:"load it with ssh-add, or ask the repository owner to grant your account access",diagnostic:s}:/could not read Username|Authentication failed|Access denied|Invalid username or (password|token)|returned error: 401|returned error: 403/i.test(n)?{code:"SYNC_LOCATION_DENIED",message:`sign in is needed, or your account has no access to this repository on ${t}`,remedy:"sign in through Git, or ask the owner to grant your account access",diagnostic:s}:/Could not resolve host|Connection refused|Connection timed out|timed out|Network is unreachable|Failed to connect/i.test(n)?{code:"SYNC_LOCATION_UNREACHABLE",message:`${t} could not be reached`,remedy:"check the address and your network, then run the command again",diagnostic:s}:/not found|does not appear to be a git repository|Repository not found/i.test(n)?{code:"SYNC_LOCATION_UNREACHABLE",message:"no repository answered at that address, or your account cannot see it; a private repository looks missing until access is granted",remedy:"check the address, then run the command again",diagnostic:s}:{code:"SYNC_LOCATION_UNREACHABLE",message:`git could not read the repository on ${t}`,remedy:"check the address and your access, then run the command again",...s?{diagnostic:s}:{}}}function M(n,e){return(n.startsWith(e)?n:n.charAt(0).toUpperCase()+n.slice(1))+"."}function wt(n,e){let t=Y(n,e),{host:r}=he(e),i=t.remedy.replace(/,? ?(and )?then run the command again$/,"");return i?`${M(t.message,r)} ${M(i,r)}`:M(t.message,r)}var Pe=Buffer.from(`* -text -filter -ident -working-tree-encoding
4
4
  `),$e="refs/kane/tip",Ge=/unexpected disconnect|hung up unexpectedly|Connection reset|Connection timed out|timed out|Could not resolve host|Failed to connect|RPC failed|Broken pipe|early EOF/i,Ue={GIT_AUTHOR_NAME:"kane-cli context",GIT_AUTHOR_EMAIL:"context@kane-cli.invalid",GIT_COMMITTER_NAME:"kane-cli context",GIT_COMMITTER_EMAIL:"context@kane-cli.invalid"},G=class n{constructor(e){this.options=e;this.exec=e.exec??H,this.prefix=e.prefix?`${e.prefix}/`:"";let t=ve("sha256").update(JSON.stringify([e.url,e.branch,this.prefix])).digest("hex");if(this.repo=_(e.cacheDir??_(A().baseDir,"context-sync","mirrors"),`${t}.git`),this.ref=e.ref??`refs/heads/${e.branch}`,!/^refs\/(heads|kane\/probe)\/[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(this.ref)||this.ref.includes(".."))throw new Error("Invalid Git location ref")}kind="git";contractVersion=1;ceilingTier=1;exec;repo;ref;prefix;ready;tip=null;tree=new Map;async run(e,t={}){let r=await this.exec(["--git-dir",this.repo,...e],t);if(r.code)throw new Error(`Git ${e[0]} failed: ${r.stderr||"unable to read the location"}`);return r.stdout}async transfer(e){let t=await this.exec(["--git-dir",this.repo,...e]);if(t.code){let r=Y(t.stderr||"",this.options.url);throw new d(r.code,r.message,r.remedy,r.diagnostic)}return t.stdout}get name(){return this.options.name??"<name>"}takenRemedy(e){return e===1?`${this.name} holds a different history: to work on it, clone it with kane-cli context clone <descriptor of ${this.name}> <dir>; to share this store, add an empty location`:`kane-cli context pull ${this.name} --rebase`}init(){return this.ready??=(async()=>{if(await ce(this.exec),ke(de(this.repo),{recursive:!0}),!Oe(this.repo)){let e=P(_(de(this.repo),".init-"));try{let t=await this.exec(["init","--bare",e]);if(t.code)throw new Error(`Cannot open Git cache: ${t.stderr}`);try{Re(e,this.repo)}catch(r){if(!["EEXIST","ENOTEMPTY"].includes(r.code??""))throw r}}finally{$(e,{recursive:!0,force:!0})}}if((await this.run(["rev-parse","--is-bare-repository"])).toString().trim()!=="true")throw new Error("The Git cache must be a bare repository");await this.refresh()})()}async refresh(){let t=(await this.transfer(["ls-remote",this.options.url,this.ref])).toString().trim();if(!t){this.tip=null,this.tree=new Map;return}let r=t.split(/\s+/)[0];if(!/^[0-9a-f]{40,64}$/.test(r))throw new Error("Git returned an invalid ref");if(r===this.tip)return;let i=`refs/kane/snapshots/${F(16).toString("hex")}`;await this.transfer(["fetch","--no-tags","--no-write-fetch-head",this.options.url,`${this.ref}:${i}`]);let s=(await this.run(["rev-parse",i])).toString().trim();await this.run(["update-ref",$e,s]),await this.run(["update-ref","-d",i]);let o=await this.readTree(s);this.tip=s,this.tree=o}contextKeys(e){let t=new Map;for(let[r,i]of e)r.startsWith(`${this.prefix}kane-context/`)&&t.set(r,i);return t}async readTree(e){let t=await this.run(["ls-tree","-rz","--full-tree",e]),r=new Map;for(let i of t.toString().split("\0").filter(Boolean)){let s=/^(\d+) (\w+) ([0-9a-f]+)\t([\s\S]+)$/.exec(i);if(!s)throw new Error("Git returned an invalid tree entry");if(s[4].startsWith(`${this.prefix}kane-context/`)&&(s[1]!=="100644"||s[2]!=="blob"))throw new d("SYNC_OBJECT_CORRUPT","Context storage contains a link or non-file object.","Ask the repository owner to restore the original context files.");r.set(s[4],s[3])}return r}key(e){if(!/^[a-zA-Z0-9_~./-]+$/.test(e)||e.split("/").some(t=>!t||t==="."||t===".."||t.toLowerCase()===".git"))throw new Error("Invalid context storage key");return this.prefix+e}async head(e){return await this.init(),this.tree.has(this.key(e))}async get(e){await this.init();let t=this.tree.get(this.key(e));return t?this.run(["cat-file","blob",t]):null}async list(e){return await this.init(),e&&e.replace(/\/$/,"")&&this.key(e.replace(/\/$/,"")),[...this.tree.keys()].filter(t=>t.startsWith(this.prefix+e)).map(t=>t.slice(this.prefix.length)).sort()}async beginTransaction(){await this.init();let e=new Map(this.tree),t=this.tip,r=new Map,i=!1,s=()=>{if(i)throw new Error("Git transaction is closed")},o=async a=>{s();let c=this.key(a),h=r.get(c),u=e.get(c);return h?Buffer.from(h):u?this.run(["cat-file","blob",u]):null};return{get:o,head:async a=>await o(a)!==null,stageIfAbsent:async(a,c)=>{s();let h=this.key(a);if(e.has(h)||r.has(h))return"exists";if(c.length>1e8)throw new d("SYNC_LOCATION_REFUSED_WRITE","A context object is too large for this Git location.","Use an S3 location for this context.");return r.set(h,Buffer.from(c)),"staged"},abort:async()=>{i=!0,r.clear()},commit:async()=>{s();try{if(!r.size)return{created:[]};let a=this.prefix+"kane-context/.gitattributes";e.has(a)||r.set(a,Pe);let c=new Map;for(let[l,m]of r)c.set(l,(await this.run(["hash-object","-w","--no-filters","--stdin"],{input:m})).toString().trim());let h=this.contextKeys(e),u=()=>{this.assertUnchanged(h);for(let[l,m]of this.contextKeys(this.tree))h.set(l,m)},g=!1,w="",S=0;for(let l=0;l<4;l++){u();for(let f of this.tree.keys())if(!(!f.startsWith(this.prefix)||e.has(f)||c.has(f))&&B(f.slice(this.prefix.length))!==null)throw new d("SYNC_BEHIND","the location gained records after this batch was prepared; nothing was published","run kane-cli context pull, then push again");let m=new Map;for(let[f,b]of c){let C=this.tree.get(f);if(C&&C!==b){let R=B(f.slice(this.prefix.length));throw R?new d("SYNC_POSITION_TAKEN",g?`position ${R} on ${this.name} now holds different work; an earlier publication could not be confirmed`:`position ${R} on ${this.name} was published by another writer; this batch was not published`,this.takenRemedy(R)):new d("SYNC_OBJECT_CORRUPT",`existing context object ${f} differs from the intended bytes`,"the object needs a person to look; nothing was published")}C||m.set(f,b)}if(!m.size)return await this.verifyPublication(c),{created:[]};t=this.tip;let x=await this.build(t,m);await this.checkAttributes(x,[...r.keys()]),S++;let E=await this.exec(["--git-dir",this.repo,"push","--porcelain",this.options.url,`${x}:${this.ref}`]),y=N(E.stdout.toString()+`
5
5
  `+E.stderr);w=y.trim();let O=E.code!==0&&/\[rejected\]|\[remote rejected\]/.test(y),p=E.code!==0&&(E.code===124||Ge.test(y));g||=p;try{await this.refresh()}catch{throw new d("SYNC_PUBLICATION_UNKNOWN","we could not confirm whether your context was uploaded; your local work is safe","check the connection and retry; kane-cli compares the published data before writing again")}if(u(),[...c].every(([f,b])=>this.tree.get(f)===b)){await this.verifyPublication(c);let f=E.code===0&&!E.stdout.toString().split(`
@@ -0,0 +1,21 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{e as R}from"./chunk-ZCRZFAOT.js";import{a as O}from"./chunk-RZ4F3BHX.js";var C={ASR_CMD_START:"info",ASR_CMD_END:"info",ASR_AGENT_SPAWN:"info",ASR_WORK_ITEM_START:"info",ASR_WORK_ITEM_END:"info",ASR_PROPOSAL:"info",ASR_VALIDATE_FAILED:"warn",ASR_COMMIT:"info",ASR_SESSION_PAUSED:"info",ASR_SESSION_RESUMED:"info",ASR_SESSION_COMPLETE:"info",ASR_AGENT_EXIT:"warn",ASR_RECONCILE_PLAN:"info",ASR_RECONCILE_ROW_END:"info",ASR_HIGH_RISK_CI:"warn",ASR_INGEST:"info",ASR_EMBED_DEGRADED:"warn",ASR_CONTEXT_CLONED:"warn",ASR_ERROR:"error",ASR_CRASH:"error",ASR_FSCK_REPORT:"warn",ASR_IMPACT_TIMING:"info"},L={ASR_CMD_START:["source_count","resumed","applied_plan"],ASR_CMD_END:["exit_code","duration_ms","credits_total","work_items_total","work_items_failed"],ASR_AGENT_SPAWN:["tier","duration_ms"],ASR_WORK_ITEM_START:["work_item_index","work_item_count","source_kind"],ASR_WORK_ITEM_END:["work_item_index","work_item_count","outcome","duration_ms","error_domain","error_code"],ASR_PROPOSAL:["item_count","turn_index"],ASR_VALIDATE_FAILED:["error_code","count","turn_index"],ASR_COMMIT:["trusted","derived","archived","items","items_dropped","record_seq","phase","duration_ms"],ASR_SESSION_PAUSED:["pending_questions","pending_proposals"],ASR_SESSION_RESUMED:["resume_count","expired_session_id"],ASR_SESSION_COMPLETE:["duration_ms","credits_total"],ASR_AGENT_EXIT:["exit_code","signal"],ASR_RECONCILE_PLAN:["row_count","add_count","modify_count","archive_count"],ASR_RECONCILE_ROW_END:["row_index","kind","outcome","duration_ms"],ASR_HIGH_RISK_CI:["count"],ASR_INGEST:["work_item_index","work_item_count","format","bytes","media_facts"],ASR_EMBED_DEGRADED:["held"],ASR_CONTEXT_CLONED:[],ASR_ERROR:["error_domain","error_code","exit_code","turn_index","request_id"],ASR_CRASH:["error_domain","error_code","error_name"],ASR_FSCK_REPORT:["issue_count","records","pending","codes","issues","issues_truncated"],ASR_IMPACT_TIMING:["read_change_ms","read_project_ms","reads","agent_start_ms","turns","turn_ms_total","turn_ms_max","tool_calls","tool_ms_total","tool_bytes_total","review_ms","print_ms","total_ms","parts","use_cases","tests","use_cases_opened","tests_opened","cases_ms","cases_found","outcome"]},U=[[/^lattice_/,"lattice"],[/^refused_/,"refused"],[/^(auth_expired|401|preflight_auth|AUTH)/i,"auth"],[/^(credit_denied|402|CREDIT)/i,"credit"],[/^(stream_drop|read_timeout|connect_failed|dns|E(CONN|AI_AGAIN|TIMEDOUT)|network)/i,"network"],[/^(frame_parse|post_terminal_data|eof_without_terminal|turn_id_mismatch|binding_mismatch|schema_invalid|frame_too_large|protocol)/i,"protocol"],[/^(provider_error|http_5\d\d|turn_exhausted|adapter_integrity)/i,"provider"],[/^(STALE_BASIS|R\d+|validation|criteria)/i,"validation"],[/^(CHAIN_ERROR|DERIVED_(MISSING|DRIFT)|NODE_FILE_(MISSING|MISMATCH|CORRUPT)|CARDINALITY_VIOLATION|SUPERSEDE_(UNKNOWN_(OLD|NEW|ECID)|CYCLE)|DOUBLE_SUPERSEDE|NAME_UNKNOWN_TARGET|EDGE_CYCLE|UNKNOWN_(LABEL|FIELD|EDGE_TYPE|EDGE_PROP)|BAD_(CHECK|ENUM)|MISSING_(FIELD|SALIENT)|ILLEGAL_EDGE)$/,"graph"],[/^(BLOB_MISSING|SOURCE_UNKNOWN|SESSION_(LOCKED|EXPIRED|MISSING|LOCK_LOST)|NO_STORE|fsck|store)/i,"store"],[/^(usage|EX2|SOURCE_WITH_RESUME|HIGH_RISK_CI|bad_flag|no_tty)/i,"usage"],[/^exit_\d+_unattributed$/,"unattributed"],[/^agent_(crash|exit)/i,"agent_crash"]];function M(e){let t=(e||"unknown").slice(0,64);for(let[n,r]of U)if(n.test(t))return{error_domain:r,error_code:t};return{error_domain:"cli_crash",error_code:t}}import{randomBytes as w}from"crypto";var b=/^(uc|sc|ac|t|gap|sty)-\d+$/,K="0123456789abcdefghijklmnopqrstuvwxyz";function W(e){let t="",n=w(e);for(let r=0;r<e;r++)t+=K[n[r]%36];return t}function se(e=new Date){let t=(r,o)=>String(r).padStart(o,"0");return`as-${`${e.getUTCFullYear()}${t(e.getUTCMonth()+1,2)}${t(e.getUTCDate(),2)}T${t(e.getUTCHours(),2)}${t(e.getUTCMinutes(),2)}`}-${W(8)}`}var v=-1,S=0;function _e(e=new Date){let t=e.getTime(),n=w(10);t===v?S=S+1&4095:(v=t,S=(n[0]<<8|n[1])&4095);let r=Buffer.alloc(16);r.writeUIntBE(t,0,6),r[6]=112|S>>8,r[7]=S&255,r[8]=128|n[2]&63,n.copy(r,9,3,10);let o=r.toString("hex");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}var B=64,k=128,$=/^[A-Za-z0-9._:@\/-]+$/,j={codes:512},H={ASR_FSCK_REPORT:["issues"]},X=20480,V=0;function q(e,t){if(typeof t=="number"&&Number.isFinite(t)||typeof t=="boolean")return t;if(typeof t!="string")return;let n=e.endsWith("_id")||e==="signal"?k:j[e]??B;if(!(t.length===0||t.length>n)&&$.test(t))return t}var P=e=>e!==void 0&&e.length>0&&e.length<=k&&$.test(e);function G(e,t,n={}){let r=L[t],o={};for(let s of r){let i=n[s];if(i==null)continue;if(H[t]?.includes(s)){if(typeof i!="string"||i.length===0)continue;let c=i.replace(/[\u0000-\u001F\u007F]/g,"");if(Buffer.byteLength(c,"utf8")>X)continue;o[s]=c;continue}if(s==="items"){let c=Array.isArray(i)?i.filter(p=>typeof p=="string"):[],u=c.filter(p=>b.test(p));u.length>0&&(o.items=u.slice(0,50).join(","));let E=c.length-u.length;E>0&&(o.items_dropped=E);continue}let a=q(s,i);a!==void 0&&(o[s]=a)}if(typeof n.error_code=="string"&&r.includes("error_code")){let{error_domain:s,error_code:i}=M(n.error_code);o.error_code=i,r.includes("error_domain")&&(o.error_domain=s)}return{level:C[t],event:t,message:t,session_id:e.session_id,operation_id:e.operation_id,...e.parent_operation_id?{parent_operation_id:e.parent_operation_id}:{},...e.agent_session_id?{agent_session_id:e.agent_session_id}:{},context_lineage_id:e.context_lineage_id??null,context_instance_id:e.context_instance_id??null,...P(e.lattice_session_id)?{lattice_session_id:e.lattice_session_id}:{},...P(e.project_id)?{project_id:e.project_id}:{},verb:e.verb,mode:e.mode,component:"kane-cli",seq:V++,event_time:new Date().toISOString(),context:o}}import _ from"fs";import A from"path";var z=500,Y=7,J=512*1024,Z=15*6e4;function I(e){if(e.length!==0)try{let t=R();_.mkdirSync(A.dirname(t),{recursive:!0});let n=e.map(o=>JSON.stringify(o)).join(`
3
+ `)+`
4
+ `;_.appendFileSync(t,n,{flag:"a",mode:384});let r=0;try{r=_.statSync(t).size}catch{r=0}r>J&&re()}catch{}}function Q(e){try{let t=A.dirname(e),n=A.basename(e);for(let r of _.readdirSync(t)){if(!r.startsWith(`${n}.claim-`)&&!r.startsWith(`${n}.prune-`))continue;let o=A.join(t,r),s=Number(r.slice(r.lastIndexOf("-")+1));if(s===process.pid)continue;let i=!1;if(Number.isFinite(s)&&s>0)try{process.kill(s,0),i=!0}catch{i=!1}let a=!i;if(i)try{a=Date.now()-_.statSync(o).mtimeMs>Z}catch{a=!1}if(a)try{let c=_.readFileSync(o,"utf8");c.trim()&&_.appendFileSync(e,c.endsWith(`
5
+ `)?c:c+`
6
+ `,{flag:"a",mode:384}),_.unlinkSync(o)}catch{}}}catch{}}function Se(e){ee(e).catch(()=>{})}function ee(e){return te(async t=>{try{return(await O(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).ok}catch{return!1}})}var F=Promise.resolve();function te(e){let t=F.then(()=>ne(e));return F=t.catch(()=>{}),t}async function ne(e){let t=R();Q(t);let n=`${t}.claim-${process.pid}`,r;try{_.renameSync(t,n),r=_.readFileSync(n,"utf8")}catch{return}let o=[];for(let s of r.split(`
7
+ `))if(s.trim())try{o.push(JSON.parse(s))}catch{}try{(o.length===0?!0:await e(o))?_.unlinkSync(n):(_.appendFileSync(t,r,{flag:"a",mode:384}),_.unlinkSync(n))}catch{try{_.appendFileSync(t,r,{flag:"a",mode:384}),_.unlinkSync(n)}catch{}}}function re(e=z,t=Y){try{let n=R(),r=`${n}.prune-${process.pid}`;_.renameSync(n,r);let s=_.readFileSync(r,"utf8").split(`
8
+ `).filter(u=>u.trim()),i=Date.now()-t*24*3600*1e3,c=s.filter(u=>{try{let E=JSON.parse(u),p=Date.parse(E.event_time??E.timestamp??"");return Number.isNaN(p)||p>=i}catch{return!1}}).slice(-e);c.length>0&&_.appendFileSync(n,c.join(`
9
+ `)+`
10
+ `,{flag:"a",mode:384}),_.unlinkSync(r)}catch{}}var f=null;function Ae(e){f=e}function Ie(){return f}var h=()=>!!process.env.KANE_DEV_MODE,d=[],T=!1,D=null,g=null,N=null,l=null,m=[];function ye(e){if(l=e,e&&m.length>0){let t=m;m=[];for(let n of t)try{e.log(n.level,n.event,n.message,n.context)}catch{}}}function Te(e,t,n,r){if(l){try{l.log(e,t,n,r)}catch{}return}m.push({level:e,event:t,message:n,context:r})}function Ne(){return l}function he(){return T}function De(e,t){d=d.filter(n=>n.name!==e),d.push({name:e,fn:t})}function xe(e){d=d.filter(t=>t.name!==e)}function Oe(e,t){let n=d.find(o=>o.name===e);if(!n)return;d=d.filter(o=>o.name!==e);let r=!0;try{n.fn()}catch(o){r=!1,process.stderr.write(`[exit-manager] cleanup(${e}) failed: ${o instanceof Error?o.message:String(o)}
11
+ `)}t&&r&&h()&&process.stderr.write(`[exit-manager] cleanup(${e}): ${t}
12
+ `)}async function Ce(e=1e3){let t=l;if(!(!t?.stopAndFlushOnce||!t.drainBuffer))try{let n=await t.stopAndFlushOnce(e);if(n!=="sent"&&n!=="empty"){let r=t.drainBuffer();r.length>0&&I(r)}}catch{}}function y(e,t,n=!1,r){if(T){process.exit(D??e);return}if(T=!0,D=e,n&&l)try{l.log("error","CRASH",t);let i=l.drainBuffer?.()??[];i.length>0&&I(i),l.shutdownSync()}catch{}if(n&&f&&e!==130&&e!==143)try{let i=/Uncaught exception:\s*([A-Za-z0-9_$]+)/.exec(t)?.[1]??"crash";I([G(f,"ASR_CRASH",{error_code:"cli_crash",error_name:i})])}catch{}let o=[...d].reverse(),s=[];for(let i of o)try{i.fn(),s.push(i.name)}catch(a){process.stderr.write(`[exit-manager] cleanup(${i.name}) failed: ${a instanceof Error?a.message:String(a)}
13
+ `)}if(d=[],h()&&(process.stderr.write(`[exit-manager] shutdown(${e}): ${t}
14
+ `),s.length>0&&process.stderr.write(`[exit-manager] cleaned up: ${s.join(", ")}
15
+ `)),n){if(N)try{N()}catch{}e===130||e===143||(process.stderr.write(`
16
+ kane-cli crashed: ${t}
17
+ `+(s.length>0?`Resources cleaned up (${s.join(", ")}).
18
+ `:"")),f&&process.stderr.write(`session: ${f.session_id} \u2014 share this id with support
19
+ `),r&&h()?process.stderr.write(`${r}
20
+ `):process.stderr.write(`(re-run with KANE_DEV_MODE=1 for the full stack)
21
+ `)),process.exit(e);return}if(g&&!n){g();return}process.exit(e)}function Le(e){g=e}function Me(){g=null}function ve(e){N=e}var x=!1;function we(){x||(x=!0,process.on("SIGINT",()=>{y(130,"Received SIGINT",!0)}),process.on("SIGTERM",()=>{y(143,"Received SIGTERM",!0)}),process.on("uncaughtException",e=>{y(1,`Uncaught exception: ${e.name}: ${e.message}`,!0,e.stack)}),process.on("unhandledRejection",e=>{y(1,`Unhandled rejection: ${String(e)}`,!0,e instanceof Error?e.stack:void 0)}))}function be(){d=[],T=!1,D=null,g=null,N=null,l=null,m=[],x=!1,f=null}export{se as a,_e as b,C as c,G as d,I as e,Se as f,ee as g,Ae as h,Ie as i,ye as j,Te as k,Ne as l,he as m,De as n,xe as o,Oe as p,Ce as q,y as r,Le as s,Me as t,ve as u,we as v,be as w};