@dahawa/hawa-code 2.7.17 → 2.7.19
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/cli.js +5 -5
- package/hands.js +4 -4
- package/package.json +1 -1
package/hands.js
CHANGED
|
@@ -623,7 +623,7 @@ data: ${JSON.stringify(z)}
|
|
|
623
623
|
`);a=M.pop()||"";for(let z of M){let j=z.trim();if(!(!j||j==="data: [DONE]"))if(j.startsWith("data: ")){let L=j.slice(6);try{let V=JSON.parse(L);D(V)}catch(V){this.logger&&this.logger.error({err:V,line:j},"Failed to parse Gemini SSE chunk")}}else try{let L=JSON.parse(j);D(L)}catch{}}};(async()=>{try{for(;;){let{value:M,done:z}=await s.read();if(z)break;a+=n.decode(M,{stream:!0}),N()}T()}catch(M){o.error(M)}})()}})}convertGeminiResponseToAnthropic(t){this.logger&&this.logger.debug({response:t},"Original Gemini response");try{if(!t.candidates||!t.candidates[0])throw new Error("No candidates found in Gemini response");let r=t.candidates[0],n=[];r.content&&r.content.parts&&r.content.parts.forEach(o=>{if(o.text&&n.push({type:"text",text:o.text}),o.functionCall){let s=`toolu_${YN()}`,a=o.functionCall.thoughtSignature||o.functionCall.thought_signature||null;n.push({type:"tool_use",id:s,name:o.functionCall.name,input:o.functionCall.args||{},thought_signature:a})}}),r.groundingMetadata&&(this.logger&&this.logger.debug({groundingMetadata:r.groundingMetadata},"Processing grounding metadata"),r.groundingMetadata.webSearchQueries&&n.push({type:"text",text:`
|
|
624
624
|
|
|
625
625
|
[Search queries used: ${r.groundingMetadata.webSearchQueries.join(", ")}]`}));let i={id:`msg_${Math.random().toString(36).slice(2)}`,type:"message",role:"assistant",model:t.modelVersion||"gemini",content:n,stop_reason:r.finishReason?r.finishReason==="STOP"&&n.some(o=>o.type==="tool_use")?"tool_use":this.mapGeminiFinishReason(r.finishReason):"end_turn",stop_sequence:null,usage:{input_tokens:t.usageMetadata?.promptTokenCount||0,output_tokens:t.usageMetadata?.candidatesTokenCount||0}};return this.logger&&this.logger.debug({result:i},"Conversion complete, final Anthropic response"),i}catch{throw H3r(`Provider error: ${JSON.stringify(t)}`,500,"provider_error")}}mapGeminiFinishReason(t){switch(t){case"STOP":return"end_turn";case"MAX_TOKENS":return"max_tokens";case"SAFETY":case"RECITATION":return"stop_sequence";default:return"end_turn"}}},z_e=new G_e;var Rpt=Re(xpt(),1);Wt();ps();function cg(e){return e?typeof e.entries=="function"?Object.fromEntries(e.entries()):{...e}:{}}function wpt(e){let t=String(e?.["x-thinking-level"]??"medium").toLowerCase();return["off","low","medium","high"].includes(t)?t:"medium"}function ren(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t}}function nen(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t,summary:"auto"}}function ien(e,t="chat"){let r={request:{},response:{},openai:{request:{},response:{}}};return r.request.model=e.request.body.model,r.request.messages=e.request.body.messages,r.request.system=e.request.body.system,r.response.content=e.response.body.content,r.response.usage=e.response.body?.usage,t==="responses"?(r.openai.request.model=e.openai.request.body.model,r.openai.request.input=e.openai.request.body.input,r.openai.response.output=e.openai.response.body?.output,r.openai.response.usage=e.openai.response.body?.usage):(r.openai.request.model=e.openai.request.body.model,r.openai.request.messages=e.openai.request.body.messages,r.openai.response.choices=e.openai.response.body.choices,r.openai.response.usage=e.openai.response.body?.usage),r}function NU(e,t,r){TG(t,e),vG(t,ien(e,r),r)}function MB(e){let t=[],r=e.getReader(),n,i=new Promise(l=>n=l),o=!1,s=()=>{o||(o=!0,n(Buffer.concat(t).toString("utf8")))};return{stream:new ReadableStream({async pull(l){try{let{done:c,value:u}=await r.read();if(c){l.close(),s();return}t.push(u),l.enqueue(u)}catch(c){l.error(c),s()}},cancel(l){r.cancel(l).catch(()=>{}),s()}}),done:i}}function BU(e){let t=new Headers(e);return t.delete("content-encoding"),t.delete("content-length"),t.delete("transfer-encoding"),t}function _1e(e,t,r,n,i){let o;try{o={type:"error",error:{type:"api_error",message:JSON.parse(i).error?.message??`${e}: ${n}`,code:`${t}_${r}_ERROR`}}}catch{o={type:"error",error:{type:"api_error",message:`${e}: ${n}`,code:`${t}_${r}_ERROR`}}}return new Response(JSON.stringify(o),{status:r,statusText:n,headers:{"Content-Type":"application/json"}})}var Dpt=["/v1/messages"];function y1e(e){let t;try{typeof e=="string"?t=new QT(e):e instanceof QT?t=e:t=new QT(e.url)}catch{return""}let r=t.pathname;for(let n of Dpt){let i=r.indexOf(n);if(i!==-1)return t.origin+r.slice(0,i)}return t.origin}function MJ(e,t){let r=typeof e=="string"?e:e instanceof QT?e.toString():e.url,n;try{n=new QT(r).pathname}catch{return!1}return Dpt.some(i=>n.includes(i))&&(t.method==="POST"||t.method==="post")}function oen(e){return async(t,r)=>{if(!MJ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await QW.transformRequestOut(n),o=y1e(t)+"/chat/completions",s=cg(r.headers),a=s.authorization??s.Authorization??"";ren(i,wpt(s));let l=await e(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:a},body:JSON.stringify(i),signal:r.signal});if(!l.ok){let y=await l.text();return K(`OpenAI Chat Completions API error: ${l.status}`,{url:o,errorResponse:y}),_1e("OpenAI Chat Completions API error","OPENROUTER",l.status,l.statusText,y)}let c=n.stream===!0,u=s["x-agent-id"],d={request:{url:o,method:r.method,headers:s,body:n},response:{status:l.status,statusText:l.statusText,headers:cg(l.headers)},openai:{request:{body:i},response:{}}};if(!c){let y=await l.text(),C=new Response(y,{status:l.status,statusText:l.statusText,headers:BU(l.headers)}),I=await QW.transformResponseIn(C,n),T=await I.text();try{NU({...d,openai:{...d.openai,response:{body:JSON.parse(y)}},response:{...d.response,body:JSON.parse(T)}},u)}catch(D){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u975E\u6D41\u5F0F):",D)}return new Response(T,{status:I.status,statusText:I.statusText,headers:I.headers})}let g=MB(l.body),m=new Response(g.stream,{status:l.status,statusText:l.statusText,headers:BU(l.headers)}),A=await QW.transformResponseIn(m,n),h=MB(A.body);return Promise.all([g.done,h.done]).then(async([y,C])=>{try{NU({...d,openai:{...d.openai,response:{body:await nit(y)}},response:{...d.response,body:await SF(C)}},u)}catch(I){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u6D41\u5F0F):"+I?.stack)}}).catch(y=>K("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Chat):"+y)),new Response(h.stream,{status:A.status,statusText:A.statusText,headers:A.headers})}}function sen(e){return async(t,r)=>{if(!MJ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await PW.transformRequestOut(n),o=cg(r.headers);nen(i,wpt(o));let s=JSON.stringify(i),l=y1e(t)+"/responses",c=o.authorization??o.Authorization??"";if(!c)return new Response(JSON.stringify({type:"error",error:{type:"api_error",message:"Missing Authorization header",code:"RESPONSES_AUTH_MISSING"}}),{status:401,headers:{"Content-Type":"application/json"}});let u=await e(l,{method:"POST",headers:{"Content-Type":"application/json",Authorization:c,"x-api-key":c.replace(/^Bearer\s+/i,"").trim()},body:s,signal:r.signal});if(!u.ok){let I=await u.text();return K(`OpenAI Responses API error: ${u.status} ${u.statusText}`,{url:l,status:u.status,errorResponse:I}),_1e("OpenAI Responses API error","RESPONSES",u.status,u.statusText,I)}let d=n.stream===!0,g=o["x-agent-id"],m={request:{url:l,method:r.method,headers:o,body:n},response:{status:u.status,statusText:u.statusText,headers:cg(u.headers)},openai:{request:{body:i},response:{}}};if(!d){let I=await u.text(),T=new Response(I,{status:u.status,statusText:u.statusText,headers:BU(u.headers)}),D=await PW.transformResponseIn(T,n),N=await D.text();try{NU({...m,openai:{...m.openai,response:{body:JSON.parse(I)}},response:{...m.response,body:JSON.parse(N)}},g,"responses")}catch(M){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u975E\u6D41\u5F0F):",M)}return new Response(N,{status:D.status,statusText:D.statusText,headers:D.headers})}let A=MB(u.body),h=new Response(A.stream,{status:u.status,statusText:u.statusText,headers:BU(u.headers)}),y=await PW.transformResponseIn(h,n),C=MB(y.body);return Promise.all([A.done,C.done]).then(async([I,T])=>{try{NU({...m,openai:{...m.openai,response:{body:await rit(I)}},response:{...m.response,body:await SF(T)}},g,"responses")}catch(D){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u6D41\u5F0F):"+D?.stack)}}).catch(I=>K("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Responses):"+I)),new Response(C.stream,{status:y.status,statusText:y.statusText,headers:y.headers})}}function aen(e){return async(t,r)=>{if(!MJ(t,r))return e(t,r);let n=JSON.parse(r.body),i=cg(r.headers),o=await z_e.transformRequestOut(n),s=JSON.stringify(o),a=y1e(t)+`/models/${n.model}:streamGenerateContent?alt=sse`,l=i.authorization??i.Authorization??"",c;try{c=await e(a,{method:"POST",headers:{"Content-Type":"application/json","x-goog-api-key":String(l).replace(/^Bearer\s+/i,"").trim()},body:s,signal:r.signal})}catch(C){throw K("gemini request error:",C),C}if(!c.ok){let C=await c.text();return K(`Gemini API error response: ${c.status} ${c.statusText}`,{url:a,status:c.status,errorResponse:C}),_1e("Gemini API error","Gemini",c.status,c.statusText,C)}let u=n.stream===!0,d=i["x-agent-id"],g={request:{url:a,method:r.method,headers:cg(r.headers),body:n},response:{status:c.status,statusText:c.statusText,headers:cg(c.headers)},openai:{request:{body:o},response:{}}},m=MB(c.body),A=new Response(m.stream,{status:c.status,statusText:c.statusText,headers:BU(c.headers)}),h=await z_e.transformResponseIn(A),y=MB(h.body);return Promise.all([m.done,y.done]).then(async([C,I])=>{try{let T=u?iit(C):JSON.parse(C),D=u?await SF(I):JSON.parse(I);NU({...g,openai:{...g.openai,response:{body:T}},response:{...g.response,body:D}},d)}catch(T){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Gemini):"+T?.stack)}}).catch(C=>K("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Gemini):"+C)),new Response(y.stream,{status:h.status,statusText:h.statusText,headers:h.headers})}}function len(e){return async(t,r)=>{if(!MJ(t,r))return e(t,r);let n=r.body;if(r.body)try{let d=JSON.parse(r.body);n=JSON.stringify(d)}catch{}let i=cg(r.headers);["1","true"].includes(String(process.env.HAWA_CODE_X_API_KEY_DISABLED??"").toLowerCase())&&(delete i["x-api-key"],delete i["X-API-Key"]),["1","true"].includes(String(process.env.HAWA_CODE_AUTH_DISABLED??"").toLowerCase())&&(delete i.authorization,delete i.Authorization),delete i["content-length"];let a=await e(t,{method:r.method,headers:i,body:n,signal:r.signal});if(!a.ok){let d=await a.text();K(`API error response: ${a.status} ${a.statusText}`,{url:typeof t=="string"?t:t instanceof QT?t.toString():t.url,status:a.status,errorResponse:d});let g;try{let m=JSON.parse(d);g={type:"error",error:{type:"api_error",message:m.error?.message||m.message||`API error: ${a.statusText}`,code:m.error?.code||m.code||`API_${a.status}_ERROR`}},m.error?.details&&(g.error.details=m.error.details)}catch{g={type:"error",error:{type:"api_error",message:`API error: ${a.statusText}`,code:`API_${a.status}_ERROR`}}}return new Response(JSON.stringify(g),{status:a.status,statusText:a.statusText,headers:{"Content-Type":"application/json"}})}let l=a.clone(),c=!(Object.hasOwn(JSON.parse(n),"stream")&&!JSON.parse(n).stream),u={request:{url:typeof t=="string"?t:t instanceof QT?t.toString():t.url,method:r.method,headers:cg(r.headers),body:JSON.parse(n)},response:{status:a.status,statusText:a.statusText,headers:cg(a.headers)}};return(async()=>{if(c){let m=await a.text();u.response.body=await SF(m)}else u.response.body=await a.json();let g=cg(r.headers)["x-agent-id"];TG(g,u),vG(g,{request:u.request.body.messages,response:u.response.body.content,usage:u.response.body?.usage})})().catch(d=>K(`\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF:
|
|
626
|
-
Stack trace: `+d.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var kJ=null,E1e=!1;function cen(){kJ=null,E1e=!1}_r.on("proxy:changed",cen);function uen(){if(E1e)return kJ;if(E1e=!0,tt().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(kJ=new Rpt.ProxyAgent({uri:e}),Ct(`[proxy] using proxy: ${e}`)),kJ}function den(){let e=uen();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function QJ(e){let t=e||process.env.API_TYPE,r=den();switch(t){case"openai":return oen(r);case"openai-responses":return sen(r);case"gemini":return aen(r);default:return len(r)}}kA();var gen=Re(it(),1);function Npt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=fen(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function fen(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||pen(t)?0:men(t)?2:1}function pen(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function men(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=129280&&e<=129535||e>=131072&&e<=262141)}function O0(e){if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),n=(e%6e4/1e3).toFixed(1);return t>0?`${t}h ${r}m ${n}s`:r>0?`${r}m ${n}s`:`${n}s`}function AC(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}Oe();ps();var Gl={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function PJ(e,t){Gl.totalCost+=e,Gl.totalAPIDuration+=t}function LJ(e,t){Gl.inputTokens+=e,Gl.outputTokens+=t,_r.emit("token:change",{inputTokens:Gl.inputTokens,outputTokens:Gl.outputTokens})}function FJ(e,t){Gl.cacheCreationTokens+=e,Gl.cacheReadTokens+=t}function b1e(){return{inputTokens:Gl.inputTokens,outputTokens:Gl.outputTokens,cacheCreationTokens:Gl.cacheCreationTokens,cacheReadTokens:Gl.cacheReadTokens}}function Bpt(){return Gl.totalCost}function Opt(){return Date.now()-Gl.startTime}function kpt(){return Gl.totalAPIDuration}function Mpt(e){Gl.currentContextTokens=e}function Qpt(){return Gl.currentContextTokens}Oe();He();He();var C1e="2.7.17";globalThis.MACRO={VERSION:C1e,PACKAGE_URL:`@dahawa/${Fi}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var UJ=process.env.HAWA_CODE_USER_AGENT||`${Fi}/${C1e} (${process.env.USER_TYPE})`;import{randomUUID as jh}from"crypto";ps();Oe();er();Ar();Oe();He();import{existsSync as L0,readdirSync as qin,statSync as Gin}from"fs";import{join as yC,relative as zin}from"path";import{homedir as xAt}from"os";import{platform as jin}from"process";import{readFile as bC}from"fs/promises";Ar();qp();Wt();import{join as yen,sep as ben}from"path";function Gp(){if(!au())return!1;try{let e=tt();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function Cf(){return(yen(Be(),".hcode","team-memory")+ben).normalize("NFC")}function M0(e){let t=e.normalize("NFC"),r=Cf();return t.startsWith(r)}qp();var wAt=Re($U(),1);Ci();var F1e=(e,t,r)=>{let n=e instanceof RegExp?tAt(e,r):e,i=t instanceof RegExp?tAt(t,r):t,o=n!==null&&i!=null&&Onn(n,i,r);return o&&{start:o[0],end:o[1],pre:r.slice(0,o[0]),body:r.slice(o[0]+n.length,o[1]),post:r.slice(o[1]+i.length)}},tAt=(e,t)=>{let r=t.match(e);return r?r[0]:null},Onn=(e,t,r)=>{let n,i,o,s,a,l=r.indexOf(e),c=r.indexOf(t,l+1),u=l;if(l>=0&&c>0){if(e===t)return[l,c];for(n=[],o=r.length;u>=0&&!a;){if(u===l)n.push(u),l=r.indexOf(e,u+1);else if(n.length===1){let d=n.pop();d!==void 0&&(a=[d,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[o,s])}return a};var rAt="\0SLASH"+Math.random()+"\0",nAt="\0OPEN"+Math.random()+"\0",H1e="\0CLOSE"+Math.random()+"\0",iAt="\0COMMA"+Math.random()+"\0",oAt="\0PERIOD"+Math.random()+"\0",knn=new RegExp(rAt,"g"),Mnn=new RegExp(nAt,"g"),Qnn=new RegExp(H1e,"g"),Pnn=new RegExp(iAt,"g"),Lnn=new RegExp(oAt,"g"),Fnn=/\\\\/g,Unn=/\\{/g,$nn=/\\}/g,Hnn=/\\,/g,qnn=/\\\./g,Gnn=1e5,znn=4e6;function U1e(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function jnn(e){return e.replace(Fnn,rAt).replace(Unn,nAt).replace($nn,H1e).replace(Hnn,iAt).replace(qnn,oAt)}function Ynn(e){return e.replace(knn,"\\").replace(Mnn,"{").replace(Qnn,"}").replace(Pnn,",").replace(Lnn,".")}function sAt(e){if(!e)return[""];let t=[],r=F1e("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=sAt(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function aAt(e,t={}){if(!e)return[];let{max:r=Gnn,maxLength:n=znn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),$1e(jnn(e),r,n,!0).map(Ynn)}function Vnn(e){return"{"+e+"}"}function Wnn(e){return/^-?0\d/.test(e)}function Knn(e,t){return e<=t}function Jnn(e,t){return e>=t}function HU(e,t,r,n,i,o){let s=[],a=0;for(let l=0;l<e.length;l++)for(let c=0;c<r.length;c++){if(s.length>=n)return s;let u=e[l]+t+r[c];if(!(o&&!u)){if(a+u.length>i)return s;s.push(u),a+=u.length}}return s}function Znn(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=U1e(i[0]),a=U1e(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(U1e(i[2])),1):1,u=Knn;a<s&&(c*=-1,u=Jnn);let g=i.some(Wnn),m=0;for(let A=s;u(A,a)&&o.length<r;A+=c){let h;if(t)h=String.fromCharCode(A),h==="\\"&&(h="");else if(h=String(A),g){let y=l-h.length;if(y>0){let C=new Array(y+1).join("0");A<0?h="-"+C+h.slice(1):h=C+h}}if(m+h.length>n)break;o.push(h),m+=h.length}return o}function $1e(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=F1e("{","}",e);if(!a)return HU(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=HU(i,l+"{"+a.body+"}",[""],t,r,o&&!a.post.length),s=!1,!a.post.length)break;e=a.post;continue}let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),d=c||u,g=a.body.indexOf(",")>=0;if(!d&&!g){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+H1e+a.post,n=!0;continue}return HU(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!d,s=!1);let m;if(d)m=Znn(a.body,u,t,r);else{let A=sAt(a.body);if(A.length===1&&A[0]!==void 0&&(A=$1e(A[0],t,r,!1).map(Vnn),A.length===1)){if(i=HU(i,l+A[0],[""],t,r,o&&!a.post.length),!a.post.length)break;e=a.post;continue}let h=o&&!a.post.length&&!l;for(let C=0;h&&C<i.length;C++)i[C]&&(h=!1);m=[];let y=0;e:for(let C=0;C<A.length;C++){let I=$1e(A[C],t,r,!1);for(let T=0;T<I.length;T++){let D=I[T];if(!(h&&!D)){if(m.length>=t||y+D.length>r)break e;m.push(D),y+=D.length}}}}if(i=HU(i,l,m,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var qU=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Xnn={"[: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]},GU=e=>e.replace(/[[\]\\-]/g,"\\$&"),ein=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),lAt=e=>e.join(""),cAt=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,l=!1,c=!1,u=r,d="";e:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===r+1){c=!0,o++;continue}if(h==="]"&&s&&!l){u=o+1;break}if(s=!0,h==="\\"&&!l){l=!0,o++;continue}if(h==="["&&!l){for(let[y,[C,I,T]]of Object.entries(Xnn))if(e.startsWith(y,o)){if(d)return["$.",!1,e.length-r,!0];o+=y.length,T?i.push(C):n.push(C),a=a||I;continue e}}if(l=!1,d){h>d?n.push(GU(d)+"-"+GU(h)):h===d&&n.push(GU(h)),d="",o++;continue}if(e.startsWith("-]",o+1)){n.push(GU(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){d=h,o+=2;continue}n.push(GU(h)),o++}if(u<o)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!c){let h=n[0].length===2?n[0].slice(-1):n[0];return[ein(h),!1,u-r,!1]}let g="["+(c?"^":"")+lAt(n)+"]",m="["+(c?"":"^")+lAt(i)+"]";return[n.length&&i.length?"("+g+"|"+m+")":n.length?g:m,a,u-r,!0]};var _C=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var fd,tin=new Set(["!","?","+","*","@"]),q1e=e=>tin.has(e),uAt=e=>q1e(e.type),rin=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),nin=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),iin=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),dAt=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),oin="(?!(?:^|/)\\.\\.?(?:$|/))",XJ="(?!\\.)",sin=new Set(["[","."]),ain=new Set(["..","."]),lin=new Set("().*{}+?[]^$\\!"),cin=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),G1e="[^/]",fAt=G1e+"*?",pAt=G1e+"+?",uin=0,GT=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;id=++uin;get depth(){return(this.#o?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#o?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(t,r,n={}){this.type=t,t&&(this.#t=!0),this.#o=r,this.#e=this.#o?this.#o.#e:this,this.#a=this.#e===this?n:this.#e.#a,this.#l=this.#e===this?[]:this.#e.#l,t==="!"&&!this.#e.#s&&this.#l.push(this),this.#i=this.#o?this.#o.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let t of this.#r)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#d!==void 0?this.#d:this.type?this.#d=this.type+"("+this.#r.map(t=>String(t)).join("|")+")":this.#d=this.#r.map(t=>String(t)).join("")}#f(){if(this!==this.#e)throw new Error("should only call on root");if(this.#s)return this;this.toString(),this.#s=!0;let t;for(;t=this.#l.pop();){if(t.type!=="!")continue;let r=t,n=r.#o;for(;n;){for(let i=r.#i+1;!n.type&&i<n.#r.length;i++)for(let o of t.#r){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#r[i])}r=n,n=r.#o}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof fd&&r.#o===this))throw new Error("invalid part: "+r);this.#r.push(r)}}toJSON(){let t=this.type===null?this.#r.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#r.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#o?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#o?.isStart())return!1;if(this.#i===0)return!0;let t=this.#o;for(let r=0;r<this.#i;r++){let n=t.#r[r];if(!(n instanceof fd&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let t=this.#o?this.#o.#r.length:0;return this.#i===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new fd(this.type,t);for(let n of this.#r)r.copyIn(n);return r}static#c(t,r,n,i,o){let s=i.maxExtglobRecursion??2,a=!1,l=!1,c=-1,u=!1;if(r.type===null){let h=n,y="";for(;h<t.length;){let C=t.charAt(h++);if(a||C==="\\"){a=!a,y+=C;continue}if(l){h===c+1?(C==="^"||C==="!")&&(u=!0):C==="]"&&!(h===c+2&&u)&&(l=!1),y+=C;continue}else if(C==="["){l=!0,c=h,u=!1,y+=C;continue}if(!i.noext&&q1e(C)&&t.charAt(h)==="("&&o<=s){r.push(y),y="";let T=new fd(C,r);h=fd.#c(t,T,h,i,o+1),r.push(T);continue}y+=C}return r.push(y),h}let d=n+1,g=new fd(null,r),m=[],A="";for(;d<t.length;){let h=t.charAt(d++);if(a||h==="\\"){a=!a,A+=h;continue}if(l){d===c+1?(h==="^"||h==="!")&&(u=!0):h==="]"&&!(d===c+2&&u)&&(l=!1),A+=h;continue}else if(h==="["){l=!0,c=d,u=!1,A+=h;continue}if(!i.noext&&q1e(h)&&t.charAt(d)==="("&&(o<=s||r&&r.#E(h))){let C=r&&r.#E(h)?0:1;g.push(A),A="";let I=new fd(h,g);g.push(I),d=fd.#c(t,I,d,i,o+C);continue}if(h==="|"){g.push(A),A="",m.push(g),g=new fd(null,r);continue}if(h===")")return A===""&&r.#r.length===0&&(r.#p=!0),g.push(A),A="",r.push(...m,g),d;A+=h}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],d}#g(t){return this.#h(t,nin)}#h(t,r=rin){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null)return!1;let n=t.#r[0];return!n||typeof n!="object"||n.type===null?!1:this.#E(n.type,r)}#E(t,r=iin){return!!r.get(this.type)?.includes(t)}#A(t,r){let n=t.#r[0],i=new fd(null,n,this.options);i.#r.push(""),n.push(i),this.#v(t,r)}#v(t,r){let n=t.#r[0];this.#r.splice(r,1,...n.#r);for(let i of n.#r)typeof i=="object"&&(i.#o=this);this.#d=void 0}#y(t){return!!dAt.get(this.type)?.has(t)}#S(t){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let r=t.#r[0];return!r||typeof r!="object"||r.type===null?!1:this.#y(r.type)}#I(t){let r=dAt.get(this.type),n=t.#r[0],i=r?.get(n.type);if(!i)return!1;this.#r=n.#r;for(let o of this.#r)typeof o=="object"&&(o.#o=this);this.type=i,this.#d=void 0,this.#p=!1}static fromGlob(t,r={}){let n=new fd(null,void 0,r);return fd.#c(t,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,i,o]=this.toRegExpSource();if(!(i||this.#t||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#a}toRegExpSource(t){let r=t??!!this.#a.dot;if(this.#e===this&&(this.#_(),this.#f()),!uAt(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(m=>typeof m!="string"),c=this.#r.map(m=>{let[A,h,y,C]=typeof m=="string"?fd.#C(m,this.#t,l):m.toRegExpSource(t);return this.#t=this.#t||y,this.#n=this.#n||C,A}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&ain.has(this.#r[0]))){let A=sin,h=r&&A.has(c.charAt(0))||c.startsWith("\\.")&&A.has(c.charAt(2))||c.startsWith("\\.\\.")&&A.has(c.charAt(4)),y=!r&&!t&&A.has(c.charAt(0));u=h?oin:y?XJ:""}let d="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(d="(?:$|\\/)"),[u+c+d,_C(c),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#b(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString(),c=this;return c.#r=[l],c.type=null,c.#t=void 0,[l,_C(this.toString()),!1,!1]}let s=!n||t||r||!XJ?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?XJ:"")+pAt;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?XJ:"")+fAt+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,_C(o),this.#t=!!this.#t,this.#n]}#_(){if(uAt(this)){let t=0,r=!1;do{r=!0;for(let n=0;n<this.#r.length;n++){let i=this.#r[n];typeof i=="object"&&(i.#_(),this.#h(i)?(r=!1,this.#v(i,n)):this.#g(i)?(r=!1,this.#A(i,n)):this.#S(i)&&(r=!1,this.#I(i)))}}while(!r&&++t<10)}else for(let t of this.#r)typeof t=="object"&&t.#_();this.#d=void 0}#b(t){return this.#r.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,o,s]=r.toRegExpSource(t);return this.#n=this.#n||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#C(t,r,n=!1){let i=!1,o="",s=!1,a=!1;for(let l=0;l<t.length;l++){let c=t.charAt(l);if(i){i=!1,o+=(lin.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?pAt:fAt,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,d,g,m]=cAt(t,l);if(g){o+=u,s=s||d,l+=g-1,r=r||m;continue}}if(c==="?"){o+=G1e,r=!0;continue}o+=cin(c)}return[o,_C(t),!!r,s]}};fd=GT;var z1e=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var jl=(e,t,r={})=>(qU(t),!r.nocomment&&t.charAt(0)==="#"?!1:new zB(t,r).match(e)),din=/^\*+([^+@!?*[(]*)$/,fin=e=>t=>!t.startsWith(".")&&t.endsWith(e),pin=e=>t=>t.endsWith(e),min=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),gin=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Ain=/^\*+\.\*+$/,hin=e=>!e.startsWith(".")&&e.includes("."),Ein=e=>e!=="."&&e!==".."&&e.includes("."),_in=/^\.\*+$/,yin=e=>e!=="."&&e!==".."&&e.startsWith("."),bin=/^\*+$/,Cin=e=>e.length!==0&&!e.startsWith("."),Sin=e=>e.length!==0&&e!=="."&&e!=="..",Iin=/^\?+([^+@!?*[(]*)?$/,Tin=([e,t=""])=>{let r=AAt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},vin=([e,t=""])=>{let r=hAt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},xin=([e,t=""])=>{let r=hAt([e]);return t?n=>r(n)&&n.endsWith(t):r},win=([e,t=""])=>{let r=AAt([e]);return t?n=>r(n)&&n.endsWith(t):r},AAt=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},hAt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},EAt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",mAt={win32:{sep:"\\"},posix:{sep:"/"}},Din=EAt==="win32"?mAt.win32.sep:mAt.posix.sep;jl.sep=Din;var vc=Symbol("globstar **");jl.GLOBSTAR=vc;var Rin="[^/]",Nin=Rin+"*?",Bin="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Oin="(?:(?!(?:\\/|^)\\.).)*?",kin=(e,t={})=>r=>jl(r,e,t);jl.filter=kin;var zp=(e,t={})=>Object.assign({},e,t),Min=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return jl;let t=jl;return Object.assign((n,i,o={})=>t(n,i,zp(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,zp(e,o))}static defaults(i){return t.defaults(zp(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,zp(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,zp(e,o))}},unescape:(n,i={})=>t.unescape(n,zp(e,i)),escape:(n,i={})=>t.escape(n,zp(e,i)),filter:(n,i={})=>t.filter(n,zp(e,i)),defaults:n=>t.defaults(zp(e,n)),makeRe:(n,i={})=>t.makeRe(n,zp(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,zp(e,i)),match:(n,i,o={})=>t.match(n,i,zp(e,o)),sep:t.sep,GLOBSTAR:vc})};jl.defaults=Min;var _At=(e,t={})=>(qU(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:aAt(e,{max:t.braceExpandMax}));jl.braceExpand=_At;var Qin=(e,t={})=>new zB(e,t).makeRe();jl.makeRe=Qin;var Pin=(e,t,r={})=>{let n=new zB(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};jl.match=Pin;var gAt=/[?*]|[+@!]\(.*?\)|\[|\]/,Lin=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),zB=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){qU(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||EAt,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.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 t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((o,s,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=o[0]===""&&o[1]===""&&(o[2]==="?"||!gAt.test(o[2]))&&!gAt.test(o[3]),c=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(c)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let s=this.set[o];s[0]===""&&s[1]===""&&this.globParts[o][2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3])&&(s[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n of t)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let o=n[n.length-1];return i==="**"&&o==="**"?n:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let o=t[i];i===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let s=i;for(;n[s+1]==="**";)s++;s>i&&n.splice(i+1,s-i);let a=n[i+1],l=n[i+2],c=n[i+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let s=1;s<n.length-1;s++){let a=n[s];s===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(s,1),s--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let s=n[o-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let l=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...l),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(i){t[r]=[],t[n]=i;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,o=0,s=[],a="";for(;i<t.length&&o<r.length;)if(t[i]===r[o])s.push(a==="b"?r[o]:t[i]),i++,o++;else if(n&&t[i]==="**"&&r[o]===t[i+1])s.push(t[i]),i++;else if(n&&r[o]==="**"&&t[i]===r[o+1])s.push(r[o]),o++;else if(t[i]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",s.push(t[i]),i++,o++}else if(r[o]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",s.push(r[o]),i++,o++}else return!1;return t.length===r.length&&s}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=0,o=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),l=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),c=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),u=!c&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),d=l?3:a?0:void 0,g=u?3:c?0:void 0;if(typeof d=="number"&&typeof g=="number"){let[m,A]=[t[d],r[g]];m.toLowerCase()===A.toLowerCase()&&(r[g]=m,o=g,i=d)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(vc)?this.#e(t,r,n,i,o):this.#n(t,r,n,i,o)}#e(t,r,n,i,o){let s=r.indexOf(vc,o),a=r.lastIndexOf(vc),[l,c,u]=n?[r.slice(o,s),r.slice(s+1),[]]:[r.slice(o,s),r.slice(s+1,a),r.slice(a+1)];if(l.length){let I=t.slice(i,i+l.length);if(!this.#n(I,l,n,0,0))return!1;i+=l.length,o+=l.length}let d=0;if(u.length){if(u.length+i>t.length)return!1;let I=t.length-u.length;if(this.#n(t,u,n,I,0))d=u.length;else{if(t[t.length-1]!==""||i+u.length===t.length||(I--,!this.#n(t,u,n,I,0)))return!1;d=u.length+1}}if(!c.length){let I=!!d;for(let T=i;T<t.length-d;T++){let D=String(t[T]);if(I=!0,D==="."||D===".."||!this.options.dot&&D.startsWith("."))return!1}return n||I}let g=[[[],0]],m=g[0],A=0,h=[0];for(let I of c)I===vc?(h.push(A),m=[[],0],g.push(m)):(m[0].push(I),A++);let y=g.length-1,C=t.length-d;for(let I of g)I[1]=C-(h[y--]+I[0].length);return!!this.#t(t,g,i,0,n,0,!!d)}#t(t,r,n,i,o,s,a){let l=r[i];if(!l){for(let d=n;d<t.length;d++){a=!0;let g=t[d];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(t.slice(0,n+c.length),c,o,n,0)&&s<this.maxGlobstarRecursion){let m=this.#t(t,r,n+c.length,i+1,o,s+1,a);if(m!==!1)return m}let g=t[n];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1;n++}return o||null}#n(t,r,n,i,o){let s,a,l,c;for(s=i,a=o,c=t.length,l=r.length;s<c&&a<l;s++,a++){this.debug("matchOne loop");let u=r[a],d=t[s];if(this.debug(r,u,d),u===!1||u===vc)return!1;let g;if(typeof u=="string"?(g=d===u,this.debug("string match",u,d,g)):(g=u.test(d),this.debug("pattern match",u,d,g)),!g)return!1}if(s===c&&a===l)return!0;if(s===c)return n;if(a===l)return s===c-1&&t[s]==="";throw new Error("wtf?")}braceExpand(){return _At(this.pattern,this.options)}parse(t){qU(t);let r=this.options;if(t==="**")return vc;if(t==="")return"";let n,i=null;(n=t.match(bin))?i=r.dot?Sin:Cin:(n=t.match(din))?i=(r.nocase?r.dot?gin:min:r.dot?pin:fin)(n[1]):(n=t.match(Iin))?i=(r.nocase?r.dot?vin:Tin:r.dot?xin:win)(n):(n=t.match(Ain))?i=r.dot?Ein:hin:(n=t.match(_in))&&(i=yin);let o=GT.fromGlob(t,this.options).toMMPattern();return i&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:i}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?Nin:r.dot?Bin:Oin,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(d=>{if(d instanceof RegExp)for(let g of d.flags.split(""))i.add(g);return typeof d=="string"?Lin(d):d===vc?vc:d._src});c.forEach((d,g)=>{let m=c[g+1],A=c[g-1];d!==vc||A===vc||(A===void 0?m!==void 0&&m!==vc?c[g+1]="(?:\\/|"+n+"\\/)?"+m:c[g]=n:m===void 0?c[g-1]=A+"(?:\\/|\\/"+n+")?":m!==vc&&(c[g-1]=A+"(?:\\/|\\/"+n+"\\/)"+m,c[g+1]=vc))});let u=c.filter(d=>d!==vc);if(this.partial&&u.length>=1){let d=[];for(let g=1;g<=u.length;g++)d.push(u.slice(0,g).join("/"));return"(?:"+d.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];o="^"+s+o+a+"$",this.partial&&(o="^(?:\\/|"+s+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let s=i[i.length-1];if(!s)for(let a=i.length-2;!s&&a>=0;a--)s=i[a];for(let a of o){let l=i;if(n.matchBase&&a.length===1&&(l=[s]),this.matchOne(l,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return jl.defaults(t).Minimatch}};jl.AST=GT;jl.Minimatch=zB;jl.escape=z1e;jl.unescape=_C;var CAt=Re($U(),1);Ar();He();Oe();Xc();import{readFile as yAt}from"fs/promises";import{existsSync as j1e,readdirSync as Fin,statSync as Uin}from"fs";import{join as Y1e,relative as SAt}from"path";import{homedir as $in}from"os";function bAt(e){try{let t=(0,CAt.default)(e),r=t.data.paths,n=[];return typeof r=="string"?n=r.split(",").map(i=>i.trim()).filter(Boolean):Array.isArray(r)&&(n=r.filter(i=>typeof i=="string")),{paths:n,content:t.content.trim()}}catch(t){return ve(t),{paths:[],content:e.trim()}}}function Hin(e,t){return t.length===0?!0:t.some(r=>{try{return jl(e,r,{matchBase:!0,dot:!0})}catch(n){return ve(n),!1}})}function V1e(e){let t=[];try{if(!j1e(e))return t;let r=Fin(e);for(let n of r){let i=Y1e(e,n),o=Uin(i);o.isDirectory()?t.push(...V1e(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){ve(r)}return t}async function eZ(){let e=[];try{let t=Y1e($in(),Jr,"rules");if(j1e(t)){let r=V1e(t);for(let n of r)try{let i=await yAt(n,"utf-8"),{paths:o,content:s}=bAt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){ve(i)}}}catch(t){ve(t)}try{let t=Y1e(Be(),Jr,"rules");if(j1e(t)){let r=V1e(t);for(let n of r)try{let i=await yAt(n,"utf-8"),{paths:o,content:s}=bAt(i);o.length>0&&e.push({filePath:SAt(Be(),n),content:s,paths:o,isProjectRule:!0})}catch(i){ve(i)}}}catch(t){ve(t)}return e}function IAt(e,t){e=yY(e);let r=yY(Be()),n=e.startsWith(r)?SAt(r,e):e;return t.filter(i=>Hin(n,i.paths))}function TAt(e){return e.length===0?"":e.map(r=>{let n=r.isProjectRule?"project instructions, checked into the codebase":"user's private global instructions for all projects";return`Contents of ${r.filePath} (${n}):
|
|
626
|
+
Stack trace: `+d.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var kJ=null,E1e=!1;function cen(){kJ=null,E1e=!1}_r.on("proxy:changed",cen);function uen(){if(E1e)return kJ;if(E1e=!0,tt().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(kJ=new Rpt.ProxyAgent({uri:e}),Ct(`[proxy] using proxy: ${e}`)),kJ}function den(){let e=uen();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function QJ(e){let t=e||process.env.API_TYPE,r=den();switch(t){case"openai":return oen(r);case"openai-responses":return sen(r);case"gemini":return aen(r);default:return len(r)}}kA();var gen=Re(it(),1);function Npt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=fen(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function fen(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||pen(t)?0:men(t)?2:1}function pen(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function men(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=129280&&e<=129535||e>=131072&&e<=262141)}function O0(e){if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),n=(e%6e4/1e3).toFixed(1);return t>0?`${t}h ${r}m ${n}s`:r>0?`${r}m ${n}s`:`${n}s`}function AC(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}Oe();ps();var Gl={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function PJ(e,t){Gl.totalCost+=e,Gl.totalAPIDuration+=t}function LJ(e,t){Gl.inputTokens+=e,Gl.outputTokens+=t,_r.emit("token:change",{inputTokens:Gl.inputTokens,outputTokens:Gl.outputTokens})}function FJ(e,t){Gl.cacheCreationTokens+=e,Gl.cacheReadTokens+=t}function b1e(){return{inputTokens:Gl.inputTokens,outputTokens:Gl.outputTokens,cacheCreationTokens:Gl.cacheCreationTokens,cacheReadTokens:Gl.cacheReadTokens}}function Bpt(){return Gl.totalCost}function Opt(){return Date.now()-Gl.startTime}function kpt(){return Gl.totalAPIDuration}function Mpt(e){Gl.currentContextTokens=e}function Qpt(){return Gl.currentContextTokens}Oe();He();He();var C1e="2.7.19";globalThis.MACRO={VERSION:C1e,PACKAGE_URL:`@dahawa/${Fi}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var UJ=process.env.HAWA_CODE_USER_AGENT||`${Fi}/${C1e} (${process.env.USER_TYPE})`;import{randomUUID as jh}from"crypto";ps();Oe();er();Ar();Oe();He();import{existsSync as L0,readdirSync as qin,statSync as Gin}from"fs";import{join as yC,relative as zin}from"path";import{homedir as xAt}from"os";import{platform as jin}from"process";import{readFile as bC}from"fs/promises";Ar();qp();Wt();import{join as yen,sep as ben}from"path";function Gp(){if(!au())return!1;try{let e=tt();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function Cf(){return(yen(Be(),".hcode","team-memory")+ben).normalize("NFC")}function M0(e){let t=e.normalize("NFC"),r=Cf();return t.startsWith(r)}qp();var wAt=Re($U(),1);Ci();var F1e=(e,t,r)=>{let n=e instanceof RegExp?tAt(e,r):e,i=t instanceof RegExp?tAt(t,r):t,o=n!==null&&i!=null&&Onn(n,i,r);return o&&{start:o[0],end:o[1],pre:r.slice(0,o[0]),body:r.slice(o[0]+n.length,o[1]),post:r.slice(o[1]+i.length)}},tAt=(e,t)=>{let r=t.match(e);return r?r[0]:null},Onn=(e,t,r)=>{let n,i,o,s,a,l=r.indexOf(e),c=r.indexOf(t,l+1),u=l;if(l>=0&&c>0){if(e===t)return[l,c];for(n=[],o=r.length;u>=0&&!a;){if(u===l)n.push(u),l=r.indexOf(e,u+1);else if(n.length===1){let d=n.pop();d!==void 0&&(a=[d,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[o,s])}return a};var rAt="\0SLASH"+Math.random()+"\0",nAt="\0OPEN"+Math.random()+"\0",H1e="\0CLOSE"+Math.random()+"\0",iAt="\0COMMA"+Math.random()+"\0",oAt="\0PERIOD"+Math.random()+"\0",knn=new RegExp(rAt,"g"),Mnn=new RegExp(nAt,"g"),Qnn=new RegExp(H1e,"g"),Pnn=new RegExp(iAt,"g"),Lnn=new RegExp(oAt,"g"),Fnn=/\\\\/g,Unn=/\\{/g,$nn=/\\}/g,Hnn=/\\,/g,qnn=/\\\./g,Gnn=1e5,znn=4e6;function U1e(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function jnn(e){return e.replace(Fnn,rAt).replace(Unn,nAt).replace($nn,H1e).replace(Hnn,iAt).replace(qnn,oAt)}function Ynn(e){return e.replace(knn,"\\").replace(Mnn,"{").replace(Qnn,"}").replace(Pnn,",").replace(Lnn,".")}function sAt(e){if(!e)return[""];let t=[],r=F1e("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=sAt(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function aAt(e,t={}){if(!e)return[];let{max:r=Gnn,maxLength:n=znn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),$1e(jnn(e),r,n,!0).map(Ynn)}function Vnn(e){return"{"+e+"}"}function Wnn(e){return/^-?0\d/.test(e)}function Knn(e,t){return e<=t}function Jnn(e,t){return e>=t}function HU(e,t,r,n,i,o){let s=[],a=0;for(let l=0;l<e.length;l++)for(let c=0;c<r.length;c++){if(s.length>=n)return s;let u=e[l]+t+r[c];if(!(o&&!u)){if(a+u.length>i)return s;s.push(u),a+=u.length}}return s}function Znn(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=U1e(i[0]),a=U1e(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(U1e(i[2])),1):1,u=Knn;a<s&&(c*=-1,u=Jnn);let g=i.some(Wnn),m=0;for(let A=s;u(A,a)&&o.length<r;A+=c){let h;if(t)h=String.fromCharCode(A),h==="\\"&&(h="");else if(h=String(A),g){let y=l-h.length;if(y>0){let C=new Array(y+1).join("0");A<0?h="-"+C+h.slice(1):h=C+h}}if(m+h.length>n)break;o.push(h),m+=h.length}return o}function $1e(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=F1e("{","}",e);if(!a)return HU(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=HU(i,l+"{"+a.body+"}",[""],t,r,o&&!a.post.length),s=!1,!a.post.length)break;e=a.post;continue}let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),d=c||u,g=a.body.indexOf(",")>=0;if(!d&&!g){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+H1e+a.post,n=!0;continue}return HU(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!d,s=!1);let m;if(d)m=Znn(a.body,u,t,r);else{let A=sAt(a.body);if(A.length===1&&A[0]!==void 0&&(A=$1e(A[0],t,r,!1).map(Vnn),A.length===1)){if(i=HU(i,l+A[0],[""],t,r,o&&!a.post.length),!a.post.length)break;e=a.post;continue}let h=o&&!a.post.length&&!l;for(let C=0;h&&C<i.length;C++)i[C]&&(h=!1);m=[];let y=0;e:for(let C=0;C<A.length;C++){let I=$1e(A[C],t,r,!1);for(let T=0;T<I.length;T++){let D=I[T];if(!(h&&!D)){if(m.length>=t||y+D.length>r)break e;m.push(D),y+=D.length}}}}if(i=HU(i,l,m,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var qU=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Xnn={"[: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]},GU=e=>e.replace(/[[\]\\-]/g,"\\$&"),ein=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),lAt=e=>e.join(""),cAt=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,l=!1,c=!1,u=r,d="";e:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===r+1){c=!0,o++;continue}if(h==="]"&&s&&!l){u=o+1;break}if(s=!0,h==="\\"&&!l){l=!0,o++;continue}if(h==="["&&!l){for(let[y,[C,I,T]]of Object.entries(Xnn))if(e.startsWith(y,o)){if(d)return["$.",!1,e.length-r,!0];o+=y.length,T?i.push(C):n.push(C),a=a||I;continue e}}if(l=!1,d){h>d?n.push(GU(d)+"-"+GU(h)):h===d&&n.push(GU(h)),d="",o++;continue}if(e.startsWith("-]",o+1)){n.push(GU(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){d=h,o+=2;continue}n.push(GU(h)),o++}if(u<o)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!c){let h=n[0].length===2?n[0].slice(-1):n[0];return[ein(h),!1,u-r,!1]}let g="["+(c?"^":"")+lAt(n)+"]",m="["+(c?"":"^")+lAt(i)+"]";return[n.length&&i.length?"("+g+"|"+m+")":n.length?g:m,a,u-r,!0]};var _C=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var fd,tin=new Set(["!","?","+","*","@"]),q1e=e=>tin.has(e),uAt=e=>q1e(e.type),rin=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),nin=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),iin=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),dAt=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),oin="(?!(?:^|/)\\.\\.?(?:$|/))",XJ="(?!\\.)",sin=new Set(["[","."]),ain=new Set(["..","."]),lin=new Set("().*{}+?[]^$\\!"),cin=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),G1e="[^/]",fAt=G1e+"*?",pAt=G1e+"+?",uin=0,GT=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;id=++uin;get depth(){return(this.#o?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#o?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(t,r,n={}){this.type=t,t&&(this.#t=!0),this.#o=r,this.#e=this.#o?this.#o.#e:this,this.#a=this.#e===this?n:this.#e.#a,this.#l=this.#e===this?[]:this.#e.#l,t==="!"&&!this.#e.#s&&this.#l.push(this),this.#i=this.#o?this.#o.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let t of this.#r)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#d!==void 0?this.#d:this.type?this.#d=this.type+"("+this.#r.map(t=>String(t)).join("|")+")":this.#d=this.#r.map(t=>String(t)).join("")}#f(){if(this!==this.#e)throw new Error("should only call on root");if(this.#s)return this;this.toString(),this.#s=!0;let t;for(;t=this.#l.pop();){if(t.type!=="!")continue;let r=t,n=r.#o;for(;n;){for(let i=r.#i+1;!n.type&&i<n.#r.length;i++)for(let o of t.#r){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#r[i])}r=n,n=r.#o}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof fd&&r.#o===this))throw new Error("invalid part: "+r);this.#r.push(r)}}toJSON(){let t=this.type===null?this.#r.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#r.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#o?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#o?.isStart())return!1;if(this.#i===0)return!0;let t=this.#o;for(let r=0;r<this.#i;r++){let n=t.#r[r];if(!(n instanceof fd&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let t=this.#o?this.#o.#r.length:0;return this.#i===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new fd(this.type,t);for(let n of this.#r)r.copyIn(n);return r}static#c(t,r,n,i,o){let s=i.maxExtglobRecursion??2,a=!1,l=!1,c=-1,u=!1;if(r.type===null){let h=n,y="";for(;h<t.length;){let C=t.charAt(h++);if(a||C==="\\"){a=!a,y+=C;continue}if(l){h===c+1?(C==="^"||C==="!")&&(u=!0):C==="]"&&!(h===c+2&&u)&&(l=!1),y+=C;continue}else if(C==="["){l=!0,c=h,u=!1,y+=C;continue}if(!i.noext&&q1e(C)&&t.charAt(h)==="("&&o<=s){r.push(y),y="";let T=new fd(C,r);h=fd.#c(t,T,h,i,o+1),r.push(T);continue}y+=C}return r.push(y),h}let d=n+1,g=new fd(null,r),m=[],A="";for(;d<t.length;){let h=t.charAt(d++);if(a||h==="\\"){a=!a,A+=h;continue}if(l){d===c+1?(h==="^"||h==="!")&&(u=!0):h==="]"&&!(d===c+2&&u)&&(l=!1),A+=h;continue}else if(h==="["){l=!0,c=d,u=!1,A+=h;continue}if(!i.noext&&q1e(h)&&t.charAt(d)==="("&&(o<=s||r&&r.#E(h))){let C=r&&r.#E(h)?0:1;g.push(A),A="";let I=new fd(h,g);g.push(I),d=fd.#c(t,I,d,i,o+C);continue}if(h==="|"){g.push(A),A="",m.push(g),g=new fd(null,r);continue}if(h===")")return A===""&&r.#r.length===0&&(r.#p=!0),g.push(A),A="",r.push(...m,g),d;A+=h}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],d}#g(t){return this.#h(t,nin)}#h(t,r=rin){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null)return!1;let n=t.#r[0];return!n||typeof n!="object"||n.type===null?!1:this.#E(n.type,r)}#E(t,r=iin){return!!r.get(this.type)?.includes(t)}#A(t,r){let n=t.#r[0],i=new fd(null,n,this.options);i.#r.push(""),n.push(i),this.#v(t,r)}#v(t,r){let n=t.#r[0];this.#r.splice(r,1,...n.#r);for(let i of n.#r)typeof i=="object"&&(i.#o=this);this.#d=void 0}#y(t){return!!dAt.get(this.type)?.has(t)}#S(t){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let r=t.#r[0];return!r||typeof r!="object"||r.type===null?!1:this.#y(r.type)}#I(t){let r=dAt.get(this.type),n=t.#r[0],i=r?.get(n.type);if(!i)return!1;this.#r=n.#r;for(let o of this.#r)typeof o=="object"&&(o.#o=this);this.type=i,this.#d=void 0,this.#p=!1}static fromGlob(t,r={}){let n=new fd(null,void 0,r);return fd.#c(t,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,i,o]=this.toRegExpSource();if(!(i||this.#t||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#a}toRegExpSource(t){let r=t??!!this.#a.dot;if(this.#e===this&&(this.#_(),this.#f()),!uAt(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(m=>typeof m!="string"),c=this.#r.map(m=>{let[A,h,y,C]=typeof m=="string"?fd.#C(m,this.#t,l):m.toRegExpSource(t);return this.#t=this.#t||y,this.#n=this.#n||C,A}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&ain.has(this.#r[0]))){let A=sin,h=r&&A.has(c.charAt(0))||c.startsWith("\\.")&&A.has(c.charAt(2))||c.startsWith("\\.\\.")&&A.has(c.charAt(4)),y=!r&&!t&&A.has(c.charAt(0));u=h?oin:y?XJ:""}let d="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(d="(?:$|\\/)"),[u+c+d,_C(c),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#b(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString(),c=this;return c.#r=[l],c.type=null,c.#t=void 0,[l,_C(this.toString()),!1,!1]}let s=!n||t||r||!XJ?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?XJ:"")+pAt;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?XJ:"")+fAt+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,_C(o),this.#t=!!this.#t,this.#n]}#_(){if(uAt(this)){let t=0,r=!1;do{r=!0;for(let n=0;n<this.#r.length;n++){let i=this.#r[n];typeof i=="object"&&(i.#_(),this.#h(i)?(r=!1,this.#v(i,n)):this.#g(i)?(r=!1,this.#A(i,n)):this.#S(i)&&(r=!1,this.#I(i)))}}while(!r&&++t<10)}else for(let t of this.#r)typeof t=="object"&&t.#_();this.#d=void 0}#b(t){return this.#r.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,o,s]=r.toRegExpSource(t);return this.#n=this.#n||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#C(t,r,n=!1){let i=!1,o="",s=!1,a=!1;for(let l=0;l<t.length;l++){let c=t.charAt(l);if(i){i=!1,o+=(lin.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?pAt:fAt,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,d,g,m]=cAt(t,l);if(g){o+=u,s=s||d,l+=g-1,r=r||m;continue}}if(c==="?"){o+=G1e,r=!0;continue}o+=cin(c)}return[o,_C(t),!!r,s]}};fd=GT;var z1e=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var jl=(e,t,r={})=>(qU(t),!r.nocomment&&t.charAt(0)==="#"?!1:new zB(t,r).match(e)),din=/^\*+([^+@!?*[(]*)$/,fin=e=>t=>!t.startsWith(".")&&t.endsWith(e),pin=e=>t=>t.endsWith(e),min=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),gin=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Ain=/^\*+\.\*+$/,hin=e=>!e.startsWith(".")&&e.includes("."),Ein=e=>e!=="."&&e!==".."&&e.includes("."),_in=/^\.\*+$/,yin=e=>e!=="."&&e!==".."&&e.startsWith("."),bin=/^\*+$/,Cin=e=>e.length!==0&&!e.startsWith("."),Sin=e=>e.length!==0&&e!=="."&&e!=="..",Iin=/^\?+([^+@!?*[(]*)?$/,Tin=([e,t=""])=>{let r=AAt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},vin=([e,t=""])=>{let r=hAt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},xin=([e,t=""])=>{let r=hAt([e]);return t?n=>r(n)&&n.endsWith(t):r},win=([e,t=""])=>{let r=AAt([e]);return t?n=>r(n)&&n.endsWith(t):r},AAt=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},hAt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},EAt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",mAt={win32:{sep:"\\"},posix:{sep:"/"}},Din=EAt==="win32"?mAt.win32.sep:mAt.posix.sep;jl.sep=Din;var vc=Symbol("globstar **");jl.GLOBSTAR=vc;var Rin="[^/]",Nin=Rin+"*?",Bin="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Oin="(?:(?!(?:\\/|^)\\.).)*?",kin=(e,t={})=>r=>jl(r,e,t);jl.filter=kin;var zp=(e,t={})=>Object.assign({},e,t),Min=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return jl;let t=jl;return Object.assign((n,i,o={})=>t(n,i,zp(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,zp(e,o))}static defaults(i){return t.defaults(zp(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,zp(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,zp(e,o))}},unescape:(n,i={})=>t.unescape(n,zp(e,i)),escape:(n,i={})=>t.escape(n,zp(e,i)),filter:(n,i={})=>t.filter(n,zp(e,i)),defaults:n=>t.defaults(zp(e,n)),makeRe:(n,i={})=>t.makeRe(n,zp(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,zp(e,i)),match:(n,i,o={})=>t.match(n,i,zp(e,o)),sep:t.sep,GLOBSTAR:vc})};jl.defaults=Min;var _At=(e,t={})=>(qU(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:aAt(e,{max:t.braceExpandMax}));jl.braceExpand=_At;var Qin=(e,t={})=>new zB(e,t).makeRe();jl.makeRe=Qin;var Pin=(e,t,r={})=>{let n=new zB(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};jl.match=Pin;var gAt=/[?*]|[+@!]\(.*?\)|\[|\]/,Lin=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),zB=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){qU(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||EAt,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.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 t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((o,s,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=o[0]===""&&o[1]===""&&(o[2]==="?"||!gAt.test(o[2]))&&!gAt.test(o[3]),c=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(c)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let s=this.set[o];s[0]===""&&s[1]===""&&this.globParts[o][2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3])&&(s[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n of t)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let o=n[n.length-1];return i==="**"&&o==="**"?n:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let o=t[i];i===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let s=i;for(;n[s+1]==="**";)s++;s>i&&n.splice(i+1,s-i);let a=n[i+1],l=n[i+2],c=n[i+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let s=1;s<n.length-1;s++){let a=n[s];s===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(s,1),s--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let s=n[o-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let l=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...l),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(i){t[r]=[],t[n]=i;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,o=0,s=[],a="";for(;i<t.length&&o<r.length;)if(t[i]===r[o])s.push(a==="b"?r[o]:t[i]),i++,o++;else if(n&&t[i]==="**"&&r[o]===t[i+1])s.push(t[i]),i++;else if(n&&r[o]==="**"&&t[i]===r[o+1])s.push(r[o]),o++;else if(t[i]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",s.push(t[i]),i++,o++}else if(r[o]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",s.push(r[o]),i++,o++}else return!1;return t.length===r.length&&s}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=0,o=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),l=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),c=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),u=!c&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),d=l?3:a?0:void 0,g=u?3:c?0:void 0;if(typeof d=="number"&&typeof g=="number"){let[m,A]=[t[d],r[g]];m.toLowerCase()===A.toLowerCase()&&(r[g]=m,o=g,i=d)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(vc)?this.#e(t,r,n,i,o):this.#n(t,r,n,i,o)}#e(t,r,n,i,o){let s=r.indexOf(vc,o),a=r.lastIndexOf(vc),[l,c,u]=n?[r.slice(o,s),r.slice(s+1),[]]:[r.slice(o,s),r.slice(s+1,a),r.slice(a+1)];if(l.length){let I=t.slice(i,i+l.length);if(!this.#n(I,l,n,0,0))return!1;i+=l.length,o+=l.length}let d=0;if(u.length){if(u.length+i>t.length)return!1;let I=t.length-u.length;if(this.#n(t,u,n,I,0))d=u.length;else{if(t[t.length-1]!==""||i+u.length===t.length||(I--,!this.#n(t,u,n,I,0)))return!1;d=u.length+1}}if(!c.length){let I=!!d;for(let T=i;T<t.length-d;T++){let D=String(t[T]);if(I=!0,D==="."||D===".."||!this.options.dot&&D.startsWith("."))return!1}return n||I}let g=[[[],0]],m=g[0],A=0,h=[0];for(let I of c)I===vc?(h.push(A),m=[[],0],g.push(m)):(m[0].push(I),A++);let y=g.length-1,C=t.length-d;for(let I of g)I[1]=C-(h[y--]+I[0].length);return!!this.#t(t,g,i,0,n,0,!!d)}#t(t,r,n,i,o,s,a){let l=r[i];if(!l){for(let d=n;d<t.length;d++){a=!0;let g=t[d];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(t.slice(0,n+c.length),c,o,n,0)&&s<this.maxGlobstarRecursion){let m=this.#t(t,r,n+c.length,i+1,o,s+1,a);if(m!==!1)return m}let g=t[n];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1;n++}return o||null}#n(t,r,n,i,o){let s,a,l,c;for(s=i,a=o,c=t.length,l=r.length;s<c&&a<l;s++,a++){this.debug("matchOne loop");let u=r[a],d=t[s];if(this.debug(r,u,d),u===!1||u===vc)return!1;let g;if(typeof u=="string"?(g=d===u,this.debug("string match",u,d,g)):(g=u.test(d),this.debug("pattern match",u,d,g)),!g)return!1}if(s===c&&a===l)return!0;if(s===c)return n;if(a===l)return s===c-1&&t[s]==="";throw new Error("wtf?")}braceExpand(){return _At(this.pattern,this.options)}parse(t){qU(t);let r=this.options;if(t==="**")return vc;if(t==="")return"";let n,i=null;(n=t.match(bin))?i=r.dot?Sin:Cin:(n=t.match(din))?i=(r.nocase?r.dot?gin:min:r.dot?pin:fin)(n[1]):(n=t.match(Iin))?i=(r.nocase?r.dot?vin:Tin:r.dot?xin:win)(n):(n=t.match(Ain))?i=r.dot?Ein:hin:(n=t.match(_in))&&(i=yin);let o=GT.fromGlob(t,this.options).toMMPattern();return i&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:i}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?Nin:r.dot?Bin:Oin,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(d=>{if(d instanceof RegExp)for(let g of d.flags.split(""))i.add(g);return typeof d=="string"?Lin(d):d===vc?vc:d._src});c.forEach((d,g)=>{let m=c[g+1],A=c[g-1];d!==vc||A===vc||(A===void 0?m!==void 0&&m!==vc?c[g+1]="(?:\\/|"+n+"\\/)?"+m:c[g]=n:m===void 0?c[g-1]=A+"(?:\\/|\\/"+n+")?":m!==vc&&(c[g-1]=A+"(?:\\/|\\/"+n+"\\/)"+m,c[g+1]=vc))});let u=c.filter(d=>d!==vc);if(this.partial&&u.length>=1){let d=[];for(let g=1;g<=u.length;g++)d.push(u.slice(0,g).join("/"));return"(?:"+d.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];o="^"+s+o+a+"$",this.partial&&(o="^(?:\\/|"+s+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let s=i[i.length-1];if(!s)for(let a=i.length-2;!s&&a>=0;a--)s=i[a];for(let a of o){let l=i;if(n.matchBase&&a.length===1&&(l=[s]),this.matchOne(l,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return jl.defaults(t).Minimatch}};jl.AST=GT;jl.Minimatch=zB;jl.escape=z1e;jl.unescape=_C;var CAt=Re($U(),1);Ar();He();Oe();Xc();import{readFile as yAt}from"fs/promises";import{existsSync as j1e,readdirSync as Fin,statSync as Uin}from"fs";import{join as Y1e,relative as SAt}from"path";import{homedir as $in}from"os";function bAt(e){try{let t=(0,CAt.default)(e),r=t.data.paths,n=[];return typeof r=="string"?n=r.split(",").map(i=>i.trim()).filter(Boolean):Array.isArray(r)&&(n=r.filter(i=>typeof i=="string")),{paths:n,content:t.content.trim()}}catch(t){return ve(t),{paths:[],content:e.trim()}}}function Hin(e,t){return t.length===0?!0:t.some(r=>{try{return jl(e,r,{matchBase:!0,dot:!0})}catch(n){return ve(n),!1}})}function V1e(e){let t=[];try{if(!j1e(e))return t;let r=Fin(e);for(let n of r){let i=Y1e(e,n),o=Uin(i);o.isDirectory()?t.push(...V1e(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){ve(r)}return t}async function eZ(){let e=[];try{let t=Y1e($in(),Jr,"rules");if(j1e(t)){let r=V1e(t);for(let n of r)try{let i=await yAt(n,"utf-8"),{paths:o,content:s}=bAt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){ve(i)}}}catch(t){ve(t)}try{let t=Y1e(Be(),Jr,"rules");if(j1e(t)){let r=V1e(t);for(let n of r)try{let i=await yAt(n,"utf-8"),{paths:o,content:s}=bAt(i);o.length>0&&e.push({filePath:SAt(Be(),n),content:s,paths:o,isProjectRule:!0})}catch(i){ve(i)}}}catch(t){ve(t)}return e}function IAt(e,t){e=yY(e);let r=yY(Be()),n=e.startsWith(r)?SAt(r,e):e;return t.filter(i=>Hin(n,i.paths))}function TAt(e){return e.length===0?"":e.map(r=>{let n=r.isProjectRule?"project instructions, checked into the codebase":"user's private global instructions for all projects";return`Contents of ${r.filePath} (${n}):
|
|
627
627
|
|
|
628
628
|
${r.content}`}).join(`
|
|
629
629
|
|
|
@@ -818,7 +818,7 @@ try {
|
|
|
818
818
|
`],{encoding:"utf8",maxBuffer:XEt,stdio:["ignore","pipe","ignore"]}).trim()||null}catch{return null}}function uln(){try{let e=C5("where",["pwsh.exe"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim().split(/\r?\n/)[0];if(e)return e}catch{}return"powershell.exe"}var dln="[Image pasted]";function n0t(e){return function(t){return(new Map(e).get(t)??(()=>{}))(t)}}function o0t({value:e,onChange:t,onSubmit:r,onExit:n,onExitMessage:i,onMessage:o,onHistoryUp:s,onHistoryDown:a,onHistoryReset:l,onCancel:c,onEscape:u,mask:d="",multiline:g=!1,cursorChar:m,invert:A,columns:h,onImagePaste:y,disableCursorMovementForUpDownKeys:C=!1,externalOffset:I,onOffsetChange:T}){let D=I,N=T,M=b5.fromText(e,h,D),[z,j]=(0,i0t.useState)(null);function L(){z&&(clearTimeout(z),j(null),o?.(!1))}let V=sv(Z=>{L(),i?.(Z,"Ctrl-C")},()=>n?.(),()=>{e&&(t(""),l?.())}),G=sv(Z=>{if(u&&!e){u();return}if(c){L(),o?.(!!e&&Z,"Press Escape again to cancel");return}L(),o?.(!!e&&Z,"Press Escape again to clear")},()=>{if(!(u&&!e)){if(c){c();return}e&&t("")}});function ae(){return b5.fromText("",h,0)}let ee=sv(Z=>i?.(Z,"Ctrl-D"),()=>n?.());function P(){return L(),M.text===""?(ee(),M):M.del()}function le(){if(d)return M;let Z=r0t();return Z===null?(t0t()&&(o?.(!0,e0t),L(),j(setTimeout(()=>{o?.(!1)},4e3))),M):(y?.(Z),M.insert(dln))}let Ee=n0t([["a",()=>M.startOfLine()],["b",()=>M.left()],["c",V],["d",P],["e",()=>M.endOfLine()],["f",()=>M.right()],["h",()=>(L(),M.backspace())],["k",()=>M.deleteToLineEnd()],["l",()=>ae()],["n",()=>se()],["p",()=>oe()],["u",()=>M.deleteToLineStart()],["v",le],["w",()=>M.deleteWordBefore()],["o",le]]),Se=n0t([["b",()=>M.prevWord()],["f",()=>M.nextWord()],["d",()=>M.deleteWordAfter()]]);function de(Z){if(g&&M.offset>0&&M.text[M.offset-1]==="\\")return M.backspace().insert(`
|
|
819
819
|
`);if(Z.meta||Z.shift)return M.insert(`
|
|
820
820
|
`);r?.(e)}function oe(){if(C)return s?.(),M;let Z=M.up();return Z.equals(M)&&s?.(),Z}function se(){if(C)return a?.(),M;let Z=M.down();return Z.equals(M)&&a?.(),Z}function _e(Z,W){if(W.tab)return;if(W.backspace||W.delete||Z==="\b"||Z==="\x7F"||Z==="\b"){let nt=M.backspace();M.equals(nt)||(N(nt.offset),M.text!==nt.text&&t(nt.text));return}if(!W.ctrl&&!W.meta&&Z.length>1){let nt=M.insert(Z);M.equals(nt)||(N(nt.offset),M.text!==nt.text&&t(nt.text));return}let Ne=je(W)(Z);Ne&&(M.equals(Ne)||(N(Ne.offset),M.text!==Ne.text&&t(Ne.text)))}function je(Z){if(Z.backspace||Z.delete)return L(),()=>M.backspace();switch(!0){case Z.escape:return u&&!e?()=>(u(),M):G;case(Z.leftArrow&&(Z.ctrl||Z.meta||"fn"in Z&&Z.fn)):return()=>M.prevWord();case(Z.rightArrow&&(Z.ctrl||Z.meta||"fn"in Z&&Z.fn)):return()=>M.nextWord();case Z.ctrl:return Ee;case("home"in Z&&Z.home):return()=>M.startOfLine();case("end"in Z&&Z.end):return()=>M.endOfLine();case Z.pageDown:return()=>M.endOfLine();case Z.pageUp:return()=>M.startOfLine();case Z.return:return()=>de(Z);case Z.meta:return Se;case Z.upArrow:return oe;case Z.downArrow:return se;case Z.leftArrow:return()=>M.left();case Z.rightArrow:return()=>M.right()}return function(W){switch(!0){case(W=="\x1B[H"||W=="\x1B[1~"):return M.startOfLine();case(W=="\x1B[F"||W=="\x1B[4~"):return M.endOfLine();case(W==="\b"||W==="\x7F"||W==="\b"):return L(),M.backspace();default:return M.insert(W.replace(/\r/g,`
|
|
821
|
-
`))}}}return{onInput:_e,renderedValue:M.render(m,d,A),offset:D,setOffset:N}}function S5({value:e,placeholder:t="",focus:r=!0,mask:n,multiline:i=!1,highlightPastedText:o=!1,showCursor:s=!0,onChange:a,onSubmit:l,onExit:c,onHistoryUp:u,onHistoryDown:d,onExitMessage:g,onMessage:m,onHistoryReset:A,onCancel:h,onEscape:y,columns:C,onImagePaste:I,onPaste:T,isDimmed:D=!1,disableCursorMovementForUpDownKeys:N=!1,cursorOffset:M,onChangeCursorOffset:z}){let{onInput:j,renderedValue:L}=o0t({value:e,onChange:a,onSubmit:l,onExit:c,onExitMessage:g,onMessage:m,onHistoryReset:A,onHistoryUp:u,onHistoryDown:d,onCancel:h,onEscape:y,focus:r,mask:n,multiline:i,cursorChar:s?" ":"",highlightPastedText:o,invert:Se=>Jt.bgHex("#ffffff").hex("#000000")(Se),themeText:Se=>Jt.hex(Me().text)(Se),columns:C,onImagePaste:I,disableCursorMovementForUpDownKeys:N,externalOffset:M,onOffsetChange:z}),[V,G]=s0t.default.useState({chunks:[],timeoutId:null}),ae=Se=>(Se&&clearTimeout(Se),setTimeout(()=>{G(({chunks:de})=>{let oe=de.join("");return Promise.resolve().then(()=>T(oe)),{chunks:[],timeoutId:null}})},100));or((Se,de)=>{if(T&&(Se.length>10||V.timeoutId)){G(({chunks:oe,timeoutId:se})=>({chunks:[...oe,Se],timeoutId:ae(se)}));return}j(Se,de)},{isActive:r});let P=t?Jt.hex(Me().secondaryText)(t):void 0,le=Se=>Jt.bgHex("#ffffff").hex("#000000")(Se);s&&r&&(P=t.length>0?le(t[0])+Jt.hex(Me().secondaryText)(t.slice(1)):le(" "));let Ee=e.length==0&&t;return(0,_.jsx)(x,{wrap:"truncate-end",dimColor:D,children:Ee?P:L})}var fln=["General","Context"];function a0t({onClose:e}){let[t,r]=(0,Mo.useState)(ri()),n=Kl.useRef(ri()),[i,o]=(0,Mo.useState)(0),[s,a]=(0,Mo.useState)("General"),l=md(()=>process.exit(0)),[c,u]=(0,Mo.useState)(tt().webServer?.enabled??!1),[d,g]=(0,Mo.useState)(tt().proxy??!1),m=Kl.useRef(tt().proxy??!1),[A,h]=(0,Mo.useState)(Ue.getLazyToolMode()),y=Kl.useRef(Ue.getLazyToolMode()),[C,I]=(0,Mo.useState)(Ue.getProxyToolSchemaFormat()),T=Kl.useRef(Ue.getProxyToolSchemaFormat()),[D,N]=(0,Mo.useState)(tt().autoMode?.enabled??!0),M=Kl.useRef(tt().autoMode?.enabled??!0),[z,j]=(0,Mo.useState)(tt().memo??!1),L=Kl.useRef(tt().memo??!1),[V,G]=(0,Mo.useState)(tt().headlessBrowser??!1),[ae,ee]=(0,Mo.useState)("not_installed"),[P,le]=(0,Mo.useState)(tt().showWindowTokens??!1),Ee=Kl.useRef(tt().showWindowTokens??!1),[Se,de]=(0,Mo.useState)(tt().messageArchiving??!1),oe=Kl.useRef(tt().messageArchiving??!1),[se,_e]=(0,Mo.useState)(tt().archiveToolUseInputs??!1),je=Kl.useRef(tt().archiveToolUseInputs??!1),[Z,W]=(0,Mo.useState)(tt().archiveThinking??!1),Ne=Kl.useRef(tt().archiveThinking??!1),[nt,Je]=(0,Mo.useState)(tt().planDirectory??""),Ve=Kl.useRef(tt().planDirectory??""),[Ze,xt]=(0,Mo.useState)(String(tt().agentDepth??1)),Dr=Kl.useRef(String(tt().agentDepth??1)),[Pr,uo]=(0,Mo.useState)(String(Ue.getCodemodeMethodsMax())),an=Kl.useRef(String(Ue.getCodemodeMethodsMax())),[yn,mn]=(0,Mo.useState)(tt().codemodeSession??!1),fo=Kl.useRef(tt().codemodeSession??!1),[Mi,po]=(0,Mo.useState)(tt().disableSuggestion??!1),Wi=Kl.useRef(tt().disableSuggestion??!1),[Ki,kt]=(0,Mo.useState)(tt().plugins?.pluginClaudeCompat??!1),Mr=Kl.useRef(tt().plugins?.pluginClaudeCompat??!1),[pi,qr]=(0,Mo.useState)(null),[Co,Ji]=(0,Mo.useState)(""),[Zi,_s]=(0,Mo.useState)(0),bt=[...process.env.ANTHROPIC_API_KEY?[{id:"apiKey",label:`Use custom API key: ${Jt.bold(kb(process.env.ANTHROPIC_API_KEY))}`,value:!!(process.env.ANTHROPIC_API_KEY&&t.customApiKeyResponses?.approved?.includes(kb(process.env.ANTHROPIC_API_KEY))),type:"boolean",onChange(ye){let ge={...ri()};if(ge.customApiKeyResponses||(ge.customApiKeyResponses={approved:[],rejected:[]}),ge.customApiKeyResponses.approved||(ge.customApiKeyResponses.approved=[]),ge.customApiKeyResponses.rejected||(ge.customApiKeyResponses.rejected=[]),process.env.ANTHROPIC_API_KEY){let Ye=kb(process.env.ANTHROPIC_API_KEY);ye?(ge.customApiKeyResponses.approved=[...ge.customApiKeyResponses.approved.filter(Ke=>Ke!==Ye),Ye],ge.customApiKeyResponses.rejected=ge.customApiKeyResponses.rejected.filter(Ke=>Ke!==Ye)):(ge.customApiKeyResponses.approved=ge.customApiKeyResponses.approved.filter(Ke=>Ke!==Ye),ge.customApiKeyResponses.rejected=[...ge.customApiKeyResponses.rejected.filter(Ke=>Ke!==Ye),Ye])}ua(ge),r(ge)}}]:[],{id:"verbose",label:"Verbose output",value:t.verbose,type:"boolean",onChange(ye){let ge={...ri(),verbose:ye};ua(ge),r(ge)}},{id:"theme",label:"Theme",value:t.theme,options:["light","dark","light-daltonized","dark-daltonized"],type:"enum",onChange(ye){let ge={...ri(),theme:ye};ua(ge),r(ge)}},{id:"notifChannel",label:"Notifications",value:t.preferredNotifChannel,options:["iterm2","terminal_bell","iterm2_with_bell","notifications_disabled"],type:"enum",onChange(ye){let ge={...ri(),preferredNotifChannel:ye};ua(ge),r(ge)}},{id:"webServer",label:"Web Server",value:c?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";u(ge);let Ye=tt(),Ke={...Ye.webServer,enabled:ge,port:Ye.webServer?.port||3210,host:Ye.webServer?.host||"127.0.0.1"};yr.updateSetting("webServer",Ke),ge?E5.start().catch(()=>{}):E5.stop().catch(()=>{})}},{id:"proxy",label:"Proxy",tab:"Context",value:d?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";g(ge),yr.updateSetting("proxy",ge),_r.emit("proxy:changed")}},{id:"lazyTool",label:"Lazy Tool",tab:"Context",value:A,options:["off","loading","proxy"],type:"enum",onChange(ye){let ge=ye;h(ge),yr.updateSetting("lazyTool",ge)}},{id:"proxyToolSchemaFormat",label:"Proxy Tool Schema Format",tab:"Context",value:C,options:["ts","json","xml"],type:"enum",onChange(ye){let ge=ye==="ts"?"ts":ye==="xml"?"xml":"json";I(ge),yr.updateSetting("proxyToolSchemaFormat",ge)}},{id:"autoMode",label:"Auto Mode",value:D?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";N(ge);let Ke={...tt().autoMode,enabled:ge};yr.updateSetting("autoMode",Ke)}},{id:"memo",label:"Memo",tab:"Context",value:z?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";j(ge),yr.updateSetting("memo",ge)}},{id:"headlessBrowser",label:"Headless Browser (JS pages)",value:V?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";G(ge),yr.updateSetting("headlessBrowser",ge),ge?(ee("installing"),dv().then(Ye=>{ee(Ye?"installed":"failed")})):ee("not_installed")}},{id:"showWindowTokens",label:"Window tokens usage",value:P?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";le(ge),yr.updateSetting("showWindowTokens",ge)}},{id:"messageArchiving",label:"Message Archiving",tab:"Context",value:Se?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";de(ge),yr.updateSetting("messageArchiving",ge)}},{id:"archiveToolUseInputs",label:"Archive Tool Use Inputs",tab:"Context",value:se?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";_e(ge),yr.updateSetting("archiveToolUseInputs",ge)}},{id:"archiveThinking",label:"Archive Thinking",tab:"Context",value:Z?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";W(ge),yr.updateSetting("archiveThinking",ge)}},{id:"pluginClaudeCompat",label:"Claude Code plugin compatibility",value:Ki?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";kt(ge);let Ke={...tt().plugins,pluginClaudeCompat:ge};yr.updateSetting("plugins",Ke)}},{id:"planDirectory",label:"Plan directory",value:nt,placeholder:"Leave empty for default",type:"string",onChange(ye){Je(ye),yr.updateSetting("planDirectory",ye||void 0)}},{id:"agentDepth",label:"Agent depth",value:Ze,placeholder:"1-5",type:"string",onChange(ye){let ge=parseInt(ye,10),Ye=Number.isNaN(ge)?1:Math.min(5,Math.max(1,ge)),Ke=String(Ye);xt(Ke),yr.updateSetting("agentDepth",Ye)}},{id:"codemodeMethodsMax",label:"Codemode methods max",value:Pr,placeholder:"1-100",type:"string",onChange(ye){let ge=parseInt(ye,10),Ye=Number.isNaN(ge)?20:Math.min(100,Math.max(1,ge)),Ke=String(Ye);uo(Ke),yr.updateSetting("codemodeMethodsMax",Ye)}},{id:"codemodeSession",label:"Codemode Session Storage",value:yn?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";mn(ge),yr.updateSetting("codemodeSession",ge)}},{id:"disableSuggestion",label:"Suggestion",value:Mi?"off":"on",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="off";po(ge),yr.updateSetting("disableSuggestion",ge)}}],$e=bt.filter(ye=>(ye.tab??"General")===s);return or((ye,ge)=>{if(ge.escape){let Ke=[],Xn=!!(process.env.ANTHROPIC_API_KEY&&n.current.customApiKeyResponses?.approved?.includes(kb(process.env.ANTHROPIC_API_KEY))),So=!!(process.env.ANTHROPIC_API_KEY&&t.customApiKeyResponses?.approved?.includes(kb(process.env.ANTHROPIC_API_KEY)));Xn!==So&&Ke.push(` \u23BF ${So?"Enabled":"Disabled"} custom API key`),t.verbose!==n.current.verbose&&Ke.push(` \u23BF Set verbose to ${Jt.bold(t.verbose)}`),t.theme!==n.current.theme&&Ke.push(` \u23BF Set theme to ${Jt.bold(t.theme)}`),t.preferredNotifChannel!==n.current.preferredNotifChannel&&Ke.push(` \u23BF Set notifications to ${Jt.bold(t.preferredNotifChannel)}`),d!==m.current&&Ke.push(` \u23BF Set proxy to ${Jt.bold(d?"on":"off")}`),A!==y.current&&Ke.push(` \u23BF Set lazy tool to ${Jt.bold(A)}`),C!==T.current&&Ke.push(` \u23BF Set proxy tool schema format to ${Jt.bold(C)}`),D!==M.current&&Ke.push(` \u23BF Set auto mode to ${Jt.bold(D?"on":"off")}`),z!==L.current&&Ke.push(` \u23BF Set memo to ${Jt.bold(z?"on":"off")}`),V!==tt().headlessBrowser&&Ke.push(` \u23BF Set headless browser to ${Jt.bold(V?"on":"off")}`),P!==Ee.current&&Ke.push(` \u23BF Set window tokens usage to ${Jt.bold(P?"on":"off")}`),Se!==oe.current&&Ke.push(` \u23BF Set message archiving to ${Jt.bold(Se?"on":"off")}`),se!==je.current&&Ke.push(` \u23BF Set archive tool use inputs to ${Jt.bold(se?"on":"off")}`),Z!==Ne.current&&Ke.push(` \u23BF Set archive thinking to ${Jt.bold(Z?"on":"off")}`),Ki!==Mr.current&&Ke.push(` \u23BF Set Claude Code plugin compatibility to ${Jt.bold(Ki?"on":"off")}`),nt!==Ve.current&&Ke.push(` \u23BF Set plan directory to ${Jt.bold(nt||"default")}`),Ze!==Dr.current&&Ke.push(` \u23BF Set agent depth to ${Jt.bold(Ze)}`),Pr!==an.current&&Ke.push(` \u23BF Set codemode methods max to ${Jt.bold(Pr)}`),yn!==fo.current&&Ke.push(` \u23BF Set codemode session storage to ${Jt.bold(yn?"on":"off")}`),Mi!==Wi.current&&Ke.push(` \u23BF Set suggestion to ${Jt.bold(Mi?"off":"on")}`),Ke.length>0&&console.log(Jt.gray(Ke.join(`
|
|
821
|
+
`))}}}return{onInput:_e,renderedValue:M.render(m,d,A),offset:D,setOffset:N}}function S5({value:e,placeholder:t="",focus:r=!0,mask:n,multiline:i=!1,highlightPastedText:o=!1,showCursor:s=!0,onChange:a,onSubmit:l,onExit:c,onHistoryUp:u,onHistoryDown:d,onExitMessage:g,onMessage:m,onHistoryReset:A,onCancel:h,onEscape:y,columns:C,onImagePaste:I,onPaste:T,isDimmed:D=!1,disableCursorMovementForUpDownKeys:N=!1,cursorOffset:M,onChangeCursorOffset:z}){let{onInput:j,renderedValue:L}=o0t({value:e,onChange:a,onSubmit:l,onExit:c,onExitMessage:g,onMessage:m,onHistoryReset:A,onHistoryUp:u,onHistoryDown:d,onCancel:h,onEscape:y,focus:r,mask:n,multiline:i,cursorChar:s?" ":"",highlightPastedText:o,invert:Se=>Jt.bgHex("#ffffff").hex("#000000")(Se),themeText:Se=>Jt.hex(Me().text)(Se),columns:C,onImagePaste:I,disableCursorMovementForUpDownKeys:N,externalOffset:M,onOffsetChange:z}),[V,G]=s0t.default.useState({chunks:[],timeoutId:null}),ae=Se=>(Se&&clearTimeout(Se),setTimeout(()=>{G(({chunks:de})=>{let oe=de.join("");return Promise.resolve().then(()=>T(oe)),{chunks:[],timeoutId:null}})},100));or((Se,de)=>{if(T&&(Se.length>10||V.timeoutId)){G(({chunks:oe,timeoutId:se})=>({chunks:[...oe,Se],timeoutId:ae(se)}));return}j(Se,de)},{isActive:r});let P=t?Jt.hex(Me().secondaryText)(t):void 0,le=Se=>Jt.bgHex("#ffffff").hex("#000000")(Se);s&&r&&(P=t.length>0?le(t[0])+Jt.hex(Me().secondaryText)(t.slice(1)):le(" "));let Ee=e.length==0&&t;return(0,_.jsx)(x,{wrap:"truncate-end",dimColor:D,children:Ee?P:L})}var fln=["General","Context"];function a0t({onClose:e}){let[t,r]=(0,Mo.useState)(ri()),n=Kl.useRef(ri()),[i,o]=(0,Mo.useState)(0),[s,a]=(0,Mo.useState)("General"),l=md(()=>process.exit(0)),[c,u]=(0,Mo.useState)(tt().webServer?.enabled??!1),[d,g]=(0,Mo.useState)(tt().proxy??!1),m=Kl.useRef(tt().proxy??!1),[A,h]=(0,Mo.useState)(Ue.getLazyToolMode()),y=Kl.useRef(Ue.getLazyToolMode()),[C,I]=(0,Mo.useState)(Ue.getProxyToolSchemaFormat()),T=Kl.useRef(Ue.getProxyToolSchemaFormat()),[D,N]=(0,Mo.useState)(tt().autoMode?.enabled??!0),M=Kl.useRef(tt().autoMode?.enabled??!0),[z,j]=(0,Mo.useState)(tt().memo??!1),L=Kl.useRef(tt().memo??!1),[V,G]=(0,Mo.useState)(tt().headlessBrowser??!1),[ae,ee]=(0,Mo.useState)("not_installed"),[P,le]=(0,Mo.useState)(tt().showWindowTokens??!1),Ee=Kl.useRef(tt().showWindowTokens??!1),[Se,de]=(0,Mo.useState)(tt().messageArchiving??!1),oe=Kl.useRef(tt().messageArchiving??!1),[se,_e]=(0,Mo.useState)(tt().archiveToolUseInputs??!1),je=Kl.useRef(tt().archiveToolUseInputs??!1),[Z,W]=(0,Mo.useState)(tt().archiveThinking??!1),Ne=Kl.useRef(tt().archiveThinking??!1),[nt,Je]=(0,Mo.useState)(tt().planDirectory??""),Ve=Kl.useRef(tt().planDirectory??""),[Ze,xt]=(0,Mo.useState)(String(tt().agentDepth??1)),Dr=Kl.useRef(String(tt().agentDepth??1)),[Pr,uo]=(0,Mo.useState)(String(Ue.getCodemodeMethodsMax())),an=Kl.useRef(String(Ue.getCodemodeMethodsMax())),[yn,mn]=(0,Mo.useState)(tt().codemodeSession??!1),fo=Kl.useRef(tt().codemodeSession??!1),[Mi,po]=(0,Mo.useState)(tt().disableSuggestion??!1),Wi=Kl.useRef(tt().disableSuggestion??!1),[Ki,kt]=(0,Mo.useState)(tt().plugins?.pluginClaudeCompat??!1),Mr=Kl.useRef(tt().plugins?.pluginClaudeCompat??!1),[pi,qr]=(0,Mo.useState)(null),[Co,Ji]=(0,Mo.useState)(""),[Zi,_s]=(0,Mo.useState)(0),bt=[...process.env.ANTHROPIC_API_KEY?[{id:"apiKey",label:`Use custom API key: ${Jt.bold(kb(process.env.ANTHROPIC_API_KEY))}`,value:!!(process.env.ANTHROPIC_API_KEY&&t.customApiKeyResponses?.approved?.includes(kb(process.env.ANTHROPIC_API_KEY))),type:"boolean",onChange(ye){let ge={...ri()};if(ge.customApiKeyResponses||(ge.customApiKeyResponses={approved:[],rejected:[]}),ge.customApiKeyResponses.approved||(ge.customApiKeyResponses.approved=[]),ge.customApiKeyResponses.rejected||(ge.customApiKeyResponses.rejected=[]),process.env.ANTHROPIC_API_KEY){let Ye=kb(process.env.ANTHROPIC_API_KEY);ye?(ge.customApiKeyResponses.approved=[...ge.customApiKeyResponses.approved.filter(Ke=>Ke!==Ye),Ye],ge.customApiKeyResponses.rejected=ge.customApiKeyResponses.rejected.filter(Ke=>Ke!==Ye)):(ge.customApiKeyResponses.approved=ge.customApiKeyResponses.approved.filter(Ke=>Ke!==Ye),ge.customApiKeyResponses.rejected=[...ge.customApiKeyResponses.rejected.filter(Ke=>Ke!==Ye),Ye])}ua(ge),r(ge)}}]:[],{id:"verbose",label:"Verbose output",value:t.verbose,type:"boolean",onChange(ye){let ge={...ri(),verbose:ye};ua(ge),r(ge)}},{id:"theme",label:"Theme",value:t.theme,options:["light","dark","light-daltonized","dark-daltonized"],type:"enum",onChange(ye){let ge={...ri(),theme:ye};ua(ge),r(ge)}},{id:"notifChannel",label:"Notifications",value:t.preferredNotifChannel,options:["iterm2","terminal_bell","iterm2_with_bell","notifications_disabled"],type:"enum",onChange(ye){let ge={...ri(),preferredNotifChannel:ye};ua(ge),r(ge)}},{id:"webServer",label:"Web Server",value:c?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";u(ge);let Ye=tt(),Ke={...Ye.webServer,enabled:ge,port:Ye.webServer?.port||3210,host:Ye.webServer?.host||"127.0.0.1"};yr.updateSetting("webServer",Ke),ge?E5.start().catch(()=>{}):E5.stop().catch(()=>{})}},{id:"proxy",label:"Proxy",value:d?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";g(ge),yr.updateSetting("proxy",ge),_r.emit("proxy:changed")}},{id:"lazyTool",label:"Lazy Tool",tab:"Context",value:A,options:["off","loading","proxy"],type:"enum",onChange(ye){let ge=ye;h(ge),yr.updateSetting("lazyTool",ge)}},{id:"proxyToolSchemaFormat",label:"Proxy Tool Schema Format",tab:"Context",value:C,options:["ts","json","xml"],type:"enum",onChange(ye){let ge=ye==="ts"?"ts":ye==="xml"?"xml":"json";I(ge),yr.updateSetting("proxyToolSchemaFormat",ge)}},{id:"autoMode",label:"Auto Mode",value:D?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";N(ge);let Ke={...tt().autoMode,enabled:ge};yr.updateSetting("autoMode",Ke)}},{id:"headlessBrowser",label:"Headless Browser (JS pages)",value:V?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";G(ge),yr.updateSetting("headlessBrowser",ge),ge?(ee("installing"),dv().then(Ye=>{ee(Ye?"installed":"failed")})):ee("not_installed")}},{id:"showWindowTokens",label:"Window tokens usage",value:P?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";le(ge),yr.updateSetting("showWindowTokens",ge)}},{id:"messageArchiving",label:"Message Archiving",tab:"Context",value:Se?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";de(ge),yr.updateSetting("messageArchiving",ge)}},{id:"archiveToolUseInputs",label:"Archive Tool Use Inputs",tab:"Context",value:se?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";_e(ge),yr.updateSetting("archiveToolUseInputs",ge)}},{id:"archiveThinking",label:"Archive Thinking",tab:"Context",value:Z?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";W(ge),yr.updateSetting("archiveThinking",ge)}},{id:"pluginClaudeCompat",label:"Claude Code plugin compatibility",value:Ki?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";kt(ge);let Ke={...tt().plugins,pluginClaudeCompat:ge};yr.updateSetting("plugins",Ke)}},{id:"planDirectory",label:"Plan directory",value:nt,placeholder:"Leave empty for default",type:"string",onChange(ye){Je(ye),yr.updateSetting("planDirectory",ye||void 0)}},{id:"agentDepth",label:"Agent depth",value:Ze,placeholder:"1-5",type:"string",onChange(ye){let ge=parseInt(ye,10),Ye=Number.isNaN(ge)?1:Math.min(5,Math.max(1,ge)),Ke=String(Ye);xt(Ke),yr.updateSetting("agentDepth",Ye)}},{id:"codemodeMethodsMax",label:"Codemode methods max",value:Pr,placeholder:"1-100",type:"string",onChange(ye){let ge=parseInt(ye,10),Ye=Number.isNaN(ge)?20:Math.min(100,Math.max(1,ge)),Ke=String(Ye);uo(Ke),yr.updateSetting("codemodeMethodsMax",Ye)}},{id:"codemodeSession",label:"Codemode Session Storage",value:yn?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";mn(ge),yr.updateSetting("codemodeSession",ge)}},{id:"disableSuggestion",label:"Suggestion",value:Mi?"off":"on",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="off";po(ge),yr.updateSetting("disableSuggestion",ge)}},{id:"memo",label:"Memo",tab:"Context",value:z?"on":"off",options:["off","on"],type:"enum",onChange(ye){let ge=ye==="on";j(ge),yr.updateSetting("memo",ge)}}],$e=bt.filter(ye=>(ye.tab??"General")===s);return or((ye,ge)=>{if(ge.escape){let Ke=[],Xn=!!(process.env.ANTHROPIC_API_KEY&&n.current.customApiKeyResponses?.approved?.includes(kb(process.env.ANTHROPIC_API_KEY))),So=!!(process.env.ANTHROPIC_API_KEY&&t.customApiKeyResponses?.approved?.includes(kb(process.env.ANTHROPIC_API_KEY)));Xn!==So&&Ke.push(` \u23BF ${So?"Enabled":"Disabled"} custom API key`),t.verbose!==n.current.verbose&&Ke.push(` \u23BF Set verbose to ${Jt.bold(t.verbose)}`),t.theme!==n.current.theme&&Ke.push(` \u23BF Set theme to ${Jt.bold(t.theme)}`),t.preferredNotifChannel!==n.current.preferredNotifChannel&&Ke.push(` \u23BF Set notifications to ${Jt.bold(t.preferredNotifChannel)}`),d!==m.current&&Ke.push(` \u23BF Set proxy to ${Jt.bold(d?"on":"off")}`),A!==y.current&&Ke.push(` \u23BF Set lazy tool to ${Jt.bold(A)}`),C!==T.current&&Ke.push(` \u23BF Set proxy tool schema format to ${Jt.bold(C)}`),D!==M.current&&Ke.push(` \u23BF Set auto mode to ${Jt.bold(D?"on":"off")}`),z!==L.current&&Ke.push(` \u23BF Set memo to ${Jt.bold(z?"on":"off")}`),V!==tt().headlessBrowser&&Ke.push(` \u23BF Set headless browser to ${Jt.bold(V?"on":"off")}`),P!==Ee.current&&Ke.push(` \u23BF Set window tokens usage to ${Jt.bold(P?"on":"off")}`),Se!==oe.current&&Ke.push(` \u23BF Set message archiving to ${Jt.bold(Se?"on":"off")}`),se!==je.current&&Ke.push(` \u23BF Set archive tool use inputs to ${Jt.bold(se?"on":"off")}`),Z!==Ne.current&&Ke.push(` \u23BF Set archive thinking to ${Jt.bold(Z?"on":"off")}`),Ki!==Mr.current&&Ke.push(` \u23BF Set Claude Code plugin compatibility to ${Jt.bold(Ki?"on":"off")}`),nt!==Ve.current&&Ke.push(` \u23BF Set plan directory to ${Jt.bold(nt||"default")}`),Ze!==Dr.current&&Ke.push(` \u23BF Set agent depth to ${Jt.bold(Ze)}`),Pr!==an.current&&Ke.push(` \u23BF Set codemode methods max to ${Jt.bold(Pr)}`),yn!==fo.current&&Ke.push(` \u23BF Set codemode session storage to ${Jt.bold(yn?"on":"off")}`),Mi!==Wi.current&&Ke.push(` \u23BF Set suggestion to ${Jt.bold(Mi?"off":"on")}`),Ke.length>0&&console.log(Jt.gray(Ke.join(`
|
|
822
822
|
`))),e();return}function Ye(){let Ke=$e[i];if(!(!Ke||!Ke.onChange)){if(Ke.type==="boolean"){Ke.onChange(!Ke.value);return}if(Ke.type==="enum"){let So=(Ke.options.indexOf(Ke.value)+1)%Ke.options.length;Ke.onChange(Ke.options[So]);return}if(Ke.type==="string"){qr(Ke.id),Ji(Ke.value);return}}}if(ge.return||ye===" "){Ye();return}ge.upArrow&&o(Ke=>Math.max(0,Ke-1)),ge.downArrow&&o(Ke=>Math.min($e.length-1,Ke+1)),(ge.leftArrow||ge.rightArrow)&&(a(Ke=>Ke==="General"?"Context":"General"),o(0))},{isActive:pi===null}),(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(B,{flexDirection:"column",borderStyle:"round",borderColor:Me().secondaryBorder,paddingX:1,marginTop:1,children:[(0,_.jsxs)(B,{flexDirection:"column",minHeight:2,marginBottom:1,children:[(0,_.jsx)(x,{bold:!0,children:"Settings"}),(0,_.jsxs)(x,{dimColor:!0,children:["Configure ",Rt," preferences"]})]}),(0,_.jsx)(B,{gap:3,marginBottom:1,children:fln.map(ye=>(0,_.jsx)(x,{bold:ye===s,color:ye===s?"blue":void 0,children:ye===s?`[ ${ye} ]`:` ${ye} `},ye))}),$e.map((ye,ge)=>{let Ye=ge===i;return(0,_.jsxs)(B,{height:2,minHeight:2,children:[(0,_.jsx)(B,{width:44,children:(0,_.jsxs)(x,{color:Ye?"blue":void 0,children:[Ye?Zt.pointer:" "," ",ye.label]})}),(0,_.jsxs)(B,{children:[ye.type==="boolean"?(0,_.jsx)(x,{color:Ye?"blue":void 0,children:ye.value.toString()}):ye.type==="string"&&pi===ye.id?(0,_.jsx)(S5,{value:Co,onChange:Ji,onSubmit:Ke=>{let Xn=bt.find(So=>So.id===ye.id);Xn&&Xn.type==="string"&&Xn.onChange(Ke),qr(null),_s(0)},onCancel:()=>{qr(null),Ji(""),_s(0)},placeholder:ye.placeholder,columns:Math.max(20,process.stdout.columns-50),cursorOffset:Zi,onChangeCursorOffset:_s}):(0,_.jsxs)(x,{color:(ye.id==="webServer"||ye.id==="proxy"||ye.id==="autoMode"||ye.id==="memo"||ye.id==="headlessBrowser"||ye.id==="showWindowTokens"||ye.id==="messageArchiving"||ye.id==="archiveToolUseInputs"||ye.id==="archiveThinking"||ye.id==="codemodeSession"||ye.id==="pluginClaudeCompat"||ye.id==="disableSuggestion")&&ye.value==="on"||ye.id==="lazyTool"&&ye.value!=="off"?"green":Ye?"blue":void 0,children:[ye.id==="lazyTool"&&ye.value==="loading"?"load":ye.id==="headlessBrowser"&&ye.value==="on"&&ae==="installing"?"installing...":ye.id==="headlessBrowser"&&ye.value==="on"&&ae==="failed"?"on (install failed)":ye.value.toString(),ye.id==="webServer"&&ye.value==="on"?` (${E5.getUrl()})`:""]}),ye.id==="headlessBrowser"&&ye.value==="on"&&ae!=="installed"&&(0,_.jsx)(x,{dimColor:!0,children:" manual install: npx -y playwright-core@1.64.1 install chromium"})]})]},ye.id)})]}),(0,_.jsx)(B,{marginLeft:3,children:(0,_.jsx)(x,{dimColor:!0,children:l.pending?(0,_.jsxs)(_.Fragment,{children:["Press ",l.keyName," again to exit"]}):pi?(0,_.jsx)(_.Fragment,{children:"Enter to save \xB7 Esc to cancel"}):(0,_.jsx)(_.Fragment,{children:"\u2190/\u2192 switch tab \xB7 \u2191/\u2193 to select \xB7 Enter/Space to change \xB7 Esc to close"})})})]})}var pln={type:"local-jsx",name:"config",description:()=>"Open config panel",isEnabled:!0,isHidden:!1,async call(e){return(0,_.jsx)(a0t,{onClose:e})},userFacingName(){return"config"}},l0t=pln;function fv(e){return e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function c0t(e){let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let r=Math.floor(t/60),n=t%60;return`${r}m ${n.toFixed(0)}s`}function u0t(e){return`${e.toFixed(1)}%`}function d0t({costUSD:e,durationMs:t,apiDurationMs:r,inputTokens:n,outputTokens:i,cacheCreationTokens:o,cacheReadTokens:s,currentContextTokens:a,contextLimit:l,onDone:c}){let u=Me();or((A,h)=>{h.escape&&c()});let d=n+o+s,g=d>0?s/d*100:0,m=l>0?a/l*100:0;return(0,_.jsxs)(B,{flexDirection:"column",borderStyle:"round",paddingLeft:1,paddingRight:1,borderColor:u.secondaryBorder,children:[(0,_.jsx)(B,{marginBottom:1,flexDirection:"column",children:(0,_.jsx)(x,{bold:!0,children:"Session Cost & Usage"})}),(0,_.jsx)(B,{flexDirection:"column",marginBottom:1,children:(0,_.jsxs)(x,{children:[(0,_.jsx)(x,{dimColor:!0,children:"Cost: "}),(0,_.jsxs)(x,{children:["$",e.toFixed(4)]})]})}),(0,_.jsxs)(B,{flexDirection:"column",marginBottom:1,children:[(0,_.jsx)(x,{dimColor:!0,children:"Session Tokens"}),(0,_.jsxs)(B,{marginLeft:2,flexDirection:"column",children:[(0,_.jsxs)(x,{children:[(0,_.jsx)(x,{children:"Input: "}),(0,_.jsx)(x,{bold:!0,children:fv(d)}),(0,_.jsxs)(x,{dimColor:!0,children:[" (uncached: ",fv(n),")"]})]}),(0,_.jsxs)(x,{children:[(0,_.jsx)(x,{children:"Output: "}),(0,_.jsx)(x,{bold:!0,children:fv(i)})]})]})]}),(0,_.jsx)(B,{flexDirection:"column",marginBottom:1,children:(0,_.jsxs)(x,{children:[(0,_.jsx)(x,{dimColor:!0,children:"Context Window: "}),(0,_.jsx)(x,{bold:!0,children:u0t(m)}),(0,_.jsxs)(x,{dimColor:!0,children:[" (",fv(a)," / ",fv(l)," tokens)"]})]})}),(0,_.jsx)(B,{flexDirection:"column",marginBottom:1,children:(0,_.jsxs)(x,{children:[(0,_.jsx)(x,{dimColor:!0,children:"Cache Hit Rate: "}),(0,_.jsx)(x,{bold:!0,children:u0t(g)}),(0,_.jsxs)(x,{dimColor:!0,children:[" ","(read: ",fv(s),", creation:"," ",fv(o),")"]})]})}),(0,_.jsxs)(B,{flexDirection:"column",marginBottom:1,children:[(0,_.jsx)(x,{dimColor:!0,children:"Duration"}),(0,_.jsxs)(B,{marginLeft:2,flexDirection:"column",children:[(0,_.jsxs)(x,{children:[(0,_.jsx)(x,{children:"API: "}),(0,_.jsx)(x,{bold:!0,children:c0t(r)})]}),(0,_.jsxs)(x,{children:[(0,_.jsx)(x,{children:"Wall: "}),(0,_.jsx)(x,{bold:!0,children:c0t(t)})]})]})]}),(0,_.jsx)(B,{marginTop:1,children:(0,_.jsx)(x,{dimColor:!0,children:"Esc to close"})})]})}_Te();kA();Oe();Wt();Ci();Wd();gI();er();He();Oe();Wt();import{existsSync as m0t,mkdirSync as yln,readFileSync as bln,writeFileSync as Cln}from"fs";import{dirname as Sln,join as Iln}from"path";import{homedir as Tln}from"os";function Kp(e){if(!e)return 0;let t=e.match(/[\u2E80-\u2FDF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]|[\p{L}\p{N}]+(?:['’\-][\p{L}\p{N}]+)*/gu);return t?t.length:0}function p0t(e,t){if(!e||t<=0)return"";let r=/[\u2E80-\u2FDF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]|[\p{L}\p{N}]+(?:['’\-][\p{L}\p{N}]+)*/gu,n=0,i=0;for(let o of e.matchAll(r))if(n++,i=(o.index??0)+o[0].length,n>=t)break;return n===0?"":n<t?e:e.slice(0,i)+"..."}var Oa="__tool_result__",Jp="__thinking__",j0="__tool_input__",Ag="THK_",pu=100;function vln(){return Ue.isArchiveToolUseInputsEnable()}function STe(){return Ue.isArchiveThinkingEnable()}var xln=new Set(["Cwd",zm,Yd,aa,lR,Bl,Ol,mI,pG,mG,sR,Zy,Ome,kme]);function wln(e){return e.replace(/[^a-zA-Z0-9]/g,"-")}function Dln(e,t=process.cwd()){return Iln(Tln(),Jr,"projects",wln(t),"archive",`${e}.json`)}function Rln(e){m0t(e)||yln(e,{recursive:!0})}function Nln(e){let t={toolUseInputFields:new Map,thinkingUuids:new Set};if(!m0t(e))return t;try{let r=bln(e,"utf8");if(!r.trim())return t;let n=JSON.parse(r);if(typeof n!="object"||n===null||Array.isArray(n))return t;let i=new Map,o=new Set;for(let[s,a]of Object.entries(n)){if(!Array.isArray(a))continue;let l=a.filter(c=>typeof c=="string");if(l.length!==0){if(l.length===1&&l[0]===Jp){o.add(s);continue}i.set(s,new Set(l))}}return{toolUseInputFields:i,thinkingUuids:o}}catch(r){return ve(`Failed to read archive state from ${e}:`,r),t}}function Bln(e,t,r){Rln(Sln(e));try{let n={};for(let[i,o]of t)o.size>0&&(n[i]=[...o]);for(let i of r)n[i]=[Jp];Cln(e,JSON.stringify(n,null,2),"utf8")}catch(n){throw ve(`Failed to write archive state to ${e}:`,n),n}}function Oln(e){return`<system>Archived result [tool_use_id: ${e}]. Unarchive via MessageArchiving.</system>`}function kln(e,t){return`<system>Archived input field "${t}" [tool_use_id: ${e}]. Unarchive via MessageArchiving.</system>`}function Mln(e){let t=e.content;return typeof t=="string"?Kp(t):Array.isArray(t)?t.reduce((r,n)=>typeof n=="string"?r+Kp(n):typeof n=="object"&&n!==null&&"text"in n&&typeof n.text=="string"?r+Kp(n.text):r,0):0}function g0t(e){return Mln(e)<=pu}function Qln(e){return{type:"text",text:`<system>[tool_use_id: ${e}]</system>`}}function yTe(e){if(typeof e=="string")return Kp(e);if(typeof e!="object"||e===null)return 0;if(Array.isArray(e))return e.reduce((n,i)=>Math.max(n,yTe(i)),0);let t=Object.values(e),r=0;for(let n of t)r=Math.max(r,yTe(n));return r}function eX(e){return typeof e=="string"?Kp(e):typeof e=="number"||typeof e=="boolean"?Kp(String(e)):Array.isArray(e)?e.reduce((t,r)=>t+eX(r),0):typeof e=="object"&&e!==null?Object.values(e).reduce((t,r)=>t+eX(r),0):0}function A0t(e){if(typeof e!="object"||e===null)return[];let t=[],r=(n,i)=>{if(typeof n=="string"){let o=Kp(n);o>pu&&t.push({path:i,words:o});return}if(Array.isArray(n)){n.forEach((o,s)=>r(o,`${i}[${s}]`));return}if(typeof n=="object"&&n!==null)for(let[o,s]of Object.entries(n)){let a=i===""?o:`${i}.${o}`;r(s,a)}};return r(e,""),t.sort((n,i)=>i.words-n.words).map(n=>n.path)}function bTe(e){return yTe(e)<=pu}function ITe(e){let t=new Map;for(let r of e){if(r.type!=="assistant")continue;let n=r.message.content;if(Array.isArray(n))for(let i of n)vTe(i)&&t.set(i.id,i.input)}return t}function Pln(e){let t=new Map;for(let r of e){if(r.type!=="assistant")continue;let n=r.message.content;if(Array.isArray(n)){for(let i of n)if(typeof i=="object"&&i!==null&&"type"in i&&i.type==="tool_use"&&"id"in i&&typeof i.id=="string"&&"name"in i&&typeof i.name=="string"){let o=i;t.set(o.id,o.name)}}}return t}function TTe(e){return xln.has(e)}function Lln(e,t){let r=t.get(e.tool_use_id);return r?TTe(r):!1}function h0t(e,t){let r;for(let s of t)if(s.type==="assistant"&&s.uuid===e){r=s;break}if(!r)return{archivable:!1,reason:"thinking block not found"};let n=r.message.content;if(!Array.isArray(n))return{archivable:!1,reason:"message has no thinking block"};let i=0,o=!1;for(let s of n)typeof s=="object"&&s!==null&&"type"in s&&s.type==="thinking"&&"thinking"in s&&typeof s.thinking=="string"?(o=!0,i+=Kp(s.thinking)):typeof s=="object"&&s!==null&&"type"in s&&s.type==="redacted_thinking"&&"data"in s&&typeof s.data=="string"&&(o=!0,i+=Kp(s.data));return o?i<=pu?{archivable:!1,reason:`thinking block is ${i} words, which is ${pu} words or fewer`}:STe()?{archivable:!0}:{archivable:!1,reason:"thinking archiving is disabled (enable by setting archiveThinking to true)"}:{archivable:!1,reason:"message has no thinking block"}}function Fln(e){let t=e.message.content;if(!Array.isArray(t))return 0;let r=0;for(let n of t)typeof n=="object"&&n!==null&&"type"in n&&n.type==="thinking"&&"thinking"in n&&typeof n.thinking=="string"?r+=Kp(n.thinking):typeof n=="object"&&n!==null&&"type"in n&&n.type==="redacted_thinking"&&"data"in n&&typeof n.data=="string"&&(r+=Kp(n.data));return r}function Uln(e){return typeof e=="object"&&e!==null&&"type"in e&&(e.type==="thinking"||e.type==="redacted_thinking")}function $ln(e){return{type:"text",text:`<system>[thinking_id: ${Ag}${e}]</system>`}}function Hln(e){return`<system-thinking>Archived thinking [thinking_id: ${Ag}${e}]. Unarchive via MessageArchiving.</system-thinking>`}function E0t(e,t){let r,n;for(let s of t){if(s.type!=="assistant")continue;let a=s.message.content;if(Array.isArray(a)){for(let l of a)if(vTe(l)&&l.id===e){r=l.input,n=l.name;break}if(n!==void 0)break}}if(!n)return{archivable:!1,reason:"no matching tool_use block found in the conversation history"};if(TTe(n))return{archivable:!1,reason:`tool "${n}" is blacklisted from archiving`};let i=!1,o=!1;for(let s of t){if(s.type!=="user")continue;let a=s.message.content;if(Array.isArray(a))for(let l of a)_0t(l)&&l.tool_use_id===e&&(i=!0,g0t(l)||(o=!0))}return i?o||!bTe(r)?{archivable:!0}:{archivable:!1,reason:`tool result and tool_use input are both ${pu} words or fewer`}:bTe(r)?{archivable:!1,reason:`tool_use input is ${pu} words or fewer`}:{archivable:!0}}function qln(e,t,r,n){let i=e.tool_use_id;if(Lln(e,r))return e;let o=n.get(i);if(g0t(e)&&bTe(o))return e;if(t.get(i)?.has(Oa)??!1)return{...e,content:[{type:"text",text:Oln(i)}]};let l;typeof e.content=="string"?l=[{type:"text",text:e.content}]:l=[...e.content];let c=Array.isArray(l)?l:[{type:"text",text:l}];return c.push(Qln(i)),{...e,content:c}}function _0t(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="tool_result"&&"tool_use_id"in e&&typeof e.tool_use_id=="string"}function vTe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="tool_use"&&"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string"}function Gln(e,t,r,n){let i=e.message.content;if(!Array.isArray(i))return e;let o=i.map(s=>_0t(s)?qln(s,t,r,n):s);return{...e,message:{...e.message,content:o}}}function zln(e,t,r,n){let i=e.message.content;if(!Array.isArray(i))return e;let o=STe(),s=vln();if(!o&&!s)return e;let a=e.uuid,l=o&&r.has(a),c=!1,u=[];for(let d of i){if(Uln(d)){if(!o){u.push(d);continue}if(l){c=!0;continue}u.push(d);continue}if(vTe(d)){if(!s){u.push(d);continue}let g=d.id,m=n.get(g)??d.name;if(TTe(m)){u.push(d);continue}let A=t.get(g);if(!A){u.push(d);continue}let h=[...A].filter(C=>C!==Oa);if(h.length===0){u.push(d);continue}if(typeof d.input!="object"||d.input===null){u.push(d);continue}let y=GE(d.input);for(let C of h)xme(y,C)?Rme(y,C,kln(g,C)):ve(`Archived input field path does not exist: ${C} for tool_use_id ${g}`);c=!0,u.push({...d,input:y});continue}u.push(d)}return c?{...e,message:{...e.message,content:u}}:e}var CTe=class e{static instance;archivedToolUseInputFields=new Map;archivedThinkingUuids=new Set;currentSessionId=null;currentArchiveFilePath=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadSession(t,r){if(!Ue.isMessageArchivingEnable()){this.archivedToolUseInputFields.clear(),this.archivedThinkingUuids.clear(),this.currentSessionId=t,this.currentArchiveFilePath=null;return}this.currentSessionId=t,this.currentArchiveFilePath=Dln(t,r);let n=Nln(this.currentArchiveFilePath);this.archivedToolUseInputFields=n.toolUseInputFields,this.archivedThinkingUuids=n.thinkingUuids}archive(t){if(Ue.isMessageArchivingEnable()){for(let[r,n]of Object.entries(t)){this.archivedToolUseInputFields.has(r)||this.archivedToolUseInputFields.set(r,new Set);let i=this.archivedToolUseInputFields.get(r);for(let o of n)i.add(o)}this.persist()}}unarchive(t){if(Ue.isMessageArchivingEnable()){for(let[r,n]of Object.entries(t)){let i=this.archivedToolUseInputFields.get(r);if(i){for(let o of n)i.delete(o);i.size===0&&this.archivedToolUseInputFields.delete(r)}}this.persist()}}archiveThinkingUuids(t){if(Ue.isMessageArchivingEnable()){for(let r of t)this.archivedThinkingUuids.add(r);this.persist()}}unarchiveThinkingUuids(t){if(Ue.isMessageArchivingEnable()){for(let r of t)this.archivedThinkingUuids.delete(r);this.persist()}}getArchivedThinkingUuids(){return new Set(this.archivedThinkingUuids)}isArchived(t){return this.archivedToolUseInputFields.get(t)?.has(Oa)??!1}getArchivedIds(){let t=new Set;for(let[r,n]of this.archivedToolUseInputFields)n.has(Oa)&&t.add(r);return t}getArchivedToolUseInputFields(t){return new Set(this.archivedToolUseInputFields.get(t)??[])}applyToMessages(t){if(!Ue.isMessageArchivingEnable())return t;let r=Pln(t),n=ITe(t),i=STe(),o=[];return t.map(s=>{if(s.type==="assistant")return i&&Array.isArray(s.message.content)&&(this.archivedThinkingUuids.has(s.uuid)?o.push({type:"text",text:Hln(s.uuid)}):Fln(s)>pu&&o.push($ln(s.uuid))),zln(s,this.archivedToolUseInputFields,this.archivedThinkingUuids,r);if(s.type==="user"){let a=Gln(s,this.archivedToolUseInputFields,r,n);if(o.length===0)return a;let l=o.splice(0,o.length),c=a.message.content,u=Array.isArray(c)?c:[{type:"text",text:c}],d=u.findIndex(m=>m.isReminder),g=d===-1?[...u,...l]:[...u.slice(0,d),...l,...u.slice(d)];return{...a,message:{...a.message,content:g}}}return s})}getCurrentArchiveFilePath(){return this.currentArchiveFilePath}persist(){this.currentArchiveFilePath&&Bln(this.currentArchiveFilePath,this.archivedToolUseInputFields,this.archivedThinkingUuids)}},vf=CTe.getInstance();He();async function y0t(){let e=tt();if(!(!e.hooks?.SessionStart||e.hooks.SessionStart.length===0))try{let t=new mg(e.hooks),r={session_id:Date.now().toString(),transcript_path:"",cwd:ms(),permission_mode:"default",hook_event_name:"SessionStart",source:"compact",model:process.env.ANTHROPIC_MODEL||"default"},n=await t.execute(r),i=[...n.additionalContext];n.asyncAdditionalContext&&n.getAsyncAdditionalContext().then(o=>{if(o.length>0){let s=et.getSessionContext(),l=[...s.getData("sessionStartAdditionalContexts")||[],...o];s.setData("sessionStartAdditionalContexts",l)}}).catch(o=>{K("SessionStart async hook execution error:",o)}),i.length>0&&et.getSessionContext().setData("sessionStartAdditionalContexts",i)}catch(t){K("SessionStart hook execution error in auto-compact:",t)}}var jln={"claude-3-7-sonnet-20250219":2e5,"claude-3-5-sonnet-20241022":2e5,"claude-3-5-haiku-20241022":2e5,"claude-3-haiku-20240307":2e5,"us.anthropic.claude-3-7-sonnet-20250219-v1:0":2e5,"us.anthropic.claude-3-5-haiku-20241022-v1:0":2e5,"claude-3-7-sonnet@20250219":2e5,"claude-3-5-haiku@20241022":2e5,"kimi-k2.5":15e4,"kimi-k2.6":15e4,"k2.5":15e4,"k2.6":15e4};function Yln(e){return jln[e.toLowerCase()]||2e5}function p2(){let e=Nn.getModelRoutingModels();if(e.length===0)throw new Error("No MODEL routing configuration found");let t=e.map(Yln);return Math.min(...t)}var Vln=`Your task is to create a detailed summary of the conversation so far, paying close attention to the user's explicit requests and your previous actions.
|
|
823
823
|
This summary should be thorough in capturing technical details, code patterns, and architectural decisions that would be essential for continuing development work without losing context.
|
|
824
824
|
|
|
@@ -985,7 +985,7 @@ ${Ue.isMessageArchivingEnable()?`
|
|
|
985
985
|
|
|
986
986
|
${await w_t()||""}`,`
|
|
987
987
|
${await Av()}
|
|
988
|
-
|
|
988
|
+
`,"# Code References\n\nWhen referencing specific functions or pieces of code include the pattern `file_path:line_number` to allow the user to easily navigate to the source code location.",...Ue.isMemoEnable()?["\n\n# Memo Tool Content Placeholder\n\nWhen the Memo tool is enabled, older Memo write contents are truncated in the context window. If you see a past Memo write where the content appears as `...<first 20 characters>...(argument truncated)`, the real content is stored on disk. Use the Memo tool's `read` operation with the corresponding `key` when you need the full content again. The most recent 5 messages keep their full content unchanged."]:[],...tt().language&&tt().language!=="auto"?[`
|
|
989
989
|
|
|
990
990
|
# Language
|
|
991
991
|
Always respond in ${tt().language}. Use ${tt().language} for all explanations, comments, and communications with the user. Technical terms and code identifiers should remain in their original form.
|
|
@@ -1016,7 +1016,7 @@ You are powered by the model ${e}.`}async function hv(){return!["1","true"].incl
|
|
|
1016
1016
|
<context name="${c}">${u}</context>`;let s=i.map(c=>{let u=c.prompt({},t),d=JSON.stringify("inputJSONSchema"in c&&c.inputJSONSchema?c.inputJSONSchema:TE(c.inputSchema));return{name:c.name,description:`${u}
|
|
1017
1017
|
|
|
1018
1018
|
Schema:
|
|
1019
|
-
${d}`}}),{messages:a}=t,l=Fcn(o);return Ucn(o,l,s,a)}},B_t=$cn;fg();var y2=Re(it(),1);Oe();Oe();import{existsSync as Hcn,readdirSync as qcn,statSync as Gcn}from"fs";import{join as zcn}from"path";function jcn(){let e=$i.plan();if(!Hcn(e))return[];try{return qcn(e).filter(r=>r.endsWith(".md")).map(r=>{let n=zcn(e,r),i=Gcn(n);return{name:r,path:n,modified:i.mtime}}).sort((r,n)=>n.modified.getTime()-r.modified.getTime())}catch{return[]}}var O_t=({onSelect:e})=>{let[t,r]=(0,y2.useState)([]),[n,i]=(0,y2.useState)(0),[o,s]=(0,y2.useState)(!1);(0,y2.useEffect)(()=>{let c=jcn();r(c),s(!0)},[]);let a=[{label:"New plan",value:"__NEW_PLAN__",isNew:!0},...t.map(c=>({label:c.name,value:c.path,isNew:!1,modified:c.modified}))];or((c,u)=>{if(u.upArrow)i(d=>d>0?d-1:a.length-1);else if(u.downArrow)i(d=>d<a.length-1?d+1:0);else if(u.return){let d=a[n];d&&e(d.value)}else u.escape&&e("__CANCELLED__")});let l=Me();return o?(0,_.jsxs)(B,{flexDirection:"column",marginY:1,children:[(0,_.jsx)(B,{marginBottom:1,children:(0,_.jsx)(x,{bold:!0,color:l.claude,children:"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"})}),(0,_.jsx)(B,{marginBottom:1,children:(0,_.jsx)(x,{bold:!0,color:l.claude,children:" Select a plan to continue, or create a new one"})}),a.map((c,u)=>{let d=u===n;return(0,_.jsxs)(B,{flexDirection:"row",marginLeft:2,children:[(0,_.jsx)(x,{color:d?l.claude:l.text,children:d?"\u276F":" "}),(0,_.jsx)(x,{color:d?l.claude:l.text,children:" "}),(0,_.jsx)(x,{color:d?l.claude:l.text,bold:c.isNew,children:c.isNew?c.label:c.label.replace(".md","")}),!c.isNew&&c.modified&&(0,_.jsxs)(x,{dimColor:!0,children:[" ","(",$me(c.modified),")"]})]},c.isNew?"new":c.value)}),(0,_.jsx)(B,{marginTop:1,marginLeft:2,children:(0,_.jsx)(x,{dimColor:!0,children:"\u2191/\u2193 to select \xB7 Enter to confirm \xB7 Esc to cancel"})})]}):(0,_.jsx)(B,{flexDirection:"column",marginY:1,children:(0,_.jsx)(x,{children:"Loading plan history..."})})};var Ycn={type:"local-jsx",name:"plan",description:()=>"Enable plan mode",isEnabled:!0,isHidden:!1,disableCancel:!0,async call(e){return Ai.isPlanMode()?(e("Already in plan mode."),null):(0,_.jsx)(O_t,{onSelect:t=>{if(t==="__CANCELLED__"){e("Cancelled.");return}t&&t!=="__NEW_PLAN__"?Ai.setCurrentPlanFilePath(t):Ai.generatePlanFilePath(),Ai.setMode("plan",!0,!1),e("Enabled plan mode")}})},userFacingName(){return"plan"}},k_t=Ycn;fg();var Vcn={type:"local",name:"auto",description:()=>"Enable auto mode",isEnabled:!0,isHidden:!1,async call(){return Ai.isAutoMode()?"Already in auto mode.":(Ai.setMode("auto",!0),"Enabled auto mode")},userFacingName(){return"auto"}},M_t=Vcn;Ar();import{resolve as Wcn}from"path";var Kcn={type:"local",name:"cd",description:()=>"Move this session to a new working directory",isEnabled:!0,isHidden:!1,argNames:["path"],async call(e){let t=e.trim();if(t==="")throw new Error("Missing directory path. Usage: /cd <path>");let r=Be(),n=Wcn(r,t);zs(n);let i=Be();return i===r?`Already in ${i}.`:`Changed directory to ${i}/`},userFacingName(){return"cd"}},Q_t=Kcn;var pCt=Re(it(),1);var ch=Re(it(),1);var wun=Re(it(),1);var N5=Re(it(),1),Tun=Re(U_t(),1);var $_t={info:"blue",success:"green",error:"red",warning:"yellow"},uun={styles:{container:({variant:e})=>({flexGrow:1,borderStyle:"round",borderColor:$_t[e],gap:1,paddingX:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:$_t[e]}),content:()=>({flexShrink:1,flexGrow:1,minWidth:0,flexDirection:"column",gap:1}),title:()=>({bold:!0}),message:()=>({})},config({variant:e}){let t;return e==="info"&&(t=Zt.info),e==="success"&&(t=Zt.tick),e==="error"&&(t=Zt.cross),e==="warning"&&(t=Zt.warning),{icon:t}}},H_t=uun;var dun={styles:{container:({color:e})=>({backgroundColor:e}),label:()=>({color:"black"})}},q_t=dun;var fun={styles:{input:({isFocused:e})=>({dimColor:!e})}},G_t=fun;var pun={styles:{container:()=>({flexDirection:"column"}),option:({isFocused:e})=>({gap:1,paddingLeft:e?0:2}),selectedIndicator:()=>({color:"green"}),focusIndicator:()=>({color:"blue"}),label({isFocused:e,isSelected:t}){let r;return t&&(r="green"),e&&(r="blue"),{color:r}},highlightedText:()=>({bold:!0})}},z_t=pun;var mun={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})}},j_t=mun;var gun={styles:{container:()=>({flexGrow:1,minWidth:0}),completed:()=>({color:"magenta"}),remaining:()=>({dimColor:!0})},config:()=>({completedCharacter:Zt.square,remainingCharacter:Zt.squareLightShade})},Y_t=gun;var Aun={styles:{container:()=>({flexDirection:"column"}),option:({isFocused:e})=>({gap:1,paddingLeft:e?0:2}),selectedIndicator:()=>({color:"green"}),focusIndicator:()=>({color:"blue"}),label({isFocused:e,isSelected:t}){let r;return t&&(r="green"),e&&(r="blue"),{color:r}},highlightedText:()=>({bold:!0})}},V_t=Aun;var hun={styles:{container:()=>({gap:1}),frame:()=>({color:"blue"}),label:()=>({})}},W_t=hun;var Eun={success:"green",error:"red",warning:"yellow",info:"blue"},_un={success:Zt.tick,error:Zt.cross,warning:Zt.warning,info:Zt.info},yun={styles:{container:()=>({gap:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:Eun[e]}),message:()=>({})},config:({variant:e})=>({icon:_un[e]})},K_t=yun;var bun={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})},config:()=>({marker:Zt.line})},J_t=bun;var Cun={styles:{value:()=>({})}},Z_t=Cun;var Sun={styles:{value:()=>({})}},X_t=Sun;var Iun={styles:{value:()=>({})}},eyt=Iun;var vun={components:{Alert:H_t,Badge:q_t,ConfirmInput:G_t,MultiSelect:z_t,OrderedList:j_t,ProgressBar:Y_t,Select:V_t,Spinner:W_t,StatusMessage:K_t,UnorderedList:J_t,TextInput:Z_t,EmailInput:X_t,PasswordInput:eyt}},xun=(0,N5.createContext)(vun);var oo=e=>(0,N5.useContext)(xun).components[e];var Dun=Re(it(),1);var V0=Re(it(),1);var C2=Re(it(),1);var tyt=Re(it(),1);var B5=Zt.line;var sX=(0,tyt.createContext)({marker:B5});function ryt({children:e}){let{marker:t}=(0,C2.useContext)(sX),{styles:r}=oo("UnorderedList");return C2.default.createElement(B,{...r.listItem()},C2.default.createElement(x,{...r.marker()},t),C2.default.createElement(B,{...r.content()},e))}var nyt=Re(it(),1),HTe=(0,nyt.createContext)({depth:0});function Run({children:e}){let{depth:t}=(0,V0.useContext)(HTe),{styles:r,config:n}=oo("UnorderedList"),i=(0,V0.useMemo)(()=>({depth:t+1}),[t]),o=(0,V0.useMemo)(()=>{let{marker:s}=n();return typeof s=="string"?{marker:s}:Array.isArray(s)?{marker:s[t]??s.at(-1)??B5}:{marker:B5}},[n,t]);return V0.default.createElement(HTe.Provider,{value:i},V0.default.createElement(sX.Provider,{value:o},V0.default.createElement(B,{...r.list()},e)))}Run.Item=ryt;var Bun=Re(it(),1);var Nun=Re(it(),1);var O5=Re(it(),1);var S2=class extends Map{first;constructor(t){let r=[],n,i,o=0;for(let s of t){let a={...s,previous:i,next:void 0,index:o};i&&(i.next=a),n||=a,r.push([s.value,a]),o++,i=a}super(r),this.first=n}};var iyt=Re(it(),1);var I2=Re(it(),1);var k5=Re(it(),1);function oyt({isFocused:e,isSelected:t,children:r}){let{styles:n}=oo("Select");return k5.default.createElement(B,{...n.option({isFocused:e})},e&&k5.default.createElement(x,{...n.focusIndicator()},Zt.pointer),k5.default.createElement(x,{...n.label({isFocused:e,isSelected:t})},r),t&&k5.default.createElement(x,{...n.selectedIndicator()},Zt.tick))}var Zp=Re(it(),1);import{isDeepStrictEqual as Oun}from"node:util";var kun=(e,t)=>{switch(t.type){case"focus-next-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.next;if(!n)return e;if(!(n.index>=e.visibleToIndex))return{...e,focusedValue:n.value};let o=Math.min(e.optionMap.size,e.visibleToIndex+1),s=o-e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:s,visibleToIndex:o}}case"focus-previous-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.previous;if(!n)return e;if(!(n.index<=e.visibleFromIndex))return{...e,focusedValue:n.value};let o=Math.max(0,e.visibleFromIndex-1),s=o+e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:o,visibleToIndex:s}}case"select-focused-option":return{...e,previousValue:e.value,value:e.focusedValue};case"reset":return t.state}},syt=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=typeof e=="number"?Math.min(e,r.length):r.length,i=new S2(r);return{optionMap:i,visibleOptionCount:n,focusedValue:i.first?.value,visibleFromIndex:0,visibleToIndex:n,previousValue:t,value:t}},ayt=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n})=>{let[i,o]=(0,Zp.useReducer)(kun,{visibleOptionCount:e,defaultValue:r,options:t},syt),[s,a]=(0,Zp.useState)(t);t!==s&&!Oun(t,s)&&(o({type:"reset",state:syt({visibleOptionCount:e,defaultValue:r,options:t})}),a(t));let l=(0,Zp.useCallback)(()=>{o({type:"focus-next-option"})},[]),c=(0,Zp.useCallback)(()=>{o({type:"focus-previous-option"})},[]),u=(0,Zp.useCallback)(()=>{o({type:"select-focused-option"})},[]),d=(0,Zp.useMemo)(()=>t.map((g,m)=>({...g,index:m})).slice(i.visibleFromIndex,i.visibleToIndex),[t,i.visibleFromIndex,i.visibleToIndex]);return(0,Zp.useEffect)(()=>{i.value&&i.previousValue!==i.value&&n?.(i.value)},[i.previousValue,i.value,t,n]),{focusedValue:i.focusedValue,visibleFromIndex:i.visibleFromIndex,visibleToIndex:i.visibleToIndex,value:i.value,visibleOptions:d,focusNextOption:l,focusPreviousOption:c,selectFocusedOption:u}};var lyt=({isDisabled:e=!1,state:t})=>{or((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};function T2({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o}){let s=ayt({visibleOptionCount:t,options:n,defaultValue:i,onChange:o});lyt({isDisabled:e,state:s});let{styles:a}=oo("Select");return I2.default.createElement(B,{...a.container()},s.visibleOptions.map(l=>{let c=l.label;if(r&&l.label.includes(r)){let u=l.label.indexOf(r);c=I2.default.createElement(I2.default.Fragment,null,l.label.slice(0,u),I2.default.createElement(x,{...a.highlightedText()},r),l.label.slice(u+r.length))}return I2.default.createElement(oyt,{key:l.value,isFocused:!e&&s.focusedValue===l.value,isSelected:s.value===l.value},c)}))}var Mun=Re(it(),1);var cyt=Re(it(),1);var Pun=Re(it(),1);var aX=Re(it(),1);var Qun=Re(it(),1);var aki=Jt.inverse(" ");var Eg=Re(it(),1);var v2=Re(it(),1);var uyt=Re(it(),1);var lX=(0,uyt.createContext)({marker:Zt.line});function cX({children:e}){let{marker:t}=(0,v2.useContext)(lX),{styles:r}=oo("OrderedList");return v2.default.createElement(B,{...r.listItem()},v2.default.createElement(x,{...r.marker()},t),v2.default.createElement(B,{...r.content()},e))}var dyt=Re(it(),1),qTe=(0,dyt.createContext)({marker:""});function _g({children:e}){let{marker:t}=(0,Eg.useContext)(qTe),{styles:r}=oo("OrderedList"),n=0;for(let o of Eg.default.Children.toArray(e))!(0,Eg.isValidElement)(o)||o.type!==cX||n++;let i=String(n).length;return Eg.default.createElement(B,{...r.list()},Eg.default.Children.map(e,(o,s)=>{if(!(0,Eg.isValidElement)(o)||o.type!==cX)return o;let a=`${String(s+1).padStart(i)}.`,l=`${t}${a}`;return Eg.default.createElement(qTe.Provider,{value:{marker:l}},Eg.default.createElement(lX.Provider,{value:{marker:l}},o))}))}_g.Item=cX;var Fun=Re(it(),1);var GTe=Re(it(),1);var Lun=Re(it(),1);var Qki=Jt.inverse(" ");var Uun=Re(it(),1);var $un=Re(it(),1);var qun=Re(it(),1);var uX=Re(it(),1);var Hun=Re(it(),1);var sMi=Jt.inverse(" ");var R2=Re(it(),1);var zTe=Re(it(),1);YU();ps();Ci();iv();Wt();var Gun=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function DC(){let e=Gun,{frame:t}=OD({interval:120});return(0,_.jsx)(B,{flexWrap:"nowrap",height:1,width:2,children:(0,_.jsx)(x,{color:Me().claude,children:e[t%e.length]})})}var pX=Re(it(),1);var Ev=null,W0=null,fX=new Set,dX=null;function YTe(e){let{columns:t,rows:r}=e;return t&&r?{columns:t,rows:r}:(dX||(dX=xfe()),{columns:t||dX.columns||80,rows:r||dX.rows||24})}function jTe(){if(!W0)return;let e=YTe(W0);Ev&&e.columns===Ev.columns&&e.rows===Ev.rows||(Ev=e,fX.forEach(t=>t(Ev)))}function zun(e,t){return W0!==e&&(W0&&W0.off("resize",jTe),W0=e,Ev=YTe(e),e.on("resize",jTe)),fX.add(t),()=>{fX.delete(t),fX.size===0&&W0&&(W0.off("resize",jTe),W0=null,Ev=null)}}function VTe(){let{stdout:e}=Uy(),[t,r]=(0,pX.useState)(()=>YTe(e));return(0,pX.useEffect)(()=>zun(e,r),[e]),t}function mX(){return VTe()}He();Xd();Oe();RA();Oe();var KQi=Re(Xbt(),1);import{homedir as q5}from"os";import{join as D2}from"path";import{existsSync as G5,mkdirSync as tCt,appendFileSync as eCt,readFileSync as rCt,constants as Hpn,writeFileSync as qpn,unlinkSync as nCt,statSync as Gpn}from"fs";import{platform as iCt}from"process";import{accessSync as zpn}from"fs";var $pn="2.7.17",H5={VERSION:$pn,PACKAGE_URL:"@dahawa/hawa-code",README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};He();var yv=D2(s0,".update.lock"),jpn=300*1e3;function oCt(){try{if(G5(s0)||tCt(s0,{recursive:!0}),G5(yv)){let e=Gpn(yv);if(Date.now()-e.mtimeMs<jpn)return!1;try{nCt(yv)}catch(r){return ve(`Failed to remove stale lock file: ${r}`),!1}}return qpn(yv,`${process.pid}`,"utf8"),!0}catch(e){return ve(`Failed to acquire lock: ${e}`),!1}}function sCt(){try{G5(yv)&&rCt(yv,"utf8")===`${process.pid}`&&nCt(yv)}catch(e){ve(`Failed to release lock: ${e}`)}}async function gve(){try{let e=await Wn("npm -g config get prefix");if(e.code!==0)return ve("Failed to check npm permissions"),{hasPermissions:!1,npmPrefix:null};let t=e.stdout.trim(),r=!1;try{zpn(t,Hpn.W_OK),r=!0}catch{r=!1}return r?{hasPermissions:!0,npmPrefix:t}:(ve("Insufficient permissions for global npm install."),{hasPermissions:!1,npmPrefix:t})}catch(e){return ve(`Failed to verify npm global install permissions: ${e}`),{hasPermissions:!1,npmPrefix:null}}}async function aCt(e){if(!oCt())throw Nt("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:H5.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{G5(e)||tCt(e,{recursive:!0});let t=await Wn(`npm -g config set prefix ${e}`);if(t.code!==0)throw new Error(`Failed to set npm prefix: ${t.stderr}`);let r=`
|
|
1019
|
+
${d}`}}),{messages:a}=t,l=Fcn(o);return Ucn(o,l,s,a)}},B_t=$cn;fg();var y2=Re(it(),1);Oe();Oe();import{existsSync as Hcn,readdirSync as qcn,statSync as Gcn}from"fs";import{join as zcn}from"path";function jcn(){let e=$i.plan();if(!Hcn(e))return[];try{return qcn(e).filter(r=>r.endsWith(".md")).map(r=>{let n=zcn(e,r),i=Gcn(n);return{name:r,path:n,modified:i.mtime}}).sort((r,n)=>n.modified.getTime()-r.modified.getTime())}catch{return[]}}var O_t=({onSelect:e})=>{let[t,r]=(0,y2.useState)([]),[n,i]=(0,y2.useState)(0),[o,s]=(0,y2.useState)(!1);(0,y2.useEffect)(()=>{let c=jcn();r(c),s(!0)},[]);let a=[{label:"New plan",value:"__NEW_PLAN__",isNew:!0},...t.map(c=>({label:c.name,value:c.path,isNew:!1,modified:c.modified}))];or((c,u)=>{if(u.upArrow)i(d=>d>0?d-1:a.length-1);else if(u.downArrow)i(d=>d<a.length-1?d+1:0);else if(u.return){let d=a[n];d&&e(d.value)}else u.escape&&e("__CANCELLED__")});let l=Me();return o?(0,_.jsxs)(B,{flexDirection:"column",marginY:1,children:[(0,_.jsx)(B,{marginBottom:1,children:(0,_.jsx)(x,{bold:!0,color:l.claude,children:"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"})}),(0,_.jsx)(B,{marginBottom:1,children:(0,_.jsx)(x,{bold:!0,color:l.claude,children:" Select a plan to continue, or create a new one"})}),a.map((c,u)=>{let d=u===n;return(0,_.jsxs)(B,{flexDirection:"row",marginLeft:2,children:[(0,_.jsx)(x,{color:d?l.claude:l.text,children:d?"\u276F":" "}),(0,_.jsx)(x,{color:d?l.claude:l.text,children:" "}),(0,_.jsx)(x,{color:d?l.claude:l.text,bold:c.isNew,children:c.isNew?c.label:c.label.replace(".md","")}),!c.isNew&&c.modified&&(0,_.jsxs)(x,{dimColor:!0,children:[" ","(",$me(c.modified),")"]})]},c.isNew?"new":c.value)}),(0,_.jsx)(B,{marginTop:1,marginLeft:2,children:(0,_.jsx)(x,{dimColor:!0,children:"\u2191/\u2193 to select \xB7 Enter to confirm \xB7 Esc to cancel"})})]}):(0,_.jsx)(B,{flexDirection:"column",marginY:1,children:(0,_.jsx)(x,{children:"Loading plan history..."})})};var Ycn={type:"local-jsx",name:"plan",description:()=>"Enable plan mode",isEnabled:!0,isHidden:!1,disableCancel:!0,async call(e){return Ai.isPlanMode()?(e("Already in plan mode."),null):(0,_.jsx)(O_t,{onSelect:t=>{if(t==="__CANCELLED__"){e("Cancelled.");return}t&&t!=="__NEW_PLAN__"?Ai.setCurrentPlanFilePath(t):Ai.generatePlanFilePath(),Ai.setMode("plan",!0,!1),e("Enabled plan mode")}})},userFacingName(){return"plan"}},k_t=Ycn;fg();var Vcn={type:"local",name:"auto",description:()=>"Enable auto mode",isEnabled:!0,isHidden:!1,async call(){return Ai.isAutoMode()?"Already in auto mode.":(Ai.setMode("auto",!0),"Enabled auto mode")},userFacingName(){return"auto"}},M_t=Vcn;Ar();import{resolve as Wcn}from"path";var Kcn={type:"local",name:"cd",description:()=>"Move this session to a new working directory",isEnabled:!0,isHidden:!1,argNames:["path"],async call(e){let t=e.trim();if(t==="")throw new Error("Missing directory path. Usage: /cd <path>");let r=Be(),n=Wcn(r,t);zs(n);let i=Be();return i===r?`Already in ${i}.`:`Changed directory to ${i}/`},userFacingName(){return"cd"}},Q_t=Kcn;var pCt=Re(it(),1);var ch=Re(it(),1);var wun=Re(it(),1);var N5=Re(it(),1),Tun=Re(U_t(),1);var $_t={info:"blue",success:"green",error:"red",warning:"yellow"},uun={styles:{container:({variant:e})=>({flexGrow:1,borderStyle:"round",borderColor:$_t[e],gap:1,paddingX:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:$_t[e]}),content:()=>({flexShrink:1,flexGrow:1,minWidth:0,flexDirection:"column",gap:1}),title:()=>({bold:!0}),message:()=>({})},config({variant:e}){let t;return e==="info"&&(t=Zt.info),e==="success"&&(t=Zt.tick),e==="error"&&(t=Zt.cross),e==="warning"&&(t=Zt.warning),{icon:t}}},H_t=uun;var dun={styles:{container:({color:e})=>({backgroundColor:e}),label:()=>({color:"black"})}},q_t=dun;var fun={styles:{input:({isFocused:e})=>({dimColor:!e})}},G_t=fun;var pun={styles:{container:()=>({flexDirection:"column"}),option:({isFocused:e})=>({gap:1,paddingLeft:e?0:2}),selectedIndicator:()=>({color:"green"}),focusIndicator:()=>({color:"blue"}),label({isFocused:e,isSelected:t}){let r;return t&&(r="green"),e&&(r="blue"),{color:r}},highlightedText:()=>({bold:!0})}},z_t=pun;var mun={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})}},j_t=mun;var gun={styles:{container:()=>({flexGrow:1,minWidth:0}),completed:()=>({color:"magenta"}),remaining:()=>({dimColor:!0})},config:()=>({completedCharacter:Zt.square,remainingCharacter:Zt.squareLightShade})},Y_t=gun;var Aun={styles:{container:()=>({flexDirection:"column"}),option:({isFocused:e})=>({gap:1,paddingLeft:e?0:2}),selectedIndicator:()=>({color:"green"}),focusIndicator:()=>({color:"blue"}),label({isFocused:e,isSelected:t}){let r;return t&&(r="green"),e&&(r="blue"),{color:r}},highlightedText:()=>({bold:!0})}},V_t=Aun;var hun={styles:{container:()=>({gap:1}),frame:()=>({color:"blue"}),label:()=>({})}},W_t=hun;var Eun={success:"green",error:"red",warning:"yellow",info:"blue"},_un={success:Zt.tick,error:Zt.cross,warning:Zt.warning,info:Zt.info},yun={styles:{container:()=>({gap:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:Eun[e]}),message:()=>({})},config:({variant:e})=>({icon:_un[e]})},K_t=yun;var bun={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})},config:()=>({marker:Zt.line})},J_t=bun;var Cun={styles:{value:()=>({})}},Z_t=Cun;var Sun={styles:{value:()=>({})}},X_t=Sun;var Iun={styles:{value:()=>({})}},eyt=Iun;var vun={components:{Alert:H_t,Badge:q_t,ConfirmInput:G_t,MultiSelect:z_t,OrderedList:j_t,ProgressBar:Y_t,Select:V_t,Spinner:W_t,StatusMessage:K_t,UnorderedList:J_t,TextInput:Z_t,EmailInput:X_t,PasswordInput:eyt}},xun=(0,N5.createContext)(vun);var oo=e=>(0,N5.useContext)(xun).components[e];var Dun=Re(it(),1);var V0=Re(it(),1);var C2=Re(it(),1);var tyt=Re(it(),1);var B5=Zt.line;var sX=(0,tyt.createContext)({marker:B5});function ryt({children:e}){let{marker:t}=(0,C2.useContext)(sX),{styles:r}=oo("UnorderedList");return C2.default.createElement(B,{...r.listItem()},C2.default.createElement(x,{...r.marker()},t),C2.default.createElement(B,{...r.content()},e))}var nyt=Re(it(),1),HTe=(0,nyt.createContext)({depth:0});function Run({children:e}){let{depth:t}=(0,V0.useContext)(HTe),{styles:r,config:n}=oo("UnorderedList"),i=(0,V0.useMemo)(()=>({depth:t+1}),[t]),o=(0,V0.useMemo)(()=>{let{marker:s}=n();return typeof s=="string"?{marker:s}:Array.isArray(s)?{marker:s[t]??s.at(-1)??B5}:{marker:B5}},[n,t]);return V0.default.createElement(HTe.Provider,{value:i},V0.default.createElement(sX.Provider,{value:o},V0.default.createElement(B,{...r.list()},e)))}Run.Item=ryt;var Bun=Re(it(),1);var Nun=Re(it(),1);var O5=Re(it(),1);var S2=class extends Map{first;constructor(t){let r=[],n,i,o=0;for(let s of t){let a={...s,previous:i,next:void 0,index:o};i&&(i.next=a),n||=a,r.push([s.value,a]),o++,i=a}super(r),this.first=n}};var iyt=Re(it(),1);var I2=Re(it(),1);var k5=Re(it(),1);function oyt({isFocused:e,isSelected:t,children:r}){let{styles:n}=oo("Select");return k5.default.createElement(B,{...n.option({isFocused:e})},e&&k5.default.createElement(x,{...n.focusIndicator()},Zt.pointer),k5.default.createElement(x,{...n.label({isFocused:e,isSelected:t})},r),t&&k5.default.createElement(x,{...n.selectedIndicator()},Zt.tick))}var Zp=Re(it(),1);import{isDeepStrictEqual as Oun}from"node:util";var kun=(e,t)=>{switch(t.type){case"focus-next-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.next;if(!n)return e;if(!(n.index>=e.visibleToIndex))return{...e,focusedValue:n.value};let o=Math.min(e.optionMap.size,e.visibleToIndex+1),s=o-e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:s,visibleToIndex:o}}case"focus-previous-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.previous;if(!n)return e;if(!(n.index<=e.visibleFromIndex))return{...e,focusedValue:n.value};let o=Math.max(0,e.visibleFromIndex-1),s=o+e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:o,visibleToIndex:s}}case"select-focused-option":return{...e,previousValue:e.value,value:e.focusedValue};case"reset":return t.state}},syt=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=typeof e=="number"?Math.min(e,r.length):r.length,i=new S2(r);return{optionMap:i,visibleOptionCount:n,focusedValue:i.first?.value,visibleFromIndex:0,visibleToIndex:n,previousValue:t,value:t}},ayt=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n})=>{let[i,o]=(0,Zp.useReducer)(kun,{visibleOptionCount:e,defaultValue:r,options:t},syt),[s,a]=(0,Zp.useState)(t);t!==s&&!Oun(t,s)&&(o({type:"reset",state:syt({visibleOptionCount:e,defaultValue:r,options:t})}),a(t));let l=(0,Zp.useCallback)(()=>{o({type:"focus-next-option"})},[]),c=(0,Zp.useCallback)(()=>{o({type:"focus-previous-option"})},[]),u=(0,Zp.useCallback)(()=>{o({type:"select-focused-option"})},[]),d=(0,Zp.useMemo)(()=>t.map((g,m)=>({...g,index:m})).slice(i.visibleFromIndex,i.visibleToIndex),[t,i.visibleFromIndex,i.visibleToIndex]);return(0,Zp.useEffect)(()=>{i.value&&i.previousValue!==i.value&&n?.(i.value)},[i.previousValue,i.value,t,n]),{focusedValue:i.focusedValue,visibleFromIndex:i.visibleFromIndex,visibleToIndex:i.visibleToIndex,value:i.value,visibleOptions:d,focusNextOption:l,focusPreviousOption:c,selectFocusedOption:u}};var lyt=({isDisabled:e=!1,state:t})=>{or((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};function T2({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o}){let s=ayt({visibleOptionCount:t,options:n,defaultValue:i,onChange:o});lyt({isDisabled:e,state:s});let{styles:a}=oo("Select");return I2.default.createElement(B,{...a.container()},s.visibleOptions.map(l=>{let c=l.label;if(r&&l.label.includes(r)){let u=l.label.indexOf(r);c=I2.default.createElement(I2.default.Fragment,null,l.label.slice(0,u),I2.default.createElement(x,{...a.highlightedText()},r),l.label.slice(u+r.length))}return I2.default.createElement(oyt,{key:l.value,isFocused:!e&&s.focusedValue===l.value,isSelected:s.value===l.value},c)}))}var Mun=Re(it(),1);var cyt=Re(it(),1);var Pun=Re(it(),1);var aX=Re(it(),1);var Qun=Re(it(),1);var aki=Jt.inverse(" ");var Eg=Re(it(),1);var v2=Re(it(),1);var uyt=Re(it(),1);var lX=(0,uyt.createContext)({marker:Zt.line});function cX({children:e}){let{marker:t}=(0,v2.useContext)(lX),{styles:r}=oo("OrderedList");return v2.default.createElement(B,{...r.listItem()},v2.default.createElement(x,{...r.marker()},t),v2.default.createElement(B,{...r.content()},e))}var dyt=Re(it(),1),qTe=(0,dyt.createContext)({marker:""});function _g({children:e}){let{marker:t}=(0,Eg.useContext)(qTe),{styles:r}=oo("OrderedList"),n=0;for(let o of Eg.default.Children.toArray(e))!(0,Eg.isValidElement)(o)||o.type!==cX||n++;let i=String(n).length;return Eg.default.createElement(B,{...r.list()},Eg.default.Children.map(e,(o,s)=>{if(!(0,Eg.isValidElement)(o)||o.type!==cX)return o;let a=`${String(s+1).padStart(i)}.`,l=`${t}${a}`;return Eg.default.createElement(qTe.Provider,{value:{marker:l}},Eg.default.createElement(lX.Provider,{value:{marker:l}},o))}))}_g.Item=cX;var Fun=Re(it(),1);var GTe=Re(it(),1);var Lun=Re(it(),1);var Qki=Jt.inverse(" ");var Uun=Re(it(),1);var $un=Re(it(),1);var qun=Re(it(),1);var uX=Re(it(),1);var Hun=Re(it(),1);var sMi=Jt.inverse(" ");var R2=Re(it(),1);var zTe=Re(it(),1);YU();ps();Ci();iv();Wt();var Gun=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function DC(){let e=Gun,{frame:t}=OD({interval:120});return(0,_.jsx)(B,{flexWrap:"nowrap",height:1,width:2,children:(0,_.jsx)(x,{color:Me().claude,children:e[t%e.length]})})}var pX=Re(it(),1);var Ev=null,W0=null,fX=new Set,dX=null;function YTe(e){let{columns:t,rows:r}=e;return t&&r?{columns:t,rows:r}:(dX||(dX=xfe()),{columns:t||dX.columns||80,rows:r||dX.rows||24})}function jTe(){if(!W0)return;let e=YTe(W0);Ev&&e.columns===Ev.columns&&e.rows===Ev.rows||(Ev=e,fX.forEach(t=>t(Ev)))}function zun(e,t){return W0!==e&&(W0&&W0.off("resize",jTe),W0=e,Ev=YTe(e),e.on("resize",jTe)),fX.add(t),()=>{fX.delete(t),fX.size===0&&W0&&(W0.off("resize",jTe),W0=null,Ev=null)}}function VTe(){let{stdout:e}=Uy(),[t,r]=(0,pX.useState)(()=>YTe(e));return(0,pX.useEffect)(()=>zun(e,r),[e]),t}function mX(){return VTe()}He();Xd();Oe();RA();Oe();var KQi=Re(Xbt(),1);import{homedir as q5}from"os";import{join as D2}from"path";import{existsSync as G5,mkdirSync as tCt,appendFileSync as eCt,readFileSync as rCt,constants as Hpn,writeFileSync as qpn,unlinkSync as nCt,statSync as Gpn}from"fs";import{platform as iCt}from"process";import{accessSync as zpn}from"fs";var $pn="2.7.19",H5={VERSION:$pn,PACKAGE_URL:"@dahawa/hawa-code",README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};He();var yv=D2(s0,".update.lock"),jpn=300*1e3;function oCt(){try{if(G5(s0)||tCt(s0,{recursive:!0}),G5(yv)){let e=Gpn(yv);if(Date.now()-e.mtimeMs<jpn)return!1;try{nCt(yv)}catch(r){return ve(`Failed to remove stale lock file: ${r}`),!1}}return qpn(yv,`${process.pid}`,"utf8"),!0}catch(e){return ve(`Failed to acquire lock: ${e}`),!1}}function sCt(){try{G5(yv)&&rCt(yv,"utf8")===`${process.pid}`&&nCt(yv)}catch(e){ve(`Failed to release lock: ${e}`)}}async function gve(){try{let e=await Wn("npm -g config get prefix");if(e.code!==0)return ve("Failed to check npm permissions"),{hasPermissions:!1,npmPrefix:null};let t=e.stdout.trim(),r=!1;try{zpn(t,Hpn.W_OK),r=!0}catch{r=!1}return r?{hasPermissions:!0,npmPrefix:t}:(ve("Insufficient permissions for global npm install."),{hasPermissions:!1,npmPrefix:t})}catch(e){return ve(`Failed to verify npm global install permissions: ${e}`),{hasPermissions:!1,npmPrefix:null}}}async function aCt(e){if(!oCt())throw Nt("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:H5.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{G5(e)||tCt(e,{recursive:!0});let t=await Wn(`npm -g config set prefix ${e}`);if(t.code!==0)throw new Error(`Failed to set npm prefix: ${t.stderr}`);let r=`
|
|
1020
1020
|
# npm global path
|
|
1021
1021
|
export PATH="${e}/bin:$PATH"
|
|
1022
1022
|
`;if(iCt==="win32"){let n=await Wn(`setx PATH "${process.env.PATH};${e}"`);if(n.code!==0)throw new Error(`Failed to update PATH on Windows: ${n.stderr}`)}else{let n=[D2(q5(),".bashrc"),D2(q5(),".bash_profile"),D2(q5(),".zshrc"),D2(q5(),".config","fish","config.fish")];for(let i of n)if(G5(i))try{if(!rCt(i,"utf8").includes(e)){if(i.includes("fish")){let s=`
|