@visulima/vis 7.1.0-next.2 → 7.1.0-next.4

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 +17 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/binx.js +1 -1
  4. package/dist/packem_chunks/bloom-sync.js +1 -1
  5. package/dist/packem_chunks/catalog.js +1 -1
  6. package/dist/packem_chunks/cli-exec.js +1 -1
  7. package/dist/packem_chunks/cli-main.js +1 -1
  8. package/dist/packem_chunks/fix.js +1 -1
  9. package/dist/packem_chunks/handler10.js +1 -1
  10. package/dist/packem_chunks/handler12.js +1 -1
  11. package/dist/packem_chunks/handler13.js +1 -1
  12. package/dist/packem_chunks/handler14.js +1 -1
  13. package/dist/packem_chunks/handler15.js +1 -1
  14. package/dist/packem_chunks/handler19.js +1 -1
  15. package/dist/packem_chunks/handler2.js +1 -1
  16. package/dist/packem_chunks/handler20.js +1 -1
  17. package/dist/packem_chunks/handler21.js +1 -1
  18. package/dist/packem_chunks/handler23.js +1 -1
  19. package/dist/packem_chunks/handler24.js +1 -1
  20. package/dist/packem_chunks/handler25.js +1 -1
  21. package/dist/packem_chunks/handler26.js +1 -1
  22. package/dist/packem_chunks/handler28.js +1 -1
  23. package/dist/packem_chunks/handler3.js +1 -1
  24. package/dist/packem_chunks/handler4.js +1 -1
  25. package/dist/packem_chunks/handler5.js +1 -1
  26. package/dist/packem_chunks/handler50.js +1 -1
  27. package/dist/packem_chunks/handler51.js +1 -1
  28. package/dist/packem_chunks/handler52.js +1 -1
  29. package/dist/packem_chunks/handler54.js +1 -1
  30. package/dist/packem_chunks/handler55.js +1 -1
  31. package/dist/packem_chunks/handler58.js +1 -1
  32. package/dist/packem_chunks/handler59.js +1 -1
  33. package/dist/packem_chunks/handler6.js +1 -1
  34. package/dist/packem_chunks/handler60.js +1 -1
  35. package/dist/packem_chunks/handler61.js +1 -1
  36. package/dist/packem_chunks/handler62.js +1 -1
  37. package/dist/packem_chunks/handler63.js +1 -1
  38. package/dist/packem_chunks/handler64.js +1 -1
  39. package/dist/packem_chunks/handler65.js +1 -1
  40. package/dist/packem_chunks/handler66.js +1 -1
  41. package/dist/packem_chunks/handler67.js +1 -1
  42. package/dist/packem_chunks/handler68.js +1 -1
  43. package/dist/packem_chunks/handler69.js +1 -1
  44. package/dist/packem_chunks/handler7.js +1 -1
  45. package/dist/packem_chunks/handler70.js +24 -24
  46. package/dist/packem_chunks/handler71.js +1 -1
  47. package/dist/packem_chunks/handler72.js +1 -1
  48. package/dist/packem_chunks/handler73.js +1 -1
  49. package/dist/packem_chunks/handler74.js +1 -1
  50. package/dist/packem_chunks/handler75.js +1 -1
  51. package/dist/packem_chunks/handler76.js +1 -1
  52. package/dist/packem_chunks/handler77.js +1 -1
  53. package/dist/packem_chunks/handler78.js +1 -1
  54. package/dist/packem_chunks/handler79.js +1 -1
  55. package/dist/packem_chunks/handler8.js +1 -1
  56. package/dist/packem_chunks/heal.js +1 -1
  57. package/dist/packem_chunks/help-command.js +1 -1
  58. package/dist/packem_chunks/index7.js +1 -1
  59. package/dist/packem_chunks/keys-refresh.js +1 -1
  60. package/dist/packem_chunks/list.js +1 -1
  61. package/dist/packem_chunks/prune.js +1 -1
  62. package/dist/packem_chunks/status.js +1 -1
  63. package/dist/packem_chunks/sync.js +1 -1
  64. package/dist/packem_chunks/sync2.js +1 -1
  65. package/dist/packem_chunks/tripwire.js +1 -1
  66. package/dist/packem_chunks/verify-lockfile.js +1 -1
  67. package/dist/packem_shared/{advisories-Wk-RI-Lt.js → advisories-BbFUg8RU.js} +1 -1
  68. package/dist/packem_shared/{affected-selection-BAEovubH.js → affected-selection-CHA-JA9v.js} +1 -1
  69. package/dist/packem_shared/{ai-analysis-DoXQg-wK.js → ai-analysis-D7yA6HDb.js} +1 -1
  70. package/dist/packem_shared/{ai-cache-B9U5m9O9.js → ai-cache-CIiLVd6H.js} +1 -1
  71. package/dist/packem_shared/{ai-fix-DzPjdJFn.js → ai-fix-BPVLEoW-.js} +1 -1
  72. package/dist/packem_shared/{bin-DKJ6q_xR.js → bin-B9M4bSlc.js} +1 -1
  73. package/dist/packem_shared/{build-scripts-B7BgERlS.js → build-scripts-CIwm3AiC.js} +1 -1
  74. package/dist/packem_shared/{dependency-scan-DKp1Y0Sx.js → dependency-scan-CVnUo47n.js} +1 -1
  75. package/dist/packem_shared/{detect-DF0ZnX4w.js → detect-BOf9_Brj.js} +1 -1
  76. package/dist/packem_shared/{docker-CxcZMIvs.js → docker-C4bCKX_b.js} +1 -1
  77. package/dist/packem_shared/{ecosystem-gate-ChG-zNz5.js → ecosystem-gate-CdpT8g5F.js} +1 -1
  78. package/dist/packem_shared/{env-D0huQDyA.js → env-CBECVaqy.js} +1 -1
  79. package/dist/packem_shared/{env-consistency-Dj56sHLM.js → env-consistency-BM-1c6oh.js} +1 -1
  80. package/dist/packem_shared/{failure-log-D6woYuZv.js → failure-log-BUWrnem1.js} +1 -1
  81. package/dist/packem_shared/glob-Cyk1H9ZL-CwM-bcq9.js +1 -0
  82. package/dist/packem_shared/{index-B3tiV1iu.js → index-BYknRylI.js} +1 -1
  83. package/dist/packem_shared/{index-u2ABjmic.js → index-Dylr7IyO.js} +1 -1
  84. package/dist/packem_shared/{lifecycle-DKTLZVXm.js → lifecycle-CmO1OdDb.js} +1 -1
  85. package/dist/packem_shared/{manifests-C3TL659D.js → manifests-C7kfBdVu.js} +1 -1
  86. package/dist/packem_shared/{min-release-age-4Jf3-DDz.js → min-release-age-Dplongyj.js} +1 -1
  87. package/dist/packem_shared/{missing-package-json-wH6OInGG.js → missing-package-json-BGS_pPSE.js} +1 -1
  88. package/dist/packem_shared/{multi-eco-lockfiles-szCMAPHo.js → multi-eco-lockfiles-C3ibnSu7.js} +1 -1
  89. package/dist/packem_shared/{native-config-sync-Dv4nFzvF.js → native-config-sync-Co7B7LHq.js} +1 -1
  90. package/dist/packem_shared/{osv-BTClyx8h.js → osv-CLps2k15.js} +1 -1
  91. package/dist/packem_shared/{package-version-CtgyD_B1.js → package-version-Bh9fCd7j.js} +1 -1
  92. package/dist/packem_shared/{packument-BOiBtGV2.js → packument-B4GE-Kt_.js} +1 -1
  93. package/dist/packem_shared/{project-name-filter-CVtU8rSE.js → project-name-filter-COFwhbnG.js} +1 -1
  94. package/dist/packem_shared/{provenance-DRntJArZ.js → provenance-DURokRlA.js} +1 -1
  95. package/dist/packem_shared/{registry-Dmy6zBD8.js → registry-C_cLtZJm.js} +1 -1
  96. package/dist/packem_shared/{registry-keys-C5UDzK6U.js → registry-keys-DwxLPz3K.js} +1 -1
  97. package/dist/packem_shared/{renderToString-DR0zDUjh-BeCb092p.js → renderToString-DR0zDUjh-CnB1vLtB.js} +1 -1
  98. package/dist/packem_shared/{resolve-explicit-ChxnXt-x.js → resolve-explicit-DhVLbfL0.js} +1 -1
  99. package/dist/packem_shared/{run-summary-utils-Co-yODTZ.js → run-summary-utils-CdBH8qU4.js} +1 -1
  100. package/dist/packem_shared/{runtime-check-CRNoD5DL.js → runtime-check-DpjLPXcB.js} +1 -1
  101. package/dist/packem_shared/{s1ngularity-DCurn2c1.js → s1ngularity-D1ocA4ja.js} +1 -1
  102. package/dist/packem_shared/{scaffold-files-D0whWHeH.js → scaffold-files-BcDQC-9O.js} +1 -1
  103. package/dist/packem_shared/{scan-progress-B6BSwS4F.js → scan-progress-D2GJbBjf.js} +1 -1
  104. package/dist/packem_shared/{selectors-DrrBSBOS.js → selectors-V2bRMuKV.js} +1 -1
  105. package/dist/packem_shared/{signatures-DHnVndR8.js → signatures-BxD1Y_rr.js} +1 -1
  106. package/dist/packem_shared/{spinner-B9D3Fl1H.js → spinner-Cet2A4FR.js} +1 -1
  107. package/dist/packem_shared/{table-BT8EWIiz.js → table-C4nDPVQn.js} +1 -1
  108. package/dist/packem_shared/{tabs-Cq8smM1S.js → tabs-DE0K4rdx.js} +1 -1
  109. package/dist/packem_shared/{toolchain-BnrrDIRc.js → toolchain-DvRok9gN.js} +1 -1
  110. package/dist/packem_shared/{typosquats-hTQZou8a.js → typosquats-BmTTOQSM.js} +1 -1
  111. package/dist/packem_shared/{use-measured-height-tg-5qUrj.js → use-measured-height-DtEL4vP2.js} +1 -1
  112. package/dist/packem_shared/{vis-update-app-BUqiU_Zo.js → vis-update-app-Bmc-ARb2.js} +1 -1
  113. package/dist/packem_shared/{vis-user-error-DNF243LB.js → vis-user-error-BlvRmXn8.js} +1 -1
  114. package/dist/packem_shared/{watch-loop-TB9JRJUD.js → watch-loop-MKZ5_QXj.js} +1 -1
  115. package/index.d.ts +204 -213
  116. package/index.js +54 -54
  117. package/package.json +10 -10
  118. package/dist/packem_shared/glob-Cyk1H9ZL-DC9cczJJ.js +0 -1
@@ -1,4 +1,4 @@
1
- import{a as B,z as J,e as I,$ as q,U as K}from"../packem_shared/index-0dnGN3GP.js";import{M as Y,N as z,P as V,L as Z,C as Q,p as E,q as ee}from"./cli-main.js";import{i as re}from"../packem_shared/index-BjdW45xX.js";import{j as t,X as u,O as a,r as R,R as te,l as se,y as ne,z as oe,A as ie,h as ce,i as A}from"../packem_shared/registry-Dmy6zBD8.js";import le from"./index.js";import{sortPackageJsonStringWithOptions as U}from"#native";import{e as C}from"../packem_shared/utils-DQFHJn72.js";import{y as L}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";const _={error:0,rewritten:1,"would-rewrite":1,unchanged:2},ae=e=>[...e].sort((r,s)=>_[r.status]-_[s.status]),de=(e,r)=>r==="all"?e:r==="errors"?e.filter(s=>s.status==="error"):r==="rewritten"?e.filter(s=>s.status==="rewritten"||s.status==="would-rewrite"):e.filter(s=>s.status==="unchanged");class ue{#e;#r=new Set;constructor(r){this.#e={entries:ae(r),filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=r=>(this.#r.add(r),()=>{this.#r.delete(r)});getFilteredEntries=()=>de(this.#e.entries,this.#e.filterType);#t(){this.#e={...this.#e};for(const r of this.#r)r()}select(r){const s=this.getFilteredEntries();this.#e.selectedIndex=s.length===0?-1:Math.max(0,Math.min(r,s.length-1)),this.#t()}selectStep(r){this.select(this.#e.selectedIndex+r)}setFilter(r){this.#e.filterType=r,this.#e.selectedIndex=0,this.#t()}setFocusedPanel(r){this.#e.focusedPanel=r,this.#t()}}const fe=({checkMode:e,entry:r,focused:s,scrollRef:c})=>{const o=s?"white":"gray";return r?t.jsxs(u,{borderColor:o,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(u,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(a,{bold:!0,color:"white",children:r.relativePath})}),t.jsxs(Y,{flexGrow:1,flexShrink:1,paddingX:2,ref:c,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(a,{}),t.jsxs(u,{children:[t.jsx(u,{width:10,children:t.jsx(a,{dimColor:!0,children:"Status:"})}),r.status==="error"?t.jsx(a,{bold:!0,color:"red",children:"error"}):r.status==="unchanged"?t.jsx(a,{bold:!0,color:"green",children:"already sorted"}):r.status==="rewritten"?t.jsx(a,{bold:!0,color:"yellow",children:"rewritten"}):t.jsx(a,{bold:!0,color:"yellow",children:"would rewrite (--check)"})]}),t.jsxs(u,{children:[t.jsx(u,{width:10,children:t.jsx(a,{dimColor:!0,children:"Path:"})}),t.jsx(a,{children:r.filePath})]}),r.error?t.jsxs(t.Fragment,{children:[t.jsxs(u,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"red",children:"ERROR"}),t.jsxs(u,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(u,{children:[t.jsx(u,{width:10,children:t.jsx(a,{dimColor:!0,children:"Step:"})}),t.jsx(a,{color:"yellow",children:r.error.step})]}),r.error.context&&t.jsxs(u,{children:[t.jsx(u,{width:10,children:t.jsx(a,{dimColor:!0,children:"Position:"})}),t.jsx(a,{children:`line ${String(r.error.context.line)}, column ${String(r.error.context.column)}`})]}),t.jsx(u,{marginTop:1,children:t.jsx(a,{color:"red",children:r.error.message})})]})]}),r.error.context&&r.error.context.snippet.length>0&&t.jsxs(u,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"SNIPPET"}),t.jsxs(u,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r.error.context.snippet.map(n=>{const i=`${n.isErrorLine?"❯":" "} ${String(n.lineNumber).padStart(4)} `;return t.jsxs(u,{children:[t.jsx(a,{color:n.isErrorLine?"red":"gray",children:i}),t.jsx(a,{color:n.isErrorLine?"white":"gray",wrap:"truncate-end",children:n.content||" "})]},n.lineNumber)}),r.error.context.column>0&&t.jsx(u,{children:t.jsx(a,{color:"red",children:`${" ".repeat(7+r.error.context.column-1)}↑`})})]})]})]}):t.jsxs(u,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"KEY DIFF"}),t.jsx(u,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.diff.length===0?t.jsx(a,{dimColor:!0,children:"No top-level keys moved (sub-key reorder only)."}):r.diff.map(n=>{const i=n.toIndex-n.fromIndex,d=i<0?`↑ ${String(Math.abs(i))}`:`↓ ${String(i)}`,f=i<0?"green":"yellow";return t.jsxs(u,{children:[t.jsx(u,{width:28,children:t.jsx(a,{wrap:"truncate",children:n.key})}),t.jsx(u,{width:10,children:t.jsxs(a,{dimColor:!0,children:[String(n.fromIndex)," → ",String(n.toIndex)]})}),t.jsx(a,{color:f,children:d})]},n.key)})}),e&&r.status==="would-rewrite"&&t.jsx(u,{marginTop:1,paddingLeft:2,children:t.jsx(a,{dimColor:!0,children:"--check mode: no write performed."})})]})]})]}):t.jsx(u,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:t.jsx(a,{dimColor:!0,children:"No entry selected"})})},he={error:"red",rewritten:"yellow",unchanged:"green","would-rewrite":"yellow"},ge={error:"ERROR",rewritten:"REWROTE",unchanged:"SORTED","would-rewrite":"REWRITE"},W={error:"errors",rewritten:"rewrites",unchanged:"sorted","would-rewrite":"rewrites"},xe={errors:"Errors",rewrites:"Rewrites",sorted:"Sorted"},pe=[{count:e=>e.errors+e.rewrites+e.sorted,key:"all",label:"All",shortcut:"1"},{count:e=>e.rewrites,key:"rewritten",label:"Rewrites",shortcut:"2"},{count:e=>e.errors,key:"errors",label:"Errors",shortcut:"3"},{count:e=>e.sorted,key:"unchanged",label:"Sorted",shortcut:"4"}],X=e=>{const r={errors:0,rewrites:0,sorted:0};for(const s of e)r[W[s.status]]++;return r},me=({entry:e,isSelected:r})=>{const s=he[e.status],c=ge[e.status];return t.jsxs(u,{flexShrink:0,height:1,children:[t.jsx(a,{children:r?">":" "}),t.jsx(a,{children:" "}),t.jsx(a,{bold:!0,color:s,children:`[${c}]`.padEnd(10)}),t.jsx(a,{children:" "}),t.jsx(u,{flexGrow:1,children:t.jsx(a,{bold:r,inverse:r,wrap:"truncate",children:e.relativePath})}),e.status!=="error"&&e.diff.length>0&&t.jsx(a,{dimColor:!0,children:` ${String(e.diff.length)} key${e.diff.length===1?"":"s"}`})]})},je=({color:e,count:r,label:s})=>t.jsx(u,{flexShrink:0,height:1,children:t.jsx(a,{bold:!0,color:e,children:`${s} (${String(r)})`})}),Se=({counts:e,entries:r,filterType:s,focused:c,selectedIndex:o,totalEntries:n,viewportHeight:i})=>{const d=c?"white":"gray",f=X(r),x=(f.errors>0?1:0)+(f.rewrites>0?1:0)+(f.sorted>0?1:0),m=s==="all"&&x>1,h=[];let j;for(const[l,g]of r.entries()){const k=W[g.status];m&&k!==j&&(j!==void 0&&h.push({kind:"spacer"}),h.push({color:k==="errors"?"red":k==="rewrites"?"yellow":"green",count:f[k],kind:"header",label:xe[k]}),j=k),h.push({entry:g,entryIndex:l,kind:"entry"})}const p=h.findIndex(l=>l.kind==="entry"&&l.entryIndex===o),y=p!==-1,S=h.length,w=Math.max(0,S-i);let b=0;y&&i>0&&(b=Math.min(w,Math.max(0,p-i+1)));const O=S>i&&i>0;return t.jsxs(u,{borderColor:d,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(u,{flexShrink:0,gap:1,paddingX:1,children:[t.jsx(a,{bold:!0,inverse:!0,children:" VIS SORT "}),t.jsxs(a,{wrap:"truncate",children:[n," ","file",n===1?"":"s"]})]}),t.jsx(u,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:pe.map(l=>{const g=s===l.key,k=l.count(e);return t.jsxs(u,{children:[t.jsx(a,{dimColor:!g,children:"["}),t.jsx(a,{bold:g,color:g?"cyan":"gray",children:l.shortcut}),t.jsx(a,{dimColor:!g,children:"]"}),t.jsxs(a,{color:g?"white":"gray",children:[" ",l.label]}),t.jsxs(a,{dimColor:!0,children:[" ","(",k,")"]})]},l.key)})}),t.jsxs(u,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(u,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(u,{flexDirection:"column",marginTop:-b,children:h.map((l,g)=>l.kind==="spacer"?t.jsx(u,{flexShrink:0,height:1},`s-${String(g)}`):l.kind==="header"?t.jsx(je,{color:l.color,count:l.count,label:l.label},`h-${l.label}`):t.jsx(me,{entry:l.entry,isSelected:l.entryIndex===o},l.entry.filePath))})}),O&&t.jsx(u,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(z,{contentHeight:S,placement:"inset",scrollOffset:b,style:"block",viewportHeight:i})})]})]})},we=100,D=10,ye=6,ke=1,M={1:"all",2:"rewritten",3:"errors",4:"unchanged"},Ee=({checkMode:e,store:r})=>{const{exit:s}=V(),{columns:c,rows:o}=Z(),n=R.useSyncExternalStore(r.subscribe,r.getSnapshot),i=R.useRef(null),d=r.getFilteredEntries(),f=d[n.selectedIndex]??null,x=X(n.entries),m=c>=we,h=Math.max(0,o-ke),j=m?h:Math.floor(h/2),p=Math.max(0,j-ye),y=R.useCallback(()=>{s()},[s]),S=R.useRef(0),w=R.useRef(void 0),b=R.useRef(!1),O=R.useCallback((l,g)=>{S.current+=g,w.current=l,!b.current&&(b.current=!0,queueMicrotask(()=>{b.current=!1;const k=S.current,N=w.current;S.current=0,w.current=void 0,!(k===0||N===void 0)&&(N==="list"?r.selectStep(Math.sign(k)):i.current?.scrollBy(Math.sign(k)))}))},[r]);return Q((l,g)=>{if(l==="q"||g.escape){y();return}if(M[l]){r.setFilter(M[l]);return}if(g.tab){r.setFocusedPanel(n.focusedPanel==="list"?"detail":"list");return}n.focusedPanel==="list"?g.upArrow||l==="k"?O("list",-1):(g.downArrow||l==="j")&&O("list",1):n.focusedPanel==="detail"&&(g.upArrow||l==="k"?O("detail",-1):(g.downArrow||l==="j")&&O("detail",1))}),o<D?t.jsx(u,{alignItems:"center",justifyContent:"center",children:t.jsxs(a,{color:"yellow",children:["Terminal too small. Resize to at least",D," ","rows."]})}):t.jsxs(u,{flexDirection:"column",height:o,width:c,children:[t.jsxs(u,{flexDirection:m?"row":"column",flexGrow:1,children:[t.jsx(u,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(Se,{counts:x,entries:d,filterType:n.filterType,focused:n.focusedPanel==="list",selectedIndex:n.selectedIndex,totalEntries:n.entries.length,viewportHeight:p})}),t.jsx(u,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(fe,{checkMode:e,entry:f,focused:n.focusedPanel==="detail",scrollRef:i})})]}),t.jsx(u,{flexShrink:0,paddingX:1,children:t.jsx(a,{dimColor:!0,children:"↑/↓ or j/k:navigate | tab:switch panel | 1-4:filter | q:quit"})})]})},F=["types","node-addons","node","import","require","default"],be=/^git\+https:\/\/github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,Oe=/^git\+ssh:\/\/git@github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,T=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),$=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>$(s));const r={};for(const[s,c]of Object.entries(e))r[s]=$(c);return r},Re=e=>{if(!T(e))return{changed:!1,value:e};const r=Object.keys(e);return r.length===1&&r[0]==="url"&&typeof e.url=="string"?{changed:!0,value:e.url}:{changed:!1,value:e}},Ie=e=>e.endsWith(".git")?e.slice(0,-4):e,Ce=e=>{if(!T(e))return{changed:!1,value:e};if(typeof e.directory=="string"&&e.directory.length>0)return{changed:!1,value:e};const{type:r}=e;if(r!==void 0&&r!=="git")return{changed:!1,value:e};const{url:s}=e;if(typeof s!="string")return{changed:!1,value:e};const c=be.exec(s)??Oe.exec(s);if(!c)return{changed:!1,value:e};const o=c[1],n=Ie(c[2]??"");if(!o||!n)return{changed:!1,value:e};const i=new Set(["type","url"]);for(const d of Object.keys(e))if(!i.has(d))return{changed:!1,value:e};return{changed:!0,value:`${o}/${n}`}},Te=e=>{const r=Object.keys(e),s=[],c=[];for(const d of F)Object.hasOwn(e,d)&&s.push(d);for(const d of r)F.includes(d)||c.push(d);const o=[...s,...c];if(o.length===r.length&&o.every((d,f)=>d===r[f]))return{changed:!1,value:e};const i={};for(const d of o)i[d]=e[d];return{changed:!0,value:i}},H=e=>{if(!T(e))return{changed:!1,value:e};let r=!1;const s={};for(const[o,n]of Object.entries(e)){const i=H(n);s[o]=i.value,i.changed&&(r=!0)}const c=Te(s);return{changed:r||c.changed,value:c.value}},Pe=(e,r)=>{const s=$(e);let c=!1;if(r.formatBugs!==!1&&Object.hasOwn(s,"bugs")){const o=Re(s.bugs);o.changed&&(s.bugs=o.value,c=!0)}if(r.formatRepository!==!1&&Object.hasOwn(s,"repository")){const o=Ce(s.repository);o.changed&&(s.repository=o.value,c=!0)}if(r.sortExports!==!1&&Object.hasOwn(s,"exports")&&T(s.exports)){const o=H(s.exports);o.changed&&(s.exports=o.value,c=!0)}return{changed:c,pkg:s}},$e=/at position (\d+)/,Ne=/\(?line (\d+) column (\d+)\)?/,Ae=e=>{const r=new Set,s=[],c=n=>{const i=K(n);!r.has(i)&&L(i)&&(r.add(i),s.push(i))};c(I(e,"package.json"));const o=ce(e);if(o){const n=A(e,o);for(const i of n)c(I(e,i,"package.json"))}else{const n=I(e,"package.json");if(L(n)){const i=JSON.parse(J(n)),d=Array.isArray(i.workspaces)?i.workspaces:i.workspaces?.packages;if(d){const f=A(e,d);for(const x of f)c(I(e,x,"package.json"))}}}return s},Le=e=>/\n([ \t]+)/.exec(e)?.[1]??" ",_e=e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},P=e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(s=>s.split(",")).map(s=>s.trim()).filter(s=>s.length>0),De=e=>e.includes(`\r
1
+ import{a as B,z as J,e as I,$ as q,U as K}from"../packem_shared/index-0dnGN3GP.js";import{M as Y,N as z,P as V,L as Z,C as Q,p as E,q as ee}from"./cli-main.js";import{i as re}from"../packem_shared/index-BjdW45xX.js";import{j as t,X as u,O as a,r as R,R as te,l as se,y as ne,z as oe,A as ie,h as ce,i as A}from"../packem_shared/registry-C_cLtZJm.js";import le from"./index.js";import{sortPackageJsonStringWithOptions as U}from"#native";import{e as C}from"../packem_shared/utils-DQFHJn72.js";import{y as L}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";const _={error:0,rewritten:1,"would-rewrite":1,unchanged:2},ae=e=>[...e].sort((r,s)=>_[r.status]-_[s.status]),de=(e,r)=>r==="all"?e:r==="errors"?e.filter(s=>s.status==="error"):r==="rewritten"?e.filter(s=>s.status==="rewritten"||s.status==="would-rewrite"):e.filter(s=>s.status==="unchanged");class ue{#e;#r=new Set;constructor(r){this.#e={entries:ae(r),filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=r=>(this.#r.add(r),()=>{this.#r.delete(r)});getFilteredEntries=()=>de(this.#e.entries,this.#e.filterType);#t(){this.#e={...this.#e};for(const r of this.#r)r()}select(r){const s=this.getFilteredEntries();this.#e.selectedIndex=s.length===0?-1:Math.max(0,Math.min(r,s.length-1)),this.#t()}selectStep(r){this.select(this.#e.selectedIndex+r)}setFilter(r){this.#e.filterType=r,this.#e.selectedIndex=0,this.#t()}setFocusedPanel(r){this.#e.focusedPanel=r,this.#t()}}const fe=({checkMode:e,entry:r,focused:s,scrollRef:c})=>{const o=s?"white":"gray";return r?t.jsxs(u,{borderColor:o,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(u,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(a,{bold:!0,color:"white",children:r.relativePath})}),t.jsxs(Y,{flexGrow:1,flexShrink:1,paddingX:2,ref:c,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(a,{}),t.jsxs(u,{children:[t.jsx(u,{width:10,children:t.jsx(a,{dimColor:!0,children:"Status:"})}),r.status==="error"?t.jsx(a,{bold:!0,color:"red",children:"error"}):r.status==="unchanged"?t.jsx(a,{bold:!0,color:"green",children:"already sorted"}):r.status==="rewritten"?t.jsx(a,{bold:!0,color:"yellow",children:"rewritten"}):t.jsx(a,{bold:!0,color:"yellow",children:"would rewrite (--check)"})]}),t.jsxs(u,{children:[t.jsx(u,{width:10,children:t.jsx(a,{dimColor:!0,children:"Path:"})}),t.jsx(a,{children:r.filePath})]}),r.error?t.jsxs(t.Fragment,{children:[t.jsxs(u,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"red",children:"ERROR"}),t.jsxs(u,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(u,{children:[t.jsx(u,{width:10,children:t.jsx(a,{dimColor:!0,children:"Step:"})}),t.jsx(a,{color:"yellow",children:r.error.step})]}),r.error.context&&t.jsxs(u,{children:[t.jsx(u,{width:10,children:t.jsx(a,{dimColor:!0,children:"Position:"})}),t.jsx(a,{children:`line ${String(r.error.context.line)}, column ${String(r.error.context.column)}`})]}),t.jsx(u,{marginTop:1,children:t.jsx(a,{color:"red",children:r.error.message})})]})]}),r.error.context&&r.error.context.snippet.length>0&&t.jsxs(u,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"SNIPPET"}),t.jsxs(u,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r.error.context.snippet.map(n=>{const i=`${n.isErrorLine?"❯":" "} ${String(n.lineNumber).padStart(4)} `;return t.jsxs(u,{children:[t.jsx(a,{color:n.isErrorLine?"red":"gray",children:i}),t.jsx(a,{color:n.isErrorLine?"white":"gray",wrap:"truncate-end",children:n.content||" "})]},n.lineNumber)}),r.error.context.column>0&&t.jsx(u,{children:t.jsx(a,{color:"red",children:`${" ".repeat(7+r.error.context.column-1)}↑`})})]})]})]}):t.jsxs(u,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"KEY DIFF"}),t.jsx(u,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.diff.length===0?t.jsx(a,{dimColor:!0,children:"No top-level keys moved (sub-key reorder only)."}):r.diff.map(n=>{const i=n.toIndex-n.fromIndex,d=i<0?`↑ ${String(Math.abs(i))}`:`↓ ${String(i)}`,f=i<0?"green":"yellow";return t.jsxs(u,{children:[t.jsx(u,{width:28,children:t.jsx(a,{wrap:"truncate",children:n.key})}),t.jsx(u,{width:10,children:t.jsxs(a,{dimColor:!0,children:[String(n.fromIndex)," → ",String(n.toIndex)]})}),t.jsx(a,{color:f,children:d})]},n.key)})}),e&&r.status==="would-rewrite"&&t.jsx(u,{marginTop:1,paddingLeft:2,children:t.jsx(a,{dimColor:!0,children:"--check mode: no write performed."})})]})]})]}):t.jsx(u,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:t.jsx(a,{dimColor:!0,children:"No entry selected"})})},he={error:"red",rewritten:"yellow",unchanged:"green","would-rewrite":"yellow"},ge={error:"ERROR",rewritten:"REWROTE",unchanged:"SORTED","would-rewrite":"REWRITE"},W={error:"errors",rewritten:"rewrites",unchanged:"sorted","would-rewrite":"rewrites"},xe={errors:"Errors",rewrites:"Rewrites",sorted:"Sorted"},pe=[{count:e=>e.errors+e.rewrites+e.sorted,key:"all",label:"All",shortcut:"1"},{count:e=>e.rewrites,key:"rewritten",label:"Rewrites",shortcut:"2"},{count:e=>e.errors,key:"errors",label:"Errors",shortcut:"3"},{count:e=>e.sorted,key:"unchanged",label:"Sorted",shortcut:"4"}],X=e=>{const r={errors:0,rewrites:0,sorted:0};for(const s of e)r[W[s.status]]++;return r},me=({entry:e,isSelected:r})=>{const s=he[e.status],c=ge[e.status];return t.jsxs(u,{flexShrink:0,height:1,children:[t.jsx(a,{children:r?">":" "}),t.jsx(a,{children:" "}),t.jsx(a,{bold:!0,color:s,children:`[${c}]`.padEnd(10)}),t.jsx(a,{children:" "}),t.jsx(u,{flexGrow:1,children:t.jsx(a,{bold:r,inverse:r,wrap:"truncate",children:e.relativePath})}),e.status!=="error"&&e.diff.length>0&&t.jsx(a,{dimColor:!0,children:` ${String(e.diff.length)} key${e.diff.length===1?"":"s"}`})]})},je=({color:e,count:r,label:s})=>t.jsx(u,{flexShrink:0,height:1,children:t.jsx(a,{bold:!0,color:e,children:`${s} (${String(r)})`})}),Se=({counts:e,entries:r,filterType:s,focused:c,selectedIndex:o,totalEntries:n,viewportHeight:i})=>{const d=c?"white":"gray",f=X(r),x=(f.errors>0?1:0)+(f.rewrites>0?1:0)+(f.sorted>0?1:0),m=s==="all"&&x>1,h=[];let j;for(const[l,g]of r.entries()){const k=W[g.status];m&&k!==j&&(j!==void 0&&h.push({kind:"spacer"}),h.push({color:k==="errors"?"red":k==="rewrites"?"yellow":"green",count:f[k],kind:"header",label:xe[k]}),j=k),h.push({entry:g,entryIndex:l,kind:"entry"})}const p=h.findIndex(l=>l.kind==="entry"&&l.entryIndex===o),y=p!==-1,S=h.length,w=Math.max(0,S-i);let b=0;y&&i>0&&(b=Math.min(w,Math.max(0,p-i+1)));const O=S>i&&i>0;return t.jsxs(u,{borderColor:d,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(u,{flexShrink:0,gap:1,paddingX:1,children:[t.jsx(a,{bold:!0,inverse:!0,children:" VIS SORT "}),t.jsxs(a,{wrap:"truncate",children:[n," ","file",n===1?"":"s"]})]}),t.jsx(u,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:pe.map(l=>{const g=s===l.key,k=l.count(e);return t.jsxs(u,{children:[t.jsx(a,{dimColor:!g,children:"["}),t.jsx(a,{bold:g,color:g?"cyan":"gray",children:l.shortcut}),t.jsx(a,{dimColor:!g,children:"]"}),t.jsxs(a,{color:g?"white":"gray",children:[" ",l.label]}),t.jsxs(a,{dimColor:!0,children:[" ","(",k,")"]})]},l.key)})}),t.jsxs(u,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(u,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(u,{flexDirection:"column",marginTop:-b,children:h.map((l,g)=>l.kind==="spacer"?t.jsx(u,{flexShrink:0,height:1},`s-${String(g)}`):l.kind==="header"?t.jsx(je,{color:l.color,count:l.count,label:l.label},`h-${l.label}`):t.jsx(me,{entry:l.entry,isSelected:l.entryIndex===o},l.entry.filePath))})}),O&&t.jsx(u,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(z,{contentHeight:S,placement:"inset",scrollOffset:b,style:"block",viewportHeight:i})})]})]})},we=100,D=10,ye=6,ke=1,M={1:"all",2:"rewritten",3:"errors",4:"unchanged"},Ee=({checkMode:e,store:r})=>{const{exit:s}=V(),{columns:c,rows:o}=Z(),n=R.useSyncExternalStore(r.subscribe,r.getSnapshot),i=R.useRef(null),d=r.getFilteredEntries(),f=d[n.selectedIndex]??null,x=X(n.entries),m=c>=we,h=Math.max(0,o-ke),j=m?h:Math.floor(h/2),p=Math.max(0,j-ye),y=R.useCallback(()=>{s()},[s]),S=R.useRef(0),w=R.useRef(void 0),b=R.useRef(!1),O=R.useCallback((l,g)=>{S.current+=g,w.current=l,!b.current&&(b.current=!0,queueMicrotask(()=>{b.current=!1;const k=S.current,N=w.current;S.current=0,w.current=void 0,!(k===0||N===void 0)&&(N==="list"?r.selectStep(Math.sign(k)):i.current?.scrollBy(Math.sign(k)))}))},[r]);return Q((l,g)=>{if(l==="q"||g.escape){y();return}if(M[l]){r.setFilter(M[l]);return}if(g.tab){r.setFocusedPanel(n.focusedPanel==="list"?"detail":"list");return}n.focusedPanel==="list"?g.upArrow||l==="k"?O("list",-1):(g.downArrow||l==="j")&&O("list",1):n.focusedPanel==="detail"&&(g.upArrow||l==="k"?O("detail",-1):(g.downArrow||l==="j")&&O("detail",1))}),o<D?t.jsx(u,{alignItems:"center",justifyContent:"center",children:t.jsxs(a,{color:"yellow",children:["Terminal too small. Resize to at least",D," ","rows."]})}):t.jsxs(u,{flexDirection:"column",height:o,width:c,children:[t.jsxs(u,{flexDirection:m?"row":"column",flexGrow:1,children:[t.jsx(u,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(Se,{counts:x,entries:d,filterType:n.filterType,focused:n.focusedPanel==="list",selectedIndex:n.selectedIndex,totalEntries:n.entries.length,viewportHeight:p})}),t.jsx(u,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(fe,{checkMode:e,entry:f,focused:n.focusedPanel==="detail",scrollRef:i})})]}),t.jsx(u,{flexShrink:0,paddingX:1,children:t.jsx(a,{dimColor:!0,children:"↑/↓ or j/k:navigate | tab:switch panel | 1-4:filter | q:quit"})})]})},F=["types","node-addons","node","import","require","default"],be=/^git\+https:\/\/github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,Oe=/^git\+ssh:\/\/git@github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,T=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),$=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>$(s));const r={};for(const[s,c]of Object.entries(e))r[s]=$(c);return r},Re=e=>{if(!T(e))return{changed:!1,value:e};const r=Object.keys(e);return r.length===1&&r[0]==="url"&&typeof e.url=="string"?{changed:!0,value:e.url}:{changed:!1,value:e}},Ie=e=>e.endsWith(".git")?e.slice(0,-4):e,Ce=e=>{if(!T(e))return{changed:!1,value:e};if(typeof e.directory=="string"&&e.directory.length>0)return{changed:!1,value:e};const{type:r}=e;if(r!==void 0&&r!=="git")return{changed:!1,value:e};const{url:s}=e;if(typeof s!="string")return{changed:!1,value:e};const c=be.exec(s)??Oe.exec(s);if(!c)return{changed:!1,value:e};const o=c[1],n=Ie(c[2]??"");if(!o||!n)return{changed:!1,value:e};const i=new Set(["type","url"]);for(const d of Object.keys(e))if(!i.has(d))return{changed:!1,value:e};return{changed:!0,value:`${o}/${n}`}},Te=e=>{const r=Object.keys(e),s=[],c=[];for(const d of F)Object.hasOwn(e,d)&&s.push(d);for(const d of r)F.includes(d)||c.push(d);const o=[...s,...c];if(o.length===r.length&&o.every((d,f)=>d===r[f]))return{changed:!1,value:e};const i={};for(const d of o)i[d]=e[d];return{changed:!0,value:i}},H=e=>{if(!T(e))return{changed:!1,value:e};let r=!1;const s={};for(const[o,n]of Object.entries(e)){const i=H(n);s[o]=i.value,i.changed&&(r=!0)}const c=Te(s);return{changed:r||c.changed,value:c.value}},Pe=(e,r)=>{const s=$(e);let c=!1;if(r.formatBugs!==!1&&Object.hasOwn(s,"bugs")){const o=Re(s.bugs);o.changed&&(s.bugs=o.value,c=!0)}if(r.formatRepository!==!1&&Object.hasOwn(s,"repository")){const o=Ce(s.repository);o.changed&&(s.repository=o.value,c=!0)}if(r.sortExports!==!1&&Object.hasOwn(s,"exports")&&T(s.exports)){const o=H(s.exports);o.changed&&(s.exports=o.value,c=!0)}return{changed:c,pkg:s}},$e=/at position (\d+)/,Ne=/\(?line (\d+) column (\d+)\)?/,Ae=e=>{const r=new Set,s=[],c=n=>{const i=K(n);!r.has(i)&&L(i)&&(r.add(i),s.push(i))};c(I(e,"package.json"));const o=ce(e);if(o){const n=A(e,o);for(const i of n)c(I(e,i,"package.json"))}else{const n=I(e,"package.json");if(L(n)){const i=JSON.parse(J(n)),d=Array.isArray(i.workspaces)?i.workspaces:i.workspaces?.packages;if(d){const f=A(e,d);for(const x of f)c(I(e,x,"package.json"))}}}return s},Le=e=>/\n([ \t]+)/.exec(e)?.[1]??" ",_e=e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},P=e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(s=>s.split(",")).map(s=>s.trim()).filter(s=>s.length>0),De=e=>e.includes(`\r
2
2
  `)?"crlf":"lf",Me=new Set(["auto","crlf","lf"]),Fe=e=>{if(e===void 0||e==="")return"auto";if(Me.has(e))return e;throw new Error(`--line-ending must be one of: auto, lf, crlf (got "${e}")`)},Ge=(e,r,s)=>r.length===0?e:e.filter(c=>{const o=B(s,c),n=q(c);return!r.some(i=>{const d=i.includes("/")?o:n;return le(i,d)})}),ve=(e,r)=>{if(r.length===0)return e;const s={},c=new Set;for(const o of r)Object.hasOwn(e,o)&&(s[o]=e[o],c.add(o));for(const o of Object.keys(e))c.has(o)||(s[o]=e[o]);return s},Be=(e,r,s)=>{if(s.length===0)return e;const c={...e};for(const o of s)Object.hasOwn(r,o)&&(c[o]=r[o]);return c},Je=(e,r)=>{let s=1,c=1;const o=Math.min(r,e.length);for(let n=0;n<o;n++)e.codePointAt(n)===10?(s++,c=1):c++;return{column:c,line:s}},G=(e,r,s=2)=>{const c=e.split(`
3
3
  `);if(r<1||r>c.length)return[];const o=Math.max(0,r-1-s),n=Math.min(c.length,r+s),i=[];for(let d=o;d<n;d++)i.push({content:c[d]??"",isErrorLine:d+1===r,lineNumber:d+1});return i},v=(e,r)=>{if(!(e instanceof Error))return;const s=$e.exec(e.message);if(s){const{column:o,line:n}=Je(r,Number.parseInt(s[1]??"0",10));return{column:o,line:n,snippet:G(r,n)}}const c=Ne.exec(e.message);if(c){const o=Number.parseInt(c[1]??"1",10);return{column:Number.parseInt(c[2]??"1",10),line:o,snippet:G(r,o)}}},Ue=(e,r)=>{const s=Object.keys(JSON.parse(e)),c=Object.keys(JSON.parse(r)),o=new Map(s.map((i,d)=>[i,d])),n=[];for(const[i,d]of c.entries()){const f=o.get(d);f!==void 0&&f!==i&&n.push({fromIndex:f,key:d,toIndex:i})}return n},We=(e,r,s)=>{const c=r.indent??s.indent??Le(e),o=r.lineEnding==="auto"?s.lineEnding??De(e):r.lineEnding,n=U(e,{pretty:!1,sortScripts:r.sortScripts});let i=JSON.parse(n);if(r.unsorted.length>0){const m=JSON.parse(e);i=Be(i,m,r.unsorted)}i=ve(i,r.sortOrder);const d={formatBugs:r.formatBugs,formatRepository:r.formatRepository,sortExports:r.sortExports},f=Pe(i,d);let x=JSON.stringify(f.pkg,null,c);return r.finalNewline&&(x+=`
4
4
  `),o==="crlf"&&(x=x.replaceAll(`
@@ -1,4 +1,4 @@
1
- import{createRequire as Z}from"node:module";import{J as I,j as re,F as O,X as U,b as D,q as ie}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as S}from"../packem_shared/index-0dnGN3GP.js";import{T as se}from"./cli-main.js";import{w as ae,r as oe,a as ce,s as le,c as de,b as ue,d as fe,o as ge,p as P,g as pe,h as me,i as he,j as xe,k as we,l as ve,n as ye,m as ke}from"../packem_shared/watch-loop-TB9JRJUD.js";import{v as d}from"../packem_shared/registry-Dmy6zBD8.js";import{d as f,f as b,r as be,a as $e}from"../packem_shared/detect-DF0ZnX4w.js";import{R as Ae}from"./ts-loader.js";let ee;const te=e=>(ee??=Z(import.meta.url))(e),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ne=e=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[t,n]=k.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return k.getBuiltinModule(e)}return te(e)},{createHash:h}=ne("node:crypto"),Ce={1:"warning",2:"error"},Fe={argsCheck:(e,t)=>V(e,t,!1),argsFix:(e,t)=>V(e,t,!0),bin:()=>["pnpm","exec","eslint"],cacheKey:(e,t)=>{const n=["eslint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.eslint.packageNames[0]),r=b(e,d.eslint.configFiles);if(!(!n&&!r))return{adapter:"eslint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["cjs","cts","js","jsx","mjs","mts","ts","tsx","vue"],id:"eslint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"eslint",file:t.root,fixable:!1,message:`eslint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n)for(const s of i.messages)r.push({adapter:"eslint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.filePath,fixable:!!s.fix,line:s.line,message:s.message,ruleId:s.ruleId??void 0,severity:s.fatal?"error":Ce[s.severity]??"warning"});return r}},V=(e,t,n)=>{const r=["--format","json","--no-error-on-unmatched-pattern"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push("--max-warnings",String(t.maxWarnings)),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},Se=/^([^:]+):(\d+)(?::(\d+))?\s+([\w/-]+)\s+(.+)$/,je=e=>{const t=Se.exec(e);if(!t)return;const[,n,r,i,s,c]=t;return{column:i===void 0?void 0:Number(i),file:n,line:Number(r),message:c,ruleId:s}},_e=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Ne={argsCheck:(e,t)=>M(e,t,!1),argsFix:(e,t)=>M(e,t,!0),bin:()=>["pnpm","exec","markdownlint-cli2"],cacheKey:(e,t)=>{const n=["markdownlint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=d.markdownlint.packageNames.map(i=>f(t,i)).find(i=>i!==void 0),r=b(e,d.markdownlint.configFiles);if(!(!n&&!r))return{adapter:"markdownlint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["markdown","md"],id:"markdownlint",kind:"lint",parse:(e,t)=>{const n=(e.stderr||e.stdout||"").trim();if(!n)return[];const r=[];for(const i of n.split(/\r?\n/)){const s=je(i.trim());s&&r.push({adapter:"markdownlint",column:s.column,file:_e(s.file)?s.file:`${t.root}/${s.file}`,fixable:!0,line:s.line,message:s.message,ruleId:s.ruleId,severity:"warning"})}return r}},M=(e,t,n)=>{const r=[];return n&&r.push("--fix"),t.extraArgs?.length&&r.push(...t.extraArgs),e.length===0?r.push("**/*.md"):r.push(...e),r},qe={advice:"info",error:"error",warning:"warning"},Ie={argsCheck:(e,t)=>L(e,t,!1),argsFix:(e,t)=>L(e,t,!0),bin:()=>["pnpm","exec","oxlint"],cacheKey:(e,t)=>{const n=["oxlint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.oxlint.packageNames[0]),r=b(e,d.oxlint.configFiles);if(!(!n&&!r))return{adapter:"oxlint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","cjs","cts","js","jsx","mjs","mts","svelte","ts","tsx","vue"],id:"oxlint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"oxlint",file:t.root,fixable:!1,message:`oxlint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n.diagnostics??[]){const s=i.labels?.[0]?.span;r.push({adapter:"oxlint",column:s?.column,file:i.filename??t.root,fixable:!1,line:s?.line,message:i.message??"",ruleId:i.code,severity:qe[i.severity??""]??"warning"})}return r}},L=(e,t,n)=>{const r=["--format","json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push(`--max-warnings=${String(t.maxWarnings)}`),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},We={error:"error",info:"info",style:"info",warning:"warning"},Re=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Te=(e,t)=>e?Re(e)?e:`${t}/${e}`:t,Ee={argsCheck:(e,t)=>B(e,t),argsFix:(e,t)=>B(e,t),bin:()=>["shellcheck"],cacheKey:(e,t)=>{const n=["shellcheck",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.shellcheck.packageNames[0]),r=b(e,d.shellcheck.configFiles);if(!(!n&&!r))return{adapter:"shellcheck",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["bash","ksh","sh"],id:"shellcheck",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"shellcheck",file:t.root,fixable:!1,message:`shellcheck output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n.comments??[])r.push({adapter:"shellcheck",column:i.column,endColumn:i.endColumn,endLine:i.endLine,file:Te(i.file,t.root),fixable:!!i.fix,line:i.line,message:i.message??"",ruleId:i.code===void 0?void 0:`SC${String(i.code)}`,severity:We[i.level??""]??"warning"});return r}},B=(e,t)=>{const n=["--format=json1"];return t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},Oe={error:"error",warning:"warning"},Pe={argsCheck:(e,t)=>J(e,t,!1),argsFix:(e,t)=>J(e,t,!0),bin:()=>["pnpm","exec","stylelint"],cacheKey:(e,t)=>{const n=["stylelint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.stylelint.packageNames[0]),r=b(e,d.stylelint.configFiles);if(!(!n&&!r))return{adapter:"stylelint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","css","less","sass","scss","svelte","vue"],id:"stylelint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"stylelint",file:t.root,fixable:!1,message:`stylelint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n)for(const s of i.warnings??[])r.push({adapter:"stylelint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.source,fixable:!1,line:s.line,message:s.text??"",ruleId:s.rule,severity:Oe[s.severity??""]??"warning"});return r}},J=(e,t,n)=>{const r=["--formatter","json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push("--max-warnings",String(t.maxWarnings)),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},G="@typescript/native-preview",Ve=2e3,Me=/^(.*)\((\d+),(\d+)\): (error|warning) (TS\d+): (.*)$/,Le=/^(error|warning) (TS\d+): (.*)$/,Y=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Be=(e,t)=>Y(e)?e:`${t}/${e}`,z=e=>{try{return Ae(e)}catch{return}},Je=e=>{const t=z(e);return Array.isArray(t?.config.references)&&t.config.references.length>0},Ke=e=>{const t=be(e);return!f(t,"typescript")&&f(t,G)?"tsgo":"tsc"},Ue={argsCheck:(e,t)=>K(t),argsFix:(e,t)=>K(t),bin:e=>{const t=["pnpm","exec",Ke(e.root)],n=e.configFile?S(e.root,e.configFile):"tsconfig.json";return e.configFile&&Je(e.root)?[...t,"-b","--pretty","false",n]:[...t,"-p",n,"--noEmit","--pretty","false"]},cacheKey:(e,t)=>{const n=["typecheck",e.declaredVersion??"unknown",e.configFile??"no-config",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,"typescript"),r=f(t,G),i=z(e),s=i?S(e,i.path):void 0;if(!(!n&&!r||!i||!s||s===".."||s.startsWith("../")||Y(s)))return{adapter:"typecheck",configFile:i.path,declared:!0,declaredVersion:n??r,root:e}},extensions:["cts","mts","ts","tsx"],id:"typecheck",kind:"lint",optIn:!0,parse:(e,t)=>{const n=[];for(const r of`${e.stdout}
1
+ import{createRequire as Z}from"node:module";import{J as I,j as re,F as O,X as U,b as D,q as ie}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as S}from"../packem_shared/index-0dnGN3GP.js";import{T as se}from"./cli-main.js";import{w as ae,r as oe,a as ce,s as le,c as de,b as ue,d as fe,o as ge,p as P,g as pe,h as me,i as he,j as xe,k as we,l as ve,n as ye,m as ke}from"../packem_shared/watch-loop-MKZ5_QXj.js";import{v as d}from"../packem_shared/registry-C_cLtZJm.js";import{d as f,f as b,r as be,a as $e}from"../packem_shared/detect-BOf9_Brj.js";import{R as Ae}from"./ts-loader.js";let ee;const te=e=>(ee??=Z(import.meta.url))(e),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ne=e=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[t,n]=k.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return k.getBuiltinModule(e)}return te(e)},{createHash:h}=ne("node:crypto"),Ce={1:"warning",2:"error"},Fe={argsCheck:(e,t)=>V(e,t,!1),argsFix:(e,t)=>V(e,t,!0),bin:()=>["pnpm","exec","eslint"],cacheKey:(e,t)=>{const n=["eslint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.eslint.packageNames[0]),r=b(e,d.eslint.configFiles);if(!(!n&&!r))return{adapter:"eslint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["cjs","cts","js","jsx","mjs","mts","ts","tsx","vue"],id:"eslint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"eslint",file:t.root,fixable:!1,message:`eslint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n)for(const s of i.messages)r.push({adapter:"eslint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.filePath,fixable:!!s.fix,line:s.line,message:s.message,ruleId:s.ruleId??void 0,severity:s.fatal?"error":Ce[s.severity]??"warning"});return r}},V=(e,t,n)=>{const r=["--format","json","--no-error-on-unmatched-pattern"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push("--max-warnings",String(t.maxWarnings)),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},Se=/^([^:]+):(\d+)(?::(\d+))?\s+([\w/-]+)\s+(.+)$/,je=e=>{const t=Se.exec(e);if(!t)return;const[,n,r,i,s,c]=t;return{column:i===void 0?void 0:Number(i),file:n,line:Number(r),message:c,ruleId:s}},_e=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Ne={argsCheck:(e,t)=>M(e,t,!1),argsFix:(e,t)=>M(e,t,!0),bin:()=>["pnpm","exec","markdownlint-cli2"],cacheKey:(e,t)=>{const n=["markdownlint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=d.markdownlint.packageNames.map(i=>f(t,i)).find(i=>i!==void 0),r=b(e,d.markdownlint.configFiles);if(!(!n&&!r))return{adapter:"markdownlint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["markdown","md"],id:"markdownlint",kind:"lint",parse:(e,t)=>{const n=(e.stderr||e.stdout||"").trim();if(!n)return[];const r=[];for(const i of n.split(/\r?\n/)){const s=je(i.trim());s&&r.push({adapter:"markdownlint",column:s.column,file:_e(s.file)?s.file:`${t.root}/${s.file}`,fixable:!0,line:s.line,message:s.message,ruleId:s.ruleId,severity:"warning"})}return r}},M=(e,t,n)=>{const r=[];return n&&r.push("--fix"),t.extraArgs?.length&&r.push(...t.extraArgs),e.length===0?r.push("**/*.md"):r.push(...e),r},qe={advice:"info",error:"error",warning:"warning"},Ie={argsCheck:(e,t)=>L(e,t,!1),argsFix:(e,t)=>L(e,t,!0),bin:()=>["pnpm","exec","oxlint"],cacheKey:(e,t)=>{const n=["oxlint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.oxlint.packageNames[0]),r=b(e,d.oxlint.configFiles);if(!(!n&&!r))return{adapter:"oxlint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","cjs","cts","js","jsx","mjs","mts","svelte","ts","tsx","vue"],id:"oxlint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"oxlint",file:t.root,fixable:!1,message:`oxlint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n.diagnostics??[]){const s=i.labels?.[0]?.span;r.push({adapter:"oxlint",column:s?.column,file:i.filename??t.root,fixable:!1,line:s?.line,message:i.message??"",ruleId:i.code,severity:qe[i.severity??""]??"warning"})}return r}},L=(e,t,n)=>{const r=["--format","json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push(`--max-warnings=${String(t.maxWarnings)}`),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},We={error:"error",info:"info",style:"info",warning:"warning"},Re=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Te=(e,t)=>e?Re(e)?e:`${t}/${e}`:t,Ee={argsCheck:(e,t)=>B(e,t),argsFix:(e,t)=>B(e,t),bin:()=>["shellcheck"],cacheKey:(e,t)=>{const n=["shellcheck",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.shellcheck.packageNames[0]),r=b(e,d.shellcheck.configFiles);if(!(!n&&!r))return{adapter:"shellcheck",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["bash","ksh","sh"],id:"shellcheck",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"shellcheck",file:t.root,fixable:!1,message:`shellcheck output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n.comments??[])r.push({adapter:"shellcheck",column:i.column,endColumn:i.endColumn,endLine:i.endLine,file:Te(i.file,t.root),fixable:!!i.fix,line:i.line,message:i.message??"",ruleId:i.code===void 0?void 0:`SC${String(i.code)}`,severity:We[i.level??""]??"warning"});return r}},B=(e,t)=>{const n=["--format=json1"];return t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},Oe={error:"error",warning:"warning"},Pe={argsCheck:(e,t)=>J(e,t,!1),argsFix:(e,t)=>J(e,t,!0),bin:()=>["pnpm","exec","stylelint"],cacheKey:(e,t)=>{const n=["stylelint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.stylelint.packageNames[0]),r=b(e,d.stylelint.configFiles);if(!(!n&&!r))return{adapter:"stylelint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","css","less","sass","scss","svelte","vue"],id:"stylelint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"stylelint",file:t.root,fixable:!1,message:`stylelint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n)for(const s of i.warnings??[])r.push({adapter:"stylelint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.source,fixable:!1,line:s.line,message:s.text??"",ruleId:s.rule,severity:Oe[s.severity??""]??"warning"});return r}},J=(e,t,n)=>{const r=["--formatter","json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push("--max-warnings",String(t.maxWarnings)),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},G="@typescript/native-preview",Ve=2e3,Me=/^(.*)\((\d+),(\d+)\): (error|warning) (TS\d+): (.*)$/,Le=/^(error|warning) (TS\d+): (.*)$/,Y=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Be=(e,t)=>Y(e)?e:`${t}/${e}`,z=e=>{try{return Ae(e)}catch{return}},Je=e=>{const t=z(e);return Array.isArray(t?.config.references)&&t.config.references.length>0},Ke=e=>{const t=be(e);return!f(t,"typescript")&&f(t,G)?"tsgo":"tsc"},Ue={argsCheck:(e,t)=>K(t),argsFix:(e,t)=>K(t),bin:e=>{const t=["pnpm","exec",Ke(e.root)],n=e.configFile?S(e.root,e.configFile):"tsconfig.json";return e.configFile&&Je(e.root)?[...t,"-b","--pretty","false",n]:[...t,"-p",n,"--noEmit","--pretty","false"]},cacheKey:(e,t)=>{const n=["typecheck",e.declaredVersion??"unknown",e.configFile??"no-config",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,"typescript"),r=f(t,G),i=z(e),s=i?S(e,i.path):void 0;if(!(!n&&!r||!i||!s||s===".."||s.startsWith("../")||Y(s)))return{adapter:"typecheck",configFile:i.path,declared:!0,declaredVersion:n??r,root:e}},extensions:["cts","mts","ts","tsx"],id:"typecheck",kind:"lint",optIn:!0,parse:(e,t)=>{const n=[];for(const r of`${e.stdout}
2
2
  ${e.stderr}`.split(/\r?\n/)){const i=Me.exec(r);if(i){n.push({adapter:"typecheck",column:Number(i[3]),file:Be(i[1],t.root),fixable:!1,line:Number(i[2]),message:i[6],ruleId:i[5],severity:i[4]==="warning"?"warning":"error"});continue}const s=Le.exec(r);if(s){n.push({adapter:"typecheck",file:t.root,fixable:!1,message:s[3],ruleId:s[2],severity:s[1]==="warning"?"warning":"error"});continue}const c=n.at(-1);c&&/^\s+\S/.test(r)&&(c.message+=`
3
3
  ${r.trim()}`)}if(n.length===0&&e.exitCode!==0){const r=`${e.stdout}
4
4
  ${e.stderr}`.trim().slice(0,Ve);n.push({adapter:"typecheck",file:t.root,fixable:!1,message:e.exitCode===null?`type-check did not complete (killed or timed out)${r?`:
@@ -1,2 +1,2 @@
1
- import{createRequire as F}from"node:module";import{i as W}from"../packem_shared/index-BjdW45xX.js";import{p as Y}from"../packem_shared/prompt-DMzaQEVa.js";import{e as U}from"../packem_shared/index-0dnGN3GP.js";import{n as B,h as X,U as J,o as Q,p as Z,e as ee,q as te,m as _}from"../packem_shared/env-D0huQDyA.js";import{y as se}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as re}from"../packem_shared/package-version-CtgyD_B1.js";import{g as oe,r as ne}from"../packem_shared/packument-BOiBtGV2.js";import{q as ce,j as ie,F as v,b as S,X as E,J as A}from"../packem_shared/index.server-Ca_EEVfw.js";import{z as ae}from"../packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js";import{a as le,o as fe}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{r as ue,a as pe}from"../packem_shared/command-runtime-DG49t2MT.js";let z;const V=e=>(z??=F(import.meta.url))(e),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(e)}return V(e)},{renameSync:q}=M("node:fs"),{stripVTControlCharacters:G}=M("node:util"),de=(e={})=>{const t=e.isCi??W;return(e.isTty??!!(process.stdin.isTTY&&process.stdout.isTTY))&&!t},k=U(B(),"dlx-seen.json"),H=(e,t)=>`${e}@${t}`,me=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return Array.isArray(t.alertKeys)&&t.alertKeys.every(s=>typeof s=="string")&&typeof t.seenAt=="number"},P=()=>{try{if(se(k)){const e=re(k);if(e&&typeof e=="object"&&e.packages&&typeof e.packages=="object"&&e.version===1){const t={};for(const[s,r]of Object.entries(e.packages))me(r)&&(t[s]=r);return{packages:t,version:1}}}}catch{}return{packages:{},version:1}},he=e=>{try{X(B());const t=`${k}.${String(process.pid)}.tmp`;J(t,JSON.stringify(e)),q(t,k)}catch{}},ge=(e,t,s)=>e.packages[H(t,s)],ye=(e,t)=>{if(!e)return!0;const s=new Set(Array.isArray(e.alertKeys)?e.alertKeys:[]);return t.some(r=>!s.has(r))},R=(e,t,s,r)=>{const o=P();o.packages[H(e,t)]={alertKeys:[...s].sort(),seenAt:r},he(o)},ve=/[\u0000-\u0008\u000B-\u001F\u007F]/g,K=e=>G(e).replaceAll(" "," ").replaceAll(ve,""),x=["CHANGELOG.md","CHANGELOG","changelog.md","CHANGES.md","HISTORY.md"],be=4e3,C=async(e,t,s)=>{if(t?.aborted)return;const r=new AbortController,o=setTimeout(()=>{r.abort()},be),a=()=>{r.abort()};t?.addEventListener("abort",a,{once:!0});try{const n=await fetch(e,{headers:s,signal:r.signal});return n.ok?await n.text():void 0}catch{return}finally{clearTimeout(o),t?.removeEventListener("abort",a)}},$e=e=>{const t=typeof e=="string"?e:e?.url;if(!t)return;const s=/github\.com[/:]([^/]+)\/([^/#]+?)(?:\.git)?(?:[/#]|$)/i.exec(t)??/^github:([^/]+)\/([^/#]+)/i.exec(t);return s?{directory:typeof e=="object"?e?.directory:void 0,owner:s[1],repo:s[2].replace(/\.git$/,"")}:void 0},O=(e,t)=>{const s=e.split(/\r?\n/),r=/^(#{1,4})\s+(.*)$/,o=t.replaceAll(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`),a=new RegExp(String.raw`(?<![\w.])${o}(?![\w.])`);let n=-1,u=0;for(const[c,l]of s.entries()){const f=r.exec(l);if(f&&a.test(f[2])){n=c,u=f[1].length;break}}if(n===-1)return;const i=[];for(let c=n+1;c<s.length;c+=1){const l=r.exec(s[c]);if(l&&l[1].length<=u)break;i.push(s[c])}return i},I=(e,t=4)=>e.map(r=>r.trim()).filter(r=>r.length>0).map(r=>K(r.replace(/^#{1,6}\s+/,"").replace(/^[*-]\s+/,"- ")).trim()).filter(r=>r.length>0&&!/^\[.*\]:/.test(r)).slice(0,t),L=(e,t)=>{if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const r=Math.floor((t-s)/(1440*60*1e3));if(r<=0)return"today";if(r===1)return"1d ago";if(r<30)return`${String(r)}d ago`;const o=Math.floor(r/30);return o<12?`${String(o)}mo ago`:`${String(Math.floor(o/12))}y ago`},N=(e,t,s)=>{const r=e.time??{},o=L(r[t],s),a=[o?`${e.name}@${t} — published ${o}`:`${e.name}@${t}`],n=Date.parse(r[t]??""),i=Object.entries(r).filter(([c])=>c!=="created"&&c!=="modified"&&c!==t).sort((c,l)=>Date.parse(l[1])-Date.parse(c[1])).filter(([,c])=>Date.parse(c)<n).slice(0,3);for(const[c,l]of i)a.push(`- ${c} (${L(l,s)})`);return{lines:a,source:"npm-diff",version:t}},Se=async e=>{const{name:t,now:s,offline:r,packument:o,signal:a,version:n}=e;if(r)return o?N(o,n,s):void 0;for(const c of x){const l=`https://cdn.jsdelivr.net/npm/${t}@${n}/${c}`,f=await C(l,a);if(f){const y=O(f,n),p=I(y??f.split(/\r?\n/));if(p.length>0)return{lines:p,source:"package-file",url:l,version:n}}}const u=o?.versions[n],i=$e(u?.repository);if(i){const c=i.directory?`${i.directory.replaceAll(/^\/+|\/+$/g,"")}/`:"";for(const l of["HEAD","main","master"])for(const f of x){const y=`https://raw.githubusercontent.com/${i.owner}/${i.repo}/${l}/${c}${f}`,p=await C(y,a);if(p){const m=O(p,n),h=I(m??p.split(/\r?\n/));if(h.length>0){const d=`https://github.com/${i.owner}/${i.repo}/blob/${l}/${c}${f}`;return{lines:h,source:"repo-file",url:d,version:n}}}}}if(o)return N(o,n,s)},we={dynamicRequire:"dynamic require",envVars:"env access",filesystemAccess:"filesystem",networkAccess:"network",shellAccess:"shell",telemetry:"telemetry",unsafe:"eval/unsafe",usesEval:"eval/unsafe"},ke=["preinstall","install","postinstall"],Te=(e,t)=>({fileCount:e?.dist?.fileCount,tarballBytes:t?.size,unpackedBytes:e?.dist?.unpackedSize}),Ee=(e,t)=>{const s=ke.filter(n=>!!e?.scripts?.[n]),r=e?.bin,o=typeof r=="string"?["(default)"]:Object.keys(r??{}).map(n=>K(n)),a=[...new Set(t.map(n=>we[n.type]).filter(n=>n!==void 0))];return{bins:o,capabilities:a,lifecycleScripts:s}},_e=(e,t,s)=>{const r=e.get(`${t}@${s}`);if(r)return r;for(const o of e.values())if(o.name===t&&o.version===s)return o},Ae=async e=>{const{name:t,now:s,offline:r,signal:o,socketToken:a,spec:n,workspaceRoot:u}=e;let i;try{i=await oe(t,{offline:r,signal:o,workspaceRoot:u})}catch{i=void 0}const c=i?ne(i,n):void 0;if(!c)return;const l=i?.versions[c],f=async()=>{if(!(r||!a))try{const g=await Z([{name:t,version:c}],{apiToken:a,minimumScore:ee});return _e(g,t,c)}catch{return}},y=Se({name:t,now:s,offline:r,packument:i,signal:o,version:c}).catch(()=>{}),[p,m]=await Promise.all([f(),y]),h=p?.alerts??[],d=[...new Set(h.filter(g=>g.severity==="critical"||g.severity==="high").map(g=>g.key))].sort(),b=p?Math.round((p.score.overall??Q(p.score))*100):void 0;return{changelog:m,name:t,permissions:Ee(l,h),security:{alerts:h,available:!!p,highSeverityKeys:d,score:b},size:Te(l,p),version:c}},w=e=>te(G(e)),Re={critical:E,high:E,low:v,medium:S},j=e=>{if(!(e===void 0||e<0))return ae(e,{decimals:1,space:!0})},xe=e=>{const{fileCount:t,tarballBytes:s,unpackedBytes:r}=e.size,o=j(r),a=j(s);if(o&&a){const n=t===void 0?"":`, ${String(t)} files`;return`${o} unpacked (${a} tarball${n})`}if(o)return`${o} unpacked`;if(a)return`${a} tarball`},Ce=e=>{const{alerts:t,available:s,score:r}=e.security;if(!s)return v("unavailable — set VIS_SOCKET_TOKEN for a Socket.dev score");const o=r===void 0?v:r>=70?A:r>=40?S:E,a=r===void 0?"n/a":`${String(r)}/100`,n=new Map;for(const l of t)n.set(l.severity,(n.get(l.severity)??0)+1);const u=[],i=["critical","high","medium","low"];for(const l of i){const f=n.get(l);f&&u.push(Re[l](`${String(f)} ${l}`))}const c=u.length>0?` ${S("!")} ${u.join(", ")}`:` ${A("no alerts")}`;return`${o(a)} ${v("(Socket.dev)")}${c}`},Oe=e=>{const{bins:t,capabilities:s,lifecycleScripts:r}=e.permissions,o=[];for(const a of r)o.push(S(`${a} script`));for(const a of s)o.push(S(a));return t.length>0&&o.push(v(`bins: ${t.join(", ")}`)),o.length>0?o.join(v(" · ")):void 0},Ie=e=>{const t=[],s=xe(e);s&&t.push({label:"size",values:[s]}),t.push({label:"score",values:[Ce(e)]});const r=Oe(e);if(r&&t.push({label:"perms",values:[r]}),e.changelog){const o=e.changelog.source==="npm-diff"?"registry":e.changelog.source==="repo-file"?"repo CHANGELOG":"CHANGELOG";t.push({label:"latest",values:[...e.changelog.lines,v(`source: ${o}`)]})}return t},D=6,Le=e=>{const t=Ie(e),s=` first run: ${e.name}@${e.version} `,r=[];for(const i of t)i.values.forEach((c,l)=>{const f=l===0?ce(i.label.padEnd(D)):" ".repeat(D);r.push(`${f} ${c}`)});const o=Math.max(w(s),...r.map(i=>w(i))),a=i=>`${i}${" ".repeat(Math.max(0,o-w(i)))}`,n=`┌─${ie(s)}${"─".repeat(Math.max(0,o-w(s)))}─┐`,u=`└─${"─".repeat(o)}─┘`;return[n,...r.map(i=>`│ ${a(i)} │`),u]},Ne=e=>{if(e.startsWith("@")){const s=e.indexOf("@",1);return s===-1?{name:e}:{name:e.slice(0,s),spec:e.slice(s+1)}}const t=e.indexOf("@");return t<=0?{name:e}:{name:e.slice(0,t),spec:e.slice(t+1)}},je=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),De=6e3,Me=e=>{process.stdout.write(e)},Be=async e=>{const{forceInfo:t=!1,noInfo:s=!1,offline:r=!1,pkg:o,socketToken:a,workspaceRoot:n,yes:u=!1}=e;if(s||!je(o))return{proceed:!0};const i=e.now??Date.now(),c=u||!de({isCi:e.isCi,isTty:e.isTty}),l=e.output??Me;if(c&&!t)return{proceed:!0};const{name:f,spec:y}=Ne(o),p=new AbortController;let m;const h=new Promise(T=>{m=setTimeout(()=>{p.abort(),T(void 0)},De)}),d=await Promise.race([Ae({name:f,now:i,offline:r,signal:p.signal,socketToken:a,spec:y,workspaceRoot:n}).catch(()=>{}),h]);if(m&&clearTimeout(m),!d)return{proceed:!0};const b=ge(P(),d.name,d.version);if(!t&&!ye(b,d.security.highSeverityKeys))return{proceed:!0};for(const T of Le(d))l(`${T}
1
+ import{createRequire as F}from"node:module";import{i as W}from"../packem_shared/index-BjdW45xX.js";import{p as Y}from"../packem_shared/prompt-DMzaQEVa.js";import{e as U}from"../packem_shared/index-0dnGN3GP.js";import{n as B,h as X,U as J,o as Q,p as Z,e as ee,q as te,m as _}from"../packem_shared/env-CBECVaqy.js";import{y as se}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as re}from"../packem_shared/package-version-Bh9fCd7j.js";import{g as oe,r as ne}from"../packem_shared/packument-B4GE-Kt_.js";import{q as ce,j as ie,F as v,b as S,X as E,J as A}from"../packem_shared/index.server-Ca_EEVfw.js";import{z as ae}from"../packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js";import{a as le,o as fe}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{r as ue,a as pe}from"../packem_shared/command-runtime-DG49t2MT.js";let z;const V=e=>(z??=F(import.meta.url))(e),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(e)}return V(e)},{renameSync:q}=M("node:fs"),{stripVTControlCharacters:G}=M("node:util"),de=(e={})=>{const t=e.isCi??W;return(e.isTty??!!(process.stdin.isTTY&&process.stdout.isTTY))&&!t},k=U(B(),"dlx-seen.json"),H=(e,t)=>`${e}@${t}`,me=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return Array.isArray(t.alertKeys)&&t.alertKeys.every(s=>typeof s=="string")&&typeof t.seenAt=="number"},P=()=>{try{if(se(k)){const e=re(k);if(e&&typeof e=="object"&&e.packages&&typeof e.packages=="object"&&e.version===1){const t={};for(const[s,r]of Object.entries(e.packages))me(r)&&(t[s]=r);return{packages:t,version:1}}}}catch{}return{packages:{},version:1}},he=e=>{try{X(B());const t=`${k}.${String(process.pid)}.tmp`;J(t,JSON.stringify(e)),q(t,k)}catch{}},ge=(e,t,s)=>e.packages[H(t,s)],ye=(e,t)=>{if(!e)return!0;const s=new Set(Array.isArray(e.alertKeys)?e.alertKeys:[]);return t.some(r=>!s.has(r))},R=(e,t,s,r)=>{const o=P();o.packages[H(e,t)]={alertKeys:[...s].sort(),seenAt:r},he(o)},ve=/[\u0000-\u0008\u000B-\u001F\u007F]/g,K=e=>G(e).replaceAll(" "," ").replaceAll(ve,""),x=["CHANGELOG.md","CHANGELOG","changelog.md","CHANGES.md","HISTORY.md"],be=4e3,C=async(e,t,s)=>{if(t?.aborted)return;const r=new AbortController,o=setTimeout(()=>{r.abort()},be),a=()=>{r.abort()};t?.addEventListener("abort",a,{once:!0});try{const n=await fetch(e,{headers:s,signal:r.signal});return n.ok?await n.text():void 0}catch{return}finally{clearTimeout(o),t?.removeEventListener("abort",a)}},$e=e=>{const t=typeof e=="string"?e:e?.url;if(!t)return;const s=/github\.com[/:]([^/]+)\/([^/#]+?)(?:\.git)?(?:[/#]|$)/i.exec(t)??/^github:([^/]+)\/([^/#]+)/i.exec(t);return s?{directory:typeof e=="object"?e?.directory:void 0,owner:s[1],repo:s[2].replace(/\.git$/,"")}:void 0},O=(e,t)=>{const s=e.split(/\r?\n/),r=/^(#{1,4})\s+(.*)$/,o=t.replaceAll(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`),a=new RegExp(String.raw`(?<![\w.])${o}(?![\w.])`);let n=-1,u=0;for(const[c,l]of s.entries()){const f=r.exec(l);if(f&&a.test(f[2])){n=c,u=f[1].length;break}}if(n===-1)return;const i=[];for(let c=n+1;c<s.length;c+=1){const l=r.exec(s[c]);if(l&&l[1].length<=u)break;i.push(s[c])}return i},I=(e,t=4)=>e.map(r=>r.trim()).filter(r=>r.length>0).map(r=>K(r.replace(/^#{1,6}\s+/,"").replace(/^[*-]\s+/,"- ")).trim()).filter(r=>r.length>0&&!/^\[.*\]:/.test(r)).slice(0,t),L=(e,t)=>{if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const r=Math.floor((t-s)/(1440*60*1e3));if(r<=0)return"today";if(r===1)return"1d ago";if(r<30)return`${String(r)}d ago`;const o=Math.floor(r/30);return o<12?`${String(o)}mo ago`:`${String(Math.floor(o/12))}y ago`},N=(e,t,s)=>{const r=e.time??{},o=L(r[t],s),a=[o?`${e.name}@${t} — published ${o}`:`${e.name}@${t}`],n=Date.parse(r[t]??""),i=Object.entries(r).filter(([c])=>c!=="created"&&c!=="modified"&&c!==t).sort((c,l)=>Date.parse(l[1])-Date.parse(c[1])).filter(([,c])=>Date.parse(c)<n).slice(0,3);for(const[c,l]of i)a.push(`- ${c} (${L(l,s)})`);return{lines:a,source:"npm-diff",version:t}},Se=async e=>{const{name:t,now:s,offline:r,packument:o,signal:a,version:n}=e;if(r)return o?N(o,n,s):void 0;for(const c of x){const l=`https://cdn.jsdelivr.net/npm/${t}@${n}/${c}`,f=await C(l,a);if(f){const y=O(f,n),p=I(y??f.split(/\r?\n/));if(p.length>0)return{lines:p,source:"package-file",url:l,version:n}}}const u=o?.versions[n],i=$e(u?.repository);if(i){const c=i.directory?`${i.directory.replaceAll(/^\/+|\/+$/g,"")}/`:"";for(const l of["HEAD","main","master"])for(const f of x){const y=`https://raw.githubusercontent.com/${i.owner}/${i.repo}/${l}/${c}${f}`,p=await C(y,a);if(p){const m=O(p,n),h=I(m??p.split(/\r?\n/));if(h.length>0){const d=`https://github.com/${i.owner}/${i.repo}/blob/${l}/${c}${f}`;return{lines:h,source:"repo-file",url:d,version:n}}}}}if(o)return N(o,n,s)},we={dynamicRequire:"dynamic require",envVars:"env access",filesystemAccess:"filesystem",networkAccess:"network",shellAccess:"shell",telemetry:"telemetry",unsafe:"eval/unsafe",usesEval:"eval/unsafe"},ke=["preinstall","install","postinstall"],Te=(e,t)=>({fileCount:e?.dist?.fileCount,tarballBytes:t?.size,unpackedBytes:e?.dist?.unpackedSize}),Ee=(e,t)=>{const s=ke.filter(n=>!!e?.scripts?.[n]),r=e?.bin,o=typeof r=="string"?["(default)"]:Object.keys(r??{}).map(n=>K(n)),a=[...new Set(t.map(n=>we[n.type]).filter(n=>n!==void 0))];return{bins:o,capabilities:a,lifecycleScripts:s}},_e=(e,t,s)=>{const r=e.get(`${t}@${s}`);if(r)return r;for(const o of e.values())if(o.name===t&&o.version===s)return o},Ae=async e=>{const{name:t,now:s,offline:r,signal:o,socketToken:a,spec:n,workspaceRoot:u}=e;let i;try{i=await oe(t,{offline:r,signal:o,workspaceRoot:u})}catch{i=void 0}const c=i?ne(i,n):void 0;if(!c)return;const l=i?.versions[c],f=async()=>{if(!(r||!a))try{const g=await Z([{name:t,version:c}],{apiToken:a,minimumScore:ee});return _e(g,t,c)}catch{return}},y=Se({name:t,now:s,offline:r,packument:i,signal:o,version:c}).catch(()=>{}),[p,m]=await Promise.all([f(),y]),h=p?.alerts??[],d=[...new Set(h.filter(g=>g.severity==="critical"||g.severity==="high").map(g=>g.key))].sort(),b=p?Math.round((p.score.overall??Q(p.score))*100):void 0;return{changelog:m,name:t,permissions:Ee(l,h),security:{alerts:h,available:!!p,highSeverityKeys:d,score:b},size:Te(l,p),version:c}},w=e=>te(G(e)),Re={critical:E,high:E,low:v,medium:S},j=e=>{if(!(e===void 0||e<0))return ae(e,{decimals:1,space:!0})},xe=e=>{const{fileCount:t,tarballBytes:s,unpackedBytes:r}=e.size,o=j(r),a=j(s);if(o&&a){const n=t===void 0?"":`, ${String(t)} files`;return`${o} unpacked (${a} tarball${n})`}if(o)return`${o} unpacked`;if(a)return`${a} tarball`},Ce=e=>{const{alerts:t,available:s,score:r}=e.security;if(!s)return v("unavailable — set VIS_SOCKET_TOKEN for a Socket.dev score");const o=r===void 0?v:r>=70?A:r>=40?S:E,a=r===void 0?"n/a":`${String(r)}/100`,n=new Map;for(const l of t)n.set(l.severity,(n.get(l.severity)??0)+1);const u=[],i=["critical","high","medium","low"];for(const l of i){const f=n.get(l);f&&u.push(Re[l](`${String(f)} ${l}`))}const c=u.length>0?` ${S("!")} ${u.join(", ")}`:` ${A("no alerts")}`;return`${o(a)} ${v("(Socket.dev)")}${c}`},Oe=e=>{const{bins:t,capabilities:s,lifecycleScripts:r}=e.permissions,o=[];for(const a of r)o.push(S(`${a} script`));for(const a of s)o.push(S(a));return t.length>0&&o.push(v(`bins: ${t.join(", ")}`)),o.length>0?o.join(v(" · ")):void 0},Ie=e=>{const t=[],s=xe(e);s&&t.push({label:"size",values:[s]}),t.push({label:"score",values:[Ce(e)]});const r=Oe(e);if(r&&t.push({label:"perms",values:[r]}),e.changelog){const o=e.changelog.source==="npm-diff"?"registry":e.changelog.source==="repo-file"?"repo CHANGELOG":"CHANGELOG";t.push({label:"latest",values:[...e.changelog.lines,v(`source: ${o}`)]})}return t},D=6,Le=e=>{const t=Ie(e),s=` first run: ${e.name}@${e.version} `,r=[];for(const i of t)i.values.forEach((c,l)=>{const f=l===0?ce(i.label.padEnd(D)):" ".repeat(D);r.push(`${f} ${c}`)});const o=Math.max(w(s),...r.map(i=>w(i))),a=i=>`${i}${" ".repeat(Math.max(0,o-w(i)))}`,n=`┌─${ie(s)}${"─".repeat(Math.max(0,o-w(s)))}─┐`,u=`└─${"─".repeat(o)}─┘`;return[n,...r.map(i=>`│ ${a(i)} │`),u]},Ne=e=>{if(e.startsWith("@")){const s=e.indexOf("@",1);return s===-1?{name:e}:{name:e.slice(0,s),spec:e.slice(s+1)}}const t=e.indexOf("@");return t<=0?{name:e}:{name:e.slice(0,t),spec:e.slice(t+1)}},je=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),De=6e3,Me=e=>{process.stdout.write(e)},Be=async e=>{const{forceInfo:t=!1,noInfo:s=!1,offline:r=!1,pkg:o,socketToken:a,workspaceRoot:n,yes:u=!1}=e;if(s||!je(o))return{proceed:!0};const i=e.now??Date.now(),c=u||!de({isCi:e.isCi,isTty:e.isTty}),l=e.output??Me;if(c&&!t)return{proceed:!0};const{name:f,spec:y}=Ne(o),p=new AbortController;let m;const h=new Promise(T=>{m=setTimeout(()=>{p.abort(),T(void 0)},De)}),d=await Promise.race([Ae({name:f,now:i,offline:r,signal:p.signal,socketToken:a,spec:y,workspaceRoot:n}).catch(()=>{}),h]);if(m&&clearTimeout(m),!d)return{proceed:!0};const b=ge(P(),d.name,d.version);if(!t&&!ye(b,d.security.highSeverityKeys))return{proceed:!0};for(const T of Le(d))l(`${T}
2
2
  `);if(c)return R(d.name,d.version,d.security.highSeverityKeys,i),{proceed:!0};const g=await Y("? Ok to proceed? (y/N) ",e.readline);return g&&R(d.name,d.version,d.security.highSeverityKeys,i),{proceed:g}},Je=async({argument:e,logger:t,options:s,process:r,visConfig:o,workspaceRoot:a})=>{const n=e;if(!n||n.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[u,...i]=n,c=a??r.cwd,l=s.package?Array.isArray(s.package)?s.package:[s.package]:[],f=s.shellMode?l:[u,...l];for(const h of f){const d=!s.info||_(r.env.VIS_DLX_NO_INFO),b=!d&&s.info;if(!(await Be({forceInfo:b,noInfo:d,offline:s.offline||!1,pkg:h,socketToken:o?.security?.socket?.apiToken??r.env.VIS_SOCKET_TOKEN,workspaceRoot:c,yes:s.yes||_(r.env.VIS_DLX_YES)})).proceed){t.info("Aborted."),process.exitCode=1;return}}const y=ue({options:s,visConfig:o},c),p=le(c,{backend:pe(y),configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),m=fe(p,{additionalPackages:l,args:i,package:u,shellMode:s.shellMode||!1,silent:s.silent||!1},c,t,{offline:s.offline||!1});m!==0&&(process.exitCode=m)};export{Je as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as ee}from"node:module";import{e as A,a as re}from"../packem_shared/index-0dnGN3GP.js";import{f as ae,h as M}from"../packem_shared/ai-cache-B9U5m9O9.js";import{p as c,W as V,X as k,Y as ne,T as P,Z as L,_ as oe,h as ie}from"./cli-main.js";import{B as ce,C as de,D as N,E as z}from"../packem_shared/registry-Dmy6zBD8.js";import{r as he,d as x,a as U,t as I}from"../packem_shared/env-D0huQDyA.js";import{z as b}from"../packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js";import{Cache as E,readLastRunSummary as q,getLastRunSummaryPath as T,parseCacheSize as me,digestFile as X,describeCacheMissReason as pe}from"@visulima/task-runner";import{y as R}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{r as G,f as F,a as ye,d as Se}from"../packem_shared/run-summary-utils-Co-yODTZ.js";let te;const se=e=>(te??=ee(import.meta.url))(e),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[s,t]=g.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return g.getBuiltinModule(e)}return se(e)},{realpath:_,rm:W,mkdtemp:fe,readdir:ue,stat:Y}=j("node:fs/promises"),{createInterface:le}=j("node:readline"),{tmpdir:$e}=j("node:os"),we=e=>new Promise(s=>{const t=le({input:process.stdin,output:process.stderr});t.question(`${e} (y/N) `,r=>{t.close();const n=r.trim().toLowerCase();s(n==="y"||n==="yes")})}),ve=()=>{try{const e=ae();e>0&&c.info(`Cleared ${String(e)} cached AI response${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear AI response cache: ${e instanceof Error?e.message:String(e)}`)}},ke=()=>{try{const e=he();e>0&&c.info(`Cleared ${String(e)} cached Socket.dev report${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear Socket.dev cache: ${e instanceof Error?e.message:String(e)}`)}},Ce=()=>{try{const e=ce();e>0&&c.info(`Cleared ${String(e)} cached deps.dev record${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear deps.dev cache: ${e instanceof Error?e.message:String(e)}`)}},ge=()=>{try{const e=de();e>0&&c.info(`Cleared ${String(e)} cached Snyk record${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear Snyk cache: ${e instanceof Error?e.message:String(e)}`)}},De=async(e,s,t)=>{if(!R(e)){c.info(`No cache directory to clean at ${e}`);return}if(t.dryRun){const a=(await Promise.all(V(e,!0).map(async i=>k(i)))).flat(),o=a.reduce((i,d)=>i+d.sizeBytes,0);c.info(`Would remove ${String(a.length)} cache entr${a.length===1?"y":"ies"} (${b(o,{decimals:1,space:!1})}) from ${e}`);return}const r=ne(e,s);try{const n=await _(e),a=await _(s);if(n===a){c.error("Refusing to delete the workspace root. The cache directory resolved to the same path as the workspace."),process.exitCode=1;return}}catch{}if(!r&&!t.force){if(c.warn(`Cache directory is outside the workspace root: ${e}`),c.warn("This will recursively delete the entire directory, including anything stored there by other tools."),!process.stdin.isTTY){c.error("Refusing to clean an out-of-workspace cache without --force (stdin is not a TTY)."),process.exitCode=1;return}if(!await we(" Continue?")){c.info("Aborted.");return}}r?await new E({cacheDirectory:e,workspaceRoot:s}).clear():await W(e,{force:!0,recursive:!0}),c.success(`Cleared cache: ${e}`)},Z=e=>e==="task"||e==="ai"||e==="socket"||e==="deps-dev"||e==="snyk"||e==="all"?e:(e&&e.length>0&&c.warn(`Unknown --type value '${e}'; falling back to 'all'.`),"all"),m=(e,s)=>e==="all"||e===s,xe=e=>e==="worktree"||e==="shared"||e==="all"?e:(e&&e.length>0&&c.warn(`Unknown --scope value '${e}'; falling back to 'shared'.`),"shared"),w=(e,s,t)=>{const r=e??process.cwd(),n=t??{},a=n.taskRunner??{},o=xe(s.scope),i=s.cacheDir,d=P(r,i,a.cacheDirectory,!1),f=P(r,i,a.cacheDirectory,n.sharedWorktreeCache),h=L(d,r,n.branchScopedCache),u=L(f,r,n.branchScopedCache);let l;switch(o){case"all":{l=u===h?[{base:f,scoped:u}]:[{base:f,scoped:u},{base:d,scoped:h}];break}case"worktree":{l=[{base:d,scoped:h}];break}default:l=[{base:f,scoped:u}]}const S=n.branchScopedCache===!0;return{directoriesFor:O=>O==="read"?[...new Set(l.flatMap(p=>p.scoped!==p.base&&oe(p.base)?[p.scoped,p.base]:[p.scoped]))]:O==="wipe"?[...new Set(l.map(p=>p.base))]:[...new Set(l.flatMap(p=>V(p.base,S)))],scope:o,sharedWorktreeCache:n.sharedWorktreeCache,workspaceRoot:r}},H=16,K=e=>e.length>H?`${e.slice(0,H)}…`:e,v=(e,s,t)=>{const r=Object.entries(s??{});if(r.length!==0){t.info(` ${e}:`),r.sort(([n],[a])=>n.localeCompare(a));for(const[n,a]of r)t.info(` ${n.padEnd(40)} ${K(a)}`)}},be=async(e,s,t)=>{if(e!==void 0)for(const r of s){const n=await new E({cacheDirectory:r,workspaceRoot:t}).get(e);if(n?.fingerprint)return n.fingerprint}},Ee=(e,s)=>{v("tracked files",e.fileHashes,s),v("tracked env",e.envHashes,s),v("missing files",Object.fromEntries(e.missingFiles.map(t=>[t,"absent"])),s)},Re=async(e,s,t)=>{const{format:r,runId:n,workspaceRoot:a}=s,o=n===void 0?await q(a,{dataDirectory:x(a)}):await G(a,n);if(!o){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:n??null,taskId:e},void 0,2)}
1
+ import{createRequire as ee}from"node:module";import{e as A,a as re}from"../packem_shared/index-0dnGN3GP.js";import{f as ae,h as M}from"../packem_shared/ai-cache-CIiLVd6H.js";import{p as c,W as V,X as k,Y as ne,T as P,Z as L,_ as oe,h as ie}from"./cli-main.js";import{B as ce,C as de,D as N,E as z}from"../packem_shared/registry-C_cLtZJm.js";import{r as he,d as x,a as U,t as I}from"../packem_shared/env-CBECVaqy.js";import{z as b}from"../packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js";import{Cache as E,readLastRunSummary as q,getLastRunSummaryPath as T,parseCacheSize as me,digestFile as X,describeCacheMissReason as pe}from"@visulima/task-runner";import{y as R}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{r as G,f as F,a as ye,d as Se}from"../packem_shared/run-summary-utils-CdBH8qU4.js";let te;const se=e=>(te??=ee(import.meta.url))(e),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[s,t]=g.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return g.getBuiltinModule(e)}return se(e)},{realpath:_,rm:W,mkdtemp:fe,readdir:ue,stat:Y}=j("node:fs/promises"),{createInterface:le}=j("node:readline"),{tmpdir:$e}=j("node:os"),we=e=>new Promise(s=>{const t=le({input:process.stdin,output:process.stderr});t.question(`${e} (y/N) `,r=>{t.close();const n=r.trim().toLowerCase();s(n==="y"||n==="yes")})}),ve=()=>{try{const e=ae();e>0&&c.info(`Cleared ${String(e)} cached AI response${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear AI response cache: ${e instanceof Error?e.message:String(e)}`)}},ke=()=>{try{const e=he();e>0&&c.info(`Cleared ${String(e)} cached Socket.dev report${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear Socket.dev cache: ${e instanceof Error?e.message:String(e)}`)}},Ce=()=>{try{const e=ce();e>0&&c.info(`Cleared ${String(e)} cached deps.dev record${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear deps.dev cache: ${e instanceof Error?e.message:String(e)}`)}},ge=()=>{try{const e=de();e>0&&c.info(`Cleared ${String(e)} cached Snyk record${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear Snyk cache: ${e instanceof Error?e.message:String(e)}`)}},De=async(e,s,t)=>{if(!R(e)){c.info(`No cache directory to clean at ${e}`);return}if(t.dryRun){const a=(await Promise.all(V(e,!0).map(async i=>k(i)))).flat(),o=a.reduce((i,d)=>i+d.sizeBytes,0);c.info(`Would remove ${String(a.length)} cache entr${a.length===1?"y":"ies"} (${b(o,{decimals:1,space:!1})}) from ${e}`);return}const r=ne(e,s);try{const n=await _(e),a=await _(s);if(n===a){c.error("Refusing to delete the workspace root. The cache directory resolved to the same path as the workspace."),process.exitCode=1;return}}catch{}if(!r&&!t.force){if(c.warn(`Cache directory is outside the workspace root: ${e}`),c.warn("This will recursively delete the entire directory, including anything stored there by other tools."),!process.stdin.isTTY){c.error("Refusing to clean an out-of-workspace cache without --force (stdin is not a TTY)."),process.exitCode=1;return}if(!await we(" Continue?")){c.info("Aborted.");return}}r?await new E({cacheDirectory:e,workspaceRoot:s}).clear():await W(e,{force:!0,recursive:!0}),c.success(`Cleared cache: ${e}`)},Z=e=>e==="task"||e==="ai"||e==="socket"||e==="deps-dev"||e==="snyk"||e==="all"?e:(e&&e.length>0&&c.warn(`Unknown --type value '${e}'; falling back to 'all'.`),"all"),m=(e,s)=>e==="all"||e===s,xe=e=>e==="worktree"||e==="shared"||e==="all"?e:(e&&e.length>0&&c.warn(`Unknown --scope value '${e}'; falling back to 'shared'.`),"shared"),w=(e,s,t)=>{const r=e??process.cwd(),n=t??{},a=n.taskRunner??{},o=xe(s.scope),i=s.cacheDir,d=P(r,i,a.cacheDirectory,!1),f=P(r,i,a.cacheDirectory,n.sharedWorktreeCache),h=L(d,r,n.branchScopedCache),u=L(f,r,n.branchScopedCache);let l;switch(o){case"all":{l=u===h?[{base:f,scoped:u}]:[{base:f,scoped:u},{base:d,scoped:h}];break}case"worktree":{l=[{base:d,scoped:h}];break}default:l=[{base:f,scoped:u}]}const S=n.branchScopedCache===!0;return{directoriesFor:O=>O==="read"?[...new Set(l.flatMap(p=>p.scoped!==p.base&&oe(p.base)?[p.scoped,p.base]:[p.scoped]))]:O==="wipe"?[...new Set(l.map(p=>p.base))]:[...new Set(l.flatMap(p=>V(p.base,S)))],scope:o,sharedWorktreeCache:n.sharedWorktreeCache,workspaceRoot:r}},H=16,K=e=>e.length>H?`${e.slice(0,H)}…`:e,v=(e,s,t)=>{const r=Object.entries(s??{});if(r.length!==0){t.info(` ${e}:`),r.sort(([n],[a])=>n.localeCompare(a));for(const[n,a]of r)t.info(` ${n.padEnd(40)} ${K(a)}`)}},be=async(e,s,t)=>{if(e!==void 0)for(const r of s){const n=await new E({cacheDirectory:r,workspaceRoot:t}).get(e);if(n?.fingerprint)return n.fingerprint}},Ee=(e,s)=>{v("tracked files",e.fileHashes,s),v("tracked env",e.envHashes,s),v("missing files",Object.fromEntries(e.missingFiles.map(t=>[t,"absent"])),s)},Re=async(e,s,t)=>{const{format:r,runId:n,workspaceRoot:a}=s,o=n===void 0?await q(a,{dataDirectory:x(a)}):await G(a,n);if(!o){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:n??null,taskId:e},void 0,2)}
2
2
  `),process.exitCode=1;return}n===void 0?c.error(`No previous run summary found. Run a task first to populate \`${T(a,{dataDirectory:x(a)})}\`.`):c.error(`Run summary "${n}" not found in ${U(a)}/.`),process.exitCode=1;return}const i=F(o,e);if(!i){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:o.id,taskId:e},void 0,2)}
3
3
  `),process.exitCode=1;return}c.error(`Task "${e}" was not part of run ${o.id}.`),process.exitCode=1;return}const d=i.hashDetails===void 0?await be(i.hash,s.cacheDirectories??[],a):void 0;if(r==="json"){process.stdout.write(`${JSON.stringify({cacheStatus:i.cacheStatus,hash:i.hash??null,hashDetails:i.hashDetails??null,hashSource:i.hashSource??null,runId:o.id,taskId:i.taskId,trackedFingerprint:d??null},void 0,2)}
4
4
  `);return}c.info(`Hash for ${e} (run ${o.id})`),t.info(""),t.info(` status: ${i.cacheStatus}`),t.info(` hash: ${i.hash??"(none)"}`),i.hashSource==="declared-fallback"&&t.info(" key: declared-fallback (no files were tracked; the entry is keyed on the declared inputs below)"),i.hashDetails?(t.info(""),t.info(` command: ${K(i.hashDetails.command)}`),v("nodes",i.hashDetails.nodes,t),v("runtime",i.hashDetails.runtime,t),v("implicitDeps",i.hashDetails.implicitDeps,t)):d?(t.info(""),Ee(d,t)):(t.info(""),c.info("No hash details recorded for this task."))},$=e=>{process.stdout.write(`${e}
@@ -1,4 +1,4 @@
1
- import{createRequire as Q}from"node:module";import{J as v,j as w,F as g,q as x,b,X as D}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as I,z as se,a as $}from"../packem_shared/index-0dnGN3GP.js";import G from"./index.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{V as oe,U as F,l as ne,$ as ae,a0 as ie,a1 as re,a2 as ce}from"./cli-main.js";import{h as pe,i as z,q as W,u as j,p as L,J as K}from"../packem_shared/registry-Dmy6zBD8.js";import{p as S}from"../packem_shared/package-version-CtgyD_B1.js";import{U as fe}from"../packem_shared/env-D0huQDyA.js";import{l as le}from"../packem_shared/missing-package-json-wH6OInGG.js";import{readCatalogs as ue}from"./catalog.js";let Z;const ee=e=>(Z??=Q(import.meta.url))(e),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,te=e=>{if(typeof V<"u"&&V.versions&&V.versions.node){const[a,s]=V.versions.node.split(".").map(Number);if(a>22||a===22&&s>=3||a===20&&s>=16)return V.getBuiltinModule(e)}return ee(e)},{readFileSync:Y,writeFileSync:H}=te("node:fs"),de=e=>/[*?[\]{}!]/.test(e),ge=e=>typeof e=="string"?e:e.reason,me=e=>typeof e=="string"?void 0:e.replacement,q=(e,a)=>e.some(s=>G(s,a)),U=(e,a)=>{if(typeof e=="string")return!0;const s=Array.isArray(e.packages)&&e.packages.length>0,t=Array.isArray(e.paths)&&e.paths.length>0;return!!(!s&&!t||s&&a.packageName!==void 0&&q(e.packages,a.packageName)||t&&q(e.paths,a.packageDir))},he=(e,a)=>{const s=a[e.depName];if(s!==void 0&&U(s,e))return{pattern:e.depName,rule:s};for(const[t,r]of Object.entries(a))if(de(t)&&G(t,e.depName)&&U(r,e))return{pattern:t,rule:r}},ke=(e,a)=>{if(Object.keys(a).length===0)return[];const s=[];for(const t of e){if(t.isInternal)continue;const r=he(t,a);r&&s.push({depName:t.depName,depType:t.depType,matchedPattern:r.pattern,packageDir:t.packageDir,packageJsonPath:t.packageJsonPath,packageName:t.packageName,reason:ge(r.rule),replacement:me(r.rule),specifier:t.specifier})}return s},ye=new Set(["dependencies","devDependencies","peerDependencies"]),Pe=e=>e.startsWith("catalog:"),$e=e=>e.startsWith("workspace:"),we=(e,a)=>{if(!e)return!1;for(const s of e.values())if(s.has(a))return!0;return!1},ve=(e,a={})=>{const s=a.min??3,t=new Set(a.ignoreDeps),r=e.filter(i=>i.isInternal||!ye.has(i.depType)||$e(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),n=new Map;for(const i of r){const c=n.get(i.depName);c?c.push(i):n.set(i.depName,[i])}const o=[];for(const[i,c]of n){if(we(a.catalogs,i)||c.some(h=>Pe(h.specifier)))continue;const p=new Map;for(const h of c){let d=p.get(h.specifier);d||(d=new Set,p.set(h.specifier,d)),d.add(h.packageJsonPath)}const m=[...p.entries()].sort((h,d)=>h[1].size!==d[1].size?d[1].size-h[1].size:h[0].localeCompare(d[0]))[0];!m||m[1].size<s||o.push({catalogName:"default",depName:i,instanceCount:m[1].size,specifier:m[0]})}return o.sort((i,c)=>i.depName.localeCompare(c.depName))},De=(e,a)=>{if(a.length===0)return;const s=I(e,"pnpm-workspace.yaml"),r=_(s)?Y(s,"utf8"):"",n=r.includes(`\r
1
+ import{createRequire as Q}from"node:module";import{J as v,j as w,F as g,q as x,b,X as D}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as I,z as se,a as $}from"../packem_shared/index-0dnGN3GP.js";import G from"./index.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{V as oe,U as F,l as ne,$ as ae,a0 as ie,a1 as re,a2 as ce}from"./cli-main.js";import{h as pe,i as z,q as W,u as j,p as L,J as K}from"../packem_shared/registry-C_cLtZJm.js";import{p as S}from"../packem_shared/package-version-Bh9fCd7j.js";import{U as fe}from"../packem_shared/env-CBECVaqy.js";import{l as le}from"../packem_shared/missing-package-json-BGS_pPSE.js";import{readCatalogs as ue}from"./catalog.js";let Z;const ee=e=>(Z??=Q(import.meta.url))(e),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,te=e=>{if(typeof V<"u"&&V.versions&&V.versions.node){const[a,s]=V.versions.node.split(".").map(Number);if(a>22||a===22&&s>=3||a===20&&s>=16)return V.getBuiltinModule(e)}return ee(e)},{readFileSync:Y,writeFileSync:H}=te("node:fs"),de=e=>/[*?[\]{}!]/.test(e),ge=e=>typeof e=="string"?e:e.reason,me=e=>typeof e=="string"?void 0:e.replacement,q=(e,a)=>e.some(s=>G(s,a)),U=(e,a)=>{if(typeof e=="string")return!0;const s=Array.isArray(e.packages)&&e.packages.length>0,t=Array.isArray(e.paths)&&e.paths.length>0;return!!(!s&&!t||s&&a.packageName!==void 0&&q(e.packages,a.packageName)||t&&q(e.paths,a.packageDir))},he=(e,a)=>{const s=a[e.depName];if(s!==void 0&&U(s,e))return{pattern:e.depName,rule:s};for(const[t,r]of Object.entries(a))if(de(t)&&G(t,e.depName)&&U(r,e))return{pattern:t,rule:r}},ke=(e,a)=>{if(Object.keys(a).length===0)return[];const s=[];for(const t of e){if(t.isInternal)continue;const r=he(t,a);r&&s.push({depName:t.depName,depType:t.depType,matchedPattern:r.pattern,packageDir:t.packageDir,packageJsonPath:t.packageJsonPath,packageName:t.packageName,reason:ge(r.rule),replacement:me(r.rule),specifier:t.specifier})}return s},ye=new Set(["dependencies","devDependencies","peerDependencies"]),Pe=e=>e.startsWith("catalog:"),$e=e=>e.startsWith("workspace:"),we=(e,a)=>{if(!e)return!1;for(const s of e.values())if(s.has(a))return!0;return!1},ve=(e,a={})=>{const s=a.min??3,t=new Set(a.ignoreDeps),r=e.filter(i=>i.isInternal||!ye.has(i.depType)||$e(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),n=new Map;for(const i of r){const c=n.get(i.depName);c?c.push(i):n.set(i.depName,[i])}const o=[];for(const[i,c]of n){if(we(a.catalogs,i)||c.some(h=>Pe(h.specifier)))continue;const p=new Map;for(const h of c){let d=p.get(h.specifier);d||(d=new Set,p.set(h.specifier,d)),d.add(h.packageJsonPath)}const m=[...p.entries()].sort((h,d)=>h[1].size!==d[1].size?d[1].size-h[1].size:h[0].localeCompare(d[0]))[0];!m||m[1].size<s||o.push({catalogName:"default",depName:i,instanceCount:m[1].size,specifier:m[0]})}return o.sort((i,c)=>i.depName.localeCompare(c.depName))},De=(e,a)=>{if(a.length===0)return;const s=I(e,"pnpm-workspace.yaml"),r=_(s)?Y(s,"utf8"):"",n=r.includes(`\r
2
2
  `)?`\r
3
3
  `:`
4
4
  `,o=a.filter(d=>d.catalogName==="default").sort((d,u)=>d.depName.localeCompare(u.depName));if(o.length===0)return;const i=r.length>0?r.split(n):[],c=i.findIndex(d=>/^catalog\s*:\s*$/.test(d));if(c===-1){const d=["catalog:"];for(const J of o)d.push(` ${J.depName}: "${J.specifier}"`);let u=0;for(;u<i.length&&(i[u]??"").trim().length===0;)u+=1;const k=[...i.slice(0,u),...d,"",...i.slice(u)].join(n);return H(s,k.endsWith(n)?k:`${k}${n}`),s}let p=i.length;const f=new Set;for(let d=c+1;d<i.length;d+=1){const u=i[d]??"",k=u.trimStart();if(u.length===0)continue;if(u.length-k.length===0&&k.length>0&&!k.startsWith("#")){p=d;break}const P=/^([\w./@-]+)\s*:/.exec(k);P?.[1]&&f.add(P[1])}const m=[];for(const d of o)f.has(d.depName)||m.push(` ${d.depName}: "${d.specifier}"`);if(m.length===0)return;const h=[...i.slice(0,p),...m,...i.slice(p)].join(n);return H(s,h.endsWith(n)?h:`${h}${n}`),s},be=(e,a)=>{if(a.length===0)return"";const s=I(e,"pnpm-workspace.yaml"),r=_(s)?Y(s,"utf8"):"",n=[...a].sort((f,m)=>f.depName.localeCompare(m.depName)),o=["--- pnpm-workspace.yaml","+++ pnpm-workspace.yaml"],i=r.includes(`\r
@@ -1 +1 @@
1
- import{r as m}from"../packem_shared/affected-shas-CycHU3nr.js";import{r as u}from"../packem_shared/toolchain-BnrrDIRc.js";const $=async({argument:h,logger:r,options:e,runtime:s,visConfig:f,workspaceRoot:n})=>{const o=h[0];if(!o)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");const l=o.split(",").map(a=>a.trim()).filter(Boolean);if(l.length===0)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=m({defaultBase:f?.defaultBase,workspaceRoot:n}),c=e.base??i.base,d=e.head??i.head;!e.base&&!e.head&&r.info(`▸ Resolved affected refs from ${i.provider} (${i.notes.join("; ")})`),e.skipToolchain||r.info("▸ Toolchain pre-flight"),await u(n,f?.toolchain,{error:a=>{r.error(a)},info:a=>{r.info(a)},warn:a=>{r.warn(a)}},!!e.skipToolchain),e.install?(r.info("▸ Installing dependencies"),await s.runCommand("install",{argv:["--ci","--frozen-lockfile"]})):r.info("▸ Skipping install (--no-install)");for(const a of l){r.info(`▸ Running affected ${a} (base=${c}, head=${d})`);const t=[a,`--base=${c}`,`--head=${d}`,`--upstream=${String(e.upstream??"none")}`,`--downstream=${String(e.downstream??"deep")}`];Number.isFinite(e.parallel)&&t.push(`--parallel=${String(e.parallel)}`),e.partition&&t.push(`--partition=${String(e.partition)}`),e.query&&t.push(`--query=${String(e.query)}`),e.ifPresent&&t.push("--if-present"),await s.runCommand("affected",{argv:t})}r.info("▸ CI pipeline complete")};export{$ as default};
1
+ import{r as m}from"../packem_shared/affected-shas-CycHU3nr.js";import{r as u}from"../packem_shared/toolchain-DvRok9gN.js";const $=async({argument:h,logger:r,options:e,runtime:s,visConfig:f,workspaceRoot:n})=>{const o=h[0];if(!o)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");const l=o.split(",").map(a=>a.trim()).filter(Boolean);if(l.length===0)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=m({defaultBase:f?.defaultBase,workspaceRoot:n}),c=e.base??i.base,d=e.head??i.head;!e.base&&!e.head&&r.info(`▸ Resolved affected refs from ${i.provider} (${i.notes.join("; ")})`),e.skipToolchain||r.info("▸ Toolchain pre-flight"),await u(n,f?.toolchain,{error:a=>{r.error(a)},info:a=>{r.info(a)},warn:a=>{r.warn(a)}},!!e.skipToolchain),e.install?(r.info("▸ Installing dependencies"),await s.runCommand("install",{argv:["--ci","--frozen-lockfile"]})):r.info("▸ Skipping install (--no-install)");for(const a of l){r.info(`▸ Running affected ${a} (base=${c}, head=${d})`);const t=[a,`--base=${c}`,`--head=${d}`,`--upstream=${String(e.upstream??"none")}`,`--downstream=${String(e.downstream??"deep")}`];Number.isFinite(e.parallel)&&t.push(`--parallel=${String(e.parallel)}`),e.partition&&t.push(`--partition=${String(e.partition)}`),e.query&&t.push(`--query=${String(e.query)}`),e.ifPresent&&t.push("--if-present"),await s.runCommand("affected",{argv:t})}r.info("▸ CI pipeline complete")};export{$ as default};
@@ -1,7 +1,7 @@
1
- import{createRequire as Ke}from"node:module";import{b as C,F as x,X as Xe,J as Ee,q as Ze}from"../packem_shared/index.server-Ca_EEVfw.js";import{m as Qe,v as E,U as I,a as M,e as V,z as et}from"../packem_shared/index-0dnGN3GP.js";import{wholeMatchFingerprint as tt,maskFinding as ee,fingerprint as H,legacyFingerprint as st,baselineKeys as ce,GIT_CONFIG_OVERRIDES as nt,DIFF_HARDENING_FLAGS as it,gitleaksIgnoreFingerprint as K,toSarifUri as rt,CONFIDENCE_LEVELS as le,DEFAULT_MAX_FILE_SIZE as O,MAX_ARCHIVE_DEPTH as ot,listRules as Te,listRequiredValidators as at,scan as ct,isPathExcluded as lt,scanStringDetailed as dt,scanGitHistoryDetailed as ut,scanDetailed as ht,scanGitStaged as pt,scanFilesDetailed as ft,inspectRuleset as mt}from"@visulima/secret-scanner";import{V as $}from"../packem_shared/vis-user-error-DNF243LB.js";import{a3 as gt,a4 as de,p as T}from"./cli-main.js";import{E as wt,A as vt}from"../packem_shared/getRandomSpinner-DX11qCB2-CoIsn7ZU.js";import{y as te}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as Rt}from"../packem_shared/package-version-CtgyD_B1.js";import{w as z}from"../packem_shared/github-workflow-command-Bn0MgB78.js";import{e as W,c as Dt}from"../packem_shared/junit-audit-CuJShWCH.js";let Ye;const Je=e=>(Ye??=Ke(import.meta.url))(e),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=e=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[t,s]=N.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return N.getBuiltinModule(e)}return Je(e)},{createRequire:$t}=L("node:module"),{mkdirSync:yt,writeFileSync:X,openSync:Ae,fchmodSync:je,closeSync:Le,realpathSync:G,lstatSync:Me,fstatSync:bt,fchownSync:St,fsyncSync:kt,renameSync:xt,rmSync:It,readFileSync:Ft}=L("node:fs"),{randomUUID:Ct,createHash:Et}=L("node:crypto"),{resolve:ue,relative:Ne,join:Tt,dirname:At,basename:jt,sep:Lt,isAbsolute:Mt}=L("node:path"),{execFileSync:Nt}=L("node:child_process"),{pathToFileURL:De}=L("node:url");let Bt;const _t=e=>(Bt??=$t(import.meta.url))(e),D=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ut=e=>{if(typeof D<"u"&&D.versions&&D.versions.node){const[t,s]=D.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return D.getBuiltinModule(e)}return _t(e)},{styleText:Ot}=Ut("node:util"),qt={error:"✖",info:"ℹ",success:"✓",warning:"⚠"},Pt=()=>{const{env:e}=process;return!!e.CI||e.CONTINUOUS_INTEGRATION==="true"||"BUILD_NUMBER"in e||"RUN_ID"in e},zt=/\u001B\[[\d;]*[a-z]/gi,Wt=e=>[...e.replaceAll(zt,"")].length,Vt=e=>{const t=[];return e.bold&&t.push("bold"),e.dim&&t.push("dim"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),e.strikethrough&&t.push("strikethrough"),e.color&&t.push(e.color),e.bgColor&&t.push(e.bgColor),t.length===0?s=>s:s=>Ot(t,s)};class Ht{#r=0;#l;#e=!1;#i="";#o="";#g=0;#d=0;#t;#s;#u="";#a;#f;#n;#y;#h=0;#c;#b;constructor(t={},s){if(t.frames)this.#a=t.frames;else{const n=t.name??"dots",r=vt(n);if(!r)throw new Error(`Unknown spinner "${n}". Pass a custom \`frames\` set or use one of: ${wt().join(", ")}.`);this.#a=r}this.#f=t.verbose!==!1,this.#i=t.prefixText??"",this.#t=s,this.#n=t.stream??process.stderr,this.#y=s?!0:this.#n.isTTY&&!Pt(),this.#b={...qt,...t.icons},typeof t.style=="function"?this.#c=t.style:t.style&&(this.#c=Vt(t.style))}get elapsedTime(){return this.#g===0?0:(this.#d||Date.now())-this.#g}get text(){return this.#o}set text(t){this.#o=t,this.#e&&this.#w()}get prefixText(){return this.#i}set prefixText(t){this.#i=t,this.#e&&this.#w()}get isRunning(){return this.#e}setInteractiveManager(t){this.#t=t}setMultiSpinner(t){this.#s=t}tick(){this.#e&&(this.#r=(this.#r+1)%this.#a.frames.length)}start(t,s){return this.#e?this:this.#f?(this.#e=!0,this.#g=Date.now(),this.#d=0,this.#r=0,this.#u="",t&&(this.#o=t),s?.prefixText&&(this.#i=s.prefixText),this.#s?(this.#s.renderAll(),this):(this.#t?(this.#t.hook(),this.#S(),this.#$()):(this.#k(),this.#$()),this)):this}stop(){if(this.#e){if(this.#p(),this.#e=!1,this.#d=Date.now(),this.#u="",this.#s){this.#s.renderAll();return}this.#t?(this.#t.erase("stdout"),this.#t.unhook(!1)):this.#v()}}stopAndPersist(t){if(!this.#e||(this.#p(),this.#e=!1,this.#d=Date.now(),!this.#f))return;const s=t?.prefixText??this.#i,n=t?.text??this.#o;let r=t?.symbol??"";s&&(r=r?`${s} ${r}`:s),n&&(r=r?`${r} ${n}`:n),this.#x(r)}succeed(t){this.#m("success",t)}failed(t){this.#m("error",t)}warn(t){this.#m("warning",t)}info(t){this.#m("info",t)}pause(){this.#p()}resume(){this.#e&&(this.#p(),this.#s||this.#$())}getFrameOutput(){if(!this.#e&&this.#u)return this.#u;const t=this.#a.frames[this.#r];let s=this.#c?this.#c(t):t;return this.#i&&(s=`${this.#i} ${s}`),this.#o&&(s=`${s} ${this.#o}`),s}#$(){this.#y&&(this.#l=setInterval(()=>{this.#e&&(this.#r=(this.#r+1)%this.#a.frames.length,this.#w())},this.#a.interval),this.#l.unref())}#p(){this.#l&&(clearInterval(this.#l),this.#l=void 0)}#w(){this.#s?this.#s.renderAll():this.#t?this.#S():this.#k()}#S(){this.#t&&this.#t.update("stdout",[this.getFrameOutput()])}#k(){const t=this.getFrameOutput();if(this.#v(),this.#n.isTTY){this.#n.write(t);const s=this.#n.columns||80;this.#h=Math.max(1,Math.ceil(Wt(t)/s))}else this.#n.write(`${t}
2
- `),this.#h=0}#v(){if(this.#h>0&&this.#n.isTTY){for(let t=1;t<this.#h;t+=1)this.#n.write("\x1B[1A\x1B[2K");this.#n.write("\r\x1B[K")}this.#h=0}#x(t){this.#u=t,this.#s?this.#s.renderAll():this.#t?(this.#t.update("stdout",[t]),this.#t.unhook(!1)):(this.#v(),this.#n.write(`${t}
3
- `))}#m(t,s){if(!this.#e||(this.#p(),this.#e=!1,this.#d=Date.now(),!this.#f))return;let n="";const r=this.#b[t];r&&(n=this.#c?this.#c(r):r),this.#i&&(n=`${this.#i} ${n}`),s&&(n=`${n} ${s}`),this.#x(n)}}const Be=(e={})=>{const t=new gt(new de(process.stdout),new de(process.stderr));return new Ht(e,t)},he=384,_e=(e,t,s)=>{if(yt(Qe(e),{recursive:!0}),!s){X(e,t);return}const n=Ae(e,"w",he);try{je(n,he),X(n,t)}finally{Le(n)}},Ue=(e,t)=>{if(!E(e))return e;const s=M(t,e);return s===""||s.startsWith("..")?e:s},Z=e=>{try{return G(e)}catch{return e}},Oe=(e,t)=>{const s=M(e,t);return s===""||s.startsWith("..")||E(s)?t:s},j=(e,t)=>{const s={...e,file:Ue(e.file,t)};return delete s.root,s},se=e=>{if(!te(e))return[];try{const t=Rt(e);return Array.isArray(t)?t:[]}catch{return[]}},ne=(e,t,s)=>{const n=E(e)?e:I(t,e);return Oe(Z(s),n)},pe=(e,t,s)=>{const n=ne(e.file,t,s);return n===e.file?e:{...e,file:n}},Gt=(e,t,s)=>{const n=e.files.map(r=>({...r,file:ne(r.file,t,s)}));return{...e,files:n}},Kt=(e,t,s)=>{const n=Z(t),r=Z(s);return se(e).flatMap(i=>{const a=Oe(r,E(i.file)?i.file:I(n,i.file));return a===i.file?[i]:[i,{...i,file:a}]})},fe=e=>[...ce(e),...ce(ee(e))],_=e=>typeof e=="string"?e:"",ie=e=>{const t={...e,match:_(e.match),secret:_(e.secret)};return Array.isArray(e.requiredFindings)?t.requiredFindings=e.requiredFindings.map(s=>({...s,match:_(s.match),secret:_(s.secret)})):delete t.requiredFindings,t},re=e=>ee(ie(e)),me=e=>[H(ie(e)),st(e),H(re(e))],Yt=(e,t,s)=>{const n=se(t).map(o=>j(o,s)),r=new Set(n.flatMap(o=>me(o))),i=e.map(o=>j(o,s)),a=new Set(i.flatMap(o=>fe(o))),c=o=>fe(o).some(d=>r.has(d));return{fresh:i.filter(o=>!c(o)),resolved:n.filter(o=>!me(o).some(d=>a.has(d))),surviving:i.filter(o=>c(o))}},ge=e=>H(re(e)),Jt=e=>{const t=_(e.secret);return re(e).secret===t},qe=(e,t,s,n={})=>{const r=e.map(a=>j(a,s));let i;if(n.replace)i=r;else{const a=new Set(r.filter(l=>l.secret!==l.match).map(l=>tt(ee(l)))),c=se(t).map(l=>j(l,s)).filter(l=>!a.has(ge(l))),o=new Set,d=new Set,p=new Set;i=[];for(const l of[...c,...r]){const b=H(ie(l)),h=ge(l),u=Jt(l);o.has(b)||(u?d.has(h):p.has(h))||(o.add(b),d.add(h),u&&p.add(h),i.push(l))}}return _e(t,`${JSON.stringify(i,null,4)}
4
- `,!0),i.length},Xt="********",Pe="<REDACTED>",Zt=Buffer.from(Pe,"utf8"),$e=(e,t)=>{const s=Ne(e,t);return s===".."||s.startsWith(`..${Lt}`)||Mt(s)},Qt=(e,t)=>{let s=1;for(let n=0;n<t;n++)e[n]===10&&s++;return s},es=(e,t,{gid:s,mode:n,uid:r})=>{const i=Tt(At(e),`.${jt(e)}.vis-fix-${process.pid}-${Ct()}`);try{const a=Ae(i,"wx",n);try{const c=bt(a);(c.uid!==r||c.gid!==s)&&St(a,r,s),je(a,n),X(a,t),kt(a)}finally{Le(a)}xt(i,e)}catch(a){throw It(i,{force:!0}),a}},we=(e,t)=>Ne(e,t)||t,ze=e=>{try{const t=Me(e);return t.isSymbolicLink()?{reason:"symbolic link"}:t.isFile()?t.nlink>1?{reason:"hard-linked file"}:(t.mode&146)===0?{reason:"read-only file"}:{bytes:Ft(e),dev:t.dev,gid:t.gid,ino:t.ino,mode:t.mode%4096,mtimeMs:t.mtimeMs,size:t.size,uid:t.uid}:{reason:"not a regular file"}}catch{return{reason:"file unavailable"}}},ts=(e,t)=>{try{const s=ze(e);return!("reason"in s)&&G(e)===e&&s.dev===t.dev&&s.ino===t.ino&&s.mode===t.mode&&s.uid===t.uid&&s.gid===t.gid&&s.size===t.size&&s.mtimeMs===t.mtimeMs&&s.bytes.equals(t.bytes)}catch{return!1}},ss=({matchEnd:e,matchStart:t,secretEnd:s,secretStart:n},r,i)=>Number.isInteger(t)&&Number.isInteger(e)&&Number.isInteger(n)&&Number.isInteger(s)&&t>=0&&n>=t&&s>n&&s<=e&&e<=r.length&&r.subarray(n,s).equals(i),ns=e=>{const t=[];for(const{end:s,ruleId:n,start:r}of[...e].sort((i,a)=>i.start-a.start||i.end-a.end)){const i=t.at(-1);i!==void 0&&r<i.end?(i.end=Math.max(i.end,s),i.ruleIds.add(n)):t.push({end:s,ruleIds:new Set([n]),start:r})}return t},is=(e,t)=>{const s=[];let n=0;for(const{end:r,start:i}of t)s.push(e.subarray(n,i),Zt),n=r;return s.push(e.subarray(n)),Buffer.concat(s)},rs=(e,t,s,n=t)=>{const r=[],i=new Map,a=new Map,c=ue(t,n);let o;try{o=G(t)}catch{o=t}const d=h=>{const u=ue(c,h),f=we(t,u);if($e(t,u))return{display:f,reason:"outside workspace"};let g;try{if(Me(u).isSymbolicLink())return{display:f,reason:"symbolic link"};g=G(u)}catch{return{display:f,reason:"file unavailable"}}if($e(o,g))return{display:f,reason:"outside workspace"};let w=a.get(g);return w===void 0&&(w=ze(g),a.set(g,w)),"reason"in w?{display:f,reason:w.reason}:{display:f,file:w,path:g}};for(const h of e){if(h.sourceSpan===void 0){r.push({file:h.file,line:h.startLine,reason:h.spanUnavailableReason??"no trusted byte span",ruleId:h.ruleId});continue}const u=d(h.file);for(const f of[h,...h.requiredFindings??[]]){const g=(S,y)=>{r.push({file:y,line:f.startLine,reason:S,ruleId:f.ruleId})},{sourceSpan:w}=f;if(w===void 0){g(f.spanUnavailableReason??"no trusted byte span",h.file);continue}if(f.secret.length===0){g("empty secret",h.file);continue}if("reason"in u){g(u.reason,u.display);continue}if(!ss(w,u.file.bytes,Buffer.from(f.secret,"utf8"))){g("span does not match file",u.display);continue}const v=i.get(u.path)??{file:u.file,spans:[]};v.spans.push({end:w.secretEnd,ruleId:f.ruleId,start:w.secretStart}),i.set(u.path,v)}}const p=[];let l=0,b=0;for(const[h,{file:u,spans:f}]of i){const g=ns(f),w=we(t,h),v=g.map(({ruleIds:y,start:m})=>({line:Qt(u.bytes,m),ruleIds:y}));if(!s){let y;if(ts(h,u))try{es(h,is(u.bytes,g),u)}catch{y="write failed"}else y="file changed during scan";if(y!==void 0){for(const{line:m,ruleIds:k}of v)r.push({file:w,line:m,reason:y,ruleId:[...k].sort().join(", ")});continue}}l++,b+=g.length;const S=new Map;for(const{line:y,ruleIds:m}of v)S.set(y,new Set([...S.get(y)??[],...m]));for(const[y,m]of S)p.push({file:w,line:y,ruleId:[...m].sort().join(", ")})}return p.sort((h,u)=>h.file.localeCompare(u.file)||h.line-u.line),r.sort((h,u)=>h.file.localeCompare(u.file)||h.line-u.line||h.reason.localeCompare(u.reason)),{changedFiles:l,edits:p,replacements:b,skipped:r}},Q=(e,t)=>{try{return Nt("git",[...nt,...t],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]})}catch{return""}},os=e=>e.split("\0").filter(Boolean),ve=(e,t)=>{if(t.startsWith("-"))throw new $(`--since "${t}" looks like a flag, not a git ref.`);const s=I(e,Q(e,["rev-parse","--show-cdup"]).trim()),n=i=>os(Q(e,["diff","-z","--name-only","--diff-filter=ACMR",...it,i,"--"]));let r=n(`${t}...HEAD`);return r.length===0&&(r=n(t)),r.map(i=>E(i)?i:V(s,i))},ye=e=>Q(e,["rev-parse","--show-toplevel"]).trim().length>0,as=/^[\t\r+=@-]/,F=e=>{const t=as.test(e)?`'${e}`:e;return/[\n\r",]/.test(t)?`"${t.replaceAll('"','""')}"`:t},cs=["RuleID","Commit","File","Secret","Match","StartLine","EndLine","StartColumn","EndColumn","Author","Message","Date","Email","Fingerprint","Tags"],ls=e=>{const t=e.map(s=>[F(s.ruleId),F(s.commit?.sha??""),F(s.file),F(s.secret),F(s.match),String(s.startLine),String(s.endLine),String(s.startColumn),String(s.endColumn),F(s.commit?.authorName??""),F(s.commit?.message??""),F(s.commit?.date??""),F(s.commit?.authorEmail??""),F(K(s)),F(s.tags.join(" "))].join(","));return`${[cs.join(","),...t].join(`\r
1
+ import{createRequire as Ke}from"node:module";import{b as C,F as I,X as Xe,J as Ee,q as Ze}from"../packem_shared/index.server-Ca_EEVfw.js";import{m as Qe,v as E,U as x,a as M,e as V,z as et}from"../packem_shared/index-0dnGN3GP.js";import{wholeMatchFingerprint as tt,maskFinding as ee,fingerprint as H,legacyFingerprint as st,baselineKeys as ce,GIT_CONFIG_OVERRIDES as nt,DIFF_HARDENING_FLAGS as it,gitleaksIgnoreFingerprint as K,toSarifUri as rt,CONFIDENCE_LEVELS as le,DEFAULT_MAX_FILE_SIZE as O,MAX_ARCHIVE_DEPTH as ot,listRules as Te,listRequiredValidators as at,scan as ct,isPathExcluded as lt,scanStringDetailed as dt,scanGitHistoryDetailed as ut,scanDetailed as ht,scanGitStaged as pt,scanFilesDetailed as ft,inspectRuleset as mt}from"@visulima/secret-scanner";import{V as $}from"../packem_shared/vis-user-error-BlvRmXn8.js";import{a3 as gt,a4 as de,p as T}from"./cli-main.js";import{E as vt,A as wt}from"../packem_shared/getRandomSpinner-DX11qCB2-CoIsn7ZU.js";import{y as te}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as Rt}from"../packem_shared/package-version-Bh9fCd7j.js";import{w as z}from"../packem_shared/github-workflow-command-Bn0MgB78.js";import{e as W,c as Dt}from"../packem_shared/junit-audit-CuJShWCH.js";let Ye;const Je=e=>(Ye??=Ke(import.meta.url))(e),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=e=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[t,s]=N.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return N.getBuiltinModule(e)}return Je(e)},{createRequire:$t}=L("node:module"),{mkdirSync:yt,writeFileSync:X,openSync:Ae,fchmodSync:je,closeSync:Le,realpathSync:G,lstatSync:Me,fstatSync:bt,fchownSync:St,fsyncSync:kt,renameSync:It,rmSync:xt,readFileSync:Ft}=L("node:fs"),{randomUUID:Ct,createHash:Et}=L("node:crypto"),{resolve:ue,relative:Ne,join:Tt,dirname:At,basename:jt,sep:Lt,isAbsolute:Mt}=L("node:path"),{execFileSync:Nt}=L("node:child_process"),{pathToFileURL:De}=L("node:url");let Bt;const _t=e=>(Bt??=$t(import.meta.url))(e),D=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ut=e=>{if(typeof D<"u"&&D.versions&&D.versions.node){const[t,s]=D.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return D.getBuiltinModule(e)}return _t(e)},{styleText:Ot}=Ut("node:util"),qt={error:"✖",info:"ℹ",success:"✓",warning:"⚠"},Pt=()=>{const{env:e}=process;return!!e.CI||e.CONTINUOUS_INTEGRATION==="true"||"BUILD_NUMBER"in e||"RUN_ID"in e},zt=/\u001B\[[\d;]*[a-z]/gi,Wt=e=>[...e.replaceAll(zt,"")].length,Vt=e=>{const t=[];return e.bold&&t.push("bold"),e.dim&&t.push("dim"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),e.strikethrough&&t.push("strikethrough"),e.color&&t.push(e.color),e.bgColor&&t.push(e.bgColor),t.length===0?s=>s:s=>Ot(t,s)};class Ht{#r=0;#l;#e=!1;#i="";#o="";#g=0;#d=0;#t;#s;#u="";#a;#f;#n;#y;#h=0;#c;#b;constructor(t={},s){if(t.frames)this.#a=t.frames;else{const n=t.name??"dots",r=wt(n);if(!r)throw new Error(`Unknown spinner "${n}". Pass a custom \`frames\` set or use one of: ${vt().join(", ")}.`);this.#a=r}this.#f=t.verbose!==!1,this.#i=t.prefixText??"",this.#t=s,this.#n=t.stream??process.stderr,this.#y=s?!0:this.#n.isTTY&&!Pt(),this.#b={...qt,...t.icons},typeof t.style=="function"?this.#c=t.style:t.style&&(this.#c=Vt(t.style))}get elapsedTime(){return this.#g===0?0:(this.#d||Date.now())-this.#g}get text(){return this.#o}set text(t){this.#o=t,this.#e&&this.#v()}get prefixText(){return this.#i}set prefixText(t){this.#i=t,this.#e&&this.#v()}get isRunning(){return this.#e}setInteractiveManager(t){this.#t=t}setMultiSpinner(t){this.#s=t}tick(){this.#e&&(this.#r=(this.#r+1)%this.#a.frames.length)}start(t,s){return this.#e?this:this.#f?(this.#e=!0,this.#g=Date.now(),this.#d=0,this.#r=0,this.#u="",t&&(this.#o=t),s?.prefixText&&(this.#i=s.prefixText),this.#s?(this.#s.renderAll(),this):(this.#t?(this.#t.hook(),this.#S(),this.#$()):(this.#k(),this.#$()),this)):this}stop(){if(this.#e){if(this.#p(),this.#e=!1,this.#d=Date.now(),this.#u="",this.#s){this.#s.renderAll();return}this.#t?(this.#t.erase("stdout"),this.#t.unhook(!1)):this.#w()}}stopAndPersist(t){if(!this.#e||(this.#p(),this.#e=!1,this.#d=Date.now(),!this.#f))return;const s=t?.prefixText??this.#i,n=t?.text??this.#o;let r=t?.symbol??"";s&&(r=r?`${s} ${r}`:s),n&&(r=r?`${r} ${n}`:n),this.#I(r)}succeed(t){this.#m("success",t)}failed(t){this.#m("error",t)}warn(t){this.#m("warning",t)}info(t){this.#m("info",t)}pause(){this.#p()}resume(){this.#e&&(this.#p(),this.#s||this.#$())}getFrameOutput(){if(!this.#e&&this.#u)return this.#u;const t=this.#a.frames[this.#r];let s=this.#c?this.#c(t):t;return this.#i&&(s=`${this.#i} ${s}`),this.#o&&(s=`${s} ${this.#o}`),s}#$(){this.#y&&(this.#l=setInterval(()=>{this.#e&&(this.#r=(this.#r+1)%this.#a.frames.length,this.#v())},this.#a.interval),this.#l.unref())}#p(){this.#l&&(clearInterval(this.#l),this.#l=void 0)}#v(){this.#s?this.#s.renderAll():this.#t?this.#S():this.#k()}#S(){this.#t&&this.#t.update("stdout",[this.getFrameOutput()])}#k(){const t=this.getFrameOutput();if(this.#w(),this.#n.isTTY){this.#n.write(t);const s=this.#n.columns||80;this.#h=Math.max(1,Math.ceil(Wt(t)/s))}else this.#n.write(`${t}
2
+ `),this.#h=0}#w(){if(this.#h>0&&this.#n.isTTY){for(let t=1;t<this.#h;t+=1)this.#n.write("\x1B[1A\x1B[2K");this.#n.write("\r\x1B[K")}this.#h=0}#I(t){this.#u=t,this.#s?this.#s.renderAll():this.#t?(this.#t.update("stdout",[t]),this.#t.unhook(!1)):(this.#w(),this.#n.write(`${t}
3
+ `))}#m(t,s){if(!this.#e||(this.#p(),this.#e=!1,this.#d=Date.now(),!this.#f))return;let n="";const r=this.#b[t];r&&(n=this.#c?this.#c(r):r),this.#i&&(n=`${this.#i} ${n}`),s&&(n=`${n} ${s}`),this.#I(n)}}const Be=(e={})=>{const t=new gt(new de(process.stdout),new de(process.stderr));return new Ht(e,t)},he=384,_e=(e,t,s)=>{if(yt(Qe(e),{recursive:!0}),!s){X(e,t);return}const n=Ae(e,"w",he);try{je(n,he),X(n,t)}finally{Le(n)}},Ue=(e,t)=>{if(!E(e))return e;const s=M(t,e);return s===""||s.startsWith("..")?e:s},Z=e=>{try{return G(e)}catch{return e}},Oe=(e,t)=>{const s=M(e,t);return s===""||s.startsWith("..")||E(s)?t:s},j=(e,t)=>{const s={...e,file:Ue(e.file,t)};return delete s.root,s},se=e=>{if(!te(e))return[];try{const t=Rt(e);return Array.isArray(t)?t:[]}catch{return[]}},ne=(e,t,s)=>{const n=E(e)?e:x(t,e);return Oe(Z(s),n)},pe=(e,t,s)=>{const n=ne(e.file,t,s);return n===e.file?e:{...e,file:n}},Gt=(e,t,s)=>{const n=e.files.map(r=>({...r,file:ne(r.file,t,s)}));return{...e,files:n}},Kt=(e,t,s)=>{const n=Z(t),r=Z(s);return se(e).flatMap(i=>{const a=Oe(r,E(i.file)?i.file:x(n,i.file));return a===i.file?[i]:[i,{...i,file:a}]})},fe=e=>[...ce(e),...ce(ee(e))],_=e=>typeof e=="string"?e:"",ie=e=>{const t={...e,match:_(e.match),secret:_(e.secret)};return Array.isArray(e.requiredFindings)?t.requiredFindings=e.requiredFindings.map(s=>({...s,match:_(s.match),secret:_(s.secret)})):delete t.requiredFindings,t},re=e=>ee(ie(e)),me=e=>[H(ie(e)),st(e),H(re(e))],Yt=(e,t,s)=>{const n=se(t).map(o=>j(o,s)),r=new Set(n.flatMap(o=>me(o))),i=e.map(o=>j(o,s)),a=new Set(i.flatMap(o=>fe(o))),c=o=>fe(o).some(d=>r.has(d));return{fresh:i.filter(o=>!c(o)),resolved:n.filter(o=>!me(o).some(d=>a.has(d))),surviving:i.filter(o=>c(o))}},ge=e=>H(re(e)),Jt=e=>{const t=_(e.secret);return re(e).secret===t},qe=(e,t,s,n={})=>{const r=e.map(a=>j(a,s));let i;if(n.replace)i=r;else{const a=new Set(r.filter(l=>l.secret!==l.match).map(l=>tt(ee(l)))),c=se(t).map(l=>j(l,s)).filter(l=>!a.has(ge(l))),o=new Set,d=new Set,f=new Set;i=[];for(const l of[...c,...r]){const b=H(ie(l)),h=ge(l),u=Jt(l);o.has(b)||(u?d.has(h):f.has(h))||(o.add(b),d.add(h),u&&f.add(h),i.push(l))}}return _e(t,`${JSON.stringify(i,null,4)}
4
+ `,!0),i.length},Xt="********",Pe="<REDACTED>",Zt=Buffer.from(Pe,"utf8"),$e=(e,t)=>{const s=Ne(e,t);return s===".."||s.startsWith(`..${Lt}`)||Mt(s)},Qt=(e,t)=>{let s=1;for(let n=0;n<t;n++)e[n]===10&&s++;return s},es=(e,t,{gid:s,mode:n,uid:r})=>{const i=Tt(At(e),`.${jt(e)}.vis-fix-${process.pid}-${Ct()}`);try{const a=Ae(i,"wx",n);try{const c=bt(a);(c.uid!==r||c.gid!==s)&&St(a,r,s),je(a,n),X(a,t),kt(a)}finally{Le(a)}It(i,e)}catch(a){throw xt(i,{force:!0}),a}},ve=(e,t)=>Ne(e,t)||t,ze=e=>{try{const t=Me(e);return t.isSymbolicLink()?{reason:"symbolic link"}:t.isFile()?t.nlink>1?{reason:"hard-linked file"}:(t.mode&146)===0?{reason:"read-only file"}:{bytes:Ft(e),dev:t.dev,gid:t.gid,ino:t.ino,mode:t.mode%4096,mtimeMs:t.mtimeMs,size:t.size,uid:t.uid}:{reason:"not a regular file"}}catch{return{reason:"file unavailable"}}},ts=(e,t)=>{try{const s=ze(e);return!("reason"in s)&&G(e)===e&&s.dev===t.dev&&s.ino===t.ino&&s.mode===t.mode&&s.uid===t.uid&&s.gid===t.gid&&s.size===t.size&&s.mtimeMs===t.mtimeMs&&s.bytes.equals(t.bytes)}catch{return!1}},ss=({matchEnd:e,matchStart:t,secretEnd:s,secretStart:n},r,i)=>Number.isInteger(t)&&Number.isInteger(e)&&Number.isInteger(n)&&Number.isInteger(s)&&t>=0&&n>=t&&s>n&&s<=e&&e<=r.length&&r.subarray(n,s).equals(i),ns=e=>{const t=[];for(const{end:s,ruleId:n,start:r}of[...e].sort((i,a)=>i.start-a.start||i.end-a.end)){const i=t.at(-1);i!==void 0&&r<i.end?(i.end=Math.max(i.end,s),i.ruleIds.add(n)):t.push({end:s,ruleIds:new Set([n]),start:r})}return t},is=(e,t)=>{const s=[];let n=0;for(const{end:r,start:i}of t)s.push(e.subarray(n,i),Zt),n=r;return s.push(e.subarray(n)),Buffer.concat(s)},rs=(e,t,s,n=t)=>{const r=[],i=new Map,a=new Map,c=ue(t,n);let o;try{o=G(t)}catch{o=t}const d=h=>{const u=ue(c,h),p=ve(t,u);if($e(t,u))return{display:p,reason:"outside workspace"};let w;try{if(Me(u).isSymbolicLink())return{display:p,reason:"symbolic link"};w=G(u)}catch{return{display:p,reason:"file unavailable"}}if($e(o,w))return{display:p,reason:"outside workspace"};let v=a.get(w);return v===void 0&&(v=ze(w),a.set(w,v)),"reason"in v?{display:p,reason:v.reason}:{display:p,file:v,path:w}};for(const h of e){if(h.sourceSpan===void 0){r.push({file:h.file,line:h.startLine,reason:h.spanUnavailableReason??"no trusted byte span",ruleId:h.ruleId});continue}const u=d(h.file);for(const p of[h,...h.requiredFindings??[]]){const w=(S,y)=>{r.push({file:y,line:p.startLine,reason:S,ruleId:p.ruleId})},{sourceSpan:v}=p;if(v===void 0){w(p.spanUnavailableReason??"no trusted byte span",h.file);continue}if(p.secret.length===0){w("empty secret",h.file);continue}if("reason"in u){w(u.reason,u.display);continue}if(!ss(v,u.file.bytes,Buffer.from(p.secret,"utf8"))){w("span does not match file",u.display);continue}const g=i.get(u.path)??{file:u.file,spans:[]};g.spans.push({end:v.secretEnd,ruleId:p.ruleId,start:v.secretStart}),i.set(u.path,g)}}const f=[];let l=0,b=0;for(const[h,{file:u,spans:p}]of i){const w=ns(p),v=ve(t,h),g=w.map(({ruleIds:y,start:m})=>({line:Qt(u.bytes,m),ruleIds:y}));if(!s){let y;if(ts(h,u))try{es(h,is(u.bytes,w),u)}catch{y="write failed"}else y="file changed during scan";if(y!==void 0){for(const{line:m,ruleIds:k}of g)r.push({file:v,line:m,reason:y,ruleId:[...k].sort().join(", ")});continue}}l++,b+=w.length;const S=new Map;for(const{line:y,ruleIds:m}of g)S.set(y,new Set([...S.get(y)??[],...m]));for(const[y,m]of S)f.push({file:v,line:y,ruleId:[...m].sort().join(", ")})}return f.sort((h,u)=>h.file.localeCompare(u.file)||h.line-u.line),r.sort((h,u)=>h.file.localeCompare(u.file)||h.line-u.line||h.reason.localeCompare(u.reason)),{changedFiles:l,edits:f,replacements:b,skipped:r}},Q=(e,t)=>{try{return Nt("git",[...nt,...t],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]})}catch{return""}},os=e=>e.split("\0").filter(Boolean),we=(e,t)=>{if(t.startsWith("-"))throw new $(`--since "${t}" looks like a flag, not a git ref.`);const s=x(e,Q(e,["rev-parse","--show-cdup"]).trim()),n=i=>os(Q(e,["diff","-z","--name-only","--diff-filter=ACMR",...it,i,"--"]));let r=n(`${t}...HEAD`);return r.length===0&&(r=n(t)),r.map(i=>E(i)?i:V(s,i))},ye=e=>Q(e,["rev-parse","--show-toplevel"]).trim().length>0,as=/^[\t\r+=@-]/,F=e=>{const t=as.test(e)?`'${e}`:e;return/[\n\r",]/.test(t)?`"${t.replaceAll('"','""')}"`:t},cs=["RuleID","Commit","File","Secret","Match","StartLine","EndLine","StartColumn","EndColumn","Author","Message","Date","Email","Fingerprint","Tags"],ls=e=>{const t=e.map(s=>[F(s.ruleId),F(s.commit?.sha??""),F(s.file),F(s.secret),F(s.match),String(s.startLine),String(s.endLine),String(s.startColumn),String(s.endColumn),F(s.commit?.authorName??""),F(s.commit?.message??""),F(s.commit?.date??""),F(s.commit?.authorEmail??""),F(K(s)),F(s.tags.join(" "))].join(","));return`${[cs.join(","),...t].join(`\r
5
5
  `)}\r
6
6
  `},ds=e=>{const t=[...e];return t.length<=6?"******":`${t.slice(0,3).join("")}${"*".repeat(t.length-6)}${t.slice(-3).join("")}`},us=(e,t={})=>{const s=(t.now??new Date).toISOString().replace(/\.\d{3}Z$/,""),n=String(e.length),r=e.map(i=>{const a=`${i.file}:${String(i.startLine)}:${String(i.startColumn)}`,c=[`Rule: ${i.ruleId}`,`File: ${a}`,...i.commit===void 0?[]:[`Commit: ${i.commit.sha}`,`Author: ${i.commit.authorName} <${i.commit.authorEmail}>`],`Secret: ${ds(i.secret)}`,`Fingerprint: ${K(i)}`].join(`
7
7
  `),o=`<failure type="${W(i.ruleId)}" message="${W(i.description||i.ruleId)}">${Dt(c)}</failure>`;return[` <testcase classname="${W(i.file)}" name="${W(`${i.ruleId} at ${a}`)}">`,` ${o}`," </testcase>",""].join(`
@@ -10,23 +10,23 @@ import{createRequire as Ke}from"node:module";import{b as C,F as x,X as Xe,J as E
10
10
  `},ps=/\.(?:zip|jar|war|ear|tar|tgz|gz)!/iu,fs=(e,t={})=>e.map(s=>{const n=s.description||s.ruleId,r=`${s.file}:${String(s.startLine)}`;return s.commit?z("error",{title:s.ruleId},`${n}
11
11
  ${r} in commit ${s.commit.sha.slice(0,7)}`):t.staged?z("error",{title:s.ruleId},`${n}
12
12
  ${r} (staged)`):ps.test(s.file)?z("error",{title:s.ruleId},`${n}
13
- ${r}`):z("error",{col:s.startColumn,endColumn:s.endColumn,endLine:s.endLine,file:s.file,line:s.startLine,title:s.ruleId},n)}).join(""),be=1,ms=e=>{const t=new Map;for(const s of e){const n=t.get(s.file);n?n.push(s):t.set(s.file,[s])}return t},gs=e=>{try{return et(e).split(/\r?\n/)}catch{return}},$s=(e,t,s)=>{const n=Math.max(1,t);return`${e.slice(0,n-1).replaceAll(/[^\t]/g," ")}${"^".repeat(Math.max(1,s))}`},B=e=>e,We=e=>e?{cyan:Ze,dim:x,green:Ee,red:Xe,yellow:C}:{cyan:B,dim:B,green:B,red:B,yellow:B},ws=(e,t,s,n={})=>{if(e.length===0)return s?x("No secrets detected."):"No secrets detected.";const r=We(s),i=[],a=ms(e);for(const[c,o]of a){const d=M(t,c)||c;i.push(r.cyan(d));const p=n.redact?void 0:gs(c);for(const l of o){const b=[l.source,l.confidence].filter(Boolean).join(", "),h=b?` ${r.dim(`(${b})`)}`:"",u=l.alternateMatches&&l.alternateMatches.length>0?` ${r.dim(`also: ${l.alternateMatches.join(", ")}`)}`:"";let f="";switch(l.validation){case"error":{f=` ${r.yellow("! error")}`;break}case"rejected":{f=` ${r.red("✗ rejected")}`;break}case"skipped":{f=` ${r.dim("— unverifiable")}`;break}case"verified":{f=` ${r.green("✓ verified")}`;break}}if(i.push(` ${r.red("✖")} ${r.yellow(`[${l.ruleId}]`)}${h}${f} ${r.dim(`line ${String(l.startLine)}:${String(l.startColumn)}`)}${u}`),p){const g=Math.max(0,l.startLine-1-be),w=Math.min(p.length,l.startLine+be);for(let v=g;v<w;v+=1){const S=String(v+1).padStart(4," "),y=v+1===l.startLine,m=y?r.red("▶"):" ";if(i.push(` ${m} ${r.dim(S)} │ ${p[v]??""}`),y){const k=Math.max(1,(l.endColumn??l.startColumn+1)-l.startColumn),P=$s(p[v]??"",l.startColumn,k);i.push(` ${r.dim(" │ ")}${r.red(P)}`)}}}i.push("")}}return i.join(`
14
- `).trimEnd()},vs=(e,t,s={})=>{if(e.length===0)return t?x("No secrets detected in git history."):"No secrets detected in git history.";const n=We(t),r=new Map;for(const a of e){const c=r.get(a.commit.sha);c?c.push(a):r.set(a.commit.sha,[a])}const i=[];for(const[a,c]of r){const{authorName:o,date:d,message:p}=c[0].commit;i.push(`${n.yellow(a.slice(0,10))} ${p}`),i.push(` ${n.dim(`${o} · ${d}`)}`);for(const l of c){const b=[l.source,l.confidence].filter(Boolean).join(", "),h=b?` ${n.dim(`(${b})`)}`:"",u=s.redact?"":` ${n.dim(l.match)}`;i.push(` ${n.red("✖")} ${n.yellow(`[${l.ruleId}]`)}${h} ${n.cyan(l.file)} ${n.dim(`line ${String(l.startLine)}:${String(l.startColumn)}`)}${u}`)}i.push("")}return i.join(`
15
- `).trimEnd()},ys=(e,t,s,n={})=>{const r=new Map;for(const o of e)r.set(o.reason,(r.get(o.reason)??0)+1);const i=[...r].map(([o,d])=>`${o}: ${String(d)}`).join(", "),a=`${String(e.length)} ${t}(s) not scanned (${i})${n.verbose?"":"; use --verbose to list them"}`,c=[s?C(a):a];if(n.verbose)for(const o of e){const d="sha"in o?` ${o.commit===void 0?"":`${o.commit.slice(0,10)} `}${o.sha.slice(0,10)}`:"",p=` - ${o.path} [${o.reason}]${d}`;c.push(s?x(p):p)}return c.join(`
16
- `)},bs=(e,t,s)=>{const n=`${String(e.length)} allow marker(s) name unknown rule ids and still suppress every rule (rename or remove the ids):`,r=[s?C(n):n];for(const i of e){const a=` - ${Ue(i.file,t)}:${String(i.line)} unknown: ${i.unknownRuleIds.join(", ")}`;r.push(s?x(a):a)}return r.join(`
17
- `)},Ss=(e,t)=>{if(!E(e))return rt(e);try{return De(e).toString()}catch{return`file://${I(t,e).replaceAll("\\","/")}`}},ks=(e,t=100)=>e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`,xs=(e,t,s=process.cwd(),n=[])=>{const r=new Map(n.map(o=>[o.id,o])),i=new Set;for(const o of e)i.add(o.ruleId);const a=[...new Set([...r.keys(),...i])].sort((o,d)=>o.localeCompare(d)),c=new Map(a.map((o,d)=>[o,d]));return JSON.stringify({$schema:"https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0.json",runs:[{originalUriBaseIds:{SRCROOT:{uri:De(s).toString()}},results:e.map(o=>{const d={};return o.source&&(d.source=o.source),o.confidence&&(d.confidence=o.confidence),o.alternateMatches&&o.alternateMatches.length>0&&(d.alternateRules=o.alternateMatches),o.validation&&(d.validation=o.validation),{level:"error",locations:[{physicalLocation:{artifactLocation:{uri:Ss(o.file,s),uriBaseId:E(o.file)?void 0:"SRCROOT"},region:{endColumn:o.endColumn,endLine:o.endLine,snippet:{text:o.match},startColumn:o.startColumn,startLine:o.startLine}}}],message:{text:o.description||o.ruleId},properties:Object.keys(d).length>0?d:void 0,ruleId:o.ruleId,ruleIndex:c.get(o.ruleId)??-1}}),tool:{driver:{informationUri:"https://visulima.com/packages/secret-scanner",name:"visulima-secret-scanner",rules:a.map(o=>{const d=r.get(o),p=d?.description??`Detected by rule \`${o}\``,l={};return d?.tags&&d.tags.length>0&&(l.tags=d.tags),d?.source&&(l.source=d.source),d?.confidence&&(l.confidence=d.confidence),{defaultConfiguration:{level:"error"},fullDescription:{text:p},helpUri:"https://visulima.com/packages/secret-scanner",id:o,name:o,properties:Object.keys(l).length>0?l:void 0,shortDescription:{text:ks(p)}}}),version:t}}}],version:"2.1.0"},void 0,2)},oe=["text","json","sarif","csv","junit","gitlab-code-quality","github"],Ve=e=>oe.includes(e),Is=e=>{const t=[],s=new Set;for(const n of e){const r=n.indexOf("="),i=r===-1?n:n.slice(0,r),a=r===-1?"":n.slice(r+1);if(!Ve(i))throw new $(`--report "${n}": format must be one of ${oe.join(", ")}, as <format>=<path> (e.g. sarif=secrets.sarif)`);if(a==="")throw new $(`--report "${n}" needs a file path: ${i}=<path>`);if(s.has(a))throw new $(`--report writes ${a} twice; give each report its own file.`);s.add(a),t.push({format:i,path:a})}return t},Se=(e,t,s)=>{const n=()=>t.map(r=>j(r,s.root));switch(e){case"csv":return ls(n());case"github":return fs(n(),{staged:s.staged});case"gitlab-code-quality":return hs(n());case"json":return`${JSON.stringify(n(),null,2)}
18
- `;case"junit":return us(n());case"sarif":return`${xs(t,s.toolVersion,s.root,s.ruleMetadata)}
19
- `;default:return`${s.history?vs(t,s.useColor,{redact:s.redact}):ws(t,s.root,s.useColor,{redact:s.redact})}
20
- `}},Fs=e=>e.kind==="secret"?"<secret-value entry>":e.raw,Rs=(e,t,s)=>{const n=`${String(e.length)} unused ${t} entr${e.length===1?"y":"ies"} (no finding matched; remove or update them):`,r=[s?C(n):n];for(const i of e){const a=` - line ${String(i.line)}: ${Fs(i)}`;r.push(s?x(a):a)}return r.join(`
21
- `)},Cs=(e,t,s)=>{const n=`${String(e.length)} finding(s) suppressed:`,r=[s?C(n):n];for(const i of e){const a=j(i,t),c=i.suppressedByEntry===void 0?"":` line ${String(i.suppressedByEntry.line)}`,o=`${i.suppressedBy}${c}`,d=` - [${i.ruleId}] ${K({...a,commit:i.commit})} (${o})`;r.push(s?x(d):d)}return r.join(`
22
- `)},Es=async(e,t)=>{try{return await e.access(t),!0}catch{return!1}},A=e=>e?Array.isArray(e)?e:[e]:[],Ts=e=>{if(e===void 0)return"text";if(!Ve(e))throw new $(`--format must be one of: ${oe.join(", ")} (got "${e}")`);return e},ke=(e,t,s)=>{if(e!==void 0){if(!Number.isInteger(e)||e<0||s!==void 0&&e>s){const n=s===void 0?"a non-negative integer":`an integer from 0 to ${String(s)}`;throw new $(`${t} must be ${n} (got ${String(e)}).`)}return e}},As=e=>{if(e!==void 0&&(!Number.isInteger(e)||e<1))throw new $(`--max-size must be a positive number of bytes (got ${String(e)}; default ${String(O)}).`);return e},js=e=>{if(e!==void 0){if(!le.includes(e))throw new $(`--min-confidence must be one of: ${le.join(", ")} (got "${e}")`);return e}},Ls=(e,t,s)=>{const n=t??{},r=m=>m?I(s,m):void 0,i=(m,k)=>{const P=A(m);return P.length>0?P:k},a=(n.config?.presets??[]).map(m=>`tag:preset:${m}`),c=i(e.enableRule,n.rules?.enable)??[],o=[...c,...a.filter(m=>!c.includes(m))],d=o.length>0?o:void 0,p=i(e.excludeRule,n.rules?.exclude),l=i(e.includeRule,n.rules?.include),b=i(e.exclude,n.walk?.excludePatterns),h=A(e.excludeFrom).map(m=>I(s,m)),u=n.walk?.excludeFromFiles?.map(m=>I(s,m)),f=r(e.baseline)??r(n.baseline),g=r(e.config)??r(n.config?.path),w=js(e.minConfidence??n.config?.minConfidence),v=A(e.secretlintignore).map(m=>I(s,m));let S,y=h.length>0?h:u;if(e.secretlintignore===!1)S=!1;else if(v.length>0&&n.secretlintIgnore===!1)S=!1,y=[...y??[],...v];else if(v.length>0){const m=Array.isArray(n.secretlintIgnore)?n.secretlintIgnore.map(k=>I(s,k)):[];S=[...new Set([...m,...v])]}else n.secretlintIgnore===!1?S=!1:S=n.secretlintIgnore?.map(m=>I(s,m));return{baseline:f,concurrency:e.concurrency,config:{extendBundled:e.extendBundled===!1?!1:n.config?.extendBundled,inline:n.config?.inline,minConfidence:w,onlyVerified:e.onlyVerified??n.config?.onlyVerified??!1,path:g,validate:e.validate??n.config?.validate??!1},inlineAllow:e.inlineAllow,maxArchiveDepth:ke(e.maxArchiveDepth,"--max-archive-depth",ot),maxDecodeDepth:ke(e.maxDecodeDepth,"--max-decode-depth"),overrides:n.overrides,overridesRoot:s,profile:e.profile===!0,redact:e.redact??n.redact??!0,reportSuppressed:e.logIgnored===!0,rules:{enable:d,exclude:p,include:l},secretlintIgnore:S,verbose:e.verbose??!1,walk:{excludeFromFiles:y,excludePatterns:b,gitignore:e.gitignore===!1?!1:n.walk?.gitignore??!0,includeHidden:e.includeHidden??n.walk?.includeHidden,maxFileSize:As(e.maxSize)??n.walk?.maxFileSize}}},q=e=>{if(e.stdin!==void 0){if(e.stdin===null||e.stdin==="")throw new $("--stdin needs a filename used for rule and path matching, e.g. `cat .env | vis secrets --stdin .env`.");return e.stdin}},He=e=>[q(e)===void 0?void 0:"--stdin",e.history?"--history":void 0,e.staged?"--staged":void 0,e.since===void 0?void 0:"--since",e.affected?"--affected":void 0].filter(t=>t!==void 0),xe=(e,t)=>[e.listRules?"--list-rules":void 0,e.listValidators?"--list-validators":void 0,e.init?"--init":void 0,t&&e.updateBaseline?"--update-baseline":void 0].find(s=>s!==void 0),Ms=e=>{const t=He(e);if(t.length>1)throw new $(`${t.join(", ")} each pick what to scan and can't be combined. Use one of them.`);if(!e.history){const s=[e.all?"--all":void 0,e.historyRange===void 0?void 0:"--history-range",e.maxCommits===void 0?void 0:"--max-commits"].filter(n=>n!==void 0);if(s.length>0)throw new $(`${s.join(", ")} only applies to git history scans. Did you mean \`vis secrets --history ${s.join(" ")}\`?`);return}if(e.all&&e.historyRange!==void 0)throw new $("--all walks every ref and can't be combined with --history-range. Use one or the other.");if(e.updateBaseline)throw new $("--update-baseline records working-tree findings and can't be combined with --history.");if(e.maxCommits!==void 0&&(!Number.isInteger(e.maxCommits)||e.maxCommits<1))throw new $(`--max-commits must be a positive integer (got ${String(e.maxCommits)}); omit it to walk every commit.`)},Ns=e=>{const t=e.history?"--history":e.staged?"--staged":void 0;if(e.maxArchiveDepth!==void 0&&t!==void 0)throw new $(`--max-archive-depth only applies to working-tree scans; ${t} scans git blobs as text and doesn't open archives. Drop --max-archive-depth or ${t}.`)},Ge=(e,t)=>[q(e)===void 0?void 0:"--stdin",e.staged?"--staged":void 0,e.since===void 0?void 0:"--since",e.affected?"--affected":void 0,e.historyRange===void 0?void 0:"--history-range",e.maxCommits===void 0?void 0:"--max-commits",t?"explicit paths":void 0].filter(s=>s!==void 0),Ds=(e,t)=>{if(q(e)!==void 0){if(t)throw new $("--stdin scans piped content and can't be combined with explicit paths.");const c=[e.updateBaseline?"--update-baseline":void 0,e.replaceBaseline?"--replace-baseline":void 0,e.logIgnored?"--log-ignored":void 0,e.maxSize===void 0?void 0:"--max-size",e.maxArchiveDepth===void 0?void 0:"--max-archive-depth",e.failOnUnreadable?"--fail-on-unreadable":void 0].filter(o=>o!==void 0);if(c.length>0)throw new $(`${c.join(", ")} can't be combined with --stdin: a single piped buffer can't seed a baseline, and there are no files to size-check, skip, list or open as archives.`)}const s=xe(e,!0),n=[A(e.report).length>0?"--report":void 0,e.logIgnored?"--log-ignored":void 0,e.profile?"--profile":void 0,e.failOnUnreadable?"--fail-on-unreadable":void 0,e.failOnUnusedIgnores?"--fail-on-unused-ignores":void 0].filter(c=>c!==void 0);if(s!==void 0&&n.length>0)throw new $(`${n.join(", ")} only applies to a scan report and can't be combined with ${s}.`);const r=xe(e,!1),i=[...He(e),...t?["explicit paths"]:[]];if(r!==void 0&&i.length>0)throw new $(`${i.join(", ")} picks what to scan and can't be combined with ${r}.`);if(!e.failOnUnusedIgnores)return;if(e.gitleaksIgnore===!1)throw new $("--fail-on-unused-ignores checks .gitleaksignore, which --no-gitleaks-ignore turns off. Drop one of them.");const a=Ge(e,t);if(a.length>0)throw new $(`--fail-on-unused-ignores needs a full scan: with ${a.join(", ")}, entries for files outside the scan would be reported as unused. Run it on a full \`vis secrets\` or \`vis secrets --history\` scan.`)},Bs=e=>{if(e.dryRun&&!e.fix&&!e.init)throw new $("--dry-run needs --fix (to preview rewrites) or --init (to preview a baseline).")},_s=(e,t,s)=>{if(!e.fix)return;const n=e.format??"text",r=[e.redact===!0?"--redact":void 0,e.history?"--history":void 0,e.staged?"--staged":void 0,e.init?"--init":void 0,q(e)===void 0?void 0:"--stdin",e.profile?"--profile":void 0,e.listRules?"--list-rules":void 0,e.listValidators?"--list-validators":void 0,e.updateBaseline?"--update-baseline":void 0,e.replaceBaseline?"--replace-baseline":void 0,A(e.report).length>0?"--report":void 0,e.logIgnored?"--log-ignored":void 0,e.failOnUnreadable?"--fail-on-unreadable":void 0,e.failOnUnusedIgnores?"--fail-on-unused-ignores":void 0,e.validate||t.config?.validate?"--validate":void 0,n==="text"?void 0:`--format ${n}`].filter(i=>i!==void 0);if(r.length>0)throw new $(`${r.join(", ")} cannot be combined with --fix. Fix mode rewrites working-tree files in place and prints only a masked summary.`);if(s>1)throw new $("--fix accepts at most one path; run one scan per path so rewrite targets stay unambiguous.")},ae=".gitleaksignore",R=T.child({stdout:process.stderr}),Us=(e,t)=>{const{flags:s,root:n,useColor:r}=t;s.quiet||(e.skipped.length>0&&process.stderr.write(`${ys(e.skipped,e.skippedUnit,r,{verbose:s.verbose})}
13
+ ${r}`):z("error",{col:s.startColumn,endColumn:s.endColumn,endLine:s.endLine,file:s.file,line:s.startLine,title:s.ruleId},n)}).join(""),be=1,ms=e=>{const t=new Map;for(const s of e){const n=t.get(s.file);n?n.push(s):t.set(s.file,[s])}return t},gs=(e,t)=>{if(t!==void 0)return t.split(/\r?\n/);try{return et(e).split(/\r?\n/)}catch{return}},$s=(e,t,s)=>{const n=Math.max(1,t);return`${e.slice(0,n-1).replaceAll(/[^\t]/g," ")}${"^".repeat(Math.max(1,s))}`},B=e=>e,We=e=>e?{cyan:Ze,dim:I,green:Ee,red:Xe,yellow:C}:{cyan:B,dim:B,green:B,red:B,yellow:B},vs=(e,t,s,n={})=>{if(e.length===0)return s?I("No secrets detected."):"No secrets detected.";const r=We(s),i=[],a=ms(e);for(const[c,o]of a){const d=M(t,c)||c;i.push(r.cyan(d));const f=n.redact?void 0:gs(c,n.virtualSource);for(const l of o){const b=[l.source,l.confidence].filter(Boolean).join(", "),h=b?` ${r.dim(`(${b})`)}`:"",u=l.alternateMatches&&l.alternateMatches.length>0?` ${r.dim(`also: ${l.alternateMatches.join(", ")}`)}`:"";let p="";switch(l.validation){case"error":{p=` ${r.yellow("! error")}`;break}case"rejected":{p=` ${r.red("✗ rejected")}`;break}case"skipped":{p=` ${r.dim("— unverifiable")}`;break}case"verified":{p=` ${r.green("✓ verified")}`;break}}if(i.push(` ${r.red("✖")} ${r.yellow(`[${l.ruleId}]`)}${h}${p} ${r.dim(`line ${String(l.startLine)}:${String(l.startColumn)}`)}${u}`),f){const w=Math.max(0,l.startLine-1-be),v=Math.min(f.length,l.startLine+be);for(let g=w;g<v;g+=1){const S=String(g+1).padStart(4," "),y=g+1===l.startLine,m=y?r.red("▶"):" ";if(i.push(` ${m} ${r.dim(S)} │ ${f[g]??""}`),y){const k=Math.max(1,(l.endColumn??l.startColumn+1)-l.startColumn),P=$s(f[g]??"",l.startColumn,k);i.push(` ${r.dim(" │ ")}${r.red(P)}`)}}}i.push("")}}return i.join(`
14
+ `).trimEnd()},ws=(e,t,s={})=>{if(e.length===0)return t?I("No secrets detected in git history."):"No secrets detected in git history.";const n=We(t),r=new Map;for(const a of e){const c=r.get(a.commit.sha);c?c.push(a):r.set(a.commit.sha,[a])}const i=[];for(const[a,c]of r){const{authorName:o,date:d,message:f}=c[0].commit;i.push(`${n.yellow(a.slice(0,10))} ${f}`),i.push(` ${n.dim(`${o} · ${d}`)}`);for(const l of c){const b=[l.source,l.confidence].filter(Boolean).join(", "),h=b?` ${n.dim(`(${b})`)}`:"",u=s.redact?"":` ${n.dim(l.match)}`;i.push(` ${n.red("✖")} ${n.yellow(`[${l.ruleId}]`)}${h} ${n.cyan(l.file)} ${n.dim(`line ${String(l.startLine)}:${String(l.startColumn)}`)}${u}`)}i.push("")}return i.join(`
15
+ `).trimEnd()},ys=(e,t,s,n={})=>{const r=new Map;for(const o of e)r.set(o.reason,(r.get(o.reason)??0)+1);const i=[...r].map(([o,d])=>`${o}: ${String(d)}`).join(", "),a=`${String(e.length)} ${t}(s) not scanned (${i})${n.verbose?"":"; use --verbose to list them"}`,c=[s?C(a):a];if(n.verbose)for(const o of e){const d="sha"in o?` ${o.commit===void 0?"":`${o.commit.slice(0,10)} `}${o.sha.slice(0,10)}`:"",f=` - ${o.path} [${o.reason}]${d}`;c.push(s?I(f):f)}return c.join(`
16
+ `)},bs=(e,t,s)=>{const n=`${String(e.length)} allow marker(s) name unknown rule ids and still suppress every rule (rename or remove the ids):`,r=[s?C(n):n];for(const i of e){const a=` - ${Ue(i.file,t)}:${String(i.line)} unknown: ${i.unknownRuleIds.join(", ")}`;r.push(s?I(a):a)}return r.join(`
17
+ `)},Ss=(e,t)=>{if(!E(e))return rt(e);try{return De(e).toString()}catch{return`file://${x(t,e).replaceAll("\\","/")}`}},ks=(e,t=100)=>e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`,Is=(e,t,s=process.cwd(),n=[])=>{const r=new Map(n.map(o=>[o.id,o])),i=new Set;for(const o of e)i.add(o.ruleId);const a=[...new Set([...r.keys(),...i])].sort((o,d)=>o.localeCompare(d)),c=new Map(a.map((o,d)=>[o,d]));return JSON.stringify({$schema:"https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0.json",runs:[{originalUriBaseIds:{SRCROOT:{uri:De(s).toString()}},results:e.map(o=>{const d={};return o.source&&(d.source=o.source),o.confidence&&(d.confidence=o.confidence),o.alternateMatches&&o.alternateMatches.length>0&&(d.alternateRules=o.alternateMatches),o.validation&&(d.validation=o.validation),{level:"error",locations:[{physicalLocation:{artifactLocation:{uri:Ss(o.file,s),uriBaseId:E(o.file)?void 0:"SRCROOT"},region:{endColumn:o.endColumn,endLine:o.endLine,snippet:{text:o.match},startColumn:o.startColumn,startLine:o.startLine}}}],message:{text:o.description||o.ruleId},properties:Object.keys(d).length>0?d:void 0,ruleId:o.ruleId,ruleIndex:c.get(o.ruleId)??-1}}),tool:{driver:{informationUri:"https://visulima.com/packages/secret-scanner",name:"visulima-secret-scanner",rules:a.map(o=>{const d=r.get(o),f=d?.description??`Detected by rule \`${o}\``,l={};return d?.tags&&d.tags.length>0&&(l.tags=d.tags),d?.source&&(l.source=d.source),d?.confidence&&(l.confidence=d.confidence),{defaultConfiguration:{level:"error"},fullDescription:{text:f},helpUri:"https://visulima.com/packages/secret-scanner",id:o,name:o,properties:Object.keys(l).length>0?l:void 0,shortDescription:{text:ks(f)}}}),version:t}}}],version:"2.1.0"},void 0,2)},oe=["text","json","sarif","csv","junit","gitlab-code-quality","github"],Ve=e=>oe.includes(e),xs=e=>{const t=[],s=new Set;for(const n of e){const r=n.indexOf("="),i=r===-1?n:n.slice(0,r),a=r===-1?"":n.slice(r+1);if(!Ve(i))throw new $(`--report "${n}": format must be one of ${oe.join(", ")}, as <format>=<path> (e.g. sarif=secrets.sarif)`);if(a==="")throw new $(`--report "${n}" needs a file path: ${i}=<path>`);if(s.has(a))throw new $(`--report writes ${a} twice; give each report its own file.`);s.add(a),t.push({format:i,path:a})}return t},Se=(e,t,s)=>{const n=()=>t.map(r=>j(r,s.root));switch(e){case"csv":return ls(n());case"github":return fs(n(),{staged:s.staged});case"gitlab-code-quality":return hs(n());case"json":return`${JSON.stringify(n(),null,2)}
18
+ `;case"junit":return us(n());case"sarif":return`${Is(t,s.toolVersion,s.root,s.ruleMetadata)}
19
+ `;default:return`${s.history?ws(t,s.useColor,{redact:s.redact}):vs(t,s.root,s.useColor,{redact:s.redact,virtualSource:s.virtualSource})}
20
+ `}},Fs=e=>e.kind==="secret"?"<secret-value entry>":e.raw,Rs=(e,t,s)=>{const n=`${String(e.length)} unused ${t} entr${e.length===1?"y":"ies"} (no finding matched; remove or update them):`,r=[s?C(n):n];for(const i of e){const a=` - line ${String(i.line)}: ${Fs(i)}`;r.push(s?I(a):a)}return r.join(`
21
+ `)},Cs=(e,t,s)=>{const n=`${String(e.length)} finding(s) suppressed:`,r=[s?C(n):n];for(const i of e){const a=j(i,t),c=i.suppressedByEntry===void 0?"":` line ${String(i.suppressedByEntry.line)}`,o=`${i.suppressedBy}${c}`,d=` - [${i.ruleId}] ${K({...a,commit:i.commit})} (${o})`;r.push(s?I(d):d)}return r.join(`
22
+ `)},Es=async(e,t)=>{try{return await e.access(t),!0}catch{return!1}},A=e=>e?Array.isArray(e)?e:[e]:[],Ts=e=>{if(e===void 0)return"text";if(!Ve(e))throw new $(`--format must be one of: ${oe.join(", ")} (got "${e}")`);return e},ke=(e,t,s)=>{if(e!==void 0){if(!Number.isInteger(e)||e<0||s!==void 0&&e>s){const n=s===void 0?"a non-negative integer":`an integer from 0 to ${String(s)}`;throw new $(`${t} must be ${n} (got ${String(e)}).`)}return e}},As=e=>{if(e!==void 0&&(!Number.isInteger(e)||e<1))throw new $(`--max-size must be a positive number of bytes (got ${String(e)}; default ${String(O)}).`);return e},js=e=>{if(e!==void 0){if(!le.includes(e))throw new $(`--min-confidence must be one of: ${le.join(", ")} (got "${e}")`);return e}},Ls=(e,t,s)=>{const n=t??{},r=m=>m?x(s,m):void 0,i=(m,k)=>{const P=A(m);return P.length>0?P:k},a=(n.config?.presets??[]).map(m=>`tag:preset:${m}`),c=i(e.enableRule,n.rules?.enable)??[],o=[...c,...a.filter(m=>!c.includes(m))],d=o.length>0?o:void 0,f=i(e.excludeRule,n.rules?.exclude),l=i(e.includeRule,n.rules?.include),b=i(e.exclude,n.walk?.excludePatterns),h=A(e.excludeFrom).map(m=>x(s,m)),u=n.walk?.excludeFromFiles?.map(m=>x(s,m)),p=r(e.baseline)??r(n.baseline),w=r(e.config)??r(n.config?.path),v=js(e.minConfidence??n.config?.minConfidence),g=A(e.secretlintignore).map(m=>x(s,m));let S,y=h.length>0?h:u;if(e.secretlintignore===!1)S=!1;else if(g.length>0&&n.secretlintIgnore===!1)S=!1,y=[...y??[],...g];else if(g.length>0){const m=Array.isArray(n.secretlintIgnore)?n.secretlintIgnore.map(k=>x(s,k)):[];S=[...new Set([...m,...g])]}else n.secretlintIgnore===!1?S=!1:S=n.secretlintIgnore?.map(m=>x(s,m));return{baseline:p,concurrency:e.concurrency,config:{extendBundled:e.extendBundled===!1?!1:n.config?.extendBundled,inline:n.config?.inline,minConfidence:v,onlyVerified:e.onlyVerified??n.config?.onlyVerified??!1,path:w,validate:e.validate??n.config?.validate??!1},inlineAllow:e.inlineAllow,maxArchiveDepth:ke(e.maxArchiveDepth,"--max-archive-depth",ot),maxDecodeDepth:ke(e.maxDecodeDepth,"--max-decode-depth"),overrides:n.overrides,overridesRoot:s,profile:e.profile===!0,redact:e.redact??n.redact??!0,reportSuppressed:e.logIgnored===!0,rules:{enable:d,exclude:f,include:l},secretlintIgnore:S,verbose:e.verbose??!1,walk:{excludeFromFiles:y,excludePatterns:b,gitignore:e.gitignore===!1?!1:n.walk?.gitignore??!0,includeHidden:e.includeHidden??n.walk?.includeHidden,maxFileSize:As(e.maxSize)??n.walk?.maxFileSize}}},q=e=>{if(e.stdin!==void 0){if(e.stdin===null||e.stdin==="")throw new $("--stdin needs a filename used for rule and path matching, e.g. `cat .env | vis secrets --stdin .env`.");return e.stdin}},He=e=>[q(e)===void 0?void 0:"--stdin",e.history?"--history":void 0,e.staged?"--staged":void 0,e.since===void 0?void 0:"--since",e.affected?"--affected":void 0].filter(t=>t!==void 0),Ie=(e,t)=>[e.listRules?"--list-rules":void 0,e.listValidators?"--list-validators":void 0,e.init?"--init":void 0,t&&e.updateBaseline?"--update-baseline":void 0].find(s=>s!==void 0),Ms=e=>{const t=He(e);if(t.length>1)throw new $(`${t.join(", ")} each pick what to scan and can't be combined. Use one of them.`);if(!e.history){const s=[e.all?"--all":void 0,e.historyRange===void 0?void 0:"--history-range",e.maxCommits===void 0?void 0:"--max-commits"].filter(n=>n!==void 0);if(s.length>0)throw new $(`${s.join(", ")} only applies to git history scans. Did you mean \`vis secrets --history ${s.join(" ")}\`?`);return}if(e.all&&e.historyRange!==void 0)throw new $("--all walks every ref and can't be combined with --history-range. Use one or the other.");if(e.updateBaseline)throw new $("--update-baseline records working-tree findings and can't be combined with --history.");if(e.maxCommits!==void 0&&(!Number.isInteger(e.maxCommits)||e.maxCommits<1))throw new $(`--max-commits must be a positive integer (got ${String(e.maxCommits)}); omit it to walk every commit.`)},Ns=e=>{const t=e.history?"--history":e.staged?"--staged":void 0;if(e.maxArchiveDepth!==void 0&&t!==void 0)throw new $(`--max-archive-depth only applies to working-tree scans; ${t} scans git blobs as text and doesn't open archives. Drop --max-archive-depth or ${t}.`)},Ge=(e,t)=>[q(e)===void 0?void 0:"--stdin",e.staged?"--staged":void 0,e.since===void 0?void 0:"--since",e.affected?"--affected":void 0,e.historyRange===void 0?void 0:"--history-range",e.maxCommits===void 0?void 0:"--max-commits",t?"explicit paths":void 0].filter(s=>s!==void 0),Ds=(e,t)=>{if(q(e)!==void 0){if(t)throw new $("--stdin scans piped content and can't be combined with explicit paths.");const c=[e.updateBaseline?"--update-baseline":void 0,e.replaceBaseline?"--replace-baseline":void 0,e.logIgnored?"--log-ignored":void 0,e.maxSize===void 0?void 0:"--max-size",e.maxArchiveDepth===void 0?void 0:"--max-archive-depth",e.failOnUnreadable?"--fail-on-unreadable":void 0].filter(o=>o!==void 0);if(c.length>0)throw new $(`${c.join(", ")} can't be combined with --stdin: a single piped buffer can't seed a baseline, and there are no files to size-check, skip, list or open as archives.`)}const s=Ie(e,!0),n=[A(e.report).length>0?"--report":void 0,e.logIgnored?"--log-ignored":void 0,e.profile?"--profile":void 0,e.failOnUnreadable?"--fail-on-unreadable":void 0,e.failOnUnusedIgnores?"--fail-on-unused-ignores":void 0].filter(c=>c!==void 0);if(s!==void 0&&n.length>0)throw new $(`${n.join(", ")} only applies to a scan report and can't be combined with ${s}.`);const r=Ie(e,!1),i=[...He(e),...t?["explicit paths"]:[]];if(r!==void 0&&i.length>0)throw new $(`${i.join(", ")} picks what to scan and can't be combined with ${r}.`);if(!e.failOnUnusedIgnores)return;if(e.gitleaksIgnore===!1)throw new $("--fail-on-unused-ignores checks .gitleaksignore, which --no-gitleaks-ignore turns off. Drop one of them.");const a=Ge(e,t);if(a.length>0)throw new $(`--fail-on-unused-ignores needs a full scan: with ${a.join(", ")}, entries for files outside the scan would be reported as unused. Run it on a full \`vis secrets\` or \`vis secrets --history\` scan.`)},Bs=e=>{if(e.dryRun&&!e.fix&&!e.init)throw new $("--dry-run needs --fix (to preview rewrites) or --init (to preview a baseline).")},_s=(e,t,s)=>{if(!e.fix)return;const n=e.format??"text",r=[e.redact===!0?"--redact":void 0,e.history?"--history":void 0,e.staged?"--staged":void 0,e.init?"--init":void 0,q(e)===void 0?void 0:"--stdin",e.profile?"--profile":void 0,e.listRules?"--list-rules":void 0,e.listValidators?"--list-validators":void 0,e.updateBaseline?"--update-baseline":void 0,e.replaceBaseline?"--replace-baseline":void 0,A(e.report).length>0?"--report":void 0,e.logIgnored?"--log-ignored":void 0,e.failOnUnreadable?"--fail-on-unreadable":void 0,e.failOnUnusedIgnores?"--fail-on-unused-ignores":void 0,e.validate||t.config?.validate?"--validate":void 0,n==="text"?void 0:`--format ${n}`].filter(i=>i!==void 0);if(r.length>0)throw new $(`${r.join(", ")} cannot be combined with --fix. Fix mode rewrites working-tree files in place and prints only a masked summary.`);if(s>1)throw new $("--fix accepts at most one path; run one scan per path so rewrite targets stay unambiguous.")},ae=".gitleaksignore",R=T.child({stdout:process.stderr}),Us=(e,t)=>{const{flags:s,root:n,useColor:r}=t;s.quiet||(e.skipped.length>0&&process.stderr.write(`${ys(e.skipped,e.skippedUnit,r,{verbose:s.verbose})}
23
23
  `),e.allowWarnings.length>0&&process.stderr.write(`${bs(e.allowWarnings,n,r)}
24
24
  `),t.fullScan&&e.unusedIgnores.length>0&&process.stderr.write(`${Rs(e.unusedIgnores,ae,r)}
25
25
  `)),s.logIgnored&&process.stderr.write(`${Cs(e.suppressed,n,r)}
26
- `)},Y=44,J=(e,t,s="start")=>{const n=e.replaceAll(/\s+/gu," ").trim();return n.length<=t?n.padEnd(t):s==="end"?`…${n.slice(n.length-t+1)}`:`${n.slice(0,t-1)}…`},Ie=(e,t,s,n="")=>` ${e} ${t.toFixed(1).padStart(7)} ms ×${String(s)}${n}`,Os=()=>({files:[],phases:[],rules:[],totalMs:0}),qs=(e,t=!1)=>{const s=i=>t?x(i):i,n=[`${s("profile:")} ${e.totalMs.toFixed(1)} ms total, ${String(e.files.length)} file(s)`],r=(i,a)=>{n.push(s(`${i}:`),...a.length>0?a:[" (none)"])};return r("phases",e.phases.slice(0,10).map(i=>Ie(J(i.name,Y),i.ms,i.count))),r("rules",e.rules.slice(0,10).map(i=>Ie(J(i.ruleId,Y),i.ms,i.count,` ${String(i.matches)} match(es)`))),r("files",e.files.slice(0,10).map(i=>` ${J(i.file,Y,"end")} ${i.ms.toFixed(1).padStart(7)} ms`)),n.join(`
26
+ `)},Y=44,J=(e,t,s="start")=>{const n=e.replaceAll(/\s+/gu," ").trim();return n.length<=t?n.padEnd(t):s==="end"?`…${n.slice(n.length-t+1)}`:`${n.slice(0,t-1)}…`},xe=(e,t,s,n="")=>` ${e} ${t.toFixed(1).padStart(7)} ms ×${String(s)}${n}`,Os=()=>({files:[],phases:[],rules:[],totalMs:0}),qs=(e,t=!1)=>{const s=i=>t?I(i):i,n=[`${s("profile:")} ${e.totalMs.toFixed(1)} ms total, ${String(e.files.length)} file(s)`],r=(i,a)=>{n.push(s(`${i}:`),...a.length>0?a:[" (none)"])};return r("phases",e.phases.slice(0,10).map(i=>xe(J(i.name,Y),i.ms,i.count))),r("rules",e.rules.slice(0,10).map(i=>xe(J(i.ruleId,Y),i.ms,i.count,` ${String(i.matches)} match(es)`))),r("files",e.files.slice(0,10).map(i=>` ${J(i.file,Y,"end")} ${i.ms.toFixed(1).padStart(7)} ms`)),n.join(`
27
27
  `)},Fe=(e,t)=>{e!==void 0&&process.stderr.write(`${qs(e,t)}
28
- `)},Ps=e=>{process.stderr.write(`${x("baseline diff: ")}${Ee(`+${String(e.fresh.length)} new`)} · ${C(`${String(e.surviving.length)} unchanged`)} · ${x(`-${String(e.resolved.length)} resolved`)}
29
- `)},zs=async(e,t)=>{const{flags:s,format:n,history:r,reports:i,root:a,scanOptions:c,toolbox:o,toolVersion:d,useColor:p}=t,l=c.redact,h=n==="sarif"||i.some(g=>g.format==="sarif")?await Te(c).catch(()=>[]):[],u={history:r,redact:l,root:a,ruleMetadata:h,staged:s.staged===!0,toolVersion:d},f=!l||r;process.stdout.write(Se(n,e.findings,{...u,useColor:p}));for(const g of i){const w=I(o.process.cwd,g.path);_e(w,Se(g.format,e.findings,{...u,useColor:!1}),f),s.quiet||R.info(`Wrote ${g.format} report to ${M(o.process.cwd,w)||w}`)}},Ws=(e,t)=>{if(t.failOnUnreadable){const s=e.skipped.filter(n=>n.reason!=="too-large"&&n.reason!=="binary").length;s>0&&(R.error(`${String(s)} ${e.skippedUnit}(s) could not be read; the scan is incomplete (--fail-on-unreadable).`),process.exitCode=1)}t.failOnUnusedIgnores&&e.unusedIgnores.length>0&&(R.error(`${String(e.unusedIgnores.length)} unused ${ae} entr${e.unusedIgnores.length===1?"y":"ies"} (--fail-on-unused-ignores).`),process.exitCode=1)},Vs=(e,t,s,n)=>{if(e.replacements===0&&e.skipped.length===0){n||process.stderr.write(t>0?`No secrets detected, but ${String(t)} file(s) were not scanned.
28
+ `)},Ps=e=>{process.stderr.write(`${I("baseline diff: ")}${Ee(`+${String(e.fresh.length)} new`)} · ${C(`${String(e.surviving.length)} unchanged`)} · ${I(`-${String(e.resolved.length)} resolved`)}
29
+ `)},zs=async(e,t)=>{const{flags:s,format:n,history:r,reports:i,root:a,scanOptions:c,stdin:o,toolbox:d,toolVersion:f,useColor:l}=t,b=c.redact,u=n==="sarif"||i.some(v=>v.format==="sarif")?await Te(c).catch(()=>[]):[],p={history:r,redact:b,root:a,ruleMetadata:u,staged:s.staged===!0,toolVersion:f,virtualSource:o},w=!b||r;process.stdout.write(Se(n,e.findings,{...p,useColor:l}));for(const v of i){const g=x(d.process.cwd,v.path);_e(g,Se(v.format,e.findings,{...p,useColor:!1}),w),s.quiet||R.info(`Wrote ${v.format} report to ${M(d.process.cwd,g)||g}`)}},Ws=(e,t)=>{if(t.failOnUnreadable){const s=e.skipped.filter(n=>n.reason!=="too-large"&&n.reason!=="binary").length;s>0&&(R.error(`${String(s)} ${e.skippedUnit}(s) could not be read; the scan is incomplete (--fail-on-unreadable).`),process.exitCode=1)}t.failOnUnusedIgnores&&e.unusedIgnores.length>0&&(R.error(`${String(e.unusedIgnores.length)} unused ${ae} entr${e.unusedIgnores.length===1?"y":"ies"} (--fail-on-unused-ignores).`),process.exitCode=1)},Vs=(e,t,s,n)=>{if(e.replacements===0&&e.skipped.length===0){n||process.stderr.write(t>0?`No secrets detected, but ${String(t)} file(s) were not scanned.
30
30
  `:`No secrets detected.
31
31
  `);return}for(const r of e.edits)process.stderr.write(`${r.file}:${String(r.line)} ${r.ruleId}: ${Xt} -> ${Pe}${s?" (dry-run)":""}
32
32
  `);for(const r of e.skipped)process.stderr.write(`Skipped ${r.file}:${String(r.line)} ${r.ruleId}: ${r.reason}
@@ -34,17 +34,17 @@ ${r}`):z("error",{col:s.startColumn,endColumn:s.endColumn,endLine:s.endLine,file
34
34
  `),t>0&&process.stderr.write(`${String(t)} file(s) were not scanned.
35
35
  `))},U=".secrets-baseline.json",Hs=async(e,t)=>{const s=await Te(e);process.stdout.write(`${String(s.length)} rules loaded
36
36
 
37
- `);for(const n of s){const r=t?C(n.id):n.id,i=n.tags.length>0?` ${t?x(`[${n.tags.join(", ")}]`):`[${n.tags.join(", ")}]`}`:"";if(process.stdout.write(`${r}${i}
37
+ `);for(const n of s){const r=t?C(n.id):n.id,i=n.tags.length>0?` ${t?I(`[${n.tags.join(", ")}]`):`[${n.tags.join(", ")}]`}`:"";if(process.stdout.write(`${r}${i}
38
38
  ${n.description}
39
- `),n.keywords.length>0){const a=`keywords: ${n.keywords.slice(0,6).join(", ")}${n.keywords.length>6?", ...":""}`;process.stdout.write(` ${t?x(a):a}
39
+ `),n.keywords.length>0){const a=`keywords: ${n.keywords.slice(0,6).join(", ")}${n.keywords.length>6?", ...":""}`;process.stdout.write(` ${t?I(a):a}
40
40
  `)}process.stdout.write(`
41
- `)}},Gs=async(e,t)=>{const s=await at(e);if(s.length===0){process.stdout.write(t?`${x("No non-HTTP validators required by the current ruleset.")}
41
+ `)}},Gs=async(e,t)=>{const s=await at(e);if(s.length===0){process.stdout.write(t?`${I("No non-HTTP validators required by the current ruleset.")}
42
42
  `:`No non-HTTP validators required by the current ruleset.
43
43
  `);return}process.stdout.write(`${String(s.length)} non-HTTP validator type(s) referenced by the current ruleset:
44
44
 
45
- `);for(const n of s){const r=t?C(n.displayName):n.displayName,i=`(${n.type}, ${String(n.ruleCount)} rule${n.ruleCount===1?"":"s"})`;process.stdout.write(`${r} ${t?x(i):i}
45
+ `);for(const n of s){const r=t?C(n.displayName):n.displayName,i=`(${n.type}, ${String(n.ruleCount)} rule${n.ruleCount===1?"":"s"})`;process.stdout.write(`${r} ${t?I(i):i}
46
46
  `),process.stdout.write(` ${n.summary}
47
- `);const a=n.packageName?`install: npm add ${n.packageName}`:"no driver — bespoke implementation required";process.stdout.write(` ${t?x(a):a}
47
+ `);const a=n.packageName?`install: npm add ${n.packageName}`:"no driver — bespoke implementation required";process.stdout.write(` ${t?I(a):a}
48
48
 
49
- `)}},Ks=async(e,t,s)=>{const n=V(e,U);if(!s&&te(n)){T.warn(`Detected existing ${U} — refusing to overwrite. Delete it first to re-init.`),process.exitCode=1;return}T.info(s?"[dry-run] Previewing init — no files will be written.":"Scanning workspace to seed baseline…");const r=Be();r.start("scanning");let i;try{i=await ct([e],t),r.succeed()}catch(c){throw r.failed(),c}if(s){T.info(`[dry-run] Would create ${U} with ${String(i.length)} finding(s).`);return}const a=qe(i,n,e,{replace:!0});T.success(`Wrote ${U} (${String(a)} findings).`),T.notice("Commit it. Use `vis secrets --baseline .secrets-baseline.json` in CI. Add path patterns to .gitignore to exclude directories from scanning.")},Re={files:{failure:"secret scan",spinner:"scanning for secrets"},history:{failure:"git-history secret scan",spinner:"scanning git history for secrets"},paths:{failure:"secret scan",spinner:"scanning for secrets"},staged:{failure:"secret scan",spinner:"scanning for secrets"},stdin:{failure:"piped-input secret scan",spinner:"scanning piped input"}},Ce=(e,t,s)=>{const n=I(s,e),r=M(t,n);return r===""||r===".."||r.startsWith("../")||E(r)?n:r},Ys=async()=>{const e=[];let t=0;for await(const s of process.stdin){if(t+=s.length,t>O)throw new $(`--stdin input exceeds ${String(O)} bytes, the largest file the scanner reads. Scan it as a file instead.`);e.push(s)}return Buffer.concat(e).toString("utf8")},Js=async(e,t,s,n,r)=>{const i=q(e);if(i!==void 0){if(r!==""){if(Buffer.byteLength(r)>O)throw new $(`--stdin input exceeds ${String(O)} bytes, the largest file the scanner reads. Scan it as a file instead.`);return{content:r,filename:Ce(i,s,n),kind:"stdin"}}if(process.stdin.isTTY)throw new $("--stdin expects piped input, but stdin is a terminal. Pipe content in, e.g. `cat .env | vis secrets --stdin .env`.");return{content:await Ys(),filename:Ce(i,s,n),kind:"stdin"}}const a=t.length>0?t.map(o=>I(s,o)):[s],c=e.history?"--history":e.staged?"--staged":e.since===void 0?void 0:"--since";if(c!==void 0&&!ye(s))throw new $(`${c} requires a git working tree, and none was detected.`);return e.history?{kind:"history"}:e.staged?{kind:"staged"}:e.since!==void 0?{files:ve(s,e.since),kind:"files"}:e.affected?ye(s)?{files:ve(s,process.env.VIS_BASE??"HEAD~1"),kind:"files"}:(R.warn("--affected requires git; falling back to full scan"),{kind:"paths",paths:a}):{kind:"paths",paths:a}},Xs=async(e,t,s,n)=>{if(e.kind==="stdin"){const{allowWarnings:c,findings:o}=lt(e.filename,s,n)?{allowWarnings:[],findings:[]}:await dt(e.content,e.filename,s);return{allowWarnings:c,findings:o,skipped:[],skippedUnit:"file",suppressed:[],unusedIgnores:[]}}if(e.kind==="history")return{...await ut({...s,all:t.all,cwd:n,maxCommits:t.maxCommits,range:t.historyRange}),skippedUnit:"blob"};if(e.kind==="paths")return{...await ht(e.paths,s),skippedUnit:"file"};const r=process.cwd(),i={...s,baseline:typeof s.baseline=="string"?Kt(s.baseline,n,r):s.baseline},a=e.kind==="staged"?await pt({...i,cwd:n}):await ft(e.files,{...i,ignoreRoot:n});return{allowWarnings:a.allowWarnings.map(c=>({...c,file:ne(c.file,r,n)})),findings:a.findings.map(c=>pe(c,r,n)),profile:a.profile&&Gt(a.profile,r,n),skipped:a.skipped,skippedUnit:e.kind==="staged"?"blob":"file",suppressed:a.suppressed.map(c=>pe(c,r,n)),unusedIgnores:a.unusedIgnores}},Zs=async e=>{const t=await mt(e);if(t.length>0){R.warn(`${String(t.length)} rule(s) skipped due to invalid regex. First few:`);for(const s of t.slice(0,5))process.stderr.write(` - ${s.ruleId}: ${s.reason}
50
- `)}},un=async e=>{const{argument:t,options:s,visConfig:n,workspaceRoot:r}=e,i=s,a=t??[],c=r??e.process.cwd,o=!i.quiet&&process.stdout.isTTY,d=n?.secrets,p=Ls(i,d,c),l="0.0.0-alpha";Ms(i),Ns(i),Ds(i,a.length>0),Bs(i),_s(i,p,a.length),i.fix&&(p.redact=!1);const b=Ts(i.format),h=Is(A(i.report)),u=V(c,ae);if(i.gitleaksIgnore!==!1&&await Es(e.fs,u)&&(p.gitleaksIgnore=u),i.listRules){await Hs(p,o);return}if(i.listValidators){await Gs(p,o);return}if(i.init){await Ks(c,p,i.dryRun??!1);return}const f=await Js(i,a,c,e.process.cwd,e.process.stdin),g=f.kind==="history";if(f.kind==="files"&&f.files.length===0){i.quiet||R.success("No files to scan."),i.profile&&Fe(Os(),o);return}const w=Be({verbose:!i.quiet&&b==="text"&&!i.fix});w.start(Re[f.kind].spinner);let v;try{v=await Xs(f,i,p,c),w.succeed()}catch(k){throw w.failed(),new $(`${Re[f.kind].failure} failed: ${k instanceof Error?k.message:String(k)}`,{cause:k})}if(i.fix){const k=rs(v.findings,c,i.dryRun===!0,f.kind==="paths"?f.paths[0]:c);Vs(k,v.skipped.length,i.dryRun===!0,i.quiet===!0),k.skipped.length>0&&(process.exitCode=1);return}const S={flags:i,format:b,fullScan:Ge(i,a.length>0).length===0,history:g,reports:h,root:c,scanOptions:p,toolbox:e,toolVersion:l,useColor:o};Us(v,S),Fe(v.profile,o),i.verbose&&await Zs(p);const{findings:y}=v,m=typeof p.baseline=="string"?p.baseline:V(c,U);if(i.updateBaseline){const k=qe(y,m,c,{replace:i.replaceBaseline});R.success(`Baseline updated: ${M(c,m)||m} now contains ${String(k)} entries.`);return}await zs(v,S),b==="text"&&!g&&!i.quiet&&te(m)&&Ps(Yt(y,m,c)),y.length>0?(i.quiet||(R.warn(`${String(y.length)} potential secret(s) found${g?" across git history":""}`),R.notice(g?"Findings reference the commit that introduced them — rotate the credential and rewrite history (e.g. git filter-repo) if it is still reachable.":"Suppress individual lines with `gitleaks:allow` / `secret-scanner:allow`, or run `vis secrets --update-baseline`.")),process.exitCode=1):i.quiet||R.success(g?"No secrets detected in git history.":"No secrets detected."),Ws(v,i)};export{un as default};
49
+ `)}},Ks=async(e,t,s)=>{const n=V(e,U);if(!s&&te(n)){T.warn(`Detected existing ${U} — refusing to overwrite. Delete it first to re-init.`),process.exitCode=1;return}T.info(s?"[dry-run] Previewing init — no files will be written.":"Scanning workspace to seed baseline…");const r=Be();r.start("scanning");let i;try{i=await ct([e],t),r.succeed()}catch(c){throw r.failed(),c}if(s){T.info(`[dry-run] Would create ${U} with ${String(i.length)} finding(s).`);return}const a=qe(i,n,e,{replace:!0});T.success(`Wrote ${U} (${String(a)} findings).`),T.notice("Commit it. Use `vis secrets --baseline .secrets-baseline.json` in CI. Add path patterns to .gitignore to exclude directories from scanning.")},Re={files:{failure:"secret scan",spinner:"scanning for secrets"},history:{failure:"git-history secret scan",spinner:"scanning git history for secrets"},paths:{failure:"secret scan",spinner:"scanning for secrets"},staged:{failure:"secret scan",spinner:"scanning for secrets"},stdin:{failure:"piped-input secret scan",spinner:"scanning piped input"}},Ce=(e,t,s)=>{const n=x(s,e),r=M(t,n);return r===""||r===".."||r.startsWith("../")||E(r)?n:r},Ys=async()=>{const e=[];let t=0;for await(const s of process.stdin){if(t+=s.length,t>O)throw new $(`--stdin input exceeds ${String(O)} bytes, the largest file the scanner reads. Scan it as a file instead.`);e.push(s)}return Buffer.concat(e).toString("utf8")},Js=async(e,t,s,n,r)=>{const i=q(e);if(i!==void 0){if(r!==""){if(Buffer.byteLength(r)>O)throw new $(`--stdin input exceeds ${String(O)} bytes, the largest file the scanner reads. Scan it as a file instead.`);return{content:r,filename:Ce(i,s,n),kind:"stdin"}}if(process.stdin.isTTY)throw new $("--stdin expects piped input, but stdin is a terminal. Pipe content in, e.g. `cat .env | vis secrets --stdin .env`.");return{content:await Ys(),filename:Ce(i,s,n),kind:"stdin"}}const a=t.length>0?t.map(o=>x(s,o)):[s],c=e.history?"--history":e.staged?"--staged":e.since===void 0?void 0:"--since";if(c!==void 0&&!ye(s))throw new $(`${c} requires a git working tree, and none was detected.`);return e.history?{kind:"history"}:e.staged?{kind:"staged"}:e.since!==void 0?{files:we(s,e.since),kind:"files"}:e.affected?ye(s)?{files:we(s,process.env.VIS_BASE??"HEAD~1"),kind:"files"}:(R.warn("--affected requires git; falling back to full scan"),{kind:"paths",paths:a}):{kind:"paths",paths:a}},Xs=async(e,t,s,n)=>{if(e.kind==="stdin"){const{allowWarnings:c,findings:o}=lt(e.filename,s,n)?{allowWarnings:[],findings:[]}:await dt(e.content,e.filename,s);return{allowWarnings:c,findings:o,skipped:[],skippedUnit:"file",suppressed:[],unusedIgnores:[]}}if(e.kind==="history")return{...await ut({...s,all:t.all,cwd:n,maxCommits:t.maxCommits,range:t.historyRange}),skippedUnit:"blob"};if(e.kind==="paths")return{...await ht(e.paths,s),skippedUnit:"file"};const r=process.cwd(),i={...s,baseline:typeof s.baseline=="string"?Kt(s.baseline,n,r):s.baseline},a=e.kind==="staged"?await pt({...i,cwd:n}):await ft(e.files,{...i,ignoreRoot:n});return{allowWarnings:a.allowWarnings.map(c=>({...c,file:ne(c.file,r,n)})),findings:a.findings.map(c=>pe(c,r,n)),profile:a.profile&&Gt(a.profile,r,n),skipped:a.skipped,skippedUnit:e.kind==="staged"?"blob":"file",suppressed:a.suppressed.map(c=>pe(c,r,n)),unusedIgnores:a.unusedIgnores}},Zs=async e=>{const t=await mt(e);if(t.length>0){R.warn(`${String(t.length)} rule(s) skipped due to invalid regex. First few:`);for(const s of t.slice(0,5))process.stderr.write(` - ${s.ruleId}: ${s.reason}
50
+ `)}},un=async e=>{const{argument:t,options:s,visConfig:n,workspaceRoot:r}=e,i=s,a=t??[],c=r??e.process.cwd,o=!i.quiet&&process.stdout.isTTY,d=n?.secrets,f=Ls(i,d,c),l="0.0.0-alpha";Ms(i),Ns(i),Ds(i,a.length>0),Bs(i),_s(i,f,a.length),i.fix&&(f.redact=!1);const b=Ts(i.format),h=xs(A(i.report)),u=V(c,ae);if(i.gitleaksIgnore!==!1&&await Es(e.fs,u)&&(f.gitleaksIgnore=u),i.listRules){await Hs(f,o);return}if(i.listValidators){await Gs(f,o);return}if(i.init){await Ks(c,f,i.dryRun??!1);return}const p=await Js(i,a,c,e.process.cwd,e.process.stdin),w=p.kind==="history";if(p.kind==="files"&&p.files.length===0){i.quiet||R.success("No files to scan."),i.profile&&Fe(Os(),o);return}const v=Be({verbose:!i.quiet&&b==="text"&&!i.fix});v.start(Re[p.kind].spinner);let g;try{g=await Xs(p,i,f,c),v.succeed()}catch(k){throw v.failed(),new $(`${Re[p.kind].failure} failed: ${k instanceof Error?k.message:String(k)}`,{cause:k})}if(i.fix){const k=rs(g.findings,c,i.dryRun===!0,p.kind==="paths"?p.paths[0]:c);Vs(k,g.skipped.length,i.dryRun===!0,i.quiet===!0),k.skipped.length>0&&(process.exitCode=1);return}const S={flags:i,format:b,fullScan:Ge(i,a.length>0).length===0,history:w,reports:h,root:c,scanOptions:f,stdin:p.kind==="stdin"?p.content:void 0,toolbox:e,toolVersion:l,useColor:o};Us(g,S),Fe(g.profile,o),i.verbose&&await Zs(f);const{findings:y}=g,m=typeof f.baseline=="string"?f.baseline:V(c,U);if(i.updateBaseline){const k=qe(y,m,c,{replace:i.replaceBaseline});R.success(`Baseline updated: ${M(c,m)||m} now contains ${String(k)} entries.`);return}await zs(g,S),b==="text"&&!w&&!i.quiet&&te(m)&&Ps(Yt(y,m,c)),y.length>0?(i.quiet||(R.warn(`${String(y.length)} potential secret(s) found${w?" across git history":""}`),R.notice(w?"Findings reference the commit that introduced them — rotate the credential and rewrite history (e.g. git filter-repo) if it is still reachable.":"Suppress individual lines with `gitleaks:allow` / `secret-scanner:allow`, or run `vis secrets --update-baseline`.")),process.exitCode=1):i.quiet||R.success(w?"No secrets detected in git history.":"No secrets detected."),Ws(g,i)};export{un as default};
@@ -1,4 +1,4 @@
1
- import{e as C,z as P,U as pe}from"../packem_shared/index-0dnGN3GP.js";import{M as ge,N as le,P as de,L as me,C as ye,R as ke,p as m,q as fe}from"./cli-main.js";import{i as ue}from"../packem_shared/index-BjdW45xX.js";import he from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import je from"module-replacements/manifests/native.json"with{type:"json"};import ve from"module-replacements/manifests/preferred.json"with{type:"json"};import{K as be,j as t,X as g,O as c,r as O,R as xe,h as Te,i as W}from"../packem_shared/registry-Dmy6zBD8.js";import{a as ee}from"../packem_shared/index--eV4qIz5.js";import{l as Ie}from"./ts-loader.js";import{y as V}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as D}from"../packem_shared/env-D0huQDyA.js";import{d as we,n as Me}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{p as re}from"../packem_shared/package-version-CtgyD_B1.js";import{l as Se}from"../packem_shared/glob-Cyk1H9ZL-DC9cczJJ.js";const Ce=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Ee=["overrides","pnpm","resolutions"],$e=["engines","files"],Oe=r=>{const e=ee.coerce(r)?.major;return e!==void 0&&e>=10},De=r=>{const e=C(r,"pnpm-workspace.yaml");if(!V(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:Ie(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},Pe=(r,e)=>{let s={};return e==="pnpm"?s=r.pnpm?.overrides??{}:e==="yarn"||e==="bun"?s=r.resolutions??{}:s=r.overrides??{},{overrides:s,source:"package.json"}},Ne=(r,e,s)=>s.name==="pnpm"&&Oe(s.version)?De(r):Pe(e,s.name),Y=(r,e)=>{const s=e;for(const o of Ee){const n=r.indexOf(o);if(n!==-1&&o!==s)return s==="overrides"?n:n+1}let i=-1;for(const o of Ce){const n=r.indexOf(o);n>i&&(i=n)}if(i!==-1)return i+1;for(const o of $e){const n=r.indexOf(o);if(n!==-1)return n}return r.length},Ae=(r,e)=>{const s=C(r,"pnpm-workspace.yaml");if(!V(s))throw new Error(`pnpm-workspace.yaml not found at ${s}. Cannot write overrides for pnpm v10+.`);let i=P(s);const n=`overrides:
1
+ import{e as C,z as P,U as pe}from"../packem_shared/index-0dnGN3GP.js";import{M as ge,N as le,P as de,L as me,C as ye,R as ke,p as m,q as fe}from"./cli-main.js";import{i as ue}from"../packem_shared/index-BjdW45xX.js";import he from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import je from"module-replacements/manifests/native.json"with{type:"json"};import ve from"module-replacements/manifests/preferred.json"with{type:"json"};import{K as be,j as t,X as g,O as c,r as O,R as xe,h as Te,i as W}from"../packem_shared/registry-C_cLtZJm.js";import{a as ee}from"../packem_shared/index--eV4qIz5.js";import{l as Ie}from"./ts-loader.js";import{y as V}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as D}from"../packem_shared/env-CBECVaqy.js";import{d as we,n as Me}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{p as re}from"../packem_shared/package-version-Bh9fCd7j.js";import{l as Se}from"../packem_shared/glob-Cyk1H9ZL-CwM-bcq9.js";const Ce=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Ee=["overrides","pnpm","resolutions"],$e=["engines","files"],Oe=r=>{const e=ee.coerce(r)?.major;return e!==void 0&&e>=10},De=r=>{const e=C(r,"pnpm-workspace.yaml");if(!V(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:Ie(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},Pe=(r,e)=>{let s={};return e==="pnpm"?s=r.pnpm?.overrides??{}:e==="yarn"||e==="bun"?s=r.resolutions??{}:s=r.overrides??{},{overrides:s,source:"package.json"}},Ne=(r,e,s)=>s.name==="pnpm"&&Oe(s.version)?De(r):Pe(e,s.name),Y=(r,e)=>{const s=e;for(const o of Ee){const n=r.indexOf(o);if(n!==-1&&o!==s)return s==="overrides"?n:n+1}let i=-1;for(const o of Ce){const n=r.indexOf(o);n>i&&(i=n)}if(i!==-1)return i+1;for(const o of $e){const n=r.indexOf(o);if(n!==-1)return n}return r.length},Ae=(r,e)=>{const s=C(r,"pnpm-workspace.yaml");if(!V(s))throw new Error(`pnpm-workspace.yaml not found at ${s}. Cannot write overrides for pnpm v10+.`);let i=P(s);const n=`overrides:
2
2
  ${Object.entries(e).map(([p,d])=>` '${p}': '${d}'`).join(`
3
3
  `)}
4
4
  `;i=/^overrides:\s*$/m.test(i)||/^overrides:\s*\n/m.test(i)?i.replace(/^overrides:\s*\n(?:(?:[ \t].*)?\n)*/m,n):`${i.trimEnd()}
@@ -1,4 +1,4 @@
1
- import{createRequire as Dt}from"node:module";import{X as xe,F as I,b as ke,q as ut,T as mt}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as V,z as $e,U as Ft}from"../packem_shared/index-0dnGN3GP.js";import{i as Me}from"../packem_shared/index-BjdW45xX.js";import{whichBin as zt}from"#native";import{b as Bt,a as Wt,e as Ht}from"../packem_shared/ai-analysis-DoXQg-wK.js";import{e as Gt,b as Kt,g as qt,s as Yt}from"../packem_shared/ai-cache-B9U5m9O9.js";import{l as Fe}from"./ts-loader.js";import{y as X}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as et,e as Jt,i as tt,f as Xt,k as Zt}from"../packem_shared/env-D0huQDyA.js";import{L as Qt,h as en,i as tn,K as nn,a as an,f as on,d as rn,b as sn}from"../packem_shared/registry-Dmy6zBD8.js";import{p as f,c as nt}from"./cli-main.js";import{d as cn,c as ln}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{a as T}from"../packem_shared/index--eV4qIz5.js";import{c as ht,s as ye,g as dn,p as pn,e as fn}from"../packem_shared/index-u2ABjmic.js";import{d as gn}from"../packem_shared/anolilab-text-CAM_E6uK.js";import{S as un,a as M,b as vt,d as be,s as mn,f as hn,g as vn,h as wn}from"../packem_shared/junit-audit-CuJShWCH.js";import{t as yn,b as bn,G as xn}from"../packem_shared/ecosystem-gate-ChG-zNz5.js";import{s as Sn}from"../packem_shared/scan-progress-B6BSwS4F.js";import{r as An,b as Nn,c as it,q as at,a as ot}from"../packem_shared/advisories-Wk-RI-Lt.js";import{p as yt}from"../packem_shared/package-version-CtgyD_B1.js";import{r as Cn,l as En,f as jn,a as Pn}from"../packem_shared/dependency-scan-DKp1Y0Sx.js";import{r as Rn}from"../packem_shared/manifests-C3TL659D.js";import{c as oe,h as On,i as In,l as Ln,m as Dn}from"../packem_shared/multi-eco-lockfiles-szCMAPHo.js";import{l as Tn,p as Mn,O as _n}from"../packem_shared/osv-bloom-DU6avR2k.js";import{f as Bn}from"../packem_shared/osv-BTClyx8h.js";let Tt;const Mt=e=>(Tt??=Dt(import.meta.url))(e),te=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Z=e=>{if(typeof te<"u"&&te.versions&&te.versions.node){const[t,n]=te.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return te.getBuiltinModule(e)}return Mt(e)},{spawnSync:_t}=Z("node:child_process"),{createInterface:Vt}=Z("node:readline"),{stripVTControlCharacters:Ut}=Z("node:util"),{createHash:kn}=Z("node:crypto"),{relative:wt,join:$n}=Z("node:path"),{readFileSync:Vn,writeFileSync:Fn,renameSync:zn,unlinkSync:Un}=Z("node:fs"),rt=(e,t={})=>{Array.isArray(t.extensions)||(t.extensions=["js","mjs","cjs","ts"]);const n=[];for(const i of Qt(e,t))n.push(i.path);return n},Se=e=>`${e.packageName}@${e.packageVersion}:${e.vulnerability.id}`,Wn=e=>e==null||e===!0||e===""||e==="true"||e.toString().toLowerCase()==="all",Hn=(e,t)=>{if(Wn(t))return e;const n=String(t).trim();if(/^\d+$/.test(n)){const a=Number.parseInt(n,10)-1,o=e[a];return o?[o]:[]}const i=n.toLowerCase();return e.filter(a=>{const{aliases:o,id:r}=a.vulnerability;return r.toLowerCase()===i||(o??[]).some(c=>c.toLowerCase()===i)})},Gn=e=>{const{packageName:t,packageVersion:n,vulnerability:i}=e,a=(i.aliases??[]).join(", ")||"none",o=(i.fixedVersions??[]).join(", ")||"no fixed version published";return`You are a security engineer. Explain this dependency vulnerability for a developer triaging it.
1
+ import{createRequire as Dt}from"node:module";import{X as xe,F as I,b as ke,q as ut,T as mt}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as V,z as $e,U as Ft}from"../packem_shared/index-0dnGN3GP.js";import{i as Me}from"../packem_shared/index-BjdW45xX.js";import{whichBin as zt}from"#native";import{b as Bt,a as Wt,e as Ht}from"../packem_shared/ai-analysis-D7yA6HDb.js";import{e as Gt,b as Kt,g as qt,s as Yt}from"../packem_shared/ai-cache-CIiLVd6H.js";import{l as Fe}from"./ts-loader.js";import{y as X}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as et,e as Jt,i as tt,f as Xt,k as Zt}from"../packem_shared/env-CBECVaqy.js";import{L as Qt,h as en,i as tn,K as nn,a as an,f as on,d as rn,b as sn}from"../packem_shared/registry-C_cLtZJm.js";import{p as f,c as nt}from"./cli-main.js";import{d as cn,c as ln}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{a as T}from"../packem_shared/index--eV4qIz5.js";import{c as ht,s as ye,g as dn,p as pn,e as fn}from"../packem_shared/index-Dylr7IyO.js";import{d as gn}from"../packem_shared/anolilab-text-CAM_E6uK.js";import{S as un,a as M,b as vt,d as be,s as mn,f as hn,g as vn,h as wn}from"../packem_shared/junit-audit-CuJShWCH.js";import{t as yn,b as bn,G as xn}from"../packem_shared/ecosystem-gate-CdpT8g5F.js";import{s as Sn}from"../packem_shared/scan-progress-D2GJbBjf.js";import{r as An,b as Nn,c as it,q as at,a as ot}from"../packem_shared/advisories-BbFUg8RU.js";import{p as yt}from"../packem_shared/package-version-Bh9fCd7j.js";import{r as Cn,l as En,f as jn,a as Pn}from"../packem_shared/dependency-scan-CVnUo47n.js";import{r as Rn}from"../packem_shared/manifests-C7kfBdVu.js";import{c as oe,h as On,i as In,l as Ln,m as Dn}from"../packem_shared/multi-eco-lockfiles-C3ibnSu7.js";import{l as Tn,p as Mn,O as _n}from"../packem_shared/osv-bloom-DU6avR2k.js";import{f as Bn}from"../packem_shared/osv-CLps2k15.js";let Tt;const Mt=e=>(Tt??=Dt(import.meta.url))(e),te=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Z=e=>{if(typeof te<"u"&&te.versions&&te.versions.node){const[t,n]=te.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return te.getBuiltinModule(e)}return Mt(e)},{spawnSync:_t}=Z("node:child_process"),{createInterface:Vt}=Z("node:readline"),{stripVTControlCharacters:Ut}=Z("node:util"),{createHash:kn}=Z("node:crypto"),{relative:wt,join:$n}=Z("node:path"),{readFileSync:Vn,writeFileSync:Fn,renameSync:zn,unlinkSync:Un}=Z("node:fs"),rt=(e,t={})=>{Array.isArray(t.extensions)||(t.extensions=["js","mjs","cjs","ts"]);const n=[];for(const i of Qt(e,t))n.push(i.path);return n},Se=e=>`${e.packageName}@${e.packageVersion}:${e.vulnerability.id}`,Wn=e=>e==null||e===!0||e===""||e==="true"||e.toString().toLowerCase()==="all",Hn=(e,t)=>{if(Wn(t))return e;const n=String(t).trim();if(/^\d+$/.test(n)){const a=Number.parseInt(n,10)-1,o=e[a];return o?[o]:[]}const i=n.toLowerCase();return e.filter(a=>{const{aliases:o,id:r}=a.vulnerability;return r.toLowerCase()===i||(o??[]).some(c=>c.toLowerCase()===i)})},Gn=e=>{const{packageName:t,packageVersion:n,vulnerability:i}=e,a=(i.aliases??[]).join(", ")||"none",o=(i.fixedVersions??[]).join(", ")||"no fixed version published";return`You are a security engineer. Explain this dependency vulnerability for a developer triaging it.
2
2
 
3
3
  Package: ${t}@${n}
4
4
  Advisory: ${i.id} (aliases: ${a})