@dahawa/hawa-code 2.6.7 → 2.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +4 -4
- package/hands.js +4 -4
- 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=Rn();e.hasCompletedProjectOnboarding||ui({...e,hasCompletedProjectOnboarding:!0})}function xbe({workspaceDir:e}){let r=!Rn().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.7",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=Rn();e.hasCompletedProjectOnboarding||ui({...e,hasCompletedProjectOnboarding:!0})}function xbe({workspaceDir:e}){let r=!Rn().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.9",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 Y=JSON.parse(P);w(Y)}catch(Y){this.logger&&this.logger.error({err:Y,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.
|
|
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.9";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>
|
|
@@ -3187,14 +3187,14 @@ process.on('message', async (msg) => {
|
|
|
3187
3187
|
${t}
|
|
3188
3188
|
}`}cr();import{existsSync as Kio,mkdirSync as Jio,readFileSync as Zio,writeFileSync as Xio}from"fs";import{dirname as eso,join as tso}from"path";Re();function per(){return tso(Ne(),".hcode",".codemode-snippets.json")}function Iue(){let e=per();if(!Kio(e))return[];try{let t=Zio(e,"utf-8"),r=ud(t);return Array.isArray(r)?r:(re(`Invalid snippets file format at ${e}: expected array`),[])}catch(t){return re(`Failed to read snippets ${e}:`,t),[]}}function rso(e){let t=per();try{Jio(eso(t),{recursive:!0}),Xio(t,JSON.stringify(e,null,2),"utf-8")}catch(r){throw re(`Failed to write snippets ${t}:`,r),r}}function mer(e){let t=Iue(),r=t.findIndex(n=>n.name===e.name);r>=0?t[r]=e:t.push(e),rso(t)}function fer(e){return Iue().find(t=>t.name===e)}cr();import{existsSync as nso,mkdirSync as oso,readFileSync as iso,writeFileSync as sso}from"fs";import{homedir as aso}from"os";import{dirname as lso,join as ger}from"path";Re();function her(e){return{userPath:e?.userPath??ger(aso(),".hcode","codemode-output-schemas.json"),projectPath:e?.projectPath??ger(Ne(),".hcode","codemode-output-schemas.json"),globalConfig:jP(e?.globalConfigPath??NN)??{},projectConfig:jP(e?.projectConfigPath??DN)??{}}}function cso(e,t){let r=e.split(".")[0];return r in t.projectConfig?t.projectPath:r in t.globalConfig?t.userPath:t.projectPath}function $3e(e){if(!nso(e))return[];try{let t=iso(e,"utf-8"),r=ud(t);return Array.isArray(r)?r:(re(`Invalid output schemas file format at ${e}: expected array`),[])}catch(t){return re(`Failed to read output schemas ${e}:`,t),[]}}function uso(e,t){try{oso(lso(e),{recursive:!0}),sso(e,JSON.stringify(t,null,2),"utf-8")}catch(r){throw re(`Failed to write output schemas ${e}:`,r),r}}function Aer(e){let t=her(e),r=new Map;for(let n of $3e(t.userPath))r.set(n.target,n);for(let n of $3e(t.projectPath))r.set(n.target,n);return[...r.values()]}function _er(e,t){let r=her(t),n=cso(e.target,r),o=$3e(n),i=o.findIndex(s=>s.target===e.target);i>=0?o[i]=e:o.push(e),uso(n,o)}var Eer=50,vue={path:12,provider:8,method:10,description:5};function f6(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_./:-]+/g," ").toLowerCase().trim()}var ber=typeof Intl.Segmenter=="function"?new Intl.Segmenter("zh",{granularity:"word"}):null;function Rue(e){let t=f6(e);if(t.length===0)return[];if(ber){let r=[];for(let{segment:n,isWordLike:o}of ber.segment(t)){if(!o)continue;let i=n.trim();i&&r.push(i)}return r}return t.split(/[^a-z0-9]+/).map(r=>r.trim()).filter(Boolean)}function xue(e){return{raw:f6(e??""),tokens:Rue(e??"")}}function wue(e,t,r,n){if(r.raw.length===0)return{score:0,matchedTokens:new Set,exactPhrase:!1};let o=0,i=new Set,s=e.length>0&&r.raw.includes(e);e.length>0&&(r.raw===e?o+=n*14:r.raw.startsWith(e)?o+=n*9:s&&(o+=n*6));for(let a of t)r.tokens.includes(a)?(o+=n*4,i.add(a)):r.tokens.some(l=>l.startsWith(a)||a.startsWith(l))?(o+=n*2,i.add(a)):r.raw.includes(a)&&(o+=n,i.add(a));return{score:o,matchedTokens:i,exactPhrase:s}}function dso(e,t){let r=f6(t),n=Rue(t);if(r.length===0||n.length===0)return null;let o=[wue(r,n,xue(e.path),vue.path),wue(r,n,xue(e.provider),vue.provider),wue(r,n,xue(e.method),vue.method),wue(r,n,xue(e.description),vue.description)],i=new Set,s=0,a=!1;for(let f of o){s+=f.score,a||=f.exactPhrase;for(let p of f.matchedTokens)i.add(p)}if(i.size===0)return null;let l=i.size/n.length,c=n.length<=2?1:.6;if(l<c&&!a)return null;l===1?s+=25:s+=Math.round(l*10);let u=Rue(e.path),d=Rue(e.method);return(u[0]===n[0]||d[0]===n[0])&&(s+=8),(f6(e.path)===r||f6(e.method)===r)&&(s+=20),{path:e.path,provider:e.provider,method:e.method,description:e.description,...e.requiresApproval?{requiresApproval:!0}:{},kind:e.kind,score:s}}function Ser(e,t,r,n=[]){let o=e.query,i=[];for(let d of t){let f=d.provider??n.find(A=>d.name.startsWith(`cm_${Uc(A)}_`));if(!f)continue;let p=d.name.slice(`cm_${Uc(f)}_`.length),h=d.description??"";i.push({path:`${f}.${p}`,provider:f,method:p,description:h,kind:"method"})}for(let d of r)i.push({path:`snippet.${d.name}`,provider:"snippet",method:d.name,description:d.description,kind:"snippet"});let s=e.provider?.trim(),l=(s?i.filter(d=>d.provider===s):i).map(d=>dso(d,o)).filter(d=>d!==null).sort((d,f)=>f.score-d.score||d.path.localeCompare(f.path)),c=l.length;return{results:l.slice(0,Eer),total:c,truncated:c>Eer}}function g6(e){return e.replace(/\*\//g,"* /").replace(/\r?\n/g," ")}function pso(){return typeof process<"u"&&process.env?.HAWA_CODE_JSDOC==="true"}function mso(e){let t={};if(e&&typeof e=="object"&&e.properties)for(let[r,n]of Object.entries(e.properties))n&&typeof n=="object"&&n.description&&(t[r]=n.description);return t}function C_(e,t){return e==null?"unknown":Array.isArray(e.type)?e.type.map(r=>yer(r,e,t)).join(" | "):yer(e.type,e,t)}function yer(e,t,r){switch(e){case"string":return t.enum?t.enum.map(n=>JSON.stringify(n)).join(" | "):"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"array":return`Array<${C_(t.items,r)}>`;case"object":{let n=["{"],o=t.properties??{},i=new Set(t.required??[]);for(let[s,a]of Object.entries(o)){let l=i.has(s)?"":"?",c=C_(a,`${r} `),u=[];typeof a=="object"&&a?.description&&u.push(g6(a.description)),typeof a=="object"&&a&&(a.minimum!==void 0&&u.push(`Minimum: ${a.minimum}`),a.maximum!==void 0&&u.push(`Maximum: ${a.maximum}`),a.minLength!==void 0&&u.push(`Min length: ${a.minLength}`),a.maxLength!==void 0&&u.push(`Max length: ${a.maxLength}`),a.default!==void 0&&u.push(`Default: ${JSON.stringify(a.default)}`)),u.length>0&&n.push(`${r} /** ${u.join(" ")} */`),n.push(`${r} ${s}${l}: ${c};`)}return t.additionalProperties&&n.push(`${r} [key: string]: unknown;`),n.push(`${r}}`),n.join(`
|
|
3189
3189
|
`)}case"null":return"null";default:return"unknown"}}function q3e(e,t="codemode"){let r=[`declare const ${t}: {`];for(let[n,o]of Object.entries(e)){let i=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(n)?n:`'${n}'`,s=C_(o.inputSchema," "),a=o.outputSchema?C_(o.outputSchema," "):"unknown",l=[];if(o.description?.trim()&&l.push(g6(o.description.trim())),pso()){let c=mso(o.inputSchema);for(let[u,d]of Object.entries(c))l.push(g6(`@param input.${u} - ${d}`))}else l.push(g6("@param input - Input parameters."));if(o.outputSchema?.description&&l.push(g6(`@returns ${o.outputSchema.description}`)),l.length>0){r.push(" /**");for(let c of l)r.push(` * ${c}`);r.push(" */")}r.push(` ${i}(input: ${s}): Promise<${a}>;`)}return r.push("};"),r.join(`
|
|
3190
|
-
`)}function Cer(e,t){return e.outputSchema!==void 0?e.outputSchema:t?.outputSchema}function Ter(e,t){return`\u26A0\uFE0F No outputSchema declared for "${e}.${t}" (return type is unknown). If the outputSchema can be inferred from the execution result, call saveOutputSchema promptly so that subsequent queries can provide an outputSchema`}var Nue={search:{description:'Search methods and snippets by intent. The "Available providers & methods" section lists at most {{METHODS_MAX}} methods per provider \u2014 use codemode.search to discover any method not shown.',inputSchema:{type:"object",properties:{query:{type:"string",description:"Short intent phrase to search for"},provider:{type:"string",description:'Optional provider name to scope the search, e.g. "github"; use "snippet" to search only snippets'}},required:["query"]},outputSchema:{type:"object",description:"Search output with ranked matches and truncation info",properties:{results:{type:"array",description:"Matching methods and snippets, best matches first",items:{type:"object",properties:{path:{type:"string",description:'Method or snippet path, e.g. "provider.method" or "snippet.<name>"'},provider:{type:"string",description:'Provider name, e.g. "github"'},method:{type:"string",description:'Method name, e.g. "list_commits"'},description:{type:"string",description:"What the method or snippet does"},requiresApproval:{type:"boolean",description:"Whether calling this method requires user approval"},kind:{type:"string",enum:["method","snippet"],description:'Result kind: "method" or "snippet"'},score:{type:"number",description:"Relevance score, higher is better"}},required:["path","provider","method","kind","score"]}},total:{type:"number",description:"Total number of matches before truncation"},truncated:{type:"boolean",description:"Whether results were truncated to the result limit"}},required:["results","total","truncated"]}},describe:{description:"Get docs, input and output structure of a method.",inputSchema:{type:"object",properties:{target:{type:"string",description:'e.g. "provider.method", "provider", "snippet.<name>"'}},required:["target"]},outputSchema:{type:"object",properties:{path:{type:"string",description:'The resolved target path, e.g. "provider.method"'},description:{type:"string",description:"Documentation for the target"},types:{type:"string",description:"Generated TypeScript declaration for the target"},kind:{type:"string",enum:["method","snippet","provider"],description:"What kind of target was described"}},required:["path","types","kind"]}},saveSnippet:{description:"Save a snippet for reuse.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Snippet name"},code:{type:"string",description:"Snippet code (async arrow function body)"},description:{type:"string",description:"What the snippet does"},inputSchema:{type:"object",description:"Optional JSON Schema of the snippet input. Saved with the snippet and used by describe to generate a concrete input type."},outputSchema:{type:"object",description:"Optional JSON Schema of the snippet output. Saved with the snippet and used by describe to generate a concrete return type."}},required:["name","code","description"]},outputSchema:{type:"object",properties:{saved:{type:"boolean",description:"Whether the snippet was saved successfully"},name:{type:"string",description:"The name of the saved snippet"}},required:["saved","name"]}},saveOutputSchema:{description:"Save an inferred output schema",inputSchema:{type:"object",properties:{target:{type:"string",description:'Target in the form "provider.method"'},outputSchema:{type:"object",description:"Output JSON Schema"},description:{type:"string",description:"Optional note about the output structure"}},required:["target","outputSchema"]},outputSchema:{type:"object",properties:{saved:{type:"boolean",description:"Whether the output schema was saved successfully"},target:{type:"string",description:'The target the schema was saved for, in the form "provider.method"'}},required:["saved","target"]}}};function Ier(e){return e.replace(/\*\//g,"* /").replace(/\r?\n/g," ")}function Y3e(e){let t=["declare const codemode: {"];for(let r of e){if(r==="snippet"){t.push(" /** Call a saved snippet by name. */"),t.push(" snippet: {"),t.push(" [name: string]: (input?: unknown) => Promise<unknown>;"),t.push(" };");continue}let n=Nue[r],o=n.inputSchema.properties??{},i=new Set(n.inputSchema.required??[]),s=Object.entries(o).map(([d,f])=>{let p=i.has(d)?"":"?";return`${d}${p}: ${C_(f," ")}`}),a=r==="search",l=a?`options: { ${s.join("; ")} }`:s.join(", "),c=n.outputSchema?C_(n.outputSchema," "):"unknown",u=[];n.description&&u.push(Ier(n.description));for(let[d,f]of Object.entries(o)){let p=f.description;if(p){let h=a?`options.${d}`:d;u.push(`@param ${h} - ${Ier(p)}`)}}if(u.length===1)t.push(` /** ${u[0]} */`);else if(u.length>1){t.push(" /**");for(let d of u)t.push(` * ${d}`);t.push(" */")}t.push(` ${r}(${l}): Promise<${c}>;`)}return t.push("};"),t.join(`
|
|
3190
|
+
`)}function Cer(e,t){return e.outputSchema!==void 0?e.outputSchema:t?.outputSchema}function Ter(e,t){return`\u26A0\uFE0F No outputSchema declared for "${e}.${t}" (return type is unknown). 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`}var Nue={search:{description:'Search methods and snippets by intent. The "Available providers & methods" section lists at most {{METHODS_MAX}} methods per provider \u2014 use codemode.search to discover any method not shown.',inputSchema:{type:"object",properties:{query:{type:"string",description:"Short intent phrase to search for"},provider:{type:"string",description:'Optional provider name to scope the search, e.g. "github"; use "snippet" to search only snippets'}},required:["query"]},outputSchema:{type:"object",description:"Search output with ranked matches and truncation info",properties:{results:{type:"array",description:"Matching methods and snippets, best matches first",items:{type:"object",properties:{path:{type:"string",description:'Method or snippet path, e.g. "provider.method" or "snippet.<name>"'},provider:{type:"string",description:'Provider name, e.g. "github"'},method:{type:"string",description:'Method name, e.g. "list_commits"'},description:{type:"string",description:"What the method or snippet does"},requiresApproval:{type:"boolean",description:"Whether calling this method requires user approval"},kind:{type:"string",enum:["method","snippet"],description:'Result kind: "method" or "snippet"'},score:{type:"number",description:"Relevance score, higher is better"}},required:["path","provider","method","kind","score"]}},total:{type:"number",description:"Total number of matches before truncation"},truncated:{type:"boolean",description:"Whether results were truncated to the result limit"}},required:["results","total","truncated"]}},describe:{description:"Get docs, input and output structure of a method.",inputSchema:{type:"object",properties:{target:{type:"string",description:'e.g. "provider.method", "provider", "snippet.<name>"'}},required:["target"]},outputSchema:{type:"object",properties:{path:{type:"string",description:'The resolved target path, e.g. "provider.method"'},description:{type:"string",description:"Documentation for the target"},types:{type:"string",description:"Generated TypeScript declaration for the target"},kind:{type:"string",enum:["method","snippet","provider"],description:"What kind of target was described"}},required:["path","types","kind"]}},saveSnippet:{description:"Save a snippet for reuse.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Snippet name"},code:{type:"string",description:"Snippet code (async arrow function body)"},description:{type:"string",description:"What the snippet does"},inputSchema:{type:"object",description:"Optional JSON Schema of the snippet input. Saved with the snippet and used by describe to generate a concrete input type."},outputSchema:{type:"object",description:"Optional JSON Schema of the snippet output. Saved with the snippet and used by describe to generate a concrete return type."}},required:["name","code","description"]},outputSchema:{type:"object",properties:{saved:{type:"boolean",description:"Whether the snippet was saved successfully"},name:{type:"string",description:"The name of the saved snippet"}},required:["saved","name"]}},saveOutputSchema:{description:"Save an inferred output schema",inputSchema:{type:"object",properties:{target:{type:"string",description:'Target in the form "provider.method"'},outputSchema:{type:"object",description:"Output JSON Schema"},description:{type:"string",description:"Optional note about the output structure"}},required:["target","outputSchema"]},outputSchema:{type:"object",properties:{saved:{type:"boolean",description:"Whether the output schema was saved successfully"},target:{type:"string",description:'The target the schema was saved for, in the form "provider.method"'}},required:["saved","target"]}}};function Ier(e){return e.replace(/\*\//g,"* /").replace(/\r?\n/g," ")}function Y3e(e){let t=["declare const codemode: {"];for(let r of e){if(r==="snippet"){t.push(" /** Call a saved snippet by name. */"),t.push(" snippet: {"),t.push(" [name: string]: (input?: unknown) => Promise<unknown>;"),t.push(" };");continue}let n=Nue[r],o=n.inputSchema.properties??{},i=new Set(n.inputSchema.required??[]),s=Object.entries(o).map(([d,f])=>{let p=i.has(d)?"":"?";return`${d}${p}: ${C_(f," ")}`}),a=r==="search",l=a?`options: { ${s.join("; ")} }`:s.join(", "),c=n.outputSchema?C_(n.outputSchema," "):"unknown",u=[];n.description&&u.push(Ier(n.description));for(let[d,f]of Object.entries(o)){let p=f.description;if(p){let h=a?`options.${d}`:d;u.push(`@param ${h} - ${Ier(p)}`)}}if(u.length===1)t.push(` /** ${u[0]} */`);else if(u.length>1){t.push(" /**");for(let d of u)t.push(` * ${d}`);t.push(" */")}t.push(` ${r}(${l}): Promise<${c}>;`)}return t.push("};"),t.join(`
|
|
3191
3191
|
`)}function ver(e){return Y3e([...Object.keys(Nue),"snippet"]).replace(/\{\{METHODS_MAX\}\}/g,String(e))}function fso(e){let t=e.inputSchema?C_(e.inputSchema," "):"unknown",r=e.outputSchema?C_(e.outputSchema," "):"unknown",n=e.inputSchema?"":"?";return["declare const codemode: {"," snippet: {",` ${e.name}(input${n}: ${t}): Promise<${r}>;`," };","};"].join(`
|
|
3192
3192
|
`)}function xer(e,t,r,n=[]){let[o,i]=e.includes(".")?e.split(".",2):[e,void 0];if(o==="snippet"){let d=e.slice(8),f=d?r.find(p=>p.name===d):void 0;return f?{path:f.name,description:f.description,types:fso(f),kind:"snippet"}:{path:e,description:void 0,types:`"${e}" not found.`,kind:"snippet"}}if(o==="codemode"){if(i===void 0)return{path:"codemode",description:"Codemode meta functions (search / describe / saveSnippet / saveOutputSchema / snippet.<name>).",types:Y3e(Object.keys(Nue)),kind:"provider"};if(i==="snippet")return{path:"codemode.snippet",description:'Run a saved snippet by name: `codemode.snippet.<name>(input)`. The snippet code is executed as an async arrow function; declare `async (input) => {...}` to receive the input. Snippets without a parameter simply ignore it. Use `codemode.describe("snippet.<name>")` to inspect a snippet.',types:["declare const codemode: {"," snippet: {"," [name: string]: (input?: unknown) => Promise<unknown>;"," };","};"].join(`
|
|
3193
3193
|
`),kind:"method"};let d=Nue[i];if(d)return{path:`codemode.${i}`,description:d.description,types:Y3e([i]),kind:"method"}}let s=Uc(o),a=t.filter(d=>d.provider?d.provider===o||Uc(d.provider)===s:d.name.startsWith(`cm_${s}_`)),l=new Map(n.map(d=>[d.target,d]));if(i===void 0&&a.length>0){let d={};for(let f of a){let p=`cm_${s}_`,h=f.name.slice(p.length),A=Cer(f,l.get(`${o}.${h}`)),_=A?f.description||void 0:[f.description,Ter(o,h)].filter(Boolean).join(`
|
|
3194
3194
|
|
|
3195
3195
|
`);d[Uc(h)]={description:_,inputSchema:f.inputSchema??{type:"object"},outputSchema:A}}return{path:o,description:`Provider ${o}`,types:q3e(d,s),kind:"provider"}}let c=i?Uc(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=Uc(p),A=Cer(d,l.get(`${o}.${p}`)),_=A?d.description??"":[d.description,Ter(o,p)].filter(Boolean).join(`
|
|
3196
3196
|
|
|
3197
|
-
`);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 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=bb(),t=Object.keys(e);if(t.length===0)return"No providers configured. You can still write plain JavaScript.";let[r,n]=await Promise.all([Sb().catch(()=>[]),Sv().catch(()=>[])]),o={},i={};for(let s of t)o[s]=[];for(let s of r)s.type==="connected"&&(i[s.name]=s.instructions);for(let s of n){let a=s.provider??t.find(c=>s.name.startsWith(`cm_${Uc(c)}_`));if(!a||o[a]===void 0)continue;let l=s.name.slice(`cm_${Uc(a)}_`.length);o[a].includes(l)||o[a].push(l)}return t.map(s=>{let a=o[s],l=i[s]?.replace(/\r\n/g,`
|
|
3197
|
+
`);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=bb(),t=Object.keys(e);if(t.length===0)return"No providers configured. You can still write plain JavaScript.";let[r,n]=await Promise.all([Sb().catch(()=>[]),Sv().catch(()=>[])]),o={},i={};for(let s of t)o[s]=[];for(let s of r)s.type==="connected"&&(i[s.name]=s.instructions);for(let s of n){let a=s.provider??t.find(c=>s.name.startsWith(`cm_${Uc(c)}_`));if(!a||o[a]===void 0)continue;let l=s.name.slice(`cm_${Uc(a)}_`.length);o[a].includes(l)||o[a].push(l)}return t.map(s=>{let a=o[s],l=i[s]?.replace(/\r\n/g,`
|
|
3198
3198
|
`).replace(/\n+/g,"\\n").trim(),c=Ner(),u=a.slice(0,c),d=a.length-u.length,f=`### ${s}\uFF08${a.length} methods, showing ${u.length}\uFF09`,p=wer(l??"(none)",Aso),h=u.length>0?u.join(`
|
|
3199
3199
|
`)+(d>0?`
|
|
3200
3200
|
(... ${d} more methods)`:""):"(no methods available)";return`${f}
|
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 S_(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 mc={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function zZ(e,t){mc.totalCost+=e,mc.totalAPIDuration+=t}function jZ(e,t){mc.inputTokens+=e,mc.outputTokens+=t,Tr.emit("token:change",{inputTokens:mc.inputTokens,outputTokens:mc.outputTokens})}function YZ(e,t){mc.cacheCreationTokens+=e,mc.cacheReadTokens+=t}function OIe(){return{inputTokens:mc.inputTokens,outputTokens:mc.outputTokens,cacheCreationTokens:mc.cacheCreationTokens,cacheReadTokens:mc.cacheReadTokens}}function Kmt(){return mc.totalCost}function Jmt(){return Date.now()-mc.startTime}function Zmt(){return mc.totalAPIDuration}function Xmt(e){mc.currentContextTokens=e}function egt(){return mc.currentContextTokens}Pe();Le();Le();var kIe="2.6.7";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 ME}from"crypto";Ns();Pe();er();br();Pe();Le();import{existsSync as w_,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 T_(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 Ac=(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;Ac.sep=gsn;var Jc=Symbol("globstar **");Ac.GLOBSTAR=Jc;var Asn="[^/]",hsn=Asn+"*?",Esn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",_sn="(?:(?!(?:\\/|^)\\.).)*?",ysn=(e,t={})=>r=>Ac(r,e,t);Ac.filter=ysn;var xm=(e,t={})=>Object.assign({},e,t),bsn=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return Ac;let t=Ac;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})};Ac.defaults=bsn;var Pht=(e,t={})=>(Z5(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Tht(e,{max:t.braceExpandMax}));Ac.braceExpand=Pht;var Csn=(e,t={})=>new V2(e,t).makeRe();Ac.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};Ac.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 Ac.defaults(t).Minimatch}};Ac.AST=qv;Ac.Minimatch=V2;Ac.escape=nTe;Ac.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 Ac(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 S_(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 mc={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function zZ(e,t){mc.totalCost+=e,mc.totalAPIDuration+=t}function jZ(e,t){mc.inputTokens+=e,mc.outputTokens+=t,Tr.emit("token:change",{inputTokens:mc.inputTokens,outputTokens:mc.outputTokens})}function YZ(e,t){mc.cacheCreationTokens+=e,mc.cacheReadTokens+=t}function OIe(){return{inputTokens:mc.inputTokens,outputTokens:mc.outputTokens,cacheCreationTokens:mc.cacheCreationTokens,cacheReadTokens:mc.cacheReadTokens}}function Kmt(){return mc.totalCost}function Jmt(){return Date.now()-mc.startTime}function Zmt(){return mc.totalAPIDuration}function Xmt(e){mc.currentContextTokens=e}function egt(){return mc.currentContextTokens}Pe();Le();Le();var kIe="2.6.9";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 ME}from"crypto";Ns();Pe();er();br();Pe();Le();import{existsSync as w_,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 T_(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 Ac=(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;Ac.sep=gsn;var Jc=Symbol("globstar **");Ac.GLOBSTAR=Jc;var Asn="[^/]",hsn=Asn+"*?",Esn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",_sn="(?:(?!(?:\\/|^)\\.).)*?",ysn=(e,t={})=>r=>Ac(r,e,t);Ac.filter=ysn;var xm=(e,t={})=>Object.assign({},e,t),bsn=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return Ac;let t=Ac;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})};Ac.defaults=bsn;var Pht=(e,t={})=>(Z5(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Tht(e,{max:t.braceExpandMax}));Ac.braceExpand=Pht;var Csn=(e,t={})=>new V2(e,t).makeRe();Ac.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};Ac.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 Ac.defaults(t).Minimatch}};Ac.AST=qv;Ac.Minimatch=V2;Ac.escape=nTe;Ac.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 Ac(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:m0(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 P_=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,P_.useContext)(Gve),{styles:r,config:n}=Ao("UnorderedList"),i=(0,P_.useMemo)(()=>({depth:t+1}),[t]),o=(0,P_.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 P_.default.createElement(Gve.Provider,{value:i},P_.default.createElement(fee.Provider,{value:o},P_.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,L_=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(!L_)return;let e=Wve(L_);gx&&e.columns===gx.columns&&e.rows===gx.rows||(gx=e,_ee.forEach(t=>t(gx)))}function cfn(e,t){return L_!==e&&(L_&&L_.off("resize",Vve),L_=e,gx=Wve(e),e.on("resize",Vve)),_ee.add(t),()=>{_ee.delete(t),_ee.size===0&&L_&&(L_.off("resize",Vve),L_=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.7",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(K0,".update.lock"),ugn=300*1e3;function _St(){try{if(K9(K0)||gSt(K0,{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 P_=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,P_.useContext)(Gve),{styles:r,config:n}=Ao("UnorderedList"),i=(0,P_.useMemo)(()=>({depth:t+1}),[t]),o=(0,P_.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 P_.default.createElement(Gve.Provider,{value:i},P_.default.createElement(fee.Provider,{value:o},P_.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,L_=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(!L_)return;let e=Wve(L_);gx&&e.columns===gx.columns&&e.rows===gx.rows||(gx=e,_ee.forEach(t=>t(gx)))}function cfn(e,t){return L_!==e&&(L_&&L_.off("resize",Vve),L_=e,gx=Wve(e),e.on("resize",Vve)),_ee.add(t),()=>{_ee.delete(t),_ee.size===0&&L_&&(L_.off("resize",Vve),L_=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.9",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(K0,".update.lock"),ugn=300*1e3;function _St(){try{if(K9(K0)||gSt(K0,{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=`
|
|
@@ -3042,14 +3042,14 @@ process.on('message', async (msg) => {
|
|
|
3042
3042
|
${t}
|
|
3043
3043
|
}`}br();import{existsSync as n3n,mkdirSync as i3n,readFileSync as o3n,writeFileSync as s3n}from"fs";import{dirname as a3n,join as l3n}from"path";Pe();function Dzt(){return l3n(Re(),".hcode",".codemode-snippets.json")}function ose(){let e=Dzt();if(!n3n(e))return[];try{let t=o3n(e,"utf-8"),r=xd(t);return Array.isArray(r)?r:(J(`Invalid snippets file format at ${e}: expected array`),[])}catch(t){return J(`Failed to read snippets ${e}:`,t),[]}}function c3n(e){let t=Dzt();try{i3n(a3n(t),{recursive:!0}),s3n(t,JSON.stringify(e,null,2),"utf-8")}catch(r){throw J(`Failed to write snippets ${t}:`,r),r}}function Rzt(e){let t=ose(),r=t.findIndex(n=>n.name===e.name);r>=0?t[r]=e:t.push(e),c3n(t)}function Nzt(e){return ose().find(t=>t.name===e)}br();import{existsSync as u3n,mkdirSync as d3n,readFileSync as f3n,writeFileSync as p3n}from"fs";import{homedir as m3n}from"os";import{dirname as g3n,join as Bzt}from"path";Pe();function Ozt(e){return{userPath:e?.userPath??Bzt(m3n(),".hcode","codemode-output-schemas.json"),projectPath:e?.projectPath??Bzt(Re(),".hcode","codemode-output-schemas.json"),globalConfig:oM(e?.globalConfigPath??Yx)??{},projectConfig:oM(e?.projectConfigPath??Vx)??{}}}function A3n(e,t){let r=e.split(".")[0];return r in t.projectConfig?t.projectPath:r in t.globalConfig?t.userPath:t.projectPath}function OLe(e){if(!u3n(e))return[];try{let t=f3n(e,"utf-8"),r=xd(t);return Array.isArray(r)?r:(J(`Invalid output schemas file format at ${e}: expected array`),[])}catch(t){return J(`Failed to read output schemas ${e}:`,t),[]}}function h3n(e,t){try{d3n(g3n(e),{recursive:!0}),p3n(e,JSON.stringify(t,null,2),"utf-8")}catch(r){throw J(`Failed to write output schemas ${e}:`,r),r}}function kzt(e){let t=Ozt(e),r=new Map;for(let n of OLe(t.userPath))r.set(n.target,n);for(let n of OLe(t.projectPath))r.set(n.target,n);return[...r.values()]}function Mzt(e,t){let r=Ozt(t),n=A3n(e.target,r),i=OLe(n),o=i.findIndex(s=>s.target===e.target);o>=0?i[o]=e:i.push(e),h3n(n,i)}var Qzt=50,sse={path:12,provider:8,method:10,description:5};function Y6(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_./:-]+/g," ").toLowerCase().trim()}var Pzt=typeof Intl.Segmenter=="function"?new Intl.Segmenter("zh",{granularity:"word"}):null;function cse(e){let t=Y6(e);if(t.length===0)return[];if(Pzt){let r=[];for(let{segment:n,isWordLike:i}of Pzt.segment(t)){if(!i)continue;let o=n.trim();o&&r.push(o)}return r}return t.split(/[^a-z0-9]+/).map(r=>r.trim()).filter(Boolean)}function ase(e){return{raw:Y6(e??""),tokens:cse(e??"")}}function lse(e,t,r,n){if(r.raw.length===0)return{score:0,matchedTokens:new Set,exactPhrase:!1};let i=0,o=new Set,s=e.length>0&&r.raw.includes(e);e.length>0&&(r.raw===e?i+=n*14:r.raw.startsWith(e)?i+=n*9:s&&(i+=n*6));for(let a of t)r.tokens.includes(a)?(i+=n*4,o.add(a)):r.tokens.some(l=>l.startsWith(a)||a.startsWith(l))?(i+=n*2,o.add(a)):r.raw.includes(a)&&(i+=n,o.add(a));return{score:i,matchedTokens:o,exactPhrase:s}}function E3n(e,t){let r=Y6(t),n=cse(t);if(r.length===0||n.length===0)return null;let i=[lse(r,n,ase(e.path),sse.path),lse(r,n,ase(e.provider),sse.provider),lse(r,n,ase(e.method),sse.method),lse(r,n,ase(e.description),sse.description)],o=new Set,s=0,a=!1;for(let g of i){s+=g.score,a||=g.exactPhrase;for(let m of g.matchedTokens)o.add(m)}if(o.size===0)return null;let l=o.size/n.length,c=n.length<=2?1:.6;if(l<c&&!a)return null;l===1?s+=25:s+=Math.round(l*10);let u=cse(e.path),d=cse(e.method);return(u[0]===n[0]||d[0]===n[0])&&(s+=8),(Y6(e.path)===r||Y6(e.method)===r)&&(s+=20),{path:e.path,provider:e.provider,method:e.method,description:e.description,...e.requiresApproval?{requiresApproval:!0}:{},kind:e.kind,score:s}}function Lzt(e,t,r,n=[]){let i=e.query,o=[];for(let d of t){let g=d.provider??n.find(h=>d.name.startsWith(`cm_${kl(h)}_`));if(!g)continue;let m=d.name.slice(`cm_${kl(g)}_`.length),A=d.description??"";o.push({path:`${g}.${m}`,provider:g,method:m,description:A,kind:"method"})}for(let d of r)o.push({path:`snippet.${d.name}`,provider:"snippet",method:d.name,description:d.description,kind:"snippet"});let s=e.provider?.trim(),l=(s?o.filter(d=>d.provider===s):o).map(d=>E3n(d,i)).filter(d=>d!==null).sort((d,g)=>g.score-d.score||d.path.localeCompare(g.path)),c=l.length;return{results:l.slice(0,Qzt),total:c,truncated:c>Qzt}}function V6(e){return e.replace(/\*\//g,"* /").replace(/\r?\n/g," ")}function _3n(){return typeof process<"u"&&process.env?.HAWA_CODE_JSDOC==="true"}function y3n(e){let t={};if(e&&typeof e=="object"&&e.properties)for(let[r,n]of Object.entries(e.properties))n&&typeof n=="object"&&n.description&&(t[r]=n.description);return t}function bA(e,t){return e==null?"unknown":Array.isArray(e.type)?e.type.map(r=>Fzt(r,e,t)).join(" | "):Fzt(e.type,e,t)}function Fzt(e,t,r){switch(e){case"string":return t.enum?t.enum.map(n=>JSON.stringify(n)).join(" | "):"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"array":return`Array<${bA(t.items,r)}>`;case"object":{let n=["{"],i=t.properties??{},o=new Set(t.required??[]);for(let[s,a]of Object.entries(i)){let l=o.has(s)?"":"?",c=bA(a,`${r} `),u=[];typeof a=="object"&&a?.description&&u.push(V6(a.description)),typeof a=="object"&&a&&(a.minimum!==void 0&&u.push(`Minimum: ${a.minimum}`),a.maximum!==void 0&&u.push(`Maximum: ${a.maximum}`),a.minLength!==void 0&&u.push(`Min length: ${a.minLength}`),a.maxLength!==void 0&&u.push(`Max length: ${a.maxLength}`),a.default!==void 0&&u.push(`Default: ${JSON.stringify(a.default)}`)),u.length>0&&n.push(`${r} /** ${u.join(" ")} */`),n.push(`${r} ${s}${l}: ${c};`)}return t.additionalProperties&&n.push(`${r} [key: string]: unknown;`),n.push(`${r}}`),n.join(`
|
|
3044
3044
|
`)}case"null":return"null";default:return"unknown"}}function kLe(e,t="codemode"){let r=[`declare const ${t}: {`];for(let[n,i]of Object.entries(e)){let o=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(n)?n:`'${n}'`,s=bA(i.inputSchema," "),a=i.outputSchema?bA(i.outputSchema," "):"unknown",l=[];if(i.description?.trim()&&l.push(V6(i.description.trim())),_3n()){let c=y3n(i.inputSchema);for(let[u,d]of Object.entries(c))l.push(V6(`@param input.${u} - ${d}`))}else l.push(V6("@param input - Input parameters."));if(i.outputSchema?.description&&l.push(V6(`@returns ${i.outputSchema.description}`)),l.length>0){r.push(" /**");for(let c of l)r.push(` * ${c}`);r.push(" */")}r.push(` ${o}(input: ${s}): Promise<${a}>;`)}return r.push("};"),r.join(`
|
|
3045
|
-
`)}function Uzt(e,t){return e.outputSchema!==void 0?e.outputSchema:t?.outputSchema}function Hzt(e,t){return`\u26A0\uFE0F No outputSchema declared for "${e}.${t}" (return type is unknown). If the outputSchema can be inferred from the execution result, call saveOutputSchema promptly so that subsequent queries can provide an outputSchema`}var use={search:{description:'Search methods and snippets by intent. The "Available providers & methods" section lists at most {{METHODS_MAX}} methods per provider \u2014 use codemode.search to discover any method not shown.',inputSchema:{type:"object",properties:{query:{type:"string",description:"Short intent phrase to search for"},provider:{type:"string",description:'Optional provider name to scope the search, e.g. "github"; use "snippet" to search only snippets'}},required:["query"]},outputSchema:{type:"object",description:"Search output with ranked matches and truncation info",properties:{results:{type:"array",description:"Matching methods and snippets, best matches first",items:{type:"object",properties:{path:{type:"string",description:'Method or snippet path, e.g. "provider.method" or "snippet.<name>"'},provider:{type:"string",description:'Provider name, e.g. "github"'},method:{type:"string",description:'Method name, e.g. "list_commits"'},description:{type:"string",description:"What the method or snippet does"},requiresApproval:{type:"boolean",description:"Whether calling this method requires user approval"},kind:{type:"string",enum:["method","snippet"],description:'Result kind: "method" or "snippet"'},score:{type:"number",description:"Relevance score, higher is better"}},required:["path","provider","method","kind","score"]}},total:{type:"number",description:"Total number of matches before truncation"},truncated:{type:"boolean",description:"Whether results were truncated to the result limit"}},required:["results","total","truncated"]}},describe:{description:"Get docs, input and output structure of a method.",inputSchema:{type:"object",properties:{target:{type:"string",description:'e.g. "provider.method", "provider", "snippet.<name>"'}},required:["target"]},outputSchema:{type:"object",properties:{path:{type:"string",description:'The resolved target path, e.g. "provider.method"'},description:{type:"string",description:"Documentation for the target"},types:{type:"string",description:"Generated TypeScript declaration for the target"},kind:{type:"string",enum:["method","snippet","provider"],description:"What kind of target was described"}},required:["path","types","kind"]}},saveSnippet:{description:"Save a snippet for reuse.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Snippet name"},code:{type:"string",description:"Snippet code (async arrow function body)"},description:{type:"string",description:"What the snippet does"},inputSchema:{type:"object",description:"Optional JSON Schema of the snippet input. Saved with the snippet and used by describe to generate a concrete input type."},outputSchema:{type:"object",description:"Optional JSON Schema of the snippet output. Saved with the snippet and used by describe to generate a concrete return type."}},required:["name","code","description"]},outputSchema:{type:"object",properties:{saved:{type:"boolean",description:"Whether the snippet was saved successfully"},name:{type:"string",description:"The name of the saved snippet"}},required:["saved","name"]}},saveOutputSchema:{description:"Save an inferred output schema",inputSchema:{type:"object",properties:{target:{type:"string",description:'Target in the form "provider.method"'},outputSchema:{type:"object",description:"Output JSON Schema"},description:{type:"string",description:"Optional note about the output structure"}},required:["target","outputSchema"]},outputSchema:{type:"object",properties:{saved:{type:"boolean",description:"Whether the output schema was saved successfully"},target:{type:"string",description:'The target the schema was saved for, in the form "provider.method"'}},required:["saved","target"]}}};function $zt(e){return e.replace(/\*\//g,"* /").replace(/\r?\n/g," ")}function MLe(e){let t=["declare const codemode: {"];for(let r of e){if(r==="snippet"){t.push(" /** Call a saved snippet by name. */"),t.push(" snippet: {"),t.push(" [name: string]: (input?: unknown) => Promise<unknown>;"),t.push(" };");continue}let n=use[r],i=n.inputSchema.properties??{},o=new Set(n.inputSchema.required??[]),s=Object.entries(i).map(([d,g])=>{let m=o.has(d)?"":"?";return`${d}${m}: ${bA(g," ")}`}),a=r==="search",l=a?`options: { ${s.join("; ")} }`:s.join(", "),c=n.outputSchema?bA(n.outputSchema," "):"unknown",u=[];n.description&&u.push($zt(n.description));for(let[d,g]of Object.entries(i)){let m=g.description;if(m){let A=a?`options.${d}`:d;u.push(`@param ${A} - ${$zt(m)}`)}}if(u.length===1)t.push(` /** ${u[0]} */`);else if(u.length>1){t.push(" /**");for(let d of u)t.push(` * ${d}`);t.push(" */")}t.push(` ${r}(${l}): Promise<${c}>;`)}return t.push("};"),t.join(`
|
|
3045
|
+
`)}function Uzt(e,t){return e.outputSchema!==void 0?e.outputSchema:t?.outputSchema}function Hzt(e,t){return`\u26A0\uFE0F No outputSchema declared for "${e}.${t}" (return type is unknown). 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`}var use={search:{description:'Search methods and snippets by intent. The "Available providers & methods" section lists at most {{METHODS_MAX}} methods per provider \u2014 use codemode.search to discover any method not shown.',inputSchema:{type:"object",properties:{query:{type:"string",description:"Short intent phrase to search for"},provider:{type:"string",description:'Optional provider name to scope the search, e.g. "github"; use "snippet" to search only snippets'}},required:["query"]},outputSchema:{type:"object",description:"Search output with ranked matches and truncation info",properties:{results:{type:"array",description:"Matching methods and snippets, best matches first",items:{type:"object",properties:{path:{type:"string",description:'Method or snippet path, e.g. "provider.method" or "snippet.<name>"'},provider:{type:"string",description:'Provider name, e.g. "github"'},method:{type:"string",description:'Method name, e.g. "list_commits"'},description:{type:"string",description:"What the method or snippet does"},requiresApproval:{type:"boolean",description:"Whether calling this method requires user approval"},kind:{type:"string",enum:["method","snippet"],description:'Result kind: "method" or "snippet"'},score:{type:"number",description:"Relevance score, higher is better"}},required:["path","provider","method","kind","score"]}},total:{type:"number",description:"Total number of matches before truncation"},truncated:{type:"boolean",description:"Whether results were truncated to the result limit"}},required:["results","total","truncated"]}},describe:{description:"Get docs, input and output structure of a method.",inputSchema:{type:"object",properties:{target:{type:"string",description:'e.g. "provider.method", "provider", "snippet.<name>"'}},required:["target"]},outputSchema:{type:"object",properties:{path:{type:"string",description:'The resolved target path, e.g. "provider.method"'},description:{type:"string",description:"Documentation for the target"},types:{type:"string",description:"Generated TypeScript declaration for the target"},kind:{type:"string",enum:["method","snippet","provider"],description:"What kind of target was described"}},required:["path","types","kind"]}},saveSnippet:{description:"Save a snippet for reuse.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Snippet name"},code:{type:"string",description:"Snippet code (async arrow function body)"},description:{type:"string",description:"What the snippet does"},inputSchema:{type:"object",description:"Optional JSON Schema of the snippet input. Saved with the snippet and used by describe to generate a concrete input type."},outputSchema:{type:"object",description:"Optional JSON Schema of the snippet output. Saved with the snippet and used by describe to generate a concrete return type."}},required:["name","code","description"]},outputSchema:{type:"object",properties:{saved:{type:"boolean",description:"Whether the snippet was saved successfully"},name:{type:"string",description:"The name of the saved snippet"}},required:["saved","name"]}},saveOutputSchema:{description:"Save an inferred output schema",inputSchema:{type:"object",properties:{target:{type:"string",description:'Target in the form "provider.method"'},outputSchema:{type:"object",description:"Output JSON Schema"},description:{type:"string",description:"Optional note about the output structure"}},required:["target","outputSchema"]},outputSchema:{type:"object",properties:{saved:{type:"boolean",description:"Whether the output schema was saved successfully"},target:{type:"string",description:'The target the schema was saved for, in the form "provider.method"'}},required:["saved","target"]}}};function $zt(e){return e.replace(/\*\//g,"* /").replace(/\r?\n/g," ")}function MLe(e){let t=["declare const codemode: {"];for(let r of e){if(r==="snippet"){t.push(" /** Call a saved snippet by name. */"),t.push(" snippet: {"),t.push(" [name: string]: (input?: unknown) => Promise<unknown>;"),t.push(" };");continue}let n=use[r],i=n.inputSchema.properties??{},o=new Set(n.inputSchema.required??[]),s=Object.entries(i).map(([d,g])=>{let m=o.has(d)?"":"?";return`${d}${m}: ${bA(g," ")}`}),a=r==="search",l=a?`options: { ${s.join("; ")} }`:s.join(", "),c=n.outputSchema?bA(n.outputSchema," "):"unknown",u=[];n.description&&u.push($zt(n.description));for(let[d,g]of Object.entries(i)){let m=g.description;if(m){let A=a?`options.${d}`:d;u.push(`@param ${A} - ${$zt(m)}`)}}if(u.length===1)t.push(` /** ${u[0]} */`);else if(u.length>1){t.push(" /**");for(let d of u)t.push(` * ${d}`);t.push(" */")}t.push(` ${r}(${l}): Promise<${c}>;`)}return t.push("};"),t.join(`
|
|
3046
3046
|
`)}function qzt(e){return MLe([...Object.keys(use),"snippet"]).replace(/\{\{METHODS_MAX\}\}/g,String(e))}function b3n(e){let t=e.inputSchema?bA(e.inputSchema," "):"unknown",r=e.outputSchema?bA(e.outputSchema," "):"unknown",n=e.inputSchema?"":"?";return["declare const codemode: {"," snippet: {",` ${e.name}(input${n}: ${t}): Promise<${r}>;`," };","};"].join(`
|
|
3047
3047
|
`)}function Gzt(e,t,r,n=[]){let[i,o]=e.includes(".")?e.split(".",2):[e,void 0];if(i==="snippet"){let d=e.slice(8),g=d?r.find(m=>m.name===d):void 0;return g?{path:g.name,description:g.description,types:b3n(g),kind:"snippet"}:{path:e,description:void 0,types:`"${e}" not found.`,kind:"snippet"}}if(i==="codemode"){if(o===void 0)return{path:"codemode",description:"Codemode meta functions (search / describe / saveSnippet / saveOutputSchema / snippet.<name>).",types:MLe(Object.keys(use)),kind:"provider"};if(o==="snippet")return{path:"codemode.snippet",description:'Run a saved snippet by name: `codemode.snippet.<name>(input)`. The snippet code is executed as an async arrow function; declare `async (input) => {...}` to receive the input. Snippets without a parameter simply ignore it. Use `codemode.describe("snippet.<name>")` to inspect a snippet.',types:["declare const codemode: {"," snippet: {"," [name: string]: (input?: unknown) => Promise<unknown>;"," };","};"].join(`
|
|
3048
3048
|
`),kind:"method"};let d=use[o];if(d)return{path:`codemode.${o}`,description:d.description,types:MLe([o]),kind:"method"}}let s=kl(i),a=t.filter(d=>d.provider?d.provider===i||kl(d.provider)===s:d.name.startsWith(`cm_${s}_`)),l=new Map(n.map(d=>[d.target,d]));if(o===void 0&&a.length>0){let d={};for(let g of a){let m=`cm_${s}_`,A=g.name.slice(m.length),h=Uzt(g,l.get(`${i}.${A}`)),_=h?g.description||void 0:[g.description,Hzt(i,A)].filter(Boolean).join(`
|
|
3049
3049
|
|
|
3050
3050
|
`);d[kl(A)]={description:_,inputSchema:g.inputSchema??{type:"object"},outputSchema:h}}return{path:i,description:`Provider ${i}`,types:kLe(d,s),kind:"provider"}}let c=o?kl(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=kl(m),h=Uzt(d,l.get(`${i}.${m}`)),_=h?d.description??"":[d.description,Hzt(i,m)].filter(Boolean).join(`
|
|
3051
3051
|
|
|
3052
|
-
`);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 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=gE(),t=Object.keys(e);if(t.length===0)return"No providers configured. You can still write plain JavaScript.";let[r,n]=await Promise.all([AE().catch(()=>[]),m1().catch(()=>[])]),i={},o={};for(let s of t)i[s]=[];for(let s of r)s.type==="connected"&&(o[s.name]=s.instructions);for(let s of n){let a=s.provider??t.find(c=>s.name.startsWith(`cm_${kl(c)}_`));if(!a||i[a]===void 0)continue;let l=s.name.slice(`cm_${kl(a)}_`.length);i[a].includes(l)||i[a].push(l)}return t.map(s=>{let a=i[s],l=o[s]?.replace(/\r\n/g,`
|
|
3052
|
+
`);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=gE(),t=Object.keys(e);if(t.length===0)return"No providers configured. You can still write plain JavaScript.";let[r,n]=await Promise.all([AE().catch(()=>[]),m1().catch(()=>[])]),i={},o={};for(let s of t)i[s]=[];for(let s of r)s.type==="connected"&&(o[s.name]=s.instructions);for(let s of n){let a=s.provider??t.find(c=>s.name.startsWith(`cm_${kl(c)}_`));if(!a||i[a]===void 0)continue;let l=s.name.slice(`cm_${kl(a)}_`.length);i[a].includes(l)||i[a].push(l)}return t.map(s=>{let a=i[s],l=o[s]?.replace(/\r\n/g,`
|
|
3053
3053
|
`).replace(/\n+/g,"\\n").trim(),c=Yzt(),u=a.slice(0,c),d=a.length-u.length,g=`### ${s}\uFF08${a.length} methods, showing ${u.length}\uFF09`,m=zzt(l??"(none)",I3n),A=u.length>0?u.join(`
|
|
3054
3054
|
`)+(d>0?`
|
|
3055
3055
|
(... ${d} more methods)`:""):"(no methods available)";return`${g}
|