@ebowwa/coder 0.1.11 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +60 -79
- package/dist/index-1eawy937.js +308 -0
- package/dist/index-29xcjnne.js +280 -0
- package/dist/index-2avyytn5.js +349 -0
- package/dist/index-4xfgd8nz.js +261 -0
- package/dist/index-6e4wf341.js +349 -0
- package/dist/index-77ckwnbm.js +280 -0
- package/dist/index-bk21w99v.js +280 -0
- package/dist/index-cb4ppjdt.js +255 -0
- package/dist/index-cmfa38hh.js +308 -0
- package/dist/index-datjz8q1.js +257 -0
- package/dist/index-em5k0m3z.js +345 -0
- package/dist/index-gkx6k2tr.js +261 -0
- package/dist/index-hcrpwyy3.js +261 -0
- package/dist/index-hk7fwwa8.js +257 -0
- package/dist/index-kbyw4th1.js +347 -0
- package/dist/index-kgj5gqnm.js +345 -0
- package/dist/index-mdf6xp1z.js +255 -0
- package/dist/index-mrhv8kvc.js +280 -0
- package/dist/index-qwdy6x44.js +261 -0
- package/dist/index-sbbw1a61.js +349 -0
- package/dist/index-svy5bcpn.js +345 -0
- package/dist/index-tvmy7tm9.js +261 -0
- package/dist/index-tzz4vzkj.js +312 -0
- package/dist/index-wksgzz8e.js +280 -0
- package/dist/index-xha05vjc.js +257 -0
- package/dist/index-z8cwtf8j.js +240 -0
- package/dist/index.js +1 -16
- package/native/claude_code_native.dylib +0 -0
- package/native/index.d.ts +135 -35
- package/native/index.darwin-arm64.node +0 -0
- package/native/index.js +1 -1
- package/native/package.json +4 -4
- package/package.json +19 -15
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var S8=Object.create;var{getPrototypeOf:x8,defineProperty:jQ,getOwnPropertyNames:T8}=Object;var E8=Object.prototype.hasOwnProperty;var k8=(Q,Z,$)=>{$=Q!=null?S8(x8(Q)):{};let X=Z||!Q||!Q.__esModule?jQ($,"default",{value:Q,enumerable:!0}):$;for(let V of T8(Q))if(!E8.call(X,V))jQ(X,V,{get:()=>Q[V],enumerable:!0});return X};var S0=import.meta.require;var z0={enabled:!0,ttl:"1h",cacheSystemPrompt:!0,cacheTools:!0,minTokensForCache:1024},y8={low:1024,medium:4096,high:16384,max:1e5},h5={enabled:!1,effort:"medium",interleaved:!0};function _Q(Q,Z){if(Q.budgetTokens)return Q.budgetTokens;let $=Q.effort||"medium",X=y8[$],V=Q.modelMultiplier??(Z.includes("opus")?2:1);return Math.min(X*V,1e5)}function UQ(Q){return Q.includes("claude-opus-4")||Q.includes("claude-sonnet-4")||Q.includes("claude-haiku-4")||Q.includes("claude-4")}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}};var b8={maxRetries:3,baseDelayMs:1000,maxDelayMs:30000,jitterFactor:0.2,retryableStatusCodes:[429,500,502,503,504,529],onRetry:void 0};function f8(Q,Z,$,X){let V=Z*Math.pow(2,Q),J=V*X*(Math.random()*2-1);return Math.min(V+J,$)}function u8(Q,Z){if(Q.message.includes("429")||Q.message.includes("rate limit"))return!0;if(Q.message.includes("500")||Q.message.includes("502")||Q.message.includes("503")||Q.message.includes("504"))return!0;if(Q.message.includes("ECONNREFUSED")||Q.message.includes("ENOTFOUND")||Q.message.includes("ETIMEDOUT")||Q.message.includes("network")||Q.message.includes("fetch failed"))return!0;for(let $ of Z)if(Q.message.includes(String($)))return!0;return!1}function h8(Q){return new Promise((Z)=>setTimeout(Z,Q))}async function wQ(Q,Z={}){let $={...b8,...Z},X=null;for(let V=0;V<=$.maxRetries;V++)try{return await Q()}catch(J){if(X=J instanceof Error?J:Error(String(J)),V<$.maxRetries&&u8(X,$.retryableStatusCodes)){let z=f8(V,$.baseDelayMs,$.maxDelayMs,$.jitterFactor);if($.onRetry)$.onRetry(V+1,X,z);else console.warn(`\x1B[33mRetry ${V+1}/${$.maxRetries} after ${z}ms: ${X.message}\x1B[0m`);await h8(z)}else throw X}throw X||Error("Max retries exceeded")}var AQ={"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 g8(Q,Z){let $=AQ[Q]??AQ["claude-sonnet-4-6"],X=Z.input_tokens-(Z.cache_read_input_tokens??0),V=Z.cache_read_input_tokens??0,J=Z.cache_creation_input_tokens??0,z=Z.output_tokens,Y=X/1e6*$.input,K=V/1e6*$.cache_read,q=J/1e6*$.cache_write,W=z/1e6*$.output,H=Y+K+q+W,j=(V+J)/1e6*($.input-$.cache_read);return{costUSD:H,estimatedSavingsUSD:j}}function m8(Q,Z){if(!Q||!Z.enabled||!Z.cacheSystemPrompt)return typeof Q==="string"?Q:void 0;if(Array.isArray(Q)){let $=[...Q];if($.length>0){let X=$[$.length-1];if(X&&X.type==="text")$[$.length-1]={type:"text",text:X.text,cache_control:{type:"ephemeral",ttl:Z.ttl}}}return $}return[{type:"text",text:Q,cache_control:{type:"ephemeral",ttl:Z.ttl}}]}function d8(Q,Z){if(!Z.enabled)return Q;let $=[];for(let X=0;X<Q.length;X++){let V=Q[X],J=[];for(let z=0;z<V.content.length;z++){let Y=V.content[z],K=z===V.content.length-1,q=X===Q.length-1;if(Y.type==="text"&&Y.text.length>=Z.minTokensForCache*4&&!Y.cache_control&&(K||q))J.push({...Y,cache_control:{type:"ephemeral",ttl:Z.ttl}});else J.push(Y)}$.push({...V,content:J})}if($.length>0&&Z.enabled){let X=$[$.length-1],V=X.content[X.content.length-1];if(V&&!("cache_control"in V))X.content[X.content.length-1]={...V,cache_control:{type:"ephemeral",ttl:Z.ttl}}}return $}function c8(Q){let Z=Q.cache_read_input_tokens??0,$=Q.cache_creation_input_tokens??0,X=Z+$,V=Z>0?1:0,J=$>0?1:0,z=V+J;return{cacheHits:V,cacheMisses:J,totalCacheReadTokens:Z,totalCacheWriteTokens:$,cacheHitRate:z>0?V/z:0,estimatedSavingsUSD:0}}async function BQ(Q,Z){let{apiKey:$,model:X="claude-sonnet-4-6",maxTokens:V=4096,tools:J,systemPrompt:z,cacheConfig:Y=z0,thinking:K,extendedThinking:q,stopSequences:W,onToken:H,onThinking:G,onRedactedThinking:j,onToolUse:_,signal:U}=Z,A=Date.now(),w=0,B=!0,v=0,O=d8(Q,Y),F=m8(z,Y),E={model:X,max_tokens:V,messages:O.map((R)=>({role:R.role,content:R.content})),stream:!0};if(F)E.system=F;if(J&&J.length>0)E.tools=J;if(W&&W.length>0)E.stop_sequences=W;let t=`${process.env.ANTHROPIC_BASE_URL||"https://api.anthropic.com"}/v1/messages`,P={"Content-Type":"application/json","x-api-key":$,"anthropic-version":"2023-06-01"};if(((q?.enabled??!1)||K&&K.type!=="disabled")&&UQ(X)){let R;if(q?.budgetTokens)R=q.budgetTokens;else if(K?.type==="enabled")R=K.budget_tokens;else{let v9=q?.effort||"medium";R=_Q({enabled:!0,effort:v9,modelMultiplier:X.includes("opus")?2:1},X)}R=Math.max(1024,Math.min(R,1e5)),E.thinking={type:"enabled",budget_tokens:R};let o=["extended-thinking-2025-01-24"];if(q?.interleaved!==!1)o.push("interleaved-thinking-2025-01-24");P["anthropic-beta"]=o.join(",")}else P["anthropic-beta"]="max-tokens-3-5-sonnet-2024-07-15";let k9={maxRetries:3,baseDelayMs:1000,maxDelayMs:30000,retryableStatusCodes:[429,500,502,503,504,529],onRetry:(R,o,v9)=>{console.log(`\x1B[33mAPI retry ${R}/3 after ${v9}ms: ${o.message}\x1B[0m`)}},e=await wQ(async()=>{let R=await fetch(t,{method:"POST",headers:P,body:JSON.stringify(E),signal:U});if(!R.ok&&k9.retryableStatusCodes?.includes(R.status)){let o=await R.text();throw Error(`API error: ${R.status} - ${o}`)}return R},k9);if(!e.ok){let R=await e.text();throw Error(`API error: ${e.status} - ${R}`)}if(!e.body)throw Error("No response body");let y9=e.body.getReader(),b9=new TextDecoder,K9=null,q9=[],W9={input_tokens:0,output_tokens:0},T=null,A9=null,Q9=null,d=null,F9="",f9=new Map,GQ="";try{let R="";while(!0){let{done:o,value:v9}=await y9.read();if(o)break;R+=b9.decode(v9,{stream:!0});let u9=R.split(`
|
|
3
|
+
`);R=u9.pop()||"";for(let h9 of u9){if(!h9.startsWith("data: "))continue;let N9=h9.slice(6);if(!N9)continue;try{let $9=JSON.parse(N9);switch($9.type){case"message_start":{let L=$9.message;K9=L,W9=L.usage;break}case"content_block_start":{let{index:L,content_block:C}=$9;if(f9.set(L,C.type),C.type==="text")T={type:"text",text:""};else if(C.type==="thinking")A9={type:"thinking",thinking:""};else if(C.type==="redacted_thinking")Q9={type:"redacted_thinking",data:""};else if(C.type==="tool_use")d={type:"tool_use",id:C.id,name:C.name,input:{}},F9="";break}case"content_block_delta":{let L=$9.delta;if(L.type==="text_delta"&&T){let C=L.text;if(T.text+=C,H?.(C),B)w=Date.now()-A,B=!1}else if(L.type==="thinking_delta"&&A9){let C=L.thinking;A9.thinking+=C,G?.(C),v+=Math.ceil(C.length/4)}else if(L.type==="redacted_thinking_delta"&&Q9){let C=L.data;Q9.data+=C,j?.(C),v+=Math.ceil(C.length/4)}else if(L.type==="input_json_delta"&&d)F9+=L.partial_json;break}case"content_block_stop":{let L=$9.index,C=f9.get(L);if(C==="text"&&T)q9.push(T),T=null;else if(C==="thinking"&&A9)q9.push(A9),A9=null;else if(C==="redacted_thinking"){let M={type:"redacted_thinking",data:Q9?.data||""};q9.push(M),j?.(M.data),Q9=null}else if(C==="tool_use"&&d){try{d.input=JSON.parse(F9)}catch{d.input={}}q9.push(d),_?.({id:d.id,name:d.name,input:d.input}),d=null}f9.delete(L);break}case"message_delta":{let L=$9;if(L.usage)W9.output_tokens=L.usage.output_tokens;if(K9&&L.delta?.stop_reason)K9.stop_reason=L.delta.stop_reason;break}case"message_stop":break}}catch{}}}}finally{y9.releaseLock()}if(!K9)throw Error("No message received from API");K9.content=q9;let{costUSD:D0,estimatedSavingsUSD:H9}=g8(X,W9),P9=c8(W9);P9.estimatedSavingsUSD=H9;let Z9=Date.now()-A;return{message:K9,usage:W9,cacheMetrics:P9,costUSD:D0,durationMs:Z9,ttftMs:w||Z9,thinkingTokens:v}}import*as LQ from"readline";var l8={Read:"low",Glob:"low",Grep:"low",Task:"low",Write:"medium",Edit:"medium",NotebookEdit:"medium",Bash:"high"},p8=[/\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 i8(Q,Z){let $=l8[Q]??"medium";if(Q==="Bash"){let X=String(Z.command??"");for(let V of p8)if(V.test(X))return"critical";if(/\bsudo\b/.test(X)||/\bchmod\b/.test(X))$="high"}if(Q==="Write"||Q==="Edit"){let X=String(Z.file_path??Z.path??"");if(/\.(env|pem|key|secret|credentials)/.test(X))$="high";if(/\/\.ssh\//.test(X)||/\/\.gnupg\//.test(X))$="critical"}return $}function n8(Q,Z){switch(Q){case"Read":return`Read file: ${Z.file_path??"unknown"}`;case"Write":return`Write file: ${Z.file_path??"unknown"} (${String(Z.content??"").length} chars)`;case"Edit":return`Edit file: ${Z.file_path??"unknown"}`;case"Bash":return`Execute: ${String(Z.command??"").slice(0,100)}${String(Z.command??"").length>100?"...":""}`;case"Glob":return`Find files: ${Z.pattern??"*"}`;case"Grep":return`Search: "${Z.pattern??""}" in ${Z.path??"."}`;case"Task":return`Spawn agent: ${Z.subagent_type??"unknown"}`;default:return`Use tool: ${Q}`}}class x0{cache={};cacheTimeout=300000;promptCallback;mode;constructor(Q="default",Z){this.mode=Q,this.promptCallback=Z??this.defaultPrompt.bind(this)}async checkPermission(Q,Z){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 $=this.getCacheKey(Q,Z),X=this.cache[$];if(X&&Date.now()-X.timestamp<this.cacheTimeout){if(X.decision==="allowAlways")return{decision:"allow",reason:"Previously approved (always)"};if(X.decision==="denyAlways")return{decision:"deny",reason:"Previously denied (always)"}}let V=i8(Q,Z),J=n8(Q,Z),z={toolName:Q,toolInput:Z,riskLevel:V,description:J,file:Z.file_path??Z.path,command:Q==="Bash"?Z.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[$]={decision:Y.decision,timestamp:Date.now()};return Y}return{decision:"allow"}}getCacheKey(Q,Z){if(["Read","Write","Edit"].includes(Q))return`${Q}:${Z.file_path??Z.path??"unknown"}`;if(Q==="Bash"){let $=String(Z.command??"").slice(0,100);return`${Q}:${$}`}return Q}async defaultPrompt(Q){return new Promise((Z)=>{let $=LQ.createInterface({input:process.stdin,output:process.stdout}),V={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: ${V}${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";$.question(`Allow? ${z}: `,(Y)=>{switch($.close(),Y.trim().toLowerCase()){case"y":case"yes":Z({decision:"allow"});break;case"a":case"always":Z({decision:"allowAlways"});break;case"d":case"deny":case"deny always":Z({decision:"denyAlways"});break;case"n":case"no":default:Z({decision:"deny"});break}})})}clearCache(){this.cache={}}setMode(Q){this.mode=Q,this.clearCache()}}var T0={readOnly:["Read","Glob","Grep","Task"],fileEdit:["Write","Edit","NotebookEdit"],system:["Bash"],network:[]};function o5(Q){return T0.readOnly.includes(Q)}function r5(Q){return T0.fileEdit.includes(Q)}function a5(Q){return T0.system.includes(Q)}import{join as X9,dirname as o8}from"path";import{fileURLToPath as r8}from"url";import{existsSync as a8}from"fs";var g9=null,FQ=!1;function j9(){if(g9)return g9;if(FQ)return vQ();FQ=!0;let{platform:Q,arch:Z}=process,$=`${Q}-${Z}`,X;try{X=o8(r8(import.meta.url))}catch{X=process.cwd()}let V=[X9(X,"..","..","native",`claude-code-native.${$}.node`),X9(X,"..","native",`claude-code-native.${$}.node`),X9(X,"native",`claude-code-native.${$}.node`),X9(X,"..","..","native",`claude_code_native.${$}.node`),X9(X,"..","..","native","index.node"),X9(X,"..","native","index.node"),X9(X,"..","..","native","claude-code-native.node"),X9(X,"..","..","node_modules","@ebowwa","coder-native","index.node"),X9(process.cwd(),"native",`claude-code-native.${$}.node`),X9(process.cwd(),"native","index.node")];for(let J of V)if(a8(J))try{let z=S0(J);return console.debug(`[native] Loaded module from: ${J}`),g9=z,g9}catch(z){console.debug(`[native] Failed to load ${J}:`,z);continue}return console.debug("[native] No native module found, using JS fallback"),vQ()}function y0(){try{return j9(),g9!==null}catch{return!1}}var s8=4,m9=10,OQ=100;function g(Q){if(!Q||Q.length===0)return 0;return Math.ceil(Q.length/s8)}function k0(Q){switch(Q.type){case"text":return g(Q.text);case"image":return OQ;case"tool_use":{let Z=JSON.stringify(Q.input);return g(Q.name)+g(Z)+m9}case"tool_result":{if(typeof Q.content==="string")return g(Q.content)+m9;return Q.content.reduce((Z,$)=>Z+k0($),0)+m9}case"thinking":return g(Q.thinking);case"redacted_thinking":return g(Q.data);default:return 0}}function Y0(Q){let Z=14695981039346656037n,$=1099511628211n,X=Z;for(let V=0;V<Q.length;V++)X^=BigInt(Q.charCodeAt(V)),X*=$,X&=0xFFFFFFFFFFFFFFFFn;return X.toString(16).padStart(16,"0")}function V9(Q){let Z=3735928559,$=1103553917;for(let X=0;X<Q.length;X++){let V=Q.charCodeAt(X);Z=Math.imul(Z^V,2654435761),$=Math.imul($^V,1597334677)}return Z=Math.imul(Z^Z>>>16,2246822507),Z=Math.imul(Z^Z>>>13,3266489909),Z=(Z^Z>>>16)>>>0,$=Math.imul($^$>>>16,2246822507),$=Math.imul($^$>>>13,3266489909),$=($^$>>>16)>>>0,(Z>>>0).toString(16).padStart(8,"0")+($>>>0).toString(16).padStart(8,"0")}function E0(Q){if(typeof Bun<"u"&&Bun.hash)try{return Bun.hash(Q).toString(16).padStart(16,"0")}catch{}if(typeof crypto<"u"&&crypto.subtle);let Z=V9(Q);for(let $=0;$<3;$++)Z=V9(Z+Q+$);return(Z+Y0(Q)+V9(Q+Z)).slice(0,64)}function vQ(){return{searchFiles:(Q,Z,$)=>{return{matches:[],total_count:0,files_searched:0}},countTokens:(Q)=>{return Math.ceil(Q.length/4)},estimateTokens:g,estimateTextBlockTokens:(Q)=>g(Q),estimateImageBlockTokens:()=>OQ,estimateToolUseBlockTokens:(Q,Z)=>{return g(Q)+g(Z)+m9},estimateToolResultBlockTokens:(Q)=>{return g(Q)+m9},estimateThinkingBlockTokens:(Q)=>g(Q),estimateRedactedThinkingBlockTokens:(Q)=>g(Q),estimateBlocksFromJson:(Q)=>{try{return JSON.parse(Q).reduce(($,X)=>$+k0(X),0)}catch{return 0}},estimateMessageTokensJson:(Q,Z)=>{try{return 4+JSON.parse(Z).reduce((J,z)=>J+k0(z),0)}catch{return 4}},calculateDiff:(Q,Z)=>{let $=Q.split(`
|
|
4
|
+
`),X=Z.split(`
|
|
5
|
+
`),V=[];if(Q!==Z)V.push({old_start:1,old_lines:$.length,new_start:1,new_lines:X.length,content:`- ${$.join(`
|
|
6
|
+
- `)}
|
|
7
|
+
+ ${X.join(`
|
|
8
|
+
+ `)}`});return V},compactContent:(Q,Z,$="truncate")=>{let V=Z*4;if(Q.length<=V)return Q;switch($){case"truncate":return Q.slice(0,V/2)+`
|
|
9
|
+
|
|
10
|
+
... [truncated] ...
|
|
11
|
+
|
|
12
|
+
`+Q.slice(-V/2);case"summarize":let J=Math.floor(V/4);return`=== BEGINNING ===
|
|
13
|
+
`+Q.slice(0,J)+`
|
|
14
|
+
|
|
15
|
+
=== END ===
|
|
16
|
+
`+Q.slice(-J);case"extract":return Q.split(`
|
|
17
|
+
`).filter((K)=>K.trim().startsWith("#")||K.trim().startsWith("function")||K.trim().startsWith("const")||K.trim().startsWith("class")||K.trim().startsWith("export")||K.trim().startsWith("import")).slice(0,V/50).join(`
|
|
18
|
+
`);default:return Q.slice(0,V)}},hashContentXxhash3:V9,hashContentXxhash64:Y0,hashContentSha256:E0,hashContent:(Q,Z="xxhash3")=>{let $=performance.now(),X;switch(Z){case"xxhash64":X=Y0(Q);break;case"sha256":X=E0(Q);break;default:X=V9(Q)}return{hash:X,algorithm:Z,input_size:Q.length,elapsed_us:Math.round((performance.now()-$)*1000)}},hashCombined:(Q,Z="xxhash3")=>{let $=Q.join("\x00");switch(Z){case"xxhash64":return Y0($);case"sha256":return E0($);default:return V9($)}},contentChanged:(Q,Z)=>V9(Q)!==Z,contentEquals:(Q,Z)=>Q.length===Z.length&&V9(Q)===V9(Z),generateCacheKey:(Q)=>V9(Q.join("\x00"))}}function CQ(Q){return JSON.stringify(Q.map((Z)=>{switch(Z.type){case"text":return{type:"text",text:Z.text};case"image":return{type:"image"};case"tool_use":return{type:"tool_use",name:Z.name,input:Z.input};case"tool_result":return{type:"tool_result",content:Z.content};case"thinking":return{type:"thinking",thinking:Z.thinking};case"redacted_thinking":return{type:"redacted_thinking",data:Z.data};default:return{type:"text",text:""}}}))}function MQ(Q){return j9().estimateBlocksFromJson(CQ(Q))}function RQ(Q,Z){return j9().estimateMessageTokensJson(Q,CQ(Z))}function Z7(Q){return j9().hashContentXxhash3(Q)}function $7(Q){return j9().hashContentSha256(Q)}function X7(Q,Z){return j9().contentChanged(Q,Z)}function V7(Q,Z){return j9().contentEquals(Q,Z)}function J7(Q){return j9().generateCacheKey(Q)}var O9=j9();var f0={tokenWarningThreshold:0.8,costUpdateInterval:5,toolSummaryInterval:3,envInfoOnStart:!0},b0={WARNING:0.8,CRITICAL:0.9,EMERGENCY:0.95};function t8(Q){let{current:Z,max:$,threshold:X=b0.WARNING}=Q;if($<=0)return"";let V=Z/$;if(V<X)return"";let J=$-Z,z=Math.round(V*100),Y,K;if(V>=b0.EMERGENCY)Y="emergency",K="\uD83D\uDEA8";else if(V>=b0.CRITICAL)Y="critical",K="\u26A0\uFE0F";else Y="warning",K="\u26A1";let q=[`${K} Token Usage ${Y.toUpperCase()}`,"",`Current: ${Z.toLocaleString()} / ${$.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(`
|
|
19
|
+
`)}function e8(Q){let{cost:Z,previousCost:$=0,currency:X="USD"}=Q,V=Q6(X),J=PQ(Z,V),z=Z-$,Y=PQ(Math.abs(z),V),K=["\uD83D\uDCB0 Cost Update","",`Total: ${J} ${X}`];if(z!==0){let q=z>0?"+":"-";K.push(`This turn: ${q}${Y} ${X}`)}return K.join(`
|
|
20
|
+
`)}function PQ(Q,Z){if(Q<0.01)return`${Z}${Q.toFixed(4)}`;else if(Q<1)return`${Z}${Q.toFixed(3)}`;return`${Z}${Q.toFixed(2)}`}function Q6(Q){return{USD:"$",EUR:"\u20AC",GBP:"\xA3",JPY:"\xA5"}[Q]||Q}function Z6(Q){let{tools:Z,maxDisplay:$=10}=Q;if(Z.length===0)return"No tools used this session.";let X=new Map;for(let Y of Z){let K=X.get(Y.name)||0;X.set(Y.name,K+1)}let V=[...X.entries()].sort((Y,K)=>K[1]-Y[1]),J=[`\uD83D\uDD27 Tool Usage Summary (${Z.length} total calls)`,""],z=V.slice(0,$);for(let[Y,K]of z)J.push(` \u2022 ${Y}: ${K} call${K===1?"":"s"}`);if(V.length>$){let Y=V.length-$;J.push(` ... and ${Y} more tool${Y===1?"":"s"}`)}return J.join(`
|
|
21
|
+
`)}function $6(Q){let{workingDirectory:Z,gitStatus:$,platform:X=process.platform,shell:V=process.env.SHELL||"unknown"}=Q,J=["\uD83D\uDCCD Environment Information","",`Working Directory: ${Z}`,`Platform: ${X}`,`Shell: ${V}`];if($){if(J.push(""),J.push("Git Status:"),J.push(` Branch: ${$.branch}`),$.ahead>0||$.behind>0)J.push(` Ahead: ${$.ahead}, Behind: ${$.behind}`);let z=$.staged.length+$.unstaged.length+$.untracked.length+$.conflicted.length;if(z>0){if(J.push(` Changes: ${z} file${z===1?"":"s"}`),$.staged.length>0)J.push(` Staged: ${$.staged.length}`);if($.unstaged.length>0)J.push(` Unstaged: ${$.unstaged.length}`);if($.untracked.length>0)J.push(` Untracked: ${$.untracked.length}`);if($.conflicted.length>0)J.push(` Conflicted: ${$.conflicted.length}`)}else J.push(" Working tree clean")}return J.join(`
|
|
22
|
+
`)}function NQ(Q){let{usage:Z,maxTokens:$,totalCost:X,previousCost:V,toolsUsed:J,workingDirectory:z,gitStatus:Y,turnNumber:K,config:q}=Q,W={...f0,...q},H=[],G=Z.input_tokens+Z.output_tokens,j=t8({current:G,max:$,threshold:W.tokenWarningThreshold});if(j)H.push(j);if(K%W.costUpdateInterval===0){let _=e8({cost:X,previousCost:V});H.push(_)}if(K%W.toolSummaryInterval===0&&J.length>0){let _=Z6({tools:J});H.push(_)}if(K===1&&W.envInfoOnStart){let _=$6({workingDirectory:z,gitStatus:Y});H.push(_)}if(H.length===0)return"";return["---","System Reminders:","",...H,"---"].join(`
|
|
23
|
+
`)}var X6=4,V6=5,J6=1,z6=8,Y6=0.9,DQ=8000,K0=10,K6=100;function D9(Q){if(!Q||Q.length===0)return 0;return Math.ceil(Q.length/X6)}function IQ(Q){if(y0())try{switch(Q.type){case"text":return O9.estimate_text_block_tokens(Q.text);case"image":return O9.estimate_image_block_tokens();case"tool_use":return O9.estimate_tool_use_block_tokens(Q.name,JSON.stringify(Q.input));case"tool_result":if(typeof Q.content==="string")return O9.estimate_tool_result_block_tokens(Q.content);return MQ(Q.content)+K0;case"thinking":return O9.estimate_thinking_block_tokens(Q.thinking);case"redacted_thinking":return O9.estimate_redacted_thinking_block_tokens(Q.data);default:return 0}}catch{}switch(Q.type){case"text":return D9(Q.text);case"image":return K6;case"tool_use":let Z=JSON.stringify(Q.input);return D9(Q.name)+D9(Z)+K0;case"tool_result":if(typeof Q.content==="string")return D9(Q.content)+K0;return Q.content.reduce(($,X)=>$+IQ(X),0)+K0;case"thinking":return D9(Q.thinking);case"redacted_thinking":return D9(Q.data);default:return 0}}function q6(Q){if(y0())try{return RQ(Q.role,Q.content)}catch{}let Z=4,$=Q.content.reduce((X,V)=>X+IQ(V),0);return Z+$}function u0(Q){if(!Q||Q.length===0)return 0;return Q.reduce((Z,$)=>Z+q6($),0)}function W6(Q){let Z=[];for(let $ of Q.content)switch($.type){case"text":Z.push($.text);break;case"tool_use":Z.push(`[Tool: ${$.name}(${JSON.stringify($.input)})]`);break;case"tool_result":let X=typeof $.content==="string"?$.content:$.content.map((V)=>V.type==="text"?V.text:"[content]").join("");Z.push(`[Result: ${X.slice(0,500)}${X.length>500?"...":""}]`);break;case"thinking":Z.push(`[Thinking: ${$.thinking.slice(0,200)}...]`);break}return Z.join(`
|
|
24
|
+
`)}function H6(Q){let Z=new Map;for(let $ of Q)for(let X of $.content)if(X.type==="tool_use")Z.set(X.id,{use:X});for(let $ of Q)for(let X of $.content)if(X.type==="tool_result"){let V=Z.get(X.tool_use_id);if(V)V.result=X}return Z}async function G6(Q){if(!Q||Q.length===0)return"";let Z=[];Z.push(`[Context Summary: ${Q.length} messages compacted]
|
|
25
|
+
`);let $=[];for(let V=0;V<Q.length;V++){let J=Q[V];if(!J)continue;let z=J.role.toUpperCase(),Y=W6(J);for(let q of J.content)if(q.type==="tool_use")$.push(`${q.name}`);let K=Y.length>300?`${Y.slice(0,300)}...`:Y;Z.push(`${z}: ${K}
|
|
26
|
+
`)}if($.length>0){let V=$.reduce((z,Y)=>{return z[Y]=(z[Y]||0)+1,z},{}),J=Object.entries(V).map(([z,Y])=>`${z}(${Y})`).join(", ");Z.push(`
|
|
27
|
+
Tools used: ${J}
|
|
28
|
+
`)}let X=Z.join("");if(X.length>DQ)X=X.slice(0,DQ)+`
|
|
29
|
+
...[truncated]`;return X}async function h0(Q,Z,$={}){let{keepFirst:X=J6,keepLast:V=V6,preserveToolPairs:J=!0}=$,z=u0(Q);if(z<=Z)return{messages:Q,messagesRemoved:0,tokensBefore:z,tokensAfter:z,didCompact:!1};if(Q.length<=X+V)return{messages:Q,messagesRemoved:0,tokensBefore:z,tokensAfter:z,didCompact:!1};let Y=Q.slice(0,X),K=Q.slice(X,-V),q=Q.slice(-V),H={role:"user",content:[{type:"text",text:`[Previous context has been compacted for continuity]
|
|
30
|
+
|
|
31
|
+
${await G6(K)}`}]},G=[];if(J&&K.length>0){let A=H6(K),w=Array.from(A.values()).slice(-3).filter((B)=>B.result&&!B.result.is_error);for(let B of w)if(G.push(B.use),B.result)G.push(B.result)}let j=[...Y,H];if(G.length>0)j.push({role:"assistant",content:G.filter((A)=>A.type==="tool_use")}),j.push({role:"user",content:G.filter((A)=>A.type==="tool_result")});j.push(...q);let _=u0(j),U=Q.length-j.length;return console.log(`Context compaction: ${Q.length} -> ${j.length} messages, ${z} -> ${_} tokens`),{messages:j,messagesRemoved:U,tokensBefore:z,tokensAfter:_,didCompact:!0}}function SQ(Q,Z,$=Y6){if(Q.length<z6)return!1;let X=u0(Q),V=Math.floor(Z*$);return X>=V}function g0(Q){if(!Q.didCompact)return{reductionPercent:0,tokensSaved:0};let Z=Q.tokensBefore-Q.tokensAfter,$=Z/Q.tokensBefore*100;return{reductionPercent:Math.round($*100)/100,tokensSaved:Z}}async function F7(Q,Z){let{apiKey:$,model:X="claude-sonnet-4-6",maxTokens:V=4096,systemPrompt:J,tools:z,permissionMode:Y,workingDirectory:K,gitStatus:q=null,reminderConfig:W,cacheConfig:H=z0,thinking:G,extendedThinking:j,stopSequences:_,getStopSequences:U,onText:A,onThinking:w,onToolUse:B,onToolResult:v,onMetrics:O,onReminder:F,onPermissionRequest:E,signal:y}=Z,t=new x0(Y,E),P=[...Q],n=[],k9=[],e=0,y9=0,b9=0,K9=0,q9=0,W9=0,T={cacheHits:0,cacheMisses:0,totalCacheReadTokens:0,totalCacheWriteTokens:0,cacheHitRate:0,estimatedSavingsUSD:0},A9={...f0,...W},Q9=!0;while(Q9){if(y?.aborted)break;b9++;let d=n[n.length-1],F9=NQ({usage:d?.usage??{input_tokens:0,output_tokens:0},maxTokens:V,totalCost:e,previousCost:K9,toolsUsed:k9,workingDirectory:K,gitStatus:q,turnNumber:b9,config:A9});if(F9)F?.(F9);if(SQ(P,V)){let L=await h0(P,V,{keepFirst:0,keepLast:3,preserveToolPairs:!0});if(L.didCompact&&L.tokensAfter<L.tokensBefore){P.length=0,P.push(...L.messages),q9++;let C=L.tokensBefore-L.tokensAfter;W9+=C;let M=g0(L);console.log(`Context compacted: ${M.reductionPercent}% reduction, ${M.tokensSaved} tokens saved`)}}let f9=j6(P,J,F9),GQ=U?U(b9,{lastStopReason:n[n.length-1]?.stopReason}):_,D0=await BQ(f9,{apiKey:$,model:X,maxTokens:V,systemPrompt:J,cacheConfig:H,thinking:G,extendedThinking:j,stopSequences:GQ,tools:z.map((L)=>({name:L.name,description:L.description,input_schema:L.input_schema})),onToken:A,onThinking:w,onToolUse:B,signal:y}),{message:H9,usage:P9,cacheMetrics:Z9,costUSD:R,durationMs:o,ttftMs:v9}=D0,u9={model:X,messageCount:P.length,messageTokens:P9.input_tokens+P9.output_tokens,usage:P9,cacheMetrics:Z9,durationMs:o,ttftMs:v9,costUSD:R,stopReason:H9.stop_reason,requestId:H9.id};if(n.push(u9),K9=e,e+=R,y9+=o,Z9)T.cacheHits+=Z9.cacheHits,T.cacheMisses+=Z9.cacheMisses,T.totalCacheReadTokens+=Z9.totalCacheReadTokens,T.totalCacheWriteTokens+=Z9.totalCacheWriteTokens,T.estimatedSavingsUSD+=Z9.estimatedSavingsUSD;let h9=T.cacheHits+T.cacheMisses;if(T.cacheHitRate=h9>0?T.cacheHits/h9:0,O?.(u9),P.push({role:"assistant",content:H9.content}),H9.stop_reason==="end_turn"||H9.stop_reason==="stop_sequence"){Q9=!1;break}if(H9.stop_reason==="max_tokens"){let L=await h0(P,V,{keepFirst:0,keepLast:3,preserveToolPairs:!0});if(L.didCompact&&L.tokensAfter<L.tokensBefore){P.length=0,P.push(...L.messages),q9++;let C=L.tokensBefore-L.tokensAfter;W9+=C;let M=g0(L);console.log(`Context compacted: ${M.reductionPercent}% reduction, ${M.tokensSaved} tokens saved`);continue}else{Q9=!1;break}}let N9=H9.content.filter((L)=>L.type==="tool_use");if(k9.push(...N9),N9.length===0){Q9=!1;break}let $9=[];if(y?.aborted);else{let L=N9.map(async(M)=>{let I0=z.find((G9)=>G9.name===M.name);if(!I0)return{toolUseId:M.id,result:{type:"tool_result",tool_use_id:M.id,content:`Error: Unknown tool "${M.name}"`,is_error:!0},toolResult:null};let J0=await t.checkPermission(I0.name,M.input);if(J0.decision==="deny"||J0.decision==="denyAlways")return{toolUseId:M.id,result:{type:"tool_result",tool_use_id:M.id,content:`Permission denied for tool "${M.name}"${J0.reason?`: ${J0.reason}`:""}`,is_error:!0},toolResult:null};try{let G9=await I0.handler(M.input,{workingDirectory:K,permissionMode:Y,abortSignal:y});return{toolUseId:M.id,result:{type:"tool_result",tool_use_id:M.id,content:G9.content,is_error:G9.is_error},toolResult:{id:M.id,result:G9}}}catch(G9){let I8=G9 instanceof Error?G9.message:String(G9);return{toolUseId:M.id,result:{type:"tool_result",tool_use_id:M.id,content:`Error: ${I8}`,is_error:!0},toolResult:null}}}),C=await Promise.all(L);for(let M of C)if($9.push(M.result),M.toolResult)v?.(M.toolResult)}P.push({role:"user",content:$9})}return{messages:P,metrics:n,totalCost:e,totalDuration:y9,totalCacheMetrics:T,compactionCount:q9,totalTokensCompacted:W9}}function j6(Q,Z,$){if($&&Q.length>0){let X=[...Q];for(let V=X.length-1;V>=0;V--){let J=X[V];if(J&&J.role==="user"){let z={role:"user",content:Array.isArray(J.content)?_6(J.content,$):[{type:"text",text:`${String(J.content)}
|
|
32
|
+
|
|
33
|
+
${$}`}]};X[V]=z;break}}return X}return Q}function _6(Q,Z){if(Q.length>0){let X=Q[Q.length-1];if(X&&X.type==="text"){let V={type:"text",text:`${X.text}
|
|
34
|
+
|
|
35
|
+
${Z}`};return[...Q.slice(0,-1),V]}}let $={type:"text",text:`
|
|
36
|
+
|
|
37
|
+
${Z}`};return[...Q,$]}function m0(Q){if(Q<0.01)return`$${Q.toFixed(4)}`;return`$${Q.toFixed(2)}`}function v7(Q){let Z=m0(Q.costUSD),$=`${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 X=Q.usage.cache_read_input_tokens?.toLocaleString()??"0",V=Q.usage.cache_creation_input_tokens?.toLocaleString()??"0";return`Cost: ${Z} | Tokens: ${$} | Cache: ${X} read, ${V} write`}return`Cost: ${Z} | Tokens: ${$}`}function O7(Q){let Z=m0(Q.costUSD),$=Q.usage.input_tokens+Q.usage.output_tokens;return`Cost: ${Z} | Tokens: ${$.toLocaleString()}`}function C7(Q){let Z=m0(Q.estimatedSavingsUSD);return`Cache: ${(Q.cacheHitRate*100).toFixed(1)}% hit rate | ${Q.totalCacheReadTokens.toLocaleString()} read | ${Q.totalCacheWriteTokens.toLocaleString()} written | Saved: ${Z}`}import{homedir as U6}from"os";import{join as _9}from"path";class w6{sessionsDir;currentSessionId=null;currentSessionFile=null;writeQueue=Promise.resolve();constructor(Q){this.sessionsDir=Q??_9(U6(),".claude","sessions")}async init(){try{await Bun.write(_9(this.sessionsDir,".gitkeep"),"")}catch{}}generateSessionId(){let Q=Date.now().toString(36),Z=Math.random().toString(36).slice(2,8);return`${Q}-${Z}`}async createSession(Q){await this.init();let Z=this.generateSessionId();this.currentSessionId=Z,this.currentSessionFile=_9(this.sessionsDir,`${Z}.jsonl`);let $={id:Z,created:Date.now(),updated:Date.now(),model:Q.model,workingDirectory:Q.workingDirectory,agentName:Q.agentName,agentColor:Q.agentColor,teamName:Q.teamName};await this.appendEntry($);let X={type:"context",timestamp:Date.now(),workingDirectory:Q.workingDirectory};return await this.appendEntry(X),Z}async resumeSession(Q){let Z=_9(this.sessionsDir,`${Q}.jsonl`);try{let $=await Bun.file(Z).text();if(!$)return null;let X=$.trim().split(`
|
|
38
|
+
`),V=[];for(let J of X)try{V.push(JSON.parse(J))}catch{}return this.parseSessionEntries(V)}catch{return null}}parseSessionEntries(Q){let Z=null,$=[],X=[],V=[],J=null;for(let z of Q){if(!("type"in z)&&"id"in z&&"created"in z){Z=z;continue}if("type"in z){let Y=z;switch(Y.type){case"message":$.push(Y.data);break;case"tool_use":X.push(Y);break;case"metrics":V.push(Y.data);break;case"context":J=Y;break}}}if(!Z)Z={id:"unknown",created:Date.now(),updated:Date.now(),model:"claude-sonnet-4-6",workingDirectory:process.cwd()};return{metadata:Z,messages:$,tools:X,metrics:V,context:J}}async appendEntry(Q){if(!this.currentSessionFile)return;this.writeQueue=this.writeQueue.then(async()=>{let Z=JSON.stringify(Q)+`
|
|
39
|
+
`,$=Bun.file(this.currentSessionFile),X=await $.exists()?await $.text():"";await Bun.write(this.currentSessionFile,X+Z)}),await this.writeQueue}async saveMessage(Q){let Z={type:"message",timestamp:Date.now(),data:Q};await this.appendEntry(Z),await this.updateTimestamp()}async saveToolUse(Q,Z,$,X,V){let J={type:"tool_use",timestamp:Date.now(),toolId:Q,toolName:Z,input:$,result:X,isError:V};await this.appendEntry(J)}async saveMetrics(Q){let Z={type:"metrics",timestamp:Date.now(),data:Q};await this.appendEntry(Z)}async updateTimestamp(){if(!this.currentSessionFile||!this.currentSessionId)return}async listSessions(Q=20){await this.init();let Z=Bun.file(this.sessionsDir),$=[];try{let V=[...new Bun.Glob("*.jsonl").scanSync(this.sessionsDir)],J=await Promise.all(V.map(async(z)=>{let Y=_9(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)$.push(q)}}catch{}return $}async getSessionSummary(Q,Z){let $=Z??_9(this.sessionsDir,`${Q}.jsonl`);try{let X=await Bun.file($).text();if(!X)return null;let V=X.trim().split(`
|
|
40
|
+
`),J=null,z=0,Y=0,K=0,q=0,W;for(let H of V)try{let G=JSON.parse(H);if(G.id&&G.created)J=G;else if(G.type==="message"){z++;let j=G.data;if(!W&&j.role==="user"){let _=j.content.find((U)=>U.type==="text");if(_&&"text"in _){if(W=_.text.slice(0,100),_.text.length>100)W+="..."}}}else if(G.type==="metrics")Y+=G.data.costUSD,K+=G.data.usage.input_tokens,q+=G.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,Z,$){let X=await this.resumeSession(Q);if(!X)throw Error(`Session not found: ${Q}`);let V,J;switch(Z){case"jsonl":{let Y=_9(this.sessionsDir,`${Q}.jsonl`);V=await Bun.file(Y).text(),J="jsonl";break}case"json":{V=JSON.stringify(X,null,2),J="json";break}case"markdown":{V=this.sessionToMarkdown(X),J="md";break}default:throw Error(`Unsupported format: ${Z}`)}let z=$??_9(process.cwd(),`session-${Q}.${J}`);return await Bun.write(z,V),z}sessionToMarkdown(Q){let Z=[];Z.push(`# Session: ${Q.metadata.id}`),Z.push(""),Z.push(`**Created:** ${new Date(Q.metadata.created).toISOString()}`),Z.push(`**Model:** ${Q.metadata.model}`),Z.push(`**Working Directory:** ${Q.metadata.workingDirectory}`),Z.push(""),Z.push("## Conversation"),Z.push("");for(let $ of Q.messages){let X=$.role==="user"?"**User**":"**Claude**";Z.push(`### ${X}`),Z.push("");for(let V of $.content)if(V.type==="text")Z.push(V.text),Z.push("");else if(V.type==="tool_use"){let J=V;Z.push(`\`\`\`tool:${J.name}`),Z.push(JSON.stringify(J.input,null,2)),Z.push("```"),Z.push("")}else if(V.type==="tool_result"){let J=V;Z.push(`**Result**${J.is_error?" (error)":""}:`),Z.push("```"),Z.push(typeof J.content==="string"?J.content:JSON.stringify(J.content,null,2)),Z.push("```"),Z.push("")}}if(Q.metrics.length>0){Z.push("## Metrics"),Z.push("");let $=Q.metrics.reduce((J,z)=>J+z.costUSD,0),X=Q.metrics.reduce((J,z)=>J+z.usage.input_tokens,0),V=Q.metrics.reduce((J,z)=>J+z.usage.output_tokens,0);Z.push(`- **Total Cost:** $${$.toFixed(4)}`),Z.push(`- **Total Input Tokens:** ${X.toLocaleString()}`),Z.push(`- **Total Output Tokens:** ${V.toLocaleString()}`),Z.push(`- **API Calls:** ${Q.metrics.length}`)}return Z.join(`
|
|
41
|
+
`)}async deleteSession(Q){let Z=_9(this.sessionsDir,`${Q}.jsonl`);try{if(await Bun.file(Z).exists()){let{unlink:X}=await import("fs/promises");return await X(Z),!0}return!1}catch{return!1}}}function A6(Q){let Z=new Date(Q.created),$=new Date(Q.updated),X=B6($),V=[];V.push(`\x1B[1m${Q.id}\x1B[0m (${X})`),V.push(` Model: ${Q.model} | Messages: ${Q.messageCount}`);let J=Q.totalCost<0.01?`$${Q.totalCost.toFixed(4)}`:`$${Q.totalCost.toFixed(2)}`;if(V.push(` Cost: ${J} | Tokens: ${Q.totalTokens.input.toLocaleString()} in, ${Q.totalTokens.output.toLocaleString()} out`),Q.firstMessage)V.push(` Preview: ${Q.firstMessage}`);return V.push(` Directory: ${Q.workingDirectory}`),V.join(`
|
|
42
|
+
`)}function B6(Q){let $=new Date().getTime()-Q.getTime(),X=Math.floor($/60000),V=Math.floor($/3600000),J=Math.floor($/86400000);if(X<1)return"just now";if(X<60)return`${X}m ago`;if(V<24)return`${V}h ago`;if(J<7)return`${J}d ago`;return Q.toLocaleDateString()}function N7(Q){if(Q.length===0){console.log("No sessions found."),console.log(`
|
|
43
|
+
Start a new conversation to create a session.`);return}console.log(`\x1B[1mRecent Sessions (${Q.length})\x1B[0m
|
|
44
|
+
`);for(let Z of Q)console.log(A6(Z)),console.log("");console.log("To resume a session:"),console.log(" coder --resume <session-id>")}var d0=(Q,Z,$)=>{let X=Q instanceof RegExp?xQ(Q,$):Q,V=Z instanceof RegExp?xQ(Z,$):Z,J=X!==null&&V!=null&&L6(X,V,$);return J&&{start:J[0],end:J[1],pre:$.slice(0,J[0]),body:$.slice(J[0]+X.length,J[1]),post:$.slice(J[1]+V.length)}},xQ=(Q,Z)=>{let $=Z.match(Q);return $?$[0]:null},L6=(Q,Z,$)=>{let X,V,J,z=void 0,Y,K=$.indexOf(Q),q=$.indexOf(Z,K+1),W=K;if(K>=0&&q>0){if(Q===Z)return[K,q];X=[],J=$.length;while(W>=0&&!Y){if(W===K)X.push(W),K=$.indexOf(Q,W+1);else if(X.length===1){let H=X.pop();if(H!==void 0)Y=[H,q]}else{if(V=X.pop(),V!==void 0&&V<J)J=V,z=q;q=$.indexOf(Z,W+1)}W=K<q&&K>=0?K:q}if(X.length&&z!==void 0)Y=[J,z]}return Y};var TQ="\x00SLASH"+Math.random()+"\x00",EQ="\x00OPEN"+Math.random()+"\x00",l0="\x00CLOSE"+Math.random()+"\x00",kQ="\x00COMMA"+Math.random()+"\x00",yQ="\x00PERIOD"+Math.random()+"\x00",F6=new RegExp(TQ,"g"),v6=new RegExp(EQ,"g"),O6=new RegExp(l0,"g"),C6=new RegExp(kQ,"g"),M6=new RegExp(yQ,"g"),R6=/\\\\/g,P6=/\\{/g,N6=/\\}/g,D6=/\\,/g,I6=/\\./g,S6=1e5;function c0(Q){return!isNaN(Q)?parseInt(Q,10):Q.charCodeAt(0)}function x6(Q){return Q.replace(R6,TQ).replace(P6,EQ).replace(N6,l0).replace(D6,kQ).replace(I6,yQ)}function T6(Q){return Q.replace(F6,"\\").replace(v6,"{").replace(O6,"}").replace(C6,",").replace(M6,".")}function bQ(Q){if(!Q)return[""];let Z=[],$=d0("{","}",Q);if(!$)return Q.split(",");let{pre:X,body:V,post:J}=$,z=X.split(",");z[z.length-1]+="{"+V+"}";let Y=bQ(J);if(J.length)z[z.length-1]+=Y.shift(),z.push.apply(z,Y);return Z.push.apply(Z,z),Z}function fQ(Q,Z={}){if(!Q)return[];let{max:$=S6}=Z;if(Q.slice(0,2)==="{}")Q="\\{\\}"+Q.slice(2);return d9(x6(Q),$,!0).map(T6)}function E6(Q){return"{"+Q+"}"}function k6(Q){return/^-?0\d/.test(Q)}function y6(Q,Z){return Q<=Z}function b6(Q,Z){return Q>=Z}function d9(Q,Z,$){let X=[],V=d0("{","}",Q);if(!V)return[Q];let J=V.pre,z=V.post.length?d9(V.post,Z,!1):[""];if(/\$$/.test(V.pre))for(let Y=0;Y<z.length&&Y<Z;Y++){let K=J+"{"+V.body+"}"+z[Y];X.push(K)}else{let Y=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(V.body),K=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(V.body),q=Y||K,W=V.body.indexOf(",")>=0;if(!q&&!W){if(V.post.match(/,(?!,).*\}/))return Q=V.pre+"{"+V.body+l0+V.post,d9(Q,Z,!0);return[Q]}let H;if(q)H=V.body.split(/\.\./);else if(H=bQ(V.body),H.length===1&&H[0]!==void 0){if(H=d9(H[0],Z,!1).map(E6),H.length===1)return z.map((j)=>V.pre+H[0]+j)}let G;if(q&&H[0]!==void 0&&H[1]!==void 0){let j=c0(H[0]),_=c0(H[1]),U=Math.max(H[0].length,H[1].length),A=H.length===3&&H[2]!==void 0?Math.abs(c0(H[2])):1,w=y6;if(_<j)A*=-1,w=b6;let v=H.some(k6);G=[];for(let O=j;w(O,_);O+=A){let F;if(K){if(F=String.fromCharCode(O),F==="\\")F=""}else if(F=String(O),v){let E=U-F.length;if(E>0){let y=Array(E+1).join("0");if(O<0)F="-"+y+F.slice(1);else F=y+F}}G.push(F)}}else{G=[];for(let j=0;j<H.length;j++)G.push.apply(G,d9(H[j],Z,!1))}for(let j=0;j<G.length;j++)for(let _=0;_<z.length&&X.length<Z;_++){let U=J+G[j]+z[_];if(!$||q||U)X.push(U)}}return X}var c9=(Q)=>{if(typeof Q!=="string")throw TypeError("invalid pattern");if(Q.length>65536)throw TypeError("pattern is too long")};var f6={"[: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]},l9=(Q)=>Q.replace(/[[\]\\-]/g,"\\$&"),u6=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),uQ=(Q)=>Q.join(""),hQ=(Q,Z)=>{let $=Z;if(Q.charAt($)!=="[")throw Error("not in a brace expression");let X=[],V=[],J=$+1,z=!1,Y=!1,K=!1,q=!1,W=$,H="";Q:while(J<Q.length){let U=Q.charAt(J);if((U==="!"||U==="^")&&J===$+1){q=!0,J++;continue}if(U==="]"&&z&&!K){W=J+1;break}if(z=!0,U==="\\"){if(!K){K=!0,J++;continue}}if(U==="["&&!K){for(let[A,[w,B,v]]of Object.entries(f6))if(Q.startsWith(A,J)){if(H)return["$.",!1,Q.length-$,!0];if(J+=A.length,v)V.push(w);else X.push(w);Y=Y||B;continue Q}}if(K=!1,H){if(U>H)X.push(l9(H)+"-"+l9(U));else if(U===H)X.push(l9(U));H="",J++;continue}if(Q.startsWith("-]",J+1)){X.push(l9(U+"-")),J+=2;continue}if(Q.startsWith("-",J+1)){H=U,J+=2;continue}X.push(l9(U)),J++}if(W<J)return["",!1,0,!1];if(!X.length&&!V.length)return["$.",!1,Q.length-$,!0];if(V.length===0&&X.length===1&&/^\\?.$/.test(X[0])&&!q){let U=X[0].length===2?X[0].slice(-1):X[0];return[u6(U),!1,W-$,!1]}let G="["+(q?"^":"")+uQ(X)+"]",j="["+(q?"":"^")+uQ(V)+"]";return[X.length&&V.length?"("+G+"|"+j+")":X.length?G:j,Y,W-$,!0]};var r=(Q,{windowsPathsNoEscape:Z=!1,magicalBraces:$=!0}={})=>{if($)return Z?Q.replace(/\[([^\/\\])\]/g,"$1"):Q.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");return Z?Q.replace(/\[([^\/\\{}])\]/g,"$1"):Q.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1")};var h,h6=new Set(["!","?","+","*","@"]),p0=(Q)=>h6.has(Q),gQ=(Q)=>p0(Q.type),g6=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),m6=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),d6=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),mQ=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),c6="(?!(?:^|/)\\.\\.?(?:$|/))",q0="(?!\\.)",l6=new Set(["[","."]),p6=new Set(["..","."]),i6=new Set("().*{}+?[]^$\\!"),n6=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),i0="[^/]",dQ=i0+"*?",cQ=i0+"+?",o6=0;class I9{type;#Q;#X;#V=!1;#Z=[];#z;#C;#B;#H=!1;#Y;#G;#W=!1;id=++o6;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.#Z.length,parts:this.#Z}}constructor(Q,Z,$={}){if(this.type=Q,Q)this.#X=!0;if(this.#z=Z,this.#Q=this.#z?this.#z.#Q:this,this.#Y=this.#Q===this?$:this.#Q.#Y,this.#B=this.#Q===this?[]:this.#Q.#B,Q==="!"&&!this.#Q.#H)this.#B.push(this);this.#C=this.#z?this.#z.#Z.length:0}get hasMagic(){if(this.#X!==void 0)return this.#X;for(let Q of this.#Z){if(typeof Q==="string")continue;if(Q.type||Q.hasMagic)return this.#X=!0}return this.#X}toString(){if(this.#G!==void 0)return this.#G;if(!this.type)return this.#G=this.#Z.map((Q)=>String(Q)).join("");else return this.#G=this.type+"("+this.#Z.map((Q)=>String(Q)).join("|")+")"}#K(){if(this!==this.#Q)throw Error("should only call on root");if(this.#H)return this;this.toString(),this.#H=!0;let Q;while(Q=this.#B.pop()){if(Q.type!=="!")continue;let Z=Q,$=Z.#z;while($){for(let X=Z.#C+1;!$.type&&X<$.#Z.length;X++)for(let V of Q.#Z){if(typeof V==="string")throw Error("string part in extglob AST??");V.copyIn($.#Z[X])}Z=$,$=Z.#z}}return this}push(...Q){for(let Z of Q){if(Z==="")continue;if(typeof Z!=="string"&&!(Z instanceof h&&Z.#z===this))throw Error("invalid part: "+Z);this.#Z.push(Z)}}toJSON(){let Q=this.type===null?this.#Z.slice().map((Z)=>typeof Z==="string"?Z:Z.toJSON()):[this.type,...this.#Z.map((Z)=>Z.toJSON())];if(this.isStart()&&!this.type)Q.unshift([]);if(this.isEnd()&&(this===this.#Q||this.#Q.#H&&this.#z?.type==="!"))Q.push({});return Q}isStart(){if(this.#Q===this)return!0;if(!this.#z?.isStart())return!1;if(this.#C===0)return!0;let Q=this.#z;for(let Z=0;Z<this.#C;Z++){let $=Q.#Z[Z];if(!($ instanceof h&&$.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.#Z.length:0;return this.#C===Q-1}copyIn(Q){if(typeof Q==="string")this.push(Q);else this.push(Q.clone(this))}clone(Q){let Z=new h(this.type,Q);for(let $ of this.#Z)Z.copyIn($);return Z}static#J(Q,Z,$,X,V){let J=X.maxExtglobRecursion??2,z=!1,Y=!1,K=-1,q=!1;if(Z.type===null){let _=$,U="";while(_<Q.length){let A=Q.charAt(_++);if(z||A==="\\"){z=!z,U+=A;continue}if(Y){if(_===K+1){if(A==="^"||A==="!")q=!0}else if(A==="]"&&!(_===K+2&&q))Y=!1;U+=A;continue}else if(A==="["){Y=!0,K=_,q=!1,U+=A;continue}if(!X.noext&&p0(A)&&Q.charAt(_)==="("&&V<=J){Z.push(U),U="";let B=new h(A,Z);_=h.#J(Q,B,_,X,V+1),Z.push(B);continue}U+=A}return Z.push(U),_}let W=$+1,H=new h(null,Z),G=[],j="";while(W<Q.length){let _=Q.charAt(W++);if(z||_==="\\"){z=!z,j+=_;continue}if(Y){if(W===K+1){if(_==="^"||_==="!")q=!0}else if(_==="]"&&!(W===K+2&&q))Y=!1;j+=_;continue}else if(_==="["){Y=!0,K=W,q=!1,j+=_;continue}if(!X.noext&&p0(_)&&Q.charAt(W)==="("&&(V<=J||Z&&Z.#_(_))){let A=Z&&Z.#_(_)?0:1;H.push(j),j="";let w=new h(_,H);H.push(w),W=h.#J(Q,w,W,X,V+A);continue}if(_==="|"){H.push(j),j="",G.push(H),H=new h(null,Z);continue}if(_===")"){if(j===""&&Z.#Z.length===0)Z.#W=!0;return H.push(j),j="",Z.push(...G,H),W}j+=_}return Z.type=null,Z.#X=void 0,Z.#Z=[Q.substring($-1)],W}#L(Q){return this.#v(Q,m6)}#v(Q,Z=g6){if(!Q||typeof Q!=="object"||Q.type!==null||Q.#Z.length!==1||this.type===null)return!1;let $=Q.#Z[0];if(!$||typeof $!=="object"||$.type===null)return!1;return this.#_($.type,Z)}#_(Q,Z=d6){return!!Z.get(this.type)?.includes(Q)}#U(Q,Z){let $=Q.#Z[0],X=new h(null,$,this.options);X.#Z.push(""),$.push(X),this.#P(Q,Z)}#P(Q,Z){let $=Q.#Z[0];this.#Z.splice(Z,1,...$.#Z);for(let X of $.#Z)if(typeof X==="object")X.#z=this;this.#G=void 0}#w(Q){return!!mQ.get(this.type)?.has(Q)}#O(Q){if(!Q||typeof Q!=="object"||Q.type!==null||Q.#Z.length!==1||this.type===null||this.#Z.length!==1)return!1;let Z=Q.#Z[0];if(!Z||typeof Z!=="object"||Z.type===null)return!1;return this.#w(Z.type)}#M(Q){let Z=mQ.get(this.type),$=Q.#Z[0],X=Z?.get($.type);if(!X)return!1;this.#Z=$.#Z;for(let V of this.#Z)if(typeof V==="object")V.#z=this;this.type=X,this.#G=void 0,this.#W=!1}static fromGlob(Q,Z={}){let $=new h(null,void 0,Z);return h.#J(Q,$,0,Z,0),$}toMMPattern(){if(this!==this.#Q)return this.#Q.toMMPattern();let Q=this.toString(),[Z,$,X,V]=this.toRegExpSource();if(!(X||this.#X||this.#Y.nocase&&!this.#Y.nocaseMagicOnly&&Q.toUpperCase()!==Q.toLowerCase()))return $;let z=(this.#Y.nocase?"i":"")+(V?"u":"");return Object.assign(new RegExp(`^${Z}$`,z),{_src:Z,_glob:Q})}get options(){return this.#Y}toRegExpSource(Q){let Z=Q??!!this.#Y.dot;if(this.#Q===this)this.#j(),this.#K();if(!gQ(this)){let Y=this.isStart()&&this.isEnd()&&!this.#Z.some((G)=>typeof G!=="string"),K=this.#Z.map((G)=>{let[j,_,U,A]=typeof G==="string"?h.#F(G,this.#X,Y):G.toRegExpSource(Q);return this.#X=this.#X||U,this.#V=this.#V||A,j}).join(""),q="";if(this.isStart()){if(typeof this.#Z[0]==="string"){if(!(this.#Z.length===1&&p6.has(this.#Z[0]))){let j=l6,_=Z&&j.has(K.charAt(0))||K.startsWith("\\.")&&j.has(K.charAt(2))||K.startsWith("\\.\\.")&&j.has(K.charAt(4)),U=!Z&&!Q&&j.has(K.charAt(0));q=_?c6:U?q0:""}}}let W="";if(this.isEnd()&&this.#Q.#H&&this.#z?.type==="!")W="(?:$|\\/)";return[q+K+W,r(K),this.#X=!!this.#X,this.#V]}let $=this.type==="*"||this.type==="+",X=this.type==="!"?"(?:(?!(?:":"(?:",V=this.#A(Z);if(this.isStart()&&this.isEnd()&&!V&&this.type!=="!"){let Y=this.toString(),K=this;return K.#Z=[Y],K.type=null,K.#X=void 0,[Y,r(this.toString()),!1,!1]}let J=!$||Q||Z||!q0?"":this.#A(!0);if(J===V)J="";if(J)V=`(?:${V})(?:${J})*?`;let z="";if(this.type==="!"&&this.#W)z=(this.isStart()&&!Z?q0:"")+cQ;else{let Y=this.type==="!"?"))"+(this.isStart()&&!Z&&!Q?q0:"")+dQ+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&J?")":this.type==="*"&&J?")?":`)${this.type}`;z=X+V+Y}return[z,r(V),this.#X=!!this.#X,this.#V]}#j(){if(!gQ(this)){for(let Q of this.#Z)if(typeof Q==="object")Q.#j()}else{let Q=0,Z=!1;do{Z=!0;for(let $=0;$<this.#Z.length;$++){let X=this.#Z[$];if(typeof X==="object"){if(X.#j(),this.#v(X))Z=!1,this.#P(X,$);else if(this.#L(X))Z=!1,this.#U(X,$);else if(this.#O(X))Z=!1,this.#M(X)}}}while(!Z&&++Q<10)}this.#G=void 0}#A(Q){return this.#Z.map((Z)=>{if(typeof Z==="string")throw Error("string type in extglob ast??");let[$,X,V,J]=Z.toRegExpSource(Q);return this.#V=this.#V||J,$}).filter((Z)=>!(this.isStart()&&this.isEnd())||!!Z).join("|")}static#F(Q,Z,$=!1){let X=!1,V="",J=!1,z=!1;for(let Y=0;Y<Q.length;Y++){let K=Q.charAt(Y);if(X){X=!1,V+=(i6.has(K)?"\\":"")+K;continue}if(K==="*"){if(z)continue;z=!0,V+=$&&/^[*]+$/.test(Q)?cQ:dQ,Z=!0;continue}else z=!1;if(K==="\\"){if(Y===Q.length-1)V+="\\\\";else X=!0;continue}if(K==="["){let[q,W,H,G]=hQ(Q,Y);if(H){V+=q,J=J||W,Y+=H-1,Z=Z||G;continue}}if(K==="?"){V+=i0,Z=!0;continue}V+=n6(K)}return[V,r(Q),!!Z,J]}}h=I9;var S9=(Q,{windowsPathsNoEscape:Z=!1,magicalBraces:$=!1}={})=>{if($)return Z?Q.replace(/[?*()[\]{}]/g,"[$&]"):Q.replace(/[?*()[\]\\{}]/g,"\\$&");return Z?Q.replace(/[?*()[\]]/g,"[$&]"):Q.replace(/[?*()[\]\\]/g,"\\$&")};var b=(Q,Z,$={})=>{if(c9(Z),!$.nocomment&&Z.charAt(0)==="#")return!1;return new l(Z,$).match(Q)},r6=/^\*+([^+@!?\*\[\(]*)$/,a6=(Q)=>(Z)=>!Z.startsWith(".")&&Z.endsWith(Q),s6=(Q)=>(Z)=>Z.endsWith(Q),t6=(Q)=>{return Q=Q.toLowerCase(),(Z)=>!Z.startsWith(".")&&Z.toLowerCase().endsWith(Q)},e6=(Q)=>{return Q=Q.toLowerCase(),(Z)=>Z.toLowerCase().endsWith(Q)},QZ=/^\*+\.\*+$/,ZZ=(Q)=>!Q.startsWith(".")&&Q.includes("."),$Z=(Q)=>Q!=="."&&Q!==".."&&Q.includes("."),XZ=/^\.\*+$/,VZ=(Q)=>Q!=="."&&Q!==".."&&Q.startsWith("."),JZ=/^\*+$/,zZ=(Q)=>Q.length!==0&&!Q.startsWith("."),YZ=(Q)=>Q.length!==0&&Q!=="."&&Q!=="..",KZ=/^\?+([^+@!?\*\[\(]*)?$/,qZ=([Q,Z=""])=>{let $=iQ([Q]);if(!Z)return $;return Z=Z.toLowerCase(),(X)=>$(X)&&X.toLowerCase().endsWith(Z)},WZ=([Q,Z=""])=>{let $=nQ([Q]);if(!Z)return $;return Z=Z.toLowerCase(),(X)=>$(X)&&X.toLowerCase().endsWith(Z)},HZ=([Q,Z=""])=>{let $=nQ([Q]);return!Z?$:(X)=>$(X)&&X.endsWith(Z)},GZ=([Q,Z=""])=>{let $=iQ([Q]);return!Z?$:(X)=>$(X)&&X.endsWith(Z)},iQ=([Q])=>{let Z=Q.length;return($)=>$.length===Z&&!$.startsWith(".")},nQ=([Q])=>{let Z=Q.length;return($)=>$.length===Z&&$!=="."&&$!==".."},oQ=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",lQ={win32:{sep:"\\"},posix:{sep:"/"}},jZ=oQ==="win32"?lQ.win32.sep:lQ.posix.sep;b.sep=jZ;var N=Symbol("globstar **");b.GLOBSTAR=N;var _Z="[^/]",UZ=_Z+"*?",wZ="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",AZ="(?:(?!(?:\\/|^)\\.).)*?",BZ=(Q,Z={})=>($)=>b($,Q,Z);b.filter=BZ;var c=(Q,Z={})=>Object.assign({},Q,Z),LZ=(Q)=>{if(!Q||typeof Q!=="object"||!Object.keys(Q).length)return b;let Z=b;return Object.assign((X,V,J={})=>Z(X,V,c(Q,J)),{Minimatch:class extends Z.Minimatch{constructor(V,J={}){super(V,c(Q,J))}static defaults(V){return Z.defaults(c(Q,V)).Minimatch}},AST:class extends Z.AST{constructor(V,J,z={}){super(V,J,c(Q,z))}static fromGlob(V,J={}){return Z.AST.fromGlob(V,c(Q,J))}},unescape:(X,V={})=>Z.unescape(X,c(Q,V)),escape:(X,V={})=>Z.escape(X,c(Q,V)),filter:(X,V={})=>Z.filter(X,c(Q,V)),defaults:(X)=>Z.defaults(c(Q,X)),makeRe:(X,V={})=>Z.makeRe(X,c(Q,V)),braceExpand:(X,V={})=>Z.braceExpand(X,c(Q,V)),match:(X,V,J={})=>Z.match(X,V,c(Q,J)),sep:Z.sep,GLOBSTAR:N})};b.defaults=LZ;var rQ=(Q,Z={})=>{if(c9(Q),Z.nobrace||!/\{(?:(?!\{).)*\}/.test(Q))return[Q];return fQ(Q,{max:Z.braceExpandMax})};b.braceExpand=rQ;var FZ=(Q,Z={})=>new l(Q,Z).makeRe();b.makeRe=FZ;var vZ=(Q,Z,$={})=>{let X=new l(Z,$);if(Q=Q.filter((V)=>X.match(V)),X.options.nonull&&!Q.length)Q.push(Z);return Q};b.match=vZ;var pQ=/[?*]|[+@!]\(.*?\)|\[|\]/,OZ=(Q)=>Q.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class l{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(Q,Z={}){c9(Q),Z=Z||{},this.options=Z,this.maxGlobstarRecursion=Z.maxGlobstarRecursion??200,this.pattern=Q,this.platform=Z.platform||oQ,this.isWindows=this.platform==="win32";let $="allowWindowsEscape";if(this.windowsPathsNoEscape=!!Z.windowsPathsNoEscape||Z[$]===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!Z.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!Z.nonegate,this.comment=!1,this.empty=!1,this.partial=!!Z.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=Z.windowsNoMagicRoot!==void 0?Z.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 Z of Q)if(typeof Z!=="string")return!0;return!1}debug(...Q){}make(){let Q=this.pattern,Z=this.options;if(!Z.nocomment&&Q.charAt(0)==="#"){this.comment=!0;return}if(!Q){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],Z.debug)this.debug=(...V)=>console.error(...V);this.debug(this.pattern,this.globSet);let $=this.globSet.map((V)=>this.slashSplit(V));this.globParts=this.preprocess($),this.debug(this.pattern,this.globParts);let X=this.globParts.map((V,J,z)=>{if(this.isWindows&&this.windowsNoMagicRoot){let Y=V[0]===""&&V[1]===""&&(V[2]==="?"||!pQ.test(V[2]))&&!pQ.test(V[3]),K=/^[a-z]:/i.test(V[0]);if(Y)return[...V.slice(0,4),...V.slice(4).map((q)=>this.parse(q))];else if(K)return[V[0],...V.slice(1).map((q)=>this.parse(q))]}return V.map((Y)=>this.parse(Y))});if(this.debug(this.pattern,X),this.set=X.filter((V)=>V.indexOf(!1)===-1),this.isWindows)for(let V=0;V<this.set.length;V++){let J=this.set[V];if(J[0]===""&&J[1]===""&&this.globParts[V][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 $=0;$<Q.length;$++)for(let X=0;X<Q[$].length;X++)if(Q[$][X]==="**")Q[$][X]="*"}let{optimizationLevel:Z=1}=this.options;if(Z>=2)Q=this.firstPhasePreProcess(Q),Q=this.secondPhasePreProcess(Q);else if(Z>=1)Q=this.levelOneOptimize(Q);else Q=this.adjascentGlobstarOptimize(Q);return Q}adjascentGlobstarOptimize(Q){return Q.map((Z)=>{let $=-1;while(($=Z.indexOf("**",$+1))!==-1){let X=$;while(Z[X+1]==="**")X++;if(X!==$)Z.splice($,X-$)}return Z})}levelOneOptimize(Q){return Q.map((Z)=>{return Z=Z.reduce(($,X)=>{let V=$[$.length-1];if(X==="**"&&V==="**")return $;if(X===".."){if(V&&V!==".."&&V!=="."&&V!=="**")return $.pop(),$}return $.push(X),$},[]),Z.length===0?[""]:Z})}levelTwoFileOptimize(Q){if(!Array.isArray(Q))Q=this.slashSplit(Q);let Z=!1;do{if(Z=!1,!this.preserveMultipleSlashes){for(let X=1;X<Q.length-1;X++){let V=Q[X];if(X===1&&V===""&&Q[0]==="")continue;if(V==="."||V==="")Z=!0,Q.splice(X,1),X--}if(Q[0]==="."&&Q.length===2&&(Q[1]==="."||Q[1]===""))Z=!0,Q.pop()}let $=0;while(($=Q.indexOf("..",$+1))!==-1){let X=Q[$-1];if(X&&X!=="."&&X!==".."&&X!=="**")Z=!0,Q.splice($-1,2),$-=2}}while(Z);return Q.length===0?[""]:Q}firstPhasePreProcess(Q){let Z=!1;do{Z=!1;for(let $ of Q){let X=-1;while((X=$.indexOf("**",X+1))!==-1){let J=X;while($[J+1]==="**")J++;if(J>X)$.splice(X+1,J-X);let z=$[X+1],Y=$[X+2],K=$[X+3];if(z!=="..")continue;if(!Y||Y==="."||Y===".."||!K||K==="."||K==="..")continue;Z=!0,$.splice(X,1);let q=$.slice(0);q[X]="**",Q.push(q),X--}if(!this.preserveMultipleSlashes){for(let J=1;J<$.length-1;J++){let z=$[J];if(J===1&&z===""&&$[0]==="")continue;if(z==="."||z==="")Z=!0,$.splice(J,1),J--}if($[0]==="."&&$.length===2&&($[1]==="."||$[1]===""))Z=!0,$.pop()}let V=0;while((V=$.indexOf("..",V+1))!==-1){let J=$[V-1];if(J&&J!=="."&&J!==".."&&J!=="**"){Z=!0;let Y=V===1&&$[V+1]==="**"?["."]:[];if($.splice(V-1,2,...Y),$.length===0)$.push("");V-=2}}}}while(Z);return Q}secondPhasePreProcess(Q){for(let Z=0;Z<Q.length-1;Z++)for(let $=Z+1;$<Q.length;$++){let X=this.partsMatch(Q[Z],Q[$],!this.preserveMultipleSlashes);if(X){Q[Z]=[],Q[$]=X;break}}return Q.filter((Z)=>Z.length)}partsMatch(Q,Z,$=!1){let X=0,V=0,J=[],z="";while(X<Q.length&&V<Z.length)if(Q[X]===Z[V])J.push(z==="b"?Z[V]:Q[X]),X++,V++;else if($&&Q[X]==="**"&&Z[V]===Q[X+1])J.push(Q[X]),X++;else if($&&Z[V]==="**"&&Q[X]===Z[V+1])J.push(Z[V]),V++;else if(Q[X]==="*"&&Z[V]&&(this.options.dot||!Z[V].startsWith("."))&&Z[V]!=="**"){if(z==="b")return!1;z="a",J.push(Q[X]),X++,V++}else if(Z[V]==="*"&&Q[X]&&(this.options.dot||!Q[X].startsWith("."))&&Q[X]!=="**"){if(z==="a")return!1;z="b",J.push(Z[V]),X++,V++}else return!1;return Q.length===Z.length&&J}parseNegate(){if(this.nonegate)return;let Q=this.pattern,Z=!1,$=0;for(let X=0;X<Q.length&&Q.charAt(X)==="!";X++)Z=!Z,$++;if($)this.pattern=Q.slice($);this.negate=Z}matchOne(Q,Z,$=!1){let X=0,V=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 Z[0]==="string"&&/^[a-z]:$/i.test(Z[0]),q=!K&&Z[0]===""&&Z[1]===""&&Z[2]==="?"&&typeof Z[3]==="string"&&/^[a-z]:$/i.test(Z[3]),W=Y?3:z?0:void 0,H=q?3:K?0:void 0;if(typeof W==="number"&&typeof H==="number"){let[G,j]=[Q[W],Z[H]];if(G.toLowerCase()===j.toLowerCase())Z[H]=G,V=H,X=W}}let{optimizationLevel:J=1}=this.options;if(J>=2)Q=this.levelTwoFileOptimize(Q);if(Z.includes(N))return this.#Q(Q,Z,$,X,V);return this.#V(Q,Z,$,X,V)}#Q(Q,Z,$,X,V){let J=Z.indexOf(N,V),z=Z.lastIndexOf(N),[Y,K,q]=$?[Z.slice(V,J),Z.slice(J+1),[]]:[Z.slice(V,J),Z.slice(J+1,z),Z.slice(z+1)];if(Y.length){let w=Q.slice(X,X+Y.length);if(!this.#V(w,Y,$,0,0))return!1;X+=Y.length,V+=Y.length}let W=0;if(q.length){if(q.length+X>Q.length)return!1;let w=Q.length-q.length;if(this.#V(Q,q,$,w,0))W=q.length;else{if(Q[Q.length-1]!==""||X+q.length===Q.length)return!1;if(w--,!this.#V(Q,q,$,w,0))return!1;W=q.length+1}}if(!K.length){let w=!!W;for(let B=X;B<Q.length-W;B++){let v=String(Q[B]);if(w=!0,v==="."||v===".."||!this.options.dot&&v.startsWith("."))return!1}return $||w}let H=[[[],0]],G=H[0],j=0,_=[0];for(let w of K)if(w===N)_.push(j),G=[[],0],H.push(G);else G[0].push(w),j++;let U=H.length-1,A=Q.length-W;for(let w of H)w[1]=A-(_[U--]+w[0].length);return!!this.#X(Q,H,X,0,$,0,!!W)}#X(Q,Z,$,X,V,J,z){let Y=Z[X];if(!Y){for(let W=$;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($<=q){if(this.#V(Q.slice(0,$+K.length),K,V,$,0)&&J<this.maxGlobstarRecursion){let G=this.#X(Q,Z,$+K.length,X+1,V,J+1,z);if(G!==!1)return G}let H=Q[$];if(H==="."||H===".."||!this.options.dot&&H.startsWith("."))return!1;$++}return V||null}#V(Q,Z,$,X,V){let J,z,Y,K;for(J=X,z=V,K=Q.length,Y=Z.length;J<K&&z<Y;J++,z++){this.debug("matchOne loop");let q=Z[z],W=Q[J];if(this.debug(Z,q,W),q===!1||q===N)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 $;else if(z===Y)return J===K-1&&Q[J]==="";else throw Error("wtf?")}braceExpand(){return rQ(this.pattern,this.options)}parse(Q){c9(Q);let Z=this.options;if(Q==="**")return N;if(Q==="")return"";let $,X=null;if($=Q.match(JZ))X=Z.dot?YZ:zZ;else if($=Q.match(r6))X=(Z.nocase?Z.dot?e6:t6:Z.dot?s6:a6)($[1]);else if($=Q.match(KZ))X=(Z.nocase?Z.dot?WZ:qZ:Z.dot?HZ:GZ)($);else if($=Q.match(QZ))X=Z.dot?$Z:ZZ;else if($=Q.match(XZ))X=VZ;let V=I9.fromGlob(Q,this.options).toMMPattern();if(X&&typeof V==="object")Reflect.defineProperty(V,"test",{value:X});return V}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let Q=this.set;if(!Q.length)return this.regexp=!1,this.regexp;let Z=this.options,$=Z.noglobstar?UZ:Z.dot?wZ:AZ,X=new Set(Z.nocase?["i"]:[]),V=Q.map((Y)=>{let K=Y.map((W)=>{if(W instanceof RegExp)for(let H of W.flags.split(""))X.add(H);return typeof W==="string"?OZ(W):W===N?N:W._src});K.forEach((W,H)=>{let G=K[H+1],j=K[H-1];if(W!==N||j===N)return;if(j===void 0)if(G!==void 0&&G!==N)K[H+1]="(?:\\/|"+$+"\\/)?"+G;else K[H]=$;else if(G===void 0)K[H-1]=j+"(?:\\/|\\/"+$+")?";else if(G!==N)K[H-1]=j+"(?:\\/|\\/"+$+"\\/)"+G,K[H+1]=N});let q=K.filter((W)=>W!==N);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(V="^"+J+V+z+"$",this.partial)V="^(?:\\/|"+J+V.slice(1,-1)+z+")$";if(this.negate)V="^(?!"+V+").+$";try{this.regexp=new RegExp(V,[...X].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,Z=this.partial){if(this.debug("match",Q,this.pattern),this.comment)return!1;if(this.empty)return Q==="";if(Q==="/"&&Z)return!0;let $=this.options;if(this.isWindows)Q=Q.split("\\").join("/");let X=this.slashSplit(Q);this.debug(this.pattern,"split",X);let V=this.set;this.debug(this.pattern,"set",V);let J=X[X.length-1];if(!J)for(let z=X.length-2;!J&&z>=0;z--)J=X[z];for(let z=0;z<V.length;z++){let Y=V[z],K=X;if($.matchBase&&Y.length===1)K=[J];if(this.matchOne(K,Y,Z)){if($.flipNegate)return!0;return!this.negate}}if($.flipNegate)return!1;return this.negate}static defaults(Q){return b.defaults(Q).Minimatch}}b.AST=I9;b.Minimatch=l;b.escape=S9;b.unescape=r;import{fileURLToPath as $5}from"url";var CZ=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,sQ=new Set,n0=typeof process=="object"&&process?process:{},tQ=(Q,Z,$,X)=>{typeof n0.emitWarning=="function"?n0.emitWarning(Q,Z,$,X):console.error(`[${$}] ${Z}: ${Q}`)},H0=globalThis.AbortController,aQ=globalThis.AbortSignal;if(typeof H0>"u"){aQ=class{onabort;_onabort=[];reason;aborted=!1;addEventListener($,X){this._onabort.push(X)}},H0=class{constructor(){Z()}signal=new aQ;abort($){if(!this.signal.aborted){this.signal.reason=$,this.signal.aborted=!0;for(let X of this.signal._onabort)X($);this.signal.onabort?.($)}}};let Q=n0.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",Z=()=>{Q&&(Q=!1,tQ("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",Z))}}var MZ=(Q)=>!sQ.has(Q),o7=Symbol("type"),B9=(Q)=>Q&&Q===Math.floor(Q)&&Q>0&&isFinite(Q),eQ=(Q)=>B9(Q)?Q<=Math.pow(2,8)?Uint8Array:Q<=Math.pow(2,16)?Uint16Array:Q<=Math.pow(2,32)?Uint32Array:Q<=Number.MAX_SAFE_INTEGER?W0:null:null,W0=class extends Array{constructor(Q){super(Q),this.fill(0)}},RZ=class Q{heap;length;static#Q=!1;static create(Z){let $=eQ(Z);if(!$)return[];Q.#Q=!0;let X=new Q(Z,$);return Q.#Q=!1,X}constructor(Z,$){if(!Q.#Q)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new $(Z),this.length=0}push(Z){this.heap[this.length++]=Z}pop(){return this.heap[--this.length]}},p9=class Q{#Q;#X;#V;#Z;#z;#C;#B;#H;get perf(){return this.#H}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#Y;#G;#W;#K;#J;#L;#v;#_;#U;#P;#w;#O;#M;#j;#A;#F;#N;#$;#k;static unsafeExposeInternals(Z){return{starts:Z.#M,ttls:Z.#j,autopurgeTimers:Z.#A,sizes:Z.#O,keyMap:Z.#W,keyList:Z.#K,valList:Z.#J,next:Z.#L,prev:Z.#v,get head(){return Z.#_},get tail(){return Z.#U},free:Z.#P,isBackgroundFetch:($)=>Z.#q($),backgroundFetch:($,X,V,J)=>Z.#d($,X,V,J),moveToTail:($)=>Z.#b($),indexes:($)=>Z.#S($),rindexes:($)=>Z.#x($),isStale:($)=>Z.#R($)}}get max(){return this.#Q}get maxSize(){return this.#X}get calculatedSize(){return this.#G}get size(){return this.#Y}get fetchMethod(){return this.#C}get memoMethod(){return this.#B}get dispose(){return this.#V}get onInsert(){return this.#Z}get disposeAfter(){return this.#z}constructor(Z){let{max:$=0,ttl:X,ttlResolution:V=1,ttlAutopurge:J,updateAgeOnGet:z,updateAgeOnHas:Y,allowStale:K,dispose:q,onInsert:W,disposeAfter:H,noDisposeOnSet:G,noUpdateTTL:j,maxSize:_=0,maxEntrySize:U=0,sizeCalculation:A,fetchMethod:w,memoMethod:B,noDeleteOnFetchRejection:v,noDeleteOnStaleGet:O,allowStaleOnFetchRejection:F,allowStaleOnFetchAbort:E,ignoreFetchAbort:y,perf:t}=Z;if(t!==void 0&&typeof t?.now!="function")throw TypeError("perf option must have a now() method if specified");if(this.#H=t??CZ,$!==0&&!B9($))throw TypeError("max option must be a nonnegative integer");let P=$?eQ($):Array;if(!P)throw Error("invalid max value: "+$);if(this.#Q=$,this.#X=_,this.maxEntrySize=U||this.#X,this.sizeCalculation=A,this.sizeCalculation){if(!this.#X&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw TypeError("sizeCalculation set to non-function")}if(B!==void 0&&typeof B!="function")throw TypeError("memoMethod must be a function if defined");if(this.#B=B,w!==void 0&&typeof w!="function")throw TypeError("fetchMethod must be a function if specified");if(this.#C=w,this.#N=!!w,this.#W=new Map,this.#K=Array($).fill(void 0),this.#J=Array($).fill(void 0),this.#L=new P($),this.#v=new P($),this.#_=0,this.#U=0,this.#P=RZ.create($),this.#Y=0,this.#G=0,typeof q=="function"&&(this.#V=q),typeof W=="function"&&(this.#Z=W),typeof H=="function"?(this.#z=H,this.#w=[]):(this.#z=void 0,this.#w=void 0),this.#F=!!this.#V,this.#k=!!this.#Z,this.#$=!!this.#z,this.noDisposeOnSet=!!G,this.noUpdateTTL=!!j,this.noDeleteOnFetchRejection=!!v,this.allowStaleOnFetchRejection=!!F,this.allowStaleOnFetchAbort=!!E,this.ignoreFetchAbort=!!y,this.maxEntrySize!==0){if(this.#X!==0&&!B9(this.#X))throw TypeError("maxSize must be a positive integer if specified");if(!B9(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#l()}if(this.allowStale=!!K,this.noDeleteOnStaleGet=!!O,this.updateAgeOnGet=!!z,this.updateAgeOnHas=!!Y,this.ttlResolution=B9(V)||V===0?V:1,this.ttlAutopurge=!!J,this.ttl=X||0,this.ttl){if(!B9(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#T()}if(this.#Q===0&&this.ttl===0&&this.#X===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Q&&!this.#X){let n="LRU_CACHE_UNBOUNDED";MZ(n)&&(sQ.add(n),tQ("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",n,Q))}}getRemainingTTL(Z){return this.#W.has(Z)?1/0:0}#T(){let Z=new W0(this.#Q),$=new W0(this.#Q);this.#j=Z,this.#M=$;let X=this.ttlAutopurge?Array(this.#Q):void 0;this.#A=X,this.#u=(z,Y,K=this.#H.now())=>{if($[z]=Y!==0?K:0,Z[z]=Y,X?.[z]&&(clearTimeout(X[z]),X[z]=void 0),Y!==0&&X){let q=setTimeout(()=>{this.#R(z)&&this.#I(this.#K[z],"expire")},Y+1);q.unref&&q.unref(),X[z]=q}},this.#D=(z)=>{$[z]=Z[z]!==0?this.#H.now():0},this.#E=(z,Y)=>{if(Z[Y]){let K=Z[Y],q=$[Y];if(!K||!q)return;z.ttl=K,z.start=q,z.now=V||J();let W=z.now-q;z.remainingTTL=K-W}};let V=0,J=()=>{let z=this.#H.now();if(this.ttlResolution>0){V=z;let Y=setTimeout(()=>V=0,this.ttlResolution);Y.unref&&Y.unref()}return z};this.getRemainingTTL=(z)=>{let Y=this.#W.get(z);if(Y===void 0)return 0;let K=Z[Y],q=$[Y];if(!K||!q)return 1/0;let W=(V||J())-q;return K-W},this.#R=(z)=>{let Y=$[z],K=Z[z];return!!K&&!!Y&&(V||J())-Y>K}}#D=()=>{};#E=()=>{};#u=()=>{};#R=()=>!1;#l(){let Z=new W0(this.#Q);this.#G=0,this.#O=Z,this.#f=($)=>{this.#G-=Z[$],Z[$]=0},this.#h=($,X,V,J)=>{if(this.#q(X))return 0;if(!B9(V))if(J){if(typeof J!="function")throw TypeError("sizeCalculation must be a function");if(V=J(X,$),!B9(V))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 V},this.#y=($,X,V)=>{if(Z[$]=X,this.#X){let J=this.#X-Z[$];for(;this.#G>J;)this.#m(!0)}this.#G+=Z[$],V&&(V.entrySize=X,V.totalCalculatedSize=this.#G)}}#f=(Z)=>{};#y=(Z,$,X)=>{};#h=(Z,$,X,V)=>{if(X||V)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#S({allowStale:Z=this.allowStale}={}){if(this.#Y)for(let $=this.#U;!(!this.#g($)||((Z||!this.#R($))&&(yield $),$===this.#_));)$=this.#v[$]}*#x({allowStale:Z=this.allowStale}={}){if(this.#Y)for(let $=this.#_;!(!this.#g($)||((Z||!this.#R($))&&(yield $),$===this.#U));)$=this.#L[$]}#g(Z){return Z!==void 0&&this.#W.get(this.#K[Z])===Z}*entries(){for(let Z of this.#S())this.#J[Z]!==void 0&&this.#K[Z]!==void 0&&!this.#q(this.#J[Z])&&(yield[this.#K[Z],this.#J[Z]])}*rentries(){for(let Z of this.#x())this.#J[Z]!==void 0&&this.#K[Z]!==void 0&&!this.#q(this.#J[Z])&&(yield[this.#K[Z],this.#J[Z]])}*keys(){for(let Z of this.#S()){let $=this.#K[Z];$!==void 0&&!this.#q(this.#J[Z])&&(yield $)}}*rkeys(){for(let Z of this.#x()){let $=this.#K[Z];$!==void 0&&!this.#q(this.#J[Z])&&(yield $)}}*values(){for(let Z of this.#S())this.#J[Z]!==void 0&&!this.#q(this.#J[Z])&&(yield this.#J[Z])}*rvalues(){for(let Z of this.#x())this.#J[Z]!==void 0&&!this.#q(this.#J[Z])&&(yield this.#J[Z])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(Z,$={}){for(let X of this.#S()){let V=this.#J[X],J=this.#q(V)?V.__staleWhileFetching:V;if(J!==void 0&&Z(J,this.#K[X],this))return this.get(this.#K[X],$)}}forEach(Z,$=this){for(let X of this.#S()){let V=this.#J[X],J=this.#q(V)?V.__staleWhileFetching:V;J!==void 0&&Z.call($,J,this.#K[X],this)}}rforEach(Z,$=this){for(let X of this.#x()){let V=this.#J[X],J=this.#q(V)?V.__staleWhileFetching:V;J!==void 0&&Z.call($,J,this.#K[X],this)}}purgeStale(){let Z=!1;for(let $ of this.#x({allowStale:!0}))this.#R($)&&(this.#I(this.#K[$],"expire"),Z=!0);return Z}info(Z){let $=this.#W.get(Z);if($===void 0)return;let X=this.#J[$],V=this.#q(X)?X.__staleWhileFetching:X;if(V===void 0)return;let J={value:V};if(this.#j&&this.#M){let z=this.#j[$],Y=this.#M[$];if(z&&Y){let K=z-(this.#H.now()-Y);J.ttl=K,J.start=Date.now()}}return this.#O&&(J.size=this.#O[$]),J}dump(){let Z=[];for(let $ of this.#S({allowStale:!0})){let X=this.#K[$],V=this.#J[$],J=this.#q(V)?V.__staleWhileFetching:V;if(J===void 0||X===void 0)continue;let z={value:J};if(this.#j&&this.#M){z.ttl=this.#j[$];let Y=this.#H.now()-this.#M[$];z.start=Math.floor(Date.now()-Y)}this.#O&&(z.size=this.#O[$]),Z.unshift([X,z])}return Z}load(Z){this.clear();for(let[$,X]of Z){if(X.start){let V=Date.now()-X.start;X.start=this.#H.now()-V}this.set($,X.value,X)}}set(Z,$,X={}){if($===void 0)return this.delete(Z),this;let{ttl:V=this.ttl,start:J,noDisposeOnSet:z=this.noDisposeOnSet,sizeCalculation:Y=this.sizeCalculation,status:K}=X,{noUpdateTTL:q=this.noUpdateTTL}=X,W=this.#h(Z,$,X.size||0,Y);if(this.maxEntrySize&&W>this.maxEntrySize)return K&&(K.set="miss",K.maxEntrySizeExceeded=!0),this.#I(Z,"set"),this;let H=this.#Y===0?void 0:this.#W.get(Z);if(H===void 0)H=this.#Y===0?this.#U:this.#P.length!==0?this.#P.pop():this.#Y===this.#Q?this.#m(!1):this.#Y,this.#K[H]=Z,this.#J[H]=$,this.#W.set(Z,H),this.#L[this.#U]=H,this.#v[H]=this.#U,this.#U=H,this.#Y++,this.#y(H,W,K),K&&(K.set="add"),q=!1,this.#k&&this.#Z?.($,Z,"add");else{this.#b(H);let G=this.#J[H];if($!==G){if(this.#N&&this.#q(G)){G.__abortController.abort(Error("replaced"));let{__staleWhileFetching:j}=G;j!==void 0&&!z&&(this.#F&&this.#V?.(j,Z,"set"),this.#$&&this.#w?.push([j,Z,"set"]))}else z||(this.#F&&this.#V?.(G,Z,"set"),this.#$&&this.#w?.push([G,Z,"set"]));if(this.#f(H),this.#y(H,W,K),this.#J[H]=$,K){K.set="replace";let j=G&&this.#q(G)?G.__staleWhileFetching:G;j!==void 0&&(K.oldValue=j)}}else K&&(K.set="update");this.#k&&this.onInsert?.($,Z,$===G?"update":"replace")}if(V!==0&&!this.#j&&this.#T(),this.#j&&(q||this.#u(H,V,J),K&&this.#E(K,H)),!z&&this.#$&&this.#w){let G=this.#w,j;for(;j=G?.shift();)this.#z?.(...j)}return this}pop(){try{for(;this.#Y;){let Z=this.#J[this.#_];if(this.#m(!0),this.#q(Z)){if(Z.__staleWhileFetching)return Z.__staleWhileFetching}else if(Z!==void 0)return Z}}finally{if(this.#$&&this.#w){let Z=this.#w,$;for(;$=Z?.shift();)this.#z?.(...$)}}}#m(Z){let $=this.#_,X=this.#K[$],V=this.#J[$];return this.#N&&this.#q(V)?V.__abortController.abort(Error("evicted")):(this.#F||this.#$)&&(this.#F&&this.#V?.(V,X,"evict"),this.#$&&this.#w?.push([V,X,"evict"])),this.#f($),this.#A?.[$]&&(clearTimeout(this.#A[$]),this.#A[$]=void 0),Z&&(this.#K[$]=void 0,this.#J[$]=void 0,this.#P.push($)),this.#Y===1?(this.#_=this.#U=0,this.#P.length=0):this.#_=this.#L[$],this.#W.delete(X),this.#Y--,$}has(Z,$={}){let{updateAgeOnHas:X=this.updateAgeOnHas,status:V}=$,J=this.#W.get(Z);if(J!==void 0){let z=this.#J[J];if(this.#q(z)&&z.__staleWhileFetching===void 0)return!1;if(this.#R(J))V&&(V.has="stale",this.#E(V,J));else return X&&this.#D(J),V&&(V.has="hit",this.#E(V,J)),!0}else V&&(V.has="miss");return!1}peek(Z,$={}){let{allowStale:X=this.allowStale}=$,V=this.#W.get(Z);if(V===void 0||!X&&this.#R(V))return;let J=this.#J[V];return this.#q(J)?J.__staleWhileFetching:J}#d(Z,$,X,V){let J=$===void 0?void 0:this.#J[$];if(this.#q(J))return J;let z=new H0,{signal:Y}=X;Y?.addEventListener("abort",()=>z.abort(Y.reason),{signal:z.signal});let K={signal:z.signal,options:X,context:V},q=(U,A=!1)=>{let{aborted:w}=z.signal,B=X.ignoreFetchAbort&&U!==void 0,v=X.ignoreFetchAbort||!!(X.allowStaleOnFetchAbort&&U!==void 0);if(X.status&&(w&&!A?(X.status.fetchAborted=!0,X.status.fetchError=z.signal.reason,B&&(X.status.fetchAbortIgnored=!0)):X.status.fetchResolved=!0),w&&!B&&!A)return H(z.signal.reason,v);let O=j,F=this.#J[$];return(F===j||B&&A&&F===void 0)&&(U===void 0?O.__staleWhileFetching!==void 0?this.#J[$]=O.__staleWhileFetching:this.#I(Z,"fetch"):(X.status&&(X.status.fetchUpdated=!0),this.set(Z,U,K.options))),U},W=(U)=>(X.status&&(X.status.fetchRejected=!0,X.status.fetchError=U),H(U,!1)),H=(U,A)=>{let{aborted:w}=z.signal,B=w&&X.allowStaleOnFetchAbort,v=B||X.allowStaleOnFetchRejection,O=v||X.noDeleteOnFetchRejection,F=j;if(this.#J[$]===j&&(!O||!A&&F.__staleWhileFetching===void 0?this.#I(Z,"fetch"):B||(this.#J[$]=F.__staleWhileFetching)),v)return X.status&&F.__staleWhileFetching!==void 0&&(X.status.returnedStale=!0),F.__staleWhileFetching;if(F.__returned===F)throw U},G=(U,A)=>{let w=this.#C?.(Z,J,K);w&&w instanceof Promise&&w.then((B)=>U(B===void 0?void 0:B),A),z.signal.addEventListener("abort",()=>{(!X.ignoreFetchAbort||X.allowStaleOnFetchAbort)&&(U(void 0),X.allowStaleOnFetchAbort&&(U=(B)=>q(B,!0)))})};X.status&&(X.status.fetchDispatched=!0);let j=new Promise(G).then(q,W),_=Object.assign(j,{__abortController:z,__staleWhileFetching:J,__returned:void 0});return $===void 0?(this.set(Z,_,{...K.options,status:void 0}),$=this.#W.get(Z)):this.#J[$]=_,_}#q(Z){if(!this.#N)return!1;let $=Z;return!!$&&$ instanceof Promise&&$.hasOwnProperty("__staleWhileFetching")&&$.__abortController instanceof H0}async fetch(Z,$={}){let{allowStale:X=this.allowStale,updateAgeOnGet:V=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:G=this.allowStaleOnFetchRejection,ignoreFetchAbort:j=this.ignoreFetchAbort,allowStaleOnFetchAbort:_=this.allowStaleOnFetchAbort,context:U,forceRefresh:A=!1,status:w,signal:B}=$;if(!this.#N)return w&&(w.fetch="get"),this.get(Z,{allowStale:X,updateAgeOnGet:V,noDeleteOnStaleGet:J,status:w});let v={allowStale:X,updateAgeOnGet:V,noDeleteOnStaleGet:J,ttl:z,noDisposeOnSet:Y,size:K,sizeCalculation:q,noUpdateTTL:W,noDeleteOnFetchRejection:H,allowStaleOnFetchRejection:G,allowStaleOnFetchAbort:_,ignoreFetchAbort:j,status:w,signal:B},O=this.#W.get(Z);if(O===void 0){w&&(w.fetch="miss");let F=this.#d(Z,O,v,U);return F.__returned=F}else{let F=this.#J[O];if(this.#q(F)){let P=X&&F.__staleWhileFetching!==void 0;return w&&(w.fetch="inflight",P&&(w.returnedStale=!0)),P?F.__staleWhileFetching:F.__returned=F}let E=this.#R(O);if(!A&&!E)return w&&(w.fetch="hit"),this.#b(O),V&&this.#D(O),w&&this.#E(w,O),F;let y=this.#d(Z,O,v,U),t=y.__staleWhileFetching!==void 0&&X;return w&&(w.fetch=E?"stale":"refresh",t&&E&&(w.returnedStale=!0)),t?y.__staleWhileFetching:y.__returned=y}}async forceFetch(Z,$={}){let X=await this.fetch(Z,$);if(X===void 0)throw Error("fetch() returned undefined");return X}memo(Z,$={}){let X=this.#B;if(!X)throw Error("no memoMethod provided to constructor");let{context:V,forceRefresh:J,...z}=$,Y=this.get(Z,z);if(!J&&Y!==void 0)return Y;let K=X(Z,Y,{options:z,context:V});return this.set(Z,K,z),K}get(Z,$={}){let{allowStale:X=this.allowStale,updateAgeOnGet:V=this.updateAgeOnGet,noDeleteOnStaleGet:J=this.noDeleteOnStaleGet,status:z}=$,Y=this.#W.get(Z);if(Y!==void 0){let K=this.#J[Y],q=this.#q(K);return z&&this.#E(z,Y),this.#R(Y)?(z&&(z.get="stale"),q?(z&&X&&K.__staleWhileFetching!==void 0&&(z.returnedStale=!0),X?K.__staleWhileFetching:void 0):(J||this.#I(Z,"expire"),z&&X&&(z.returnedStale=!0),X?K:void 0)):(z&&(z.get="hit"),q?K.__staleWhileFetching:(this.#b(Y),V&&this.#D(Y),K))}else z&&(z.get="miss")}#c(Z,$){this.#v[$]=Z,this.#L[Z]=$}#b(Z){Z!==this.#U&&(Z===this.#_?this.#_=this.#L[Z]:this.#c(this.#v[Z],this.#L[Z]),this.#c(this.#U,Z),this.#U=Z)}delete(Z){return this.#I(Z,"delete")}#I(Z,$){let X=!1;if(this.#Y!==0){let V=this.#W.get(Z);if(V!==void 0)if(this.#A?.[V]&&(clearTimeout(this.#A?.[V]),this.#A[V]=void 0),X=!0,this.#Y===1)this.#p($);else{this.#f(V);let J=this.#J[V];if(this.#q(J)?J.__abortController.abort(Error("deleted")):(this.#F||this.#$)&&(this.#F&&this.#V?.(J,Z,$),this.#$&&this.#w?.push([J,Z,$])),this.#W.delete(Z),this.#K[V]=void 0,this.#J[V]=void 0,V===this.#U)this.#U=this.#v[V];else if(V===this.#_)this.#_=this.#L[V];else{let z=this.#v[V];this.#L[z]=this.#L[V];let Y=this.#L[V];this.#v[Y]=this.#v[V]}this.#Y--,this.#P.push(V)}}if(this.#$&&this.#w?.length){let V=this.#w,J;for(;J=V?.shift();)this.#z?.(...J)}return X}clear(){return this.#p("delete")}#p(Z){for(let $ of this.#x({allowStale:!0})){let X=this.#J[$];if(this.#q(X))X.__abortController.abort(Error("deleted"));else{let V=this.#K[$];this.#F&&this.#V?.(X,V,Z),this.#$&&this.#w?.push([X,V,Z])}}if(this.#W.clear(),this.#J.fill(void 0),this.#K.fill(void 0),this.#j&&this.#M){this.#j.fill(0),this.#M.fill(0);for(let $ of this.#A??[])$!==void 0&&clearTimeout($);this.#A?.fill(void 0)}if(this.#O&&this.#O.fill(0),this.#_=0,this.#U=0,this.#P.length=0,this.#G=0,this.#Y=0,this.#$&&this.#w){let $=this.#w,X;for(;X=$?.shift();)this.#z?.(...X)}}};import{posix as bZ,win32 as XQ}from"path";import{fileURLToPath as fZ}from"url";import{lstatSync as uZ,readdir as hZ,readdirSync as gZ,readlinkSync as mZ,realpathSync as dZ}from"fs";import*as cZ from"fs";import{lstat as pZ,readdir as iZ,readlink as nZ,realpath as oZ}from"fs/promises";import{EventEmitter as e0}from"events";import V8 from"stream";import{StringDecoder as PZ}from"string_decoder";var Q8=typeof process==="object"&&process?process:{stdout:null,stderr:null},NZ=(Q)=>!!Q&&typeof Q==="object"&&(Q instanceof M9||Q instanceof V8||DZ(Q)||IZ(Q)),DZ=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof e0&&typeof Q.pipe==="function"&&Q.pipe!==V8.Writable.prototype.pipe,IZ=(Q)=>!!Q&&typeof Q==="object"&&Q instanceof e0&&typeof Q.write==="function"&&typeof Q.end==="function",U9=Symbol("EOF"),w9=Symbol("maybeEmitEnd"),L9=Symbol("emittedEnd"),G0=Symbol("emittingEnd"),i9=Symbol("emittedError"),j0=Symbol("closed"),Z8=Symbol("read"),_0=Symbol("flush"),$8=Symbol("flushChunk"),a=Symbol("encoding"),x9=Symbol("decoder"),I=Symbol("flowing"),n9=Symbol("paused"),T9=Symbol("resume"),S=Symbol("buffer"),f=Symbol("pipes"),x=Symbol("bufferLength"),o0=Symbol("bufferPush"),U0=Symbol("bufferShift"),k=Symbol("objectMode"),D=Symbol("destroyed"),r0=Symbol("error"),a0=Symbol("emitData"),X8=Symbol("emitEnd"),s0=Symbol("emitEnd2"),J9=Symbol("async"),t0=Symbol("abort"),w0=Symbol("aborted"),o9=Symbol("signal"),C9=Symbol("dataListeners"),m=Symbol("discarded"),r9=(Q)=>Promise.resolve().then(Q),SZ=(Q)=>Q(),xZ=(Q)=>Q==="end"||Q==="finish"||Q==="prefinish",TZ=(Q)=>Q instanceof ArrayBuffer||!!Q&&typeof Q==="object"&&Q.constructor&&Q.constructor.name==="ArrayBuffer"&&Q.byteLength>=0,EZ=(Q)=>!Buffer.isBuffer(Q)&&ArrayBuffer.isView(Q);class QQ{src;dest;opts;ondrain;constructor(Q,Z,$){this.src=Q,this.dest=Z,this.opts=$,this.ondrain=()=>Q[T9](),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 J8 extends QQ{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(Q,Z,$){super(Q,Z,$);this.proxyErrors=(X)=>this.dest.emit("error",X),Q.on("error",this.proxyErrors)}}var kZ=(Q)=>!!Q.objectMode,yZ=(Q)=>!Q.objectMode&&!!Q.encoding&&Q.encoding!=="buffer";class M9 extends e0{[I]=!1;[n9]=!1;[f]=[];[S]=[];[k];[a];[J9];[x9];[U9]=!1;[L9]=!1;[G0]=!1;[j0]=!1;[i9]=null;[x]=0;[D]=!1;[o9];[w0]=!1;[C9]=0;[m]=!1;writable=!0;readable=!0;constructor(...Q){let Z=Q[0]||{};super();if(Z.objectMode&&typeof Z.encoding==="string")throw TypeError("Encoding and objectMode may not be used together");if(kZ(Z))this[k]=!0,this[a]=null;else if(yZ(Z))this[a]=Z.encoding,this[k]=!1;else this[k]=!1,this[a]=null;if(this[J9]=!!Z.async,this[x9]=this[a]?new PZ(this[a]):null,Z&&Z.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[S]});if(Z&&Z.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[f]});let{signal:$}=Z;if($)if(this[o9]=$,$.aborted)this[t0]();else $.addEventListener("abort",()=>this[t0]())}get bufferLength(){return this[x]}get encoding(){return this[a]}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[k]}set objectMode(Q){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[J9]}set["async"](Q){this[J9]=this[J9]||!!Q}[t0](){this[w0]=!0,this.emit("abort",this[o9]?.reason),this.destroy(this[o9]?.reason)}get aborted(){return this[w0]}set aborted(Q){}write(Q,Z,$){if(this[w0])return!1;if(this[U9])throw Error("write after end");if(this[D])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof Z==="function")$=Z,Z="utf8";if(!Z)Z="utf8";let X=this[J9]?r9:SZ;if(!this[k]&&!Buffer.isBuffer(Q)){if(EZ(Q))Q=Buffer.from(Q.buffer,Q.byteOffset,Q.byteLength);else if(TZ(Q))Q=Buffer.from(Q);else if(typeof Q!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[k]){if(this[I]&&this[x]!==0)this[_0](!0);if(this[I])this.emit("data",Q);else this[o0](Q);if(this[x]!==0)this.emit("readable");if($)X($);return this[I]}if(!Q.length){if(this[x]!==0)this.emit("readable");if($)X($);return this[I]}if(typeof Q==="string"&&!(Z===this[a]&&!this[x9]?.lastNeed))Q=Buffer.from(Q,Z);if(Buffer.isBuffer(Q)&&this[a])Q=this[x9].write(Q);if(this[I]&&this[x]!==0)this[_0](!0);if(this[I])this.emit("data",Q);else this[o0](Q);if(this[x]!==0)this.emit("readable");if($)X($);return this[I]}read(Q){if(this[D])return null;if(this[m]=!1,this[x]===0||Q===0||Q&&Q>this[x])return this[w9](),null;if(this[k])Q=null;if(this[S].length>1&&!this[k])this[S]=[this[a]?this[S].join(""):Buffer.concat(this[S],this[x])];let Z=this[Z8](Q||null,this[S][0]);return this[w9](),Z}[Z8](Q,Z){if(this[k])this[U0]();else{let $=Z;if(Q===$.length||Q===null)this[U0]();else if(typeof $==="string")this[S][0]=$.slice(Q),Z=$.slice(0,Q),this[x]-=Q;else this[S][0]=$.subarray(Q),Z=$.subarray(0,Q),this[x]-=Q}if(this.emit("data",Z),!this[S].length&&!this[U9])this.emit("drain");return Z}end(Q,Z,$){if(typeof Q==="function")$=Q,Q=void 0;if(typeof Z==="function")$=Z,Z="utf8";if(Q!==void 0)this.write(Q,Z);if($)this.once("end",$);if(this[U9]=!0,this.writable=!1,this[I]||!this[n9])this[w9]();return this}[T9](){if(this[D])return;if(!this[C9]&&!this[f].length)this[m]=!0;if(this[n9]=!1,this[I]=!0,this.emit("resume"),this[S].length)this[_0]();else if(this[U9])this[w9]();else this.emit("drain")}resume(){return this[T9]()}pause(){this[I]=!1,this[n9]=!0,this[m]=!1}get destroyed(){return this[D]}get flowing(){return this[I]}get paused(){return this[n9]}[o0](Q){if(this[k])this[x]+=1;else this[x]+=Q.length;this[S].push(Q)}[U0](){if(this[k])this[x]-=1;else this[x]-=this[S][0].length;return this[S].shift()}[_0](Q=!1){do;while(this[$8](this[U0]())&&this[S].length);if(!Q&&!this[S].length&&!this[U9])this.emit("drain")}[$8](Q){return this.emit("data",Q),this[I]}pipe(Q,Z){if(this[D])return Q;this[m]=!1;let $=this[L9];if(Z=Z||{},Q===Q8.stdout||Q===Q8.stderr)Z.end=!1;else Z.end=Z.end!==!1;if(Z.proxyErrors=!!Z.proxyErrors,$){if(Z.end)Q.end()}else if(this[f].push(!Z.proxyErrors?new QQ(this,Q,Z):new J8(this,Q,Z)),this[J9])r9(()=>this[T9]());else this[T9]();return Q}unpipe(Q){let Z=this[f].find(($)=>$.dest===Q);if(Z){if(this[f].length===1){if(this[I]&&this[C9]===0)this[I]=!1;this[f]=[]}else this[f].splice(this[f].indexOf(Z),1);Z.unpipe()}}addListener(Q,Z){return this.on(Q,Z)}on(Q,Z){let $=super.on(Q,Z);if(Q==="data"){if(this[m]=!1,this[C9]++,!this[f].length&&!this[I])this[T9]()}else if(Q==="readable"&&this[x]!==0)super.emit("readable");else if(xZ(Q)&&this[L9])super.emit(Q),this.removeAllListeners(Q);else if(Q==="error"&&this[i9]){let X=Z;if(this[J9])r9(()=>X.call(this,this[i9]));else X.call(this,this[i9])}return $}removeListener(Q,Z){return this.off(Q,Z)}off(Q,Z){let $=super.off(Q,Z);if(Q==="data"){if(this[C9]=this.listeners("data").length,this[C9]===0&&!this[m]&&!this[f].length)this[I]=!1}return $}removeAllListeners(Q){let Z=super.removeAllListeners(Q);if(Q==="data"||Q===void 0){if(this[C9]=0,!this[m]&&!this[f].length)this[I]=!1}return Z}get emittedEnd(){return this[L9]}[w9](){if(!this[G0]&&!this[L9]&&!this[D]&&this[S].length===0&&this[U9]){if(this[G0]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[j0])this.emit("close");this[G0]=!1}}emit(Q,...Z){let $=Z[0];if(Q!=="error"&&Q!=="close"&&Q!==D&&this[D])return!1;else if(Q==="data")return!this[k]&&!$?!1:this[J9]?(r9(()=>this[a0]($)),!0):this[a0]($);else if(Q==="end")return this[X8]();else if(Q==="close"){if(this[j0]=!0,!this[L9]&&!this[D])return!1;let V=super.emit("close");return this.removeAllListeners("close"),V}else if(Q==="error"){this[i9]=$,super.emit(r0,$);let V=!this[o9]||this.listeners("error").length?super.emit("error",$):!1;return this[w9](),V}else if(Q==="resume"){let V=super.emit("resume");return this[w9](),V}else if(Q==="finish"||Q==="prefinish"){let V=super.emit(Q);return this.removeAllListeners(Q),V}let X=super.emit(Q,...Z);return this[w9](),X}[a0](Q){for(let $ of this[f])if($.dest.write(Q)===!1)this.pause();let Z=this[m]?!1:super.emit("data",Q);return this[w9](),Z}[X8](){if(this[L9])return!1;return this[L9]=!0,this.readable=!1,this[J9]?(r9(()=>this[s0]()),!0):this[s0]()}[s0](){if(this[x9]){let Z=this[x9].end();if(Z){for(let $ of this[f])$.dest.write(Z);if(!this[m])super.emit("data",Z)}}for(let Z of this[f])Z.end();let Q=super.emit("end");return this.removeAllListeners("end"),Q}async collect(){let Q=Object.assign([],{dataLength:0});if(!this[k])Q.dataLength=0;let Z=this.promise();return this.on("data",($)=>{if(Q.push($),!this[k])Q.dataLength+=$.length}),await Z,Q}async concat(){if(this[k])throw Error("cannot concat in objectMode");let Q=await this.collect();return this[a]?Q.join(""):Buffer.concat(Q,Q.dataLength)}async promise(){return new Promise((Q,Z)=>{this.on(D,()=>Z(Error("stream destroyed"))),this.on("error",($)=>Z($)),this.on("end",()=>Q())})}[Symbol.asyncIterator](){this[m]=!1;let Q=!1,Z=async()=>{return this.pause(),Q=!0,{value:void 0,done:!0}};return{next:()=>{if(Q)return Z();let X=this.read();if(X!==null)return Promise.resolve({done:!1,value:X});if(this[U9])return Z();let V,J,z=(W)=>{this.off("data",Y),this.off("end",K),this.off(D,q),Z(),J(W)},Y=(W)=>{this.off("error",z),this.off("end",K),this.off(D,q),this.pause(),V({value:W,done:!!this[U9]})},K=()=>{this.off("error",z),this.off("data",Y),this.off(D,q),Z(),V({done:!0,value:void 0})},q=()=>z(Error("stream destroyed"));return new Promise((W,H)=>{J=H,V=W,this.once(D,q),this.once("error",z),this.once("end",K),this.once("data",Y)})},throw:Z,return:Z,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[m]=!1;let Q=!1,Z=()=>{return this.pause(),this.off(r0,Z),this.off(D,Z),this.off("end",Z),Q=!0,{done:!0,value:void 0}},$=()=>{if(Q)return Z();let X=this.read();return X===null?Z():{done:!1,value:X}};return this.once("end",Z),this.once(r0,Z),this.once(D,Z),{next:$,throw:Z,return:Z,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(Q){if(this[D]){if(Q)this.emit("error",Q);else this.emit(D);return this}this[D]=!0,this[m]=!0,this[S].length=0,this[x]=0;let Z=this;if(typeof Z.close==="function"&&!this[j0])Z.close();if(Q)this.emit("error",Q);else this.emit(D);return this}static get isStream(){return NZ}}var lZ=dZ.native,s9={lstatSync:uZ,readdir:hZ,readdirSync:gZ,readlinkSync:mZ,realpathSync:lZ,promises:{lstat:pZ,readdir:iZ,readlink:nZ,realpath:oZ}},W8=(Q)=>!Q||Q===s9||Q===cZ?s9:{...s9,...Q,promises:{...s9.promises,...Q.promises||{}}},H8=/^\\\\\?\\([a-z]:)\\?$/i,rZ=(Q)=>Q.replace(/\//g,"\\").replace(H8,"$1\\"),aZ=/[\\\/]/,i=0,G8=1,j8=2,z9=4,_8=6,U8=8,R9=10,w8=12,p=15,a9=~p,ZQ=16,z8=32,t9=64,s=128,A0=256,L0=512,Y8=t9|s|L0,sZ=1023,$Q=(Q)=>Q.isFile()?U8:Q.isDirectory()?z9:Q.isSymbolicLink()?R9:Q.isCharacterDevice()?j8:Q.isBlockDevice()?_8:Q.isSocket()?w8:Q.isFIFO()?G8:i,K8=new p9({max:4096}),e9=(Q)=>{let Z=K8.get(Q);if(Z)return Z;let $=Q.normalize("NFKD");return K8.set(Q,$),$},q8=new p9({max:4096}),B0=(Q)=>{let Z=q8.get(Q);if(Z)return Z;let $=e9(Q.toLowerCase());return q8.set(Q,$),$};class VQ extends p9{constructor(){super({max:256})}}class A8 extends p9{constructor(Q=16384){super({maxSize:Q,sizeCalculation:(Z)=>Z.length+1})}}var B8=Symbol("PathScurry setAsCwd");class u{name;root;roots;parent;nocase;isCWD=!1;#Q;#X;get dev(){return this.#X}#V;get mode(){return this.#V}#Z;get nlink(){return this.#Z}#z;get uid(){return this.#z}#C;get gid(){return this.#C}#B;get rdev(){return this.#B}#H;get blksize(){return this.#H}#Y;get ino(){return this.#Y}#G;get size(){return this.#G}#W;get blocks(){return this.#W}#K;get atimeMs(){return this.#K}#J;get mtimeMs(){return this.#J}#L;get ctimeMs(){return this.#L}#v;get birthtimeMs(){return this.#v}#_;get atime(){return this.#_}#U;get mtime(){return this.#U}#P;get ctime(){return this.#P}#w;get birthtime(){return this.#w}#O;#M;#j;#A;#F;#N;#$;#k;#T;#D;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Q,Z=i,$,X,V,J,z){if(this.name=Q,this.#O=V?B0(Q):e9(Q),this.#$=Z&sZ,this.nocase=V,this.roots=X,this.root=$||this,this.#k=J,this.#j=z.fullpath,this.#F=z.relative,this.#N=z.relativePosix,this.parent=z.parent,this.parent)this.#Q=this.parent.#Q;else this.#Q=W8(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.#k}resolve(Q){if(!Q)return this;let Z=this.getRootString(Q),X=Q.substring(Z.length).split(this.splitSep);return Z?this.getRoot(Z).#E(X):this.#E(X)}#E(Q){let Z=this;for(let $ of Q)Z=Z.child($);return Z}children(){let Q=this.#k.get(this);if(Q)return Q;let Z=Object.assign([],{provisional:0});return this.#k.set(this,Z),this.#$&=~ZQ,Z}child(Q,Z){if(Q===""||Q===".")return this;if(Q==="..")return this.parent||this;let $=this.children(),X=this.nocase?B0(Q):e9(Q);for(let Y of $)if(Y.#O===X)return Y;let V=this.parent?this.sep:"",J=this.#j?this.#j+V+Q:void 0,z=this.newChild(Q,i,{...Z,parent:this,fullpath:J});if(!this.canReaddir())z.#$|=s;return $.push(z),z}relative(){if(this.isCWD)return"";if(this.#F!==void 0)return this.#F;let Q=this.name,Z=this.parent;if(!Z)return this.#F=this.name;let $=Z.relative();return $+(!$||!Z.parent?"":this.sep)+Q}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#N!==void 0)return this.#N;let Q=this.name,Z=this.parent;if(!Z)return this.#N=this.fullpathPosix();let $=Z.relativePosix();return $+(!$||!Z.parent?"":"/")+Q}fullpath(){if(this.#j!==void 0)return this.#j;let Q=this.name,Z=this.parent;if(!Z)return this.#j=this.name;let X=Z.fullpath()+(!Z.parent?"":this.sep)+Q;return this.#j=X}fullpathPosix(){if(this.#A!==void 0)return this.#A;if(this.sep==="/")return this.#A=this.fullpath();if(!this.parent){let X=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(X))return this.#A=`//?/${X}`;else return this.#A=X}let Q=this.parent,Z=Q.fullpathPosix(),$=Z+(!Z||!Q.parent?"":"/")+this.name;return this.#A=$}isUnknown(){return(this.#$&p)===i}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.#$&p)===U8}isDirectory(){return(this.#$&p)===z9}isCharacterDevice(){return(this.#$&p)===j8}isBlockDevice(){return(this.#$&p)===_8}isFIFO(){return(this.#$&p)===G8}isSocket(){return(this.#$&p)===w8}isSymbolicLink(){return(this.#$&R9)===R9}lstatCached(){return this.#$&z8?this:void 0}readlinkCached(){return this.#T}realpathCached(){return this.#D}readdirCached(){let Q=this.children();return Q.slice(0,Q.provisional)}canReadlink(){if(this.#T)return!0;if(!this.parent)return!1;let Q=this.#$&p;return!(Q!==i&&Q!==R9||this.#$&A0||this.#$&s)}calledReaddir(){return!!(this.#$&ZQ)}isENOENT(){return!!(this.#$&s)}isNamed(Q){return!this.nocase?this.#O===e9(Q):this.#O===B0(Q)}async readlink(){let Q=this.#T;if(Q)return Q;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=await this.#Q.promises.readlink(this.fullpath()),$=(await this.parent.realpath())?.resolve(Z);if($)return this.#T=$}catch(Z){this.#x(Z.code);return}}readlinkSync(){let Q=this.#T;if(Q)return Q;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=this.#Q.readlinkSync(this.fullpath()),$=this.parent.realpathSync()?.resolve(Z);if($)return this.#T=$}catch(Z){this.#x(Z.code);return}}#u(Q){this.#$|=ZQ;for(let Z=Q.provisional;Z<Q.length;Z++){let $=Q[Z];if($)$.#R()}}#R(){if(this.#$&s)return;this.#$=(this.#$|s)&a9,this.#l()}#l(){let Q=this.children();Q.provisional=0;for(let Z of Q)Z.#R()}#f(){this.#$|=L0,this.#y()}#y(){if(this.#$&t9)return;let Q=this.#$;if((Q&p)===z9)Q&=a9;this.#$=Q|t9,this.#l()}#h(Q=""){if(Q==="ENOTDIR"||Q==="EPERM")this.#y();else if(Q==="ENOENT")this.#R();else this.children().provisional=0}#S(Q=""){if(Q==="ENOTDIR")this.parent.#y();else if(Q==="ENOENT")this.#R()}#x(Q=""){let Z=this.#$;if(Z|=A0,Q==="ENOENT")Z|=s;if(Q==="EINVAL"||Q==="UNKNOWN")Z&=a9;if(this.#$=Z,Q==="ENOTDIR"&&this.parent)this.parent.#y()}#g(Q,Z){return this.#d(Q,Z)||this.#m(Q,Z)}#m(Q,Z){let $=$Q(Q),X=this.newChild(Q.name,$,{parent:this}),V=X.#$&p;if(V!==z9&&V!==R9&&V!==i)X.#$|=t9;return Z.unshift(X),Z.provisional++,X}#d(Q,Z){for(let $=Z.provisional;$<Z.length;$++){let X=Z[$];if((this.nocase?B0(Q.name):e9(Q.name))!==X.#O)continue;return this.#q(Q,X,$,Z)}}#q(Q,Z,$,X){let V=Z.name;if(Z.#$=Z.#$&a9|$Q(Q),V!==Q.name)Z.name=Q.name;if($!==X.provisional){if($===X.length-1)X.pop();else X.splice($,1);X.unshift(Z)}return X.provisional++,Z}async lstat(){if((this.#$&s)===0)try{return this.#c(await this.#Q.promises.lstat(this.fullpath())),this}catch(Q){this.#S(Q.code)}}lstatSync(){if((this.#$&s)===0)try{return this.#c(this.#Q.lstatSync(this.fullpath())),this}catch(Q){this.#S(Q.code)}}#c(Q){let{atime:Z,atimeMs:$,birthtime:X,birthtimeMs:V,blksize:J,blocks:z,ctime:Y,ctimeMs:K,dev:q,gid:W,ino:H,mode:G,mtime:j,mtimeMs:_,nlink:U,rdev:A,size:w,uid:B}=Q;this.#_=Z,this.#K=$,this.#w=X,this.#v=V,this.#H=J,this.#W=z,this.#P=Y,this.#L=K,this.#X=q,this.#C=W,this.#Y=H,this.#V=G,this.#U=j,this.#J=_,this.#Z=U,this.#B=A,this.#G=w,this.#z=B;let v=$Q(Q);if(this.#$=this.#$&a9|v|z8,v!==i&&v!==z9&&v!==R9)this.#$|=t9}#b=[];#I=!1;#p(Q){this.#I=!1;let Z=this.#b.slice();this.#b.length=0,Z.forEach(($)=>$(null,Q))}readdirCB(Q,Z=!1){if(!this.canReaddir()){if(Z)Q(null,[]);else queueMicrotask(()=>Q(null,[]));return}let $=this.children();if(this.calledReaddir()){let V=$.slice(0,$.provisional);if(Z)Q(null,V);else queueMicrotask(()=>Q(null,V));return}if(this.#b.push(Q),this.#I)return;this.#I=!0;let X=this.fullpath();this.#Q.readdir(X,{withFileTypes:!0},(V,J)=>{if(V)this.#h(V.code),$.provisional=0;else{for(let z of J)this.#g(z,$);this.#u($)}this.#p($.slice(0,$.provisional));return})}#i;async readdir(){if(!this.canReaddir())return[];let Q=this.children();if(this.calledReaddir())return Q.slice(0,Q.provisional);let Z=this.fullpath();if(this.#i)await this.#i;else{let $=()=>{};this.#i=new Promise((X)=>$=X);try{for(let X of await this.#Q.promises.readdir(Z,{withFileTypes:!0}))this.#g(X,Q);this.#u(Q)}catch(X){this.#h(X.code),Q.provisional=0}this.#i=void 0,$()}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 Z=this.fullpath();try{for(let $ of this.#Q.readdirSync(Z,{withFileTypes:!0}))this.#g($,Q);this.#u(Q)}catch($){this.#h($.code),Q.provisional=0}return Q.slice(0,Q.provisional)}canReaddir(){if(this.#$&Y8)return!1;let Q=p&this.#$;if(!(Q===i||Q===z9||Q===R9))return!1;return!0}shouldWalk(Q,Z){return(this.#$&z9)===z9&&!(this.#$&Y8)&&!Q.has(this)&&(!Z||Z(this))}async realpath(){if(this.#D)return this.#D;if((L0|A0|s)&this.#$)return;try{let Q=await this.#Q.promises.realpath(this.fullpath());return this.#D=this.resolve(Q)}catch(Q){this.#f()}}realpathSync(){if(this.#D)return this.#D;if((L0|A0|s)&this.#$)return;try{let Q=this.#Q.realpathSync(this.fullpath());return this.#D=this.resolve(Q)}catch(Q){this.#f()}}[B8](Q){if(Q===this)return;Q.isCWD=!1,this.isCWD=!0;let Z=new Set([]),$=[],X=this;while(X&&X.parent)Z.add(X),X.#F=$.join(this.sep),X.#N=$.join("/"),X=X.parent,$.push("..");X=Q;while(X&&X.parent&&!Z.has(X))X.#F=void 0,X.#N=void 0,X=X.parent}}class F0 extends u{sep="\\";splitSep=aZ;constructor(Q,Z=i,$,X,V,J,z){super(Q,Z,$,X,V,J,z)}newChild(Q,Z=i,$={}){return new F0(Q,Z,this.root,this.roots,this.nocase,this.childrenCache(),$)}getRootString(Q){return XQ.parse(Q).root}getRoot(Q){if(Q=rZ(Q.toUpperCase()),Q===this.root.name)return this.root;for(let[Z,$]of Object.entries(this.roots))if(this.sameRoot(Q,Z))return this.roots[Q]=$;return this.roots[Q]=new Q0(Q,this).root}sameRoot(Q,Z=this.root.name){return Q=Q.toUpperCase().replace(/\//g,"\\").replace(H8,"$1\\"),Q===Z}}class v0 extends u{splitSep="/";sep="/";constructor(Q,Z=i,$,X,V,J,z){super(Q,Z,$,X,V,J,z)}getRootString(Q){return Q.startsWith("/")?"/":""}getRoot(Q){return this.root}newChild(Q,Z=i,$={}){return new v0(Q,Z,this.root,this.roots,this.nocase,this.childrenCache(),$)}}class JQ{root;rootPath;roots;cwd;#Q;#X;#V;nocase;#Z;constructor(Q=process.cwd(),Z,$,{nocase:X,childrenCacheSize:V=16384,fs:J=s9}={}){if(this.#Z=W8(J),Q instanceof URL||Q.startsWith("file://"))Q=fZ(Q);let z=Z.resolve(Q);this.roots=Object.create(null),this.rootPath=this.parseRootPath(z),this.#Q=new VQ,this.#X=new VQ,this.#V=new A8(V);let Y=z.substring(this.rootPath.length).split($);if(Y.length===1&&!Y[0])Y.pop();if(X===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=X,this.root=this.newRoot(this.#Z),this.roots[this.rootPath]=this.root;let K=this.root,q=Y.length-1,W=Z.sep,H=this.rootPath,G=!1;for(let j of Y){let _=q--;K=K.child(j,{relative:Array(_).fill("..").join(W),relativePosix:Array(_).fill("..").join("/"),fullpath:H+=(G?"":W)+j}),G=!0}this.cwd=K}depth(Q=this.cwd){if(typeof Q==="string")Q=this.cwd.resolve(Q);return Q.depth()}childrenCache(){return this.#V}resolve(...Q){let Z="";for(let V=Q.length-1;V>=0;V--){let J=Q[V];if(!J||J===".")continue;if(Z=Z?`${J}/${Z}`:J,this.isAbsolute(J))break}let $=this.#Q.get(Z);if($!==void 0)return $;let X=this.cwd.resolve(Z).fullpath();return this.#Q.set(Z,X),X}resolvePosix(...Q){let Z="";for(let V=Q.length-1;V>=0;V--){let J=Q[V];if(!J||J===".")continue;if(Z=Z?`${J}/${Z}`:J,this.isAbsolute(J))break}let $=this.#X.get(Z);if($!==void 0)return $;let X=this.cwd.resolve(Z).fullpathPosix();return this.#X.set(Z,X),X}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,Z={withFileTypes:!0}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof u))Z=Q,Q=this.cwd;let{withFileTypes:$}=Z;if(!Q.canReaddir())return[];else{let X=await Q.readdir();return $?X:X.map((V)=>V.name)}}readdirSync(Q=this.cwd,Z={withFileTypes:!0}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof u))Z=Q,Q=this.cwd;let{withFileTypes:$=!0}=Z;if(!Q.canReaddir())return[];else if($)return Q.readdirSync();else return Q.readdirSync().map((X)=>X.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:Z}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof u))Z=Q.withFileTypes,Q=this.cwd;let $=await Q.readlink();return Z?$:$?.fullpath()}readlinkSync(Q=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof u))Z=Q.withFileTypes,Q=this.cwd;let $=Q.readlinkSync();return Z?$:$?.fullpath()}async realpath(Q=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof u))Z=Q.withFileTypes,Q=this.cwd;let $=await Q.realpath();return Z?$:$?.fullpath()}realpathSync(Q=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof u))Z=Q.withFileTypes,Q=this.cwd;let $=Q.realpathSync();return Z?$:$?.fullpath()}async walk(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof u))Z=Q,Q=this.cwd;let{withFileTypes:$=!0,follow:X=!1,filter:V,walkFilter:J}=Z,z=[];if(!V||V(Q))z.push($?Q:Q.fullpath());let Y=new Set,K=(W,H)=>{Y.add(W),W.readdirCB((G,j)=>{if(G)return H(G);let _=j.length;if(!_)return H();let U=()=>{if(--_===0)H()};for(let A of j){if(!V||V(A))z.push($?A:A.fullpath());if(X&&A.isSymbolicLink())A.realpath().then((w)=>w?.isUnknown()?w.lstat():w).then((w)=>w?.shouldWalk(Y,J)?K(w,U):U());else if(A.shouldWalk(Y,J))K(A,U);else U()}},!0)},q=Q;return new Promise((W,H)=>{K(q,(G)=>{if(G)return H(G);W(z)})})}walkSync(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof u))Z=Q,Q=this.cwd;let{withFileTypes:$=!0,follow:X=!1,filter:V,walkFilter:J}=Z,z=[];if(!V||V(Q))z.push($?Q:Q.fullpath());let Y=new Set([Q]);for(let K of Y){let q=K.readdirSync();for(let W of q){if(!V||V(W))z.push($?W:W.fullpath());let H=W;if(W.isSymbolicLink()){if(!(X&&(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,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof u))Z=Q,Q=this.cwd;return this.stream(Q,Z)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof u))Z=Q,Q=this.cwd;let{withFileTypes:$=!0,follow:X=!1,filter:V,walkFilter:J}=Z;if(!V||V(Q))yield $?Q:Q.fullpath();let z=new Set([Q]);for(let Y of z){let K=Y.readdirSync();for(let q of K){if(!V||V(q))yield $?q:q.fullpath();let W=q;if(q.isSymbolicLink()){if(!(X&&(W=q.realpathSync())))continue;if(W.isUnknown())W.lstatSync()}if(W.shouldWalk(z,J))z.add(W)}}}stream(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof u))Z=Q,Q=this.cwd;let{withFileTypes:$=!0,follow:X=!1,filter:V,walkFilter:J}=Z,z=new M9({objectMode:!0});if(!V||V(Q))z.write($?Q:Q.fullpath());let Y=new Set,K=[Q],q=0,W=()=>{let H=!1;while(!H){let G=K.shift();if(!G){if(q===0)z.end();return}q++,Y.add(G);let j=(U,A,w=!1)=>{if(U)return z.emit("error",U);if(X&&!w){let B=[];for(let v of A)if(v.isSymbolicLink())B.push(v.realpath().then((O)=>O?.isUnknown()?O.lstat():O));if(B.length){Promise.all(B).then(()=>j(null,A,!0));return}}for(let B of A)if(B&&(!V||V(B))){if(!z.write($?B:B.fullpath()))H=!0}q--;for(let B of A){let v=B.realpathCached()||B;if(v.shouldWalk(Y,J))K.push(v)}if(H&&!z.flowing)z.once("drain",W);else if(!_)W()},_=!0;G.readdirCB(j,!0),_=!1}};return W(),z}streamSync(Q=this.cwd,Z={}){if(typeof Q==="string")Q=this.cwd.resolve(Q);else if(!(Q instanceof u))Z=Q,Q=this.cwd;let{withFileTypes:$=!0,follow:X=!1,filter:V,walkFilter:J}=Z,z=new M9({objectMode:!0}),Y=new Set;if(!V||V(Q))z.write($?Q:Q.fullpath());let K=[Q],q=0,W=()=>{let H=!1;while(!H){let G=K.shift();if(!G){if(q===0)z.end();return}q++,Y.add(G);let j=G.readdirSync();for(let _ of j)if(!V||V(_)){if(!z.write($?_:_.fullpath()))H=!0}q--;for(let _ of j){let U=_;if(_.isSymbolicLink()){if(!(X&&(U=_.realpathSync())))continue;if(U.isUnknown())U.lstatSync()}if(U.shouldWalk(Y,J))K.push(U)}}if(H&&!z.flowing)z.once("drain",W)};return W(),z}chdir(Q=this.cwd){let Z=this.cwd;this.cwd=typeof Q==="string"?this.cwd.resolve(Q):Q,this.cwd[B8](Z)}}class Q0 extends JQ{sep="\\";constructor(Q=process.cwd(),Z={}){let{nocase:$=!0}=Z;super(Q,XQ,"\\",{...Z,nocase:$});this.nocase=$;for(let X=this.cwd;X;X=X.parent)X.nocase=this.nocase}parseRootPath(Q){return XQ.parse(Q).root.toUpperCase()}newRoot(Q){return new F0(this.rootPath,z9,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Q})}isAbsolute(Q){return Q.startsWith("/")||Q.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Q)}}class Z0 extends JQ{sep="/";constructor(Q=process.cwd(),Z={}){let{nocase:$=!1}=Z;super(Q,bZ,"/",{...Z,nocase:$});this.nocase=$}parseRootPath(Q){return"/"}newRoot(Q){return new v0(this.rootPath,z9,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Q})}isAbsolute(Q){return Q.startsWith("/")}}class O0 extends Z0{constructor(Q=process.cwd(),Z={}){let{nocase:$=!0}=Z;super(Q,{...Z,nocase:$})}}var q$=process.platform==="win32"?F0:v0,L8=process.platform==="win32"?Q0:process.platform==="darwin"?O0:Z0;var tZ=(Q)=>Q.length>=1,eZ=(Q)=>Q.length>=1;class E9{#Q;#X;#V;length;#Z;#z;#C;#B;#H;#Y;#G=!0;constructor(Q,Z,$,X){if(!tZ(Q))throw TypeError("empty pattern list");if(!eZ(Z))throw TypeError("empty glob list");if(Z.length!==Q.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=Q.length,$<0||$>=this.length)throw TypeError("index out of range");if(this.#Q=Q,this.#X=Z,this.#V=$,this.#Z=X,this.#V===0){if(this.isUNC()){let[V,J,z,Y,...K]=this.#Q,[q,W,H,G,...j]=this.#X;if(K[0]==="")K.shift(),j.shift();let _=[V,J,z,Y,""].join("/"),U=[q,W,H,G,""].join("/");this.#Q=[_,...K],this.#X=[U,...j],this.length=this.#Q.length}else if(this.isDrive()||this.isAbsolute()){let[V,...J]=this.#Q,[z,...Y]=this.#X;if(J[0]==="")J.shift(),Y.shift();let K=V+"/",q=z+"/";this.#Q=[K,...J],this.#X=[q,...Y],this.length=this.#Q.length}}}pattern(){return this.#Q[this.#V]}isString(){return typeof this.#Q[this.#V]==="string"}isGlobstar(){return this.#Q[this.#V]===N}isRegExp(){return this.#Q[this.#V]instanceof RegExp}globString(){return this.#C=this.#C||(this.#V===0?this.isAbsolute()?this.#X[0]+this.#X.slice(1).join("/"):this.#X.join("/"):this.#X.slice(this.#V).join("/"))}hasMore(){return this.length>this.#V+1}rest(){if(this.#z!==void 0)return this.#z;if(!this.hasMore())return this.#z=null;return this.#z=new E9(this.#Q,this.#X,this.#V+1,this.#Z),this.#z.#Y=this.#Y,this.#z.#H=this.#H,this.#z.#B=this.#B,this.#z}isUNC(){let Q=this.#Q;return this.#H!==void 0?this.#H:this.#H=this.#Z==="win32"&&this.#V===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.#Z==="win32"&&this.#V===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.#V===0?Q:""}checkFollowGlobstar(){return!(this.#V===0||!this.isGlobstar()||!this.#G)}markFollowGlobstar(){if(this.#V===0||!this.isGlobstar()||!this.#G)return!1;return this.#G=!1,!0}}var Q5=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class $0{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Q,{nobrace:Z,nocase:$,noext:X,noglobstar:V,platform:J=Q5}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=J,this.mmopts={dot:!0,nobrace:Z,nocase:$,noext:X,noglobstar:V,optimizationLevel:2,platform:J,nocomment:!0,nonegate:!0};for(let z of Q)this.add(z)}add(Q){let Z=new l(Q,this.mmopts);for(let $=0;$<Z.set.length;$++){let X=Z.set[$],V=Z.globParts[$];if(!X||!V)throw Error("invalid pattern object");while(X[0]==="."&&V[0]===".")X.shift(),V.shift();let J=new E9(X,V,0,this.platform),z=new l(J.globString(),this.mmopts),Y=V[V.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 Z=Q.fullpath(),$=`${Z}/`,X=Q.relative()||".",V=`${X}/`;for(let J of this.relative)if(J.match(X)||J.match(V))return!0;for(let J of this.absolute)if(J.match(Z)||J.match($))return!0;return!1}childrenIgnored(Q){let Z=Q.fullpath()+"/",$=(Q.relative()||".")+"/";for(let X of this.relativeChildren)if(X.match($))return!0;for(let X of this.absoluteChildren)if(X.match(Z))return!0;return!1}}class zQ{store;constructor(Q=new Map){this.store=Q}copy(){return new zQ(new Map(this.store))}hasWalked(Q,Z){return this.store.get(Q.fullpath())?.has(Z.globString())}storeWalked(Q,Z){let $=Q.fullpath(),X=this.store.get($);if(X)X.add(Z.globString());else this.store.set($,new Set([Z.globString()]))}}class F8{store=new Map;add(Q,Z,$){let X=(Z?2:0)|($?1:0),V=this.store.get(Q);this.store.set(Q,V===void 0?X:X&V)}entries(){return[...this.store.entries()].map(([Q,Z])=>[Q,!!(Z&2),!!(Z&1)])}}class v8{store=new Map;add(Q,Z){if(!Q.canReaddir())return;let $=this.store.get(Q);if($){if(!$.find((X)=>X.globString()===Z.globString()))$.push(Z)}else this.store.set(Q,[Z])}get(Q){let Z=this.store.get(Q);if(!Z)throw Error("attempting to walk unknown path");return Z}entries(){return this.keys().map((Q)=>[Q,this.store.get(Q)])}keys(){return[...this.store.keys()].filter((Q)=>Q.canReaddir())}}class X0{hasWalkedCache;matches=new F8;subwalks=new v8;patterns;follow;dot;opts;constructor(Q,Z){this.opts=Q,this.follow=!!Q.follow,this.dot=!!Q.dot,this.hasWalkedCache=Z?Z.copy():new zQ}processPatterns(Q,Z){this.patterns=Z;let $=Z.map((X)=>[Q,X]);for(let[X,V]of $){this.hasWalkedCache.storeWalked(X,V);let J=V.root(),z=V.isAbsolute()&&this.opts.absolute!==!1;if(J){X=X.resolve(J==="/"&&this.opts.root!==void 0?this.opts.root:J);let W=V.rest();if(!W){this.matches.add(X,!0,!1);continue}else V=W}if(X.isENOENT())continue;let Y,K,q=!1;while(typeof(Y=V.pattern())==="string"&&(K=V.rest()))X=X.resolve(Y),V=K,q=!0;if(Y=V.pattern(),K=V.rest(),q){if(this.hasWalkedCache.hasWalked(X,V))continue;this.hasWalkedCache.storeWalked(X,V)}if(typeof Y==="string"){let W=Y===".."||Y===""||Y===".";this.matches.add(X.resolve(Y),z,W);continue}else if(Y===N){if(!X.isSymbolicLink()||this.follow||V.checkFollowGlobstar())this.subwalks.add(X,V);let W=K?.pattern(),H=K?.rest();if(!K||(W===""||W===".")&&!H)this.matches.add(X,z,W===""||W===".");else if(W===".."){let G=X.parent||X;if(!H)this.matches.add(G,z,!0);else if(!this.hasWalkedCache.hasWalked(G,H))this.subwalks.add(G,H)}}else if(Y instanceof RegExp)this.subwalks.add(X,V)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new X0(this.opts,this.hasWalkedCache)}filterEntries(Q,Z){let $=this.subwalks.get(Q),X=this.child();for(let V of Z)for(let J of $){let z=J.isAbsolute(),Y=J.pattern(),K=J.rest();if(Y===N)X.testGlobstar(V,J,K,z);else if(Y instanceof RegExp)X.testRegExp(V,Y,K,z);else X.testString(V,Y,K,z)}return X}testGlobstar(Q,Z,$,X){if(this.dot||!Q.name.startsWith(".")){if(!Z.hasMore())this.matches.add(Q,X,!1);if(Q.canReaddir()){if(this.follow||!Q.isSymbolicLink())this.subwalks.add(Q,Z);else if(Q.isSymbolicLink()){if($&&Z.checkFollowGlobstar())this.subwalks.add(Q,$);else if(Z.markFollowGlobstar())this.subwalks.add(Q,Z)}}}if($){let V=$.pattern();if(typeof V==="string"&&V!==".."&&V!==""&&V!==".")this.testString(Q,V,$.rest(),X);else if(V===".."){let J=Q.parent||Q;this.subwalks.add(J,$)}else if(V instanceof RegExp)this.testRegExp(Q,V,$.rest(),X)}}testRegExp(Q,Z,$,X){if(!Z.test(Q.name))return;if(!$)this.matches.add(Q,X,!1);else this.subwalks.add(Q,$)}testString(Q,Z,$,X){if(!Q.isNamed(Z))return;if(!$)this.matches.add(Q,X,!1);else this.subwalks.add(Q,$)}}var Z5=(Q,Z)=>typeof Q==="string"?new $0([Q],Z):Array.isArray(Q)?new $0(Q,Z):Q;class YQ{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Q=[];#X;#V;signal;maxDepth;includeChildMatches;constructor(Q,Z,$){if(this.patterns=Q,this.path=Z,this.opts=$,this.#V=!$.posix&&$.platform==="win32"?"\\":"/",this.includeChildMatches=$.includeChildMatches!==!1,$.ignore||!this.includeChildMatches){if(this.#X=Z5($.ignore??[],$),!this.includeChildMatches&&typeof this.#X.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=$.maxDepth||1/0,$.signal)this.signal=$.signal,this.signal.addEventListener("abort",()=>{this.#Q.length=0})}#Z(Q){return this.seen.has(Q)||!!this.#X?.ignored?.(Q)}#z(Q){return!!this.#X?.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,Z){if(Z&&this.opts.nodir)return;let $;if(this.opts.realpath){if($=Q.realpathCached()||await Q.realpath(),!$)return;Q=$}let V=Q.isUnknown()||this.opts.stat?await Q.lstat():Q;if(this.opts.follow&&this.opts.nodir&&V?.isSymbolicLink()){let J=await V.realpath();if(J&&(J.isUnknown()||this.opts.stat))await J.lstat()}return this.matchCheckTest(V,Z)}matchCheckTest(Q,Z){return Q&&(this.maxDepth===1/0||Q.depth()<=this.maxDepth)&&(!Z||Q.canReaddir())&&(!this.opts.nodir||!Q.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!Q.isSymbolicLink()||!Q.realpathCached()?.isDirectory())&&!this.#Z(Q)?Q:void 0}matchCheckSync(Q,Z){if(Z&&this.opts.nodir)return;let $;if(this.opts.realpath){if($=Q.realpathCached()||Q.realpathSync(),!$)return;Q=$}let V=Q.isUnknown()||this.opts.stat?Q.lstatSync():Q;if(this.opts.follow&&this.opts.nodir&&V?.isSymbolicLink()){let J=V.realpathSync();if(J&&(J?.isUnknown()||this.opts.stat))J.lstatSync()}return this.matchCheckTest(V,Z)}matchFinish(Q,Z){if(this.#Z(Q))return;if(!this.includeChildMatches&&this.#X?.add){let V=`${Q.relativePosix()}/**`;this.#X.add(V)}let $=this.opts.absolute===void 0?Z:this.opts.absolute;this.seen.add(Q);let X=this.opts.mark&&Q.isDirectory()?this.#V:"";if(this.opts.withFileTypes)this.matchEmit(Q);else if($){let V=this.opts.posix?Q.fullpathPosix():Q.fullpath();this.matchEmit(V+X)}else{let V=this.opts.posix?Q.relativePosix():Q.relative(),J=this.opts.dotRelative&&!V.startsWith(".."+this.#V)?"."+this.#V:"";this.matchEmit(!V?"."+X:J+V+X)}}async match(Q,Z,$){let X=await this.matchCheck(Q,$);if(X)this.matchFinish(X,Z)}matchSync(Q,Z,$){let X=this.matchCheckSync(Q,$);if(X)this.matchFinish(X,Z)}walkCB(Q,Z,$){if(this.signal?.aborted)$();this.walkCB2(Q,Z,new X0(this.opts),$)}walkCB2(Q,Z,$,X){if(this.#z(Q))return X();if(this.signal?.aborted)X();if(this.paused){this.onResume(()=>this.walkCB2(Q,Z,$,X));return}$.processPatterns(Q,Z);let V=1,J=()=>{if(--V===0)X()};for(let[z,Y,K]of $.matches.entries()){if(this.#Z(z))continue;V++,this.match(z,Y,K).then(()=>J())}for(let z of $.subwalkTargets()){if(this.maxDepth!==1/0&&z.depth()>=this.maxDepth)continue;V++;let Y=z.readdirCached();if(z.calledReaddir())this.walkCB3(z,Y,$,J);else z.readdirCB((K,q)=>this.walkCB3(z,q,$,J),!0)}J()}walkCB3(Q,Z,$,X){$=$.filterEntries(Q,Z);let V=1,J=()=>{if(--V===0)X()};for(let[z,Y,K]of $.matches.entries()){if(this.#Z(z))continue;V++,this.match(z,Y,K).then(()=>J())}for(let[z,Y]of $.subwalks.entries())V++,this.walkCB2(z,Y,$.child(),J);J()}walkCBSync(Q,Z,$){if(this.signal?.aborted)$();this.walkCB2Sync(Q,Z,new X0(this.opts),$)}walkCB2Sync(Q,Z,$,X){if(this.#z(Q))return X();if(this.signal?.aborted)X();if(this.paused){this.onResume(()=>this.walkCB2Sync(Q,Z,$,X));return}$.processPatterns(Q,Z);let V=1,J=()=>{if(--V===0)X()};for(let[z,Y,K]of $.matches.entries()){if(this.#Z(z))continue;this.matchSync(z,Y,K)}for(let z of $.subwalkTargets()){if(this.maxDepth!==1/0&&z.depth()>=this.maxDepth)continue;V++;let Y=z.readdirSync();this.walkCB3Sync(z,Y,$,J)}J()}walkCB3Sync(Q,Z,$,X){$=$.filterEntries(Q,Z);let V=1,J=()=>{if(--V===0)X()};for(let[z,Y,K]of $.matches.entries()){if(this.#Z(z))continue;this.matchSync(z,Y,K)}for(let[z,Y]of $.subwalks.entries())V++,this.walkCB2Sync(z,Y,$.child(),J);J()}}class C0 extends YQ{matches=new Set;constructor(Q,Z,$){super(Q,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,Z)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)Z(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 M0 extends YQ{results;constructor(Q,Z,$){super(Q,Z,$);this.results=new M9({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 X5=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class Y9{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,Z){if(!Z)throw TypeError("glob options required");if(this.withFileTypes=!!Z.withFileTypes,this.signal=Z.signal,this.follow=!!Z.follow,this.dot=!!Z.dot,this.dotRelative=!!Z.dotRelative,this.nodir=!!Z.nodir,this.mark=!!Z.mark,!Z.cwd)this.cwd="";else if(Z.cwd instanceof URL||Z.cwd.startsWith("file://"))Z.cwd=$5(Z.cwd);if(this.cwd=Z.cwd||"",this.root=Z.root,this.magicalBraces=!!Z.magicalBraces,this.nobrace=!!Z.nobrace,this.noext=!!Z.noext,this.realpath=!!Z.realpath,this.absolute=Z.absolute,this.includeChildMatches=Z.includeChildMatches!==!1,this.noglobstar=!!Z.noglobstar,this.matchBase=!!Z.matchBase,this.maxDepth=typeof Z.maxDepth==="number"?Z.maxDepth:1/0,this.stat=!!Z.stat,this.ignore=Z.ignore,this.withFileTypes&&this.absolute!==void 0)throw Error("cannot set absolute and withFileTypes:true");if(typeof Q==="string")Q=[Q];if(this.windowsPathsNoEscape=!!Z.windowsPathsNoEscape||Z.allowWindowsEscape===!1,this.windowsPathsNoEscape)Q=Q.map((Y)=>Y.replace(/\\/g,"/"));if(this.matchBase){if(Z.noglobstar)throw TypeError("base matching requires globstar");Q=Q.map((Y)=>Y.includes("/")?Y:`./**/${Y}`)}if(this.pattern=Q,this.platform=Z.platform||X5,this.opts={...Z,platform:this.platform},Z.scurry){if(this.scurry=Z.scurry,Z.nocase!==void 0&&Z.nocase!==Z.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let Y=Z.platform==="win32"?Q0:Z.platform==="darwin"?O0:Z.platform?Z0:L8;this.scurry=new Y(this.cwd,{nocase:Z.nocase,fs:Z.fs})}this.nocase=this.scurry.nocase;let $=this.platform==="darwin"||this.platform==="win32",X={...Z,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:$,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},V=this.pattern.map((Y)=>new l(Y,X)),[J,z]=V.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 E9(Y,q,0,this.platform)})}async walk(){return[...await new C0(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 C0(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 M0(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 M0(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 KQ=(Q,Z={})=>{if(!Array.isArray(Q))Q=[Q];for(let $ of Q)if(new l($,Z).hasMagic())return!0;return!1};function P0(Q,Z={}){return new Y9(Q,Z).streamSync()}function C8(Q,Z={}){return new Y9(Q,Z).stream()}function M8(Q,Z={}){return new Y9(Q,Z).walkSync()}async function O8(Q,Z={}){return new Y9(Q,Z).walk()}function N0(Q,Z={}){return new Y9(Q,Z).iterateSync()}function R8(Q,Z={}){return new Y9(Q,Z).iterate()}var V5=P0,J5=Object.assign(C8,{sync:P0}),z5=N0,Y5=Object.assign(R8,{sync:N0}),K5=Object.assign(M8,{stream:P0,iterate:N0}),R0=Object.assign(O8,{glob:O8,globSync:M8,sync:K5,globStream:C8,stream:J5,globStreamSync:P0,streamSync:V5,globIterate:R8,iterate:Y5,globIterateSync:N0,iterateSync:z5,Glob:Y9,hasMagic:KQ,escape:S9,unescape:r});R0.glob=R0;var q5={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,Z)=>{let $=Q.file_path,X=Q.offset||1,V=Q.limit||2000;try{let Y=(await Bun.file($).text()).split(`
|
|
45
|
+
`),K=Math.max(0,X-1),q=Math.min(Y.length,K+V);return{content:Y.slice(K,q).map((G,j)=>`${K+j+1} ${G}`).join(`
|
|
46
|
+
`)}}catch(J){return{content:`Error reading file: ${J instanceof Error?J.message:String(J)}`,is_error:!0}}}},W5={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,Z)=>{let{file_path:$,content:X}=Q;try{return await Bun.write($,X),{content:`Successfully wrote to ${$}`}}catch(V){return{content:`Error writing file: ${V instanceof Error?V.message:String(V)}`,is_error:!0}}}},H5={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,Z)=>{let{file_path:$,old_string:X,new_string:V}=Q,J=Q.replace_all||!1;try{let Y=await Bun.file($).text();if(J){let K=Y;Y=Y.split(X).join(V);let q=(K.match(new RegExp(G5(X),"g"))||[]).length;if(q===0)return{content:"Error: String not found in file",is_error:!0};return await Bun.write($,Y),{content:`Successfully replaced ${q} occurrences`}}else{let K=Y.indexOf(X);if(K===-1)return{content:"Error: String not found in file",is_error:!0};if(Y.indexOf(X,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(X,V),await Bun.write($,Y),{content:`Successfully edited ${$}`}}}catch(z){return{content:`Error editing file: ${z instanceof Error?z.message:String(z)}`,is_error:!0}}}};function G5(Q){return Q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var j5={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,Z)=>{let $=Q.command,X=Q.timeout||120000;try{let V=Bun.spawnSync(["sh","-c",$],{cwd:Z.workingDirectory,timeout:X,maxBuffer:31457280}),J=V.stdout?.toString()||"",z=V.stderr?.toString()||"";if(V.exitCode!==0)return{content:`Exit code: ${V.exitCode}
|
|
47
|
+
${J}
|
|
48
|
+
${z}`.trim(),is_error:!0};return{content:J||"(no output)"}}catch(V){return{content:`Error executing command: ${V instanceof Error?V.message:String(V)}`,is_error:!0}}}},_5={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,Z)=>{let $=Q.pattern,X=Q.path||Z.workingDirectory;try{let V=await R0($,{cwd:X,absolute:!0,nodir:!0});if(V.length===0)return{content:"No files found matching pattern"};return{content:V.sort().join(`
|
|
49
|
+
`)}}catch(V){return{content:`Error searching files: ${V instanceof Error?V.message:String(V)}`,is_error:!0}}}},U5={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,Z)=>{let $=Q.pattern,X=Q.path||Z.workingDirectory,V=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(V)q.push("--glob",V);if(J==="files_with_matches")q.push("--files-with-matches");if(J==="count")q.push("--count");q.push($,X);let H=Bun.spawnSync(["rg",...q],{cwd:Z.workingDirectory,maxBuffer:10485760}).stdout?.toString()||"";if(!H.trim())return{content:"No matches found"};if(J==="content"){let G=H.trim().split(`
|
|
50
|
+
`),j=[];for(let _ of G.slice(0,K||100))try{let U=JSON.parse(_);if(U.type==="match"){let A=U.data?.path?.text||"",w=U.data?.line_number||0,B=U.data?.lines?.text||"";j.push(`${A}:${w}:${B.trim()}`)}}catch{j.push(_)}return{content:j.join(`
|
|
51
|
+
`)||"No matches found"}}return{content:H.trim()}}catch(q){return{content:`Error searching: ${q instanceof Error?q.message:String(q)}`,is_error:!0}}}},w5={name:"Task",description:`Launch a new agent to handle complex, multi-step tasks autonomously.
|
|
52
|
+
|
|
53
|
+
The Task tool launches specialized agents (subprocesses) that autonomously handle complex tasks. Each agent type has specific capabilities and tools available to it.
|
|
54
|
+
|
|
55
|
+
Available agent types and their tools:
|
|
56
|
+
- Bash: Command execution specialist for running bash commands. Use for git operations, command execution, and other terminal tasks.
|
|
57
|
+
- general-purpose: General-purpose agent for researching complex questions, searching for code, and executing multi-step tasks.
|
|
58
|
+
- Explore: Fast agent specialized for exploring codebases. Use to quickly find files by patterns, search code for keywords, or answer questions about the codebase.
|
|
59
|
+
- Plan: Software architect agent for designing implementation plans. Returns step-by-step plans, identifies critical files and considers architectural trade-offs.
|
|
60
|
+
|
|
61
|
+
When using the Task tool, you must specify a subagent_type parameter to select the agent type.
|
|
62
|
+
|
|
63
|
+
Usage notes:
|
|
64
|
+
- Always include a short description (3-5 words) summarizing what the agent will do
|
|
65
|
+
- Launch multiple agents concurrently whenever possible to maximize performance
|
|
66
|
+
- Agents can be resumed using the "resume" parameter by passing the agent ID from a previous invocation.`,input_schema:{type:"object",properties:{subagent_type:{type:"string",enum:["Bash","general-purpose","Explore","Plan"],description:"The agent type to launch"},description:{type:"string",description:"A short (3-5 word) description of what the agent will do"},prompt:{type:"string",description:"The task for the agent to perform"},resume:{type:"string",description:"Resume a previous agent by its ID"},model:{type:"string",enum:["sonnet","opus","haiku"],description:"Model for the subagent (default: haiku for quick tasks)"},run_in_background:{type:"boolean",description:"Run the agent in the background"}},required:["subagent_type","prompt"]},handler:async(Q,Z)=>{let{subagent_type:$,prompt:X,description:V}=Q,J=Q.model||"haiku",z=Q.resume,Y=Q.run_in_background,K=z||`${$.toLowerCase()}-${Date.now().toString(36)}`;try{let q=process.env.ANTHROPIC_API_KEY||process.env.CLAUDE_API_KEY||process.env.ANTHROPIC_AUTH_TOKEN||process.env.Z_AI_API_KEY||"";if(!q)return{content:"Error: No API key available for subagent. Set ANTHROPIC_API_KEY, CLAUDE_API_KEY, ANTHROPIC_AUTH_TOKEN, or Z_AI_API_KEY environment variable.",is_error:!0};let W={haiku:"claude-haiku-4-5",sonnet:"claude-sonnet-4-6",opus:"claude-opus-4-6"},H=W[J]||W.haiku,G=[import.meta.dir+"/../../dist/cli.js",import.meta.dir+"/../cli.ts",process.cwd()+"/dist/cli.js",process.cwd()+"/src/cli.ts"],j=null;for(let B of G)try{if(await Bun.file(B).exists()){j=B;break}}catch{}if(!j)return{content:`Error: Could not find CLI. Tried:
|
|
67
|
+
${G.join(`
|
|
68
|
+
`)}`,is_error:!0};let _=["run",j,"-m",H,"-p",Z.permissionMode,"-q",X];if(Y)return Bun.spawn(["bun",..._],{cwd:Z.workingDirectory,detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,ANTHROPIC_API_KEY:q}}).unref(),{content:JSON.stringify({agentId:K,status:"running",message:`Agent started in background. Use TaskOutput tool with task_id: "${K}" to check results.`,description:V||"Background task"})};let U=Bun.spawnSync(["bun",..._],{cwd:Z.workingDirectory,timeout:300000,maxBuffer:10485760,env:{...process.env,ANTHROPIC_API_KEY:q}}),A=U.stdout?.toString()||"",w=U.stderr?.toString()||"";if(U.exitCode!==0)return{content:`Agent failed with exit code ${U.exitCode}
|
|
69
|
+
${w}
|
|
70
|
+
${A}`.trim(),is_error:!0};return{content:JSON.stringify({agentId:K,status:"completed",output:A,description:V||"Task completed"})}}catch(q){return{content:`Error running subagent: ${q instanceof Error?q.message:String(q)}`,is_error:!0}}}},A5={name:"TaskOutput",description:`Retrieves output from a running or completed task (background shell, agent, or remote session).
|
|
71
|
+
|
|
72
|
+
Takes a task_id parameter identifying the task.
|
|
73
|
+
Returns the task output along with status information.
|
|
74
|
+
Use block=true (default) to wait for task completion.
|
|
75
|
+
Use block=false for non-blocking check of current status.
|
|
76
|
+
|
|
77
|
+
Task IDs can be found using the /tasks command
|
|
78
|
+
Works with all task types: background shells, async agents, and remote sessions`,input_schema:{type:"object",properties:{task_id:{type:"string",description:"The task ID to get output from"},block:{type:"boolean",description:"Whether to wait for completion (default: true)",default:!0},timeout:{type:"number",description:"Max wait time in ms (default: 30000, max: 600000)",default:30000,minimum:0,maximum:600000}},required:["task_id"]},handler:async(Q,Z)=>{let $=Q.task_id,X=Q.block??!0,V=Q.timeout??30000;try{let J=`${Z.workingDirectory}/.claude/tasks/${$}.json`,z=Bun.file(J);if(!await z.exists())return{content:`Task not found: ${$}. Use /tasks to list available tasks.`,is_error:!0};let Y=await z.json();if(X&&Y.status==="running"){let K=Date.now();while(Date.now()-K<V){await new Promise((W)=>setTimeout(W,1000));let q=Bun.file(J);if(await q.exists()){let W=await q.json();if(W.status!=="running")return{content:JSON.stringify({task_id:$,status:W.status,output:W.output,error:W.error,duration:W.endTime?W.endTime-W.startTime:null},null,2)}}}return{content:JSON.stringify({task_id:$,status:"timeout",message:`Task still running after ${V}ms`},null,2)}}return{content:JSON.stringify({task_id:$,status:Y.status,output:Y.output,error:Y.error,duration:Y.endTime?Y.endTime-Y.startTime:null},null,2)}}catch(J){return{content:`Error getting task output: ${J instanceof Error?J.message:String(J)}`,is_error:!0}}}},B5={name:"AskUserQuestion",description:`Use this tool when you need to ask the user questions during execution.
|
|
79
|
+
|
|
80
|
+
This allows you to:
|
|
81
|
+
1. Gather user preferences or requirements
|
|
82
|
+
2. Clarify ambiguous instructions
|
|
83
|
+
3. Get decisions on implementation choices
|
|
84
|
+
4. Offer choices to the user about what direction to take
|
|
85
|
+
|
|
86
|
+
Plan mode note: In plan mode, use this tool to clarify requirements or choose between approaches BEFORE finalizing your plan. Do NOT use this tool if your plan is ready - that's what ExitPlanMode is for.
|
|
87
|
+
|
|
88
|
+
The options array should have 2-4 options. Each option should be a distinct, mutually exclusive choice.
|
|
89
|
+
The preview feature allows showing markdown content in a side-by-side layout.
|
|
90
|
+
|
|
91
|
+
User can always select "Other" to provide custom text input.`,input_schema:{type:"object",properties:{questions:{type:"array",description:"Questions to ask the user (1-4 questions)",items:{type:"object",properties:{question:{type:"string",description:"The complete question to ask the user"},header:{type:"string",description:"Very short label displayed as a chip/tag (max 12 chars)"},options:{type:"array",description:"The available choices (2-4 options)",items:{type:"object",properties:{label:{type:"string",description:"The display text for this option (5 words max)"},description:{type:"string",description:"Explanation of what this option means"},markdown:{type:"string",description:"Optional preview content shown in a monospace box"}},required:["label","description"]},minItems:2,maxItems:4},multiSelect:{type:"boolean",description:"Allow selecting multiple options (default: false)",default:!1}},required:["question","header","options"]},minItems:1,maxItems:4}},required:["questions"]},handler:async(Q,Z)=>{let $=Q.questions;try{let X=$.map((V,J)=>{let z=V.options.map((Y,K)=>{let q=` ${K+1}. ${Y.label}`;if(Y.description)q+=` - ${Y.description}`;return q}).join(`
|
|
92
|
+
`);return`## Question ${J+1}: [${V.header}]
|
|
93
|
+
${V.question}
|
|
94
|
+
|
|
95
|
+
Options:
|
|
96
|
+
${z}${V.multiSelect?`
|
|
97
|
+
(multi-select enabled)`:""}`}).join(`
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
`);return{content:JSON.stringify({type:"user_question",questions:$,formatted:X,message:"Questions prepared for user response"},null,2)}}catch(X){return{content:`Error preparing questions: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},L5={name:"EnterPlanMode",description:`Use this tool when you are in plan mode and have finished writing your plan to the plan file and are ready for user approval.
|
|
102
|
+
|
|
103
|
+
How This Tool Works:
|
|
104
|
+
- You should have already written your plan to the plan file specified in the plan mode system message
|
|
105
|
+
- This tool does NOT take the plan content as a parameter - it will read the plan from the file you wrote
|
|
106
|
+
- This tool simply signals that you're done planning and ready for the user to review and approve
|
|
107
|
+
|
|
108
|
+
When to Use This Tool:
|
|
109
|
+
IMPORTANT: Only use this tool when the task requires planning the implementation steps of a task that requires writing code. For research tasks where you're gathering information, searching files, reading files or in general trying to understand the codebase - do NOT use this tool.
|
|
110
|
+
|
|
111
|
+
Plan mode note: In plan mode, use this tool to clarify requirements or choose between approaches BEFORE finalizing your plan. Do NOT use this tool if your plan is ready - that's what ExitPlanMode is for.
|
|
112
|
+
|
|
113
|
+
Examples:
|
|
114
|
+
- "Search for and understand the implementation of vim mode" - Do NOT use this tool
|
|
115
|
+
- "Help me implement yank mode for vim" - Use EnterPlanMode
|
|
116
|
+
|
|
117
|
+
Important notes:
|
|
118
|
+
- NEVER run additional commands to read or explore code, besides git bash commands
|
|
119
|
+
- NEVER use the TodoWrite or Task tools
|
|
120
|
+
- DO NOT commit files that likely contain secrets (.env, credentials.json, etc.)
|
|
121
|
+
- If you discover unexpected state like unfamiliar files, branches, or configuration, investigate before deleting or overwriting`,input_schema:{type:"object",properties:{allowedPrompts:{type:"array",description:"Prompt-based permissions needed to implement the plan",items:{type:"object",properties:{tool:{type:"string",description:"The tool this prompt applies to (e.g., 'Bash')"},prompt:{type:"string",description:"Semantic description of the action (e.g., 'run tests', 'install dependencies')"}},required:["tool","prompt"]}}},required:[]},handler:async(Q,Z)=>{let $=Q.allowedPrompts;try{let X=`${Z.workingDirectory}/.claude/plan.md`,V=Bun.file(X);if(!await V.exists())return{content:"Error: No plan file found. Please write your plan to .claude/plan.md first.",is_error:!0};let J=await V.text();return{content:JSON.stringify({type:"plan_ready",planFile:X,planLength:J.length,allowedPrompts:$||[],message:"Plan is ready for user review. ExitPlanMode will request user approval."},null,2)}}catch(X){return{content:`Error entering plan mode: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},F5={name:"ExitPlanMode",description:`Use this tool when you are in plan mode and have finished writing your plan to the plan file and are ready for user approval.
|
|
122
|
+
|
|
123
|
+
This tool does NOT take the plan content as a parameter - it will read the plan from the file you wrote.
|
|
124
|
+
This tool simply signals that you're done planning and ready for the user to review and approve.
|
|
125
|
+
|
|
126
|
+
IMPORTANT: Only use this tool when the task requires planning the implementation steps of a task that requires writing code.
|
|
127
|
+
ExitPlanMode inherently requests user approval of the plan.`,input_schema:{type:"object",properties:{allowedPrompts:{type:"array",description:"Prompt-based permissions needed to implement the plan",items:{type:"object",properties:{tool:{type:"string",description:"The tool this prompt applies to"},prompt:{type:"string",description:"Semantic description of the action"}},required:["tool","prompt"]}}},required:[]},handler:async(Q,Z)=>{let $=Q.allowedPrompts;try{let X=`${Z.workingDirectory}/.claude/plan.md`,V=Bun.file(X);if(!await V.exists())return{content:"Error: No plan file found at .claude/plan.md",is_error:!0};let J=await V.text();return{content:JSON.stringify({type:"exit_plan_mode",status:"awaiting_approval",planFile:X,planPreview:J.slice(0,500)+(J.length>500?"...":""),allowedPrompts:$||[],message:"Plan submitted for user approval."},null,2)}}catch(X){return{content:`Error exiting plan mode: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},v5={name:"Skill",description:`Execute a skill within the main conversation.
|
|
128
|
+
|
|
129
|
+
When users ask you to perform tasks, check if any of the available skills match. Skills provide specialized capabilities and domain knowledge.
|
|
130
|
+
|
|
131
|
+
When users reference a "slash command" or "/<something>" (e.g., "/commit", "/review-pr"), they are referring to a skill. Use this tool to invoke it.
|
|
132
|
+
|
|
133
|
+
How to invoke:
|
|
134
|
+
- Use this tool with the skill name and optional arguments
|
|
135
|
+
- Examples:
|
|
136
|
+
- skill: "commit" - invoke the commit skill
|
|
137
|
+
- skill: "review-pr", args: "123" - invoke with arguments
|
|
138
|
+
- Use fully qualified name for namespaced skills: skill: "ms-office-suite:pdf"
|
|
139
|
+
|
|
140
|
+
Available skills are listed in system-reminder messages in the conversation.
|
|
141
|
+
When a skill matches the user's request, this is a BLOCKING REQUIREMENT: invoke the relevant Skill tool BEFORE generating any other response about the task.
|
|
142
|
+
|
|
143
|
+
Important:
|
|
144
|
+
- NEVER mention a skill without actually calling this tool
|
|
145
|
+
- Do not invoke a skill that is already running
|
|
146
|
+
- Do not use this tool for built-in CLI commands (like /help, /clear)`,input_schema:{type:"object",properties:{skill:{type:"string",description:"The skill name (e.g., 'commit', 'review-pr', or fully qualified 'namespace:skill')"},args:{type:"string",description:"Optional arguments for the skill"}},required:["skill"]},handler:async(Q,Z)=>{let{skill:$,args:X}=Q;try{let V=`${Z.workingDirectory}/.claude/skills`,J=`${process.env.HOME||""}/.claude/skills`,z=[`${V}/${$}.md`,`${V}/${$}/skill.md`,`${J}/${$}.md`,`${J}/${$}/skill.md`],Y=null;for(let W of z)if(await Bun.file(W).exists()){Y=W;break}if(!Y)return{content:`Skill not found: ${$}. Available skills can be listed with /help.`,is_error:!0};let q=await Bun.file(Y).text();return{content:JSON.stringify({type:"skill_invocation",skill:$,args:X,skillFile:Y,content:q,message:`Skill "${$}" loaded. Follow the instructions in the skill content.`},null,2)}}catch(V){return{content:`Error invoking skill: ${V instanceof Error?V.message:String(V)}`,is_error:!0}}}},O5={name:"TaskStop",description:`Stops a running background task by its ID.
|
|
147
|
+
Takes a task_id parameter identifying the task to stop.
|
|
148
|
+
Returns a success or failure status.
|
|
149
|
+
Use this tool to terminate a long-running task.`,input_schema:{type:"object",properties:{task_id:{type:"string",description:"The ID of the background task to stop"},shell_id:{type:"string",description:"Deprecated: use task_id instead"}},required:["task_id"]},handler:async(Q,Z)=>{let $=Q.task_id;try{let X=`${Z.workingDirectory}/.claude/tasks/${$}.json`,V=Bun.file(X);if(!await V.exists())return{content:`Task not found: ${$}`,is_error:!0};let J=await V.json();if(J.status!=="running")return{content:JSON.stringify({task_id:$,status:J.status,message:`Task is already ${J.status}`},null,2)};return J.status="stopped",await Bun.write(X,JSON.stringify(J,null,2)),{content:JSON.stringify({task_id:$,status:"stopped",message:"Task stopped successfully"},null,2)}}catch(X){return{content:`Error stopping task: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},C5={name:"NotebookEdit",description:`Completely replaces the contents of a specific cell in a Jupyter notebook (.ipynb file) with new source.
|
|
150
|
+
|
|
151
|
+
Jupyter notebooks are interactive documents that combine code, text, and visualizations. The notebook_path parameter must be an absolute path, not a relative path. The cell_number is 0-indexed. Use edit_mode=insert to add a new cell at the index specified by cell_number. Use edit_mode=delete to delete the cell at the index specified by cell_number.`,input_schema:{type:"object",properties:{notebook_path:{type:"string",description:"The absolute path to the Jupyter notebook file to edit"},cell_id:{type:"string",description:"The ID of the cell to edit (optional, alternative to cell_number)"},cell_number:{type:"number",description:"The index of the cell to edit (0-indexed)"},new_source:{type:"string",description:"The new source for the cell"},cell_type:{type:"string",enum:["code","markdown"],description:"The type of the cell (code or markdown). Defaults to code."},edit_mode:{type:"string",enum:["replace","insert","delete"],description:"The type of edit to perform (replace, insert, delete)"}},required:["notebook_path"]},handler:async(Q,Z)=>{let{notebook_path:$,cell_id:X,cell_number:V,new_source:J}=Q,z=Q.cell_type||"code",Y=Q.edit_mode||"replace";try{let K=Bun.file($);if(!await K.exists())return{content:`Error: Notebook not found: ${$}`,is_error:!0};let q=await K.json();if(!q.cells||!Array.isArray(q.cells))return{content:"Error: Invalid notebook format - no cells array",is_error:!0};let W;if(X){if(W=q.cells.findIndex((H)=>H.id===X),W===-1)return{content:`Error: Cell with ID "${X}" not found`,is_error:!0}}else if(V!==void 0){if(W=V,W<0||W>=q.cells.length)if(Y==="insert")W=q.cells.length;else return{content:`Error: Cell number ${W} out of range (0-${q.cells.length-1})`,is_error:!0}}else if(Y!=="insert")return{content:"Error: Must specify either cell_id or cell_number",is_error:!0};else W=q.cells.length;switch(Y){case"delete":{q.cells.splice(W,1);break}case"insert":{let H={id:`cell-${Date.now()}`,cell_type:z,source:J||"",metadata:{},...z==="code"?{outputs:[],execution_count:null}:{}};q.cells.splice(W,0,H);break}case"replace":default:{if(J===void 0)return{content:"Error: new_source is required for replace mode",is_error:!0};let H=q.cells[W];if(!H)return{content:`Error: Cell at index ${W} not found`,is_error:!0};q.cells[W]={...H,source:J,cell_type:z,...z==="code"?{execution_count:null}:{}};break}}return await Bun.write($,JSON.stringify(q,null,1)),{content:JSON.stringify({success:!0,message:`Successfully ${Y}d cell in ${$}`,cellCount:q.cells.length})}}catch(K){return{content:`Error editing notebook: ${K instanceof Error?K.message:String(K)}`,is_error:!0}}}},M5=[q5,W5,H5,j5,_5,U5,w5,A5,O5,B5,L5,F5,v5,C5];function h$(Q){return M5.find((Z)=>Z.name===Q)}import{spawn as R5}from"child_process";import qQ from"ws";class WQ{static MCPClient=WQ;name;config;connected=!1;tools=[];process=null;websocket=null;requestId=0;pendingRequests=new Map;buffer="";onLog;constructor(Q){this.name=Q.name,this.config=Q.config,this.onLog=Q.onLog}async connect(){if(this.config.type==="stdio")await this.connectStdio();else if(this.config.type==="http"||this.config.type==="sse")await this.connectHttp();else if(this.config.type==="ws")await this.connectWebSocket()}async connectStdio(){if(!this.config.command)throw Error("No command specified for stdio transport");this.log(`Starting stdio transport: ${this.config.command}`),this.process=R5(this.config.command,this.config.args||[],{env:{...process.env,...this.config.env},stdio:["pipe","pipe","pipe"]}),this.process.stdout?.on("data",(Q)=>{this.handleData(Q.toString())}),this.process.stderr?.on("data",(Q)=>{this.log(`stderr: ${Q.toString()}`)}),this.process.on("error",(Q)=>{this.log(`Process error: ${Q.message}`)}),this.process.on("close",(Q)=>{this.log(`Process closed with code ${Q}`),this.connected=!1}),await new Promise((Q)=>setTimeout(Q,100)),await this.initialize()}async connectHttp(){if(!this.config.url)throw Error("No URL specified for HTTP transport");this.log(`Starting HTTP transport: ${this.config.url}`);try{let Q=await fetch(this.config.url,{method:"POST",headers:{"Content-Type":"application/json",...this.config.headers},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2024-11-05",capabilities:{},clientInfo:{name:"coder",version:"0.1.0"}}})});if(!Q.ok)throw Error(`HTTP error: ${Q.status}`);let Z=await Q.json();this.connected=!0,await this.loadTools()}catch(Q){let Z=Q instanceof Error?Q.message:String(Q);throw Error(`Failed to connect to HTTP server: ${Z}`)}}async connectWebSocket(){if(!this.config.url)throw Error("No URL specified for WebSocket transport");let Q=this.config.url;return this.log(`Starting WebSocket transport: ${Q}`),new Promise((Z,$)=>{let X={...this.config.headers},V=new qQ(Q,{headers:X,handshakeTimeout:this.config.timeout||30000});V.on("open",()=>{this.log("WebSocket connection established"),this.websocket=V,this.connected=!0,this.initialize().then(()=>Z()).catch((J)=>{let z=J instanceof Error?J.message:String(J);this.log(`Initialization failed: ${z}`),$(J)})}),V.on("message",(J,z)=>{let Y=z?J.toString():J.toString();this.handleData(Y)}),V.on("error",(J)=>{if(this.log(`WebSocket error: ${J.message}`),!this.connected)$(Error(`WebSocket connection failed: ${J.message}`))}),V.on("close",(J,z)=>{this.log(`WebSocket closed: code=${J}, reason=${z.toString()}`),this.connected=!1,this.websocket=null;for(let[Y,K]of this.pendingRequests)this.pendingRequests.delete(Y),K.reject(Error(`WebSocket closed: ${z.toString()}`))}),V.on("ping",()=>{V.pong()})})}async initialize(){let Q=await this.request("initialize",{protocolVersion:"2024-11-05",capabilities:{tools:{},resources:{},prompts:{}},clientInfo:{name:"coder",version:"0.1.0"}});this.log(`Initialized with: ${JSON.stringify(Q)}`),this.connected=!0,this.notify("notifications/initialized",{}),await this.loadTools()}async loadTools(){try{let Q=await this.request("tools/list",{});this.tools=Q.tools.map((Z)=>({name:Z.name,description:Z.description,inputSchema:Z.inputSchema})),this.log(`Loaded ${this.tools.length} tools`)}catch(Q){this.log(`Failed to load tools: ${Q}`)}}async callTool(Q,Z){return{content:(await this.request("tools/call",{name:Q,arguments:Z})).content.filter((V)=>V.type==="text").map((V)=>V.text||"").join(`
|
|
152
|
+
`)}}async request(Q,Z){let $=++this.requestId,X={jsonrpc:"2.0",id:$,method:Q,params:Z};return new Promise((V,J)=>{this.pendingRequests.set($,{resolve:V,reject:J});let z=JSON.stringify(X);if(this.websocket&&this.websocket.readyState===qQ.OPEN)this.websocket.send(z);else if(this.process?.stdin?.writable)this.process.stdin.write(z+`
|
|
153
|
+
`);else{this.pendingRequests.delete($),J(Error("No active connection to send request"));return}setTimeout(()=>{if(this.pendingRequests.has($))this.pendingRequests.delete($),J(Error(`Request timeout for ${Q}`))},this.config.timeout||120000)})}notify(Q,Z){let X=JSON.stringify({jsonrpc:"2.0",method:Q,params:Z});if(this.websocket&&this.websocket.readyState===qQ.OPEN)this.websocket.send(X);else if(this.process?.stdin?.writable)this.process.stdin.write(X+`
|
|
154
|
+
`)}handleData(Q){this.buffer+=Q;let Z=this.buffer.split(`
|
|
155
|
+
`);this.buffer=Z.pop()||"";for(let $ of Z){if(!$.trim())continue;try{let X=JSON.parse($);if(X.id!==void 0){let V=this.pendingRequests.get(X.id);if(V)if(this.pendingRequests.delete(X.id),X.error)V.reject(Error(X.error.message));else V.resolve(X.result)}}catch(X){this.log(`Parse error: ${X}`)}}}async close(){if(this.websocket)this.websocket.close(),this.websocket=null;if(this.process)this.process.kill(),this.process=null;this.connected=!1}log(Q){this.onLog?.(`[MCP:${this.name}] ${Q}`)}}async function c$(Q,Z){let $=new Map;for(let[X,V]of Object.entries(Q)){if(V.disabled)continue;let J=new WQ({name:X,config:V,onLog:Z});try{await J.connect(),$.set(X,J)}catch(z){let Y=z instanceof Error?z.message:String(z);Z?.(`[MCP:${X}] Failed to connect: ${Y}`)}}return $}import{spawn as P5}from"child_process";class N5{hooks=new Map;timeout;constructor(Q=60000){this.timeout=Q}register(Q,Z){if(!this.hooks.has(Q))this.hooks.set(Q,[]);this.hooks.get(Q)?.push(Z)}registerAll(Q){for(let[Z,$]of Object.entries(Q))for(let X of $)this.register(Z,X)}async execute(Q,Z){let $=this.hooks.get(Q);if(!$||$.length===0)return{decision:"allow"};let X={...Z,event:Q,timestamp:Date.now()};for(let V of $){if(V.enabled===!1)continue;let J=await this.executeHook(V,X);if(J.decision==="deny"||J.decision==="block")return J;if(J.modified_input)Object.assign(Z,J.modified_input)}return{decision:"allow"}}async executeHook(Q,Z){let $=Q.timeout||this.timeout;try{return await new Promise((V,J)=>{let z=P5(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);V(W)}catch{V({decision:"allow"})}else if(q===1)V({decision:"deny",reason:K||"Hook denied execution"});else if(q===2)V({decision:"block",reason:K||"Hook blocked execution"});else V({decision:"allow"})}),z.on("error",(q)=>{V({decision:"allow",reason:`Hook error: ${q.message}`})}),z.stdin?.write(JSON.stringify(Z)),z.stdin?.end(),setTimeout(()=>{z.kill(),V({decision:"allow",reason:"Hook timeout"})},$)})}catch(X){return{decision:"allow",reason:`Hook execution failed: ${X instanceof Error?X.message:String(X)}`}}}getHooks(Q){return this.hooks.get(Q)||[]}clear(Q){if(Q)this.hooks.delete(Q);else this.hooks.clear()}}var i$={validateWrite:{event:"PreToolUse",command:`node -e '
|
|
156
|
+
const input = JSON.parse(require("fs").readFileSync(0, "utf8"));
|
|
157
|
+
if (input.tool_name === "Write") {
|
|
158
|
+
const path = input.tool_input.file_path;
|
|
159
|
+
if (path.includes("..") || path.startsWith("/etc/")) {
|
|
160
|
+
console.log(JSON.stringify({ decision: "deny", reason: "Unsafe path" }));
|
|
161
|
+
process.exit(1);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
console.log(JSON.stringify({ decision: "allow" }));
|
|
165
|
+
'`,timeout:5000,enabled:!1},logToolUse:{event:"PostToolUse",command:`node -e '
|
|
166
|
+
const input = JSON.parse(require("fs").readFileSync(0, "utf8"));
|
|
167
|
+
console.error(\`[LOG] Tool: \${input.tool_name}\`);
|
|
168
|
+
console.log(JSON.stringify({ decision: "allow" }));
|
|
169
|
+
'`,timeout:5000,enabled:!1}},n$={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."},o$={ALLOW:0,DENY:1,BLOCK:2};import{readFileSync as D5,existsSync as P8,readdirSync as I5}from"fs";import{join as S5}from"path";function x5(Q,Z="project"){if(!P8(Q))return null;let $=D5(Q,"utf-8"),X=Q.split("/").pop()?.replace(/\.md$/i,"")||"unknown",V=$.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!V)return{path:Q,name:X,description:"",prompt:$.trim(),source:Z};let J=V[1]??"",z=V[2]??"",Y=T5(J);return{path:Q,name:Y.name||X,description:Y.description||"",prompt:z.trim(),tools:Y.tools,model:Y.model,color:Y.color,source:Z}}function T5(Q){let Z={},$=Q.split(`
|
|
170
|
+
`);for(let X of $){let V=X.match(/^(\w+):\s*(.*)$/);if(V){let J=V[1];if(!J)continue;let z=V[2]??"";if(z.startsWith("["))try{Z[J]=JSON.parse(z)}catch{Z[J]=z}else if(z==="true")Z[J]=!0;else if(z==="false")Z[J]=!1;else if(/^\d+$/.test(z))Z[J]=parseInt(z,10);else if(/^\d+\.\d+$/.test(z))Z[J]=parseFloat(z);else Z[J]=z}}return Z}class E5{skills=new Map;loadFromDirectory(Q,Z="project"){if(!P8(Q))return 0;let $=0,X=I5(Q);for(let V of X)if(V.endsWith(".md")){let J=x5(S5(Q,V),Z);if(J)this.skills.set(J.name,J),$++}return $}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 e$(Q){return`
|
|
171
|
+
<skill-loading>
|
|
172
|
+
You are operating with the "${Q.name}" skill loaded.
|
|
173
|
+
|
|
174
|
+
${Q.description?`Description: ${Q.description}
|
|
175
|
+
`:""}
|
|
176
|
+
${Q.prompt}
|
|
177
|
+
</skill-loading>
|
|
178
|
+
`.trim()}var Q1=[{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.
|
|
179
|
+
|
|
180
|
+
Steps:
|
|
181
|
+
1. Run \`git diff --staged\` to see staged changes
|
|
182
|
+
2. Run \`git log --oneline -5\` to understand commit message style
|
|
183
|
+
3. Create a commit message following conventional commits format
|
|
184
|
+
4. Include "Co-Authored-By: Claude <noreply@anthropic.com>" if applicable
|
|
185
|
+
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.
|
|
186
|
+
|
|
187
|
+
Steps:
|
|
188
|
+
1. Use \`gh pr view\` to get PR details
|
|
189
|
+
2. Use \`gh pr diff\` to see the changes
|
|
190
|
+
3. Analyze the code for:
|
|
191
|
+
- Bugs and potential issues
|
|
192
|
+
- Code quality and style
|
|
193
|
+
- Test coverage
|
|
194
|
+
- Documentation
|
|
195
|
+
4. Provide constructive feedback
|
|
196
|
+
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.
|
|
197
|
+
|
|
198
|
+
MCP servers enable LLMs to interact with external services through well-designed tools.
|
|
199
|
+
|
|
200
|
+
Key concepts:
|
|
201
|
+
1. Use FastMCP (Python) or MCP SDK (TypeScript)
|
|
202
|
+
2. Define tools with clear input schemas
|
|
203
|
+
3. Return structured content
|
|
204
|
+
4. Handle errors gracefully
|
|
205
|
+
|
|
206
|
+
Transport types:
|
|
207
|
+
- stdio: Local process communication
|
|
208
|
+
- HTTP: REST API with JSON-RPC
|
|
209
|
+
- SSE: Server-Sent Events for streaming
|
|
210
|
+
- 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.
|
|
211
|
+
|
|
212
|
+
Hooks are user-defined shell commands that execute at specific points during Claude Code's lifecycle.
|
|
213
|
+
|
|
214
|
+
Available events:
|
|
215
|
+
- PreToolUse: Before a tool executes
|
|
216
|
+
- PostToolUse: After a tool succeeds
|
|
217
|
+
- PostToolUseFailure: After a tool fails
|
|
218
|
+
- Stop: When agent stops
|
|
219
|
+
- UserPromptSubmit: When user submits prompt
|
|
220
|
+
- SessionStart/SessionEnd: Session lifecycle
|
|
221
|
+
|
|
222
|
+
Exit codes:
|
|
223
|
+
- 0: Allow execution
|
|
224
|
+
- 1: Deny and show stderr
|
|
225
|
+
- 2: Block silently`,tools:["Read","Write","Edit"],model:"sonnet",source:"built-in"}];function Z1(Q){return Q.match(/^\/(\w+)(?:\s+(.*))?$/)?.[1]??null}function $1(Q){return Q.match(/^\/\w+\s+(.*)$/)?.[1]??""}import{spawn as HQ}from"child_process";import{mkdirSync as N8,rmSync as k5,existsSync as D8,readFileSync as y5}from"fs";import{join as V0}from"path";class b5{teams=new Map;teammates=new Map;messageQueue=new Map;storagePath;constructor(Q="~/.claude/teams"){if(this.storagePath=Q.replace("~",process.env.HOME||""),!D8(this.storagePath))N8(this.storagePath,{recursive:!0});this.loadTeams()}createTeam(Q){let Z={...Q,status:"active"};this.teams.set(Q.name,Z);for(let $ of Q.teammates)this.teammates.set($.teammateId,$);return this.persistTeam(Z).catch(($)=>{console.error(`Failed to persist team ${Q.name}:`,$)}),Z}getTeam(Q){return this.teams.get(Q)}listTeams(){return Array.from(this.teams.values())}deleteTeam(Q){let Z=this.teams.get(Q);if(Z){for(let X of Z.teammates)this.teammates.delete(X.teammateId),this.messageQueue.delete(X.teammateId);this.teams.delete(Q);let $=V0(this.storagePath,Q);try{k5($,{recursive:!0,force:!0})}catch(X){console.error(`Failed to delete team directory ${$}:`,X)}}}getTeammate(Q){return this.teammates.get(Q)}updateTeammateStatus(Q,Z){let $=this.teammates.get(Q);if($)$.status=Z}async spawnTeammate(Q,Z={}){let{session:$,workingDir:X=process.cwd()}=Z;if(!process.env.TMUX)await this.spawnInTerminal(Q,{session:$,workingDir:X});else await this.spawnInTmux(Q,{session:$,workingDir:X});this.updateTeammateStatus(Q.teammateId,"in_progress")}async spawnInTerminal(Q,Z){let $=["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)$.push("--permission-mode","plan");if(process.platform==="darwin"){let X=`
|
|
226
|
+
tell application "Terminal"
|
|
227
|
+
do script "cd ${Z.workingDir} && ${$.join(" ")}"
|
|
228
|
+
activate
|
|
229
|
+
end tell
|
|
230
|
+
`;HQ("osascript",["-e",X])}else HQ("xterm",["-e",$.join(" ")])}async spawnInTmux(Q,Z){let $=Z.session||process.env.TMUX?.split(",")[0]?.split(":")[0]||"claude";await this.tmuxCommand(["split-window","-t",$,"-c",Z.workingDir]);let X=await this.tmuxCommand(["display-message","-p","#{pane_id}"]);if(X)Q.paneId=X.trim();let V=["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||"",V.join(" "),"Enter"])}async tmuxCommand(Q){return new Promise((Z)=>{let $=HQ("tmux",Q),X="";$.stdout?.on("data",(V)=>{X+=V.toString()}),$.on("close",()=>{Z(X)})})}broadcast(Q,Z,$){let X=this.teams.get(Q);if(!X)return;let V={type:"broadcast",from:$||"system",content:Z,timestamp:Date.now()};for(let J of X.teammates){if($&&J.teammateId===$)continue;let z=this.messageQueue.get(J.teammateId)||[];z.push(V),this.messageQueue.set(J.teammateId,z)}}sendDirect(Q,Z,$){let X={type:"direct",from:Z,to:Q,content:$,timestamp:Date.now()},V=this.messageQueue.get(Q)||[];V.push(X),this.messageQueue.set(Q,V)}getMessages(Q){let Z=this.messageQueue.get(Q)||[];return this.messageQueue.delete(Q),Z}hasMessages(Q){let Z=this.messageQueue.get(Q);return Z!==void 0&&Z.length>0}peekMessages(Q){return this.messageQueue.get(Q)||[]}clearMessages(Q){this.messageQueue.delete(Q)}getMessageCount(Q){return this.messageQueue.get(Q)?.length||0}async persistTeam(Q){let Z=V0(this.storagePath,Q.name),$=V0(Z,"config.json");if(!D8(Z))N8(Z,{recursive:!0});await Bun.write(V0(Z,".gitkeep"),"");let X={name:Q.name,description:Q.description,teammates:Q.teammates,taskListId:Q.taskListId,status:Q.status,coordination:Q.coordination,updatedAt:Date.now()};await Bun.write($,JSON.stringify(X,null,2))}loadTeams(){let Q=new Bun.Glob("**/config.json");try{let Z=Array.from(Q.scanSync(this.storagePath));for(let $ of Z)try{let X=V0(this.storagePath,$);if(Bun.file(X).size===0)continue;let z=y5(X,"utf-8"),Y=JSON.parse(z);if(!Y.name||!Y.teammates||!Array.isArray(Y.teammates))continue;let K={name:Y.name,description:Y.description||"",teammates:Y.teammates,taskListId:Y.taskListId||"",status:Y.status||"active",coordination:Y.coordination||{dependencyOrder:[],communicationProtocol:"broadcast",taskAssignmentStrategy:"manual"}};this.teams.set(K.name,K);for(let q of K.teammates)this.teammates.set(q.teammateId,q)}catch(X){}}catch(Z){if(Z.code!=="ENOENT");}}async persistAllTeams(){let Q=Array.from(this.teams.values()).map((Z)=>this.persistTeam(Z));await Promise.all(Q)}}var Y1={architect:(Q)=>({name:"architect",teamName:Q,color:"blue",prompt:`You are an architect on the ${Q} team.
|
|
231
|
+
Your role is to design and plan the technical architecture.
|
|
232
|
+
Focus on:
|
|
233
|
+
- System design and component relationships
|
|
234
|
+
- API contracts and interfaces
|
|
235
|
+
- Data models and schemas
|
|
236
|
+
- 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.
|
|
237
|
+
Your role is to write clean, working code based on the architecture.
|
|
238
|
+
Focus on:
|
|
239
|
+
- Implementing the designed architecture
|
|
240
|
+
- Writing tests
|
|
241
|
+
- Following coding standards
|
|
242
|
+
- 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.
|
|
243
|
+
Your role is to review code changes and provide feedback.
|
|
244
|
+
Focus on:
|
|
245
|
+
- Code quality and readability
|
|
246
|
+
- Potential bugs and issues
|
|
247
|
+
- Performance considerations
|
|
248
|
+
- Test coverage`,planModeRequired:!1,status:"pending"}),tester:(Q)=>({name:"tester",teamName:Q,color:"orange",prompt:`You are a tester on the ${Q} team.
|
|
249
|
+
Your role is to ensure features work correctly.
|
|
250
|
+
Focus on:
|
|
251
|
+
- Writing comprehensive tests
|
|
252
|
+
- Finding edge cases
|
|
253
|
+
- Verifying requirements
|
|
254
|
+
- Reporting bugs`,planModeRequired:!1,status:"pending"})};function f5(){return`teammate_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function K1(Q){return{...Q,teammateId:f5(),status:"pending"}}
|
|
255
|
+
export{S0 as a,z0 as b,y8 as c,h5 as d,_Q as e,UQ as f,g5 as g,g8 as h,m8 as i,d8 as j,c8 as k,BQ as l,i8 as m,n8 as n,x0 as o,T0 as p,o5 as q,r5 as r,a5 as s,j9 as t,y0 as u,MQ as v,RQ as w,Z7 as x,$7 as y,X7 as z,V7 as A,J7 as B,O9 as C,F7 as D,m0 as E,v7 as F,O7 as G,C7 as H,w6 as I,A6 as J,N7 as K,q5 as L,W5 as M,H5 as N,j5 as O,_5 as P,U5 as Q,w5 as R,A5 as S,B5 as T,L5 as U,F5 as V,v5 as W,O5 as X,C5 as Y,M5 as Z,h$ as _,WQ as $,c$ as aa,N5 as ba,i$ as ca,n$ as da,o$ as ea,x5 as fa,E5 as ga,e$ as ha,Q1 as ia,Z1 as ja,$1 as ka,b5 as la,Y1 as ma,f5 as na,K1 as oa};
|