@testmuai/kane-cli 0.8.13 → 0.8.14

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 (300) hide show
  1. package/dist/{ChatSurface-B6ZIO3JL.js → ChatSurface-AVL3TJA2.js} +3 -3
  2. package/dist/{ChromeProfilePicker-QSICCUMV.js → ChromeProfilePicker-WJZJOZ6Z.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-LLLNSKW2.js → CliFeedbackPrompt-65BQF5G5.js} +1 -1
  4. package/dist/{CliUploadProgress-N5IY66T2.js → CliUploadProgress-HEBZYKGN.js} +1 -1
  5. package/dist/{ConfigView-UQIRPENS.js → ConfigView-JEVQ2SO4.js} +1 -1
  6. package/dist/EvidenceViewOffer-5MB4ZXKM.js +2 -0
  7. package/dist/FolderPicker-SYFXH6D5.js +2 -0
  8. package/dist/{InfoBox-ZGSLEOPE.js → InfoBox-KM5DLBCV.js} +1 -1
  9. package/dist/{LinksBox-JFT44YUK.js → LinksBox-FQA36GTV.js} +1 -1
  10. package/dist/{ProfilesView-WZSPK3HF.js → ProfilesView-76KGHTMK.js} +1 -1
  11. package/dist/{ProjectPicker-SBBGVF4L.js → ProjectPicker-65YOU46H.js} +1 -1
  12. package/dist/{SaveSessionPrompt-F3563T3C.js → SaveSessionPrompt-QD6BNTWO.js} +1 -1
  13. package/dist/ScrollbackTap-QHJOFYMC.js +2 -0
  14. package/dist/SingleShotApp-U54ETXS3.js +2 -0
  15. package/dist/{SummaryBox-6N6NESLI.js → SummaryBox-N2B6DUDD.js} +1 -1
  16. package/dist/TestMdRunView-WA4TC5PT.js +2 -0
  17. package/dist/{TestrunEvidenceTable-JLJBJ76Q.js → TestrunEvidenceTable-3WLQVTF4.js} +1 -1
  18. package/dist/{WhoamiView-PNVUCWLB.js → WhoamiView-T26HA4ZZ.js} +1 -1
  19. package/dist/agent-parse-XMWVKCRD.js +2 -0
  20. package/dist/{app-download-NNB52ZRJ.js → app-download-XKZWFMEK.js} +1 -1
  21. package/dist/attach-target-V6LECVES.js +2 -0
  22. package/dist/{auth-JIDDELKY.js → auth-PPJANIMZ.js} +1 -1
  23. package/dist/{binary-LXYAW7WQ.js → binary-DKWWODT2.js} +1 -1
  24. package/dist/bind-62AZYFAY.js +15 -0
  25. package/dist/{bootstrap-THOC3SS7.js → bootstrap-6IJNZIPT.js} +1 -1
  26. package/dist/bridge-X5DEJL6F.js +2 -0
  27. package/dist/{changelog-BSMZXLTG.js → changelog-UTGJ7FSP.js} +1 -1
  28. package/dist/chat-committer-HDE3TP5I.js +2 -0
  29. package/dist/chat-controller-3EPK7UZG.js +2 -0
  30. package/dist/chunk-22QIVSQR.js +29 -0
  31. package/dist/{chunk-FNIL4G3V.js → chunk-2BFXT7VQ.js} +3 -3
  32. package/dist/{chunk-3FXNQTCE.js → chunk-2RMHDOP4.js} +1 -1
  33. package/dist/{chunk-7GUFVQOQ.js → chunk-3BHRGHIZ.js} +1 -1
  34. package/dist/{chunk-EEFZXZTZ.js → chunk-3IXEARDX.js} +1 -1
  35. package/dist/chunk-3N6IAVD5.js +7 -0
  36. package/dist/{chunk-I75FRXKE.js → chunk-3SPOJWRA.js} +1 -1
  37. package/dist/chunk-3YX3RQXO.js +2 -0
  38. package/dist/chunk-42FHKRPA.js +4 -0
  39. package/dist/{chunk-VYMMGWVO.js → chunk-4BBDKWM3.js} +1 -1
  40. package/dist/{chunk-J2UN2AHO.js → chunk-4K5XTIJ6.js} +1 -1
  41. package/dist/chunk-52WM3XYO.js +4 -0
  42. package/dist/{chunk-WUV3FJ7C.js → chunk-53MPG2J3.js} +1 -1
  43. package/dist/{chunk-R7QAS6LZ.js → chunk-55YDTPB7.js} +1 -1
  44. package/dist/{chunk-IDX3TOPY.js → chunk-5LJRZI7S.js} +1 -1
  45. package/dist/chunk-66MOZKD2.js +2 -0
  46. package/dist/{chunk-2X3TANEV.js → chunk-6F6YI3ZG.js} +1 -1
  47. package/dist/chunk-6LGED4FC.js +35 -0
  48. package/dist/chunk-73ULUGBM.js +5 -0
  49. package/dist/{chunk-F5AI3UVS.js → chunk-75I46VTM.js} +2 -2
  50. package/dist/{chunk-SEKJZOKW.js → chunk-7L25ZNNP.js} +1 -1
  51. package/dist/chunk-7O54QURK.js +2 -0
  52. package/dist/{chunk-XAM5E27U.js → chunk-7RAI77XD.js} +1 -1
  53. package/dist/{chunk-PWRIG6UB.js → chunk-AC7BPO4X.js} +1 -1
  54. package/dist/chunk-AHXOKBVE.js +7 -0
  55. package/dist/{chunk-DNNZ353O.js → chunk-ALCE5RLK.js} +1 -1
  56. package/dist/{chunk-AQWTK6IN.js → chunk-ARG56PJG.js} +1 -1
  57. package/dist/{chunk-33GXXC2L.js → chunk-B2ZGG7WM.js} +1 -1
  58. package/dist/{chunk-LAQBCZ5A.js → chunk-BAKJPQGU.js} +1 -1
  59. package/dist/{chunk-DIM5X2FR.js → chunk-BJYGWXVP.js} +1 -1
  60. package/dist/chunk-C74ABM24.js +2 -0
  61. package/dist/chunk-CGT4NFQN.js +8 -0
  62. package/dist/{chunk-EV64VI66.js → chunk-CRZUBDJ3.js} +1 -1
  63. package/dist/{chunk-EXLXV5OU.js → chunk-DA57DXCF.js} +1 -1
  64. package/dist/{chunk-PUM5J56E.js → chunk-EMSLJTYN.js} +1 -1
  65. package/dist/{chunk-YEZYO5QH.js → chunk-FFFB5BXL.js} +1 -1
  66. package/dist/{chunk-WIAZN7G4.js → chunk-FFVNISYH.js} +1 -1
  67. package/dist/chunk-FQNQVC5O.js +5 -0
  68. package/dist/{chunk-UF4JZXEE.js → chunk-GESG672R.js} +1 -1
  69. package/dist/{chunk-XL6HDWM3.js → chunk-GKZ2KVE6.js} +1 -1
  70. package/dist/chunk-GP7WD4UY.js +4 -0
  71. package/dist/{chunk-PYQS5ST6.js → chunk-GPIXV7AV.js} +2 -2
  72. package/dist/chunk-H6TNBKGR.js +5 -0
  73. package/dist/chunk-HOA4VWSD.js +5 -0
  74. package/dist/chunk-IE3OO5GI.js +2 -0
  75. package/dist/chunk-IICQ5KRD.js +5 -0
  76. package/dist/{chunk-K4SULRBL.js → chunk-IQ7GPETF.js} +1 -1
  77. package/dist/{chunk-3M2D7UUI.js → chunk-IQ7NGOAT.js} +1 -1
  78. package/dist/{chunk-TMRLBSIA.js → chunk-J7NRD4Q7.js} +1 -1
  79. package/dist/{chunk-FE6XRABM.js → chunk-JH6E632O.js} +1 -1
  80. package/dist/{chunk-XH2KDLZO.js → chunk-JJJSDDQ2.js} +1 -1
  81. package/dist/{chunk-BTBUIL4Q.js → chunk-JKX57HA7.js} +1 -1
  82. package/dist/{chunk-VJ3ES3RR.js → chunk-K7K23DIQ.js} +1 -1
  83. package/dist/chunk-KN65CUNT.js +15 -0
  84. package/dist/{chunk-CAO3XRA2.js → chunk-KOL6ZWOQ.js} +1 -1
  85. package/dist/{chunk-MCKBJIBB.js → chunk-KOPP4CJW.js} +1 -1
  86. package/dist/chunk-KZG4E5RM.js +2 -0
  87. package/dist/{chunk-J3Q63NFG.js → chunk-L4M7753M.js} +1 -1
  88. package/dist/{chunk-BJAHVN2F.js → chunk-L6MOO4WT.js} +1 -1
  89. package/dist/chunk-LBNADEQN.js +8 -0
  90. package/dist/{chunk-Q4YAJJPP.js → chunk-LL5DQO6V.js} +1 -1
  91. package/dist/chunk-LNV7C2YO.js +6 -0
  92. package/dist/{chunk-JX2CAVX6.js → chunk-LR5DJ6EN.js} +1 -1
  93. package/dist/{chunk-IZU5ND2C.js → chunk-M7DN6FO3.js} +1 -1
  94. package/dist/chunk-MLRO7OH3.js +9 -0
  95. package/dist/{chunk-DMLYUTS4.js → chunk-MNE5VMHT.js} +1 -1
  96. package/dist/{chunk-TDNM22BQ.js → chunk-N7ZRF5K3.js} +1 -1
  97. package/dist/{chunk-TXZ66K4Q.js → chunk-NBMLBCJ3.js} +1 -1
  98. package/dist/{chunk-KSLJOUH4.js → chunk-NDCRJXYF.js} +1 -1
  99. package/dist/{chunk-XS3HIVNS.js → chunk-NOLYYHVG.js} +1 -1
  100. package/dist/{chunk-IWVA37B6.js → chunk-O25AL4B7.js} +1 -1
  101. package/dist/{chunk-AIVOYTYQ.js → chunk-O2APH6TZ.js} +1 -1
  102. package/dist/{chunk-KAZGHWGK.js → chunk-O3XBIURC.js} +1 -1
  103. package/dist/{chunk-ZOSY2PJM.js → chunk-O5AS2ZIX.js} +1 -1
  104. package/dist/{chunk-DXFMELKC.js → chunk-O6U2HU5M.js} +1 -1
  105. package/dist/{chunk-NUWOQS6L.js → chunk-OH2NSBO6.js} +1 -1
  106. package/dist/{chunk-ARU6KAGY.js → chunk-OO5GMBVI.js} +1 -1
  107. package/dist/chunk-OPL2MIQG.js +2 -0
  108. package/dist/chunk-P3JUE2RM.js +17 -0
  109. package/dist/{chunk-D4G3SEBU.js → chunk-PGU64EWQ.js} +1 -1
  110. package/dist/{chunk-GILD6RGH.js → chunk-Q7XBMBMR.js} +1 -1
  111. package/dist/{chunk-OHK6V7JX.js → chunk-QJ5O27SJ.js} +1 -1
  112. package/dist/{chunk-KXUTO5WC.js → chunk-QPUVOVD7.js} +1 -1
  113. package/dist/{chunk-NM76SG3S.js → chunk-RBHQXWR7.js} +1 -1
  114. package/dist/{chunk-LWQNRZH3.js → chunk-RH6KFHJB.js} +1 -1
  115. package/dist/{chunk-FUP4AP6J.js → chunk-RQLU4NDG.js} +1 -1
  116. package/dist/{chunk-MXDWS7S4.js → chunk-SFTFHFG3.js} +7 -7
  117. package/dist/{chunk-4PARDPK2.js → chunk-SGHP44WS.js} +1 -1
  118. package/dist/{chunk-6AZNGOLH.js → chunk-SQDQADWD.js} +1 -1
  119. package/dist/{chunk-N2I23ANS.js → chunk-SX56MVUO.js} +1 -1
  120. package/dist/{chunk-O5U6EAL3.js → chunk-TCAHDVII.js} +1 -1
  121. package/dist/chunk-TNBF5OMZ.js +2 -0
  122. package/dist/chunk-TU6IMGWO.js +2 -0
  123. package/dist/{chunk-5G22NOZK.js → chunk-UHT5SVP5.js} +1 -1
  124. package/dist/{chunk-UZCSVEWP.js → chunk-UXH3RMQ7.js} +1 -1
  125. package/dist/{chunk-K2UEVCIJ.js → chunk-VNFCX2SH.js} +1 -1
  126. package/dist/{chunk-NU45ROHH.js → chunk-WBHSPN55.js} +2 -2
  127. package/dist/chunk-WILT62DP.js +16 -0
  128. package/dist/{chunk-QD2BUO5M.js → chunk-WOA7VCGA.js} +1 -1
  129. package/dist/{chunk-RN5ERSV2.js → chunk-WR42Q3HU.js} +1 -1
  130. package/dist/chunk-X5276I5H.js +9 -0
  131. package/dist/{chunk-477DYMXZ.js → chunk-X74PP5NJ.js} +1 -1
  132. package/dist/{chunk-KV5BOFPK.js → chunk-XGHMZJGI.js} +2 -2
  133. package/dist/{chunk-XS2LZFCH.js → chunk-YCH7H7JX.js} +1 -1
  134. package/dist/{chunk-7KIIM6H7.js → chunk-YHR2YAN5.js} +1 -1
  135. package/dist/chunk-YHVG7V3E.js +21 -0
  136. package/dist/chunk-YLQHY4A7.js +2 -0
  137. package/dist/{chunk-KGKJU27A.js → chunk-YYYQ5MVD.js} +1 -1
  138. package/dist/{chunk-W2UYUV47.js → chunk-ZA4M4O7E.js} +2 -2
  139. package/dist/chunk-ZKEOPIQ3.js +9 -0
  140. package/dist/chunk-ZUZ6QJRA.js +23 -0
  141. package/dist/{chunk-3SP4JVDN.js → chunk-ZWHPIR2Z.js} +2 -2
  142. package/dist/chunk-ZZTZJPT2.js +88 -0
  143. package/dist/committer-IYQPXG6C.js +2 -0
  144. package/dist/{config-BCGD2FEX.js → config-3AKWRTFS.js} +1 -1
  145. package/dist/cover-cmd-ZLAWMEC2.js +3 -0
  146. package/dist/{credentials-YNH5BU2Z.js → credentials-Q4WH5CBN.js} +1 -1
  147. package/dist/{deps-bundle-LOFI4DAJ.js → deps-bundle-RVZK6LZJ.js} +1 -1
  148. package/dist/{deps-resolve-GA6IPHVZ.js → deps-resolve-6F2U4TJP.js} +1 -1
  149. package/dist/design-committer-J57IAAA5.js +2 -0
  150. package/dist/dispatch-46BETGXY.js +2 -0
  151. package/dist/{doctor-W5TQBYB5.js → doctor-WRPG56HH.js} +1 -1
  152. package/dist/docx-convert-WPZS6OIC.js +2 -0
  153. package/dist/{dossier-Y6TJWFZU.js → dossier-UGJMYYAB.js} +1 -1
  154. package/dist/evidence-XWR32HWP.js +2 -0
  155. package/dist/evolve-cmd-27ZQN6YB.js +2 -0
  156. package/dist/explain-H5HJEDEF.js +2 -0
  157. package/dist/explain-cmd-JCJTXVZY.js +9 -0
  158. package/dist/{explain-cmd-XCRO4AS6.js → explain-cmd-R45I5MT7.js} +1 -1
  159. package/dist/extract-bind-D5BYYGYA.js +14 -0
  160. package/dist/{extract-cmd-7FKQJNS7.js → extract-cmd-CCYW7FIY.js} +3 -3
  161. package/dist/feeder-RSHMGW6B.js +2 -0
  162. package/dist/gaps-cmd-3VJKQ25D.js +3 -0
  163. package/dist/{generate-headless-OBMB5CSB.js → generate-headless-2M6UT3IK.js} +2 -2
  164. package/dist/headless-io-3A3BZVQ5.js +2 -0
  165. package/dist/index.js +188 -205
  166. package/dist/ingest-QGLVY7ND.js +2 -0
  167. package/dist/ingest-cmd-HVTUK264.js +2 -0
  168. package/dist/install-5WJLE7XT.js +2 -0
  169. package/dist/interactive-bind-OJCYNQPI.js +26 -0
  170. package/dist/lifecycle-cmd-GWFGUGTC.js +2 -0
  171. package/dist/{list-cmd-V3HJ5K4O.js → list-cmd-AXDW64OY.js} +1 -1
  172. package/dist/{list-commands-SH4HPFI4.js → list-commands-YNZ6EFIF.js} +1 -1
  173. package/dist/{locks-cmd-CSVSWY2Y.js → locks-cmd-67OHQZNV.js} +1 -1
  174. package/dist/logical-ids-DN6IZSUM.js +2 -0
  175. package/dist/login-flow-PRXFPRYZ.js +2 -0
  176. package/dist/maintenance-cmd-QEMK6YNV.js +2 -0
  177. package/dist/{mobile-prompts-UZTRJ3L7.js → mobile-prompts-OXHA5GHJ.js} +1 -1
  178. package/dist/{objective-variable-gate-3VUXNDCZ.js → objective-variable-gate-76GYUHEP.js} +1 -1
  179. package/dist/open-provider-E5VUGFNE.js +2 -0
  180. package/dist/pdf-convert-5H4HQNN3.js +2 -0
  181. package/dist/{persist-recorded-session-QMRY4DOF.js → persist-recorded-session-KWPH37HI.js} +1 -1
  182. package/dist/phase-seed-HKJ2EF7R.js +2 -0
  183. package/dist/pipeline-A2OGF4XW.js +2 -0
  184. package/dist/prepare-target-P6BWJZBZ.js +2 -0
  185. package/dist/readmodel-IBFRM6EO.js +2 -0
  186. package/dist/reconcile-cmd-V7TDYETT.js +2 -0
  187. package/dist/reconcile-deps-X6IGH4CA.js +4 -0
  188. package/dist/reconcile-engine-OGXSIE7O.js +2 -0
  189. package/dist/{recording-banner-7E75ERQJ.js → recording-banner-IZWN2XFY.js} +1 -1
  190. package/dist/records-TJJJWBUD.js +2 -0
  191. package/dist/registry-GOLIFVK5.js +2 -0
  192. package/dist/{require-project-folder-LBUYWQOF.js → require-project-folder-PEEUITK6.js} +1 -1
  193. package/dist/{resolve-run-intent-GHISMXLZ.js → resolve-run-intent-JGXXE45Y.js} +1 -1
  194. package/dist/{resolver-7JC5VZ4S.js → resolver-TY7XLJBN.js} +1 -1
  195. package/dist/revert-6BBBK3I4.js +2 -0
  196. package/dist/review-cmd-74YTPT7E.js +5 -0
  197. package/dist/run-DN4XARP2.js +2 -0
  198. package/dist/run-GRYWYKIH.js +2 -0
  199. package/dist/{run-test-md-5LPCKCW7.js → run-test-md-DFCKCQ4T.js} +2 -2
  200. package/dist/sessions-NH7WQWMX.js +2 -0
  201. package/dist/{sessions-cmd-VDQGRBEM.js → sessions-cmd-DV442ZCY.js} +1 -1
  202. package/dist/{skill-installer-YQPZZB7I.js → skill-installer-GRU3HOYF.js} +1 -1
  203. package/dist/{spawner-X2FOOONV.js → spawner-LNMD4NJF.js} +1 -1
  204. package/dist/store-guard-Q4MYZQHF.js +2 -0
  205. package/dist/structured-answers-NADW6D44.js +5 -0
  206. package/dist/sync-cmd-H6Y5EB3L.js +2 -0
  207. package/dist/sync-setup-THGRBKTA.js +2 -0
  208. package/dist/sync-setup-ui-RC727VK6.js +3 -0
  209. package/dist/tcg-generate-SZZ7MJXY.js +2 -0
  210. package/dist/testmd-actions-MRIUOOXO.js +2 -0
  211. package/dist/testmd-sync-UYVJ47BN.js +2 -0
  212. package/dist/token-refresh-KN5JK2U4.js +2 -0
  213. package/dist/{validate-basic-GTSVZFQI.js → validate-basic-RCBEELSB.js} +1 -1
  214. package/dist/{variable-receipt-IHQAYWMZ.js → variable-receipt-JHRW73Z6.js} +1 -1
  215. package/dist/verdicts-XFXDRND4.js +2 -0
  216. package/dist/{version-check-IPEPJZDX.js → version-check-Z774UWW3.js} +1 -1
  217. package/dist/{view-cmd-SXXNDZIC.js → view-cmd-I4LQGJ2X.js} +1 -1
  218. package/dist/walk-session-FP52IGLB.js +2 -0
  219. package/dist/with-telemetry-P6RUPWBH.js +2 -0
  220. package/package.json +12 -11
  221. package/dist/EvidenceViewOffer-AZRAILJQ.js +0 -2
  222. package/dist/FolderPicker-OJFR7AKZ.js +0 -2
  223. package/dist/ScrollbackTap-Q3IOKNMS.js +0 -2
  224. package/dist/SingleShotApp-72D5VVLE.js +0 -2
  225. package/dist/TestMdRunView-4OA52DA2.js +0 -2
  226. package/dist/bind-F36JFHUK.js +0 -12
  227. package/dist/bridge-KMDML2NB.js +0 -2
  228. package/dist/chat-committer-RAOIL2T6.js +0 -2
  229. package/dist/chat-controller-YJCNU76T.js +0 -2
  230. package/dist/chunk-4WOVHRI2.js +0 -15
  231. package/dist/chunk-54JZ6VEW.js +0 -4
  232. package/dist/chunk-5DT7PIGB.js +0 -5
  233. package/dist/chunk-6FCPS2VT.js +0 -4
  234. package/dist/chunk-6IAA644J.js +0 -9
  235. package/dist/chunk-6J635CRI.js +0 -5
  236. package/dist/chunk-AGRUULPT.js +0 -4
  237. package/dist/chunk-BZTWTYQQ.js +0 -6
  238. package/dist/chunk-CUSTYILP.js +0 -2
  239. package/dist/chunk-DBIBROYW.js +0 -5
  240. package/dist/chunk-I27YRAGO.js +0 -7
  241. package/dist/chunk-IAHKTEET.js +0 -2
  242. package/dist/chunk-IVQX3AKL.js +0 -4
  243. package/dist/chunk-K6RAOZHP.js +0 -4
  244. package/dist/chunk-KO3FL2XW.js +0 -26
  245. package/dist/chunk-L32DKFRQ.js +0 -16
  246. package/dist/chunk-LPDBTGO5.js +0 -21
  247. package/dist/chunk-N7Z7BQYO.js +0 -3
  248. package/dist/chunk-NVGBE2DR.js +0 -2
  249. package/dist/chunk-OS4VSIHT.js +0 -4
  250. package/dist/chunk-OTMAFCZK.js +0 -8
  251. package/dist/chunk-P5MJMM3X.js +0 -85
  252. package/dist/chunk-QQ5MHSSY.js +0 -2
  253. package/dist/chunk-T7DGNWI2.js +0 -17
  254. package/dist/chunk-UH2ZTX4E.js +0 -2
  255. package/dist/chunk-W3Z7AZNT.js +0 -4
  256. package/dist/chunk-XMTSHHYQ.js +0 -4
  257. package/dist/committer-C6UCDYMC.js +0 -2
  258. package/dist/cover-cmd-5LPHIOSI.js +0 -3
  259. package/dist/design-committer-UPC6NZUF.js +0 -2
  260. package/dist/dispatch-FRCPK3AZ.js +0 -2
  261. package/dist/docx-convert-BIV5T7F5.js +0 -2
  262. package/dist/evidence-FHO36EEV.js +0 -2
  263. package/dist/evolve-cmd-6RXLKERE.js +0 -2
  264. package/dist/explain-3HAZY7Q6.js +0 -2
  265. package/dist/explain-cmd-RMJPXD4U.js +0 -9
  266. package/dist/extract-bind-BFJPRNPQ.js +0 -10
  267. package/dist/feeder-IOR3XRNF.js +0 -2
  268. package/dist/gaps-cmd-FDJ3PT4C.js +0 -3
  269. package/dist/headless-io-66RG5NN5.js +0 -2
  270. package/dist/ingest-TTUQ7UDK.js +0 -2
  271. package/dist/ingest-cmd-AV66Q5LC.js +0 -2
  272. package/dist/install-SFJ2FFQ6.js +0 -2
  273. package/dist/interactive-bind-N5AQB26T.js +0 -25
  274. package/dist/lifecycle-cmd-KSMETBPP.js +0 -2
  275. package/dist/logical-ids-MLXAH45L.js +0 -2
  276. package/dist/login-flow-ODVWEPRU.js +0 -2
  277. package/dist/maintenance-cmd-VFYGKY3X.js +0 -2
  278. package/dist/pdf-convert-OZIRUADA.js +0 -2
  279. package/dist/phase-seed-BMOSAA74.js +0 -2
  280. package/dist/pipeline-5FHWZAXK.js +0 -2
  281. package/dist/prepare-target-UJEY2FSR.js +0 -2
  282. package/dist/readmodel-TDRFVDVI.js +0 -2
  283. package/dist/reconcile-cmd-2QHZML2L.js +0 -2
  284. package/dist/reconcile-deps-ZBWUY3SM.js +0 -4
  285. package/dist/reconcile-engine-YC4RQYF2.js +0 -2
  286. package/dist/records-JLS63SDI.js +0 -2
  287. package/dist/registry-JJTRUPH7.js +0 -2
  288. package/dist/revert-PRR3D4XM.js +0 -2
  289. package/dist/review-cmd-SAGIKWEW.js +0 -4
  290. package/dist/run-43ACVPJK.js +0 -2
  291. package/dist/run-EOTOXNQO.js +0 -2
  292. package/dist/sessions-GIEXOCE4.js +0 -2
  293. package/dist/structured-answers-YAVW65G4.js +0 -5
  294. package/dist/tcg-generate-V4QRNEZV.js +0 -2
  295. package/dist/testmd-actions-2UMU3QMV.js +0 -2
  296. package/dist/testmd-sync-UBXDLWYD.js +0 -2
  297. package/dist/token-refresh-NL5AM446.js +0 -2
  298. package/dist/verdicts-QU6W3TUF.js +0 -2
  299. package/dist/walk-session-7JVB4Z5S.js +0 -2
  300. package/dist/with-telemetry-LRI7H6DH.js +0 -2
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as $}from"./chunk-IZU5ND2C.js";import{f as D}from"./chunk-CAO3XRA2.js";import{a as E}from"./chunk-NLCCBXXV.js";function U(e){return["completed","failed","ended","stopped"].includes(e.trim().toLowerCase())}function je(e){return["ended","stopped"].includes(e.trim().toLowerCase())}function q(e){return{requestId:e.requestId,objective:e.objective,status:"",turnActive:!1,scenarios:[],thinking:"",thinkingLog:[],chatLog:[],progress:0}}function Re(e){return e.pendingClarification===void 0?e:{...e,pendingClarification:void 0}}function Ce(e){return{...e,turnActive:!0,error:void 0,thinking:"",thinkingLog:[]}}function P(e,t){switch(t.type){case"thinking":return{...e,status:"thinking",thinking:e.thinking+t.delta};case"thinking_done":return{...e,thinkingLog:[...e.thinkingLog,{text:e.thinking,tookMs:t.tookMs}],thinking:""};case"progress":return{...e,progress:t.pct};case"snapshot":return{...e,scenarios:t.data.scenarios,status:t.data.status,headline:t.data.headline??e.headline};case"chat":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}]};case"clarification":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}],pendingClarification:t.text};case"limit":return{...e,limits:{scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit}};case"error":return{...e,error:t.message};case"done":return{...e,status:t.status,turnActive:!1,error:t.status==="failed"&&!e.error?"generation failed":e.error}}}function H(e,t){let n=[],i=e.type??"",d=e.status??"";if(i==="ping")return n;switch(i){case"thinking_token":typeof e.data=="string"&&n.push({type:"thinking",delta:e.data});break;case"thinking_stopped":{let r=e.data??{},o=se(r.time_taken);n.push({type:"thinking_done",text:typeof e.data=="string"?e.data:r.message??"",tookMs:o});break}case"progress":{let r=e.data??{};typeof r.progress=="number"&&n.push({type:"progress",pct:r.progress});break}case"clarification":{let r=e.data??{};typeof r.message=="string"&&n.push({type:"clarification",text:r.message});break}case"chatting_stopped":{let r=e.data??{};typeof r.message=="string"&&r.message.length>0&&n.push({type:"chat",text:r.message});break}case"limit_update":{let r=e.data??{},o=r.test_cases_limit??e.test_cases_limit,p=r.per_scenario_test_cases_limit??e.per_scenario_test_cases_limit;n.push({type:"limit",scenarioLimit:o,perScenarioLimit:p});break}case"error":{let r=typeof e.data=="string"?e.data:e.data?.message??"generation error";n.push({type:"error",message:r});break}case"request_cancelled":return n.push({type:"done",status:"stopped"}),n;case"session_ended":return n.push({type:"done",status:"ended"}),n;default:break}if(Array.isArray(e.scenarios)&&n.push({type:"snapshot",data:{requestId:t,status:d,headline:e.headline,scenarios:e.scenarios}}),d&&U(d)){let r=d.trim().toLowerCase();n.push({type:"done",status:r})}return n}function se(e){if(!e)return;let t=/^([\d.]+)(ms|s)?$/.exec(e.trim());if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return t[2]==="ms"?Math.round(n):Math.round(n*1e3)}var v=class extends Error{constructor(t){super(t),this.name="AuthError"}},M=class extends Error{constructor(t){super(t),this.name="ForbiddenError"}},I=class extends Error{constructor(t){super(t),this.name="InsufficientCreditsError"}},k=class extends Error{constructor(n,i){super(n);this.cause=i;this.name="TransportError"}};function x(e,t){let n=t?.message??t?.error??`HTTP ${e}`;return e===401?new v(n):e===403?t?.key==="insufficient_credits"?new I(n):new M(n):new k(n)}async function*J(e){let t=e.fetchImpl??fetch,n=e.maxRetries??5,i=e.maxBackoffMs??3e4,d=e.connectTimeoutMs??1e4,r=0,o=!1;for(;;){if(e.signal.aborted)return;let p=new AbortController,a=()=>p.abort();e.signal.addEventListener("abort",a,{once:!0});let c=setTimeout(()=>p.abort(),d),g;try{g=await t(e.url,{method:"GET",headers:{Authorization:await e.authHeader(),Accept:"text/event-stream"},signal:p.signal})}catch(w){if(clearTimeout(c),e.signal.removeEventListener("abort",a),e.signal.aborted)return;if(++r>n)throw new k("SSE connect failed",w);await O(F(r,i));continue}if(clearTimeout(c),!g.ok){e.signal.removeEventListener("abort",a);let w=await oe(g);if(g.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(g.status,w)}if(!g.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let m=g.body.getReader(),h=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await m.cancel().catch(()=>{});return}let{done:w,value:s}=await m.read();if(w)break;b+=h.decode(s,{stream:!0});let f;for(;(f=b.indexOf(`
2
+ import{a as $}from"./chunk-M7DN6FO3.js";import{f as D}from"./chunk-KOL6ZWOQ.js";import{a as E}from"./chunk-NLCCBXXV.js";function U(e){return["completed","failed","ended","stopped"].includes(e.trim().toLowerCase())}function je(e){return["ended","stopped"].includes(e.trim().toLowerCase())}function q(e){return{requestId:e.requestId,objective:e.objective,status:"",turnActive:!1,scenarios:[],thinking:"",thinkingLog:[],chatLog:[],progress:0}}function Re(e){return e.pendingClarification===void 0?e:{...e,pendingClarification:void 0}}function Ce(e){return{...e,turnActive:!0,error:void 0,thinking:"",thinkingLog:[]}}function P(e,t){switch(t.type){case"thinking":return{...e,status:"thinking",thinking:e.thinking+t.delta};case"thinking_done":return{...e,thinkingLog:[...e.thinkingLog,{text:e.thinking,tookMs:t.tookMs}],thinking:""};case"progress":return{...e,progress:t.pct};case"snapshot":return{...e,scenarios:t.data.scenarios,status:t.data.status,headline:t.data.headline??e.headline};case"chat":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}]};case"clarification":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}],pendingClarification:t.text};case"limit":return{...e,limits:{scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit}};case"error":return{...e,error:t.message};case"done":return{...e,status:t.status,turnActive:!1,error:t.status==="failed"&&!e.error?"generation failed":e.error}}}function H(e,t){let n=[],i=e.type??"",d=e.status??"";if(i==="ping")return n;switch(i){case"thinking_token":typeof e.data=="string"&&n.push({type:"thinking",delta:e.data});break;case"thinking_stopped":{let r=e.data??{},o=se(r.time_taken);n.push({type:"thinking_done",text:typeof e.data=="string"?e.data:r.message??"",tookMs:o});break}case"progress":{let r=e.data??{};typeof r.progress=="number"&&n.push({type:"progress",pct:r.progress});break}case"clarification":{let r=e.data??{};typeof r.message=="string"&&n.push({type:"clarification",text:r.message});break}case"chatting_stopped":{let r=e.data??{};typeof r.message=="string"&&r.message.length>0&&n.push({type:"chat",text:r.message});break}case"limit_update":{let r=e.data??{},o=r.test_cases_limit??e.test_cases_limit,p=r.per_scenario_test_cases_limit??e.per_scenario_test_cases_limit;n.push({type:"limit",scenarioLimit:o,perScenarioLimit:p});break}case"error":{let r=typeof e.data=="string"?e.data:e.data?.message??"generation error";n.push({type:"error",message:r});break}case"request_cancelled":return n.push({type:"done",status:"stopped"}),n;case"session_ended":return n.push({type:"done",status:"ended"}),n;default:break}if(Array.isArray(e.scenarios)&&n.push({type:"snapshot",data:{requestId:t,status:d,headline:e.headline,scenarios:e.scenarios}}),d&&U(d)){let r=d.trim().toLowerCase();n.push({type:"done",status:r})}return n}function se(e){if(!e)return;let t=/^([\d.]+)(ms|s)?$/.exec(e.trim());if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return t[2]==="ms"?Math.round(n):Math.round(n*1e3)}var v=class extends Error{constructor(t){super(t),this.name="AuthError"}},M=class extends Error{constructor(t){super(t),this.name="ForbiddenError"}},I=class extends Error{constructor(t){super(t),this.name="InsufficientCreditsError"}},k=class extends Error{constructor(n,i){super(n);this.cause=i;this.name="TransportError"}};function x(e,t){let n=t?.message??t?.error??`HTTP ${e}`;return e===401?new v(n):e===403?t?.key==="insufficient_credits"?new I(n):new M(n):new k(n)}async function*J(e){let t=e.fetchImpl??fetch,n=e.maxRetries??5,i=e.maxBackoffMs??3e4,d=e.connectTimeoutMs??1e4,r=0,o=!1;for(;;){if(e.signal.aborted)return;let p=new AbortController,a=()=>p.abort();e.signal.addEventListener("abort",a,{once:!0});let c=setTimeout(()=>p.abort(),d),g;try{g=await t(e.url,{method:"GET",headers:{Authorization:await e.authHeader(),Accept:"text/event-stream"},signal:p.signal})}catch(w){if(clearTimeout(c),e.signal.removeEventListener("abort",a),e.signal.aborted)return;if(++r>n)throw new k("SSE connect failed",w);await O(F(r,i));continue}if(clearTimeout(c),!g.ok){e.signal.removeEventListener("abort",a);let w=await oe(g);if(g.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(g.status,w)}if(!g.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let m=g.body.getReader(),h=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await m.cancel().catch(()=>{});return}let{done:w,value:s}=await m.read();if(w)break;b+=h.decode(s,{stream:!0});let f;for(;(f=b.indexOf(`
3
3
 
4
4
  `))>=0;){let u=b.slice(0,f);b=b.slice(f+2);let l=ie(u);l&&(yield l)}}}catch(w){if(e.signal.aborted)return;if(++r>n)throw new k("SSE stream dropped",w);await O(F(r,i));continue}finally{e.signal.removeEventListener("abort",a)}return}}function ie(e){let t="message",n="";for(let i of e.split(`
5
5
  `))i.startsWith("event:")?t=i.slice(6).trim():i.startsWith("data:")&&(n+=i.slice(5).trim());if(t!=="message"||!n)return null;try{let i=Buffer.from(n,"base64").toString("utf-8");return JSON.parse(i)}catch{return null}}function F(e,t){return Math.min(t,1e3*2**(e-1))}function O(e){return new Promise(t=>setTimeout(t,e))}async function oe(e){try{return await e.clone().json()}catch{return}}function W(e,t){t?.length&&(e.append("files",t.map(n=>n.fileKey).join(",")),e.append("gemini_metadata",JSON.stringify(t.map(n=>({fileData:{fileUri:n.geminiUri,mimeType:n.mimeType}})))))}function Ue(e,t={}){let n=t.fetchImpl??fetch,i=new Map,d=!0;async function r(){let s=await e.authResolver.resolve();if(!s)throw new v("unauthorized; run `kane-cli login`");return E(s.username,s.access_key)}function o(s){return`${e.baseUrl}${s}`}async function p(s){if(!s.ok){let f;try{f=await s.clone().json()}catch{f=void 0}throw x(s.status,f)}return s.json()}function a(s){let f=s?.data??s;return{request_id:f.request_id??f.id,status:f.status??""}}function c(s,f,u,l){let y=q({requestId:s,objective:f});l&&(y=P(y,{type:"snapshot",data:l}),l.status==="cleaned_up"&&(y={...y,error:"session was reaped (cleaned_up) \u2014 continuing will destructively regenerate"}));let S=new AbortController;u&&(u.aborted?S.abort():u.addEventListener("abort",()=>S.abort(),{once:!0})),i.set(s,S);let A={requestId:s,state:y,events:void 0};return A.events=(async function*(){try{let C=J({url:o(`/requests/${s}/sse`),authHeader:r,signal:S.signal,log:e.log,fetchImpl:n});for await(let L of C)for(let z of H(L,s))A.state=P(A.state,z),yield z}finally{i.delete(s)}})(),A}async function g(s,f){let u=new FormData;u.append("prompt",s.prompt),d=s.memoryEnhancement??!0,u.append("memory_enhancement",String(d)),s.scenarioLimit!==void 0&&u.append("test_scenario_limit",String(s.scenarioLimit)),s.perScenarioLimit!==void 0&&u.append("per_scenario_test_cases_limit",String(s.perScenarioLimit));let l=s.projectId??e.projectId,y=s.folderId??e.folderId;l&&u.append("project_id",l),y&&u.append("folder_id",y),W(u,s.attachments);let S=await n(o("/requests"),{method:"POST",headers:{Authorization:await r()},body:u}),A=await p(S),{request_id:C}=a(A),L=String(C);return c(L,s.prompt,f)}async function m(s,f){let u=await n(o(`/requests/${s}`),{method:"GET",headers:{Authorization:await r()}}),l=await p(u),y=l?.data??l,S={requestId:s,status:y.status??"",headline:y.headline,scenarios:Array.isArray(y.scenarios)?y.scenarios:[]};return c(s,"",f,S)}async function h(s,f,u){let l=new FormData;l.append("prompt",f),l.append("chat_enabled","true"),l.append("memory_enhancement",String(d)),u?.mappings&&l.append("mappings",JSON.stringify(u.mappings)),W(l,u?.attachments);let y=await n(o(`/requests/${s}`),{method:"PUT",headers:{Authorization:await r()},body:l});if(!y.ok){let S;try{S=await y.clone().json()}catch{}throw x(y.status,S)}}async function b(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/stop`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}async function w(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/end`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}return{start:g,attach:m,chat:h,cancel:b,end:w}}import{statSync as ae,realpathSync as G,existsSync as ce}from"fs";import{extname as ue,resolve as j,isAbsolute as pe}from"path";import{homedir as V}from"os";var de=new Set([".txt",".md",".json",".xml",".jpg",".jpeg",".png",".gif",".bmp",".webp",".pdf",".docx",".csv",".xlsx",".mp3",".wav",".m4a",".webm",".mpeg",".mpga",".mp4",".mov"]),le=50*1024*1024,X=10;function fe(e){return e==="~"?V():e.startsWith("~/")?j(V(),e.slice(2)):e}function Ge(e,t){let n=[],i=[],d=new Set,r=[],o=(()=>{try{return G(j(t))}catch{return j(t)}})(),p=o.endsWith("/")?o:o+"/";for(let a of e){let c=fe(a),g=pe(c)?c:j(t,c);if(!ce(g)){n.push(`Not found: ${a}`);continue}let m;try{m=G(g)}catch{n.push(`Cannot resolve: ${a}`);continue}if(d.has(m))continue;let h;try{h=ae(m)}catch{n.push(`Cannot read: ${a}`);continue}if(!h.isFile()){n.push(`Not a file: ${a}`);continue}if(h.size===0){n.push(`Empty file: ${a}`);continue}let b=ue(m).toLowerCase();if(!de.has(b)){n.push(`Unsupported type ${b||"(none)"}: ${a}`);continue}if(h.size>le){n.push(`Too large (>50MB): ${a}`);continue}m!==o&&!m.startsWith(p)&&i.push(`Outside working dir: ${a}`),d.add(m),r.push(m)}return r.length>X&&n.push(`Too many files: ${r.length} (max ${X})`),{ok:n.length?[]:r,errors:n,warnings:i}}var B=class extends Error{constructor(n){super(n.join("; "));this.errors=n;this.name="AttachmentValidationError"}};async function Xe(e){let{promptText:t,filePaths:n,cwd:i,scenarios:d,isRefine:r,conn:o,deps:p}=e,{ok:a,errors:c,warnings:g}=p.validate(n,i);if(c.length)throw new B(c);e.onValidated?.();let m=a.length?await p.upload(o,a,p.onUpload):[],h=r?p.buildMappings(t,d):void 0;return{promptText:t,mappings:h,attachments:m,warnings:g}}import{readFile as me}from"fs/promises";import{basename as K}from"path";async function ge(e){let t=await e.authResolver.resolve();if(!t)throw new v("unauthorized; run `kane-cli login`");return E(t.username,t.access_key)}async function he(e,t,n={}){let i=n.fetchImpl??fetch,d=await me(t),r=K(t),o=new FormData;o.append("file",new Blob([d]),r),o.append("source","omniBox"),o.append("geminiFileUpload","true");let p=await i(`${e.tmsBaseUrl}/v1/attachment`,{method:"POST",headers:{Authorization:await ge(e)},body:o,signal:n.signal});if(!p.ok){let h;try{h=await p.clone().json()}catch{}throw x(p.status,h)}let a=await p.json(),c=a?.data??a,g=c?.gemini_response?.uri,m=c?.gemini_response?.mimeType;if(!c?.file_key||!g){let h=c&&typeof c=="object"?Object.keys(c).join(","):typeof c,b=(()=>{try{return JSON.stringify(c).slice(0,500)}catch{return"<unserializable>"}})();throw new Error(`attachment upload for ${r} returned no file_key/gemini uri \u2014 status ${p.status}, body keys: [${h}], raw: ${b}`)}return{fileName:c.file_name??r,fileKey:c.file_key,geminiUri:g,mimeType:m??"application/octet-stream"}}async function tt(e,t,n,i={}){let d=[];for(let r=0;r<t.length;r++){if(i.signal?.aborted)throw Object.assign(new Error("upload aborted"),{name:"AbortError"});let o=K(t[r]);n?.({file:o,index:r+1,total:t.length,status:"uploading"});try{d.push(await he(e,t[r],i)),n?.({file:o,index:r+1,total:t.length,status:"done"})}catch(p){throw n?.({file:o,index:r+1,total:t.length,status:"failed"}),p}}return d}var ye=/@([sS])(\d+)\.([cC])(\d+)/g,be=/@([sS])(\d+)(?!\d)(?!\.[cC]\d)/g;function rt(e,t){let n={},i={};for(let d of e.matchAll(ye)){let r=Number(d[2]),o=Number(d[4]),p=t[r-1];if(!p)continue;n[`s${r}`]=String(p.id);let a=p.test_cases??[];if(a[o-1])for(let c=0;c<o;c++){let g=a[c];g&&(i[`s${r}.c${c+1}`]=String(g.id))}}for(let d of e.matchAll(be)){let r=Number(d[2]),o=t[r-1];o&&(n[`s${r}`]=String(o.id))}if(!(Object.keys(n).length===0&&Object.keys(i).length===0))return{scenario:n,testcase:i}}function R(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(n==null||typeof n!="object")return[];let i=n;if(typeof i.step!="string")return[];let d=typeof i.expected_result=="string"?i.expected_result:typeof i.outcome=="string"?i.outcome:"";t.push({step:i.step,expected:d})}return t}var we=30,Se=300;function Z(){return{mode:"testing",max_steps:we,timeout:Se,variables:{}}}function Q(e){return e.title??`Test case ${e.id}`}function ct(e,t){return $({frontmatter:Z(),heading:Q(t),steps:e.sub_objectives.map(n=>n.objective)})}function Y(e){let t=R(e.manual_steps).map(n=>n.step);return $({frontmatter:Z(),heading:Q(e),steps:t})}import{mkdtempSync as xe,mkdirSync as N,writeFileSync as ee,rmSync as te,renameSync as _e,existsSync as ne,readFileSync as ve}from"fs";import{join as _,resolve as ke}from"path";async function ft(e,t,n,i=Y){(n.redirectBareCwd??!0)&&ke(t)===process.cwd()&&(t=_(t,".testmuai","tests"));let d=T(e.objective)??e.headline,r=T(n.suiteName)??`${T(re(d,4))??"tcg"}-${e.requestId}`,o=r,p=_(t,r);ne(p)&&!Te(p,e.requestId)&&(o=`${r}-${e.requestId}`);let a=_(t,o),c=[],g=new Map;for(let h of e.scenarios){let b=(h.test_cases??[]).filter(Ae);if(b.length===0)continue;let w=T(Ee(h.scode))??T(h.sid)??`s${h.id}`,s=g.get(w)??new Set;g.set(w,s);for(let f of b){let u=T(re(f.title,5))??"case",l=`${u}_test.md`;for(let y=2;s.has(l);y++)l=`${u}-${y}_test.md`;s.add(l),c.push({dir:w,file:l,tc:f})}}if(c.length===0)return{suiteDir:a,paths:[],warning:"no functional test cases generated"};N(t,{recursive:!0});let m=xe(_(t,".tcg-tmp-"));try{N(_(m,"helpers"),{recursive:!0}),ee(_(m,".tcg-suite.json"),JSON.stringify({requestId:e.requestId,suiteName:o}));let h=[],b=new Set;for(let s of c){let f=_(m,s.dir);b.has(f)||(N(f,{recursive:!0}),b.add(f));let u=_(f,s.file);ee(u,i(s.tc)),h.push(u)}ne(a)&&te(a,{recursive:!0,force:!0}),_e(m,a);let w=h.map(s=>s.replace(m,a));return{suiteDir:a,paths:w}}catch(h){try{te(m,{recursive:!0,force:!0})}catch{}throw h}}function Ae(e){return(e.category??"").trim().toLowerCase()==="functional"}function Te(e,t){try{return JSON.parse(ve(_(e,".tcg-suite.json"),"utf-8"))?.requestId===t}catch{return!1}}function T(e){return e&&e.length>0?e:void 0}function re(e,t){return e?e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean).slice(0,t).join("-"):""}function Ee(e){return e?e.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,""):""}function ht(e){let t=[];e.title&&t.push(e.title),e.description&&t.push("",e.description);let n=R(e.manual_steps);return n.length>0&&(t.push("","Steps:"),n.forEach((i,d)=>{t.push(`${d+1}. ${i.step}`)})),t.join(`
@@ -0,0 +1,9 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as N,b as U,c as Y,d as L}from"./chunk-P3JUE2RM.js";import{l as R,m as D,o as P}from"./chunk-AHXOKBVE.js";import{g as A}from"./chunk-55YDTPB7.js";import{i as G}from"./chunk-YCH7H7JX.js";import{T as S,W as k,X as C}from"./chunk-6LGED4FC.js";import{c as E}from"./chunk-H6TNBKGR.js";import{a as h}from"./chunk-CH273NAE.js";import{C as y}from"./chunk-GP7WD4UY.js";import{t as T}from"./chunk-3N6IAVD5.js";import{existsSync as H}from"fs";import{basename as Z}from"path";import{appendFileSync as W,mkdirSync as B}from"fs";import{homedir as X}from"os";import{dirname as K,join as V}from"path";function F(d,a){let t=/^(DOCX_[A-Z_]+):/.exec(a)?.[1];if(t)try{let u=process.env.KANE_CONTEXT_REFUSAL_LOG??V(X(),".testmuai","kaneai","context-refusals.log");B(K(u),{recursive:!0}),W(u,`${new Date().toISOString()} ${t} ${d}
3
+ `)}catch{}}function j(d){return d?.outcome==="added"?"added .context/ to .gitignore":d?.outcome==="failed"?`warning: could not add .context/ to .gitignore: ${d.reason}`:null}async function x(d,a,t,u=process.cwd(),f){let l=h(u),g=[];if(a.as!==void 0&&d.length>1)return(t.err??t.out)(`error: --as names ONE source identity \u2014 pass a single file (got ${d.length})`,"AS_SINGLE_SOURCE"),{code:2,results:g};for(let i of d){if(Y(i)){let e=L(i);if(e===null)return(t.err??t.out)(`error: ${i}: unsupported remote URL \u2014 supported: ${U.map(c=>c.hint).join("; ")}`,"UNSUPPORTED_URL"),{code:1,results:g};let o=await e.ingest(i,a.as,t,l,f);if(o.code!==0)return{code:o.code,results:g};if(o.result){let c=j(o.result.gitignore);c&&t.out(c),g.push({status:o.result.status==="versioned"?"versioned":o.result.status==="unchanged"?"unchanged":"created",source_id:o.result.source_id,source_cid:o.result.source_cid,...o.result.gitignore?{gitignore:o.result.gitignore}:{}})}continue}let m=a.as,p;if(m===void 0&&H(l)){let e=R(i),o=D(e);if(o){let c=y(l);c.heads.get(o)!=null&&c.heads.get(e)==null&&(p=o,t.isTTY&&await t.confirm(`${e} looks like a new version of existing source '${o}' \u2014 ingest as '${o}' (replaces the current version; items built on it go stale)?`)&&(m=o))}}let n;try{n=await P({contextDir:l,filePath:i,asId:m,confirmSameSource:t.isTTY?e=>t.confirm(`identical bytes already ingested as ${e} \u2014 treat as the same source?`):void 0,converters:{pdf:A,docx:G}})}catch(e){let o=e instanceof Error?e.message:String(e);return e instanceof T?((t.err??t.out)(`error: ${o}`,e.code),(t.err??t.out)(`next: ${e.remedy}`,e.code),{code:2,results:g}):(F(i,o),(t.err??t.out)(`error: ${i}: ${o}`,"INGEST_FAILED"),{code:1,results:g})}t.out(N(t.isTTY,n,Z(i)));for(let e of n.warnings??[])t.out(`warning: ${e}`);let _=j(n.gitignore);if(_&&t.out(_),n.composite&&(n.composite.delivered>0||n.composite.omitted>0)){let e=n.composite.pages!==void 0?` ${n.composite.pages} pages,`:"";t.out(`${n.source_id}: ${n.composite.kind},${e} ${n.composite.delivered} images delivered (${n.composite.omitted} omitted)`)}let v;if(!t.isTTY&&n.status==="created"){let e=y(l);for(let[o,c]of e.heads.entries())if(!(o===n.source_id||c==null)&&e.getNode(c)?.content.blob===n.blob){v=o,t.out(`hint: identical bytes already ingested as ${o} \u2014 merged later via review`);break}}g.push({status:n.status,source_id:n.source_id,source_cid:n.cid,...n.warnings?.length?{warnings:n.warnings}:{},...n.composite?{media:{kind:n.composite.kind,...n.composite.pages!==void 0?{pages:n.composite.pages}:{},delivered:n.composite.delivered,omitted:n.composite.omitted}}:{},...v?{duplicate_of:v}:{},...p&&m===void 0?{lineage_candidate:p}:{},...n.gitignore?{gitignore:n.gitignore}:{}})}return{code:0,results:g}}async function le(d,a,t,u=process.cwd(),f){return(await x(d,a,t,u,f)).code}async function fe(d,a){if(a.mode!=null&&!["interactive","agent","ci","override"].includes(a.mode)){let{makeHeadlessIO:r,agentRefusal:s}=await import("./headless-io-3A3BZVQ5.js");return s(r("ndjson","extract"),`ingest: --mode must be interactive | agent | ci | override, got '${a.mode}'`,"MODE_USAGE")}let t=E();if(a.mode==="interactive"&&!t)return process.stderr.write(`ingest: --mode interactive needs a TTY on stdin and stdout (use --mode agent|ci|override headless)
4
+ `),2;let u=a.mode??(t?"interactive":void 0),f=u==="interactive"||u==="agent"||u==="override";if(!f&&(a.plan||a.force||a.trust!==void 0))return process.stderr.write(`ingest: --plan/--force/--trust steer the extraction \u2014 not available when only landing (use --mode agent to extract headless)
5
+ `),2;let{createInterface:l}=await import("readline/promises"),g=u==="agent",i=g?(await import("./headless-io-3A3BZVQ5.js")).makeHeadlessIO("ndjson","extract"):null,m=H(h(process.cwd()))?k(h(process.cwd())):null;if(m)return i?(i.event(C(m)),i.done(2,"refused")):(process.stderr.write(`error: ${m.text}
6
+ next: ${m.remedy}
7
+ `),2);let p=[],n=()=>{for(let r of p.splice(0))i.event({type:"error",message:r.message,...r.code?{code:r.code}:{}})},_=r=>{for(let s of r)i.event({type:"ingested",source_id:s.source_id,status:s.status,cid:s.source_cid,...s.warnings?.length?{warnings:s.warnings}:{},...s.media?{media:s.media}:{},...s.duplicate_of?{duplicate_of:s.duplicate_of}:{},...s.lineage_candidate?{lineage_candidate:s.lineage_candidate}:{}})},v=r=>{for(let s of r)s.gitignore?.outcome==="added"?i.event({type:"gitignore_updated",path:".gitignore"}):s.gitignore?.outcome==="failed"&&i.event({type:"warning",message:`could not add .context/ to .gitignore: ${s.gitignore.reason}`})},e=i?{out:()=>{},err:(r,s)=>p.push({message:r.replace(/^error: /,""),...s?{code:s}:{}}),isTTY:!1,confirm:async()=>!1}:{out:r=>process.stdout.write(r+`
8
+ `),err:r=>process.stderr.write(r+`
9
+ `),isTTY:t,confirm:async r=>{let s=l({input:process.stdin,output:process.stdout});try{let O=await s.question(`${r} [Y/n] `);return!/^n(o)?$/i.test(O.trim())}finally{s.close()}}};if(!f){let{withTelemetry:r}=await import("./with-telemetry-P6RUPWBH.js");return r("ingest",async()=>{await S(h(process.cwd()),I=>(e.err??e.out)(I));let{code:s,results:O}=await x(d,{as:a.as},e,void 0,void 0);if(s!==0)return s;let b=O.filter(I=>I.status!=="unchanged").length;return b>0&&(e.err??e.out)(`landed ${b} source(s) \u2014 run kane-cli context extract to extract them`),0},{write:!0})}let o;try{o=i?await(await import("./run-channel-RGH4WIQX.js")).runWithChannel({event:i.event},()=>x(d,{as:a.as},e,void 0,void 0)):await x(d,{as:a.as},e,void 0,void 0)}catch(r){if(i)return n(),i.event({type:"error",message:r instanceof Error?r.message:String(r),code:"INGEST_FAILED"}),i.done(1,"error");throw r}let{code:c,results:w}=o;if(i&&v(w),c!==0)return i?(_(w),n(),i.done(c,c===2?"refused":"error")):c;if(w.length===0)return i?i.done(0):0;let{extractCommand:q}=await import("./extract-cmd-CCYW7FIY.js"),M=[...new Set(w.map(r=>r.source_id))],$=await q({...a.mode!==void 0?{mode:a.mode}:{},...a.plan?{plan:!0}:{},...a.force?{force:!0}:{},...a.trust!==void 0?{trust:a.trust}:{},sources:M,landed:w});if($===2&&!g){let r=w.filter(s=>s.status!=="unchanged").length;r>0&&(e.err??e.out)(`note: the ${r} landed source(s) are safe \u2014 extract later with kane-cli context extract`)}return $}export{x as a,le as b,fe as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-5Y2G4NC7.js";import{y as o}from"./chunk-33GXXC2L.js";import{a as n}from"./chunk-HCBYKLMW.js";import{b as t}from"./chunk-C44QQJR4.js";import{a as s}from"./chunk-6YGTRKDT.js";import{e as r}from"./chunk-UR6MHSHU.js";var l=r(s(),1);var m=r(n(),1),i=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function b({active:e=!0}){let[p,c]=(0,l.useState)(0);return a(()=>{c(f=>(f+1)%i.length)},e?80:null),(0,m.jsx)(t,{color:o.orange,children:e?i[p]:"\u25CF"})}export{b as a};
2
+ import{a}from"./chunk-5Y2G4NC7.js";import{y as o}from"./chunk-B2ZGG7WM.js";import{a as n}from"./chunk-HCBYKLMW.js";import{b as t}from"./chunk-C44QQJR4.js";import{a as s}from"./chunk-6YGTRKDT.js";import{e as r}from"./chunk-UR6MHSHU.js";var l=r(s(),1);var m=r(n(),1),i=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function b({active:e=!0}){let[p,c]=(0,l.useState)(0);return a(()=>{c(f=>(f+1)%i.length)},e?80:null),(0,m.jsx)(t,{color:o.orange,children:e?i[p]:"\u25CF"})}export{b as a};
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as k}from"./chunk-VYMMGWVO.js";import{a as m}from"./chunk-BPMSNGXQ.js";import{r as a}from"./chunk-RSSOJ3L2.js";import{a as y}from"./chunk-NUWOQS6L.js";import{a as h}from"./chunk-3M2D7UUI.js";var $=10,u=200,N=1e4,S=1e6;function T(t,e,r="streaming"){let n=r==="full-fetch"?S:N,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function C(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function j(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
2
+ import{a as k}from"./chunk-4BBDKWM3.js";import{a as m}from"./chunk-BPMSNGXQ.js";import{r as a}from"./chunk-RSSOJ3L2.js";import{a as y}from"./chunk-OH2NSBO6.js";import{a as h}from"./chunk-IQ7NGOAT.js";var $=10,u=200,N=1e4,S=1e6;function T(t,e,r="streaming"){let n=r==="full-fetch"?S:N,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function C(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function j(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
3
3
  `)){for(let n of t)r(JSON.stringify(n));r(JSON.stringify({_meta:"page",limit:e.limit,offset:e.offset,returned:t.length,has_more:e.has_more}))}function b(t,e,r=n=>process.stdout.write(`${n}
4
- `)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-NL5AM446.js"),w=await d({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(d){return{ok:!1,reason:"refresh_failed",detail:d instanceof Error?d.message:String(d)}}let c=y(e),f=await new k(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
4
+ `)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-KN5JK2U4.js"),w=await d({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(d){return{ok:!1,reason:"refresh_failed",detail:d instanceof Error?d.message:String(d)}}let c=y(e),f=await new k(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
5
5
  `,exitCode:2};case"refresh_failed":return{message:`error: OAuth token refresh failed for profile "${t}" [${e}]${r.detail?`: ${r.detail}`:""}. Run \`kane-cli login\` to re-auth.
6
6
  `,exitCode:2};case"exchange_failed":return{message:`error: TMS credential exchange failed for profile "${t}" [${e}]. Token may be revoked \u2014 try \`kane-cli login\`; if the problem persists, TMS may be down.
7
7
  `,exitCode:2}}}function O(t){return{id:t.project_id,name:t.name}}function M(t){return{id:t.id,name:t.name}}async function P(t,e,r,n){let o=r+n+1,i=[],s=!0;for await(let c of t.listProjectsStream({name:e})){if(i.push(...c.projects),c.done){s=!0;break}if(i.length>=o){s=!1;break}}return{items:i,doneStreaming:s}}function g(t){return!!t.agent||!process.stdin.isTTY||!process.stdout.isTTY}function _(t,e=r=>process.stdout.write(`${r}
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as vt}from"./chunk-BKHXPBWN.js";import{a as Ot,b as Mt}from"./chunk-2UIHS2FH.js";import{a as kt}from"./chunk-N2P4MI32.js";import{b as wt}from"./chunk-NVGBE2DR.js";import{a as Nt,b as Ft,c as St}from"./chunk-MSGW4JDG.js";import{c as G,e as Rt}from"./chunk-UR6MHSHU.js";var Lt=G(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.CHAR=`
2
+ import{a as Ot,b as Mt}from"./chunk-2UIHS2FH.js";import{a as vt}from"./chunk-BKHXPBWN.js";import{a as kt}from"./chunk-N2P4MI32.js";import{b as wt}from"./chunk-IE3OO5GI.js";import{a as Nt,b as Ft,c as St}from"./chunk-MSGW4JDG.js";import{c as G,e as Rt}from"./chunk-UR6MHSHU.js";var Lt=G(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.CHAR=`
3
3
  \r -\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}`;x.S=` \r
4
4
  `;x.NAME_START_CHAR=":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";x.NAME_CHAR="-"+x.NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";x.CHAR_RE=new RegExp("^["+x.CHAR+"]$","u");x.S_RE=new RegExp("^["+x.S+"]+$","u");x.NAME_START_CHAR_RE=new RegExp("^["+x.NAME_START_CHAR+"]$","u");x.NAME_CHAR_RE=new RegExp("^["+x.NAME_CHAR+"]$","u");x.NAME_RE=new RegExp("^["+x.NAME_START_CHAR+"]["+x.NAME_CHAR+"]*$","u");x.NMTOKEN_RE=new RegExp("^["+x.NAME_CHAR+"]+$","u");var tt=9,et=10,st=13,it=32;x.S_LIST=[it,et,st,tt];function Ne(e){return e>=it&&e<=55295||e===et||e===st||e===tt||e>=57344&&e<=65533||e>=65536&&e<=1114111}x.isChar=Ne;function Fe(e){return e===it||e===et||e===st||e===tt}x.isS=Fe;function Pt(e){return e>=65&&e<=90||e>=97&&e<=122||e===58||e===95||e===8204||e===8205||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}x.isNameStartChar=Pt;function Se(e){return Pt(e)||e>=48&&e<=57||e===45||e===46||e===183||e>=768&&e<=879||e>=8255&&e<=8256}x.isNameChar=Se});var Ht=G(f=>{"use strict";Object.defineProperty(f,"__esModule",{value:!0});f.CHAR="-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}";f.RESTRICTED_CHAR="-\b\v\f-\x7F-\x84\x86-\x9F";f.S=` \r
5
5
  `;f.NAME_START_CHAR=":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";f.NAME_CHAR="-"+f.NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";f.CHAR_RE=new RegExp("^["+f.CHAR+"]$","u");f.RESTRICTED_CHAR_RE=new RegExp("^["+f.RESTRICTED_CHAR+"]$","u");f.S_RE=new RegExp("^["+f.S+"]+$","u");f.NAME_START_CHAR_RE=new RegExp("^["+f.NAME_START_CHAR+"]$","u");f.NAME_CHAR_RE=new RegExp("^["+f.NAME_CHAR+"]$","u");f.NAME_RE=new RegExp("^["+f.NAME_START_CHAR+"]["+f.NAME_CHAR+"]*$","u");f.NMTOKEN_RE=new RegExp("^["+f.NAME_CHAR+"]+$","u");var yt=9,It=10,Bt=13,Xt=32;f.S_LIST=[Xt,It,Bt,yt];function we(e){return e>=1&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111}f.isChar=we;function ke(e){return e>=1&&e<=8||e===11||e===12||e>=14&&e<=31||e>=127&&e<=132||e>=134&&e<=159}f.isRestrictedChar=ke;function ve(e){return e===9||e===10||e===13||e>31&&e<127||e===133||e>159&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111}f.isCharAndNotRestricted=ve;function Oe(e){return e===Xt||e===It||e===Bt||e===yt}f.isS=Oe;function $t(e){return e>=65&&e<=90||e>=97&&e<=122||e===58||e===95||e===8204||e===8205||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}f.isNameStartChar=$t;function Me(e){return $t(e)||e>=48&&e<=57||e===45||e===46||e===183||e>=768&&e<=879||e>=8255&&e<=8256}f.isNameChar=Me});var Ut=G(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.NC_NAME_START_CHAR="A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";N.NC_NAME_CHAR="-"+N.NC_NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";N.NC_NAME_START_CHAR_RE=new RegExp("^["+N.NC_NAME_START_CHAR+"]$","u");N.NC_NAME_CHAR_RE=new RegExp("^["+N.NC_NAME_CHAR+"]$","u");N.NC_NAME_RE=new RegExp("^["+N.NC_NAME_START_CHAR+"]["+N.NC_NAME_CHAR+"]*$","u");function Wt(e){return e>=65&&e<=90||e===95||e>=97&&e<=122||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}N.isNCNameStartChar=Wt;function Pe(e){return Wt(e)||e===45||e===46||e>=48&&e<=57||e===183||e>=768&&e<=879||e>=8255&&e<=8256}N.isNCNameChar=Pe});var Ct=G(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.SaxesParser=B.EVENTS=void 0;var X=Lt(),Le=Ht(),xt=Ut(),F=X.isS,ye=X.isChar,W=X.isNameStartChar,Vt=X.isNameChar,ne=X.S_LIST,Ie=X.NAME_RE,Be=Le.isChar,Xe=xt.isNCNameStartChar,$e=xt.isNCNameChar,He=xt.NC_NAME_RE,K="http://www.w3.org/XML/1998/namespace",I="http://www.w3.org/2000/xmlns/",We={__proto__:null,xml:K,xmlns:I},Ue={__proto__:null,amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},C=-1,k=-2,Gt=0,Ve=1,nt=2,Ge=3,P=4,qe=5,je=6,ze=7,rt=8,Ye=9,Qe=10,Ke=11,Ze=12,A=13,q=14,at=15,Je=16,ot=17,ts=18,es=19,ht=20,ss=21,is=22,ns=23,qt=24,lt=25,j=26,jt=27,rs=28,as=29,zt=30,os=31,hs=32,O=33,ls=34,ct=35,U=36,ut=37,cs=38,Yt=39,Qt=40,us=41,Kt=42,ds=43,fs=44,dt=9,w=10,ft=13,Zt=32,Jt=33,re=34,V=38,ae=39,z=45,Y=47,ps=59,v=60,L=61,D=62,T=63,oe=91,y=93,te=133,ee=8232,Q=e=>e===re||e===ae,he=[re,ae],ms=[...he,oe,D],gs=[...he,v,y],xs=[L,T,...ne],Cs=[...ne,D,V,v];function mt(e,t,s){switch(t){case"xml":s!==K&&e.fail(`xml prefix must be bound to ${K}.`);break;case"xmlns":s!==I&&e.fail(`xmlns prefix must be bound to ${I}.`);break;default:}switch(s){case I:e.fail(t===""?`the default namespace may not be set to ${s}.`:`may not assign a prefix (even "xmlns") to the URI ${I}.`);break;case K:switch(t){case"xml":break;case"":e.fail(`the default namespace may not be set to ${s}.`);break;default:e.fail("may not assign the xml namespace to another prefix.")}break;default:}}function _s(e,t){for(let s of Object.keys(t))mt(e,s,t[s])}var Es=e=>He.test(e),Ds=e=>Ie.test(e),M=0,se=1,pt=2;B.EVENTS=["xmldecl","text","processinginstruction","doctype","comment","opentagstart","attribute","opentag","closetag","cdata","error","end","ready"];var ie={xmldecl:"xmldeclHandler",text:"textHandler",processinginstruction:"piHandler",doctype:"doctypeHandler",comment:"commentHandler",opentagstart:"openTagStartHandler",attribute:"attributeHandler",opentag:"openTagHandler",closetag:"closeTagHandler",cdata:"cdataHandler",error:"errorHandler",end:"endHandler",ready:"readyHandler"},gt=class{constructor(t){this.opt=t??{},this.fragmentOpt=!!this.opt.fragment;let s=this.xmlnsOpt=!!this.opt.xmlns;if(this.trackPosition=this.opt.position!==!1,this.fileName=this.opt.fileName,s){this.nameStartCheck=Xe,this.nameCheck=$e,this.isName=Es,this.processAttribs=this.processAttribsNS,this.pushAttrib=this.pushAttribNS,this.ns=Object.assign({__proto__:null},We);let i=this.opt.additionalNamespaces;i!=null&&(_s(this,i),Object.assign(this.ns,i))}else this.nameStartCheck=W,this.nameCheck=Vt,this.isName=Ds,this.processAttribs=this.processAttribsPlain,this.pushAttrib=this.pushAttribPlain;this.stateTable=[this.sBegin,this.sBeginWhitespace,this.sDoctype,this.sDoctypeQuote,this.sDTD,this.sDTDQuoted,this.sDTDOpenWaka,this.sDTDOpenWakaBang,this.sDTDComment,this.sDTDCommentEnding,this.sDTDCommentEnded,this.sDTDPI,this.sDTDPIEnding,this.sText,this.sEntity,this.sOpenWaka,this.sOpenWakaBang,this.sComment,this.sCommentEnding,this.sCommentEnded,this.sCData,this.sCDataEnding,this.sCDataEnding2,this.sPIFirstChar,this.sPIRest,this.sPIBody,this.sPIEnding,this.sXMLDeclNameStart,this.sXMLDeclName,this.sXMLDeclEq,this.sXMLDeclValueStart,this.sXMLDeclValue,this.sXMLDeclSeparator,this.sXMLDeclEnding,this.sOpenTag,this.sOpenTagSlash,this.sAttrib,this.sAttribName,this.sAttribNameSawWhite,this.sAttribValue,this.sAttribValueQuoted,this.sAttribValueClosed,this.sAttribValueUnquoted,this.sCloseTag,this.sCloseTagSawWhite],this._init()}get closed(){return this._closed}_init(){var t;this.openWakaBang="",this.text="",this.name="",this.piTarget="",this.entity="",this.q=null,this.tags=[],this.tag=null,this.topNS=null,this.chunk="",this.chunkPosition=0,this.i=0,this.prevI=0,this.carriedFromPrevious=void 0,this.forbiddenState=M,this.attribList=[];let{fragmentOpt:s}=this;this.state=s?A:Gt,this.reportedTextBeforeRoot=this.reportedTextAfterRoot=this.closedRoot=this.sawRoot=s,this.xmlDeclPossible=!s,this.xmlDeclExpects=["version"],this.entityReturnState=void 0;let{defaultXMLVersion:i}=this.opt;if(i===void 0){if(this.opt.forceXMLVersion===!0)throw new Error("forceXMLVersion set but defaultXMLVersion is not set");i="1.0"}this.setXMLVersion(i),this.positionAtNewLine=0,this.doctype=!1,this._closed=!1,this.xmlDecl={version:void 0,encoding:void 0,standalone:void 0},this.line=1,this.column=0,this.ENTITIES=Object.create(Ue),(t=this.readyHandler)===null||t===void 0||t.call(this)}get position(){return this.chunkPosition+this.i}get columnIndex(){return this.position-this.positionAtNewLine}on(t,s){this[ie[t]]=s}off(t){this[ie[t]]=void 0}makeError(t){var s;let i=(s=this.fileName)!==null&&s!==void 0?s:"";return this.trackPosition&&(i.length>0&&(i+=":"),i+=`${this.line}:${this.column}`),i.length>0&&(i+=": "),new Error(i+t)}fail(t){let s=this.makeError(t),i=this.errorHandler;if(i===void 0)throw s;return i(s),this}write(t){if(this.closed)return this.fail("cannot write after close; assign an onready handler.");let s=!1;t===null?(s=!0,t=""):typeof t=="object"&&(t=t.toString()),this.carriedFromPrevious!==void 0&&(t=`${this.carriedFromPrevious}${t}`,this.carriedFromPrevious=void 0);let i=t.length,n=t.charCodeAt(i-1);!s&&(n===ft||n>=55296&&n<=56319)&&(this.carriedFromPrevious=t[i-1],i--,t=t.slice(0,i));let{stateTable:r}=this;for(this.chunk=t,this.i=0;this.i<i;)r[this.state].call(this);return this.chunkPosition+=i,s?this.end():this}close(){return this.write(null)}getCode10(){let{chunk:t,i:s}=this;if(this.prevI=s,this.i=s+1,s>=t.length)return C;let i=t.charCodeAt(s);if(this.column++,i<55296){if(i>=Zt||i===dt)return i;switch(i){case w:return this.line++,this.column=0,this.positionAtNewLine=this.position,w;case ft:return t.charCodeAt(s+1)===w&&(this.i=s+2),this.line++,this.column=0,this.positionAtNewLine=this.position,k;default:return this.fail("disallowed character."),i}}if(i>56319)return i>=57344&&i<=65533||this.fail("disallowed character."),i;let n=65536+(i-55296)*1024+(t.charCodeAt(s+1)-56320);return this.i=s+2,n>1114111&&this.fail("disallowed character."),n}getCode11(){let{chunk:t,i:s}=this;if(this.prevI=s,this.i=s+1,s>=t.length)return C;let i=t.charCodeAt(s);if(this.column++,i<55296){if(i>31&&i<127||i>159&&i!==ee||i===dt)return i;switch(i){case w:return this.line++,this.column=0,this.positionAtNewLine=this.position,w;case ft:{let r=t.charCodeAt(s+1);(r===w||r===te)&&(this.i=s+2)}case te:case ee:return this.line++,this.column=0,this.positionAtNewLine=this.position,k;default:return this.fail("disallowed character."),i}}if(i>56319)return i>=57344&&i<=65533||this.fail("disallowed character."),i;let n=65536+(i-55296)*1024+(t.charCodeAt(s+1)-56320);return this.i=s+2,n>1114111&&this.fail("disallowed character."),n}getCodeNorm(){let t=this.getCode();return t===k?w:t}unget(){this.i=this.prevI,this.column--}captureTo(t){let{i:s}=this,{chunk:i}=this;for(;;){let n=this.getCode(),r=n===k,a=r?w:n;if(a===C||t.includes(a))return this.text+=i.slice(s,this.prevI),a;r&&(this.text+=`${i.slice(s,this.prevI)}
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as A}from"./chunk-YCCUBQY4.js";import{a as _}from"./chunk-NM76SG3S.js";import{a as B}from"./chunk-BPMSNGXQ.js";import{a as R}from"./chunk-ARU6KAGY.js";import{a as k}from"./chunk-NUWOQS6L.js";import{y as c}from"./chunk-33GXXC2L.js";import{a as P}from"./chunk-HCBYKLMW.js";import{a as u,b as l}from"./chunk-C44QQJR4.js";import{a as J}from"./chunk-6YGTRKDT.js";import{e as L}from"./chunk-UR6MHSHU.js";var t=L(J(),1);var e=L(P(),1);function X(n,i,y,m){return{id:n,label:`${i} (${n}) \xB7 ${y} tests`,isActive:n===m}}function W({resolver:n,projectId:i,currentFolderId:y,env:m,onSelect:x,onCancel:w}){let[I,M]=(0,t.useState)([]),[$,d]=(0,t.useState)(!0),[O,g]=(0,t.useState)(!1),[U,N]=(0,t.useState)(null),[p,b]=(0,t.useState)("list"),[S,v]=(0,t.useState)(""),[E,f]=(0,t.useState)(null),h=(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 s=await T.listFolders(i);yield{page:1,folders:s,totalLoaded:s.length,done:!0}})();for await(let s of F){if(d(!1),s.totalLoaded===0){h.current=!0,b("naming"),g(!1);return}M(s.folders.map(C=>X(C.id,C.name,C.test_cases_count,y))),s.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,i,y,m]);let D=(0,t.useCallback)(o=>{let r=o.trim();if(!r){f("Name cannot be empty");return}if(!i){f("No project selected \u2014 pick a project first");return}f(null),b("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),s=await new B(T.tmsBaseUrl,a.username,a.access_key).createFolder(i,r);x(s.id,s.name)}catch(a){f(a instanceof Error?a.message:String(a)),b("naming")}})()},[n,i,m,x]),H=(0,t.useCallback)(()=>{v(""),f(null),h.current?w():b("list")},[w]);return p==="naming"||p==="creating"?(0,e.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:c.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:c.orange,bold:!0,children:"Create new folder"}),h.current&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.dim,children:"No folders yet \u2014 let's create one."})}),(0,e.jsxs)(u,{marginTop:1,children:[(0,e.jsx)(l,{color:c.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)(l,{children:S})]}),E&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.red,children:E})}),p==="creating"&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.dim,children:"Creating..."})}),p==="naming"&&(0,e.jsx)(R,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:h.current?"cancel":"back"})]}):(0,e.jsx)(_,{title:"Folders",items:I,loading:$,loadingMore:O,preserveSelectionById:!0,error:U,itemNoun:"folders",onTab:()=>{h.current=!1,b("naming")},extraHint:"tab to create new",onSelect:o=>{let r=o.label.split(" (")[0];x(o.id,r)},onCancel:w})}export{X as a,W as b};
2
+ import{a as A}from"./chunk-YCCUBQY4.js";import{a as _}from"./chunk-RBHQXWR7.js";import{a as B}from"./chunk-BPMSNGXQ.js";import{a as R}from"./chunk-OO5GMBVI.js";import{a as k}from"./chunk-OH2NSBO6.js";import{y as c}from"./chunk-B2ZGG7WM.js";import{a as P}from"./chunk-HCBYKLMW.js";import{a as u,b as l}from"./chunk-C44QQJR4.js";import{a as J}from"./chunk-6YGTRKDT.js";import{e as L}from"./chunk-UR6MHSHU.js";var t=L(J(),1);var e=L(P(),1);function X(n,i,y,m){return{id:n,label:`${i} (${n}) \xB7 ${y} tests`,isActive:n===m}}function W({resolver:n,projectId:i,currentFolderId:y,env:m,onSelect:x,onCancel:w}){let[I,M]=(0,t.useState)([]),[$,d]=(0,t.useState)(!0),[O,g]=(0,t.useState)(!1),[U,N]=(0,t.useState)(null),[p,b]=(0,t.useState)("list"),[S,v]=(0,t.useState)(""),[E,f]=(0,t.useState)(null),h=(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 s=await T.listFolders(i);yield{page:1,folders:s,totalLoaded:s.length,done:!0}})();for await(let s of F){if(d(!1),s.totalLoaded===0){h.current=!0,b("naming"),g(!1);return}M(s.folders.map(C=>X(C.id,C.name,C.test_cases_count,y))),s.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,i,y,m]);let D=(0,t.useCallback)(o=>{let r=o.trim();if(!r){f("Name cannot be empty");return}if(!i){f("No project selected \u2014 pick a project first");return}f(null),b("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),s=await new B(T.tmsBaseUrl,a.username,a.access_key).createFolder(i,r);x(s.id,s.name)}catch(a){f(a instanceof Error?a.message:String(a)),b("naming")}})()},[n,i,m,x]),H=(0,t.useCallback)(()=>{v(""),f(null),h.current?w():b("list")},[w]);return p==="naming"||p==="creating"?(0,e.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:c.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:c.orange,bold:!0,children:"Create new folder"}),h.current&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.dim,children:"No folders yet \u2014 let's create one."})}),(0,e.jsxs)(u,{marginTop:1,children:[(0,e.jsx)(l,{color:c.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)(l,{children:S})]}),E&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.red,children:E})}),p==="creating"&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.dim,children:"Creating..."})}),p==="naming"&&(0,e.jsx)(R,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:h.current?"cancel":"back"})]}):(0,e.jsx)(_,{title:"Folders",items:I,loading:$,loadingMore:O,preserveSelectionById:!0,error:U,itemNoun:"folders",onTab:()=>{h.current=!1,b("naming")},extraHint:"tab to create new",onSelect:o=>{let r=o.label.split(" (")[0];x(o.id,r)},onCancel:w})}export{X as a,W as b};
@@ -0,0 +1,21 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as d,g as B,k as ee}from"./chunk-YLQHY4A7.js";import{P as Z}from"./chunk-3N6IAVD5.js";import{b as A}from"./chunk-B2ZGG7WM.js";import{createHash as Ie,randomBytes as F}from"crypto";import{mkdirSync as xe,mkdtempSync as P,rmSync as $,existsSync as ve,renameSync as ke}from"fs";import{tmpdir as j}from"os";import{join as _,dirname as ce}from"path";import{spawn as te}from"child_process";function N(n,e=process.env){let t=n.replace(/https?:\/\/[^\s/@]+:[^\s/@]+@/gi,"https://[redacted]@").replace(/(authorization\s*[:=])[^\r\n]+/gi,"$1 [redacted]"),r=e.KANE_SYNC_GIT_TOKEN;if(r)for(let i of[r,Buffer.from(`x-access-token:${r}`).toString("base64")])t=t.split(i).join("[redacted]");return t}function be(n,e){if(n.GIT_SSH_COMMAND)return re(n.GIT_SSH_COMMAND);if(!n.GIT_SSH)return e?re(e):"ssh -o BatchMode=yes"}function re(n){return/(^|\s)-o\s*BatchMode=yes(\s|$)/.test(n)?n:`${n} -o BatchMode=yes`}var _e=/^(?:ssh:\/\/|[^/\s@:]+@[^/\s:]+:)/i,ie=new Map;function Ae(n,e){let t=[e??"",n.GIT_CONFIG_GLOBAL??"",n.HOME??""].join("\0"),r=ie.get(t);return r===void 0&&(r=se(["config","--get","core.sshCommand"],n,e,12e4).then(i=>i.code===0&&i.stdout.toString().trim()||void 0,()=>{}),ie.set(t,r)),r}var ne=new Set(["fetch","push","clone","ls-remote"]);function Ce(n,e,t){if(t!==void 0)return t;if(!n.some(i=>ne.has(i)))return 12e4;let r=e.KANE_SYNC_GIT_TRANSFER_TIMEOUT_SECONDS;if(r!==void 0){if(!/^\d+$/.test(r)||Number(r)<60||Number(r)>3600)throw new Error("KANE_SYNC_GIT_TRANSFER_TIMEOUT_SECONDS must be 60 to 3600");return Number(r)*1e3}return 9e5}function Ne(n){if(n.some(t=>/^(--force(?:-with-lease|-if-includes)?(?:=|$)|--mirror(?:=|$)|--delete(?:=|$)|-f$)/.test(t)))throw new Error("Git location cannot force, mirror or delete");let e=n.indexOf("push");if(e>=0){let t=n.slice(e+1);if(t.length!==3||t[0]!=="--porcelain"||!/^[0-9a-f]{40,64}:refs\/(heads|kane\/probe)\/[A-Za-z0-9._/-]+$/.test(t[2]))throw new Error("Git location requires an exact commit SHA and explicit ref")}}var H=async(n,e={})=>{Ne(n);let t={...process.env,...e.env};for(let h of["GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_CONFIG_PARAMETERS"])delete t[h];e.env?.GIT_INDEX_FILE&&(t.GIT_INDEX_FILE=e.env.GIT_INDEX_FILE);let r=[["core.autocrlf","false"],["core.eol","lf"],["core.symlinks","false"],["core.hooksPath","/dev/null"],["gc.autoDetach","false"],["gc.pruneExpire","3.days.ago"],["maintenance.auto","false"],["push.followTags","false"],["push.gpgSign","false"],["commit.gpgSign","false"]],i=t.KANE_SYNC_GIT_HTTP_POST_BUFFER;if(i!==void 0){if(!/^\d+$/.test(i)||Number(i)<1048576||Number(i)>536870912)throw new Error("KANE_SYNC_GIT_HTTP_POST_BUFFER must be 1048576 to 536870912 bytes; use it only for a proxy that rejects chunked uploads");r.push(["http.postBuffer",i])}for(let h of Object.keys(t))h.startsWith("GIT_TRACE")&&delete t[h];let s=n.find(h=>h.startsWith("https://"));if(t.KANE_SYNC_GIT_TOKEN&&s){let h=new URL(s);r.push([`http.${h.origin}${h.pathname}.extraheader`,""],[`http.${h.origin}${h.pathname}.extraheader`,`AUTHORIZATION: basic ${Buffer.from(`x-access-token:${t.KANE_SYNC_GIT_TOKEN}`).toString("base64")}`],["credential.helper",""])}for(let h of Object.keys(t))/^GIT_CONFIG_(COUNT|KEY_\d+|VALUE_\d+)$/.test(h)&&delete t[h];let a=!t.GIT_SSH_COMMAND&&!t.GIT_SSH&&n.some(h=>ne.has(h))&&n.some(h=>_e.test(h))?await Ae({...t},e.cwd):void 0;r.forEach(([h,u],g)=>{t[`GIT_CONFIG_KEY_${g}`]=h,t[`GIT_CONFIG_VALUE_${g}`]=u}),t.GIT_CONFIG_COUNT=String(r.length),t.GIT_TERMINAL_PROMPT="0",t.GCM_INTERACTIVE="never",t.GIT_ASKPASS="",t.SSH_ASKPASS="";let c=be(t,a);return c!==void 0&&(t.GIT_SSH_COMMAND=c),t.GIT_NO_REPLACE_OBJECTS="1",se(n,t,e.cwd,Ce(n,t,e.timeout),e.input)};function se(n,e,t,r,i){return new Promise((s,o)=>{let a=te("git",n,{cwd:t,env:e,windowsHide:!0,detached:process.platform!=="win32",stdio:["pipe","pipe","pipe"]}),c=[],h=0,u="",g=!1,w=()=>{if(process.platform==="win32"&&a.pid)te("taskkill",["/pid",String(a.pid),"/t","/f"],{windowsHide:!0,stdio:"ignore"}).on("error",()=>a.kill("SIGKILL"));else try{a.pid&&process.kill(-a.pid,"SIGKILL")}catch{a.kill("SIGKILL")}},S=setTimeout(()=>{g=!0,w()},r);a.stdout.on("data",l=>{h+=l.length,h>128*1024*1024?w():c.push(l)}),a.stderr.on("data",l=>{u.length<64e3&&(u+=l.toString())}),a.stdin.on("error",()=>{}),a.on("error",l=>{clearTimeout(S),o(new d("SYNC_GIT_REQUIRED",`Git could not start: ${N(l.message,e)}`,"Install Git 2.31 or newer, then run the command again: https://git-scm.com/downloads"))}),a.on("close",l=>{clearTimeout(S),s({code:g||h>128*1024*1024?124:l??1,stdout:Buffer.concat(c),stderr:N(g?"Git operation timed out":u,e)})}),a.stdin.end(i)})}async function oe(n=H){let e=await n(["--version"],{timeout:1e4}),t=/git version (\d+)\.(\d+)/.exec(e.stdout.toString());if(e.code||!t||+t[1]<2||+t[1]==2&&+t[2]<31)throw new d("SYNC_GIT_REQUIRED","This location needs Git 2.31 or newer.","Install or update Git, then run setup again: https://git-scm.com/downloads")}function ae(n){let e=/^([^/@:]+)@([^/:]+):/.exec(n);if(e)return{user:e[1],host:e[2]};try{let t=new URL(n);return{host:t.hostname||"the server",user:t.username||"git",port:t.port||void 0}}catch{return{host:"the server",user:"git"}}}function gt(n){let e=/^[^/@:]+@([^/:]+):/.exec(n);if(e)return e[1].toLowerCase();try{return new URL(n).hostname.toLowerCase()}catch{return""}}function Y(n,e){let{host:t,user:r,port:i}=ae(e),s=N(n).trim().split(`
3
+ `).slice(-2).join(" ").trim();return/Host key verification failed|REMOTE HOST IDENTIFICATION HAS CHANGED/i.test(n)?{code:"SYNC_LOCATION_DENIED",message:`this computer has not accepted ${t}'s SSH host key yet`,remedy:`in a terminal run: ssh -T ${i?`-p ${i} `:""}${r}@${t} and answer yes, then run the command again`,diagnostic:s}:/Permission denied \(publickey/i.test(n)?{code:"SYNC_LOCATION_DENIED",message:`${t} did not accept your SSH key`,remedy:"load it with ssh-add, or ask the repository owner to grant your account access",diagnostic:s}:/could not read Username|Authentication failed|Access denied|Invalid username or (password|token)|returned error: 401|returned error: 403/i.test(n)?{code:"SYNC_LOCATION_DENIED",message:`sign in is needed, or your account has no access to this repository on ${t}`,remedy:"sign in through Git, or ask the owner to grant your account access",diagnostic:s}:/Could not resolve host|Connection refused|Connection timed out|timed out|Network is unreachable|Failed to connect/i.test(n)?{code:"SYNC_LOCATION_UNREACHABLE",message:`${t} could not be reached`,remedy:"check the address and your network, then run the command again",diagnostic:s}:/not found|does not appear to be a git repository|Repository not found/i.test(n)?{code:"SYNC_LOCATION_UNREACHABLE",message:"no repository answered at that address, or your account cannot see it; a private repository looks missing until access is granted",remedy:"check the address, then run the command again",diagnostic:s}:{code:"SYNC_LOCATION_UNREACHABLE",message:`git could not read the repository on ${t}`,remedy:"check the address and your access, then run the command again",...s?{diagnostic:s}:{}}}function M(n,e){return(n.startsWith(e)?n:n.charAt(0).toUpperCase()+n.slice(1))+"."}function yt(n,e){let t=Y(n,e),{host:r}=ae(e),i=t.remedy.replace(/,? ?(and )?then run the command again$/,"");return i?`${M(t.message,r)} ${M(i,r)}`:M(t.message,r)}var Oe=Buffer.from(`* -text -filter -ident -working-tree-encoding
4
+ `),Re="refs/kane/tip",Pe=/unexpected disconnect|hung up unexpectedly|Connection reset|Connection timed out|timed out|Could not resolve host|Failed to connect|RPC failed|Broken pipe|early EOF/i,$e={GIT_AUTHOR_NAME:"kane-cli context",GIT_AUTHOR_EMAIL:"context@kane-cli.invalid",GIT_COMMITTER_NAME:"kane-cli context",GIT_COMMITTER_EMAIL:"context@kane-cli.invalid"},G=class n{constructor(e){this.options=e;this.exec=e.exec??H,this.prefix=e.prefix?`${e.prefix}/`:"";let t=Ie("sha256").update(JSON.stringify([e.url,e.branch,this.prefix])).digest("hex");if(this.repo=_(e.cacheDir??_(A,"context-sync","mirrors"),`${t}.git`),this.ref=e.ref??`refs/heads/${e.branch}`,!/^refs\/(heads|kane\/probe)\/[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(this.ref)||this.ref.includes(".."))throw new Error("Invalid Git location ref")}kind="git";contractVersion=1;ceilingTier=1;exec;repo;ref;prefix;ready;tip=null;tree=new Map;async run(e,t={}){let r=await this.exec(["--git-dir",this.repo,...e],t);if(r.code)throw new Error(`Git ${e[0]} failed: ${r.stderr||"unable to read the location"}`);return r.stdout}async transfer(e){let t=await this.exec(["--git-dir",this.repo,...e]);if(t.code){let r=Y(t.stderr||"",this.options.url);throw new d(r.code,r.message,r.remedy,r.diagnostic)}return t.stdout}get name(){return this.options.name??"<name>"}takenRemedy(e){return e===1?`${this.name} holds a different history: to work on it, clone it with kane-cli context clone <descriptor of ${this.name}> <dir>; to share this store, add an empty location`:`kane-cli context pull ${this.name} --rebase`}init(){return this.ready??=(async()=>{if(await oe(this.exec),xe(ce(this.repo),{recursive:!0}),!ve(this.repo)){let e=P(_(ce(this.repo),".init-"));try{let t=await this.exec(["init","--bare",e]);if(t.code)throw new Error(`Cannot open Git cache: ${t.stderr}`);try{ke(e,this.repo)}catch(r){if(!["EEXIST","ENOTEMPTY"].includes(r.code??""))throw r}}finally{$(e,{recursive:!0,force:!0})}}if((await this.run(["rev-parse","--is-bare-repository"])).toString().trim()!=="true")throw new Error("The Git cache must be a bare repository");await this.refresh()})()}async refresh(){let t=(await this.transfer(["ls-remote",this.options.url,this.ref])).toString().trim();if(!t){this.tip=null,this.tree=new Map;return}let r=t.split(/\s+/)[0];if(!/^[0-9a-f]{40,64}$/.test(r))throw new Error("Git returned an invalid ref");if(r===this.tip)return;let i=`refs/kane/snapshots/${F(16).toString("hex")}`;await this.transfer(["fetch","--no-tags","--no-write-fetch-head",this.options.url,`${this.ref}:${i}`]);let s=(await this.run(["rev-parse",i])).toString().trim();await this.run(["update-ref",Re,s]),await this.run(["update-ref","-d",i]);let o=await this.readTree(s);this.tip=s,this.tree=o}contextKeys(e){let t=new Map;for(let[r,i]of e)r.startsWith(`${this.prefix}kane-context/`)&&t.set(r,i);return t}async readTree(e){let t=await this.run(["ls-tree","-rz","--full-tree",e]),r=new Map;for(let i of t.toString().split("\0").filter(Boolean)){let s=/^(\d+) (\w+) ([0-9a-f]+)\t([\s\S]+)$/.exec(i);if(!s)throw new Error("Git returned an invalid tree entry");if(s[4].startsWith(`${this.prefix}kane-context/`)&&(s[1]!=="100644"||s[2]!=="blob"))throw new d("SYNC_OBJECT_CORRUPT","Context storage contains a link or non-file object.","Ask the repository owner to restore the original context files.");r.set(s[4],s[3])}return r}key(e){if(!/^[a-zA-Z0-9_~./-]+$/.test(e)||e.split("/").some(t=>!t||t==="."||t===".."||t.toLowerCase()===".git"))throw new Error("Invalid context storage key");return this.prefix+e}async head(e){return await this.init(),this.tree.has(this.key(e))}async get(e){await this.init();let t=this.tree.get(this.key(e));return t?this.run(["cat-file","blob",t]):null}async list(e){return await this.init(),e&&e.replace(/\/$/,"")&&this.key(e.replace(/\/$/,"")),[...this.tree.keys()].filter(t=>t.startsWith(this.prefix+e)).map(t=>t.slice(this.prefix.length)).sort()}async beginTransaction(){await this.init();let e=new Map(this.tree),t=this.tip,r=new Map,i=!1,s=()=>{if(i)throw new Error("Git transaction is closed")},o=async a=>{s();let c=this.key(a),h=r.get(c),u=e.get(c);return h?Buffer.from(h):u?this.run(["cat-file","blob",u]):null};return{get:o,head:async a=>await o(a)!==null,stageIfAbsent:async(a,c)=>{s();let h=this.key(a);if(e.has(h)||r.has(h))return"exists";if(c.length>1e8)throw new d("SYNC_LOCATION_REFUSED_WRITE","A context object is too large for this Git location.","Use an S3 location for this context.");return r.set(h,Buffer.from(c)),"staged"},abort:async()=>{i=!0,r.clear()},commit:async()=>{s();try{if(!r.size)return{created:[]};let a=this.prefix+"kane-context/.gitattributes";e.has(a)||r.set(a,Oe);let c=new Map;for(let[l,m]of r)c.set(l,(await this.run(["hash-object","-w","--no-filters","--stdin"],{input:m})).toString().trim());let h=this.contextKeys(e),u=()=>{this.assertUnchanged(h);for(let[l,m]of this.contextKeys(this.tree))h.set(l,m)},g=!1,w="",S=0;for(let l=0;l<4;l++){u();for(let f of this.tree.keys())if(!(!f.startsWith(this.prefix)||e.has(f)||c.has(f))&&B(f.slice(this.prefix.length))!==null)throw new d("SYNC_BEHIND","the location gained records after this batch was prepared; nothing was published","run kane-cli context pull, then push again");let m=new Map;for(let[f,T]of c){let C=this.tree.get(f);if(C&&C!==T){let R=B(f.slice(this.prefix.length));throw R?new d("SYNC_POSITION_TAKEN",g?`position ${R} on ${this.name} now holds different work; an earlier publication could not be confirmed`:`position ${R} on ${this.name} was published by another writer; this batch was not published`,this.takenRemedy(R)):new d("SYNC_OBJECT_CORRUPT",`existing context object ${f} differs from the intended bytes`,"the object needs a person to look; nothing was published")}C||m.set(f,T)}if(!m.size)return await this.verifyPublication(c),{created:[]};t=this.tip;let I=await this.build(t,m);await this.checkAttributes(I,[...r.keys()]),S++;let E=await this.exec(["--git-dir",this.repo,"push","--porcelain",this.options.url,`${I}:${this.ref}`]),y=N(E.stdout.toString()+`
5
+ `+E.stderr);w=y.trim();let O=E.code!==0&&/\[rejected\]|\[remote rejected\]/.test(y),p=E.code!==0&&(E.code===124||Pe.test(y));g||=p;try{await this.refresh()}catch{throw new d("SYNC_PUBLICATION_UNKNOWN","we could not confirm whether your context was uploaded; your local work is safe","check the connection and retry; kane-cli compares the published data before writing again")}if(u(),[...c].every(([f,T])=>this.tree.get(f)===T)){await this.verifyPublication(c);let f=E.code===0&&!E.stdout.toString().split(`
6
+ `).some(T=>T.startsWith("= "));return f&&await this.maintain(),{created:f?[...m.keys()].map(T=>T.slice(this.prefix.length)):[]}}if(E.code===0)throw new d("SYNC_PUBLICATION_UNKNOWN","the server accepted publication, but a fresh read did not confirm all context objects","retry after checking the location; do not discard local context");if(this.tip===t&&!g)throw new d("SYNC_LOCATION_REFUSED_WRITE",`${this.name} refused publication`,"check repository write access and branch rules, then retry",y.trim());if(this.tip===t&&!O&&g){await new Promise(f=>setTimeout(f,200*(l+1)+Math.random()*200));continue}await new Promise(f=>setTimeout(f,50*(l+1)+Math.random()*100))}throw new d("SYNC_PUBLICATION_UNKNOWN",`publication could not be confirmed after ${S} attempts; your local work is safe`,"run kane-cli context sync status, then retry",w||void 0)}finally{i=!0,r.clear()}}}}async maintain(){try{await this.exec(["--git-dir",this.repo,"gc","--auto","--quiet"],{timeout:3e5})}catch{}}assertUnchanged(e){for(let[t,r]of e)if(t.startsWith(`${this.prefix}kane-context/`)&&this.tree.get(t)!==r)throw new d("SYNC_REMOTE_ROLLED_BACK","The location changed or removed previously observed context data.","Ask the repository owner to restore the published context; keep your local copy.")}async verifyPublication(e){try{await this.verify(e)}catch{throw new d("SYNC_PUBLICATION_UNKNOWN","Publication was observed, but its bytes could not be fully verified. Your local work is safe.","Check the connection and retry before discarding local context.")}}async verify(e){for(let[t,r]of e){if(this.tree.get(t)!==r)throw new Error("Published context verification failed");let i=await this.run(["cat-file","blob",r]);if((await this.run(["hash-object","--no-filters","--stdin"],{input:i})).toString().trim()!==r)throw new Error("Published bytes do not match their Git object")}}async checkAttributes(e,t=[]){if(!e)return;let r=P(_(j(),"kane-git-attributes-"));try{let i={GIT_INDEX_FILE:_(r,"index")};await this.run(["read-tree",e],{env:i});let s=["commits/000000/000000001.json","blobs/ab/1234","proposals/sample/1234.json"].map(u=>`${this.prefix}kane-context/v1/${u}`),o=t.filter(u=>u.startsWith(`${this.prefix}kane-context/`)&&!u.endsWith("/.gitattributes")),a=Buffer.from([...new Set([...s,...o])].join("\0")+"\0"),h=(await this.run(["check-attr","--cached","-z","--stdin","text","filter","ident","working-tree-encoding"],{env:i,input:a})).toString().split("\0");for(let u=0;u+2<h.length;u+=3)if(!["unset","unspecified"].includes(h[u+2]))throw new d("SYNC_LOCATION_REFUSED_WRITE",`Git attributes transform context bytes (${h[u+1]}).`,"Use a dedicated context repository with no text, filter, ident or encoding conversions.")}finally{$(r,{recursive:!0,force:!0})}}async build(e,t){let r=P(_(j(),"kane-git-index-"));try{let i={GIT_INDEX_FILE:_(r,"index")};await this.run(e?["read-tree",e]:["read-tree","--empty"],{env:i});let s=Buffer.from([...t].map(([l,m])=>`100644 ${m} ${l}\0`).join(""));await this.run(["update-index","-z","--index-info"],{env:i,input:s});let a=["commit-tree",(await this.run(["write-tree"],{env:i})).toString().trim(),...e?["-p",e]:[],"-m",`Append context objects
7
+
8
+ Kane-Context: v1`],c=await this.exec(["--git-dir",this.repo,...a]),h=(c.code===0?c.stdout:await this.run(a,{env:$e})).toString().trim(),u=(await this.run(["rev-list","--parents","-n","1",h])).toString().trim().split(" ");if(u.length!==(e?2:1)||e&&u[1]!==e)throw new Error("Unsafe Git commit parent");let g=(await this.run(["diff-tree","--no-commit-id","--name-status","--no-renames","-r","-z",...e?[e,h]:["--root",h]])).toString().split("\0").filter(Boolean);if(g.length!==t.size*2||g.some((l,m)=>m%2===0?l!=="A":!t.has(l)))throw new Error("Unsafe Git commit: unexpected changed path or file mode");let w=await this.readTree(h),S=e?await this.readTree(e):new Map;if(w.size!==S.size+t.size||[...S].some(([l,m])=>w.get(l)!==m)||[...t].some(([l,m])=>S.has(l)||w.get(l)!==m))throw new Error("Unsafe Git commit: only intended new keys may be added");return h}finally{$(r,{recursive:!0,force:!0})}}async putIfAbsent(e,t){let r=await this.beginTransaction();try{if(await r.stageIfAbsent(e,t)==="exists")return"exists";try{return(await r.commit()).created.includes(e)?"created":"exists"}catch(i){if(i instanceof d&&["SYNC_POSITION_TAKEN","SYNC_OBJECT_CORRUPT"].includes(i.code)&&await this.head(e))return"exists";throw i}}finally{await r.abort()}}async probe(){await this.init();let e=ee(F(16).toString("hex"));try{await this.putIfAbsent(e,Buffer.from("connection check"))}catch(c){if(c instanceof d&&c.code==="SYNC_LOCATION_REFUSED_WRITE")return await this.refresh(),{tier:3,detail:"This location can be downloaded, but publication was refused."};throw c}if(await this.putIfAbsent(e,Buffer.from("must not replace"))!=="exists")throw new d("SYNC_PROBE_INCONCLUSIVE","Exclusive create could not be verified.","Retry the connection check.");let t=P(_(j(),"kane-git-reader-"));try{let c=new n({...this.options,cacheDir:t});if(!Buffer.from(await c.get(e)??[]).equals(Buffer.from("connection check"))||!await c.head(e)||!(await c.list(e)).includes(e))throw new Error("Independent reader could not confirm published bytes")}finally{$(t,{recursive:!0,force:!0})}let r=`refs/kane/probe/${F(16).toString("hex")}`,i=Array.from({length:8},()=>new n({...this.options,ref:r}));if((await Promise.allSettled(i.map(c=>c.head(e)))).some(c=>c.status==="rejected"))throw new d("SYNC_PROBE_INCONCLUSIVE","The concurrent connection check could not initialize its independent clients.","Retry the connection check.");let o=await Promise.allSettled(i.map((c,h)=>c.putIfAbsent(e,Buffer.from(`contender ${h}`))));if(o.some(c=>c.status==="rejected"))throw new d("SYNC_PROBE_INCONCLUSIVE","The server did not complete the concurrent connection check. Its scratch-ref policy may differ from the storage branch.","Ask the repository owner to allow the connection-check ref, then retry.");if(o.filter(c=>c.status==="fulfilled"&&c.value==="created").length!==1)throw new d("SYNC_PROBE_INCONCLUSIVE","The concurrent connection check did not produce exactly one winner.","Do not publish to this location until its connection check passes.");return{tier:1,detail:"Can download and publish; independent reads and concurrent writes verified."}}};import{closeSync as Ge,existsSync as Ue,fsyncSync as De,linkSync as Le,lstatSync as Ke,mkdirSync as Be,openSync as He,readFileSync as Me,readdirSync as Ye,realpathSync as q,rmSync as he,statSync as z,writeFileSync as Fe}from"fs";import{randomBytes as je}from"crypto";import{dirname as de,join as ue,resolve as le,sep as U}from"path";var ze=[/^Dropbox( \(.*\))?$/,/^Mobile Documents$/,/^OneDrive(-.*)?$/,/^Google ?Drive(-.*)?$/,/^My Drive$/,/^CloudStorage$/,/^iCloud Drive/],We="a folder synced by Dropbox, OneDrive, Google Drive or iCloud cannot be a location: these keep both sides of a conflict as duplicate files instead of refusing the second write \u2014 use a directory outside the sync client, a git-tracked folder, or an s3:// bucket";function fe(n){return n.split(U).some(e=>ze.some(t=>t.test(e)))}function qe(n){try{return q(n)}catch{return n}}var pe=".tmp-";function Xe(n){try{return Ke(n),!0}catch{return!1}}var b=n=>n.code??"",x=new Set(["ENOENT","ENOTDIR"]),W=new Set(["EACCES","EPERM"]),D=class{kind="dir";contractVersion=1;ceilingTier;root;createRoot;constructor(e,t={}){if(this.root=le(e),fe(this.root)||fe(qe(this.root)))throw new Error(We);this.ceilingTier=1,this.createRoot=t.createRoot??!0}requireRoot(){if(!this.createRoot){try{if(z(this.root).isDirectory())return}catch(e){if(W.has(b(e)))throw this.denied();if(!x.has(b(e)))throw e}throw this.unreachable()}}unreachable(){return new d("SYNC_LOCATION_UNREACHABLE",`nothing answered at ${this.root}: that folder does not exist and cannot be created`,"check the path, then run the command again")}denied(){return new d("SYNC_LOCATION_DENIED",`${this.root} cannot be read by this account`,"ask the owner of the folder for access")}readFault(e){return W.has(b(e))?this.denied():e}writeFault(e){return x.has(b(e))||b(e)==="EROFS"?this.rootExists()?this.refusedWrite("its filesystem is read-only"):this.unreachable():W.has(b(e))?this.refusedWrite("this account has no write access"):e}refusedWrite(e){return new d("SYNC_LOCATION_REFUSED_WRITE",`${this.root} cannot be written: ${e}`,"ask the owner of the folder for write access, or pull from it without pushing")}rootExists(){try{return z(this.root).isDirectory()}catch{return!1}}path(e){let t=e.split("/"),r=e!==""&&!e.startsWith("/")&&!e.includes("\\")&&t.every(s=>s!==""&&s!=="."&&s!==".."),i=r?le(this.root,...t):"";if(!r||!i.startsWith(this.root+U)||!this.contained(i))throw new Error(`bad key ${e}`);return i}contained(e){let t=e;for(;!Xe(t);)t=de(t);if(t===this.root||!t.startsWith(this.root+U))return!0;try{let r=q(this.root),i=q(t);return i===r||i.startsWith(r+U)}catch{return!1}}async head(e){this.requireRoot();try{return z(this.path(e)).isFile()}catch(t){if(x.has(b(t)))return!1;throw this.readFault(t)}}async get(e){this.requireRoot();try{return new Uint8Array(Me(this.path(e)))}catch(t){if(x.has(b(t)))return null;throw this.readFault(t)}}async list(e){this.requireRoot();let t=e.lastIndexOf("/"),r=t===-1?"":e.slice(0,t),i=r===""?this.root:this.path(r),s=[],o=(a,c)=>{for(let h of Ye(a,{withFileTypes:!0})){let u=c+h.name;h.isDirectory()?o(ue(a,h.name),`${u}/`):!h.name.startsWith(pe)&&u.startsWith(e)&&s.push(u)}};try{o(i,r===""?"":`${r}/`)}catch(a){if(x.has(b(a))&&!Ue(i))return[];throw this.readFault(a)}return s.sort()}async putIfAbsent(e,t){this.requireRoot();let r=this.path(e),i=de(r),s=ue(i,`${pe}${process.pid}-${je(6).toString("hex")}`),o;try{Be(i,{recursive:!0}),o=He(s,"wx")}catch(c){throw this.writeFault(c)}try{Fe(o,t),De(o)}finally{Ge(o)}let a="created";try{Le(s,r)}catch(c){if(c.code!=="EEXIST")throw he(s,{force:!0}),c;a="exists"}return he(s,{force:!0}),Z(i),a}};var J=new TextEncoder,Je={appstream2:"appstream",cloudhsmv2:"cloudhsm",email:"ses",marketplace:"aws-marketplace",mobile:"AWSMobileHubService",pinpoint:"mobiletargeting",queue:"sqs","git-codecommit":"codecommit","mturk-requester-sandbox":"mturk-requester","personalize-runtime":"personalize"},Ve=new Set(["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id","range","connection"]),L=class{constructor({accessKeyId:e,secretAccessKey:t,sessionToken:r,service:i,region:s,cache:o,retries:a,initRetryMs:c}){if(e==null)throw new TypeError("accessKeyId is a required option");if(t==null)throw new TypeError("secretAccessKey is a required option");this.accessKeyId=e,this.secretAccessKey=t,this.sessionToken=r,this.service=i,this.region=s,this.cache=o||new Map,this.retries=a??10,this.initRetryMs=c||50}async sign(e,t){if(e instanceof Request){let{method:s,url:o,headers:a,body:c}=e;t=Object.assign({method:s,url:o,headers:a},t),t.body==null&&a.has("Content-Type")&&(t.body=c!=null&&a.has("X-Amz-Content-Sha256")?c:await e.clone().arrayBuffer()),e=o}let r=new V(Object.assign({url:e.toString()},t,this,t&&t.aws)),i=Object.assign({},t,await r.sign());delete i.aws;try{return new Request(i.url.toString(),i)}catch(s){if(s instanceof TypeError)return new Request(i.url.toString(),Object.assign({duplex:"half"},i));throw s}}async fetch(e,t){for(let r=0;r<=this.retries;r++){let i=fetch(await this.sign(e,t));if(r===this.retries)return i;let s=await i;if(s.status<500&&s.status!==429)return s;await new Promise(o=>setTimeout(o,Math.random()*this.initRetryMs*Math.pow(2,r)))}throw new Error("An unknown error occurred, ensure retries is not negative")}},V=class{constructor({method:e,url:t,headers:r,body:i,accessKeyId:s,secretAccessKey:o,sessionToken:a,service:c,region:h,cache:u,datetime:g,signQuery:w,appendSessionToken:S,allHeaders:l,singleEncode:m}){if(t==null)throw new TypeError("url is a required option");if(s==null)throw new TypeError("accessKeyId is a required option");if(o==null)throw new TypeError("secretAccessKey is a required option");this.method=e||(i?"POST":"GET"),this.url=new URL(t),this.headers=new Headers(r||{}),this.body=i,this.accessKeyId=s,this.secretAccessKey=o,this.sessionToken=a;let I,E;(!c||!h)&&([I,E]=Qe(this.url,this.headers)),this.service=c||I||"",this.region=h||E||"us-east-1",this.cache=u||new Map,this.datetime=g||new Date().toISOString().replace(/[:-]|\.\d{3}/g,""),this.signQuery=w,this.appendSessionToken=S||this.service==="iotdevicegateway",this.headers.delete("Host"),this.service==="s3"&&!this.signQuery&&!this.headers.has("X-Amz-Content-Sha256")&&this.headers.set("X-Amz-Content-Sha256","UNSIGNED-PAYLOAD");let y=this.signQuery?this.url.searchParams:this.headers;if(y.set("X-Amz-Date",this.datetime),this.sessionToken&&!this.appendSessionToken&&y.set("X-Amz-Security-Token",this.sessionToken),this.signableHeaders=["host",...this.headers.keys()].filter(p=>l||!Ve.has(p)).sort(),this.signedHeaders=this.signableHeaders.join(";"),this.canonicalHeaders=this.signableHeaders.map(p=>p+":"+(p==="host"?this.url.host:(this.headers.get(p)||"").replace(/\s+/g," "))).join(`
9
+ `),this.credentialString=[this.datetime.slice(0,8),this.region,this.service,"aws4_request"].join("/"),this.signQuery&&(this.service==="s3"&&!y.has("X-Amz-Expires")&&y.set("X-Amz-Expires","86400"),y.set("X-Amz-Algorithm","AWS4-HMAC-SHA256"),y.set("X-Amz-Credential",this.accessKeyId+"/"+this.credentialString),y.set("X-Amz-SignedHeaders",this.signedHeaders)),this.service==="s3")try{this.encodedPath=decodeURIComponent(this.url.pathname.replace(/\+/g," "))}catch{this.encodedPath=this.url.pathname}else this.encodedPath=this.url.pathname.replace(/\/+/g,"/");m||(this.encodedPath=encodeURIComponent(this.encodedPath).replace(/%2F/g,"/")),this.encodedPath=ye(this.encodedPath);let O=new Set;this.encodedSearch=[...this.url.searchParams].filter(([p])=>{if(!p)return!1;if(this.service==="s3"){if(O.has(p))return!1;O.add(p)}return!0}).map(p=>p.map(f=>ye(encodeURIComponent(f)))).sort(([p,f],[T,C])=>p<T?-1:p>T?1:f<C?-1:f>C?1:0).map(p=>p.join("=")).join("&")}async sign(){return this.signQuery?(this.url.searchParams.set("X-Amz-Signature",await this.signature()),this.sessionToken&&this.appendSessionToken&&this.url.searchParams.set("X-Amz-Security-Token",this.sessionToken)):this.headers.set("Authorization",await this.authHeader()),{method:this.method,url:this.url,headers:this.headers,body:this.body}}async authHeader(){return["AWS4-HMAC-SHA256 Credential="+this.accessKeyId+"/"+this.credentialString,"SignedHeaders="+this.signedHeaders,"Signature="+await this.signature()].join(", ")}async signature(){let e=this.datetime.slice(0,8),t=[this.secretAccessKey,e,this.region,this.service].join(),r=this.cache.get(t);if(!r){let i=await v("AWS4"+this.secretAccessKey,e),s=await v(i,this.region),o=await v(s,this.service);r=await v(o,"aws4_request"),this.cache.set(t,r)}return X(await v(r,await this.stringToSign()))}async stringToSign(){return["AWS4-HMAC-SHA256",this.datetime,this.credentialString,X(await me(await this.canonicalString()))].join(`
10
+ `)}async canonicalString(){return[this.method.toUpperCase(),this.encodedPath,this.encodedSearch,this.canonicalHeaders+`
11
+ `,this.signedHeaders,await this.hexBodyHash()].join(`
12
+ `)}async hexBodyHash(){let e=this.headers.get("X-Amz-Content-Sha256")||(this.service==="s3"&&this.signQuery?"UNSIGNED-PAYLOAD":null);if(e==null){if(this.body&&typeof this.body!="string"&&!("byteLength"in this.body))throw new Error("body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header");e=X(await me(this.body||""))}return e}};async function v(n,e){let t=await crypto.subtle.importKey("raw",typeof n=="string"?J.encode(n):n,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return crypto.subtle.sign("HMAC",t,J.encode(e))}async function me(n){return crypto.subtle.digest("SHA-256",typeof n=="string"?J.encode(n):n)}var ge=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function X(n){let e=new Uint8Array(n),t="";for(let r=0;r<e.length;r++){let i=e[r];t+=ge[i>>>4&15],t+=ge[i&15]}return t}function ye(n){return n.replace(/[!'()*]/g,e=>"%"+e.charCodeAt(0).toString(16).toUpperCase())}function Qe(n,e){let{hostname:t,pathname:r}=n;if(t.endsWith(".on.aws")){let a=t.match(/^[^.]{1,63}\.lambda-url\.([^.]{1,63})\.on\.aws$/);return a!=null?["lambda",a[1]||""]:["",""]}if(t.endsWith(".r2.cloudflarestorage.com"))return["s3","auto"];if(t.endsWith(".backblazeb2.com")){let a=t.match(/^(?:[^.]{1,63}\.)?s3\.([^.]{1,63})\.backblazeb2\.com$/);return a!=null?["s3",a[1]||""]:["",""]}let i=t.replace("dualstack.","").match(/([^.]{1,63})\.(?:([^.]{0,63})\.)?amazonaws\.com(?:\.cn)?$/),s=i&&i[1]||"",o=i&&i[2];if(o==="us-gov")o="us-gov-west-1";else if(o==="s3"||o==="s3-accelerate")o="us-east-1",s="s3";else if(s==="iot")t.startsWith("iot.")?s="execute-api":t.startsWith("data.jobs.iot.")?s="iot-jobs-data":s=r==="/mqtt"?"iotdevicegateway":"iotdata";else if(s==="autoscaling"){let a=(e.get("X-Amz-Target")||"").split(".")[0];a==="AnyScaleFrontendService"?s="application-autoscaling":a==="AnyScaleScalingPlannerFrontendService"&&(s="autoscaling-plans")}else o==null&&s.startsWith("s3-")?(o=s.slice(3).replace(/^fips-|^external-1/,""),s="s3"):s.endsWith("-fips")?s=s.slice(0,-5):o&&/-\d$/.test(s)&&!/-\d$/.test(o)&&([s,o]=[o,s]);return[Je[s]||s,o||""]}var Q=3,Ze=[300,900],et=200,tt=15e3,rt=/<Key>([^<]*)<\/Key>/g,it=/<NextContinuationToken>([^<]*)<\/NextContinuationToken>/,we=n=>new Promise(e=>setTimeout(e,n));function nt(n){let e=n instanceof Error?n.name:"";return e==="TimeoutError"||e==="AbortError"?"timeout":"network"}async function st(n){try{return await n.text()}catch{return""}}var K=class n{kind="s3";contractVersion=1;ceilingTier=1;client;base;prefix;pageSize;name;constructor(e){this.client=new L({accessKeyId:e.accessKeyId,secretAccessKey:e.secretAccessKey,service:"s3",region:e.region}),this.base=e.endpoint?`${e.endpoint.replace(/\/+$/,"")}/${e.bucket}`:`https://${e.bucket}.s3.${e.region}.amazonaws.com`,this.prefix=e.prefix,this.pageSize=e.pageSize??1e3,this.name=e.name??"this location"}url(e){return`${this.base}/${this.prefix}${e}`}static line(e,t,r){return`${e} ${new URL(t).pathname} -> ${r}`}answer(e,t,r){let i=n.line(e,t,r);return r===404?new d("SYNC_LOCATION_UNREACHABLE",`nothing answered at ${this.base}: no bucket there`,"check the bucket name and the endpoint, then run the command again",i):r===401||r===403?new d("SYNC_LOCATION_DENIED",`the bucket at ${this.base} did not accept ${this.name}'s access keys, even for reading`,`ask the owner of the bucket for access, or bind it again with the right keys: kane-cli context sync add ${this.name} <descriptor> --credential-env <VAR>`,i):r>=500||r===429?this.unreachable(i):r===301||r===307||r===308?new d("SYNC_LOCATION_UNREACHABLE",`the bucket at ${this.base} answered with a redirect: it lives in another region or behind another endpoint`,`set region=<its region> (or endpoint=<its endpoint>) in the descriptor, then bind ${this.name} again`,i):new Error(i)}unreachable(e){return new d("SYNC_LOCATION_UNREACHABLE",`nothing answered at ${this.base}`,"check the endpoint and your network, then run the command again",e)}async request(e,t,r={}){let i="";for(let s=0;s<Q;s++){s>0&&await we(Ze[s-1]);let o;try{o=await fetch(await this.client.sign(t,{method:e,headers:r.headers,body:r.body&&new Uint8Array(r.body),signal:AbortSignal.timeout(tt)}))}catch(a){i=nt(a);continue}if((o.status>=500||o.status===429)&&s<Q-1){i=String(o.status);continue}return o}throw this.unreachable(`${n.line(e,t,i)} after ${Q} attempts`)}async head(e){let t=await this.request("HEAD",this.url(e));if(t.status===200)return!0;if(t.status===404)return!1;throw this.answer("HEAD",this.url(e),t.status)}async bodyOf(e,t,r,i){try{return await i(e)}catch{throw this.unreachable(n.line(t,r,"body read failed"))}}async get(e){let t=await this.request("GET",this.url(e));if(t.status===200)return new Uint8Array(await this.bodyOf(t,"GET",this.url(e),r=>r.arrayBuffer()));if(t.status===404)return null;throw this.answer("GET",this.url(e),t.status)}async list(e){let t=[],r=null;do{let i=new URLSearchParams({"list-type":"2",prefix:this.prefix+e,"max-keys":String(this.pageSize)});r&&i.set("continuation-token",r);let s=`${this.base}?${i.toString()}`,o=await this.request("GET",s);if(o.status!==200)throw this.answer("GET",s,o.status);let a=await this.bodyOf(o,"GET",s,c=>c.text());for(let c of a.matchAll(rt))t.push(c[1].slice(this.prefix.length));r=it.exec(a)?.[1]??null}while(r);return t.sort()}async putIfAbsent(e,t){let r=await this.create(e,t);if(r!=="conflict")return r;if(await we(et),await this.head(e))return"exists";let i=await this.create(e,t);if(i!=="conflict")return i;throw new Error(`${n.line("PUT",this.url(e),409)} twice (ConditionalRequestConflict) and the key is still absent`)}async create(e,t){let r=this.url(e),i=await this.request("PUT",r,{headers:{"If-None-Match":"*","Content-Type":"application/octet-stream"},body:t});if(i.status===200||i.status===201)return"created";if(i.status===412)return"exists";if(i.status===409&&(await st(i)).includes("ConditionalRequestConflict"))return"conflict";throw i.status===401||i.status===403?new d("SYNC_LOCATION_REFUSED_WRITE",`${this.name}'s access keys cannot write to ${this.base}`,"ask the owner of the bucket for write access, or pull from it without pushing",n.line("PUT",r,i.status)):this.answer("PUT",r,i.status)}};import{chmodSync as ot,mkdirSync as at,readFileSync as ct,rmSync as ht,writeFileSync as dt}from"fs";import{join as Se}from"path";var Ee="context-sync",ut=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function k(n,e=A){if(!ut.test(n))throw new Error(`bad location name ${JSON.stringify(n)} \u2014 letters, digits, dot, dash and underscore only`);return Se(e,Ee,`${n}.json`)}function Te(n,e=A){let t=process.env.KANE_SYNC_S3_ACCESS_KEY_ID,r=process.env.KANE_SYNC_S3_SECRET_ACCESS_KEY;if(t&&r)return{accessKeyId:t,secretAccessKey:r};let i=k(n,e),s;try{s=ct(i,"utf-8")}catch{return null}let o;try{o=JSON.parse(s)}catch(a){throw new Error(`${i} is not readable JSON: ${a instanceof Error?a.message:String(a)}`)}if(typeof o!="object"||o===null||!("accessKeyId"in o)||!("secretAccessKey"in o)||typeof o.accessKeyId!="string"||typeof o.secretAccessKey!="string")throw new Error(`${i} does not hold an access key and a secret \u2014 re-add the location to replace it`);return{accessKeyId:o.accessKeyId,secretAccessKey:o.secretAccessKey}}function Mt(n,e,t=A){let r=k(n,t);at(Se(t,Ee),{recursive:!0,mode:448}),dt(r,JSON.stringify(e)+`
13
+ `,{mode:384}),ot(r,384)}function Yt(n,e=A){ht(k(n,e),{force:!0})}function Xt(n,e,t,r={}){switch(n.kind){case"fake":{let i=t?.get(n.location.slice(7));if(!i)throw new Error(`${n.location} is a test-only location and no test registered it`);return i}case"git":return new G({url:n.gitUrl,branch:n.branch,prefix:n.prefix,name:e});case"dir":return new D(n.path,{createRoot:r.createRoot});case"s3":{let i=Te(e);if(!i)throw new Error(`no credentials for ${e} \u2014 re-add it with --credential-env <VAR> or --credential-file <path> (kane-cli context sync add), set KANE_SYNC_S3_ACCESS_KEY_ID and KANE_SYNC_S3_SECRET_ACCESS_KEY, or write {"accessKeyId", "secretAccessKey"} to ${k(e)} with mode 0600`);return new K({endpoint:n.endpoint,region:n.region,bucket:n.bucket,prefix:n.prefix,name:e,...i})}}}export{H as a,oe as b,gt as c,yt as d,k as e,Mt as f,Yt as g,Xt as h};
14
+ /*! Bundled license information:
15
+
16
+ aws4fetch/dist/aws4fetch.esm.mjs:
17
+ (**
18
+ * @license MIT <https://opensource.org/licenses/MIT>
19
+ * @copyright Michael Hart 2024
20
+ *)
21
+ */
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ var S=new Set(["SYNC_BEHIND","SYNC_DIVERGED","SYNC_POSITION_TAKEN","SYNC_LOCAL_MOVED"]),i=new Set(["SYNC_REMOTE_CHAIN_BROKEN","SYNC_OBJECT_CORRUPT","SYNC_LOCAL_RECORD_CORRUPT"]),s=class extends Error{constructor(n,e,u,p){super(e);this.code=n;this.remedy=u;this.diagnostic=p}};function Y(r){return S.has(r)?3:i.has(r)?1:2}var o="kane-context/v1",E=`${o}/commits/`,f=`${o}/meta.json`,O=1e3,C=999999999,c=new RegExp(`^${o}/commits/(\\d{6})/(\\d{9})\\.json$`),R=/^sha256:([0-9a-f]{64})$/;function N(r,t){let n=R.exec(r);if(!n)throw new Error(`not a ${t} fingerprint: ${r} \u2014 expected sha256:<64 lower-case hex>`);return n[1]}function _(r){if(!Number.isInteger(r)||r<1||r>C)throw new Error(`bad position ${r} \u2014 a position is a whole number from 1 to ${C}`);return String(Math.floor((r-1)/O)).padStart(6,"0")}function g(r){return`${E}${_(r)}/${String(r).padStart(9,"0")}.json`}function l(r){return`${E}${_(r)}/`}function d(r){let t=c.exec(r);if(!t)return null;let n=Number(t[2]);return n<1||t[1]!==_(n)?null:n}function D(r){let t=N(r,"blob");return`${o}/blobs/${t.slice(0,2)}/${t.slice(2)}`}function L(r,t){return`${a(r)}${N(t,"proposal digest").slice(0,12)}.json`}function a(r){let t=I(r);if(t===""||t==="."||t==="..")throw new Error(`bad proposal id ${JSON.stringify(r)} \u2014 a proposal id names a folder`);return`${o}/proposals/${t}/`}function I(r){let t="";for(let n of Buffer.from(r,"utf8")){let e=String.fromCharCode(n);t+=/^[a-z0-9._-]$/.test(e)?e:`~${n.toString(16).padStart(2,"0")}`}return t}function $(r){if(!/^[0-9a-f]{16,32}$/.test(r))throw new Error("probe nonce must be 16 to 32 lower-case hex characters");return`${o}/probe/${r}`}export{s as a,Y as b,E as c,f as d,g as e,l as f,d as g,D as h,L as i,a as j,$ as k};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as b,b as $}from"./chunk-W3Z7AZNT.js";function C(n){return n.replace(/\n$/,"").split(`
2
+ import{a as b,b as $}from"./chunk-GP7WD4UY.js";function C(n){return n.replace(/\n$/,"").split(`
3
3
  `).map((l,o)=>`${String(o+1).padStart(4,"0")}| ${l}`).join(`
4
4
  `)}function S(n,d,l){if(!n.quote)return n;let o=$(l,n.anchor);if(o!==null&&o.includes(n.quote))return n;let a=d.indexOf(n.quote);if(a===-1||d.indexOf(n.quote,a+1)!==-1)return"gone-or-ambiguous";let t=d.slice(0,a).split(`
5
5
  `).length,r=t+n.quote.replace(/\n$/,"").split(`
@@ -1,10 +1,10 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as j,b as H}from"./chunk-3SP4JVDN.js";import{a as B,b as N}from"./chunk-BTBUIL4Q.js";import{a as se,b as ie,c as ae}from"./chunk-PDXZROJM.js";import{d as ce}from"./chunk-LWQNRZH3.js";import{a as $,b as q,e as M,g as oe}from"./chunk-4WOVHRI2.js";import{a as re,b as ne}from"./chunk-OTMAFCZK.js";import{a as L}from"./chunk-ZOSY2PJM.js";import{a as te}from"./chunk-NM76SG3S.js";import{a as X}from"./chunk-NUWOQS6L.js";import{a as ee}from"./chunk-DHJSM5DT.js";import{a as A}from"./chunk-RZ4F3BHX.js";import{a as O}from"./chunk-3M2D7UUI.js";import{y}from"./chunk-33GXXC2L.js";import{a as F}from"./chunk-HCBYKLMW.js";import{a as k,b as p,i as Z}from"./chunk-C44QQJR4.js";import{a as K}from"./chunk-6YGTRKDT.js";import{e as v}from"./chunk-UR6MHSHU.js";var D=v(K(),1);import{existsSync as P,readFileSync as He,rmSync as ye,unlinkSync as Ve}from"fs";import{resolve as Q}from"path";import{promises as le,realpathSync as Ee}from"fs";import{homedir as Se}from"os";import{join as V,parse as ve,relative as ue,resolve as de}from"path";var fe=new Set(["node_modules",".git","dist","build",".next",".venv","venv","target","__pycache__"]),R=class extends Error{constructor(s){super(`refusing to scan '${s}'. Run from your project root, or pass --root <dir>.`);this.cwd=s;this.name="HomeRefusedError"}};function me(e){try{return Ee(de(e))}catch{return de(e)}}function Re(e){let r=me(e),s=me(Se()),n=ve(r).root;if(process.platform==="win32"){let o=t=>t.toLowerCase();return o(r)===o(s)||o(r)===o(n)}return r===s||r===n}async function U(e){if(Re(e.root))throw new R(e.root);let r=e.maxEntries??5e4,s=e.maxResults??5e3,n=new Set(e.ignore??[]),o=[],t=0,i=0,a=!1,u,c=[e.root];for(;c.length>0&&!a;){let l=c.shift(),g;try{g=await le.readdir(l,{withFileTypes:!0})}catch{continue}i++;for(let _ of g){if(t++,t>r){a=!0,u="max_entries";break}let m=_.name,T=V(l,m);if(_.isDirectory()){if(fe.has(m)||m.startsWith(".")||m.startsWith("output-")||n.has(m))continue;c.push(T)}else if(_.isFile()&&m.endsWith("_test.md")&&(o.push({path:T,relPath:ue(e.root,T),source:"cwd"}),o.length>=s)){a=!0,u="max_results";break}}e.onProgress?.(i,o.length)}if(!a){let g=[{dir:V(e.root,".testmuai","tests"),depth:0}];for(;g.length>0&&!a;){let{dir:_,depth:m}=g.shift(),T;try{T=await le.readdir(_,{withFileTypes:!0})}catch{continue}i++;for(let d of T){if(t++,t>r){a=!0,u="max_entries";break}let b=d.name,w=V(_,b);if(d.isDirectory()){if(m>=20||b.startsWith(".")||b.startsWith("output-")||fe.has(b))continue;g.push({dir:w,depth:m+1})}else if(d.isFile()&&b.endsWith("_test.md")&&(o.push({path:w,relPath:ue(e.root,w),source:"tests-dir"}),o.length>=s)){a=!0,u="max_results";break}}}}return{results:o,aborted:a,abortReason:u,dirsScanned:i}}import{readFileSync as Pe}from"fs";function Y(e){let r;try{r=Pe(e,"utf8")}catch{return{tags:[]}}try{let{global:s}=re(e,r),n=ne(s);return{tags:s.tags??[],...n?{mobileTarget:n}:{}}}catch{return{tags:[],...De(r)?{mobileTarget:Me}:{}}}}var Me={platform:"",app:""};function De(e){let r=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!r)return!1;let s=r[1].split(/\r?\n/);if(s.some(o=>/^target:\s*['"]?(emulator|simulator)['"]?\s*$/.test(o)))return!0;let n=s.findIndex(o=>/^target:\s*$/.test(o));return n<0?!1:s.slice(n+1).some(o=>/^\s+\S/.test(o))}function W(e){return Y(e).tags}import{mkdirSync as Ce,writeFileSync as $e}from"fs";import{join as Ie}from"path";function ge(e,r){return`Basic ${Buffer.from(`${e}:${r}`).toString("base64")}`}async function Fe(e){let r=ie({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId,codeExport:{enabled:!0,language:e.language,skipValidation:e.skipValidation},mobile:e.framework==="appium"}),s=await A(r.url,{method:"POST",headers:{"content-type":"application/json",authorization:ge(e.auth.username,e.auth.access_key)},body:JSON.stringify(r.body)});if(!s.ok)throw new Error(`code-export trigger failed: ${s.status} ${await s.text()}`);e.log("info","CODE_EXPORT_TRIGGERED","Code export triggered",{testcase_id:e.testcaseId})}async function Oe(e){let r=ae({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId}),s=e.pollIntervalMs??5e3,n=e.timeoutMs??3e5,o=Date.now()+n;for(;Date.now()<o;){let t=await A(r,{headers:{authorization:ge(e.auth.username,e.auth.access_key),accept:"application/json"}});if(!t.ok){await new Promise(c=>setTimeout(c,s));continue}let a=(await t.json()).data?.find(c=>c.code_name==="kane-cli-trigger");if(!a){await new Promise(c=>setTimeout(c,s));continue}let u=(a.status??"").toLowerCase();if(u==="in progress"||u==="in_progress"||u==="pending"){await new Promise(c=>setTimeout(c,s));continue}if(!a.url||a.url.length===0)throw new Error(`code-export status=${a.status} but no files returned`);Ce(e.outDir,{recursive:!0});for(let c of a.url){let l=Ie(e.outDir,c.file_name),g=await A(c.file_url);if(!g.ok){e.log("warn","CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:c.file_name,status:g.status});continue}let _=await g.text();$e(l,_,"utf-8")}return e.log("info","CODE_EXPORT_DOWNLOADED","Code export saved",{out_dir:e.outDir,file_count:a.url.length}),e.outDir}throw new Error("code-export polling timed out")}async function pe(e){return await Fe(e),await Oe(e)}var E=v(K(),1);import{existsSync as Ae,readFileSync as Le}from"fs";var h=v(F(),1);function je(e){j(e);let r=M(e);if(!Ae(r))return null;try{return JSON.parse(Le(r,"utf8"))}catch{return{}}}function Be(e){return e===null?"never_run":e.testcase_id?"synced":"local_only"}function Ne(e){return e==="synced"?"\u2601":e==="local_only"?"\u25A3":"\u25CB"}function Ue(e){return e==="tests-dir"?"\u2726":" "}function We(e,r){return r==="all"?!0:r==="synced"?e.status==="synced":r==="local"?e.status==="local_only":r==="never_run"?e.status==="never_run":r==="cli"?e.source==="tests-dir":r==="hand"?e.source==="cwd":!0}var z=["all","synced","local","never_run","cli","hand"];function Je(e){let r=z.indexOf(e);return z[(r+1)%z.length]}function he({root:e,currentOrgId:r,onSelect:s,onCancel:n}){let[o,t]=(0,E.useState)([]),[i,a]=(0,E.useState)(null),[u,c]=(0,E.useState)(!0),[l,g]=(0,E.useState)("all");(0,E.useEffect)(()=>{(async()=>{try{let d=await U({root:e}),b=[];for(let w of d.results){let G=je(w.path);G?.org_id!==void 0&&G.org_id!==r||b.push({path:w.path,relPath:w.relPath,name:$(w.path),status:Be(G),source:w.source,tags:W(w.path)})}t(b),c(!1)}catch(d){d instanceof R,a(d.message),c(!1)}})()},[e,r]);let _=(0,E.useMemo)(()=>o.filter(d=>We(d,l)).map(d=>({id:d.path,label:`${Ne(d.status)} ${Ue(d.source)} ${d.relPath}${d.tags.length>0?` [${d.tags.join(", ")}]`:""}`})),[o,l]),m=(0,E.useMemo)(()=>Ke(l,o),[l,o]);if(i)return(0,h.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:y.red,paddingX:2,paddingY:1,children:[(0,h.jsx)(p,{color:y.red,bold:!0,children:"testmd"}),(0,h.jsx)(k,{marginTop:1,children:(0,h.jsx)(p,{color:y.red,children:i})})]});let T=l==="all"?"all":Ge(l);return(0,h.jsx)(te,{title:`testmd \xB7 filter: ${T}`,items:_,loading:u,itemNoun:"tests",onSelect:d=>{let b=o.find(w=>w.path===d.id);b&&s(b)},onCancel:n,onTab:()=>g(d=>Je(d)),extraHint:"cycle filter",footer:m})}function Ge(e){return e==="synced"?"synced (\u2601)":e==="local"?"local (\u25A3)":e==="never_run"?"never run (\u25CB)":e==="cli"?"cli-generated (\u2726)":e==="hand"?"hand-written":"all"}function Ke(e,r){let s={synced:r.filter(o=>o.status==="synced").length,local:r.filter(o=>o.status==="local_only").length,never:r.filter(o=>o.status==="never_run").length,cli:r.filter(o=>o.source==="tests-dir").length,hand:r.filter(o=>o.source==="cwd").length},n=o=>o?y.orange:y.dim;return(0,h.jsxs)(k,{flexDirection:"column",children:[(0,h.jsx)(p,{color:y.dim,children:"legend:"}),(0,h.jsxs)(k,{children:[(0,h.jsx)(p,{color:n(e==="synced"),children:` \u2601 synced (${s.synced}) `}),(0,h.jsx)(p,{color:n(e==="local"),children:`\u25A3 local (${s.local}) `}),(0,h.jsx)(p,{color:n(e==="never_run"),children:`\u25CB never run (${s.never})`})]}),(0,h.jsxs)(k,{children:[(0,h.jsx)(p,{color:n(e==="cli"),children:` \u2726 cli-generated (${s.cli}) `}),(0,h.jsx)(p,{color:n(e==="hand"),children:` hand-written (${s.hand})`})]})]})}var I=v(K(),1);import{existsSync as Xe,readFileSync as qe}from"fs";var f=v(F(),1);function _e({path:e,relPath:r,onAction:s,onBack:n,onView:o}){let[t,i]=(0,I.useState)(null),[a,u]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let l=M(e);if(Xe(l))try{i(JSON.parse(qe(l,"utf8")))}catch{i(null)}},[e]),Z((l,g)=>{if(g.escape){if(a){u(!1);return}n();return}if(a){l==="y"||l==="Y"?(u(!1),s("delete")):(l==="n"||l==="N")&&u(!1);return}l==="r"&&s("run"),l==="e"&&t?.testcase_id&&s("export"),l==="d"&&u(!0),l==="v"&&o&&o()});let c=({k:l,v:g})=>g?(0,f.jsxs)(p,{children:[(0,f.jsx)(p,{color:y.dim,children:l.padEnd(14)}),g]}):null;return(0,f.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:y.orange,paddingX:2,paddingY:1,children:[(0,f.jsx)(p,{color:y.orange,bold:!0,children:r}),(0,f.jsx)(k,{marginTop:1,flexDirection:"column",children:t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(c,{k:"test_id",v:t.test_id}),(0,f.jsx)(c,{k:"testcase_id",v:t.testcase_id}),(0,f.jsx)(c,{k:"project_id",v:t.project_id}),(0,f.jsx)(c,{k:"folder_id",v:t.folder_id}),(0,f.jsx)(c,{k:"org_id",v:t.org_id}),(0,f.jsx)(c,{k:"session_name",v:t.session_name}),(0,f.jsx)(c,{k:"commit_id",v:t.commit_id})]}):(0,f.jsx)(p,{color:y.dim,children:"(never run \u2014 no meta.json)"})}),a?(0,f.jsx)(k,{marginTop:1,children:(0,f.jsxs)(p,{color:y.red,bold:!0,children:["Delete ",r," and its output dir? [y/n]"]})}):(0,f.jsx)(k,{marginTop:1,children:(0,f.jsxs)(p,{color:y.dim,children:["[r] run [e] export",t?.testcase_id?"":" (need testcase_id)"," [d] delete",o?" [v] view":""," [Esc] back"]})})]})}function C(e){j(e);let r=M(e);if(!P(r))return null;try{return JSON.parse(He(r,"utf8"))}catch{return null}}function xe(e,r){return!e||e.org_id===void 0?!0:e.org_id===r}function J(e,r){return xe(e,r)?null:(process.stderr.write(`error: this test belongs to org ${e.org_id}; you are logged in as org ${r}.
2
+ import{a as j,b as H}from"./chunk-ZWHPIR2Z.js";import{a as B,b as N}from"./chunk-JKX57HA7.js";import{a as se,b as ie,c as ae}from"./chunk-PDXZROJM.js";import{d as ce}from"./chunk-RH6KFHJB.js";import{a as $,b as q,e as M,g as oe}from"./chunk-KN65CUNT.js";import{a as re,b as ne}from"./chunk-LBNADEQN.js";import{a as L}from"./chunk-O5AS2ZIX.js";import{a as te}from"./chunk-RBHQXWR7.js";import{a as X}from"./chunk-OH2NSBO6.js";import{a as ee}from"./chunk-DHJSM5DT.js";import{a as A}from"./chunk-RZ4F3BHX.js";import{a as O}from"./chunk-IQ7NGOAT.js";import{y}from"./chunk-B2ZGG7WM.js";import{a as F}from"./chunk-HCBYKLMW.js";import{a as k,b as p,i as Z}from"./chunk-C44QQJR4.js";import{a as K}from"./chunk-6YGTRKDT.js";import{e as v}from"./chunk-UR6MHSHU.js";var D=v(K(),1);import{existsSync as P,readFileSync as He,rmSync as ye,unlinkSync as Ve}from"fs";import{resolve as Q}from"path";import{promises as le,realpathSync as Ee}from"fs";import{homedir as Se}from"os";import{join as V,parse as ve,relative as ue,resolve as de}from"path";var fe=new Set(["node_modules",".git","dist","build",".next",".venv","venv","target","__pycache__"]),R=class extends Error{constructor(s){super(`refusing to scan '${s}'. Run from your project root, or pass --root <dir>.`);this.cwd=s;this.name="HomeRefusedError"}};function me(e){try{return Ee(de(e))}catch{return de(e)}}function Re(e){let r=me(e),s=me(Se()),n=ve(r).root;if(process.platform==="win32"){let o=t=>t.toLowerCase();return o(r)===o(s)||o(r)===o(n)}return r===s||r===n}async function U(e){if(Re(e.root))throw new R(e.root);let r=e.maxEntries??5e4,s=e.maxResults??5e3,n=new Set(e.ignore??[]),o=[],t=0,i=0,a=!1,u,c=[e.root];for(;c.length>0&&!a;){let l=c.shift(),g;try{g=await le.readdir(l,{withFileTypes:!0})}catch{continue}i++;for(let _ of g){if(t++,t>r){a=!0,u="max_entries";break}let m=_.name,T=V(l,m);if(_.isDirectory()){if(fe.has(m)||m.startsWith(".")||m.startsWith("output-")||n.has(m))continue;c.push(T)}else if(_.isFile()&&m.endsWith("_test.md")&&(o.push({path:T,relPath:ue(e.root,T),source:"cwd"}),o.length>=s)){a=!0,u="max_results";break}}e.onProgress?.(i,o.length)}if(!a){let g=[{dir:V(e.root,".testmuai","tests"),depth:0}];for(;g.length>0&&!a;){let{dir:_,depth:m}=g.shift(),T;try{T=await le.readdir(_,{withFileTypes:!0})}catch{continue}i++;for(let d of T){if(t++,t>r){a=!0,u="max_entries";break}let b=d.name,w=V(_,b);if(d.isDirectory()){if(m>=20||b.startsWith(".")||b.startsWith("output-")||fe.has(b))continue;g.push({dir:w,depth:m+1})}else if(d.isFile()&&b.endsWith("_test.md")&&(o.push({path:w,relPath:ue(e.root,w),source:"tests-dir"}),o.length>=s)){a=!0,u="max_results";break}}}}return{results:o,aborted:a,abortReason:u,dirsScanned:i}}import{readFileSync as Pe}from"fs";function Y(e){let r;try{r=Pe(e,"utf8")}catch{return{tags:[]}}try{let{global:s}=re(e,r),n=ne(s);return{tags:s.tags??[],...n?{mobileTarget:n}:{}}}catch{return{tags:[],...De(r)?{mobileTarget:Me}:{}}}}var Me={platform:"",app:""};function De(e){let r=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!r)return!1;let s=r[1].split(/\r?\n/);if(s.some(o=>/^target:\s*['"]?(emulator|simulator)['"]?\s*$/.test(o)))return!0;let n=s.findIndex(o=>/^target:\s*$/.test(o));return n<0?!1:s.slice(n+1).some(o=>/^\s+\S/.test(o))}function W(e){return Y(e).tags}import{mkdirSync as Ce,writeFileSync as $e}from"fs";import{join as Ie}from"path";function ge(e,r){return`Basic ${Buffer.from(`${e}:${r}`).toString("base64")}`}async function Fe(e){let r=ie({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId,codeExport:{enabled:!0,language:e.language,skipValidation:e.skipValidation},mobile:e.framework==="appium"}),s=await A(r.url,{method:"POST",headers:{"content-type":"application/json",authorization:ge(e.auth.username,e.auth.access_key)},body:JSON.stringify(r.body)});if(!s.ok)throw new Error(`code-export trigger failed: ${s.status} ${await s.text()}`);e.log("info","CODE_EXPORT_TRIGGERED","Code export triggered",{testcase_id:e.testcaseId})}async function Oe(e){let r=ae({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId}),s=e.pollIntervalMs??5e3,n=e.timeoutMs??3e5,o=Date.now()+n;for(;Date.now()<o;){let t=await A(r,{headers:{authorization:ge(e.auth.username,e.auth.access_key),accept:"application/json"}});if(!t.ok){await new Promise(c=>setTimeout(c,s));continue}let a=(await t.json()).data?.find(c=>c.code_name==="kane-cli-trigger");if(!a){await new Promise(c=>setTimeout(c,s));continue}let u=(a.status??"").toLowerCase();if(u==="in progress"||u==="in_progress"||u==="pending"){await new Promise(c=>setTimeout(c,s));continue}if(!a.url||a.url.length===0)throw new Error(`code-export status=${a.status} but no files returned`);Ce(e.outDir,{recursive:!0});for(let c of a.url){let l=Ie(e.outDir,c.file_name),g=await A(c.file_url);if(!g.ok){e.log("warn","CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:c.file_name,status:g.status});continue}let _=await g.text();$e(l,_,"utf-8")}return e.log("info","CODE_EXPORT_DOWNLOADED","Code export saved",{out_dir:e.outDir,file_count:a.url.length}),e.outDir}throw new Error("code-export polling timed out")}async function pe(e){return await Fe(e),await Oe(e)}var E=v(K(),1);import{existsSync as Ae,readFileSync as Le}from"fs";var h=v(F(),1);function je(e){j(e);let r=M(e);if(!Ae(r))return null;try{return JSON.parse(Le(r,"utf8"))}catch{return{}}}function Be(e){return e===null?"never_run":e.testcase_id?"synced":"local_only"}function Ne(e){return e==="synced"?"\u2601":e==="local_only"?"\u25A3":"\u25CB"}function Ue(e){return e==="tests-dir"?"\u2726":" "}function We(e,r){return r==="all"?!0:r==="synced"?e.status==="synced":r==="local"?e.status==="local_only":r==="never_run"?e.status==="never_run":r==="cli"?e.source==="tests-dir":r==="hand"?e.source==="cwd":!0}var z=["all","synced","local","never_run","cli","hand"];function Je(e){let r=z.indexOf(e);return z[(r+1)%z.length]}function he({root:e,currentOrgId:r,onSelect:s,onCancel:n}){let[o,t]=(0,E.useState)([]),[i,a]=(0,E.useState)(null),[u,c]=(0,E.useState)(!0),[l,g]=(0,E.useState)("all");(0,E.useEffect)(()=>{(async()=>{try{let d=await U({root:e}),b=[];for(let w of d.results){let G=je(w.path);G?.org_id!==void 0&&G.org_id!==r||b.push({path:w.path,relPath:w.relPath,name:$(w.path),status:Be(G),source:w.source,tags:W(w.path)})}t(b),c(!1)}catch(d){d instanceof R,a(d.message),c(!1)}})()},[e,r]);let _=(0,E.useMemo)(()=>o.filter(d=>We(d,l)).map(d=>({id:d.path,label:`${Ne(d.status)} ${Ue(d.source)} ${d.relPath}${d.tags.length>0?` [${d.tags.join(", ")}]`:""}`})),[o,l]),m=(0,E.useMemo)(()=>Ke(l,o),[l,o]);if(i)return(0,h.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:y.red,paddingX:2,paddingY:1,children:[(0,h.jsx)(p,{color:y.red,bold:!0,children:"testmd"}),(0,h.jsx)(k,{marginTop:1,children:(0,h.jsx)(p,{color:y.red,children:i})})]});let T=l==="all"?"all":Ge(l);return(0,h.jsx)(te,{title:`testmd \xB7 filter: ${T}`,items:_,loading:u,itemNoun:"tests",onSelect:d=>{let b=o.find(w=>w.path===d.id);b&&s(b)},onCancel:n,onTab:()=>g(d=>Je(d)),extraHint:"cycle filter",footer:m})}function Ge(e){return e==="synced"?"synced (\u2601)":e==="local"?"local (\u25A3)":e==="never_run"?"never run (\u25CB)":e==="cli"?"cli-generated (\u2726)":e==="hand"?"hand-written":"all"}function Ke(e,r){let s={synced:r.filter(o=>o.status==="synced").length,local:r.filter(o=>o.status==="local_only").length,never:r.filter(o=>o.status==="never_run").length,cli:r.filter(o=>o.source==="tests-dir").length,hand:r.filter(o=>o.source==="cwd").length},n=o=>o?y.orange:y.dim;return(0,h.jsxs)(k,{flexDirection:"column",children:[(0,h.jsx)(p,{color:y.dim,children:"legend:"}),(0,h.jsxs)(k,{children:[(0,h.jsx)(p,{color:n(e==="synced"),children:` \u2601 synced (${s.synced}) `}),(0,h.jsx)(p,{color:n(e==="local"),children:`\u25A3 local (${s.local}) `}),(0,h.jsx)(p,{color:n(e==="never_run"),children:`\u25CB never run (${s.never})`})]}),(0,h.jsxs)(k,{children:[(0,h.jsx)(p,{color:n(e==="cli"),children:` \u2726 cli-generated (${s.cli}) `}),(0,h.jsx)(p,{color:n(e==="hand"),children:` hand-written (${s.hand})`})]})]})}var I=v(K(),1);import{existsSync as Xe,readFileSync as qe}from"fs";var f=v(F(),1);function _e({path:e,relPath:r,onAction:s,onBack:n,onView:o}){let[t,i]=(0,I.useState)(null),[a,u]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let l=M(e);if(Xe(l))try{i(JSON.parse(qe(l,"utf8")))}catch{i(null)}},[e]),Z((l,g)=>{if(g.escape){if(a){u(!1);return}n();return}if(a){l==="y"||l==="Y"?(u(!1),s("delete")):(l==="n"||l==="N")&&u(!1);return}l==="r"&&s("run"),l==="e"&&t?.testcase_id&&s("export"),l==="d"&&u(!0),l==="v"&&o&&o()});let c=({k:l,v:g})=>g?(0,f.jsxs)(p,{children:[(0,f.jsx)(p,{color:y.dim,children:l.padEnd(14)}),g]}):null;return(0,f.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:y.orange,paddingX:2,paddingY:1,children:[(0,f.jsx)(p,{color:y.orange,bold:!0,children:r}),(0,f.jsx)(k,{marginTop:1,flexDirection:"column",children:t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(c,{k:"test_id",v:t.test_id}),(0,f.jsx)(c,{k:"testcase_id",v:t.testcase_id}),(0,f.jsx)(c,{k:"project_id",v:t.project_id}),(0,f.jsx)(c,{k:"folder_id",v:t.folder_id}),(0,f.jsx)(c,{k:"org_id",v:t.org_id}),(0,f.jsx)(c,{k:"session_name",v:t.session_name}),(0,f.jsx)(c,{k:"commit_id",v:t.commit_id})]}):(0,f.jsx)(p,{color:y.dim,children:"(never run \u2014 no meta.json)"})}),a?(0,f.jsx)(k,{marginTop:1,children:(0,f.jsxs)(p,{color:y.red,bold:!0,children:["Delete ",r," and its output dir? [y/n]"]})}):(0,f.jsx)(k,{marginTop:1,children:(0,f.jsxs)(p,{color:y.dim,children:["[r] run [e] export",t?.testcase_id?"":" (need testcase_id)"," [d] delete",o?" [v] view":""," [Esc] back"]})})]})}function C(e){j(e);let r=M(e);if(!P(r))return null;try{return JSON.parse(He(r,"utf8"))}catch{return null}}function xe(e,r){return!e||e.org_id===void 0?!0:e.org_id===r}function J(e,r){return xe(e,r)?null:(process.stderr.write(`error: this test belongs to org ${e.org_id}; you are logged in as org ${r}.
3
3
  Switch profiles with \`kane-cli profiles switch\` to act on it.
4
4
  `),2)}async function Ht(e={}){let r=!!process.stdin.isTTY&&!e.json,s=new O,n=new L;await H({isInteractive:r,creds:s,config:n});let o=s.getDefaultEnv()??"prod";try{let t=await N({creds:s,env:o,log:()=>{}});return t.resolvedCreds?.org_id===void 0?(process.stderr.write("error: TMS did not return an org_id. Run `kane-cli login` again.\n"),{ok:!1,code:2}):{ok:!0,orgId:String(t.resolvedCreds.org_id)}}catch(t){if(t instanceof B)return process.stderr.write("error: not authenticated. Run `kane-cli login` first.\n"),{ok:!1,code:2};throw t}}async function Vt(e,r){if(process.stdin.isTTY&&!e.json)return await Qe(r,e.root);let s=e.root??process.cwd(),n;try{n=await U({root:s,ignore:e.ignore})}catch(o){if(o instanceof R)return process.stderr.write(`error: ${o.message}
5
5
  `),2;throw o}for(let o of n.results){let t=C(o.path);if(!xe(t,r))continue;let i={path:o.relPath.startsWith(".")?o.relPath:`./${o.relPath}`,name:$(o.path),has_meta:t!==null,source:o.source,synced:!!t?.testcase_id,tags:W(o.path)};t&&(t.test_id&&(i.test_id=t.test_id),t.testcase_id&&(i.testcase_id=t.testcase_id),t.org_id&&(i.org_id=t.org_id),t.project_id&&(i.project_id=t.project_id),t.folder_id&&(i.folder_id=t.folder_id)),process.stdout.write(JSON.stringify(i)+`
6
6
  `)}return n.aborted&&process.stderr.write(`warn: walk aborted (${n.abortReason}). Pass --root or --ignore to narrow.
7
- `),0}var we=-1001,be=-1002,ke=-1003,x={action:null,path:null};function Ye(e,r){return x.action=e,x.path=r,e==="run"?we:e==="export"?be:ke}function ze({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(he,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(_e,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Ye(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function Qe(e,r){let s=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:a}=n(D.default.createElement(ze,{root:s,currentOrgId:e,onComplete:u=>{i(),t(u)}}),{stdout:process.stderr,exitOnCtrlC:!0});a().then(()=>t(0)).catch(()=>t(0))});if(o===we&&x.path){let{runTestMdFile:t}=await import("./run-test-md-5LPCKCW7.js"),i=await t(x.path,{});return x.action=null,x.path=null,i}if(o===be&&x.path){let t=await et(x.path,{},e);return x.action=null,x.path=null,t}if(o===ke&&x.path){let t=await Ze(x.path,!0,e);return x.action=null,x.path=null,t}return o}async function Yt(e,r){let s=Q(e);if(!P(s))return process.stderr.write(`error: file not found: ${s}
7
+ `),0}var we=-1001,be=-1002,ke=-1003,x={action:null,path:null};function Ye(e,r){return x.action=e,x.path=r,e==="run"?we:e==="export"?be:ke}function ze({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(he,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(_e,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Ye(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function Qe(e,r){let s=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:a}=n(D.default.createElement(ze,{root:s,currentOrgId:e,onComplete:u=>{i(),t(u)}}),{stdout:process.stderr,exitOnCtrlC:!0});a().then(()=>t(0)).catch(()=>t(0))});if(o===we&&x.path){let{runTestMdFile:t}=await import("./run-test-md-DFCKCQ4T.js"),i=await t(x.path,{});return x.action=null,x.path=null,i}if(o===be&&x.path){let t=await et(x.path,{},e);return x.action=null,x.path=null,t}if(o===ke&&x.path){let t=await Ze(x.path,!0,e);return x.action=null,x.path=null,t}return o}async function Yt(e,r){let s=Q(e);if(!P(s))return process.stderr.write(`error: file not found: ${s}
8
8
  `),2;let n=C(s),o=J(n,r);if(o!==null)return o;let t={path:s,name:$(s),has_meta:n!==null};return n&&(n.commit_id&&(t.commit_id=n.commit_id),n.test_id&&(t.test_id=n.test_id),n.testcase_id&&(t.testcase_id=n.testcase_id),n.project_id&&(t.project_id=n.project_id),n.folder_id&&(t.folder_id=n.folder_id),n.org_id&&(t.org_id=n.org_id),n.session_name&&(t.session_name=n.session_name)),process.stdout.write(JSON.stringify(t)+`
9
9
  `),0}async function Ze(e,r,s){let n=Q(e);if(!P(n))return process.stderr.write(`error: file not found: ${n}
10
10
  `),2;let o=C(n),t=J(o,s);if(t!==null)return t;if(!r)return process.stderr.write(`error: refusing to delete without --yes.