@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.
- package/README.md +31 -32
- package/dist/index.js +52191 -1
- package/dist/interfaces/ui/terminal/cli/index.js +52776 -0
- package/native/README.md +5 -5
- package/native/index.darwin-arm64.node +0 -0
- package/native/index.node +0 -0
- package/native/package.json +4 -4
- package/package.json +30 -15
- package/dist/cli.js +0 -148
- package/dist/index-0pkak453.js +0 -136
- package/dist/index-0qd0x8b4.js +0 -110
- package/dist/index-0x3kprq6.js +0 -240
- package/dist/index-1eawy937.js +0 -308
- package/dist/index-24m2aygy.js +0 -240
- package/dist/index-29xcjnne.js +0 -280
- package/dist/index-2avyytn5.js +0 -349
- package/dist/index-4ms367ey.js +0 -136
- package/dist/index-4w2t3b0m.js +0 -240
- package/dist/index-4xfgd8nz.js +0 -261
- package/dist/index-5acjp9gc.js +0 -157
- package/dist/index-5s15hr56.js +0 -136
- package/dist/index-6e4wf341.js +0 -349
- package/dist/index-6fvnkedw.js +0 -240
- package/dist/index-6rqpmd4g.js +0 -128
- package/dist/index-77ckwnbm.js +0 -280
- package/dist/index-9knxy49k.js +0 -128
- package/dist/index-9zrnw4zx.js +0 -128
- package/dist/index-bk21w99v.js +0 -280
- package/dist/index-c41n76fv.js +0 -240
- package/dist/index-cb4ppjdt.js +0 -255
- package/dist/index-cfb2edt6.js +0 -240
- package/dist/index-cmfa38hh.js +0 -308
- package/dist/index-datjz8q1.js +0 -257
- package/dist/index-eadf4wvn.js +0 -240
- package/dist/index-em5k0m3z.js +0 -345
- package/dist/index-gh8r333a.js +0 -110
- package/dist/index-gkx6k2tr.js +0 -261
- package/dist/index-h5cabfks.js +0 -155
- package/dist/index-hcrpwyy3.js +0 -261
- package/dist/index-hk7fwwa8.js +0 -257
- package/dist/index-jb8cw7f8.js +0 -136
- package/dist/index-kbyw4th1.js +0 -347
- package/dist/index-kgj5gqnm.js +0 -345
- package/dist/index-mdf6xp1z.js +0 -255
- package/dist/index-mrhv8kvc.js +0 -280
- package/dist/index-mt4743dd.js +0 -161
- package/dist/index-qnwsg97q.js +0 -240
- package/dist/index-qwdy6x44.js +0 -261
- package/dist/index-rmj77261.js +0 -157
- package/dist/index-sbbw1a61.js +0 -349
- package/dist/index-svy5bcpn.js +0 -345
- package/dist/index-tvmy7tm9.js +0 -261
- package/dist/index-tzz4vzkj.js +0 -312
- package/dist/index-vz80zmhe.js +0 -110
- package/dist/index-wed2fk67.js +0 -240
- package/dist/index-wksgzz8e.js +0 -280
- package/dist/index-wn2m4wma.js +0 -240
- package/dist/index-xha05vjc.js +0 -257
- package/dist/index-yc6eh8p8.js +0 -136
- package/dist/index-ycjxx9ft.js +0 -240
- package/dist/index-z0gzd0fc.js +0 -110
- package/dist/index-z8cwtf8j.js +0 -240
- package/dist/index-zy5mtt00.js +0 -128
package/dist/index-9zrnw4zx.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
var l6=Object.create;var{getPrototypeOf:p6,defineProperty:h5,getOwnPropertyNames:i6}=Object;var n6=Object.prototype.hasOwnProperty;var o6=(Q,X,Z)=>{Z=Q!=null?l6(p6(Q)):{};let V=X||!Q||!Q.__esModule?h5(Z,"default",{value:Q,enumerable:!0}):Z;for(let $ of i6(Q))if(!n6.call(V,$))h5(V,$,{get:()=>Q[$],enumerable:!0});return V};var a6=import.meta.require;var lQ={enabled:!0,ttl:"1h",cacheSystemPrompt:!0,cacheTools:!0,minTokensForCache:1024},M9={"claude-opus-4-6":{input:15,output:75,cache_write:18.75,cache_read:1.5},"claude-sonnet-4-6":{input:3,output:15,cache_write:3.75,cache_read:0.3},"claude-haiku-4-5":{input:0.8,output:4,cache_write:1,cache_read:0.08}};var g5={"claude-opus-4-6":{input:15,output:75,cache_write:18.75,cache_read:1.5},"claude-sonnet-4-6":{input:3,output:15,cache_write:3.75,cache_read:0.3},"claude-haiku-4-5":{input:0.8,output:4,cache_write:1,cache_read:0.08},"claude-3-5-sonnet":{input:3,output:15,cache_write:3.75,cache_read:0.3},"claude-3-5-haiku":{input:0.8,output:4,cache_write:1,cache_read:0.08},"claude-3-opus":{input:15,output:75,cache_write:18.75,cache_read:1.5}};function r6(Q,X){let Z=g5[Q]??g5["claude-sonnet-4-6"],V=X.input_tokens-(X.cache_read_input_tokens??0),$=X.cache_read_input_tokens??0,J=X.cache_creation_input_tokens??0,z=X.output_tokens,Y=V/1e6*Z.input,K=$/1e6*Z.cache_read,q=J/1e6*Z.cache_write,W=z/1e6*Z.output,H=Y+K+q+W,_=($+J)/1e6*(Z.input-Z.cache_read);return{costUSD:H,estimatedSavingsUSD:_}}function s6(Q,X){if(!Q||!X.enabled||!X.cacheSystemPrompt)return typeof Q==="string"?Q:void 0;if(Array.isArray(Q)){let Z=[...Q];if(Z.length>0){let V=Z[Z.length-1];if(V&&V.type==="text")Z[Z.length-1]={type:"text",text:V.text,cache_control:{type:"ephemeral",ttl:X.ttl}}}return Z}return[{type:"text",text:Q,cache_control:{type:"ephemeral",ttl:X.ttl}}]}function e6(Q,X){if(!X.enabled)return Q;let Z=[];for(let V=0;V<Q.length;V++){let $=Q[V],J=[];for(let z=0;z<$.content.length;z++){let Y=$.content[z],K=z===$.content.length-1,q=V===Q.length-1;if(Y.type==="text"&&Y.text.length>=X.minTokensForCache*4&&!Y.cache_control&&(K||q))J.push({...Y,cache_control:{type:"ephemeral",ttl:X.ttl}});else J.push(Y)}Z.push({...$,content:J})}if(Z.length>0&&X.enabled){let V=Z[Z.length-1],$=V.content[V.content.length-1];if($&&!("cache_control"in $))V.content[V.content.length-1]={...$,cache_control:{type:"ephemeral",ttl:X.ttl}}}return Z}function t6(Q){let X=Q.cache_read_input_tokens??0,Z=Q.cache_creation_input_tokens??0,V=X+Z,$=X>0?1:0,J=Z>0?1:0,z=$+J;return{cacheHits:$,cacheMisses:J,totalCacheReadTokens:X,totalCacheWriteTokens:Z,cacheHitRate:z>0?$/z:0,estimatedSavingsUSD:0}}async function m5(Q,X){let{apiKey:Z,model:V="claude-sonnet-4-6",maxTokens:$=4096,tools:J,systemPrompt:z,cacheConfig:Y=lQ,thinking:K,onToken:q,onThinking:W,onToolUse:H,signal:j}=X,_=Date.now(),G=0,w=!0,U=e6(Q,Y),A=s6(z,Y),B={model:V,max_tokens:$,messages:U.map((g)=>({role:g.role,content:g.content})),stream:!0};if(A)B.system=A;if(J&&J.length>0)B.tools=J;let v=`${process.env.ANTHROPIC_BASE_URL||"https://api.anthropic.com"}/v1/messages`,L={"Content-Type":"application/json","x-api-key":Z,"anthropic-version":"2023-06-01","anthropic-beta":"max-tokens-3-5-sonnet-2024-07-15"};if(K&&K.type!=="disabled"){if(K.type==="enabled")B.thinking={type:"enabled",budget_tokens:K.budget_tokens};else if(K.type==="adaptive")B.thinking={type:"adaptive"};L["anthropic-beta"]="extended-thinking-2025-01-24"}let R=await fetch(v,{method:"POST",headers:L,body:JSON.stringify(B),signal:j});if(!R.ok){let g=await R.text();throw Error(`API error: ${R.status} - ${g}`)}if(!R.body)throw Error("No response body");let I=R.body.getReader(),p=new TextDecoder,k=null,i=[],zQ={input_tokens:0,output_tokens:0},QQ=null,S=null,h=null,YQ="",u5="";try{let g="";while(!0){let{done:XQ,value:mQ}=await I.read();if(XQ)break;g+=p.decode(mQ,{stream:!0});let CQ=g.split(`
|
|
3
|
-
`);g=CQ.pop()||"";for(let dQ of CQ){if(!dQ.startsWith("data: "))continue;let OQ=dQ.slice(6);if(!OQ)continue;try{let KQ=JSON.parse(OQ);switch(KQ.type){case"message_start":{let C=KQ.message;k=C,zQ=C.usage;break}case"content_block_start":{let C=KQ.content_block;if(C.type==="text")QQ={type:"text",text:""};else if(C.type==="thinking")S={type:"thinking",thinking:""};else if(C.type==="tool_use")h={type:"tool_use",id:C.id,name:C.name,input:{}},YQ="";break}case"content_block_delta":{let C=KQ.delta;if(C.type==="text_delta"&&QQ){let qQ=C.text;if(QQ.text+=qQ,q?.(qQ),w)G=Date.now()-_,w=!1}else if(C.type==="thinking_delta"&&S){let qQ=C.thinking;S.thinking+=qQ,W?.(qQ)}else if(C.type==="input_json_delta"&&h)YQ+=C.partial_json;break}case"content_block_stop":if(QQ)i.push(QQ),QQ=null;else if(S)i.push(S),S=null;else if(h){try{h.input=JSON.parse(YQ)}catch{h.input={}}i.push(h),H?.({id:h.id,name:h.name,input:h.input}),h=null}break;case"message_delta":{let C=KQ;if(C.usage)zQ.output_tokens=C.usage.output_tokens;if(k&&C.delta?.stop_reason)k.stop_reason=C.delta.stop_reason;break}case"message_stop":break}}catch{}}}}finally{I.releaseLock()}if(!k)throw Error("No message received from API");k.content=i;let{costUSD:FQ,estimatedSavingsUSD:H5}=r6(V,zQ),gQ=t6(zQ);gQ.estimatedSavingsUSD=H5;let r=Date.now()-_;return{message:k,usage:zQ,cacheMetrics:gQ,costUSD:FQ,durationMs:r,ttftMs:G||r}}import*as d5 from"readline";var Q7={Read:"low",Glob:"low",Grep:"low",Task:"low",Write:"medium",Edit:"medium",NotebookEdit:"medium",Bash:"high"},X7=[/\brm\s+-rf\b/,/\brm\s+-r\b/,/\brm\s+[^-]/,/\bgit\s+push\s+--force\b/,/\bgit\s+reset\s+--hard\b/,/\bgit\s+clean\s+-fd\b/,/\bdrop\b/i,/\bdelete\b/i,/\btruncate\b/i,/\bformat\b/i,/\bdd\s+if=/,/\bshred\b/,/\b:\(\)\{\s*:\|:\s*&\s*\};\s*:\b/];function Z7(Q,X){let Z=Q7[Q]??"medium";if(Q==="Bash"){let V=String(X.command??"");for(let $ of X7)if($.test(V))return"critical";if(/\bsudo\b/.test(V)||/\bchmod\b/.test(V))Z="high"}if(Q==="Write"||Q==="Edit"){let V=String(X.file_path??X.path??"");if(/\.(env|pem|key|secret|credentials)/.test(V))Z="high";if(/\/\.ssh\//.test(V)||/\/\.gnupg\//.test(V))Z="critical"}return Z}function V7(Q,X){switch(Q){case"Read":return`Read file: ${X.file_path??"unknown"}`;case"Write":return`Write file: ${X.file_path??"unknown"} (${String(X.content??"").length} chars)`;case"Edit":return`Edit file: ${X.file_path??"unknown"}`;case"Bash":return`Execute: ${String(X.command??"").slice(0,100)}${String(X.command??"").length>100?"...":""}`;case"Glob":return`Find files: ${X.pattern??"*"}`;case"Grep":return`Search: "${X.pattern??""}" in ${X.path??"."}`;case"Task":return`Spawn agent: ${X.subagent_type??"unknown"}`;default:return`Use tool: ${Q}`}}class j5{cache={};cacheTimeout=300000;promptCallback;mode;constructor(Q="default",X){this.mode=Q,this.promptCallback=X??this.defaultPrompt.bind(this)}async checkPermission(Q,X){if(this.mode==="bypassPermissions")return{decision:"allow"};if(this.mode==="dontAsk")return{decision:"deny",reason:"Permission mode is dontAsk"};if(this.mode==="acceptEdits"){if(["Read","Write","Edit","Glob","Grep"].includes(Q))return{decision:"allow"}}if(this.mode==="plan"){if(["Read","Glob","Grep","Task"].includes(Q))return{decision:"allow"};return{decision:"deny",reason:"Plan mode - write operations disabled"}}let Z=this.getCacheKey(Q,X),V=this.cache[Z];if(V&&Date.now()-V.timestamp<this.cacheTimeout){if(V.decision==="allowAlways")return{decision:"allow",reason:"Previously approved (always)"};if(V.decision==="denyAlways")return{decision:"deny",reason:"Previously denied (always)"}}let $=Z7(Q,X),J=V7(Q,X),z={toolName:Q,toolInput:X,riskLevel:$,description:J,file:X.file_path??X.path,command:Q==="Bash"?X.command:void 0};if(this.mode==="interactive"||this.mode==="default"){let Y=await this.promptCallback(z);if(Y.decision==="allowAlways"||Y.decision==="denyAlways")this.cache[Z]={decision:Y.decision,timestamp:Date.now()};return Y}return{decision:"allow"}}getCacheKey(Q,X){if(["Read","Write","Edit"].includes(Q))return`${Q}:${X.file_path??X.path??"unknown"}`;if(Q==="Bash"){let Z=String(X.command??"").slice(0,100);return`${Q}:${Z}`}return Q}async defaultPrompt(Q){return new Promise((X)=>{let Z=d5.createInterface({input:process.stdin,output:process.stdout}),$={low:"\x1B[32m",medium:"\x1B[33m",high:"\x1B[31m",critical:"\x1B[35m"}[Q.riskLevel]??"\x1B[0m",J="\x1B[0m";if(console.log(""),console.log("\x1B[36m\u2501\u2501\u2501 Permission Required \u2501\u2501\u2501\x1B[0m"),console.log(`Tool: \x1B[1m${Q.toolName}\x1B[0m`),console.log(`Risk: ${$}${Q.riskLevel.toUpperCase()}\x1B[0m`),console.log(`Action: ${Q.description}`),Q.file)console.log(`File: ${Q.file}`);if(Q.command)console.log(`Command: ${Q.command.slice(0,200)}${Q.command.length>200?"...":""}`);console.log("");let z="[y]es / [n]o / [a]lways / [d]eny always";Z.question(`Allow? ${z}: `,(Y)=>{switch(Z.close(),Y.trim().toLowerCase()){case"y":case"yes":X({decision:"allow"});break;case"a":case"always":X({decision:"allowAlways"});break;case"d":case"deny":case"deny always":X({decision:"denyAlways"});break;case"n":case"no":default:X({decision:"deny"});break}})})}clearCache(){this.cache={}}setMode(Q){this.mode=Q,this.clearCache()}}var _5={readOnly:["Read","Glob","Grep","Task"],fileEdit:["Write","Edit","NotebookEdit"],system:["Bash"],network:[]};function x9(Q){return _5.readOnly.includes(Q)}function D9(Q){return _5.fileEdit.includes(Q)}function N9(Q){return _5.system.includes(Q)}var w5={tokenWarningThreshold:0.8,costUpdateInterval:5,toolSummaryInterval:3,envInfoOnStart:!0},G5={WARNING:0.8,CRITICAL:0.9,EMERGENCY:0.95};function $7(Q){let{current:X,max:Z,threshold:V=G5.WARNING}=Q;if(Z<=0)return"";let $=X/Z;if($<V)return"";let J=Z-X,z=Math.round($*100),Y,K;if($>=G5.EMERGENCY)Y="emergency",K="\uD83D\uDEA8";else if($>=G5.CRITICAL)Y="critical",K="\u26A0\uFE0F";else Y="warning",K="\u26A1";let q=[`${K} Token Usage ${Y.toUpperCase()}`,"",`Current: ${X.toLocaleString()} / ${Z.toLocaleString()} tokens (${z}%)`,`Remaining: ${J.toLocaleString()} tokens`];if(Y==="emergency")q.push(""),q.push("Consider summarizing or compacting the conversation to continue.");else if(Y==="critical")q.push(""),q.push("Approaching token limit. Consider wrapping up soon.");return q.join(`
|
|
4
|
-
`)}function J7(Q){let{cost:X,previousCost:Z=0,currency:V="USD"}=Q,$=z7(V),J=c5(X,$),z=X-Z,Y=c5(Math.abs(z),$),K=["\uD83D\uDCB0 Cost Update","",`Total: ${J} ${V}`];if(z!==0){let q=z>0?"+":"-";K.push(`This turn: ${q}${Y} ${V}`)}return K.join(`
|
|
5
|
-
`)}function c5(Q,X){if(Q<0.01)return`${X}${Q.toFixed(4)}`;else if(Q<1)return`${X}${Q.toFixed(3)}`;return`${X}${Q.toFixed(2)}`}function z7(Q){return{USD:"$",EUR:"\u20AC",GBP:"\xA3",JPY:"\xA5"}[Q]||Q}function Y7(Q){let{tools:X,maxDisplay:Z=10}=Q;if(X.length===0)return"No tools used this session.";let V=new Map;for(let Y of X){let K=V.get(Y.name)||0;V.set(Y.name,K+1)}let $=[...V.entries()].sort((Y,K)=>K[1]-Y[1]),J=[`\uD83D\uDD27 Tool Usage Summary (${X.length} total calls)`,""],z=$.slice(0,Z);for(let[Y,K]of z)J.push(` \u2022 ${Y}: ${K} call${K===1?"":"s"}`);if($.length>Z){let Y=$.length-Z;J.push(` ... and ${Y} more tool${Y===1?"":"s"}`)}return J.join(`
|
|
6
|
-
`)}function K7(Q){let{workingDirectory:X,gitStatus:Z,platform:V=process.platform,shell:$=process.env.SHELL||"unknown"}=Q,J=["\uD83D\uDCCD Environment Information","",`Working Directory: ${X}`,`Platform: ${V}`,`Shell: ${$}`];if(Z){if(J.push(""),J.push("Git Status:"),J.push(` Branch: ${Z.branch}`),Z.ahead>0||Z.behind>0)J.push(` Ahead: ${Z.ahead}, Behind: ${Z.behind}`);let z=Z.staged.length+Z.unstaged.length+Z.untracked.length+Z.conflicted.length;if(z>0){if(J.push(` Changes: ${z} file${z===1?"":"s"}`),Z.staged.length>0)J.push(` Staged: ${Z.staged.length}`);if(Z.unstaged.length>0)J.push(` Unstaged: ${Z.unstaged.length}`);if(Z.untracked.length>0)J.push(` Untracked: ${Z.untracked.length}`);if(Z.conflicted.length>0)J.push(` Conflicted: ${Z.conflicted.length}`)}else J.push(" Working tree clean")}return J.join(`
|
|
7
|
-
`)}function l5(Q){let{usage:X,maxTokens:Z,totalCost:V,previousCost:$,toolsUsed:J,workingDirectory:z,gitStatus:Y,turnNumber:K,config:q}=Q,W={...w5,...q},H=[],j=X.input_tokens+X.output_tokens,_=$7({current:j,max:Z,threshold:W.tokenWarningThreshold});if(_)H.push(_);if(K%W.costUpdateInterval===0){let G=J7({cost:V,previousCost:$});H.push(G)}if(K%W.toolSummaryInterval===0&&J.length>0){let G=Y7({tools:J});H.push(G)}if(K===1&&W.envInfoOnStart){let G=K7({workingDirectory:z,gitStatus:Y});H.push(G)}if(H.length===0)return"";return["---","System Reminders:","",...H,"---"].join(`
|
|
8
|
-
`)}async function g9(Q,X){let{apiKey:Z,model:V="claude-sonnet-4-6",maxTokens:$=4096,systemPrompt:J,tools:z,permissionMode:Y,workingDirectory:K,gitStatus:q=null,reminderConfig:W,cacheConfig:H=lQ,thinking:j,onText:_,onThinking:G,onToolUse:w,onToolResult:U,onMetrics:A,onReminder:B,onPermissionRequest:F,signal:v}=X,L=new j5(Y,F),R=[...Q],I=[],p=[],k=0,i=0,zQ=0,QQ=0,S={cacheHits:0,cacheMisses:0,totalCacheReadTokens:0,totalCacheWriteTokens:0,cacheHitRate:0,estimatedSavingsUSD:0},h={...w5,...W},YQ=!0;while(YQ){if(v?.aborted)break;zQ++;let u5=I[I.length-1],FQ=l5({usage:u5?.usage??{input_tokens:0,output_tokens:0},maxTokens:$,totalCost:k,previousCost:QQ,toolsUsed:p,workingDirectory:K,gitStatus:q,turnNumber:zQ,config:h});if(FQ)B?.(FQ);let H5=q7(R,J,FQ),gQ=await m5(H5,{apiKey:Z,model:V,maxTokens:$,systemPrompt:J,cacheConfig:H,thinking:j,tools:z.map((jQ)=>({name:jQ.name,description:jQ.description,input_schema:jQ.input_schema})),onToken:_,onThinking:G,onToolUse:w,signal:v}),{message:r,usage:g,cacheMetrics:XQ,costUSD:mQ,durationMs:CQ,ttftMs:dQ}=gQ,OQ={model:V,messageCount:R.length,messageTokens:g.input_tokens+g.output_tokens,usage:g,cacheMetrics:XQ,durationMs:CQ,ttftMs:dQ,costUSD:mQ,stopReason:r.stop_reason,requestId:r.id};if(I.push(OQ),QQ=k,k+=mQ,i+=CQ,XQ)S.cacheHits+=XQ.cacheHits,S.cacheMisses+=XQ.cacheMisses,S.totalCacheReadTokens+=XQ.totalCacheReadTokens,S.totalCacheWriteTokens+=XQ.totalCacheWriteTokens,S.estimatedSavingsUSD+=XQ.estimatedSavingsUSD;let KQ=S.cacheHits+S.cacheMisses;if(S.cacheHitRate=KQ>0?S.cacheHits/KQ:0,A?.(OQ),R.push({role:"assistant",content:r.content}),r.stop_reason==="end_turn"||r.stop_reason==="stop_sequence"){YQ=!1;break}if(r.stop_reason==="max_tokens"){console.warn("Max tokens reached - context compaction needed"),YQ=!1;break}let C=r.content.filter((jQ)=>jQ.type==="tool_use");if(p.push(...C),C.length===0){YQ=!1;break}let qQ=[];if(v?.aborted);else{let jQ=C.map(async(P)=>{let W5=z.find((ZQ)=>ZQ.name===P.name);if(!W5)return{toolUseId:P.id,result:{type:"tool_result",tool_use_id:P.id,content:`Error: Unknown tool "${P.name}"`,is_error:!0},toolResult:null};let cQ=await L.checkPermission(W5.name,P.input);if(cQ.decision==="deny"||cQ.decision==="denyAlways")return{toolUseId:P.id,result:{type:"tool_result",tool_use_id:P.id,content:`Permission denied for tool "${P.name}"${cQ.reason?`: ${cQ.reason}`:""}`,is_error:!0},toolResult:null};try{let ZQ=await W5.handler(P.input,{workingDirectory:K,permissionMode:Y,abortSignal:v});return{toolUseId:P.id,result:{type:"tool_result",tool_use_id:P.id,content:ZQ.content,is_error:ZQ.is_error},toolResult:{id:P.id,result:ZQ}}}catch(ZQ){let c6=ZQ instanceof Error?ZQ.message:String(ZQ);return{toolUseId:P.id,result:{type:"tool_result",tool_use_id:P.id,content:`Error: ${c6}`,is_error:!0},toolResult:null}}}),d6=await Promise.all(jQ);for(let P of d6)if(qQ.push(P.result),P.toolResult)U?.(P.toolResult)}R.push({role:"user",content:qQ})}return{messages:R,metrics:I,totalCost:k,totalDuration:i,totalCacheMetrics:S}}function q7(Q,X,Z){if(Z&&Q.length>0){let V=[...Q];for(let $=V.length-1;$>=0;$--){let J=V[$];if(J&&J.role==="user"){let z={role:"user",content:Array.isArray(J.content)?H7(J.content,Z):[{type:"text",text:`${String(J.content)}
|
|
9
|
-
|
|
10
|
-
${Z}`}]};V[$]=z;break}}return V}return Q}function H7(Q,X){if(Q.length>0){let V=Q[Q.length-1];if(V&&V.type==="text"){let $={type:"text",text:`${V.text}
|
|
11
|
-
|
|
12
|
-
${X}`};return[...Q.slice(0,-1),$]}}let Z={type:"text",text:`
|
|
13
|
-
|
|
14
|
-
${X}`};return[...Q,Z]}function p5(Q){if(Q<0.01)return`$${Q.toFixed(4)}`;return`$${Q.toFixed(2)}`}function m9(Q){let X=p5(Q.costUSD),Z=`${Q.usage.input_tokens.toLocaleString()} input, ${Q.usage.output_tokens.toLocaleString()} output`;if(Q.usage.cache_read_input_tokens||Q.usage.cache_creation_input_tokens){let V=Q.usage.cache_read_input_tokens?.toLocaleString()??"0",$=Q.usage.cache_creation_input_tokens?.toLocaleString()??"0";return`Cost: ${X} | Tokens: ${Z} | Cache: ${V} read, ${$} write`}return`Cost: ${X} | Tokens: ${Z}`}function d9(Q){let X=p5(Q.estimatedSavingsUSD);return`Cache: ${(Q.cacheHitRate*100).toFixed(1)}% hit rate | ${Q.totalCacheReadTokens.toLocaleString()} read | ${Q.totalCacheWriteTokens.toLocaleString()} written | Saved: ${X}`}import{homedir as W7}from"os";import{join as VQ}from"path";class j7{sessionsDir;currentSessionId=null;currentSessionFile=null;writeQueue=Promise.resolve();constructor(Q){this.sessionsDir=Q??VQ(W7(),".claude","sessions")}async init(){try{await Bun.write(VQ(this.sessionsDir,".gitkeep"),"")}catch{}}generateSessionId(){let Q=Date.now().toString(36),X=Math.random().toString(36).slice(2,8);return`${Q}-${X}`}async createSession(Q){await this.init();let X=this.generateSessionId();this.currentSessionId=X,this.currentSessionFile=VQ(this.sessionsDir,`${X}.jsonl`);let Z={id:X,created:Date.now(),updated:Date.now(),model:Q.model,workingDirectory:Q.workingDirectory,agentName:Q.agentName,agentColor:Q.agentColor,teamName:Q.teamName};await this.appendEntry(Z);let V={type:"context",timestamp:Date.now(),workingDirectory:Q.workingDirectory};return await this.appendEntry(V),X}async resumeSession(Q){let X=VQ(this.sessionsDir,`${Q}.jsonl`);try{let Z=await Bun.file(X).text();if(!Z)return null;let V=Z.trim().split(`
|
|
15
|
-
`),$=[];for(let J of V)try{$.push(JSON.parse(J))}catch{}return this.parseSessionEntries($)}catch{return null}}parseSessionEntries(Q){let X=null,Z=[],V=[],$=[],J=null;for(let z of Q){if(!("type"in z)&&"id"in z&&"created"in z){X=z;continue}if("type"in z){let Y=z;switch(Y.type){case"message":Z.push(Y.data);break;case"tool_use":V.push(Y);break;case"metrics":$.push(Y.data);break;case"context":J=Y;break}}}if(!X)X={id:"unknown",created:Date.now(),updated:Date.now(),model:"claude-sonnet-4-6",workingDirectory:process.cwd()};return{metadata:X,messages:Z,tools:V,metrics:$,context:J}}async appendEntry(Q){if(!this.currentSessionFile)return;this.writeQueue=this.writeQueue.then(async()=>{let X=JSON.stringify(Q)+`
|
|
16
|
-
`,Z=Bun.file(this.currentSessionFile),V=await Z.exists()?await Z.text():"";await Bun.write(this.currentSessionFile,V+X)}),await this.writeQueue}async saveMessage(Q){let X={type:"message",timestamp:Date.now(),data:Q};await this.appendEntry(X),await this.updateTimestamp()}async saveToolUse(Q,X,Z,V,$){let J={type:"tool_use",timestamp:Date.now(),toolId:Q,toolName:X,input:Z,result:V,isError:$};await this.appendEntry(J)}async saveMetrics(Q){let X={type:"metrics",timestamp:Date.now(),data:Q};await this.appendEntry(X)}async updateTimestamp(){if(!this.currentSessionFile||!this.currentSessionId)return}async listSessions(Q=20){await this.init();let X=Bun.file(this.sessionsDir),Z=[];try{let $=[...new Bun.Glob("*.jsonl").scanSync(this.sessionsDir)],J=await Promise.all($.map(async(z)=>{let Y=VQ(this.sessionsDir,z),K=await Bun.file(Y).stat();return{file:z,fullPath:Y,mtime:K?.mtime??new Date(0)}}));J.sort((z,Y)=>Y.mtime.getTime()-z.mtime.getTime());for(let{file:z,fullPath:Y}of J.slice(0,Q)){let K=z.replace(".jsonl",""),q=await this.getSessionSummary(K,Y);if(q)Z.push(q)}}catch{}return Z}async getSessionSummary(Q,X){let Z=X??VQ(this.sessionsDir,`${Q}.jsonl`);try{let V=await Bun.file(Z).text();if(!V)return null;let $=V.trim().split(`
|
|
17
|
-
`),J=null,z=0,Y=0,K=0,q=0,W;for(let H of $)try{let j=JSON.parse(H);if(j.id&&j.created)J=j;else if(j.type==="message"){z++;let _=j.data;if(!W&&_.role==="user"){let G=_.content.find((w)=>w.type==="text");if(G&&"text"in G){if(W=G.text.slice(0,100),G.text.length>100)W+="..."}}}else if(j.type==="metrics")Y+=j.data.costUSD,K+=j.data.usage.input_tokens,q+=j.data.usage.output_tokens}catch{}if(!J)return null;return{id:Q,created:J.created,updated:J.updated,model:J.model,messageCount:z,totalCost:Y,totalTokens:{input:K,output:q},firstMessage:W,workingDirectory:J.workingDirectory}}catch{return null}}getCurrentSessionId(){return this.currentSessionId}async exportSession(Q,X,Z){let V=await this.resumeSession(Q);if(!V)throw Error(`Session not found: ${Q}`);let $,J;switch(X){case"jsonl":{let Y=VQ(this.sessionsDir,`${Q}.jsonl`);$=await Bun.file(Y).text(),J="jsonl";break}case"json":{$=JSON.stringify(V,null,2),J="json";break}case"markdown":{$=this.sessionToMarkdown(V),J="md";break}default:throw Error(`Unsupported format: ${X}`)}let z=Z??VQ(process.cwd(),`session-${Q}.${J}`);return await Bun.write(z,$),z}sessionToMarkdown(Q){let X=[];X.push(`# Session: ${Q.metadata.id}`),X.push(""),X.push(`**Created:** ${new Date(Q.metadata.created).toISOString()}`),X.push(`**Model:** ${Q.metadata.model}`),X.push(`**Working Directory:** ${Q.metadata.workingDirectory}`),X.push(""),X.push("## Conversation"),X.push("");for(let Z of Q.messages){let V=Z.role==="user"?"**User**":"**Claude**";X.push(`### ${V}`),X.push("");for(let $ of Z.content)if($.type==="text")X.push($.text),X.push("");else if($.type==="tool_use"){let J=$;X.push(`\`\`\`tool:${J.name}`),X.push(JSON.stringify(J.input,null,2)),X.push("```"),X.push("")}else if($.type==="tool_result"){let J=$;X.push(`**Result**${J.is_error?" (error)":""}:`),X.push("```"),X.push(typeof J.content==="string"?J.content:JSON.stringify(J.content,null,2)),X.push("```"),X.push("")}}if(Q.metrics.length>0){X.push("## Metrics"),X.push("");let Z=Q.metrics.reduce((J,z)=>J+z.costUSD,0),V=Q.metrics.reduce((J,z)=>J+z.usage.input_tokens,0),$=Q.metrics.reduce((J,z)=>J+z.usage.output_tokens,0);X.push(`- **Total Cost:** $${Z.toFixed(4)}`),X.push(`- **Total Input Tokens:** ${V.toLocaleString()}`),X.push(`- **Total Output Tokens:** ${$.toLocaleString()}`),X.push(`- **API Calls:** ${Q.metrics.length}`)}return X.join(`
|
|
18
|
-
`)}async deleteSession(Q){let X=VQ(this.sessionsDir,`${Q}.jsonl`);try{if(await Bun.file(X).exists()){let{unlink:V}=await import("fs/promises");return await V(X),!0}return!1}catch{return!1}}}function _7(Q){let X=new Date(Q.created),Z=new Date(Q.updated),V=G7(Z),$=[];$.push(`\x1B[1m${Q.id}\x1B[0m (${V})`),$.push(` Model: ${Q.model} | Messages: ${Q.messageCount}`);let J=Q.totalCost<0.01?`$${Q.totalCost.toFixed(4)}`:`$${Q.totalCost.toFixed(2)}`;if($.push(` Cost: ${J} | Tokens: ${Q.totalTokens.input.toLocaleString()} in, ${Q.totalTokens.output.toLocaleString()} out`),Q.firstMessage)$.push(` Preview: ${Q.firstMessage}`);return $.push(` Directory: ${Q.workingDirectory}`),$.join(`
|
|
19
|
-
`)}function G7(Q){let Z=new Date().getTime()-Q.getTime(),V=Math.floor(Z/60000),$=Math.floor(Z/3600000),J=Math.floor(Z/86400000);if(V<1)return"just now";if(V<60)return`${V}m ago`;if($<24)return`${$}h ago`;if(J<7)return`${J}d ago`;return Q.toLocaleDateString()}function i9(Q){if(Q.length===0){console.log("No sessions found."),console.log(`
|
|
20
|
-
Start a new conversation to create a session.`);return}console.log(`\x1B[1mRecent Sessions (${Q.length})\x1B[0m
|
|
21
|
-
`);for(let X of Q)console.log(_7(X)),console.log("");console.log("To resume a session:"),console.log(" claude-remake --resume <session-id>")}var A5=(Q,X,Z)=>{let V=Q instanceof RegExp?i5(Q,Z):Q,$=X instanceof RegExp?i5(X,Z):X,J=V!==null&&$!=null&&w7(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)}},i5=(Q,X)=>{let Z=X.match(Q);return Z?Z[0]:null},w7=(Q,X,Z)=>{let V,$,J,z=void 0,Y,K=Z.indexOf(Q),q=Z.indexOf(X,K+1),W=K;if(K>=0&&q>0){if(Q===X)return[K,q];V=[],J=Z.length;while(W>=0&&!Y){if(W===K)V.push(W),K=Z.indexOf(Q,W+1);else if(V.length===1){let H=V.pop();if(H!==void 0)Y=[H,q]}else{if($=V.pop(),$!==void 0&&$<J)J=$,z=q;q=Z.indexOf(X,W+1)}W=K<q&&K>=0?K:q}if(V.length&&z!==void 0)Y=[J,z]}return Y};var n5="\x00SLASH"+Math.random()+"\x00",o5="\x00OPEN"+Math.random()+"\x00",B5="\x00CLOSE"+Math.random()+"\x00",a5="\x00COMMA"+Math.random()+"\x00",r5="\x00PERIOD"+Math.random()+"\x00",A7=new RegExp(n5,"g"),U7=new RegExp(o5,"g"),B7=new RegExp(B5,"g"),L7=new RegExp(a5,"g"),v7=new RegExp(r5,"g"),F7=/\\\\/g,C7=/\\{/g,O7=/\\}/g,M7=/\\,/g,R7=/\\./g,k7=1e5;function U5(Q){return!isNaN(Q)?parseInt(Q,10):Q.charCodeAt(0)}function P7(Q){return Q.replace(F7,n5).replace(C7,o5).replace(O7,B5).replace(M7,a5).replace(R7,r5)}function x7(Q){return Q.replace(A7,"\\").replace(U7,"{").replace(B7,"}").replace(L7,",").replace(v7,".")}function s5(Q){if(!Q)return[""];let X=[],Z=A5("{","}",Q);if(!Z)return Q.split(",");let{pre:V,body:$,post:J}=Z,z=V.split(",");z[z.length-1]+="{"+$+"}";let Y=s5(J);if(J.length)z[z.length-1]+=Y.shift(),z.push.apply(z,Y);return X.push.apply(X,z),X}function e5(Q,X={}){if(!Q)return[];let{max:Z=k7}=X;if(Q.slice(0,2)==="{}")Q="\\{\\}"+Q.slice(2);return MQ(P7(Q),Z,!0).map(x7)}function D7(Q){return"{"+Q+"}"}function N7(Q){return/^-?0\d/.test(Q)}function I7(Q,X){return Q<=X}function S7(Q,X){return Q>=X}function MQ(Q,X,Z){let V=[],$=A5("{","}",Q);if(!$)return[Q];let J=$.pre,z=$.post.length?MQ($.post,X,!1):[""];if(/\$$/.test($.pre))for(let Y=0;Y<z.length&&Y<X;Y++){let K=J+"{"+$.body+"}"+z[Y];V.push(K)}else{let Y=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test($.body),K=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test($.body),q=Y||K,W=$.body.indexOf(",")>=0;if(!q&&!W){if($.post.match(/,(?!,).*\}/))return Q=$.pre+"{"+$.body+B5+$.post,MQ(Q,X,!0);return[Q]}let H;if(q)H=$.body.split(/\.\./);else if(H=s5($.body),H.length===1&&H[0]!==void 0){if(H=MQ(H[0],X,!1).map(D7),H.length===1)return z.map((_)=>$.pre+H[0]+_)}let j;if(q&&H[0]!==void 0&&H[1]!==void 0){let _=U5(H[0]),G=U5(H[1]),w=Math.max(H[0].length,H[1].length),U=H.length===3&&H[2]!==void 0?Math.abs(U5(H[2])):1,A=I7;if(G<_)U*=-1,A=S7;let F=H.some(N7);j=[];for(let v=_;A(v,G);v+=U){let L;if(K){if(L=String.fromCharCode(v),L==="\\")L=""}else if(L=String(v),F){let R=w-L.length;if(R>0){let I=Array(R+1).join("0");if(v<0)L="-"+I+L.slice(1);else L=I+L}}j.push(L)}}else{j=[];for(let _=0;_<H.length;_++)j.push.apply(j,MQ(H[_],X,!1))}for(let _=0;_<j.length;_++)for(let G=0;G<z.length&&V.length<X;G++){let w=J+j[_]+z[G];if(!Z||q||w)V.push(w)}}return V}var RQ=(Q)=>{if(typeof Q!=="string")throw TypeError("invalid pattern");if(Q.length>65536)throw TypeError("pattern is too long")};var T7={"[: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]},kQ=(Q)=>Q.replace(/[[\]\\-]/g,"\\$&"),E7=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),t5=(Q)=>Q.join(""),Q6=(Q,X)=>{let Z=X;if(Q.charAt(Z)!=="[")throw Error("not in a brace expression");let V=[],$=[],J=Z+1,z=!1,Y=!1,K=!1,q=!1,W=Z,H="";Q:while(J<Q.length){let w=Q.charAt(J);if((w==="!"||w==="^")&&J===Z+1){q=!0,J++;continue}if(w==="]"&&z&&!K){W=J+1;break}if(z=!0,w==="\\"){if(!K){K=!0,J++;continue}}if(w==="["&&!K){for(let[U,[A,B,F]]of Object.entries(T7))if(Q.startsWith(U,J)){if(H)return["$.",!1,Q.length-Z,!0];if(J+=U.length,F)$.push(A);else V.push(A);Y=Y||B;continue Q}}if(K=!1,H){if(w>H)V.push(kQ(H)+"-"+kQ(w));else if(w===H)V.push(kQ(w));H="",J++;continue}if(Q.startsWith("-]",J+1)){V.push(kQ(w+"-")),J+=2;continue}if(Q.startsWith("-",J+1)){H=w,J+=2;continue}V.push(kQ(w)),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])&&!q){let w=V[0].length===2?V[0].slice(-1):V[0];return[E7(w),!1,W-Z,!1]}let j="["+(q?"^":"")+t5(V)+"]",_="["+(q?"":"^")+t5($)+"]";return[V.length&&$.length?"("+j+"|"+_+")":V.length?j:_,Y,W-Z,!0]};var n=(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 f,b7=new Set(["!","?","+","*","@"]),L5=(Q)=>b7.has(Q),X6=(Q)=>L5(Q.type),y7=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),f7=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),u7=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),Z6=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),h7="(?!(?:^|/)\\.\\.?(?:$|/))",pQ="(?!\\.)",g7=new Set(["[","."]),m7=new Set(["..","."]),d7=new Set("().*{}+?[]^$\\!"),c7=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),v5="[^/]",V6=v5+"*?",$6=v5+"+?",l7=0;class AQ{type;#Q;#V;#$=!1;#X=[];#z;#O;#B;#W=!1;#Y;#j;#H=!1;id=++l7;get depth(){return(this.#z?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#Q.id,parent:this.#z?.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.#z=X,this.#Q=this.#z?this.#z.#Q:this,this.#Y=this.#Q===this?Z:this.#Q.#Y,this.#B=this.#Q===this?[]:this.#Q.#B,Q==="!"&&!this.#Q.#W)this.#B.push(this);this.#O=this.#z?this.#z.#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("|")+")"}#K(){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.#z;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.#z}}return this}push(...Q){for(let X of Q){if(X==="")continue;if(typeof X!=="string"&&!(X instanceof f&&X.#z===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.#z?.type==="!"))Q.push({});return Q}isStart(){if(this.#Q===this)return!0;if(!this.#z?.isStart())return!1;if(this.#O===0)return!0;let Q=this.#z;for(let X=0;X<this.#O;X++){let Z=Q.#X[X];if(!(Z instanceof f&&Z.type==="!"))return!1}return!0}isEnd(){if(this.#Q===this)return!0;if(this.#z?.type==="!")return!0;if(!this.#z?.isEnd())return!1;if(!this.type)return this.#z?.isEnd();let Q=this.#z?this.#z.#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 f(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,z=!1,Y=!1,K=-1,q=!1;if(X.type===null){let G=Z,w="";while(G<Q.length){let U=Q.charAt(G++);if(z||U==="\\"){z=!z,w+=U;continue}if(Y){if(G===K+1){if(U==="^"||U==="!")q=!0}else if(U==="]"&&!(G===K+2&&q))Y=!1;w+=U;continue}else if(U==="["){Y=!0,K=G,q=!1,w+=U;continue}if(!V.noext&&L5(U)&&Q.charAt(G)==="("&&$<=J){X.push(w),w="";let B=new f(U,X);G=f.#J(Q,B,G,V,$+1),X.push(B);continue}w+=U}return X.push(w),G}let W=Z+1,H=new f(null,X),j=[],_="";while(W<Q.length){let G=Q.charAt(W++);if(z||G==="\\"){z=!z,_+=G;continue}if(Y){if(W===K+1){if(G==="^"||G==="!")q=!0}else if(G==="]"&&!(W===K+2&&q))Y=!1;_+=G;continue}else if(G==="["){Y=!0,K=W,q=!1,_+=G;continue}if(!V.noext&&L5(G)&&Q.charAt(W)==="("&&($<=J||X&&X.#G(G))){let U=X&&X.#G(G)?0:1;H.push(_),_="";let A=new f(G,H);H.push(A),W=f.#J(Q,A,W,V,$+U);continue}if(G==="|"){H.push(_),_="",j.push(H),H=new f(null,X);continue}if(G===")"){if(_===""&&X.#X.length===0)X.#H=!0;return H.push(_),_="",X.push(...j,H),W}_+=G}return X.type=null,X.#V=void 0,X.#X=[Q.substring(Z-1)],W}#L(Q){return this.#F(Q,f7)}#F(Q,X=y7){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=u7){return!!X.get(this.type)?.includes(Q)}#w(Q,X){let Z=Q.#X[0],V=new f(null,Z,this.options);V.#X.push(""),Z.push(V),this.#k(Q,X)}#k(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.#z=this;this.#j=void 0}#A(Q){return!!Z6.get(this.type)?.has(Q)}#C(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.#A(X.type)}#M(Q){let X=Z6.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")$.#z=this;this.type=V,this.#j=void 0,this.#H=!1}static fromGlob(Q,X={}){let Z=new f(null,void 0,X);return f.#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.#Y.nocase&&!this.#Y.nocaseMagicOnly&&Q.toUpperCase()!==Q.toLowerCase()))return Z;let z=(this.#Y.nocase?"i":"")+($?"u":"");return Object.assign(new RegExp(`^${X}$`,z),{_src:X,_glob:Q})}get options(){return this.#Y}toRegExpSource(Q){let X=Q??!!this.#Y.dot;if(this.#Q===this)this.#_(),this.#K();if(!X6(this)){let Y=this.isStart()&&this.isEnd()&&!this.#X.some((j)=>typeof j!=="string"),K=this.#X.map((j)=>{let[_,G,w,U]=typeof j==="string"?f.#v(j,this.#V,Y):j.toRegExpSource(Q);return this.#V=this.#V||w,this.#$=this.#$||U,_}).join(""),q="";if(this.isStart()){if(typeof this.#X[0]==="string"){if(!(this.#X.length===1&&m7.has(this.#X[0]))){let _=g7,G=X&&_.has(K.charAt(0))||K.startsWith("\\.")&&_.has(K.charAt(2))||K.startsWith("\\.\\.")&&_.has(K.charAt(4)),w=!X&&!Q&&_.has(K.charAt(0));q=G?h7:w?pQ:""}}}let W="";if(this.isEnd()&&this.#Q.#W&&this.#z?.type==="!")W="(?:$|\\/)";return[q+K+W,n(K),this.#V=!!this.#V,this.#$]}let Z=this.type==="*"||this.type==="+",V=this.type==="!"?"(?:(?!(?:":"(?:",$=this.#U(X);if(this.isStart()&&this.isEnd()&&!$&&this.type!=="!"){let Y=this.toString(),K=this;return K.#X=[Y],K.type=null,K.#V=void 0,[Y,n(this.toString()),!1,!1]}let J=!Z||Q||X||!pQ?"":this.#U(!0);if(J===$)J="";if(J)$=`(?:${$})(?:${J})*?`;let z="";if(this.type==="!"&&this.#H)z=(this.isStart()&&!X?pQ:"")+$6;else{let Y=this.type==="!"?"))"+(this.isStart()&&!X&&!Q?pQ:"")+V6+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&J?")":this.type==="*"&&J?")?":`)${this.type}`;z=V+$+Y}return[z,n($),this.#V=!!this.#V,this.#$]}#_(){if(!X6(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.#F(V))X=!1,this.#k(V,Z);else if(this.#L(V))X=!1,this.#w(V,Z);else if(this.#C(V))X=!1,this.#M(V)}}}while(!X&&++Q<10)}this.#j=void 0}#U(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#v(Q,X,Z=!1){let V=!1,$="",J=!1,z=!1;for(let Y=0;Y<Q.length;Y++){let K=Q.charAt(Y);if(V){V=!1,$+=(d7.has(K)?"\\":"")+K;continue}if(K==="*"){if(z)continue;z=!0,$+=Z&&/^[*]+$/.test(Q)?$6:V6,X=!0;continue}else z=!1;if(K==="\\"){if(Y===Q.length-1)$+="\\\\";else V=!0;continue}if(K==="["){let[q,W,H,j]=Q6(Q,Y);if(H){$+=q,J=J||W,Y+=H-1,X=X||j;continue}}if(K==="?"){$+=v5,X=!0;continue}$+=c7(K)}return[$,n(Q),!!X,J]}}f=AQ;var UQ=(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 E=(Q,X,Z={})=>{if(RQ(X),!Z.nocomment&&X.charAt(0)==="#")return!1;return new d(X,Z).match(Q)},p7=/^\*+([^+@!?\*\[\(]*)$/,i7=(Q)=>(X)=>!X.startsWith(".")&&X.endsWith(Q),n7=(Q)=>(X)=>X.endsWith(Q),o7=(Q)=>{return Q=Q.toLowerCase(),(X)=>!X.startsWith(".")&&X.toLowerCase().endsWith(Q)},a7=(Q)=>{return Q=Q.toLowerCase(),(X)=>X.toLowerCase().endsWith(Q)},r7=/^\*+\.\*+$/,s7=(Q)=>!Q.startsWith(".")&&Q.includes("."),e7=(Q)=>Q!=="."&&Q!==".."&&Q.includes("."),t7=/^\.\*+$/,Q8=(Q)=>Q!=="."&&Q!==".."&&Q.startsWith("."),X8=/^\*+$/,Z8=(Q)=>Q.length!==0&&!Q.startsWith("."),V8=(Q)=>Q.length!==0&&Q!=="."&&Q!=="..",$8=/^\?+([^+@!?\*\[\(]*)?$/,J8=([Q,X=""])=>{let Z=Y6([Q]);if(!X)return Z;return X=X.toLowerCase(),(V)=>Z(V)&&V.toLowerCase().endsWith(X)},z8=([Q,X=""])=>{let Z=K6([Q]);if(!X)return Z;return X=X.toLowerCase(),(V)=>Z(V)&&V.toLowerCase().endsWith(X)},Y8=([Q,X=""])=>{let Z=K6([Q]);return!X?Z:(V)=>Z(V)&&V.endsWith(X)},K8=([Q,X=""])=>{let Z=Y6([Q]);return!X?Z:(V)=>Z(V)&&V.endsWith(X)},Y6=([Q])=>{let X=Q.length;return(Z)=>Z.length===X&&!Z.startsWith(".")},K6=([Q])=>{let X=Q.length;return(Z)=>Z.length===X&&Z!=="."&&Z!==".."},q6=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",J6={win32:{sep:"\\"},posix:{sep:"/"}},q8=q6==="win32"?J6.win32.sep:J6.posix.sep;E.sep=q8;var O=Symbol("globstar **");E.GLOBSTAR=O;var H8="[^/]",W8=H8+"*?",j8="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",_8="(?:(?!(?:\\/|^)\\.).)*?",G8=(Q,X={})=>(Z)=>E(Z,Q,X);E.filter=G8;var m=(Q,X={})=>Object.assign({},Q,X),w8=(Q)=>{if(!Q||typeof Q!=="object"||!Object.keys(Q).length)return E;let X=E;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,z={}){super($,J,m(Q,z))}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})};E.defaults=w8;var H6=(Q,X={})=>{if(RQ(Q),X.nobrace||!/\{(?:(?!\{).)*\}/.test(Q))return[Q];return e5(Q,{max:X.braceExpandMax})};E.braceExpand=H6;var A8=(Q,X={})=>new d(Q,X).makeRe();E.makeRe=A8;var U8=(Q,X,Z={})=>{let V=new d(X,Z);if(Q=Q.filter(($)=>V.match($)),V.options.nonull&&!Q.length)Q.push(X);return Q};E.match=U8;var z6=/[?*]|[+@!]\(.*?\)|\[|\]/,B8=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class d{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(Q,X={}){RQ(Q),X=X||{},this.options=X,this.maxGlobstarRecursion=X.maxGlobstarRecursion??200,this.pattern=Q,this.platform=X.platform||q6,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,z)=>{if(this.isWindows&&this.windowsNoMagicRoot){let Y=$[0]===""&&$[1]===""&&($[2]==="?"||!z6.test($[2]))&&!z6.test($[3]),K=/^[a-z]:/i.test($[0]);if(Y)return[...$.slice(0,4),...$.slice(4).map((q)=>this.parse(q))];else if(K)return[$[0],...$.slice(1).map((q)=>this.parse(q))]}return $.map((Y)=>this.parse(Y))});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 z=Z[V+1],Y=Z[V+2],K=Z[V+3];if(z!=="..")continue;if(!Y||Y==="."||Y===".."||!K||K==="."||K==="..")continue;X=!0,Z.splice(V,1);let q=Z.slice(0);q[V]="**",Q.push(q),V--}if(!this.preserveMultipleSlashes){for(let J=1;J<Z.length-1;J++){let z=Z[J];if(J===1&&z===""&&Z[0]==="")continue;if(z==="."||z==="")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 Y=$===1&&Z[$+1]==="**"?["."]:[];if(Z.splice($-1,2,...Y),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=[],z="";while(V<Q.length&&$<X.length)if(Q[V]===X[$])J.push(z==="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(z==="b")return!1;z="a",J.push(Q[V]),V++,$++}else if(X[$]==="*"&&Q[V]&&(this.options.dot||!Q[V].startsWith("."))&&Q[V]!=="**"){if(z==="a")return!1;z="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 z=typeof Q[0]==="string"&&/^[a-z]:$/i.test(Q[0]),Y=!z&&Q[0]===""&&Q[1]===""&&Q[2]==="?"&&/^[a-z]:$/i.test(Q[3]),K=typeof X[0]==="string"&&/^[a-z]:$/i.test(X[0]),q=!K&&X[0]===""&&X[1]===""&&X[2]==="?"&&typeof X[3]==="string"&&/^[a-z]:$/i.test(X[3]),W=Y?3:z?0:void 0,H=q?3:K?0:void 0;if(typeof W==="number"&&typeof H==="number"){let[j,_]=[Q[W],X[H]];if(j.toLowerCase()===_.toLowerCase())X[H]=j,$=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,$),z=X.lastIndexOf(O),[Y,K,q]=Z?[X.slice($,J),X.slice(J+1),[]]:[X.slice($,J),X.slice(J+1,z),X.slice(z+1)];if(Y.length){let A=Q.slice(V,V+Y.length);if(!this.#$(A,Y,Z,0,0))return!1;V+=Y.length,$+=Y.length}let W=0;if(q.length){if(q.length+V>Q.length)return!1;let A=Q.length-q.length;if(this.#$(Q,q,Z,A,0))W=q.length;else{if(Q[Q.length-1]!==""||V+q.length===Q.length)return!1;if(A--,!this.#$(Q,q,Z,A,0))return!1;W=q.length+1}}if(!K.length){let A=!!W;for(let B=V;B<Q.length-W;B++){let F=String(Q[B]);if(A=!0,F==="."||F===".."||!this.options.dot&&F.startsWith("."))return!1}return Z||A}let H=[[[],0]],j=H[0],_=0,G=[0];for(let A of K)if(A===O)G.push(_),j=[[],0],H.push(j);else j[0].push(A),_++;let w=H.length-1,U=Q.length-W;for(let A of H)A[1]=U-(G[w--]+A[0].length);return!!this.#V(Q,H,V,0,Z,0,!!W)}#V(Q,X,Z,V,$,J,z){let Y=X[V];if(!Y){for(let W=Z;W<Q.length;W++){z=!0;let H=Q[W];if(H==="."||H===".."||!this.options.dot&&H.startsWith("."))return!1}return z}let[K,q]=Y;while(Z<=q){if(this.#$(Q.slice(0,Z+K.length),K,$,Z,0)&&J<this.maxGlobstarRecursion){let j=this.#V(Q,X,Z+K.length,V+1,$,J+1,z);if(j!==!1)return j}let H=Q[Z];if(H==="."||H===".."||!this.options.dot&&H.startsWith("."))return!1;Z++}return $||null}#$(Q,X,Z,V,$){let J,z,Y,K;for(J=V,z=$,K=Q.length,Y=X.length;J<K&&z<Y;J++,z++){this.debug("matchOne loop");let q=X[z],W=Q[J];if(this.debug(X,q,W),q===!1||q===O)return!1;let H;if(typeof q==="string")H=W===q,this.debug("string match",q,W,H);else H=q.test(W),this.debug("pattern match",q,W,H);if(!H)return!1}if(J===K&&z===Y)return!0;else if(J===K)return Z;else if(z===Y)return J===K-1&&Q[J]==="";else throw Error("wtf?")}braceExpand(){return H6(this.pattern,this.options)}parse(Q){RQ(Q);let X=this.options;if(Q==="**")return O;if(Q==="")return"";let Z,V=null;if(Z=Q.match(X8))V=X.dot?V8:Z8;else if(Z=Q.match(p7))V=(X.nocase?X.dot?a7:o7:X.dot?n7:i7)(Z[1]);else if(Z=Q.match($8))V=(X.nocase?X.dot?z8:J8:X.dot?Y8:K8)(Z);else if(Z=Q.match(r7))V=X.dot?e7:s7;else if(Z=Q.match(t7))V=Q8;let $=AQ.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?W8:X.dot?j8:_8,V=new Set(X.nocase?["i"]:[]),$=Q.map((Y)=>{let K=Y.map((W)=>{if(W instanceof RegExp)for(let H of W.flags.split(""))V.add(H);return typeof W==="string"?B8(W):W===O?O:W._src});K.forEach((W,H)=>{let j=K[H+1],_=K[H-1];if(W!==O||_===O)return;if(_===void 0)if(j!==void 0&&j!==O)K[H+1]="(?:\\/|"+Z+"\\/)?"+j;else K[H]=Z;else if(j===void 0)K[H-1]=_+"(?:\\/|\\/"+Z+")?";else if(j!==O)K[H-1]=_+"(?:\\/|\\/"+Z+"\\/)"+j,K[H+1]=O});let q=K.filter((W)=>W!==O);if(this.partial&&q.length>=1){let W=[];for(let H=1;H<=q.length;H++)W.push(q.slice(0,H).join("/"));return"(?:"+W.join("|")+")"}return q.join("/")}).join("|"),[J,z]=Q.length>1?["(?:",")"]:["",""];if($="^"+J+$+z+"$",this.partial)$="^(?:\\/|"+J+$.slice(1,-1)+z+")$";if(this.negate)$="^(?!"+$+").+$";try{this.regexp=new RegExp($,[...V].join(""))}catch(Y){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 z=V.length-2;!J&&z>=0;z--)J=V[z];for(let z=0;z<$.length;z++){let Y=$[z],K=V;if(Z.matchBase&&Y.length===1)K=[J];if(this.matchOne(K,Y,X)){if(Z.flipNegate)return!0;return!this.negate}}if(Z.flipNegate)return!1;return this.negate}static defaults(Q){return E.defaults(Q).Minimatch}}E.AST=AQ;E.Minimatch=d;E.escape=UQ;E.unescape=n;import{fileURLToPath as e8}from"url";var L8=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,j6=new Set,F5=typeof process=="object"&&process?process:{},_6=(Q,X,Z,V)=>{typeof F5.emitWarning=="function"?F5.emitWarning(Q,X,Z,V):console.error(`[${Z}] ${X}: ${Q}`)},nQ=globalThis.AbortController,W6=globalThis.AbortSignal;if(typeof nQ>"u"){W6=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(Z,V){this._onabort.push(V)}},nQ=class{constructor(){X()}signal=new W6;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=F5.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",X=()=>{Q&&(Q=!1,_6("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 v8=(Q)=>!j6.has(Q),_0=Symbol("type"),HQ=(Q)=>Q&&Q===Math.floor(Q)&&Q>0&&isFinite(Q),G6=(Q)=>HQ(Q)?Q<=Math.pow(2,8)?Uint8Array:Q<=Math.pow(2,16)?Uint16Array:Q<=Math.pow(2,32)?Uint32Array:Q<=Number.MAX_SAFE_INTEGER?iQ:null:null,iQ=class extends Array{constructor(Q){super(Q),this.fill(0)}},F8=class Q{heap;length;static#Q=!1;static create(X){let Z=G6(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]}},PQ=class Q{#Q;#V;#$;#X;#z;#O;#B;#W;get perf(){return this.#W}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#Y;#j;#H;#K;#J;#L;#F;#G;#w;#k;#A;#C;#M;#_;#U;#v;#P;#Z;#E;static unsafeExposeInternals(X){return{starts:X.#M,ttls:X.#_,autopurgeTimers:X.#U,sizes:X.#C,keyMap:X.#H,keyList:X.#K,valList:X.#J,next:X.#L,prev:X.#F,get head(){return X.#G},get tail(){return X.#w},free:X.#k,isBackgroundFetch:(Z)=>X.#q(Z),backgroundFetch:(Z,V,$,J)=>X.#d(Z,V,$,J),moveToTail:(Z)=>X.#y(Z),indexes:(Z)=>X.#N(Z),rindexes:(Z)=>X.#I(Z),isStale:(Z)=>X.#R(Z)}}get max(){return this.#Q}get maxSize(){return this.#V}get calculatedSize(){return this.#j}get size(){return this.#Y}get fetchMethod(){return this.#O}get memoMethod(){return this.#B}get dispose(){return this.#$}get onInsert(){return this.#X}get disposeAfter(){return this.#z}constructor(X){let{max:Z=0,ttl:V,ttlResolution:$=1,ttlAutopurge:J,updateAgeOnGet:z,updateAgeOnHas:Y,allowStale:K,dispose:q,onInsert:W,disposeAfter:H,noDisposeOnSet:j,noUpdateTTL:_,maxSize:G=0,maxEntrySize:w=0,sizeCalculation:U,fetchMethod:A,memoMethod:B,noDeleteOnFetchRejection:F,noDeleteOnStaleGet:v,allowStaleOnFetchRejection:L,allowStaleOnFetchAbort:R,ignoreFetchAbort:I,perf:p}=X;if(p!==void 0&&typeof p?.now!="function")throw TypeError("perf option must have a now() method if specified");if(this.#W=p??L8,Z!==0&&!HQ(Z))throw TypeError("max option must be a nonnegative integer");let k=Z?G6(Z):Array;if(!k)throw Error("invalid max value: "+Z);if(this.#Q=Z,this.#V=G,this.maxEntrySize=w||this.#V,this.sizeCalculation=U,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,A!==void 0&&typeof A!="function")throw TypeError("fetchMethod must be a function if specified");if(this.#O=A,this.#P=!!A,this.#H=new Map,this.#K=Array(Z).fill(void 0),this.#J=Array(Z).fill(void 0),this.#L=new k(Z),this.#F=new k(Z),this.#G=0,this.#w=0,this.#k=F8.create(Z),this.#Y=0,this.#j=0,typeof q=="function"&&(this.#$=q),typeof W=="function"&&(this.#X=W),typeof H=="function"?(this.#z=H,this.#A=[]):(this.#z=void 0,this.#A=void 0),this.#v=!!this.#$,this.#E=!!this.#X,this.#Z=!!this.#z,this.noDisposeOnSet=!!j,this.noUpdateTTL=!!_,this.noDeleteOnFetchRejection=!!F,this.allowStaleOnFetchRejection=!!L,this.allowStaleOnFetchAbort=!!R,this.ignoreFetchAbort=!!I,this.maxEntrySize!==0){if(this.#V!==0&&!HQ(this.#V))throw TypeError("maxSize must be a positive integer if specified");if(!HQ(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#l()}if(this.allowStale=!!K,this.noDeleteOnStaleGet=!!v,this.updateAgeOnGet=!!z,this.updateAgeOnHas=!!Y,this.ttlResolution=HQ($)||$===0?$:1,this.ttlAutopurge=!!J,this.ttl=V||0,this.ttl){if(!HQ(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 i="LRU_CACHE_UNBOUNDED";v8(i)&&(j6.add(i),_6("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",i,Q))}}getRemainingTTL(X){return this.#H.has(X)?1/0:0}#S(){let X=new iQ(this.#Q),Z=new iQ(this.#Q);this.#_=X,this.#M=Z;let V=this.ttlAutopurge?Array(this.#Q):void 0;this.#U=V,this.#u=(z,Y,K=this.#W.now())=>{if(Z[z]=Y!==0?K:0,X[z]=Y,V?.[z]&&(clearTimeout(V[z]),V[z]=void 0),Y!==0&&V){let q=setTimeout(()=>{this.#R(z)&&this.#D(this.#K[z],"expire")},Y+1);q.unref&&q.unref(),V[z]=q}},this.#x=(z)=>{Z[z]=X[z]!==0?this.#W.now():0},this.#T=(z,Y)=>{if(X[Y]){let K=X[Y],q=Z[Y];if(!K||!q)return;z.ttl=K,z.start=q,z.now=$||J();let W=z.now-q;z.remainingTTL=K-W}};let $=0,J=()=>{let z=this.#W.now();if(this.ttlResolution>0){$=z;let Y=setTimeout(()=>$=0,this.ttlResolution);Y.unref&&Y.unref()}return z};this.getRemainingTTL=(z)=>{let Y=this.#H.get(z);if(Y===void 0)return 0;let K=X[Y],q=Z[Y];if(!K||!q)return 1/0;let W=($||J())-q;return K-W},this.#R=(z)=>{let Y=Z[z],K=X[z];return!!K&&!!Y&&($||J())-Y>K}}#x=()=>{};#T=()=>{};#u=()=>{};#R=()=>!1;#l(){let X=new iQ(this.#Q);this.#j=0,this.#C=X,this.#f=(Z)=>{this.#j-=X[Z],X[Z]=0},this.#h=(Z,V,$,J)=>{if(this.#q(V))return 0;if(!HQ($))if(J){if(typeof J!="function")throw TypeError("sizeCalculation must be a function");if($=J(V,Z),!HQ($))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.#m(!0)}this.#j+=X[Z],$&&($.entrySize=V,$.totalCalculatedSize=this.#j)}}#f=(X)=>{};#b=(X,Z,V)=>{};#h=(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.#Y)for(let Z=this.#w;!(!this.#g(Z)||((X||!this.#R(Z))&&(yield Z),Z===this.#G));)Z=this.#F[Z]}*#I({allowStale:X=this.allowStale}={}){if(this.#Y)for(let Z=this.#G;!(!this.#g(Z)||((X||!this.#R(Z))&&(yield Z),Z===this.#w));)Z=this.#L[Z]}#g(X){return X!==void 0&&this.#H.get(this.#K[X])===X}*entries(){for(let X of this.#N())this.#J[X]!==void 0&&this.#K[X]!==void 0&&!this.#q(this.#J[X])&&(yield[this.#K[X],this.#J[X]])}*rentries(){for(let X of this.#I())this.#J[X]!==void 0&&this.#K[X]!==void 0&&!this.#q(this.#J[X])&&(yield[this.#K[X],this.#J[X]])}*keys(){for(let X of this.#N()){let Z=this.#K[X];Z!==void 0&&!this.#q(this.#J[X])&&(yield Z)}}*rkeys(){for(let X of this.#I()){let Z=this.#K[X];Z!==void 0&&!this.#q(this.#J[X])&&(yield Z)}}*values(){for(let X of this.#N())this.#J[X]!==void 0&&!this.#q(this.#J[X])&&(yield this.#J[X])}*rvalues(){for(let X of this.#I())this.#J[X]!==void 0&&!this.#q(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.#q($)?$.__staleWhileFetching:$;if(J!==void 0&&X(J,this.#K[V],this))return this.get(this.#K[V],Z)}}forEach(X,Z=this){for(let V of this.#N()){let $=this.#J[V],J=this.#q($)?$.__staleWhileFetching:$;J!==void 0&&X.call(Z,J,this.#K[V],this)}}rforEach(X,Z=this){for(let V of this.#I()){let $=this.#J[V],J=this.#q($)?$.__staleWhileFetching:$;J!==void 0&&X.call(Z,J,this.#K[V],this)}}purgeStale(){let X=!1;for(let Z of this.#I({allowStale:!0}))this.#R(Z)&&(this.#D(this.#K[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.#q(V)?V.__staleWhileFetching:V;if($===void 0)return;let J={value:$};if(this.#_&&this.#M){let z=this.#_[Z],Y=this.#M[Z];if(z&&Y){let K=z-(this.#W.now()-Y);J.ttl=K,J.start=Date.now()}}return this.#C&&(J.size=this.#C[Z]),J}dump(){let X=[];for(let Z of this.#N({allowStale:!0})){let V=this.#K[Z],$=this.#J[Z],J=this.#q($)?$.__staleWhileFetching:$;if(J===void 0||V===void 0)continue;let z={value:J};if(this.#_&&this.#M){z.ttl=this.#_[Z];let Y=this.#W.now()-this.#M[Z];z.start=Math.floor(Date.now()-Y)}this.#C&&(z.size=this.#C[Z]),X.unshift([V,z])}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:z=this.noDisposeOnSet,sizeCalculation:Y=this.sizeCalculation,status:K}=V,{noUpdateTTL:q=this.noUpdateTTL}=V,W=this.#h(X,Z,V.size||0,Y);if(this.maxEntrySize&&W>this.maxEntrySize)return K&&(K.set="miss",K.maxEntrySizeExceeded=!0),this.#D(X,"set"),this;let H=this.#Y===0?void 0:this.#H.get(X);if(H===void 0)H=this.#Y===0?this.#w:this.#k.length!==0?this.#k.pop():this.#Y===this.#Q?this.#m(!1):this.#Y,this.#K[H]=X,this.#J[H]=Z,this.#H.set(X,H),this.#L[this.#w]=H,this.#F[H]=this.#w,this.#w=H,this.#Y++,this.#b(H,W,K),K&&(K.set="add"),q=!1,this.#E&&this.#X?.(Z,X,"add");else{this.#y(H);let j=this.#J[H];if(Z!==j){if(this.#P&&this.#q(j)){j.__abortController.abort(Error("replaced"));let{__staleWhileFetching:_}=j;_!==void 0&&!z&&(this.#v&&this.#$?.(_,X,"set"),this.#Z&&this.#A?.push([_,X,"set"]))}else z||(this.#v&&this.#$?.(j,X,"set"),this.#Z&&this.#A?.push([j,X,"set"]));if(this.#f(H),this.#b(H,W,K),this.#J[H]=Z,K){K.set="replace";let _=j&&this.#q(j)?j.__staleWhileFetching:j;_!==void 0&&(K.oldValue=_)}}else K&&(K.set="update");this.#E&&this.onInsert?.(Z,X,Z===j?"update":"replace")}if($!==0&&!this.#_&&this.#S(),this.#_&&(q||this.#u(H,$,J),K&&this.#T(K,H)),!z&&this.#Z&&this.#A){let j=this.#A,_;for(;_=j?.shift();)this.#z?.(..._)}return this}pop(){try{for(;this.#Y;){let X=this.#J[this.#G];if(this.#m(!0),this.#q(X)){if(X.__staleWhileFetching)return X.__staleWhileFetching}else if(X!==void 0)return X}}finally{if(this.#Z&&this.#A){let X=this.#A,Z;for(;Z=X?.shift();)this.#z?.(...Z)}}}#m(X){let Z=this.#G,V=this.#K[Z],$=this.#J[Z];return this.#P&&this.#q($)?$.__abortController.abort(Error("evicted")):(this.#v||this.#Z)&&(this.#v&&this.#$?.($,V,"evict"),this.#Z&&this.#A?.push([$,V,"evict"])),this.#f(Z),this.#U?.[Z]&&(clearTimeout(this.#U[Z]),this.#U[Z]=void 0),X&&(this.#K[Z]=void 0,this.#J[Z]=void 0,this.#k.push(Z)),this.#Y===1?(this.#G=this.#w=0,this.#k.length=0):this.#G=this.#L[Z],this.#H.delete(V),this.#Y--,Z}has(X,Z={}){let{updateAgeOnHas:V=this.updateAgeOnHas,status:$}=Z,J=this.#H.get(X);if(J!==void 0){let z=this.#J[J];if(this.#q(z)&&z.__staleWhileFetching===void 0)return!1;if(this.#R(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.#R($))return;let J=this.#J[$];return this.#q(J)?J.__staleWhileFetching:J}#d(X,Z,V,$){let J=Z===void 0?void 0:this.#J[Z];if(this.#q(J))return J;let z=new nQ,{signal:Y}=V;Y?.addEventListener("abort",()=>z.abort(Y.reason),{signal:z.signal});let K={signal:z.signal,options:V,context:$},q=(w,U=!1)=>{let{aborted:A}=z.signal,B=V.ignoreFetchAbort&&w!==void 0,F=V.ignoreFetchAbort||!!(V.allowStaleOnFetchAbort&&w!==void 0);if(V.status&&(A&&!U?(V.status.fetchAborted=!0,V.status.fetchError=z.signal.reason,B&&(V.status.fetchAbortIgnored=!0)):V.status.fetchResolved=!0),A&&!B&&!U)return H(z.signal.reason,F);let v=_,L=this.#J[Z];return(L===_||B&&U&&L===void 0)&&(w===void 0?v.__staleWhileFetching!==void 0?this.#J[Z]=v.__staleWhileFetching:this.#D(X,"fetch"):(V.status&&(V.status.fetchUpdated=!0),this.set(X,w,K.options))),w},W=(w)=>(V.status&&(V.status.fetchRejected=!0,V.status.fetchError=w),H(w,!1)),H=(w,U)=>{let{aborted:A}=z.signal,B=A&&V.allowStaleOnFetchAbort,F=B||V.allowStaleOnFetchRejection,v=F||V.noDeleteOnFetchRejection,L=_;if(this.#J[Z]===_&&(!v||!U&&L.__staleWhileFetching===void 0?this.#D(X,"fetch"):B||(this.#J[Z]=L.__staleWhileFetching)),F)return V.status&&L.__staleWhileFetching!==void 0&&(V.status.returnedStale=!0),L.__staleWhileFetching;if(L.__returned===L)throw w},j=(w,U)=>{let A=this.#O?.(X,J,K);A&&A instanceof Promise&&A.then((B)=>w(B===void 0?void 0:B),U),z.signal.addEventListener("abort",()=>{(!V.ignoreFetchAbort||V.allowStaleOnFetchAbort)&&(w(void 0),V.allowStaleOnFetchAbort&&(w=(B)=>q(B,!0)))})};V.status&&(V.status.fetchDispatched=!0);let _=new Promise(j).then(q,W),G=Object.assign(_,{__abortController:z,__staleWhileFetching:J,__returned:void 0});return Z===void 0?(this.set(X,G,{...K.options,status:void 0}),Z=this.#H.get(X)):this.#J[Z]=G,G}#q(X){if(!this.#P)return!1;let Z=X;return!!Z&&Z instanceof Promise&&Z.hasOwnProperty("__staleWhileFetching")&&Z.__abortController instanceof nQ}async fetch(X,Z={}){let{allowStale:V=this.allowStale,updateAgeOnGet:$=this.updateAgeOnGet,noDeleteOnStaleGet:J=this.noDeleteOnStaleGet,ttl:z=this.ttl,noDisposeOnSet:Y=this.noDisposeOnSet,size:K=0,sizeCalculation:q=this.sizeCalculation,noUpdateTTL:W=this.noUpdateTTL,noDeleteOnFetchRejection:H=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:j=this.allowStaleOnFetchRejection,ignoreFetchAbort:_=this.ignoreFetchAbort,allowStaleOnFetchAbort:G=this.allowStaleOnFetchAbort,context:w,forceRefresh:U=!1,status:A,signal:B}=Z;if(!this.#P)return A&&(A.fetch="get"),this.get(X,{allowStale:V,updateAgeOnGet:$,noDeleteOnStaleGet:J,status:A});let F={allowStale:V,updateAgeOnGet:$,noDeleteOnStaleGet:J,ttl:z,noDisposeOnSet:Y,size:K,sizeCalculation:q,noUpdateTTL:W,noDeleteOnFetchRejection:H,allowStaleOnFetchRejection:j,allowStaleOnFetchAbort:G,ignoreFetchAbort:_,status:A,signal:B},v=this.#H.get(X);if(v===void 0){A&&(A.fetch="miss");let L=this.#d(X,v,F,w);return L.__returned=L}else{let L=this.#J[v];if(this.#q(L)){let k=V&&L.__staleWhileFetching!==void 0;return A&&(A.fetch="inflight",k&&(A.returnedStale=!0)),k?L.__staleWhileFetching:L.__returned=L}let R=this.#R(v);if(!U&&!R)return A&&(A.fetch="hit"),this.#y(v),$&&this.#x(v),A&&this.#T(A,v),L;let I=this.#d(X,v,F,w),p=I.__staleWhileFetching!==void 0&&V;return A&&(A.fetch=R?"stale":"refresh",p&&R&&(A.returnedStale=!0)),p?I.__staleWhileFetching:I.__returned=I}}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,...z}=Z,Y=this.get(X,z);if(!J&&Y!==void 0)return Y;let K=V(X,Y,{options:z,context:$});return this.set(X,K,z),K}get(X,Z={}){let{allowStale:V=this.allowStale,updateAgeOnGet:$=this.updateAgeOnGet,noDeleteOnStaleGet:J=this.noDeleteOnStaleGet,status:z}=Z,Y=this.#H.get(X);if(Y!==void 0){let K=this.#J[Y],q=this.#q(K);return z&&this.#T(z,Y),this.#R(Y)?(z&&(z.get="stale"),q?(z&&V&&K.__staleWhileFetching!==void 0&&(z.returnedStale=!0),V?K.__staleWhileFetching:void 0):(J||this.#D(X,"expire"),z&&V&&(z.returnedStale=!0),V?K:void 0)):(z&&(z.get="hit"),q?K.__staleWhileFetching:(this.#y(Y),$&&this.#x(Y),K))}else z&&(z.get="miss")}#c(X,Z){this.#F[Z]=X,this.#L[X]=Z}#y(X){X!==this.#w&&(X===this.#G?this.#G=this.#L[X]:this.#c(this.#F[X],this.#L[X]),this.#c(this.#w,X),this.#w=X)}delete(X){return this.#D(X,"delete")}#D(X,Z){let V=!1;if(this.#Y!==0){let $=this.#H.get(X);if($!==void 0)if(this.#U?.[$]&&(clearTimeout(this.#U?.[$]),this.#U[$]=void 0),V=!0,this.#Y===1)this.#p(Z);else{this.#f($);let J=this.#J[$];if(this.#q(J)?J.__abortController.abort(Error("deleted")):(this.#v||this.#Z)&&(this.#v&&this.#$?.(J,X,Z),this.#Z&&this.#A?.push([J,X,Z])),this.#H.delete(X),this.#K[$]=void 0,this.#J[$]=void 0,$===this.#w)this.#w=this.#F[$];else if($===this.#G)this.#G=this.#L[$];else{let z=this.#F[$];this.#L[z]=this.#L[$];let Y=this.#L[$];this.#F[Y]=this.#F[$]}this.#Y--,this.#k.push($)}}if(this.#Z&&this.#A?.length){let $=this.#A,J;for(;J=$?.shift();)this.#z?.(...J)}return V}clear(){return this.#p("delete")}#p(X){for(let Z of this.#I({allowStale:!0})){let V=this.#J[Z];if(this.#q(V))V.__abortController.abort(Error("deleted"));else{let $=this.#K[Z];this.#v&&this.#$?.(V,$,X),this.#Z&&this.#A?.push([V,$,X])}}if(this.#H.clear(),this.#J.fill(void 0),this.#K.fill(void 0),this.#_&&this.#M){this.#_.fill(0),this.#M.fill(0);for(let Z of this.#U??[])Z!==void 0&&clearTimeout(Z);this.#U?.fill(void 0)}if(this.#C&&this.#C.fill(0),this.#G=0,this.#w=0,this.#k.length=0,this.#j=0,this.#Y=0,this.#Z&&this.#A){let Z=this.#A,V;for(;V=Z?.shift();)this.#z?.(...V)}}};import{posix as S8,win32 as I5}from"path";import{fileURLToPath as T8}from"url";import{lstatSync as E8,readdir as b8,readdirSync as y8,readlinkSync as f8,realpathSync as u8}from"fs";import*as h8 from"fs";import{lstat as m8,readdir as d8,readlink as c8,realpath as l8}from"fs/promises";import{EventEmitter as P5}from"events";import L6 from"stream";import{StringDecoder as C8}from"string_decoder";var w6=typeof process==="object"&&process?process:{stdout:null,stderr:null},O8=(Q)=>!!Q&&typeof Q==="object"&&(Q instanceof GQ||Q instanceof L6||M8(Q)||R8(Q)),M8=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof P5&&typeof Q.pipe==="function"&&Q.pipe!==L6.Writable.prototype.pipe,R8=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof P5&&typeof Q.write==="function"&&typeof Q.end==="function",$Q=Symbol("EOF"),JQ=Symbol("maybeEmitEnd"),WQ=Symbol("emittedEnd"),oQ=Symbol("emittingEnd"),xQ=Symbol("emittedError"),aQ=Symbol("closed"),A6=Symbol("read"),rQ=Symbol("flush"),U6=Symbol("flushChunk"),o=Symbol("encoding"),BQ=Symbol("decoder"),x=Symbol("flowing"),DQ=Symbol("paused"),LQ=Symbol("resume"),D=Symbol("buffer"),b=Symbol("pipes"),N=Symbol("bufferLength"),C5=Symbol("bufferPush"),sQ=Symbol("bufferShift"),T=Symbol("objectMode"),M=Symbol("destroyed"),O5=Symbol("error"),M5=Symbol("emitData"),B6=Symbol("emitEnd"),R5=Symbol("emitEnd2"),s=Symbol("async"),k5=Symbol("abort"),eQ=Symbol("aborted"),NQ=Symbol("signal"),_Q=Symbol("dataListeners"),u=Symbol("discarded"),IQ=(Q)=>Promise.resolve().then(Q),k8=(Q)=>Q(),P8=(Q)=>Q==="end"||Q==="finish"||Q==="prefinish",x8=(Q)=>Q instanceof ArrayBuffer||!!Q&&typeof Q==="object"&&Q.constructor&&Q.constructor.name==="ArrayBuffer"&&Q.byteLength>=0,D8=(Q)=>!Buffer.isBuffer(Q)&&ArrayBuffer.isView(Q);class x5{src;dest;opts;ondrain;constructor(Q,X,Z){this.src=Q,this.dest=X,this.opts=Z,this.ondrain=()=>Q[LQ](),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 v6 extends x5{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 N8=(Q)=>!!Q.objectMode,I8=(Q)=>!Q.objectMode&&!!Q.encoding&&Q.encoding!=="buffer";class GQ extends P5{[x]=!1;[DQ]=!1;[b]=[];[D]=[];[T];[o];[s];[BQ];[$Q]=!1;[WQ]=!1;[oQ]=!1;[aQ]=!1;[xQ]=null;[N]=0;[M]=!1;[NQ];[eQ]=!1;[_Q]=0;[u]=!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(N8(X))this[T]=!0,this[o]=null;else if(I8(X))this[o]=X.encoding,this[T]=!1;else this[T]=!1,this[o]=null;if(this[s]=!!X.async,this[BQ]=this[o]?new C8(this[o]):null,X&&X.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[D]});if(X&&X.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[b]});let{signal:Z}=X;if(Z)if(this[NQ]=Z,Z.aborted)this[k5]();else Z.addEventListener("abort",()=>this[k5]())}get bufferLength(){return this[N]}get encoding(){return this[o]}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[T]}set objectMode(Q){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[s]}set["async"](Q){this[s]=this[s]||!!Q}[k5](){this[eQ]=!0,this.emit("abort",this[NQ]?.reason),this.destroy(this[NQ]?.reason)}get aborted(){return this[eQ]}set aborted(Q){}write(Q,X,Z){if(this[eQ])return!1;if(this[$Q])throw Error("write after end");if(this[M])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof X==="function")Z=X,X="utf8";if(!X)X="utf8";let V=this[s]?IQ:k8;if(!this[T]&&!Buffer.isBuffer(Q)){if(D8(Q))Q=Buffer.from(Q.buffer,Q.byteOffset,Q.byteLength);else if(x8(Q))Q=Buffer.from(Q);else if(typeof Q!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[T]){if(this[x]&&this[N]!==0)this[rQ](!0);if(this[x])this.emit("data",Q);else this[C5](Q);if(this[N]!==0)this.emit("readable");if(Z)V(Z);return this[x]}if(!Q.length){if(this[N]!==0)this.emit("readable");if(Z)V(Z);return this[x]}if(typeof Q==="string"&&!(X===this[o]&&!this[BQ]?.lastNeed))Q=Buffer.from(Q,X);if(Buffer.isBuffer(Q)&&this[o])Q=this[BQ].write(Q);if(this[x]&&this[N]!==0)this[rQ](!0);if(this[x])this.emit("data",Q);else this[C5](Q);if(this[N]!==0)this.emit("readable");if(Z)V(Z);return this[x]}read(Q){if(this[M])return null;if(this[u]=!1,this[N]===0||Q===0||Q&&Q>this[N])return this[JQ](),null;if(this[T])Q=null;if(this[D].length>1&&!this[T])this[D]=[this[o]?this[D].join(""):Buffer.concat(this[D],this[N])];let X=this[A6](Q||null,this[D][0]);return this[JQ](),X}[A6](Q,X){if(this[T])this[sQ]();else{let Z=X;if(Q===Z.length||Q===null)this[sQ]();else if(typeof Z==="string")this[D][0]=Z.slice(Q),X=Z.slice(0,Q),this[N]-=Q;else this[D][0]=Z.subarray(Q),X=Z.subarray(0,Q),this[N]-=Q}if(this.emit("data",X),!this[D].length&&!this[$Q])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[$Q]=!0,this.writable=!1,this[x]||!this[DQ])this[JQ]();return this}[LQ](){if(this[M])return;if(!this[_Q]&&!this[b].length)this[u]=!0;if(this[DQ]=!1,this[x]=!0,this.emit("resume"),this[D].length)this[rQ]();else if(this[$Q])this[JQ]();else this.emit("drain")}resume(){return this[LQ]()}pause(){this[x]=!1,this[DQ]=!0,this[u]=!1}get destroyed(){return this[M]}get flowing(){return this[x]}get paused(){return this[DQ]}[C5](Q){if(this[T])this[N]+=1;else this[N]+=Q.length;this[D].push(Q)}[sQ](){if(this[T])this[N]-=1;else this[N]-=this[D][0].length;return this[D].shift()}[rQ](Q=!1){do;while(this[U6](this[sQ]())&&this[D].length);if(!Q&&!this[D].length&&!this[$Q])this.emit("drain")}[U6](Q){return this.emit("data",Q),this[x]}pipe(Q,X){if(this[M])return Q;this[u]=!1;let Z=this[WQ];if(X=X||{},Q===w6.stdout||Q===w6.stderr)X.end=!1;else X.end=X.end!==!1;if(X.proxyErrors=!!X.proxyErrors,Z){if(X.end)Q.end()}else if(this[b].push(!X.proxyErrors?new x5(this,Q,X):new v6(this,Q,X)),this[s])IQ(()=>this[LQ]());else this[LQ]();return Q}unpipe(Q){let X=this[b].find((Z)=>Z.dest===Q);if(X){if(this[b].length===1){if(this[x]&&this[_Q]===0)this[x]=!1;this[b]=[]}else this[b].splice(this[b].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[u]=!1,this[_Q]++,!this[b].length&&!this[x])this[LQ]()}else if(Q==="readable"&&this[N]!==0)super.emit("readable");else if(P8(Q)&&this[WQ])super.emit(Q),this.removeAllListeners(Q);else if(Q==="error"&&this[xQ]){let V=X;if(this[s])IQ(()=>V.call(this,this[xQ]));else V.call(this,this[xQ])}return Z}removeListener(Q,X){return this.off(Q,X)}off(Q,X){let Z=super.off(Q,X);if(Q==="data"){if(this[_Q]=this.listeners("data").length,this[_Q]===0&&!this[u]&&!this[b].length)this[x]=!1}return Z}removeAllListeners(Q){let X=super.removeAllListeners(Q);if(Q==="data"||Q===void 0){if(this[_Q]=0,!this[u]&&!this[b].length)this[x]=!1}return X}get emittedEnd(){return this[WQ]}[JQ](){if(!this[oQ]&&!this[WQ]&&!this[M]&&this[D].length===0&&this[$Q]){if(this[oQ]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[aQ])this.emit("close");this[oQ]=!1}}emit(Q,...X){let Z=X[0];if(Q!=="error"&&Q!=="close"&&Q!==M&&this[M])return!1;else if(Q==="data")return!this[T]&&!Z?!1:this[s]?(IQ(()=>this[M5](Z)),!0):this[M5](Z);else if(Q==="end")return this[B6]();else if(Q==="close"){if(this[aQ]=!0,!this[WQ]&&!this[M])return!1;let $=super.emit("close");return this.removeAllListeners("close"),$}else if(Q==="error"){this[xQ]=Z,super.emit(O5,Z);let $=!this[NQ]||this.listeners("error").length?super.emit("error",Z):!1;return this[JQ](),$}else if(Q==="resume"){let $=super.emit("resume");return this[JQ](),$}else if(Q==="finish"||Q==="prefinish"){let $=super.emit(Q);return this.removeAllListeners(Q),$}let V=super.emit(Q,...X);return this[JQ](),V}[M5](Q){for(let Z of this[b])if(Z.dest.write(Q)===!1)this.pause();let X=this[u]?!1:super.emit("data",Q);return this[JQ](),X}[B6](){if(this[WQ])return!1;return this[WQ]=!0,this.readable=!1,this[s]?(IQ(()=>this[R5]()),!0):this[R5]()}[R5](){if(this[BQ]){let X=this[BQ].end();if(X){for(let Z of this[b])Z.dest.write(X);if(!this[u])super.emit("data",X)}}for(let X of this[b])X.end();let Q=super.emit("end");return this.removeAllListeners("end"),Q}async collect(){let Q=Object.assign([],{dataLength:0});if(!this[T])Q.dataLength=0;let X=this.promise();return this.on("data",(Z)=>{if(Q.push(Z),!this[T])Q.dataLength+=Z.length}),await X,Q}async concat(){if(this[T])throw Error("cannot concat in objectMode");let Q=await this.collect();return this[o]?Q.join(""):Buffer.concat(Q,Q.dataLength)}async promise(){return new Promise((Q,X)=>{this.on(M,()=>X(Error("stream destroyed"))),this.on("error",(Z)=>X(Z)),this.on("end",()=>Q())})}[Symbol.asyncIterator](){this[u]=!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[$Q])return X();let $,J,z=(W)=>{this.off("data",Y),this.off("end",K),this.off(M,q),X(),J(W)},Y=(W)=>{this.off("error",z),this.off("end",K),this.off(M,q),this.pause(),$({value:W,done:!!this[$Q]})},K=()=>{this.off("error",z),this.off("data",Y),this.off(M,q),X(),$({done:!0,value:void 0})},q=()=>z(Error("stream destroyed"));return new Promise((W,H)=>{J=H,$=W,this.once(M,q),this.once("error",z),this.once("end",K),this.once("data",Y)})},throw:X,return:X,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[u]=!1;let Q=!1,X=()=>{return this.pause(),this.off(O5,X),this.off(M,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(O5,X),this.once(M,X),{next:Z,throw:X,return:X,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(Q){if(this[M]){if(Q)this.emit("error",Q);else this.emit(M);return this}this[M]=!0,this[u]=!0,this[D].length=0,this[N]=0;let X=this;if(typeof X.close==="function"&&!this[aQ])X.close();if(Q)this.emit("error",Q);else this.emit(M);return this}static get isStream(){return O8}}var g8=u8.native,TQ={lstatSync:E8,readdir:b8,readdirSync:y8,readlinkSync:f8,realpathSync:g8,promises:{lstat:m8,readdir:d8,readlink:c8,realpath:l8}},R6=(Q)=>!Q||Q===TQ||Q===h8?TQ:{...TQ,...Q,promises:{...TQ.promises,...Q.promises||{}}},k6=/^\\\\\?\\([a-z]:)\\?$/i,p8=(Q)=>Q.replace(/\//g,"\\").replace(k6,"$1\\"),i8=/[\\\/]/,l=0,P6=1,x6=2,e=4,D6=6,N6=8,wQ=10,I6=12,c=15,SQ=~c,D5=16,F6=32,EQ=64,a=128,tQ=256,X5=512,C6=EQ|a|X5,n8=1023,N5=(Q)=>Q.isFile()?N6:Q.isDirectory()?e:Q.isSymbolicLink()?wQ:Q.isCharacterDevice()?x6:Q.isBlockDevice()?D6:Q.isSocket()?I6:Q.isFIFO()?P6:l,O6=new PQ({max:4096}),bQ=(Q)=>{let X=O6.get(Q);if(X)return X;let Z=Q.normalize("NFKD");return O6.set(Q,Z),Z},M6=new PQ({max:4096}),Q5=(Q)=>{let X=M6.get(Q);if(X)return X;let Z=bQ(Q.toLowerCase());return M6.set(Q,Z),Z};class S5 extends PQ{constructor(){super({max:256})}}class S6 extends PQ{constructor(Q=16384){super({maxSize:Q,sizeCalculation:(X)=>X.length+1})}}var T6=Symbol("PathScurry setAsCwd");class y{name;root;roots;parent;nocase;isCWD=!1;#Q;#V;get dev(){return this.#V}#$;get mode(){return this.#$}#X;get nlink(){return this.#X}#z;get uid(){return this.#z}#O;get gid(){return this.#O}#B;get rdev(){return this.#B}#W;get blksize(){return this.#W}#Y;get ino(){return this.#Y}#j;get size(){return this.#j}#H;get blocks(){return this.#H}#K;get atimeMs(){return this.#K}#J;get mtimeMs(){return this.#J}#L;get ctimeMs(){return this.#L}#F;get birthtimeMs(){return this.#F}#G;get atime(){return this.#G}#w;get mtime(){return this.#w}#k;get ctime(){return this.#k}#A;get birthtime(){return this.#A}#C;#M;#_;#U;#v;#P;#Z;#E;#S;#x;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Q,X=l,Z,V,$,J,z){if(this.name=Q,this.#C=$?Q5(Q):bQ(Q),this.#Z=X&n8,this.nocase=$,this.roots=V,this.root=Z||this,this.#E=J,this.#_=z.fullpath,this.#v=z.relative,this.#P=z.relativePosix,this.parent=z.parent,this.parent)this.#Q=this.parent.#Q;else this.#Q=R6(z.fs)}depth(){if(this.#M!==void 0)return this.#M;if(!this.parent)return this.#M=0;return this.#M=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&=~D5,X}child(Q,X){if(Q===""||Q===".")return this;if(Q==="..")return this.parent||this;let Z=this.children(),V=this.nocase?Q5(Q):bQ(Q);for(let Y of Z)if(Y.#C===V)return Y;let $=this.parent?this.sep:"",J=this.#_?this.#_+$+Q:void 0,z=this.newChild(Q,l,{...X,parent:this,fullpath:J});if(!this.canReaddir())z.#Z|=a;return Z.push(z),z}relative(){if(this.isCWD)return"";if(this.#v!==void 0)return this.#v;let Q=this.name,X=this.parent;if(!X)return this.#v=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.#P!==void 0)return this.#P;let Q=this.name,X=this.parent;if(!X)return this.#P=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.#U!==void 0)return this.#U;if(this.sep==="/")return this.#U=this.fullpath();if(!this.parent){let V=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(V))return this.#U=`//?/${V}`;else return this.#U=V}let Q=this.parent,X=Q.fullpathPosix(),Z=X+(!X||!Q.parent?"":"/")+this.name;return this.#U=Z}isUnknown(){return(this.#Z&c)===l}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&c)===N6}isDirectory(){return(this.#Z&c)===e}isCharacterDevice(){return(this.#Z&c)===x6}isBlockDevice(){return(this.#Z&c)===D6}isFIFO(){return(this.#Z&c)===P6}isSocket(){return(this.#Z&c)===I6}isSymbolicLink(){return(this.#Z&wQ)===wQ}lstatCached(){return this.#Z&F6?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&c;return!(Q!==l&&Q!==wQ||this.#Z&tQ||this.#Z&a)}calledReaddir(){return!!(this.#Z&D5)}isENOENT(){return!!(this.#Z&a)}isNamed(Q){return!this.nocase?this.#C===bQ(Q):this.#C===Q5(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.#I(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.#I(X.code);return}}#u(Q){this.#Z|=D5;for(let X=Q.provisional;X<Q.length;X++){let Z=Q[X];if(Z)Z.#R()}}#R(){if(this.#Z&a)return;this.#Z=(this.#Z|a)&SQ,this.#l()}#l(){let Q=this.children();Q.provisional=0;for(let X of Q)X.#R()}#f(){this.#Z|=X5,this.#b()}#b(){if(this.#Z&EQ)return;let Q=this.#Z;if((Q&c)===e)Q&=SQ;this.#Z=Q|EQ,this.#l()}#h(Q=""){if(Q==="ENOTDIR"||Q==="EPERM")this.#b();else if(Q==="ENOENT")this.#R();else this.children().provisional=0}#N(Q=""){if(Q==="ENOTDIR")this.parent.#b();else if(Q==="ENOENT")this.#R()}#I(Q=""){let X=this.#Z;if(X|=tQ,Q==="ENOENT")X|=a;if(Q==="EINVAL"||Q==="UNKNOWN")X&=SQ;if(this.#Z=X,Q==="ENOTDIR"&&this.parent)this.parent.#b()}#g(Q,X){return this.#d(Q,X)||this.#m(Q,X)}#m(Q,X){let Z=N5(Q),V=this.newChild(Q.name,Z,{parent:this}),$=V.#Z&c;if($!==e&&$!==wQ&&$!==l)V.#Z|=EQ;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?Q5(Q.name):bQ(Q.name))!==V.#C)continue;return this.#q(Q,V,Z,X)}}#q(Q,X,Z,V){let $=X.name;if(X.#Z=X.#Z&SQ|N5(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&a)===0)try{return this.#c(await this.#Q.promises.lstat(this.fullpath())),this}catch(Q){this.#N(Q.code)}}lstatSync(){if((this.#Z&a)===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:z,ctime:Y,ctimeMs:K,dev:q,gid:W,ino:H,mode:j,mtime:_,mtimeMs:G,nlink:w,rdev:U,size:A,uid:B}=Q;this.#G=X,this.#K=Z,this.#A=V,this.#F=$,this.#W=J,this.#H=z,this.#k=Y,this.#L=K,this.#V=q,this.#O=W,this.#Y=H,this.#$=j,this.#w=_,this.#J=G,this.#X=w,this.#B=U,this.#j=A,this.#z=B;let F=N5(Q);if(this.#Z=this.#Z&SQ|F|F6,F!==l&&F!==e&&F!==wQ)this.#Z|=EQ}#y=[];#D=!1;#p(Q){this.#D=!1;let X=this.#y.slice();this.#y.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.#y.push(Q),this.#D)return;this.#D=!0;let V=this.fullpath();this.#Q.readdir(V,{withFileTypes:!0},($,J)=>{if($)this.#h($.code),Z.provisional=0;else{for(let z of J)this.#g(z,Z);this.#u(Z)}this.#p(Z.slice(0,Z.provisional));return})}#i;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.#i)await this.#i;else{let Z=()=>{};this.#i=new Promise((V)=>Z=V);try{for(let V of await this.#Q.promises.readdir(X,{withFileTypes:!0}))this.#g(V,Q);this.#u(Q)}catch(V){this.#h(V.code),Q.provisional=0}this.#i=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.#g(Z,Q);this.#u(Q)}catch(Z){this.#h(Z.code),Q.provisional=0}return Q.slice(0,Q.provisional)}canReaddir(){if(this.#Z&C6)return!1;let Q=c&this.#Z;if(!(Q===l||Q===e||Q===wQ))return!1;return!0}shouldWalk(Q,X){return(this.#Z&e)===e&&!(this.#Z&C6)&&!Q.has(this)&&(!X||X(this))}async realpath(){if(this.#x)return this.#x;if((X5|tQ|a)&this.#Z)return;try{let Q=await this.#Q.promises.realpath(this.fullpath());return this.#x=this.resolve(Q)}catch(Q){this.#f()}}realpathSync(){if(this.#x)return this.#x;if((X5|tQ|a)&this.#Z)return;try{let Q=this.#Q.realpathSync(this.fullpath());return this.#x=this.resolve(Q)}catch(Q){this.#f()}}[T6](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.#v=Z.join(this.sep),V.#P=Z.join("/"),V=V.parent,Z.push("..");V=Q;while(V&&V.parent&&!X.has(V))V.#v=void 0,V.#P=void 0,V=V.parent}}class Z5 extends y{sep="\\";splitSep=i8;constructor(Q,X=l,Z,V,$,J,z){super(Q,X,Z,V,$,J,z)}newChild(Q,X=l,Z={}){return new Z5(Q,X,this.root,this.roots,this.nocase,this.childrenCache(),Z)}getRootString(Q){return I5.parse(Q).root}getRoot(Q){if(Q=p8(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 yQ(Q,this).root}sameRoot(Q,X=this.root.name){return Q=Q.toUpperCase().replace(/\//g,"\\").replace(k6,"$1\\"),Q===X}}class V5 extends y{splitSep="/";sep="/";constructor(Q,X=l,Z,V,$,J,z){super(Q,X,Z,V,$,J,z)}getRootString(Q){return Q.startsWith("/")?"/":""}getRoot(Q){return this.root}newChild(Q,X=l,Z={}){return new V5(Q,X,this.root,this.roots,this.nocase,this.childrenCache(),Z)}}class T5{root;rootPath;roots;cwd;#Q;#V;#$;nocase;#X;constructor(Q=process.cwd(),X,Z,{nocase:V,childrenCacheSize:$=16384,fs:J=TQ}={}){if(this.#X=R6(J),Q instanceof URL||Q.startsWith("file://"))Q=T8(Q);let z=X.resolve(Q);this.roots=Object.create(null),this.rootPath=this.parseRootPath(z),this.#Q=new S5,this.#V=new S5,this.#$=new S6($);let Y=z.substring(this.rootPath.length).split(Z);if(Y.length===1&&!Y[0])Y.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 K=this.root,q=Y.length-1,W=X.sep,H=this.rootPath,j=!1;for(let _ of Y){let G=q--;K=K.child(_,{relative:Array(G).fill("..").join(W),relativePosix:Array(G).fill("..").join("/"),fullpath:H+=(j?"":W)+_}),j=!0}this.cwd=K}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 y))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 y))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 y))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 y))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 y))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 y))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 y))X=Q,Q=this.cwd;let{withFileTypes:Z=!0,follow:V=!1,filter:$,walkFilter:J}=X,z=[];if(!$||$(Q))z.push(Z?Q:Q.fullpath());let Y=new Set,K=(W,H)=>{Y.add(W),W.readdirCB((j,_)=>{if(j)return H(j);let G=_.length;if(!G)return H();let w=()=>{if(--G===0)H()};for(let U of _){if(!$||$(U))z.push(Z?U:U.fullpath());if(V&&U.isSymbolicLink())U.realpath().then((A)=>A?.isUnknown()?A.lstat():A).then((A)=>A?.shouldWalk(Y,J)?K(A,w):w());else if(U.shouldWalk(Y,J))K(U,w);else w()}},!0)},q=Q;return new Promise((W,H)=>{K(q,(j)=>{if(j)return H(j);W(z)})})}walkSync(Q=this.cwd,X={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof y))X=Q,Q=this.cwd;let{withFileTypes:Z=!0,follow:V=!1,filter:$,walkFilter:J}=X,z=[];if(!$||$(Q))z.push(Z?Q:Q.fullpath());let Y=new Set([Q]);for(let K of Y){let q=K.readdirSync();for(let W of q){if(!$||$(W))z.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(Y,J))Y.add(H)}}return z}[Symbol.asyncIterator](){return this.iterate()}iterate(Q=this.cwd,X={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof y))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 y))X=Q,Q=this.cwd;let{withFileTypes:Z=!0,follow:V=!1,filter:$,walkFilter:J}=X;if(!$||$(Q))yield Z?Q:Q.fullpath();let z=new Set([Q]);for(let Y of z){let K=Y.readdirSync();for(let q of K){if(!$||$(q))yield Z?q:q.fullpath();let W=q;if(q.isSymbolicLink()){if(!(V&&(W=q.realpathSync())))continue;if(W.isUnknown())W.lstatSync()}if(W.shouldWalk(z,J))z.add(W)}}}stream(Q=this.cwd,X={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof y))X=Q,Q=this.cwd;let{withFileTypes:Z=!0,follow:V=!1,filter:$,walkFilter:J}=X,z=new GQ({objectMode:!0});if(!$||$(Q))z.write(Z?Q:Q.fullpath());let Y=new Set,K=[Q],q=0,W=()=>{let H=!1;while(!H){let j=K.shift();if(!j){if(q===0)z.end();return}q++,Y.add(j);let _=(w,U,A=!1)=>{if(w)return z.emit("error",w);if(V&&!A){let B=[];for(let F of U)if(F.isSymbolicLink())B.push(F.realpath().then((v)=>v?.isUnknown()?v.lstat():v));if(B.length){Promise.all(B).then(()=>_(null,U,!0));return}}for(let B of U)if(B&&(!$||$(B))){if(!z.write(Z?B:B.fullpath()))H=!0}q--;for(let B of U){let F=B.realpathCached()||B;if(F.shouldWalk(Y,J))K.push(F)}if(H&&!z.flowing)z.once("drain",W);else if(!G)W()},G=!0;j.readdirCB(_,!0),G=!1}};return W(),z}streamSync(Q=this.cwd,X={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof y))X=Q,Q=this.cwd;let{withFileTypes:Z=!0,follow:V=!1,filter:$,walkFilter:J}=X,z=new GQ({objectMode:!0}),Y=new Set;if(!$||$(Q))z.write(Z?Q:Q.fullpath());let K=[Q],q=0,W=()=>{let H=!1;while(!H){let j=K.shift();if(!j){if(q===0)z.end();return}q++,Y.add(j);let _=j.readdirSync();for(let G of _)if(!$||$(G)){if(!z.write(Z?G:G.fullpath()))H=!0}q--;for(let G of _){let w=G;if(G.isSymbolicLink()){if(!(V&&(w=G.realpathSync())))continue;if(w.isUnknown())w.lstatSync()}if(w.shouldWalk(Y,J))K.push(w)}}if(H&&!z.flowing)z.once("drain",W)};return W(),z}chdir(Q=this.cwd){let X=this.cwd;this.cwd=typeof Q==="string"?this.cwd.resolve(Q):Q,this.cwd[T6](X)}}class yQ extends T5{sep="\\";constructor(Q=process.cwd(),X={}){let{nocase:Z=!0}=X;super(Q,I5,"\\",{...X,nocase:Z});this.nocase=Z;for(let V=this.cwd;V;V=V.parent)V.nocase=this.nocase}parseRootPath(Q){return I5.parse(Q).root.toUpperCase()}newRoot(Q){return new Z5(this.rootPath,e,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Q})}isAbsolute(Q){return Q.startsWith("/")||Q.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Q)}}class fQ extends T5{sep="/";constructor(Q=process.cwd(),X={}){let{nocase:Z=!1}=X;super(Q,S8,"/",{...X,nocase:Z});this.nocase=Z}parseRootPath(Q){return"/"}newRoot(Q){return new V5(this.rootPath,e,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Q})}isAbsolute(Q){return Q.startsWith("/")}}class $5 extends fQ{constructor(Q=process.cwd(),X={}){let{nocase:Z=!0}=X;super(Q,{...X,nocase:Z})}}var x0=process.platform==="win32"?Z5:V5,E6=process.platform==="win32"?yQ:process.platform==="darwin"?$5:fQ;var o8=(Q)=>Q.length>=1,a8=(Q)=>Q.length>=1;class vQ{#Q;#V;#$;length;#X;#z;#O;#B;#W;#Y;#j=!0;constructor(Q,X,Z,V){if(!o8(Q))throw TypeError("empty pattern list");if(!a8(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,z,Y,...K]=this.#Q,[q,W,H,j,..._]=this.#V;if(K[0]==="")K.shift(),_.shift();let G=[$,J,z,Y,""].join("/"),w=[q,W,H,j,""].join("/");this.#Q=[G,...K],this.#V=[w,..._],this.length=this.#Q.length}else if(this.isDrive()||this.isAbsolute()){let[$,...J]=this.#Q,[z,...Y]=this.#V;if(J[0]==="")J.shift(),Y.shift();let K=$+"/",q=z+"/";this.#Q=[K,...J],this.#V=[q,...Y],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.#z!==void 0)return this.#z;if(!this.hasMore())return this.#z=null;return this.#z=new vQ(this.#Q,this.#V,this.#$+1,this.#X),this.#z.#Y=this.#Y,this.#z.#W=this.#W,this.#z.#B=this.#B,this.#z}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.#Y!==void 0?this.#Y:this.#Y=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 r8=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class uQ{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Q,{nobrace:X,nocase:Z,noext:V,noglobstar:$,platform:J=r8}){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 z of Q)this.add(z)}add(Q){let X=new d(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 vQ(V,$,0,this.platform),z=new d(J.globString(),this.mmopts),Y=$[$.length-1]==="**",K=J.isAbsolute();if(K)this.absolute.push(z);else this.relative.push(z);if(Y)if(K)this.absoluteChildren.push(z);else this.relativeChildren.push(z)}}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 E5{store;constructor(Q=new Map){this.store=Q}copy(){return new E5(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 b6{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 hQ{hasWalkedCache;matches=new b6;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 E5}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(),z=$.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 Y,K,q=!1;while(typeof(Y=$.pattern())==="string"&&(K=$.rest()))V=V.resolve(Y),$=K,q=!0;if(Y=$.pattern(),K=$.rest(),q){if(this.hasWalkedCache.hasWalked(V,$))continue;this.hasWalkedCache.storeWalked(V,$)}if(typeof Y==="string"){let W=Y===".."||Y===""||Y===".";this.matches.add(V.resolve(Y),z,W);continue}else if(Y===O){if(!V.isSymbolicLink()||this.follow||$.checkFollowGlobstar())this.subwalks.add(V,$);let W=K?.pattern(),H=K?.rest();if(!K||(W===""||W===".")&&!H)this.matches.add(V,z,W===""||W===".");else if(W===".."){let j=V.parent||V;if(!H)this.matches.add(j,z,!0);else if(!this.hasWalkedCache.hasWalked(j,H))this.subwalks.add(j,H)}}else if(Y instanceof RegExp)this.subwalks.add(V,$)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new hQ(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 z=J.isAbsolute(),Y=J.pattern(),K=J.rest();if(Y===O)V.testGlobstar($,J,K,z);else if(Y instanceof RegExp)V.testRegExp($,Y,K,z);else V.testString($,Y,K,z)}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 s8=(Q,X)=>typeof Q==="string"?new uQ([Q],X):Array.isArray(Q)?new uQ(Q,X):Q;class b5{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=s8(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)}#z(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 hQ(this.opts),Z)}walkCB2(Q,X,Z,V){if(this.#z(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[z,Y,K]of Z.matches.entries()){if(this.#X(z))continue;$++,this.match(z,Y,K).then(()=>J())}for(let z of Z.subwalkTargets()){if(this.maxDepth!==1/0&&z.depth()>=this.maxDepth)continue;$++;let Y=z.readdirCached();if(z.calledReaddir())this.walkCB3(z,Y,Z,J);else z.readdirCB((K,q)=>this.walkCB3(z,q,Z,J),!0)}J()}walkCB3(Q,X,Z,V){Z=Z.filterEntries(Q,X);let $=1,J=()=>{if(--$===0)V()};for(let[z,Y,K]of Z.matches.entries()){if(this.#X(z))continue;$++,this.match(z,Y,K).then(()=>J())}for(let[z,Y]of Z.subwalks.entries())$++,this.walkCB2(z,Y,Z.child(),J);J()}walkCBSync(Q,X,Z){if(this.signal?.aborted)Z();this.walkCB2Sync(Q,X,new hQ(this.opts),Z)}walkCB2Sync(Q,X,Z,V){if(this.#z(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[z,Y,K]of Z.matches.entries()){if(this.#X(z))continue;this.matchSync(z,Y,K)}for(let z of Z.subwalkTargets()){if(this.maxDepth!==1/0&&z.depth()>=this.maxDepth)continue;$++;let Y=z.readdirSync();this.walkCB3Sync(z,Y,Z,J)}J()}walkCB3Sync(Q,X,Z,V){Z=Z.filterEntries(Q,X);let $=1,J=()=>{if(--$===0)V()};for(let[z,Y,K]of Z.matches.entries()){if(this.#X(z))continue;this.matchSync(z,Y,K)}for(let[z,Y]of Z.subwalks.entries())$++,this.walkCB2Sync(z,Y,Z.child(),J);J()}}class J5 extends b5{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 z5 extends b5{results;constructor(Q,X,Z){super(Q,X,Z);this.results=new GQ({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 t8=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class t{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=e8(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((Y)=>Y.replace(/\\/g,"/"));if(this.matchBase){if(X.noglobstar)throw TypeError("base matching requires globstar");Q=Q.map((Y)=>Y.includes("/")?Y:`./**/${Y}`)}if(this.pattern=Q,this.platform=X.platform||t8,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 Y=X.platform==="win32"?yQ:X.platform==="darwin"?$5:X.platform?fQ:E6;this.scurry=new Y(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((Y)=>new d(Y,V)),[J,z]=$.reduce((Y,K)=>{return Y[0].push(...K.set),Y[1].push(...K.globParts),Y},[[],[]]);this.patterns=J.map((Y,K)=>{let q=z[K];if(!q)throw Error("invalid pattern object");return new vQ(Y,q,0,this.platform)})}async walk(){return[...await new J5(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 J5(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 z5(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 z5(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 y5=(Q,X={})=>{if(!Array.isArray(Q))Q=[Q];for(let Z of Q)if(new d(Z,X).hasMagic())return!0;return!1};function K5(Q,X={}){return new t(Q,X).streamSync()}function u6(Q,X={}){return new t(Q,X).stream()}function h6(Q,X={}){return new t(Q,X).walkSync()}async function f6(Q,X={}){return new t(Q,X).walk()}function q5(Q,X={}){return new t(Q,X).iterateSync()}function g6(Q,X={}){return new t(Q,X).iterate()}var Q9=K5,X9=Object.assign(u6,{sync:K5}),Z9=q5,V9=Object.assign(g6,{sync:q5}),$9=Object.assign(h6,{stream:K5,iterate:q5}),Y5=Object.assign(f6,{glob:f6,globSync:h6,sync:$9,globStream:u6,stream:X9,globStreamSync:K5,streamSync:Q9,globIterate:g6,iterate:V9,globIterateSync:q5,iterateSync:Z9,Glob:t,hasMagic:y5,escape:UQ,unescape:n});Y5.glob=Y5;var J9={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 Y=(await Bun.file(Z).text()).split(`
|
|
22
|
-
`),K=Math.max(0,V-1),q=Math.min(Y.length,K+$);return{content:Y.slice(K,q).map((j,_)=>`${K+_+1} ${j}`).join(`
|
|
23
|
-
`)}}catch(J){return{content:`Error reading file: ${J instanceof Error?J.message:String(J)}`,is_error:!0}}}},z9={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}}}},Y9={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 Y=await Bun.file(Z).text();if(J){let K=Y;Y=Y.split(V).join($);let q=(K.match(new RegExp(K9(V),"g"))||[]).length;if(q===0)return{content:"Error: String not found in file",is_error:!0};return await Bun.write(Z,Y),{content:`Successfully replaced ${q} occurrences`}}else{let K=Y.indexOf(V);if(K===-1)return{content:"Error: String not found in file",is_error:!0};if(Y.indexOf(V,K+1)!==-1)return{content:"Error: String appears multiple times in file. Use replace_all or provide more context.",is_error:!0};return Y=Y.replace(V,$),await Bun.write(Z,Y),{content:`Successfully edited ${Z}`}}}catch(z){return{content:`Error editing file: ${z instanceof Error?z.message:String(z)}`,is_error:!0}}}};function K9(Q){return Q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var q9={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()||"",z=$.stderr?.toString()||"";if($.exitCode!==0)return{content:`Exit code: ${$.exitCode}
|
|
24
|
-
${J}
|
|
25
|
-
${z}`.trim(),is_error:!0};return{content:J||"(no output)"}}catch($){return{content:`Error executing command: ${$ instanceof Error?$.message:String($)}`,is_error:!0}}}},H9={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 Y5(Z,{cwd:V,absolute:!0,nodir:!0});if($.length===0)return{content:"No files found matching pattern"};return{content:$.sort().join(`
|
|
26
|
-
`)}}catch($){return{content:`Error searching files: ${$ instanceof Error?$.message:String($)}`,is_error:!0}}}},W9={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",z=Q["-i:"],Y=Q["-C:"],K=Q.head_limit;try{let q=["--json"];if(z)q.push("-i");if(Y)q.push("-C",String(Y));if($)q.push("--glob",$);if(J==="files_with_matches")q.push("--files-with-matches");if(J==="count")q.push("--count");q.push(Z,V);let H=Bun.spawnSync(["rg",...q],{cwd:X.workingDirectory,maxBuffer:10485760}).stdout?.toString()||"";if(!H.trim())return{content:"No matches found"};if(J==="content"){let j=H.trim().split(`
|
|
27
|
-
`),_=[];for(let G of j.slice(0,K||100))try{let w=JSON.parse(G);if(w.type==="match"){let U=w.data?.path?.text||"",A=w.data?.line_number||0,B=w.data?.lines?.text||"";_.push(`${U}:${A}:${B.trim()}`)}}catch{_.push(G)}return{content:_.join(`
|
|
28
|
-
`)||"No matches found"}}return{content:H.trim()}}catch(q){return{content:`Error searching: ${q instanceof Error?q.message:String(q)}`,is_error:!0}}}},j9=[J9,z9,Y9,q9,H9,W9];function $X(Q){return j9.find((X)=>X.name===Q)}import{spawn as _9}from"child_process";class G9{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 z=_9(Q.command,[],{shell:!0,stdio:["pipe","pipe","pipe"]}),Y="",K="";z.stdout?.on("data",(q)=>{Y+=q.toString()}),z.stderr?.on("data",(q)=>{K+=q.toString()}),z.on("close",(q)=>{if(q===0)try{let W=JSON.parse(Y);$(W)}catch{$({decision:"allow"})}else if(q===1)$({decision:"deny",reason:K||"Hook denied execution"});else if(q===2)$({decision:"block",reason:K||"Hook blocked execution"});else $({decision:"allow"})}),z.on("error",(q)=>{$({decision:"allow",reason:`Hook error: ${q.message}`})}),z.stdin?.write(JSON.stringify(X)),z.stdin?.end(),setTimeout(()=>{z.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 YX={validateWrite:{event:"PreToolUse",command:`node -e '
|
|
29
|
-
const input = JSON.parse(require("fs").readFileSync(0, "utf8"));
|
|
30
|
-
if (input.tool_name === "Write") {
|
|
31
|
-
const path = input.tool_input.file_path;
|
|
32
|
-
if (path.includes("..") || path.startsWith("/etc/")) {
|
|
33
|
-
console.log(JSON.stringify({ decision: "deny", reason: "Unsafe path" }));
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
console.log(JSON.stringify({ decision: "allow" }));
|
|
38
|
-
'`,timeout:5000,enabled:!1},logToolUse:{event:"PostToolUse",command:`node -e '
|
|
39
|
-
const input = JSON.parse(require("fs").readFileSync(0, "utf8"));
|
|
40
|
-
console.error(\`[LOG] Tool: \${input.tool_name}\`);
|
|
41
|
-
console.log(JSON.stringify({ decision: "allow" }));
|
|
42
|
-
'`,timeout:5000,enabled:!1}},KX={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."},qX={ALLOW:0,DENY:1,BLOCK:2};import{readFileSync as w9,existsSync as m6,readdirSync as A9}from"fs";import{join as U9}from"path";function B9(Q,X="project"){if(!m6(Q))return null;let Z=w9(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=$[1]??"",z=$[2]??"",Y=L9(J);return{path:Q,name:Y.name||V,description:Y.description||"",prompt:z.trim(),tools:Y.tools,model:Y.model,color:Y.color,source:X}}function L9(Q){let X={},Z=Q.split(`
|
|
43
|
-
`);for(let V of Z){let $=V.match(/^(\w+):\s*(.*)$/);if($){let J=$[1];if(!J)continue;let z=$[2]??"";if(z.startsWith("["))try{X[J]=JSON.parse(z)}catch{X[J]=z}else if(z==="true")X[J]=!0;else if(z==="false")X[J]=!1;else if(/^\d+$/.test(z))X[J]=parseInt(z,10);else if(/^\d+\.\d+$/.test(z))X[J]=parseFloat(z);else X[J]=z}}return X}class v9{skills=new Map;loadFromDirectory(Q,X="project"){if(!m6(Q))return 0;let Z=0,V=A9(Q);for(let $ of V)if($.endsWith(".md")){let J=B9(U9(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 GX(Q){return`
|
|
44
|
-
<skill-loading>
|
|
45
|
-
You are operating with the "${Q.name}" skill loaded.
|
|
46
|
-
|
|
47
|
-
${Q.description?`Description: ${Q.description}
|
|
48
|
-
`:""}
|
|
49
|
-
${Q.prompt}
|
|
50
|
-
</skill-loading>
|
|
51
|
-
`.trim()}var wX=[{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.
|
|
52
|
-
|
|
53
|
-
Steps:
|
|
54
|
-
1. Run \`git diff --staged\` to see staged changes
|
|
55
|
-
2. Run \`git log --oneline -5\` to understand commit message style
|
|
56
|
-
3. Create a commit message following conventional commits format
|
|
57
|
-
4. Include "Co-Authored-By: Claude <noreply@anthropic.com>" if applicable
|
|
58
|
-
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.
|
|
59
|
-
|
|
60
|
-
Steps:
|
|
61
|
-
1. Use \`gh pr view\` to get PR details
|
|
62
|
-
2. Use \`gh pr diff\` to see the changes
|
|
63
|
-
3. Analyze the code for:
|
|
64
|
-
- Bugs and potential issues
|
|
65
|
-
- Code quality and style
|
|
66
|
-
- Test coverage
|
|
67
|
-
- Documentation
|
|
68
|
-
4. Provide constructive feedback
|
|
69
|
-
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.
|
|
70
|
-
|
|
71
|
-
MCP servers enable LLMs to interact with external services through well-designed tools.
|
|
72
|
-
|
|
73
|
-
Key concepts:
|
|
74
|
-
1. Use FastMCP (Python) or MCP SDK (TypeScript)
|
|
75
|
-
2. Define tools with clear input schemas
|
|
76
|
-
3. Return structured content
|
|
77
|
-
4. Handle errors gracefully
|
|
78
|
-
|
|
79
|
-
Transport types:
|
|
80
|
-
- stdio: Local process communication
|
|
81
|
-
- HTTP: REST API with JSON-RPC
|
|
82
|
-
- SSE: Server-Sent Events for streaming
|
|
83
|
-
- 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.
|
|
84
|
-
|
|
85
|
-
Hooks are user-defined shell commands that execute at specific points during Claude Code's lifecycle.
|
|
86
|
-
|
|
87
|
-
Available events:
|
|
88
|
-
- PreToolUse: Before a tool executes
|
|
89
|
-
- PostToolUse: After a tool succeeds
|
|
90
|
-
- PostToolUseFailure: After a tool fails
|
|
91
|
-
- Stop: When agent stops
|
|
92
|
-
- UserPromptSubmit: When user submits prompt
|
|
93
|
-
- SessionStart/SessionEnd: Session lifecycle
|
|
94
|
-
|
|
95
|
-
Exit codes:
|
|
96
|
-
- 0: Allow execution
|
|
97
|
-
- 1: Deny and show stderr
|
|
98
|
-
- 2: Block silently`,tools:["Read","Write","Edit"],model:"sonnet",source:"built-in"}];function AX(Q){return Q.match(/^\/(\w+)(?:\s+(.*))?$/)?.[1]??null}function UX(Q){return Q.match(/^\/\w+\s+(.*)$/)?.[1]??""}import{spawn as f5}from"child_process";class F9{teams=new Map;teammates=new Map;messageQueue=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.messageQueue.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=`
|
|
99
|
-
tell application "Terminal"
|
|
100
|
-
do script "cd ${X.workingDir} && ${Z.join(" ")}"
|
|
101
|
-
activate
|
|
102
|
-
end tell
|
|
103
|
-
`;f5("osascript",["-e",V])}else f5("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=f5("tmux",Q),V="";Z.stdout?.on("data",($)=>{V+=$.toString()}),Z.on("close",()=>{X(V)})})}broadcast(Q,X,Z){let V=this.teams.get(Q);if(!V)return;let $={type:"broadcast",from:Z||"system",content:X,timestamp:Date.now()};for(let J of V.teammates){if(Z&&J.teammateId===Z)continue;let z=this.messageQueue.get(J.teammateId)||[];z.push($),this.messageQueue.set(J.teammateId,z)}}sendDirect(Q,X,Z){let V={type:"direct",from:X,to:Q,content:Z,timestamp:Date.now()},$=this.messageQueue.get(Q)||[];$.push(V),this.messageQueue.set(Q,$)}getMessages(Q){let X=this.messageQueue.get(Q)||[];return this.messageQueue.delete(Q),X}hasMessages(Q){let X=this.messageQueue.get(Q);return X!==void 0&&X.length>0}peekMessages(Q){return this.messageQueue.get(Q)||[]}clearMessages(Q){this.messageQueue.delete(Q)}getMessageCount(Q){return this.messageQueue.get(Q)?.length||0}persistTeam(Q){let X=`${this.storagePath}/${Q.name}/config.json`}loadTeams(){}}var vX={architect:(Q)=>({name:"architect",teamName:Q,color:"blue",prompt:`You are an architect on the ${Q} team.
|
|
104
|
-
Your role is to design and plan the technical architecture.
|
|
105
|
-
Focus on:
|
|
106
|
-
- System design and component relationships
|
|
107
|
-
- API contracts and interfaces
|
|
108
|
-
- Data models and schemas
|
|
109
|
-
- 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.
|
|
110
|
-
Your role is to write clean, working code based on the architecture.
|
|
111
|
-
Focus on:
|
|
112
|
-
- Implementing the designed architecture
|
|
113
|
-
- Writing tests
|
|
114
|
-
- Following coding standards
|
|
115
|
-
- 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.
|
|
116
|
-
Your role is to review code changes and provide feedback.
|
|
117
|
-
Focus on:
|
|
118
|
-
- Code quality and readability
|
|
119
|
-
- Potential bugs and issues
|
|
120
|
-
- Performance considerations
|
|
121
|
-
- Test coverage`,planModeRequired:!1,status:"pending"}),tester:(Q)=>({name:"tester",teamName:Q,color:"orange",prompt:`You are a tester on the ${Q} team.
|
|
122
|
-
Your role is to ensure features work correctly.
|
|
123
|
-
Focus on:
|
|
124
|
-
- Writing comprehensive tests
|
|
125
|
-
- Finding edge cases
|
|
126
|
-
- Verifying requirements
|
|
127
|
-
- Reporting bugs`,planModeRequired:!1,status:"pending"})};function C9(){return`teammate_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function FX(Q){return{...Q,teammateId:C9(),status:"pending"}}
|
|
128
|
-
export{a6 as a,lQ as b,M9 as c,r6 as d,s6 as e,e6 as f,t6 as g,m5 as h,Z7 as i,V7 as j,j5 as k,_5 as l,x9 as m,D9 as n,N9 as o,g9 as p,p5 as q,m9 as r,d9 as s,j7 as t,_7 as u,i9 as v,J9 as w,z9 as x,Y9 as y,q9 as z,H9 as A,W9 as B,j9 as C,$X as D,G9 as E,YX as F,KX as G,qX as H,B9 as I,v9 as J,GX as K,wX as L,AX as M,UX as N,F9 as O,vX as P,C9 as Q,FX as R};
|