@dahawa/hawa-code 2.4.52 → 2.4.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/cli.js +6 -6
  2. package/hands.js +6 -6
  3. package/package.json +1 -1
package/cli.js CHANGED
@@ -652,7 +652,7 @@ globstar while`,e,d,t,m,p),this.matchOne(e.slice(d),t.slice(m),r))return this.de
652
652
  `)),hWr(e,o,{encoding:r,flush:!0})}var bat=new MJ.default({fetchMethod:e=>CWr(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});async function Rat(e){let t=c5(e);return bat.get(t)||bat.fetchMethod?.(t)}async function CWr(e){let t=new AbortController;setTimeout(()=>{t.abort()},1e3);let r=await $rt(e,t.signal,15),n=0;for(let o of r)tw(o)==="CRLF"&&n++;return n>3?"CRLF":"LF"}function Nat(e,t,r){if(e.has(t))return e.get(t);let n=r();return e.set(t,n),n}var TWr=new MJ.default({fetchMethod:e=>Dat(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});function Vp(e){let t=c5(e);return Nat(TWr,t,()=>Dat(t))}function Dat(e){let r=Buffer.alloc(4096),n;try{n=yat(e,"r");let o=Cat(n,r,0,4096,0);return o===0?"utf8":o>=2&&r[0]===255&&r[1]===254?"utf16le":o>=3&&r[0]===239&&r[1]===187&&r[2]===191||r.slice(0,o).toString("utf8").length>0?"utf8":"ascii"}catch(o){return Se(`Error detecting encoding for file ${e}: ${o}`),"utf8"}finally{n&&Tat(n)}}var IWr=new MJ.default({fetchMethod:e=>Oat(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});function tw(e){let t=c5(e);return Nat(IWr,t,()=>Oat(t))}function Oat(e,t="utf8"){try{if(!Iat(e).isFile())return"LF";let n=Buffer.alloc(4096),o=yat(e,"r"),i=Cat(o,n,0,4096,0);Tat(o);let s=n.toString(t,0,i),a=0,l=0;for(let c=0;c<s.length;c++)s[c]===`
653
653
  `&&(c>0&&s[c-1]==="\r"?a++:l++);return a>l?"CRLF":"LF"}catch(r){return Se(`Error detecting line endings for file ${e}: ${r}`),"LF"}}function GM(e){let t=vat(e)?e:c5(Ne(),e);return t.endsWith(" AM.png")?t.replace(" AM.png","\u202FAM.png"):t.endsWith(" PM.png")?t.replace(" PM.png","\u202FPM.png"):t}function DSe(e){return e?vat(e)?e:c5(Ne(),e):void 0}function Bat(e){try{let t=DSe(e),r=t?SWr(Ne(),t):void 0;return{absolutePath:t,relativePath:r}}catch(t){return te("getAbsoluteAndRelativePaths error ",t),{absolutePath:null,relativePath:null}}}function LJ(e){try{let t=bWr(e),r=_at(e,Eat(e));if(!AWr(t))return;let i=_Wr(t).filter(s=>_at(s,Eat(s))===r&&yWr(t,s)!==e)[0];return i||void 0}catch(t){Se(`Error finding similar file for ${e}: ${t}`);return}}function OSe(){let e=process.env.HAWA_CODE_COMPACT_LINE_PREFIX;return!(e==="0"||e==="false")}function bT({content:e,startLine:t}){if(!e)return"";let r=e.split(/\r?\n/);return OSe()?r.map((n,o)=>`${o+t} ${n}`).join(`
654
654
  `):r.map((n,o)=>{let i=String(o+t);return i.length>=6?`${i}\u2192${n}`:`${i.padStart(6," ")}\u2192${n}`}).join(`
655
- `)}function Mat(e){try{let t=EWr(e),r=t.readSync();return t.closeSync(),r===null}catch(t){return Se(`Error checking directory: ${t}`),!1}}Pe();function AT(){let e=Rn();e.hasCompletedProjectOnboarding||pi({...e,hasCompletedProjectOnboarding:!0})}function BSe({workspaceDir:e}){let r=!Rn().hasCompletedProjectOnboarding;if(!r)return null;let n=vWr(xWr(e,Zo)),o=Mat(e),i=!n&&!o,s=MM.isEnabled&&!Gr().shiftEnterKeyBindingInstalled,a=re();return Qa.createElement(x,{flexDirection:"column",gap:1,padding:1,paddingBottom:0},r&&Qa.createElement(Qa.Fragment,null,Qa.createElement(T,{color:a.secondaryText},"Tips for getting started:"),Qa.createElement(uu,{children:[]},(()=>{let l=[];return o&&l.push(Qa.createElement(uu.Item,{key:"workspace"},Qa.createElement(T,{color:a.secondaryText},"Ask ",tt," to create a new app or clone a repository."))),i&&l.push(Qa.createElement(uu.Item,{key:"claudemd"},Qa.createElement(T,{color:a.secondaryText},"Run ",Qa.createElement(T,{color:a.text},"/init")," to create a",Zo," file with instructions for Hawa code."))),s&&l.push(Qa.createElement(uu.Item,{key:"terminal"},Qa.createElement(T,{color:a.secondaryText},"Run ",Qa.createElement(T,{color:a.text},"/terminal-setup"),Qa.createElement(T,{bold:!1}," to set up terminal integration")))),l.push(Qa.createElement(uu.Item,{key:"questions"},Qa.createElement(T,{color:a.secondaryText},"Ask ",tt," questions about your codebase."))),l.push(Qa.createElement(uu.Item,{key:"changes"},Qa.createElement(T,{color:a.secondaryText},"Ask ",tt," to implement changes to your codebase."))),l})())),e===wWr()&&Qa.createElement(T,{color:re().warning},"Note: You have launched ",Qa.createElement(T,{bold:!0},tt)," in your home directory. For the best experience, launch it in a project directory instead."))}var $M=j(ie(),1);var HM=j(ie(),1);var u5=j(ie(),1);function MSe({isFocused:e,isSelected:t,smallPointer:r,children:n}){let{styles:o}=Di("Select");return u5.default.createElement(x,{...o.option({isFocused:e})},e&&u5.default.createElement(T,{...o.focusIndicator()},r?rr.triangleDownSmall:rr.pointer),u5.default.createElement(T,{...o.label({isFocused:e,isSelected:t})},n),t&&u5.default.createElement(T,{...o.selectedIndicator()},rr.tick))}var Wp=j(ie(),1);import{isDeepStrictEqual as RWr}from"node:util";var d5=class extends Map{first;constructor(t){let r=[],n,o,i=0;for(let s of t){let a={...s,previous:o,next:void 0,index:i};o&&(o.next=a),n||=a;let l="value"in s?s.value:kSe(s);r.push([l,a]),i++,o=a}super(r),this.first=n}};var NWr=(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;for(;n&&!("value"in n);)n=n.next;if(!n)return e;if(!(n.index>=e.visibleToIndex))return{...e,focusedValue:n.value};let i=Math.min(e.optionMap.size,e.visibleToIndex+1),s=i-e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:s,visibleToIndex:i}}case"focus-previous-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.previous;for(;n&&!("value"in n);)n=n.previous;if(!n)return e;if(!(n.index<=e.visibleFromIndex))return{...e,focusedValue:n.value};let i=Math.max(0,e.visibleFromIndex-1),s=i+e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:i,visibleToIndex:s}}case"select-focused-option":return{...e,previousValue:e.value,value:e.focusedValue};case"reset":return t.state;case"set-focus":return{...e,focusedValue:t.value}}},LSe=e=>e.flatMap(t=>{if("options"in t){let r=LSe(t.options),n=r.flatMap(i=>"value"in i?i.value:[]);return[...t.header!==void 0?[{header:t.header,optionValues:n}]:[],...r]}return t}),kat=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=LSe(r),o=typeof e=="number"?Math.min(e,n.length):n.length,i=new d5(n),s=i.first,a=s&&"value"in s?s.value:void 0;return{optionMap:i,visibleOptionCount:o,focusedValue:a,visibleFromIndex:0,visibleToIndex:o,previousValue:t,value:t}},PSe=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n,onFocus:o,focusValue:i})=>{let s=LSe(t),[a,l]=(0,Wp.useReducer)(NWr,{visibleOptionCount:e,defaultValue:r,options:t},kat),[c,u]=(0,Wp.useState)(s);s!==c&&!RWr(s,c)&&(l({type:"reset",state:kat({visibleOptionCount:e,defaultValue:r,options:t})}),u(s));let d=(0,Wp.useCallback)(()=>{l({type:"focus-next-option"})},[]),m=(0,Wp.useCallback)(()=>{l({type:"focus-previous-option"})},[]),p=(0,Wp.useCallback)(()=>{l({type:"select-focused-option"})},[]),h=(0,Wp.useMemo)(()=>s.map((A,_)=>({...A,index:_})).slice(a.visibleFromIndex,a.visibleToIndex),[s,a.visibleFromIndex,a.visibleToIndex]);return(0,Wp.useEffect)(()=>{a.value&&a.previousValue!==a.value&&n?.(a.value)},[a.previousValue,a.value,t,n]),(0,Wp.useEffect)(()=>{a.focusedValue&&o?.(a.focusedValue)},[a.focusedValue,o]),(0,Wp.useEffect)(()=>{i&&l({type:"set-focus",value:i})},[i]),{focusedValue:a.focusedValue,visibleFromIndex:a.visibleFromIndex,visibleToIndex:a.visibleToIndex,value:a.value,visibleOptions:h,focusNextOption:d,focusPreviousOption:m,selectFocusedOption:p}};var FSe=({isDisabled:e=!1,state:t})=>{pt((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};var kSe=e=>`HEADER-${e.optionValues.join(",")}`;function Vb({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a}){let l=PSe({visibleOptionCount:t,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a});FSe({isDisabled:e,state:l});let{styles:c}=Di("Select");return HM.default.createElement(x,{...c.container()},l.visibleOptions.map(u=>{let d="value"in u?u.value:kSe(u),m=!e&&l.focusedValue!==void 0&&("value"in u?l.focusedValue===u.value:u.optionValues.includes(l.focusedValue)),p=!!l.value&&("value"in u?l.value===u.value:u.optionValues.includes(l.value)),h="header"in u,A="label"in u?u.label:u.header,_=A;if(r&&A.includes(r)){let S=A.indexOf(r);_=HM.default.createElement(HM.default.Fragment,null,A.slice(0,S),HM.default.createElement(T,{...c.highlightedText()},r),A.slice(S+r.length))}return HM.default.createElement(MSe,{key:d,isFocused:m,isSelected:p,smallPointer:h},_)}))}function Lat({onDone:e}){return pt((t,r)=>{(r.ctrl&&(t==="c"||t==="d")||r.escape)&&e()}),$M.default.createElement(x,{flexDirection:"column",borderStyle:"round",padding:1,borderColor:re().secondaryBorder},$M.default.createElement(x,{marginBottom:1,flexDirection:"column"},$M.default.createElement(T,{bold:!0},"You've spent $5 this session.")),$M.default.createElement(x,null,$M.default.createElement(Vb,{options:[{value:"ok",label:"Got it, thanks!"}],onChange:e})))}var un=j(ie(),1),Jt=j(ie(),1);var Wd=j(ie(),1);Pe();lr();cE();var BWr="2.4.52",uE={VERSION:BWr,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"};var GSe=46,Qat=["(\u2740\u2579\u25E1\u2579)","(\u25D5\u072B\u25D5)","\u239D(\u25D5u\u25D5)\u23A0","\u10DA(\u25C9\u25DE\u0C6A\u25DF\u25C9 )\u10DA","(\xB4\u25C9\u203F\u25C9\uFF40)","\u0E01\u0E47\u0295\u2022\u0361\u1D25\u2022\u0294 \u0E01\u0E49","\uFF0F/( \u25D5\u203F\u203F\u25D5 )\uFF3C"];function PJ({isDefaultModel:e=!1}){let t=Math.max(GSe,Ne().length+12),r=re(),n=Qat[Math.floor(Math.random()*Qat.length)];return Wd.createElement(x,{flexDirection:"column"},Wd.createElement(x,{flexDirection:"column",gap:1,paddingLeft:1,width:"100%"},Wd.createElement(T,null,Wd.createElement(T,null,n)," Welcome to"," ",Wd.createElement(T,{bold:!0},tt),Wd.createElement(T,{color:r.secondaryText}," v",uE.VERSION)),Wd.createElement(Wd.Fragment,null,Wd.createElement(x,{paddingLeft:2,flexDirection:"column",gap:1},Wd.createElement(T,{color:r.secondaryText,italic:!0},"/help for help"),Wd.createElement(T,{color:r.secondaryText},"cwd: ",Ne()),Wd.createElement(T,{color:r.secondaryText},"model: ",oo.getConfig().routing.MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A"),Wd.createElement(T,{color:r.secondaryText},"small fast model: ",oo.getConfig().routing.SMALL_FAST_MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A")))))}var x_=j(ie(),1);Re();var x6=j(ie(),1);import{randomUUID as Wh}from"crypto";fs();Re();Zt();lr();Re();Pe();import{existsSync as Kb,readdirSync as lZr,statSync as cZr}from"fs";import{join as vT,relative as uZr}from"path";import{homedir as Out}from"os";import{platform as dZr}from"process";import{readFile as xT}from"fs/promises";lr();af();hr();import{join as QWr,sep as UWr}from"path";function jd(){if(!du())return!1;try{let e=rt();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function jp(){return(QWr(Ne(),".hcode","team-memory")+UWr).normalize("NFC")}function jg(e){let t=e.normalize("NFC"),r=jp();return t.startsWith(r)}af();var But=j(S5(),1);Ro();var ibe=(e,t,r)=>{let n=e instanceof RegExp?sut(e,r):e,o=t instanceof RegExp?sut(t,r):t,i=n!==null&&o!=null&&ZKr(n,o,r);return i&&{start:i[0],end:i[1],pre:r.slice(0,i[0]),body:r.slice(i[0]+n.length,i[1]),post:r.slice(i[1]+o.length)}},sut=(e,t)=>{let r=t.match(e);return r?r[0]:null},ZKr=(e,t,r)=>{let n,o,i,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=[],i=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 o=n.pop(),o!==void 0&&o<i&&(i=o,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[i,s])}return a};var aut="\0SLASH"+Math.random()+"\0",lut="\0OPEN"+Math.random()+"\0",lbe="\0CLOSE"+Math.random()+"\0",cut="\0COMMA"+Math.random()+"\0",uut="\0PERIOD"+Math.random()+"\0",XKr=new RegExp(aut,"g"),eJr=new RegExp(lut,"g"),tJr=new RegExp(lbe,"g"),rJr=new RegExp(cut,"g"),nJr=new RegExp(uut,"g"),oJr=/\\\\/g,iJr=/\\{/g,sJr=/\\}/g,aJr=/\\,/g,lJr=/\\\./g,cJr=1e5,uJr=4e6;function sbe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function dJr(e){return e.replace(oJr,aut).replace(iJr,lut).replace(sJr,lbe).replace(aJr,cut).replace(lJr,uut)}function pJr(e){return e.replace(XKr,"\\").replace(eJr,"{").replace(tJr,"}").replace(rJr,",").replace(nJr,".")}function dut(e){if(!e)return[""];let t=[],r=ibe("{","}",e);if(!r)return e.split(",");let{pre:n,body:o,post:i}=r,s=n.split(",");s[s.length-1]+="{"+o+"}";let a=dut(i);return i.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function put(e,t={}){if(!e)return[];let{max:r=cJr,maxLength:n=uJr}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),abe(dJr(e),r,n,!0).map(pJr)}function mJr(e){return"{"+e+"}"}function fJr(e){return/^-?0\d/.test(e)}function gJr(e,t){return e<=t}function hJr(e,t){return e>=t}function b5(e,t,r,n,o,i){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(!(i&&!u)){if(a+u.length>o)return s;s.push(u),a+=u.length}}return s}function AJr(e,t,r,n){let o=e.split(/\.\./),i=[];if(o[0]===void 0||o[1]===void 0)return i;let s=sbe(o[0]),a=sbe(o[1]),l=Math.max(o[0].length,o[1].length),c=o.length===3&&o[2]!==void 0?Math.max(Math.abs(sbe(o[2])),1):1,u=gJr;a<s&&(c*=-1,u=hJr);let m=o.some(fJr),p=0;for(let h=s;u(h,a)&&i.length<r;h+=c){let A;if(t)A=String.fromCharCode(h),A==="\\"&&(A="");else if(A=String(h),m){let _=l-A.length;if(_>0){let S=new Array(_+1).join("0");h<0?A="-"+S+A.slice(1):A=S+A}}if(p+A.length>n)break;i.push(A),p+=A.length}return i}function abe(e,t,r,n){let o=[""],i=!1,s=!0;for(;;){let a=ibe("{","}",e);if(!a)return b5(o,e,[""],t,r,i);let l=a.pre;if(/\$$/.test(l)){if(o=b5(o,l+"{"+a.body+"}",[""],t,r,i&&!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,m=a.body.indexOf(",")>=0;if(!d&&!m){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+lbe+a.post,n=!0;continue}return b5(o,l+"{"+a.body+"}"+a.post,[""],t,r,i)}s&&(i=n&&!d,s=!1);let p;if(d)p=AJr(a.body,u,t,r);else{let h=dut(a.body);if(h.length===1&&h[0]!==void 0&&(h=abe(h[0],t,r,!1).map(mJr),h.length===1)){if(o=b5(o,l+h[0],[""],t,r,i&&!a.post.length),!a.post.length)break;e=a.post;continue}let A=i&&!a.post.length&&!l;for(let S=0;A&&S<o.length;S++)o[S]&&(A=!1);p=[];let _=0;e:for(let S=0;S<h.length;S++){let y=abe(h[S],t,r,!1);for(let I=0;I<y.length;I++){let w=y[I];if(!(A&&!w)){if(p.length>=t||_+w.length>r)break e;p.push(w),_+=w.length}}}}if(o=b5(o,l,p,t,r,i&&!a.post.length),!a.post.length)break;e=a.post}return o}var y5=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var _Jr={"[: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]},C5=e=>e.replace(/[[\]\\-]/g,"\\$&"),EJr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),mut=e=>e.join(""),fut=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],o=[],i=r+1,s=!1,a=!1,l=!1,c=!1,u=r,d="";e:for(;i<e.length;){let A=e.charAt(i);if((A==="!"||A==="^")&&i===r+1){c=!0,i++;continue}if(A==="]"&&s&&!l){u=i+1;break}if(s=!0,A==="\\"&&!l){l=!0,i++;continue}if(A==="["&&!l){for(let[_,[S,y,I]]of Object.entries(_Jr))if(e.startsWith(_,i)){if(d)return["$.",!1,e.length-r,!0];i+=_.length,I?o.push(S):n.push(S),a=a||y;continue e}}if(l=!1,d){A>d?n.push(C5(d)+"-"+C5(A)):A===d&&n.push(C5(A)),d="",i++;continue}if(e.startsWith("-]",i+1)){n.push(C5(A+"-")),i+=2;continue}if(e.startsWith("-",i+1)){d=A,i+=2;continue}n.push(C5(A)),i++}if(u<i)return["",!1,0,!1];if(!n.length&&!o.length)return["$.",!1,e.length-r,!0];if(o.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!c){let A=n[0].length===2?n[0].slice(-1):n[0];return[EJr(A),!1,u-r,!1]}let m="["+(c?"^":"")+mut(n)+"]",p="["+(c?"":"^")+mut(o)+"]";return[n.length&&o.length?"("+m+"|"+p+")":n.length?m:p,a,u-r,!0]};var IT=(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 Jp,SJr=new Set(["!","?","+","*","@"]),cbe=e=>SJr.has(e),gut=e=>cbe(e.type),bJr=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),yJr=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),CJr=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),hut=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),TJr="(?!(?:^|/)\\.\\.?(?:$|/))",jJ="(?!\\.)",IJr=new Set(["[","."]),vJr=new Set(["..","."]),xJr=new Set("().*{}+?[]^$\\!"),wJr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ube="[^/]",Aut=ube+"*?",_ut=ube+"+?",RJr=0,cw=class{type;#e;#t;#n=!1;#r=[];#i;#o;#l;#s=!1;#a;#d;#m=!1;id=++RJr;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(t,r,n={}){this.type=t,t&&(this.#t=!0),this.#i=r,this.#e=this.#i?this.#i.#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.#o=this.#i?this.#i.#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("")}#p(){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.#i;for(;n;){for(let o=r.#o+1;!n.type&&o<n.#r.length;o++)for(let i of t.#r){if(typeof i=="string")throw new Error("string part in extglob AST??");i.copyIn(n.#r[o])}r=n,n=r.#i}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof Jp&&r.#i===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.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#o===0)return!0;let t=this.#i;for(let r=0;r<this.#o;r++){let n=t.#r[r];if(!(n instanceof Jp&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#r.length:0;return this.#o===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new Jp(this.type,t);for(let n of this.#r)r.copyIn(n);return r}static#c(t,r,n,o,i){let s=o.maxExtglobRecursion??2,a=!1,l=!1,c=-1,u=!1;if(r.type===null){let A=n,_="";for(;A<t.length;){let S=t.charAt(A++);if(a||S==="\\"){a=!a,_+=S;continue}if(l){A===c+1?(S==="^"||S==="!")&&(u=!0):S==="]"&&!(A===c+2&&u)&&(l=!1),_+=S;continue}else if(S==="["){l=!0,c=A,u=!1,_+=S;continue}if(!o.noext&&cbe(S)&&t.charAt(A)==="("&&i<=s){r.push(_),_="";let I=new Jp(S,r);A=Jp.#c(t,I,A,o,i+1),r.push(I);continue}_+=S}return r.push(_),A}let d=n+1,m=new Jp(null,r),p=[],h="";for(;d<t.length;){let A=t.charAt(d++);if(a||A==="\\"){a=!a,h+=A;continue}if(l){d===c+1?(A==="^"||A==="!")&&(u=!0):A==="]"&&!(d===c+2&&u)&&(l=!1),h+=A;continue}else if(A==="["){l=!0,c=d,u=!1,h+=A;continue}if(!o.noext&&cbe(A)&&t.charAt(d)==="("&&(i<=s||r&&r.#_(A))){let S=r&&r.#_(A)?0:1;m.push(h),h="";let y=new Jp(A,m);m.push(y),d=Jp.#c(t,y,d,o,i+S);continue}if(A==="|"){m.push(h),h="",p.push(m),m=new Jp(null,r);continue}if(A===")")return h===""&&r.#r.length===0&&(r.#m=!0),m.push(h),h="",r.push(...p,m),d;h+=A}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],d}#g(t){return this.#A(t,yJr)}#A(t,r=bJr){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.#_(n.type,r)}#_(t,r=CJr){return!!r.get(this.type)?.includes(t)}#h(t,r){let n=t.#r[0],o=new Jp(null,n,this.options);o.#r.push(""),n.push(o),this.#v(t,r)}#v(t,r){let n=t.#r[0];this.#r.splice(r,1,...n.#r);for(let o of n.#r)typeof o=="object"&&(o.#i=this);this.#d=void 0}#S(t){return!!hut.get(this.type)?.has(t)}#C(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.#S(r.type)}#T(t){let r=hut.get(this.type),n=t.#r[0],o=r?.get(n.type);if(!o)return!1;this.#r=n.#r;for(let i of this.#r)typeof i=="object"&&(i.#i=this);this.type=o,this.#d=void 0,this.#m=!1}static fromGlob(t,r={}){let n=new Jp(null,void 0,r);return Jp.#c(t,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,o,i]=this.toRegExpSource();if(!(o||this.#t||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(i?"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.#E(),this.#p()),!gut(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(p=>typeof p!="string"),c=this.#r.map(p=>{let[h,A,_,S]=typeof p=="string"?Jp.#y(p,this.#t,l):p.toRegExpSource(t);return this.#t=this.#t||_,this.#n=this.#n||S,h}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&vJr.has(this.#r[0]))){let h=IJr,A=r&&h.has(c.charAt(0))||c.startsWith("\\.")&&h.has(c.charAt(2))||c.startsWith("\\.\\.")&&h.has(c.charAt(4)),_=!r&&!t&&h.has(c.charAt(0));u=A?TJr:_?jJ:""}let d="";return this.isEnd()&&this.#e.#s&&this.#i?.type==="!"&&(d="(?:$|\\/)"),[u+c+d,IT(c),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",o=this.type==="!"?"(?:(?!(?:":"(?:",i=this.#b(r);if(this.isStart()&&this.isEnd()&&!i&&this.type!=="!"){let l=this.toString(),c=this;return c.#r=[l],c.type=null,c.#t=void 0,[l,IT(this.toString()),!1,!1]}let s=!n||t||r||!jJ?"":this.#b(!0);s===i&&(s=""),s&&(i=`(?:${i})(?:${s})*?`);let a="";if(this.type==="!"&&this.#m)a=(this.isStart()&&!r?jJ:"")+_ut;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?jJ:"")+Aut+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=o+i+l}return[a,IT(i),this.#t=!!this.#t,this.#n]}#E(){if(gut(this)){let t=0,r=!1;do{r=!0;for(let n=0;n<this.#r.length;n++){let o=this.#r[n];typeof o=="object"&&(o.#E(),this.#A(o)?(r=!1,this.#v(o,n)):this.#g(o)?(r=!1,this.#h(o,n)):this.#C(o)&&(r=!1,this.#T(o)))}}while(!r&&++t<10)}else for(let t of this.#r)typeof t=="object"&&t.#E();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,o,i,s]=r.toRegExpSource(t);return this.#n=this.#n||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#y(t,r,n=!1){let o=!1,i="",s=!1,a=!1;for(let l=0;l<t.length;l++){let c=t.charAt(l);if(o){o=!1,i+=(xJr.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,i+=n&&/^[*]+$/.test(t)?_ut:Aut,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?i+="\\\\":o=!0;continue}if(c==="["){let[u,d,m,p]=fut(t,l);if(m){i+=u,s=s||d,l+=m-1,r=r||p;continue}}if(c==="?"){i+=ube,r=!0;continue}i+=wJr(c)}return[i,IT(t),!!r,s]}};Jp=cw;var dbe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var pu=(e,t,r={})=>(y5(t),!r.nocomment&&t.charAt(0)==="#"?!1:new ek(t,r).match(e)),NJr=/^\*+([^+@!?*[(]*)$/,DJr=e=>t=>!t.startsWith(".")&&t.endsWith(e),OJr=e=>t=>t.endsWith(e),BJr=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),MJr=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),kJr=/^\*+\.\*+$/,LJr=e=>!e.startsWith(".")&&e.includes("."),PJr=e=>e!=="."&&e!==".."&&e.includes("."),FJr=/^\.\*+$/,QJr=e=>e!=="."&&e!==".."&&e.startsWith("."),UJr=/^\*+$/,GJr=e=>e.length!==0&&!e.startsWith("."),HJr=e=>e.length!==0&&e!=="."&&e!=="..",$Jr=/^\?+([^+@!?*[(]*)?$/,qJr=([e,t=""])=>{let r=but([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},YJr=([e,t=""])=>{let r=yut([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},zJr=([e,t=""])=>{let r=yut([e]);return t?n=>r(n)&&n.endsWith(t):r},VJr=([e,t=""])=>{let r=but([e]);return t?n=>r(n)&&n.endsWith(t):r},but=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},yut=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},Cut=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Eut={win32:{sep:"\\"},posix:{sep:"/"}},WJr=Cut==="win32"?Eut.win32.sep:Eut.posix.sep;pu.sep=WJr;var ud=Symbol("globstar **");pu.GLOBSTAR=ud;var jJr="[^/]",KJr=jJr+"*?",JJr="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",ZJr="(?:(?!(?:\\/|^)\\.).)*?",XJr=(e,t={})=>r=>pu(r,e,t);pu.filter=XJr;var Kg=(e,t={})=>Object.assign({},e,t),eZr=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return pu;let t=pu;return Object.assign((n,o,i={})=>t(n,o,Kg(e,i)),{Minimatch:class extends t.Minimatch{constructor(o,i={}){super(o,Kg(e,i))}static defaults(o){return t.defaults(Kg(e,o)).Minimatch}},AST:class extends t.AST{constructor(o,i,s={}){super(o,i,Kg(e,s))}static fromGlob(o,i={}){return t.AST.fromGlob(o,Kg(e,i))}},unescape:(n,o={})=>t.unescape(n,Kg(e,o)),escape:(n,o={})=>t.escape(n,Kg(e,o)),filter:(n,o={})=>t.filter(n,Kg(e,o)),defaults:n=>t.defaults(Kg(e,n)),makeRe:(n,o={})=>t.makeRe(n,Kg(e,o)),braceExpand:(n,o={})=>t.braceExpand(n,Kg(e,o)),match:(n,o,i={})=>t.match(n,o,Kg(e,i)),sep:t.sep,GLOBSTAR:ud})};pu.defaults=eZr;var Tut=(e,t={})=>(y5(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:put(e,{max:t.braceExpandMax}));pu.braceExpand=Tut;var tZr=(e,t={})=>new ek(e,t).makeRe();pu.makeRe=tZr;var rZr=(e,t,r={})=>{let n=new ek(t,r);return e=e.filter(o=>n.match(o)),n.options.nonull&&!e.length&&e.push(t),e};pu.match=rZr;var Sut=/[?*]|[+@!]\(.*?\)|\[|\]/,nZr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ek=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){y5(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||Cut,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=(...i)=>console.error(...i)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(i=>this.slashSplit(i));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let o=this.globParts.map((i,s,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=i[0]===""&&i[1]===""&&(i[2]==="?"||!Sut.test(i[2]))&&!Sut.test(i[3]),c=/^[a-z]:/i.test(i[0]);if(l)return[...i.slice(0,4),...i.slice(4).map(u=>this.parse(u))];if(c)return[i[0],...i.slice(1).map(u=>this.parse(u))]}return i.map(l=>this.parse(l))});if(this.debug(this.pattern,o),this.set=o.filter(i=>i.indexOf(!1)===-1),this.isWindows)for(let i=0;i<this.set.length;i++){let s=this.set[i];s[0]===""&&s[1]===""&&this.globParts[i][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 o=0;o<n.length;o++)n[o]==="**"&&(n[o]="*");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 o=n;for(;r[o+1]==="**";)o++;o!==n&&r.splice(n,o-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,o)=>{let i=n[n.length-1];return o==="**"&&i==="**"?n:o===".."&&i&&i!==".."&&i!=="."&&i!=="**"?(n.pop(),n):(n.push(o),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 o=1;o<t.length-1;o++){let i=t[o];o===1&&i===""&&t[0]===""||(i==="."||i==="")&&(r=!0,t.splice(o,1),o--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let o=t[n-1];o&&o!=="."&&o!==".."&&o!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(o))&&(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 o=-1;for(;(o=n.indexOf("**",o+1))!==-1;){let s=o;for(;n[s+1]==="**";)s++;s>o&&n.splice(o+1,s-o);let a=n[o+1],l=n[o+2],c=n[o+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(o,1);let u=n.slice(0);u[o]="**",t.push(u),o--}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 i=0;for(;(i=n.indexOf("..",i+1))!==-1;){let s=n[i-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let l=i===1&&n[i+1]==="**"?["."]:[];n.splice(i-1,2,...l),n.length===0&&n.push(""),i-=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 o=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(o){t[r]=[],t[n]=o;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let o=0,i=0,s=[],a="";for(;o<t.length&&i<r.length;)if(t[o]===r[i])s.push(a==="b"?r[i]:t[o]),o++,i++;else if(n&&t[o]==="**"&&r[i]===t[o+1])s.push(t[o]),o++;else if(n&&r[i]==="**"&&t[o]===r[i+1])s.push(r[i]),i++;else if(t[o]==="*"&&r[i]&&(this.options.dot||!r[i].startsWith("."))&&r[i]!=="**"){if(a==="b")return!1;a="a",s.push(t[o]),o++,i++}else if(r[i]==="*"&&t[o]&&(this.options.dot||!t[o].startsWith("."))&&t[o]!=="**"){if(a==="a")return!1;a="b",s.push(r[i]),o++,i++}else return!1;return t.length===r.length&&s}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let o=0;o<t.length&&t.charAt(o)==="!";o++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let o=0,i=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,m=u?3:c?0:void 0;if(typeof d=="number"&&typeof m=="number"){let[p,h]=[t[d],r[m]];p.toLowerCase()===h.toLowerCase()&&(r[m]=p,i=m,o=d)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(ud)?this.#e(t,r,n,o,i):this.#n(t,r,n,o,i)}#e(t,r,n,o,i){let s=r.indexOf(ud,i),a=r.lastIndexOf(ud),[l,c,u]=n?[r.slice(i,s),r.slice(s+1),[]]:[r.slice(i,s),r.slice(s+1,a),r.slice(a+1)];if(l.length){let y=t.slice(o,o+l.length);if(!this.#n(y,l,n,0,0))return!1;o+=l.length,i+=l.length}let d=0;if(u.length){if(u.length+o>t.length)return!1;let y=t.length-u.length;if(this.#n(t,u,n,y,0))d=u.length;else{if(t[t.length-1]!==""||o+u.length===t.length||(y--,!this.#n(t,u,n,y,0)))return!1;d=u.length+1}}if(!c.length){let y=!!d;for(let I=o;I<t.length-d;I++){let w=String(t[I]);if(y=!0,w==="."||w===".."||!this.options.dot&&w.startsWith("."))return!1}return n||y}let m=[[[],0]],p=m[0],h=0,A=[0];for(let y of c)y===ud?(A.push(h),p=[[],0],m.push(p)):(p[0].push(y),h++);let _=m.length-1,S=t.length-d;for(let y of m)y[1]=S-(A[_--]+y[0].length);return!!this.#t(t,m,o,0,n,0,!!d)}#t(t,r,n,o,i,s,a){let l=r[o];if(!l){for(let d=n;d<t.length;d++){a=!0;let m=t[d];if(m==="."||m===".."||!this.options.dot&&m.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(t.slice(0,n+c.length),c,i,n,0)&&s<this.maxGlobstarRecursion){let p=this.#t(t,r,n+c.length,o+1,i,s+1,a);if(p!==!1)return p}let m=t[n];if(m==="."||m===".."||!this.options.dot&&m.startsWith("."))return!1;n++}return i||null}#n(t,r,n,o,i){let s,a,l,c;for(s=o,a=i,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===ud)return!1;let m;if(typeof u=="string"?(m=d===u,this.debug("string match",u,d,m)):(m=u.test(d),this.debug("pattern match",u,d,m)),!m)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 Tut(this.pattern,this.options)}parse(t){y5(t);let r=this.options;if(t==="**")return ud;if(t==="")return"";let n,o=null;(n=t.match(UJr))?o=r.dot?HJr:GJr:(n=t.match(NJr))?o=(r.nocase?r.dot?MJr:BJr:r.dot?OJr:DJr)(n[1]):(n=t.match($Jr))?o=(r.nocase?r.dot?YJr:qJr:r.dot?zJr:VJr)(n):(n=t.match(kJr))?o=r.dot?PJr:LJr:(n=t.match(FJr))&&(o=QJr);let i=cw.fromGlob(t,this.options).toMMPattern();return o&&typeof i=="object"&&Reflect.defineProperty(i,"test",{value:o}),i}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?KJr:r.dot?JJr:ZJr,o=new Set(r.nocase?["i"]:[]),i=t.map(l=>{let c=l.map(d=>{if(d instanceof RegExp)for(let m of d.flags.split(""))o.add(m);return typeof d=="string"?nZr(d):d===ud?ud:d._src});c.forEach((d,m)=>{let p=c[m+1],h=c[m-1];d!==ud||h===ud||(h===void 0?p!==void 0&&p!==ud?c[m+1]="(?:\\/|"+n+"\\/)?"+p:c[m]=n:p===void 0?c[m-1]=h+"(?:\\/|\\/"+n+")?":p!==ud&&(c[m-1]=h+"(?:\\/|\\/"+n+"\\/)"+p,c[m+1]=ud))});let u=c.filter(d=>d!==ud);if(this.partial&&u.length>=1){let d=[];for(let m=1;m<=u.length;m++)d.push(u.slice(0,m).join("/"));return"(?:"+d.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];i="^"+s+i+a+"$",this.partial&&(i="^(?:\\/|"+s+i.slice(1,-1)+a+")$"),this.negate&&(i="^(?!"+i+").+$");try{this.regexp=new RegExp(i,[...o].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 o=this.slashSplit(t);this.debug(this.pattern,"split",o);let i=this.set;this.debug(this.pattern,"set",i);let s=o[o.length-1];if(!s)for(let a=o.length-2;!s&&a>=0;a--)s=o[a];for(let a of i){let l=o;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 pu.defaults(t).Minimatch}};pu.AST=cw;pu.Minimatch=ek;pu.escape=dbe;pu.unescape=IT;var xut=j(S5(),1);lr();Pe();Re();$d();import{readFile as Iut}from"fs/promises";import{existsSync as pbe,readdirSync as oZr,statSync as iZr}from"fs";import{join as mbe,relative as wut}from"path";import{homedir as sZr}from"os";function vut(e){try{let t=(0,xut.default)(e),r=t.data.paths,n=[];return typeof r=="string"?n=r.split(",").map(o=>o.trim()).filter(Boolean):Array.isArray(r)&&(n=r.filter(o=>typeof o=="string")),{paths:n,content:t.content.trim()}}catch(t){return Se(t),{paths:[],content:e.trim()}}}function aZr(e,t){return t.length===0?!0:t.some(r=>{try{return pu(e,r,{matchBase:!0,dot:!0})}catch(n){return Se(n),!1}})}function fbe(e){let t=[];try{if(!pbe(e))return t;let r=oZr(e);for(let n of r){let o=mbe(e,n),i=iZr(o);i.isDirectory()?t.push(...fbe(o)):i.isFile()&&n.endsWith(".md")&&t.push(o)}}catch(r){Se(r)}return t}async function KJ(){let e=[];try{let t=mbe(sZr(),wn,"rules");if(pbe(t)){let r=fbe(t);for(let n of r)try{let o=await Iut(n,"utf-8"),{paths:i,content:s}=vut(o);i.length>0&&e.push({filePath:n,content:s,paths:i,isProjectRule:!1})}catch(o){Se(o)}}}catch(t){Se(t)}try{let t=mbe(Ne(),wn,"rules");if(pbe(t)){let r=fbe(t);for(let n of r)try{let o=await Iut(n,"utf-8"),{paths:i,content:s}=vut(o);i.length>0&&e.push({filePath:wut(Ne(),n),content:s,paths:i,isProjectRule:!0})}catch(o){Se(o)}}}catch(t){Se(t)}return e}function Rut(e,t){e=OK(e);let r=OK(Ne()),n=e.startsWith(r)?wut(r,e):e;return t.filter(o=>aZr(n,o.paths))}function Nut(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}):
655
+ `)}function Mat(e){try{let t=EWr(e),r=t.readSync();return t.closeSync(),r===null}catch(t){return Se(`Error checking directory: ${t}`),!1}}Pe();function AT(){let e=Rn();e.hasCompletedProjectOnboarding||pi({...e,hasCompletedProjectOnboarding:!0})}function BSe({workspaceDir:e}){let r=!Rn().hasCompletedProjectOnboarding;if(!r)return null;let n=vWr(xWr(e,Zo)),o=Mat(e),i=!n&&!o,s=MM.isEnabled&&!Gr().shiftEnterKeyBindingInstalled,a=re();return Qa.createElement(x,{flexDirection:"column",gap:1,padding:1,paddingBottom:0},r&&Qa.createElement(Qa.Fragment,null,Qa.createElement(T,{color:a.secondaryText},"Tips for getting started:"),Qa.createElement(uu,{children:[]},(()=>{let l=[];return o&&l.push(Qa.createElement(uu.Item,{key:"workspace"},Qa.createElement(T,{color:a.secondaryText},"Ask ",tt," to create a new app or clone a repository."))),i&&l.push(Qa.createElement(uu.Item,{key:"claudemd"},Qa.createElement(T,{color:a.secondaryText},"Run ",Qa.createElement(T,{color:a.text},"/init")," to create a",Zo," file with instructions for Hawa code."))),s&&l.push(Qa.createElement(uu.Item,{key:"terminal"},Qa.createElement(T,{color:a.secondaryText},"Run ",Qa.createElement(T,{color:a.text},"/terminal-setup"),Qa.createElement(T,{bold:!1}," to set up terminal integration")))),l.push(Qa.createElement(uu.Item,{key:"questions"},Qa.createElement(T,{color:a.secondaryText},"Ask ",tt," questions about your codebase."))),l.push(Qa.createElement(uu.Item,{key:"changes"},Qa.createElement(T,{color:a.secondaryText},"Ask ",tt," to implement changes to your codebase."))),l})())),e===wWr()&&Qa.createElement(T,{color:re().warning},"Note: You have launched ",Qa.createElement(T,{bold:!0},tt)," in your home directory. For the best experience, launch it in a project directory instead."))}var $M=j(ie(),1);var HM=j(ie(),1);var u5=j(ie(),1);function MSe({isFocused:e,isSelected:t,smallPointer:r,children:n}){let{styles:o}=Di("Select");return u5.default.createElement(x,{...o.option({isFocused:e})},e&&u5.default.createElement(T,{...o.focusIndicator()},r?rr.triangleDownSmall:rr.pointer),u5.default.createElement(T,{...o.label({isFocused:e,isSelected:t})},n),t&&u5.default.createElement(T,{...o.selectedIndicator()},rr.tick))}var Wp=j(ie(),1);import{isDeepStrictEqual as RWr}from"node:util";var d5=class extends Map{first;constructor(t){let r=[],n,o,i=0;for(let s of t){let a={...s,previous:o,next:void 0,index:i};o&&(o.next=a),n||=a;let l="value"in s?s.value:kSe(s);r.push([l,a]),i++,o=a}super(r),this.first=n}};var NWr=(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;for(;n&&!("value"in n);)n=n.next;if(!n)return e;if(!(n.index>=e.visibleToIndex))return{...e,focusedValue:n.value};let i=Math.min(e.optionMap.size,e.visibleToIndex+1),s=i-e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:s,visibleToIndex:i}}case"focus-previous-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.previous;for(;n&&!("value"in n);)n=n.previous;if(!n)return e;if(!(n.index<=e.visibleFromIndex))return{...e,focusedValue:n.value};let i=Math.max(0,e.visibleFromIndex-1),s=i+e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:i,visibleToIndex:s}}case"select-focused-option":return{...e,previousValue:e.value,value:e.focusedValue};case"reset":return t.state;case"set-focus":return{...e,focusedValue:t.value}}},LSe=e=>e.flatMap(t=>{if("options"in t){let r=LSe(t.options),n=r.flatMap(i=>"value"in i?i.value:[]);return[...t.header!==void 0?[{header:t.header,optionValues:n}]:[],...r]}return t}),kat=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=LSe(r),o=typeof e=="number"?Math.min(e,n.length):n.length,i=new d5(n),s=i.first,a=s&&"value"in s?s.value:void 0;return{optionMap:i,visibleOptionCount:o,focusedValue:a,visibleFromIndex:0,visibleToIndex:o,previousValue:t,value:t}},PSe=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n,onFocus:o,focusValue:i})=>{let s=LSe(t),[a,l]=(0,Wp.useReducer)(NWr,{visibleOptionCount:e,defaultValue:r,options:t},kat),[c,u]=(0,Wp.useState)(s);s!==c&&!RWr(s,c)&&(l({type:"reset",state:kat({visibleOptionCount:e,defaultValue:r,options:t})}),u(s));let d=(0,Wp.useCallback)(()=>{l({type:"focus-next-option"})},[]),m=(0,Wp.useCallback)(()=>{l({type:"focus-previous-option"})},[]),p=(0,Wp.useCallback)(()=>{l({type:"select-focused-option"})},[]),h=(0,Wp.useMemo)(()=>s.map((A,_)=>({...A,index:_})).slice(a.visibleFromIndex,a.visibleToIndex),[s,a.visibleFromIndex,a.visibleToIndex]);return(0,Wp.useEffect)(()=>{a.value&&a.previousValue!==a.value&&n?.(a.value)},[a.previousValue,a.value,t,n]),(0,Wp.useEffect)(()=>{a.focusedValue&&o?.(a.focusedValue)},[a.focusedValue,o]),(0,Wp.useEffect)(()=>{i&&l({type:"set-focus",value:i})},[i]),{focusedValue:a.focusedValue,visibleFromIndex:a.visibleFromIndex,visibleToIndex:a.visibleToIndex,value:a.value,visibleOptions:h,focusNextOption:d,focusPreviousOption:m,selectFocusedOption:p}};var FSe=({isDisabled:e=!1,state:t})=>{pt((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};var kSe=e=>`HEADER-${e.optionValues.join(",")}`;function Vb({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a}){let l=PSe({visibleOptionCount:t,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a});FSe({isDisabled:e,state:l});let{styles:c}=Di("Select");return HM.default.createElement(x,{...c.container()},l.visibleOptions.map(u=>{let d="value"in u?u.value:kSe(u),m=!e&&l.focusedValue!==void 0&&("value"in u?l.focusedValue===u.value:u.optionValues.includes(l.focusedValue)),p=!!l.value&&("value"in u?l.value===u.value:u.optionValues.includes(l.value)),h="header"in u,A="label"in u?u.label:u.header,_=A;if(r&&A.includes(r)){let S=A.indexOf(r);_=HM.default.createElement(HM.default.Fragment,null,A.slice(0,S),HM.default.createElement(T,{...c.highlightedText()},r),A.slice(S+r.length))}return HM.default.createElement(MSe,{key:d,isFocused:m,isSelected:p,smallPointer:h},_)}))}function Lat({onDone:e}){return pt((t,r)=>{(r.ctrl&&(t==="c"||t==="d")||r.escape)&&e()}),$M.default.createElement(x,{flexDirection:"column",borderStyle:"round",padding:1,borderColor:re().secondaryBorder},$M.default.createElement(x,{marginBottom:1,flexDirection:"column"},$M.default.createElement(T,{bold:!0},"You've spent $5 this session.")),$M.default.createElement(x,null,$M.default.createElement(Vb,{options:[{value:"ok",label:"Got it, thanks!"}],onChange:e})))}var un=j(ie(),1),Jt=j(ie(),1);var Wd=j(ie(),1);Pe();lr();cE();var BWr="2.4.53",uE={VERSION:BWr,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"};var GSe=46,Qat=["(\u2740\u2579\u25E1\u2579)","(\u25D5\u072B\u25D5)","\u239D(\u25D5u\u25D5)\u23A0","\u10DA(\u25C9\u25DE\u0C6A\u25DF\u25C9 )\u10DA","(\xB4\u25C9\u203F\u25C9\uFF40)","\u0E01\u0E47\u0295\u2022\u0361\u1D25\u2022\u0294 \u0E01\u0E49","\uFF0F/( \u25D5\u203F\u203F\u25D5 )\uFF3C"];function PJ({isDefaultModel:e=!1}){let t=Math.max(GSe,Ne().length+12),r=re(),n=Qat[Math.floor(Math.random()*Qat.length)];return Wd.createElement(x,{flexDirection:"column"},Wd.createElement(x,{flexDirection:"column",gap:1,paddingLeft:1,width:"100%"},Wd.createElement(T,null,Wd.createElement(T,null,n)," Welcome to"," ",Wd.createElement(T,{bold:!0},tt),Wd.createElement(T,{color:r.secondaryText}," v",uE.VERSION)),Wd.createElement(Wd.Fragment,null,Wd.createElement(x,{paddingLeft:2,flexDirection:"column",gap:1},Wd.createElement(T,{color:r.secondaryText,italic:!0},"/help for help"),Wd.createElement(T,{color:r.secondaryText},"cwd: ",Ne()),Wd.createElement(T,{color:r.secondaryText},"model: ",oo.getConfig().routing.MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A"),Wd.createElement(T,{color:r.secondaryText},"small fast model: ",oo.getConfig().routing.SMALL_FAST_MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A")))))}var x_=j(ie(),1);Re();var x6=j(ie(),1);import{randomUUID as Wh}from"crypto";fs();Re();Zt();lr();Re();Pe();import{existsSync as Kb,readdirSync as lZr,statSync as cZr}from"fs";import{join as vT,relative as uZr}from"path";import{homedir as Out}from"os";import{platform as dZr}from"process";import{readFile as xT}from"fs/promises";lr();af();hr();import{join as QWr,sep as UWr}from"path";function jd(){if(!du())return!1;try{let e=rt();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function jp(){return(QWr(Ne(),".hcode","team-memory")+UWr).normalize("NFC")}function jg(e){let t=e.normalize("NFC"),r=jp();return t.startsWith(r)}af();var But=j(S5(),1);Ro();var ibe=(e,t,r)=>{let n=e instanceof RegExp?sut(e,r):e,o=t instanceof RegExp?sut(t,r):t,i=n!==null&&o!=null&&ZKr(n,o,r);return i&&{start:i[0],end:i[1],pre:r.slice(0,i[0]),body:r.slice(i[0]+n.length,i[1]),post:r.slice(i[1]+o.length)}},sut=(e,t)=>{let r=t.match(e);return r?r[0]:null},ZKr=(e,t,r)=>{let n,o,i,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=[],i=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 o=n.pop(),o!==void 0&&o<i&&(i=o,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[i,s])}return a};var aut="\0SLASH"+Math.random()+"\0",lut="\0OPEN"+Math.random()+"\0",lbe="\0CLOSE"+Math.random()+"\0",cut="\0COMMA"+Math.random()+"\0",uut="\0PERIOD"+Math.random()+"\0",XKr=new RegExp(aut,"g"),eJr=new RegExp(lut,"g"),tJr=new RegExp(lbe,"g"),rJr=new RegExp(cut,"g"),nJr=new RegExp(uut,"g"),oJr=/\\\\/g,iJr=/\\{/g,sJr=/\\}/g,aJr=/\\,/g,lJr=/\\\./g,cJr=1e5,uJr=4e6;function sbe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function dJr(e){return e.replace(oJr,aut).replace(iJr,lut).replace(sJr,lbe).replace(aJr,cut).replace(lJr,uut)}function pJr(e){return e.replace(XKr,"\\").replace(eJr,"{").replace(tJr,"}").replace(rJr,",").replace(nJr,".")}function dut(e){if(!e)return[""];let t=[],r=ibe("{","}",e);if(!r)return e.split(",");let{pre:n,body:o,post:i}=r,s=n.split(",");s[s.length-1]+="{"+o+"}";let a=dut(i);return i.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function put(e,t={}){if(!e)return[];let{max:r=cJr,maxLength:n=uJr}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),abe(dJr(e),r,n,!0).map(pJr)}function mJr(e){return"{"+e+"}"}function fJr(e){return/^-?0\d/.test(e)}function gJr(e,t){return e<=t}function hJr(e,t){return e>=t}function b5(e,t,r,n,o,i){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(!(i&&!u)){if(a+u.length>o)return s;s.push(u),a+=u.length}}return s}function AJr(e,t,r,n){let o=e.split(/\.\./),i=[];if(o[0]===void 0||o[1]===void 0)return i;let s=sbe(o[0]),a=sbe(o[1]),l=Math.max(o[0].length,o[1].length),c=o.length===3&&o[2]!==void 0?Math.max(Math.abs(sbe(o[2])),1):1,u=gJr;a<s&&(c*=-1,u=hJr);let m=o.some(fJr),p=0;for(let h=s;u(h,a)&&i.length<r;h+=c){let A;if(t)A=String.fromCharCode(h),A==="\\"&&(A="");else if(A=String(h),m){let _=l-A.length;if(_>0){let S=new Array(_+1).join("0");h<0?A="-"+S+A.slice(1):A=S+A}}if(p+A.length>n)break;i.push(A),p+=A.length}return i}function abe(e,t,r,n){let o=[""],i=!1,s=!0;for(;;){let a=ibe("{","}",e);if(!a)return b5(o,e,[""],t,r,i);let l=a.pre;if(/\$$/.test(l)){if(o=b5(o,l+"{"+a.body+"}",[""],t,r,i&&!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,m=a.body.indexOf(",")>=0;if(!d&&!m){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+lbe+a.post,n=!0;continue}return b5(o,l+"{"+a.body+"}"+a.post,[""],t,r,i)}s&&(i=n&&!d,s=!1);let p;if(d)p=AJr(a.body,u,t,r);else{let h=dut(a.body);if(h.length===1&&h[0]!==void 0&&(h=abe(h[0],t,r,!1).map(mJr),h.length===1)){if(o=b5(o,l+h[0],[""],t,r,i&&!a.post.length),!a.post.length)break;e=a.post;continue}let A=i&&!a.post.length&&!l;for(let S=0;A&&S<o.length;S++)o[S]&&(A=!1);p=[];let _=0;e:for(let S=0;S<h.length;S++){let y=abe(h[S],t,r,!1);for(let I=0;I<y.length;I++){let w=y[I];if(!(A&&!w)){if(p.length>=t||_+w.length>r)break e;p.push(w),_+=w.length}}}}if(o=b5(o,l,p,t,r,i&&!a.post.length),!a.post.length)break;e=a.post}return o}var y5=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var _Jr={"[: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]},C5=e=>e.replace(/[[\]\\-]/g,"\\$&"),EJr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),mut=e=>e.join(""),fut=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],o=[],i=r+1,s=!1,a=!1,l=!1,c=!1,u=r,d="";e:for(;i<e.length;){let A=e.charAt(i);if((A==="!"||A==="^")&&i===r+1){c=!0,i++;continue}if(A==="]"&&s&&!l){u=i+1;break}if(s=!0,A==="\\"&&!l){l=!0,i++;continue}if(A==="["&&!l){for(let[_,[S,y,I]]of Object.entries(_Jr))if(e.startsWith(_,i)){if(d)return["$.",!1,e.length-r,!0];i+=_.length,I?o.push(S):n.push(S),a=a||y;continue e}}if(l=!1,d){A>d?n.push(C5(d)+"-"+C5(A)):A===d&&n.push(C5(A)),d="",i++;continue}if(e.startsWith("-]",i+1)){n.push(C5(A+"-")),i+=2;continue}if(e.startsWith("-",i+1)){d=A,i+=2;continue}n.push(C5(A)),i++}if(u<i)return["",!1,0,!1];if(!n.length&&!o.length)return["$.",!1,e.length-r,!0];if(o.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!c){let A=n[0].length===2?n[0].slice(-1):n[0];return[EJr(A),!1,u-r,!1]}let m="["+(c?"^":"")+mut(n)+"]",p="["+(c?"":"^")+mut(o)+"]";return[n.length&&o.length?"("+m+"|"+p+")":n.length?m:p,a,u-r,!0]};var IT=(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 Jp,SJr=new Set(["!","?","+","*","@"]),cbe=e=>SJr.has(e),gut=e=>cbe(e.type),bJr=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),yJr=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),CJr=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),hut=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),TJr="(?!(?:^|/)\\.\\.?(?:$|/))",jJ="(?!\\.)",IJr=new Set(["[","."]),vJr=new Set(["..","."]),xJr=new Set("().*{}+?[]^$\\!"),wJr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ube="[^/]",Aut=ube+"*?",_ut=ube+"+?",RJr=0,cw=class{type;#e;#t;#n=!1;#r=[];#i;#o;#l;#s=!1;#a;#d;#m=!1;id=++RJr;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(t,r,n={}){this.type=t,t&&(this.#t=!0),this.#i=r,this.#e=this.#i?this.#i.#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.#o=this.#i?this.#i.#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("")}#p(){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.#i;for(;n;){for(let o=r.#o+1;!n.type&&o<n.#r.length;o++)for(let i of t.#r){if(typeof i=="string")throw new Error("string part in extglob AST??");i.copyIn(n.#r[o])}r=n,n=r.#i}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof Jp&&r.#i===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.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#o===0)return!0;let t=this.#i;for(let r=0;r<this.#o;r++){let n=t.#r[r];if(!(n instanceof Jp&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#r.length:0;return this.#o===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new Jp(this.type,t);for(let n of this.#r)r.copyIn(n);return r}static#c(t,r,n,o,i){let s=o.maxExtglobRecursion??2,a=!1,l=!1,c=-1,u=!1;if(r.type===null){let A=n,_="";for(;A<t.length;){let S=t.charAt(A++);if(a||S==="\\"){a=!a,_+=S;continue}if(l){A===c+1?(S==="^"||S==="!")&&(u=!0):S==="]"&&!(A===c+2&&u)&&(l=!1),_+=S;continue}else if(S==="["){l=!0,c=A,u=!1,_+=S;continue}if(!o.noext&&cbe(S)&&t.charAt(A)==="("&&i<=s){r.push(_),_="";let I=new Jp(S,r);A=Jp.#c(t,I,A,o,i+1),r.push(I);continue}_+=S}return r.push(_),A}let d=n+1,m=new Jp(null,r),p=[],h="";for(;d<t.length;){let A=t.charAt(d++);if(a||A==="\\"){a=!a,h+=A;continue}if(l){d===c+1?(A==="^"||A==="!")&&(u=!0):A==="]"&&!(d===c+2&&u)&&(l=!1),h+=A;continue}else if(A==="["){l=!0,c=d,u=!1,h+=A;continue}if(!o.noext&&cbe(A)&&t.charAt(d)==="("&&(i<=s||r&&r.#_(A))){let S=r&&r.#_(A)?0:1;m.push(h),h="";let y=new Jp(A,m);m.push(y),d=Jp.#c(t,y,d,o,i+S);continue}if(A==="|"){m.push(h),h="",p.push(m),m=new Jp(null,r);continue}if(A===")")return h===""&&r.#r.length===0&&(r.#m=!0),m.push(h),h="",r.push(...p,m),d;h+=A}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],d}#g(t){return this.#A(t,yJr)}#A(t,r=bJr){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.#_(n.type,r)}#_(t,r=CJr){return!!r.get(this.type)?.includes(t)}#h(t,r){let n=t.#r[0],o=new Jp(null,n,this.options);o.#r.push(""),n.push(o),this.#v(t,r)}#v(t,r){let n=t.#r[0];this.#r.splice(r,1,...n.#r);for(let o of n.#r)typeof o=="object"&&(o.#i=this);this.#d=void 0}#S(t){return!!hut.get(this.type)?.has(t)}#C(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.#S(r.type)}#T(t){let r=hut.get(this.type),n=t.#r[0],o=r?.get(n.type);if(!o)return!1;this.#r=n.#r;for(let i of this.#r)typeof i=="object"&&(i.#i=this);this.type=o,this.#d=void 0,this.#m=!1}static fromGlob(t,r={}){let n=new Jp(null,void 0,r);return Jp.#c(t,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,o,i]=this.toRegExpSource();if(!(o||this.#t||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(i?"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.#E(),this.#p()),!gut(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(p=>typeof p!="string"),c=this.#r.map(p=>{let[h,A,_,S]=typeof p=="string"?Jp.#y(p,this.#t,l):p.toRegExpSource(t);return this.#t=this.#t||_,this.#n=this.#n||S,h}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&vJr.has(this.#r[0]))){let h=IJr,A=r&&h.has(c.charAt(0))||c.startsWith("\\.")&&h.has(c.charAt(2))||c.startsWith("\\.\\.")&&h.has(c.charAt(4)),_=!r&&!t&&h.has(c.charAt(0));u=A?TJr:_?jJ:""}let d="";return this.isEnd()&&this.#e.#s&&this.#i?.type==="!"&&(d="(?:$|\\/)"),[u+c+d,IT(c),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",o=this.type==="!"?"(?:(?!(?:":"(?:",i=this.#b(r);if(this.isStart()&&this.isEnd()&&!i&&this.type!=="!"){let l=this.toString(),c=this;return c.#r=[l],c.type=null,c.#t=void 0,[l,IT(this.toString()),!1,!1]}let s=!n||t||r||!jJ?"":this.#b(!0);s===i&&(s=""),s&&(i=`(?:${i})(?:${s})*?`);let a="";if(this.type==="!"&&this.#m)a=(this.isStart()&&!r?jJ:"")+_ut;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?jJ:"")+Aut+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=o+i+l}return[a,IT(i),this.#t=!!this.#t,this.#n]}#E(){if(gut(this)){let t=0,r=!1;do{r=!0;for(let n=0;n<this.#r.length;n++){let o=this.#r[n];typeof o=="object"&&(o.#E(),this.#A(o)?(r=!1,this.#v(o,n)):this.#g(o)?(r=!1,this.#h(o,n)):this.#C(o)&&(r=!1,this.#T(o)))}}while(!r&&++t<10)}else for(let t of this.#r)typeof t=="object"&&t.#E();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,o,i,s]=r.toRegExpSource(t);return this.#n=this.#n||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#y(t,r,n=!1){let o=!1,i="",s=!1,a=!1;for(let l=0;l<t.length;l++){let c=t.charAt(l);if(o){o=!1,i+=(xJr.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,i+=n&&/^[*]+$/.test(t)?_ut:Aut,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?i+="\\\\":o=!0;continue}if(c==="["){let[u,d,m,p]=fut(t,l);if(m){i+=u,s=s||d,l+=m-1,r=r||p;continue}}if(c==="?"){i+=ube,r=!0;continue}i+=wJr(c)}return[i,IT(t),!!r,s]}};Jp=cw;var dbe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var pu=(e,t,r={})=>(y5(t),!r.nocomment&&t.charAt(0)==="#"?!1:new ek(t,r).match(e)),NJr=/^\*+([^+@!?*[(]*)$/,DJr=e=>t=>!t.startsWith(".")&&t.endsWith(e),OJr=e=>t=>t.endsWith(e),BJr=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),MJr=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),kJr=/^\*+\.\*+$/,LJr=e=>!e.startsWith(".")&&e.includes("."),PJr=e=>e!=="."&&e!==".."&&e.includes("."),FJr=/^\.\*+$/,QJr=e=>e!=="."&&e!==".."&&e.startsWith("."),UJr=/^\*+$/,GJr=e=>e.length!==0&&!e.startsWith("."),HJr=e=>e.length!==0&&e!=="."&&e!=="..",$Jr=/^\?+([^+@!?*[(]*)?$/,qJr=([e,t=""])=>{let r=but([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},YJr=([e,t=""])=>{let r=yut([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},zJr=([e,t=""])=>{let r=yut([e]);return t?n=>r(n)&&n.endsWith(t):r},VJr=([e,t=""])=>{let r=but([e]);return t?n=>r(n)&&n.endsWith(t):r},but=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},yut=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},Cut=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Eut={win32:{sep:"\\"},posix:{sep:"/"}},WJr=Cut==="win32"?Eut.win32.sep:Eut.posix.sep;pu.sep=WJr;var ud=Symbol("globstar **");pu.GLOBSTAR=ud;var jJr="[^/]",KJr=jJr+"*?",JJr="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",ZJr="(?:(?!(?:\\/|^)\\.).)*?",XJr=(e,t={})=>r=>pu(r,e,t);pu.filter=XJr;var Kg=(e,t={})=>Object.assign({},e,t),eZr=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return pu;let t=pu;return Object.assign((n,o,i={})=>t(n,o,Kg(e,i)),{Minimatch:class extends t.Minimatch{constructor(o,i={}){super(o,Kg(e,i))}static defaults(o){return t.defaults(Kg(e,o)).Minimatch}},AST:class extends t.AST{constructor(o,i,s={}){super(o,i,Kg(e,s))}static fromGlob(o,i={}){return t.AST.fromGlob(o,Kg(e,i))}},unescape:(n,o={})=>t.unescape(n,Kg(e,o)),escape:(n,o={})=>t.escape(n,Kg(e,o)),filter:(n,o={})=>t.filter(n,Kg(e,o)),defaults:n=>t.defaults(Kg(e,n)),makeRe:(n,o={})=>t.makeRe(n,Kg(e,o)),braceExpand:(n,o={})=>t.braceExpand(n,Kg(e,o)),match:(n,o,i={})=>t.match(n,o,Kg(e,i)),sep:t.sep,GLOBSTAR:ud})};pu.defaults=eZr;var Tut=(e,t={})=>(y5(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:put(e,{max:t.braceExpandMax}));pu.braceExpand=Tut;var tZr=(e,t={})=>new ek(e,t).makeRe();pu.makeRe=tZr;var rZr=(e,t,r={})=>{let n=new ek(t,r);return e=e.filter(o=>n.match(o)),n.options.nonull&&!e.length&&e.push(t),e};pu.match=rZr;var Sut=/[?*]|[+@!]\(.*?\)|\[|\]/,nZr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ek=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){y5(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||Cut,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=(...i)=>console.error(...i)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(i=>this.slashSplit(i));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let o=this.globParts.map((i,s,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=i[0]===""&&i[1]===""&&(i[2]==="?"||!Sut.test(i[2]))&&!Sut.test(i[3]),c=/^[a-z]:/i.test(i[0]);if(l)return[...i.slice(0,4),...i.slice(4).map(u=>this.parse(u))];if(c)return[i[0],...i.slice(1).map(u=>this.parse(u))]}return i.map(l=>this.parse(l))});if(this.debug(this.pattern,o),this.set=o.filter(i=>i.indexOf(!1)===-1),this.isWindows)for(let i=0;i<this.set.length;i++){let s=this.set[i];s[0]===""&&s[1]===""&&this.globParts[i][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 o=0;o<n.length;o++)n[o]==="**"&&(n[o]="*");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 o=n;for(;r[o+1]==="**";)o++;o!==n&&r.splice(n,o-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,o)=>{let i=n[n.length-1];return o==="**"&&i==="**"?n:o===".."&&i&&i!==".."&&i!=="."&&i!=="**"?(n.pop(),n):(n.push(o),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 o=1;o<t.length-1;o++){let i=t[o];o===1&&i===""&&t[0]===""||(i==="."||i==="")&&(r=!0,t.splice(o,1),o--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let o=t[n-1];o&&o!=="."&&o!==".."&&o!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(o))&&(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 o=-1;for(;(o=n.indexOf("**",o+1))!==-1;){let s=o;for(;n[s+1]==="**";)s++;s>o&&n.splice(o+1,s-o);let a=n[o+1],l=n[o+2],c=n[o+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(o,1);let u=n.slice(0);u[o]="**",t.push(u),o--}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 i=0;for(;(i=n.indexOf("..",i+1))!==-1;){let s=n[i-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let l=i===1&&n[i+1]==="**"?["."]:[];n.splice(i-1,2,...l),n.length===0&&n.push(""),i-=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 o=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(o){t[r]=[],t[n]=o;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let o=0,i=0,s=[],a="";for(;o<t.length&&i<r.length;)if(t[o]===r[i])s.push(a==="b"?r[i]:t[o]),o++,i++;else if(n&&t[o]==="**"&&r[i]===t[o+1])s.push(t[o]),o++;else if(n&&r[i]==="**"&&t[o]===r[i+1])s.push(r[i]),i++;else if(t[o]==="*"&&r[i]&&(this.options.dot||!r[i].startsWith("."))&&r[i]!=="**"){if(a==="b")return!1;a="a",s.push(t[o]),o++,i++}else if(r[i]==="*"&&t[o]&&(this.options.dot||!t[o].startsWith("."))&&t[o]!=="**"){if(a==="a")return!1;a="b",s.push(r[i]),o++,i++}else return!1;return t.length===r.length&&s}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let o=0;o<t.length&&t.charAt(o)==="!";o++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let o=0,i=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,m=u?3:c?0:void 0;if(typeof d=="number"&&typeof m=="number"){let[p,h]=[t[d],r[m]];p.toLowerCase()===h.toLowerCase()&&(r[m]=p,i=m,o=d)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(ud)?this.#e(t,r,n,o,i):this.#n(t,r,n,o,i)}#e(t,r,n,o,i){let s=r.indexOf(ud,i),a=r.lastIndexOf(ud),[l,c,u]=n?[r.slice(i,s),r.slice(s+1),[]]:[r.slice(i,s),r.slice(s+1,a),r.slice(a+1)];if(l.length){let y=t.slice(o,o+l.length);if(!this.#n(y,l,n,0,0))return!1;o+=l.length,i+=l.length}let d=0;if(u.length){if(u.length+o>t.length)return!1;let y=t.length-u.length;if(this.#n(t,u,n,y,0))d=u.length;else{if(t[t.length-1]!==""||o+u.length===t.length||(y--,!this.#n(t,u,n,y,0)))return!1;d=u.length+1}}if(!c.length){let y=!!d;for(let I=o;I<t.length-d;I++){let w=String(t[I]);if(y=!0,w==="."||w===".."||!this.options.dot&&w.startsWith("."))return!1}return n||y}let m=[[[],0]],p=m[0],h=0,A=[0];for(let y of c)y===ud?(A.push(h),p=[[],0],m.push(p)):(p[0].push(y),h++);let _=m.length-1,S=t.length-d;for(let y of m)y[1]=S-(A[_--]+y[0].length);return!!this.#t(t,m,o,0,n,0,!!d)}#t(t,r,n,o,i,s,a){let l=r[o];if(!l){for(let d=n;d<t.length;d++){a=!0;let m=t[d];if(m==="."||m===".."||!this.options.dot&&m.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(t.slice(0,n+c.length),c,i,n,0)&&s<this.maxGlobstarRecursion){let p=this.#t(t,r,n+c.length,o+1,i,s+1,a);if(p!==!1)return p}let m=t[n];if(m==="."||m===".."||!this.options.dot&&m.startsWith("."))return!1;n++}return i||null}#n(t,r,n,o,i){let s,a,l,c;for(s=o,a=i,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===ud)return!1;let m;if(typeof u=="string"?(m=d===u,this.debug("string match",u,d,m)):(m=u.test(d),this.debug("pattern match",u,d,m)),!m)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 Tut(this.pattern,this.options)}parse(t){y5(t);let r=this.options;if(t==="**")return ud;if(t==="")return"";let n,o=null;(n=t.match(UJr))?o=r.dot?HJr:GJr:(n=t.match(NJr))?o=(r.nocase?r.dot?MJr:BJr:r.dot?OJr:DJr)(n[1]):(n=t.match($Jr))?o=(r.nocase?r.dot?YJr:qJr:r.dot?zJr:VJr)(n):(n=t.match(kJr))?o=r.dot?PJr:LJr:(n=t.match(FJr))&&(o=QJr);let i=cw.fromGlob(t,this.options).toMMPattern();return o&&typeof i=="object"&&Reflect.defineProperty(i,"test",{value:o}),i}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?KJr:r.dot?JJr:ZJr,o=new Set(r.nocase?["i"]:[]),i=t.map(l=>{let c=l.map(d=>{if(d instanceof RegExp)for(let m of d.flags.split(""))o.add(m);return typeof d=="string"?nZr(d):d===ud?ud:d._src});c.forEach((d,m)=>{let p=c[m+1],h=c[m-1];d!==ud||h===ud||(h===void 0?p!==void 0&&p!==ud?c[m+1]="(?:\\/|"+n+"\\/)?"+p:c[m]=n:p===void 0?c[m-1]=h+"(?:\\/|\\/"+n+")?":p!==ud&&(c[m-1]=h+"(?:\\/|\\/"+n+"\\/)"+p,c[m+1]=ud))});let u=c.filter(d=>d!==ud);if(this.partial&&u.length>=1){let d=[];for(let m=1;m<=u.length;m++)d.push(u.slice(0,m).join("/"));return"(?:"+d.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];i="^"+s+i+a+"$",this.partial&&(i="^(?:\\/|"+s+i.slice(1,-1)+a+")$"),this.negate&&(i="^(?!"+i+").+$");try{this.regexp=new RegExp(i,[...o].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 o=this.slashSplit(t);this.debug(this.pattern,"split",o);let i=this.set;this.debug(this.pattern,"set",i);let s=o[o.length-1];if(!s)for(let a=o.length-2;!s&&a>=0;a--)s=o[a];for(let a of i){let l=o;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 pu.defaults(t).Minimatch}};pu.AST=cw;pu.Minimatch=ek;pu.escape=dbe;pu.unescape=IT;var xut=j(S5(),1);lr();Pe();Re();$d();import{readFile as Iut}from"fs/promises";import{existsSync as pbe,readdirSync as oZr,statSync as iZr}from"fs";import{join as mbe,relative as wut}from"path";import{homedir as sZr}from"os";function vut(e){try{let t=(0,xut.default)(e),r=t.data.paths,n=[];return typeof r=="string"?n=r.split(",").map(o=>o.trim()).filter(Boolean):Array.isArray(r)&&(n=r.filter(o=>typeof o=="string")),{paths:n,content:t.content.trim()}}catch(t){return Se(t),{paths:[],content:e.trim()}}}function aZr(e,t){return t.length===0?!0:t.some(r=>{try{return pu(e,r,{matchBase:!0,dot:!0})}catch(n){return Se(n),!1}})}function fbe(e){let t=[];try{if(!pbe(e))return t;let r=oZr(e);for(let n of r){let o=mbe(e,n),i=iZr(o);i.isDirectory()?t.push(...fbe(o)):i.isFile()&&n.endsWith(".md")&&t.push(o)}}catch(r){Se(r)}return t}async function KJ(){let e=[];try{let t=mbe(sZr(),wn,"rules");if(pbe(t)){let r=fbe(t);for(let n of r)try{let o=await Iut(n,"utf-8"),{paths:i,content:s}=vut(o);i.length>0&&e.push({filePath:n,content:s,paths:i,isProjectRule:!1})}catch(o){Se(o)}}}catch(t){Se(t)}try{let t=mbe(Ne(),wn,"rules");if(pbe(t)){let r=fbe(t);for(let n of r)try{let o=await Iut(n,"utf-8"),{paths:i,content:s}=vut(o);i.length>0&&e.push({filePath:wut(Ne(),n),content:s,paths:i,isProjectRule:!0})}catch(o){Se(o)}}}catch(t){Se(t)}return e}function Rut(e,t){e=OK(e);let r=OK(Ne()),n=e.startsWith(r)?wut(r,e):e;return t.filter(o=>aZr(n,o.paths))}function Nut(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}):
656
656
 
657
657
  ${r.content}`}).join(`
658
658
 
@@ -748,7 +748,7 @@ data: ${JSON.stringify(F)}
748
748
  `);a=O.pop()||"";for(let F of O){let U=F.trim();if(!(!U||U==="data: [DONE]"))if(U.startsWith("data: ")){let P=U.slice(6);try{let Y=JSON.parse(P);w(Y)}catch(Y){this.logger&&this.logger.error({err:Y,line:U},"Failed to parse Gemini SSE chunk")}}else try{let P=JSON.parse(U);w(P)}catch{}}};(async()=>{try{for(;;){let{value:O,done:F}=await s.read();if(F)break;a+=n.decode(O,{stream:!0}),N()}I()}catch(O){i.error(O)}})()}})}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(i=>{if(i.text&&n.push({type:"text",text:i.text}),i.functionCall){let s=`toolu_${Ck()}`,a=i.functionCall.thoughtSignature||i.functionCall.thought_signature||null;n.push({type:"tool_use",id:s,name:i.functionCall.name,input:i.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:`
749
749
 
750
750
  [Search queries used: ${r.groundingMetadata.webSearchQueries.join(", ")}]`}));let o={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(i=>i.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:o},"Conversion complete, final Anthropic response"),o}catch{throw Rnn(`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"}}},T0e=new C0e;var Vbt=j(qbt(),1);hr();fs();function LA(e){return e?typeof e.entries=="function"?Object.fromEntries(e.entries()):{...e}:{}}function Ybt(e){let t=String(e?.["x-thinking-level"]??"medium").toLowerCase();return["off","low","medium","high"].includes(t)?t:"medium"}function $En(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t}}function qEn(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t,summary:"auto"}}function YEn(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 E3(e,t,r){vV(t,e),xV(t,YEn(e,r),r)}function d2(e){let t=[],r=e.getReader(),n,o=new Promise(l=>n=l),i=!1,s=()=>{i||(i=!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:o}}function S3(e){let t=new Headers(e);return t.delete("content-encoding"),t.delete("content-length"),t.delete("transfer-encoding"),t}function Zve(e,t,r,n,o){let i;try{i={type:"error",error:{type:"api_error",message:JSON.parse(o).error?.message??`${e}: ${n}`,code:`${t}_${r}_ERROR`}}}catch{i={type:"error",error:{type:"api_error",message:`${e}: ${n}`,code:`${t}_${r}_ERROR`}}}return new Response(JSON.stringify(i),{status:r,statusText:n,headers:{"Content-Type":"application/json"}})}var zbt=["/v1/messages"];function Xve(e){let t;try{typeof e=="string"?t=new Zw(e):e instanceof Zw?t=e:t=new Zw(e.url)}catch{return""}let r=t.pathname;for(let n of zbt){let o=r.indexOf(n);if(o!==-1)return t.origin+r.slice(0,o)}return t.origin}function Dte(e,t){let r=typeof e=="string"?e:e instanceof Zw?e.toString():e.url,n;try{n=new Zw(r).pathname}catch{return!1}return zbt.some(o=>n.includes(o))&&(t.method==="POST"||t.method==="post")}function zEn(e){return async(t,r)=>{if(!Dte(t,r))return e(t,r);let n=JSON.parse(r.body),o=await OX.transformRequestOut(n),i=Xve(t)+"/chat/completions",s=LA(r.headers),a=s.authorization??s.Authorization??"";$En(o,Ybt(s));let l=await e(i,{method:"POST",headers:{"Content-Type":"application/json",Authorization:a},body:JSON.stringify(o),signal:r.signal});if(!l.ok){let _=await l.text();return te(`OpenAI Chat Completions API error: ${l.status}`,{url:i,errorResponse:_}),Zve("OpenAI Chat Completions API error","OPENROUTER",l.status,l.statusText,_)}let c=n.stream===!0,u=s["x-agent-id"],d={request:{url:i,method:r.method,headers:s,body:n},response:{status:l.status,statusText:l.statusText,headers:LA(l.headers)},openai:{request:{body:o},response:{}}};if(!c){let _=await l.text(),S=new Response(_,{status:l.status,statusText:l.statusText,headers:S3(l.headers)}),y=await OX.transformResponseIn(S,n),I=await y.text();try{E3({...d,openai:{...d.openai,response:{body:JSON.parse(_)}},response:{...d.response,body:JSON.parse(I)}},u)}catch(w){te("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u975E\u6D41\u5F0F):",w)}return new Response(I,{status:y.status,statusText:y.statusText,headers:y.headers})}let m=d2(l.body),p=new Response(m.stream,{status:l.status,statusText:l.statusText,headers:S3(l.headers)}),h=await OX.transformResponseIn(p,n),A=d2(h.body);return Promise.all([m.done,A.done]).then(async([_,S])=>{try{E3({...d,openai:{...d.openai,response:{body:await Spt(_)}},response:{...d.response,body:await d4(S)}},u)}catch(y){te("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u6D41\u5F0F):"+y?.stack)}}).catch(_=>te("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Chat):"+_)),new Response(A.stream,{status:h.status,statusText:h.statusText,headers:h.headers})}}function VEn(e){return async(t,r)=>{if(!Dte(t,r))return e(t,r);let n=JSON.parse(r.body),o=await BX.transformRequestOut(n),i=LA(r.headers);qEn(o,Ybt(i));let s=JSON.stringify(o),l=Xve(t)+"/responses",c=i.authorization??i.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 y=await u.text();return te(`OpenAI Responses API error: ${u.status} ${u.statusText}`,{url:l,status:u.status,errorResponse:y}),Zve("OpenAI Responses API error","RESPONSES",u.status,u.statusText,y)}let d=n.stream===!0,m=i["x-agent-id"],p={request:{url:l,method:r.method,headers:i,body:n},response:{status:u.status,statusText:u.statusText,headers:LA(u.headers)},openai:{request:{body:o},response:{}}};if(!d){let y=await u.text(),I=new Response(y,{status:u.status,statusText:u.statusText,headers:S3(u.headers)}),w=await BX.transformResponseIn(I,n),N=await w.text();try{E3({...p,openai:{...p.openai,response:{body:JSON.parse(y)}},response:{...p.response,body:JSON.parse(N)}},m,"responses")}catch(O){te("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u975E\u6D41\u5F0F):",O)}return new Response(N,{status:w.status,statusText:w.statusText,headers:w.headers})}let h=d2(u.body),A=new Response(h.stream,{status:u.status,statusText:u.statusText,headers:S3(u.headers)}),_=await BX.transformResponseIn(A,n),S=d2(_.body);return Promise.all([h.done,S.done]).then(async([y,I])=>{try{E3({...p,openai:{...p.openai,response:{body:await Ept(y)}},response:{...p.response,body:await d4(I)}},m,"responses")}catch(w){te("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u6D41\u5F0F):"+w?.stack)}}).catch(y=>te("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Responses):"+y)),new Response(S.stream,{status:_.status,statusText:_.statusText,headers:_.headers})}}function WEn(e){return async(t,r)=>{if(!Dte(t,r))return e(t,r);let n=JSON.parse(r.body),o=LA(r.headers),i=await T0e.transformRequestOut(n),s=JSON.stringify(i),a=Xve(t)+`/models/${n.model}:streamGenerateContent?alt=sse`,l=o.authorization??o.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(S){throw te("gemini request error:",S),S}if(!c.ok){let S=await c.text();return te(`Gemini API error response: ${c.status} ${c.statusText}`,{url:a,status:c.status,errorResponse:S}),Zve("Gemini API error","Gemini",c.status,c.statusText,S)}let u=n.stream===!0,d=o["x-agent-id"],m={request:{url:a,method:r.method,headers:LA(r.headers),body:n},response:{status:c.status,statusText:c.statusText,headers:LA(c.headers)},openai:{request:{body:i},response:{}}},p=d2(c.body),h=new Response(p.stream,{status:c.status,statusText:c.statusText,headers:S3(c.headers)}),A=await T0e.transformResponseIn(h),_=d2(A.body);return Promise.all([p.done,_.done]).then(async([S,y])=>{try{let I=u?bpt(S):JSON.parse(S),w=u?await d4(y):JSON.parse(y);E3({...m,openai:{...m.openai,response:{body:I}},response:{...m.response,body:w}},d)}catch(I){te("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Gemini):"+I?.stack)}}).catch(S=>te("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Gemini):"+S)),new Response(_.stream,{status:A.status,statusText:A.statusText,headers:A.headers})}}function jEn(e){return async(t,r)=>{if(!Dte(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 o=LA(r.headers);["1","true"].includes(String(process.env.HAWA_CODE_X_API_KEY_DISABLED??"").toLowerCase())&&(delete o["x-api-key"],delete o["X-API-Key"]),["1","true"].includes(String(process.env.HAWA_CODE_AUTH_DISABLED??"").toLowerCase())&&(delete o.authorization,delete o.Authorization),delete o["content-length"];let a=await e(t,{method:r.method,headers:o,body:n,signal:r.signal});if(!a.ok){let d=await a.text();te(`API error response: ${a.status} ${a.statusText}`,{url:typeof t=="string"?t:t instanceof Zw?t.toString():t.url,status:a.status,errorResponse:d});let m;try{let p=JSON.parse(d);m={type:"error",error:{type:"api_error",message:p.error?.message||p.message||`API error: ${a.statusText}`,code:p.error?.code||p.code||`API_${a.status}_ERROR`}},p.error?.details&&(m.error.details=p.error.details)}catch{m={type:"error",error:{type:"api_error",message:`API error: ${a.statusText}`,code:`API_${a.status}_ERROR`}}}return new Response(JSON.stringify(m),{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 Zw?t.toString():t.url,method:r.method,headers:LA(r.headers),body:JSON.parse(n)},response:{status:a.status,statusText:a.statusText,headers:LA(a.headers)}};return(async()=>{if(c){let p=await a.text();u.response.body=await d4(p)}else u.response.body=await a.json();let m=LA(r.headers)["x-agent-id"];vV(m,u),xV(m,{request:u.request.body.messages,response:u.response.body.content,usage:u.response.body?.usage})})().catch(d=>te(`\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF:
751
- Stack trace: `+d.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var Nte=null,Jve=!1;function KEn(){Nte=null,Jve=!1}Ut.on("proxy:changed",KEn);function JEn(){if(Jve)return Nte;if(Jve=!0,rt().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(Nte=new Vbt.ProxyAgent({uri:e}),jt(`[proxy] using proxy: ${e}`)),Nte}function ZEn(){let e=JEn();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function Ote(e){let t=e||process.env.API_TYPE,r=ZEn();switch(t){case"openai":return zEn(r);case"openai-responses":return VEn(r);case"gemini":return WEn(r);default:return jEn(r)}}cE();Re();Pe();Pe();var e1e="2.4.52";globalThis.MACRO={VERSION:e1e,PACKAGE_URL:`@dahawa/${Xo}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var Bte=process.env.HAWA_CODE_USER_AGENT||`${Xo}/${e1e} (${process.env.USER_TYPE})`;Re();Re();Zt();function md(e,t){let r=[],n=new Set;return e.filter(o=>o.type!=="progress"&&o.type!=="reminder").forEach(o=>{switch(o.type){case"user":{let i=ru(r);if(i?.type==="user"){r[r.length-1]=Wbt(i,o);return}r.push(o);return}case"assistant":r.push(o);return;case"insert":{let i=ru(r);i?.type==="user"&&(r[r.length-1]=XEn(i,o));return}case"path_rules":{let i=t?.pathRules;if(!i)return;let s=o.content.paths.filter(u=>!n.has(u));if(s.length===0)return;let a=s.map(u=>i.get(u)).filter(u=>u!==void 0);if(s.forEach(u=>n.add(u)),a.length===0)return;let l=Et([{type:"text",text:`<system-rules>
751
+ Stack trace: `+d.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var Nte=null,Jve=!1;function KEn(){Nte=null,Jve=!1}Ut.on("proxy:changed",KEn);function JEn(){if(Jve)return Nte;if(Jve=!0,rt().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(Nte=new Vbt.ProxyAgent({uri:e}),jt(`[proxy] using proxy: ${e}`)),Nte}function ZEn(){let e=JEn();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function Ote(e){let t=e||process.env.API_TYPE,r=ZEn();switch(t){case"openai":return zEn(r);case"openai-responses":return VEn(r);case"gemini":return WEn(r);default:return jEn(r)}}cE();Re();Pe();Pe();var e1e="2.4.53";globalThis.MACRO={VERSION:e1e,PACKAGE_URL:`@dahawa/${Xo}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var Bte=process.env.HAWA_CODE_USER_AGENT||`${Xo}/${e1e} (${process.env.USER_TYPE})`;Re();Re();Zt();function md(e,t){let r=[],n=new Set;return e.filter(o=>o.type!=="progress"&&o.type!=="reminder").forEach(o=>{switch(o.type){case"user":{let i=ru(r);if(i?.type==="user"){r[r.length-1]=Wbt(i,o);return}r.push(o);return}case"assistant":r.push(o);return;case"insert":{let i=ru(r);i?.type==="user"&&(r[r.length-1]=XEn(i,o));return}case"path_rules":{let i=t?.pathRules;if(!i)return;let s=o.content.paths.filter(u=>!n.has(u));if(s.length===0)return;let a=s.map(u=>i.get(u)).filter(u=>u!==void 0);if(s.forEach(u=>n.add(u)),a.length===0)return;let l=Et([{type:"text",text:`<system-rules>
752
752
  ${Nut(a)}
753
753
  </system-rules>`}]),c=ru(r);c?.type==="user"?r[r.length-1]=Wbt(c,l,{skipTrailingSystemReminders:!0}):r.push(l);return}}}),r}function XEn(e,t){return{...e,message:{...e.message,content:tSn(e.message.content,eSn(t.content.content))}}}function eSn(e){return`
754
754
  <system-reminder>
@@ -3301,11 +3301,11 @@ async () => {
3301
3301
  - Instructions: ${a??"(none)"}
3302
3302
  - Methods: ${l}`}).join(`
3303
3303
  `)}async function Wer(){return bso.replace("{{providers}}",await yso())}async function Cso(e){let t=[];for(let r of e){if(r.type!=="connected")continue;let n={};try{let{tools:o}=await r.client.listTools();for(let i of o)n[i.name]=async s=>q6t(r.client,i.name,s)}catch(o){console.warn(`Failed to list tools for codemode client ${r.name}:`,o);continue}t.push({name:r.name,fns:n})}return t}function jer(){let e=new Bue;return{name:"codemode",inputSchema:Sso,inputJSONSchema:{type:"object",properties:{code:{type:"string",description:"JavaScript async arrow function to execute"},timeout:{type:"number",description:"Execution timeout in seconds. Defaults to 60."}},required:["code"]},async description(t){return t?.code?"Execute JavaScript code":Wer()},async prompt(){return Wer()},userFacingName(){return"codemode"},async isEnabled(){return!0},isReadOnly(){return!1},isMcp(){return!1},needsPermissions(){return!0},async validateInput(t){return!t.code||typeof t.code!="string"?{result:!1,message:"code is required"}:{result:!0}},renderResultForAssistant(t){return t.error?`Error: ${t.error}`:iGe(t.result)},renderToolUseMessage(t){return t.code.split(`
3304
- `)[0]??"codemode"},renderToolResultMessage(t){let r=Ner(t.result);return Yv.createElement(x,{flexDirection:"column"},t.error?Yv.createElement(x,{flexDirection:"row",key:"error"},Yv.createElement(T,null," \u23BF "),Yv.createElement(T,{color:"red",key:"error-text"},`Error: ${t.error}`)):null,Yv.createElement(x,{flexDirection:"row",key:"result"},Yv.createElement(T,null," \u23BF "),Yv.createElement(T,{key:"result-text"},r)))},async*call(t,r,n){let o=r??{abortController:new AbortController,readFileTimestamps:{}},i=c0(),s=Object.keys(i),[a,l]=await Promise.all([fS(),kle().catch(()=>[])]),c=await Cso(a),u=Mue(),d={search:async h=>Ger(h,l,u,s),describe:async h=>Ver(h,l,u,Fer()),saveSnippet:async(h,A,_,S,y)=>{if(typeof A!="string"||A.length===0)throw new Error("saveSnippet: code must be a non-empty string (a function or string of snippet code)");for(let[w,N]of[["inputSchema",S],["outputSchema",y]])if(N!==void 0&&(N===null||typeof N!="object"))throw new Error(`saveSnippet: ${w} must be an object when provided`);let I={name:h,description:_,code:A,savedAt:Date.now(),connectors:s,...S!==void 0?{inputSchema:S}:{},...y!==void 0?{outputSchema:y}:{}};return Mer(I),{saved:!0,name:h}},saveOutputSchema:async(h,A,_)=>{let[S,y,I]=Array.isArray(h)?h:[h,A,_];if(typeof S!="string"||!S.includes("."))throw new Error('saveOutputSchema: target must be in the form "provider.method"');if(y===null||typeof y!="object")throw new Error("saveOutputSchema: outputSchema must be an object");let w={target:S,outputSchema:y,description:I,savedAt:Date.now()};return Qer(w),{saved:!0,target:S}},__snippetCode:async h=>{let A=ker(h);if(!A)throw new Error(`Snippet not found: ${h}`);return A.code}},m=typeof t.timeout=="number"&&t.timeout>0?t.timeout*1e3:void 0,p=await e.execute(Oer(t.code),c,d,m);yield{type:"result",data:p,resultForAssistant:p.error?`Error: ${p.error}`:iGe(p.result)}}}}var Tso=L.object({code:L.string().describe("JavaScript async arrow function to execute"),timeout:L.number().optional().describe("Execution timeout in seconds. Defaults to 60.")}),HF=jer(),Ker={...HF,name:"codemode",inputSchema:Tso,async description(e){return HF.description(e)},async prompt(){return HF.description()},userFacingName(){return"Code"},async isEnabled(){try{return(await kle()).length>0}catch{return!1}},isReadOnly(){return!1},isMcp(){return!1},needsPermissions(){return!0},async validateInput(e){return!e.code||typeof e.code!="string"?{result:!1,message:"code is required"}:{result:!0}},renderResultForAssistant(e){return e.error?`Error: ${e.error}`:HF.renderResultForAssistant(e)},renderToolUseMessage(e){return e.code},renderToolResultMessage(e){return HF.renderToolResultMessage(e)},async*call(e,t,r){yield*HF.call(e,t,r)}};var $F=j(ie(),1);dn();Zt();j3();Pe();var Jer=qo,Zer="Proxies calls to all other tools by tool name, and can load the target tool usage guide and its TS arguments type",Xer=`Proxies calls to all other tools by tool name, and can load the target tool usage guide and its TS arguments type.
3304
+ `)[0]??"codemode"},renderToolResultMessage(t){let r=Ner(t.result);return Yv.createElement(x,{flexDirection:"column"},t.error?Yv.createElement(x,{flexDirection:"row",key:"error"},Yv.createElement(T,null," \u23BF "),Yv.createElement(T,{color:"red",key:"error-text"},`Error: ${t.error}`)):null,Yv.createElement(x,{flexDirection:"row",key:"result"},Yv.createElement(T,null," \u23BF "),Yv.createElement(T,{key:"result-text"},r)))},async*call(t,r,n){let o=r??{abortController:new AbortController,readFileTimestamps:{}},i=c0(),s=Object.keys(i),[a,l]=await Promise.all([fS(),kle().catch(()=>[])]),c=await Cso(a),u=Mue(),d={search:async h=>Ger(h,l,u,s),describe:async h=>Ver(h,l,u,Fer()),saveSnippet:async(h,A,_,S,y)=>{if(typeof A!="string"||A.length===0)throw new Error("saveSnippet: code must be a non-empty string (a function or string of snippet code)");for(let[w,N]of[["inputSchema",S],["outputSchema",y]])if(N!==void 0&&(N===null||typeof N!="object"))throw new Error(`saveSnippet: ${w} must be an object when provided`);let I={name:h,description:_,code:A,savedAt:Date.now(),connectors:s,...S!==void 0?{inputSchema:S}:{},...y!==void 0?{outputSchema:y}:{}};return Mer(I),{saved:!0,name:h}},saveOutputSchema:async(h,A,_)=>{let[S,y,I]=Array.isArray(h)?h:[h,A,_];if(typeof S!="string"||!S.includes("."))throw new Error('saveOutputSchema: target must be in the form "provider.method"');if(y===null||typeof y!="object")throw new Error("saveOutputSchema: outputSchema must be an object");let w={target:S,outputSchema:y,description:I,savedAt:Date.now()};return Qer(w),{saved:!0,target:S}},__snippetCode:async h=>{let A=ker(h);if(!A)throw new Error(`Snippet not found: ${h}`);return A.code}},m=typeof t.timeout=="number"&&t.timeout>0?t.timeout*1e3:void 0,p=await e.execute(Oer(t.code),c,d,m);yield{type:"result",data:p,resultForAssistant:p.error?`Error: ${p.error}`:iGe(p.result)}}}}var Tso=L.object({code:L.string().describe("JavaScript async arrow function to execute"),timeout:L.number().optional().describe("Execution timeout in seconds. Defaults to 60.")}),HF=jer(),Ker={...HF,name:"codemode",inputSchema:Tso,async description(e){return HF.description(e)},async prompt(){return HF.description()},userFacingName(){return"Code"},async isEnabled(){try{return(await kle()).length>0}catch{return!1}},isReadOnly(){return!1},isMcp(){return!1},needsPermissions(){return!0},async validateInput(e){return!e.code||typeof e.code!="string"?{result:!1,message:"code is required"}:{result:!0}},renderResultForAssistant(e){return e.error?`Error: ${e.error}`:HF.renderResultForAssistant(e)},renderToolUseMessage(e){return e.code},renderToolResultMessage(e){return HF.renderToolResultMessage(e)},async*call(e,t,r){yield*HF.call(e,t,r)}};var $F=j(ie(),1);dn();Zt();j3();Pe();var Jer=qo,Zer="Proxies calls to tools listed in <loadable_tools>, and can load the target tool's usage guide and its TS arguments type",Xer=`Proxies calls to tools listed in <loadable_tools>, and can load the target tool usage guide and its TS arguments type.
3305
3305
  The tools that appear in <loadable_tools> are NOT directly callable in this conversation \u2014 they are a catalog only. Every one of them MUST be invoked through ${qo}. Calling them by their own names (e.g. Glob, Read, Grep) will fail.
3306
3306
 
3307
3307
  ## Discovery-First Rule
3308
- For each tool, you MUST load it once before your first call in this conversation. After the load, reuse the returned type signature for subsequent calls. Never guess method names, parameter names, types, or structure.
3308
+ For each tool in <loadable_tools>, you MUST load it once before your first call in this conversation. After the load, reuse the returned type signature for subsequent calls. Never guess method names, parameter names, types, or structure.
3309
3309
  - FIRST: ${qo}({ proxyToolAction: "load", toolName: "Glob" })
3310
3310
  THEN: ${qo}({ proxyToolAction: "call", toolName: "Glob", arguments: { pattern: "**/*.ts" } })
3311
3311
 
@@ -3315,7 +3315,7 @@ For each tool, you MUST load it once before your first call in this conversation
3315
3315
 
3316
3316
  - call: ${qo}({ proxyToolAction: "call", toolName: "<tool_name>", arguments: { ... } })
3317
3317
  \u2192 Executes the target tool.
3318
- \u2192 The \`arguments\` object MUST strictly match the TypeScript type signature returned by \`load\`.
3318
+ \u2192 The \`arguments\` object MUST strictly match the TypeScript type signature returned by \`load\` for that same toolName..
3319
3319
 
3320
3320
  ## Examples
3321
3321
  - WRONG: Glob({ pattern: "**/*.ts" })
@@ -3327,7 +3327,7 @@ For each tool, you MUST load it once before your first call in this conversation
3327
3327
 
3328
3328
  ## Rules
3329
3329
  - Do not proxy tools that are not in <loadable_tools>. Do not invent tool names.
3330
- `;td();Pe();hr();var Iso=Ue(()=>L.object({proxyToolAction:L.enum(["call","load"]).default("load").describe("call=invoke the target tool; load=get the target tool usage guide and its TS arguments type"),toolName:L.string().describe("Name of the tool to invoke"),arguments:L.record(L.unknown()).optional().describe("call mode only: arguments object for the target tool; must match the TS arguments type shown in the load result of the same tool; when unsure, run proxyToolAction:'load' first instead of guessing. Ignored in load mode.")})),vso={type:"object",properties:{proxyToolAction:{type:"string",enum:["call","load"],default:"load",description:"call=invoke the target tool; load=get the target tool usage guide and its TS arguments type"},toolName:{type:"string",description:"Name of the tool to invoke"},arguments:{type:"object",description:"call mode only: arguments object for the target tool; must match the TS arguments type shown in the load result of the same tool; when unsure, run proxyToolAction:'load' first instead of guessing. Ignored in load mode."}},required:["toolName"]};async function etr(e){return e?.options?._tools??await mn.getTools(!1)??[]}function dGe(e){return e.name!==qo&&e.name!==W8&&!j8.includes(e.name)}var ttr={name:Jer,async description(){return Zer},async prompt({dangerouslySkipPermissions:e}={},t){let n=(await etr(t)).filter(dGe),o=(await Promise.all(n.map(async i=>`<tool><name>${i.name}</name><description>${i.isMcp?.()?xL.getSimpleDescription(i.name):await i.description?.()}</description></tool>`))).join(`
3330
+ `;td();Pe();hr();var Iso=Ue(()=>L.object({proxyToolAction:L.enum(["call","load"]).default("load").describe("call=invoke the target tool; load=get the target tool usage guide and its TS arguments type"),toolName:L.string().describe("Name of the tool to invoke"),arguments:L.record(L.unknown()).optional().describe("call mode only: arguments object for the target tool; must match the TS arguments type shown in the load result of the same tool; when unsure, run proxyToolAction:'load' first instead of guessing. Ignored in load mode.")})),vso={type:"object",properties:{proxyToolAction:{type:"string",enum:["call","load"],description:"call=invoke the target tool; load=get the target tool usage guide and its TS arguments type. Set only here, never in arguments"},toolName:{type:"string",description:"Exact target tool name from <loadable_tools>; not ProxyTool. Set only here, never in arguments; used by both load and call"},arguments:{type:"object",description:"call mode only: arguments object for the target tool; must match the TS arguments type shown in the load result of the same tool; when unsure, run proxyToolAction:'load' first instead of guessing. omit in load mode."}},required:["proxyToolAction","toolName"]};async function etr(e){return e?.options?._tools??await mn.getTools(!1)??[]}function dGe(e){return e.name!==qo&&e.name!==W8&&!j8.includes(e.name)}var ttr={name:Jer,async description(){return Zer},async prompt({dangerouslySkipPermissions:e}={},t){let n=(await etr(t)).filter(dGe),o=(await Promise.all(n.map(async i=>`<tool><name>${i.name}</name><description>${i.isMcp?.()?xL.getSimpleDescription(i.name):await i.description?.()}</description></tool>`))).join(`
3331
3331
  `);return`${Xer}
3332
3332
  <loadable_tools>
3333
3333
  ${o}
package/hands.js CHANGED
@@ -622,7 +622,7 @@ data: ${JSON.stringify(G)}
622
622
  `);a=Q.pop()||"";for(let G of Q){let j=G.trim();if(!(!j||j==="data: [DONE]"))if(j.startsWith("data: ")){let q=j.slice(6);try{let V=JSON.parse(q);w(V)}catch(V){this.logger&&this.logger.error({err:V,line:j},"Failed to parse Gemini SSE chunk")}}else try{let q=JSON.parse(j);w(q)}catch{}}};(async()=>{try{for(;;){let{value:Q,done:G}=await s.read();if(G)break;a+=n.decode(Q,{stream:!0}),O()}I()}catch(Q){o.error(Q)}})()}})}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_${zB()}`,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:`
623
623
 
624
624
  [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 z8r(`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"}}},dbe=new ube;var fgt=ee(cgt(),1);dr();Rs();function $g(e){return e?typeof e.entries=="function"?Object.fromEntries(e.entries()):{...e}:{}}function ugt(e){let t=String(e?.["x-thinking-level"]??"medium").toLowerCase();return["off","low","medium","high"].includes(t)?t:"medium"}function orn(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t}}function srn(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t,summary:"auto"}}function arn(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 $5(e,t,r){Qz(t,e),Pz(t,arn(e,r),r)}function O2(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 q5(e){let t=new Headers(e);return t.delete("content-encoding"),t.delete("content-length"),t.delete("transfer-encoding"),t}function FIe(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 dgt=["/v1/messages"];function UIe(e){let t;try{typeof e=="string"?t=new Bv(e):e instanceof Bv?t=e:t=new Bv(e.url)}catch{return""}let r=t.pathname;for(let n of dgt){let i=r.indexOf(n);if(i!==-1)return t.origin+r.slice(0,i)}return t.origin}function YZ(e,t){let r=typeof e=="string"?e:e instanceof Bv?e.toString():e.url,n;try{n=new Bv(r).pathname}catch{return!1}return dgt.some(i=>n.includes(i))&&(t.method==="POST"||t.method==="post")}function lrn(e){return async(t,r)=>{if(!YZ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await VK.transformRequestOut(n),o=UIe(t)+"/chat/completions",s=$g(r.headers),a=s.authorization??s.Authorization??"";orn(i,ugt(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 _=await l.text();return K(`OpenAI Chat Completions API error: ${l.status}`,{url:o,errorResponse:_}),FIe("OpenAI Chat Completions API error","OPENROUTER",l.status,l.statusText,_)}let c=n.stream===!0,u=s["x-agent-id"],f={request:{url:o,method:r.method,headers:s,body:n},response:{status:l.status,statusText:l.statusText,headers:$g(l.headers)},openai:{request:{body:i},response:{}}};if(!c){let _=await l.text(),y=new Response(_,{status:l.status,statusText:l.statusText,headers:q5(l.headers)}),S=await VK.transformResponseIn(y,n),I=await S.text();try{$5({...f,openai:{...f.openai,response:{body:JSON.parse(_)}},response:{...f.response,body:JSON.parse(I)}},u)}catch(w){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u975E\u6D41\u5F0F):",w)}return new Response(I,{status:S.status,statusText:S.statusText,headers:S.headers})}let g=O2(l.body),m=new Response(g.stream,{status:l.status,statusText:l.statusText,headers:q5(l.headers)}),A=await VK.transformResponseIn(m,n),h=O2(A.body);return Promise.all([g.done,h.done]).then(async([_,y])=>{try{$5({...f,openai:{...f.openai,response:{body:await Fot(_)}},response:{...f.response,body:await kU(y)}},u)}catch(S){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u6D41\u5F0F):"+S?.stack)}}).catch(_=>K("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Chat):"+_)),new Response(h.stream,{status:A.status,statusText:A.statusText,headers:A.headers})}}function crn(e){return async(t,r)=>{if(!YZ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await WK.transformRequestOut(n),o=$g(r.headers);srn(i,ugt(o));let s=JSON.stringify(i),l=UIe(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 S=await u.text();return K(`OpenAI Responses API error: ${u.status} ${u.statusText}`,{url:l,status:u.status,errorResponse:S}),FIe("OpenAI Responses API error","RESPONSES",u.status,u.statusText,S)}let f=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:$g(u.headers)},openai:{request:{body:i},response:{}}};if(!f){let S=await u.text(),I=new Response(S,{status:u.status,statusText:u.statusText,headers:q5(u.headers)}),w=await WK.transformResponseIn(I,n),O=await w.text();try{$5({...m,openai:{...m.openai,response:{body:JSON.parse(S)}},response:{...m.response,body:JSON.parse(O)}},g,"responses")}catch(Q){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u975E\u6D41\u5F0F):",Q)}return new Response(O,{status:w.status,statusText:w.statusText,headers:w.headers})}let A=O2(u.body),h=new Response(A.stream,{status:u.status,statusText:u.statusText,headers:q5(u.headers)}),_=await WK.transformResponseIn(h,n),y=O2(_.body);return Promise.all([A.done,y.done]).then(async([S,I])=>{try{$5({...m,openai:{...m.openai,response:{body:await Lot(S)}},response:{...m.response,body:await kU(I)}},g,"responses")}catch(w){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u6D41\u5F0F):"+w?.stack)}}).catch(S=>K("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Responses):"+S)),new Response(y.stream,{status:_.status,statusText:_.statusText,headers:_.headers})}}function urn(e){return async(t,r)=>{if(!YZ(t,r))return e(t,r);let n=JSON.parse(r.body),i=$g(r.headers),o=await dbe.transformRequestOut(n),s=JSON.stringify(o),a=UIe(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(y){throw K("gemini request error:",y),y}if(!c.ok){let y=await c.text();return K(`Gemini API error response: ${c.status} ${c.statusText}`,{url:a,status:c.status,errorResponse:y}),FIe("Gemini API error","Gemini",c.status,c.statusText,y)}let u=n.stream===!0,f=i["x-agent-id"],g={request:{url:a,method:r.method,headers:$g(r.headers),body:n},response:{status:c.status,statusText:c.statusText,headers:$g(c.headers)},openai:{request:{body:o},response:{}}},m=O2(c.body),A=new Response(m.stream,{status:c.status,statusText:c.statusText,headers:q5(c.headers)}),h=await dbe.transformResponseIn(A),_=O2(h.body);return Promise.all([m.done,_.done]).then(async([y,S])=>{try{let I=u?Uot(y):JSON.parse(y),w=u?await kU(S):JSON.parse(S);$5({...g,openai:{...g.openai,response:{body:I}},response:{...g.response,body:w}},f)}catch(I){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Gemini):"+I?.stack)}}).catch(y=>K("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Gemini):"+y)),new Response(_.stream,{status:h.status,statusText:h.statusText,headers:h.headers})}}function drn(e){return async(t,r)=>{if(!YZ(t,r))return e(t,r);let n=r.body;if(r.body)try{let f=JSON.parse(r.body);n=JSON.stringify(f)}catch{}let i=$g(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 f=await a.text();K(`API error response: ${a.status} ${a.statusText}`,{url:typeof t=="string"?t:t instanceof Bv?t.toString():t.url,status:a.status,errorResponse:f});let g;try{let m=JSON.parse(f);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 Bv?t.toString():t.url,method:r.method,headers:$g(r.headers),body:JSON.parse(n)},response:{status:a.status,statusText:a.statusText,headers:$g(a.headers)}};return(async()=>{if(c){let m=await a.text();u.response.body=await kU(m)}else u.response.body=await a.json();let g=$g(r.headers)["x-agent-id"];Qz(g,u),Pz(g,{request:u.request.body.messages,response:u.response.body.content,usage:u.response.body?.usage})})().catch(f=>K(`\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF:
625
- Stack trace: `+f.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var jZ=null,LIe=!1;function frn(){jZ=null,LIe=!1}Sr.on("proxy:changed",frn);function prn(){if(LIe)return jZ;if(LIe=!0,ut().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(jZ=new fgt.ProxyAgent({uri:e}),tr(`[proxy] using proxy: ${e}`)),jZ}function mrn(){let e=prn();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function VZ(e){let t=e||process.env.API_TYPE,r=mrn();switch(t){case"openai":return lrn(r);case"openai-responses":return crn(r);case"gemini":return urn(r);default:return drn(r)}}Ah();var Ern=ee(ge(),1);function pgt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=grn(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function grn(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||Arn(t)?0:hrn(t)?2:1}function Arn(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function hrn(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 E_(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 oS(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}Qe();Rs();var pc={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function WZ(e,t){pc.totalCost+=e,pc.totalAPIDuration+=t}function KZ(e,t){pc.inputTokens+=e,pc.outputTokens+=t,Sr.emit("token:change",{inputTokens:pc.inputTokens,outputTokens:pc.outputTokens})}function JZ(e,t){pc.cacheCreationTokens+=e,pc.cacheReadTokens+=t}function HIe(){return{inputTokens:pc.inputTokens,outputTokens:pc.outputTokens,cacheCreationTokens:pc.cacheCreationTokens,cacheReadTokens:pc.cacheReadTokens}}function mgt(){return pc.totalCost}function ggt(){return Date.now()-pc.startTime}function Agt(){return pc.totalAPIDuration}function hgt(e){pc.currentContextTokens=e}function Egt(){return pc.currentContextTokens}Qe();Ue();Ue();var $Ie="2.4.52";globalThis.MACRO={VERSION:$Ie,PACKAGE_URL:`@dahawa/${Zi}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var ZZ=process.env.HAWA_CODE_USER_AGENT||`${Zi}/${$Ie} (${process.env.USER_TYPE})`;import{randomUUID as NE}from"crypto";Rs();Qe();Zt();_r();Qe();Ue();import{existsSync as S_,readdirSync as jsn,statSync as Ysn}from"fs";import{join as cS,relative as Vsn}from"path";import{homedir as cEt}from"os";import{platform as Wsn}from"process";import{readFile as uS}from"fs/promises";_r();ym();dr();import{join as Srn,sep as Irn}from"path";function bm(){if(!Ou())return!1;try{let e=ut();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function Zf(){return(Srn(Re(),".hcode","team-memory")+Irn).normalize("NFC")}function y_(e){let t=e.normalize("NFC"),r=Zf();return t.startsWith(r)}ym();var uEt=ee(Z5(),1);Li();var oTe=(e,t,r)=>{let n=e instanceof RegExp?Pht(e,r):e,i=t instanceof RegExp?Pht(t,r):t,o=n!==null&&i!=null&&Qon(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)}},Pht=(e,t)=>{let r=t.match(e);return r?r[0]:null},Qon=(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 f=n.pop();f!==void 0&&(a=[f,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 Lht="\0SLASH"+Math.random()+"\0",Fht="\0OPEN"+Math.random()+"\0",lTe="\0CLOSE"+Math.random()+"\0",Uht="\0COMMA"+Math.random()+"\0",Hht="\0PERIOD"+Math.random()+"\0",Pon=new RegExp(Lht,"g"),Lon=new RegExp(Fht,"g"),Fon=new RegExp(lTe,"g"),Uon=new RegExp(Uht,"g"),Hon=new RegExp(Hht,"g"),$on=/\\\\/g,qon=/\\{/g,Gon=/\\}/g,zon=/\\,/g,jon=/\\\./g,Yon=1e5,Von=4e6;function sTe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Won(e){return e.replace($on,Lht).replace(qon,Fht).replace(Gon,lTe).replace(zon,Uht).replace(jon,Hht)}function Kon(e){return e.replace(Pon,"\\").replace(Lon,"{").replace(Fon,"}").replace(Uon,",").replace(Hon,".")}function $ht(e){if(!e)return[""];let t=[],r=oTe("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=$ht(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function qht(e,t={}){if(!e)return[];let{max:r=Yon,maxLength:n=Von}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),aTe(Won(e),r,n,!0).map(Kon)}function Jon(e){return"{"+e+"}"}function Zon(e){return/^-?0\d/.test(e)}function Xon(e,t){return e<=t}function esn(e,t){return e>=t}function X5(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 tsn(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=sTe(i[0]),a=sTe(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(sTe(i[2])),1):1,u=Xon;a<s&&(c*=-1,u=esn);let g=i.some(Zon),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 _=l-h.length;if(_>0){let y=new Array(_+1).join("0");A<0?h="-"+y+h.slice(1):h=y+h}}if(m+h.length>n)break;o.push(h),m+=h.length}return o}function aTe(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=oTe("{","}",e);if(!a)return X5(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=X5(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),f=c||u,g=a.body.indexOf(",")>=0;if(!f&&!g){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+lTe+a.post,n=!0;continue}return X5(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!f,s=!1);let m;if(f)m=tsn(a.body,u,t,r);else{let A=$ht(a.body);if(A.length===1&&A[0]!==void 0&&(A=aTe(A[0],t,r,!1).map(Jon),A.length===1)){if(i=X5(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 y=0;h&&y<i.length;y++)i[y]&&(h=!1);m=[];let _=0;e:for(let y=0;y<A.length;y++){let S=aTe(A[y],t,r,!1);for(let I=0;I<S.length;I++){let w=S[I];if(!(h&&!w)){if(m.length>=t||_+w.length>r)break e;m.push(w),_+=w.length}}}}if(i=X5(i,l,m,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var e9=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var rsn={"[: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]},t9=e=>e.replace(/[[\]\\-]/g,"\\$&"),nsn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ght=e=>e.join(""),zht=(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,f="";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,S,I]]of Object.entries(rsn))if(e.startsWith(_,o)){if(f)return["$.",!1,e.length-r,!0];o+=_.length,I?i.push(y):n.push(y),a=a||S;continue e}}if(l=!1,f){h>f?n.push(t9(f)+"-"+t9(h)):h===f&&n.push(t9(h)),f="",o++;continue}if(e.startsWith("-]",o+1)){n.push(t9(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){f=h,o+=2;continue}n.push(t9(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[nsn(h),!1,u-r,!1]}let g="["+(c?"^":"")+Ght(n)+"]",m="["+(c?"":"^")+Ght(i)+"]";return[n.length&&i.length?"("+g+"|"+m+")":n.length?g:m,a,u-r,!0]};var lS=(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 $d,isn=new Set(["!","?","+","*","@"]),cTe=e=>isn.has(e),jht=e=>cTe(e.type),osn=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),ssn=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),asn=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),Yht=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),lsn="(?!(?:^|/)\\.\\.?(?:$|/))",dX="(?!\\.)",csn=new Set(["[","."]),usn=new Set(["..","."]),dsn=new Set("().*{}+?[]^$\\!"),fsn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),uTe="[^/]",Vht=uTe+"*?",Wht=uTe+"+?",psn=0,Uv=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;id=++psn;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 $d&&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 $d&&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 $d(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,_="";for(;h<t.length;){let y=t.charAt(h++);if(a||y==="\\"){a=!a,_+=y;continue}if(l){h===c+1?(y==="^"||y==="!")&&(u=!0):y==="]"&&!(h===c+2&&u)&&(l=!1),_+=y;continue}else if(y==="["){l=!0,c=h,u=!1,_+=y;continue}if(!i.noext&&cTe(y)&&t.charAt(h)==="("&&o<=s){r.push(_),_="";let I=new $d(y,r);h=$d.#c(t,I,h,i,o+1),r.push(I);continue}_+=y}return r.push(_),h}let f=n+1,g=new $d(null,r),m=[],A="";for(;f<t.length;){let h=t.charAt(f++);if(a||h==="\\"){a=!a,A+=h;continue}if(l){f===c+1?(h==="^"||h==="!")&&(u=!0):h==="]"&&!(f===c+2&&u)&&(l=!1),A+=h;continue}else if(h==="["){l=!0,c=f,u=!1,A+=h;continue}if(!i.noext&&cTe(h)&&t.charAt(f)==="("&&(o<=s||r&&r.#E(h))){let y=r&&r.#E(h)?0:1;g.push(A),A="";let S=new $d(h,g);g.push(S),f=$d.#c(t,S,f,i,o+y);continue}if(h==="|"){g.push(A),A="",m.push(g),g=new $d(null,r);continue}if(h===")")return A===""&&r.#r.length===0&&(r.#p=!0),g.push(A),A="",r.push(...m,g),f;A+=h}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],f}#g(t){return this.#h(t,ssn)}#h(t,r=osn){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=asn){return!!r.get(this.type)?.includes(t)}#A(t,r){let n=t.#r[0],i=new $d(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!!Yht.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=Yht.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 $d(null,void 0,r);return $d.#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()),!jht(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(m=>typeof m!="string"),c=this.#r.map(m=>{let[A,h,_,y]=typeof m=="string"?$d.#C(m,this.#t,l):m.toRegExpSource(t);return this.#t=this.#t||_,this.#n=this.#n||y,A}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&usn.has(this.#r[0]))){let A=csn,h=r&&A.has(c.charAt(0))||c.startsWith("\\.")&&A.has(c.charAt(2))||c.startsWith("\\.\\.")&&A.has(c.charAt(4)),_=!r&&!t&&A.has(c.charAt(0));u=h?lsn:_?dX:""}let f="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(f="(?:$|\\/)"),[u+c+f,lS(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,lS(this.toString()),!1,!1]}let s=!n||t||r||!dX?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?dX:"")+Wht;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?dX:"")+Vht+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,lS(o),this.#t=!!this.#t,this.#n]}#_(){if(jht(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+=(dsn.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?Wht:Vht,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,f,g,m]=zht(t,l);if(g){o+=u,s=s||f,l+=g-1,r=r||m;continue}}if(c==="?"){o+=uTe,r=!0;continue}o+=fsn(c)}return[o,lS(t),!!r,s]}};$d=Uv;var dTe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var gc=(e,t,r={})=>(e9(t),!r.nocomment&&t.charAt(0)==="#"?!1:new q2(t,r).match(e)),msn=/^\*+([^+@!?*[(]*)$/,gsn=e=>t=>!t.startsWith(".")&&t.endsWith(e),Asn=e=>t=>t.endsWith(e),hsn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Esn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),_sn=/^\*+\.\*+$/,ysn=e=>!e.startsWith(".")&&e.includes("."),bsn=e=>e!=="."&&e!==".."&&e.includes("."),Csn=/^\.\*+$/,Ssn=e=>e!=="."&&e!==".."&&e.startsWith("."),Isn=/^\*+$/,Tsn=e=>e.length!==0&&!e.startsWith("."),vsn=e=>e.length!==0&&e!=="."&&e!=="..",xsn=/^\?+([^+@!?*[(]*)?$/,wsn=([e,t=""])=>{let r=Zht([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Dsn=([e,t=""])=>{let r=Xht([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Rsn=([e,t=""])=>{let r=Xht([e]);return t?n=>r(n)&&n.endsWith(t):r},Nsn=([e,t=""])=>{let r=Zht([e]);return t?n=>r(n)&&n.endsWith(t):r},Zht=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},Xht=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},eEt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Kht={win32:{sep:"\\"},posix:{sep:"/"}},Bsn=eEt==="win32"?Kht.win32.sep:Kht.posix.sep;gc.sep=Bsn;var Kc=Symbol("globstar **");gc.GLOBSTAR=Kc;var Osn="[^/]",ksn=Osn+"*?",Msn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Qsn="(?:(?!(?:\\/|^)\\.).)*?",Psn=(e,t={})=>r=>gc(r,e,t);gc.filter=Psn;var Cm=(e,t={})=>Object.assign({},e,t),Lsn=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return gc;let t=gc;return Object.assign((n,i,o={})=>t(n,i,Cm(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,Cm(e,o))}static defaults(i){return t.defaults(Cm(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,Cm(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,Cm(e,o))}},unescape:(n,i={})=>t.unescape(n,Cm(e,i)),escape:(n,i={})=>t.escape(n,Cm(e,i)),filter:(n,i={})=>t.filter(n,Cm(e,i)),defaults:n=>t.defaults(Cm(e,n)),makeRe:(n,i={})=>t.makeRe(n,Cm(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,Cm(e,i)),match:(n,i,o={})=>t.match(n,i,Cm(e,o)),sep:t.sep,GLOBSTAR:Kc})};gc.defaults=Lsn;var tEt=(e,t={})=>(e9(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:qht(e,{max:t.braceExpandMax}));gc.braceExpand=tEt;var Fsn=(e,t={})=>new q2(e,t).makeRe();gc.makeRe=Fsn;var Usn=(e,t,r={})=>{let n=new q2(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};gc.match=Usn;var Jht=/[?*]|[+@!]\(.*?\)|\[|\]/,Hsn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),q2=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){e9(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||eEt,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]==="?"||!Jht.test(o[2]))&&!Jht.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]),f=l?3:a?0:void 0,g=u?3:c?0:void 0;if(typeof f=="number"&&typeof g=="number"){let[m,A]=[t[f],r[g]];m.toLowerCase()===A.toLowerCase()&&(r[g]=m,o=g,i=f)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(Kc)?this.#e(t,r,n,i,o):this.#n(t,r,n,i,o)}#e(t,r,n,i,o){let s=r.indexOf(Kc,o),a=r.lastIndexOf(Kc),[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 S=t.slice(i,i+l.length);if(!this.#n(S,l,n,0,0))return!1;i+=l.length,o+=l.length}let f=0;if(u.length){if(u.length+i>t.length)return!1;let S=t.length-u.length;if(this.#n(t,u,n,S,0))f=u.length;else{if(t[t.length-1]!==""||i+u.length===t.length||(S--,!this.#n(t,u,n,S,0)))return!1;f=u.length+1}}if(!c.length){let S=!!f;for(let I=i;I<t.length-f;I++){let w=String(t[I]);if(S=!0,w==="."||w===".."||!this.options.dot&&w.startsWith("."))return!1}return n||S}let g=[[[],0]],m=g[0],A=0,h=[0];for(let S of c)S===Kc?(h.push(A),m=[[],0],g.push(m)):(m[0].push(S),A++);let _=g.length-1,y=t.length-f;for(let S of g)S[1]=y-(h[_--]+S[0].length);return!!this.#t(t,g,i,0,n,0,!!f)}#t(t,r,n,i,o,s,a){let l=r[i];if(!l){for(let f=n;f<t.length;f++){a=!0;let g=t[f];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],f=t[s];if(this.debug(r,u,f),u===!1||u===Kc)return!1;let g;if(typeof u=="string"?(g=f===u,this.debug("string match",u,f,g)):(g=u.test(f),this.debug("pattern match",u,f,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 tEt(this.pattern,this.options)}parse(t){e9(t);let r=this.options;if(t==="**")return Kc;if(t==="")return"";let n,i=null;(n=t.match(Isn))?i=r.dot?vsn:Tsn:(n=t.match(msn))?i=(r.nocase?r.dot?Esn:hsn:r.dot?Asn:gsn)(n[1]):(n=t.match(xsn))?i=(r.nocase?r.dot?Dsn:wsn:r.dot?Rsn:Nsn)(n):(n=t.match(_sn))?i=r.dot?bsn:ysn:(n=t.match(Csn))&&(i=Ssn);let o=Uv.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?ksn:r.dot?Msn:Qsn,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(f=>{if(f instanceof RegExp)for(let g of f.flags.split(""))i.add(g);return typeof f=="string"?Hsn(f):f===Kc?Kc:f._src});c.forEach((f,g)=>{let m=c[g+1],A=c[g-1];f!==Kc||A===Kc||(A===void 0?m!==void 0&&m!==Kc?c[g+1]="(?:\\/|"+n+"\\/)?"+m:c[g]=n:m===void 0?c[g-1]=A+"(?:\\/|\\/"+n+")?":m!==Kc&&(c[g-1]=A+"(?:\\/|\\/"+n+"\\/)"+m,c[g+1]=Kc))});let u=c.filter(f=>f!==Kc);if(this.partial&&u.length>=1){let f=[];for(let g=1;g<=u.length;g++)f.push(u.slice(0,g).join("/"));return"(?:"+f.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 gc.defaults(t).Minimatch}};gc.AST=Uv;gc.Minimatch=q2;gc.escape=dTe;gc.unescape=lS;var iEt=ee(Z5(),1);_r();Ue();Qe();Tu();import{readFile as rEt}from"fs/promises";import{existsSync as fTe,readdirSync as $sn,statSync as qsn}from"fs";import{join as pTe,relative as oEt}from"path";import{homedir as Gsn}from"os";function nEt(e){try{let t=(0,iEt.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 Te(t),{paths:[],content:e.trim()}}}function zsn(e,t){return t.length===0?!0:t.some(r=>{try{return gc(e,r,{matchBase:!0,dot:!0})}catch(n){return Te(n),!1}})}function mTe(e){let t=[];try{if(!fTe(e))return t;let r=$sn(e);for(let n of r){let i=pTe(e,n),o=qsn(i);o.isDirectory()?t.push(...mTe(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){Te(r)}return t}async function fX(){let e=[];try{let t=pTe(Gsn(),en,"rules");if(fTe(t)){let r=mTe(t);for(let n of r)try{let i=await rEt(n,"utf-8"),{paths:o,content:s}=nEt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){Te(i)}}}catch(t){Te(t)}try{let t=pTe(Re(),en,"rules");if(fTe(t)){let r=mTe(t);for(let n of r)try{let i=await rEt(n,"utf-8"),{paths:o,content:s}=nEt(i);o.length>0&&e.push({filePath:oEt(Re(),n),content:s,paths:o,isProjectRule:!0})}catch(i){Te(i)}}}catch(t){Te(t)}return e}function sEt(e,t){e=OV(e);let r=OV(Re()),n=e.startsWith(r)?oEt(r,e):e;return t.filter(i=>zsn(n,i.paths))}function aEt(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}):
625
+ Stack trace: `+f.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var jZ=null,LIe=!1;function frn(){jZ=null,LIe=!1}Sr.on("proxy:changed",frn);function prn(){if(LIe)return jZ;if(LIe=!0,ut().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(jZ=new fgt.ProxyAgent({uri:e}),tr(`[proxy] using proxy: ${e}`)),jZ}function mrn(){let e=prn();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function VZ(e){let t=e||process.env.API_TYPE,r=mrn();switch(t){case"openai":return lrn(r);case"openai-responses":return crn(r);case"gemini":return urn(r);default:return drn(r)}}Ah();var Ern=ee(ge(),1);function pgt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=grn(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function grn(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||Arn(t)?0:hrn(t)?2:1}function Arn(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function hrn(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 E_(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 oS(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}Qe();Rs();var pc={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function WZ(e,t){pc.totalCost+=e,pc.totalAPIDuration+=t}function KZ(e,t){pc.inputTokens+=e,pc.outputTokens+=t,Sr.emit("token:change",{inputTokens:pc.inputTokens,outputTokens:pc.outputTokens})}function JZ(e,t){pc.cacheCreationTokens+=e,pc.cacheReadTokens+=t}function HIe(){return{inputTokens:pc.inputTokens,outputTokens:pc.outputTokens,cacheCreationTokens:pc.cacheCreationTokens,cacheReadTokens:pc.cacheReadTokens}}function mgt(){return pc.totalCost}function ggt(){return Date.now()-pc.startTime}function Agt(){return pc.totalAPIDuration}function hgt(e){pc.currentContextTokens=e}function Egt(){return pc.currentContextTokens}Qe();Ue();Ue();var $Ie="2.4.53";globalThis.MACRO={VERSION:$Ie,PACKAGE_URL:`@dahawa/${Zi}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var ZZ=process.env.HAWA_CODE_USER_AGENT||`${Zi}/${$Ie} (${process.env.USER_TYPE})`;import{randomUUID as NE}from"crypto";Rs();Qe();Zt();_r();Qe();Ue();import{existsSync as S_,readdirSync as jsn,statSync as Ysn}from"fs";import{join as cS,relative as Vsn}from"path";import{homedir as cEt}from"os";import{platform as Wsn}from"process";import{readFile as uS}from"fs/promises";_r();ym();dr();import{join as Srn,sep as Irn}from"path";function bm(){if(!Ou())return!1;try{let e=ut();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function Zf(){return(Srn(Re(),".hcode","team-memory")+Irn).normalize("NFC")}function y_(e){let t=e.normalize("NFC"),r=Zf();return t.startsWith(r)}ym();var uEt=ee(Z5(),1);Li();var oTe=(e,t,r)=>{let n=e instanceof RegExp?Pht(e,r):e,i=t instanceof RegExp?Pht(t,r):t,o=n!==null&&i!=null&&Qon(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)}},Pht=(e,t)=>{let r=t.match(e);return r?r[0]:null},Qon=(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 f=n.pop();f!==void 0&&(a=[f,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 Lht="\0SLASH"+Math.random()+"\0",Fht="\0OPEN"+Math.random()+"\0",lTe="\0CLOSE"+Math.random()+"\0",Uht="\0COMMA"+Math.random()+"\0",Hht="\0PERIOD"+Math.random()+"\0",Pon=new RegExp(Lht,"g"),Lon=new RegExp(Fht,"g"),Fon=new RegExp(lTe,"g"),Uon=new RegExp(Uht,"g"),Hon=new RegExp(Hht,"g"),$on=/\\\\/g,qon=/\\{/g,Gon=/\\}/g,zon=/\\,/g,jon=/\\\./g,Yon=1e5,Von=4e6;function sTe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Won(e){return e.replace($on,Lht).replace(qon,Fht).replace(Gon,lTe).replace(zon,Uht).replace(jon,Hht)}function Kon(e){return e.replace(Pon,"\\").replace(Lon,"{").replace(Fon,"}").replace(Uon,",").replace(Hon,".")}function $ht(e){if(!e)return[""];let t=[],r=oTe("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=$ht(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function qht(e,t={}){if(!e)return[];let{max:r=Yon,maxLength:n=Von}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),aTe(Won(e),r,n,!0).map(Kon)}function Jon(e){return"{"+e+"}"}function Zon(e){return/^-?0\d/.test(e)}function Xon(e,t){return e<=t}function esn(e,t){return e>=t}function X5(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 tsn(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=sTe(i[0]),a=sTe(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(sTe(i[2])),1):1,u=Xon;a<s&&(c*=-1,u=esn);let g=i.some(Zon),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 _=l-h.length;if(_>0){let y=new Array(_+1).join("0");A<0?h="-"+y+h.slice(1):h=y+h}}if(m+h.length>n)break;o.push(h),m+=h.length}return o}function aTe(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=oTe("{","}",e);if(!a)return X5(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=X5(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),f=c||u,g=a.body.indexOf(",")>=0;if(!f&&!g){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+lTe+a.post,n=!0;continue}return X5(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!f,s=!1);let m;if(f)m=tsn(a.body,u,t,r);else{let A=$ht(a.body);if(A.length===1&&A[0]!==void 0&&(A=aTe(A[0],t,r,!1).map(Jon),A.length===1)){if(i=X5(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 y=0;h&&y<i.length;y++)i[y]&&(h=!1);m=[];let _=0;e:for(let y=0;y<A.length;y++){let S=aTe(A[y],t,r,!1);for(let I=0;I<S.length;I++){let w=S[I];if(!(h&&!w)){if(m.length>=t||_+w.length>r)break e;m.push(w),_+=w.length}}}}if(i=X5(i,l,m,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var e9=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var rsn={"[: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]},t9=e=>e.replace(/[[\]\\-]/g,"\\$&"),nsn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ght=e=>e.join(""),zht=(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,f="";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,S,I]]of Object.entries(rsn))if(e.startsWith(_,o)){if(f)return["$.",!1,e.length-r,!0];o+=_.length,I?i.push(y):n.push(y),a=a||S;continue e}}if(l=!1,f){h>f?n.push(t9(f)+"-"+t9(h)):h===f&&n.push(t9(h)),f="",o++;continue}if(e.startsWith("-]",o+1)){n.push(t9(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){f=h,o+=2;continue}n.push(t9(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[nsn(h),!1,u-r,!1]}let g="["+(c?"^":"")+Ght(n)+"]",m="["+(c?"":"^")+Ght(i)+"]";return[n.length&&i.length?"("+g+"|"+m+")":n.length?g:m,a,u-r,!0]};var lS=(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 $d,isn=new Set(["!","?","+","*","@"]),cTe=e=>isn.has(e),jht=e=>cTe(e.type),osn=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),ssn=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),asn=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),Yht=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),lsn="(?!(?:^|/)\\.\\.?(?:$|/))",dX="(?!\\.)",csn=new Set(["[","."]),usn=new Set(["..","."]),dsn=new Set("().*{}+?[]^$\\!"),fsn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),uTe="[^/]",Vht=uTe+"*?",Wht=uTe+"+?",psn=0,Uv=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;id=++psn;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 $d&&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 $d&&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 $d(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,_="";for(;h<t.length;){let y=t.charAt(h++);if(a||y==="\\"){a=!a,_+=y;continue}if(l){h===c+1?(y==="^"||y==="!")&&(u=!0):y==="]"&&!(h===c+2&&u)&&(l=!1),_+=y;continue}else if(y==="["){l=!0,c=h,u=!1,_+=y;continue}if(!i.noext&&cTe(y)&&t.charAt(h)==="("&&o<=s){r.push(_),_="";let I=new $d(y,r);h=$d.#c(t,I,h,i,o+1),r.push(I);continue}_+=y}return r.push(_),h}let f=n+1,g=new $d(null,r),m=[],A="";for(;f<t.length;){let h=t.charAt(f++);if(a||h==="\\"){a=!a,A+=h;continue}if(l){f===c+1?(h==="^"||h==="!")&&(u=!0):h==="]"&&!(f===c+2&&u)&&(l=!1),A+=h;continue}else if(h==="["){l=!0,c=f,u=!1,A+=h;continue}if(!i.noext&&cTe(h)&&t.charAt(f)==="("&&(o<=s||r&&r.#E(h))){let y=r&&r.#E(h)?0:1;g.push(A),A="";let S=new $d(h,g);g.push(S),f=$d.#c(t,S,f,i,o+y);continue}if(h==="|"){g.push(A),A="",m.push(g),g=new $d(null,r);continue}if(h===")")return A===""&&r.#r.length===0&&(r.#p=!0),g.push(A),A="",r.push(...m,g),f;A+=h}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],f}#g(t){return this.#h(t,ssn)}#h(t,r=osn){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=asn){return!!r.get(this.type)?.includes(t)}#A(t,r){let n=t.#r[0],i=new $d(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!!Yht.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=Yht.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 $d(null,void 0,r);return $d.#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()),!jht(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(m=>typeof m!="string"),c=this.#r.map(m=>{let[A,h,_,y]=typeof m=="string"?$d.#C(m,this.#t,l):m.toRegExpSource(t);return this.#t=this.#t||_,this.#n=this.#n||y,A}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&usn.has(this.#r[0]))){let A=csn,h=r&&A.has(c.charAt(0))||c.startsWith("\\.")&&A.has(c.charAt(2))||c.startsWith("\\.\\.")&&A.has(c.charAt(4)),_=!r&&!t&&A.has(c.charAt(0));u=h?lsn:_?dX:""}let f="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(f="(?:$|\\/)"),[u+c+f,lS(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,lS(this.toString()),!1,!1]}let s=!n||t||r||!dX?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?dX:"")+Wht;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?dX:"")+Vht+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,lS(o),this.#t=!!this.#t,this.#n]}#_(){if(jht(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+=(dsn.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?Wht:Vht,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,f,g,m]=zht(t,l);if(g){o+=u,s=s||f,l+=g-1,r=r||m;continue}}if(c==="?"){o+=uTe,r=!0;continue}o+=fsn(c)}return[o,lS(t),!!r,s]}};$d=Uv;var dTe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var gc=(e,t,r={})=>(e9(t),!r.nocomment&&t.charAt(0)==="#"?!1:new q2(t,r).match(e)),msn=/^\*+([^+@!?*[(]*)$/,gsn=e=>t=>!t.startsWith(".")&&t.endsWith(e),Asn=e=>t=>t.endsWith(e),hsn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Esn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),_sn=/^\*+\.\*+$/,ysn=e=>!e.startsWith(".")&&e.includes("."),bsn=e=>e!=="."&&e!==".."&&e.includes("."),Csn=/^\.\*+$/,Ssn=e=>e!=="."&&e!==".."&&e.startsWith("."),Isn=/^\*+$/,Tsn=e=>e.length!==0&&!e.startsWith("."),vsn=e=>e.length!==0&&e!=="."&&e!=="..",xsn=/^\?+([^+@!?*[(]*)?$/,wsn=([e,t=""])=>{let r=Zht([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Dsn=([e,t=""])=>{let r=Xht([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Rsn=([e,t=""])=>{let r=Xht([e]);return t?n=>r(n)&&n.endsWith(t):r},Nsn=([e,t=""])=>{let r=Zht([e]);return t?n=>r(n)&&n.endsWith(t):r},Zht=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},Xht=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},eEt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Kht={win32:{sep:"\\"},posix:{sep:"/"}},Bsn=eEt==="win32"?Kht.win32.sep:Kht.posix.sep;gc.sep=Bsn;var Kc=Symbol("globstar **");gc.GLOBSTAR=Kc;var Osn="[^/]",ksn=Osn+"*?",Msn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Qsn="(?:(?!(?:\\/|^)\\.).)*?",Psn=(e,t={})=>r=>gc(r,e,t);gc.filter=Psn;var Cm=(e,t={})=>Object.assign({},e,t),Lsn=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return gc;let t=gc;return Object.assign((n,i,o={})=>t(n,i,Cm(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,Cm(e,o))}static defaults(i){return t.defaults(Cm(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,Cm(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,Cm(e,o))}},unescape:(n,i={})=>t.unescape(n,Cm(e,i)),escape:(n,i={})=>t.escape(n,Cm(e,i)),filter:(n,i={})=>t.filter(n,Cm(e,i)),defaults:n=>t.defaults(Cm(e,n)),makeRe:(n,i={})=>t.makeRe(n,Cm(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,Cm(e,i)),match:(n,i,o={})=>t.match(n,i,Cm(e,o)),sep:t.sep,GLOBSTAR:Kc})};gc.defaults=Lsn;var tEt=(e,t={})=>(e9(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:qht(e,{max:t.braceExpandMax}));gc.braceExpand=tEt;var Fsn=(e,t={})=>new q2(e,t).makeRe();gc.makeRe=Fsn;var Usn=(e,t,r={})=>{let n=new q2(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};gc.match=Usn;var Jht=/[?*]|[+@!]\(.*?\)|\[|\]/,Hsn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),q2=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){e9(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||eEt,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]==="?"||!Jht.test(o[2]))&&!Jht.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]),f=l?3:a?0:void 0,g=u?3:c?0:void 0;if(typeof f=="number"&&typeof g=="number"){let[m,A]=[t[f],r[g]];m.toLowerCase()===A.toLowerCase()&&(r[g]=m,o=g,i=f)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(Kc)?this.#e(t,r,n,i,o):this.#n(t,r,n,i,o)}#e(t,r,n,i,o){let s=r.indexOf(Kc,o),a=r.lastIndexOf(Kc),[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 S=t.slice(i,i+l.length);if(!this.#n(S,l,n,0,0))return!1;i+=l.length,o+=l.length}let f=0;if(u.length){if(u.length+i>t.length)return!1;let S=t.length-u.length;if(this.#n(t,u,n,S,0))f=u.length;else{if(t[t.length-1]!==""||i+u.length===t.length||(S--,!this.#n(t,u,n,S,0)))return!1;f=u.length+1}}if(!c.length){let S=!!f;for(let I=i;I<t.length-f;I++){let w=String(t[I]);if(S=!0,w==="."||w===".."||!this.options.dot&&w.startsWith("."))return!1}return n||S}let g=[[[],0]],m=g[0],A=0,h=[0];for(let S of c)S===Kc?(h.push(A),m=[[],0],g.push(m)):(m[0].push(S),A++);let _=g.length-1,y=t.length-f;for(let S of g)S[1]=y-(h[_--]+S[0].length);return!!this.#t(t,g,i,0,n,0,!!f)}#t(t,r,n,i,o,s,a){let l=r[i];if(!l){for(let f=n;f<t.length;f++){a=!0;let g=t[f];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],f=t[s];if(this.debug(r,u,f),u===!1||u===Kc)return!1;let g;if(typeof u=="string"?(g=f===u,this.debug("string match",u,f,g)):(g=u.test(f),this.debug("pattern match",u,f,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 tEt(this.pattern,this.options)}parse(t){e9(t);let r=this.options;if(t==="**")return Kc;if(t==="")return"";let n,i=null;(n=t.match(Isn))?i=r.dot?vsn:Tsn:(n=t.match(msn))?i=(r.nocase?r.dot?Esn:hsn:r.dot?Asn:gsn)(n[1]):(n=t.match(xsn))?i=(r.nocase?r.dot?Dsn:wsn:r.dot?Rsn:Nsn)(n):(n=t.match(_sn))?i=r.dot?bsn:ysn:(n=t.match(Csn))&&(i=Ssn);let o=Uv.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?ksn:r.dot?Msn:Qsn,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(f=>{if(f instanceof RegExp)for(let g of f.flags.split(""))i.add(g);return typeof f=="string"?Hsn(f):f===Kc?Kc:f._src});c.forEach((f,g)=>{let m=c[g+1],A=c[g-1];f!==Kc||A===Kc||(A===void 0?m!==void 0&&m!==Kc?c[g+1]="(?:\\/|"+n+"\\/)?"+m:c[g]=n:m===void 0?c[g-1]=A+"(?:\\/|\\/"+n+")?":m!==Kc&&(c[g-1]=A+"(?:\\/|\\/"+n+"\\/)"+m,c[g+1]=Kc))});let u=c.filter(f=>f!==Kc);if(this.partial&&u.length>=1){let f=[];for(let g=1;g<=u.length;g++)f.push(u.slice(0,g).join("/"));return"(?:"+f.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 gc.defaults(t).Minimatch}};gc.AST=Uv;gc.Minimatch=q2;gc.escape=dTe;gc.unescape=lS;var iEt=ee(Z5(),1);_r();Ue();Qe();Tu();import{readFile as rEt}from"fs/promises";import{existsSync as fTe,readdirSync as $sn,statSync as qsn}from"fs";import{join as pTe,relative as oEt}from"path";import{homedir as Gsn}from"os";function nEt(e){try{let t=(0,iEt.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 Te(t),{paths:[],content:e.trim()}}}function zsn(e,t){return t.length===0?!0:t.some(r=>{try{return gc(e,r,{matchBase:!0,dot:!0})}catch(n){return Te(n),!1}})}function mTe(e){let t=[];try{if(!fTe(e))return t;let r=$sn(e);for(let n of r){let i=pTe(e,n),o=qsn(i);o.isDirectory()?t.push(...mTe(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){Te(r)}return t}async function fX(){let e=[];try{let t=pTe(Gsn(),en,"rules");if(fTe(t)){let r=mTe(t);for(let n of r)try{let i=await rEt(n,"utf-8"),{paths:o,content:s}=nEt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){Te(i)}}}catch(t){Te(t)}try{let t=pTe(Re(),en,"rules");if(fTe(t)){let r=mTe(t);for(let n of r)try{let i=await rEt(n,"utf-8"),{paths:o,content:s}=nEt(i);o.length>0&&e.push({filePath:oEt(Re(),n),content:s,paths:o,isProjectRule:!0})}catch(i){Te(i)}}}catch(t){Te(t)}return e}function sEt(e,t){e=OV(e);let r=OV(Re()),n=e.startsWith(r)?oEt(r,e):e;return t.filter(i=>zsn(n,i.paths))}function aEt(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
626
 
627
627
  ${r.content}`}).join(`
628
628
 
@@ -995,7 +995,7 @@ You are powered by the model ${e}.`}async function dx(){return r9()?`gitStatus:
995
995
  <context name="${c}">${u}</context>`;let s=i.map(c=>{let u=c.prompt({},t),f=JSON.stringify("inputJSONSchema"in c&&c.inputJSONSchema?c.inputJSONSchema:c0(c.inputSchema));return{name:c.name,description:`${u}
996
996
 
997
997
  Schema:
998
- ${f}`}}),{messages:a}=t,l=ydn(o);return bdn(o,l,s,a)}},abt=Cdn;zg();var Uu=ee(ge(),1),yO=ee(ge(),1);Qe();Qe();import{existsSync as Sdn,readdirSync as Idn,statSync as Tdn}from"fs";import{join as vdn}from"path";function xdn(){let e=Xi.plan();if(!Sdn(e))return[];try{return Idn(e).filter(r=>r.endsWith(".md")).map(r=>{let n=vdn(e,r),i=Tdn(n);return{name:r,path:n,modified:i.mtime}}).sort((r,n)=>n.modified.getTime()-r.modified.getTime())}catch{return[]}}var lbt=({onSelect:e})=>{let[t,r]=(0,yO.useState)([]),[n,i]=(0,yO.useState)(0),[o,s]=(0,yO.useState)(!1);(0,yO.useEffect)(()=>{let c=xdn();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}))];sr((c,u)=>{if(u.upArrow)i(f=>f>0?f-1:a.length-1);else if(u.downArrow)i(f=>f<a.length-1?f+1:0);else if(u.return){let f=a[n];f&&e(f.value)}else u.escape&&e("__CANCELLED__")});let l=Ne();return o?Uu.createElement(R,{flexDirection:"column",marginY:1},Uu.createElement(R,{marginBottom:1},Uu.createElement(v,{bold:!0,color:l.claude},"\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")),Uu.createElement(R,{marginBottom:1},Uu.createElement(v,{bold:!0,color:l.claude}," Select a plan to continue, or create a new one")),a.map((c,u)=>{let f=u===n;return Uu.createElement(R,{key:c.isNew?"new":c.value,flexDirection:"row",marginLeft:2},Uu.createElement(v,{color:f?l.claude:l.text},f?"\u276F":" "),Uu.createElement(v,{color:f?l.claude:l.text}," "),Uu.createElement(v,{color:f?l.claude:l.text,bold:c.isNew},c.isNew?c.label:c.label.replace(".md","")),!c.isNew&&c.modified&&Uu.createElement(v,{dimColor:!0}," ","(",iAe(c.modified),")"))}),Uu.createElement(R,{marginTop:1,marginLeft:2},Uu.createElement(v,{dimColor:!0},"\u2191/\u2193 to select \xB7 Enter to confirm \xB7 Esc to cancel"))):Uu.createElement(R,{flexDirection:"column",marginY:1},Uu.createElement(v,null,"Loading plan history..."))};var cbt=ee(ge(),1),wdn={type:"local-jsx",name:"plan",description:()=>"Enable plan mode",isEnabled:!0,isHidden:!1,disableCancel:!0,async call(e){return vi.isPlanMode()?(e("Already in plan mode."),null):cbt.createElement(lbt,{onSelect:t=>{if(t==="__CANCELLED__"){e("Cancelled.");return}t&&t!=="__NEW_PLAN__"?vi.setCurrentPlanFilePath(t):vi.generatePlanFilePath(),vi.setMode("plan",!0,!1),e("Enabled plan mode")}})},userFacingName(){return"plan"}},ubt=wdn;zg();var Ddn={type:"local",name:"auto",description:()=>"Enable auto mode",isEnabled:!0,isHidden:!1,async call(){return vi.isAutoMode()?"Already in auto mode.":(vi.setMode("auto",!0),"Enabled auto mode")},userFacingName(){return"auto"}},dbt=Ddn;_r();import{resolve as Rdn}from"path";var Ndn={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=Re(),n=Rdn(r,t);ua(n);let i=Re();return i===r?`Already in ${i}.`:`Changed directory to ${i}/`},userFacingName(){return"cd"}},fbt=Ndn;var qSt=ee(ge(),1);var $n=ee(ge(),1);var cfn=ee(ge(),1);var F9=ee(ge(),1),sfn=ee(Abt(),1);var hbt={info:"blue",success:"green",error:"red",warning:"yellow"},zdn={styles:{container:({variant:e})=>({flexGrow:1,borderStyle:"round",borderColor:hbt[e],gap:1,paddingX:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:hbt[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=Jt.info),e==="success"&&(t=Jt.tick),e==="error"&&(t=Jt.cross),e==="warning"&&(t=Jt.warning),{icon:t}}},Ebt=zdn;var jdn={styles:{container:({color:e})=>({backgroundColor:e}),label:()=>({color:"black"})}},_bt=jdn;var Ydn={styles:{input:({isFocused:e})=>({dimColor:!e})}},ybt=Ydn;var Vdn={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})}},bbt=Vdn;var Wdn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})}},Cbt=Wdn;var Kdn={styles:{container:()=>({flexGrow:1,minWidth:0}),completed:()=>({color:"magenta"}),remaining:()=>({dimColor:!0})},config:()=>({completedCharacter:Jt.square,remainingCharacter:Jt.squareLightShade})},Sbt=Kdn;var Jdn={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})}},Ibt=Jdn;var Zdn={styles:{container:()=>({gap:1}),frame:()=>({color:"blue"}),label:()=>({})}},Tbt=Zdn;var Xdn={success:"green",error:"red",warning:"yellow",info:"blue"},efn={success:Jt.tick,error:Jt.cross,warning:Jt.warning,info:Jt.info},tfn={styles:{container:()=>({gap:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:Xdn[e]}),message:()=>({})},config:({variant:e})=>({icon:efn[e]})},vbt=tfn;var rfn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})},config:()=>({marker:Jt.line})},xbt=rfn;var nfn={styles:{value:()=>({})}},wbt=nfn;var ifn={styles:{value:()=>({})}},Dbt=ifn;var ofn={styles:{value:()=>({})}},Rbt=ofn;var afn={components:{Alert:Ebt,Badge:_bt,ConfirmInput:ybt,MultiSelect:bbt,OrderedList:Cbt,ProgressBar:Sbt,Select:Ibt,Spinner:Tbt,StatusMessage:vbt,UnorderedList:xbt,TextInput:wbt,EmailInput:Dbt,PasswordInput:Rbt}},lfn=(0,F9.createContext)(afn);var go=e=>(0,F9.useContext)(lfn).components[e];var ufn=ee(ge(),1);var B_=ee(ge(),1);var CO=ee(ge(),1);var Nbt=ee(ge(),1);var U9=Jt.line;var Aee=(0,Nbt.createContext)({marker:U9});function Bbt({children:e}){let{marker:t}=(0,CO.useContext)(Aee),{styles:r}=go("UnorderedList");return CO.default.createElement(R,{...r.listItem()},CO.default.createElement(v,{...r.marker()},t),CO.default.createElement(R,{...r.content()},e))}var Obt=ee(ge(),1),Xve=(0,Obt.createContext)({depth:0});function dfn({children:e}){let{depth:t}=(0,B_.useContext)(Xve),{styles:r,config:n}=go("UnorderedList"),i=(0,B_.useMemo)(()=>({depth:t+1}),[t]),o=(0,B_.useMemo)(()=>{let{marker:s}=n();return typeof s=="string"?{marker:s}:Array.isArray(s)?{marker:s[t]??s.at(-1)??U9}:{marker:U9}},[n,t]);return B_.default.createElement(Xve.Provider,{value:i},B_.default.createElement(Aee.Provider,{value:o},B_.default.createElement(R,{...r.list()},e)))}dfn.Item=Bbt;var pfn=ee(ge(),1);var ffn=ee(ge(),1);var H9=ee(ge(),1);var SO=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 kbt=ee(ge(),1);var IO=ee(ge(),1);var $9=ee(ge(),1);function Mbt({isFocused:e,isSelected:t,children:r}){let{styles:n}=go("Select");return $9.default.createElement(R,{...n.option({isFocused:e})},e&&$9.default.createElement(v,{...n.focusIndicator()},Jt.pointer),$9.default.createElement(v,{...n.label({isFocused:e,isSelected:t})},r),t&&$9.default.createElement(v,{...n.selectedIndicator()},Jt.tick))}var wm=ee(ge(),1);import{isDeepStrictEqual as mfn}from"node:util";var gfn=(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}},Qbt=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=typeof e=="number"?Math.min(e,r.length):r.length,i=new SO(r);return{optionMap:i,visibleOptionCount:n,focusedValue:i.first?.value,visibleFromIndex:0,visibleToIndex:n,previousValue:t,value:t}},Pbt=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n})=>{let[i,o]=(0,wm.useReducer)(gfn,{visibleOptionCount:e,defaultValue:r,options:t},Qbt),[s,a]=(0,wm.useState)(t);t!==s&&!mfn(t,s)&&(o({type:"reset",state:Qbt({visibleOptionCount:e,defaultValue:r,options:t})}),a(t));let l=(0,wm.useCallback)(()=>{o({type:"focus-next-option"})},[]),c=(0,wm.useCallback)(()=>{o({type:"focus-previous-option"})},[]),u=(0,wm.useCallback)(()=>{o({type:"select-focused-option"})},[]),f=(0,wm.useMemo)(()=>t.map((g,m)=>({...g,index:m})).slice(i.visibleFromIndex,i.visibleToIndex),[t,i.visibleFromIndex,i.visibleToIndex]);return(0,wm.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:f,focusNextOption:l,focusPreviousOption:c,selectFocusedOption:u}};var Lbt=({isDisabled:e=!1,state:t})=>{sr((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};function TO({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o}){let s=Pbt({visibleOptionCount:t,options:n,defaultValue:i,onChange:o});Lbt({isDisabled:e,state:s});let{styles:a}=go("Select");return IO.default.createElement(R,{...a.container()},s.visibleOptions.map(l=>{let c=l.label;if(r&&l.label.includes(r)){let u=l.label.indexOf(r);c=IO.default.createElement(IO.default.Fragment,null,l.label.slice(0,u),IO.default.createElement(v,{...a.highlightedText()},r),l.label.slice(u+r.length))}return IO.default.createElement(Mbt,{key:l.value,isFocused:!e&&s.focusedValue===l.value,isSelected:s.value===l.value},c)}))}var Afn=ee(ge(),1);var Fbt=ee(ge(),1);var Efn=ee(ge(),1);var hee=ee(ge(),1);var hfn=ee(ge(),1);var Jki=ur.inverse(" ");var Kg=ee(ge(),1);var vO=ee(ge(),1);var Ubt=ee(ge(),1);var Eee=(0,Ubt.createContext)({marker:Jt.line});function _ee({children:e}){let{marker:t}=(0,vO.useContext)(Eee),{styles:r}=go("OrderedList");return vO.default.createElement(R,{...r.listItem()},vO.default.createElement(v,{...r.marker()},t),vO.default.createElement(R,{...r.content()},e))}var Hbt=ee(ge(),1),exe=(0,Hbt.createContext)({marker:""});function Jg({children:e}){let{marker:t}=(0,Kg.useContext)(exe),{styles:r}=go("OrderedList"),n=0;for(let o of Kg.default.Children.toArray(e))!(0,Kg.isValidElement)(o)||o.type!==_ee||n++;let i=String(n).length;return Kg.default.createElement(R,{...r.list()},Kg.default.Children.map(e,(o,s)=>{if(!(0,Kg.isValidElement)(o)||o.type!==_ee)return o;let a=`${String(s+1).padStart(i)}.`,l=`${t}${a}`;return Kg.default.createElement(exe.Provider,{value:{marker:l}},Kg.default.createElement(Eee.Provider,{value:{marker:l}},o))}))}Jg.Item=_ee;var yfn=ee(ge(),1);var txe=ee(ge(),1);var _fn=ee(ge(),1);var vMi=ur.inverse(" ");var bfn=ee(ge(),1);var Cfn=ee(ge(),1);var Ifn=ee(ge(),1);var yee=ee(ge(),1);var Sfn=ee(ge(),1);var KMi=ur.inverse(" ");var Gi=ee(ge(),1);var rxe=ee(ge(),1),nxe=ee(ge(),1);i9();Rs();Li();ex();dr();var Tfn=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function ES(){let e=Tfn,{frame:t}=wR({interval:120});return rxe.createElement(R,{flexWrap:"nowrap",height:1,width:2},rxe.createElement(v,{color:Ne().claude},e[t%e.length]))}var See=ee(ge(),1);var Cee=null,O_=null,bee=new Set;function oxe(e){let{columns:t,rows:r}=e;if(t&&r)return{columns:t,rows:r};let n=jpe();return{columns:t||n.columns||80,rows:r||n.rows||24}}function ixe(){O_&&(Cee=oxe(O_),bee.forEach(e=>e(Cee)))}function vfn(e,t){return O_!==e&&(O_&&O_.off("resize",ixe),O_=e,Cee=oxe(e),e.on("resize",ixe)),bee.add(t),()=>{bee.delete(t),bee.size===0&&O_&&(O_.off("resize",ixe),O_=null,Cee=null)}}function sxe(){let{stdout:e}=wb(),[t,r]=(0,See.useState)(()=>oxe(e));return(0,See.useEffect)(()=>vfn(e,r),[e]),t}function Iee(){return sxe()}Ue();Rf();Qe();fh();Qe();var FPi=ee(DSt(),1);import{homedir as J9}from"os";import{join as DO}from"path";import{existsSync as Z9,mkdirSync as NSt,appendFileSync as RSt,readFileSync as BSt,constants as Sgn,writeFileSync as Ign,unlinkSync as OSt,statSync as Tgn}from"fs";import{platform as kSt}from"process";import{accessSync as vgn}from"fs";var Cgn="2.4.52",K9={VERSION:Cgn,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"};Ue();var px=DO(z0,".update.lock"),xgn=300*1e3;function MSt(){try{if(Z9(z0)||NSt(z0,{recursive:!0}),Z9(px)){let e=Tgn(px);if(Date.now()-e.mtimeMs<xgn)return!1;try{OSt(px)}catch(r){return Te(`Failed to remove stale lock file: ${r}`),!1}}return Ign(px,`${process.pid}`,"utf8"),!0}catch(e){return Te(`Failed to acquire lock: ${e}`),!1}}function QSt(){try{Z9(px)&&BSt(px,"utf8")===`${process.pid}`&&OSt(px)}catch(e){Te(`Failed to release lock: ${e}`)}}async function xxe(){try{let e=await ai("npm -g config get prefix");if(e.code!==0)return Te("Failed to check npm permissions"),{hasPermissions:!1,npmPrefix:null};let t=e.stdout.trim(),r=!1;try{vgn(t,Sgn.W_OK),r=!0}catch{r=!1}return r?{hasPermissions:!0,npmPrefix:t}:(Te("Insufficient permissions for global npm install."),{hasPermissions:!1,npmPrefix:t})}catch(e){return Te(`Failed to verify npm global install permissions: ${e}`),{hasPermissions:!1,npmPrefix:null}}}async function PSt(e){if(!MSt())throw Rt("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:K9.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{Z9(e)||NSt(e,{recursive:!0});let t=await ai(`npm -g config set prefix ${e}`);if(t.code!==0)throw new Error(`Failed to set npm prefix: ${t.stderr}`);let r=`
998
+ ${f}`}}),{messages:a}=t,l=ydn(o);return bdn(o,l,s,a)}},abt=Cdn;zg();var Uu=ee(ge(),1),yO=ee(ge(),1);Qe();Qe();import{existsSync as Sdn,readdirSync as Idn,statSync as Tdn}from"fs";import{join as vdn}from"path";function xdn(){let e=Xi.plan();if(!Sdn(e))return[];try{return Idn(e).filter(r=>r.endsWith(".md")).map(r=>{let n=vdn(e,r),i=Tdn(n);return{name:r,path:n,modified:i.mtime}}).sort((r,n)=>n.modified.getTime()-r.modified.getTime())}catch{return[]}}var lbt=({onSelect:e})=>{let[t,r]=(0,yO.useState)([]),[n,i]=(0,yO.useState)(0),[o,s]=(0,yO.useState)(!1);(0,yO.useEffect)(()=>{let c=xdn();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}))];sr((c,u)=>{if(u.upArrow)i(f=>f>0?f-1:a.length-1);else if(u.downArrow)i(f=>f<a.length-1?f+1:0);else if(u.return){let f=a[n];f&&e(f.value)}else u.escape&&e("__CANCELLED__")});let l=Ne();return o?Uu.createElement(R,{flexDirection:"column",marginY:1},Uu.createElement(R,{marginBottom:1},Uu.createElement(v,{bold:!0,color:l.claude},"\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")),Uu.createElement(R,{marginBottom:1},Uu.createElement(v,{bold:!0,color:l.claude}," Select a plan to continue, or create a new one")),a.map((c,u)=>{let f=u===n;return Uu.createElement(R,{key:c.isNew?"new":c.value,flexDirection:"row",marginLeft:2},Uu.createElement(v,{color:f?l.claude:l.text},f?"\u276F":" "),Uu.createElement(v,{color:f?l.claude:l.text}," "),Uu.createElement(v,{color:f?l.claude:l.text,bold:c.isNew},c.isNew?c.label:c.label.replace(".md","")),!c.isNew&&c.modified&&Uu.createElement(v,{dimColor:!0}," ","(",iAe(c.modified),")"))}),Uu.createElement(R,{marginTop:1,marginLeft:2},Uu.createElement(v,{dimColor:!0},"\u2191/\u2193 to select \xB7 Enter to confirm \xB7 Esc to cancel"))):Uu.createElement(R,{flexDirection:"column",marginY:1},Uu.createElement(v,null,"Loading plan history..."))};var cbt=ee(ge(),1),wdn={type:"local-jsx",name:"plan",description:()=>"Enable plan mode",isEnabled:!0,isHidden:!1,disableCancel:!0,async call(e){return vi.isPlanMode()?(e("Already in plan mode."),null):cbt.createElement(lbt,{onSelect:t=>{if(t==="__CANCELLED__"){e("Cancelled.");return}t&&t!=="__NEW_PLAN__"?vi.setCurrentPlanFilePath(t):vi.generatePlanFilePath(),vi.setMode("plan",!0,!1),e("Enabled plan mode")}})},userFacingName(){return"plan"}},ubt=wdn;zg();var Ddn={type:"local",name:"auto",description:()=>"Enable auto mode",isEnabled:!0,isHidden:!1,async call(){return vi.isAutoMode()?"Already in auto mode.":(vi.setMode("auto",!0),"Enabled auto mode")},userFacingName(){return"auto"}},dbt=Ddn;_r();import{resolve as Rdn}from"path";var Ndn={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=Re(),n=Rdn(r,t);ua(n);let i=Re();return i===r?`Already in ${i}.`:`Changed directory to ${i}/`},userFacingName(){return"cd"}},fbt=Ndn;var qSt=ee(ge(),1);var $n=ee(ge(),1);var cfn=ee(ge(),1);var F9=ee(ge(),1),sfn=ee(Abt(),1);var hbt={info:"blue",success:"green",error:"red",warning:"yellow"},zdn={styles:{container:({variant:e})=>({flexGrow:1,borderStyle:"round",borderColor:hbt[e],gap:1,paddingX:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:hbt[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=Jt.info),e==="success"&&(t=Jt.tick),e==="error"&&(t=Jt.cross),e==="warning"&&(t=Jt.warning),{icon:t}}},Ebt=zdn;var jdn={styles:{container:({color:e})=>({backgroundColor:e}),label:()=>({color:"black"})}},_bt=jdn;var Ydn={styles:{input:({isFocused:e})=>({dimColor:!e})}},ybt=Ydn;var Vdn={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})}},bbt=Vdn;var Wdn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})}},Cbt=Wdn;var Kdn={styles:{container:()=>({flexGrow:1,minWidth:0}),completed:()=>({color:"magenta"}),remaining:()=>({dimColor:!0})},config:()=>({completedCharacter:Jt.square,remainingCharacter:Jt.squareLightShade})},Sbt=Kdn;var Jdn={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})}},Ibt=Jdn;var Zdn={styles:{container:()=>({gap:1}),frame:()=>({color:"blue"}),label:()=>({})}},Tbt=Zdn;var Xdn={success:"green",error:"red",warning:"yellow",info:"blue"},efn={success:Jt.tick,error:Jt.cross,warning:Jt.warning,info:Jt.info},tfn={styles:{container:()=>({gap:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:Xdn[e]}),message:()=>({})},config:({variant:e})=>({icon:efn[e]})},vbt=tfn;var rfn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})},config:()=>({marker:Jt.line})},xbt=rfn;var nfn={styles:{value:()=>({})}},wbt=nfn;var ifn={styles:{value:()=>({})}},Dbt=ifn;var ofn={styles:{value:()=>({})}},Rbt=ofn;var afn={components:{Alert:Ebt,Badge:_bt,ConfirmInput:ybt,MultiSelect:bbt,OrderedList:Cbt,ProgressBar:Sbt,Select:Ibt,Spinner:Tbt,StatusMessage:vbt,UnorderedList:xbt,TextInput:wbt,EmailInput:Dbt,PasswordInput:Rbt}},lfn=(0,F9.createContext)(afn);var go=e=>(0,F9.useContext)(lfn).components[e];var ufn=ee(ge(),1);var B_=ee(ge(),1);var CO=ee(ge(),1);var Nbt=ee(ge(),1);var U9=Jt.line;var Aee=(0,Nbt.createContext)({marker:U9});function Bbt({children:e}){let{marker:t}=(0,CO.useContext)(Aee),{styles:r}=go("UnorderedList");return CO.default.createElement(R,{...r.listItem()},CO.default.createElement(v,{...r.marker()},t),CO.default.createElement(R,{...r.content()},e))}var Obt=ee(ge(),1),Xve=(0,Obt.createContext)({depth:0});function dfn({children:e}){let{depth:t}=(0,B_.useContext)(Xve),{styles:r,config:n}=go("UnorderedList"),i=(0,B_.useMemo)(()=>({depth:t+1}),[t]),o=(0,B_.useMemo)(()=>{let{marker:s}=n();return typeof s=="string"?{marker:s}:Array.isArray(s)?{marker:s[t]??s.at(-1)??U9}:{marker:U9}},[n,t]);return B_.default.createElement(Xve.Provider,{value:i},B_.default.createElement(Aee.Provider,{value:o},B_.default.createElement(R,{...r.list()},e)))}dfn.Item=Bbt;var pfn=ee(ge(),1);var ffn=ee(ge(),1);var H9=ee(ge(),1);var SO=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 kbt=ee(ge(),1);var IO=ee(ge(),1);var $9=ee(ge(),1);function Mbt({isFocused:e,isSelected:t,children:r}){let{styles:n}=go("Select");return $9.default.createElement(R,{...n.option({isFocused:e})},e&&$9.default.createElement(v,{...n.focusIndicator()},Jt.pointer),$9.default.createElement(v,{...n.label({isFocused:e,isSelected:t})},r),t&&$9.default.createElement(v,{...n.selectedIndicator()},Jt.tick))}var wm=ee(ge(),1);import{isDeepStrictEqual as mfn}from"node:util";var gfn=(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}},Qbt=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=typeof e=="number"?Math.min(e,r.length):r.length,i=new SO(r);return{optionMap:i,visibleOptionCount:n,focusedValue:i.first?.value,visibleFromIndex:0,visibleToIndex:n,previousValue:t,value:t}},Pbt=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n})=>{let[i,o]=(0,wm.useReducer)(gfn,{visibleOptionCount:e,defaultValue:r,options:t},Qbt),[s,a]=(0,wm.useState)(t);t!==s&&!mfn(t,s)&&(o({type:"reset",state:Qbt({visibleOptionCount:e,defaultValue:r,options:t})}),a(t));let l=(0,wm.useCallback)(()=>{o({type:"focus-next-option"})},[]),c=(0,wm.useCallback)(()=>{o({type:"focus-previous-option"})},[]),u=(0,wm.useCallback)(()=>{o({type:"select-focused-option"})},[]),f=(0,wm.useMemo)(()=>t.map((g,m)=>({...g,index:m})).slice(i.visibleFromIndex,i.visibleToIndex),[t,i.visibleFromIndex,i.visibleToIndex]);return(0,wm.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:f,focusNextOption:l,focusPreviousOption:c,selectFocusedOption:u}};var Lbt=({isDisabled:e=!1,state:t})=>{sr((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};function TO({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o}){let s=Pbt({visibleOptionCount:t,options:n,defaultValue:i,onChange:o});Lbt({isDisabled:e,state:s});let{styles:a}=go("Select");return IO.default.createElement(R,{...a.container()},s.visibleOptions.map(l=>{let c=l.label;if(r&&l.label.includes(r)){let u=l.label.indexOf(r);c=IO.default.createElement(IO.default.Fragment,null,l.label.slice(0,u),IO.default.createElement(v,{...a.highlightedText()},r),l.label.slice(u+r.length))}return IO.default.createElement(Mbt,{key:l.value,isFocused:!e&&s.focusedValue===l.value,isSelected:s.value===l.value},c)}))}var Afn=ee(ge(),1);var Fbt=ee(ge(),1);var Efn=ee(ge(),1);var hee=ee(ge(),1);var hfn=ee(ge(),1);var Jki=ur.inverse(" ");var Kg=ee(ge(),1);var vO=ee(ge(),1);var Ubt=ee(ge(),1);var Eee=(0,Ubt.createContext)({marker:Jt.line});function _ee({children:e}){let{marker:t}=(0,vO.useContext)(Eee),{styles:r}=go("OrderedList");return vO.default.createElement(R,{...r.listItem()},vO.default.createElement(v,{...r.marker()},t),vO.default.createElement(R,{...r.content()},e))}var Hbt=ee(ge(),1),exe=(0,Hbt.createContext)({marker:""});function Jg({children:e}){let{marker:t}=(0,Kg.useContext)(exe),{styles:r}=go("OrderedList"),n=0;for(let o of Kg.default.Children.toArray(e))!(0,Kg.isValidElement)(o)||o.type!==_ee||n++;let i=String(n).length;return Kg.default.createElement(R,{...r.list()},Kg.default.Children.map(e,(o,s)=>{if(!(0,Kg.isValidElement)(o)||o.type!==_ee)return o;let a=`${String(s+1).padStart(i)}.`,l=`${t}${a}`;return Kg.default.createElement(exe.Provider,{value:{marker:l}},Kg.default.createElement(Eee.Provider,{value:{marker:l}},o))}))}Jg.Item=_ee;var yfn=ee(ge(),1);var txe=ee(ge(),1);var _fn=ee(ge(),1);var vMi=ur.inverse(" ");var bfn=ee(ge(),1);var Cfn=ee(ge(),1);var Ifn=ee(ge(),1);var yee=ee(ge(),1);var Sfn=ee(ge(),1);var KMi=ur.inverse(" ");var Gi=ee(ge(),1);var rxe=ee(ge(),1),nxe=ee(ge(),1);i9();Rs();Li();ex();dr();var Tfn=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function ES(){let e=Tfn,{frame:t}=wR({interval:120});return rxe.createElement(R,{flexWrap:"nowrap",height:1,width:2},rxe.createElement(v,{color:Ne().claude},e[t%e.length]))}var See=ee(ge(),1);var Cee=null,O_=null,bee=new Set;function oxe(e){let{columns:t,rows:r}=e;if(t&&r)return{columns:t,rows:r};let n=jpe();return{columns:t||n.columns||80,rows:r||n.rows||24}}function ixe(){O_&&(Cee=oxe(O_),bee.forEach(e=>e(Cee)))}function vfn(e,t){return O_!==e&&(O_&&O_.off("resize",ixe),O_=e,Cee=oxe(e),e.on("resize",ixe)),bee.add(t),()=>{bee.delete(t),bee.size===0&&O_&&(O_.off("resize",ixe),O_=null,Cee=null)}}function sxe(){let{stdout:e}=wb(),[t,r]=(0,See.useState)(()=>oxe(e));return(0,See.useEffect)(()=>vfn(e,r),[e]),t}function Iee(){return sxe()}Ue();Rf();Qe();fh();Qe();var FPi=ee(DSt(),1);import{homedir as J9}from"os";import{join as DO}from"path";import{existsSync as Z9,mkdirSync as NSt,appendFileSync as RSt,readFileSync as BSt,constants as Sgn,writeFileSync as Ign,unlinkSync as OSt,statSync as Tgn}from"fs";import{platform as kSt}from"process";import{accessSync as vgn}from"fs";var Cgn="2.4.53",K9={VERSION:Cgn,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"};Ue();var px=DO(z0,".update.lock"),xgn=300*1e3;function MSt(){try{if(Z9(z0)||NSt(z0,{recursive:!0}),Z9(px)){let e=Tgn(px);if(Date.now()-e.mtimeMs<xgn)return!1;try{OSt(px)}catch(r){return Te(`Failed to remove stale lock file: ${r}`),!1}}return Ign(px,`${process.pid}`,"utf8"),!0}catch(e){return Te(`Failed to acquire lock: ${e}`),!1}}function QSt(){try{Z9(px)&&BSt(px,"utf8")===`${process.pid}`&&OSt(px)}catch(e){Te(`Failed to release lock: ${e}`)}}async function xxe(){try{let e=await ai("npm -g config get prefix");if(e.code!==0)return Te("Failed to check npm permissions"),{hasPermissions:!1,npmPrefix:null};let t=e.stdout.trim(),r=!1;try{vgn(t,Sgn.W_OK),r=!0}catch{r=!1}return r?{hasPermissions:!0,npmPrefix:t}:(Te("Insufficient permissions for global npm install."),{hasPermissions:!1,npmPrefix:t})}catch(e){return Te(`Failed to verify npm global install permissions: ${e}`),{hasPermissions:!1,npmPrefix:null}}}async function PSt(e){if(!MSt())throw Rt("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:K9.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{Z9(e)||NSt(e,{recursive:!0});let t=await ai(`npm -g config set prefix ${e}`);if(t.code!==0)throw new Error(`Failed to set npm prefix: ${t.stderr}`);let r=`
999
999
  # npm global path
1000
1000
  export PATH="${e}/bin:$PATH"
1001
1001
  `;if(kSt==="win32"){let n=await ai(`setx PATH "${process.env.PATH};${e}"`);if(n.code!==0)throw new Error(`Failed to update PATH on Windows: ${n.stderr}`)}else{let n=[DO(J9(),".bashrc"),DO(J9(),".bash_profile"),DO(J9(),".zshrc"),DO(J9(),".config","fish","config.fish")];for(let i of n)if(Z9(i))try{if(!BSt(i,"utf8").includes(e)){if(i.includes("fish")){let s=`
@@ -3156,11 +3156,11 @@ async () => {
3156
3156
  - Instructions: ${a??"(none)"}
3157
3157
  - Methods: ${l}`}).join(`
3158
3158
  `)}async function A7t(){return G3n.replace("{{providers}}",await z3n())}async function j3n(e){let t=[];for(let r of e){if(r.type!=="connected")continue;let n={};try{let{tools:i}=await r.client.listTools();for(let o of i)n[o.name]=async s=>ZUt(r.client,o.name,s)}catch(i){console.warn(`Failed to list tools for codemode client ${r.name}:`,i);continue}t.push({name:r.name,fns:n})}return t}function h7t(){let e=new pse;return{name:"codemode",inputSchema:q3n,inputJSONSchema:{type:"object",properties:{code:{type:"string",description:"JavaScript async arrow function to execute"},timeout:{type:"number",description:"Execution timeout in seconds. Defaults to 60."}},required:["code"]},async description(t){return t?.code?"Execute JavaScript code":A7t()},async prompt(){return A7t()},userFacingName(){return"codemode"},async isEnabled(){return!0},isReadOnly(){return!1},isMcp(){return!1},needsPermissions(){return!0},async validateInput(t){return!t.code||typeof t.code!="string"?{result:!1,message:"code is required"}:{result:!0}},renderResultForAssistant(t){return t.error?`Error: ${t.error}`:JLe(t.result)},renderToolUseMessage(t){return t.code.split(`
3159
- `)[0]??"codemode"},renderToolResultMessage(t){let r=Zzt(t.result);return U1.createElement(R,{flexDirection:"column"},t.error?U1.createElement(R,{flexDirection:"row",key:"error"},U1.createElement(v,null," \u23BF "),U1.createElement(v,{color:"red",key:"error-text"},`Error: ${t.error}`)):null,U1.createElement(R,{flexDirection:"row",key:"result"},U1.createElement(v,null," \u23BF "),U1.createElement(v,{key:"result-text"},r)))},async*call(t,r,n){let i=r??{abortController:new AbortController,readFileTimestamps:{}},o=oy(),s=Object.keys(o),[a,l]=await Promise.all([uE(),Iie().catch(()=>[])]),c=await j3n(a),u=mse(),f={search:async A=>c7t(A,l,u,s),describe:async A=>g7t(A,l,u,s7t()),saveSnippet:async(A,h,_,y,S)=>{if(typeof h!="string"||h.length===0)throw new Error("saveSnippet: code must be a non-empty string (a function or string of snippet code)");for(let[w,O]of[["inputSchema",y],["outputSchema",S]])if(O!==void 0&&(O===null||typeof O!="object"))throw new Error(`saveSnippet: ${w} must be an object when provided`);let I={name:A,description:_,code:h,savedAt:Date.now(),connectors:s,...y!==void 0?{inputSchema:y}:{},...S!==void 0?{outputSchema:S}:{}};return r7t(I),{saved:!0,name:A}},saveOutputSchema:async(A,h,_)=>{let[y,S,I]=Array.isArray(A)?A:[A,h,_];if(typeof y!="string"||!y.includes("."))throw new Error('saveOutputSchema: target must be in the form "provider.method"');if(S===null||typeof S!="object")throw new Error("saveOutputSchema: outputSchema must be an object");let w={target:y,outputSchema:S,description:I,savedAt:Date.now()};return a7t(w),{saved:!0,target:y}},__snippetCode:async A=>{let h=n7t(A);if(!h)throw new Error(`Snippet not found: ${A}`);return h.code}},g=typeof t.timeout=="number"&&t.timeout>0?t.timeout*1e3:void 0,m=await e.execute(e7t(t.code),c,f,g);yield{type:"result",data:m,resultForAssistant:m.error?`Error: ${m.error}`:JLe(m.result)}}}}var Y3n=k.object({code:k.string().describe("JavaScript async arrow function to execute"),timeout:k.number().optional().describe("Execution timeout in seconds. Defaults to 60.")}),rQ=h7t(),E7t={...rQ,name:"codemode",inputSchema:Y3n,async description(e){return rQ.description(e)},async prompt(){return rQ.description()},userFacingName(){return"Code"},async isEnabled(){try{return(await Iie()).length>0}catch{return!1}},isReadOnly(){return!1},isMcp(){return!1},needsPermissions(){return!0},async validateInput(e){return!e.code||typeof e.code!="string"?{result:!1,message:"code is required"}:{result:!0}},renderResultForAssistant(e){return e.error?`Error: ${e.error}`:rQ.renderResultForAssistant(e)},renderToolUseMessage(e){return e.code},renderToolResultMessage(e){return rQ.renderToolResultMessage(e)},async*call(e,t,r){yield*rQ.call(e,t,r)}};var nQ=ee(ge(),1);Pr();Zt();yP();Ue();var _7t=Pi,y7t="Proxies calls to all other tools by tool name, and can load the target tool usage guide and its TS arguments type",b7t=`Proxies calls to all other tools by tool name, and can load the target tool usage guide and its TS arguments type.
3159
+ `)[0]??"codemode"},renderToolResultMessage(t){let r=Zzt(t.result);return U1.createElement(R,{flexDirection:"column"},t.error?U1.createElement(R,{flexDirection:"row",key:"error"},U1.createElement(v,null," \u23BF "),U1.createElement(v,{color:"red",key:"error-text"},`Error: ${t.error}`)):null,U1.createElement(R,{flexDirection:"row",key:"result"},U1.createElement(v,null," \u23BF "),U1.createElement(v,{key:"result-text"},r)))},async*call(t,r,n){let i=r??{abortController:new AbortController,readFileTimestamps:{}},o=oy(),s=Object.keys(o),[a,l]=await Promise.all([uE(),Iie().catch(()=>[])]),c=await j3n(a),u=mse(),f={search:async A=>c7t(A,l,u,s),describe:async A=>g7t(A,l,u,s7t()),saveSnippet:async(A,h,_,y,S)=>{if(typeof h!="string"||h.length===0)throw new Error("saveSnippet: code must be a non-empty string (a function or string of snippet code)");for(let[w,O]of[["inputSchema",y],["outputSchema",S]])if(O!==void 0&&(O===null||typeof O!="object"))throw new Error(`saveSnippet: ${w} must be an object when provided`);let I={name:A,description:_,code:h,savedAt:Date.now(),connectors:s,...y!==void 0?{inputSchema:y}:{},...S!==void 0?{outputSchema:S}:{}};return r7t(I),{saved:!0,name:A}},saveOutputSchema:async(A,h,_)=>{let[y,S,I]=Array.isArray(A)?A:[A,h,_];if(typeof y!="string"||!y.includes("."))throw new Error('saveOutputSchema: target must be in the form "provider.method"');if(S===null||typeof S!="object")throw new Error("saveOutputSchema: outputSchema must be an object");let w={target:y,outputSchema:S,description:I,savedAt:Date.now()};return a7t(w),{saved:!0,target:y}},__snippetCode:async A=>{let h=n7t(A);if(!h)throw new Error(`Snippet not found: ${A}`);return h.code}},g=typeof t.timeout=="number"&&t.timeout>0?t.timeout*1e3:void 0,m=await e.execute(e7t(t.code),c,f,g);yield{type:"result",data:m,resultForAssistant:m.error?`Error: ${m.error}`:JLe(m.result)}}}}var Y3n=k.object({code:k.string().describe("JavaScript async arrow function to execute"),timeout:k.number().optional().describe("Execution timeout in seconds. Defaults to 60.")}),rQ=h7t(),E7t={...rQ,name:"codemode",inputSchema:Y3n,async description(e){return rQ.description(e)},async prompt(){return rQ.description()},userFacingName(){return"Code"},async isEnabled(){try{return(await Iie()).length>0}catch{return!1}},isReadOnly(){return!1},isMcp(){return!1},needsPermissions(){return!0},async validateInput(e){return!e.code||typeof e.code!="string"?{result:!1,message:"code is required"}:{result:!0}},renderResultForAssistant(e){return e.error?`Error: ${e.error}`:rQ.renderResultForAssistant(e)},renderToolUseMessage(e){return e.code},renderToolResultMessage(e){return rQ.renderToolResultMessage(e)},async*call(e,t,r){yield*rQ.call(e,t,r)}};var nQ=ee(ge(),1);Pr();Zt();yP();Ue();var _7t=Pi,y7t="Proxies calls to tools listed in <loadable_tools>, and can load the target tool's usage guide and its TS arguments type",b7t=`Proxies calls to tools listed in <loadable_tools>, and can load the target tool usage guide and its TS arguments type.
3160
3160
  The tools that appear in <loadable_tools> are NOT directly callable in this conversation \u2014 they are a catalog only. Every one of them MUST be invoked through ${Pi}. Calling them by their own names (e.g. Glob, Read, Grep) will fail.
3161
3161
 
3162
3162
  ## Discovery-First Rule
3163
- For each tool, you MUST load it once before your first call in this conversation. After the load, reuse the returned type signature for subsequent calls. Never guess method names, parameter names, types, or structure.
3163
+ For each tool in <loadable_tools>, you MUST load it once before your first call in this conversation. After the load, reuse the returned type signature for subsequent calls. Never guess method names, parameter names, types, or structure.
3164
3164
  - FIRST: ${Pi}({ proxyToolAction: "load", toolName: "Glob" })
3165
3165
  THEN: ${Pi}({ proxyToolAction: "call", toolName: "Glob", arguments: { pattern: "**/*.ts" } })
3166
3166
 
@@ -3170,7 +3170,7 @@ For each tool, you MUST load it once before your first call in this conversation
3170
3170
 
3171
3171
  - call: ${Pi}({ proxyToolAction: "call", toolName: "<tool_name>", arguments: { ... } })
3172
3172
  \u2192 Executes the target tool.
3173
- \u2192 The \`arguments\` object MUST strictly match the TypeScript type signature returned by \`load\`.
3173
+ \u2192 The \`arguments\` object MUST strictly match the TypeScript type signature returned by \`load\` for that same toolName..
3174
3174
 
3175
3175
  ## Examples
3176
3176
  - WRONG: Glob({ pattern: "**/*.ts" })
@@ -3182,7 +3182,7 @@ For each tool, you MUST load it once before your first call in this conversation
3182
3182
 
3183
3183
  ## Rules
3184
3184
  - Do not proxy tools that are not in <loadable_tools>. Do not invent tool names.
3185
- `;bd();Ue();dr();var V3n=ke(()=>k.object({proxyToolAction:k.enum(["call","load"]).default("load").describe("call=invoke the target tool; load=get the target tool usage guide and its TS arguments type"),toolName:k.string().describe("Name of the tool to invoke"),arguments:k.record(k.unknown()).optional().describe("call mode only: arguments object for the target tool; must match the TS arguments type shown in the load result of the same tool; when unsure, run proxyToolAction:'load' first instead of guessing. Ignored in load mode.")})),W3n={type:"object",properties:{proxyToolAction:{type:"string",enum:["call","load"],default:"load",description:"call=invoke the target tool; load=get the target tool usage guide and its TS arguments type"},toolName:{type:"string",description:"Name of the tool to invoke"},arguments:{type:"object",description:"call mode only: arguments object for the target tool; must match the TS arguments type shown in the load result of the same tool; when unsure, run proxyToolAction:'load' first instead of guessing. Ignored in load mode."}},required:["toolName"]};async function C7t(e){return e?.options?._tools??await tn.getTools(!1)??[]}function nFe(e){return e.name!==Pi&&e.name!==vz&&!xz.includes(e.name)}var S7t={name:_7t,async description(){return y7t},async prompt({dangerouslySkipPermissions:e}={},t){let n=(await C7t(t)).filter(nFe),i=(await Promise.all(n.map(async o=>`<tool><name>${o.name}</name><description>${o.isMcp?.()?qO.getSimpleDescription(o.name):await o.description?.()}</description></tool>`))).join(`
3185
+ `;bd();Ue();dr();var V3n=ke(()=>k.object({proxyToolAction:k.enum(["call","load"]).default("load").describe("call=invoke the target tool; load=get the target tool usage guide and its TS arguments type"),toolName:k.string().describe("Name of the tool to invoke"),arguments:k.record(k.unknown()).optional().describe("call mode only: arguments object for the target tool; must match the TS arguments type shown in the load result of the same tool; when unsure, run proxyToolAction:'load' first instead of guessing. Ignored in load mode.")})),W3n={type:"object",properties:{proxyToolAction:{type:"string",enum:["call","load"],description:"call=invoke the target tool; load=get the target tool usage guide and its TS arguments type. Set only here, never in arguments"},toolName:{type:"string",description:"Exact target tool name from <loadable_tools>; not ProxyTool. Set only here, never in arguments; used by both load and call"},arguments:{type:"object",description:"call mode only: arguments object for the target tool; must match the TS arguments type shown in the load result of the same tool; when unsure, run proxyToolAction:'load' first instead of guessing. omit in load mode."}},required:["proxyToolAction","toolName"]};async function C7t(e){return e?.options?._tools??await tn.getTools(!1)??[]}function nFe(e){return e.name!==Pi&&e.name!==vz&&!xz.includes(e.name)}var S7t={name:_7t,async description(){return y7t},async prompt({dangerouslySkipPermissions:e}={},t){let n=(await C7t(t)).filter(nFe),i=(await Promise.all(n.map(async o=>`<tool><name>${o.name}</name><description>${o.isMcp?.()?qO.getSimpleDescription(o.name):await o.description?.()}</description></tool>`))).join(`
3186
3186
  `);return`${b7t}
3187
3187
  <loadable_tools>
3188
3188
  ${i}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dahawa/hawa-code",
3
- "version": "2.4.52",
3
+ "version": "2.4.53",
4
4
  "bin": {
5
5
  "hcode": "hawa.js"
6
6
  },