@ebowwa/coder 0.2.1 → 0.7.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +31 -32
  2. package/dist/index.js +52191 -1
  3. package/dist/interfaces/ui/terminal/cli/index.js +52776 -0
  4. package/native/README.md +5 -5
  5. package/native/index.darwin-arm64.node +0 -0
  6. package/native/index.node +0 -0
  7. package/native/package.json +4 -4
  8. package/package.json +30 -15
  9. package/dist/cli.js +0 -148
  10. package/dist/index-0pkak453.js +0 -136
  11. package/dist/index-0qd0x8b4.js +0 -110
  12. package/dist/index-0x3kprq6.js +0 -240
  13. package/dist/index-1eawy937.js +0 -308
  14. package/dist/index-24m2aygy.js +0 -240
  15. package/dist/index-29xcjnne.js +0 -280
  16. package/dist/index-2avyytn5.js +0 -349
  17. package/dist/index-4ms367ey.js +0 -136
  18. package/dist/index-4w2t3b0m.js +0 -240
  19. package/dist/index-4xfgd8nz.js +0 -261
  20. package/dist/index-5acjp9gc.js +0 -157
  21. package/dist/index-5s15hr56.js +0 -136
  22. package/dist/index-6e4wf341.js +0 -349
  23. package/dist/index-6fvnkedw.js +0 -240
  24. package/dist/index-6rqpmd4g.js +0 -128
  25. package/dist/index-77ckwnbm.js +0 -280
  26. package/dist/index-9knxy49k.js +0 -128
  27. package/dist/index-9zrnw4zx.js +0 -128
  28. package/dist/index-bk21w99v.js +0 -280
  29. package/dist/index-c41n76fv.js +0 -240
  30. package/dist/index-cb4ppjdt.js +0 -255
  31. package/dist/index-cfb2edt6.js +0 -240
  32. package/dist/index-cmfa38hh.js +0 -308
  33. package/dist/index-datjz8q1.js +0 -257
  34. package/dist/index-eadf4wvn.js +0 -240
  35. package/dist/index-em5k0m3z.js +0 -345
  36. package/dist/index-gh8r333a.js +0 -110
  37. package/dist/index-gkx6k2tr.js +0 -261
  38. package/dist/index-h5cabfks.js +0 -155
  39. package/dist/index-hcrpwyy3.js +0 -261
  40. package/dist/index-hk7fwwa8.js +0 -257
  41. package/dist/index-jb8cw7f8.js +0 -136
  42. package/dist/index-kbyw4th1.js +0 -347
  43. package/dist/index-kgj5gqnm.js +0 -345
  44. package/dist/index-mdf6xp1z.js +0 -255
  45. package/dist/index-mrhv8kvc.js +0 -280
  46. package/dist/index-mt4743dd.js +0 -161
  47. package/dist/index-qnwsg97q.js +0 -240
  48. package/dist/index-qwdy6x44.js +0 -261
  49. package/dist/index-rmj77261.js +0 -157
  50. package/dist/index-sbbw1a61.js +0 -349
  51. package/dist/index-svy5bcpn.js +0 -345
  52. package/dist/index-tvmy7tm9.js +0 -261
  53. package/dist/index-tzz4vzkj.js +0 -312
  54. package/dist/index-vz80zmhe.js +0 -110
  55. package/dist/index-wed2fk67.js +0 -240
  56. package/dist/index-wksgzz8e.js +0 -280
  57. package/dist/index-wn2m4wma.js +0 -240
  58. package/dist/index-xha05vjc.js +0 -257
  59. package/dist/index-yc6eh8p8.js +0 -136
  60. package/dist/index-ycjxx9ft.js +0 -240
  61. package/dist/index-z0gzd0fc.js +0 -110
  62. package/dist/index-z8cwtf8j.js +0 -240
  63. package/dist/index-zy5mtt00.js +0 -128
@@ -1,110 +0,0 @@
1
- // @bun
2
- var I8=import.meta.require;var A5={"claude-opus-4-6":{input:15,output:75},"claude-sonnet-4-6":{input:3,output:15},"claude-haiku-4-5":{input:0.8,output:4},"claude-3-5-sonnet":{input:3,output:15},"claude-3-5-haiku":{input:0.8,output:4},"claude-3-opus":{input:15,output:75}};function U6(Q,X,Z){let V=A5[Q]??A5["claude-sonnet-4-6"],$=X/1e6*V.input,J=Z/1e6*V.output;return $+J}async function B5(Q,X){let{apiKey:Z,model:V="claude-sonnet-4-6",maxTokens:$=4096,onToken:J,onThinking:q,onToolUse:K,signal:z}=X,Y=Date.now(),W=0,H=!0,_={model:V,max_tokens:$,messages:Q.map((E)=>({role:E.role,content:E.content})),stream:!0},j=await fetch("https://api.anthropic.com/v1/messages",{method:"POST",headers:{"Content-Type":"application/json","x-api-key":Z,"anthropic-version":"2023-06-01","anthropic-beta":"max-tokens-3-5-sonnet-2024-07-15"},body:JSON.stringify(_),signal:z});if(!j.ok){let E=await j.text();throw Error(`API error: ${j.status} - ${E}`)}if(!j.body)throw Error("No response body");let U=j.body.getReader(),G=new TextDecoder,A=null,C=[],B={input_tokens:0,output_tokens:0},L=null,v=null,w=null,k="",T="";try{let E="";while(!0){let{done:xQ,value:PQ}=await U.read();if(xQ)break;E+=G.decode(PQ,{stream:!0});let e=E.split(`
3
- `);E=e.pop()||"";for(let b of e){if(!b.startsWith("data: "))continue;let JQ=b.slice(6);if(!JQ)continue;try{let qQ=JSON.parse(JQ);switch(qQ.type){case"message_start":{let M=qQ.message;A=M,B=M.usage;break}case"content_block_start":{let M=qQ.content_block;if(M.type==="text")L={type:"text",text:""};else if(M.type==="thinking")v={type:"thinking",thinking:""};else if(M.type==="tool_use")w={type:"tool_use",id:M.id,name:M.name,input:{}},k="";break}case"content_block_delta":{let M=qQ.delta;if(M.type==="text_delta"&&L){let XQ=M.text;if(L.text+=XQ,J?.(XQ),H)W=Date.now()-Y,H=!1}else if(M.type==="thinking_delta"&&v){let XQ=M.thinking;v.thinking+=XQ,q?.(XQ)}else if(M.type==="input_json_delta"&&w)k+=M.partial_json;break}case"content_block_stop":if(L)C.push(L),L=null;else if(v)C.push(v),v=null;else if(w){try{w.input=JSON.parse(k)}catch{w.input={}}C.push(w),K?.({id:w.id,name:w.name,input:w.input}),w=null}break;case"message_delta":{let M=qQ;if(M.usage)B.output_tokens=M.usage.output_tokens;if(A&&M.delta?.stop_reason)A.stop_reason=M.delta.stop_reason;break}case"message_stop":break}}catch{}}}}finally{U.releaseLock()}if(!A)throw Error("No message received from API");A.content=C;let c=U6(V,B.input_tokens,B.output_tokens),f=Date.now()-Y;return{message:A,usage:B,costUSD:c,durationMs:f,ttftMs:W||f}}async function E8(Q,X){let{apiKey:Z,model:V="claude-sonnet-4-6",maxTokens:$=4096,systemPrompt:J,tools:q,permissionMode:K,workingDirectory:z,onText:Y,onThinking:W,onToolUse:H,onToolResult:_,onMetrics:j,signal:U}=X,G=[...Q],A=[],C=0,B=0,L=!0;while(L){if(U?.aborted)break;let v=C6(G,J),w=await B5(v,{apiKey:Z,onToken:Y,onThinking:W,onToolUse:H,signal:U}),{message:k,usage:T,costUSD:c,durationMs:f,ttftMs:E}=w,xQ={model:V,messageCount:G.length,messageTokens:T.input_tokens+T.output_tokens,usage:T,durationMs:f,ttftMs:E,costUSD:c,stopReason:k.stop_reason,requestId:k.id};if(A.push(xQ),C+=c,B+=f,j?.(xQ),G.push({role:"assistant",content:k.content}),k.stop_reason==="end_turn"||k.stop_reason==="stop_sequence"){L=!1;break}if(k.stop_reason==="max_tokens"){console.warn("Max tokens reached - context compaction needed"),L=!1;break}let PQ=k.content.filter((b)=>b.type==="tool_use");if(PQ.length===0){L=!1;break}let e=[];for(let b of PQ){if(U?.aborted)break;let JQ=q.find((M)=>M.name===b.name);if(!JQ){e.push({type:"tool_result",tool_use_id:b.id,content:`Error: Unknown tool "${b.name}"`,is_error:!0});continue}if(!A6(JQ.name,K)){e.push({type:"tool_result",tool_use_id:b.id,content:`Permission denied for tool "${b.name}"`,is_error:!0});continue}try{let M=await JQ.handler(b.input,{workingDirectory:z,permissionMode:K,abortSignal:U});e.push({type:"tool_result",tool_use_id:b.id,content:M.content,is_error:M.is_error}),_?.({id:b.id,result:M})}catch(M){let XQ=M instanceof Error?M.message:String(M);e.push({type:"tool_result",tool_use_id:b.id,content:`Error: ${XQ}`,is_error:!0})}}G.push({role:"user",content:e})}return{messages:G,metrics:A,totalCost:C,totalDuration:B}}function C6(Q,X){return Q}function A6(Q,X){switch(X){case"bypassPermissions":return!0;case"dontAsk":return!1;case"acceptEdits":return["Read","Write","Edit","Glob","Grep"].includes(Q);case"interactive":case"default":case"plan":return!0;default:return!0}}function B6(Q){if(Q<0.01)return`$${Q.toFixed(4)}`;return`$${Q.toFixed(2)}`}function b8(Q){let X=B6(Q.costUSD),Z=`${Q.usage.input_tokens.toLocaleString()} input, ${Q.usage.output_tokens.toLocaleString()} output`;return`Cost: ${X} | Tokens: ${Z}`}var aQ=(Q,X,Z)=>{let V=Q instanceof RegExp?w5(Q,Z):Q,$=X instanceof RegExp?w5(X,Z):X,J=V!==null&&$!=null&&w6(V,$,Z);return J&&{start:J[0],end:J[1],pre:Z.slice(0,J[0]),body:Z.slice(J[0]+V.length,J[1]),post:Z.slice(J[1]+$.length)}},w5=(Q,X)=>{let Z=X.match(Q);return Z?Z[0]:null},w6=(Q,X,Z)=>{let V,$,J,q=void 0,K,z=Z.indexOf(Q),Y=Z.indexOf(X,z+1),W=z;if(z>=0&&Y>0){if(Q===X)return[z,Y];V=[],J=Z.length;while(W>=0&&!K){if(W===z)V.push(W),z=Z.indexOf(Q,W+1);else if(V.length===1){let H=V.pop();if(H!==void 0)K=[H,Y]}else{if($=V.pop(),$!==void 0&&$<J)J=$,q=Y;Y=Z.indexOf(X,W+1)}W=z<Y&&z>=0?z:Y}if(V.length&&q!==void 0)K=[J,q]}return K};var L5="\x00SLASH"+Math.random()+"\x00",v5="\x00OPEN"+Math.random()+"\x00",sQ="\x00CLOSE"+Math.random()+"\x00",M5="\x00COMMA"+Math.random()+"\x00",O5="\x00PERIOD"+Math.random()+"\x00",L6=new RegExp(L5,"g"),v6=new RegExp(v5,"g"),M6=new RegExp(sQ,"g"),O6=new RegExp(M5,"g"),F6=new RegExp(O5,"g"),k6=/\\\\/g,R6=/\\{/g,I6=/\\}/g,x6=/\\,/g,P6=/\\./g,N6=1e5;function rQ(Q){return!isNaN(Q)?parseInt(Q,10):Q.charCodeAt(0)}function D6(Q){return Q.replace(k6,L5).replace(R6,v5).replace(I6,sQ).replace(x6,M5).replace(P6,O5)}function S6(Q){return Q.replace(L6,"\\").replace(v6,"{").replace(M6,"}").replace(O6,",").replace(F6,".")}function F5(Q){if(!Q)return[""];let X=[],Z=aQ("{","}",Q);if(!Z)return Q.split(",");let{pre:V,body:$,post:J}=Z,q=V.split(",");q[q.length-1]+="{"+$+"}";let K=F5(J);if(J.length)q[q.length-1]+=K.shift(),q.push.apply(q,K);return X.push.apply(X,q),X}function k5(Q,X={}){if(!Q)return[];let{max:Z=N6}=X;if(Q.slice(0,2)==="{}")Q="\\{\\}"+Q.slice(2);return jQ(D6(Q),Z,!0).map(S6)}function T6(Q){return"{"+Q+"}"}function E6(Q){return/^-?0\d/.test(Q)}function b6(Q,X){return Q<=X}function u6(Q,X){return Q>=X}function jQ(Q,X,Z){let V=[],$=aQ("{","}",Q);if(!$)return[Q];let J=$.pre,q=$.post.length?jQ($.post,X,!1):[""];if(/\$$/.test($.pre))for(let K=0;K<q.length&&K<X;K++){let z=J+"{"+$.body+"}"+q[K];V.push(z)}else{let K=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test($.body),z=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test($.body),Y=K||z,W=$.body.indexOf(",")>=0;if(!Y&&!W){if($.post.match(/,(?!,).*\}/))return Q=$.pre+"{"+$.body+sQ+$.post,jQ(Q,X,!0);return[Q]}let H;if(Y)H=$.body.split(/\.\./);else if(H=F5($.body),H.length===1&&H[0]!==void 0){if(H=jQ(H[0],X,!1).map(T6),H.length===1)return q.map((j)=>$.pre+H[0]+j)}let _;if(Y&&H[0]!==void 0&&H[1]!==void 0){let j=rQ(H[0]),U=rQ(H[1]),G=Math.max(H[0].length,H[1].length),A=H.length===3&&H[2]!==void 0?Math.abs(rQ(H[2])):1,C=b6;if(U<j)A*=-1,C=u6;let L=H.some(E6);_=[];for(let v=j;C(v,U);v+=A){let w;if(z){if(w=String.fromCharCode(v),w==="\\")w=""}else if(w=String(v),L){let k=G-w.length;if(k>0){let T=Array(k+1).join("0");if(v<0)w="-"+T+w.slice(1);else w=T+w}}_.push(w)}}else{_=[];for(let j=0;j<H.length;j++)_.push.apply(_,jQ(H[j],X,!1))}for(let j=0;j<_.length;j++)for(let U=0;U<q.length&&V.length<X;U++){let G=J+_[j]+q[U];if(!Z||Y||G)V.push(G)}}return V}var _Q=(Q)=>{if(typeof Q!=="string")throw TypeError("invalid pattern");if(Q.length>65536)throw TypeError("pattern is too long")};var y6={"[: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]},GQ=(Q)=>Q.replace(/[[\]\\-]/g,"\\$&"),f6=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),R5=(Q)=>Q.join(""),I5=(Q,X)=>{let Z=X;if(Q.charAt(Z)!=="[")throw Error("not in a brace expression");let V=[],$=[],J=Z+1,q=!1,K=!1,z=!1,Y=!1,W=Z,H="";Q:while(J<Q.length){let G=Q.charAt(J);if((G==="!"||G==="^")&&J===Z+1){Y=!0,J++;continue}if(G==="]"&&q&&!z){W=J+1;break}if(q=!0,G==="\\"){if(!z){z=!0,J++;continue}}if(G==="["&&!z){for(let[A,[C,B,L]]of Object.entries(y6))if(Q.startsWith(A,J)){if(H)return["$.",!1,Q.length-Z,!0];if(J+=A.length,L)$.push(C);else V.push(C);K=K||B;continue Q}}if(z=!1,H){if(G>H)V.push(GQ(H)+"-"+GQ(G));else if(G===H)V.push(GQ(G));H="",J++;continue}if(Q.startsWith("-]",J+1)){V.push(GQ(G+"-")),J+=2;continue}if(Q.startsWith("-",J+1)){H=G,J+=2;continue}V.push(GQ(G)),J++}if(W<J)return["",!1,0,!1];if(!V.length&&!$.length)return["$.",!1,Q.length-Z,!0];if($.length===0&&V.length===1&&/^\\?.$/.test(V[0])&&!Y){let G=V[0].length===2?V[0].slice(-1):V[0];return[f6(G),!1,W-Z,!1]}let _="["+(Y?"^":"")+R5(V)+"]",j="["+(Y?"":"^")+R5($)+"]";return[V.length&&$.length?"("+_+"|"+j+")":V.length?_:j,K,W-Z,!0]};var l=(Q,{windowsPathsNoEscape:X=!1,magicalBraces:Z=!0}={})=>{if(Z)return X?Q.replace(/\[([^\/\\])\]/g,"$1"):Q.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");return X?Q.replace(/\[([^\/\\{}])\]/g,"$1"):Q.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1")};var u,m6=new Set(["!","?","+","*","@"]),eQ=(Q)=>m6.has(Q),x5=(Q)=>eQ(Q.type),h6=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),g6=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),d6=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),P5=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),c6="(?!(?:^|/)\\.\\.?(?:$|/))",NQ="(?!\\.)",l6=new Set(["[","."]),i6=new Set(["..","."]),p6=new Set("().*{}+?[]^$\\!"),o6=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),tQ="[^/]",N5=tQ+"*?",D5=tQ+"+?",n6=0;class KQ{type;#Q;#V;#$=!1;#X=[];#q;#O;#B;#W=!1;#K;#j;#H=!1;id=++n6;get depth(){return(this.#q?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#Q.id,parent:this.#q?.id,depth:this.depth,partsLength:this.#X.length,parts:this.#X}}constructor(Q,X,Z={}){if(this.type=Q,Q)this.#V=!0;if(this.#q=X,this.#Q=this.#q?this.#q.#Q:this,this.#K=this.#Q===this?Z:this.#Q.#K,this.#B=this.#Q===this?[]:this.#Q.#B,Q==="!"&&!this.#Q.#W)this.#B.push(this);this.#O=this.#q?this.#q.#X.length:0}get hasMagic(){if(this.#V!==void 0)return this.#V;for(let Q of this.#X){if(typeof Q==="string")continue;if(Q.type||Q.hasMagic)return this.#V=!0}return this.#V}toString(){if(this.#j!==void 0)return this.#j;if(!this.type)return this.#j=this.#X.map((Q)=>String(Q)).join("");else return this.#j=this.type+"("+this.#X.map((Q)=>String(Q)).join("|")+")"}#z(){if(this!==this.#Q)throw Error("should only call on root");if(this.#W)return this;this.toString(),this.#W=!0;let Q;while(Q=this.#B.pop()){if(Q.type!=="!")continue;let X=Q,Z=X.#q;while(Z){for(let V=X.#O+1;!Z.type&&V<Z.#X.length;V++)for(let $ of Q.#X){if(typeof $==="string")throw Error("string part in extglob AST??");$.copyIn(Z.#X[V])}X=Z,Z=X.#q}}return this}push(...Q){for(let X of Q){if(X==="")continue;if(typeof X!=="string"&&!(X instanceof u&&X.#q===this))throw Error("invalid part: "+X);this.#X.push(X)}}toJSON(){let Q=this.type===null?this.#X.slice().map((X)=>typeof X==="string"?X:X.toJSON()):[this.type,...this.#X.map((X)=>X.toJSON())];if(this.isStart()&&!this.type)Q.unshift([]);if(this.isEnd()&&(this===this.#Q||this.#Q.#W&&this.#q?.type==="!"))Q.push({});return Q}isStart(){if(this.#Q===this)return!0;if(!this.#q?.isStart())return!1;if(this.#O===0)return!0;let Q=this.#q;for(let X=0;X<this.#O;X++){let Z=Q.#X[X];if(!(Z instanceof u&&Z.type==="!"))return!1}return!0}isEnd(){if(this.#Q===this)return!0;if(this.#q?.type==="!")return!0;if(!this.#q?.isEnd())return!1;if(!this.type)return this.#q?.isEnd();let Q=this.#q?this.#q.#X.length:0;return this.#O===Q-1}copyIn(Q){if(typeof Q==="string")this.push(Q);else this.push(Q.clone(this))}clone(Q){let X=new u(this.type,Q);for(let Z of this.#X)X.copyIn(Z);return X}static#J(Q,X,Z,V,$){let J=V.maxExtglobRecursion??2,q=!1,K=!1,z=-1,Y=!1;if(X.type===null){let U=Z,G="";while(U<Q.length){let A=Q.charAt(U++);if(q||A==="\\"){q=!q,G+=A;continue}if(K){if(U===z+1){if(A==="^"||A==="!")Y=!0}else if(A==="]"&&!(U===z+2&&Y))K=!1;G+=A;continue}else if(A==="["){K=!0,z=U,Y=!1,G+=A;continue}if(!V.noext&&eQ(A)&&Q.charAt(U)==="("&&$<=J){X.push(G),G="";let B=new u(A,X);U=u.#J(Q,B,U,V,$+1),X.push(B);continue}G+=A}return X.push(G),U}let W=Z+1,H=new u(null,X),_=[],j="";while(W<Q.length){let U=Q.charAt(W++);if(q||U==="\\"){q=!q,j+=U;continue}if(K){if(W===z+1){if(U==="^"||U==="!")Y=!0}else if(U==="]"&&!(W===z+2&&Y))K=!1;j+=U;continue}else if(U==="["){K=!0,z=W,Y=!1,j+=U;continue}if(!V.noext&&eQ(U)&&Q.charAt(W)==="("&&($<=J||X&&X.#G(U))){let A=X&&X.#G(U)?0:1;H.push(j),j="";let C=new u(U,H);H.push(C),W=u.#J(Q,C,W,V,$+A);continue}if(U==="|"){H.push(j),j="",_.push(H),H=new u(null,X);continue}if(U===")"){if(j===""&&X.#X.length===0)X.#H=!0;return H.push(j),j="",X.push(..._,H),W}j+=U}return X.type=null,X.#V=void 0,X.#X=[Q.substring(Z-1)],W}#w(Q){return this.#v(Q,g6)}#v(Q,X=h6){if(!Q||typeof Q!=="object"||Q.type!==null||Q.#X.length!==1||this.type===null)return!1;let Z=Q.#X[0];if(!Z||typeof Z!=="object"||Z.type===null)return!1;return this.#G(Z.type,X)}#G(Q,X=d6){return!!X.get(this.type)?.includes(Q)}#U(Q,X){let Z=Q.#X[0],V=new u(null,Z,this.options);V.#X.push(""),Z.push(V),this.#R(Q,X)}#R(Q,X){let Z=Q.#X[0];this.#X.splice(X,1,...Z.#X);for(let V of Z.#X)if(typeof V==="object")V.#q=this;this.#j=void 0}#C(Q){return!!P5.get(this.type)?.has(Q)}#M(Q){if(!Q||typeof Q!=="object"||Q.type!==null||Q.#X.length!==1||this.type===null||this.#X.length!==1)return!1;let X=Q.#X[0];if(!X||typeof X!=="object"||X.type===null)return!1;return this.#C(X.type)}#F(Q){let X=P5.get(this.type),Z=Q.#X[0],V=X?.get(Z.type);if(!V)return!1;this.#X=Z.#X;for(let $ of this.#X)if(typeof $==="object")$.#q=this;this.type=V,this.#j=void 0,this.#H=!1}static fromGlob(Q,X={}){let Z=new u(null,void 0,X);return u.#J(Q,Z,0,X,0),Z}toMMPattern(){if(this!==this.#Q)return this.#Q.toMMPattern();let Q=this.toString(),[X,Z,V,$]=this.toRegExpSource();if(!(V||this.#V||this.#K.nocase&&!this.#K.nocaseMagicOnly&&Q.toUpperCase()!==Q.toLowerCase()))return Z;let q=(this.#K.nocase?"i":"")+($?"u":"");return Object.assign(new RegExp(`^${X}$`,q),{_src:X,_glob:Q})}get options(){return this.#K}toRegExpSource(Q){let X=Q??!!this.#K.dot;if(this.#Q===this)this.#_(),this.#z();if(!x5(this)){let K=this.isStart()&&this.isEnd()&&!this.#X.some((_)=>typeof _!=="string"),z=this.#X.map((_)=>{let[j,U,G,A]=typeof _==="string"?u.#L(_,this.#V,K):_.toRegExpSource(Q);return this.#V=this.#V||G,this.#$=this.#$||A,j}).join(""),Y="";if(this.isStart()){if(typeof this.#X[0]==="string"){if(!(this.#X.length===1&&i6.has(this.#X[0]))){let j=l6,U=X&&j.has(z.charAt(0))||z.startsWith("\\.")&&j.has(z.charAt(2))||z.startsWith("\\.\\.")&&j.has(z.charAt(4)),G=!X&&!Q&&j.has(z.charAt(0));Y=U?c6:G?NQ:""}}}let W="";if(this.isEnd()&&this.#Q.#W&&this.#q?.type==="!")W="(?:$|\\/)";return[Y+z+W,l(z),this.#V=!!this.#V,this.#$]}let Z=this.type==="*"||this.type==="+",V=this.type==="!"?"(?:(?!(?:":"(?:",$=this.#A(X);if(this.isStart()&&this.isEnd()&&!$&&this.type!=="!"){let K=this.toString(),z=this;return z.#X=[K],z.type=null,z.#V=void 0,[K,l(this.toString()),!1,!1]}let J=!Z||Q||X||!NQ?"":this.#A(!0);if(J===$)J="";if(J)$=`(?:${$})(?:${J})*?`;let q="";if(this.type==="!"&&this.#H)q=(this.isStart()&&!X?NQ:"")+D5;else{let K=this.type==="!"?"))"+(this.isStart()&&!X&&!Q?NQ:"")+N5+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&J?")":this.type==="*"&&J?")?":`)${this.type}`;q=V+$+K}return[q,l($),this.#V=!!this.#V,this.#$]}#_(){if(!x5(this)){for(let Q of this.#X)if(typeof Q==="object")Q.#_()}else{let Q=0,X=!1;do{X=!0;for(let Z=0;Z<this.#X.length;Z++){let V=this.#X[Z];if(typeof V==="object"){if(V.#_(),this.#v(V))X=!1,this.#R(V,Z);else if(this.#w(V))X=!1,this.#U(V,Z);else if(this.#M(V))X=!1,this.#F(V)}}}while(!X&&++Q<10)}this.#j=void 0}#A(Q){return this.#X.map((X)=>{if(typeof X==="string")throw Error("string type in extglob ast??");let[Z,V,$,J]=X.toRegExpSource(Q);return this.#$=this.#$||J,Z}).filter((X)=>!(this.isStart()&&this.isEnd())||!!X).join("|")}static#L(Q,X,Z=!1){let V=!1,$="",J=!1,q=!1;for(let K=0;K<Q.length;K++){let z=Q.charAt(K);if(V){V=!1,$+=(p6.has(z)?"\\":"")+z;continue}if(z==="*"){if(q)continue;q=!0,$+=Z&&/^[*]+$/.test(Q)?D5:N5,X=!0;continue}else q=!1;if(z==="\\"){if(K===Q.length-1)$+="\\\\";else V=!0;continue}if(z==="["){let[Y,W,H,_]=I5(Q,K);if(H){$+=Y,J=J||W,K+=H-1,X=X||_;continue}}if(z==="?"){$+=tQ,X=!0;continue}$+=o6(z)}return[$,l(Q),!!X,J]}}u=KQ;var zQ=(Q,{windowsPathsNoEscape:X=!1,magicalBraces:Z=!1}={})=>{if(Z)return X?Q.replace(/[?*()[\]{}]/g,"[$&]"):Q.replace(/[?*()[\]\\{}]/g,"\\$&");return X?Q.replace(/[?*()[\]]/g,"[$&]"):Q.replace(/[?*()[\]\\]/g,"\\$&")};var N=(Q,X,Z={})=>{if(_Q(X),!Z.nocomment&&X.charAt(0)==="#")return!1;return new h(X,Z).match(Q)},a6=/^\*+([^+@!?\*\[\(]*)$/,r6=(Q)=>(X)=>!X.startsWith(".")&&X.endsWith(Q),s6=(Q)=>(X)=>X.endsWith(Q),e6=(Q)=>{return Q=Q.toLowerCase(),(X)=>!X.startsWith(".")&&X.toLowerCase().endsWith(Q)},t6=(Q)=>{return Q=Q.toLowerCase(),(X)=>X.toLowerCase().endsWith(Q)},Q7=/^\*+\.\*+$/,X7=(Q)=>!Q.startsWith(".")&&Q.includes("."),Z7=(Q)=>Q!=="."&&Q!==".."&&Q.includes("."),V7=/^\.\*+$/,$7=(Q)=>Q!=="."&&Q!==".."&&Q.startsWith("."),J7=/^\*+$/,q7=(Q)=>Q.length!==0&&!Q.startsWith("."),K7=(Q)=>Q.length!==0&&Q!=="."&&Q!=="..",z7=/^\?+([^+@!?\*\[\(]*)?$/,Y7=([Q,X=""])=>{let Z=E5([Q]);if(!X)return Z;return X=X.toLowerCase(),(V)=>Z(V)&&V.toLowerCase().endsWith(X)},H7=([Q,X=""])=>{let Z=b5([Q]);if(!X)return Z;return X=X.toLowerCase(),(V)=>Z(V)&&V.toLowerCase().endsWith(X)},W7=([Q,X=""])=>{let Z=b5([Q]);return!X?Z:(V)=>Z(V)&&V.endsWith(X)},j7=([Q,X=""])=>{let Z=E5([Q]);return!X?Z:(V)=>Z(V)&&V.endsWith(X)},E5=([Q])=>{let X=Q.length;return(Z)=>Z.length===X&&!Z.startsWith(".")},b5=([Q])=>{let X=Q.length;return(Z)=>Z.length===X&&Z!=="."&&Z!==".."},u5=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",S5={win32:{sep:"\\"},posix:{sep:"/"}},_7=u5==="win32"?S5.win32.sep:S5.posix.sep;N.sep=_7;var O=Symbol("globstar **");N.GLOBSTAR=O;var G7="[^/]",U7=G7+"*?",C7="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",A7="(?:(?!(?:\\/|^)\\.).)*?",B7=(Q,X={})=>(Z)=>N(Z,Q,X);N.filter=B7;var m=(Q,X={})=>Object.assign({},Q,X),w7=(Q)=>{if(!Q||typeof Q!=="object"||!Object.keys(Q).length)return N;let X=N;return Object.assign((V,$,J={})=>X(V,$,m(Q,J)),{Minimatch:class extends X.Minimatch{constructor($,J={}){super($,m(Q,J))}static defaults($){return X.defaults(m(Q,$)).Minimatch}},AST:class extends X.AST{constructor($,J,q={}){super($,J,m(Q,q))}static fromGlob($,J={}){return X.AST.fromGlob($,m(Q,J))}},unescape:(V,$={})=>X.unescape(V,m(Q,$)),escape:(V,$={})=>X.escape(V,m(Q,$)),filter:(V,$={})=>X.filter(V,m(Q,$)),defaults:(V)=>X.defaults(m(Q,V)),makeRe:(V,$={})=>X.makeRe(V,m(Q,$)),braceExpand:(V,$={})=>X.braceExpand(V,m(Q,$)),match:(V,$,J={})=>X.match(V,$,m(Q,J)),sep:X.sep,GLOBSTAR:O})};N.defaults=w7;var y5=(Q,X={})=>{if(_Q(Q),X.nobrace||!/\{(?:(?!\{).)*\}/.test(Q))return[Q];return k5(Q,{max:X.braceExpandMax})};N.braceExpand=y5;var L7=(Q,X={})=>new h(Q,X).makeRe();N.makeRe=L7;var v7=(Q,X,Z={})=>{let V=new h(X,Z);if(Q=Q.filter(($)=>V.match($)),V.options.nonull&&!Q.length)Q.push(X);return Q};N.match=v7;var T5=/[?*]|[+@!]\(.*?\)|\[|\]/,M7=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class h{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(Q,X={}){_Q(Q),X=X||{},this.options=X,this.maxGlobstarRecursion=X.maxGlobstarRecursion??200,this.pattern=Q,this.platform=X.platform||u5,this.isWindows=this.platform==="win32";let Z="allowWindowsEscape";if(this.windowsPathsNoEscape=!!X.windowsPathsNoEscape||X[Z]===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!X.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!X.nonegate,this.comment=!1,this.empty=!1,this.partial=!!X.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=X.windowsNoMagicRoot!==void 0?X.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 Q of this.set)for(let X of Q)if(typeof X!=="string")return!0;return!1}debug(...Q){}make(){let Q=this.pattern,X=this.options;if(!X.nocomment&&Q.charAt(0)==="#"){this.comment=!0;return}if(!Q){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],X.debug)this.debug=(...$)=>console.error(...$);this.debug(this.pattern,this.globSet);let Z=this.globSet.map(($)=>this.slashSplit($));this.globParts=this.preprocess(Z),this.debug(this.pattern,this.globParts);let V=this.globParts.map(($,J,q)=>{if(this.isWindows&&this.windowsNoMagicRoot){let K=$[0]===""&&$[1]===""&&($[2]==="?"||!T5.test($[2]))&&!T5.test($[3]),z=/^[a-z]:/i.test($[0]);if(K)return[...$.slice(0,4),...$.slice(4).map((Y)=>this.parse(Y))];else if(z)return[$[0],...$.slice(1).map((Y)=>this.parse(Y))]}return $.map((K)=>this.parse(K))});if(this.debug(this.pattern,V),this.set=V.filter(($)=>$.indexOf(!1)===-1),this.isWindows)for(let $=0;$<this.set.length;$++){let J=this.set[$];if(J[0]===""&&J[1]===""&&this.globParts[$][2]==="?"&&typeof J[3]==="string"&&/^[a-z]:$/i.test(J[3]))J[2]="?"}this.debug(this.pattern,this.set)}preprocess(Q){if(this.options.noglobstar){for(let Z=0;Z<Q.length;Z++)for(let V=0;V<Q[Z].length;V++)if(Q[Z][V]==="**")Q[Z][V]="*"}let{optimizationLevel:X=1}=this.options;if(X>=2)Q=this.firstPhasePreProcess(Q),Q=this.secondPhasePreProcess(Q);else if(X>=1)Q=this.levelOneOptimize(Q);else Q=this.adjascentGlobstarOptimize(Q);return Q}adjascentGlobstarOptimize(Q){return Q.map((X)=>{let Z=-1;while((Z=X.indexOf("**",Z+1))!==-1){let V=Z;while(X[V+1]==="**")V++;if(V!==Z)X.splice(Z,V-Z)}return X})}levelOneOptimize(Q){return Q.map((X)=>{return X=X.reduce((Z,V)=>{let $=Z[Z.length-1];if(V==="**"&&$==="**")return Z;if(V===".."){if($&&$!==".."&&$!=="."&&$!=="**")return Z.pop(),Z}return Z.push(V),Z},[]),X.length===0?[""]:X})}levelTwoFileOptimize(Q){if(!Array.isArray(Q))Q=this.slashSplit(Q);let X=!1;do{if(X=!1,!this.preserveMultipleSlashes){for(let V=1;V<Q.length-1;V++){let $=Q[V];if(V===1&&$===""&&Q[0]==="")continue;if($==="."||$==="")X=!0,Q.splice(V,1),V--}if(Q[0]==="."&&Q.length===2&&(Q[1]==="."||Q[1]===""))X=!0,Q.pop()}let Z=0;while((Z=Q.indexOf("..",Z+1))!==-1){let V=Q[Z-1];if(V&&V!=="."&&V!==".."&&V!=="**")X=!0,Q.splice(Z-1,2),Z-=2}}while(X);return Q.length===0?[""]:Q}firstPhasePreProcess(Q){let X=!1;do{X=!1;for(let Z of Q){let V=-1;while((V=Z.indexOf("**",V+1))!==-1){let J=V;while(Z[J+1]==="**")J++;if(J>V)Z.splice(V+1,J-V);let q=Z[V+1],K=Z[V+2],z=Z[V+3];if(q!=="..")continue;if(!K||K==="."||K===".."||!z||z==="."||z==="..")continue;X=!0,Z.splice(V,1);let Y=Z.slice(0);Y[V]="**",Q.push(Y),V--}if(!this.preserveMultipleSlashes){for(let J=1;J<Z.length-1;J++){let q=Z[J];if(J===1&&q===""&&Z[0]==="")continue;if(q==="."||q==="")X=!0,Z.splice(J,1),J--}if(Z[0]==="."&&Z.length===2&&(Z[1]==="."||Z[1]===""))X=!0,Z.pop()}let $=0;while(($=Z.indexOf("..",$+1))!==-1){let J=Z[$-1];if(J&&J!=="."&&J!==".."&&J!=="**"){X=!0;let K=$===1&&Z[$+1]==="**"?["."]:[];if(Z.splice($-1,2,...K),Z.length===0)Z.push("");$-=2}}}}while(X);return Q}secondPhasePreProcess(Q){for(let X=0;X<Q.length-1;X++)for(let Z=X+1;Z<Q.length;Z++){let V=this.partsMatch(Q[X],Q[Z],!this.preserveMultipleSlashes);if(V){Q[X]=[],Q[Z]=V;break}}return Q.filter((X)=>X.length)}partsMatch(Q,X,Z=!1){let V=0,$=0,J=[],q="";while(V<Q.length&&$<X.length)if(Q[V]===X[$])J.push(q==="b"?X[$]:Q[V]),V++,$++;else if(Z&&Q[V]==="**"&&X[$]===Q[V+1])J.push(Q[V]),V++;else if(Z&&X[$]==="**"&&Q[V]===X[$+1])J.push(X[$]),$++;else if(Q[V]==="*"&&X[$]&&(this.options.dot||!X[$].startsWith("."))&&X[$]!=="**"){if(q==="b")return!1;q="a",J.push(Q[V]),V++,$++}else if(X[$]==="*"&&Q[V]&&(this.options.dot||!Q[V].startsWith("."))&&Q[V]!=="**"){if(q==="a")return!1;q="b",J.push(X[$]),V++,$++}else return!1;return Q.length===X.length&&J}parseNegate(){if(this.nonegate)return;let Q=this.pattern,X=!1,Z=0;for(let V=0;V<Q.length&&Q.charAt(V)==="!";V++)X=!X,Z++;if(Z)this.pattern=Q.slice(Z);this.negate=X}matchOne(Q,X,Z=!1){let V=0,$=0;if(this.isWindows){let q=typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0]),K=!q&&Q[0]===""&&Q[1]===""&&Q[2]==="?"&&/^[a-z]:$/i.test(Q[3]),z=typeof X[0]==="string"&&/^[a-z]:$/i.test(X[0]),Y=!z&&X[0]===""&&X[1]===""&&X[2]==="?"&&typeof X[3]==="string"&&/^[a-z]:$/i.test(X[3]),W=K?3:q?0:void 0,H=Y?3:z?0:void 0;if(typeof W==="number"&&typeof H==="number"){let[_,j]=[Q[W],X[H]];if(_.toLowerCase()===j.toLowerCase())X[H]=_,$=H,V=W}}let{optimizationLevel:J=1}=this.options;if(J>=2)Q=this.levelTwoFileOptimize(Q);if(X.includes(O))return this.#Q(Q,X,Z,V,$);return this.#$(Q,X,Z,V,$)}#Q(Q,X,Z,V,$){let J=X.indexOf(O,$),q=X.lastIndexOf(O),[K,z,Y]=Z?[X.slice($,J),X.slice(J+1),[]]:[X.slice($,J),X.slice(J+1,q),X.slice(q+1)];if(K.length){let C=Q.slice(V,V+K.length);if(!this.#$(C,K,Z,0,0))return!1;V+=K.length,$+=K.length}let W=0;if(Y.length){if(Y.length+V>Q.length)return!1;let C=Q.length-Y.length;if(this.#$(Q,Y,Z,C,0))W=Y.length;else{if(Q[Q.length-1]!==""||V+Y.length===Q.length)return!1;if(C--,!this.#$(Q,Y,Z,C,0))return!1;W=Y.length+1}}if(!z.length){let C=!!W;for(let B=V;B<Q.length-W;B++){let L=String(Q[B]);if(C=!0,L==="."||L===".."||!this.options.dot&&L.startsWith("."))return!1}return Z||C}let H=[[[],0]],_=H[0],j=0,U=[0];for(let C of z)if(C===O)U.push(j),_=[[],0],H.push(_);else _[0].push(C),j++;let G=H.length-1,A=Q.length-W;for(let C of H)C[1]=A-(U[G--]+C[0].length);return!!this.#V(Q,H,V,0,Z,0,!!W)}#V(Q,X,Z,V,$,J,q){let K=X[V];if(!K){for(let W=Z;W<Q.length;W++){q=!0;let H=Q[W];if(H==="."||H===".."||!this.options.dot&&H.startsWith("."))return!1}return q}let[z,Y]=K;while(Z<=Y){if(this.#$(Q.slice(0,Z+z.length),z,$,Z,0)&&J<this.maxGlobstarRecursion){let _=this.#V(Q,X,Z+z.length,V+1,$,J+1,q);if(_!==!1)return _}let H=Q[Z];if(H==="."||H===".."||!this.options.dot&&H.startsWith("."))return!1;Z++}return $||null}#$(Q,X,Z,V,$){let J,q,K,z;for(J=V,q=$,z=Q.length,K=X.length;J<z&&q<K;J++,q++){this.debug("matchOne loop");let Y=X[q],W=Q[J];if(this.debug(X,Y,W),Y===!1||Y===O)return!1;let H;if(typeof Y==="string")H=W===Y,this.debug("string match",Y,W,H);else H=Y.test(W),this.debug("pattern match",Y,W,H);if(!H)return!1}if(J===z&&q===K)return!0;else if(J===z)return Z;else if(q===K)return J===z-1&&Q[J]==="";else throw Error("wtf?")}braceExpand(){return y5(this.pattern,this.options)}parse(Q){_Q(Q);let X=this.options;if(Q==="**")return O;if(Q==="")return"";let Z,V=null;if(Z=Q.match(J7))V=X.dot?K7:q7;else if(Z=Q.match(a6))V=(X.nocase?X.dot?t6:e6:X.dot?s6:r6)(Z[1]);else if(Z=Q.match(z7))V=(X.nocase?X.dot?H7:Y7:X.dot?W7:j7)(Z);else if(Z=Q.match(Q7))V=X.dot?Z7:X7;else if(Z=Q.match(V7))V=$7;let $=KQ.fromGlob(Q,this.options).toMMPattern();if(V&&typeof $==="object")Reflect.defineProperty($,"test",{value:V});return $}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let Q=this.set;if(!Q.length)return this.regexp=!1,this.regexp;let X=this.options,Z=X.noglobstar?U7:X.dot?C7:A7,V=new Set(X.nocase?["i"]:[]),$=Q.map((K)=>{let z=K.map((W)=>{if(W instanceof RegExp)for(let H of W.flags.split(""))V.add(H);return typeof W==="string"?M7(W):W===O?O:W._src});z.forEach((W,H)=>{let _=z[H+1],j=z[H-1];if(W!==O||j===O)return;if(j===void 0)if(_!==void 0&&_!==O)z[H+1]="(?:\\/|"+Z+"\\/)?"+_;else z[H]=Z;else if(_===void 0)z[H-1]=j+"(?:\\/|\\/"+Z+")?";else if(_!==O)z[H-1]=j+"(?:\\/|\\/"+Z+"\\/)"+_,z[H+1]=O});let Y=z.filter((W)=>W!==O);if(this.partial&&Y.length>=1){let W=[];for(let H=1;H<=Y.length;H++)W.push(Y.slice(0,H).join("/"));return"(?:"+W.join("|")+")"}return Y.join("/")}).join("|"),[J,q]=Q.length>1?["(?:",")"]:["",""];if($="^"+J+$+q+"$",this.partial)$="^(?:\\/|"+J+$.slice(1,-1)+q+")$";if(this.negate)$="^(?!"+$+").+$";try{this.regexp=new RegExp($,[...V].join(""))}catch(K){this.regexp=!1}return this.regexp}slashSplit(Q){if(this.preserveMultipleSlashes)return Q.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test(Q))return["",...Q.split(/\/+/)];else return Q.split(/\/+/)}match(Q,X=this.partial){if(this.debug("match",Q,this.pattern),this.comment)return!1;if(this.empty)return Q==="";if(Q==="/"&&X)return!0;let Z=this.options;if(this.isWindows)Q=Q.split("\\").join("/");let V=this.slashSplit(Q);this.debug(this.pattern,"split",V);let $=this.set;this.debug(this.pattern,"set",$);let J=V[V.length-1];if(!J)for(let q=V.length-2;!J&&q>=0;q--)J=V[q];for(let q=0;q<$.length;q++){let K=$[q],z=V;if(Z.matchBase&&K.length===1)z=[J];if(this.matchOne(z,K,X)){if(Z.flipNegate)return!0;return!this.negate}}if(Z.flipNegate)return!1;return this.negate}static defaults(Q){return N.defaults(Q).Minimatch}}N.AST=KQ;N.Minimatch=h;N.escape=zQ;N.unescape=l;import{fileURLToPath as Z8}from"url";var O7=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,m5=new Set,Q5=typeof process=="object"&&process?process:{},h5=(Q,X,Z,V)=>{typeof Q5.emitWarning=="function"?Q5.emitWarning(Q,X,Z,V):console.error(`[${Z}] ${X}: ${Q}`)},SQ=globalThis.AbortController,f5=globalThis.AbortSignal;if(typeof SQ>"u"){f5=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(Z,V){this._onabort.push(V)}},SQ=class{constructor(){X()}signal=new f5;abort(Z){if(!this.signal.aborted){this.signal.reason=Z,this.signal.aborted=!0;for(let V of this.signal._onabort)V(Z);this.signal.onabort?.(Z)}}};let Q=Q5.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",X=()=>{Q&&(Q=!1,h5("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",X))}}var F7=(Q)=>!m5.has(Q),Z9=Symbol("type"),t=(Q)=>Q&&Q===Math.floor(Q)&&Q>0&&isFinite(Q),g5=(Q)=>t(Q)?Q<=Math.pow(2,8)?Uint8Array:Q<=Math.pow(2,16)?Uint16Array:Q<=Math.pow(2,32)?Uint32Array:Q<=Number.MAX_SAFE_INTEGER?DQ:null:null,DQ=class extends Array{constructor(Q){super(Q),this.fill(0)}},k7=class Q{heap;length;static#Q=!1;static create(X){let Z=g5(X);if(!Z)return[];Q.#Q=!0;let V=new Q(X,Z);return Q.#Q=!1,V}constructor(X,Z){if(!Q.#Q)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new Z(X),this.length=0}push(X){this.heap[this.length++]=X}pop(){return this.heap[--this.length]}},UQ=class Q{#Q;#V;#$;#X;#q;#O;#B;#W;get perf(){return this.#W}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#K;#j;#H;#z;#J;#w;#v;#G;#U;#R;#C;#M;#F;#_;#A;#L;#I;#Z;#E;static unsafeExposeInternals(X){return{starts:X.#F,ttls:X.#_,autopurgeTimers:X.#A,sizes:X.#M,keyMap:X.#H,keyList:X.#z,valList:X.#J,next:X.#w,prev:X.#v,get head(){return X.#G},get tail(){return X.#U},free:X.#R,isBackgroundFetch:(Z)=>X.#Y(Z),backgroundFetch:(Z,V,$,J)=>X.#d(Z,V,$,J),moveToTail:(Z)=>X.#u(Z),indexes:(Z)=>X.#N(Z),rindexes:(Z)=>X.#D(Z),isStale:(Z)=>X.#k(Z)}}get max(){return this.#Q}get maxSize(){return this.#V}get calculatedSize(){return this.#j}get size(){return this.#K}get fetchMethod(){return this.#O}get memoMethod(){return this.#B}get dispose(){return this.#$}get onInsert(){return this.#X}get disposeAfter(){return this.#q}constructor(X){let{max:Z=0,ttl:V,ttlResolution:$=1,ttlAutopurge:J,updateAgeOnGet:q,updateAgeOnHas:K,allowStale:z,dispose:Y,onInsert:W,disposeAfter:H,noDisposeOnSet:_,noUpdateTTL:j,maxSize:U=0,maxEntrySize:G=0,sizeCalculation:A,fetchMethod:C,memoMethod:B,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:v,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:k,ignoreFetchAbort:T,perf:c}=X;if(c!==void 0&&typeof c?.now!="function")throw TypeError("perf option must have a now() method if specified");if(this.#W=c??O7,Z!==0&&!t(Z))throw TypeError("max option must be a nonnegative integer");let f=Z?g5(Z):Array;if(!f)throw Error("invalid max value: "+Z);if(this.#Q=Z,this.#V=U,this.maxEntrySize=G||this.#V,this.sizeCalculation=A,this.sizeCalculation){if(!this.#V&&!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(B!==void 0&&typeof B!="function")throw TypeError("memoMethod must be a function if defined");if(this.#B=B,C!==void 0&&typeof C!="function")throw TypeError("fetchMethod must be a function if specified");if(this.#O=C,this.#I=!!C,this.#H=new Map,this.#z=Array(Z).fill(void 0),this.#J=Array(Z).fill(void 0),this.#w=new f(Z),this.#v=new f(Z),this.#G=0,this.#U=0,this.#R=k7.create(Z),this.#K=0,this.#j=0,typeof Y=="function"&&(this.#$=Y),typeof W=="function"&&(this.#X=W),typeof H=="function"?(this.#q=H,this.#C=[]):(this.#q=void 0,this.#C=void 0),this.#L=!!this.#$,this.#E=!!this.#X,this.#Z=!!this.#q,this.noDisposeOnSet=!!_,this.noUpdateTTL=!!j,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!w,this.allowStaleOnFetchAbort=!!k,this.ignoreFetchAbort=!!T,this.maxEntrySize!==0){if(this.#V!==0&&!t(this.#V))throw TypeError("maxSize must be a positive integer if specified");if(!t(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#l()}if(this.allowStale=!!z,this.noDeleteOnStaleGet=!!v,this.updateAgeOnGet=!!q,this.updateAgeOnHas=!!K,this.ttlResolution=t($)||$===0?$:1,this.ttlAutopurge=!!J,this.ttl=V||0,this.ttl){if(!t(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#S()}if(this.#Q===0&&this.ttl===0&&this.#V===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Q&&!this.#V){let E="LRU_CACHE_UNBOUNDED";F7(E)&&(m5.add(E),h5("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",E,Q))}}getRemainingTTL(X){return this.#H.has(X)?1/0:0}#S(){let X=new DQ(this.#Q),Z=new DQ(this.#Q);this.#_=X,this.#F=Z;let V=this.ttlAutopurge?Array(this.#Q):void 0;this.#A=V,this.#f=(q,K,z=this.#W.now())=>{if(Z[q]=K!==0?z:0,X[q]=K,V?.[q]&&(clearTimeout(V[q]),V[q]=void 0),K!==0&&V){let Y=setTimeout(()=>{this.#k(q)&&this.#P(this.#z[q],"expire")},K+1);Y.unref&&Y.unref(),V[q]=Y}},this.#x=(q)=>{Z[q]=X[q]!==0?this.#W.now():0},this.#T=(q,K)=>{if(X[K]){let z=X[K],Y=Z[K];if(!z||!Y)return;q.ttl=z,q.start=Y,q.now=$||J();let W=q.now-Y;q.remainingTTL=z-W}};let $=0,J=()=>{let q=this.#W.now();if(this.ttlResolution>0){$=q;let K=setTimeout(()=>$=0,this.ttlResolution);K.unref&&K.unref()}return q};this.getRemainingTTL=(q)=>{let K=this.#H.get(q);if(K===void 0)return 0;let z=X[K],Y=Z[K];if(!z||!Y)return 1/0;let W=($||J())-Y;return z-W},this.#k=(q)=>{let K=Z[q],z=X[q];return!!z&&!!K&&($||J())-K>z}}#x=()=>{};#T=()=>{};#f=()=>{};#k=()=>!1;#l(){let X=new DQ(this.#Q);this.#j=0,this.#M=X,this.#y=(Z)=>{this.#j-=X[Z],X[Z]=0},this.#m=(Z,V,$,J)=>{if(this.#Y(V))return 0;if(!t($))if(J){if(typeof J!="function")throw TypeError("sizeCalculation must be a function");if($=J(V,Z),!t($))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 $},this.#b=(Z,V,$)=>{if(X[Z]=V,this.#V){let J=this.#V-X[Z];for(;this.#j>J;)this.#g(!0)}this.#j+=X[Z],$&&($.entrySize=V,$.totalCalculatedSize=this.#j)}}#y=(X)=>{};#b=(X,Z,V)=>{};#m=(X,Z,V,$)=>{if(V||$)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#N({allowStale:X=this.allowStale}={}){if(this.#K)for(let Z=this.#U;!(!this.#h(Z)||((X||!this.#k(Z))&&(yield Z),Z===this.#G));)Z=this.#v[Z]}*#D({allowStale:X=this.allowStale}={}){if(this.#K)for(let Z=this.#G;!(!this.#h(Z)||((X||!this.#k(Z))&&(yield Z),Z===this.#U));)Z=this.#w[Z]}#h(X){return X!==void 0&&this.#H.get(this.#z[X])===X}*entries(){for(let X of this.#N())this.#J[X]!==void 0&&this.#z[X]!==void 0&&!this.#Y(this.#J[X])&&(yield[this.#z[X],this.#J[X]])}*rentries(){for(let X of this.#D())this.#J[X]!==void 0&&this.#z[X]!==void 0&&!this.#Y(this.#J[X])&&(yield[this.#z[X],this.#J[X]])}*keys(){for(let X of this.#N()){let Z=this.#z[X];Z!==void 0&&!this.#Y(this.#J[X])&&(yield Z)}}*rkeys(){for(let X of this.#D()){let Z=this.#z[X];Z!==void 0&&!this.#Y(this.#J[X])&&(yield Z)}}*values(){for(let X of this.#N())this.#J[X]!==void 0&&!this.#Y(this.#J[X])&&(yield this.#J[X])}*rvalues(){for(let X of this.#D())this.#J[X]!==void 0&&!this.#Y(this.#J[X])&&(yield this.#J[X])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(X,Z={}){for(let V of this.#N()){let $=this.#J[V],J=this.#Y($)?$.__staleWhileFetching:$;if(J!==void 0&&X(J,this.#z[V],this))return this.get(this.#z[V],Z)}}forEach(X,Z=this){for(let V of this.#N()){let $=this.#J[V],J=this.#Y($)?$.__staleWhileFetching:$;J!==void 0&&X.call(Z,J,this.#z[V],this)}}rforEach(X,Z=this){for(let V of this.#D()){let $=this.#J[V],J=this.#Y($)?$.__staleWhileFetching:$;J!==void 0&&X.call(Z,J,this.#z[V],this)}}purgeStale(){let X=!1;for(let Z of this.#D({allowStale:!0}))this.#k(Z)&&(this.#P(this.#z[Z],"expire"),X=!0);return X}info(X){let Z=this.#H.get(X);if(Z===void 0)return;let V=this.#J[Z],$=this.#Y(V)?V.__staleWhileFetching:V;if($===void 0)return;let J={value:$};if(this.#_&&this.#F){let q=this.#_[Z],K=this.#F[Z];if(q&&K){let z=q-(this.#W.now()-K);J.ttl=z,J.start=Date.now()}}return this.#M&&(J.size=this.#M[Z]),J}dump(){let X=[];for(let Z of this.#N({allowStale:!0})){let V=this.#z[Z],$=this.#J[Z],J=this.#Y($)?$.__staleWhileFetching:$;if(J===void 0||V===void 0)continue;let q={value:J};if(this.#_&&this.#F){q.ttl=this.#_[Z];let K=this.#W.now()-this.#F[Z];q.start=Math.floor(Date.now()-K)}this.#M&&(q.size=this.#M[Z]),X.unshift([V,q])}return X}load(X){this.clear();for(let[Z,V]of X){if(V.start){let $=Date.now()-V.start;V.start=this.#W.now()-$}this.set(Z,V.value,V)}}set(X,Z,V={}){if(Z===void 0)return this.delete(X),this;let{ttl:$=this.ttl,start:J,noDisposeOnSet:q=this.noDisposeOnSet,sizeCalculation:K=this.sizeCalculation,status:z}=V,{noUpdateTTL:Y=this.noUpdateTTL}=V,W=this.#m(X,Z,V.size||0,K);if(this.maxEntrySize&&W>this.maxEntrySize)return z&&(z.set="miss",z.maxEntrySizeExceeded=!0),this.#P(X,"set"),this;let H=this.#K===0?void 0:this.#H.get(X);if(H===void 0)H=this.#K===0?this.#U:this.#R.length!==0?this.#R.pop():this.#K===this.#Q?this.#g(!1):this.#K,this.#z[H]=X,this.#J[H]=Z,this.#H.set(X,H),this.#w[this.#U]=H,this.#v[H]=this.#U,this.#U=H,this.#K++,this.#b(H,W,z),z&&(z.set="add"),Y=!1,this.#E&&this.#X?.(Z,X,"add");else{this.#u(H);let _=this.#J[H];if(Z!==_){if(this.#I&&this.#Y(_)){_.__abortController.abort(Error("replaced"));let{__staleWhileFetching:j}=_;j!==void 0&&!q&&(this.#L&&this.#$?.(j,X,"set"),this.#Z&&this.#C?.push([j,X,"set"]))}else q||(this.#L&&this.#$?.(_,X,"set"),this.#Z&&this.#C?.push([_,X,"set"]));if(this.#y(H),this.#b(H,W,z),this.#J[H]=Z,z){z.set="replace";let j=_&&this.#Y(_)?_.__staleWhileFetching:_;j!==void 0&&(z.oldValue=j)}}else z&&(z.set="update");this.#E&&this.onInsert?.(Z,X,Z===_?"update":"replace")}if($!==0&&!this.#_&&this.#S(),this.#_&&(Y||this.#f(H,$,J),z&&this.#T(z,H)),!q&&this.#Z&&this.#C){let _=this.#C,j;for(;j=_?.shift();)this.#q?.(...j)}return this}pop(){try{for(;this.#K;){let X=this.#J[this.#G];if(this.#g(!0),this.#Y(X)){if(X.__staleWhileFetching)return X.__staleWhileFetching}else if(X!==void 0)return X}}finally{if(this.#Z&&this.#C){let X=this.#C,Z;for(;Z=X?.shift();)this.#q?.(...Z)}}}#g(X){let Z=this.#G,V=this.#z[Z],$=this.#J[Z];return this.#I&&this.#Y($)?$.__abortController.abort(Error("evicted")):(this.#L||this.#Z)&&(this.#L&&this.#$?.($,V,"evict"),this.#Z&&this.#C?.push([$,V,"evict"])),this.#y(Z),this.#A?.[Z]&&(clearTimeout(this.#A[Z]),this.#A[Z]=void 0),X&&(this.#z[Z]=void 0,this.#J[Z]=void 0,this.#R.push(Z)),this.#K===1?(this.#G=this.#U=0,this.#R.length=0):this.#G=this.#w[Z],this.#H.delete(V),this.#K--,Z}has(X,Z={}){let{updateAgeOnHas:V=this.updateAgeOnHas,status:$}=Z,J=this.#H.get(X);if(J!==void 0){let q=this.#J[J];if(this.#Y(q)&&q.__staleWhileFetching===void 0)return!1;if(this.#k(J))$&&($.has="stale",this.#T($,J));else return V&&this.#x(J),$&&($.has="hit",this.#T($,J)),!0}else $&&($.has="miss");return!1}peek(X,Z={}){let{allowStale:V=this.allowStale}=Z,$=this.#H.get(X);if($===void 0||!V&&this.#k($))return;let J=this.#J[$];return this.#Y(J)?J.__staleWhileFetching:J}#d(X,Z,V,$){let J=Z===void 0?void 0:this.#J[Z];if(this.#Y(J))return J;let q=new SQ,{signal:K}=V;K?.addEventListener("abort",()=>q.abort(K.reason),{signal:q.signal});let z={signal:q.signal,options:V,context:$},Y=(G,A=!1)=>{let{aborted:C}=q.signal,B=V.ignoreFetchAbort&&G!==void 0,L=V.ignoreFetchAbort||!!(V.allowStaleOnFetchAbort&&G!==void 0);if(V.status&&(C&&!A?(V.status.fetchAborted=!0,V.status.fetchError=q.signal.reason,B&&(V.status.fetchAbortIgnored=!0)):V.status.fetchResolved=!0),C&&!B&&!A)return H(q.signal.reason,L);let v=j,w=this.#J[Z];return(w===j||B&&A&&w===void 0)&&(G===void 0?v.__staleWhileFetching!==void 0?this.#J[Z]=v.__staleWhileFetching:this.#P(X,"fetch"):(V.status&&(V.status.fetchUpdated=!0),this.set(X,G,z.options))),G},W=(G)=>(V.status&&(V.status.fetchRejected=!0,V.status.fetchError=G),H(G,!1)),H=(G,A)=>{let{aborted:C}=q.signal,B=C&&V.allowStaleOnFetchAbort,L=B||V.allowStaleOnFetchRejection,v=L||V.noDeleteOnFetchRejection,w=j;if(this.#J[Z]===j&&(!v||!A&&w.__staleWhileFetching===void 0?this.#P(X,"fetch"):B||(this.#J[Z]=w.__staleWhileFetching)),L)return V.status&&w.__staleWhileFetching!==void 0&&(V.status.returnedStale=!0),w.__staleWhileFetching;if(w.__returned===w)throw G},_=(G,A)=>{let C=this.#O?.(X,J,z);C&&C instanceof Promise&&C.then((B)=>G(B===void 0?void 0:B),A),q.signal.addEventListener("abort",()=>{(!V.ignoreFetchAbort||V.allowStaleOnFetchAbort)&&(G(void 0),V.allowStaleOnFetchAbort&&(G=(B)=>Y(B,!0)))})};V.status&&(V.status.fetchDispatched=!0);let j=new Promise(_).then(Y,W),U=Object.assign(j,{__abortController:q,__staleWhileFetching:J,__returned:void 0});return Z===void 0?(this.set(X,U,{...z.options,status:void 0}),Z=this.#H.get(X)):this.#J[Z]=U,U}#Y(X){if(!this.#I)return!1;let Z=X;return!!Z&&Z instanceof Promise&&Z.hasOwnProperty("__staleWhileFetching")&&Z.__abortController instanceof SQ}async fetch(X,Z={}){let{allowStale:V=this.allowStale,updateAgeOnGet:$=this.updateAgeOnGet,noDeleteOnStaleGet:J=this.noDeleteOnStaleGet,ttl:q=this.ttl,noDisposeOnSet:K=this.noDisposeOnSet,size:z=0,sizeCalculation:Y=this.sizeCalculation,noUpdateTTL:W=this.noUpdateTTL,noDeleteOnFetchRejection:H=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:_=this.allowStaleOnFetchRejection,ignoreFetchAbort:j=this.ignoreFetchAbort,allowStaleOnFetchAbort:U=this.allowStaleOnFetchAbort,context:G,forceRefresh:A=!1,status:C,signal:B}=Z;if(!this.#I)return C&&(C.fetch="get"),this.get(X,{allowStale:V,updateAgeOnGet:$,noDeleteOnStaleGet:J,status:C});let L={allowStale:V,updateAgeOnGet:$,noDeleteOnStaleGet:J,ttl:q,noDisposeOnSet:K,size:z,sizeCalculation:Y,noUpdateTTL:W,noDeleteOnFetchRejection:H,allowStaleOnFetchRejection:_,allowStaleOnFetchAbort:U,ignoreFetchAbort:j,status:C,signal:B},v=this.#H.get(X);if(v===void 0){C&&(C.fetch="miss");let w=this.#d(X,v,L,G);return w.__returned=w}else{let w=this.#J[v];if(this.#Y(w)){let f=V&&w.__staleWhileFetching!==void 0;return C&&(C.fetch="inflight",f&&(C.returnedStale=!0)),f?w.__staleWhileFetching:w.__returned=w}let k=this.#k(v);if(!A&&!k)return C&&(C.fetch="hit"),this.#u(v),$&&this.#x(v),C&&this.#T(C,v),w;let T=this.#d(X,v,L,G),c=T.__staleWhileFetching!==void 0&&V;return C&&(C.fetch=k?"stale":"refresh",c&&k&&(C.returnedStale=!0)),c?T.__staleWhileFetching:T.__returned=T}}async forceFetch(X,Z={}){let V=await this.fetch(X,Z);if(V===void 0)throw Error("fetch() returned undefined");return V}memo(X,Z={}){let V=this.#B;if(!V)throw Error("no memoMethod provided to constructor");let{context:$,forceRefresh:J,...q}=Z,K=this.get(X,q);if(!J&&K!==void 0)return K;let z=V(X,K,{options:q,context:$});return this.set(X,z,q),z}get(X,Z={}){let{allowStale:V=this.allowStale,updateAgeOnGet:$=this.updateAgeOnGet,noDeleteOnStaleGet:J=this.noDeleteOnStaleGet,status:q}=Z,K=this.#H.get(X);if(K!==void 0){let z=this.#J[K],Y=this.#Y(z);return q&&this.#T(q,K),this.#k(K)?(q&&(q.get="stale"),Y?(q&&V&&z.__staleWhileFetching!==void 0&&(q.returnedStale=!0),V?z.__staleWhileFetching:void 0):(J||this.#P(X,"expire"),q&&V&&(q.returnedStale=!0),V?z:void 0)):(q&&(q.get="hit"),Y?z.__staleWhileFetching:(this.#u(K),$&&this.#x(K),z))}else q&&(q.get="miss")}#c(X,Z){this.#v[Z]=X,this.#w[X]=Z}#u(X){X!==this.#U&&(X===this.#G?this.#G=this.#w[X]:this.#c(this.#v[X],this.#w[X]),this.#c(this.#U,X),this.#U=X)}delete(X){return this.#P(X,"delete")}#P(X,Z){let V=!1;if(this.#K!==0){let $=this.#H.get(X);if($!==void 0)if(this.#A?.[$]&&(clearTimeout(this.#A?.[$]),this.#A[$]=void 0),V=!0,this.#K===1)this.#i(Z);else{this.#y($);let J=this.#J[$];if(this.#Y(J)?J.__abortController.abort(Error("deleted")):(this.#L||this.#Z)&&(this.#L&&this.#$?.(J,X,Z),this.#Z&&this.#C?.push([J,X,Z])),this.#H.delete(X),this.#z[$]=void 0,this.#J[$]=void 0,$===this.#U)this.#U=this.#v[$];else if($===this.#G)this.#G=this.#w[$];else{let q=this.#v[$];this.#w[q]=this.#w[$];let K=this.#w[$];this.#v[K]=this.#v[$]}this.#K--,this.#R.push($)}}if(this.#Z&&this.#C?.length){let $=this.#C,J;for(;J=$?.shift();)this.#q?.(...J)}return V}clear(){return this.#i("delete")}#i(X){for(let Z of this.#D({allowStale:!0})){let V=this.#J[Z];if(this.#Y(V))V.__abortController.abort(Error("deleted"));else{let $=this.#z[Z];this.#L&&this.#$?.(V,$,X),this.#Z&&this.#C?.push([V,$,X])}}if(this.#H.clear(),this.#J.fill(void 0),this.#z.fill(void 0),this.#_&&this.#F){this.#_.fill(0),this.#F.fill(0);for(let Z of this.#A??[])Z!==void 0&&clearTimeout(Z);this.#A?.fill(void 0)}if(this.#M&&this.#M.fill(0),this.#G=0,this.#U=0,this.#R.length=0,this.#j=0,this.#K=0,this.#Z&&this.#C){let Z=this.#C,V;for(;V=Z?.shift();)this.#q?.(...V)}}};import{posix as u7,win32 as H5}from"path";import{fileURLToPath as y7}from"url";import{lstatSync as f7,readdir as m7,readdirSync as h7,readlinkSync as g7,realpathSync as d7}from"fs";import*as c7 from"fs";import{lstat as i7,readdir as p7,readlink as o7,realpath as n7}from"fs/promises";import{EventEmitter as q5}from"events";import p5 from"stream";import{StringDecoder as R7}from"string_decoder";var d5=typeof process==="object"&&process?process:{stdout:null,stderr:null},I7=(Q)=>!!Q&&typeof Q==="object"&&(Q instanceof VQ||Q instanceof p5||x7(Q)||P7(Q)),x7=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof q5&&typeof Q.pipe==="function"&&Q.pipe!==p5.Writable.prototype.pipe,P7=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof q5&&typeof Q.write==="function"&&typeof Q.end==="function",r=Symbol("EOF"),s=Symbol("maybeEmitEnd"),QQ=Symbol("emittedEnd"),TQ=Symbol("emittingEnd"),CQ=Symbol("emittedError"),EQ=Symbol("closed"),c5=Symbol("read"),bQ=Symbol("flush"),l5=Symbol("flushChunk"),i=Symbol("encoding"),YQ=Symbol("decoder"),R=Symbol("flowing"),AQ=Symbol("paused"),HQ=Symbol("resume"),I=Symbol("buffer"),D=Symbol("pipes"),x=Symbol("bufferLength"),X5=Symbol("bufferPush"),uQ=Symbol("bufferShift"),P=Symbol("objectMode"),F=Symbol("destroyed"),Z5=Symbol("error"),V5=Symbol("emitData"),i5=Symbol("emitEnd"),$5=Symbol("emitEnd2"),o=Symbol("async"),J5=Symbol("abort"),yQ=Symbol("aborted"),BQ=Symbol("signal"),ZQ=Symbol("dataListeners"),y=Symbol("discarded"),wQ=(Q)=>Promise.resolve().then(Q),N7=(Q)=>Q(),D7=(Q)=>Q==="end"||Q==="finish"||Q==="prefinish",S7=(Q)=>Q instanceof ArrayBuffer||!!Q&&typeof Q==="object"&&Q.constructor&&Q.constructor.name==="ArrayBuffer"&&Q.byteLength>=0,T7=(Q)=>!Buffer.isBuffer(Q)&&ArrayBuffer.isView(Q);class K5{src;dest;opts;ondrain;constructor(Q,X,Z){this.src=Q,this.dest=X,this.opts=Z,this.ondrain=()=>Q[HQ](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(Q){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class o5 extends K5{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(Q,X,Z){super(Q,X,Z);this.proxyErrors=(V)=>this.dest.emit("error",V),Q.on("error",this.proxyErrors)}}var E7=(Q)=>!!Q.objectMode,b7=(Q)=>!Q.objectMode&&!!Q.encoding&&Q.encoding!=="buffer";class VQ extends q5{[R]=!1;[AQ]=!1;[D]=[];[I]=[];[P];[i];[o];[YQ];[r]=!1;[QQ]=!1;[TQ]=!1;[EQ]=!1;[CQ]=null;[x]=0;[F]=!1;[BQ];[yQ]=!1;[ZQ]=0;[y]=!1;writable=!0;readable=!0;constructor(...Q){let X=Q[0]||{};super();if(X.objectMode&&typeof X.encoding==="string")throw TypeError("Encoding and objectMode may not be used together");if(E7(X))this[P]=!0,this[i]=null;else if(b7(X))this[i]=X.encoding,this[P]=!1;else this[P]=!1,this[i]=null;if(this[o]=!!X.async,this[YQ]=this[i]?new R7(this[i]):null,X&&X.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[I]});if(X&&X.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[D]});let{signal:Z}=X;if(Z)if(this[BQ]=Z,Z.aborted)this[J5]();else Z.addEventListener("abort",()=>this[J5]())}get bufferLength(){return this[x]}get encoding(){return this[i]}set encoding(Q){throw Error("Encoding must be set at instantiation time")}setEncoding(Q){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[P]}set objectMode(Q){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[o]}set["async"](Q){this[o]=this[o]||!!Q}[J5](){this[yQ]=!0,this.emit("abort",this[BQ]?.reason),this.destroy(this[BQ]?.reason)}get aborted(){return this[yQ]}set aborted(Q){}write(Q,X,Z){if(this[yQ])return!1;if(this[r])throw Error("write after end");if(this[F])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof X==="function")Z=X,X="utf8";if(!X)X="utf8";let V=this[o]?wQ:N7;if(!this[P]&&!Buffer.isBuffer(Q)){if(T7(Q))Q=Buffer.from(Q.buffer,Q.byteOffset,Q.byteLength);else if(S7(Q))Q=Buffer.from(Q);else if(typeof Q!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[P]){if(this[R]&&this[x]!==0)this[bQ](!0);if(this[R])this.emit("data",Q);else this[X5](Q);if(this[x]!==0)this.emit("readable");if(Z)V(Z);return this[R]}if(!Q.length){if(this[x]!==0)this.emit("readable");if(Z)V(Z);return this[R]}if(typeof Q==="string"&&!(X===this[i]&&!this[YQ]?.lastNeed))Q=Buffer.from(Q,X);if(Buffer.isBuffer(Q)&&this[i])Q=this[YQ].write(Q);if(this[R]&&this[x]!==0)this[bQ](!0);if(this[R])this.emit("data",Q);else this[X5](Q);if(this[x]!==0)this.emit("readable");if(Z)V(Z);return this[R]}read(Q){if(this[F])return null;if(this[y]=!1,this[x]===0||Q===0||Q&&Q>this[x])return this[s](),null;if(this[P])Q=null;if(this[I].length>1&&!this[P])this[I]=[this[i]?this[I].join(""):Buffer.concat(this[I],this[x])];let X=this[c5](Q||null,this[I][0]);return this[s](),X}[c5](Q,X){if(this[P])this[uQ]();else{let Z=X;if(Q===Z.length||Q===null)this[uQ]();else if(typeof Z==="string")this[I][0]=Z.slice(Q),X=Z.slice(0,Q),this[x]-=Q;else this[I][0]=Z.subarray(Q),X=Z.subarray(0,Q),this[x]-=Q}if(this.emit("data",X),!this[I].length&&!this[r])this.emit("drain");return X}end(Q,X,Z){if(typeof Q==="function")Z=Q,Q=void 0;if(typeof X==="function")Z=X,X="utf8";if(Q!==void 0)this.write(Q,X);if(Z)this.once("end",Z);if(this[r]=!0,this.writable=!1,this[R]||!this[AQ])this[s]();return this}[HQ](){if(this[F])return;if(!this[ZQ]&&!this[D].length)this[y]=!0;if(this[AQ]=!1,this[R]=!0,this.emit("resume"),this[I].length)this[bQ]();else if(this[r])this[s]();else this.emit("drain")}resume(){return this[HQ]()}pause(){this[R]=!1,this[AQ]=!0,this[y]=!1}get destroyed(){return this[F]}get flowing(){return this[R]}get paused(){return this[AQ]}[X5](Q){if(this[P])this[x]+=1;else this[x]+=Q.length;this[I].push(Q)}[uQ](){if(this[P])this[x]-=1;else this[x]-=this[I][0].length;return this[I].shift()}[bQ](Q=!1){do;while(this[l5](this[uQ]())&&this[I].length);if(!Q&&!this[I].length&&!this[r])this.emit("drain")}[l5](Q){return this.emit("data",Q),this[R]}pipe(Q,X){if(this[F])return Q;this[y]=!1;let Z=this[QQ];if(X=X||{},Q===d5.stdout||Q===d5.stderr)X.end=!1;else X.end=X.end!==!1;if(X.proxyErrors=!!X.proxyErrors,Z){if(X.end)Q.end()}else if(this[D].push(!X.proxyErrors?new K5(this,Q,X):new o5(this,Q,X)),this[o])wQ(()=>this[HQ]());else this[HQ]();return Q}unpipe(Q){let X=this[D].find((Z)=>Z.dest===Q);if(X){if(this[D].length===1){if(this[R]&&this[ZQ]===0)this[R]=!1;this[D]=[]}else this[D].splice(this[D].indexOf(X),1);X.unpipe()}}addListener(Q,X){return this.on(Q,X)}on(Q,X){let Z=super.on(Q,X);if(Q==="data"){if(this[y]=!1,this[ZQ]++,!this[D].length&&!this[R])this[HQ]()}else if(Q==="readable"&&this[x]!==0)super.emit("readable");else if(D7(Q)&&this[QQ])super.emit(Q),this.removeAllListeners(Q);else if(Q==="error"&&this[CQ]){let V=X;if(this[o])wQ(()=>V.call(this,this[CQ]));else V.call(this,this[CQ])}return Z}removeListener(Q,X){return this.off(Q,X)}off(Q,X){let Z=super.off(Q,X);if(Q==="data"){if(this[ZQ]=this.listeners("data").length,this[ZQ]===0&&!this[y]&&!this[D].length)this[R]=!1}return Z}removeAllListeners(Q){let X=super.removeAllListeners(Q);if(Q==="data"||Q===void 0){if(this[ZQ]=0,!this[y]&&!this[D].length)this[R]=!1}return X}get emittedEnd(){return this[QQ]}[s](){if(!this[TQ]&&!this[QQ]&&!this[F]&&this[I].length===0&&this[r]){if(this[TQ]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[EQ])this.emit("close");this[TQ]=!1}}emit(Q,...X){let Z=X[0];if(Q!=="error"&&Q!=="close"&&Q!==F&&this[F])return!1;else if(Q==="data")return!this[P]&&!Z?!1:this[o]?(wQ(()=>this[V5](Z)),!0):this[V5](Z);else if(Q==="end")return this[i5]();else if(Q==="close"){if(this[EQ]=!0,!this[QQ]&&!this[F])return!1;let $=super.emit("close");return this.removeAllListeners("close"),$}else if(Q==="error"){this[CQ]=Z,super.emit(Z5,Z);let $=!this[BQ]||this.listeners("error").length?super.emit("error",Z):!1;return this[s](),$}else if(Q==="resume"){let $=super.emit("resume");return this[s](),$}else if(Q==="finish"||Q==="prefinish"){let $=super.emit(Q);return this.removeAllListeners(Q),$}let V=super.emit(Q,...X);return this[s](),V}[V5](Q){for(let Z of this[D])if(Z.dest.write(Q)===!1)this.pause();let X=this[y]?!1:super.emit("data",Q);return this[s](),X}[i5](){if(this[QQ])return!1;return this[QQ]=!0,this.readable=!1,this[o]?(wQ(()=>this[$5]()),!0):this[$5]()}[$5](){if(this[YQ]){let X=this[YQ].end();if(X){for(let Z of this[D])Z.dest.write(X);if(!this[y])super.emit("data",X)}}for(let X of this[D])X.end();let Q=super.emit("end");return this.removeAllListeners("end"),Q}async collect(){let Q=Object.assign([],{dataLength:0});if(!this[P])Q.dataLength=0;let X=this.promise();return this.on("data",(Z)=>{if(Q.push(Z),!this[P])Q.dataLength+=Z.length}),await X,Q}async concat(){if(this[P])throw Error("cannot concat in objectMode");let Q=await this.collect();return this[i]?Q.join(""):Buffer.concat(Q,Q.dataLength)}async promise(){return new Promise((Q,X)=>{this.on(F,()=>X(Error("stream destroyed"))),this.on("error",(Z)=>X(Z)),this.on("end",()=>Q())})}[Symbol.asyncIterator](){this[y]=!1;let Q=!1,X=async()=>{return this.pause(),Q=!0,{value:void 0,done:!0}};return{next:()=>{if(Q)return X();let V=this.read();if(V!==null)return Promise.resolve({done:!1,value:V});if(this[r])return X();let $,J,q=(W)=>{this.off("data",K),this.off("end",z),this.off(F,Y),X(),J(W)},K=(W)=>{this.off("error",q),this.off("end",z),this.off(F,Y),this.pause(),$({value:W,done:!!this[r]})},z=()=>{this.off("error",q),this.off("data",K),this.off(F,Y),X(),$({done:!0,value:void 0})},Y=()=>q(Error("stream destroyed"));return new Promise((W,H)=>{J=H,$=W,this.once(F,Y),this.once("error",q),this.once("end",z),this.once("data",K)})},throw:X,return:X,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[y]=!1;let Q=!1,X=()=>{return this.pause(),this.off(Z5,X),this.off(F,X),this.off("end",X),Q=!0,{done:!0,value:void 0}},Z=()=>{if(Q)return X();let V=this.read();return V===null?X():{done:!1,value:V}};return this.once("end",X),this.once(Z5,X),this.once(F,X),{next:Z,throw:X,return:X,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(Q){if(this[F]){if(Q)this.emit("error",Q);else this.emit(F);return this}this[F]=!0,this[y]=!0,this[I].length=0,this[x]=0;let X=this;if(typeof X.close==="function"&&!this[EQ])X.close();if(Q)this.emit("error",Q);else this.emit(F);return this}static get isStream(){return I7}}var l7=d7.native,vQ={lstatSync:f7,readdir:m7,readdirSync:h7,readlinkSync:g7,realpathSync:l7,promises:{lstat:i7,readdir:p7,readlink:o7,realpath:n7}},e5=(Q)=>!Q||Q===vQ||Q===c7?vQ:{...vQ,...Q,promises:{...vQ.promises,...Q.promises||{}}},t5=/^\\\\\?\\([a-z]:)\\?$/i,a7=(Q)=>Q.replace(/\//g,"\\").replace(t5,"$1\\"),r7=/[\\\/]/,d=0,Q6=1,X6=2,n=4,Z6=6,V6=8,$Q=10,$6=12,g=15,LQ=~g,z5=16,n5=32,MQ=64,p=128,fQ=256,hQ=512,a5=MQ|p|hQ,s7=1023,Y5=(Q)=>Q.isFile()?V6:Q.isDirectory()?n:Q.isSymbolicLink()?$Q:Q.isCharacterDevice()?X6:Q.isBlockDevice()?Z6:Q.isSocket()?$6:Q.isFIFO()?Q6:d,r5=new UQ({max:4096}),OQ=(Q)=>{let X=r5.get(Q);if(X)return X;let Z=Q.normalize("NFKD");return r5.set(Q,Z),Z},s5=new UQ({max:4096}),mQ=(Q)=>{let X=s5.get(Q);if(X)return X;let Z=OQ(Q.toLowerCase());return s5.set(Q,Z),Z};class W5 extends UQ{constructor(){super({max:256})}}class J6 extends UQ{constructor(Q=16384){super({maxSize:Q,sizeCalculation:(X)=>X.length+1})}}var q6=Symbol("PathScurry setAsCwd");class S{name;root;roots;parent;nocase;isCWD=!1;#Q;#V;get dev(){return this.#V}#$;get mode(){return this.#$}#X;get nlink(){return this.#X}#q;get uid(){return this.#q}#O;get gid(){return this.#O}#B;get rdev(){return this.#B}#W;get blksize(){return this.#W}#K;get ino(){return this.#K}#j;get size(){return this.#j}#H;get blocks(){return this.#H}#z;get atimeMs(){return this.#z}#J;get mtimeMs(){return this.#J}#w;get ctimeMs(){return this.#w}#v;get birthtimeMs(){return this.#v}#G;get atime(){return this.#G}#U;get mtime(){return this.#U}#R;get ctime(){return this.#R}#C;get birthtime(){return this.#C}#M;#F;#_;#A;#L;#I;#Z;#E;#S;#x;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Q,X=d,Z,V,$,J,q){if(this.name=Q,this.#M=$?mQ(Q):OQ(Q),this.#Z=X&s7,this.nocase=$,this.roots=V,this.root=Z||this,this.#E=J,this.#_=q.fullpath,this.#L=q.relative,this.#I=q.relativePosix,this.parent=q.parent,this.parent)this.#Q=this.parent.#Q;else this.#Q=e5(q.fs)}depth(){if(this.#F!==void 0)return this.#F;if(!this.parent)return this.#F=0;return this.#F=this.parent.depth()+1}childrenCache(){return this.#E}resolve(Q){if(!Q)return this;let X=this.getRootString(Q),V=Q.substring(X.length).split(this.splitSep);return X?this.getRoot(X).#T(V):this.#T(V)}#T(Q){let X=this;for(let Z of Q)X=X.child(Z);return X}children(){let Q=this.#E.get(this);if(Q)return Q;let X=Object.assign([],{provisional:0});return this.#E.set(this,X),this.#Z&=~z5,X}child(Q,X){if(Q===""||Q===".")return this;if(Q==="..")return this.parent||this;let Z=this.children(),V=this.nocase?mQ(Q):OQ(Q);for(let K of Z)if(K.#M===V)return K;let $=this.parent?this.sep:"",J=this.#_?this.#_+$+Q:void 0,q=this.newChild(Q,d,{...X,parent:this,fullpath:J});if(!this.canReaddir())q.#Z|=p;return Z.push(q),q}relative(){if(this.isCWD)return"";if(this.#L!==void 0)return this.#L;let Q=this.name,X=this.parent;if(!X)return this.#L=this.name;let Z=X.relative();return Z+(!Z||!X.parent?"":this.sep)+Q}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#I!==void 0)return this.#I;let Q=this.name,X=this.parent;if(!X)return this.#I=this.fullpathPosix();let Z=X.relativePosix();return Z+(!Z||!X.parent?"":"/")+Q}fullpath(){if(this.#_!==void 0)return this.#_;let Q=this.name,X=this.parent;if(!X)return this.#_=this.name;let V=X.fullpath()+(!X.parent?"":this.sep)+Q;return this.#_=V}fullpathPosix(){if(this.#A!==void 0)return this.#A;if(this.sep==="/")return this.#A=this.fullpath();if(!this.parent){let V=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(V))return this.#A=`//?/${V}`;else return this.#A=V}let Q=this.parent,X=Q.fullpathPosix(),Z=X+(!X||!Q.parent?"":"/")+this.name;return this.#A=Z}isUnknown(){return(this.#Z&g)===d}isType(Q){return this[`is${Q}`]()}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.#Z&g)===V6}isDirectory(){return(this.#Z&g)===n}isCharacterDevice(){return(this.#Z&g)===X6}isBlockDevice(){return(this.#Z&g)===Z6}isFIFO(){return(this.#Z&g)===Q6}isSocket(){return(this.#Z&g)===$6}isSymbolicLink(){return(this.#Z&$Q)===$Q}lstatCached(){return this.#Z&n5?this:void 0}readlinkCached(){return this.#S}realpathCached(){return this.#x}readdirCached(){let Q=this.children();return Q.slice(0,Q.provisional)}canReadlink(){if(this.#S)return!0;if(!this.parent)return!1;let Q=this.#Z&g;return!(Q!==d&&Q!==$Q||this.#Z&fQ||this.#Z&p)}calledReaddir(){return!!(this.#Z&z5)}isENOENT(){return!!(this.#Z&p)}isNamed(Q){return!this.nocase?this.#M===OQ(Q):this.#M===mQ(Q)}async readlink(){let Q=this.#S;if(Q)return Q;if(!this.canReadlink())return;if(!this.parent)return;try{let X=await this.#Q.promises.readlink(this.fullpath()),Z=(await this.parent.realpath())?.resolve(X);if(Z)return this.#S=Z}catch(X){this.#D(X.code);return}}readlinkSync(){let Q=this.#S;if(Q)return Q;if(!this.canReadlink())return;if(!this.parent)return;try{let X=this.#Q.readlinkSync(this.fullpath()),Z=this.parent.realpathSync()?.resolve(X);if(Z)return this.#S=Z}catch(X){this.#D(X.code);return}}#f(Q){this.#Z|=z5;for(let X=Q.provisional;X<Q.length;X++){let Z=Q[X];if(Z)Z.#k()}}#k(){if(this.#Z&p)return;this.#Z=(this.#Z|p)&LQ,this.#l()}#l(){let Q=this.children();Q.provisional=0;for(let X of Q)X.#k()}#y(){this.#Z|=hQ,this.#b()}#b(){if(this.#Z&MQ)return;let Q=this.#Z;if((Q&g)===n)Q&=LQ;this.#Z=Q|MQ,this.#l()}#m(Q=""){if(Q==="ENOTDIR"||Q==="EPERM")this.#b();else if(Q==="ENOENT")this.#k();else this.children().provisional=0}#N(Q=""){if(Q==="ENOTDIR")this.parent.#b();else if(Q==="ENOENT")this.#k()}#D(Q=""){let X=this.#Z;if(X|=fQ,Q==="ENOENT")X|=p;if(Q==="EINVAL"||Q==="UNKNOWN")X&=LQ;if(this.#Z=X,Q==="ENOTDIR"&&this.parent)this.parent.#b()}#h(Q,X){return this.#d(Q,X)||this.#g(Q,X)}#g(Q,X){let Z=Y5(Q),V=this.newChild(Q.name,Z,{parent:this}),$=V.#Z&g;if($!==n&&$!==$Q&&$!==d)V.#Z|=MQ;return X.unshift(V),X.provisional++,V}#d(Q,X){for(let Z=X.provisional;Z<X.length;Z++){let V=X[Z];if((this.nocase?mQ(Q.name):OQ(Q.name))!==V.#M)continue;return this.#Y(Q,V,Z,X)}}#Y(Q,X,Z,V){let $=X.name;if(X.#Z=X.#Z&LQ|Y5(Q),$!==Q.name)X.name=Q.name;if(Z!==V.provisional){if(Z===V.length-1)V.pop();else V.splice(Z,1);V.unshift(X)}return V.provisional++,X}async lstat(){if((this.#Z&p)===0)try{return this.#c(await this.#Q.promises.lstat(this.fullpath())),this}catch(Q){this.#N(Q.code)}}lstatSync(){if((this.#Z&p)===0)try{return this.#c(this.#Q.lstatSync(this.fullpath())),this}catch(Q){this.#N(Q.code)}}#c(Q){let{atime:X,atimeMs:Z,birthtime:V,birthtimeMs:$,blksize:J,blocks:q,ctime:K,ctimeMs:z,dev:Y,gid:W,ino:H,mode:_,mtime:j,mtimeMs:U,nlink:G,rdev:A,size:C,uid:B}=Q;this.#G=X,this.#z=Z,this.#C=V,this.#v=$,this.#W=J,this.#H=q,this.#R=K,this.#w=z,this.#V=Y,this.#O=W,this.#K=H,this.#$=_,this.#U=j,this.#J=U,this.#X=G,this.#B=A,this.#j=C,this.#q=B;let L=Y5(Q);if(this.#Z=this.#Z&LQ|L|n5,L!==d&&L!==n&&L!==$Q)this.#Z|=MQ}#u=[];#P=!1;#i(Q){this.#P=!1;let X=this.#u.slice();this.#u.length=0,X.forEach((Z)=>Z(null,Q))}readdirCB(Q,X=!1){if(!this.canReaddir()){if(X)Q(null,[]);else queueMicrotask(()=>Q(null,[]));return}let Z=this.children();if(this.calledReaddir()){let $=Z.slice(0,Z.provisional);if(X)Q(null,$);else queueMicrotask(()=>Q(null,$));return}if(this.#u.push(Q),this.#P)return;this.#P=!0;let V=this.fullpath();this.#Q.readdir(V,{withFileTypes:!0},($,J)=>{if($)this.#m($.code),Z.provisional=0;else{for(let q of J)this.#h(q,Z);this.#f(Z)}this.#i(Z.slice(0,Z.provisional));return})}#p;async readdir(){if(!this.canReaddir())return[];let Q=this.children();if(this.calledReaddir())return Q.slice(0,Q.provisional);let X=this.fullpath();if(this.#p)await this.#p;else{let Z=()=>{};this.#p=new Promise((V)=>Z=V);try{for(let V of await this.#Q.promises.readdir(X,{withFileTypes:!0}))this.#h(V,Q);this.#f(Q)}catch(V){this.#m(V.code),Q.provisional=0}this.#p=void 0,Z()}return Q.slice(0,Q.provisional)}readdirSync(){if(!this.canReaddir())return[];let Q=this.children();if(this.calledReaddir())return Q.slice(0,Q.provisional);let X=this.fullpath();try{for(let Z of this.#Q.readdirSync(X,{withFileTypes:!0}))this.#h(Z,Q);this.#f(Q)}catch(Z){this.#m(Z.code),Q.provisional=0}return Q.slice(0,Q.provisional)}canReaddir(){if(this.#Z&a5)return!1;let Q=g&this.#Z;if(!(Q===d||Q===n||Q===$Q))return!1;return!0}shouldWalk(Q,X){return(this.#Z&n)===n&&!(this.#Z&a5)&&!Q.has(this)&&(!X||X(this))}async realpath(){if(this.#x)return this.#x;if((hQ|fQ|p)&this.#Z)return;try{let Q=await this.#Q.promises.realpath(this.fullpath());return this.#x=this.resolve(Q)}catch(Q){this.#y()}}realpathSync(){if(this.#x)return this.#x;if((hQ|fQ|p)&this.#Z)return;try{let Q=this.#Q.realpathSync(this.fullpath());return this.#x=this.resolve(Q)}catch(Q){this.#y()}}[q6](Q){if(Q===this)return;Q.isCWD=!1,this.isCWD=!0;let X=new Set([]),Z=[],V=this;while(V&&V.parent)X.add(V),V.#L=Z.join(this.sep),V.#I=Z.join("/"),V=V.parent,Z.push("..");V=Q;while(V&&V.parent&&!X.has(V))V.#L=void 0,V.#I=void 0,V=V.parent}}class gQ extends S{sep="\\";splitSep=r7;constructor(Q,X=d,Z,V,$,J,q){super(Q,X,Z,V,$,J,q)}newChild(Q,X=d,Z={}){return new gQ(Q,X,this.root,this.roots,this.nocase,this.childrenCache(),Z)}getRootString(Q){return H5.parse(Q).root}getRoot(Q){if(Q=a7(Q.toUpperCase()),Q===this.root.name)return this.root;for(let[X,Z]of Object.entries(this.roots))if(this.sameRoot(Q,X))return this.roots[Q]=Z;return this.roots[Q]=new FQ(Q,this).root}sameRoot(Q,X=this.root.name){return Q=Q.toUpperCase().replace(/\//g,"\\").replace(t5,"$1\\"),Q===X}}class dQ extends S{splitSep="/";sep="/";constructor(Q,X=d,Z,V,$,J,q){super(Q,X,Z,V,$,J,q)}getRootString(Q){return Q.startsWith("/")?"/":""}getRoot(Q){return this.root}newChild(Q,X=d,Z={}){return new dQ(Q,X,this.root,this.roots,this.nocase,this.childrenCache(),Z)}}class j5{root;rootPath;roots;cwd;#Q;#V;#$;nocase;#X;constructor(Q=process.cwd(),X,Z,{nocase:V,childrenCacheSize:$=16384,fs:J=vQ}={}){if(this.#X=e5(J),Q instanceof URL||Q.startsWith("file://"))Q=y7(Q);let q=X.resolve(Q);this.roots=Object.create(null),this.rootPath=this.parseRootPath(q),this.#Q=new W5,this.#V=new W5,this.#$=new J6($);let K=q.substring(this.rootPath.length).split(Z);if(K.length===1&&!K[0])K.pop();if(V===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=V,this.root=this.newRoot(this.#X),this.roots[this.rootPath]=this.root;let z=this.root,Y=K.length-1,W=X.sep,H=this.rootPath,_=!1;for(let j of K){let U=Y--;z=z.child(j,{relative:Array(U).fill("..").join(W),relativePosix:Array(U).fill("..").join("/"),fullpath:H+=(_?"":W)+j}),_=!0}this.cwd=z}depth(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.depth()}childrenCache(){return this.#$}resolve(...Q){let X="";for(let $=Q.length-1;$>=0;$--){let J=Q[$];if(!J||J===".")continue;if(X=X?`${J}/${X}`:J,this.isAbsolute(J))break}let Z=this.#Q.get(X);if(Z!==void 0)return Z;let V=this.cwd.resolve(X).fullpath();return this.#Q.set(X,V),V}resolvePosix(...Q){let X="";for(let $=Q.length-1;$>=0;$--){let J=Q[$];if(!J||J===".")continue;if(X=X?`${J}/${X}`:J,this.isAbsolute(J))break}let Z=this.#V.get(X);if(Z!==void 0)return Z;let V=this.cwd.resolve(X).fullpathPosix();return this.#V.set(X,V),V}relative(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.relative()}relativePosix(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.relativePosix()}basename(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.name}dirname(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return(Q.parent||Q).fullpath()}async readdir(Q=this.cwd,X={withFileTypes:!0}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof S))X=Q,Q=this.cwd;let{withFileTypes:Z}=X;if(!Q.canReaddir())return[];else{let V=await Q.readdir();return Z?V:V.map(($)=>$.name)}}readdirSync(Q=this.cwd,X={withFileTypes:!0}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof S))X=Q,Q=this.cwd;let{withFileTypes:Z=!0}=X;if(!Q.canReaddir())return[];else if(Z)return Q.readdirSync();else return Q.readdirSync().map((V)=>V.name)}async lstat(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.lstat()}lstatSync(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.lstatSync()}async readlink(Q=this.cwd,{withFileTypes:X}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof S))X=Q.withFileTypes,Q=this.cwd;let Z=await Q.readlink();return X?Z:Z?.fullpath()}readlinkSync(Q=this.cwd,{withFileTypes:X}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof S))X=Q.withFileTypes,Q=this.cwd;let Z=Q.readlinkSync();return X?Z:Z?.fullpath()}async realpath(Q=this.cwd,{withFileTypes:X}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof S))X=Q.withFileTypes,Q=this.cwd;let Z=await Q.realpath();return X?Z:Z?.fullpath()}realpathSync(Q=this.cwd,{withFileTypes:X}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof S))X=Q.withFileTypes,Q=this.cwd;let Z=Q.realpathSync();return X?Z:Z?.fullpath()}async walk(Q=this.cwd,X={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof S))X=Q,Q=this.cwd;let{withFileTypes:Z=!0,follow:V=!1,filter:$,walkFilter:J}=X,q=[];if(!$||$(Q))q.push(Z?Q:Q.fullpath());let K=new Set,z=(W,H)=>{K.add(W),W.readdirCB((_,j)=>{if(_)return H(_);let U=j.length;if(!U)return H();let G=()=>{if(--U===0)H()};for(let A of j){if(!$||$(A))q.push(Z?A:A.fullpath());if(V&&A.isSymbolicLink())A.realpath().then((C)=>C?.isUnknown()?C.lstat():C).then((C)=>C?.shouldWalk(K,J)?z(C,G):G());else if(A.shouldWalk(K,J))z(A,G);else G()}},!0)},Y=Q;return new Promise((W,H)=>{z(Y,(_)=>{if(_)return H(_);W(q)})})}walkSync(Q=this.cwd,X={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof S))X=Q,Q=this.cwd;let{withFileTypes:Z=!0,follow:V=!1,filter:$,walkFilter:J}=X,q=[];if(!$||$(Q))q.push(Z?Q:Q.fullpath());let K=new Set([Q]);for(let z of K){let Y=z.readdirSync();for(let W of Y){if(!$||$(W))q.push(Z?W:W.fullpath());let H=W;if(W.isSymbolicLink()){if(!(V&&(H=W.realpathSync())))continue;if(H.isUnknown())H.lstatSync()}if(H.shouldWalk(K,J))K.add(H)}}return q}[Symbol.asyncIterator](){return this.iterate()}iterate(Q=this.cwd,X={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof S))X=Q,Q=this.cwd;return this.stream(Q,X)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(Q=this.cwd,X={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof S))X=Q,Q=this.cwd;let{withFileTypes:Z=!0,follow:V=!1,filter:$,walkFilter:J}=X;if(!$||$(Q))yield Z?Q:Q.fullpath();let q=new Set([Q]);for(let K of q){let z=K.readdirSync();for(let Y of z){if(!$||$(Y))yield Z?Y:Y.fullpath();let W=Y;if(Y.isSymbolicLink()){if(!(V&&(W=Y.realpathSync())))continue;if(W.isUnknown())W.lstatSync()}if(W.shouldWalk(q,J))q.add(W)}}}stream(Q=this.cwd,X={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof S))X=Q,Q=this.cwd;let{withFileTypes:Z=!0,follow:V=!1,filter:$,walkFilter:J}=X,q=new VQ({objectMode:!0});if(!$||$(Q))q.write(Z?Q:Q.fullpath());let K=new Set,z=[Q],Y=0,W=()=>{let H=!1;while(!H){let _=z.shift();if(!_){if(Y===0)q.end();return}Y++,K.add(_);let j=(G,A,C=!1)=>{if(G)return q.emit("error",G);if(V&&!C){let B=[];for(let L of A)if(L.isSymbolicLink())B.push(L.realpath().then((v)=>v?.isUnknown()?v.lstat():v));if(B.length){Promise.all(B).then(()=>j(null,A,!0));return}}for(let B of A)if(B&&(!$||$(B))){if(!q.write(Z?B:B.fullpath()))H=!0}Y--;for(let B of A){let L=B.realpathCached()||B;if(L.shouldWalk(K,J))z.push(L)}if(H&&!q.flowing)q.once("drain",W);else if(!U)W()},U=!0;_.readdirCB(j,!0),U=!1}};return W(),q}streamSync(Q=this.cwd,X={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof S))X=Q,Q=this.cwd;let{withFileTypes:Z=!0,follow:V=!1,filter:$,walkFilter:J}=X,q=new VQ({objectMode:!0}),K=new Set;if(!$||$(Q))q.write(Z?Q:Q.fullpath());let z=[Q],Y=0,W=()=>{let H=!1;while(!H){let _=z.shift();if(!_){if(Y===0)q.end();return}Y++,K.add(_);let j=_.readdirSync();for(let U of j)if(!$||$(U)){if(!q.write(Z?U:U.fullpath()))H=!0}Y--;for(let U of j){let G=U;if(U.isSymbolicLink()){if(!(V&&(G=U.realpathSync())))continue;if(G.isUnknown())G.lstatSync()}if(G.shouldWalk(K,J))z.push(G)}}if(H&&!q.flowing)q.once("drain",W)};return W(),q}chdir(Q=this.cwd){let X=this.cwd;this.cwd=typeof Q==="string"?this.cwd.resolve(Q):Q,this.cwd[q6](X)}}class FQ extends j5{sep="\\";constructor(Q=process.cwd(),X={}){let{nocase:Z=!0}=X;super(Q,H5,"\\",{...X,nocase:Z});this.nocase=Z;for(let V=this.cwd;V;V=V.parent)V.nocase=this.nocase}parseRootPath(Q){return H5.parse(Q).root.toUpperCase()}newRoot(Q){return new gQ(this.rootPath,n,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Q})}isAbsolute(Q){return Q.startsWith("/")||Q.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Q)}}class kQ extends j5{sep="/";constructor(Q=process.cwd(),X={}){let{nocase:Z=!1}=X;super(Q,u7,"/",{...X,nocase:Z});this.nocase=Z}parseRootPath(Q){return"/"}newRoot(Q){return new dQ(this.rootPath,n,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Q})}isAbsolute(Q){return Q.startsWith("/")}}class cQ extends kQ{constructor(Q=process.cwd(),X={}){let{nocase:Z=!0}=X;super(Q,{...X,nocase:Z})}}var A9=process.platform==="win32"?gQ:dQ,K6=process.platform==="win32"?FQ:process.platform==="darwin"?cQ:kQ;var e7=(Q)=>Q.length>=1,t7=(Q)=>Q.length>=1;class WQ{#Q;#V;#$;length;#X;#q;#O;#B;#W;#K;#j=!0;constructor(Q,X,Z,V){if(!e7(Q))throw TypeError("empty pattern list");if(!t7(X))throw TypeError("empty glob list");if(X.length!==Q.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=Q.length,Z<0||Z>=this.length)throw TypeError("index out of range");if(this.#Q=Q,this.#V=X,this.#$=Z,this.#X=V,this.#$===0){if(this.isUNC()){let[$,J,q,K,...z]=this.#Q,[Y,W,H,_,...j]=this.#V;if(z[0]==="")z.shift(),j.shift();let U=[$,J,q,K,""].join("/"),G=[Y,W,H,_,""].join("/");this.#Q=[U,...z],this.#V=[G,...j],this.length=this.#Q.length}else if(this.isDrive()||this.isAbsolute()){let[$,...J]=this.#Q,[q,...K]=this.#V;if(J[0]==="")J.shift(),K.shift();let z=$+"/",Y=q+"/";this.#Q=[z,...J],this.#V=[Y,...K],this.length=this.#Q.length}}}pattern(){return this.#Q[this.#$]}isString(){return typeof this.#Q[this.#$]==="string"}isGlobstar(){return this.#Q[this.#$]===O}isRegExp(){return this.#Q[this.#$]instanceof RegExp}globString(){return this.#O=this.#O||(this.#$===0?this.isAbsolute()?this.#V[0]+this.#V.slice(1).join("/"):this.#V.join("/"):this.#V.slice(this.#$).join("/"))}hasMore(){return this.length>this.#$+1}rest(){if(this.#q!==void 0)return this.#q;if(!this.hasMore())return this.#q=null;return this.#q=new WQ(this.#Q,this.#V,this.#$+1,this.#X),this.#q.#K=this.#K,this.#q.#W=this.#W,this.#q.#B=this.#B,this.#q}isUNC(){let Q=this.#Q;return this.#W!==void 0?this.#W:this.#W=this.#X==="win32"&&this.#$===0&&Q[0]===""&&Q[1]===""&&typeof Q[2]==="string"&&!!Q[2]&&typeof Q[3]==="string"&&!!Q[3]}isDrive(){let Q=this.#Q;return this.#B!==void 0?this.#B:this.#B=this.#X==="win32"&&this.#$===0&&this.length>1&&typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0])}isAbsolute(){let Q=this.#Q;return this.#K!==void 0?this.#K:this.#K=Q[0]===""&&Q.length>1||this.isDrive()||this.isUNC()}root(){let Q=this.#Q[0];return typeof Q==="string"&&this.isAbsolute()&&this.#$===0?Q:""}checkFollowGlobstar(){return!(this.#$===0||!this.isGlobstar()||!this.#j)}markFollowGlobstar(){if(this.#$===0||!this.isGlobstar()||!this.#j)return!1;return this.#j=!1,!0}}var Q8=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class RQ{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Q,{nobrace:X,nocase:Z,noext:V,noglobstar:$,platform:J=Q8}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=J,this.mmopts={dot:!0,nobrace:X,nocase:Z,noext:V,noglobstar:$,optimizationLevel:2,platform:J,nocomment:!0,nonegate:!0};for(let q of Q)this.add(q)}add(Q){let X=new h(Q,this.mmopts);for(let Z=0;Z<X.set.length;Z++){let V=X.set[Z],$=X.globParts[Z];if(!V||!$)throw Error("invalid pattern object");while(V[0]==="."&&$[0]===".")V.shift(),$.shift();let J=new WQ(V,$,0,this.platform),q=new h(J.globString(),this.mmopts),K=$[$.length-1]==="**",z=J.isAbsolute();if(z)this.absolute.push(q);else this.relative.push(q);if(K)if(z)this.absoluteChildren.push(q);else this.relativeChildren.push(q)}}ignored(Q){let X=Q.fullpath(),Z=`${X}/`,V=Q.relative()||".",$=`${V}/`;for(let J of this.relative)if(J.match(V)||J.match($))return!0;for(let J of this.absolute)if(J.match(X)||J.match(Z))return!0;return!1}childrenIgnored(Q){let X=Q.fullpath()+"/",Z=(Q.relative()||".")+"/";for(let V of this.relativeChildren)if(V.match(Z))return!0;for(let V of this.absoluteChildren)if(V.match(X))return!0;return!1}}class _5{store;constructor(Q=new Map){this.store=Q}copy(){return new _5(new Map(this.store))}hasWalked(Q,X){return this.store.get(Q.fullpath())?.has(X.globString())}storeWalked(Q,X){let Z=Q.fullpath(),V=this.store.get(Z);if(V)V.add(X.globString());else this.store.set(Z,new Set([X.globString()]))}}class z6{store=new Map;add(Q,X,Z){let V=(X?2:0)|(Z?1:0),$=this.store.get(Q);this.store.set(Q,$===void 0?V:V&$)}entries(){return[...this.store.entries()].map(([Q,X])=>[Q,!!(X&2),!!(X&1)])}}class Y6{store=new Map;add(Q,X){if(!Q.canReaddir())return;let Z=this.store.get(Q);if(Z){if(!Z.find((V)=>V.globString()===X.globString()))Z.push(X)}else this.store.set(Q,[X])}get(Q){let X=this.store.get(Q);if(!X)throw Error("attempting to walk unknown path");return X}entries(){return this.keys().map((Q)=>[Q,this.store.get(Q)])}keys(){return[...this.store.keys()].filter((Q)=>Q.canReaddir())}}class IQ{hasWalkedCache;matches=new z6;subwalks=new Y6;patterns;follow;dot;opts;constructor(Q,X){this.opts=Q,this.follow=!!Q.follow,this.dot=!!Q.dot,this.hasWalkedCache=X?X.copy():new _5}processPatterns(Q,X){this.patterns=X;let Z=X.map((V)=>[Q,V]);for(let[V,$]of Z){this.hasWalkedCache.storeWalked(V,$);let J=$.root(),q=$.isAbsolute()&&this.opts.absolute!==!1;if(J){V=V.resolve(J==="/"&&this.opts.root!==void 0?this.opts.root:J);let W=$.rest();if(!W){this.matches.add(V,!0,!1);continue}else $=W}if(V.isENOENT())continue;let K,z,Y=!1;while(typeof(K=$.pattern())==="string"&&(z=$.rest()))V=V.resolve(K),$=z,Y=!0;if(K=$.pattern(),z=$.rest(),Y){if(this.hasWalkedCache.hasWalked(V,$))continue;this.hasWalkedCache.storeWalked(V,$)}if(typeof K==="string"){let W=K===".."||K===""||K===".";this.matches.add(V.resolve(K),q,W);continue}else if(K===O){if(!V.isSymbolicLink()||this.follow||$.checkFollowGlobstar())this.subwalks.add(V,$);let W=z?.pattern(),H=z?.rest();if(!z||(W===""||W===".")&&!H)this.matches.add(V,q,W===""||W===".");else if(W===".."){let _=V.parent||V;if(!H)this.matches.add(_,q,!0);else if(!this.hasWalkedCache.hasWalked(_,H))this.subwalks.add(_,H)}}else if(K instanceof RegExp)this.subwalks.add(V,$)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new IQ(this.opts,this.hasWalkedCache)}filterEntries(Q,X){let Z=this.subwalks.get(Q),V=this.child();for(let $ of X)for(let J of Z){let q=J.isAbsolute(),K=J.pattern(),z=J.rest();if(K===O)V.testGlobstar($,J,z,q);else if(K instanceof RegExp)V.testRegExp($,K,z,q);else V.testString($,K,z,q)}return V}testGlobstar(Q,X,Z,V){if(this.dot||!Q.name.startsWith(".")){if(!X.hasMore())this.matches.add(Q,V,!1);if(Q.canReaddir()){if(this.follow||!Q.isSymbolicLink())this.subwalks.add(Q,X);else if(Q.isSymbolicLink()){if(Z&&X.checkFollowGlobstar())this.subwalks.add(Q,Z);else if(X.markFollowGlobstar())this.subwalks.add(Q,X)}}}if(Z){let $=Z.pattern();if(typeof $==="string"&&$!==".."&&$!==""&&$!==".")this.testString(Q,$,Z.rest(),V);else if($===".."){let J=Q.parent||Q;this.subwalks.add(J,Z)}else if($ instanceof RegExp)this.testRegExp(Q,$,Z.rest(),V)}}testRegExp(Q,X,Z,V){if(!X.test(Q.name))return;if(!Z)this.matches.add(Q,V,!1);else this.subwalks.add(Q,Z)}testString(Q,X,Z,V){if(!Q.isNamed(X))return;if(!Z)this.matches.add(Q,V,!1);else this.subwalks.add(Q,Z)}}var X8=(Q,X)=>typeof Q==="string"?new RQ([Q],X):Array.isArray(Q)?new RQ(Q,X):Q;class G5{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Q=[];#V;#$;signal;maxDepth;includeChildMatches;constructor(Q,X,Z){if(this.patterns=Q,this.path=X,this.opts=Z,this.#$=!Z.posix&&Z.platform==="win32"?"\\":"/",this.includeChildMatches=Z.includeChildMatches!==!1,Z.ignore||!this.includeChildMatches){if(this.#V=X8(Z.ignore??[],Z),!this.includeChildMatches&&typeof this.#V.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=Z.maxDepth||1/0,Z.signal)this.signal=Z.signal,this.signal.addEventListener("abort",()=>{this.#Q.length=0})}#X(Q){return this.seen.has(Q)||!!this.#V?.ignored?.(Q)}#q(Q){return!!this.#V?.childrenIgnored?.(Q)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let Q=void 0;while(!this.paused&&(Q=this.#Q.shift()))Q()}onResume(Q){if(this.signal?.aborted)return;if(!this.paused)Q();else this.#Q.push(Q)}async matchCheck(Q,X){if(X&&this.opts.nodir)return;let Z;if(this.opts.realpath){if(Z=Q.realpathCached()||await Q.realpath(),!Z)return;Q=Z}let $=Q.isUnknown()||this.opts.stat?await Q.lstat():Q;if(this.opts.follow&&this.opts.nodir&&$?.isSymbolicLink()){let J=await $.realpath();if(J&&(J.isUnknown()||this.opts.stat))await J.lstat()}return this.matchCheckTest($,X)}matchCheckTest(Q,X){return Q&&(this.maxDepth===1/0||Q.depth()<=this.maxDepth)&&(!X||Q.canReaddir())&&(!this.opts.nodir||!Q.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!Q.isSymbolicLink()||!Q.realpathCached()?.isDirectory())&&!this.#X(Q)?Q:void 0}matchCheckSync(Q,X){if(X&&this.opts.nodir)return;let Z;if(this.opts.realpath){if(Z=Q.realpathCached()||Q.realpathSync(),!Z)return;Q=Z}let $=Q.isUnknown()||this.opts.stat?Q.lstatSync():Q;if(this.opts.follow&&this.opts.nodir&&$?.isSymbolicLink()){let J=$.realpathSync();if(J&&(J?.isUnknown()||this.opts.stat))J.lstatSync()}return this.matchCheckTest($,X)}matchFinish(Q,X){if(this.#X(Q))return;if(!this.includeChildMatches&&this.#V?.add){let $=`${Q.relativePosix()}/**`;this.#V.add($)}let Z=this.opts.absolute===void 0?X:this.opts.absolute;this.seen.add(Q);let V=this.opts.mark&&Q.isDirectory()?this.#$:"";if(this.opts.withFileTypes)this.matchEmit(Q);else if(Z){let $=this.opts.posix?Q.fullpathPosix():Q.fullpath();this.matchEmit($+V)}else{let $=this.opts.posix?Q.relativePosix():Q.relative(),J=this.opts.dotRelative&&!$.startsWith(".."+this.#$)?"."+this.#$:"";this.matchEmit(!$?"."+V:J+$+V)}}async match(Q,X,Z){let V=await this.matchCheck(Q,Z);if(V)this.matchFinish(V,X)}matchSync(Q,X,Z){let V=this.matchCheckSync(Q,Z);if(V)this.matchFinish(V,X)}walkCB(Q,X,Z){if(this.signal?.aborted)Z();this.walkCB2(Q,X,new IQ(this.opts),Z)}walkCB2(Q,X,Z,V){if(this.#q(Q))return V();if(this.signal?.aborted)V();if(this.paused){this.onResume(()=>this.walkCB2(Q,X,Z,V));return}Z.processPatterns(Q,X);let $=1,J=()=>{if(--$===0)V()};for(let[q,K,z]of Z.matches.entries()){if(this.#X(q))continue;$++,this.match(q,K,z).then(()=>J())}for(let q of Z.subwalkTargets()){if(this.maxDepth!==1/0&&q.depth()>=this.maxDepth)continue;$++;let K=q.readdirCached();if(q.calledReaddir())this.walkCB3(q,K,Z,J);else q.readdirCB((z,Y)=>this.walkCB3(q,Y,Z,J),!0)}J()}walkCB3(Q,X,Z,V){Z=Z.filterEntries(Q,X);let $=1,J=()=>{if(--$===0)V()};for(let[q,K,z]of Z.matches.entries()){if(this.#X(q))continue;$++,this.match(q,K,z).then(()=>J())}for(let[q,K]of Z.subwalks.entries())$++,this.walkCB2(q,K,Z.child(),J);J()}walkCBSync(Q,X,Z){if(this.signal?.aborted)Z();this.walkCB2Sync(Q,X,new IQ(this.opts),Z)}walkCB2Sync(Q,X,Z,V){if(this.#q(Q))return V();if(this.signal?.aborted)V();if(this.paused){this.onResume(()=>this.walkCB2Sync(Q,X,Z,V));return}Z.processPatterns(Q,X);let $=1,J=()=>{if(--$===0)V()};for(let[q,K,z]of Z.matches.entries()){if(this.#X(q))continue;this.matchSync(q,K,z)}for(let q of Z.subwalkTargets()){if(this.maxDepth!==1/0&&q.depth()>=this.maxDepth)continue;$++;let K=q.readdirSync();this.walkCB3Sync(q,K,Z,J)}J()}walkCB3Sync(Q,X,Z,V){Z=Z.filterEntries(Q,X);let $=1,J=()=>{if(--$===0)V()};for(let[q,K,z]of Z.matches.entries()){if(this.#X(q))continue;this.matchSync(q,K,z)}for(let[q,K]of Z.subwalks.entries())$++,this.walkCB2Sync(q,K,Z.child(),J);J()}}class lQ extends G5{matches=new Set;constructor(Q,X,Z){super(Q,X,Z)}matchEmit(Q){this.matches.add(Q)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise((Q,X)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)X(this.signal.reason);else Q(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 iQ extends G5{results;constructor(Q,X,Z){super(Q,X,Z);this.results=new VQ({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(Q){if(this.results.write(Q),!this.results.flowing)this.pause()}stream(){let Q=this.path;if(Q.isUnknown())Q.lstat().then(()=>{this.walkCB(Q,this.patterns,()=>this.results.end())});else this.walkCB(Q,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 V8=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class a{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,X){if(!X)throw TypeError("glob options required");if(this.withFileTypes=!!X.withFileTypes,this.signal=X.signal,this.follow=!!X.follow,this.dot=!!X.dot,this.dotRelative=!!X.dotRelative,this.nodir=!!X.nodir,this.mark=!!X.mark,!X.cwd)this.cwd="";else if(X.cwd instanceof URL||X.cwd.startsWith("file://"))X.cwd=Z8(X.cwd);if(this.cwd=X.cwd||"",this.root=X.root,this.magicalBraces=!!X.magicalBraces,this.nobrace=!!X.nobrace,this.noext=!!X.noext,this.realpath=!!X.realpath,this.absolute=X.absolute,this.includeChildMatches=X.includeChildMatches!==!1,this.noglobstar=!!X.noglobstar,this.matchBase=!!X.matchBase,this.maxDepth=typeof X.maxDepth==="number"?X.maxDepth:1/0,this.stat=!!X.stat,this.ignore=X.ignore,this.withFileTypes&&this.absolute!==void 0)throw Error("cannot set absolute and withFileTypes:true");if(typeof Q==="string")Q=[Q];if(this.windowsPathsNoEscape=!!X.windowsPathsNoEscape||X.allowWindowsEscape===!1,this.windowsPathsNoEscape)Q=Q.map((K)=>K.replace(/\\/g,"/"));if(this.matchBase){if(X.noglobstar)throw TypeError("base matching requires globstar");Q=Q.map((K)=>K.includes("/")?K:`./**/${K}`)}if(this.pattern=Q,this.platform=X.platform||V8,this.opts={...X,platform:this.platform},X.scurry){if(this.scurry=X.scurry,X.nocase!==void 0&&X.nocase!==X.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let K=X.platform==="win32"?FQ:X.platform==="darwin"?cQ:X.platform?kQ:K6;this.scurry=new K(this.cwd,{nocase:X.nocase,fs:X.fs})}this.nocase=this.scurry.nocase;let Z=this.platform==="darwin"||this.platform==="win32",V={...X,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:Z,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},$=this.pattern.map((K)=>new h(K,V)),[J,q]=$.reduce((K,z)=>{return K[0].push(...z.set),K[1].push(...z.globParts),K},[[],[]]);this.patterns=J.map((K,z)=>{let Y=q[z];if(!Y)throw Error("invalid pattern object");return new WQ(K,Y,0,this.platform)})}async walk(){return[...await new lQ(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 lQ(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 iQ(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 iQ(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 U5=(Q,X={})=>{if(!Array.isArray(Q))Q=[Q];for(let Z of Q)if(new h(Z,X).hasMagic())return!0;return!1};function oQ(Q,X={}){return new a(Q,X).streamSync()}function W6(Q,X={}){return new a(Q,X).stream()}function j6(Q,X={}){return new a(Q,X).walkSync()}async function H6(Q,X={}){return new a(Q,X).walk()}function nQ(Q,X={}){return new a(Q,X).iterateSync()}function _6(Q,X={}){return new a(Q,X).iterate()}var $8=oQ,J8=Object.assign(W6,{sync:oQ}),q8=nQ,K8=Object.assign(_6,{sync:nQ}),z8=Object.assign(j6,{stream:oQ,iterate:nQ}),pQ=Object.assign(H6,{glob:H6,globSync:j6,sync:z8,globStream:W6,stream:J8,globStreamSync:oQ,streamSync:$8,globIterate:_6,iterate:K8,globIterateSync:nQ,iterateSync:q8,Glob:a,hasMagic:U5,escape:zQ,unescape:l});pQ.glob=pQ;var Y8={name:"Read",description:"Reads a file from the local filesystem. You can access any file directly by using this tool.",input_schema:{type:"object",properties:{file_path:{type:"string",description:"The absolute path to the file to read"},offset:{type:"number",description:"The line number to start reading from (1-based)"},limit:{type:"number",description:"The number of lines to read"}},required:["file_path"]},handler:async(Q,X)=>{let Z=Q.file_path,V=Q.offset||1,$=Q.limit||2000;try{let K=(await Bun.file(Z).text()).split(`
4
- `),z=Math.max(0,V-1),Y=Math.min(K.length,z+$);return{content:K.slice(z,Y).map((_,j)=>`${z+j+1} ${_}`).join(`
5
- `)}}catch(J){return{content:`Error reading file: ${J instanceof Error?J.message:String(J)}`,is_error:!0}}}},H8={name:"Write",description:"Writes a file to the local filesystem. This tool will overwrite the existing file if there is one at the provided path.",input_schema:{type:"object",properties:{file_path:{type:"string",description:"The absolute path to the file to write"},content:{type:"string",description:"The content to write to the file"}},required:["file_path","content"]},handler:async(Q,X)=>{let{file_path:Z,content:V}=Q;try{return await Bun.write(Z,V),{content:`Successfully wrote to ${Z}`}}catch($){return{content:`Error writing file: ${$ instanceof Error?$.message:String($)}`,is_error:!0}}}},W8={name:"Edit",description:"Performs exact string replacements in files. Use this tool to modify existing files.",input_schema:{type:"object",properties:{file_path:{type:"string",description:"The absolute path to the file to modify"},old_string:{type:"string",description:"The text to replace"},new_string:{type:"string",description:"The text to replace it with"},replace_all:{type:"boolean",description:"Replace all occurrences (default false)"}},required:["file_path","old_string","new_string"]},handler:async(Q,X)=>{let{file_path:Z,old_string:V,new_string:$}=Q,J=Q.replace_all||!1;try{let K=await Bun.file(Z).text();if(J){let z=K;K=K.split(V).join($);let Y=(z.match(new RegExp(j8(V),"g"))||[]).length;if(Y===0)return{content:"Error: String not found in file",is_error:!0};return await Bun.write(Z,K),{content:`Successfully replaced ${Y} occurrences`}}else{let z=K.indexOf(V);if(z===-1)return{content:"Error: String not found in file",is_error:!0};if(K.indexOf(V,z+1)!==-1)return{content:"Error: String appears multiple times in file. Use replace_all or provide more context.",is_error:!0};return K=K.replace(V,$),await Bun.write(Z,K),{content:`Successfully edited ${Z}`}}}catch(q){return{content:`Error editing file: ${q instanceof Error?q.message:String(q)}`,is_error:!0}}}};function j8(Q){return Q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var _8={name:"Bash",description:"Executes a given bash command with optional timeout. Working directory persists between commands.",input_schema:{type:"object",properties:{command:{type:"string",description:"The command to execute"},timeout:{type:"number",description:"Optional timeout in milliseconds (max 600000)"},description:{type:"string",description:"Clear, concise description of what this command does"}},required:["command"]},handler:async(Q,X)=>{let Z=Q.command,V=Q.timeout||120000;try{let $=Bun.spawnSync(["sh","-c",Z],{cwd:X.workingDirectory,timeout:V,maxBuffer:31457280}),J=$.stdout?.toString()||"",q=$.stderr?.toString()||"";if($.exitCode!==0)return{content:`Exit code: ${$.exitCode}
6
- ${J}
7
- ${q}`.trim(),is_error:!0};return{content:J||"(no output)"}}catch($){return{content:`Error executing command: ${$ instanceof Error?$.message:String($)}`,is_error:!0}}}},G8={name:"Glob",description:"Fast file pattern matching tool that works with any codebase size. Supports glob patterns.",input_schema:{type:"object",properties:{pattern:{type:"string",description:"The glob pattern to match files"},path:{type:"string",description:"The directory to search (default: current directory)"}},required:["pattern"]},handler:async(Q,X)=>{let Z=Q.pattern,V=Q.path||X.workingDirectory;try{let $=await pQ(Z,{cwd:V,absolute:!0,nodir:!0});if($.length===0)return{content:"No files found matching pattern"};return{content:$.sort().join(`
8
- `)}}catch($){return{content:`Error searching files: ${$ instanceof Error?$.message:String($)}`,is_error:!0}}}},U8={name:"Grep",description:"A powerful search tool built on ripgrep. Supports full regex syntax.",input_schema:{type:"object",properties:{pattern:{type:"string",description:"The regular expression pattern to search for"},path:{type:"string",description:"File or directory to search"},glob:{type:"string",description:"Glob pattern to filter files"},output_mode:{type:"string",enum:["content","files_with_matches","count"],description:"Output mode (default: content)"},"-i:":{type:"boolean",description:"Case insensitive search"},"-C:":{type:"number",description:"Context lines around match"},head_limit:{type:"number",description:"Maximum number of results"}},required:["pattern"]},handler:async(Q,X)=>{let Z=Q.pattern,V=Q.path||X.workingDirectory,$=Q.glob,J=Q.output_mode||"content",q=Q["-i:"],K=Q["-C:"],z=Q.head_limit;try{let Y=["--json"];if(q)Y.push("-i");if(K)Y.push("-C",String(K));if($)Y.push("--glob",$);if(J==="files_with_matches")Y.push("--files-with-matches");if(J==="count")Y.push("--count");Y.push(Z,V);let H=Bun.spawnSync(["rg",...Y],{cwd:X.workingDirectory,maxBuffer:10485760}).stdout?.toString()||"";if(!H.trim())return{content:"No matches found"};if(J==="content"){let _=H.trim().split(`
9
- `),j=[];for(let U of _.slice(0,z||100))try{let G=JSON.parse(U);if(G.type==="match"){let A=G.data?.path?.text||"",C=G.data?.line_number||0,B=G.data?.lines?.text||"";j.push(`${A}:${C}:${B.trim()}`)}}catch{j.push(U)}return{content:j.join(`
10
- `)||"No matches found"}}return{content:H.trim()}}catch(Y){return{content:`Error searching: ${Y instanceof Error?Y.message:String(Y)}`,is_error:!0}}}},C8=[Y8,H8,W8,_8,G8,U8];function o9(Q){return C8.find((X)=>X.name===Q)}import{spawn as A8}from"child_process";class B8{hooks=new Map;timeout;constructor(Q=60000){this.timeout=Q}register(Q,X){if(!this.hooks.has(Q))this.hooks.set(Q,[]);this.hooks.get(Q)?.push(X)}registerAll(Q){for(let[X,Z]of Object.entries(Q))for(let V of Z)this.register(X,V)}async execute(Q,X){let Z=this.hooks.get(Q);if(!Z||Z.length===0)return{decision:"allow"};let V={...X,event:Q,timestamp:Date.now()};for(let $ of Z){if($.enabled===!1)continue;let J=await this.executeHook($,V);if(J.decision==="deny"||J.decision==="block")return J;if(J.modified_input)Object.assign(X,J.modified_input)}return{decision:"allow"}}async executeHook(Q,X){let Z=Q.timeout||this.timeout;try{return await new Promise(($,J)=>{let q=A8(Q.command,[],{shell:!0,stdio:["pipe","pipe","pipe"]}),K="",z="";q.stdout?.on("data",(Y)=>{K+=Y.toString()}),q.stderr?.on("data",(Y)=>{z+=Y.toString()}),q.on("close",(Y)=>{if(Y===0)try{let W=JSON.parse(K);$(W)}catch{$({decision:"allow"})}else if(Y===1)$({decision:"deny",reason:z||"Hook denied execution"});else if(Y===2)$({decision:"block",reason:z||"Hook blocked execution"});else $({decision:"allow"})}),q.on("error",(Y)=>{$({decision:"allow",reason:`Hook error: ${Y.message}`})}),q.stdin?.write(JSON.stringify(X)),q.stdin?.end(),setTimeout(()=>{q.kill(),$({decision:"allow",reason:"Hook timeout"})},Z)})}catch(V){return{decision:"allow",reason:`Hook execution failed: ${V instanceof Error?V.message:String(V)}`}}}getHooks(Q){return this.hooks.get(Q)||[]}clear(Q){if(Q)this.hooks.delete(Q);else this.hooks.clear()}}var r9={validateWrite:{event:"PreToolUse",command:`node -e '
11
- const input = JSON.parse(require("fs").readFileSync(0, "utf8"));
12
- if (input.tool_name === "Write") {
13
- const path = input.tool_input.file_path;
14
- if (path.includes("..") || path.startsWith("/etc/")) {
15
- console.log(JSON.stringify({ decision: "deny", reason: "Unsafe path" }));
16
- process.exit(1);
17
- }
18
- }
19
- console.log(JSON.stringify({ decision: "allow" }));
20
- '`,timeout:5000,enabled:!1},logToolUse:{event:"PostToolUse",command:`node -e '
21
- const input = JSON.parse(require("fs").readFileSync(0, "utf8"));
22
- console.error(\`[LOG] Tool: \${input.tool_name}\`);
23
- console.log(JSON.stringify({ decision: "allow" }));
24
- '`,timeout:5000,enabled:!1}},s9={PreToolUse:"Before a tool is executed. Can modify input or deny execution.",PostToolUse:"After a tool successfully executes. Can process result.",PostToolUseFailure:"After a tool fails. Can handle error or retry.",Stop:"When the agent stops (end_turn, max_tokens, error).",UserPromptSubmit:"When user submits a prompt. Can modify or reject.",SessionStart:"When a new session starts.",SessionEnd:"When a session ends.",Notification:"When a notification is sent.",ConfigChange:"When configuration changes.",WorktreeCreate:"When a git worktree is created."},e9={ALLOW:0,DENY:1,BLOCK:2};import{readFileSync as w8,existsSync as G6,readdirSync as L8}from"fs";import{join as v8}from"path";function M8(Q,X="project"){if(!G6(Q))return null;let Z=w8(Q,"utf-8"),V=Q.split("/").pop()?.replace(/\.md$/i,"")||"unknown",$=Z.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!$)return{path:Q,name:V,description:"",prompt:Z.trim(),source:X};let[,J,q]=$,K=O8(J);return{path:Q,name:K.name||V,description:K.description||"",prompt:q.trim(),tools:K.tools,model:K.model,color:K.color,source:X}}function O8(Q){let X={},Z=Q.split(`
25
- `);for(let V of Z){let $=V.match(/^(\w+):\s*(.*)$/);if($){let[,J,q]=$;if(q.startsWith("["))try{X[J]=JSON.parse(q)}catch{X[J]=q}else if(q==="true")X[J]=!0;else if(q==="false")X[J]=!1;else if(/^\d+$/.test(q))X[J]=parseInt(q,10);else if(/^\d+\.\d+$/.test(q))X[J]=parseFloat(q);else X[J]=q}}return X}class F8{skills=new Map;loadFromDirectory(Q,X="project"){if(!G6(Q))return 0;let Z=0,V=L8(Q);for(let $ of V)if($.endsWith(".md")){let J=M8(v8(Q,$),X);if(J)this.skills.set(J.name,J),Z++}return Z}get(Q){return this.skills.get(Q)}getAll(){return Array.from(this.skills.values())}has(Q){return this.skills.has(Q)}getNames(){return Array.from(this.skills.keys())}}function V0(Q){return`
26
- <skill-loading>
27
- You are operating with the "${Q.name}" skill loaded.
28
-
29
- ${Q.description?`Description: ${Q.description}
30
- `:""}
31
- ${Q.prompt}
32
- </skill-loading>
33
- `.trim()}var $0=[{path:"built-in://commit",name:"commit",description:"Create a git commit with the staged changes",prompt:`Analyze the staged changes and create a git commit.
34
-
35
- Steps:
36
- 1. Run \`git diff --staged\` to see staged changes
37
- 2. Run \`git log --oneline -5\` to understand commit message style
38
- 3. Create a commit message following conventional commits format
39
- 4. Include "Co-Authored-By: Claude <noreply@anthropic.com>" if applicable
40
- 5. Run \`git commit\` with the message`,tools:["Bash"],model:"sonnet",source:"built-in"},{path:"built-in://review-pr",name:"review-pr",description:"Review a pull request",prompt:`Review the current pull request and provide feedback.
41
-
42
- Steps:
43
- 1. Use \`gh pr view\` to get PR details
44
- 2. Use \`gh pr diff\` to see the changes
45
- 3. Analyze the code for:
46
- - Bugs and potential issues
47
- - Code quality and style
48
- - Test coverage
49
- - Documentation
50
- 4. Provide constructive feedback
51
- 5. Approve or request changes as appropriate`,tools:["Bash"],model:"sonnet",source:"built-in"},{path:"built-in://mcp-builder",name:"mcp-builder",description:"Guide for creating MCP servers",prompt:`Help the user build MCP (Model Context Protocol) servers.
52
-
53
- MCP servers enable LLMs to interact with external services through well-designed tools.
54
-
55
- Key concepts:
56
- 1. Use FastMCP (Python) or MCP SDK (TypeScript)
57
- 2. Define tools with clear input schemas
58
- 3. Return structured content
59
- 4. Handle errors gracefully
60
-
61
- Transport types:
62
- - stdio: Local process communication
63
- - HTTP: REST API with JSON-RPC
64
- - SSE: Server-Sent Events for streaming
65
- - WebSocket: Bidirectional communication`,tools:["Read","Write","Edit","Bash"],model:"sonnet",source:"built-in"},{path:"built-in://claude-hooks",name:"claude-hooks",description:"Guide for Claude Code hooks",prompt:`Help the user configure Claude Code hooks.
66
-
67
- Hooks are user-defined shell commands that execute at specific points during Claude Code's lifecycle.
68
-
69
- Available events:
70
- - PreToolUse: Before a tool executes
71
- - PostToolUse: After a tool succeeds
72
- - PostToolUseFailure: After a tool fails
73
- - Stop: When agent stops
74
- - UserPromptSubmit: When user submits prompt
75
- - SessionStart/SessionEnd: Session lifecycle
76
-
77
- Exit codes:
78
- - 0: Allow execution
79
- - 1: Deny and show stderr
80
- - 2: Block silently`,tools:["Read","Write","Edit"],model:"sonnet",source:"built-in"}];function J0(Q){let X=Q.match(/^\/(\w+)(?:\s+(.*))?$/);return X?X[1]:null}function q0(Q){let X=Q.match(/^\/\w+\s+(.*)$/);return X?X[1]:""}import{spawn as C5}from"child_process";class k8{teams=new Map;teammates=new Map;storagePath;constructor(Q="~/.claude/teams"){this.storagePath=Q.replace("~",process.env.HOME||"")}createTeam(Q){let X={...Q,status:"active"};this.teams.set(Q.name,X);for(let Z of Q.teammates)this.teammates.set(Z.teammateId,Z);return this.persistTeam(X),X}getTeam(Q){return this.teams.get(Q)}listTeams(){return Array.from(this.teams.values())}deleteTeam(Q){let X=this.teams.get(Q);if(X){for(let Z of X.teammates)this.teammates.delete(Z.teammateId);this.teams.delete(Q)}}getTeammate(Q){return this.teammates.get(Q)}updateTeammateStatus(Q,X){let Z=this.teammates.get(Q);if(Z)Z.status=X}async spawnTeammate(Q,X={}){let{session:Z,workingDir:V=process.cwd()}=X;if(!process.env.TMUX)await this.spawnInTerminal(Q,{session:Z,workingDir:V});else await this.spawnInTmux(Q,{session:Z,workingDir:V});this.updateTeammateStatus(Q.teammateId,"in_progress")}async spawnInTerminal(Q,X){let Z=["bun","run","src/cli.ts","--teammate-mode","--agent-id",Q.teammateId,"--agent-name",Q.name,"--team-name",Q.teamName,"--agent-color",Q.color];if(Q.planModeRequired)Z.push("--permission-mode","plan");if(process.platform==="darwin"){let V=`
81
- tell application "Terminal"
82
- do script "cd ${X.workingDir} && ${Z.join(" ")}"
83
- activate
84
- end tell
85
- `;C5("osascript",["-e",V])}else C5("xterm",["-e",Z.join(" ")])}async spawnInTmux(Q,X){let Z=X.session||process.env.TMUX?.split(",")[0]?.split(":")[0]||"claude";await this.tmuxCommand(["split-window","-t",Z,"-c",X.workingDir]);let V=await this.tmuxCommand(["display-message","-p","#{pane_id}"]);if(V)Q.paneId=V.trim();let $=["bun","run","src/cli.ts","--teammate-mode","--agent-id",Q.teammateId,"--agent-name",Q.name,"--team-name",Q.teamName];await this.tmuxCommand(["send-keys","-t",Q.paneId||"",$.join(" "),"Enter"])}async tmuxCommand(Q){return new Promise((X)=>{let Z=C5("tmux",Q),V="";Z.stdout?.on("data",($)=>{V+=$.toString()}),Z.on("close",()=>{X(V)})})}broadcast(Q,X){if(!this.teams.get(Q))return;let V={type:"broadcast",from:"system",content:X,timestamp:Date.now()};console.log(`[Broadcast:${Q}] ${X}`)}sendDirect(Q,X,Z){let V={type:"direct",from:X,to:Q,content:Z,timestamp:Date.now()};console.log(`[Direct:${X}->${Q}] ${Z}`)}persistTeam(Q){let X=`${this.storagePath}/${Q.name}/config.json`}loadTeams(){}}var Y0={architect:(Q)=>({name:"architect",teamName:Q,color:"blue",prompt:`You are an architect on the ${Q} team.
86
- Your role is to design and plan the technical architecture.
87
- Focus on:
88
- - System design and component relationships
89
- - API contracts and interfaces
90
- - Data models and schemas
91
- - Trade-offs and design decisions`,planModeRequired:!0,status:"pending"}),implementer:(Q)=>({name:"implementer",teamName:Q,color:"green",prompt:`You are an implementer on the ${Q} team.
92
- Your role is to write clean, working code based on the architecture.
93
- Focus on:
94
- - Implementing the designed architecture
95
- - Writing tests
96
- - Following coding standards
97
- - Handling edge cases`,planModeRequired:!1,status:"pending"}),reviewer:(Q)=>({name:"reviewer",teamName:Q,color:"yellow",prompt:`You are a code reviewer on the ${Q} team.
98
- Your role is to review code changes and provide feedback.
99
- Focus on:
100
- - Code quality and readability
101
- - Potential bugs and issues
102
- - Performance considerations
103
- - Test coverage`,planModeRequired:!1,status:"pending"}),tester:(Q)=>({name:"tester",teamName:Q,color:"orange",prompt:`You are a tester on the ${Q} team.
104
- Your role is to ensure features work correctly.
105
- Focus on:
106
- - Writing comprehensive tests
107
- - Finding edge cases
108
- - Verifying requirements
109
- - Reporting bugs`,planModeRequired:!1,status:"pending"})};function R8(){return`teammate_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function H0(Q){return{...Q,teammateId:R8(),status:"pending"}}
110
- export{I8 as a,U6 as b,B5 as c,E8 as d,B6 as e,b8 as f,Y8 as g,H8 as h,W8 as i,_8 as j,G8 as k,U8 as l,C8 as m,o9 as n,B8 as o,r9 as p,s9 as q,e9 as r,M8 as s,F8 as t,V0 as u,$0 as v,J0 as w,q0 as x,k8 as y,Y0 as z,R8 as A,H0 as B};