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

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 (421) hide show
  1. package/dist/ChatSurface-FIYDTZSI.js +2 -0
  2. package/dist/{ChromeProfilePicker-M4WXOB5O.js → ChromeProfilePicker-Q6FIGVYU.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-6MJA7DF6.js → CliFeedbackPrompt-2NV2G65E.js} +1 -1
  4. package/dist/{CliUploadProgress-6NLS7XHH.js → CliUploadProgress-JZ5FXODE.js} +1 -1
  5. package/dist/{ConfigView-O4WKZ5PU.js → ConfigView-TZ4YINOE.js} +1 -1
  6. package/dist/EvidenceViewOffer-LKPN5BHX.js +2 -0
  7. package/dist/FolderPicker-H5K74PCH.js +2 -0
  8. package/dist/InfoBox-DNSOAK5L.js +2 -0
  9. package/dist/{LinksBox-DXP66H3H.js → LinksBox-32TZOANP.js} +1 -1
  10. package/dist/{ProfilesView-TWOY5PVC.js → ProfilesView-UC4MPM54.js} +1 -1
  11. package/dist/ProjectPicker-ZJ5RW6XL.js +2 -0
  12. package/dist/SaveSessionPrompt-F327WC7A.js +2 -0
  13. package/dist/SingleShotApp-OMLRYOSI.js +2 -0
  14. package/dist/{SummaryBox-IA2KS6GT.js → SummaryBox-XGFO5X76.js} +1 -1
  15. package/dist/TestMdRunView-ZZ77QTAQ.js +2 -0
  16. package/dist/TestrunEvidenceTable-G7MPF55X.js +2 -0
  17. package/dist/{WhoamiView-SNL75TEF.js → WhoamiView-4XIJXMTU.js} +1 -1
  18. package/dist/{app-download-UI4ABEIX.js → app-download-XEDO3EMV.js} +1 -1
  19. package/dist/{assurance-job-FFSSS4XV.js → assurance-job-MD65GQLC.js} +1 -1
  20. package/dist/{auth-7Z54TMQQ.js → auth-WBIEHHDS.js} +1 -1
  21. package/dist/{binary-THPLXCOD.js → binary-NVYLR36K.js} +1 -1
  22. package/dist/bind-H3ALI2NG.js +2 -0
  23. package/dist/bootstrap-JEVSVPQ2.js +2 -0
  24. package/dist/bridge-2UHJOVLX.js +2 -0
  25. package/dist/{catalog-MYPS2BXY.js → catalog-5UYBWA4W.js} +1 -1
  26. package/dist/catalog-client-VVKV4JKW.js +2 -0
  27. package/dist/{changelog-SU674BVE.js → changelog-FPWJXERY.js} +1 -1
  28. package/dist/chat-committer-ZKEKJA2R.js +2 -0
  29. package/dist/chat-controller-FXRJXUG3.js +2 -0
  30. package/dist/child-JHYENXE7.js +2 -0
  31. package/dist/chunk-226AGYHB.js +87 -0
  32. package/dist/{chunk-MNBGG4H3.js → chunk-23DKB2MT.js} +1 -1
  33. package/dist/{chunk-EECDDDSB.js → chunk-2COXO5LQ.js} +1 -1
  34. package/dist/{chunk-LUR7JFPP.js → chunk-2GEAKFAV.js} +1 -1
  35. package/dist/{chunk-7SY34IIL.js → chunk-2QKBXRLI.js} +1 -1
  36. package/dist/{chunk-AVSMXDTX.js → chunk-2ULYGALF.js} +1 -1
  37. package/dist/{chunk-JNSWKGTB.js → chunk-32HED7X2.js} +1 -1
  38. package/dist/{chunk-GRURFGBP.js → chunk-32MFECUA.js} +1 -1
  39. package/dist/{chunk-MYVKUJGS.js → chunk-35BG2EMW.js} +1 -1
  40. package/dist/{chunk-3GXN6VF6.js → chunk-3KY7HHQU.js} +1 -1
  41. package/dist/{chunk-7NPTL66J.js → chunk-3V4J65GN.js} +1 -1
  42. package/dist/{chunk-457Y5TEC.js → chunk-3YIA3DSL.js} +1 -1
  43. package/dist/{chunk-36N3EHW5.js → chunk-44SIFDNY.js} +1 -1
  44. package/dist/{chunk-MEKPGQAM.js → chunk-45NM23EQ.js} +2 -2
  45. package/dist/{chunk-I2MC6VVX.js → chunk-4C7WVQOD.js} +1 -1
  46. package/dist/{chunk-TU42YZOJ.js → chunk-4HARMERK.js} +1 -1
  47. package/dist/{chunk-ICLUC44J.js → chunk-4HYPMGDF.js} +1 -1
  48. package/dist/{chunk-7KX2BHKG.js → chunk-4KCYNP2K.js} +1 -1
  49. package/dist/{chunk-IJ2AHSWW.js → chunk-4LGQHTXM.js} +1 -1
  50. package/dist/{chunk-ETZMFRD6.js → chunk-4NEPHIAO.js} +1 -1
  51. package/dist/{chunk-3E4ZO73O.js → chunk-54NJJVG5.js} +1 -1
  52. package/dist/{chunk-734ORT6O.js → chunk-5F44KH3R.js} +1 -1
  53. package/dist/{chunk-E6KSRQXL.js → chunk-5F5IVART.js} +1 -1
  54. package/dist/{chunk-EBPRPNSA.js → chunk-5KJU4MG4.js} +1 -1
  55. package/dist/{chunk-JZP3Y4ZM.js → chunk-5MFPQYW3.js} +1 -1
  56. package/dist/{chunk-QENCC2ZS.js → chunk-5WLXAQ4H.js} +1 -1
  57. package/dist/{chunk-RFEON5GN.js → chunk-5XVWT6UK.js} +1 -1
  58. package/dist/{chunk-W4QSZNMB.js → chunk-6CS23F3E.js} +1 -1
  59. package/dist/{chunk-DZOYYWOW.js → chunk-6JUS2ULI.js} +1 -1
  60. package/dist/chunk-6K5BEEAJ.js +2 -0
  61. package/dist/{chunk-4QFTHUJA.js → chunk-6LEHGRRG.js} +1 -1
  62. package/dist/{chunk-LSDJOVWW.js → chunk-6SD4XTYC.js} +1 -1
  63. package/dist/{chunk-TW5AA5A7.js → chunk-6SWHEBPR.js} +1 -1
  64. package/dist/{chunk-URH4FX3H.js → chunk-6YBH3WUW.js} +1 -1
  65. package/dist/{chunk-ZAFJQ3SM.js → chunk-73HMW2WA.js} +1 -1
  66. package/dist/{chunk-NXAJBSIF.js → chunk-75FF7J5R.js} +1 -1
  67. package/dist/{chunk-P3JXJ4BW.js → chunk-7DLDADQR.js} +1 -1
  68. package/dist/{chunk-7NCJMWFX.js → chunk-7LYLJ75Z.js} +1 -1
  69. package/dist/chunk-7O2FIZB7.js +9 -0
  70. package/dist/chunk-7PCLHURF.js +101 -0
  71. package/dist/{chunk-PUVMC4PX.js → chunk-7V34ZMMS.js} +1 -1
  72. package/dist/{chunk-AEWNWAXW.js → chunk-7XJNYLQW.js} +2 -2
  73. package/dist/{chunk-WEIPY3CI.js → chunk-7ZR5CQY3.js} +1 -1
  74. package/dist/{chunk-2DYHAP4E.js → chunk-A474TUCE.js} +1 -1
  75. package/dist/chunk-A4ZV2SHL.js +5 -0
  76. package/dist/chunk-A7IMHUFY.js +27 -0
  77. package/dist/{chunk-XLEGGC4Y.js → chunk-ABMM37L2.js} +1 -1
  78. package/dist/{chunk-NIVFEACM.js → chunk-AUSLHNXQ.js} +1 -1
  79. package/dist/{chunk-YPFQ4UGF.js → chunk-B226SFOV.js} +1 -1
  80. package/dist/{chunk-DJC7NTLA.js → chunk-B57ZRHEQ.js} +1 -1
  81. package/dist/{chunk-CGITGJ3I.js → chunk-BHQIH2FE.js} +1 -1
  82. package/dist/{chunk-FWUPJORV.js → chunk-BJT6PZXL.js} +1 -1
  83. package/dist/{chunk-VX657KIK.js → chunk-C6P6YUCR.js} +1 -1
  84. package/dist/chunk-CB344EDO.js +2 -0
  85. package/dist/chunk-CCOD4GQJ.js +2 -0
  86. package/dist/{chunk-ZFM77AQU.js → chunk-CQDCNP7V.js} +1 -1
  87. package/dist/{chunk-VUFIL5VR.js → chunk-D4QXYAYA.js} +2 -2
  88. package/dist/{chunk-Y7E5L42F.js → chunk-DLP5S3TO.js} +1 -1
  89. package/dist/{chunk-35ECWCCK.js → chunk-DXIQVBMI.js} +1 -1
  90. package/dist/chunk-DXLZCJH5.js +7 -0
  91. package/dist/{chunk-OJ33Q6DU.js → chunk-E4GIGM5V.js} +1 -1
  92. package/dist/{chunk-I4WXALQR.js → chunk-EAWU2TOG.js} +1 -1
  93. package/dist/{chunk-ACMBMZDQ.js → chunk-EEOAU43D.js} +1 -1
  94. package/dist/{chunk-MYZHOBS4.js → chunk-EHB55V23.js} +1 -1
  95. package/dist/{chunk-UYDHOHSZ.js → chunk-ENRFXGID.js} +1 -1
  96. package/dist/{chunk-RTVHJ23A.js → chunk-ET5EK2CM.js} +1 -1
  97. package/dist/{chunk-EF47KRUK.js → chunk-EZMRWXRT.js} +1 -1
  98. package/dist/chunk-FAMQ4DHU.js +2 -0
  99. package/dist/{chunk-C2RUDJ46.js → chunk-FI2DVNRT.js} +1 -1
  100. package/dist/{chunk-AUJSC7PU.js → chunk-FNUGDPTS.js} +1 -1
  101. package/dist/{chunk-VLDCHFXF.js → chunk-FOLUB336.js} +1 -1
  102. package/dist/{chunk-NZ6AV2TA.js → chunk-FYPIF3BE.js} +1 -1
  103. package/dist/{chunk-HHW6MRU3.js → chunk-G4K3TP2I.js} +1 -1
  104. package/dist/{chunk-P2ZQDQDB.js → chunk-GAKBHNC4.js} +1 -1
  105. package/dist/{chunk-DPGOAFKF.js → chunk-GBQ4K25P.js} +1 -1
  106. package/dist/{chunk-O3HHTKZ5.js → chunk-GEZVC4S3.js} +1 -1
  107. package/dist/chunk-GJ7MO2FW.js +9 -0
  108. package/dist/{chunk-EZN7CF45.js → chunk-GJXO6FF7.js} +1 -1
  109. package/dist/{chunk-QDFY5GGO.js → chunk-GLM5UGTF.js} +1 -1
  110. package/dist/{chunk-HK62JVQM.js → chunk-GQARXS6F.js} +1 -1
  111. package/dist/{chunk-I4RVVBG3.js → chunk-GT3JDX5H.js} +1 -1
  112. package/dist/{chunk-YLXWAY7D.js → chunk-GZQAETB2.js} +1 -1
  113. package/dist/{chunk-7HMSMAUG.js → chunk-H4TIVILC.js} +5 -5
  114. package/dist/{chunk-VXGN3IV7.js → chunk-HG2ILWCE.js} +1 -1
  115. package/dist/{chunk-M43WH5DQ.js → chunk-HHOVANJ7.js} +1 -1
  116. package/dist/{chunk-CM4CHYSN.js → chunk-HM6LZ2KM.js} +1 -1
  117. package/dist/{chunk-QDXKEOKI.js → chunk-HNF3PWF3.js} +6 -6
  118. package/dist/{chunk-R7KXAISS.js → chunk-HVOXMCKE.js} +1 -1
  119. package/dist/{chunk-D7U2M26S.js → chunk-HWPWCCEV.js} +1 -1
  120. package/dist/{chunk-XRNQSXOM.js → chunk-HX5OLRKU.js} +2 -2
  121. package/dist/{chunk-4I7YN6YY.js → chunk-HYJVYYAZ.js} +2 -2
  122. package/dist/{chunk-CUXY6KQ2.js → chunk-I52NWH4U.js} +1 -1
  123. package/dist/{chunk-IGEAET7M.js → chunk-IB5WG5YY.js} +1 -1
  124. package/dist/{chunk-LAOTVZHV.js → chunk-IH73ZCBB.js} +1 -1
  125. package/dist/{chunk-TU7TVFBK.js → chunk-IT5JVCZN.js} +1 -1
  126. package/dist/{chunk-54XA5MZH.js → chunk-IZ66FKPC.js} +1 -1
  127. package/dist/{chunk-44B6THYK.js → chunk-JNPFEBUR.js} +1 -1
  128. package/dist/{chunk-RX6776AI.js → chunk-JTNEF5ZP.js} +1 -1
  129. package/dist/{chunk-QBYENBMB.js → chunk-JUVY6PHY.js} +1 -1
  130. package/dist/{chunk-5AKJPYUW.js → chunk-K4K2BGQC.js} +3 -3
  131. package/dist/{chunk-HJMCXSUJ.js → chunk-K75WIRI5.js} +1 -1
  132. package/dist/{chunk-FSYOTRMC.js → chunk-KKLCXRW6.js} +1 -1
  133. package/dist/{chunk-7YT4TTKL.js → chunk-KN7GZWKK.js} +1 -1
  134. package/dist/{chunk-ZTHYAHDN.js → chunk-L3BUPFAQ.js} +4 -4
  135. package/dist/{chunk-7XBNMOH4.js → chunk-LLQWEGXD.js} +1 -1
  136. package/dist/chunk-LTPOMMAB.js +2 -0
  137. package/dist/{chunk-CCP4X75B.js → chunk-LWCP4GLY.js} +1 -1
  138. package/dist/chunk-LXCTV75T.js +12 -0
  139. package/dist/{chunk-RDP7GWSY.js → chunk-LZGAFKYH.js} +1 -1
  140. package/dist/{chunk-3QICDXY5.js → chunk-LZPYIFHZ.js} +1 -1
  141. package/dist/{chunk-3OQW2GTA.js → chunk-M3TFOFUQ.js} +1 -1
  142. package/dist/{chunk-V7USCQWO.js → chunk-M7Y5GGVJ.js} +1 -1
  143. package/dist/{chunk-SMTBOSEJ.js → chunk-MEMXFTLD.js} +1 -1
  144. package/dist/{chunk-D756UWY2.js → chunk-MINDIQET.js} +1 -1
  145. package/dist/{chunk-ZTRRFG52.js → chunk-MP6NCJFE.js} +1 -1
  146. package/dist/{chunk-GXKY5A46.js → chunk-MSYRAPDK.js} +1 -1
  147. package/dist/{chunk-HJLMH7ZM.js → chunk-MUX2A37P.js} +1 -1
  148. package/dist/{chunk-YHFZFV3A.js → chunk-NCP54AIQ.js} +9 -9
  149. package/dist/{chunk-ZU4W2QGM.js → chunk-NVD2MXHQ.js} +1 -1
  150. package/dist/{chunk-FWDUVFS6.js → chunk-O2Y46A3G.js} +17 -17
  151. package/dist/{chunk-XZGEN4NU.js → chunk-O3TXAMFW.js} +1 -1
  152. package/dist/{chunk-YGRULEZY.js → chunk-O5KTMDTH.js} +1 -1
  153. package/dist/{chunk-PAWQ4AKN.js → chunk-OK6NLITG.js} +1 -1
  154. package/dist/{chunk-7AET4JKQ.js → chunk-OKA6FPJM.js} +1 -1
  155. package/dist/{chunk-3YTCKCBG.js → chunk-OVNTCBNS.js} +1 -1
  156. package/dist/{chunk-YQ5C6UDG.js → chunk-P4VFC6HO.js} +1 -1
  157. package/dist/{chunk-LQQNPMOD.js → chunk-PC22QRIY.js} +1 -1
  158. package/dist/{chunk-XQMWHPZI.js → chunk-PEUIHME2.js} +1 -1
  159. package/dist/{chunk-UEE3RZN4.js → chunk-PI7OXS62.js} +1 -1
  160. package/dist/{chunk-D7TKE7LK.js → chunk-POA336CU.js} +1 -1
  161. package/dist/{chunk-WZXPF3BI.js → chunk-PR5EGLEI.js} +1 -1
  162. package/dist/{chunk-YIKF4ERQ.js → chunk-PRBWZXFA.js} +2 -2
  163. package/dist/{chunk-XZYA7DNH.js → chunk-PVN64537.js} +1 -1
  164. package/dist/{chunk-VSVWNRI2.js → chunk-PWNYTIVA.js} +1 -1
  165. package/dist/chunk-Q4JV4U65.js +161 -0
  166. package/dist/{chunk-LUZBGTYB.js → chunk-Q5AKIQIE.js} +1 -1
  167. package/dist/{chunk-6EB5VRAN.js → chunk-QB77LRF4.js} +1 -1
  168. package/dist/{chunk-GQRU3B54.js → chunk-QUNIY6NN.js} +1 -1
  169. package/dist/{chunk-KODJVOCN.js → chunk-QVMXL675.js} +1 -1
  170. package/dist/{chunk-LCSJ7GOG.js → chunk-R6TFRAMZ.js} +1 -1
  171. package/dist/{chunk-4YW767UV.js → chunk-RAVAJZV2.js} +7 -7
  172. package/dist/{chunk-DDZLCAEO.js → chunk-RDAIOJCR.js} +1 -1
  173. package/dist/{chunk-RPRXRKKR.js → chunk-RQKMSNEU.js} +1 -1
  174. package/dist/{chunk-ECPFI75W.js → chunk-RRKYHUOD.js} +1 -1
  175. package/dist/{chunk-3RJHXOZH.js → chunk-S7XCOBYD.js} +1 -1
  176. package/dist/{chunk-Q3C6NDGI.js → chunk-SALZ6WSF.js} +1 -1
  177. package/dist/{chunk-ZFMRQ57Y.js → chunk-SIHX5FW5.js} +1 -1
  178. package/dist/{chunk-FIP5L6LV.js → chunk-SSOUYKVG.js} +1 -1
  179. package/dist/{chunk-TNORODUF.js → chunk-SVIIUKJ2.js} +1 -1
  180. package/dist/{chunk-7RWP4Y3H.js → chunk-T77LTLAD.js} +1 -1
  181. package/dist/{chunk-NLZZLANH.js → chunk-TAY7J5VS.js} +1 -1
  182. package/dist/chunk-TD6GCEIK.js +2 -0
  183. package/dist/{chunk-LKQFG4RW.js → chunk-TM6VLC6V.js} +1 -1
  184. package/dist/{chunk-YAW6JW6D.js → chunk-TMH4TPMB.js} +1 -1
  185. package/dist/{chunk-OFSDB7B4.js → chunk-TU2KPOW2.js} +2 -2
  186. package/dist/{chunk-3BSYOCSW.js → chunk-U2VYTVKV.js} +1 -1
  187. package/dist/{chunk-LIGTP3A3.js → chunk-UCVP7ZY4.js} +1 -1
  188. package/dist/{chunk-RHGW7B5Q.js → chunk-UICJ2KLJ.js} +1 -1
  189. package/dist/chunk-UJLULWSR.js +21 -0
  190. package/dist/{chunk-OCDBTAYS.js → chunk-UMNCM4RJ.js} +2 -2
  191. package/dist/{chunk-WOSANGV6.js → chunk-UWPG5MWM.js} +1 -1
  192. package/dist/{chunk-W6HZF56M.js → chunk-V3OZJO7Y.js} +1 -1
  193. package/dist/{chunk-3F5FMH76.js → chunk-VE4HLIGA.js} +1 -1
  194. package/dist/{chunk-RF37IJNN.js → chunk-W2HRX3DR.js} +1 -1
  195. package/dist/{chunk-NXRF7FFS.js → chunk-W54BX6HC.js} +1 -1
  196. package/dist/{chunk-IZ65ZPWY.js → chunk-W5HFUBXD.js} +1 -1
  197. package/dist/{chunk-HAW5WEKT.js → chunk-WEJR2V7R.js} +1 -1
  198. package/dist/{chunk-F5NHG7VB.js → chunk-X3A4QPA3.js} +1 -1
  199. package/dist/{chunk-AVI5H4UM.js → chunk-X52YIWGG.js} +1 -1
  200. package/dist/{chunk-72RC7JSA.js → chunk-X6FCXBXU.js} +1 -1
  201. package/dist/{chunk-PZA3BSOE.js → chunk-X7S7IGCV.js} +1 -1
  202. package/dist/{chunk-6DZX5HLZ.js → chunk-XCUF5AVM.js} +1 -1
  203. package/dist/{chunk-F22K3RRX.js → chunk-XHFU5TGS.js} +1 -1
  204. package/dist/chunk-XNXJXGVB.js +4 -0
  205. package/dist/{chunk-C62QWG4B.js → chunk-XZ6J3Y2W.js} +1 -1
  206. package/dist/{chunk-JGRXMTME.js → chunk-YDB72F4K.js} +1 -1
  207. package/dist/{chunk-7DFBOVUB.js → chunk-YJAQZMJT.js} +1 -1
  208. package/dist/chunk-YO6SNXBJ.js +2 -0
  209. package/dist/{chunk-AZLNLHUA.js → chunk-Z24SD2EJ.js} +1 -1
  210. package/dist/{chunk-HQ2E2XCU.js → chunk-Z36KVIRR.js} +1 -1
  211. package/dist/{chunk-WAOUE7MP.js → chunk-Z6SI7YNV.js} +1 -1
  212. package/dist/{chunk-6NFOH4AC.js → chunk-ZAQGIC33.js} +1 -1
  213. package/dist/{chunk-6UVIY56J.js → chunk-ZCL7XIVS.js} +1 -1
  214. package/dist/{chunk-UUJIGOEO.js → chunk-ZDCXWEQG.js} +1 -1
  215. package/dist/{chunk-SGPAM5DZ.js → chunk-ZDQYGLCZ.js} +1 -1
  216. package/dist/{chunk-42PALMW2.js → chunk-ZHAMVLQZ.js} +1 -1
  217. package/dist/{chunk-W7FLXW6Q.js → chunk-ZMWTRXFH.js} +1 -1
  218. package/dist/{chunk-KXHJMAZU.js → chunk-ZO3ZAMUU.js} +2 -2
  219. package/dist/{chunk-L5DALV5N.js → chunk-ZZZGTDYE.js} +1 -1
  220. package/dist/commands-R5AYK6XM.js +2 -0
  221. package/dist/{committer-JGY66PFM.js → committer-UO3B3S5Y.js} +1 -1
  222. package/dist/{config-754B73XK.js → config-YMHI3H3Y.js} +1 -1
  223. package/dist/cover-cmd-DVQIGFDY.js +2 -0
  224. package/dist/{credentials-F7DYLVWY.js → credentials-BCR73VGS.js} +1 -1
  225. package/dist/{deps-bundle-PW3WEQJ7.js → deps-bundle-6WLX44OA.js} +1 -1
  226. package/dist/{deps-resolve-SQYVN76L.js → deps-resolve-DSAKPZ3T.js} +1 -1
  227. package/dist/{design-chat-F3OEZPNJ.js → design-chat-YUI2JPO6.js} +1 -1
  228. package/dist/design-committer-7YIPFKMO.js +2 -0
  229. package/dist/design-headless-KIP6R7UV.js +2 -0
  230. package/dist/{design-remote-2BEGCVCX.js → design-remote-XMSHDDUX.js} +2 -2
  231. package/dist/device-env-K7J5NN66.js +2 -0
  232. package/dist/dispatch-BV6XMCN3.js +2 -0
  233. package/dist/{doctor-XY26Z35T.js → doctor-PGTNOMSP.js} +1 -1
  234. package/dist/{docx-convert-6IZO5P5K.js → docx-convert-DO5AQYD3.js} +1 -1
  235. package/dist/{dossier-NROC2MCY.js → dossier-5XKNAK6Q.js} +1 -1
  236. package/dist/evidence-RO3RDZXO.js +2 -0
  237. package/dist/evidence-presentation-LSFOZGLH.js +2 -0
  238. package/dist/evolve-cmd-U2ALVGMT.js +2 -0
  239. package/dist/evolve-remote-K2MCCVMM.js +2 -0
  240. package/dist/{exit-manager-EDHCETUN.js → exit-manager-EGWAZHCR.js} +1 -1
  241. package/dist/{explain-cmd-VYAANFFZ.js → explain-cmd-KNDORU2D.js} +1 -1
  242. package/dist/{explain-cmd-OP5I5W3O.js → explain-cmd-UWK5YVXG.js} +1 -1
  243. package/dist/explore-S2BGQUIF.js +2 -0
  244. package/dist/{explore-context-tty-RZ7D2TBV.js → explore-context-tty-WJHUSP3A.js} +1 -1
  245. package/dist/{explore-entry-EKXJ67BD.js → explore-entry-3EX2T3NS.js} +4 -4
  246. package/dist/{explore-live-2YVRAQZO.js → explore-live-TRY5A2ME.js} +1 -1
  247. package/dist/{explore-run-tty-D47FGPX7.js → explore-run-tty-ZV5XFKZA.js} +2 -2
  248. package/dist/{extract-bind-W2NET364.js → extract-bind-TXUBMK3T.js} +3 -3
  249. package/dist/extract-chat-VPYDGQKO.js +2 -0
  250. package/dist/{extract-cmd-FTFLETOP.js → extract-cmd-YUOYMVF5.js} +2 -2
  251. package/dist/extract-headless-UWTAPOET.js +2 -0
  252. package/dist/{feeder-NY45UFJK.js → feeder-NGWIPZ26.js} +1 -1
  253. package/dist/folder-flags-WV7UV3JG.js +2 -0
  254. package/dist/gaps-cmd-PFV3FZCM.js +3 -0
  255. package/dist/gate-7ALXLCNB.js +2 -0
  256. package/dist/gate-NB5CJMTN.js +2 -0
  257. package/dist/{generate-headless-RURIEKVS.js → generate-headless-KMBBZTLS.js} +2 -2
  258. package/dist/hold-passthrough-JGHWMYDM.js +2 -0
  259. package/dist/impact-cmd-PW33L5RF.js +11 -0
  260. package/dist/index.js +4150 -180
  261. package/dist/ingest-ZHHHBUXR.js +2 -0
  262. package/dist/{ingest-cmd-4G2AK4Y2.js → ingest-cmd-MXYILQLV.js} +3 -3
  263. package/dist/ingest-remote-2EEJP6ML.js +2 -0
  264. package/dist/install-7J34AYB6.js +2 -0
  265. package/dist/{interactive-bind-SI2ZS55Q.js → interactive-bind-FDWJUTI6.js} +4 -4
  266. package/dist/{interactive-remote-J56EWJGA.js → interactive-remote-O2Q2FNOH.js} +2 -2
  267. package/dist/lane-CNGO7LH5.js +2 -0
  268. package/dist/lattice-auth-TXNDLHM6.js +2 -0
  269. package/dist/{lifecycle-cmd-HJ37LTXE.js → lifecycle-cmd-GFHDBRXX.js} +1 -1
  270. package/dist/{list-cmd-6XL2FYLQ.js → list-cmd-RR75PMPE.js} +1 -1
  271. package/dist/list-commands-3QGZWJ5P.js +2 -0
  272. package/dist/{list-remote-LXPQNXYN.js → list-remote-AA3VSWOI.js} +1 -1
  273. package/dist/{locks-cmd-JJ2QNTNY.js → locks-cmd-AZKCSGHI.js} +1 -1
  274. package/dist/{logical-ids-RXAQJZ3T.js → logical-ids-74PLU3VR.js} +1 -1
  275. package/dist/login-flow-ZQ6UFTS2.js +2 -0
  276. package/dist/{maintenance-cmd-BXXHP36K.js → maintenance-cmd-OHGVARQ2.js} +1 -1
  277. package/dist/{mobile-prompts-CECJ5UY2.js → mobile-prompts-FZRKLLTN.js} +1 -1
  278. package/dist/{objective-variable-gate-3Z7DNVVC.js → objective-variable-gate-V5HHFOUS.js} +1 -1
  279. package/dist/{onboarding-PDVYMTY5.js → onboarding-NXGMV3VG.js} +1 -1
  280. package/dist/open-provider-XDJKT3W3.js +2 -0
  281. package/dist/pdf-convert-YB6PJFMI.js +2 -0
  282. package/dist/persist-recorded-session-INFN4JZT.js +3 -0
  283. package/dist/phase-seed-ZZSJME7M.js +2 -0
  284. package/dist/pipeline-MVZRI6YZ.js +2 -0
  285. package/dist/policy-commands-3YJ6YCDN.js +8 -0
  286. package/dist/prepare-target-DII5WZCX.js +2 -0
  287. package/dist/{pull-cmd-UPFQYUND.js → pull-cmd-XZN53XFZ.js} +1 -1
  288. package/dist/pull-route-R33BVADE.js +2 -0
  289. package/dist/readmodel-TRV4E3MW.js +2 -0
  290. package/dist/real-device-run-DGENHGUV.js +2 -0
  291. package/dist/{reconcile-cmd-JBH365JL.js → reconcile-cmd-KFPRCCJB.js} +4 -4
  292. package/dist/reconcile-deps-UDQBWSLE.js +2 -0
  293. package/dist/{reconcile-remote-BCX6SWFC.js → reconcile-remote-6WISFGRG.js} +2 -2
  294. package/dist/{recording-banner-YKBAL6UB.js → recording-banner-XOX2CDCF.js} +1 -1
  295. package/dist/registry-NV3EMDMK.js +2 -0
  296. package/dist/remote-entry-BCTFT643.js +2 -0
  297. package/dist/remote-mode-4HN27MD4.js +4 -0
  298. package/dist/{remote-words-YVB66R3F.js → remote-words-LFDYKIZ7.js} +1 -1
  299. package/dist/{require-project-folder-MLMEQJYP.js → require-project-folder-ZK4JJCDB.js} +1 -1
  300. package/dist/{resolve-run-intent-PC7TQZUL.js → resolve-run-intent-LYLVNNDZ.js} +1 -1
  301. package/dist/{resolver-EID34LQE.js → resolver-RMHGGYRP.js} +1 -1
  302. package/dist/revert-QKHPCRT6.js +2 -0
  303. package/dist/{review-cmd-EUHFLFMY.js → review-cmd-UGF2FC5Y.js} +1 -1
  304. package/dist/run-CSYGVV3D.js +2 -0
  305. package/dist/run-YUHHD54J.js +2 -0
  306. package/dist/{run-channel-63SVP5OI.js → run-channel-IIIYXOIW.js} +1 -1
  307. package/dist/run-remote-BGKQDAOA.js +2 -0
  308. package/dist/{run-startup-gate-YO66G6LS.js → run-startup-gate-4XE73OON.js} +1 -1
  309. package/dist/run-test-md-G6U3RU2Q.js +19 -0
  310. package/dist/session-worker.js +2 -2
  311. package/dist/{sessions-CFV7FOIT.js → sessions-NH2EG7BP.js} +1 -1
  312. package/dist/{sessions-cmd-S7WZBUCN.js → sessions-cmd-CABAX7BO.js} +2 -2
  313. package/dist/{sessions-remote-IWHWIQ2T.js → sessions-remote-Y4FTZL7Y.js} +1 -1
  314. package/dist/{skill-installer-MAVQY6GW.js → skill-installer-FS2AV7GX.js} +1 -1
  315. package/dist/spawner-MQ4XEHIX.js +2 -0
  316. package/dist/{store-MSA7KASS.js → store-PLKJZTGC.js} +1 -1
  317. package/dist/store-choice-UAB6Z4AL.js +2 -0
  318. package/dist/store-guard-DUN2X3SR.js +2 -0
  319. package/dist/{store-site-KA2DNBGY.js → store-site-K5NHLI7D.js} +1 -1
  320. package/dist/stream-warnings-GM7YEOVG.js +2 -0
  321. package/dist/sync-cmd-AGTOGPYM.js +2 -0
  322. package/dist/{sync-setup-RBRDUV7Q.js → sync-setup-4KIY3PDO.js} +1 -1
  323. package/dist/tcg-generate-CUY4AZ2V.js +2 -0
  324. package/dist/{test-definition-VRI4YIYL.js → test-definition-53XNBEDE.js} +1 -1
  325. package/dist/testmd-actions-UD6PAWUX.js +2 -0
  326. package/dist/{testmd-sync-UPAA5UMD.js → testmd-sync-EEJ7GPLR.js} +1 -1
  327. package/dist/tms-client-XWCR7O7J.js +2 -0
  328. package/dist/token-refresh-K6PVBBFE.js +2 -0
  329. package/dist/{trust-gate-AT2XBWN4.js → trust-gate-674C2NZS.js} +1 -1
  330. package/dist/{turn-preflight-LHYLRL7G.js → turn-preflight-R4PU6NYY.js} +1 -1
  331. package/dist/{use-case-ref-NE4X4MZN.js → use-case-ref-44BPIP4N.js} +1 -1
  332. package/dist/{validate-basic-M5JHHNZA.js → validate-basic-3JZRZL45.js} +1 -1
  333. package/dist/{variable-receipt-BXSZO36E.js → variable-receipt-7PRKDTRJ.js} +1 -1
  334. package/dist/verdicts-PVB7TV5S.js +2 -0
  335. package/dist/{version-check-Q737BE65.js → version-check-IY3YSQIP.js} +1 -1
  336. package/dist/{view-cmd-XSNL5DGI.js → view-cmd-WUIGTRFX.js} +1 -1
  337. package/dist/{walk-session-SHGYLFRB.js → walk-session-EH7227WR.js} +1 -1
  338. package/dist/with-telemetry-7JMZUBUZ.js +2 -0
  339. package/package.json +17 -17
  340. package/dist/ChatSurface-6NZGMNHL.js +0 -2
  341. package/dist/EvidenceViewOffer-WIEWCZUP.js +0 -2
  342. package/dist/FolderPicker-AF7ZMV3M.js +0 -2
  343. package/dist/InfoBox-D7GGZJU4.js +0 -2
  344. package/dist/ProjectPicker-OBYHJJLU.js +0 -2
  345. package/dist/SaveSessionPrompt-7XSHS4NL.js +0 -2
  346. package/dist/SingleShotApp-XQUDR36R.js +0 -2
  347. package/dist/TestMdRunView-LS2QUFWR.js +0 -2
  348. package/dist/TestrunEvidenceTable-HNDVJDIF.js +0 -2
  349. package/dist/bind-4XWK3DG2.js +0 -2
  350. package/dist/bootstrap-6ACT4ALI.js +0 -2
  351. package/dist/bridge-T6QMYKED.js +0 -2
  352. package/dist/chat-committer-ZCSRJEUB.js +0 -2
  353. package/dist/chat-controller-XINCDH6Z.js +0 -2
  354. package/dist/child-G2GCW73X.js +0 -2
  355. package/dist/chunk-34R7BNZ2.js +0 -2
  356. package/dist/chunk-65VANXOF.js +0 -147
  357. package/dist/chunk-C6HI6Y3S.js +0 -2
  358. package/dist/chunk-D36V5OX6.js +0 -2
  359. package/dist/chunk-HCJ2N3XB.js +0 -12
  360. package/dist/chunk-IUQOG7Z5.js +0 -5
  361. package/dist/chunk-KF4DKXSS.js +0 -2
  362. package/dist/chunk-NC7D7GOM.js +0 -21
  363. package/dist/chunk-OGFU4YY4.js +0 -2
  364. package/dist/chunk-R4JUKTDO.js +0 -2
  365. package/dist/chunk-VZ4A6WMK.js +0 -97
  366. package/dist/chunk-W54OT2FU.js +0 -9
  367. package/dist/chunk-W72ACCFL.js +0 -27
  368. package/dist/chunk-WXJCJL5L.js +0 -7
  369. package/dist/cover-cmd-NBNZCR6C.js +0 -2
  370. package/dist/design-committer-TRYP3LOZ.js +0 -2
  371. package/dist/design-headless-OTHYOX3E.js +0 -2
  372. package/dist/device-env-CHFRRV6W.js +0 -2
  373. package/dist/dispatch-DVQ3H7EJ.js +0 -2
  374. package/dist/evidence-P6FFKC7B.js +0 -2
  375. package/dist/evidence-presentation-YYTIDCBS.js +0 -2
  376. package/dist/evolve-cmd-WWOB3QJR.js +0 -2
  377. package/dist/evolve-remote-WLVY3QID.js +0 -2
  378. package/dist/explore-K5YBGHK6.js +0 -2
  379. package/dist/extract-chat-M65NWGUK.js +0 -2
  380. package/dist/extract-headless-G6W6JQ27.js +0 -2
  381. package/dist/folder-flags-KKIH654K.js +0 -2
  382. package/dist/gaps-cmd-OIDDLRYL.js +0 -3
  383. package/dist/gate-7AKRPRMK.js +0 -2
  384. package/dist/gate-WISOUTHQ.js +0 -2
  385. package/dist/hold-passthrough-IOWPVB4W.js +0 -2
  386. package/dist/ingest-PDGS5ZTL.js +0 -2
  387. package/dist/ingest-remote-SSLUHQVG.js +0 -2
  388. package/dist/install-ZVBHPXGP.js +0 -2
  389. package/dist/lane-AQYRIW24.js +0 -2
  390. package/dist/lattice-auth-6FEVSR7E.js +0 -2
  391. package/dist/list-commands-5DCCKU3L.js +0 -2
  392. package/dist/login-flow-WEK3E476.js +0 -2
  393. package/dist/open-provider-OZAG6WZS.js +0 -2
  394. package/dist/pdf-convert-447ACUB3.js +0 -2
  395. package/dist/persist-recorded-session-A3ID7JFA.js +0 -3
  396. package/dist/phase-seed-LCJ4WSYV.js +0 -2
  397. package/dist/pipeline-GX3LKPI5.js +0 -2
  398. package/dist/prepare-target-FMT6QFHZ.js +0 -2
  399. package/dist/pull-route-FWBXJMR7.js +0 -2
  400. package/dist/readmodel-INMP6MNW.js +0 -2
  401. package/dist/real-device-run-X7JJWOIK.js +0 -2
  402. package/dist/reconcile-deps-TWJ3FTSU.js +0 -2
  403. package/dist/registry-VQC757MJ.js +0 -2
  404. package/dist/remote-entry-X6JMPC2K.js +0 -2
  405. package/dist/remote-mode-FDPA7EWG.js +0 -4
  406. package/dist/revert-FHOBLZWF.js +0 -2
  407. package/dist/run-5RQUCNYP.js +0 -2
  408. package/dist/run-PC5YO4AS.js +0 -2
  409. package/dist/run-remote-SJCRTL7O.js +0 -2
  410. package/dist/run-test-md-BLNBK4MH.js +0 -17
  411. package/dist/spawner-C7NLLM4F.js +0 -2
  412. package/dist/store-choice-3OJCV26J.js +0 -2
  413. package/dist/store-guard-OOSDLMEC.js +0 -2
  414. package/dist/stream-warnings-GEQKKJU7.js +0 -2
  415. package/dist/sync-cmd-RDFDMVKQ.js +0 -2
  416. package/dist/tcg-generate-KIECTZ2C.js +0 -2
  417. package/dist/testmd-actions-CMAG6HWI.js +0 -2
  418. package/dist/tms-client-NXAB6VJD.js +0 -2
  419. package/dist/token-refresh-KP3AYMYK.js +0 -2
  420. package/dist/verdicts-XK3GAUX3.js +0 -2
  421. package/dist/with-telemetry-PM2HVN2B.js +0 -2
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{M as r,vb as e}from"./chunk-UEE3RZN4.js";function p(t,o){return{store:o,dir:t,graph:()=>e(t)}}function a(t){return{store:t,dir:null,graph:()=>r(t)}}export{p as a,a as b};
2
+ import{M as r,vb as e}from"./chunk-PI7OXS62.js";function p(t,o){return{store:o,dir:t,graph:()=>e(t)}}function a(t){return{store:t,dir:null,graph:()=>r(t)}}export{p as a,a as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{ta as u}from"./chunk-UEE3RZN4.js";import{m as c}from"./chunk-4I7YN6YY.js";function a(e,r){let n=u(e.superseded,i=>e.nodeLabel.get(i)),t=r,o=new Set;for(;n.has(t)&&!o.has(t);)o.add(t),t=n.get(t);return t}function d(e,r){let n=e.resolve(r);if(n===null)return null;let t=e.designGenerationOf.get(a(e,n.cid));if(t===void 0)return null;let o=e.tipOf(n.cid),i=!e.superseded.has(o);return{gen:t.gen,live:i,minted_at_seq:t.seq}}function _(e,r,n){let t=e.resolve(r);if(t===null)return{error:{code:"UNKNOWN_REF",detail:`'${r}' names no use-case in this context`}};let o=a(e,t.cid),i=e.designGenerationOf.get(o);if(i===void 0)return{uc_root:o,next_gen:1,expected_prev_gen:null,...n.because?{because:n.because}:{}};let s=d(e,r);return s!==null&&s.live&&!n.force?{error:{code:"GENERATION_LIVE",detail:c().text("GENERATION_LIVE",{use_case:r,gen:i.gen})}}:s!==null&&s.live&&n.force&&!n.because?{error:{code:"MISSING_BECAUSE",detail:`superseding the live generation of ${r} requires --because <reason>`}}:{uc_root:o,next_gen:i.gen+1,expected_prev_gen:i.gen,...n.because?{because:n.because}:{}}}function f(e,r){let n=e.designGenerationOf.get(r.uc_root)?.gen??null;return n!==r.expected_prev_gen?{code:"GENERATION_MOVED",detail:`design generation of ${r.uc_root.slice(0,12)} moved (expected ${String(r.expected_prev_gen)}, found ${String(n)}) \u2014 another session finalized; re-open and re-ground`}:null}function p(e,r,n){return{uc_root:e.uc_root,uc_cid:r,generation:e.next_gen,supersedes_generation:e.expected_prev_gen,...e.because?{because:e.because}:{},by:n}}export{a,d as b,_ as c,f as d,p as e};
2
+ import{ta as u}from"./chunk-PI7OXS62.js";import{o as c}from"./chunk-HYJVYYAZ.js";function a(e,r){let n=u(e.superseded,i=>e.nodeLabel.get(i)),t=r,o=new Set;for(;n.has(t)&&!o.has(t);)o.add(t),t=n.get(t);return t}function d(e,r){let n=e.resolve(r);if(n===null)return null;let t=e.designGenerationOf.get(a(e,n.cid));if(t===void 0)return null;let o=e.tipOf(n.cid),i=!e.superseded.has(o);return{gen:t.gen,live:i,minted_at_seq:t.seq}}function _(e,r,n){let t=e.resolve(r);if(t===null)return{error:{code:"UNKNOWN_REF",detail:`'${r}' names no use-case in this context`}};let o=a(e,t.cid),i=e.designGenerationOf.get(o);if(i===void 0)return{uc_root:o,next_gen:1,expected_prev_gen:null,...n.because?{because:n.because}:{}};let s=d(e,r);return s!==null&&s.live&&!n.force?{error:{code:"GENERATION_LIVE",detail:c().text("GENERATION_LIVE",{use_case:r,gen:i.gen})}}:s!==null&&s.live&&n.force&&!n.because?{error:{code:"MISSING_BECAUSE",detail:`superseding the live generation of ${r} requires --because <reason>`}}:{uc_root:o,next_gen:i.gen+1,expected_prev_gen:i.gen,...n.because?{because:n.because}:{}}}function f(e,r){let n=e.designGenerationOf.get(r.uc_root)?.gen??null;return n!==r.expected_prev_gen?{code:"GENERATION_MOVED",detail:`design generation of ${r.uc_root.slice(0,12)} moved (expected ${String(r.expected_prev_gen)}, found ${String(n)}) \u2014 another session finalized; re-open and re-ground`}:null}function p(e,r,n){return{uc_root:e.uc_root,uc_cid:r,generation:e.next_gen,supersedes_generation:e.expected_prev_gen,...e.because?{because:e.because}:{},by:n}}export{a,d as b,_ as c,f as d,p as e};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{K as $,s as p}from"./chunk-7HMSMAUG.js";import{a as f}from"./chunk-QXQ7KVEN.js";import{oa as u}from"./chunk-UEE3RZN4.js";var w=e=>e===1?"1 change":`${e} changes`,v=e=>e===1?"waits":"wait";function c(e){let t=/^(\S+-\d+) · (.+)$/.exec(e.title);return t?`${u(t[1])} "${t[2]}"`:`"${e.title}"`}var y=e=>typeof e=="string"?`"${e}"`:e.bare,d=y,j=e=>typeof e=="string"?e:e.bare;function D(e,t){return t.page?{...e,page:t.page}:null}var m=e=>e.page?.bare?{bare:e.page.shown}:e.page?.shown??e.source,O={header:e=>`reviewing what changed in ${d(e)}`,held:(e,t)=>{let n=t.filter(s=>s==="ADD").length,i=t.filter(s=>s==="ARCHIVE").length,r=t.length-n-i,o=[n>0?`${n} new ${n===1?"use-case":"use-cases"}`:null,r>0?`${r} changed`:null,i>0?`${i} no longer in it`:null].filter(s=>s!==null);return`${w(t.length)} from ${d(e)} ${v(t.length)} for your review: ${o.join(", ")}`},waiting:(e,t)=>`${w(t)} from ${d(e)} ${v(t)} for your review`,reviewRow:(e,t)=>`review ${w(t)} from ${d(e)}`,finishForNow:{label:"finish for now",detail:"the review waits in this session"},adjust:"adjust \u2014 tell me what to change",reviewed:(e,t)=>{let n=t.approved+t.rejected+t.deferred,i=[t.approved>0?`${t.approved} approved`:null,t.rejected>0?t.rejected===1?"1 kept as it was":`${t.rejected} kept as they were`:null,t.deferred>0?`${t.deferred} left for later`:null].filter(r=>r!==null);return`reviewed ${n===1?"the change":`the ${n} changes`} from ${d(e)}: ${i.join(" \xB7 ")}`},finishSession:"finish the session",diffTitle:e=>c(e),receipt:(e,t)=>{let n=c(e),i=e.kind==="ADD",r="nothing is saved for this change, and it may be suggested again";return t==="approve"?{line:i?`added ${n} to this session`:e.kind==="ARCHIVE"?`archived ${n} in this session`:`approved the change to ${n} in this session`}:t==="reject"?{line:i?`left ${n} out of this session`:`kept ${n} as it is`,note:r}:{line:i?`left ${n} out for now, as an open question`:`left ${n} as it is for now, as an open question`}},refused:(e,t,n)=>t==="TARGET_RETIRED"?{line:`${c(e)} was archived while you were reviewing, so nothing changed`}:t==="SOURCE_MOVED"?{line:`${d(m(n))} changed again while you were reviewing, so this change wasn't taken`,next:["next: to review the latest version, run:",n.page?` kane-cli context ingest ${f(n.page.address)}${n.page.as?` --as ${f(n.page.as)}`:""}`:` kane-cli maintain reconcile --from ${n.file} --source-id ${n.source}`]}:t==="SOURCE_UNRESOLVED"?{line:`${d(m(n))} was removed while you were reviewing, so this change can't be taken`}:t==="ARCHIVE_UNRESOLVED"?{line:`${c(e)} changed while you were reviewing, so it can't be archived`,moveOn:!0}:t==="CONCURRENT_APPEND"?{line:"that didn't go through: the project was busy; try the card again"}:t==="ALREADY_VERDICTED"||t==="CARD_GONE"||t==="HOLD_GONE"?{line:"that change isn't in this review anymore, so nothing was done"}:{line:"that change can't be taken, so nothing was done",next:[`if this keeps failing, share this id with support: ${p(`refused_${t}`)}`]},chatRefused:e=>{let t=[];for(let n of e){let i=n.ref?`${u(n.ref)}${n.title?` "${n.title}"`:""}`:null;n.code==="EXPECTED_CID_MOVED"&&i?n.moved?t.push(`${i} changed after the agent read it, so this edit wasn't made`,"continue, and the agent works from its latest version"):t.push(`the agent's edit to ${i} didn't match it as it is now, so it wasn't made`,"continue, and the agent reads it again"):t.push("continue, and the agent tries again",`if this keeps failing, share this id with support: ${p(`refused_${n.code}`)}`)}return[...new Set(t)]},approveRefused:e=>{let t=e.find(n=>n.code==="EXPECTED_CID_MOVED"&&n.ref);return t?{line:`${`${u(t.ref)}${t.title?` "${t.title}"`:""}`} changed after it was shown to you, so nothing was approved`,notes:['view what was added to see it as it is now, then pick "looks good" again']}:{line:"that didn't go through, so nothing was approved",notes:['pick "looks good" again',`if this keeps failing, share this id with support: ${p(`refused_${e[0]?.code??"APPROVE"}`)}`]}},diffSummary:e=>{let t=e.filter(s=>s.field==="criteria"),n=Math.max(t.filter(s=>s.op==="+").length,t.filter(s=>s.op==="-").length),i=[...new Set(e.filter(s=>s.field!=="criteria").map(s=>s.field))],r=i.length>0?`its ${i.join(" and ")}`:null,o=n>0?`${n} acceptance ${n===1?"criterion":"criteria"} changed`:null;return o&&r?`${o}, and ${r}`:o??`${r} changed`},steering:"reading the change again, with your words",steerNothing:"your words left nothing to review",steerFailed:"that didn't go through; the changes wait as they were",offerAsks:e=>e>0?"design its tests again?":"design its tests?",notLanded:"that didn't go through; try the card again",offer:(e,t)=>t>0?{headline:t===1?`the test of "${e}" was designed for its old version`:`the ${t} tests of "${e}" were designed for its old version`,rows:[{key:"run",label:t===1?"design it again now":"design them again now",detail:t===1?"replaces it if it no longer fits":"replaces any that no longer fit"},{key:"later",label:"later",detail:`kane-cli context list --stale lists ${t===1?"it":"them"}`}]}:{headline:`"${e}" has no tests yet`,rows:[{key:"run",label:"design its tests now"},{key:"later",label:"later",detail:"design them after you save"}]},childOpen:(e,t)=>`designing the tests of "${t}"${e==="evolve"?" again":""}`,childClosed:(e,t,n)=>[`designed the tests of "${t}"${e==="evolve"?" again":""}`,n.join(" \xB7 ")].filter(Boolean).join(" \u2014 "),childTests:(e,t)=>`${l(t)}${e==="evolve"?"":" added"}`,back:e=>`back to the review \u2014 ${l(e)} added in this session`,againBack:e=>{let t=(a,h)=>a===1?`its test ${h}`:`its ${a} tests ${h}`,i=[e.replaced.scenarios+e.replaced.tests>0&&"replaced",e.updated>0&&"updated",e.kept>0&&"kept"].filter(a=>a!==!1);if(i.length===0)return null;let r=`${[...e.replaced.scenarios>0?[k(e.replaced.scenarios)]:[],...e.replaced.tests>0?[l(e.replaced.tests)]:[]].join(" and ")} replaced`;if(i.length===1)return`back to the review \u2014 ${i[0]==="replaced"?e.replaced.scenarios===0?t(e.replaced.tests,"replaced"):r:i[0]==="updated"?t(e.updated,"updated"):e.kept===1?"its test kept as it was":`its ${e.kept} tests kept as they were`}`;let o=[],s=0;return i.forEach((a,h)=>{let b=h===i.length-1;if(a==="replaced"){o.push(r),s+=e.replaced.tests;return}let g=a==="updated"?e.updated:e.kept;b?o.push(s>0?`the other ${g===1?"test":`${g} tests`} ${a}`:t(g,a)):(o.push(`${l(g)} ${a}`),s+=g)}),`back to the review \u2014 ${o.join(", ")}`},childUnfinished:e=>e==="evolve"?"designing its tests again didn't finish":"designing its tests didn't finish",childFailed:(e,t)=>`couldn't design the tests of "${t}"${e==="evolve"?" again":""}`,childFailedNext:(e,t)=>t==="evolve"?["next: to update them later, run:",` kane-cli maintain evolve ${e}`]:["next: to design its tests later, run:",` kane-cli design tests --use-case ${e}`],childFailedNew:"its tests can be designed after you save this session",updateOpen:(e,t)=>`updating the tests of "${e}"${t?" \u2014 its use-case changed":""}`,updateClosed:(e,t)=>[`updated the tests of "${e}"`,t.join(" \xB7 ")].filter(Boolean).join(" \u2014 "),updateTests:e=>[...e.added>0?[`${l(e.added)} added`]:[],...$({changes:{tests:e.updated}})].join(", ")||null,updateUnfinished:e=>`updating the tests of "${e}" didn't finish`,updateFinishing:"finishing the update\u2026",updateFailed:e=>`couldn't update the tests of "${e}"`,updateUntouched:e=>`finished here: the tests of "${e}" weren't changed`,childHeld:(e,t)=>[{text:` \u2717 its tests can't be designed again now: ${e?"you're designing them in another session":"someone else is designing them"}`},{text:" the change stays approved in this session; to update its tests later, run:",dim:!0},{text:` kane-cli maintain evolve ${t}`,dim:!0}]},l=e=>e===1?"1 test":`${e} tests`,k=e=>e===1?"1 scenario":`${e} scenarios`;function S(e){return/^\S+-\d+ · (.+)$/.exec(e.title)?.[1]??e.title}export{c as a,y as b,j as c,D as d,m as e,O as f,S as g};
2
+ import{K as $,s as p}from"./chunk-H4TIVILC.js";import{a as f}from"./chunk-QXQ7KVEN.js";import{oa as u}from"./chunk-PI7OXS62.js";var w=e=>e===1?"1 change":`${e} changes`,v=e=>e===1?"waits":"wait";function c(e){let t=/^(\S+-\d+) · (.+)$/.exec(e.title);return t?`${u(t[1])} "${t[2]}"`:`"${e.title}"`}var y=e=>typeof e=="string"?`"${e}"`:e.bare,d=y,j=e=>typeof e=="string"?e:e.bare;function D(e,t){return t.page?{...e,page:t.page}:null}var m=e=>e.page?.bare?{bare:e.page.shown}:e.page?.shown??e.source,O={header:e=>`reviewing what changed in ${d(e)}`,held:(e,t)=>{let n=t.filter(s=>s==="ADD").length,i=t.filter(s=>s==="ARCHIVE").length,r=t.length-n-i,o=[n>0?`${n} new ${n===1?"use-case":"use-cases"}`:null,r>0?`${r} changed`:null,i>0?`${i} no longer in it`:null].filter(s=>s!==null);return`${w(t.length)} from ${d(e)} ${v(t.length)} for your review: ${o.join(", ")}`},waiting:(e,t)=>`${w(t)} from ${d(e)} ${v(t)} for your review`,reviewRow:(e,t)=>`review ${w(t)} from ${d(e)}`,finishForNow:{label:"finish for now",detail:"the review waits in this session"},adjust:"adjust \u2014 tell me what to change",reviewed:(e,t)=>{let n=t.approved+t.rejected+t.deferred,i=[t.approved>0?`${t.approved} approved`:null,t.rejected>0?t.rejected===1?"1 kept as it was":`${t.rejected} kept as they were`:null,t.deferred>0?`${t.deferred} left for later`:null].filter(r=>r!==null);return`reviewed ${n===1?"the change":`the ${n} changes`} from ${d(e)}: ${i.join(" \xB7 ")}`},finishSession:"finish the session",diffTitle:e=>c(e),receipt:(e,t)=>{let n=c(e),i=e.kind==="ADD",r="nothing is saved for this change, and it may be suggested again";return t==="approve"?{line:i?`added ${n} to this session`:e.kind==="ARCHIVE"?`archived ${n} in this session`:`approved the change to ${n} in this session`}:t==="reject"?{line:i?`left ${n} out of this session`:`kept ${n} as it is`,note:r}:{line:i?`left ${n} out for now, as an open question`:`left ${n} as it is for now, as an open question`}},refused:(e,t,n)=>t==="TARGET_RETIRED"?{line:`${c(e)} was archived while you were reviewing, so nothing changed`}:t==="SOURCE_MOVED"?{line:`${d(m(n))} changed again while you were reviewing, so this change wasn't taken`,next:["next: to review the latest version, run:",n.page?` kane-cli context ingest ${f(n.page.address)}${n.page.as?` --as ${f(n.page.as)}`:""}`:` kane-cli maintain reconcile --from ${n.file} --source-id ${n.source}`]}:t==="SOURCE_UNRESOLVED"?{line:`${d(m(n))} was removed while you were reviewing, so this change can't be taken`}:t==="ARCHIVE_UNRESOLVED"?{line:`${c(e)} changed while you were reviewing, so it can't be archived`,moveOn:!0}:t==="CONCURRENT_APPEND"?{line:"that didn't go through: the project was busy; try the card again"}:t==="ALREADY_VERDICTED"||t==="CARD_GONE"||t==="HOLD_GONE"?{line:"that change isn't in this review anymore, so nothing was done"}:{line:"that change can't be taken, so nothing was done",next:[`if this keeps failing, share this id with support: ${p(`refused_${t}`)}`]},chatRefused:e=>{let t=[];for(let n of e){let i=n.ref?`${u(n.ref)}${n.title?` "${n.title}"`:""}`:null;n.code==="EXPECTED_CID_MOVED"&&i?n.moved?t.push(`${i} changed after the agent read it, so this edit wasn't made`,"continue, and the agent works from its latest version"):t.push(`the agent's edit to ${i} didn't match it as it is now, so it wasn't made`,"continue, and the agent reads it again"):t.push("continue, and the agent tries again",`if this keeps failing, share this id with support: ${p(`refused_${n.code}`)}`)}return[...new Set(t)]},approveRefused:e=>{let t=e.find(n=>n.code==="EXPECTED_CID_MOVED"&&n.ref);return t?{line:`${`${u(t.ref)}${t.title?` "${t.title}"`:""}`} changed after it was shown to you, so nothing was approved`,notes:['view what was added to see it as it is now, then pick "looks good" again']}:{line:"that didn't go through, so nothing was approved",notes:['pick "looks good" again',`if this keeps failing, share this id with support: ${p(`refused_${e[0]?.code??"APPROVE"}`)}`]}},diffSummary:e=>{let t=e.filter(s=>s.field==="criteria"),n=Math.max(t.filter(s=>s.op==="+").length,t.filter(s=>s.op==="-").length),i=[...new Set(e.filter(s=>s.field!=="criteria").map(s=>s.field))],r=i.length>0?`its ${i.join(" and ")}`:null,o=n>0?`${n} acceptance ${n===1?"criterion":"criteria"} changed`:null;return o&&r?`${o}, and ${r}`:o??`${r} changed`},steering:"reading the change again, with your words",steerNothing:"your words left nothing to review",steerFailed:"that didn't go through; the changes wait as they were",offerAsks:e=>e>0?"design its tests again?":"design its tests?",notLanded:"that didn't go through; try the card again",offer:(e,t)=>t>0?{headline:t===1?`the test of "${e}" was designed for its old version`:`the ${t} tests of "${e}" were designed for its old version`,rows:[{key:"run",label:t===1?"design it again now":"design them again now",detail:t===1?"replaces it if it no longer fits":"replaces any that no longer fit"},{key:"later",label:"later",detail:`kane-cli context list --stale lists ${t===1?"it":"them"}`}]}:{headline:`"${e}" has no tests yet`,rows:[{key:"run",label:"design its tests now"},{key:"later",label:"later",detail:"design them after you save"}]},childOpen:(e,t)=>`designing the tests of "${t}"${e==="evolve"?" again":""}`,childClosed:(e,t,n)=>[`designed the tests of "${t}"${e==="evolve"?" again":""}`,n.join(" \xB7 ")].filter(Boolean).join(" \u2014 "),childTests:(e,t)=>`${l(t)}${e==="evolve"?"":" added"}`,back:e=>`back to the review \u2014 ${l(e)} added in this session`,againBack:e=>{let t=(a,h)=>a===1?`its test ${h}`:`its ${a} tests ${h}`,i=[e.replaced.scenarios+e.replaced.tests>0&&"replaced",e.updated>0&&"updated",e.kept>0&&"kept"].filter(a=>a!==!1);if(i.length===0)return null;let r=`${[...e.replaced.scenarios>0?[k(e.replaced.scenarios)]:[],...e.replaced.tests>0?[l(e.replaced.tests)]:[]].join(" and ")} replaced`;if(i.length===1)return`back to the review \u2014 ${i[0]==="replaced"?e.replaced.scenarios===0?t(e.replaced.tests,"replaced"):r:i[0]==="updated"?t(e.updated,"updated"):e.kept===1?"its test kept as it was":`its ${e.kept} tests kept as they were`}`;let o=[],s=0;return i.forEach((a,h)=>{let b=h===i.length-1;if(a==="replaced"){o.push(r),s+=e.replaced.tests;return}let g=a==="updated"?e.updated:e.kept;b?o.push(s>0?`the other ${g===1?"test":`${g} tests`} ${a}`:t(g,a)):(o.push(`${l(g)} ${a}`),s+=g)}),`back to the review \u2014 ${o.join(", ")}`},childUnfinished:e=>e==="evolve"?"designing its tests again didn't finish":"designing its tests didn't finish",childFailed:(e,t)=>`couldn't design the tests of "${t}"${e==="evolve"?" again":""}`,childFailedNext:(e,t)=>t==="evolve"?["next: to update them later, run:",` kane-cli maintain evolve ${e}`]:["next: to design its tests later, run:",` kane-cli design tests --use-case ${e}`],childFailedNew:"its tests can be designed after you save this session",updateOpen:(e,t)=>`updating the tests of "${e}"${t?" \u2014 its use-case changed":""}`,updateClosed:(e,t)=>[`updated the tests of "${e}"`,t.join(" \xB7 ")].filter(Boolean).join(" \u2014 "),updateTests:e=>[...e.added>0?[`${l(e.added)} added`]:[],...$({changes:{tests:e.updated}})].join(", ")||null,updateUnfinished:e=>`updating the tests of "${e}" didn't finish`,updateFinishing:"finishing the update\u2026",updateFailed:e=>`couldn't update the tests of "${e}"`,updateUntouched:e=>`finished here: the tests of "${e}" weren't changed`,childHeld:(e,t)=>[{text:` \u2717 its tests can't be designed again now: ${e?"you're designing them in another session":"someone else is designing them"}`},{text:" the change stays approved in this session; to update its tests later, run:",dim:!0},{text:` kane-cli maintain evolve ${t}`,dim:!0}]},l=e=>e===1?"1 test":`${e} tests`,k=e=>e===1?"1 scenario":`${e} scenarios`;function S(e){return/^\S+-\d+ · (.+)$/.exec(e.title)?.[1]??e.title}export{c as a,y as b,j as c,D as d,m as e,O as f,S as g};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as E}from"./chunk-7NPTL66J.js";import{a as A,b as I,c as L,d as p,e as N,f as O,g as R,m as T}from"./chunk-ZTHYAHDN.js";import{Fa as f,ka as c}from"./chunk-7HMSMAUG.js";var h="https://integrations.lambdatest.com",m=" kane-cli context ingest <file>";function $(e){try{let n=new URL(e);return`${n.hostname}${n.pathname==="/"?"":n.pathname}`}catch{return e}}function D(e){switch(e.provider){case"web":return`the page ${e.display}`;case"jira":return`Jira issue ${e.display}`;case"confluence":return e.title?`Confluence page "${e.title}"`:`Confluence page ${e.display.split("/").at(-1)}`;case"linear":return`Linear issue ${e.display}`;case"linear-doc":return e.display.startsWith("document ")?`Linear ${e.display}`:`Linear document "${e.display}"`;default:return e.display}}function U(e,n){let t=C(e,n),i={jira:"Jira issue",confluence:"Confluence page",linear:"Linear issue","linear-doc":"Linear document"}[e];return i&&t!==n?`${i} ${t}`:t}function C(e,n){return e==="jira"?A(n)?.issueKey??n:e==="confluence"?L(n)?.pageId??n:e==="linear"?p(n)?.key??n:e==="linear-doc"?N(n)?.slugId??n:$(n)}var k=(e,n)=>e==="web"?`the page ${$(n)}`:U(e,n);function z(e){if(!e?.url)return null;let n=e.kind==="url"?"web":e.kind==="linear"?p(e.url)?"linear":"linear-doc":e.kind;return["web","jira","confluence","linear","linear-doc"].includes(n)?k(n,e.url):null}var x=e=>e.provider==="confluence"?e.title??e.display.split("/").at(-1):e.display;function P(e,n){let t={reading:e.provider==="web"?e.display:D(e),address:e.address,...n?{as:n}:{}};return e.provider==="confluence"&&!e.title?{...t,shown:`Confluence page ${e.display.split("/").at(-1)}`,bare:!0}:e.provider==="linear-doc"&&e.display.startsWith("document ")?{...t,shown:`Linear ${e.display}`,bare:!0}:{...t,shown:x(e)}}function q(e,n,t){return T(e)?.sourceIdFor(n)===t?void 0:t}function Q(e,n){try{let t=I(e,n)?.title;return typeof t=="string"&&t.length>0?t:void 0}catch{return}}function X(e,n,t,i){let s=C(e,n),d=e==="linear-doc"?t??`document ${s}`:s;return P({provider:e,display:d,...t?{title:t}:{},address:n},i)}var Z=e=>`with ${e.delivered+e.omitted} attachments: ${e.delivered} of its images added, ${e.omitted} left out`,ee=(e,n,t=!1)=>`the same ${t?"file":"text"} as "${e}", already in "${n}"`;function y(e,n){return e==="jira"?A(n)?.issueKey??n:e==="confluence"?`the Confluence page ${L(n)?.pageId??n}`:e==="linear"?p(n)?.key??n:e==="linear-doc"?`the Linear document ${N(n)?.slugId??n}`:`the page ${$(n)}`}var w=e=>e==="jira"?"Jira":e==="confluence"?"Confluence":e.startsWith("linear")?"Linear":"the web",S=e=>e.startsWith("linear")?"Linear":"Atlassian",b=e=>O(e)?.workspace??R(e)?.workspace??"<workspace>",G={invalid_url:"INVALID_URL",target_disallowed:"ADDRESS_NOT_ALLOWED",page_not_found:"PAGE_NOT_FOUND",page_access_blocked:"PAGE_BLOCKED",page_paywalled:"PAGE_PAYWALLED",unsupported_content_type:"NOT_A_PAGE",page_too_large:"PAGE_TOO_LARGE",page_timeout:"PAGE_TIMEOUT",scrape_unavailable:"PAGES_UNAVAILABLE",scrape_rate_limited:"PAGES_UNAVAILABLE",internal_error:"PAGES_UNAVAILABLE",malformed_response:"PAGES_UNAVAILABLE",credit_denied:"OUT_OF_CREDITS",auth_rejected:"CREDENTIALS_REJECTED",route_missing:"PAGES_NOT_AVAILABLE",transport_unreachable:"CONNECTION_FAILED",LIS_AUTH:"CREDENTIALS_REJECTED",JIRA_NOT_CONNECTED:"NO_CONNECTION",JIRA_ISSUE_UNAVAILABLE:"ITEM_UNAVAILABLE",LIS_UNAVAILABLE:"INTEGRATION_UNAVAILABLE",LIS_SETUP:"INTEGRATION_SETUP",LIS_FORBIDDEN:"NO_ACCESS",LIS_RATE_LIMITED:"INTEGRATION_BUSY"};function ne(e,n,t){let i=G[t.code]??t.code,s=y(e,n),d=w(e),a=(u,o,g=!1)=>({code:i,message:u,remedy:o,...g?{support:!0}:{}});switch(i){case"INVALID_URL":return a(`${n} isn't a valid public web address, so nothing was added`,"check the address, then run the command again");case"ADDRESS_NOT_ALLOWED":return a(`${n} can't be fetched: it isn't an allowed public web page, so nothing was added`,`use a public page's address, or save the page as a file and add the file:
2
+ import{b as E}from"./chunk-3V4J65GN.js";import{a as A,b as I,c as L,d as p,e as N,f as O,g as R,m as T}from"./chunk-L3BUPFAQ.js";import{Fa as f,ka as c}from"./chunk-H4TIVILC.js";var h="https://integrations.lambdatest.com",m=" kane-cli context ingest <file>";function $(e){try{let n=new URL(e);return`${n.hostname}${n.pathname==="/"?"":n.pathname}`}catch{return e}}function D(e){switch(e.provider){case"web":return`the page ${e.display}`;case"jira":return`Jira issue ${e.display}`;case"confluence":return e.title?`Confluence page "${e.title}"`:`Confluence page ${e.display.split("/").at(-1)}`;case"linear":return`Linear issue ${e.display}`;case"linear-doc":return e.display.startsWith("document ")?`Linear ${e.display}`:`Linear document "${e.display}"`;default:return e.display}}function U(e,n){let t=C(e,n),i={jira:"Jira issue",confluence:"Confluence page",linear:"Linear issue","linear-doc":"Linear document"}[e];return i&&t!==n?`${i} ${t}`:t}function C(e,n){return e==="jira"?A(n)?.issueKey??n:e==="confluence"?L(n)?.pageId??n:e==="linear"?p(n)?.key??n:e==="linear-doc"?N(n)?.slugId??n:$(n)}var k=(e,n)=>e==="web"?`the page ${$(n)}`:U(e,n);function z(e){if(!e?.url)return null;let n=e.kind==="url"?"web":e.kind==="linear"?p(e.url)?"linear":"linear-doc":e.kind;return["web","jira","confluence","linear","linear-doc"].includes(n)?k(n,e.url):null}var x=e=>e.provider==="confluence"?e.title??e.display.split("/").at(-1):e.display;function P(e,n){let t={reading:e.provider==="web"?e.display:D(e),address:e.address,...n?{as:n}:{}};return e.provider==="confluence"&&!e.title?{...t,shown:`Confluence page ${e.display.split("/").at(-1)}`,bare:!0}:e.provider==="linear-doc"&&e.display.startsWith("document ")?{...t,shown:`Linear ${e.display}`,bare:!0}:{...t,shown:x(e)}}function q(e,n,t){return T(e)?.sourceIdFor(n)===t?void 0:t}function Q(e,n){try{let t=I(e,n)?.title;return typeof t=="string"&&t.length>0?t:void 0}catch{return}}function X(e,n,t,i){let s=C(e,n),d=e==="linear-doc"?t??`document ${s}`:s;return P({provider:e,display:d,...t?{title:t}:{},address:n},i)}var Z=e=>`with ${e.delivered+e.omitted} attachments: ${e.delivered} of its images added, ${e.omitted} left out`,ee=(e,n,t=!1)=>`the same ${t?"file":"text"} as "${e}", already in "${n}"`;function y(e,n){return e==="jira"?A(n)?.issueKey??n:e==="confluence"?`the Confluence page ${L(n)?.pageId??n}`:e==="linear"?p(n)?.key??n:e==="linear-doc"?`the Linear document ${N(n)?.slugId??n}`:`the page ${$(n)}`}var w=e=>e==="jira"?"Jira":e==="confluence"?"Confluence":e.startsWith("linear")?"Linear":"the web",S=e=>e.startsWith("linear")?"Linear":"Atlassian",b=e=>O(e)?.workspace??R(e)?.workspace??"<workspace>",G={invalid_url:"INVALID_URL",target_disallowed:"ADDRESS_NOT_ALLOWED",page_not_found:"PAGE_NOT_FOUND",page_access_blocked:"PAGE_BLOCKED",page_paywalled:"PAGE_PAYWALLED",unsupported_content_type:"NOT_A_PAGE",page_too_large:"PAGE_TOO_LARGE",page_timeout:"PAGE_TIMEOUT",scrape_unavailable:"PAGES_UNAVAILABLE",scrape_rate_limited:"PAGES_UNAVAILABLE",internal_error:"PAGES_UNAVAILABLE",malformed_response:"PAGES_UNAVAILABLE",credit_denied:"OUT_OF_CREDITS",auth_rejected:"CREDENTIALS_REJECTED",route_missing:"PAGES_NOT_AVAILABLE",transport_unreachable:"CONNECTION_FAILED",LIS_AUTH:"CREDENTIALS_REJECTED",JIRA_NOT_CONNECTED:"NO_CONNECTION",JIRA_ISSUE_UNAVAILABLE:"ITEM_UNAVAILABLE",LIS_UNAVAILABLE:"INTEGRATION_UNAVAILABLE",LIS_SETUP:"INTEGRATION_SETUP",LIS_FORBIDDEN:"NO_ACCESS",LIS_RATE_LIMITED:"INTEGRATION_BUSY"};function ne(e,n,t){let i=G[t.code]??t.code,s=y(e,n),d=w(e),a=(u,o,g=!1)=>({code:i,message:u,remedy:o,...g?{support:!0}:{}});switch(i){case"INVALID_URL":return a(`${n} isn't a valid public web address, so nothing was added`,"check the address, then run the command again");case"ADDRESS_NOT_ALLOWED":return a(`${n} can't be fetched: it isn't an allowed public web page, so nothing was added`,`use a public page's address, or save the page as a file and add the file:
3
3
  ${m}`);case"PAGE_NOT_FOUND":return a(`${s} couldn't be found, so nothing was added`,"check that the address is right and the page still exists, then run the command again");case"PAGE_BLOCKED":return a(`${s} refused automated access, so nothing was added`,`use a version of the page anyone can open, or save it as a file and add the file:
4
4
  ${m}`);case"PAGE_PAYWALLED":return a(`${s} is behind a paywall or a sign-in, so nothing was added`,`use a copy anyone can open, or save it as a file and add the file:
5
5
  ${m}`);case"NOT_A_PAGE":return a(`${$(n)} isn't a web page, so nothing was added`,`download the document, then add the file:
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as $}from"./chunk-MMBBQ4OZ.js";import{j as h}from"./chunk-XRNQSXOM.js";import{a as w}from"./chunk-RZ4F3BHX.js";import{b as v}from"./chunk-D36V5OX6.js";import{spawn as V,spawnSync as _}from"child_process";import{createServer as K}from"net";import{mkdirSync as g,openSync as W,readFileSync as I,renameSync as j,rmSync as x,statSync as Y,writeFileSync as M}from"fs";import{readFile as q}from"fs/promises";import{dirname as l,join as y}from"path";var G=[4723,4724,4725,4726,4727,4728,4729,4730],X={emulator:4750,simulator:4790},z=40,E=2e3,D=3e4,T=500,Ce=["emulator","simulator"];function Q(e){return y(v,"mobile",`appium-server-${e}.log`)}function m(){return y(v,"mobile","appium-servers.json")}function Z(){return y(v,"mobile","appium-servers.lock")}var ee=1e4,re=50;function C(e){let r=Z();try{g(l(r),{recursive:!0})}catch{return e()}let n=!1;for(let o=0;o<re;o++)try{g(r),n=!0;break}catch{try{Date.now()-Y(r).mtimeMs>ee&&x(r,{recursive:!0,force:!0})}catch{}ne(10)}try{return e()}finally{if(n)try{x(r,{recursive:!0,force:!0})}catch{}}}function ne(e){try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}catch{}}function te(){try{let e=JSON.parse(I(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}function oe(e){let r=m();g(l(r),{recursive:!0});let n=`${r}.tmp`;M(n,JSON.stringify(e,null,2)),j(n,r)}function se(e,r,n){return`Another mobile session is already running${n?` on ${n}`:""}. Wait for it to finish, or close the terminal running it.`}var A=class extends Error{constructor(n,o){super(n);this.port=o;this.name="DeviceBusyError"}};function ie(e){return w(e,{signal:AbortSignal.timeout(E)}).then(r=>r.ok,()=>!1)}async function ae(e,r){try{return(await w(`http://127.0.0.1:${e}/session/${r}`,{method:"DELETE",signal:AbortSignal.timeout(E)})).ok}catch{return!1}}function R(e){let r=e?.value;return Array.isArray(r)?r.map(n=>{let o=n??{},t=o.capabilities??o;return{...typeof o.id=="string"?{id:o.id}:{},caps:t}}):[]}async function ue(e){try{let r=await w(`http://127.0.0.1:${e}/sessions`,{signal:AbortSignal.timeout(E)});return r.ok?R(await r.json()):[]}catch{return[]}}var ce=["udid","appium:udid","deviceUDID","appium:deviceUDID","deviceName","appium:deviceName"];function L(){let e=r=>{try{let n=_("curl",["-s","--noproxy","*","--max-time","2",...r],{encoding:"utf8",timeout:5e3});return{ok:n.status===0,stdout:n.stdout??""}}catch{return{ok:!1,stdout:""}}};return{readState:()=>{try{let r=JSON.parse(I(m(),"utf8"));return Array.isArray(r)?r:[]}catch{return[]}},alive:b,getJson:r=>{let n=e([r]);if(n.ok)try{return JSON.parse(n.stdout)}catch{return}},del:r=>{let n=e(["-o","/dev/null","-w","%{http_code}","-X","DELETE",r]);return n.ok&&/^2\d\d$/.test(n.stdout.trim())}}}function Le(e,r={}){let n={...L(),...r},o=0;try{for(let t of n.readState()){if(!n.alive(t.pid))continue;let i=R(n.getJson(`http://127.0.0.1:${t.port}/sessions`));for(let s of i)s.id&&de(s.caps,e.udid,e.displayName)&&n.del(`http://127.0.0.1:${t.port}/session/${s.id}`)&&(o+=1)}}catch{}return o}function de(e,r,n){let o=[r,n].filter(t=>!!t).map(t=>t.toLowerCase());for(let t of ce){let i=e[t];if(typeof i=="string"&&o.includes(i.toLowerCase()))return!0}return!1}function pe(e,r,n){let o=W(n.logPath,"a"),t=V(e,r,{stdio:["ignore",o,o],detached:!0,env:{...process.env,...n.env}});return t.unref(),t.pid}async function le(e,r){for(let n=e;n<e+r;n++)if(await new Promise(t=>{let i=K();i.once("error",()=>t(!1)),i.once("listening",()=>i.close(()=>t(!0))),i.listen(n)}))return n;throw new Error(`No free port for the managed Appium server in ${e}-${e+r-1}.`)}function b(e){try{return process.kill(e,0),!0}catch{return!1}}function P(e){try{let r=_("ps",["-o","comm=","-p",String(e)],{encoding:"utf8",timeout:2e3});if(r.status!==0)return!1;let n=r.stdout.trim().toLowerCase();return n===""?!0:n.includes("node")||n.includes("kane")}catch{return!0}}function k(e){try{process.kill(e)}catch{}}async function me(){try{let e=JSON.parse(await q(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}async function fe(e){let r=process.pid,n=e.filter(o=>o.owner===r);C(()=>{let o=[];for(let t of te())t.owner!==r&&(Se(t)?o.push(t):b(t.pid)&&k(t.pid));oe([...o,...n])})}function Se(e){return e.owner===void 0?!1:b(e.owner)&&P(e.owner)}function ve(){return{probe:ie,sessions:ue,deleteSession:ae,spawn:pe,freePort:le,alive:b,kill:k,readState:me,writeState:fe,owner:process.pid,depsEnv:e=>h().environment(e),bundleVersion:async e=>(await h().status(e)).version,nodeBinary:process.execPath,env:process.env,os:process.platform,now:()=>Date.now(),sleep:e=>new Promise(r=>setTimeout(r,e))}}function we(e,r,n){if(!e.platformToolsDir)return{};let o=n==="win32"?";":":",t=$(r),i=t?.root??l(e.platformToolsDir),s=t?.platformToolsDir??e.platformToolsDir;return{ANDROID_HOME:i,ANDROID_SDK_ROOT:i,PATH:r.PATH?`${s}${o}${r.PATH}`:s}}async function ge(e){let r=await e.readState(),n=[],o=[];for(let t of r)t.owner!==void 0&&e.alive(t.owner)&&(e.ownerIsOurs??P)(t.owner)?n.push(t):o.push(t);for(let t of o){let i=e.ownerIsOurs??P;e.alive(t.pid)&&i(t.pid)&&e.kill(t.pid)}return o.length>0&&await e.writeState(n),n}async function Je(e,r={}){if(r.appiumUrl)return{result:"external",url:r.appiumUrl};let n={...ve(),...r.deps},o=await ge(n),t=o.filter(a=>a.owner===n.owner),i=new Set(t.map(a=>a.port)),s=new Set(o.map(a=>a.port));if(r.device){let a=await ye(n,s,i,e);if(a!==null)throw new A(se(r.device,a.port,a.device),a.port)}let c=await n.bundleVersion(e),u=t.find(a=>a.deviceClass===e&&(a.bundleVersion??c)===c);if(u&&await n.probe(`http://127.0.0.1:${u.port}/status`))return{result:"reused",url:`http://127.0.0.1:${u.port}`};for(let a of t.filter(S=>S.deviceClass===e&&S!==u))n.kill(a.pid);u&&n.kill(u.pid);let d=await n.depsEnv(e);if(!d.appiumHome)throw new Error(`The managed dependencies for the ${e} class are not installed.
2
+ import{a as $}from"./chunk-MMBBQ4OZ.js";import{j as h}from"./chunk-HX5OLRKU.js";import{a as w}from"./chunk-RZ4F3BHX.js";import{b as v}from"./chunk-FAMQ4DHU.js";import{spawn as V,spawnSync as _}from"child_process";import{createServer as K}from"net";import{mkdirSync as g,openSync as W,readFileSync as I,renameSync as j,rmSync as x,statSync as Y,writeFileSync as M}from"fs";import{readFile as q}from"fs/promises";import{dirname as l,join as y}from"path";var G=[4723,4724,4725,4726,4727,4728,4729,4730],X={emulator:4750,simulator:4790},z=40,E=2e3,D=3e4,T=500,Ce=["emulator","simulator"];function Q(e){return y(v,"mobile",`appium-server-${e}.log`)}function m(){return y(v,"mobile","appium-servers.json")}function Z(){return y(v,"mobile","appium-servers.lock")}var ee=1e4,re=50;function C(e){let r=Z();try{g(l(r),{recursive:!0})}catch{return e()}let n=!1;for(let o=0;o<re;o++)try{g(r),n=!0;break}catch{try{Date.now()-Y(r).mtimeMs>ee&&x(r,{recursive:!0,force:!0})}catch{}ne(10)}try{return e()}finally{if(n)try{x(r,{recursive:!0,force:!0})}catch{}}}function ne(e){try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}catch{}}function te(){try{let e=JSON.parse(I(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}function oe(e){let r=m();g(l(r),{recursive:!0});let n=`${r}.tmp`;M(n,JSON.stringify(e,null,2)),j(n,r)}function se(e,r,n){return`Another mobile session is already running${n?` on ${n}`:""}. Wait for it to finish, or close the terminal running it.`}var A=class extends Error{constructor(n,o){super(n);this.port=o;this.name="DeviceBusyError"}};function ie(e){return w(e,{signal:AbortSignal.timeout(E)}).then(r=>r.ok,()=>!1)}async function ae(e,r){try{return(await w(`http://127.0.0.1:${e}/session/${r}`,{method:"DELETE",signal:AbortSignal.timeout(E)})).ok}catch{return!1}}function R(e){let r=e?.value;return Array.isArray(r)?r.map(n=>{let o=n??{},t=o.capabilities??o;return{...typeof o.id=="string"?{id:o.id}:{},caps:t}}):[]}async function ue(e){try{let r=await w(`http://127.0.0.1:${e}/sessions`,{signal:AbortSignal.timeout(E)});return r.ok?R(await r.json()):[]}catch{return[]}}var ce=["udid","appium:udid","deviceUDID","appium:deviceUDID","deviceName","appium:deviceName"];function L(){let e=r=>{try{let n=_("curl",["-s","--noproxy","*","--max-time","2",...r],{encoding:"utf8",timeout:5e3});return{ok:n.status===0,stdout:n.stdout??""}}catch{return{ok:!1,stdout:""}}};return{readState:()=>{try{let r=JSON.parse(I(m(),"utf8"));return Array.isArray(r)?r:[]}catch{return[]}},alive:b,getJson:r=>{let n=e([r]);if(n.ok)try{return JSON.parse(n.stdout)}catch{return}},del:r=>{let n=e(["-o","/dev/null","-w","%{http_code}","-X","DELETE",r]);return n.ok&&/^2\d\d$/.test(n.stdout.trim())}}}function Le(e,r={}){let n={...L(),...r},o=0;try{for(let t of n.readState()){if(!n.alive(t.pid))continue;let i=R(n.getJson(`http://127.0.0.1:${t.port}/sessions`));for(let s of i)s.id&&de(s.caps,e.udid,e.displayName)&&n.del(`http://127.0.0.1:${t.port}/session/${s.id}`)&&(o+=1)}}catch{}return o}function de(e,r,n){let o=[r,n].filter(t=>!!t).map(t=>t.toLowerCase());for(let t of ce){let i=e[t];if(typeof i=="string"&&o.includes(i.toLowerCase()))return!0}return!1}function pe(e,r,n){let o=W(n.logPath,"a"),t=V(e,r,{stdio:["ignore",o,o],detached:!0,env:{...process.env,...n.env}});return t.unref(),t.pid}async function le(e,r){for(let n=e;n<e+r;n++)if(await new Promise(t=>{let i=K();i.once("error",()=>t(!1)),i.once("listening",()=>i.close(()=>t(!0))),i.listen(n)}))return n;throw new Error(`No free port for the managed Appium server in ${e}-${e+r-1}.`)}function b(e){try{return process.kill(e,0),!0}catch{return!1}}function P(e){try{let r=_("ps",["-o","comm=","-p",String(e)],{encoding:"utf8",timeout:2e3});if(r.status!==0)return!1;let n=r.stdout.trim().toLowerCase();return n===""?!0:n.includes("node")||n.includes("kane")}catch{return!0}}function k(e){try{process.kill(e)}catch{}}async function me(){try{let e=JSON.parse(await q(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}async function fe(e){let r=process.pid,n=e.filter(o=>o.owner===r);C(()=>{let o=[];for(let t of te())t.owner!==r&&(Se(t)?o.push(t):b(t.pid)&&k(t.pid));oe([...o,...n])})}function Se(e){return e.owner===void 0?!1:b(e.owner)&&P(e.owner)}function ve(){return{probe:ie,sessions:ue,deleteSession:ae,spawn:pe,freePort:le,alive:b,kill:k,readState:me,writeState:fe,owner:process.pid,depsEnv:e=>h().environment(e),bundleVersion:async e=>(await h().status(e)).version,nodeBinary:process.execPath,env:process.env,os:process.platform,now:()=>Date.now(),sleep:e=>new Promise(r=>setTimeout(r,e))}}function we(e,r,n){if(!e.platformToolsDir)return{};let o=n==="win32"?";":":",t=$(r),i=t?.root??l(e.platformToolsDir),s=t?.platformToolsDir??e.platformToolsDir;return{ANDROID_HOME:i,ANDROID_SDK_ROOT:i,PATH:r.PATH?`${s}${o}${r.PATH}`:s}}async function ge(e){let r=await e.readState(),n=[],o=[];for(let t of r)t.owner!==void 0&&e.alive(t.owner)&&(e.ownerIsOurs??P)(t.owner)?n.push(t):o.push(t);for(let t of o){let i=e.ownerIsOurs??P;e.alive(t.pid)&&i(t.pid)&&e.kill(t.pid)}return o.length>0&&await e.writeState(n),n}async function Je(e,r={}){if(r.appiumUrl)return{result:"external",url:r.appiumUrl};let n={...ve(),...r.deps},o=await ge(n),t=o.filter(a=>a.owner===n.owner),i=new Set(t.map(a=>a.port)),s=new Set(o.map(a=>a.port));if(r.device){let a=await ye(n,s,i,e);if(a!==null)throw new A(se(r.device,a.port,a.device),a.port)}let c=await n.bundleVersion(e),u=t.find(a=>a.deviceClass===e&&(a.bundleVersion??c)===c);if(u&&await n.probe(`http://127.0.0.1:${u.port}/status`))return{result:"reused",url:`http://127.0.0.1:${u.port}`};for(let a of t.filter(S=>S.deviceClass===e&&S!==u))n.kill(a.pid);u&&n.kill(u.pid);let d=await n.depsEnv(e);if(!d.appiumHome)throw new Error(`The managed dependencies for the ${e} class are not installed.
3
3
  Run \`kane-cli doctor --target ${e} --install\` to install them, or pass --appium-url for an external server.`);let p=await n.freePort(X[e],z),O=`http://127.0.0.1:${p}`,J=l(d.appiumHome),U=y(J,"appium","node_modules","appium","index.js"),N=Q(e);r.onProgress?.(`starting the managed Appium server (${e}, port ${p})\u2026`);let f=n.spawn(n.nodeBinary,[U,"--port",String(p),"--allow-insecure=uiautomator2:adb_shell"],{env:{APPIUM_HOME:d.appiumHome,...we(d,n.env,n.os)},logPath:N}),B=n.now()+D,F=Math.ceil(D/T)+1;for(let a=0;a<F&&n.now()<B;a++)if(await n.sleep(T),await n.probe(`${O}/status`)){if(f!==void 0){let S=t.filter(H=>H.deviceClass!==e);await n.writeState([...S,{port:p,pid:f,owner:n.owner,deviceClass:e,...c?{bundleVersion:c}:{},startedAt:new Date(n.now()).toISOString()}])}return r.onProgress?.("Appium server ready"),{result:"started",url:O}}throw f!==void 0&&n.kill(f),new Error(`The managed Appium server (${e}) did not answer on ${p} within ${D/1e3}s.
4
4
  Check its log: ${N}`)}async function ye(e,r=[],n=[],o){let t=new Set(n),i=new Set([...G,...r]);for(let s of i)if(!t.has(s))for(let c of await e.sessions(s)){if(!c.id)continue;if(o){let d=be(c.caps);if(d&&d!==o)continue}let u=De(c.caps);return{port:s,...u?{device:u}:{}}}return null}function be(e){let r=t=>{let i=e[t];return typeof i=="string"?i.toLowerCase():""},n=r("platformName")||r("appium:platformName");if(n.includes("ios"))return"simulator";if(n.includes("android"))return"emulator";let o=r("appium:automationName")||r("automationName");if(o.includes("xcuitest"))return"simulator";if(o.includes("uiautomator"))return"emulator"}var he=["appium:deviceName","deviceName","appium:udid","udid","appium:deviceUDID","deviceUDID"];function De(e){for(let r of he){let n=e[r];if(typeof n=="string"&&n.trim())return n}}function Ue(e={}){let r={...L(),kill:k,writeState:Ae,...e.deps};try{let n=r.readState(),o=e.owner??process.pid,t=n.filter(s=>s.owner===o&&(!e.deviceClass||s.deviceClass===e.deviceClass));for(let s of t){if(!r.alive(s.pid))continue;let c=R(r.getJson(`http://127.0.0.1:${s.port}/sessions`));for(let u of c)u.id&&r.del(`http://127.0.0.1:${s.port}/session/${u.id}`);r.kill(s.pid)}let i=new Set(t.map(s=>`${s.port}:${s.pid}`));C(()=>{r.writeState(r.readState().filter(s=>!i.has(`${s.port}:${s.pid}`)))})}catch{}}function Ae(e){try{let r=m();g(l(r),{recursive:!0}),M(r,JSON.stringify(e,null,2))}catch{}}export{Ce as a,Q as b,se as c,Le as d,ve as e,Je as f,ye as g,Ue as h};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as P}from"./chunk-DZOYYWOW.js";import{b as Le}from"./chunk-VXGN3IV7.js";import{a as m,c as Nt,d as At,e as I,f as Ae,g as Ce,h as Ct,i as Te,j as Tt}from"./chunk-CB4ARIHR.js";import{a as _t}from"./chunk-BSRSXYDZ.js";import{a as Z,c as xt,e as It}from"./chunk-WOSANGV6.js";import{d as Ot}from"./chunk-XMPTFXPW.js";import{a as Rt}from"./chunk-73Y6T2UK.js";import{a as et}from"./chunk-WN5VKKJ3.js";import{b as Pt,c as Ft}from"./chunk-MNBGG4H3.js";import{a as Lt}from"./chunk-VRIZDOO5.js";import{b as qe,d as qt}from"./chunk-ZHWU6L2G.js";import{a as vt,b as Ne,c as Et,d as de}from"./chunk-ZFM77AQU.js";import{Da as pt,Ea as S,Ga as ft,Ha as ht,Ia as mt,Ka as gt,Na as bt,Pa as W,Qa as L,Sa as ke,Ta as wt,Ua as yt,Va as C,Xa as Re,Ya as St,bb as ve,cb as Ee,eb as $,fb as w,gb as xe,h as at,hb as $t,ib as Ie,kb as Oe,l as ct,lb as kt,mb as _e,o as lt,ob as X,s as dt,xa as K,ya as ut}from"./chunk-UEE3RZN4.js";import{c as st,n as it}from"./chunk-DBMW3VUN.js";import{a as q}from"./chunk-KU3YHPWZ.js";import{a as ce,b as le}from"./chunk-7V4BQSSV.js";import{c as rt}from"./chunk-HHW6MRU3.js";import{a as ae}from"./chunk-7DFBOVUB.js";import{a as ot}from"./chunk-6PIIUAZF.js";import{s as tt,t as nt}from"./chunk-NC7D7GOM.js";import{a as ie}from"./chunk-HCBYKLMW.js";import{a as M,b as k,i as se}from"./chunk-33DWJV67.js";import{a as Nn}from"./chunk-6YGTRKDT.js";import{y as A}from"./chunk-D36V5OX6.js";import{e as z}from"./chunk-UR6MHSHU.js";import{existsSync as co}from"fs";var D=z(Nn(),1);import{existsSync as re,mkdirSync as Sn,readdirSync as Lr,readFileSync as we,rmSync as yn,writeFileSync as Pr,renameSync as Fr}from"fs";import{randomBytes as Jr}from"crypto";import{basename as Br,join as ze}from"path";import{appendFileSync as he,closeSync as cr,existsSync as b,mkdirSync as T,openSync as lr,readdirSync as j,readFileSync as y,renameSync as ge,rmdirSync as dr,rmSync as _,realpathSync as ur,statfsSync as pr,statSync as on,writeFileSync as fr}from"fs";import{randomBytes as sn}from"crypto";import{basename as an,dirname as R,join as f,relative as Me}from"path";var An=/^sha256:[0-9a-f]{64}$/;function Q(t){let e=new Set,n=r=>{typeof r=="string"&&An.test(r)&&e.add(r)};for(let r of t.nodes??[])n(r.content?.blob);for(let r of Object.values(t.media??{})){n(r.text_blob);for(let o of r.images??[])n(o.blob);n(r.plugin?.index),n(r.plugin?.notes),n(r.plugin?.coverage)}return{blobs:[...e].sort(),proposalId:t.proposal_id??null}}function Pe(t){return"sha256:"+le(Buffer.from("assurance.proposal\0"+ce(JSON.parse(t)),"utf8"))}import{mkdirSync as Cn,readFileSync as Tn}from"fs";import{dirname as qn,join as Ln}from"path";var Jt="locations.json",Bt="state.json";function ue(t,e){return Ln(t,"sync",e)}function Ut(t){return Yt(ue(t,Jt),{version:1,locations:[]})}function $o(t,e){jt(ue(t,Jt),e)}function F(t){return Yt(ue(t,Bt),{version:1,entries:{}})}function Mt(t,e){jt(ue(t,Bt),e)}function Wt(t,e){let n=t.locations;if(n.length===0)throw new Error("no locations yet \u2014 add one with kane-cli context sync add <name> <descriptor>");if(e!==void 0){let o=n.find(i=>i.name===e);if(o)return o;throw new Error(`no location named ${e} \u2014 known locations: ${n.map(i=>i.name).join(", ")}`)}if(n.length===1)return n[0];let r=n.find(o=>o.name==="origin");if(r)return r;throw new Error(`name a location: ${n.map(o=>o.name).join(", ")}`)}var H=class extends Error{code="WITNESS_LOWERED"};function Ht(t,e,n){let r=t.entries[e];if(!r)throw new Error(`no sync state for ${e} \u2014 run kane-cli context sync add ${e} <descriptor> first`);let o=r.witness;if(o){if(n.seq<o.seq)throw new H(`${e} is behind what it already served: position ${o.seq} was seen there, now ${n.seq}`);if(n.seq===o.seq&&n.hash!==o.hash)throw new H(`${e} changed the record at position ${o.seq}: ${o.hash} was seen there, now ${n.hash}`)}r.witness=n}function ko(t,e,n){let r=t.locations.length,o=t.locations.filter(i=>i.name!==n);if(o.length===r){let i=r===0?"none":t.locations.map(s=>s.name).join(", ");throw new Error(`no location named ${n} \u2014 known locations: ${i}`)}return t.locations=o,e.entries[n]?.witness??null}function Yt(t,e){let n;try{n=Tn(t,"utf-8")}catch(o){if(o.code==="ENOENT")return e;throw new Error(`${t} could not be read: ${o instanceof Error?o.message:String(o)}`)}let r;try{r=JSON.parse(n)}catch(o){throw new Error(`${t} is not readable JSON: ${o instanceof Error?o.message:String(o)}`)}if(typeof r!="object"||r===null||!("version"in r)||r.version!==1)throw new Error(`${t} is not a version 1 sync file \u2014 this store was written by a newer kane-cli`);return r}function jt(t,e){Cn(qn(t),{recursive:!0}),$(t,JSON.stringify(e,null,2)+`
2
+ import{a as P}from"./chunk-6JUS2ULI.js";import{b as Le}from"./chunk-HG2ILWCE.js";import{a as _t}from"./chunk-BSRSXYDZ.js";import{a as m,c as Nt,d as At,e as I,f as Ae,g as Ce,h as Ct,i as Te,j as Tt}from"./chunk-CB4ARIHR.js";import{a as Z,c as xt,e as It}from"./chunk-UWPG5MWM.js";import{a as Rt}from"./chunk-73Y6T2UK.js";import{d as Ot}from"./chunk-XMPTFXPW.js";import{a as et}from"./chunk-WN5VKKJ3.js";import{b as Pt,c as Ft}from"./chunk-23DKB2MT.js";import{a as Lt}from"./chunk-VRIZDOO5.js";import{b as qe,d as qt}from"./chunk-ZHWU6L2G.js";import{a as vt,b as Ne,c as Et,d as de}from"./chunk-CQDCNP7V.js";import{a as ot}from"./chunk-6PIIUAZF.js";import{Da as pt,Ea as S,Ga as ft,Ha as ht,Ia as mt,Ka as gt,Na as bt,Pa as W,Qa as L,Sa as ke,Ta as wt,Ua as yt,Va as C,Xa as Re,Ya as St,bb as ve,cb as Ee,eb as $,fb as w,gb as xe,h as at,hb as $t,ib as Ie,kb as Oe,l as ct,lb as kt,mb as _e,o as lt,ob as X,s as dt,xa as K,ya as ut}from"./chunk-PI7OXS62.js";import{c as st,n as it}from"./chunk-DBMW3VUN.js";import{a as q}from"./chunk-KU3YHPWZ.js";import{a as ce,b as le}from"./chunk-7V4BQSSV.js";import{c as rt}from"./chunk-G4K3TP2I.js";import{a as ae}from"./chunk-YJAQZMJT.js";import{s as tt,t as nt}from"./chunk-UJLULWSR.js";import{a as ie}from"./chunk-HCBYKLMW.js";import{a as M,b as k,i as se}from"./chunk-33DWJV67.js";import{a as Nn}from"./chunk-6YGTRKDT.js";import{z as A}from"./chunk-FAMQ4DHU.js";import{e as z}from"./chunk-UR6MHSHU.js";import{existsSync as co}from"fs";var D=z(Nn(),1);import{existsSync as re,mkdirSync as Sn,readdirSync as Lr,readFileSync as we,rmSync as yn,writeFileSync as Pr,renameSync as Fr}from"fs";import{randomBytes as Jr}from"crypto";import{basename as Br,join as ze}from"path";import{appendFileSync as he,closeSync as cr,existsSync as b,mkdirSync as T,openSync as lr,readdirSync as j,readFileSync as y,renameSync as ge,rmdirSync as dr,rmSync as _,realpathSync as ur,statfsSync as pr,statSync as on,writeFileSync as fr}from"fs";import{randomBytes as sn}from"crypto";import{basename as an,dirname as R,join as f,relative as Me}from"path";var An=/^sha256:[0-9a-f]{64}$/;function Q(t){let e=new Set,n=r=>{typeof r=="string"&&An.test(r)&&e.add(r)};for(let r of t.nodes??[])n(r.content?.blob);for(let r of Object.values(t.media??{})){n(r.text_blob);for(let o of r.images??[])n(o.blob);n(r.plugin?.index),n(r.plugin?.notes),n(r.plugin?.coverage)}return{blobs:[...e].sort(),proposalId:t.proposal_id??null}}function Pe(t){return"sha256:"+le(Buffer.from("assurance.proposal\0"+ce(JSON.parse(t)),"utf8"))}import{mkdirSync as Cn,readFileSync as Tn}from"fs";import{dirname as qn,join as Ln}from"path";var Jt="locations.json",Bt="state.json";function ue(t,e){return Ln(t,"sync",e)}function Ut(t){return Yt(ue(t,Jt),{version:1,locations:[]})}function $o(t,e){jt(ue(t,Jt),e)}function F(t){return Yt(ue(t,Bt),{version:1,entries:{}})}function Mt(t,e){jt(ue(t,Bt),e)}function Wt(t,e){let n=t.locations;if(n.length===0)throw new Error("no locations yet \u2014 add one with kane-cli context sync add <name> <descriptor>");if(e!==void 0){let o=n.find(i=>i.name===e);if(o)return o;throw new Error(`no location named ${e} \u2014 known locations: ${n.map(i=>i.name).join(", ")}`)}if(n.length===1)return n[0];let r=n.find(o=>o.name==="origin");if(r)return r;throw new Error(`name a location: ${n.map(o=>o.name).join(", ")}`)}var H=class extends Error{code="WITNESS_LOWERED"};function Ht(t,e,n){let r=t.entries[e];if(!r)throw new Error(`no sync state for ${e} \u2014 run kane-cli context sync add ${e} <descriptor> first`);let o=r.witness;if(o){if(n.seq<o.seq)throw new H(`${e} is behind what it already served: position ${o.seq} was seen there, now ${n.seq}`);if(n.seq===o.seq&&n.hash!==o.hash)throw new H(`${e} changed the record at position ${o.seq}: ${o.hash} was seen there, now ${n.hash}`)}r.witness=n}function ko(t,e,n){let r=t.locations.length,o=t.locations.filter(i=>i.name!==n);if(o.length===r){let i=r===0?"none":t.locations.map(s=>s.name).join(", ");throw new Error(`no location named ${n} \u2014 known locations: ${i}`)}return t.locations=o,e.entries[n]?.witness??null}function Yt(t,e){let n;try{n=Tn(t,"utf-8")}catch(o){if(o.code==="ENOENT")return e;throw new Error(`${t} could not be read: ${o instanceof Error?o.message:String(o)}`)}let r;try{r=JSON.parse(n)}catch(o){throw new Error(`${t} is not readable JSON: ${o instanceof Error?o.message:String(o)}`)}if(typeof r!="object"||r===null||!("version"in r)||r.version!==1)throw new Error(`${t} is not a version 1 sync file \u2014 this store was written by a newer kane-cli`);return r}function jt(t,e){Cn(qn(t),{recursive:!0}),$(t,JSON.stringify(e,null,2)+`
3
3
  `)}import{closeSync as Yn,existsSync as Zt,linkSync as jn,mkdirSync as Vn,openSync as Gn,readFileSync as Dn,rmSync as Qt,writeFileSync as zn}from"fs";import{dirname as pe,join as en}from"path";import{existsSync as Un}from"fs";import{join as Mn}from"path";var Vt=1e3,Pn=999999999,Gt=/^assurance\/context@(\d+)$/,Fn=Number(Gt.exec(q)[1]);async function te(t,e){let n=await t.get(I(e));if(n===null)throw ee(`position ${e} is absent`);return{hash:Fe(e,n).hash,raw:n}}function Fe(t,e){let n=i=>new m("SYNC_OBJECT_CORRUPT",`the record at position ${t} on the storage is not usable: ${i}`,"the storage object needs a human look; nothing was changed"),r;try{r=JSON.parse(Buffer.from(e).toString("utf8"))}catch(i){throw n(`not JSON (${i instanceof Error?i.message:String(i)})`)}if(typeof r!="object"||r===null||Array.isArray(r)||r.seq!==t)throw n(`it says it is position ${String(r?.seq)}`);let o=r.schema_version===ve&&Ee(r);if(r.schema_version!==void 0&&r.schema_version!==q&&!o){let i=Gt.exec(r.schema_version);throw i&&Number(i[1])>Fn?new m("SYNC_CLIENT_TOO_OLD",`position ${t} is stamped ${r.schema_version}; this kane-cli reads ${q}`,`upgrade kane-cli to a release that reads ${r.schema_version}, then run the command again`):n(`it is stamped ${r.schema_version}, this build reads ${q}`)}if(r.schema_version===q&&Ee(r))throw n(`it carries a source-plugin fact and is stamped ${q}; such a record is stamped ${ve}`);if(r.parents!==void 0&&!(r.prev_hash===null?r.parents.length===0:r.parents.length===1&&r.parents[0]===r.prev_hash))throw n("parents does not mirror prev_hash");return{record:r,hash:L(r)}}async function J(t,e,n=0){let r=e,o=1,i;for(;;){let p=e+o;if(!await t.head(I(p))){i=p;break}r=p,o*=2}if(r===e&&e>0&&!await t.head(I(e)))return J(t,0);for(;i-r>1;){let p=r+Math.floor((i-r)/2);await t.head(I(p))?r=p:i=p}let s=r;if(s===0){if(await t.head(At))throw ee("meta.json exists but position 1 is gone");let p=(await t.list(Nt)).map(Ce).find(h=>h!==null);if(p!==void 0)throw ee(`position ${p} exists but position 1 is gone`);return{seq:0,hash:null,raw:null}}let a=[Ae(s),Ae(Math.min(s+Vt,Pn))];a[1]===a[0]&&a.pop();let c=new Set;for(let p of a)for(let h of await t.list(p)){let x=Ce(h);if(x!==null){if(x>s){if(await t.head(I(s+1))){if(n>=Jn)throw Bn(s);return J(t,s,n+1)}throw ee(`position ${x} exists above the tail at ${s}`)}c.add(x)}}let d=s-(s-1)%Vt;for(let p=d;p<=s;p++)if(!c.has(p))throw ee(`position ${p} is missing below the tail at ${s}`);let{hash:l,raw:u}=await te(t,s);return{seq:s,hash:l,raw:u}}var Jn=3;function Bn(t){return new m("SYNC_REMOTE_HOLE",`the storage kept growing while its tail was being found (last seen at ${t}); nothing was changed`,"run the command again in a moment")}function ee(t){return new m("SYNC_REMOTE_HOLE",`the storage has a hole: ${t} \u2014 a position was deleted below evidence of a later one`,"restore the missing position from a copy that holds it; nothing was changed")}function Dt(t,e){let n=St(t,e);if(n===null)throw new S(`no local record at position ${e} \u2014 run kane-cli context fsck`);if(!(n!==Re&&Un(Mn(t,"commits",`${String(e).padStart(6,"0")}-${n.slice(7,19)}.json`))))throw new m("SYNC_LOCAL_RECORD_CORRUPT",`the local record at position ${e} ${n===Re?"is unreadable":"does not hash to its file name"}`,"run kane-cli context fsck, then restore the record from a backup or a clone; nothing was changed");return n}async function zt(t,e,n){let r=C(t),o=await J(e,n?.seq??0),i=async u=>u===o.seq?o.hash:(await te(e,u)).hash;if(n&&(o.seq<n.seq||await i(n.seq)!==n.hash))throw new m("SYNC_REMOTE_ROLLED_BACK",`the storage was rolled back: position ${n.seq} was seen there with ${n.hash}, `+(o.seq<n.seq?`now its tail is ${o.seq}`:"now a different record sits there"),"restore the storage from a copy that holds the witnessed records, or remove and re-add the location after a human has decided it was rebuilt on purpose");let s=o.seq===0?null:{seq:o.seq,hash:o.hash};if(s===null)return{kind:"empty-storage",local:r,storage:s};if(r===null)return{kind:"empty-local",local:r,storage:s};if(Dt(t,1)!==await i(1))return{kind:"foreign-lineage",local:r,storage:s};let a=Math.min(r.seq,s.seq),c=async u=>(u===r.seq?r.hash:Dt(t,u))===await i(u);if(await c(a))return{kind:r.seq===s.seq?"up-to-date":r.seq<s.seq?"behind":"ahead",local:r,storage:s};let d=1,l=a;for(;l-d>1;){let u=d+Math.floor((l-d)/2);await c(u)?d=u:l=u}return{kind:"diverged",local:r,storage:s,at:l}}function Kt(t){let e=new Map;return{indexOf(n){if(!e.has(n)){let r=t(n);e.set(n,r===null?void 0:it(r))}return e.get(n)},notesBlob:n=>t(n),coverageBlob:n=>t(n)}}function Xt(t,e){for(let[n,r]of Object.entries(t??{})){let o=r?.plugin;if(o==null||typeof o!="object")continue;let i;if(typeof o.index=="string"){if(i=e.indexOf(o.index),i===null)return{code:"UNIT_INDEX_INVALID",sourceId:n,blob:o.index,detail:"that blob is not a unit index"};if(i!==void 0&&(i.plugin!==o.id||i.rules!==o.rules))return{code:"UNIT_INDEX_INVALID",sourceId:n,blob:o.index,detail:`that index was written by plugin ${JSON.stringify(i.plugin)} under rules ${JSON.stringify(i.rules)}, not by ${JSON.stringify(o.id)} under rules ${JSON.stringify(o.rules)} as the record says`}}if(typeof o.notes=="string"){let s=e.notesBlob(o.notes);if(s===null)continue;let a=qt(s);if(a===null)return{code:"NOTES_INVALID",sourceId:n,blob:o.notes,detail:`that blob is not the stored form of a version's notes${Hn(s)}`};if(a.plugin!==o.id)return{code:"NOTES_INVALID",sourceId:n,blob:o.notes,detail:`those notes were written by plugin ${JSON.stringify(a.plugin)}, not by ${JSON.stringify(o.id)} as the record says`};let c=new Set((i?.units??[]).map(l=>l.id).filter(l=>l!==st)),d=qe(a,c);if(d!==null)return{code:"NOTES_INVALID",sourceId:n,blob:o.notes,detail:d}}if(typeof o.coverage=="string"){let s=e.coverageBlob(o.coverage);if(s===null)continue;let a=Wn(s);if(a===void 0)return{code:"COVERAGE_INVALID",sourceId:n,blob:o.coverage,detail:"that blob is not the stored form of a coverage plan (it is not JSON)"};let c=(i?.units??[]).map(l=>l.id),d=Lt(a,c);if(d!==null)return{code:"COVERAGE_INVALID",sourceId:n,blob:o.coverage,detail:`that blob is not the stored form of a coverage plan of this version (${/^(expected|group \d|the unit|two groups)/.test(d)?d:`it ${d}`})`};if(ce(a)!==Buffer.from(s).toString("utf8"))return{code:"COVERAGE_INVALID",sourceId:n,blob:o.coverage,detail:"that blob is not the stored form of a coverage plan (its bytes are not the canonical form of what it holds)"};if(a.plugin!==o.id)return{code:"COVERAGE_INVALID",sourceId:n,blob:o.coverage,detail:`that coverage plan was written by plugin ${JSON.stringify(a.plugin)}, not by ${JSON.stringify(o.id)} as the record says`}}}return null}function Wn(t){try{return JSON.parse(Buffer.from(t).toString("utf8"))}catch{return}}function Hn(t){try{let e=qe(JSON.parse(Buffer.from(t).toString("utf8")));return e===null?" (its bytes are not the canonical form of what it holds)":e.startsWith("note ")?` (${e})`:` (it ${e})`}catch{return" (it is not JSON)"}}var Kn=2e3;async function rs(t,e,n,r,o){let i=F(t).entries[n]?.witness??null,s=await zt(t,e,i),a=s.local?.seq??0,c={imported:0,from:a,to:a,blobs:0,proposals:0};switch(s.kind){case"empty-storage":return r(`nothing to pull: ${n} is empty`),c;case"up-to-date":return r("up to date"),c;case"ahead":return o?.quietAhead||r(`nothing to pull; you are ahead of ${n} \u2014 run kane-cli context push ${n}`),c;case"diverged":throw new m("SYNC_DIVERGED",`you and ${n} both added work after position ${s.at-1}; nothing was pulled`,`run kane-cli context pull ${n} --rebase to save your local work, take the team version from ${n}, and then reapply yours`);case"foreign-lineage":throw new m("SYNC_FOREIGN_LINEAGE",`${n} holds a different history (its first record is not this store's)`,`to work on it, clone it: kane-cli context clone <descriptor of ${n}> <dir>; to share this store, add an empty location`);case"behind":case"empty-local":break}let d=s.storage.seq,l=await Be(t,e,s.local,s.storage,Xn(t,s.local),r);return Ue(t,l,s.local?.hash??null,n),X(t),Je(t,n,{seq:d,hash:l.records[l.records.length-1].hash}),{imported:l.records.length,from:a,to:d,blobs:l.blobs.size,proposals:l.proposals.size}}function Je(t,e,n,r){let o=r?.lockHeld?()=>{}:W(t,{deadlineMs:Kn});try{let i=F(t),s=i.entries[e]?.witness??null;if(r?.forwardOnly&&s&&s.seq>n.seq)return;try{Ht(i,e,n)}catch(a){throw a instanceof H?new m("SYNC_REMOTE_ROLLED_BACK",a.message,"restore the storage from a copy that holds the witnessed records, or remove and re-add the location after a human has decided it was rebuilt on purpose"):a}Mt(t,i)}finally{o()}}function Xn(t,e){let n=kt(t);return n&&n.applied.seq===(e?.seq??0)&&n.applied.hash===(e?.hash??null)?n:X(t)}async function Be(t,e,n,r,o,i=()=>{}){let s=await Qn(e,n?.seq??0,n?.hash??null,r.seq,r.hash),a=nr(s,o),c=await er(t,e,s);ir(t,s),ar(t,s,a);let d=await tr(t,e,s,i);return{records:s,blobs:c,proposals:d}}function Ue(t,e,n,r,o){for(let[a,c]of e.proposals){let[d,l]=a.split("/");Zn(en(pe(Z(t,d)),l),c)}let i=n,s=null;for(let a=0;a<e.records.length;a+=xe){let c=e.records.slice(a,a+xe),d=o?.lockHeld?()=>{}:W(t);try{$t(t,c.map(({seq:l,raw:u})=>({seq:l,raw:u})),i,{...o,lockHeld:!0})}catch(l){if(!(l instanceof bt))throw l;let u=`this store appended position ${C(t)?.seq??0} while the pull was`;throw new m("SYNC_LOCAL_MOVED",s===null?`${u} being prepared; nothing was imported`:`${u} landing; positions ${e.records[0].seq}..${s} were imported, a valid prefix, and nothing more`,`kane-cli context pull ${r}`)}finally{d()}i=c[c.length-1].hash,s=c[c.length-1].seq,o?.afterChunk?.(s)}}function Zn(t,e){Vn(pe(t),{recursive:!0});let n=`${t}.tmp-${process.pid}`,r=Gn(n,"w");try{zn(r,e),ae(r)}finally{Yn(r)}try{jn(n,t)}catch(o){if(o.code!=="EEXIST")throw Qt(n,{force:!0}),o}Qt(n,{force:!0}),w(pe(t))}async function Qn(t,e,n,r,o){let i=[],s=n;for(let a=e+1;a<=r;a++){let c=await t.get(I(a));if(c===null)throw new m("SYNC_REMOTE_HOLE",`the storage has a hole: position ${a} is missing below its tail at ${r}`,"restore the missing position from a copy that holds it; nothing was changed");let{record:d,hash:l}=Fe(a,c);if(d.prev_hash!==s)throw new m("SYNC_REMOTE_CHAIN_BROKEN",`position ${a} on the storage is sealed onto ${String(d.prev_hash)}, but position ${a-1} hashes ${String(s)}`,"the storage chain needs a human look; nothing was changed");if(a===r&&l!==o)throw new m("SYNC_REMOTE_CHAIN_BROKEN",`the tail at position ${r} changed while this pull ran: it hashed ${o}, now ${l}`,"run kane-cli context pull again");i.push({seq:a,hash:l,raw:Buffer.from(c).toString("utf8"),record:d}),s=l}return i}async function er(t,e,n){let r=new Set;for(let{seq:o,record:i}of n)for(let s of Q(i).blobs){if(r.has(s))continue;let a=de(t,s);if(a!==null&&Ne(a)===s)continue;let c=await e.get(Ct(s));if(c===null)throw new m("SYNC_REMOTE_HOLE",`the storage has a hole: position ${o} names blob ${s}, which the storage does not hold`,"restore the blob from a copy that holds it; nothing was changed");let d=Buffer.from(c);if(Ne(d)!==s)throw new m("SYNC_OBJECT_CORRUPT",`the blob ${s} on the storage does not hash to its name (named by position ${o})`,"the storage object needs a human look; nothing was changed");a===null?Et(t,d):$(vt(t,s),d),r.add(s)}return r}async function tr(t,e,n,r){let o=new Map,i=new Set;for(let{seq:s,record:a}of n){let c=Q(a).proposalId;if(c===null||i.has(c))continue;i.add(c);let d=Z(t,c),l=null;if(Zt(d))try{l=Pe(Dn(d,"utf8"))}catch{l=""}let u=await e.list(Tt(c));if(u.length===0)continue;if(u.length>1){r(`proposal ${c} (position ${s}) has ${u.length} payloads on the storage and the record names none of them; skipped`);continue}if(l!==null&&Te(c,l)===u[0])continue;let p=await e.get(u[0]);if(p===null)continue;let h=null;try{h=Pe(Buffer.from(p).toString("utf8"))}catch{h=null}if(h===null||Te(c,h)!==u[0]){r(`proposal ${c} (position ${s}) on the storage does not digest to its key ${u[0]}; skipped`);continue}if(l===null){o.set(`${c}/proposal.json`,Buffer.from(p));continue}let x=`${c}/proposal.${h.slice(7,19)}.json`;Zt(en(pe(d),x.slice(c.length+1)))||(r(`proposal ${c} (position ${s}) differs from the one here; the storage's payload is installed beside it as ${x}`),o.set(x,Buffer.from(p)))}return o}function nr(t,e){let n=structuredClone(e);for(let{seq:r,hash:o,record:i}of t)try{lt(n,i,o)}catch(s){throw s instanceof ct?new m("SYNC_REMOTE_ADMISSION_RED",`position ${r} would not pass this store's checks: ${s.message}`,`nothing was imported; ask whoever pushed position ${r} to run kane-cli context fsck on their store, or upgrade kane-cli if theirs is newer`):s}return n}var fe=t=>t.slice(0,19),rr=t=>t===null?"no units":`units [${t.join(", ")}]`,or=t=>t===null?"no units":`[${t.join(", ")}]`,sr=(t,e)=>`the record at position ${t} says citation ${fe(e.ecid)} is in ${rr(e.said)}; its lines ${e.anchor} of ${e.sourceId} fall in ${or(e.found)} \u2014 nothing was applied`;function ir(t,e){let n=Kt(r=>de(t,r));for(let{seq:r,record:o}of e){let i=Xt(o.media,n);if(i===null)continue;let s=i.code==="UNIT_INDEX_INVALID"?"unit index":i.code==="NOTES_INVALID"?"notes":"coverage plan";throw new m(i.code==="UNIT_INDEX_INVALID"?"SYNC_UNIT_INDEX_INVALID":i.code==="NOTES_INVALID"?"SYNC_NOTES_INVALID":"SYNC_COVERAGE_INVALID",`the record at position ${r} names blob ${fe(i.blob)} as the ${s} of ${i.sourceId}, and ${i.detail} \u2014 nothing was applied`,`this build cannot take that record. It was written by a kane-cli with a fault or was altered; tell whoever pushed position ${r}, and keep working from your own store`)}}function ar(t,e,n){let r={mediaOf:o=>Object.hasOwn(n.media,o)?n.media[o]:void 0,getBlob:o=>de(t,o)};for(let{seq:o,record:i}of e){let s=at(i.edges,r);if(s!==null)throw s.code==="UNIT_INDEX_MISSING"?new m("SYNC_UNIT_INDEX_MISSING",`the record at position ${o} cites ${s.anchor} of ${s.sourceId} at version ${fe(s.versionCid)}, and that version's unit index (blob ${fe(s.index??"")}) is not in this store's blob store, so the citation's units cannot be checked \u2014 nothing was applied`,"restore this store's blobs from a copy, or clone the location into a new folder (a clone fetches every blob); kane-cli context fsck names what is missing"):new m("SYNC_UNITS_MISMATCH",sr(o,s),`this build cannot take that record. It was written by a kane-cli with a fault or was altered; tell whoever pushed position ${o}, and keep working from your own store`)}}var hr=["pending-facts.ndjson","signals.ndjson","store.json"],mr=/^\d{6}-[0-9a-f]{12}\.json$/,tn=["staged","fenced","backed-up","trimmed","importing","imported","unfenced"],cn=2e3,gr=1440*60*1e3,br=(t,e)=>f(t,"sync","backups",`${e}-reset`),wr=()=>new Date().toISOString().replace(/[:.]/g,"-"),yr=t=>f(t,"sync","incoming"),v=t=>f(t,"sync","replay"),We=t=>an(t),ln=(t,e)=>f(v(t),`${We(e)}.receipt.json`),N=t=>f(t,"sync","journal.json"),O=t=>f(t,"commits"),ne=t=>f(O(t),ke),V=(t,e)=>f(yr(t),e),He=(t,e)=>`${String(t).padStart(6,"0")}-${e.slice(7,19)}.json`,Y=t=>"sha256:"+le(t),dn=()=>({pid:process.pid,nonce:sn(4).toString("hex")});async function vs(t,e,n,r,o,i={}){if(r.kind!=="diverged"||r.at===void 0)throw new Error(`reset needs a diverged relation, got ${r.kind}`);let s=r.at;if(b(N(t)))throw new m("SYNC_STORE_BUSY","a reset is already in progress","run kane-cli context sync doctor");rn(t),$r(t,n),Sr(t);let{records:a,hashes:c}=yt(t),d={seq:s-1,hash:c[s-2]},l=Oe();_e(t,l,a.slice(0,s-1),c.slice(0,s-1),{writeNodeFiles:!1});let u=await Be(t,e,d,r.storage,l),p=a.slice(s-1).map(U=>He(U.seq,c[U.seq-1])),h=Ar(t,a,c,s),x=fn(t,p,h);kr(t,Rr(u)+x.reduce((U,_n)=>U+on(_n.src).size,0));let Qe=i.ts??wr(),oe={nonce:sn(8).toString("hex"),state:"staged",name:n,holder:dn(),base:d,at:s,storage:r.storage,backup:br(t,Qe),ts:Qe,moved:p,testIds:h,counts:{records:u.records.length,blobs:u.blobs.size,proposals:u.proposals.size},manifest:[]};Er(t,oe.nonce,u);let On=W(t,{deadlineMs:cn});try{if(C(t)?.hash!==r.local?.hash)throw new m("SYNC_STORE_BUSY","the chain moved while the reset was being prepared",`run kane-cli context pull ${n} --rebase again`);return rn(t),Ye(t,oe,i.afterTransition),un(t,oe,o,i)}catch(U){throw b(N(t))||me(V(t,oe.nonce)),U}finally{On()}}async function Es(t,e,n=()=>{}){let r={state:"none",detail:"no reset in progress"},o=nn(t);if(o===null)return r;let i=W(t,{deadlineMs:cn});try{let s=nn(t);if(s===null||s.nonce!==o.nonce)return r;if(s.holder.pid!==process.pid&&K(s.holder.pid))throw new m("SYNC_STORE_BUSY",`a reset is running as pid ${s.holder.pid} \u2014 wait`,"wait for it to finish, then run the command again");if(s.holder=dn(),Ye(t,s),e==="resume"){let l=un(t,s,n,{});return{state:"resumed",detail:`finished the reset interrupted at '${s.state}': ${l.moved.length} records moved to ${l.backup}`,result:l}}if(B(s,"imported"))return{state:"refused",detail:`the shared records are already imported, so the reset can only finish (kane-cli context sync or kane-cli context pull finishes it); its receipt will be ${ln(t,s.backup)}`};let a=Nr(t,s),c=0;for(let{name:l,hash:u}of s.manifest){if(!l.startsWith("commits/")&&!l.startsWith("intents/"))continue;let p=f(t,l);try{if(b(p)){if(Y(y(p))!==u)throw new Error("the live file does not match the backup manifest");continue}let h=y(f(s.backup,l));if(Y(h)!==u)throw new Error("the backup copy does not match the manifest");T(R(p),{recursive:!0}),$(p,h),l.startsWith("commits/")&&c++}catch(h){throw new Error(`restore stopped at ${l}: ${h instanceof Error?h.message:String(h)}; re-run abort`)}}pn(t,s.nonce),_(Ie(t),{recursive:!0,force:!0});let d=`${s.backup}.aborted`;return b(s.backup)&&ge(s.backup,d),w(R(s.backup)),_(N(t),{force:!0}),w(R(N(t))),me(d),me(V(t,s.nonce)),{state:"aborted",detail:`aborted the reset at '${s.state}': ${a} imported records removed, ${c} records put back, the chain is as it was`}}finally{i()}}function nn(t){return b(N(t))?JSON.parse(y(N(t),"utf8")):null}var B=(t,e)=>tn.indexOf(t.state)>=tn.indexOf(e);function un(t,e,n,r){let o=l=>{e.state=l,Ye(t,e,r.afterTransition)},i=()=>{if(!je(t,e.nonce))throw new Error("sentinel missing \u2014 run kane-cli context sync doctor")};B(e,"fenced")||(vr(t,e.nonce),o("fenced")),B(e,"backed-up")||(i(),e.manifest=Ir(t,e),o("backed-up")),B(e,"trimmed")||(i(),Or(t,e),o("trimmed")),B(e,"importing")||(i(),o("importing")),B(e,"imported")||(i(),_(Ie(t),{recursive:!0,force:!0}),_r(t,e,xr(t,e.nonce),r.afterChunk),o("imported")),B(e,"unfenced")||(pn(t,e.nonce),o("unfenced"));let s=X(t),a=Cr(t,e),c=It(t,gr),d=Tr(t,f(v(t),We(e.backup)),new Set(Object.keys(s.nodeLabel)));T(v(t),{recursive:!0}),$(ln(t,e.backup),JSON.stringify({from:e.at,moved:e.moved,storageTail:e.storage,quarantinedTests:a,droppedPendingFacts:d,liveSideQueues:c},null,2)+`
4
4
  `),w(v(t)),_(N(t),{force:!0}),w(R(N(t))),me(V(t,e.nonce)),Je(t,e.name,e.storage,{lockHeld:!0}),n(`saved ${e.moved.length} local record${e.moved.length===1?"":"s"} from position ${e.at} in ${e.backup}; ${e.name}'s records took their place`);for(let l of a)n(`quarantined test file ${l}: its test was minted by a moved record`);return{name:e.name,backup:e.backup,moved:e.moved,quarantinedTests:a,pulled:{imported:e.counts.records,from:e.base.seq,to:e.storage.seq,blobs:e.counts.blobs,proposals:e.counts.proposals}}}function rn(t){let e=new Date,n=f(t,"sessions");if(b(n))for(let r of j(n)){let o=f(n,r,".lock");if(!b(o))continue;let i;try{i=JSON.parse(y(o,"utf8"))}catch{continue}let s=e.getTime()-new Date(i.ts??0).getTime();if(typeof i.pid=="number"&&K(i.pid)&&s<rt)throw new m("SYNC_STORE_BUSY",`session ${r} is live (pid ${i.pid})`,"finish or pause that session, then run the reset again")}for(let{key:r,grant:o}of pt(t))if(!ut(o,e))throw new m("SYNC_STORE_BUSY",`lock ${r} is held by ${o.verb} (pid ${o.pid})`,"wait for that command to finish, then run the reset again")}function Sr(t){let e=gn(t);if(!e)return;let n=e.listHolds().length;throw new m("SYNC_REBASE_PENDING",`your last rebase still has ${n} unresolved decision${n===1?"":"s"}; no new rebase was started`,"run kane-cli context sync or kane-cli context pull again to continue. To discard the unresolved local changes instead, run kane-cli context sync doctor --abort")}function $r(t,e){let n=F(t).entries[e]?.binding,r=ot(t),o=ur(t),i=on(t),s=r!==null&&n?.instance_id===r.context_instance_id&&n.realpath===o;if(!(s&&n.dev===i.dev&&n.ino===i.ino))throw new m("SYNC_COPIED_STORE_UNRESOLVED",r===null?"this store has no store.json ids, so it cannot prove it is the one the location was added from":s?`this store's directory is not the one ${e} was bound from: same ids and path, but the .context inode changed \u2014 it was replaced in place by a copy`:`this store is not the one ${e} was added from (${n?`bound to ${n.realpath}`:"no binding"}; this is ${o})`,`re-run kane-cli context sync add ${e} <descriptor> from this directory to bind it`)}function kr(t,e){let n=pr(t),r=n.bavail*n.bsize;if(!(r>=2*e))throw new m("SYNC_DISK_LOW",`${r} bytes free, the reset needs ${2*e} (twice the staged suffix plus the backup)`,"free some disk space, then run the reset again")}function Rr(t){let e=0;for(let n of t.records)e+=Buffer.byteLength(n.raw);for(let n of t.proposals.values())e+=n.length;return e}function Ye(t,e,n){T(R(N(t)),{recursive:!0}),$(N(t),JSON.stringify(e,null,2)+`
5
5
  `),n?.(e.state)}function vr(t,e){let n=ne(t);try{let r=lr(n,"wx");try{fr(r,wt(e)),ae(r)}finally{cr(r)}w(O(t))}catch(r){if(r.code!=="EEXIST")throw r;if(!je(t,e))throw new Error(`${n} belongs to another reset \u2014 run kane-cli context sync doctor`)}}function pn(t,e){if(b(ne(t))){if(!je(t,e))throw new Error(`${ne(t)} belongs to another reset \u2014 left in place`);_(ne(t)),w(O(t))}}function je(t,e){try{return JSON.parse(y(ne(t),"utf8")).kane?.nonce===e}catch{return!1}}function Er(t,e,n){let r=V(t,e);for(let o of["records","proposals"])T(f(r,o),{recursive:!0});for(let o of n.records)$(f(r,"records",`${o.seq}.json`),o.raw);for(let[o,i]of n.proposals)T(R(f(r,"proposals",o)),{recursive:!0}),$(f(r,"proposals",o),i)}function xr(t,e){let n=V(t,e),r=j(f(n,"records")).map(i=>Number(i.slice(0,-5))).sort((i,s)=>i-s).map(i=>{let s=y(f(n,"records",`${i}.json`),"utf8"),a=JSON.parse(s);return{seq:i,raw:s,record:a,hash:L(a)}}),o=new Map;for(let i of Ve(f(n,"proposals")))o.set(Me(f(n,"proposals"),i),y(i));return{records:r,blobs:new Set,proposals:o}}function me(t){_(t,{recursive:!0,force:!0});try{dr(R(t))}catch{}}function fn(t,e,n){let r=[],o=a=>{r.push({name:a,src:f(t,a)})},i=[];for(let a of e){o(`commits/${a}`);let c=JSON.parse(y(f(O(t),a),"utf8"));i.push(c);let d=dt(t,L(c));b(d)&&o(Me(t,d))}let s=f(t,"sessions");if(b(s))for(let a of Ve(s))o(Me(t,a));for(let a of hr)b(f(t,a))&&o(a);for(let a of j(t))xt.test(a)&&o(a);for(let a of i){let c=Q(a).proposalId;c!==null&&b(Z(t,c))&&o(`proposals/${c}/proposal.json`)}for(let a of mn(t,n))r.push({name:`tests/${an(a)}`,src:a});return r}function Ve(t){let e=[];for(let n of j(t,{withFileTypes:!0})){let r=f(t,n.name);n.isDirectory()?e.push(...Ve(r)):n.isFile()&&e.push(r)}return e}function Ir(t,e){let n=f(e.backup,"manifest.json");if(b(n))return JSON.parse(y(n,"utf8"));let r=[];T(e.backup,{recursive:!0}),w(R(e.backup)),w(R(R(e.backup)));let o=(i,s)=>{let a=f(e.backup,i);T(R(a),{recursive:!0}),$(a,s),r.push({name:i,hash:Y(s)})};for(let{name:i,src:s}of fn(t,e.moved,e.testIds??[]))o(i,y(s));return o("base-witness.json",Buffer.from(JSON.stringify({name:e.name,base:e.base,storage:e.storage,from:e.at},null,2)+`
@@ -18,4 +18,4 @@ import{a as P}from"./chunk-DZOYYWOW.js";import{b as Le}from"./chunk-VXGN3IV7.js"
18
18
  `),_(o),i.length}var qr=/^sha256:[0-9a-f]{64}$/,Ge=class t{m=new Map;get size(){return this.m.size}set(e,n){this.m.set(e,n)}get(e){return this.m.get(e)}rewrite(e){if(typeof e=="string")return qr.test(e)?this.m.get(e)??e:e;if(Array.isArray(e))return e.map(n=>this.rewrite(n));if(e!==null&&typeof e=="object"){let n={};for(let[r,o]of Object.entries(e))n[r]=this.rewrite(o);return n}return e}toJSON(){return Object.fromEntries(this.m)}static fromJSON(e){let n=new t;for(let[r,o]of Object.entries(e??{}))n.set(r,o);return n}},De=class t{m=new Map;set(e,n){this.m.set(e.hash,{orig:e,fate:n})}get(e){let n=this.m.get(e.hash);return n&&n.orig.seq===e.seq?n.fate:void 0}byHash(e){return this.m.get(e)?.fate}toJSON(){return[...this.m.values()]}static fromJSON(e){let n=new t;for(let r of e??[])n.set(r.orig,r.fate);return n}},bn=t=>({cid:t.cid.toJSON(),record:t.record.toJSON()}),wn=t=>({cid:Ge.fromJSON(t?.cid),record:De.fromJSON(t?.record)});var Ps=["keep-theirs","apply-mine","apply-mine-as-new"];function Ke(t,e,n){switch(e){case"keep-theirs":return t==="generation"?"the local design stays in the backup; after this rebase, run design again if you want both":"the local change stays in the backup";case"apply-mine":return t==="slug"?`the name moves to the local node; the node that holds it on ${n} is reached by its id again`:t==="head"?`retire the source as it is now, ${n}'s version included`:`the local version lands on top of ${n}'s`;case"apply-mine-as-new":return`a new node beside ${n}'s (duplicate check first)`;case"later":return"leaves the rebase open; kane-cli context sync or kane-cli context pull asks again"}}function Fs(t,e,n){return{rebase_id:t,decision_id:e.holdId,kind:e.kind,intent:e.verb,seq:e.orig.seq,label:e.label,location:n,mine:e.mine,theirs:e.theirs,answers:e.answers.map(r=>({answer:r,consequence:Ke(e.kind,r,n)}))}}function Js(t){return{from:(n,r)=>{let o=n===0?null:t.tokenAt(n);if(n>0&&o===null)throw new S(`the record log holds no record at position ${n} \u2014 run kane-cli context rebuild`);let i=t.recordsSince(o);if(i.length>0&&o!==null&&t.resolveToken(o)?.hash!==r)throw new S(`broken chain after position ${n}: it no longer continues ${String(r)}`);return{records:i,hashes:i.map(L)}},hashAt:n=>{let r=t.tokenAt(n);return r===null?null:t.resolveToken(r)?.hash??null}}}var Bs=t=>t.dirOrThrow(),be=(t,e)=>ze(v(t),`${e}.json`),Ur=(t,e)=>ze(v(t),`${e}.lock`),G=class t{constructor(e,n){this.contextDir=e;this.data=n;this.maps=wn(n.maps)}maps;static create(e,n,r,o,i){let s=Br(n);if(re(be(e,s)))throw new S(`rebase ${s} already has a ledger \u2014 run kane-cli context sync or kane-cli context pull to continue it, or kane-cli context sync doctor --abort to close it`);let a=new t(e,{version:1,backup:n,backupId:s,from:o,state:"open",...i?{location:i}:{},items:r.map(d=>({...d})),maps:{cid:{},record:[]},aliases:[]}),c=!re(v(e));return Sn(v(e),{recursive:!0}),c&&w(ze(e,"sync")),a.save(),a}static open(e,n){let r=be(e,n);if(!re(r))throw new S(`no rebase ${n} here \u2014 kane-cli context sync doctor lists the rebases this store has`);let o;try{o=JSON.parse(we(r,"utf8"))}catch{o=null}if(!ht(o)||typeof o.backup!="string")throw new S(Hr(n));return new t(e,o)}get backupId(){return this.data.backupId}get location(){return this.data.location??"the location"}get rev(){return this.data.rev??0}get backup(){return this.data.backup}get from(){return this.data.from}get state(){return this.data.state}get closedBy(){return this.data.closedBy}get items(){return this.data.items}get aliases(){return this.data.aliases}item(e){let n=this.data.items.find(r=>r.k===e);if(!n)throw new Error(`no replay item ${e}`);return n}itemAt(e){return this.data.items.find(n=>n.orig.seq===e||n.group?.some(r=>r.seq===e))}beginItem(e,n){this.assertOpen();let r=this.item(e);r.begin={expectPrev:n},delete r.outcome,this.save()}endItem(e,n){this.assertOpen(),this.item(e).outcome=n,this.save()}pendingItem(){return this.data.items.find(e=>e.begin!==void 0&&e.outcome===void 0)}reconcileAll(e,n){let r=this.item(e);if(!r.begin)return[];let o=r.origins??Object.fromEntries((r.group??[r.orig]).map(c=>[c.hash,c.seq])),{records:i,hashes:s}=n.from(r.begin.expectPrev.seq,r.begin.expectPrev.hash),a=[];return i.forEach((c,d)=>{let l=c.replayed_from===void 0?void 0:o[c.replayed_from.orig.hash];l!==void 0&&a.push({seq:c.seq,hash:s[d],member:l})}),a}reconcileFrom(e,n,r){let o=this.item(e),i=o.origins??Object.fromEntries((o.group??[o.orig]).map(d=>[d.hash,d.seq])),{records:s,hashes:a}=n.from(r.seq,r.hash),c=[];return s.forEach((d,l)=>{let u=d.replayed_from===void 0?void 0:i[d.replayed_from.orig.hash];u!==void 0&&c.push({seq:d.seq,hash:a[l],member:u})}),c}reconcile(e,n){let r=this.reconcileAll(e,n).at(-1);return r?{seq:r.seq,hash:r.hash}:void 0}lastAppliedInChain(e){for(let n of[...this.data.items].reverse()){let r=n.outcome;if(r&&"applied"in r)return e.hashAt(r.applied.newSeq)===r.applied.newHash;if(r&&"deduped"in r&&r.deduped.newSeq!==void 0)return e.hashAt(r.deduped.newSeq)===r.deduped.newHash}return!0}setMaps(e){this.maps=e,this.data.maps=bn(e),this.save()}addAlias(e){this.data.aliases.push(e),this.save()}listHolds(){return this.data.items.flatMap(e=>e.outcome&&"held"in e.outcome?[e.outcome.held]:[])}resolveHold(e,n){let r=this.heldItem(e);if(!r.outcome.held.answers.includes(n))throw new S(`${n} is not an answer ${e} accepts`);return r.answer=n,this.reopen(r)}reopenHold(e){let n=this.heldItem(e);return delete n.answer,this.reopen(n)}heldItem(e){this.assertOpen();let n=this.data.items.find(r=>r.outcome&&"held"in r.outcome&&r.outcome.held.holdId===e);if(!n)throw new S(`${e} is not an open decision \u2014 kane-cli context sync status lists them`);return n}reopen(e){return delete e.outcome,delete e.begin,this.save(),e}close(e){this.data.state="closed",this.data.closedBy=e,this.save()}toJSON(){return structuredClone(this.data)}assertOpen(){if(this.data.state!=="open")throw new S(`rebase ${this.data.backupId} is closed \u2014 kane-cli context sync doctor lists every rebase and what it reapplied`)}save(){let e=be(this.contextDir,this.data.backupId);if(re(e)){let n=0;try{n=JSON.parse(we(e,"utf8")).rev??0}catch{n=0}if(n>(this.data.rev??0))throw new S(`the replay ledger for ${this.data.backupId} changed on disk (rev ${n}, this process holds rev ${this.data.rev??0}) \u2014 another process is working on it; run the command again`)}this.data.rev=(this.data.rev??0)+1,$(e,JSON.stringify(this.data,null,2)+`
19
19
  `)}};function Mr(t,e){let n=Ur(t,e);Sn(v(t),{recursive:!0});let r=Jr(6).toString("hex");for(;;)try{return Pr(n,JSON.stringify({pid:process.pid,nonce:r}),{flag:"wx"}),()=>{try{JSON.parse(we(n,"utf8")).nonce===r&&yn(n)}catch{}}}catch(o){if(o.code!=="EEXIST")throw o;let i={};try{i=JSON.parse(we(n,"utf8"))}catch{i={}}if(typeof i.pid=="number"&&K(i.pid))throw new S(`rebase ${e} is being worked on by pid ${i.pid} \u2014 wait for it to finish`);yn(n,{force:!0})}}var Us=(t,e,n,r,o)=>G.create(t,e,n,r,o),Wr=(t,e)=>G.open(t,e),Hr=t=>`rebase ${t} has a ledger this store cannot read (sync/replay/${t}.json) \u2014 ${ft}`,$n=t=>{let e=v(t);return re(e)?Lr(e).filter(n=>n.endsWith(".json")&&!n.endsWith(".receipt.json")).sort().reverse().map(n=>n.slice(0,-5)):[]};function Yr(t,e={}){let n=[];for(let r of $n(t))try{n.push(G.open(t,r))}catch(o){if(!e.tolerant)throw o}return n}function Ms(t){return $n(t).filter(e=>{try{return G.open(t,e),!1}catch{return!0}})}function Ws(t,e){let n=be(t,e),r=`${n}.unreadable`;return Fr(n,r),w(v(t)),r}function gn(t){return Yr(t).find(e=>e.state==="open")}function jr(t){let e=t.outcome;return e?"applied"in e?`reapplied \u2192 record ${e.applied.newSeq}`:"held"in e?`decision ${e.held.holdId} (${e.held.kind})`:"deduped"in e?`already present: ${e.deduped.as.slice(0,19)}`:`not reapplied: ${e.skipped.reason}`:t.begin?"pending":"waiting"}function Hs(t,e,n={}){let r=t.itemAt(e);if(!r)throw new S(`no moved record at position ${e} in rebase ${t.backupId}`);let o=r.label.startsWith(`${r.verb} `)||r.label===r.verb?r.label:`${r.verb} ${r.label}`,i=[`record ${r.orig.seq}: ${o}`,`origin ${r.orig.hash}`,`outcome: ${jr(r)}`];if(r.group&&i.push(`group: records ${r.group.map(s=>s.seq).join(", ")}`),r.outcome&&"held"in r.outcome){let s=r.outcome.held,a=Math.max(5,t.location.length)+1;i.push(`${"local:".padEnd(a+1)}${s.mine}`,`${`${t.location}:`.padEnd(a+1)}${s.theirs}`,`choose: ${s.answers.join(", ")}`),n.detail!==!1&&i.push(JSON.stringify(s.detail,null,2))}return i}function Ys(t,e){let n=Mr(t,e);try{let r=Wr(t,e);return r.state==="open"&&r.close("abort"),r}finally{n()}}var g=z(ie(),1);function kn(t,e,n){let r={"keep-theirs":`keep ${n}'s version`,"apply-mine":"apply the local version","apply-mine-as-new":"add the local version as new",later:"decide later"},o=t.answers.map(i=>({key:i,answer:i,label:r[i],detail:e(i)}));return o.push({key:"later",answer:"later",label:r.later,detail:e("later")}),o}function Rn({card:t,index:e,total:n,rebaseId:r,location:o,diff:i,rows:s,sel:a,focused:c,expanded:d}){let l=Math.max(...(i??[]).map(u=>Math.max(u.was.length,u.local.length,u.origin.length)),8);return(0,g.jsxs)(M,{flexDirection:"column",children:[(0,g.jsxs)(k,{bold:!0,children:[`decision ${e} of ${n}`,(0,g.jsx)(k,{color:A.dim,children:` \xB7 ${t.kind} on your ${t.verb} from record ${t.orig.seq}`})]}),i&&i.length>0?(0,g.jsxs)(M,{flexDirection:"column",children:[(0,g.jsx)(k,{color:A.dim,children:` ${"".padEnd(12)}${"was".padEnd(l+2)}${"local".padEnd(l+2)}${o}`}),i.map(u=>(0,g.jsxs)(k,{children:[(0,g.jsx)(k,{color:A.dim,children:` ${u.field.padEnd(12)}`}),u.was.padEnd(l+2),(0,g.jsx)(k,{color:A.assuranceAccent,children:u.local.padEnd(l+2)}),u.origin]},u.field))]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(P,{label:"local",text:t.mine,accent:!0}),(0,g.jsx)(P,{label:o,text:t.theirs})]}),d?d.map((u,p)=>(0,g.jsx)(k,{color:A.dim,children:` ${u}`},`x-${p}`)):null,(0,g.jsx)(Le,{headline:`what should happen to the local ${t.verb} from record ${t.orig.seq}`,ask:!0,rows:s,sel:a,focused:c}),(0,g.jsx)(k,{color:A.dim,children:" \u2191\u2193 select \xB7 \u23CE confirm \xB7 1\u20139 jump \xB7 v full record \xB7 a decide everything later \xB7 ctrl+c pause"})]})}function vn({name:t,count:e,from:n,backupPath:r,taking:o,sel:i,focused:s}){let a=[{key:"continue",label:"continue",detail:"save, take, reapply"},{key:"not-now",label:"not now",detail:"nothing changes"}];return(0,g.jsxs)(M,{flexDirection:"column",children:[(0,g.jsx)(k,{bold:!0,children:`rebase from ${t}`}),(0,g.jsx)(P,{label:"local",text:`${e} record${e===1?"":"s"} from position ${n} saved to ${r}`}),(0,g.jsx)(P,{label:t,text:`records ${o.from}..${o.to} taken into this store`}),(0,g.jsx)(P,{label:"then",text:"the local records reapplied on top; a disagreement becomes a decision you answer"}),(0,g.jsx)(P,{label:"never",text:`history on ${t} rewritten`}),(0,g.jsx)(Le,{headline:"continue",ask:!0,rows:a,sel:i,focused:s}),(0,g.jsx)(k,{color:A.dim,children:" \u2191\u2193 select \xB7 \u23CE confirm \xB7 esc not now"})]})}var E=z(ie(),1);function Vr(t){let e=t.detail,n=c=>c&&typeof c=="object"&&!Array.isArray(c)?c:null,r=n(e.was),o=n(e.mine),i=n(e.theirs);if(!r||!o||!i)return[];let s=c=>c==null?"":typeof c=="string"?c:JSON.stringify(c);return[...new Set([...Object.keys(r),...Object.keys(o),...Object.keys(i)])].filter(c=>s(o[c])!==s(r[c])||s(i[c])!==s(r[c])).map(c=>({field:c,was:s(r[c]),local:s(o[c]),origin:s(i[c])}))}function oi(t,e,n,r){let o={"keep-theirs":`kept ${n}'s version`,"apply-mine":"applied the local version","apply-mine-as-new":"added the local version as new",later:"decided later","later-all":"decided later"},i=r&&"deduped"in r?`already present on ${n}`:r&&"skipped"in r&&e!=="keep-theirs"?`not reapplied (${r.skipped.reason})`:o[e];return`decision ${t.holdId}: ${i}`}var Xe=class{screen={kind:"idle"};version=0;interrupted=!1;scrollback={current:null};listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));set(e){this.screen=e,this.emit()}note(e){this.scrollback.current?.append((0,E.jsx)(k,{children:e}))}flush(){return this.scrollback.current?.flush()??Promise.resolve()}emit(){this.version+=1;for(let e of this.listeners)e()}};function Gr(t){return(0,D.useSyncExternalStore)(t.subscribe,()=>t.version),t.screen}function Dr({ask:t,rows:e,done:n}){let[r,o]=(0,D.useState)(0),[i,s]=(0,D.useState)(!1);se((c,d)=>{if(d.ctrl&&c==="c")return n("later-all");if(d.escape)return n("later");if(c==="a")return n("later-all");if(c==="v")return s(u=>!u);if(d.upArrow)return o(u=>Math.max(0,u-1));if(d.downArrow)return o(u=>Math.min(e.length-1,u+1));if(d.return)return n(e[r].answer);let l=Number(c);Number.isInteger(l)&&l>=1&&l<=e.length&&o(l-1)});let a=Vr(t.card);return(0,E.jsx)(Rn,{card:t.card,index:t.index,total:t.total,rebaseId:t.rebaseId,location:t.location,diff:a,rows:e,sel:r,focused:!0,expanded:i?t.record:void 0})}function zr({ask:t,done:e}){let[n,r]=(0,D.useState)(0);return se((o,i)=>{if(i.ctrl&&o==="c"||i.escape)return e(!1);if(i.upArrow)return r(0);if(i.downArrow)return r(1);if(o==="1")return r(0);if(o==="2")return r(1);if(i.return)return e(n===0)}),(0,E.jsx)(vn,{...t,sel:n,focused:!0})}function Kr({store:t}){return se((e,n)=>{n.ctrl&&e==="c"&&(t.interrupted=!0)}),null}function Xr({store:t}){let e=Gr(t);return e.kind==="decide"?(0,E.jsx)(Dr,{ask:e.ask,rows:e.rows,done:e.done},e.ask.card.holdId):e.kind==="confirm"?(0,E.jsx)(zr,{ask:e.ask,done:e.done}):(0,E.jsx)(Kr,{store:t})}function Zr({store:t}){return(0,E.jsxs)(et,{children:[(0,E.jsx)(_t,{into:t.scrollback}),(0,E.jsx)(M,{flexDirection:"column",children:(0,E.jsx)(Xr,{store:t})})]})}function Qr(t,e){return kn(t,n=>Ke(t.kind,n,e),e)}function En(){let t=new Xe,e=null,n=async()=>{if(e)return;let{render:o}=await import("./build-5ZN47FAT.js");e=o((0,E.jsx)(Zr,{store:t}),{exitOnCtrlC:!1}),tt(()=>e?.unmount())},r=async()=>{if(!e)return;let o=e;e=null,await t.flush();let i=o.waitUntilExit().catch(()=>{});o.unmount(),await i,nt()};return{async confirm(o){await n();let i=await new Promise(s=>t.set({kind:"confirm",ask:o,done:s}));return t.set({kind:"idle"}),await r(),i},async decide(o){await n();let i=await new Promise(s=>t.set({kind:"decide",ask:o,rows:Qr(o.card,o.location),done:s}));return t.set({kind:"idle"}),i},note(o){t.note(o)},close:r,interrupted:()=>t.interrupted}}import{resolve as eo}from"path";import{fileURLToPath as to,pathToFileURL as no}from"url";var ro="us-east-1",oo=/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//,$e="use file:///abs/path, an absolute or relative directory path, s3://<bucket>/<prefix>?endpoint=<url>&region=<region>, or a GitHub HTTPS/SSH repository URL";function In(t,e){let n=t.trim();if(n==="")throw new Error(`a location is required \u2014 ${$e}`);if(/^(?:git\+)?https:\/\//i.test(n)||/^(?:git\+)?ssh:\/\//i.test(n)||/^[^/\s@:]+@[^/\s:]+:/.test(n)||n.startsWith("git+scp://"))return ao(n);if(!oo.test(n))return xn(eo(e,n));let r=new URL(n);switch(r.protocol){case"fake:":if(r.hostname==="")throw new Error(`fake:// needs a name \u2014 ${$e}`);return{kind:"fake",location:`fake://${r.hostname}`};case"file:":return xn(to(r));case"s3:":return so(r);default:throw new Error(`this release does not speak "${r.protocol}" \u2014 ${$e}`)}}function xn(t){return{kind:"dir",location:no(t).href,path:t}}function so(t){let e=t.hostname;if(e==="")throw new Error(`an s3 location needs a bucket \u2014 ${$e}`);let n=t.pathname.replace(/^\/+/,"").replace(/\/+$/,""),r=n===""?"":`${n}/`,o=t.searchParams.get("region")||ro;if(!/^[A-Za-z0-9-]{1,64}$/.test(o))throw new Error("the region must be letters, digits and dashes only, like us-east-1");let i=t.searchParams.get("endpoint"),s=i===null||i===""?null:io(i),a=s===null?`?region=${o}`:`?endpoint=${s}&region=${o}`,c={kind:"s3",location:`s3://${e}/${r}${a}`,bucket:e,prefix:r,region:o};return s!==null&&(c.endpoint=s),c}function io(t){let e="the endpoint must be an http URL like http://127.0.0.1:9000",n;try{n=new URL(t)}catch{throw new Error(e)}if(n.protocol!=="http:"&&n.protocol!=="https:")throw new Error(e);if(n.username||n.password)throw new Error("an endpoint never carries a user name or password; pass credentials with --credential-env or --credential-file");if(n.search!==""||n.hash!==""||n.pathname!=="/")throw new Error(`the endpoint must be a host and port only, with no path or query \u2014 got ${n.origin}`);return`${n.protocol}//${n.host}`}var ye="Use a Git repository address with no dot or parent segments";function Se(t){return t.split("/").some(e=>e==="."||e==="..")}function ao(t){if(/[\x00-\x20\x7f]/.test(t))throw new Error("A Git location cannot contain whitespace or control characters");let e=t;if(e.startsWith("git+scp://")){let p=e.slice(10).replace(/[?#].*$/,"").replace(/^[^/]*/,"");if(Se(p.slice(1)))throw new Error(ye);let h=new URL(e);e=`${decodeURIComponent(h.username)}@${h.hostname}:${h.pathname.slice(1)}${h.search}${h.hash}`}else e=e.replace(/^git\+/,"");let n=e.indexOf("#"),r=n<0?"main":decodeURIComponent(e.slice(n+1)),o=n<0?e:e.slice(0,n),i=o.indexOf("?"),s=i<0?o:o.slice(0,i),a=new URLSearchParams(i<0?"":o.slice(i+1));for(let p of a.keys())if(p!=="prefix")throw new Error("https: and ssh: Git locations accept only the prefix query option; never put credentials in a location");if(a.getAll("prefix").length>1)throw new Error("Only one Git prefix may be supplied");let c=a.get("prefix")??"";if(c&&(!/^[a-zA-Z0-9_~./-]+$/.test(c)||c.split("/").some(p=>!p||p==="."||p===".."||p.toLowerCase()===".git")))throw new Error("Use a relative Git prefix with no empty, dot or parent segments");if(!/^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(r)||r.includes("..")||r.includes("//")||r.endsWith(".")||r.split("/").some(p=>!p||p.startsWith(".")||p.endsWith(".lock")))throw new Error("Use a valid Git branch name");let d=/^([^/@:]+)@([^/:]+):(.+)$/.exec(s),l;if(d){if(!/^[A-Za-z0-9._-]+$/.test(d[1])||!/^[A-Za-z0-9.-]+$/.test(d[2])||!/^[A-Za-z0-9_~./-]+$/.test(d[3]))throw new Error("Use a valid SSH repository address");if(Se(d[3]))throw new Error(ye);l=`git+scp://${d[1]}@${d[2]}/${d[3]}`}else{if(Se(s.replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/[^/]*/,"")))throw new Error(ye);let p=new URL(s);if(!["https:","ssh:"].includes(p.protocol)||!p.hostname||!p.pathname||p.pathname==="/"||p.password||p.protocol==="https:"&&p.username)throw new Error("Use a secret-free HTTPS or SSH repository URL; sign in through Git instead");if(/%(?:00|0a|0d)/i.test(p.pathname))throw new Error("Invalid repository path");if(Se(p.pathname))throw new Error(ye);s=p.href,l=`git+${p.href}`}let u=c?`?${new URLSearchParams({prefix:c})}`:"";return{kind:"git",gitUrl:s,branch:r,prefix:c,location:`${l}${u}#${encodeURIComponent(r)}`}}function ci(t){if(t.kind==="dir")return t.path;if(t.kind!=="git")return t.location;let e=t.prefix?`?${new URLSearchParams({prefix:t.prefix})}`:"",n=t.branch&&t.branch!=="main"?`#${encodeURIComponent(t.branch)}`:"";return`${t.gitUrl}${e}${n}`}function Ze(t,e){(t.err??t.out)(`error: ${e}`)}function Si(t,e){let n=Rt(t);return co(n)?n:(Ze(e,"no context store here (run `kane-cli context ingest <files>` first)"),null)}async function $i(t,e,n){return n?!0:t.isTTY?t.confirm(`${e}?`):(Ze(t,`refusing to ${e} without --yes (no TTY to confirm)`),!1)}function ki(){return{out:t=>process.stdout.write(t+`
20
20
  `),err:t=>process.stderr.write(t+`
21
- `),isTTY:Ot(),walkUI:En,confirm:async t=>{let{createInterface:e}=await import("readline/promises"),n=e({input:process.stdin,output:process.stdout});try{let r=await n.question(`${t} [y/N] `);return/^y(es)?$/i.test(r.trim())}catch(r){if(r.name==="AbortError")return!1;throw r}finally{n.close()}},ask:async t=>{let{createInterface:e}=await import("readline/promises"),n=e({input:process.stdin,output:process.stdout});try{return await n.question(t)}finally{n.close()}}}}var lo=1500;function uo(t,e){return t==="behind"?`${e} has moved past this machine \u2014 run kane-cli context pull ${e}`:`this store and ${e} have diverged \u2014 run kane-cli context pull ${e} --rebase`}async function Ri(t,e,n){let r=await po(t,n);r&&e(r.text)}async function po(t,e){if(process.env.KANE_SYNC_GUARD==="0")return null;try{let n=Ut(t);if(n.locations.length===0)return null;let r=Wt(n),o=F(t).entries[r.name]?.witness;if(!o)return null;let{openProvider:i}=await import("./open-provider-OZAG6WZS.js"),s=i(In(r.location,t),r.name,e),a=await Promise.race([fo(t,s,o),ho()]);return a?{text:uo(a.kind,r.name),name:r.name,localSeq:a.localSeq,storageSeq:a.storageSeq}:null}catch{return null}}function vi(t){return{type:"sync_behind",name:t.name,local_seq:t.localSeq,storage_seq:t.storageSeq,text:t.text}}async function fo(t,e,n){try{let r=C(t),o=r?.seq??0;return await e.head(I(n.seq+1))?{kind:"behind",localSeq:o,storageSeq:(await J(e,n.seq+1)).seq}:r===null||(await te(e,r.seq)).hash===r.hash?null:{kind:"diverged",localSeq:o,storageSeq:(await J(e,r.seq)).seq}}catch{return null}}function ho(){return new Promise(t=>{setTimeout(()=>t(null),lo).unref()})}function mo(t){try{return gt(t),null}catch(e){if(e instanceof mt)return{code:e.code,text:e.message,remedy:e.remedy};throw e}}function Ei(t){return{type:"sync_error",code:t.code,detail:t.text,remedy:t.remedy}}function xi(t,e){let n=mo(t);return n?(Ze(e,n.text),(e.err??e.out)(`next: ${n.remedy}`),!0):!1}export{Q as a,Pe as b,Ut as c,$o as d,F as e,Mt as f,Wt as g,ko as h,te as i,J as j,zt as k,rs as l,Je as m,br as n,wr as o,yr as p,v as q,We as r,ln as s,vs as t,Es as u,nn as v,xs as w,Ps as x,Fs as y,Js as z,Bs as A,Mr as B,Us as C,Wr as D,Yr as E,Ms as F,Ws as G,gn as H,Hs as I,Ys as J,oi as K,In as L,ci as M,Ze as N,Si as O,$i as P,ki as Q,Ri as R,po as S,vi as T,mo as U,Ei as V,xi as W};
21
+ `),isTTY:Ot(),walkUI:En,confirm:async t=>{let{createInterface:e}=await import("readline/promises"),n=e({input:process.stdin,output:process.stdout});try{let r=await n.question(`${t} [y/N] `);return/^y(es)?$/i.test(r.trim())}catch(r){if(r.name==="AbortError")return!1;throw r}finally{n.close()}},ask:async t=>{let{createInterface:e}=await import("readline/promises"),n=e({input:process.stdin,output:process.stdout});try{return await n.question(t)}finally{n.close()}}}}var lo=1500;function uo(t,e){return t==="behind"?`${e} has moved past this machine \u2014 run kane-cli context pull ${e}`:`this store and ${e} have diverged \u2014 run kane-cli context pull ${e} --rebase`}async function Ri(t,e,n){let r=await po(t,n);r&&e(r.text)}async function po(t,e){if(process.env.KANE_SYNC_GUARD==="0")return null;try{let n=Ut(t);if(n.locations.length===0)return null;let r=Wt(n),o=F(t).entries[r.name]?.witness;if(!o)return null;let{openProvider:i}=await import("./open-provider-XDJKT3W3.js"),s=i(In(r.location,t),r.name,e),a=await Promise.race([fo(t,s,o),ho()]);return a?{text:uo(a.kind,r.name),name:r.name,localSeq:a.localSeq,storageSeq:a.storageSeq}:null}catch{return null}}function vi(t){return{type:"sync_behind",name:t.name,local_seq:t.localSeq,storage_seq:t.storageSeq,text:t.text}}async function fo(t,e,n){try{let r=C(t),o=r?.seq??0;return await e.head(I(n.seq+1))?{kind:"behind",localSeq:o,storageSeq:(await J(e,n.seq+1)).seq}:r===null||(await te(e,r.seq)).hash===r.hash?null:{kind:"diverged",localSeq:o,storageSeq:(await J(e,r.seq)).seq}}catch{return null}}function ho(){return new Promise(t=>{setTimeout(()=>t(null),lo).unref()})}function mo(t){try{return gt(t),null}catch(e){if(e instanceof mt)return{code:e.code,text:e.message,remedy:e.remedy};throw e}}function Ei(t){return{type:"sync_error",code:t.code,detail:t.text,remedy:t.remedy}}function xi(t,e){let n=mo(t);return n?(Ze(e,n.text),(e.err??e.out)(`next: ${n.remedy}`),!0):!1}export{Q as a,Pe as b,Ut as c,$o as d,F as e,Mt as f,Wt as g,ko as h,te as i,J as j,zt as k,rs as l,Je as m,br as n,wr as o,yr as p,v as q,We as r,ln as s,vs as t,Es as u,nn as v,xs as w,Ps as x,Fs as y,Js as z,Bs as A,Mr as B,Us as C,Wr as D,Yr as E,Ms as F,Ws as G,gn as H,Hs as I,Ys as J,oi as K,In as L,ci as M,Ze as N,Si as O,$i as P,ki as Q,Ri as R,po as S,vi as T,mo as U,Ei as V,xi as W};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{k as $,l as I}from"./chunk-4I7YN6YY.js";import{randomUUID as q}from"crypto";var f=class extends Error{constructor(i,a,t,r=null,n=null,c={},u=null){super(t);this.status=i;this.code=a;this.failed=r;this.seq=n;this.extra=c;this.requestId=u;this.name="LatticeError"}get retryable(){return this.status===0||this.status===502||this.status===503||this.status===504}get forPerson(){return this.code==="UNREACHABLE"?"Lattice did not answer":this.code==="UNEXPECTED_ANSWER"?"Lattice gave an answer the session host could not read":this.message}};function Y(e,l){let i=Number(e.headers.get(l));return Number.isInteger(i)&&i>0?i:null}function B(e,l,i,a){let t=null;try{t=JSON.parse(l.toString("utf8"))}catch{}let r=t?.error;if(typeof r?.code=="string"&&typeof r.message=="string"){let{code:n,message:c,failed:u,seq:d,...R}=r;return new f(e.status,n,c,typeof u=="string"?u:null,typeof d=="number"?d:null,R,a)}return new f(e.status,"UNEXPECTED_ANSWER",`${i} answered ${e.status} without the contract's error body; check Lattice's log`,null,null,{},a)}function D(e){let l=$(),i=I();return{"x-request-id":e,...l!==null?{"x-user-session-id":l}:{},...i!==null?{"user-agent":`kane-cli/${i}`}:{}}}var P=6e4,U=64*1024;function C(e){let l=e.fetch??((t,r)=>fetch(t,r));async function i(t,r,n,{headers:c={},bulk:u=!1,route:d,onSend:R}={}){let g=/^https?:\/\//i.test(r),m=d??(g?`${t} upload`:`${t} ${r}`),w=g?null:q(),b={...g?{}:{authorization:e.basicAuth,...D(w)},...Object.fromEntries(Object.entries(c).map(([s,o])=>[s.toLowerCase(),o]))},h,S=n instanceof Buffer&&n.length>U;if(n instanceof Buffer)if(b["content-type"]??="application/octet-stream",S){b["content-length"]=String(n.length);let s=0;h=new ReadableStream({pull(o){if(s>=n.length)return o.close();let p=n.subarray(s,s+U);s+=p.length,y(),e.onSend?.(m,s,n.length),R?.(s,n.length),o.enqueue(new Uint8Array(p))}})}else h=new Uint8Array(n);else n!==void 0&&(b["content-type"]="application/json",h=JSON.stringify(n));let N=e.requestDeadlineMs??P,_=new AbortController,E=!1,T,y=()=>{clearTimeout(T),T=setTimeout(()=>{E=!0,_.abort()},N)};y();try{let s={method:t,headers:b,signal:_.signal,...h!==void 0?{body:h}:{},...S?{duplex:"half"}:{}},o=await l(g?r:`${e.url}${r}`,s);(u||S)&&y();let p=[],x=o.headers.get("content-encoding")?Number(o.headers.get("lattice-history-bytes")??NaN):Number(o.headers.get("content-length")??NaN),M=Number.isFinite(x)?x:null,A=0;if(o.body){let v=o.body.getReader();for(;;){let{done:k,value:L}=await v.read();if(k)break;p.push(L),u&&(y(),A+=L.byteLength,e.onBody?.(m,A,M))}}let O=Buffer.concat(p);if(!o.ok)throw B(o,O,m,w);return{response:o,bytes:O}}catch(s){if(s instanceof f)throw s;let o=E?`no answer within ${N/1e3} s${u?" of its last part":""}`:s instanceof Error?s.message:String(s);throw new f(0,"UNREACHABLE",g?`${m} did not reach the upload's address: ${E?o:"the connection failed"}`:`${m} did not reach Lattice at ${e.url}: ${o}`,null,null,{},w)}finally{clearTimeout(T)}}async function a(t,r,n,c=!1){let{response:u,bytes:d}=await i(t,r,n,{bulk:c});if(u.status!==204)return JSON.parse(d.toString("utf8"))}return{exchange:i,request:a}}function H(e=12e4,l=a=>new Promise(t=>setTimeout(t,a)),i=Date.now){let a=null,t=500,r=0;return{async again(n){a??=i();let c=a+e-i();if(c<=0)return!1;r+=1;let u=Math.min(t,c);return n?.(u),await l(u),t=Math.min(t*2,1e4),!0},get attempt(){return r},endsAt(){return a===null?null:a+e},reset(){a=null,t=500,r=0}}}export{f as a,Y as b,P as c,C as d,H as e};
2
+ import{k as $,n as I}from"./chunk-HYJVYYAZ.js";import{randomUUID as q}from"crypto";var f=class extends Error{constructor(i,a,t,r=null,n=null,c={},u=null){super(t);this.status=i;this.code=a;this.failed=r;this.seq=n;this.extra=c;this.requestId=u;this.name="LatticeError"}get retryable(){return this.status===0||this.status===502||this.status===503||this.status===504}get forPerson(){return this.code==="UNREACHABLE"?"Lattice did not answer":this.code==="UNEXPECTED_ANSWER"?"Lattice gave an answer the session host could not read":this.message}};function Y(e,l){let i=Number(e.headers.get(l));return Number.isInteger(i)&&i>0?i:null}function B(e,l,i,a){let t=null;try{t=JSON.parse(l.toString("utf8"))}catch{}let r=t?.error;if(typeof r?.code=="string"&&typeof r.message=="string"){let{code:n,message:c,failed:u,seq:d,...R}=r;return new f(e.status,n,c,typeof u=="string"?u:null,typeof d=="number"?d:null,R,a)}return new f(e.status,"UNEXPECTED_ANSWER",`${i} answered ${e.status} without the contract's error body; check Lattice's log`,null,null,{},a)}function D(e){let l=$(),i=I();return{"x-request-id":e,...l!==null?{"x-user-session-id":l}:{},...i!==null?{"user-agent":`kane-cli/${i}`}:{}}}var P=6e4,U=64*1024;function C(e){let l=e.fetch??((t,r)=>fetch(t,r));async function i(t,r,n,{headers:c={},bulk:u=!1,route:d,onSend:R}={}){let g=/^https?:\/\//i.test(r),m=d??(g?`${t} upload`:`${t} ${r}`),w=g?null:q(),b={...g?{}:{authorization:e.basicAuth,...D(w)},...Object.fromEntries(Object.entries(c).map(([s,o])=>[s.toLowerCase(),o]))},h,S=n instanceof Buffer&&n.length>U;if(n instanceof Buffer)if(b["content-type"]??="application/octet-stream",S){b["content-length"]=String(n.length);let s=0;h=new ReadableStream({pull(o){if(s>=n.length)return o.close();let p=n.subarray(s,s+U);s+=p.length,y(),e.onSend?.(m,s,n.length),R?.(s,n.length),o.enqueue(new Uint8Array(p))}})}else h=new Uint8Array(n);else n!==void 0&&(b["content-type"]="application/json",h=JSON.stringify(n));let N=e.requestDeadlineMs??P,_=new AbortController,E=!1,T,y=()=>{clearTimeout(T),T=setTimeout(()=>{E=!0,_.abort()},N)};y();try{let s={method:t,headers:b,signal:_.signal,...h!==void 0?{body:h}:{},...S?{duplex:"half"}:{}},o=await l(g?r:`${e.url}${r}`,s);(u||S)&&y();let p=[],x=o.headers.get("content-encoding")?Number(o.headers.get("lattice-history-bytes")??NaN):Number(o.headers.get("content-length")??NaN),M=Number.isFinite(x)?x:null,A=0;if(o.body){let v=o.body.getReader();for(;;){let{done:k,value:L}=await v.read();if(k)break;p.push(L),u&&(y(),A+=L.byteLength,e.onBody?.(m,A,M))}}let O=Buffer.concat(p);if(!o.ok)throw B(o,O,m,w);return{response:o,bytes:O}}catch(s){if(s instanceof f)throw s;let o=E?`no answer within ${N/1e3} s${u?" of its last part":""}`:s instanceof Error?s.message:String(s);throw new f(0,"UNREACHABLE",g?`${m} did not reach the upload's address: ${E?o:"the connection failed"}`:`${m} did not reach Lattice at ${e.url}: ${o}`,null,null,{},w)}finally{clearTimeout(T)}}async function a(t,r,n,c=!1){let{response:u,bytes:d}=await i(t,r,n,{bulk:c});if(u.status!==204)return JSON.parse(d.toString("utf8"))}return{exchange:i,request:a}}function H(e=12e4,l=a=>new Promise(t=>setTimeout(t,a)),i=Date.now){let a=null,t=500,r=0;return{async again(n){a??=i();let c=a+e-i();if(c<=0)return!1;r+=1;let u=Math.min(t,c);return n?.(u),await l(u),t=Math.min(t*2,1e4),!0},get attempt(){return r},endsAt(){return a===null?null:a+e},reset(){a=null,t=500,r=0}}}export{f as a,Y as b,P as c,C as d,H as e};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as l}from"./chunk-WD52ZNQY.js";import{b as i,d as p,e as f,g,h as u}from"./chunk-77ZZQJLX.js";import{b as d}from"./chunk-CGITGJ3I.js";import{existsSync as t,mkdirSync as w,readFileSync as S,renameSync as y,writeFileSync as D}from"fs";import{join as j}from"path";function O(r){l(i(r));let a=i(r);if(!t(a))return;let s=j(a,"meta.json"),n=f(r);if(t(s)&&!t(n))try{w(p(r),{recursive:!0}),y(s,n)}catch(e){process.stderr.write(`warn: meta.json migration failed: ${e.message}
2
+ import{b as l}from"./chunk-WD52ZNQY.js";import{b as i,d as p,e as f,g,h as u}from"./chunk-77ZZQJLX.js";import{b as d}from"./chunk-BHQIH2FE.js";import{existsSync as t,mkdirSync as w,readFileSync as S,renameSync as y,writeFileSync as D}from"fs";import{join as j}from"path";function O(r){l(i(r));let a=i(r);if(!t(a))return;let s=j(a,"meta.json"),n=f(r);if(t(s)&&!t(n))try{w(p(r),{recursive:!0}),y(s,n)}catch(e){process.stderr.write(`warn: meta.json migration failed: ${e.message}
3
3
  `)}let c=u(r);if(t(c)){let e="python";try{let o=new d().load();o.code_export?.language&&(e=o.code_export.language)}catch{}let m=g(r,"playwright",e);if(!t(m))try{y(c,m)}catch(o){process.stderr.write(`warn: generated-code migration failed: ${o.message}
4
4
  `)}}if(t(n))try{let e=JSON.parse(S(n,"utf8"));"md5sum"in e&&(delete e.md5sum,D(n,JSON.stringify(e,null,2)+`
5
5
  `,"utf8"))}catch(e){process.stderr.write(`warn: meta.json md5sum strip failed: ${e.message}
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as s}from"./chunk-HCBYKLMW.js";import{a as i,b as n}from"./chunk-33DWJV67.js";import{y as a}from"./chunk-D36V5OX6.js";import{e as r}from"./chunk-UR6MHSHU.js";var o=r(s(),1);function g({bindings:c,suppressEscBack:p=!1,escBackLabel:m="back to chat"}){let e=c.map(t=>`${t.keys} ${t.label}`);return p||e.push(`esc \xB7 ${m}`),(0,o.jsx)(i,{marginTop:1,children:(0,o.jsx)(n,{color:a.dim,children:e.join(" \xB7 ")})})}export{g as a};
2
+ import{a as s}from"./chunk-HCBYKLMW.js";import{a as i,b as n}from"./chunk-33DWJV67.js";import{z as a}from"./chunk-FAMQ4DHU.js";import{e as r}from"./chunk-UR6MHSHU.js";var o=r(s(),1);function g({bindings:c,suppressEscBack:p=!1,escBackLabel:m="back to chat"}){let e=c.map(t=>`${t.keys} ${t.label}`);return p||e.push(`esc \xB7 ${m}`),(0,o.jsx)(i,{marginTop:1,children:(0,o.jsx)(n,{color:a.dim,children:e.join(" \xB7 ")})})}export{g as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{m as d}from"./chunk-4I7YN6YY.js";function a(n,e){return n.trust.get(e)}function c(n,e){return a(n,e)==="derived"?"unreviewed":void 0}function u(n,e){let t=n.resolve(e);if(!t)return{ok:!1,code:"UNKNOWN_REF",detail:`${e} names nothing in the graph`};let r=t.tip,i=a(n,r),o=d(),s=o.command("next.review_use_case",{use_case:e});return i==="archived"?{ok:!1,code:"UC_ARCHIVED",detail:`${e} is archived (previously rejected by the owner) \u2014 re-approve it before designing`,ref:e,...s!==null?{reviewCmd:s}:{}}:i==="derived"?{ok:!1,code:"UC_UNREVIEWED",detail:o.text("UC_UNREVIEWED",{use_case:e}),ref:e,...s!==null?{reviewCmd:s}:{}}:{ok:!0}}function g(n,e){if(!e.useCase||e.allowUnreviewed||e.resuming&&e.sessionUseCase===e.useCase)return null;let t=u(n,e.useCase);return!t.ok&&(t.code==="UC_UNREVIEWED"||t.code==="UC_ARCHIVED")?t:null}function p(n){return n.code==="UC_UNREVIEWED"}function v(n,e){return a(n,e)==="derived"?"quarantine":"evidence-attach"}async function f(n,e){let t={id:"trust-gate",header:"unreviewed use-case",text:`design: ${e.detail??"this use-case is unreviewed"} \u2014 design against it anyway?`,risk:"high",rationale:e.reviewCmd?`approve it first: ${e.reviewCmd}`:"",options:[{label:"no \u2014 approve it first",detail:e.reviewCmd??"review it before designing"},{label:"design against it anyway",detail:"the design will build on an unreviewed use-case"}],recommended_index:0,allow_free_text:!1},r=await n([t]);return Array.isArray(r)?r.find(i=>i.id==="trust-gate")?.selected_index===1:!1}export{a,c as b,u as c,g as d,p as e,v as f,f as g};
2
+ import{o as d}from"./chunk-HYJVYYAZ.js";function a(n,e){return n.trust.get(e)}function c(n,e){return a(n,e)==="derived"?"unreviewed":void 0}function u(n,e){let t=n.resolve(e);if(!t)return{ok:!1,code:"UNKNOWN_REF",detail:`${e} names nothing in the graph`};let r=t.tip,i=a(n,r),o=d(),s=o.command("next.review_use_case",{use_case:e});return i==="archived"?{ok:!1,code:"UC_ARCHIVED",detail:`${e} is archived (previously rejected by the owner) \u2014 re-approve it before designing`,ref:e,...s!==null?{reviewCmd:s}:{}}:i==="derived"?{ok:!1,code:"UC_UNREVIEWED",detail:o.text("UC_UNREVIEWED",{use_case:e}),ref:e,...s!==null?{reviewCmd:s}:{}}:{ok:!0}}function g(n,e){if(!e.useCase||e.allowUnreviewed||e.resuming&&e.sessionUseCase===e.useCase)return null;let t=u(n,e.useCase);return!t.ok&&(t.code==="UC_UNREVIEWED"||t.code==="UC_ARCHIVED")?t:null}function p(n){return n.code==="UC_UNREVIEWED"}function v(n,e){return a(n,e)==="derived"?"quarantine":"evidence-attach"}async function f(n,e){let t={id:"trust-gate",header:"unreviewed use-case",text:`design: ${e.detail??"this use-case is unreviewed"} \u2014 design against it anyway?`,risk:"high",rationale:e.reviewCmd?`approve it first: ${e.reviewCmd}`:"",options:[{label:"no \u2014 approve it first",detail:e.reviewCmd??"review it before designing"},{label:"design against it anyway",detail:"the design will build on an unreviewed use-case"}],recommended_index:0,allow_free_text:!1},r=await n([t]);return Array.isArray(r)?r.find(i=>i.id==="trust-gate")?.selected_index===1:!1}export{a,c as b,u as c,g as d,p as e,v as f,f as g};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as O,c as P}from"./chunk-SMXABALN.js";import{a as M,b as $}from"./chunk-7NPTL66J.js";import{b as I,c as L}from"./chunk-BWXLZS5O.js";import{oa as j}from"./chunk-UEE3RZN4.js";import{a as D}from"./chunk-HCBYKLMW.js";import{a as m,b as s,k as _}from"./chunk-33DWJV67.js";import{a as q}from"./chunk-6YGTRKDT.js";import{y as f}from"./chunk-D36V5OX6.js";import{e as C}from"./chunk-UR6MHSHU.js";var F={"acceptance criteria":1,scenarios:2,"acceptance criteria + exercises":3,"tests + gaps":4,tests:4};function J(e,i,n={}){let r=[],u=L(e.turns).entries.length;if(i==="design"){let c;for(let g=e.ledger.length-1;g>=0;g--){let p=e.ledger[g];if(p.kind==="banner"&&p.text.startsWith("designing: ")){c=p.text.slice(11);break}}let o=n.remote&&!c?e.ledger.find(g=>g.kind==="header")?.phase:void 0,v=c?F[c]:o;v&&r.push(`phase ${v}/4`),u>0&&!n.remote&&r.push(`${u} item${u===1?"":"s"} this session`)}else u>0&&!n.remote&&r.push(`${u} saved as draft${u===1?"":"s"}`);let l=n.remote?n.added??I(e.turns):0,a=n.remote?n.updated??0:0;(l>0||a>0)&&r.push([l>0?`${l} added`:"",a>0?`${a} updated`:"","not saved yet"].filter(Boolean).join(" \xB7 "));let h=e.pending?e.pending.resolution.filter(c=>!c).length:0;return h>0&&r.push(`${h} question${h===1?"":"s"} pending`),e.credits&&r.push(`${e.credits.total.toFixed(1)} credits`),{items:r}}function Z(e,i){let n=[],r=e.applied+e.committed+e.retired;n.push(`${r} applied`),n.push(`${i} to decide`);let u=[];return e.skipped>0&&u.push(`${e.skipped} skipped`),e.deferred>0&&u.push(`${e.deferred} deferred`),e.failed>0&&u.push(`${e.failed} failed`),{items:[...n,...u]}}var x=C(q(),1);function ne({onToggleThinking:e,onCtrlC:i,explorer:n,panel:r}){let l=(0,x.useRef)(null),a=(0,x.useRef)(""),h=()=>{l.current&&clearTimeout(l.current),l.current=null,a.current=""};return(0,x.useEffect)(()=>h,[]),O((c,o)=>{if(o.ctrl&&c==="t"){e();return}if(o.ctrl&&c==="c"){i();return}if(!o.ctrl&&c.includes("")){i();return}if(!o.ctrl&&c.includes("")){e();return}if(n&&n.isOpen()){let v=()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{h(),n.onBack()},150)};if(l.current){if(o.upArrow||o.downArrow||o.return){h(),o.return?n.onEnter():n.onMove(o.upArrow?-1:1);return}if(a.current+=c,a.current==="["){v();return}let g=a.current;h();let p=/^\[([ABCD])/.exec(g);if(p){(p[1]==="A"||p[1]==="B")&&n.onMove(p[1]==="A"?-1:1);return}n.onBack();return}if(o.upArrow){n.onMove(-1);return}if(o.downArrow){n.onMove(1);return}if(o.return){n.onEnter();return}if(o.escape){a.current="",v();return}return}if(r&&r.isFocused()){let v=()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{h(),r.onBack()},150)};if(l.current){if(o.upArrow||o.downArrow||o.return||o.leftArrow||o.rightArrow){h(),o.return?r.onSelect():o.leftArrow?r.onLeft?.():o.rightArrow?r.onRight?.():r.onMove(o.upArrow?-1:1);return}if(a.current+=c,a.current==="["){v();return}let g=a.current;h();let p=/^\[([ABCD])/.exec(g);if(p){p[1]==="A"||p[1]==="B"?r.onMove(p[1]==="A"?-1:1):p[1]==="C"?r.onRight?.():r.onLeft?.();return}r.onBack();return}if(o.upArrow){r.onMove(-1);return}if(o.downArrow){r.onMove(1);return}if(o.leftArrow){r.onLeft?.();return}if(o.rightArrow){r.onRight?.();return}if(o.return){r.onSelect();return}if(o.escape){a.current="",v();return}if(/^[1-9]$/.test(c)){r.onDigit(Number(c));return}if(o.tab){r.onTab?.();return}if(c===" "&&r.isMulti()){r.onSpace();return}if(c&&!o.ctrl&&!o.meta){r.onType(c);return}return}}),null}var t=C(D(),1);function N(e,i=!1){return i?Y(e):e.kind==="REVIEW"?[{v:"approve",label:"approve",detail:"mark it reviewed and trusted"},{v:"archive",label:"archive",detail:"reject it \u2014 asks for a reason; impact shown above"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="PAIR"?[{v:"merge",label:"merge",detail:"duplicate \u2014 fold into the older item (it stays unreviewed)"},{v:"keep_both",label:"keep both",detail:"genuinely distinct \u2014 promote both"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="ARCHIVE"?[{v:"archive",label:"retire",detail:"hidden from now on; history is kept and it can be reverted"},{v:"skip",label:"skip",detail:"keep it \u2014 decided, never re-offered"},{v:"defer",label:"defer",detail:"not now \u2014 the plan re-offers it"}]:e.heldPayload?[{v:"approve",label:"approve update",detail:"commit the held payload \u2014 impact preview above"},{v:"skip",label:"keep current",detail:"drop the held payload (the owner's disk state stays untouched)"},{v:"defer",label:"defer",detail:"not now \u2014 stays held"}]:[{v:"approve",label:"approve",detail:e.kind==="ADD"?"commit + design it":"commit the updated version (old\u2192new redirect)"},{v:"skip",label:e.origin==="content-change"?"reject":"skip",detail:e.origin==="content-change"?"drop the staged proposal \u2014 nothing committed":"leave it as is"},{v:"defer",label:"defer",detail:"not now \u2014 the plan keeps it staged"}]}var Q=e=>e===0?null:e===1?"its test was designed for the old version":`its ${e} tests were designed for the old version`;function Y(e){return e.heldPayload?[{v:"approve",label:"approve the change",detail:"the use-case takes the new version"},{v:"skip",label:"keep it as it is",detail:"the change is dropped"},{v:"defer",label:"decide later",detail:"it keeps waiting"}]:e.kind==="ARCHIVE"?[...e.archiveRefused?[]:[{v:"archive",label:"archive",detail:"it's hidden from the project from now on"}],{v:"skip",label:"keep it",detail:"it stays as it is; this may be suggested again"},{v:"defer",label:"defer",detail:"decide later; it's kept as an open question"}]:e.kind==="ADD"?[{v:"approve",label:"approve",detail:"add it to this session"},{v:"skip",label:"reject",detail:"leave it out; it may be suggested again"},{v:"defer",label:"defer",detail:"leave it out for now, as an open question"}]:[{v:"approve",label:"approve",detail:"the use-case takes the new version"},{v:"skip",label:"reject",detail:"it stays as it is; the change may be suggested again"},{v:"defer",label:"defer",detail:"it stays as it is for now, as an open question"}]}function K(e,i=!1){let n=N(e,i);return e.viewDiff&&n.push({v:"view_diff",label:"view diff",detail:i?"the whole change, old \u2192 new":"full old \u2192 new"}),n}function R(e,i=!1){return e.kind==="ARCHIVE"?null:K(e,i).length}var G={ADD:{color:f.green??"green"},MODIFY:{color:"yellow"},ARCHIVE:{color:f.red},REVIEW:{color:"cyan"},PAIR:{color:"magenta"}},U=60,X=(e,i)=>`${e.heldPayload?"changed earlier":e.kind==="ADD"?"new":e.kind==="ARCHIVE"?`no longer in ${$(i)}`:"changed"}:`;function de({card:e,position:i,sel:n=0,focused:r=!1,freeText:u=null,editorIntent:l="steer",remote:a,gapAbove:h=!0}){let{stdout:c}=_(),o=c?.columns??80,v=o<U,g=K(e,!!a),p=R(e,!!a),H=G[e.kind],S=d=>r&&n===d?(0,t.jsx)(s,{color:f.assuranceAccent,children:"\u276F"}):" ",b=e.impact,k=a?e.kind==="MODIFY"?Q(e.tests??0):null:b&&"stale_refs"in b&&b.stale_refs.length>0?`${e.kind==="ARCHIVE"?"retiring leaves":"approving marks"} ${b.stale_refs.length} item(s) stale`+((b.direct_refs?.length??0)>0?` \u2014 ${b.direct_refs.length} directly touched: ${b.direct_refs.join(", ")}`:""):b&&"design_children"in b?`${e.kind==="REVIEW"?"archiving drops":"merging folds"} ${b.design_children} design child(ren)`:null,T=e.provenance&&e.provenance!==e.why?e.provenance:a?null:e.origin??null,B=a?[{label:"change",text:e.why},...T?[{label:"from",text:T,dimmer:!0}]:[],...k?[{label:"tests",text:k}]:[]]:[{label:"why",text:e.why},...T?[{label:"from",text:T,dimmer:!0}]:[],...e.tier?[{label:"match",text:e.tier,dimmer:!0}]:[],...k?[{label:"impact",text:k}]:[]],E=Math.max(...B.map(d=>d.label.length)),A=a?`? review the changes from ${$(a.source)}`:"? reconcile",y=a?`${i.n} of ${i.of}`:`item ${i.n} of ${i.of}`,W=(0,t.jsxs)(m,{flexDirection:"column",children:[(0,t.jsx)(m,{paddingLeft:2,children:(0,t.jsxs)(s,{bold:!0,children:[(0,t.jsx)(s,{color:H.color,children:a?X(e,a.source):`[${e.kind}]`}),` ${a?M(e):j(e.title)}`]})}),B.map((d,w)=>a?(0,t.jsxs)(m,{paddingLeft:2,children:[(0,t.jsx)(m,{flexShrink:0,width:E+2,children:(0,t.jsx)(s,{color:f.dim,children:d.label})}),(0,t.jsx)(m,{flexGrow:1,children:(0,t.jsx)(s,{color:d.dimmer?f.dim:void 0,children:d.text})})]},`f-${w}`):(0,t.jsx)(m,{paddingLeft:2,children:(0,t.jsxs)(s,{children:[(0,t.jsx)(s,{color:f.dim,children:`${d.label.padEnd(E)} `}),(0,t.jsx)(s,{color:d.dimmer?f.dim:void 0,children:d.text})]})},`f-${w}`)),e.diffSummary?(0,t.jsx)(m,{paddingLeft:2,children:(0,t.jsx)(s,{color:f.dim,children:e.diffSummary})}):(e.diff??[]).map((d,w)=>(0,t.jsx)(m,{paddingLeft:4,children:(0,t.jsx)(s,{color:d.op==="-"?"red":"green",children:`${d.op==="-"?"\u2212":"+"} ${d.field==="criteria"?a?"acceptance criterion":"criterion":d.field}: ${d.text}`})},`d-${w}`)),(a?[]:e.citeLines??[]).map((d,w)=>(0,t.jsx)(m,{paddingLeft:2,children:(0,t.jsx)(s,{color:f.dim,children:d})},`c-${w}`)),(0,t.jsx)(s,{children:" "}),g.map((d,w)=>(0,t.jsxs)(s,{children:[S(w),` ${w+1}. ${d.label}`,(0,t.jsx)(s,{color:f.dim,children:` \u2014 ${d.detail}`})]},`o-${w}`)),p!==null||u&&l==="because"?u?(0,t.jsxs)(m,{flexDirection:"column",children:[(0,t.jsxs)(m,{children:[(0,t.jsxs)(s,{children:[(0,t.jsx)(s,{color:f.assuranceAccent,children:"\u276F"})," ",(0,t.jsx)(s,{color:f.dim,children:"\u270E "})]}),(0,t.jsx)(P,{value:u.value,onChange:u.onChange,onSubmit:u.onSubmit,onCancel:u.onCancel,placeholder:l==="because"?"why archive it?":l==="adjust"?"tell me what to change":"say what to adjust"})]}),(0,t.jsx)(s,{color:f.muted,children:l==="because"?" submits as: archive \xB7 your reason goes on the record":l==="adjust"?" the agent looks at this change again, with your words":e.kind==="PAIR"?" submits as: defer \xB7 your note parks with the card (it re-offers)":" submits as: approve \xB7 your words steer the re-design"})]}):p!==null?(0,t.jsxs)(s,{children:[S(p)," ",(0,t.jsx)(s,{color:f.dim,children:l==="adjust"?"\u270E adjust \u2014 tell me what to change":e.kind==="PAIR"?"\u270E defer with a note \u2014 say what you noticed":"\u270E approve with changes \u2014 say what to adjust"})]}):null:null]});if(v)return(0,t.jsxs)(m,{marginTop:h?1:0,marginBottom:1,flexDirection:"column",children:[(0,t.jsx)(s,{bold:!0,color:f.assuranceAccent,children:A}),(0,t.jsx)(s,{color:f.dim,children:y}),W]});let V=Math.max(2,Math.min(o-1,100)-A.length-y.length);return(0,t.jsxs)(m,{marginTop:h?1:0,marginBottom:1,flexDirection:"column",children:[(0,t.jsxs)(s,{children:[(0,t.jsx)(s,{bold:!0,color:f.assuranceAccent,children:A})," ".repeat(V),(0,t.jsx)(s,{color:f.dim,children:y})]}),(0,t.jsx)(s,{children:" "}),W]})}function fe(e,i){let n=["\u2191\u2193 select","\u23CE confirm"];return e.multi_select&&n.push("space toggle"),i.batchCount>1&&n.push("\u2190 \u2192 questions"),(e.allow_free_text||e.options.some(r=>r.input===!0))&&n.push("\u270E type your own"),i.canAttach&&n.push("@ attach a file or URL"),i.escBack&&n.push("esc back"),{keys:n}}function pe(e,i){let n=["\u2191\u2193 select","\u23CE confirm"];return e.some(r=>r.free)&&n.push("\u270E type your own"),i.escBack&&n.push("esc back"),{keys:n}}function he(e){let i=["\u2191\u2193 select","\u23CE confirm","1-9 verdict"];return R(e)!==null&&i.push("type = adjust"),i.push("esc \xB7 nothing to undo"),{keys:i}}export{J as a,Z as b,ne as c,N as d,K as e,R as f,de as g,fe as h,pe as i,he as j};
2
+ import{b as O,c as P}from"./chunk-SMXABALN.js";import{b as I,c as L}from"./chunk-BWXLZS5O.js";import{a as M,b as $}from"./chunk-3V4J65GN.js";import{oa as j}from"./chunk-PI7OXS62.js";import{a as D}from"./chunk-HCBYKLMW.js";import{a as m,b as s,k as _}from"./chunk-33DWJV67.js";import{a as q}from"./chunk-6YGTRKDT.js";import{z as f}from"./chunk-FAMQ4DHU.js";import{e as C}from"./chunk-UR6MHSHU.js";var F={"acceptance criteria":1,scenarios:2,"acceptance criteria + exercises":3,"tests + gaps":4,tests:4};function J(e,i,n={}){let r=[],u=L(e.turns).entries.length;if(i==="design"){let c;for(let g=e.ledger.length-1;g>=0;g--){let p=e.ledger[g];if(p.kind==="banner"&&p.text.startsWith("designing: ")){c=p.text.slice(11);break}}let o=n.remote&&!c?e.ledger.find(g=>g.kind==="header")?.phase:void 0,v=c?F[c]:o;v&&r.push(`phase ${v}/4`),u>0&&!n.remote&&r.push(`${u} item${u===1?"":"s"} this session`)}else u>0&&!n.remote&&r.push(`${u} saved as draft${u===1?"":"s"}`);let l=n.remote?n.added??I(e.turns):0,a=n.remote?n.updated??0:0;(l>0||a>0)&&r.push([l>0?`${l} added`:"",a>0?`${a} updated`:"","not saved yet"].filter(Boolean).join(" \xB7 "));let h=e.pending?e.pending.resolution.filter(c=>!c).length:0;return h>0&&r.push(`${h} question${h===1?"":"s"} pending`),e.credits&&r.push(`${e.credits.total.toFixed(1)} credits`),{items:r}}function Z(e,i){let n=[],r=e.applied+e.committed+e.retired;n.push(`${r} applied`),n.push(`${i} to decide`);let u=[];return e.skipped>0&&u.push(`${e.skipped} skipped`),e.deferred>0&&u.push(`${e.deferred} deferred`),e.failed>0&&u.push(`${e.failed} failed`),{items:[...n,...u]}}var x=C(q(),1);function ne({onToggleThinking:e,onCtrlC:i,explorer:n,panel:r}){let l=(0,x.useRef)(null),a=(0,x.useRef)(""),h=()=>{l.current&&clearTimeout(l.current),l.current=null,a.current=""};return(0,x.useEffect)(()=>h,[]),O((c,o)=>{if(o.ctrl&&c==="t"){e();return}if(o.ctrl&&c==="c"){i();return}if(!o.ctrl&&c.includes("")){i();return}if(!o.ctrl&&c.includes("")){e();return}if(n&&n.isOpen()){let v=()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{h(),n.onBack()},150)};if(l.current){if(o.upArrow||o.downArrow||o.return){h(),o.return?n.onEnter():n.onMove(o.upArrow?-1:1);return}if(a.current+=c,a.current==="["){v();return}let g=a.current;h();let p=/^\[([ABCD])/.exec(g);if(p){(p[1]==="A"||p[1]==="B")&&n.onMove(p[1]==="A"?-1:1);return}n.onBack();return}if(o.upArrow){n.onMove(-1);return}if(o.downArrow){n.onMove(1);return}if(o.return){n.onEnter();return}if(o.escape){a.current="",v();return}return}if(r&&r.isFocused()){let v=()=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{h(),r.onBack()},150)};if(l.current){if(o.upArrow||o.downArrow||o.return||o.leftArrow||o.rightArrow){h(),o.return?r.onSelect():o.leftArrow?r.onLeft?.():o.rightArrow?r.onRight?.():r.onMove(o.upArrow?-1:1);return}if(a.current+=c,a.current==="["){v();return}let g=a.current;h();let p=/^\[([ABCD])/.exec(g);if(p){p[1]==="A"||p[1]==="B"?r.onMove(p[1]==="A"?-1:1):p[1]==="C"?r.onRight?.():r.onLeft?.();return}r.onBack();return}if(o.upArrow){r.onMove(-1);return}if(o.downArrow){r.onMove(1);return}if(o.leftArrow){r.onLeft?.();return}if(o.rightArrow){r.onRight?.();return}if(o.return){r.onSelect();return}if(o.escape){a.current="",v();return}if(/^[1-9]$/.test(c)){r.onDigit(Number(c));return}if(o.tab){r.onTab?.();return}if(c===" "&&r.isMulti()){r.onSpace();return}if(c&&!o.ctrl&&!o.meta){r.onType(c);return}return}}),null}var t=C(D(),1);function N(e,i=!1){return i?Y(e):e.kind==="REVIEW"?[{v:"approve",label:"approve",detail:"mark it reviewed and trusted"},{v:"archive",label:"archive",detail:"reject it \u2014 asks for a reason; impact shown above"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="PAIR"?[{v:"merge",label:"merge",detail:"duplicate \u2014 fold into the older item (it stays unreviewed)"},{v:"keep_both",label:"keep both",detail:"genuinely distinct \u2014 promote both"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="ARCHIVE"?[{v:"archive",label:"retire",detail:"hidden from now on; history is kept and it can be reverted"},{v:"skip",label:"skip",detail:"keep it \u2014 decided, never re-offered"},{v:"defer",label:"defer",detail:"not now \u2014 the plan re-offers it"}]:e.heldPayload?[{v:"approve",label:"approve update",detail:"commit the held payload \u2014 impact preview above"},{v:"skip",label:"keep current",detail:"drop the held payload (the owner's disk state stays untouched)"},{v:"defer",label:"defer",detail:"not now \u2014 stays held"}]:[{v:"approve",label:"approve",detail:e.kind==="ADD"?"commit + design it":"commit the updated version (old\u2192new redirect)"},{v:"skip",label:e.origin==="content-change"?"reject":"skip",detail:e.origin==="content-change"?"drop the staged proposal \u2014 nothing committed":"leave it as is"},{v:"defer",label:"defer",detail:"not now \u2014 the plan keeps it staged"}]}var Q=e=>e===0?null:e===1?"its test was designed for the old version":`its ${e} tests were designed for the old version`;function Y(e){return e.heldPayload?[{v:"approve",label:"approve the change",detail:"the use-case takes the new version"},{v:"skip",label:"keep it as it is",detail:"the change is dropped"},{v:"defer",label:"decide later",detail:"it keeps waiting"}]:e.kind==="ARCHIVE"?[...e.archiveRefused?[]:[{v:"archive",label:"archive",detail:"it's hidden from the project from now on"}],{v:"skip",label:"keep it",detail:"it stays as it is; this may be suggested again"},{v:"defer",label:"defer",detail:"decide later; it's kept as an open question"}]:e.kind==="ADD"?[{v:"approve",label:"approve",detail:"add it to this session"},{v:"skip",label:"reject",detail:"leave it out; it may be suggested again"},{v:"defer",label:"defer",detail:"leave it out for now, as an open question"}]:[{v:"approve",label:"approve",detail:"the use-case takes the new version"},{v:"skip",label:"reject",detail:"it stays as it is; the change may be suggested again"},{v:"defer",label:"defer",detail:"it stays as it is for now, as an open question"}]}function K(e,i=!1){let n=N(e,i);return e.viewDiff&&n.push({v:"view_diff",label:"view diff",detail:i?"the whole change, old \u2192 new":"full old \u2192 new"}),n}function R(e,i=!1){return e.kind==="ARCHIVE"?null:K(e,i).length}var G={ADD:{color:f.green??"green"},MODIFY:{color:"yellow"},ARCHIVE:{color:f.red},REVIEW:{color:"cyan"},PAIR:{color:"magenta"}},U=60,X=(e,i)=>`${e.heldPayload?"changed earlier":e.kind==="ADD"?"new":e.kind==="ARCHIVE"?`no longer in ${$(i)}`:"changed"}:`;function de({card:e,position:i,sel:n=0,focused:r=!1,freeText:u=null,editorIntent:l="steer",remote:a,gapAbove:h=!0}){let{stdout:c}=_(),o=c?.columns??80,v=o<U,g=K(e,!!a),p=R(e,!!a),H=G[e.kind],S=d=>r&&n===d?(0,t.jsx)(s,{color:f.assuranceAccent,children:"\u276F"}):" ",b=e.impact,k=a?e.kind==="MODIFY"?Q(e.tests??0):null:b&&"stale_refs"in b&&b.stale_refs.length>0?`${e.kind==="ARCHIVE"?"retiring leaves":"approving marks"} ${b.stale_refs.length} item(s) stale`+((b.direct_refs?.length??0)>0?` \u2014 ${b.direct_refs.length} directly touched: ${b.direct_refs.join(", ")}`:""):b&&"design_children"in b?`${e.kind==="REVIEW"?"archiving drops":"merging folds"} ${b.design_children} design child(ren)`:null,T=e.provenance&&e.provenance!==e.why?e.provenance:a?null:e.origin??null,B=a?[{label:"change",text:e.why},...T?[{label:"from",text:T,dimmer:!0}]:[],...k?[{label:"tests",text:k}]:[]]:[{label:"why",text:e.why},...T?[{label:"from",text:T,dimmer:!0}]:[],...e.tier?[{label:"match",text:e.tier,dimmer:!0}]:[],...k?[{label:"impact",text:k}]:[]],E=Math.max(...B.map(d=>d.label.length)),A=a?`? review the changes from ${$(a.source)}`:"? reconcile",y=a?`${i.n} of ${i.of}`:`item ${i.n} of ${i.of}`,W=(0,t.jsxs)(m,{flexDirection:"column",children:[(0,t.jsx)(m,{paddingLeft:2,children:(0,t.jsxs)(s,{bold:!0,children:[(0,t.jsx)(s,{color:H.color,children:a?X(e,a.source):`[${e.kind}]`}),` ${a?M(e):j(e.title)}`]})}),B.map((d,w)=>a?(0,t.jsxs)(m,{paddingLeft:2,children:[(0,t.jsx)(m,{flexShrink:0,width:E+2,children:(0,t.jsx)(s,{color:f.dim,children:d.label})}),(0,t.jsx)(m,{flexGrow:1,children:(0,t.jsx)(s,{color:d.dimmer?f.dim:void 0,children:d.text})})]},`f-${w}`):(0,t.jsx)(m,{paddingLeft:2,children:(0,t.jsxs)(s,{children:[(0,t.jsx)(s,{color:f.dim,children:`${d.label.padEnd(E)} `}),(0,t.jsx)(s,{color:d.dimmer?f.dim:void 0,children:d.text})]})},`f-${w}`)),e.diffSummary?(0,t.jsx)(m,{paddingLeft:2,children:(0,t.jsx)(s,{color:f.dim,children:e.diffSummary})}):(e.diff??[]).map((d,w)=>(0,t.jsx)(m,{paddingLeft:4,children:(0,t.jsx)(s,{color:d.op==="-"?"red":"green",children:`${d.op==="-"?"\u2212":"+"} ${d.field==="criteria"?a?"acceptance criterion":"criterion":d.field}: ${d.text}`})},`d-${w}`)),(a?[]:e.citeLines??[]).map((d,w)=>(0,t.jsx)(m,{paddingLeft:2,children:(0,t.jsx)(s,{color:f.dim,children:d})},`c-${w}`)),(0,t.jsx)(s,{children:" "}),g.map((d,w)=>(0,t.jsxs)(s,{children:[S(w),` ${w+1}. ${d.label}`,(0,t.jsx)(s,{color:f.dim,children:` \u2014 ${d.detail}`})]},`o-${w}`)),p!==null||u&&l==="because"?u?(0,t.jsxs)(m,{flexDirection:"column",children:[(0,t.jsxs)(m,{children:[(0,t.jsxs)(s,{children:[(0,t.jsx)(s,{color:f.assuranceAccent,children:"\u276F"})," ",(0,t.jsx)(s,{color:f.dim,children:"\u270E "})]}),(0,t.jsx)(P,{value:u.value,onChange:u.onChange,onSubmit:u.onSubmit,onCancel:u.onCancel,placeholder:l==="because"?"why archive it?":l==="adjust"?"tell me what to change":"say what to adjust"})]}),(0,t.jsx)(s,{color:f.muted,children:l==="because"?" submits as: archive \xB7 your reason goes on the record":l==="adjust"?" the agent looks at this change again, with your words":e.kind==="PAIR"?" submits as: defer \xB7 your note parks with the card (it re-offers)":" submits as: approve \xB7 your words steer the re-design"})]}):p!==null?(0,t.jsxs)(s,{children:[S(p)," ",(0,t.jsx)(s,{color:f.dim,children:l==="adjust"?"\u270E adjust \u2014 tell me what to change":e.kind==="PAIR"?"\u270E defer with a note \u2014 say what you noticed":"\u270E approve with changes \u2014 say what to adjust"})]}):null:null]});if(v)return(0,t.jsxs)(m,{marginTop:h?1:0,marginBottom:1,flexDirection:"column",children:[(0,t.jsx)(s,{bold:!0,color:f.assuranceAccent,children:A}),(0,t.jsx)(s,{color:f.dim,children:y}),W]});let V=Math.max(2,Math.min(o-1,100)-A.length-y.length);return(0,t.jsxs)(m,{marginTop:h?1:0,marginBottom:1,flexDirection:"column",children:[(0,t.jsxs)(s,{children:[(0,t.jsx)(s,{bold:!0,color:f.assuranceAccent,children:A})," ".repeat(V),(0,t.jsx)(s,{color:f.dim,children:y})]}),(0,t.jsx)(s,{children:" "}),W]})}function fe(e,i){let n=["\u2191\u2193 select","\u23CE confirm"];return e.multi_select&&n.push("space toggle"),i.batchCount>1&&n.push("\u2190 \u2192 questions"),(e.allow_free_text||e.options.some(r=>r.input===!0))&&n.push("\u270E type your own"),i.canAttach&&n.push("@ attach a file or URL"),i.escBack&&n.push("esc back"),{keys:n}}function pe(e,i){let n=["\u2191\u2193 select","\u23CE confirm"];return e.some(r=>r.free)&&n.push("\u270E type your own"),i.escBack&&n.push("esc back"),{keys:n}}function he(e){let i=["\u2191\u2193 select","\u23CE confirm","1-9 verdict"];return R(e)!==null&&i.push("type = adjust"),i.push("esc \xB7 nothing to undo"),{keys:i}}export{J as a,Z as b,ne as c,N as d,K as e,R as f,de as g,fe as h,pe as i,he as j};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-HCBYKLMW.js";import{a as m,b as r,i as d}from"./chunk-33DWJV67.js";import{a as u}from"./chunk-6YGTRKDT.js";import{y as o}from"./chunk-D36V5OX6.js";import{e as s}from"./chunk-UR6MHSHU.js";var l=s(u(),1);var e=s(a(),1);function T({message:t,confirmLabel:c,choice:n}){return(0,e.jsxs)(m,{flexDirection:"column",borderStyle:"round",borderColor:o.dim,paddingX:1,children:[(0,e.jsx)(r,{bold:!0,children:t}),(0,e.jsxs)(m,{marginTop:1,children:[(0,e.jsx)(r,{color:n==="yes"?o.red:o.dim,children:`\u276F ${c}`}),(0,e.jsx)(r,{children:" "}),(0,e.jsx)(r,{color:n==="no"?o.green:o.dim,children:"\u276F No"})]}),(0,e.jsx)(r,{color:o.dim,children:"\u2190 \u2192 choose \xB7 \u21B5 confirm \xB7 esc cancel"})]})}function y({message:t,onConfirm:c,onCancel:n,confirmLabel:p="Yes, end"}){let[f,g]=(0,l.useState)("no");return d((b,i)=>{(i.leftArrow||i.rightArrow)&&g(x=>x==="yes"?"no":"yes"),i.return&&(f==="yes"?c:n)(),i.escape&&n()}),(0,e.jsx)(T,{message:t,confirmLabel:p,choice:f})}export{y as a};
2
+ import{a}from"./chunk-HCBYKLMW.js";import{a as m,b as r,i as d}from"./chunk-33DWJV67.js";import{a as u}from"./chunk-6YGTRKDT.js";import{z as o}from"./chunk-FAMQ4DHU.js";import{e as s}from"./chunk-UR6MHSHU.js";var l=s(u(),1);var e=s(a(),1);function T({message:t,confirmLabel:c,choice:n}){return(0,e.jsxs)(m,{flexDirection:"column",borderStyle:"round",borderColor:o.dim,paddingX:1,children:[(0,e.jsx)(r,{bold:!0,children:t}),(0,e.jsxs)(m,{marginTop:1,children:[(0,e.jsx)(r,{color:n==="yes"?o.red:o.dim,children:`\u276F ${c}`}),(0,e.jsx)(r,{children:" "}),(0,e.jsx)(r,{color:n==="no"?o.green:o.dim,children:"\u276F No"})]}),(0,e.jsx)(r,{color:o.dim,children:"\u2190 \u2192 choose \xB7 \u21B5 confirm \xB7 esc cancel"})]})}function y({message:t,onConfirm:c,onCancel:n,confirmLabel:p="Yes, end"}){let[f,g]=(0,l.useState)("no");return d((b,i)=>{(i.leftArrow||i.rightArrow)&&g(x=>x==="yes"?"no":"yes"),i.return&&(f==="yes"?c:n)(),i.escape&&n()}),(0,e.jsx)(T,{message:t,confirmLabel:p,choice:f})}export{y as a};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as v}from"./chunk-34R7BNZ2.js";import{a as S}from"./chunk-QSCXXNC2.js";import{n as g}from"./chunk-NC7D7GOM.js";import{a as u,b as d}from"./chunk-D36V5OX6.js";import{existsSync as P}from"fs";import{join as T}from"path";import{mkdirSync as b,rmSync as h,writeFileSync as k}from"fs";import{join as E,resolve as A}from"path";import{join as w}from"path";function m(){return process.env.KANE_CLI_WIRE_BASE_DIR||d}function J(e){return w(m(),"sessions",`testrun-${e}`)}function y(e=m()){return E(e,"sessions","active")}function _(e,r){return E(y(r),`${e}.json`)}function x(e){let r=e.pid??process.pid,n=_(r,e.baseDir);try{b(y(e.baseDir),{recursive:!0}),k(n,JSON.stringify({pid:r,cwd:process.cwd(),surface:e.surface,session_dir:A(e.sessionDir),started:new Date().toISOString(),cli_version:u,host_agent:S()},null,2)+`
2
+ import{b as v}from"./chunk-CCOD4GQJ.js";import{a as S}from"./chunk-QSCXXNC2.js";import{n as g}from"./chunk-UJLULWSR.js";import{a as u,b as d}from"./chunk-FAMQ4DHU.js";import{existsSync as P}from"fs";import{join as T}from"path";import{mkdirSync as b,rmSync as h,writeFileSync as k}from"fs";import{join as E,resolve as A}from"path";import{join as w}from"path";function m(){return process.env.KANE_CLI_WIRE_BASE_DIR||d}function J(e){return w(m(),"sessions",`testrun-${e}`)}function y(e=m()){return E(e,"sessions","active")}function _(e,r){return E(y(r),`${e}.json`)}function x(e){let r=e.pid??process.pid,n=_(r,e.baseDir);try{b(y(e.baseDir),{recursive:!0}),k(n,JSON.stringify({pid:r,cwd:process.cwd(),surface:e.surface,session_dir:A(e.sessionDir),started:new Date().toISOString(),cli_version:u,host_agent:S()},null,2)+`
3
3
  `)}catch{}return n}function f(e=process.pid,r){try{h(_(e,r),{force:!0})}catch{}}var R={run:"run_end",testmd:"test_md_done",testrun:"testrun_done",explore:"done"};import{appendFileSync as I,mkdirSync as N}from"fs";import{dirname as O}from"path";function D(e){let r=!1;return{path:e,append(n){try{r||(N(O(e),{recursive:!0}),r=!0),I(e,n+`
4
4
  `)}catch{}}}}function W(e,r=()=>new Date){let{v:n,ts:c,...i}=e;return{...i,v:1,ts:typeof c=="string"?c:r().toISOString()}}function V(e){let r=e.stdout??(t=>{process.stdout.write(t)}),n=R[e.surface],c=!1,i=null,o=null,p=[],l=()=>{if(!(o||!i||!P(i))){o=D(T(i,"events.ndjson"));for(let t of p)o.append(t);p=[];try{e.onAttach?.(i)}catch{}}};return{emit(t){if(c)return;let a=v(JSON.stringify(W(t,e.now)));r(a+`
5
5
  `),l(),o?o.append(a):p.push(a),t.type===n&&(c=!0,p=[])},attachSessionDir(t){i=t,l()},setTerminal(t){n=t},get logPath(){return o?o.path:null}}}var s=null;function j(e){return r=>{x({surface:e,sessionDir:r}),g("wire-active-run",()=>f()),process.once("exit",()=>f())}}function se(e,r){return s=V({surface:e,cliVersion:u,onAttach:r??j(e)}),s.emit({type:"stream_start",cli_version:u,surface:e,pid:process.pid}),s}function ce(){return s}function ue(e){if(s){s.emit(e);return}process.stdout.write(JSON.stringify(W(e))+`
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as ue,c as fe}from"./chunk-XQMWHPZI.js";import{a as ae}from"./chunk-DDZLCAEO.js";import{k as re,l as oe}from"./chunk-HCJ2N3XB.js";import{a as C,b as k}from"./chunk-NLZZLANH.js";import{c as de,d as ce,f as le}from"./chunk-EECDDDSB.js";import{B as A,Ba as ie,Ha as f,M as K,T as H,V as x,W as q,X as O,Z as B,ba as G,fa as z,ga as J,ia as Q,ja as V,ka as X,ma as Y,na as Z,pa as P,qa as ee,ra as ne,s as W,ua as te,va as se,y as D,z as U}from"./chunk-7HMSMAUG.js";import{a as w}from"./chunk-I2MC6VVX.js";import{a as S}from"./chunk-RPRXRKKR.js";import{oa as L}from"./chunk-UEE3RZN4.js";import{a as p}from"./chunk-FOJHSG5M.js";import{y as I}from"./chunk-D36V5OX6.js";var ve={usecase:"use_case",scenario:"scenario",test:"test",ac:"acceptance_criterion",source:"source"},b={use_case:"the use case",scenario:"the scenario",test:"the test",acceptance_criterion:"the acceptance criterion",source:"the document"};async function pe(e,n,s,i=()=>{}){let r=e,t=r?.entity;if(typeof t!="string"||t==="")return null;let c=async d=>{if(typeof d!="string")return null;try{let a=await n.mainNode(s,d),o=ve[a.label];if(!o)return null;let l=o==="acceptance_criterion"?a.content.text:a.content.title;return{kind:o,id:a.name,title:typeof l=="string"&&l!==""?l:null}}catch(a){return i(`the conflict's node couldn't be read, so the save's refusal names nothing: ${k(a)}`),null}};if(r?.kind==="source")return{kind:"source",id:t,title:typeof r.fileName=="string"&&r.fileName!==""?r.fileName:null};if(r?.kind==="edge"){let[d,a]=r.ends?await Promise.all([c(r.ends.from),c(r.ends.to)]):[null,null];return d||a?{kind:"link",from:d,to:a}:null}if(r?.kind==="node"||t.startsWith("sha256:"))return c(t);try{return(await n.sources(s)).some(d=>d.sourceId===t)?{kind:"source",id:t,title:null}:null}catch(d){return i(`the project's sources couldn't be read, so the save's refusal names nothing: ${k(d)}`),null}}function $(e){if(e.kind==="source")return e.title?`${b.source} "${e.title}"`:"a document this session reads";let n=e.id?L(e.id):null;return e.kind==="acceptance_criterion"&&n?`${b[e.kind]} ${n}`:e.title?`${b[e.kind]} "${e.title}"`:n?`${b[e.kind]} ${n}`:b[e.kind]}function me(e,n,s,i=[]){return{code:"PROJECT_CHANGED",message:`not saved \u2014 another save also changed ${e.kind!=="link"?$(e):e.from&&e.to?`the link between ${$(e.from)} and ${$(e.to)}`:`a link to ${$(e.from??e.to)}`}`,detail:`this session can't be saved now, so ${Z(n)} won't reach the project`,remedy:V(s,i)}}function ke(e){let n=le(e);return n!==null?de(n,S()):ce("save",S())}async function ge(e,n){if(n.verb!=="evolve")return{notUpdated:[],stillStale:0,repins:new Map};let s=await e.sessionLog?.().catch(()=>[])??[],i=s.filter(t=>t.kind==="evolve_not_updated").at(-1)?.body,r=t=>Array.isArray(t)?t.filter(c=>typeof c=="string"):[];return{notUpdated:r(i?.use_cases),stillStale:r(i?.still_stale).length,repins:q(s)}}function _(e,n){let s=n==="agent"?" --mode agent":"";return e.verb==="evolve"?`kane-cli maintain evolve ${e.useCase??"--from-stale"}${s}`:e.verb==="design"&&e.useCase?`kane-cli design tests --use-case ${e.useCase}${s}`:`kane-cli context extract${s}`}async function Ke(e){let n={...e,trace:e.trace??ke(e.sid)},s=n.mode==="agent",i=n.print??(c=>{process.stdout.write(`${c}
2
+ import{a as ue,c as fe}from"./chunk-PEUIHME2.js";import{a as ae}from"./chunk-RDAIOJCR.js";import{k as re,l as oe}from"./chunk-LXCTV75T.js";import{a as C,b as k}from"./chunk-TAY7J5VS.js";import{c as de,d as ce,f as le}from"./chunk-2COXO5LQ.js";import{B as A,Ba as ie,Ha as f,M as K,T as H,V as x,W as q,X as O,Z as B,ba as G,fa as z,ga as J,ia as Q,ja as V,ka as X,ma as Y,na as Z,pa as P,qa as ee,ra as ne,s as W,ua as te,va as se,y as D,z as U}from"./chunk-H4TIVILC.js";import{a as S}from"./chunk-RQKMSNEU.js";import{a as w}from"./chunk-4C7WVQOD.js";import{oa as L}from"./chunk-PI7OXS62.js";import{a as p}from"./chunk-FOJHSG5M.js";import{z as I}from"./chunk-FAMQ4DHU.js";var ve={usecase:"use_case",scenario:"scenario",test:"test",ac:"acceptance_criterion",source:"source"},b={use_case:"the use case",scenario:"the scenario",test:"the test",acceptance_criterion:"the acceptance criterion",source:"the document"};async function pe(e,n,s,i=()=>{}){let r=e,t=r?.entity;if(typeof t!="string"||t==="")return null;let c=async d=>{if(typeof d!="string")return null;try{let a=await n.mainNode(s,d),o=ve[a.label];if(!o)return null;let l=o==="acceptance_criterion"?a.content.text:a.content.title;return{kind:o,id:a.name,title:typeof l=="string"&&l!==""?l:null}}catch(a){return i(`the conflict's node couldn't be read, so the save's refusal names nothing: ${k(a)}`),null}};if(r?.kind==="source")return{kind:"source",id:t,title:typeof r.fileName=="string"&&r.fileName!==""?r.fileName:null};if(r?.kind==="edge"){let[d,a]=r.ends?await Promise.all([c(r.ends.from),c(r.ends.to)]):[null,null];return d||a?{kind:"link",from:d,to:a}:null}if(r?.kind==="node"||t.startsWith("sha256:"))return c(t);try{return(await n.sources(s)).some(d=>d.sourceId===t)?{kind:"source",id:t,title:null}:null}catch(d){return i(`the project's sources couldn't be read, so the save's refusal names nothing: ${k(d)}`),null}}function $(e){if(e.kind==="source")return e.title?`${b.source} "${e.title}"`:"a document this session reads";let n=e.id?L(e.id):null;return e.kind==="acceptance_criterion"&&n?`${b[e.kind]} ${n}`:e.title?`${b[e.kind]} "${e.title}"`:n?`${b[e.kind]} ${n}`:b[e.kind]}function me(e,n,s,i=[]){return{code:"PROJECT_CHANGED",message:`not saved \u2014 another save also changed ${e.kind!=="link"?$(e):e.from&&e.to?`the link between ${$(e.from)} and ${$(e.to)}`:`a link to ${$(e.from??e.to)}`}`,detail:`this session can't be saved now, so ${Z(n)} won't reach the project`,remedy:V(s,i)}}function ke(e){let n=le(e);return n!==null?de(n,S()):ce("save",S())}async function ge(e,n){if(n.verb!=="evolve")return{notUpdated:[],stillStale:0,repins:new Map};let s=await e.sessionLog?.().catch(()=>[])??[],i=s.filter(t=>t.kind==="evolve_not_updated").at(-1)?.body,r=t=>Array.isArray(t)?t.filter(c=>typeof c=="string"):[];return{notUpdated:r(i?.use_cases),stillStale:r(i?.still_stale).length,repins:q(s)}}function _(e,n){let s=n==="agent"?" --mode agent":"";return e.verb==="evolve"?`kane-cli maintain evolve ${e.useCase??"--from-stale"}${s}`:e.verb==="design"&&e.useCase?`kane-cli design tests --use-case ${e.useCase}${s}`:`kane-cli context extract${s}`}async function Ke(e){let n={...e,trace:e.trace??ke(e.sid)},s=n.mode==="agent",i=n.print??(c=>{process.stdout.write(`${c}
3
3
  `)}),r=(c,d)=>(n.trace.line("save_refused",{sid:n.sid,...c.code?{code:c.code}:{},exit:d}),s?n.emit({type:"error",code:c.code,message:c.message,...A(c)}):(re(c),i("")),d),t=!1;try{return await be(n,s,i,r,()=>t=!0)}catch(c){return c instanceof w&&c.retryable?r(t?f.saveUnconfirmed():f.noConnectionToSave(),2):r(f.assuranceOffOr(c,n.projectName,f.saveFailed("your work is")),1)}}async function be(e,n,s,i,r){let t;try{t=await e.person.getSession(e.sid)}catch(u){if(u instanceof w&&u.code==="NOT_FOUND")return i(f.noSuchSession(e.sid),2);throw u}if(t.ended==="failed")return i(f.sessionFailed(e.sid),2);if(t.ended!=="complete")return i(f.notFinished(e.sid,P(t.verb==="design"||t.verb==="evolve"?"design":"extract",e.sid,n)),2);if(t.scope?.state==="finalized")return T(e,t,{},n,s,i,r,!0);let c=await G(e.person,e.projectId,e.sid);if(!z(c,(t.scope?.position??t.basePosition)>t.basePosition))return await e.person.discard(e.sid,t.generation).catch(()=>{}),n?e.onProgress({kind:"save",sid:e.sid,phase:"saved",landed:0}):s(f.nothingToSave),0;let{notUpdated:d,repins:a}=await ge(e,t),o=O(x(t.verb,c),a);if(e.trace?.line("save_check",{sid:e.sid,verb:t.verb,counts:c}),n)return e.onProgress({kind:"save",sid:e.sid,phase:"check",project:e.projectName,counts:c,...d.length>0?{notUpdated:d}:{},...o.replaces?{replaces:o.replaces}:{},...o.keeps?{keeps:o.keeps}:{}}),e.yes?T(e,t,c,n,s,i,r):i(f.confirmRequired(e.sid),2);let l=(await e.person.project(e.projectId))?.mainPosition??null,g=l!==null&&l>t.basePosition;for(let u of ye(e.projectName,o,g))s(u);s("");let m=e.yes||await e.confirm("save this session? (y/N)");return e.yes||s(""),m?T(e,t,c,n,s,i,r):(s(`not saved \u2014 your work is kept in session ${e.sid}`),0)}function ye(e,n,s){return[p.bold(`save this session to "${e}"`),...J(n,s).map(([i,r])=>`${p.dim(` ${i.padEnd(10)}`)}${r}`)]}function we(e,n="",s=process.stdout.columns,i=null,r=null){let t=[];if(e.receipt!==null&&t.push(`${n}${p.green(`\u2714 ${e.receipt}`)}`),i?.line&&t.push(`${n}${p.dim(i.line)}`),i?.replacedHead&&i.replaced){t.push(`${n}${p.dim(i.replacedHead)}`);for(let d of i.replaced){if(t.push(`${n}${p.dim(` ${d.file}`)}`),d.by.length===0)continue;let a=` replaced by ${d.by.length===1?d.by[0]:`${d.by.slice(0,-1).join(", ")} and ${d.by[d.by.length-1]}`}`;!s||n.length+a.length<=s?t.push(`${n}${p.dim(a)}`):d.by.forEach((o,l)=>t.push(`${n}${p.dim(l===0?` replaced by ${o}`:` and ${o}`)}`))}}if(i?.needed){let d=[...D(i.needed,{cwd:process.cwd(),tests:i.needed.tests,indent:0,...s?{columns:s-n.length}:{}}),...U(i.needed.noStartPage,{indent:0})];for(let a of d)t.push(`${n}${p.dim(a)}`)}let c=Re(e.lines,i?.lines??[],r);if(c.length>0){t.push("");let d=a=>s&&!a.startsWith(" kane-cli ")?oe(a,s):a;for(let a of c)t.push(a.tone==="warning"?p.hex(I.amber)(d(a.text)):a.tone==="detail"?p.dim(a.command?$e(a.text,s):a.text):d(a.text));(e.support||i?.support)&&t.push(`if this keeps failing, share this id with support: ${W(e.support?"refused_TEST_MANAGER":"refused_TEST_FILES")}`)}return t}function $e(e,n){let s=e.indexOf("run: kane-cli ");if(!n||e.length<=n||s<0)return e;let i=e.match(/^ */)[0];return`${e.slice(0,s+4)}
4
4
  ${i} ${e.slice(s+5)}`}function Re(e,n,s){if(n.length===0)return e;if(e.length===0)return n;let i=c=>c.text.startsWith("next: "),r=e.findIndex(i),t=n.findIndex(i);return s!==null&&r>=0&&t>=0?[...e.slice(0,r),...n.slice(0,t),{text:s,tone:"plain"},...e.slice(r+1),...n.slice(t+2)]:[...e,{text:"",tone:"plain"},...n]}async function T(e,n,s,i,r,t,c,d=!1){e.onProgress({kind:"save",sid:e.sid,phase:"saving"}),d&&!i&&r(f.savedBefore);let a=o=>{i||r(d?`finishing test cases in Test Manager\u2026 ${o}`:`saving\u2026 ${o}`)};try{c();let o=await e.person.land(e.sid,n.generation),l=n.verb==="design"||n.verb==="reconcile"||n.verb==="evolve"?await fe({person:e.person,projectId:n.projectId,landing:o,cwd:process.cwd()}):null,g=o.testManager?.notCovered?.length?await ue({person:e.person,projectId:n.projectId,landing:o}):void 0;e.trace?.line("save_landed",Ne(e.sid,o,l));let m=B(s),{stillStale:u,repins:R}=await ge(e,n),{changes:M,approves:j,archives:E,removes:F}=s,v=O(x(n.verb,s),R);if(e.onProgress({kind:"save",sid:e.sid,phase:"saved",landed:o.landed,...m>0?{heldChanges:m}:{},...M?{changes:M}:{},...j?{approves:j}:{},...E?{archives:E}:{},...F?{removes:F}:{},...v.replaces?{replaces:v.replaces}:{},...v.keeps?{keeps:v.keeps}:{},...s.uncounted?{uncounted:s.uncounted}:{},...o.testManager!==void 0?{testManager:o.testManager}:{},...g?{sessionUseCases:[...g]}:{},...l!==null?{testFiles:l}:{},...u>0?{stillStale:u}:{}}),!i){let y=ne(o.testManager,e.sid,e.projectName,g,ee(l)),N=l===null?null:te(l,e.sid,d,{testManager:o.testManager});if(d){let h=y.receipt===null&&y.lines.length===0;a(o.testManager?.error?"stopped":h?"nothing left to do":"done"),(y.receipt!==null||N?.line)&&r("")}else{a("saved"),r("");let h=H(v);r(p.green(`\u2714 saved to "${e.projectName}"${h?` \u2014 ${h}`:""}`));for(let he of K(v))r(p.dim(` ${he}`))}for(let h of we(y,"",void 0,N,se(o.testManager,N,e.projectName)))r(h);if(u>0)for(let h of ie.stillOutOfDate(u))r(h);r("")}return 0}catch(o){if(!(o instanceof w))throw o;if(o.retryable)return a("failed"),i||r(""),t(f.saveUnconfirmed(),2);if(o.code==="SESSION_NOT_FINISHED")return a("failed"),i||r(""),t(f.notFinished(e.sid,P(n.verb==="design"||n.verb==="evolve"?"design":"extract",e.sid,i)),2);if(o.code==="SCOPE_BEHIND_HEAD"){let g={kind:"save",sid:e.sid,phase:"behind"},m=await pe(o.extra.conflict,e.person,e.projectId,C("remote-save")),u=Y(n);if(i){let R=u.length>0?{cmd:`${X(u)} --mode agent`,why:"start again from the latest, adding this session's documents again"}:{cmd:_(n,e.mode),why:"start again from the latest"};return e.emit({...ae(g),...m?{conflict:m}:{},next:[R]}),2}return e.onProgress(g),a("failed"),r(""),t(m?me(m,s,_(n,e.mode),u):f.projectChanged(e.projectName,s,_(n,e.mode),u),2)}let l=o.code==="SCOPE_RECORD_REFUSED";return l&&C("remote-save")(`session ${e.sid}: the save was refused: ${k(o)}`),e.onProgress({kind:"save",sid:e.sid,phase:"failed",reason:"not_accepted",...l?{code:"SCOPE_RECORD_REFUSED"}:{}}),i?1:(a("failed"),r(""),t(f.saveFailed(Q(s)),1))}}function Ne(e,n,s){return{sid:e,landed:n.landed,...n.testManager!==void 0?{test_manager:n.testManager===null?null:{error:n.testManager.error??null}}:{},...s!==null?{test_files:s==="unread"?"unread":{written:s.wrote.length,refused:s.refused.length}}:{}}}export{pe as a,me as b,ke as c,Ke as d,we as e,Ne as f};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Be}from"./chunk-54XA5MZH.js";import{a as Te}from"./chunk-QDFY5GGO.js";import{a as ce,b as Pe,c as Ue,d as ae,e as le,f as ue}from"./chunk-IZ65ZPWY.js";import{a as Ne,b as je}from"./chunk-63EKRZKI.js";import{c as Le,d as Ge}from"./chunk-42PALMW2.js";import{g as Me}from"./chunk-ZFMRQ57Y.js";import{i as De}from"./chunk-PZA3BSOE.js";import{a as Ce}from"./chunk-AUJSC7PU.js";import{Ea as Re,Ia as $e,M as L,Na as Ie,Oa as Oe,e as be,sa as Ae,v as U}from"./chunk-UEE3RZN4.js";import{e as ve,n as Se}from"./chunk-DBMW3VUN.js";import{g as xe}from"./chunk-KU3YHPWZ.js";import{a as Ee}from"./chunk-6NFOH4AC.js";import{m as ie}from"./chunk-4I7YN6YY.js";var ht=()=>null;function Zt(e){return e.telemetryIds?(e.provider??ht)({verb:e.verb,contextInstanceId:e.telemetryIds.context_instance_id??null,sessionId:e.telemetryIds.session_id}):e.storeLocalPath}function en(e,t){return e?t(e):"(no local trace)"}function nn(e){let t=process.env.HOME??"";return t&&e.startsWith(t)?`~${e.slice(t.length)}`:e}import{randomBytes as Ut}from"crypto";function de(e,t){let n=Math.min(e.length,t.length),s=0,r=0,c=0;for(let o=0;o<n;o++)s+=e[o]*t[o],r+=e[o]*e[o],c+=t[o]*t[o];return r===0||c===0?0:s/(Math.sqrt(r)*Math.sqrt(c))}function fe(e,t,n){return n*e+(1-n)*t}var ge=.7;var He=e=>e.lines!==void 0?[[e.lines[0],e.lines[1]]]:(e.segments??[]).map(([t,n])=>[t,n]);function Fe(e){let t=[];for(let[n,s]of He(e))for(let r=n;r<=s;r++)t.push(r);return t}function pt(e,t,n,s,r){let c=new Map(t.units.map(a=>[a.id,a]));if(r.some(a=>!c.has(a)))return null;let o=new Map;for(let a of e.units)r.includes(a.id)&&Fe(a).forEach((d,m)=>o.set(d,{unit:a,nth:m}));let g=new Map,u=[],f=!0;for(let a=n;a<=s&&f;a++){let d=o.get(a),m=d===void 0?void 0:c.get(d.unit.id);if(d===void 0||m===void 0||m.text!==d.unit.text){f=!1;break}let h=g.get(m.id);h===void 0&&g.set(m.id,h=Fe(m));let w=h[d.nth];w===void 0?f=!1:u.push(w)}return f&&u.length>0&&u.every((a,d)=>d===0||a===u[d-1]+1)?{anchor:`L${u[0]}-L${u[u.length-1]}`}:{units_at_head:r.flatMap(a=>He(c.get(a)).map(([d,m])=>({unit:a,anchor:`L${d}-L${m}`})))}}function Qe(e){let t=new Map,n=r=>{let c=e.mediaOf(r)?.plugin?.index;if(c===void 0)return null;let o=t.get(c);return o===void 0&&t.set(c,o=Se(e.getBlob(c))),o},s=new Map;return r=>{if(r.type!==xe.DERIVES||!Array.isArray(r.props.units)||r.props.units.length===0)return null;let c=r.props.units,o=e.headOf(String(r.props.source_id)),g=String(r.props.source_cid);if(o==null||o===g)return null;let u=s.get(o);u===void 0&&s.set(o,u=ve(o,w=>e.mediaOf(w)?.plugin));let f=u?.distance.get(g);if(u==null||f===void 0||c.some(w=>(u.touchedAt.get(w)??1/0)<=f))return null;let a=be(String(r.props.anchor));if(a?.kind!=="lines")return null;let d=n(g),m=n(o);if(d===null||m===null)return null;let h=pt(d,m,Math.min(a.a,a.b),Math.max(a.a,a.b),c);return h===null?null:{head:o,...h}}}var _t=["get_node","get_edges","find_by_provenance","match_by_type","stale_nodes","search_similar","search_similar_batch","history"],yt=["source_read","source_grep","source_list"],wt=[..._t,...yt],We=50,Xe=200,me=10,qe=50,Ve=20,kt=200,xt=50;function K(e,t,n){let s=typeof e=="number"&&Number.isFinite(e)?Math.floor(e):t;return Math.max(1,Math.min(s,n))}function M(e,t){let n=e[t];if(typeof n!="string"||n.length===0)throw new x(`param "${t}" must be a non-empty string`);return n}function O(e,t){let n=e[t];if(n==null)return null;if(typeof n!="string")throw new x(`param "${t}" must be a string when present`);return n}var x=class extends Error{},ze=24,bt=10,vt=10;function St(e){let t=e.cursor;if(t==null)return 0;if(typeof t=="string"&&/^\d+$/.test(t))return Number.parseInt(t,10);throw new x(`BAD_CURSOR: cursor ${JSON.stringify(t)} is not a cursor this store minted`)}function Ye(e,t){let n=t.fields;if(!Array.isArray(n)||n.length===0)return e;let s=new Set(n.filter(r=>typeof r=="string"));return e.map(r=>Object.fromEntries(Object.entries(r).filter(([c])=>s.has(c))))}function he(e,t,n=We,s=Xe){let r=St(t),c=K(t.limit,n,s),o=e.slice(r,r+c),g=r+o.length<e.length;return{rows:Ye(o,t),truncated:g,next_cursor:g?String(r+o.length):null}}var Et=e=>e.cursor!=null||e.fields!=null;function W(e,t,n=We){let s=he(e,t,n);return Et(t)||s.truncated?{rows:s.rows,truncated:s.truncated,next_cursor:s.next_cursor}:s.rows}function pe(e,t){let n=e.getNode(t);return n?{cid:t,label:n.label,content:n.content,trust:e.trust.get(t)??null,freshness:e.stale(t)}:null}function Ke(e){return new Set(e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").split(" ").filter(Boolean))}function X(e,...t){let n=Ke(e);if(n.size===0)return 0;let s=e.trim().toLowerCase(),r=0;for(let c of t){let o=Ke(c);if(o.size===0)continue;let g=0;for(let a of n)o.has(a)&&g++;let u=n.size+o.size-g,f=u===0?0:g/u;s&&c.toLowerCase().includes(s)&&(f=Math.max(f,.9)),r=Math.max(r,f)}return r}function At(e,t,n){let s=M(t,"cid"),r=O(t,"type"),c=O(t,"direction")??"both";if(!["out","in","both"].includes(c))throw new x('param "direction" must be out|in|both');let o=e.edgesFrom(s),g=e.edgesInto(s);if(o.length===0&&g.length===0&&!e.hasNode(s)&&![...e.heads.values()].includes(s))throw new x(`${s} names nothing in this project; read the cid again from where it was shown`);let u=[];(c==="out"||c==="both")&&u.push(...o),(c==="in"||c==="both")&&u.push(...g);let f=n===void 0?null:Qe({mediaOf:d=>e.mediaOf(d),getBlob:d=>n.getBlob(d),headOf:d=>e.heads.get(d)}),a=u.filter(d=>r==null||d.type===r).map(d=>{let m=f===null?null:f(d);return m===null?d:"anchor"in m?{...d,props:{...d.props,source_cid:m.head,anchor:m.anchor},pinned:{source_cid:d.props.source_cid,anchor:d.props.anchor}}:{...d,units_at_head:m.units_at_head}});return W(a,t)}function Rt(e,t){let n=M(t,"source_id"),s=e.heads.get(n)??null,r=[];for(let c of e.nodeLabel.keys()){let o=e.derivesInto(c).filter(u=>u.props.source_id===n).map(u=>({source_cid:u.props.source_cid,anchor:u.props.anchor??null}));if(o.length===0)continue;let g=pe(e,c);g&&r.push({...g,pins:o,pinned_to_head:s!=null&&o.some(u=>u.source_cid===s)})}return W(r,t,Xe)}function $t(e,t){let n=M(t,"label"),s=O(t,"trust"),r=O(t,"freshness"),c=[];for(let{cid:o}of e.byLabel(n)){let g=pe(e,o);g&&(s!=null&&g.trust!==s||r!=null&&g.freshness!==r||c.push(g))}return W(c,t)}function It(e,t={}){let n=O(t,"label"),s=e.staleList().map(({cid:r,state:c})=>{let o=e.getNode(r);return{cid:r,state:c,label:o?.label??null,title:o?.content.title??null}}).filter(r=>n==null||r.label===n);return W(s,t)}function Ot(e,t,n){let s=t.extracted,r=O(t,"kind"),c=[];for(let f of[...e.heads.keys()].sort()){let a=e.heads.get(f);if(typeof a!="string")continue;let m=e.mediaOf(a).format;if(r!=null&&m!==r)continue;let h=e.extractedSourceCids.has(a);if(typeof s=="boolean"&&h!==s)continue;let w=0;if(m!=="image"){let y=U(n,e,a);y&&(w=y.toString("utf8").replace(/\n$/,"").split(`
2
+ import{a as Be}from"./chunk-IZ66FKPC.js";import{a as Te}from"./chunk-GLM5UGTF.js";import{a as ce,b as Pe,c as Ue,d as ae,e as le,f as ue}from"./chunk-W5HFUBXD.js";import{a as Ne,b as je}from"./chunk-63EKRZKI.js";import{c as Le,d as Ge}from"./chunk-ZHAMVLQZ.js";import{g as Me}from"./chunk-SIHX5FW5.js";import{i as De}from"./chunk-X7S7IGCV.js";import{a as Ce}from"./chunk-FNUGDPTS.js";import{Ea as Re,Ia as $e,M as L,Na as Ie,Oa as Oe,e as be,sa as Ae,v as U}from"./chunk-PI7OXS62.js";import{e as ve,n as Se}from"./chunk-DBMW3VUN.js";import{g as xe}from"./chunk-KU3YHPWZ.js";import{a as Ee}from"./chunk-ZAQGIC33.js";import{o as ie}from"./chunk-HYJVYYAZ.js";var ht=()=>null;function Zt(e){return e.telemetryIds?(e.provider??ht)({verb:e.verb,contextInstanceId:e.telemetryIds.context_instance_id??null,sessionId:e.telemetryIds.session_id}):e.storeLocalPath}function en(e,t){return e?t(e):"(no local trace)"}function nn(e){let t=process.env.HOME??"";return t&&e.startsWith(t)?`~${e.slice(t.length)}`:e}import{randomBytes as Ut}from"crypto";function de(e,t){let n=Math.min(e.length,t.length),s=0,r=0,c=0;for(let o=0;o<n;o++)s+=e[o]*t[o],r+=e[o]*e[o],c+=t[o]*t[o];return r===0||c===0?0:s/(Math.sqrt(r)*Math.sqrt(c))}function fe(e,t,n){return n*e+(1-n)*t}var ge=.7;var He=e=>e.lines!==void 0?[[e.lines[0],e.lines[1]]]:(e.segments??[]).map(([t,n])=>[t,n]);function Fe(e){let t=[];for(let[n,s]of He(e))for(let r=n;r<=s;r++)t.push(r);return t}function pt(e,t,n,s,r){let c=new Map(t.units.map(a=>[a.id,a]));if(r.some(a=>!c.has(a)))return null;let o=new Map;for(let a of e.units)r.includes(a.id)&&Fe(a).forEach((d,m)=>o.set(d,{unit:a,nth:m}));let g=new Map,u=[],f=!0;for(let a=n;a<=s&&f;a++){let d=o.get(a),m=d===void 0?void 0:c.get(d.unit.id);if(d===void 0||m===void 0||m.text!==d.unit.text){f=!1;break}let h=g.get(m.id);h===void 0&&g.set(m.id,h=Fe(m));let w=h[d.nth];w===void 0?f=!1:u.push(w)}return f&&u.length>0&&u.every((a,d)=>d===0||a===u[d-1]+1)?{anchor:`L${u[0]}-L${u[u.length-1]}`}:{units_at_head:r.flatMap(a=>He(c.get(a)).map(([d,m])=>({unit:a,anchor:`L${d}-L${m}`})))}}function Qe(e){let t=new Map,n=r=>{let c=e.mediaOf(r)?.plugin?.index;if(c===void 0)return null;let o=t.get(c);return o===void 0&&t.set(c,o=Se(e.getBlob(c))),o},s=new Map;return r=>{if(r.type!==xe.DERIVES||!Array.isArray(r.props.units)||r.props.units.length===0)return null;let c=r.props.units,o=e.headOf(String(r.props.source_id)),g=String(r.props.source_cid);if(o==null||o===g)return null;let u=s.get(o);u===void 0&&s.set(o,u=ve(o,w=>e.mediaOf(w)?.plugin));let f=u?.distance.get(g);if(u==null||f===void 0||c.some(w=>(u.touchedAt.get(w)??1/0)<=f))return null;let a=be(String(r.props.anchor));if(a?.kind!=="lines")return null;let d=n(g),m=n(o);if(d===null||m===null)return null;let h=pt(d,m,Math.min(a.a,a.b),Math.max(a.a,a.b),c);return h===null?null:{head:o,...h}}}var _t=["get_node","get_edges","find_by_provenance","match_by_type","stale_nodes","search_similar","search_similar_batch","history"],yt=["source_read","source_grep","source_list"],wt=[..._t,...yt],We=50,Xe=200,me=10,qe=50,Ve=20,kt=200,xt=50;function K(e,t,n){let s=typeof e=="number"&&Number.isFinite(e)?Math.floor(e):t;return Math.max(1,Math.min(s,n))}function M(e,t){let n=e[t];if(typeof n!="string"||n.length===0)throw new x(`param "${t}" must be a non-empty string`);return n}function O(e,t){let n=e[t];if(n==null)return null;if(typeof n!="string")throw new x(`param "${t}" must be a string when present`);return n}var x=class extends Error{},ze=24,bt=10,vt=10;function St(e){let t=e.cursor;if(t==null)return 0;if(typeof t=="string"&&/^\d+$/.test(t))return Number.parseInt(t,10);throw new x(`BAD_CURSOR: cursor ${JSON.stringify(t)} is not a cursor this store minted`)}function Ye(e,t){let n=t.fields;if(!Array.isArray(n)||n.length===0)return e;let s=new Set(n.filter(r=>typeof r=="string"));return e.map(r=>Object.fromEntries(Object.entries(r).filter(([c])=>s.has(c))))}function he(e,t,n=We,s=Xe){let r=St(t),c=K(t.limit,n,s),o=e.slice(r,r+c),g=r+o.length<e.length;return{rows:Ye(o,t),truncated:g,next_cursor:g?String(r+o.length):null}}var Et=e=>e.cursor!=null||e.fields!=null;function W(e,t,n=We){let s=he(e,t,n);return Et(t)||s.truncated?{rows:s.rows,truncated:s.truncated,next_cursor:s.next_cursor}:s.rows}function pe(e,t){let n=e.getNode(t);return n?{cid:t,label:n.label,content:n.content,trust:e.trust.get(t)??null,freshness:e.stale(t)}:null}function Ke(e){return new Set(e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").split(" ").filter(Boolean))}function X(e,...t){let n=Ke(e);if(n.size===0)return 0;let s=e.trim().toLowerCase(),r=0;for(let c of t){let o=Ke(c);if(o.size===0)continue;let g=0;for(let a of n)o.has(a)&&g++;let u=n.size+o.size-g,f=u===0?0:g/u;s&&c.toLowerCase().includes(s)&&(f=Math.max(f,.9)),r=Math.max(r,f)}return r}function At(e,t,n){let s=M(t,"cid"),r=O(t,"type"),c=O(t,"direction")??"both";if(!["out","in","both"].includes(c))throw new x('param "direction" must be out|in|both');let o=e.edgesFrom(s),g=e.edgesInto(s);if(o.length===0&&g.length===0&&!e.hasNode(s)&&![...e.heads.values()].includes(s))throw new x(`${s} names nothing in this project; read the cid again from where it was shown`);let u=[];(c==="out"||c==="both")&&u.push(...o),(c==="in"||c==="both")&&u.push(...g);let f=n===void 0?null:Qe({mediaOf:d=>e.mediaOf(d),getBlob:d=>n.getBlob(d),headOf:d=>e.heads.get(d)}),a=u.filter(d=>r==null||d.type===r).map(d=>{let m=f===null?null:f(d);return m===null?d:"anchor"in m?{...d,props:{...d.props,source_cid:m.head,anchor:m.anchor},pinned:{source_cid:d.props.source_cid,anchor:d.props.anchor}}:{...d,units_at_head:m.units_at_head}});return W(a,t)}function Rt(e,t){let n=M(t,"source_id"),s=e.heads.get(n)??null,r=[];for(let c of e.nodeLabel.keys()){let o=e.derivesInto(c).filter(u=>u.props.source_id===n).map(u=>({source_cid:u.props.source_cid,anchor:u.props.anchor??null}));if(o.length===0)continue;let g=pe(e,c);g&&r.push({...g,pins:o,pinned_to_head:s!=null&&o.some(u=>u.source_cid===s)})}return W(r,t,Xe)}function $t(e,t){let n=M(t,"label"),s=O(t,"trust"),r=O(t,"freshness"),c=[];for(let{cid:o}of e.byLabel(n)){let g=pe(e,o);g&&(s!=null&&g.trust!==s||r!=null&&g.freshness!==r||c.push(g))}return W(c,t)}function It(e,t={}){let n=O(t,"label"),s=e.staleList().map(({cid:r,state:c})=>{let o=e.getNode(r);return{cid:r,state:c,label:o?.label??null,title:o?.content.title??null}}).filter(r=>n==null||r.label===n);return W(s,t)}function Ot(e,t,n){let s=t.extracted,r=O(t,"kind"),c=[];for(let f of[...e.heads.keys()].sort()){let a=e.heads.get(f);if(typeof a!="string")continue;let m=e.mediaOf(a).format;if(r!=null&&m!==r)continue;let h=e.extractedSourceCids.has(a);if(typeof s=="boolean"&&h!==s)continue;let w=0;if(m!=="image"){let y=U(n,e,a);y&&(w=y.toString("utf8").replace(/\n$/,"").split(`
3
3
  `).length)}let k=e.extractionCompleteness.get(f);c.push({source_id:f,kind:m,lines:w,head_cid:a,extracted:h,last_extract_at:k?.at??null,extractor_version:k?.extractor_version??null})}let{rows:o,truncated:g,next_cursor:u}=he(c,t);return{sources:o,truncated:g,next_cursor:u}}function Mt(e,t,n){let s=M(t,"ref"),r=e.resolve(s);if(!r)throw new x(`UNKNOWN_REF: ${s} names nothing in the graph`);let c=r.tip,o=new Map,g=v=>e.nodeLabel.get(v);for(let[v,A]of e.superseded)typeof A=="string"&&A!==v&&!Ae(v,A,g)&&o.set(A,[...o.get(A)??[],v]);let u=[],f=[c],a=new Set;for(;f.length>0;){let v=f.pop();a.has(v)||(a.add(v),u.push(v),f.push(...o.get(v)??[]))}let d=n.recordsSince(null),m=new Map,h=new Map;for(let v of d){for(let A of v.nodes)m.has(A.cid)||m.set(A.cid,v.ts);for(let A of v.supersessions)A.kind==="node"&&h.set(A.old,{by_cid:A.new,reason:A.reason})}let w=u.map(v=>({cid:v,minted_at:m.get(v)??null,superseded_by:h.get(v)?.by_cid??null,reason:h.get(v)?.reason??null,change_note:null})),{rows:k,truncated:y,next_cursor:D}=he(w,t,vt);return{root_logical_id:e.displayNameOf(c),live_tip:e.superseded.has(c)?null:c,truncated:y,next_cursor:D,chain:k}}function Je(e){let t=e.queries;if(!Array.isArray(t)||t.length<1||t.length>ze)throw new x(`param "queries" must be 1..${ze} entries`);return t.map((n,s)=>{if(typeof n!="object"||n===null)throw new x(`queries[${s}] must be an object`);let r=n;if(typeof r.qid!="string"||r.qid.length===0)throw new x(`queries[${s}].qid must be a non-empty string`);if(typeof r.text!="string"||r.text.length===0)throw new x(`queries[${s}].text must be a non-empty string`);return{qid:r.qid,text:r.text,topK:K(r.top_k,me,bt)}})}function Ze(e){let t=[];for(let{cid:n,content:s}of e.byLabel("usecase"))e.superseded.has(n)||t.push({cid:n,title:String(s.title??""),summary:String(s.summary??""),description:String(s.description??"")});return t}function et(e,t,n){let s=Ze(e);return t.map(r=>{let c=[];for(let o of s){let g=n(r,o);g<=0||c.push({cid:o.cid,logical_id:e.displayNameOf(o.cid),title:o.title,score:Math.round(g*1e3)/1e3,trust:e.trust.get(o.cid)??null,superseded:!1})}return c.sort((o,g)=>g.score-o.score||o.cid.localeCompare(g.cid)),{qid:r.qid,truncated:c.length>r.topK,matches:c.slice(0,r.topK)}})}function tt(e,t){let n=Je(t);return{results:et(e,n,(s,r)=>X(s.text,r.title,r.summary,r.description)),scorer:"lexical_fallback"}}function Dt(e,t){let n=M(t,"text"),s=O(t,"label")??"usecase",r=K(t.k,me,qe),c=[];for(let{cid:o,content:g}of e.byLabel(s)){let u=String(g.title??""),f=String(g.summary??""),a=X(n,u,f);a<=0||c.push({cid:o,title:u,summary:f,score:Math.round(a*1e3)/1e3,trust:e.trust.get(o)??null,freshness:e.stale(o)})}return c.sort((o,g)=>g.score-o.score||o.cid.localeCompare(g.cid)),c.slice(0,r)}function nt(e,t,n){let s=e.heads.get(n);if(typeof s!="string"){let c=[...e.heads.keys()].sort().join(", ");throw new x(`unknown source_id "${n}" \u2014 known: ${c||"(none)"}`)}if(e.mediaOf(s).format==="image")throw new x(`source "${n}" is an image \u2014 no line window (cite img#whole)`);let r=U(t,e,s);if(r==null)throw new x(`source "${n}" blob is missing from the store`);return{head:s,lines:r.toString("utf8").replace(/\n$/,"").split(`
4
4
  `)}}function Ct(e,t,n){return e.slice(t-1,n).map((s,r)=>`${String(t+r).padStart(4,"0")}| ${s}`).join(`
5
5
  `)}function Tt(e,t,n){let s=M(t,"source_id"),r=O(t,"anchor"),c=t.line_range;if(r!=null&&c!=null)throw new x("give anchor OR line_range, not both");let{head:o,lines:g}=nt(e,n,s),u=g.length,f,a;if(r!=null){let d=/^L(\d+)-L(\d+)$/.exec(r);if(!d)throw new x(`anchor "${r}" is not L<a>-L<b>`);let m=Number(d[1]),h=Number(d[2]);if(m<1||h<m||h>u)throw new x(`anchor "${r}" does not resolve (source has ${u} lines)`);f=Math.max(1,m-Ve),a=Math.min(u,h+Ve)}else if(c!=null){if(!Array.isArray(c)||c.length!==2||!c.every(h=>Number.isInteger(h)))throw new x('param "line_range" must be [from_line, to_line]');let[d,m]=c;if(d<1||m<d)throw new x('param "line_range" must be 1-based with from \u2264 to');if(d>u)throw new x(`line_range starts past the end (source has ${u} lines)`);f=d,a=Math.min(m,u)}else f=1,a=u;return a=Math.min(a,f+kt-1),{window:Ct(g,f,a),from_line:f,to_line:a,source_cid:o,total_lines:u}}function Lt(e,t,n){let s=M(t,"pattern"),r=O(t,"source_id"),c;try{c=new RegExp(s,"u")}catch(f){throw new x(`invalid pattern: ${f instanceof Error?f.message:String(f)}`)}let o=r!=null?[r]:[...e.heads.keys()].sort(),g=[],u=!1;e:for(let f of o){if(r==null){let d=e.heads.get(f);if(typeof d!="string"||e.mediaOf(d).format==="image")continue}let{lines:a}=nt(e,n,f);for(let d=0;d<a.length;d++)if(c.test(a[d])){if(g.length>=xt){u=!0;break e}g.push({source_id:f,line:d+1,text:a[d]})}}return{matches:g,truncated:u}}function Gt(e,t,n,s){try{switch(t){case"get_node":{let r=pe(e,M(n,"cid"));return r==null?{ok:!0,result:null}:{ok:!0,result:Ye([r],n)[0]}}case"get_edges":return{ok:!0,result:At(e,n,s)};case"find_by_provenance":return{ok:!0,result:Rt(e,n)};case"match_by_type":return{ok:!0,result:$t(e,n)};case"stale_nodes":return{ok:!0,result:It(e,n)};case"search_similar":return{ok:!0,result:Dt(e,n)};case"search_similar_batch":return{ok:!0,result:tt(e,n)};case"history":{if(s==null)throw new x("history unavailable (no context store)");return{ok:!0,result:Mt(e,n,s)}}case"source_list":{if(s==null)throw new x("source roster unavailable (no context store)");return{ok:!0,result:Ot(e,n,s)}}case"source_read":case"source_grep":{if(s==null)throw new x("source text unavailable (no context store)");return{ok:!0,result:(t==="source_read"?Tt:Lt)(e,n,s)}}default:return{ok:!1,error:`unknown method: ${t} \u2014 available: ${wt.join(", ")}`}}}catch(r){return r instanceof x?{ok:!1,error:`${t}: ${r.message}`}:{ok:!1,error:`${t}: graph read failed: ${r instanceof Error?r.message:String(r)}`}}}var I="assurance.sim";function Nt(e){return[e.title,e.summary,e.description].filter(Boolean).join(`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{e as k,f as l}from"./chunk-Y6Y6RAY4.js";import{b as p}from"./chunk-NXAJBSIF.js";import{a as f}from"./chunk-C2RUDJ46.js";import{a as d}from"./chunk-RZ4F3BHX.js";import{promises as g}from"fs";import{basename as _,join as w}from"path";var D=3e3,S="/deviceSkin";function b(e){return e.replace(/\([^)]*\)/g," ").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||void 0}function v(e){if(e.model){let r=b(e.model);return r?`real-${r}`:void 0}let n=e.name?.trim();return n&&!k(n)?n:void 0}function y(e){let n=e?.data?.skin,r=typeof n?.skin_url=="string"?n.skin_url.trim():"",t=n?.skin_data??{},i=u=>typeof u=="number"&&Number.isFinite(u)?u:void 0,s=i(t.width),o=i(t.height);if(!r||!s||!o)return;let m={width:s,height:o};for(let u of["top","right","bottom","left","radius"]){let c=i(t[u]);c!==void 0&&(m[u]=c)}return{skin_url:r,skin_data:m}}var a=new Map;async function h(e,n,r={}){let t=`${f(e).lrmaaBaseUrl}${S}/${encodeURIComponent(n)}`;if(a.has(t))return a.get(t);try{let i=await(r.request??d)(t,{method:"GET",signal:AbortSignal.timeout(D)});if(!i.ok)return;let s=y(await i.json());return a.set(t,s),s}catch{return}}function A(e){let n=(e??"").trim().replace(/^lt:\/\//i,"").trim();if(n)return(p(n)?n:_(n))||void 0}async function P(e){try{let n=w(e,"steps"),r=(await g.readdir(n,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,i)=>(parseInt(t,10)||0)-(parseInt(i,10)||0));for(let t of r)try{let i=await g.readFile(w(n,t,"step.json"),"utf8"),o=JSON.parse(i).basis?.window;if(Array.isArray(o)&&o.length===2&&Number.isFinite(Number(o[0]))&&Number.isFinite(Number(o[1]))&&Number(o[0])>0&&Number(o[1])>0)return`${Math.round(Number(o[0]))}x${Math.round(Number(o[1]))}`}catch{}return}catch{return}}async function T(e,n,r){if(!e.native_platform||!n.environment)return e;let t=v({model:n.deviceModel,name:l(n.runnerEnvironment?.device)});if(!t)return e;let i=await h(n.environment,t,r);return i?{...e,skin_url:i.skin_url,skin_data:i.skin_data}:e}export{v as a,h as b,A as c,P as d,T as e};
2
+ import{e as k,f as l}from"./chunk-Y6Y6RAY4.js";import{b as p}from"./chunk-75FF7J5R.js";import{a as f}from"./chunk-FI2DVNRT.js";import{a as d}from"./chunk-RZ4F3BHX.js";import{promises as g}from"fs";import{basename as _,join as w}from"path";var D=3e3,S="/deviceSkin";function b(e){return e.replace(/\([^)]*\)/g," ").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||void 0}function v(e){if(e.model){let r=b(e.model);return r?`real-${r}`:void 0}let n=e.name?.trim();return n&&!k(n)?n:void 0}function y(e){let n=e?.data?.skin,r=typeof n?.skin_url=="string"?n.skin_url.trim():"",t=n?.skin_data??{},i=u=>typeof u=="number"&&Number.isFinite(u)?u:void 0,s=i(t.width),o=i(t.height);if(!r||!s||!o)return;let m={width:s,height:o};for(let u of["top","right","bottom","left","radius"]){let c=i(t[u]);c!==void 0&&(m[u]=c)}return{skin_url:r,skin_data:m}}var a=new Map;async function h(e,n,r={}){let t=`${f(e).lrmaaBaseUrl}${S}/${encodeURIComponent(n)}`;if(a.has(t))return a.get(t);try{let i=await(r.request??d)(t,{method:"GET",signal:AbortSignal.timeout(D)});if(!i.ok)return;let s=y(await i.json());return a.set(t,s),s}catch{return}}function A(e){let n=(e??"").trim().replace(/^lt:\/\//i,"").trim();if(n)return(p(n)?n:_(n))||void 0}async function P(e){try{let n=w(e,"steps"),r=(await g.readdir(n,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,i)=>(parseInt(t,10)||0)-(parseInt(i,10)||0));for(let t of r)try{let i=await g.readFile(w(n,t,"step.json"),"utf8"),o=JSON.parse(i).basis?.window;if(Array.isArray(o)&&o.length===2&&Number.isFinite(Number(o[0]))&&Number.isFinite(Number(o[1]))&&Number(o[0])>0&&Number(o[1])>0)return`${Math.round(Number(o[0]))}x${Math.round(Number(o[1]))}`}catch{}return}catch{return}}async function T(e,n,r){if(!e.native_platform||!n.environment)return e;let t=v({model:n.deviceModel,name:l(n.runnerEnvironment?.device)});if(!t)return e;let i=await h(n.environment,t,r);return i?{...e,skin_url:i.skin_url,skin_data:i.skin_data}:e}export{v as a,h as b,A as c,P as d,T as e};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as A}from"./chunk-SMXABALN.js";import{a as _}from"./chunk-ZAFJQ3SM.js";import{d as B}from"./chunk-C6HI6Y3S.js";import{a as R}from"./chunk-ICLUC44J.js";import{a as k}from"./chunk-C2RUDJ46.js";import{a as P}from"./chunk-HCBYKLMW.js";import{a as u,b as c}from"./chunk-33DWJV67.js";import{a as J}from"./chunk-6YGTRKDT.js";import{y as l}from"./chunk-D36V5OX6.js";import{e as L}from"./chunk-UR6MHSHU.js";var t=L(J(),1);var e=L(P(),1);function X(n,s,y,m){return{id:n,label:`${s} (${n}) \xB7 ${y} tests`,isActive:n===m}}function W({resolver:n,projectId:s,currentFolderId:y,env:m,onSelect:w,onCancel:x}){let[I,M]=(0,t.useState)([]),[$,d]=(0,t.useState)(!0),[O,g]=(0,t.useState)(!1),[U,N]=(0,t.useState)(null),[p,h]=(0,t.useState)("list"),[S,v]=(0,t.useState)(""),[E,f]=(0,t.useState)(null),b=(0,t.useRef)(!1);(0,t.useEffect)(()=>{if(!n){N("Login first to browse folders"),d(!1);return}let o=new AbortController;return d(!0),g(!0),(async()=>{try{let r=n.cached??await n.resolve();if(!r){N("Login first to browse folders"),d(!1),g(!1);return}let a=k(m),T=new B(a.tmsBaseUrl,r.username,r.access_key),F=(async function*(){if(o.signal.aborted)return;let i=await T.listFolders(s);yield{page:1,folders:i,totalLoaded:i.length,done:!0}})();for await(let i of F){if(d(!1),i.totalLoaded===0){b.current=!0,h("naming"),g(!1);return}M(i.folders.map(C=>X(C.id,C.name,C.test_cases_count,y))),i.done&&g(!1)}}catch(r){if(r?.name==="AbortError")return;N(r instanceof Error?r.message:String(r)),d(!1),g(!1)}})(),()=>o.abort()},[n,s,y,m]);let D=(0,t.useCallback)(o=>{let r=o.trim();if(!r){f("Name cannot be empty");return}if(!s){f("No project selected \u2014 pick a project first");return}f(null),h("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let a=n.cached??await n.resolve();if(!a)throw new Error("Not authenticated");let T=k(m),i=await new B(T.tmsBaseUrl,a.username,a.access_key).createFolder(s,r);w(i.id,i.name)}catch(a){f(a instanceof Error?a.message:String(a)),h("naming")}})()},[n,s,m,w]),H=(0,t.useCallback)(()=>{v(""),f(null),b.current?x():h("list")},[x]);return p==="naming"||p==="creating"?(0,e.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(c,{color:l.orange,bold:!0,children:"Create new folder"}),b.current&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(c,{color:l.dim,children:"No folders yet \u2014 let's create one."})}),(0,e.jsxs)(u,{marginTop:1,children:[(0,e.jsx)(c,{color:l.dim,children:"Name: "}),p==="naming"?(0,e.jsx)(A,{value:S,onChange:o=>{v(o),E&&f(null)},onSubmit:D,onCancel:H}):(0,e.jsx)(c,{children:S})]}),E&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(c,{color:l.red,children:E})}),p==="creating"&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(c,{color:l.dim,children:"Creating..."})}),p==="naming"&&(0,e.jsx)(R,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:b.current?"cancel":"back"})]}):(0,e.jsx)(_,{title:"Folders",items:I,loading:$,loadingMore:O,preserveSelectionById:!0,error:U,itemNoun:"folders",onTab:()=>{b.current=!1,h("naming")},extraHint:"new",onSelect:o=>{let r=o.label.split(" (")[0];w(o.id,r)},onCancel:x})}export{X as a,W as b};
2
+ import{c as A}from"./chunk-SMXABALN.js";import{a as _}from"./chunk-73HMW2WA.js";import{e as B}from"./chunk-6K5BEEAJ.js";import{a as R}from"./chunk-4HYPMGDF.js";import{a as k}from"./chunk-FI2DVNRT.js";import{a as P}from"./chunk-HCBYKLMW.js";import{a as u,b as c}from"./chunk-33DWJV67.js";import{a as J}from"./chunk-6YGTRKDT.js";import{z as l}from"./chunk-FAMQ4DHU.js";import{e as L}from"./chunk-UR6MHSHU.js";var t=L(J(),1);var e=L(P(),1);function X(n,s,y,m){return{id:n,label:`${s} (${n}) \xB7 ${y} tests`,isActive:n===m}}function W({resolver:n,projectId:s,currentFolderId:y,env:m,onSelect:w,onCancel:x}){let[I,M]=(0,t.useState)([]),[$,d]=(0,t.useState)(!0),[O,g]=(0,t.useState)(!1),[U,N]=(0,t.useState)(null),[p,h]=(0,t.useState)("list"),[S,v]=(0,t.useState)(""),[E,f]=(0,t.useState)(null),b=(0,t.useRef)(!1);(0,t.useEffect)(()=>{if(!n){N("Login first to browse folders"),d(!1);return}let o=new AbortController;return d(!0),g(!0),(async()=>{try{let r=n.cached??await n.resolve();if(!r){N("Login first to browse folders"),d(!1),g(!1);return}let a=k(m),T=new B(a.tmsBaseUrl,r.username,r.access_key),F=(async function*(){if(o.signal.aborted)return;let i=await T.listFolders(s);yield{page:1,folders:i,totalLoaded:i.length,done:!0}})();for await(let i of F){if(d(!1),i.totalLoaded===0){b.current=!0,h("naming"),g(!1);return}M(i.folders.map(C=>X(C.id,C.name,C.test_cases_count,y))),i.done&&g(!1)}}catch(r){if(r?.name==="AbortError")return;N(r instanceof Error?r.message:String(r)),d(!1),g(!1)}})(),()=>o.abort()},[n,s,y,m]);let D=(0,t.useCallback)(o=>{let r=o.trim();if(!r){f("Name cannot be empty");return}if(!s){f("No project selected \u2014 pick a project first");return}f(null),h("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let a=n.cached??await n.resolve();if(!a)throw new Error("Not authenticated");let T=k(m),i=await new B(T.tmsBaseUrl,a.username,a.access_key).createFolder(s,r);w(i.id,i.name)}catch(a){f(a instanceof Error?a.message:String(a)),h("naming")}})()},[n,s,m,w]),H=(0,t.useCallback)(()=>{v(""),f(null),b.current?x():h("list")},[x]);return p==="naming"||p==="creating"?(0,e.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(c,{color:l.orange,bold:!0,children:"Create new folder"}),b.current&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(c,{color:l.dim,children:"No folders yet \u2014 let's create one."})}),(0,e.jsxs)(u,{marginTop:1,children:[(0,e.jsx)(c,{color:l.dim,children:"Name: "}),p==="naming"?(0,e.jsx)(A,{value:S,onChange:o=>{v(o),E&&f(null)},onSubmit:D,onCancel:H}):(0,e.jsx)(c,{children:S})]}),E&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(c,{color:l.red,children:E})}),p==="creating"&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(c,{color:l.dim,children:"Creating..."})}),p==="naming"&&(0,e.jsx)(R,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:b.current?"cancel":"back"})]}):(0,e.jsx)(_,{title:"Folders",items:I,loading:$,loadingMore:O,preserveSelectionById:!0,error:U,itemNoun:"folders",onTab:()=>{b.current=!1,h("naming")},extraHint:"new",onSelect:o=>{let r=o.label.split(" (")[0];w(o.id,r)},onCancel:x})}export{X as a,W as b};