@dahawa/hawa-code 2.4.35 → 2.4.37
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 +3 -3
- package/hands.js +3 -3
- package/package.json +1 -2
package/cli.js
CHANGED
|
@@ -686,7 +686,7 @@ globstar while`,e,d,t,p,f),this.matchOne(e.slice(d),t.slice(p),r))return this.de
|
|
|
686
686
|
`)),k8n(e,o,{encoding:r,flush:!0})}var wqt=new Zde.default({fetchMethod:e=>H8n(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});async function Fqt(e){let t=WY(e);return wqt.get(t)||wqt.fetchMethod?.(t)}async function H8n(e){let t=new AbortController;setTimeout(()=>{t.abort()},1e3);let r=await LLt(e,t.signal,15),n=0;for(let o of r)GM(o)==="CRLF"&&n++;return n>3?"CRLF":"LF"}function Qqt(e,t,r){if(e.has(t))return e.get(t);let n=r();return e.set(t,n),n}var q8n=new Zde.default({fetchMethod:e=>Gqt(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});function ag(e){let t=WY(e);return Qqt(q8n,t,()=>Gqt(t))}function Gqt(e){let r=Buffer.alloc(4096),n;try{n=Dqt(e,"r");let o=Mqt(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&&Bqt(n)}}var $8n=new Zde.default({fetchMethod:e=>Hqt(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});function GM(e){let t=WY(e);return Qqt($8n,t,()=>Hqt(t))}function Hqt(e,t="utf8"){try{if(!kqt(e).isFile())return"LF";let n=Buffer.alloc(4096),o=Dqt(e,"r"),i=Mqt(o,n,0,4096,0);Bqt(o);let s=n.toString(t,0,i),a=0,c=0;for(let l=0;l<s.length;l++)s[l]===`
|
|
687
687
|
`&&(l>0&&s[l-1]==="\r"?a++:c++);return a>c?"CRLF":"LF"}catch(r){return be(`Error detecting line endings for file ${e}: ${r}`),"LF"}}function gG(e){let t=Pqt(e)?e:WY(Pe(),e);return t.endsWith(" AM.png")?t.replace(" AM.png","\u202FAM.png"):t.endsWith(" PM.png")?t.replace(" PM.png","\u202FPM.png"):t}function E2e(e){return e?Pqt(e)?e:WY(Pe(),e):void 0}function qqt(e){try{let t=E2e(e),r=t?F8n(Pe(),t):void 0;return{absolutePath:t,relativePath:r}}catch(t){return ne("getAbsoluteAndRelativePaths error ",t),{absolutePath:null,relativePath:null}}}function epe(e){try{let t=Q8n(e),r=Nqt(e,xqt(e));if(!P8n(t))return;let i=L8n(t).filter(s=>Nqt(s,xqt(s))===r&&G8n(t,s)!==e)[0];return i||void 0}catch(t){be(`Error finding similar file for ${e}: ${t}`);return}}function S2e(){let e=process.env.HAWA_CODE_COMPACT_LINE_PREFIX;return!(e==="0"||e==="false")}function bx({content:e,startLine:t}){if(!e)return"";let r=e.split(/\r?\n/);return S2e()?r.map((n,o)=>`${o+t} ${n}`).join(`
|
|
688
688
|
`):r.map((n,o)=>{let i=String(o+t);return i.length>=6?`${i}\u2192${n}`:`${i.padStart(6," ")}\u2192${n}`}).join(`
|
|
689
|
-
`)}function $qt(e){try{let t=U8n(e),r=t.readSync();return t.closeSync(),r===null}catch(t){return be(`Error checking directory: ${t}`),!1}}qe();function Ex(){let e=Jn();e.hasCompletedProjectOnboarding||zi({...e,hasCompletedProjectOnboarding:!0})}function W8n(){let e=vr();Do({...e,lastReleaseNotesSeen:MACRO.VERSION})}function T2e({workspaceDir:e}){let r=!Jn().hasCompletedProjectOnboarding,o=vr().lastReleaseNotesSeen,i=[];(!o||(0,Yqt.gt)(MACRO.VERSION,o))&&(i=Sde[MACRO.VERSION]||[]);let s=i.length>0;if(os.useEffect(()=>{s&&!r&&W8n()},[s,r]),!r&&!s)return null;let a=Y8n(V8n(e,Di)),c=$qt(e),l=!a&&!c,u=sG.isEnabled&&!vr().shiftEnterKeyBindingInstalled,d=re();return os.createElement(v,{flexDirection:"column",gap:1,padding:1,paddingBottom:0},r&&os.createElement(os.Fragment,null,os.createElement(I,{color:d.secondaryText},"Tips for getting started:"),os.createElement(jd,{children:[]},(()=>{let p=[];return c&&p.push(os.createElement(jd.Item,{key:"workspace"},os.createElement(I,{color:d.secondaryText},"Ask ",rt," to create a new app or clone a repository."))),l&&p.push(os.createElement(jd.Item,{key:"claudemd"},os.createElement(I,{color:d.secondaryText},"Run ",os.createElement(I,{color:d.text},"/init")," to create a",Di," file with instructions for Hawa code."))),u&&p.push(os.createElement(jd.Item,{key:"terminal"},os.createElement(I,{color:d.secondaryText},"Run ",os.createElement(I,{color:d.text},"/terminal-setup"),os.createElement(I,{bold:!1}," to set up terminal integration")))),p.push(os.createElement(jd.Item,{key:"questions"},os.createElement(I,{color:d.secondaryText},"Ask ",rt," questions about your codebase."))),p.push(os.createElement(jd.Item,{key:"changes"},os.createElement(I,{color:d.secondaryText},"Ask ",rt," to implement changes to your codebase."))),p})())),!r&&s&&os.createElement(v,{borderColor:re().secondaryBorder,flexDirection:"column",marginRight:1},os.createElement(v,{flexDirection:"column",gap:0},os.createElement(v,{marginBottom:1},os.createElement(I,null,"\u{1F195} What's new in v",MACRO.VERSION,":")),os.createElement(v,{flexDirection:"column",marginLeft:1},i.map((p,f)=>os.createElement(I,{key:f,color:re().secondaryText},"\u2022 ",p))))),e===z8n()&&os.createElement(I,{color:re().warning},"Note: You have launched ",os.createElement(I,{bold:!0},rt)," in your home directory. For the best experience, launch it in a project directory instead."))}var hG=G(ae(),1);var AG=G(ae(),1);var jY=G(ae(),1);function y2e({isFocused:e,isSelected:t,smallPointer:r,children:n}){let{styles:o}=Es("Select");return jY.default.createElement(v,{...o.option({isFocused:e})},e&&jY.default.createElement(I,{...o.focusIndicator()},r?ar.triangleDownSmall:ar.pointer),jY.default.createElement(I,{...o.label({isFocused:e,isSelected:t})},n),t&&jY.default.createElement(I,{...o.selectedIndicator()},ar.tick))}var cg=G(ae(),1);import{isDeepStrictEqual as j8n}from"node:util";var KY=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 c="value"in s?s.value:b2e(s);r.push([c,a]),i++,o=a}super(r),this.first=n}};var K8n=(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}}},C2e=e=>e.flatMap(t=>{if("options"in t){let r=C2e(t.options),n=r.flatMap(i=>"value"in i?i.value:[]);return[...t.header!==void 0?[{header:t.header,optionValues:n}]:[],...r]}return t}),Vqt=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=C2e(r),o=typeof e=="number"?Math.min(e,n.length):n.length,i=new KY(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}},I2e=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n,onFocus:o,focusValue:i})=>{let s=C2e(t),[a,c]=(0,cg.useReducer)(K8n,{visibleOptionCount:e,defaultValue:r,options:t},Vqt),[l,u]=(0,cg.useState)(s);s!==l&&!j8n(s,l)&&(c({type:"reset",state:Vqt({visibleOptionCount:e,defaultValue:r,options:t})}),u(s));let d=(0,cg.useCallback)(()=>{c({type:"focus-next-option"})},[]),p=(0,cg.useCallback)(()=>{c({type:"focus-previous-option"})},[]),f=(0,cg.useCallback)(()=>{c({type:"select-focused-option"})},[]),g=(0,cg.useMemo)(()=>s.map((h,_)=>({...h,index:_})).slice(a.visibleFromIndex,a.visibleToIndex),[s,a.visibleFromIndex,a.visibleToIndex]);return(0,cg.useEffect)(()=>{a.value&&a.previousValue!==a.value&&n?.(a.value)},[a.previousValue,a.value,t,n]),(0,cg.useEffect)(()=>{a.focusedValue&&o?.(a.focusedValue)},[a.focusedValue,o]),(0,cg.useEffect)(()=>{i&&c({type:"set-focus",value:i})},[i]),{focusedValue:a.focusedValue,visibleFromIndex:a.visibleFromIndex,visibleToIndex:a.visibleToIndex,value:a.value,visibleOptions:g,focusNextOption:d,focusPreviousOption:p,selectFocusedOption:f}};var v2e=({isDisabled:e=!1,state:t})=>{gt((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};var b2e=e=>`HEADER-${e.optionValues.join(",")}`;function V0({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a}){let c=I2e({visibleOptionCount:t,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a});v2e({isDisabled:e,state:c});let{styles:l}=Es("Select");return AG.default.createElement(v,{...l.container()},c.visibleOptions.map(u=>{let d="value"in u?u.value:b2e(u),p=!e&&c.focusedValue!==void 0&&("value"in u?c.focusedValue===u.value:u.optionValues.includes(c.focusedValue)),f=!!c.value&&("value"in u?c.value===u.value:u.optionValues.includes(c.value)),g="header"in u,h="label"in u?u.label:u.header,_=h;if(r&&h.includes(r)){let T=h.indexOf(r);_=AG.default.createElement(AG.default.Fragment,null,h.slice(0,T),AG.default.createElement(I,{...l.highlightedText()},r),h.slice(T+r.length))}return AG.default.createElement(y2e,{key:d,isFocused:p,isSelected:f,smallPointer:g},_)}))}function zqt({onDone:e}){return gt((t,r)=>{(r.ctrl&&(t==="c"||t==="d")||r.escape)&&e()}),hG.default.createElement(v,{flexDirection:"column",borderStyle:"round",padding:1,borderColor:re().secondaryBorder},hG.default.createElement(v,{marginBottom:1,flexDirection:"column"},hG.default.createElement(I,{bold:!0},"You've spent $5 this session.")),hG.default.createElement(v,null,hG.default.createElement(V0,{options:[{value:"ok",label:"Got it, thanks!"}],onChange:e})))}var Nn=G(ae(),1),rr=G(ae(),1);var jf=G(ae(),1);qe();fr();Hy();var X8n="2.4.35",qy={VERSION:X8n,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 x2e=46,Kqt=["(\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 tpe({isDefaultModel:e=!1}){let t=Math.max(x2e,Pe().length+12),r=re(),n=Kqt[Math.floor(Math.random()*Kqt.length)];return jf.createElement(v,{flexDirection:"column"},jf.createElement(v,{flexDirection:"column",gap:1,paddingLeft:1,width:"100%"},jf.createElement(I,null,jf.createElement(I,null,n)," Welcome to"," ",jf.createElement(I,{bold:!0},rt),jf.createElement(I,{color:r.secondaryText}," v",qy.VERSION)),jf.createElement(jf.Fragment,null,jf.createElement(v,{paddingLeft:2,flexDirection:"column",gap:1},jf.createElement(I,{color:r.secondaryText,italic:!0},"/help for help"),jf.createElement(I,{color:r.secondaryText},"cwd: ",Pe()),jf.createElement(I,{color:r.secondaryText},"model: ",Mo.getConfig().routing.MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A"),jf.createElement(I,{color:r.secondaryText},"small fast model: ",Mo.getConfig().routing.SMALL_FAST_MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A")))))}var UT=G(ae(),1);De();var _Z=G(ae(),1);import{randomUUID as LE}from"crypto";Js();De();nr();fr();De();qe();import{existsSync as j0,readdirSync as Njn,statSync as xjn}from"fs";import{join as Nx,relative as Ojn}from"path";import{homedir as q8t}from"os";import{platform as wjn}from"process";import{readFile as xx}from"fs/promises";fr();k_();br();import{join as iYn,sep as sYn}from"path";function Kf(){if(!lg())return!1;try{let e=it();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function ug(){return(iYn(Pe(),".hcode","team-memory")+sYn).normalize("NFC")}function P_(e){let t=e.normalize("NFC"),r=ug();return t.startsWith(r)}var $8t=G(iV(),1);ci();var z2e=(e,t,r)=>{let n=e instanceof RegExp?h8t(e,r):e,o=t instanceof RegExp?h8t(t,r):t,i=n!==null&&o!=null&&_Wn(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)}},h8t=(e,t)=>{let r=t.match(e);return r?r[0]:null},_Wn=(e,t,r)=>{let n,o,i,s,a,c=r.indexOf(e),l=r.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(n=[],i=r.length;u>=0&&!a;){if(u===c)n.push(u),c=r.indexOf(e,u+1);else if(n.length===1){let d=n.pop();d!==void 0&&(a=[d,l])}else o=n.pop(),o!==void 0&&o<i&&(i=o,s=l),l=r.indexOf(t,u+1);u=c<l&&c>=0?c:l}n.length&&s!==void 0&&(a=[i,s])}return a};var _8t="\0SLASH"+Math.random()+"\0",E8t="\0OPEN"+Math.random()+"\0",K2e="\0CLOSE"+Math.random()+"\0",S8t="\0COMMA"+Math.random()+"\0",T8t="\0PERIOD"+Math.random()+"\0",EWn=new RegExp(_8t,"g"),SWn=new RegExp(E8t,"g"),TWn=new RegExp(K2e,"g"),yWn=new RegExp(S8t,"g"),bWn=new RegExp(T8t,"g"),CWn=/\\\\/g,IWn=/\\{/g,vWn=/\\}/g,RWn=/\\,/g,NWn=/\\\./g,xWn=1e5,OWn=4e6;function W2e(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function wWn(e){return e.replace(CWn,_8t).replace(IWn,E8t).replace(vWn,K2e).replace(RWn,S8t).replace(NWn,T8t)}function DWn(e){return e.replace(EWn,"\\").replace(SWn,"{").replace(TWn,"}").replace(yWn,",").replace(bWn,".")}function y8t(e){if(!e)return[""];let t=[],r=z2e("{","}",e);if(!r)return e.split(",");let{pre:n,body:o,post:i}=r,s=n.split(",");s[s.length-1]+="{"+o+"}";let a=y8t(i);return i.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function b8t(e,t={}){if(!e)return[];let{max:r=xWn,maxLength:n=OWn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),j2e(wWn(e),r,n,!0).map(DWn)}function MWn(e){return"{"+e+"}"}function BWn(e){return/^-?0\d/.test(e)}function kWn(e,t){return e<=t}function PWn(e,t){return e>=t}function sV(e,t,r,n,o,i){let s=[],a=0;for(let c=0;c<e.length;c++)for(let l=0;l<r.length;l++){if(s.length>=n)return s;let u=e[c]+t+r[l];if(!(i&&!u)){if(a+u.length>o)return s;s.push(u),a+=u.length}}return s}function LWn(e,t,r,n){let o=e.split(/\.\./),i=[];if(o[0]===void 0||o[1]===void 0)return i;let s=W2e(o[0]),a=W2e(o[1]),c=Math.max(o[0].length,o[1].length),l=o.length===3&&o[2]!==void 0?Math.max(Math.abs(W2e(o[2])),1):1,u=kWn;a<s&&(l*=-1,u=PWn);let p=o.some(BWn),f=0;for(let g=s;u(g,a)&&i.length<r;g+=l){let h;if(t)h=String.fromCharCode(g),h==="\\"&&(h="");else if(h=String(g),p){let _=c-h.length;if(_>0){let T=new Array(_+1).join("0");g<0?h="-"+T+h.slice(1):h=T+h}}if(f+h.length>n)break;i.push(h),f+=h.length}return i}function j2e(e,t,r,n){let o=[""],i=!1,s=!0;for(;;){let a=z2e("{","}",e);if(!a)return sV(o,e,[""],t,r,i);let c=a.pre;if(/\$$/.test(c)){if(o=sV(o,c+"{"+a.body+"}",[""],t,r,i&&!a.post.length),s=!1,!a.post.length)break;e=a.post;continue}let l=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),d=l||u,p=a.body.indexOf(",")>=0;if(!d&&!p){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+K2e+a.post,n=!0;continue}return sV(o,c+"{"+a.body+"}"+a.post,[""],t,r,i)}s&&(i=n&&!d,s=!1);let f;if(d)f=LWn(a.body,u,t,r);else{let g=y8t(a.body);if(g.length===1&&g[0]!==void 0&&(g=j2e(g[0],t,r,!1).map(MWn),g.length===1)){if(o=sV(o,c+g[0],[""],t,r,i&&!a.post.length),!a.post.length)break;e=a.post;continue}let h=i&&!a.post.length&&!c;for(let T=0;h&&T<o.length;T++)o[T]&&(h=!1);f=[];let _=0;e:for(let T=0;T<g.length;T++){let y=j2e(g[T],t,r,!1);for(let C=0;C<y.length;C++){let R=y[C];if(!(h&&!R)){if(f.length>=t||_+R.length>r)break e;f.push(R),_+=R.length}}}}if(o=sV(o,c,f,t,r,i&&!a.post.length),!a.post.length)break;e=a.post}return o}var aV=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var UWn={"[: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]},cV=e=>e.replace(/[[\]\\-]/g,"\\$&"),FWn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),C8t=e=>e.join(""),I8t=(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,c=!1,l=!1,u=r,d="";e:for(;i<e.length;){let h=e.charAt(i);if((h==="!"||h==="^")&&i===r+1){l=!0,i++;continue}if(h==="]"&&s&&!c){u=i+1;break}if(s=!0,h==="\\"&&!c){c=!0,i++;continue}if(h==="["&&!c){for(let[_,[T,y,C]]of Object.entries(UWn))if(e.startsWith(_,i)){if(d)return["$.",!1,e.length-r,!0];i+=_.length,C?o.push(T):n.push(T),a=a||y;continue e}}if(c=!1,d){h>d?n.push(cV(d)+"-"+cV(h)):h===d&&n.push(cV(h)),d="",i++;continue}if(e.startsWith("-]",i+1)){n.push(cV(h+"-")),i+=2;continue}if(e.startsWith("-",i+1)){d=h,i+=2;continue}n.push(cV(h)),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])&&!l){let h=n[0].length===2?n[0].slice(-1):n[0];return[FWn(h),!1,u-r,!1]}let p="["+(l?"^":"")+C8t(n)+"]",f="["+(l?"":"^")+C8t(o)+"]";return[n.length&&o.length?"("+p+"|"+f+")":n.length?p:f,a,u-r,!0]};var Rx=(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 pg,QWn=new Set(["!","?","+","*","@"]),J2e=e=>QWn.has(e),v8t=e=>J2e(e.type),GWn=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),HWn=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),qWn=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),R8t=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),$Wn="(?!(?:^|/)\\.\\.?(?:$|/))",fpe="(?!\\.)",YWn=new Set(["[","."]),VWn=new Set(["..","."]),zWn=new Set("().*{}+?[]^$\\!"),WWn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Z2e="[^/]",N8t=Z2e+"*?",x8t=Z2e+"+?",jWn=0,jM=class{type;#e;#t;#n=!1;#r=[];#o;#i;#c;#a=!1;#s;#d;#f=!1;id=++jWn;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.#s=this.#e===this?n:this.#e.#s,this.#c=this.#e===this?[]:this.#e.#c,t==="!"&&!this.#e.#a&&this.#c.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("")}#p(){if(this!==this.#e)throw new Error("should only call on root");if(this.#a)return this;this.toString(),this.#a=!0;let t;for(;t=this.#c.pop();){if(t.type!=="!")continue;let r=t,n=r.#o;for(;n;){for(let o=r.#i+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.#o}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof pg&&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.#a&&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 pg&&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 pg(this.type,t);for(let n of this.#r)r.copyIn(n);return r}static#l(t,r,n,o,i){let s=o.maxExtglobRecursion??2,a=!1,c=!1,l=-1,u=!1;if(r.type===null){let h=n,_="";for(;h<t.length;){let T=t.charAt(h++);if(a||T==="\\"){a=!a,_+=T;continue}if(c){h===l+1?(T==="^"||T==="!")&&(u=!0):T==="]"&&!(h===l+2&&u)&&(c=!1),_+=T;continue}else if(T==="["){c=!0,l=h,u=!1,_+=T;continue}if(!o.noext&&J2e(T)&&t.charAt(h)==="("&&i<=s){r.push(_),_="";let C=new pg(T,r);h=pg.#l(t,C,h,o,i+1),r.push(C);continue}_+=T}return r.push(_),h}let d=n+1,p=new pg(null,r),f=[],g="";for(;d<t.length;){let h=t.charAt(d++);if(a||h==="\\"){a=!a,g+=h;continue}if(c){d===l+1?(h==="^"||h==="!")&&(u=!0):h==="]"&&!(d===l+2&&u)&&(c=!1),g+=h;continue}else if(h==="["){c=!0,l=d,u=!1,g+=h;continue}if(!o.noext&&J2e(h)&&t.charAt(d)==="("&&(i<=s||r&&r.#_(h))){let T=r&&r.#_(h)?0:1;p.push(g),g="";let y=new pg(h,p);p.push(y),d=pg.#l(t,y,d,o,i+T);continue}if(h==="|"){p.push(g),g="",f.push(p),p=new pg(null,r);continue}if(h===")")return g===""&&r.#r.length===0&&(r.#f=!0),p.push(g),g="",r.push(...f,p),d;g+=h}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],d}#m(t){return this.#A(t,HWn)}#A(t,r=GWn){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=qWn){return!!r.get(this.type)?.includes(t)}#h(t,r){let n=t.#r[0],o=new pg(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.#o=this);this.#d=void 0}#S(t){return!!R8t.get(this.type)?.has(t)}#b(t){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let r=t.#r[0];return!r||typeof r!="object"||r.type===null?!1:this.#S(r.type)}#C(t){let r=R8t.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.#o=this);this.type=o,this.#d=void 0,this.#f=!1}static fromGlob(t,r={}){let n=new pg(null,void 0,r);return pg.#l(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.#s.nocase&&!this.#s.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#s.nocase?"i":"")+(i?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#s}toRegExpSource(t){let r=t??!!this.#s.dot;if(this.#e===this&&(this.#E(),this.#p()),!v8t(this)){let c=this.isStart()&&this.isEnd()&&!this.#r.some(f=>typeof f!="string"),l=this.#r.map(f=>{let[g,h,_,T]=typeof f=="string"?pg.#y(f,this.#t,c):f.toRegExpSource(t);return this.#t=this.#t||_,this.#n=this.#n||T,g}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&VWn.has(this.#r[0]))){let g=YWn,h=r&&g.has(l.charAt(0))||l.startsWith("\\.")&&g.has(l.charAt(2))||l.startsWith("\\.\\.")&&g.has(l.charAt(4)),_=!r&&!t&&g.has(l.charAt(0));u=h?$Wn:_?fpe:""}let d="";return this.isEnd()&&this.#e.#a&&this.#o?.type==="!"&&(d="(?:$|\\/)"),[u+l+d,Rx(l),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",o=this.type==="!"?"(?:(?!(?:":"(?:",i=this.#T(r);if(this.isStart()&&this.isEnd()&&!i&&this.type!=="!"){let c=this.toString(),l=this;return l.#r=[c],l.type=null,l.#t=void 0,[c,Rx(this.toString()),!1,!1]}let s=!n||t||r||!fpe?"":this.#T(!0);s===i&&(s=""),s&&(i=`(?:${i})(?:${s})*?`);let a="";if(this.type==="!"&&this.#f)a=(this.isStart()&&!r?fpe:"")+x8t;else{let c=this.type==="!"?"))"+(this.isStart()&&!r&&!t?fpe:"")+N8t+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=o+i+c}return[a,Rx(i),this.#t=!!this.#t,this.#n]}#E(){if(v8t(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.#m(o)?(r=!1,this.#h(o,n)):this.#b(o)&&(r=!1,this.#C(o)))}}while(!r&&++t<10)}else for(let t of this.#r)typeof t=="object"&&t.#E();this.#d=void 0}#T(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 c=0;c<t.length;c++){let l=t.charAt(c);if(o){o=!1,i+=(zWn.has(l)?"\\":"")+l;continue}if(l==="*"){if(a)continue;a=!0,i+=n&&/^[*]+$/.test(t)?x8t:N8t,r=!0;continue}else a=!1;if(l==="\\"){c===t.length-1?i+="\\\\":o=!0;continue}if(l==="["){let[u,d,p,f]=I8t(t,c);if(p){i+=u,s=s||d,c+=p-1,r=r||f;continue}}if(l==="?"){i+=Z2e,r=!0;continue}i+=WWn(l)}return[i,Rx(t),!!r,s]}};pg=jM;var X2e=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var Kd=(e,t,r={})=>(aV(t),!r.nocomment&&t.charAt(0)==="#"?!1:new NG(t,r).match(e)),KWn=/^\*+([^+@!?*[(]*)$/,JWn=e=>t=>!t.startsWith(".")&&t.endsWith(e),ZWn=e=>t=>t.endsWith(e),XWn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),ejn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),tjn=/^\*+\.\*+$/,rjn=e=>!e.startsWith(".")&&e.includes("."),njn=e=>e!=="."&&e!==".."&&e.includes("."),ojn=/^\.\*+$/,ijn=e=>e!=="."&&e!==".."&&e.startsWith("."),sjn=/^\*+$/,ajn=e=>e.length!==0&&!e.startsWith("."),cjn=e=>e.length!==0&&e!=="."&&e!=="..",ljn=/^\?+([^+@!?*[(]*)?$/,ujn=([e,t=""])=>{let r=D8t([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},djn=([e,t=""])=>{let r=M8t([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},pjn=([e,t=""])=>{let r=M8t([e]);return t?n=>r(n)&&n.endsWith(t):r},fjn=([e,t=""])=>{let r=D8t([e]);return t?n=>r(n)&&n.endsWith(t):r},D8t=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},M8t=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},B8t=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",O8t={win32:{sep:"\\"},posix:{sep:"/"}},mjn=B8t==="win32"?O8t.win32.sep:O8t.posix.sep;Kd.sep=mjn;var tf=Symbol("globstar **");Kd.GLOBSTAR=tf;var gjn="[^/]",Ajn=gjn+"*?",hjn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",_jn="(?:(?!(?:\\/|^)\\.).)*?",Ejn=(e,t={})=>r=>Kd(r,e,t);Kd.filter=Ejn;var L_=(e,t={})=>Object.assign({},e,t),Sjn=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return Kd;let t=Kd;return Object.assign((n,o,i={})=>t(n,o,L_(e,i)),{Minimatch:class extends t.Minimatch{constructor(o,i={}){super(o,L_(e,i))}static defaults(o){return t.defaults(L_(e,o)).Minimatch}},AST:class extends t.AST{constructor(o,i,s={}){super(o,i,L_(e,s))}static fromGlob(o,i={}){return t.AST.fromGlob(o,L_(e,i))}},unescape:(n,o={})=>t.unescape(n,L_(e,o)),escape:(n,o={})=>t.escape(n,L_(e,o)),filter:(n,o={})=>t.filter(n,L_(e,o)),defaults:n=>t.defaults(L_(e,n)),makeRe:(n,o={})=>t.makeRe(n,L_(e,o)),braceExpand:(n,o={})=>t.braceExpand(n,L_(e,o)),match:(n,o,i={})=>t.match(n,o,L_(e,i)),sep:t.sep,GLOBSTAR:tf})};Kd.defaults=Sjn;var k8t=(e,t={})=>(aV(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:b8t(e,{max:t.braceExpandMax}));Kd.braceExpand=k8t;var Tjn=(e,t={})=>new NG(e,t).makeRe();Kd.makeRe=Tjn;var yjn=(e,t,r={})=>{let n=new NG(t,r);return e=e.filter(o=>n.match(o)),n.options.nonull&&!e.length&&e.push(t),e};Kd.match=yjn;var w8t=/[?*]|[+@!]\(.*?\)|\[|\]/,bjn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),NG=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){aV(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||B8t,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 c=i[0]===""&&i[1]===""&&(i[2]==="?"||!w8t.test(i[2]))&&!w8t.test(i[3]),l=/^[a-z]:/i.test(i[0]);if(c)return[...i.slice(0,4),...i.slice(4).map(u=>this.parse(u))];if(l)return[i[0],...i.slice(1).map(u=>this.parse(u))]}return i.map(c=>this.parse(c))});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],c=n[o+2],l=n[o+3];if(a!==".."||!c||c==="."||c===".."||!l||l==="."||l==="..")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 c=i===1&&n[i+1]==="**"?["."]:[];n.splice(i-1,2,...c),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]),c=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),l=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),u=!l&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),d=c?3:a?0:void 0,p=u?3:l?0:void 0;if(typeof d=="number"&&typeof p=="number"){let[f,g]=[t[d],r[p]];f.toLowerCase()===g.toLowerCase()&&(r[p]=f,i=p,o=d)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(tf)?this.#e(t,r,n,o,i):this.#n(t,r,n,o,i)}#e(t,r,n,o,i){let s=r.indexOf(tf,i),a=r.lastIndexOf(tf),[c,l,u]=n?[r.slice(i,s),r.slice(s+1),[]]:[r.slice(i,s),r.slice(s+1,a),r.slice(a+1)];if(c.length){let y=t.slice(o,o+c.length);if(!this.#n(y,c,n,0,0))return!1;o+=c.length,i+=c.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(!l.length){let y=!!d;for(let C=o;C<t.length-d;C++){let R=String(t[C]);if(y=!0,R==="."||R===".."||!this.options.dot&&R.startsWith("."))return!1}return n||y}let p=[[[],0]],f=p[0],g=0,h=[0];for(let y of l)y===tf?(h.push(g),f=[[],0],p.push(f)):(f[0].push(y),g++);let _=p.length-1,T=t.length-d;for(let y of p)y[1]=T-(h[_--]+y[0].length);return!!this.#t(t,p,o,0,n,0,!!d)}#t(t,r,n,o,i,s,a){let c=r[o];if(!c){for(let d=n;d<t.length;d++){a=!0;let p=t[d];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1}return a}let[l,u]=c;for(;n<=u;){if(this.#n(t.slice(0,n+l.length),l,i,n,0)&&s<this.maxGlobstarRecursion){let f=this.#t(t,r,n+l.length,o+1,i,s+1,a);if(f!==!1)return f}let p=t[n];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1;n++}return i||null}#n(t,r,n,o,i){let s,a,c,l;for(s=o,a=i,l=t.length,c=r.length;s<l&&a<c;s++,a++){this.debug("matchOne loop");let u=r[a],d=t[s];if(this.debug(r,u,d),u===!1||u===tf)return!1;let p;if(typeof u=="string"?(p=d===u,this.debug("string match",u,d,p)):(p=u.test(d),this.debug("pattern match",u,d,p)),!p)return!1}if(s===l&&a===c)return!0;if(s===l)return n;if(a===c)return s===l-1&&t[s]==="";throw new Error("wtf?")}braceExpand(){return k8t(this.pattern,this.options)}parse(t){aV(t);let r=this.options;if(t==="**")return tf;if(t==="")return"";let n,o=null;(n=t.match(sjn))?o=r.dot?cjn:ajn:(n=t.match(KWn))?o=(r.nocase?r.dot?ejn:XWn:r.dot?ZWn:JWn)(n[1]):(n=t.match(ljn))?o=(r.nocase?r.dot?djn:ujn:r.dot?pjn:fjn)(n):(n=t.match(tjn))?o=r.dot?njn:rjn:(n=t.match(ojn))&&(o=ijn);let i=jM.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?Ajn:r.dot?hjn:_jn,o=new Set(r.nocase?["i"]:[]),i=t.map(c=>{let l=c.map(d=>{if(d instanceof RegExp)for(let p of d.flags.split(""))o.add(p);return typeof d=="string"?bjn(d):d===tf?tf:d._src});l.forEach((d,p)=>{let f=l[p+1],g=l[p-1];d!==tf||g===tf||(g===void 0?f!==void 0&&f!==tf?l[p+1]="(?:\\/|"+n+"\\/)?"+f:l[p]=n:f===void 0?l[p-1]=g+"(?:\\/|\\/"+n+")?":f!==tf&&(l[p-1]=g+"(?:\\/|\\/"+n+"\\/)"+f,l[p+1]=tf))});let u=l.filter(d=>d!==tf);if(this.partial&&u.length>=1){let d=[];for(let p=1;p<=u.length;p++)d.push(u.slice(0,p).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 c=o;if(n.matchBase&&a.length===1&&(c=[s]),this.matchOne(c,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return Kd.defaults(t).Minimatch}};Kd.AST=jM;Kd.Minimatch=NG;Kd.escape=X2e;Kd.unescape=Rx;var U8t=G(iV(),1);fr();qe();De();qf();import{readFile as P8t}from"fs/promises";import{existsSync as eUe,readdirSync as Cjn,statSync as Ijn}from"fs";import{join as tUe,relative as F8t}from"path";import{homedir as vjn}from"os";function L8t(e){try{let t=(0,U8t.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 Rjn(e,t){return t.length===0?!0:t.some(r=>{try{return Kd(e,r,{matchBase:!0,dot:!0})}catch(n){return be(n),!1}})}function rUe(e){let t=[];try{if(!eUe(e))return t;let r=Cjn(e);for(let n of r){let o=tUe(e,n),i=Ijn(o);i.isDirectory()?t.push(...rUe(o)):i.isFile()&&n.endsWith(".md")&&t.push(o)}}catch(r){be(r)}return t}async function mpe(){let e=[];try{let t=tUe(vjn(),Kn,"rules");if(eUe(t)){let r=rUe(t);for(let n of r)try{let o=await P8t(n,"utf-8"),{paths:i,content:s}=L8t(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=tUe(Pe(),Kn,"rules");if(eUe(t)){let r=rUe(t);for(let n of r)try{let o=await P8t(n,"utf-8"),{paths:i,content:s}=L8t(o);i.length>0&&e.push({filePath:F8t(Pe(),n),content:s,paths:i,isProjectRule:!0})}catch(o){be(o)}}}catch(t){be(t)}return e}function Q8t(e,t){e=Qle(e);let r=Qle(Pe()),n=e.startsWith(r)?F8t(r,e):e;return t.filter(o=>Rjn(n,o.paths))}function G8t(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}):
|
|
689
|
+
`)}function $qt(e){try{let t=U8n(e),r=t.readSync();return t.closeSync(),r===null}catch(t){return be(`Error checking directory: ${t}`),!1}}qe();function Ex(){let e=Jn();e.hasCompletedProjectOnboarding||zi({...e,hasCompletedProjectOnboarding:!0})}function W8n(){let e=vr();Do({...e,lastReleaseNotesSeen:MACRO.VERSION})}function T2e({workspaceDir:e}){let r=!Jn().hasCompletedProjectOnboarding,o=vr().lastReleaseNotesSeen,i=[];(!o||(0,Yqt.gt)(MACRO.VERSION,o))&&(i=Sde[MACRO.VERSION]||[]);let s=i.length>0;if(os.useEffect(()=>{s&&!r&&W8n()},[s,r]),!r&&!s)return null;let a=Y8n(V8n(e,Di)),c=$qt(e),l=!a&&!c,u=sG.isEnabled&&!vr().shiftEnterKeyBindingInstalled,d=re();return os.createElement(v,{flexDirection:"column",gap:1,padding:1,paddingBottom:0},r&&os.createElement(os.Fragment,null,os.createElement(I,{color:d.secondaryText},"Tips for getting started:"),os.createElement(jd,{children:[]},(()=>{let p=[];return c&&p.push(os.createElement(jd.Item,{key:"workspace"},os.createElement(I,{color:d.secondaryText},"Ask ",rt," to create a new app or clone a repository."))),l&&p.push(os.createElement(jd.Item,{key:"claudemd"},os.createElement(I,{color:d.secondaryText},"Run ",os.createElement(I,{color:d.text},"/init")," to create a",Di," file with instructions for Hawa code."))),u&&p.push(os.createElement(jd.Item,{key:"terminal"},os.createElement(I,{color:d.secondaryText},"Run ",os.createElement(I,{color:d.text},"/terminal-setup"),os.createElement(I,{bold:!1}," to set up terminal integration")))),p.push(os.createElement(jd.Item,{key:"questions"},os.createElement(I,{color:d.secondaryText},"Ask ",rt," questions about your codebase."))),p.push(os.createElement(jd.Item,{key:"changes"},os.createElement(I,{color:d.secondaryText},"Ask ",rt," to implement changes to your codebase."))),p})())),!r&&s&&os.createElement(v,{borderColor:re().secondaryBorder,flexDirection:"column",marginRight:1},os.createElement(v,{flexDirection:"column",gap:0},os.createElement(v,{marginBottom:1},os.createElement(I,null,"\u{1F195} What's new in v",MACRO.VERSION,":")),os.createElement(v,{flexDirection:"column",marginLeft:1},i.map((p,f)=>os.createElement(I,{key:f,color:re().secondaryText},"\u2022 ",p))))),e===z8n()&&os.createElement(I,{color:re().warning},"Note: You have launched ",os.createElement(I,{bold:!0},rt)," in your home directory. For the best experience, launch it in a project directory instead."))}var hG=G(ae(),1);var AG=G(ae(),1);var jY=G(ae(),1);function y2e({isFocused:e,isSelected:t,smallPointer:r,children:n}){let{styles:o}=Es("Select");return jY.default.createElement(v,{...o.option({isFocused:e})},e&&jY.default.createElement(I,{...o.focusIndicator()},r?ar.triangleDownSmall:ar.pointer),jY.default.createElement(I,{...o.label({isFocused:e,isSelected:t})},n),t&&jY.default.createElement(I,{...o.selectedIndicator()},ar.tick))}var cg=G(ae(),1);import{isDeepStrictEqual as j8n}from"node:util";var KY=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 c="value"in s?s.value:b2e(s);r.push([c,a]),i++,o=a}super(r),this.first=n}};var K8n=(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}}},C2e=e=>e.flatMap(t=>{if("options"in t){let r=C2e(t.options),n=r.flatMap(i=>"value"in i?i.value:[]);return[...t.header!==void 0?[{header:t.header,optionValues:n}]:[],...r]}return t}),Vqt=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=C2e(r),o=typeof e=="number"?Math.min(e,n.length):n.length,i=new KY(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}},I2e=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n,onFocus:o,focusValue:i})=>{let s=C2e(t),[a,c]=(0,cg.useReducer)(K8n,{visibleOptionCount:e,defaultValue:r,options:t},Vqt),[l,u]=(0,cg.useState)(s);s!==l&&!j8n(s,l)&&(c({type:"reset",state:Vqt({visibleOptionCount:e,defaultValue:r,options:t})}),u(s));let d=(0,cg.useCallback)(()=>{c({type:"focus-next-option"})},[]),p=(0,cg.useCallback)(()=>{c({type:"focus-previous-option"})},[]),f=(0,cg.useCallback)(()=>{c({type:"select-focused-option"})},[]),g=(0,cg.useMemo)(()=>s.map((h,_)=>({...h,index:_})).slice(a.visibleFromIndex,a.visibleToIndex),[s,a.visibleFromIndex,a.visibleToIndex]);return(0,cg.useEffect)(()=>{a.value&&a.previousValue!==a.value&&n?.(a.value)},[a.previousValue,a.value,t,n]),(0,cg.useEffect)(()=>{a.focusedValue&&o?.(a.focusedValue)},[a.focusedValue,o]),(0,cg.useEffect)(()=>{i&&c({type:"set-focus",value:i})},[i]),{focusedValue:a.focusedValue,visibleFromIndex:a.visibleFromIndex,visibleToIndex:a.visibleToIndex,value:a.value,visibleOptions:g,focusNextOption:d,focusPreviousOption:p,selectFocusedOption:f}};var v2e=({isDisabled:e=!1,state:t})=>{gt((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};var b2e=e=>`HEADER-${e.optionValues.join(",")}`;function V0({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a}){let c=I2e({visibleOptionCount:t,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a});v2e({isDisabled:e,state:c});let{styles:l}=Es("Select");return AG.default.createElement(v,{...l.container()},c.visibleOptions.map(u=>{let d="value"in u?u.value:b2e(u),p=!e&&c.focusedValue!==void 0&&("value"in u?c.focusedValue===u.value:u.optionValues.includes(c.focusedValue)),f=!!c.value&&("value"in u?c.value===u.value:u.optionValues.includes(c.value)),g="header"in u,h="label"in u?u.label:u.header,_=h;if(r&&h.includes(r)){let T=h.indexOf(r);_=AG.default.createElement(AG.default.Fragment,null,h.slice(0,T),AG.default.createElement(I,{...l.highlightedText()},r),h.slice(T+r.length))}return AG.default.createElement(y2e,{key:d,isFocused:p,isSelected:f,smallPointer:g},_)}))}function zqt({onDone:e}){return gt((t,r)=>{(r.ctrl&&(t==="c"||t==="d")||r.escape)&&e()}),hG.default.createElement(v,{flexDirection:"column",borderStyle:"round",padding:1,borderColor:re().secondaryBorder},hG.default.createElement(v,{marginBottom:1,flexDirection:"column"},hG.default.createElement(I,{bold:!0},"You've spent $5 this session.")),hG.default.createElement(v,null,hG.default.createElement(V0,{options:[{value:"ok",label:"Got it, thanks!"}],onChange:e})))}var Nn=G(ae(),1),rr=G(ae(),1);var jf=G(ae(),1);qe();fr();Hy();var X8n="2.4.37",qy={VERSION:X8n,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 x2e=46,Kqt=["(\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 tpe({isDefaultModel:e=!1}){let t=Math.max(x2e,Pe().length+12),r=re(),n=Kqt[Math.floor(Math.random()*Kqt.length)];return jf.createElement(v,{flexDirection:"column"},jf.createElement(v,{flexDirection:"column",gap:1,paddingLeft:1,width:"100%"},jf.createElement(I,null,jf.createElement(I,null,n)," Welcome to"," ",jf.createElement(I,{bold:!0},rt),jf.createElement(I,{color:r.secondaryText}," v",qy.VERSION)),jf.createElement(jf.Fragment,null,jf.createElement(v,{paddingLeft:2,flexDirection:"column",gap:1},jf.createElement(I,{color:r.secondaryText,italic:!0},"/help for help"),jf.createElement(I,{color:r.secondaryText},"cwd: ",Pe()),jf.createElement(I,{color:r.secondaryText},"model: ",Mo.getConfig().routing.MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A"),jf.createElement(I,{color:r.secondaryText},"small fast model: ",Mo.getConfig().routing.SMALL_FAST_MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A")))))}var UT=G(ae(),1);De();var _Z=G(ae(),1);import{randomUUID as LE}from"crypto";Js();De();nr();fr();De();qe();import{existsSync as j0,readdirSync as Njn,statSync as xjn}from"fs";import{join as Nx,relative as Ojn}from"path";import{homedir as q8t}from"os";import{platform as wjn}from"process";import{readFile as xx}from"fs/promises";fr();k_();br();import{join as iYn,sep as sYn}from"path";function Kf(){if(!lg())return!1;try{let e=it();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function ug(){return(iYn(Pe(),".hcode","team-memory")+sYn).normalize("NFC")}function P_(e){let t=e.normalize("NFC"),r=ug();return t.startsWith(r)}var $8t=G(iV(),1);ci();var z2e=(e,t,r)=>{let n=e instanceof RegExp?h8t(e,r):e,o=t instanceof RegExp?h8t(t,r):t,i=n!==null&&o!=null&&_Wn(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)}},h8t=(e,t)=>{let r=t.match(e);return r?r[0]:null},_Wn=(e,t,r)=>{let n,o,i,s,a,c=r.indexOf(e),l=r.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(n=[],i=r.length;u>=0&&!a;){if(u===c)n.push(u),c=r.indexOf(e,u+1);else if(n.length===1){let d=n.pop();d!==void 0&&(a=[d,l])}else o=n.pop(),o!==void 0&&o<i&&(i=o,s=l),l=r.indexOf(t,u+1);u=c<l&&c>=0?c:l}n.length&&s!==void 0&&(a=[i,s])}return a};var _8t="\0SLASH"+Math.random()+"\0",E8t="\0OPEN"+Math.random()+"\0",K2e="\0CLOSE"+Math.random()+"\0",S8t="\0COMMA"+Math.random()+"\0",T8t="\0PERIOD"+Math.random()+"\0",EWn=new RegExp(_8t,"g"),SWn=new RegExp(E8t,"g"),TWn=new RegExp(K2e,"g"),yWn=new RegExp(S8t,"g"),bWn=new RegExp(T8t,"g"),CWn=/\\\\/g,IWn=/\\{/g,vWn=/\\}/g,RWn=/\\,/g,NWn=/\\\./g,xWn=1e5,OWn=4e6;function W2e(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function wWn(e){return e.replace(CWn,_8t).replace(IWn,E8t).replace(vWn,K2e).replace(RWn,S8t).replace(NWn,T8t)}function DWn(e){return e.replace(EWn,"\\").replace(SWn,"{").replace(TWn,"}").replace(yWn,",").replace(bWn,".")}function y8t(e){if(!e)return[""];let t=[],r=z2e("{","}",e);if(!r)return e.split(",");let{pre:n,body:o,post:i}=r,s=n.split(",");s[s.length-1]+="{"+o+"}";let a=y8t(i);return i.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function b8t(e,t={}){if(!e)return[];let{max:r=xWn,maxLength:n=OWn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),j2e(wWn(e),r,n,!0).map(DWn)}function MWn(e){return"{"+e+"}"}function BWn(e){return/^-?0\d/.test(e)}function kWn(e,t){return e<=t}function PWn(e,t){return e>=t}function sV(e,t,r,n,o,i){let s=[],a=0;for(let c=0;c<e.length;c++)for(let l=0;l<r.length;l++){if(s.length>=n)return s;let u=e[c]+t+r[l];if(!(i&&!u)){if(a+u.length>o)return s;s.push(u),a+=u.length}}return s}function LWn(e,t,r,n){let o=e.split(/\.\./),i=[];if(o[0]===void 0||o[1]===void 0)return i;let s=W2e(o[0]),a=W2e(o[1]),c=Math.max(o[0].length,o[1].length),l=o.length===3&&o[2]!==void 0?Math.max(Math.abs(W2e(o[2])),1):1,u=kWn;a<s&&(l*=-1,u=PWn);let p=o.some(BWn),f=0;for(let g=s;u(g,a)&&i.length<r;g+=l){let h;if(t)h=String.fromCharCode(g),h==="\\"&&(h="");else if(h=String(g),p){let _=c-h.length;if(_>0){let T=new Array(_+1).join("0");g<0?h="-"+T+h.slice(1):h=T+h}}if(f+h.length>n)break;i.push(h),f+=h.length}return i}function j2e(e,t,r,n){let o=[""],i=!1,s=!0;for(;;){let a=z2e("{","}",e);if(!a)return sV(o,e,[""],t,r,i);let c=a.pre;if(/\$$/.test(c)){if(o=sV(o,c+"{"+a.body+"}",[""],t,r,i&&!a.post.length),s=!1,!a.post.length)break;e=a.post;continue}let l=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),d=l||u,p=a.body.indexOf(",")>=0;if(!d&&!p){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+K2e+a.post,n=!0;continue}return sV(o,c+"{"+a.body+"}"+a.post,[""],t,r,i)}s&&(i=n&&!d,s=!1);let f;if(d)f=LWn(a.body,u,t,r);else{let g=y8t(a.body);if(g.length===1&&g[0]!==void 0&&(g=j2e(g[0],t,r,!1).map(MWn),g.length===1)){if(o=sV(o,c+g[0],[""],t,r,i&&!a.post.length),!a.post.length)break;e=a.post;continue}let h=i&&!a.post.length&&!c;for(let T=0;h&&T<o.length;T++)o[T]&&(h=!1);f=[];let _=0;e:for(let T=0;T<g.length;T++){let y=j2e(g[T],t,r,!1);for(let C=0;C<y.length;C++){let R=y[C];if(!(h&&!R)){if(f.length>=t||_+R.length>r)break e;f.push(R),_+=R.length}}}}if(o=sV(o,c,f,t,r,i&&!a.post.length),!a.post.length)break;e=a.post}return o}var aV=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var UWn={"[: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]},cV=e=>e.replace(/[[\]\\-]/g,"\\$&"),FWn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),C8t=e=>e.join(""),I8t=(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,c=!1,l=!1,u=r,d="";e:for(;i<e.length;){let h=e.charAt(i);if((h==="!"||h==="^")&&i===r+1){l=!0,i++;continue}if(h==="]"&&s&&!c){u=i+1;break}if(s=!0,h==="\\"&&!c){c=!0,i++;continue}if(h==="["&&!c){for(let[_,[T,y,C]]of Object.entries(UWn))if(e.startsWith(_,i)){if(d)return["$.",!1,e.length-r,!0];i+=_.length,C?o.push(T):n.push(T),a=a||y;continue e}}if(c=!1,d){h>d?n.push(cV(d)+"-"+cV(h)):h===d&&n.push(cV(h)),d="",i++;continue}if(e.startsWith("-]",i+1)){n.push(cV(h+"-")),i+=2;continue}if(e.startsWith("-",i+1)){d=h,i+=2;continue}n.push(cV(h)),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])&&!l){let h=n[0].length===2?n[0].slice(-1):n[0];return[FWn(h),!1,u-r,!1]}let p="["+(l?"^":"")+C8t(n)+"]",f="["+(l?"":"^")+C8t(o)+"]";return[n.length&&o.length?"("+p+"|"+f+")":n.length?p:f,a,u-r,!0]};var Rx=(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 pg,QWn=new Set(["!","?","+","*","@"]),J2e=e=>QWn.has(e),v8t=e=>J2e(e.type),GWn=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),HWn=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),qWn=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),R8t=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),$Wn="(?!(?:^|/)\\.\\.?(?:$|/))",fpe="(?!\\.)",YWn=new Set(["[","."]),VWn=new Set(["..","."]),zWn=new Set("().*{}+?[]^$\\!"),WWn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Z2e="[^/]",N8t=Z2e+"*?",x8t=Z2e+"+?",jWn=0,jM=class{type;#e;#t;#n=!1;#r=[];#o;#i;#c;#a=!1;#s;#d;#f=!1;id=++jWn;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.#s=this.#e===this?n:this.#e.#s,this.#c=this.#e===this?[]:this.#e.#c,t==="!"&&!this.#e.#a&&this.#c.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("")}#p(){if(this!==this.#e)throw new Error("should only call on root");if(this.#a)return this;this.toString(),this.#a=!0;let t;for(;t=this.#c.pop();){if(t.type!=="!")continue;let r=t,n=r.#o;for(;n;){for(let o=r.#i+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.#o}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof pg&&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.#a&&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 pg&&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 pg(this.type,t);for(let n of this.#r)r.copyIn(n);return r}static#l(t,r,n,o,i){let s=o.maxExtglobRecursion??2,a=!1,c=!1,l=-1,u=!1;if(r.type===null){let h=n,_="";for(;h<t.length;){let T=t.charAt(h++);if(a||T==="\\"){a=!a,_+=T;continue}if(c){h===l+1?(T==="^"||T==="!")&&(u=!0):T==="]"&&!(h===l+2&&u)&&(c=!1),_+=T;continue}else if(T==="["){c=!0,l=h,u=!1,_+=T;continue}if(!o.noext&&J2e(T)&&t.charAt(h)==="("&&i<=s){r.push(_),_="";let C=new pg(T,r);h=pg.#l(t,C,h,o,i+1),r.push(C);continue}_+=T}return r.push(_),h}let d=n+1,p=new pg(null,r),f=[],g="";for(;d<t.length;){let h=t.charAt(d++);if(a||h==="\\"){a=!a,g+=h;continue}if(c){d===l+1?(h==="^"||h==="!")&&(u=!0):h==="]"&&!(d===l+2&&u)&&(c=!1),g+=h;continue}else if(h==="["){c=!0,l=d,u=!1,g+=h;continue}if(!o.noext&&J2e(h)&&t.charAt(d)==="("&&(i<=s||r&&r.#_(h))){let T=r&&r.#_(h)?0:1;p.push(g),g="";let y=new pg(h,p);p.push(y),d=pg.#l(t,y,d,o,i+T);continue}if(h==="|"){p.push(g),g="",f.push(p),p=new pg(null,r);continue}if(h===")")return g===""&&r.#r.length===0&&(r.#f=!0),p.push(g),g="",r.push(...f,p),d;g+=h}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],d}#m(t){return this.#A(t,HWn)}#A(t,r=GWn){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=qWn){return!!r.get(this.type)?.includes(t)}#h(t,r){let n=t.#r[0],o=new pg(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.#o=this);this.#d=void 0}#S(t){return!!R8t.get(this.type)?.has(t)}#b(t){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let r=t.#r[0];return!r||typeof r!="object"||r.type===null?!1:this.#S(r.type)}#C(t){let r=R8t.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.#o=this);this.type=o,this.#d=void 0,this.#f=!1}static fromGlob(t,r={}){let n=new pg(null,void 0,r);return pg.#l(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.#s.nocase&&!this.#s.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#s.nocase?"i":"")+(i?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#s}toRegExpSource(t){let r=t??!!this.#s.dot;if(this.#e===this&&(this.#E(),this.#p()),!v8t(this)){let c=this.isStart()&&this.isEnd()&&!this.#r.some(f=>typeof f!="string"),l=this.#r.map(f=>{let[g,h,_,T]=typeof f=="string"?pg.#y(f,this.#t,c):f.toRegExpSource(t);return this.#t=this.#t||_,this.#n=this.#n||T,g}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&VWn.has(this.#r[0]))){let g=YWn,h=r&&g.has(l.charAt(0))||l.startsWith("\\.")&&g.has(l.charAt(2))||l.startsWith("\\.\\.")&&g.has(l.charAt(4)),_=!r&&!t&&g.has(l.charAt(0));u=h?$Wn:_?fpe:""}let d="";return this.isEnd()&&this.#e.#a&&this.#o?.type==="!"&&(d="(?:$|\\/)"),[u+l+d,Rx(l),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",o=this.type==="!"?"(?:(?!(?:":"(?:",i=this.#T(r);if(this.isStart()&&this.isEnd()&&!i&&this.type!=="!"){let c=this.toString(),l=this;return l.#r=[c],l.type=null,l.#t=void 0,[c,Rx(this.toString()),!1,!1]}let s=!n||t||r||!fpe?"":this.#T(!0);s===i&&(s=""),s&&(i=`(?:${i})(?:${s})*?`);let a="";if(this.type==="!"&&this.#f)a=(this.isStart()&&!r?fpe:"")+x8t;else{let c=this.type==="!"?"))"+(this.isStart()&&!r&&!t?fpe:"")+N8t+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=o+i+c}return[a,Rx(i),this.#t=!!this.#t,this.#n]}#E(){if(v8t(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.#m(o)?(r=!1,this.#h(o,n)):this.#b(o)&&(r=!1,this.#C(o)))}}while(!r&&++t<10)}else for(let t of this.#r)typeof t=="object"&&t.#E();this.#d=void 0}#T(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 c=0;c<t.length;c++){let l=t.charAt(c);if(o){o=!1,i+=(zWn.has(l)?"\\":"")+l;continue}if(l==="*"){if(a)continue;a=!0,i+=n&&/^[*]+$/.test(t)?x8t:N8t,r=!0;continue}else a=!1;if(l==="\\"){c===t.length-1?i+="\\\\":o=!0;continue}if(l==="["){let[u,d,p,f]=I8t(t,c);if(p){i+=u,s=s||d,c+=p-1,r=r||f;continue}}if(l==="?"){i+=Z2e,r=!0;continue}i+=WWn(l)}return[i,Rx(t),!!r,s]}};pg=jM;var X2e=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var Kd=(e,t,r={})=>(aV(t),!r.nocomment&&t.charAt(0)==="#"?!1:new NG(t,r).match(e)),KWn=/^\*+([^+@!?*[(]*)$/,JWn=e=>t=>!t.startsWith(".")&&t.endsWith(e),ZWn=e=>t=>t.endsWith(e),XWn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),ejn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),tjn=/^\*+\.\*+$/,rjn=e=>!e.startsWith(".")&&e.includes("."),njn=e=>e!=="."&&e!==".."&&e.includes("."),ojn=/^\.\*+$/,ijn=e=>e!=="."&&e!==".."&&e.startsWith("."),sjn=/^\*+$/,ajn=e=>e.length!==0&&!e.startsWith("."),cjn=e=>e.length!==0&&e!=="."&&e!=="..",ljn=/^\?+([^+@!?*[(]*)?$/,ujn=([e,t=""])=>{let r=D8t([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},djn=([e,t=""])=>{let r=M8t([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},pjn=([e,t=""])=>{let r=M8t([e]);return t?n=>r(n)&&n.endsWith(t):r},fjn=([e,t=""])=>{let r=D8t([e]);return t?n=>r(n)&&n.endsWith(t):r},D8t=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},M8t=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},B8t=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",O8t={win32:{sep:"\\"},posix:{sep:"/"}},mjn=B8t==="win32"?O8t.win32.sep:O8t.posix.sep;Kd.sep=mjn;var tf=Symbol("globstar **");Kd.GLOBSTAR=tf;var gjn="[^/]",Ajn=gjn+"*?",hjn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",_jn="(?:(?!(?:\\/|^)\\.).)*?",Ejn=(e,t={})=>r=>Kd(r,e,t);Kd.filter=Ejn;var L_=(e,t={})=>Object.assign({},e,t),Sjn=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return Kd;let t=Kd;return Object.assign((n,o,i={})=>t(n,o,L_(e,i)),{Minimatch:class extends t.Minimatch{constructor(o,i={}){super(o,L_(e,i))}static defaults(o){return t.defaults(L_(e,o)).Minimatch}},AST:class extends t.AST{constructor(o,i,s={}){super(o,i,L_(e,s))}static fromGlob(o,i={}){return t.AST.fromGlob(o,L_(e,i))}},unescape:(n,o={})=>t.unescape(n,L_(e,o)),escape:(n,o={})=>t.escape(n,L_(e,o)),filter:(n,o={})=>t.filter(n,L_(e,o)),defaults:n=>t.defaults(L_(e,n)),makeRe:(n,o={})=>t.makeRe(n,L_(e,o)),braceExpand:(n,o={})=>t.braceExpand(n,L_(e,o)),match:(n,o,i={})=>t.match(n,o,L_(e,i)),sep:t.sep,GLOBSTAR:tf})};Kd.defaults=Sjn;var k8t=(e,t={})=>(aV(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:b8t(e,{max:t.braceExpandMax}));Kd.braceExpand=k8t;var Tjn=(e,t={})=>new NG(e,t).makeRe();Kd.makeRe=Tjn;var yjn=(e,t,r={})=>{let n=new NG(t,r);return e=e.filter(o=>n.match(o)),n.options.nonull&&!e.length&&e.push(t),e};Kd.match=yjn;var w8t=/[?*]|[+@!]\(.*?\)|\[|\]/,bjn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),NG=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){aV(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||B8t,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 c=i[0]===""&&i[1]===""&&(i[2]==="?"||!w8t.test(i[2]))&&!w8t.test(i[3]),l=/^[a-z]:/i.test(i[0]);if(c)return[...i.slice(0,4),...i.slice(4).map(u=>this.parse(u))];if(l)return[i[0],...i.slice(1).map(u=>this.parse(u))]}return i.map(c=>this.parse(c))});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],c=n[o+2],l=n[o+3];if(a!==".."||!c||c==="."||c===".."||!l||l==="."||l==="..")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 c=i===1&&n[i+1]==="**"?["."]:[];n.splice(i-1,2,...c),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]),c=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),l=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),u=!l&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),d=c?3:a?0:void 0,p=u?3:l?0:void 0;if(typeof d=="number"&&typeof p=="number"){let[f,g]=[t[d],r[p]];f.toLowerCase()===g.toLowerCase()&&(r[p]=f,i=p,o=d)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(tf)?this.#e(t,r,n,o,i):this.#n(t,r,n,o,i)}#e(t,r,n,o,i){let s=r.indexOf(tf,i),a=r.lastIndexOf(tf),[c,l,u]=n?[r.slice(i,s),r.slice(s+1),[]]:[r.slice(i,s),r.slice(s+1,a),r.slice(a+1)];if(c.length){let y=t.slice(o,o+c.length);if(!this.#n(y,c,n,0,0))return!1;o+=c.length,i+=c.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(!l.length){let y=!!d;for(let C=o;C<t.length-d;C++){let R=String(t[C]);if(y=!0,R==="."||R===".."||!this.options.dot&&R.startsWith("."))return!1}return n||y}let p=[[[],0]],f=p[0],g=0,h=[0];for(let y of l)y===tf?(h.push(g),f=[[],0],p.push(f)):(f[0].push(y),g++);let _=p.length-1,T=t.length-d;for(let y of p)y[1]=T-(h[_--]+y[0].length);return!!this.#t(t,p,o,0,n,0,!!d)}#t(t,r,n,o,i,s,a){let c=r[o];if(!c){for(let d=n;d<t.length;d++){a=!0;let p=t[d];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1}return a}let[l,u]=c;for(;n<=u;){if(this.#n(t.slice(0,n+l.length),l,i,n,0)&&s<this.maxGlobstarRecursion){let f=this.#t(t,r,n+l.length,o+1,i,s+1,a);if(f!==!1)return f}let p=t[n];if(p==="."||p===".."||!this.options.dot&&p.startsWith("."))return!1;n++}return i||null}#n(t,r,n,o,i){let s,a,c,l;for(s=o,a=i,l=t.length,c=r.length;s<l&&a<c;s++,a++){this.debug("matchOne loop");let u=r[a],d=t[s];if(this.debug(r,u,d),u===!1||u===tf)return!1;let p;if(typeof u=="string"?(p=d===u,this.debug("string match",u,d,p)):(p=u.test(d),this.debug("pattern match",u,d,p)),!p)return!1}if(s===l&&a===c)return!0;if(s===l)return n;if(a===c)return s===l-1&&t[s]==="";throw new Error("wtf?")}braceExpand(){return k8t(this.pattern,this.options)}parse(t){aV(t);let r=this.options;if(t==="**")return tf;if(t==="")return"";let n,o=null;(n=t.match(sjn))?o=r.dot?cjn:ajn:(n=t.match(KWn))?o=(r.nocase?r.dot?ejn:XWn:r.dot?ZWn:JWn)(n[1]):(n=t.match(ljn))?o=(r.nocase?r.dot?djn:ujn:r.dot?pjn:fjn)(n):(n=t.match(tjn))?o=r.dot?njn:rjn:(n=t.match(ojn))&&(o=ijn);let i=jM.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?Ajn:r.dot?hjn:_jn,o=new Set(r.nocase?["i"]:[]),i=t.map(c=>{let l=c.map(d=>{if(d instanceof RegExp)for(let p of d.flags.split(""))o.add(p);return typeof d=="string"?bjn(d):d===tf?tf:d._src});l.forEach((d,p)=>{let f=l[p+1],g=l[p-1];d!==tf||g===tf||(g===void 0?f!==void 0&&f!==tf?l[p+1]="(?:\\/|"+n+"\\/)?"+f:l[p]=n:f===void 0?l[p-1]=g+"(?:\\/|\\/"+n+")?":f!==tf&&(l[p-1]=g+"(?:\\/|\\/"+n+"\\/)"+f,l[p+1]=tf))});let u=l.filter(d=>d!==tf);if(this.partial&&u.length>=1){let d=[];for(let p=1;p<=u.length;p++)d.push(u.slice(0,p).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 c=o;if(n.matchBase&&a.length===1&&(c=[s]),this.matchOne(c,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return Kd.defaults(t).Minimatch}};Kd.AST=jM;Kd.Minimatch=NG;Kd.escape=X2e;Kd.unescape=Rx;var U8t=G(iV(),1);fr();qe();De();qf();import{readFile as P8t}from"fs/promises";import{existsSync as eUe,readdirSync as Cjn,statSync as Ijn}from"fs";import{join as tUe,relative as F8t}from"path";import{homedir as vjn}from"os";function L8t(e){try{let t=(0,U8t.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 Rjn(e,t){return t.length===0?!0:t.some(r=>{try{return Kd(e,r,{matchBase:!0,dot:!0})}catch(n){return be(n),!1}})}function rUe(e){let t=[];try{if(!eUe(e))return t;let r=Cjn(e);for(let n of r){let o=tUe(e,n),i=Ijn(o);i.isDirectory()?t.push(...rUe(o)):i.isFile()&&n.endsWith(".md")&&t.push(o)}}catch(r){be(r)}return t}async function mpe(){let e=[];try{let t=tUe(vjn(),Kn,"rules");if(eUe(t)){let r=rUe(t);for(let n of r)try{let o=await P8t(n,"utf-8"),{paths:i,content:s}=L8t(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=tUe(Pe(),Kn,"rules");if(eUe(t)){let r=rUe(t);for(let n of r)try{let o=await P8t(n,"utf-8"),{paths:i,content:s}=L8t(o);i.length>0&&e.push({filePath:F8t(Pe(),n),content:s,paths:i,isProjectRule:!0})}catch(o){be(o)}}}catch(t){be(t)}return e}function Q8t(e,t){e=Qle(e);let r=Qle(Pe()),n=e.startsWith(r)?F8t(r,e):e;return t.filter(o=>Rjn(n,o.paths))}function G8t(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}):
|
|
690
690
|
|
|
691
691
|
${r.content}`}).join(`
|
|
692
692
|
|
|
@@ -782,7 +782,7 @@ data: ${JSON.stringify(U)}
|
|
|
782
782
|
Stack trace: `+d.stack)),new Response(c.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var Wge=null,L4e=!1;function fAo(){Wge=null,L4e=!1}Ft.on("proxy:changed",fAo);function mAo(){if(L4e)return Wge;if(L4e=!0,it().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(Wge=new etr.ProxyAgent({uri:e}),er(`[proxy] using proxy: ${e}`)),Wge}function gAo(){let e=mAo();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function Kge(e){let t=e||process.env.API_TYPE,r=gAo();switch(t){case"openai":return lAo(r);case"openai-responses":return uAo(r);case"gemini":return dAo(r);default:return pAo(r)}}Hy();var rtr=G(ae(),1);function ttr(e,t){let r=[],n=Math.max(1,Math.floor(t)),o="",i=0;for(let s of e){let a=AAo(s);o&&i+a>n?(r.push(o),o=s,i=a):(o+=s,i+=a)}return o&&r.push(o),r}function AAo(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||hAo(t)?0:_Ao(t)?2:1}function hAo(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function _Ao(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 zS(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 Q4e(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let r=Math.floor(t/3600),n=Math.floor(t%3600/60),o=t%60;return r>0?`${r}h ${n}m ${o}s`:`${n}m ${o}s`}function AI(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}function Jge(e,t,r){let n=[];return typeof e=="number"&&n.push(Q4e(e)),typeof t=="number"&&n.push(`${t} ${t===1?"turn":"turns"}`),typeof r=="number"&&n.push(`${AI(r)} tokens`),n.length>0?` (${n.join(" \xB7 ")})`:""}De();Js();var cu={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function Zge(e,t){cu.totalCost+=e,cu.totalAPIDuration+=t}function Xge(e,t){cu.inputTokens+=e,cu.outputTokens+=t,Ft.emit("token:change",{inputTokens:cu.inputTokens,outputTokens:cu.outputTokens})}function eAe(e,t){cu.cacheCreationTokens+=e,cu.cacheReadTokens+=t}function UB(){return{inputTokens:cu.inputTokens,outputTokens:cu.outputTokens,cacheCreationTokens:cu.cacheCreationTokens,cacheReadTokens:cu.cacheReadTokens}}function F9(){return cu.totalCost}function tAe(){return Date.now()-cu.startTime}function ntr(){return cu.totalAPIDuration}function otr(e){cu.currentContextTokens=e}function itr(){return cu.currentContextTokens}function EAo(){return It.grey(`Total duration (API): ${zS(cu.totalAPIDuration)}
|
|
783
783
|
Total duration (wall): ${zS(tAe())}`)}function atr(){(0,rtr.useEffect)(()=>{let e=()=>{process.stdout.write(`
|
|
784
784
|
`+EAo()+`
|
|
785
|
-
`);let t=Jn();zi({...t,lastCost:cu.totalCost,lastAPIDuration:cu.totalAPIDuration,lastDuration:tAe(),lastSessionId:bS})};return process.on("exit",e),()=>{process.off("exit",e)}},[])}De();qe();qe();var G4e="2.4.
|
|
785
|
+
`);let t=Jn();zi({...t,lastCost:cu.totalCost,lastAPIDuration:cu.totalAPIDuration,lastDuration:tAe(),lastSessionId:bS})};return process.on("exit",e),()=>{process.off("exit",e)}},[])}De();qe();qe();var G4e="2.4.37";globalThis.MACRO={VERSION:G4e,PACKAGE_URL:`@dahawa/${Mi}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var rAe=process.env.HAWA_CODE_USER_AGENT||`${Mi}/${G4e} (${process.env.USER_TYPE})`;De();De();nr();function of(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=Hd(r);if(i?.type==="user"){r[r.length-1]=ctr(i,o);return}r.push(o);return}case"assistant":r.push(o);return;case"insert":{let i=Hd(r);i?.type==="user"&&(r[r.length-1]=SAo(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 c=yt([{type:"text",text:`<system-rules>
|
|
786
786
|
${G8t(a)}
|
|
787
787
|
</system-rules>`}]),l=Hd(r);l?.type==="user"?r[r.length-1]=ctr(l,c,{skipTrailingSystemReminders:!0}):r.push(c);return}}}),r}function SAo(e,t){return{...e,message:{...e.message,content:yAo(e.message.content,TAo(t.content.content))}}}function TAo(e){return`
|
|
788
788
|
<system-reminder>
|
|
@@ -3575,7 +3575,7 @@ NEVER SUGGEST:
|
|
|
3575
3575
|
Stay silent if the next step isn't obvious from what the user said.
|
|
3576
3576
|
Format: 2-8 words, match the user's style. Or nothing.
|
|
3577
3577
|
Reply with ONLY the suggestion, no quotes or explanation.
|
|
3578
|
-
\u5386\u53F2\u6D88\u606F\u4E2D\u5DE5\u5177\u52A0\u8F7D\u548C\u5378\u8F7D\u6D88\u606F\u4E0D\u9700\u8981\u4F5C\u4E3A\u5EFA\u8BAE\u53C2\u8003\u5185\u5BB9.`,aot=class{async getSuggestionPrompt(t,r){try{if(r?.aborted)return null;let o=[...qQr()?HQr(t):t,yt(dti)],s=(await tl(of(o),["You are a helpful assistant that suggests the next user input based on conversation history. keep answers short, 2 to 8 words"],[],r,{model:wa(),dangerouslySkipPermissions:!1,prependCLISysprompt:!1,thinking:"off"})).message.content,a="";for(let l of s)l.type==="text"&&(a+=l.text);if(a=a.trim(),!a||a==="(no content)")return null;let c=a.trim().split(/[\s\p{P}]+/u).filter(l=>l.length>0).length;return c>20?(ne(`Suggestion too long (${c} words): "${a}"`),null):a}catch(n){return ne("Error generating suggestion:",n),null}}},$Qr=new aot;Ok();br();function YQr(e){let t={...e};return Object.keys(e).forEach(r=>{let n=e[r];if(typeof n=="string")try{n=xl(n);let o=JSON.parse(n);typeof o=="object"&&o!==null&&(t[r]=o)}catch{}}),t}uE();De();k_();import{readdir as pti,readFile as fti,stat as mti}from"fs/promises";import{basename as gti,join as Ati}from"path";var hti=200,_ti=30;function Eti(e){let t=/^---\s*\n([\s\S]*?)---\s*\n?/,r=e.match(t);if(!r)return{frontmatter:{},content:e};let n=r[1]||"",o=e.slice(r[0].length),i={},s=n.split(`
|
|
3578
|
+
\u5386\u53F2\u6D88\u606F\u4E2D\u5DE5\u5177\u52A0\u8F7D\u548C\u5378\u8F7D\u6D88\u606F\u4E0D\u9700\u8981\u4F5C\u4E3A\u5EFA\u8BAE\u53C2\u8003\u5185\u5BB9.`,aot=class{async getSuggestionPrompt(t,r){try{if(r?.aborted)return null;let o=[...qQr()?HQr(t):t,yt(dti)],s=(await tl(of(o),["You are a helpful assistant that suggests the next user input based on conversation history. keep answers short, 2 to 8 words"],[],r,{model:wa(),dangerouslySkipPermissions:!1,prependCLISysprompt:!1,thinking:"off",agentId:"suggest\u201D"})).message.content,a="";for(let l of s)l.type==="text"&&(a+=l.text);if(a=a.trim(),!a||a==="(no content)")return null;let c=a.trim().split(/[\s\p{P}]+/u).filter(l=>l.length>0).length;return c>20?(ne(`Suggestion too long (${c} words): "${a}"`),null):a}catch(n){return ne("Error generating suggestion:",n),null}}},$Qr=new aot;Ok();br();function YQr(e){let t={...e};return Object.keys(e).forEach(r=>{let n=e[r];if(typeof n=="string")try{n=xl(n);let o=JSON.parse(n);typeof o=="object"&&o!==null&&(t[r]=o)}catch{}}),t}uE();De();k_();import{readdir as pti,readFile as fti,stat as mti}from"fs/promises";import{basename as gti,join as Ati}from"path";var hti=200,_ti=30;function Eti(e){let t=/^---\s*\n([\s\S]*?)---\s*\n?/,r=e.match(t);if(!r)return{frontmatter:{},content:e};let n=r[1]||"",o=e.slice(r[0].length),i={},s=n.split(`
|
|
3579
3579
|
`);for(let a of s){let c=a.trim();if(!c||c.startsWith("#"))continue;let l=c.indexOf(":");if(l===-1)continue;let u=c.slice(0,l).trim(),d=c.slice(l+1).trim();i[u]=d.replace(/['"]/g,"")}return{frontmatter:i,content:o}}async function T0e(e,t){try{let n=(await pti(e,{recursive:!0})).filter(i=>i.endsWith(".md")&>i(i)!=="MEMORY.md");return(await Promise.allSettled(n.map(async i=>{let s=Ati(e,i);if(t.aborted)throw new Error("Aborted");let a=await mti(s),u=(await fti(s,{encoding:"utf-8"})).split(`
|
|
3580
3580
|
`).slice(0,_ti).join(`
|
|
3581
3581
|
`),{frontmatter:d}=Eti(u);return{filename:i,filePath:s,mtimeMs:a.mtimeMs,description:d.description||null,type:dlr(d.type)}}))).filter(i=>i.status==="fulfilled").map(i=>i.value).sort((i,s)=>s.mtimeMs-i.mtimeMs).slice(0,hti)}catch{return[]}}function y0e(e){return e.map(t=>{let r=t.type?`[${t.type}] `:"",n=new Date(t.mtimeMs).toISOString();return t.description?`- ${r}${t.filename} (${n}): ${t.description}`:`- ${r}${t.filename} (${n})`}).join(`
|
package/hands.js
CHANGED
|
@@ -758,7 +758,7 @@ data: ${JSON.stringify(G)}
|
|
|
758
758
|
`);a=Q.pop()||"";for(let G of Q){let j=G.trim();if(!(!j||j==="data: [DONE]"))if(j.startsWith("data: ")){let q=j.slice(6);try{let V=JSON.parse(q);w(V)}catch(V){this.logger&&this.logger.error({err:V,line:j},"Failed to parse Gemini SSE chunk")}}else try{let q=JSON.parse(j);w(q)}catch{}}};(async()=>{try{for(;;){let{value:Q,done:G}=await s.read();if(G)break;a+=n.decode(Q,{stream:!0}),O()}I()}catch(Q){o.error(Q)}})()}})}convertGeminiResponseToAnthropic(t){this.logger&&this.logger.debug({response:t},"Original Gemini response");try{if(!t.candidates||!t.candidates[0])throw new Error("No candidates found in Gemini response");let r=t.candidates[0],n=[];r.content&&r.content.parts&&r.content.parts.forEach(o=>{if(o.text&&n.push({type:"text",text:o.text}),o.functionCall){let s=`toolu_${WB()}`,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:`
|
|
759
759
|
|
|
760
760
|
[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 pHr(`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"}}},hbe=new Abe;var vgt=X(Sgt(),1);ar();fs();function Gg(e){return e?typeof e.entries=="function"?Object.fromEntries(e.entries()):{...e}:{}}function Igt(e){let t=String(e?.["x-thinking-level"]??"medium").toLowerCase();return["off","low","medium","high"].includes(t)?t:"medium"}function xrn(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t}}function wrn(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t,summary:"auto"}}function Drn(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 j5(e,t,r){$z(t,e),qz(t,Drn(e,r),r)}function P2(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 Y5(e){let t=new Headers(e);return t.delete("content-encoding"),t.delete("content-length"),t.delete("transfer-encoding"),t}function zIe(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 Tgt=["/v1/messages"];function jIe(e){let t;try{typeof e=="string"?t=new Qv(e):e instanceof Qv?t=e:t=new Qv(e.url)}catch{return""}let r=t.pathname;for(let n of Tgt){let i=r.indexOf(n);if(i!==-1)return t.origin+r.slice(0,i)}return t.origin}function XZ(e,t){let r=typeof e=="string"?e:e instanceof Qv?e.toString():e.url,n;try{n=new Qv(r).pathname}catch{return!1}return Tgt.some(i=>n.includes(i))&&(t.method==="POST"||t.method==="post")}function Rrn(e){return async(t,r)=>{if(!XZ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await eJ.transformRequestOut(n),o=jIe(t)+"/chat/completions",s=Gg(r.headers),a=s.authorization??s.Authorization??"";xrn(i,Igt(s));let l=await e(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:a},body:JSON.stringify(i),signal:r.signal});if(!l.ok){let _=await l.text();return K(`OpenAI Chat Completions API error: ${l.status}`,{url:o,errorResponse:_}),zIe("OpenAI Chat Completions API error","OPENROUTER",l.status,l.statusText,_)}let c=n.stream===!0,u=s["x-agent-id"],f={request:{url:o,method:r.method,headers:s,body:n},response:{status:l.status,statusText:l.statusText,headers:Gg(l.headers)},openai:{request:{body:i},response:{}}};if(!c){let _=await l.text(),y=new Response(_,{status:l.status,statusText:l.statusText,headers:Y5(l.headers)}),S=await eJ.transformResponseIn(y,n),I=await S.text();try{j5({...f,openai:{...f.openai,response:{body:JSON.parse(_)}},response:{...f.response,body:JSON.parse(I)}},u)}catch(w){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u975E\u6D41\u5F0F):",w)}return new Response(I,{status:S.status,statusText:S.statusText,headers:S.headers})}let g=P2(l.body),m=new Response(g.stream,{status:l.status,statusText:l.statusText,headers:Y5(l.headers)}),A=await eJ.transformResponseIn(m,n),h=P2(A.body);return Promise.all([g.done,h.done]).then(async([_,y])=>{try{j5({...f,openai:{...f.openai,response:{body:await Xot(_)}},response:{...f.response,body:await LU(y)}},u)}catch(S){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u6D41\u5F0F):"+S?.stack)}}).catch(_=>K("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Chat):"+_)),new Response(h.stream,{status:A.status,statusText:A.statusText,headers:A.headers})}}function Nrn(e){return async(t,r)=>{if(!XZ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await tJ.transformRequestOut(n),o=Gg(r.headers);wrn(i,Igt(o));let s=JSON.stringify(i),l=jIe(t)+"/responses",c=o.authorization??o.Authorization??"";if(!c)return new Response(JSON.stringify({type:"error",error:{type:"api_error",message:"Missing Authorization header",code:"RESPONSES_AUTH_MISSING"}}),{status:401,headers:{"Content-Type":"application/json"}});let u=await e(l,{method:"POST",headers:{"Content-Type":"application/json",Authorization:c,"x-api-key":c.replace(/^Bearer\s+/i,"").trim()},body:s,signal:r.signal});if(!u.ok){let S=await u.text();return K(`OpenAI Responses API error: ${u.status} ${u.statusText}`,{url:l,status:u.status,errorResponse:S}),zIe("OpenAI Responses API error","RESPONSES",u.status,u.statusText,S)}let f=n.stream===!0,g=o["x-agent-id"],m={request:{url:l,method:r.method,headers:o,body:n},response:{status:u.status,statusText:u.statusText,headers:Gg(u.headers)},openai:{request:{body:i},response:{}}};if(!f){let S=await u.text(),I=new Response(S,{status:u.status,statusText:u.statusText,headers:Y5(u.headers)}),w=await tJ.transformResponseIn(I,n),O=await w.text();try{j5({...m,openai:{...m.openai,response:{body:JSON.parse(S)}},response:{...m.response,body:JSON.parse(O)}},g,"responses")}catch(Q){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u975E\u6D41\u5F0F):",Q)}return new Response(O,{status:w.status,statusText:w.statusText,headers:w.headers})}let A=P2(u.body),h=new Response(A.stream,{status:u.status,statusText:u.statusText,headers:Y5(u.headers)}),_=await tJ.transformResponseIn(h,n),y=P2(_.body);return Promise.all([A.done,y.done]).then(async([S,I])=>{try{j5({...m,openai:{...m.openai,response:{body:await Zot(S)}},response:{...m.response,body:await LU(I)}},g,"responses")}catch(w){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u6D41\u5F0F):"+w?.stack)}}).catch(S=>K("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Responses):"+S)),new Response(y.stream,{status:_.status,statusText:_.statusText,headers:_.headers})}}function Brn(e){return async(t,r)=>{if(!XZ(t,r))return e(t,r);let n=JSON.parse(r.body),i=Gg(r.headers),o=await hbe.transformRequestOut(n),s=JSON.stringify(o),a=jIe(t)+`/models/${n.model}:streamGenerateContent?alt=sse`,l=i.authorization??i.Authorization??"",c;try{c=await e(a,{method:"POST",headers:{"Content-Type":"application/json","x-goog-api-key":String(l).replace(/^Bearer\s+/i,"").trim()},body:s,signal:r.signal})}catch(y){throw K("gemini request error:",y),y}if(!c.ok){let y=await c.text();return K(`Gemini API error response: ${c.status} ${c.statusText}`,{url:a,status:c.status,errorResponse:y}),zIe("Gemini API error","Gemini",c.status,c.statusText,y)}let u=n.stream===!0,f=i["x-agent-id"],g={request:{url:a,method:r.method,headers:Gg(r.headers),body:n},response:{status:c.status,statusText:c.statusText,headers:Gg(c.headers)},openai:{request:{body:o},response:{}}},m=P2(c.body),A=new Response(m.stream,{status:c.status,statusText:c.statusText,headers:Y5(c.headers)}),h=await hbe.transformResponseIn(A),_=P2(h.body);return Promise.all([m.done,_.done]).then(async([y,S])=>{try{let I=u?est(y):JSON.parse(y),w=u?await LU(S):JSON.parse(S);j5({...g,openai:{...g.openai,response:{body:I}},response:{...g.response,body:w}},f)}catch(I){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Gemini):"+I?.stack)}}).catch(y=>K("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Gemini):"+y)),new Response(_.stream,{status:h.status,statusText:h.statusText,headers:h.headers})}}function Orn(e){return async(t,r)=>{if(!XZ(t,r))return e(t,r);let n=r.body;if(r.body)try{let f=JSON.parse(r.body);n=JSON.stringify(f)}catch{}let i=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 f=await a.text();K(`API error response: ${a.status} ${a.statusText}`,{url:typeof t=="string"?t:t instanceof Qv?t.toString():t.url,status:a.status,errorResponse:f});let g;try{let m=JSON.parse(f);g={type:"error",error:{type:"api_error",message:m.error?.message||m.message||`API error: ${a.statusText}`,code:m.error?.code||m.code||`API_${a.status}_ERROR`}},m.error?.details&&(g.error.details=m.error.details)}catch{g={type:"error",error:{type:"api_error",message:`API error: ${a.statusText}`,code:`API_${a.status}_ERROR`}}}return new Response(JSON.stringify(g),{status:a.status,statusText:a.statusText,headers:{"Content-Type":"application/json"}})}let l=a.clone(),c=!(Object.hasOwn(JSON.parse(n),"stream")&&!JSON.parse(n).stream),u={request:{url:typeof t=="string"?t:t instanceof Qv?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 LU(m)}else u.response.body=await a.json();let g=Gg(r.headers)["x-agent-id"];$z(g,u),qz(g,{request:u.request.body.messages,response:u.response.body.content,usage:u.response.body?.usage})})().catch(f=>K(`\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF:
|
|
761
|
-
Stack trace: `+f.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var ZZ=null,GIe=!1;function krn(){ZZ=null,GIe=!1}gr.on("proxy:changed",krn);function Mrn(){if(GIe)return ZZ;if(GIe=!0,ut().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(ZZ=new vgt.ProxyAgent({uri:e}),Zt(`[proxy] using proxy: ${e}`)),ZZ}function Qrn(){let e=Mrn();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function eX(e){let t=e||process.env.API_TYPE,r=Qrn();switch(t){case"openai":return Rrn(r);case"openai-responses":return Nrn(r);case"gemini":return Brn(r);default:return Orn(r)}}_h();var Urn=X(ge(),1);function xgt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=Prn(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function Prn(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||Lrn(t)?0:Frn(t)?2:1}function Lrn(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function Frn(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=129280&&e<=129535||e>=131072&&e<=262141)}function C_(e){if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),n=(e%6e4/1e3).toFixed(1);return t>0?`${t}h ${r}m ${n}s`:r>0?`${r}m ${n}s`:`${n}s`}function cS(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}ke();fs();var gc={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function tX(e,t){gc.totalCost+=e,gc.totalAPIDuration+=t}function rX(e,t){gc.inputTokens+=e,gc.outputTokens+=t,gr.emit("token:change",{inputTokens:gc.inputTokens,outputTokens:gc.outputTokens})}function nX(e,t){gc.cacheCreationTokens+=e,gc.cacheReadTokens+=t}function YIe(){return{inputTokens:gc.inputTokens,outputTokens:gc.outputTokens,cacheCreationTokens:gc.cacheCreationTokens,cacheReadTokens:gc.cacheReadTokens}}function wgt(){return gc.totalCost}function Dgt(){return Date.now()-gc.startTime}function Rgt(){return gc.totalAPIDuration}function Ngt(e){gc.currentContextTokens=e}function Bgt(){return gc.currentContextTokens}ke();He();He();var VIe="2.4.35";globalThis.MACRO={VERSION:VIe,PACKAGE_URL:`@dahawa/${Ji}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var iX=process.env.HAWA_CODE_USER_AGENT||`${Ji}/${VIe} (${process.env.USER_TYPE})`;import{randomUUID as kE}from"crypto";fs();ke();Wt();Er();ke();He();import{existsSync as x_,readdirSync as man,statSync as gan}from"fs";import{join as pS,relative as Aan}from"path";import{homedir as SEt}from"os";import{platform as han}from"process";import{readFile as mS}from"fs/promises";Er();zg();ar();import{join as zrn,sep as jrn}from"path";function Cm(){if(!bm())return!1;try{let e=ut();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function tp(){return(zrn(Oe(),".hcode","team-memory")+jrn).normalize("NFC")}function I_(e){let t=e.normalize("NFC"),r=tp();return t.startsWith(r)}var IEt=X(r9(),1);Pi();var dTe=(e,t,r)=>{let n=e instanceof RegExp?Jht(e,r):e,i=t instanceof RegExp?Jht(t,r):t,o=n!==null&&i!=null&&isn(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)}},Jht=(e,t)=>{let r=t.match(e);return r?r[0]:null},isn=(e,t,r)=>{let n,i,o,s,a,l=r.indexOf(e),c=r.indexOf(t,l+1),u=l;if(l>=0&&c>0){if(e===t)return[l,c];for(n=[],o=r.length;u>=0&&!a;){if(u===l)n.push(u),l=r.indexOf(e,u+1);else if(n.length===1){let f=n.pop();f!==void 0&&(a=[f,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[o,s])}return a};var Zht="\0SLASH"+Math.random()+"\0",Xht="\0OPEN"+Math.random()+"\0",mTe="\0CLOSE"+Math.random()+"\0",eEt="\0COMMA"+Math.random()+"\0",tEt="\0PERIOD"+Math.random()+"\0",osn=new RegExp(Zht,"g"),ssn=new RegExp(Xht,"g"),asn=new RegExp(mTe,"g"),lsn=new RegExp(eEt,"g"),csn=new RegExp(tEt,"g"),usn=/\\\\/g,dsn=/\\{/g,fsn=/\\}/g,psn=/\\,/g,msn=/\\\./g,gsn=1e5,Asn=4e6;function fTe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function hsn(e){return e.replace(usn,Zht).replace(dsn,Xht).replace(fsn,mTe).replace(psn,eEt).replace(msn,tEt)}function Esn(e){return e.replace(osn,"\\").replace(ssn,"{").replace(asn,"}").replace(lsn,",").replace(csn,".")}function rEt(e){if(!e)return[""];let t=[],r=dTe("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=rEt(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function nEt(e,t={}){if(!e)return[];let{max:r=gsn,maxLength:n=Asn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),pTe(hsn(e),r,n,!0).map(Esn)}function _sn(e){return"{"+e+"}"}function ysn(e){return/^-?0\d/.test(e)}function bsn(e,t){return e<=t}function Csn(e,t){return e>=t}function n9(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 Ssn(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=fTe(i[0]),a=fTe(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(fTe(i[2])),1):1,u=bsn;a<s&&(c*=-1,u=Csn);let g=i.some(ysn),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 pTe(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=dTe("{","}",e);if(!a)return n9(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=n9(i,l+"{"+a.body+"}",[""],t,r,o&&!a.post.length),s=!1,!a.post.length)break;e=a.post;continue}let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),f=c||u,g=a.body.indexOf(",")>=0;if(!f&&!g){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+mTe+a.post,n=!0;continue}return n9(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!f,s=!1);let m;if(f)m=Ssn(a.body,u,t,r);else{let A=rEt(a.body);if(A.length===1&&A[0]!==void 0&&(A=pTe(A[0],t,r,!1).map(_sn),A.length===1)){if(i=n9(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=pTe(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=n9(i,l,m,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var i9=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Isn={"[: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]},o9=e=>e.replace(/[[\]\\-]/g,"\\$&"),Tsn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),iEt=e=>e.join(""),oEt=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,l=!1,c=!1,u=r,f="";e:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===r+1){c=!0,o++;continue}if(h==="]"&&s&&!l){u=o+1;break}if(s=!0,h==="\\"&&!l){l=!0,o++;continue}if(h==="["&&!l){for(let[_,[y,S,I]]of Object.entries(Isn))if(e.startsWith(_,o)){if(f)return["$.",!1,e.length-r,!0];o+=_.length,I?i.push(y):n.push(y),a=a||S;continue e}}if(l=!1,f){h>f?n.push(o9(f)+"-"+o9(h)):h===f&&n.push(o9(h)),f="",o++;continue}if(e.startsWith("-]",o+1)){n.push(o9(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){f=h,o+=2;continue}n.push(o9(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[Tsn(h),!1,u-r,!1]}let g="["+(c?"^":"")+iEt(n)+"]",m="["+(c?"":"^")+iEt(i)+"]";return[n.length&&i.length?"("+g+"|"+m+")":n.length?g:m,a,u-r,!0]};var fS=(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 zd,vsn=new Set(["!","?","+","*","@"]),gTe=e=>vsn.has(e),sEt=e=>gTe(e.type),xsn=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),wsn=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Dsn=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),aEt=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Rsn="(?!(?:^|/)\\.\\.?(?:$|/))",hX="(?!\\.)",Nsn=new Set(["[","."]),Bsn=new Set(["..","."]),Osn=new Set("().*{}+?[]^$\\!"),ksn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ATe="[^/]",lEt=ATe+"*?",cEt=ATe+"+?",Msn=0,Gv=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;id=++Msn;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 zd&&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 zd&&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 zd(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&&gTe(y)&&t.charAt(h)==="("&&o<=s){r.push(_),_="";let I=new zd(y,r);h=zd.#c(t,I,h,i,o+1),r.push(I);continue}_+=y}return r.push(_),h}let f=n+1,g=new zd(null,r),m=[],A="";for(;f<t.length;){let h=t.charAt(f++);if(a||h==="\\"){a=!a,A+=h;continue}if(l){f===c+1?(h==="^"||h==="!")&&(u=!0):h==="]"&&!(f===c+2&&u)&&(l=!1),A+=h;continue}else if(h==="["){l=!0,c=f,u=!1,A+=h;continue}if(!i.noext&&gTe(h)&&t.charAt(f)==="("&&(o<=s||r&&r.#E(h))){let y=r&&r.#E(h)?0:1;g.push(A),A="";let S=new zd(h,g);g.push(S),f=zd.#c(t,S,f,i,o+y);continue}if(h==="|"){g.push(A),A="",m.push(g),g=new zd(null,r);continue}if(h===")")return A===""&&r.#r.length===0&&(r.#p=!0),g.push(A),A="",r.push(...m,g),f;A+=h}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],f}#g(t){return this.#h(t,wsn)}#h(t,r=xsn){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=Dsn){return!!r.get(this.type)?.includes(t)}#A(t,r){let n=t.#r[0],i=new zd(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!!aEt.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=aEt.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 zd(null,void 0,r);return zd.#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()),!sEt(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"?zd.#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&&Bsn.has(this.#r[0]))){let A=Nsn,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?Rsn:_?hX:""}let f="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(f="(?:$|\\/)"),[u+c+f,fS(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,fS(this.toString()),!1,!1]}let s=!n||t||r||!hX?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?hX:"")+cEt;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?hX:"")+lEt+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,fS(o),this.#t=!!this.#t,this.#n]}#_(){if(sEt(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+=(Osn.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?cEt:lEt,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,f,g,m]=oEt(t,l);if(g){o+=u,s=s||f,l+=g-1,r=r||m;continue}}if(c==="?"){o+=ATe,r=!0;continue}o+=ksn(c)}return[o,fS(t),!!r,s]}};zd=Gv;var hTe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var hc=(e,t,r={})=>(i9(t),!r.nocomment&&t.charAt(0)==="#"?!1:new Y2(t,r).match(e)),Qsn=/^\*+([^+@!?*[(]*)$/,Psn=e=>t=>!t.startsWith(".")&&t.endsWith(e),Lsn=e=>t=>t.endsWith(e),Fsn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Usn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Hsn=/^\*+\.\*+$/,$sn=e=>!e.startsWith(".")&&e.includes("."),qsn=e=>e!=="."&&e!==".."&&e.includes("."),Gsn=/^\.\*+$/,zsn=e=>e!=="."&&e!==".."&&e.startsWith("."),jsn=/^\*+$/,Ysn=e=>e.length!==0&&!e.startsWith("."),Vsn=e=>e.length!==0&&e!=="."&&e!=="..",Wsn=/^\?+([^+@!?*[(]*)?$/,Ksn=([e,t=""])=>{let r=fEt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Jsn=([e,t=""])=>{let r=pEt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Zsn=([e,t=""])=>{let r=pEt([e]);return t?n=>r(n)&&n.endsWith(t):r},Xsn=([e,t=""])=>{let r=fEt([e]);return t?n=>r(n)&&n.endsWith(t):r},fEt=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},pEt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},mEt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",uEt={win32:{sep:"\\"},posix:{sep:"/"}},ean=mEt==="win32"?uEt.win32.sep:uEt.posix.sep;hc.sep=ean;var Jc=Symbol("globstar **");hc.GLOBSTAR=Jc;var tan="[^/]",ran=tan+"*?",nan="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",ian="(?:(?!(?:\\/|^)\\.).)*?",oan=(e,t={})=>r=>hc(r,e,t);hc.filter=oan;var Sm=(e,t={})=>Object.assign({},e,t),san=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return hc;let t=hc;return Object.assign((n,i,o={})=>t(n,i,Sm(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,Sm(e,o))}static defaults(i){return t.defaults(Sm(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,Sm(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,Sm(e,o))}},unescape:(n,i={})=>t.unescape(n,Sm(e,i)),escape:(n,i={})=>t.escape(n,Sm(e,i)),filter:(n,i={})=>t.filter(n,Sm(e,i)),defaults:n=>t.defaults(Sm(e,n)),makeRe:(n,i={})=>t.makeRe(n,Sm(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,Sm(e,i)),match:(n,i,o={})=>t.match(n,i,Sm(e,o)),sep:t.sep,GLOBSTAR:Jc})};hc.defaults=san;var gEt=(e,t={})=>(i9(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:nEt(e,{max:t.braceExpandMax}));hc.braceExpand=gEt;var aan=(e,t={})=>new Y2(e,t).makeRe();hc.makeRe=aan;var lan=(e,t,r={})=>{let n=new Y2(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};hc.match=lan;var dEt=/[?*]|[+@!]\(.*?\)|\[|\]/,can=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Y2=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){i9(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||mEt,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]==="?"||!dEt.test(o[2]))&&!dEt.test(o[3]),c=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(c)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let s=this.set[o];s[0]===""&&s[1]===""&&this.globParts[o][2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3])&&(s[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n of t)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let o=n[n.length-1];return i==="**"&&o==="**"?n:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let o=t[i];i===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let s=i;for(;n[s+1]==="**";)s++;s>i&&n.splice(i+1,s-i);let a=n[i+1],l=n[i+2],c=n[i+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let s=1;s<n.length-1;s++){let a=n[s];s===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(s,1),s--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let s=n[o-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let l=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...l),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(i){t[r]=[],t[n]=i;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,o=0,s=[],a="";for(;i<t.length&&o<r.length;)if(t[i]===r[o])s.push(a==="b"?r[o]:t[i]),i++,o++;else if(n&&t[i]==="**"&&r[o]===t[i+1])s.push(t[i]),i++;else if(n&&r[o]==="**"&&t[i]===r[o+1])s.push(r[o]),o++;else if(t[i]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",s.push(t[i]),i++,o++}else if(r[o]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",s.push(r[o]),i++,o++}else return!1;return t.length===r.length&&s}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=0,o=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),l=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),c=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),u=!c&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),f=l?3:a?0:void 0,g=u?3:c?0:void 0;if(typeof f=="number"&&typeof g=="number"){let[m,A]=[t[f],r[g]];m.toLowerCase()===A.toLowerCase()&&(r[g]=m,o=g,i=f)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(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 f=0;if(u.length){if(u.length+i>t.length)return!1;let S=t.length-u.length;if(this.#n(t,u,n,S,0))f=u.length;else{if(t[t.length-1]!==""||i+u.length===t.length||(S--,!this.#n(t,u,n,S,0)))return!1;f=u.length+1}}if(!c.length){let S=!!f;for(let I=i;I<t.length-f;I++){let w=String(t[I]);if(S=!0,w==="."||w===".."||!this.options.dot&&w.startsWith("."))return!1}return n||S}let g=[[[],0]],m=g[0],A=0,h=[0];for(let S of c)S===Jc?(h.push(A),m=[[],0],g.push(m)):(m[0].push(S),A++);let _=g.length-1,y=t.length-f;for(let S of g)S[1]=y-(h[_--]+S[0].length);return!!this.#t(t,g,i,0,n,0,!!f)}#t(t,r,n,i,o,s,a){let l=r[i];if(!l){for(let f=n;f<t.length;f++){a=!0;let g=t[f];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(t.slice(0,n+c.length),c,o,n,0)&&s<this.maxGlobstarRecursion){let m=this.#t(t,r,n+c.length,i+1,o,s+1,a);if(m!==!1)return m}let g=t[n];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1;n++}return o||null}#n(t,r,n,i,o){let s,a,l,c;for(s=i,a=o,c=t.length,l=r.length;s<c&&a<l;s++,a++){this.debug("matchOne loop");let u=r[a],f=t[s];if(this.debug(r,u,f),u===!1||u===Jc)return!1;let g;if(typeof u=="string"?(g=f===u,this.debug("string match",u,f,g)):(g=u.test(f),this.debug("pattern match",u,f,g)),!g)return!1}if(s===c&&a===l)return!0;if(s===c)return n;if(a===l)return s===c-1&&t[s]==="";throw new Error("wtf?")}braceExpand(){return gEt(this.pattern,this.options)}parse(t){i9(t);let r=this.options;if(t==="**")return Jc;if(t==="")return"";let n,i=null;(n=t.match(jsn))?i=r.dot?Vsn:Ysn:(n=t.match(Qsn))?i=(r.nocase?r.dot?Usn:Fsn:r.dot?Lsn:Psn)(n[1]):(n=t.match(Wsn))?i=(r.nocase?r.dot?Jsn:Ksn:r.dot?Zsn:Xsn)(n):(n=t.match(Hsn))?i=r.dot?qsn:$sn:(n=t.match(Gsn))&&(i=zsn);let o=Gv.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?ran:r.dot?nan:ian,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(f=>{if(f instanceof RegExp)for(let g of f.flags.split(""))i.add(g);return typeof f=="string"?can(f):f===Jc?Jc:f._src});c.forEach((f,g)=>{let m=c[g+1],A=c[g-1];f!==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(f=>f!==Jc);if(this.partial&&u.length>=1){let f=[];for(let g=1;g<=u.length;g++)f.push(u.slice(0,g).join("/"));return"(?:"+f.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];o="^"+s+o+a+"$",this.partial&&(o="^(?:\\/|"+s+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let s=i[i.length-1];if(!s)for(let a=i.length-2;!s&&a>=0;a--)s=i[a];for(let a of o){let l=i;if(n.matchBase&&a.length===1&&(l=[s]),this.matchOne(l,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return hc.defaults(t).Minimatch}};hc.AST=Gv;hc.Minimatch=Y2;hc.escape=hTe;hc.unescape=fS;var EEt=X(r9(),1);Er();He();ke();wu();import{readFile as AEt}from"fs/promises";import{existsSync as ETe,readdirSync as uan,statSync as dan}from"fs";import{join as _Te,relative as _Et}from"path";import{homedir as fan}from"os";function hEt(e){try{let t=(0,EEt.default)(e),r=t.data.paths,n=[];return typeof r=="string"?n=r.split(",").map(i=>i.trim()).filter(Boolean):Array.isArray(r)&&(n=r.filter(i=>typeof i=="string")),{paths:n,content:t.content.trim()}}catch(t){return ve(t),{paths:[],content:e.trim()}}}function pan(e,t){return t.length===0?!0:t.some(r=>{try{return hc(e,r,{matchBase:!0,dot:!0})}catch(n){return ve(n),!1}})}function yTe(e){let t=[];try{if(!ETe(e))return t;let r=uan(e);for(let n of r){let i=_Te(e,n),o=dan(i);o.isDirectory()?t.push(...yTe(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){ve(r)}return t}async function EX(){let e=[];try{let t=_Te(fan(),Xr,"rules");if(ETe(t)){let r=yTe(t);for(let n of r)try{let i=await AEt(n,"utf-8"),{paths:o,content:s}=hEt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){ve(i)}}}catch(t){ve(t)}try{let t=_Te(Oe(),Xr,"rules");if(ETe(t)){let r=yTe(t);for(let n of r)try{let i=await AEt(n,"utf-8"),{paths:o,content:s}=hEt(i);o.length>0&&e.push({filePath:_Et(Oe(),n),content:s,paths:o,isProjectRule:!0})}catch(i){ve(i)}}}catch(t){ve(t)}return e}function yEt(e,t){e=FV(e);let r=FV(Oe()),n=e.startsWith(r)?_Et(r,e):e;return t.filter(i=>pan(n,i.paths))}function bEt(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}):
|
|
761
|
+
Stack trace: `+f.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var ZZ=null,GIe=!1;function krn(){ZZ=null,GIe=!1}gr.on("proxy:changed",krn);function Mrn(){if(GIe)return ZZ;if(GIe=!0,ut().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(ZZ=new vgt.ProxyAgent({uri:e}),Zt(`[proxy] using proxy: ${e}`)),ZZ}function Qrn(){let e=Mrn();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function eX(e){let t=e||process.env.API_TYPE,r=Qrn();switch(t){case"openai":return Rrn(r);case"openai-responses":return Nrn(r);case"gemini":return Brn(r);default:return Orn(r)}}_h();var Urn=X(ge(),1);function xgt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=Prn(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function Prn(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||Lrn(t)?0:Frn(t)?2:1}function Lrn(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function Frn(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=129280&&e<=129535||e>=131072&&e<=262141)}function C_(e){if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),n=(e%6e4/1e3).toFixed(1);return t>0?`${t}h ${r}m ${n}s`:r>0?`${r}m ${n}s`:`${n}s`}function cS(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}ke();fs();var gc={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function tX(e,t){gc.totalCost+=e,gc.totalAPIDuration+=t}function rX(e,t){gc.inputTokens+=e,gc.outputTokens+=t,gr.emit("token:change",{inputTokens:gc.inputTokens,outputTokens:gc.outputTokens})}function nX(e,t){gc.cacheCreationTokens+=e,gc.cacheReadTokens+=t}function YIe(){return{inputTokens:gc.inputTokens,outputTokens:gc.outputTokens,cacheCreationTokens:gc.cacheCreationTokens,cacheReadTokens:gc.cacheReadTokens}}function wgt(){return gc.totalCost}function Dgt(){return Date.now()-gc.startTime}function Rgt(){return gc.totalAPIDuration}function Ngt(e){gc.currentContextTokens=e}function Bgt(){return gc.currentContextTokens}ke();He();He();var VIe="2.4.37";globalThis.MACRO={VERSION:VIe,PACKAGE_URL:`@dahawa/${Ji}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var iX=process.env.HAWA_CODE_USER_AGENT||`${Ji}/${VIe} (${process.env.USER_TYPE})`;import{randomUUID as kE}from"crypto";fs();ke();Wt();Er();ke();He();import{existsSync as x_,readdirSync as man,statSync as gan}from"fs";import{join as pS,relative as Aan}from"path";import{homedir as SEt}from"os";import{platform as han}from"process";import{readFile as mS}from"fs/promises";Er();zg();ar();import{join as zrn,sep as jrn}from"path";function Cm(){if(!bm())return!1;try{let e=ut();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function tp(){return(zrn(Oe(),".hcode","team-memory")+jrn).normalize("NFC")}function I_(e){let t=e.normalize("NFC"),r=tp();return t.startsWith(r)}var IEt=X(r9(),1);Pi();var dTe=(e,t,r)=>{let n=e instanceof RegExp?Jht(e,r):e,i=t instanceof RegExp?Jht(t,r):t,o=n!==null&&i!=null&&isn(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)}},Jht=(e,t)=>{let r=t.match(e);return r?r[0]:null},isn=(e,t,r)=>{let n,i,o,s,a,l=r.indexOf(e),c=r.indexOf(t,l+1),u=l;if(l>=0&&c>0){if(e===t)return[l,c];for(n=[],o=r.length;u>=0&&!a;){if(u===l)n.push(u),l=r.indexOf(e,u+1);else if(n.length===1){let f=n.pop();f!==void 0&&(a=[f,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[o,s])}return a};var Zht="\0SLASH"+Math.random()+"\0",Xht="\0OPEN"+Math.random()+"\0",mTe="\0CLOSE"+Math.random()+"\0",eEt="\0COMMA"+Math.random()+"\0",tEt="\0PERIOD"+Math.random()+"\0",osn=new RegExp(Zht,"g"),ssn=new RegExp(Xht,"g"),asn=new RegExp(mTe,"g"),lsn=new RegExp(eEt,"g"),csn=new RegExp(tEt,"g"),usn=/\\\\/g,dsn=/\\{/g,fsn=/\\}/g,psn=/\\,/g,msn=/\\\./g,gsn=1e5,Asn=4e6;function fTe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function hsn(e){return e.replace(usn,Zht).replace(dsn,Xht).replace(fsn,mTe).replace(psn,eEt).replace(msn,tEt)}function Esn(e){return e.replace(osn,"\\").replace(ssn,"{").replace(asn,"}").replace(lsn,",").replace(csn,".")}function rEt(e){if(!e)return[""];let t=[],r=dTe("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=rEt(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function nEt(e,t={}){if(!e)return[];let{max:r=gsn,maxLength:n=Asn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),pTe(hsn(e),r,n,!0).map(Esn)}function _sn(e){return"{"+e+"}"}function ysn(e){return/^-?0\d/.test(e)}function bsn(e,t){return e<=t}function Csn(e,t){return e>=t}function n9(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 Ssn(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=fTe(i[0]),a=fTe(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(fTe(i[2])),1):1,u=bsn;a<s&&(c*=-1,u=Csn);let g=i.some(ysn),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 pTe(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=dTe("{","}",e);if(!a)return n9(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=n9(i,l+"{"+a.body+"}",[""],t,r,o&&!a.post.length),s=!1,!a.post.length)break;e=a.post;continue}let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),f=c||u,g=a.body.indexOf(",")>=0;if(!f&&!g){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+mTe+a.post,n=!0;continue}return n9(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!f,s=!1);let m;if(f)m=Ssn(a.body,u,t,r);else{let A=rEt(a.body);if(A.length===1&&A[0]!==void 0&&(A=pTe(A[0],t,r,!1).map(_sn),A.length===1)){if(i=n9(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=pTe(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=n9(i,l,m,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var i9=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Isn={"[: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]},o9=e=>e.replace(/[[\]\\-]/g,"\\$&"),Tsn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),iEt=e=>e.join(""),oEt=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,l=!1,c=!1,u=r,f="";e:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===r+1){c=!0,o++;continue}if(h==="]"&&s&&!l){u=o+1;break}if(s=!0,h==="\\"&&!l){l=!0,o++;continue}if(h==="["&&!l){for(let[_,[y,S,I]]of Object.entries(Isn))if(e.startsWith(_,o)){if(f)return["$.",!1,e.length-r,!0];o+=_.length,I?i.push(y):n.push(y),a=a||S;continue e}}if(l=!1,f){h>f?n.push(o9(f)+"-"+o9(h)):h===f&&n.push(o9(h)),f="",o++;continue}if(e.startsWith("-]",o+1)){n.push(o9(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){f=h,o+=2;continue}n.push(o9(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[Tsn(h),!1,u-r,!1]}let g="["+(c?"^":"")+iEt(n)+"]",m="["+(c?"":"^")+iEt(i)+"]";return[n.length&&i.length?"("+g+"|"+m+")":n.length?g:m,a,u-r,!0]};var fS=(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 zd,vsn=new Set(["!","?","+","*","@"]),gTe=e=>vsn.has(e),sEt=e=>gTe(e.type),xsn=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),wsn=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),Dsn=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),aEt=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Rsn="(?!(?:^|/)\\.\\.?(?:$|/))",hX="(?!\\.)",Nsn=new Set(["[","."]),Bsn=new Set(["..","."]),Osn=new Set("().*{}+?[]^$\\!"),ksn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ATe="[^/]",lEt=ATe+"*?",cEt=ATe+"+?",Msn=0,Gv=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;id=++Msn;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 zd&&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 zd&&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 zd(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&&gTe(y)&&t.charAt(h)==="("&&o<=s){r.push(_),_="";let I=new zd(y,r);h=zd.#c(t,I,h,i,o+1),r.push(I);continue}_+=y}return r.push(_),h}let f=n+1,g=new zd(null,r),m=[],A="";for(;f<t.length;){let h=t.charAt(f++);if(a||h==="\\"){a=!a,A+=h;continue}if(l){f===c+1?(h==="^"||h==="!")&&(u=!0):h==="]"&&!(f===c+2&&u)&&(l=!1),A+=h;continue}else if(h==="["){l=!0,c=f,u=!1,A+=h;continue}if(!i.noext&&gTe(h)&&t.charAt(f)==="("&&(o<=s||r&&r.#E(h))){let y=r&&r.#E(h)?0:1;g.push(A),A="";let S=new zd(h,g);g.push(S),f=zd.#c(t,S,f,i,o+y);continue}if(h==="|"){g.push(A),A="",m.push(g),g=new zd(null,r);continue}if(h===")")return A===""&&r.#r.length===0&&(r.#p=!0),g.push(A),A="",r.push(...m,g),f;A+=h}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],f}#g(t){return this.#h(t,wsn)}#h(t,r=xsn){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=Dsn){return!!r.get(this.type)?.includes(t)}#A(t,r){let n=t.#r[0],i=new zd(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!!aEt.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=aEt.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 zd(null,void 0,r);return zd.#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()),!sEt(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"?zd.#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&&Bsn.has(this.#r[0]))){let A=Nsn,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?Rsn:_?hX:""}let f="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(f="(?:$|\\/)"),[u+c+f,fS(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,fS(this.toString()),!1,!1]}let s=!n||t||r||!hX?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?hX:"")+cEt;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?hX:"")+lEt+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,fS(o),this.#t=!!this.#t,this.#n]}#_(){if(sEt(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+=(Osn.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?cEt:lEt,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,f,g,m]=oEt(t,l);if(g){o+=u,s=s||f,l+=g-1,r=r||m;continue}}if(c==="?"){o+=ATe,r=!0;continue}o+=ksn(c)}return[o,fS(t),!!r,s]}};zd=Gv;var hTe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var hc=(e,t,r={})=>(i9(t),!r.nocomment&&t.charAt(0)==="#"?!1:new Y2(t,r).match(e)),Qsn=/^\*+([^+@!?*[(]*)$/,Psn=e=>t=>!t.startsWith(".")&&t.endsWith(e),Lsn=e=>t=>t.endsWith(e),Fsn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Usn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Hsn=/^\*+\.\*+$/,$sn=e=>!e.startsWith(".")&&e.includes("."),qsn=e=>e!=="."&&e!==".."&&e.includes("."),Gsn=/^\.\*+$/,zsn=e=>e!=="."&&e!==".."&&e.startsWith("."),jsn=/^\*+$/,Ysn=e=>e.length!==0&&!e.startsWith("."),Vsn=e=>e.length!==0&&e!=="."&&e!=="..",Wsn=/^\?+([^+@!?*[(]*)?$/,Ksn=([e,t=""])=>{let r=fEt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Jsn=([e,t=""])=>{let r=pEt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Zsn=([e,t=""])=>{let r=pEt([e]);return t?n=>r(n)&&n.endsWith(t):r},Xsn=([e,t=""])=>{let r=fEt([e]);return t?n=>r(n)&&n.endsWith(t):r},fEt=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},pEt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},mEt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",uEt={win32:{sep:"\\"},posix:{sep:"/"}},ean=mEt==="win32"?uEt.win32.sep:uEt.posix.sep;hc.sep=ean;var Jc=Symbol("globstar **");hc.GLOBSTAR=Jc;var tan="[^/]",ran=tan+"*?",nan="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",ian="(?:(?!(?:\\/|^)\\.).)*?",oan=(e,t={})=>r=>hc(r,e,t);hc.filter=oan;var Sm=(e,t={})=>Object.assign({},e,t),san=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return hc;let t=hc;return Object.assign((n,i,o={})=>t(n,i,Sm(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,Sm(e,o))}static defaults(i){return t.defaults(Sm(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,Sm(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,Sm(e,o))}},unescape:(n,i={})=>t.unescape(n,Sm(e,i)),escape:(n,i={})=>t.escape(n,Sm(e,i)),filter:(n,i={})=>t.filter(n,Sm(e,i)),defaults:n=>t.defaults(Sm(e,n)),makeRe:(n,i={})=>t.makeRe(n,Sm(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,Sm(e,i)),match:(n,i,o={})=>t.match(n,i,Sm(e,o)),sep:t.sep,GLOBSTAR:Jc})};hc.defaults=san;var gEt=(e,t={})=>(i9(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:nEt(e,{max:t.braceExpandMax}));hc.braceExpand=gEt;var aan=(e,t={})=>new Y2(e,t).makeRe();hc.makeRe=aan;var lan=(e,t,r={})=>{let n=new Y2(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};hc.match=lan;var dEt=/[?*]|[+@!]\(.*?\)|\[|\]/,can=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Y2=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){i9(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||mEt,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]==="?"||!dEt.test(o[2]))&&!dEt.test(o[3]),c=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(c)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let s=this.set[o];s[0]===""&&s[1]===""&&this.globParts[o][2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3])&&(s[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n of t)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let o=n[n.length-1];return i==="**"&&o==="**"?n:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let o=t[i];i===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let s=i;for(;n[s+1]==="**";)s++;s>i&&n.splice(i+1,s-i);let a=n[i+1],l=n[i+2],c=n[i+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let s=1;s<n.length-1;s++){let a=n[s];s===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(s,1),s--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let s=n[o-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let l=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...l),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(i){t[r]=[],t[n]=i;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,o=0,s=[],a="";for(;i<t.length&&o<r.length;)if(t[i]===r[o])s.push(a==="b"?r[o]:t[i]),i++,o++;else if(n&&t[i]==="**"&&r[o]===t[i+1])s.push(t[i]),i++;else if(n&&r[o]==="**"&&t[i]===r[o+1])s.push(r[o]),o++;else if(t[i]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",s.push(t[i]),i++,o++}else if(r[o]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",s.push(r[o]),i++,o++}else return!1;return t.length===r.length&&s}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=0,o=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),l=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),c=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),u=!c&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),f=l?3:a?0:void 0,g=u?3:c?0:void 0;if(typeof f=="number"&&typeof g=="number"){let[m,A]=[t[f],r[g]];m.toLowerCase()===A.toLowerCase()&&(r[g]=m,o=g,i=f)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(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 f=0;if(u.length){if(u.length+i>t.length)return!1;let S=t.length-u.length;if(this.#n(t,u,n,S,0))f=u.length;else{if(t[t.length-1]!==""||i+u.length===t.length||(S--,!this.#n(t,u,n,S,0)))return!1;f=u.length+1}}if(!c.length){let S=!!f;for(let I=i;I<t.length-f;I++){let w=String(t[I]);if(S=!0,w==="."||w===".."||!this.options.dot&&w.startsWith("."))return!1}return n||S}let g=[[[],0]],m=g[0],A=0,h=[0];for(let S of c)S===Jc?(h.push(A),m=[[],0],g.push(m)):(m[0].push(S),A++);let _=g.length-1,y=t.length-f;for(let S of g)S[1]=y-(h[_--]+S[0].length);return!!this.#t(t,g,i,0,n,0,!!f)}#t(t,r,n,i,o,s,a){let l=r[i];if(!l){for(let f=n;f<t.length;f++){a=!0;let g=t[f];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(t.slice(0,n+c.length),c,o,n,0)&&s<this.maxGlobstarRecursion){let m=this.#t(t,r,n+c.length,i+1,o,s+1,a);if(m!==!1)return m}let g=t[n];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1;n++}return o||null}#n(t,r,n,i,o){let s,a,l,c;for(s=i,a=o,c=t.length,l=r.length;s<c&&a<l;s++,a++){this.debug("matchOne loop");let u=r[a],f=t[s];if(this.debug(r,u,f),u===!1||u===Jc)return!1;let g;if(typeof u=="string"?(g=f===u,this.debug("string match",u,f,g)):(g=u.test(f),this.debug("pattern match",u,f,g)),!g)return!1}if(s===c&&a===l)return!0;if(s===c)return n;if(a===l)return s===c-1&&t[s]==="";throw new Error("wtf?")}braceExpand(){return gEt(this.pattern,this.options)}parse(t){i9(t);let r=this.options;if(t==="**")return Jc;if(t==="")return"";let n,i=null;(n=t.match(jsn))?i=r.dot?Vsn:Ysn:(n=t.match(Qsn))?i=(r.nocase?r.dot?Usn:Fsn:r.dot?Lsn:Psn)(n[1]):(n=t.match(Wsn))?i=(r.nocase?r.dot?Jsn:Ksn:r.dot?Zsn:Xsn)(n):(n=t.match(Hsn))?i=r.dot?qsn:$sn:(n=t.match(Gsn))&&(i=zsn);let o=Gv.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?ran:r.dot?nan:ian,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(f=>{if(f instanceof RegExp)for(let g of f.flags.split(""))i.add(g);return typeof f=="string"?can(f):f===Jc?Jc:f._src});c.forEach((f,g)=>{let m=c[g+1],A=c[g-1];f!==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(f=>f!==Jc);if(this.partial&&u.length>=1){let f=[];for(let g=1;g<=u.length;g++)f.push(u.slice(0,g).join("/"));return"(?:"+f.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];o="^"+s+o+a+"$",this.partial&&(o="^(?:\\/|"+s+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let s=i[i.length-1];if(!s)for(let a=i.length-2;!s&&a>=0;a--)s=i[a];for(let a of o){let l=i;if(n.matchBase&&a.length===1&&(l=[s]),this.matchOne(l,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return hc.defaults(t).Minimatch}};hc.AST=Gv;hc.Minimatch=Y2;hc.escape=hTe;hc.unescape=fS;var EEt=X(r9(),1);Er();He();ke();wu();import{readFile as AEt}from"fs/promises";import{existsSync as ETe,readdirSync as uan,statSync as dan}from"fs";import{join as _Te,relative as _Et}from"path";import{homedir as fan}from"os";function hEt(e){try{let t=(0,EEt.default)(e),r=t.data.paths,n=[];return typeof r=="string"?n=r.split(",").map(i=>i.trim()).filter(Boolean):Array.isArray(r)&&(n=r.filter(i=>typeof i=="string")),{paths:n,content:t.content.trim()}}catch(t){return ve(t),{paths:[],content:e.trim()}}}function pan(e,t){return t.length===0?!0:t.some(r=>{try{return hc(e,r,{matchBase:!0,dot:!0})}catch(n){return ve(n),!1}})}function yTe(e){let t=[];try{if(!ETe(e))return t;let r=uan(e);for(let n of r){let i=_Te(e,n),o=dan(i);o.isDirectory()?t.push(...yTe(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){ve(r)}return t}async function EX(){let e=[];try{let t=_Te(fan(),Xr,"rules");if(ETe(t)){let r=yTe(t);for(let n of r)try{let i=await AEt(n,"utf-8"),{paths:o,content:s}=hEt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){ve(i)}}}catch(t){ve(t)}try{let t=_Te(Oe(),Xr,"rules");if(ETe(t)){let r=yTe(t);for(let n of r)try{let i=await AEt(n,"utf-8"),{paths:o,content:s}=hEt(i);o.length>0&&e.push({filePath:_Et(Oe(),n),content:s,paths:o,isProjectRule:!0})}catch(i){ve(i)}}}catch(t){ve(t)}return e}function yEt(e,t){e=FV(e);let r=FV(Oe()),n=e.startsWith(r)?_Et(r,e):e;return t.filter(i=>pan(n,i.paths))}function bEt(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}):
|
|
762
762
|
|
|
763
763
|
${r.content}`}).join(`
|
|
764
764
|
|
|
@@ -1131,7 +1131,7 @@ You are powered by the model ${e}.`}async function Ax(){return s9()?`gitStatus:
|
|
|
1131
1131
|
<context name="${c}">${u}</context>`;let s=i.map(c=>{let u=c.prompt({},t),f=JSON.stringify("inputJSONSchema"in c&&c.inputJSONSchema?c.inputJSONSchema:f0(c.inputSchema));return{name:c.name,description:`${u}
|
|
1132
1132
|
|
|
1133
1133
|
Schema:
|
|
1134
|
-
${f}`}}),{messages:a}=t,l=$dn(o);return qdn(o,l,s,a)}},bbt=Gdn;Yg();var $u=X(ge(),1),IO=X(ge(),1);ke();ke();import{existsSync as zdn,readdirSync as jdn,statSync as Ydn}from"fs";import{join as Vdn}from"path";function Wdn(){let e=Zi.plan();if(!zdn(e))return[];try{return jdn(e).filter(r=>r.endsWith(".md")).map(r=>{let n=Vdn(e,r),i=Ydn(n);return{name:r,path:n,modified:i.mtime}}).sort((r,n)=>n.modified.getTime()-r.modified.getTime())}catch{return[]}}var Cbt=({onSelect:e})=>{let[t,r]=(0,IO.useState)([]),[n,i]=(0,IO.useState)(0),[o,s]=(0,IO.useState)(!1);(0,IO.useEffect)(()=>{let c=Wdn();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}))];er((c,u)=>{if(u.upArrow)i(f=>f>0?f-1:a.length-1);else if(u.downArrow)i(f=>f<a.length-1?f+1:0);else if(u.return){let f=a[n];f&&e(f.value)}else u.escape&&e("__CANCELLED__")});let l=Be();return o?$u.createElement(R,{flexDirection:"column",marginY:1},$u.createElement(R,{marginBottom:1},$u.createElement(v,{bold:!0,color:l.claude},"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),$u.createElement(R,{marginBottom:1},$u.createElement(v,{bold:!0,color:l.claude}," Select a plan to continue, or create a new one")),a.map((c,u)=>{let f=u===n;return $u.createElement(R,{key:c.isNew?"new":c.value,flexDirection:"row",marginLeft:2},$u.createElement(v,{color:f?l.claude:l.text},f?"\u276F":" "),$u.createElement(v,{color:f?l.claude:l.text}," "),$u.createElement(v,{color:f?l.claude:l.text,bold:c.isNew},c.isNew?c.label:c.label.replace(".md","")),!c.isNew&&c.modified&&$u.createElement(v,{dimColor:!0}," ","(",uAe(c.modified),")"))}),$u.createElement(R,{marginTop:1,marginLeft:2},$u.createElement(v,{dimColor:!0},"\u2191/\u2193 to select \xB7 Enter to confirm \xB7 Esc to cancel"))):$u.createElement(R,{flexDirection:"column",marginY:1},$u.createElement(v,null,"Loading plan history..."))};var Sbt=X(ge(),1),Kdn={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):Sbt.createElement(Cbt,{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"}},Ibt=Kdn;Yg();var Jdn={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"}},Tbt=Jdn;Er();import{resolve as Zdn}from"path";var Xdn={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=Oe(),n=Zdn(r,t);fa(n);let i=Oe();return i===r?`Already in ${i}.`:`Changed directory to ${i}/`},userFacingName(){return"cd"}},vbt=Xdn;var n1t=X(ge(),1);var $n=X(ge(),1);var Nfn=X(ge(),1);var q9=X(ge(),1),wfn=X(Rbt(),1);var Nbt={info:"blue",success:"green",error:"red",warning:"yellow"},pfn={styles:{container:({variant:e})=>({flexGrow:1,borderStyle:"round",borderColor:Nbt[e],gap:1,paddingX:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:Nbt[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=Vt.info),e==="success"&&(t=Vt.tick),e==="error"&&(t=Vt.cross),e==="warning"&&(t=Vt.warning),{icon:t}}},Bbt=pfn;var mfn={styles:{container:({color:e})=>({backgroundColor:e}),label:()=>({color:"black"})}},Obt=mfn;var gfn={styles:{input:({isFocused:e})=>({dimColor:!e})}},kbt=gfn;var Afn={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})}},Mbt=Afn;var hfn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})}},Qbt=hfn;var Efn={styles:{container:()=>({flexGrow:1,minWidth:0}),completed:()=>({color:"magenta"}),remaining:()=>({dimColor:!0})},config:()=>({completedCharacter:Vt.square,remainingCharacter:Vt.squareLightShade})},Pbt=Efn;var _fn={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=_fn;var yfn={styles:{container:()=>({gap:1}),frame:()=>({color:"blue"}),label:()=>({})}},Fbt=yfn;var bfn={success:"green",error:"red",warning:"yellow",info:"blue"},Cfn={success:Vt.tick,error:Vt.cross,warning:Vt.warning,info:Vt.info},Sfn={styles:{container:()=>({gap:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:bfn[e]}),message:()=>({})},config:({variant:e})=>({icon:Cfn[e]})},Ubt=Sfn;var Ifn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})},config:()=>({marker:Vt.line})},Hbt=Ifn;var Tfn={styles:{value:()=>({})}},$bt=Tfn;var vfn={styles:{value:()=>({})}},qbt=vfn;var xfn={styles:{value:()=>({})}},Gbt=xfn;var Dfn={components:{Alert:Bbt,Badge:Obt,ConfirmInput:kbt,MultiSelect:Mbt,OrderedList:Qbt,ProgressBar:Pbt,Select:Lbt,Spinner:Fbt,StatusMessage:Ubt,UnorderedList:Hbt,TextInput:$bt,EmailInput:qbt,PasswordInput:Gbt}},Rfn=(0,q9.createContext)(Dfn);var mo=e=>(0,q9.useContext)(Rfn).components[e];var Bfn=X(ge(),1);var Q_=X(ge(),1);var vO=X(ge(),1);var zbt=X(ge(),1);var G9=Vt.line;var Cee=(0,zbt.createContext)({marker:G9});function jbt({children:e}){let{marker:t}=(0,vO.useContext)(Cee),{styles:r}=mo("UnorderedList");return vO.default.createElement(R,{...r.listItem()},vO.default.createElement(v,{...r.marker()},t),vO.default.createElement(R,{...r.content()},e))}var Ybt=X(ge(),1),ixe=(0,Ybt.createContext)({depth:0});function Ofn({children:e}){let{depth:t}=(0,Q_.useContext)(ixe),{styles:r,config:n}=mo("UnorderedList"),i=(0,Q_.useMemo)(()=>({depth:t+1}),[t]),o=(0,Q_.useMemo)(()=>{let{marker:s}=n();return typeof s=="string"?{marker:s}:Array.isArray(s)?{marker:s[t]??s.at(-1)??G9}:{marker:G9}},[n,t]);return Q_.default.createElement(ixe.Provider,{value:i},Q_.default.createElement(Cee.Provider,{value:o},Q_.default.createElement(R,{...r.list()},e)))}Ofn.Item=jbt;var Mfn=X(ge(),1);var kfn=X(ge(),1);var z9=X(ge(),1);var xO=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 Vbt=X(ge(),1);var wO=X(ge(),1);var j9=X(ge(),1);function Wbt({isFocused:e,isSelected:t,children:r}){let{styles:n}=mo("Select");return j9.default.createElement(R,{...n.option({isFocused:e})},e&&j9.default.createElement(v,{...n.focusIndicator()},Vt.pointer),j9.default.createElement(v,{...n.label({isFocused:e,isSelected:t})},r),t&&j9.default.createElement(v,{...n.selectedIndicator()},Vt.tick))}var Dm=X(ge(),1);import{isDeepStrictEqual as Qfn}from"node:util";var Pfn=(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}},Kbt=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=typeof e=="number"?Math.min(e,r.length):r.length,i=new xO(r);return{optionMap:i,visibleOptionCount:n,focusedValue:i.first?.value,visibleFromIndex:0,visibleToIndex:n,previousValue:t,value:t}},Jbt=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n})=>{let[i,o]=(0,Dm.useReducer)(Pfn,{visibleOptionCount:e,defaultValue:r,options:t},Kbt),[s,a]=(0,Dm.useState)(t);t!==s&&!Qfn(t,s)&&(o({type:"reset",state:Kbt({visibleOptionCount:e,defaultValue:r,options:t})}),a(t));let l=(0,Dm.useCallback)(()=>{o({type:"focus-next-option"})},[]),c=(0,Dm.useCallback)(()=>{o({type:"focus-previous-option"})},[]),u=(0,Dm.useCallback)(()=>{o({type:"select-focused-option"})},[]),f=(0,Dm.useMemo)(()=>t.map((g,m)=>({...g,index:m})).slice(i.visibleFromIndex,i.visibleToIndex),[t,i.visibleFromIndex,i.visibleToIndex]);return(0,Dm.useEffect)(()=>{i.value&&i.previousValue!==i.value&&n?.(i.value)},[i.previousValue,i.value,t,n]),{focusedValue:i.focusedValue,visibleFromIndex:i.visibleFromIndex,visibleToIndex:i.visibleToIndex,value:i.value,visibleOptions:f,focusNextOption:l,focusPreviousOption:c,selectFocusedOption:u}};var Zbt=({isDisabled:e=!1,state:t})=>{er((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};function DO({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o}){let s=Jbt({visibleOptionCount:t,options:n,defaultValue:i,onChange:o});Zbt({isDisabled:e,state:s});let{styles:a}=mo("Select");return wO.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=wO.default.createElement(wO.default.Fragment,null,l.label.slice(0,u),wO.default.createElement(v,{...a.highlightedText()},r),l.label.slice(u+r.length))}return wO.default.createElement(Wbt,{key:l.value,isFocused:!e&&s.focusedValue===l.value,isSelected:s.value===l.value},c)}))}var Lfn=X(ge(),1);var Xbt=X(ge(),1);var Ufn=X(ge(),1);var See=X(ge(),1);var Ffn=X(ge(),1);var _Mi=cr.inverse(" ");var Zg=X(ge(),1);var RO=X(ge(),1);var eCt=X(ge(),1);var Iee=(0,eCt.createContext)({marker:Vt.line});function Tee({children:e}){let{marker:t}=(0,RO.useContext)(Iee),{styles:r}=mo("OrderedList");return RO.default.createElement(R,{...r.listItem()},RO.default.createElement(v,{...r.marker()},t),RO.default.createElement(R,{...r.content()},e))}var tCt=X(ge(),1),oxe=(0,tCt.createContext)({marker:""});function Xg({children:e}){let{marker:t}=(0,Zg.useContext)(oxe),{styles:r}=mo("OrderedList"),n=0;for(let o of Zg.default.Children.toArray(e))!(0,Zg.isValidElement)(o)||o.type!==Tee||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!==Tee)return o;let a=`${String(s+1).padStart(i)}.`,l=`${t}${a}`;return Zg.default.createElement(oxe.Provider,{value:{marker:l}},Zg.default.createElement(Iee.Provider,{value:{marker:l}},o))}))}Xg.Item=Tee;var $fn=X(ge(),1);var sxe=X(ge(),1);var Hfn=X(ge(),1);var VMi=cr.inverse(" ");var qfn=X(ge(),1);var Gfn=X(ge(),1);var jfn=X(ge(),1);var vee=X(ge(),1);var zfn=X(ge(),1);var EQi=cr.inverse(" ");var qi=X(ge(),1);var axe=X(ge(),1),lxe=X(ge(),1);l9();fs();Pi();ix();ar();var rCt=process.platform==="darwin"?["\xB7","\u2722","\u2733","\u2217","\u273B","\u273D"]:["\xB7","\u2722","*","\u2217","\u273B","\u273D"];function eA(){let e=[...rCt,...[...rCt].reverse()],{frame:t}=BR({interval:120});return axe.createElement(R,{flexWrap:"nowrap",height:1,width:2},axe.createElement(v,{color:Be().claude},e[t%e.length]))}var Dee=X(ge(),1);var wee=null,P_=null,xee=new Set;function uxe(e){let{columns:t,rows:r}=e;if(t&&r)return{columns:t,rows:r};let n=Zpe();return{columns:t||n.columns||80,rows:r||n.rows||24}}function cxe(){P_&&(wee=uxe(P_),xee.forEach(e=>e(wee)))}function Yfn(e,t){return P_!==e&&(P_&&P_.off("resize",cxe),P_=e,wee=uxe(e),e.on("resize",cxe)),xee.add(t),()=>{xee.delete(t),xee.size===0&&P_&&(P_.off("resize",cxe),P_=null,wee=null)}}function dxe(){let{stdout:e}=Ob(),[t,r]=(0,Dee.useState)(()=>uxe(e));return(0,Dee.useEffect)(()=>Yfn(e,r),[e]),t}function NO(){return dxe()}He();Of();ke();mh();ke();var aLi=X(Bxe(),1);import{homedir as t4}from"os";import{join as kO}from"path";import{existsSync as r4,mkdirSync as zSt,appendFileSync as GSt,readFileSync as jSt,constants as Ggn,writeFileSync as zgn,unlinkSync as YSt,statSync as jgn}from"fs";import{platform as VSt}from"process";import{accessSync as Ygn}from"fs";var qgn="2.4.35",e4={VERSION:qgn,PACKAGE_URL:"@dahawa/hawa-code",README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};He();var Ex=kO(W0,".update.lock"),Vgn=300*1e3;function WSt(){try{if(r4(W0)||zSt(W0,{recursive:!0}),r4(Ex)){let e=jgn(Ex);if(Date.now()-e.mtimeMs<Vgn)return!1;try{YSt(Ex)}catch(r){return ve(`Failed to remove stale lock file: ${r}`),!1}}return zgn(Ex,`${process.pid}`,"utf8"),!0}catch(e){return ve(`Failed to acquire lock: ${e}`),!1}}function KSt(){try{r4(Ex)&&jSt(Ex,"utf8")===`${process.pid}`&&YSt(Ex)}catch(e){ve(`Failed to release lock: ${e}`)}}async function Oxe(){try{let e=await ai("npm -g config get prefix");if(e.code!==0)return ve("Failed to check npm permissions"),{hasPermissions:!1,npmPrefix:null};let t=e.stdout.trim(),r=!1;try{Ygn(t,Ggn.W_OK),r=!0}catch{r=!1}return r?{hasPermissions:!0,npmPrefix:t}:(ve("Insufficient permissions for global npm install."),{hasPermissions:!1,npmPrefix:t})}catch(e){return ve(`Failed to verify npm global install permissions: ${e}`),{hasPermissions:!1,npmPrefix:null}}}async function JSt(e){if(!WSt())throw Et("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:e4.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{r4(e)||zSt(e,{recursive:!0});let t=await ai(`npm -g config set prefix ${e}`);if(t.code!==0)throw new Error(`Failed to set npm prefix: ${t.stderr}`);let r=`
|
|
1134
|
+
${f}`}}),{messages:a}=t,l=$dn(o);return qdn(o,l,s,a)}},bbt=Gdn;Yg();var $u=X(ge(),1),IO=X(ge(),1);ke();ke();import{existsSync as zdn,readdirSync as jdn,statSync as Ydn}from"fs";import{join as Vdn}from"path";function Wdn(){let e=Zi.plan();if(!zdn(e))return[];try{return jdn(e).filter(r=>r.endsWith(".md")).map(r=>{let n=Vdn(e,r),i=Ydn(n);return{name:r,path:n,modified:i.mtime}}).sort((r,n)=>n.modified.getTime()-r.modified.getTime())}catch{return[]}}var Cbt=({onSelect:e})=>{let[t,r]=(0,IO.useState)([]),[n,i]=(0,IO.useState)(0),[o,s]=(0,IO.useState)(!1);(0,IO.useEffect)(()=>{let c=Wdn();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}))];er((c,u)=>{if(u.upArrow)i(f=>f>0?f-1:a.length-1);else if(u.downArrow)i(f=>f<a.length-1?f+1:0);else if(u.return){let f=a[n];f&&e(f.value)}else u.escape&&e("__CANCELLED__")});let l=Be();return o?$u.createElement(R,{flexDirection:"column",marginY:1},$u.createElement(R,{marginBottom:1},$u.createElement(v,{bold:!0,color:l.claude},"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),$u.createElement(R,{marginBottom:1},$u.createElement(v,{bold:!0,color:l.claude}," Select a plan to continue, or create a new one")),a.map((c,u)=>{let f=u===n;return $u.createElement(R,{key:c.isNew?"new":c.value,flexDirection:"row",marginLeft:2},$u.createElement(v,{color:f?l.claude:l.text},f?"\u276F":" "),$u.createElement(v,{color:f?l.claude:l.text}," "),$u.createElement(v,{color:f?l.claude:l.text,bold:c.isNew},c.isNew?c.label:c.label.replace(".md","")),!c.isNew&&c.modified&&$u.createElement(v,{dimColor:!0}," ","(",uAe(c.modified),")"))}),$u.createElement(R,{marginTop:1,marginLeft:2},$u.createElement(v,{dimColor:!0},"\u2191/\u2193 to select \xB7 Enter to confirm \xB7 Esc to cancel"))):$u.createElement(R,{flexDirection:"column",marginY:1},$u.createElement(v,null,"Loading plan history..."))};var Sbt=X(ge(),1),Kdn={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):Sbt.createElement(Cbt,{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"}},Ibt=Kdn;Yg();var Jdn={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"}},Tbt=Jdn;Er();import{resolve as Zdn}from"path";var Xdn={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=Oe(),n=Zdn(r,t);fa(n);let i=Oe();return i===r?`Already in ${i}.`:`Changed directory to ${i}/`},userFacingName(){return"cd"}},vbt=Xdn;var n1t=X(ge(),1);var $n=X(ge(),1);var Nfn=X(ge(),1);var q9=X(ge(),1),wfn=X(Rbt(),1);var Nbt={info:"blue",success:"green",error:"red",warning:"yellow"},pfn={styles:{container:({variant:e})=>({flexGrow:1,borderStyle:"round",borderColor:Nbt[e],gap:1,paddingX:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:Nbt[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=Vt.info),e==="success"&&(t=Vt.tick),e==="error"&&(t=Vt.cross),e==="warning"&&(t=Vt.warning),{icon:t}}},Bbt=pfn;var mfn={styles:{container:({color:e})=>({backgroundColor:e}),label:()=>({color:"black"})}},Obt=mfn;var gfn={styles:{input:({isFocused:e})=>({dimColor:!e})}},kbt=gfn;var Afn={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})}},Mbt=Afn;var hfn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})}},Qbt=hfn;var Efn={styles:{container:()=>({flexGrow:1,minWidth:0}),completed:()=>({color:"magenta"}),remaining:()=>({dimColor:!0})},config:()=>({completedCharacter:Vt.square,remainingCharacter:Vt.squareLightShade})},Pbt=Efn;var _fn={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=_fn;var yfn={styles:{container:()=>({gap:1}),frame:()=>({color:"blue"}),label:()=>({})}},Fbt=yfn;var bfn={success:"green",error:"red",warning:"yellow",info:"blue"},Cfn={success:Vt.tick,error:Vt.cross,warning:Vt.warning,info:Vt.info},Sfn={styles:{container:()=>({gap:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:bfn[e]}),message:()=>({})},config:({variant:e})=>({icon:Cfn[e]})},Ubt=Sfn;var Ifn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})},config:()=>({marker:Vt.line})},Hbt=Ifn;var Tfn={styles:{value:()=>({})}},$bt=Tfn;var vfn={styles:{value:()=>({})}},qbt=vfn;var xfn={styles:{value:()=>({})}},Gbt=xfn;var Dfn={components:{Alert:Bbt,Badge:Obt,ConfirmInput:kbt,MultiSelect:Mbt,OrderedList:Qbt,ProgressBar:Pbt,Select:Lbt,Spinner:Fbt,StatusMessage:Ubt,UnorderedList:Hbt,TextInput:$bt,EmailInput:qbt,PasswordInput:Gbt}},Rfn=(0,q9.createContext)(Dfn);var mo=e=>(0,q9.useContext)(Rfn).components[e];var Bfn=X(ge(),1);var Q_=X(ge(),1);var vO=X(ge(),1);var zbt=X(ge(),1);var G9=Vt.line;var Cee=(0,zbt.createContext)({marker:G9});function jbt({children:e}){let{marker:t}=(0,vO.useContext)(Cee),{styles:r}=mo("UnorderedList");return vO.default.createElement(R,{...r.listItem()},vO.default.createElement(v,{...r.marker()},t),vO.default.createElement(R,{...r.content()},e))}var Ybt=X(ge(),1),ixe=(0,Ybt.createContext)({depth:0});function Ofn({children:e}){let{depth:t}=(0,Q_.useContext)(ixe),{styles:r,config:n}=mo("UnorderedList"),i=(0,Q_.useMemo)(()=>({depth:t+1}),[t]),o=(0,Q_.useMemo)(()=>{let{marker:s}=n();return typeof s=="string"?{marker:s}:Array.isArray(s)?{marker:s[t]??s.at(-1)??G9}:{marker:G9}},[n,t]);return Q_.default.createElement(ixe.Provider,{value:i},Q_.default.createElement(Cee.Provider,{value:o},Q_.default.createElement(R,{...r.list()},e)))}Ofn.Item=jbt;var Mfn=X(ge(),1);var kfn=X(ge(),1);var z9=X(ge(),1);var xO=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 Vbt=X(ge(),1);var wO=X(ge(),1);var j9=X(ge(),1);function Wbt({isFocused:e,isSelected:t,children:r}){let{styles:n}=mo("Select");return j9.default.createElement(R,{...n.option({isFocused:e})},e&&j9.default.createElement(v,{...n.focusIndicator()},Vt.pointer),j9.default.createElement(v,{...n.label({isFocused:e,isSelected:t})},r),t&&j9.default.createElement(v,{...n.selectedIndicator()},Vt.tick))}var Dm=X(ge(),1);import{isDeepStrictEqual as Qfn}from"node:util";var Pfn=(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}},Kbt=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=typeof e=="number"?Math.min(e,r.length):r.length,i=new xO(r);return{optionMap:i,visibleOptionCount:n,focusedValue:i.first?.value,visibleFromIndex:0,visibleToIndex:n,previousValue:t,value:t}},Jbt=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n})=>{let[i,o]=(0,Dm.useReducer)(Pfn,{visibleOptionCount:e,defaultValue:r,options:t},Kbt),[s,a]=(0,Dm.useState)(t);t!==s&&!Qfn(t,s)&&(o({type:"reset",state:Kbt({visibleOptionCount:e,defaultValue:r,options:t})}),a(t));let l=(0,Dm.useCallback)(()=>{o({type:"focus-next-option"})},[]),c=(0,Dm.useCallback)(()=>{o({type:"focus-previous-option"})},[]),u=(0,Dm.useCallback)(()=>{o({type:"select-focused-option"})},[]),f=(0,Dm.useMemo)(()=>t.map((g,m)=>({...g,index:m})).slice(i.visibleFromIndex,i.visibleToIndex),[t,i.visibleFromIndex,i.visibleToIndex]);return(0,Dm.useEffect)(()=>{i.value&&i.previousValue!==i.value&&n?.(i.value)},[i.previousValue,i.value,t,n]),{focusedValue:i.focusedValue,visibleFromIndex:i.visibleFromIndex,visibleToIndex:i.visibleToIndex,value:i.value,visibleOptions:f,focusNextOption:l,focusPreviousOption:c,selectFocusedOption:u}};var Zbt=({isDisabled:e=!1,state:t})=>{er((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};function DO({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o}){let s=Jbt({visibleOptionCount:t,options:n,defaultValue:i,onChange:o});Zbt({isDisabled:e,state:s});let{styles:a}=mo("Select");return wO.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=wO.default.createElement(wO.default.Fragment,null,l.label.slice(0,u),wO.default.createElement(v,{...a.highlightedText()},r),l.label.slice(u+r.length))}return wO.default.createElement(Wbt,{key:l.value,isFocused:!e&&s.focusedValue===l.value,isSelected:s.value===l.value},c)}))}var Lfn=X(ge(),1);var Xbt=X(ge(),1);var Ufn=X(ge(),1);var See=X(ge(),1);var Ffn=X(ge(),1);var _Mi=cr.inverse(" ");var Zg=X(ge(),1);var RO=X(ge(),1);var eCt=X(ge(),1);var Iee=(0,eCt.createContext)({marker:Vt.line});function Tee({children:e}){let{marker:t}=(0,RO.useContext)(Iee),{styles:r}=mo("OrderedList");return RO.default.createElement(R,{...r.listItem()},RO.default.createElement(v,{...r.marker()},t),RO.default.createElement(R,{...r.content()},e))}var tCt=X(ge(),1),oxe=(0,tCt.createContext)({marker:""});function Xg({children:e}){let{marker:t}=(0,Zg.useContext)(oxe),{styles:r}=mo("OrderedList"),n=0;for(let o of Zg.default.Children.toArray(e))!(0,Zg.isValidElement)(o)||o.type!==Tee||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!==Tee)return o;let a=`${String(s+1).padStart(i)}.`,l=`${t}${a}`;return Zg.default.createElement(oxe.Provider,{value:{marker:l}},Zg.default.createElement(Iee.Provider,{value:{marker:l}},o))}))}Xg.Item=Tee;var $fn=X(ge(),1);var sxe=X(ge(),1);var Hfn=X(ge(),1);var VMi=cr.inverse(" ");var qfn=X(ge(),1);var Gfn=X(ge(),1);var jfn=X(ge(),1);var vee=X(ge(),1);var zfn=X(ge(),1);var EQi=cr.inverse(" ");var qi=X(ge(),1);var axe=X(ge(),1),lxe=X(ge(),1);l9();fs();Pi();ix();ar();var rCt=process.platform==="darwin"?["\xB7","\u2722","\u2733","\u2217","\u273B","\u273D"]:["\xB7","\u2722","*","\u2217","\u273B","\u273D"];function eA(){let e=[...rCt,...[...rCt].reverse()],{frame:t}=BR({interval:120});return axe.createElement(R,{flexWrap:"nowrap",height:1,width:2},axe.createElement(v,{color:Be().claude},e[t%e.length]))}var Dee=X(ge(),1);var wee=null,P_=null,xee=new Set;function uxe(e){let{columns:t,rows:r}=e;if(t&&r)return{columns:t,rows:r};let n=Zpe();return{columns:t||n.columns||80,rows:r||n.rows||24}}function cxe(){P_&&(wee=uxe(P_),xee.forEach(e=>e(wee)))}function Yfn(e,t){return P_!==e&&(P_&&P_.off("resize",cxe),P_=e,wee=uxe(e),e.on("resize",cxe)),xee.add(t),()=>{xee.delete(t),xee.size===0&&P_&&(P_.off("resize",cxe),P_=null,wee=null)}}function dxe(){let{stdout:e}=Ob(),[t,r]=(0,Dee.useState)(()=>uxe(e));return(0,Dee.useEffect)(()=>Yfn(e,r),[e]),t}function NO(){return dxe()}He();Of();ke();mh();ke();var aLi=X(Bxe(),1);import{homedir as t4}from"os";import{join as kO}from"path";import{existsSync as r4,mkdirSync as zSt,appendFileSync as GSt,readFileSync as jSt,constants as Ggn,writeFileSync as zgn,unlinkSync as YSt,statSync as jgn}from"fs";import{platform as VSt}from"process";import{accessSync as Ygn}from"fs";var qgn="2.4.37",e4={VERSION:qgn,PACKAGE_URL:"@dahawa/hawa-code",README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};He();var Ex=kO(W0,".update.lock"),Vgn=300*1e3;function WSt(){try{if(r4(W0)||zSt(W0,{recursive:!0}),r4(Ex)){let e=jgn(Ex);if(Date.now()-e.mtimeMs<Vgn)return!1;try{YSt(Ex)}catch(r){return ve(`Failed to remove stale lock file: ${r}`),!1}}return zgn(Ex,`${process.pid}`,"utf8"),!0}catch(e){return ve(`Failed to acquire lock: ${e}`),!1}}function KSt(){try{r4(Ex)&&jSt(Ex,"utf8")===`${process.pid}`&&YSt(Ex)}catch(e){ve(`Failed to release lock: ${e}`)}}async function Oxe(){try{let e=await ai("npm -g config get prefix");if(e.code!==0)return ve("Failed to check npm permissions"),{hasPermissions:!1,npmPrefix:null};let t=e.stdout.trim(),r=!1;try{Ygn(t,Ggn.W_OK),r=!0}catch{r=!1}return r?{hasPermissions:!0,npmPrefix:t}:(ve("Insufficient permissions for global npm install."),{hasPermissions:!1,npmPrefix:t})}catch(e){return ve(`Failed to verify npm global install permissions: ${e}`),{hasPermissions:!1,npmPrefix:null}}}async function JSt(e){if(!WSt())throw Et("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:e4.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{r4(e)||zSt(e,{recursive:!0});let t=await ai(`npm -g config set prefix ${e}`);if(t.code!==0)throw new Error(`Failed to set npm prefix: ${t.stderr}`);let r=`
|
|
1135
1135
|
# npm global path
|
|
1136
1136
|
export PATH="${e}/bin:$PATH"
|
|
1137
1137
|
`;if(VSt==="win32"){let n=await ai(`setx PATH "${process.env.PATH};${e}"`);if(n.code!==0)throw new Error(`Failed to update PATH on Windows: ${n.stderr}`)}else{let n=[kO(t4(),".bashrc"),kO(t4(),".bash_profile"),kO(t4(),".zshrc"),kO(t4(),".config","fish","config.fish")];for(let i of n)if(r4(i))try{if(!jSt(i,"utf8").includes(e)){if(i.includes("fish")){let s=`
|
|
@@ -3393,7 +3393,7 @@ NEVER SUGGEST:
|
|
|
3393
3393
|
Stay silent if the next step isn't obvious from what the user said.
|
|
3394
3394
|
Format: 2-8 words, match the user's style. Or nothing.
|
|
3395
3395
|
Reply with ONLY the suggestion, no quotes or explanation.
|
|
3396
|
-
\u5386\u53F2\u6D88\u606F\u4E2D\u5DE5\u5177\u52A0\u8F7D\u548C\u5378\u8F7D\u6D88\u606F\u4E0D\u9700\u8981\u4F5C\u4E3A\u5EFA\u8BAE\u53C2\u8003\u5185\u5BB9.`,hFe=class{async getSuggestionPrompt(t,r){try{if(r?.aborted)return null;let i=[...ejt()?X7t(t):t,Gt(O6n)],s=(await Ws(jd(i),["You are a helpful assistant that suggests the next user input based on conversation history. keep answers short, 2 to 8 words"],[],r,{model:Lo(),dangerouslySkipPermissions:!1,prependCLISysprompt:!1,thinking:"off"})).message.content,a="";for(let c of s)c.type==="text"&&(a+=c.text);if(a=a.trim(),!a||a==="(no content)")return null;let l=a.trim().split(/[\s\p{P}]+/u).filter(c=>c.length>0).length;return l>20?(K(`Suggestion too long (${l} words): "${a}"`),null):a}catch(n){return K("Error generating suggestion:",n),null}}},k6n=new hFe;mO();ar();function tjt(e){let t={...e};return Object.keys(e).forEach(r=>{let n=e[r];if(typeof n=="string")try{n=pa(n);let i=JSON.parse(n);typeof i=="object"&&i!==null&&(t[r]=i)}catch{}}),t}zh();ke();zg();import{readdir as M6n,readFile as Q6n,stat as P6n}from"fs/promises";import{basename as L6n,join as F6n}from"path";var U6n=200,H6n=30;function $6n(e){let t=/^---\s*\n([\s\S]*?)---\s*\n?/,r=e.match(t);if(!r)return{frontmatter:{},content:e};let n=r[1]||"",i=e.slice(r[0].length),o={},s=n.split(`
|
|
3396
|
+
\u5386\u53F2\u6D88\u606F\u4E2D\u5DE5\u5177\u52A0\u8F7D\u548C\u5378\u8F7D\u6D88\u606F\u4E0D\u9700\u8981\u4F5C\u4E3A\u5EFA\u8BAE\u53C2\u8003\u5185\u5BB9.`,hFe=class{async getSuggestionPrompt(t,r){try{if(r?.aborted)return null;let i=[...ejt()?X7t(t):t,Gt(O6n)],s=(await Ws(jd(i),["You are a helpful assistant that suggests the next user input based on conversation history. keep answers short, 2 to 8 words"],[],r,{model:Lo(),dangerouslySkipPermissions:!1,prependCLISysprompt:!1,thinking:"off",agentId:"suggest\u201D"})).message.content,a="";for(let c of s)c.type==="text"&&(a+=c.text);if(a=a.trim(),!a||a==="(no content)")return null;let l=a.trim().split(/[\s\p{P}]+/u).filter(c=>c.length>0).length;return l>20?(K(`Suggestion too long (${l} words): "${a}"`),null):a}catch(n){return K("Error generating suggestion:",n),null}}},k6n=new hFe;mO();ar();function tjt(e){let t={...e};return Object.keys(e).forEach(r=>{let n=e[r];if(typeof n=="string")try{n=pa(n);let i=JSON.parse(n);typeof i=="object"&&i!==null&&(t[r]=i)}catch{}}),t}zh();ke();zg();import{readdir as M6n,readFile as Q6n,stat as P6n}from"fs/promises";import{basename as L6n,join as F6n}from"path";var U6n=200,H6n=30;function $6n(e){let t=/^---\s*\n([\s\S]*?)---\s*\n?/,r=e.match(t);if(!r)return{frontmatter:{},content:e};let n=r[1]||"",i=e.slice(r[0].length),o={},s=n.split(`
|
|
3397
3397
|
`);for(let a of s){let l=a.trim();if(!l||l.startsWith("#"))continue;let c=l.indexOf(":");if(c===-1)continue;let u=l.slice(0,c).trim(),f=l.slice(c+1).trim();o[u]=f.replace(/['"]/g,"")}return{frontmatter:o,content:i}}async function EFe(e,t){try{let n=(await M6n(e,{recursive:!0})).filter(o=>o.endsWith(".md")&&L6n(o)!=="MEMORY.md");return(await Promise.allSettled(n.map(async o=>{let s=F6n(e,o);if(t.aborted)throw new Error("Aborted");let a=await P6n(s),u=(await Q6n(s,{encoding:"utf-8"})).split(`
|
|
3398
3398
|
`).slice(0,H6n).join(`
|
|
3399
3399
|
`),{frontmatter:f}=$6n(u);return{filename:o,filePath:s,mtimeMs:a.mtimeMs,description:f.description||null,type:mbt(f.type)}}))).filter(o=>o.status==="fulfilled").map(o=>o.value).sort((o,s)=>s.mtimeMs-o.mtimeMs).slice(0,U6n)}catch{return[]}}function _Fe(e){return e.map(t=>{let r=t.type?`[${t.type}] `:"",n=new Date(t.mtimeMs).toISOString();return t.description?`- ${r}${t.filename} (${n}): ${t.description}`:`- ${r}${t.filename} (${n})`}).join(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dahawa/hawa-code",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.37",
|
|
4
4
|
"bin": {
|
|
5
5
|
"hcode": "hawa.js"
|
|
6
6
|
},
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"@statsig/js-client": "^3.26.0",
|
|
28
28
|
"@types/react": "^19.0.0",
|
|
29
29
|
"@types/ws": "^8.18.1",
|
|
30
|
-
"bun": "^1.4.2",
|
|
31
30
|
"cli-highlight": "^2.1.11",
|
|
32
31
|
"cli-table3": "^0.6.5",
|
|
33
32
|
"commander": "^12.0.0",
|