@dahawa/hawa-code 2.6.10 → 2.6.11

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 +3 -3
  2. package/hands.js +3 -3
  3. package/package.json +1 -1
package/cli.js CHANGED
@@ -652,7 +652,7 @@ globstar while`,e,d,t,f,p),this.matchOne(e.slice(d),t.slice(f),r))return this.de
652
652
  `)),gWr(e,o,{encoding:r,flush:!0})}var oat=new OJ.default({fetchMethod:e=>yWr(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});async function pat(e){let t=m5(e);return oat.get(t)||oat.fetchMethod?.(t)}async function yWr(e){let t=new AbortController;setTimeout(()=>{t.abort()},1e3);let r=await Trt(e,t.signal,15),n=0;for(let o of r)pw(o)==="CRLF"&&n++;return n>3?"CRLF":"LF"}function mat(e,t,r){if(e.has(t))return e.get(t);let n=r();return e.set(t,n),n}var CWr=new OJ.default({fetchMethod:e=>fat(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});function Vp(e){let t=m5(e);return mat(CWr,t,()=>fat(t))}function fat(e){let r=Buffer.alloc(4096),n;try{n=iat(e,"r");let o=sat(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 be(`Error detecting encoding for file ${e}: ${o}`),"utf8"}finally{n&&aat(n)}}var TWr=new OJ.default({fetchMethod:e=>gat(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});function pw(e){let t=m5(e);return mat(TWr,t,()=>gat(t))}function gat(e,t="utf8"){try{if(!lat(e).isFile())return"LF";let n=Buffer.alloc(4096),o=iat(e,"r"),i=sat(o,n,0,4096,0);aat(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 be(`Error detecting line endings for file ${e}: ${r}`),"LF"}}function rk(e){let t=cat(e)?e:m5(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 Ibe(e){return e?cat(e)?e:m5(Ne(),e):void 0}function hat(e){try{let t=Ibe(e),r=t?EWr(Ne(),t):void 0;return{absolutePath:t,relativePath:r}}catch(t){return re("getAbsoluteAndRelativePaths error ",t),{absolutePath:null,relativePath:null}}}function MJ(e){try{let t=bWr(e),r=tat(e,rat(e));if(!hWr(t))return;let i=AWr(t).filter(s=>tat(s,rat(s))===r&&SWr(t,s)!==e)[0];return i||void 0}catch(t){be(`Error finding similar file for ${e}: ${t}`);return}}function vbe(){let e=process.env.HAWA_CODE_COMPACT_LINE_PREFIX;return!(e==="0"||e==="false")}function OT({content:e,startLine:t}){if(!e)return"";let r=e.split(/\r?\n/);return vbe()?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 Aat(e){try{let t=_Wr(e),r=t.readSync();return t.closeSync(),r===null}catch(t){return be(`Error checking directory: ${t}`),!1}}ke();var xa=M(J(),1);function wT(){let e=Pn();e.hasCompletedProjectOnboarding||ui({...e,hasCompletedProjectOnboarding:!0})}function xbe({workspaceDir:e}){let r=!Pn().hasCompletedProjectOnboarding;if(!r)return null;let n=IWr(vWr(e,Ko)),o=Aat(e),i=!n&&!o,s=jM.isEnabled&&!Gr().shiftEnterKeyBindingInstalled,a=ne();return(0,xa.jsxs)(v,{flexDirection:"column",gap:1,padding:1,paddingBottom:0,children:[r&&(0,xa.jsxs)(xa.Fragment,{children:[(0,xa.jsx)(T,{color:a.secondaryText,children:"Tips for getting started:"}),(0,xa.jsx)(mu,{children:(()=>{let l=[];return o&&l.push((0,xa.jsx)(mu.Item,{children:(0,xa.jsxs)(T,{color:a.secondaryText,children:["Ask ",rt," to create a new app or clone a repository."]})},"workspace")),i&&l.push((0,xa.jsx)(mu.Item,{children:(0,xa.jsxs)(T,{color:a.secondaryText,children:["Run ",(0,xa.jsx)(T,{color:a.text,children:"/init"})," to create a",Ko," file with instructions for Hawa code."]})},"claudemd")),s&&l.push((0,xa.jsx)(mu.Item,{children:(0,xa.jsxs)(T,{color:a.secondaryText,children:["Run ",(0,xa.jsx)(T,{color:a.text,children:"/terminal-setup"}),(0,xa.jsx)(T,{bold:!1,children:" to set up terminal integration"})]})},"terminal")),l.push((0,xa.jsx)(mu.Item,{children:(0,xa.jsxs)(T,{color:a.secondaryText,children:["Ask ",rt," questions about your codebase."]})},"questions")),l.push((0,xa.jsx)(mu.Item,{children:(0,xa.jsxs)(T,{color:a.secondaryText,children:["Ask ",rt," to implement changes to your codebase."]})},"changes")),l})()})]}),e===xWr()&&(0,xa.jsxs)(T,{color:ne().warning,children:["Note: You have launched ",(0,xa.jsx)(T,{bold:!0,children:rt})," in your home directory. For the best experience, launch it in a project directory instead."]})]})}var nk=M(J(),1);function wbe({isFocused:e,isSelected:t,smallPointer:r,children:n}){let{styles:o}=Mi("Select");return(0,nk.jsxs)(v,{...o.option({isFocused:e}),children:[e&&(0,nk.jsx)(T,{...o.focusIndicator(),children:r?nr.triangleDownSmall:nr.pointer}),(0,nk.jsx)(T,{...o.label({isFocused:e,isSelected:t}),children:n}),t&&(0,nk.jsx)(T,{...o.selectedIndicator(),children:nr.tick})]})}var Wp=M($e(),1);import{isDeepStrictEqual as wWr}from"node:util";var f5=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:Rbe(s);r.push([l,a]),i++,o=a}super(r),this.first=n}};var RWr=(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}}},Nbe=e=>e.flatMap(t=>{if("options"in t){let r=Nbe(t.options),n=r.flatMap(i=>"value"in i?i.value:[]);return[...t.header!==void 0?[{header:t.header,optionValues:n}]:[],...r]}return t}),_at=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=Nbe(r),o=typeof e=="number"?Math.min(e,n.length):n.length,i=new f5(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}},Dbe=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n,onFocus:o,focusValue:i})=>{let s=Nbe(t),[a,l]=(0,Wp.useReducer)(RWr,{visibleOptionCount:e,defaultValue:r,options:t},_at),[c,u]=(0,Wp.useState)(s);s!==c&&!wWr(s,c)&&(l({type:"reset",state:_at({visibleOptionCount:e,defaultValue:r,options:t})}),u(s));let d=(0,Wp.useCallback)(()=>{l({type:"focus-next-option"})},[]),f=(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:f,selectFocusedOption:p}};var Obe=({isDisabled:e=!1,state:t})=>{ft((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};var BT=M(J(),1),Rbe=e=>`HEADER-${e.optionValues.join(",")}`;function JS({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a}){let l=Dbe({visibleOptionCount:t,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a});Obe({isDisabled:e,state:l});let{styles:c}=Mi("Select");return(0,BT.jsx)(v,{...c.container(),children:l.visibleOptions.map(u=>{let d="value"in u?u.value:Rbe(u),f=!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 b=A.indexOf(r);_=(0,BT.jsxs)(BT.Fragment,{children:[A.slice(0,b),(0,BT.jsx)(T,{...c.highlightedText(),children:r}),A.slice(b+r.length)]})}return(0,BT.jsx)(wbe,{isFocused:f,isSelected:p,smallPointer:h,children:_},d)})})}var mw=M(J(),1);function Eat({onDone:e}){return ft((t,r)=>{(r.ctrl&&(t==="c"||t==="d")||r.escape)&&e()}),(0,mw.jsxs)(v,{flexDirection:"column",borderStyle:"round",padding:1,borderColor:ne().secondaryBorder,children:[(0,mw.jsx)(v,{marginBottom:1,flexDirection:"column",children:(0,mw.jsx)(T,{bold:!0,children:"You've spent $5 this session."})}),(0,mw.jsx)(v,{children:(0,mw.jsx)(JS,{options:[{value:"ok",label:"Got it, thanks!"}],onChange:e})})]})}var Zt=M($e(),1);ke();cr();mE();var OWr="2.6.10",fE={VERSION:OWr,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 pd=M(J(),1),kbe=46,yat=["(\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 kJ({isDefaultModel:e=!1}){let t=Math.max(kbe,Ne().length+12),r=ne(),n=yat[Math.floor(Math.random()*yat.length)];return(0,pd.jsx)(v,{flexDirection:"column",children:(0,pd.jsxs)(v,{flexDirection:"column",gap:1,paddingLeft:1,width:"100%",children:[(0,pd.jsxs)(T,{children:[(0,pd.jsx)(T,{children:n})," Welcome to"," ",(0,pd.jsx)(T,{bold:!0,children:rt}),(0,pd.jsxs)(T,{color:r.secondaryText,children:[" v",fE.VERSION]})]}),(0,pd.jsx)(pd.Fragment,{children:(0,pd.jsxs)(v,{paddingLeft:2,flexDirection:"column",gap:1,children:[(0,pd.jsx)(T,{color:r.secondaryText,italic:!0,children:"/help for help"}),(0,pd.jsxs)(T,{color:r.secondaryText,children:["cwd: ",Ne()]}),(0,pd.jsxs)(T,{color:r.secondaryText,children:["model: ",oo.getConfig().routing.MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A"]}),(0,pd.jsxs)(T,{color:r.secondaryText,children:["small fast model: ",oo.getConfig().routing.SMALL_FAST_MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A"]})]})})]})})}Re();import{randomUUID as Kh}from"crypto";ms();Re();Xt();cr();Re();ke();import{existsSync as ey,readdirSync as aZr,statSync as lZr}from"fs";import{join as FT,relative as cZr}from"path";import{homedir as gut}from"os";import{platform as uZr}from"process";import{readFile as QT}from"fs/promises";cr();cf();lr();import{join as FWr,sep as QWr}from"path";function tp(){if(!fu())return!1;try{let e=nt();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function jp(){return(FWr(Ne(),".hcode","team-memory")+QWr).normalize("NFC")}function Xg(e){let t=e.normalize("NFC"),r=jp();return t.startsWith(r)}cf();var hut=M(C5(),1);wo();var Xbe=(e,t,r)=>{let n=e instanceof RegExp?$ct(e,r):e,o=t instanceof RegExp?$ct(t,r):t,i=n!==null&&o!=null&&JKr(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)}},$ct=(e,t)=>{let r=t.match(e);return r?r[0]:null},JKr=(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 qct="\0SLASH"+Math.random()+"\0",Yct="\0OPEN"+Math.random()+"\0",rSe="\0CLOSE"+Math.random()+"\0",zct="\0COMMA"+Math.random()+"\0",Vct="\0PERIOD"+Math.random()+"\0",ZKr=new RegExp(qct,"g"),XKr=new RegExp(Yct,"g"),eJr=new RegExp(rSe,"g"),tJr=new RegExp(zct,"g"),rJr=new RegExp(Vct,"g"),nJr=/\\\\/g,oJr=/\\{/g,iJr=/\\}/g,sJr=/\\,/g,aJr=/\\\./g,lJr=1e5,cJr=4e6;function eSe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function uJr(e){return e.replace(nJr,qct).replace(oJr,Yct).replace(iJr,rSe).replace(sJr,zct).replace(aJr,Vct)}function dJr(e){return e.replace(ZKr,"\\").replace(XKr,"{").replace(eJr,"}").replace(tJr,",").replace(rJr,".")}function Wct(e){if(!e)return[""];let t=[],r=Xbe("{","}",e);if(!r)return e.split(",");let{pre:n,body:o,post:i}=r,s=n.split(",");s[s.length-1]+="{"+o+"}";let a=Wct(i);return i.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function jct(e,t={}){if(!e)return[];let{max:r=lJr,maxLength:n=cJr}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),tSe(uJr(e),r,n,!0).map(dJr)}function pJr(e){return"{"+e+"}"}function mJr(e){return/^-?0\d/.test(e)}function fJr(e,t){return e<=t}function gJr(e,t){return e>=t}function T5(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 hJr(e,t,r,n){let o=e.split(/\.\./),i=[];if(o[0]===void 0||o[1]===void 0)return i;let s=eSe(o[0]),a=eSe(o[1]),l=Math.max(o[0].length,o[1].length),c=o.length===3&&o[2]!==void 0?Math.max(Math.abs(eSe(o[2])),1):1,u=fJr;a<s&&(c*=-1,u=gJr);let f=o.some(mJr),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),f){let _=l-A.length;if(_>0){let b=new Array(_+1).join("0");h<0?A="-"+b+A.slice(1):A=b+A}}if(p+A.length>n)break;i.push(A),p+=A.length}return i}function tSe(e,t,r,n){let o=[""],i=!1,s=!0;for(;;){let a=Xbe("{","}",e);if(!a)return T5(o,e,[""],t,r,i);let l=a.pre;if(/\$$/.test(l)){if(o=T5(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,f=a.body.indexOf(",")>=0;if(!d&&!f){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+rSe+a.post,n=!0;continue}return T5(o,l+"{"+a.body+"}"+a.post,[""],t,r,i)}s&&(i=n&&!d,s=!1);let p;if(d)p=hJr(a.body,u,t,r);else{let h=Wct(a.body);if(h.length===1&&h[0]!==void 0&&(h=tSe(h[0],t,r,!1).map(pJr),h.length===1)){if(o=T5(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 b=0;A&&b<o.length;b++)o[b]&&(A=!1);p=[];let _=0;e:for(let b=0;b<h.length;b++){let y=tSe(h[b],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=T5(o,l,p,t,r,i&&!a.post.length),!a.post.length)break;e=a.post}return o}var I5=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var AJr={"[: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]},v5=e=>e.replace(/[[\]\\-]/g,"\\$&"),_Jr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Kct=e=>e.join(""),Jct=(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[_,[b,y,I]]of Object.entries(AJr))if(e.startsWith(_,i)){if(d)return["$.",!1,e.length-r,!0];i+=_.length,I?o.push(b):n.push(b),a=a||y;continue e}}if(l=!1,d){A>d?n.push(v5(d)+"-"+v5(A)):A===d&&n.push(v5(A)),d="",i++;continue}if(e.startsWith("-]",i+1)){n.push(v5(A+"-")),i+=2;continue}if(e.startsWith("-",i+1)){d=A,i+=2;continue}n.push(v5(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[_Jr(A),!1,u-r,!1]}let f="["+(c?"^":"")+Kct(n)+"]",p="["+(c?"":"^")+Kct(o)+"]";return[n.length&&o.length?"("+f+"|"+p+")":n.length?f:p,a,u-r,!0]};var PT=(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,EJr=new Set(["!","?","+","*","@"]),nSe=e=>EJr.has(e),Zct=e=>nSe(e.type),bJr=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),SJr=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),yJr=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),Xct=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),CJr="(?!(?:^|/)\\.\\.?(?:$|/))",VJ="(?!\\.)",TJr=new Set(["[","."]),IJr=new Set(["..","."]),vJr=new Set("().*{}+?[]^$\\!"),xJr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),oSe="[^/]",eut=oSe+"*?",tut=oSe+"+?",wJr=0,Sw=class{type;#e;#t;#n=!1;#r=[];#i;#o;#l;#s=!1;#a;#d;#m=!1;id=++wJr;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 b=t.charAt(A++);if(a||b==="\\"){a=!a,_+=b;continue}if(l){A===c+1?(b==="^"||b==="!")&&(u=!0):b==="]"&&!(A===c+2&&u)&&(l=!1),_+=b;continue}else if(b==="["){l=!0,c=A,u=!1,_+=b;continue}if(!o.noext&&nSe(b)&&t.charAt(A)==="("&&i<=s){r.push(_),_="";let I=new Jp(b,r);A=Jp.#c(t,I,A,o,i+1),r.push(I);continue}_+=b}return r.push(_),A}let d=n+1,f=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&&nSe(A)&&t.charAt(d)==="("&&(i<=s||r&&r.#_(A))){let b=r&&r.#_(A)?0:1;f.push(h),h="";let y=new Jp(A,f);f.push(y),d=Jp.#c(t,y,d,o,i+b);continue}if(A==="|"){f.push(h),h="",p.push(f),f=new Jp(null,r);continue}if(A===")")return h===""&&r.#r.length===0&&(r.#m=!0),f.push(h),h="",r.push(...p,f),d;h+=A}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],d}#g(t){return this.#A(t,SJr)}#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=yJr){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}#b(t){return!!Xct.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.#b(r.type)}#T(t){let r=Xct.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()),!Zct(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(p=>typeof p!="string"),c=this.#r.map(p=>{let[h,A,_,b]=typeof p=="string"?Jp.#y(p,this.#t,l):p.toRegExpSource(t);return this.#t=this.#t||_,this.#n=this.#n||b,h}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&IJr.has(this.#r[0]))){let h=TJr,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?CJr:_?VJ:""}let d="";return this.isEnd()&&this.#e.#s&&this.#i?.type==="!"&&(d="(?:$|\\/)"),[u+c+d,PT(c),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",o=this.type==="!"?"(?:(?!(?:":"(?:",i=this.#S(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,PT(this.toString()),!1,!1]}let s=!n||t||r||!VJ?"":this.#S(!0);s===i&&(s=""),s&&(i=`(?:${i})(?:${s})*?`);let a="";if(this.type==="!"&&this.#m)a=(this.isStart()&&!r?VJ:"")+tut;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?VJ:"")+eut+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=o+i+l}return[a,PT(i),this.#t=!!this.#t,this.#n]}#E(){if(Zct(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}#S(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+=(vJr.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,i+=n&&/^[*]+$/.test(t)?tut:eut,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?i+="\\\\":o=!0;continue}if(c==="["){let[u,d,f,p]=Jct(t,l);if(f){i+=u,s=s||d,l+=f-1,r=r||p;continue}}if(c==="?"){i+=oSe,r=!0;continue}i+=xJr(c)}return[i,PT(t),!!r,s]}};Jp=Sw;var iSe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var gu=(e,t,r={})=>(I5(t),!r.nocomment&&t.charAt(0)==="#"?!1:new fk(t,r).match(e)),RJr=/^\*+([^+@!?*[(]*)$/,NJr=e=>t=>!t.startsWith(".")&&t.endsWith(e),DJr=e=>t=>t.endsWith(e),OJr=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),BJr=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),MJr=/^\*+\.\*+$/,kJr=e=>!e.startsWith(".")&&e.includes("."),LJr=e=>e!=="."&&e!==".."&&e.includes("."),PJr=/^\.\*+$/,FJr=e=>e!=="."&&e!==".."&&e.startsWith("."),QJr=/^\*+$/,UJr=e=>e.length!==0&&!e.startsWith("."),GJr=e=>e.length!==0&&e!=="."&&e!=="..",HJr=/^\?+([^+@!?*[(]*)?$/,$Jr=([e,t=""])=>{let r=out([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},qJr=([e,t=""])=>{let r=iut([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},YJr=([e,t=""])=>{let r=iut([e]);return t?n=>r(n)&&n.endsWith(t):r},zJr=([e,t=""])=>{let r=out([e]);return t?n=>r(n)&&n.endsWith(t):r},out=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},iut=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},sut=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",rut={win32:{sep:"\\"},posix:{sep:"/"}},VJr=sut==="win32"?rut.win32.sep:rut.posix.sep;gu.sep=VJr;var fd=Symbol("globstar **");gu.GLOBSTAR=fd;var WJr="[^/]",jJr=WJr+"*?",KJr="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",JJr="(?:(?!(?:\\/|^)\\.).)*?",ZJr=(e,t={})=>r=>gu(r,e,t);gu.filter=ZJr;var eh=(e,t={})=>Object.assign({},e,t),XJr=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return gu;let t=gu;return Object.assign((n,o,i={})=>t(n,o,eh(e,i)),{Minimatch:class extends t.Minimatch{constructor(o,i={}){super(o,eh(e,i))}static defaults(o){return t.defaults(eh(e,o)).Minimatch}},AST:class extends t.AST{constructor(o,i,s={}){super(o,i,eh(e,s))}static fromGlob(o,i={}){return t.AST.fromGlob(o,eh(e,i))}},unescape:(n,o={})=>t.unescape(n,eh(e,o)),escape:(n,o={})=>t.escape(n,eh(e,o)),filter:(n,o={})=>t.filter(n,eh(e,o)),defaults:n=>t.defaults(eh(e,n)),makeRe:(n,o={})=>t.makeRe(n,eh(e,o)),braceExpand:(n,o={})=>t.braceExpand(n,eh(e,o)),match:(n,o,i={})=>t.match(n,o,eh(e,i)),sep:t.sep,GLOBSTAR:fd})};gu.defaults=XJr;var aut=(e,t={})=>(I5(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:jct(e,{max:t.braceExpandMax}));gu.braceExpand=aut;var eZr=(e,t={})=>new fk(e,t).makeRe();gu.makeRe=eZr;var tZr=(e,t,r={})=>{let n=new fk(t,r);return e=e.filter(o=>n.match(o)),n.options.nonull&&!e.length&&e.push(t),e};gu.match=tZr;var nut=/[?*]|[+@!]\(.*?\)|\[|\]/,rZr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),fk=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){I5(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||sut,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]==="?"||!nut.test(i[2]))&&!nut.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,f=u?3:c?0:void 0;if(typeof d=="number"&&typeof f=="number"){let[p,h]=[t[d],r[f]];p.toLowerCase()===h.toLowerCase()&&(r[f]=p,i=f,o=d)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(fd)?this.#e(t,r,n,o,i):this.#n(t,r,n,o,i)}#e(t,r,n,o,i){let s=r.indexOf(fd,i),a=r.lastIndexOf(fd),[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 f=[[[],0]],p=f[0],h=0,A=[0];for(let y of c)y===fd?(A.push(h),p=[[],0],f.push(p)):(p[0].push(y),h++);let _=f.length-1,b=t.length-d;for(let y of f)y[1]=b-(A[_--]+y[0].length);return!!this.#t(t,f,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 f=t[d];if(f==="."||f===".."||!this.options.dot&&f.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 f=t[n];if(f==="."||f===".."||!this.options.dot&&f.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===fd)return!1;let f;if(typeof u=="string"?(f=d===u,this.debug("string match",u,d,f)):(f=u.test(d),this.debug("pattern match",u,d,f)),!f)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 aut(this.pattern,this.options)}parse(t){I5(t);let r=this.options;if(t==="**")return fd;if(t==="")return"";let n,o=null;(n=t.match(QJr))?o=r.dot?GJr:UJr:(n=t.match(RJr))?o=(r.nocase?r.dot?BJr:OJr:r.dot?DJr:NJr)(n[1]):(n=t.match(HJr))?o=(r.nocase?r.dot?qJr:$Jr:r.dot?YJr:zJr)(n):(n=t.match(MJr))?o=r.dot?LJr:kJr:(n=t.match(PJr))&&(o=FJr);let i=Sw.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?jJr:r.dot?KJr:JJr,o=new Set(r.nocase?["i"]:[]),i=t.map(l=>{let c=l.map(d=>{if(d instanceof RegExp)for(let f of d.flags.split(""))o.add(f);return typeof d=="string"?rZr(d):d===fd?fd:d._src});c.forEach((d,f)=>{let p=c[f+1],h=c[f-1];d!==fd||h===fd||(h===void 0?p!==void 0&&p!==fd?c[f+1]="(?:\\/|"+n+"\\/)?"+p:c[f]=n:p===void 0?c[f-1]=h+"(?:\\/|\\/"+n+")?":p!==fd&&(c[f-1]=h+"(?:\\/|\\/"+n+"\\/)"+p,c[f+1]=fd))});let u=c.filter(d=>d!==fd);if(this.partial&&u.length>=1){let d=[];for(let f=1;f<=u.length;f++)d.push(u.slice(0,f).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 gu.defaults(t).Minimatch}};gu.AST=Sw;gu.Minimatch=fk;gu.escape=iSe;gu.unescape=PT;var uut=M(C5(),1);cr();ke();Re();Kd();import{readFile as lut}from"fs/promises";import{existsSync as sSe,readdirSync as nZr,statSync as oZr}from"fs";import{join as aSe,relative as dut}from"path";import{homedir as iZr}from"os";function cut(e){try{let t=(0,uut.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 be(t),{paths:[],content:e.trim()}}}function sZr(e,t){return t.length===0?!0:t.some(r=>{try{return gu(e,r,{matchBase:!0,dot:!0})}catch(n){return be(n),!1}})}function lSe(e){let t=[];try{if(!sSe(e))return t;let r=nZr(e);for(let n of r){let o=aSe(e,n),i=oZr(o);i.isDirectory()?t.push(...lSe(o)):i.isFile()&&n.endsWith(".md")&&t.push(o)}}catch(r){be(r)}return t}async function WJ(){let e=[];try{let t=aSe(iZr(),wn,"rules");if(sSe(t)){let r=lSe(t);for(let n of r)try{let o=await lut(n,"utf-8"),{paths:i,content:s}=cut(o);i.length>0&&e.push({filePath:n,content:s,paths:i,isProjectRule:!1})}catch(o){be(o)}}}catch(t){be(t)}try{let t=aSe(Ne(),wn,"rules");if(sSe(t)){let r=lSe(t);for(let n of r)try{let o=await lut(n,"utf-8"),{paths:i,content:s}=cut(o);i.length>0&&e.push({filePath:dut(Ne(),n),content:s,paths:i,isProjectRule:!0})}catch(o){be(o)}}}catch(t){be(t)}return e}function put(e,t){e=RK(e);let r=RK(Ne()),n=e.startsWith(r)?dut(r,e):e;return t.filter(o=>sZr(n,o.paths))}function mut(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 Aat(e){try{let t=_Wr(e),r=t.readSync();return t.closeSync(),r===null}catch(t){return be(`Error checking directory: ${t}`),!1}}ke();var xa=M(J(),1);function wT(){let e=Pn();e.hasCompletedProjectOnboarding||ui({...e,hasCompletedProjectOnboarding:!0})}function xbe({workspaceDir:e}){let r=!Pn().hasCompletedProjectOnboarding;if(!r)return null;let n=IWr(vWr(e,Ko)),o=Aat(e),i=!n&&!o,s=jM.isEnabled&&!Gr().shiftEnterKeyBindingInstalled,a=ne();return(0,xa.jsxs)(v,{flexDirection:"column",gap:1,padding:1,paddingBottom:0,children:[r&&(0,xa.jsxs)(xa.Fragment,{children:[(0,xa.jsx)(T,{color:a.secondaryText,children:"Tips for getting started:"}),(0,xa.jsx)(mu,{children:(()=>{let l=[];return o&&l.push((0,xa.jsx)(mu.Item,{children:(0,xa.jsxs)(T,{color:a.secondaryText,children:["Ask ",rt," to create a new app or clone a repository."]})},"workspace")),i&&l.push((0,xa.jsx)(mu.Item,{children:(0,xa.jsxs)(T,{color:a.secondaryText,children:["Run ",(0,xa.jsx)(T,{color:a.text,children:"/init"})," to create a",Ko," file with instructions for Hawa code."]})},"claudemd")),s&&l.push((0,xa.jsx)(mu.Item,{children:(0,xa.jsxs)(T,{color:a.secondaryText,children:["Run ",(0,xa.jsx)(T,{color:a.text,children:"/terminal-setup"}),(0,xa.jsx)(T,{bold:!1,children:" to set up terminal integration"})]})},"terminal")),l.push((0,xa.jsx)(mu.Item,{children:(0,xa.jsxs)(T,{color:a.secondaryText,children:["Ask ",rt," questions about your codebase."]})},"questions")),l.push((0,xa.jsx)(mu.Item,{children:(0,xa.jsxs)(T,{color:a.secondaryText,children:["Ask ",rt," to implement changes to your codebase."]})},"changes")),l})()})]}),e===xWr()&&(0,xa.jsxs)(T,{color:ne().warning,children:["Note: You have launched ",(0,xa.jsx)(T,{bold:!0,children:rt})," in your home directory. For the best experience, launch it in a project directory instead."]})]})}var nk=M(J(),1);function wbe({isFocused:e,isSelected:t,smallPointer:r,children:n}){let{styles:o}=Mi("Select");return(0,nk.jsxs)(v,{...o.option({isFocused:e}),children:[e&&(0,nk.jsx)(T,{...o.focusIndicator(),children:r?nr.triangleDownSmall:nr.pointer}),(0,nk.jsx)(T,{...o.label({isFocused:e,isSelected:t}),children:n}),t&&(0,nk.jsx)(T,{...o.selectedIndicator(),children:nr.tick})]})}var Wp=M($e(),1);import{isDeepStrictEqual as wWr}from"node:util";var f5=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:Rbe(s);r.push([l,a]),i++,o=a}super(r),this.first=n}};var RWr=(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}}},Nbe=e=>e.flatMap(t=>{if("options"in t){let r=Nbe(t.options),n=r.flatMap(i=>"value"in i?i.value:[]);return[...t.header!==void 0?[{header:t.header,optionValues:n}]:[],...r]}return t}),_at=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=Nbe(r),o=typeof e=="number"?Math.min(e,n.length):n.length,i=new f5(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}},Dbe=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n,onFocus:o,focusValue:i})=>{let s=Nbe(t),[a,l]=(0,Wp.useReducer)(RWr,{visibleOptionCount:e,defaultValue:r,options:t},_at),[c,u]=(0,Wp.useState)(s);s!==c&&!wWr(s,c)&&(l({type:"reset",state:_at({visibleOptionCount:e,defaultValue:r,options:t})}),u(s));let d=(0,Wp.useCallback)(()=>{l({type:"focus-next-option"})},[]),f=(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:f,selectFocusedOption:p}};var Obe=({isDisabled:e=!1,state:t})=>{ft((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};var BT=M(J(),1),Rbe=e=>`HEADER-${e.optionValues.join(",")}`;function JS({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a}){let l=Dbe({visibleOptionCount:t,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a});Obe({isDisabled:e,state:l});let{styles:c}=Mi("Select");return(0,BT.jsx)(v,{...c.container(),children:l.visibleOptions.map(u=>{let d="value"in u?u.value:Rbe(u),f=!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 b=A.indexOf(r);_=(0,BT.jsxs)(BT.Fragment,{children:[A.slice(0,b),(0,BT.jsx)(T,{...c.highlightedText(),children:r}),A.slice(b+r.length)]})}return(0,BT.jsx)(wbe,{isFocused:f,isSelected:p,smallPointer:h,children:_},d)})})}var mw=M(J(),1);function Eat({onDone:e}){return ft((t,r)=>{(r.ctrl&&(t==="c"||t==="d")||r.escape)&&e()}),(0,mw.jsxs)(v,{flexDirection:"column",borderStyle:"round",padding:1,borderColor:ne().secondaryBorder,children:[(0,mw.jsx)(v,{marginBottom:1,flexDirection:"column",children:(0,mw.jsx)(T,{bold:!0,children:"You've spent $5 this session."})}),(0,mw.jsx)(v,{children:(0,mw.jsx)(JS,{options:[{value:"ok",label:"Got it, thanks!"}],onChange:e})})]})}var Zt=M($e(),1);ke();cr();mE();var OWr="2.6.11",fE={VERSION:OWr,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 pd=M(J(),1),kbe=46,yat=["(\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 kJ({isDefaultModel:e=!1}){let t=Math.max(kbe,Ne().length+12),r=ne(),n=yat[Math.floor(Math.random()*yat.length)];return(0,pd.jsx)(v,{flexDirection:"column",children:(0,pd.jsxs)(v,{flexDirection:"column",gap:1,paddingLeft:1,width:"100%",children:[(0,pd.jsxs)(T,{children:[(0,pd.jsx)(T,{children:n})," Welcome to"," ",(0,pd.jsx)(T,{bold:!0,children:rt}),(0,pd.jsxs)(T,{color:r.secondaryText,children:[" v",fE.VERSION]})]}),(0,pd.jsx)(pd.Fragment,{children:(0,pd.jsxs)(v,{paddingLeft:2,flexDirection:"column",gap:1,children:[(0,pd.jsx)(T,{color:r.secondaryText,italic:!0,children:"/help for help"}),(0,pd.jsxs)(T,{color:r.secondaryText,children:["cwd: ",Ne()]}),(0,pd.jsxs)(T,{color:r.secondaryText,children:["model: ",oo.getConfig().routing.MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A"]}),(0,pd.jsxs)(T,{color:r.secondaryText,children:["small fast model: ",oo.getConfig().routing.SMALL_FAST_MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A"]})]})})]})})}Re();import{randomUUID as Kh}from"crypto";ms();Re();Xt();cr();Re();ke();import{existsSync as ey,readdirSync as aZr,statSync as lZr}from"fs";import{join as FT,relative as cZr}from"path";import{homedir as gut}from"os";import{platform as uZr}from"process";import{readFile as QT}from"fs/promises";cr();cf();lr();import{join as FWr,sep as QWr}from"path";function tp(){if(!fu())return!1;try{let e=nt();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function jp(){return(FWr(Ne(),".hcode","team-memory")+QWr).normalize("NFC")}function Xg(e){let t=e.normalize("NFC"),r=jp();return t.startsWith(r)}cf();var hut=M(C5(),1);wo();var Xbe=(e,t,r)=>{let n=e instanceof RegExp?$ct(e,r):e,o=t instanceof RegExp?$ct(t,r):t,i=n!==null&&o!=null&&JKr(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)}},$ct=(e,t)=>{let r=t.match(e);return r?r[0]:null},JKr=(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 qct="\0SLASH"+Math.random()+"\0",Yct="\0OPEN"+Math.random()+"\0",rSe="\0CLOSE"+Math.random()+"\0",zct="\0COMMA"+Math.random()+"\0",Vct="\0PERIOD"+Math.random()+"\0",ZKr=new RegExp(qct,"g"),XKr=new RegExp(Yct,"g"),eJr=new RegExp(rSe,"g"),tJr=new RegExp(zct,"g"),rJr=new RegExp(Vct,"g"),nJr=/\\\\/g,oJr=/\\{/g,iJr=/\\}/g,sJr=/\\,/g,aJr=/\\\./g,lJr=1e5,cJr=4e6;function eSe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function uJr(e){return e.replace(nJr,qct).replace(oJr,Yct).replace(iJr,rSe).replace(sJr,zct).replace(aJr,Vct)}function dJr(e){return e.replace(ZKr,"\\").replace(XKr,"{").replace(eJr,"}").replace(tJr,",").replace(rJr,".")}function Wct(e){if(!e)return[""];let t=[],r=Xbe("{","}",e);if(!r)return e.split(",");let{pre:n,body:o,post:i}=r,s=n.split(",");s[s.length-1]+="{"+o+"}";let a=Wct(i);return i.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function jct(e,t={}){if(!e)return[];let{max:r=lJr,maxLength:n=cJr}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),tSe(uJr(e),r,n,!0).map(dJr)}function pJr(e){return"{"+e+"}"}function mJr(e){return/^-?0\d/.test(e)}function fJr(e,t){return e<=t}function gJr(e,t){return e>=t}function T5(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 hJr(e,t,r,n){let o=e.split(/\.\./),i=[];if(o[0]===void 0||o[1]===void 0)return i;let s=eSe(o[0]),a=eSe(o[1]),l=Math.max(o[0].length,o[1].length),c=o.length===3&&o[2]!==void 0?Math.max(Math.abs(eSe(o[2])),1):1,u=fJr;a<s&&(c*=-1,u=gJr);let f=o.some(mJr),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),f){let _=l-A.length;if(_>0){let b=new Array(_+1).join("0");h<0?A="-"+b+A.slice(1):A=b+A}}if(p+A.length>n)break;i.push(A),p+=A.length}return i}function tSe(e,t,r,n){let o=[""],i=!1,s=!0;for(;;){let a=Xbe("{","}",e);if(!a)return T5(o,e,[""],t,r,i);let l=a.pre;if(/\$$/.test(l)){if(o=T5(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,f=a.body.indexOf(",")>=0;if(!d&&!f){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+rSe+a.post,n=!0;continue}return T5(o,l+"{"+a.body+"}"+a.post,[""],t,r,i)}s&&(i=n&&!d,s=!1);let p;if(d)p=hJr(a.body,u,t,r);else{let h=Wct(a.body);if(h.length===1&&h[0]!==void 0&&(h=tSe(h[0],t,r,!1).map(pJr),h.length===1)){if(o=T5(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 b=0;A&&b<o.length;b++)o[b]&&(A=!1);p=[];let _=0;e:for(let b=0;b<h.length;b++){let y=tSe(h[b],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=T5(o,l,p,t,r,i&&!a.post.length),!a.post.length)break;e=a.post}return o}var I5=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var AJr={"[: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]},v5=e=>e.replace(/[[\]\\-]/g,"\\$&"),_Jr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Kct=e=>e.join(""),Jct=(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[_,[b,y,I]]of Object.entries(AJr))if(e.startsWith(_,i)){if(d)return["$.",!1,e.length-r,!0];i+=_.length,I?o.push(b):n.push(b),a=a||y;continue e}}if(l=!1,d){A>d?n.push(v5(d)+"-"+v5(A)):A===d&&n.push(v5(A)),d="",i++;continue}if(e.startsWith("-]",i+1)){n.push(v5(A+"-")),i+=2;continue}if(e.startsWith("-",i+1)){d=A,i+=2;continue}n.push(v5(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[_Jr(A),!1,u-r,!1]}let f="["+(c?"^":"")+Kct(n)+"]",p="["+(c?"":"^")+Kct(o)+"]";return[n.length&&o.length?"("+f+"|"+p+")":n.length?f:p,a,u-r,!0]};var PT=(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,EJr=new Set(["!","?","+","*","@"]),nSe=e=>EJr.has(e),Zct=e=>nSe(e.type),bJr=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),SJr=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),yJr=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),Xct=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),CJr="(?!(?:^|/)\\.\\.?(?:$|/))",VJ="(?!\\.)",TJr=new Set(["[","."]),IJr=new Set(["..","."]),vJr=new Set("().*{}+?[]^$\\!"),xJr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),oSe="[^/]",eut=oSe+"*?",tut=oSe+"+?",wJr=0,Sw=class{type;#e;#t;#n=!1;#r=[];#i;#o;#l;#s=!1;#a;#d;#m=!1;id=++wJr;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 b=t.charAt(A++);if(a||b==="\\"){a=!a,_+=b;continue}if(l){A===c+1?(b==="^"||b==="!")&&(u=!0):b==="]"&&!(A===c+2&&u)&&(l=!1),_+=b;continue}else if(b==="["){l=!0,c=A,u=!1,_+=b;continue}if(!o.noext&&nSe(b)&&t.charAt(A)==="("&&i<=s){r.push(_),_="";let I=new Jp(b,r);A=Jp.#c(t,I,A,o,i+1),r.push(I);continue}_+=b}return r.push(_),A}let d=n+1,f=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&&nSe(A)&&t.charAt(d)==="("&&(i<=s||r&&r.#_(A))){let b=r&&r.#_(A)?0:1;f.push(h),h="";let y=new Jp(A,f);f.push(y),d=Jp.#c(t,y,d,o,i+b);continue}if(A==="|"){f.push(h),h="",p.push(f),f=new Jp(null,r);continue}if(A===")")return h===""&&r.#r.length===0&&(r.#m=!0),f.push(h),h="",r.push(...p,f),d;h+=A}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],d}#g(t){return this.#A(t,SJr)}#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=yJr){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}#b(t){return!!Xct.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.#b(r.type)}#T(t){let r=Xct.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()),!Zct(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(p=>typeof p!="string"),c=this.#r.map(p=>{let[h,A,_,b]=typeof p=="string"?Jp.#y(p,this.#t,l):p.toRegExpSource(t);return this.#t=this.#t||_,this.#n=this.#n||b,h}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&IJr.has(this.#r[0]))){let h=TJr,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?CJr:_?VJ:""}let d="";return this.isEnd()&&this.#e.#s&&this.#i?.type==="!"&&(d="(?:$|\\/)"),[u+c+d,PT(c),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",o=this.type==="!"?"(?:(?!(?:":"(?:",i=this.#S(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,PT(this.toString()),!1,!1]}let s=!n||t||r||!VJ?"":this.#S(!0);s===i&&(s=""),s&&(i=`(?:${i})(?:${s})*?`);let a="";if(this.type==="!"&&this.#m)a=(this.isStart()&&!r?VJ:"")+tut;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?VJ:"")+eut+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=o+i+l}return[a,PT(i),this.#t=!!this.#t,this.#n]}#E(){if(Zct(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}#S(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+=(vJr.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,i+=n&&/^[*]+$/.test(t)?tut:eut,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?i+="\\\\":o=!0;continue}if(c==="["){let[u,d,f,p]=Jct(t,l);if(f){i+=u,s=s||d,l+=f-1,r=r||p;continue}}if(c==="?"){i+=oSe,r=!0;continue}i+=xJr(c)}return[i,PT(t),!!r,s]}};Jp=Sw;var iSe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var gu=(e,t,r={})=>(I5(t),!r.nocomment&&t.charAt(0)==="#"?!1:new fk(t,r).match(e)),RJr=/^\*+([^+@!?*[(]*)$/,NJr=e=>t=>!t.startsWith(".")&&t.endsWith(e),DJr=e=>t=>t.endsWith(e),OJr=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),BJr=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),MJr=/^\*+\.\*+$/,kJr=e=>!e.startsWith(".")&&e.includes("."),LJr=e=>e!=="."&&e!==".."&&e.includes("."),PJr=/^\.\*+$/,FJr=e=>e!=="."&&e!==".."&&e.startsWith("."),QJr=/^\*+$/,UJr=e=>e.length!==0&&!e.startsWith("."),GJr=e=>e.length!==0&&e!=="."&&e!=="..",HJr=/^\?+([^+@!?*[(]*)?$/,$Jr=([e,t=""])=>{let r=out([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},qJr=([e,t=""])=>{let r=iut([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},YJr=([e,t=""])=>{let r=iut([e]);return t?n=>r(n)&&n.endsWith(t):r},zJr=([e,t=""])=>{let r=out([e]);return t?n=>r(n)&&n.endsWith(t):r},out=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},iut=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},sut=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",rut={win32:{sep:"\\"},posix:{sep:"/"}},VJr=sut==="win32"?rut.win32.sep:rut.posix.sep;gu.sep=VJr;var fd=Symbol("globstar **");gu.GLOBSTAR=fd;var WJr="[^/]",jJr=WJr+"*?",KJr="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",JJr="(?:(?!(?:\\/|^)\\.).)*?",ZJr=(e,t={})=>r=>gu(r,e,t);gu.filter=ZJr;var eh=(e,t={})=>Object.assign({},e,t),XJr=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return gu;let t=gu;return Object.assign((n,o,i={})=>t(n,o,eh(e,i)),{Minimatch:class extends t.Minimatch{constructor(o,i={}){super(o,eh(e,i))}static defaults(o){return t.defaults(eh(e,o)).Minimatch}},AST:class extends t.AST{constructor(o,i,s={}){super(o,i,eh(e,s))}static fromGlob(o,i={}){return t.AST.fromGlob(o,eh(e,i))}},unescape:(n,o={})=>t.unescape(n,eh(e,o)),escape:(n,o={})=>t.escape(n,eh(e,o)),filter:(n,o={})=>t.filter(n,eh(e,o)),defaults:n=>t.defaults(eh(e,n)),makeRe:(n,o={})=>t.makeRe(n,eh(e,o)),braceExpand:(n,o={})=>t.braceExpand(n,eh(e,o)),match:(n,o,i={})=>t.match(n,o,eh(e,i)),sep:t.sep,GLOBSTAR:fd})};gu.defaults=XJr;var aut=(e,t={})=>(I5(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:jct(e,{max:t.braceExpandMax}));gu.braceExpand=aut;var eZr=(e,t={})=>new fk(e,t).makeRe();gu.makeRe=eZr;var tZr=(e,t,r={})=>{let n=new fk(t,r);return e=e.filter(o=>n.match(o)),n.options.nonull&&!e.length&&e.push(t),e};gu.match=tZr;var nut=/[?*]|[+@!]\(.*?\)|\[|\]/,rZr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),fk=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){I5(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||sut,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]==="?"||!nut.test(i[2]))&&!nut.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,f=u?3:c?0:void 0;if(typeof d=="number"&&typeof f=="number"){let[p,h]=[t[d],r[f]];p.toLowerCase()===h.toLowerCase()&&(r[f]=p,i=f,o=d)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(fd)?this.#e(t,r,n,o,i):this.#n(t,r,n,o,i)}#e(t,r,n,o,i){let s=r.indexOf(fd,i),a=r.lastIndexOf(fd),[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 f=[[[],0]],p=f[0],h=0,A=[0];for(let y of c)y===fd?(A.push(h),p=[[],0],f.push(p)):(p[0].push(y),h++);let _=f.length-1,b=t.length-d;for(let y of f)y[1]=b-(A[_--]+y[0].length);return!!this.#t(t,f,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 f=t[d];if(f==="."||f===".."||!this.options.dot&&f.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 f=t[n];if(f==="."||f===".."||!this.options.dot&&f.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===fd)return!1;let f;if(typeof u=="string"?(f=d===u,this.debug("string match",u,d,f)):(f=u.test(d),this.debug("pattern match",u,d,f)),!f)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 aut(this.pattern,this.options)}parse(t){I5(t);let r=this.options;if(t==="**")return fd;if(t==="")return"";let n,o=null;(n=t.match(QJr))?o=r.dot?GJr:UJr:(n=t.match(RJr))?o=(r.nocase?r.dot?BJr:OJr:r.dot?DJr:NJr)(n[1]):(n=t.match(HJr))?o=(r.nocase?r.dot?qJr:$Jr:r.dot?YJr:zJr)(n):(n=t.match(MJr))?o=r.dot?LJr:kJr:(n=t.match(PJr))&&(o=FJr);let i=Sw.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?jJr:r.dot?KJr:JJr,o=new Set(r.nocase?["i"]:[]),i=t.map(l=>{let c=l.map(d=>{if(d instanceof RegExp)for(let f of d.flags.split(""))o.add(f);return typeof d=="string"?rZr(d):d===fd?fd:d._src});c.forEach((d,f)=>{let p=c[f+1],h=c[f-1];d!==fd||h===fd||(h===void 0?p!==void 0&&p!==fd?c[f+1]="(?:\\/|"+n+"\\/)?"+p:c[f]=n:p===void 0?c[f-1]=h+"(?:\\/|\\/"+n+")?":p!==fd&&(c[f-1]=h+"(?:\\/|\\/"+n+"\\/)"+p,c[f+1]=fd))});let u=c.filter(d=>d!==fd);if(this.partial&&u.length>=1){let d=[];for(let f=1;f<=u.length;f++)d.push(u.slice(0,f).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 gu.defaults(t).Minimatch}};gu.AST=Sw;gu.Minimatch=fk;gu.escape=iSe;gu.unescape=PT;var uut=M(C5(),1);cr();ke();Re();Kd();import{readFile as lut}from"fs/promises";import{existsSync as sSe,readdirSync as nZr,statSync as oZr}from"fs";import{join as aSe,relative as dut}from"path";import{homedir as iZr}from"os";function cut(e){try{let t=(0,uut.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 be(t),{paths:[],content:e.trim()}}}function sZr(e,t){return t.length===0?!0:t.some(r=>{try{return gu(e,r,{matchBase:!0,dot:!0})}catch(n){return be(n),!1}})}function lSe(e){let t=[];try{if(!sSe(e))return t;let r=nZr(e);for(let n of r){let o=aSe(e,n),i=oZr(o);i.isDirectory()?t.push(...lSe(o)):i.isFile()&&n.endsWith(".md")&&t.push(o)}}catch(r){be(r)}return t}async function WJ(){let e=[];try{let t=aSe(iZr(),wn,"rules");if(sSe(t)){let r=lSe(t);for(let n of r)try{let o=await lut(n,"utf-8"),{paths:i,content:s}=cut(o);i.length>0&&e.push({filePath:n,content:s,paths:i,isProjectRule:!1})}catch(o){be(o)}}}catch(t){be(t)}try{let t=aSe(Ne(),wn,"rules");if(sSe(t)){let r=lSe(t);for(let n of r)try{let o=await lut(n,"utf-8"),{paths:i,content:s}=cut(o);i.length>0&&e.push({filePath:dut(Ne(),n),content:s,paths:i,isProjectRule:!0})}catch(o){be(o)}}}catch(t){be(t)}return e}function put(e,t){e=RK(e);let r=RK(Ne()),n=e.startsWith(r)?dut(r,e):e;return t.filter(o=>sZr(n,o.paths))}function mut(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(Q)}
748
748
  `);a=O.pop()||"";for(let Q of O){let G=Q.trim();if(!(!G||G==="data: [DONE]"))if(G.startsWith("data: ")){let P=G.slice(6);try{let q=JSON.parse(P);w(q)}catch(q){this.logger&&this.logger.error({err:q,line:G},"Failed to parse Gemini SSE chunk")}}else try{let P=JSON.parse(G);w(P)}catch{}}};(async()=>{try{for(;;){let{value:O,done:Q}=await s.read();if(Q)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_${Pk()}`,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 wnn(`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"}}},_0e=new A0e;var NSt=M(xSt(),1);lr();ms();function FA(e){return e?typeof e.entries=="function"?Object.fromEntries(e.entries()):{...e}:{}}function wSt(e){let t=String(e?.["x-thinking-level"]??"medium").toLowerCase();return["off","low","medium","high"].includes(t)?t:"medium"}function HEn(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t}}function $En(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t,summary:"auto"}}function qEn(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 y3(e,t,r){CV(t,e),TV(t,qEn(e,r),r)}function I2(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 C3(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 RSt=["/v1/messages"];function Vve(e){let t;try{typeof e=="string"?t=new uR(e):e instanceof uR?t=e:t=new uR(e.url)}catch{return""}let r=t.pathname;for(let n of RSt){let o=r.indexOf(n);if(o!==-1)return t.origin+r.slice(0,o)}return t.origin}function Rte(e,t){let r=typeof e=="string"?e:e instanceof uR?e.toString():e.url,n;try{n=new uR(r).pathname}catch{return!1}return RSt.some(o=>n.includes(o))&&(t.method==="POST"||t.method==="post")}function YEn(e){return async(t,r)=>{if(!Rte(t,r))return e(t,r);let n=JSON.parse(r.body),o=await NX.transformRequestOut(n),i=Vve(t)+"/chat/completions",s=FA(r.headers),a=s.authorization??s.Authorization??"";HEn(o,wSt(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 re(`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:FA(l.headers)},openai:{request:{body:o},response:{}}};if(!c){let _=await l.text(),b=new Response(_,{status:l.status,statusText:l.statusText,headers:C3(l.headers)}),y=await NX.transformResponseIn(b,n),I=await y.text();try{y3({...d,openai:{...d.openai,response:{body:JSON.parse(_)}},response:{...d.response,body:JSON.parse(I)}},u)}catch(w){re("\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 f=I2(l.body),p=new Response(f.stream,{status:l.status,statusText:l.statusText,headers:C3(l.headers)}),h=await NX.transformResponseIn(p,n),A=I2(h.body);return Promise.all([f.done,A.done]).then(async([_,b])=>{try{y3({...d,openai:{...d.openai,response:{body:await npt(_)}},response:{...d.response,body:await f4(b)}},u)}catch(y){re("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u6D41\u5F0F):"+y?.stack)}}).catch(_=>re("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Chat):"+_)),new Response(A.stream,{status:h.status,statusText:h.statusText,headers:h.headers})}}function zEn(e){return async(t,r)=>{if(!Rte(t,r))return e(t,r);let n=JSON.parse(r.body),o=await DX.transformRequestOut(n),i=FA(r.headers);$En(o,wSt(i));let s=JSON.stringify(o),l=Vve(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 re(`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,f=i["x-agent-id"],p={request:{url:l,method:r.method,headers:i,body:n},response:{status:u.status,statusText:u.statusText,headers:FA(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:C3(u.headers)}),w=await DX.transformResponseIn(I,n),N=await w.text();try{y3({...p,openai:{...p.openai,response:{body:JSON.parse(y)}},response:{...p.response,body:JSON.parse(N)}},f,"responses")}catch(O){re("\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=I2(u.body),A=new Response(h.stream,{status:u.status,statusText:u.statusText,headers:C3(u.headers)}),_=await DX.transformResponseIn(A,n),b=I2(_.body);return Promise.all([h.done,b.done]).then(async([y,I])=>{try{y3({...p,openai:{...p.openai,response:{body:await rpt(y)}},response:{...p.response,body:await f4(I)}},f,"responses")}catch(w){re("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u6D41\u5F0F):"+w?.stack)}}).catch(y=>re("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Responses):"+y)),new Response(b.stream,{status:_.status,statusText:_.statusText,headers:_.headers})}}function VEn(e){return async(t,r)=>{if(!Rte(t,r))return e(t,r);let n=JSON.parse(r.body),o=FA(r.headers),i=await _0e.transformRequestOut(n),s=JSON.stringify(i),a=Vve(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(b){throw re("gemini request error:",b),b}if(!c.ok){let b=await c.text();return re(`Gemini API error response: ${c.status} ${c.statusText}`,{url:a,status:c.status,errorResponse:b}),zve("Gemini API error","Gemini",c.status,c.statusText,b)}let u=n.stream===!0,d=o["x-agent-id"],f={request:{url:a,method:r.method,headers:FA(r.headers),body:n},response:{status:c.status,statusText:c.statusText,headers:FA(c.headers)},openai:{request:{body:i},response:{}}},p=I2(c.body),h=new Response(p.stream,{status:c.status,statusText:c.statusText,headers:C3(c.headers)}),A=await _0e.transformResponseIn(h),_=I2(A.body);return Promise.all([p.done,_.done]).then(async([b,y])=>{try{let I=u?opt(b):JSON.parse(b),w=u?await f4(y):JSON.parse(y);y3({...f,openai:{...f.openai,response:{body:I}},response:{...f.response,body:w}},d)}catch(I){re("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Gemini):"+I?.stack)}}).catch(b=>re("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Gemini):"+b)),new Response(_.stream,{status:A.status,statusText:A.statusText,headers:A.headers})}}function WEn(e){return async(t,r)=>{if(!Rte(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=FA(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();re(`API error response: ${a.status} ${a.statusText}`,{url:typeof t=="string"?t:t instanceof uR?t.toString():t.url,status:a.status,errorResponse:d});let f;try{let p=JSON.parse(d);f={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&&(f.error.details=p.error.details)}catch{f={type:"error",error:{type:"api_error",message:`API error: ${a.statusText}`,code:`API_${a.status}_ERROR`}}}return new Response(JSON.stringify(f),{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 uR?t.toString():t.url,method:r.method,headers:FA(r.headers),body:JSON.parse(n)},response:{status:a.status,statusText:a.statusText,headers:FA(a.headers)}};return(async()=>{if(c){let p=await a.text();u.response.body=await f4(p)}else u.response.body=await a.json();let f=FA(r.headers)["x-agent-id"];CV(f,u),TV(f,{request:u.request.body.messages,response:u.response.body.content,usage:u.response.body?.usage})})().catch(d=>re(`\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 wte=null,Yve=!1;function jEn(){wte=null,Yve=!1}Gt.on("proxy:changed",jEn);function KEn(){if(Yve)return wte;if(Yve=!0,nt().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(wte=new NSt.ProxyAgent({uri:e}),Kt(`[proxy] using proxy: ${e}`)),wte}function JEn(){let e=KEn();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function Nte(e){let t=e||process.env.API_TYPE,r=JEn();switch(t){case"openai":return YEn(r);case"openai-responses":return zEn(r);case"gemini":return VEn(r);default:return WEn(r)}}mE();Re();ke();ke();var Wve="2.6.10";globalThis.MACRO={VERSION:Wve,PACKAGE_URL:`@dahawa/${Jo}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var Dte=process.env.HAWA_CODE_USER_AGENT||`${Jo}/${Wve} (${process.env.USER_TYPE})`;Re();Re();Xt();function Ad(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=ou(r);if(i?.type==="user"){r[r.length-1]=DSt(i,o);return}r.push(o);return}case"assistant":r.push(o);return;case"insert":{let i=ou(r);i?.type==="user"&&(r[r.length-1]=ZEn(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=bt([{type:"text",text:`<system-rules>
751
+ Stack trace: `+d.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var wte=null,Yve=!1;function jEn(){wte=null,Yve=!1}Gt.on("proxy:changed",jEn);function KEn(){if(Yve)return wte;if(Yve=!0,nt().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(wte=new NSt.ProxyAgent({uri:e}),Kt(`[proxy] using proxy: ${e}`)),wte}function JEn(){let e=KEn();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function Nte(e){let t=e||process.env.API_TYPE,r=JEn();switch(t){case"openai":return YEn(r);case"openai-responses":return zEn(r);case"gemini":return VEn(r);default:return WEn(r)}}mE();Re();ke();ke();var Wve="2.6.11";globalThis.MACRO={VERSION:Wve,PACKAGE_URL:`@dahawa/${Jo}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var Dte=process.env.HAWA_CODE_USER_AGENT||`${Jo}/${Wve} (${process.env.USER_TYPE})`;Re();Re();Xt();function Ad(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=ou(r);if(i?.type==="user"){r[r.length-1]=DSt(i,o);return}r.push(o);return}case"assistant":r.push(o);return;case"insert":{let i=ou(r);i?.type==="user"&&(r[r.length-1]=ZEn(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=bt([{type:"text",text:`<system-rules>
752
752
  ${mut(a)}
753
753
  </system-rules>`}]),c=ou(r);c?.type==="user"?r[r.length-1]=DSt(c,l,{skipTrailingSystemReminders:!0}):r.push(l);return}}}),r}function ZEn(e,t){return{...e,message:{...e.message,content:ebn(e.message.content,XEn(t.content.content))}}}function XEn(e){return`
754
754
  <system-reminder>
@@ -3193,7 +3193,7 @@ ${t}
3193
3193
 
3194
3194
  `);d[Pu(h)]={description:_,inputSchema:f.inputSchema??{type:"object"},outputSchema:A}}return{path:o,description:`Provider ${o}`,types:q3e(d,s),kind:"provider"}}let c=i?Pu(i):void 0,u=c?a.filter(d=>d.name===`cm_${s}_${c}`||d.name.endsWith(`_${c}`)):a;for(let d of u){let f=`cm_${s}_`,p=d.name.slice(f.length),h=Pu(p),A=Cer(d,l.get(`${o}.${p}`)),_=A?d.description??"":[d.description,Ter(o,p)].filter(Boolean).join(`
3195
3195
 
3196
- `);return{path:`${o}.${p}`,description:_,types:q3e({[h]:{description:_,inputSchema:d.inputSchema??{type:"object"},outputSchema:A}},s),kind:"method"}}return{path:e,description:void 0,types:`"${e}" not found.`,kind:"method"}}function wer(e,t){if(!e||t<=0)return"";let r=/[\u2E80-\u2FDF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]|[\p{L}\p{N}]+(?:['’\-][\p{L}\p{N}]+)*/gu,n=0,o=0;for(let i of e.matchAll(r))if(n++,o=(i.index??0)+i[0].length,n>=t)break;return n===0?"":n<t?e:e.slice(0,o)+"..."}lr();var gso=F.object({code:F.string().describe("JavaScript async arrow function to execute"),timeout:F.number().optional().describe("Execution timeout in seconds. Defaults to 60.")}),hso='Execute JavaScript in a sandbox that has access to provider methods and sandbox meta methods. Available providers and their methods are listed at the end of this prompt under \u201CAvailable providers & methods".\n\n## Call provider methods\n\n`codemode.<provider>.<method>(input)`.\n\n## Call sandbox meta methods\n\nThe meta methods are typed as follows (descriptions in JSDoc):\n\n`codemode.<meta_function_name>(input)`.\n\n```ts\n{{metaTypes}}\n```\n\n## Rules\n\n- The ONLY globals are the configured codemode providers and `codemode` itself (plus standard JavaScript). No `host`, `fs`, `require`, `process`, or Node.js APIs \u2014 all I/O goes through the providers.\n- NEVER guess method names or parameters. If you already know the method name, check its parameters with `await codemode.describe("provider.method")` \u2014 no need to search first. Only when the method name is unknown, discover it with `await codemode.search(...)`.\n- The meta methods above are sandbox JavaScript functions, NOT external tools. Call them only from inside the async arrow function you return.\n- Batch independent calls into ONE function: sequential `await`s (or `Promise.all`) inside a single returned function. Only split into multiple codemode calls when a later call depends on an earlier call\'s result. Never retry the same failing call in a loop \u2014 try an alternative approach instead.\n- Return the final value directly. On failure, throw an Error with a clear message instead of returning partial results.\n- Write a single async arrow function in plain JavaScript. No TypeScript syntax (no type annotations, interfaces, or generics), no named helper functions \u2014 write the arrow function body directly.\n- If `codemode.describe` reports an `unknown` return type, If the outputSchema can be inferred from the execution result, call saveOutputSchema promptly, but not in the same function as the inference, so that subsequent queries can provide an outputSchema.\n\n## Available providers & methods\n\n{{providers}}',Aso=60;function Ner(){return ot.getCodemodeMethodsMax()}async function _so(){let[e,t]=await Promise.all([Sb().catch(()=>[]),Sv().catch(()=>[])]),r=[...new Set(t.map(i=>i.provider))];if(r.length===0)return"No providers configured. You can still write plain JavaScript.";let n={},o={};for(let i of r)n[i]=[];for(let i of e)i.type==="connected"&&(o[i.name]=i.instructions);for(let i of t){let s=i.name.slice(`cm_${Pu(i.provider)}_`.length);n[i.provider].includes(s)||n[i.provider].push(s)}return r.map(i=>{let s=n[i],a=o[i]?.replace(/\r\n/g,`
3196
+ `);return{path:`${o}.${p}`,description:_,types:q3e({[h]:{description:_,inputSchema:d.inputSchema??{type:"object"},outputSchema:A}},s),kind:"method"}}return{path:e,description:void 0,types:`"${e}" not found.`,kind:"method"}}function wer(e,t){if(!e||t<=0)return"";let r=/[\u2E80-\u2FDF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]|[\p{L}\p{N}]+(?:['’\-][\p{L}\p{N}]+)*/gu,n=0,o=0;for(let i of e.matchAll(r))if(n++,o=(i.index??0)+i[0].length,n>=t)break;return n===0?"":n<t?e:e.slice(0,o)+"..."}lr();var gso=F.object({code:F.string().describe("JavaScript async arrow function to execute"),timeout:F.number().optional().describe("Execution timeout in seconds. Defaults to 60.")}),hso="Execute JavaScript in a sandbox that has access to provider methods and sandbox meta methods. Available providers and their methods are listed at the end of this prompt under \u201CAvailable providers & methods\".\n\n## Call provider methods\n\n`codemode.<provider>.<method>(input)`.\n\n## Call sandbox meta methods\n\nThe meta methods are typed as follows (descriptions in JSDoc):\n\n`codemode.<meta_function_name>(input)`.\n\n```ts\n{{metaTypes}}\n```\n\n## Rules\n\n- The ONLY globals are the configured codemode providers and `codemode` itself (plus standard JavaScript). No `host`, `fs`, `require`, `process`, or Node.js APIs \u2014 all I/O goes through the providers.\n- NEVER guess method names or parameters. If you already know the method name, check its parameters with `await codemode.describe` \u2014 no need to search first. Only when the method name is unknown, discover it with `await codemode.search`.\n- The meta methods above are sandbox JavaScript functions, NOT external tools. Call them only from inside the async arrow function you return.\n- Batch independent calls into ONE function: sequential `await`s (or `Promise.all`) inside a single returned function. Only split into multiple codemode calls when a later call depends on an earlier call's result. Never retry the same failing call in a loop \u2014 try an alternative approach instead.\n- Return the final value directly. On failure, throw an Error with a clear message instead of returning partial results.\n- Write a single async arrow function in plain JavaScript. No TypeScript syntax (no type annotations, interfaces, or generics), no named helper functions \u2014 write the arrow function body directly.\n- If `codemode.describe` reports an `unknown` return type, If the outputSchema can be inferred from the execution result, call `codemode.saveOutputSchema` promptly, but not in the same function as the inference, so that subsequent queries can provide an outputSchema.\n\n## Available providers & methods\n\n{{providers}}",Aso=60;function Ner(){return ot.getCodemodeMethodsMax()}async function _so(){let[e,t]=await Promise.all([Sb().catch(()=>[]),Sv().catch(()=>[])]),r=[...new Set(t.map(i=>i.provider))];if(r.length===0)return"No providers configured. You can still write plain JavaScript.";let n={},o={};for(let i of r)n[i]=[];for(let i of e)i.type==="connected"&&(o[i.name]=i.instructions);for(let i of t){let s=i.name.slice(`cm_${Pu(i.provider)}_`.length);n[i.provider].includes(s)||n[i.provider].push(s)}return r.map(i=>{let s=n[i],a=o[i]?.replace(/\r\n/g,`
3197
3197
  `).replace(/\n+/g,"\\n").trim(),l=Ner(),c=s.slice(0,l),u=s.length-c.length,d=`### ${i}\uFF08${s.length} methods, showing ${c.length}\uFF09`,f=wer(a??"(none)",Aso),p=c.length>0?c.join(`
3198
3198
  `)+(u>0?`
3199
3199
  (... ${u} more methods)`:""):"(no methods available)";return`${d}
package/hands.js CHANGED
@@ -622,7 +622,7 @@ data: ${JSON.stringify(z)}
622
622
  `);a=Q.pop()||"";for(let z of Q){let Y=z.trim();if(!(!Y||Y==="data: [DONE]"))if(Y.startsWith("data: ")){let G=Y.slice(6);try{let W=JSON.parse(G);w(W)}catch(W){this.logger&&this.logger.error({err:W,line:Y},"Failed to parse Gemini SSE chunk")}}else try{let G=JSON.parse(Y);w(G)}catch{}}};(async()=>{try{for(;;){let{value:Q,done:z}=await s.read();if(z)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_${KB()}`,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 w8r(`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"}}},nbe=new rbe;var Vmt=U(zmt(),1);or();Ns();function Gg(e){return e?typeof e.entries=="function"?Object.fromEntries(e.entries()):{...e}:{}}function jmt(e){let t=String(e?.["x-thinking-level"]??"medium").toLowerCase();return["off","low","medium","high"].includes(t)?t:"medium"}function $tn(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t}}function qtn(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t,summary:"auto"}}function Gtn(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 U5(e,t,r){Nz(t,e),Bz(t,Gtn(e,r),r)}function L2(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 H5(e){let t=new Headers(e);return t.delete("content-encoding"),t.delete("content-length"),t.delete("transfer-encoding"),t}function NIe(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 Ymt=["/v1/messages"];function BIe(e){let t;try{typeof e=="string"?t=new Mv(e):e instanceof Mv?t=e:t=new Mv(e.url)}catch{return""}let r=t.pathname;for(let n of Ymt){let i=r.indexOf(n);if(i!==-1)return t.origin+r.slice(0,i)}return t.origin}function qZ(e,t){let r=typeof e=="string"?e:e instanceof Mv?e.toString():e.url,n;try{n=new Mv(r).pathname}catch{return!1}return Ymt.some(i=>n.includes(i))&&(t.method==="POST"||t.method==="post")}function ztn(e){return async(t,r)=>{if(!qZ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await GK.transformRequestOut(n),o=BIe(t)+"/chat/completions",s=Gg(r.headers),a=s.authorization??s.Authorization??"";$tn(i,jmt(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 J(`OpenAI Chat Completions API error: ${l.status}`,{url:o,errorResponse:_}),NIe("OpenAI Chat Completions API error","OPENROUTER",l.status,l.statusText,_)}let c=n.stream===!0,u=s["x-agent-id"],d={request:{url:o,method:r.method,headers:s,body:n},response:{status:l.status,statusText:l.statusText,headers:Gg(l.headers)},openai:{request:{body:i},response:{}}};if(!c){let _=await l.text(),y=new Response(_,{status:l.status,statusText:l.statusText,headers:H5(l.headers)}),S=await GK.transformResponseIn(y,n),I=await S.text();try{U5({...d,openai:{...d.openai,response:{body:JSON.parse(_)}},response:{...d.response,body:JSON.parse(I)}},u)}catch(w){J("\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=L2(l.body),m=new Response(g.stream,{status:l.status,statusText:l.statusText,headers:H5(l.headers)}),A=await GK.transformResponseIn(m,n),h=L2(A.body);return Promise.all([g.done,h.done]).then(async([_,y])=>{try{U5({...d,openai:{...d.openai,response:{body:await bot(_)}},response:{...d.response,body:await BU(y)}},u)}catch(S){J("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u6D41\u5F0F):"+S?.stack)}}).catch(_=>J("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Chat):"+_)),new Response(h.stream,{status:A.status,statusText:A.statusText,headers:A.headers})}}function jtn(e){return async(t,r)=>{if(!qZ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await zK.transformRequestOut(n),o=Gg(r.headers);qtn(i,jmt(o));let s=JSON.stringify(i),l=BIe(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 J(`OpenAI Responses API error: ${u.status} ${u.statusText}`,{url:l,status:u.status,errorResponse:S}),NIe("OpenAI Responses API error","RESPONSES",u.status,u.statusText,S)}let d=n.stream===!0,g=o["x-agent-id"],m={request:{url:l,method:r.method,headers:o,body:n},response:{status:u.status,statusText:u.statusText,headers:Gg(u.headers)},openai:{request:{body:i},response:{}}};if(!d){let S=await u.text(),I=new Response(S,{status:u.status,statusText:u.statusText,headers:H5(u.headers)}),w=await zK.transformResponseIn(I,n),O=await w.text();try{U5({...m,openai:{...m.openai,response:{body:JSON.parse(S)}},response:{...m.response,body:JSON.parse(O)}},g,"responses")}catch(Q){J("\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=L2(u.body),h=new Response(A.stream,{status:u.status,statusText:u.statusText,headers:H5(u.headers)}),_=await zK.transformResponseIn(h,n),y=L2(_.body);return Promise.all([A.done,y.done]).then(async([S,I])=>{try{U5({...m,openai:{...m.openai,response:{body:await yot(S)}},response:{...m.response,body:await BU(I)}},g,"responses")}catch(w){J("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u6D41\u5F0F):"+w?.stack)}}).catch(S=>J("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Responses):"+S)),new Response(y.stream,{status:_.status,statusText:_.statusText,headers:_.headers})}}function Ytn(e){return async(t,r)=>{if(!qZ(t,r))return e(t,r);let n=JSON.parse(r.body),i=Gg(r.headers),o=await nbe.transformRequestOut(n),s=JSON.stringify(o),a=BIe(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 J("gemini request error:",y),y}if(!c.ok){let y=await c.text();return J(`Gemini API error response: ${c.status} ${c.statusText}`,{url:a,status:c.status,errorResponse:y}),NIe("Gemini API error","Gemini",c.status,c.statusText,y)}let u=n.stream===!0,d=i["x-agent-id"],g={request:{url:a,method:r.method,headers:Gg(r.headers),body:n},response:{status:c.status,statusText:c.statusText,headers:Gg(c.headers)},openai:{request:{body:o},response:{}}},m=L2(c.body),A=new Response(m.stream,{status:c.status,statusText:c.statusText,headers:H5(c.headers)}),h=await nbe.transformResponseIn(A),_=L2(h.body);return Promise.all([m.done,_.done]).then(async([y,S])=>{try{let I=u?Cot(y):JSON.parse(y),w=u?await BU(S):JSON.parse(S);U5({...g,openai:{...g.openai,response:{body:I}},response:{...g.response,body:w}},d)}catch(I){J("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Gemini):"+I?.stack)}}).catch(y=>J("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Gemini):"+y)),new Response(_.stream,{status:h.status,statusText:h.statusText,headers:h.headers})}}function Vtn(e){return async(t,r)=>{if(!qZ(t,r))return e(t,r);let n=r.body;if(r.body)try{let d=JSON.parse(r.body);n=JSON.stringify(d)}catch{}let i=Gg(r.headers);["1","true"].includes(String(process.env.HAWA_CODE_X_API_KEY_DISABLED??"").toLowerCase())&&(delete i["x-api-key"],delete i["X-API-Key"]),["1","true"].includes(String(process.env.HAWA_CODE_AUTH_DISABLED??"").toLowerCase())&&(delete i.authorization,delete i.Authorization),delete i["content-length"];let a=await e(t,{method:r.method,headers:i,body:n,signal:r.signal});if(!a.ok){let d=await a.text();J(`API error response: ${a.status} ${a.statusText}`,{url:typeof t=="string"?t:t instanceof Mv?t.toString():t.url,status:a.status,errorResponse:d});let g;try{let m=JSON.parse(d);g={type:"error",error:{type:"api_error",message:m.error?.message||m.message||`API error: ${a.statusText}`,code:m.error?.code||m.code||`API_${a.status}_ERROR`}},m.error?.details&&(g.error.details=m.error.details)}catch{g={type:"error",error:{type:"api_error",message:`API error: ${a.statusText}`,code:`API_${a.status}_ERROR`}}}return new Response(JSON.stringify(g),{status:a.status,statusText:a.statusText,headers:{"Content-Type":"application/json"}})}let l=a.clone(),c=!(Object.hasOwn(JSON.parse(n),"stream")&&!JSON.parse(n).stream),u={request:{url:typeof t=="string"?t:t instanceof Mv?t.toString():t.url,method:r.method,headers:Gg(r.headers),body:JSON.parse(n)},response:{status:a.status,statusText:a.statusText,headers:Gg(a.headers)}};return(async()=>{if(c){let m=await a.text();u.response.body=await BU(m)}else u.response.body=await a.json();let g=Gg(r.headers)["x-agent-id"];Nz(g,u),Bz(g,{request:u.request.body.messages,response:u.response.body.content,usage:u.response.body?.usage})})().catch(d=>J(`\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF:
625
- Stack trace: `+d.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var $Z=null,RIe=!1;function Wtn(){$Z=null,RIe=!1}Tr.on("proxy:changed",Wtn);function Ktn(){if(RIe)return $Z;if(RIe=!0,ct().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&($Z=new Vmt.ProxyAgent({uri:e}),rr(`[proxy] using proxy: ${e}`)),$Z}function Jtn(){let e=Ktn();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function GZ(e){let t=e||process.env.API_TYPE,r=Jtn();switch(t){case"openai":return ztn(r);case"openai-responses":return jtn(r);case"gemini":return Ytn(r);default:return Vtn(r)}}_h();var trn=U(et(),1);function Wmt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=Ztn(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function Ztn(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||Xtn(t)?0:ern(t)?2:1}function Xtn(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function ern(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 C_(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 mS(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}Pe();Ns();var pc={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function zZ(e,t){pc.totalCost+=e,pc.totalAPIDuration+=t}function jZ(e,t){pc.inputTokens+=e,pc.outputTokens+=t,Tr.emit("token:change",{inputTokens:pc.inputTokens,outputTokens:pc.outputTokens})}function YZ(e,t){pc.cacheCreationTokens+=e,pc.cacheReadTokens+=t}function OIe(){return{inputTokens:pc.inputTokens,outputTokens:pc.outputTokens,cacheCreationTokens:pc.cacheCreationTokens,cacheReadTokens:pc.cacheReadTokens}}function Kmt(){return pc.totalCost}function Jmt(){return Date.now()-pc.startTime}function Zmt(){return pc.totalAPIDuration}function Xmt(e){pc.currentContextTokens=e}function egt(){return pc.currentContextTokens}Pe();Le();Le();var kIe="2.6.10";globalThis.MACRO={VERSION:kIe,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 VZ=process.env.HAWA_CODE_USER_AGENT||`${Zi}/${kIe} (${process.env.USER_TYPE})`;import{randomUUID as kE}from"crypto";Ns();Pe();er();br();Pe();Le();import{existsSync as x_,readdirSync as Dsn,statSync as Rsn}from"fs";import{join as ES,relative as Nsn}from"path";import{homedir as zht}from"os";import{platform as Bsn}from"process";import{readFile as _S}from"fs/promises";br();Tm();or();import{join as srn,sep as arn}from"path";function vm(){if(!Fu())return!1;try{let e=ct();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function Zf(){return(srn(Re(),".hcode","team-memory")+arn).normalize("NFC")}function I_(e){let t=e.normalize("NFC"),r=Zf();return t.startsWith(r)}Tm();var jht=U(K5(),1);Hi();var JIe=(e,t,r)=>{let n=e instanceof RegExp?_ht(e,r):e,i=t instanceof RegExp?_ht(t,r):t,o=n!==null&&i!=null&&_on(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)}},_ht=(e,t)=>{let r=t.match(e);return r?r[0]:null},_on=(e,t,r)=>{let n,i,o,s,a,l=r.indexOf(e),c=r.indexOf(t,l+1),u=l;if(l>=0&&c>0){if(e===t)return[l,c];for(n=[],o=r.length;u>=0&&!a;){if(u===l)n.push(u),l=r.indexOf(e,u+1);else if(n.length===1){let d=n.pop();d!==void 0&&(a=[d,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[o,s])}return a};var yht="\0SLASH"+Math.random()+"\0",bht="\0OPEN"+Math.random()+"\0",eTe="\0CLOSE"+Math.random()+"\0",Cht="\0COMMA"+Math.random()+"\0",Sht="\0PERIOD"+Math.random()+"\0",yon=new RegExp(yht,"g"),bon=new RegExp(bht,"g"),Con=new RegExp(eTe,"g"),Son=new RegExp(Cht,"g"),Ion=new RegExp(Sht,"g"),Ton=/\\\\/g,von=/\\{/g,xon=/\\}/g,won=/\\,/g,Don=/\\\./g,Ron=1e5,Non=4e6;function ZIe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Bon(e){return e.replace(Ton,yht).replace(von,bht).replace(xon,eTe).replace(won,Cht).replace(Don,Sht)}function Oon(e){return e.replace(yon,"\\").replace(bon,"{").replace(Con,"}").replace(Son,",").replace(Ion,".")}function Iht(e){if(!e)return[""];let t=[],r=JIe("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=Iht(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function Tht(e,t={}){if(!e)return[];let{max:r=Ron,maxLength:n=Non}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),XIe(Bon(e),r,n,!0).map(Oon)}function kon(e){return"{"+e+"}"}function Mon(e){return/^-?0\d/.test(e)}function Qon(e,t){return e<=t}function Pon(e,t){return e>=t}function J5(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 Lon(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=ZIe(i[0]),a=ZIe(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(ZIe(i[2])),1):1,u=Qon;a<s&&(c*=-1,u=Pon);let g=i.some(Mon),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 XIe(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=JIe("{","}",e);if(!a)return J5(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=J5(i,l+"{"+a.body+"}",[""],t,r,o&&!a.post.length),s=!1,!a.post.length)break;e=a.post;continue}let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),d=c||u,g=a.body.indexOf(",")>=0;if(!d&&!g){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+eTe+a.post,n=!0;continue}return J5(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!d,s=!1);let m;if(d)m=Lon(a.body,u,t,r);else{let A=Iht(a.body);if(A.length===1&&A[0]!==void 0&&(A=XIe(A[0],t,r,!1).map(kon),A.length===1)){if(i=J5(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=XIe(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=J5(i,l,m,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var Z5=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Fon={"[: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]},X5=e=>e.replace(/[[\]\\-]/g,"\\$&"),Uon=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),vht=e=>e.join(""),xht=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,l=!1,c=!1,u=r,d="";e:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===r+1){c=!0,o++;continue}if(h==="]"&&s&&!l){u=o+1;break}if(s=!0,h==="\\"&&!l){l=!0,o++;continue}if(h==="["&&!l){for(let[_,[y,S,I]]of Object.entries(Fon))if(e.startsWith(_,o)){if(d)return["$.",!1,e.length-r,!0];o+=_.length,I?i.push(y):n.push(y),a=a||S;continue e}}if(l=!1,d){h>d?n.push(X5(d)+"-"+X5(h)):h===d&&n.push(X5(h)),d="",o++;continue}if(e.startsWith("-]",o+1)){n.push(X5(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){d=h,o+=2;continue}n.push(X5(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[Uon(h),!1,u-r,!1]}let g="["+(c?"^":"")+vht(n)+"]",m="["+(c?"":"^")+vht(i)+"]";return[n.length&&i.length?"("+g+"|"+m+")":n.length?g:m,a,u-r,!0]};var hS=(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,Hon=new Set(["!","?","+","*","@"]),tTe=e=>Hon.has(e),wht=e=>tTe(e.type),$on=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),qon=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Gon=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),Dht=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),zon="(?!(?:^|/)\\.\\.?(?:$|/))",aX="(?!\\.)",jon=new Set(["[","."]),Yon=new Set(["..","."]),Von=new Set("().*{}+?[]^$\\!"),Won=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),rTe="[^/]",Rht=rTe+"*?",Nht=rTe+"+?",Kon=0,qv=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;id=++Kon;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&&tTe(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 d=n+1,g=new $d(null,r),m=[],A="";for(;d<t.length;){let h=t.charAt(d++);if(a||h==="\\"){a=!a,A+=h;continue}if(l){d===c+1?(h==="^"||h==="!")&&(u=!0):h==="]"&&!(d===c+2&&u)&&(l=!1),A+=h;continue}else if(h==="["){l=!0,c=d,u=!1,A+=h;continue}if(!i.noext&&tTe(h)&&t.charAt(d)==="("&&(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),d=$d.#c(t,S,d,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),d;A+=h}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],d}#g(t){return this.#h(t,qon)}#h(t,r=$on){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=Gon){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!!Dht.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=Dht.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()),!wht(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&&Yon.has(this.#r[0]))){let A=jon,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?zon:_?aX:""}let d="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(d="(?:$|\\/)"),[u+c+d,hS(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,hS(this.toString()),!1,!1]}let s=!n||t||r||!aX?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?aX:"")+Nht;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?aX:"")+Rht+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,hS(o),this.#t=!!this.#t,this.#n]}#_(){if(wht(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+=(Von.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?Nht:Rht,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,d,g,m]=xht(t,l);if(g){o+=u,s=s||d,l+=g-1,r=r||m;continue}}if(c==="?"){o+=rTe,r=!0;continue}o+=Won(c)}return[o,hS(t),!!r,s]}};$d=qv;var nTe=(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={})=>(Z5(t),!r.nocomment&&t.charAt(0)==="#"?!1:new V2(t,r).match(e)),Jon=/^\*+([^+@!?*[(]*)$/,Zon=e=>t=>!t.startsWith(".")&&t.endsWith(e),Xon=e=>t=>t.endsWith(e),esn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),tsn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),rsn=/^\*+\.\*+$/,nsn=e=>!e.startsWith(".")&&e.includes("."),isn=e=>e!=="."&&e!==".."&&e.includes("."),osn=/^\.\*+$/,ssn=e=>e!=="."&&e!==".."&&e.startsWith("."),asn=/^\*+$/,lsn=e=>e.length!==0&&!e.startsWith("."),csn=e=>e.length!==0&&e!=="."&&e!=="..",usn=/^\?+([^+@!?*[(]*)?$/,dsn=([e,t=""])=>{let r=kht([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},fsn=([e,t=""])=>{let r=Mht([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},psn=([e,t=""])=>{let r=Mht([e]);return t?n=>r(n)&&n.endsWith(t):r},msn=([e,t=""])=>{let r=kht([e]);return t?n=>r(n)&&n.endsWith(t):r},kht=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},Mht=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},Qht=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Bht={win32:{sep:"\\"},posix:{sep:"/"}},gsn=Qht==="win32"?Bht.win32.sep:Bht.posix.sep;gc.sep=gsn;var Jc=Symbol("globstar **");gc.GLOBSTAR=Jc;var Asn="[^/]",hsn=Asn+"*?",Esn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",_sn="(?:(?!(?:\\/|^)\\.).)*?",ysn=(e,t={})=>r=>gc(r,e,t);gc.filter=ysn;var xm=(e,t={})=>Object.assign({},e,t),bsn=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return gc;let t=gc;return Object.assign((n,i,o={})=>t(n,i,xm(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,xm(e,o))}static defaults(i){return t.defaults(xm(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,xm(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,xm(e,o))}},unescape:(n,i={})=>t.unescape(n,xm(e,i)),escape:(n,i={})=>t.escape(n,xm(e,i)),filter:(n,i={})=>t.filter(n,xm(e,i)),defaults:n=>t.defaults(xm(e,n)),makeRe:(n,i={})=>t.makeRe(n,xm(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,xm(e,i)),match:(n,i,o={})=>t.match(n,i,xm(e,o)),sep:t.sep,GLOBSTAR:Jc})};gc.defaults=bsn;var Pht=(e,t={})=>(Z5(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Tht(e,{max:t.braceExpandMax}));gc.braceExpand=Pht;var Csn=(e,t={})=>new V2(e,t).makeRe();gc.makeRe=Csn;var Ssn=(e,t,r={})=>{let n=new V2(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};gc.match=Ssn;var Oht=/[?*]|[+@!]\(.*?\)|\[|\]/,Isn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),V2=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){Z5(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||Qht,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]==="?"||!Oht.test(o[2]))&&!Oht.test(o[3]),c=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(c)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let s=this.set[o];s[0]===""&&s[1]===""&&this.globParts[o][2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3])&&(s[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n of t)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let o=n[n.length-1];return i==="**"&&o==="**"?n:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let o=t[i];i===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let s=i;for(;n[s+1]==="**";)s++;s>i&&n.splice(i+1,s-i);let a=n[i+1],l=n[i+2],c=n[i+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let s=1;s<n.length-1;s++){let a=n[s];s===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(s,1),s--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let s=n[o-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let l=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...l),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(i){t[r]=[],t[n]=i;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,o=0,s=[],a="";for(;i<t.length&&o<r.length;)if(t[i]===r[o])s.push(a==="b"?r[o]:t[i]),i++,o++;else if(n&&t[i]==="**"&&r[o]===t[i+1])s.push(t[i]),i++;else if(n&&r[o]==="**"&&t[i]===r[o+1])s.push(r[o]),o++;else if(t[i]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",s.push(t[i]),i++,o++}else if(r[o]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",s.push(r[o]),i++,o++}else return!1;return t.length===r.length&&s}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=0,o=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),l=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),c=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),u=!c&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),d=l?3:a?0:void 0,g=u?3:c?0:void 0;if(typeof d=="number"&&typeof g=="number"){let[m,A]=[t[d],r[g]];m.toLowerCase()===A.toLowerCase()&&(r[g]=m,o=g,i=d)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(Jc)?this.#e(t,r,n,i,o):this.#n(t,r,n,i,o)}#e(t,r,n,i,o){let s=r.indexOf(Jc,o),a=r.lastIndexOf(Jc),[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 d=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))d=u.length;else{if(t[t.length-1]!==""||i+u.length===t.length||(S--,!this.#n(t,u,n,S,0)))return!1;d=u.length+1}}if(!c.length){let S=!!d;for(let I=i;I<t.length-d;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===Jc?(h.push(A),m=[[],0],g.push(m)):(m[0].push(S),A++);let _=g.length-1,y=t.length-d;for(let S of g)S[1]=y-(h[_--]+S[0].length);return!!this.#t(t,g,i,0,n,0,!!d)}#t(t,r,n,i,o,s,a){let l=r[i];if(!l){for(let d=n;d<t.length;d++){a=!0;let g=t[d];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(t.slice(0,n+c.length),c,o,n,0)&&s<this.maxGlobstarRecursion){let m=this.#t(t,r,n+c.length,i+1,o,s+1,a);if(m!==!1)return m}let g=t[n];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1;n++}return o||null}#n(t,r,n,i,o){let s,a,l,c;for(s=i,a=o,c=t.length,l=r.length;s<c&&a<l;s++,a++){this.debug("matchOne loop");let u=r[a],d=t[s];if(this.debug(r,u,d),u===!1||u===Jc)return!1;let g;if(typeof u=="string"?(g=d===u,this.debug("string match",u,d,g)):(g=u.test(d),this.debug("pattern match",u,d,g)),!g)return!1}if(s===c&&a===l)return!0;if(s===c)return n;if(a===l)return s===c-1&&t[s]==="";throw new Error("wtf?")}braceExpand(){return Pht(this.pattern,this.options)}parse(t){Z5(t);let r=this.options;if(t==="**")return Jc;if(t==="")return"";let n,i=null;(n=t.match(asn))?i=r.dot?csn:lsn:(n=t.match(Jon))?i=(r.nocase?r.dot?tsn:esn:r.dot?Xon:Zon)(n[1]):(n=t.match(usn))?i=(r.nocase?r.dot?fsn:dsn:r.dot?psn:msn)(n):(n=t.match(rsn))?i=r.dot?isn:nsn:(n=t.match(osn))&&(i=ssn);let o=qv.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?hsn:r.dot?Esn:_sn,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(d=>{if(d instanceof RegExp)for(let g of d.flags.split(""))i.add(g);return typeof d=="string"?Isn(d):d===Jc?Jc:d._src});c.forEach((d,g)=>{let m=c[g+1],A=c[g-1];d!==Jc||A===Jc||(A===void 0?m!==void 0&&m!==Jc?c[g+1]="(?:\\/|"+n+"\\/)?"+m:c[g]=n:m===void 0?c[g-1]=A+"(?:\\/|\\/"+n+")?":m!==Jc&&(c[g-1]=A+"(?:\\/|\\/"+n+"\\/)"+m,c[g+1]=Jc))});let u=c.filter(d=>d!==Jc);if(this.partial&&u.length>=1){let d=[];for(let g=1;g<=u.length;g++)d.push(u.slice(0,g).join("/"));return"(?:"+d.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];o="^"+s+o+a+"$",this.partial&&(o="^(?:\\/|"+s+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let s=i[i.length-1];if(!s)for(let a=i.length-2;!s&&a>=0;a--)s=i[a];for(let a of o){let l=i;if(n.matchBase&&a.length===1&&(l=[s]),this.matchOne(l,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return gc.defaults(t).Minimatch}};gc.AST=qv;gc.Minimatch=V2;gc.escape=nTe;gc.unescape=hS;var Uht=U(K5(),1);br();Le();Pe();Nu();import{readFile as Lht}from"fs/promises";import{existsSync as iTe,readdirSync as Tsn,statSync as vsn}from"fs";import{join as oTe,relative as Hht}from"path";import{homedir as xsn}from"os";function Fht(e){try{let t=(0,Uht.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 wsn(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 sTe(e){let t=[];try{if(!iTe(e))return t;let r=Tsn(e);for(let n of r){let i=oTe(e,n),o=vsn(i);o.isDirectory()?t.push(...sTe(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){Te(r)}return t}async function lX(){let e=[];try{let t=oTe(xsn(),rn,"rules");if(iTe(t)){let r=sTe(t);for(let n of r)try{let i=await Lht(n,"utf-8"),{paths:o,content:s}=Fht(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=oTe(Re(),rn,"rules");if(iTe(t)){let r=sTe(t);for(let n of r)try{let i=await Lht(n,"utf-8"),{paths:o,content:s}=Fht(i);o.length>0&&e.push({filePath:Hht(Re(),n),content:s,paths:o,isProjectRule:!0})}catch(i){Te(i)}}}catch(t){Te(t)}return e}function $ht(e,t){e=wV(e);let r=wV(Re()),n=e.startsWith(r)?Hht(r,e):e;return t.filter(i=>wsn(n,i.paths))}function qht(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: `+d.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var $Z=null,RIe=!1;function Wtn(){$Z=null,RIe=!1}Tr.on("proxy:changed",Wtn);function Ktn(){if(RIe)return $Z;if(RIe=!0,ct().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&($Z=new Vmt.ProxyAgent({uri:e}),rr(`[proxy] using proxy: ${e}`)),$Z}function Jtn(){let e=Ktn();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function GZ(e){let t=e||process.env.API_TYPE,r=Jtn();switch(t){case"openai":return ztn(r);case"openai-responses":return jtn(r);case"gemini":return Ytn(r);default:return Vtn(r)}}_h();var trn=U(et(),1);function Wmt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=Ztn(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function Ztn(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||Xtn(t)?0:ern(t)?2:1}function Xtn(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function ern(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 C_(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 mS(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}Pe();Ns();var pc={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function zZ(e,t){pc.totalCost+=e,pc.totalAPIDuration+=t}function jZ(e,t){pc.inputTokens+=e,pc.outputTokens+=t,Tr.emit("token:change",{inputTokens:pc.inputTokens,outputTokens:pc.outputTokens})}function YZ(e,t){pc.cacheCreationTokens+=e,pc.cacheReadTokens+=t}function OIe(){return{inputTokens:pc.inputTokens,outputTokens:pc.outputTokens,cacheCreationTokens:pc.cacheCreationTokens,cacheReadTokens:pc.cacheReadTokens}}function Kmt(){return pc.totalCost}function Jmt(){return Date.now()-pc.startTime}function Zmt(){return pc.totalAPIDuration}function Xmt(e){pc.currentContextTokens=e}function egt(){return pc.currentContextTokens}Pe();Le();Le();var kIe="2.6.11";globalThis.MACRO={VERSION:kIe,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 VZ=process.env.HAWA_CODE_USER_AGENT||`${Zi}/${kIe} (${process.env.USER_TYPE})`;import{randomUUID as kE}from"crypto";Ns();Pe();er();br();Pe();Le();import{existsSync as x_,readdirSync as Dsn,statSync as Rsn}from"fs";import{join as ES,relative as Nsn}from"path";import{homedir as zht}from"os";import{platform as Bsn}from"process";import{readFile as _S}from"fs/promises";br();Tm();or();import{join as srn,sep as arn}from"path";function vm(){if(!Fu())return!1;try{let e=ct();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function Zf(){return(srn(Re(),".hcode","team-memory")+arn).normalize("NFC")}function I_(e){let t=e.normalize("NFC"),r=Zf();return t.startsWith(r)}Tm();var jht=U(K5(),1);Hi();var JIe=(e,t,r)=>{let n=e instanceof RegExp?_ht(e,r):e,i=t instanceof RegExp?_ht(t,r):t,o=n!==null&&i!=null&&_on(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)}},_ht=(e,t)=>{let r=t.match(e);return r?r[0]:null},_on=(e,t,r)=>{let n,i,o,s,a,l=r.indexOf(e),c=r.indexOf(t,l+1),u=l;if(l>=0&&c>0){if(e===t)return[l,c];for(n=[],o=r.length;u>=0&&!a;){if(u===l)n.push(u),l=r.indexOf(e,u+1);else if(n.length===1){let d=n.pop();d!==void 0&&(a=[d,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[o,s])}return a};var yht="\0SLASH"+Math.random()+"\0",bht="\0OPEN"+Math.random()+"\0",eTe="\0CLOSE"+Math.random()+"\0",Cht="\0COMMA"+Math.random()+"\0",Sht="\0PERIOD"+Math.random()+"\0",yon=new RegExp(yht,"g"),bon=new RegExp(bht,"g"),Con=new RegExp(eTe,"g"),Son=new RegExp(Cht,"g"),Ion=new RegExp(Sht,"g"),Ton=/\\\\/g,von=/\\{/g,xon=/\\}/g,won=/\\,/g,Don=/\\\./g,Ron=1e5,Non=4e6;function ZIe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Bon(e){return e.replace(Ton,yht).replace(von,bht).replace(xon,eTe).replace(won,Cht).replace(Don,Sht)}function Oon(e){return e.replace(yon,"\\").replace(bon,"{").replace(Con,"}").replace(Son,",").replace(Ion,".")}function Iht(e){if(!e)return[""];let t=[],r=JIe("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=Iht(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function Tht(e,t={}){if(!e)return[];let{max:r=Ron,maxLength:n=Non}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),XIe(Bon(e),r,n,!0).map(Oon)}function kon(e){return"{"+e+"}"}function Mon(e){return/^-?0\d/.test(e)}function Qon(e,t){return e<=t}function Pon(e,t){return e>=t}function J5(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 Lon(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=ZIe(i[0]),a=ZIe(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(ZIe(i[2])),1):1,u=Qon;a<s&&(c*=-1,u=Pon);let g=i.some(Mon),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 XIe(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=JIe("{","}",e);if(!a)return J5(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=J5(i,l+"{"+a.body+"}",[""],t,r,o&&!a.post.length),s=!1,!a.post.length)break;e=a.post;continue}let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),d=c||u,g=a.body.indexOf(",")>=0;if(!d&&!g){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+eTe+a.post,n=!0;continue}return J5(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!d,s=!1);let m;if(d)m=Lon(a.body,u,t,r);else{let A=Iht(a.body);if(A.length===1&&A[0]!==void 0&&(A=XIe(A[0],t,r,!1).map(kon),A.length===1)){if(i=J5(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=XIe(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=J5(i,l,m,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var Z5=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Fon={"[: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]},X5=e=>e.replace(/[[\]\\-]/g,"\\$&"),Uon=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),vht=e=>e.join(""),xht=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,l=!1,c=!1,u=r,d="";e:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===r+1){c=!0,o++;continue}if(h==="]"&&s&&!l){u=o+1;break}if(s=!0,h==="\\"&&!l){l=!0,o++;continue}if(h==="["&&!l){for(let[_,[y,S,I]]of Object.entries(Fon))if(e.startsWith(_,o)){if(d)return["$.",!1,e.length-r,!0];o+=_.length,I?i.push(y):n.push(y),a=a||S;continue e}}if(l=!1,d){h>d?n.push(X5(d)+"-"+X5(h)):h===d&&n.push(X5(h)),d="",o++;continue}if(e.startsWith("-]",o+1)){n.push(X5(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){d=h,o+=2;continue}n.push(X5(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[Uon(h),!1,u-r,!1]}let g="["+(c?"^":"")+vht(n)+"]",m="["+(c?"":"^")+vht(i)+"]";return[n.length&&i.length?"("+g+"|"+m+")":n.length?g:m,a,u-r,!0]};var hS=(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,Hon=new Set(["!","?","+","*","@"]),tTe=e=>Hon.has(e),wht=e=>tTe(e.type),$on=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),qon=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Gon=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),Dht=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),zon="(?!(?:^|/)\\.\\.?(?:$|/))",aX="(?!\\.)",jon=new Set(["[","."]),Yon=new Set(["..","."]),Von=new Set("().*{}+?[]^$\\!"),Won=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),rTe="[^/]",Rht=rTe+"*?",Nht=rTe+"+?",Kon=0,qv=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;id=++Kon;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&&tTe(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 d=n+1,g=new $d(null,r),m=[],A="";for(;d<t.length;){let h=t.charAt(d++);if(a||h==="\\"){a=!a,A+=h;continue}if(l){d===c+1?(h==="^"||h==="!")&&(u=!0):h==="]"&&!(d===c+2&&u)&&(l=!1),A+=h;continue}else if(h==="["){l=!0,c=d,u=!1,A+=h;continue}if(!i.noext&&tTe(h)&&t.charAt(d)==="("&&(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),d=$d.#c(t,S,d,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),d;A+=h}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],d}#g(t){return this.#h(t,qon)}#h(t,r=$on){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=Gon){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!!Dht.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=Dht.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()),!wht(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&&Yon.has(this.#r[0]))){let A=jon,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?zon:_?aX:""}let d="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(d="(?:$|\\/)"),[u+c+d,hS(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,hS(this.toString()),!1,!1]}let s=!n||t||r||!aX?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?aX:"")+Nht;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?aX:"")+Rht+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,hS(o),this.#t=!!this.#t,this.#n]}#_(){if(wht(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+=(Von.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?Nht:Rht,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,d,g,m]=xht(t,l);if(g){o+=u,s=s||d,l+=g-1,r=r||m;continue}}if(c==="?"){o+=rTe,r=!0;continue}o+=Won(c)}return[o,hS(t),!!r,s]}};$d=qv;var nTe=(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={})=>(Z5(t),!r.nocomment&&t.charAt(0)==="#"?!1:new V2(t,r).match(e)),Jon=/^\*+([^+@!?*[(]*)$/,Zon=e=>t=>!t.startsWith(".")&&t.endsWith(e),Xon=e=>t=>t.endsWith(e),esn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),tsn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),rsn=/^\*+\.\*+$/,nsn=e=>!e.startsWith(".")&&e.includes("."),isn=e=>e!=="."&&e!==".."&&e.includes("."),osn=/^\.\*+$/,ssn=e=>e!=="."&&e!==".."&&e.startsWith("."),asn=/^\*+$/,lsn=e=>e.length!==0&&!e.startsWith("."),csn=e=>e.length!==0&&e!=="."&&e!=="..",usn=/^\?+([^+@!?*[(]*)?$/,dsn=([e,t=""])=>{let r=kht([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},fsn=([e,t=""])=>{let r=Mht([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},psn=([e,t=""])=>{let r=Mht([e]);return t?n=>r(n)&&n.endsWith(t):r},msn=([e,t=""])=>{let r=kht([e]);return t?n=>r(n)&&n.endsWith(t):r},kht=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},Mht=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},Qht=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Bht={win32:{sep:"\\"},posix:{sep:"/"}},gsn=Qht==="win32"?Bht.win32.sep:Bht.posix.sep;gc.sep=gsn;var Jc=Symbol("globstar **");gc.GLOBSTAR=Jc;var Asn="[^/]",hsn=Asn+"*?",Esn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",_sn="(?:(?!(?:\\/|^)\\.).)*?",ysn=(e,t={})=>r=>gc(r,e,t);gc.filter=ysn;var xm=(e,t={})=>Object.assign({},e,t),bsn=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return gc;let t=gc;return Object.assign((n,i,o={})=>t(n,i,xm(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,xm(e,o))}static defaults(i){return t.defaults(xm(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,xm(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,xm(e,o))}},unescape:(n,i={})=>t.unescape(n,xm(e,i)),escape:(n,i={})=>t.escape(n,xm(e,i)),filter:(n,i={})=>t.filter(n,xm(e,i)),defaults:n=>t.defaults(xm(e,n)),makeRe:(n,i={})=>t.makeRe(n,xm(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,xm(e,i)),match:(n,i,o={})=>t.match(n,i,xm(e,o)),sep:t.sep,GLOBSTAR:Jc})};gc.defaults=bsn;var Pht=(e,t={})=>(Z5(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Tht(e,{max:t.braceExpandMax}));gc.braceExpand=Pht;var Csn=(e,t={})=>new V2(e,t).makeRe();gc.makeRe=Csn;var Ssn=(e,t,r={})=>{let n=new V2(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};gc.match=Ssn;var Oht=/[?*]|[+@!]\(.*?\)|\[|\]/,Isn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),V2=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){Z5(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||Qht,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]==="?"||!Oht.test(o[2]))&&!Oht.test(o[3]),c=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(c)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let s=this.set[o];s[0]===""&&s[1]===""&&this.globParts[o][2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3])&&(s[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n of t)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let o=n[n.length-1];return i==="**"&&o==="**"?n:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let o=t[i];i===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let s=i;for(;n[s+1]==="**";)s++;s>i&&n.splice(i+1,s-i);let a=n[i+1],l=n[i+2],c=n[i+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let s=1;s<n.length-1;s++){let a=n[s];s===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(s,1),s--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let s=n[o-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let l=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...l),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(i){t[r]=[],t[n]=i;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,o=0,s=[],a="";for(;i<t.length&&o<r.length;)if(t[i]===r[o])s.push(a==="b"?r[o]:t[i]),i++,o++;else if(n&&t[i]==="**"&&r[o]===t[i+1])s.push(t[i]),i++;else if(n&&r[o]==="**"&&t[i]===r[o+1])s.push(r[o]),o++;else if(t[i]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",s.push(t[i]),i++,o++}else if(r[o]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",s.push(r[o]),i++,o++}else return!1;return t.length===r.length&&s}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=0,o=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),l=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),c=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),u=!c&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),d=l?3:a?0:void 0,g=u?3:c?0:void 0;if(typeof d=="number"&&typeof g=="number"){let[m,A]=[t[d],r[g]];m.toLowerCase()===A.toLowerCase()&&(r[g]=m,o=g,i=d)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(Jc)?this.#e(t,r,n,i,o):this.#n(t,r,n,i,o)}#e(t,r,n,i,o){let s=r.indexOf(Jc,o),a=r.lastIndexOf(Jc),[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 d=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))d=u.length;else{if(t[t.length-1]!==""||i+u.length===t.length||(S--,!this.#n(t,u,n,S,0)))return!1;d=u.length+1}}if(!c.length){let S=!!d;for(let I=i;I<t.length-d;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===Jc?(h.push(A),m=[[],0],g.push(m)):(m[0].push(S),A++);let _=g.length-1,y=t.length-d;for(let S of g)S[1]=y-(h[_--]+S[0].length);return!!this.#t(t,g,i,0,n,0,!!d)}#t(t,r,n,i,o,s,a){let l=r[i];if(!l){for(let d=n;d<t.length;d++){a=!0;let g=t[d];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(t.slice(0,n+c.length),c,o,n,0)&&s<this.maxGlobstarRecursion){let m=this.#t(t,r,n+c.length,i+1,o,s+1,a);if(m!==!1)return m}let g=t[n];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1;n++}return o||null}#n(t,r,n,i,o){let s,a,l,c;for(s=i,a=o,c=t.length,l=r.length;s<c&&a<l;s++,a++){this.debug("matchOne loop");let u=r[a],d=t[s];if(this.debug(r,u,d),u===!1||u===Jc)return!1;let g;if(typeof u=="string"?(g=d===u,this.debug("string match",u,d,g)):(g=u.test(d),this.debug("pattern match",u,d,g)),!g)return!1}if(s===c&&a===l)return!0;if(s===c)return n;if(a===l)return s===c-1&&t[s]==="";throw new Error("wtf?")}braceExpand(){return Pht(this.pattern,this.options)}parse(t){Z5(t);let r=this.options;if(t==="**")return Jc;if(t==="")return"";let n,i=null;(n=t.match(asn))?i=r.dot?csn:lsn:(n=t.match(Jon))?i=(r.nocase?r.dot?tsn:esn:r.dot?Xon:Zon)(n[1]):(n=t.match(usn))?i=(r.nocase?r.dot?fsn:dsn:r.dot?psn:msn)(n):(n=t.match(rsn))?i=r.dot?isn:nsn:(n=t.match(osn))&&(i=ssn);let o=qv.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?hsn:r.dot?Esn:_sn,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(d=>{if(d instanceof RegExp)for(let g of d.flags.split(""))i.add(g);return typeof d=="string"?Isn(d):d===Jc?Jc:d._src});c.forEach((d,g)=>{let m=c[g+1],A=c[g-1];d!==Jc||A===Jc||(A===void 0?m!==void 0&&m!==Jc?c[g+1]="(?:\\/|"+n+"\\/)?"+m:c[g]=n:m===void 0?c[g-1]=A+"(?:\\/|\\/"+n+")?":m!==Jc&&(c[g-1]=A+"(?:\\/|\\/"+n+"\\/)"+m,c[g+1]=Jc))});let u=c.filter(d=>d!==Jc);if(this.partial&&u.length>=1){let d=[];for(let g=1;g<=u.length;g++)d.push(u.slice(0,g).join("/"));return"(?:"+d.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];o="^"+s+o+a+"$",this.partial&&(o="^(?:\\/|"+s+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let s=i[i.length-1];if(!s)for(let a=i.length-2;!s&&a>=0;a--)s=i[a];for(let a of o){let l=i;if(n.matchBase&&a.length===1&&(l=[s]),this.matchOne(l,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return gc.defaults(t).Minimatch}};gc.AST=qv;gc.Minimatch=V2;gc.escape=nTe;gc.unescape=hS;var Uht=U(K5(),1);br();Le();Pe();Nu();import{readFile as Lht}from"fs/promises";import{existsSync as iTe,readdirSync as Tsn,statSync as vsn}from"fs";import{join as oTe,relative as Hht}from"path";import{homedir as xsn}from"os";function Fht(e){try{let t=(0,Uht.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 wsn(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 sTe(e){let t=[];try{if(!iTe(e))return t;let r=Tsn(e);for(let n of r){let i=oTe(e,n),o=vsn(i);o.isDirectory()?t.push(...sTe(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){Te(r)}return t}async function lX(){let e=[];try{let t=oTe(xsn(),rn,"rules");if(iTe(t)){let r=sTe(t);for(let n of r)try{let i=await Lht(n,"utf-8"),{paths:o,content:s}=Fht(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=oTe(Re(),rn,"rules");if(iTe(t)){let r=sTe(t);for(let n of r)try{let i=await Lht(n,"utf-8"),{paths:o,content:s}=Fht(i);o.length>0&&e.push({filePath:Hht(Re(),n),content:s,paths:o,isProjectRule:!0})}catch(i){Te(i)}}}catch(t){Te(t)}return e}function $ht(e,t){e=wV(e);let r=wV(Re()),n=e.startsWith(r)?Hht(r,e):e;return t.filter(i=>wsn(n,i.paths))}function qht(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 mx(){return e9()?`gitStatus:
995
995
  <context name="${c}">${u}</context>`;let s=i.map(c=>{let u=c.prompt({},t),d=JSON.stringify("inputJSONSchema"in c&&c.inputJSONSchema?c.inputJSONSchema:p0(c.inputSchema));return{name:c.name,description:`${u}
996
996
 
997
997
  Schema:
998
- ${d}`}}),{messages:a}=t,l=ndn(o);return idn(o,l,s,a)}},zyt=odn;Yg();var TO=U(et(),1);Pe();Pe();var ru=U(ge(),1);import{existsSync as sdn,readdirSync as adn,statSync as ldn}from"fs";import{join as cdn}from"path";function udn(){let e=Xi.plan();if(!sdn(e))return[];try{return adn(e).filter(r=>r.endsWith(".md")).map(r=>{let n=cdn(e,r),i=ldn(n);return{name:r,path:n,modified:i.mtime}}).sort((r,n)=>n.modified.getTime()-r.modified.getTime())}catch{return[]}}var jyt=({onSelect:e})=>{let[t,r]=(0,TO.useState)([]),[n,i]=(0,TO.useState)(0),[o,s]=(0,TO.useState)(!1);(0,TO.useEffect)(()=>{let c=udn();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}))];ur((c,u)=>{if(u.upArrow)i(d=>d>0?d-1:a.length-1);else if(u.downArrow)i(d=>d<a.length-1?d+1:0);else if(u.return){let d=a[n];d&&e(d.value)}else u.escape&&e("__CANCELLED__")});let l=Oe();return o?(0,ru.jsxs)(R,{flexDirection:"column",marginY:1,children:[(0,ru.jsx)(R,{marginBottom:1,children:(0,ru.jsx)(v,{bold:!0,color:l.claude,children:"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"})}),(0,ru.jsx)(R,{marginBottom:1,children:(0,ru.jsx)(v,{bold:!0,color:l.claude,children:" Select a plan to continue, or create a new one"})}),a.map((c,u)=>{let d=u===n;return(0,ru.jsxs)(R,{flexDirection:"row",marginLeft:2,children:[(0,ru.jsx)(v,{color:d?l.claude:l.text,children:d?"\u276F":" "}),(0,ru.jsx)(v,{color:d?l.claude:l.text,children:" "}),(0,ru.jsx)(v,{color:d?l.claude:l.text,bold:c.isNew,children:c.isNew?c.label:c.label.replace(".md","")}),!c.isNew&&c.modified&&(0,ru.jsxs)(v,{dimColor:!0,children:[" ","(",Kge(c.modified),")"]})]},c.isNew?"new":c.value)}),(0,ru.jsx)(R,{marginTop:1,marginLeft:2,children:(0,ru.jsx)(v,{dimColor:!0,children:"\u2191/\u2193 to select \xB7 Enter to confirm \xB7 Esc to cancel"})})]}):(0,ru.jsx)(R,{flexDirection:"column",marginY:1,children:(0,ru.jsx)(v,{children:"Loading plan history..."})})};var Vyt=U(ge(),1),ddn={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):(0,Vyt.jsx)(jyt,{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"}},Yyt=ddn;Yg();var fdn={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"}},Wyt=fdn;br();import{resolve as pdn}from"path";var mdn={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=pdn(r,t);ua(n);let i=Re();return i===r?`Already in ${i}.`:`Changed directory to ${i}/`},userFacingName(){return"cd"}},Kyt=mdn;var xSt=U(et(),1);var Wh=U(et(),1);var jdn=U(et(),1);var P9=U(et(),1),qdn=U(ebt(),1);var tbt={info:"blue",success:"green",error:"red",warning:"yellow"},wdn={styles:{container:({variant:e})=>({flexGrow:1,borderStyle:"round",borderColor:tbt[e],gap:1,paddingX:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:tbt[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}}},rbt=wdn;var Ddn={styles:{container:({color:e})=>({backgroundColor:e}),label:()=>({color:"black"})}},nbt=Ddn;var Rdn={styles:{input:({isFocused:e})=>({dimColor:!e})}},ibt=Rdn;var Ndn={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})}},obt=Ndn;var Bdn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})}},sbt=Bdn;var Odn={styles:{container:()=>({flexGrow:1,minWidth:0}),completed:()=>({color:"magenta"}),remaining:()=>({dimColor:!0})},config:()=>({completedCharacter:Jt.square,remainingCharacter:Jt.squareLightShade})},abt=Odn;var kdn={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})}},lbt=kdn;var Mdn={styles:{container:()=>({gap:1}),frame:()=>({color:"blue"}),label:()=>({})}},cbt=Mdn;var Qdn={success:"green",error:"red",warning:"yellow",info:"blue"},Pdn={success:Jt.tick,error:Jt.cross,warning:Jt.warning,info:Jt.info},Ldn={styles:{container:()=>({gap:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:Qdn[e]}),message:()=>({})},config:({variant:e})=>({icon:Pdn[e]})},ubt=Ldn;var Fdn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})},config:()=>({marker:Jt.line})},dbt=Fdn;var Udn={styles:{value:()=>({})}},fbt=Udn;var Hdn={styles:{value:()=>({})}},pbt=Hdn;var $dn={styles:{value:()=>({})}},mbt=$dn;var Gdn={components:{Alert:rbt,Badge:nbt,ConfirmInput:ibt,MultiSelect:obt,OrderedList:sbt,ProgressBar:abt,Select:lbt,Spinner:cbt,StatusMessage:ubt,UnorderedList:dbt,TextInput:fbt,EmailInput:pbt,PasswordInput:mbt}},zdn=(0,P9.createContext)(Gdn);var Ao=e=>(0,P9.useContext)(zdn).components[e];var Ydn=U(et(),1);var Q_=U(et(),1);var xO=U(et(),1);var gbt=U(et(),1);var L9=Jt.line;var fee=(0,gbt.createContext)({marker:L9});function Abt({children:e}){let{marker:t}=(0,xO.useContext)(fee),{styles:r}=Ao("UnorderedList");return xO.default.createElement(R,{...r.listItem()},xO.default.createElement(v,{...r.marker()},t),xO.default.createElement(R,{...r.content()},e))}var hbt=U(et(),1),Gve=(0,hbt.createContext)({depth:0});function Vdn({children:e}){let{depth:t}=(0,Q_.useContext)(Gve),{styles:r,config:n}=Ao("UnorderedList"),i=(0,Q_.useMemo)(()=>({depth:t+1}),[t]),o=(0,Q_.useMemo)(()=>{let{marker:s}=n();return typeof s=="string"?{marker:s}:Array.isArray(s)?{marker:s[t]??s.at(-1)??L9}:{marker:L9}},[n,t]);return Q_.default.createElement(Gve.Provider,{value:i},Q_.default.createElement(fee.Provider,{value:o},Q_.default.createElement(R,{...r.list()},e)))}Vdn.Item=Abt;var Kdn=U(et(),1);var Wdn=U(et(),1);var F9=U(et(),1);var wO=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 Ebt=U(et(),1);var DO=U(et(),1);var U9=U(et(),1);function _bt({isFocused:e,isSelected:t,children:r}){let{styles:n}=Ao("Select");return U9.default.createElement(R,{...n.option({isFocused:e})},e&&U9.default.createElement(v,{...n.focusIndicator()},Jt.pointer),U9.default.createElement(v,{...n.label({isFocused:e,isSelected:t})},r),t&&U9.default.createElement(v,{...n.selectedIndicator()},Jt.tick))}var Om=U(et(),1);import{isDeepStrictEqual as Jdn}from"node:util";var Zdn=(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}},ybt=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=typeof e=="number"?Math.min(e,r.length):r.length,i=new wO(r);return{optionMap:i,visibleOptionCount:n,focusedValue:i.first?.value,visibleFromIndex:0,visibleToIndex:n,previousValue:t,value:t}},bbt=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n})=>{let[i,o]=(0,Om.useReducer)(Zdn,{visibleOptionCount:e,defaultValue:r,options:t},ybt),[s,a]=(0,Om.useState)(t);t!==s&&!Jdn(t,s)&&(o({type:"reset",state:ybt({visibleOptionCount:e,defaultValue:r,options:t})}),a(t));let l=(0,Om.useCallback)(()=>{o({type:"focus-next-option"})},[]),c=(0,Om.useCallback)(()=>{o({type:"focus-previous-option"})},[]),u=(0,Om.useCallback)(()=>{o({type:"select-focused-option"})},[]),d=(0,Om.useMemo)(()=>t.map((g,m)=>({...g,index:m})).slice(i.visibleFromIndex,i.visibleToIndex),[t,i.visibleFromIndex,i.visibleToIndex]);return(0,Om.useEffect)(()=>{i.value&&i.previousValue!==i.value&&n?.(i.value)},[i.previousValue,i.value,t,n]),{focusedValue:i.focusedValue,visibleFromIndex:i.visibleFromIndex,visibleToIndex:i.visibleToIndex,value:i.value,visibleOptions:d,focusNextOption:l,focusPreviousOption:c,selectFocusedOption:u}};var Cbt=({isDisabled:e=!1,state:t})=>{ur((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};function RO({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o}){let s=bbt({visibleOptionCount:t,options:n,defaultValue:i,onChange:o});Cbt({isDisabled:e,state:s});let{styles:a}=Ao("Select");return DO.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=DO.default.createElement(DO.default.Fragment,null,l.label.slice(0,u),DO.default.createElement(v,{...a.highlightedText()},r),l.label.slice(u+r.length))}return DO.default.createElement(_bt,{key:l.value,isFocused:!e&&s.focusedValue===l.value,isSelected:s.value===l.value},c)}))}var Xdn=U(et(),1);var Sbt=U(et(),1);var tfn=U(et(),1);var pee=U(et(),1);var efn=U(et(),1);var Oki=cr.inverse(" ");var Zg=U(et(),1);var NO=U(et(),1);var Ibt=U(et(),1);var mee=(0,Ibt.createContext)({marker:Jt.line});function gee({children:e}){let{marker:t}=(0,NO.useContext)(mee),{styles:r}=Ao("OrderedList");return NO.default.createElement(R,{...r.listItem()},NO.default.createElement(v,{...r.marker()},t),NO.default.createElement(R,{...r.content()},e))}var Tbt=U(et(),1),zve=(0,Tbt.createContext)({marker:""});function Xg({children:e}){let{marker:t}=(0,Zg.useContext)(zve),{styles:r}=Ao("OrderedList"),n=0;for(let o of Zg.default.Children.toArray(e))!(0,Zg.isValidElement)(o)||o.type!==gee||n++;let i=String(n).length;return Zg.default.createElement(R,{...r.list()},Zg.default.Children.map(e,(o,s)=>{if(!(0,Zg.isValidElement)(o)||o.type!==gee)return o;let a=`${String(s+1).padStart(i)}.`,l=`${t}${a}`;return Zg.default.createElement(zve.Provider,{value:{marker:l}},Zg.default.createElement(mee.Provider,{value:{marker:l}},o))}))}Xg.Item=gee;var nfn=U(et(),1);var jve=U(et(),1);var rfn=U(et(),1);var lMi=cr.inverse(" ");var ifn=U(et(),1);var ofn=U(et(),1);var afn=U(et(),1);var Aee=U(et(),1);var sfn=U(et(),1);var BMi=cr.inverse(" ");var MO=U(et(),1);var Yve=U(et(),1);r9();Ns();Hi();nx();or();var hee=U(ge(),1),lfn=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function xS(){let e=lfn,{frame:t}=MR({interval:120});return(0,hee.jsx)(R,{flexWrap:"nowrap",height:1,width:2,children:(0,hee.jsx)(v,{color:Oe().claude,children:e[t%e.length]})})}var yee=U(et(),1);var gx=null,P_=null,_ee=new Set,Eee=null;function Wve(e){let{columns:t,rows:r}=e;return t&&r?{columns:t,rows:r}:(Eee||(Eee=Lpe()),{columns:t||Eee.columns||80,rows:r||Eee.rows||24})}function Vve(){if(!P_)return;let e=Wve(P_);gx&&e.columns===gx.columns&&e.rows===gx.rows||(gx=e,_ee.forEach(t=>t(gx)))}function cfn(e,t){return P_!==e&&(P_&&P_.off("resize",Vve),P_=e,gx=Wve(e),e.on("resize",Vve)),_ee.add(t),()=>{_ee.delete(t),_ee.size===0&&P_&&(P_.off("resize",Vve),P_=null,gx=null)}}function Kve(){let{stdout:e}=Qb(),[t,r]=(0,yee.useState)(()=>Wve(e));return(0,yee.useEffect)(()=>cfn(e,r),[e]),t}function bee(){return Kve()}Le();Rf();Pe();gh();Pe();var bPi=U(pSt(),1);import{homedir as W9}from"os";import{join as kO}from"path";import{existsSync as K9,mkdirSync as gSt,appendFileSync as mSt,readFileSync as ASt,constants as sgn,writeFileSync as agn,unlinkSync as hSt,statSync as lgn}from"fs";import{platform as ESt}from"process";import{accessSync as cgn}from"fs";var ogn="2.6.10",V9={VERSION:ogn,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"};Le();var hx=kO(W0,".update.lock"),ugn=300*1e3;function _St(){try{if(K9(W0)||gSt(W0,{recursive:!0}),K9(hx)){let e=lgn(hx);if(Date.now()-e.mtimeMs<ugn)return!1;try{hSt(hx)}catch(r){return Te(`Failed to remove stale lock file: ${r}`),!1}}return agn(hx,`${process.pid}`,"utf8"),!0}catch(e){return Te(`Failed to acquire lock: ${e}`),!1}}function ySt(){try{K9(hx)&&ASt(hx,"utf8")===`${process.pid}`&&hSt(hx)}catch(e){Te(`Failed to release lock: ${e}`)}}async function hxe(){try{let e=await oi("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{cgn(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 bSt(e){if(!_St())throw Bt("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:V9.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{K9(e)||gSt(e,{recursive:!0});let t=await oi(`npm -g config set prefix ${e}`);if(t.code!==0)throw new Error(`Failed to set npm prefix: ${t.stderr}`);let r=`
998
+ ${d}`}}),{messages:a}=t,l=ndn(o);return idn(o,l,s,a)}},zyt=odn;Yg();var TO=U(et(),1);Pe();Pe();var ru=U(ge(),1);import{existsSync as sdn,readdirSync as adn,statSync as ldn}from"fs";import{join as cdn}from"path";function udn(){let e=Xi.plan();if(!sdn(e))return[];try{return adn(e).filter(r=>r.endsWith(".md")).map(r=>{let n=cdn(e,r),i=ldn(n);return{name:r,path:n,modified:i.mtime}}).sort((r,n)=>n.modified.getTime()-r.modified.getTime())}catch{return[]}}var jyt=({onSelect:e})=>{let[t,r]=(0,TO.useState)([]),[n,i]=(0,TO.useState)(0),[o,s]=(0,TO.useState)(!1);(0,TO.useEffect)(()=>{let c=udn();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}))];ur((c,u)=>{if(u.upArrow)i(d=>d>0?d-1:a.length-1);else if(u.downArrow)i(d=>d<a.length-1?d+1:0);else if(u.return){let d=a[n];d&&e(d.value)}else u.escape&&e("__CANCELLED__")});let l=Oe();return o?(0,ru.jsxs)(R,{flexDirection:"column",marginY:1,children:[(0,ru.jsx)(R,{marginBottom:1,children:(0,ru.jsx)(v,{bold:!0,color:l.claude,children:"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"})}),(0,ru.jsx)(R,{marginBottom:1,children:(0,ru.jsx)(v,{bold:!0,color:l.claude,children:" Select a plan to continue, or create a new one"})}),a.map((c,u)=>{let d=u===n;return(0,ru.jsxs)(R,{flexDirection:"row",marginLeft:2,children:[(0,ru.jsx)(v,{color:d?l.claude:l.text,children:d?"\u276F":" "}),(0,ru.jsx)(v,{color:d?l.claude:l.text,children:" "}),(0,ru.jsx)(v,{color:d?l.claude:l.text,bold:c.isNew,children:c.isNew?c.label:c.label.replace(".md","")}),!c.isNew&&c.modified&&(0,ru.jsxs)(v,{dimColor:!0,children:[" ","(",Kge(c.modified),")"]})]},c.isNew?"new":c.value)}),(0,ru.jsx)(R,{marginTop:1,marginLeft:2,children:(0,ru.jsx)(v,{dimColor:!0,children:"\u2191/\u2193 to select \xB7 Enter to confirm \xB7 Esc to cancel"})})]}):(0,ru.jsx)(R,{flexDirection:"column",marginY:1,children:(0,ru.jsx)(v,{children:"Loading plan history..."})})};var Vyt=U(ge(),1),ddn={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):(0,Vyt.jsx)(jyt,{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"}},Yyt=ddn;Yg();var fdn={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"}},Wyt=fdn;br();import{resolve as pdn}from"path";var mdn={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=pdn(r,t);ua(n);let i=Re();return i===r?`Already in ${i}.`:`Changed directory to ${i}/`},userFacingName(){return"cd"}},Kyt=mdn;var xSt=U(et(),1);var Wh=U(et(),1);var jdn=U(et(),1);var P9=U(et(),1),qdn=U(ebt(),1);var tbt={info:"blue",success:"green",error:"red",warning:"yellow"},wdn={styles:{container:({variant:e})=>({flexGrow:1,borderStyle:"round",borderColor:tbt[e],gap:1,paddingX:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:tbt[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}}},rbt=wdn;var Ddn={styles:{container:({color:e})=>({backgroundColor:e}),label:()=>({color:"black"})}},nbt=Ddn;var Rdn={styles:{input:({isFocused:e})=>({dimColor:!e})}},ibt=Rdn;var Ndn={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})}},obt=Ndn;var Bdn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})}},sbt=Bdn;var Odn={styles:{container:()=>({flexGrow:1,minWidth:0}),completed:()=>({color:"magenta"}),remaining:()=>({dimColor:!0})},config:()=>({completedCharacter:Jt.square,remainingCharacter:Jt.squareLightShade})},abt=Odn;var kdn={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})}},lbt=kdn;var Mdn={styles:{container:()=>({gap:1}),frame:()=>({color:"blue"}),label:()=>({})}},cbt=Mdn;var Qdn={success:"green",error:"red",warning:"yellow",info:"blue"},Pdn={success:Jt.tick,error:Jt.cross,warning:Jt.warning,info:Jt.info},Ldn={styles:{container:()=>({gap:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:Qdn[e]}),message:()=>({})},config:({variant:e})=>({icon:Pdn[e]})},ubt=Ldn;var Fdn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})},config:()=>({marker:Jt.line})},dbt=Fdn;var Udn={styles:{value:()=>({})}},fbt=Udn;var Hdn={styles:{value:()=>({})}},pbt=Hdn;var $dn={styles:{value:()=>({})}},mbt=$dn;var Gdn={components:{Alert:rbt,Badge:nbt,ConfirmInput:ibt,MultiSelect:obt,OrderedList:sbt,ProgressBar:abt,Select:lbt,Spinner:cbt,StatusMessage:ubt,UnorderedList:dbt,TextInput:fbt,EmailInput:pbt,PasswordInput:mbt}},zdn=(0,P9.createContext)(Gdn);var Ao=e=>(0,P9.useContext)(zdn).components[e];var Ydn=U(et(),1);var Q_=U(et(),1);var xO=U(et(),1);var gbt=U(et(),1);var L9=Jt.line;var fee=(0,gbt.createContext)({marker:L9});function Abt({children:e}){let{marker:t}=(0,xO.useContext)(fee),{styles:r}=Ao("UnorderedList");return xO.default.createElement(R,{...r.listItem()},xO.default.createElement(v,{...r.marker()},t),xO.default.createElement(R,{...r.content()},e))}var hbt=U(et(),1),Gve=(0,hbt.createContext)({depth:0});function Vdn({children:e}){let{depth:t}=(0,Q_.useContext)(Gve),{styles:r,config:n}=Ao("UnorderedList"),i=(0,Q_.useMemo)(()=>({depth:t+1}),[t]),o=(0,Q_.useMemo)(()=>{let{marker:s}=n();return typeof s=="string"?{marker:s}:Array.isArray(s)?{marker:s[t]??s.at(-1)??L9}:{marker:L9}},[n,t]);return Q_.default.createElement(Gve.Provider,{value:i},Q_.default.createElement(fee.Provider,{value:o},Q_.default.createElement(R,{...r.list()},e)))}Vdn.Item=Abt;var Kdn=U(et(),1);var Wdn=U(et(),1);var F9=U(et(),1);var wO=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 Ebt=U(et(),1);var DO=U(et(),1);var U9=U(et(),1);function _bt({isFocused:e,isSelected:t,children:r}){let{styles:n}=Ao("Select");return U9.default.createElement(R,{...n.option({isFocused:e})},e&&U9.default.createElement(v,{...n.focusIndicator()},Jt.pointer),U9.default.createElement(v,{...n.label({isFocused:e,isSelected:t})},r),t&&U9.default.createElement(v,{...n.selectedIndicator()},Jt.tick))}var Om=U(et(),1);import{isDeepStrictEqual as Jdn}from"node:util";var Zdn=(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}},ybt=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=typeof e=="number"?Math.min(e,r.length):r.length,i=new wO(r);return{optionMap:i,visibleOptionCount:n,focusedValue:i.first?.value,visibleFromIndex:0,visibleToIndex:n,previousValue:t,value:t}},bbt=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n})=>{let[i,o]=(0,Om.useReducer)(Zdn,{visibleOptionCount:e,defaultValue:r,options:t},ybt),[s,a]=(0,Om.useState)(t);t!==s&&!Jdn(t,s)&&(o({type:"reset",state:ybt({visibleOptionCount:e,defaultValue:r,options:t})}),a(t));let l=(0,Om.useCallback)(()=>{o({type:"focus-next-option"})},[]),c=(0,Om.useCallback)(()=>{o({type:"focus-previous-option"})},[]),u=(0,Om.useCallback)(()=>{o({type:"select-focused-option"})},[]),d=(0,Om.useMemo)(()=>t.map((g,m)=>({...g,index:m})).slice(i.visibleFromIndex,i.visibleToIndex),[t,i.visibleFromIndex,i.visibleToIndex]);return(0,Om.useEffect)(()=>{i.value&&i.previousValue!==i.value&&n?.(i.value)},[i.previousValue,i.value,t,n]),{focusedValue:i.focusedValue,visibleFromIndex:i.visibleFromIndex,visibleToIndex:i.visibleToIndex,value:i.value,visibleOptions:d,focusNextOption:l,focusPreviousOption:c,selectFocusedOption:u}};var Cbt=({isDisabled:e=!1,state:t})=>{ur((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};function RO({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o}){let s=bbt({visibleOptionCount:t,options:n,defaultValue:i,onChange:o});Cbt({isDisabled:e,state:s});let{styles:a}=Ao("Select");return DO.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=DO.default.createElement(DO.default.Fragment,null,l.label.slice(0,u),DO.default.createElement(v,{...a.highlightedText()},r),l.label.slice(u+r.length))}return DO.default.createElement(_bt,{key:l.value,isFocused:!e&&s.focusedValue===l.value,isSelected:s.value===l.value},c)}))}var Xdn=U(et(),1);var Sbt=U(et(),1);var tfn=U(et(),1);var pee=U(et(),1);var efn=U(et(),1);var Oki=cr.inverse(" ");var Zg=U(et(),1);var NO=U(et(),1);var Ibt=U(et(),1);var mee=(0,Ibt.createContext)({marker:Jt.line});function gee({children:e}){let{marker:t}=(0,NO.useContext)(mee),{styles:r}=Ao("OrderedList");return NO.default.createElement(R,{...r.listItem()},NO.default.createElement(v,{...r.marker()},t),NO.default.createElement(R,{...r.content()},e))}var Tbt=U(et(),1),zve=(0,Tbt.createContext)({marker:""});function Xg({children:e}){let{marker:t}=(0,Zg.useContext)(zve),{styles:r}=Ao("OrderedList"),n=0;for(let o of Zg.default.Children.toArray(e))!(0,Zg.isValidElement)(o)||o.type!==gee||n++;let i=String(n).length;return Zg.default.createElement(R,{...r.list()},Zg.default.Children.map(e,(o,s)=>{if(!(0,Zg.isValidElement)(o)||o.type!==gee)return o;let a=`${String(s+1).padStart(i)}.`,l=`${t}${a}`;return Zg.default.createElement(zve.Provider,{value:{marker:l}},Zg.default.createElement(mee.Provider,{value:{marker:l}},o))}))}Xg.Item=gee;var nfn=U(et(),1);var jve=U(et(),1);var rfn=U(et(),1);var lMi=cr.inverse(" ");var ifn=U(et(),1);var ofn=U(et(),1);var afn=U(et(),1);var Aee=U(et(),1);var sfn=U(et(),1);var BMi=cr.inverse(" ");var MO=U(et(),1);var Yve=U(et(),1);r9();Ns();Hi();nx();or();var hee=U(ge(),1),lfn=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function xS(){let e=lfn,{frame:t}=MR({interval:120});return(0,hee.jsx)(R,{flexWrap:"nowrap",height:1,width:2,children:(0,hee.jsx)(v,{color:Oe().claude,children:e[t%e.length]})})}var yee=U(et(),1);var gx=null,P_=null,_ee=new Set,Eee=null;function Wve(e){let{columns:t,rows:r}=e;return t&&r?{columns:t,rows:r}:(Eee||(Eee=Lpe()),{columns:t||Eee.columns||80,rows:r||Eee.rows||24})}function Vve(){if(!P_)return;let e=Wve(P_);gx&&e.columns===gx.columns&&e.rows===gx.rows||(gx=e,_ee.forEach(t=>t(gx)))}function cfn(e,t){return P_!==e&&(P_&&P_.off("resize",Vve),P_=e,gx=Wve(e),e.on("resize",Vve)),_ee.add(t),()=>{_ee.delete(t),_ee.size===0&&P_&&(P_.off("resize",Vve),P_=null,gx=null)}}function Kve(){let{stdout:e}=Qb(),[t,r]=(0,yee.useState)(()=>Wve(e));return(0,yee.useEffect)(()=>cfn(e,r),[e]),t}function bee(){return Kve()}Le();Rf();Pe();gh();Pe();var bPi=U(pSt(),1);import{homedir as W9}from"os";import{join as kO}from"path";import{existsSync as K9,mkdirSync as gSt,appendFileSync as mSt,readFileSync as ASt,constants as sgn,writeFileSync as agn,unlinkSync as hSt,statSync as lgn}from"fs";import{platform as ESt}from"process";import{accessSync as cgn}from"fs";var ogn="2.6.11",V9={VERSION:ogn,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"};Le();var hx=kO(W0,".update.lock"),ugn=300*1e3;function _St(){try{if(K9(W0)||gSt(W0,{recursive:!0}),K9(hx)){let e=lgn(hx);if(Date.now()-e.mtimeMs<ugn)return!1;try{hSt(hx)}catch(r){return Te(`Failed to remove stale lock file: ${r}`),!1}}return agn(hx,`${process.pid}`,"utf8"),!0}catch(e){return Te(`Failed to acquire lock: ${e}`),!1}}function ySt(){try{K9(hx)&&ASt(hx,"utf8")===`${process.pid}`&&hSt(hx)}catch(e){Te(`Failed to release lock: ${e}`)}}async function hxe(){try{let e=await oi("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{cgn(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 bSt(e){if(!_St())throw Bt("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:V9.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{K9(e)||gSt(e,{recursive:!0});let t=await oi(`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(ESt==="win32"){let n=await oi(`setx PATH "${process.env.PATH};${e}"`);if(n.code!==0)throw new Error(`Failed to update PATH on Windows: ${n.stderr}`)}else{let n=[kO(W9(),".bashrc"),kO(W9(),".bash_profile"),kO(W9(),".zshrc"),kO(W9(),".config","fish","config.fish")];for(let i of n)if(K9(i))try{if(!ASt(i,"utf8").includes(e)){if(i.includes("fish")){let s=`
@@ -3048,7 +3048,7 @@ ${t}
3048
3048
 
3049
3049
  `);d[Ic(A)]={description:_,inputSchema:g.inputSchema??{type:"object"},outputSchema:h}}return{path:i,description:`Provider ${i}`,types:kLe(d,s),kind:"provider"}}let c=o?Ic(o):void 0,u=c?a.filter(d=>d.name===`cm_${s}_${c}`||d.name.endsWith(`_${c}`)):a;for(let d of u){let g=`cm_${s}_`,m=d.name.slice(g.length),A=Ic(m),h=Uzt(d,l.get(`${i}.${m}`)),_=h?d.description??"":[d.description,Hzt(i,m)].filter(Boolean).join(`
3050
3050
 
3051
- `);return{path:`${i}.${m}`,description:_,types:kLe({[A]:{description:_,inputSchema:d.inputSchema??{type:"object"},outputSchema:h}},s),kind:"method"}}return{path:e,description:void 0,types:`"${e}" not found.`,kind:"method"}}function zzt(e,t){if(!e||t<=0)return"";let r=/[\u2E80-\u2FDF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]|[\p{L}\p{N}]+(?:['’\-][\p{L}\p{N}]+)*/gu,n=0,i=0;for(let o of e.matchAll(r))if(n++,i=(o.index??0)+o[0].length,n>=t)break;return n===0?"":n<t?e:e.slice(0,i)+"..."}or();var C3n=k.object({code:k.string().describe("JavaScript async arrow function to execute"),timeout:k.number().optional().describe("Execution timeout in seconds. Defaults to 60.")}),S3n='Execute JavaScript in a sandbox that has access to provider methods and sandbox meta methods. Available providers and their methods are listed at the end of this prompt under \u201CAvailable providers & methods".\n\n## Call provider methods\n\n`codemode.<provider>.<method>(input)`.\n\n## Call sandbox meta methods\n\nThe meta methods are typed as follows (descriptions in JSDoc):\n\n`codemode.<meta_function_name>(input)`.\n\n```ts\n{{metaTypes}}\n```\n\n## Rules\n\n- The ONLY globals are the configured codemode providers and `codemode` itself (plus standard JavaScript). No `host`, `fs`, `require`, `process`, or Node.js APIs \u2014 all I/O goes through the providers.\n- NEVER guess method names or parameters. If you already know the method name, check its parameters with `await codemode.describe("provider.method")` \u2014 no need to search first. Only when the method name is unknown, discover it with `await codemode.search(...)`.\n- The meta methods above are sandbox JavaScript functions, NOT external tools. Call them only from inside the async arrow function you return.\n- Batch independent calls into ONE function: sequential `await`s (or `Promise.all`) inside a single returned function. Only split into multiple codemode calls when a later call depends on an earlier call\'s result. Never retry the same failing call in a loop \u2014 try an alternative approach instead.\n- Return the final value directly. On failure, throw an Error with a clear message instead of returning partial results.\n- Write a single async arrow function in plain JavaScript. No TypeScript syntax (no type annotations, interfaces, or generics), no named helper functions \u2014 write the arrow function body directly.\n- If `codemode.describe` reports an `unknown` return type, If the outputSchema can be inferred from the execution result, call saveOutputSchema promptly, but not in the same function as the inference, so that subsequent queries can provide an outputSchema.\n\n## Available providers & methods\n\n{{providers}}',I3n=60;function Yzt(){return rt.getCodemodeMethodsMax()}async function T3n(){let[e,t]=await Promise.all([gE().catch(()=>[]),m1().catch(()=>[])]),r=[...new Set(t.map(o=>o.provider))];if(r.length===0)return"No providers configured. You can still write plain JavaScript.";let n={},i={};for(let o of r)n[o]=[];for(let o of e)o.type==="connected"&&(i[o.name]=o.instructions);for(let o of t){let s=o.name.slice(`cm_${Ic(o.provider)}_`.length);n[o.provider].includes(s)||n[o.provider].push(s)}return r.map(o=>{let s=n[o],a=i[o]?.replace(/\r\n/g,`
3051
+ `);return{path:`${i}.${m}`,description:_,types:kLe({[A]:{description:_,inputSchema:d.inputSchema??{type:"object"},outputSchema:h}},s),kind:"method"}}return{path:e,description:void 0,types:`"${e}" not found.`,kind:"method"}}function zzt(e,t){if(!e||t<=0)return"";let r=/[\u2E80-\u2FDF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]|[\p{L}\p{N}]+(?:['’\-][\p{L}\p{N}]+)*/gu,n=0,i=0;for(let o of e.matchAll(r))if(n++,i=(o.index??0)+o[0].length,n>=t)break;return n===0?"":n<t?e:e.slice(0,i)+"..."}or();var C3n=k.object({code:k.string().describe("JavaScript async arrow function to execute"),timeout:k.number().optional().describe("Execution timeout in seconds. Defaults to 60.")}),S3n="Execute JavaScript in a sandbox that has access to provider methods and sandbox meta methods. Available providers and their methods are listed at the end of this prompt under \u201CAvailable providers & methods\".\n\n## Call provider methods\n\n`codemode.<provider>.<method>(input)`.\n\n## Call sandbox meta methods\n\nThe meta methods are typed as follows (descriptions in JSDoc):\n\n`codemode.<meta_function_name>(input)`.\n\n```ts\n{{metaTypes}}\n```\n\n## Rules\n\n- The ONLY globals are the configured codemode providers and `codemode` itself (plus standard JavaScript). No `host`, `fs`, `require`, `process`, or Node.js APIs \u2014 all I/O goes through the providers.\n- NEVER guess method names or parameters. If you already know the method name, check its parameters with `await codemode.describe` \u2014 no need to search first. Only when the method name is unknown, discover it with `await codemode.search`.\n- The meta methods above are sandbox JavaScript functions, NOT external tools. Call them only from inside the async arrow function you return.\n- Batch independent calls into ONE function: sequential `await`s (or `Promise.all`) inside a single returned function. Only split into multiple codemode calls when a later call depends on an earlier call's result. Never retry the same failing call in a loop \u2014 try an alternative approach instead.\n- Return the final value directly. On failure, throw an Error with a clear message instead of returning partial results.\n- Write a single async arrow function in plain JavaScript. No TypeScript syntax (no type annotations, interfaces, or generics), no named helper functions \u2014 write the arrow function body directly.\n- If `codemode.describe` reports an `unknown` return type, If the outputSchema can be inferred from the execution result, call `codemode.saveOutputSchema` promptly, but not in the same function as the inference, so that subsequent queries can provide an outputSchema.\n\n## Available providers & methods\n\n{{providers}}",I3n=60;function Yzt(){return rt.getCodemodeMethodsMax()}async function T3n(){let[e,t]=await Promise.all([gE().catch(()=>[]),m1().catch(()=>[])]),r=[...new Set(t.map(o=>o.provider))];if(r.length===0)return"No providers configured. You can still write plain JavaScript.";let n={},i={};for(let o of r)n[o]=[];for(let o of e)o.type==="connected"&&(i[o.name]=o.instructions);for(let o of t){let s=o.name.slice(`cm_${Ic(o.provider)}_`.length);n[o.provider].includes(s)||n[o.provider].push(s)}return r.map(o=>{let s=n[o],a=i[o]?.replace(/\r\n/g,`
3052
3052
  `).replace(/\n+/g,"\\n").trim(),l=Yzt(),c=s.slice(0,l),u=s.length-c.length,d=`### ${o}\uFF08${s.length} methods, showing ${c.length}\uFF09`,g=zzt(a??"(none)",I3n),m=c.length>0?c.join(`
3053
3053
  `)+(u>0?`
3054
3054
  (... ${u} more methods)`:""):"(no methods available)";return`${d}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dahawa/hawa-code",
3
- "version": "2.6.10",
3
+ "version": "2.6.11",
4
4
  "bin": {
5
5
  "hcode": "hawa.js"
6
6
  },