@visulima/vis 1.0.0-alpha.27 → 1.0.0-alpha.29

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 (132) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/LICENSE.md +3217 -99
  3. package/dist/bin.js +1 -1
  4. package/dist/binx.js +1 -1
  5. package/dist/packem_chunks/bin.js +468 -364
  6. package/dist/packem_chunks/bloom-status.js +1 -1
  7. package/dist/packem_chunks/bloom-sync.js +1 -1
  8. package/dist/packem_chunks/config.js +15 -15
  9. package/dist/packem_chunks/devtools.js +82 -0
  10. package/dist/packem_chunks/doctor-probe.js +1 -1
  11. package/dist/packem_chunks/fix.js +1 -1
  12. package/dist/packem_chunks/handler.js +1 -1
  13. package/dist/packem_chunks/handler10.js +1 -2
  14. package/dist/packem_chunks/handler11.js +5 -1
  15. package/dist/packem_chunks/handler12.js +1 -5
  16. package/dist/packem_chunks/handler13.js +27 -1
  17. package/dist/packem_chunks/handler14.js +5 -27
  18. package/dist/packem_chunks/handler15.js +1 -5
  19. package/dist/packem_chunks/handler16.js +1 -1
  20. package/dist/packem_chunks/handler17.js +1 -1
  21. package/dist/packem_chunks/handler18.js +1 -1
  22. package/dist/packem_chunks/handler19.js +1 -1
  23. package/dist/packem_chunks/handler2.js +1 -1
  24. package/dist/packem_chunks/handler20.js +5 -1
  25. package/dist/packem_chunks/handler21.js +2 -5
  26. package/dist/packem_chunks/handler22.js +2 -2
  27. package/dist/packem_chunks/handler23.js +1 -2
  28. package/dist/packem_chunks/handler24.js +1 -1
  29. package/dist/packem_chunks/handler25.js +5 -1
  30. package/dist/packem_chunks/handler26.js +1 -5
  31. package/dist/packem_chunks/handler27.js +3 -1
  32. package/dist/packem_chunks/handler28.js +1 -3
  33. package/dist/packem_chunks/handler29.js +7 -1
  34. package/dist/packem_chunks/handler3.js +4 -4
  35. package/dist/packem_chunks/handler30.js +32 -6
  36. package/dist/packem_chunks/handler31.js +3 -33
  37. package/dist/packem_chunks/handler32.js +8 -3
  38. package/dist/packem_chunks/handler33.js +1 -1
  39. package/dist/packem_chunks/handler34.js +4 -4
  40. package/dist/packem_chunks/handler35.js +11 -3
  41. package/dist/packem_chunks/handler36.js +3 -22
  42. package/dist/packem_chunks/handler37.js +21 -60
  43. package/dist/packem_chunks/handler38.js +61 -3
  44. package/dist/packem_chunks/handler39.js +3 -6
  45. package/dist/packem_chunks/handler4.js +5 -5
  46. package/dist/packem_chunks/handler40.js +6 -24
  47. package/dist/packem_chunks/handler41.js +24 -153
  48. package/dist/packem_chunks/handler42.js +153 -10
  49. package/dist/packem_chunks/handler43.js +6 -6
  50. package/dist/packem_chunks/handler44.js +10 -708
  51. package/dist/packem_chunks/handler45.js +708 -24
  52. package/dist/packem_chunks/handler46.js +24 -322
  53. package/dist/packem_chunks/handler47.js +322 -48
  54. package/dist/packem_chunks/handler48.js +48 -3
  55. package/dist/packem_chunks/handler49.js +3 -27
  56. package/dist/packem_chunks/handler5.js +7 -7
  57. package/dist/packem_chunks/handler50.js +21 -190
  58. package/dist/packem_chunks/handler51.js +194 -33
  59. package/dist/packem_chunks/handler52.js +34 -0
  60. package/dist/packem_chunks/handler6.js +1 -1
  61. package/dist/packem_chunks/handler7.js +1 -1
  62. package/dist/packem_chunks/handler8.js +1 -1
  63. package/dist/packem_chunks/handler9.js +1 -1
  64. package/dist/packem_chunks/heal-accept.js +1 -1
  65. package/dist/packem_chunks/heal.js +1 -1
  66. package/dist/packem_chunks/help-command.js +7 -17
  67. package/dist/packem_chunks/index.js +3 -3
  68. package/dist/packem_chunks/keys-refresh.js +1 -1
  69. package/dist/packem_chunks/list.js +2 -2
  70. package/dist/packem_chunks/loader.js +1 -1
  71. package/dist/packem_chunks/loader2.js +1 -1
  72. package/dist/packem_chunks/prune.js +1 -1
  73. package/dist/packem_chunks/run.js +1 -1
  74. package/dist/packem_chunks/status.js +1 -1
  75. package/dist/packem_chunks/sync.js +1 -1
  76. package/dist/packem_chunks/sync2.js +1 -1
  77. package/dist/packem_chunks/tripwire.js +2 -2
  78. package/dist/packem_chunks/verify-lockfile.js +1 -1
  79. package/dist/packem_shared/Table-3pFgIUZ2-DABgc6rj.js +12 -0
  80. package/dist/packem_shared/_commonjsHelpers-CLblCigl.js +1 -0
  81. package/dist/packem_shared/{advisories-xIOdLbAI.js → advisories-DpgSuWDH.js} +1 -1
  82. package/dist/packem_shared/{affected-shas-Dm7eqcI8.js → affected-shas-BkXXecyi.js} +1 -1
  83. package/dist/packem_shared/ai-analysis-KP8b5lc0.js +68 -0
  84. package/dist/packem_shared/{ai-fix-BlYyz5bI.js → ai-fix-CfFWatGY.js} +5 -5
  85. package/dist/packem_shared/{applyDefaults-KxZkvlp3.js → applyDefaults-DLvOqXGX.js} +1 -1
  86. package/dist/packem_shared/{build-scripts-3E2pmscY.js → build-scripts-D-ysm_bS.js} +1 -1
  87. package/dist/packem_shared/{cyclonedx-B3ILsY74.js → cyclonedx-B04lIvwu.js} +3 -3
  88. package/dist/packem_shared/{dependency-scan-s2MD0vi-.js → dependency-scan-B9wTcLxf.js} +1 -1
  89. package/dist/packem_shared/{docker-BynKrOLe.js → docker-DxA80dRx.js} +1 -1
  90. package/dist/packem_shared/{failure-log-B0Uh-65U.js → failure-log-n3j_-w8s.js} +1 -1
  91. package/dist/packem_shared/index-BDF8gawl.js +29 -0
  92. package/dist/packem_shared/{index-B_KtN1MB.js → index-BfG9_znI.js} +1 -1
  93. package/dist/packem_shared/{lifecycle-CJRNbN3x.js → lifecycle-NHIKDiCh.js} +2 -2
  94. package/dist/packem_shared/lockfile-CoeFxWAv.js +1 -0
  95. package/dist/packem_shared/lockfile-DAuTDwow.js +1 -0
  96. package/dist/packem_shared/{manifests-Z3spBpxv.js → manifests-B7wUR3Rk.js} +1 -1
  97. package/dist/packem_shared/{min-release-age-aEn0x8Vy.js → min-release-age-YyNI7gqV.js} +1 -1
  98. package/dist/packem_shared/{native-config-sync-DdhTLlKL.js → native-config-sync-CgRIIRZV.js} +2 -2
  99. package/dist/packem_shared/{osv-bloom-BJhlc_I2.js → osv-bloom-BQSIHt5h.js} +2 -2
  100. package/dist/packem_shared/pm-runner-Ta_yz2uP.js +1 -0
  101. package/dist/packem_shared/{provenance-BuiEsWbI.js → provenance-DoEp2uOo.js} +1 -1
  102. package/dist/packem_shared/{readFileSync-CGmzMUF2-D6rUjGDn.js → readFileSync-4c_c6Qey-6SWMDNdw.js} +1 -1
  103. package/dist/packem_shared/{registry-keys-pemEkRM9.js → registry-keys-CD1xHavV.js} +1 -1
  104. package/dist/packem_shared/{resolve-explicit-RgRrUDZv.js → resolve-explicit-DpSc7RN2.js} +1 -1
  105. package/dist/packem_shared/{runtime-check-DgXsKCsv.js → runtime-check-Cbtb_Utb.js} +1 -1
  106. package/dist/packem_shared/s1ngularity-CIX7UcT5.js +1 -0
  107. package/dist/packem_shared/scan-progress-CTVVf9WW.js +2 -0
  108. package/dist/packem_shared/{selectors-BE2BCnTR.js → selectors-BU8aTRQm.js} +1 -1
  109. package/dist/packem_shared/{signatures-LYMy8OR5.js → signatures-BHM7cnqB.js} +1 -1
  110. package/dist/packem_shared/spinner-C8xs6QZv.js +1 -0
  111. package/dist/packem_shared/spinners-f91Rbo99-Bjf3NcO0.js +1 -0
  112. package/dist/packem_shared/tabs-xZkm6Y_J.js +1 -0
  113. package/dist/packem_shared/{toolchain-Jx2lkAYy.js → toolchain-juKl-WgV.js} +1 -1
  114. package/dist/packem_shared/typosquats-DRKU6d2S.js +1 -0
  115. package/dist/packem_shared/use-measured-height-Lea6TCVD.js +1 -0
  116. package/dist/packem_shared/{verify-C8EAHql6.js → verify-DA80ja1b.js} +1 -1
  117. package/dist/packem_shared/vis-update-app-BCKzlqj8.js +1 -0
  118. package/dist/packem_shared/{watch-BSVsZ_1I.js → watch-DdR-pFzX.js} +1 -1
  119. package/dist/packem_shared/{watch-loop-DLlMLg_J.js → watch-loop-C8csFvRU.js} +2 -2
  120. package/index.d.ts +201 -201
  121. package/index.js +567 -751
  122. package/package.json +13 -13
  123. package/dist/packem_shared/ai-analysis-Csn82p17.js +0 -68
  124. package/dist/packem_shared/index-efSniSRN.js +0 -29
  125. package/dist/packem_shared/index.server-B7ETiT4C.js +0 -2
  126. package/dist/packem_shared/lockfile-BG1HvBzH.js +0 -1
  127. package/dist/packem_shared/pm-runner-BwX5AL3W.js +0 -1
  128. package/dist/packem_shared/s1ngularity-Bs9fUf3q.js +0 -1
  129. package/dist/packem_shared/scan-progress-DjPT66jy.js +0 -2
  130. package/dist/packem_shared/typosquats-znskIR5j.js +0 -1
  131. package/dist/packem_shared/use-measured-height-DjYgUOKk.js +0 -1
  132. package/dist/packem_shared/vis-update-app-qhQPV97i.js +0 -1
@@ -0,0 +1,29 @@
1
+ var Un=Object.defineProperty;var j=(t,e)=>Un(t,"name",{value:e,configurable:!0});import{createRequire as Vn}from"node:module";import"./_commonjsHelpers-CLblCigl.js";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
+ const require = __cjs_mod__.createRequire(import.meta.url);
3
+ const Bn=Vn(import.meta.url),fe=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Dn=j(t=>{if(typeof fe<"u"&&fe.versions&&fe.versions.node){const[e,n]=fe.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return fe.getBuiltinModule(t)}return Bn(t)},"__cjs_getBuiltinModule"),{createRequire:Ke}=Dn("node:module"),Rn=16,tt=32,zn=64,re=128,Pe="positionals";var Fn=Object.defineProperty,Lt=j((t,e)=>Fn(t,"name",{value:e,configurable:!0}),"i$6"),Wn=Object.defineProperty,Tt=Lt((t,e)=>Wn(t,"name",{value:e,configurable:!0}),"s"),qn=Object.defineProperty,It=Tt((t,e)=>qn(t,"name",{value:e,configurable:!0}),"s"),Gn=Object.defineProperty,St=It((t,e)=>Gn(t,"name",{value:e,configurable:!0}),"i"),Hn=Object.defineProperty,Mt=St((t,e)=>Hn(t,"name",{value:e,configurable:!0}),"t");Mt(t=>t instanceof Error&&t.type==="VisulimaError","isVisulimaError");let ye=class extends Error{static{j(this,"V")}static{Lt(this,"g")}static{Tt(this,"p")}static{It(this,"V")}static{St(this,"VisulimaError")}static{Mt(this,"VisulimaError")}loc;title;hint;type="VisulimaError";constructor({cause:e,hint:n,location:i,message:r,name:o,stack:s,title:l}){super(r,{cause:e}),this.title=l,this.name=o,this.stack=s??this.stack,this.loc=i,this.hint=n}setLocation(e){this.loc=e}setName(e){this.name=e}setMessage(e){this.message=e}setHint(e){this.hint=e}};var Jn=Object.defineProperty,Ut=j((t,e)=>Jn(t,"name",{value:e,configurable:!0}),"t$3"),Kn=Object.defineProperty,Vt=Ut((t,e)=>Kn(t,"name",{value:e,configurable:!0}),"t"),Zn=Object.defineProperty,Yn=Vt((t,e)=>Zn(t,"name",{value:e,configurable:!0}),"e");let E=class extends ye{static{j(this,"m")}static{Ut(this,"u")}static{Vt(this,"c")}static{Yn(this,"CerebroError")}code;context;constructor(e,n,i){super({message:e,name:"CerebroError"}),this.code=n,this.context=i}};var Qn=Object.defineProperty,Xn=j((t,e)=>Qn(t,"name",{value:e,configurable:!0}),"a$2"),ei=Object.defineProperty,ti=Xn((t,e)=>ei(t,"name",{value:e,configurable:!0}),"l"),ni=Object.defineProperty,I=ti((t,e)=>ni(t,"name",{value:e,configurable:!0}),"r");const D=I(t=>"Deno"in t,"hasDeno"),R=I(t=>"Bun"in t,"hasBun"),Ae=I(()=>{if(D(globalThis)){const t=globalThis.Deno,e=t.execPath();let n=e;try{const{importMeta:i}=globalThis;i?.url&&(n=i.url)}catch{}return[e,n,...t.args]}return R(globalThis)?globalThis.Bun.process.argv:process.argv},"getArgv"),ii=I(()=>D(globalThis)?globalThis.Deno.cwd():R(globalThis)?globalThis.Bun.process.cwd():process.cwd(),"getCwd"),J=I(()=>{if(D(globalThis)){const t=globalThis.Deno;return new Proxy(t.env.toObject(),{get:I((e,n)=>typeof n=="string"?t.env.get(n):e[n],"get"),has:I((e,n)=>typeof n=="string"?t.env.has(n):n in e,"has"),set:I((e,n,i)=>typeof n=="string"?(i===void 0||t.env.set(n,i),!0):!1,"set")})}return R(globalThis)?globalThis.Bun.process.env:process.env},"getEnv"),Bt=I(()=>D(globalThis)?[]:R(globalThis)?globalThis.Bun.process.execArgv:process.execArgv,"getExecArgv"),Dt=I(()=>D(globalThis)?globalThis.Deno.execPath():R(globalThis)?globalThis.Bun.process.execPath:process.execPath,"getExecPath"),oi=I(()=>{if(D(globalThis)){const t=globalThis.Deno.build?.os??"unknown";return t==="windows"?"win32":t}return R(globalThis)?globalThis.Bun.platform??"unknown":process.platform},"getPlatform"),ri=I(()=>{if(D(globalThis)){const t=globalThis.Deno.build?.arch??"unknown";return t==="x86_64"?"x64":t==="aarch64"?"arm64":t}return R(globalThis)?globalThis.Bun.process.arch:process.arch},"getArch");I(()=>{if(D(globalThis)){const t=globalThis.Deno,e={};return t.version?.deno&&(e.deno=t.version.deno),t.version?.v8&&(e.v8=t.version.v8),t.version?.typescript&&(e.typescript=t.version.typescript),e}if(R(globalThis)){const t=globalThis.Bun,e={...t.process.versions};return t.version&&(e.bun=t.version),e}return process.versions},"getVersions");const q=I((t=0)=>{if(D(globalThis))throw globalThis.Deno.exit(t),new Error("Deno exit failed");if(R(globalThis))throw globalThis.Bun.process.exit(t),new Error("Bun exit failed");process.exit(t)},"exitProcess"),nt=I((t,e)=>{if(D(globalThis))return()=>{};if(R(globalThis)){try{const i=globalThis.Bun;if(i.process?.on)return i.process.on(t,e),()=>{i.process?.removeListener&&i.process.removeListener(t,e)}}catch{}return()=>{}}const n=process;return n.on(t,e),()=>{n.removeListener(t,e)}},"onProcessEvent");var ai=Object.defineProperty,Ce=j((t,e)=>ai(t,"name",{value:e,configurable:!0}),"k$3");const W=new Uint32Array(65536),si=Ce((t,e)=>{const n=t.length,i=e.length,r=1<<n-1;let o=-1,s=0,l=n,f=n;for(;f--;)W[t.charCodeAt(f)]|=1<<f;for(f=0;f<i;f++){let a=W[e.charCodeAt(f)];const c=a|s;a|=(a&o)+o^o,s|=~(a|o),o&=a,s&r&&l++,o&r&&l--,s=s<<1|1,o=o<<1|~(c|s),s&=c}for(f=n;f--;)W[t.charCodeAt(f)]=0;return l},"myers_32"),li=Ce((t,e)=>{const n=e.length,i=t.length,r=[],o=[],s=Math.ceil(n/32),l=Math.ceil(i/32);for(let u=0;u<s;u++)o[u]=-1,r[u]=0;let f=0;for(;f<l-1;f++){let u=0,v=-1;const w=f*32,b=Math.min(32,i)+w;for(let $=w;$<b;$++)W[t.charCodeAt($)]|=1<<$;for(let $=0;$<n;$++){const A=W[e.charCodeAt($)],N=o[$/32|0]>>>$&1,d=r[$/32|0]>>>$&1,g=A|u,y=((A|d)&v)+v^v|A|d;let O=u|~(y|v),P=v&y;O>>>31^N&&(o[$/32|0]^=1<<$),P>>>31^d&&(r[$/32|0]^=1<<$),O=O<<1|N,P=P<<1|d,v=P|~(g|O),u=O&g}for(let $=w;$<b;$++)W[t.charCodeAt($)]=0}let a=0,c=-1;const h=f*32,p=Math.min(32,i-h)+h;for(let u=h;u<p;u++)W[t.charCodeAt(u)]|=1<<u;let m=i;for(let u=0;u<n;u++){const v=W[e.charCodeAt(u)],w=o[u/32|0]>>>u&1,b=r[u/32|0]>>>u&1,$=v|a,A=((v|b)&c)+c^c|v|b;let N=a|~(A|c),d=c&A;m+=N>>>i-1&1,m-=d>>>i-1&1,N>>>31^w&&(o[u/32|0]^=1<<u),d>>>31^b&&(r[u/32|0]^=1<<u),N=N<<1|w,d=d<<1|b,c=d|~($|N),a=N&$}for(let u=h;u<p;u++)W[t.charCodeAt(u)]=0;return m},"myers_x"),Rt=Ce((t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return e.length===0?t.length:t.length<=32?si(t,e):li(t,e)},"distance");Ce((t,e)=>{let n=1/0,i=0;for(let r=0;r<e.length;r++){const o=Rt(t,e[r]);o<n&&(n=o,i=r)}return e[i]},"closest");var ci=Object.defineProperty,ui=j((t,e)=>ci(t,"name",{value:e,configurable:!0}),"a$1"),pi=Object.defineProperty,fi=ui((t,e)=>pi(t,"name",{value:e,configurable:!0}),"a"),di=Object.defineProperty,hi=fi((t,e)=>di(t,"name",{value:e,configurable:!0}),"p"),mi=Object.defineProperty,zt=hi((t,e)=>mi(t,"name",{value:e,configurable:!0}),"e"),gi=Object.defineProperty,vi=zt((t,e)=>gi(t,"name",{value:e,configurable:!0}),"E");const Ft=String.raw,it=Ft`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,bi=vi(()=>new RegExp(Ft`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${it}(?:\u200D${it})*`,"gu"),"default");var yi=Object.defineProperty,wi=zt((t,e)=>yi(t,"name",{value:e,configurable:!0}),"p");Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]]));const Ac=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,Ec=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,K=bi(),$i=/[-_./\s]+/g,ve=/(\u001B\[[0-9;]*[a-z])/i,ot=new RegExp("\\p{Script=Arabic}","u"),Oi=new RegExp("\\p{Script=Bengali}","u"),ie=new RegExp("\\p{Script=Cyrillic}","u"),xi=new RegExp("\\p{Script=Devanagari}","u"),Pi=new RegExp("\\p{Script=Ethiopic}","u"),Be=new RegExp("\\p{Script=Greek}","u"),rt=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),Ai=new RegExp("\\p{Script=Gujarati}","u"),Ei=new RegExp("\\p{Script=Gurmukhi}","u"),at=new RegExp("\\p{Script=Hangul}","u"),st=new RegExp("\\p{Script=Hebrew}","u"),Ni=new RegExp("\\p{Script=Hiragana}","u"),lt=new RegExp("\\p{Script=Han}","u"),Ci=new RegExp("\\p{Script=Kannada}","u"),ji=new RegExp("\\p{Script=Katakana}","u"),ki=new RegExp("\\p{Script=Khmer}","u"),_i=new RegExp("\\p{Script=Lao}","u"),M=new RegExp("\\p{Script=Latin}","u"),Li=new RegExp("\\p{Script=Malayalam}","u"),Ti=new RegExp("\\p{Script=Myanmar}","u"),Ii=new RegExp("\\p{Script=Oriya}","u"),Si=new RegExp("\\p{Script=Sinhala}","u"),Mi=new RegExp("\\p{Script=Tamil}","u"),Ui=new RegExp("\\p{Script=Telugu}","u"),Vi=new RegExp("\\p{Script=Thai}","u"),Bi=new RegExp("\\p{Script=Tibetan}","u"),ct=/[\u02BB\u02BC\u0027]/u,Di=wi(t=>t.replace(K,""),"stripEmoji");var Ri=Object.defineProperty,S=j((t,e)=>Ri(t,"name",{value:e,configurable:!0}),"L$1"),zi=Object.defineProperty,x=S((t,e)=>zi(t,"name",{value:e,configurable:!0}),"$");const Fi=Ke(import.meta.url),de=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Wt=x(t=>{if(typeof de<"u"&&de.versions&&de.versions.node){const[e,n]=de.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return de.getBuiltinModule(t)}return Fi(t)},"__cjs_getBuiltinModule"),{writeFile:Wi,stat:qi,rm:Gi,readFile:ut,readdir:Hi,mkdir:Ji,access:Ki}=Wt("node:fs/promises"),{createRequire:Zi}=Wt("node:module"),$e=[{alias:"v",description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];var Yi=Object.defineProperty,Qi=x((t,e)=>Yi(t,"name",{value:e,configurable:!0}),"t$9");let Z=class extends E{static{j(this,"B")}static{S(this,"V")}static{x(this,"a")}static{Qi(this,"CommandNotFoundError")}commandName;constructor(e,n=[]){const i=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(i,"COMMAND_NOT_FOUND",{commandName:e,suggestions:n}),this.name="CommandNotFoundError",this.commandName=e,n.length>0&&(this.hint=`Try one of these commands: ${n.join(", ")}`)}};var Xi=Object.defineProperty,eo=x((t,e)=>Xi(t,"name",{value:e,configurable:!0}),"e$7");let qt=class extends E{static{j(this,"st")}static{S(this,"at")}static{x(this,"o")}static{eo(this,"ConflictingOptionsError")}option1;option2;constructor(t,e){super(`Options "${t}" and "${e}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:t,option2:e}),this.name="ConflictingOptionsError",this.option1=t,this.option2=e,this.hint=`Remove either --${t} or --${e}`}};var to=Object.defineProperty,no=x((t,e)=>to(t,"name",{value:e,configurable:!0}),"e$6");let io=class extends E{static{j(this,"xn")}static{S(this,"kn")}static{x(this,"o")}static{no(this,"PluginError")}pluginName;constructor(t,e,n){super(`Plugin "${t}" error: ${e}`,"PLUGIN_ERROR",{originalError:n,pluginName:t}),this.name="PluginError",this.pluginName=t,n&&(this.cause=n)}};var oo=Object.defineProperty,pt=x((t,e)=>oo(t,"name",{value:e,configurable:!0}),"d$6");let ro=class{static{j(this,"Ln")}static{S(this,"xn")}static{x(this,"p")}static{pt(this,"PluginManager")}logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(t){this.logger=t}hasPlugins(){return this.plugins.size>0}register(t){if(this.initialized)throw new Error(`Cannot register plugin "${t.name}" after initialization`);if(this.plugins.has(t.name))throw new Error(`Plugin "${t.name}" is already registered`);J().CEREBRO_OUTPUT_LEVEL===String(re)&&this.logger.debug(`registering plugin: ${t.name}`),this.plugins.set(t.name,t),this.cachedDependencyOrder=void 0}async init(t){if(this.initialized)throw new Error("PluginManager already initialized");if(this.plugins.size===0){this.logger.debug("no plugins registered, skipping initialization"),this.initialized=!0;return}this.validateDependencies();const e=this.getDependencyOrder();this.logger.debug(`initializing ${String(e.length)} plugin(s)...`);for(const n of e)if(typeof n.init=="function"){this.logger.debug(`initializing plugin: ${n.name}`);try{await n.init(t)}catch(i){const r=new io(n.name,`Failed to initialize: ${i instanceof Error?i.message:String(i)}`,i instanceof Error?i:void 0);throw this.logger.error(r.message),r}}this.initialized=!0}async executeLifecycle(t,e,n){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const i=this.getDependencyOrder();for(const r of i){const o=r[t];if(typeof o=="function"){this.logger.debug(`executing ${t} hook for plugin: ${r.name}`);try{await(t==="afterCommand"?o(e,n):o(e))}catch(s){throw this.logger.error(`Error in ${t} hook for plugin "${r.name}":`,s),s}}}}async executeErrorHandlers(t,e){if(!this.initialized||this.plugins.size===0)return;const n=this.getDependencyOrder();for(const i of n)if(typeof i.onError=="function"){this.logger.debug(`executing error handler for plugin: ${i.name}`);try{await i.onError(t,e)}catch(r){this.logger.error(`Error in error handler for plugin "${i.name}":`,r)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const t=[],e=new Set,n=new Set,i=pt(r=>{if(e.has(r))return;if(n.has(r))throw new Error(`Circular dependency detected involving plugin "${r}"`);const o=this.plugins.get(r);if(!o)throw new Error(`Plugin "${r}" not found`);if(n.add(r),o.dependencies)for(const s of o.dependencies)i(s);n.delete(r),e.add(r),t.push(o)},"visit");for(const r of this.plugins.keys())i(r);return this.cachedDependencyOrder=t,t}validateDependencies(){for(const t of this.plugins.values())if(t.dependencies){for(const e of t.dependencies)if(!this.plugins.has(e))throw new Error(`Plugin "${t.name}" depends on "${e}" which is not registered`)}}};var ao=Object.defineProperty,so=x((t,e)=>ao(t,"name",{value:e,configurable:!0}),"n$b");const be=so(t=>t.type?.name==="Boolean","optionIsBoolean");var lo=Object.defineProperty,Gt=x((t,e)=>lo(t,"name",{value:e,configurable:!0}),"p$6");const co=Gt(t=>{let e=t.type?t.type.name.toLowerCase():"string";const n=t.multiple??t.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${n}}`),e},"getTypeLabel"),ft=Gt(t=>(be(t)||(t.typeLabel=t.typeLabel??co(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),"mapOptionTypeLabel");var uo=Object.defineProperty,Ht=x((t,e)=>uo(t,"name",{value:e,configurable:!0}),"e$4");const po=new RegExp(/^-([^\d-])$/),fo=new RegExp(/^--(\S+)/),ho=new RegExp(/^-([^\d-]{2,})$/),mo=Ht(t=>po.test(t)||fo.test(t)||ho.test(t),"isOption"),go=Ht((t,e)=>{const n=e[0]&&mo(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const i=new Error(`Command not recognised: ${String(n)}`);throw i.command=n,i.name="INVALID_COMMAND",i}return{argv:e,command:n}},"commandLineCommands");var vo=Object.defineProperty,Jt=x((t,e)=>vo(t,"name",{value:e,configurable:!0}),"o$b"),bo=Object.defineProperty,Kt=Jt((t,e)=>bo(t,"name",{value:e,configurable:!0}),"o"),yo=Object.defineProperty,wo=Kt((t,e)=>yo(t,"name",{value:e,configurable:!0}),"i");let $o=class Zt extends ye{static{j(this,"pt")}static{S(this,"ut")}static{x(this,"a")}static{Jt(this,"r")}static{Kt(this,"t")}static{wo(this,"AlreadySetError")}optionName;constructor(e){super({cause:void 0,hint:`Remove the duplicate option '${e}' from your command line arguments.`,location:void 0,message:`Option '${e}' is already set`,name:"ALREADY_SET",stack:void 0,title:"Option Already Set"}),this.optionName=e,Object.setPrototypeOf(this,Zt.prototype)}};var Oo=Object.defineProperty,Yt=x((t,e)=>Oo(t,"name",{value:e,configurable:!0}),"t$7"),xo=Object.defineProperty,Qt=Yt((t,e)=>xo(t,"name",{value:e,configurable:!0}),"e"),Po=Object.defineProperty,Ao=Qt((t,e)=>Po(t,"name",{value:e,configurable:!0}),"e");let dt=class Xt extends ye{static{j(this,"ft")}static{S(this,"dt")}static{x(this,"n")}static{Yt(this,"n")}static{Qt(this,"o")}static{Ao(this,"UnknownOptionError")}optionName;constructor(e){super({cause:void 0,hint:`Check your option definitions or remove the unknown option '${e}' from your command line arguments.`,location:void 0,message:`Unknown option: --${e}`,name:"UNKNOWN_OPTION",stack:void 0,title:"Unknown Option"}),this.optionName=`--${e}`,Object.setPrototypeOf(this,Xt.prototype)}};var Eo=Object.defineProperty,en=x((t,e)=>Eo(t,"name",{value:e,configurable:!0}),"a$9"),No=Object.defineProperty,tn=en((t,e)=>No(t,"name",{value:e,configurable:!0}),"a"),Co=Object.defineProperty,jo=tn((t,e)=>Co(t,"name",{value:e,configurable:!0}),"o");let ko=class nn extends ye{static{j(this,"vt")}static{S(this,"gt")}static{x(this,"o")}static{en(this,"r")}static{tn(this,"e")}static{jo(this,"UnknownValueError")}value;constructor(e){super({hint:"Use a defined option or add a defaultOption to capture this value.",message:`Unknown value: ${e}`,name:"UNKNOWN_VALUE",title:"Unknown Value"}),this.value=e,Object.setPrototypeOf(this,nn.prototype)}};var _o=Object.defineProperty,on=x((t,e)=>_o(t,"name",{value:e,configurable:!0}),"i$8"),Lo=Object.defineProperty,rn=on((t,e)=>Lo(t,"name",{value:e,configurable:!0}),"i"),To=Object.defineProperty,Io=rn((t,e)=>To(t,"name",{value:e,configurable:!0}),"i");let U=class an extends ye{static{j(this,"bt")}static{S(this,"yt")}static{x(this,"a")}static{on(this,"o")}static{rn(this,"e")}static{Io(this,"InvalidDefinitionsError")}constructor(e,n){super({cause:void 0,hint:n,location:void 0,message:e,name:"INVALID_DEFINITIONS",stack:void 0,title:"Invalid Option Definition"}),Object.setPrototypeOf(this,an.prototype)}};var So=Object.defineProperty,Mo=x((t,e)=>So(t,"name",{value:e,configurable:!0}),"E$3"),Uo=Object.defineProperty,le=Mo((t,e)=>Uo(t,"name",{value:e,configurable:!0}),"C"),Vo=Object.defineProperty,je=le((t,e)=>Vo(t,"name",{value:e,configurable:!0}),"o");const ht=je(t=>t===Boolean||typeof t=="function"&&t.name==="Boolean","isBooleanType"),mt=je(t=>t===Number||typeof t=="function"&&t.name==="Number","isNumberType"),gt=je(t=>t===String||typeof t=="function"&&t.name==="String","isStringType"),Bo=je((t,e)=>Array.isArray(t)?ht(e)?t.map(Boolean):mt(e)?t.map(Number):gt(e)?t.map(String):t.map(n=>e(String(n))):t===null?null:ht(e)?!!t:mt(e)?Number(t):gt(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t)),"convertValue");var Do=Object.defineProperty,Ro=le((t,e)=>Do(t,"name",{value:e,configurable:!0}),"e");const L=Ro((t,e,n,...i)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...i)},"debug");var zo=Object.defineProperty,ne=le((t,e)=>zo(t,"name",{value:e,configurable:!0}),"x$2");const Fo=/-([a-z])/g,Wo=/^\d+$/,De=ne(t=>t===Boolean||typeof t=="function"&&t.name==="Boolean","isBooleanType"),qo=ne(t=>t.codePointAt(0)===95,"isSpecialKey"),vt=ne((t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],"appendToArrayMultiple"),bt=ne(t=>t==="__proto__"||t==="constructor"||t==="prototype","isUnsafeKey"),yt=ne((t,e,n,i=!1)=>{t[e]===void 0?t[e]=i?[n]:n:i&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},"createOrAppendArray"),Go=ne((t,e,n,i,r)=>{let o=e.get(t)??n.get(t);if(!o&&i){const s=t.toLowerCase();o=i.get(s)??r?.get(s)}return o},"getDefinition"),Ho=ne((t,e,n,i)=>{const r=n.debug??!1;L(r,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),L(r,"Starting argument resolution","resolver"),L(r,"Tokens:","resolver",t),L(r,"Definitions:","resolver",e),L(r,"Processing tokens...","resolver");const o=new Map,s=new Map,l=n.caseInsensitive?new Map:void 0,f=n.caseInsensitive?new Map:void 0,a=n.camelCase?new Map:void 0,c=n.camelCase?new Map:void 0;for(const d of e)if(o.set(d.name,d),d.alias&&s.set(d.alias,d),n.caseInsensitive&&l&&(l.set(d.name.toLowerCase(),d),d.alias&&f&&f.set(d.alias.toLowerCase(),d)),n.camelCase&&a&&c){const g=d.name.replaceAll(Fo,(y,O)=>O.toUpperCase());a.set(d.name,g),c.set(g,d.name)}const h={},p={},m=[],u=[],v=new Set;let w=!1;const b=e.find(d=>d.defaultOption),$=e.some(d=>d.group),A=e.some(d=>d.type===Number);for(let d=0;d<t.length;d++){const g=t[d];if(g.kind==="option-terminator"){h._unknown=i.slice(g.index),w=!0;break}if(g.kind==="option"&&g.name){let y=Go(g.name,o,s,l,f);if(!y&&g.value===void 0&&A&&Wo.test(g.name)){const C=e.find(z=>z.type===Number);C&&(y=C,g.value=g.name,g.name=C.name)}const O=y?y.name:g.name,P=y?.multiple,V=y?.lazyMultiple;if(p[O]!==void 0&&!P&&!V&&!n.partial)throw new $o(O);if(!y&&n.partial){const C=g.rawName??`--${g.name}${g.value!==void 0&&g.inlineValue?`=${g.value}`:""}`;m.push({index:g.index,value:C});continue}if(!y&&n.stopAtFirstUnknown){h._unknown=i.slice(g.index);break}if(!y&&!n.partial)throw new dt(g.name);if(g.value===void 0){const C=t[d+1],z=C?.kind==="option"&&!("name"in C)&&C.value!==void 0,T=C&&y&&!(y.type&&De(y.type))&&(C.kind==="positional"||z),Mn=y&&y.defaultOption&&!y.multiple&&!y.lazyMultiple;if(T&&(!y?.defaultOption||Mn))if(P){let F=d+1;const Ve=[];for(;F<t.length&&(t[F].kind==="positional"||t[F].kind==="option"&&!("name"in t[F])&&t[F].value!==void 0);)Ve.push(t[F].value),v.add(t[F].index),F++;p[O]=p[O]===void 0?Ve:vt(p[O],Ve),d=F-1}else V?(yt(p,O,C.value,!0),v.add(C.index),d++):(p[O]=C.value,v.add(C.index),d++);else y?.type&&De(y.type)?yt(p,O,!0,P):p[O]=P?[]:null}else{let{value:C}=g;if(y?.type&&De(y.type))switch(C){case"":{if(n.partial){p._unknown??=[];const T=`${g.rawName??`--${g.name}`}${g.value?`=${g.value}`:""}`;p._unknown.push(T),u.push({index:g.index,value:T}),C=!0}else throw new dt(g.name);break}case"false":{C=!1;break}case"true":{C=!0;break}default:C=!0}const z=[C];if(P){let T=d+1;for(;T<t.length&&t[T].kind==="positional";)z.push(t[T].value),v.add(t[T].index),T++;d=T-1}p[O]===void 0?p[O]=P||V?z:C:P||V?p[O]=vt(p[O],z):p[O]=C}}else if(g.kind==="positional"&&n.stopAtFirstUnknown&&!v.has(g.index)&&!b){L(r,`Found unconsumed positional token at index ${String(g.index)}, stopping processing`,"resolver"),h._unknown=i.slice(g.index);break}}for(const[d,g]of Object.entries(p)){const y=o.get(d);y&&(y.multiple||y.lazyMultiple)&&!Array.isArray(g)&&(p[d]=[g])}let N=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!w){for(const d of t)if(d.kind==="option"&&!o.has(d.name??"")&&!s.has(d.name??"")&&(!n.caseInsensitive||!l?.has(d.name?.toLowerCase()??"")&&!f?.has(d.name?.toLowerCase()??""))){N=d.index;break}}if(b){const d=[],g=[];for(const y of t)y.kind==="positional"&&!v.has(y.index)&&y.index<N&&(d.push(y.value),g.push(y));if(d.length>0){const y=p[b.name],O=b.multiple??b.lazyMultiple;y===void 0?O?(g.forEach(P=>v.add(P.index)),p[b.name]=d):(v.add(g[0].index),p[b.name]=d[0]):O&&(g.forEach(P=>v.add(P.index)),p[b.name]=Array.isArray(y)?[...d,...y]:[...d,y])}}if(!n.partial){for(const d of t)if(d.kind==="positional"&&!v.has(d.index))throw new ko(i[d.index])}if(n.partial&&!n.stopAtFirstUnknown){const d=[...m];if(p._unknown)for(const g of u)d.push({index:g.index,value:g.value});for(const g of t)g.kind==="positional"&&!v.has(g.index)&&d.push({index:g.index,value:i[g.index]});d.length>0&&(d.sort((g,y)=>g.index-y.index),h._unknown=d.map(g=>g.value))}if(n.stopAtFirstUnknown&&!w){const d=t.findIndex(O=>O.kind==="option"&&!o.has(O.name??"")&&!s.has(O.name??"")&&(!n.caseInsensitive||!l?.has(O.name?.toLowerCase()??"")&&!f?.has(O.name?.toLowerCase()??""))),g=t.findIndex(O=>O.kind==="positional"&&!v.has(O.index));let y=-1;if(d!==-1&&g!==-1?y=Math.min(d,g):d!==-1?y=d:g!==-1&&(y=g),y>=0){const O=t[y].index;h._unknown=i.slice(O)}}else m.length>0&&!n.partial&&(h._unknown=m.map(d=>d.value));for(const[d,g]of Object.entries(p)){const y=n.camelCase?a?.get(d)??d:d,O=o.get(d);h[y]=O?.type?Bo(g,O.type):g===void 0?null:g}for(const d of e){const g=n.camelCase?a?.get(d.name)??d.name:d.name;!(g in h)&&d.defaultValue!==void 0&&(d.multiple??d.lazyMultiple?h[g]=Array.isArray(d.defaultValue)?[...d.defaultValue]:[d.defaultValue]:h[g]=d.defaultValue)}if($){const d={},g={},y={};for(const P of e)if(P.group){const V=Array.isArray(P.group)?P.group:[P.group];for(const C of V)bt(C)||(d[C]??={})}for(const P of Object.keys(h))if(!qo(P)){g[P]=h[P];let V=P;n.camelCase&&(V=c?.get(P)??P);const C=o.get(V);if(C?.group){const z=Array.isArray(C.group)?C.group:[C.group];for(const T of z)bt(T)||d[T]&&(d[T][P]=h[P])}else y[P]=h[P]}const O={_all:g};for(const[P,V]of Object.entries(d))O[P]=V;Object.keys(y).length>0&&(O._none=y),h._unknown&&(O._unknown=h._unknown),Object.keys(h).forEach(P=>delete h[P]),Object.assign(h,O)}return L(r,"Final parsed result:","resolver",h),h},"resolveArgs");var Jo=Object.defineProperty,ce=le((t,e)=>Jo(t,"name",{value:e,configurable:!0}),"l");const se="-".codePointAt(0),X="=",Ko=X.codePointAt(0),Zo="--",Yo="-",Qo="--",sn=ce(t=>t.length>2&&t.startsWith(Qo),"hasLongOptionPrefix"),Xo=ce(t=>sn(t)&&!t.includes(X,3),"isLongOption"),er=ce(t=>sn(t)&&t.includes(X,3),"isLongOptionAndValue"),tr=ce(t=>{if(t.length!==2||t.codePointAt(0)!==se||t.codePointAt(1)===se)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},"isShortOption"),nr=ce(t=>!(t.length<=2||t.codePointAt(0)!==se||t.codePointAt(1)===se),"isShortOptionGroup"),ir=ce(t=>{const e=[],n=[...t];let i=-1,r=0;for(;n.length>0;){const o=n.shift();if(o===void 0)break;if(r>0?r--:i++,o===Zo){e.push({index:i,kind:"option-terminator"});const s=n.map((l,f)=>({index:i+f+1,kind:"positional",value:l}));e.push(...s),i+=n.length;break}if(tr(o)){const s=o.charAt(1);e.push({index:i,kind:"option",name:s,rawName:o});continue}if(nr(o)&&!o.includes(X)){const s=[];let l="",f=!1;for(let a=1;a<o.length;a++){const c=o.charAt(a);f?l+=c:c.codePointAt(0)===Ko?f=!0:s.push(`${Yo}${c}`)}if(f)if(s.length>0){const a=s.pop();s.push(`${a}=${l}`)}else s.push(l);n.unshift(...s),r=s.length;continue}if(Xo(o)){const s=o.slice(2);e.push({index:i,kind:"option",name:s,rawName:o});continue}if(er(o)){const s=o.indexOf(X),l=o.slice(2,s),f=o.slice(s+1);e.push({index:i,inlineValue:!0,kind:"option",name:l,rawName:o,value:f});continue}if(o.length>2&&o.codePointAt(0)===se&&o.codePointAt(1)!==se&&o.includes(X)){const s=o.indexOf(X),l=o.charAt(1),f=o.slice(s+1);e.push({index:i,inlineValue:!0,kind:"option",name:l,rawName:o,value:f});continue}e.push({index:i,kind:"positional",value:o})}return e},"parseArgsTokens");var or=Object.defineProperty,Ze=le((t,e)=>or(t,"name",{value:e,configurable:!0}),"d");const rr=/\d/,ar=Ze(t=>t===Boolean||typeof t=="function"&&t.name==="Boolean","isBooleanType"),sr=Ze(t=>typeof t=="function","isValidCustomTypeFunction"),lr=Ze((t,e,n)=>{const i=n?.debug??!1;L(i,"Validating definitions:","validation",t,"caseInsensitive:",e);const r=new Set,o=new Set,s=new Set,l=new Set;let f=0;for(const a of t){if(L(i,"Checking definition:","validation",a),!a.name)throw L(i,"Validation failed: name is required","validation"),new U("Invalid option definition: name is required");if(typeof a.name!="string")throw new U("Invalid option definition: name must be a string");if(a.name.trim()==="")throw new U("Invalid option definition: name cannot be empty");const c=e?a.name.toLowerCase():"";if(r.has(a.name)||e&&s.has(c))throw new U(`Invalid option definition: duplicate name '${a.name}'`);if(o.has(a.name)||e&&l.has(c))throw new U(`Invalid option definition: name '${a.name}' conflicts with an existing alias`);if(r.add(a.name),e&&s.add(c),a.alias!==void 0){if(typeof a.alias!="string")throw new U("Invalid option definition: alias must be a string");if(a.alias.length!==1)throw new U("Invalid option definition: alias must be a single character");if(rr.test(a.alias))throw new U("Invalid option definition: alias cannot be numeric");if(a.alias==="-")throw new U('Invalid option definition: alias cannot be "-"');const h=e?a.alias.toLowerCase():"";if(o.has(a.alias)||e&&l.has(h))throw new U(`Invalid option definition: duplicate alias '${a.alias}'`);if(r.has(a.alias)||e&&s.has(h))throw new U(`Invalid option definition: alias '${a.alias}' conflicts with an existing option name`);o.add(a.alias),e&&l.add(h)}if(a.defaultOption&&(f++,a.type!==void 0&&ar(a.type)))throw new U("Invalid option definition: defaultOption cannot be Boolean type");if(a.type!==void 0&&!(a.type===Boolean||a.type===Number||a.type===String||typeof a.type=="function"&&sr(a.type)))throw new U("Invalid option definition: invalid type")}if(f>1)throw L(i,"Validation failed: multiple defaultOptions not allowed","validation"),new U("Invalid option definition: multiple defaultOptions not allowed");L(i,"Validation completed successfully","validation")},"validateDefinitions");var cr=Object.defineProperty,ur=le((t,e)=>cr(t,"name",{value:e,configurable:!0}),"O");const pr=ur((t,e={})=>{const n=e.debug??!1;L(n,"Starting command-line-args parsing","index"),L(n,"Options:","index",e);const i={...e};i.stopAtFirstUnknown&&(i.partial=!0);const r=Array.isArray(t)?t:[t];L(n,"Normalized definitions:","index",r),lr(r,i.caseInsensitive,n?i:void 0);let{argv:o}=i;if(!o&&(o=process.argv.slice(2),process.execArgv.length>0)){const a=new Set(process.execArgv);o=o.filter(c=>!a.has(c))}L(n,"Using argv:","index",o);let s=o;i.caseInsensitive&&(s=o.map(a=>{if(a.startsWith("--")){const c=a.indexOf("="),h=(c===-1?a.slice(2):a.slice(2,c)).toLowerCase();return c===-1?`--${h}`:`--${h}${a.slice(c)}`}if(a.startsWith("-")&&!a.startsWith("--")&&a.length>1){const c=a.slice(1).split("=",2),h=c[0],p=c[1];if(!h)return a;const m=h.toLowerCase();return p===void 0?`-${m}`:`-${m}=${p}`}return a}));const l=ir(s.map(String));L(n,"Tokenized arguments:","index",l);const f=Ho(l,r,i,o);return L(n,"Command-line-args parsing completed","index"),f},"commandLineArgs");var fr=Object.defineProperty,dr=x((t,e)=>fr(t,"name",{value:e,configurable:!0}),"b$2");let hr=class{static{j(this,"Di")}static{S(this,"Vo")}static{x(this,"m")}static{dr(this,"EmptyToolbox")}result;argv;options;argument;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;constructor(t,e){this.commandName=t,this.command=e}};var mr=Object.defineProperty,gr=x((t,e)=>mr(t,"name",{value:e,configurable:!0}),"n$7");let Re=class extends E{static{j(this,"Ae")}static{S(this,"$e")}static{x(this,"i")}static{gr(this,"CommandLoaderError")}commandName;constructor(e,n,i){super(`Failed to load command "${e}": ${n}`,"COMMAND_LOADER_ERROR",{commandName:e,reason:n}),this.name="CommandLoaderError",this.commandName=e,this.hint="Ensure the loader resolves to a module with a default export that is the command handler function.",i!==void 0&&(this.cause=i)}};var vr=Object.defineProperty,br=x((t,e)=>vr(t,"name",{value:e,configurable:!0}),"f$5");const yr=/^-{1,2}(\w+)(=(.+))?$/,ln=br((t,e,n,i)=>{const r=yr.exec(t);if(r===null)return{};const o=r[1];if(!o)return{};const s=n&&i?n.get(o)??i.get(o):e.find(l=>l.name===o||l.alias===o);return s!==void 0?{argName:s.name,argValue:r[3],option:s}:{}},"getParameterOption");var wr=Object.defineProperty,Je=x((t,e)=>wr(t,"name",{value:e,configurable:!0}),"e$3");const wt=Je((t,e)=>{if(e.type===void 0)return t;if(e.type.name==="Boolean"){if(t==="true"||t==="1")return e.type(!0);if(t==="false"||t==="0")return e.type(!1)}return e.type(t)},"convertType"),$r=new Set(["0","1","false","true"]),Or=Je((t,e,n,i)=>{if(e.length===0||t.length===0)return{};const r=Je((o,s)=>{const{argName:l,argValue:f,option:a}=ln(s,e,n,i),{lastOption:c}=o;return a&&be(a)&&f&&l?o.partial[l]=wt(f,a):o.lastName&&c&&be(c)&&$r.has(s)&&(o.partial[o.lastName]=wt(s,c)),{lastName:l,lastOption:a,partial:o.partial}},"getBooleanValue");return t.reduce(r,{partial:{}}).partial},"getBooleanValues");var xr=Object.defineProperty,$t=x((t,e)=>xr(t,"name",{value:e,configurable:!0}),"s$9");const Pr=new Set(["0","1","false","true"]),Ar=$t((t,e,n,i)=>{if(e.length===0||t.length===0)return t;const r=$t((o,s)=>{const{argValue:l,option:f}=ln(s,e,n,i),{lastOption:a}=o;if(a&&be(a)&&Pr.has(s)){const{args:c}=o;return{args:c.slice(0,-1)}}return f&&be(f)&&l?{args:o.args}:{args:[...o.args,s],lastOption:f}},"removeBooleanArguments");return t.reduce(r,{args:[]}).args},"removeBooleanValues");var Er=Object.defineProperty,Nr=x((t,e)=>Er(t,"name",{value:e,configurable:!0}),"o$8");const Cr=Nr(t=>{const e=new Map;for(const n of t){const i=e.get(n.name);i?e.set(n.name,{...i,...n}):e.set(n.name,n)}return[...e.values()]},"mergeArguments");var jr=Object.defineProperty,ke=x((t,e)=>jr(t,"name",{value:e,configurable:!0}),"o$7");const kr=ke(t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},"transformBooleanEnv"),_r=ke((t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return kr(e);if(t.type===Number||typeof t.type=="function"&&t.type.name==="Number"){const n=Number.parseFloat(e);return Number.isNaN(n)?void 0:n}return t.type===String||typeof t.type=="function"&&t.type.name==="String"?e:t.type(e)}},"transformEnvValue"),Lr=/_./g,Tr=/^[A-Z]/,Ir=ke(t=>t.toLowerCase().replaceAll(Lr,e=>e[1]?.toUpperCase()??e).replace(Tr,e=>e.toLowerCase()),"toCamelCase"),Sr=ke(t=>{if(!t||t.length===0)return{};const e={},n=J();for(const i of t){const r=n[i.name],o=_r(i,r),s=o===void 0?i.defaultValue:o,l=Ir(i.name);e[l]=s}return e},"processEnvVariables");var Mr=Object.defineProperty,we=x((t,e)=>Mr(t,"name",{value:e,configurable:!0}),"a$5");const Ur=we(t=>{const e=new Map,n=new Map;for(const i of t)if(e.set(i.name,i),i.alias){const r=Array.isArray(i.alias)?i.alias:[i.alias];for(const o of r)n.set(o,i)}return{optionMapByAlias:n,optionMapByName:e}},"buildOptionMaps"),cn=we(async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new Re(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(i){throw new Re(t.name,i instanceof Error?i.message:String(i),i)}const n=e.default;if(typeof n!="function")throw new Re(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},"loadLazyHandler"),Vr=we((t,e,n,i)=>{const r=new hr(t.name,t),{_all:o,_unknown:s,positionals:l}=e,f=Object.keys(n).length>0?{...o,...n}:o;Pe in f&&delete f[Pe],r.argument=l?.[Pe]??[],r.rawUnknown=[...s??[]];const a=Object.keys(i).length>0;return r.options=a?{...f,...i}:f,r.env=Sr(t.env),r},"prepareToolbox"),Br=we((t,e,n)=>{const i=t.options??[],r=i.length>0;let o=Cr(r?[...i,...n]:n);if(o.length>0){for(const a of o)if(a.multiple&&a.lazyMultiple)throw new Error(`Argument "${a.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}t.argument&&(o=[{defaultOption:!0,description:t.argument.description,group:"positionals",multiple:!0,name:Pe,type:t.argument.type,typeLabel:t.argument.typeLabel},...o]);let s,l;if(r){const{optionMapByAlias:a,optionMapByName:c}=Ur(i);s=Ar(e,i,c,a),l=Or(e,i,c,a)}else s=e,l={};const f=pr(o,{argv:s,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:o,booleanValues:l,parsedArgs:f}},"processCommandArgs"),oe=we(async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await cn(t))(e),"executeCommand");var Dr=Object.defineProperty,Rr=x((t,e)=>Dr(t,"name",{value:e,configurable:!0}),"n$6");let zr=class extends E{static{j(this,"fo")}static{S(this,"fi")}static{x(this,"s")}static{Rr(this,"CommandValidationError")}commandName;missingOptions;constructor(t,e){super(`Command "${t}" is missing required options: ${e.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:t,missingOptions:e}),this.name="CommandValidationError",this.commandName=t,this.missingOptions=e,this.hint=`Provide the following required options: ${e.join(", ")}`}};var Fr=Object.defineProperty,Wr=x((t,e)=>Fr(t,"name",{value:e,configurable:!0}),"t$5");const Ot=Wr((t,e,n=!1)=>{const i=[];for(const r of t)if(!(!n&&!r.required)&&e[r.name]===void 0){if(r.type?.name==="Boolean"){e[r.name]=!1;continue}i.push(r)}return i},"listMissingArguments");var qr=Object.defineProperty,un=x((t,e)=>qr(t,"name",{value:e,configurable:!0}),"n$5");const Gr=un((t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:Rt(t,e)<=t.length/3,"isSimilar"),Q=un((t,e)=>{const n=t.toLowerCase();return e.filter(i=>Gr(i.toLowerCase(),n))},"findAlternatives");var Hr=Object.defineProperty,_e=x((t,e)=>Hr(t,"name",{value:e,configurable:!0}),"a$4");const Jr=_e((t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(i=>{const r=i.startsWith("--");let o=`Found unknown ${r?"option":"argument"} "${i}"`;if(r){const s=Q(i.replace("--",""),(e.options??[]).map(l=>l.name));if(s.length>0){const[l,...f]=s.map(a=>`--${a}`);o+=f.length>0?`, did you mean ${l??""} or ${f.join(", ")}?`:`, did you mean ${l??""}?`}}n.push(o)}),n.length>0)throw new Error(n.join(`
4
+ `))},"validateUnknownOptions"),Kr=_e((t,e,n)=>{const i=n.__requiredOptions__,r=i?Ot(i,e,!0):Ot(t,e,!1);if(r.length>0)throw new zr(n.name,r.map(o=>o.name));e._unknown&&e._unknown.length>0&&!n.argument&&Jr(e,n)},"validateRequiredOptions"),Zr=_e((t,e,n)=>{const i=n.__conflictingOptions__??t.filter(r=>r.conflicts!==void 0);if(i.length>0){const r=i.find(o=>Array.isArray(o.conflicts)?o.conflicts.some(s=>e[s]!==void 0)&&e[o.name]!==void 0:e[o.conflicts]!==void 0&&e[o.name]!==void 0);if(r)throw new qt(r.name,typeof r.conflicts=="string"?r.conflicts:r.conflicts?.[0]??"unknown")}},"validateConflictingOptions"),Yr=_e(t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const r of t.options){if(r.name){const o=e.get(r.name)??[];o.push(r),e.set(r.name,o)}if(typeof r.alias=="string"&&r.alias.length>0){const o=n.get(r.alias)??[];o.push(r),n.set(r.alias,o)}else if(Array.isArray(r.alias)){for(const o of r.alias)if(o.length>0){const s=n.get(o)??[];s.push(r),n.set(o,s)}}}const i=[];for(const[r,o]of e)o.length>1&&i.push(`Duplicate option name "${r}" in command "${t.name}": ${JSON.stringify(o)}`);for(const[r,o]of n)o.length>1&&i.push(`Duplicate option alias "-${r}" used by options ${o.map(s=>`"${s.name}"`).join(", ")} in command "${t.name}"`);if(i.length>0)throw new Error(i.join(`
5
+ `))},"validateDuplicateOptions");var Qr=Object.defineProperty,Ye=x((t,e)=>Qr(t,"name",{value:e,configurable:!0}),"s$5");const Xr=Ye((t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];let i;for(let r=1;r<=e.length;r+=1){const o=e[r-1];if(o===void 0||o.startsWith("-"))break;n.push(o);const s=n.join(" ");t.has(s)&&(i={commandPath:[...n],depth:r})}return i?{argv:e.slice(i.depth),commandPath:i.commandPath}:{argv:e,commandPath:void 0}},"parseNestedCommand"),Y=Ye(t=>t.join(" "),"getCommandPathKey"),xt=Ye((t,e)=>e&&e.length>0?[...e,t]:[t],"getFullCommandPath");var ea=Object.defineProperty,pn=x((t,e)=>ea(t,"name",{value:e,configurable:!0}),"a$3"),ta=Object.defineProperty,fn=pn((t,e)=>ta(t,"name",{value:e,configurable:!0}),"a"),na=Object.defineProperty,ia=fn((t,e)=>na(t,"name",{value:e,configurable:!0}),"a");let dn=class{static{j(this,"_t")}static{S(this,"Nt")}static{x(this,"u")}static{pn(this,"n")}static{fn(this,"s")}static{ia(this,"LRUCache")}capacity;cache;constructor(t){this.capacity=t,this.cache=new Map}get(t){if(!this.cache.has(t))return;const e=this.cache.get(t);return this.cache.delete(t),this.cache.set(t,e),e}has(t){return this.cache.has(t)}set(t,e){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const n=this.cache.keys().next().value;n!==void 0&&this.cache.delete(n)}this.cache.set(t,e)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}};var oa=Object.defineProperty,ra=x((t,e)=>oa(t,"name",{value:e,configurable:!0}),"r$5"),aa=Object.defineProperty,sa=ra((t,e)=>aa(t,"name",{value:e,configurable:!0}),"a"),la=Object.defineProperty,ca=sa((t,e)=>la(t,"name",{value:e,configurable:!0}),"s");const ua=ca((t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleLowerCase(e.locale):t[0].toLowerCase())+t.slice(1),"lowerFirst");var pa=Object.defineProperty,fa=x((t,e)=>pa(t,"name",{value:e,configurable:!0}),"T"),da=Object.defineProperty,Le=fa((t,e)=>da(t,"name",{value:e,configurable:!0}),"j");const ha=Zi(import.meta.url),he=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ma=Le(t=>{if(typeof he<"u"&&he.versions&&he.versions.node){const[e,n]=he.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return he.getBuiltinModule(t)}return ha(t)},"__cjs_getBuiltinModule"),{stripVTControlCharacters:ga}=ma("node:util");var va=Object.defineProperty,ba=Le((t,e)=>va(t,"name",{value:e,configurable:!0}),"a");const ze=new dn(1e3),ya=/[.*+?^${}()|[\]\\]/g,wa=ba(t=>{const e=t.join("");if(ze.has(e)){const r=ze.get(e);return r.lastIndex=0,r}const n=t.map(r=>r.replaceAll(ya,String.raw`\$&`)).join("|"),i=new RegExp(n,"g");return ze.set(e,i),i},"getSeparatorsRegex");var $a=Object.defineProperty,Oa=Le((t,e)=>$a(t,"name",{value:e,configurable:!0}),"t");const xa=Oa(t=>{const e=[];let n=0,i;for(K.lastIndex=0;(i=K.exec(t))!==null;)i.index>n&&e.push(t.slice(n,i.index)),e.push(i[0]),n=K.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},"splitByEmoji");var Pa=Object.defineProperty,k=Le((t,e)=>Pa(t,"name",{value:e,configurable:!0}),"u");const Aa=/[ČŠŽĐ]/i,hn=new Uint8Array(128),mn=new Uint8Array(128),gn=new Uint8Array(128);for(let t=0;t<128;t++)hn[t]=t>=65&&t<=90?1:0,mn[t]=t>=97&&t<=122?1:0,gn[t]=t>=48&&t<=57?1:0;const Fe=k(t=>hn[t],"isUpper"),Pt=k(t=>mn[t],"isLower"),We=k(t=>gn[t],"isDigit"),H=k((t,e,n,i,r)=>{if(t.length===0)return[];let o=!1;const s=Object.values(e);for(const m of s)if(m(t[0])){o=!0;break}if(!o&&!n)return[t];const l=[...t],f=[];let a=l[0],c="other";const h=Object.entries(e);for(const m of h){const[u,v]=m;if(v(l[0])){c=u;break}}let p=n&&i?l[0]===l[0].toLocaleUpperCase(i):!1;for(let m=1;m<l.length;m++){const u=l[m];let v="other";for(const $ of h){const[A,N]=$;if(N(u)){v=A;break}}const w=n&&i?u===u.toLocaleUpperCase(i):!1;let b=!1;r?b=r(c,v,p,w,u,m,l):(c!==v&&c!=="other"&&v!=="other"&&(b=!0),n&&v!=="other"&&!p&&w&&(b=!0)),b?(f.push(a),a=u):a+=u,c=v,n&&(p=w)}return a&&a.length>0&&f.push(a),f.length>0?f:[t]},"handleScriptTransitions"),Ea=k((t,e,n,i)=>{if(n.size===0)return e;for(const r of n)if(t.startsWith(r,e))return i.push(r),e+r.length;return e},"detectAndProcessAcronym"),vn=k((t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const i=[],r=t.length;for(let o=1;o<r;o++){const s=Ea(t,n,e,i);if(s!==n){n=s,o=n-1;continue}const l=t.codePointAt(o-1),f=t.codePointAt(o),a=l&&l<128&&Fe(l),c=f&&f<128&&Fe(f),h=l&&l<128&&Pt(l),p=l&&l<128&&We(l),m=f&&f<128&&We(f);if(h&&c){i.push(t.slice(n,o)),n=o;continue}if(p&&!m||!p&&m){i.push(t.slice(n,o)),n=o;continue}if(m&&!p){let u=!1,v=!1;if(o+1<r){const w=t.codePointAt(o+1);u=w&&w<128&&Fe(w),v=w&&w<128&&We(w)}if(!v&&u){i.push(t.slice(n,o),t.slice(o,o+1)),n=o+1;continue}}if(o+1<r){const u=t.codePointAt(o+1),v=u&&u<128&&Pt(u);if(a&&c&&v){const w=t.slice(n,o+1);e.has(w)||(i.push(t.slice(n,o)),n=o)}}}return n<r&&i.push(t.slice(n)),i.filter(o=>o!=="")},"splitCamelCaseFast"),bn=k((t,e,n)=>{if(t.length===0)return[];const i=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!i&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const a=[...t],c=a.length,h=[];let p=a[0],m=a[0]===a[0].toLocaleUpperCase(e),u=m,v=m?0:-1;for(let w=1;w<c;w++){const b=a[w],$=b===b.toLocaleUpperCase(e);if($===m)p+=b;else if($)p&&p.length>0&&(h.push(p),p=b),u=!0,v=w;else{if(u&&w-v>1){const A=a[w-1],N=p.slice(0,-1);N&&N.length>0&&h.push(N),p=A+b}else p+=b;u=!1,v=-1}m=$}return p&&p.length>0&&h.push(p),h}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!ie.test(t)&&!M.test(t))return[t];const a=[...t],c=a.length,h=[];let p=a[0];const m=a[0];let u;ie.test(m)?u=1:M.test(m)?u=2:u=0;let v=m===m.toLocaleUpperCase(e);for(let b=1;b<c;b++){const $=a[b];let A;ie.test($)?A=1:M.test($)?A=2:A=0;const N=$===$.toLocaleUpperCase(e);u!==A&&(u===1||u===2)&&(A===1||A===2)||A===u&&!v&&N?(h.push(p),p=$):p+=$,u=A,v=N}p&&p.length>0&&h.push(p);const w=[];for(let b=0;b<h.length;b++)b<h.length-1&&h[b].length===1&&M.test(h[b])&&ie.test(h[b+1][0])?(w.push(h[b]+h[b+1]),b+=1):w.push(h[b]);return w}if(e.startsWith("el")){if(!Be.test(t)&&!M.test(t))return[t];const a=[];rt.lastIndex=0;let c;for(;(c=rt.exec(t))!==null;)a.push(c[0]);a.length===0&&a.push(t);const h=[];if(a.length===1){const p=a[0];if(!p||!Be.test(p[0])||p.length===1)return[p??t]}for(const p of a){if(!p)continue;if(!Be.test(p[0])||p.length===1){h.push(p);continue}const m=p.length;let u=p[0],v=p[0]===p[0].toLocaleUpperCase(e);for(let w=1;w<m;w++){const b=p[w],$=b===b.toLocaleUpperCase(e);!v&&$?(h.push(u),u=b):u+=b,v=$}u&&h.push(u)}return h}if(e.startsWith("ja")||e.startsWith("ko")){const a=e.startsWith("ja"),c=a?{hiragana:k(p=>Ni.test(p),"hiragana"),kanji:k(p=>lt.test(p),"kanji"),katakana:k(p=>ji.test(p),"katakana"),latin:k(p=>M.test(p),"latin")}:{hangul:k(p=>at.test(p),"hangul"),latin:k(p=>M.test(p),"latin")},h=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(a){const p=H(t,c,!1,e,(u,v)=>u==="hiragana"&&v==="katakana"||u==="katakana"&&v==="hiragana"||u==="hiragana"&&v==="latin"||u==="katakana"&&v==="latin"||u==="kanji"&&v==="latin"||u==="latin"&&(v==="hiragana"||v==="katakana"||v==="kanji")),m=[];for(const u of p){const v=u;v.length===1&&h.has(v)&&m.length>0?m[m.length-1]=m.at(-1)+v:m.push(v)}return m.length>0?m:[t]}return H(t,c,!1,e,(p,m)=>p==="hangul"&&m==="latin"||p==="latin"&&m==="hangul")}if(e.startsWith("sl")){const a=[...t],c=a.length,h=[];let p=a[0],m=a[0]===a[0].toLocaleUpperCase(e);for(let u=1;u<c;u++){const v=a[u],w=v===v.toLocaleUpperCase(e),b=Aa.test(v),$=u<c-1&&a[u+1]===a[u+1].toLocaleUpperCase(e);!m&&w||b&&$?(h.push(p),p=v,b&&$&&(h.push(p),p="")):p+=v,m=w}return p&&p.length>0&&h.push(p),h}if(e.startsWith("zh"))return H(t,{han:k(a=>lt.test(a),"han"),latin:k(a=>M.test(a),"latin")},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const a=k(c=>st.test(c)||ot.test(c),"isRtlChar");return H(t,{latin:k(c=>M.test(c),"latin"),rtl:k(c=>a(c),"rtl")},!1,e)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(e.split("-")[0])){const a=k(c=>xi.test(c)||Oi.test(c)||Ai.test(c)||Ei.test(c)||Ci.test(c)||Mi.test(c)||Ui.test(c)||Li.test(c)||Si.test(c)||Vi.test(c)||_i.test(c)||Bi.test(c)||Ti.test(c)||Pi.test(c)||ki.test(c)||Ii.test(c),"isIndicChar");return H(t,{indic:k(c=>a(c),"indic"),latin:k(c=>M.test(c),"latin")},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return H(t,{cyrillic:k(a=>ie.test(a),"cyrillic"),latin:k(a=>M.test(a),"latin")},!0,e);if(["ar","fa","he"].includes(e))return H(t,{latin:k(a=>M.test(a),"latin"),rtl:k(a=>st.test(a)||ot.test(a),"rtl")},!1,e);if(e.startsWith("ko"))return H(t,{hangul:k(a=>at.test(a),"hangul"),latin:k(a=>M.test(a),"latin")},!1,e);if(e.startsWith("uz")){if(!ie.test(t)&&!M.test(t))return[t];const a=[...t],c=a.length,h=[];let p=a[0],m=a[0]===a[0].toLocaleUpperCase(e);for(let u=1;u<c;u++){const v=a[u],w=v===v.toLocaleUpperCase(e);if(ct.test(v)||ct.test(a[u-1])){p+=v;continue}!m&&w?(h.push(p),p=v):p+=v,m=w}return p&&p.length>0&&h.push(p),h}const r=[...t],o=r.length,s=[];let l=r[0],f=r[0]===r[0].toLocaleUpperCase(e);for(const a of n)if(t.startsWith(a)){s.push(a),l=r[a.length],f=l===l.toLocaleUpperCase(e);break}for(let a=1;a<o;a++){const c=r[a],h=c===c.toLocaleUpperCase(e);let p=0;for(const m of n)if(t.startsWith(m,a)){s.push(l,m),p=m.length,l="";const u=m.at(-1);u&&(f=u===u.toLocaleUpperCase(e));break}if(p>0){a+=p-1;continue}!f&&h?(s.push(l),l=c):l+=c,f=h}return l&&s.push(l),s},"splitCamelCaseLocale"),Na=k((t,e,n)=>{const i=[],r=ve.test(t)?t.split(ve).filter(Boolean):[t];for(const o of r){const s=o;if(ve.test(s))i.push(s);else{K.lastIndex=0;const l=K.test(s)?xa(s).filter(Boolean):[s];for(const f of l)if(K.lastIndex=0,K.test(f))i.push(f);else if(e){const a=e.toLowerCase().split("-")[0];i.push(...bn(f,a,n))}else i.push(...vn(f,n))}}return i},"processTextWithAnsiEmoji"),Ca=k((t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:i=!1,knownAcronyms:r=[],locale:o,normalize:s=!1,separators:l,stripAnsi:f=!1,stripEmoji:a=!1}=e,c=new Set([...r].toSorted((b,$)=>$.length-b.length));let h=t;f&&(h=ga(h)),a&&(h=Di(h));let p;Array.isArray(l)?p=wa(l):l instanceof RegExp?p=l:p=$i;const m=[];let u=h;const v=p.flags.includes("g")?p:new RegExp(p.source,`${p.flags}g`);for(;u.length>0;){const b=v.exec(u);if(!b){u===".."?m.push(".."):u==="."?m.push("."):u.length>0&&m.push(u);break}const $=b.index,A=b[0],N=A.length,d=u.slice(0,$),g=u.slice($+N);if(A.startsWith("../"))m.push(".."),u=u.slice($+3);else if(A.startsWith("./"))m.push("."),u=u.slice($+2);else if($===0&&A==="..")m.push(".."),u=u.slice(2);else if($===0&&A===".")m.push("."),u=u.slice(1);else{d.length>0&&m.push(d);let y=0;for(;(y=A.indexOf("../",y))!==-1;)m.push(".."),y+=3;for(y=0;(y=A.indexOf("./",y))!==-1;)(y===0||A[y-1]!==".")&&m.push("."),y+=2;let O=g;for(;O.startsWith("../");)m.push(".."),O=O.slice(3);for(;O.startsWith("./");)m.push("."),O=O.slice(2);if(O===".."){m.push("..");break}else if(O==="."){m.push(".");break}else u=O}v.lastIndex=0}if(m.length===0){const b=h.split(p).filter(Boolean);m.push(...b)}let w=[];for(const b of m)n||i?w.push(...Na(b,o,c)):o?w.push(...bn(b,o,c)):w.push(...vn(b,c));return s&&(w=w.map(b=>c.has(b)?b:o&&b===b.toLocaleUpperCase(o)?b[0]+b.slice(1).toLocaleLowerCase(o):b.toUpperCase()===b&&!c.has(b)?b.slice(0,1)+b.slice(1).toLowerCase():b)),w},"splitByCase");var ja=Object.defineProperty,ka=x((t,e)=>ja(t,"name",{value:e,configurable:!0}),"r$4"),_a=Object.defineProperty,La=ka((t,e)=>_a(t,"name",{value:e,configurable:!0}),"o"),Ta=Object.defineProperty,Ia=La((t,e)=>Ta(t,"name",{value:e,configurable:!0}),"s");const Sa=Ia((t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleUpperCase(e.locale):t[0].toUpperCase())+t.slice(1),"upperFirst");var Ma=Object.defineProperty,Ua=x((t,e)=>Ma(t,"name",{value:e,configurable:!0}),"r$3"),Va=Object.defineProperty,Ba=Ua((t,e)=>Va(t,"name",{value:e,configurable:!0}),"r"),Da=Object.defineProperty,Ra=Ba((t,e)=>Da(t,"name",{value:e,configurable:!0}),"n");const za=Ra((t,e)=>`${t}::${e?.joiner??""}::${e?.locale??""}::${e?.knownAcronyms?.join(",")??""}::${e?.normalize?"true":"false"}`,"generateCacheKey");var Fa=Object.defineProperty,Wa=x((t,e)=>Fa(t,"name",{value:e,configurable:!0}),"i$3"),qa=Object.defineProperty,Ga=Wa((t,e)=>qa(t,"name",{value:e,configurable:!0}),"f"),Ha=Object.defineProperty,Ja=Ga((t,e)=>Ha(t,"name",{value:e,configurable:!0}),"l");const Ka=Ja((t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const i=[];let r="",o="";for(let s=0;s<n;s++){const l=t[s];if(ve.test(l)){r?(i.push(r+o+l),r="",o=""):(i.length>0&&i.push(e),r=l);continue}r?(o&&(o+=e),o+=l):(i.length>0&&i.push(e),i.push(l))}return i.join("")},"joinSegments");var Za=Object.defineProperty,Ya=x((t,e)=>Za(t,"name",{value:e,configurable:!0}),"r$2"),Qa=Object.defineProperty,Xa=Ya((t,e)=>Qa(t,"name",{value:e,configurable:!0}),"a"),es=Object.defineProperty,ts=Xa((t,e)=>es(t,"name",{value:e,configurable:!0}),"e");const ns=/(?<![a-zß])SS(?![a-z])/g,is=ts(t=>t.replaceAll(ns,"ß"),"normalizeGermanEszett");var os=Object.defineProperty,rs=x((t,e)=>os(t,"name",{value:e,configurable:!0}),"c$2"),as=Object.defineProperty,ss=rs((t,e)=>as(t,"name",{value:e,configurable:!0}),"c"),ls=Object.defineProperty,cs=ss((t,e)=>ls(t,"name",{value:e,configurable:!0}),"o");const us=new dn(1e3),yn=cs((t,e)=>{if(typeof t!="string"||!t)return"";const n=e?.cache??!1,i=e?.cacheStore??us;let r;if(n&&(r=za(t,e)),n&&r&&i.has(r))return i.get(r);let o=!0;const s=Ka(Ca(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(l=>{if(e?.handleAnsi&&ve.test(l))return l;const f=e?.locale?.startsWith("de")?is(l):l,a=e?.locale?f.toLocaleLowerCase(e.locale):f.toLowerCase();return o?(o=!1,ua(a,e)):Sa(a,e)}),"");return n&&r&&i.set(r,s),s},"camelCase");var ps=Object.defineProperty,Te=x((t,e)=>ps(t,"name",{value:e,configurable:!0}),"a$2");const fs=Te(t=>{t.options?.forEach(e=>{e.__camelCaseName__=yn(e.name)})},"processOptionNames"),ds=Te(t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const i of t.options)e.add(i.name);const n=[];for(const i of t.options)if(i.name.startsWith("no-")){const r=i.name.replace(/^no-/,"");if(!e.has(r)){if(i.type!==Boolean)throw new Error(`Cannot add negated option "${i.name}" to command "${t.name}" because it is not a boolean.`);const o={...i,defaultValue:i.defaultValue===void 0?!0:!i.defaultValue,name:r};n.push(o),e.add(r)}}n.length>0&&t.options.push(...n)},"addNegatableOptions"),hs=Te((t,e)=>{if(!e.options||e.options.length===0)return;const{options:n}=t,i=new Map;for(const o of e.options)if(o.name.startsWith("no-")){const s=yn(o.name);i.set(s,o)}const r=Object.keys(n).filter(o=>i.has(o));if(r.length!==0)for(const o of r){const s=o.charAt(2);if(!s)continue;const l=s.toLowerCase()+o.slice(3),f=i.get(o);f&&(f.__negated__=!0),n[l]=!n[o],Reflect.deleteProperty(n,o)}},"mapNegatableOptions"),ms=Te((t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const r of e.options)r.__camelCaseName__&&r.__negated__===void 0&&r.implies!==void 0&&n.set(r.__camelCaseName__,r);if(n.size===0)return;const{options:i}=t;for(const r of Object.keys(i)){const o=n.get(r);if(o?.implies){const{implies:s}=o;for(const[l,f]of Object.entries(s))i[l]===void 0&&(i[l]=f)}}},"mapImpliedOptions");var gs=Object.defineProperty,Ie=x((t,e)=>gs(t,"name",{value:e,configurable:!0}),"e$2");const vs=Ie(()=>!!process.versions.electron,"isElectronApp"),bs=Ie(()=>vs()&&!process.defaultApp,"isBundledElectronApp"),ys=Ie(()=>bs()?0:1,"getProcessArgvBinIndex"),ws=Ie(t=>t.slice(ys()+1),"hideBin");var $s=Object.defineProperty,wn=x((t,e)=>$s(t,"name",{value:e,configurable:!0}),"e$1");const Os=" ",xs=wn((t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,i)=>n===e[i]),"equals"),Ps=wn(t=>{if(typeof t=="string")return t.split(Os);const e=Ae();return xs(t,e)?ws(t):t},"parseRawCommand");var As=Object.defineProperty,qe=x((t,e)=>As(t,"name",{value:e,configurable:!0}),"r");const Es=qe(t=>{const e=qe(o=>{t.error(`Uncaught exception: ${o.message||o}`),o.stack&&t.error(o.stack),q(1)},"uncaughtExceptionHandler"),n=qe((o,s)=>{if(o instanceof Error)t.error(`Promise rejection: ${o.message||o}`),o.stack&&t.error(o.stack);else{let l;if(typeof o=="string")l=o;else try{l=JSON.stringify(o)}catch{l=String(o)}t.error(`Promise rejection: ${l}`)}q(1)},"unhandledRejectionHandler"),i=nt("uncaughtException",e),r=nt("unhandledRejection",n);return()=>{i(),r()}},"registerExceptionHandler");var Ns=Object.defineProperty,ue=x((t,e)=>Ns(t,"name",{value:e,configurable:!0}),"e");const Ee=100,$n=/^[a-z][\w-]*$/i,Ne=ue((t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new E(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},"validateNonEmptyString"),At=ue((t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new E(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateStringArray");ue((t,e)=>{if(typeof t!="function")throw new E(`${e} must be a function`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateFunction");const Ge=ue((t,e)=>{if(typeof t!="object"||t===null)throw new E(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateObject"),Oe=ue(t=>{const e=Ne(t,"Command name");if(e.length>Ee)throw new E(`Command name is too long (maximum ${String(Ee)} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new E(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!$n.test(e))throw new E(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},"validateCommandName");ue(t=>{const e=Ne(t,"Plugin name");if(e.length>Ee)throw new E(`Plugin name is too long (maximum ${String(Ee)} characters)`,"INVALID_PLUGIN_NAME",{length:e.length,pluginName:e});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new E(`Plugin name "${e}" contains invalid characters`,"INVALID_PLUGIN_NAME",{pluginName:e});if(!$n.test(e))throw new E(`Plugin name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_PLUGIN_NAME",{pluginName:e});return e},"validatePluginName");var Cs=Object.defineProperty,Se=x((t,e)=>Cs(t,"name",{value:e,configurable:!0}),"s");const js=new Set([`
6
+ `,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),ks=/^[A-Z]:/i,_s=Se((t,e=!0)=>{if(typeof t!="string")throw new TypeError("Argument must be a string");if(t.length>1e4)throw new Error(`Argument is too long (maximum ${String(1e4)} characters)`);if(e){for(const n of t)if(js.has(n))throw new Error(`Argument contains dangerous character: ${n}`)}return t.trim()},"sanitizeArgument"),Et=Se((t,e=!0)=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");if(t.length>100)throw new Error(`Too many arguments (maximum ${String(100)})`);return t.map(n=>_s(n,e))},"sanitizeArguments");Se(t=>{if(typeof t!="string")throw new TypeError("Path must be a string");const e=t.trim();if(e.split(/[/\\]/).includes(".."))throw new Error("Path contains directory traversal sequences");if(e.startsWith("/")||ks.test(e))throw new Error("Absolute paths are not allowed");if(e.length>1e3)throw new Error("Path is too long");return e},"validateSafePath");class jc{static{j(this,"vs")}static{S(this,"Ar")}static{x(this,"RateLimiter")}static{Se(this,"RateLimiter")}attempts=new Map;maxAttempts;windowMs;constructor(e=5,n=6e4){if(e<=0||n<=0)throw new Error("maxAttempts and windowMs must be positive numbers");this.maxAttempts=e,this.windowMs=n}checkLimit(e){const n=Date.now(),i=this.attempts.get(e);return!i||n>i.resetTime?(this.attempts.set(e,{count:1,resetTime:n+this.windowMs}),this.cleanup(n),!0):i.count>=this.maxAttempts?!1:(i.count+=1,!0)}reset(e){this.attempts.delete(e)}cleanup(e){for(const[n,i]of this.attempts.entries())e>i.resetTime&&this.attempts.delete(n)}}var Ls=Object.defineProperty,B=x((t,e)=>Ls(t,"name",{value:e,configurable:!0}),"b");const Ts=/^-([^\d-])$/,Is=/^--(\S+)/,Ss=/^-([^\d-]{2,})$/,He=B(t=>Ts.test(t)||Is.test(t)||Ss.test(t),"isOption"),Ms={access:B((t,e)=>Ki(t,e),"access"),mkdir:B((t,e)=>Ji(t,e),"mkdir"),readdir:B(t=>Hi(t),"readdir"),readFile:B((async(t,e)=>e===void 0?ut(t):ut(t,e)),"readFile"),rm:B((t,e)=>Gi(t,e),"rm"),stat:B(t=>qi(t),"stat"),writeFile:B((t,e,n)=>Wi(t,e,n),"writeFile")};let Us=class On{static{j(this,"je")}static{S(this,"Tt")}static{x(this,"Cli")}static{B(this,"Cli")}#t;#e;#c;#u;#f;#d;#y;#w;#$;#O;#x;#p;#n;#i;#o;#r;#a;#h=!1;#P;#A=!1;#m;#g;#v;#l=[];#k(){return this.#m===void 0&&(this.#m=[...this.#i.keys()]),this.#m}#E(){return this.#g===void 0&&(this.#g=[...this.#n.keys()]),this.#g}#s(){return this.#v===void 0&&(this.#v=[...this.#k(),...this.#E()]),this.#v}#N(){return this.#l.length===0?$e:[...$e,...this.#l]}#C(){this.#m=void 0,this.#g=void 0,this.#v=void 0}#b(){if(this.#c===void 0){const e=Ps(this.#e.argv);this.#c=Et(e,!1),this.#_()}return this.#c}#_(){if(!this.#c)return;const e=J();let n=!1;for(const i of this.#c){if(i==="--quiet"||i==="-q"){e.CEREBRO_OUTPUT_LEVEL=String(Rn),n=!0;break}if(i==="--verbose"||i==="-v"){e.CEREBRO_OUTPUT_LEVEL=String(zn),n=!0;break}if(i==="--debug"){e.CEREBRO_OUTPUT_LEVEL=String(re),n=!0;break}}n||(e.CEREBRO_OUTPUT_LEVEL=Object.hasOwn(e,"DEBUG")?String(re):String(tt))}#L(){this.#A||(this.#P=Es(this.#t),this.#A=!0)}#T(){return{arch:ri(),argv:this.#b(),cwd:this.#u,env:this.#O??J(),exit:this.#$??(e=>q(e??0)),platform:oi(),stdin:this.#x}}#j(e,n,i,r){this.#t.debug(`command '${r}' found, parsing command args: ${n.join(", ")}`);const{arguments_:o,booleanValues:s,parsedArgs:l}=Br(e,n,this.#N()),f=Object.keys(s).length>0;let a=l;f&&(a={...l,_all:{...l._all,...s}}),Kr(o,a,e);const c=Vr(e,l,s,i);c.runtime=this,c.argv=this.#b(),c.fs=this.#w??Ms,c.process=this.#T(),c.console=this.#t;const h=e.options&&e.options.length>0;if(h&&e.options){const p=e.options.filter(m=>m.name.startsWith("no-"));for(const m of p){const u=m.name.replace(/^no-/,""),v=`--${m.name}`,w=`--${u}`,b=n.includes(v),$=n.includes(w);if(b&&$)throw new qt(u,m.name)}}return h&&(hs(c,e),ms(c,e)),Zr(o,c.options,e),J().CEREBRO_OUTPUT_LEVEL===String(re)&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(c.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(c.argument,null,2))),{arguments_:o,booleanValues:s,commandArgs:a,parsedArgs:l,toolbox:c}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new E("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#f=e.trim();const i=n.argv??Ae(),r=n.cwd??ii();if(this.#e={...n,argv:i,cwd:r},this.#e.argv&&!Array.isArray(this.#e.argv))throw new E("CLI argv option must be an array of strings","INVALID_INPUT",{argv:this.#e.argv});if(this.#e.cwd&&typeof this.#e.cwd!="string")throw new E("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new E("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new E("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});const o=J();if(o.CEREBRO_OUTPUT_LEVEL=String(tt),typeof this.#e.logger=="object"){const c=["debug","error","info","log","warn"],h=[],p=this.#e.logger;for(const m of c)typeof p[m]!="function"&&h.push(m);if(h.length>0)throw new E(`Logger object is missing required methods: ${h.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:h});this.#t=this.#e.logger}else this.#t={...console,debug:B((...c)=>{o.CEREBRO_OUTPUT_LEVEL===String(re)&&console.debug(...c)},"debug")};this.#d=this.#e.packageVersion,this.#y=this.#e.packageName,this.#u=this.#e.cwd,this.#r="help",this.#a={};const s=n.fs;if(s!==void 0&&(typeof s!="object"||s===null))throw new E("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const l=n.exit;if(l!==void 0&&typeof l!="function")throw new E("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const f=n.env;if(f!==void 0&&(typeof f!="object"||f===null))throw new E("CLI env option must be a record of string keys","INVALID_INPUT",{env:n.env});const a=n.stdin;if(a!==void 0&&typeof a!="string")throw new E("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#w=n.fs,this.#$=n.exit,this.#O=n.env,this.#x=n.stdin??"",this.#n=new Map,this.#i=new Map,this.#o=new Map}setCommandSection(e){return this.#a=e,this}getCommandSection(){return this.#a.header||(this.#a.header=`${this.#f}${this.#d?` v${this.#d}`:""}`),this.#a}setDefaultCommand(e){return this.#r=e,this}get defaultCommand(){return this.#r}addCommand(e){Ge(e,"Command"),Oe(e.name);const n=typeof e.execute=="function",i=typeof e.loader=="function";if(n&&i)throw new E(`Command "${e.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:e.name});if(!n&&!i)throw new E(`Command "${e.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:e.name});e.alias&&(typeof e.alias=="string"?Oe(e.alias):At(e.alias,"Command alias").forEach(a=>Oe(a))),e.argument&&Ge(e.argument,"Command argument"),e.options&&Ge(e.options,"Command options"),e.commandPath&&(At(e.commandPath,"Command commandPath"),e.commandPath.forEach(a=>{Oe(a)}));const r=xt(e.name,e.commandPath),o=Y(r);if(this.#i.has(o))throw new E(`Command with path "${o}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});const s=Array.isArray(e.commandPath)&&e.commandPath.length>0,l=this.#n.get(e.name),f=l!==void 0&&(l.commandPath===void 0||l.commandPath.length===0);if(!s&&f)throw new E(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const a of e.options)ft(a);if(Yr(e),ds(e),fs(e),e.options&&(e.__conflictingOptions__=e.options.filter(a=>a.conflicts!==void 0),e.__requiredOptions__=e.options.filter(a=>a.required===!0)),s&&l!==void 0)this.#n.set(o,e);else{if(!s&&l!==void 0&&!f){const a=xt(l.name,l.commandPath);this.#n.set(Y(a),l)}this.#n.set(e.name,e)}if(this.#i.set(o,r),this.#o.set(o,e),this.#C(),e.alias!==void 0){const a=typeof e.alias=="string"?[e.alias]:e.alias;for(const c of a){if(J().CEREBRO_OUTPUT_LEVEL===String(re)&&this.#t.debug("adding alias",c),this.#n.has(c))throw new E(`Command alias "${c}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:c,commandName:e.name});this.#n.set(c,e)}}return this}addGlobalOption(e){const n=e,i=new Set($e.map(o=>o.name)),r=new Set($e.map(o=>o.alias).filter(Boolean));if(i.has(n.name))throw new E(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&r.has(n.alias))throw new E(`Cannot add global option with alias "-${n.alias}": it conflicts with a built-in global option alias`,"DUPLICATE_OPTION",{alias:n.alias,optionName:n.name});if(new Set(this.#l.map(o=>o.name)).has(n.name))throw new E(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",ft(n),this.#l.push(n),this}getGlobalOptions(){return this.#N()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#p?this.#p:(this.#p=new ro(this.#t),this.#p.register({description:"Attaches the logger to the toolbox",execute:B(e=>{e.logger=this.#t,e.console=e.logger},"execute"),name:"logger"}),this.#p)}getCliName(){return this.#f}getPackageVersion(){return this.#d}getPackageName(){return this.#y}getCommands(){return this.#n}getCwd(){return this.#u}dispose(){this.#P?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:i=!0,...r}=e;if(!this.#n.has("help")){const{default:d}=await import("../packem_chunks/help-command.js");this.addCommand(new d(this.#n))}const o=this.#E(),s=this.#i;this.#L();const l=this.#b();let f,a=[...l];const c=Dt(),h=Bt(),p=Ae();this.#t.debug(`process.execPath: ${c}`),this.#t.debug(`process.execArgv: ${h.join(" ")}`),this.#t.debug(`process.argv: ${p.join(" ")}`);const m=Xr(s,[...l]);if(m.commandPath)f=m.commandPath,a=m.argv;else{if(l.length>1&&l[0]&&l[1]&&!He(l[0])&&!He(l[1])){const g=[];let y=0;for(;y<l.length;){const P=l[y];if(!P||He(P))break;g.push(P),y+=1}const O=Y(g);if(g[0]&&!o.includes(g[0])){const P=this.#s(),V=Q(O,P);throw new Z(O,V)}}let d;try{d=go([null,...o],[...l])}catch(g){if(g instanceof Error&&g.name==="INVALID_COMMAND"&&"command"in g){const y=g.command,O=this.#s(),P=Q(y,O);throw new Z(y,P)}throw g}d.command&&(f=[d.command],a=d.argv)}if(!f)if(this.#r)f=[this.#r];else{const d=this.#s();throw new Z("",d)}const u=Y(f),v=this.#i.get(u);let w;if(v){if(w=this.#o.get(u),!w||Y(v)!==u){const d=this.#s(),g=Q(u,d);throw new Z(u,g)}}else{const d=f.at(-1);if(w=d?this.#n.get(d):void 0,!w){const g=this.#s(),y=Q(u,g);throw new Z(u,y)}}if(typeof w.execute!="function"&&typeof w.loader!="function")return this.#t.error(`Command "${w.name}" has no function to execute.`),i?q(1):void 0;const b=a;let $,A;try{({commandArgs:$,toolbox:A}=this.#j(w,b,r,u))}catch(d){if(this.#t.error(d),i)return q(1);throw d}const N=this.getPluginManager();try{!this.#h&&N.hasPlugins()&&(await N.init({cli:this,cwd:this.#u,logger:this.#t}),this.#h=!0),await N.executeLifecycle("execute",A),await N.executeLifecycle("beforeCommand",A);let d;const g=$.global;if(g?.help){const y=this.#n.get("help");if(!y)throw new E("Help command not found","COMMAND_NOT_FOUND");d=await oe(y,A,$)}else if(g?.version??g?.V){const y=this.#n.get("version");if(!y)throw new E("Version command not found","COMMAND_NOT_FOUND");d=await oe(y,A,$)}else d=await oe(w,A,$);return await N.executeLifecycle("afterCommand",A,d),i?q(0):void 0}catch(d){throw await N.executeErrorHandlers(d,A),d}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:i=[],...r}=n;Ne(e,"Command name");const o=e.split(" ").filter(Boolean),s=Y(o),l=this.#i.get(s)?this.#o.get(s):this.#n.get(e);if(!l){const p=this.#s(),m=Q(s||e,p);throw new Z(e,m)}if(typeof l.execute!="function"&&typeof l.loader!="function")throw new E(`Command "${l.name}" has no function to execute`,"INVALID_COMMAND",{commandName:l.name});const f=[...Et(i,!1)];this.#t.debug(`running command '${e}' programmatically with args: ${f.join(", ")}`);const{commandArgs:a,toolbox:c}=this.#j(l,f,r,s||e),h=this.getPluginManager();try{!this.#h&&h.hasPlugins()&&(await h.init({cli:this,cwd:this.#u,logger:this.#t}),this.#h=!0),await h.executeLifecycle("execute",c),await h.executeLifecycle("beforeCommand",c);let p;const m=a.global;if(m?.help){const u=this.#n.get("help");if(!u)throw new E("Help command not found","COMMAND_NOT_FOUND");p=await oe(u,c,a)}else if(m?.version??m?.V){const u=this.#n.get("version");if(!u)throw new E("Version command not found","COMMAND_NOT_FOUND");p=await oe(u,c,a)}else p=await oe(l,c,a);return await h.executeLifecycle("afterCommand",c,p),p}catch(p){throw await h.executeErrorHandlers(p,c),p}}clone(e){const n={...this.#e,...e},i=new On(this.#f,n);for(const[r,o]of this.#n)i.#n.set(r,o);for(const[r,o]of this.#i)i.#i.set(r,[...o]);for(const[r,o]of this.#o)i.#o.set(r,o);for(const r of this.#l)i.#l.push(r);return i.#r=this.#r,i.#a={...this.#a},i.#C(),i}async getAction(e){Ne(e,"Command name");const n=e.split(" ").filter(Boolean),i=Y(n),r=this.#i.get(i)?this.#o.get(i):this.#n.get(e);if(!r){const o=this.#s(),s=Q(i||e,o);throw new Z(e,s)}if(typeof r.execute=="function")return r.execute;if(typeof r.loader=="function")return cn(r);throw new E(`Command "${r.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:r.name})}};var Vs=Object.defineProperty,Bs=j((t,e)=>Vs(t,"name",{value:e,configurable:!0}),"e$1"),Ds=Object.defineProperty,Rs=Bs((t,e)=>Ds(t,"name",{value:e,configurable:!0}),"o"),zs=Object.defineProperty,Fs=Rs((t,e)=>zs(t,"name",{value:e,configurable:!0}),"t");const kc=Fs((t,e)=>new Us(t,e),"createCerebro");var Ws=Object.defineProperty,qs=j((t,e)=>Ws(t,"name",{value:e,configurable:!0}),"r$1"),Gs=Object.defineProperty,Hs=qs((t,e)=>Gs(t,"name",{value:e,configurable:!0}),"r"),Js=Object.defineProperty,Ks=Hs((t,e)=>Js(t,"name",{value:e,configurable:!0}),"o");const _c=Ks(()=>{try{const t=require("node:module");if(typeof t.enableCompileCache=="function"){t.enableCompileCache();return}}catch{}try{require("v8-compile-cache")}catch{}},"enableCompileCache");var Zs=Object.defineProperty,Ys=j((t,e)=>Zs(t,"name",{value:e,configurable:!0}),"u$2"),Qs=Object.defineProperty,xn=Ys((t,e)=>Qs(t,"name",{value:e,configurable:!0}),"p");const Xs=Ke(import.meta.url),me=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Pn=xn(t=>{if(typeof me<"u"&&me.versions&&me.versions.node){const[e,n]=me.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return me.getBuiltinModule(t)}return Xs(t)},"__cjs_getBuiltinModule"),{execFileSync:el}=Pn("node:child_process"),{totalmem:tl}=Pn("node:os");var nl=Object.defineProperty,Me=xn((t,e)=>nl(t,"name",{value:e,configurable:!0}),"r");const il=/--max-old-space-size=(\d+)/,ol=/--max-semi-space-size=(\d+)/,rl=Me(t=>Math.floor(tl()/1024/1024*t),"getDefaultMaxOldSpaceSize"),al=Me(t=>t<=512?4:t<=1024?8:t<=2048?16:t<=4096?32:t<=8192?64:Math.floor(Math.log2(t))*8,"getSemiSpaceSize"),Nt=Me((t,e)=>{for(const n of e){const i=t.exec(n);if(i)return Number.parseInt(i[1],10)}},"extractFlag"),Lc=Me(t=>{const e=t?.maxOldSpacePercent??.75,n=[...Bt()],i=[...Ae()],r=Nt(il,n),o=Nt(ol,n);if(r!==void 0&&o!==void 0)return;const s=r??rl(e),l=o??al(s),f=[];if(r===void 0&&f.push(`--max-old-space-size=${String(s)}`),o===void 0&&f.push(`--max-semi-space-size=${String(l)}`),f.length!==0)try{el(Dt(),[...f,...n,...i.slice(1)],{env:J(),stdio:"inherit"}),q(0)}catch(a){const c=a.status;q(typeof c=="number"?c:1)}},"applyHeapTuning");var sl=Object.defineProperty,ll=j((t,e)=>sl(t,"name",{value:e,configurable:!0}),"T"),cl=Object.defineProperty,Ue=ll((t,e)=>cl(t,"name",{value:e,configurable:!0}),"N");const ul=Ke(import.meta.url),ge=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,pl=Ue(t=>{if(typeof ge<"u"&&ge.versions&&ge.versions.node){const[e,n]=ge.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ge.getBuiltinModule(t)}return ul(t)},"__cjs_getBuiltinModule"),{createRequire:fl}=pl("node:module");var dl=Object.defineProperty,hl=Ue((t,e)=>dl(t,"name",{value:e,configurable:!0}),"A$2"),ml=Object.defineProperty,Qe=hl((t,e)=>ml(t,"name",{value:e,configurable:!0}),"$"),gl=Object.defineProperty,vl=Qe((t,e)=>gl(t,"name",{value:e,configurable:!0}),"r$1");const bl=vl(t=>t.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
7
+ `),"normalizeLF"),yl=globalThis.process??Object.create(null),Ct={versions:{}},jt=new Proxy(yl,{get(t,e){if(e in t)return t[e];if(e in Ct)return Ct[e]}});var wl=Object.defineProperty,$l=Qe((t,e)=>wl(t,"name",{value:e,configurable:!0}),"b");const Ol=$l((t,e,n,i)=>{const r={column:0,line:-1,...t.start},o={...r,...t.end},s=r.line,l=r.column,f=o.line,a=o.column;let c=Math.max(s-(n+1),0),h=Math.min(e.length,f+i);s===-1&&(c=0),f===-1&&(h=e.length);const p=f-s,m={};if(p)for(let u=0;u<=p;u++){const v=u+s;if(!l)m[v]=!0;else if(u===0){const w=e[v-1]?.length;m[v]=[l,(w??0)-l+1]}else if(u===p)m[v]=[0,a];else{const w=e[v-u]?.length;m[v]=[0,w]}}else l===a?m[s]=l?[l,0]:!0:m[s]=[l,(a??0)-(l??0)];return{end:h,markerLines:m,start:c}},"getMarkerLines");var xl=Object.defineProperty,xe=Qe((t,e)=>xl(t,"name",{value:e,configurable:!0}),"t");const Pl=jt.platform==="win32"&&!jt.env?.WT_SESSION?">":"❯",Al=xe((t,e,n)=>{const i={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,tabWidth:4,...n,color:{gutter:xe(u=>u,"gutter"),marker:xe(u=>u,"marker"),message:xe(u=>u,"message"),...n?.color}},r=typeof e.start.column=="number";let o=bl(t).split(`
8
+ `);typeof i.tabWidth=="number"&&(o=o.map(u=>u.replaceAll(" "," ".repeat(i.tabWidth))));const{end:s,markerLines:l,start:f}=Ol(e,o,i.linesAbove,i.linesBelow),a=String(s).length,{gutter:c,marker:h,message:p}=i.color;let m=o.slice(f,s).map((u,v)=>{const w=f+1+v,b=l[w],$=` ${String(w)}`.slice(-a),A=!l[w+1],N=` ${$}${i.showGutter?" |":""}`;if(b){let d="";if(Array.isArray(b)){const g=u.replaceAll(/[^\t]/g," ").slice(0,Math.max(b[0]-1,0)),y=b[1]||1;d=[`
9
+ `,i.prefix+c(N.replaceAll(/\d/g," "))," ",g,h("^").repeat(y)].join(""),A&&i.message&&(d+=` ${p(i.message)}`)}return[i.prefix+h(Pl),c(N),u.length>0?` ${u}`:"",d].join("")}return`${i.prefix} ${c(N)}${u.length>0?` ${u}`:""}`}).join(`
10
+ `);return i.message&&!r&&(m=`${i.prefix+" ".repeat(a+1)+i.message}
11
+ ${m}`),m},"codeFrame");var El=Object.defineProperty,Nl=Ue((t,e)=>El(t,"name",{value:e,configurable:!0}),"x$1"),Cl=Object.defineProperty,jl=Nl((t,e)=>Cl(t,"name",{value:e,configurable:!0}),"x"),kl=Object.defineProperty,G=jl((t,e)=>kl(t,"name",{value:e,configurable:!0}),"u");const ee=G((t,...e)=>{process.env.DEBUG&&process.env.DEBUG==="true"&&console.debug(`error:parse-stacktrace: ${t}`,...e)},"debugLog"),te="<unknown>",_l=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ll=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,Tl=/(.*?):(\d+):(\d+)(?:\s<-\s.+:\d+:\d+)?/,Il=/eval\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*<anonymous>?:(\d+)?:(\d+)/,Sl=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,Ml=/in\s(.*)\s\(at\s(.+)\)\sat/,Ul=/^(?:.*@)?(.*):(\d+):(\d+)$/,Vl=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Bl=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Dl=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,kt=/\(error: (.*)\)/,Rl=/at\s/,zl=/^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/,Fl=/\S*(?:Error: |AggregateError:)/,An=/^Anonymous function$/,Wl=/^\s*in\s.*/,ql=/^.*?\s*at\s.*/,Gl=/^.*?\s*@.*|\[native code\]/,En=G((t,e)=>{const n=t.includes("safari-extension"),i=t.includes("safari-web-extension");return n||i?[t.includes("@")?t.split("@")[0]:te,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]},"extractSafariExtensionDetails"),Nn=G((t,e)=>{const n=Tl.exec(e);n&&(t.file=n[1],t.line=+n[2],t.column=+n[3])},"parseMapped"),Hl=G(t=>{const e=Ml.exec(t);if(e){ee(`parse nested node error stack line: "${t}"`,`found: ${JSON.stringify(e)}`);const i=e[2].split(":");return{column:i[2]?+i[2]:void 0,file:i[0],line:i[1]?+i[1]:void 0,methodName:e[1]??te,raw:t,type:void 0}}const n=Sl.exec(t);if(n){ee(`parse node error stack line: "${t}"`,`found: ${JSON.stringify(n)}`);const i={column:n[4]?+n[4]:void 0,file:n[2]?n[2].replace(Rl,""):void 0,line:n[3]?+n[3]:void 0,methodName:n[1]??te,raw:t,type:t.startsWith("internal")?"internal":void 0};return Nn(i,`${n[2]}:${n[3]}:${n[4]}`),i}},"parseNode"),Jl=G(t=>{const e=_l.exec(t);if(e){ee(`parse chrome error stack line: "${t}"`,`found: ${JSON.stringify(e)}`);const n=e[2]?.startsWith("native"),i=e[2]?.startsWith("eval")||e[1]?.startsWith("eval");let r,o;if(i){const a=Ll.exec(t);if(a){const c=zl.exec(a[1]);c?(e[2]=c[4]??c[1],e[3]=c[5]??c[2],e[4]=c[3]):a[2]&&(e[2]=a[1]),a[2]&&(r={column:a[4]?+a[4]:void 0,file:a[2],line:a[3]?+a[3]:void 0,methodName:"eval",raw:t,type:"eval"})}else{const c=Il.exec(t);c&&(o={column:c[4]?+c[4]:void 0,file:c[2],line:c[3]?+c[3]:void 0},r={column:c[6]?+c[6]:void 0,file:c[1],line:c[5]?+c[5]:void 0,methodName:"eval",raw:c[0],type:"eval"})}}const[s,l]=En(e[1]?e[1].replace(An,"<anonymous>"):te,e[2]),f={column:e[4]?+e[4]:void 0,evalOrigin:r,file:l,line:e[3]?+e[3]:void 0,methodName:s,raw:t,type:i?"eval":n?"native":void 0};return o?(f.column=o.column,f.file=o.file,f.line=o.line):Nn(f,`${l}:${e[3]}:${e[4]}`),f}},"parseChromium"),Kl=G((t,e)=>{const n=Vl.exec(t);if(n){ee(`parse gecko error stack line: "${t}"`,`found: ${JSON.stringify(n)}`);const i=n[3]?.includes(" > eval"),r=i&&n[3]&&Bl.exec(n[3]);let o;i&&r&&(n[3]=r[1],o={column:n[5]?+n[5]:void 0,file:n[3],line:n[4]?+n[4]:void 0,methodName:"eval",raw:t,type:"eval"},n[4]=r[2]);const[s,l]=En(n[1]?n[1].replace(An,"<anonymous>"):te,n[3]);let f;(e?.type==="safari"||!i&&e?.type==="firefox")&&e.column?f=e.column:!i&&n[5]&&(f=+n[5]);let a;return(e?.type==="safari"||!i&&e?.type==="firefox")&&e.line?a=e.line:n[4]&&(a=+n[4]),{column:f,evalOrigin:o,file:l,line:a,methodName:s,raw:t,type:i?"eval":l.includes("[native code]")?"native":void 0}}},"parseGecko"),Zl=G((t,e)=>{const n=Dl.exec(t);if(!(n&&n[2].includes(" > eval"))&&n)return ee(`parse firefox error stack line: "${t}"`,`found: ${JSON.stringify(n)}`),{column:n[4]?+n[4]:e?.column??void 0,file:n[2],line:n[3]?+n[3]:e?.line??void 0,methodName:n[1]||te,raw:t,type:void 0}},"parseFirefox"),Yl=G(t=>{const e=Ul.exec(t);if(e)return ee(`parse react android native error stack line: "${t}"`,`found: ${JSON.stringify(e)}`),{column:e[3]?+e[3]:void 0,file:e[1],line:e[2]?+e[2]:void 0,methodName:te,raw:t,type:void 0}},"parseReactAndroidNative"),Cn=G((t,{filter:e,frameLimit:n=50}={})=>{const i=t;let r=(typeof i.stacktrace=="string"?i.stacktrace:t.stack??"").split(`
12
+ `).map(o=>(kt.test(o)?o.replace(kt,"$1"):o).trim()).filter(o=>!Fl.test(o)&&o!=="eval code");return e&&(r=r.filter(o=>e(o))),r=r.slice(0,n),r.reduce((o,s,l)=>{if(!s||s.length>1024)return o;let f;if(Wl.test(s))f=Hl(s);else if(ql.test(s))f=Jl(s);else if(Gl.test(s)){let a;if(l===0){const c=t,h=c.columnNumber,p=c.lineNumber,m=c.line,u=c.column;h||p?a={column:h,line:p,type:"firefox"}:(m||u)&&(a={column:u,line:m,type:"safari"})}f=Zl(s,a)??Kl(s,a)}else f=Yl(s);return f?o.push(f):ee(`parse error stack line: "${s}"`,"not parser found"),o},[])},"parseStacktrace");var Ql=Object.defineProperty,Xl=Ue((t,e)=>Ql(t,"name",{value:e,configurable:!0}),"p"),ec=Object.defineProperty,jn=Xl((t,e)=>ec(t,"name",{value:e,configurable:!0}),"m");const tc=fl(import.meta.url),ae=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Xe=jn(t=>{if(typeof ae<"u"&&ae.versions&&ae.versions.node){const[e,n]=ae.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ae.getBuiltinModule(t)}return tc(t)},"__cjs_getBuiltinModule"),{existsSync:nc,readFileSync:ic}=Xe("node:fs"),{relative:oc}=Xe("node:path"),{cwd:rc}=ae,{fileURLToPath:ac}=Xe("node:url");var sc=Object.defineProperty,_=jn((t,e)=>sc(t,"name",{value:e,configurable:!0}),"o");const pe=_((t,e,n)=>n===0?t:e===" "?t+" ".repeat(n):t+" ".repeat(e*n),"getPrefix"),lc=_((t,e)=>{const n=t.replace("async file:","file:");return oc(e,n.startsWith("file:")?ac(n):n)},"getRelativePath"),cc=_((t,e,n)=>{if(e)return n.title(t.message);const i=t.message?`: ${t.message}`:"";return n.title(t.name+i)},"getTitleText"),kn=_((t,{color:e,hideErrorTitle:n,indentation:i,prefix:r},o)=>`${pe(r,i,o)}${cc(t,n,e)}
13
+ `,"getMessage"),_n=_((t,{color:e,indentation:n,prefix:i},r)=>{if(t.hint===void 0)return;const o=pe(i,n,r);let s="";if(Array.isArray(t.hint))for(const l of t.hint)s+=`${o+l}
14
+ `;else s+=o+t.hint;return e.hint(s)},"getHint"),et=_((t,{color:e,cwd:n,displayShortPath:i,indentation:r,prefix:o},s=0)=>{const l=i?lc(t.file,n):t.file,{fileLine:f,method:a}=e;return`${pe(o,r,s)}at ${t.methodName?`${a(t.methodName)} `:""}${f(l)}:${f(t.line?.toString()??"")}`},"getMainFrame"),Ln=_((t,{color:e,indentation:n,linesAbove:i,linesBelow:r,prefix:o,showGutter:s,showLineNumbers:l,tabWidth:f},a)=>{if(t.file===void 0)return;const c=t.file.replace("file://","");if(!nc(c))return;const h=ic(c,"utf8");return Al(h,{start:{column:t.column,line:t.line}},{color:e,linesAbove:i,linesBelow:r,prefix:pe(o,n,a),showGutter:s,showLineNumbers:l,tabWidth:f})},"getCode"),Tn=_((t,e,n)=>{if(t.errors.length===0)return;let i=`${pe(e.prefix,e.indentation,n)}Errors:
15
+
16
+ `,r=!0;for(const o of t.errors)r?r=!1:i+=`
17
+
18
+ `,i+=Sn(o,{...e,framesMaxLimit:1,hideErrorCodeView:e.hideErrorErrorsCodeView},n+1);return`
19
+ ${i}`},"getErrors"),In=_((t,e,n)=>{let i=`${pe(e.prefix,e.indentation,n)}Caused by:
20
+
21
+ `;const r=t.cause;i+=kn(r,e,n);const o=Cn(r).shift(),s=_n(r,e,n);if(s&&(i+=`${s}
22
+ `),o&&(i+=et(o,e,n),!e.hideErrorCauseCodeView)){const l=Ln(o,e,n);l!==void 0&&(i+=`
23
+ ${l}`)}if(r.cause)i+=`
24
+ ${In(r,e,n+1)}`;else if(r instanceof AggregateError){const l=Tn(r,e,n);l!==void 0&&(i+=`
25
+ ${l}`)}return`
26
+ ${i}`},"getCause"),uc=_((t,e)=>(t.length>0?`
27
+ `:"")+t.map(n=>et(n,e)).join(`
28
+ `),"getStacktrace"),Sn=_((t,e,n)=>{const i={cwd:rc(),displayShortPath:!1,filterStacktrace:void 0,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...e,color:{fileLine:_(s=>s,"fileLine"),gutter:_(s=>s,"gutter"),hint:_(s=>s,"hint"),marker:_(s=>s,"marker"),message:_(s=>s,"message"),method:_(s=>s,"method"),title:_(s=>s,"title"),...e.color}},r=Cn(t,{filter:e.filterStacktrace,frameLimit:i.framesMaxLimit}),o=r.shift();return[e.hideMessage?void 0:kn(t,i,n),_n(t,i,n),o?et(o,i,n):void 0,o&&!i.hideErrorCodeView?Ln(o,i,n):void 0,t instanceof AggregateError?Tn(t,i,n):void 0,t.cause===void 0?void 0:In(t,i,n),r.length>0?uc(r,i):void 0].filter(Boolean).join(`
29
+ `).replaceAll("\\","/")},"internalRenderError"),pc=_((t,e={})=>{if(e.framesMaxLimit!==void 0&&e.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return Sn(t,e,0)},"renderError");var fc=Object.defineProperty,dc=j((t,e)=>fc(t,"name",{value:e,configurable:!0}),"i$1"),hc=Object.defineProperty,mc=dc((t,e)=>hc(t,"name",{value:e,configurable:!0}),"n"),gc=Object.defineProperty,_t=mc((t,e)=>gc(t,"name",{value:e,configurable:!0}),"n");const Tc=_t((t={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:_t((e,n)=>{const{logger:i,runtime:r}=n,{detailed:o=!1,exitOnError:s=!0,formatter:l,logErrors:f=!0,renderOptions:a={}}=t;if(f)if(l)i.error(l(e));else if(o){const c=r.getCwd(),h=pc(e,{cwd:c,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...a});i.error(h)}else i.error(e);s&&q(1)},"handleError"),version:"1.0.0"}),"errorHandlerPlugin");var vc="1.0.0-alpha.28";const Ic={version:vc};var bc=Object.defineProperty,yc=j((t,e)=>bc(t,"name",{value:e,configurable:!0}),"e");const Sc={argument:{description:"Package to execute (optionally with @version)",name:"package",type:String},description:"Execute a remote package without permanent installation",examples:[["vis dlx create-vite my-app","Scaffold a new project"],["vis dlx typescript@5.5.4 tsc --version","Run specific version"],["vis dlx -p cowsay -p lolcatjs -c 'echo hi | cowsay | lolcatjs'","Multiple packages with shell"],["vis install && vis dlx --offline typescript tsc --version","Hardened: pre-install + offline (no registry fetch on dlx)"]],group:"Run & Execute",loader:yc(()=>import("../packem_chunks/handler9.js"),"loader"),name:"dlx",options:[{alias:"p",description:"Additional packages to install (repeatable)",multiple:!0,name:"package",type:String},{alias:"c",defaultValue:!1,description:"Execute within shell environment",name:"shell-mode",type:Boolean},{alias:"s",defaultValue:!1,description:"Suppress output except command results",name:"silent",type:Boolean},{defaultValue:!1,description:"Resolve from local store only — fail rather than fetch from the registry. Pair with `vis install` for hardened npx-style workflows.",name:"offline",type:Boolean}]};export{Lc as N,kc as T,Sc as a,J as b,Ac as c,E as d,Ec as f,_c as i,Ic as m,K as n,Tc as w};
@@ -1 +1 @@
1
- var D=Object.defineProperty;var v=(t,e)=>D(t,"name",{value:e,configurable:!0});import{m as w,D as C,g as S,f as A}from"./provenance-BuiEsWbI.js";import{L as m}from"../packem_chunks/bin.js";import{x as W}from"./build-scripts-3E2pmscY.js";import{n as b}from"./license-zZU7aavK.js";import{a as j,C as F,$ as U}from"./readFileSync-CGmzMUF2-D6rUjGDn.js";import{F as E}from"./lockfile-BG1HvBzH.js";import{L as N}from"./dependency-scan-s2MD0vi-.js";var I=Object.defineProperty,L=v((t,e)=>I(t,"name",{value:e,configurable:!0}),"i");const g={CRITICAL:0,HIGH:1,LOW:3,MODERATE:2,UNKNOWN:4},we=L((t,e)=>{const i=g[(t.vulnerability.severity??"UNKNOWN").toUpperCase()]??4,n=g[(e.vulnerability.severity??"UNKNOWN").toUpperCase()]??4;return i-n||t.packageName.localeCompare(e.packageName)||t.packageVersion.localeCompare(e.packageVersion)},"compareFindingsForDisplay"),M=L((t,e)=>{const i=g[e.toUpperCase()]??2;return(g[t.toUpperCase()]??4)<=i},"severityPassesFilter"),P=["firstSeen","installScripts","license","malware","publisherChange","score","unexpectedDeps","vulnerability"];var V=Object.defineProperty,R=v((t,e)=>V(t,"name",{value:e,configurable:!0}),"r");const $=6e4,_=R((t,e,i)=>{for(const n of i)if(n===t||n===`${t}@${e}`||n.endsWith("*")&&t.startsWith(n.slice(0,-1)))return!0;return!1},"isExcluded"),T=R(async(t,e)=>{const i=e.security?.policies?.firstSeen;if(i?.minutes===void 0||i.minutes<=0)return[];const{minutes:n}=i,a=i.exclude??[],o=e.security?.acceptedRisks,c=n*$,s=Date.now();return(await w(t.packages,C,async r=>{if(_(r.name,r.version,a))return;const l=await S(r.name,{workspaceRoot:t.workspaceRoot});if(l===void 0)return;const p=l.time?.[r.version];if(p===void 0)return;const u=Date.parse(p);if(Number.isNaN(u))return;const f=s-u;if(f>=c)return;const k=Math.max(0,Math.floor(f/$));return{acceptedRisk:m(r.name,r.version,o,"firstSeen"),data:{ageMinutes:k,minimumMinutes:n,publishedAt:p},packageName:r.name,policy:"firstSeen",reason:`${r.name}@${r.version} was published ${String(k)} min ago — below the ${String(n)} min firstSeen cooldown.`,severity:"block",version:r.version}})).filter(r=>r!==void 0)},"evaluateFirstSeenPolicy");var K=Object.defineProperty,H=v((t,e)=>K(t,"name",{value:e,configurable:!0}),"n");const q=H((t,e)=>{const i=e.security?.policies?.installScripts;if(!i)return[];const n=i.allow??{},a=i.strict===!0;if(!a&&Object.keys(n).length===0)return[];const o=W(t.workspaceRoot,n,{pinVersions:e.security?.pinVersions===!0});if(o.unapproved.length===0)return[];const c=e.security?.acceptedRisks,s=a?"block":"warn";return o.unapproved.map(r=>({acceptedRisk:m(r.name,r.version??"*",c,"installScripts"),data:{hooks:r.hooks},packageName:r.name,policy:"installScripts",reason:`${r.name}${r.version?`@${r.version}`:""} declares unapproved build script(s): ${r.hooks.join(", ")}`,severity:s,version:r.version??"*"}))},"evaluateInstallScriptsPolicy");var z=Object.defineProperty,y=v((t,e)=>z(t,"name",{value:e,configurable:!0}),"a");const Y=new Set(["AND","OR"]),B=y(t=>{const e=t.replaceAll("("," ").replaceAll(")"," ").split(/\s+/).map(a=>a.trim()).filter(a=>a.length>0),i=[];let n=!1;for(const a of e){const o=a.toUpperCase();if(n){n=!1;continue}if(o==="WITH"){n=!0;continue}if(Y.has(o))continue;const c=a.endsWith("+"),s=c?a.slice(0,-1):a,r=b(s)??s;i.push(r),c&&i.push(`${r}-or-later`)}return i},"extractSpdxLeaves"),G=y(t=>{if(typeof t.license=="string"){const e=t.license.trim();return e.length>0?e:void 0}if(t.license&&typeof t.license=="object"&&typeof t.license.type=="string"){const e=t.license.type.trim();if(e.length>0)return e}if(Array.isArray(t.licenses)&&t.licenses.length>0){const e=t.licenses.map(i=>i&&typeof i.type=="string"?i.type.trim():"").filter(i=>i.length>0);if(e.length>0)return e.length===1?e[0]:`(${e.join(" OR ")})`}},"declaredLicense"),J=y((t,e)=>{if(e.length===0)return;const i=new Set(e.map(n=>b(n)??n).map(n=>n.toLowerCase()));for(const n of t)if(i.has(n.toLowerCase()))return n},"findDeniedLeaf"),Q=y((t,e)=>{if(e.length===0)return;const i=new Set(e.map(n=>b(n)??n).map(n=>n.toLowerCase()));for(const n of t)if(!i.has(n.toLowerCase()))return n},"findUnallowedLeaf"),X=y((t,e)=>{const i=e.security?.policies?.license;if(!i)return[];const n=i.allow??[],a=i.deny??[];if(n.length===0&&a.length===0)return[];const o=e.security?.acceptedRisks,c=[];for(const s of t.packages){const r=t.manifestData?.get(`${s.name}@${s.version}`),l=r?G(r):void 0;if(!l){n.length>0&&c.push({acceptedRisk:m(s.name,s.version,o,"license"),data:{declaredLicense:null},packageName:s.name,policy:"license",reason:`${s.name}@${s.version} declares no license; allow-list mode requires one of: ${n.join(", ")}`,severity:"block",version:s.version});continue}const p=B(l),u=J(p,a);if(u){c.push({acceptedRisk:m(s.name,s.version,o,"license"),data:{declaredLicense:l,deniedLicense:u},packageName:s.name,policy:"license",reason:`${s.name}@${s.version} uses denied license '${u}' (declared: ${l})`,severity:"block",version:s.version});continue}const f=Q(p,n);f&&c.push({acceptedRisk:m(s.name,s.version,o,"license"),data:{allowList:n,declaredLicense:l,unallowedLicense:f},packageName:s.name,policy:"license",reason:`${s.name}@${s.version} uses license '${f}' which is not on the allow-list (declared: ${l})`,severity:"block",version:s.version})}return c},"evaluateLicensePolicy");var Z=Object.defineProperty,O=v((t,e)=>Z(t,"name",{value:e,configurable:!0}),"c$1");const ee=6e4,te=O((t,e,i)=>{for(const n of i)if(n===t||n===`${t}@${e}`||n.endsWith("*")&&t.startsWith(n.slice(0,-1)))return!0;return!1},"isExcluded"),ie=O(async(t,e)=>{const i=e.security?.policies?.publisherChange;if(i?.mode!=="no-downgrade")return[];const n=i.exclude??[],a=typeof i.ignoreAfter=="number"?i.ignoreAfter*ee:void 0,o=e.security?.acceptedRisks,c=Date.now();return(await w(t.packages,C,async s=>{if(te(s.name,s.version,n))return;const r=await S(s.name,{workspaceRoot:t.workspaceRoot});if(r===void 0)return;if(a!==void 0){const p=r.time?.[s.version],u=p===void 0?Number.NaN:Date.parse(p);if(!Number.isNaN(u)&&c-u>a)return}if(r.versions[s.version]?.dist?.attestations?.provenance!==void 0)return;const l=A(r,s.version);if(l!==void 0)return{acceptedRisk:m(s.name,s.version,o,"publisherChange"),data:{priorVersionWithProvenance:l},packageName:s.name,policy:"publisherChange",reason:`${s.name}@${s.version} dropped the provenance attestation that ${s.name}@${l} carried — publisher trust downgrade.`,severity:"block",version:s.version}})).filter(s=>s!==void 0)},"evaluatePublisherChangePolicy");var ne=Object.defineProperty,h=v((t,e)=>ne(t,"name",{value:e,configurable:!0}),"l$1");const se=h(t=>{for(const e of Object.values(N))for(const i of[e.file,...e.aliases??[]])if(t===i||t.endsWith(`/${i}`)||t.endsWith(`.${i}`))return e.type},"detectLockfileType"),re=h((t,e,i)=>{const n=j(e)?e:F(t,e);let a;try{a=U(n)}catch{return}const o=se(n)??N[i]?.type;if(!o)return;const c=E(a,o);if(c.length===0)return;const s=new Set;for(const r of c)s.add(`${r.name}@${r.version}`);return s},"loadBaselineKeys"),oe=h((t,e)=>{for(const i of e)if(i===t||i.endsWith("*")&&t.startsWith(i.slice(0,-1)))return!0;return!1},"matchesAllowList"),ae=h((t,e)=>{const i=e.security?.policies?.unexpectedDeps;if(!i)return[];const n=i.allow??[],a=i.baselineLockfile;if(n.length===0&&!a)return[];const o=a?re(t.workspaceRoot,a,t.packageManager):void 0,c=e.security?.acceptedRisks,s=[];for(const r of t.packages){const l=n.length===0||oe(r.name,n),p=o?o.has(`${r.name}@${r.version}`):!0;if(l&&p)continue;const u=[],f={};l||(u.push(`not on allow-list (${n.length} entr${n.length===1?"y":"ies"})`),f.allowList=n),!p&&o&&(u.push(`not present in baseline lockfile (${a})`),f.baselineLockfile=a),s.push({acceptedRisk:m(r.name,r.version,c,"unexpectedDeps"),data:f,packageName:r.name,policy:"unexpectedDeps",reason:`${r.name}@${r.version} is unexpected: ${u.join("; ")}`,severity:"block",version:r.version})}return s},"evaluateUnexpectedDepsPolicy");var ce=Object.defineProperty,le=v((t,e)=>ce(t,"name",{value:e,configurable:!0}),"c");const ue=le((t,e)=>{if(!t.osvFindings||t.osvFindings.size===0)return[];const i=e.security?.policies?.vulnerability?.failOn,n=e.security?.acceptedRisks,a=[];for(const o of t.packages){const c=t.osvFindings.get(o.name);if(!(!c||c.length===0))for(const s of c){const r=i?M(s.severity,i)?"block":"warn":"info";a.push({acceptedRisk:m(o.name,o.version,n,"vulnerability"),data:{advisoryId:s.id,aliases:s.aliases??[],cvssScore:s.cvssScore,fixedVersions:s.fixedVersions,severity:s.severity,summary:s.summary},packageName:o.name,policy:"vulnerability",reason:`${s.severity} ${s.id} affects ${o.name}@${o.version}: ${s.summary}`,severity:r,version:o.version})}}return a},"evaluateVulnerabilityPolicy");var pe=Object.defineProperty,d=v((t,e)=>pe(t,"name",{value:e,configurable:!0}),"t");const x=[{evaluate:ue,isConfigured:d(t=>t.security?.policies?.vulnerability!==void 0,"isConfigured"),name:"vulnerability",offlineSupported:!0,surfaces:["audit","doctor"]},{evaluate:X,isConfigured:d(t=>{const e=t.security?.policies?.license;return!!(e&&(e.allow&&e.allow.length>0||e.deny&&e.deny.length>0))},"isConfigured"),name:"license",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:q,isConfigured:d(t=>{const e=t.security?.policies?.installScripts;return!!(e&&(e.allow&&Object.keys(e.allow).length>0||e.strict===!0))},"isConfigured"),name:"installScripts",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:ae,isConfigured:d(t=>{const e=t.security?.policies?.unexpectedDeps;return!!(e&&(e.allow&&e.allow.length>0||typeof e.baselineLockfile=="string"))},"isConfigured"),name:"unexpectedDeps",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:T,isConfigured:d(t=>{const e=t.security?.policies?.firstSeen?.minutes;return typeof e=="number"&&e>0},"isConfigured"),name:"firstSeen",offlineSupported:!1,surfaces:["audit","doctor","install"]},{evaluate:ie,isConfigured:d(t=>t.security?.policies?.publisherChange?.mode==="no-downgrade","isConfigured"),name:"publisherChange",offlineSupported:!1,surfaces:["audit","doctor","install"]}],fe=d((t,e,i)=>x.filter(n=>n.surfaces.includes(t)?i!==void 0?i.has(n.name):n.isConfigured(e):!1),"selectModules"),Ce=d(async(t,e,i)=>{const n=fe(e,i.visConfig,i.enabledPolicies),a=[];for(const o of n){if(t.offline&&!o.offlineSupported){a.push({packageName:"*",policy:o.name,reason:`policy.${o.name} skipped: requires network (--offline)`,severity:"info",version:"*"});continue}try{const c=await o.evaluate(t,i.visConfig);a.push(...c)}catch(c){const s=c instanceof Error?c.message:String(c);a.push({packageName:"*",policy:o.name,reason:`policy.${o.name} failed: ${s}`,severity:"info",version:"*"})}}return a},"evaluatePolicies"),de=(()=>{const t=new Map;for(const e of P)t.set(e.toLowerCase(),e);return t})(),Se=d(()=>x.map(t=>t.name),"getRegisteredPolicyNames"),Ne=d((t,e)=>{if(t===void 0)return;const i=t.trim().toLowerCase();if(i===""||i==="none")return new Set;if(i==="all")return new Set(P);const n=new Set;for(const a of t.split(",").map(o=>o.trim()).filter(o=>o.length>0)){const o=a.replace(/^_+/,"").replaceAll(/_+([a-z])/g,(s,r)=>r.toUpperCase()),c=de.get(o.toLowerCase());c===void 0?e?.(a):n.add(c)}return n},"parsePoliciesFlag");export{we as c,Ce as e,Se as g,Ne as p,M as s};
1
+ var D=Object.defineProperty;var v=(t,e)=>D(t,"name",{value:e,configurable:!0});import{m as w,D as C,g as S,f as A}from"./provenance-DoEp2uOo.js";import{$ as m}from"../packem_chunks/bin.js";import{x as W}from"./build-scripts-D-ysm_bS.js";import{n as $}from"./license-zZU7aavK.js";import{a as j,C as F,$ as U}from"./readFileSync-4c_c6Qey-6SWMDNdw.js";import{S as E}from"./lockfile-CoeFxWAv.js";import{L as N}from"./dependency-scan-B9wTcLxf.js";var I=Object.defineProperty,L=v((t,e)=>I(t,"name",{value:e,configurable:!0}),"i");const g={CRITICAL:0,HIGH:1,LOW:3,MODERATE:2,UNKNOWN:4},we=L((t,e)=>{const i=g[(t.vulnerability.severity??"UNKNOWN").toUpperCase()]??4,n=g[(e.vulnerability.severity??"UNKNOWN").toUpperCase()]??4;return i-n||t.packageName.localeCompare(e.packageName)||t.packageVersion.localeCompare(e.packageVersion)},"compareFindingsForDisplay"),M=L((t,e)=>{const i=g[e.toUpperCase()]??2;return(g[t.toUpperCase()]??4)<=i},"severityPassesFilter"),P=["firstSeen","installScripts","license","malware","publisherChange","score","unexpectedDeps","vulnerability"];var V=Object.defineProperty,R=v((t,e)=>V(t,"name",{value:e,configurable:!0}),"r");const k=6e4,_=R((t,e,i)=>{for(const n of i)if(n===t||n===`${t}@${e}`||n.endsWith("*")&&t.startsWith(n.slice(0,-1)))return!0;return!1},"isExcluded"),T=R(async(t,e)=>{const i=e.security?.policies?.firstSeen;if(i?.minutes===void 0||i.minutes<=0)return[];const{minutes:n}=i,a=i.exclude??[],o=e.security?.acceptedRisks,c=n*k,s=Date.now();return(await w(t.packages,C,async r=>{if(_(r.name,r.version,a))return;const l=await S(r.name,{workspaceRoot:t.workspaceRoot});if(l===void 0)return;const p=l.time?.[r.version];if(p===void 0)return;const u=Date.parse(p);if(Number.isNaN(u))return;const f=s-u;if(f>=c)return;const b=Math.max(0,Math.floor(f/k));return{acceptedRisk:m(r.name,r.version,o,"firstSeen"),data:{ageMinutes:b,minimumMinutes:n,publishedAt:p},packageName:r.name,policy:"firstSeen",reason:`${r.name}@${r.version} was published ${String(b)} min ago — below the ${String(n)} min firstSeen cooldown.`,severity:"block",version:r.version}})).filter(r=>r!==void 0)},"evaluateFirstSeenPolicy");var K=Object.defineProperty,H=v((t,e)=>K(t,"name",{value:e,configurable:!0}),"n");const q=H((t,e)=>{const i=e.security?.policies?.installScripts;if(!i)return[];const n=i.allow??{},a=i.strict===!0;if(!a&&Object.keys(n).length===0)return[];const o=W(t.workspaceRoot,n,{pinVersions:e.security?.pinVersions===!0});if(o.unapproved.length===0)return[];const c=e.security?.acceptedRisks,s=a?"block":"warn";return o.unapproved.map(r=>({acceptedRisk:m(r.name,r.version??"*",c,"installScripts"),data:{hooks:r.hooks},packageName:r.name,policy:"installScripts",reason:`${r.name}${r.version?`@${r.version}`:""} declares unapproved build script(s): ${r.hooks.join(", ")}`,severity:s,version:r.version??"*"}))},"evaluateInstallScriptsPolicy");var z=Object.defineProperty,y=v((t,e)=>z(t,"name",{value:e,configurable:!0}),"a");const Y=new Set(["AND","OR"]),B=y(t=>{const e=t.replaceAll("("," ").replaceAll(")"," ").split(/\s+/).map(a=>a.trim()).filter(a=>a.length>0),i=[];let n=!1;for(const a of e){const o=a.toUpperCase();if(n){n=!1;continue}if(o==="WITH"){n=!0;continue}if(Y.has(o))continue;const c=a.endsWith("+"),s=c?a.slice(0,-1):a,r=$(s)??s;i.push(r),c&&i.push(`${r}-or-later`)}return i},"extractSpdxLeaves"),G=y(t=>{if(typeof t.license=="string"){const e=t.license.trim();return e.length>0?e:void 0}if(t.license&&typeof t.license=="object"&&typeof t.license.type=="string"){const e=t.license.type.trim();if(e.length>0)return e}if(Array.isArray(t.licenses)&&t.licenses.length>0){const e=t.licenses.map(i=>i&&typeof i.type=="string"?i.type.trim():"").filter(i=>i.length>0);if(e.length>0)return e.length===1?e[0]:`(${e.join(" OR ")})`}},"declaredLicense"),J=y((t,e)=>{if(e.length===0)return;const i=new Set(e.map(n=>$(n)??n).map(n=>n.toLowerCase()));for(const n of t)if(i.has(n.toLowerCase()))return n},"findDeniedLeaf"),Q=y((t,e)=>{if(e.length===0)return;const i=new Set(e.map(n=>$(n)??n).map(n=>n.toLowerCase()));for(const n of t)if(!i.has(n.toLowerCase()))return n},"findUnallowedLeaf"),X=y((t,e)=>{const i=e.security?.policies?.license;if(!i)return[];const n=i.allow??[],a=i.deny??[];if(n.length===0&&a.length===0)return[];const o=e.security?.acceptedRisks,c=[];for(const s of t.packages){const r=t.manifestData?.get(`${s.name}@${s.version}`),l=r?G(r):void 0;if(!l){n.length>0&&c.push({acceptedRisk:m(s.name,s.version,o,"license"),data:{declaredLicense:null},packageName:s.name,policy:"license",reason:`${s.name}@${s.version} declares no license; allow-list mode requires one of: ${n.join(", ")}`,severity:"block",version:s.version});continue}const p=B(l),u=J(p,a);if(u){c.push({acceptedRisk:m(s.name,s.version,o,"license"),data:{declaredLicense:l,deniedLicense:u},packageName:s.name,policy:"license",reason:`${s.name}@${s.version} uses denied license '${u}' (declared: ${l})`,severity:"block",version:s.version});continue}const f=Q(p,n);f&&c.push({acceptedRisk:m(s.name,s.version,o,"license"),data:{allowList:n,declaredLicense:l,unallowedLicense:f},packageName:s.name,policy:"license",reason:`${s.name}@${s.version} uses license '${f}' which is not on the allow-list (declared: ${l})`,severity:"block",version:s.version})}return c},"evaluateLicensePolicy");var Z=Object.defineProperty,O=v((t,e)=>Z(t,"name",{value:e,configurable:!0}),"c$1");const ee=6e4,te=O((t,e,i)=>{for(const n of i)if(n===t||n===`${t}@${e}`||n.endsWith("*")&&t.startsWith(n.slice(0,-1)))return!0;return!1},"isExcluded"),ie=O(async(t,e)=>{const i=e.security?.policies?.publisherChange;if(i?.mode!=="no-downgrade")return[];const n=i.exclude??[],a=typeof i.ignoreAfter=="number"?i.ignoreAfter*ee:void 0,o=e.security?.acceptedRisks,c=Date.now();return(await w(t.packages,C,async s=>{if(te(s.name,s.version,n))return;const r=await S(s.name,{workspaceRoot:t.workspaceRoot});if(r===void 0)return;if(a!==void 0){const p=r.time?.[s.version],u=p===void 0?Number.NaN:Date.parse(p);if(!Number.isNaN(u)&&c-u>a)return}if(r.versions[s.version]?.dist?.attestations?.provenance!==void 0)return;const l=A(r,s.version);if(l!==void 0)return{acceptedRisk:m(s.name,s.version,o,"publisherChange"),data:{priorVersionWithProvenance:l},packageName:s.name,policy:"publisherChange",reason:`${s.name}@${s.version} dropped the provenance attestation that ${s.name}@${l} carried — publisher trust downgrade.`,severity:"block",version:s.version}})).filter(s=>s!==void 0)},"evaluatePublisherChangePolicy");var ne=Object.defineProperty,h=v((t,e)=>ne(t,"name",{value:e,configurable:!0}),"l$1");const se=h(t=>{for(const e of Object.values(N))for(const i of[e.file,...e.aliases??[]])if(t===i||t.endsWith(`/${i}`)||t.endsWith(`.${i}`))return e.type},"detectLockfileType"),re=h((t,e,i)=>{const n=j(e)?e:F(t,e);let a;try{a=U(n)}catch{return}const o=se(n)??N[i]?.type;if(!o)return;const c=E(a,o);if(c.length===0)return;const s=new Set;for(const r of c)s.add(`${r.name}@${r.version}`);return s},"loadBaselineKeys"),oe=h((t,e)=>{for(const i of e)if(i===t||i.endsWith("*")&&t.startsWith(i.slice(0,-1)))return!0;return!1},"matchesAllowList"),ae=h((t,e)=>{const i=e.security?.policies?.unexpectedDeps;if(!i)return[];const n=i.allow??[],a=i.baselineLockfile;if(n.length===0&&!a)return[];const o=a?re(t.workspaceRoot,a,t.packageManager):void 0,c=e.security?.acceptedRisks,s=[];for(const r of t.packages){const l=n.length===0||oe(r.name,n),p=o?o.has(`${r.name}@${r.version}`):!0;if(l&&p)continue;const u=[],f={};l||(u.push(`not on allow-list (${n.length} entr${n.length===1?"y":"ies"})`),f.allowList=n),!p&&o&&(u.push(`not present in baseline lockfile (${a})`),f.baselineLockfile=a),s.push({acceptedRisk:m(r.name,r.version,c,"unexpectedDeps"),data:f,packageName:r.name,policy:"unexpectedDeps",reason:`${r.name}@${r.version} is unexpected: ${u.join("; ")}`,severity:"block",version:r.version})}return s},"evaluateUnexpectedDepsPolicy");var ce=Object.defineProperty,le=v((t,e)=>ce(t,"name",{value:e,configurable:!0}),"c");const ue=le((t,e)=>{if(!t.osvFindings||t.osvFindings.size===0)return[];const i=e.security?.policies?.vulnerability?.failOn,n=e.security?.acceptedRisks,a=[];for(const o of t.packages){const c=t.osvFindings.get(o.name);if(!(!c||c.length===0))for(const s of c){const r=i?M(s.severity,i)?"block":"warn":"info";a.push({acceptedRisk:m(o.name,o.version,n,"vulnerability"),data:{advisoryId:s.id,aliases:s.aliases??[],cvssScore:s.cvssScore,fixedVersions:s.fixedVersions,severity:s.severity,summary:s.summary},packageName:o.name,policy:"vulnerability",reason:`${s.severity} ${s.id} affects ${o.name}@${o.version}: ${s.summary}`,severity:r,version:o.version})}}return a},"evaluateVulnerabilityPolicy");var pe=Object.defineProperty,d=v((t,e)=>pe(t,"name",{value:e,configurable:!0}),"t");const x=[{evaluate:ue,isConfigured:d(t=>t.security?.policies?.vulnerability!==void 0,"isConfigured"),name:"vulnerability",offlineSupported:!0,surfaces:["audit","doctor"]},{evaluate:X,isConfigured:d(t=>{const e=t.security?.policies?.license;return!!(e&&(e.allow&&e.allow.length>0||e.deny&&e.deny.length>0))},"isConfigured"),name:"license",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:q,isConfigured:d(t=>{const e=t.security?.policies?.installScripts;return!!(e&&(e.allow&&Object.keys(e.allow).length>0||e.strict===!0))},"isConfigured"),name:"installScripts",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:ae,isConfigured:d(t=>{const e=t.security?.policies?.unexpectedDeps;return!!(e&&(e.allow&&e.allow.length>0||typeof e.baselineLockfile=="string"))},"isConfigured"),name:"unexpectedDeps",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:T,isConfigured:d(t=>{const e=t.security?.policies?.firstSeen?.minutes;return typeof e=="number"&&e>0},"isConfigured"),name:"firstSeen",offlineSupported:!1,surfaces:["audit","doctor","install"]},{evaluate:ie,isConfigured:d(t=>t.security?.policies?.publisherChange?.mode==="no-downgrade","isConfigured"),name:"publisherChange",offlineSupported:!1,surfaces:["audit","doctor","install"]}],fe=d((t,e,i)=>x.filter(n=>n.surfaces.includes(t)?i!==void 0?i.has(n.name):n.isConfigured(e):!1),"selectModules"),Ce=d(async(t,e,i)=>{const n=fe(e,i.visConfig,i.enabledPolicies),a=[];for(const o of n){if(t.offline&&!o.offlineSupported){a.push({packageName:"*",policy:o.name,reason:`policy.${o.name} skipped: requires network (--offline)`,severity:"info",version:"*"});continue}try{const c=await o.evaluate(t,i.visConfig);a.push(...c)}catch(c){const s=c instanceof Error?c.message:String(c);a.push({packageName:"*",policy:o.name,reason:`policy.${o.name} failed: ${s}`,severity:"info",version:"*"})}}return a},"evaluatePolicies"),de=(()=>{const t=new Map;for(const e of P)t.set(e.toLowerCase(),e);return t})(),Se=d(()=>x.map(t=>t.name),"getRegisteredPolicyNames"),Ne=d((t,e)=>{if(t===void 0)return;const i=t.trim().toLowerCase();if(i===""||i==="none")return new Set;if(i==="all")return new Set(P);const n=new Set;for(const a of t.split(",").map(o=>o.trim()).filter(o=>o.length>0)){const o=a.replace(/^_+/,"").replaceAll(/_+([a-z])/g,(s,r)=>r.toUpperCase()),c=de.get(o.toLowerCase());c===void 0?e?.(a):n.add(c)}return n},"parsePoliciesFlag");export{we as c,Ce as e,Se as g,Ne as p,M as s};
@@ -1,2 +1,2 @@
1
- var z=Object.defineProperty;var n=(t,e)=>z(t,"name",{value:e,configurable:!0});import{createRequire as Q}from"node:module";import{f as tt,M as w}from"./readFileSync-CGmzMUF2-D6rUjGDn.js";import{f as j}from"../packem_chunks/config.js";import{aD as ht,B as dt,aE as L}from"../packem_chunks/bin.js";import{withEnhancedPath as wt}from"@visulima/task-runner";const Z=Q(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,p=n(t=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[e,o]=m.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return m.getBuiltinModule(t)}return Z(t)},"__cjs_getBuiltinModule"),{Socket:et}=p("node:net"),{randomBytes:ot}=p("node:crypto"),{readdir:st,writeFile:rt,rm:M,rename:it,open:nt,readFile:at,stat:ct,unlink:O}=p("node:fs/promises"),{createRequire:lt}=p("node:module"),{spawn:ft}=p("node:child_process"),{openSync:ut,closeSync:pt}=p("node:fs");var kt=Object.defineProperty,mt=n((t,e)=>kt(t,"name",{value:e,configurable:!0}),"i$1"),vt=Object.defineProperty,W=mt((t,e)=>vt(t,"name",{value:e,configurable:!0}),"s");const gt=lt(import.meta.url),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,yt=W(t=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[e,o]=v.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return v.getBuiltinModule(t)}return gt(t)},"__cjs_getBuiltinModule"),{lstat:x,mkdir:_t}=yt("node:fs/promises");var bt=Object.defineProperty,$t=W((t,e)=>bt(t,"name",{value:e,configurable:!0}),"o");const Et=$t(async t=>{tt(t);try{const e=await x(t);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(j(e))}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{await _t(t,{recursive:!0})}catch(e){if(e.code!=="EEXIST")throw e;const o=await x(t);if(!o.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(j(o))}'`,{cause:e})}},"ensureDir");var St=Object.defineProperty,f=n((t,e)=>St(t,"name",{value:e,configurable:!0}),"s$1");const Ht=3e4,N=100;class Pt extends Error{static{n(this,"ServiceReadinessError")}constructor(e,o){super(e),this.elapsedMs=o,this.name="ServiceReadinessError"}elapsedMs;static{f(this,"ServiceReadinessError")}}const Mt=f(async t=>{const e=t.host??"127.0.0.1",{port:o}=t,s=t.timeoutMs??Ht,r=Date.now();for(;Date.now()-r<s;){if(await Rt(e,o))return;await Tt(N)}throw new Pt(`Timed out waiting for ${e}:${String(o)} to accept TCP connections (${String(s)}ms)`,Date.now()-r)},"waitForTcp"),Rt=f((t,e)=>new Promise(o=>{const s=new et,r=f(i=>{s.removeAllListeners(),s.destroy(),o(i)},"onDone");s.once("connect",()=>{r(!0)}),s.once("error",()=>{r(!1)}),s.setTimeout(N,()=>{r(!1)});try{s.connect(e,t)}catch{r(!1)}}),"tryConnect"),Tt=f(t=>new Promise(e=>{setTimeout(e,t)}),"delay"),Dt=f(async(t,e)=>{const o=t.readiness??(t.port===void 0?void 0:{tcp:{port:t.port}});o&&await Mt({host:o.tcp.host,port:o.tcp.port,timeoutMs:e?.timeoutMs??o.tcp.timeoutMs})},"runReadiness");var Ot=Object.defineProperty,h=n((t,e)=>Ot(t,"name",{value:e,configurable:!0}),"o");const R=384,C=5e3,jt=50,xt=3e4,k=h(async t=>{const e=w(ht(t),"services");try{await Et(e)}catch(o){throw o.code==="ENOTDIR"?new Error(`Service registry path ${e} exists but is not a directory. Remove it or move the conflicting file before running \`vis service\`.`,{cause:o}):o}return e},"getRegistryDir"),T=h(t=>t.replaceAll("/","_").replaceAll(":","__"),"slugify"),D=h((t,e)=>w(t,`${T(e)}.json`),"entryPath"),Ct=h((t,e)=>w(t,`${T(e)}.lock`),"lockPath"),b=h(async(t,e)=>{const o=await k(t),s=D(o,e);if(await dt(s))try{return await L(s)}catch{return}},"readEntry"),At=h(async t=>{const e=await k(t);let o;try{o=await st(e)}catch{return[]}const s=[];for(const r of o)if(r.endsWith(".json"))try{const i=await L(w(e,r));s.push(i)}catch{}return s},"readAllEntries"),It=h(async(t,e)=>{const o=await k(t),s=D(o,e.id),r=w(o,`.${ot(8).toString("hex")}.tmp`);await rt(r,`${JSON.stringify(e,void 0,2)}
2
- `,{mode:R});try{await Nt(r,s)}catch(i){throw await M(r,{force:!0}).catch(()=>{}),i}},"writeEntry"),Ft=new Set(["EACCES","EBUSY","EPERM"]),Lt=8,Wt=20,Nt=h(async(t,e)=>{let o=0;for(;;)try{await it(t,e);return}catch(s){const{code:r}=s;if(!(r!==void 0&&Ft.has(r))||o>=Lt)throw s;const i=Wt*2**o;await new Promise(c=>{setTimeout(c,i)}),o+=1}},"renameWithRetry"),g=h(async(t,e,o)=>{const s=await k(t),r=o??await b(t,e);await M(D(s,e),{force:!0}),r&&await M(r.logFile,{force:!0}).catch(()=>{})},"deleteEntry"),u=h(t=>{try{return process.kill(t,0),!0}catch{return!1}},"isAlive"),le=h(async t=>{const e=await At(t),o=[],s=[];for(const r of e){if(u(r.pid)){s.push(r);continue}const i=await b(t,r.id);if(i&&i.pid!==r.pid){s.push(i);continue}await g(t,r.id,r).catch(()=>{}),o.push(r.id)}return{pruned:o,surviving:s}},"pruneDead"),Bt=h(t=>new Promise(e=>{setTimeout(e,t)}),"sleep"),Gt=h(async t=>{try{const e=await nt(t,"wx",R);try{await e.writeFile(String(process.pid))}finally{await e.close().catch(()=>{})}return!0}catch(e){if(e.code==="EEXIST")return!1;throw e}},"tryClaimLock"),Vt=h(async t=>{let e;try{const o=await at(t,"utf8"),s=Number.parseInt(o.trim(),10);e=Number.isFinite(s)?s:void 0}catch{return!0}if(e!==void 0&&!u(e))return!0;try{const o=await ct(t);return Date.now()-o.mtimeMs>xt}catch{return!0}},"isLockStale"),B=h(async(t,e,o)=>{const s=await k(t),r=Ct(s,e),i=Date.now();for(;!await Gt(r);){if(await Vt(r)){await O(r).catch(()=>{});continue}if(Date.now()-i>=C)throw new Error(`Could not acquire service lock for ${e} within ${String(C)}ms — another \`vis service\` invocation appears to be holding it.`);await Bt(jt)}try{return await o()}finally{await O(r).catch(()=>{})}},"withServiceLock");var qt=Object.defineProperty,l=n((t,e)=>qt(t,"name",{value:e,configurable:!0}),"r");function y(t,e={},o){for(const s in t){const r=t[s],i=o?`${o}:${s}`:s;typeof r=="object"&&r!==null?y(r,e,i):typeof r=="function"&&(e[i]=r)}return e}n(y,"c");l(y,"flatHooks");function Xt(...t){const e={};for(const o of t){const s=y(o);for(const r in s)e[r]?e[r].push(s[r]):e[r]=[s[r]]}for(const o in e)if(e[o].length>1){const s=e[o];e[o]=(...r)=>G(s,i=>i(...r))}else e[o]=e[o][0];return e}n(Xt,"v");l(Xt,"mergeHooks");function G(t,e){return t.reduce((o,s)=>o.then(()=>e(s)),Promise.resolve())}n(G,"d$1");l(G,"serial");const V=(()=>{if(console.createTask)return console.createTask;const t={run:l(e=>e(),"run")};return()=>t})();function $(t,e,o,s){for(let r=o;r<t.length;r+=1)try{const i=s?s.run(()=>t[r](...e)):t[r](...e);if(i&&typeof i.then=="function")return Promise.resolve(i).then(()=>$(t,e,r+1,s))}catch(i){return Promise.reject(i)}}n($,"k");l($,"callHooks");function q(t,e,o){if(t.length>0)return $(t,e,0,V(o))}n(q,"y");l(q,"serialTaskCaller");function X(t,e,o){if(t.length>0){const s=V(o);return Promise.all(t.map(r=>s.run(()=>r(...e))))}}n(X,"m");l(X,"parallelTaskCaller");function Yt(t,e){return t.reduce((o,s)=>o.then(()=>s(...e||[])),Promise.resolve())}n(Yt,"x");l(Yt,"serialCaller");function Jt(t,e){return Promise.all(t.map(o=>o(...e||[])))}n(Jt,"P");l(Jt,"parallelCaller");function _(t,e){for(const o of[...t])o(e)}n(_,"a");l(_,"callEachWith");var Kt=class{static{n(this,"p")}static{l(this,"Hookable")}_hooks;_before;_after;_deprecatedHooks;_deprecatedMessages;constructor(){this._hooks={},this._before=void 0,this._after=void 0,this._deprecatedMessages=void 0,this._deprecatedHooks={},this.hook=this.hook.bind(this),this.callHook=this.callHook.bind(this),this.callHookWith=this.callHookWith.bind(this)}hook(t,e,o={}){if(!t||typeof e!="function")return()=>{};const s=t;let r;for(;this._deprecatedHooks[t];)r=this._deprecatedHooks[t],t=r.to;if(r&&!o.allowDeprecated){let i=r.message;i||(i=`${s} hook has been deprecated`+(r.to?`, please use ${r.to}`:"")),this._deprecatedMessages||(this._deprecatedMessages=new Set),this._deprecatedMessages.has(i)||(console.warn(i),this._deprecatedMessages.add(i))}if(!e.name)try{Object.defineProperty(e,"name",{get:l(()=>"_"+t.replace(/\W+/g,"_")+"_hook_cb","get"),configurable:!0})}catch{}return this._hooks[t]=this._hooks[t]||[],this._hooks[t].push(e),()=>{e&&(this.removeHook(t,e),e=void 0)}}hookOnce(t,e){let o,s=l((...r)=>(typeof o=="function"&&o(),o=void 0,s=void 0,e(...r)),"_function");return o=this.hook(t,s),o}removeHook(t,e){const o=this._hooks[t];if(o){const s=o.indexOf(e);s!==-1&&o.splice(s,1),o.length===0&&(this._hooks[t]=void 0)}}clearHook(t){this._hooks[t]=void 0}deprecateHook(t,e){this._deprecatedHooks[t]=typeof e=="string"?{to:e}:e;const o=this._hooks[t]||[];this._hooks[t]=void 0;for(const s of o)this.hook(t,s)}deprecateHooks(t){for(const e in t)this.deprecateHook(e,t[e])}addHooks(t){const e=y(t),o=Object.keys(e).map(s=>this.hook(s,e[s]));return()=>{for(const s of o)s();o.length=0}}removeHooks(t){const e=y(t);for(const o in e)this.removeHook(o,e[o])}removeAllHooks(){this._hooks={}}callHook(t,...e){return this.callHookWith(q,t,e)}callHookParallel(t,...e){return this.callHookWith(X,t,e)}callHookWith(t,e,o){const s=this._before||this._after?{name:e,args:o,context:{}}:void 0;this._before&&_(this._before,s);const r=t(this._hooks[e]?[...this._hooks[e]]:[],o,e);return r instanceof Promise?r.finally(()=>{this._after&&s&&_(this._after,s)}):(this._after&&s&&_(this._after,s),r)}beforeEach(t){return this._before=this._before||[],this._before.push(t),()=>{if(this._before!==void 0){const e=this._before.indexOf(t);e!==-1&&this._before.splice(e,1)}}}afterEach(t){return this._after=this._after||[],this._after.push(t),()=>{if(this._after!==void 0){const e=this._after.indexOf(t);e!==-1&&this._after.splice(e,1)}}}};function Y(){return new Kt}n(Y,"w$1");l(Y,"createHooks");(class{static{l(this,"HookableCore")}_hooks;constructor(){this._hooks={}}hook(t,e){return!t||typeof e!="function"?()=>{}:(this._hooks[t]=this._hooks[t]||[],this._hooks[t].push(e),()=>{e&&(this.removeHook(t,e),e=void 0)})}removeHook(t,e){const o=this._hooks[t];if(o){const s=o.indexOf(e);s!==-1&&o.splice(s,1),o.length===0&&(this._hooks[t]=void 0)}}callHook(t,...e){const o=this._hooks[t];if(!(!o||o.length===0))return $(o,e,0)}});const A=typeof window<"u";function Ut(t,e={}){const o={inspect:A,group:A,filter:l(()=>!0,"filter"),...e},s=o.filter,r=typeof s=="string"?a=>a.startsWith(s):s,i=o.tag?`[${o.tag}] `:"",c=l(a=>i+a.name+"".padEnd(a._id,"\0"),"logPrefix"),d={},H=t.beforeEach(a=>{r!==void 0&&!r(a.name)||(d[a.name]=d[a.name]||0,a._id=d[a.name]++,console.time(c(a)))}),P=t.afterEach(a=>{r!==void 0&&!r(a.name)||(o.group&&console.groupCollapsed(a.name),o.inspect?console.timeLog(c(a),a.args):console.timeEnd(c(a)),o.group&&console.groupEnd(),d[a.name]--)});return{close:l(()=>{H(),P()},"close")}}n(Ut,"W");l(Ut,"createDebugger");var zt=Object.defineProperty,E=n((t,e)=>zt(t,"name",{value:e,configurable:!0}),"t$1");const he=E(()=>Y(),"createVisHooks"),de=E(async(t,e)=>{if(!(!e||e.length===0))for(const o of e){if(o.hooks)for(const[s,r]of Object.entries(o.hooks)){const i=Array.isArray(r)?r:[r];for(const c of i)t.hook(s,c)}o.setup&&await o.setup(t)}},"registerPlugins");class fe{static{n(this,"HookableLifeCycle")}static{E(this,"HookableLifeCycle")}#o;#e;#s=new Map;constructor(e,o){this.#o=e,this.#e=o}startTasks(e){for(const o of e)this.#s.set(o.id,o),this.#t("task:before",o)}endTasks(e){for(const o of e)this.#s.delete(o.task.id),this.#t("task:after",o.task,o),o.status==="failure"?this.#t("task:failure",o.task,o):Qt(o.status)&&this.#t("task:cacheHit",o.task,o)}printCacheMiss(e,o){this.#t("task:cacheMiss",e,o)}onTaskStdout(e,o){this.#t("task:stdout",e,o)}onTaskStderr(e,o){this.#t("task:stderr",e,o)}#t(e,...o){Promise.resolve(this.#o.callHook(e,...o)).catch(s=>{if(this.#e)try{this.#e(e,s)}catch{}})}}const Qt=E(t=>t==="local-cache"||t==="local-cache-kept-existing"||t==="remote-cache","isCacheStatus");var Zt=Object.defineProperty,te=n((t,e)=>Zt(t,"name",{value:e,configurable:!0}),"i");const I=process.platform==="win32",ee=te(async t=>{const{command:e,cwd:o,env:s,logFile:r}=t,i=ut(r,"a",R);let c;const d=I?"cmd":"/bin/sh",H=I?["/d","/s","/c",e]:["-c",e];try{c=ft(d,H,{cwd:o,detached:!0,env:wt({...process.env,...s},o),stdio:["ignore",i,i],windowsHide:!0})}finally{pt(i)}if(c.pid===void 0&&await new Promise((P,a)=>{c.once("spawn",()=>{P()}),c.once("error",U=>{a(U)})}),c.pid===void 0)throw new Error(`Failed to spawn detached process for command: ${e}`);return c.unref(),{pid:c.pid}},"spawnDetached");var oe=Object.defineProperty,S=n((t,e)=>oe(t,"name",{value:e,configurable:!0}),"t");const J=5e3,ue=S(async t=>B(t.workspaceRoot,t.id,async()=>{const e=await b(t.workspaceRoot,t.id);if(e&&u(e.pid))throw new Error(`Service ${t.id} is already running (pid ${String(e.pid)})`);e&&await g(t.workspaceRoot,t.id,e);const o=await k(t.workspaceRoot),s=T(t.id),r=w(o,`${s}.log`),{pid:i}=await ee({command:t.command,cwd:t.cwd,env:t.env,logFile:r}),c={command:t.command,config:t.config,cwd:t.cwd,env:t.config.env??{},id:t.id,logFile:r,pid:i,slug:s,startedAt:new Date().toISOString(),visVersion:process.env.VIS_VERSION??"0.0.0"};if(await It(t.workspaceRoot,c),t.skipReadiness!==!0)try{await Dt(t.config,{timeoutMs:t.readinessTimeoutMs})}catch(d){throw await K(i,t.config.killGracePeriodMs??J).catch(()=>{}),await g(t.workspaceRoot,t.id,c).catch(()=>{}),d}return{entry:c}}),"startService"),pe=S(async t=>B(t.workspaceRoot,t.id,async()=>{const e=await b(t.workspaceRoot,t.id);if(!e)return{stopped:!1};if(!u(e.pid))return await g(t.workspaceRoot,t.id,e),{stopped:!1};const o=t.graceMs??e.config.killGracePeriodMs??J;return await K(e.pid,o),await g(t.workspaceRoot,t.id,e),{stopped:!0}}),"stopService"),K=S(async(t,e)=>{F(t,"SIGTERM");const o=Date.now();for(;Date.now()-o<e;){if(!u(t))return;await new Promise(s=>{setTimeout(s,100)})}u(t)&&F(t,"SIGKILL")},"stopServiceByPid"),F=S((t,e)=>{try{process.platform==="win32"?process.kill(t,e):process.kill(-t,e)}catch(o){if(o.code==="ESRCH")return;throw o}},"sendSignalToServiceGroup");export{fe as H,Pt as S,b as a,pe as b,he as c,At as d,Dt as e,g as f,u as i,le as p,de as r,ue as s};
1
+ var Q=Object.defineProperty;var n=(t,e)=>Q(t,"name",{value:e,configurable:!0});import{createRequire as z}from"node:module";import{f as tt,M as w}from"./readFileSync-4c_c6Qey-6SWMDNdw.js";import{f as j}from"../packem_chunks/config.js";import{aT as ht,Q as dt,aU as L}from"../packem_chunks/bin.js";import{withEnhancedPath as wt}from"@visulima/task-runner";const Z=z(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,p=n(t=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[e,o]=m.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return m.getBuiltinModule(t)}return Z(t)},"__cjs_getBuiltinModule"),{Socket:et}=p("node:net"),{randomBytes:ot}=p("node:crypto"),{readdir:st,writeFile:rt,rm:T,rename:it,open:nt,readFile:at,stat:ct,unlink:O}=p("node:fs/promises"),{createRequire:lt}=p("node:module"),{spawn:ft}=p("node:child_process"),{openSync:ut,closeSync:pt}=p("node:fs");var kt=Object.defineProperty,mt=n((t,e)=>kt(t,"name",{value:e,configurable:!0}),"i$1"),vt=Object.defineProperty,W=mt((t,e)=>vt(t,"name",{value:e,configurable:!0}),"s");const gt=lt(import.meta.url),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,yt=W(t=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[e,o]=v.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return v.getBuiltinModule(t)}return gt(t)},"__cjs_getBuiltinModule"),{lstat:x,mkdir:_t}=yt("node:fs/promises");var bt=Object.defineProperty,$t=W((t,e)=>bt(t,"name",{value:e,configurable:!0}),"o");const Et=$t(async t=>{tt(t);try{const e=await x(t);if(!e.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(j(e))}'`);return}catch(e){if(e.code!=="ENOENT")throw e}try{await _t(t,{recursive:!0})}catch(e){if(e.code!=="EEXIST")throw e;const o=await x(t);if(!o.isDirectory())throw new Error(`Ensure path exists, expected 'dir', got '${String(j(o))}'`,{cause:e})}},"ensureDir");var St=Object.defineProperty,f=n((t,e)=>St(t,"name",{value:e,configurable:!0}),"s$1");const Ht=3e4,N=100;class Pt extends Error{static{n(this,"ServiceReadinessError")}constructor(e,o){super(e),this.elapsedMs=o,this.name="ServiceReadinessError"}elapsedMs;static{f(this,"ServiceReadinessError")}}const Tt=f(async t=>{const e=t.host??"127.0.0.1",{port:o}=t,s=t.timeoutMs??Ht,r=Date.now();for(;Date.now()-r<s;){if(await Mt(e,o))return;await Rt(N)}throw new Pt(`Timed out waiting for ${e}:${String(o)} to accept TCP connections (${String(s)}ms)`,Date.now()-r)},"waitForTcp"),Mt=f((t,e)=>new Promise(o=>{const s=new et,r=f(i=>{s.removeAllListeners(),s.destroy(),o(i)},"onDone");s.once("connect",()=>{r(!0)}),s.once("error",()=>{r(!1)}),s.setTimeout(N,()=>{r(!1)});try{s.connect(e,t)}catch{r(!1)}}),"tryConnect"),Rt=f(t=>new Promise(e=>{setTimeout(e,t)}),"delay"),Dt=f(async(t,e)=>{const o=t.readiness??(t.port===void 0?void 0:{tcp:{port:t.port}});o&&await Tt({host:o.tcp.host,port:o.tcp.port,timeoutMs:e?.timeoutMs??o.tcp.timeoutMs})},"runReadiness");var Ot=Object.defineProperty,h=n((t,e)=>Ot(t,"name",{value:e,configurable:!0}),"o");const M=384,C=5e3,jt=50,xt=3e4,k=h(async t=>{const e=w(ht(t),"services");try{await Et(e)}catch(o){throw o.code==="ENOTDIR"?new Error(`Service registry path ${e} exists but is not a directory. Remove it or move the conflicting file before running \`vis service\`.`,{cause:o}):o}return e},"getRegistryDir"),R=h(t=>t.replaceAll("/","_").replaceAll(":","__"),"slugify"),D=h((t,e)=>w(t,`${R(e)}.json`),"entryPath"),Ct=h((t,e)=>w(t,`${R(e)}.lock`),"lockPath"),b=h(async(t,e)=>{const o=await k(t),s=D(o,e);if(await dt(s))try{return await L(s)}catch{return}},"readEntry"),At=h(async t=>{const e=await k(t);let o;try{o=await st(e)}catch{return[]}const s=[];for(const r of o)if(r.endsWith(".json"))try{const i=await L(w(e,r));s.push(i)}catch{}return s},"readAllEntries"),It=h(async(t,e)=>{const o=await k(t),s=D(o,e.id),r=w(o,`.${ot(8).toString("hex")}.tmp`);await rt(r,`${JSON.stringify(e,void 0,2)}
2
+ `,{mode:M});try{await Nt(r,s)}catch(i){throw await T(r,{force:!0}).catch(()=>{}),i}},"writeEntry"),Ft=new Set(["EACCES","EBUSY","EPERM"]),Lt=8,Wt=20,Nt=h(async(t,e)=>{let o=0;for(;;)try{await it(t,e);return}catch(s){const{code:r}=s;if(!(r!==void 0&&Ft.has(r))||o>=Lt)throw s;const i=Wt*2**o;await new Promise(c=>{setTimeout(c,i)}),o+=1}},"renameWithRetry"),g=h(async(t,e,o)=>{const s=await k(t),r=o??await b(t,e);await T(D(s,e),{force:!0}),r&&await T(r.logFile,{force:!0}).catch(()=>{})},"deleteEntry"),u=h(t=>{try{return process.kill(t,0),!0}catch{return!1}},"isAlive"),le=h(async t=>{const e=await At(t),o=[],s=[];for(const r of e){if(u(r.pid)){s.push(r);continue}const i=await b(t,r.id);if(i&&i.pid!==r.pid){s.push(i);continue}await g(t,r.id,r).catch(()=>{}),o.push(r.id)}return{pruned:o,surviving:s}},"pruneDead"),Bt=h(t=>new Promise(e=>{setTimeout(e,t)}),"sleep"),Gt=h(async t=>{try{const e=await nt(t,"wx",M);try{await e.writeFile(String(process.pid))}finally{await e.close().catch(()=>{})}return!0}catch(e){if(e.code==="EEXIST")return!1;throw e}},"tryClaimLock"),Vt=h(async t=>{let e;try{const o=await at(t,"utf8"),s=Number.parseInt(o.trim(),10);e=Number.isFinite(s)?s:void 0}catch{return!0}if(e!==void 0&&!u(e))return!0;try{const o=await ct(t);return Date.now()-o.mtimeMs>xt}catch{return!0}},"isLockStale"),B=h(async(t,e,o)=>{const s=await k(t),r=Ct(s,e),i=Date.now();for(;!await Gt(r);){if(await Vt(r)){await O(r).catch(()=>{});continue}if(Date.now()-i>=C)throw new Error(`Could not acquire service lock for ${e} within ${String(C)}ms — another \`vis service\` invocation appears to be holding it.`);await Bt(jt)}try{return await o()}finally{await O(r).catch(()=>{})}},"withServiceLock");var qt=Object.defineProperty,l=n((t,e)=>qt(t,"name",{value:e,configurable:!0}),"r");function y(t,e={},o){for(const s in t){const r=t[s],i=o?`${o}:${s}`:s;typeof r=="object"&&r!==null?y(r,e,i):typeof r=="function"&&(e[i]=r)}return e}n(y,"c");l(y,"flatHooks");function Ut(...t){const e={};for(const o of t){const s=y(o);for(const r in s)e[r]?e[r].push(s[r]):e[r]=[s[r]]}for(const o in e)if(e[o].length>1){const s=e[o];e[o]=(...r)=>G(s,i=>i(...r))}else e[o]=e[o][0];return e}n(Ut,"v");l(Ut,"mergeHooks");function G(t,e){return t.reduce((o,s)=>o.then(()=>e(s)),Promise.resolve())}n(G,"d$1");l(G,"serial");const V=(()=>{if(console.createTask)return console.createTask;const t={run:l(e=>e(),"run")};return()=>t})();function $(t,e,o,s){for(let r=o;r<t.length;r+=1)try{const i=s?s.run(()=>t[r](...e)):t[r](...e);if(i&&typeof i.then=="function")return Promise.resolve(i).then(()=>$(t,e,r+1,s))}catch(i){return Promise.reject(i)}}n($,"k");l($,"callHooks");function q(t,e,o){if(t.length>0)return $(t,e,0,V(o))}n(q,"y");l(q,"serialTaskCaller");function U(t,e,o){if(t.length>0){const s=V(o);return Promise.all(t.map(r=>s.run(()=>r(...e))))}}n(U,"m");l(U,"parallelTaskCaller");function Xt(t,e){return t.reduce((o,s)=>o.then(()=>s(...e||[])),Promise.resolve())}n(Xt,"x");l(Xt,"serialCaller");function Yt(t,e){return Promise.all(t.map(o=>o(...e||[])))}n(Yt,"P");l(Yt,"parallelCaller");function _(t,e){for(const o of[...t])o(e)}n(_,"a");l(_,"callEachWith");var Jt=class{static{n(this,"p")}static{l(this,"Hookable")}_hooks;_before;_after;_deprecatedHooks;_deprecatedMessages;constructor(){this._hooks={},this._before=void 0,this._after=void 0,this._deprecatedMessages=void 0,this._deprecatedHooks={},this.hook=this.hook.bind(this),this.callHook=this.callHook.bind(this),this.callHookWith=this.callHookWith.bind(this)}hook(t,e,o={}){if(!t||typeof e!="function")return()=>{};const s=t;let r;for(;this._deprecatedHooks[t];)r=this._deprecatedHooks[t],t=r.to;if(r&&!o.allowDeprecated){let i=r.message;i||(i=`${s} hook has been deprecated`+(r.to?`, please use ${r.to}`:"")),this._deprecatedMessages||(this._deprecatedMessages=new Set),this._deprecatedMessages.has(i)||(console.warn(i),this._deprecatedMessages.add(i))}if(!e.name)try{Object.defineProperty(e,"name",{get:l(()=>"_"+t.replace(/\W+/g,"_")+"_hook_cb","get"),configurable:!0})}catch{}return this._hooks[t]=this._hooks[t]||[],this._hooks[t].push(e),()=>{e&&(this.removeHook(t,e),e=void 0)}}hookOnce(t,e){let o,s=l((...r)=>(typeof o=="function"&&o(),o=void 0,s=void 0,e(...r)),"_function");return o=this.hook(t,s),o}removeHook(t,e){const o=this._hooks[t];if(o){const s=o.indexOf(e);s!==-1&&o.splice(s,1),o.length===0&&(this._hooks[t]=void 0)}}clearHook(t){this._hooks[t]=void 0}deprecateHook(t,e){this._deprecatedHooks[t]=typeof e=="string"?{to:e}:e;const o=this._hooks[t]||[];this._hooks[t]=void 0;for(const s of o)this.hook(t,s)}deprecateHooks(t){for(const e in t)this.deprecateHook(e,t[e])}addHooks(t){const e=y(t),o=Object.keys(e).map(s=>this.hook(s,e[s]));return()=>{for(const s of o)s();o.length=0}}removeHooks(t){const e=y(t);for(const o in e)this.removeHook(o,e[o])}removeAllHooks(){this._hooks={}}callHook(t,...e){return this.callHookWith(q,t,e)}callHookParallel(t,...e){return this.callHookWith(U,t,e)}callHookWith(t,e,o){const s=this._before||this._after?{name:e,args:o,context:{}}:void 0;this._before&&_(this._before,s);const r=t(this._hooks[e]?[...this._hooks[e]]:[],o,e);return r instanceof Promise?r.finally(()=>{this._after&&s&&_(this._after,s)}):(this._after&&s&&_(this._after,s),r)}beforeEach(t){return this._before=this._before||[],this._before.push(t),()=>{if(this._before!==void 0){const e=this._before.indexOf(t);e!==-1&&this._before.splice(e,1)}}}afterEach(t){return this._after=this._after||[],this._after.push(t),()=>{if(this._after!==void 0){const e=this._after.indexOf(t);e!==-1&&this._after.splice(e,1)}}}};function X(){return new Jt}n(X,"w$1");l(X,"createHooks");(class{static{l(this,"HookableCore")}_hooks;constructor(){this._hooks={}}hook(t,e){return!t||typeof e!="function"?()=>{}:(this._hooks[t]=this._hooks[t]||[],this._hooks[t].push(e),()=>{e&&(this.removeHook(t,e),e=void 0)})}removeHook(t,e){const o=this._hooks[t];if(o){const s=o.indexOf(e);s!==-1&&o.splice(s,1),o.length===0&&(this._hooks[t]=void 0)}}callHook(t,...e){const o=this._hooks[t];if(!(!o||o.length===0))return $(o,e,0)}});const A=typeof window<"u";function Kt(t,e={}){const o={inspect:A,group:A,filter:l(()=>!0,"filter"),...e},s=o.filter,r=typeof s=="string"?a=>a.startsWith(s):s,i=o.tag?`[${o.tag}] `:"",c=l(a=>i+a.name+"".padEnd(a._id,"\0"),"logPrefix"),d={},H=t.beforeEach(a=>{r!==void 0&&!r(a.name)||(d[a.name]=d[a.name]||0,a._id=d[a.name]++,console.time(c(a)))}),P=t.afterEach(a=>{r!==void 0&&!r(a.name)||(o.group&&console.groupCollapsed(a.name),o.inspect?console.timeLog(c(a),a.args):console.timeEnd(c(a)),o.group&&console.groupEnd(),d[a.name]--)});return{close:l(()=>{H(),P()},"close")}}n(Kt,"W");l(Kt,"createDebugger");var Qt=Object.defineProperty,E=n((t,e)=>Qt(t,"name",{value:e,configurable:!0}),"t$1");const he=E(()=>X(),"createVisHooks"),de=E(async(t,e)=>{if(!(!e||e.length===0))for(const o of e){if(o.hooks)for(const[s,r]of Object.entries(o.hooks)){const i=Array.isArray(r)?r:[r];for(const c of i)t.hook(s,c)}o.setup&&await o.setup(t)}},"registerPlugins");class fe{static{n(this,"HookableLifeCycle")}static{E(this,"HookableLifeCycle")}#o;#e;#s=new Map;constructor(e,o){this.#o=e,this.#e=o}startTasks(e){for(const o of e)this.#s.set(o.id,o),this.#t("task:before",o)}endTasks(e){for(const o of e)this.#s.delete(o.task.id),this.#t("task:after",o.task,o),o.status==="failure"?this.#t("task:failure",o.task,o):zt(o.status)&&this.#t("task:cacheHit",o.task,o)}printCacheMiss(e,o){this.#t("task:cacheMiss",e,o)}onTaskStdout(e,o){this.#t("task:stdout",e,o)}onTaskStderr(e,o){this.#t("task:stderr",e,o)}#t(e,...o){Promise.resolve(this.#o.callHook(e,...o)).catch(s=>{if(this.#e)try{this.#e(e,s)}catch{}})}}const zt=E(t=>t==="local-cache"||t==="local-cache-kept-existing"||t==="remote-cache","isCacheStatus");var Zt=Object.defineProperty,te=n((t,e)=>Zt(t,"name",{value:e,configurable:!0}),"i");const I=process.platform==="win32",ee=te(async t=>{const{command:e,cwd:o,env:s,logFile:r}=t,i=ut(r,"a",M);let c;const d=I?"cmd":"/bin/sh",H=I?["/d","/s","/c",e]:["-c",e];try{c=ft(d,H,{cwd:o,detached:!0,env:wt({...process.env,...s},o),stdio:["ignore",i,i],windowsHide:!0})}finally{pt(i)}if(c.pid===void 0&&await new Promise((P,a)=>{c.once("spawn",()=>{P()}),c.once("error",K=>{a(K)})}),c.pid===void 0)throw new Error(`Failed to spawn detached process for command: ${e}`);return c.unref(),{pid:c.pid}},"spawnDetached");var oe=Object.defineProperty,S=n((t,e)=>oe(t,"name",{value:e,configurable:!0}),"t");const Y=5e3,ue=S(async t=>B(t.workspaceRoot,t.id,async()=>{const e=await b(t.workspaceRoot,t.id);if(e&&u(e.pid))throw new Error(`Service ${t.id} is already running (pid ${String(e.pid)})`);e&&await g(t.workspaceRoot,t.id,e);const o=await k(t.workspaceRoot),s=R(t.id),r=w(o,`${s}.log`),{pid:i}=await ee({command:t.command,cwd:t.cwd,env:t.env,logFile:r}),c={command:t.command,config:t.config,cwd:t.cwd,env:t.config.env??{},id:t.id,logFile:r,pid:i,slug:s,startedAt:new Date().toISOString(),visVersion:process.env.VIS_VERSION??"0.0.0"};if(await It(t.workspaceRoot,c),t.skipReadiness!==!0)try{await Dt(t.config,{timeoutMs:t.readinessTimeoutMs})}catch(d){throw await J(i,t.config.killGracePeriodMs??Y).catch(()=>{}),await g(t.workspaceRoot,t.id,c).catch(()=>{}),d}return{entry:c}}),"startService"),pe=S(async t=>B(t.workspaceRoot,t.id,async()=>{const e=await b(t.workspaceRoot,t.id);if(!e)return{stopped:!1};if(!u(e.pid))return await g(t.workspaceRoot,t.id,e),{stopped:!1};const o=t.graceMs??e.config.killGracePeriodMs??Y;return await J(e.pid,o),await g(t.workspaceRoot,t.id,e),{stopped:!0}}),"stopService"),J=S(async(t,e)=>{F(t,"SIGTERM");const o=Date.now();for(;Date.now()-o<e;){if(!u(t))return;await new Promise(s=>{setTimeout(s,100)})}u(t)&&F(t,"SIGKILL")},"stopServiceByPid"),F=S((t,e)=>{try{process.platform==="win32"?process.kill(t,e):process.kill(-t,e)}catch(o){if(o.code==="ESRCH")return;throw o}},"sendSignalToServiceGroup");export{fe as H,Pt as S,b as a,pe as b,he as c,At as d,Dt as e,g as f,u as i,le as p,de as r,ue as s};
@@ -0,0 +1 @@
1
+ var T=Object.defineProperty;var j=(n,e)=>T(n,"name",{value:e,configurable:!0});import{createRequire as B}from"node:module";import{u as R,U}from"../packem_chunks/bin.js";const q=B(import.meta.url),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=j(n=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[e,t]=h.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return h.getBuiltinModule(n)}return q(n)},"__cjs_getBuiltinModule"),{createRequire:N}=A("node:module");var C=Object.defineProperty,z=j((n,e)=>C(n,"name",{value:e,configurable:!0}),"L"),I=Object.defineProperty,S=z((n,e)=>I(n,"name",{value:e,configurable:!0}),"b");const J=N(import.meta.url),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=S(n=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[e,t]=y.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return y.getBuiltinModule(n)}return J(n)},"__cjs_getBuiltinModule"),{readFileSync:Y}=_("node:fs"),{readFile:Z}=_("node:fs/promises");var K=Object.defineProperty,l=S((n,e)=>K(n,"name",{value:e,configurable:!0}),"g");const G={sha256:"sha256",sha384:"sha384",sha512:"sha512"},H=1024,Q=/^[A-Z0-9+/]+={0,2}$/i,V=/.*node_modules\/((?:@[^/]+\/)?[^/]+)$/,k=/^['"]/,v=/['"]$/,X=/^[a-z][a-zA-Z0-9]*:\s*$/m,ee=/resolution:\s*\{[^}]*integrity:\s*([^,}\s]+)/,ne=/^["']?((?:@[^/@"']+\/)?[^@"'\n]+)@[^\n]+\n((?:[\t ][^\n]*(?:\n|$))+)/gm,te=/^\s+version:?\s+"?([^"\n]+)"?/m,se=/^\s+integrity[\s:]+"?([^"\s]+)"?/m,x=l(n=>{if(n.length>H)return;const e=n.indexOf("-");if(e<=0)return;const t=G[n.slice(0,e).toLowerCase()];if(!t)return;const s=n.slice(e+1);if(Q.test(s))try{const i=Buffer.from(s,"base64");return i.length===0?void 0:{algorithm:t,hex:i.toString("hex")}}catch{return}},"decodeSriIntegrity"),w=l((n,e,t)=>{const s=`${t.name}@${t.version}`;e.has(s)||(e.add(s),n.push(t))},"pushUniqueEntry"),m=l((n,e,t)=>{t&&Object.keys(t).length>0&&(n[e]={...t})},"copyDepMap"),g=l(n=>{if(!n)return;const e={};for(const[t,s]of Object.entries(n))e[t]=[s];return Object.keys(e).length>0?e:void 0},"liftDepMap"),re=l(n=>{const e=[],t=new Set;let s;try{s=JSON.parse(n)}catch{return e}if(!s.packages)return e;for(const[i,r]of Object.entries(s.packages)){if(!i||!r.version)continue;const p=V.exec(i);if(!p?.[1])continue;const c=r.name??p[1];if(c.startsWith("."))continue;const o={name:c,version:r.version};if(r.integrity){const a=x(r.integrity);a&&(o.integrity=a)}m(o,"dependencies",g(r.dependencies)),m(o,"peerDependencies",g(r.peerDependencies)),m(o,"optionalDependencies",g(r.optionalDependencies)),w(e,t,o)}return e},"parseNpmLockFile"),W=l(n=>{let e=n.trim();e.startsWith("/")&&(e=e.slice(1)),e=e.replace(k,"").replace(v,"");const t=e.indexOf("(");t>0&&(e=e.slice(0,t));const s=e.lastIndexOf("@");if(s<=0)return;const i=e.slice(0,s),r=e.slice(s+1);if(!(!i||!r||r.startsWith("link:")||r.startsWith("workspace:")||r.startsWith("file:")))return{name:i,version:r}},"splitPnpmPackageKey"),F=l((n,e)=>{const t=new RegExp(String.raw`^${e}:\s*$`,"m").exec(n);if(!t)return;const s=t.index+t[0].length,i=X.exec(n.slice(s));return n.slice(s,i?s+i.index:n.length)},"sliceTopLevelSection"),oe=l(n=>{const e=new Map,t=F(n,"snapshots");if(!t)return e;const s=/^ {2}(['"]?[^\s:][^:\n]*?['"]?):\s*\n((?: {4}[^\n]*\n?)+)/gm;let i;for(;(i=s.exec(t)??void 0)!==void 0;){const r=W(i[1]);if(!r)continue;const p=`${r.name}@${r.version}`,c=i[2],o=e.get(p)??{};for(const a of["dependencies","peerDependencies","optionalDependencies"]){const u=b(c,a);if(!u)continue;const d=o[a]??{};for(const[f,P]of Object.entries(u)){const D=d[f]??[];for(const O of P)D.includes(O)||D.push(O);d[f]=D}o[a]=d}e.set(p,o)}return e},"parsePnpmSnapshotEdges"),ie=l(n=>{const e=[],t=new Set,s=F(n,"packages");if(!s)return e;const i=oe(n),r=/^ {2}(['"]?[^\s:][^:\n]*?['"]?):\s*\n((?: {4}[^\n]*\n?)+)/gm;let p;for(;(p=r.exec(s)??void 0)!==void 0;){const c=W(p[1]);if(!c)continue;const o=p[2],a=ee.exec(o),u={name:c.name,version:c.version};if(a?.[1]){const f=x(a[1]);f&&(u.integrity=f)}const d=i.get(`${c.name}@${c.version}`);m(u,"dependencies",d?.dependencies??b(o,"dependencies")),m(u,"peerDependencies",d?.peerDependencies??b(o,"peerDependencies")),m(u,"optionalDependencies",d?.optionalDependencies??b(o,"optionalDependencies")),w(e,t,u)}return e},"parsePnpmLockFile"),b=l((n,e)=>{const t=new RegExp(String.raw`^ {4}${e}:\s*\n((?: {6,}[^\n]*\n?)+)`,"m").exec(n);if(!t?.[1])return;const s={},i=/^ {6}([^\s:]+):\s*([^\n]+)/gm;let r;for(;(r=i.exec(t[1])??void 0)!==void 0;){const p=r[1].replace(k,"").replace(v,"");let c=r[2].trim();c=c.replace(k,"").replace(v,"");const o=c.indexOf("(");if(o>0&&(c=c.slice(0,o).trim()),!p||!c)continue;const a=s[p]??[];a.includes(c)||a.push(c),s[p]=a}return Object.keys(s).length>0?s:void 0},"extractPnpmDependencyMap"),ce=l(n=>{const e=[],t=new Set,s=ne;s.lastIndex=0;let i;for(;(i=s.exec(n)??void 0)!==void 0;){const r=i[1].replace(k,"").replace(v,"");if(!r)continue;const p=i[2],c=te.exec(p);if(!c?.[1])continue;const o={name:r,version:c[1].trim()},a=se.exec(p);if(a?.[1]){const u=x(a[1]);u&&(o.integrity=u)}m(o,"dependencies",$(p,"dependencies")),m(o,"peerDependencies",$(p,"peerDependencies")),m(o,"optionalDependencies",$(p,"optionalDependencies")),w(e,t,o)}return e},"parseYarnLockFile"),$=l((n,e)=>{const t=new RegExp(String.raw`^ {2}${e}:\s*\n((?: {4,}[^\n]*\n?)+)`,"m").exec(n);if(!t?.[1])return;const s={},i=/^ {4}(['"]?[^\s:'"]+['"]?)\s*(?::\s*)?['"]([^'"\n]+)['"]/gm;let r;for(;(r=i.exec(t[1])??void 0)!==void 0;){const p=r[1].replace(k,"").replace(v,""),c=r[2];if(p&&c){const o=s[p]??[];o.includes(c)||o.push(c),s[p]=o}}return Object.keys(s).length>0?s:void 0},"extractYarnDependencyMap"),pe=/,(?=\s*[}\]])/g,ae=l(n=>{const e=[],t=new Set;let s;try{s=JSON.parse(n.replaceAll(pe,""))}catch{return e}if(!s.packages)return e;for(const i of Object.values(s.packages)){const r=i[0];if(typeof r!="string")continue;const p=r.indexOf("@",1);if(p<=0)continue;const c=r.slice(0,p),o=r.slice(p+1);if(!c||!o||o.startsWith("workspace:")||o.startsWith("link:")||o.startsWith("file:"))continue;const a={name:c,version:o},u=i[3];if(typeof u=="string"&&u.length>0){const f=x(u);f&&(a.integrity=f)}const d=i[2];if(d&&typeof d=="object"&&!Array.isArray(d)){const f=d;m(a,"dependencies",g(f.dependencies)),m(a,"peerDependencies",g(f.peerDependencies)),m(a,"optionalDependencies",g(f.optionalDependencies))}w(e,t,a)}return e},"parseBunLockFile"),L=l(n=>{if(n.endsWith("pnpm-lock.yaml"))return"pnpm";if(n.endsWith("package-lock.json"))return"npm";if(n.endsWith("yarn.lock"))return"yarn";if(n.endsWith("bun.lock"))return"bun"},"inferLockFileType"),E=l((n,e)=>{switch(e){case"bun":return ae(n);case"npm":return re(n);case"pnpm":return ie(n);case"yarn":return ce(n);default:return[]}},"parseLockFileContent"),M=["pnpm-lock.yaml","package-lock.json","yarn.lock","bun.lock"];l(async n=>{const e=await R(M,{type:"file",...n&&{cwd:n}});if(!e)throw new Error("Could not find a supported lock file (pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lock)");const t=L(e);if(!t)throw new Error(`Unsupported lock file: ${e}`);const s=await Z(e,"utf8");return{entries:E(s,t),path:e,type:t}},"parseLockFile");l(n=>{const e=U(M,{type:"file",...n&&{cwd:n}});if(!e)throw new Error("Could not find a supported lock file (pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lock)");const t=L(e);if(!t)throw new Error(`Unsupported lock file: ${e}`);return{entries:E(Y(e,"utf8"),t),path:e,type:t}},"parseLockFileSync");export{E as S};
@@ -0,0 +1 @@
1
+ var k=Object.defineProperty;var u=(e,n)=>k(e,"name",{value:n,configurable:!0});import{createRequire as g}from"node:module";import{M as m}from"./readFileSync-4c_c6Qey-6SWMDNdw.js";const b=g(import.meta.url),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=u(e=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[n,s]=l.versions.node.split(".").map(Number);if(n>22||n===22&&s>=3||n===20&&s>=16)return l.getBuiltinModule(e)}return b(e)},"__cjs_getBuiltinModule"),{existsSync:f,statSync:p}=h("node:fs");var y=Object.defineProperty,i=u((e,n)=>y(e,"name",{value:n,configurable:!0}),"s");const M={aube:["aube-lock.yaml"],bun:["bun.lock","bun.lockb"],npm:["npm-shrinkwrap.json","package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]},_={aube:["node_modules/.aube-state","node_modules/.modules.yaml"],bun:["node_modules/.bun-tag"],npm:["node_modules/.package-lock.json"],pnpm:["node_modules/.modules.yaml","node_modules/.pnpm/lock.yaml"],yarn:["node_modules/.yarn-integrity","node_modules/.yarn-state.yml",".yarn/install-state.gz"]},j={ci:{aube:"aube ci",bun:"bun install --frozen-lockfile",npm:"npm ci",pnpm:"pnpm install --frozen-lockfile",yarn:"yarn install --immutable"},tty:{aube:"aube install",bun:"bun install",npm:"npm install",pnpm:"pnpm install",yarn:"yarn install"}},v=1e3,P=i(e=>{for(const[n,s]of Object.entries(M))for(const t of s)if(f(m(e,t)))return{lockfileFile:t,manager:n}},"detectPackageManager"),C=i((e,n)=>{let s;for(const t of _[n]){const o=m(e,t);if(!f(o))continue;const{mtimeMs:a}=p(o);(!s||a>s.mtimeMs)&&(s={mtimeMs:a,path:t})}return s},"findFreshestMarker"),F=i((e,n={})=>{const s=P(e);if(!s)return{checked:!1};const{lockfileFile:t,manager:o}=s,a=p(m(e,t)).mtimeMs,r=C(e,o),d=j[n.inCi?"ci":"tty"][o],c={installMarkerMtimeMs:r?.mtimeMs,lockfileMtimeMs:a,lockfilePath:t,marker:r?.path,packageManager:o};return r?a>r.mtimeMs+v?{checked:!0,detail:c,failure:"stale-install",message:`${t} is newer than node_modules (${r.path}) — run \`${d}\` to sync.`}:{checked:!0,detail:c}:{checked:!0,detail:c,failure:"missing-install",message:`lockfile detected but node_modules looks uninitialised — run \`${d}\` before \`vis run\`.`}},"checkLockfileFreshness"),w=i((e,n,s,t={})=>{if(t.skip)return{checked:!1,shouldContinue:!0};const o=F(e,{inCi:n});if(!o.failure)return{...o,shouldContinue:!0};const a=`preflight: ${o.message??"lockfile drift detected"}`;return n&&!t.ciAsWarning?{...o,formattedMessage:a,shouldContinue:!1}:(s.warn(a),{...o,formattedMessage:a,shouldContinue:!0})},"runLockfilePreflight");export{P as d,w as r};
@@ -1 +1 @@
1
- var j=Object.defineProperty;var g=(s,e)=>j(s,"name",{value:e,configurable:!0});import{createRequire as S}from"node:module";import{M as d,i as y}from"./readFileSync-CGmzMUF2-D6rUjGDn.js";import{n as q}from"../packem_chunks/config.js";const $=S(import.meta.url),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=g(s=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[e,n]=l.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return l.getBuiltinModule(s)}return $(s)},"__cjs_getBuiltinModule"),{readdirSync:b,lstatSync:P}=A("node:fs");var w=Object.defineProperty,v=g((s,e)=>w(s,"name",{value:e,configurable:!0}),"u");const D=/^([^<(]+?)?(?:<([^>]+)>)?\s*(?:\(([^)]+)\))?\s*$/u,N=v(s=>{const e=s.match(D);if(!e)return;const n=e[1]?.trim(),t=e[2]?.trim(),r=e[3]?.trim();if(!(!n&&!t&&!r))return{email:t||void 0,name:n||void 0,url:r||void 0}},"parsePersonString"),R=v(s=>{if(!Array.isArray(s)||s.length===0)return;const e=[];for(const n of s)if(typeof n=="string"){const t=N(n);t&&e.push(t)}else if(n&&typeof n=="object"){const t=n,r=typeof t.name=="string"?t.name:void 0,o=typeof t.email=="string"?t.email:void 0,u=typeof t.url=="string"?t.url:void 0;(r||o||u)&&e.push({email:o,name:r,url:u})}return e.length>0?e:void 0},"normalizeMaintainers"),W=v(s=>{const e=d(s,"node_modules");if(!y(e))return new Map;const n=new Map,t=new Set,r=v((o,u="")=>{if(t.has(o))return;t.add(o);let h;try{h=b(o)}catch{return}for(const a of h){const c=d(o,a);let m;try{m=P(c)}catch{continue}if(m.isSymbolicLink())continue;if(a.startsWith("@")){m.isDirectory()&&r(c,`${a}/`);continue}if(a===".pnpm"&&u===""){let i;try{i=b(c)}catch{continue}for(const p of i){const f=d(c,p,"node_modules");y(f)&&r(f)}continue}if(a.startsWith(".")||!m.isDirectory())continue;const _=u+a,M=d(c,"package.json");try{if(!y(M))continue;const i=q(M);if(typeof i.version!="string")continue;const p=`${_}@${i.version}`;n.has(p)||n.set(p,{directory:c,license:i.license,licenses:Array.isArray(i.licenses)?i.licenses:void 0,maintainers:R(i.maintainers),name:_,scripts:i.scripts&&typeof i.scripts=="object"?i.scripts:void 0,version:i.version});const f=d(c,"node_modules");y(f)&&r(f)}catch{}}},"scanDir");return r(e),n},"readNodeModulesManifests");export{R as n,W as r};
1
+ var j=Object.defineProperty;var g=(s,e)=>j(s,"name",{value:e,configurable:!0});import{createRequire as S}from"node:module";import{M as d,i as y}from"./readFileSync-4c_c6Qey-6SWMDNdw.js";import{n as q}from"../packem_chunks/config.js";const $=S(import.meta.url),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=g(s=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[e,n]=l.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return l.getBuiltinModule(s)}return $(s)},"__cjs_getBuiltinModule"),{readdirSync:b,lstatSync:P}=A("node:fs");var w=Object.defineProperty,v=g((s,e)=>w(s,"name",{value:e,configurable:!0}),"u");const D=/^([^<(]+?)?(?:<([^>]+)>)?\s*(?:\(([^)]+)\))?\s*$/u,N=v(s=>{const e=s.match(D);if(!e)return;const n=e[1]?.trim(),t=e[2]?.trim(),r=e[3]?.trim();if(!(!n&&!t&&!r))return{email:t||void 0,name:n||void 0,url:r||void 0}},"parsePersonString"),R=v(s=>{if(!Array.isArray(s)||s.length===0)return;const e=[];for(const n of s)if(typeof n=="string"){const t=N(n);t&&e.push(t)}else if(n&&typeof n=="object"){const t=n,r=typeof t.name=="string"?t.name:void 0,o=typeof t.email=="string"?t.email:void 0,u=typeof t.url=="string"?t.url:void 0;(r||o||u)&&e.push({email:o,name:r,url:u})}return e.length>0?e:void 0},"normalizeMaintainers"),W=v(s=>{const e=d(s,"node_modules");if(!y(e))return new Map;const n=new Map,t=new Set,r=v((o,u="")=>{if(t.has(o))return;t.add(o);let h;try{h=b(o)}catch{return}for(const a of h){const c=d(o,a);let m;try{m=P(c)}catch{continue}if(m.isSymbolicLink())continue;if(a.startsWith("@")){m.isDirectory()&&r(c,`${a}/`);continue}if(a===".pnpm"&&u===""){let i;try{i=b(c)}catch{continue}for(const p of i){const f=d(c,p,"node_modules");y(f)&&r(f)}continue}if(a.startsWith(".")||!m.isDirectory())continue;const _=u+a,M=d(c,"package.json");try{if(!y(M))continue;const i=q(M);if(typeof i.version!="string")continue;const p=`${_}@${i.version}`;n.has(p)||n.set(p,{directory:c,license:i.license,licenses:Array.isArray(i.licenses)?i.licenses:void 0,maintainers:R(i.maintainers),name:_,scripts:i.scripts&&typeof i.scripts=="object"?i.scripts:void 0,version:i.version});const f=d(c,"node_modules");y(f)&&r(f)}catch{}}},"scanDir");return r(e),n},"readNodeModulesManifests");export{R as n,W as r};
@@ -1,4 +1,4 @@
1
- var E=Object.defineProperty;var R=(u,p)=>E(u,"name",{value:p,configurable:!0});import{M as d,i as o,$}from"./readFileSync-CGmzMUF2-D6rUjGDn.js";import{d as h}from"../packem_chunks/config.js";import{m as x}from"../packem_chunks/bin.js";var S=Object.defineProperty,b=R((u,p)=>S(u,"name",{value:p,configurable:!0}),"k");const U=b((u,p,A,m=[])=>{const i=[];if(A===void 0)return i.push("minimumReleaseAge not set in vis.config; skipping native sync."),i;const r=Number.isFinite(A)?Math.max(0,Math.round(A)):0;switch(u){case"bun":{const n=d(p,"bunfig.toml");let e=o(n)?$(n):"";const a=r*60,t=`minimumReleaseAge = ${String(a)}`,s=m.length>0?`minimumReleaseAgeExcludes = [${m.map(c=>`"${c.replaceAll(String.raw`"`,String.raw`\"`)}"`).join(", ")}]`:void 0,g=/^\[install\][ \t]*\n/m.exec(e);if(g?.index===void 0){const c=s?`${t}
1
+ var E=Object.defineProperty;var R=(u,p)=>E(u,"name",{value:p,configurable:!0});import{M as d,i as o,$}from"./readFileSync-4c_c6Qey-6SWMDNdw.js";import{q as h}from"../packem_chunks/config.js";import{z as x}from"../packem_chunks/bin.js";var S=Object.defineProperty,b=R((u,p)=>S(u,"name",{value:p,configurable:!0}),"k");const U=b((u,p,A,m=[])=>{const i=[];if(A===void 0)return i.push("minimumReleaseAge not set in vis.config; skipping native sync."),i;const r=Number.isFinite(A)?Math.max(0,Math.round(A)):0;switch(u){case"bun":{const n=d(p,"bunfig.toml");let e=o(n)?$(n):"";const a=r*60,t=`minimumReleaseAge = ${String(a)}`,s=m.length>0?`minimumReleaseAgeExcludes = [${m.map(c=>`"${c.replaceAll(String.raw`"`,String.raw`\"`)}"`).join(", ")}]`:void 0,g=/^\[install\][ \t]*\n/m.exec(e);if(g?.index===void 0){const c=s?`${t}
2
2
  ${s}`:t;e=`${e.trimEnd()?`${e.trimEnd()}
3
3
 
4
4
  `:""}[install]
@@ -1,4 +1,4 @@
1
- var v=Object.defineProperty;var E=(o,l)=>v(o,"name",{value:l,configurable:!0});import{M as c,$ as S,i as g}from"./readFileSync-CGmzMUF2-D6rUjGDn.js";import{d as i,n as O}from"../packem_chunks/config.js";import{e as N,o as U}from"../packem_chunks/bin.js";var x=Object.defineProperty,D=E((o,l)=>x(o,"name",{value:l,configurable:!0}),"f");const W=D((o,l,d)=>{const s=[],b=Object.entries(d).filter(([,n])=>n).map(([n])=>n);switch(o){case"bun":{const n=c(l,"package.json");if(g(n))try{const e=O(n);e.trustedDependencies=b,i(n,`${JSON.stringify(e,null,2)}
1
+ var v=Object.defineProperty;var E=(o,l)=>v(o,"name",{value:l,configurable:!0});import{M as c,$ as S,i as g}from"./readFileSync-4c_c6Qey-6SWMDNdw.js";import{q as i,n as O}from"../packem_chunks/config.js";import{q as N,r as U}from"../packem_chunks/bin.js";var q=Object.defineProperty,D=E((o,l)=>q(o,"name",{value:l,configurable:!0}),"f");const P=D((o,l,d)=>{const s=[],b=Object.entries(d).filter(([,n])=>n).map(([n])=>n);switch(o){case"bun":{const n=c(l,"package.json");if(g(n))try{const e=O(n);e.trustedDependencies=b,i(n,`${JSON.stringify(e,null,2)}
2
2
  `),s.push(`Updated package.json trustedDependencies with ${b.length} packages`)}catch(e){s.push(`Failed to update package.json: ${e instanceof Error?e.message:String(e)}`)}break}case"npm":{const n=c(l,".npmrc");let e=g(n)?S(n):"";/^\s*ignore-scripts\s*=\s*true\s*$/m.test(e)?s.push(".npmrc already has ignore-scripts=true"):(e=`${e.trimEnd()}
3
3
  ignore-scripts=true
4
4
  `,i(n,e),s.push("Added ignore-scripts=true to .npmrc"));break}case"pnpm":{const n=c(l,"pnpm-workspace.yaml");if(!g(n)){s.push("pnpm-workspace.yaml not found. Cannot sync allowBuilds.");break}let e={},m=[];try{const t=U(n);e=t?.allowBuilds??{},m=Array.isArray(t?.onlyBuiltDependencies)?t.onlyBuiltDependencies:[]}catch{}const h={...e,...d},A=Object.keys(d).filter(t=>e[t]!==d[t]).length,u=b.toSorted((t,p)=>t.localeCompare(p)),k=[...new Set([...m,...u])].toSorted((t,p)=>t.localeCompare(p)),w=u.filter(t=>!m.includes(t)).length;if(A===0&&w===0)s.push(`All ${String(Object.keys(d).length)} allowBuilds entries already present in pnpm-workspace.yaml.`);else{const t=Object.keys(h).sort(),p=D(a=>a.startsWith("@")||a.includes("/")||/[:#\s]/.test(a),"needsQuote"),$=D(a=>p(a)?`'${a.replaceAll("'","''")}'`:a,"renderKey"),y=`allowBuilds:
@@ -18,4 +18,4 @@ ${a}`}i(n,r),s.push(`Updated pnpm-workspace.yaml allowBuilds (${String(A)} new,
18
18
  enableScripts: false
19
19
  `,i(n,e),s.push("Added enableScripts: false to .yarnrc.yml"))}else{const n=c(l,".npmrc");let e=g(n)?S(n):"";/^\s*ignore-scripts\s*=\s*true\s*$/m.test(e)?s.push(".npmrc already has ignore-scripts=true"):(e=`${e.trimEnd()}
20
20
  ignore-scripts=true
21
- `,i(n,e),s.push("Added ignore-scripts=true to .npmrc (yarn classic lacks enableScripts)"))}break}}return s},"syncAllowBuildsToNativeConfig");export{W as N};
21
+ `,i(n,e),s.push("Added ignore-scripts=true to .npmrc (yarn classic lacks enableScripts)"))}break}}return s},"syncAllowBuildsToNativeConfig");export{P as N};
@@ -1,2 +1,2 @@
1
- var U=Object.defineProperty;var l=(e,o)=>U(e,"name",{value:o,configurable:!0});import{createRequire as P}from"node:module";import{B as K}from"../packem_chunks/config.js";import{NATIVE_BINDING_VERSION as M,osvBloomDecode as Y,osvBloomProbe as Q,osvBloomProbeBatch as X}from"#native";const V=P(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,O=l(e=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[o,t]=d.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return d.getBuiltinModule(e)}return V(e)},"__cjs_getBuiltinModule"),{randomUUID:H,createHash:F}=O("node:crypto"),{existsSync:p}=O("node:fs"),{readFile:y,mkdir:L,stat:I,rm:q,writeFile:G,rename:J,unlink:W}=O("node:fs/promises"),{join:w,dirname:z}=O("node:path");var Z=Object.defineProperty,s=l((e,o)=>Z(e,"name",{value:o,configurable:!0}),"r");const N=5;if(M!==N)throw new Error(`vis native binding ABI mismatch in osv-bloom: expected ${N}, got ${M}. Rebuild via \`pnpm --filter @visulima/vis run build:native\` or reinstall the platform binding package.`);const ut="https://endevco.github.io/osv-bloom",tt=new Set(["endevco.github.io"]);class g extends Error{static{l(this,"OsvBloomSourceNotAllowedError")}static{s(this,"OsvBloomSourceNotAllowedError")}cause="OSV_BLOOM_SOURCE_NOT_ALLOWED";constructor(o){super(`osv-bloom source host '${o}' is not in the built-in allowlist. Add it to \`security.audit.advisories.bloom.allowedHosts\` if intentional.`),this.name="OsvBloomSourceNotAllowedError"}}class S extends Error{static{l(this,"OsvBloomNetworkError")}static{s(this,"OsvBloomNetworkError")}cause="OSV_BLOOM_NETWORK";constructor(o,t){super(`osv-bloom fetch failed for ${o}: ${t}. Check connectivity, proxy env vars, or --source.`),this.name="OsvBloomNetworkError"}}class et extends Error{static{l(this,"OsvBloomIntegrityError")}static{s(this,"OsvBloomIntegrityError")}cause="OSV_BLOOM_INTEGRITY";constructor(o,t){super(`osv-bloom filter.bin sha256 mismatch (expected ${o}, got ${t}). Refusing to install a corrupted filter.`),this.name="OsvBloomIntegrityError"}}class v extends Error{static{l(this,"OsvBloomManifestError")}static{s(this,"OsvBloomManifestError")}cause="OSV_BLOOM_MANIFEST";constructor(o){super(`osv-bloom manifest invalid: ${o}`),this.name="OsvBloomManifestError"}}class ot extends Error{static{l(this,"OsvBloomCacheMissError")}static{s(this,"OsvBloomCacheMissError")}cause="OSV_BLOOM_CACHE_MISS";constructor(o){super(`No osv-bloom cache at ${o}. Run 'vis advisories bloom sync' first.`),this.name="OsvBloomCacheMissError"}}const b=s(e=>{const o=K("vis",{create:!0,cwd:e})??w(e,"node_modules",".cache","vis");return w(o,"osv-bloom")},"resolveOsvBloomCacheDir"),h=s(e=>w(e,"filter.bin"),"filterPath"),R=s(e=>w(e,"manifest.json"),"manifestPath"),T=s(e=>w(e,"state.json"),"statePath"),st=s((e,o)=>{let t;try{t=new URL(e)}catch{throw new g(e)}if(!t.host)throw new g(e);if(t.protocol!=="https:")throw new g(`${t.protocol}//${t.host}`);if(!new Set([...tt,...o??[]]).has(t.host))throw new g(t.host);return t},"validateOsvBloomSource"),ht=s(async e=>{const o=Date.now(),t=e.cacheDir??b(e.workspaceRoot);await L(t,{recursive:!0});const r=st(e.source,e.allowedHosts),a=new URL("manifest.json",$(r.toString())),i=new URL("filter.bin",$(r.toString())),n=await x(a,{method:"GET"});if(!n.ok)throw new S(a.toString(),n.status);const B=await n.text(),c=k(B),m=await C(t);if(!e.force&&m?.setDigestSha256===c.setDigestSha256&&p(h(t)))return{bytesOnDisk:(await I(h(t))).size,cacheDir:t,durationMs:Date.now()-o,manifest:c,upToDate:!0};const E={};!e.force&&m?.filterEtag&&(E.headers={"if-none-match":m.filterEtag});const f=await x(i,{...E,method:"GET"});if(f.status===304&&m&&p(h(t)))return await A(t,B,{fetchedAtIso:new Date().toISOString(),filterEtag:m.filterEtag,setDigestSha256:c.setDigestSha256}),{bytesOnDisk:(await I(h(t))).size,cacheDir:t,durationMs:Date.now()-o,manifest:c,upToDate:!0};if(!f.ok||!f.body)throw new S(i.toString(),f.status);const u=Buffer.from(await f.arrayBuffer());e.onProgress&&e.onProgress(u.length,u.length);const D=rt(u);if(D!==c.filterSha256)throw new et(c.filterSha256,D);if(u.length!==c.bloomByteLen)throw new v(`filter.bin length ${u.length} does not match manifest.bloom_byte_len ${c.bloomByteLen}`);const j=f.headers.get("etag")??void 0;return await _(h(t),u),await A(t,B,{fetchedAtIso:new Date().toISOString(),filterEtag:j,setDigestSha256:c.setDigestSha256}),{bytesOnDisk:u.length,cacheDir:t,durationMs:Date.now()-o,manifest:c,upToDate:!1}},"syncOsvBloom"),ft=s(async(e,o)=>{const t=o?.cacheDir??b(e),r=h(t);if(!p(r)){if(o?.softFail)return null;throw new ot(t)}const a=await y(r);return Y(a)},"loadOsvBloomHandle");s((e,o,t)=>Q(e,o,t),"probeOsvBloom");const mt=s((e,o)=>X(e,o),"probeOsvBloomBatch"),dt=s(async(e,o)=>{const t=o??b(e);if(!p(h(t)))return{cacheDir:t,present:!1};let r,a;try{r=k(await y(R(t),"utf8"))}catch{}try{a=await C(t)}catch{}return{cacheDir:t,fetchedAtIso:a?.fetchedAtIso,manifest:r,present:!0}},"getOsvBloomStatus");s(async(e,o)=>{const t=o??b(e);await q(t,{force:!0,recursive:!0})},"clearOsvBloomCache");const k=s(e=>{let o;try{o=JSON.parse(e)}catch(i){throw new v(i instanceof Error?i.message:String(i))}const t=s(i=>{const n=o[i];if(typeof n!="number"||Number.isNaN(n))throw new v(`field '${i}' missing or non-numeric`);return n},"requireNumber"),r=s(i=>{const n=o[i];if(typeof n!="string"||n.length===0)throw new v(`field '${i}' missing or empty`);return n},"requireString"),a=t("format_version");if(a!==1)throw new v(`unsupported format_version ${a} (this build expects v1)`);return{advisoryCount:t("advisory_count"),bloomByteLen:t("bloom_byte_len"),bloomKHashes:t("bloom_k_hashes"),bloomMBits:t("bloom_m_bits"),builtAtRfc3339:r("built_at_rfc3339"),builtAtUnix:t("built_at_unix"),entryCount:t("entry_count"),filterSha256:r("filter_sha256"),formatVersion:a,setDigestSha256:r("set_digest_sha256"),sourceUrl:r("source_url"),targetFpr:t("target_fpr")}},"parseManifest"),C=s(async e=>{try{const o=await y(T(e),"utf8"),t=JSON.parse(o);return typeof t.setDigestSha256!="string"||typeof t.fetchedAtIso!="string"?void 0:{fetchedAtIso:t.fetchedAtIso,filterEtag:typeof t.filterEtag=="string"?t.filterEtag:void 0,setDigestSha256:t.setDigestSha256}}catch{return}},"readState"),A=s(async(e,o,t)=>{await _(R(e),Buffer.from(o,"utf8")),await _(T(e),Buffer.from(`${JSON.stringify(t,void 0,2)}
2
- `,"utf8"))},"persistManifestAndState"),_=s(async(e,o)=>{await L(z(e),{recursive:!0});const t=`${e}.${process.pid}.${H()}.tmp`;try{await G(t,o),await J(t,e)}catch(r){throw await W(t).catch(()=>{}),r}},"atomicWrite"),rt=s(e=>F("sha256").update(e).digest("hex"),"sha256Hex"),$=s(e=>e.endsWith("/")?e:`${e}/`,"ensureTrailingSlash"),it=3e4,x=s(async(e,o)=>{try{return await fetch(e,{...o,signal:AbortSignal.timeout(it)})}catch(t){throw new S(e.toString(),t instanceof Error?t.message:String(t))}},"safeFetch");export{ut as D,ot as O,dt as g,ft as l,mt as p,ht as s};
1
+ var U=Object.defineProperty;var l=(e,o)=>U(e,"name",{value:o,configurable:!0});import{createRequire as P}from"node:module";import{d as K}from"../packem_chunks/config.js";import{NATIVE_BINDING_VERSION as M,osvBloomDecode as Y,osvBloomProbe as Q,osvBloomProbeBatch as X}from"#native";const V=P(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,O=l(e=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[o,t]=d.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return d.getBuiltinModule(e)}return V(e)},"__cjs_getBuiltinModule"),{randomUUID:H,createHash:F}=O("node:crypto"),{existsSync:p}=O("node:fs"),{readFile:y,mkdir:L,stat:I,rm:q,writeFile:G,rename:J,unlink:W}=O("node:fs/promises"),{join:w,dirname:z}=O("node:path");var Z=Object.defineProperty,s=l((e,o)=>Z(e,"name",{value:o,configurable:!0}),"r");const N=5;if(M!==N)throw new Error(`vis native binding ABI mismatch in osv-bloom: expected ${N}, got ${M}. Rebuild via \`pnpm --filter @visulima/vis run build:native\` or reinstall the platform binding package.`);const ut="https://endevco.github.io/osv-bloom",tt=new Set(["endevco.github.io"]);class g extends Error{static{l(this,"OsvBloomSourceNotAllowedError")}static{s(this,"OsvBloomSourceNotAllowedError")}cause="OSV_BLOOM_SOURCE_NOT_ALLOWED";constructor(o){super(`osv-bloom source host '${o}' is not in the built-in allowlist. Add it to \`security.audit.advisories.bloom.allowedHosts\` if intentional.`),this.name="OsvBloomSourceNotAllowedError"}}class B extends Error{static{l(this,"OsvBloomNetworkError")}static{s(this,"OsvBloomNetworkError")}cause="OSV_BLOOM_NETWORK";constructor(o,t){super(`osv-bloom fetch failed for ${o}: ${t}. Check connectivity, proxy env vars, or --source.`),this.name="OsvBloomNetworkError"}}class et extends Error{static{l(this,"OsvBloomIntegrityError")}static{s(this,"OsvBloomIntegrityError")}cause="OSV_BLOOM_INTEGRITY";constructor(o,t){super(`osv-bloom filter.bin sha256 mismatch (expected ${o}, got ${t}). Refusing to install a corrupted filter.`),this.name="OsvBloomIntegrityError"}}class v extends Error{static{l(this,"OsvBloomManifestError")}static{s(this,"OsvBloomManifestError")}cause="OSV_BLOOM_MANIFEST";constructor(o){super(`osv-bloom manifest invalid: ${o}`),this.name="OsvBloomManifestError"}}class ot extends Error{static{l(this,"OsvBloomCacheMissError")}static{s(this,"OsvBloomCacheMissError")}cause="OSV_BLOOM_CACHE_MISS";constructor(o){super(`No osv-bloom cache at ${o}. Run 'vis advisories bloom sync' first.`),this.name="OsvBloomCacheMissError"}}const b=s(e=>{const o=K("vis",{create:!0,cwd:e})??w(e,"node_modules",".cache","vis");return w(o,"osv-bloom")},"resolveOsvBloomCacheDir"),h=s(e=>w(e,"filter.bin"),"filterPath"),R=s(e=>w(e,"manifest.json"),"manifestPath"),T=s(e=>w(e,"state.json"),"statePath"),st=s((e,o)=>{let t;try{t=new URL(e)}catch{throw new g(e)}if(!t.host)throw new g(e);if(t.protocol!=="https:")throw new g(`${t.protocol}//${t.host}`);if(!new Set([...tt,...o??[]]).has(t.host))throw new g(t.host);return t},"validateOsvBloomSource"),ht=s(async e=>{const o=Date.now(),t=e.cacheDir??b(e.workspaceRoot);await L(t,{recursive:!0});const r=st(e.source,e.allowedHosts),a=new URL("manifest.json",$(r.toString())),i=new URL("filter.bin",$(r.toString())),n=await x(a,{method:"GET"});if(!n.ok)throw new B(a.toString(),n.status);const S=await n.text(),c=k(S),m=await C(t);if(!e.force&&m?.setDigestSha256===c.setDigestSha256&&p(h(t)))return{bytesOnDisk:(await I(h(t))).size,cacheDir:t,durationMs:Date.now()-o,manifest:c,upToDate:!0};const E={};!e.force&&m?.filterEtag&&(E.headers={"if-none-match":m.filterEtag});const f=await x(i,{...E,method:"GET"});if(f.status===304&&m&&p(h(t)))return await A(t,S,{fetchedAtIso:new Date().toISOString(),filterEtag:m.filterEtag,setDigestSha256:c.setDigestSha256}),{bytesOnDisk:(await I(h(t))).size,cacheDir:t,durationMs:Date.now()-o,manifest:c,upToDate:!0};if(!f.ok||!f.body)throw new B(i.toString(),f.status);const u=Buffer.from(await f.arrayBuffer());e.onProgress&&e.onProgress(u.length,u.length);const D=rt(u);if(D!==c.filterSha256)throw new et(c.filterSha256,D);if(u.length!==c.bloomByteLen)throw new v(`filter.bin length ${u.length} does not match manifest.bloom_byte_len ${c.bloomByteLen}`);const j=f.headers.get("etag")??void 0;return await _(h(t),u),await A(t,S,{fetchedAtIso:new Date().toISOString(),filterEtag:j,setDigestSha256:c.setDigestSha256}),{bytesOnDisk:u.length,cacheDir:t,durationMs:Date.now()-o,manifest:c,upToDate:!1}},"syncOsvBloom"),ft=s(async(e,o)=>{const t=o?.cacheDir??b(e),r=h(t);if(!p(r)){if(o?.softFail)return null;throw new ot(t)}const a=await y(r);return Y(a)},"loadOsvBloomHandle");s((e,o,t)=>Q(e,o,t),"probeOsvBloom");const mt=s((e,o)=>X(e,o),"probeOsvBloomBatch"),dt=s(async(e,o)=>{const t=o??b(e);if(!p(h(t)))return{cacheDir:t,present:!1};let r,a;try{r=k(await y(R(t),"utf8"))}catch{}try{a=await C(t)}catch{}return{cacheDir:t,fetchedAtIso:a?.fetchedAtIso,manifest:r,present:!0}},"getOsvBloomStatus");s(async(e,o)=>{const t=o??b(e);await q(t,{force:!0,recursive:!0})},"clearOsvBloomCache");const k=s(e=>{let o;try{o=JSON.parse(e)}catch(i){throw new v(i instanceof Error?i.message:String(i))}const t=s(i=>{const n=o[i];if(typeof n!="number"||Number.isNaN(n))throw new v(`field '${i}' missing or non-numeric`);return n},"requireNumber"),r=s(i=>{const n=o[i];if(typeof n!="string"||n.length===0)throw new v(`field '${i}' missing or empty`);return n},"requireString"),a=t("format_version");if(a!==1)throw new v(`unsupported format_version ${a} (this build expects v1)`);return{advisoryCount:t("advisory_count"),bloomByteLen:t("bloom_byte_len"),bloomKHashes:t("bloom_k_hashes"),bloomMBits:t("bloom_m_bits"),builtAtRfc3339:r("built_at_rfc3339"),builtAtUnix:t("built_at_unix"),entryCount:t("entry_count"),filterSha256:r("filter_sha256"),formatVersion:a,setDigestSha256:r("set_digest_sha256"),sourceUrl:r("source_url"),targetFpr:t("target_fpr")}},"parseManifest"),C=s(async e=>{try{const o=await y(T(e),"utf8"),t=JSON.parse(o);return typeof t.setDigestSha256!="string"||typeof t.fetchedAtIso!="string"?void 0:{fetchedAtIso:t.fetchedAtIso,filterEtag:typeof t.filterEtag=="string"?t.filterEtag:void 0,setDigestSha256:t.setDigestSha256}}catch{return}},"readState"),A=s(async(e,o,t)=>{await _(R(e),Buffer.from(o,"utf8")),await _(T(e),Buffer.from(`${JSON.stringify(t,void 0,2)}
2
+ `,"utf8"))},"persistManifestAndState"),_=s(async(e,o)=>{await L(z(e),{recursive:!0});const t=`${e}.${process.pid}.${H()}.tmp`;try{await G(t,o),await J(t,e)}catch(r){throw await W(t).catch(()=>{}),r}},"atomicWrite"),rt=s(e=>F("sha256").update(e).digest("hex"),"sha256Hex"),$=s(e=>e.endsWith("/")?e:`${e}/`,"ensureTrailingSlash"),it=3e4,x=s(async(e,o)=>{try{return await fetch(e,{...o,signal:AbortSignal.timeout(it)})}catch(t){throw new B(e.toString(),t instanceof Error?t.message:String(t))}},"safeFetch");export{ut as D,ot as O,dt as g,ft as l,mt as p,ht as s};