@testmuai/kane-cli 0.8.17 → 0.8.20

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 (182) hide show
  1. package/dist/{ChatSurface-X2HLVN2I.js → ChatSurface-757LHEYF.js} +1 -1
  2. package/dist/{ChromeProfilePicker-YU7HL6Z5.js → ChromeProfilePicker-UAMRJG2H.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-7FEEVGCU.js → CliFeedbackPrompt-NAPKBEOP.js} +1 -1
  4. package/dist/{CliUploadProgress-OTVPBGW4.js → CliUploadProgress-R6FHYXP5.js} +1 -1
  5. package/dist/{ConfigView-UKHUASHL.js → ConfigView-CKYIRJBS.js} +1 -1
  6. package/dist/{EvidenceViewOffer-LIPGXO23.js → EvidenceViewOffer-M3DAU4YU.js} +1 -1
  7. package/dist/FolderPicker-I2E2EJON.js +2 -0
  8. package/dist/{InfoBox-2TYT2ROK.js → InfoBox-WKFPWFII.js} +1 -1
  9. package/dist/{LinksBox-7AS6D7MX.js → LinksBox-MQOD3X3E.js} +1 -1
  10. package/dist/{ProfilesView-F4MFHZ7Y.js → ProfilesView-PLO2SBGI.js} +1 -1
  11. package/dist/{ProjectPicker-QLGZM35L.js → ProjectPicker-QT2IENIZ.js} +1 -1
  12. package/dist/{SaveSessionPrompt-T4MS76FY.js → SaveSessionPrompt-BRNUVO5J.js} +1 -1
  13. package/dist/SingleShotApp-CQWGPSLT.js +2 -0
  14. package/dist/{SummaryBox-IX32QPWM.js → SummaryBox-7OBZAVJU.js} +1 -1
  15. package/dist/TestMdRunView-GIOPBTA6.js +2 -0
  16. package/dist/{TestrunEvidenceTable-OK2HAENB.js → TestrunEvidenceTable-PKFPTUZX.js} +1 -1
  17. package/dist/WhoamiView-CINKGNTV.js +2 -0
  18. package/dist/{app-download-CF4JLXWV.js → app-download-KLCWIQWJ.js} +1 -1
  19. package/dist/{auth-D4BDPJPR.js → auth-L7PFZJBY.js} +1 -1
  20. package/dist/{binary-NWVJK542.js → binary-25KA3XAX.js} +1 -1
  21. package/dist/{bind-LWN72YES.js → bind-N5QZUUUU.js} +2 -2
  22. package/dist/{bootstrap-63FBDEEU.js → bootstrap-545GY5CC.js} +1 -1
  23. package/dist/bridge-VNFL4T6K.js +2 -0
  24. package/dist/{changelog-GIZLIFMN.js → changelog-ABQ5HREB.js} +1 -1
  25. package/dist/{chunk-637S3COE.js → chunk-2TNMV4BX.js} +1 -1
  26. package/dist/{chunk-KQCGBDPM.js → chunk-3Q5IQXOI.js} +1 -1
  27. package/dist/{chunk-UUYYTJG2.js → chunk-47ZPSTT6.js} +1 -1
  28. package/dist/{chunk-75SSVUGS.js → chunk-4K44ZIC4.js} +1 -1
  29. package/dist/{chunk-3YBT4UGQ.js → chunk-4L45IQNU.js} +1 -1
  30. package/dist/{chunk-RSXCS474.js → chunk-4ZVGZF2L.js} +1 -1
  31. package/dist/{chunk-L2SJRAK4.js → chunk-56UYK35Z.js} +1 -1
  32. package/dist/{chunk-WKIYI6MB.js → chunk-5FCXFSAO.js} +1 -1
  33. package/dist/{chunk-2LCWGWYC.js → chunk-5UCXN56I.js} +1 -1
  34. package/dist/{chunk-VIYV6NIW.js → chunk-5WZ2WOOM.js} +1 -1
  35. package/dist/{chunk-ICFJVEEA.js → chunk-6MTKXDTH.js} +1 -1
  36. package/dist/{chunk-I6RTGDZ7.js → chunk-6V4ANMW4.js} +1 -1
  37. package/dist/{chunk-B6NU3SNG.js → chunk-7BKOTLIL.js} +1 -1
  38. package/dist/{chunk-MDM2LJFN.js → chunk-7SV2NQZV.js} +1 -1
  39. package/dist/chunk-7XC5IQN6.js +95 -0
  40. package/dist/{chunk-7U7HOEZO.js → chunk-A55WPXDZ.js} +1 -1
  41. package/dist/{chunk-GT6Y2SEY.js → chunk-ALK3OUGN.js} +2 -2
  42. package/dist/{chunk-IZ3PYWUL.js → chunk-ARCYAF37.js} +1 -1
  43. package/dist/{chunk-3UIZVDOF.js → chunk-AXJ47YFH.js} +1 -1
  44. package/dist/{chunk-IHD2WXKT.js → chunk-BNWU7JOW.js} +1 -1
  45. package/dist/{chunk-UQNRUAES.js → chunk-CLLLLX4F.js} +1 -1
  46. package/dist/{chunk-JWPBLVPW.js → chunk-CVXVFF2G.js} +1 -1
  47. package/dist/{chunk-AG2MVCNK.js → chunk-CXXTQ4C5.js} +1 -1
  48. package/dist/{chunk-4OQ7GEIA.js → chunk-DCLMFWCF.js} +1 -1
  49. package/dist/{chunk-RGJIGNB3.js → chunk-DFHVZZI3.js} +1 -1
  50. package/dist/{chunk-2STKZSVF.js → chunk-DVYQVSNS.js} +1 -1
  51. package/dist/{chunk-D2F5T3NX.js → chunk-E6MW25UV.js} +1 -1
  52. package/dist/{chunk-AW34ZNNO.js → chunk-EPVK2NMQ.js} +1 -1
  53. package/dist/{chunk-KMF2PPJ5.js → chunk-EV3EU2MT.js} +1 -1
  54. package/dist/{chunk-DFK5QYB5.js → chunk-FD5TFGJX.js} +1 -1
  55. package/dist/{chunk-5LSPHA3P.js → chunk-FNJJGQUI.js} +1 -1
  56. package/dist/{chunk-CCW3VQIY.js → chunk-FYW7USQY.js} +1 -1
  57. package/dist/{chunk-UTIP6SMW.js → chunk-G5Q4EJAT.js} +1 -1
  58. package/dist/{chunk-E6X5BVXC.js → chunk-I3NUTW6U.js} +1 -1
  59. package/dist/{chunk-TMOSERKN.js → chunk-IHVIIRW5.js} +2 -2
  60. package/dist/{chunk-EIMHIZKF.js → chunk-ISBISZUE.js} +1 -1
  61. package/dist/{chunk-YOVKKZVZ.js → chunk-IYOL2FUH.js} +1 -1
  62. package/dist/{chunk-JPOYZCTX.js → chunk-JKQX7DUC.js} +1 -1
  63. package/dist/chunk-K3EN7O5N.js +26 -0
  64. package/dist/{chunk-KRI5NSGQ.js → chunk-K4D5BB63.js} +1 -1
  65. package/dist/{chunk-KX5IV5FL.js → chunk-LJ5O7DZ7.js} +2 -2
  66. package/dist/{chunk-233MYVFS.js → chunk-LPVAOUAC.js} +1 -1
  67. package/dist/{chunk-5ZU7S4E7.js → chunk-M5V464PU.js} +2 -2
  68. package/dist/{chunk-2LKNUXRN.js → chunk-N3MZALFQ.js} +1 -1
  69. package/dist/{chunk-47QKRIPY.js → chunk-NFQ67CQO.js} +3 -3
  70. package/dist/{chunk-CCNPXTC6.js → chunk-OGWYTILK.js} +2 -2
  71. package/dist/{chunk-PHR2OSWD.js → chunk-OWPQZP4C.js} +1 -1
  72. package/dist/{chunk-TISVRTL7.js → chunk-P6HK7GSS.js} +7 -6
  73. package/dist/{chunk-SDJNWR4D.js → chunk-PCBCEXYO.js} +1 -1
  74. package/dist/{chunk-ZRRBZUDJ.js → chunk-PN4EL4JN.js} +1 -1
  75. package/dist/{chunk-IKB2JKMA.js → chunk-PP4I2Z6M.js} +1 -1
  76. package/dist/{chunk-GIC56KI3.js → chunk-PY4BWRR6.js} +1 -1
  77. package/dist/{chunk-DQRVB5EU.js → chunk-Q5PQ7U3W.js} +1 -1
  78. package/dist/{chunk-IGI4T3VC.js → chunk-QBU5B4GH.js} +1 -1
  79. package/dist/chunk-R54VY272.js +6 -0
  80. package/dist/{chunk-WDK5ETMA.js → chunk-R5UVQMMP.js} +1 -1
  81. package/dist/{chunk-5X7JIGG7.js → chunk-R6RK32R2.js} +1 -1
  82. package/dist/{chunk-JWOPRJIO.js → chunk-RMLC3QWX.js} +1 -1
  83. package/dist/{chunk-KWANVHJX.js → chunk-RPJUE54T.js} +1 -1
  84. package/dist/{chunk-AH4QWIYU.js → chunk-RTD27WRG.js} +1 -1
  85. package/dist/{chunk-6OKOMKYR.js → chunk-RV3KMXUX.js} +1 -1
  86. package/dist/{chunk-5HDM7GDO.js → chunk-SA7ORQHP.js} +1 -1
  87. package/dist/{chunk-6CYF7Q5W.js → chunk-SBSANJ2T.js} +2 -2
  88. package/dist/{chunk-5MKY3WMF.js → chunk-SHXJQ73O.js} +1 -1
  89. package/dist/{chunk-UXJZUGKL.js → chunk-T27HVHZA.js} +1 -1
  90. package/dist/{chunk-AIR2WVXM.js → chunk-T7UACVWW.js} +1 -1
  91. package/dist/{chunk-DT2LIX5S.js → chunk-TEJG5H2O.js} +1 -1
  92. package/dist/{chunk-NFLQWKFR.js → chunk-TFGGJSTI.js} +2 -2
  93. package/dist/{chunk-4PWAODKJ.js → chunk-U7WMRB5V.js} +1 -1
  94. package/dist/{chunk-N55U4S4W.js → chunk-UFWG6VMI.js} +1 -1
  95. package/dist/{chunk-GBXF4JE6.js → chunk-UUT7EHLT.js} +1 -1
  96. package/dist/{chunk-IDLJHKJX.js → chunk-UVR7MESH.js} +1 -1
  97. package/dist/{chunk-IHUF6UP4.js → chunk-UYTBGBT4.js} +1 -1
  98. package/dist/{chunk-MTCLFYNH.js → chunk-VKFLER7N.js} +1 -1
  99. package/dist/{chunk-ZQ6KWTJ2.js → chunk-VL7LPZVI.js} +1 -1
  100. package/dist/{chunk-PDXZROJM.js → chunk-W3USRQX6.js} +1 -1
  101. package/dist/{chunk-HLUOLWEJ.js → chunk-X77AR3IL.js} +1 -1
  102. package/dist/{chunk-JGCB4OUP.js → chunk-XSZH2K3E.js} +1 -1
  103. package/dist/{chunk-5UHM7CKR.js → chunk-Y67FYNLP.js} +1 -1
  104. package/dist/chunk-YKYHVRM2.js +5 -0
  105. package/dist/{chunk-4ASBXR6Q.js → chunk-YL5J3SNK.js} +1 -1
  106. package/dist/{chunk-RBFCGUR3.js → chunk-YV6CSSWA.js} +1 -1
  107. package/dist/{chunk-LO47W2DO.js → chunk-ZXP2TJEJ.js} +4 -4
  108. package/dist/{config-WKLEWUPU.js → config-A6MBUY54.js} +1 -1
  109. package/dist/{cover-cmd-7TSQJFGM.js → cover-cmd-TIY53OMC.js} +1 -1
  110. package/dist/{credentials-FLY3ZXVX.js → credentials-GXICFDVV.js} +1 -1
  111. package/dist/{deps-bundle-CAKK3EO5.js → deps-bundle-RDGQAIGD.js} +1 -1
  112. package/dist/{deps-resolve-MSLEFPVD.js → deps-resolve-52BOL7G6.js} +1 -1
  113. package/dist/{dispatch-SXS276ZT.js → dispatch-GJ7RVYPK.js} +1 -1
  114. package/dist/{doctor-EZPQTFJM.js → doctor-XNI2NZZJ.js} +1 -1
  115. package/dist/evidence-QYJ7SQR6.js +2 -0
  116. package/dist/{evolve-cmd-LJJFOXXP.js → evolve-cmd-2LM6NKMY.js} +1 -1
  117. package/dist/{explain-cmd-5LLIJKM2.js → explain-cmd-LQ5CHHNY.js} +1 -1
  118. package/dist/{extract-bind-CGU6WVS7.js → extract-bind-NWA4PSTU.js} +2 -2
  119. package/dist/{extract-cmd-7N7CCGN6.js → extract-cmd-Q5PZS626.js} +1 -1
  120. package/dist/{gaps-cmd-BNUGDF5N.js → gaps-cmd-UKMO7KYX.js} +1 -1
  121. package/dist/{generate-headless-7TJYESUU.js → generate-headless-CLKY4IAU.js} +2 -2
  122. package/dist/index.js +125 -125
  123. package/dist/{ingest-cmd-B4T5CW5R.js → ingest-cmd-JZNVRFFS.js} +1 -1
  124. package/dist/install-FLC6WLPZ.js +2 -0
  125. package/dist/{interactive-bind-HUZDSGFX.js → interactive-bind-7JMBM3OK.js} +3 -3
  126. package/dist/{lifecycle-cmd-GIVLSUPE.js → lifecycle-cmd-VMZKHC2Y.js} +1 -1
  127. package/dist/{list-cmd-KEKKQDUF.js → list-cmd-3XDCASJH.js} +1 -1
  128. package/dist/{list-commands-SMBBT5CY.js → list-commands-QURMKZZH.js} +1 -1
  129. package/dist/login-flow-BPT46DCE.js +2 -0
  130. package/dist/{maintenance-cmd-MLQ3IRFV.js → maintenance-cmd-MQ4GCVDU.js} +1 -1
  131. package/dist/{mobile-prompts-EEPPPA6S.js → mobile-prompts-VXNHSCAH.js} +1 -1
  132. package/dist/{objective-variable-gate-AEBWIGH7.js → objective-variable-gate-BDSG2BEA.js} +1 -1
  133. package/dist/{open-provider-OTZ37JB6.js → open-provider-ZYBUD6JW.js} +1 -1
  134. package/dist/{persist-recorded-session-IRWGMXGI.js → persist-recorded-session-NV2ULVPH.js} +1 -1
  135. package/dist/{pipeline-OV3TWKSZ.js → pipeline-STTNBJC4.js} +1 -1
  136. package/dist/prepare-target-CRO3BGAP.js +2 -0
  137. package/dist/{reconcile-cmd-NBBDE7DJ.js → reconcile-cmd-VQTFUGEJ.js} +1 -1
  138. package/dist/{reconcile-deps-DJNIY7TP.js → reconcile-deps-SE6COSXQ.js} +2 -2
  139. package/dist/{reconcile-engine-Z2XKUCQ7.js → reconcile-engine-GLKGQEVR.js} +1 -1
  140. package/dist/{recording-banner-GCR6A46M.js → recording-banner-WZECSZJM.js} +1 -1
  141. package/dist/registry-GQEYUEQJ.js +2 -0
  142. package/dist/{require-project-folder-YBB5T3OE.js → require-project-folder-OFA4F2T5.js} +1 -1
  143. package/dist/{resolve-run-intent-XGZN6OQ6.js → resolve-run-intent-M7EXFU7E.js} +1 -1
  144. package/dist/{resolver-WNV53IOL.js → resolver-TZAQGCFJ.js} +1 -1
  145. package/dist/{review-cmd-ZXTLZ4GE.js → review-cmd-RXD2RWKN.js} +1 -1
  146. package/dist/{run-YWKZGZVL.js → run-DVBOAY7S.js} +1 -1
  147. package/dist/{run-YZP2PTNW.js → run-VF2MBI6M.js} +1 -1
  148. package/dist/{run-test-md-N43FRXB6.js → run-test-md-Z75BGXRK.js} +2 -2
  149. package/dist/{skill-installer-G7Z5ZDAQ.js → skill-installer-FEOJ4KX3.js} +1 -1
  150. package/dist/{spawner-ABB7B5CQ.js → spawner-XHE7OXNW.js} +1 -1
  151. package/dist/{store-guard-YIQQF4LC.js → store-guard-HIBKFC2T.js} +1 -1
  152. package/dist/{sync-cmd-4AKHO5EG.js → sync-cmd-MZYM5IE6.js} +1 -1
  153. package/dist/{sync-setup-E7UV25KK.js → sync-setup-WGYN6ZTI.js} +1 -1
  154. package/dist/tcg-generate-Y2UMDGPL.js +2 -0
  155. package/dist/testmd-actions-UDNH6W2Z.js +2 -0
  156. package/dist/{testmd-sync-I2E6W6JL.js → testmd-sync-4BXMEIJ3.js} +1 -1
  157. package/dist/token-refresh-KYIQ7LZL.js +2 -0
  158. package/dist/{validate-basic-WZY6A3KD.js → validate-basic-GBA5PHIK.js} +1 -1
  159. package/dist/{variable-receipt-JONRYHCY.js → variable-receipt-WMV33LAD.js} +1 -1
  160. package/dist/{verdicts-JMVS6HNJ.js → verdicts-34ZGB67K.js} +1 -1
  161. package/dist/{version-check-CD7DHZI2.js → version-check-BHRM4PN4.js} +1 -1
  162. package/dist/{view-cmd-ASH2UFUW.js → view-cmd-FJGT5KZO.js} +1 -1
  163. package/dist/{walk-session-ZPXR7ASG.js → walk-session-CTZ5475S.js} +1 -1
  164. package/dist/{with-telemetry-QXCHDKPW.js → with-telemetry-AIPWSH4P.js} +1 -1
  165. package/package.json +11 -11
  166. package/dist/FolderPicker-OTQYRAYC.js +0 -2
  167. package/dist/SingleShotApp-4CDTAF3H.js +0 -2
  168. package/dist/TestMdRunView-MRMY3RW5.js +0 -2
  169. package/dist/WhoamiView-AHMNIIXZ.js +0 -2
  170. package/dist/bridge-UMXGHAJF.js +0 -2
  171. package/dist/chunk-64TO3MD7.js +0 -93
  172. package/dist/chunk-BNZQKQOE.js +0 -6
  173. package/dist/chunk-OCWS5YVO.js +0 -26
  174. package/dist/chunk-WC54SZUO.js +0 -5
  175. package/dist/evidence-GUOURW6F.js +0 -2
  176. package/dist/install-6KJ2MZX3.js +0 -2
  177. package/dist/login-flow-5ZIG7JXT.js +0 -2
  178. package/dist/prepare-target-35OI7XBL.js +0 -2
  179. package/dist/registry-V3ULHPLM.js +0 -2
  180. package/dist/tcg-generate-XJN5OMIJ.js +0 -2
  181. package/dist/testmd-actions-WFDWYEAU.js +0 -2
  182. package/dist/token-refresh-NADDXLYM.js +0 -2
@@ -0,0 +1,6 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as Y,b as Z,c as ee,d as ne,e as te}from"./chunk-DFHVZZI3.js";import{b as ie,c as re}from"./chunk-P7YZ3PU3.js";import{n as X,p as P}from"./chunk-RSSOJ3L2.js";import{a as Pe}from"./chunk-6YGTRKDT.js";import{e as Ce}from"./chunk-UR6MHSHU.js";function se(i){return{command:"start",...i}}function oe(i,n,o){return{command:"run",run_id:i,kind:n,...o}}function ae(i){return{command:"cancel",...i?{run_id:i}:{}}}function ue(i){return{command:"ask_user_response",answer:i}}function de(i={}){return{command:"shutdown",...i.testStatus?{test_status:i.testStatus,remark:i.remark??""}:{}}}var z=Symbol("run-queue-end"),G=class{items=[];waiting=null;ended=!1;error=null;push(n){if(this.waiting){let{resolve:o}=this.waiting;this.waiting=null,o(n)}else this.items.push(n)}end(){if(this.ended=!0,this.waiting){let{resolve:n}=this.waiting;this.waiting=null,n(z)}}fail(n){if(this.error=n,this.waiting){let{reject:o}=this.waiting;this.waiting=null,o(n)}}next(){return this.items.length>0?Promise.resolve(this.items.shift()):this.error?Promise.reject(this.error):this.ended?Promise.resolve(z):new Promise((n,o)=>{this.waiting={resolve:n,reject:o}})}},D=class{env;runner;log;sessionId;spawnFn;proc=null;activeRun=null;pendingReady=null;shuttingDown=!1;finalized=!1;exitInfo=null;exitedUnexpectedly=!1;exitResolve;exited;constructor(n){this.env=n.env,this.runner=n.runner,this.log=n.log,this.sessionId=n.sessionId,this.spawnFn=n.spawn??Z;let o;this.exited=new Promise(c=>{o=c}),this.exitResolve=o}async start(n){if(this.proc)throw new Error("PersistentRunner.start called twice");this.proc=this.spawnFn({env:this.env,runner:this.runner,log:this.log,sessionId:this.sessionId}),this.consume();let o=new Promise((c,g)=>{this.pendingReady={resolve:c,reject:g}});this.writeCommand(se(n)),await o}async*run(n,o,c){if(!this.proc)throw new Error("PersistentRunner.run called before start");if(this.finalized)throw new Error(`v16-runner is not running (exited code=${this.exitInfo?.code??"null"}, signal=${this.exitInfo?.signal??"none"}) \u2014 cannot start run '${n}'`);if(this.activeRun)throw new Error(`PersistentRunner.run overlap: '${this.activeRun.runId}' still in flight`);let g=new G,w={runId:n,queue:g};this.activeRun=w,this.writeCommand(oe(n,o,c));try{for(;;){let v=await g.next();if(v===z||(yield v,v.type==="run_end"&&(v.run_id===void 0||v.run_id===n)))break}}finally{this.activeRun===w&&(this.activeRun=null)}}sendUserResponse(n){this.writeCommand(ue(n))}cancel(n){this.writeCommand(ae(n))}kill(){this.proc?.child.kill("SIGTERM")}async shutdown(n={}){this.shuttingDown=!0,this.proc&&(this.writeCommand(de(n)),await this.exited)}get stderr(){return this.proc?.getStderr()??""}get diedUnexpectedly(){return this.exitedUnexpectedly}writeCommand(n){let o=JSON.stringify(n)+`
3
+ `;try{this.proc?.child.stdin?.write(o)}catch{}}async consume(){if(!this.proc)return;try{for await(let c of this.proc.events){if(c.type==="ready"){this.onReady();continue}this.routeEvent(c)}}catch(c){this.log?.("error","PERSISTENT_RUNNER_STREAM_ERROR","Runner stdout stream errored",{error:c instanceof Error?c.message:String(c)})}let{code:n,signal:o}=await this.proc.exited;this.onExit(n,o)}onReady(){if(this.pendingReady){let{resolve:n}=this.pendingReady;this.pendingReady=null,n()}}routeEvent(n){let o=this.activeRun;if(!o){this.log?.("warn","PERSISTENT_RUNNER_ORPHAN_EVENT","Runner event with no active run",{event_type:n.type});return}o.queue.push(n)}onExit(n,o){if(!this.finalized){if(this.finalized=!0,this.exitInfo={code:n,signal:o},this.shuttingDown||(this.exitedUnexpectedly=!0),this.exitResolve({code:n,signal:o}),this.pendingReady){let{reject:c}=this.pendingReady;this.pendingReady=null,c(new Error(`v16-runner exited before ready (code=${n}, signal=${o??"none"})`))}if(this.activeRun){let{queue:c}=this.activeRun;if(this.activeRun=null,this.shuttingDown)c.end();else{let g=this.proc?.getStderr()?.slice(-500)??"";c.fail(new Error(`v16-runner exited unexpectedly mid-run (code=${n}, signal=${o??"none"})${g?`
4
+ ${g}`:""}`))}}}}};var p=Ce(Pe(),1);function le(i){let n={cdp_endpoint:i.cdp_endpoint,ws_endpoint:i.ws_endpoint,width:i.width,height:i.height,headless:i.headless,model:i.model,max_steps:i.max_steps,network_ws:i.network_ws,network_sse:i.network_sse,session_id:i.session_id};return i.device&&(n.device=i.device),i.auth&&(n.auth=i.auth),i.project_id&&(n.project_id=i.project_id),i.disable_ask_user&&(n.disable_ask_user=!0),i.username&&(n.username=i.username),i.access_key&&(n.access_key=i.access_key),n}function j(i,n){let o=null,c=(g,w)=>{for(let v=0;v<g.length;v++){let _=g[v],h=[...w,v];n(_)&&(o===null||h.length>o.length)&&(o=h),_.children&&_.children.length>0&&c(_.children,h)}};return c(i,[]),o}function N(i,n,o){if(n.length===0)return[...i];let c=n[0],g=[...i],w=g[c];if(n.length===1)g[c]=o(w);else{let v=n.slice(1),_=N(w.children??[],v,o);g[c]={...w,children:_}}return g}function ce(){return{steps:[],maxOrdinal:0}}function je(i,n){if(n.type==="run_start"&&n.child_id)return n.environment?.resolution?{...i,resolution:n.environment.resolution}:i;if(n.type==="run_start"){let o=re(i.runnerEnvironment,ie(n.environment));if(o)return{...i,runnerEnvironment:o,...o.resolution?{resolution:o.resolution}:{}}}if(n.type==="step_end"&&typeof n.ordinal=="number"&&n.id){let o={id:n.id,ordinal:n.ordinal,status:n.status,...n.kind?{kind:n.kind}:{},...typeof n.duration=="number"?{duration_ms:Math.round(n.duration*1e3)}:{},...typeof n.action_id=="string"&&n.action_id?{action_id:n.action_id}:{}};return{...i,steps:[...i.steps,o],maxOrdinal:Math.max(i.maxOrdinal,n.ordinal)}}return i}function K(i){let n=i.indexOf(": ");return n>0&&n<15?i.slice(n+2):i}function V(i){return i.map(n=>{let o=n.children?V(n.children):n.children;return n.status==="running"?{...n,status:"stopped",phase:void 0,children:o}:o!==n.children?{...n,children:o}:n})}function ze(i,n,o,c,g){let[w,v]=(0,p.useState)(!1),[_,h]=(0,p.useState)([]),[pe,T]=(0,p.useState)(null),[he,B]=(0,p.useState)(null),[fe,k]=(0,p.useState)(null),[me,W]=(0,p.useState)(null),[ve,J]=(0,p.useState)([]),[ge,H]=(0,p.useState)(null),[Re,Se]=(0,p.useState)(void 0),[ye,$]=(0,p.useState)(0),y=(0,p.useRef)(null),E=(0,p.useRef)(null),S=(0,p.useRef)(null),b=(0,p.useRef)(0),F=(0,p.useRef)(!1),U=(0,p.useRef)(ce()),O=(0,p.useRef)(null),we=(0,p.useCallback)(async(m,x)=>{let Q=O.current;if(Q)try{await Q}catch{}h([]),T(null),B(null),k(null),W(null),J([]),H(null),Se(m.max_steps),v(!0),S.current=null,b.current=0,U.current=ce();let I=y.current;if(I&&E.current!==m.session_id){try{I.kill()}catch{}y.current=null,E.current=null,$(e=>e+1),I=null}if(!I){let e=Y();if(!e){k("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available."),v(!1);return}let d=ne({environment:x?.environment,mode:x?.mode,assertionMode:x?.assertionMode,finalValidation:x?.finalValidation,username:m.username,accessKey:m.access_key,sessionId:m.session_id});m.device?.platform&&await ee(d,m.device);let u=new D({env:d,runner:e,log:x?.log,sessionId:m.session_id});y.current=u,E.current=m.session_id,I=u,X("runner",()=>{try{u.kill()}catch{}});let s=le(m);try{await u.start(s)}catch(a){k(a instanceof Error?a.message:String(a)),v(!1),P("runner","Runner start failed"),y.current=null,E.current=null,$(t=>t+1);return}}let M={...m};delete M.run_id,te(M,{environment:x?.environment});let ke=`run-${m.run_index}`,Ie=m.mode==="replay"?"replay":"author",L=I,q=(async()=>{F.current=!1;for await(let e of L.run(ke,Ie,M)){if(F.current)break;switch(U.current=je(U.current,e),e.type){case"run_start":if(e.child_id)break;if(S.current&&!S.current.isSingleFlow){let d=b.current;b.current++,h(u=>u.map((s,a)=>a===d?{...s,status:"running"}:s.status==="running"&&!s.children?.some(t=>t.status==="running")?{...s,status:s.children?.some(t=>t.status==="failed")?"failed":"passed"}:s))}break;case"bifurcation":{let d=e.flows??[],u=e.count??d.length,s={flows:d,isSingleFlow:e.is_single_flow??u<=1};W(s),S.current=s,b.current=0,h(d.map((a,t)=>({index:t+1,objective:a??`Flow ${t+1}`,status:"pending"})));break}case"step_start":{n?.("STEP_START",`Step ${e.index} started`,{index:e.index,objective:e.objective,child_id:e.child_id});let d=e.index,u=e.objective??`Step ${d}`,s=e.child_id,a=S.current&&!S.current.isSingleFlow;if(s)h(t=>{let r=j(t,l=>l.branchChildId===s)??j(t,l=>l.status==="running");return r?N(t,r,l=>{let f=(l.children??[]).map(R=>R.status==="running"&&R.childId===s?{...R,status:"stopped",phase:void 0}:R);return f.push({index:d,objective:u,status:"running",childId:s}),{...l,children:f}}):t});else if(a){let t=Math.max(0,b.current-1);h(r=>{let l=[...r];if(t>=l.length)return r;let f={...l[t]},C=[...f.children??[]].map(A=>A.status==="running"&&A.childId===void 0?{...A,status:"stopped",phase:void 0}:A);return C.push({index:d,objective:u,status:"running"}),f.children=C,f.status="running",l[t]=f,l})}else h(t=>{let r=V(t);return r.some(f=>f.index===d)?r.map(f=>f.index===d?{...f,status:"running",objective:u}:f):[...r,{index:d,objective:u,status:"running"}]});break}case"step_event":{n?.("STEP_EVENT",`Step ${e.index} ${e.event}`,{index:e.index,phase:e.event,action_type:e.action_type,detail:e.detail,child_id:e.child_id});let d=e.child_id,u=S.current&&!S.current.isSingleFlow;if(e.event==="cm_init"&&e.checkpoint_count!=null){J(s=>[...s,e.checkpoint_count]);break}if(e.event==="replay_started"){H({recordingLength:e.recording_length??0});break}if(e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&o?.(e.detail),d){let s=t=>{if(t.index!==e.index||t.childId!==d)return t;let r={phase:e.event};return e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(r.objective=e.detail),e.action_type&&(r.actionType=e.action_type),{...t,...r}},a=t=>t.map(r=>{let l=s(r);return l!==r?l:r.children&&r.children.length>0?{...r,children:a(r.children)}:r});h(t=>t.map(r=>r.children?{...r,children:a(r.children)}:r))}else if(u){let s=Math.max(0,b.current-1);h(a=>{let t=[...a];if(s>=t.length)return a;let r={...t[s]},l=[...r.children??[]];if(!l.some(R=>R.index===e.index&&R.childId===void 0))l.push({index:e.index,objective:`Step ${e.index}`,status:"running",phase:e.event,actionType:e.action_type});else for(let R=0;R<l.length;R++){if(l[R].index!==e.index||l[R].childId!==void 0)continue;let C={phase:e.event};e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(C.objective=e.detail),e.action_type&&(C.actionType=e.action_type),l[R]={...l[R],...C}}return r.children=l,t[s]=r,t})}else h(s=>s.some(t=>t.index===e.index)?s.map(t=>{if(t.index!==e.index)return t;let r={phase:e.event};return e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(r.objective=e.detail),e.action_type&&(r.actionType=e.action_type),{...t,...r}}):[...V(s),{index:e.index,objective:`Step ${e.index}`,status:"running",phase:e.event,actionType:e.action_type}]);break}case"step_end":{n?.("STEP_END",`Step ${e.index} ${e.status}`,{index:e.index,status:e.status,duration:e.duration,summary:e.summary,child_id:e.child_id}),c?.();let d=e.child_id,u=S.current&&!S.current.isSingleFlow;if(d){let s=t=>t.index===e.index&&t.childId===d?{...t,status:e.status,duration:e.duration,phase:void 0,objective:t.objective.startsWith("Step ")?K(e.summary||t.objective):t.objective}:t,a=t=>t.map(r=>{let l=s(r);return l!==r?l:r.children&&r.children.length>0?{...r,children:a(r.children)}:r});h(t=>t.map(r=>r.children?{...r,children:a(r.children)}:r))}else if(u){let s=Math.max(0,b.current-1);h(a=>{let t=[...a];if(s>=t.length)return a;let r={...t[s]},l=(r.children??[]).map(f=>f.index===e.index&&f.childId===void 0?{...f,status:e.status,duration:e.duration,phase:void 0,objective:f.objective.startsWith("Step ")?K(e.summary||f.objective):f.objective}:f);return r.children=l,t[s]=r,t})}else h(s=>s.map(a=>a.index===e.index?{...a,status:e.status,duration:e.duration,phase:void 0,objective:a.objective.startsWith("Step ")?K(e.summary||a.objective):a.objective}:a));{let a=S.current&&!S.current.isSingleFlow?Math.max(0,b.current-1):0,t=typeof e.ordinal=="number"&&e.id?{ordinal:e.ordinal,id:e.id}:void 0;i?.(e.index,a,e.child_id,t)}break}case"child_agent_start":{let d=e.objective??"",u=e.child_id;h(s=>{let a=j(s,t=>t.status==="running");return a?N(s,a,t=>({...t,objective:`${d} (branch)`,phase:`child: ${d.slice(0,50)}`,branchObjective:d,branchChildId:u})):s});break}case"child_agent_end":{let d=e.child_id,u=`child ${e.success?"done":"failed"}`;h(s=>{let a=j(s,t=>t.branchChildId===d);return a?N(s,a,t=>({...t,phase:u})):s.map(t=>t.phase?.startsWith("child:")?{...t,phase:u}:t)});break}case"describe_trigger":g?.(e);break;case"ask_user":T(e.question??"");break;case"run_end":h(d=>d.map(u=>u.status==="running"?{...u,status:e.status,phase:void 0}:u)),v(!1),B(e);break;case"error":v(!1),k(e.message??"Runner error"),h(d=>d.map(u=>u.status==="running"?{...u,status:"failed",phase:void 0}:u));break}}})().catch(e=>{if(y.current!==L)return;let u=[e instanceof Error?e.message:String(e)],s=L.stderr;s&&!u.join(`
5
+ `).includes(s)&&u.push(s),k(u.join(`
6
+ `)),v(!1),h(a=>a.map(t=>t.status==="running"?{...t,status:"failed",phase:void 0}:t)),P("runner","Runner died mid-run"),y.current=null,E.current=null,$(a=>a+1)});O.current=q,q.finally(()=>{O.current===q&&(O.current=null)})},[i,n,o,c,g]),xe=(0,p.useCallback)(m=>{y.current?.sendUserResponse(m),T(null)},[]),_e=(0,p.useCallback)(()=>{let m=y.current;m&&(m.cancel(),v(!1),T(null))},[]),be=(0,p.useCallback)(async()=>{let m=y.current;if(m){try{await Promise.race([m.shutdown(),new Promise(x=>setTimeout(x,5e3))])}catch{}P("runner","Runner shut down"),y.current=null,E.current=null,$(x=>x+1)}},[]),Ee=(0,p.useCallback)(()=>{h([]),B(null),k(null)},[]);return(0,p.useEffect)(()=>()=>{F.current=!0,P("runner","Component unmounted"),y.current=null,E.current=null},[]),{isRunning:w,steps:_,askingUser:pe,lastRunEnd:he,runError:fe,bifurcationInfo:me,cmInitCounts:ve,replayInfo:ge,maxSteps:Re,sessionGen:ye,startRun:we,sendAnswer:xe,cancelRun:_e,shutdownRunner:be,clearLastRun:Ee,getEvidenceState:()=>U.current}}export{D as a,le as b,ce as c,je as d,ze as e};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{d as j}from"./chunk-RKXHVP2Z.js";import{a as L}from"./chunk-RRY5IXOB.js";import{a as O}from"./chunk-5Y2G4NC7.js";import{a as D}from"./chunk-YCCUBQY4.js";import{y as l}from"./chunk-PHR2OSWD.js";import{a as E}from"./chunk-HCBYKLMW.js";import{a as g,b as s,i as I,k as B}from"./chunk-C44QQJR4.js";import{a as P}from"./chunk-6YGTRKDT.js";import{e as $}from"./chunk-UR6MHSHU.js";var H=$(P(),1);var w=$(E(),1),K=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function J(e){let t=e.replace(/…$/,"");return t&&t.charAt(0).toLowerCase()+t.slice(1)}function N(e,t){if(e.length<=t)return e;if(t<=1)return"\u2026";let r=Math.ceil((t-1)/2),n=Math.floor((t-1)/2);return`${e.slice(0,r)}\u2026${n>0?e.slice(-n):""}`}function Z({status:e,meta:t,tallies:r,keys:n,child:d,cols:c}){let{stdout:h}=B(),m=c??h?.columns??80,f=e.kind==="working"||e.kind==="child-working",[i,b]=(0,H.useState)(0);O(()=>b(a=>a+1),f?120:null);let k=K[i%K.length],u,p;switch(e.kind){case"working":u=`${k} ${e.step}${e.elapsedS!==void 0?` \xB7 ${e.elapsedS}s`:""}`,p=l.assuranceAccent;break;case"waiting":u=`\u25CF waiting on you${e.pending?` \u2014 ${e.pending} question${e.pending===1?"":"s"}`:""}`,p=l.amber;break;case"idle":u="\u25CF idle",p=l.assuranceAccent;break;case"card":u=`\u25CF card ${e.n} of ${e.m}`,p=l.amber;break;case"child-working":u=`${k} child: ${e.step}`,p=l.assuranceAccent;break;case"child-waiting":u="\u25CF child waiting on you",p=l.amber;break}let A=d?`${t.verb} \u25B8 ${d.verb}`:t.verb,S=d?.sid?t.sid?`${N(t.sid,14)} \u25B8 ${d.sid}`:d.sid:t.sid,C=t.env==="prod"?"":t.env,_=[A,S,C].filter(Boolean),v=" \xB7 ",R=u.length+v.length+_.join(v).length,T=t.subject;if(T){let a=m-R-v.length;T=a>=8?N(T,a):void 0}let M=[A,...T?[T]:[],S,C].filter(Boolean).join(v);return(0,w.jsxs)(g,{flexDirection:"column",children:[(0,w.jsx)(s,{color:l.muted,children:"\u2500".repeat(Math.max(1,m))}),(0,w.jsxs)(s,{children:[(0,w.jsx)(s,{color:p,children:u}),(0,w.jsx)(s,{color:l.dim,children:`${v}${M}`})]}),(0,w.jsx)(s,{color:l.dim,children:r.items.length>0?r.items.join(v):" "}),(0,w.jsx)(s,{color:l.muted,children:n.join(v)})]})}var y=$(P(),1);function ne({onToggleThinking:e,onCtrlC:t,explorer:r,panel:n}){let c=(0,y.useRef)(null),h=(0,y.useRef)(""),m=()=>{c.current&&clearTimeout(c.current),c.current=null,h.current=""};return(0,y.useEffect)(()=>m,[]),I((f,i)=>{if(i.ctrl&&f==="t"){e();return}if(i.ctrl&&f==="c"){t();return}if(!i.ctrl&&f.includes("")){t();return}if(!i.ctrl&&f.includes("")){e();return}if(r&&r.isOpen()){let b=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{m(),r.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return){m(),i.return?r.onEnter():r.onMove(i.upArrow?-1:1);return}if(h.current+=f,h.current==="["){b();return}let k=h.current;m();let u=/^\[([ABCD])/.exec(k);if(u){(u[1]==="A"||u[1]==="B")&&r.onMove(u[1]==="A"?-1:1);return}r.onBack();return}if(i.upArrow){r.onMove(-1);return}if(i.downArrow){r.onMove(1);return}if(i.return){r.onEnter();return}if(i.escape){h.current="",b();return}return}if(n&&n.isFocused()){let b=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{m(),n.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return||i.leftArrow||i.rightArrow){m(),i.return?n.onSelect():i.leftArrow?n.onLeft?.():i.rightArrow?n.onRight?.():n.onMove(i.upArrow?-1:1);return}if(h.current+=f,h.current==="["){b();return}let k=h.current;m();let u=/^\[([ABCD])/.exec(k);if(u){u[1]==="A"||u[1]==="B"?n.onMove(u[1]==="A"?-1:1):u[1]==="C"?n.onRight?.():n.onLeft?.();return}n.onBack();return}if(i.upArrow){n.onMove(-1);return}if(i.downArrow){n.onMove(1);return}if(i.leftArrow){n.onLeft?.();return}if(i.rightArrow){n.onRight?.();return}if(i.return){n.onSelect();return}if(i.escape){h.current="",b();return}if(/^[1-9]$/.test(f)){n.onDigit(Number(f));return}if(i.tab){n.onTab?.();return}if(f===" "&&n.isMulti()){n.onSpace();return}if(f&&!i.ctrl&&!i.meta){n.onType(f);return}return}}),null}var o=$(E(),1);function V(e){return e.kind==="REVIEW"?[{v:"approve",label:"approve",detail:"mark it reviewed and trusted"},{v:"archive",label:"archive",detail:"reject it \u2014 asks for a reason; impact shown above"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="PAIR"?[{v:"merge",label:"merge",detail:"duplicate \u2014 fold into the older item (it stays unreviewed)"},{v:"keep_both",label:"keep both",detail:"genuinely distinct \u2014 promote both"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="ARCHIVE"?[{v:"archive",label:"retire",detail:"hidden from now on; history is kept and it can be reverted"},{v:"skip",label:"skip",detail:"keep it \u2014 decided, never re-offered"},{v:"defer",label:"defer",detail:"not now \u2014 the plan re-offers it"}]:e.heldPayload?[{v:"approve",label:"approve update",detail:"commit the held payload \u2014 impact preview above"},{v:"skip",label:"keep current",detail:"drop the held payload (the owner's disk state stays untouched)"},{v:"defer",label:"defer",detail:"not now \u2014 stays held"}]:[{v:"approve",label:"approve",detail:e.kind==="ADD"?"commit + design it":"commit the updated version (old\u2192new redirect)"},{v:"skip",label:e.origin==="content-change"?"reject":"skip",detail:e.origin==="content-change"?"drop the staged proposal \u2014 nothing committed":"leave it as is"},{v:"defer",label:"defer",detail:"not now \u2014 the plan keeps it staged"}]}function F(e){let t=V(e);return e.viewDiff&&t.push({v:"view_diff",label:"view diff",detail:"full old \u2192 new"}),t}function W(e){return e.kind==="ARCHIVE"?null:F(e).length}var q={ADD:{color:l.green??"green"},MODIFY:{color:"yellow"},ARCHIVE:{color:l.red},REVIEW:{color:"cyan"},PAIR:{color:"magenta"}},Q=60;function ce({card:e,position:t,sel:r=0,focused:n=!1,freeText:d=null,editorIntent:c="steer"}){let{stdout:h}=B(),m=h?.columns??80,f=m<Q,i=F(e),b=W(e),k=q[e.kind],u=a=>n&&r===a?(0,o.jsx)(s,{color:l.assuranceAccent,children:"\u276F"}):" ",p=e.impact,A=p&&"stale_refs"in p&&p.stale_refs.length>0?`${e.kind==="ARCHIVE"?"retiring leaves":"approving marks"} ${p.stale_refs.length} item(s) stale`+((p.direct_refs?.length??0)>0?` \u2014 ${p.direct_refs.length} directly touched: ${p.direct_refs.join(", ")}`:""):p&&"design_children"in p?`${e.kind==="REVIEW"?"archiving drops":"merging folds"} ${p.design_children} design child(ren)`:null,S=e.provenance&&e.provenance!==e.why?e.provenance:e.origin??null,C=[{label:"why",text:e.why},...S?[{label:"from",text:S,dimmer:!0}]:[],...e.tier?[{label:"match",text:e.tier,dimmer:!0}]:[],...A?[{label:"impact",text:A}]:[]],_=Math.max(...C.map(a=>a.label.length)),v="? reconcile",R=`item ${t.n} of ${t.of}`,T=(0,o.jsxs)(g,{flexDirection:"column",children:[(0,o.jsx)(g,{paddingLeft:2,children:(0,o.jsxs)(s,{bold:!0,children:[(0,o.jsx)(s,{color:k.color,children:`[${e.kind}]`}),` ${L(e.title)}`]})}),C.map((a,x)=>(0,o.jsx)(g,{paddingLeft:2,children:(0,o.jsxs)(s,{children:[(0,o.jsx)(s,{color:l.dim,children:`${a.label.padEnd(_)} `}),(0,o.jsx)(s,{color:a.dimmer?l.dim:void 0,children:a.text})]})},`f-${x}`)),e.diffSummary?(0,o.jsx)(g,{paddingLeft:2,children:(0,o.jsx)(s,{color:l.dim,children:e.diffSummary})}):(e.diff??[]).map((a,x)=>(0,o.jsx)(g,{paddingLeft:4,children:(0,o.jsx)(s,{color:a.op==="-"?"red":"green",children:`${a.op==="-"?"\u2212":"+"} ${a.field==="criteria"?"criterion":a.field}: ${a.text}`})},`d-${x}`)),(e.citeLines??[]).map((a,x)=>(0,o.jsx)(g,{paddingLeft:2,children:(0,o.jsx)(s,{color:l.dim,children:a})},`c-${x}`)),(0,o.jsx)(s,{children:" "}),i.map((a,x)=>(0,o.jsxs)(s,{children:[u(x),` ${x+1}. ${a.label}`,(0,o.jsx)(s,{color:l.dim,children:` \u2014 ${a.detail}`})]},`o-${x}`)),b!==null||d&&c==="because"?d?(0,o.jsxs)(g,{flexDirection:"column",children:[(0,o.jsxs)(g,{children:[(0,o.jsxs)(s,{children:[(0,o.jsx)(s,{color:l.assuranceAccent,children:"\u276F"})," ",(0,o.jsx)(s,{color:l.dim,children:"\u270E "})]}),(0,o.jsx)(D,{value:d.value,onChange:d.onChange,onSubmit:d.onSubmit,onCancel:d.onCancel,placeholder:c==="because"?"why archive it?":"say what to adjust"})]}),(0,o.jsx)(s,{color:l.muted,children:c==="because"?" submits as: archive \xB7 your reason goes on the record":e.kind==="PAIR"?" submits as: defer \xB7 your note parks with the card (it re-offers)":" submits as: approve \xB7 your words steer the re-design"})]}):b!==null?(0,o.jsxs)(s,{children:[u(b)," ",(0,o.jsx)(s,{color:l.dim,children:e.kind==="PAIR"?"\u270E defer with a note \u2014 say what you noticed":"\u270E approve with changes \u2014 say what to adjust"})]}):null:null]});if(f)return(0,o.jsxs)(g,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,o.jsx)(s,{bold:!0,color:l.assuranceAccent,children:v}),(0,o.jsx)(s,{color:l.dim,children:R}),T]});let M=Math.max(2,Math.min(m-1,100)-v.length-R.length);return(0,o.jsxs)(g,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,o.jsxs)(s,{children:[(0,o.jsx)(s,{bold:!0,color:l.assuranceAccent,children:v})," ".repeat(M),(0,o.jsx)(s,{color:l.dim,children:R})]}),(0,o.jsx)(s,{children:" "}),T]})}var Y={"acceptance criteria":1,scenarios:2,"acceptance criteria + exercises":3,"tests + gaps":4};function ue(e,t){let r=[],n=j(e.turns).entries.length;if(t==="design"){let c;for(let m=e.ledger.length-1;m>=0;m--){let f=e.ledger[m];if(f.kind==="banner"&&f.text.startsWith("designing: ")){c=f.text.slice(11);break}}let h=c?Y[c]:void 0;h&&r.push(`phase ${h}/4`),n>0&&r.push(`${n} item${n===1?"":"s"} this session`)}else n>0&&r.push(`${n} saved as draft${n===1?"":"s"}`);let d=e.pending?e.pending.resolution.filter(c=>!c).length:0;return d>0&&r.push(`${d} question${d===1?"":"s"} pending`),e.credits&&r.push(`${e.credits.total.toFixed(1)} credits`),{items:r}}function fe(e,t){let r=[],n=e.applied+e.committed+e.retired;r.push(`${n} applied`),r.push(`${t} to decide`);let d=[];return e.skipped>0&&d.push(`${e.skipped} skipped`),e.deferred>0&&d.push(`${e.deferred} deferred`),e.failed>0&&d.push(`${e.failed} failed`),{items:[...r,...d]}}function he(e,t){let r=["\u2191\u2193 select","\u23CE confirm"];return e.multi_select&&r.push("space toggle"),t.batchCount>1&&r.push("\u2190 \u2192 questions"),(e.allow_free_text||e.options.some(n=>n.input===!0))&&r.push("\u270E type your own"),t.canAttach&&r.push("@ attach a file or URL"),t.escBack&&r.push("esc back"),{keys:r}}function ge(e,t){let r=["\u2191\u2193 select","\u23CE confirm"];return e.some(n=>n.free)&&r.push("\u270E type your own"),t.escBack&&r.push("esc back"),{keys:r}}function be(e){let t=["\u2191\u2193 select","\u23CE confirm","1-9 verdict"];return W(e)!==null&&t.push("type = adjust"),t.push("esc \xB7 nothing to undo"),{keys:t}}export{J as a,Z as b,ne as c,V as d,F as e,W as f,ce as g,ue as h,fe as i,he as j,ge as k,be as l};
2
+ import{d as j}from"./chunk-RKXHVP2Z.js";import{a as L}from"./chunk-RRY5IXOB.js";import{a as O}from"./chunk-5Y2G4NC7.js";import{a as D}from"./chunk-YCCUBQY4.js";import{y as l}from"./chunk-OWPQZP4C.js";import{a as E}from"./chunk-HCBYKLMW.js";import{a as g,b as s,i as I,k as B}from"./chunk-C44QQJR4.js";import{a as P}from"./chunk-6YGTRKDT.js";import{e as $}from"./chunk-UR6MHSHU.js";var H=$(P(),1);var w=$(E(),1),K=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function J(e){let t=e.replace(/…$/,"");return t&&t.charAt(0).toLowerCase()+t.slice(1)}function N(e,t){if(e.length<=t)return e;if(t<=1)return"\u2026";let r=Math.ceil((t-1)/2),n=Math.floor((t-1)/2);return`${e.slice(0,r)}\u2026${n>0?e.slice(-n):""}`}function Z({status:e,meta:t,tallies:r,keys:n,child:d,cols:c}){let{stdout:h}=B(),m=c??h?.columns??80,f=e.kind==="working"||e.kind==="child-working",[i,b]=(0,H.useState)(0);O(()=>b(a=>a+1),f?120:null);let k=K[i%K.length],u,p;switch(e.kind){case"working":u=`${k} ${e.step}${e.elapsedS!==void 0?` \xB7 ${e.elapsedS}s`:""}`,p=l.assuranceAccent;break;case"waiting":u=`\u25CF waiting on you${e.pending?` \u2014 ${e.pending} question${e.pending===1?"":"s"}`:""}`,p=l.amber;break;case"idle":u="\u25CF idle",p=l.assuranceAccent;break;case"card":u=`\u25CF card ${e.n} of ${e.m}`,p=l.amber;break;case"child-working":u=`${k} child: ${e.step}`,p=l.assuranceAccent;break;case"child-waiting":u="\u25CF child waiting on you",p=l.amber;break}let A=d?`${t.verb} \u25B8 ${d.verb}`:t.verb,S=d?.sid?t.sid?`${N(t.sid,14)} \u25B8 ${d.sid}`:d.sid:t.sid,C=t.env==="prod"?"":t.env,_=[A,S,C].filter(Boolean),v=" \xB7 ",R=u.length+v.length+_.join(v).length,T=t.subject;if(T){let a=m-R-v.length;T=a>=8?N(T,a):void 0}let M=[A,...T?[T]:[],S,C].filter(Boolean).join(v);return(0,w.jsxs)(g,{flexDirection:"column",children:[(0,w.jsx)(s,{color:l.muted,children:"\u2500".repeat(Math.max(1,m))}),(0,w.jsxs)(s,{children:[(0,w.jsx)(s,{color:p,children:u}),(0,w.jsx)(s,{color:l.dim,children:`${v}${M}`})]}),(0,w.jsx)(s,{color:l.dim,children:r.items.length>0?r.items.join(v):" "}),(0,w.jsx)(s,{color:l.muted,children:n.join(v)})]})}var y=$(P(),1);function ne({onToggleThinking:e,onCtrlC:t,explorer:r,panel:n}){let c=(0,y.useRef)(null),h=(0,y.useRef)(""),m=()=>{c.current&&clearTimeout(c.current),c.current=null,h.current=""};return(0,y.useEffect)(()=>m,[]),I((f,i)=>{if(i.ctrl&&f==="t"){e();return}if(i.ctrl&&f==="c"){t();return}if(!i.ctrl&&f.includes("")){t();return}if(!i.ctrl&&f.includes("")){e();return}if(r&&r.isOpen()){let b=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{m(),r.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return){m(),i.return?r.onEnter():r.onMove(i.upArrow?-1:1);return}if(h.current+=f,h.current==="["){b();return}let k=h.current;m();let u=/^\[([ABCD])/.exec(k);if(u){(u[1]==="A"||u[1]==="B")&&r.onMove(u[1]==="A"?-1:1);return}r.onBack();return}if(i.upArrow){r.onMove(-1);return}if(i.downArrow){r.onMove(1);return}if(i.return){r.onEnter();return}if(i.escape){h.current="",b();return}return}if(n&&n.isFocused()){let b=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{m(),n.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return||i.leftArrow||i.rightArrow){m(),i.return?n.onSelect():i.leftArrow?n.onLeft?.():i.rightArrow?n.onRight?.():n.onMove(i.upArrow?-1:1);return}if(h.current+=f,h.current==="["){b();return}let k=h.current;m();let u=/^\[([ABCD])/.exec(k);if(u){u[1]==="A"||u[1]==="B"?n.onMove(u[1]==="A"?-1:1):u[1]==="C"?n.onRight?.():n.onLeft?.();return}n.onBack();return}if(i.upArrow){n.onMove(-1);return}if(i.downArrow){n.onMove(1);return}if(i.leftArrow){n.onLeft?.();return}if(i.rightArrow){n.onRight?.();return}if(i.return){n.onSelect();return}if(i.escape){h.current="",b();return}if(/^[1-9]$/.test(f)){n.onDigit(Number(f));return}if(i.tab){n.onTab?.();return}if(f===" "&&n.isMulti()){n.onSpace();return}if(f&&!i.ctrl&&!i.meta){n.onType(f);return}return}}),null}var o=$(E(),1);function V(e){return e.kind==="REVIEW"?[{v:"approve",label:"approve",detail:"mark it reviewed and trusted"},{v:"archive",label:"archive",detail:"reject it \u2014 asks for a reason; impact shown above"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="PAIR"?[{v:"merge",label:"merge",detail:"duplicate \u2014 fold into the older item (it stays unreviewed)"},{v:"keep_both",label:"keep both",detail:"genuinely distinct \u2014 promote both"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="ARCHIVE"?[{v:"archive",label:"retire",detail:"hidden from now on; history is kept and it can be reverted"},{v:"skip",label:"skip",detail:"keep it \u2014 decided, never re-offered"},{v:"defer",label:"defer",detail:"not now \u2014 the plan re-offers it"}]:e.heldPayload?[{v:"approve",label:"approve update",detail:"commit the held payload \u2014 impact preview above"},{v:"skip",label:"keep current",detail:"drop the held payload (the owner's disk state stays untouched)"},{v:"defer",label:"defer",detail:"not now \u2014 stays held"}]:[{v:"approve",label:"approve",detail:e.kind==="ADD"?"commit + design it":"commit the updated version (old\u2192new redirect)"},{v:"skip",label:e.origin==="content-change"?"reject":"skip",detail:e.origin==="content-change"?"drop the staged proposal \u2014 nothing committed":"leave it as is"},{v:"defer",label:"defer",detail:"not now \u2014 the plan keeps it staged"}]}function F(e){let t=V(e);return e.viewDiff&&t.push({v:"view_diff",label:"view diff",detail:"full old \u2192 new"}),t}function W(e){return e.kind==="ARCHIVE"?null:F(e).length}var q={ADD:{color:l.green??"green"},MODIFY:{color:"yellow"},ARCHIVE:{color:l.red},REVIEW:{color:"cyan"},PAIR:{color:"magenta"}},Q=60;function ce({card:e,position:t,sel:r=0,focused:n=!1,freeText:d=null,editorIntent:c="steer"}){let{stdout:h}=B(),m=h?.columns??80,f=m<Q,i=F(e),b=W(e),k=q[e.kind],u=a=>n&&r===a?(0,o.jsx)(s,{color:l.assuranceAccent,children:"\u276F"}):" ",p=e.impact,A=p&&"stale_refs"in p&&p.stale_refs.length>0?`${e.kind==="ARCHIVE"?"retiring leaves":"approving marks"} ${p.stale_refs.length} item(s) stale`+((p.direct_refs?.length??0)>0?` \u2014 ${p.direct_refs.length} directly touched: ${p.direct_refs.join(", ")}`:""):p&&"design_children"in p?`${e.kind==="REVIEW"?"archiving drops":"merging folds"} ${p.design_children} design child(ren)`:null,S=e.provenance&&e.provenance!==e.why?e.provenance:e.origin??null,C=[{label:"why",text:e.why},...S?[{label:"from",text:S,dimmer:!0}]:[],...e.tier?[{label:"match",text:e.tier,dimmer:!0}]:[],...A?[{label:"impact",text:A}]:[]],_=Math.max(...C.map(a=>a.label.length)),v="? reconcile",R=`item ${t.n} of ${t.of}`,T=(0,o.jsxs)(g,{flexDirection:"column",children:[(0,o.jsx)(g,{paddingLeft:2,children:(0,o.jsxs)(s,{bold:!0,children:[(0,o.jsx)(s,{color:k.color,children:`[${e.kind}]`}),` ${L(e.title)}`]})}),C.map((a,x)=>(0,o.jsx)(g,{paddingLeft:2,children:(0,o.jsxs)(s,{children:[(0,o.jsx)(s,{color:l.dim,children:`${a.label.padEnd(_)} `}),(0,o.jsx)(s,{color:a.dimmer?l.dim:void 0,children:a.text})]})},`f-${x}`)),e.diffSummary?(0,o.jsx)(g,{paddingLeft:2,children:(0,o.jsx)(s,{color:l.dim,children:e.diffSummary})}):(e.diff??[]).map((a,x)=>(0,o.jsx)(g,{paddingLeft:4,children:(0,o.jsx)(s,{color:a.op==="-"?"red":"green",children:`${a.op==="-"?"\u2212":"+"} ${a.field==="criteria"?"criterion":a.field}: ${a.text}`})},`d-${x}`)),(e.citeLines??[]).map((a,x)=>(0,o.jsx)(g,{paddingLeft:2,children:(0,o.jsx)(s,{color:l.dim,children:a})},`c-${x}`)),(0,o.jsx)(s,{children:" "}),i.map((a,x)=>(0,o.jsxs)(s,{children:[u(x),` ${x+1}. ${a.label}`,(0,o.jsx)(s,{color:l.dim,children:` \u2014 ${a.detail}`})]},`o-${x}`)),b!==null||d&&c==="because"?d?(0,o.jsxs)(g,{flexDirection:"column",children:[(0,o.jsxs)(g,{children:[(0,o.jsxs)(s,{children:[(0,o.jsx)(s,{color:l.assuranceAccent,children:"\u276F"})," ",(0,o.jsx)(s,{color:l.dim,children:"\u270E "})]}),(0,o.jsx)(D,{value:d.value,onChange:d.onChange,onSubmit:d.onSubmit,onCancel:d.onCancel,placeholder:c==="because"?"why archive it?":"say what to adjust"})]}),(0,o.jsx)(s,{color:l.muted,children:c==="because"?" submits as: archive \xB7 your reason goes on the record":e.kind==="PAIR"?" submits as: defer \xB7 your note parks with the card (it re-offers)":" submits as: approve \xB7 your words steer the re-design"})]}):b!==null?(0,o.jsxs)(s,{children:[u(b)," ",(0,o.jsx)(s,{color:l.dim,children:e.kind==="PAIR"?"\u270E defer with a note \u2014 say what you noticed":"\u270E approve with changes \u2014 say what to adjust"})]}):null:null]});if(f)return(0,o.jsxs)(g,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,o.jsx)(s,{bold:!0,color:l.assuranceAccent,children:v}),(0,o.jsx)(s,{color:l.dim,children:R}),T]});let M=Math.max(2,Math.min(m-1,100)-v.length-R.length);return(0,o.jsxs)(g,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,o.jsxs)(s,{children:[(0,o.jsx)(s,{bold:!0,color:l.assuranceAccent,children:v})," ".repeat(M),(0,o.jsx)(s,{color:l.dim,children:R})]}),(0,o.jsx)(s,{children:" "}),T]})}var Y={"acceptance criteria":1,scenarios:2,"acceptance criteria + exercises":3,"tests + gaps":4};function ue(e,t){let r=[],n=j(e.turns).entries.length;if(t==="design"){let c;for(let m=e.ledger.length-1;m>=0;m--){let f=e.ledger[m];if(f.kind==="banner"&&f.text.startsWith("designing: ")){c=f.text.slice(11);break}}let h=c?Y[c]:void 0;h&&r.push(`phase ${h}/4`),n>0&&r.push(`${n} item${n===1?"":"s"} this session`)}else n>0&&r.push(`${n} saved as draft${n===1?"":"s"}`);let d=e.pending?e.pending.resolution.filter(c=>!c).length:0;return d>0&&r.push(`${d} question${d===1?"":"s"} pending`),e.credits&&r.push(`${e.credits.total.toFixed(1)} credits`),{items:r}}function fe(e,t){let r=[],n=e.applied+e.committed+e.retired;r.push(`${n} applied`),r.push(`${t} to decide`);let d=[];return e.skipped>0&&d.push(`${e.skipped} skipped`),e.deferred>0&&d.push(`${e.deferred} deferred`),e.failed>0&&d.push(`${e.failed} failed`),{items:[...r,...d]}}function he(e,t){let r=["\u2191\u2193 select","\u23CE confirm"];return e.multi_select&&r.push("space toggle"),t.batchCount>1&&r.push("\u2190 \u2192 questions"),(e.allow_free_text||e.options.some(n=>n.input===!0))&&r.push("\u270E type your own"),t.canAttach&&r.push("@ attach a file or URL"),t.escBack&&r.push("esc back"),{keys:r}}function ge(e,t){let r=["\u2191\u2193 select","\u23CE confirm"];return e.some(n=>n.free)&&r.push("\u270E type your own"),t.escBack&&r.push("esc back"),{keys:r}}function be(e){let t=["\u2191\u2193 select","\u23CE confirm","1-9 verdict"];return W(e)!==null&&t.push("type = adjust"),t.push("esc \xB7 nothing to undo"),{keys:t}}export{J as a,Z as b,ne as c,V as d,F as e,W as f,ce as g,ue as h,fe as i,he as j,ge as k,be as l};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{y as o}from"./chunk-PHR2OSWD.js";import{a as m}from"./chunk-HCBYKLMW.js";import{a as e,b as i}from"./chunk-C44QQJR4.js";import{e as d}from"./chunk-UR6MHSHU.js";var r=d(m(),1),s={default:o.muted,error:o.red,success:o.green,info:o.orange,warning:o.orange};function h({title:t,titleColor:a,borderColor:l,variant:n="default",children:c,width:u,paddingX:x=2,paddingY:g=0,marginBottom:f=0}){let p=l??s[n],B=a??(n==="default"?o.orange:s[n]);return(0,r.jsxs)(e,{flexDirection:"column",marginBottom:f,children:[t&&(0,r.jsx)(e,{marginBottom:0,children:(0,r.jsxs)(i,{color:B,bold:!0,children:[" ",t]})}),(0,r.jsx)(e,{borderStyle:"round",borderColor:p,flexDirection:"column",paddingX:x,paddingY:g,width:u,children:c})]})}function k({label:t,value:a,labelColor:l=o.dim,valueColor:n,labelWidth:c=14}){return(0,r.jsxs)(e,{children:[(0,r.jsx)(e,{width:c,flexShrink:0,children:(0,r.jsx)(i,{color:l,children:t})}),(0,r.jsx)(e,{flexShrink:1,children:(0,r.jsx)(i,{color:n,wrap:"wrap",children:a})})]})}function I({label:t}){return(0,r.jsx)(e,{marginTop:1,marginBottom:0,children:(0,r.jsx)(i,{bold:!0,children:t})})}export{h as a,k as b,I as c};
2
+ import{y as o}from"./chunk-OWPQZP4C.js";import{a as m}from"./chunk-HCBYKLMW.js";import{a as e,b as i}from"./chunk-C44QQJR4.js";import{e as d}from"./chunk-UR6MHSHU.js";var r=d(m(),1),s={default:o.muted,error:o.red,success:o.green,info:o.orange,warning:o.orange};function h({title:t,titleColor:a,borderColor:l,variant:n="default",children:c,width:u,paddingX:x=2,paddingY:g=0,marginBottom:f=0}){let p=l??s[n],B=a??(n==="default"?o.orange:s[n]);return(0,r.jsxs)(e,{flexDirection:"column",marginBottom:f,children:[t&&(0,r.jsx)(e,{marginBottom:0,children:(0,r.jsxs)(i,{color:B,bold:!0,children:[" ",t]})}),(0,r.jsx)(e,{borderStyle:"round",borderColor:p,flexDirection:"column",paddingX:x,paddingY:g,width:u,children:c})]})}function k({label:t,value:a,labelColor:l=o.dim,valueColor:n,labelWidth:c=14}){return(0,r.jsxs)(e,{children:[(0,r.jsx)(e,{width:c,flexShrink:0,children:(0,r.jsx)(i,{color:l,children:t})}),(0,r.jsx)(e,{flexShrink:1,children:(0,r.jsx)(i,{color:n,wrap:"wrap",children:a})})]})}function I({label:t}){return(0,r.jsx)(e,{marginTop:1,marginBottom:0,children:(0,r.jsx)(i,{bold:!0,children:t})})}export{h as a,k as b,I as c};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as g}from"./chunk-PHR2OSWD.js";import{readFileSync as o,writeFileSync as h,mkdirSync as u,readdirSync as a,unlinkSync as s,existsSync as l,chmodSync as f}from"fs";import{join as n,dirname as P}from"path";var d=class{baseDir;profilesDir;configFile;constructor(t=g){this.baseDir=t,this.profilesDir=n(t,"profiles"),this.configFile=n(t,"config.json")}readConfig(){try{return JSON.parse(o(this.configFile,"utf-8"))}catch{return{}}}writeConfig(t){u(this.baseDir,{recursive:!0,mode:448}),h(this.configFile,JSON.stringify(t,null,2)+`
2
+ import{b as g}from"./chunk-OWPQZP4C.js";import{readFileSync as o,writeFileSync as h,mkdirSync as u,readdirSync as a,unlinkSync as s,existsSync as l,chmodSync as f}from"fs";import{join as n,dirname as P}from"path";var d=class{baseDir;profilesDir;configFile;constructor(t=g){this.baseDir=t,this.profilesDir=n(t,"profiles"),this.configFile=n(t,"config.json")}readConfig(){try{return JSON.parse(o(this.configFile,"utf-8"))}catch{return{}}}writeConfig(t){u(this.baseDir,{recursive:!0,mode:448}),h(this.configFile,JSON.stringify(t,null,2)+`
3
3
  `),f(this.configFile,384)}getActiveProfile(){return this.readConfig().active_profile??null}setActiveProfile(t){let i=this.readConfig();i.active_profile=t,this.writeConfig(i)}getDefaultEnv(){return this.readConfig().default_env??"prod"}setDefaultEnv(t){let i=this.readConfig();i.default_env=t,this.writeConfig(i)}credentialsPath(t,i){return n(this.profilesDir,t,i,"credentials")}clientPath(t,i){return n(this.profilesDir,t,i,"client.json")}basicAuthPath(t,i){return n(this.profilesDir,t,i,"basic-auth")}profileConfigPath(t,i){return n(this.profilesDir,t,i,"profile-config.json")}saveProfileConfig(t,i,r){let e=this.loadProfileConfig(t,i)??{};this.writeSecure(this.profileConfigPath(t,i),{...e,...r})}loadProfileConfig(t,i){try{return JSON.parse(o(this.profileConfigPath(t,i),"utf-8"))}catch{return null}}writeSecure(t,i){try{u(P(t),{recursive:!0,mode:448}),h(t,JSON.stringify(i,null,2)+`
4
4
  `),f(t,384)}catch(r){let e=r instanceof Error?r.message:String(r);process.stderr.write(`[auth] Failed to save credentials: ${e}
5
5
  `)}}saveCredentials(t,i,r){this.writeSecure(this.credentialsPath(t,i),r)}loadCredentials(t,i){try{return JSON.parse(o(this.credentialsPath(t,i),"utf-8"))}catch{return null}}saveClient(t,i,r){this.writeSecure(this.clientPath(t,i),r)}loadClient(t,i){try{return JSON.parse(o(this.clientPath(t,i),"utf-8"))}catch{return null}}getActiveCredentials(){let t=this.getActiveProfile();if(!t)return{credentials:null,profile:null,env:null};let i=this.getDefaultEnv();return{credentials:this.loadCredentials(t,i),profile:t,env:i}}saveBasicAuth(t,i,r){this.writeSecure(this.basicAuthPath(t,i),r)}loadBasicAuth(t,i){try{return JSON.parse(o(this.basicAuthPath(t,i),"utf-8"))}catch{return null}}deleteBasicAuth(t,i){try{s(this.basicAuthPath(t,i))}catch{}}resolveAuth(){let t=this.getActiveProfile();if(!t)return null;let i=this.getDefaultEnv(),r=this.loadBasicAuth(t,i);return r?{method:"basic",...r,profile:t,env:i}:this.loadCredentials(t,i)?{method:"oauth",profile:t,env:i}:null}listProfiles(){let t=[];try{for(let i of a(this.profilesDir)){let r=n(this.profilesDir,i);try{for(let e of a(r)){let c=n(r,e),v=l(n(c,"credentials")),p=l(n(c,"client.json")),y=l(n(c,"basic-auth"));(v||p||y)&&t.push({profile:i,env:e})}}catch{}}}catch{}return t}deleteProfile(t,i){try{s(this.credentialsPath(t,i))}catch{}if(this.getActiveProfile()===t){let r=this.readConfig();delete r.active_profile,this.writeConfig(r)}}deleteProfileFull(t,i){if(i){try{s(this.credentialsPath(t,i))}catch{}try{s(this.clientPath(t,i))}catch{}try{s(this.basicAuthPath(t,i))}catch{}try{s(this.profileConfigPath(t,i))}catch{}}else try{let r=n(this.profilesDir,t);for(let e of a(r)){try{s(n(r,e,"credentials"))}catch{}try{s(n(r,e,"client.json"))}catch{}try{s(n(r,e,"basic-auth"))}catch{}try{s(n(r,e,"profile-config.json"))}catch{}}}catch{}}};export{d as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as t}from"./chunk-PHR2OSWD.js";import{join as i}from"path";function e(n=t){return i(n,"plugins")}function g(n,r=t){return i(e(r),n)}function c(n,r,o=t){return i(g(n,o),r)}function f(n,r=t){return i(g(n,r),"current")}function x(n,r=t){return i(g(n,r),"config.json")}function l(n,r=t){return i(g(n,r),".jobs")}function s(n=t){return i(n,"bin")}function h(n=t){return i(s(n),"hyperexecute")}export{e as a,g as b,c,f as d,x as e,l as f,s as g,h};
2
+ import{b as t}from"./chunk-OWPQZP4C.js";import{join as i}from"path";function e(n=t){return i(n,"plugins")}function g(n,r=t){return i(e(r),n)}function c(n,r,o=t){return i(g(n,o),r)}function f(n,r=t){return i(g(n,r),"current")}function x(n,r=t){return i(g(n,r),"config.json")}function l(n,r=t){return i(g(n,r),".jobs")}function s(n=t){return i(n,"bin")}function h(n=t){return i(s(n),"hyperexecute")}export{e as a,g as b,c,f as d,x as e,l as f,s as g,h};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{e as z}from"./chunk-EHN5HTUD.js";import{b as X,c as v,e as W,i as Y,j as Z,k as ee,l as te,m as E,o as ne}from"./chunk-L45HDSJ7.js";import{a as Q}from"./chunk-CAOZKSQ3.js";import{d as q}from"./chunk-PHR2OSWD.js";import{copyFileSync as Se,cpSync as Re,existsSync as P,mkdirSync as xe,readFileSync as qe,readdirSync as Ie,rmSync as ze,writeFileSync as Qe}from"fs";import{dirname as Xe,isAbsolute as Ye,join as R,relative as Ze,resolve as et}from"path";import{writeFileSync as we,mkdirSync as ve,readFileSync as Pe}from"fs";import{dirname as je,basename as se}from"path";function ie(e){let t=e.outPath??v(e.sourcePath);ve(je(t),{recursive:!0});let n=[];n.push("---"),n.push(`test: ../${se(e.sourcePath)}`),n.push(`status: ${e.overallStatus}`),n.push(`started: ${e.startedISO}`),n.push(`duration_s: ${e.durationS}`),n.push(`session_id: ${e.sessionId}`),n.push("---",""),n.push(`# ${e.title??se(e.sourcePath)} \u2014 Result`,"");for(let r=0;r<e.rootSteps.length;r++){let o=e.rootSteps[r],s=e.outcomes.find(l=>l.rootStepIndex===r+1);if(n.push(De(o,s)),s?.stepMd5&&n.push(`md5: ${s.stepMd5}`),s?.status==="failed"&&s.reason&&n.push(`Reason: ${s.reason}`),s?.softFailures?.length)for(let l of s.softFailures){let a=l.reason?`: ${l.reason}`:"";n.push(`\u26A0 optional sub-step ${l.subStepIndex} failed${a}`)}o.body.kind==="objective"&&s?.status!=="skipped"&&n.push(o.body.text),n.push("")}return we(t,n.join(`
2
+ import{e as z}from"./chunk-EHN5HTUD.js";import{b as X,c as v,e as W,i as Y,j as Z,k as ee,l as te,m as E,o as ne}from"./chunk-L45HDSJ7.js";import{a as Q}from"./chunk-CAOZKSQ3.js";import{d as q}from"./chunk-OWPQZP4C.js";import{copyFileSync as Se,cpSync as Re,existsSync as P,mkdirSync as xe,readFileSync as qe,readdirSync as Ie,rmSync as ze,writeFileSync as Qe}from"fs";import{dirname as Xe,isAbsolute as Ye,join as R,relative as Ze,resolve as et}from"path";import{writeFileSync as we,mkdirSync as ve,readFileSync as Pe}from"fs";import{dirname as je,basename as se}from"path";function ie(e){let t=e.outPath??v(e.sourcePath);ve(je(t),{recursive:!0});let n=[];n.push("---"),n.push(`test: ../${se(e.sourcePath)}`),n.push(`status: ${e.overallStatus}`),n.push(`started: ${e.startedISO}`),n.push(`duration_s: ${e.durationS}`),n.push(`session_id: ${e.sessionId}`),n.push("---",""),n.push(`# ${e.title??se(e.sourcePath)} \u2014 Result`,"");for(let r=0;r<e.rootSteps.length;r++){let o=e.rootSteps[r],s=e.outcomes.find(l=>l.rootStepIndex===r+1);if(n.push(De(o,s)),s?.stepMd5&&n.push(`md5: ${s.stepMd5}`),s?.status==="failed"&&s.reason&&n.push(`Reason: ${s.reason}`),s?.softFailures?.length)for(let l of s.softFailures){let a=l.reason?`: ${l.reason}`:"";n.push(`\u26A0 optional sub-step ${l.subStepIndex} failed${a}`)}o.body.kind==="objective"&&s?.status!=="skipped"&&n.push(o.body.text),n.push("")}return we(t,n.join(`
3
3
  `),"utf8"),t}function De(e,t){if(!t)return`## ${e.heading} (no outcome)`;let n=t.duration_s!=null?`${t.duration_s}s`:"\u2014";if(t.status==="skipped")return`## ${e.heading} \u23ED skipped`;let r=t.softFailed?" (optional)":"";if(t.refKind&&t.status==="passed"){let o=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2713 passed (via @${t.refKind} ${t.refLabel} \u2014 ${t.inlinedCount} inlined steps, ${n}${o})`}if(t.refKind&&t.status==="failed"){let o=t.failedSubStepIndex&&t.failedSubStepIndex.length>0?` \u2014 at sub-step ${t.failedSubStepIndex.join(" \u2192 sub-step ")}`:"",s=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2717 failed${r} (via @${t.refKind} ${t.refLabel}${o}, ${n}${s})`}return t.status==="passed"?`## ${e.heading} \u2713 passed (${n})`:`## ${e.heading} \u2717 failed${r} (${n})`}var $e=/^##\s+(.+?)\s+(✓ passed|✗ failed(?:\s+\(optional\))?|⏭ skipped)(?:\s+\((.*)\))?\s*$/,Fe=/via\s+@\w+\s+(\S+).*?(?:→\s+(\S+))?\s*$/,Oe=/^md5:\s+([a-f0-9]{32})\s*$/;function re(e,t){for(let n=t;n<e.length&&!/^##\s/.test(e[n]);n++){if(e[n].trim()==="")continue;let r=Oe.exec(e[n]);return r?r[1]:null}return null}function D(e){let n=Pe(e,"utf8").split(`
4
4
  `),r="passed";if(n[0]?.trim()==="---")for(let s=1;s<n.length&&n[s].trim()!=="---";s++){let l=/^status:\s+(passed|failed|interrupted)\s*$/.exec(n[s]);l&&(r=l[1])}let o=[];for(let s=0;s<n.length;s++){let l=$e.exec(n[s]);if(!l)continue;let a=l[1],i=l[2],c=l[3]??"",f=i.startsWith("\u2713")?"passed":i.startsWith("\u23ED")?"skipped":"failed";if(/via\s+@/.test(c)){let m=Fe.exec(c),w=m?.[1]??"",x=m?.[2]??null;o.push({kind:"import",heading:a,status:f,md5:re(n,s+1),importPath:w,helperResultRelPath:x})}else o.push({kind:"objective",heading:a,status:f,md5:re(n,s+1)})}return{overallStatus:r,steps:o}}import{copyFileSync as oe,existsSync as H,mkdirSync as _e,writeFileSync as ae,promises as at}from"fs";import{join as $,dirname as de,basename as Ae}from"path";async function pe(e){for(let t=0;t<e.totalRunDirs;t++){let n=e.runIndex+t,r=$(e.sessionDir,"runs",String(n)),o=$(e.stagingStepDir,"flows",String(t));_e(o,{recursive:!0});let s=$(o,"actions.ndjson");if(e.packTestDir){let i=$(e.packTestDir,"logs",`${n}-actions.ndjson`);if(H(i)){oe(i,s);continue}let c=de(de(e.packTestDir)),f=Ae(e.packTestDir),S=H(c)?await z(c,`tests/${f}/logs/${n}-actions.ndjson`).catch(()=>null):null;ae(s,S??"");continue}let l=[$(r,"run-test","actions.ndjson"),$(r,"actions.ndjson")],a=!1;for(let i of l)if(H(i)){oe(i,s),a=!0;break}a||ae(s,"")}}import{existsSync as ue,readFileSync as ce,readdirSync as Ke}from"fs";import{join as F}from"path";function Te(e){if(e.action_type!=="upload_files")return null;let t=e.action_params?.media;if(!t||typeof t!="object")return null;let n=typeof t.media_id=="string"?t.media_id:"",r=typeof t.name=="string"?t.name:"",o=typeof t.media_url=="string"?t.media_url:"";if(!n||!r||!o)return null;let s=typeof t.type=="string"&&t.type?t.type:"doc";return{media_id:n,name:r,media_url:o,type:s}}function Ee(e){let t=e.action_params?.file_paths,n=Array.isArray(t)?t[0]:t;return typeof n=="string"&&n.length>0?n:null}function Le(e){let t={};for(let[n,r]of Object.entries(e??{}))t[n]={...r,refs:[...r.refs??[]]};return t}function Ue(e,t){if(!t)return!1;let n=t.endsWith("/")?t:t+"/";return e.startsWith(n)}function le(e,t,n,r={}){let o=Le(e);for(let s of t){let l=Te(s);if(!l)continue;let a=o[l.media_id]??={name:l.name,media_url:l.media_url,type:l.type,refs:[],recorded_at:n};a.recorded_at=n;let i=Ee(s);if(!(!i||Ue(i,r.ignoreAliasUnder))){for(let[c,f]of Object.entries(o))c!==l.media_id&&(f.refs=f.refs.filter(S=>S!==i));a.refs.includes(i)||a.refs.push(i)}}return o}function ut(e){let t=e?.media;if(!t||typeof t!="object")return[];let n=[];for(let[r,o]of Object.entries(t)){if(!r||!o||typeof o!="object")continue;let s=o;typeof s.name!="string"||!s.name||typeof s.media_url!="string"||!s.media_url||n.push({media_id:r,name:s.name,media_url:s.media_url,type:typeof s.type=="string"&&s.type?s.type:"doc",refs:Array.isArray(s.refs)?s.refs.filter(l=>typeof l=="string"&&l.length>0):[]})}return n}function Ne(e){let t=[];for(let n of e){let r;try{r=ce(n,"utf8")}catch{continue}for(let o of r.split(`
5
5
  `)){let s=o.trim();if(s)try{let l=JSON.parse(s);l&&typeof l=="object"&&t.push(l)}catch{}}}return t}function V(e){try{return Ke(e,{withFileTypes:!0}).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,n)=>t.localeCompare(n,void 0,{numeric:!0}))}catch{return[]}}function yt(e){if(!e)return[];let t=[];for(let n of V(F(e,"runs")))for(let r of[F(e,"runs",n,"run-test","actions.ndjson"),F(e,"runs",n,"actions.ndjson")])if(ue(r)){t.push(r);break}return t}function fe(e){let t=[],n=F(e,".internal","steps");for(let r of V(n)){let o=F(n,r,"flows");for(let s of V(o)){let l=F(o,s,"actions.ndjson");ue(l)&&t.push(l)}}return t}function Ce(e){try{let n=JSON.parse(ce(e,"utf8"))?.media;return n&&typeof n=="object"?n:void 0}catch{return}}function me(e){let t=Ce(e.priorMetaPath),n=Ne(e.recordFiles),r=le(t,n,e.now??new Date().toISOString(),{ignoreAliasUnder:e.ignoreAliasUnder??q});return Object.keys(r).length>0?r:void 0}import{existsSync as L,readdirSync as We}from"fs";import{dirname as He,join as O,basename as B}from"path";function Mt(e,t){let n=[];return e.steps.forEach((r,o)=>{let s=t[o];r.block||!r.replayOnly||!s||s.kind!=="author"||n.push({flatIndex:r.flatIndex,file:r.owningFile,heading:r.trace[r.trace.length-1].heading,kind:r.replayOnly,reason:s.reason})}),n}function wt(e){let t=[],n=new Set,r=new Map;function o(i){if(r.has(i))return r.get(i);let c=v(i),f=L(c)?D(c):null;return r.set(i,f),f}let s=new Map;function l(i){if(s.has(i))return s.get(i);let c=O(i,"Result.md"),f=L(c)?D(c):null;return s.set(i,f),f}function a(i){for(let c=1;c<i.trace.length;c++){let f=i.trace[c-1],S=o(f.file);if(!S)continue;let m=S.steps[f.stepIndex-1];if(m){if(m.kind!=="import")return{kind:"author",reason:"structure-mismatch"};if(B(m.importPath)!==B(i.trace[c].file))return{kind:"author",reason:"structure-mismatch"};if(m.md5!=null&&m.md5!==f.rowMd5)return{kind:"author",reason:"structure-mismatch"}}}return null}for(let i of e.steps){let c=i.trace[i.trace.length-1].stepIndex,f=i.replayOnly;if(i.block){let g=o(i.owningFile)?.steps[c-1],j=i.controlFlow!==void 0,A=g?.kind==="objective"&&g.status==="skipped";if(j||A){t.push({kind:"replay",recordingDir:"",flowCount:0,unrecorded:!0,...f?{replayOnly:f}:{}});continue}}let S=n.has(i.owningFile);for(let g=0;g<i.trace.length-1&&!S;g++)n.has(i.trace[g].file)&&(S=!0);if(S&&!f){t.push({kind:"author",reason:o(i.owningFile)===null?"no-result-md":"downstream-of-divergence"});continue}let m=a(i);if(m){for(let g=0;g<i.trace.length;g++)n.add(i.trace[g].file);if(!f){t.push(m);continue}}let w=o(i.owningFile),x;if(w===null&&i.trace.length>1){let g=J(i.trace);x=ge(i,l(g),c,g)}else x=ge(i,w,c);if(f&&x.kind==="replay"&&(x={...x,replayOnly:f}),t.push(x),x.kind==="author"){n.add(i.owningFile);for(let g=0;g<i.trace.length-1;g++)n.add(i.trace[g].file)}}return t}function ge(e,t,n,r=null){if(!t)return{kind:"author",reason:"no-result-md"};let o=t.steps[n-1];if(!o)return{kind:"author",reason:"no-result-md"};if(o.kind!=="objective")return{kind:"author",reason:"structure-mismatch"};if(o.status!=="passed")return{kind:"author",reason:"recorded-failed"};let s=E(e);if(s!==o.md5)return{kind:"author",reason:"md5-mismatch"};let l=r===null?ee(e.owningFile,n,s.slice(0,8)):O(r,".internal","steps",`${n}-${s.slice(0,8)}`),a=Ve(l);return a===0?{kind:"author",reason:"missing-recording"}:{kind:"replay",recordingDir:l,flowCount:a}}function Ve(e){let t=O(e,"flows");if(!L(t))return 0;let n;try{n=We(t,{withFileTypes:!0}).filter(o=>o.isDirectory()&&/^\d+$/.test(o.name)).map(o=>parseInt(o.name,10))}catch{return 0}if(n.length===0)return 0;let r=Math.max(...n);for(let o=0;o<=r;o++)if(!L(O(t,String(o),"actions.ndjson")))return 0;return r+1}function vt(e){return e.some(t=>t.kind==="author")}function Pt(e){for(let t=0;t<e.length;t++)if(e[t].kind==="author")return t;return e.length}function J(e){let t=s=>{let l=B(s);return l.endsWith("_test.md")?l.slice(0,-8):l.endsWith(".md")?l.slice(0,-3):l},n=t(e[0].file),r=t(e[e.length-1].file),o=e.slice(0,-1).map(s=>String(s.stepIndex));return O(He(e[e.length-1].file),`helper-output-${r}-${n}-${o.join("-")}`)}function jt(e){return Array.from({length:e.flowCount},(t,n)=>O(e.recordingDir,"flows",String(n),"actions.ndjson"))}import{existsSync as he,mkdirSync as Be,rmSync as Je,cpSync as Ge}from"fs";function ye(e,t){he(e)&&(he(t)&&Je(t,{recursive:!0,force:!0}),Be(t,{recursive:!0}),Ge(e,t,{recursive:!0}))}async function Ht(e){let t=new Map;for(let a of e.stepRunRecords)t.set(a.testmdStepIndex,a);let n=e.authoredFlatIdx??new Set,r=[],o=[],s=new Map,l=a=>{if(s.has(a))return s.get(a);let i=R(a,"Result.md"),c=P(i)?D(i):null;return s.set(a,c),c};for(let a of e.resolvedTest.unitFiles){let i=a.file===e.resolvedTest.rootPath,c=Q(a.file,qe(a.file,"utf8")),f=v(a.file),S=P(f)?D(f):null,m=[],w=[],x=[],g=[];if(!i)for(let p of e.resolvedTest.steps){if(p.owningFile!==a.file||p.trace.length<2)continue;let d=J(p.trace);g.includes(d)||g.push(d)}let j=p=>{if(S!==null)return null;for(let d of g){let M=l(d)?.steps[p-1];if(M)return{row:M,dir:d}}return null},A=[],U=!1,G=!1,K=!1,N=!1;for(let p of c.steps){let d=p.index,u=S?.steps[d-1];if(p.body.kind==="objective"){let h=e.resolvedTest.steps.filter(y=>y.owningFile===a.file&&y.trace[y.trace.length-1].stepIndex===d&&t.has(y.flatIndex)),I=h.length>0?h[h.length-1]:null;if(I){U=!0,n.has(I.flatIndex)&&(G=!0);let y=E(I),k;i?k=e.outcomes.find(Me=>Me.rootStepIndex===d)??{rootStepIndex:d,status:"skipped"}:k={rootStepIndex:d,status:ke(I,e.outcomes)},k.status==="failed"&&(K=!0),k.stepMd5==null&&(k.stepMd5=y),m.push(k),w.push({stepIndex:d,md5:y,rec:t.get(I.flatIndex)}),(!u||u.kind!=="objective"||u.status!==k.status||k.status==="passed"&&u.md5!==y)&&(N=!0)}else if(u&&u.kind==="objective")m.push({rootStepIndex:d,status:u.status,...u.md5?{stepMd5:u.md5}:{}}),x.push(d);else if(!i&&j(d)?.row.kind==="objective"){let y=j(d),k=y.row;m.push({rootStepIndex:d,status:k.status,...k.md5?{stepMd5:k.md5}:{}}),A.push({psIdx:d,dir:y.dir})}else i?m.push(e.outcomes.find(y=>y.rootStepIndex===d)??{rootStepIndex:d,status:"skipped"}):m.push({rootStepIndex:d,status:"skipped"});continue}let M=Ye(p.body.path)?p.body.path:et(Xe(a.file),p.body.path),T=te({path:p.body.path,bindings:p.body.bindings,optional:p.optional??!1}),C=Ze(X(a.file),v(M)),_=e.resolvedTest.steps.filter(h=>h.trace.some((I,y)=>y<h.trace.length-1&&I.file===a.file&&I.stepIndex===d)&&t.has(h.flatIndex));if(_.length>0){U=!0;let h;if(i)h=e.outcomes.find(I=>I.rootStepIndex===d)??{rootStepIndex:d,status:"passed",refKind:"import",refLabel:p.body.path};else{let I=_.some(y=>ke(y,e.outcomes)==="failed");h={rootStepIndex:d,status:I?"failed":"passed",refKind:"import",refLabel:p.body.path,inlinedCount:_.length}}h.status==="failed"&&(K=!0),h.stepMd5==null&&(h.stepMd5=T),h.helperResultRelPath==null&&(h.helperResultRelPath=C),m.push(h),(!u||u.kind!=="import"||u.status!==h.status||u.md5!==T)&&(N=!0)}else if(u&&u.kind==="import")m.push({rootStepIndex:d,status:u.status,refKind:"import",refLabel:u.importPath,...u.md5?{stepMd5:u.md5}:{},...u.helperResultRelPath?{helperResultRelPath:u.helperResultRelPath}:{}});else if(!i&&j(d)?.row.kind==="import"){let h=j(d).row;m.push({rootStepIndex:d,status:h.status,refKind:"import",refLabel:p.body.path})}else i?m.push(e.outcomes.find(h=>h.rootStepIndex===d)??{rootStepIndex:d,status:"skipped",refKind:"import",refLabel:p.body.path}):m.push({rootStepIndex:d,status:"skipped",refKind:"import",refLabel:p.body.path})}if(!(i||U&&(G||K||S===null||N)))continue;r.push(a.file);let b=Y(a.file);xe(R(b,".internal"),{recursive:!0});for(let p of w){let d=R(b,".internal","steps",`${p.stepIndex}-${p.md5.slice(0,8)}`);xe(d,{recursive:!0}),await pe({sessionDir:e.sessionDir,runIndex:p.rec.runIndex,totalRunDirs:p.rec.totalRunDirs,stagingStepDir:d,packTestDir:e.packTestDir})}if(x.length>0){let p=Z(a.file);if(P(p))for(let d of Ie(p)){let u=parseInt(d.split("-")[0]??"",10);!Number.isNaN(u)&&x.includes(u)&&Re(R(p,d),R(b,".internal","steps",d),{recursive:!0})}}for(let p of A){let d=R(p.dir,".internal","steps");if(P(d))for(let u of Ie(d))parseInt(u.split("-")[0]??"",10)===p.psIdx&&Re(R(d,u),R(b,".internal","steps",u),{recursive:!0})}let be=m.some(p=>p.status==="failed");if(ie({sourcePath:a.file,title:c.title,rootSteps:c.steps,outcomes:m,overallStatus:i?e.overallStatus:be?"failed":"passed",startedISO:e.startedISO,durationS:i?e.durationS:0,sessionId:e.sessionId,outPath:R(b,"Result.md")}),i){let p={};e.commitId&&(p.commit_id=e.commitId),e.tmsIds.testId&&(p.test_id=e.tmsIds.testId),e.tmsIds.testcaseId&&(p.testcase_id=e.tmsIds.testcaseId),e.tmsIds.projectId&&(p.project_id=e.tmsIds.projectId),e.tmsIds.folderId&&(p.folder_id=e.tmsIds.folderId),e.tmsIds.orgId&&(p.org_id=e.tmsIds.orgId),e.tmsIds.sessionName&&(p.session_name=e.tmsIds.sessionName);let d=me({priorMetaPath:W(a.file),recordFiles:fe(b)});d&&(p.media=d);let u=ne(a.file);u&&(p.tc_id=u),Qe(R(b,".internal","meta.json"),JSON.stringify(p,null,2)+`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as S}from"./chunk-RBFCGUR3.js";import{y as o}from"./chunk-PHR2OSWD.js";import{a as R}from"./chunk-HCBYKLMW.js";import{a as y,b as c,j as x}from"./chunk-C44QQJR4.js";import{a as w}from"./chunk-6YGTRKDT.js";import{e as b}from"./chunk-UR6MHSHU.js";var k=b(w(),1);var i=b(R(),1);function A(e){let t=e.decisions.filter(l=>l.kind==="replay").length,s=e.decisions.filter(l=>l.kind==="author").length,d=e.outcomes.filter(l=>l.status==="passed").length,f=e.outcomes.filter(l=>l.status==="failed").length,h=e.outcomes.filter(l=>l.status==="skipped").length,a=o.green,u;e.cancelled||e.overallStatus==="interrupted"?(a=o.orange,u="CANCELLED"):e.overallStatus==="failed"?(a=o.red,u="FAILED"):u="PASSED";let r=`${u} \xB7 ${e.durationS}s \xB7 ${e.outcomes.length} steps (${d} passed, ${f} failed, ${h} skipped)`,T=`${t} replay \xB7 ${s} author`,C=e.retryTriggered,_="yes \u2014 healed after a replay miss",n,p=o.dim;if(e.cancelled)n="\u2013 not committed (cancellation)";else if(e.overallStatus==="failed")n="\u2013 not committed (run failed)",p=o.red;else if(!e.shouldCommit)e.isFirstRun?n="\u2013 not committed (first run skipped commit)":e.lockHeld?n="\u2013 not committed":n="\u2013 not committed (readonly fallback / no lock)";else if(e.committed===!1&&!e.uploadResult?.testcaseId)n="\u2013 not committed (commit did not land)",p=o.red;else{let l=e.uploadResult?.testcaseId;n=l?`\u2713 pushed (testcase=${l})`:"\u2713 pushed",p=o.green}let v=e.shouldReplaceLocalOutput?"output dir replaced":e.anyAuthorStepRan?"untouched (cancellation or no replace)":"untouched (replay-only)",m,g=o.dim;return e.shouldUploadArtifacts?e.uploadResult?.success?(m="\u2713 TMS",g=o.green):e.uploadResult?(m=`\u2717 failed${e.uploadResult.error?`: ${e.uploadResult.error}`:""}`,g=o.red):m="\u2013 not run":m="\u2013 skipped (--local or no auth)",{resultLine:{color:a,text:r},breakdown:T,showRetries:C,retriesText:_,commitText:n,commitColor:p,artifactsText:v,uploadText:m,uploadColor:g}}function I(e){let t=e.decisions.filter(r=>r.kind==="replay").length,s=e.decisions.filter(r=>r.kind==="author").length,d=e.outcomes.filter(r=>r.status==="passed").length,f=e.outcomes.filter(r=>r.status==="failed").length,h=e.outcomes.filter(r=>r.status==="skipped").length,a,u=!1;return e.cancelled?a="cancellation":e.overallStatus==="failed"?a="run_failed":e.shouldCommit&&(e.committed===!0||e.uploadResult?.testcaseId)?(a="ok",u=!0):!e.shouldCommit&&!e.lockHeld&&!e.isFirstRun?a="readonly_fallback":a="not_committed",{type:"test_md_summary",overall_status:e.overallStatus,duration_s:e.durationS,steps:{total:e.outcomes.length,passed:d,failed:f,skipped:h,replay_decisions:t,author_decisions:s},adaptive_heal:{triggered:e.retryTriggered},commit:{committed:u,reason:a,...e.uploadResult?.testcaseId?{testcase_id:e.uploadResult.testcaseId}:{}},artifacts:{replaced:e.shouldReplaceLocalOutput},upload:{performed:e.shouldUploadArtifacts,...e.uploadResult?{succeeded:!!e.uploadResult.success}:{}},...e.shareUrl?{share_url:e.shareUrl}:{},cancelled:e.cancelled,...e.imports&&e.imports.length>0?{imports:e.imports}:{}}}function D({data:e}){let t=A(e),s=[{label:"result",value:(0,i.jsx)(c,{color:t.resultLine.color,bold:!0,children:t.resultLine.text})},{label:"breakdown",value:(0,i.jsx)(c,{color:o.dim,children:t.breakdown})}];return t.showRetries&&s.push({label:"adaptive heal",value:(0,i.jsx)(c,{color:o.orange,children:t.retriesText})}),s.push({label:"commit",value:(0,i.jsx)(c,{color:t.commitColor,children:t.commitText})}),s.push({label:"artifacts",value:(0,i.jsx)(c,{color:o.dim,children:t.artifactsText})}),s.push({label:"upload",value:(0,i.jsx)(c,{color:t.uploadColor,children:t.uploadText})}),(0,i.jsx)(S,{title:"Run summary",titleColor:"#ff9500",rows:s})}function O({data:e}){let{exit:t}=x();return(0,k.useEffect)(()=>{let s=setTimeout(()=>t(),50);return()=>clearTimeout(s)},[t]),(0,i.jsx)(y,{flexDirection:"column",children:(0,i.jsx)(D,{data:e})})}export{A as a,I as b,D as c,O as d};
2
+ import{a as S}from"./chunk-YV6CSSWA.js";import{y as o}from"./chunk-OWPQZP4C.js";import{a as R}from"./chunk-HCBYKLMW.js";import{a as y,b as c,j as x}from"./chunk-C44QQJR4.js";import{a as w}from"./chunk-6YGTRKDT.js";import{e as b}from"./chunk-UR6MHSHU.js";var k=b(w(),1);var i=b(R(),1);function A(e){let t=e.decisions.filter(l=>l.kind==="replay").length,s=e.decisions.filter(l=>l.kind==="author").length,d=e.outcomes.filter(l=>l.status==="passed").length,f=e.outcomes.filter(l=>l.status==="failed").length,h=e.outcomes.filter(l=>l.status==="skipped").length,a=o.green,u;e.cancelled||e.overallStatus==="interrupted"?(a=o.orange,u="CANCELLED"):e.overallStatus==="failed"?(a=o.red,u="FAILED"):u="PASSED";let r=`${u} \xB7 ${e.durationS}s \xB7 ${e.outcomes.length} steps (${d} passed, ${f} failed, ${h} skipped)`,T=`${t} replay \xB7 ${s} author`,C=e.retryTriggered,_="yes \u2014 healed after a replay miss",n,p=o.dim;if(e.cancelled)n="\u2013 not committed (cancellation)";else if(e.overallStatus==="failed")n="\u2013 not committed (run failed)",p=o.red;else if(!e.shouldCommit)e.isFirstRun?n="\u2013 not committed (first run skipped commit)":e.lockHeld?n="\u2013 not committed":n="\u2013 not committed (readonly fallback / no lock)";else if(e.committed===!1&&!e.uploadResult?.testcaseId)n="\u2013 not committed (commit did not land)",p=o.red;else{let l=e.uploadResult?.testcaseId;n=l?`\u2713 pushed (testcase=${l})`:"\u2713 pushed",p=o.green}let v=e.shouldReplaceLocalOutput?"output dir replaced":e.anyAuthorStepRan?"untouched (cancellation or no replace)":"untouched (replay-only)",m,g=o.dim;return e.shouldUploadArtifacts?e.uploadResult?.success?(m="\u2713 TMS",g=o.green):e.uploadResult?(m=`\u2717 failed${e.uploadResult.error?`: ${e.uploadResult.error}`:""}`,g=o.red):m="\u2013 not run":m="\u2013 skipped (--local or no auth)",{resultLine:{color:a,text:r},breakdown:T,showRetries:C,retriesText:_,commitText:n,commitColor:p,artifactsText:v,uploadText:m,uploadColor:g}}function I(e){let t=e.decisions.filter(r=>r.kind==="replay").length,s=e.decisions.filter(r=>r.kind==="author").length,d=e.outcomes.filter(r=>r.status==="passed").length,f=e.outcomes.filter(r=>r.status==="failed").length,h=e.outcomes.filter(r=>r.status==="skipped").length,a,u=!1;return e.cancelled?a="cancellation":e.overallStatus==="failed"?a="run_failed":e.shouldCommit&&(e.committed===!0||e.uploadResult?.testcaseId)?(a="ok",u=!0):!e.shouldCommit&&!e.lockHeld&&!e.isFirstRun?a="readonly_fallback":a="not_committed",{type:"test_md_summary",overall_status:e.overallStatus,duration_s:e.durationS,steps:{total:e.outcomes.length,passed:d,failed:f,skipped:h,replay_decisions:t,author_decisions:s},adaptive_heal:{triggered:e.retryTriggered},commit:{committed:u,reason:a,...e.uploadResult?.testcaseId?{testcase_id:e.uploadResult.testcaseId}:{}},artifacts:{replaced:e.shouldReplaceLocalOutput},upload:{performed:e.shouldUploadArtifacts,...e.uploadResult?{succeeded:!!e.uploadResult.success}:{}},...e.shareUrl?{share_url:e.shareUrl}:{},cancelled:e.cancelled,...e.imports&&e.imports.length>0?{imports:e.imports}:{}}}function D({data:e}){let t=A(e),s=[{label:"result",value:(0,i.jsx)(c,{color:t.resultLine.color,bold:!0,children:t.resultLine.text})},{label:"breakdown",value:(0,i.jsx)(c,{color:o.dim,children:t.breakdown})}];return t.showRetries&&s.push({label:"adaptive heal",value:(0,i.jsx)(c,{color:o.orange,children:t.retriesText})}),s.push({label:"commit",value:(0,i.jsx)(c,{color:t.commitColor,children:t.commitText})}),s.push({label:"artifacts",value:(0,i.jsx)(c,{color:o.dim,children:t.artifactsText})}),s.push({label:"upload",value:(0,i.jsx)(c,{color:t.uploadColor,children:t.uploadText})}),(0,i.jsx)(S,{title:"Run summary",titleColor:"#ff9500",rows:s})}function O({data:e}){let{exit:t}=x();return(0,k.useEffect)(()=>{let s=setTimeout(()=>t(),50);return()=>clearTimeout(s)},[t]),(0,i.jsx)(y,{flexDirection:"column",children:(0,i.jsx)(D,{data:e})})}export{A as a,I as b,D as c,O as d};
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as m,c}from"./chunk-EYOCNMUM.js";import{c as b,j as h}from"./chunk-PHR2OSWD.js";import{readFileSync as w,writeFileSync as y,mkdirSync as C,existsSync as k}from"fs";import{dirname as x}from"path";var f={window_size:{width:1920,height:1080},chrome_profile_path:"",default_url:h,model:"v16-alpha",project_id:null,project_name:null,folder_id:null,folder_name:null,mode:"testing",assertion_mode:"dom",network_ws:!1,network_sse:!1,bug_detection:"off",final_validation:!1,code_export:{enabled:!0,language:"python",skip_validation:!0},generate:{scenario_limit:2,per_scenario_limit:3,memory_enabled:!1},last_seen_version:"",hints_enabled:!0};function T(o){let{mobile:e,...i}=o,t={...i};delete t.target,delete t.device,delete t.device_name,delete t.os_version,delete t.app;let n=e??{};n.tui_target&&(t.target=n.tui_target);let s=n.default_target?.name?.trim(),l=n.default_target?.os_version?.trim();if(s||l)s&&(t.device_name=s),l&&(t.os_version=l);else{let r=n.default_target?.id?.trim();r&&(t.device=r)}n.default_app&&(t.app=n.default_app);let a={};return n.no_reset!==void 0&&(a.no_reset=n.no_reset),n.appium_url!==void 0&&(a.appium_url=n.appium_url),n.auto_grant_permissions!==void 0&&(a.auto_grant_permissions=n.auto_grant_permissions),n.auto_accept_alerts!==void 0&&(a.auto_accept_alerts=n.auto_accept_alerts),Object.keys(a).length>0&&(t.mobile=a),t}function S(o){let e=o.mobile??{},i=typeof o.target=="string"?o.target:void 0,t=typeof o.device=="string"&&o.device.trim()!==""?o.device.trim():void 0,n=g=>typeof g=="string"&&g.trim()!==""?g.trim():void 0,s=n(o.device_name),l=n(o.os_version),a=typeof o.app=="string"&&o.app!==""?o.app:void 0,r={},u=i??e.tui_target;u&&(r.tui_target=u);let _=m(u,void 0).kind,d=_==="emulator"||_==="simulator"?_:null;d&&(s||l)?r.default_target={platform:c(d),kind:d,...s?{name:s}:{},...l?{os_version:l}:{}}:d&&t?r.default_target={platform:c(d),kind:d,id:t}:(e.default_target?.id?.trim()||e.default_target?.name?.trim())&&(r.default_target=e.default_target);let p=a??e.default_app;return p&&(r.default_app=p),e.no_reset!==void 0&&(r.no_reset=e.no_reset),e.appium_url!==void 0&&(r.appium_url=e.appium_url),e.auto_grant_permissions!==void 0&&(r.auto_grant_permissions=e.auto_grant_permissions),e.auto_accept_alerts!==void 0&&(r.auto_accept_alerts=e.auto_accept_alerts),Object.keys(r).length>0?r:void 0}var v=class{constructor(e=b){this.path=e}exists(){return k(this.path)}load(){try{let e=w(this.path,"utf-8"),i=JSON.parse(e),t=S(i),{target:n,device:s,app:l,...a}=i;return{...f,...a,...t?{mobile:t}:{},code_export:{...f.code_export,...i.code_export??{}},generate:{...f.generate,...i.generate??{}}}}catch{return{...f,code_export:{...f.code_export},generate:{...f.generate}}}}write(e){try{C(x(this.path),{recursive:!0}),y(this.path,JSON.stringify(T(e),null,2)+`
2
+ import{a as m,c}from"./chunk-EYOCNMUM.js";import{c as b,j as h}from"./chunk-OWPQZP4C.js";import{readFileSync as w,writeFileSync as y,mkdirSync as C,existsSync as k}from"fs";import{dirname as x}from"path";var f={window_size:{width:1920,height:1080},chrome_profile_path:"",default_url:h,model:"v16-alpha",project_id:null,project_name:null,folder_id:null,folder_name:null,mode:"testing",assertion_mode:"dom",network_ws:!1,network_sse:!1,bug_detection:"off",final_validation:!1,code_export:{enabled:!0,language:"python",skip_validation:!0},generate:{scenario_limit:2,per_scenario_limit:3,memory_enabled:!1},last_seen_version:"",hints_enabled:!0};function T(o){let{mobile:e,...i}=o,t={...i};delete t.target,delete t.device,delete t.device_name,delete t.os_version,delete t.app;let n=e??{};n.tui_target&&(t.target=n.tui_target);let s=n.default_target?.name?.trim(),l=n.default_target?.os_version?.trim();if(s||l)s&&(t.device_name=s),l&&(t.os_version=l);else{let r=n.default_target?.id?.trim();r&&(t.device=r)}n.default_app&&(t.app=n.default_app);let a={};return n.no_reset!==void 0&&(a.no_reset=n.no_reset),n.appium_url!==void 0&&(a.appium_url=n.appium_url),n.auto_grant_permissions!==void 0&&(a.auto_grant_permissions=n.auto_grant_permissions),n.auto_accept_alerts!==void 0&&(a.auto_accept_alerts=n.auto_accept_alerts),Object.keys(a).length>0&&(t.mobile=a),t}function S(o){let e=o.mobile??{},i=typeof o.target=="string"?o.target:void 0,t=typeof o.device=="string"&&o.device.trim()!==""?o.device.trim():void 0,n=g=>typeof g=="string"&&g.trim()!==""?g.trim():void 0,s=n(o.device_name),l=n(o.os_version),a=typeof o.app=="string"&&o.app!==""?o.app:void 0,r={},u=i??e.tui_target;u&&(r.tui_target=u);let _=m(u,void 0).kind,d=_==="emulator"||_==="simulator"?_:null;d&&(s||l)?r.default_target={platform:c(d),kind:d,...s?{name:s}:{},...l?{os_version:l}:{}}:d&&t?r.default_target={platform:c(d),kind:d,id:t}:(e.default_target?.id?.trim()||e.default_target?.name?.trim())&&(r.default_target=e.default_target);let p=a??e.default_app;return p&&(r.default_app=p),e.no_reset!==void 0&&(r.no_reset=e.no_reset),e.appium_url!==void 0&&(r.appium_url=e.appium_url),e.auto_grant_permissions!==void 0&&(r.auto_grant_permissions=e.auto_grant_permissions),e.auto_accept_alerts!==void 0&&(r.auto_accept_alerts=e.auto_accept_alerts),Object.keys(r).length>0?r:void 0}var v=class{constructor(e=b){this.path=e}exists(){return k(this.path)}load(){try{let e=w(this.path,"utf-8"),i=JSON.parse(e),t=S(i),{target:n,device:s,app:l,...a}=i;return{...f,...a,...t?{mobile:t}:{},code_export:{...f.code_export,...i.code_export??{}},generate:{...f.generate,...i.generate??{}}}}catch{return{...f,code_export:{...f.code_export},generate:{...f.generate}}}}write(e){try{C(x(this.path),{recursive:!0}),y(this.path,JSON.stringify(T(e),null,2)+`
3
3
  `)}catch(i){let t=i instanceof Error?i.message:String(i);process.stderr.write(`[config] Failed to save config: ${t}
4
4
  `)}}set(e,i){let t=this.load();t[e]=i,this.write(t)}save(e){this.write({...this.load(),...e})}getMobile(){return this.load().mobile??{}}setMobile(e){let i={...this.getMobile()};for(let t of Object.keys(e)){let n=e[t];n===void 0?delete i[t]:i[t]=n}this.set("mobile",Object.keys(i).length>0?i:void 0)}writeRaw(e){this.write(e)}};export{v as a};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as Me}from"./chunk-ICFJVEEA.js";import{c as Ft}from"./chunk-H6TNBKGR.js";import{a as Jt}from"./chunk-66MOZKD2.js";import{a as g,c as Mt,d as Bt,e as _,f as Le,g as Fe,h as Wt,i as Je,j as Ht}from"./chunk-YLQHY4A7.js";import{h as ut,k as ft,m as ht,o as _e,r as Pt,t as Lt}from"./chunk-IPQAKIJO.js";import{a as At,b as Pe,c as Ct,d as Tt}from"./chunk-VVOKM2VO.js";import{a as Nt}from"./chunk-CH273NAE.js";import{b as dt}from"./chunk-5LJRZI7S.js";import{a as lt}from"./chunk-BKM2LWU2.js";import{u as qt}from"./chunk-IICT4VOU.js";import{B as re,D as Ie,E as Et,F as xt,G as L,I as qe,J as he,K as Ot,O as $,P as y,Q as Ae,R as _t,S as Ce,U as Te,V as It,W as Ne,X as se,a as pt,b as fe,h as te,i as mt,j as gt,n as wt,p as x,r as St,s as $t,t as kt,v as Rt,x as vt,z as Y}from"./chunk-RDHWNSDP.js";import{b as ne,c as bt,h as yt}from"./chunk-FQNQVC5O.js";import{a as ee}from"./chunk-XLSOQLVT.js";import{s as at,t as ct}from"./chunk-RSSOJ3L2.js";import{y as O}from"./chunk-PHR2OSWD.js";import{a as it}from"./chunk-DFS4RMVP.js";import{a as ue}from"./chunk-HCBYKLMW.js";import{a as U,b,i as pe}from"./chunk-C44QQJR4.js";import{a as Pn}from"./chunk-6YGTRKDT.js";import{e as D}from"./chunk-UR6MHSHU.js";import{existsSync as fs}from"fs";var V=D(Pn(),1);import{existsSync as de,mkdirSync as xn,readdirSync as Hr,readFileSync as Re,rmSync as En,writeFileSync as Ur,renameSync as Yr}from"fs";import{randomBytes as jr}from"crypto";import{basename as zr,join as tt}from"path";import{appendFileSync as ye,closeSync as hr,existsSync as w,fsyncSync as mr,mkdirSync as F,openSync as gr,readdirSync as G,readFileSync as S,renameSync as $e,rmdirSync as wr,rmSync as q,realpathSync as br,statfsSync as yr,statSync as pn,writeFileSync as Sr}from"fs";import{randomBytes as un}from"crypto";import{basename as fn,dirname as R,join as h,relative as Ge}from"path";var Ln=/^sha256:[0-9a-f]{64}$/;function oe(t){let e=new Set,n=r=>{typeof r=="string"&&Ln.test(r)&&e.add(r)};for(let r of t.nodes??[])n(r.content?.blob);for(let r of Object.values(t.media??{})){n(r.text_blob);for(let s of r.images??[])n(s.blob)}return{blobs:[...e].sort(),proposalId:t.proposal_id??null}}function Be(t){return"sha256:"+fe(Buffer.from("assurance.proposal\0"+pt(JSON.parse(t)),"utf8"))}import{mkdirSync as Fn,readFileSync as Jn}from"fs";import{dirname as Mn,join as Bn}from"path";var Ut="locations.json",Yt="state.json";function me(t,e){return Bn(t,"sync",e)}function jt(t){return Zt(me(t,Ut),{version:1,locations:[]})}function Es(t,e){Xt(me(t,Ut),e)}function B(t){return Zt(me(t,Yt),{version:1,entries:{}})}function zt(t,e){Xt(me(t,Yt),e)}function Gt(t,e){let n=t.locations;if(n.length===0)throw new Error("no locations yet \u2014 add one with kane-cli context sync add <name> <descriptor>");if(e!==void 0){let s=n.find(i=>i.name===e);if(s)return s;throw new Error(`no location named ${e} \u2014 known locations: ${n.map(i=>i.name).join(", ")}`)}if(n.length===1)return n[0];let r=n.find(s=>s.name==="origin");if(r)return r;throw new Error(`name a location: ${n.map(s=>s.name).join(", ")}`)}var j=class extends Error{code="WITNESS_LOWERED"};function Kt(t,e,n){let r=t.entries[e];if(!r)throw new Error(`no sync state for ${e} \u2014 run kane-cli context sync add ${e} <descriptor> first`);let s=r.witness;if(s){if(n.seq<s.seq)throw new j(`${e} is behind what it already served: position ${s.seq} was seen there, now ${n.seq}`);if(n.seq===s.seq&&n.hash!==s.hash)throw new j(`${e} changed the record at position ${s.seq}: ${s.hash} was seen there, now ${n.hash}`)}r.witness=n}function xs(t,e,n){let r=t.locations.length,s=t.locations.filter(i=>i.name!==n);if(s.length===r){let i=r===0?"none":t.locations.map(o=>o.name).join(", ");throw new Error(`no location named ${n} \u2014 known locations: ${i}`)}return t.locations=s,e.entries[n]?.witness??null}function Zt(t,e){let n;try{n=Jn(t,"utf-8")}catch(s){if(s.code==="ENOENT")return e;throw new Error(`${t} could not be read: ${s instanceof Error?s.message:String(s)}`)}let r;try{r=JSON.parse(n)}catch(s){throw new Error(`${t} is not readable JSON: ${s instanceof Error?s.message:String(s)}`)}if(typeof r!="object"||r===null||!("version"in r)||r.version!==1)throw new Error(`${t} is not a version 1 sync file \u2014 this store was written by a newer kane-cli`);return r}function Xt(t,e){Fn(Mn(t),{recursive:!0}),$(t,JSON.stringify(e,null,2)+`
2
+ import{b as Me}from"./chunk-6MTKXDTH.js";import{c as Ft}from"./chunk-H6TNBKGR.js";import{a as Jt}from"./chunk-66MOZKD2.js";import{a as g,c as Mt,d as Bt,e as _,f as Le,g as Fe,h as Wt,i as Je,j as Ht}from"./chunk-YLQHY4A7.js";import{h as ut,k as ft,m as ht,o as _e,r as Pt,t as Lt}from"./chunk-IPQAKIJO.js";import{a as At,b as Pe,c as Ct,d as Tt}from"./chunk-VVOKM2VO.js";import{a as Nt}from"./chunk-CH273NAE.js";import{b as dt}from"./chunk-5LJRZI7S.js";import{a as lt}from"./chunk-BKM2LWU2.js";import{u as qt}from"./chunk-IICT4VOU.js";import{B as re,D as Ie,E as Et,F as xt,G as L,I as qe,J as he,K as Ot,O as $,P as y,Q as Ae,R as _t,S as Ce,U as Te,V as It,W as Ne,X as se,a as pt,b as fe,h as te,i as mt,j as gt,n as wt,p as x,r as St,s as $t,t as kt,v as Rt,x as vt,z as Y}from"./chunk-RDHWNSDP.js";import{b as ne,c as bt,h as yt}from"./chunk-FQNQVC5O.js";import{a as ee}from"./chunk-XLSOQLVT.js";import{s as at,t as ct}from"./chunk-RSSOJ3L2.js";import{y as O}from"./chunk-OWPQZP4C.js";import{a as it}from"./chunk-DFS4RMVP.js";import{a as ue}from"./chunk-HCBYKLMW.js";import{a as U,b,i as pe}from"./chunk-C44QQJR4.js";import{a as Pn}from"./chunk-6YGTRKDT.js";import{e as D}from"./chunk-UR6MHSHU.js";import{existsSync as fs}from"fs";var V=D(Pn(),1);import{existsSync as de,mkdirSync as xn,readdirSync as Hr,readFileSync as Re,rmSync as En,writeFileSync as Ur,renameSync as Yr}from"fs";import{randomBytes as jr}from"crypto";import{basename as zr,join as tt}from"path";import{appendFileSync as ye,closeSync as hr,existsSync as w,fsyncSync as mr,mkdirSync as F,openSync as gr,readdirSync as G,readFileSync as S,renameSync as $e,rmdirSync as wr,rmSync as q,realpathSync as br,statfsSync as yr,statSync as pn,writeFileSync as Sr}from"fs";import{randomBytes as un}from"crypto";import{basename as fn,dirname as R,join as h,relative as Ge}from"path";var Ln=/^sha256:[0-9a-f]{64}$/;function oe(t){let e=new Set,n=r=>{typeof r=="string"&&Ln.test(r)&&e.add(r)};for(let r of t.nodes??[])n(r.content?.blob);for(let r of Object.values(t.media??{})){n(r.text_blob);for(let s of r.images??[])n(s.blob)}return{blobs:[...e].sort(),proposalId:t.proposal_id??null}}function Be(t){return"sha256:"+fe(Buffer.from("assurance.proposal\0"+pt(JSON.parse(t)),"utf8"))}import{mkdirSync as Fn,readFileSync as Jn}from"fs";import{dirname as Mn,join as Bn}from"path";var Ut="locations.json",Yt="state.json";function me(t,e){return Bn(t,"sync",e)}function jt(t){return Zt(me(t,Ut),{version:1,locations:[]})}function Es(t,e){Xt(me(t,Ut),e)}function B(t){return Zt(me(t,Yt),{version:1,entries:{}})}function zt(t,e){Xt(me(t,Yt),e)}function Gt(t,e){let n=t.locations;if(n.length===0)throw new Error("no locations yet \u2014 add one with kane-cli context sync add <name> <descriptor>");if(e!==void 0){let s=n.find(i=>i.name===e);if(s)return s;throw new Error(`no location named ${e} \u2014 known locations: ${n.map(i=>i.name).join(", ")}`)}if(n.length===1)return n[0];let r=n.find(s=>s.name==="origin");if(r)return r;throw new Error(`name a location: ${n.map(s=>s.name).join(", ")}`)}var j=class extends Error{code="WITNESS_LOWERED"};function Kt(t,e,n){let r=t.entries[e];if(!r)throw new Error(`no sync state for ${e} \u2014 run kane-cli context sync add ${e} <descriptor> first`);let s=r.witness;if(s){if(n.seq<s.seq)throw new j(`${e} is behind what it already served: position ${s.seq} was seen there, now ${n.seq}`);if(n.seq===s.seq&&n.hash!==s.hash)throw new j(`${e} changed the record at position ${s.seq}: ${s.hash} was seen there, now ${n.hash}`)}r.witness=n}function xs(t,e,n){let r=t.locations.length,s=t.locations.filter(i=>i.name!==n);if(s.length===r){let i=r===0?"none":t.locations.map(o=>o.name).join(", ");throw new Error(`no location named ${n} \u2014 known locations: ${i}`)}return t.locations=s,e.entries[n]?.witness??null}function Zt(t,e){let n;try{n=Jn(t,"utf-8")}catch(s){if(s.code==="ENOENT")return e;throw new Error(`${t} could not be read: ${s instanceof Error?s.message:String(s)}`)}let r;try{r=JSON.parse(n)}catch(s){throw new Error(`${t} is not readable JSON: ${s instanceof Error?s.message:String(s)}`)}if(typeof r!="object"||r===null||!("version"in r)||r.version!==1)throw new Error(`${t} is not a version 1 sync file \u2014 this store was written by a newer kane-cli`);return r}function Xt(t,e){Fn(Mn(t),{recursive:!0}),$(t,JSON.stringify(e,null,2)+`
3
3
  `)}import{closeSync as Gn,existsSync as tn,fsyncSync as Kn,linkSync as Zn,mkdirSync as Xn,openSync as Vn,readFileSync as Qn,rmSync as nn,writeFileSync as Dn}from"fs";import{dirname as ge,join as rn}from"path";import{existsSync as jn}from"fs";import{join as zn}from"path";var Vt=1e3,Wn=999999999,Qt=/^assurance\/context@(\d+)$/,Hn=Number(Qt.exec(ee)[1]);async function ae(t,e){let n=await t.get(_(e));if(n===null)throw ie(`position ${e} is absent`);return{hash:We(e,n).hash,raw:n}}function We(t,e){let n=s=>new g("SYNC_OBJECT_CORRUPT",`the record at position ${t} on the storage is not usable: ${s}`,"the storage object needs a human look; nothing was changed"),r;try{r=JSON.parse(Buffer.from(e).toString("utf8"))}catch(s){throw n(`not JSON (${s instanceof Error?s.message:String(s)})`)}if(typeof r!="object"||r===null||Array.isArray(r)||r.seq!==t)throw n(`it says it is position ${String(r?.seq)}`);if(r.schema_version!==void 0&&r.schema_version!==ee){let s=Qt.exec(r.schema_version);throw s&&Number(s[1])>Hn?new g("SYNC_CLIENT_TOO_OLD",`position ${t} is stamped ${r.schema_version}; this kane-cli reads ${ee}`,`upgrade kane-cli to a release that reads ${r.schema_version}, then run the command again`):n(`it is stamped ${r.schema_version}, this build reads ${ee}`)}if(r.parents!==void 0&&!(r.prev_hash===null?r.parents.length===0:r.parents.length===1&&r.parents[0]===r.prev_hash))throw n("parents does not mirror prev_hash");return{record:r,hash:re(r)}}async function W(t,e,n=0){let r=e,s=1,i;for(;;){let u=e+s;if(!await t.head(_(u))){i=u;break}r=u,s*=2}if(r===e&&e>0&&!await t.head(_(e)))return W(t,0);for(;i-r>1;){let u=r+Math.floor((i-r)/2);await t.head(_(u))?r=u:i=u}let o=r;if(o===0){if(await t.head(Bt))throw ie("meta.json exists but position 1 is gone");let u=(await t.list(Mt)).map(Fe).find(f=>f!==null);if(u!==void 0)throw ie(`position ${u} exists but position 1 is gone`);return{seq:0,hash:null,raw:null}}let a=[Le(o),Le(Math.min(o+Vt,Wn))];a[1]===a[0]&&a.pop();let c=new Set;for(let u of a)for(let f of await t.list(u)){let k=Fe(f);if(k!==null){if(k>o){if(await t.head(_(o+1))){if(n>=Un)throw Yn(o);return W(t,o,n+1)}throw ie(`position ${k} exists above the tail at ${o}`)}c.add(k)}}let p=o-(o-1)%Vt;for(let u=p;u<=o;u++)if(!c.has(u))throw ie(`position ${u} is missing below the tail at ${o}`);let{hash:d,raw:l}=await ae(t,o);return{seq:o,hash:d,raw:l}}var Un=3;function Yn(t){return new g("SYNC_REMOTE_HOLE",`the storage kept growing while its tail was being found (last seen at ${t}); nothing was changed`,"run the command again in a moment")}function ie(t){return new g("SYNC_REMOTE_HOLE",`the storage has a hole: ${t} \u2014 a position was deleted below evidence of a later one`,"restore the missing position from a copy that holds it; nothing was changed")}function Dt(t,e){let n=he(t,e);if(n===null)throw new x(`no local record at position ${e} \u2014 run kane-cli context fsck`);if(!(n!==qe&&jn(zn(t,"commits",`${String(e).padStart(6,"0")}-${n.slice(7,19)}.json`))))throw new g("SYNC_LOCAL_RECORD_CORRUPT",`the local record at position ${e} ${n===qe?"is unreadable":"does not hash to its file name"}`,"run kane-cli context fsck, then restore the record from a backup or a clone; nothing was changed");return n}async function en(t,e,n){let r=L(t),s=await W(e,n?.seq??0),i=async l=>l===s.seq?s.hash:(await ae(e,l)).hash;if(n&&(s.seq<n.seq||await i(n.seq)!==n.hash))throw new g("SYNC_REMOTE_ROLLED_BACK",`the storage was rolled back: position ${n.seq} was seen there with ${n.hash}, `+(s.seq<n.seq?`now its tail is ${s.seq}`:"now a different record sits there"),"restore the storage from a copy that holds the witnessed records, or remove and re-add the location after a human has decided it was rebuilt on purpose");let o=s.seq===0?null:{seq:s.seq,hash:s.hash};if(o===null)return{kind:"empty-storage",local:r,storage:o};if(r===null)return{kind:"empty-local",local:r,storage:o};if(Dt(t,1)!==await i(1))return{kind:"foreign-lineage",local:r,storage:o};let a=Math.min(r.seq,o.seq),c=async l=>(l===r.seq?r.hash:Dt(t,l))===await i(l);if(await c(a))return{kind:r.seq===o.seq?"up-to-date":r.seq<o.seq?"behind":"ahead",local:r,storage:o};let p=1,d=a;for(;d-p>1;){let l=p+Math.floor((d-p)/2);await c(l)?p=l:d=l}return{kind:"diverged",local:r,storage:o,at:d}}var er=2e3;async function Qs(t,e,n,r,s){let i=B(t).entries[n]?.witness??null,o=await en(t,e,i),a=o.local?.seq??0,c={imported:0,from:a,to:a,blobs:0,proposals:0};switch(o.kind){case"empty-storage":return r(`nothing to pull: ${n} is empty`),c;case"up-to-date":return r("up to date"),c;case"ahead":return s?.quietAhead||r(`nothing to pull; you are ahead of ${n} \u2014 run kane-cli context push ${n}`),c;case"diverged":throw new g("SYNC_DIVERGED",`you and ${n} both added work after position ${o.at-1}; nothing was pulled`,`run kane-cli context pull ${n} --rebase to save your local work, take the team version from ${n}, and then reapply yours`);case"foreign-lineage":throw new g("SYNC_FOREIGN_LINEAGE",`${n} holds a different history (its first record is not this store's)`,`to work on it, clone it: kane-cli context clone <descriptor of ${n}> <dir>; to share this store, add an empty location`);case"behind":case"empty-local":break}let p=o.storage.seq,d=await Ue(t,e,o.local,o.storage,tr(t,o.local),r);return Ye(t,d,o.local?.hash??null,n),se(t),He(t,n,{seq:p,hash:d.records[d.records.length-1].hash}),{imported:d.records.length,from:a,to:p,blobs:d.blobs.size,proposals:d.proposals.size}}function He(t,e,n,r){let s=r?.lockHeld?()=>{}:Y(t,{deadlineMs:er});try{let i=B(t),o=i.entries[e]?.witness??null;if(r?.forwardOnly&&o&&o.seq>n.seq)return;try{Kt(i,e,n)}catch(a){throw a instanceof j?new g("SYNC_REMOTE_ROLLED_BACK",a.message,"restore the storage from a copy that holds the witnessed records, or remove and re-add the location after a human has decided it was rebuilt on purpose"):a}zt(t,i)}finally{s()}}function tr(t,e){let n=It(t);return n&&n.applied.seq===(e?.seq??0)&&n.applied.hash===(e?.hash??null)?n:se(t)}async function Ue(t,e,n,r,s,i=()=>{}){let o=await rr(e,n?.seq??0,n?.hash??null,r.seq,r.hash);ir(t,o,s);let a=await sr(t,e,o),c=await or(t,e,o,i);return{records:o,blobs:a,proposals:c}}function Ye(t,e,n,r,s){for(let[a,c]of e.proposals){let[p,d]=a.split("/");nr(rn(ge(te(t,p)),d),c)}let i=n,o=null;for(let a=0;a<e.records.length;a+=Ae){let c=e.records.slice(a,a+Ae),p=s?.lockHeld?()=>{}:Y(t);try{_t(t,c.map(({seq:d,raw:l})=>({seq:d,raw:l})),i,{...s,lockHeld:!0})}catch(d){if(!(d instanceof vt))throw d;let l=`this store appended position ${L(t)?.seq??0} while the pull was`;throw new g("SYNC_LOCAL_MOVED",o===null?`${l} being prepared; nothing was imported`:`${l} landing; positions ${e.records[0].seq}..${o} were imported, a valid prefix, and nothing more`,`kane-cli context pull ${r}`)}finally{p()}i=c[c.length-1].hash,o=c[c.length-1].seq,s?.afterChunk?.(o)}}function nr(t,e){Xn(ge(t),{recursive:!0});let n=`${t}.tmp-${process.pid}`,r=Vn(n,"w");try{Dn(r,e),Kn(r)}finally{Gn(r)}try{Zn(n,t)}catch(s){if(s.code!=="EEXIST")throw nn(n,{force:!0}),s}nn(n,{force:!0}),y(ge(t))}async function rr(t,e,n,r,s){let i=[],o=n;for(let a=e+1;a<=r;a++){let c=await t.get(_(a));if(c===null)throw new g("SYNC_REMOTE_HOLE",`the storage has a hole: position ${a} is missing below its tail at ${r}`,"restore the missing position from a copy that holds it; nothing was changed");let{record:p,hash:d}=We(a,c);if(p.prev_hash!==o)throw new g("SYNC_REMOTE_CHAIN_BROKEN",`position ${a} on the storage is sealed onto ${String(p.prev_hash)}, but position ${a-1} hashes ${String(o)}`,"the storage chain needs a human look; nothing was changed");if(a===r&&d!==s)throw new g("SYNC_REMOTE_CHAIN_BROKEN",`the tail at position ${r} changed while this pull ran: it hashed ${s}, now ${d}`,"run kane-cli context pull again");i.push({seq:a,hash:d,raw:Buffer.from(c).toString("utf8"),record:p}),o=d}return i}async function sr(t,e,n){let r=new Set;for(let{seq:s,record:i}of n)for(let o of oe(i).blobs){if(r.has(o))continue;let a=Tt(t,o);if(a!==null&&Pe(a)===o)continue;let c=await e.get(Wt(o));if(c===null)throw new g("SYNC_REMOTE_HOLE",`the storage has a hole: position ${s} names blob ${o}, which the storage does not hold`,"restore the blob from a copy that holds it; nothing was changed");let p=Buffer.from(c);if(Pe(p)!==o)throw new g("SYNC_OBJECT_CORRUPT",`the blob ${o} on the storage does not hash to its name (named by position ${s})`,"the storage object needs a human look; nothing was changed");a===null?Ct(t,p):$(At(t,o),p),r.add(o)}return r}async function or(t,e,n,r){let s=new Map,i=new Set;for(let{seq:o,record:a}of n){let c=oe(a).proposalId;if(c===null||i.has(c))continue;i.add(c);let p=te(t,c),d=null;if(tn(p))try{d=Be(Qn(p,"utf8"))}catch{d=""}let l=await e.list(Ht(c));if(l.length===0)continue;if(l.length>1){r(`proposal ${c} (position ${o}) has ${l.length} payloads on the storage and the record names none of them; skipped`);continue}if(d!==null&&Je(c,d)===l[0])continue;let u=await e.get(l[0]);if(u===null)continue;let f=null;try{f=Be(Buffer.from(u).toString("utf8"))}catch{f=null}if(f===null||Je(c,f)!==l[0]){r(`proposal ${c} (position ${o}) on the storage does not digest to its key ${l[0]}; skipped`);continue}if(d===null){s.set(`${c}/proposal.json`,Buffer.from(u));continue}let k=`${c}/proposal.${f.slice(7,19)}.json`;tn(rn(ge(p),k.slice(c.length+1)))||(r(`proposal ${c} (position ${o}) differs from the one here; the storage's payload is installed beside it as ${k}`),s.set(k,Buffer.from(u)))}return s}function ir(t,e,n){let r=structuredClone(n);for(let{seq:s,hash:i,record:o}of e)try{gt(t,r,o,i)}catch(a){throw a instanceof mt?new g("SYNC_REMOTE_ADMISSION_RED",`position ${s} would not pass this store's checks: ${a.message}`,`nothing was imported; ask whoever pushed position ${s} to run kane-cli context fsck on their store, or upgrade kane-cli if theirs is newer`):a}}import{existsSync as on,mkdirSync as ar,readdirSync as cr,readFileSync as an,renameSync as dr,writeFileSync as lr}from"fs";import{join as we}from"path";var pr=/^@import\s+(\S+)\s*$/;function sn(t,e){let n=t.resolve(e),r=n?String(t.getNode(n.tip)?.content.title??""):"";return r&&qt(r,()=>!1)||e}function je(t){return we(t,".testmuai","tests")}function ze(t){let e=new Map;if(!on(t))return e;for(let n of cr(t)){if(!n.endsWith("_test.md"))continue;let r=we(t,n);try{let s=_e(an(r,"utf8"))?.id;s&&e.set(s,[...e.get(s)??[],r])}catch{}}return e}function ur(t,e,n){let r=`assurance:
4
4
  id: ${e}
5
5
  base: ${n}
@@ -32,4 +32,4 @@ ${s}`}function fr(t,e){let n=`${t}.tmp-mint`;lr(n,e),dr(n,t)}function oo(t){let{
32
32
  `),q(s),i.length}var Wr=/^sha256:[0-9a-f]{64}$/,De=class t{m=new Map;get size(){return this.m.size}set(e,n){this.m.set(e,n)}get(e){return this.m.get(e)}rewrite(e){if(typeof e=="string")return Wr.test(e)?this.m.get(e)??e:e;if(Array.isArray(e))return e.map(n=>this.rewrite(n));if(e!==null&&typeof e=="object"){let n={};for(let[r,s]of Object.entries(e))n[r]=this.rewrite(s);return n}return e}toJSON(){return Object.fromEntries(this.m)}static fromJSON(e){let n=new t;for(let[r,s]of Object.entries(e??{}))n.set(r,s);return n}},et=class t{m=new Map;set(e,n){this.m.set(e.hash,{orig:e,fate:n})}get(e){let n=this.m.get(e.hash);return n&&n.orig.seq===e.seq?n.fate:void 0}byHash(e){return this.m.get(e)?.fate}toJSON(){return[...this.m.values()]}static fromJSON(e){let n=new t;for(let r of e??[])n.set(r.orig,r.fate);return n}},Rn=t=>({cid:t.cid.toJSON(),record:t.record.toJSON()}),vn=t=>({cid:De.fromJSON(t?.cid),record:et.fromJSON(t?.record)});var Jo=["keep-theirs","apply-mine","apply-mine-as-new"];function nt(t,e,n){switch(e){case"keep-theirs":return t==="generation"?"the local design stays in the backup; after this rebase, run design again if you want both":"the local change stays in the backup";case"apply-mine":return t==="slug"?`the name moves to the local node; the node that holds it on ${n} is reached by its id again`:t==="head"?`retire the source as it is now, ${n}'s version included`:`the local version lands on top of ${n}'s`;case"apply-mine-as-new":return`a new node beside ${n}'s (duplicate check first)`;case"later":return"leaves the rebase open; kane-cli context sync or kane-cli context pull asks again"}}function Mo(t,e,n){return{rebase_id:t,decision_id:e.holdId,kind:e.kind,intent:e.verb,seq:e.orig.seq,label:e.label,location:n,mine:e.mine,theirs:e.theirs,answers:e.answers.map(r=>({answer:r,consequence:nt(e.kind,r,n)}))}}var Bo=t=>({from:(e,n)=>Ot(t,e,n),hashAt:e=>{let n=he(t,e);return n===null||n==="corrupt"?null:n}}),ke=(t,e)=>tt(v(t),`${e}.json`),Gr=(t,e)=>tt(v(t),`${e}.lock`),Z=class t{constructor(e,n){this.contextDir=e;this.data=n;this.maps=vn(n.maps)}maps;static create(e,n,r,s,i){let o=zr(n);if(de(ke(e,o)))throw new x(`rebase ${o} already has a ledger \u2014 run kane-cli context sync or kane-cli context pull to continue it, or kane-cli context sync doctor --abort to close it`);let a=new t(e,{version:1,backup:n,backupId:o,from:s,state:"open",...i?{location:i}:{},items:r.map(p=>({...p})),maps:{cid:{},record:[]},aliases:[]}),c=!de(v(e));return xn(v(e),{recursive:!0}),c&&y(tt(e,"sync")),a.save(),a}static open(e,n){let r=ke(e,n);if(!de(r))throw new x(`no rebase ${n} here \u2014 kane-cli context sync doctor lists the rebases this store has`);let s;try{s=JSON.parse(Re(r,"utf8"))}catch{s=null}if(!$t(s)||typeof s.backup!="string")throw new x(Kr(n));return new t(e,s)}get backupId(){return this.data.backupId}get location(){return this.data.location??"the location"}get rev(){return this.data.rev??0}get backup(){return this.data.backup}get from(){return this.data.from}get state(){return this.data.state}get closedBy(){return this.data.closedBy}get items(){return this.data.items}get aliases(){return this.data.aliases}item(e){let n=this.data.items.find(r=>r.k===e);if(!n)throw new Error(`no replay item ${e}`);return n}itemAt(e){return this.data.items.find(n=>n.orig.seq===e||n.group?.some(r=>r.seq===e))}beginItem(e,n){this.assertOpen();let r=this.item(e);r.begin={expectPrev:n},delete r.outcome,this.save()}endItem(e,n){this.assertOpen(),this.item(e).outcome=n,this.save()}pendingItem(){return this.data.items.find(e=>e.begin!==void 0&&e.outcome===void 0)}reconcileAll(e,n){let r=this.item(e);if(!r.begin)return[];let s=r.origins??Object.fromEntries((r.group??[r.orig]).map(c=>[c.hash,c.seq])),{records:i,hashes:o}=n.from(r.begin.expectPrev.seq,r.begin.expectPrev.hash),a=[];return i.forEach((c,p)=>{let d=c.replayed_from===void 0?void 0:s[c.replayed_from.orig.hash];d!==void 0&&a.push({seq:c.seq,hash:o[p],member:d})}),a}reconcileFrom(e,n,r){let s=this.item(e),i=s.origins??Object.fromEntries((s.group??[s.orig]).map(p=>[p.hash,p.seq])),{records:o,hashes:a}=n.from(r.seq,r.hash),c=[];return o.forEach((p,d)=>{let l=p.replayed_from===void 0?void 0:i[p.replayed_from.orig.hash];l!==void 0&&c.push({seq:p.seq,hash:a[d],member:l})}),c}reconcile(e,n){let r=this.reconcileAll(e,n).at(-1);return r?{seq:r.seq,hash:r.hash}:void 0}lastAppliedInChain(e){for(let n of[...this.data.items].reverse()){let r=n.outcome;if(r&&"applied"in r)return e.hashAt(r.applied.newSeq)===r.applied.newHash;if(r&&"deduped"in r&&r.deduped.newSeq!==void 0)return e.hashAt(r.deduped.newSeq)===r.deduped.newHash}return!0}setMaps(e){this.maps=e,this.data.maps=Rn(e),this.save()}addAlias(e){this.data.aliases.push(e),this.save()}listHolds(){return this.data.items.flatMap(e=>e.outcome&&"held"in e.outcome?[e.outcome.held]:[])}resolveHold(e,n){let r=this.heldItem(e);if(!r.outcome.held.answers.includes(n))throw new x(`${n} is not an answer ${e} accepts`);return r.answer=n,this.reopen(r)}reopenHold(e){let n=this.heldItem(e);return delete n.answer,this.reopen(n)}heldItem(e){this.assertOpen();let n=this.data.items.find(r=>r.outcome&&"held"in r.outcome&&r.outcome.held.holdId===e);if(!n)throw new x(`${e} is not an open decision \u2014 kane-cli context sync status lists them`);return n}reopen(e){return delete e.outcome,delete e.begin,this.save(),e}close(e){this.data.state="closed",this.data.closedBy=e,this.save()}toJSON(){return structuredClone(this.data)}assertOpen(){if(this.data.state!=="open")throw new x(`rebase ${this.data.backupId} is closed \u2014 kane-cli context sync doctor lists every rebase and what it reapplied`)}save(){let e=ke(this.contextDir,this.data.backupId);if(de(e)){let n=0;try{n=JSON.parse(Re(e,"utf8")).rev??0}catch{n=0}if(n>(this.data.rev??0))throw new x(`the replay ledger for ${this.data.backupId} changed on disk (rev ${n}, this process holds rev ${this.data.rev??0}) \u2014 another process is working on it; run the command again`)}this.data.rev=(this.data.rev??0)+1,$(e,JSON.stringify(this.data,null,2)+`
33
33
  `)}};function Wo(t,e){let n=Gr(t,e);xn(v(t),{recursive:!0});let r=jr(6).toString("hex");for(;;)try{return Ur(n,JSON.stringify({pid:process.pid,nonce:r}),{flag:"wx"}),()=>{try{JSON.parse(Re(n,"utf8")).nonce===r&&En(n)}catch{}}}catch(s){if(s.code!=="EEXIST")throw s;let i={};try{i=JSON.parse(Re(n,"utf8"))}catch{i={}}if(typeof i.pid=="number"&&ne(i.pid))throw new x(`rebase ${e} is being worked on by pid ${i.pid} \u2014 wait for it to finish`);En(n,{force:!0})}}var Ho=(t,e,n,r,s)=>Z.create(t,e,n,r,s),Uo=(t,e)=>Z.open(t,e),Kr=t=>`rebase ${t} has a ledger this store cannot read (sync/replay/${t}.json) \u2014 ${St}`,On=t=>{let e=v(t);return de(e)?Hr(e).filter(n=>n.endsWith(".json")&&!n.endsWith(".receipt.json")).sort().reverse().map(n=>n.slice(0,-5)):[]};function Zr(t,e={}){let n=[];for(let r of On(t))try{n.push(Z.open(t,r))}catch(s){if(!e.tolerant)throw s}return n}function Yo(t){return On(t).filter(e=>{try{return Z.open(t,e),!1}catch{return!0}})}function jo(t,e){let n=ke(t,e),r=`${n}.unreadable`;return Yr(n,r),y(v(t)),r}function kn(t){return Zr(t).find(e=>e.state==="open")}function Xr(t){let e=t.outcome;return e?"applied"in e?`reapplied \u2192 record ${e.applied.newSeq}`:"held"in e?`decision ${e.held.holdId} (${e.held.kind})`:"deduped"in e?`already present: ${e.deduped.as.slice(0,19)}`:`not reapplied: ${e.skipped.reason}`:t.begin?"pending":"waiting"}function zo(t,e,n={}){let r=t.itemAt(e);if(!r)throw new x(`no moved record at position ${e} in rebase ${t.backupId}`);let s=r.label.startsWith(`${r.verb} `)||r.label===r.verb?r.label:`${r.verb} ${r.label}`,i=[`record ${r.orig.seq}: ${s}`,`origin ${r.orig.hash}`,`outcome: ${Xr(r)}`];if(r.group&&i.push(`group: records ${r.group.map(o=>o.seq).join(", ")}`),r.outcome&&"held"in r.outcome){let o=r.outcome.held,a=Math.max(5,t.location.length)+1;i.push(`${"local:".padEnd(a+1)}${o.mine}`,`${`${t.location}:`.padEnd(a+1)}${o.theirs}`,`choose: ${o.answers.join(", ")}`),n.detail!==!1&&i.push(JSON.stringify(o.detail,null,2))}return i}var m=D(ue(),1);function _n(t,e,n){let r={"keep-theirs":`keep ${n}'s version`,"apply-mine":"apply the local version","apply-mine-as-new":"add the local version as new",later:"decide later"},s=t.answers.map(i=>({key:i,answer:i,label:r[i],detail:e(i)}));return s.push({key:"later",answer:"later",label:r.later,detail:e("later")}),s}function X({label:t,text:e,accent:n}){return(0,m.jsxs)(b,{children:[(0,m.jsx)(b,{color:O.dim,children:` ${t.padEnd(15)}`}),(0,m.jsx)(b,{color:n?O.assuranceAccent:void 0,children:e})]})}function In({card:t,index:e,total:n,rebaseId:r,location:s,diff:i,rows:o,sel:a,focused:c,expanded:p}){let d=Math.max(...(i??[]).map(l=>Math.max(l.was.length,l.local.length,l.origin.length)),8);return(0,m.jsxs)(U,{flexDirection:"column",children:[(0,m.jsxs)(b,{bold:!0,children:[`decision ${e} of ${n}`,(0,m.jsx)(b,{color:O.dim,children:` \xB7 ${t.kind} on your ${t.verb} from record ${t.orig.seq}`})]}),i&&i.length>0?(0,m.jsxs)(U,{flexDirection:"column",children:[(0,m.jsx)(b,{color:O.dim,children:` ${"".padEnd(12)}${"was".padEnd(d+2)}${"local".padEnd(d+2)}${s}`}),i.map(l=>(0,m.jsxs)(b,{children:[(0,m.jsx)(b,{color:O.dim,children:` ${l.field.padEnd(12)}`}),l.was.padEnd(d+2),(0,m.jsx)(b,{color:O.assuranceAccent,children:l.local.padEnd(d+2)}),l.origin]},l.field))]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(X,{label:"local",text:t.mine,accent:!0}),(0,m.jsx)(X,{label:s,text:t.theirs})]}),p?p.map((l,u)=>(0,m.jsx)(b,{color:O.dim,children:` ${l}`},`x-${u}`)):null,(0,m.jsx)(Me,{headline:`what should happen to the local ${t.verb} from record ${t.orig.seq}`,ask:!0,rows:o,sel:a,focused:c}),(0,m.jsx)(b,{color:O.dim,children:" \u2191\u2193 select \xB7 \u23CE confirm \xB7 1\u20139 jump \xB7 v full record \xB7 a decide everything later \xB7 ctrl+c pause"})]})}function qn({name:t,count:e,from:n,backupPath:r,taking:s,sel:i,focused:o}){let a=[{key:"continue",label:"continue",detail:"save, take, reapply"},{key:"not-now",label:"not now",detail:"nothing changes"}];return(0,m.jsxs)(U,{flexDirection:"column",children:[(0,m.jsx)(b,{bold:!0,children:`rebase from ${t}`}),(0,m.jsx)(X,{label:"local",text:`${e} record${e===1?"":"s"} from position ${n} saved to ${r}`}),(0,m.jsx)(X,{label:t,text:`records ${s.from}..${s.to} taken into this store`}),(0,m.jsx)(X,{label:"then",text:"the local records reapplied on top; a disagreement becomes a decision you answer"}),(0,m.jsx)(X,{label:"never",text:`history on ${t} rewritten`}),(0,m.jsx)(Me,{headline:"continue",ask:!0,rows:a,sel:i,focused:o}),(0,m.jsx)(b,{color:O.dim,children:" \u2191\u2193 select \xB7 \u23CE confirm \xB7 esc not now"})]})}var E=D(ue(),1);function Vr(t){let e=t.detail,n=c=>c&&typeof c=="object"&&!Array.isArray(c)?c:null,r=n(e.was),s=n(e.mine),i=n(e.theirs);if(!r||!s||!i)return[];let o=c=>c==null?"":typeof c=="string"?c:JSON.stringify(c);return[...new Set([...Object.keys(r),...Object.keys(s),...Object.keys(i)])].filter(c=>o(s[c])!==o(r[c])||o(i[c])!==o(r[c])).map(c=>({field:c,was:o(r[c]),local:o(s[c]),origin:o(i[c])}))}function oi(t,e,n,r){let s={"keep-theirs":`kept ${n}'s version`,"apply-mine":"applied the local version","apply-mine-as-new":"added the local version as new",later:"decided later","later-all":"decided later"},i=r&&"deduped"in r?`already present on ${n}`:r&&"skipped"in r&&e!=="keep-theirs"?`not reapplied (${r.skipped.reason})`:s[e];return`decision ${t.holdId}: ${i}`}var rt=class{screen={kind:"idle"};version=0;interrupted=!1;scrollback={current:null};listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));set(e){this.screen=e,this.emit()}note(e){this.scrollback.current?.append((0,E.jsx)(b,{children:e}))}flush(){return this.scrollback.current?.flush()??Promise.resolve()}emit(){this.version+=1;for(let e of this.listeners)e()}};function Qr(t){return(0,V.useSyncExternalStore)(t.subscribe,()=>t.version),t.screen}function Dr({ask:t,rows:e,done:n}){let[r,s]=(0,V.useState)(0),[i,o]=(0,V.useState)(!1);pe((c,p)=>{if(p.ctrl&&c==="c")return n("later-all");if(p.escape)return n("later");if(c==="a")return n("later-all");if(c==="v")return o(l=>!l);if(p.upArrow)return s(l=>Math.max(0,l-1));if(p.downArrow)return s(l=>Math.min(e.length-1,l+1));if(p.return)return n(e[r].answer);let d=Number(c);Number.isInteger(d)&&d>=1&&d<=e.length&&s(d-1)});let a=Vr(t.card);return(0,E.jsx)(In,{card:t.card,index:t.index,total:t.total,rebaseId:t.rebaseId,location:t.location,diff:a,rows:e,sel:r,focused:!0,expanded:i?t.record:void 0})}function es({ask:t,done:e}){let[n,r]=(0,V.useState)(0);return pe((s,i)=>{if(i.ctrl&&s==="c"||i.escape)return e(!1);if(i.upArrow)return r(0);if(i.downArrow)return r(1);if(s==="1")return r(0);if(s==="2")return r(1);if(i.return)return e(n===0)}),(0,E.jsx)(qn,{...t,sel:n,focused:!0})}function ts({store:t}){return pe((e,n)=>{n.ctrl&&e==="c"&&(t.interrupted=!0)}),null}function ns({store:t}){let e=Qr(t);return e.kind==="decide"?(0,E.jsx)(Dr,{ask:e.ask,rows:e.rows,done:e.done},e.ask.card.holdId):e.kind==="confirm"?(0,E.jsx)(es,{ask:e.ask,done:e.done}):(0,E.jsx)(ts,{store:t})}function rs({store:t}){return(0,E.jsxs)(it,{children:[(0,E.jsx)(Jt,{into:t.scrollback}),(0,E.jsx)(U,{flexDirection:"column",children:(0,E.jsx)(ns,{store:t})})]})}function ss(t,e){return _n(t,n=>nt(t.kind,n,e),e)}function An(){let t=new rt,e=null,n=async()=>{if(e)return;let{render:s}=await import("./build-JIKYOZUH.js");e=s((0,E.jsx)(rs,{store:t}),{exitOnCtrlC:!1}),at(()=>e?.unmount())},r=async()=>{if(!e)return;let s=e;e=null,await t.flush();let i=s.waitUntilExit().catch(()=>{});s.unmount(),await i,ct()};return{async confirm(s){await n();let i=await new Promise(o=>t.set({kind:"confirm",ask:s,done:o}));return t.set({kind:"idle"}),await r(),i},async decide(s){await n();let i=await new Promise(o=>t.set({kind:"decide",ask:s,rows:ss(s.card,s.location),done:o}));return t.set({kind:"idle"}),i},note(s){t.note(s)},close:r,interrupted:()=>t.interrupted}}import{resolve as os}from"path";import{fileURLToPath as is,pathToFileURL as as}from"url";var cs="us-east-1",ds=/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//,xe="use file:///abs/path, an absolute or relative directory path, s3://<bucket>/<prefix>?endpoint=<url>&region=<region>, or a GitHub HTTPS/SSH repository URL";function Tn(t,e){let n=t.trim();if(n==="")throw new Error(`a location is required \u2014 ${xe}`);if(/^(?:git\+)?https:\/\//i.test(n)||/^(?:git\+)?ssh:\/\//i.test(n)||/^[^/\s@:]+@[^/\s:]+:/.test(n)||n.startsWith("git+scp://"))return us(n);if(!ds.test(n))return Cn(os(e,n));let r=new URL(n);switch(r.protocol){case"fake:":if(r.hostname==="")throw new Error(`fake:// needs a name \u2014 ${xe}`);return{kind:"fake",location:`fake://${r.hostname}`};case"file:":return Cn(is(r));case"s3:":return ls(r);default:throw new Error(`this release does not speak "${r.protocol}" \u2014 ${xe}`)}}function Cn(t){return{kind:"dir",location:as(t).href,path:t}}function ls(t){let e=t.hostname;if(e==="")throw new Error(`an s3 location needs a bucket \u2014 ${xe}`);let n=t.pathname.replace(/^\/+/,"").replace(/\/+$/,""),r=n===""?"":`${n}/`,s=t.searchParams.get("region")||cs;if(!/^[A-Za-z0-9-]{1,64}$/.test(s))throw new Error("the region must be letters, digits and dashes only, like us-east-1");let i=t.searchParams.get("endpoint"),o=i===null||i===""?null:ps(i),a=o===null?`?region=${s}`:`?endpoint=${o}&region=${s}`,c={kind:"s3",location:`s3://${e}/${r}${a}`,bucket:e,prefix:r,region:s};return o!==null&&(c.endpoint=o),c}function ps(t){let e="the endpoint must be an http URL like http://127.0.0.1:9000",n;try{n=new URL(t)}catch{throw new Error(e)}if(n.protocol!=="http:"&&n.protocol!=="https:")throw new Error(e);if(n.username||n.password)throw new Error("an endpoint never carries a user name or password; pass credentials with --credential-env or --credential-file");if(n.search!==""||n.hash!==""||n.pathname!=="/")throw new Error(`the endpoint must be a host and port only, with no path or query \u2014 got ${n.origin}`);return`${n.protocol}//${n.host}`}var ve="Use a Git repository address with no dot or parent segments";function Ee(t){return t.split("/").some(e=>e==="."||e==="..")}function us(t){if(/[\x00-\x20\x7f]/.test(t))throw new Error("A Git location cannot contain whitespace or control characters");let e=t;if(e.startsWith("git+scp://")){let u=e.slice(10).replace(/[?#].*$/,"").replace(/^[^/]*/,"");if(Ee(u.slice(1)))throw new Error(ve);let f=new URL(e);e=`${decodeURIComponent(f.username)}@${f.hostname}:${f.pathname.slice(1)}${f.search}${f.hash}`}else e=e.replace(/^git\+/,"");let n=e.indexOf("#"),r=n<0?"main":decodeURIComponent(e.slice(n+1)),s=n<0?e:e.slice(0,n),i=s.indexOf("?"),o=i<0?s:s.slice(0,i),a=new URLSearchParams(i<0?"":s.slice(i+1));for(let u of a.keys())if(u!=="prefix")throw new Error("https: and ssh: Git locations accept only the prefix query option; never put credentials in a location");if(a.getAll("prefix").length>1)throw new Error("Only one Git prefix may be supplied");let c=a.get("prefix")??"";if(c&&(!/^[a-zA-Z0-9_~./-]+$/.test(c)||c.split("/").some(u=>!u||u==="."||u===".."||u.toLowerCase()===".git")))throw new Error("Use a relative Git prefix with no empty, dot or parent segments");if(!/^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(r)||r.includes("..")||r.includes("//")||r.endsWith(".")||r.split("/").some(u=>!u||u.startsWith(".")||u.endsWith(".lock")))throw new Error("Use a valid Git branch name");let p=/^([^/@:]+)@([^/:]+):(.+)$/.exec(o),d;if(p){if(!/^[A-Za-z0-9._-]+$/.test(p[1])||!/^[A-Za-z0-9.-]+$/.test(p[2])||!/^[A-Za-z0-9_~./-]+$/.test(p[3]))throw new Error("Use a valid SSH repository address");if(Ee(p[3]))throw new Error(ve);d=`git+scp://${p[1]}@${p[2]}/${p[3]}`}else{if(Ee(o.replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/[^/]*/,"")))throw new Error(ve);let u=new URL(o);if(!["https:","ssh:"].includes(u.protocol)||!u.hostname||!u.pathname||u.pathname==="/"||u.password||u.protocol==="https:"&&u.username)throw new Error("Use a secret-free HTTPS or SSH repository URL; sign in through Git instead");if(/%(?:00|0a|0d)/i.test(u.pathname))throw new Error("Invalid repository path");if(Ee(u.pathname))throw new Error(ve);o=u.href,d=`git+${u.href}`}let l=c?`?${new URLSearchParams({prefix:c})}`:"";return{kind:"git",gitUrl:o,branch:r,prefix:c,location:`${d}${l}#${encodeURIComponent(r)}`}}function di(t){if(t.kind==="dir")return t.path;if(t.kind!=="git")return t.location;let e=t.prefix?`?${new URLSearchParams({prefix:t.prefix})}`:"",n=t.branch&&t.branch!=="main"?`#${encodeURIComponent(t.branch)}`:"";return`${t.gitUrl}${e}${n}`}function st(t,e){(t.err??t.out)(`error: ${e}`)}function $i(t,e){let n=Nt(t);return fs(n)?n:(st(e,"no context store here (run `kane-cli context ingest <files>` first)"),null)}async function ki(t,e,n){return n?!0:t.isTTY?t.confirm(`${e}?`):(st(t,`refusing to ${e} without --yes (no TTY to confirm)`),!1)}function Ri(){return{out:t=>process.stdout.write(t+`
34
34
  `),err:t=>process.stderr.write(t+`
35
- `),isTTY:Ft(),walkUI:An,confirm:async t=>{let{createInterface:e}=await import("readline/promises"),n=e({input:process.stdin,output:process.stdout});try{let r=await n.question(`${t} [y/N] `);return/^y(es)?$/i.test(r.trim())}catch(r){if(r.name==="AbortError")return!1;throw r}finally{n.close()}},ask:async t=>{let{createInterface:e}=await import("readline/promises"),n=e({input:process.stdin,output:process.stdout});try{return await n.question(t)}finally{n.close()}}}}var hs=1500;function ms(t,e){return t==="behind"?`${e} has moved past this machine \u2014 run kane-cli context pull ${e}`:`this store and ${e} have diverged \u2014 run kane-cli context pull ${e} --rebase`}async function vi(t,e,n){let r=await gs(t,n);r&&e(r.text)}async function gs(t,e){if(process.env.KANE_SYNC_GUARD==="0")return null;try{let n=jt(t);if(n.locations.length===0)return null;let r=Gt(n),s=B(t).entries[r.name]?.witness;if(!s)return null;let{openProvider:i}=await import("./open-provider-OTZ37JB6.js"),o=i(Tn(r.location,t),r.name,e),a=await Promise.race([ws(t,o,s),bs()]);return a?{text:ms(a.kind,r.name),name:r.name,localSeq:a.localSeq,storageSeq:a.storageSeq}:null}catch{return null}}function Ei(t){return{type:"sync_behind",name:t.name,local_seq:t.localSeq,storage_seq:t.storageSeq,text:t.text}}async function ws(t,e,n){try{let r=L(t),s=r?.seq??0;return await e.head(_(n.seq+1))?{kind:"behind",localSeq:s,storageSeq:(await W(e,n.seq+1)).seq}:r===null||(await ae(e,r.seq)).hash===r.hash?null:{kind:"diverged",localSeq:s,storageSeq:(await W(e,r.seq)).seq}}catch{return null}}function bs(){return new Promise(t=>{setTimeout(()=>t(null),hs).unref()})}function ys(t){try{return Rt(t),null}catch(e){if(e instanceof kt)return{code:e.code,text:e.message,remedy:e.remedy};throw e}}function xi(t){return{type:"sync_error",code:t.code,detail:t.text,remedy:t.remedy}}function Oi(t,e){let n=ys(t);return n?(st(e,n.text),(e.err??e.out)(`next: ${n.remedy}`),!0):!1}export{oe as a,Be as b,jt as c,Es as d,B as e,zt as f,Gt as g,xs as h,ae as i,W as j,en as k,Qs as l,He as m,sn as n,je as o,ze as p,oo as q,vr as r,Er as s,xr as t,v as u,Ke as v,mn as w,xo as x,Oo as y,dn as z,_o as A,Jo as B,Mo as C,Bo as D,Wo as E,Ho as F,Uo as G,Zr as H,Yo as I,jo as J,kn as K,zo as L,oi as M,Tn as N,di as O,st as P,$i as Q,ki as R,Ri as S,vi as T,gs as U,Ei as V,ys as W,xi as X,Oi as Y};
35
+ `),isTTY:Ft(),walkUI:An,confirm:async t=>{let{createInterface:e}=await import("readline/promises"),n=e({input:process.stdin,output:process.stdout});try{let r=await n.question(`${t} [y/N] `);return/^y(es)?$/i.test(r.trim())}catch(r){if(r.name==="AbortError")return!1;throw r}finally{n.close()}},ask:async t=>{let{createInterface:e}=await import("readline/promises"),n=e({input:process.stdin,output:process.stdout});try{return await n.question(t)}finally{n.close()}}}}var hs=1500;function ms(t,e){return t==="behind"?`${e} has moved past this machine \u2014 run kane-cli context pull ${e}`:`this store and ${e} have diverged \u2014 run kane-cli context pull ${e} --rebase`}async function vi(t,e,n){let r=await gs(t,n);r&&e(r.text)}async function gs(t,e){if(process.env.KANE_SYNC_GUARD==="0")return null;try{let n=jt(t);if(n.locations.length===0)return null;let r=Gt(n),s=B(t).entries[r.name]?.witness;if(!s)return null;let{openProvider:i}=await import("./open-provider-ZYBUD6JW.js"),o=i(Tn(r.location,t),r.name,e),a=await Promise.race([ws(t,o,s),bs()]);return a?{text:ms(a.kind,r.name),name:r.name,localSeq:a.localSeq,storageSeq:a.storageSeq}:null}catch{return null}}function Ei(t){return{type:"sync_behind",name:t.name,local_seq:t.localSeq,storage_seq:t.storageSeq,text:t.text}}async function ws(t,e,n){try{let r=L(t),s=r?.seq??0;return await e.head(_(n.seq+1))?{kind:"behind",localSeq:s,storageSeq:(await W(e,n.seq+1)).seq}:r===null||(await ae(e,r.seq)).hash===r.hash?null:{kind:"diverged",localSeq:s,storageSeq:(await W(e,r.seq)).seq}}catch{return null}}function bs(){return new Promise(t=>{setTimeout(()=>t(null),hs).unref()})}function ys(t){try{return Rt(t),null}catch(e){if(e instanceof kt)return{code:e.code,text:e.message,remedy:e.remedy};throw e}}function xi(t){return{type:"sync_error",code:t.code,detail:t.text,remedy:t.remedy}}function Oi(t,e){let n=ys(t);return n?(st(e,n.text),(e.err??e.out)(`next: ${n.remedy}`),!0):!1}export{oe as a,Be as b,jt as c,Es as d,B as e,zt as f,Gt as g,xs as h,ae as i,W as j,en as k,Qs as l,He as m,sn as n,je as o,ze as p,oo as q,vr as r,Er as s,xr as t,v as u,Ke as v,mn as w,xo as x,Oo as y,dn as z,_o as A,Jo as B,Mo as C,Bo as D,Wo as E,Ho as F,Uo as G,Zr as H,Yo as I,jo as J,kn as K,zo as L,oi as M,Tn as N,di as O,st as P,$i as Q,ki as R,Ri as S,vi as T,gs as U,Ei as V,ys as W,xi as X,Oi as Y};
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as w}from"./chunk-ZLWURCJ7.js";import{a as O}from"./chunk-QSCXXNC2.js";import{a as I}from"./chunk-KBM3XHAM.js";import{f as L}from"./chunk-5LJRZI7S.js";import{a as N,b as k}from"./chunk-BKM2LWU2.js";import{a as R,b as y,c as T,d as m,e as A,g as b,h as r}from"./chunk-RSSOJ3L2.js";import{b as x}from"./chunk-5EOX4MEY.js";import{a as E}from"./chunk-RZ4F3BHX.js";import{a as g,i as v}from"./chunk-PHR2OSWD.js";import{platform as X,arch as Y}from"os";import P from"fs";import M from"fs";import D from"path";var V=1e3,d=0,j=new Set([130,3]),a=class t{ids;logger;opts;ended=!1;createdAt=Date.now();errorState;constructor(e,n={emitted:!1}){this.ids=e.envelope,this.logger=e.logger,this.opts=e,this.errorState=n}get enabled(){return this.logger!==null}event(e,n={}){if(!this.logger)return;e==="ASR_ERROR"&&(this.errorState.emitted=!0);let i=m(this.ids,e,n);this.logger.log(R[e],e,e,C(i))}error(e,n={}){this.logger&&(this.logger.escalate(d),this.event("ASR_ERROR",{...n,error_code:e}))}child(e,n){return new t({...this.opts,envelope:{...this.ids,operation_id:n,parent_operation_id:this.ids.operation_id,verb:"design"}},this.errorState)}async lateBindContext(e){if(!(!this.logger||this.ids.context_instance_id))try{let{ensureStoreIds:n}=await import("./store-id-EOSGEKVK.js"),{ids:i,cloned:s}=n(e);this.ids.context_lineage_id=i.context_lineage_id,this.ids.context_instance_id=i.context_instance_id,s&&this.event("ASR_CONTEXT_CLONED")}catch{}}agentSession(e){this.ids.agent_session_id=e}spawnEnv(){if(!this.opts.telemetryEnabled)return{};let e={TESTMUAI_USER_SESSION_ID:this.ids.session_id,TESTMUAI_OPERATION_ID:this.ids.operation_id,TESTMUAI_CLIENT_VERSION:this.opts.clientVersion,TESTMUAI_TELEMETRY_PROXY_URL:this.opts.proxyUrl};return this.ids.context_instance_id&&(e.TESTMUAI_CONTEXT_INSTANCE_ID=this.ids.context_instance_id),e}traceTee(){return e=>{if(!this.logger)return;let n=typeof e.kind=="string"?e.kind.slice(0,64):"trace",i={...C(m(this.ids,"ASR_CMD_START",{})),trace_kind:n};typeof e.code=="string"&&(i.trace_code=e.code.slice(0,64)),delete i.event,this.logger.logStep(d,`trace_${n}`,n,i)}}wireTrace(e,n,i){if(!this.logger)return;i&&this.agentSession(i);let s=n&&typeof n=="object"?n:{};switch(e){case"spawn":this.event("ASR_AGENT_SPAWN",{tier:s.tier});break;case"session_paused":this.event("ASR_SESSION_PAUSED",s);break;case"commit":this.event("ASR_COMMIT",s);break;default:this.traceTee()({kind:e,code:typeof s.code=="string"?s.code:void 0})}}banner(){return`session: ${this.ids.session_id}`}supportFooter(){return`if this keeps failing, share this id with support: ${this.ids.session_id}`}async end(e){if(!this.ended){if(this.ended=!0,e.duration_ms===void 0&&(e={...e,duration_ms:Date.now()-this.createdAt}),this.logger)if(e.exit_code===0?this.logger.discardSteps(d):this.logger.escalate(d),e.exit_code>0&&!j.has(e.exit_code)&&!this.errorState.emitted&&this.event("ASR_ERROR",{error_code:e.exit_code===2?"usage_exit_unattributed":`exit_${e.exit_code}_unattributed`,exit_code:e.exit_code}),this.event("ASR_CMD_END",e),this.opts.longSession)await this.logger.shutdown();else{let n=await this.logger.flushOnce(V);(n==="failed"||n==="timeout")&&A(this.logger.drainBuffer())}this.logger&&this.writeManifestLine(e.exit_code),r(null)}}writeManifestLine(e){try{let n=x(this.ids.context_instance_id??null);M.mkdirSync(D.dirname(n),{recursive:!0});let i={ts:new Date().toISOString(),session_id:this.ids.session_id,operation_id:this.ids.operation_id,agent_session_id:this.ids.agent_session_id,verb:this.ids.verb,mode:this.ids.mode,exit_code:e};M.appendFileSync(n,JSON.stringify(i)+`
2
+ import{a as w}from"./chunk-ZLWURCJ7.js";import{a as O}from"./chunk-QSCXXNC2.js";import{a as I}from"./chunk-KBM3XHAM.js";import{f as L}from"./chunk-5LJRZI7S.js";import{a as N,b as k}from"./chunk-BKM2LWU2.js";import{a as R,b as y,c as T,d as m,e as A,g as b,h as r}from"./chunk-RSSOJ3L2.js";import{b as x}from"./chunk-5EOX4MEY.js";import{a as E}from"./chunk-RZ4F3BHX.js";import{a as g,i as v}from"./chunk-OWPQZP4C.js";import{platform as X,arch as Y}from"os";import P from"fs";import M from"fs";import D from"path";var V=1e3,d=0,j=new Set([130,3]),a=class t{ids;logger;opts;ended=!1;createdAt=Date.now();errorState;constructor(e,n={emitted:!1}){this.ids=e.envelope,this.logger=e.logger,this.opts=e,this.errorState=n}get enabled(){return this.logger!==null}event(e,n={}){if(!this.logger)return;e==="ASR_ERROR"&&(this.errorState.emitted=!0);let i=m(this.ids,e,n);this.logger.log(R[e],e,e,C(i))}error(e,n={}){this.logger&&(this.logger.escalate(d),this.event("ASR_ERROR",{...n,error_code:e}))}child(e,n){return new t({...this.opts,envelope:{...this.ids,operation_id:n,parent_operation_id:this.ids.operation_id,verb:"design"}},this.errorState)}async lateBindContext(e){if(!(!this.logger||this.ids.context_instance_id))try{let{ensureStoreIds:n}=await import("./store-id-EOSGEKVK.js"),{ids:i,cloned:s}=n(e);this.ids.context_lineage_id=i.context_lineage_id,this.ids.context_instance_id=i.context_instance_id,s&&this.event("ASR_CONTEXT_CLONED")}catch{}}agentSession(e){this.ids.agent_session_id=e}spawnEnv(){if(!this.opts.telemetryEnabled)return{};let e={TESTMUAI_USER_SESSION_ID:this.ids.session_id,TESTMUAI_OPERATION_ID:this.ids.operation_id,TESTMUAI_CLIENT_VERSION:this.opts.clientVersion,TESTMUAI_TELEMETRY_PROXY_URL:this.opts.proxyUrl};return this.ids.context_instance_id&&(e.TESTMUAI_CONTEXT_INSTANCE_ID=this.ids.context_instance_id),e}traceTee(){return e=>{if(!this.logger)return;let n=typeof e.kind=="string"?e.kind.slice(0,64):"trace",i={...C(m(this.ids,"ASR_CMD_START",{})),trace_kind:n};typeof e.code=="string"&&(i.trace_code=e.code.slice(0,64)),delete i.event,this.logger.logStep(d,`trace_${n}`,n,i)}}wireTrace(e,n,i){if(!this.logger)return;i&&this.agentSession(i);let s=n&&typeof n=="object"?n:{};switch(e){case"spawn":this.event("ASR_AGENT_SPAWN",{tier:s.tier});break;case"session_paused":this.event("ASR_SESSION_PAUSED",s);break;case"commit":this.event("ASR_COMMIT",s);break;default:this.traceTee()({kind:e,code:typeof s.code=="string"?s.code:void 0})}}banner(){return`session: ${this.ids.session_id}`}supportFooter(){return`if this keeps failing, share this id with support: ${this.ids.session_id}`}async end(e){if(!this.ended){if(this.ended=!0,e.duration_ms===void 0&&(e={...e,duration_ms:Date.now()-this.createdAt}),this.logger)if(e.exit_code===0?this.logger.discardSteps(d):this.logger.escalate(d),e.exit_code>0&&!j.has(e.exit_code)&&!this.errorState.emitted&&this.event("ASR_ERROR",{error_code:e.exit_code===2?"usage_exit_unattributed":`exit_${e.exit_code}_unattributed`,exit_code:e.exit_code}),this.event("ASR_CMD_END",e),this.opts.longSession)await this.logger.shutdown();else{let n=await this.logger.flushOnce(V);(n==="failed"||n==="timeout")&&A(this.logger.drainBuffer())}this.logger&&this.writeManifestLine(e.exit_code),r(null)}}writeManifestLine(e){try{let n=x(this.ids.context_instance_id??null);M.mkdirSync(D.dirname(n),{recursive:!0});let i={ts:new Date().toISOString(),session_id:this.ids.session_id,operation_id:this.ids.operation_id,agent_session_id:this.ids.agent_session_id,verb:this.ids.verb,mode:this.ids.mode,exit_code:e};M.appendFileSync(n,JSON.stringify(i)+`
3
3
  `,{flag:"a",mode:384})}catch{}}};function C(t){let e={event:t.event,session_id:t.session_id,operation_id:t.operation_id,verb:t.verb,mode:t.mode,component:t.component,seq:t.seq,context_lineage_id:t.context_lineage_id,context_instance_id:t.context_instance_id};t.parent_operation_id&&(e.parent_operation_id=t.parent_operation_id),t.agent_session_id&&(e.agent_session_id=t.agent_session_id);for(let[n,i]of Object.entries(t.context))e[n]=i;return e}var u=process.env.KANE_TELEMETRY_URL||v;function B(){return process.env.TESTMUAI_BASE_URL?"custom":process.env.TESTMUAI_ENV==="stage"?"stage":"prod"}function _e(t){let e=process.env.KANE_TELEMETRY!=="0"&&(!process.env.VITEST||process.env.KANE_TELEMETRY==="1"),n=t.env??B(),i=null;if(t.resumeSid&&t.contextRoot)try{let o=L(t.contextRoot,t.resumeSid);o?.user_session_id&&(i=o.user_session_id)}catch{}if(!i&&t.applyPlanPath)try{let o=JSON.parse(P.readFileSync(t.applyPlanPath,"utf8"));o.telemetry?.user_session_id&&(i=o.telemetry.user_session_id)}catch{}let s=i!==null;i||(i=y());let l=null,c=null,f=!1;if(t.contextRoot&&P.existsSync(t.contextRoot))if(t.write&&e){let o=k(t.contextRoot);l=o.ids.context_lineage_id,c=o.ids.context_instance_id,f=o.cloned}else{let o=N(t.contextRoot);l=o?.context_lineage_id??null,c=o?.context_instance_id??null}let h={session_id:i,operation_id:T(),context_lineage_id:l,context_instance_id:c,verb:t.verb,mode:t.mode,component:"kane-cli"},_=null;if(e){let o=I(n),S={org_id:o.org_id??"",user_id:o.user_id??"",machine_id:o.machine_id,email:null,email_domain:"",user_type:o.user_type??"unknown",env:o.env,plan:o.plan??"unknown"},U=t.mode==="interactive"||t.mode==="cli"?"cli":"agent";_=new w({proxyUrl:u,sessionId:i,identity:S,device:{cli_version:g,platform:X(),arch:Y(),host_agent:O(),invocation_mode:U},getToken:async()=>null}),t.longSession&&_.start()}let p=new a({envelope:h,logger:_,longSession:!!t.longSession,proxyUrl:u,clientVersion:`kane-cli/${g}`,telemetryEnabled:e});return e&&(r(h),p.event("ASR_CMD_START",{resumed:s,applied_plan:!!t.applyPlanPath}),f&&p.event("ASR_CONTEXT_CLONED"),b(async o=>{try{return(await E(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})).ok}catch{return!1}}).catch(()=>{})),p}export{B as a,_e as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as O,d as S}from"./chunk-D2F5T3NX.js";import{c as L}from"./chunk-RFHMDQXZ.js";import{n as P,o as R}from"./chunk-RSSOJ3L2.js";import{y as s}from"./chunk-PHR2OSWD.js";import{a as y}from"./chunk-HCBYKLMW.js";import{a as E,b as o,i as h}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as d}from"./chunk-UR6MHSHU.js";var n=d(B(),1);import{basename as D}from"path";var r=d(y(),1),U="evidence-view-server";function Q({packPath:m,viewerBase:w,onDone:V,openUrl:k}){let[t,a]=(0,n.useState)("ask"),[g,b]=(0,n.useState)(null),[l,p]=(0,n.useState)(null),f=(0,n.useRef)(null),u=(0,n.useRef)(!1),x=async()=>{let e=f.current;f.current=null,e&&(R(U),await e.close())},v=()=>{u.current||(u.current=!0,V())};return h((e,i)=>{u.current||(t==="ask"?e==="y"||e==="Y"?a("starting"):(e==="n"||e==="N"||i.return||i.escape)&&v():t==="serving"&&(e==="q"||e==="Q"||i.escape)&&x().then(v))}),(0,n.useEffect)(()=>{if(t!=="starting")return;let e=!1;return(async()=>{try{let i=D(m),c=await O({packs:new Map([[i,m]]),allowedOrigins:[new URL(w).origin]});if(e){await c.close();return}f.current=c,P(U,()=>{c.close()});let T=S(c.urlFor(i),w);b(T);try{await(k??(q=>L(q)))(T)}catch{p("could not open browser \u2014 open the URL manually")}a("serving")}catch(i){p(`evidence view failed \u2014 ${i.message}`),a("failed")}})(),()=>{e=!0}},[t]),(0,n.useEffect)(()=>{if(t!=="failed")return;let e=setTimeout(v,0);return()=>clearTimeout(e)},[t]),(0,n.useEffect)(()=>()=>{x()},[]),t==="ask"?(0,r.jsxs)(o,{children:["View evidence in browser? ",(0,r.jsx)(o,{color:s.dim,children:"(y/N)"})]}):t==="serving"||t==="starting"?(0,r.jsxs)(E,{flexDirection:"column",children:[g?(0,r.jsxs)(o,{children:["viewer ",(0,r.jsx)(o,{color:s.orange,children:g})]}):(0,r.jsx)(o,{color:s.dim,children:"starting\u2026"}),l?(0,r.jsx)(o,{color:"yellow",children:l}):null,t==="serving"?(0,r.jsx)(o,{color:s.dim,children:"Press q when done"}):null]}):l?(0,r.jsx)(o,{color:"yellow",children:l}):null}export{Q as a};
2
+ import{b as O,d as S}from"./chunk-E6MW25UV.js";import{c as L}from"./chunk-RFHMDQXZ.js";import{n as P,o as R}from"./chunk-RSSOJ3L2.js";import{y as s}from"./chunk-OWPQZP4C.js";import{a as y}from"./chunk-HCBYKLMW.js";import{a as E,b as o,i as h}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as d}from"./chunk-UR6MHSHU.js";var n=d(B(),1);import{basename as D}from"path";var r=d(y(),1),U="evidence-view-server";function Q({packPath:m,viewerBase:w,onDone:V,openUrl:k}){let[t,a]=(0,n.useState)("ask"),[g,b]=(0,n.useState)(null),[l,p]=(0,n.useState)(null),f=(0,n.useRef)(null),u=(0,n.useRef)(!1),x=async()=>{let e=f.current;f.current=null,e&&(R(U),await e.close())},v=()=>{u.current||(u.current=!0,V())};return h((e,i)=>{u.current||(t==="ask"?e==="y"||e==="Y"?a("starting"):(e==="n"||e==="N"||i.return||i.escape)&&v():t==="serving"&&(e==="q"||e==="Q"||i.escape)&&x().then(v))}),(0,n.useEffect)(()=>{if(t!=="starting")return;let e=!1;return(async()=>{try{let i=D(m),c=await O({packs:new Map([[i,m]]),allowedOrigins:[new URL(w).origin]});if(e){await c.close();return}f.current=c,P(U,()=>{c.close()});let T=S(c.urlFor(i),w);b(T);try{await(k??(q=>L(q)))(T)}catch{p("could not open browser \u2014 open the URL manually")}a("serving")}catch(i){p(`evidence view failed \u2014 ${i.message}`),a("failed")}})(),()=>{e=!0}},[t]),(0,n.useEffect)(()=>{if(t!=="failed")return;let e=setTimeout(v,0);return()=>clearTimeout(e)},[t]),(0,n.useEffect)(()=>()=>{x()},[]),t==="ask"?(0,r.jsxs)(o,{children:["View evidence in browser? ",(0,r.jsx)(o,{color:s.dim,children:"(y/N)"})]}):t==="serving"||t==="starting"?(0,r.jsxs)(E,{flexDirection:"column",children:[g?(0,r.jsxs)(o,{children:["viewer ",(0,r.jsx)(o,{color:s.orange,children:g})]}):(0,r.jsx)(o,{color:s.dim,children:"starting\u2026"}),l?(0,r.jsx)(o,{color:"yellow",children:l}):null,t==="serving"?(0,r.jsx)(o,{color:s.dim,children:"Press q when done"}):null]}):l?(0,r.jsx)(o,{color:"yellow",children:l}):null}export{Q as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as f}from"./chunk-AG2MVCNK.js";import{c as g}from"./chunk-UD7KKHPW.js";import{existsSync as u}from"fs";import{dirname as A,resolve as l}from"path";import{fileURLToPath as E}from"url";var p=A(E(import.meta.url));function _(){return[l(p,".."),l(p,"../../..")]}function x(s){return{"darwin-arm64":"kane-cli-darwin-arm64","darwin-x64":"kane-cli-darwin-x64","linux-x64":"kane-cli-linux-x64","linux-arm64":"kane-cli-linux-arm64","win32-x64":"kane-cli-win-x64"}[s]??null}function T(s){return{"darwin-arm64":"kane-cli-assurance-darwin-arm64","darwin-x64":"kane-cli-assurance-darwin-x64","linux-x64":"kane-cli-assurance-linux-x64","linux-arm64":"kane-cli-assurance-linux-arm64","win32-x64":"kane-cli-assurance-win-x64"}[s]??null}function I(s=_()){let n=x(`${process.platform}-${process.arch}`),i=T(`${process.platform}-${process.arch}`),a=process.platform==="win32"?"assurance-agent.exe":"assurance-agent";for(let e of s){for(let t of i?["@testmuai","@lambdatestincprivate"]:[]){let m=l(e,"node_modules",t,i,"bin",a);if(u(m))return{cmd:m,args:[],tier:"platform"}}for(let t of n?["@testmuai","@lambdatestincprivate"]:[]){let m=l(e,"node_modules",t,n,"bin",a);if(u(m))return{cmd:m,args:[],tier:"platform"}}let c=l(e,"dist","bin",a);if(u(c))return{cmd:c,args:[],tier:"embedded"};let r=l(e,"../assurance-agent/dist",a);if(u(r))return{cmd:r,args:[],tier:"sibling"};let o=l(e,"../assurance-agent/main.py");if(u(o)){let t=l(e,"../assurance-agent/.venv/bin/python");return{cmd:u(t)?t:"python3",args:[o],tier:"dev-python"}}}return null}function U(s,n={}){return{...process.env,...n,...f(),TESTMUAI_SOURCE:"kane-cli",TESTMUAI_SESSION_ID:s,ASSURANCE_LOG_LEVEL:process.env.ASSURANCE_LOG_LEVEL??"info"}}async function P(){if(process.env.TESTMUAI_API_KEY||process.env.TESTMUAI_BASIC_AUTH)return{};try{let{CredentialsManager:s}=await import("./credentials-FLY3ZXVX.js"),n=process.env.TESTMUAI_ENV==="stage"?"stage":"prod",i=new s,a=i.getActiveProfile()??"default",e={TESTMUAI_ENV:n},c=i.loadBasicAuth(a,n);if(c)return e.TESTMUAI_BASIC_AUTH=Buffer.from(`${c.username}:${c.access_key}`,"utf8").toString("base64"),e;let r=i.loadCredentials(a,n);if(r){try{let{refreshOAuthToken:t}=await import("./token-refresh-NADDXLYM.js");await t({creds:i,profile:a,env:n,credentials:r})}catch{}let o=i.loadCredentials(a,n)??r;if(typeof o.access_token=="string"){let t=await w(n,o.access_token);return t?(e.TESTMUAI_BASIC_AUTH=t,e):(e.TESTMUAI_API_KEY=o.access_token,e)}}return{}}catch{return{}}}var h=8e3;function d(){return g("warn: session auth may expire during long runs \u2014 if that happens, run `kane-cli login` and retry","AUTH_EXCHANGE_FAILED"),null}async function w(s,n){try{let[{getEnvironment:i},{ControllerClient:a}]=await Promise.all([import("./config-WKLEWUPU.js"),import("./controller-client-ZF5IXRUV.js")]),e=new a(i(s).controllerBaseUrl,n),c;try{let r=await Promise.race([e.getTmsCredentials().catch(()=>null),new Promise(o=>{c=setTimeout(()=>o(null),h)})]);if(typeof r?.username!="string"||!r.username||typeof r.access_key!="string"||!r.access_key)return d();try{let[{refreshIdentitySnapshot:o},{telemetryEnvName:t}]=await Promise.all([import("./identity-ADZ4PAJF.js"),import("./bootstrap-63FBDEEU.js")]);await o(t(),r)}catch{}return Buffer.from(`${r.username}:${r.access_key}`,"utf8").toString("base64")}finally{clearTimeout(c)}}catch{return d()}}export{x as a,T as b,I as c,U as d,P as e};
2
+ import{b as f}from"./chunk-CXXTQ4C5.js";import{c as g}from"./chunk-UD7KKHPW.js";import{existsSync as u}from"fs";import{dirname as A,resolve as l}from"path";import{fileURLToPath as E}from"url";var p=A(E(import.meta.url));function _(){return[l(p,".."),l(p,"../../..")]}function x(s){return{"darwin-arm64":"kane-cli-darwin-arm64","darwin-x64":"kane-cli-darwin-x64","linux-x64":"kane-cli-linux-x64","linux-arm64":"kane-cli-linux-arm64","win32-x64":"kane-cli-win-x64"}[s]??null}function T(s){return{"darwin-arm64":"kane-cli-assurance-darwin-arm64","darwin-x64":"kane-cli-assurance-darwin-x64","linux-x64":"kane-cli-assurance-linux-x64","linux-arm64":"kane-cli-assurance-linux-arm64","win32-x64":"kane-cli-assurance-win-x64"}[s]??null}function I(s=_()){let n=x(`${process.platform}-${process.arch}`),i=T(`${process.platform}-${process.arch}`),a=process.platform==="win32"?"assurance-agent.exe":"assurance-agent";for(let e of s){for(let t of i?["@testmuai","@lambdatestincprivate"]:[]){let m=l(e,"node_modules",t,i,"bin",a);if(u(m))return{cmd:m,args:[],tier:"platform"}}for(let t of n?["@testmuai","@lambdatestincprivate"]:[]){let m=l(e,"node_modules",t,n,"bin",a);if(u(m))return{cmd:m,args:[],tier:"platform"}}let c=l(e,"dist","bin",a);if(u(c))return{cmd:c,args:[],tier:"embedded"};let r=l(e,"../assurance-agent/dist",a);if(u(r))return{cmd:r,args:[],tier:"sibling"};let o=l(e,"../assurance-agent/main.py");if(u(o)){let t=l(e,"../assurance-agent/.venv/bin/python");return{cmd:u(t)?t:"python3",args:[o],tier:"dev-python"}}}return null}function U(s,n={}){return{...process.env,...n,...f(),TESTMUAI_SOURCE:"kane-cli",TESTMUAI_SESSION_ID:s,ASSURANCE_LOG_LEVEL:process.env.ASSURANCE_LOG_LEVEL??"info"}}async function P(){if(process.env.TESTMUAI_API_KEY||process.env.TESTMUAI_BASIC_AUTH)return{};try{let{CredentialsManager:s}=await import("./credentials-GXICFDVV.js"),n=process.env.TESTMUAI_ENV==="stage"?"stage":"prod",i=new s,a=i.getActiveProfile()??"default",e={TESTMUAI_ENV:n},c=i.loadBasicAuth(a,n);if(c)return e.TESTMUAI_BASIC_AUTH=Buffer.from(`${c.username}:${c.access_key}`,"utf8").toString("base64"),e;let r=i.loadCredentials(a,n);if(r){try{let{refreshOAuthToken:t}=await import("./token-refresh-KYIQ7LZL.js");await t({creds:i,profile:a,env:n,credentials:r})}catch{}let o=i.loadCredentials(a,n)??r;if(typeof o.access_token=="string"){let t=await w(n,o.access_token);return t?(e.TESTMUAI_BASIC_AUTH=t,e):(e.TESTMUAI_API_KEY=o.access_token,e)}}return{}}catch{return{}}}var h=8e3;function d(){return g("warn: session auth may expire during long runs \u2014 if that happens, run `kane-cli login` and retry","AUTH_EXCHANGE_FAILED"),null}async function w(s,n){try{let[{getEnvironment:i},{ControllerClient:a}]=await Promise.all([import("./config-A6MBUY54.js"),import("./controller-client-ZF5IXRUV.js")]),e=new a(i(s).controllerBaseUrl,n),c;try{let r=await Promise.race([e.getTmsCredentials().catch(()=>null),new Promise(o=>{c=setTimeout(()=>o(null),h)})]);if(typeof r?.username!="string"||!r.username||typeof r.access_key!="string"||!r.access_key)return d();try{let[{refreshIdentitySnapshot:o},{telemetryEnvName:t}]=await Promise.all([import("./identity-ADZ4PAJF.js"),import("./bootstrap-545GY5CC.js")]);await o(t(),r)}catch{}return Buffer.from(`${r.username}:${r.access_key}`,"utf8").toString("base64")}finally{clearTimeout(c)}}catch{return d()}}export{x as a,T as b,I as c,U as d,P as e};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as $}from"./chunk-YCCUBQY4.js";import{a as U}from"./chunk-IKB2JKMA.js";import{a as k}from"./chunk-BPMSNGXQ.js";import{a as _}from"./chunk-GIC56KI3.js";import{a as T}from"./chunk-VIYV6NIW.js";import{y as i}from"./chunk-PHR2OSWD.js";import{a as O}from"./chunk-HCBYKLMW.js";import{a as u,b as s}from"./chunk-C44QQJR4.js";import{a as K}from"./chunk-6YGTRKDT.js";import{e as S}from"./chunk-UR6MHSHU.js";var e=S(K(),1);var r=S(O(),1);function V(n,x,c){return{id:n,label:`${x} (${n})`,isActive:n===c}}function se({resolver:n,currentProjectId:x,env:c,onSelect:w,onCancel:C}){let[q,B]=(0,e.useState)([]),[D,l]=(0,e.useState)(!0),[H,m]=(0,e.useState)(!1),[J,g]=(0,e.useState)(!1),[Q,P]=(0,e.useState)(null),[d,p]=(0,e.useState)("list"),[v,R]=(0,e.useState)(""),[E,h]=(0,e.useState)(null),[I,X]=(0,e.useState)(""),b=(0,e.useRef)(!1),A=(0,e.useRef)(!0);(0,e.useEffect)(()=>{if(!n){P("Login first to browse projects"),l(!1);return}let o=new AbortController,a=I.trim();return A.current?l(!0):a&&g(!0),m(!0),P(null),(async()=>{try{let t=n.cached??await n.resolve();if(!t){P("Login first to browse projects"),l(!1),m(!1),g(!1);return}let L=T(c),F=new k(L.tmsBaseUrl,t.username,t.access_key),f=!0,N=0,G=a?{signal:o.signal,name:a,perPage:10}:{signal:o.signal,perPage:10};for await(let y of F.listProjectsStream(G)){if(f&&(l(!1),g(!1),A.current=!1,f=!1),y.totalLoaded===0&&y.done&&N===0&&!a){b.current=!0,p("naming"),m(!1);return}let M=y.projects.map(j=>V(j.project_id,j.name,x));B(N===0?M:j=>[...j,...M]),N+=y.projects.length,y.done&&m(!1)}f&&(l(!1),m(!1),g(!1))}catch(t){if(t?.name==="AbortError")return;P(t instanceof Error?t.message:String(t)),l(!1),m(!1),g(!1)}})(),()=>o.abort()},[n,x,c,I]);let Y=(0,e.useCallback)(o=>{let a=o.trim();if(!a){h("Name cannot be empty");return}h(null),p("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let t=n.cached??await n.resolve();if(!t)throw new Error("Not authenticated");let L=T(c),f=await new k(L.tmsBaseUrl,t.username,t.access_key).createProject(a);w(f.id,f.name)}catch(t){h(t instanceof Error?t.message:String(t)),p("naming")}})()},[n,c,w]),z=(0,e.useCallback)(()=>{R(""),h(null),b.current?C():p("list")},[C]);return d==="naming"||d==="creating"?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(s,{color:i.orange,bold:!0,children:"Create new project"}),b.current&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.dim,children:"No projects yet \u2014 let's create one."})}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(s,{color:i.dim,children:"Name: "}),d==="naming"?(0,r.jsx)($,{value:v,onChange:o=>{R(o),E&&h(null)},onSubmit:Y,onCancel:z}):(0,r.jsx)(s,{children:v})]}),E&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.red,children:E})}),d==="creating"&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.dim,children:"Creating..."})}),d==="naming"&&(0,r.jsx)(_,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:b.current?"cancel":"back"})]}):(0,r.jsx)(U,{title:"Projects",items:q,loading:D,loadingMore:H,searching:J,preserveSelectionById:!0,onSearch:X,error:Q,itemNoun:"projects",onTab:()=>{b.current=!1,p("naming")},extraHint:"tab to create new",onSelect:o=>{let a=o.label.replace(` (${o.id})`,"");w(o.id,a)},onCancel:C})}export{V as a,se as b};
2
+ import{a as $}from"./chunk-YCCUBQY4.js";import{a as U}from"./chunk-PP4I2Z6M.js";import{a as k}from"./chunk-BPMSNGXQ.js";import{a as _}from"./chunk-PY4BWRR6.js";import{a as T}from"./chunk-5WZ2WOOM.js";import{y as i}from"./chunk-OWPQZP4C.js";import{a as O}from"./chunk-HCBYKLMW.js";import{a as u,b as s}from"./chunk-C44QQJR4.js";import{a as K}from"./chunk-6YGTRKDT.js";import{e as S}from"./chunk-UR6MHSHU.js";var e=S(K(),1);var r=S(O(),1);function V(n,x,c){return{id:n,label:`${x} (${n})`,isActive:n===c}}function se({resolver:n,currentProjectId:x,env:c,onSelect:w,onCancel:C}){let[q,B]=(0,e.useState)([]),[D,l]=(0,e.useState)(!0),[H,m]=(0,e.useState)(!1),[J,g]=(0,e.useState)(!1),[Q,P]=(0,e.useState)(null),[d,p]=(0,e.useState)("list"),[v,R]=(0,e.useState)(""),[E,h]=(0,e.useState)(null),[I,X]=(0,e.useState)(""),b=(0,e.useRef)(!1),A=(0,e.useRef)(!0);(0,e.useEffect)(()=>{if(!n){P("Login first to browse projects"),l(!1);return}let o=new AbortController,a=I.trim();return A.current?l(!0):a&&g(!0),m(!0),P(null),(async()=>{try{let t=n.cached??await n.resolve();if(!t){P("Login first to browse projects"),l(!1),m(!1),g(!1);return}let L=T(c),F=new k(L.tmsBaseUrl,t.username,t.access_key),f=!0,N=0,G=a?{signal:o.signal,name:a,perPage:10}:{signal:o.signal,perPage:10};for await(let y of F.listProjectsStream(G)){if(f&&(l(!1),g(!1),A.current=!1,f=!1),y.totalLoaded===0&&y.done&&N===0&&!a){b.current=!0,p("naming"),m(!1);return}let M=y.projects.map(j=>V(j.project_id,j.name,x));B(N===0?M:j=>[...j,...M]),N+=y.projects.length,y.done&&m(!1)}f&&(l(!1),m(!1),g(!1))}catch(t){if(t?.name==="AbortError")return;P(t instanceof Error?t.message:String(t)),l(!1),m(!1),g(!1)}})(),()=>o.abort()},[n,x,c,I]);let Y=(0,e.useCallback)(o=>{let a=o.trim();if(!a){h("Name cannot be empty");return}h(null),p("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let t=n.cached??await n.resolve();if(!t)throw new Error("Not authenticated");let L=T(c),f=await new k(L.tmsBaseUrl,t.username,t.access_key).createProject(a);w(f.id,f.name)}catch(t){h(t instanceof Error?t.message:String(t)),p("naming")}})()},[n,c,w]),z=(0,e.useCallback)(()=>{R(""),h(null),b.current?C():p("list")},[C]);return d==="naming"||d==="creating"?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(s,{color:i.orange,bold:!0,children:"Create new project"}),b.current&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.dim,children:"No projects yet \u2014 let's create one."})}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(s,{color:i.dim,children:"Name: "}),d==="naming"?(0,r.jsx)($,{value:v,onChange:o=>{R(o),E&&h(null)},onSubmit:Y,onCancel:z}):(0,r.jsx)(s,{children:v})]}),E&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.red,children:E})}),d==="creating"&&(0,r.jsx)(u,{marginTop:1,children:(0,r.jsx)(s,{color:i.dim,children:"Creating..."})}),d==="naming"&&(0,r.jsx)(_,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:b.current?"cancel":"back"})]}):(0,r.jsx)(U,{title:"Projects",items:q,loading:D,loadingMore:H,searching:J,preserveSelectionById:!0,onSearch:X,error:Q,itemNoun:"projects",onTab:()=>{b.current=!1,p("naming")},extraHint:"tab to create new",onSelect:o=>{let a=o.label.replace(` (${o.id})`,"");w(o.id,a)},onCancel:C})}export{V as a,se as b};
@@ -1,8 +1,8 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as K}from"./chunk-7U7HOEZO.js";import{a as U,b as Y,c as q}from"./chunk-KJQNAOOE.js";import{a as B}from"./chunk-KDNNMU7Q.js";import{d as j}from"./chunk-WESMQEPO.js";import{j as N,n as F,z as k}from"./chunk-IICT4VOU.js";import{a as L,b as V,c as G}from"./chunk-3UI5VTQS.js";import{F as I}from"./chunk-RDHWNSDP.js";import{f as v,g as x,i as H}from"./chunk-XLSOQLVT.js";function te(t,e,n,i,s){let f=n.rows.filter(u=>{let d=i.get(u.temp_ref);return d!==void 0&&d!=="reject"});if(f.length===0)return{record:null,errors:null};let o={version:1,read_basis:e.latestHash,source:{source_id:n.source_id,source_cid:e.heads.get(n.source_id)??""},use_cases:f.map(u=>u.uc)},p=new Map;for(let u of f){let d=i.get(u.temp_ref);typeof d=="object"?p.set(u.temp_ref,{resolution:"edited",edit:d.edited}):p.set(u.temp_ref,{resolution:u.uc.matches_existing&&u.uc.changed?"edited":"approved"})}let g=q(o,e,n.staged_source_cid);if(g.errors!==null)return{record:null,errors:g.errors};let r=g.proposal,l=o.source.source_cid?D(t,e,o.source.source_cid):null;if(l!==null){r=Y(r,l);let u=N(r,U(l),e);if(u.length>0)return{record:null,errors:[{code:"HELD_CITES_STALE",detail:"the source moved after this plan staged \u2014 its quotes no longer verify against the current head; re-run kane-cli maintain reconcile to re-stage"},...u]}}let m=`held-${(e.latestHash??"root").slice(-12)}-${f.length}`;return F({contextDir:t,graph:e,proposal:r,proposalId:m,verdicts:p,by:s,autoName:!0})}function Z(t,e,n=[]){let i=K(t,e),s=new Set,f=[],o=l=>{!l||s.has(l)||(s.add(l),f.push(y(t,l)))};for(let l of i.pairs)o(l.scenario),o(l.test);for(let[l,m]of i.verifies){o(l);for(let u of m)o(u)}if(n.length===0)return{stale_refs:f};let p=l=>`${String(l.props.source_id)}\0${String(l.props.anchor)}`,g=new Set;for(let{cid:l}of t.byLabel(v.USECASE))if(t.tipOf(l)===e)for(let m of t.edgesInto(l)){if(m.type!==x.DERIVES)continue;let u=m.props.claim;typeof u=="string"&&n.includes(u)&&g.add(p(m))}if(g.size===0)return{stale_refs:f};let r=new Set;for(let[l,m]of i.verifies)if(t.edgesInto(l).some(d=>d.type===x.DERIVES&&g.has(p(d)))){r.add(y(t,l));for(let d of m)r.add(y(t,d))}return{stale_refs:f,...r.size>0?{direct_refs:[...r]}:{}}}var X="this release plans changes only \u2014 blast-radius impact and drift meaning-checks are not measured, and REMOVE rows are never executed automatically",ne="suite untouched; graph updated";function M(t,e){return!t.superseded.has(e)&&t.trust.get(e)!=="archived"}function y(t,e,n=new Set){let i=t.nameOf.get(e);if(i!==void 0)return i;if(n.has(e))return e;n.add(e);for(let[s,f]of t.superseded){if(f!==e)continue;let o=y(t,s,n);if(o!==s)return o}return e}function C(t){return String(t).slice(0,19)}function A(t,e,n){let i=t.edgesFrom(e).find(s=>s.type===n);return i?t.tipOf(i.dst):null}function z(t,e){let n=t.nodeLabel.get(e);if(n===v.USECASE)return e;if(n===v.SCENARIO)return A(t,e,x.BELONGS_TO);if(n===v.AC){let i=A(t,e,x.SCOPED_TO);return i?t.nodeLabel.get(i)===v.USECASE?i:A(t,i,x.BELONGS_TO):null}if(n===v.TEST){let i=A(t,e,x.AUTOMATES);return i?A(t,i,x.BELONGS_TO):null}return null}function J(t,e){let n=[],i=new Map;for(let s of t.derivesInto(e))i.set(String(s.props.source_id),s);for(let[s,f]of i){let o=t.heads.get(s);if(o==null){n.push(`DERIVES pin ${s} @ ${C(f.props.source_cid)} \u2014 source retired`);continue}if(o!==f.props.source_cid){let p=t.convChains.get(s)?.chain;if(p&&p.includes(String(f.props.source_cid)))continue;n.push(`DERIVES pin ${s} @ ${C(f.props.source_cid)} \u2014 source head moved to ${C(o)}`)}}for(let s of t.edgesFrom(e))H(s.type)?.pin?.comparesTo==="dst_tip"&&t.superseded.has(s.dst)&&n.push(`${s.type} pin \u2192 ${y(t,s.dst)} \u2014 target superseded`);return n.join("; ")||"structural pin broken"}var se=new Set([v.USECASE,v.SCENARIO,v.AC,v.TEST]);function $(t,e){return t.ref<e.ref?-1:t.ref>e.ref?1:0}function D(t,e,n){let i=B(t,e,n);return i===null?null:i.toString("utf8")}function oe(t,e,n,i,s){let f=n.props.quote;if(typeof f=="string"&&f.length>0)return G(f,i);let o=String(n.props.source_cid);s.has(o)||s.set(o,D(t,e,o));let p=s.get(o);if(p===null)return!1;let g=V(p,String(n.props.anchor));return g===null?!1:g.split(`
2
+ import{b as K}from"./chunk-A55WPXDZ.js";import{a as U,b as Y,c as q}from"./chunk-KJQNAOOE.js";import{a as B}from"./chunk-KDNNMU7Q.js";import{d as j}from"./chunk-WESMQEPO.js";import{j as N,n as F,z as k}from"./chunk-IICT4VOU.js";import{a as L,b as V,c as G}from"./chunk-3UI5VTQS.js";import{F as I}from"./chunk-RDHWNSDP.js";import{f as v,g as x,i as H}from"./chunk-XLSOQLVT.js";function te(t,e,n,i,s){let f=n.rows.filter(u=>{let d=i.get(u.temp_ref);return d!==void 0&&d!=="reject"});if(f.length===0)return{record:null,errors:null};let o={version:1,read_basis:e.latestHash,source:{source_id:n.source_id,source_cid:e.heads.get(n.source_id)??""},use_cases:f.map(u=>u.uc)},p=new Map;for(let u of f){let d=i.get(u.temp_ref);typeof d=="object"?p.set(u.temp_ref,{resolution:"edited",edit:d.edited}):p.set(u.temp_ref,{resolution:u.uc.matches_existing&&u.uc.changed?"edited":"approved"})}let g=q(o,e,n.staged_source_cid);if(g.errors!==null)return{record:null,errors:g.errors};let r=g.proposal,l=o.source.source_cid?D(t,e,o.source.source_cid):null;if(l!==null){r=Y(r,l);let u=N(r,U(l),e);if(u.length>0)return{record:null,errors:[{code:"HELD_CITES_STALE",detail:"the source moved after this plan staged \u2014 its quotes no longer verify against the current head; re-run kane-cli maintain reconcile to re-stage"},...u]}}let m=`held-${(e.latestHash??"root").slice(-12)}-${f.length}`;return F({contextDir:t,graph:e,proposal:r,proposalId:m,verdicts:p,by:s,autoName:!0})}function Z(t,e,n=[]){let i=K(t,e),s=new Set,f=[],o=l=>{!l||s.has(l)||(s.add(l),f.push(y(t,l)))};for(let l of i.pairs)o(l.scenario),o(l.test);for(let[l,m]of i.verifies){o(l);for(let u of m)o(u)}if(n.length===0)return{stale_refs:f};let p=l=>`${String(l.props.source_id)}\0${String(l.props.anchor)}`,g=new Set;for(let{cid:l}of t.byLabel(v.USECASE))if(t.tipOf(l)===e)for(let m of t.edgesInto(l)){if(m.type!==x.DERIVES)continue;let u=m.props.claim;typeof u=="string"&&n.includes(u)&&g.add(p(m))}if(g.size===0)return{stale_refs:f};let r=new Set;for(let[l,m]of i.verifies)if(t.edgesInto(l).some(d=>d.type===x.DERIVES&&g.has(p(d)))){r.add(y(t,l));for(let d of m)r.add(y(t,d))}return{stale_refs:f,...r.size>0?{direct_refs:[...r]}:{}}}var X="this release plans changes only \u2014 blast-radius impact and drift meaning-checks are not measured, and REMOVE rows are never executed automatically",ne="suite untouched; graph updated";function M(t,e){return!t.superseded.has(e)&&t.trust.get(e)!=="archived"}function y(t,e,n=new Set){let i=t.nameOf.get(e);if(i!==void 0)return i;if(n.has(e))return e;n.add(e);for(let[s,f]of t.superseded){if(f!==e)continue;let o=y(t,s,n);if(o!==s)return o}return e}function C(t){return String(t).slice(0,19)}function A(t,e,n){let i=t.edgesFrom(e).find(s=>s.type===n);return i?t.tipOf(i.dst):null}function z(t,e){let n=t.nodeLabel.get(e);if(n===v.USECASE)return e;if(n===v.SCENARIO)return A(t,e,x.BELONGS_TO);if(n===v.AC){let i=A(t,e,x.SCOPED_TO);return i?t.nodeLabel.get(i)===v.USECASE?i:A(t,i,x.BELONGS_TO):null}if(n===v.TEST){let i=A(t,e,x.AUTOMATES);return i?A(t,i,x.BELONGS_TO):null}return null}function J(t,e){let n=[],i=new Map;for(let s of t.derivesInto(e))i.set(String(s.props.source_id),s);for(let[s,f]of i){let o=t.heads.get(s);if(o==null){n.push(`DERIVES pin ${s} @ ${C(f.props.source_cid)} \u2014 source retired`);continue}if(o!==f.props.source_cid){let p=t.convChains.get(s)?.chain;if(p&&p.includes(String(f.props.source_cid)))continue;n.push(`DERIVES pin ${s} @ ${C(f.props.source_cid)} \u2014 source head moved to ${C(o)}`)}}for(let s of t.edgesFrom(e))H(s.type)?.pin?.comparesTo==="dst_tip"&&t.superseded.has(s.dst)&&n.push(`${s.type} pin \u2192 ${y(t,s.dst)} \u2014 target superseded`);return n.join("; ")||"structural pin broken"}var se=new Set([v.USECASE,v.SCENARIO,v.AC,v.TEST]);function $(t,e){return t.ref<e.ref?-1:t.ref>e.ref?1:0}function D(t,e,n){let i=B(t,e,n);return i===null?null:i.toString("utf8")}function oe(t,e,n,i,s){let f=n.props.quote;if(typeof f=="string"&&f.length>0)return G(f,i);let o=String(n.props.source_cid);s.has(o)||s.set(o,D(t,e,o));let p=s.get(o);if(p===null)return!1;let g=V(p,String(n.props.anchor));return g===null?!1:g.split(`
3
3
  `).some(r=>r.trim().length>0&&i.includes(r.trim()))}function re(t,e,n){let i=L(String(e.props.anchor));if(i?.kind!=="img-part")return!1;let f=(t.mediaOf(String(e.props.source_cid)).images??[]).find(r=>r.ref===i.ref),o=f?.blob;if(o===void 0)return!1;let p=t.mediaOf(n).images??[];if(p.some(r=>r.blob===o))return!0;let g=f?.appearance;return g!==void 0&&p.filter(r=>r.appearance===g).length===1}var W=128*1024,Q=64*1024;function ie(t,e){let n=t.split(`
4
4
  `),i=e.split(`
5
5
  `),s=0;for(;s<n.length&&s<i.length&&n[s]===i[s];)s++;let f=n.length,o=i.length;for(;f>s&&o>s&&n[f-1]===i[o-1];)f--,o--;if(f===s&&o===s)return"";let p=n.slice(s,f),g=i.slice(s,o),l=ce(p,g,2e3),m=[];if(l===null)m.push(`@@ old L${s+1}-L${f} \u2192 new L${s+1}-L${o} @@`,...p.map(u=>`- ${u}`),...g.map(u=>`+ ${u}`));else{let u=l.map((a,h)=>a.op==="="?-1:h).filter(a=>a>=0),d=0;for(;d<u.length;){let a=d;for(;a+1<u.length&&u[a+1]-u[a]<=3;)a++;let h=Math.max(u[d]-1,0),R=Math.min(u[a]+1,l.length-1),b=l.slice(h,R+1),S=s+(b[0].ai??0)+1,_=s+(b[0].bi??0)+1,c=b.filter(E=>E.op!=="+").length,w=b.filter(E=>E.op!=="-").length;m.push(`@@ old L${S}-L${S+Math.max(c-1,0)} \u2192 new L${_}-L${_+Math.max(w-1,0)} @@`);for(let E of b)m.push(E.op==="="?` ${E.line}`:`${E.op} ${E.line}`);d=a+1}}return m.join(`
6
6
  `)}function ce(t,e,n){let i=t.length,s=e.length,f=Math.min(i+s,n),o=new Map([[1,0]]),p=[],g=!1;for(let u=0;u<=f&&!g;u++){p.push(new Map(o));for(let d=-u;d<=u;d+=2){let a=d===-u||d!==u&&(o.get(d-1)??0)<(o.get(d+1)??0)?o.get(d+1)??0:(o.get(d-1)??0)+1,h=a-d;for(;a<i&&h<s&&t[a]===e[h];)a++,h++;if(o.set(d,a),a>=i&&h>=s){g=!0;break}}}if(!g)return null;let r=i,l=s,m=[];for(let u=p.length-1;u>0;u--){let d=p[u],a=r-l,h=a===-u||a!==u&&(d.get(a-1)??0)<(d.get(a+1)??0)?a+1:a-1,R=d.get(h)??0,b=R-h;for(;r>R&&l>b;)m.push({op:"=",line:t[r-1],ai:r-1,bi:l-1}),r--,l--;u>0&&(r===R?(m.push({op:"+",line:e[l-1],ai:r,bi:l-1}),l--):(m.push({op:"-",line:t[r-1],ai:r-1,bi:l}),r--))}for(;r>0&&l>0;)m.push({op:"=",line:t[r-1],ai:r-1,bi:l-1}),r--,l--;for(;r>0;)m.push({op:"-",line:t[r-1],ai:r-1,bi:0}),r--;for(;l>0;)m.push({op:"+",line:e[l-1],ai:0,bi:l-1}),l--;return m.reverse()}function ae(t){let e=Buffer.byteLength(t,"utf8");if(e<=W+Q)return{diff:t,truncated:!1};let n=Buffer.from(t,"utf8"),i=W;for(;i>0&&(n[i]&192)===128;)i--;let s=e-Q;for(;s<e&&(n[s]&192)===128;)s++;let f=n.subarray(0,i).toString("utf8"),o=n.subarray(s).toString("utf8");return{diff:`${f}
7
7
  \u2026 [diff truncated: ${e-i-(e-s)} bytes omitted] \u2026
8
- ${o}`,truncated:!0}}function de(t,e){let n=k(t),i=n.heads.get(e);if(typeof i!="string")return null;let s=[];for(let d of I(t).records){let a=d.source_head_moves?.[e];a!==void 0&&a!==s[s.length-1]&&s.push(a)}let f=s.lastIndexOf(i),o=f>0?s[f-1]:null;if(typeof o!="string"||o===i)return null;let p=D(t,n,o),g=D(t,n,i);if(p===null||g===null)return null;let{diff:r,truncated:l}=ae(ie(p,g)),m=new Set,u=[];for(let d of n.edgesFrom(o))d.type!==x.DERIVES||n.nodeLabel.get(d.dst)!==v.USECASE||m.has(d.dst)||(m.add(d.dst),u.push({id:d.dst,title:String(n.getNode(d.dst)?.content.title??"")}));return{source_id:e,old_head:o,new_head:i,diff:r,...l?{truncated:!0}:{},prior_ucs:u}}function le(t,e,n){let i=t.getNode(e)?.content??{},s=t.getNode(n)?.content??{},o=[...new Set([...Object.keys(i),...Object.keys(s)])].sort().filter(p=>JSON.stringify(i[p])!==JSON.stringify(s[p]));return o.length>0?`updated: ${o.join(", ")}`:"updated"}function ue(t,e,n,i,s,f,o){let p=new Set((o?.rows??[]).map(a=>a.matched_cid).filter(a=>!!a)),g=[];for(let[a,h]of n.superseded)h===null||a===h||e.superseded.has(a)||n.nodeLabel.get(a)===v.USECASE&&g.push({kind:"MODIFY",ref:y(n,a),old_cid:a,new_cid:h,summary:le(n,a,h)});let r=f.map(a=>({kind:"ADD",ref:y(n,a),cid:a}));for(let a of o?.rows??[])a.kind==="MODIFY"&&a.matched_cid?g.push({kind:"MODIFY",ref:y(n,a.matched_cid),old_cid:a.matched_cid,new_cid:null,summary:`${a.why} (staged)`}):a.kind==="ADD"&&r.push({kind:"ADD",ref:a.title,cid:null});let l=[],m=D(t,n,s),u=new Map;for(let{cid:a}of n.byLabel(v.USECASE)){if(!M(n,a)||p.has(a))continue;let h=n.derivesInto(a),R=h.filter(_=>String(_.props.source_id)===i);R.length===0||R.some(_=>_.props.source_cid===s)||R.some(_=>{let c=String(_.props.anchor),w=L(c);return w?.kind==="img-whole"?!1:w?.kind==="img-part"?re(n,_,s):m!==null&&oe(t,n,_,m,u)})||h.some(_=>{let c=String(_.props.source_id);if(c===i)return!1;let w=n.heads.get(c);return w!=null})||l.push({kind:"ARCHIVE",ref:y(n,a),cid:a,why:`evidence decayed: no quote from ${i} relocates into @${C(s)}, no other live source, no fresh evidence this run`,impact:Z(n,n.tipOf(a))})}let d=(a,h)=>a.ref<h.ref?-1:a.ref>h.ref?1:0;return[...g.sort(d),...r.sort(d),...l.sort(d)]}function Re(t,e,n,i,s){let f=e.rows.find(d=>d.temp_ref===n);if(!f)return{ok:!1,message:`held item ${n} missing from the plan artifact`};let o=f,p=k(t);if(o.matched_cid){let d=p.tipOf(o.matched_cid);if(p.superseded.get(d)===null)return{ok:!1,message:`use-case for "${o.title}" was retired meanwhile \u2014 nothing to update`};d!==o.matched_cid&&(o={...o,matched_cid:d,uc:{...o.uc,matches_existing:{cid:d}}})}let g=s?{edited:s}:"approve",r=te(t,p,{source_id:e.source_id,...e.staged_source_cid!==void 0?{staged_source_cid:e.staged_source_cid}:{},rows:[o]},new Map([[o.temp_ref,g]]),i);if(r.errors)return{ok:!1,message:r.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")};let l=k(t),m=o.matched_cid?l.tipOf(o.matched_cid):r.record?.nodes.find(d=>d.label==="usecase")?.cid??r.record?.review[0]?.id;return{ok:!0,ref:m?y(l,m):o.title,kind:o.kind}}async function ye(t,e,n,i={}){let s=k(t),f=s.heads.get(e)??null,o=new Set(s.staleList().filter(c=>c.state==="stale").map(c=>c.cid)),p=await n.reingest(e);if(p.status==="unchanged"&&!i.resumeHeld)return{source_id:e,changed:!1,head:{status:p.status,before:f,after:p.cid},note:`nothing to reconcile \u2014 ${e} is unchanged`,skipped_arms:X,changeset:[],rows:[]};let g=i.resumeHeld?{minted:[],matched:[],held:i.resumeHeld}:await n.reextract(e),r=k(t),l=g.minted.map(c=>{let w=y(r,c);return{kind:"ADD",origin:"content-change",ref:w,reason:`new use-case extracted from ${e}`,provenance:`extraction commit \u2014 DERIVES ${e} @ ${C(p.cid)}`,action:`kane-cli design tests --use-case ${w}`}}),m=r.staleList().filter(c=>c.state==="stale"&&!o.has(c.cid)&&M(r,c.cid)).map(c=>c.cid),u=m.map(c=>{let w=y(r,c),E=se.has(r.nodeLabel.get(c)??"");return{kind:"MODIFY",origin:"structural-stale",ref:w,reason:"stale (structural)",provenance:J(r,c),action:E?`kane-cli maintain evolve ${w}`:`kane-cli design explain ${w}`}}),d=[],a=[];for(let c of g.held?.rows??[])if(c.kind==="ADD")d.push({kind:"ADD",origin:"content-change",ref:c.title,held_ref:c.temp_ref,reason:`${c.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${e} @ ${C(p.cid)}`,action:"approve to commit + design"});else{let w=c.matched_cid?r.tipOf(c.matched_cid):null,E=w?r.getNode(w)?.content.criteria??[]:[],T=(c.uc.updated?.criteria??[]).map(O=>typeof O=="string"?O:O.text),ee=[...T.filter(O=>!E.includes(O)),...c.uc.updated?.criteria!==void 0?E.filter(O=>!T.includes(O)):[]],P=w?Z(r,w,ee):void 0;a.push({kind:"MODIFY",origin:"content-change",ref:c.matched_cid?y(r,c.matched_cid):c.title,held_ref:c.temp_ref,reason:`${c.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${e} @ ${C(p.cid)}`,action:"approve to commit the updated version (old\u2192new redirect)",...P?{impact:P}:{}})}let h=new Set;for(let c of[...g.minted,...g.matched])h.add(r.tipOf(c));for(let c of g.held?.rows??[])c.matched_cid&&h.add(r.tipOf(c.matched_cid));for(let c of m){let w=z(r,r.tipOf(c));w&&r.nodeLabel.get(w)===v.USECASE&&h.add(r.tipOf(w))}let R=[];for(let c of await j(r,"design")){if(c.kind!=="no-verifies")continue;let w=r.resolve(c.ref);if(!w)continue;let E=z(r,w.tip);!E||!h.has(r.tipOf(E))||R.push({kind:"ADD",origin:"content-change",ref:c.ref,reason:c.why,provenance:`gaps engine (design) \u2014 uncovered AC of touched use-case ${y(r,E)}`,action:c.ready_command})}let b=[];for(let{cid:c}of r.byLabel(v.USECASE))M(r,c)&&r.stale(c)==="orphaned"&&b.push({kind:"REMOVE",ref:y(r,c),reason:"orphaned \u2014 no live source evidences this use-case",provenance:J(r,c),action:"plan-only \u2014 REMOVE is not executed in this release"});let S=new Set,_=[...l.sort($),...d.sort($),...R.sort($),...a.sort($),...u.sort($),...b.sort($)].filter(c=>{let w=`${c.kind}\0${c.ref}`;return S.has(w)?!1:(S.add(w),!0)});return{source_id:e,changed:!0,head:{status:p.status,before:f,after:p.cid},note:ne,skipped_arms:X,changeset:ue(t,s,r,e,p.cid,g.minted,g.held),rows:_,...g.held?{held:g.held}:{}}}function be(t,e){return async n=>{let{ingestFile:i}=await import("./ingest-OSNNM3DH.js"),{convertPdf:s}=await import("./pdf-convert-RLXSXFWN.js"),{convertDocx:f}=await import("./docx-convert-SQRTF7XS.js"),o=await i({contextDir:t,filePath:e,asId:n,converters:{pdf:s,docx:f}});return{status:o.status,cid:o.cid}}}function xe(t,e,n,i){return async()=>{let f=(i??(await import("./dispatch-SXS276ZT.js")).findProvider)(e);if(!f)throw new Error(`the remote re-ingest failed \u2014 no provider matches '${e}'`);let o=await f.ingest(e,void 0,{out:n.out,err:n.err,confirm:async()=>!0,isTTY:!1},t,void 0);if(o.code!==0||!o.result)throw new Error("the remote re-ingest failed \u2014 fix the reported problem and re-run");return{status:o.result.status,cid:o.result.source_cid}}}function ke(t,e={}){return async n=>{let i=[],[{runExtract:s},{resolveAgentAuthEnv:f},{runAgent:o},{preflightTurn:p}]=await Promise.all([import("./run-YWKZGZVL.js"),import("./spawner-ABB7B5CQ.js"),import("./bridge-UMXGHAJF.js"),import("./turn-preflight-JGYT7LXP.js")]),g=await f(),r=new Set(k(t).byLabel(v.USECASE).map(S=>S.cid)),l=de(t,n)??void 0,m=0,u=await s({mode:"override",source:n,...l?{changeContext:l}:{}},{contextDir:t,agent:o,preflightTurn:()=>p(g),ask:async()=>[],review:async S=>{if(!e.stage)return new Map(S.map(c=>[c.temp_ref,{resolution:c.matches_existing&&c.changed?"edited":"skipped"}]));let _=new Map;for(let c of S){if(c.matches_existing&&!c.changed){_.set(c.temp_ref,{resolution:"skipped"});continue}i.push({kind:c.matches_existing?"MODIFY":"ADD",temp_ref:c.temp_ref,title:c.title,why:c.matches_existing?`updated: ${Object.keys(c.updated??{}).join(", ")||"content"}`:`newly extracted from ${n}`,...c.matches_existing?{matched_cid:c.matches_existing.cid,updated:c.updated}:{},uc:c}),_.set(c.temp_ref,{resolution:"rejected"})}return _},confirmStale:async()=>!1,out:S=>e.hostOut?.(S),progress:S=>e.hostProgress?.(S),emit:S=>{S.type==="commit"&&typeof S.assumed=="number"&&(m+=S.assumed),e.hostEmit?.(S)},isTTY:!1,auth:g});if(u!==0)throw new Error(`reconcile: re-extract of ${n} failed (exit ${u})`);let d=k(t),a=d.heads.get(n),h=[],R=[];if(typeof a=="string"){let S=new Set;for(let _ of d.edgesFrom(a))_.type!==x.DERIVES||d.nodeLabel.get(_.dst)!==v.USECASE||S.has(_.dst)||(S.add(_.dst),!(e.stage&&d.trust.get(_.dst)==="archived")&&(r.has(_.dst)?R:h).push(_.dst))}let b=k(t).heads.get(n);return{minted:h,matched:R,defaultsTaken:m,...e.stage?{held:{source_id:n,...b!=null?{staged_source_cid:b}:{},rows:i}}:{}}}}export{te as a,Z as b,X as c,ne as d,M as e,z as f,se as g,ie as h,ae as i,de as j,Re as k,ye as l,be as m,xe as n,ke as o};
8
+ ${o}`,truncated:!0}}function de(t,e){let n=k(t),i=n.heads.get(e);if(typeof i!="string")return null;let s=[];for(let d of I(t).records){let a=d.source_head_moves?.[e];a!==void 0&&a!==s[s.length-1]&&s.push(a)}let f=s.lastIndexOf(i),o=f>0?s[f-1]:null;if(typeof o!="string"||o===i)return null;let p=D(t,n,o),g=D(t,n,i);if(p===null||g===null)return null;let{diff:r,truncated:l}=ae(ie(p,g)),m=new Set,u=[];for(let d of n.edgesFrom(o))d.type!==x.DERIVES||n.nodeLabel.get(d.dst)!==v.USECASE||m.has(d.dst)||(m.add(d.dst),u.push({id:d.dst,title:String(n.getNode(d.dst)?.content.title??"")}));return{source_id:e,old_head:o,new_head:i,diff:r,...l?{truncated:!0}:{},prior_ucs:u}}function le(t,e,n){let i=t.getNode(e)?.content??{},s=t.getNode(n)?.content??{},o=[...new Set([...Object.keys(i),...Object.keys(s)])].sort().filter(p=>JSON.stringify(i[p])!==JSON.stringify(s[p]));return o.length>0?`updated: ${o.join(", ")}`:"updated"}function ue(t,e,n,i,s,f,o){let p=new Set((o?.rows??[]).map(a=>a.matched_cid).filter(a=>!!a)),g=[];for(let[a,h]of n.superseded)h===null||a===h||e.superseded.has(a)||n.nodeLabel.get(a)===v.USECASE&&g.push({kind:"MODIFY",ref:y(n,a),old_cid:a,new_cid:h,summary:le(n,a,h)});let r=f.map(a=>({kind:"ADD",ref:y(n,a),cid:a}));for(let a of o?.rows??[])a.kind==="MODIFY"&&a.matched_cid?g.push({kind:"MODIFY",ref:y(n,a.matched_cid),old_cid:a.matched_cid,new_cid:null,summary:`${a.why} (staged)`}):a.kind==="ADD"&&r.push({kind:"ADD",ref:a.title,cid:null});let l=[],m=D(t,n,s),u=new Map;for(let{cid:a}of n.byLabel(v.USECASE)){if(!M(n,a)||p.has(a))continue;let h=n.derivesInto(a),R=h.filter(_=>String(_.props.source_id)===i);R.length===0||R.some(_=>_.props.source_cid===s)||R.some(_=>{let c=String(_.props.anchor),w=L(c);return w?.kind==="img-whole"?!1:w?.kind==="img-part"?re(n,_,s):m!==null&&oe(t,n,_,m,u)})||h.some(_=>{let c=String(_.props.source_id);if(c===i)return!1;let w=n.heads.get(c);return w!=null})||l.push({kind:"ARCHIVE",ref:y(n,a),cid:a,why:`evidence decayed: no quote from ${i} relocates into @${C(s)}, no other live source, no fresh evidence this run`,impact:Z(n,n.tipOf(a))})}let d=(a,h)=>a.ref<h.ref?-1:a.ref>h.ref?1:0;return[...g.sort(d),...r.sort(d),...l.sort(d)]}function Re(t,e,n,i,s){let f=e.rows.find(d=>d.temp_ref===n);if(!f)return{ok:!1,message:`held item ${n} missing from the plan artifact`};let o=f,p=k(t);if(o.matched_cid){let d=p.tipOf(o.matched_cid);if(p.superseded.get(d)===null)return{ok:!1,message:`use-case for "${o.title}" was retired meanwhile \u2014 nothing to update`};d!==o.matched_cid&&(o={...o,matched_cid:d,uc:{...o.uc,matches_existing:{cid:d}}})}let g=s?{edited:s}:"approve",r=te(t,p,{source_id:e.source_id,...e.staged_source_cid!==void 0?{staged_source_cid:e.staged_source_cid}:{},rows:[o]},new Map([[o.temp_ref,g]]),i);if(r.errors)return{ok:!1,message:r.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")};let l=k(t),m=o.matched_cid?l.tipOf(o.matched_cid):r.record?.nodes.find(d=>d.label==="usecase")?.cid??r.record?.review[0]?.id;return{ok:!0,ref:m?y(l,m):o.title,kind:o.kind}}async function ye(t,e,n,i={}){let s=k(t),f=s.heads.get(e)??null,o=new Set(s.staleList().filter(c=>c.state==="stale").map(c=>c.cid)),p=await n.reingest(e);if(p.status==="unchanged"&&!i.resumeHeld)return{source_id:e,changed:!1,head:{status:p.status,before:f,after:p.cid},note:`nothing to reconcile \u2014 ${e} is unchanged`,skipped_arms:X,changeset:[],rows:[]};let g=i.resumeHeld?{minted:[],matched:[],held:i.resumeHeld}:await n.reextract(e),r=k(t),l=g.minted.map(c=>{let w=y(r,c);return{kind:"ADD",origin:"content-change",ref:w,reason:`new use-case extracted from ${e}`,provenance:`extraction commit \u2014 DERIVES ${e} @ ${C(p.cid)}`,action:`kane-cli design tests --use-case ${w}`}}),m=r.staleList().filter(c=>c.state==="stale"&&!o.has(c.cid)&&M(r,c.cid)).map(c=>c.cid),u=m.map(c=>{let w=y(r,c),E=se.has(r.nodeLabel.get(c)??"");return{kind:"MODIFY",origin:"structural-stale",ref:w,reason:"stale (structural)",provenance:J(r,c),action:E?`kane-cli maintain evolve ${w}`:`kane-cli design explain ${w}`}}),d=[],a=[];for(let c of g.held?.rows??[])if(c.kind==="ADD")d.push({kind:"ADD",origin:"content-change",ref:c.title,held_ref:c.temp_ref,reason:`${c.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${e} @ ${C(p.cid)}`,action:"approve to commit + design"});else{let w=c.matched_cid?r.tipOf(c.matched_cid):null,E=w?r.getNode(w)?.content.criteria??[]:[],T=(c.uc.updated?.criteria??[]).map(O=>typeof O=="string"?O:O.text),ee=[...T.filter(O=>!E.includes(O)),...c.uc.updated?.criteria!==void 0?E.filter(O=>!T.includes(O)):[]],P=w?Z(r,w,ee):void 0;a.push({kind:"MODIFY",origin:"content-change",ref:c.matched_cid?y(r,c.matched_cid):c.title,held_ref:c.temp_ref,reason:`${c.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${e} @ ${C(p.cid)}`,action:"approve to commit the updated version (old\u2192new redirect)",...P?{impact:P}:{}})}let h=new Set;for(let c of[...g.minted,...g.matched])h.add(r.tipOf(c));for(let c of g.held?.rows??[])c.matched_cid&&h.add(r.tipOf(c.matched_cid));for(let c of m){let w=z(r,r.tipOf(c));w&&r.nodeLabel.get(w)===v.USECASE&&h.add(r.tipOf(w))}let R=[];for(let c of await j(r,"design")){if(c.kind!=="no-verifies")continue;let w=r.resolve(c.ref);if(!w)continue;let E=z(r,w.tip);!E||!h.has(r.tipOf(E))||R.push({kind:"ADD",origin:"content-change",ref:c.ref,reason:c.why,provenance:`gaps engine (design) \u2014 uncovered AC of touched use-case ${y(r,E)}`,action:c.ready_command})}let b=[];for(let{cid:c}of r.byLabel(v.USECASE))M(r,c)&&r.stale(c)==="orphaned"&&b.push({kind:"REMOVE",ref:y(r,c),reason:"orphaned \u2014 no live source evidences this use-case",provenance:J(r,c),action:"plan-only \u2014 REMOVE is not executed in this release"});let S=new Set,_=[...l.sort($),...d.sort($),...R.sort($),...a.sort($),...u.sort($),...b.sort($)].filter(c=>{let w=`${c.kind}\0${c.ref}`;return S.has(w)?!1:(S.add(w),!0)});return{source_id:e,changed:!0,head:{status:p.status,before:f,after:p.cid},note:ne,skipped_arms:X,changeset:ue(t,s,r,e,p.cid,g.minted,g.held),rows:_,...g.held?{held:g.held}:{}}}function be(t,e){return async n=>{let{ingestFile:i}=await import("./ingest-OSNNM3DH.js"),{convertPdf:s}=await import("./pdf-convert-RLXSXFWN.js"),{convertDocx:f}=await import("./docx-convert-SQRTF7XS.js"),o=await i({contextDir:t,filePath:e,asId:n,converters:{pdf:s,docx:f}});return{status:o.status,cid:o.cid}}}function xe(t,e,n,i){return async()=>{let f=(i??(await import("./dispatch-GJ7RVYPK.js")).findProvider)(e);if(!f)throw new Error(`the remote re-ingest failed \u2014 no provider matches '${e}'`);let o=await f.ingest(e,void 0,{out:n.out,err:n.err,confirm:async()=>!0,isTTY:!1},t,void 0);if(o.code!==0||!o.result)throw new Error("the remote re-ingest failed \u2014 fix the reported problem and re-run");return{status:o.result.status,cid:o.result.source_cid}}}function ke(t,e={}){return async n=>{let i=[],[{runExtract:s},{resolveAgentAuthEnv:f},{runAgent:o},{preflightTurn:p}]=await Promise.all([import("./run-DVBOAY7S.js"),import("./spawner-XHE7OXNW.js"),import("./bridge-VNFL4T6K.js"),import("./turn-preflight-JGYT7LXP.js")]),g=await f(),r=new Set(k(t).byLabel(v.USECASE).map(S=>S.cid)),l=de(t,n)??void 0,m=0,u=await s({mode:"override",source:n,...l?{changeContext:l}:{}},{contextDir:t,agent:o,preflightTurn:()=>p(g),ask:async()=>[],review:async S=>{if(!e.stage)return new Map(S.map(c=>[c.temp_ref,{resolution:c.matches_existing&&c.changed?"edited":"skipped"}]));let _=new Map;for(let c of S){if(c.matches_existing&&!c.changed){_.set(c.temp_ref,{resolution:"skipped"});continue}i.push({kind:c.matches_existing?"MODIFY":"ADD",temp_ref:c.temp_ref,title:c.title,why:c.matches_existing?`updated: ${Object.keys(c.updated??{}).join(", ")||"content"}`:`newly extracted from ${n}`,...c.matches_existing?{matched_cid:c.matches_existing.cid,updated:c.updated}:{},uc:c}),_.set(c.temp_ref,{resolution:"rejected"})}return _},confirmStale:async()=>!1,out:S=>e.hostOut?.(S),progress:S=>e.hostProgress?.(S),emit:S=>{S.type==="commit"&&typeof S.assumed=="number"&&(m+=S.assumed),e.hostEmit?.(S)},isTTY:!1,auth:g});if(u!==0)throw new Error(`reconcile: re-extract of ${n} failed (exit ${u})`);let d=k(t),a=d.heads.get(n),h=[],R=[];if(typeof a=="string"){let S=new Set;for(let _ of d.edgesFrom(a))_.type!==x.DERIVES||d.nodeLabel.get(_.dst)!==v.USECASE||S.has(_.dst)||(S.add(_.dst),!(e.stage&&d.trust.get(_.dst)==="archived")&&(r.has(_.dst)?R:h).push(_.dst))}let b=k(t).heads.get(n);return{minted:h,matched:R,defaultsTaken:m,...e.stage?{held:{source_id:n,...b!=null?{staged_source_cid:b}:{},rows:i}}:{}}}}export{te as a,Z as b,X as c,ne as d,M as e,z as f,se as g,ie as h,ae as i,de as j,Re as k,ye as l,be as m,xe as n,ke as o};
@@ -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-IKB2JKMA.js";import{a as B}from"./chunk-BPMSNGXQ.js";import{a as R}from"./chunk-GIC56KI3.js";import{a as k}from"./chunk-VIYV6NIW.js";import{y as c}from"./chunk-PHR2OSWD.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-PP4I2Z6M.js";import{a as B}from"./chunk-BPMSNGXQ.js";import{a as R}from"./chunk-PY4BWRR6.js";import{a as k}from"./chunk-5WZ2WOOM.js";import{y as c}from"./chunk-OWPQZP4C.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};