zen-code 4.7.4 → 4.8.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/dist/app.js +271 -0
- package/dist/chunk-0fhpz98a.js +2 -0
- package/dist/chunk-15smn69q.js +31 -0
- package/dist/chunk-3ep2tag7.js +2 -0
- package/dist/chunk-3jek9sxm.js +2 -0
- package/dist/chunk-3n2b4eb4.js +2 -0
- package/dist/chunk-3znrwnd8.js +1 -0
- package/dist/chunk-4b8yaknt.js +1 -0
- package/dist/chunk-5fqt5yg1.js +81 -0
- package/dist/chunk-5nzs0q25.js +1 -0
- package/dist/chunk-5wn1nfqy.js +6 -0
- package/dist/chunk-6ty22kkt.js +4 -0
- package/dist/chunk-70a0e941.js +1 -0
- package/dist/chunk-7dp8kq2f.js +2 -0
- package/dist/chunk-8nhayyat.js +1 -0
- package/dist/chunk-9k57afdm.js +2 -0
- package/dist/chunk-9kc9cea3.js +7 -0
- package/dist/chunk-bgpcx3bm.js +2 -0
- package/dist/chunk-bjywwcgn.js +26 -0
- package/dist/chunk-c9q11tk2.js +88 -0
- package/dist/chunk-cga0m5sy.js +1 -0
- package/dist/chunk-cze71w02.js +2 -0
- package/dist/chunk-czz2fs2w.js +7 -0
- package/dist/chunk-dh3jz71n.js +1 -0
- package/dist/chunk-e0sqjq2h.js +1 -0
- package/dist/chunk-efhkdw2z.js +1 -0
- package/dist/chunk-ew7249h9.js +1 -0
- package/dist/chunk-h5nnz4dy.js +1 -0
- package/dist/chunk-hww94vjn.js +1 -0
- package/dist/chunk-j1n8jp1w.js +253 -0
- package/dist/chunk-j204fejq.js +1 -0
- package/dist/chunk-jkbtx9va.js +2 -0
- package/dist/chunk-k67epfhc.js +1 -0
- package/dist/chunk-kbs4px1b.js +6 -0
- package/dist/chunk-keqk70wm.js +2 -0
- package/dist/chunk-kxk71nn0.js +1 -0
- package/dist/chunk-mg8zpgaz.js +1 -0
- package/dist/chunk-n1d8xx5k.js +2 -0
- package/dist/chunk-ndtwq2zx.js +2 -0
- package/dist/chunk-pdkbrds7.js +1 -0
- package/dist/chunk-q8arjxg1.js +23 -0
- package/dist/chunk-rdc9pxf6.js +1 -0
- package/dist/chunk-rrkzfahh.js +91 -0
- package/dist/chunk-s3fyfrka.js +2 -0
- package/dist/chunk-sft6ep0c.js +310 -0
- package/dist/chunk-vc384abg.js +3 -0
- package/dist/chunk-vjj00e3e.js +6 -0
- package/dist/chunk-vkng13p1.js +424 -0
- package/dist/chunk-wbn1hbxf.js +1 -0
- package/dist/chunk-wwn7gw8g.js +274 -0
- package/dist/chunk-yaa4eesd.js +2 -0
- package/dist/chunk-yvhq458c.js +25 -0
- package/dist/cli.js +2 -0
- package/dist/nonInteractive.js +4 -0
- package/dist/zen-keyboard.js +3 -0
- package/package.json +88 -87
- package/LICENSE +0 -201
- package/dist/FileSystemPluginStore-ChortK7z.mjs +0 -64
- package/dist/FileSystemSkillStore-Dl5briBv.mjs +0 -108
- package/dist/MultiLineTextInput-CL8nm9nv.mjs +0 -24492
- package/dist/_commonjsHelpers-DQNKXVTB.mjs +0 -33
- package/dist/app-CK3nD8Gj.mjs +0 -22428
- package/dist/checkpoint-C5AFBYE--CczNxXBB.mjs +0 -355
- package/dist/checkpoint-DxiUsHMy-B5iaccT2.mjs +0 -394
- package/dist/cli.mjs +0 -57
- package/dist/devtools-CzaVuYnh.mjs +0 -2667
- package/dist/graphBuilder-DJoMXf6J.mjs +0 -28909
- package/dist/index-BPG5Np-8.mjs +0 -144
- package/dist/index-Dxfhvdx8.mjs +0 -23
- package/dist/index-F6_SKYUd.mjs +0 -463
- package/dist/load-iYJqYrjn.mjs +0 -119
- package/dist/memories-CaHDnBK1.mjs +0 -115
- package/dist/metadata-XVTVXthy.mjs +0 -6
- package/dist/nonInteractive.mjs +0 -55
- package/dist/pg-adapter-BFtir1GE-BbUXBpaX.mjs +0 -60
- package/dist/queue-DySatFkr-CG2GdO4P.mjs +0 -106
- package/dist/remote-threads-CrG03ZS7-C9duTCnB.mjs +0 -157
- package/dist/shallow-G4eKoZ7M.mjs +0 -331
- package/dist/shallow-checkpoint-BEhTdp7z-DfHxnfoU.mjs +0 -383
- package/dist/sqlite-adapter-oBA95xba-BrBWorSV.mjs +0 -82
- package/dist/subTasks-DNjIN4eU.mjs +0 -18
- package/dist/zen-code.mjs +0 -3
- package/dist/zen-keyboard.mjs +0 -13
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import{Ma as c0}from"./chunk-sft6ep0c.js";import{rb as e}from"./chunk-cze71w02.js";import{AgentPackage as BQ,MemoryStorage as AQ}from"@langgraph-js/standard-agent";import{tool as p0}from"@langchain/core/tools";import{z as a}from"zod";import{execa as F$}from"execa";import{execa as i0}from"execa";var f=new Map;function n0($){let Q=process.platform==="win32";try{if(Q)e("child_process").spawnSync("taskkill",["/F","/T","/PID",String($)],{timeout:5000});else try{process.kill(-$,"SIGKILL")}catch{try{process.kill($,"SIGKILL")}catch{}}}catch(X){console.error(`[bash_manager] Failed to kill process tree ${$}:`,X)}}async function f2($){let Q=process.platform==="win32";try{if(Q)await i0("taskkill",["/F","/T","/PID",String($)],{reject:!1,timeout:5000});else{try{process.kill(-$,"SIGTERM")}catch{try{process.kill($,"SIGTERM")}catch{return}}await new Promise((X)=>setTimeout(X,500));try{process.kill($,0);try{process.kill(-$,"SIGKILL")}catch{process.kill($,"SIGKILL")}}catch{}}}catch(X){console.error(`[bash_manager] Failed to kill process tree ${$}:`,X)}}function O$($,Q){let X=f.get($);if(!X){console.error(`[bash_manager] Process ${$} not found`);return}if(X.timer)clearTimeout(X.timer);X.timeout=Q,X.timer=setTimeout(async()=>{console.log(`[bash_manager] Process ${$} timed out after ${Q}ms, force killing...`),await f2($),f.delete($)},Q)}function X$($){let Q=f.get($);if(Q?.timer)clearTimeout(Q.timer),Q.timer=void 0,Q.timeout=void 0}async function a0(){let $=[];for(let[Q,X]of f.entries()){if(X.timer)clearTimeout(X.timer);$.push(f2(Q)),console.log(`[bash_manager] Killing background process ${Q}`)}await Promise.all($),f.clear()}function Q$(){for(let[$,Q]of f.entries()){if(Q.timer)clearTimeout(Q.timer);n0($),console.log(`[bash_manager] Killed background process ${$}`)}f.clear()}function s0(){process.on("beforeExit",async()=>{await a0()}),process.on("exit",()=>{Q$()}),process.on("SIGINT",()=>{Q$()}),process.on("SIGTERM",()=>{Q$()})}if(!process.env.__BASH_MANAGER_CLEANUP_REGISTERED__)s0(),process.env.__BASH_MANAGER_CLEANUP_REGISTERED__="true";var H2=process.platform==="win32",R$=H2?"cmd.exe":"/bin/bash",T$=H2?["/d","/s","/c"]:["-c"],f$=p0(async({command:$,timeout:Q,run_in_background:X,kill_process_id:q,get_output_id:Z,filter:V})=>{if(q){let J=parseInt(q,10);if(!f.get(J))return`Error: No background process found with ID ${q}.`;return X$(J),await f2(J),f.delete(J),`Successfully killed process with ID ${q}.`}if(Z){let J=parseInt(Z,10),Y=f.get(J);if(!Y)return`Error: No background process found with ID ${Z}.`;let z=Y.stdout.join(""),H=Y.stderr.join("");if(Y.stdout=[],Y.stderr=[],V){let K=new RegExp(V);z=z.split(`
|
|
2
|
+
`).filter((j)=>K.test(j)).join(`
|
|
3
|
+
`),H=H.split(`
|
|
4
|
+
`).filter((j)=>K.test(j)).join(`
|
|
5
|
+
`)}let W="";if(z)W+=`STDOUT:
|
|
6
|
+
${z}
|
|
7
|
+
`;if(H)W+=`STDERR:
|
|
8
|
+
${H}
|
|
9
|
+
`;return W||"No new output since last check."}if(!$)return"Error: 'command' argument is required unless using 'kill_process_id' or 'get_output_id'.";if(X)try{let J=F$(R$,[...T$,$],{timeout:Q,reject:!1,windowsVerbatimArguments:H2,detached:!H2});if(!J.pid)return"Failed to start command in background.";let Y={process:J,stdout:[],stderr:[]};if(f.set(J.pid,Y),J.stdout?.on("data",(z)=>{Y.stdout.push(z.toString())}),J.stderr?.on("data",(z)=>{Y.stderr.push(z.toString())}),J.on("exit",(z,H)=>{console.log(`[bash_tool] Background process ${J.pid} exited with code ${z}, signal ${H}`),X$(J.pid)}),Q&&Q>0)O$(J.pid,Q);return`Command started in background with ID: ${J.pid}${Q?`, timeout: ${Q}ms`:""}`}catch(J){return`Error starting background command: ${J}`}else try{let J=await F$(R$,[...T$,$],{timeout:Q,reject:!1,windowsVerbatimArguments:H2});if(J.exitCode!==0)return J.stderr;return J.stdout}catch(J){return`Error executing command: ${J}`}},{name:"terminal",description:`Executes commands in a persistent shell session (Bash on Linux/macOS, CMD on Windows).
|
|
10
|
+
Features:
|
|
11
|
+
- Run commands (foreground or background)
|
|
12
|
+
- Retrieve background process output
|
|
13
|
+
- Kill background processes
|
|
14
|
+
- Cross-platform support (auto-detects OS)
|
|
15
|
+
- Auto-cleanup: All background processes killed on process exit (SIGINT/SIGTERM)
|
|
16
|
+
|
|
17
|
+
Usage:
|
|
18
|
+
1. Run Command: Provide \`command\`. Optional: \`run_in_background\`, \`timeout\`.
|
|
19
|
+
- Foreground: Waits for completion or timeout (default 120s)
|
|
20
|
+
- Background: Returns PID immediately, auto-kills after timeout if specified
|
|
21
|
+
2. Check Output: Provide \`get_output_id\`. Optional: \`filter\`.
|
|
22
|
+
3. Kill Process: Provide \`kill_process_id\`.
|
|
23
|
+
|
|
24
|
+
Notes:
|
|
25
|
+
- For file paths with spaces, ALWAYS use quotes: "path/to file"
|
|
26
|
+
- Avoid interactive commands (like top, vim)
|
|
27
|
+
- Use '&&' or ';' to chain commands (PowerShell/CMD syntax varies, simple chaining often works)
|
|
28
|
+
- CAN'T BATCH CALL THIS TOOL!
|
|
29
|
+
`,schema:a.object({description:a.string().describe("what you want to do"),command:a.string().optional().describe("The command to execute (required for running commands)"),timeout:a.number().optional().describe("Timeout in ms (default: 120000)"),run_in_background:a.boolean().optional().describe("Run command in background"),kill_process_id:a.string().optional().describe("ID of process to kill"),get_output_id:a.string().optional().describe("ID of process to get output from"),filter:a.string().optional().describe("Regex to filter output (only for get_output_id)")})});var N$=[f$];import{tool as r0}from"@langchain/core/tools";import{z as W2}from"zod";import{promises as j2}from"fs";import y$ from"path";var e0=W2.object({operation:W2.enum(["create","list","exists"]).describe("The folder operation to perform"),folder_path:W2.string().describe("The absolute path to the folder"),description:W2.string().optional().describe("What you want to do"),recursive:W2.boolean().default(!0).optional().describe("For create: create parent directories if they do not exist")}).strict(),D$=r0(async({operation:$,folder_path:Q,recursive:X=!0})=>{try{let q=y$.resolve(Q);switch($){case"create":return await j2.mkdir(q,{recursive:X}),`✓ Folder created successfully at: ${q}`;case"exists":try{await j2.access(q);let Z=await j2.stat(q);return`✓ Folder exists at: ${q}
|
|
30
|
+
Type: ${Z.isDirectory()?"Directory":"File"}`}catch{return`✗ Folder does not exist at: ${q}`}case"list":try{let Z=await j2.readdir(q,{withFileTypes:!0});if(Z.length===0)return`Folder is empty: ${q}`;let V=[];V.push(`\uD83D\uDCC1 ${q}
|
|
31
|
+
`);let J=[],Y=[];for(let z of Z){let H=y$.join(q,z.name);try{let W=await j2.stat(H),K=W.size,j=W.mtime.toLocaleDateString(),U=`${z.isDirectory()?"\uD83D\uDCC1":"\uD83D\uDCC4"} ${z.name}${z.isDirectory()?"/":""} (${K} bytes, ${j})`;if(z.isDirectory())J.push(U);else Y.push(U)}catch(W){Y.push(`⚠️ ${z.name} (unreadable)`)}}if(J.length>0)V.push("Directories:"),J.forEach((z)=>V.push(` ${z}`)),V.push("");if(Y.length>0)V.push("Files:"),Y.forEach((z)=>V.push(` ${z}`));return V.push(`
|
|
32
|
+
Total: ${J.length} directories, ${Y.length} files`),V.join(`
|
|
33
|
+
`)}catch(Z){if(Z.code==="ENOENT")return`✗ Folder not found: ${q}`;if(Z.code==="ENOTDIR")return`✗ Path exists but is not a folder: ${q}`;throw Z}default:return`✗ Unknown operation: ${$}`}}catch(q){if(q.code==="ENOENT")return`✗ Folder not found: ${Q}`;if(q.code==="EACCES")return`✗ Permission denied: ${Q}`;return`✗ Error: ${q.message}`}},{name:"folder_operations",description:`Unified folder operations tool supporting create, list, and existence check.
|
|
34
|
+
|
|
35
|
+
**Operations:**
|
|
36
|
+
- create: Create a folder (supports nested directory creation)
|
|
37
|
+
- list: List all files and subdirectories with metadata
|
|
38
|
+
- exists: Check if a folder exists
|
|
39
|
+
|
|
40
|
+
**Usage Examples:**
|
|
41
|
+
- Create nested folders: {operation: "create", folder_path: "/path/to/nested/folder"}
|
|
42
|
+
- List contents: {operation: "list", folder_path: "/path/to/folder"}
|
|
43
|
+
- Check existence: {operation: "exists", folder_path: "/path/to/folder"}
|
|
44
|
+
|
|
45
|
+
**Important:**
|
|
46
|
+
- All folder paths must be absolute paths
|
|
47
|
+
- Create operation is recursive (creates parent directories if needed)
|
|
48
|
+
- List operation shows file sizes and modification dates
|
|
49
|
+
- Delete operations are not supported for safety reasons. Use terminal commands with user approval if needed.`,schema:e0});import{tool as h5}from"@langchain/core/tools";import{z as e2}from"zod";var q$=($,Q,X)=>{let q=$ instanceof RegExp?S$($,X):$,Z=Q instanceof RegExp?S$(Q,X):Q,V=q!==null&&Z!=null&&t0(q,Z,X);return V&&{start:V[0],end:V[1],pre:X.slice(0,V[0]),body:X.slice(V[0]+q.length,V[1]),post:X.slice(V[1]+Z.length)}},S$=($,Q)=>{let X=Q.match($);return X?X[0]:null},t0=($,Q,X)=>{let q,Z,V,J=void 0,Y,z=X.indexOf($),H=X.indexOf(Q,z+1),W=z;if(z>=0&&H>0){if($===Q)return[z,H];q=[],V=X.length;while(W>=0&&!Y){if(W===z)q.push(W),z=X.indexOf($,W+1);else if(q.length===1){let K=q.pop();if(K!==void 0)Y=[K,H]}else{if(Z=q.pop(),Z!==void 0&&Z<V)V=Z,J=H;H=X.indexOf(Q,W+1)}W=z<H&&z>=0?z:H}if(q.length&&J!==void 0)Y=[V,J]}return Y};var P$="\x00SLASH"+Math.random()+"\x00",b$="\x00OPEN"+Math.random()+"\x00",V$="\x00CLOSE"+Math.random()+"\x00",h$="\x00COMMA"+Math.random()+"\x00",d$="\x00PERIOD"+Math.random()+"\x00",$1=new RegExp(P$,"g"),Q1=new RegExp(b$,"g"),X1=new RegExp(V$,"g"),q1=new RegExp(h$,"g"),Z1=new RegExp(d$,"g"),V1=/\\\\/g,J1=/\\{/g,Y1=/\\}/g,z1=/\\,/g,K1=/\\./g,H1=1e5;function Z$($){return!isNaN($)?parseInt($,10):$.charCodeAt(0)}function W1($){return $.replace(V1,P$).replace(J1,b$).replace(Y1,V$).replace(z1,h$).replace(K1,d$)}function j1($){return $.replace($1,"\\").replace(Q1,"{").replace(X1,"}").replace(q1,",").replace(Z1,".")}function E$($){if(!$)return[""];let Q=[],X=q$("{","}",$);if(!X)return $.split(",");let{pre:q,body:Z,post:V}=X,J=q.split(",");J[J.length-1]+="{"+Z+"}";let Y=E$(V);if(V.length)J[J.length-1]+=Y.shift(),J.push.apply(J,Y);return Q.push.apply(Q,J),Q}function g$($,Q={}){if(!$)return[];let{max:X=H1}=Q;if($.slice(0,2)==="{}")$="\\{\\}"+$.slice(2);return u2(W1($),X,!0).map(j1)}function u1($){return"{"+$+"}"}function v1($){return/^-?0\d/.test($)}function U1($,Q){return $<=Q}function G1($,Q){return $>=Q}function u2($,Q,X){let q=[],Z=q$("{","}",$);if(!Z)return[$];let V=Z.pre,J=Z.post.length?u2(Z.post,Q,!1):[""];if(/\$$/.test(Z.pre))for(let Y=0;Y<J.length&&Y<Q;Y++){let z=V+"{"+Z.body+"}"+J[Y];q.push(z)}else{let Y=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(Z.body),z=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(Z.body),H=Y||z,W=Z.body.indexOf(",")>=0;if(!H&&!W){if(Z.post.match(/,(?!,).*\}/))return $=Z.pre+"{"+Z.body+V$+Z.post,u2($,Q,!0);return[$]}let K;if(H)K=Z.body.split(/\.\./);else if(K=E$(Z.body),K.length===1&&K[0]!==void 0){if(K=u2(K[0],Q,!1).map(u1),K.length===1)return J.map((u)=>Z.pre+K[0]+u)}let j;if(H&&K[0]!==void 0&&K[1]!==void 0){let u=Z$(K[0]),U=Z$(K[1]),v=Math.max(K[0].length,K[1].length),k=K.length===3&&K[2]!==void 0?Math.abs(Z$(K[2])):1,G=U1;if(U<u)k*=-1,G=G1;let B=K.some(v1);j=[];for(let A=u;G(A,U);A+=k){let C;if(z){if(C=String.fromCharCode(A),C==="\\")C=""}else if(C=String(A),B){let n=v-C.length;if(n>0){let c=Array(n+1).join("0");if(A<0)C="-"+c+C.slice(1);else C=c+C}}j.push(C)}}else{j=[];for(let u=0;u<K.length;u++)j.push.apply(j,u2(K[u],Q,!1))}for(let u=0;u<j.length;u++)for(let U=0;U<J.length&&q.length<Q;U++){let v=V+j[u]+J[U];if(!X||H||v)q.push(v)}}return q}var v2=($)=>{if(typeof $!=="string")throw TypeError("invalid pattern");if($.length>65536)throw TypeError("pattern is too long")};var w1={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},U2=($)=>$.replace(/[[\]\\-]/g,"\\$&"),k1=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),l$=($)=>$.join(""),c$=($,Q)=>{let X=Q;if($.charAt(X)!=="[")throw Error("not in a brace expression");let q=[],Z=[],V=X+1,J=!1,Y=!1,z=!1,H=!1,W=X,K="";$:while(V<$.length){let v=$.charAt(V);if((v==="!"||v==="^")&&V===X+1){H=!0,V++;continue}if(v==="]"&&J&&!z){W=V+1;break}if(J=!0,v==="\\"){if(!z){z=!0,V++;continue}}if(v==="["&&!z){for(let[k,[G,w,B]]of Object.entries(w1))if($.startsWith(k,V)){if(K)return["$.",!1,$.length-X,!0];if(V+=k.length,B)Z.push(G);else q.push(G);Y=Y||w;continue $}}if(z=!1,K){if(v>K)q.push(U2(K)+"-"+U2(v));else if(v===K)q.push(U2(v));K="",V++;continue}if($.startsWith("-]",V+1)){q.push(U2(v+"-")),V+=2;continue}if($.startsWith("-",V+1)){K=v,V+=2;continue}q.push(U2(v)),V++}if(W<V)return["",!1,0,!1];if(!q.length&&!Z.length)return["$.",!1,$.length-X,!0];if(Z.length===0&&q.length===1&&/^\\?.$/.test(q[0])&&!H){let v=q[0].length===2?q[0].slice(-1):q[0];return[k1(v),!1,W-X,!1]}let j="["+(H?"^":"")+l$(q)+"]",u="["+(H?"":"^")+l$(Z)+"]";return[q.length&&Z.length?"("+j+"|"+u+")":q.length?j:u,Y,W-X,!0]};var b=($,{windowsPathsNoEscape:Q=!1,magicalBraces:X=!0}={})=>{if(X)return Q?$.replace(/\[([^\/\\])\]/g,"$1"):$.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");return Q?$.replace(/\[([^\/\\{}])\]/g,"$1"):$.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1")};var C1=new Set(["!","?","+","*","@"]),o$=($)=>C1.has($),B1="(?!(?:^|/)\\.\\.?(?:$|/))",N2="(?!\\.)",A1=new Set(["[","."]),m1=new Set(["..","."]),L1=new Set("().*{}+?[]^$\\!"),_1=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),J$="[^/]",i$=J$+"*?",n$=J$+"+?";class M{type;#$;#X;#V=!1;#Z=[];#J;#B;#w;#H=!1;#Y;#j;#W=!1;constructor($,Q,X={}){if(this.type=$,$)this.#X=!0;if(this.#J=Q,this.#$=this.#J?this.#J.#$:this,this.#Y=this.#$===this?X:this.#$.#Y,this.#w=this.#$===this?[]:this.#$.#w,$==="!"&&!this.#$.#H)this.#w.push(this);this.#B=this.#J?this.#J.#Z.length:0}get hasMagic(){if(this.#X!==void 0)return this.#X;for(let $ of this.#Z){if(typeof $==="string")continue;if($.type||$.hasMagic)return this.#X=!0}return this.#X}toString(){if(this.#j!==void 0)return this.#j;if(!this.type)return this.#j=this.#Z.map(($)=>String($)).join("");else return this.#j=this.type+"("+this.#Z.map(($)=>String($)).join("|")+")"}#z(){if(this!==this.#$)throw Error("should only call on root");if(this.#H)return this;this.toString(),this.#H=!0;let $;while($=this.#w.pop()){if($.type!=="!")continue;let Q=$,X=Q.#J;while(X){for(let q=Q.#B+1;!X.type&&q<X.#Z.length;q++)for(let Z of $.#Z){if(typeof Z==="string")throw Error("string part in extglob AST??");Z.copyIn(X.#Z[q])}Q=X,X=Q.#J}}return this}push(...$){for(let Q of $){if(Q==="")continue;if(typeof Q!=="string"&&!(Q instanceof M&&Q.#J===this))throw Error("invalid part: "+Q);this.#Z.push(Q)}}toJSON(){let $=this.type===null?this.#Z.slice().map((Q)=>typeof Q==="string"?Q:Q.toJSON()):[this.type,...this.#Z.map((Q)=>Q.toJSON())];if(this.isStart()&&!this.type)$.unshift([]);if(this.isEnd()&&(this===this.#$||this.#$.#H&&this.#J?.type==="!"))$.push({});return $}isStart(){if(this.#$===this)return!0;if(!this.#J?.isStart())return!1;if(this.#B===0)return!0;let $=this.#J;for(let Q=0;Q<this.#B;Q++){let X=$.#Z[Q];if(!(X instanceof M&&X.type==="!"))return!1}return!0}isEnd(){if(this.#$===this)return!0;if(this.#J?.type==="!")return!0;if(!this.#J?.isEnd())return!1;if(!this.type)return this.#J?.isEnd();let $=this.#J?this.#J.#Z.length:0;return this.#B===$-1}copyIn($){if(typeof $==="string")this.push($);else this.push($.clone(this))}clone($){let Q=new M(this.type,$);for(let X of this.#Z)Q.copyIn(X);return Q}static#q($,Q,X,q){let Z=!1,V=!1,J=-1,Y=!1;if(Q.type===null){let j=X,u="";while(j<$.length){let U=$.charAt(j++);if(Z||U==="\\"){Z=!Z,u+=U;continue}if(V){if(j===J+1){if(U==="^"||U==="!")Y=!0}else if(U==="]"&&!(j===J+2&&Y))V=!1;u+=U;continue}else if(U==="["){V=!0,J=j,Y=!1,u+=U;continue}if(!q.noext&&o$(U)&&$.charAt(j)==="("){Q.push(u),u="";let v=new M(U,Q);j=M.#q($,v,j,q),Q.push(v);continue}u+=U}return Q.push(u),j}let z=X+1,H=new M(null,Q),W=[],K="";while(z<$.length){let j=$.charAt(z++);if(Z||j==="\\"){Z=!Z,K+=j;continue}if(V){if(z===J+1){if(j==="^"||j==="!")Y=!0}else if(j==="]"&&!(z===J+2&&Y))V=!1;K+=j;continue}else if(j==="["){V=!0,J=z,Y=!1,K+=j;continue}if(o$(j)&&$.charAt(z)==="("){H.push(K),K="";let u=new M(j,H);H.push(u),z=M.#q($,u,z,q);continue}if(j==="|"){H.push(K),K="",W.push(H),H=new M(null,Q);continue}if(j===")"){if(K===""&&Q.#Z.length===0)Q.#W=!0;return H.push(K),K="",Q.push(...W,H),z}K+=j}return Q.type=null,Q.#X=void 0,Q.#Z=[$.substring(X-1)],z}static fromGlob($,Q={}){let X=new M(null,void 0,Q);return M.#q($,X,0,Q),X}toMMPattern(){if(this!==this.#$)return this.#$.toMMPattern();let $=this.toString(),[Q,X,q,Z]=this.toRegExpSource();if(!(q||this.#X||this.#Y.nocase&&!this.#Y.nocaseMagicOnly&&$.toUpperCase()!==$.toLowerCase()))return X;let J=(this.#Y.nocase?"i":"")+(Z?"u":"");return Object.assign(new RegExp(`^${Q}$`,J),{_src:Q,_glob:$})}get options(){return this.#Y}toRegExpSource($){let Q=$??!!this.#Y.dot;if(this.#$===this)this.#z();if(!this.type){let Y=this.isStart()&&this.isEnd()&&!this.#Z.some((j)=>typeof j!=="string"),z=this.#Z.map((j)=>{let[u,U,v,k]=typeof j==="string"?M.#A(j,this.#X,Y):j.toRegExpSource($);return this.#X=this.#X||v,this.#V=this.#V||k,u}).join(""),H="";if(this.isStart()){if(typeof this.#Z[0]==="string"){if(!(this.#Z.length===1&&m1.has(this.#Z[0]))){let u=A1,U=Q&&u.has(z.charAt(0))||z.startsWith("\\.")&&u.has(z.charAt(2))||z.startsWith("\\.\\.")&&u.has(z.charAt(4)),v=!Q&&!$&&u.has(z.charAt(0));H=U?B1:v?N2:""}}}let W="";if(this.isEnd()&&this.#$.#H&&this.#J?.type==="!")W="(?:$|\\/)";return[H+z+W,b(z),this.#X=!!this.#X,this.#V]}let X=this.type==="*"||this.type==="+",q=this.type==="!"?"(?:(?!(?:":"(?:",Z=this.#u(Q);if(this.isStart()&&this.isEnd()&&!Z&&this.type!=="!"){let Y=this.toString();return this.#Z=[Y],this.type=null,this.#X=void 0,[Y,b(this.toString()),!1,!1]}let V=!X||$||Q||!N2?"":this.#u(!0);if(V===Z)V="";if(V)Z=`(?:${Z})(?:${V})*?`;let J="";if(this.type==="!"&&this.#W)J=(this.isStart()&&!Q?N2:"")+n$;else{let Y=this.type==="!"?"))"+(this.isStart()&&!Q&&!$?N2:"")+i$+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&V?")":this.type==="*"&&V?")?":`)${this.type}`;J=q+Z+Y}return[J,b(Z),this.#X=!!this.#X,this.#V]}#u($){return this.#Z.map((Q)=>{if(typeof Q==="string")throw Error("string type in extglob ast??");let[X,q,Z,V]=Q.toRegExpSource($);return this.#V=this.#V||V,X}).filter((Q)=>!(this.isStart()&&this.isEnd())||!!Q).join("|")}static#A($,Q,X=!1){let q=!1,Z="",V=!1,J=!1;for(let Y=0;Y<$.length;Y++){let z=$.charAt(Y);if(q){q=!1,Z+=(L1.has(z)?"\\":"")+z;continue}if(z==="*"){if(J)continue;J=!0,Z+=X&&/^[*]+$/.test($)?n$:i$,Q=!0;continue}else J=!1;if(z==="\\"){if(Y===$.length-1)Z+="\\\\";else q=!0;continue}if(z==="["){let[H,W,K,j]=c$($,Y);if(K){Z+=H,V=V||W,Y+=K-1,Q=Q||j;continue}}if(z==="?"){Z+=J$,Q=!0;continue}Z+=_1(z)}return[Z,b($),!!Q,V]}}var Z2=($,{windowsPathsNoEscape:Q=!1,magicalBraces:X=!1}={})=>{if(X)return Q?$.replace(/[?*()[\]{}]/g,"[$&]"):$.replace(/[?*()[\]\\{}]/g,"\\$&");return Q?$.replace(/[?*()[\]]/g,"[$&]"):$.replace(/[?*()[\]\\]/g,"\\$&")};var F=($,Q,X={})=>{if(v2(Q),!X.nocomment&&Q.charAt(0)==="#")return!1;return new D(Q,X).match($)},x1=/^\*+([^+@!?\*\[\(]*)$/,M1=($)=>(Q)=>!Q.startsWith(".")&&Q.endsWith($),I1=($)=>(Q)=>Q.endsWith($),O1=($)=>{return $=$.toLowerCase(),(Q)=>!Q.startsWith(".")&&Q.toLowerCase().endsWith($)},F1=($)=>{return $=$.toLowerCase(),(Q)=>Q.toLowerCase().endsWith($)},R1=/^\*+\.\*+$/,T1=($)=>!$.startsWith(".")&&$.includes("."),f1=($)=>$!=="."&&$!==".."&&$.includes("."),N1=/^\.\*+$/,y1=($)=>$!=="."&&$!==".."&&$.startsWith("."),D1=/^\*+$/,S1=($)=>$.length!==0&&!$.startsWith("."),P1=($)=>$.length!==0&&$!=="."&&$!=="..",b1=/^\?+([^+@!?\*\[\(]*)?$/,h1=([$,Q=""])=>{let X=p$([$]);if(!Q)return X;return Q=Q.toLowerCase(),(q)=>X(q)&&q.toLowerCase().endsWith(Q)},d1=([$,Q=""])=>{let X=r$([$]);if(!Q)return X;return Q=Q.toLowerCase(),(q)=>X(q)&&q.toLowerCase().endsWith(Q)},E1=([$,Q=""])=>{let X=r$([$]);return!Q?X:(q)=>X(q)&&q.endsWith(Q)},g1=([$,Q=""])=>{let X=p$([$]);return!Q?X:(q)=>X(q)&&q.endsWith(Q)},p$=([$])=>{let Q=$.length;return(X)=>X.length===Q&&!X.startsWith(".")},r$=([$])=>{let Q=$.length;return(X)=>X.length===Q&&X!=="."&&X!==".."},e$=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",a$={win32:{sep:"\\"},posix:{sep:"/"}},l1=e$==="win32"?a$.win32.sep:a$.posix.sep;F.sep=l1;var I=Symbol("globstar **");F.GLOBSTAR=I;var c1="[^/]",o1=c1+"*?",i1="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",n1="(?:(?!(?:\\/|^)\\.).)*?",a1=($,Q={})=>(X)=>F(X,$,Q);F.filter=a1;var y=($,Q={})=>Object.assign({},$,Q),s1=($)=>{if(!$||typeof $!=="object"||!Object.keys($).length)return F;let Q=F;return Object.assign((q,Z,V={})=>Q(q,Z,y($,V)),{Minimatch:class extends Q.Minimatch{constructor(Z,V={}){super(Z,y($,V))}static defaults(Z){return Q.defaults(y($,Z)).Minimatch}},AST:class extends Q.AST{constructor(Z,V,J={}){super(Z,V,y($,J))}static fromGlob(Z,V={}){return Q.AST.fromGlob(Z,y($,V))}},unescape:(q,Z={})=>Q.unescape(q,y($,Z)),escape:(q,Z={})=>Q.escape(q,y($,Z)),filter:(q,Z={})=>Q.filter(q,y($,Z)),defaults:(q)=>Q.defaults(y($,q)),makeRe:(q,Z={})=>Q.makeRe(q,y($,Z)),braceExpand:(q,Z={})=>Q.braceExpand(q,y($,Z)),match:(q,Z,V={})=>Q.match(q,Z,y($,V)),sep:Q.sep,GLOBSTAR:I})};F.defaults=s1;var t$=($,Q={})=>{if(v2($),Q.nobrace||!/\{(?:(?!\{).)*\}/.test($))return[$];return g$($,{max:Q.braceExpandMax})};F.braceExpand=t$;var p1=($,Q={})=>new D($,Q).makeRe();F.makeRe=p1;var r1=($,Q,X={})=>{let q=new D(Q,X);if($=$.filter((Z)=>q.match(Z)),q.options.nonull&&!$.length)$.push(Q);return $};F.match=r1;var s$=/[?*]|[+@!]\(.*?\)|\[|\]/,e1=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class D{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor($,Q={}){v2($),Q=Q||{},this.options=Q,this.pattern=$,this.platform=Q.platform||e$,this.isWindows=this.platform==="win32";let X="allowWindowsEscape";if(this.windowsPathsNoEscape=!!Q.windowsPathsNoEscape||Q[X]===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!Q.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!Q.nonegate,this.comment=!1,this.empty=!1,this.partial=!!Q.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=Q.windowsNoMagicRoot!==void 0?Q.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let $ of this.set)for(let Q of $)if(typeof Q!=="string")return!0;return!1}debug(...$){}make(){let $=this.pattern,Q=this.options;if(!Q.nocomment&&$.charAt(0)==="#"){this.comment=!0;return}if(!$){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],Q.debug)this.debug=(...Z)=>console.error(...Z);this.debug(this.pattern,this.globSet);let X=this.globSet.map((Z)=>this.slashSplit(Z));this.globParts=this.preprocess(X),this.debug(this.pattern,this.globParts);let q=this.globParts.map((Z,V,J)=>{if(this.isWindows&&this.windowsNoMagicRoot){let Y=Z[0]===""&&Z[1]===""&&(Z[2]==="?"||!s$.test(Z[2]))&&!s$.test(Z[3]),z=/^[a-z]:/i.test(Z[0]);if(Y)return[...Z.slice(0,4),...Z.slice(4).map((H)=>this.parse(H))];else if(z)return[Z[0],...Z.slice(1).map((H)=>this.parse(H))]}return Z.map((Y)=>this.parse(Y))});if(this.debug(this.pattern,q),this.set=q.filter((Z)=>Z.indexOf(!1)===-1),this.isWindows)for(let Z=0;Z<this.set.length;Z++){let V=this.set[Z];if(V[0]===""&&V[1]===""&&this.globParts[Z][2]==="?"&&typeof V[3]==="string"&&/^[a-z]:$/i.test(V[3]))V[2]="?"}this.debug(this.pattern,this.set)}preprocess($){if(this.options.noglobstar){for(let X=0;X<$.length;X++)for(let q=0;q<$[X].length;q++)if($[X][q]==="**")$[X][q]="*"}let{optimizationLevel:Q=1}=this.options;if(Q>=2)$=this.firstPhasePreProcess($),$=this.secondPhasePreProcess($);else if(Q>=1)$=this.levelOneOptimize($);else $=this.adjascentGlobstarOptimize($);return $}adjascentGlobstarOptimize($){return $.map((Q)=>{let X=-1;while((X=Q.indexOf("**",X+1))!==-1){let q=X;while(Q[q+1]==="**")q++;if(q!==X)Q.splice(X,q-X)}return Q})}levelOneOptimize($){return $.map((Q)=>{return Q=Q.reduce((X,q)=>{let Z=X[X.length-1];if(q==="**"&&Z==="**")return X;if(q===".."){if(Z&&Z!==".."&&Z!=="."&&Z!=="**")return X.pop(),X}return X.push(q),X},[]),Q.length===0?[""]:Q})}levelTwoFileOptimize($){if(!Array.isArray($))$=this.slashSplit($);let Q=!1;do{if(Q=!1,!this.preserveMultipleSlashes){for(let q=1;q<$.length-1;q++){let Z=$[q];if(q===1&&Z===""&&$[0]==="")continue;if(Z==="."||Z==="")Q=!0,$.splice(q,1),q--}if($[0]==="."&&$.length===2&&($[1]==="."||$[1]===""))Q=!0,$.pop()}let X=0;while((X=$.indexOf("..",X+1))!==-1){let q=$[X-1];if(q&&q!=="."&&q!==".."&&q!=="**")Q=!0,$.splice(X-1,2),X-=2}}while(Q);return $.length===0?[""]:$}firstPhasePreProcess($){let Q=!1;do{Q=!1;for(let X of $){let q=-1;while((q=X.indexOf("**",q+1))!==-1){let V=q;while(X[V+1]==="**")V++;if(V>q)X.splice(q+1,V-q);let J=X[q+1],Y=X[q+2],z=X[q+3];if(J!=="..")continue;if(!Y||Y==="."||Y===".."||!z||z==="."||z==="..")continue;Q=!0,X.splice(q,1);let H=X.slice(0);H[q]="**",$.push(H),q--}if(!this.preserveMultipleSlashes){for(let V=1;V<X.length-1;V++){let J=X[V];if(V===1&&J===""&&X[0]==="")continue;if(J==="."||J==="")Q=!0,X.splice(V,1),V--}if(X[0]==="."&&X.length===2&&(X[1]==="."||X[1]===""))Q=!0,X.pop()}let Z=0;while((Z=X.indexOf("..",Z+1))!==-1){let V=X[Z-1];if(V&&V!=="."&&V!==".."&&V!=="**"){Q=!0;let Y=Z===1&&X[Z+1]==="**"?["."]:[];if(X.splice(Z-1,2,...Y),X.length===0)X.push("");Z-=2}}}}while(Q);return $}secondPhasePreProcess($){for(let Q=0;Q<$.length-1;Q++)for(let X=Q+1;X<$.length;X++){let q=this.partsMatch($[Q],$[X],!this.preserveMultipleSlashes);if(q){$[Q]=[],$[X]=q;break}}return $.filter((Q)=>Q.length)}partsMatch($,Q,X=!1){let q=0,Z=0,V=[],J="";while(q<$.length&&Z<Q.length)if($[q]===Q[Z])V.push(J==="b"?Q[Z]:$[q]),q++,Z++;else if(X&&$[q]==="**"&&Q[Z]===$[q+1])V.push($[q]),q++;else if(X&&Q[Z]==="**"&&$[q]===Q[Z+1])V.push(Q[Z]),Z++;else if($[q]==="*"&&Q[Z]&&(this.options.dot||!Q[Z].startsWith("."))&&Q[Z]!=="**"){if(J==="b")return!1;J="a",V.push($[q]),q++,Z++}else if(Q[Z]==="*"&&$[q]&&(this.options.dot||!$[q].startsWith("."))&&$[q]!=="**"){if(J==="a")return!1;J="b",V.push(Q[Z]),q++,Z++}else return!1;return $.length===Q.length&&V}parseNegate(){if(this.nonegate)return;let $=this.pattern,Q=!1,X=0;for(let q=0;q<$.length&&$.charAt(q)==="!";q++)Q=!Q,X++;if(X)this.pattern=$.slice(X);this.negate=Q}matchOne($,Q,X=!1){let q=this.options;if(this.isWindows){let U=typeof $[0]==="string"&&/^[a-z]:$/i.test($[0]),v=!U&&$[0]===""&&$[1]===""&&$[2]==="?"&&/^[a-z]:$/i.test($[3]),k=typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0]),G=!k&&Q[0]===""&&Q[1]===""&&Q[2]==="?"&&typeof Q[3]==="string"&&/^[a-z]:$/i.test(Q[3]),w=v?3:U?0:void 0,B=G?3:k?0:void 0;if(typeof w==="number"&&typeof B==="number"){let[A,C]=[$[w],Q[B]];if(A.toLowerCase()===C.toLowerCase()){if(Q[B]=A,B>w)Q=Q.slice(B);else if(w>B)$=$.slice(w)}}}let{optimizationLevel:Z=1}=this.options;if(Z>=2)$=this.levelTwoFileOptimize($);this.debug("matchOne",this,{file:$,pattern:Q}),this.debug("matchOne",$.length,Q.length);for(var V=0,J=0,Y=$.length,z=Q.length;V<Y&&J<z;V++,J++){this.debug("matchOne loop");var H=Q[J],W=$[V];if(this.debug(Q,H,W),H===!1)return!1;if(H===I){this.debug("GLOBSTAR",[Q,H,W]);var K=V,j=J+1;if(j===z){this.debug("** at the end");for(;V<Y;V++)if($[V]==="."||$[V]===".."||!q.dot&&$[V].charAt(0)===".")return!1;return!0}while(K<Y){var u=$[K];if(this.debug(`
|
|
50
|
+
globstar while`,$,K,Q,j,u),this.matchOne($.slice(K),Q.slice(j),X))return this.debug("globstar found match!",K,Y,u),!0;else{if(u==="."||u===".."||!q.dot&&u.charAt(0)==="."){this.debug("dot detected!",$,K,Q,j);break}this.debug("globstar swallow a segment, and continue"),K++}}if(X){if(this.debug(`
|
|
51
|
+
>>> no match, partial?`,$,K,Q,j),K===Y)return!0}return!1}let U;if(typeof H==="string")U=W===H,this.debug("string match",H,W,U);else U=H.test(W),this.debug("pattern match",H,W,U);if(!U)return!1}if(V===Y&&J===z)return!0;else if(V===Y)return X;else if(J===z)return V===Y-1&&$[V]==="";else throw Error("wtf?")}braceExpand(){return t$(this.pattern,this.options)}parse($){v2($);let Q=this.options;if($==="**")return I;if($==="")return"";let X,q=null;if(X=$.match(D1))q=Q.dot?P1:S1;else if(X=$.match(x1))q=(Q.nocase?Q.dot?F1:O1:Q.dot?I1:M1)(X[1]);else if(X=$.match(b1))q=(Q.nocase?Q.dot?d1:h1:Q.dot?E1:g1)(X);else if(X=$.match(R1))q=Q.dot?f1:T1;else if(X=$.match(N1))q=y1;let Z=M.fromGlob($,this.options).toMMPattern();if(q&&typeof Z==="object")Reflect.defineProperty(Z,"test",{value:q});return Z}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let $=this.set;if(!$.length)return this.regexp=!1,this.regexp;let Q=this.options,X=Q.noglobstar?o1:Q.dot?i1:n1,q=new Set(Q.nocase?["i"]:[]),Z=$.map((Y)=>{let z=Y.map((W)=>{if(W instanceof RegExp)for(let K of W.flags.split(""))q.add(K);return typeof W==="string"?e1(W):W===I?I:W._src});z.forEach((W,K)=>{let j=z[K+1],u=z[K-1];if(W!==I||u===I)return;if(u===void 0)if(j!==void 0&&j!==I)z[K+1]="(?:\\/|"+X+"\\/)?"+j;else z[K]=X;else if(j===void 0)z[K-1]=u+"(?:\\/|\\/"+X+")?";else if(j!==I)z[K-1]=u+"(?:\\/|\\/"+X+"\\/)"+j,z[K+1]=I});let H=z.filter((W)=>W!==I);if(this.partial&&H.length>=1){let W=[];for(let K=1;K<=H.length;K++)W.push(H.slice(0,K).join("/"));return"(?:"+W.join("|")+")"}return H.join("/")}).join("|"),[V,J]=$.length>1?["(?:",")"]:["",""];if(Z="^"+V+Z+J+"$",this.partial)Z="^(?:\\/|"+V+Z.slice(1,-1)+J+")$";if(this.negate)Z="^(?!"+Z+").+$";try{this.regexp=new RegExp(Z,[...q].join(""))}catch(Y){this.regexp=!1}return this.regexp}slashSplit($){if(this.preserveMultipleSlashes)return $.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test($))return["",...$.split(/\/+/)];else return $.split(/\/+/)}match($,Q=this.partial){if(this.debug("match",$,this.pattern),this.comment)return!1;if(this.empty)return $==="";if($==="/"&&Q)return!0;let X=this.options;if(this.isWindows)$=$.split("\\").join("/");let q=this.slashSplit($);this.debug(this.pattern,"split",q);let Z=this.set;this.debug(this.pattern,"set",Z);let V=q[q.length-1];if(!V)for(let J=q.length-2;!V&&J>=0;J--)V=q[J];for(let J=0;J<Z.length;J++){let Y=Z[J],z=q;if(X.matchBase&&Y.length===1)z=[V];if(this.matchOne(z,Y,Q)){if(X.flipNegate)return!0;return!this.negate}}if(X.flipNegate)return!1;return this.negate}static defaults($){return F.defaults($).Minimatch}}F.AST=M;F.Minimatch=D;F.escape=Z2;F.unescape=b;import{fileURLToPath as f5}from"node:url";var t1=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Q0=new Set,Y$=typeof process=="object"&&process?process:{},X0=($,Q,X,q)=>{typeof Y$.emitWarning=="function"?Y$.emitWarning($,Q,X,q):console.error(`[${X}] ${Q}: ${$}`)},D2=globalThis.AbortController,$0=globalThis.AbortSignal;if(typeof D2>"u"){$0=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(X,q){this._onabort.push(q)}},D2=class{constructor(){Q()}signal=new $0;abort(X){if(!this.signal.aborted){this.signal.reason=X,this.signal.aborted=!0;for(let q of this.signal._onabort)q(X);this.signal.onabort?.(X)}}};let $=Y$.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",Q=()=>{$&&($=!1,X0("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",Q))}}var $5=($)=>!Q0.has($),Q6=Symbol("type"),s=($)=>$&&$===Math.floor($)&&$>0&&isFinite($),q0=($)=>s($)?$<=Math.pow(2,8)?Uint8Array:$<=Math.pow(2,16)?Uint16Array:$<=Math.pow(2,32)?Uint32Array:$<=Number.MAX_SAFE_INTEGER?y2:null:null,y2=class extends Array{constructor($){super($),this.fill(0)}},Q5=class ${heap;length;static#$=!1;static create(Q){let X=q0(Q);if(!X)return[];$.#$=!0;let q=new $(Q,X);return $.#$=!1,q}constructor(Q,X){if(!$.#$)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new X(Q),this.length=0}push(Q){this.heap[this.length++]=Q}pop(){return this.heap[--this.length]}},G2=class ${#$;#X;#V;#Z;#J;#B;#w;#H;get perf(){return this.#H}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#Y;#j;#W;#z;#q;#u;#A;#C;#v;#O;#U;#_;#x;#G;#k;#m;#M;#Q;#y;static unsafeExposeInternals(Q){return{starts:Q.#x,ttls:Q.#G,autopurgeTimers:Q.#k,sizes:Q.#_,keyMap:Q.#W,keyList:Q.#z,valList:Q.#q,next:Q.#u,prev:Q.#A,get head(){return Q.#C},get tail(){return Q.#v},free:Q.#O,isBackgroundFetch:(X)=>Q.#K(X),backgroundFetch:(X,q,Z,V)=>Q.#g(X,q,Z,V),moveToTail:(X)=>Q.#S(X),indexes:(X)=>Q.#R(X),rindexes:(X)=>Q.#T(X),isStale:(X)=>Q.#L(X)}}get max(){return this.#$}get maxSize(){return this.#X}get calculatedSize(){return this.#j}get size(){return this.#Y}get fetchMethod(){return this.#B}get memoMethod(){return this.#w}get dispose(){return this.#V}get onInsert(){return this.#Z}get disposeAfter(){return this.#J}constructor(Q){let{max:X=0,ttl:q,ttlResolution:Z=1,ttlAutopurge:V,updateAgeOnGet:J,updateAgeOnHas:Y,allowStale:z,dispose:H,onInsert:W,disposeAfter:K,noDisposeOnSet:j,noUpdateTTL:u,maxSize:U=0,maxEntrySize:v=0,sizeCalculation:k,fetchMethod:G,memoMethod:w,noDeleteOnFetchRejection:B,noDeleteOnStaleGet:A,allowStaleOnFetchRejection:C,allowStaleOnFetchAbort:n,ignoreFetchAbort:c,perf:X2}=Q;if(X2!==void 0&&typeof X2?.now!="function")throw TypeError("perf option must have a now() method if specified");if(this.#H=X2??t1,X!==0&&!s(X))throw TypeError("max option must be a nonnegative integer");let q2=X?q0(X):Array;if(!q2)throw Error("invalid max value: "+X);if(this.#$=X,this.#X=U,this.maxEntrySize=v||this.#X,this.sizeCalculation=k,this.sizeCalculation){if(!this.#X&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw TypeError("sizeCalculation set to non-function")}if(w!==void 0&&typeof w!="function")throw TypeError("memoMethod must be a function if defined");if(this.#w=w,G!==void 0&&typeof G!="function")throw TypeError("fetchMethod must be a function if specified");if(this.#B=G,this.#M=!!G,this.#W=new Map,this.#z=Array(X).fill(void 0),this.#q=Array(X).fill(void 0),this.#u=new q2(X),this.#A=new q2(X),this.#C=0,this.#v=0,this.#O=Q5.create(X),this.#Y=0,this.#j=0,typeof H=="function"&&(this.#V=H),typeof W=="function"&&(this.#Z=W),typeof K=="function"?(this.#J=K,this.#U=[]):(this.#J=void 0,this.#U=void 0),this.#m=!!this.#V,this.#y=!!this.#Z,this.#Q=!!this.#J,this.noDisposeOnSet=!!j,this.noUpdateTTL=!!u,this.noDeleteOnFetchRejection=!!B,this.allowStaleOnFetchRejection=!!C,this.allowStaleOnFetchAbort=!!n,this.ignoreFetchAbort=!!c,this.maxEntrySize!==0){if(this.#X!==0&&!s(this.#X))throw TypeError("maxSize must be a positive integer if specified");if(!s(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#c()}if(this.allowStale=!!z,this.noDeleteOnStaleGet=!!A,this.updateAgeOnGet=!!J,this.updateAgeOnHas=!!Y,this.ttlResolution=s(Z)||Z===0?Z:1,this.ttlAutopurge=!!V,this.ttl=q||0,this.ttl){if(!s(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#f()}if(this.#$===0&&this.ttl===0&&this.#X===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#$&&!this.#X){let $$="LRU_CACHE_UNBOUNDED";$5($$)&&(Q0.add($$),X0("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",$$,$))}}getRemainingTTL(Q){return this.#W.has(Q)?1/0:0}#f(){let Q=new y2(this.#$),X=new y2(this.#$);this.#G=Q,this.#x=X;let q=this.ttlAutopurge?Array(this.#$):void 0;this.#k=q,this.#b=(J,Y,z=this.#H.now())=>{if(X[J]=Y!==0?z:0,Q[J]=Y,q?.[J]&&(clearTimeout(q[J]),q[J]=void 0),Y!==0&&q){let H=setTimeout(()=>{this.#L(J)&&this.#F(this.#z[J],"expire")},Y+1);H.unref&&H.unref(),q[J]=H}},this.#I=(J)=>{X[J]=Q[J]!==0?this.#H.now():0},this.#N=(J,Y)=>{if(Q[Y]){let z=Q[Y],H=X[Y];if(!z||!H)return;J.ttl=z,J.start=H,J.now=Z||V();let W=J.now-H;J.remainingTTL=z-W}};let Z=0,V=()=>{let J=this.#H.now();if(this.ttlResolution>0){Z=J;let Y=setTimeout(()=>Z=0,this.ttlResolution);Y.unref&&Y.unref()}return J};this.getRemainingTTL=(J)=>{let Y=this.#W.get(J);if(Y===void 0)return 0;let z=Q[Y],H=X[Y];if(!z||!H)return 1/0;let W=(Z||V())-H;return z-W},this.#L=(J)=>{let Y=X[J],z=Q[J];return!!z&&!!Y&&(Z||V())-Y>z}}#I=()=>{};#N=()=>{};#b=()=>{};#L=()=>!1;#c(){let Q=new y2(this.#$);this.#j=0,this.#_=Q,this.#P=(X)=>{this.#j-=Q[X],Q[X]=0},this.#h=(X,q,Z,V)=>{if(this.#K(q))return 0;if(!s(Z))if(V){if(typeof V!="function")throw TypeError("sizeCalculation must be a function");if(Z=V(q,X),!s(Z))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return Z},this.#D=(X,q,Z)=>{if(Q[X]=q,this.#X){let V=this.#X-Q[X];for(;this.#j>V;)this.#E(!0)}this.#j+=Q[X],Z&&(Z.entrySize=q,Z.totalCalculatedSize=this.#j)}}#P=(Q)=>{};#D=(Q,X,q)=>{};#h=(Q,X,q,Z)=>{if(q||Z)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#R({allowStale:Q=this.allowStale}={}){if(this.#Y)for(let X=this.#v;!(!this.#d(X)||((Q||!this.#L(X))&&(yield X),X===this.#C));)X=this.#A[X]}*#T({allowStale:Q=this.allowStale}={}){if(this.#Y)for(let X=this.#C;!(!this.#d(X)||((Q||!this.#L(X))&&(yield X),X===this.#v));)X=this.#u[X]}#d(Q){return Q!==void 0&&this.#W.get(this.#z[Q])===Q}*entries(){for(let Q of this.#R())this.#q[Q]!==void 0&&this.#z[Q]!==void 0&&!this.#K(this.#q[Q])&&(yield[this.#z[Q],this.#q[Q]])}*rentries(){for(let Q of this.#T())this.#q[Q]!==void 0&&this.#z[Q]!==void 0&&!this.#K(this.#q[Q])&&(yield[this.#z[Q],this.#q[Q]])}*keys(){for(let Q of this.#R()){let X=this.#z[Q];X!==void 0&&!this.#K(this.#q[Q])&&(yield X)}}*rkeys(){for(let Q of this.#T()){let X=this.#z[Q];X!==void 0&&!this.#K(this.#q[Q])&&(yield X)}}*values(){for(let Q of this.#R())this.#q[Q]!==void 0&&!this.#K(this.#q[Q])&&(yield this.#q[Q])}*rvalues(){for(let Q of this.#T())this.#q[Q]!==void 0&&!this.#K(this.#q[Q])&&(yield this.#q[Q])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(Q,X={}){for(let q of this.#R()){let Z=this.#q[q],V=this.#K(Z)?Z.__staleWhileFetching:Z;if(V!==void 0&&Q(V,this.#z[q],this))return this.get(this.#z[q],X)}}forEach(Q,X=this){for(let q of this.#R()){let Z=this.#q[q],V=this.#K(Z)?Z.__staleWhileFetching:Z;V!==void 0&&Q.call(X,V,this.#z[q],this)}}rforEach(Q,X=this){for(let q of this.#T()){let Z=this.#q[q],V=this.#K(Z)?Z.__staleWhileFetching:Z;V!==void 0&&Q.call(X,V,this.#z[q],this)}}purgeStale(){let Q=!1;for(let X of this.#T({allowStale:!0}))this.#L(X)&&(this.#F(this.#z[X],"expire"),Q=!0);return Q}info(Q){let X=this.#W.get(Q);if(X===void 0)return;let q=this.#q[X],Z=this.#K(q)?q.__staleWhileFetching:q;if(Z===void 0)return;let V={value:Z};if(this.#G&&this.#x){let J=this.#G[X],Y=this.#x[X];if(J&&Y){let z=J-(this.#H.now()-Y);V.ttl=z,V.start=Date.now()}}return this.#_&&(V.size=this.#_[X]),V}dump(){let Q=[];for(let X of this.#R({allowStale:!0})){let q=this.#z[X],Z=this.#q[X],V=this.#K(Z)?Z.__staleWhileFetching:Z;if(V===void 0||q===void 0)continue;let J={value:V};if(this.#G&&this.#x){J.ttl=this.#G[X];let Y=this.#H.now()-this.#x[X];J.start=Math.floor(Date.now()-Y)}this.#_&&(J.size=this.#_[X]),Q.unshift([q,J])}return Q}load(Q){this.clear();for(let[X,q]of Q){if(q.start){let Z=Date.now()-q.start;q.start=this.#H.now()-Z}this.set(X,q.value,q)}}set(Q,X,q={}){if(X===void 0)return this.delete(Q),this;let{ttl:Z=this.ttl,start:V,noDisposeOnSet:J=this.noDisposeOnSet,sizeCalculation:Y=this.sizeCalculation,status:z}=q,{noUpdateTTL:H=this.noUpdateTTL}=q,W=this.#h(Q,X,q.size||0,Y);if(this.maxEntrySize&&W>this.maxEntrySize)return z&&(z.set="miss",z.maxEntrySizeExceeded=!0),this.#F(Q,"set"),this;let K=this.#Y===0?void 0:this.#W.get(Q);if(K===void 0)K=this.#Y===0?this.#v:this.#O.length!==0?this.#O.pop():this.#Y===this.#$?this.#E(!1):this.#Y,this.#z[K]=Q,this.#q[K]=X,this.#W.set(Q,K),this.#u[this.#v]=K,this.#A[K]=this.#v,this.#v=K,this.#Y++,this.#D(K,W,z),z&&(z.set="add"),H=!1,this.#y&&this.#Z?.(X,Q,"add");else{this.#S(K);let j=this.#q[K];if(X!==j){if(this.#M&&this.#K(j)){j.__abortController.abort(Error("replaced"));let{__staleWhileFetching:u}=j;u!==void 0&&!J&&(this.#m&&this.#V?.(u,Q,"set"),this.#Q&&this.#U?.push([u,Q,"set"]))}else J||(this.#m&&this.#V?.(j,Q,"set"),this.#Q&&this.#U?.push([j,Q,"set"]));if(this.#P(K),this.#D(K,W,z),this.#q[K]=X,z){z.set="replace";let u=j&&this.#K(j)?j.__staleWhileFetching:j;u!==void 0&&(z.oldValue=u)}}else z&&(z.set="update");this.#y&&this.onInsert?.(X,Q,X===j?"update":"replace")}if(Z!==0&&!this.#G&&this.#f(),this.#G&&(H||this.#b(K,Z,V),z&&this.#N(z,K)),!J&&this.#Q&&this.#U){let j=this.#U,u;for(;u=j?.shift();)this.#J?.(...u)}return this}pop(){try{for(;this.#Y;){let Q=this.#q[this.#C];if(this.#E(!0),this.#K(Q)){if(Q.__staleWhileFetching)return Q.__staleWhileFetching}else if(Q!==void 0)return Q}}finally{if(this.#Q&&this.#U){let Q=this.#U,X;for(;X=Q?.shift();)this.#J?.(...X)}}}#E(Q){let X=this.#C,q=this.#z[X],Z=this.#q[X];return this.#M&&this.#K(Z)?Z.__abortController.abort(Error("evicted")):(this.#m||this.#Q)&&(this.#m&&this.#V?.(Z,q,"evict"),this.#Q&&this.#U?.push([Z,q,"evict"])),this.#P(X),this.#k?.[X]&&(clearTimeout(this.#k[X]),this.#k[X]=void 0),Q&&(this.#z[X]=void 0,this.#q[X]=void 0,this.#O.push(X)),this.#Y===1?(this.#C=this.#v=0,this.#O.length=0):this.#C=this.#u[X],this.#W.delete(q),this.#Y--,X}has(Q,X={}){let{updateAgeOnHas:q=this.updateAgeOnHas,status:Z}=X,V=this.#W.get(Q);if(V!==void 0){let J=this.#q[V];if(this.#K(J)&&J.__staleWhileFetching===void 0)return!1;if(this.#L(V))Z&&(Z.has="stale",this.#N(Z,V));else return q&&this.#I(V),Z&&(Z.has="hit",this.#N(Z,V)),!0}else Z&&(Z.has="miss");return!1}peek(Q,X={}){let{allowStale:q=this.allowStale}=X,Z=this.#W.get(Q);if(Z===void 0||!q&&this.#L(Z))return;let V=this.#q[Z];return this.#K(V)?V.__staleWhileFetching:V}#g(Q,X,q,Z){let V=X===void 0?void 0:this.#q[X];if(this.#K(V))return V;let J=new D2,{signal:Y}=q;Y?.addEventListener("abort",()=>J.abort(Y.reason),{signal:J.signal});let z={signal:J.signal,options:q,context:Z},H=(v,k=!1)=>{let{aborted:G}=J.signal,w=q.ignoreFetchAbort&&v!==void 0,B=q.ignoreFetchAbort||!!(q.allowStaleOnFetchAbort&&v!==void 0);if(q.status&&(G&&!k?(q.status.fetchAborted=!0,q.status.fetchError=J.signal.reason,w&&(q.status.fetchAbortIgnored=!0)):q.status.fetchResolved=!0),G&&!w&&!k)return K(J.signal.reason,B);let A=u,C=this.#q[X];return(C===u||w&&k&&C===void 0)&&(v===void 0?A.__staleWhileFetching!==void 0?this.#q[X]=A.__staleWhileFetching:this.#F(Q,"fetch"):(q.status&&(q.status.fetchUpdated=!0),this.set(Q,v,z.options))),v},W=(v)=>(q.status&&(q.status.fetchRejected=!0,q.status.fetchError=v),K(v,!1)),K=(v,k)=>{let{aborted:G}=J.signal,w=G&&q.allowStaleOnFetchAbort,B=w||q.allowStaleOnFetchRejection,A=B||q.noDeleteOnFetchRejection,C=u;if(this.#q[X]===u&&(!A||!k&&C.__staleWhileFetching===void 0?this.#F(Q,"fetch"):w||(this.#q[X]=C.__staleWhileFetching)),B)return q.status&&C.__staleWhileFetching!==void 0&&(q.status.returnedStale=!0),C.__staleWhileFetching;if(C.__returned===C)throw v},j=(v,k)=>{let G=this.#B?.(Q,V,z);G&&G instanceof Promise&&G.then((w)=>v(w===void 0?void 0:w),k),J.signal.addEventListener("abort",()=>{(!q.ignoreFetchAbort||q.allowStaleOnFetchAbort)&&(v(void 0),q.allowStaleOnFetchAbort&&(v=(w)=>H(w,!0)))})};q.status&&(q.status.fetchDispatched=!0);let u=new Promise(j).then(H,W),U=Object.assign(u,{__abortController:J,__staleWhileFetching:V,__returned:void 0});return X===void 0?(this.set(Q,U,{...z.options,status:void 0}),X=this.#W.get(Q)):this.#q[X]=U,U}#K(Q){if(!this.#M)return!1;let X=Q;return!!X&&X instanceof Promise&&X.hasOwnProperty("__staleWhileFetching")&&X.__abortController instanceof D2}async fetch(Q,X={}){let{allowStale:q=this.allowStale,updateAgeOnGet:Z=this.updateAgeOnGet,noDeleteOnStaleGet:V=this.noDeleteOnStaleGet,ttl:J=this.ttl,noDisposeOnSet:Y=this.noDisposeOnSet,size:z=0,sizeCalculation:H=this.sizeCalculation,noUpdateTTL:W=this.noUpdateTTL,noDeleteOnFetchRejection:K=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:j=this.allowStaleOnFetchRejection,ignoreFetchAbort:u=this.ignoreFetchAbort,allowStaleOnFetchAbort:U=this.allowStaleOnFetchAbort,context:v,forceRefresh:k=!1,status:G,signal:w}=X;if(!this.#M)return G&&(G.fetch="get"),this.get(Q,{allowStale:q,updateAgeOnGet:Z,noDeleteOnStaleGet:V,status:G});let B={allowStale:q,updateAgeOnGet:Z,noDeleteOnStaleGet:V,ttl:J,noDisposeOnSet:Y,size:z,sizeCalculation:H,noUpdateTTL:W,noDeleteOnFetchRejection:K,allowStaleOnFetchRejection:j,allowStaleOnFetchAbort:U,ignoreFetchAbort:u,status:G,signal:w},A=this.#W.get(Q);if(A===void 0){G&&(G.fetch="miss");let C=this.#g(Q,A,B,v);return C.__returned=C}else{let C=this.#q[A];if(this.#K(C)){let q2=q&&C.__staleWhileFetching!==void 0;return G&&(G.fetch="inflight",q2&&(G.returnedStale=!0)),q2?C.__staleWhileFetching:C.__returned=C}let n=this.#L(A);if(!k&&!n)return G&&(G.fetch="hit"),this.#S(A),Z&&this.#I(A),G&&this.#N(G,A),C;let c=this.#g(Q,A,B,v),X2=c.__staleWhileFetching!==void 0&&q;return G&&(G.fetch=n?"stale":"refresh",X2&&n&&(G.returnedStale=!0)),X2?c.__staleWhileFetching:c.__returned=c}}async forceFetch(Q,X={}){let q=await this.fetch(Q,X);if(q===void 0)throw Error("fetch() returned undefined");return q}memo(Q,X={}){let q=this.#w;if(!q)throw Error("no memoMethod provided to constructor");let{context:Z,forceRefresh:V,...J}=X,Y=this.get(Q,J);if(!V&&Y!==void 0)return Y;let z=q(Q,Y,{options:J,context:Z});return this.set(Q,z,J),z}get(Q,X={}){let{allowStale:q=this.allowStale,updateAgeOnGet:Z=this.updateAgeOnGet,noDeleteOnStaleGet:V=this.noDeleteOnStaleGet,status:J}=X,Y=this.#W.get(Q);if(Y!==void 0){let z=this.#q[Y],H=this.#K(z);return J&&this.#N(J,Y),this.#L(Y)?(J&&(J.get="stale"),H?(J&&q&&z.__staleWhileFetching!==void 0&&(J.returnedStale=!0),q?z.__staleWhileFetching:void 0):(V||this.#F(Q,"expire"),J&&q&&(J.returnedStale=!0),q?z:void 0)):(J&&(J.get="hit"),H?z.__staleWhileFetching:(this.#S(Y),Z&&this.#I(Y),z))}else J&&(J.get="miss")}#l(Q,X){this.#A[X]=Q,this.#u[Q]=X}#S(Q){Q!==this.#v&&(Q===this.#C?this.#C=this.#u[Q]:this.#l(this.#A[Q],this.#u[Q]),this.#l(this.#v,Q),this.#v=Q)}delete(Q){return this.#F(Q,"delete")}#F(Q,X){let q=!1;if(this.#Y!==0){let Z=this.#W.get(Q);if(Z!==void 0)if(this.#k?.[Z]&&(clearTimeout(this.#k?.[Z]),this.#k[Z]=void 0),q=!0,this.#Y===1)this.#o(X);else{this.#P(Z);let V=this.#q[Z];if(this.#K(V)?V.__abortController.abort(Error("deleted")):(this.#m||this.#Q)&&(this.#m&&this.#V?.(V,Q,X),this.#Q&&this.#U?.push([V,Q,X])),this.#W.delete(Q),this.#z[Z]=void 0,this.#q[Z]=void 0,Z===this.#v)this.#v=this.#A[Z];else if(Z===this.#C)this.#C=this.#u[Z];else{let J=this.#A[Z];this.#u[J]=this.#u[Z];let Y=this.#u[Z];this.#A[Y]=this.#A[Z]}this.#Y--,this.#O.push(Z)}}if(this.#Q&&this.#U?.length){let Z=this.#U,V;for(;V=Z?.shift();)this.#J?.(...V)}return q}clear(){return this.#o("delete")}#o(Q){for(let X of this.#T({allowStale:!0})){let q=this.#q[X];if(this.#K(q))q.__abortController.abort(Error("deleted"));else{let Z=this.#z[X];this.#m&&this.#V?.(q,Z,Q),this.#Q&&this.#U?.push([q,Z,Q])}}if(this.#W.clear(),this.#q.fill(void 0),this.#z.fill(void 0),this.#G&&this.#x){this.#G.fill(0),this.#x.fill(0);for(let X of this.#k??[])X!==void 0&&clearTimeout(X);this.#k?.fill(void 0)}if(this.#_&&this.#_.fill(0),this.#C=0,this.#v=0,this.#O.length=0,this.#j=0,this.#Y=0,this.#Q&&this.#U){let X=this.#U,q;for(;q=X?.shift();)this.#J?.(...q)}}};import{posix as j5,win32 as w$}from"node:path";import{fileURLToPath as u5}from"node:url";import{lstatSync as v5,readdir as U5,readdirSync as G5,readlinkSync as w5,realpathSync as k5}from"fs";import*as C5 from"node:fs";import{lstat as A5,readdir as m5,readlink as L5,realpath as _5}from"node:fs/promises";import{EventEmitter as u$}from"node:events";import z0 from"node:stream";import{StringDecoder as X5}from"node:string_decoder";var Z0=typeof process==="object"&&process?process:{stdout:null,stderr:null},q5=($)=>!!$&&typeof $==="object"&&($ instanceof $2||$ instanceof z0||Z5($)||V5($)),Z5=($)=>!!$&&typeof $==="object"&&$ instanceof u$&&typeof $.pipe==="function"&&$.pipe!==z0.Writable.prototype.pipe,V5=($)=>!!$&&typeof $==="object"&&$ instanceof u$&&typeof $.write==="function"&&typeof $.end==="function",o=Symbol("EOF"),i=Symbol("maybeEmitEnd"),p=Symbol("emittedEnd"),S2=Symbol("emittingEnd"),w2=Symbol("emittedError"),P2=Symbol("closed"),V0=Symbol("read"),b2=Symbol("flush"),J0=Symbol("flushChunk"),h=Symbol("encoding"),V2=Symbol("decoder"),L=Symbol("flowing"),k2=Symbol("paused"),J2=Symbol("resume"),_=Symbol("buffer"),R=Symbol("pipes"),x=Symbol("bufferLength"),z$=Symbol("bufferPush"),h2=Symbol("bufferShift"),O=Symbol("objectMode"),m=Symbol("destroyed"),K$=Symbol("error"),H$=Symbol("emitData"),Y0=Symbol("emitEnd"),W$=Symbol("emitEnd2"),E=Symbol("async"),j$=Symbol("abort"),d2=Symbol("aborted"),C2=Symbol("signal"),t=Symbol("dataListeners"),N=Symbol("discarded"),B2=($)=>Promise.resolve().then($),J5=($)=>$(),Y5=($)=>$==="end"||$==="finish"||$==="prefinish",z5=($)=>$ instanceof ArrayBuffer||!!$&&typeof $==="object"&&$.constructor&&$.constructor.name==="ArrayBuffer"&&$.byteLength>=0,K5=($)=>!Buffer.isBuffer($)&&ArrayBuffer.isView($);class v${src;dest;opts;ondrain;constructor($,Q,X){this.src=$,this.dest=Q,this.opts=X,this.ondrain=()=>$[J2](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors($){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class K0 extends v${unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor($,Q,X){super($,Q,X);this.proxyErrors=(q)=>this.dest.emit("error",q),$.on("error",this.proxyErrors)}}var H5=($)=>!!$.objectMode,W5=($)=>!$.objectMode&&!!$.encoding&&$.encoding!=="buffer";class $2 extends u${[L]=!1;[k2]=!1;[R]=[];[_]=[];[O];[h];[E];[V2];[o]=!1;[p]=!1;[S2]=!1;[P2]=!1;[w2]=null;[x]=0;[m]=!1;[C2];[d2]=!1;[t]=0;[N]=!1;writable=!0;readable=!0;constructor(...$){let Q=$[0]||{};super();if(Q.objectMode&&typeof Q.encoding==="string")throw TypeError("Encoding and objectMode may not be used together");if(H5(Q))this[O]=!0,this[h]=null;else if(W5(Q))this[h]=Q.encoding,this[O]=!1;else this[O]=!1,this[h]=null;if(this[E]=!!Q.async,this[V2]=this[h]?new X5(this[h]):null,Q&&Q.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[_]});if(Q&&Q.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[R]});let{signal:X}=Q;if(X)if(this[C2]=X,X.aborted)this[j$]();else X.addEventListener("abort",()=>this[j$]())}get bufferLength(){return this[x]}get encoding(){return this[h]}set encoding($){throw Error("Encoding must be set at instantiation time")}setEncoding($){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[O]}set objectMode($){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[E]}set["async"]($){this[E]=this[E]||!!$}[j$](){this[d2]=!0,this.emit("abort",this[C2]?.reason),this.destroy(this[C2]?.reason)}get aborted(){return this[d2]}set aborted($){}write($,Q,X){if(this[d2])return!1;if(this[o])throw Error("write after end");if(this[m])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof Q==="function")X=Q,Q="utf8";if(!Q)Q="utf8";let q=this[E]?B2:J5;if(!this[O]&&!Buffer.isBuffer($)){if(K5($))$=Buffer.from($.buffer,$.byteOffset,$.byteLength);else if(z5($))$=Buffer.from($);else if(typeof $!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[O]){if(this[L]&&this[x]!==0)this[b2](!0);if(this[L])this.emit("data",$);else this[z$]($);if(this[x]!==0)this.emit("readable");if(X)q(X);return this[L]}if(!$.length){if(this[x]!==0)this.emit("readable");if(X)q(X);return this[L]}if(typeof $==="string"&&!(Q===this[h]&&!this[V2]?.lastNeed))$=Buffer.from($,Q);if(Buffer.isBuffer($)&&this[h])$=this[V2].write($);if(this[L]&&this[x]!==0)this[b2](!0);if(this[L])this.emit("data",$);else this[z$]($);if(this[x]!==0)this.emit("readable");if(X)q(X);return this[L]}read($){if(this[m])return null;if(this[N]=!1,this[x]===0||$===0||$&&$>this[x])return this[i](),null;if(this[O])$=null;if(this[_].length>1&&!this[O])this[_]=[this[h]?this[_].join(""):Buffer.concat(this[_],this[x])];let Q=this[V0]($||null,this[_][0]);return this[i](),Q}[V0]($,Q){if(this[O])this[h2]();else{let X=Q;if($===X.length||$===null)this[h2]();else if(typeof X==="string")this[_][0]=X.slice($),Q=X.slice(0,$),this[x]-=$;else this[_][0]=X.subarray($),Q=X.subarray(0,$),this[x]-=$}if(this.emit("data",Q),!this[_].length&&!this[o])this.emit("drain");return Q}end($,Q,X){if(typeof $==="function")X=$,$=void 0;if(typeof Q==="function")X=Q,Q="utf8";if($!==void 0)this.write($,Q);if(X)this.once("end",X);if(this[o]=!0,this.writable=!1,this[L]||!this[k2])this[i]();return this}[J2](){if(this[m])return;if(!this[t]&&!this[R].length)this[N]=!0;if(this[k2]=!1,this[L]=!0,this.emit("resume"),this[_].length)this[b2]();else if(this[o])this[i]();else this.emit("drain")}resume(){return this[J2]()}pause(){this[L]=!1,this[k2]=!0,this[N]=!1}get destroyed(){return this[m]}get flowing(){return this[L]}get paused(){return this[k2]}[z$]($){if(this[O])this[x]+=1;else this[x]+=$.length;this[_].push($)}[h2](){if(this[O])this[x]-=1;else this[x]-=this[_][0].length;return this[_].shift()}[b2]($=!1){do;while(this[J0](this[h2]())&&this[_].length);if(!$&&!this[_].length&&!this[o])this.emit("drain")}[J0]($){return this.emit("data",$),this[L]}pipe($,Q){if(this[m])return $;this[N]=!1;let X=this[p];if(Q=Q||{},$===Z0.stdout||$===Z0.stderr)Q.end=!1;else Q.end=Q.end!==!1;if(Q.proxyErrors=!!Q.proxyErrors,X){if(Q.end)$.end()}else if(this[R].push(!Q.proxyErrors?new v$(this,$,Q):new K0(this,$,Q)),this[E])B2(()=>this[J2]());else this[J2]();return $}unpipe($){let Q=this[R].find((X)=>X.dest===$);if(Q){if(this[R].length===1){if(this[L]&&this[t]===0)this[L]=!1;this[R]=[]}else this[R].splice(this[R].indexOf(Q),1);Q.unpipe()}}addListener($,Q){return this.on($,Q)}on($,Q){let X=super.on($,Q);if($==="data"){if(this[N]=!1,this[t]++,!this[R].length&&!this[L])this[J2]()}else if($==="readable"&&this[x]!==0)super.emit("readable");else if(Y5($)&&this[p])super.emit($),this.removeAllListeners($);else if($==="error"&&this[w2]){let q=Q;if(this[E])B2(()=>q.call(this,this[w2]));else q.call(this,this[w2])}return X}removeListener($,Q){return this.off($,Q)}off($,Q){let X=super.off($,Q);if($==="data"){if(this[t]=this.listeners("data").length,this[t]===0&&!this[N]&&!this[R].length)this[L]=!1}return X}removeAllListeners($){let Q=super.removeAllListeners($);if($==="data"||$===void 0){if(this[t]=0,!this[N]&&!this[R].length)this[L]=!1}return Q}get emittedEnd(){return this[p]}[i](){if(!this[S2]&&!this[p]&&!this[m]&&this[_].length===0&&this[o]){if(this[S2]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[P2])this.emit("close");this[S2]=!1}}emit($,...Q){let X=Q[0];if($!=="error"&&$!=="close"&&$!==m&&this[m])return!1;else if($==="data")return!this[O]&&!X?!1:this[E]?(B2(()=>this[H$](X)),!0):this[H$](X);else if($==="end")return this[Y0]();else if($==="close"){if(this[P2]=!0,!this[p]&&!this[m])return!1;let Z=super.emit("close");return this.removeAllListeners("close"),Z}else if($==="error"){this[w2]=X,super.emit(K$,X);let Z=!this[C2]||this.listeners("error").length?super.emit("error",X):!1;return this[i](),Z}else if($==="resume"){let Z=super.emit("resume");return this[i](),Z}else if($==="finish"||$==="prefinish"){let Z=super.emit($);return this.removeAllListeners($),Z}let q=super.emit($,...Q);return this[i](),q}[H$]($){for(let X of this[R])if(X.dest.write($)===!1)this.pause();let Q=this[N]?!1:super.emit("data",$);return this[i](),Q}[Y0](){if(this[p])return!1;return this[p]=!0,this.readable=!1,this[E]?(B2(()=>this[W$]()),!0):this[W$]()}[W$](){if(this[V2]){let Q=this[V2].end();if(Q){for(let X of this[R])X.dest.write(Q);if(!this[N])super.emit("data",Q)}}for(let Q of this[R])Q.end();let $=super.emit("end");return this.removeAllListeners("end"),$}async collect(){let $=Object.assign([],{dataLength:0});if(!this[O])$.dataLength=0;let Q=this.promise();return this.on("data",(X)=>{if($.push(X),!this[O])$.dataLength+=X.length}),await Q,$}async concat(){if(this[O])throw Error("cannot concat in objectMode");let $=await this.collect();return this[h]?$.join(""):Buffer.concat($,$.dataLength)}async promise(){return new Promise(($,Q)=>{this.on(m,()=>Q(Error("stream destroyed"))),this.on("error",(X)=>Q(X)),this.on("end",()=>$())})}[Symbol.asyncIterator](){this[N]=!1;let $=!1,Q=async()=>{return this.pause(),$=!0,{value:void 0,done:!0}};return{next:()=>{if($)return Q();let q=this.read();if(q!==null)return Promise.resolve({done:!1,value:q});if(this[o])return Q();let Z,V,J=(W)=>{this.off("data",Y),this.off("end",z),this.off(m,H),Q(),V(W)},Y=(W)=>{this.off("error",J),this.off("end",z),this.off(m,H),this.pause(),Z({value:W,done:!!this[o]})},z=()=>{this.off("error",J),this.off("data",Y),this.off(m,H),Q(),Z({done:!0,value:void 0})},H=()=>J(Error("stream destroyed"));return new Promise((W,K)=>{V=K,Z=W,this.once(m,H),this.once("error",J),this.once("end",z),this.once("data",Y)})},throw:Q,return:Q,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[N]=!1;let $=!1,Q=()=>{return this.pause(),this.off(K$,Q),this.off(m,Q),this.off("end",Q),$=!0,{done:!0,value:void 0}},X=()=>{if($)return Q();let q=this.read();return q===null?Q():{done:!1,value:q}};return this.once("end",Q),this.once(K$,Q),this.once(m,Q),{next:X,throw:Q,return:Q,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy($){if(this[m]){if($)this.emit("error",$);else this.emit(m);return this}this[m]=!0,this[N]=!0,this[_].length=0,this[x]=0;let Q=this;if(typeof Q.close==="function"&&!this[P2])Q.close();if($)this.emit("error",$);else this.emit(m);return this}static get isStream(){return q5}}var B5=k5.native,m2={lstatSync:v5,readdir:U5,readdirSync:G5,readlinkSync:w5,realpathSync:B5,promises:{lstat:A5,readdir:m5,readlink:L5,realpath:_5}},v0=($)=>!$||$===m2||$===C5?m2:{...m2,...$,promises:{...m2.promises,...$.promises||{}}},U0=/^\\\\\?\\([a-z]:)\\?$/i,x5=($)=>$.replace(/\//g,"\\").replace(U0,"$1\\"),M5=/[\\\/]/,P=0,G0=1,w0=2,g=4,k0=6,C0=8,Q2=10,B0=12,S=15,A2=~S,U$=16,H0=32,L2=64,d=128,E2=256,l2=512,W0=L2|d|l2,I5=1023,G$=($)=>$.isFile()?C0:$.isDirectory()?g:$.isSymbolicLink()?Q2:$.isCharacterDevice()?w0:$.isBlockDevice()?k0:$.isSocket()?B0:$.isFIFO()?G0:P,j0=new G2({max:4096}),_2=($)=>{let Q=j0.get($);if(Q)return Q;let X=$.normalize("NFKD");return j0.set($,X),X},u0=new G2({max:4096}),g2=($)=>{let Q=u0.get($);if(Q)return Q;let X=_2($.toLowerCase());return u0.set($,X),X};class k$ extends G2{constructor(){super({max:256})}}class A0 extends G2{constructor($=16384){super({maxSize:$,sizeCalculation:(Q)=>Q.length+1})}}var m0=Symbol("PathScurry setAsCwd");class T{name;root;roots;parent;nocase;isCWD=!1;#$;#X;get dev(){return this.#X}#V;get mode(){return this.#V}#Z;get nlink(){return this.#Z}#J;get uid(){return this.#J}#B;get gid(){return this.#B}#w;get rdev(){return this.#w}#H;get blksize(){return this.#H}#Y;get ino(){return this.#Y}#j;get size(){return this.#j}#W;get blocks(){return this.#W}#z;get atimeMs(){return this.#z}#q;get mtimeMs(){return this.#q}#u;get ctimeMs(){return this.#u}#A;get birthtimeMs(){return this.#A}#C;get atime(){return this.#C}#v;get mtime(){return this.#v}#O;get ctime(){return this.#O}#U;get birthtime(){return this.#U}#_;#x;#G;#k;#m;#M;#Q;#y;#f;#I;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor($,Q=P,X,q,Z,V,J){if(this.name=$,this.#_=Z?g2($):_2($),this.#Q=Q&I5,this.nocase=Z,this.roots=q,this.root=X||this,this.#y=V,this.#G=J.fullpath,this.#m=J.relative,this.#M=J.relativePosix,this.parent=J.parent,this.parent)this.#$=this.parent.#$;else this.#$=v0(J.fs)}depth(){if(this.#x!==void 0)return this.#x;if(!this.parent)return this.#x=0;return this.#x=this.parent.depth()+1}childrenCache(){return this.#y}resolve($){if(!$)return this;let Q=this.getRootString($),q=$.substring(Q.length).split(this.splitSep);return Q?this.getRoot(Q).#N(q):this.#N(q)}#N($){let Q=this;for(let X of $)Q=Q.child(X);return Q}children(){let $=this.#y.get(this);if($)return $;let Q=Object.assign([],{provisional:0});return this.#y.set(this,Q),this.#Q&=~U$,Q}child($,Q){if($===""||$===".")return this;if($==="..")return this.parent||this;let X=this.children(),q=this.nocase?g2($):_2($);for(let Y of X)if(Y.#_===q)return Y;let Z=this.parent?this.sep:"",V=this.#G?this.#G+Z+$:void 0,J=this.newChild($,P,{...Q,parent:this,fullpath:V});if(!this.canReaddir())J.#Q|=d;return X.push(J),J}relative(){if(this.isCWD)return"";if(this.#m!==void 0)return this.#m;let $=this.name,Q=this.parent;if(!Q)return this.#m=this.name;let X=Q.relative();return X+(!X||!Q.parent?"":this.sep)+$}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#M!==void 0)return this.#M;let $=this.name,Q=this.parent;if(!Q)return this.#M=this.fullpathPosix();let X=Q.relativePosix();return X+(!X||!Q.parent?"":"/")+$}fullpath(){if(this.#G!==void 0)return this.#G;let $=this.name,Q=this.parent;if(!Q)return this.#G=this.name;let q=Q.fullpath()+(!Q.parent?"":this.sep)+$;return this.#G=q}fullpathPosix(){if(this.#k!==void 0)return this.#k;if(this.sep==="/")return this.#k=this.fullpath();if(!this.parent){let q=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(q))return this.#k=`//?/${q}`;else return this.#k=q}let $=this.parent,Q=$.fullpathPosix(),X=Q+(!Q||!$.parent?"":"/")+this.name;return this.#k=X}isUnknown(){return(this.#Q&S)===P}isType($){return this[`is${$}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#Q&S)===C0}isDirectory(){return(this.#Q&S)===g}isCharacterDevice(){return(this.#Q&S)===w0}isBlockDevice(){return(this.#Q&S)===k0}isFIFO(){return(this.#Q&S)===G0}isSocket(){return(this.#Q&S)===B0}isSymbolicLink(){return(this.#Q&Q2)===Q2}lstatCached(){return this.#Q&H0?this:void 0}readlinkCached(){return this.#f}realpathCached(){return this.#I}readdirCached(){let $=this.children();return $.slice(0,$.provisional)}canReadlink(){if(this.#f)return!0;if(!this.parent)return!1;let $=this.#Q&S;return!($!==P&&$!==Q2||this.#Q&E2||this.#Q&d)}calledReaddir(){return!!(this.#Q&U$)}isENOENT(){return!!(this.#Q&d)}isNamed($){return!this.nocase?this.#_===_2($):this.#_===g2($)}async readlink(){let $=this.#f;if($)return $;if(!this.canReadlink())return;if(!this.parent)return;try{let Q=await this.#$.promises.readlink(this.fullpath()),X=(await this.parent.realpath())?.resolve(Q);if(X)return this.#f=X}catch(Q){this.#T(Q.code);return}}readlinkSync(){let $=this.#f;if($)return $;if(!this.canReadlink())return;if(!this.parent)return;try{let Q=this.#$.readlinkSync(this.fullpath()),X=this.parent.realpathSync()?.resolve(Q);if(X)return this.#f=X}catch(Q){this.#T(Q.code);return}}#b($){this.#Q|=U$;for(let Q=$.provisional;Q<$.length;Q++){let X=$[Q];if(X)X.#L()}}#L(){if(this.#Q&d)return;this.#Q=(this.#Q|d)&A2,this.#c()}#c(){let $=this.children();$.provisional=0;for(let Q of $)Q.#L()}#P(){this.#Q|=l2,this.#D()}#D(){if(this.#Q&L2)return;let $=this.#Q;if(($&S)===g)$&=A2;this.#Q=$|L2,this.#c()}#h($=""){if($==="ENOTDIR"||$==="EPERM")this.#D();else if($==="ENOENT")this.#L();else this.children().provisional=0}#R($=""){if($==="ENOTDIR")this.parent.#D();else if($==="ENOENT")this.#L()}#T($=""){let Q=this.#Q;if(Q|=E2,$==="ENOENT")Q|=d;if($==="EINVAL"||$==="UNKNOWN")Q&=A2;if(this.#Q=Q,$==="ENOTDIR"&&this.parent)this.parent.#D()}#d($,Q){return this.#g($,Q)||this.#E($,Q)}#E($,Q){let X=G$($),q=this.newChild($.name,X,{parent:this}),Z=q.#Q&S;if(Z!==g&&Z!==Q2&&Z!==P)q.#Q|=L2;return Q.unshift(q),Q.provisional++,q}#g($,Q){for(let X=Q.provisional;X<Q.length;X++){let q=Q[X];if((this.nocase?g2($.name):_2($.name))!==q.#_)continue;return this.#K($,q,X,Q)}}#K($,Q,X,q){let Z=Q.name;if(Q.#Q=Q.#Q&A2|G$($),Z!==$.name)Q.name=$.name;if(X!==q.provisional){if(X===q.length-1)q.pop();else q.splice(X,1);q.unshift(Q)}return q.provisional++,Q}async lstat(){if((this.#Q&d)===0)try{return this.#l(await this.#$.promises.lstat(this.fullpath())),this}catch($){this.#R($.code)}}lstatSync(){if((this.#Q&d)===0)try{return this.#l(this.#$.lstatSync(this.fullpath())),this}catch($){this.#R($.code)}}#l($){let{atime:Q,atimeMs:X,birthtime:q,birthtimeMs:Z,blksize:V,blocks:J,ctime:Y,ctimeMs:z,dev:H,gid:W,ino:K,mode:j,mtime:u,mtimeMs:U,nlink:v,rdev:k,size:G,uid:w}=$;this.#C=Q,this.#z=X,this.#U=q,this.#A=Z,this.#H=V,this.#W=J,this.#O=Y,this.#u=z,this.#X=H,this.#B=W,this.#Y=K,this.#V=j,this.#v=u,this.#q=U,this.#Z=v,this.#w=k,this.#j=G,this.#J=w;let B=G$($);if(this.#Q=this.#Q&A2|B|H0,B!==P&&B!==g&&B!==Q2)this.#Q|=L2}#S=[];#F=!1;#o($){this.#F=!1;let Q=this.#S.slice();this.#S.length=0,Q.forEach((X)=>X(null,$))}readdirCB($,Q=!1){if(!this.canReaddir()){if(Q)$(null,[]);else queueMicrotask(()=>$(null,[]));return}let X=this.children();if(this.calledReaddir()){let Z=X.slice(0,X.provisional);if(Q)$(null,Z);else queueMicrotask(()=>$(null,Z));return}if(this.#S.push($),this.#F)return;this.#F=!0;let q=this.fullpath();this.#$.readdir(q,{withFileTypes:!0},(Z,V)=>{if(Z)this.#h(Z.code),X.provisional=0;else{for(let J of V)this.#d(J,X);this.#b(X)}this.#o(X.slice(0,X.provisional));return})}#i;async readdir(){if(!this.canReaddir())return[];let $=this.children();if(this.calledReaddir())return $.slice(0,$.provisional);let Q=this.fullpath();if(this.#i)await this.#i;else{let X=()=>{};this.#i=new Promise((q)=>X=q);try{for(let q of await this.#$.promises.readdir(Q,{withFileTypes:!0}))this.#d(q,$);this.#b($)}catch(q){this.#h(q.code),$.provisional=0}this.#i=void 0,X()}return $.slice(0,$.provisional)}readdirSync(){if(!this.canReaddir())return[];let $=this.children();if(this.calledReaddir())return $.slice(0,$.provisional);let Q=this.fullpath();try{for(let X of this.#$.readdirSync(Q,{withFileTypes:!0}))this.#d(X,$);this.#b($)}catch(X){this.#h(X.code),$.provisional=0}return $.slice(0,$.provisional)}canReaddir(){if(this.#Q&W0)return!1;let $=S&this.#Q;if(!($===P||$===g||$===Q2))return!1;return!0}shouldWalk($,Q){return(this.#Q&g)===g&&!(this.#Q&W0)&&!$.has(this)&&(!Q||Q(this))}async realpath(){if(this.#I)return this.#I;if((l2|E2|d)&this.#Q)return;try{let $=await this.#$.promises.realpath(this.fullpath());return this.#I=this.resolve($)}catch($){this.#P()}}realpathSync(){if(this.#I)return this.#I;if((l2|E2|d)&this.#Q)return;try{let $=this.#$.realpathSync(this.fullpath());return this.#I=this.resolve($)}catch($){this.#P()}}[m0]($){if($===this)return;$.isCWD=!1,this.isCWD=!0;let Q=new Set([]),X=[],q=this;while(q&&q.parent)Q.add(q),q.#m=X.join(this.sep),q.#M=X.join("/"),q=q.parent,X.push("..");q=$;while(q&&q.parent&&!Q.has(q))q.#m=void 0,q.#M=void 0,q=q.parent}}class c2 extends T{sep="\\";splitSep=M5;constructor($,Q=P,X,q,Z,V,J){super($,Q,X,q,Z,V,J)}newChild($,Q=P,X={}){return new c2($,Q,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString($){return w$.parse($).root}getRoot($){if($=x5($.toUpperCase()),$===this.root.name)return this.root;for(let[Q,X]of Object.entries(this.roots))if(this.sameRoot($,Q))return this.roots[$]=X;return this.roots[$]=new x2($,this).root}sameRoot($,Q=this.root.name){return $=$.toUpperCase().replace(/\//g,"\\").replace(U0,"$1\\"),$===Q}}class o2 extends T{splitSep="/";sep="/";constructor($,Q=P,X,q,Z,V,J){super($,Q,X,q,Z,V,J)}getRootString($){return $.startsWith("/")?"/":""}getRoot($){return this.root}newChild($,Q=P,X={}){return new o2($,Q,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class C${root;rootPath;roots;cwd;#$;#X;#V;nocase;#Z;constructor($=process.cwd(),Q,X,{nocase:q,childrenCacheSize:Z=16384,fs:V=m2}={}){if(this.#Z=v0(V),$ instanceof URL||$.startsWith("file://"))$=u5($);let J=Q.resolve($);this.roots=Object.create(null),this.rootPath=this.parseRootPath(J),this.#$=new k$,this.#X=new k$,this.#V=new A0(Z);let Y=J.substring(this.rootPath.length).split(X);if(Y.length===1&&!Y[0])Y.pop();if(q===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=q,this.root=this.newRoot(this.#Z),this.roots[this.rootPath]=this.root;let z=this.root,H=Y.length-1,W=Q.sep,K=this.rootPath,j=!1;for(let u of Y){let U=H--;z=z.child(u,{relative:Array(U).fill("..").join(W),relativePosix:Array(U).fill("..").join("/"),fullpath:K+=(j?"":W)+u}),j=!0}this.cwd=z}depth($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.depth()}childrenCache(){return this.#V}resolve(...$){let Q="";for(let Z=$.length-1;Z>=0;Z--){let V=$[Z];if(!V||V===".")continue;if(Q=Q?`${V}/${Q}`:V,this.isAbsolute(V))break}let X=this.#$.get(Q);if(X!==void 0)return X;let q=this.cwd.resolve(Q).fullpath();return this.#$.set(Q,q),q}resolvePosix(...$){let Q="";for(let Z=$.length-1;Z>=0;Z--){let V=$[Z];if(!V||V===".")continue;if(Q=Q?`${V}/${Q}`:V,this.isAbsolute(V))break}let X=this.#X.get(Q);if(X!==void 0)return X;let q=this.cwd.resolve(Q).fullpathPosix();return this.#X.set(Q,q),q}relative($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.relative()}relativePosix($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.relativePosix()}basename($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.name}dirname($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return($.parent||$).fullpath()}async readdir($=this.cwd,Q={withFileTypes:!0}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof T))Q=$,$=this.cwd;let{withFileTypes:X}=Q;if(!$.canReaddir())return[];else{let q=await $.readdir();return X?q:q.map((Z)=>Z.name)}}readdirSync($=this.cwd,Q={withFileTypes:!0}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof T))Q=$,$=this.cwd;let{withFileTypes:X=!0}=Q;if(!$.canReaddir())return[];else if(X)return $.readdirSync();else return $.readdirSync().map((q)=>q.name)}async lstat($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.lstat()}lstatSync($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.lstatSync()}async readlink($=this.cwd,{withFileTypes:Q}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof T))Q=$.withFileTypes,$=this.cwd;let X=await $.readlink();return Q?X:X?.fullpath()}readlinkSync($=this.cwd,{withFileTypes:Q}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof T))Q=$.withFileTypes,$=this.cwd;let X=$.readlinkSync();return Q?X:X?.fullpath()}async realpath($=this.cwd,{withFileTypes:Q}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof T))Q=$.withFileTypes,$=this.cwd;let X=await $.realpath();return Q?X:X?.fullpath()}realpathSync($=this.cwd,{withFileTypes:Q}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof T))Q=$.withFileTypes,$=this.cwd;let X=$.realpathSync();return Q?X:X?.fullpath()}async walk($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof T))Q=$,$=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Z,walkFilter:V}=Q,J=[];if(!Z||Z($))J.push(X?$:$.fullpath());let Y=new Set,z=(W,K)=>{Y.add(W),W.readdirCB((j,u)=>{if(j)return K(j);let U=u.length;if(!U)return K();let v=()=>{if(--U===0)K()};for(let k of u){if(!Z||Z(k))J.push(X?k:k.fullpath());if(q&&k.isSymbolicLink())k.realpath().then((G)=>G?.isUnknown()?G.lstat():G).then((G)=>G?.shouldWalk(Y,V)?z(G,v):v());else if(k.shouldWalk(Y,V))z(k,v);else v()}},!0)},H=$;return new Promise((W,K)=>{z(H,(j)=>{if(j)return K(j);W(J)})})}walkSync($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof T))Q=$,$=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Z,walkFilter:V}=Q,J=[];if(!Z||Z($))J.push(X?$:$.fullpath());let Y=new Set([$]);for(let z of Y){let H=z.readdirSync();for(let W of H){if(!Z||Z(W))J.push(X?W:W.fullpath());let K=W;if(W.isSymbolicLink()){if(!(q&&(K=W.realpathSync())))continue;if(K.isUnknown())K.lstatSync()}if(K.shouldWalk(Y,V))Y.add(K)}}return J}[Symbol.asyncIterator](){return this.iterate()}iterate($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof T))Q=$,$=this.cwd;return this.stream($,Q)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof T))Q=$,$=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Z,walkFilter:V}=Q;if(!Z||Z($))yield X?$:$.fullpath();let J=new Set([$]);for(let Y of J){let z=Y.readdirSync();for(let H of z){if(!Z||Z(H))yield X?H:H.fullpath();let W=H;if(H.isSymbolicLink()){if(!(q&&(W=H.realpathSync())))continue;if(W.isUnknown())W.lstatSync()}if(W.shouldWalk(J,V))J.add(W)}}}stream($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof T))Q=$,$=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Z,walkFilter:V}=Q,J=new $2({objectMode:!0});if(!Z||Z($))J.write(X?$:$.fullpath());let Y=new Set,z=[$],H=0,W=()=>{let K=!1;while(!K){let j=z.shift();if(!j){if(H===0)J.end();return}H++,Y.add(j);let u=(v,k,G=!1)=>{if(v)return J.emit("error",v);if(q&&!G){let w=[];for(let B of k)if(B.isSymbolicLink())w.push(B.realpath().then((A)=>A?.isUnknown()?A.lstat():A));if(w.length){Promise.all(w).then(()=>u(null,k,!0));return}}for(let w of k)if(w&&(!Z||Z(w))){if(!J.write(X?w:w.fullpath()))K=!0}H--;for(let w of k){let B=w.realpathCached()||w;if(B.shouldWalk(Y,V))z.push(B)}if(K&&!J.flowing)J.once("drain",W);else if(!U)W()},U=!0;j.readdirCB(u,!0),U=!1}};return W(),J}streamSync($=this.cwd,Q={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof T))Q=$,$=this.cwd;let{withFileTypes:X=!0,follow:q=!1,filter:Z,walkFilter:V}=Q,J=new $2({objectMode:!0}),Y=new Set;if(!Z||Z($))J.write(X?$:$.fullpath());let z=[$],H=0,W=()=>{let K=!1;while(!K){let j=z.shift();if(!j){if(H===0)J.end();return}H++,Y.add(j);let u=j.readdirSync();for(let U of u)if(!Z||Z(U)){if(!J.write(X?U:U.fullpath()))K=!0}H--;for(let U of u){let v=U;if(U.isSymbolicLink()){if(!(q&&(v=U.realpathSync())))continue;if(v.isUnknown())v.lstatSync()}if(v.shouldWalk(Y,V))z.push(v)}}if(K&&!J.flowing)J.once("drain",W)};return W(),J}chdir($=this.cwd){let Q=this.cwd;this.cwd=typeof $==="string"?this.cwd.resolve($):$,this.cwd[m0](Q)}}class x2 extends C${sep="\\";constructor($=process.cwd(),Q={}){let{nocase:X=!0}=Q;super($,w$,"\\",{...Q,nocase:X});this.nocase=X;for(let q=this.cwd;q;q=q.parent)q.nocase=this.nocase}parseRootPath($){return w$.parse($).root.toUpperCase()}newRoot($){return new c2(this.rootPath,g,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")||$.startsWith("\\")||/^[a-z]:(\/|\\)/i.test($)}}class M2 extends C${sep="/";constructor($=process.cwd(),Q={}){let{nocase:X=!1}=Q;super($,j5,"/",{...Q,nocase:X});this.nocase=X}parseRootPath($){return"/"}newRoot($){return new o2(this.rootPath,g,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")}}class i2 extends M2{constructor($=process.cwd(),Q={}){let{nocase:X=!0}=Q;super($,{...Q,nocase:X})}}var G6=process.platform==="win32"?c2:o2,L0=process.platform==="win32"?x2:process.platform==="darwin"?i2:M2;var O5=($)=>$.length>=1,F5=($)=>$.length>=1;class Y2{#$;#X;#V;length;#Z;#J;#B;#w;#H;#Y;#j=!0;constructor($,Q,X,q){if(!O5($))throw TypeError("empty pattern list");if(!F5(Q))throw TypeError("empty glob list");if(Q.length!==$.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=$.length,X<0||X>=this.length)throw TypeError("index out of range");if(this.#$=$,this.#X=Q,this.#V=X,this.#Z=q,this.#V===0){if(this.isUNC()){let[Z,V,J,Y,...z]=this.#$,[H,W,K,j,...u]=this.#X;if(z[0]==="")z.shift(),u.shift();let U=[Z,V,J,Y,""].join("/"),v=[H,W,K,j,""].join("/");this.#$=[U,...z],this.#X=[v,...u],this.length=this.#$.length}else if(this.isDrive()||this.isAbsolute()){let[Z,...V]=this.#$,[J,...Y]=this.#X;if(V[0]==="")V.shift(),Y.shift();let z=Z+"/",H=J+"/";this.#$=[z,...V],this.#X=[H,...Y],this.length=this.#$.length}}}pattern(){return this.#$[this.#V]}isString(){return typeof this.#$[this.#V]==="string"}isGlobstar(){return this.#$[this.#V]===I}isRegExp(){return this.#$[this.#V]instanceof RegExp}globString(){return this.#B=this.#B||(this.#V===0?this.isAbsolute()?this.#X[0]+this.#X.slice(1).join("/"):this.#X.join("/"):this.#X.slice(this.#V).join("/"))}hasMore(){return this.length>this.#V+1}rest(){if(this.#J!==void 0)return this.#J;if(!this.hasMore())return this.#J=null;return this.#J=new Y2(this.#$,this.#X,this.#V+1,this.#Z),this.#J.#Y=this.#Y,this.#J.#H=this.#H,this.#J.#w=this.#w,this.#J}isUNC(){let $=this.#$;return this.#H!==void 0?this.#H:this.#H=this.#Z==="win32"&&this.#V===0&&$[0]===""&&$[1]===""&&typeof $[2]==="string"&&!!$[2]&&typeof $[3]==="string"&&!!$[3]}isDrive(){let $=this.#$;return this.#w!==void 0?this.#w:this.#w=this.#Z==="win32"&&this.#V===0&&this.length>1&&typeof $[0]==="string"&&/^[a-z]:$/i.test($[0])}isAbsolute(){let $=this.#$;return this.#Y!==void 0?this.#Y:this.#Y=$[0]===""&&$.length>1||this.isDrive()||this.isUNC()}root(){let $=this.#$[0];return typeof $==="string"&&this.isAbsolute()&&this.#V===0?$:""}checkFollowGlobstar(){return!(this.#V===0||!this.isGlobstar()||!this.#j)}markFollowGlobstar(){if(this.#V===0||!this.isGlobstar()||!this.#j)return!1;return this.#j=!1,!0}}var R5=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class I2{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor($,{nobrace:Q,nocase:X,noext:q,noglobstar:Z,platform:V=R5}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=V,this.mmopts={dot:!0,nobrace:Q,nocase:X,noext:q,noglobstar:Z,optimizationLevel:2,platform:V,nocomment:!0,nonegate:!0};for(let J of $)this.add(J)}add($){let Q=new D($,this.mmopts);for(let X=0;X<Q.set.length;X++){let q=Q.set[X],Z=Q.globParts[X];if(!q||!Z)throw Error("invalid pattern object");while(q[0]==="."&&Z[0]===".")q.shift(),Z.shift();let V=new Y2(q,Z,0,this.platform),J=new D(V.globString(),this.mmopts),Y=Z[Z.length-1]==="**",z=V.isAbsolute();if(z)this.absolute.push(J);else this.relative.push(J);if(Y)if(z)this.absoluteChildren.push(J);else this.relativeChildren.push(J)}}ignored($){let Q=$.fullpath(),X=`${Q}/`,q=$.relative()||".",Z=`${q}/`;for(let V of this.relative)if(V.match(q)||V.match(Z))return!0;for(let V of this.absolute)if(V.match(Q)||V.match(X))return!0;return!1}childrenIgnored($){let Q=$.fullpath()+"/",X=($.relative()||".")+"/";for(let q of this.relativeChildren)if(q.match(X))return!0;for(let q of this.absoluteChildren)if(q.match(Q))return!0;return!1}}class B${store;constructor($=new Map){this.store=$}copy(){return new B$(new Map(this.store))}hasWalked($,Q){return this.store.get($.fullpath())?.has(Q.globString())}storeWalked($,Q){let X=$.fullpath(),q=this.store.get(X);if(q)q.add(Q.globString());else this.store.set(X,new Set([Q.globString()]))}}class _0{store=new Map;add($,Q,X){let q=(Q?2:0)|(X?1:0),Z=this.store.get($);this.store.set($,Z===void 0?q:q&Z)}entries(){return[...this.store.entries()].map(([$,Q])=>[$,!!(Q&2),!!(Q&1)])}}class x0{store=new Map;add($,Q){if(!$.canReaddir())return;let X=this.store.get($);if(X){if(!X.find((q)=>q.globString()===Q.globString()))X.push(Q)}else this.store.set($,[Q])}get($){let Q=this.store.get($);if(!Q)throw Error("attempting to walk unknown path");return Q}entries(){return this.keys().map(($)=>[$,this.store.get($)])}keys(){return[...this.store.keys()].filter(($)=>$.canReaddir())}}class O2{hasWalkedCache;matches=new _0;subwalks=new x0;patterns;follow;dot;opts;constructor($,Q){this.opts=$,this.follow=!!$.follow,this.dot=!!$.dot,this.hasWalkedCache=Q?Q.copy():new B$}processPatterns($,Q){this.patterns=Q;let X=Q.map((q)=>[$,q]);for(let[q,Z]of X){this.hasWalkedCache.storeWalked(q,Z);let V=Z.root(),J=Z.isAbsolute()&&this.opts.absolute!==!1;if(V){q=q.resolve(V==="/"&&this.opts.root!==void 0?this.opts.root:V);let W=Z.rest();if(!W){this.matches.add(q,!0,!1);continue}else Z=W}if(q.isENOENT())continue;let Y,z,H=!1;while(typeof(Y=Z.pattern())==="string"&&(z=Z.rest()))q=q.resolve(Y),Z=z,H=!0;if(Y=Z.pattern(),z=Z.rest(),H){if(this.hasWalkedCache.hasWalked(q,Z))continue;this.hasWalkedCache.storeWalked(q,Z)}if(typeof Y==="string"){let W=Y===".."||Y===""||Y===".";this.matches.add(q.resolve(Y),J,W);continue}else if(Y===I){if(!q.isSymbolicLink()||this.follow||Z.checkFollowGlobstar())this.subwalks.add(q,Z);let W=z?.pattern(),K=z?.rest();if(!z||(W===""||W===".")&&!K)this.matches.add(q,J,W===""||W===".");else if(W===".."){let j=q.parent||q;if(!K)this.matches.add(j,J,!0);else if(!this.hasWalkedCache.hasWalked(j,K))this.subwalks.add(j,K)}}else if(Y instanceof RegExp)this.subwalks.add(q,Z)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new O2(this.opts,this.hasWalkedCache)}filterEntries($,Q){let X=this.subwalks.get($),q=this.child();for(let Z of Q)for(let V of X){let J=V.isAbsolute(),Y=V.pattern(),z=V.rest();if(Y===I)q.testGlobstar(Z,V,z,J);else if(Y instanceof RegExp)q.testRegExp(Z,Y,z,J);else q.testString(Z,Y,z,J)}return q}testGlobstar($,Q,X,q){if(this.dot||!$.name.startsWith(".")){if(!Q.hasMore())this.matches.add($,q,!1);if($.canReaddir()){if(this.follow||!$.isSymbolicLink())this.subwalks.add($,Q);else if($.isSymbolicLink()){if(X&&Q.checkFollowGlobstar())this.subwalks.add($,X);else if(Q.markFollowGlobstar())this.subwalks.add($,Q)}}}if(X){let Z=X.pattern();if(typeof Z==="string"&&Z!==".."&&Z!==""&&Z!==".")this.testString($,Z,X.rest(),q);else if(Z===".."){let V=$.parent||$;this.subwalks.add(V,X)}else if(Z instanceof RegExp)this.testRegExp($,Z,X.rest(),q)}}testRegExp($,Q,X,q){if(!Q.test($.name))return;if(!X)this.matches.add($,q,!1);else this.subwalks.add($,X)}testString($,Q,X,q){if(!$.isNamed(Q))return;if(!X)this.matches.add($,q,!1);else this.subwalks.add($,X)}}var T5=($,Q)=>typeof $==="string"?new I2([$],Q):Array.isArray($)?new I2($,Q):$;class A${path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#$=[];#X;#V;signal;maxDepth;includeChildMatches;constructor($,Q,X){if(this.patterns=$,this.path=Q,this.opts=X,this.#V=!X.posix&&X.platform==="win32"?"\\":"/",this.includeChildMatches=X.includeChildMatches!==!1,X.ignore||!this.includeChildMatches){if(this.#X=T5(X.ignore??[],X),!this.includeChildMatches&&typeof this.#X.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=X.maxDepth||1/0,X.signal)this.signal=X.signal,this.signal.addEventListener("abort",()=>{this.#$.length=0})}#Z($){return this.seen.has($)||!!this.#X?.ignored?.($)}#J($){return!!this.#X?.childrenIgnored?.($)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let $=void 0;while(!this.paused&&($=this.#$.shift()))$()}onResume($){if(this.signal?.aborted)return;if(!this.paused)$();else this.#$.push($)}async matchCheck($,Q){if(Q&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=$.realpathCached()||await $.realpath(),!X)return;$=X}let Z=$.isUnknown()||this.opts.stat?await $.lstat():$;if(this.opts.follow&&this.opts.nodir&&Z?.isSymbolicLink()){let V=await Z.realpath();if(V&&(V.isUnknown()||this.opts.stat))await V.lstat()}return this.matchCheckTest(Z,Q)}matchCheckTest($,Q){return $&&(this.maxDepth===1/0||$.depth()<=this.maxDepth)&&(!Q||$.canReaddir())&&(!this.opts.nodir||!$.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!$.isSymbolicLink()||!$.realpathCached()?.isDirectory())&&!this.#Z($)?$:void 0}matchCheckSync($,Q){if(Q&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=$.realpathCached()||$.realpathSync(),!X)return;$=X}let Z=$.isUnknown()||this.opts.stat?$.lstatSync():$;if(this.opts.follow&&this.opts.nodir&&Z?.isSymbolicLink()){let V=Z.realpathSync();if(V&&(V?.isUnknown()||this.opts.stat))V.lstatSync()}return this.matchCheckTest(Z,Q)}matchFinish($,Q){if(this.#Z($))return;if(!this.includeChildMatches&&this.#X?.add){let Z=`${$.relativePosix()}/**`;this.#X.add(Z)}let X=this.opts.absolute===void 0?Q:this.opts.absolute;this.seen.add($);let q=this.opts.mark&&$.isDirectory()?this.#V:"";if(this.opts.withFileTypes)this.matchEmit($);else if(X){let Z=this.opts.posix?$.fullpathPosix():$.fullpath();this.matchEmit(Z+q)}else{let Z=this.opts.posix?$.relativePosix():$.relative(),V=this.opts.dotRelative&&!Z.startsWith(".."+this.#V)?"."+this.#V:"";this.matchEmit(!Z?"."+q:V+Z+q)}}async match($,Q,X){let q=await this.matchCheck($,X);if(q)this.matchFinish(q,Q)}matchSync($,Q,X){let q=this.matchCheckSync($,X);if(q)this.matchFinish(q,Q)}walkCB($,Q,X){if(this.signal?.aborted)X();this.walkCB2($,Q,new O2(this.opts),X)}walkCB2($,Q,X,q){if(this.#J($))return q();if(this.signal?.aborted)q();if(this.paused){this.onResume(()=>this.walkCB2($,Q,X,q));return}X.processPatterns($,Q);let Z=1,V=()=>{if(--Z===0)q()};for(let[J,Y,z]of X.matches.entries()){if(this.#Z(J))continue;Z++,this.match(J,Y,z).then(()=>V())}for(let J of X.subwalkTargets()){if(this.maxDepth!==1/0&&J.depth()>=this.maxDepth)continue;Z++;let Y=J.readdirCached();if(J.calledReaddir())this.walkCB3(J,Y,X,V);else J.readdirCB((z,H)=>this.walkCB3(J,H,X,V),!0)}V()}walkCB3($,Q,X,q){X=X.filterEntries($,Q);let Z=1,V=()=>{if(--Z===0)q()};for(let[J,Y,z]of X.matches.entries()){if(this.#Z(J))continue;Z++,this.match(J,Y,z).then(()=>V())}for(let[J,Y]of X.subwalks.entries())Z++,this.walkCB2(J,Y,X.child(),V);V()}walkCBSync($,Q,X){if(this.signal?.aborted)X();this.walkCB2Sync($,Q,new O2(this.opts),X)}walkCB2Sync($,Q,X,q){if(this.#J($))return q();if(this.signal?.aborted)q();if(this.paused){this.onResume(()=>this.walkCB2Sync($,Q,X,q));return}X.processPatterns($,Q);let Z=1,V=()=>{if(--Z===0)q()};for(let[J,Y,z]of X.matches.entries()){if(this.#Z(J))continue;this.matchSync(J,Y,z)}for(let J of X.subwalkTargets()){if(this.maxDepth!==1/0&&J.depth()>=this.maxDepth)continue;Z++;let Y=J.readdirSync();this.walkCB3Sync(J,Y,X,V)}V()}walkCB3Sync($,Q,X,q){X=X.filterEntries($,Q);let Z=1,V=()=>{if(--Z===0)q()};for(let[J,Y,z]of X.matches.entries()){if(this.#Z(J))continue;this.matchSync(J,Y,z)}for(let[J,Y]of X.subwalks.entries())Z++,this.walkCB2Sync(J,Y,X.child(),V);V()}}class n2 extends A${matches=new Set;constructor($,Q,X){super($,Q,X)}matchEmit($){this.matches.add($)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise(($,Q)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)Q(this.signal.reason);else $(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class a2 extends A${results;constructor($,Q,X){super($,Q,X);this.results=new $2({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit($){if(this.results.write($),!this.results.flowing)this.pause()}stream(){let $=this.path;if($.isUnknown())$.lstat().then(()=>{this.walkCB($,this.patterns,()=>this.results.end())});else this.walkCB($,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var N5=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class l{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor($,Q){if(!Q)throw TypeError("glob options required");if(this.withFileTypes=!!Q.withFileTypes,this.signal=Q.signal,this.follow=!!Q.follow,this.dot=!!Q.dot,this.dotRelative=!!Q.dotRelative,this.nodir=!!Q.nodir,this.mark=!!Q.mark,!Q.cwd)this.cwd="";else if(Q.cwd instanceof URL||Q.cwd.startsWith("file://"))Q.cwd=f5(Q.cwd);if(this.cwd=Q.cwd||"",this.root=Q.root,this.magicalBraces=!!Q.magicalBraces,this.nobrace=!!Q.nobrace,this.noext=!!Q.noext,this.realpath=!!Q.realpath,this.absolute=Q.absolute,this.includeChildMatches=Q.includeChildMatches!==!1,this.noglobstar=!!Q.noglobstar,this.matchBase=!!Q.matchBase,this.maxDepth=typeof Q.maxDepth==="number"?Q.maxDepth:1/0,this.stat=!!Q.stat,this.ignore=Q.ignore,this.withFileTypes&&this.absolute!==void 0)throw Error("cannot set absolute and withFileTypes:true");if(typeof $==="string")$=[$];if(this.windowsPathsNoEscape=!!Q.windowsPathsNoEscape||Q.allowWindowsEscape===!1,this.windowsPathsNoEscape)$=$.map((Y)=>Y.replace(/\\/g,"/"));if(this.matchBase){if(Q.noglobstar)throw TypeError("base matching requires globstar");$=$.map((Y)=>Y.includes("/")?Y:`./**/${Y}`)}if(this.pattern=$,this.platform=Q.platform||N5,this.opts={...Q,platform:this.platform},Q.scurry){if(this.scurry=Q.scurry,Q.nocase!==void 0&&Q.nocase!==Q.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let Y=Q.platform==="win32"?x2:Q.platform==="darwin"?i2:Q.platform?M2:L0;this.scurry=new Y(this.cwd,{nocase:Q.nocase,fs:Q.fs})}this.nocase=this.scurry.nocase;let X=this.platform==="darwin"||this.platform==="win32",q={...Q,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:X,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},Z=this.pattern.map((Y)=>new D(Y,q)),[V,J]=Z.reduce((Y,z)=>{return Y[0].push(...z.set),Y[1].push(...z.globParts),Y},[[],[]]);this.patterns=V.map((Y,z)=>{let H=J[z];if(!H)throw Error("invalid pattern object");return new Y2(Y,H,0,this.platform)})}async walk(){return[...await new n2(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new n2(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new a2(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new a2(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var m$=($,Q={})=>{if(!Array.isArray($))$=[$];for(let X of $)if(new D(X,Q).hasMagic())return!0;return!1};function p2($,Q={}){return new l($,Q).streamSync()}function I0($,Q={}){return new l($,Q).stream()}function O0($,Q={}){return new l($,Q).walkSync()}async function M0($,Q={}){return new l($,Q).walk()}function r2($,Q={}){return new l($,Q).iterateSync()}function F0($,Q={}){return new l($,Q).iterate()}var y5=p2,D5=Object.assign(I0,{sync:p2}),S5=r2,P5=Object.assign(F0,{sync:r2}),b5=Object.assign(O0,{stream:p2,iterate:r2}),s2=Object.assign(M0,{glob:M0,globSync:O0,sync:b5,globStream:I0,stream:D5,globStreamSync:p2,streamSync:y5,globIterate:F0,iterate:P5,globIterateSync:r2,iterateSync:S5,Glob:l,hasMagic:m$,escape:Z2,unescape:b});s2.glob=s2;var d5=e2.object({description:e2.string().optional().describe("what you want to do"),pattern:e2.string().describe("The glob pattern to match files against"),path:e2.string().optional().describe('The directory to search in. If not specified, the current working directory will be used. IMPORTANT: Omit this field to use the default directory. DO NOT enter "undefined" or "null" - simply omit it for the default behavior. Must be a valid directory path if provided.')}),R0=h5(async({pattern:$,path:Q})=>{let X=await s2($,{ignore:["node_modules",".git","dist","build",".next",".turbo","coverage",".nyc_output","temp",".cache","vendor","venv","__pycache__","*.pyc","target","out",".output"],cwd:Q,absolute:!0});if(X.length===0)return"No files found.";return X.join(`
|
|
52
|
+
`)},{name:"glob_files",description:`- Fast file pattern matching tool that works with any codebase size
|
|
53
|
+
- Supports glob patterns like "**/*.js" or "src/**/*.ts"
|
|
54
|
+
- Returns matching file paths sorted by modification time
|
|
55
|
+
- Use this tool when you need to find files by name patterns
|
|
56
|
+
- When you are doing an open ended search that may require multiple rounds of globbing and grepping, use the Agent tool instead
|
|
57
|
+
- You have the capability to call multiple tools in a single response. It is always better to speculatively perform multiple searches as a batch that are potentially useful.`,schema:d5});import{tool as XQ}from"@langchain/core/tools";import{z as R2}from"zod";import{execa as f0}from"execa";import E5 from"extract-zip";import g5 from"fs-extra";import*as F2 from"node:os";import{dirname as N0,join as l5}from"node:path";import{pipeline as c5}from"node:stream/promises";import{fileURLToPath as o5}from"node:url";import{pathExists as T0}from"path-exists";import{temporaryFile as i5}from"tempy";import{xdgCache as n5}from"xdg-basedir";var{mkdir:_$,createWriteStream:a5,move:s5}=g5,y0=N0(o5(import.meta.url)),p5="microsoft/ripgrep-prebuilt",L$=process.env.RIPGREP_VERSION||"v15.0.0",r5=()=>{let $=process.env.npm_config_arch||F2.arch(),Q=process.env.platform||F2.platform();switch(Q){case"darwin":switch($){case"arm64":return"aarch64-apple-darwin.tar.gz";default:return"x86_64-apple-darwin.tar.gz"}case"win32":switch($){case"x64":return"x86_64-pc-windows-msvc.zip";case"arm":return"aarch64-pc-windows-msvc.zip";default:return"i686-pc-windows-msvc.zip"}case"linux":switch($){case"x64":return"x86_64-unknown-linux-musl.tar.gz";case"arm":case"armv7l":return"arm-unknown-linux-gnueabihf.tar.gz";case"arm64":return"aarch64-unknown-linux-gnu.tar.gz";case"ppc64":return"powerpc64le-unknown-linux-gnu.tar.gz";case"s390x":return"s390x-unknown-linux-gnu.tar.gz";default:return"i686-unknown-linux-musl.tar.gz"}default:throw Error("Unknown platform: "+Q)}},e5=async($,Q)=>{try{let X=i5(),q=await fetch($);if(!q.ok)throw Error(`HTTP ${q.status}: ${q.statusText}`);await c5(q.body,a5(X)),await _$(N0(Q),{recursive:!0}),await s5(X,Q)}catch(X){throw console.error(`Failed to download "${$}"`),X}},t5=async($,Q)=>{try{await _$(Q,{recursive:!0}),await E5($,{dir:Q})}catch(X){throw console.error(`Failed to unzip "${$}"`),X}},$Q=async($,Q)=>{try{await _$(Q,{recursive:!0}),await f0("tar",["xvf",$,"-C",Q])}catch(X){throw console.error(`Failed to extract "${$}"`),X}},QQ=async($)=>{if($==="android")try{return await f0("pkg",["install","ripgrep","-y"]),!0}catch(Q){return console.info("Could not install ripgrep via pkg. Falling back to download."),!1}return!1},x$=l5(y0,`rg${process.platform==="win32"?".exe":""}`),Z8=async($)=>{if(await T0(x$)){console.log("rg cached");return}let Q=process.env.platform||F2.platform();if(Q==="android"){if(await QQ(Q))return}let X=r5(),Z=`${process.env.RIPGREP_PREBUILT_BINARIES_MIRROR||`https://v6.gh-proxy.org/https://github.com/${p5}/releases/download`}/${L$}/ripgrep-${L$}-${X}`,V=`${n5}/vscode-ripgrep/ripgrep-${L$}-${X}`,J=$??y0;if(!await T0(V))await e5(Z,V);else console.info(`File ${V} has been cached`);if(V.endsWith(".tar.gz"))await $Q(V,J);else if(V.endsWith(".zip"))await t5(V,J);else throw Error(`Invalid downloadPath ${V}`)};import{execa as qQ}from"execa";var ZQ=async($,Q,X={})=>{let{timeout:q=15000,cwd:Z=process.cwd()}=X;try{let V=await qQ($,Q,{cwd:Z,timeout:q,reject:!1,stripFinalNewline:!1,stdio:["pipe","pipe","pipe"],env:process.env});return{code:V.exitCode??0,stdout:V.stdout,stderr:V.stderr}}catch(V){if(V.timedOut)return{code:124,stdout:V.stdout||"",stderr:(V.stderr||"")+`
|
|
58
|
+
Process timed out`};return{code:V.exitCode||1,stdout:V.stdout||"",stderr:V.stderr||V.message||"Unknown error"}}},D0=XQ(async({args:$,head_limit:Q})=>{if(!$||$.length===0)return"Error: No arguments provided. Please provide ripgrep arguments.";if(!Q&&!$.includes("--max-count"))Q=500;let X=await ZQ(x$,$,{timeout:15000,cwd:process.cwd()});if(Q&&X.stdout){let q=X.stdout.split(`
|
|
59
|
+
`);if(q.length>Q)X.stdout=q.slice(0,Q).join(`
|
|
60
|
+
`)}if(X.code!==0&&X.stderr){if(X.code===1&&X.stdout==="")return"No matches found.";if(X.code===124||X.stderr.includes("timeout")||X.stderr.includes("timed out"))return"Error: Search timed out after 15 seconds. Please use a more specific pattern or limit the search scope with type/glob/path parameters.";return`Error executing ripgrep: ${X.stderr}`}return X.stdout||"No matches found."},{name:"search_files_rg",description:`Ripgrep (rg) - A fast text search tool that recursively searches directories for regex patterns
|
|
61
|
+
|
|
62
|
+
⚠️ IMPORTANT USAGE GUIDELINES:
|
|
63
|
+
- This tool wraps the ripgrep (rg) command-line tool
|
|
64
|
+
- Use this ONLY for searching TEXT PATTERNS within file contents
|
|
65
|
+
- For reading entire files, use the Read tool instead
|
|
66
|
+
- For finding files by name patterns, use the Glob tool instead
|
|
67
|
+
|
|
68
|
+
\uD83D\uDD0D SEARCH PATH REQUIREMENT:
|
|
69
|
+
- MUST always specify a search path at the end of args array
|
|
70
|
+
- If no specific path needed, use "./" for current directory
|
|
71
|
+
- Never omit the path parameter - ripgrep requires it
|
|
72
|
+
|
|
73
|
+
Usage - Pass ripgrep (rg) arguments as an array:
|
|
74
|
+
The args array corresponds directly to 'rg [OPTIONS] PATTERN [PATH ...]'
|
|
75
|
+
|
|
76
|
+
Examples:
|
|
77
|
+
- Search pattern in current directory: ["PATTERN", "./"]
|
|
78
|
+
- Search in specific path: ["PATTERN", "src/"]
|
|
79
|
+
- Search with file type filter: ["--type", "ts", "PATTERN", "./"]
|
|
80
|
+
- Case insensitive search: ["-i", "PATTERN", "./"]
|
|
81
|
+
- Show line numbers: ["-n", "PATTERN", "./"]
|
|
82
|
+
- Show context lines: ["-C", "3", "PATTERN", "./"]
|
|
83
|
+
- Only show file names: ["-l", "PATTERN", "./"]
|
|
84
|
+
- Count matches: ["-c", "PATTERN", "./"]
|
|
85
|
+
- Multiple options: ["-n", "-i", "--type", "js", "function", "src/"]
|
|
86
|
+
|
|
87
|
+
Common ripgrep (rg) options:
|
|
88
|
+
- -i, --ignore-case: Case insensitive search
|
|
89
|
+
- -n, --line-number: Show line numbers
|
|
90
|
+
- -A NUM: Show NUM lines after each match
|
|
91
|
+
- -B NUM: Show NUM lines before each match
|
|
92
|
+
- -C NUM: Show NUM lines around each match
|
|
93
|
+
- -l, --files-with-matches: Only show file paths that match
|
|
94
|
+
- -c, --count: Only show count of matches per file
|
|
95
|
+
- --type TYPE: Only search files of TYPE (js, ts, py, rust, etc.)
|
|
96
|
+
- --glob PATTERN: Include/exclude files matching PATTERN
|
|
97
|
+
- --max-count NUM: Stop after NUM matches per file
|
|
98
|
+
- --no-ignore: Don't respect .gitignore files
|
|
99
|
+
- --hidden: Search hidden files and directories
|
|
100
|
+
|
|
101
|
+
Performance:
|
|
102
|
+
- 15 second timeout per search
|
|
103
|
+
- Results limited to 500 lines by default (use head_limit parameter)
|
|
104
|
+
- Respects .gitignore by default (use --no-ignore to override)
|
|
105
|
+
`,schema:R2.object({description:R2.string().optional().describe("what you want to do"),args:R2.array(R2.string()).describe('Ripgrep (rg) command arguments as array. Format: [OPTIONS...] PATTERN [PATH...]. MUST include path at end! Examples: ["import", "./"] (search "import" in current dir), ["-n", "-i", "function", "./"] (search "function" with line numbers, case insensitive), ["--type", "ts", "export", "src/"] (search "export" in TypeScript files in src/).'),head_limit:R2.number().optional().describe("Limit output to first N lines. If not specified and no --max-count in args, defaults to 500 lines for performance.")})});import{tool as VQ}from"langchain";import{z as T2}from"zod";import{promises as JQ}from"fs";var M$=2000,YQ=T2.object({description:T2.string().optional().describe("what you want to do"),file_path:T2.string().describe("The absolute path to the file to read"),offset:T2.number().default(0).optional().describe("The line number to start reading from. Only provide if the file is too large to read at once"),limit:T2.number().default(M$).optional().describe("The number of lines to read. Only provide if the file is too large to read at once.")}),S0=VQ(async({file_path:$,offset:Q,limit:X})=>{try{let Z=(await JQ.readFile($,"utf-8")).split(`
|
|
106
|
+
`);if(Q)Z=Z.slice(Q-1);if(X)Z=Z.slice(0,X);return Z.join(`
|
|
107
|
+
`)}catch(q){if(q.code==="ENOENT")return`Error: File not found at ${$}`;throw q}},{name:"read_file",description:`Reads a file from the local filesystem. You can access any file directly by using this tool.
|
|
108
|
+
Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.
|
|
109
|
+
|
|
110
|
+
Usage:
|
|
111
|
+
- The file_path parameter must be an absolute path, not a relative path
|
|
112
|
+
- By default, it reads up to ${M$} lines starting from the beginning of the file
|
|
113
|
+
- You can optionally specify a line offset and limit (especially handy for long files), but it's recommended to read the whole file by not providing these parameters
|
|
114
|
+
- Any lines longer than ${M$} characters will be truncated
|
|
115
|
+
- Results are returned using cat -n format, with line numbers starting at 1
|
|
116
|
+
- This tool allows You to read images (eg PNG, JPG, etc). When reading an image file the contents are presented visually as You is a multimodal LLM.
|
|
117
|
+
- This tool can read PDF files (.pdf). PDFs are processed page by page, extracting both text and visual content for analysis.
|
|
118
|
+
- This tool can read Jupyter notebooks (.ipynb files) and returns all cells with their outputs, combining code, text, and visualizations.
|
|
119
|
+
- You have the capability to call multiple tools in a single response. It is always better to speculatively read multiple files as a batch that are potentially useful.
|
|
120
|
+
- You will regularly be asked to read screenshots. If the user provides a path to a screenshot ALWAYS use this tool to view the file at the path. This tool will work with all temporary file paths like /var/folders/123/abc/T/TemporaryItems/NSIRD_screencaptureui_ZfB1tD/Screenshot.png
|
|
121
|
+
- If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.`,schema:YQ});import{tool as zQ}from"@langchain/core/tools";import{z as t2}from"zod";import{promises as KQ}from"fs";var P0=zQ(async({file_path:$,content:Q})=>{try{return await KQ.writeFile($,Q,"utf-8"),`File ${$} has been written successfully.`}catch(X){return`Error writing file: ${X.message}`}},{name:"write_file",description:`Writes a file to the local filesystem.
|
|
122
|
+
Usage:
|
|
123
|
+
- This tool will overwrite the existing file if there is one at the provided path.
|
|
124
|
+
- If this is an existing file, you MUST use the Read tool first to read the file's contents. This tool will fail if you did not read the file first.
|
|
125
|
+
- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.
|
|
126
|
+
- NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.
|
|
127
|
+
- Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.`,schema:t2.object({description:t2.string().optional().describe("what you want to do"),file_path:t2.string().describe("The absolute path to the file to write (must be absolute, not relative)"),content:t2.string().describe("The content to write to the file")})});import{tool as HQ}from"@langchain/core/tools";import{z as z2}from"zod";import{promises as I$}from"fs";var WQ=z2.object({description:z2.string().optional().describe("what you want to do"),file_path:z2.string().describe("The absolute path to the file to modify"),old_string:z2.string().describe("The text to replace"),new_string:z2.string().describe("The text to replace it with (must be different from old_string)"),replace_all:z2.boolean().optional().default(!1).describe("Replace all occurences of old_string (default false)")}),b0=HQ(async({file_path:$,old_string:Q,new_string:X,replace_all:q=!1})=>{try{let Z=await I$.readFile($,"utf-8");if(q){if(!Z.includes(Q))return`Error: old_string not found in ${$}`;let V=Z.split(Q).join(X);return await I$.writeFile($,V,"utf-8"),`File ${$} has been edited successfully. Replaced all occurrences of old_string.`}else{let V=Z.split(Q);if(V.length===1)return`Error: old_string not found in ${$}`;if(V.length>2)return`Error: old_string is not unique in ${$} (found ${V.length-1} occurrences). Please provide more context or set replace_all to true.`;let J=Z.replace(Q,X);return await I$.writeFile($,J,"utf-8"),`File ${$} has been edited successfully. Replaced single occurrence of old_string.`}}catch(Z){if(Z.code==="ENOENT")return`Error: File not found at ${$}`;throw Z}},{name:"edit_file",description:"Performs exact string replacements in files. \n\nUsage:\n- You must use your `Read` tool at least once in the conversation before editing. This tool will error if you attempt an edit without reading the file. \n- When editing text from Read tool output, ensure you preserve the exact indentation (tabs/spaces) as it appears AFTER the line number prefix. The line number prefix format is: spaces + line number + tab. Everything after that tab is the actual file content to match. Never include any part of the line number prefix in the old_string or new_string.\n- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.\n- Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked.\n- The edit will FAIL if `old_string` is not unique in the file. Either provide a larger string with more surrounding context to make it unique or use `replace_all` to change every instance of `old_string`. \n- Use `replace_all` for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable for instance.",schema:WQ});import{tool as jQ}from"@langchain/core/tools";import{z as K2}from"zod";var uQ=K2.object({content:K2.string().min(1),status:K2.enum(["pending","in_progress","completed"]),id:K2.string()}),vQ=K2.object({todos:K2.array(uQ).describe("The updated todo list")}),h0=jQ(async()=>{return"todo saved successfully"},{name:"todo_write",description:`Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
|
|
128
|
+
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
129
|
+
## When to Use This Tool
|
|
130
|
+
Use this tool proactively in these scenarios:
|
|
131
|
+
|
|
132
|
+
1. Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
|
|
133
|
+
2. Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
|
|
134
|
+
3. User explicitly requests todo list - When the user directly asks you to use the todo list
|
|
135
|
+
4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
|
|
136
|
+
5. After receiving new instructions - Immediately capture user requirements as todos
|
|
137
|
+
6. When you start working on a task - Mark it as in_progress BEFORE beginning work. Ideally you should only have one todo as in_progress at a time
|
|
138
|
+
7. After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation
|
|
139
|
+
|
|
140
|
+
## When NOT to Use This Tool
|
|
141
|
+
|
|
142
|
+
Skip using this tool when:
|
|
143
|
+
1. There is only a single, straightforward task
|
|
144
|
+
2. The task is trivial and tracking it provides no organizational benefit
|
|
145
|
+
3. The task can be completed in less than 3 trivial steps
|
|
146
|
+
4. The task is purely conversational or informational
|
|
147
|
+
|
|
148
|
+
NOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.
|
|
149
|
+
|
|
150
|
+
## Examples of When to Use the Todo List
|
|
151
|
+
|
|
152
|
+
<example>
|
|
153
|
+
User: I want to add a dark mode toggle to the application settings. Make sure you run the tests and build when you're done!
|
|
154
|
+
Assistant: I'll help add a dark mode toggle to your application settings. Let me create a todo list to track this implementation.
|
|
155
|
+
*Creates todo list with the following items:*
|
|
156
|
+
1. Create dark mode toggle component in Settings page
|
|
157
|
+
2. Add dark mode state management (context/store)
|
|
158
|
+
3. Implement CSS-in-JS styles for dark theme
|
|
159
|
+
4. Update existing components to support theme switching
|
|
160
|
+
5. Run tests and build process, addressing any failures or errors that occur
|
|
161
|
+
*Begins working on the first task*
|
|
162
|
+
|
|
163
|
+
<reasoning>
|
|
164
|
+
The assistant used the todo list because:
|
|
165
|
+
1. Adding dark mode is a multi-step feature requiring UI, state management, and styling changes
|
|
166
|
+
2. The user explicitly requested tests and build be run afterward
|
|
167
|
+
3. The assistant inferred that tests and build need to pass by adding "Ensure tests and build succeed" as the final task
|
|
168
|
+
</reasoning>
|
|
169
|
+
</example>
|
|
170
|
+
|
|
171
|
+
<example>
|
|
172
|
+
User: Help me rename the function getCwd to getCurrentWorkingDirectory across my project
|
|
173
|
+
Assistant: Let me first search through your codebase to find all occurrences of 'getCwd'.
|
|
174
|
+
*Uses grep or search tools to locate all instances of getCwd in the codebase*
|
|
175
|
+
Assistant: I've found 15 instances of 'getCwd' across 8 different files. Let me create a todo list to track these changes.
|
|
176
|
+
*Creates todo list with specific items for each file that needs updating*
|
|
177
|
+
|
|
178
|
+
<reasoning>
|
|
179
|
+
The assistant used the todo list because:
|
|
180
|
+
1. First, the assistant searched to understand the scope of the task
|
|
181
|
+
2. Upon finding multiple occurrences across different files, it determined this was a complex task with multiple steps
|
|
182
|
+
3. The todo list helps ensure every instance is tracked and updated systematically
|
|
183
|
+
4. This approach prevents missing any occurrences and maintains code consistency
|
|
184
|
+
</reasoning>
|
|
185
|
+
</example>
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
<example>
|
|
189
|
+
User: I need to implement these features for my e-commerce site: user registration, product catalog, shopping cart, and checkout flow.
|
|
190
|
+
Assistant: I'll help implement these features. First, let's add all the features to the todo list.
|
|
191
|
+
*Creates a todo list breaking down each feature into specific tasks based on the project architecture*
|
|
192
|
+
Assistant: Let's start with user registration. This will involve creating database models, API endpoints, and frontend forms that integrate with your existing authentication system.
|
|
193
|
+
|
|
194
|
+
<reasoning>
|
|
195
|
+
The assistant used the todo list because:
|
|
196
|
+
1. The user provided multiple complex features to implement in a comma separated list
|
|
197
|
+
2. The todo list helps organize these large features into manageable tasks
|
|
198
|
+
3. This approach allows for tracking progress across the entire implementation
|
|
199
|
+
</reasoning>
|
|
200
|
+
</example>
|
|
201
|
+
|
|
202
|
+
<example>
|
|
203
|
+
User: Can you help optimize my React application? It's rendering slowly and has performance issues.</user>
|
|
204
|
+
Assistant: I'll help optimize your React application. First, let me examine your codebase to identify potential performance bottlenecks.
|
|
205
|
+
*Reviews component structure, render patterns, state management, and data fetching*
|
|
206
|
+
Assistant: After analyzing your codebase, I've identified several performance issues. Let me create a todo list to track our optimization efforts.
|
|
207
|
+
*Creates todo list with items like: 1) Implement memoization for expensive calculations in ProductList, 2) Add virtualization for long lists in Dashboard, 3) Optimize image loading in Gallery component, 4) Fix state update loops in ShoppingCart, 5) Review bundle size and implement code splitting*
|
|
208
|
+
Let's start by implementing memoization for the expensive calculations in your ProductList component.</assistant>
|
|
209
|
+
|
|
210
|
+
<reasoning>
|
|
211
|
+
The assistant used the todo list because:
|
|
212
|
+
1. First, the assistant examined the codebase to identify specific performance issues
|
|
213
|
+
2. Based on this analysis, it identified multiple optimization opportunities
|
|
214
|
+
3. Performance optimization is a non-trivial task requiring multiple steps
|
|
215
|
+
4. The todo list helps methodically track improvements across different components
|
|
216
|
+
5. This systematic approach ensures all performance bottlenecks are addressed
|
|
217
|
+
</reasoning>
|
|
218
|
+
</example>
|
|
219
|
+
|
|
220
|
+
## Examples of When NOT to Use the Todo List
|
|
221
|
+
|
|
222
|
+
<example>
|
|
223
|
+
User: How do I print 'Hello World' in Python?
|
|
224
|
+
Assistant: In Python, you can print "Hello World" with this simple code:
|
|
225
|
+
|
|
226
|
+
python
|
|
227
|
+
print("Hello World")
|
|
228
|
+
|
|
229
|
+
This will output the text "Hello World" to the console when executed.</assistant>
|
|
230
|
+
|
|
231
|
+
<reasoning>
|
|
232
|
+
The assistant did not use the todo list because this is a single, trivial task that can be completed in one step. There's no need to track multiple tasks or steps for such a straightforward request.
|
|
233
|
+
</reasoning>
|
|
234
|
+
</example>
|
|
235
|
+
|
|
236
|
+
<example>
|
|
237
|
+
User: What does the git status command do?
|
|
238
|
+
Assistant: The git status command shows the current state of your working directory and staging area. It displays which changes have been staged, which haven't, and which files aren't being tracked by Git. This is a fundamental command for understanding the current state of your repository before making commits.
|
|
239
|
+
|
|
240
|
+
<reasoning>
|
|
241
|
+
The assistant did not use the todo list because this is an informational request with no actual coding task to complete. The user is simply asking for an explanation, not for the assistant to perform multiple steps or tasks.
|
|
242
|
+
</reasoning>
|
|
243
|
+
</example>
|
|
244
|
+
|
|
245
|
+
<example>
|
|
246
|
+
User: Can you add a comment to the calculateTotal function to explain what it does?
|
|
247
|
+
Assistant: Sure, let me add a comment to the calculateTotal function to explain what it does.
|
|
248
|
+
* Uses the Edit tool to add a comment to the calculateTotal function *
|
|
249
|
+
|
|
250
|
+
<reasoning>
|
|
251
|
+
The assistant did not use the todo list because this is a single, straightforward task confined to one location in the code. Adding a comment doesn't require tracking multiple steps or systematic organization.
|
|
252
|
+
</reasoning>
|
|
253
|
+
</example>
|
|
254
|
+
|
|
255
|
+
<example>
|
|
256
|
+
User: Run npm install for me and tell me what happens.
|
|
257
|
+
Assistant: I'll run the npm install command for you.
|
|
258
|
+
|
|
259
|
+
*Executes: npm install*
|
|
260
|
+
|
|
261
|
+
The command completed successfully. Here's the output:
|
|
262
|
+
[Output of npm install command]
|
|
263
|
+
|
|
264
|
+
All dependencies have been installed according to your package.json file.
|
|
265
|
+
|
|
266
|
+
<reasoning>
|
|
267
|
+
The assistant did not use the todo list because this is a single command execution with immediate results. There are no multiple steps to track or organize, making the todo list unnecessary for this straightforward task.
|
|
268
|
+
</reasoning>
|
|
269
|
+
</example>
|
|
270
|
+
|
|
271
|
+
## Task States and Management
|
|
272
|
+
|
|
273
|
+
1. **Task States**: Use these states to track progress:
|
|
274
|
+
- pending: Task not yet started
|
|
275
|
+
- in_progress: Currently working on (limit to ONE task at a time)
|
|
276
|
+
- completed: Task finished successfully
|
|
277
|
+
|
|
278
|
+
2. **Task Management**:
|
|
279
|
+
- Update task status in real-time as you work
|
|
280
|
+
- Mark tasks complete IMMEDIATELY after finishing (don't batch completions)
|
|
281
|
+
- Only have ONE task in_progress at any time
|
|
282
|
+
- Complete current tasks before starting new ones
|
|
283
|
+
- Remove tasks that are no longer relevant from the list entirely
|
|
284
|
+
|
|
285
|
+
3. **Task Completion Requirements**:
|
|
286
|
+
- ONLY mark a task as completed when you have FULLY accomplished it
|
|
287
|
+
- If you encounter errors, blockers, or cannot finish, keep the task as in_progress
|
|
288
|
+
- When blocked, create a new task describing what needs to be resolved
|
|
289
|
+
- Never mark a task as completed if:
|
|
290
|
+
- Tests are failing
|
|
291
|
+
- Implementation is partial
|
|
292
|
+
- You encountered unresolved errors
|
|
293
|
+
- You couldn't find necessary files or dependencies
|
|
294
|
+
|
|
295
|
+
4. **Task Breakdown**:
|
|
296
|
+
- Create specific, actionable items
|
|
297
|
+
- Break complex tasks into smaller, manageable steps
|
|
298
|
+
- Use clear, descriptive task names
|
|
299
|
+
|
|
300
|
+
When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.
|
|
301
|
+
`,schema:vQ});import{z as r}from"zod";import{tool as UQ}from"langchain";var GQ=r.object({label:r.string().min(1).max(50).describe("选项显示文本,简洁明了(1-50 字符)")}),wQ=r.object({description:r.string().min(1).describe("向用户提出的问题,清晰具体,包含必要的上下文"),type:r.enum(["single_select","multi_select"]).describe("选择类型:single_select(单选)或 multi_select(多选)"),options:r.array(GQ).min(2).max(6).describe("选项列表,至少 2 个,最多 6 个"),allow_custom_input:r.boolean().default(!0).describe("是否允许用户输入自定义文本,默认 true"),placeholder:r.string().optional().describe("自定义输入框的占位符文本")}),d0=UQ(()=>{},{name:"ask_user_questions",description:"Ask the user a question with selectable options",schema:wQ});var kQ=[d0,h0,R0,D0,S0,P0,b0,D$,...N$];async function CQ($,Q){await $.addTool({id:Q.name,name:Q.name,description:Q.description});let X={id:Q.name,name:Q.name,description:Q.description,paramsSchema:Q.schema,execute:async(q)=>{let Z=await Q.invoke(q);if(Z&&typeof Z==="object"&&"content"in Z)return Z.content;return Z}};$.tools.registerImplementation(X)}async function E0($){return await Promise.all(kQ.map((Q)=>CQ($,Q)))}async function g0($){let Q={id:"subagents",name:"subagents",description:"Task delegation to specialized agents",execute:async()=>{let{createSubAgentsMiddleware:V}=await import("./chunk-ew7249h9.js");return await V($)}};await $.addMiddleware(Q),$.middlewares.registerImplementation(Q);let X={id:"memories",name:"memories",description:"Knowledge persistence",execute:async(V)=>{V.projectMemoriesDir=V.projectMemoriesDir||"./.claude/memories";let{MemoriesMiddleware:J}=await import("./chunk-8nhayyat.js");return new J(V)}};await $.addMiddleware(X),$.middlewares.registerImplementation(X);let q={id:"skills",name:"skills",description:"Progressive skills disclosure",execute:async(V)=>{if(V.projectSkillsDir=V.projectSkillsDir||"./.claude/skills",!V.skillsDir){let Y=await import("os"),z=await import("path");V.skillsDir=z.join(Y.homedir(),".claude","skills")}let{SkillsMiddleware:J}=await import("@langgraph-js/standard-agent");return new J(V)}};await $.addMiddleware(q),$.middlewares.registerImplementation(q);let Z={id:"agents_md",name:"agents_md",description:"Inject agent documentation",execute:async(V)=>{let{AgentsMdMiddleware:J}=await import("@langgraph-js/standard-agent");return new J({projectRoot:V?.projectRoot})}};await $.addMiddleware(Z),$.middlewares.registerImplementation(Z)}var l0=`# 架构师 - 任务派发协调者
|
|
302
|
+
|
|
303
|
+
你是一位**任务派发架构师**,核心职责是将用户需求分析并拆解为子任务,然后委派给合适的子 agent 执行。
|
|
304
|
+
|
|
305
|
+
## 核心职责
|
|
306
|
+
|
|
307
|
+
**你的唯一任务**:
|
|
308
|
+
1. 理解用户需求
|
|
309
|
+
2. 拆解为可执行的子任务
|
|
310
|
+
3. 委派给合适的子 agent
|
|
311
|
+
4. 跟踪和汇总结果
|
|
312
|
+
|
|
313
|
+
**不要做的事**:
|
|
314
|
+
- ❌ 不要自己编写代码
|
|
315
|
+
- ❌ 不要自己读取文件或搜索代码
|
|
316
|
+
- ❌ 不要自己执行终端命令
|
|
317
|
+
- ❌ 不要做具体的架构分析或设计文档
|
|
318
|
+
|
|
319
|
+
## 工作流程
|
|
320
|
+
|
|
321
|
+
### 步骤 1:需求分析
|
|
322
|
+
|
|
323
|
+
当收到用户请求时,快速判断:
|
|
324
|
+
|
|
325
|
+
1. **任务类型**:
|
|
326
|
+
- 代码实现/修改 → 委派给 \`agents/default\`
|
|
327
|
+
- 任务规划/协调 → 委派给 \`agents/manager\`
|
|
328
|
+
- 复杂任务 → 先由 \`agents/manager\` 规划,再由 \`agents/default\` 执行
|
|
329
|
+
|
|
330
|
+
2. **任务规模**:
|
|
331
|
+
- 单一任务 → 直接委派
|
|
332
|
+
- 多任务 → 拆分后分别委派
|
|
333
|
+
|
|
334
|
+
### 步骤 2:任务拆解
|
|
335
|
+
|
|
336
|
+
使用 \`task\` 工具委派任务:
|
|
337
|
+
|
|
338
|
+
\`\`\`typescript
|
|
339
|
+
// 示例:委派代码实现任务
|
|
340
|
+
{
|
|
341
|
+
subagent_id: "agents/default",
|
|
342
|
+
task_description: "实现用户认证功能,包括登录、注册、登出三个接口",
|
|
343
|
+
data_transfer: {
|
|
344
|
+
requirements: "使用 JWT 认证,密码需要加密存储",
|
|
345
|
+
constraints: "使用现有的数据库连接池"
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
\`\`\`
|
|
349
|
+
|
|
350
|
+
### 步骤 3:结果汇总
|
|
351
|
+
|
|
352
|
+
子 agent 完成后:
|
|
353
|
+
1. 检查执行结果
|
|
354
|
+
2. 如果有多个子任务,协调依赖关系
|
|
355
|
+
3. 向用户汇报整体进度和结果
|
|
356
|
+
|
|
357
|
+
## 委派策略
|
|
358
|
+
|
|
359
|
+
### 简单任务
|
|
360
|
+
|
|
361
|
+
用户请求单一功能时,直接委派:
|
|
362
|
+
|
|
363
|
+
> 用户:添加一个日志工具函数
|
|
364
|
+
|
|
365
|
+
→ 委派给 \`agents/default\`,任务描述清晰完整
|
|
366
|
+
|
|
367
|
+
### 复杂任务
|
|
368
|
+
|
|
369
|
+
用户请求多功能时,拆分后委派:
|
|
370
|
+
|
|
371
|
+
> 用户:重构用户模块并添加测试
|
|
372
|
+
|
|
373
|
+
→ 拆分为:
|
|
374
|
+
1. 委派 \`agents/default\`:重构用户模块代码
|
|
375
|
+
2. 等第一步完成后,委派 \`agents/default\`:为用户模块编写测试
|
|
376
|
+
|
|
377
|
+
### 规划任务
|
|
378
|
+
|
|
379
|
+
用户需要方案设计时:
|
|
380
|
+
|
|
381
|
+
> 用户:设计一个新的权限系统
|
|
382
|
+
|
|
383
|
+
→ 委派 \`agents/manager\` 进行任务规划,然后按规划执行
|
|
384
|
+
|
|
385
|
+
## 输出格式
|
|
386
|
+
|
|
387
|
+
### 委派时
|
|
388
|
+
|
|
389
|
+
\`\`\`markdown
|
|
390
|
+
## 任务分析
|
|
391
|
+
|
|
392
|
+
**用户需求**:{用户原始请求}
|
|
393
|
+
|
|
394
|
+
**任务拆解**:
|
|
395
|
+
1. 任务 A → 委派给 agents/default
|
|
396
|
+
2. 任务 B → 委派给 agents/manager
|
|
397
|
+
|
|
398
|
+
**开始执行**...
|
|
399
|
+
\`\`\`
|
|
400
|
+
|
|
401
|
+
### 汇报时
|
|
402
|
+
|
|
403
|
+
\`\`\`markdown
|
|
404
|
+
## 执行结果
|
|
405
|
+
|
|
406
|
+
**已完成**:
|
|
407
|
+
- ✅ 任务 A:{简要结果}
|
|
408
|
+
- ✅ 任务 B:{简要结果}
|
|
409
|
+
|
|
410
|
+
**总结**:{整体结果摘要}
|
|
411
|
+
\`\`\`
|
|
412
|
+
|
|
413
|
+
## 重要约束
|
|
414
|
+
|
|
415
|
+
1. **立即委派**:收到任务后,不要犹豫,立即分析并委派
|
|
416
|
+
2. **清晰描述**:给子 agent 的任务描述要完整、清晰
|
|
417
|
+
3. **传递上下文**:使用 \`data_transfer\` 传递必要的背景信息
|
|
418
|
+
4. **不要插手**:相信子 agent 的能力,不要自己动手做具体工作
|
|
419
|
+
5. **保持简洁**:你的输出应该简短,重点是协调和汇总
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
|
|
423
|
+
**记住**:你是协调者,不是执行者。快速分析需求,立即委派任务,高效汇总结果。`;async function o0(){let $=new AQ,Q=new BQ($);return await Q.addModel({id:"glm-4.7",model_name:"glm-4.7",model_provider:process.env.MODEL_PROVIDER||"openai",stream_usage:!0,enable_thinking:!0,temperature:0.7,max_tokens:4096,top_p:1,frequency_penalty:0,presence_penalty:0}),await Q.addPrompt({id:"prompts/default",name:"default",content:c0}),await Q.addPrompt({id:"prompts/manager",name:"manager",content:l0}),await E0(Q),await g0(Q),await Q.addAgent({id:"agents/default",name:"Jarvis",description:"代码实现助手",system_prompt:"prompts/default",model:"glm-4.7",tools:{read_file:!0,write_file:!0,edit_file:!0,glob_files:!0,search_files_rg:!0,folder_operations:!0,terminal:!0,ask_user_questions:!0,todo_write:!0},middleware:{agents_md:!0,skills:!0,memories:!0,subagents:!0}}),await Q.addAgent({id:"agents/manager",name:"Manager",description:"任务管理员",system_prompt:"prompts/manager",model:"glm-4.7",tools:{read_file:!0,write_file:!0,edit_file:!0,glob_files:!0,search_files_rg:!0,folder_operations:!0,terminal:!0,ask_user_questions:!0,todo_write:!0},middleware:{agents_md:!0,skills:!0,memories:!0,subagents:!0}}),Q}var $7=await o0();
|
|
424
|
+
export{D$ as za,d5 as Aa,Z8 as Ba,YQ as Ca,WQ as Da,vQ as Ea,$7 as Fa};
|