just-bash 2.5.0 → 2.5.1

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 (36) hide show
  1. package/dist/bin/chunks/chunk-CTLU5QUH.js +17 -0
  2. package/dist/bin/chunks/{grep-WDHYDUUD.js → grep-QCXXYC54.js} +1 -1
  3. package/dist/bin/chunks/rg-GVIT6FTE.js +33 -0
  4. package/dist/bin/just-bash.js +1 -1
  5. package/dist/bin/shell/chunks/chunk-CTLU5QUH.js +17 -0
  6. package/dist/bin/shell/chunks/{grep-WDHYDUUD.js → grep-QCXXYC54.js} +1 -1
  7. package/dist/bin/shell/chunks/rg-GVIT6FTE.js +33 -0
  8. package/dist/bin/shell/shell.js +1 -1
  9. package/dist/bundle/browser.js +379 -375
  10. package/dist/bundle/chunks/chunk-OHJS5H37.js +16 -0
  11. package/dist/bundle/chunks/{grep-QVR5G7SC.js → grep-TUWLGQC2.js} +1 -1
  12. package/dist/bundle/chunks/rg-KTCMPGU6.js +32 -0
  13. package/dist/bundle/index.js +1 -1
  14. package/dist/commands/rg/file-types.d.ts +33 -7
  15. package/dist/commands/rg/gitignore.d.ts +32 -3
  16. package/dist/commands/rg/rg-options.d.ts +14 -0
  17. package/dist/commands/search-engine/index.d.ts +1 -1
  18. package/dist/commands/search-engine/regex.d.ts +10 -0
  19. package/dist/fs/in-memory-fs/in-memory-fs.d.ts +51 -0
  20. package/dist/fs/in-memory-fs/index.d.ts +1 -0
  21. package/dist/fs/init.d.ts +12 -0
  22. package/dist/fs/interface.d.ts +203 -0
  23. package/dist/fs/mountable-fs/index.d.ts +1 -0
  24. package/dist/fs/mountable-fs/mountable-fs.d.ts +108 -0
  25. package/dist/fs/overlay-fs/index.d.ts +1 -0
  26. package/dist/fs/overlay-fs/overlay-fs.d.ts +107 -0
  27. package/dist/fs/read-write-fs/index.d.ts +1 -0
  28. package/dist/fs/read-write-fs/read-write-fs.d.ts +47 -0
  29. package/dist/fs/utils.d.ts +17 -0
  30. package/package.json +2 -3
  31. package/dist/bin/chunks/chunk-X4WRNADE.js +0 -17
  32. package/dist/bin/chunks/rg-ALK3CYAN.js +0 -29
  33. package/dist/bin/shell/chunks/chunk-X4WRNADE.js +0 -17
  34. package/dist/bin/shell/chunks/rg-ALK3CYAN.js +0 -29
  35. package/dist/bundle/chunks/chunk-7VH6U2UX.js +0 -16
  36. package/dist/bundle/chunks/rg-43HLKW4V.js +0 -28
@@ -0,0 +1,16 @@
1
+ function D(u,e){return u.replace(/\$(&|\d+|<([^>]+)>)/g,(h,c,f)=>{if(c==="&")return e[0];if(f!==void 0)return e.groups?.[f]??"";let T=parseInt(c,10);return e[T]??""})}function F(u,e,h={}){let{invertMatch:c=!1,showLineNumbers:f=!1,countOnly:T=!1,countMatches:j=!1,filename:o="",onlyMatching:v=!1,beforeContext:A=0,afterContext:P=0,maxCount:w=0,contextSeparator:B="--",showColumn:S=!1,vimgrep:_=!1,showByteOffset:M=!1,replace:p=null,passthru:y=!1,multiline:N=!1}=h;if(N)return W(u,e,{invertMatch:c,showLineNumbers:f,countOnly:T,countMatches:j,filename:o,onlyMatching:v,beforeContext:A,afterContext:P,maxCount:w,contextSeparator:B,showColumn:S,showByteOffset:M,replace:p});let d=u.split(`
2
+ `),g=d.length,O=g>0&&d[g-1]===""?g-1:g;if(T||j){let l=0,a=(j||v)&&!c;for(let t=0;t<O;t++)if(e.lastIndex=0,a)for(let s=e.exec(d[t]);s!==null;s=e.exec(d[t]))l++,s[0].length===0&&e.lastIndex++;else e.test(d[t])!==c&&l++;return{output:`${o?`${o}:${l}`:String(l)}
3
+ `,matched:l>0,matchCount:l}}if(A===0&&P===0&&!y){let l=[],a=!1,n=0,t=0;for(let s=0;s<O&&!(w>0&&n>=w);s++){let L=d[s];if(e.lastIndex=0,e.test(L)!==c)if(a=!0,n++,v){e.lastIndex=0;for(let r=e.exec(L);r!==null;r=e.exec(L)){let b=p!==null?D(p,r):r[0],k=o?`${o}:`:"";M&&(k+=`${t+r.index}:`),f&&(k+=`${s+1}:`),S&&(k+=`${r.index+1}:`),l.push(k+b),r[0].length===0&&e.lastIndex++}}else if(_){e.lastIndex=0;for(let r=e.exec(L);r!==null;r=e.exec(L)){let b=o?`${o}:`:"";M&&(b+=`${t+r.index}:`),f&&(b+=`${s+1}:`),S&&(b+=`${r.index+1}:`),l.push(b+L),r[0].length===0&&e.lastIndex++}}else{e.lastIndex=0;let r=e.exec(L),b=r?r.index+1:1,k=L;p!==null&&(e.lastIndex=0,k=L.replace(e,(...I)=>{if(I[0].length===0)return"";let z=I,Z=I[I.length-1];return typeof Z=="object"&&Z!==null?(z.groups=Z,z.input=I[I.length-2],z.index=I[I.length-3]):(z.input=I[I.length-1],z.index=I[I.length-2]),D(p,z)}));let E=o?`${o}:`:"";M&&(E+=`${t+(r?r.index:0)}:`),f&&(E+=`${s+1}:`),S&&(E+=`${b}:`),l.push(E+k)}t+=L.length+1}return{output:l.length>0?`${l.join(`
4
+ `)}
5
+ `:"",matched:a,matchCount:n}}if(y){let l=[],a=!1,n=0;for(let t=0;t<O;t++){let s=d[t];e.lastIndex=0;let R=e.test(s)!==c;R&&(a=!0,n++);let r=R?":":"-",b=o?`${o}${r}`:"";f&&(b+=`${t+1}${r}`),l.push(b+s)}return{output:l.length>0?`${l.join(`
6
+ `)}
7
+ `:"",matched:a,matchCount:n}}let $=[],C=0,m=new Set,x=-1,i=[];for(let l=0;l<O&&!(w>0&&C>=w);l++)e.lastIndex=0,e.test(d[l])!==c&&(i.push(l),C++);for(let l of i){let a=Math.max(0,l-A);x>=0&&a>x+1&&$.push(B);for(let t=a;t<l;t++)if(!m.has(t)){m.add(t),x=t;let s=d[t];f&&(s=`${t+1}-${s}`),o&&(s=`${o}-${s}`),$.push(s)}if(!m.has(l)){m.add(l),x=l;let t=d[l];if(v){e.lastIndex=0;for(let s=e.exec(t);s!==null;s=e.exec(t)){let L=p!==null?p:s[0],R=o?`${o}:`:"";f&&(R+=`${l+1}:`),S&&(R+=`${s.index+1}:`),$.push(R+L),s[0].length===0&&e.lastIndex++}}else{let s=t;f&&(s=`${l+1}:${s}`),o&&(s=`${o}:${s}`),$.push(s)}}let n=Math.min(O-1,l+P);for(let t=l+1;t<=n;t++)if(!m.has(t)){m.add(t),x=t;let s=d[t];f&&(s=`${t+1}-${s}`),o&&(s=`${o}-${s}`),$.push(s)}}return{output:$.length>0?`${$.join(`
8
+ `)}
9
+ `:"",matched:C>0,matchCount:C}}function W(u,e,h){let{invertMatch:c,showLineNumbers:f,countOnly:T,countMatches:j,filename:o,onlyMatching:v,beforeContext:A,afterContext:P,maxCount:w,contextSeparator:B,showColumn:S,showByteOffset:_,replace:M}=h,p=u.split(`
10
+ `),y=p.length,N=y>0&&p[y-1]===""?y-1:y,d=[0];for(let i=0;i<u.length;i++)u[i]===`
11
+ `&&d.push(i+1);let g=i=>{let l=0;for(let a=0;a<d.length&&!(d[a]>i);a++)l=a;return l},O=i=>{let l=g(i);return i-d[l]+1},$=[];e.lastIndex=0;for(let i=e.exec(u);i!==null&&!(w>0&&$.length>=w);i=e.exec(u)){let l=g(i.index),a=g(i.index+Math.max(0,i[0].length-1));$.push({startLine:l,endLine:a,byteOffset:i.index,column:O(i.index),matchText:i[0]}),i[0].length===0&&e.lastIndex++}if(T||j){let i;if(j)i=c?0:$.length;else{let a=new Set;for(let n of $)for(let t=n.startLine;t<=n.endLine;t++)a.add(t);i=c?N-a.size:a.size}return{output:`${o?`${o}:${i}`:String(i)}
12
+ `,matched:i>0,matchCount:i}}if(c){let i=new Set;for(let a of $)for(let n=a.startLine;n<=a.endLine;n++)i.add(n);let l=[];for(let a=0;a<N;a++)if(!i.has(a)){let n=p[a];f&&(n=`${a+1}:${n}`),o&&(n=`${o}:${n}`),l.push(n)}return{output:l.length>0?`${l.join(`
13
+ `)}
14
+ `:"",matched:l.length>0,matchCount:l.length}}if($.length===0)return{output:"",matched:!1,matchCount:0};let C=new Set,m=-1,x=[];for(let i of $){let l=Math.max(0,i.startLine-A),a=Math.min(N-1,i.endLine+P);m>=0&&l>m+1&&x.push(B);for(let n=l;n<i.startLine;n++)if(!C.has(n)){C.add(n),m=n;let t=p[n];f&&(t=`${n+1}-${t}`),o&&(t=`${o}-${t}`),x.push(t)}if(v){let n=M!==null?M:i.matchText,t=o?`${o}:`:"";_&&(t+=`${i.byteOffset}:`),f&&(t+=`${i.startLine+1}:`),S&&(t+=`${i.column}:`),x.push(t+n);for(let s=i.startLine;s<=i.endLine;s++)C.add(s),m=s}else for(let n=i.startLine;n<=i.endLine&&n<N;n++)if(!C.has(n)){C.add(n),m=n;let t=p[n];M!==null&&n===i.startLine&&(e.lastIndex=0,t=t.replace(e,M));let s=o?`${o}:`:"";_&&n===i.startLine&&(s+=`${i.byteOffset}:`),f&&(s+=`${n+1}:`),S&&n===i.startLine&&(s+=`${i.column}:`),x.push(s+t)}for(let n=i.endLine+1;n<=a;n++)if(!C.has(n)){C.add(n),m=n;let t=p[n];f&&(t=`${n+1}-${t}`),o&&(t=`${o}-${t}`),x.push(t)}}return{output:x.length>0?`${x.join(`
15
+ `)}
16
+ `:"",matched:!0,matchCount:$.length}}function q(u,e){let h;switch(e.mode){case"fixed":h=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");break;case"extended":case"perl":h=u.replace(/\(\?P<([^>]+)>/g,"(?<$1>");break;default:h=H(u);break}e.wholeWord&&(h=`(?<![\\w])(?:${h})(?![\\w])`),e.lineRegexp&&(h=`^${h}$`);let c="g"+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.multilineDotall?"s":"");return new RegExp(h,c)}function G(u){let e=u.replace(/\$\{0\}|\$0(?![0-9])/g,"$$&");return e=e.replace(/\$\{([^0-9}][^}]*)\}/g,"$$<$1>"),e=e.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)(?![>0-9])/g,"$$<$1>"),e}function H(u){let e="",h=0;for(;h<u.length;){let c=u[h];if(c==="\\"&&h+1<u.length){let f=u[h+1];if(f==="|"||f==="("||f===")"){e+=f,h+=2;continue}else if(f==="{"||f==="}"){e+=`\\${f}`,h+=2;continue}}c==="+"||c==="?"||c==="|"||c==="("||c===")"||c==="{"||c==="}"?e+=`\\${c}`:e+=c,h++}return e}export{F as a,q as b,G as c};
@@ -1,4 +1,4 @@
1
- import{a as y}from"./chunk-UJMN5NLH.js";import{a as S,b as j}from"./chunk-7VH6U2UX.js";import{a as Z,b as _,c as L}from"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";var ee={name:"grep",summary:"print lines that match patterns",usage:"grep [OPTION]... PATTERN [FILE]...",options:["-E, --extended-regexp PATTERN is an extended regular expression","-P, --perl-regexp PATTERN is a Perl regular expression","-F, --fixed-strings PATTERN is a set of newline-separated strings","-i, --ignore-case ignore case distinctions","-v, --invert-match select non-matching lines","-w, --word-regexp match only whole words","-x, --line-regexp match only whole lines","-c, --count print only a count of matching lines","-l, --files-with-matches print only names of files with matches","-L, --files-without-match print names of files with no matches","-m NUM, --max-count=NUM stop after NUM matches","-n, --line-number print line number with output lines","-h, --no-filename suppress the file name prefix on output","-o, --only-matching show only nonempty parts of lines that match","-q, --quiet, --silent suppress all normal output","-r, -R, --recursive search directories recursively","-A NUM print NUM lines of trailing context","-B NUM print NUM lines of leading context","-C NUM print NUM lines of context","-e PATTERN use PATTERN for matching"," --include=GLOB search only files matching GLOB"," --exclude=GLOB skip files matching GLOB"," --exclude-dir=DIR skip directories matching DIR"," --help display this help and exit"]},z={name:"grep",async execute(t,s){if(_(t))return Z(ee);let o=!1,f=!1,c=!1,p=!1,m=!1,l=!1,i=!1,d=!1,w=!1,u=!1,h=!1,T=!1,x=!1,q=!1,B=!1,W=0,F=0,N=0,R=[],A=[],Q=[],$=null,I=[];for(let r=0;r<t.length;r++){let n=t[r];if(n.startsWith("-")&&n!=="-"){if(n==="-e"&&r+1<t.length){$=t[++r];continue}if(n.startsWith("--include=")){R.push(n.slice(10));continue}if(n.startsWith("--exclude=")){A.push(n.slice(10));continue}if(n.startsWith("--exclude-dir=")){Q.push(n.slice(14));continue}if(n.startsWith("--max-count=")){W=parseInt(n.slice(12),10);continue}let C=n.match(/^-m(\d+)$/);if(C){W=parseInt(C[1],10);continue}if(n==="-m"&&r+1<t.length){W=parseInt(t[++r],10);continue}let a=n.match(/^-([ABC])(\d+)$/);if(a){let e=parseInt(a[2],10);a[1]==="A"?N=e:a[1]==="B"?F=e:a[1]==="C"&&(F=e,N=e);continue}if((n==="-A"||n==="-B"||n==="-C")&&r+1<t.length){let e=parseInt(t[++r],10);n==="-A"?N=e:n==="-B"?F=e:(F=e,N=e);continue}let g=n.startsWith("--")?[n]:n.slice(1).split("");for(let e of g)if(e==="i"||e==="--ignore-case")o=!0;else if(e==="n"||e==="--line-number")f=!0;else if(e==="v"||e==="--invert-match")c=!0;else if(e==="c"||e==="--count")p=!0;else if(e==="l"||e==="--files-with-matches")m=!0;else if(e==="L"||e==="--files-without-match")l=!0;else if(e==="r"||e==="R"||e==="--recursive")i=!0;else if(e==="w"||e==="--word-regexp")d=!0;else if(e==="x"||e==="--line-regexp")w=!0;else if(e==="E"||e==="--extended-regexp")u=!0;else if(e==="P"||e==="--perl-regexp")h=!0;else if(e==="F"||e==="--fixed-strings")T=!0;else if(e==="o"||e==="--only-matching")x=!0;else if(e==="h"||e==="--no-filename")q=!0;else if(e==="q"||e==="--quiet"||e==="--silent")B=!0;else{if(e.startsWith("--"))return L("grep",e);if(e.length===1)return L("grep",`-${e}`)}}else $===null?$=n:I.push(n)}if($===null)return{stdout:"",stderr:`grep: missing pattern
1
+ import{a as y}from"./chunk-UJMN5NLH.js";import{a as S,b as j}from"./chunk-OHJS5H37.js";import{a as Z,b as _,c as L}from"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";var ee={name:"grep",summary:"print lines that match patterns",usage:"grep [OPTION]... PATTERN [FILE]...",options:["-E, --extended-regexp PATTERN is an extended regular expression","-P, --perl-regexp PATTERN is a Perl regular expression","-F, --fixed-strings PATTERN is a set of newline-separated strings","-i, --ignore-case ignore case distinctions","-v, --invert-match select non-matching lines","-w, --word-regexp match only whole words","-x, --line-regexp match only whole lines","-c, --count print only a count of matching lines","-l, --files-with-matches print only names of files with matches","-L, --files-without-match print names of files with no matches","-m NUM, --max-count=NUM stop after NUM matches","-n, --line-number print line number with output lines","-h, --no-filename suppress the file name prefix on output","-o, --only-matching show only nonempty parts of lines that match","-q, --quiet, --silent suppress all normal output","-r, -R, --recursive search directories recursively","-A NUM print NUM lines of trailing context","-B NUM print NUM lines of leading context","-C NUM print NUM lines of context","-e PATTERN use PATTERN for matching"," --include=GLOB search only files matching GLOB"," --exclude=GLOB skip files matching GLOB"," --exclude-dir=DIR skip directories matching DIR"," --help display this help and exit"]},z={name:"grep",async execute(t,s){if(_(t))return Z(ee);let o=!1,f=!1,c=!1,p=!1,m=!1,l=!1,i=!1,d=!1,w=!1,u=!1,h=!1,T=!1,x=!1,q=!1,B=!1,W=0,F=0,N=0,R=[],A=[],Q=[],$=null,I=[];for(let r=0;r<t.length;r++){let n=t[r];if(n.startsWith("-")&&n!=="-"){if(n==="-e"&&r+1<t.length){$=t[++r];continue}if(n.startsWith("--include=")){R.push(n.slice(10));continue}if(n.startsWith("--exclude=")){A.push(n.slice(10));continue}if(n.startsWith("--exclude-dir=")){Q.push(n.slice(14));continue}if(n.startsWith("--max-count=")){W=parseInt(n.slice(12),10);continue}let C=n.match(/^-m(\d+)$/);if(C){W=parseInt(C[1],10);continue}if(n==="-m"&&r+1<t.length){W=parseInt(t[++r],10);continue}let a=n.match(/^-([ABC])(\d+)$/);if(a){let e=parseInt(a[2],10);a[1]==="A"?N=e:a[1]==="B"?F=e:a[1]==="C"&&(F=e,N=e);continue}if((n==="-A"||n==="-B"||n==="-C")&&r+1<t.length){let e=parseInt(t[++r],10);n==="-A"?N=e:n==="-B"?F=e:(F=e,N=e);continue}let g=n.startsWith("--")?[n]:n.slice(1).split("");for(let e of g)if(e==="i"||e==="--ignore-case")o=!0;else if(e==="n"||e==="--line-number")f=!0;else if(e==="v"||e==="--invert-match")c=!0;else if(e==="c"||e==="--count")p=!0;else if(e==="l"||e==="--files-with-matches")m=!0;else if(e==="L"||e==="--files-without-match")l=!0;else if(e==="r"||e==="R"||e==="--recursive")i=!0;else if(e==="w"||e==="--word-regexp")d=!0;else if(e==="x"||e==="--line-regexp")w=!0;else if(e==="E"||e==="--extended-regexp")u=!0;else if(e==="P"||e==="--perl-regexp")h=!0;else if(e==="F"||e==="--fixed-strings")T=!0;else if(e==="o"||e==="--only-matching")x=!0;else if(e==="h"||e==="--no-filename")q=!0;else if(e==="q"||e==="--quiet"||e==="--silent")B=!0;else{if(e.startsWith("--"))return L("grep",e);if(e.length===1)return L("grep",`-${e}`)}}else $===null?$=n:I.push(n)}if($===null)return{stdout:"",stderr:`grep: missing pattern
2
2
  `,exitCode:2};let K=T?"fixed":u?"extended":h?"perl":"basic",U;try{U=j($,{mode:K,ignoreCase:o,wholeWord:d,lineRegexp:w})}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${$}
3
3
  `,exitCode:2}}if(I.length===0&&s.stdin){let r=S(s.stdin,U,{invertMatch:c,showLineNumbers:f,countOnly:p,filename:"",onlyMatching:x,beforeContext:F,afterContext:N,maxCount:W});return B?{stdout:"",stderr:"",exitCode:r.matched?0:1}:{stdout:r.output,stderr:"",exitCode:r.matched?0:1}}if(I.length===0)return{stdout:"",stderr:`grep: no input files
4
4
  `,exitCode:2};let v="",D="",G=!1,H=!1,P=[];for(let r of I)if(r.includes("*")||r.includes("?")||r.includes("[")){let n=await te(r,s);if(i)for(let C of n){let a=await O(C.path,s,R,A,Q,C.isFile);P.push(...a)}else P.push(...n)}else if(i){let n=await O(r,s,R,A,Q);P.push(...n)}else P.push({path:r});let V=(P.length>1||i)&&!q,k=50;for(let r=0;r<P.length;r+=k){let n=P.slice(r,r+k),C=await Promise.all(n.map(async a=>{let g=a.path,e=g.split("/").pop()||g;if(A.length>0&&!i&&A.some(M=>y(e,M,{stripQuotes:!0}))||R.length>0&&!i&&!R.some(M=>y(e,M,{stripQuotes:!0})))return null;try{let M=s.fs.resolvePath(s.cwd,g),b=!1;if(a.isFile===void 0?b=(await s.fs.stat(M)).isDirectory:b=!a.isFile,b)return i?null:{error:`grep: ${g}: Is a directory
@@ -0,0 +1,32 @@
1
+ import{a as E,b as R,c as A}from"./chunk-OHJS5H37.js";import{a as L,b as _,c as k}from"./chunk-74CEPOFO.js";import"./chunk-DXB73IDG.js";var z={js:{extensions:[".js",".mjs",".cjs",".jsx"],globs:[]},ts:{extensions:[".ts",".tsx",".mts",".cts"],globs:[]},html:{extensions:[".html",".htm",".xhtml"],globs:[]},css:{extensions:[".css",".scss",".sass",".less"],globs:[]},json:{extensions:[".json",".jsonc",".json5"],globs:[]},xml:{extensions:[".xml",".xsl",".xslt"],globs:[]},c:{extensions:[".c",".h"],globs:[]},cpp:{extensions:[".cpp",".cc",".cxx",".hpp",".hh",".hxx",".h"],globs:[]},rust:{extensions:[".rs"],globs:[]},go:{extensions:[".go"],globs:[]},zig:{extensions:[".zig"],globs:[]},java:{extensions:[".java"],globs:[]},kotlin:{extensions:[".kt",".kts"],globs:[]},scala:{extensions:[".scala",".sc"],globs:[]},clojure:{extensions:[".clj",".cljc",".cljs",".edn"],globs:[]},py:{extensions:[".py",".pyi",".pyw"],globs:[]},rb:{extensions:[".rb",".rake",".gemspec"],globs:["Rakefile","Gemfile"]},php:{extensions:[".php",".phtml",".php3",".php4",".php5"],globs:[]},perl:{extensions:[".pl",".pm",".pod",".t"],globs:[]},lua:{extensions:[".lua"],globs:[]},sh:{extensions:[".sh",".bash",".zsh",".fish"],globs:[".bashrc",".zshrc",".profile"]},bat:{extensions:[".bat",".cmd"],globs:[]},ps:{extensions:[".ps1",".psm1",".psd1"],globs:[]},yaml:{extensions:[".yaml",".yml"],globs:[]},toml:{extensions:[".toml"],globs:["Cargo.toml","pyproject.toml"]},ini:{extensions:[".ini",".cfg",".conf"],globs:[]},csv:{extensions:[".csv",".tsv"],globs:[]},md:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},markdown:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},rst:{extensions:[".rst"],globs:[]},txt:{extensions:[".txt",".text"],globs:[]},tex:{extensions:[".tex",".ltx",".sty",".cls"],globs:[]},sql:{extensions:[".sql"],globs:[]},graphql:{extensions:[".graphql",".gql"],globs:[]},proto:{extensions:[".proto"],globs:[]},make:{extensions:[".mk",".mak"],globs:["Makefile","GNUmakefile","makefile"]},docker:{extensions:[],globs:["Dockerfile","Dockerfile.*","*.dockerfile"]},tf:{extensions:[".tf",".tfvars"],globs:[]}},S=class{types;constructor(){this.types=new Map(Object.entries(z).map(([t,n])=>[t,{extensions:[...n.extensions],globs:[...n.globs]}]))}addType(t){let n=t.indexOf(":");if(n===-1)return;let s=t.slice(0,n),r=t.slice(n+1);if(r.startsWith("include:")){let l=r.slice(8),i=this.types.get(l);if(i){let a=this.types.get(s)||{extensions:[],globs:[]};a.extensions.push(...i.extensions),a.globs.push(...i.globs),this.types.set(s,a)}}else{let l=this.types.get(s)||{extensions:[],globs:[]};if(r.startsWith("*.")&&!r.slice(2).includes("*")){let i=r.slice(1);l.extensions.includes(i)||l.extensions.push(i)}else l.globs.includes(r)||l.globs.push(r);this.types.set(s,l)}}clearType(t){let n=this.types.get(t);n&&(n.extensions=[],n.globs=[])}getType(t){return this.types.get(t)}getAllTypes(){return this.types}matchesType(t,n){let s=t.toLowerCase();for(let r of n){if(r==="all"){if(this.matchesAnyType(t))return!0;continue}let l=this.types.get(r);if(l){for(let i of l.extensions)if(s.endsWith(i))return!0;for(let i of l.globs)if(i.includes("*")){let a=i.replace(/\./g,"\\.").replace(/\*/g,".*");if(new RegExp(`^${a}$`,"i").test(t))return!0}else if(s===i.toLowerCase())return!0}}return!1}matchesAnyType(t){let n=t.toLowerCase();for(let s of this.types.values()){for(let r of s.extensions)if(n.endsWith(r))return!0;for(let r of s.globs)if(r.includes("*")){let l=r.replace(/\./g,"\\.").replace(/\*/g,".*");if(new RegExp(`^${l}$`,"i").test(t))return!0}else if(n===r.toLowerCase())return!0}return!1}};function B(){let e=[];for(let[t,n]of Object.entries(z).sort()){let s=[];for(let r of n.extensions)s.push(`*${r}`);for(let r of n.globs)s.push(r);e.push(`${t}: ${s.join(", ")}`)}return`${e.join(`
2
+ `)}
3
+ `}function G(){return{ignoreCase:!1,caseSensitive:!1,smartCase:!0,fixedStrings:!1,wordRegexp:!1,lineRegexp:!1,invertMatch:!1,multiline:!1,multilineDotall:!1,patterns:[],patternFiles:[],count:!1,countMatches:!1,files:!1,filesWithMatches:!1,filesWithoutMatch:!1,stats:!1,onlyMatching:!1,maxCount:0,lineNumber:!0,noFilename:!1,withFilename:!1,nullSeparator:!1,byteOffset:!1,column:!1,vimgrep:!1,replace:null,afterContext:0,beforeContext:0,contextSeparator:"--",quiet:!1,heading:!1,passthru:!1,includeZero:!1,sort:"path",json:!1,globs:[],iglobs:[],globCaseInsensitive:!1,types:[],typesNot:[],typeAdd:[],typeClear:[],hidden:!1,noIgnore:!1,noIgnoreDot:!1,noIgnoreVcs:!1,ignoreFiles:[],maxDepth:1/0,maxFilesize:0,followSymlinks:!1,searchZip:!1,searchBinary:!1,preprocessor:null,preprocessorGlobs:[]}}function K(e){let t=e.match(/^(\d+)([KMG])?$/i);if(!t)return 0;let n=parseInt(t[1],10);switch((t[2]||"").toUpperCase()){case"K":return n*1024;case"M":return n*1024*1024;case"G":return n*1024*1024*1024;default:return n}}function X(e){return/^\d+[KMG]?$/i.test(e)?null:{stdout:"",stderr:`rg: invalid --max-filesize value: ${e}
4
+ `,exitCode:1}}function U(e){return null}var q=[{short:"g",long:"glob",target:"globs",multi:!0},{long:"iglob",target:"iglobs",multi:!0},{short:"t",long:"type",target:"types",multi:!0,validate:U},{short:"T",long:"type-not",target:"typesNot",multi:!0,validate:U},{long:"type-add",target:"typeAdd",multi:!0},{long:"type-clear",target:"typeClear",multi:!0},{short:"m",long:"max-count",target:"maxCount",parse:parseInt},{short:"e",long:"regexp",target:"patterns",multi:!0},{short:"f",long:"file",target:"patternFiles",multi:!0},{short:"r",long:"replace",target:"replace"},{short:"d",long:"max-depth",target:"maxDepth",parse:parseInt},{long:"max-filesize",target:"maxFilesize",parse:K,validate:X},{long:"context-separator",target:"contextSeparator"},{short:"j",long:"threads",target:"maxDepth",parse:()=>1/0},{long:"ignore-file",target:"ignoreFiles",multi:!0},{long:"pre",target:"preprocessor"},{long:"pre-glob",target:"preprocessorGlobs",multi:!0}],Q={i:e=>{e.ignoreCase=!0,e.caseSensitive=!1,e.smartCase=!1},"--ignore-case":e=>{e.ignoreCase=!0,e.caseSensitive=!1,e.smartCase=!1},s:e=>{e.caseSensitive=!0,e.ignoreCase=!1,e.smartCase=!1},"--case-sensitive":e=>{e.caseSensitive=!0,e.ignoreCase=!1,e.smartCase=!1},S:e=>{e.smartCase=!0,e.ignoreCase=!1,e.caseSensitive=!1},"--smart-case":e=>{e.smartCase=!0,e.ignoreCase=!1,e.caseSensitive=!1},F:e=>{e.fixedStrings=!0},"--fixed-strings":e=>{e.fixedStrings=!0},w:e=>{e.wordRegexp=!0},"--word-regexp":e=>{e.wordRegexp=!0},x:e=>{e.lineRegexp=!0},"--line-regexp":e=>{e.lineRegexp=!0},v:e=>{e.invertMatch=!0},"--invert-match":e=>{e.invertMatch=!0},U:e=>{e.multiline=!0},"--multiline":e=>{e.multiline=!0},"--multiline-dotall":e=>{e.multilineDotall=!0,e.multiline=!0},c:e=>{e.count=!0},"--count":e=>{e.count=!0},"--count-matches":e=>{e.countMatches=!0},l:e=>{e.filesWithMatches=!0},"--files":e=>{e.files=!0},"--files-with-matches":e=>{e.filesWithMatches=!0},"--files-without-match":e=>{e.filesWithoutMatch=!0},"--stats":e=>{e.stats=!0},o:e=>{e.onlyMatching=!0},"--only-matching":e=>{e.onlyMatching=!0},q:e=>{e.quiet=!0},"--quiet":e=>{e.quiet=!0},N:e=>{e.lineNumber=!1},"--no-line-number":e=>{e.lineNumber=!1},H:e=>{e.withFilename=!0},"--with-filename":e=>{e.withFilename=!0},I:e=>{e.noFilename=!0},"--no-filename":e=>{e.noFilename=!0},0:e=>{e.nullSeparator=!0},"--null":e=>{e.nullSeparator=!0},b:e=>{e.byteOffset=!0},"--byte-offset":e=>{e.byteOffset=!0},"--column":e=>{e.column=!0,e.lineNumber=!0},"--no-column":e=>{e.column=!1},"--vimgrep":e=>{e.vimgrep=!0,e.column=!0,e.lineNumber=!0},"--json":e=>{e.json=!0},"--hidden":e=>{e.hidden=!0},"--no-ignore":e=>{e.noIgnore=!0},"--no-ignore-dot":e=>{e.noIgnoreDot=!0},"--no-ignore-vcs":e=>{e.noIgnoreVcs=!0},L:e=>{e.followSymlinks=!0},"--follow":e=>{e.followSymlinks=!0},z:e=>{e.searchZip=!0},"--search-zip":e=>{e.searchZip=!0},a:e=>{e.searchBinary=!0},"--text":e=>{e.searchBinary=!0},"--heading":e=>{e.heading=!0},"--passthru":e=>{e.passthru=!0},"--include-zero":e=>{e.includeZero=!0},"--glob-case-insensitive":e=>{e.globCaseInsensitive=!0}},ee=new Set(["n","--line-number"]);function te(e){e.hidden?e.searchBinary=!0:e.noIgnore?e.hidden=!0:e.noIgnore=!0}function se(e,t,n){let s=e[t];for(let r of q){if(s.startsWith(`--${r.long}=`)){let l=s.slice(`--${r.long}=`.length),i=j(n,r,l);return i?{newIndex:t,error:i}:{newIndex:t}}if(r.short&&s.startsWith(`-${r.short}`)&&s.length>2){let l=s.slice(2),i=j(n,r,l);return i?{newIndex:t,error:i}:{newIndex:t}}if(r.short&&s===`-${r.short}`||s===`--${r.long}`){if(t+1>=e.length)return null;let l=e[t+1],i=j(n,r,l);return i?{newIndex:t+1,error:i}:{newIndex:t+1}}}return null}function ne(e){return q.find(t=>t.short===e)}function j(e,t,n){if(t.validate){let r=t.validate(n);if(r)return r}let s=t.parse?t.parse(n):n;t.multi?e[t.target].push(s):e[t.target]=s}function re(e,t){let n=e[t];if(n==="--sort"&&t+1<e.length){let s=e[t+1];if(s==="path"||s==="none")return{value:s,newIndex:t+1}}if(n.startsWith("--sort=")){let s=n.slice(7);if(s==="path"||s==="none")return{value:s,newIndex:t}}return null}function ie(e,t){let n=e[t],s=n.match(/^-([ABC])(\d+)$/);return s?{flag:s[1],value:parseInt(s[2],10),newIndex:t}:(n==="-A"||n==="-B"||n==="-C")&&t+1<e.length?{flag:n[1],value:parseInt(e[t+1],10),newIndex:t+1}:null}function le(e){let t=e.match(/^-m(\d+)$/);return t?parseInt(t[1],10):null}function V(e){let t=G(),n=null,s=[],r=-1,l=-1,i=-1,a=!1;for(let c=0;c<e.length;c++){let o=e[c];if(o.startsWith("-")&&o!=="-"){let h=ie(e,c);if(h){let{flag:f,value:w,newIndex:d}=h;f==="A"?r=Math.max(r,w):f==="B"?l=Math.max(l,w):i=w,c=d;continue}let m=le(o);if(m!==null){t.maxCount=m;continue}let y=se(e,c,t);if(y){if(y.error)return{success:!1,error:y.error};c=y.newIndex;continue}let p=re(e,c);if(p){t.sort=p.value,c=p.newIndex;continue}let b=o.startsWith("--")?[o]:o.slice(1).split(""),u=!1;for(let f of b){if(ee.has(f)){t.lineNumber=!0,a=!0;continue}if(f==="u"||f==="--unrestricted"){te(t);continue}if(f==="P"||f==="--pcre2")return{success:!1,error:{stdout:"",stderr:`rg: PCRE2 is not supported. Use standard regex syntax instead.
5
+ `,exitCode:1}};if(f.length===1){let d=ne(f);if(d){if(c+1>=e.length)return{success:!1,error:k("rg",`-${f}`)};let g=j(t,d,e[c+1]);if(g)return{success:!1,error:g};c++,u=!0;continue}}let w=Q[f];if(w){w(t);continue}if(f.startsWith("--"))return{success:!1,error:k("rg",f)};if(f.length===1)return{success:!1,error:k("rg",`-${f}`)}}}else n===null&&t.patterns.length===0&&t.patternFiles.length===0?n=o:s.push(o)}return(r>=0||i>=0)&&(t.afterContext=Math.max(r>=0?r:0,i>=0?i:0)),(l>=0||i>=0)&&(t.beforeContext=Math.max(l>=0?l:0,i>=0?i:0)),n!==null&&t.patterns.push(n),(t.column||t.vimgrep)&&(a=!0),{success:!0,options:t,paths:s,explicitLineNumbers:a}}import{gunzipSync as oe}from"node:zlib";var $=class{patterns=[];basePath;constructor(t="/"){this.basePath=t}parse(t){let n=t.split(`
6
+ `);for(let s of n){let r=s.replace(/\s+$/,"");if(!r||r.startsWith("#"))continue;let l=!1;r.startsWith("!")&&(l=!0,r=r.slice(1));let i=!1;r.endsWith("/")&&(i=!0,r=r.slice(0,-1));let a=!1;r.startsWith("/")?(a=!0,r=r.slice(1)):r.includes("/")&&!r.startsWith("**/")&&(a=!0);let c=this.patternToRegex(r,a);this.patterns.push({pattern:s,regex:c,negated:l,directoryOnly:i,rooted:a})}}patternToRegex(t,n){let s="";n?s="^":s="(?:^|/)";let r=0;for(;r<t.length;){let l=t[r];if(l==="*")t[r+1]==="*"?t[r+2]==="/"?(s+="(?:.*/)?",r+=3):(r+2>=t.length,s+=".*",r+=2):(s+="[^/]*",r++);else if(l==="?")s+="[^/]",r++;else if(l==="["){let i=r+1;for(i<t.length&&t[i]==="!"&&i++,i<t.length&&t[i]==="]"&&i++;i<t.length&&t[i]!=="]";)i++;if(i<t.length){let a=t.slice(r,i+1);a.startsWith("[!")&&(a=`[^${a.slice(2)}`),s+=a,r=i+1}else s+="\\[",r++}else l==="/"?(s+="/",r++):(s+=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r++)}return s+="(?:/.*)?$",new RegExp(s)}matches(t,n){let s=t.replace(/^\.\//,"");s=s.replace(/^\//,"");let r=!1;for(let l of this.patterns)l.directoryOnly&&!n||l.regex.test(s)&&(r=!l.negated);return r}isWhitelisted(t,n){let s=t.replace(/^\.\//,"");s=s.replace(/^\//,"");for(let r of this.patterns)if(!(r.directoryOnly&&!n)&&r.negated&&r.regex.test(s))return!0;return!1}getBasePath(){return this.basePath}},M=class{parsers=[];fs;skipDotIgnore;skipVcsIgnore;loadedDirs=new Set;constructor(t,n,s=!1,r=!1){this.fs=t,this.skipDotIgnore=s,this.skipVcsIgnore=r}async load(t){let n=[],s=t;for(;;){n.unshift(s);let l=this.fs.resolvePath(s,"..");if(l===s)break;s=l}let r=[];this.skipVcsIgnore||r.push(".gitignore"),this.skipDotIgnore||r.push(".rgignore",".ignore");for(let l of n){this.loadedDirs.add(l);for(let i of r){let a=this.fs.resolvePath(l,i);try{let c=await this.fs.readFile(a),o=new $(l);o.parse(c),this.parsers.push(o)}catch{}}}}async loadForDirectory(t){if(this.loadedDirs.has(t))return;this.loadedDirs.add(t);let n=[];this.skipVcsIgnore||n.push(".gitignore"),this.skipDotIgnore||n.push(".rgignore",".ignore");for(let s of n){let r=this.fs.resolvePath(t,s);try{let l=await this.fs.readFile(r),i=new $(t);i.parse(l),this.parsers.push(i)}catch{}}}addPatternsFromContent(t,n){let s=new $(n);s.parse(t),this.parsers.push(s)}matches(t,n){for(let s of this.parsers){let r=s.getBasePath();if(!t.startsWith(r))continue;let l=t.slice(r.length).replace(/^\//,"");if(s.matches(l,n))return!0}return!1}isWhitelisted(t,n){for(let s of this.parsers){let r=s.getBasePath();if(!t.startsWith(r))continue;let l=t.slice(r.length).replace(/^\//,"");if(s.isWhitelisted(l,n))return!0}return!1}static isCommonIgnored(t){return new Set(["node_modules",".git",".svn",".hg","__pycache__",".pytest_cache",".mypy_cache","venv",".venv",".next",".nuxt",".cargo"]).has(t)}};async function O(e,t,n=!1,s=!1,r=[]){let l=new M(e,t,n,s);await l.load(t);for(let i of r)try{let a=e.resolvePath(t,i),c=await e.readFile(a);l.addPatternsFromContent(c,t)}catch{}return l}function ae(e){return e.length>=2&&e[0]===31&&e[1]===139}function ce(e){let t=!1;for(let n=0;n<e.length;n++){let s=e[n];s==="["&&!t?t=!0:s==="]"&&t&&(t=!1)}return t?`rg: glob '${e}' has an unclosed character class`:null}async function Z(e){let{ctx:t,options:n,paths:s,explicitLineNumbers:r}=e;for(let u of n.globs){let f=u.startsWith("!")?u.slice(1):u,w=ce(f);if(w)return{stdout:"",stderr:`${w}
7
+ `,exitCode:1}}if(n.files){let u=[...n.patterns,...s];return he(t,u,n)}let l=[...n.patterns];for(let u of n.patternFiles)try{let f;if(u==="-")f=t.stdin;else{let d=t.fs.resolvePath(t.cwd,u);f=await t.fs.readFile(d)}let w=f.split(`
8
+ `).filter(d=>d.length>0);l.push(...w)}catch{return{stdout:"",stderr:`rg: ${u}: No such file or directory
9
+ `,exitCode:2}}if(l.length===0)return n.patternFiles.length>0?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`rg: no pattern given
10
+ `,exitCode:2};let i=s.length===0?["."]:s,a=fe(n,l),c;try{c=ue(l,n,a)}catch{return{stdout:"",stderr:`rg: invalid regex: ${l.join(", ")}
11
+ `,exitCode:2}}let o=null;n.noIgnore||(o=await O(t.fs,t.cwd,n.noIgnoreDot,n.noIgnoreVcs,n.ignoreFiles));let h=new S;for(let u of n.typeClear)h.clearType(u);for(let u of n.typeAdd)h.addType(u);let{files:m,singleExplicitFile:y}=await H(t,i,n,o,h);if(m.length===0)return{stdout:"",stderr:"",exitCode:1};let p=!n.noFilename&&(n.withFilename||!y||m.length>1),b=n.lineNumber;return r||(y&&m.length===1&&(b=!1),n.onlyMatching&&(b=!1)),pe(t,m,c,n,p,b)}function fe(e,t){return e.caseSensitive?!1:e.ignoreCase?!0:e.smartCase?!t.some(n=>/[A-Z]/.test(n)):!1}function ue(e,t,n){let s;return e.length===1?s=e[0]:s=e.map(r=>t.fixedStrings?r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):`(?:${r})`).join("|"),R(s,{mode:t.fixedStrings&&e.length===1?"fixed":"perl",ignoreCase:n,wholeWord:t.wordRegexp,lineRegexp:t.lineRegexp,multiline:t.multiline,multilineDotall:t.multilineDotall})}async function H(e,t,n,s,r){let l=[],i=0,a=0;for(let o of t){let h=e.fs.resolvePath(e.cwd,o);try{let m=await e.fs.stat(h);if(m.isFile){if(i++,n.maxFilesize>0&&m.size>n.maxFilesize)continue;Y(o,n,s,h,r)&&l.push(o)}else m.isDirectory&&(a++,await J(e,o,h,0,n,s,r,l))}catch{}}return{files:n.sort==="path"?l.sort():l,singleExplicitFile:i===1&&a===0}}async function J(e,t,n,s,r,l,i,a){if(!(s>=r.maxDepth)){l&&await l.loadForDirectory(n);try{let c=e.fs.readdirWithFileTypes?await e.fs.readdirWithFileTypes(n):(await e.fs.readdir(n)).map(o=>({name:o,isFile:void 0}));for(let o of c){let h=o.name;if(!r.noIgnore&&M.isCommonIgnored(h))continue;let m=h.startsWith("."),y=t==="."?h:t==="./"?`./${h}`:t.endsWith("/")?`${t}${h}`:`${t}/${h}`,p=e.fs.resolvePath(n,h),b,u,f=!1;if(o.isFile!==void 0&&"isDirectory"in o){let g=o;if(f=g.isSymbolicLink===!0,f&&!r.followSymlinks)continue;if(f&&r.followSymlinks)try{let x=await e.fs.stat(p);b=x.isFile,u=x.isDirectory}catch{continue}else b=g.isFile,u=g.isDirectory}else try{let g=e.fs.lstat?await e.fs.lstat(p):await e.fs.stat(p);if(f=g.isSymbolicLink===!0,f&&!r.followSymlinks)continue;let x=f&&r.followSymlinks?await e.fs.stat(p):g;b=x.isFile,u=x.isDirectory}catch{continue}if(!l?.matches(p,u)&&!(m&&!r.hidden&&!l?.isWhitelisted(p,u))){if(u)await J(e,y,p,s+1,r,l,i,a);else if(b){if(r.maxFilesize>0)try{if((await e.fs.stat(p)).size>r.maxFilesize)continue}catch{continue}Y(y,r,l,p,i)&&a.push(y)}}}}catch{}}}function Y(e,t,n,s,r){let l=e.split("/").pop()||e;if(n?.matches(s,!1)||t.types.length>0&&!r.matchesType(l,t.types)||t.typesNot.length>0&&r.matchesType(l,t.typesNot))return!1;if(t.globs.length>0){let i=t.globCaseInsensitive,a=t.globs.filter(o=>!o.startsWith("!")),c=t.globs.filter(o=>o.startsWith("!")).map(o=>o.slice(1));if(a.length>0){let o=!1;for(let h of a)if(v(l,h,i)||v(e,h,i)){o=!0;break}if(!o)return!1}for(let o of c)if(o.startsWith("/")){let h=o.slice(1);if(v(e,h,i))return!1}else if(v(l,o,i)||v(e,o,i))return!1}if(t.iglobs.length>0){let i=t.iglobs.filter(c=>!c.startsWith("!")),a=t.iglobs.filter(c=>c.startsWith("!")).map(c=>c.slice(1));if(i.length>0){let c=!1;for(let o of i)if(v(l,o,!0)||v(e,o,!0)){c=!0;break}if(!c)return!1}for(let c of a)if(c.startsWith("/")){let o=c.slice(1);if(v(e,o,!0))return!1}else if(v(l,c,!0)||v(e,c,!0))return!1}return!0}function v(e,t,n=!1){let s="^";for(let r=0;r<t.length;r++){let l=t[r];if(l==="*")t[r+1]==="*"?(s+=".*",r++):s+="[^/]*";else if(l==="?")s+="[^/]";else if(l==="["){let i=r+1;for(i<t.length&&t[i]==="!"&&i++,i<t.length&&t[i]==="]"&&i++;i<t.length&&t[i]!=="]";)i++;if(i<t.length){let a=t.slice(r,i+1);a.startsWith("[!")&&(a=`[^${a.slice(2)}`),s+=a,r=i}else s+="\\["}else s+=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}return s+="$",new RegExp(s,n?"i":"").test(e)}async function he(e,t,n){let s=null;n.noIgnore||(s=await O(e.fs,e.cwd,n.noIgnoreDot,n.noIgnoreVcs,n.ignoreFiles));let r=new S;for(let o of n.typeClear)r.clearType(o);for(let o of n.typeAdd)r.addType(o);let l=t.length===0?["."]:t,{files:i}=await H(e,l,n,s,r);if(i.length===0)return{stdout:"",stderr:"",exitCode:1};if(n.quiet)return{stdout:"",stderr:"",exitCode:0};let a=n.nullSeparator?"\0":`
12
+ `;return{stdout:i.map(o=>o+a).join(""),stderr:"",exitCode:0}}function ge(e,t){if(t.length===0)return!0;for(let n of t)if(v(e,n,!1))return!0;return!1}async function de(e,t,n,s){try{if(s.preprocessor&&e.exec){let i=n.split("/").pop()||n;if(ge(i,s.preprocessorGlobs)){let a=await e.exec(`${s.preprocessor} "${t}"`,{cwd:e.cwd});if(a.exitCode===0&&a.stdout){let c=a.stdout.slice(0,8192);return{content:a.stdout,isBinary:c.includes("\0")}}}}if(s.searchZip&&n.endsWith(".gz")){let i=await e.fs.readFileBuffer(t);if(ae(i))try{let a=oe(i),c=new TextDecoder().decode(a),o=c.slice(0,8192);return{content:c,isBinary:o.includes("\0")}}catch{return null}}let r=await e.fs.readFile(t),l=r.slice(0,8192);return{content:r,isBinary:l.includes("\0")}}catch{return null}}async function pe(e,t,n,s,r,l){let i="",a=!1,c=[],o=0,h=0,m=0,y=50;e:for(let u=0;u<t.length;u+=y){let f=t.slice(u,u+y),w=await Promise.all(f.map(async d=>{let g=e.fs.resolvePath(e.cwd,d),x=await de(e,g,d,s);if(!x)return null;let{content:C,isBinary:T}=x;if(m+=C.length,T&&!s.searchBinary)return null;let W=r&&!s.heading?d:"",I=E(C,n,{invertMatch:s.invertMatch,showLineNumbers:l,countOnly:s.count,countMatches:s.countMatches,filename:W,onlyMatching:s.onlyMatching,beforeContext:s.beforeContext,afterContext:s.afterContext,maxCount:s.maxCount,contextSeparator:s.contextSeparator,showColumn:s.column,vimgrep:s.vimgrep,showByteOffset:s.byteOffset,replace:s.replace!==null?A(s.replace):null,passthru:s.passthru,multiline:s.multiline});return s.json&&I.matched?{file:d,result:I,content:C,isBinary:!1}:{file:d,result:I}}));for(let d of w){if(!d)continue;let{file:g,result:x}=d;if(x.matched){if(a=!0,h++,o+=x.matchCount,s.quiet&&!s.json)break e;if(s.json&&!s.quiet){let C=d.content||"";c.push(JSON.stringify({type:"begin",data:{path:{text:g}}}));let T=C.split(`
13
+ `);n.lastIndex=0;let W=0;for(let I=0;I<T.length;I++){let N=T[I];n.lastIndex=0;let D=[];for(let F=n.exec(N);F!==null;F=n.exec(N)){let P={match:{text:F[0]},start:F.index,end:F.index+F[0].length};s.replace!==null&&(P.replacement={text:s.replace}),D.push(P),F[0].length===0&&n.lastIndex++}if(D.length>0){let F={type:"match",data:{path:{text:g},lines:{text:`${N}
14
+ `},line_number:I+1,absolute_offset:W,submatches:D}};c.push(JSON.stringify(F))}W+=N.length+1}c.push(JSON.stringify({type:"end",data:{path:{text:g},binary_offset:null,stats:{elapsed:{secs:0,nanos:0,human:"0s"},searches:1,searches_with_match:1,bytes_searched:C.length,bytes_printed:0,matched_lines:x.matchCount,matches:x.matchCount}}}))}else if(s.filesWithMatches){let C=s.nullSeparator?"\0":`
15
+ `;i+=`${g}${C}`}else s.filesWithoutMatch||(s.heading&&!s.noFilename&&(i+=`${g}
16
+ `),i+=x.output)}else if(s.filesWithoutMatch){let C=s.nullSeparator?"\0":`
17
+ `;i+=`${g}${C}`}else s.includeZero&&(s.count||s.countMatches)&&(i+=x.output)}}s.json&&(c.push(JSON.stringify({type:"summary",data:{elapsed_total:{secs:0,nanos:0,human:"0s"},stats:{elapsed:{secs:0,nanos:0,human:"0s"},searches:t.length,searches_with_match:h,bytes_searched:m,bytes_printed:0,matched_lines:o,matches:o}}})),i=`${c.join(`
18
+ `)}
19
+ `);let p=s.quiet&&!s.json?"":i;if(s.stats&&!s.json){let u=["",`${o} matches`,`${o} matched lines`,`${h} files contained matches`,`${t.length} files searched`,`${m} bytes searched`].join(`
20
+ `);p+=`${u}
21
+ `}let b;return s.filesWithoutMatch?b=i.length>0?0:1:b=a?0:1,{stdout:p,stderr:"",exitCode:b}}var me={name:"rg",summary:"recursively search for a pattern",usage:"rg [OPTIONS] PATTERN [PATH ...]",description:`rg (ripgrep) recursively searches directories for a regex pattern.
22
+ Unlike grep, rg is recursive by default and respects .gitignore files.
23
+
24
+ EXAMPLES:
25
+ rg foo Search for 'foo' in current directory
26
+ rg foo src/ Search in src/ directory
27
+ rg -i foo Case-insensitive search
28
+ rg -w foo Match whole words only
29
+ rg -t js foo Search only JavaScript files
30
+ rg -g '*.ts' foo Search files matching glob
31
+ rg --hidden foo Include hidden files
32
+ rg -l foo List files with matches only`,options:["-e, --regexp PATTERN search for PATTERN (can be used multiple times)","-f, --file FILE read patterns from FILE, one per line","-i, --ignore-case case-insensitive search","-s, --case-sensitive case-sensitive search (overrides smart-case)","-S, --smart-case smart case (default: case-insensitive unless pattern has uppercase)","-F, --fixed-strings treat pattern as literal string","-w, --word-regexp match whole words only","-x, --line-regexp match whole lines only","-v, --invert-match select non-matching lines","-r, --replace TEXT replace matches with TEXT","-c, --count print count of matching lines per file"," --count-matches print count of individual matches per file","-l, --files-with-matches print only file names with matches"," --files-without-match print file names without matches"," --files list files that would be searched","-o, --only-matching print only matching parts","-m, --max-count NUM stop after NUM matches per file","-q, --quiet suppress output, exit 0 on match"," --stats print search statistics","-n, --line-number print line numbers (default: on)","-N, --no-line-number do not print line numbers","-I, --no-filename suppress the prefixing of file names","-0, --null use NUL as filename separator","-b, --byte-offset show byte offset of each match"," --column show column number of first match"," --vimgrep show results in vimgrep format"," --json show results in JSON Lines format","-A NUM print NUM lines after each match","-B NUM print NUM lines before each match","-C NUM print NUM lines before and after each match"," --context-separator SEP separator for context groups (default: --)","-U, --multiline match patterns across lines","-z, --search-zip search in compressed files (gzip only)","-g, --glob GLOB include files matching GLOB","-t, --type TYPE only search files of TYPE (e.g., js, py, ts)","-T, --type-not TYPE exclude files of TYPE","-L, --follow follow symbolic links","-u, --unrestricted reduce filtering (-u: no ignore, -uu: +hidden, -uuu: +binary)","-a, --text search binary files as text"," --hidden search hidden files and directories"," --no-ignore don't respect .gitignore/.ignore files","-d, --max-depth NUM maximum search depth"," --sort TYPE sort files (path, none)"," --heading show file path above matches"," --passthru print all lines (non-matches use - separator)"," --include-zero include files with 0 matches in count output"," --type-list list all available file types"," --help display this help and exit"]},je={name:"rg",async execute(e,t){if(_(e))return L(me);if(e.includes("--type-list"))return{stdout:B(),stderr:"",exitCode:0};let n=V(e);return n.success?Z({ctx:t,options:n.options,paths:n.paths,explicitLineNumbers:n.explicitLineNumbers}):n.error}};export{je as rgCommand};
@@ -1,4 +1,4 @@
1
- import{a as U,b as Y,c as G,d as te,e as J,f as R,g as W,h as Ee,i as B,j as ue,k as qe}from"./chunks/chunk-CG2HXOFG.js";import"./chunks/chunk-NUFRM6SI.js";import{a as le}from"./chunks/chunk-44UOCSGV.js";import"./chunks/chunk-DXB73IDG.js";var ge=[{name:"echo",load:async()=>(await import("./chunks/echo-VUHWYV6L.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-MV4K6AUA.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-VG2POOXB.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-5W3NU5OJ.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-7UKY4B3B.js")).mkdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-MVQSKQKT.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-I2SRVF7H.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-PBJT3GBF.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-FXHEKRTB.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-Y7YB677N.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-FBHLEIY6.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-AC4P3JKI.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-EM4O3U4P.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-FZ6IQHYW.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-PD4RZR6J.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-DFQKWSIZ.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-IVQBBOKN.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-QVR5G7SC.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-QVR5G7SC.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-QVR5G7SC.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-43HLKW4V.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-ZKODWZ6F.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-46RTIZKB.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-EJUT5LXD.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-47QVBRNC.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-AXQM7FFF.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-NVKWEAZF.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-QTGVEPH5.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-EDGW5FG6.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-FKUV5GH5.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-KWQGFZH5.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-6CFXIPYZ.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-VSTNOVF5.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-I7A2VXFD.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-LRU5XCFP.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-YBTFW7MT.js")).split},{name:"column",load:async()=>(await import("./chunks/column-XPDNNO5Y.js")).column},{name:"join",load:async()=>(await import("./chunks/join-X3QYPZUA.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-2QU4NRSJ.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-ACOAWALE.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-CFA5ZIGT.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-YPJLCQYA.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-MEM64BW3.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-NQXEC3EF.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-EG5SQSAQ.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-EG5SQSAQ.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-4UGRF4DM.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-4UGRF4DM.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-MQDK2OPD.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-4FRA6OJ7.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-CNJ54NE6.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-CNJ54NE6.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-VT2LJIDX.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-ZILV3VHA.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-ZILV3VHA.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-3YU5HRKE.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-3BME25ON.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-ZLJYSBRK.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-PN3CMG7K.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-AK4QE4WR.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-X3X3N6IE.js")).timeoutCommand},{name:"seq",load:async()=>(await import("./chunks/seq-5VRIVQYP.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-DG4E7SIS.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-KLHZSRUA.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-WKWTIZGQ.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-IUVNMBTA.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-AWZ3TUFP.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-ZK6GQVSL.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-75YOGKM4.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-M5MQ6QXQ.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-2X4JLF4W.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-NWR32CGF.js")).hostname},{name:"od",load:async()=>(await import("./chunks/od-ECWXNUB4.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-L3NDJG3F.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-L3NDJG3F.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-L3NDJG3F.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(ge.push({name:"tar",load:async()=>(await import("./chunks/tar-QWBXMF7K.js")).tarCommand}),ge.push({name:"yq",load:async()=>(await import("./chunks/yq-KANM4MD2.js")).yqCommand}),ge.push({name:"xan",load:async()=>(await import("./chunks/xan-2R2APJJ4.js")).xanCommand}),ge.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-5QVZOGER.js")).sqlite3Command}));var Ar=[{name:"curl",load:async()=>(await import("./chunks/curl-TVZH24MD.js")).curlCommand}],gr=new Map;function Sr(t){return{name:t.name,async execute(e,n){let r=gr.get(t.name);return r||(r=await t.load(),gr.set(t.name,r)),r.execute(e,n)}}}function jn(){return ge.map(t=>t.name)}function qn(){return Ar.map(t=>t.name)}function xr(t){return(t?ge.filter(n=>t.includes(n.name)):ge).map(Sr)}function br(){return Ar.map(Sr)}function Cr(t){return"load"in t&&typeof t.load=="function"}function Zn(t,e){return{name:t,execute:e}}function Nr(t){let e=null;return{name:t.name,async execute(n,r){return e||(e=await t.load()),e.execute(n,r)}}}var Qn=new TextEncoder,Kn=new TextDecoder;function re(t,e){if(t instanceof Uint8Array)return t;if(e==="base64")return Uint8Array.from(atob(t),n=>n.charCodeAt(0));if(e==="hex"){let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=parseInt(t.slice(r,r+2),16);return n}return e==="binary"||e==="latin1"?Uint8Array.from(t,n=>n.charCodeAt(0)):Qn.encode(t)}function Ce(t,e){return e==="base64"?btoa(String.fromCharCode(...t)):e==="hex"?Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join(""):e==="binary"||e==="latin1"?String.fromCharCode(...t):Kn.decode(t)}function q(t){if(t!=null)return typeof t=="string"?t:t.encoding??void 0}var Ze=new TextEncoder;function Xn(t){return typeof t=="object"&&t!==null&&!(t instanceof Uint8Array)&&"content"in t}var ne=class{data=new Map;constructor(e){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[n,r]of Object.entries(e))Xn(r)?this.writeFileSync(n,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(n,r)}normalizePath(e){if(!e||e==="/")return"/";let n=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;n.startsWith("/")||(n=`/${n}`);let r=n.split("/").filter(i=>i&&i!=="."),s=[];for(let i of r)i===".."?s.pop():s.push(i);return`/${s.join("/")}`||"/"}dirname(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.lastIndexOf("/");return r===0?"/":n.slice(0,r)}ensureParentDirs(e){let n=this.dirname(e);n!=="/"&&(this.data.has(n)||(this.ensureParentDirs(n),this.data.set(n,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,n,r,s){let i=this.normalizePath(e);this.ensureParentDirs(i);let o=q(r),a=re(n,o);this.data.set(i,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}async readFile(e,n){let r=await this.readFileBuffer(e),s=q(n);return Ce(r,s)}async readFileBuffer(e){let n=this.resolvePathWithSymlinks(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return r.content instanceof Uint8Array?r.content:Ze.encode(r.content)}async writeFile(e,n,r){this.writeFileSync(e,n,r)}async appendFile(e,n,r){let s=this.normalizePath(e),i=this.data.get(s);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${e}'`);let o=q(r),a=re(n,o);if(i?.type==="file"){let c=i.content instanceof Uint8Array?i.content:Ze.encode(i.content),l=new Uint8Array(c.length+a.length);l.set(c),l.set(a,c.length),this.data.set(s,{type:"file",content:l,mode:i.mode,mtime:new Date})}else this.writeFileSync(e,n,r)}async exists(e){try{let n=this.resolvePathWithSymlinks(e);return this.data.has(n)}catch{return!1}}async stat(e){let n=this.resolvePathWithSymlinks(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Ze.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}async lstat(e){let n=this.resolveIntermediateSymlinks(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Ze.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}resolveSymlink(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=this.dirname(e);return this.normalizePath(r==="/"?`/${n}`:`${r}/${n}`)}resolveIntermediateSymlinks(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.slice(1).split("/");if(r.length<=1)return n;let s="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];s=`${s}/${a}`;let c=this.data.get(s),l=0,u=40;for(;c&&c.type==="symlink"&&l<u;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`);i.add(s),s=this.resolveSymlink(s,c.target),c=this.data.get(s),l++}if(l>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`)}return`${s}/${r[r.length-1]}`}resolvePathWithSymlinks(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.slice(1).split("/"),s="",i=new Set;for(let o of r){s=`${s}/${o}`;let a=this.data.get(s),c=0,l=40;for(;a&&a.type==="symlink"&&c<l;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);i.add(s),s=this.resolveSymlink(s,a.target),a=this.data.get(s),c++}if(c>=l)throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`)}return s}async mkdir(e,n){this.mkdirSync(e,n)}mkdirSync(e,n){let r=this.normalizePath(e);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=this.dirname(r);if(s!=="/"&&!this.data.has(s))if(n?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(e){return(await this.readdirWithFileTypes(e)).map(r=>r.name)}async readdirWithFileTypes(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);let s=new Set;for(;r&&r.type==="symlink";){if(s.has(n))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${e}'`);s.add(n),n=this.resolveSymlink(n,r.target),r=this.data.get(n)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);let i=n==="/"?"/":`${n}/`,o=new Map;for(let[a,c]of this.data.entries())if(a!==n&&a.startsWith(i)){let l=a.slice(i.length),u=l.split("/")[0];u&&!l.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:c.type==="file",isDirectory:c.type==="directory",isSymbolicLink:c.type==="symlink"})}return Array.from(o.values()).sort((a,c)=>a.name<c.name?-1:a.name>c.name?1:0)}async rm(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}if(s.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let o of i){let a=r==="/"?`/${o}`:`${r}/${o}`;await this.rm(a,n)}}}this.data.delete(r)}async cp(e,n,r){let s=this.normalizePath(e),i=this.normalizePath(n),o=this.data.get(s);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${e}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(s);for(let c of a){let l=s==="/"?`/${c}`:`${s}/${c}`,u=i==="/"?`/${c}`:`${i}/${c}`;await this.cp(l,u,r)}}}async mv(e,n){await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=e==="/"?`/${n}`:`${e}/${n}`;return this.normalizePath(r)}async chmod(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);s.mode=n}async symlink(e,n){let r=this.normalizePath(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,n){let r=this.normalizePath(e),s=this.normalizePath(n),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${n}'`);this.ensureParentDirs(s),this.data.set(s,{type:"file",content:i.content,mode:i.mode,mtime:i.mtime})}async readlink(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}};var Pr="5.1.0(1)-release",vr="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT";function We(){return{pid:process.pid,ppid:process.ppid,uid:process.getuid?.()??1e3,gid:process.getgid?.()??1e3}}function $r(){let{pid:t,ppid:e,uid:n,gid:r}=We();return`Name: bash
1
+ import{a as U,b as Y,c as G,d as te,e as J,f as R,g as W,h as Ee,i as B,j as ue,k as qe}from"./chunks/chunk-CG2HXOFG.js";import"./chunks/chunk-NUFRM6SI.js";import{a as le}from"./chunks/chunk-44UOCSGV.js";import"./chunks/chunk-DXB73IDG.js";var ge=[{name:"echo",load:async()=>(await import("./chunks/echo-VUHWYV6L.js")).echoCommand},{name:"cat",load:async()=>(await import("./chunks/cat-MV4K6AUA.js")).catCommand},{name:"printf",load:async()=>(await import("./chunks/printf-VG2POOXB.js")).printfCommand},{name:"ls",load:async()=>(await import("./chunks/ls-5W3NU5OJ.js")).lsCommand},{name:"mkdir",load:async()=>(await import("./chunks/mkdir-7UKY4B3B.js")).mkdirCommand},{name:"touch",load:async()=>(await import("./chunks/touch-MVQSKQKT.js")).touchCommand},{name:"rm",load:async()=>(await import("./chunks/rm-I2SRVF7H.js")).rmCommand},{name:"cp",load:async()=>(await import("./chunks/cp-PBJT3GBF.js")).cpCommand},{name:"mv",load:async()=>(await import("./chunks/mv-FXHEKRTB.js")).mvCommand},{name:"ln",load:async()=>(await import("./chunks/ln-Y7YB677N.js")).lnCommand},{name:"chmod",load:async()=>(await import("./chunks/chmod-FBHLEIY6.js")).chmodCommand},{name:"pwd",load:async()=>(await import("./chunks/pwd-AC4P3JKI.js")).pwdCommand},{name:"readlink",load:async()=>(await import("./chunks/readlink-EM4O3U4P.js")).readlinkCommand},{name:"head",load:async()=>(await import("./chunks/head-FZ6IQHYW.js")).headCommand},{name:"tail",load:async()=>(await import("./chunks/tail-PD4RZR6J.js")).tailCommand},{name:"wc",load:async()=>(await import("./chunks/wc-DFQKWSIZ.js")).wcCommand},{name:"stat",load:async()=>(await import("./chunks/stat-IVQBBOKN.js")).statCommand},{name:"grep",load:async()=>(await import("./chunks/grep-TUWLGQC2.js")).grepCommand},{name:"fgrep",load:async()=>(await import("./chunks/grep-TUWLGQC2.js")).fgrepCommand},{name:"egrep",load:async()=>(await import("./chunks/grep-TUWLGQC2.js")).egrepCommand},{name:"rg",load:async()=>(await import("./chunks/rg-KTCMPGU6.js")).rgCommand},{name:"sed",load:async()=>(await import("./chunks/sed-ZKODWZ6F.js")).sedCommand},{name:"awk",load:async()=>(await import("./chunks/awk2-46RTIZKB.js")).awkCommand2},{name:"sort",load:async()=>(await import("./chunks/sort-EJUT5LXD.js")).sortCommand},{name:"uniq",load:async()=>(await import("./chunks/uniq-47QVBRNC.js")).uniqCommand},{name:"comm",load:async()=>(await import("./chunks/comm-AXQM7FFF.js")).commCommand},{name:"cut",load:async()=>(await import("./chunks/cut-NVKWEAZF.js")).cutCommand},{name:"paste",load:async()=>(await import("./chunks/paste-QTGVEPH5.js")).pasteCommand},{name:"tr",load:async()=>(await import("./chunks/tr-EDGW5FG6.js")).trCommand},{name:"rev",load:async()=>(await import("./chunks/rev-FKUV5GH5.js")).rev},{name:"nl",load:async()=>(await import("./chunks/nl-KWQGFZH5.js")).nl},{name:"fold",load:async()=>(await import("./chunks/fold-6CFXIPYZ.js")).fold},{name:"expand",load:async()=>(await import("./chunks/expand-VSTNOVF5.js")).expand},{name:"unexpand",load:async()=>(await import("./chunks/unexpand-I7A2VXFD.js")).unexpand},{name:"strings",load:async()=>(await import("./chunks/strings-LRU5XCFP.js")).strings},{name:"split",load:async()=>(await import("./chunks/split-YBTFW7MT.js")).split},{name:"column",load:async()=>(await import("./chunks/column-XPDNNO5Y.js")).column},{name:"join",load:async()=>(await import("./chunks/join-X3QYPZUA.js")).join},{name:"tee",load:async()=>(await import("./chunks/tee-2QU4NRSJ.js")).teeCommand},{name:"find",load:async()=>(await import("./chunks/find-ACOAWALE.js")).findCommand},{name:"basename",load:async()=>(await import("./chunks/basename-CFA5ZIGT.js")).basenameCommand},{name:"dirname",load:async()=>(await import("./chunks/dirname-YPJLCQYA.js")).dirnameCommand},{name:"tree",load:async()=>(await import("./chunks/tree-MEM64BW3.js")).treeCommand},{name:"du",load:async()=>(await import("./chunks/du-NQXEC3EF.js")).duCommand},{name:"env",load:async()=>(await import("./chunks/env-EG5SQSAQ.js")).envCommand},{name:"printenv",load:async()=>(await import("./chunks/env-EG5SQSAQ.js")).printenvCommand},{name:"alias",load:async()=>(await import("./chunks/alias-4UGRF4DM.js")).aliasCommand},{name:"unalias",load:async()=>(await import("./chunks/alias-4UGRF4DM.js")).unaliasCommand},{name:"history",load:async()=>(await import("./chunks/history-MQDK2OPD.js")).historyCommand},{name:"xargs",load:async()=>(await import("./chunks/xargs-4FRA6OJ7.js")).xargsCommand},{name:"true",load:async()=>(await import("./chunks/true-CNJ54NE6.js")).trueCommand},{name:"false",load:async()=>(await import("./chunks/true-CNJ54NE6.js")).falseCommand},{name:"clear",load:async()=>(await import("./chunks/clear-VT2LJIDX.js")).clearCommand},{name:"bash",load:async()=>(await import("./chunks/bash-ZILV3VHA.js")).bashCommand},{name:"sh",load:async()=>(await import("./chunks/bash-ZILV3VHA.js")).shCommand},{name:"jq",load:async()=>(await import("./chunks/jq-3YU5HRKE.js")).jqCommand},{name:"base64",load:async()=>(await import("./chunks/base64-3BME25ON.js")).base64Command},{name:"diff",load:async()=>(await import("./chunks/diff-ZLJYSBRK.js")).diffCommand},{name:"date",load:async()=>(await import("./chunks/date-PN3CMG7K.js")).dateCommand},{name:"sleep",load:async()=>(await import("./chunks/sleep-AK4QE4WR.js")).sleepCommand},{name:"timeout",load:async()=>(await import("./chunks/timeout-X3X3N6IE.js")).timeoutCommand},{name:"seq",load:async()=>(await import("./chunks/seq-5VRIVQYP.js")).seqCommand},{name:"expr",load:async()=>(await import("./chunks/expr-DG4E7SIS.js")).exprCommand},{name:"md5sum",load:async()=>(await import("./chunks/md5sum-KLHZSRUA.js")).md5sumCommand},{name:"sha1sum",load:async()=>(await import("./chunks/sha1sum-WKWTIZGQ.js")).sha1sumCommand},{name:"sha256sum",load:async()=>(await import("./chunks/sha256sum-IUVNMBTA.js")).sha256sumCommand},{name:"file",load:async()=>(await import("./chunks/file-AWZ3TUFP.js")).fileCommand},{name:"html-to-markdown",load:async()=>(await import("./chunks/html-to-markdown-ZK6GQVSL.js")).htmlToMarkdownCommand},{name:"help",load:async()=>(await import("./chunks/help-75YOGKM4.js")).helpCommand},{name:"which",load:async()=>(await import("./chunks/which-M5MQ6QXQ.js")).whichCommand},{name:"tac",load:async()=>(await import("./chunks/tac-2X4JLF4W.js")).tac},{name:"hostname",load:async()=>(await import("./chunks/hostname-NWR32CGF.js")).hostname},{name:"od",load:async()=>(await import("./chunks/od-ECWXNUB4.js")).od},{name:"gzip",load:async()=>(await import("./chunks/gzip-L3NDJG3F.js")).gzipCommand},{name:"gunzip",load:async()=>(await import("./chunks/gzip-L3NDJG3F.js")).gunzipCommand},{name:"zcat",load:async()=>(await import("./chunks/gzip-L3NDJG3F.js")).zcatCommand}];(typeof __BROWSER__>"u"||!__BROWSER__)&&(ge.push({name:"tar",load:async()=>(await import("./chunks/tar-QWBXMF7K.js")).tarCommand}),ge.push({name:"yq",load:async()=>(await import("./chunks/yq-KANM4MD2.js")).yqCommand}),ge.push({name:"xan",load:async()=>(await import("./chunks/xan-2R2APJJ4.js")).xanCommand}),ge.push({name:"sqlite3",load:async()=>(await import("./chunks/sqlite3-5QVZOGER.js")).sqlite3Command}));var Ar=[{name:"curl",load:async()=>(await import("./chunks/curl-TVZH24MD.js")).curlCommand}],gr=new Map;function Sr(t){return{name:t.name,async execute(e,n){let r=gr.get(t.name);return r||(r=await t.load(),gr.set(t.name,r)),r.execute(e,n)}}}function jn(){return ge.map(t=>t.name)}function qn(){return Ar.map(t=>t.name)}function xr(t){return(t?ge.filter(n=>t.includes(n.name)):ge).map(Sr)}function br(){return Ar.map(Sr)}function Cr(t){return"load"in t&&typeof t.load=="function"}function Zn(t,e){return{name:t,execute:e}}function Nr(t){let e=null;return{name:t.name,async execute(n,r){return e||(e=await t.load()),e.execute(n,r)}}}var Qn=new TextEncoder,Kn=new TextDecoder;function re(t,e){if(t instanceof Uint8Array)return t;if(e==="base64")return Uint8Array.from(atob(t),n=>n.charCodeAt(0));if(e==="hex"){let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=parseInt(t.slice(r,r+2),16);return n}return e==="binary"||e==="latin1"?Uint8Array.from(t,n=>n.charCodeAt(0)):Qn.encode(t)}function Ce(t,e){return e==="base64"?btoa(String.fromCharCode(...t)):e==="hex"?Array.from(t).map(n=>n.toString(16).padStart(2,"0")).join(""):e==="binary"||e==="latin1"?String.fromCharCode(...t):Kn.decode(t)}function q(t){if(t!=null)return typeof t=="string"?t:t.encoding??void 0}var Ze=new TextEncoder;function Xn(t){return typeof t=="object"&&t!==null&&!(t instanceof Uint8Array)&&"content"in t}var ne=class{data=new Map;constructor(e){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[n,r]of Object.entries(e))Xn(r)?this.writeFileSync(n,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(n,r)}normalizePath(e){if(!e||e==="/")return"/";let n=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;n.startsWith("/")||(n=`/${n}`);let r=n.split("/").filter(i=>i&&i!=="."),s=[];for(let i of r)i===".."?s.pop():s.push(i);return`/${s.join("/")}`||"/"}dirname(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.lastIndexOf("/");return r===0?"/":n.slice(0,r)}ensureParentDirs(e){let n=this.dirname(e);n!=="/"&&(this.data.has(n)||(this.ensureParentDirs(n),this.data.set(n,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,n,r,s){let i=this.normalizePath(e);this.ensureParentDirs(i);let o=q(r),a=re(n,o);this.data.set(i,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}async readFile(e,n){let r=await this.readFileBuffer(e),s=q(n);return Ce(r,s)}async readFileBuffer(e){let n=this.resolvePathWithSymlinks(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return r.content instanceof Uint8Array?r.content:Ze.encode(r.content)}async writeFile(e,n,r){this.writeFileSync(e,n,r)}async appendFile(e,n,r){let s=this.normalizePath(e),i=this.data.get(s);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${e}'`);let o=q(r),a=re(n,o);if(i?.type==="file"){let c=i.content instanceof Uint8Array?i.content:Ze.encode(i.content),l=new Uint8Array(c.length+a.length);l.set(c),l.set(a,c.length),this.data.set(s,{type:"file",content:l,mode:i.mode,mtime:new Date})}else this.writeFileSync(e,n,r)}async exists(e){try{let n=this.resolvePathWithSymlinks(e);return this.data.has(n)}catch{return!1}}async stat(e){let n=this.resolvePathWithSymlinks(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Ze.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}async lstat(e){let n=this.resolveIntermediateSymlinks(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Ze.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}resolveSymlink(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=this.dirname(e);return this.normalizePath(r==="/"?`/${n}`:`${r}/${n}`)}resolveIntermediateSymlinks(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.slice(1).split("/");if(r.length<=1)return n;let s="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];s=`${s}/${a}`;let c=this.data.get(s),l=0,u=40;for(;c&&c.type==="symlink"&&l<u;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`);i.add(s),s=this.resolveSymlink(s,c.target),c=this.data.get(s),l++}if(l>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${e}'`)}return`${s}/${r[r.length-1]}`}resolvePathWithSymlinks(e){let n=this.normalizePath(e);if(n==="/")return"/";let r=n.slice(1).split("/"),s="",i=new Set;for(let o of r){s=`${s}/${o}`;let a=this.data.get(s),c=0,l=40;for(;a&&a.type==="symlink"&&c<l;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);i.add(s),s=this.resolveSymlink(s,a.target),a=this.data.get(s),c++}if(c>=l)throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`)}return s}async mkdir(e,n){this.mkdirSync(e,n)}mkdirSync(e,n){let r=this.normalizePath(e);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=this.dirname(r);if(s!=="/"&&!this.data.has(s))if(n?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(e){return(await this.readdirWithFileTypes(e)).map(r=>r.name)}async readdirWithFileTypes(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);let s=new Set;for(;r&&r.type==="symlink";){if(s.has(n))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${e}'`);s.add(n),n=this.resolveSymlink(n,r.target),r=this.data.get(n)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);let i=n==="/"?"/":`${n}/`,o=new Map;for(let[a,c]of this.data.entries())if(a!==n&&a.startsWith(i)){let l=a.slice(i.length),u=l.split("/")[0];u&&!l.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:c.type==="file",isDirectory:c.type==="directory",isSymbolicLink:c.type==="symlink"})}return Array.from(o.values()).sort((a,c)=>a.name<c.name?-1:a.name>c.name?1:0)}async rm(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}if(s.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let o of i){let a=r==="/"?`/${o}`:`${r}/${o}`;await this.rm(a,n)}}}this.data.delete(r)}async cp(e,n,r){let s=this.normalizePath(e),i=this.normalizePath(n),o=this.data.get(s);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${e}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(s);for(let c of a){let l=s==="/"?`/${c}`:`${s}/${c}`,u=i==="/"?`/${c}`:`${i}/${c}`;await this.cp(l,u,r)}}}async mv(e,n){await this.cp(e,n,{recursive:!0}),await this.rm(e,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,n){if(n.startsWith("/"))return this.normalizePath(n);let r=e==="/"?`/${n}`:`${e}/${n}`;return this.normalizePath(r)}async chmod(e,n){let r=this.normalizePath(e),s=this.data.get(r);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);s.mode=n}async symlink(e,n){let r=this.normalizePath(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,n){let r=this.normalizePath(e),s=this.normalizePath(n),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${n}'`);this.ensureParentDirs(s),this.data.set(s,{type:"file",content:i.content,mode:i.mode,mtime:i.mtime})}async readlink(e){let n=this.normalizePath(e),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}};var Pr="5.1.0(1)-release",vr="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT";function We(){return{pid:process.pid,ppid:process.ppid,uid:process.getuid?.()??1e3,gid:process.getgid?.()??1e3}}function $r(){let{pid:t,ppid:e,uid:n,gid:r}=We();return`Name: bash
2
2
  State: R (running)
3
3
  Pid: ${t}
4
4
  PPid: ${e}
@@ -9,14 +9,40 @@ export interface FileType {
9
9
  globs: string[];
10
10
  }
11
11
  /**
12
- * Built-in file type definitions
13
- * Use `rg --type-list` to see all types in real ripgrep
12
+ * Mutable file type registry for runtime type modifications
13
+ * Supports --type-add and --type-clear flags
14
14
  */
15
- export declare const FILE_TYPES: Record<string, FileType>;
16
- /**
17
- * Check if a filename matches any of the specified types
18
- */
19
- export declare function matchesType(filename: string, types: string[]): boolean;
15
+ export declare class FileTypeRegistry {
16
+ private types;
17
+ constructor();
18
+ /**
19
+ * Add a type definition
20
+ * Format: "name:pattern" where pattern can be:
21
+ * - "*.ext" - glob pattern
22
+ * - "include:other" - include patterns from another type
23
+ */
24
+ addType(spec: string): void;
25
+ /**
26
+ * Clear all patterns from a type
27
+ */
28
+ clearType(name: string): void;
29
+ /**
30
+ * Get a type by name
31
+ */
32
+ getType(name: string): FileType | undefined;
33
+ /**
34
+ * Get all type names
35
+ */
36
+ getAllTypes(): Map<string, FileType>;
37
+ /**
38
+ * Check if a filename matches any of the specified types
39
+ */
40
+ matchesType(filename: string, typeNames: string[]): boolean;
41
+ /**
42
+ * Check if a filename matches any recognized type
43
+ */
44
+ private matchesAnyType;
45
+ }
20
46
  /**
21
47
  * Format type list for --type-list output
22
48
  */
@@ -29,6 +29,14 @@ export declare class GitignoreParser {
29
29
  * @returns true if the path should be ignored
30
30
  */
31
31
  matches(relativePath: string, isDirectory: boolean): boolean;
32
+ /**
33
+ * Check if a path is explicitly whitelisted by a negation pattern
34
+ *
35
+ * @param relativePath Path relative to the gitignore location
36
+ * @param isDirectory Whether the path is a directory
37
+ * @returns true if the path is whitelisted by a negation pattern
38
+ */
39
+ isWhitelisted(relativePath: string, isDirectory: boolean): boolean;
32
40
  /**
33
41
  * Get the base path for this gitignore
34
42
  */
@@ -43,12 +51,24 @@ export declare class GitignoreParser {
43
51
  export declare class GitignoreManager {
44
52
  private parsers;
45
53
  private fs;
46
- private rootPath;
47
- constructor(fs: IFileSystem, rootPath: string);
54
+ private skipDotIgnore;
55
+ private skipVcsIgnore;
56
+ private loadedDirs;
57
+ constructor(fs: IFileSystem, _rootPath: string, skipDotIgnore?: boolean, skipVcsIgnore?: boolean);
48
58
  /**
49
59
  * Load all .gitignore and .ignore files from root to the specified path
50
60
  */
51
61
  load(targetPath: string): Promise<void>;
62
+ /**
63
+ * Load ignore files for a directory during traversal.
64
+ * Only loads if the directory hasn't been loaded before.
65
+ */
66
+ loadForDirectory(dir: string): Promise<void>;
67
+ /**
68
+ * Add patterns from raw content at the specified base path.
69
+ * Used for --ignore-file flag.
70
+ */
71
+ addPatternsFromContent(content: string, basePath: string): void;
52
72
  /**
53
73
  * Check if a path should be ignored
54
74
  *
@@ -57,6 +77,15 @@ export declare class GitignoreManager {
57
77
  * @returns true if the path should be ignored
58
78
  */
59
79
  matches(absolutePath: string, isDirectory: boolean): boolean;
80
+ /**
81
+ * Check if a path is explicitly whitelisted by a negation pattern.
82
+ * Used to include hidden files that have negation patterns like "!.foo"
83
+ *
84
+ * @param absolutePath Absolute path to check
85
+ * @param isDirectory Whether the path is a directory
86
+ * @returns true if the path is whitelisted by a negation pattern
87
+ */
88
+ isWhitelisted(absolutePath: string, isDirectory: boolean): boolean;
60
89
  /**
61
90
  * Quick check for common ignored directories
62
91
  * Used for early pruning during traversal
@@ -66,4 +95,4 @@ export declare class GitignoreManager {
66
95
  /**
67
96
  * Load gitignore files for a search starting at the given path
68
97
  */
69
- export declare function loadGitignores(fs: IFileSystem, startPath: string): Promise<GitignoreManager>;
98
+ export declare function loadGitignores(fs: IFileSystem, startPath: string, skipDotIgnore?: boolean, skipVcsIgnore?: boolean, customIgnoreFiles?: string[]): Promise<GitignoreManager>;
@@ -10,16 +10,20 @@ export interface RgOptions {
10
10
  lineRegexp: boolean;
11
11
  invertMatch: boolean;
12
12
  multiline: boolean;
13
+ multilineDotall: boolean;
13
14
  patterns: string[];
14
15
  patternFiles: string[];
15
16
  count: boolean;
16
17
  countMatches: boolean;
18
+ files: boolean;
17
19
  filesWithMatches: boolean;
18
20
  filesWithoutMatch: boolean;
21
+ stats: boolean;
19
22
  onlyMatching: boolean;
20
23
  maxCount: number;
21
24
  lineNumber: boolean;
22
25
  noFilename: boolean;
26
+ withFilename: boolean;
23
27
  nullSeparator: boolean;
24
28
  byteOffset: boolean;
25
29
  column: boolean;
@@ -35,13 +39,23 @@ export interface RgOptions {
35
39
  sort: "path" | "none";
36
40
  json: boolean;
37
41
  globs: string[];
42
+ iglobs: string[];
43
+ globCaseInsensitive: boolean;
38
44
  types: string[];
39
45
  typesNot: string[];
46
+ typeAdd: string[];
47
+ typeClear: string[];
40
48
  hidden: boolean;
41
49
  noIgnore: boolean;
50
+ noIgnoreDot: boolean;
51
+ noIgnoreVcs: boolean;
52
+ ignoreFiles: string[];
42
53
  maxDepth: number;
54
+ maxFilesize: number;
43
55
  followSymlinks: boolean;
44
56
  searchZip: boolean;
45
57
  searchBinary: boolean;
58
+ preprocessor: string | null;
59
+ preprocessorGlobs: string[];
46
60
  }
47
61
  export declare function createDefaultOptions(): RgOptions;
@@ -7,4 +7,4 @@
7
7
  * - Regex building for different modes (basic, extended, fixed, perl)
8
8
  */
9
9
  export { type SearchOptions, type SearchResult, searchContent, } from "./matcher.js";
10
- export { buildRegex, type RegexMode, type RegexOptions } from "./regex.js";
10
+ export { buildRegex, convertReplacement, type RegexMode, type RegexOptions, } from "./regex.js";
@@ -15,3 +15,13 @@ export interface RegexOptions {
15
15
  * Build a JavaScript RegExp from a pattern with the specified mode
16
16
  */
17
17
  export declare function buildRegex(pattern: string, options: RegexOptions): RegExp;
18
+ /**
19
+ * Convert replacement string syntax to JavaScript's String.replace format
20
+ *
21
+ * Conversions:
22
+ * - $0 and ${0} -> $& (full match)
23
+ * - $name -> $<name> (named capture groups)
24
+ * - ${name} -> $<name> (braced named capture groups)
25
+ * - Preserves $1, $2, etc. for numbered groups
26
+ */
27
+ export declare function convertReplacement(replacement: string): string;
@@ -0,0 +1,51 @@
1
+ import type { BufferEncoding, CpOptions, DirectoryEntry, DirentEntry, FileContent, FileEntry, FsEntry, FsStat, IFileSystem, InitialFiles, MkdirOptions, ReadFileOptions, RmOptions, SymlinkEntry, WriteFileOptions } from "../interface.js";
2
+ export type { BufferEncoding, FileContent, FileEntry, DirectoryEntry, SymlinkEntry, FsEntry, FsStat, IFileSystem, };
3
+ export interface FsData {
4
+ [path: string]: FsEntry;
5
+ }
6
+ export declare class InMemoryFs implements IFileSystem {
7
+ private data;
8
+ constructor(initialFiles?: InitialFiles);
9
+ private normalizePath;
10
+ private dirname;
11
+ private ensureParentDirs;
12
+ writeFileSync(path: string, content: FileContent, options?: WriteFileOptions | BufferEncoding, metadata?: {
13
+ mode?: number;
14
+ mtime?: Date;
15
+ }): void;
16
+ readFile(path: string, options?: ReadFileOptions | BufferEncoding): Promise<string>;
17
+ readFileBuffer(path: string): Promise<Uint8Array>;
18
+ writeFile(path: string, content: FileContent, options?: WriteFileOptions | BufferEncoding): Promise<void>;
19
+ appendFile(path: string, content: FileContent, options?: WriteFileOptions | BufferEncoding): Promise<void>;
20
+ exists(path: string): Promise<boolean>;
21
+ stat(path: string): Promise<FsStat>;
22
+ lstat(path: string): Promise<FsStat>;
23
+ private resolveSymlink;
24
+ /**
25
+ * Resolve symlinks in intermediate path components only (not the final component).
26
+ * Used by lstat which should not follow the final symlink.
27
+ */
28
+ private resolveIntermediateSymlinks;
29
+ /**
30
+ * Resolve all symlinks in a path, including intermediate components.
31
+ * For example: /home/user/linkdir/file.txt where linkdir is a symlink to "subdir"
32
+ * would resolve to /home/user/subdir/file.txt
33
+ */
34
+ private resolvePathWithSymlinks;
35
+ mkdir(path: string, options?: MkdirOptions): Promise<void>;
36
+ /**
37
+ * Synchronous version of mkdir
38
+ */
39
+ mkdirSync(path: string, options?: MkdirOptions): void;
40
+ readdir(path: string): Promise<string[]>;
41
+ readdirWithFileTypes(path: string): Promise<DirentEntry[]>;
42
+ rm(path: string, options?: RmOptions): Promise<void>;
43
+ cp(src: string, dest: string, options?: CpOptions): Promise<void>;
44
+ mv(src: string, dest: string): Promise<void>;
45
+ getAllPaths(): string[];
46
+ resolvePath(base: string, path: string): string;
47
+ chmod(path: string, mode: number): Promise<void>;
48
+ symlink(target: string, linkPath: string): Promise<void>;
49
+ link(existingPath: string, newPath: string): Promise<void>;
50
+ readlink(path: string): Promise<string>;
51
+ }
@@ -0,0 +1 @@
1
+ export { InMemoryFs } from "./in-memory-fs.js";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Filesystem Initialization
3
+ *
4
+ * Sets up the default filesystem structure for the bash environment
5
+ * including /dev, /proc, and common directories.
6
+ */
7
+ import type { IFileSystem } from "./interface.js";
8
+ /**
9
+ * Initialize the filesystem with standard directories and files
10
+ * Works with both InMemoryFs and OverlayFs (both write to memory)
11
+ */
12
+ export declare function initFilesystem(fs: IFileSystem, useDefaultLayout: boolean): void;