just-bash 2.4.4 → 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.
- package/README.md +42 -4
- package/dist/AGENTS.md +2 -2
- package/dist/bin/chunks/base64-O7TCK5TL.js +6 -0
- package/dist/bin/{shell/chunks/cat-ZEMMQGY5.js → chunks/cat-AJXZOSPN.js} +1 -1
- package/dist/bin/chunks/{chunk-45SNFRCY.js → chunk-5WFYIUU2.js} +2 -2
- package/dist/bin/chunks/chunk-CTLU5QUH.js +17 -0
- package/dist/bin/{shell/chunks/chunk-GX4MPCG6.js → chunks/chunk-Y5QKO4KO.js} +5 -5
- package/dist/bin/chunks/{cut-WWPJ2PYT.js → cut-IHF6BEOO.js} +1 -1
- package/dist/bin/chunks/grep-QCXXYC54.js +9 -0
- package/dist/bin/{shell/chunks/gzip-MNCJB6OR.js → chunks/gzip-YXK3WZQL.js} +22 -22
- package/dist/bin/{shell/chunks/jq-XH2PXRWE.js → chunks/jq-XXZPU5CA.js} +1 -1
- package/dist/bin/chunks/{md5sum-VGXAOUBA.js → md5sum-2VAAFCTS.js} +1 -1
- package/dist/bin/chunks/rg-GVIT6FTE.js +33 -0
- package/dist/bin/chunks/{sha1sum-BIUH233Z.js → sha1sum-67P4ME4N.js} +1 -1
- package/dist/bin/{shell/chunks/sha256sum-SUIK2MT2.js → chunks/sha256sum-MV3WQ4QF.js} +1 -1
- package/dist/bin/{shell/chunks/sort-C3F6LCNY.js → chunks/sort-KUHOCH5S.js} +1 -1
- package/dist/bin/chunks/tar-C27YYUAS.js +63 -0
- package/dist/bin/{shell/chunks/uniq-DKS7RIAE.js → chunks/uniq-IXHB2FVS.js} +1 -1
- package/dist/bin/chunks/{wc-4LMTC3QD.js → wc-QSBRKIF5.js} +1 -1
- package/dist/bin/chunks/{xan-WNN2ZOAX.js → xan-6K2NGTHM.js} +1 -1
- package/dist/bin/just-bash.js +78 -78
- package/dist/bin/shell/chunks/base64-O7TCK5TL.js +6 -0
- package/dist/bin/{chunks/cat-ZEMMQGY5.js → shell/chunks/cat-AJXZOSPN.js} +1 -1
- package/dist/bin/shell/chunks/{chunk-45SNFRCY.js → chunk-5WFYIUU2.js} +2 -2
- package/dist/bin/shell/chunks/chunk-CTLU5QUH.js +17 -0
- package/dist/bin/{chunks/chunk-GX4MPCG6.js → shell/chunks/chunk-Y5QKO4KO.js} +5 -5
- package/dist/bin/shell/chunks/{cut-WWPJ2PYT.js → cut-IHF6BEOO.js} +1 -1
- package/dist/bin/shell/chunks/grep-QCXXYC54.js +9 -0
- package/dist/bin/{chunks/gzip-MNCJB6OR.js → shell/chunks/gzip-YXK3WZQL.js} +22 -22
- package/dist/bin/{chunks/jq-XH2PXRWE.js → shell/chunks/jq-XXZPU5CA.js} +1 -1
- package/dist/bin/shell/chunks/{md5sum-VGXAOUBA.js → md5sum-2VAAFCTS.js} +1 -1
- package/dist/bin/shell/chunks/rg-GVIT6FTE.js +33 -0
- package/dist/bin/shell/chunks/{sha1sum-BIUH233Z.js → sha1sum-67P4ME4N.js} +1 -1
- package/dist/bin/{chunks/sha256sum-SUIK2MT2.js → shell/chunks/sha256sum-MV3WQ4QF.js} +1 -1
- package/dist/bin/{chunks/sort-C3F6LCNY.js → shell/chunks/sort-KUHOCH5S.js} +1 -1
- package/dist/bin/shell/chunks/tar-C27YYUAS.js +63 -0
- package/dist/bin/{chunks/uniq-DKS7RIAE.js → shell/chunks/uniq-IXHB2FVS.js} +1 -1
- package/dist/bin/shell/chunks/{wc-4LMTC3QD.js → wc-QSBRKIF5.js} +1 -1
- package/dist/bin/shell/chunks/{xan-WNN2ZOAX.js → xan-6K2NGTHM.js} +1 -1
- package/dist/bin/shell/shell.js +100 -100
- package/dist/bundle/browser.js +557 -517
- package/dist/bundle/chunks/base64-3BME25ON.js +5 -0
- package/dist/bundle/chunks/{cat-W5XITXDC.js → cat-MV4K6AUA.js} +1 -1
- package/dist/bundle/chunks/{chunk-4ACWXGKW.js → chunk-7L36YK2X.js} +2 -2
- package/dist/bundle/chunks/{chunk-46TSKXFW.js → chunk-GFLIVSUW.js} +5 -5
- package/dist/bundle/chunks/chunk-OHJS5H37.js +16 -0
- package/dist/bundle/chunks/{cut-KKAAQJVD.js → cut-NVKWEAZF.js} +1 -1
- package/dist/bundle/chunks/grep-TUWLGQC2.js +8 -0
- package/dist/bundle/chunks/{gzip-7QAS5P2Y.js → gzip-L3NDJG3F.js} +22 -22
- package/dist/bundle/chunks/{jq-AAWVUTC4.js → jq-3YU5HRKE.js} +1 -1
- package/dist/bundle/chunks/{md5sum-LJHKXLVT.js → md5sum-KLHZSRUA.js} +1 -1
- package/dist/bundle/chunks/rg-KTCMPGU6.js +32 -0
- package/dist/bundle/chunks/{sha1sum-NRUZZ4Q6.js → sha1sum-WKWTIZGQ.js} +1 -1
- package/dist/bundle/chunks/{sha256sum-5ZGJ4NJL.js → sha256sum-IUVNMBTA.js} +1 -1
- package/dist/bundle/chunks/{sort-JHO22QVO.js → sort-EJUT5LXD.js} +1 -1
- package/dist/bundle/chunks/tar-QWBXMF7K.js +62 -0
- package/dist/bundle/chunks/{uniq-SEKCFR7B.js → uniq-47QVBRNC.js} +1 -1
- package/dist/bundle/chunks/{wc-52FZ4QGS.js → wc-DFQKWSIZ.js} +1 -1
- package/dist/bundle/chunks/{xan-ZHXYF6B4.js → xan-2R2APJJ4.js} +1 -1
- package/dist/bundle/index.js +119 -119
- package/dist/commands/registry.d.ts +1 -1
- package/dist/commands/rg/file-types.d.ts +49 -0
- package/dist/commands/rg/gitignore.d.ts +98 -0
- package/dist/commands/rg/rg-options.d.ts +61 -0
- package/dist/commands/rg/rg-parser.d.ts +20 -0
- package/dist/commands/rg/rg-search.d.ts +15 -0
- package/dist/commands/rg/rg.d.ts +12 -0
- package/dist/commands/search-engine/index.d.ts +10 -0
- package/dist/commands/search-engine/matcher.d.ts +57 -0
- package/dist/commands/search-engine/regex.d.ts +27 -0
- package/dist/commands/tar/archive.d.ts +107 -0
- package/dist/commands/tar/tar.d.ts +8 -0
- package/dist/fs/in-memory-fs/in-memory-fs.d.ts +51 -0
- package/dist/fs/in-memory-fs/index.d.ts +1 -0
- package/dist/fs/init.d.ts +12 -0
- package/dist/fs/interface.d.ts +203 -0
- package/dist/fs/mountable-fs/index.d.ts +1 -0
- package/dist/fs/mountable-fs/mountable-fs.d.ts +108 -0
- package/dist/fs/overlay-fs/index.d.ts +1 -0
- package/dist/fs/overlay-fs/overlay-fs.d.ts +107 -0
- package/dist/fs/read-write-fs/index.d.ts +1 -0
- package/dist/fs/read-write-fs/read-write-fs.d.ts +47 -0
- package/dist/fs/utils.d.ts +17 -0
- package/dist/index.d.ts +1 -0
- package/package.json +12 -7
- package/dist/bin/chunks/base64-RJX7MYGG.js +0 -6
- package/dist/bin/chunks/grep-U2RCKOEG.js +0 -15
- package/dist/bin/shell/chunks/base64-RJX7MYGG.js +0 -6
- package/dist/bin/shell/chunks/grep-U2RCKOEG.js +0 -15
- package/dist/bundle/chunks/base64-F5R4G5EG.js +0 -5
- package/dist/bundle/chunks/grep-CTJRP2G3.js +0 -14
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ Custom commands receive the full `CommandContext` with access to `fs`, `cwd`, `e
|
|
|
99
99
|
|
|
100
100
|
### Filesystem Options
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
Four filesystem implementations are available:
|
|
103
103
|
|
|
104
104
|
**InMemoryFs** (default) - Pure in-memory filesystem, no disk access:
|
|
105
105
|
|
|
@@ -133,6 +133,44 @@ const env = new Bash({ fs: rwfs });
|
|
|
133
133
|
await env.exec('echo "hello" > file.txt'); // writes to real filesystem
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
+
**MountableFs** - Mount multiple filesystems at different paths. Combines read-only and read-write filesystems into a unified namespace:
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
import { Bash, MountableFs, InMemoryFs } from "just-bash";
|
|
140
|
+
import { OverlayFs } from "just-bash/fs/overlay-fs";
|
|
141
|
+
import { ReadWriteFs } from "just-bash/fs/read-write-fs";
|
|
142
|
+
|
|
143
|
+
const fs = new MountableFs({ base: new InMemoryFs() });
|
|
144
|
+
|
|
145
|
+
// Mount read-only knowledge base
|
|
146
|
+
fs.mount("/mnt/knowledge", new OverlayFs({ root: "/path/to/knowledge", readOnly: true }));
|
|
147
|
+
|
|
148
|
+
// Mount read-write workspace
|
|
149
|
+
fs.mount("/home/agent", new ReadWriteFs({ root: "/path/to/workspace" }));
|
|
150
|
+
|
|
151
|
+
const bash = new Bash({ fs, cwd: "/home/agent" });
|
|
152
|
+
|
|
153
|
+
await bash.exec("ls /mnt/knowledge"); // reads from knowledge base
|
|
154
|
+
await bash.exec("cp /mnt/knowledge/doc.txt ./"); // cross-mount copy
|
|
155
|
+
await bash.exec('echo "notes" > notes.txt'); // writes to workspace
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
You can also configure mounts in the constructor:
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
import { MountableFs, InMemoryFs } from "just-bash";
|
|
162
|
+
import { OverlayFs } from "just-bash/fs/overlay-fs";
|
|
163
|
+
import { ReadWriteFs } from "just-bash/fs/read-write-fs";
|
|
164
|
+
|
|
165
|
+
const fs = new MountableFs({
|
|
166
|
+
base: new InMemoryFs(),
|
|
167
|
+
mounts: [
|
|
168
|
+
{ mountPoint: "/data", filesystem: new OverlayFs({ root: "/shared/data" }) },
|
|
169
|
+
{ mountPoint: "/workspace", filesystem: new ReadWriteFs({ root: "/tmp/work" }) },
|
|
170
|
+
],
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
136
174
|
### AI SDK Tool
|
|
137
175
|
|
|
138
176
|
For AI agents, use [`bash-tool`](https://github.com/vercel-labs/bash-tool) which is optimized for just-bash and provides a ready-to-use [AI SDK](https://ai-sdk.dev/) tool:
|
|
@@ -241,15 +279,15 @@ pnpm shell --no-network
|
|
|
241
279
|
|
|
242
280
|
### Text Processing
|
|
243
281
|
|
|
244
|
-
`awk`, `base64`, `column`, `comm`, `cut`, `diff`, `expand`, `fold`, `grep` (+ `egrep`, `fgrep`), `head`, `join`, `md5sum`, `nl`, `od`, `paste`, `printf`, `rev`, `sed`, `sha1sum`, `sha256sum`, `sort`, `strings`, `tac`, `tail`, `tr`, `unexpand`, `uniq`, `wc`, `xargs`
|
|
282
|
+
`awk`, `base64`, `column`, `comm`, `cut`, `diff`, `expand`, `fold`, `grep` (+ `egrep`, `fgrep`), `head`, `join`, `md5sum`, `nl`, `od`, `paste`, `printf`, `rev`, `rg`, `sed`, `sha1sum`, `sha256sum`, `sort`, `strings`, `tac`, `tail`, `tr`, `unexpand`, `uniq`, `wc`, `xargs`
|
|
245
283
|
|
|
246
284
|
### Data Processing
|
|
247
285
|
|
|
248
286
|
`jq` (JSON), `sqlite3` (SQLite), `xan` (CSV), `yq` (YAML/XML/TOML/CSV)
|
|
249
287
|
|
|
250
|
-
### Compression
|
|
288
|
+
### Compression & Archives
|
|
251
289
|
|
|
252
|
-
`gzip` (+ `gunzip`, `zcat`)
|
|
290
|
+
`gzip` (+ `gunzip`, `zcat`), `tar`
|
|
253
291
|
|
|
254
292
|
### Navigation & Environment
|
|
255
293
|
|
package/dist/AGENTS.md
CHANGED
|
@@ -64,13 +64,13 @@ const result = await bash.exec("cat input.txt | grep pattern");
|
|
|
64
64
|
|
|
65
65
|
## Available Commands
|
|
66
66
|
|
|
67
|
-
**Text processing**: `awk`, `cat`, `column`, `comm`, `cut`, `egrep`, `expand`, `fgrep`, `fold`, `grep`, `head`, `join`, `nl`, `paste`, `rev`, `sed`, `sort`, `strings`, `tac`, `tail`, `tr`, `unexpand`, `uniq`, `wc`, `xargs`
|
|
67
|
+
**Text processing**: `awk`, `cat`, `column`, `comm`, `cut`, `egrep`, `expand`, `fgrep`, `fold`, `grep`, `head`, `join`, `nl`, `paste`, `rev`, `rg`, `sed`, `sort`, `strings`, `tac`, `tail`, `tr`, `unexpand`, `uniq`, `wc`, `xargs`
|
|
68
68
|
|
|
69
69
|
**Data processing**: `jq` (JSON), `sqlite3` (SQLite), `xan` (CSV), `yq` (YAML/XML/TOML/CSV)
|
|
70
70
|
|
|
71
71
|
**File operations**: `basename`, `chmod`, `cp`, `dirname`, `du`, `file`, `find`, `ln`, `ls`, `mkdir`, `mv`, `od`, `pwd`, `readlink`, `rm`, `split`, `stat`, `touch`, `tree`
|
|
72
72
|
|
|
73
|
-
**Utilities**: `alias`, `base64`, `bash`, `clear`, `curl`, `date`, `diff`, `echo`, `env`, `expr`, `false`, `gzip`, `gunzip`, `help`, `history`, `hostname`, `html-to-markdown`, `md5sum`, `printenv`, `printf`, `seq`, `sh`, `sha1sum`, `sha256sum`, `sleep`, `tee`, `timeout`, `true`, `unalias`, `which`, `zcat`
|
|
73
|
+
**Utilities**: `alias`, `base64`, `bash`, `clear`, `curl`, `date`, `diff`, `echo`, `env`, `expr`, `false`, `gzip`, `gunzip`, `help`, `history`, `hostname`, `html-to-markdown`, `md5sum`, `printenv`, `printf`, `seq`, `sh`, `sha1sum`, `sha256sum`, `sleep`, `tar`, `tee`, `timeout`, `true`, `unalias`, `which`, `zcat`
|
|
74
74
|
|
|
75
75
|
All commands support `--help` for usage details.
|
|
76
76
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as f}from"./chunk-TA7RUHGQ.js";import{a as l,b as u}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var g={name:"base64",summary:"base64 encode/decode data and print to standard output",usage:"base64 [OPTION]... [FILE]",options:["-d, --decode decode data","-w, --wrap=COLS wrap encoded lines after COLS character (default 76, 0 to disable)"," --help display this help and exit"]},b={decode:{short:"d",long:"decode",type:"boolean"},wrap:{short:"w",long:"wrap",type:"number",default:76}};async function p(r,o,a){if(o.length===0||o.length===1&&o[0]==="-")return{ok:!0,data:Uint8Array.from(r.stdin,e=>e.charCodeAt(0))};let s=[];for(let e of o){if(e==="-"){s.push(Uint8Array.from(r.stdin,t=>t.charCodeAt(0)));continue}try{let t=r.fs.resolvePath(r.cwd,e),n=await r.fs.readFileBuffer(t);s.push(n)}catch{return{ok:!1,error:{stdout:"",stderr:`${a}: ${e}: No such file or directory
|
|
3
|
+
`,exitCode:1}}}}let c=s.reduce((e,t)=>e+t.length,0),i=new Uint8Array(c),d=0;for(let e of s)i.set(e,d),d+=e.length;return{ok:!0,data:i}}var y={name:"base64",async execute(r,o){if(u(r))return l(g);let a=f("base64",r,b);if(!a.ok)return a.error;let s=a.result.flags.decode,c=a.result.flags.wrap,i=a.result.positional;try{if(s){let t=await p(o,i,"base64");if(!t.ok)return t.error;let h=String.fromCharCode(...t.data).replace(/\s/g,"");return{stdout:atob(h),stderr:"",exitCode:0}}let d=await p(o,i,"base64");if(!d.ok)return d.error;let e=btoa(String.fromCharCode(...d.data));if(c>0){let t=[];for(let n=0;n<e.length;n+=c)t.push(e.slice(n,n+c));e=t.join(`
|
|
4
|
+
`)+(e.length>0?`
|
|
5
|
+
`:"")}return{stdout:e,stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`base64: invalid input
|
|
6
|
+
`,exitCode:1}}}};export{y as base64Command};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as p}from"./chunk-
|
|
2
|
+
import{a as p}from"./chunk-5WFYIUU2.js";import"./chunk-OBH7XN5N.js";import{a as d}from"./chunk-TA7RUHGQ.js";import{a as c,b as m}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var f={name:"cat",summary:"concatenate files and print on the standard output",usage:"cat [OPTION]... [FILE]...",options:["-n, --number number all output lines"," --help display this help and exit"]},b={number:{short:"n",long:"number",type:"boolean"}},w={name:"cat",async execute(t,r){if(m(t))return c(f);let e=d("cat",t,b);if(!e.ok)return e.error;let s=e.result.flags.number,o=e.result.positional,a=await p(r,o,{cmdName:"cat",allowStdinMarker:!0,stopOnError:!1}),n="",i=1;for(let{content:l}of a.files)if(s){let u=h(l,i);n+=u.content,i=u.nextLineNumber}else n+=l;return{stdout:n,stderr:a.stderr,exitCode:a.exitCode}}};function h(t,r){let e=t.split(`
|
|
3
3
|
`),s=t.endsWith(`
|
|
4
4
|
`),o=s?e.slice(0,-1):e;return{content:o.map((n,i)=>`${String(r+i).padStart(6," ")} ${n}`).join(`
|
|
5
5
|
`)+(s?`
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
async function
|
|
3
|
-
`}}}));for(let e of m)if(e.error){if(c+=e.error,l=1,a)return{files:i,stderr:c,exitCode:l}}else i.push({filename:e.filename,content:e.content})}return{files:i,stderr:c,exitCode:l}}async function
|
|
2
|
+
async function y(t,n,s){let{cmdName:r,allowStdinMarker:f=!0,stopOnError:a=!1,batchSize:u=100}=s;if(n.length===0)return{files:[{filename:"",content:t.stdin}],stderr:"",exitCode:0};let i=[],c="",l=0;for(let o=0;o<n.length;o+=u){let d=n.slice(o,o+u),m=await Promise.all(d.map(async e=>{if(f&&e==="-")return{filename:"-",content:t.stdin,error:null};try{let h=t.fs.resolvePath(t.cwd,e),p=await t.fs.readFile(h,"binary");return{filename:e,content:p,error:null}}catch{return{filename:e,content:"",error:`${r}: ${e}: No such file or directory
|
|
3
|
+
`}}}));for(let e of m)if(e.error){if(c+=e.error,l=1,a)return{files:i,stderr:c,exitCode:l}}else i.push({filename:e.filename,content:e.content})}return{files:i,stderr:c,exitCode:l}}async function b(t,n,s){let r=await y(t,n,{...s,stopOnError:!0});return r.exitCode!==0?{ok:!1,error:{stdout:"",stderr:r.stderr,exitCode:r.exitCode}}:{ok:!0,content:r.files.map(a=>a.content).join("")}}export{y as a,b};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
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(`
|
|
3
|
+
`),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)}
|
|
4
|
+
`,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(`
|
|
5
|
+
`)}
|
|
6
|
+
`:"",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(`
|
|
7
|
+
`)}
|
|
8
|
+
`:"",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(`
|
|
9
|
+
`)}
|
|
10
|
+
`:"",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(`
|
|
11
|
+
`),y=p.length,N=y>0&&p[y-1]===""?y-1:y,d=[0];for(let i=0;i<u.length;i++)u[i]===`
|
|
12
|
+
`&&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)}
|
|
13
|
+
`,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(`
|
|
14
|
+
`)}
|
|
15
|
+
`:"",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(`
|
|
16
|
+
`)}
|
|
17
|
+
`:"",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,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as
|
|
3
|
-
`,exitCode:1};for(let
|
|
4
|
-
`)){let r
|
|
5
|
-
`,e++;continue}let i=await
|
|
2
|
+
import{a as $,b as m,c as C}from"./chunk-GTNBSMZR.js";var k={sha1:"SHA-1",sha256:"SHA-256"};function L(n){function h(a,u){return a<<u|a>>>32-u}let p=new Uint32Array([3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745]),A=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],g=n.length*8,o=(n.length%64<56?56:120)-n.length%64,s=new Uint8Array(n.length+o+8);s.set(n),s[n.length]=128;let d=new DataView(s.buffer);d.setUint32(s.length-8,g>>>0,!0),d.setUint32(s.length-4,Math.floor(g/4294967296),!0);let b=1732584193,l=4023233417,w=2562383102,e=271733878;for(let a=0;a<s.length;a+=64){let u=new Uint32Array(16);for(let t=0;t<16;t++)u[t]=d.getUint32(a+t*4,!0);let y=b,r=l,x=w,c=e;for(let t=0;t<64;t++){let i,U;t<16?(i=r&x|~r&c,U=t):t<32?(i=c&r|~c&x,U=(5*t+1)%16):t<48?(i=r^x^c,U=(3*t+5)%16):(i=x^(r|~c),U=7*t%16),i=i+y+p[t]+u[U]>>>0,y=c,c=x,x=r,r=r+h(i,A[t])>>>0}b=b+y>>>0,l=l+r>>>0,w=w+x>>>0,e=e+c>>>0}let f=new Uint8Array(16);return new DataView(f.buffer).setUint32(0,b,!0),new DataView(f.buffer).setUint32(4,l,!0),new DataView(f.buffer).setUint32(8,w,!0),new DataView(f.buffer).setUint32(12,e,!0),Array.from(f).map(a=>a.toString(16).padStart(2,"0")).join("")}async function F(n,h){if(n==="md5")return L(h);let p=await globalThis.crypto.subtle.digest(k[n],new Uint8Array(h).buffer);return Array.from(new Uint8Array(p)).map(A=>A.toString(16).padStart(2,"0")).join("")}function S(n,h,p){let A={name:n,summary:p,usage:`${n} [OPTION]... [FILE]...`,options:["-c, --check read checksums from FILEs and check them"," --help display this help and exit"]};return{name:n,async execute(g,o){if(m(g))return $(A);let s=!1,d=[];for(let e of g)if(e==="-c"||e==="--check")s=!0;else if(!(e==="-b"||e==="-t"||e==="--binary"||e==="--text")){if(e.startsWith("-")&&e!=="-")return C(n,e);d.push(e)}d.length===0&&d.push("-");let b=async e=>{if(e==="-")return Uint8Array.from(o.stdin,f=>f.charCodeAt(0));try{return await o.fs.readFileBuffer(o.fs.resolvePath(o.cwd,e))}catch{return null}};if(s){let e=0,f="";for(let a of d){let u=a==="-"?o.stdin:await o.fs.readFile(o.fs.resolvePath(o.cwd,a)).catch(()=>null);if(u===null)return{stdout:"",stderr:`${n}: ${a}: No such file or directory
|
|
3
|
+
`,exitCode:1};for(let y of u.split(`
|
|
4
|
+
`)){let r=y.match(/^([a-fA-F0-9]+)\s+[* ]?(.+)$/);if(!r)continue;let[,x,c]=r,t=await b(c);if(t===null){f+=`${c}: FAILED open or read
|
|
5
|
+
`,e++;continue}let i=await F(h,t)===x.toLowerCase();f+=`${c}: ${i?"OK":"FAILED"}
|
|
6
6
|
`,i||e++}}return e>0&&(f+=`${n}: WARNING: ${e} computed checksum${e>1?"s":""} did NOT match
|
|
7
7
|
`),{stdout:f,stderr:"",exitCode:e>0?1:0}}let l="",w=0;for(let e of d){let f=await b(e);if(f===null){l+=`${n}: ${e}: No such file or directory
|
|
8
|
-
`,w=1;continue}l+=`${await
|
|
8
|
+
`,w=1;continue}l+=`${await F(h,f)} ${e}
|
|
9
9
|
`}return{stdout:l,stderr:"",exitCode:w}}}}export{S as a};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{b as x}from"./chunk-
|
|
2
|
+
import{b as x}from"./chunk-5WFYIUU2.js";import"./chunk-OBH7XN5N.js";import{a as y,b as I,c as m}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var W={name:"cut",summary:"remove sections from each line of files",usage:"cut [OPTION]... [FILE]...",options:["-c LIST select only these characters","-d DELIM use DELIM instead of TAB for field delimiter","-f LIST select only these fields","-s, --only-delimited do not print lines without delimiters"," --help display this help and exit"]};function k(t){let c=[],l=t.split(",");for(let n of l)if(n.includes("-")){let[s,r]=n.split("-");c.push({start:s?parseInt(s,10):1,end:r?parseInt(r,10):null})}else{let s=parseInt(n,10);c.push({start:s,end:s})}return c}function C(t,c){let l=[];for(let n of c){let s=n.start-1,r=n.end===null?t.length:n.end;for(let i=s;i<r&&i<t.length;i++)i>=0&&!l.includes(t[i])&&l.push(t[i])}return l}var E={name:"cut",async execute(t,c){if(I(t))return y(W);let l=" ",n=null,s=null,r=!1,i=[];for(let o=0;o<t.length;o++){let e=t[o];if(e==="-d")l=t[++o]||" ";else if(e.startsWith("-d"))l=e.slice(2);else if(e==="-f")n=t[++o];else if(e.startsWith("-f"))n=e.slice(2);else if(e==="-c")s=t[++o];else if(e.startsWith("-c"))s=e.slice(2);else if(e==="-s"||e==="--only-delimited")r=!0;else{if(e.startsWith("--"))return m("cut",e);if(e.startsWith("-")){let f=!1;for(let u of e.slice(1))if(u==="s")r=!0;else if(!"dfc".includes(u)){f=!0;break}if(f)return m("cut",e)}else i.push(e)}}if(!n&&!s)return{stdout:"",stderr:`cut: you must specify a list of bytes, characters, or fields
|
|
3
3
|
`,exitCode:1};let p=await x(c,i,{cmdName:"cut"});if(!p.ok)return p.error;let a=p.content.split(`
|
|
4
4
|
`);a.length>0&&a[a.length-1]===""&&a.pop();let g=k(n||s||"1"),h="";for(let o of a)if(s){let e=o.split(""),f=[];for(let u of g){let w=u.start-1,L=u.end===null?e.length:u.end;for(let d=w;d<L&&d<e.length;d++)d>=0&&f.push(e[d])}h+=`${f.join("")}
|
|
5
5
|
`}else{if(r&&!o.includes(l))continue;let e=o.split(l),f=C(e,g);h+=`${f.join(l)}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as y}from"./chunk-26Q3PZQ6.js";import{a as S,b as j}from"./chunk-CTLU5QUH.js";import{a as Z,b as _,c as L}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.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
|
|
3
|
+
`,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: ${$}
|
|
4
|
+
`,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
|
|
5
|
+
`,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
|
|
6
|
+
`};let X=await s.fs.readFile(M),Y=S(X,U,{invertMatch:c,showLineNumbers:f,countOnly:p,filename:V?g:"",onlyMatching:x,beforeContext:F,afterContext:N,maxCount:W});return{file:g,result:Y}}catch{return{error:`grep: ${g}: No such file or directory
|
|
7
|
+
`}}}));for(let a of C){if(a===null)continue;if("error"in a&&a.error){D+=a.error,a.error.includes("Is a directory")||(H=!0);continue}if(!("file"in a)||!a.result)continue;let{file:g,result:e}=a;if(e.matched){if(G=!0,B)return{stdout:"",stderr:"",exitCode:0};m?v+=`${g}
|
|
8
|
+
`:l||(v+=e.output)}else l?v+=`${g}
|
|
9
|
+
`:p&&!m&&(v+=e.output)}}let E;return H?E=2:l?E=v.length>0?0:1:E=G?0:1,B?{stdout:"",stderr:"",exitCode:E}:{stdout:v,stderr:D,exitCode:E}}};async function J(t,s,o,f){let c=o.fs.resolvePath(o.cwd,t);try{if(!(await o.fs.stat(c)).isDirectory){let l=t.split("/").pop()||"";if(s){let i=s.replace(/^\//,"");y(l,i,{stripQuotes:!0})&&f.push(t)}return}let m=await o.fs.readdir(c);for(let l of m){let i=t==="."?l:`${t}/${l}`,d=o.fs.resolvePath(o.cwd,i);if((await o.fs.stat(d)).isDirectory)await J(i,s,o,f);else if(s){let u=s.replace(/^\//,"");y(l,u,{stripQuotes:!0})&&f.push(i)}}}catch{}}async function te(t,s){let o=[],f=t.lastIndexOf("/"),c,p;if(f===-1?(c=s.cwd,p=t):(c=t.slice(0,f)||"/",p=t.slice(f+1)),t.includes("**")){let l=[],i=t.split("**"),d=i[0].replace(/\/$/,"")||".",w=i[1]||"";return await J(d,w,s,l),l.map(u=>({path:u}))}let m=s.fs.resolvePath(s.cwd,c);try{if(s.fs.readdirWithFileTypes){let l=await s.fs.readdirWithFileTypes(m);for(let i of l)if(y(i.name,p,{stripQuotes:!0})){let d=f===-1?i.name:`${c}/${i.name}`;o.push({path:d,isFile:i.isFile})}}else{let l=await s.fs.readdir(m);for(let i of l)if(y(i,p,{stripQuotes:!0})){let d=f===-1?i:`${c}/${i}`;o.push({path:d})}}}catch{}return o.sort((l,i)=>l.path.localeCompare(i.path))}async function O(t,s,o=[],f=[],c=[],p){let m=s.fs.resolvePath(s.cwd,t),l=[];try{let i,d;if(p!==void 0)i=p,d=!p;else{let u=await s.fs.stat(m);i=u.isFile,d=u.isDirectory}if(i){let u=t.split("/").pop()||t;return f.length>0&&f.some(h=>y(u,h,{stripQuotes:!0}))?[]:o.length>0&&!o.some(h=>y(u,h,{stripQuotes:!0}))?[]:[{path:t,isFile:!0}]}if(!d)return[];let w=t.split("/").pop()||t;if(c.length>0&&c.some(u=>y(w,u,{stripQuotes:!0})))return[];if(s.fs.readdirWithFileTypes){let u=await s.fs.readdirWithFileTypes(m);for(let h of u){if(h.name.startsWith("."))continue;let T=t==="."?h.name:`${t}/${h.name}`,x=await O(T,s,o,f,c,h.isFile);l.push(...x)}}else{let u=await s.fs.readdir(m);for(let h of u){if(h.startsWith("."))continue;let T=t==="."?h:`${t}/${h}`,x=await O(T,s,o,f,c);l.push(...x)}}}catch{}return l}var le={name:"fgrep",async execute(t,s){return z.execute(["-F",...t],s)}},oe={name:"egrep",async execute(t,s){return z.execute(["-E",...t],s)}};export{oe as egrepCommand,le as fgrepCommand,z as grepCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as z}from"./chunk-TA7RUHGQ.js";import{a as
|
|
2
|
+
import{a as z}from"./chunk-TA7RUHGQ.js";import{a as $,b as w}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";import{constants as C,gunzipSync as x,gzipSync as b}from"node:zlib";var I={name:"gzip",summary:"compress or expand files",usage:"gzip [OPTION]... [FILE]...",description:`Compress FILEs (by default, in-place).
|
|
3
3
|
|
|
4
4
|
When no FILE is given, or when FILE is -, read from standard input.
|
|
5
5
|
|
|
@@ -7,26 +7,26 @@ With -d, decompress instead.`,options:["-c, --stdout write to standard outp
|
|
|
7
7
|
|
|
8
8
|
When no FILE is given, or when FILE is -, read from standard input.`,options:["-c, --stdout write to standard output, keep original files","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not restore the original name and timestamp","-N, --name restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},P={name:"zcat",summary:"decompress files to stdout",usage:"zcat [OPTION]... [FILE]...",description:`Decompress FILEs to standard output.
|
|
9
9
|
|
|
10
|
-
When no FILE is given, or when FILE is -, read from standard input.`,options:["-f, --force force; read compressed data even from a terminal","-l, --list list compressed file contents","-q, --quiet suppress all warnings","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},
|
|
11
|
-
`,exitCode:1};try{let
|
|
12
|
-
`,exitCode:1}}}else{let
|
|
10
|
+
When no FILE is given, or when FILE is -, read from standard input.`,options:["-f, --force force; read compressed data even from a terminal","-l, --list list compressed file contents","-q, --quiet suppress all warnings","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},L={stdout:{short:"c",long:"stdout",type:"boolean"},toStdout:{long:"to-stdout",type:"boolean"},decompress:{short:"d",long:"decompress",type:"boolean"},uncompress:{long:"uncompress",type:"boolean"},force:{short:"f",long:"force",type:"boolean"},keep:{short:"k",long:"keep",type:"boolean"},list:{short:"l",long:"list",type:"boolean"},noName:{short:"n",long:"no-name",type:"boolean"},name:{short:"N",long:"name",type:"boolean"},quiet:{short:"q",long:"quiet",type:"boolean"},recursive:{short:"r",long:"recursive",type:"boolean"},suffix:{short:"S",long:"suffix",type:"string",default:".gz"},test:{short:"t",long:"test",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"},fast:{short:"1",long:"fast",type:"boolean"},level2:{short:"2",type:"boolean"},level3:{short:"3",type:"boolean"},level4:{short:"4",type:"boolean"},level5:{short:"5",type:"boolean"},level6:{short:"6",type:"boolean"},level7:{short:"7",type:"boolean"},level8:{short:"8",type:"boolean"},best:{short:"9",long:"best",type:"boolean"}};function F(e){return e.best?C.Z_BEST_COMPRESSION:e.level8?8:e.level7?7:e.level6?6:e.level5?5:e.level4?4:e.level3?3:e.level2?2:e.fast?C.Z_BEST_SPEED:C.Z_DEFAULT_COMPRESSION}function S(e){if(e.length<10)return{originalName:null,mtime:null,headerSize:0};if(e[0]!==31||e[1]!==139)return{originalName:null,mtime:null,headerSize:0};let t=e[3],o=e[4]|e[5]<<8|e[6]<<16|e[7]<<24,r=10;if(t&4){if(r+2>e.length)return{originalName:null,mtime:null,headerSize:0};let s=e[r]|e[r+1]<<8;r+=2+s}let n=null;if(t&8){let s=r;for(;r<e.length&&e[r]!==0;)r++;r<e.length&&(n=new TextDecoder().decode(e.slice(s,r)),r++)}if(t&16){for(;r<e.length&&e[r]!==0;)r++;r++}return t&2&&(r+=2),{originalName:n,mtime:o>0?new Date(o*1e3):null,headerSize:r}}function D(e){if(e.length<4)return 0;let t=e.length;return e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24}function y(e){return e.length>=2&&e[0]===31&&e[1]===139}async function E(e,t,o,r,n,s){let u=o.suffix,f,p,l;if(t==="-"||t==="")if(l=Uint8Array.from(e.stdin,d=>d.charCodeAt(0)),n){if(!y(l))return o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: stdin: not in gzip format
|
|
11
|
+
`,exitCode:1};try{let d=x(l);return{stdout:String.fromCharCode(...d),stderr:"",exitCode:0}}catch(d){let i=d instanceof Error?d.message:"unknown error";return{stdout:"",stderr:`${r}: stdin: ${i}
|
|
12
|
+
`,exitCode:1}}}else{let d=F(o),i=b(l,{level:d});return{stdout:String.fromCharCode(...i),stderr:"",exitCode:0}}f=e.fs.resolvePath(e.cwd,t);try{if((await e.fs.stat(f)).isDirectory)return o.recursive?await k(e,f,o,r,n,s):o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: is a directory -- ignored
|
|
13
13
|
`,exitCode:1}}catch{return{stdout:"",stderr:`${r}: ${t}: No such file or directory
|
|
14
|
-
`,exitCode:1}}try{
|
|
15
|
-
`,exitCode:1}}if(
|
|
16
|
-
`,exitCode:1};if(!y(
|
|
17
|
-
`,exitCode:1};let
|
|
18
|
-
`,exitCode:1}}if(
|
|
19
|
-
`,exitCode:1}}catch{}if(await e.fs.writeFile(p,
|
|
14
|
+
`,exitCode:1}}try{l=await e.fs.readFileBuffer(f)}catch{return{stdout:"",stderr:`${r}: ${t}: No such file or directory
|
|
15
|
+
`,exitCode:1}}if(n){if(!t.endsWith(u))return o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: unknown suffix -- ignored
|
|
16
|
+
`,exitCode:1};if(!y(l))return o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: not in gzip format
|
|
17
|
+
`,exitCode:1};let d;try{d=x(l)}catch(i){let c=i instanceof Error?i.message:"unknown error";return{stdout:"",stderr:`${r}: ${t}: ${c}
|
|
18
|
+
`,exitCode:1}}if(s)return{stdout:String.fromCharCode(...d),stderr:"",exitCode:0};if(o.name){let i=S(l);i.originalName?p=e.fs.resolvePath(e.cwd,i.originalName):p=f.slice(0,-u.length)}else p=f.slice(0,-u.length);if(!o.force)try{return await e.fs.stat(p),{stdout:"",stderr:`${r}: ${p} already exists; not overwritten
|
|
19
|
+
`,exitCode:1}}catch{}if(await e.fs.writeFile(p,d),!o.keep&&!s&&await e.fs.rm(f),o.verbose){let i=l.length>0?((1-l.length/d.length)*100).toFixed(1):"0.0";return{stdout:"",stderr:`${t}: ${i}% -- replaced with ${p.split("/").pop()}
|
|
20
20
|
`,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}else{if(t.endsWith(u))return o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t} already has ${u} suffix -- unchanged
|
|
21
|
-
`,exitCode:1};let
|
|
22
|
-
`,exitCode:1}}if(
|
|
23
|
-
`,exitCode:1}}catch{}if(await e.fs.writeFile(p,i),!o.keep&&!
|
|
24
|
-
`,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}}async function k(e,t,o,r,s
|
|
25
|
-
`,exitCode:1}}}if(!y(
|
|
26
|
-
`,exitCode:1};let n
|
|
27
|
-
`,stderr:"",exitCode:0}}async function
|
|
28
|
-
`,exitCode:1}}}if(!y(
|
|
29
|
-
`,exitCode:1};try{return
|
|
30
|
-
`,exitCode:0}:{stdout:"",stderr:"",exitCode:0}}catch(
|
|
31
|
-
`,exitCode:1}}}async function v(e,t,o){let r=o==="zcat"?P:o==="gunzip"?q:I;if(
|
|
32
|
-
`,a="",m=0;for(let g of u){let h=await
|
|
21
|
+
`,exitCode:1};let d=F(o),i;try{i=b(l,{level:d})}catch(c){let a=c instanceof Error?c.message:"unknown error";return{stdout:"",stderr:`${r}: ${t}: ${a}
|
|
22
|
+
`,exitCode:1}}if(s)return{stdout:String.fromCharCode(...i),stderr:"",exitCode:0};if(p=f+u,!o.force)try{return await e.fs.stat(p),{stdout:"",stderr:`${r}: ${p} already exists; not overwritten
|
|
23
|
+
`,exitCode:1}}catch{}if(await e.fs.writeFile(p,i),!o.keep&&!s&&await e.fs.rm(f),o.verbose){let c=l.length>0?((1-i.length/l.length)*100).toFixed(1):"0.0";return{stdout:"",stderr:`${t}: ${c}% -- replaced with ${p.split("/").pop()}
|
|
24
|
+
`,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}}async function k(e,t,o,r,n,s){let u=await e.fs.readdir(t),f="",p="",l=0;for(let d of u){let i=e.fs.resolvePath(t,d),c=await e.fs.stat(i);if(c.isDirectory){let a=await k(e,i,o,r,n,s);f+=a.stdout,p+=a.stderr,a.exitCode!==0&&(l=a.exitCode)}else if(c.isFile){let a=o.suffix;if(n&&!d.endsWith(a)||!n&&d.endsWith(a))continue;let m=i.startsWith(`${e.cwd}/`)?i.slice(e.cwd.length+1):i,g=await E(e,m,o,r,n,s);f+=g.stdout,p+=g.stderr,g.exitCode!==0&&(l=g.exitCode)}}return{stdout:f,stderr:p,exitCode:l}}async function O(e,t,o,r){let n;if(t==="-"||t==="")n=Uint8Array.from(e.stdin,i=>i.charCodeAt(0));else{let i=e.fs.resolvePath(e.cwd,t);try{n=await e.fs.readFileBuffer(i)}catch{return{stdout:"",stderr:`${r}: ${t}: No such file or directory
|
|
25
|
+
`,exitCode:1}}}if(!y(n))return o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: not in gzip format
|
|
26
|
+
`,exitCode:1};let s=n.length,u=D(n),f=u>0?((1-s/u)*100).toFixed(1):"0.0",l=S(n).originalName||(t==="-"?"":t.replace(/\.gz$/,""));return{stdout:`${s.toString().padStart(10)} ${u.toString().padStart(10)} ${f.padStart(5)}% ${l}
|
|
27
|
+
`,stderr:"",exitCode:0}}async function U(e,t,o,r){let n;if(t==="-"||t==="")n=Uint8Array.from(e.stdin,s=>s.charCodeAt(0));else{let s=e.fs.resolvePath(e.cwd,t);try{n=await e.fs.readFileBuffer(s)}catch{return{stdout:"",stderr:`${r}: ${t}: No such file or directory
|
|
28
|
+
`,exitCode:1}}}if(!y(n))return o.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: not in gzip format
|
|
29
|
+
`,exitCode:1};try{return x(n),o.verbose?{stdout:"",stderr:`${t}: OK
|
|
30
|
+
`,exitCode:0}:{stdout:"",stderr:"",exitCode:0}}catch(s){let u=s instanceof Error?s.message:"invalid";return{stdout:"",stderr:`${r}: ${t}: ${u}
|
|
31
|
+
`,exitCode:1}}}async function v(e,t,o){let r=o==="zcat"?P:o==="gunzip"?q:I;if(w(e))return $(r);let n=z(o,e,L);if(!n.ok)return n.error.stderr.includes("unrecognized option"),n.error;let s=n.result.flags,u=n.result.positional,f=o==="gunzip"||o==="zcat"||s.decompress||s.uncompress,p=o==="zcat"||s.stdout||s.toStdout;if(s.list){u.length===0&&(u=["-"]);let c=` compressed uncompressed ratio uncompressed_name
|
|
32
|
+
`,a="",m=0;for(let g of u){let h=await O(t,g,s,o);c+=h.stdout,a+=h.stderr,h.exitCode!==0&&(m=h.exitCode)}return{stdout:c,stderr:a,exitCode:m}}if(s.test){u.length===0&&(u=["-"]);let c="",a="",m=0;for(let g of u){let h=await U(t,g,s,o);c+=h.stdout,a+=h.stderr,h.exitCode!==0&&(m=h.exitCode)}return{stdout:c,stderr:a,exitCode:m}}u.length===0&&(u=["-"]);let l="",d="",i=0;for(let c of u){let a=await E(t,c,s,o,f,p);l+=a.stdout,d+=a.stderr,a.exitCode!==0&&(i=a.exitCode)}return{stdout:l,stderr:d,exitCode:i}}var _={name:"gzip",async execute(e,t){return v(e,t,"gzip")}},H={name:"gunzip",async execute(e,t){return v(e,t,"gunzip")}},B={name:"zcat",async execute(e,t){return v(e,t,"zcat")}};export{H as gunzipCommand,_ as gzipCommand,B as zcatCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as w,b as J}from"./chunk-ACRTDIBO.js";import{i as q}from"./chunk-NWWB2XRE.js";import{a as N}from"./chunk-
|
|
2
|
+
import{a as w,b as J}from"./chunk-ACRTDIBO.js";import{i as q}from"./chunk-NWWB2XRE.js";import{a as N}from"./chunk-5WFYIUU2.js";import"./chunk-OBH7XN5N.js";import{a as C,b as E,c as x}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";function I(s){let i=[],t=0,o=s.length;for(;t<o;){for(;t<o&&/\s/.test(s[t]);)t++;if(t>=o)break;let a=t,r=s[t];if(r==="{"||r==="["){let n=r,l=r==="{"?"}":"]",c=1,p=!1,d=!1;for(t++;t<o&&c>0;){let h=s[t];d?d=!1:h==="\\"?d=!0:h==='"'?p=!p:p||(h===n?c++:h===l&&c--),t++}if(c!==0)throw new Error(`Unexpected end of JSON input at position ${t} (unclosed ${n})`);i.push(JSON.parse(s.slice(a,t)))}else if(r==='"'){let n=!1;for(t++;t<o;){let l=s[t];if(n)n=!1;else if(l==="\\")n=!0;else if(l==='"'){t++;break}t++}i.push(JSON.parse(s.slice(a,t)))}else if(r==="-"||r>="0"&&r<="9"){for(;t<o&&/[\d.eE+-]/.test(s[t]);)t++;i.push(JSON.parse(s.slice(a,t)))}else if(s.slice(t,t+4)==="true")i.push(!0),t+=4;else if(s.slice(t,t+5)==="false")i.push(!1),t+=5;else if(s.slice(t,t+4)==="null")i.push(null),t+=4;else{let n=s.slice(t,t+10);throw new Error(`Invalid JSON at position ${a}: unexpected '${n.split(/\s/)[0]}'`)}}return i}var H={name:"jq",summary:"command-line JSON processor",usage:"jq [OPTIONS] FILTER [FILE]",options:["-r, --raw-output output strings without quotes","-c, --compact compact output (no pretty printing)","-e, --exit-status set exit status based on output","-s, --slurp read entire input into array","-n, --null-input don't read any input","-j, --join-output don't print newlines after each output","-a, --ascii force ASCII output","-S, --sort-keys sort object keys","-C, --color colorize output (ignored)","-M, --monochrome monochrome output (ignored)"," --tab use tabs for indentation"," --help display this help and exit"]};function g(s,i,t,o,a,r=0){if(s===null||s===void 0)return"null";if(typeof s=="boolean")return String(s);if(typeof s=="number")return Number.isFinite(s)?String(s):"null";if(typeof s=="string")return t?s:JSON.stringify(s);let n=a?" ":" ";if(Array.isArray(s))return s.length===0?"[]":i?`[${s.map(c=>g(c,!0,!1,o,a)).join(",")}]`:`[
|
|
3
3
|
${s.map(c=>n.repeat(r+1)+g(c,!1,!1,o,a,r+1)).join(`,
|
|
4
4
|
`)}
|
|
5
5
|
${n.repeat(r)}]`;if(typeof s=="object"){let l=Object.keys(s);return o&&(l=l.sort()),l.length===0?"{}":i?`{${l.map(p=>`${JSON.stringify(p)}:${g(s[p],!0,!1,o,a)}`).join(",")}}`:`{
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as m}from"./chunk-
|
|
2
|
+
import{a as m}from"./chunk-Y5QKO4KO.js";import"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var o=m("md5sum","md5","compute MD5 message digest");export{o as md5sumCommand};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as E,b as R,c as A}from"./chunk-CTLU5QUH.js";import{a as L,b as _,c as k}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.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(`
|
|
3
|
+
`)}
|
|
4
|
+
`}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}
|
|
5
|
+
`,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.
|
|
6
|
+
`,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(`
|
|
7
|
+
`);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}
|
|
8
|
+
`,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(`
|
|
9
|
+
`).filter(d=>d.length>0);l.push(...w)}catch{return{stdout:"",stderr:`rg: ${u}: No such file or directory
|
|
10
|
+
`,exitCode:2}}if(l.length===0)return n.patternFiles.length>0?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`rg: no pattern given
|
|
11
|
+
`,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(", ")}
|
|
12
|
+
`,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":`
|
|
13
|
+
`;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(`
|
|
14
|
+
`);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}
|
|
15
|
+
`},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":`
|
|
16
|
+
`;i+=`${g}${C}`}else s.filesWithoutMatch||(s.heading&&!s.noFilename&&(i+=`${g}
|
|
17
|
+
`),i+=x.output)}else if(s.filesWithoutMatch){let C=s.nullSeparator?"\0":`
|
|
18
|
+
`;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(`
|
|
19
|
+
`)}
|
|
20
|
+
`);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(`
|
|
21
|
+
`);p+=`${u}
|
|
22
|
+
`}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.
|
|
23
|
+
Unlike grep, rg is recursive by default and respects .gitignore files.
|
|
24
|
+
|
|
25
|
+
EXAMPLES:
|
|
26
|
+
rg foo Search for 'foo' in current directory
|
|
27
|
+
rg foo src/ Search in src/ directory
|
|
28
|
+
rg -i foo Case-insensitive search
|
|
29
|
+
rg -w foo Match whole words only
|
|
30
|
+
rg -t js foo Search only JavaScript files
|
|
31
|
+
rg -g '*.ts' foo Search files matching glob
|
|
32
|
+
rg --hidden foo Include hidden files
|
|
33
|
+
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,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as m}from"./chunk-
|
|
2
|
+
import{a as m}from"./chunk-Y5QKO4KO.js";import"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var e=m("sha1sum","sha1","compute SHA1 message digest");export{e as sha1sumCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as m}from"./chunk-
|
|
2
|
+
import{a as m}from"./chunk-Y5QKO4KO.js";import"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var e=m("sha256sum","sha256","compute SHA256 message digest");export{e as sha256sumCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{b as O}from"./chunk-
|
|
2
|
+
import{b as O}from"./chunk-5WFYIUU2.js";import"./chunk-OBH7XN5N.js";import{a as F,b as N,c as k}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var P={"":1,k:1024,m:1048576,g:1073741824,t:1099511627776,p:0x4000000000000,e:1152921504606847e3},V={jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12};function w(u){let r=u.trim(),e=r.match(/^([+-]?\d*\.?\d+)\s*([kmgtpeKMGTPE])?[iI]?[bB]?$/);if(!e){let n=parseFloat(r);return Number.isNaN(n)?0:n}let l=parseFloat(e[1]),s=(e[2]||"").toLowerCase(),i=P[s]||1;return l*i}function L(u){let r=u.trim().toLowerCase().slice(0,3);return V[r]||0}function D(u,r){let e=u.split(/(\d+)/),l=r.split(/(\d+)/),s=Math.max(e.length,l.length);for(let i=0;i<s;i++){let n=e[i]||"",d=l[i]||"",o=/^\d+$/.test(n)?parseInt(n,10):null,c=/^\d+$/.test(d)?parseInt(d,10):null;if(o!==null&&c!==null){if(o!==c)return o-c}else if(n!==d)return n.localeCompare(d)}return 0}function x(u){return u.replace(/[^a-zA-Z0-9\s]/g,"")}function v(u,r,e){let l=e!==null?e:/\s+/,s=u.split(l),i=r.startField-1;if(i>=s.length)return"";if(r.endField===void 0){let o=s[i]||"";return r.startChar!==void 0&&(o=o.slice(r.startChar-1)),r.ignoreLeading&&(o=o.trimStart()),o}let n=Math.min(r.endField-1,s.length-1),d="";for(let o=i;o<=n&&o<s.length;o++){let c=s[o]||"";if(o===i&&r.startChar!==void 0&&(c=c.slice(r.startChar-1)),o===n&&r.endChar!==void 0){let t=o===i&&r.startChar!==void 0?r.endChar-r.startChar+1:r.endChar;c=c.slice(0,t)}o>i&&(d+=e||" "),d+=c}return r.ignoreLeading&&(d=d.trimStart()),d}function I(u,r,e){let l=u,s=r;if(e.dictionaryOrder&&(l=x(l),s=x(s)),e.ignoreCase&&(l=l.toLowerCase(),s=s.toLowerCase()),e.monthSort){let i=L(l),n=L(s);return i-n}if(e.humanNumeric){let i=w(l),n=w(s);return i-n}if(e.versionSort)return D(l,s);if(e.numeric){let i=parseFloat(l)||0,n=parseFloat(s)||0;return i-n}return l.localeCompare(s)}function M(u){let{keys:r,fieldDelimiter:e,numeric:l,ignoreCase:s,reverse:i,humanNumeric:n,versionSort:d,dictionaryOrder:o,monthSort:c,ignoreLeadingBlanks:t,stable:a}=u;return(f,S)=>{let g=f,b=S;if(t&&(g=g.trimStart(),b=b.trimStart()),r.length===0){let h=I(g,b,{numeric:l,ignoreCase:s,humanNumeric:n,versionSort:d,dictionaryOrder:o,monthSort:c});if(h!==0)return i?-h:h;if(!a){let p=f.localeCompare(S);return i?-p:p}return 0}for(let m of r){let h=v(g,m,e),p=v(b,m,e);m.ignoreLeading&&(h=h.trimStart(),p=p.trimStart());let B={numeric:m.numeric??l,ignoreCase:m.ignoreCase??s,humanNumeric:m.humanNumeric??n,versionSort:m.versionSort??d,dictionaryOrder:m.dictionaryOrder??o,monthSort:m.monthSort??c},A=m.reverse??i,y=I(h,p,B);if(y!==0)return A?-y:y}if(!a){let m=f.localeCompare(S);return i?-m:m}return 0}}function E(u,r){if(r.keys.length===0){if(r.ignoreCase){let s=new Set;return u.filter(i=>{let n=i.toLowerCase();return s.has(n)?!1:(s.add(n),!0)})}return[...new Set(u)]}let e=r.keys[0],l=new Set;return u.filter(s=>{let i=v(s,e,r.fieldDelimiter);return(e.ignoreCase??r.ignoreCase)&&(i=i.toLowerCase()),l.has(i)?!1:(l.add(i),!0)})}function C(u){let r={startField:1},e="",l=u,s=l.match(/([bdfhMnrV]+)$/);s&&(e=s[1],l=l.slice(0,-e.length)),e.includes("n")&&(r.numeric=!0),e.includes("r")&&(r.reverse=!0),e.includes("f")&&(r.ignoreCase=!0),e.includes("b")&&(r.ignoreLeading=!0),e.includes("h")&&(r.humanNumeric=!0),e.includes("V")&&(r.versionSort=!0),e.includes("d")&&(r.dictionaryOrder=!0),e.includes("M")&&(r.monthSort=!0);let i=l.split(",");if(i.length===0||i[0]==="")return null;let n=i[0].split("."),d=parseInt(n[0],10);if(Number.isNaN(d)||d<1)return null;if(r.startField=d,n.length>1&&n[1]){let o=parseInt(n[1],10);!Number.isNaN(o)&&o>=1&&(r.startChar=o)}if(i.length>1&&i[1]){let o=i[1],c=o.match(/([bdfhMnrV]+)$/);if(c){let a=c[1];a.includes("n")&&(r.numeric=!0),a.includes("r")&&(r.reverse=!0),a.includes("f")&&(r.ignoreCase=!0),a.includes("b")&&(r.ignoreLeading=!0),a.includes("h")&&(r.humanNumeric=!0),a.includes("V")&&(r.versionSort=!0),a.includes("d")&&(r.dictionaryOrder=!0),a.includes("M")&&(r.monthSort=!0),o=o.slice(0,-a.length)}let t=o.split(".");if(t[0]){let a=parseInt(t[0],10);if(!Number.isNaN(a)&&a>=1&&(r.endField=a),t.length>1&&t[1]){let f=parseInt(t[1],10);!Number.isNaN(f)&&f>=1&&(r.endChar=f)}}}return r}var q={name:"sort",summary:"sort lines of text files",usage:"sort [OPTION]... [FILE]...",options:["-b, --ignore-leading-blanks ignore leading blanks","-d, --dictionary-order consider only blanks and alphanumeric characters","-f, --ignore-case fold lower case to upper case characters","-h, --human-numeric-sort compare human readable numbers (e.g., 2K 1G)","-M, --month-sort compare (unknown) < 'JAN' < ... < 'DEC'","-n, --numeric-sort compare according to string numerical value","-r, --reverse reverse the result of comparisons","-V, --version-sort natural sort of (version) numbers within text","-c, --check check for sorted input; do not sort","-o, --output=FILE write result to FILE instead of stdout","-s, --stable stabilize sort by disabling last-resort comparison","-u, --unique output only unique lines","-k, --key=KEYDEF sort via a key; KEYDEF gives location and type","-t, --field-separator=SEP use SEP as field separator"," --help display this help and exit"],description:`KEYDEF is F[.C][OPTS][,F[.C][OPTS]]
|
|
3
3
|
F is a field number (1-indexed)
|
|
4
4
|
C is a character position within the field (1-indexed)
|
|
5
5
|
OPTS can be: b d f h M n r V (per-key modifiers)
|