@testmuai/kane-cli 0.8.4 → 0.8.5

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 (161) hide show
  1. package/dist/{ChatSurface-H26E7DM6.js → ChatSurface-HAIVTS4J.js} +1 -1
  2. package/dist/{ChromeProfilePicker-USUPENU2.js → ChromeProfilePicker-5ILSVC2K.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-ZIAZ2M2U.js → CliFeedbackPrompt-LFKEYMKP.js} +1 -1
  4. package/dist/{CliUploadProgress-LEOJTXHT.js → CliUploadProgress-Y7ITY2I7.js} +1 -1
  5. package/dist/{ConfigView-JBIQPG7O.js → ConfigView-OECNNCXC.js} +1 -1
  6. package/dist/{EvidenceViewOffer-IWQ6Q2CI.js → EvidenceViewOffer-FODRAS6Z.js} +1 -1
  7. package/dist/FolderPicker-5U3RHHBE.js +2 -0
  8. package/dist/{InfoBox-ORHNXPET.js → InfoBox-HWMHNWPM.js} +1 -1
  9. package/dist/{LinksBox-6SKDUB5T.js → LinksBox-TAGYCFFO.js} +1 -1
  10. package/dist/{ProfilesView-Y5GTLDJY.js → ProfilesView-QJBR3RCM.js} +1 -1
  11. package/dist/{ProjectPicker-WDCMKWNQ.js → ProjectPicker-PP75ILZU.js} +1 -1
  12. package/dist/{SaveSessionPrompt-I4KLFESC.js → SaveSessionPrompt-UCRET3II.js} +1 -1
  13. package/dist/SingleShotApp-XWOPGLKZ.js +2 -0
  14. package/dist/{SummaryBox-QWKW5FHK.js → SummaryBox-SLM3OFS2.js} +1 -1
  15. package/dist/TestMdRunView-6BY3IUH5.js +2 -0
  16. package/dist/{TestrunEvidenceTable-ENJJ2GIW.js → TestrunEvidenceTable-PTIBYAXO.js} +1 -1
  17. package/dist/{WhoamiView-H6M536AY.js → WhoamiView-WPHMNYUV.js} +1 -1
  18. package/dist/{app-download-PSRQWDVW.js → app-download-GYQYLGT3.js} +1 -1
  19. package/dist/{auth-JVH2EHK2.js → auth-3DLNMZC2.js} +1 -1
  20. package/dist/{binary-YTQJP2FG.js → binary-XJ3RF3VO.js} +1 -1
  21. package/dist/{bind-OUXCFLSE.js → bind-2N4Q6YKH.js} +2 -2
  22. package/dist/{bootstrap-3NEI7O6I.js → bootstrap-5IHKW5SE.js} +1 -1
  23. package/dist/bridge-LOBTHY3P.js +2 -0
  24. package/dist/{changelog-WDKG4WCV.js → changelog-WCCTI47M.js} +1 -1
  25. package/dist/{chunk-BXRZGISN.js → chunk-2K2BX23I.js} +1 -1
  26. package/dist/{chunk-W75AVBFG.js → chunk-2WSOPZJU.js} +1 -1
  27. package/dist/{chunk-TXH2KG7U.js → chunk-35EUIBYJ.js} +1 -1
  28. package/dist/{chunk-NEHX45NQ.js → chunk-3AJ3QSF5.js} +11 -11
  29. package/dist/{chunk-66RJPH73.js → chunk-4D3DNCQY.js} +1 -1
  30. package/dist/{chunk-XHNPNYJP.js → chunk-4UMQDH52.js} +1 -1
  31. package/dist/{chunk-5HYXTFGB.js → chunk-5NSYHRDN.js} +1 -1
  32. package/dist/{chunk-BWSL2KQQ.js → chunk-5S46D5AJ.js} +1 -1
  33. package/dist/{chunk-PWFZZWYU.js → chunk-66BSTNLD.js} +1 -1
  34. package/dist/{chunk-UTIGOLON.js → chunk-6BTZ2Q4P.js} +1 -1
  35. package/dist/{chunk-BDUCWZYO.js → chunk-6DTWVLSJ.js} +1 -1
  36. package/dist/{chunk-NDAAY2RL.js → chunk-7JUUNZQP.js} +1 -1
  37. package/dist/chunk-7PADFQ5S.js +71 -0
  38. package/dist/{chunk-RN3YHD4S.js → chunk-AJPLHW4T.js} +1 -1
  39. package/dist/{chunk-DYGUHGZ6.js → chunk-AMULIFC5.js} +1 -1
  40. package/dist/{chunk-A6TJUSOS.js → chunk-BAL7E4OH.js} +1 -1
  41. package/dist/{chunk-7HXZZ3VA.js → chunk-BG66IAO6.js} +1 -1
  42. package/dist/{chunk-QBF5FJVL.js → chunk-BJHII5SD.js} +1 -1
  43. package/dist/chunk-BVKDHHPK.js +5 -0
  44. package/dist/chunk-CCUGKBIH.js +2 -0
  45. package/dist/{chunk-UONRTWLU.js → chunk-CGYSFLM2.js} +1 -1
  46. package/dist/{chunk-7LP4X25A.js → chunk-CNNJ4U2L.js} +1 -1
  47. package/dist/{chunk-QWDFFEEJ.js → chunk-DCUT3GJA.js} +1 -1
  48. package/dist/{chunk-2HT3RYKJ.js → chunk-DJ7T7BMV.js} +1 -1
  49. package/dist/{chunk-PRLTUEKP.js → chunk-E3BXNQYE.js} +1 -1
  50. package/dist/{chunk-U55NUF4E.js → chunk-EFRJNPBZ.js} +2 -2
  51. package/dist/chunk-EKCGZXZE.js +2 -0
  52. package/dist/{chunk-BGMI5PH4.js → chunk-FDWEL5HR.js} +1 -1
  53. package/dist/chunk-FRSHEJUS.js +2 -0
  54. package/dist/{chunk-SFXQFUM6.js → chunk-FTZPWXF7.js} +1 -1
  55. package/dist/{chunk-62WYSEAT.js → chunk-G4AFOZKU.js} +1 -1
  56. package/dist/{chunk-L4EDLDLZ.js → chunk-GYF4CH62.js} +2 -2
  57. package/dist/{chunk-DWWAIXVZ.js → chunk-GZ4X53ZA.js} +2 -2
  58. package/dist/{chunk-PQWSHTSH.js → chunk-HFCDUFV3.js} +1 -1
  59. package/dist/{chunk-YB73T7QH.js → chunk-HQWLSA5M.js} +1 -1
  60. package/dist/{chunk-KAMJ7U4M.js → chunk-JJWQUQJ2.js} +1 -1
  61. package/dist/{chunk-OVLCJ2VX.js → chunk-JN2DP4R2.js} +1 -1
  62. package/dist/{chunk-VYYTENPY.js → chunk-JRQKUQWL.js} +1 -1
  63. package/dist/{chunk-IXTFWIQ6.js → chunk-K2QV7FGP.js} +1 -1
  64. package/dist/{chunk-GJED4QGF.js → chunk-K7UYWAZH.js} +1 -1
  65. package/dist/{chunk-55NSNWM5.js → chunk-KBMQGNKO.js} +9 -9
  66. package/dist/{chunk-35L2QXWP.js → chunk-KWKUMBHS.js} +2 -2
  67. package/dist/{chunk-52GWEKFD.js → chunk-KX2GOJ4C.js} +2 -2
  68. package/dist/{chunk-BCCWICSS.js → chunk-LA2EMSHE.js} +1 -1
  69. package/dist/{chunk-N7N222VC.js → chunk-M335FQYJ.js} +2 -2
  70. package/dist/{chunk-HHHNQW5Z.js → chunk-MJ56GUKS.js} +1 -1
  71. package/dist/{chunk-NEAMQMYH.js → chunk-MUGMUKSZ.js} +1 -1
  72. package/dist/{chunk-HXSEA7JS.js → chunk-NHOHQBIF.js} +1 -1
  73. package/dist/{chunk-KUYJ6FEN.js → chunk-NLECZCMZ.js} +1 -1
  74. package/dist/{chunk-7HPEHQHH.js → chunk-NYSMQ7UY.js} +1 -1
  75. package/dist/{chunk-DXJKMZEC.js → chunk-O3AY6JHJ.js} +1 -1
  76. package/dist/{chunk-OSB32HJE.js → chunk-OWTEHU6B.js} +1 -1
  77. package/dist/{chunk-A3PGLDQY.js → chunk-PB3GADUD.js} +1 -1
  78. package/dist/{chunk-YBX2SQ5R.js → chunk-PCOSE5SW.js} +2 -2
  79. package/dist/{chunk-ZI6W65E3.js → chunk-PEI2566X.js} +1 -1
  80. package/dist/{chunk-PSWB3BWQ.js → chunk-PQUMOFT5.js} +1 -1
  81. package/dist/chunk-PUFJEU46.js +2 -0
  82. package/dist/{chunk-4CHO7SAT.js → chunk-PWYEOBXV.js} +1 -1
  83. package/dist/{chunk-VBCIDWSK.js → chunk-Q6JHBDW2.js} +1 -1
  84. package/dist/{chunk-JR46A564.js → chunk-R7OGNE3W.js} +1 -1
  85. package/dist/{chunk-A4XJUWAQ.js → chunk-RY6TFVAX.js} +1 -1
  86. package/dist/{chunk-ZK57J37M.js → chunk-T3XDMR5B.js} +1 -1
  87. package/dist/{chunk-N5JHMCRU.js → chunk-T5LKD2OB.js} +1 -1
  88. package/dist/{chunk-L77ZOU4N.js → chunk-TCK3QMKY.js} +1 -1
  89. package/dist/{chunk-GSYJUHRK.js → chunk-TJZMYU2W.js} +1 -1
  90. package/dist/{chunk-DZJQNL66.js → chunk-UX3KPYTI.js} +1 -1
  91. package/dist/{chunk-BSCMUMSV.js → chunk-VT2XNEOD.js} +3 -3
  92. package/dist/{chunk-J27JJWMT.js → chunk-W27F2NWA.js} +1 -1
  93. package/dist/{chunk-JT7I6OST.js → chunk-WLOGO44E.js} +1 -1
  94. package/dist/{chunk-6CR2HTIM.js → chunk-WYST42WI.js} +1 -1
  95. package/dist/{chunk-SIH6JG7S.js → chunk-YFLKS4UV.js} +3 -3
  96. package/dist/{chunk-JCILRPOM.js → chunk-Z2T7E5HM.js} +2 -2
  97. package/dist/{chunk-JRADU3PO.js → chunk-ZFZ7YXEU.js} +1 -1
  98. package/dist/{chunk-7VTYRTEJ.js → chunk-ZIRMSWKS.js} +1 -1
  99. package/dist/{config-SFM45WCV.js → config-OKTAPFOT.js} +1 -1
  100. package/dist/{credentials-3CENDBPH.js → credentials-SO3DSQEM.js} +1 -1
  101. package/dist/{deps-bundle-P37ZJDXC.js → deps-bundle-FRM65BQO.js} +1 -1
  102. package/dist/{deps-resolve-VSICFRWU.js → deps-resolve-RPZORKUN.js} +1 -1
  103. package/dist/{dispatch-HDGQAEWN.js → dispatch-OZRMWY25.js} +1 -1
  104. package/dist/doctor-VWGEQYBB.js +2 -0
  105. package/dist/{evidence-ABYJOIV2.js → evidence-5AUZMKE3.js} +1 -1
  106. package/dist/{evolve-cmd-MROTNJIV.js → evolve-cmd-TWYJL4EG.js} +1 -1
  107. package/dist/{extract-bind-LBZMEDUK.js → extract-bind-EW7XUDLQ.js} +2 -2
  108. package/dist/{extract-cmd-K4KBPMB7.js → extract-cmd-HOVGMBGM.js} +1 -1
  109. package/dist/{generate-headless-EBMWSLTR.js → generate-headless-FYTJULPG.js} +2 -2
  110. package/dist/index.js +163 -145
  111. package/dist/{ingest-cmd-ULEWNGCI.js → ingest-cmd-RJLTFNMN.js} +1 -1
  112. package/dist/install-46S4VOZ4.js +2 -0
  113. package/dist/{interactive-bind-IYAJN45L.js → interactive-bind-PSEYAL54.js} +3 -3
  114. package/dist/{list-commands-YPBJNGCE.js → list-commands-2SVSEAP6.js} +1 -1
  115. package/dist/login-flow-U43QVFPH.js +2 -0
  116. package/dist/{mobile-prompts-LHUYRSV7.js → mobile-prompts-T6HZ2YLY.js} +1 -1
  117. package/dist/{persist-recorded-session-KCXYXSQG.js → persist-recorded-session-O2NCYTSD.js} +1 -1
  118. package/dist/pipeline-BHEA7ODT.js +2 -0
  119. package/dist/prepare-target-27UN4KNO.js +2 -0
  120. package/dist/{reconcile-cmd-TSQDYEUT.js → reconcile-cmd-FU3JIHTO.js} +1 -1
  121. package/dist/{reconcile-deps-ETMGIQNM.js → reconcile-deps-SUKZA2FL.js} +2 -2
  122. package/dist/{reconcile-engine-TLFTAOTZ.js → reconcile-engine-ILL4M3NW.js} +1 -1
  123. package/dist/{recording-banner-ACOLKL4K.js → recording-banner-5VXVKCV4.js} +1 -1
  124. package/dist/{registry-3Q6PNWCK.js → registry-BKV3EDTK.js} +1 -1
  125. package/dist/replay-policy-CVQ6OJX5.js +2 -0
  126. package/dist/{require-project-folder-5KWTJAXN.js → require-project-folder-2IO6IX5W.js} +1 -1
  127. package/dist/{resolve-run-intent-L2I7G55O.js → resolve-run-intent-ZML3HKG7.js} +1 -1
  128. package/dist/{resolver-NRU6HGTL.js → resolver-CBTWTZZR.js} +1 -1
  129. package/dist/{run-RHLRZCV5.js → run-EXIYK6PU.js} +1 -1
  130. package/dist/{run-T53Z5TCY.js → run-R7GND73C.js} +1 -1
  131. package/dist/{run-test-md-JYDYT3XF.js → run-test-md-664ASWRQ.js} +2 -2
  132. package/dist/{skill-installer-NWF53JAB.js → skill-installer-QLQK4JJE.js} +1 -1
  133. package/dist/{spawner-LKYUMXSO.js → spawner-ANLF7OX3.js} +1 -1
  134. package/dist/tcg-generate-VBC5ODDI.js +2 -0
  135. package/dist/{testmd-actions-CRRUXYOP.js → testmd-actions-QZD3N4EH.js} +1 -1
  136. package/dist/token-refresh-PIUX5OFA.js +2 -0
  137. package/dist/{validate-basic-X2XPEBFD.js → validate-basic-D7IJUFUQ.js} +1 -1
  138. package/dist/{verdicts-J2SDU4MW.js → verdicts-EO5TZ5BW.js} +1 -1
  139. package/dist/{version-check-DAWGRSJ5.js → version-check-JRLPWQ6T.js} +1 -1
  140. package/dist/{walk-session-D6TCM33V.js → walk-session-IODOH7QU.js} +1 -1
  141. package/dist/{with-telemetry-RXLIXUMR.js → with-telemetry-ASNQQBGP.js} +1 -1
  142. package/package.json +11 -11
  143. package/dist/FolderPicker-G4DT3OEZ.js +0 -2
  144. package/dist/HelpView-I27LWSL5.js +0 -2
  145. package/dist/SingleShotApp-Y77CNTSO.js +0 -2
  146. package/dist/TestMdRunView-PPM6LD3I.js +0 -2
  147. package/dist/bridge-AFQTFWCU.js +0 -2
  148. package/dist/chunk-2PH43Z3P.js +0 -69
  149. package/dist/chunk-3JLWPEQW.js +0 -2
  150. package/dist/chunk-C5UNZ6ZY.js +0 -2
  151. package/dist/chunk-EQSE6NIB.js +0 -5
  152. package/dist/chunk-PH22FRN5.js +0 -2
  153. package/dist/chunk-QDIZQ3ZF.js +0 -2
  154. package/dist/doctor-CPMWU5TL.js +0 -2
  155. package/dist/install-YDH2CORO.js +0 -2
  156. package/dist/login-flow-W5SAB7NN.js +0 -2
  157. package/dist/pipeline-ELIXCTFZ.js +0 -2
  158. package/dist/prepare-target-OU2DQXSW.js +0 -2
  159. package/dist/replay-policy-6USQBT3E.js +0 -2
  160. package/dist/tcg-generate-2PHA7VNL.js +0 -2
  161. package/dist/token-refresh-XKXPM6H3.js +0 -2
@@ -1,10 +1,10 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as B,b as H,d as ie}from"./chunk-L4EDLDLZ.js";import{a as j,b as N}from"./chunk-NEAMQMYH.js";import{a as C,b as G,e as M,f as te,m as re,n as ne}from"./chunk-DEZ7CXGM.js";import{a as oe,b as se}from"./chunk-2YQ6TW77.js";import{a as L}from"./chunk-BDUCWZYO.js";import{a as ee}from"./chunk-BCCWICSS.js";import{a as q}from"./chunk-JT7I6OST.js";import{a as Z}from"./chunk-DPUV6OSP.js";import{a as A}from"./chunk-RZ4F3BHX.js";import{a as O}from"./chunk-XHNPNYJP.js";import{y as h}from"./chunk-PH22FRN5.js";import{a as F}from"./chunk-HCBYKLMW.js";import{a as k,b as m,i as Q}from"./chunk-C44QQJR4.js";import{a as X}from"./chunk-6YGTRKDT.js";import{e as v}from"./chunk-UR6MHSHU.js";var D=v(X(),1);import{existsSync as P,readFileSync as Ge,rmSync as he,unlinkSync as He}from"fs";import{resolve as z}from"path";import{promises as ae,realpathSync as be}from"fs";import{homedir as Te}from"os";import{join as V,parse as Ee,relative as ce,resolve as le}from"path";var ue=new Set(["node_modules",".git","dist","build",".next",".venv","venv","target","__pycache__"]),R=class extends Error{constructor(s){super(`refusing to scan '${s}'. Run from your project root, or pass --root <dir>.`);this.cwd=s;this.name="HomeRefusedError"}};function de(e){try{return be(le(e))}catch{return le(e)}}function Se(e){let r=de(e),s=de(Te()),n=Ee(r).root;if(process.platform==="win32"){let o=t=>t.toLowerCase();return o(r)===o(s)||o(r)===o(n)}return r===s||r===n}async function U(e){if(Se(e.root))throw new R(e.root);let r=e.maxEntries??5e4,s=e.maxResults??5e3,n=new Set(e.ignore??[]),o=[],t=0,i=0,c=!1,f,l=[e.root];for(;l.length>0&&!c;){let a=l.shift(),g;try{g=await ae.readdir(a,{withFileTypes:!0})}catch{continue}i++;for(let b of g){if(t++,t>r){c=!0,f="max_entries";break}let x=b.name,E=V(a,x);if(b.isDirectory()){if(ue.has(x)||x.startsWith(".")||x.startsWith("output-")||n.has(x))continue;l.push(E)}else if(b.isFile()&&x.endsWith("_test.md")&&(o.push({path:E,relPath:ce(e.root,E),source:"cwd"}),o.length>=s)){c=!0,f="max_results";break}}e.onProgress?.(i,o.length)}if(!c){let g=[{dir:V(e.root,".testmuai","tests"),depth:0}];for(;g.length>0&&!c;){let{dir:b,depth:x}=g.shift(),E;try{E=await ae.readdir(b,{withFileTypes:!0})}catch{continue}i++;for(let u of E){if(t++,t>r){c=!0,f="max_entries";break}let w=u.name,y=V(b,w);if(u.isDirectory()){if(x>=20||w.startsWith(".")||w.startsWith("output-")||ue.has(w))continue;g.push({dir:y,depth:x+1})}else if(u.isFile()&&w.endsWith("_test.md")&&(o.push({path:y,relPath:ce(e.root,y),source:"tests-dir"}),o.length>=s)){c=!0,f="max_results";break}}}}return{results:o,aborted:c,abortReason:f,dirsScanned:i}}import{readFileSync as ve}from"fs";function Re(e){let r;try{r=ve(e,"utf8")}catch{return{tags:[]}}try{let{global:s}=re(e,r),n=ne(s);return{tags:s.tags??[],...n?{mobileTarget:n}:{}}}catch{return{tags:[],...Me(r)?{mobileTarget:Pe}:{}}}}var Pe={platform:"",app:""};function Me(e){let r=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!r)return!1;let s=r[1].split(/\r?\n/);if(s.some(o=>/^target:\s*['"]?(emulator|simulator)['"]?\s*$/.test(o)))return!0;let n=s.findIndex(o=>/^target:\s*$/.test(o));return n<0?!1:s.slice(n+1).some(o=>/^\s+\S/.test(o))}function W(e){return Re(e).tags}import{mkdirSync as De,writeFileSync as $e}from"fs";import{join as Ce}from"path";function fe(e,r){return`Basic ${Buffer.from(`${e}:${r}`).toString("base64")}`}async function Ie(e){let r=oe({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId,codeExport:{enabled:!0,language:e.language,skipValidation:e.skipValidation}}),s=await A(r.url,{method:"POST",headers:{"content-type":"application/json",authorization:fe(e.auth.username,e.auth.access_key)},body:JSON.stringify(r.body)});if(!s.ok)throw new Error(`code-export trigger failed: ${s.status} ${await s.text()}`);e.log("info","CODE_EXPORT_TRIGGERED","Code export triggered",{testcase_id:e.testcaseId})}async function Fe(e){let r=se({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId}),s=e.pollIntervalMs??5e3,n=e.timeoutMs??3e5,o=Date.now()+n;for(;Date.now()<o;){let t=await A(r,{headers:{authorization:fe(e.auth.username,e.auth.access_key),accept:"application/json"}});if(!t.ok){await new Promise(l=>setTimeout(l,s));continue}let c=(await t.json()).data?.find(l=>l.code_name==="kane-cli-trigger");if(!c){await new Promise(l=>setTimeout(l,s));continue}let f=(c.status??"").toLowerCase();if(f==="in progress"||f==="in_progress"||f==="pending"){await new Promise(l=>setTimeout(l,s));continue}if(!c.url||c.url.length===0)throw new Error(`code-export status=${c.status} but no files returned`);De(e.outDir,{recursive:!0});for(let l of c.url){let a=Ce(e.outDir,l.file_name),g=await A(l.file_url);if(!g.ok){e.log("warn","CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:l.file_name,status:g.status});continue}let b=await g.text();$e(a,b,"utf-8")}return e.log("info","CODE_EXPORT_DOWNLOADED","Code export saved",{out_dir:e.outDir,file_count:c.url.length}),e.outDir}throw new Error("code-export polling timed out")}async function ge(e){return await Ie(e),await Fe(e)}var T=v(X(),1);import{existsSync as Oe,readFileSync as Ae}from"fs";var p=v(F(),1);function Le(e){B(e);let r=M(e);if(!Oe(r))return null;try{return JSON.parse(Ae(r,"utf8"))}catch{return{}}}function Be(e){return e===null?"never_run":e.testcase_id?"synced":"local_only"}function je(e){return e==="synced"?"\u2601":e==="local_only"?"\u25A3":"\u25CB"}function Ne(e){return e==="tests-dir"?"\u2726":" "}function Ue(e,r){return r==="all"?!0:r==="synced"?e.status==="synced":r==="local"?e.status==="local_only":r==="never_run"?e.status==="never_run":r==="cli"?e.source==="tests-dir":r==="hand"?e.source==="cwd":!0}var Y=["all","synced","local","never_run","cli","hand"];function We(e){let r=Y.indexOf(e);return Y[(r+1)%Y.length]}function me({root:e,currentOrgId:r,onSelect:s,onCancel:n}){let[o,t]=(0,T.useState)([]),[i,c]=(0,T.useState)(null),[f,l]=(0,T.useState)(!0),[a,g]=(0,T.useState)("all");(0,T.useEffect)(()=>{(async()=>{try{let u=await U({root:e}),w=[];for(let y of u.results){let K=Le(y.path);K?.org_id!==void 0&&K.org_id!==r||w.push({path:y.path,relPath:y.relPath,name:C(y.path),status:Be(K),source:y.source,tags:W(y.path)})}t(w),l(!1)}catch(u){u instanceof R,c(u.message),l(!1)}})()},[e,r]);let b=(0,T.useMemo)(()=>o.filter(u=>Ue(u,a)).map(u=>({id:u.path,label:`${je(u.status)} ${Ne(u.source)} ${u.relPath}${u.tags.length>0?` [${u.tags.join(", ")}]`:""}`})),[o,a]),x=(0,T.useMemo)(()=>Ke(a,o),[a,o]);if(i)return(0,p.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.red,paddingX:2,paddingY:1,children:[(0,p.jsx)(m,{color:h.red,bold:!0,children:"testmd"}),(0,p.jsx)(k,{marginTop:1,children:(0,p.jsx)(m,{color:h.red,children:i})})]});let E=a==="all"?"all":Je(a);return(0,p.jsx)(ee,{title:`testmd \xB7 filter: ${E}`,items:b,loading:f,itemNoun:"tests",onSelect:u=>{let w=o.find(y=>y.path===u.id);w&&s(w)},onCancel:n,onTab:()=>g(u=>We(u)),extraHint:"cycle filter",footer:x})}function Je(e){return e==="synced"?"synced (\u2601)":e==="local"?"local (\u25A3)":e==="never_run"?"never run (\u25CB)":e==="cli"?"cli-generated (\u2726)":e==="hand"?"hand-written":"all"}function Ke(e,r){let s={synced:r.filter(o=>o.status==="synced").length,local:r.filter(o=>o.status==="local_only").length,never:r.filter(o=>o.status==="never_run").length,cli:r.filter(o=>o.source==="tests-dir").length,hand:r.filter(o=>o.source==="cwd").length},n=o=>o?h.orange:h.dim;return(0,p.jsxs)(k,{flexDirection:"column",children:[(0,p.jsx)(m,{color:h.dim,children:"legend:"}),(0,p.jsxs)(k,{children:[(0,p.jsx)(m,{color:n(e==="synced"),children:` \u2601 synced (${s.synced}) `}),(0,p.jsx)(m,{color:n(e==="local"),children:`\u25A3 local (${s.local}) `}),(0,p.jsx)(m,{color:n(e==="never_run"),children:`\u25CB never run (${s.never})`})]}),(0,p.jsxs)(k,{children:[(0,p.jsx)(m,{color:n(e==="cli"),children:` \u2726 cli-generated (${s.cli}) `}),(0,p.jsx)(m,{color:n(e==="hand"),children:` hand-written (${s.hand})`})]})]})}var I=v(X(),1);import{existsSync as Xe,readFileSync as qe}from"fs";var d=v(F(),1);function pe({path:e,relPath:r,onAction:s,onBack:n,onView:o}){let[t,i]=(0,I.useState)(null),[c,f]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let a=M(e);if(Xe(a))try{i(JSON.parse(qe(a,"utf8")))}catch{i(null)}},[e]),Q((a,g)=>{if(g.escape){if(c){f(!1);return}n();return}if(c){a==="y"||a==="Y"?(f(!1),s("delete")):(a==="n"||a==="N")&&f(!1);return}a==="r"&&s("run"),a==="e"&&t?.testcase_id&&s("export"),a==="d"&&f(!0),a==="v"&&o&&o()});let l=({k:a,v:g})=>g?(0,d.jsxs)(m,{children:[(0,d.jsx)(m,{color:h.dim,children:a.padEnd(14)}),g]}):null;return(0,d.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.orange,paddingX:2,paddingY:1,children:[(0,d.jsx)(m,{color:h.orange,bold:!0,children:r}),(0,d.jsx)(k,{marginTop:1,flexDirection:"column",children:t?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l,{k:"test_id",v:t.test_id}),(0,d.jsx)(l,{k:"testcase_id",v:t.testcase_id}),(0,d.jsx)(l,{k:"project_id",v:t.project_id}),(0,d.jsx)(l,{k:"folder_id",v:t.folder_id}),(0,d.jsx)(l,{k:"org_id",v:t.org_id}),(0,d.jsx)(l,{k:"session_name",v:t.session_name}),(0,d.jsx)(l,{k:"commit_id",v:t.commit_id})]}):(0,d.jsx)(m,{color:h.dim,children:"(never run \u2014 no meta.json)"})}),c?(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(m,{color:h.red,bold:!0,children:["Delete ",r," and its output dir? [y/n]"]})}):(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(m,{color:h.dim,children:["[r] run [e] export",t?.testcase_id?"":" (need testcase_id)"," [d] delete",o?" [v] view":""," [Esc] back"]})})]})}function $(e){B(e);let r=M(e);if(!P(r))return null;try{return JSON.parse(Ge(r,"utf8"))}catch{return null}}function _e(e,r){return!e||e.org_id===void 0?!0:e.org_id===r}function J(e,r){return _e(e,r)?null:(process.stderr.write(`error: this test belongs to org ${e.org_id}; you are logged in as org ${r}.
2
+ import{a as B,b as H,d as ie}from"./chunk-GYF4CH62.js";import{a as j,b as N}from"./chunk-MUGMUKSZ.js";import{a as C,b as G,e as M,f as te,m as re,n as ne}from"./chunk-DEZ7CXGM.js";import{a as oe,b as se}from"./chunk-2YQ6TW77.js";import{a as L}from"./chunk-6DTWVLSJ.js";import{a as ee}from"./chunk-LA2EMSHE.js";import{a as q}from"./chunk-WLOGO44E.js";import{a as Z}from"./chunk-DPUV6OSP.js";import{a as A}from"./chunk-RZ4F3BHX.js";import{a as O}from"./chunk-4UMQDH52.js";import{x as h}from"./chunk-CCUGKBIH.js";import{a as F}from"./chunk-HCBYKLMW.js";import{a as k,b as m,i as Q}from"./chunk-C44QQJR4.js";import{a as X}from"./chunk-6YGTRKDT.js";import{e as v}from"./chunk-UR6MHSHU.js";var D=v(X(),1);import{existsSync as P,readFileSync as Ge,rmSync as he,unlinkSync as He}from"fs";import{resolve as z}from"path";import{promises as ae,realpathSync as be}from"fs";import{homedir as Te}from"os";import{join as V,parse as Ee,relative as ce,resolve as le}from"path";var ue=new Set(["node_modules",".git","dist","build",".next",".venv","venv","target","__pycache__"]),R=class extends Error{constructor(s){super(`refusing to scan '${s}'. Run from your project root, or pass --root <dir>.`);this.cwd=s;this.name="HomeRefusedError"}};function de(e){try{return be(le(e))}catch{return le(e)}}function Se(e){let r=de(e),s=de(Te()),n=Ee(r).root;if(process.platform==="win32"){let o=t=>t.toLowerCase();return o(r)===o(s)||o(r)===o(n)}return r===s||r===n}async function U(e){if(Se(e.root))throw new R(e.root);let r=e.maxEntries??5e4,s=e.maxResults??5e3,n=new Set(e.ignore??[]),o=[],t=0,i=0,c=!1,f,l=[e.root];for(;l.length>0&&!c;){let a=l.shift(),g;try{g=await ae.readdir(a,{withFileTypes:!0})}catch{continue}i++;for(let b of g){if(t++,t>r){c=!0,f="max_entries";break}let x=b.name,E=V(a,x);if(b.isDirectory()){if(ue.has(x)||x.startsWith(".")||x.startsWith("output-")||n.has(x))continue;l.push(E)}else if(b.isFile()&&x.endsWith("_test.md")&&(o.push({path:E,relPath:ce(e.root,E),source:"cwd"}),o.length>=s)){c=!0,f="max_results";break}}e.onProgress?.(i,o.length)}if(!c){let g=[{dir:V(e.root,".testmuai","tests"),depth:0}];for(;g.length>0&&!c;){let{dir:b,depth:x}=g.shift(),E;try{E=await ae.readdir(b,{withFileTypes:!0})}catch{continue}i++;for(let u of E){if(t++,t>r){c=!0,f="max_entries";break}let w=u.name,y=V(b,w);if(u.isDirectory()){if(x>=20||w.startsWith(".")||w.startsWith("output-")||ue.has(w))continue;g.push({dir:y,depth:x+1})}else if(u.isFile()&&w.endsWith("_test.md")&&(o.push({path:y,relPath:ce(e.root,y),source:"tests-dir"}),o.length>=s)){c=!0,f="max_results";break}}}}return{results:o,aborted:c,abortReason:f,dirsScanned:i}}import{readFileSync as ve}from"fs";function Re(e){let r;try{r=ve(e,"utf8")}catch{return{tags:[]}}try{let{global:s}=re(e,r),n=ne(s);return{tags:s.tags??[],...n?{mobileTarget:n}:{}}}catch{return{tags:[],...Me(r)?{mobileTarget:Pe}:{}}}}var Pe={platform:"",app:""};function Me(e){let r=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!r)return!1;let s=r[1].split(/\r?\n/);if(s.some(o=>/^target:\s*['"]?(emulator|simulator)['"]?\s*$/.test(o)))return!0;let n=s.findIndex(o=>/^target:\s*$/.test(o));return n<0?!1:s.slice(n+1).some(o=>/^\s+\S/.test(o))}function W(e){return Re(e).tags}import{mkdirSync as De,writeFileSync as $e}from"fs";import{join as Ce}from"path";function fe(e,r){return`Basic ${Buffer.from(`${e}:${r}`).toString("base64")}`}async function Ie(e){let r=oe({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId,codeExport:{enabled:!0,language:e.language,skipValidation:e.skipValidation}}),s=await A(r.url,{method:"POST",headers:{"content-type":"application/json",authorization:fe(e.auth.username,e.auth.access_key)},body:JSON.stringify(r.body)});if(!s.ok)throw new Error(`code-export trigger failed: ${s.status} ${await s.text()}`);e.log("info","CODE_EXPORT_TRIGGERED","Code export triggered",{testcase_id:e.testcaseId})}async function Fe(e){let r=se({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId}),s=e.pollIntervalMs??5e3,n=e.timeoutMs??3e5,o=Date.now()+n;for(;Date.now()<o;){let t=await A(r,{headers:{authorization:fe(e.auth.username,e.auth.access_key),accept:"application/json"}});if(!t.ok){await new Promise(l=>setTimeout(l,s));continue}let c=(await t.json()).data?.find(l=>l.code_name==="kane-cli-trigger");if(!c){await new Promise(l=>setTimeout(l,s));continue}let f=(c.status??"").toLowerCase();if(f==="in progress"||f==="in_progress"||f==="pending"){await new Promise(l=>setTimeout(l,s));continue}if(!c.url||c.url.length===0)throw new Error(`code-export status=${c.status} but no files returned`);De(e.outDir,{recursive:!0});for(let l of c.url){let a=Ce(e.outDir,l.file_name),g=await A(l.file_url);if(!g.ok){e.log("warn","CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:l.file_name,status:g.status});continue}let b=await g.text();$e(a,b,"utf-8")}return e.log("info","CODE_EXPORT_DOWNLOADED","Code export saved",{out_dir:e.outDir,file_count:c.url.length}),e.outDir}throw new Error("code-export polling timed out")}async function ge(e){return await Ie(e),await Fe(e)}var T=v(X(),1);import{existsSync as Oe,readFileSync as Ae}from"fs";var p=v(F(),1);function Le(e){B(e);let r=M(e);if(!Oe(r))return null;try{return JSON.parse(Ae(r,"utf8"))}catch{return{}}}function Be(e){return e===null?"never_run":e.testcase_id?"synced":"local_only"}function je(e){return e==="synced"?"\u2601":e==="local_only"?"\u25A3":"\u25CB"}function Ne(e){return e==="tests-dir"?"\u2726":" "}function Ue(e,r){return r==="all"?!0:r==="synced"?e.status==="synced":r==="local"?e.status==="local_only":r==="never_run"?e.status==="never_run":r==="cli"?e.source==="tests-dir":r==="hand"?e.source==="cwd":!0}var Y=["all","synced","local","never_run","cli","hand"];function We(e){let r=Y.indexOf(e);return Y[(r+1)%Y.length]}function me({root:e,currentOrgId:r,onSelect:s,onCancel:n}){let[o,t]=(0,T.useState)([]),[i,c]=(0,T.useState)(null),[f,l]=(0,T.useState)(!0),[a,g]=(0,T.useState)("all");(0,T.useEffect)(()=>{(async()=>{try{let u=await U({root:e}),w=[];for(let y of u.results){let K=Le(y.path);K?.org_id!==void 0&&K.org_id!==r||w.push({path:y.path,relPath:y.relPath,name:C(y.path),status:Be(K),source:y.source,tags:W(y.path)})}t(w),l(!1)}catch(u){u instanceof R,c(u.message),l(!1)}})()},[e,r]);let b=(0,T.useMemo)(()=>o.filter(u=>Ue(u,a)).map(u=>({id:u.path,label:`${je(u.status)} ${Ne(u.source)} ${u.relPath}${u.tags.length>0?` [${u.tags.join(", ")}]`:""}`})),[o,a]),x=(0,T.useMemo)(()=>Ke(a,o),[a,o]);if(i)return(0,p.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.red,paddingX:2,paddingY:1,children:[(0,p.jsx)(m,{color:h.red,bold:!0,children:"testmd"}),(0,p.jsx)(k,{marginTop:1,children:(0,p.jsx)(m,{color:h.red,children:i})})]});let E=a==="all"?"all":Je(a);return(0,p.jsx)(ee,{title:`testmd \xB7 filter: ${E}`,items:b,loading:f,itemNoun:"tests",onSelect:u=>{let w=o.find(y=>y.path===u.id);w&&s(w)},onCancel:n,onTab:()=>g(u=>We(u)),extraHint:"cycle filter",footer:x})}function Je(e){return e==="synced"?"synced (\u2601)":e==="local"?"local (\u25A3)":e==="never_run"?"never run (\u25CB)":e==="cli"?"cli-generated (\u2726)":e==="hand"?"hand-written":"all"}function Ke(e,r){let s={synced:r.filter(o=>o.status==="synced").length,local:r.filter(o=>o.status==="local_only").length,never:r.filter(o=>o.status==="never_run").length,cli:r.filter(o=>o.source==="tests-dir").length,hand:r.filter(o=>o.source==="cwd").length},n=o=>o?h.orange:h.dim;return(0,p.jsxs)(k,{flexDirection:"column",children:[(0,p.jsx)(m,{color:h.dim,children:"legend:"}),(0,p.jsxs)(k,{children:[(0,p.jsx)(m,{color:n(e==="synced"),children:` \u2601 synced (${s.synced}) `}),(0,p.jsx)(m,{color:n(e==="local"),children:`\u25A3 local (${s.local}) `}),(0,p.jsx)(m,{color:n(e==="never_run"),children:`\u25CB never run (${s.never})`})]}),(0,p.jsxs)(k,{children:[(0,p.jsx)(m,{color:n(e==="cli"),children:` \u2726 cli-generated (${s.cli}) `}),(0,p.jsx)(m,{color:n(e==="hand"),children:` hand-written (${s.hand})`})]})]})}var I=v(X(),1);import{existsSync as Xe,readFileSync as qe}from"fs";var d=v(F(),1);function pe({path:e,relPath:r,onAction:s,onBack:n,onView:o}){let[t,i]=(0,I.useState)(null),[c,f]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let a=M(e);if(Xe(a))try{i(JSON.parse(qe(a,"utf8")))}catch{i(null)}},[e]),Q((a,g)=>{if(g.escape){if(c){f(!1);return}n();return}if(c){a==="y"||a==="Y"?(f(!1),s("delete")):(a==="n"||a==="N")&&f(!1);return}a==="r"&&s("run"),a==="e"&&t?.testcase_id&&s("export"),a==="d"&&f(!0),a==="v"&&o&&o()});let l=({k:a,v:g})=>g?(0,d.jsxs)(m,{children:[(0,d.jsx)(m,{color:h.dim,children:a.padEnd(14)}),g]}):null;return(0,d.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.orange,paddingX:2,paddingY:1,children:[(0,d.jsx)(m,{color:h.orange,bold:!0,children:r}),(0,d.jsx)(k,{marginTop:1,flexDirection:"column",children:t?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l,{k:"test_id",v:t.test_id}),(0,d.jsx)(l,{k:"testcase_id",v:t.testcase_id}),(0,d.jsx)(l,{k:"project_id",v:t.project_id}),(0,d.jsx)(l,{k:"folder_id",v:t.folder_id}),(0,d.jsx)(l,{k:"org_id",v:t.org_id}),(0,d.jsx)(l,{k:"session_name",v:t.session_name}),(0,d.jsx)(l,{k:"commit_id",v:t.commit_id})]}):(0,d.jsx)(m,{color:h.dim,children:"(never run \u2014 no meta.json)"})}),c?(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(m,{color:h.red,bold:!0,children:["Delete ",r," and its output dir? [y/n]"]})}):(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(m,{color:h.dim,children:["[r] run [e] export",t?.testcase_id?"":" (need testcase_id)"," [d] delete",o?" [v] view":""," [Esc] back"]})})]})}function $(e){B(e);let r=M(e);if(!P(r))return null;try{return JSON.parse(Ge(r,"utf8"))}catch{return null}}function _e(e,r){return!e||e.org_id===void 0?!0:e.org_id===r}function J(e,r){return _e(e,r)?null:(process.stderr.write(`error: this test belongs to org ${e.org_id}; you are logged in as org ${r}.
3
3
  Switch profiles with \`kane-cli profiles switch\` to act on it.
4
4
  `),2)}async function Xt(e={}){let r=!!process.stdin.isTTY&&!e.json,s=new O,n=new L;await H({isInteractive:r,creds:s,config:n});let o=s.getDefaultEnv()??"prod";try{let t=await N({creds:s,env:o,log:()=>{}});return t.resolvedCreds?.org_id===void 0?(process.stderr.write("error: TMS did not return an org_id. Run `kane-cli login` again.\n"),{ok:!1,code:2}):{ok:!0,orgId:String(t.resolvedCreds.org_id)}}catch(t){if(t instanceof j)return process.stderr.write("error: not authenticated. Run `kane-cli login` first.\n"),{ok:!1,code:2};throw t}}async function qt(e,r){if(process.stdin.isTTY&&!e.json)return await ze(r,e.root);let s=e.root??process.cwd(),n;try{n=await U({root:s,ignore:e.ignore})}catch(o){if(o instanceof R)return process.stderr.write(`error: ${o.message}
5
5
  `),2;throw o}for(let o of n.results){let t=$(o.path);if(!_e(t,r))continue;let i={path:o.relPath.startsWith(".")?o.relPath:`./${o.relPath}`,name:C(o.path),has_meta:t!==null,source:o.source,synced:!!t?.testcase_id,tags:W(o.path)};t&&(t.test_id&&(i.test_id=t.test_id),t.testcase_id&&(i.testcase_id=t.testcase_id),t.org_id&&(i.org_id=t.org_id),t.project_id&&(i.project_id=t.project_id),t.folder_id&&(i.folder_id=t.folder_id)),process.stdout.write(JSON.stringify(i)+`
6
6
  `)}return n.aborted&&process.stderr.write(`warn: walk aborted (${n.abortReason}). Pass --root or --ignore to narrow.
7
- `),0}var ye=-1001,xe=-1002,we=-1003,_={action:null,path:null};function Ve(e,r){return _.action=e,_.path=r,e==="run"?ye:e==="export"?xe:we}function Ye({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(me,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(pe,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Ve(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function ze(e,r){let s=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:c}=n(D.default.createElement(Ye,{root:s,currentOrgId:e,onComplete:f=>{i(),t(f)}}),{stdout:process.stderr,exitOnCtrlC:!0});c().then(()=>t(0)).catch(()=>t(0))});if(o===ye&&_.path){let{runTestMdFile:t}=await import("./run-test-md-JYDYT3XF.js"),i=await t(_.path,{});return _.action=null,_.path=null,i}if(o===xe&&_.path){let t=await Ze(_.path,{},e);return _.action=null,_.path=null,t}if(o===we&&_.path){let t=await Qe(_.path,!0,e);return _.action=null,_.path=null,t}return o}async function Gt(e,r){let s=z(e);if(!P(s))return process.stderr.write(`error: file not found: ${s}
7
+ `),0}var ye=-1001,xe=-1002,we=-1003,_={action:null,path:null};function Ve(e,r){return _.action=e,_.path=r,e==="run"?ye:e==="export"?xe:we}function Ye({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(me,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(pe,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Ve(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function ze(e,r){let s=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:c}=n(D.default.createElement(Ye,{root:s,currentOrgId:e,onComplete:f=>{i(),t(f)}}),{stdout:process.stderr,exitOnCtrlC:!0});c().then(()=>t(0)).catch(()=>t(0))});if(o===ye&&_.path){let{runTestMdFile:t}=await import("./run-test-md-664ASWRQ.js"),i=await t(_.path,{});return _.action=null,_.path=null,i}if(o===xe&&_.path){let t=await Ze(_.path,{},e);return _.action=null,_.path=null,t}if(o===we&&_.path){let t=await Qe(_.path,!0,e);return _.action=null,_.path=null,t}return o}async function Gt(e,r){let s=z(e);if(!P(s))return process.stderr.write(`error: file not found: ${s}
8
8
  `),2;let n=$(s),o=J(n,r);if(o!==null)return o;let t={path:s,name:C(s),has_meta:n!==null};return n&&(n.commit_id&&(t.commit_id=n.commit_id),n.test_id&&(t.test_id=n.test_id),n.testcase_id&&(t.testcase_id=n.testcase_id),n.project_id&&(t.project_id=n.project_id),n.folder_id&&(t.folder_id=n.folder_id),n.org_id&&(t.org_id=n.org_id),n.session_name&&(t.session_name=n.session_name)),process.stdout.write(JSON.stringify(t)+`
9
9
  `),0}async function Qe(e,r,s){let n=z(e);if(!P(n))return process.stderr.write(`error: file not found: ${n}
10
10
  `),2;let o=$(n),t=J(o,s);if(t!==null)return t;if(!r)return process.stderr.write(`error: refusing to delete without --yes.
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as $}from"./chunk-MMBBQ4OZ.js";import{j as h}from"./chunk-JCILRPOM.js";import{a as w}from"./chunk-RZ4F3BHX.js";import{c as v}from"./chunk-PH22FRN5.js";import{spawn as V,spawnSync as _}from"child_process";import{createServer as K}from"net";import{mkdirSync as g,openSync as W,readFileSync as I,renameSync as j,rmSync as x,statSync as Y,writeFileSync as M}from"fs";import{readFile as q}from"fs/promises";import{dirname as l,join as y}from"path";var G=[4723,4724,4725,4726,4727,4728,4729,4730],X={emulator:4750,simulator:4790},z=40,E=2e3,D=3e4,T=500,Ce=["emulator","simulator"];function Q(e){return y(v,"mobile",`appium-server-${e}.log`)}function m(){return y(v,"mobile","appium-servers.json")}function Z(){return y(v,"mobile","appium-servers.lock")}var ee=1e4,re=50;function C(e){let r=Z();try{g(l(r),{recursive:!0})}catch{return e()}let n=!1;for(let o=0;o<re;o++)try{g(r),n=!0;break}catch{try{Date.now()-Y(r).mtimeMs>ee&&x(r,{recursive:!0,force:!0})}catch{}ne(10)}try{return e()}finally{if(n)try{x(r,{recursive:!0,force:!0})}catch{}}}function ne(e){try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}catch{}}function te(){try{let e=JSON.parse(I(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}function oe(e){let r=m();g(l(r),{recursive:!0});let n=`${r}.tmp`;M(n,JSON.stringify(e,null,2)),j(n,r)}function se(e,r,n){return`Another mobile session is already running${n?` on ${n}`:""}. Wait for it to finish, or close the terminal running it.`}var A=class extends Error{constructor(n,o){super(n);this.port=o;this.name="DeviceBusyError"}};function ie(e){return w(e,{signal:AbortSignal.timeout(E)}).then(r=>r.ok,()=>!1)}async function ae(e,r){try{return(await w(`http://127.0.0.1:${e}/session/${r}`,{method:"DELETE",signal:AbortSignal.timeout(E)})).ok}catch{return!1}}function R(e){let r=e?.value;return Array.isArray(r)?r.map(n=>{let o=n??{},t=o.capabilities??o;return{...typeof o.id=="string"?{id:o.id}:{},caps:t}}):[]}async function ue(e){try{let r=await w(`http://127.0.0.1:${e}/sessions`,{signal:AbortSignal.timeout(E)});return r.ok?R(await r.json()):[]}catch{return[]}}var ce=["udid","appium:udid","deviceUDID","appium:deviceUDID","deviceName","appium:deviceName"];function L(){let e=r=>{try{let n=_("curl",["-s","--noproxy","*","--max-time","2",...r],{encoding:"utf8",timeout:5e3});return{ok:n.status===0,stdout:n.stdout??""}}catch{return{ok:!1,stdout:""}}};return{readState:()=>{try{let r=JSON.parse(I(m(),"utf8"));return Array.isArray(r)?r:[]}catch{return[]}},alive:b,getJson:r=>{let n=e([r]);if(n.ok)try{return JSON.parse(n.stdout)}catch{return}},del:r=>{let n=e(["-o","/dev/null","-w","%{http_code}","-X","DELETE",r]);return n.ok&&/^2\d\d$/.test(n.stdout.trim())}}}function Le(e,r={}){let n={...L(),...r},o=0;try{for(let t of n.readState()){if(!n.alive(t.pid))continue;let i=R(n.getJson(`http://127.0.0.1:${t.port}/sessions`));for(let s of i)s.id&&de(s.caps,e.udid,e.displayName)&&n.del(`http://127.0.0.1:${t.port}/session/${s.id}`)&&(o+=1)}}catch{}return o}function de(e,r,n){let o=[r,n].filter(t=>!!t).map(t=>t.toLowerCase());for(let t of ce){let i=e[t];if(typeof i=="string"&&o.includes(i.toLowerCase()))return!0}return!1}function pe(e,r,n){let o=W(n.logPath,"a"),t=V(e,r,{stdio:["ignore",o,o],detached:!0,env:{...process.env,...n.env}});return t.unref(),t.pid}async function le(e,r){for(let n=e;n<e+r;n++)if(await new Promise(t=>{let i=K();i.once("error",()=>t(!1)),i.once("listening",()=>i.close(()=>t(!0))),i.listen(n)}))return n;throw new Error(`No free port for the managed Appium server in ${e}-${e+r-1}.`)}function b(e){try{return process.kill(e,0),!0}catch{return!1}}function P(e){try{let r=_("ps",["-o","comm=","-p",String(e)],{encoding:"utf8",timeout:2e3});if(r.status!==0)return!1;let n=r.stdout.trim().toLowerCase();return n===""?!0:n.includes("node")||n.includes("kane")}catch{return!0}}function k(e){try{process.kill(e)}catch{}}async function me(){try{let e=JSON.parse(await q(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}async function fe(e){let r=process.pid,n=e.filter(o=>o.owner===r);C(()=>{let o=[];for(let t of te())t.owner!==r&&(Se(t)?o.push(t):b(t.pid)&&k(t.pid));oe([...o,...n])})}function Se(e){return e.owner===void 0?!1:b(e.owner)&&P(e.owner)}function ve(){return{probe:ie,sessions:ue,deleteSession:ae,spawn:pe,freePort:le,alive:b,kill:k,readState:me,writeState:fe,owner:process.pid,depsEnv:e=>h().environment(e),bundleVersion:async e=>(await h().status(e)).version,nodeBinary:process.execPath,env:process.env,os:process.platform,now:()=>Date.now(),sleep:e=>new Promise(r=>setTimeout(r,e))}}function we(e,r,n){if(!e.platformToolsDir)return{};let o=n==="win32"?";":":",t=$(r),i=t?.root??l(e.platformToolsDir),s=t?.platformToolsDir??e.platformToolsDir;return{ANDROID_HOME:i,ANDROID_SDK_ROOT:i,PATH:r.PATH?`${s}${o}${r.PATH}`:s}}async function ge(e){let r=await e.readState(),n=[],o=[];for(let t of r)t.owner!==void 0&&e.alive(t.owner)&&(e.ownerIsOurs??P)(t.owner)?n.push(t):o.push(t);for(let t of o){let i=e.ownerIsOurs??P;e.alive(t.pid)&&i(t.pid)&&e.kill(t.pid)}return o.length>0&&await e.writeState(n),n}async function Je(e,r={}){if(r.appiumUrl)return{result:"external",url:r.appiumUrl};let n={...ve(),...r.deps},o=await ge(n),t=o.filter(a=>a.owner===n.owner),i=new Set(t.map(a=>a.port)),s=new Set(o.map(a=>a.port));if(r.device){let a=await ye(n,s,i,e);if(a!==null)throw new A(se(r.device,a.port,a.device),a.port)}let c=await n.bundleVersion(e),u=t.find(a=>a.deviceClass===e&&(a.bundleVersion??c)===c);if(u&&await n.probe(`http://127.0.0.1:${u.port}/status`))return{result:"reused",url:`http://127.0.0.1:${u.port}`};for(let a of t.filter(S=>S.deviceClass===e&&S!==u))n.kill(a.pid);u&&n.kill(u.pid);let d=await n.depsEnv(e);if(!d.appiumHome)throw new Error(`The managed dependencies for the ${e} class are not installed.
3
- Run \`kane-cli doctor --target ${e} --install\` to install them, or pass --appium-url for an external server.`);let p=await n.freePort(X[e],z),O=`http://127.0.0.1:${p}`,J=l(d.appiumHome),U=y(J,"appium","node_modules","appium","index.js"),N=Q(e);r.onProgress?.(`starting the managed Appium server (${e}, port ${p})\u2026`);let f=n.spawn(n.nodeBinary,[U,"--port",String(p)],{env:{APPIUM_HOME:d.appiumHome,...we(d,n.env,n.os)},logPath:N}),B=n.now()+D,F=Math.ceil(D/T)+1;for(let a=0;a<F&&n.now()<B;a++)if(await n.sleep(T),await n.probe(`${O}/status`)){if(f!==void 0){let S=t.filter(H=>H.deviceClass!==e);await n.writeState([...S,{port:p,pid:f,owner:n.owner,deviceClass:e,...c?{bundleVersion:c}:{},startedAt:new Date(n.now()).toISOString()}])}return r.onProgress?.("Appium server ready"),{result:"started",url:O}}throw f!==void 0&&n.kill(f),new Error(`The managed Appium server (${e}) did not answer on ${p} within ${D/1e3}s.
2
+ import{a as $}from"./chunk-MMBBQ4OZ.js";import{j as h}from"./chunk-Z2T7E5HM.js";import{a as w}from"./chunk-RZ4F3BHX.js";import{b as v}from"./chunk-CCUGKBIH.js";import{spawn as V,spawnSync as _}from"child_process";import{createServer as K}from"net";import{mkdirSync as g,openSync as W,readFileSync as I,renameSync as j,rmSync as x,statSync as Y,writeFileSync as M}from"fs";import{readFile as q}from"fs/promises";import{dirname as l,join as y}from"path";var G=[4723,4724,4725,4726,4727,4728,4729,4730],X={emulator:4750,simulator:4790},z=40,E=2e3,D=3e4,T=500,Ce=["emulator","simulator"];function Q(e){return y(v,"mobile",`appium-server-${e}.log`)}function m(){return y(v,"mobile","appium-servers.json")}function Z(){return y(v,"mobile","appium-servers.lock")}var ee=1e4,re=50;function C(e){let r=Z();try{g(l(r),{recursive:!0})}catch{return e()}let n=!1;for(let o=0;o<re;o++)try{g(r),n=!0;break}catch{try{Date.now()-Y(r).mtimeMs>ee&&x(r,{recursive:!0,force:!0})}catch{}ne(10)}try{return e()}finally{if(n)try{x(r,{recursive:!0,force:!0})}catch{}}}function ne(e){try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}catch{}}function te(){try{let e=JSON.parse(I(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}function oe(e){let r=m();g(l(r),{recursive:!0});let n=`${r}.tmp`;M(n,JSON.stringify(e,null,2)),j(n,r)}function se(e,r,n){return`Another mobile session is already running${n?` on ${n}`:""}. Wait for it to finish, or close the terminal running it.`}var A=class extends Error{constructor(n,o){super(n);this.port=o;this.name="DeviceBusyError"}};function ie(e){return w(e,{signal:AbortSignal.timeout(E)}).then(r=>r.ok,()=>!1)}async function ae(e,r){try{return(await w(`http://127.0.0.1:${e}/session/${r}`,{method:"DELETE",signal:AbortSignal.timeout(E)})).ok}catch{return!1}}function R(e){let r=e?.value;return Array.isArray(r)?r.map(n=>{let o=n??{},t=o.capabilities??o;return{...typeof o.id=="string"?{id:o.id}:{},caps:t}}):[]}async function ue(e){try{let r=await w(`http://127.0.0.1:${e}/sessions`,{signal:AbortSignal.timeout(E)});return r.ok?R(await r.json()):[]}catch{return[]}}var ce=["udid","appium:udid","deviceUDID","appium:deviceUDID","deviceName","appium:deviceName"];function L(){let e=r=>{try{let n=_("curl",["-s","--noproxy","*","--max-time","2",...r],{encoding:"utf8",timeout:5e3});return{ok:n.status===0,stdout:n.stdout??""}}catch{return{ok:!1,stdout:""}}};return{readState:()=>{try{let r=JSON.parse(I(m(),"utf8"));return Array.isArray(r)?r:[]}catch{return[]}},alive:b,getJson:r=>{let n=e([r]);if(n.ok)try{return JSON.parse(n.stdout)}catch{return}},del:r=>{let n=e(["-o","/dev/null","-w","%{http_code}","-X","DELETE",r]);return n.ok&&/^2\d\d$/.test(n.stdout.trim())}}}function Le(e,r={}){let n={...L(),...r},o=0;try{for(let t of n.readState()){if(!n.alive(t.pid))continue;let i=R(n.getJson(`http://127.0.0.1:${t.port}/sessions`));for(let s of i)s.id&&de(s.caps,e.udid,e.displayName)&&n.del(`http://127.0.0.1:${t.port}/session/${s.id}`)&&(o+=1)}}catch{}return o}function de(e,r,n){let o=[r,n].filter(t=>!!t).map(t=>t.toLowerCase());for(let t of ce){let i=e[t];if(typeof i=="string"&&o.includes(i.toLowerCase()))return!0}return!1}function pe(e,r,n){let o=W(n.logPath,"a"),t=V(e,r,{stdio:["ignore",o,o],detached:!0,env:{...process.env,...n.env}});return t.unref(),t.pid}async function le(e,r){for(let n=e;n<e+r;n++)if(await new Promise(t=>{let i=K();i.once("error",()=>t(!1)),i.once("listening",()=>i.close(()=>t(!0))),i.listen(n)}))return n;throw new Error(`No free port for the managed Appium server in ${e}-${e+r-1}.`)}function b(e){try{return process.kill(e,0),!0}catch{return!1}}function P(e){try{let r=_("ps",["-o","comm=","-p",String(e)],{encoding:"utf8",timeout:2e3});if(r.status!==0)return!1;let n=r.stdout.trim().toLowerCase();return n===""?!0:n.includes("node")||n.includes("kane")}catch{return!0}}function k(e){try{process.kill(e)}catch{}}async function me(){try{let e=JSON.parse(await q(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}async function fe(e){let r=process.pid,n=e.filter(o=>o.owner===r);C(()=>{let o=[];for(let t of te())t.owner!==r&&(Se(t)?o.push(t):b(t.pid)&&k(t.pid));oe([...o,...n])})}function Se(e){return e.owner===void 0?!1:b(e.owner)&&P(e.owner)}function ve(){return{probe:ie,sessions:ue,deleteSession:ae,spawn:pe,freePort:le,alive:b,kill:k,readState:me,writeState:fe,owner:process.pid,depsEnv:e=>h().environment(e),bundleVersion:async e=>(await h().status(e)).version,nodeBinary:process.execPath,env:process.env,os:process.platform,now:()=>Date.now(),sleep:e=>new Promise(r=>setTimeout(r,e))}}function we(e,r,n){if(!e.platformToolsDir)return{};let o=n==="win32"?";":":",t=$(r),i=t?.root??l(e.platformToolsDir),s=t?.platformToolsDir??e.platformToolsDir;return{ANDROID_HOME:i,ANDROID_SDK_ROOT:i,PATH:r.PATH?`${s}${o}${r.PATH}`:s}}async function ge(e){let r=await e.readState(),n=[],o=[];for(let t of r)t.owner!==void 0&&e.alive(t.owner)&&(e.ownerIsOurs??P)(t.owner)?n.push(t):o.push(t);for(let t of o){let i=e.ownerIsOurs??P;e.alive(t.pid)&&i(t.pid)&&e.kill(t.pid)}return o.length>0&&await e.writeState(n),n}async function Je(e,r={}){if(r.appiumUrl)return{result:"external",url:r.appiumUrl};let n={...ve(),...r.deps},o=await ge(n),t=o.filter(a=>a.owner===n.owner),i=new Set(t.map(a=>a.port)),s=new Set(o.map(a=>a.port));if(r.device){let a=await ye(n,s,i,e);if(a!==null)throw new A(se(r.device,a.port,a.device),a.port)}let c=await n.bundleVersion(e),u=t.find(a=>a.deviceClass===e&&(a.bundleVersion??c)===c);if(u&&await n.probe(`http://127.0.0.1:${u.port}/status`))return{result:"reused",url:`http://127.0.0.1:${u.port}`};for(let a of t.filter(S=>S.deviceClass===e&&S!==u))n.kill(a.pid);u&&n.kill(u.pid);let d=await n.depsEnv(e);if(!d.appiumHome)throw new Error(`The managed dependencies for the ${e} class are not installed.
3
+ Run \`kane-cli doctor --target ${e} --install\` to install them, or pass --appium-url for an external server.`);let p=await n.freePort(X[e],z),O=`http://127.0.0.1:${p}`,J=l(d.appiumHome),U=y(J,"appium","node_modules","appium","index.js"),N=Q(e);r.onProgress?.(`starting the managed Appium server (${e}, port ${p})\u2026`);let f=n.spawn(n.nodeBinary,[U,"--port",String(p),"--allow-insecure=uiautomator2:adb_shell"],{env:{APPIUM_HOME:d.appiumHome,...we(d,n.env,n.os)},logPath:N}),B=n.now()+D,F=Math.ceil(D/T)+1;for(let a=0;a<F&&n.now()<B;a++)if(await n.sleep(T),await n.probe(`${O}/status`)){if(f!==void 0){let S=t.filter(H=>H.deviceClass!==e);await n.writeState([...S,{port:p,pid:f,owner:n.owner,deviceClass:e,...c?{bundleVersion:c}:{},startedAt:new Date(n.now()).toISOString()}])}return r.onProgress?.("Appium server ready"),{result:"started",url:O}}throw f!==void 0&&n.kill(f),new Error(`The managed Appium server (${e}) did not answer on ${p} within ${D/1e3}s.
4
4
  Check its log: ${N}`)}async function ye(e,r=[],n=[],o){let t=new Set(n),i=new Set([...G,...r]);for(let s of i)if(!t.has(s))for(let c of await e.sessions(s)){if(!c.id)continue;if(o){let d=be(c.caps);if(d&&d!==o)continue}let u=De(c.caps);return{port:s,...u?{device:u}:{}}}return null}function be(e){let r=t=>{let i=e[t];return typeof i=="string"?i.toLowerCase():""},n=r("platformName")||r("appium:platformName");if(n.includes("ios"))return"simulator";if(n.includes("android"))return"emulator";let o=r("appium:automationName")||r("automationName");if(o.includes("xcuitest"))return"simulator";if(o.includes("uiautomator"))return"emulator"}var he=["appium:deviceName","deviceName","appium:udid","udid","appium:deviceUDID","deviceUDID"];function De(e){for(let r of he){let n=e[r];if(typeof n=="string"&&n.trim())return n}}function Ue(e={}){let r={...L(),kill:k,writeState:Ae,...e.deps};try{let n=r.readState(),o=e.owner??process.pid,t=n.filter(s=>s.owner===o&&(!e.deviceClass||s.deviceClass===e.deviceClass));for(let s of t){if(!r.alive(s.pid))continue;let c=R(r.getJson(`http://127.0.0.1:${s.port}/sessions`));for(let u of c)u.id&&r.del(`http://127.0.0.1:${s.port}/session/${u.id}`);r.kill(s.pid)}let i=new Set(t.map(s=>`${s.port}:${s.pid}`));C(()=>{r.writeState(r.readState().filter(s=>!i.has(`${s.port}:${s.pid}`)))})}catch{}}function Ae(e){try{let r=m();g(l(r),{recursive:!0}),M(r,JSON.stringify(e,null,2))}catch{}}export{Ce as a,Q as b,se as c,Le as d,ve as e,Je as f,ye as g,Ue as h};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as R}from"./chunk-7VTYRTEJ.js";import{y as i}from"./chunk-PH22FRN5.js";import{a as X}from"./chunk-HCBYKLMW.js";import{a,b as l,i as p}from"./chunk-C44QQJR4.js";import{a as G}from"./chunk-6YGTRKDT.js";import{e as P}from"./chunk-UR6MHSHU.js";var x=P(G(),1);var e=P(X(),1),f=5;function K(t,I){if(!I)return t;let c=I.toLowerCase();return t.filter(B=>B.label.toLowerCase().includes(c))}function J(t){let{title:I,items:c,loading:B=!1,loadingText:Y,error:L=null,itemNoun:v="items",onSelect:F,onCancel:E,defaultActiveId:w,onTab:y,extraHint:H}=t,[g,d]=(0,x.useState)(0),[S,u]=(0,x.useState)(0),[s,A]=(0,x.useState)(""),[C,h]=(0,x.useState)(null);(0,x.useEffect)(()=>{if(c.length===0)return;if(t.preserveSelectionById&&C!==null){let o=c.findIndex(n=>n.id===C);if(o>=0){u(Math.floor(o/f)),d(o%f);return}}let r=w?c.findIndex(o=>o.id===w):c.findIndex(o=>o.isActive);r>=0?(u(Math.floor(r/f)),d(r%f),t.preserveSelectionById&&h(c[r].id)):t.preserveSelectionById&&(u(0),d(0),h(c[0]?.id??null))},[c,w,t.preserveSelectionById,C]),(0,x.useEffect)(()=>{if(!t.onSearch)return;let r=setTimeout(()=>t.onSearch(s),t.searchDebounceMs??250);return()=>clearTimeout(r)},[s,t.onSearch,t.searchDebounceMs]);let b=t.onSearch?c:K(c,s),D=S*f,N=Math.min(D+f,b.length),M=Math.ceil(b.length/f),O=N-D,T=b.slice(D,N);return p((r,o)=>{if(L){o.escape&&E();return}if(o.escape){s?(A(""),d(0),u(0)):E();return}if(o.tab&&y){y();return}if(o.upArrow){if(g>0){let n=g-1;d(n),t.preserveSelectionById&&h(T[n]?.id??null)}else if(S>0){let n=S-1,m=f-1;u(n),d(m),t.preserveSelectionById&&h(b[n*f+m]?.id??null)}return}if(o.downArrow){if(g<O-1){let n=g+1;d(n),t.preserveSelectionById&&h(T[n]?.id??null)}else if(S<M-1){let n=S+1,m=0;u(n),d(m),t.preserveSelectionById&&h(b[n*f+m]?.id??null)}return}if(o.return&&T[g]){if(T[g].disabled)return;F(T[g]);return}if(o.backspace||o.delete){A(n=>n.slice(0,-1)),d(0),u(0);return}r&&!o.ctrl&&!o.meta&&(A(n=>n+r),d(0),u(0))},{isActive:!B}),B?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:i.orange,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(l,{color:i.secondary,children:Y??`Loading ${v}\u2026`})})]}):L?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.red,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:i.red,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(l,{color:i.red,children:L})}),(0,e.jsx)(R,{bindings:[]})]}):(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(l,{color:i.orange,bold:!0,children:I}),(0,e.jsxs)(l,{color:i.dim,children:[" (",b.length,!t.onSearch&&s?`/${c.length}`:""," ",v,t.loadingMore?" \xB7 loading more":"",")"]})]}),(0,e.jsxs)(a,{marginTop:1,children:[(0,e.jsx)(l,{color:i.secondary,children:s?"filter: ":""}),s?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l,{children:s}),(0,e.jsx)(l,{inverse:!0,children:" "})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(l,{color:i.dim,children:["Search ",v,"\u2026"]}),(0,e.jsx)(l,{inverse:!0,children:" "})]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:t.searching?(0,e.jsxs)(l,{color:i.secondary,children:["Searching ",v,"\u2026"]}):b.length===0?(0,e.jsxs)(l,{color:i.dim,children:["No ",v,' match "',s,'"']}):T.map((r,o)=>{let n=o===g,m=n?"\u276F ":" ",$=r.disabled?i.muted:r.isActive?i.green:n?i.orange:void 0;return(0,e.jsxs)(a,{flexDirection:"column",children:[(0,e.jsxs)(l,{color:$,children:[m,r.label,r.isActive&&!r.disabled?" \u25CF selected":""]}),n&&r.disabled&&r.disabledHint&&(0,e.jsxs)(l,{color:i.red,children:[" ",r.disabledHint]})]},r.id)})}),!t.searching&&M>1&&(0,e.jsx)(a,{marginTop:1,children:(0,e.jsxs)(l,{color:i.dim,children:["Page ",S+1,"/",M]})}),t.footer&&(0,e.jsx)(a,{marginTop:1,flexDirection:"column",children:t.footer}),(0,e.jsx)(R,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"type",label:"to search"},{keys:"\u21B5",label:"select"},...y&&H?[{keys:"tab",label:H}]:[]],escBackLabel:s?"clear":"back to chat"})]})}export{J as a};
2
+ import{a as R}from"./chunk-ZIRMSWKS.js";import{x as i}from"./chunk-CCUGKBIH.js";import{a as X}from"./chunk-HCBYKLMW.js";import{a,b as l,i as p}from"./chunk-C44QQJR4.js";import{a as G}from"./chunk-6YGTRKDT.js";import{e as P}from"./chunk-UR6MHSHU.js";var x=P(G(),1);var e=P(X(),1),f=5;function K(t,I){if(!I)return t;let c=I.toLowerCase();return t.filter(B=>B.label.toLowerCase().includes(c))}function J(t){let{title:I,items:c,loading:B=!1,loadingText:Y,error:L=null,itemNoun:v="items",onSelect:F,onCancel:E,defaultActiveId:w,onTab:y,extraHint:H}=t,[g,d]=(0,x.useState)(0),[S,u]=(0,x.useState)(0),[s,A]=(0,x.useState)(""),[C,h]=(0,x.useState)(null);(0,x.useEffect)(()=>{if(c.length===0)return;if(t.preserveSelectionById&&C!==null){let o=c.findIndex(n=>n.id===C);if(o>=0){u(Math.floor(o/f)),d(o%f);return}}let r=w?c.findIndex(o=>o.id===w):c.findIndex(o=>o.isActive);r>=0?(u(Math.floor(r/f)),d(r%f),t.preserveSelectionById&&h(c[r].id)):t.preserveSelectionById&&(u(0),d(0),h(c[0]?.id??null))},[c,w,t.preserveSelectionById,C]),(0,x.useEffect)(()=>{if(!t.onSearch)return;let r=setTimeout(()=>t.onSearch(s),t.searchDebounceMs??250);return()=>clearTimeout(r)},[s,t.onSearch,t.searchDebounceMs]);let b=t.onSearch?c:K(c,s),D=S*f,N=Math.min(D+f,b.length),M=Math.ceil(b.length/f),O=N-D,T=b.slice(D,N);return p((r,o)=>{if(L){o.escape&&E();return}if(o.escape){s?(A(""),d(0),u(0)):E();return}if(o.tab&&y){y();return}if(o.upArrow){if(g>0){let n=g-1;d(n),t.preserveSelectionById&&h(T[n]?.id??null)}else if(S>0){let n=S-1,m=f-1;u(n),d(m),t.preserveSelectionById&&h(b[n*f+m]?.id??null)}return}if(o.downArrow){if(g<O-1){let n=g+1;d(n),t.preserveSelectionById&&h(T[n]?.id??null)}else if(S<M-1){let n=S+1,m=0;u(n),d(m),t.preserveSelectionById&&h(b[n*f+m]?.id??null)}return}if(o.return&&T[g]){if(T[g].disabled)return;F(T[g]);return}if(o.backspace||o.delete){A(n=>n.slice(0,-1)),d(0),u(0);return}r&&!o.ctrl&&!o.meta&&(A(n=>n+r),d(0),u(0))},{isActive:!B}),B?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:i.orange,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(l,{color:i.secondary,children:Y??`Loading ${v}\u2026`})})]}):L?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.red,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:i.red,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(l,{color:i.red,children:L})}),(0,e.jsx)(R,{bindings:[]})]}):(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(l,{color:i.orange,bold:!0,children:I}),(0,e.jsxs)(l,{color:i.dim,children:[" (",b.length,!t.onSearch&&s?`/${c.length}`:""," ",v,t.loadingMore?" \xB7 loading more":"",")"]})]}),(0,e.jsxs)(a,{marginTop:1,children:[(0,e.jsx)(l,{color:i.secondary,children:s?"filter: ":""}),s?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l,{children:s}),(0,e.jsx)(l,{inverse:!0,children:" "})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(l,{color:i.dim,children:["Search ",v,"\u2026"]}),(0,e.jsx)(l,{inverse:!0,children:" "})]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:t.searching?(0,e.jsxs)(l,{color:i.secondary,children:["Searching ",v,"\u2026"]}):b.length===0?(0,e.jsxs)(l,{color:i.dim,children:["No ",v,' match "',s,'"']}):T.map((r,o)=>{let n=o===g,m=n?"\u276F ":" ",$=r.disabled?i.muted:r.isActive?i.green:n?i.orange:void 0;return(0,e.jsxs)(a,{flexDirection:"column",children:[(0,e.jsxs)(l,{color:$,children:[m,r.label,r.isActive&&!r.disabled?" \u25CF selected":""]}),n&&r.disabled&&r.disabledHint&&(0,e.jsxs)(l,{color:i.red,children:[" ",r.disabledHint]})]},r.id)})}),!t.searching&&M>1&&(0,e.jsx)(a,{marginTop:1,children:(0,e.jsxs)(l,{color:i.dim,children:["Page ",S+1,"/",M]})}),t.footer&&(0,e.jsx)(a,{marginTop:1,flexDirection:"column",children:t.footer}),(0,e.jsx)(R,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"type",label:"to search"},{keys:"\u21B5",label:"select"},...y&&H?[{keys:"tab",label:H}]:[]],escBackLabel:s?"clear":"back to chat"})]})}export{J as a};
@@ -1,8 +1,8 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as K}from"./chunk-QWDFFEEJ.js";import{a as B,b as U,c as Y}from"./chunk-AFPHLUQ5.js";import{a as j}from"./chunk-DNNZ353O.js";import{d as F}from"./chunk-XWKUZJCP.js";import{A as k,a as L,b as V,k as G,o as N}from"./chunk-TH47OOBV.js";import{d as I}from"./chunk-DUAXZYAD.js";import{d as v,e as x,g as H}from"./chunk-WXHQYYD5.js";function ee(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=Y(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=U(r,l);let u=G(r,B(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 N({contextDir:t,graph:e,proposal:r,proposalId:m,verdicts:p,by:s,autoName:!0})}function W(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 q="this release plans changes only \u2014 blast-radius impact and drift meaning-checks are not measured, and REMOVE rows are never executed automatically",te="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 X(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 z(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 ne=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=j(t,e,n);return i===null?null:i.toString("utf8")}function se(t,e,n,i,s){let f=n.props.quote;if(typeof f=="string"&&f.length>0)return i.includes(f);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-DCUT3GJA.js";import{a as B,b as U,c as Y}from"./chunk-AFPHLUQ5.js";import{a as j}from"./chunk-DNNZ353O.js";import{d as F}from"./chunk-XWKUZJCP.js";import{A as k,a as L,b as V,k as G,o as N}from"./chunk-TH47OOBV.js";import{d as I}from"./chunk-DUAXZYAD.js";import{d as v,e as x,g as H}from"./chunk-WXHQYYD5.js";function ee(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=Y(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=U(r,l);let u=G(r,B(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 N({contextDir:t,graph:e,proposal:r,proposalId:m,verdicts:p,by:s,autoName:!0})}function W(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 q="this release plans changes only \u2014 blast-radius impact and drift meaning-checks are not measured, and REMOVE rows are never executed automatically",te="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 X(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 z(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 ne=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=j(t,e,n);return i===null?null:i.toString("utf8")}function se(t,e,n,i,s){let f=n.props.quote;if(typeof f=="string"&&f.length>0)return i.includes(f);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 oe(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 J=128*1024,Q=64*1024;function re(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=ie(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 ie(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 ce(t){let e=Buffer.byteLength(t,"utf8");if(e<=J+Q)return{diff:t,truncated:!1};let n=Buffer.from(t,"utf8"),i=J;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 ae(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}=ce(re(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 de(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 le(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:de(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"?oe(n,_,s):m!==null&&se(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:W(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 Ee(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=ee(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 Re(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:q,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=ne.has(r.nodeLabel.get(c)??"");return{kind:"MODIFY",origin:"structural-stale",ref:w,reason:"stale (structural)",provenance:z(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),Z=[...T.filter(O=>!E.includes(O)),...c.uc.updated?.criteria!==void 0?E.filter(O=>!T.includes(O)):[]],P=w?W(r,w,Z):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=X(r,r.tipOf(c));w&&r.nodeLabel.get(w)===v.USECASE&&h.add(r.tipOf(w))}let R=[];for(let c of await F(r,"design")){if(c.kind!=="no-verifies")continue;let w=r.resolve(c.ref);if(!w)continue;let E=X(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:z(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:te,skipped_arms:q,changeset:le(t,s,r,e,p.cid,g.minted,g.held),rows:_,...g.held?{held:g.held}:{}}}function ye(t,e){return async n=>{let{ingestFile:i}=await import("./ingest-4447MYLF.js"),{convertPdf:s}=await import("./pdf-convert-OZIRUADA.js"),{convertDocx:f}=await import("./docx-convert-JMUMT5C4.js"),o=await i({contextDir:t,filePath:e,asId:n,converters:{pdf:s,docx:f}});return{status:o.status,cid:o.cid}}}function be(t,e,n,i){return async()=>{let f=(i??(await import("./dispatch-HDGQAEWN.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 xe(t,e={}){return async n=>{let i=[],[{runExtract:s},{resolveAgentAuthEnv:f},{runAgent:o},{preflightTurn:p}]=await Promise.all([import("./run-T53Z5TCY.js"),import("./spawner-LKYUMXSO.js"),import("./bridge-AFQTFWCU.js"),import("./turn-preflight-JGYT7LXP.js")]),g=await f(),r=new Set(k(t).byLabel(v.USECASE).map(S=>S.cid)),l=ae(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{ee as a,W as b,q as c,te as d,M as e,X as f,ne as g,re as h,ce as i,ae as j,Ee as k,Re as l,ye as m,be as n,xe as o};
8
+ ${o}`,truncated:!0}}function ae(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}=ce(re(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 de(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 le(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:de(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"?oe(n,_,s):m!==null&&se(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:W(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 Ee(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=ee(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 Re(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:q,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=ne.has(r.nodeLabel.get(c)??"");return{kind:"MODIFY",origin:"structural-stale",ref:w,reason:"stale (structural)",provenance:z(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),Z=[...T.filter(O=>!E.includes(O)),...c.uc.updated?.criteria!==void 0?E.filter(O=>!T.includes(O)):[]],P=w?W(r,w,Z):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=X(r,r.tipOf(c));w&&r.nodeLabel.get(w)===v.USECASE&&h.add(r.tipOf(w))}let R=[];for(let c of await F(r,"design")){if(c.kind!=="no-verifies")continue;let w=r.resolve(c.ref);if(!w)continue;let E=X(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:z(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:te,skipped_arms:q,changeset:le(t,s,r,e,p.cid,g.minted,g.held),rows:_,...g.held?{held:g.held}:{}}}function ye(t,e){return async n=>{let{ingestFile:i}=await import("./ingest-4447MYLF.js"),{convertPdf:s}=await import("./pdf-convert-OZIRUADA.js"),{convertDocx:f}=await import("./docx-convert-JMUMT5C4.js"),o=await i({contextDir:t,filePath:e,asId:n,converters:{pdf:s,docx:f}});return{status:o.status,cid:o.cid}}}function be(t,e,n,i){return async()=>{let f=(i??(await import("./dispatch-OZRMWY25.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 xe(t,e={}){return async n=>{let i=[],[{runExtract:s},{resolveAgentAuthEnv:f},{runAgent:o},{preflightTurn:p}]=await Promise.all([import("./run-R7GND73C.js"),import("./spawner-ANLF7OX3.js"),import("./bridge-LOBTHY3P.js"),import("./turn-preflight-JGYT7LXP.js")]),g=await f(),r=new Set(k(t).byLabel(v.USECASE).map(S=>S.cid)),l=ae(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{ee as a,W as b,q as c,te as d,M as e,X as f,ne as g,re as h,ce as i,ae as j,Ee as k,Re as l,ye as m,be as n,xe as o};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as b}from"./chunk-7VTYRTEJ.js";import{n as d,y as o}from"./chunk-PH22FRN5.js";import{a as L}from"./chunk-HCBYKLMW.js";import{a as u,b as c,i as A}from"./chunk-C44QQJR4.js";import{a as D}from"./chunk-6YGTRKDT.js";import{e as h}from"./chunk-UR6MHSHU.js";var x=h(D(),1);import{readdirSync as N,mkdirSync as B,statSync as k}from"fs";import{join as P}from"path";var r=h(L(),1);function O(n){try{return N(n).filter(l=>{try{return k(P(n,l)).isDirectory()}catch{return!1}})}catch{return[]}}function E(n,l,f,v){return{name:n,path:l,label:n,isActive:v}}function H({currentPath:n,onSelect:l,onCancel:f}){let s=O(d).map(i=>{let e=P(d,i);return E(i,e,n,e===n)}),p=!n,R=s.length+2,[a,C]=(0,x.useState)(()=>{if(p)return 0;let i=s.findIndex(e=>e.isActive);return i>=0?i+1:0}),[T,I]=(0,x.useState)(!1),[S,g]=(0,x.useState)("");return A((i,e)=>{if(T){if(e.escape){I(!1),g("");return}if(e.return){let t=S.trim();if(t){let m=P(d,t);B(m,{recursive:!0}),l(m),f()}return}if(e.backspace||e.delete){g(t=>t.slice(0,-1));return}i&&!e.ctrl&&!e.meta&&g(t=>t+i);return}if(e.escape){f();return}if(e.upArrow){C(t=>Math.max(0,t-1));return}if(e.downArrow){C(t=>Math.min(R-1,t+1));return}if(e.return){if(a===0){p||l(""),f();return}if(a===s.length+1){B(d,{recursive:!0}),I(!0),g("");return}let t=s[a-1];t&&!t.isActive&&l(t.path),f();return}}),T?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile \u203A New"}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(c,{color:o.secondary,children:"Name: "}),(0,r.jsx)(c,{children:S}),(0,r.jsx)(c,{color:o.dim,children:"\u2588"})]}),(0,r.jsx)(b,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:"back"})]}):(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile"}),(0,r.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,r.jsxs)(c,{color:p?o.green:a===0?o.orange:o.dim,children:[a===0?"\u276F ":" ","Use temporary (no profile)",p?" \u25CF active":""]}),s.map((i,e)=>{let m=e+1===a,w=m?"\u276F ":" ",y=i.isActive?o.green:m?o.orange:void 0;return(0,r.jsxs)(c,{color:y,children:[w,i.label,i.isActive?" \u25CF active":""]},i.name)}),(0,r.jsxs)(c,{color:a===s.length+1?o.orange:o.dim,children:[a===s.length+1?"\u276F ":" ","+ Create new"]})]}),(0,r.jsx)(b,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}export{O as a,E as b,H as c};
2
+ import{a as b}from"./chunk-ZIRMSWKS.js";import{m as d,x as o}from"./chunk-CCUGKBIH.js";import{a as L}from"./chunk-HCBYKLMW.js";import{a as u,b as c,i as A}from"./chunk-C44QQJR4.js";import{a as D}from"./chunk-6YGTRKDT.js";import{e as h}from"./chunk-UR6MHSHU.js";var x=h(D(),1);import{readdirSync as N,mkdirSync as B,statSync as k}from"fs";import{join as P}from"path";var r=h(L(),1);function O(n){try{return N(n).filter(l=>{try{return k(P(n,l)).isDirectory()}catch{return!1}})}catch{return[]}}function E(n,l,f,v){return{name:n,path:l,label:n,isActive:v}}function H({currentPath:n,onSelect:l,onCancel:f}){let s=O(d).map(i=>{let e=P(d,i);return E(i,e,n,e===n)}),p=!n,R=s.length+2,[a,C]=(0,x.useState)(()=>{if(p)return 0;let i=s.findIndex(e=>e.isActive);return i>=0?i+1:0}),[T,I]=(0,x.useState)(!1),[S,g]=(0,x.useState)("");return A((i,e)=>{if(T){if(e.escape){I(!1),g("");return}if(e.return){let t=S.trim();if(t){let m=P(d,t);B(m,{recursive:!0}),l(m),f()}return}if(e.backspace||e.delete){g(t=>t.slice(0,-1));return}i&&!e.ctrl&&!e.meta&&g(t=>t+i);return}if(e.escape){f();return}if(e.upArrow){C(t=>Math.max(0,t-1));return}if(e.downArrow){C(t=>Math.min(R-1,t+1));return}if(e.return){if(a===0){p||l(""),f();return}if(a===s.length+1){B(d,{recursive:!0}),I(!0),g("");return}let t=s[a-1];t&&!t.isActive&&l(t.path),f();return}}),T?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile \u203A New"}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(c,{color:o.secondary,children:"Name: "}),(0,r.jsx)(c,{children:S}),(0,r.jsx)(c,{color:o.dim,children:"\u2588"})]}),(0,r.jsx)(b,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:"back"})]}):(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile"}),(0,r.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,r.jsxs)(c,{color:p?o.green:a===0?o.orange:o.dim,children:[a===0?"\u276F ":" ","Use temporary (no profile)",p?" \u25CF active":""]}),s.map((i,e)=>{let m=e+1===a,w=m?"\u276F ":" ",y=i.isActive?o.green:m?o.orange:void 0;return(0,r.jsxs)(c,{color:y,children:[w,i.label,i.isActive?" \u25CF active":""]},i.name)}),(0,r.jsxs)(c,{color:a===s.length+1?o.orange:o.dim,children:[a===s.length+1?"\u276F ":" ","+ Create new"]})]}),(0,r.jsx)(b,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}export{O as a,E as b,H as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as h}from"./chunk-VYYTENPY.js";import{a as f}from"./chunk-JRADU3PO.js";import{a as m}from"./chunk-JT7I6OST.js";var o=class extends Error{constructor(a,l){super(a);this.code=l;this.name="AuthError"}};async function k(c){let{creds:i,env:a,usernameFlag:l,accessKeyFlag:g,log:t}=c,e=null,u=null;if(l&&g)e={username:l,access_key:g},t("info","AUTH_RESOLVE_FLAGS","Auth resolved via CLI flags",{username:l});else{let r=i.resolveAuth();r?.method==="basic"&&(e={username:r.username,access_key:r.access_key},t("info","AUTH_RESOLVE_CONFIG","Auth resolved via config",{username:r.username}))}if(!e){let{credentials:r,profile:E}=i.getActiveCredentials();if(!r)throw new o("Not authenticated \u2014 no credentials found","not_authenticated");if(u=r.access_token,r.expires_at-Date.now()/1e3<300)try{let n=await f({creds:i,profile:E,env:a,credentials:r});n&&(u=n.accessToken,t("info","AUTH_TOKEN_REFRESHED","OAuth token refreshed"))}catch(n){let d=n instanceof Error?n.message:String(n);throw t("error","TOKEN_REFRESH_FAILED","Token refresh failed",{error:d}),new o(`Token refresh failed: ${d}`,"refresh_failed")}}let v=m(a),b=async()=>u,y=e?{username:e.username,access_key:e.access_key}:null,p=new h(v.controllerBaseUrl,b,y,t),s=await p.resolve();return s&&!e&&(e={username:s.username,access_key:s.access_key},t("info","AUTH_RESOLVE_CONTROLLER","Auth resolved via controller",{username:s.username})),{basicAuth:e,token:u,resolver:p,resolvedCreds:s}}export{o as a,k as b};
2
+ import{a as h}from"./chunk-JRQKUQWL.js";import{a as f}from"./chunk-ZFZ7YXEU.js";import{a as m}from"./chunk-WLOGO44E.js";var o=class extends Error{constructor(a,l){super(a);this.code=l;this.name="AuthError"}};async function k(c){let{creds:i,env:a,usernameFlag:l,accessKeyFlag:g,log:t}=c,e=null,u=null;if(l&&g)e={username:l,access_key:g},t("info","AUTH_RESOLVE_FLAGS","Auth resolved via CLI flags",{username:l});else{let r=i.resolveAuth();r?.method==="basic"&&(e={username:r.username,access_key:r.access_key},t("info","AUTH_RESOLVE_CONFIG","Auth resolved via config",{username:r.username}))}if(!e){let{credentials:r,profile:E}=i.getActiveCredentials();if(!r)throw new o("Not authenticated \u2014 no credentials found","not_authenticated");if(u=r.access_token,r.expires_at-Date.now()/1e3<300)try{let n=await f({creds:i,profile:E,env:a,credentials:r});n&&(u=n.accessToken,t("info","AUTH_TOKEN_REFRESHED","OAuth token refreshed"))}catch(n){let d=n instanceof Error?n.message:String(n);throw t("error","TOKEN_REFRESH_FAILED","Token refresh failed",{error:d}),new o(`Token refresh failed: ${d}`,"refresh_failed")}}let v=m(a),b=async()=>u,y=e?{username:e.username,access_key:e.access_key}:null,p=new h(v.controllerBaseUrl,b,y,t),s=await p.resolve();return s&&!e&&(e={username:s.username,access_key:s.access_key},t("info","AUTH_RESOLVE_CONTROLLER","Auth resolved via controller",{username:s.username})),{basicAuth:e,token:u,resolver:p,resolvedCreds:s}}export{o as a,k as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as u,b as x}from"./chunk-PSWB3BWQ.js";import{y as m}from"./chunk-PH22FRN5.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as r,b as i}from"./chunk-C44QQJR4.js";import{e as n}from"./chunk-UR6MHSHU.js";var e=n(f(),1);function C({title:B,titleColor:c,borderColor:d,variant:p,rows:s,footer:t,labelWidth:l=14,marginBottom:b=1}){return(0,e.jsxs)(u,{title:B,titleColor:c,borderColor:d,variant:p,marginBottom:b,children:[s.map((o,a)=>typeof o.value=="string"?(0,e.jsx)(x,{label:o.label,value:o.value,valueColor:o.valueColor,labelWidth:l},`${o.label}-${a}`):(0,e.jsxs)(r,{children:[(0,e.jsx)(r,{width:l,children:(0,e.jsx)(i,{color:m.dim,children:o.label})}),o.value]},`${o.label}-${a}`)),t&&(0,e.jsx)(r,{marginTop:1,children:t})]})}export{C as a};
2
+ import{a as u,b as x}from"./chunk-PQUMOFT5.js";import{x as m}from"./chunk-CCUGKBIH.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as r,b as i}from"./chunk-C44QQJR4.js";import{e as n}from"./chunk-UR6MHSHU.js";var e=n(f(),1);function C({title:B,titleColor:c,borderColor:d,variant:p,rows:s,footer:t,labelWidth:l=14,marginBottom:b=1}){return(0,e.jsxs)(u,{title:B,titleColor:c,borderColor:d,variant:p,marginBottom:b,children:[s.map((o,a)=>typeof o.value=="string"?(0,e.jsx)(x,{label:o.label,value:o.value,valueColor:o.valueColor,labelWidth:l},`${o.label}-${a}`):(0,e.jsxs)(r,{children:[(0,e.jsx)(r,{width:l,children:(0,e.jsx)(i,{color:m.dim,children:o.label})}),o.value]},`${o.label}-${a}`)),t&&(0,e.jsx)(r,{marginTop:1,children:t})]})}export{C as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as f}from"./chunk-5HYXTFGB.js";import{y as t}from"./chunk-PH22FRN5.js";import{a as x}from"./chunk-HCBYKLMW.js";import{a,b as n}from"./chunk-C44QQJR4.js";import{a as R}from"./chunk-6YGTRKDT.js";import{e as c}from"./chunk-UR6MHSHU.js";var p=c(R(),1);var e=c(x(),1);function v(){return[{name:"convert",label:"Converting session data",status:"pending"},{name:"zip",label:"Compressing artifacts",status:"pending"},{name:"presign",label:"Requesting upload URLs",status:"pending"},{name:"upload",label:"Uploading to KaneAI",status:"pending"},{name:"atomic_replace",label:"Replacing local output",status:"pending"},{name:"commit_lock",label:"Committing to TMS",status:"pending"},{name:"finalize",label:"Finalizing test case",status:"pending"},{name:"code_export",label:"Downloading test code",status:"pending"}]}function U(s,o,d,i){return s.map(l=>l.name===o?{...l,status:d,detail:i}:l)}function D(s){let o=s/1e3;if(o<60)return`${o.toFixed(1)}s`;let d=Math.floor(o/60),i=Math.round(o%60);return`${d}m ${i}s`}function w(s){let[o,d]=(0,p.useState)(0),i=p.default.useRef(Date.now());return(0,p.useEffect)(()=>{if(!s)return;i.current=Date.now();let l=setInterval(()=>{d(Date.now()-i.current)},100);return()=>clearInterval(l)},[s]),o}function h({steps:s,status:o,testUrl:d,error:i}){let l=w(o==="uploading");return o==="uploading"?(0,e.jsxs)(a,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(n,{color:t.orange,children:"\u2601 "}),(0,e.jsx)(n,{color:t.orange,bold:!0,children:"Saving to KaneAI"}),(0,e.jsxs)(n,{color:t.dim,children:[" ",D(l)]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:s.filter(r=>r.status!=="skipped"||r.detail).map((r,S,T)=>{let b=S===T.length-1?"\u2514\u2500":"\u251C\u2500",u=r.status==="done",m=r.status==="running",g=r.status==="failed",B=r.status==="skipped";return(0,e.jsxs)(a,{children:[(0,e.jsxs)(n,{color:t.dim,children:[" ",b," "]}),(0,e.jsx)(a,{width:3,children:m?(0,e.jsx)(f,{}):u?(0,e.jsx)(n,{color:t.green,children:"\u2713"}):g?(0,e.jsx)(n,{color:t.red,children:"\u2717"}):B?(0,e.jsx)(n,{color:t.muted,children:"\u2013"}):(0,e.jsx)(n,{color:t.muted,children:"\u25CB"})}),(0,e.jsx)(n,{color:u?t.dim:m?void 0:g?t.red:t.muted,children:r.label}),r.detail&&(0,e.jsxs)(n,{color:t.dim,children:[" ",r.detail]})]},r.name)})}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(n,{color:t.muted,children:" press Ctrl+C twice to force exit"})})]}):o==="success"?(0,e.jsx)(e.Fragment,{}):(0,e.jsxs)(a,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(n,{color:t.red,children:"\u2601 "}),(0,e.jsx)(n,{color:t.red,bold:!0,children:"Save failed"})]}),i&&(0,e.jsxs)(a,{marginTop:0,children:[(0,e.jsx)(n,{color:t.dim,children:" "}),(0,e.jsx)(n,{color:t.dim,children:i})]})]})}export{v as a,U as b,h as c};
2
+ import{a as f}from"./chunk-5NSYHRDN.js";import{x as t}from"./chunk-CCUGKBIH.js";import{a as x}from"./chunk-HCBYKLMW.js";import{a,b as n}from"./chunk-C44QQJR4.js";import{a as R}from"./chunk-6YGTRKDT.js";import{e as c}from"./chunk-UR6MHSHU.js";var p=c(R(),1);var e=c(x(),1);function v(){return[{name:"convert",label:"Converting session data",status:"pending"},{name:"zip",label:"Compressing artifacts",status:"pending"},{name:"presign",label:"Requesting upload URLs",status:"pending"},{name:"upload",label:"Uploading to KaneAI",status:"pending"},{name:"atomic_replace",label:"Replacing local output",status:"pending"},{name:"commit_lock",label:"Committing to TMS",status:"pending"},{name:"finalize",label:"Finalizing test case",status:"pending"},{name:"code_export",label:"Downloading test code",status:"pending"}]}function U(s,o,d,i){return s.map(l=>l.name===o?{...l,status:d,detail:i}:l)}function D(s){let o=s/1e3;if(o<60)return`${o.toFixed(1)}s`;let d=Math.floor(o/60),i=Math.round(o%60);return`${d}m ${i}s`}function w(s){let[o,d]=(0,p.useState)(0),i=p.default.useRef(Date.now());return(0,p.useEffect)(()=>{if(!s)return;i.current=Date.now();let l=setInterval(()=>{d(Date.now()-i.current)},100);return()=>clearInterval(l)},[s]),o}function h({steps:s,status:o,testUrl:d,error:i}){let l=w(o==="uploading");return o==="uploading"?(0,e.jsxs)(a,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(n,{color:t.orange,children:"\u2601 "}),(0,e.jsx)(n,{color:t.orange,bold:!0,children:"Saving to KaneAI"}),(0,e.jsxs)(n,{color:t.dim,children:[" ",D(l)]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:s.filter(r=>r.status!=="skipped"||r.detail).map((r,S,T)=>{let b=S===T.length-1?"\u2514\u2500":"\u251C\u2500",u=r.status==="done",m=r.status==="running",g=r.status==="failed",B=r.status==="skipped";return(0,e.jsxs)(a,{children:[(0,e.jsxs)(n,{color:t.dim,children:[" ",b," "]}),(0,e.jsx)(a,{width:3,children:m?(0,e.jsx)(f,{}):u?(0,e.jsx)(n,{color:t.green,children:"\u2713"}):g?(0,e.jsx)(n,{color:t.red,children:"\u2717"}):B?(0,e.jsx)(n,{color:t.muted,children:"\u2013"}):(0,e.jsx)(n,{color:t.muted,children:"\u25CB"})}),(0,e.jsx)(n,{color:u?t.dim:m?void 0:g?t.red:t.muted,children:r.label}),r.detail&&(0,e.jsxs)(n,{color:t.dim,children:[" ",r.detail]})]},r.name)})}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(n,{color:t.muted,children:" press Ctrl+C twice to force exit"})})]}):o==="success"?(0,e.jsx)(e.Fragment,{}):(0,e.jsxs)(a,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(n,{color:t.red,children:"\u2601 "}),(0,e.jsx)(n,{color:t.red,bold:!0,children:"Save failed"})]}),i&&(0,e.jsxs)(a,{marginTop:0,children:[(0,e.jsx)(n,{color:t.dim,children:" "}),(0,e.jsx)(n,{color:t.dim,children:i})]})]})}export{v as a,U as b,h as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as h}from"./chunk-7VTYRTEJ.js";import{y as l}from"./chunk-PH22FRN5.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as c,b as f,i as P}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as x}from"./chunk-UR6MHSHU.js";var L=x(B(),1);var n=x(A(),1);function S(r,d,s,u,m){let p=s==="basic"&&u?`basic (${u})`:s,i=20,a=`${r} [${d}]`,g="\xB7".repeat(Math.max(2,i-a.length+3));return{label:`${a} ${g} ${p}`,profile:r,env:d,isActive:m}}function M({creds:r,onSwitch:d,onCancel:s}){let u=r.listProfiles(),m=r.getActiveProfile(),p=r.getDefaultEnv(),i=u.map(e=>{let o=r.loadBasicAuth(e.profile,e.env),t=r.loadCredentials(e.profile,e.env)!==null,v=o?"basic":t?"oauth":"none",b=o?o.username:null,w=e.profile===m&&e.env===p;return S(e.profile,e.env,v,b,w)}),[a,g]=(0,L.useState)(()=>{let e=i.findIndex(o=>o.isActive);return e>=0?e:0});return P((e,o)=>{if(o.escape){s();return}if(o.upArrow){g(t=>Math.max(0,t-1));return}if(o.downArrow){g(t=>Math.min(i.length-1,t+1));return}if(o.return&&i[a]){let t=i[a];t.isActive||d(t.profile,t.env),s();return}}),i.length===0?(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{marginTop:1,children:(0,n.jsx)(f,{color:l.dim,children:"No profiles \u2014 use Login to create one"})}),(0,n.jsx)(h,{bindings:[],escBackLabel:"back"})]}):(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{flexDirection:"column",marginTop:1,children:i.map((e,o)=>{let t=o===a,v=t?"\u276F ":" ",b=e.isActive?l.green:t?l.orange:void 0;return(0,n.jsxs)(f,{color:b,children:[v,e.label,e.isActive?" \u25CF active":""]},`${e.profile}-${e.env}`)})}),(0,n.jsx)(h,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"switch"}],escBackLabel:"back"})]})}export{S as a,M as b};
2
+ import{a as h}from"./chunk-ZIRMSWKS.js";import{x as l}from"./chunk-CCUGKBIH.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as c,b as f,i as P}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as x}from"./chunk-UR6MHSHU.js";var L=x(B(),1);var n=x(A(),1);function S(r,d,s,u,m){let p=s==="basic"&&u?`basic (${u})`:s,i=20,a=`${r} [${d}]`,g="\xB7".repeat(Math.max(2,i-a.length+3));return{label:`${a} ${g} ${p}`,profile:r,env:d,isActive:m}}function M({creds:r,onSwitch:d,onCancel:s}){let u=r.listProfiles(),m=r.getActiveProfile(),p=r.getDefaultEnv(),i=u.map(e=>{let o=r.loadBasicAuth(e.profile,e.env),t=r.loadCredentials(e.profile,e.env)!==null,v=o?"basic":t?"oauth":"none",b=o?o.username:null,w=e.profile===m&&e.env===p;return S(e.profile,e.env,v,b,w)}),[a,g]=(0,L.useState)(()=>{let e=i.findIndex(o=>o.isActive);return e>=0?e:0});return P((e,o)=>{if(o.escape){s();return}if(o.upArrow){g(t=>Math.max(0,t-1));return}if(o.downArrow){g(t=>Math.min(i.length-1,t+1));return}if(o.return&&i[a]){let t=i[a];t.isActive||d(t.profile,t.env),s();return}}),i.length===0?(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{marginTop:1,children:(0,n.jsx)(f,{color:l.dim,children:"No profiles \u2014 use Login to create one"})}),(0,n.jsx)(h,{bindings:[],escBackLabel:"back"})]}):(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{flexDirection:"column",marginTop:1,children:i.map((e,o)=>{let t=o===a,v=t?"\u276F ":" ",b=e.isActive?l.green:t?l.orange:void 0;return(0,n.jsxs)(f,{color:b,children:[v,e.label,e.isActive?" \u25CF active":""]},`${e.profile}-${e.env}`)})}),(0,n.jsx)(h,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"switch"}],escBackLabel:"back"})]})}export{S as a,M as b};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Ke}from"./chunk-ZKSN2SJ7.js";import{a as ze,b as ue}from"./chunk-3Q6WAK6P.js";import{a as Ue,b as We}from"./chunk-JZ26R6UL.js";import{a as Z,b as Le,e as le,f as de,g as Be,h as He}from"./chunk-RN3YHD4S.js";import{a as Ne,c as je,d as Fe,e as me,f as Ge}from"./chunk-ZGBSGZZM.js";import{a as Ae,b as Ie,c as Oe}from"./chunk-J27JJWMT.js";import{a as Re,b as Ce,c as Te}from"./chunk-BB2W35TW.js";import{a as qe}from"./chunk-L2TV4G56.js";import{c as Pe}from"./chunk-6KPPGMO2.js";import{a as $e,e as Ee}from"./chunk-GFKCTYCA.js";import{a as Me}from"./chunk-IMR64OCZ.js";import{c as Ve}from"./chunk-V444REBC.js";import{b as ye,c as we,d as ve,e as ae,h as oe,i as ce}from"./chunk-ZSXDZI56.js";import{b as ne}from"./chunk-VZ7KXRXB.js";import{a as be,b as re}from"./chunk-IDX3TOPY.js";import{A as U}from"./chunk-TH47OOBV.js";import{f as De}from"./chunk-DUAXZYAD.js";import{a as ke,e as xe,f as Se}from"./chunk-DBIBROYW.js";import{d as z,e as X}from"./chunk-WXHQYYD5.js";import{a as _e}from"./chunk-5EOX4MEY.js";import{mkdirSync as St,appendFileSync as Dt,rmdirSync as dt}from"fs";import{randomBytes as $t}from"crypto";import{dirname as mt,join as he}from"path";function Qe(t,e){let n=[];for(let i of e??[]){let g=t.resolve(i.ref)?.tip??null;g!==i.cid&&n.push({ref:i.ref,pinned:i.cid,now:g})}return n}import{existsSync as ge,readFileSync as pe,readdirSync as pt}from"fs";import{join as te}from"path";var Ye=`
2
+ import{a as Ke}from"./chunk-ZKSN2SJ7.js";import{a as ze,b as ue}from"./chunk-3Q6WAK6P.js";import{a as Ue,b as We}from"./chunk-JZ26R6UL.js";import{a as Z,b as Le,e as le,f as de,g as Be,h as He}from"./chunk-AJPLHW4T.js";import{a as Ne,c as je,d as Fe,e as me,f as Ge}from"./chunk-ZGBSGZZM.js";import{a as Ae,b as Ie,c as Oe}from"./chunk-W27F2NWA.js";import{a as Re,b as Ce,c as Te}from"./chunk-BB2W35TW.js";import{a as qe}from"./chunk-L2TV4G56.js";import{c as Pe}from"./chunk-6KPPGMO2.js";import{a as $e,e as Ee}from"./chunk-GFKCTYCA.js";import{a as Me}from"./chunk-IMR64OCZ.js";import{c as Ve}from"./chunk-V444REBC.js";import{b as ye,c as we,d as ve,e as ae,h as oe,i as ce}from"./chunk-ZSXDZI56.js";import{b as ne}from"./chunk-VZ7KXRXB.js";import{a as be,b as re}from"./chunk-IDX3TOPY.js";import{A as U}from"./chunk-TH47OOBV.js";import{f as De}from"./chunk-DUAXZYAD.js";import{a as ke,e as xe,f as Se}from"./chunk-DBIBROYW.js";import{d as z,e as X}from"./chunk-WXHQYYD5.js";import{a as _e}from"./chunk-5EOX4MEY.js";import{mkdirSync as St,appendFileSync as Dt,rmdirSync as dt}from"fs";import{randomBytes as $t}from"crypto";import{dirname as mt,join as he}from"path";function Qe(t,e){let n=[];for(let i of e??[]){let g=t.resolve(i.ref)?.tip??null;g!==i.cid&&n.push({ref:i.ref,pinned:i.cid,now:g})}return n}import{existsSync as ge,readFileSync as pe,readdirSync as pt}from"fs";import{join as te}from"path";var Ye=`
3
3
  version: 1
4
4
  techniques:
5
5
  - id: eqp
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Y,b as Z,c as nn,d as en,e as tn}from"./chunk-DYGUHGZ6.js";import{b as rn,c as sn}from"./chunk-P7YZ3PU3.js";import{m as X,o as P}from"./chunk-56PAQAX5.js";import{a as jn}from"./chunk-6YGTRKDT.js";import{e as Pn}from"./chunk-UR6MHSHU.js";function on(i){return{command:"start",...i}}function an(i,e,o){return{command:"run",run_id:i,kind:e,...o}}function un(i){return{command:"cancel",...i?{run_id:i}:{}}}function dn(i){return{command:"ask_user_response",answer:i}}function ln(){return{command:"shutdown"}}var z=Symbol("run-queue-end"),G=class{items=[];waiting=null;ended=!1;error=null;push(e){if(this.waiting){let{resolve:o}=this.waiting;this.waiting=null,o(e)}else this.items.push(e)}end(){if(this.ended=!0,this.waiting){let{resolve:e}=this.waiting;this.waiting=null,e(z)}}fail(e){if(this.error=e,this.waiting){let{reject:o}=this.waiting;this.waiting=null,o(e)}}next(){return this.items.length>0?Promise.resolve(this.items.shift()):this.error?Promise.reject(this.error):this.ended?Promise.resolve(z):new Promise((e,o)=>{this.waiting={resolve:e,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(e){this.env=e.env,this.runner=e.runner,this.log=e.log,this.sessionId=e.sessionId,this.spawnFn=e.spawn??Z;let o;this.exited=new Promise(c=>{o=c}),this.exitResolve=o}async start(e){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(on(e)),await o}async*run(e,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 '${e}'`);if(this.activeRun)throw new Error(`PersistentRunner.run overlap: '${this.activeRun.runId}' still in flight`);let g=new G,w={runId:e,queue:g};this.activeRun=w,this.writeCommand(an(e,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===e)))break}}finally{this.activeRun===w&&(this.activeRun=null)}}sendUserResponse(e){this.writeCommand(dn(e))}cancel(e){this.writeCommand(un(e))}kill(){this.proc?.child.kill("SIGTERM")}async shutdown(){this.shuttingDown=!0,this.proc&&(this.writeCommand(ln()),await this.exited)}get stderr(){return this.proc?.getStderr()??""}get diedUnexpectedly(){return this.exitedUnexpectedly}writeCommand(e){let o=JSON.stringify(e)+`
2
+ import{a as Y,b as Z,c as nn,d as en,e as tn}from"./chunk-AMULIFC5.js";import{b as rn,c as sn}from"./chunk-P7YZ3PU3.js";import{m as X,o as P}from"./chunk-56PAQAX5.js";import{a as jn}from"./chunk-6YGTRKDT.js";import{e as Pn}from"./chunk-UR6MHSHU.js";function on(i){return{command:"start",...i}}function an(i,e,o){return{command:"run",run_id:i,kind:e,...o}}function un(i){return{command:"cancel",...i?{run_id:i}:{}}}function dn(i){return{command:"ask_user_response",answer:i}}function ln(){return{command:"shutdown"}}var z=Symbol("run-queue-end"),G=class{items=[];waiting=null;ended=!1;error=null;push(e){if(this.waiting){let{resolve:o}=this.waiting;this.waiting=null,o(e)}else this.items.push(e)}end(){if(this.ended=!0,this.waiting){let{resolve:e}=this.waiting;this.waiting=null,e(z)}}fail(e){if(this.error=e,this.waiting){let{reject:o}=this.waiting;this.waiting=null,o(e)}}next(){return this.items.length>0?Promise.resolve(this.items.shift()):this.error?Promise.reject(this.error):this.ended?Promise.resolve(z):new Promise((e,o)=>{this.waiting={resolve:e,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(e){this.env=e.env,this.runner=e.runner,this.log=e.log,this.sessionId=e.sessionId,this.spawnFn=e.spawn??Z;let o;this.exited=new Promise(c=>{o=c}),this.exitResolve=o}async start(e){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(on(e)),await o}async*run(e,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 '${e}'`);if(this.activeRun)throw new Error(`PersistentRunner.run overlap: '${this.activeRun.runId}' still in flight`);let g=new G,w={runId:e,queue:g};this.activeRun=w,this.writeCommand(an(e,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===e)))break}}finally{this.activeRun===w&&(this.activeRun=null)}}sendUserResponse(e){this.writeCommand(dn(e))}cancel(e){this.writeCommand(un(e))}kill(){this.proc?.child.kill("SIGTERM")}async shutdown(){this.shuttingDown=!0,this.proc&&(this.writeCommand(ln()),await this.exited)}get stderr(){return this.proc?.getStderr()??""}get diedUnexpectedly(){return this.exitedUnexpectedly}writeCommand(e){let o=JSON.stringify(e)+`
3
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:e,signal:o}=await this.proc.exited;this.onExit(e,o)}onReady(){if(this.pendingReady){let{resolve:e}=this.pendingReady;this.pendingReady=null,e()}}routeEvent(e){let o=this.activeRun;if(!o){this.log?.("warn","PERSISTENT_RUNNER_ORPHAN_EVENT","Runner event with no active run",{event_type:e.type});return}o.queue.push(e)}onExit(e,o){if(!this.finalized){if(this.finalized=!0,this.exitInfo={code:e,signal:o},this.shuttingDown||(this.exitedUnexpectedly=!0),this.exitResolve({code:e,signal:o}),this.pendingReady){let{reject:c}=this.pendingReady;this.pendingReady=null,c(new Error(`v16-runner exited before ready (code=${e}, 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=${e}, signal=${o??"none"})${g?`
4
4
  ${g}`:""}`))}}}}};var p=Pn(jn(),1);function cn(i){let e={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&&(e.device=i.device),i.auth&&(e.auth=i.auth),i.username&&(e.username=i.username),i.access_key&&(e.access_key=i.access_key),e}function j(i,e){let o=null,c=(g,w)=>{for(let v=0;v<g.length;v++){let b=g[v],h=[...w,v];e(b)&&(o===null||h.length>o.length)&&(o=h),b.children&&b.children.length>0&&c(b.children,h)}};return c(i,[]),o}function N(i,e,o){if(e.length===0)return[...i];let c=e[0],g=[...i],w=g[c];if(e.length===1)g[c]=o(w);else{let v=e.slice(1),b=N(w.children??[],v,o);g[c]={...w,children:b}}return g}function pn(){return{steps:[],maxOrdinal:0}}function Nn(i,e){if(e.type==="run_start"&&e.child_id)return e.environment?.resolution?{...i,resolution:e.environment.resolution}:i;if(e.type==="run_start"){let o=sn(i.runnerEnvironment,rn(e.environment));if(o)return{...i,runnerEnvironment:o,...o.resolution?{resolution:o.resolution}:{}}}if(e.type==="step_end"&&typeof e.ordinal=="number"&&e.id){let o={id:e.id,ordinal:e.ordinal,status:e.status,...e.kind?{kind:e.kind}:{},...typeof e.duration=="number"?{duration_ms:Math.round(e.duration*1e3)}:{},...typeof e.action_id=="string"&&e.action_id?{action_id:e.action_id}:{}};return{...i,steps:[...i.steps,o],maxOrdinal:Math.max(i.maxOrdinal,e.ordinal)}}return i}function V(i){let e=i.indexOf(": ");return e>0&&e<15?i.slice(e+2):i}function W(i){return i.map(e=>{let o=e.children?W(e.children):e.children;return e.status==="running"?{...e,status:"stopped",phase:void 0,children:o}:o!==e.children?{...e,children:o}:e})}function Gn(i,e,o,c,g){let[w,v]=(0,p.useState)(!1),[b,h]=(0,p.useState)([]),[hn,T]=(0,p.useState)(null),[fn,B]=(0,p.useState)(null),[mn,I]=(0,p.useState)(null),[vn,J]=(0,p.useState)(null),[gn,H]=(0,p.useState)([]),[Rn,K]=(0,p.useState)(null),[Sn,yn]=(0,p.useState)(void 0),[wn,$]=(0,p.useState)(0),y=(0,p.useRef)(null),E=(0,p.useRef)(null),S=(0,p.useRef)(null),_=(0,p.useRef)(0),F=(0,p.useRef)(!1),U=(0,p.useRef)(pn()),O=(0,p.useRef)(null),xn=(0,p.useCallback)(async(m,x)=>{let Q=O.current;if(Q)try{await Q}catch{}h([]),T(null),B(null),I(null),J(null),H([]),K(null),yn(m.max_steps),v(!0),S.current=null,_.current=0,U.current=pn();let k=y.current;if(k&&E.current!==m.session_id){try{k.kill()}catch{}y.current=null,E.current=null,$(n=>n+1),k=null}if(!k){let n=Y();if(!n){I("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available."),v(!1);return}let d=en({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 nn(d,m.device);let u=new D({env:d,runner:n,log:x?.log,sessionId:m.session_id});y.current=u,E.current=m.session_id,k=u,X("runner",()=>{try{u.kill()}catch{}});let s=cn(m);try{await u.start(s)}catch(a){I(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,tn(M,{environment:x?.environment});let kn=`run-${m.run_index}`,Cn=m.mode==="replay"?"replay":"author",L=k,q=(async()=>{F.current=!1;for await(let n of L.run(kn,Cn,M)){if(F.current)break;switch(U.current=Nn(U.current,n),n.type){case"run_start":if(n.child_id)break;if(S.current&&!S.current.isSingleFlow){let d=_.current;_.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=n.flows??[],u=n.count??d.length,s={flows:d,isSingleFlow:n.is_single_flow??u<=1};J(s),S.current=s,_.current=0,h(d.map((a,t)=>({index:t+1,objective:a??`Flow ${t+1}`,status:"pending"})));break}case"step_start":{e?.("STEP_START",`Step ${n.index} started`,{index:n.index,objective:n.objective,child_id:n.child_id});let d=n.index,u=n.objective??`Step ${d}`,s=n.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,_.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=W(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":{e?.("STEP_EVENT",`Step ${n.index} ${n.event}`,{index:n.index,phase:n.event,action_type:n.action_type,detail:n.detail,child_id:n.child_id});let d=n.child_id,u=S.current&&!S.current.isSingleFlow;if(n.event==="cm_init"&&n.checkpoint_count!=null){H(s=>[...s,n.checkpoint_count]);break}if(n.event==="replay_started"){K({recordingLength:n.recording_length??0});break}if(n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&o?.(n.detail),d){let s=t=>{if(t.index!==n.index||t.childId!==d)return t;let r={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(r.objective=n.detail),n.action_type&&(r.actionType=n.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,_.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===n.index&&R.childId===void 0))l.push({index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type});else for(let R=0;R<l.length;R++){if(l[R].index!==n.index||l[R].childId!==void 0)continue;let C={phase:n.event};n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(C.objective=n.detail),n.action_type&&(C.actionType=n.action_type),l[R]={...l[R],...C}}return r.children=l,t[s]=r,t})}else h(s=>s.some(t=>t.index===n.index)?s.map(t=>{if(t.index!==n.index)return t;let r={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(r.objective=n.detail),n.action_type&&(r.actionType=n.action_type),{...t,...r}}):[...W(s),{index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type}]);break}case"step_end":{e?.("STEP_END",`Step ${n.index} ${n.status}`,{index:n.index,status:n.status,duration:n.duration,summary:n.summary,child_id:n.child_id}),c?.();let d=n.child_id,u=S.current&&!S.current.isSingleFlow;if(d){let s=t=>t.index===n.index&&t.childId===d?{...t,status:n.status,duration:n.duration,phase:void 0,objective:t.objective.startsWith("Step ")?V(n.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,_.current-1);h(a=>{let t=[...a];if(s>=t.length)return a;let r={...t[s]},l=(r.children??[]).map(f=>f.index===n.index&&f.childId===void 0?{...f,status:n.status,duration:n.duration,phase:void 0,objective:f.objective.startsWith("Step ")?V(n.summary||f.objective):f.objective}:f);return r.children=l,t[s]=r,t})}else h(s=>s.map(a=>a.index===n.index?{...a,status:n.status,duration:n.duration,phase:void 0,objective:a.objective.startsWith("Step ")?V(n.summary||a.objective):a.objective}:a));{let a=S.current&&!S.current.isSingleFlow?Math.max(0,_.current-1):0,t=typeof n.ordinal=="number"&&n.id?{ordinal:n.ordinal,id:n.id}:void 0;i?.(n.index,a,n.child_id,t)}break}case"child_agent_start":{let d=n.objective??"",u=n.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=n.child_id,u=`child ${n.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?.(n);break;case"ask_user":T(n.question??"");break;case"run_end":h(d=>d.map(u=>u.status==="running"?{...u,status:n.status,phase:void 0}:u)),v(!1),B(n);break;case"error":v(!1),I(n.message??"Runner error"),h(d=>d.map(u=>u.status==="running"?{...u,status:"failed",phase:void 0}:u));break}}})().catch(n=>{if(y.current!==L)return;let u=[n instanceof Error?n.message:String(n)],s=L.stderr;s&&!u.join(`
5
5
  `).includes(s)&&u.push(s),I(u.join(`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as c}from"./chunk-JT7I6OST.js";import{a as n}from"./chunk-RZ4F3BHX.js";import{v as s,w as a}from"./chunk-PH22FRN5.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l as a};
2
+ import{a as c}from"./chunk-WLOGO44E.js";import{a as n}from"./chunk-RZ4F3BHX.js";import{u as s,v as a}from"./chunk-CCUGKBIH.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l as a};
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- function l(r){let{isAgent:c,log:m}=r,a=r.stdout??process.stderr,s=r.stdin??process.stdin,p=t=>{c&&process.stdout.write(JSON.stringify(t)+`
3
- `)};return{async runSteps(t){let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{TestMdRunView:i}=await import("./TestMdRunView-PPM6LD3I.js"),{ScrollbackProvider:n}=await import("./scrollback-JLPJR25X.js"),{waitUntilExit:d}=o(e.createElement(n,null,e.createElement(i,t)),{stdout:a,stdin:s,exitOnCtrlC:!1});await d()},async runUpload(t,e){let{renderUploadProgress:o}=await import("./CliUploadProgress-LEOJTXHT.js");return await o(t,e)},async onSummary(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{AutoExitSummaryBox:i}=await import("./SummaryBox-QWKW5FHK.js"),{waitUntilExit:n}=o(e.createElement(i,{data:t}),{stdout:a,stdin:s});await n()}catch(e){m("warn","TEST_MD_SUMMARY_RENDER_FAILED","Summary box render failed",{error:String(e)})}},async onLinks(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{LinksBox:i}=await import("./LinksBox-6SKDUB5T.js"),{waitUntilExit:n}=o(e.createElement(i,t),{stdout:a,stdin:s});await n()}catch(e){m("warn","TEST_MD_LINKS_RENDER_FAILED","LinksBox render failed",{error:String(e)})}},onLockState(t){p({type:"test_md_lock_state",...t})},onRetryAttempt(t){p({type:"test_md_retry_attempt",...t})},onAgentEvent(t){p(t)}}}export{l as a};
2
+ function l(r){let{isAgent:m,log:d}=r,a=r.stdout??process.stderr,s=r.stdin??process.stdin,p=t=>{m&&process.stdout.write(JSON.stringify(t)+`
3
+ `)};return{async runSteps(t){let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{TestMdRunView:i}=await import("./TestMdRunView-6BY3IUH5.js"),{ScrollbackProvider:n}=await import("./scrollback-JLPJR25X.js"),{waitUntilExit:c}=o(e.createElement(n,null,e.createElement(i,t)),{stdout:a,stdin:s,exitOnCtrlC:!1});await c()},async runUpload(t,e){let{renderUploadProgress:o}=await import("./CliUploadProgress-Y7ITY2I7.js");return await o(t,e)},async onSummary(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{AutoExitSummaryBox:i}=await import("./SummaryBox-SLM3OFS2.js"),{waitUntilExit:n}=o(e.createElement(i,{data:t}),{stdout:a,stdin:s});await n()}catch(e){d("warn","TEST_MD_SUMMARY_RENDER_FAILED","Summary box render failed",{error:String(e)})}},async onLinks(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{LinksBox:i}=await import("./LinksBox-TAGYCFFO.js"),{waitUntilExit:n}=o(e.createElement(i,t),{stdout:a,stdin:s});await n()}catch(e){d("warn","TEST_MD_LINKS_RENDER_FAILED","LinksBox render failed",{error:String(e)})}},onLockState(t){p({type:"test_md_lock_state",...t})},onAdaptiveHeal(t){p({type:"test_md_adaptive_heal",...t})},onAgentEvent(t){p(t)}}}export{l as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as j}from"./chunk-CLGC7VEO.js";import{d as K}from"./chunk-RKXHVP2Z.js";import{a as L}from"./chunk-5Y2G4NC7.js";import{a as M}from"./chunk-YCCUBQY4.js";import{y as s}from"./chunk-PH22FRN5.js";import{a as O}from"./chunk-HCBYKLMW.js";import{a as x,b as n,i as D,k as E}from"./chunk-C44QQJR4.js";import{a as I}from"./chunk-6YGTRKDT.js";import{e as y}from"./chunk-UR6MHSHU.js";var g=y(O(),1);function ee(e){let t=e.findIndex(r=>r.free);return t>=0?t:null}var q=60,Q=100;function te({headline:e,ask:t=!1,rows:r,sel:o,focused:d,freeText:c=null,freeTextNote:h,sublines:b=[]}){let{stdout:p}=E(),i=p?.columns??80,v=i<q,k=Math.min(i-1,Q),u=a=>d&&o===a?(0,g.jsx)(n,{color:s.assuranceAccent,children:"\u276F"}):" ",m=t?`? ${e}`:e,A=Math.max(4,k-3),S=b.map((a,w)=>(0,g.jsx)(n,{color:s.dim,children:` ${a.length>A?`${a.slice(0,A-1)}\u2026`:a}`},`sub-${w}`)),R=0,B=r.map((a,w)=>a.free?c?(0,g.jsxs)(x,{flexDirection:"column",children:[(0,g.jsxs)(x,{children:[(0,g.jsxs)(n,{children:[(0,g.jsx)(n,{color:s.assuranceAccent,children:"\u276F"})," ",(0,g.jsx)(n,{color:s.dim,children:"\u270E "})]}),(0,g.jsx)(M,{value:c.value,onChange:c.onChange,onSubmit:c.onSubmit,onCancel:c.onCancel,placeholder:a.label})]}),h?(0,g.jsx)(n,{color:s.muted,children:` ${h}`}):null]},a.key):(0,g.jsxs)(n,{children:[u(w)," ",(0,g.jsx)(n,{color:s.dim,children:`\u270E ${a.label}`})]},a.key):(R+=1,(0,g.jsxs)(n,{bold:d&&o===w,children:[u(w),` ${R}. ${a.label}`,a.detail?(0,g.jsx)(n,{color:s.dim,bold:!1,children:` \u2014 ${a.detail}`}):null]},a.key)));return v?(0,g.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,g.jsx)(n,{bold:!0,color:s.assuranceAccent,children:m}),S,B]}):(0,g.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,g.jsx)(n,{bold:!0,color:s.assuranceAccent,children:m}),S,(0,g.jsx)(n,{children:" "}),B]})}var H=y(I(),1);var $=y(O(),1),N=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function le(e){let t=e.replace(/…$/,"");return t&&t.charAt(0).toLowerCase()+t.slice(1)}function F(e,t){if(e.length<=t)return e;if(t<=1)return"\u2026";let r=Math.ceil((t-1)/2),o=Math.floor((t-1)/2);return`${e.slice(0,r)}\u2026${o>0?e.slice(-o):""}`}function ce({status:e,meta:t,tallies:r,keys:o,child:d,cols:c}){let{stdout:h}=E(),b=c??h?.columns??80,p=e.kind==="working"||e.kind==="child-working",[i,v]=(0,H.useState)(0);L(()=>v(f=>f+1),p?120:null);let k=N[i%N.length],u,m;switch(e.kind){case"working":u=`${k} ${e.step}${e.elapsedS!==void 0?` \xB7 ${e.elapsedS}s`:""}`,m=s.assuranceAccent;break;case"waiting":u=`\u25CF waiting on you${e.pending?` \u2014 ${e.pending} question${e.pending===1?"":"s"}`:""}`,m=s.amber;break;case"idle":u="\u25CF idle",m=s.assuranceAccent;break;case"card":u=`\u25CF card ${e.n} of ${e.m}`,m=s.amber;break;case"child-working":u=`${k} child: ${e.step}`,m=s.assuranceAccent;break;case"child-waiting":u="\u25CF child waiting on you",m=s.amber;break}let A=d?`${t.verb} \u25B8 ${d.verb}`:t.verb,S=d?.sid?t.sid?`${F(t.sid,14)} \u25B8 ${d.sid}`:d.sid:t.sid,R=t.env==="prod"?"":t.env,B=[A,S,R].filter(Boolean),a=" \xB7 ",w=u.length+a.length+B.join(a).length,C=t.subject;if(C){let f=b-w-a.length;C=f>=8?F(C,f):void 0}let _=[A,...C?[C]:[],S,R].filter(Boolean).join(a);return(0,$.jsxs)(x,{flexDirection:"column",children:[(0,$.jsx)(n,{color:s.muted,children:"\u2500".repeat(Math.max(1,b))}),(0,$.jsxs)(n,{children:[(0,$.jsx)(n,{color:m,children:u}),(0,$.jsx)(n,{color:s.dim,children:`${a}${_}`})]}),(0,$.jsx)(n,{color:s.dim,children:r.items.length>0?r.items.join(a):" "}),(0,$.jsx)(n,{color:s.muted,children:o.join(a)})]})}var P=y(I(),1);function ue({onToggleThinking:e,onCtrlC:t,explorer:r,panel:o}){let c=(0,P.useRef)(null),h=(0,P.useRef)(""),b=()=>{c.current&&clearTimeout(c.current),c.current=null,h.current=""};return(0,P.useEffect)(()=>b,[]),D((p,i)=>{if(i.ctrl&&p==="t"){e();return}if(i.ctrl&&p==="c"){t();return}if(!i.ctrl&&p.includes("")){t();return}if(!i.ctrl&&p.includes("")){e();return}if(r&&r.isOpen()){let v=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{b(),r.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return){b(),i.return?r.onEnter():r.onMove(i.upArrow?-1:1);return}if(h.current+=p,h.current==="["){v();return}let k=h.current;b();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="",v();return}return}if(o&&o.isFocused()){let v=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{b(),o.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return||i.leftArrow||i.rightArrow){b(),i.return?o.onSelect():i.leftArrow?o.onLeft?.():i.rightArrow?o.onRight?.():o.onMove(i.upArrow?-1:1);return}if(h.current+=p,h.current==="["){v();return}let k=h.current;b();let u=/^\[([ABCD])/.exec(k);if(u){u[1]==="A"||u[1]==="B"?o.onMove(u[1]==="A"?-1:1):u[1]==="C"?o.onRight?.():o.onLeft?.();return}o.onBack();return}if(i.upArrow){o.onMove(-1);return}if(i.downArrow){o.onMove(1);return}if(i.leftArrow){o.onLeft?.();return}if(i.rightArrow){o.onRight?.();return}if(i.return){o.onSelect();return}if(i.escape){h.current="",v();return}if(/^[1-9]$/.test(p)){o.onDigit(Number(p));return}if(i.tab){o.onTab?.();return}if(p===" "&&o.isMulti()){o.onSpace();return}if(p&&!i.ctrl&&!i.meta){o.onType(p);return}return}}),null}var l=y(O(),1);function X(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 V(e){let t=X(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:V(e).length}var Y={ADD:{color:s.green??"green"},MODIFY:{color:"yellow"},ARCHIVE:{color:s.red},REVIEW:{color:"cyan"},PAIR:{color:"magenta"}},U=60;function be({card:e,position:t,sel:r=0,focused:o=!1,freeText:d=null,editorIntent:c="steer"}){let{stdout:h}=E(),b=h?.columns??80,p=b<U,i=V(e),v=W(e),k=Y[e.kind],u=f=>o&&r===f?(0,l.jsx)(n,{color:s.assuranceAccent,children:"\u276F"}):" ",m=e.impact,A=m&&"stale_refs"in m&&m.stale_refs.length>0?`${e.kind==="ARCHIVE"?"retiring leaves":"approving marks"} ${m.stale_refs.length} item(s) stale`+((m.direct_refs?.length??0)>0?` \u2014 ${m.direct_refs.length} directly touched: ${m.direct_refs.join(", ")}`:""):m&&"design_children"in m?`${e.kind==="REVIEW"?"archiving drops":"merging folds"} ${m.design_children} design child(ren)`:null,S=e.provenance&&e.provenance!==e.why?e.provenance:e.origin??null,R=[{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}]:[]],B=Math.max(...R.map(f=>f.label.length)),a="? reconcile",w=`item ${t.n} of ${t.of}`,C=(0,l.jsxs)(x,{flexDirection:"column",children:[(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsxs)(n,{bold:!0,children:[(0,l.jsx)(n,{color:k.color,children:`[${e.kind}]`}),` ${j(e.title)}`]})}),R.map((f,T)=>(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{color:s.dim,children:`${f.label.padEnd(B)} `}),(0,l.jsx)(n,{color:f.dimmer?s.dim:void 0,children:f.text})]})},`f-${T}`)),e.diffSummary?(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsx)(n,{color:s.dim,children:e.diffSummary})}):(e.diff??[]).map((f,T)=>(0,l.jsx)(x,{paddingLeft:4,children:(0,l.jsx)(n,{color:f.op==="-"?"red":"green",children:`${f.op==="-"?"\u2212":"+"} ${f.field==="criteria"?"criterion":f.field}: ${f.text}`})},`d-${T}`)),(e.citeLines??[]).map((f,T)=>(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsx)(n,{color:s.dim,children:f})},`c-${T}`)),(0,l.jsx)(n,{children:" "}),i.map((f,T)=>(0,l.jsxs)(n,{children:[u(T),` ${T+1}. ${f.label}`,(0,l.jsx)(n,{color:s.dim,children:` \u2014 ${f.detail}`})]},`o-${T}`)),v!==null||d&&c==="because"?d?(0,l.jsxs)(x,{flexDirection:"column",children:[(0,l.jsxs)(x,{children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{color:s.assuranceAccent,children:"\u276F"})," ",(0,l.jsx)(n,{color:s.dim,children:"\u270E "})]}),(0,l.jsx)(M,{value:d.value,onChange:d.onChange,onSubmit:d.onSubmit,onCancel:d.onCancel,placeholder:c==="because"?"why archive it?":"say what to adjust"})]}),(0,l.jsx)(n,{color:s.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"})]}):v!==null?(0,l.jsxs)(n,{children:[u(v)," ",(0,l.jsx)(n,{color:s.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(p)return(0,l.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,l.jsx)(n,{bold:!0,color:s.assuranceAccent,children:a}),(0,l.jsx)(n,{color:s.dim,children:w}),C]});let _=Math.max(2,Math.min(b-1,100)-a.length-w.length);return(0,l.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{bold:!0,color:s.assuranceAccent,children:a})," ".repeat(_),(0,l.jsx)(n,{color:s.dim,children:w})]}),(0,l.jsx)(n,{children:" "}),C]})}var z={"acceptance criteria":1,scenarios:2,"acceptance criteria + exercises":3,"tests + gaps":4};function we(e,t){let r=[],o=K(e.turns).entries.length;if(t==="design"){let c;for(let b=e.ledger.length-1;b>=0;b--){let p=e.ledger[b];if(p.kind==="banner"&&p.text.startsWith("designing: ")){c=p.text.slice(11);break}}let h=c?z[c]:void 0;h&&r.push(`phase ${h}/4`),o>0&&r.push(`${o} item${o===1?"":"s"} this session`)}else o>0&&r.push(`${o} saved as draft${o===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 ke(e,t){let r=[],o=e.applied+e.committed+e.retired;r.push(`${o} 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 Ae(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(o=>o.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 Se(e,t){let r=["\u2191\u2193 select","\u23CE confirm"];return e.some(o=>o.free)&&r.push("\u270E type your own"),t.escBack&&r.push("esc back"),{keys:r}}function Re(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{ee as a,te as b,le as c,ce as d,ue as e,X as f,V as g,W as h,be as i,we as j,ke as k,Ae as l,Se as m,Re as n};
2
+ import{a as j}from"./chunk-CLGC7VEO.js";import{d as K}from"./chunk-RKXHVP2Z.js";import{a as L}from"./chunk-5Y2G4NC7.js";import{a as M}from"./chunk-YCCUBQY4.js";import{x as s}from"./chunk-CCUGKBIH.js";import{a as O}from"./chunk-HCBYKLMW.js";import{a as x,b as n,i as D,k as E}from"./chunk-C44QQJR4.js";import{a as I}from"./chunk-6YGTRKDT.js";import{e as y}from"./chunk-UR6MHSHU.js";var g=y(O(),1);function ee(e){let t=e.findIndex(r=>r.free);return t>=0?t:null}var q=60,Q=100;function te({headline:e,ask:t=!1,rows:r,sel:o,focused:d,freeText:c=null,freeTextNote:h,sublines:b=[]}){let{stdout:p}=E(),i=p?.columns??80,v=i<q,k=Math.min(i-1,Q),u=a=>d&&o===a?(0,g.jsx)(n,{color:s.assuranceAccent,children:"\u276F"}):" ",m=t?`? ${e}`:e,A=Math.max(4,k-3),S=b.map((a,w)=>(0,g.jsx)(n,{color:s.dim,children:` ${a.length>A?`${a.slice(0,A-1)}\u2026`:a}`},`sub-${w}`)),R=0,B=r.map((a,w)=>a.free?c?(0,g.jsxs)(x,{flexDirection:"column",children:[(0,g.jsxs)(x,{children:[(0,g.jsxs)(n,{children:[(0,g.jsx)(n,{color:s.assuranceAccent,children:"\u276F"})," ",(0,g.jsx)(n,{color:s.dim,children:"\u270E "})]}),(0,g.jsx)(M,{value:c.value,onChange:c.onChange,onSubmit:c.onSubmit,onCancel:c.onCancel,placeholder:a.label})]}),h?(0,g.jsx)(n,{color:s.muted,children:` ${h}`}):null]},a.key):(0,g.jsxs)(n,{children:[u(w)," ",(0,g.jsx)(n,{color:s.dim,children:`\u270E ${a.label}`})]},a.key):(R+=1,(0,g.jsxs)(n,{bold:d&&o===w,children:[u(w),` ${R}. ${a.label}`,a.detail?(0,g.jsx)(n,{color:s.dim,bold:!1,children:` \u2014 ${a.detail}`}):null]},a.key)));return v?(0,g.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,g.jsx)(n,{bold:!0,color:s.assuranceAccent,children:m}),S,B]}):(0,g.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,g.jsx)(n,{bold:!0,color:s.assuranceAccent,children:m}),S,(0,g.jsx)(n,{children:" "}),B]})}var H=y(I(),1);var $=y(O(),1),N=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function le(e){let t=e.replace(/…$/,"");return t&&t.charAt(0).toLowerCase()+t.slice(1)}function F(e,t){if(e.length<=t)return e;if(t<=1)return"\u2026";let r=Math.ceil((t-1)/2),o=Math.floor((t-1)/2);return`${e.slice(0,r)}\u2026${o>0?e.slice(-o):""}`}function ce({status:e,meta:t,tallies:r,keys:o,child:d,cols:c}){let{stdout:h}=E(),b=c??h?.columns??80,p=e.kind==="working"||e.kind==="child-working",[i,v]=(0,H.useState)(0);L(()=>v(f=>f+1),p?120:null);let k=N[i%N.length],u,m;switch(e.kind){case"working":u=`${k} ${e.step}${e.elapsedS!==void 0?` \xB7 ${e.elapsedS}s`:""}`,m=s.assuranceAccent;break;case"waiting":u=`\u25CF waiting on you${e.pending?` \u2014 ${e.pending} question${e.pending===1?"":"s"}`:""}`,m=s.amber;break;case"idle":u="\u25CF idle",m=s.assuranceAccent;break;case"card":u=`\u25CF card ${e.n} of ${e.m}`,m=s.amber;break;case"child-working":u=`${k} child: ${e.step}`,m=s.assuranceAccent;break;case"child-waiting":u="\u25CF child waiting on you",m=s.amber;break}let A=d?`${t.verb} \u25B8 ${d.verb}`:t.verb,S=d?.sid?t.sid?`${F(t.sid,14)} \u25B8 ${d.sid}`:d.sid:t.sid,R=t.env==="prod"?"":t.env,B=[A,S,R].filter(Boolean),a=" \xB7 ",w=u.length+a.length+B.join(a).length,C=t.subject;if(C){let f=b-w-a.length;C=f>=8?F(C,f):void 0}let _=[A,...C?[C]:[],S,R].filter(Boolean).join(a);return(0,$.jsxs)(x,{flexDirection:"column",children:[(0,$.jsx)(n,{color:s.muted,children:"\u2500".repeat(Math.max(1,b))}),(0,$.jsxs)(n,{children:[(0,$.jsx)(n,{color:m,children:u}),(0,$.jsx)(n,{color:s.dim,children:`${a}${_}`})]}),(0,$.jsx)(n,{color:s.dim,children:r.items.length>0?r.items.join(a):" "}),(0,$.jsx)(n,{color:s.muted,children:o.join(a)})]})}var P=y(I(),1);function ue({onToggleThinking:e,onCtrlC:t,explorer:r,panel:o}){let c=(0,P.useRef)(null),h=(0,P.useRef)(""),b=()=>{c.current&&clearTimeout(c.current),c.current=null,h.current=""};return(0,P.useEffect)(()=>b,[]),D((p,i)=>{if(i.ctrl&&p==="t"){e();return}if(i.ctrl&&p==="c"){t();return}if(!i.ctrl&&p.includes("")){t();return}if(!i.ctrl&&p.includes("")){e();return}if(r&&r.isOpen()){let v=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{b(),r.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return){b(),i.return?r.onEnter():r.onMove(i.upArrow?-1:1);return}if(h.current+=p,h.current==="["){v();return}let k=h.current;b();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="",v();return}return}if(o&&o.isFocused()){let v=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{b(),o.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return||i.leftArrow||i.rightArrow){b(),i.return?o.onSelect():i.leftArrow?o.onLeft?.():i.rightArrow?o.onRight?.():o.onMove(i.upArrow?-1:1);return}if(h.current+=p,h.current==="["){v();return}let k=h.current;b();let u=/^\[([ABCD])/.exec(k);if(u){u[1]==="A"||u[1]==="B"?o.onMove(u[1]==="A"?-1:1):u[1]==="C"?o.onRight?.():o.onLeft?.();return}o.onBack();return}if(i.upArrow){o.onMove(-1);return}if(i.downArrow){o.onMove(1);return}if(i.leftArrow){o.onLeft?.();return}if(i.rightArrow){o.onRight?.();return}if(i.return){o.onSelect();return}if(i.escape){h.current="",v();return}if(/^[1-9]$/.test(p)){o.onDigit(Number(p));return}if(i.tab){o.onTab?.();return}if(p===" "&&o.isMulti()){o.onSpace();return}if(p&&!i.ctrl&&!i.meta){o.onType(p);return}return}}),null}var l=y(O(),1);function X(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 V(e){let t=X(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:V(e).length}var Y={ADD:{color:s.green??"green"},MODIFY:{color:"yellow"},ARCHIVE:{color:s.red},REVIEW:{color:"cyan"},PAIR:{color:"magenta"}},U=60;function be({card:e,position:t,sel:r=0,focused:o=!1,freeText:d=null,editorIntent:c="steer"}){let{stdout:h}=E(),b=h?.columns??80,p=b<U,i=V(e),v=W(e),k=Y[e.kind],u=f=>o&&r===f?(0,l.jsx)(n,{color:s.assuranceAccent,children:"\u276F"}):" ",m=e.impact,A=m&&"stale_refs"in m&&m.stale_refs.length>0?`${e.kind==="ARCHIVE"?"retiring leaves":"approving marks"} ${m.stale_refs.length} item(s) stale`+((m.direct_refs?.length??0)>0?` \u2014 ${m.direct_refs.length} directly touched: ${m.direct_refs.join(", ")}`:""):m&&"design_children"in m?`${e.kind==="REVIEW"?"archiving drops":"merging folds"} ${m.design_children} design child(ren)`:null,S=e.provenance&&e.provenance!==e.why?e.provenance:e.origin??null,R=[{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}]:[]],B=Math.max(...R.map(f=>f.label.length)),a="? reconcile",w=`item ${t.n} of ${t.of}`,C=(0,l.jsxs)(x,{flexDirection:"column",children:[(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsxs)(n,{bold:!0,children:[(0,l.jsx)(n,{color:k.color,children:`[${e.kind}]`}),` ${j(e.title)}`]})}),R.map((f,T)=>(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{color:s.dim,children:`${f.label.padEnd(B)} `}),(0,l.jsx)(n,{color:f.dimmer?s.dim:void 0,children:f.text})]})},`f-${T}`)),e.diffSummary?(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsx)(n,{color:s.dim,children:e.diffSummary})}):(e.diff??[]).map((f,T)=>(0,l.jsx)(x,{paddingLeft:4,children:(0,l.jsx)(n,{color:f.op==="-"?"red":"green",children:`${f.op==="-"?"\u2212":"+"} ${f.field==="criteria"?"criterion":f.field}: ${f.text}`})},`d-${T}`)),(e.citeLines??[]).map((f,T)=>(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsx)(n,{color:s.dim,children:f})},`c-${T}`)),(0,l.jsx)(n,{children:" "}),i.map((f,T)=>(0,l.jsxs)(n,{children:[u(T),` ${T+1}. ${f.label}`,(0,l.jsx)(n,{color:s.dim,children:` \u2014 ${f.detail}`})]},`o-${T}`)),v!==null||d&&c==="because"?d?(0,l.jsxs)(x,{flexDirection:"column",children:[(0,l.jsxs)(x,{children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{color:s.assuranceAccent,children:"\u276F"})," ",(0,l.jsx)(n,{color:s.dim,children:"\u270E "})]}),(0,l.jsx)(M,{value:d.value,onChange:d.onChange,onSubmit:d.onSubmit,onCancel:d.onCancel,placeholder:c==="because"?"why archive it?":"say what to adjust"})]}),(0,l.jsx)(n,{color:s.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"})]}):v!==null?(0,l.jsxs)(n,{children:[u(v)," ",(0,l.jsx)(n,{color:s.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(p)return(0,l.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,l.jsx)(n,{bold:!0,color:s.assuranceAccent,children:a}),(0,l.jsx)(n,{color:s.dim,children:w}),C]});let _=Math.max(2,Math.min(b-1,100)-a.length-w.length);return(0,l.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{bold:!0,color:s.assuranceAccent,children:a})," ".repeat(_),(0,l.jsx)(n,{color:s.dim,children:w})]}),(0,l.jsx)(n,{children:" "}),C]})}var z={"acceptance criteria":1,scenarios:2,"acceptance criteria + exercises":3,"tests + gaps":4};function we(e,t){let r=[],o=K(e.turns).entries.length;if(t==="design"){let c;for(let b=e.ledger.length-1;b>=0;b--){let p=e.ledger[b];if(p.kind==="banner"&&p.text.startsWith("designing: ")){c=p.text.slice(11);break}}let h=c?z[c]:void 0;h&&r.push(`phase ${h}/4`),o>0&&r.push(`${o} item${o===1?"":"s"} this session`)}else o>0&&r.push(`${o} saved as draft${o===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 ke(e,t){let r=[],o=e.applied+e.committed+e.retired;r.push(`${o} 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 Ae(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(o=>o.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 Se(e,t){let r=["\u2191\u2193 select","\u23CE confirm"];return e.some(o=>o.free)&&r.push("\u270E type your own"),t.escBack&&r.push("esc back"),{keys:r}}function Re(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{ee as a,te as b,le as c,ce as d,ue as e,X as f,V as g,W as h,be as i,we as j,ke as k,Ae as l,Se as m,Re as n};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{y as o}from"./chunk-PH22FRN5.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{x as o}from"./chunk-CCUGKBIH.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};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as S}from"./chunk-NHOHQBIF.js";import{x as o}from"./chunk-CCUGKBIH.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,r=e.decisions.filter(l=>l.kind==="author").length,p=e.outcomes.filter(l=>l.status==="passed").length,d=e.outcomes.filter(l=>l.status==="failed").length,f=e.outcomes.filter(l=>l.status==="skipped").length,a=o.green,n;e.cancelled||e.overallStatus==="interrupted"?(a=o.orange,n="CANCELLED"):e.overallStatus==="failed"?(a=o.red,n="FAILED"):n="PASSED";let s=`${n} \xB7 ${e.durationS}s \xB7 ${e.outcomes.length} steps (${p} passed, ${d} failed, ${f} skipped)`,T=`${t} replay \xB7 ${r} author`,C=e.retryTriggered,_="yes \u2014 healed after a replay miss",u,h=o.dim;if(e.cancelled)u="\u2013 not committed (cancellation)";else if(e.overallStatus==="failed")u="\u2013 not committed (run failed)",h=o.red;else if(!e.shouldCommit)e.isFirstRun?u="\u2013 not committed (first run skipped commit)":e.lockHeld?u="\u2013 not committed":u="\u2013 not committed (readonly fallback / no lock)";else{let l=e.uploadResult?.testcaseId;u=l?`\u2713 pushed (testcase=${l})`:"\u2713 pushed",h=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:s},breakdown:T,showRetries:C,retriesText:_,commitText:u,commitColor:h,artifactsText:v,uploadText:m,uploadColor:g}}function O(e){let t=e.decisions.filter(s=>s.kind==="replay").length,r=e.decisions.filter(s=>s.kind==="author").length,p=e.outcomes.filter(s=>s.status==="passed").length,d=e.outcomes.filter(s=>s.status==="failed").length,f=e.outcomes.filter(s=>s.status==="skipped").length,a,n=!1;return e.cancelled?a="cancellation":e.overallStatus==="failed"?a="run_failed":e.shouldCommit&&e.uploadResult?.testcaseId?(a="ok",n=!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:p,failed:d,skipped:f,replay_decisions:t,author_decisions:r},adaptive_heal:{triggered:e.retryTriggered},commit:{committed:n,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),r=[{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&&r.push({label:"adaptive heal",value:(0,i.jsx)(c,{color:o.orange,children:t.retriesText})}),r.push({label:"commit",value:(0,i.jsx)(c,{color:t.commitColor,children:t.commitText})}),r.push({label:"artifacts",value:(0,i.jsx)(c,{color:o.dim,children:t.artifactsText})}),r.push({label:"upload",value:(0,i.jsx)(c,{color:t.uploadColor,children:t.uploadText})}),(0,i.jsx)(S,{title:"Run summary",titleColor:"#ff9500",rows:r})}function I({data:e}){let{exit:t}=x();return(0,k.useEffect)(()=>{let r=setTimeout(()=>t(),50);return()=>clearTimeout(r)},[t]),(0,i.jsx)(y,{flexDirection:"column",children:(0,i.jsx)(D,{data:e})})}export{A as a,O as b,D as c,I as d};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Ve}from"./chunk-BDUCWZYO.js";import{a as Ye}from"./chunk-VYYTENPY.js";import{a as We}from"./chunk-YCCUBQY4.js";import{a as qe}from"./chunk-VE3SUJMA.js";import{a as be}from"./chunk-7VTYRTEJ.js";import{a as Ge}from"./chunk-A3PGLDQY.js";import{a as He}from"./chunk-JT7I6OST.js";import{c as Le,y as u}from"./chunk-PH22FRN5.js";import{a as re}from"./chunk-HCBYKLMW.js";import{a as h,b as f,h as Fe,i as Se,k as Ne}from"./chunk-C44QQJR4.js";import{a as we}from"./chunk-6YGTRKDT.js";import{e as $}from"./chunk-UR6MHSHU.js";var je=$(we(),1);import{readFileSync as ct,writeFileSync as ut,mkdirSync as ft}from"fs";import{dirname as dt,join as ze}from"path";var mt=ze(Le,"command-history.json"),Dt=ze(Le,"generate-history.json"),ht=200,De=class{entries;filePath;max;constructor(t=mt,e=ht){this.filePath=t,this.max=e,this.entries=this._load()}push(t){this.entries.length>0&&this.entries[this.entries.length-1]===t||(this.entries.push(t),this.entries.length>this.max&&(this.entries=this.entries.slice(this.entries.length-this.max)),this._save())}getAll(){return[...this.entries]}search(t){let e=t.toLowerCase(),o=[];for(let s=this.entries.length-1;s>=0;s--)this.entries[s].toLowerCase().includes(e)&&o.push(this.entries[s]);return o}_load(){if(this.filePath===null)return[];try{let t=ct(this.filePath,"utf-8"),e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}}_save(){if(this.filePath!==null)try{ft(dt(this.filePath),{recursive:!0}),ut(this.filePath,JSON.stringify(this.entries)+`
2
+ import{a as Ve}from"./chunk-6DTWVLSJ.js";import{a as Ye}from"./chunk-JRQKUQWL.js";import{a as We}from"./chunk-YCCUBQY4.js";import{a as qe}from"./chunk-VE3SUJMA.js";import{a as be}from"./chunk-ZIRMSWKS.js";import{a as Ge}from"./chunk-PB3GADUD.js";import{a as He}from"./chunk-WLOGO44E.js";import{b as Le,x as u}from"./chunk-CCUGKBIH.js";import{a as re}from"./chunk-HCBYKLMW.js";import{a as h,b as f,h as Fe,i as Se,k as Ne}from"./chunk-C44QQJR4.js";import{a as we}from"./chunk-6YGTRKDT.js";import{e as $}from"./chunk-UR6MHSHU.js";var je=$(we(),1);import{readFileSync as ct,writeFileSync as ut,mkdirSync as ft}from"fs";import{dirname as dt,join as ze}from"path";var mt=ze(Le,"command-history.json"),Dt=ze(Le,"generate-history.json"),ht=200,De=class{entries;filePath;max;constructor(t=mt,e=ht){this.filePath=t,this.max=e,this.entries=this._load()}push(t){this.entries.length>0&&this.entries[this.entries.length-1]===t||(this.entries.push(t),this.entries.length>this.max&&(this.entries=this.entries.slice(this.entries.length-this.max)),this._save())}getAll(){return[...this.entries]}search(t){let e=t.toLowerCase(),o=[];for(let s=this.entries.length-1;s>=0;s--)this.entries[s].toLowerCase().includes(e)&&o.push(this.entries[s]);return o}_load(){if(this.filePath===null)return[];try{let t=ct(this.filePath,"utf-8"),e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}}_save(){if(this.filePath!==null)try{ft(dt(this.filePath),{recursive:!0}),ut(this.filePath,JSON.stringify(this.entries)+`
3
3
  `)}catch{}}};function kt(n){let t=(0,je.useRef)(null);return t.current||(t.current=new De(n)),t.current}var D=$(we(),1);var ke=$(we(),1);var Z=$(re(),1);function Xe({history:n,onSelect:t,onClose:e}){let[o,s]=(0,ke.useState)(""),[l,m]=(0,ke.useState)(0),v=o?n.search(o).slice(0,8):[];return Se((b,d)=>{if(d.escape){e();return}if(d.return){v.length>0&&v[l]?t(v[l]):e();return}if(d.upArrow){m(S=>Math.max(0,S-1));return}if(d.downArrow){m(S=>Math.min(v.length-1,S+1));return}if(d.backspace||d.delete){s(S=>S.slice(0,-1)),m(0);return}b&&!d.ctrl&&!d.meta&&(s(S=>S+b),m(0))}),(0,Z.jsxs)(h,{flexDirection:"column",marginLeft:2,borderStyle:"single",paddingX:1,children:[(0,Z.jsx)(f,{color:u.muted,bold:!0,children:"reverse search"}),(0,Z.jsxs)(h,{gap:1,children:[(0,Z.jsx)(f,{color:u.dim,children:"search:"}),(0,Z.jsx)(f,{children:o}),(0,Z.jsx)(f,{color:u.orange,children:"\u2588"})]}),v.length>0&&(0,Z.jsx)(f,{children:" "}),v.map((b,d)=>(0,Z.jsx)(h,{marginLeft:2,children:(0,Z.jsxs)(f,{color:d===l?u.orange:u.dim,bold:d===l,children:[d===l?"\u25B8 ":" ",b]})},`${d}-${b}`))]})}var X=$(re(),1);function Je({commands:n,selectedIndex:t}){return n.length===0?null:(0,X.jsx)(h,{flexDirection:"column",marginBottom:0,children:n.map((e,o)=>{let s=o===t;return e.disabled?(0,X.jsxs)(h,{children:[(0,X.jsx)(f,{color:u.dim,children:s?"\u276F ":" "}),(0,X.jsxs)(f,{color:u.dim,children:["/",e.name]}),(0,X.jsxs)(f,{color:u.dim,children:[" ",e.disabledReason??e.description]})]},e.name):(0,X.jsxs)(h,{children:[(0,X.jsx)(f,{color:s?u.orange:u.dim,children:s?"\u276F ":" "}),(0,X.jsxs)(f,{color:s?u.orange:void 0,bold:s,children:["/",e.name]}),e.args&&(0,X.jsxs)(f,{color:u.dim,children:[" ",e.args]}),(0,X.jsxs)(f,{color:u.dim,children:[" ",e.description]})]},e.name)})})}var Ze=$(we(),1);var q=$(re(),1),et={scenario:"Scenarios",case:"Test Cases",file:"Files",artifact:"Artifact candidates",installed:"Installed on device"};function Qe(n){let t={scenario:0,case:0,file:0,artifact:0,installed:0};for(let e of n)t[e.kind]++;return["scenario","case","file","artifact","installed"].filter(e=>t[e]>0).map(e=>`${t[e]} ${et[e]}`).join(" \xB7 ")}var Pe=7;function tt({items:n,selectedIndex:t,accent:e=u.orange}){let o=n.length;if(o===0)return null;let s=Math.floor(Pe/2),l=o<=Pe?0:Math.max(0,Math.min(t-s,o-Pe)),m=Math.min(o,l+Pe),v=l,b=o-m;return(0,q.jsxs)(h,{flexDirection:"column",marginBottom:0,children:[v>0&&(0,q.jsx)(h,{children:(0,q.jsx)(f,{color:u.dim,children:` \u22EF ${v} above \u2014 ${Qe(n.slice(0,l))}`})}),n.slice(l,m).map((d,S)=>{let U=l+S,F=d.selectable!==!1,E=U===t&&F,R=S===0||n[U-1].kind!==d.kind;return(0,q.jsxs)(Ze.default.Fragment,{children:[R&&(0,q.jsx)(h,{children:(0,q.jsx)(f,{color:u.dim,children:et[d.kind]})}),(0,q.jsxs)(h,{children:[(0,q.jsx)(f,{color:E?e:u.dim,children:E?"\u276F ":" "}),(0,q.jsxs)(f,{color:E?e:F?void 0:u.dim,bold:E,children:[d.label,d.reason?` \u2014 ${d.reason}`:""]})]})]},`${d.kind}:${d.value}:${U}`)}),b>0&&(0,q.jsx)(h,{children:(0,q.jsx)(f,{color:u.dim,children:` \u22EF ${b} more \u2014 ${Qe(n.slice(m))}`})})]})}var Be=$(we(),1);var gt=27,pt=127,xt=11;function bt(n){return n>=64&&n<=126}function Tt(n,t){n===xt&&t({killToEnd:!0,ctrl:!0,raw:String.fromCharCode(n)})}function vt(n,t){n===pt&&t({backspace:!0,meta:!0,raw:"\x1B\x7F"})}function wt(n,t){let e=n.map(s=>String.fromCharCode(s)).join(""),o=/^\[1;([0-9]+)([A-D])$/.exec(e);if(o){let s=parseInt(o[1],10),l=o[2],m={raw:"\x1B"+e};if(s===2)m.shift=!0;else if(s===3)m.meta=!0;else if(s===5)m.ctrl=!0;else return;l==="A"?m.arrowUp=!0:l==="B"?m.arrowDown=!0:l==="C"?m.arrowRight=!0:l==="D"&&(m.arrowLeft=!0),t(m);return}if(e==="[H"||e==="[1~"||e==="[7~"){t({home:!0,raw:"\x1B"+e});return}if(e==="[F"||e==="[4~"||e==="[8~"){t({end:!0,raw:"\x1B"+e});return}if(e==="[3;5~"){t({delete:!0,ctrl:!0,raw:"\x1B"+e});return}if(e==="[3;3~"){t({delete:!0,meta:!0,raw:"\x1B"+e});return}}function St(n,t){n===72?t({home:!0,raw:"\x1BO"+String.fromCharCode(n)}):n===70&&t({end:!0,raw:"\x1BO"+String.fromCharCode(n)})}function Et(){let n="IDLE",t=[];function e(){n="IDLE",t=[]}return{feed(o,s){for(let l of o)n==="IDLE"?l===gt?(n="ESC",t=[]):Tt(l,s):n==="ESC"?l===91?(n="CSI",t=[]):l===79?(n="SS3",t=[]):(vt(l,s),e()):n==="CSI"?(t.push(l),bt(l)&&(wt([91,...t],s),e())):n==="SS3"&&(St(l,s),e())},flushIdle(o){n==="ESC"&&t.length===0&&o({raw:"\x1B"}),e()}}}function nt(n,t={}){let e=(0,Be.useRef)(n);e.current=n;let{stdin:o}=Fe();(0,Be.useEffect)(()=>{if(t.isActive===!1||!o)return;let s=Et(),l=null,m=v=>{l&&(clearTimeout(l),l=null);let b=Buffer.isBuffer(v)?v:Buffer.from(v,"binary");s.feed(b,d=>e.current(d)),l=setTimeout(()=>{s.flushIdle(d=>e.current(d)),l=null},50)};return o.on("data",m),()=>{o.removeListener("data",m),l&&clearTimeout(l)}},[t.isActive,o])}var w=$(re(),1);function yt(n,t){let e=t-1;for(;e>=0&&n[e]!=="@"&&n[e]!==" "&&n[e]!==`
4
4
  `;)e--;return e<0||n[e]!=="@"||e>0&&n[e-1]!==" "&&n[e-1]!==`
5
5
  `?null:{at:e,query:n.slice(e+1,t).join("")}}function rt(n,t,e){for(let o=t+e;o>=0&&o<n.length;o+=e)if(n[o]?.selectable!==!1)return o;return t}function At(n){let t=n.findIndex(e=>e.selectable!==!1);return t===-1?0:t}var Oe=10;function Rt(n){return n.replace(/\x1b?\[200~/g,"").replace(/\x1b?\[201~/g,"").replace(/\r\n/g,`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as t}from"./chunk-PH22FRN5.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-CCUGKBIH.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,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as B,c as S,d as T}from"./chunk-GSYJUHRK.js";import{c as g}from"./chunk-RFHMDQXZ.js";import{a as E}from"./chunk-PSWB3BWQ.js";import{y as n}from"./chunk-PH22FRN5.js";import{a as h}from"./chunk-HCBYKLMW.js";import{a as i,b as c,c as w,i as x}from"./chunk-C44QQJR4.js";import{a as L}from"./chunk-6YGTRKDT.js";import{e as u}from"./chunk-UR6MHSHU.js";var l=u(L(),1);var r=u(h(),1);function y(e){return new Map(e.map((o,s)=>[`${s}-${o.label}`,o.packPath]))}async function H(e){let o=e.deps?.viewerBase??S(e.env),s=e.deps?.startServer??B,a=e.deps?.openUrl??(m=>g(m).then(()=>{})),t=y(e.rows),d;try{d=await s({packs:t,allowedOrigins:[new URL(o).origin]});let m=d,D=async p=>{let v=[...t.keys()][p];await a(T(m.urlFor(v),o))};if(e.deps?.hold){await e.deps.hold();return}await new Promise(p=>{let v=w(l.default.createElement(P,{rows:e.rows,onOpen:D,onDone:()=>{v.unmount(),p()}}),{stdout:process.stderr,exitOnCtrlC:!1})})}finally{await d?.close()}}function I(e){return e==="passed"?n.green:e==="failed"||e==="broken"||e==="cancelled"?n.red:n.dim}var b=40,R=9,k=20;function f(e,o){return e.length>o?e.slice(0,o-1)+"\u2026":e.padEnd(o)}function O({row:e,selected:o}){let s=e.testId??e.commitId??"";return(0,r.jsxs)(i,{children:[(0,r.jsx)(i,{width:2,flexShrink:0,children:(0,r.jsx)(c,{color:n.orange,children:o?"\u25B8":" "})}),(0,r.jsx)(i,{width:2,flexShrink:0,children:(0,r.jsx)(c,{color:e.kind==="execution"?n.orange:n.muted,children:e.kind==="execution"?"\u25CF":"\u25CB"})}),(0,r.jsx)(i,{width:b,flexShrink:0,children:(0,r.jsx)(c,{color:o?n.orange:void 0,bold:o,wrap:"truncate-end",children:f(e.label,b)})}),(0,r.jsx)(i,{width:R,flexShrink:0,children:(0,r.jsx)(c,{color:I(e.status),bold:o,wrap:"truncate-end",children:f(e.status,R)})}),(0,r.jsx)(i,{width:k,flexShrink:0,children:(0,r.jsx)(c,{color:n.dim,wrap:"truncate-end",children:f(s,k)})})]})}function P(e){let[o,s]=(0,l.useState)(0);return x((a,t)=>{t.upArrow?s(d=>Math.max(0,d-1)):t.downArrow?s(d=>Math.min(e.rows.length-1,d+1)):t.return||a==="o"?e.onOpen(o):(a==="q"||t.escape)&&e.onDone()}),(0,r.jsx)(E,{title:"Evidence",borderColor:n.muted,children:(0,r.jsxs)(i,{flexDirection:"column",children:[e.rows.map((a,t)=>(0,r.jsx)(O,{row:a,selected:t===o},t)),(0,r.jsx)(i,{marginTop:1,children:(0,r.jsx)(c,{color:n.dim,children:"\u2191/\u2193 move \xB7 enter/o open \xB7 q quit"})})]})})}export{y as a,H as b};
2
+ import{b as B,c as S,d as T}from"./chunk-TJZMYU2W.js";import{c as g}from"./chunk-RFHMDQXZ.js";import{a as E}from"./chunk-PQUMOFT5.js";import{x as n}from"./chunk-CCUGKBIH.js";import{a as h}from"./chunk-HCBYKLMW.js";import{a as i,b as c,c as w,i as x}from"./chunk-C44QQJR4.js";import{a as L}from"./chunk-6YGTRKDT.js";import{e as u}from"./chunk-UR6MHSHU.js";var l=u(L(),1);var r=u(h(),1);function y(e){return new Map(e.map((o,s)=>[`${s}-${o.label}`,o.packPath]))}async function H(e){let o=e.deps?.viewerBase??S(e.env),s=e.deps?.startServer??B,a=e.deps?.openUrl??(m=>g(m).then(()=>{})),t=y(e.rows),d;try{d=await s({packs:t,allowedOrigins:[new URL(o).origin]});let m=d,D=async p=>{let v=[...t.keys()][p];await a(T(m.urlFor(v),o))};if(e.deps?.hold){await e.deps.hold();return}await new Promise(p=>{let v=w(l.default.createElement(P,{rows:e.rows,onOpen:D,onDone:()=>{v.unmount(),p()}}),{stdout:process.stderr,exitOnCtrlC:!1})})}finally{await d?.close()}}function I(e){return e==="passed"?n.green:e==="failed"||e==="broken"||e==="cancelled"?n.red:n.dim}var b=40,R=9,k=20;function f(e,o){return e.length>o?e.slice(0,o-1)+"\u2026":e.padEnd(o)}function O({row:e,selected:o}){let s=e.testId??e.commitId??"";return(0,r.jsxs)(i,{children:[(0,r.jsx)(i,{width:2,flexShrink:0,children:(0,r.jsx)(c,{color:n.orange,children:o?"\u25B8":" "})}),(0,r.jsx)(i,{width:2,flexShrink:0,children:(0,r.jsx)(c,{color:e.kind==="execution"?n.orange:n.muted,children:e.kind==="execution"?"\u25CF":"\u25CB"})}),(0,r.jsx)(i,{width:b,flexShrink:0,children:(0,r.jsx)(c,{color:o?n.orange:void 0,bold:o,wrap:"truncate-end",children:f(e.label,b)})}),(0,r.jsx)(i,{width:R,flexShrink:0,children:(0,r.jsx)(c,{color:I(e.status),bold:o,wrap:"truncate-end",children:f(e.status,R)})}),(0,r.jsx)(i,{width:k,flexShrink:0,children:(0,r.jsx)(c,{color:n.dim,wrap:"truncate-end",children:f(s,k)})})]})}function P(e){let[o,s]=(0,l.useState)(0);return x((a,t)=>{t.upArrow?s(d=>Math.max(0,d-1)):t.downArrow?s(d=>Math.min(e.rows.length-1,d+1)):t.return||a==="o"?e.onOpen(o):(a==="q"||t.escape)&&e.onDone()}),(0,r.jsx)(E,{title:"Evidence",borderColor:n.muted,children:(0,r.jsxs)(i,{flexDirection:"column",children:[e.rows.map((a,t)=>(0,r.jsx)(O,{row:a,selected:t===o},t)),(0,r.jsx)(i,{marginTop:1,children:(0,r.jsx)(c,{color:n.dim,children:"\u2191/\u2193 move \xB7 enter/o open \xB7 q quit"})})]})})}export{y as a,H as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-HXSEA7JS.js";import{y as s}from"./chunk-PH22FRN5.js";import{a as w}from"./chunk-HCBYKLMW.js";import{a as x,b as t,c as h,i as P,j as S}from"./chunk-C44QQJR4.js";import{a as C}from"./chunk-6YGTRKDT.js";import{e as T}from"./chunk-UR6MHSHU.js";var o=T(C(),1);var e=T(w(),1);function D({defaultName:i,onSubmit:c}){let[d,p]=(0,o.useState)("confirm"),[f,a]=(0,o.useState)(""),[m,u]=(0,o.useState)(null),l=(0,o.useMemo)(()=>f.trim()||i,[f,i]);return P((n,r)=>{if(d==="confirm"){if(n==="y"||n==="Y"){a(i),p("name");return}if(n==="n"||n==="N"||r.escape||r.ctrl&&n==="c"){c(null);return}if(r.return){c(i);return}return}if(r.return){if(!B(l)){u(`name "${l}" is invalid; allowed: letters, digits, underscore, hyphen`);return}c(l);return}if(r.escape||r.ctrl&&n==="c"){c(null);return}if(r.backspace||r.delete){a(v=>v.slice(0,-1)),u(null);return}n&&!r.ctrl&&!r.meta&&(a(v=>v+n),u(null))}),d==="confirm"?(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsx)(t,{color:s.orange,children:i})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save with this name"}),(0,e.jsx)(t,{color:s.dim,children:"Y \u2014 edit name"}),(0,e.jsx)(t,{color:s.dim,children:"N/esc \u2014 discard session"})]})}):(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsxs)(x,{children:[(0,e.jsx)(t,{color:s.orange,children:f}),(0,e.jsx)(t,{inverse:!0,children:" "})]})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[m&&(0,e.jsx)(t,{color:s.red,children:m}),(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save \xB7 esc \u2014 discard"})]})})}function V(){return new Date().toISOString().slice(0,19).replace(/:/g,"-")}async function Y(i){return new Promise(c=>{function d(){let{exit:a}=S(),[m,u]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{if(m){let l=setTimeout(()=>a(),50);return()=>clearTimeout(l)}},[m,a]),(0,e.jsx)(D,{defaultName:i,onSubmit:l=>{c(l),u(!0)}})}let{waitUntilExit:p,unmount:f}=h((0,e.jsx)(d,{}),{stdout:process.stderr,exitOnCtrlC:!1});p().then(()=>{try{f()}catch{}})})}export{D as a,V as b,Y as c};
2
+ import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-NHOHQBIF.js";import{x as s}from"./chunk-CCUGKBIH.js";import{a as w}from"./chunk-HCBYKLMW.js";import{a as x,b as t,c as h,i as P,j as S}from"./chunk-C44QQJR4.js";import{a as C}from"./chunk-6YGTRKDT.js";import{e as T}from"./chunk-UR6MHSHU.js";var o=T(C(),1);var e=T(w(),1);function D({defaultName:i,onSubmit:c}){let[d,p]=(0,o.useState)("confirm"),[f,a]=(0,o.useState)(""),[m,u]=(0,o.useState)(null),l=(0,o.useMemo)(()=>f.trim()||i,[f,i]);return P((n,r)=>{if(d==="confirm"){if(n==="y"||n==="Y"){a(i),p("name");return}if(n==="n"||n==="N"||r.escape||r.ctrl&&n==="c"){c(null);return}if(r.return){c(i);return}return}if(r.return){if(!B(l)){u(`name "${l}" is invalid; allowed: letters, digits, underscore, hyphen`);return}c(l);return}if(r.escape||r.ctrl&&n==="c"){c(null);return}if(r.backspace||r.delete){a(v=>v.slice(0,-1)),u(null);return}n&&!r.ctrl&&!r.meta&&(a(v=>v+n),u(null))}),d==="confirm"?(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsx)(t,{color:s.orange,children:i})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save with this name"}),(0,e.jsx)(t,{color:s.dim,children:"Y \u2014 edit name"}),(0,e.jsx)(t,{color:s.dim,children:"N/esc \u2014 discard session"})]})}):(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsxs)(x,{children:[(0,e.jsx)(t,{color:s.orange,children:f}),(0,e.jsx)(t,{inverse:!0,children:" "})]})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[m&&(0,e.jsx)(t,{color:s.red,children:m}),(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save \xB7 esc \u2014 discard"})]})})}function V(){return new Date().toISOString().slice(0,19).replace(/:/g,"-")}async function Y(i){return new Promise(c=>{function d(){let{exit:a}=S(),[m,u]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{if(m){let l=setTimeout(()=>a(),50);return()=>clearTimeout(l)}},[m,a]),(0,e.jsx)(D,{defaultName:i,onSubmit:l=>{c(l),u(!0)}})}let{waitUntilExit:p,unmount:f}=h((0,e.jsx)(d,{}),{stdout:process.stderr,exitOnCtrlC:!1});p().then(()=>{try{f()}catch{}})})}export{D as a,V as b,Y as c};