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

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 (118) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/binx.js +1 -1
  4. package/dist/packem_chunks/bin.js +368 -367
  5. package/dist/packem_chunks/bloom-status.js +1 -1
  6. package/dist/packem_chunks/bloom-sync.js +1 -1
  7. package/dist/packem_chunks/config.js +15 -15
  8. package/dist/packem_chunks/doctor-probe.js +1 -1
  9. package/dist/packem_chunks/fix.js +1 -1
  10. package/dist/packem_chunks/handler.js +1 -1
  11. package/dist/packem_chunks/handler10.js +1 -1
  12. package/dist/packem_chunks/handler11.js +4 -4
  13. package/dist/packem_chunks/handler12.js +1 -1
  14. package/dist/packem_chunks/handler13.js +2 -2
  15. package/dist/packem_chunks/handler14.js +1 -1
  16. package/dist/packem_chunks/handler15.js +1 -1
  17. package/dist/packem_chunks/handler16.js +1 -1
  18. package/dist/packem_chunks/handler17.js +1 -1
  19. package/dist/packem_chunks/handler18.js +1 -1
  20. package/dist/packem_chunks/handler19.js +1 -1
  21. package/dist/packem_chunks/handler2.js +1 -1
  22. package/dist/packem_chunks/handler20.js +1 -1
  23. package/dist/packem_chunks/handler21.js +2 -2
  24. package/dist/packem_chunks/handler22.js +2 -2
  25. package/dist/packem_chunks/handler23.js +1 -1
  26. package/dist/packem_chunks/handler25.js +1 -1
  27. package/dist/packem_chunks/handler26.js +1 -1
  28. package/dist/packem_chunks/handler27.js +1 -1
  29. package/dist/packem_chunks/handler28.js +1 -1
  30. package/dist/packem_chunks/handler29.js +1 -1
  31. package/dist/packem_chunks/handler30.js +7 -7
  32. package/dist/packem_chunks/handler32.js +1 -1
  33. package/dist/packem_chunks/handler33.js +1 -1
  34. package/dist/packem_chunks/handler34.js +4 -4
  35. package/dist/packem_chunks/handler35.js +1 -1
  36. package/dist/packem_chunks/handler36.js +1 -1
  37. package/dist/packem_chunks/handler37.js +5 -5
  38. package/dist/packem_chunks/handler38.js +4 -4
  39. package/dist/packem_chunks/handler39.js +1 -1
  40. package/dist/packem_chunks/handler4.js +1 -1
  41. package/dist/packem_chunks/handler40.js +2 -2
  42. package/dist/packem_chunks/handler41.js +6 -6
  43. package/dist/packem_chunks/handler42.js +13 -13
  44. package/dist/packem_chunks/handler43.js +5 -5
  45. package/dist/packem_chunks/handler44.js +5 -5
  46. package/dist/packem_chunks/handler45.js +1 -1
  47. package/dist/packem_chunks/handler46.js +12 -12
  48. package/dist/packem_chunks/handler47.js +40 -40
  49. package/dist/packem_chunks/handler48.js +15 -15
  50. package/dist/packem_chunks/handler49.js +3 -3
  51. package/dist/packem_chunks/handler5.js +1 -1
  52. package/dist/packem_chunks/handler50.js +9 -9
  53. package/dist/packem_chunks/handler51.js +1 -1
  54. package/dist/packem_chunks/handler52.js +1 -1
  55. package/dist/packem_chunks/handler6.js +1 -1
  56. package/dist/packem_chunks/handler7.js +1 -1
  57. package/dist/packem_chunks/handler8.js +1 -1
  58. package/dist/packem_chunks/handler9.js +1 -1
  59. package/dist/packem_chunks/heal-accept.js +1 -1
  60. package/dist/packem_chunks/heal.js +1 -1
  61. package/dist/packem_chunks/help-command.js +7 -7
  62. package/dist/packem_chunks/index.js +6 -6
  63. package/dist/packem_chunks/keys-refresh.js +1 -1
  64. package/dist/packem_chunks/list.js +2 -2
  65. package/dist/packem_chunks/loader.js +1 -1
  66. package/dist/packem_chunks/loader2.js +1 -1
  67. package/dist/packem_chunks/prune.js +1 -1
  68. package/dist/packem_chunks/run.js +1 -1
  69. package/dist/packem_chunks/status.js +1 -1
  70. package/dist/packem_chunks/sync.js +1 -1
  71. package/dist/packem_chunks/sync2.js +1 -1
  72. package/dist/packem_chunks/tripwire.js +2 -2
  73. package/dist/packem_chunks/verify-lockfile.js +1 -1
  74. package/dist/packem_shared/Table-DoSoazT6-DwnyTUsA.js +12 -0
  75. package/dist/packem_shared/{advisories-DpgSuWDH.js → advisories-BxXiKFbL.js} +1 -1
  76. package/dist/packem_shared/{affected-shas-BkXXecyi.js → affected-shas-BdnlfiV1.js} +1 -1
  77. package/dist/packem_shared/{ai-fix-CfFWatGY.js → ai-fix-BkPUHA0z.js} +1 -1
  78. package/dist/packem_shared/{applyDefaults-DLvOqXGX.js → applyDefaults-BogleaFi.js} +1 -1
  79. package/dist/packem_shared/build-scripts-DE6U8jVq.js +1 -0
  80. package/dist/packem_shared/{cyclonedx-B04lIvwu.js → cyclonedx-BpGVHqSW.js} +1 -1
  81. package/dist/packem_shared/{dependency-scan-B9wTcLxf.js → dependency-scan-BUbOcMwX.js} +1 -1
  82. package/dist/packem_shared/{docker-DxA80dRx.js → docker-CTE3s4LW.js} +1 -1
  83. package/dist/packem_shared/{failure-log-n3j_-w8s.js → failure-log-34Wl3npC.js} +1 -1
  84. package/dist/packem_shared/glob-D_7bct6p-D8itOHsr.js +1 -0
  85. package/dist/packem_shared/{index-BfG9_znI.js → index-D1xC1Y_R.js} +1 -1
  86. package/dist/packem_shared/index-hoWfZmNo.js +30 -0
  87. package/dist/packem_shared/{lifecycle-NHIKDiCh.js → lifecycle-CXaqPGAQ.js} +2 -2
  88. package/dist/packem_shared/lockfile-CrT86D6d.js +1 -0
  89. package/dist/packem_shared/{lockfile-DAuTDwow.js → lockfile-Cu2BH6bl.js} +1 -1
  90. package/dist/packem_shared/{manifests-B7wUR3Rk.js → manifests-BzWpKW8F.js} +1 -1
  91. package/dist/packem_shared/{min-release-age-YyNI7gqV.js → min-release-age-BPVXwPUg.js} +2 -2
  92. package/dist/packem_shared/{native-config-sync-CgRIIRZV.js → native-config-sync-BRZZetn3.js} +8 -8
  93. package/dist/packem_shared/{osv-bloom-BQSIHt5h.js → osv-bloom-DSZcHLsM.js} +1 -1
  94. package/dist/packem_shared/{pm-runner-Ta_yz2uP.js → pm-runner-DmKT2FqF.js} +1 -1
  95. package/dist/packem_shared/{provenance-DoEp2uOo.js → provenance-DkCA8BrN.js} +1 -1
  96. package/dist/packem_shared/readFileSync-DseCu8sg-DEq4Fn3a.js +1 -0
  97. package/dist/packem_shared/{registry-keys-CD1xHavV.js → registry-keys-Mixm4eAY.js} +1 -1
  98. package/dist/packem_shared/{resolve-explicit-DpSc7RN2.js → resolve-explicit-D5E72FfN.js} +1 -1
  99. package/dist/packem_shared/runtime-check-CilFOqUU.js +1 -0
  100. package/dist/packem_shared/{s1ngularity-CIX7UcT5.js → s1ngularity-Qxc6tRRI.js} +1 -1
  101. package/dist/packem_shared/{scan-progress-CTVVf9WW.js → scan-progress-DVtCtI2z.js} +1 -1
  102. package/dist/packem_shared/{selectors-BU8aTRQm.js → selectors-DkgYFzdq.js} +1 -1
  103. package/dist/packem_shared/{signatures-BHM7cnqB.js → signatures-byuFrtAH.js} +1 -1
  104. package/dist/packem_shared/{toolchain-juKl-WgV.js → toolchain-DoG6b_G_.js} +2 -2
  105. package/dist/packem_shared/{typosquats-DRKU6d2S.js → typosquats-BiDxQj7R.js} +1 -1
  106. package/dist/packem_shared/{verify-DA80ja1b.js → verify-cLcZwKqe.js} +1 -1
  107. package/dist/packem_shared/{watch-DdR-pFzX.js → watch-DEL0yol9.js} +1 -1
  108. package/dist/packem_shared/{watch-loop-C8csFvRU.js → watch-loop-C31Ar7BX.js} +3 -3
  109. package/index.d.ts +201 -201
  110. package/index.js +26 -26
  111. package/package.json +10 -10
  112. package/dist/packem_shared/Table-3pFgIUZ2-DABgc6rj.js +0 -12
  113. package/dist/packem_shared/build-scripts-D-ysm_bS.js +0 -1
  114. package/dist/packem_shared/glob-MHJQjR39-CQ2GC0b_.js +0 -1
  115. package/dist/packem_shared/index-BDF8gawl.js +0 -29
  116. package/dist/packem_shared/lockfile-CoeFxWAv.js +0 -1
  117. package/dist/packem_shared/readFileSync-4c_c6Qey-6SWMDNdw.js +0 -1
  118. package/dist/packem_shared/runtime-check-Cbtb_Utb.js +0 -1
@@ -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-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
+ 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-DkCA8BrN.js";import{$ as m}from"../packem_chunks/bin.js";import{x as W}from"./build-scripts-DE6U8jVq.js";import{n as b}from"./license-zZU7aavK.js";import{a as j,C as F,B as U}from"./readFileSync-DseCu8sg-DEq4Fn3a.js";import{S as E}from"./lockfile-CrT86D6d.js";import{L as N}from"./dependency-scan-BUbOcMwX.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};
@@ -0,0 +1,30 @@
1
+ var on=Object.defineProperty;var _=(t,e)=>on(t,"name",{value:e,configurable:!0});import{createRequire as sn}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 rn=sn(import.meta.url),le=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,an=_(t=>{if(typeof le<"u"&&le.versions&&le.versions.node){const[e,n]=le.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return le.getBuiltinModule(t)}return rn(t)},"__cjs_getBuiltinModule"),{createRequire:Me}=an("node:module"),ln=16,Be=32,cn=64,oe=128,ye="positionals";var un=Object.defineProperty,gt=_((t,e)=>un(t,"name",{value:e,configurable:!0}),"i$5"),pn=Object.defineProperty,wt=gt((t,e)=>pn(t,"name",{value:e,configurable:!0}),"s"),hn=Object.defineProperty,vt=wt((t,e)=>hn(t,"name",{value:e,configurable:!0}),"t");vt(t=>t instanceof Error&&t.type==="VisulimaError","isVisulimaError");let de=class extends Error{static{_(this,"f")}static{gt(this,"E")}static{wt(this,"VisulimaError")}static{vt(this,"VisulimaError")}loc;title;hint;type="VisulimaError";constructor({cause:e,hint:n,location:o,message:s,name:i,stack:a,title:l}){super(s,{cause:e}),this.title=l,this.name=i,this.stack=a??this.stack,this.loc=o,this.hint=n}setLocation(e){this.loc=e}setName(e){this.name=e}setMessage(e){this.message=e}setHint(e){this.hint=e}};var fn=Object.defineProperty,dn=_((t,e)=>fn(t,"name",{value:e,configurable:!0}),"t$3");let k=class extends de{static{_(this,"a")}static{dn(this,"n")}code;context;constructor(e,n,o){super({message:e,name:"CerebroError"}),this.code=n,this.context=o}};var mn=Object.defineProperty,S=_((t,e)=>mn(t,"name",{value:e,configurable:!0}),"r$1");const U=S(t=>"Deno"in t,"n"),D=S(t=>"Bun"in t,"l"),$e=S(()=>{if(U(globalThis)){const t=globalThis.Deno,e=t.execPath();let n=e;try{const{importMeta:o}=globalThis;o?.url&&(n=o.url)}catch{}return[e,n,...t.args]}return D(globalThis)?globalThis.Bun.process.argv:process.argv},"i"),gn=S(()=>U(globalThis)?globalThis.Deno.cwd():D(globalThis)?globalThis.Bun.process.cwd():process.cwd(),"t"),q=S(()=>{if(U(globalThis)){const t=globalThis.Deno;return new Proxy(t.env.toObject(),{get:S((e,n)=>typeof n=="string"?t.env.get(n):e[n],"get"),has:S((e,n)=>typeof n=="string"?t.env.has(n):n in e,"has"),set:S((e,n,o)=>typeof n=="string"?(o===void 0||t.env.set(n,o),!0):!1,"set")})}return D(globalThis)?globalThis.Bun.process.env:process.env},"a"),yt=S(()=>U(globalThis)?[]:D(globalThis)?globalThis.Bun.process.execArgv:process.execArgv,"c"),bt=S(()=>U(globalThis)?globalThis.Deno.execPath():D(globalThis)?globalThis.Bun.process.execPath:process.execPath,"g"),wn=S(()=>{if(U(globalThis)){const t=globalThis.Deno.build?.os??"unknown";return t==="windows"?"win32":t}return D(globalThis)?globalThis.Bun.platform??"unknown":process.platform},"h"),vn=S(()=>{if(U(globalThis)){const t=globalThis.Deno.build?.arch??"unknown";return t==="x86_64"?"x64":t==="aarch64"?"arm64":t}return D(globalThis)?globalThis.Bun.process.arch:process.arch},"b");S(()=>{if(U(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(D(globalThis)){const t=globalThis.Bun,e={...t.process.versions};return t.version&&(e.bun=t.version),e}return process.versions},"T");const z=S((t=0)=>{if(U(globalThis))throw globalThis.Deno.exit(t),new Error("Deno exit failed");if(D(globalThis))throw globalThis.Bun.process.exit(t),new Error("Bun exit failed");process.exit(t)},"u"),Re=S((t,e)=>{if(U(globalThis))return()=>{};if(D(globalThis)){try{const o=globalThis.Bun;if(o.process?.on)return o.process.on(t,e),()=>{o.process?.removeListener&&o.process.removeListener(t,e)}}catch{}return()=>{}}const n=process;return n.on(t,e),()=>{n.removeListener(t,e)}},"p");var yn=Object.defineProperty,xe=_((t,e)=>yn(t,"name",{value:e,configurable:!0}),"k$1");const R=new Uint32Array(65536),bn=xe((t,e)=>{const n=t.length,o=e.length,s=1<<n-1;let i=-1,a=0,l=n,h=n;for(;h--;)R[t.charCodeAt(h)]|=1<<h;for(h=0;h<o;h++){let r=R[e.charCodeAt(h)];const c=r|a;r|=(r&i)+i^i,a|=~(r|i),i&=r,a&s&&l++,i&s&&l--,a=a<<1|1,i=i<<1|~(c|a),a&=c}for(h=n;h--;)R[t.charCodeAt(h)]=0;return l},"myers_32"),$n=xe((t,e)=>{const n=e.length,o=t.length,s=[],i=[],a=Math.ceil(n/32),l=Math.ceil(o/32);for(let u=0;u<a;u++)i[u]=-1,s[u]=0;let h=0;for(;h<l-1;h++){let u=0,v=-1;const $=h*32,y=Math.min(32,o)+$;for(let x=$;x<y;x++)R[t.charCodeAt(x)]|=1<<x;for(let x=0;x<n;x++){const E=R[e.charCodeAt(x)],O=i[x/32|0]>>>x&1,f=s[x/32|0]>>>x&1,w=E|u,b=((E|f)&v)+v^v|E|f;let N=u|~(b|v),A=v&b;N>>>31^O&&(i[x/32|0]^=1<<x),A>>>31^f&&(s[x/32|0]^=1<<x),N=N<<1|O,A=A<<1|f,v=A|~(w|N),u=N&w}for(let x=$;x<y;x++)R[t.charCodeAt(x)]=0}let r=0,c=-1;const m=h*32,p=Math.min(32,o-m)+m;for(let u=m;u<p;u++)R[t.charCodeAt(u)]|=1<<u;let g=o;for(let u=0;u<n;u++){const v=R[e.charCodeAt(u)],$=i[u/32|0]>>>u&1,y=s[u/32|0]>>>u&1,x=v|r,E=((v|y)&c)+c^c|v|y;let O=r|~(E|c),f=c&E;g+=O>>>o-1&1,g-=f>>>o-1&1,O>>>31^$&&(i[u/32|0]^=1<<u),f>>>31^y&&(s[u/32|0]^=1<<u),O=O<<1|$,f=f<<1|y,c=f|~(x|O),r=O&x}for(let u=m;u<p;u++)R[t.charCodeAt(u)]=0;return g},"myers_x"),$t=xe((t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return e.length===0?t.length:t.length<=32?bn(t,e):$n(t,e)},"distance");xe((t,e)=>{let n=1/0,o=0;for(let s=0;s<e.length;s++){const i=$t(t,e[s]);i<n&&(n=i,o=s)}return e[o]},"closest");var xn=Object.defineProperty,xt=_((t,e)=>xn(t,"name",{value:e,configurable:!0}),"e$1");const Nt=String.raw,ze=Nt`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,Nn=xt(()=>new RegExp(Nt`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${ze}(?:\u200D${ze})*`,"gu"),"i");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 vr=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,yr=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,G=Nn(),An=/[-_./\s]+/g,be=/(\u001B\[[0-9;]*[a-z])/i,Fe=new RegExp("\\p{Script=Arabic}","u"),En=new RegExp("\\p{Script=Bengali}","u"),te=new RegExp("\\p{Script=Cyrillic}","u"),kn=new RegExp("\\p{Script=Devanagari}","u"),On=new RegExp("\\p{Script=Ethiopic}","u"),ke=new RegExp("\\p{Script=Greek}","u"),We=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),Cn=new RegExp("\\p{Script=Gujarati}","u"),_n=new RegExp("\\p{Script=Gurmukhi}","u"),qe=new RegExp("\\p{Script=Hangul}","u"),Ge=new RegExp("\\p{Script=Hebrew}","u"),Ln=new RegExp("\\p{Script=Hiragana}","u"),He=new RegExp("\\p{Script=Han}","u"),Pn=new RegExp("\\p{Script=Kannada}","u"),Tn=new RegExp("\\p{Script=Katakana}","u"),Sn=new RegExp("\\p{Script=Khmer}","u"),In=new RegExp("\\p{Script=Lao}","u"),I=new RegExp("\\p{Script=Latin}","u"),Mn=new RegExp("\\p{Script=Malayalam}","u"),jn=new RegExp("\\p{Script=Myanmar}","u"),Un=new RegExp("\\p{Script=Oriya}","u"),Dn=new RegExp("\\p{Script=Sinhala}","u"),Vn=new RegExp("\\p{Script=Tamil}","u"),Bn=new RegExp("\\p{Script=Telugu}","u"),Rn=new RegExp("\\p{Script=Thai}","u"),zn=new RegExp("\\p{Script=Tibetan}","u"),Je=/[\u02BB\u02BC\u0027]/u,Fn=xt(t=>t.replace(G,""),"A");var Wn=Object.defineProperty,d=_((t,e)=>Wn(t,"name",{value:e,configurable:!0}),"u$2");const qn=Me(import.meta.url),ce=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,At=d(t=>{if(typeof ce<"u"&&ce.versions&&ce.versions.node){const[e,n]=ce.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ce.getBuiltinModule(t)}return qn(t)},"ze"),{writeFile:Gn,stat:Hn,rm:Jn,readFile:Ke,readdir:Kn,mkdir:Yn,access:Zn}=At("node:fs/promises"),{createRequire:Qn}=At("node:module"),ge=[{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}];let H=class extends k{static{_(this,"V")}static{d(this,"T")}commandName;constructor(e,n=[]){const o=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(o,"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(", ")}`)}},Et=class extends k{static{_(this,"Fe")}static{d(this,"We")}option1;option2;constructor(e,n){super(`Options "${e}" and "${n}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:e,option2:n}),this.name="ConflictingOptionsError",this.option1=e,this.option2=n,this.hint=`Remove either --${e} or --${n}`}},Xn=class extends k{static{_(this,"Gt")}static{d(this,"qt")}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)}},eo=class{static{_(this,"Yt")}static{d(this,"Gt")}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`);q().CEREBRO_OUTPUT_LEVEL===String(oe)&&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(o){const s=new Xn(n.name,`Failed to initialize: ${o instanceof Error?o.message:String(o)}`,o instanceof Error?o:void 0);throw this.logger.error(s.message),s}}this.initialized=!0}async executeLifecycle(t,e,n){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const o=this.getDependencyOrder();for(const s of o){const i=s[t];if(typeof i=="function"){this.logger.debug(`executing ${t} hook for plugin: ${s.name}`);try{await(t==="afterCommand"?i(e,n):i(e))}catch(a){throw this.logger.error(`Error in ${t} hook for plugin "${s.name}":`,a),a}}}}async executeErrorHandlers(t,e){if(!this.initialized||this.plugins.size===0)return;const n=this.getDependencyOrder();for(const o of n)if(typeof o.onError=="function"){this.logger.debug(`executing error handler for plugin: ${o.name}`);try{await o.onError(t,e)}catch(s){this.logger.error(`Error in error handler for plugin "${o.name}":`,s)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const t=[],e=new Set,n=new Set,o=d(s=>{if(e.has(s))return;if(n.has(s))throw new Error(`Circular dependency detected involving plugin "${s}"`);const i=this.plugins.get(s);if(!i)throw new Error(`Plugin "${s}" not found`);if(n.add(s),i.dependencies)for(const a of i.dependencies)o(a);n.delete(s),e.add(s),t.push(i)},"s");for(const s of this.plugins.keys())o(s);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`)}}};const fe=d(t=>t.type?.name==="Boolean","Z"),to=d(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},"Kt"),Ye=d(t=>(fe(t)||(t.typeLabel=t.typeLabel??to(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),"ke"),no=new RegExp(/^-([^\d-])$/),oo=new RegExp(/^--(\S+)/),io=new RegExp(/^-([^\d-]{2,})$/),so=d(t=>no.test(t)||oo.test(t)||io.test(t),"Qt"),ro=d((t,e)=>{const n=e[0]&&so(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const o=new Error(`Command not recognised: ${String(n)}`);throw o.command=n,o.name="INVALID_COMMAND",o}return{argv:e,command:n}},"Zt");var ao=Object.defineProperty,kt=d((t,e)=>ao(t,"name",{value:e,configurable:!0}),"Fe"),lo=Object.defineProperty,co=kt((t,e)=>lo(t,"name",{value:e,configurable:!0}),"i");let uo=class Ot extends de{static{_(this,"Ge")}static{d(this,"qe")}static{kt(this,"t")}static{co(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,Ot.prototype)}};var po=Object.defineProperty,Ct=d((t,e)=>po(t,"name",{value:e,configurable:!0}),"Ge"),ho=Object.defineProperty,fo=Ct((t,e)=>ho(t,"name",{value:e,configurable:!0}),"e");let Ze=class _t extends de{static{_(this,"ie")}static{d(this,"oe")}static{Ct(this,"o")}static{fo(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,_t.prototype)}};var mo=Object.defineProperty,Lt=d((t,e)=>mo(t,"name",{value:e,configurable:!0}),"Ke"),go=Object.defineProperty,wo=Lt((t,e)=>go(t,"name",{value:e,configurable:!0}),"o");let vo=class Pt extends de{static{_(this,"Ke")}static{d(this,"He")}static{Lt(this,"e")}static{wo(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,Pt.prototype)}};var yo=Object.defineProperty,Tt=d((t,e)=>yo(t,"name",{value:e,configurable:!0}),"Ye"),bo=Object.defineProperty,$o=Tt((t,e)=>bo(t,"name",{value:e,configurable:!0}),"i");let M=class St extends de{static{_(this,"Qe")}static{d(this,"Je")}static{Tt(this,"e")}static{$o(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,St.prototype)}};var xo=Object.defineProperty,re=d((t,e)=>xo(t,"name",{value:e,configurable:!0}),"H"),No=Object.defineProperty,Ne=re((t,e)=>No(t,"name",{value:e,configurable:!0}),"o");const Qe=Ne(t=>t===Boolean||typeof t=="function"&&t.name==="Boolean","isBooleanType"),Xe=Ne(t=>t===Number||typeof t=="function"&&t.name==="Number","isNumberType"),et=Ne(t=>t===String||typeof t=="function"&&t.name==="String","isStringType"),Ao=Ne((t,e)=>Array.isArray(t)?Qe(e)?t.map(Boolean):Xe(e)?t.map(Number):et(e)?t.map(String):t.map(n=>e(String(n))):t===null?null:Qe(e)?!!t:Xe(e)?Number(t):et(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t)),"convertValue");var Eo=Object.defineProperty,ko=re((t,e)=>Eo(t,"name",{value:e,configurable:!0}),"e");const P=ko((t,e,n,...o)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...o)},"debug");var Oo=Object.defineProperty,ee=re((t,e)=>Oo(t,"name",{value:e,configurable:!0}),"x$2");const Co=/-([a-z])/g,_o=/^\d+$/,Oe=ee(t=>t===Boolean||typeof t=="function"&&t.name==="Boolean","isBooleanType"),Lo=ee(t=>t.codePointAt(0)===95,"isSpecialKey"),tt=ee((t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],"appendToArrayMultiple"),nt=ee(t=>t==="__proto__"||t==="constructor"||t==="prototype","isUnsafeKey"),ot=ee((t,e,n,o=!1)=>{t[e]===void 0?t[e]=o?[n]:n:o&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},"createOrAppendArray"),Po=ee((t,e,n,o,s)=>{let i=e.get(t)??n.get(t);if(!i&&o){const a=t.toLowerCase();i=o.get(a)??s?.get(a)}return i},"getDefinition"),To=ee((t,e,n,o)=>{const s=n.debug??!1;P(s,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),P(s,"Starting argument resolution","resolver"),P(s,"Tokens:","resolver",t),P(s,"Definitions:","resolver",e),P(s,"Processing tokens...","resolver");const i=new Map,a=new Map,l=n.caseInsensitive?new Map:void 0,h=n.caseInsensitive?new Map:void 0,r=n.camelCase?new Map:void 0,c=n.camelCase?new Map:void 0;for(const f of e)if(i.set(f.name,f),f.alias&&a.set(f.alias,f),n.caseInsensitive&&l&&(l.set(f.name.toLowerCase(),f),f.alias&&h&&h.set(f.alias.toLowerCase(),f)),n.camelCase&&r&&c){const w=f.name.replaceAll(Co,(b,N)=>N.toUpperCase());r.set(f.name,w),c.set(w,f.name)}const m={},p={},g=[],u=[],v=new Set;let $=!1;const y=e.find(f=>f.defaultOption),x=e.some(f=>f.group),E=e.some(f=>f.type===Number);for(let f=0;f<t.length;f++){const w=t[f];if(w.kind==="option-terminator"){m._unknown=o.slice(w.index),$=!0;break}if(w.kind==="option"&&w.name){let b=Po(w.name,i,a,l,h);if(!b&&w.value===void 0&&E&&_o.test(w.name)){const C=e.find(V=>V.type===Number);C&&(b=C,w.value=w.name,w.name=C.name)}const N=b?b.name:w.name,A=b?.multiple,j=b?.lazyMultiple;if(p[N]!==void 0&&!A&&!j&&!n.partial)throw new uo(N);if(!b&&n.partial){const C=w.rawName??`--${w.name}${w.value!==void 0&&w.inlineValue?`=${w.value}`:""}`;g.push({index:w.index,value:C});continue}if(!b&&n.stopAtFirstUnknown){m._unknown=o.slice(w.index);break}if(!b&&!n.partial)throw new Ze(w.name);if(w.value===void 0){const C=t[f+1],V=C?.kind==="option"&&!("name"in C)&&C.value!==void 0,T=C&&b&&!(b.type&&Oe(b.type))&&(C.kind==="positional"||V),nn=b&&b.defaultOption&&!b.multiple&&!b.lazyMultiple;if(T&&(!b?.defaultOption||nn))if(A){let B=f+1;const Ee=[];for(;B<t.length&&(t[B].kind==="positional"||t[B].kind==="option"&&!("name"in t[B])&&t[B].value!==void 0);)Ee.push(t[B].value),v.add(t[B].index),B++;p[N]=p[N]===void 0?Ee:tt(p[N],Ee),f=B-1}else j?(ot(p,N,C.value,!0),v.add(C.index),f++):(p[N]=C.value,v.add(C.index),f++);else b?.type&&Oe(b.type)?ot(p,N,!0,A):p[N]=A?[]:null}else{let{value:C}=w;if(b?.type&&Oe(b.type))switch(C){case"":{if(n.partial){p._unknown??=[];const T=`${w.rawName??`--${w.name}`}${w.value?`=${w.value}`:""}`;p._unknown.push(T),u.push({index:w.index,value:T}),C=!0}else throw new Ze(w.name);break}case"false":{C=!1;break}case"true":{C=!0;break}default:C=!0}const V=[C];if(A){let T=f+1;for(;T<t.length&&t[T].kind==="positional";)V.push(t[T].value),v.add(t[T].index),T++;f=T-1}p[N]===void 0?p[N]=A||j?V:C:A||j?p[N]=tt(p[N],V):p[N]=C}}else if(w.kind==="positional"&&n.stopAtFirstUnknown&&!v.has(w.index)&&!y){P(s,`Found unconsumed positional token at index ${String(w.index)}, stopping processing`,"resolver"),m._unknown=o.slice(w.index);break}}for(const[f,w]of Object.entries(p)){const b=i.get(f);b&&(b.multiple||b.lazyMultiple)&&!Array.isArray(w)&&(p[f]=[w])}let O=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!$){for(const f of t)if(f.kind==="option"&&!i.has(f.name??"")&&!a.has(f.name??"")&&(!n.caseInsensitive||!l?.has(f.name?.toLowerCase()??"")&&!h?.has(f.name?.toLowerCase()??""))){O=f.index;break}}if(y){const f=[],w=[];for(const b of t)b.kind==="positional"&&!v.has(b.index)&&b.index<O&&(f.push(b.value),w.push(b));if(f.length>0){const b=p[y.name],N=y.multiple??y.lazyMultiple;b===void 0?N?(w.forEach(A=>v.add(A.index)),p[y.name]=f):(v.add(w[0].index),p[y.name]=f[0]):N&&(w.forEach(A=>v.add(A.index)),p[y.name]=Array.isArray(b)?[...f,...b]:[...f,b])}}if(!n.partial){for(const f of t)if(f.kind==="positional"&&!v.has(f.index))throw new vo(o[f.index])}if(n.partial&&!n.stopAtFirstUnknown){const f=[...g];if(p._unknown)for(const w of u)f.push({index:w.index,value:w.value});for(const w of t)w.kind==="positional"&&!v.has(w.index)&&f.push({index:w.index,value:o[w.index]});f.length>0&&(f.sort((w,b)=>w.index-b.index),m._unknown=f.map(w=>w.value))}if(n.stopAtFirstUnknown&&!$){const f=t.findIndex(N=>N.kind==="option"&&!i.has(N.name??"")&&!a.has(N.name??"")&&(!n.caseInsensitive||!l?.has(N.name?.toLowerCase()??"")&&!h?.has(N.name?.toLowerCase()??""))),w=t.findIndex(N=>N.kind==="positional"&&!v.has(N.index));let b=-1;if(f!==-1&&w!==-1?b=Math.min(f,w):f!==-1?b=f:w!==-1&&(b=w),b>=0){const N=t[b].index;m._unknown=o.slice(N)}}else g.length>0&&!n.partial&&(m._unknown=g.map(f=>f.value));for(const[f,w]of Object.entries(p)){const b=n.camelCase?r?.get(f)??f:f,N=i.get(f);m[b]=N?.type?Ao(w,N.type):w===void 0?null:w}for(const f of e){const w=n.camelCase?r?.get(f.name)??f.name:f.name;!(w in m)&&f.defaultValue!==void 0&&(f.multiple??f.lazyMultiple?m[w]=Array.isArray(f.defaultValue)?[...f.defaultValue]:[f.defaultValue]:m[w]=f.defaultValue)}if(x){const f={},w={},b={};for(const A of e)if(A.group){const j=Array.isArray(A.group)?A.group:[A.group];for(const C of j)nt(C)||(f[C]??={})}for(const A of Object.keys(m))if(!Lo(A)){w[A]=m[A];let j=A;n.camelCase&&(j=c?.get(A)??A);const C=i.get(j);if(C?.group){const V=Array.isArray(C.group)?C.group:[C.group];for(const T of V)nt(T)||f[T]&&(f[T][A]=m[A])}else b[A]=m[A]}const N={_all:w};for(const[A,j]of Object.entries(f))N[A]=j;Object.keys(b).length>0&&(N._none=b),m._unknown&&(N._unknown=m._unknown),Object.keys(m).forEach(A=>delete m[A]),Object.assign(m,N)}return P(s,"Final parsed result:","resolver",m),m},"resolveArgs");var So=Object.defineProperty,ae=re((t,e)=>So(t,"name",{value:e,configurable:!0}),"l");const se="-".codePointAt(0),Y="=",Io=Y.codePointAt(0),Mo="--",jo="-",Uo="--",It=ae(t=>t.length>2&&t.startsWith(Uo),"hasLongOptionPrefix"),Do=ae(t=>It(t)&&!t.includes(Y,3),"isLongOption"),Vo=ae(t=>It(t)&&t.includes(Y,3),"isLongOptionAndValue"),Bo=ae(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"),Ro=ae(t=>!(t.length<=2||t.codePointAt(0)!==se||t.codePointAt(1)===se),"isShortOptionGroup"),zo=ae(t=>{const e=[],n=[...t];let o=-1,s=0;for(;n.length>0;){const i=n.shift();if(i===void 0)break;if(s>0?s--:o++,i===Mo){e.push({index:o,kind:"option-terminator"});const a=n.map((l,h)=>({index:o+h+1,kind:"positional",value:l}));e.push(...a),o+=n.length;break}if(Bo(i)){const a=i.charAt(1);e.push({index:o,kind:"option",name:a,rawName:i});continue}if(Ro(i)&&!i.includes(Y)){const a=[];let l="",h=!1;for(let r=1;r<i.length;r++){const c=i.charAt(r);h?l+=c:c.codePointAt(0)===Io?h=!0:a.push(`${jo}${c}`)}if(h)if(a.length>0){const r=a.pop();a.push(`${r}=${l}`)}else a.push(l);n.unshift(...a),s=a.length;continue}if(Do(i)){const a=i.slice(2);e.push({index:o,kind:"option",name:a,rawName:i});continue}if(Vo(i)){const a=i.indexOf(Y),l=i.slice(2,a),h=i.slice(a+1);e.push({index:o,inlineValue:!0,kind:"option",name:l,rawName:i,value:h});continue}if(i.length>2&&i.codePointAt(0)===se&&i.codePointAt(1)!==se&&i.includes(Y)){const a=i.indexOf(Y),l=i.charAt(1),h=i.slice(a+1);e.push({index:o,inlineValue:!0,kind:"option",name:l,rawName:i,value:h});continue}e.push({index:o,kind:"positional",value:i})}return e},"parseArgsTokens");var Fo=Object.defineProperty,je=re((t,e)=>Fo(t,"name",{value:e,configurable:!0}),"d");const Wo=/\d/,qo=je(t=>t===Boolean||typeof t=="function"&&t.name==="Boolean","isBooleanType"),Go=je(t=>typeof t=="function","isValidCustomTypeFunction"),Ho=je((t,e,n)=>{const o=n?.debug??!1;P(o,"Validating definitions:","validation",t,"caseInsensitive:",e);const s=new Set,i=new Set,a=new Set,l=new Set;let h=0;for(const r of t){if(P(o,"Checking definition:","validation",r),!r.name)throw P(o,"Validation failed: name is required","validation"),new M("Invalid option definition: name is required");if(typeof r.name!="string")throw new M("Invalid option definition: name must be a string");if(r.name.trim()==="")throw new M("Invalid option definition: name cannot be empty");const c=e?r.name.toLowerCase():"";if(s.has(r.name)||e&&a.has(c))throw new M(`Invalid option definition: duplicate name '${r.name}'`);if(i.has(r.name)||e&&l.has(c))throw new M(`Invalid option definition: name '${r.name}' conflicts with an existing alias`);if(s.add(r.name),e&&a.add(c),r.alias!==void 0){if(typeof r.alias!="string")throw new M("Invalid option definition: alias must be a string");if(r.alias.length!==1)throw new M("Invalid option definition: alias must be a single character");if(Wo.test(r.alias))throw new M("Invalid option definition: alias cannot be numeric");if(r.alias==="-")throw new M('Invalid option definition: alias cannot be "-"');const m=e?r.alias.toLowerCase():"";if(i.has(r.alias)||e&&l.has(m))throw new M(`Invalid option definition: duplicate alias '${r.alias}'`);if(s.has(r.alias)||e&&a.has(m))throw new M(`Invalid option definition: alias '${r.alias}' conflicts with an existing option name`);i.add(r.alias),e&&l.add(m)}if(r.defaultOption&&(h++,r.type!==void 0&&qo(r.type)))throw new M("Invalid option definition: defaultOption cannot be Boolean type");if(r.type!==void 0&&!(r.type===Boolean||r.type===Number||r.type===String||typeof r.type=="function"&&Go(r.type)))throw new M("Invalid option definition: invalid type")}if(h>1)throw P(o,"Validation failed: multiple defaultOptions not allowed","validation"),new M("Invalid option definition: multiple defaultOptions not allowed");P(o,"Validation completed successfully","validation")},"validateDefinitions");var Jo=Object.defineProperty,Ko=re((t,e)=>Jo(t,"name",{value:e,configurable:!0}),"O");const Yo=Ko((t,e={})=>{const n=e.debug??!1;P(n,"Starting command-line-args parsing","index"),P(n,"Options:","index",e);const o={...e};o.stopAtFirstUnknown&&(o.partial=!0);const s=Array.isArray(t)?t:[t];P(n,"Normalized definitions:","index",s),Ho(s,o.caseInsensitive,n?o:void 0);let{argv:i}=o;if(!i&&(i=process.argv.slice(2),process.execArgv.length>0)){const r=new Set(process.execArgv);i=i.filter(c=>!r.has(c))}P(n,"Using argv:","index",i);let a=i;o.caseInsensitive&&(a=i.map(r=>{if(r.startsWith("--")){const c=r.indexOf("="),m=(c===-1?r.slice(2):r.slice(2,c)).toLowerCase();return c===-1?`--${m}`:`--${m}${r.slice(c)}`}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>1){const c=r.slice(1).split("=",2),m=c[0],p=c[1];if(!m)return r;const g=m.toLowerCase();return p===void 0?`-${g}`:`-${g}=${p}`}return r}));const l=zo(a.map(String));P(n,"Tokenized arguments:","index",l);const h=To(l,s,o,i);return P(n,"Command-line-args parsing completed","index"),h},"commandLineArgs");class Zo{static{_(this,"Fn")}static{d(this,"Wn")}result;argv;options;argument;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;constructor(e,n){this.commandName=e,this.command=n}}let Ce=class extends k{static{_(this,"he")}static{d(this,"ce")}commandName;constructor(e,n,o){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.",o!==void 0&&(this.cause=o)}};const Qo=/^-{1,2}(\w+)(=(.+))?$/,Mt=d((t,e,n,o)=>{const s=Qo.exec(t);if(s===null)return{};const i=s[1];if(!i)return{};const a=n&&o?n.get(i)??o.get(i):e.find(l=>l.name===i||l.alias===i);return a!==void 0?{argName:a.name,argValue:s[3],option:a}:{}},"Ze"),it=d((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)},"Me"),Xo=new Set(["0","1","false","true"]),ei=d((t,e,n,o)=>{if(e.length===0||t.length===0)return{};const s=d((i,a)=>{const{argName:l,argValue:h,option:r}=Mt(a,e,n,o),{lastOption:c}=i;return r&&fe(r)&&h&&l?i.partial[l]=it(h,r):i.lastName&&c&&fe(c)&&Xo.has(a)&&(i.partial[i.lastName]=it(a,c)),{lastName:l,lastOption:r,partial:i.partial}},"s");return t.reduce(s,{partial:{}}).partial},"Gn"),ti=new Set(["0","1","false","true"]),ni=d((t,e,n,o)=>{if(e.length===0||t.length===0)return t;const s=d((i,a)=>{const{argValue:l,option:h}=Mt(a,e,n,o),{lastOption:r}=i;if(r&&fe(r)&&ti.has(a)){const{args:c}=i;return{args:c.slice(0,-1)}}return h&&fe(h)&&l?{args:i.args}:{args:[...i.args,a],lastOption:h}},"s");return t.reduce(s,{args:[]}).args},"Hn"),oi=d(t=>{const e=new Map;for(const n of t){const o=e.get(n.name);o?e.set(n.name,{...o,...n}):e.set(n.name,n)}return[...e.values()]},"De"),ii=d(t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},"Yn"),si=d((t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return ii(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)}},"Jn"),ri=/_./g,ai=/^[A-Z]/,li=d(t=>t.toLowerCase().replaceAll(ri,e=>e[1]?.toUpperCase()??e).replace(ai,e=>e.toLowerCase()),"Xn"),ci=d(t=>{if(!t||t.length===0)return{};const e={},n=q();for(const o of t){const s=n[o.name],i=si(o,s),a=i===void 0?o.defaultValue:i,l=li(o.name);e[l]=a}return e},"eo"),ui=d(t=>{const e=new Map,n=new Map;for(const o of t)if(e.set(o.name,o),o.alias){const s=Array.isArray(o.alias)?o.alias:[o.alias];for(const i of s)n.set(i,o)}return{optionMapByAlias:n,optionMapByName:e}},"to"),jt=d(async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new Ce(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(o){throw new Ce(t.name,o instanceof Error?o.message:String(o),o)}const n=e.default;if(typeof n!="function")throw new Ce(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},"Xe"),pi=d((t,e,n,o)=>{const s=new Zo(t.name,t),{_all:i,_unknown:a,positionals:l}=e,h=Object.keys(n).length>0?{...i,...n}:i;ye in h&&delete h[ye],s.argument=l?.[ye]??[],s.rawUnknown=[...a??[]];const r=Object.keys(o).length>0;return s.options=r?{...h,...o}:h,s.env=ci(t.env),s},"no"),hi=d((t,e,n)=>{const o=t.options??[],s=o.length>0;let i=oi(s?[...o,...n]:n);if(i.length>0){for(const r of i)if(r.multiple&&r.lazyMultiple)throw new Error(`Argument "${r.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}t.argument&&(i=[{defaultOption:!0,description:t.argument.description,group:"positionals",multiple:!0,name:ye,type:t.argument.type,typeLabel:t.argument.typeLabel},...i]);let a,l;if(s){const{optionMapByAlias:r,optionMapByName:c}=ui(o);a=ni(e,o,c,r),l=ei(e,o,c,r)}else a=e,l={};const h=Yo(i,{argv:a,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:i,booleanValues:l,parsedArgs:h}},"oo"),ne=d(async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await jt(t))(e),"F");let fi=class extends k{static{_(this,"ao")}static{d(this,"io")}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(", ")}`}};const st=d((t,e,n=!1)=>{const o=[];for(const s of t)if(!(!n&&!s.required)&&e[s.name]===void 0){if(s.type?.name==="Boolean"){e[s.name]=!1;continue}o.push(s)}return o},"Te"),di=d((t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:$t(t,e)<=t.length/3,"so"),K=d((t,e)=>{const n=t.toLowerCase();return e.filter(o=>di(o.toLowerCase(),n))},"S"),mi=d((t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(o=>{const s=o.startsWith("--");let i=`Found unknown ${s?"option":"argument"} "${o}"`;if(s){const a=K(o.replace("--",""),(e.options??[]).map(l=>l.name));if(a.length>0){const[l,...h]=a.map(r=>`--${r}`);i+=h.length>0?`, did you mean ${l??""} or ${h.join(", ")}?`:`, did you mean ${l??""}?`}}n.push(i)}),n.length>0)throw new Error(n.join(`
4
+ `))},"ao"),gi=d((t,e,n)=>{const o=n.__requiredOptions__,s=o?st(o,e,!0):st(t,e,!1);if(s.length>0)throw new fi(n.name,s.map(i=>i.name));e._unknown&&e._unknown.length>0&&!n.argument&&mi(e,n)},"ro"),wi=d((t,e,n)=>{const o=n.__conflictingOptions__??t.filter(s=>s.conflicts!==void 0);if(o.length>0){const s=o.find(i=>Array.isArray(i.conflicts)?i.conflicts.some(a=>e[a]!==void 0)&&e[i.name]!==void 0:e[i.conflicts]!==void 0&&e[i.name]!==void 0);if(s)throw new Et(s.name,typeof s.conflicts=="string"?s.conflicts:s.conflicts?.[0]??"unknown")}},"lo"),vi=d(t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const s of t.options){if(s.name){const i=e.get(s.name)??[];i.push(s),e.set(s.name,i)}if(typeof s.alias=="string"&&s.alias.length>0){const i=n.get(s.alias)??[];i.push(s),n.set(s.alias,i)}else if(Array.isArray(s.alias)){for(const i of s.alias)if(i.length>0){const a=n.get(i)??[];a.push(s),n.set(i,a)}}}const o=[];for(const[s,i]of e)i.length>1&&o.push(`Duplicate option name "${s}" in command "${t.name}": ${JSON.stringify(i)}`);for(const[s,i]of n)i.length>1&&o.push(`Duplicate option alias "-${s}" used by options ${i.map(a=>`"${a.name}"`).join(", ")} in command "${t.name}"`);if(o.length>0)throw new Error(o.join(`
5
+ `))},"co"),yi=d((t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];let o;for(let s=1;s<=e.length;s+=1){const i=e[s-1];if(i===void 0||i.startsWith("-"))break;n.push(i);const a=n.join(" ");t.has(a)&&(o={commandPath:[...n],depth:s})}return o?{argv:e.slice(o.depth),commandPath:o.commandPath}:{argv:e,commandPath:void 0}},"uo"),J=d(t=>t.join(" "),"V"),rt=d((t,e)=>e&&e.length>0?[...e,t]:[t],"Ve");class bi{static{_(this,"fo")}static{d(this,"ho")}capacity;cache;constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const n=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,n),n}has(e){return this.cache.has(e)}set(e,n){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){const o=this.cache.keys().next().value;o!==void 0&&this.cache.delete(o)}this.cache.set(e,n)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}}const $i=d((t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),"po"),xi=Qn(import.meta.url),ue=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ni=d(t=>{if(typeof ue<"u"&&ue.versions&&ue.versions.node){const[e,n]=ue.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ue.getBuiltinModule(t)}return xi(t)},"mo"),{stripVTControlCharacters:Ai}=Ni("node:util"),_e=new bi(1e3),Ei=/[.*+?^${}()|[\]\\]/g,ki=d(t=>{const e=t.join("");if(_e.has(e)){const s=_e.get(e);return s.lastIndex=0,s}const n=t.map(s=>s.replaceAll(Ei,String.raw`\$&`)).join("|"),o=new RegExp(n,"g");return _e.set(e,o),o},"yo"),Oi=d(t=>{const e=[];let n=0,o;for(G.lastIndex=0;(o=G.exec(t))!==null;)o.index>n&&e.push(t.slice(n,o.index)),e.push(o[0]),n=G.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},"vo"),Ci=/[ČŠŽĐ]/i,Ut=new Uint8Array(128),Dt=new Uint8Array(128),Vt=new Uint8Array(128);for(let t=0;t<128;t++)Ut[t]=t>=65&&t<=90?1:0,Dt[t]=t>=97&&t<=122?1:0,Vt[t]=t>=48&&t<=57?1:0;const Le=d(t=>Ut[t],"he"),at=d(t=>Dt[t],"Se"),Pe=d(t=>Vt[t],"pe"),W=d((t,e,n,o,s)=>{if(t.length===0)return[];let i=!1;const a=Object.values(e);for(const g of a)if(g(t[0])){i=!0;break}if(!i&&!n)return[t];const l=[...t],h=[];let r=l[0],c="other";const m=Object.entries(e);for(const g of m){const[u,v]=g;if(v(l[0])){c=u;break}}let p=n&&o?l[0]===l[0].toLocaleUpperCase(o):!1;for(let g=1;g<l.length;g++){const u=l[g];let v="other";for(const x of m){const[E,O]=x;if(O(u)){v=E;break}}const $=n&&o?u===u.toLocaleUpperCase(o):!1;let y=!1;s?y=s(c,v,p,$,u,g,l):(c!==v&&c!=="other"&&v!=="other"&&(y=!0),n&&v!=="other"&&!p&&$&&(y=!0)),y?(h.push(r),r=u):r+=u,c=v,n&&(p=$)}return r&&r.length>0&&h.push(r),h.length>0?h:[t]},"D"),_i=d((t,e,n,o)=>{if(n.size===0)return e;for(const s of n)if(t.startsWith(s,e))return o.push(s),e+s.length;return e},"$o"),Bt=d((t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const o=[],s=t.length;for(let i=1;i<s;i++){const a=_i(t,n,e,o);if(a!==n){n=a,i=n-1;continue}const l=t.codePointAt(i-1),h=t.codePointAt(i),r=l&&l<128&&Le(l),c=h&&h<128&&Le(h),m=l&&l<128&&at(l),p=l&&l<128&&Pe(l),g=h&&h<128&&Pe(h);if(m&&c){o.push(t.slice(n,i)),n=i;continue}if(p&&!g||!p&&g){o.push(t.slice(n,i)),n=i;continue}if(g&&!p){let u=!1,v=!1;if(i+1<s){const $=t.codePointAt(i+1);u=$&&$<128&&Le($),v=$&&$<128&&Pe($)}if(!v&&u){o.push(t.slice(n,i),t.slice(i,i+1)),n=i+1;continue}}if(i+1<s){const u=t.codePointAt(i+1),v=u&&u<128&&at(u);if(r&&c&&v){const $=t.slice(n,i+1);e.has($)||(o.push(t.slice(n,i)),n=i)}}}return n<s&&o.push(t.slice(n)),o.filter(i=>i!=="")},"ot"),Rt=d((t,e,n)=>{if(t.length===0)return[];const o=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!o&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const r=[...t],c=r.length,m=[];let p=r[0],g=r[0]===r[0].toLocaleUpperCase(e),u=g,v=g?0:-1;for(let $=1;$<c;$++){const y=r[$],x=y===y.toLocaleUpperCase(e);if(x===g)p+=y;else if(x)p&&p.length>0&&(m.push(p),p=y),u=!0,v=$;else{if(u&&$-v>1){const E=r[$-1],O=p.slice(0,-1);O&&O.length>0&&m.push(O),p=E+y}else p+=y;u=!1,v=-1}g=x}return p&&p.length>0&&m.push(p),m}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!te.test(t)&&!I.test(t))return[t];const r=[...t],c=r.length,m=[];let p=r[0];const g=r[0];let u;te.test(g)?u=1:I.test(g)?u=2:u=0;let v=g===g.toLocaleUpperCase(e);for(let y=1;y<c;y++){const x=r[y];let E;te.test(x)?E=1:I.test(x)?E=2:E=0;const O=x===x.toLocaleUpperCase(e);u!==E&&(u===1||u===2)&&(E===1||E===2)||E===u&&!v&&O?(m.push(p),p=x):p+=x,u=E,v=O}p&&p.length>0&&m.push(p);const $=[];for(let y=0;y<m.length;y++)y<m.length-1&&m[y].length===1&&I.test(m[y])&&te.test(m[y+1][0])?($.push(m[y]+m[y+1]),y+=1):$.push(m[y]);return $}if(e.startsWith("el")){if(!ke.test(t)&&!I.test(t))return[t];const r=[];We.lastIndex=0;let c;for(;(c=We.exec(t))!==null;)r.push(c[0]);r.length===0&&r.push(t);const m=[];if(r.length===1){const p=r[0];if(!p||!ke.test(p[0])||p.length===1)return[p??t]}for(const p of r){if(!p)continue;if(!ke.test(p[0])||p.length===1){m.push(p);continue}const g=p.length;let u=p[0],v=p[0]===p[0].toLocaleUpperCase(e);for(let $=1;$<g;$++){const y=p[$],x=y===y.toLocaleUpperCase(e);!v&&x?(m.push(u),u=y):u+=y,v=x}u&&m.push(u)}return m}if(e.startsWith("ja")||e.startsWith("ko")){const r=e.startsWith("ja"),c=r?{hiragana:d(p=>Ln.test(p),"hiragana"),kanji:d(p=>He.test(p),"kanji"),katakana:d(p=>Tn.test(p),"katakana"),latin:d(p=>I.test(p),"latin")}:{hangul:d(p=>qe.test(p),"hangul"),latin:d(p=>I.test(p),"latin")},m=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(r){const p=W(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")),g=[];for(const u of p){const v=u;v.length===1&&m.has(v)&&g.length>0?g[g.length-1]=g.at(-1)+v:g.push(v)}return g.length>0?g:[t]}return W(t,c,!1,e,(p,g)=>p==="hangul"&&g==="latin"||p==="latin"&&g==="hangul")}if(e.startsWith("sl")){const r=[...t],c=r.length,m=[];let p=r[0],g=r[0]===r[0].toLocaleUpperCase(e);for(let u=1;u<c;u++){const v=r[u],$=v===v.toLocaleUpperCase(e),y=Ci.test(v),x=u<c-1&&r[u+1]===r[u+1].toLocaleUpperCase(e);!g&&$||y&&x?(m.push(p),p=v,y&&x&&(m.push(p),p="")):p+=v,g=$}return p&&p.length>0&&m.push(p),m}if(e.startsWith("zh"))return W(t,{han:d(r=>He.test(r),"han"),latin:d(r=>I.test(r),"latin")},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const r=d(c=>Ge.test(c)||Fe.test(c),"a");return W(t,{latin:d(c=>I.test(c),"latin"),rtl:d(c=>r(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 r=d(c=>kn.test(c)||En.test(c)||Cn.test(c)||_n.test(c)||Pn.test(c)||Vn.test(c)||Bn.test(c)||Mn.test(c)||Dn.test(c)||Rn.test(c)||In.test(c)||zn.test(c)||jn.test(c)||On.test(c)||Sn.test(c)||Un.test(c),"a");return W(t,{indic:d(c=>r(c),"indic"),latin:d(c=>I.test(c),"latin")},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return W(t,{cyrillic:d(r=>te.test(r),"cyrillic"),latin:d(r=>I.test(r),"latin")},!0,e);if(["ar","fa","he"].includes(e))return W(t,{latin:d(r=>I.test(r),"latin"),rtl:d(r=>Ge.test(r)||Fe.test(r),"rtl")},!1,e);if(e.startsWith("ko"))return W(t,{hangul:d(r=>qe.test(r),"hangul"),latin:d(r=>I.test(r),"latin")},!1,e);if(e.startsWith("uz")){if(!te.test(t)&&!I.test(t))return[t];const r=[...t],c=r.length,m=[];let p=r[0],g=r[0]===r[0].toLocaleUpperCase(e);for(let u=1;u<c;u++){const v=r[u],$=v===v.toLocaleUpperCase(e);if(Je.test(v)||Je.test(r[u-1])){p+=v;continue}!g&&$?(m.push(p),p=v):p+=v,g=$}return p&&p.length>0&&m.push(p),m}const s=[...t],i=s.length,a=[];let l=s[0],h=s[0]===s[0].toLocaleUpperCase(e);for(const r of n)if(t.startsWith(r)){a.push(r),l=s[r.length],h=l===l.toLocaleUpperCase(e);break}for(let r=1;r<i;r++){const c=s[r],m=c===c.toLocaleUpperCase(e);let p=0;for(const g of n)if(t.startsWith(g,r)){a.push(l,g),p=g.length,l="";const u=g.at(-1);u&&(h=u===u.toLocaleUpperCase(e));break}if(p>0){r+=p-1;continue}!h&&m?(a.push(l),l=c):l+=c,h=m}return l&&a.push(l),a},"it"),Li=d((t,e,n)=>{const o=[],s=be.test(t)?t.split(be).filter(Boolean):[t];for(const i of s){const a=i;if(be.test(a))o.push(a);else{G.lastIndex=0;const l=G.test(a)?Oi(a).filter(Boolean):[a];for(const h of l)if(G.lastIndex=0,G.test(h))o.push(h);else if(e){const r=e.toLowerCase().split("-")[0];o.push(...Rt(h,r,n))}else o.push(...Bt(h,n))}}return o},"Oo"),Pi=d((t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:o=!1,knownAcronyms:s=[],locale:i,normalize:a=!1,separators:l,stripAnsi:h=!1,stripEmoji:r=!1}=e,c=new Set([...s].toSorted((y,x)=>x.length-y.length));let m=t;h&&(m=Ai(m)),r&&(m=Fn(m));let p;Array.isArray(l)?p=ki(l):l instanceof RegExp?p=l:p=An;const g=[];let u=m;const v=p.flags.includes("g")?p:new RegExp(p.source,`${p.flags}g`);for(;u.length>0;){const y=v.exec(u);if(!y){u===".."?g.push(".."):u==="."?g.push("."):u.length>0&&g.push(u);break}const x=y.index,E=y[0],O=E.length,f=u.slice(0,x),w=u.slice(x+O);if(E.startsWith("../"))g.push(".."),u=u.slice(x+3);else if(E.startsWith("./"))g.push("."),u=u.slice(x+2);else if(x===0&&E==="..")g.push(".."),u=u.slice(2);else if(x===0&&E===".")g.push("."),u=u.slice(1);else{f.length>0&&g.push(f);let b=0;for(;(b=E.indexOf("../",b))!==-1;)g.push(".."),b+=3;for(b=0;(b=E.indexOf("./",b))!==-1;)(b===0||E[b-1]!==".")&&g.push("."),b+=2;let N=w;for(;N.startsWith("../");)g.push(".."),N=N.slice(3);for(;N.startsWith("./");)g.push("."),N=N.slice(2);if(N===".."){g.push("..");break}else if(N==="."){g.push(".");break}else u=N}v.lastIndex=0}if(g.length===0){const y=m.split(p).filter(Boolean);g.push(...y)}let $=[];for(const y of g)n||o?$.push(...Li(y,i,c)):i?$.push(...Rt(y,i,c)):$.push(...Bt(y,c));return a&&($=$.map(y=>c.has(y)?y:i&&y===y.toLocaleUpperCase(i)?y[0]+y.slice(1).toLocaleLowerCase(i):y.toUpperCase()===y&&!c.has(y)?y.slice(0,1)+y.slice(1).toLowerCase():y)),$},"Ao"),Ti=d((t,e)=>typeof t!="string"||t===""?"":t[0].toUpperCase()+t.slice(1),"No"),Si=d((t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const o=[];let s="",i="";for(let a=0;a<n;a++){const l=t[a];if(be.test(l)){s?(o.push(s+i+l),s="",i=""):(o.length>0&&o.push(e),s=l);continue}s?(i&&(i+=e),i+=l):(o.length>0&&o.push(e),o.push(l))}return o.join("")},"Co"),zt=d((t,e)=>{if(typeof t!="string"||!t)return"";let n=!0;return Si(Pi(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(o=>{const s=o,i=s.toLowerCase();return n?(n=!1,$i(i)):Ti(i)}),"")},"st"),Ii=d(t=>{t.options?.forEach(e=>{e.__camelCaseName__=zt(e.name)})},"_o"),Mi=d(t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const o of t.options)e.add(o.name);const n=[];for(const o of t.options)if(o.name.startsWith("no-")){const s=o.name.replace(/^no-/,"");if(!e.has(s)){if(o.type!==Boolean)throw new Error(`Cannot add negated option "${o.name}" to command "${t.name}" because it is not a boolean.`);const i={...o,defaultValue:o.defaultValue===void 0?!0:!o.defaultValue,name:s};n.push(i),e.add(s)}}n.length>0&&t.options.push(...n)},"ko"),ji=d((t,e)=>{if(!e.options||e.options.length===0)return;const{options:n}=t,o=new Map;for(const i of e.options)if(i.name.startsWith("no-")){const a=zt(i.name);o.set(a,i)}const s=Object.keys(n).filter(i=>o.has(i));if(s.length!==0)for(const i of s){const a=i.charAt(2);if(!a)continue;const l=a.toLowerCase()+i.slice(3),h=o.get(i);h&&(h.__negated__=!0),n[l]=!n[i],Reflect.deleteProperty(n,i)}},"xo"),Ui=d((t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const s of e.options)s.__camelCaseName__&&s.__negated__===void 0&&s.implies!==void 0&&n.set(s.__camelCaseName__,s);if(n.size===0)return;const{options:o}=t;for(const s of Object.keys(o)){const i=n.get(s);if(i?.implies){const{implies:a}=i;for(const[l,h]of Object.entries(a))o[l]===void 0&&(o[l]=h)}}},"Io"),Di=d(()=>!!process.versions.electron,"Lo"),Vi=d(()=>Di()&&!process.defaultApp,"Eo"),Bi=d(()=>Vi()?0:1,"Po"),Ri=d(t=>t.slice(Bi()+1),"Uo"),zi=" ",Fi=d((t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,o)=>n===e[o]),"Do"),Wi=d(t=>{if(typeof t=="string")return t.split(zi);const e=$e();return Fi(t,e)?Ri(t):t},"To"),qi=d(t=>{const e=d(i=>{t.error(`Uncaught exception: ${i.message||i}`),i.stack&&t.error(i.stack),z(1)},"e"),n=d((i,a)=>{if(i instanceof Error)t.error(`Promise rejection: ${i.message||i}`),i.stack&&t.error(i.stack);else{let l;if(typeof i=="string")l=i;else try{l=JSON.stringify(i)}catch{l=String(i)}t.error(`Promise rejection: ${l}`)}z(1)},"n"),o=Re("uncaughtException",e),s=Re("unhandledRejection",n);return()=>{o(),s()}},"Vo"),lt=100,Gi=/^[a-z][\w-]*$/i,Ie=d((t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new k(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},"ge"),ct=d((t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new k(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},"Be"),Te=d((t,e)=>{if(typeof t!="object"||t===null)throw new k(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},"fe"),we=d(t=>{const e=Ie(t,"Command name");if(e.length>lt)throw new k(`Command name is too long (maximum ${String(lt)} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new k(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!Gi.test(e))throw new k(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},"ee"),Hi=new Set([`
6
+ `,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),Ji=d((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(Hi.has(n))throw new Error(`Argument contains dangerous character: ${n}`)}return t.trim()},"Bo"),ut=d((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=>Ji(n,e))},"Re"),Ki=/^-([^\d-])$/,Yi=/^--(\S+)/,Zi=/^-([^\d-]{2,})$/,Se=d(t=>Ki.test(t)||Yi.test(t)||Zi.test(t),"de"),Qi={access:d((t,e)=>Zn(t,e),"access"),mkdir:d((t,e)=>Yn(t,e),"mkdir"),readdir:d(t=>Kn(t),"readdir"),readFile:d((async(t,e)=>e===void 0?Ke(t):Ke(t,e)),"readFile"),rm:d((t,e)=>Jn(t,e),"rm"),stat:d(t=>Hn(t),"stat"),writeFile:d((t,e,n)=>Gn(t,e,n),"writeFile")};let Xi=class Ft{static{_(this,"ve")}static{d(this,"at")}#t;#e;#c;#u;#h;#f;#y;#b;#$;#x;#N;#p;#n;#o;#i;#s;#r;#d=!1;#A;#E=!1;#m;#g;#w;#l=[];#L(){return this.#m===void 0&&(this.#m=[...this.#o.keys()]),this.#m}#k(){return this.#g===void 0&&(this.#g=[...this.#n.keys()]),this.#g}#a(){return this.#w===void 0&&(this.#w=[...this.#L(),...this.#k()]),this.#w}#O(){return this.#l.length===0?ge:[...ge,...this.#l]}#C(){this.#m=void 0,this.#g=void 0,this.#w=void 0}#v(){if(this.#c===void 0){const e=Wi(this.#e.argv);this.#c=ut(e,!1),this.#P()}return this.#c}#P(){if(!this.#c)return;const e=q();let n=!1;for(const o of this.#c){if(o==="--quiet"||o==="-q"){e.CEREBRO_OUTPUT_LEVEL=String(ln),n=!0;break}if(o==="--verbose"||o==="-v"){e.CEREBRO_OUTPUT_LEVEL=String(cn),n=!0;break}if(o==="--debug"){e.CEREBRO_OUTPUT_LEVEL=String(oe),n=!0;break}}n||(e.CEREBRO_OUTPUT_LEVEL=Object.hasOwn(e,"DEBUG")?String(oe):String(Be))}#T(){this.#E||(this.#A=qi(this.#t),this.#E=!0)}#S(){return{arch:vn(),argv:this.#v(),cwd:this.#u,env:this.#x??q(),exit:this.#$??(e=>z(e??0)),platform:wn(),stdin:this.#N}}#_(e,n,o,s){this.#t.debug(`command '${s}' found, parsing command args: ${n.join(", ")}`);const{arguments_:i,booleanValues:a,parsedArgs:l}=hi(e,n,this.#O()),h=Object.keys(a).length>0;let r=l;h&&(r={...l,_all:{...l._all,...a}}),gi(i,r,e);const c=pi(e,l,a,o);c.runtime=this,c.argv=this.#v(),c.fs=this.#b??Qi,c.process=this.#S(),c.console=this.#t;const m=e.options&&e.options.length>0;if(m&&e.options){const p=e.options.filter(g=>g.name.startsWith("no-"));for(const g of p){const u=g.name.replace(/^no-/,""),v=`--${g.name}`,$=`--${u}`,y=n.includes(v),x=n.includes($);if(y&&x)throw new Et(u,g.name)}}return m&&(ji(c,e),Ui(c,e)),wi(i,c.options,e),q().CEREBRO_OUTPUT_LEVEL===String(oe)&&(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_:i,booleanValues:a,commandArgs:r,parsedArgs:l,toolbox:c}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new k("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#h=e.trim();const o=n.argv??$e(),s=n.cwd??gn();if(this.#e={...n,argv:o,cwd:s},this.#e.argv&&!Array.isArray(this.#e.argv))throw new k("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 k("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new k("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new k("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});const i=q();if(i.CEREBRO_OUTPUT_LEVEL=String(Be),typeof this.#e.logger=="object"){const c=["debug","error","info","log","warn"],m=[],p=this.#e.logger;for(const g of c)typeof p[g]!="function"&&m.push(g);if(m.length>0)throw new k(`Logger object is missing required methods: ${m.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:m});this.#t=this.#e.logger}else this.#t={...console,debug:d((...c)=>{i.CEREBRO_OUTPUT_LEVEL===String(oe)&&console.debug(...c)},"debug")};this.#f=this.#e.packageVersion,this.#y=this.#e.packageName,this.#u=this.#e.cwd,this.#s="help",this.#r={};const a=n.fs;if(a!==void 0&&(typeof a!="object"||a===null))throw new k("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 k("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const h=n.env;if(h!==void 0&&(typeof h!="object"||h===null))throw new k("CLI env option must be a record of string keys","INVALID_INPUT",{env:n.env});const r=n.stdin;if(r!==void 0&&typeof r!="string")throw new k("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#b=n.fs,this.#$=n.exit,this.#x=n.env,this.#N=n.stdin??"",this.#n=new Map,this.#o=new Map,this.#i=new Map}setCommandSection(e){return this.#r=e,this}getCommandSection(){return this.#r.header||(this.#r.header=`${this.#h}${this.#f?` v${this.#f}`:""}`),this.#r}setDefaultCommand(e){return this.#s=e,this}get defaultCommand(){return this.#s}addCommand(e){Te(e,"Command"),we(e.name);const n=typeof e.execute=="function",o=typeof e.loader=="function";if(n&&o)throw new k(`Command "${e.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:e.name});if(!n&&!o)throw new k(`Command "${e.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:e.name});e.alias&&(typeof e.alias=="string"?we(e.alias):ct(e.alias,"Command alias").forEach(r=>we(r))),e.argument&&Te(e.argument,"Command argument"),e.options&&Te(e.options,"Command options"),e.commandPath&&(ct(e.commandPath,"Command commandPath"),e.commandPath.forEach(r=>{we(r)}));const s=rt(e.name,e.commandPath),i=J(s);if(this.#o.has(i))throw new k(`Command with path "${i}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});const a=Array.isArray(e.commandPath)&&e.commandPath.length>0,l=this.#n.get(e.name),h=l!==void 0&&(l.commandPath===void 0||l.commandPath.length===0);if(!a&&h)throw new k(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const r of e.options)Ye(r);if(vi(e),Mi(e),Ii(e),e.options&&(e.__conflictingOptions__=e.options.filter(r=>r.conflicts!==void 0),e.__requiredOptions__=e.options.filter(r=>r.required===!0)),a&&l!==void 0)this.#n.set(i,e);else{if(!a&&l!==void 0&&!h){const r=rt(l.name,l.commandPath);this.#n.set(J(r),l)}this.#n.set(e.name,e)}if(this.#o.set(i,s),this.#i.set(i,e),this.#C(),e.alias!==void 0){const r=typeof e.alias=="string"?[e.alias]:e.alias;for(const c of r){if(q().CEREBRO_OUTPUT_LEVEL===String(oe)&&this.#t.debug("adding alias",c),this.#n.has(c))throw new k(`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,o=new Set(ge.map(i=>i.name)),s=new Set(ge.map(i=>i.alias).filter(Boolean));if(o.has(n.name))throw new k(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&s.has(n.alias))throw new k(`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(i=>i.name)).has(n.name))throw new k(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",Ye(n),this.#l.push(n),this}getGlobalOptions(){return this.#O()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#p?this.#p:(this.#p=new eo(this.#t),this.#p.register({description:"Attaches the logger to the toolbox",execute:d(e=>{e.logger=this.#t,e.console=e.logger},"execute"),name:"logger"}),this.#p)}getCliName(){return this.#h}getPackageVersion(){return this.#f}getPackageName(){return this.#y}getCommands(){return this.#n}getCwd(){return this.#u}dispose(){this.#A?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:o=!0,...s}=e;if(!this.#n.has("help")){const{default:f}=await import("../packem_chunks/help-command.js");this.addCommand(new f(this.#n))}const i=this.#k(),a=this.#o;this.#T();const l=this.#v();let h,r=[...l];const c=bt(),m=yt(),p=$e();this.#t.debug(`process.execPath: ${c}`),this.#t.debug(`process.execArgv: ${m.join(" ")}`),this.#t.debug(`process.argv: ${p.join(" ")}`);const g=yi(a,[...l]);if(g.commandPath)h=g.commandPath,r=g.argv;else{if(l.length>1&&l[0]&&l[1]&&!Se(l[0])&&!Se(l[1])){const w=[];let b=0;for(;b<l.length;){const A=l[b];if(!A||Se(A))break;w.push(A),b+=1}const N=J(w);if(w[0]&&!i.includes(w[0])){const A=this.#a(),j=K(N,A);throw new H(N,j)}}let f;try{f=ro([null,...i],[...l])}catch(w){if(w instanceof Error&&w.name==="INVALID_COMMAND"&&"command"in w){const b=w.command,N=this.#a(),A=K(b,N);throw new H(b,A)}throw w}f.command&&(h=[f.command],r=f.argv)}if(!h)if(this.#s)h=[this.#s];else{const f=this.#a();throw new H("",f)}const u=J(h),v=this.#o.get(u);let $;if(v){if($=this.#i.get(u),!$||J(v)!==u){const f=this.#a(),w=K(u,f);throw new H(u,w)}}else{const f=h.at(-1);if($=f?this.#n.get(f):void 0,!$){const w=this.#a(),b=K(u,w);throw new H(u,b)}}if(typeof $.execute!="function"&&typeof $.loader!="function")return this.#t.error(`Command "${$.name}" has no function to execute.`),o?z(1):void 0;const y=r;let x,E;try{({commandArgs:x,toolbox:E}=this.#_($,y,s,u))}catch(f){if(this.#t.error(f),o)return z(1);throw f}const O=this.getPluginManager();try{!this.#d&&O.hasPlugins()&&(await O.init({cli:this,cwd:this.#u,logger:this.#t}),this.#d=!0),await O.executeLifecycle("execute",E),await O.executeLifecycle("beforeCommand",E);let f;const w=x.global;if(w?.help){const b=this.#n.get("help");if(!b)throw new k("Help command not found","COMMAND_NOT_FOUND");f=await ne(b,E)}else if(w?.version??w?.V){const b=this.#n.get("version");if(!b)throw new k("Version command not found","COMMAND_NOT_FOUND");f=await ne(b,E)}else f=await ne($,E);return await O.executeLifecycle("afterCommand",E,f),o?z(0):void 0}catch(f){throw await O.executeErrorHandlers(f,E),f}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:o=[],...s}=n;Ie(e,"Command name");const i=e.split(" ").filter(Boolean),a=J(i),l=this.#o.get(a)?this.#i.get(a):this.#n.get(e);if(!l){const p=this.#a(),g=K(a||e,p);throw new H(e,g)}if(typeof l.execute!="function"&&typeof l.loader!="function")throw new k(`Command "${l.name}" has no function to execute`,"INVALID_COMMAND",{commandName:l.name});const h=[...ut(o,!1)];this.#t.debug(`running command '${e}' programmatically with args: ${h.join(", ")}`);const{commandArgs:r,toolbox:c}=this.#_(l,h,s,a||e),m=this.getPluginManager();try{!this.#d&&m.hasPlugins()&&(await m.init({cli:this,cwd:this.#u,logger:this.#t}),this.#d=!0),await m.executeLifecycle("execute",c),await m.executeLifecycle("beforeCommand",c);let p;const g=r.global;if(g?.help){const u=this.#n.get("help");if(!u)throw new k("Help command not found","COMMAND_NOT_FOUND");p=await ne(u,c)}else if(g?.version??g?.V){const u=this.#n.get("version");if(!u)throw new k("Version command not found","COMMAND_NOT_FOUND");p=await ne(u,c)}else p=await ne(l,c);return await m.executeLifecycle("afterCommand",c,p),p}catch(p){throw await m.executeErrorHandlers(p,c),p}}clone(e){const n={...this.#e,...e},o=new Ft(this.#h,n);for(const[s,i]of this.#n)o.#n.set(s,i);for(const[s,i]of this.#o)o.#o.set(s,[...i]);for(const[s,i]of this.#i)o.#i.set(s,i);for(const s of this.#l)o.#l.push(s);return o.#s=this.#s,o.#r={...this.#r},o.#C(),o}async getAction(e){Ie(e,"Command name");const n=e.split(" ").filter(Boolean),o=J(n),s=this.#o.get(o)?this.#i.get(o):this.#n.get(e);if(!s){const i=this.#a(),a=K(o||e,i);throw new H(e,a)}if(typeof s.execute=="function")return s.execute;if(typeof s.loader=="function")return jt(s);throw new k(`Command "${s.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:s.name})}};var es=Object.defineProperty,ts=_((t,e)=>es(t,"name",{value:e,configurable:!0}),"r");const Nr=ts((t,e)=>new Xi(t,e),"m");var ns=Object.defineProperty,os=_((t,e)=>ns(t,"name",{value:e,configurable:!0}),"c$1");const Ar=os(()=>{try{const t=require("node:module");if(typeof t.enableCompileCache=="function"){t.enableCompileCache();return}}catch{}try{require("v8-compile-cache")}catch{}},"t");var is=Object.defineProperty,me=_((t,e)=>is(t,"name",{value:e,configurable:!0}),"t");const ss=Me(import.meta.url),pe=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Wt=me(t=>{if(typeof pe<"u"&&pe.versions&&pe.versions.node){const[e,n]=pe.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return pe.getBuiltinModule(t)}return ss(t)},"u"),{execFileSync:rs}=Wt("node:child_process"),{totalmem:as}=Wt("node:os"),ls=/--max-old-space-size=(\d+)/,cs=/--max-semi-space-size=(\d+)/,us=me(t=>Math.floor(as()/1024/1024*t),"E"),ps=me(t=>t<=512?4:t<=1024?8:t<=2048?16:t<=4096?32:t<=8192?64:Math.floor(Math.log2(t))*8,"P"),pt=me((t,e)=>{for(const n of e){const o=t.exec(n);if(o)return Number.parseInt(o[1],10)}},"l"),Er=me(t=>{const e=t?.maxOldSpacePercent??.75,n=[...yt()],o=[...$e()],s=pt(ls,n),i=pt(cs,n);if(s!==void 0&&i!==void 0)return;const a=s??us(e),l=i??ps(a),h=[];if(s===void 0&&h.push(`--max-old-space-size=${String(a)}`),i===void 0&&h.push(`--max-semi-space-size=${String(l)}`),h.length!==0)try{rs(bt(),[...h,...n,...o.slice(1)],{env:q(),stdio:"inherit"}),z(0)}catch(r){const c=r.status;z(typeof c=="number"?c:1)}},"q");var hs=Object.defineProperty,Ae=_((t,e)=>hs(t,"name",{value:e,configurable:!0}),"S");const fs=Me(import.meta.url),he=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ds=Ae(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 fs(t)},"Q"),{createRequire:ms}=ds("node:module");var gs=Object.defineProperty,Ue=Ae((t,e)=>gs(t,"name",{value:e,configurable:!0}),"L"),ws=Object.defineProperty,vs=Ue((t,e)=>ws(t,"name",{value:e,configurable:!0}),"r$1");const ys=vs(t=>t.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
7
+ `),"normalizeLF"),bs=globalThis.process??Object.create(null),ht={versions:{}},ft=new Proxy(bs,{get(t,e){if(e in t)return t[e];if(e in ht)return ht[e]}});var $s=Object.defineProperty,xs=Ue((t,e)=>$s(t,"name",{value:e,configurable:!0}),"b");const Ns=xs((t,e,n,o)=>{const s={column:0,line:-1,...t.start},i={...s,...t.end},a=s.line,l=s.column,h=i.line,r=i.column;let c=Math.max(a-(n+1),0),m=Math.min(e.length,h+o);a===-1&&(c=0),h===-1&&(m=e.length);const p=h-a,g={};if(p)for(let u=0;u<=p;u++){const v=u+a;if(!l)g[v]=!0;else if(u===0){const $=e[v-1]?.length;g[v]=[l,($??0)-l+1]}else if(u===p)g[v]=[0,r];else{const $=e[v-u]?.length;g[v]=[0,$]}}else l===r?g[a]=l?[l,0]:!0:g[a]=[l,(r??0)-(l??0)];return{end:m,markerLines:g,start:c}},"getMarkerLines");var As=Object.defineProperty,ve=Ue((t,e)=>As(t,"name",{value:e,configurable:!0}),"t");const Es=ft.platform==="win32"&&!ft.env?.WT_SESSION?">":"❯",ks=ve((t,e,n)=>{const o={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,tabWidth:4,...n,color:{gutter:ve(u=>u,"gutter"),marker:ve(u=>u,"marker"),message:ve(u=>u,"message"),...n?.color}},s=typeof e.start.column=="number";let i=ys(t).split(`
8
+ `);typeof o.tabWidth=="number"&&(i=i.map(u=>u.replaceAll(" "," ".repeat(o.tabWidth))));const{end:a,markerLines:l,start:h}=Ns(e,i,o.linesAbove,o.linesBelow),r=String(a).length,{gutter:c,marker:m,message:p}=o.color;let g=i.slice(h,a).map((u,v)=>{const $=h+1+v,y=l[$],x=String($).padStart(r),E=!l[$+1],O=` ${x}${o.showGutter?" |":""}`;if(y){let f="";if(Array.isArray(y)){const w=u.replaceAll(/[^\t]/g," ").slice(0,Math.max(y[0]-1,0)),b=y[1]||1;f=[`
9
+ `,o.prefix+c(O.replaceAll(/\d/g," "))," ",w,m("^").repeat(b)].join(""),E&&o.message&&(f+=` ${p(o.message)}`)}return[o.prefix+m(Es),c(O),u.length>0?` ${u}`:"",f].join("")}return`${o.prefix} ${c(O)}${u.length>0?` ${u}`:""}`}).join(`
10
+ `);return o.message&&!s&&(g=`${o.prefix+" ".repeat(r+1)+o.message}
11
+ ${g}`),g},"codeFrame");var Os=Object.defineProperty,Cs=Ae((t,e)=>Os(t,"name",{value:e,configurable:!0}),"ue"),_s=Object.defineProperty,F=Cs((t,e)=>_s(t,"name",{value:e,configurable:!0}),"u");const Z=F((t,...e)=>{process.env.DEBUG&&process.env.DEBUG==="true"&&console.debug(`error:parse-stacktrace: ${t}`,...e)},"debugLog"),Q="<unknown>",Ls=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ps=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,Ts=/(.*?):(\d+):(\d+)(?:\s<-\s.+:\d+:\d+)?/,Ss=/eval\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*<anonymous>?:(\d+)?:(\d+)/,Is=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,Ms=/in\s(.*)\s\(at\s(.+)\)\sat/,js=/^(?:.*@)?(.*):(\d+):(\d+)$/,Us=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Ds=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Vs=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,dt=/\(error: (.*)\)/,Bs=/at\s/,Rs=/^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/,zs=/\S*(?:Error: |AggregateError:)/,qt=/^Anonymous function$/,Fs=/^\s*in\s.*/,Ws=/^.*?\s*at\s.*/,qs=/^.*?\s*@.*|\[native code\]/,Gt=F((t,e)=>{const n=t.includes("safari-extension"),o=t.includes("safari-web-extension");return n||o?[t.includes("@")?t.split("@")[0]:Q,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]},"extractSafariExtensionDetails"),Ht=F((t,e)=>{const n=Ts.exec(e);n&&(t.file=n[1],t.line=+n[2],t.column=+n[3])},"parseMapped"),Gs=F(t=>{const e=Ms.exec(t);if(e){Z(`parse nested node error stack line: "${t}"`,`found: ${JSON.stringify(e)}`);const o=e[2].split(":");return{column:o[2]?+o[2]:void 0,file:o[0],line:o[1]?+o[1]:void 0,methodName:e[1]??Q,raw:t,type:void 0}}const n=Is.exec(t);if(n){Z(`parse node error stack line: "${t}"`,`found: ${JSON.stringify(n)}`);const o={column:n[4]?+n[4]:void 0,file:n[2]?n[2].replace(Bs,""):void 0,line:n[3]?+n[3]:void 0,methodName:n[1]??Q,raw:t,type:t.startsWith("internal")?"internal":void 0};return Ht(o,`${n[2]}:${n[3]}:${n[4]}`),o}},"parseNode"),Hs=F(t=>{const e=Ls.exec(t);if(e){Z(`parse chrome error stack line: "${t}"`,`found: ${JSON.stringify(e)}`);const n=e[2]?.startsWith("native"),o=e[2]?.startsWith("eval")||e[1]?.startsWith("eval");let s,i;if(o){const r=Ps.exec(t);if(r){const c=Rs.exec(r[1]);c?(e[2]=c[4]??c[1],e[3]=c[5]??c[2],e[4]=c[3]):r[2]&&(e[2]=r[1]),r[2]&&(s={column:r[4]?+r[4]:void 0,file:r[2],line:r[3]?+r[3]:void 0,methodName:"eval",raw:t,type:"eval"})}else{const c=Ss.exec(t);c&&(i={column:c[4]?+c[4]:void 0,file:c[2],line:c[3]?+c[3]:void 0},s={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[a,l]=Gt(e[1]?e[1].replace(qt,"<anonymous>"):Q,e[2]),h={column:e[4]?+e[4]:void 0,evalOrigin:s,file:l,line:e[3]?+e[3]:void 0,methodName:a,raw:t,type:o?"eval":n?"native":void 0};return i?(h.column=i.column,h.file=i.file,h.line=i.line):Ht(h,`${l}:${e[3]}:${e[4]}`),h}},"parseChromium"),Js=F((t,e)=>{const n=Us.exec(t);if(n){Z(`parse gecko error stack line: "${t}"`,`found: ${JSON.stringify(n)}`);const o=n[3]?.includes(" > eval"),s=o&&n[3]&&Ds.exec(n[3]);let i;o&&s&&(n[3]=s[1],i={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]=s[2]);const[a,l]=Gt(n[1]?n[1].replace(qt,"<anonymous>"):Q,n[3]);let h;(e?.type==="safari"||!o&&e?.type==="firefox")&&e.column?h=e.column:!o&&n[5]&&(h=+n[5]);let r;return(e?.type==="safari"||!o&&e?.type==="firefox")&&e.line?r=e.line:n[4]&&(r=+n[4]),{column:h,evalOrigin:i,file:l,line:r,methodName:a,raw:t,type:o?"eval":l.includes("[native code]")?"native":void 0}}},"parseGecko"),Ks=F((t,e)=>{const n=Vs.exec(t);if(!(n&&n[2].includes(" > eval"))&&n)return Z(`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]||Q,raw:t,type:void 0}},"parseFirefox"),Ys=F(t=>{const e=js.exec(t);if(e)return Z(`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:Q,raw:t,type:void 0}},"parseReactAndroidNative"),Jt=F((t,{filter:e,frameLimit:n=50}={})=>{const o=t;let s=(typeof o.stacktrace=="string"?o.stacktrace:t.stack??"").split(`
12
+ `).map(i=>(dt.test(i)?i.replace(dt,"$1"):i).trim()).filter(i=>!zs.test(i)&&i!=="eval code");return e&&(s=s.filter(i=>e(i))),s=s.slice(0,n),s.reduce((i,a,l)=>{if(!a||a.length>1024)return i;let h;if(Fs.test(a))h=Gs(a);else if(Ws.test(a))h=Hs(a);else if(qs.test(a)){let r;if(l===0){const c=t,m=c.columnNumber,p=c.lineNumber,g=c.line,u=c.column;m||p?r={column:m,line:p,type:"firefox"}:(g||u)&&(r={column:u,line:g,type:"safari"})}h=Ks(a,r)??Js(a,r)}else h=Ys(a);return h?i.push(h):Z(`parse error stack line: "${a}"`,"not parser found"),i},[])},"parseStacktrace");var Zs=Object.defineProperty,Kt=Ae((t,e)=>Zs(t,"name",{value:e,configurable:!0}),"V");const Qs=ms(import.meta.url),ie=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,De=Kt(t=>{if(typeof ie<"u"&&ie.versions&&ie.versions.node){const[e,n]=ie.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ie.getBuiltinModule(t)}return Qs(t)},"__cjs_getBuiltinModule"),{existsSync:Xs,readFileSync:er}=De("node:fs"),{relative:tr}=De("node:path"),{cwd:nr}=ie,{fileURLToPath:or}=De("node:url");var ir=Object.defineProperty,L=Kt((t,e)=>ir(t,"name",{value:e,configurable:!0}),"o");const X=L((t,e,n)=>n===0?t:e===" "?t+" ".repeat(n):t+" ".repeat(e*n),"getPrefix"),sr=L((t,e)=>{const n=t.replace("async file:","file:");return tr(e,n.startsWith("file:")?or(n):n)},"getRelativePath"),rr=L((t,e,n)=>{if(e)return n.title(t.message);const o=t.message?`: ${t.message}`:"";return n.title(t.name+o)},"getTitleText"),Yt=L((t,{color:e,hideErrorTitle:n,indentation:o,prefix:s},i)=>`${X(s,o,i)}${rr(t,n,e)}
13
+ `,"getMessage"),Zt=L((t,{color:e,indentation:n,prefix:o},s)=>{if(t.hint===void 0)return;const i=X(o,n,s);let a="";if(Array.isArray(t.hint))for(const l of t.hint)a+=`${i+l}
14
+ `;else a+=i+t.hint;return e.hint(a)},"getHint"),Ve=L((t,{color:e,cwd:n,displayShortPath:o,indentation:s,prefix:i},a=0)=>{const l=o?sr(t.file,n):t.file,{fileLine:h,method:r}=e;return`${X(i,s,a)}at ${t.methodName?`${r(t.methodName)} `:""}${h(l)}:${h(t.line?.toString()??"")}`},"getMainFrame"),Qt=L((t,{color:e,indentation:n,linesAbove:o,linesBelow:s,prefix:i,showGutter:a,showLineNumbers:l,tabWidth:h},r)=>{if(t.file===void 0)return;const c=t.file.replace("file://","");if(!Xs(c))return;const m=er(c,"utf8");return ks(m,{start:{column:t.column,line:t.line}},{color:e,linesAbove:o,linesBelow:s,prefix:X(i,n,r),showGutter:a,showLineNumbers:l,tabWidth:h})},"getCode"),Xt=L((t,e,n)=>{if(t.errors.length===0)return;let o=`${X(e.prefix,e.indentation,n)}Errors:
15
+
16
+ `,s=!0;for(const i of t.errors)s?s=!1:o+=`
17
+
18
+ `,o+=tn(i,{...e,framesMaxLimit:1,hideErrorCodeView:e.hideErrorErrorsCodeView},n+1);return`
19
+ ${o}`},"getErrors"),en=L((t,e,n,o=new Set)=>{o.add(t);let s=`${X(e.prefix,e.indentation,n)}Caused by:
20
+
21
+ `;const i=t.cause;s+=Yt(i,e,n);const a=Jt(i).shift(),l=Zt(i,e,n);if(l&&(s+=`${l}
22
+ `),a&&(s+=Ve(a,e,n),!e.hideErrorCauseCodeView)){const h=Qt(a,e,n);h!==void 0&&(s+=`
23
+ ${h}`)}if(i instanceof AggregateError){const h=Xt(i,e,n);h!==void 0&&(s+=`
24
+ ${h}`)}return i.cause&&(o.has(i)?s+=`
25
+ ${X(e.prefix,e.indentation,n+1)}Caused by: [Circular]`:s+=`
26
+ ${en(i,e,n+1,o)}`),`
27
+ ${s}`},"getCause"),ar=L((t,e)=>(t.length>0?`
28
+ `:"")+t.map(n=>Ve(n,e)).join(`
29
+ `),"getStacktrace"),tn=L((t,e,n)=>{const o={cwd:nr(),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:L(a=>a,"fileLine"),gutter:L(a=>a,"gutter"),hint:L(a=>a,"hint"),marker:L(a=>a,"marker"),message:L(a=>a,"message"),method:L(a=>a,"method"),title:L(a=>a,"title"),...e.color}},s=Jt(t,{filter:e.filterStacktrace,frameLimit:o.framesMaxLimit}),i=s.shift();return[e.hideMessage?void 0:Yt(t,o,n),Zt(t,o,n),i?Ve(i,o,n):void 0,i&&!o.hideErrorCodeView?Qt(i,o,n):void 0,t instanceof AggregateError?Xt(t,o,n):void 0,t.cause===void 0?void 0:en(t,o,n),s.length>0?ar(s,o):void 0].filter(Boolean).join(`
30
+ `).replaceAll("\\","/")},"internalRenderError"),lr=L((t,e={})=>{if(e.framesMaxLimit!==void 0&&e.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return tn(t,e,0)},"renderError");var cr=Object.defineProperty,mt=_((t,e)=>cr(t,"name",{value:e,configurable:!0}),"i$1");const kr=mt((t={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:mt((e,n)=>{const{logger:o,runtime:s}=n,{detailed:i=!1,exitOnError:a=!0,formatter:l,logErrors:h=!0,renderOptions:r={}}=t;if(h)if(l)o.error(l(e));else if(i){const c=s.getCwd(),m=lr(e,{cwd:c,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...r});o.error(m)}else o.error(e);a&&z(1)},"onError"),version:"1.0.0"}),"E");var ur="1.0.0-alpha.29";const Or={version:ur};var pr=Object.defineProperty,hr=_((t,e)=>pr(t,"name",{value:e,configurable:!0}),"e");const Cr={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:hr(()=>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{Er as $,vr as E,Nr as I,Ar as a,G as b,yr as c,k as d,q as h,Cr as i,Or as m,kr as p};
@@ -1,2 +1,2 @@
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};
1
+ var z=Object.defineProperty;var n=(t,e)=>z(t,"name",{value:e,configurable:!0});import{createRequire as Q}from"node:module";import{n as tt,M as w}from"./readFileSync-DseCu8sg-DEq4Fn3a.js";import{g as j}from"../packem_chunks/config.js";import{aT as ht,U as dt,aU 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: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,W=n((t,e)=>kt(t,"name",{value:e,configurable:!0}),"s$2");const mt=lt(import.meta.url),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,yt=W(t=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[e,o]=y.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return y.getBuiltinModule(t)}return mt(t)},"a"),{lstat:x,mkdir:gt}=yt("node:fs/promises"),vt=W(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 gt(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})}},"m");var _t=Object.defineProperty,f=n((t,e)=>_t(t,"name",{value:e,configurable:!0}),"s$1");const bt=3e4,N=100;class Et extends Error{static{n(this,"ServiceReadinessError")}constructor(e,o){super(e),this.elapsedMs=o,this.name="ServiceReadinessError"}elapsedMs;static{f(this,"ServiceReadinessError")}}const $t=f(async t=>{const e=t.host??"127.0.0.1",{port:o}=t,s=t.timeoutMs??bt,r=Date.now();for(;Date.now()-r<s;){if(await St(e,o))return;await Ht(N)}throw new Et(`Timed out waiting for ${e}:${String(o)} to accept TCP connections (${String(s)}ms)`,Date.now()-r)},"waitForTcp"),St=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"),Ht=f(t=>new Promise(e=>{setTimeout(e,t)}),"delay"),Pt=f(async(t,e)=>{const o=t.readiness??(t.port===void 0?void 0:{tcp:{port:t.port}});o&&await $t({host:o.tcp.host,port:o.tcp.port,timeoutMs:e?.timeoutMs??o.tcp.timeoutMs})},"runReadiness");var Tt=Object.defineProperty,h=n((t,e)=>Tt(t,"name",{value:e,configurable:!0}),"o");const R=384,C=5e3,Rt=50,Mt=3e4,k=h(async t=>{const e=w(ht(t),"services");try{await vt(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"),M=h(t=>t.replaceAll("/","_").replaceAll(":","__"),"slugify"),D=h((t,e)=>w(t,`${M(e)}.json`),"entryPath"),Dt=h((t,e)=>w(t,`${M(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"),Ot=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"),jt=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 It(r,s)}catch(i){throw await T(r,{force:!0}).catch(()=>{}),i}},"writeEntry"),xt=new Set(["EACCES","EBUSY","EPERM"]),Ct=8,At=20,It=h(async(t,e)=>{let o=0;for(;;)try{await it(t,e);return}catch(s){const{code:r}=s;if(!(r!==void 0&&xt.has(r))||o>=Ct)throw s;const i=At*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"),ie=h(async t=>{const e=await Ot(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"),Ft=h(t=>new Promise(e=>{setTimeout(e,t)}),"sleep"),Lt=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"),Wt=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>Mt}catch{return!0}},"isLockStale"),B=h(async(t,e,o)=>{const s=await k(t),r=Dt(s,e),i=Date.now();for(;!await Lt(r);){if(await Wt(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 Ft(Rt)}try{return await o()}finally{await O(r).catch(()=>{})}},"withServiceLock");var Nt=Object.defineProperty,l=n((t,e)=>Nt(t,"name",{value:e,configurable:!0}),"r");function v(t,e={},o){for(const s in t){const r=t[s],i=o?`${o}:${s}`:s;typeof r=="object"&&r!==null?v(r,e,i):typeof r=="function"&&(e[i]=r)}return e}n(v,"c");l(v,"flatHooks");function Bt(...t){const e={};for(const o of t){const s=v(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(Bt,"v");l(Bt,"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 E(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(()=>E(t,e,r+1,s))}catch(i){return Promise.reject(i)}}n(E,"k");l(E,"callHooks");function q(t,e,o){if(t.length>0)return E(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 Gt(t,e){return t.reduce((o,s)=>o.then(()=>s(...e||[])),Promise.resolve())}n(Gt,"x");l(Gt,"serialCaller");function Vt(t,e){return Promise.all(t.map(o=>o(...e||[])))}n(Vt,"P");l(Vt,"parallelCaller");function _(t,e){for(const o of[...t])o(e)}n(_,"a");l(_,"callEachWith");var qt=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=v(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=v(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 qt}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 E(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 Xt=Object.defineProperty,$=n((t,e)=>Xt(t,"name",{value:e,configurable:!0}),"t$1");const ne=$(()=>X(),"createVisHooks"),ae=$(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 ce{static{n(this,"HookableLifeCycle")}static{$(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):Yt(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 Yt=$(t=>t==="local-cache"||t==="local-cache-kept-existing"||t==="remote-cache","isCacheStatus");var Jt=Object.defineProperty,Kt=n((t,e)=>Jt(t,"name",{value:e,configurable:!0}),"i");const I=process.platform==="win32",zt=Kt(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",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 Qt=Object.defineProperty,S=n((t,e)=>Qt(t,"name",{value:e,configurable:!0}),"t");const Y=5e3,le=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=M(t.id),r=w(o,`${s}.log`),{pid:i}=await zt({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 jt(t.workspaceRoot,c),t.skipReadiness!==!0)try{await Pt(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"),he=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{ce as H,Et as S,b as a,he as b,ne as c,Ot as d,Pt as e,g as f,u as i,ie as p,ae as r,le 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{D as R,u as C}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 U=Object.defineProperty,z=j((n,e)=>U(n,"name",{value:e,configurable:!0}),"L"),I=Object.defineProperty,_=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}=S("node:fs"),{readFile:Z}=S("node:fs/promises");var K=Object.defineProperty,l=_((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 $ of P)D.includes($)||D.push($);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",O(p,"dependencies")),m(o,"peerDependencies",O(p,"peerDependencies")),m(o,"optionalDependencies",O(p,"optionalDependencies")),w(e,t,o)}return e},"parseYarnLockFile"),O=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=C(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};
@@ -1 +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
+ 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-DseCu8sg-DEq4Fn3a.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-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
+ 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,l as y}from"./readFileSync-DseCu8sg-DEq4Fn3a.js";import{s as q}from"../packem_chunks/config.js";const $=S(import.meta.url),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=g(s=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[e,n]=f.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return f.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 l=d(c,p,"node_modules");y(l)&&r(l)}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 l=d(c,"node_modules");y(l)&&r(l)}catch{}}},"scanDir");return r(e),n},"readNodeModulesManifests");export{R as n,W as r};
@@ -1,9 +1,9 @@
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}
1
+ var f=Object.defineProperty;var R=(u,p)=>f(u,"name",{value:p,configurable:!0});import{M as d,l as o,B as $}from"./readFileSync-DseCu8sg-DEq4Fn3a.js";import{E 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]
5
5
  ${c}
6
- `}else{const c=g.index+g[0].length,f=e.slice(c),y=/^\[/m.exec(f),k=y?.index===void 0?e.length:c+y.index;let l=e.slice(c,k);l=/^[ \t]*minimumReleaseAge[ \t]*=/m.test(l)?l.replace(/^[ \t]*minimumReleaseAge[ \t]*=.*$/m,t):`${t}
6
+ `}else{const c=g.index+g[0].length,E=e.slice(c),y=/^\[/m.exec(E),k=y?.index===void 0?e.length:c+y.index;let l=e.slice(c,k);l=/^[ \t]*minimumReleaseAge[ \t]*=/m.test(l)?l.replace(/^[ \t]*minimumReleaseAge[ \t]*=.*$/m,t):`${t}
7
7
  ${l}`,s&&(l=/^[ \t]*minimumReleaseAgeExcludes[ \t]*=/m.test(l)?l.replace(/^[ \t]*minimumReleaseAgeExcludes[ \t]*=.*$/m,s):`${s}
8
8
  ${l}`),e=`${e.slice(0,c)}${l}${e.slice(k)}`}h(n,e.endsWith(`
9
9
  `)?e:`${e}
@@ -1,21 +1,21 @@
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)}
1
+ var v=Object.defineProperty;var C=(o,l)=>v(o,"name",{value:l,configurable:!0});import{M as c,B as S,l as g}from"./readFileSync-DseCu8sg-DEq4Fn3a.js";import{E as i,s as O}from"../packem_chunks/config.js";import{q as N,r as U}from"../packem_chunks/bin.js";var x=Object.defineProperty,D=C((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)}
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
- `,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:
5
- ${t.map(a=>` ${$(a)}: ${String(h[a])}`).join(`
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"),f=D(a=>p(a)?`'${a.replaceAll("'","''")}'`:a,"renderKey"),y=`allowBuilds:
5
+ ${t.map(a=>` ${f(a)}: ${String(h[a])}`).join(`
6
6
  `)}
7
7
  `;let r=S(n);r.endsWith(`
8
8
  `)||(r+=`
9
- `);const f=/^allowBuilds:[ \t]*\n(?:[ \t]{2}[^\n]*\n)*/m;if(r=f.test(r)?r.replace(f,y):`${r.trimEnd()}
9
+ `);const $=/^allowBuilds:[ \t]*\n(?:[ \t]{2}[^\n]*\n)*/m;if(r=$.test(r)?r.replace($,y):`${r.trimEnd()}
10
10
 
11
11
  ${y}`,k.length>0){const a=`onlyBuiltDependencies:
12
12
  ${k.map(j=>` - ${p(j)?`'${j.replaceAll("'","''")}'`:j}`).join(`
13
13
  `)}
14
- `,C=/^onlyBuiltDependencies:[ \t]*\n(?:[ \t]{2}[^\n]*\n)*/m;r=C.test(r)?r.replace(C,a):`${r.trimEnd()}
14
+ `,E=/^onlyBuiltDependencies:[ \t]*\n(?:[ \t]{2}[^\n]*\n)*/m;r=E.test(r)?r.replace(E,a):`${r.trimEnd()}
15
15
 
16
- ${a}`}i(n,r),s.push(`Updated pnpm-workspace.yaml allowBuilds (${String(A)} new, ${String(t.length)} total)`),w>0&&s.push(`Updated pnpm-workspace.yaml onlyBuiltDependencies (${String(w)} new, ${String(k.length)} total)`)}const B=c(l,"package.json");if(g(B)&&u.length>0)try{const t=O(B),p=Array.isArray(t.pnpm?.onlyBuiltDependencies)?t.pnpm.onlyBuiltDependencies:[],$=[...new Set([...p,...u])].toSorted((r,f)=>r.localeCompare(f)),y=u.filter(r=>!p.includes(r)).length;y>0&&(t.pnpm={...t.pnpm,onlyBuiltDependencies:$},i(B,`${JSON.stringify(t,null,2)}
17
- `),s.push(`Updated package.json pnpm.onlyBuiltDependencies (${String(y)} new, ${String($.length)} total)`))}catch(t){s.push(`Failed to update package.json pnpm.onlyBuiltDependencies: ${t instanceof Error?t.message:String(t)}`)}break}case"yarn":{if(N(l)){const n=c(l,".yarnrc.yml");let e=S(n);const m=/^\s*enableScripts\s*:/m.test(e),h=/^\s*enableScripts\s*:\s*false\s*$/m.test(e);m?h?s.push(".yarnrc.yml already has enableScripts: false"):(e=e.replace(/^\s*enableScripts\s*:.+$/m,"enableScripts: false"),i(n,e),s.push("Changed enableScripts to false in .yarnrc.yml")):(e=`${e.trimEnd()}
16
+ ${a}`}i(n,r),s.push(`Updated pnpm-workspace.yaml allowBuilds (${String(A)} new, ${String(t.length)} total)`),w>0&&s.push(`Updated pnpm-workspace.yaml onlyBuiltDependencies (${String(w)} new, ${String(k.length)} total)`)}const B=c(l,"package.json");if(g(B)&&u.length>0)try{const t=O(B),p=Array.isArray(t.pnpm?.onlyBuiltDependencies)?t.pnpm.onlyBuiltDependencies:[],f=[...new Set([...p,...u])].toSorted((r,$)=>r.localeCompare($)),y=u.filter(r=>!p.includes(r)).length;y>0&&(t.pnpm={...t.pnpm,onlyBuiltDependencies:f},i(B,`${JSON.stringify(t,null,2)}
17
+ `),s.push(`Updated package.json pnpm.onlyBuiltDependencies (${String(y)} new, ${String(f.length)} total)`))}catch(t){s.push(`Failed to update package.json pnpm.onlyBuiltDependencies: ${t instanceof Error?t.message:String(t)}`)}break}case"yarn":{if(N(l)){const n=c(l,".yarnrc.yml");let e=S(n);const m=/^\s*enableScripts\s*:/m.test(e),h=/^\s*enableScripts\s*:\s*false\s*$/m.test(e);m?h?s.push(".yarnrc.yml already has enableScripts: false"):(e=e.replace(/^\s*enableScripts\s*:.+$/m,"enableScripts: false"),i(n,e),s.push("Changed enableScripts to false in .yarnrc.yml")):(e=`${e.trimEnd()}
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{P as N};
21
+ `,i(n,e),s.push("Added ignore-scripts=true to .npmrc (yarn classic lacks enableScripts)"))}break}}return s},"syncAllowBuildsToNativeConfig");export{W 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{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)}
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 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
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};