@dahawa/hawa-code 1.40.1 → 1.40.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +4 -4
- package/hands.js +4 -4
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -408,7 +408,7 @@ ${a}., and again, please do not mention this information directly to the user.`:
|
|
|
408
408
|
|
|
409
409
|
${a}. Continue on with the tasks at hand if applicable.`;return this.createReminderMessage("todo","task","medium",u,i)}}dispatchSecurityEvent(){if(!this.sessionState.config.securityReminder)return null;let t=Date.now();return this.sessionState.lastFileAccess>0&&!this.sessionState.remindersSent.has("file_security")?(this.sessionState.remindersSent.add("file_security"),this.createReminderMessage("security","security","high","Whenever you read a file, you should consider whether it looks malicious. If it does, you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer high-level questions about the code behavior.",t)):null}dispatchPerformanceEvent(t){let r=Date.now();return r-$e.getInQueryContext(t).startTime>1800*1e3?this.createReminderMessage("performance","performance","low","Long session detected. Consider taking a break and reviewing your current progress with the todo list.",r):null}getSelectionChanged(t){if(t)return;let r=$e.getInQueryContext(t)[eN];if(typeof r>"u"){let o=ber();o?$e.getInQueryContext(t)[eN]=o:$e.getInQueryContext(t)[eN]={},r=$e.getInQueryContext(t)[eN]}return!r.filePath&&!r.text?null:[this.createReminderMessage("selection_changed","general","medium",`
|
|
410
410
|
The user opened the file ${r.filePath} ${r.text} in the IDE. This may or may not be related to the current task.
|
|
411
|
-
`,Date.now()
|
|
411
|
+
`,Date.now())]}getPlanMode(t,r){if(!t&&!Xn.isPlanMode()||t&&r!=="plan")return null;let n=Xn.getCurrentPlanFilePath(),o=`
|
|
412
412
|
Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make any edits (with the exception of the plan file mentioned below), run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supercedes any other instructions you have received.
|
|
413
413
|
|
|
414
414
|
## Plan File Info:
|
|
@@ -480,7 +480,7 @@ ${c}. Members must communicate with each other using the ${dh} tool`;if(n){u+=`
|
|
|
480
480
|
|
|
481
481
|
Warning: Team "${r}" has ${d.length} active ${f}, so it cannot be deleted.`}u+=`
|
|
482
482
|
|
|
483
|
-
You don't need to keep checking on the team's tool progress\u2014members will notify you when they complete their tasks. Continue with other work or respond to the user instead`}return[this.createReminderMessage("agent_team","task","medium",u,s,!0)]}getContextOptimizationReminder(t,r,n){let o=it.isMessageArchivingEnable(),i=it.isMemoEnable();if(!o&&!i)return null;let s=r??t,a=o&&s?.some(y=>y.name===lp),c=i&&s?.some(y=>y.name===sb);if(!a&&!c)return null;let u
|
|
483
|
+
You don't need to keep checking on the team's tool progress\u2014members will notify you when they complete their tasks. Continue with other work or respond to the user instead`}return[this.createReminderMessage("agent_team","task","medium",u,s,!0)]}getContextOptimizationReminder(t,r,n){let o=it.isMessageArchivingEnable(),i=it.isMemoEnable();if(!o&&!i)return null;let s=r??t,a=o&&s?.some(y=>y.name===lp),c=i&&s?.some(y=>y.name===sb);if(!a&&!c)return null;let u=!0,l=!0,d=Date.now(),f=n?.percentUsed,p=.92*100,A=[];a&&A.push(u?`use ${lp} to archive tool_result messages that are no longer needed for the current task. Do not archive results required for ongoing reasoning`:`load ${lp} with ${gd} to archive old tool_result messages and reduce context usage`),c&&A.push(l?`use ${sb} to persist long analysis conclusions, plans, or error records to keep them out of the context window while remaining retrievable later`:`load ${sb} with ${gd} to persist long conclusions outside the context window`),a&&c&&A.push(`${lp} \u548C ${sb} \u53EF\u4EE5\u914D\u5408\u4F7F\u7528\uFF0C\u4ECE\u800C\u51CF\u5C11\u4E0A\u4E0B\u6587\u4F7F\u7528\u548C\u51CF\u5C11 token \u4F7F\u7528`);let h="";f!==void 0?h=`Context usage is ${f}%. The system will automatically compact prior messages when usage reaches ${p}%. Reduce context usage by: `:h="Reduce context usage by: ";let _=A.length===1?`${h}${A[0]}`:`${h}${A.map(y=>`- ${y}`).join(`
|
|
484
484
|
`)}`;return this.createReminderMessage("message_archiving_context","performance","medium",_,d,!0)}async getToolLazy(t,r,n,o){if(!(it.isLazyToolEnable()&&o===!0))return null;let i=n??await fo.getTools(!1),s=r?.map(A=>A.name)??[],a=new Set(s),c=i.filter(A=>!TS.includes(A.name)&&!a.has(A.name)).map(A=>A.name),u=i.some(A=>A.name===gd),l=i.some(A=>A.name===Ad),d=u?`Load them with ${gd} if needed; call it in parallel with other tools when possible.`:"",f=l?`Unload tools you no longer need with ${Ad}; call it in parallel with other tools when possible. You do not need to unload if you are returning results to the user.`:"",p=`Available but not loaded tools: ${c.length?c.join(", ")+". "+d:"none."}
|
|
485
485
|
Loaded tools: ${s.length?s.join(", ")+". "+f:"none."}`;return[this.createReminderMessage("tool","general","high",p,Date.now())]}getRecalledMemories(t){let n=$e.getQueryContext(t).recalledMemories;if(!n||n.length===0)return null;let o=Date.now(),s=`The following memories were recalled and may be relevant to the current task. Use them only if they are helpful:
|
|
486
486
|
|
|
@@ -668,7 +668,7 @@ globstar while`,t,f,r,p,A),this.matchOne(t.slice(f),r.slice(p),n))return this.de
|
|
|
668
668
|
`)),zNn(e,o,{encoding:r,flush:!0})}var jUt=new lue.default({fetchMethod:e=>tOn(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});async function t3t(e){let t=Hq(e);return jUt.get(t)||jUt.fetchMethod?.(t)}async function tOn(e){let t=new AbortController;setTimeout(()=>{t.abort()},1e3);let r=await jOt(e,t.signal,15),n=0;for(let o of r)AO(o)==="CRLF"&&n++;return n>3?"CRLF":"LF"}function r3t(e,t,r){if(e.has(t))return e.get(t);let n=r();return e.set(t,n),n}var rOn=new lue.default({fetchMethod:e=>n3t(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});function Tm(e){let t=Hq(e);return r3t(rOn,t,()=>n3t(t))}function n3t(e){let r=Buffer.alloc(4096),n;try{n=zUt(e,"r");let o=WUt(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 he(`Error detecting encoding for file ${e}: ${o}`),"utf8"}finally{n&&KUt(n)}}var nOn=new lue.default({fetchMethod:e=>o3t(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});function AO(e){let t=Hq(e);return r3t(nOn,t,()=>o3t(t))}function o3t(e,t="utf8"){try{if(!JUt(e).isFile())return"LF";let n=Buffer.alloc(4096),o=zUt(e,"r"),i=WUt(o,n,0,4096,0);KUt(o);let s=n.toString(t,0,i),a=0,c=0;for(let u=0;u<s.length;u++)s[u]===`
|
|
669
669
|
`&&(u>0&&s[u-1]==="\r"?a++:c++);return a>c?"CRLF":"LF"}catch(r){return he(`Error detecting line endings for file ${e}: ${r}`),"LF"}}function RMe(e){let t=ZUt(e)?e:Hq(Me(),e);return t.endsWith(" AM.png")?t.replace(" AM.png","\u202FAM.png"):t.endsWith(" PM.png")?t.replace(" PM.png","\u202FPM.png"):t}function wMe(e){return e?ZUt(e)?e:Hq(Me(),e):void 0}function i3t(e){try{let t=wMe(e),r=t?ZNn(Me(),t):void 0;return{absolutePath:t,relativePath:r}}catch(t){return pe("getAbsoluteAndRelativePaths error ",t),{absolutePath:null,relativePath:null}}}function fue(e){try{let t=XNn(e),r=$Ut(e,VUt(e));if(!WNn(t))return;let i=KNn(t).filter(s=>$Ut(s,VUt(s))===r&&eOn(t,s)!==e)[0];return i||void 0}catch(t){he(`Error finding similar file for ${e}: ${t}`);return}}function NMe(){let e=process.env.HAWA_CODE_COMPACT_LINE_PREFIX;return!(e==="0"||e==="false")}function cx({content:e,startLine:t}){if(!e)return"";let r=e.split(/\r?\n/);return NMe()?r.map((n,o)=>`${o+t} ${n}`).join(`
|
|
670
670
|
`):r.map((n,o)=>{let i=String(o+t);return i.length>=6?`${i}\u2192${n}`:`${i.padStart(6," ")}\u2192${n}`}).join(`
|
|
671
|
-
`)}function s3t(e){try{let t=JNn(e),r=t.readSync();return t.closeSync(),r===null}catch(t){return he(`Error checking directory: ${t}`),!1}}Le();function ox(){let e=On();e.hasCompletedProjectOnboarding||vi({...e,hasCompletedProjectOnboarding:!0})}function aOn(){let e=ur();po({...e,lastReleaseNotesSeen:MACRO.VERSION})}function OMe({workspaceDir:e}){let r=!On().hasCompletedProjectOnboarding,o=ur().lastReleaseNotesSeen,i=[];(!o||(0,a3t.gt)(MACRO.VERSION,o))&&(i=wce[MACRO.VERSION]||[]);let s=i.length>0;if(Pi.useEffect(()=>{s&&!r&&aOn()},[s,r]),!r&&!s)return null;let a=oOn(iOn(e,ui)),c=s3t(e),u=!a&&!c,l=CQ.isEnabled&&!ur().shiftEnterKeyBindingInstalled,d=K();return Pi.createElement(D,{flexDirection:"column",gap:1,padding:1,paddingBottom:0},r&&Pi.createElement(Pi.Fragment,null,Pi.createElement(C,{color:d.secondaryText},"Tips for getting started:"),Pi.createElement(Cd,{children:[]},(()=>{let f=[];return c&&f.push(Pi.createElement(Cd.Item,{key:"workspace"},Pi.createElement(C,{color:d.secondaryText},"Ask ",ze," to create a new app or clone a repository."))),u&&f.push(Pi.createElement(Cd.Item,{key:"claudemd"},Pi.createElement(C,{color:d.secondaryText},"Run ",Pi.createElement(C,{color:d.text},"/init")," to create a",ui," file with instructions for Hawa code."))),l&&f.push(Pi.createElement(Cd.Item,{key:"terminal"},Pi.createElement(C,{color:d.secondaryText},"Run ",Pi.createElement(C,{color:d.text},"/terminal-setup"),Pi.createElement(C,{bold:!1}," to set up terminal integration")))),f.push(Pi.createElement(Cd.Item,{key:"questions"},Pi.createElement(C,{color:d.secondaryText},"Ask ",ze," questions about your codebase."))),f.push(Pi.createElement(Cd.Item,{key:"changes"},Pi.createElement(C,{color:d.secondaryText},"Ask ",ze," to implement changes to your codebase."))),f})())),!r&&s&&Pi.createElement(D,{borderColor:K().secondaryBorder,flexDirection:"column",marginRight:1},Pi.createElement(D,{flexDirection:"column",gap:0},Pi.createElement(D,{marginBottom:1},Pi.createElement(C,null,"\u{1F195} What's new in v",MACRO.VERSION,":")),Pi.createElement(D,{flexDirection:"column",marginLeft:1},i.map((f,p)=>Pi.createElement(C,{key:p,color:K().secondaryText},"\u2022 ",f))))),e===sOn()&&Pi.createElement(C,{color:K().warning},"Note: You have launched ",Pi.createElement(C,{bold:!0},ze)," in your home directory. For the best experience, launch it in a project directory instead."))}var UQ=U(ne(),1);var QQ=U(ne(),1);var Gq=U(ne(),1);function BMe({isFocused:e,isSelected:t,smallPointer:r,children:n}){let{styles:o}=Ki("Select");return Gq.default.createElement(D,{...o.option({isFocused:e})},e&&Gq.default.createElement(C,{...o.focusIndicator()},r?Vr.triangleDownSmall:Vr.pointer),Gq.default.createElement(C,{...o.label({isFocused:e,isSelected:t})},n),t&&Gq.default.createElement(C,{...o.selectedIndicator()},Vr.tick))}var bm=U(ne(),1);import{isDeepStrictEqual as cOn}from"node:util";var qq=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:MMe(s);r.push([c,a]),i++,o=a}super(r),this.first=n}};var uOn=(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}}},kMe=e=>e.flatMap(t=>{if("options"in t){let r=kMe(t.options),n=r.flatMap(i=>"value"in i?i.value:[]);return[...t.header!==void 0?[{header:t.header,optionValues:n}]:[],...r]}return t}),c3t=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=kMe(r),o=typeof e=="number"?Math.min(e,n.length):n.length,i=new qq(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}},PMe=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n,onFocus:o,focusValue:i})=>{let s=kMe(t),[a,c]=(0,bm.useReducer)(uOn,{visibleOptionCount:e,defaultValue:r,options:t},c3t),[u,l]=(0,bm.useState)(s);s!==u&&!cOn(s,u)&&(c({type:"reset",state:c3t({visibleOptionCount:e,defaultValue:r,options:t})}),l(s));let d=(0,bm.useCallback)(()=>{c({type:"focus-next-option"})},[]),f=(0,bm.useCallback)(()=>{c({type:"focus-previous-option"})},[]),p=(0,bm.useCallback)(()=>{c({type:"select-focused-option"})},[]),A=(0,bm.useMemo)(()=>s.map((h,_)=>({...h,index:_})).slice(a.visibleFromIndex,a.visibleToIndex),[s,a.visibleFromIndex,a.visibleToIndex]);return(0,bm.useEffect)(()=>{a.value&&a.previousValue!==a.value&&n?.(a.value)},[a.previousValue,a.value,t,n]),(0,bm.useEffect)(()=>{a.focusedValue&&o?.(a.focusedValue)},[a.focusedValue,o]),(0,bm.useEffect)(()=>{i&&c({type:"set-focus",value:i})},[i]),{focusedValue:a.focusedValue,visibleFromIndex:a.visibleFromIndex,visibleToIndex:a.visibleToIndex,value:a.value,visibleOptions:A,focusNextOption:d,focusPreviousOption:f,selectFocusedOption:p}};var LMe=({isDisabled:e=!1,state:t})=>{vt((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};var MMe=e=>`HEADER-${e.optionValues.join(",")}`;function Ub({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a}){let c=PMe({visibleOptionCount:t,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a});LMe({isDisabled:e,state:c});let{styles:u}=Ki("Select");return QQ.default.createElement(D,{...u.container()},c.visibleOptions.map(l=>{let d="value"in l?l.value:MMe(l),f=!e&&c.focusedValue!==void 0&&("value"in l?c.focusedValue===l.value:l.optionValues.includes(c.focusedValue)),p=!!c.value&&("value"in l?c.value===l.value:l.optionValues.includes(c.value)),A="header"in l,h="label"in l?l.label:l.header,_=h;if(r&&h.includes(r)){let y=h.indexOf(r);_=QQ.default.createElement(QQ.default.Fragment,null,h.slice(0,y),QQ.default.createElement(C,{...u.highlightedText()},r),h.slice(y+r.length))}return QQ.default.createElement(BMe,{key:d,isFocused:f,isSelected:p,smallPointer:A},_)}))}function u3t({onDone:e}){return vt((t,r)=>{(r.ctrl&&(t==="c"||t==="d")||r.escape)&&e()}),UQ.default.createElement(D,{flexDirection:"column",borderStyle:"round",padding:1,borderColor:K().secondaryBorder},UQ.default.createElement(D,{marginBottom:1,flexDirection:"column"},UQ.default.createElement(C,{bold:!0},"You've spent $5 this session.")),UQ.default.createElement(D,null,UQ.default.createElement(Ub,{options:[{value:"ok",label:"Got it, thanks!"}],onChange:e})))}var bn=U(ne(),1),dr=U(ne(),1);var hp=U(ne(),1);Le();Sr();Le();Ne();import lOn from"os";import dOn from"path";import $q from"fs";var fOn={sources:{},routing:{}};function f3t(){let e=lOn.homedir();return dOn.join(e,Cn,"config.json")}function l3t(){try{let e=f3t();if(!$q.existsSync(e))return fOn;let t=$q.readFileSync(e,"utf-8"),r=JSON.parse(t);return r.sources&&r.routing?r:pOn(r)}catch(e){throw he(e),e}}function pOn(e){let t={},r={};for(let[n,o]of Object.entries(e))if(o?.enable===!0&&o?.env){let i=o.env,s=n;t[s]={base_url:i.BASE_URL||"",auth_token:i.AUTH_TOKEN||"",api_type:i.API_TYPE||"anthropic",models:[]},i.MODEL&&(r.MODEL=[{source:s,model:i.MODEL,weight:100}],t[s].models.push(i.MODEL)),i.SMALL_FAST_MODEL&&(r.SMALL_FAST_MODEL=[{source:s,model:i.SMALL_FAST_MODEL,weight:100}],t[s].models.includes(i.SMALL_FAST_MODEL)||t[s].models.push(i.SMALL_FAST_MODEL));break}return{sources:t,routing:r}}function d3t(e){if(e.length===0)throw new Error("No items to select from");if(e.length===1)return e[0];let t=e.reduce((n,o)=>n+(o.weight??100),0),r=Math.random()*t;for(let n of e){let o=n.weight??100;if(r-=o,r<=0)return n}return e[e.length-1]}var FMe=class{config;constructor(){try{this.config=l3t()}catch(t){console.log(t)}}reload(){this.config=l3t()}getConfig(){return this.config}hasModelRouting(){return!!(this.config.routing?.MODEL&&this.config.routing.MODEL.length>0)}getModelRoutingModels(){let t=this.config.routing?.MODEL;return!t||t.length===0?[]:t.map(r=>r.model)}hasSmallFastModelRouting(){return!!(this.config.routing?.SMALL_FAST_MODEL&&this.config.routing.SMALL_FAST_MODEL.length>0)}getModel(){let t=this.config.routing?.MODEL;if(!t||t.length===0)throw new Error("No MODEL routing configuration found");let r=d3t(t);return`${r.source}__${r.model}`}getSmallFastModel(){let t=this.config.routing?.SMALL_FAST_MODEL;if(!t||t.length===0)throw new Error("No SMALL_FAST_MODEL routing configuration found");let r=d3t(t);return`${r.source}__${r.model}`}getSourceConfig(t){return this.config.sources?.[t]}parseModelKey(t){let r=t.indexOf("__");return r===-1?{source:"",model:t}:{source:t.slice(0,r),model:t.slice(r+2)}}getModelSourceConfig(t){let{source:r}=this.parseModelKey(t);if(r)return this.getSourceConfig(r)}setModelRouting(t){this.config.routing.MODEL=t,this.saveConfig()}setSmallFastModelRouting(t){this.config.routing.SMALL_FAST_MODEL=t,this.saveConfig()}getAvailableModels(){let t=[];for(let[r,n]of Object.entries(this.config.sources||{}))for(let o of n.models||[])t.push(`${r}__${o}`);return t}saveConfig(){try{let t=f3t(),r={};if($q.existsSync(t)){let o=$q.readFileSync(t,"utf-8");r=JSON.parse(o)}let n={...r,sources:this.config.sources,routing:this.config.routing};$q.writeFileSync(t,JSON.stringify(n,null,2))}catch(t){he(t)}}},Ho=new FMe;var mOn="1.40.1",$S={VERSION:mOn,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 QMe=46,p3t=["(\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 pue({isDefaultModel:e=!1}){let t=Math.max(QMe,Me().length+12),r=K(),n=p3t[Math.floor(Math.random()*p3t.length)];return hp.createElement(D,{flexDirection:"column"},hp.createElement(D,{flexDirection:"column",gap:1,paddingLeft:1,width:"100%"},hp.createElement(C,null,hp.createElement(C,null,n)," Welcome to"," ",hp.createElement(C,{bold:!0},ze),hp.createElement(C,{color:r.secondaryText}," v",$S.VERSION)),hp.createElement(hp.Fragment,null,hp.createElement(D,{paddingLeft:2,flexDirection:"column",gap:1},hp.createElement(C,{color:r.secondaryText,italic:!0},"/help for help"),hp.createElement(C,{color:r.secondaryText},"cwd: ",Me()),hp.createElement(C,{color:r.secondaryText},"model: ",Ho.getConfig().routing.MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A"),hp.createElement(C,{color:r.secondaryText},"small fast model: ",Ho.getConfig().routing.SMALL_FAST_MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A")))))}var N0=U(ne(),1);Ne();var WW=U(ne(),1);import{randomUUID as x0}from"crypto";var m3t=()=>[],g3t=()=>{};function A3t(e){m3t=e}function mue(){return m3t}function h3t(e){g3t=e}function E3t(){return g3t}Ne();Xt();Sr();Ne();Le();import{existsSync as qb,readdirSync as L2n,statSync as F2n}from"fs";import{join as dx,relative as Q2n}from"path";import{homedir as V9t}from"os";import{platform as U2n}from"process";import{readFile as fx}from"fs/promises";Sr();VS();Ir();import{join as SOn,sep as yOn}from"path";function Ep(){if(!Cm())return!1;try{let e=Tt();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function Im(){return(SOn(Me(),".hcode","team-memory")+yOn).normalize("NFC")}function qQ(e){let t=e.normalize("NFC"),r=Im();return t.startsWith(r)}var Y9t=U(Xq(),1);Uo();var H9t=U(Xq(),1);Sr();Le();Ne();pp();import{readFile as Q9t}from"fs/promises";import{existsSync as n2e,readdirSync as B2n,statSync as M2n}from"fs";import{join as o2e,relative as G9t}from"path";import{homedir as k2n}from"os";function U9t(e){try{let t=(0,H9t.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 he(t),{paths:[],content:e.trim()}}}function P2n(e,t){return t.length===0?!0:t.some(r=>{try{return vd(e,r,{matchBase:!0,dot:!0})}catch(n){return he(n),!1}})}function i2e(e){let t=[];try{if(!n2e(e))return t;let r=B2n(e);for(let n of r){let o=o2e(e,n),i=M2n(o);i.isDirectory()?t.push(...i2e(o)):i.isFile()&&n.endsWith(".md")&&t.push(o)}}catch(r){he(r)}return t}async function q9t(){let e=[];try{let t=o2e(k2n(),Cn,"rules");if(n2e(t)){let r=i2e(t);for(let n of r)try{let o=await Q9t(n,"utf-8"),{paths:i,content:s}=U9t(o);i.length>0&&e.push({filePath:n,content:s,paths:i,isProjectRule:!1})}catch(o){he(o)}}}catch(t){he(t)}try{let t=o2e(Me(),Cn,"rules");if(n2e(t)){let r=i2e(t);for(let n of r)try{let o=await Q9t(n,"utf-8"),{paths:i,content:s}=U9t(o);i.length>0&&e.push({filePath:G9t(Me(),n),content:s,paths:i,isProjectRule:!0})}catch(o){he(o)}}}catch(t){he(t)}return e}function $9t(e,t){e=dae(e);let r=dae(Me()),n=e.startsWith(r)?G9t(r,e):e;return t.filter(o=>P2n(n,o.paths))}var H2n=`# hawaCodeMd
|
|
671
|
+
`)}function s3t(e){try{let t=JNn(e),r=t.readSync();return t.closeSync(),r===null}catch(t){return he(`Error checking directory: ${t}`),!1}}Le();function ox(){let e=On();e.hasCompletedProjectOnboarding||vi({...e,hasCompletedProjectOnboarding:!0})}function aOn(){let e=ur();po({...e,lastReleaseNotesSeen:MACRO.VERSION})}function OMe({workspaceDir:e}){let r=!On().hasCompletedProjectOnboarding,o=ur().lastReleaseNotesSeen,i=[];(!o||(0,a3t.gt)(MACRO.VERSION,o))&&(i=wce[MACRO.VERSION]||[]);let s=i.length>0;if(Pi.useEffect(()=>{s&&!r&&aOn()},[s,r]),!r&&!s)return null;let a=oOn(iOn(e,ui)),c=s3t(e),u=!a&&!c,l=CQ.isEnabled&&!ur().shiftEnterKeyBindingInstalled,d=K();return Pi.createElement(D,{flexDirection:"column",gap:1,padding:1,paddingBottom:0},r&&Pi.createElement(Pi.Fragment,null,Pi.createElement(C,{color:d.secondaryText},"Tips for getting started:"),Pi.createElement(Cd,{children:[]},(()=>{let f=[];return c&&f.push(Pi.createElement(Cd.Item,{key:"workspace"},Pi.createElement(C,{color:d.secondaryText},"Ask ",ze," to create a new app or clone a repository."))),u&&f.push(Pi.createElement(Cd.Item,{key:"claudemd"},Pi.createElement(C,{color:d.secondaryText},"Run ",Pi.createElement(C,{color:d.text},"/init")," to create a",ui," file with instructions for Hawa code."))),l&&f.push(Pi.createElement(Cd.Item,{key:"terminal"},Pi.createElement(C,{color:d.secondaryText},"Run ",Pi.createElement(C,{color:d.text},"/terminal-setup"),Pi.createElement(C,{bold:!1}," to set up terminal integration")))),f.push(Pi.createElement(Cd.Item,{key:"questions"},Pi.createElement(C,{color:d.secondaryText},"Ask ",ze," questions about your codebase."))),f.push(Pi.createElement(Cd.Item,{key:"changes"},Pi.createElement(C,{color:d.secondaryText},"Ask ",ze," to implement changes to your codebase."))),f})())),!r&&s&&Pi.createElement(D,{borderColor:K().secondaryBorder,flexDirection:"column",marginRight:1},Pi.createElement(D,{flexDirection:"column",gap:0},Pi.createElement(D,{marginBottom:1},Pi.createElement(C,null,"\u{1F195} What's new in v",MACRO.VERSION,":")),Pi.createElement(D,{flexDirection:"column",marginLeft:1},i.map((f,p)=>Pi.createElement(C,{key:p,color:K().secondaryText},"\u2022 ",f))))),e===sOn()&&Pi.createElement(C,{color:K().warning},"Note: You have launched ",Pi.createElement(C,{bold:!0},ze)," in your home directory. For the best experience, launch it in a project directory instead."))}var UQ=U(ne(),1);var QQ=U(ne(),1);var Gq=U(ne(),1);function BMe({isFocused:e,isSelected:t,smallPointer:r,children:n}){let{styles:o}=Ki("Select");return Gq.default.createElement(D,{...o.option({isFocused:e})},e&&Gq.default.createElement(C,{...o.focusIndicator()},r?Vr.triangleDownSmall:Vr.pointer),Gq.default.createElement(C,{...o.label({isFocused:e,isSelected:t})},n),t&&Gq.default.createElement(C,{...o.selectedIndicator()},Vr.tick))}var bm=U(ne(),1);import{isDeepStrictEqual as cOn}from"node:util";var qq=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:MMe(s);r.push([c,a]),i++,o=a}super(r),this.first=n}};var uOn=(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}}},kMe=e=>e.flatMap(t=>{if("options"in t){let r=kMe(t.options),n=r.flatMap(i=>"value"in i?i.value:[]);return[...t.header!==void 0?[{header:t.header,optionValues:n}]:[],...r]}return t}),c3t=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=kMe(r),o=typeof e=="number"?Math.min(e,n.length):n.length,i=new qq(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}},PMe=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n,onFocus:o,focusValue:i})=>{let s=kMe(t),[a,c]=(0,bm.useReducer)(uOn,{visibleOptionCount:e,defaultValue:r,options:t},c3t),[u,l]=(0,bm.useState)(s);s!==u&&!cOn(s,u)&&(c({type:"reset",state:c3t({visibleOptionCount:e,defaultValue:r,options:t})}),l(s));let d=(0,bm.useCallback)(()=>{c({type:"focus-next-option"})},[]),f=(0,bm.useCallback)(()=>{c({type:"focus-previous-option"})},[]),p=(0,bm.useCallback)(()=>{c({type:"select-focused-option"})},[]),A=(0,bm.useMemo)(()=>s.map((h,_)=>({...h,index:_})).slice(a.visibleFromIndex,a.visibleToIndex),[s,a.visibleFromIndex,a.visibleToIndex]);return(0,bm.useEffect)(()=>{a.value&&a.previousValue!==a.value&&n?.(a.value)},[a.previousValue,a.value,t,n]),(0,bm.useEffect)(()=>{a.focusedValue&&o?.(a.focusedValue)},[a.focusedValue,o]),(0,bm.useEffect)(()=>{i&&c({type:"set-focus",value:i})},[i]),{focusedValue:a.focusedValue,visibleFromIndex:a.visibleFromIndex,visibleToIndex:a.visibleToIndex,value:a.value,visibleOptions:A,focusNextOption:d,focusPreviousOption:f,selectFocusedOption:p}};var LMe=({isDisabled:e=!1,state:t})=>{vt((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};var MMe=e=>`HEADER-${e.optionValues.join(",")}`;function Ub({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a}){let c=PMe({visibleOptionCount:t,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a});LMe({isDisabled:e,state:c});let{styles:u}=Ki("Select");return QQ.default.createElement(D,{...u.container()},c.visibleOptions.map(l=>{let d="value"in l?l.value:MMe(l),f=!e&&c.focusedValue!==void 0&&("value"in l?c.focusedValue===l.value:l.optionValues.includes(c.focusedValue)),p=!!c.value&&("value"in l?c.value===l.value:l.optionValues.includes(c.value)),A="header"in l,h="label"in l?l.label:l.header,_=h;if(r&&h.includes(r)){let y=h.indexOf(r);_=QQ.default.createElement(QQ.default.Fragment,null,h.slice(0,y),QQ.default.createElement(C,{...u.highlightedText()},r),h.slice(y+r.length))}return QQ.default.createElement(BMe,{key:d,isFocused:f,isSelected:p,smallPointer:A},_)}))}function u3t({onDone:e}){return vt((t,r)=>{(r.ctrl&&(t==="c"||t==="d")||r.escape)&&e()}),UQ.default.createElement(D,{flexDirection:"column",borderStyle:"round",padding:1,borderColor:K().secondaryBorder},UQ.default.createElement(D,{marginBottom:1,flexDirection:"column"},UQ.default.createElement(C,{bold:!0},"You've spent $5 this session.")),UQ.default.createElement(D,null,UQ.default.createElement(Ub,{options:[{value:"ok",label:"Got it, thanks!"}],onChange:e})))}var bn=U(ne(),1),dr=U(ne(),1);var hp=U(ne(),1);Le();Sr();Le();Ne();import lOn from"os";import dOn from"path";import $q from"fs";var fOn={sources:{},routing:{}};function f3t(){let e=lOn.homedir();return dOn.join(e,Cn,"config.json")}function l3t(){try{let e=f3t();if(!$q.existsSync(e))return fOn;let t=$q.readFileSync(e,"utf-8"),r=JSON.parse(t);return r.sources&&r.routing?r:pOn(r)}catch(e){throw he(e),e}}function pOn(e){let t={},r={};for(let[n,o]of Object.entries(e))if(o?.enable===!0&&o?.env){let i=o.env,s=n;t[s]={base_url:i.BASE_URL||"",auth_token:i.AUTH_TOKEN||"",api_type:i.API_TYPE||"anthropic",models:[]},i.MODEL&&(r.MODEL=[{source:s,model:i.MODEL,weight:100}],t[s].models.push(i.MODEL)),i.SMALL_FAST_MODEL&&(r.SMALL_FAST_MODEL=[{source:s,model:i.SMALL_FAST_MODEL,weight:100}],t[s].models.includes(i.SMALL_FAST_MODEL)||t[s].models.push(i.SMALL_FAST_MODEL));break}return{sources:t,routing:r}}function d3t(e){if(e.length===0)throw new Error("No items to select from");if(e.length===1)return e[0];let t=e.reduce((n,o)=>n+(o.weight??100),0),r=Math.random()*t;for(let n of e){let o=n.weight??100;if(r-=o,r<=0)return n}return e[e.length-1]}var FMe=class{config;constructor(){try{this.config=l3t()}catch(t){console.log(t)}}reload(){this.config=l3t()}getConfig(){return this.config}hasModelRouting(){return!!(this.config.routing?.MODEL&&this.config.routing.MODEL.length>0)}getModelRoutingModels(){let t=this.config.routing?.MODEL;return!t||t.length===0?[]:t.map(r=>r.model)}hasSmallFastModelRouting(){return!!(this.config.routing?.SMALL_FAST_MODEL&&this.config.routing.SMALL_FAST_MODEL.length>0)}getModel(){let t=this.config.routing?.MODEL;if(!t||t.length===0)throw new Error("No MODEL routing configuration found");let r=d3t(t);return`${r.source}__${r.model}`}getSmallFastModel(){let t=this.config.routing?.SMALL_FAST_MODEL;if(!t||t.length===0)throw new Error("No SMALL_FAST_MODEL routing configuration found");let r=d3t(t);return`${r.source}__${r.model}`}getSourceConfig(t){return this.config.sources?.[t]}parseModelKey(t){let r=t.indexOf("__");return r===-1?{source:"",model:t}:{source:t.slice(0,r),model:t.slice(r+2)}}getModelSourceConfig(t){let{source:r}=this.parseModelKey(t);if(r)return this.getSourceConfig(r)}setModelRouting(t){this.config.routing.MODEL=t,this.saveConfig()}setSmallFastModelRouting(t){this.config.routing.SMALL_FAST_MODEL=t,this.saveConfig()}getAvailableModels(){let t=[];for(let[r,n]of Object.entries(this.config.sources||{}))for(let o of n.models||[])t.push(`${r}__${o}`);return t}saveConfig(){try{let t=f3t(),r={};if($q.existsSync(t)){let o=$q.readFileSync(t,"utf-8");r=JSON.parse(o)}let n={...r,sources:this.config.sources,routing:this.config.routing};$q.writeFileSync(t,JSON.stringify(n,null,2))}catch(t){he(t)}}},Ho=new FMe;var mOn="1.40.3",$S={VERSION:mOn,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 QMe=46,p3t=["(\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 pue({isDefaultModel:e=!1}){let t=Math.max(QMe,Me().length+12),r=K(),n=p3t[Math.floor(Math.random()*p3t.length)];return hp.createElement(D,{flexDirection:"column"},hp.createElement(D,{flexDirection:"column",gap:1,paddingLeft:1,width:"100%"},hp.createElement(C,null,hp.createElement(C,null,n)," Welcome to"," ",hp.createElement(C,{bold:!0},ze),hp.createElement(C,{color:r.secondaryText}," v",$S.VERSION)),hp.createElement(hp.Fragment,null,hp.createElement(D,{paddingLeft:2,flexDirection:"column",gap:1},hp.createElement(C,{color:r.secondaryText,italic:!0},"/help for help"),hp.createElement(C,{color:r.secondaryText},"cwd: ",Me()),hp.createElement(C,{color:r.secondaryText},"model: ",Ho.getConfig().routing.MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A"),hp.createElement(C,{color:r.secondaryText},"small fast model: ",Ho.getConfig().routing.SMALL_FAST_MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A")))))}var N0=U(ne(),1);Ne();var WW=U(ne(),1);import{randomUUID as x0}from"crypto";var m3t=()=>[],g3t=()=>{};function A3t(e){m3t=e}function mue(){return m3t}function h3t(e){g3t=e}function E3t(){return g3t}Ne();Xt();Sr();Ne();Le();import{existsSync as qb,readdirSync as L2n,statSync as F2n}from"fs";import{join as dx,relative as Q2n}from"path";import{homedir as V9t}from"os";import{platform as U2n}from"process";import{readFile as fx}from"fs/promises";Sr();VS();Ir();import{join as SOn,sep as yOn}from"path";function Ep(){if(!Cm())return!1;try{let e=Tt();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function Im(){return(SOn(Me(),".hcode","team-memory")+yOn).normalize("NFC")}function qQ(e){let t=e.normalize("NFC"),r=Im();return t.startsWith(r)}var Y9t=U(Xq(),1);Uo();var H9t=U(Xq(),1);Sr();Le();Ne();pp();import{readFile as Q9t}from"fs/promises";import{existsSync as n2e,readdirSync as B2n,statSync as M2n}from"fs";import{join as o2e,relative as G9t}from"path";import{homedir as k2n}from"os";function U9t(e){try{let t=(0,H9t.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 he(t),{paths:[],content:e.trim()}}}function P2n(e,t){return t.length===0?!0:t.some(r=>{try{return vd(e,r,{matchBase:!0,dot:!0})}catch(n){return he(n),!1}})}function i2e(e){let t=[];try{if(!n2e(e))return t;let r=B2n(e);for(let n of r){let o=o2e(e,n),i=M2n(o);i.isDirectory()?t.push(...i2e(o)):i.isFile()&&n.endsWith(".md")&&t.push(o)}}catch(r){he(r)}return t}async function q9t(){let e=[];try{let t=o2e(k2n(),Cn,"rules");if(n2e(t)){let r=i2e(t);for(let n of r)try{let o=await Q9t(n,"utf-8"),{paths:i,content:s}=U9t(o);i.length>0&&e.push({filePath:n,content:s,paths:i,isProjectRule:!1})}catch(o){he(o)}}}catch(t){he(t)}try{let t=o2e(Me(),Cn,"rules");if(n2e(t)){let r=i2e(t);for(let n of r)try{let o=await Q9t(n,"utf-8"),{paths:i,content:s}=U9t(o);i.length>0&&e.push({filePath:G9t(Me(),n),content:s,paths:i,isProjectRule:!0})}catch(o){he(o)}}}catch(t){he(t)}return e}function $9t(e,t){e=dae(e);let r=dae(Me()),n=e.startsWith(r)?G9t(r,e):e;return t.filter(o=>P2n(n,o.paths))}var H2n=`# hawaCodeMd
|
|
672
672
|
Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.`;function G2n(e="default"){let r=$e.getSessionContext(e).getData("matchedPathRules");return!r||r.length===0?"":r.map(o=>{let i=o.isProjectRule?"project instructions, checked into the codebase":"user's private global instructions for all projects";return`Contents of ${o.filePath} (${i}):
|
|
673
673
|
|
|
674
674
|
${o.content}`}).join(`
|
|
@@ -766,7 +766,7 @@ data: ${JSON.stringify(Q)}
|
|
|
766
766
|
Stack trace: `+d.stack)),new Response(c.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var ipe=null,UUe=!1;function CWn(){ipe=null,UUe=!1}hr.on("proxy:changed",CWn);function IWn(){if(UUe)return ipe;if(UUe=!0,Tt().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(ipe=new t7t.ProxyAgent({uri:e}),Ft(`[proxy] using proxy: ${e}`)),ipe}function vWn(){let e=IWn();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function ape(e){let t=e||process.env.API_TYPE,r=vWn();switch(t){case"openai":return SWn(r);case"openai-responses":return yWn(r);case"gemini":return TWn(r);default:return bWn(r)}}var n7t=U(ne(),1);function r7t(e,t){let r=[],n=Math.max(1,Math.floor(t)),o="",i=0;for(let s of e){let a=xWn(s);o&&i+a>n?(r.push(o),o=s,i=a):(o+=s,i+=a)}return o&&r.push(o),r}function xWn(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||DWn(t)?0:RWn(t)?2:1}function DWn(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function RWn(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 q_(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 qUe(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 lC(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}function cpe(e,t,r){let n=[];return typeof e=="number"&&n.push(qUe(e)),typeof t=="number"&&n.push(`${t} ${t===1?"turn":"turns"}`),typeof r=="number"&&n.push(`${lC(r)} tokens`),n.length>0?` (${n.join(" \xB7 ")})`:""}Ne();ra();var iA={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0};function upe(e,t){iA.totalCost+=e,iA.totalAPIDuration+=t}function lpe(e,t){iA.inputTokens+=e,iA.outputTokens+=t,hr.emit("token:change",{inputTokens:iA.inputTokens,outputTokens:iA.outputTokens})}function JV(){return{inputTokens:iA.inputTokens,outputTokens:iA.outputTokens}}function dpe(){return iA.totalCost}function o7t(){return Date.now()-iA.startTime}function $Ue(){return ht.grey(`Total duration (API): ${q_(iA.totalAPIDuration)}
|
|
767
767
|
Total duration (wall): ${q_(o7t())}`)}function i7t(){(0,n7t.useEffect)(()=>{let e=()=>{process.stdout.write(`
|
|
768
768
|
`+$Ue()+`
|
|
769
|
-
`);let t=On();vi({...t,lastCost:iA.totalCost,lastAPIDuration:iA.totalAPIDuration,lastDuration:o7t(),lastSessionId:h_})};return process.on("exit",e),()=>{process.off("exit",e)}},[])}Ne();Le();Le();var VUe="1.40.
|
|
769
|
+
`);let t=On();vi({...t,lastCost:iA.totalCost,lastAPIDuration:iA.totalAPIDuration,lastDuration:o7t(),lastSessionId:h_})};return process.on("exit",e),()=>{process.off("exit",e)}},[])}Ne();Le();Le();var VUe="1.40.3";globalThis.MACRO={VERSION:VUe,PACKAGE_URL:`@dahawa/${li}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var fpe=process.env.HAWA_CODE_USER_AGENT||`${li}/${VUe} (${process.env.USER_TYPE})`;Ne();Ne();Xt();function wf(e){let t=[];return e.filter(r=>r.type!=="progress"&&r.type!=="reminder").forEach(r=>{switch(r.type){case"user":{let n=gf(t);if(n?.type==="user"){t[t.length-1]=BWn(n,r);return}t.push(r);return}case"assistant":t.push(r);return;case"insert":{let n=gf(t);n?.type==="user"&&(t[t.length-1]=wWn(n,r));return}}}),t}function wWn(e,t){return{...e,message:{...e.message,content:OWn(e.message.content,NWn(t.content.content))}}}function NWn(e){return`
|
|
770
770
|
<system-reminder>
|
|
771
771
|
The user sent the following message:
|
|
772
772
|
${e}
|
package/hands.js
CHANGED
|
@@ -404,7 +404,7 @@ ${a}., and again, please do not mention this information directly to the user.`:
|
|
|
404
404
|
|
|
405
405
|
${a}. Continue on with the tasks at hand if applicable.`;return this.createReminderMessage("todo","task","medium",l,o)}}dispatchSecurityEvent(){if(!this.sessionState.config.securityReminder)return null;let t=Date.now();return this.sessionState.lastFileAccess>0&&!this.sessionState.remindersSent.has("file_security")?(this.sessionState.remindersSent.add("file_security"),this.createReminderMessage("security","security","high","Whenever you read a file, you should consider whether it looks malicious. If it does, you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer high-level questions about the code behavior.",t)):null}dispatchPerformanceEvent(t){let r=Date.now();return r-Ge.getInQueryContext(t).startTime>1800*1e3?this.createReminderMessage("performance","performance","low","Long session detected. Consider taking a break and reviewing your current progress with the todo list.",r):null}getSelectionChanged(t){if(t)return;let r=Ge.getInQueryContext(t)[lI];if(typeof r>"u"){let i=lpt();i?Ge.getInQueryContext(t)[lI]=i:Ge.getInQueryContext(t)[lI]={},r=Ge.getInQueryContext(t)[lI]}return!r.filePath&&!r.text?null:[this.createReminderMessage("selection_changed","general","medium",`
|
|
406
406
|
The user opened the file ${r.filePath} ${r.text} in the IDE. This may or may not be related to the current task.
|
|
407
|
-
`,Date.now()
|
|
407
|
+
`,Date.now())]}getPlanMode(t,r){if(!t&&!ni.isPlanMode()||t&&r!=="plan")return null;let n=ni.getCurrentPlanFilePath(),i=`
|
|
408
408
|
Plan mode is active. The user indicated that they do not want you to execute yet -- you MUST NOT make any edits (with the exception of the plan file mentioned below), run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supercedes any other instructions you have received.
|
|
409
409
|
|
|
410
410
|
## Plan File Info:
|
|
@@ -476,7 +476,7 @@ ${u}. Members must communicate with each other using the ${_p} tool`;if(n){l+=`
|
|
|
476
476
|
|
|
477
477
|
Warning: Team "${r}" has ${f.length} active ${A}, so it cannot be deleted.`}l+=`
|
|
478
478
|
|
|
479
|
-
You don't need to keep checking on the team's tool progress\u2014members will notify you when they complete their tasks. Continue with other work or respond to the user instead`}return[this.createReminderMessage("agent_team","task","medium",l,s,!0)]}getContextOptimizationReminder(t,r,n){let i=ft.isMessageArchivingEnable(),o=ft.isMemoEnable();if(!i&&!o)return null;let s=r??t,a=i&&s?.some(C=>C.name===id),u=o&&s?.some(C=>C.name===jE);if(!a&&!u)return null;let l
|
|
479
|
+
You don't need to keep checking on the team's tool progress\u2014members will notify you when they complete their tasks. Continue with other work or respond to the user instead`}return[this.createReminderMessage("agent_team","task","medium",l,s,!0)]}getContextOptimizationReminder(t,r,n){let i=ft.isMessageArchivingEnable(),o=ft.isMemoEnable();if(!i&&!o)return null;let s=r??t,a=i&&s?.some(C=>C.name===id),u=o&&s?.some(C=>C.name===jE);if(!a&&!u)return null;let l=!0,c=!0,f=Date.now(),A=n?.percentUsed,m=.92*100,g=[];a&&g.push(l?`use ${id} to archive tool_result messages that are no longer needed for the current task. Do not archive results required for ongoing reasoning`:`load ${id} with ${wl} to archive old tool_result messages and reduce context usage`),u&&g.push(c?`use ${jE} to persist long analysis conclusions, plans, or error records to keep them out of the context window while remaining retrievable later`:`load ${jE} with ${wl} to persist long conclusions outside the context window`),a&&u&&g.push(`${id} \u548C ${jE} \u53EF\u4EE5\u914D\u5408\u4F7F\u7528\uFF0C\u4ECE\u800C\u51CF\u5C11\u4E0A\u4E0B\u6587\u4F7F\u7528\u548C\u51CF\u5C11 token \u4F7F\u7528`);let E="";A!==void 0?E=`Context usage is ${A}%. The system will automatically compact prior messages when usage reaches ${m}%. Reduce context usage by: `:E="Reduce context usage by: ";let _=g.length===1?`${E}${g[0]}`:`${E}${g.map(C=>`- ${C}`).join(`
|
|
480
480
|
`)}`;return this.createReminderMessage("message_archiving_context","performance","medium",_,f,!0)}async getToolLazy(t,r,n,i){if(!(ft.isLazyToolEnable()&&i===!0))return null;let o=n??await Nn.getTools(!1),s=r?.map(g=>g.name)??[],a=new Set(s),u=o.filter(g=>!Dg.includes(g.name)&&!a.has(g.name)).map(g=>g.name),l=o.some(g=>g.name===wl),c=o.some(g=>g.name===Bl),f=l?`Load them with ${wl} if needed; call it in parallel with other tools when possible.`:"",A=c?`Unload tools you no longer need with ${Bl}; call it in parallel with other tools when possible. You do not need to unload if you are returning results to the user.`:"",m=`Available but not loaded tools: ${u.length?u.join(", ")+". "+f:"none."}
|
|
481
481
|
Loaded tools: ${s.length?s.join(", ")+". "+A:"none."}`;return[this.createReminderMessage("tool","general","high",m,Date.now())]}getRecalledMemories(t){let n=Ge.getQueryContext(t).recalledMemories;if(!n||n.length===0)return null;let i=Date.now(),s=`The following memories were recalled and may be relevant to the current task. Use them only if they are helpful:
|
|
482
482
|
|
|
@@ -752,7 +752,7 @@ data: ${JSON.stringify(G)}
|
|
|
752
752
|
|
|
753
753
|
[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 vQr(`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"}}},R0e=new N0e;var mct=te(dct(),1);hr();vs();function _A(e){return e?typeof e.entries=="function"?Object.fromEntries(e.entries()):{...e}:{}}function fct(e){let t=String(e?.["x-thinking-level"]??"medium").toLowerCase();return["off","low","medium","high"].includes(t)?t:"medium"}function UYr(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t}}function HYr(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t,summary:"auto"}}function qYr(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,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.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}function bU(e,t,r){FG(t,e),QG(t,qYr(e,r),r)}function RR(e){let t=[],r=e.getReader(),n,i=new Promise(u=>n=u),o=!1,s=()=>{o||(o=!0,n(Buffer.concat(t).toString("utf8")))};return{stream:new ReadableStream({async pull(u){try{let{done:l,value:c}=await r.read();if(l){u.close(),s();return}t.push(c),u.enqueue(c)}catch(l){u.error(l),s()}},cancel(u){r.cancel(u).catch(()=>{}),s()}}),done:i}}function CU(e){let t=new Headers(e);return t.delete("content-encoding"),t.delete("content-length"),t.delete("transfer-encoding"),t}function s1e(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 pct=["/v1/messages"];function a1e(e){let t;try{typeof e=="string"?t=new MT(e):e instanceof MT?t=e:t=new MT(e.url)}catch{return""}let r=t.pathname;for(let n of pct){let i=r.indexOf(n);if(i!==-1)return t.origin+r.slice(0,i)}return t.origin}function KK(e,t){let r=typeof e=="string"?e:e instanceof MT?e.toString():e.url,n;try{n=new MT(r).pathname}catch{return!1}return pct.some(i=>n.includes(i))&&(t.method==="POST"||t.method==="post")}function GYr(e){return async(t,r)=>{if(!KK(t,r))return e(t,r);let n=JSON.parse(r.body),i=await JV.transformRequestOut(n),o=a1e(t)+"/chat/completions",s=_A(r.headers),a=s.authorization??s.Authorization??"";UYr(i,fct(s));let u=await e(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:a},body:JSON.stringify(i),signal:r.signal});if(!u.ok){let _=await u.text();return le(`OpenAI Chat Completions API error: ${u.status}`,{url:o,errorResponse:_}),s1e("OpenAI Chat Completions API error","OPENROUTER",u.status,u.statusText,_)}let l=n.stream===!0,c=s["x-agent-id"],f={request:{url:o,method:r.method,headers:s,body:n},response:{status:u.status,statusText:u.statusText,headers:_A(u.headers)},openai:{request:{body:i},response:{}}};if(!l){let _=await u.text(),C=new Response(_,{status:u.status,statusText:u.statusText,headers:CU(u.headers)}),S=await JV.transformResponseIn(C,n),I=await S.text();try{bU({...f,openai:{...f.openai,response:{body:JSON.parse(_)}},response:{...f.response,body:JSON.parse(I)}},c)}catch(x){le("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u975E\u6D41\u5F0F):",x)}return new Response(I,{status:S.status,statusText:S.statusText,headers:S.headers})}let A=RR(u.body),m=new Response(A.stream,{status:u.status,statusText:u.statusText,headers:CU(u.headers)}),g=await JV.transformResponseIn(m,n),E=RR(g.body);return Promise.all([A.done,E.done]).then(async([_,C])=>{try{bU({...f,openai:{...f.openai,response:{body:await Het(_)}},response:{...f.response,body:await pP(C)}},c)}catch(S){le("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u6D41\u5F0F):"+S?.stack)}}).catch(_=>le("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Chat):"+_)),new Response(E.stream,{status:g.status,statusText:g.statusText,headers:g.headers})}}function $Yr(e){return async(t,r)=>{if(!KK(t,r))return e(t,r);let n=JSON.parse(r.body),i=await ZV.transformRequestOut(n),o=_A(r.headers);HYr(i,fct(o));let s=JSON.stringify(i),u=a1e(t)+"/responses",l=o.authorization??o.Authorization??"";if(!l)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 c=await e(u,{method:"POST",headers:{"Content-Type":"application/json",Authorization:l,"x-api-key":l.replace(/^Bearer\s+/i,"").trim()},body:s,signal:r.signal});if(!c.ok){let S=await c.text();return le(`OpenAI Responses API error: ${c.status} ${c.statusText}`,{url:u,status:c.status,errorResponse:S}),s1e("OpenAI Responses API error","RESPONSES",c.status,c.statusText,S)}let f=n.stream===!0,A=o["x-agent-id"],m={request:{url:u,method:r.method,headers:o,body:n},response:{status:c.status,statusText:c.statusText,headers:_A(c.headers)},openai:{request:{body:i},response:{}}};if(!f){let S=await c.text(),I=new Response(S,{status:c.status,statusText:c.statusText,headers:CU(c.headers)}),x=await ZV.transformResponseIn(I,n),O=await x.text();try{bU({...m,openai:{...m.openai,response:{body:JSON.parse(S)}},response:{...m.response,body:JSON.parse(O)}},A,"responses")}catch(F){le("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u975E\u6D41\u5F0F):",F)}return new Response(O,{status:x.status,statusText:x.statusText,headers:x.headers})}let g=RR(c.body),E=new Response(g.stream,{status:c.status,statusText:c.statusText,headers:CU(c.headers)}),_=await ZV.transformResponseIn(E,n),C=RR(_.body);return Promise.all([g.done,C.done]).then(async([S,I])=>{try{bU({...m,openai:{...m.openai,response:{body:await Uet(S)}},response:{...m.response,body:await pP(I)}},A,"responses")}catch(x){le("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u6D41\u5F0F):"+x?.stack)}}).catch(S=>le("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Responses):"+S)),new Response(C.stream,{status:_.status,statusText:_.statusText,headers:_.headers})}}function zYr(e){return async(t,r)=>{if(!KK(t,r))return e(t,r);let n=JSON.parse(r.body),i=_A(r.headers),o=await R0e.transformRequestOut(n),s=JSON.stringify(o),a=a1e(t)+`/models/${n.model}:streamGenerateContent?alt=sse`,u=i.authorization??i.Authorization??"",l;try{l=await e(a,{method:"POST",headers:{"Content-Type":"application/json","x-goog-api-key":String(u).replace(/^Bearer\s+/i,"").trim()},body:s,signal:r.signal})}catch(C){throw le("gemini request error:",C),C}if(!l.ok){let C=await l.text();return le(`Gemini API error response: ${l.status} ${l.statusText}`,{url:a,status:l.status,errorResponse:C}),s1e("Gemini API error","Gemini",l.status,l.statusText,C)}let c=n.stream===!0,f=i["x-agent-id"],A={request:{url:a,method:r.method,headers:_A(r.headers),body:n},response:{status:l.status,statusText:l.statusText,headers:_A(l.headers)},openai:{request:{body:o},response:{}}},m=RR(l.body),g=new Response(m.stream,{status:l.status,statusText:l.statusText,headers:CU(l.headers)}),E=await R0e.transformResponseIn(g),_=RR(E.body);return Promise.all([m.done,_.done]).then(async([C,S])=>{try{let I=c?qet(C):JSON.parse(C),x=c?await pP(S):JSON.parse(S);bU({...A,openai:{...A.openai,response:{body:I}},response:{...A.response,body:x}},f)}catch(I){le("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Gemini):"+I?.stack)}}).catch(C=>le("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Gemini):"+C)),new Response(_.stream,{status:E.status,statusText:E.statusText,headers:E.headers})}}function YYr(e){return async(t,r)=>{if(!KK(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=_A(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();le(`API error response: ${a.status} ${a.statusText}`,{url:typeof t=="string"?t:t instanceof MT?t.toString():t.url,status:a.status,errorResponse:f});let A;try{let m=JSON.parse(f);A={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&&(A.error.details=m.error.details)}catch{A={type:"error",error:{type:"api_error",message:`API error: ${a.statusText}`,code:`API_${a.status}_ERROR`}}}return new Response(JSON.stringify(A),{status:a.status,statusText:a.statusText,headers:{"Content-Type":"application/json"}})}let u=a.clone(),l=!(Object.hasOwn(JSON.parse(n),"stream")&&!JSON.parse(n).stream),c={request:{url:typeof t=="string"?t:t instanceof MT?t.toString():t.url,method:r.method,headers:_A(r.headers),body:JSON.parse(n)},response:{status:a.status,statusText:a.statusText,headers:_A(a.headers)}};return(async()=>{if(l){let m=await a.text();c.response.body=await pP(m)}else c.response.body=await a.json();let A=_A(r.headers)["x-agent-id"];FG(A,c),QG(A,{request:c.request.body.messages,response:c.response.body.content})})().catch(f=>le(`\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF:
|
|
754
754
|
Stack trace: `+f.stack)),new Response(u.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var WK=null,o1e=!1;function jYr(){WK=null,o1e=!1}Mr.on("proxy:changed",jYr);function VYr(){if(o1e)return WK;if(o1e=!0,Ht().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(WK=new mct.ProxyAgent({uri:e}),$t(`[proxy] using proxy: ${e}`)),WK}function WYr(){let e=VYr();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function JK(e){let t=e||process.env.API_TYPE,r=WYr();switch(t){case"openai":return GYr(r);case"openai-responses":return $Yr(r);case"gemini":return zYr(r);default:return YYr(r)}}var XYr=te(Ee(),1);function Act(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=KYr(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function KYr(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||JYr(t)?0:ZYr(t)?2:1}function JYr(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function ZYr(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 yA(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 lC(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}Ue();vs();var cC={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0};function ZK(e,t){cC.totalCost+=e,cC.totalAPIDuration+=t}function XK(e,t){cC.inputTokens+=e,cC.outputTokens+=t,Mr.emit("token:change",{inputTokens:cC.inputTokens,outputTokens:cC.outputTokens})}function ejr(){return Date.now()-cC.startTime}function gct(){return pr.grey(`Total duration (API): ${yA(cC.totalAPIDuration)}
|
|
755
|
-
Total duration (wall): ${yA(ejr())}`)}Ue();Me();Me();var u1e="1.40.
|
|
755
|
+
Total duration (wall): ${yA(ejr())}`)}Ue();Me();Me();var u1e="1.40.3";globalThis.MACRO={VERSION:u1e,PACKAGE_URL:`@dahawa/${qi}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var eJ=process.env.HAWA_CODE_USER_AGENT||`${qi}/${u1e} (${process.env.USER_TYPE})`;import{randomUUID as F_}from"crypto";var tjr=()=>[],rjr=()=>{};function tJ(){return tjr}function hct(){return rjr}Ue();Kt();vr();Ue();Me();import{existsSync as k0,readdirSync as IKr,statSync as TKr}from"fs";import{join as pC,relative as vKr}from"path";import{homedir as qft}from"os";import{platform as xKr}from"process";import{readFile as mC}from"fs/promises";vr();N0();hr();import{join as ajr,sep as ujr}from"path";function Vp(){if(!jp())return!1;try{let e=Ht();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function xf(){return(ajr(Fe(),".hcode","team-memory")+ujr).normalize("NFC")}function c1e(e){let t=e.normalize("NFC"),r=xf();return t.startsWith(r)}var Gft=te(NU(),1);bi();var Lft=te(NU(),1);vr();Me();Ue();dc();import{readFile as Fft}from"fs/promises";import{existsSync as x1e,readdirSync as yKr,statSync as bKr}from"fs";import{join as D1e,relative as Pft}from"path";import{homedir as CKr}from"os";function Qft(e){try{let t=(0,Lft.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 Ie(t),{paths:[],content:e.trim()}}}function SKr(e,t){return t.length===0?!0:t.some(r=>{try{return Zu(e,r,{matchBase:!0,dot:!0})}catch(n){return Ie(n),!1}})}function w1e(e){let t=[];try{if(!x1e(e))return t;let r=yKr(e);for(let n of r){let i=D1e(e,n),o=bKr(i);o.isDirectory()?t.push(...w1e(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){Ie(r)}return t}async function Uft(){let e=[];try{let t=D1e(CKr(),qr,"rules");if(x1e(t)){let r=w1e(t);for(let n of r)try{let i=await Fft(n,"utf-8"),{paths:o,content:s}=Qft(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){Ie(i)}}}catch(t){Ie(t)}try{let t=D1e(Fe(),qr,"rules");if(x1e(t)){let r=w1e(t);for(let n of r)try{let i=await Fft(n,"utf-8"),{paths:o,content:s}=Qft(i);o.length>0&&e.push({filePath:Pft(Fe(),n),content:s,paths:o,isProjectRule:!0})}catch(i){Ie(i)}}}catch(t){Ie(t)}return e}function Hft(e,t){e=OY(e);let r=OY(Fe()),n=e.startsWith(r)?Pft(r,e):e;return t.filter(i=>SKr(n,i.paths))}var DKr=`# hawaCodeMd
|
|
756
756
|
Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.`;function wKr(e="default"){let r=Ge.getSessionContext(e).getData("matchedPathRules");return!r||r.length===0?"":r.map(i=>{let o=i.isProjectRule?"project instructions, checked into the codebase":"user's private global instructions for all projects";return`Contents of ${i.filePath} (${o}):
|
|
757
757
|
|
|
758
758
|
${i.content}`}).join(`
|
|
@@ -1015,7 +1015,7 @@ try {
|
|
|
1015
1015
|
`],{encoding:"utf8",maxBuffer:wgt,stdio:["ignore","pipe","ignore"]}).trim()||null}catch{return null}}function ken(){try{let e=l3("where",["pwsh.exe"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim().split(/\r?\n/)[0];if(e)return e}catch{}return"powershell.exe"}var Men="[Image pasted]";function Ogt(e){return function(t){return(new Map(e).get(t)??(()=>{}))(t)}}function Mgt({value:e,onChange:t,onSubmit:r,onExit:n,onExitMessage:i,onMessage:o,onHistoryUp:s,onHistoryDown:a,onHistoryReset:u,mask:l="",multiline:c=!1,cursorChar:f,invert:A,columns:m,onImagePaste:g,disableCursorMovementForUpDownKeys:E=!1,externalOffset:_,onOffsetChange:C}){let S=_,I=C,x=u3.fromText(e,m,S),[O,F]=(0,kgt.useState)(null);function G(){O&&(clearTimeout(O),F(null),o?.(!1))}let j=iv(ce=>{G(),i?.(ce,"Ctrl-C")},()=>n?.(),()=>{e&&(t(""),u?.())}),U=iv(ce=>{G(),o?.(!!e&&ce,"Press Escape again to clear")},()=>{e&&t("")});function $(){return u3.fromText("",m,0)}let q=iv(ce=>i?.(ce,"Ctrl-D"),()=>n?.());function de(){return G(),x.text===""?(q(),x):x.del()}function _e(){if(l)return x;let ce=Rgt();return ce===null?(Ngt()&&(o?.(!0,Bgt),G(),F(setTimeout(()=>{o?.(!1)},4e3))),x):(g?.(ce),x.insert(Men))}let k=Ogt([["a",()=>x.startOfLine()],["b",()=>x.left()],["c",j],["d",de],["e",()=>x.endOfLine()],["f",()=>x.right()],["h",()=>(G(),x.backspace())],["k",()=>x.deleteToLineEnd()],["l",()=>$()],["n",()=>ee()],["p",()=>ae()],["u",()=>x.deleteToLineStart()],["v",_e],["w",()=>x.deleteWordBefore()],["o",_e]]),ue=Ogt([["b",()=>x.prevWord()],["f",()=>x.nextWord()],["d",()=>x.deleteWordAfter()]]);function me(ce){if(c&&x.offset>0&&x.text[x.offset-1]==="\\")return x.backspace().insert(`
|
|
1016
1016
|
`);if(ce.meta)return x.insert(`
|
|
1017
1017
|
`);r?.(e)}function ae(){if(E)return s?.(),x;let ce=x.up();return ce.equals(x)&&s?.(),ce}function ee(){if(E)return a?.(),x;let ce=x.down();return ce.equals(x)&&a?.(),ce}function xe(ce,$e){if($e.tab)return;if($e.backspace||$e.delete||ce==="\b"||ce==="\x7F"||ce==="\b"){let K=x.backspace();x.equals(K)||(I(K.offset),x.text!==K.text&&t(K.text));return}if(!$e.ctrl&&!$e.meta&&ce.length>1){let K=x.insert(ce);x.equals(K)||(I(K.offset),x.text!==K.text&&t(K.text));return}let ye=Te($e)(ce);ye&&(x.equals(ye)||(I(ye.offset),x.text!==ye.text&&t(ye.text)))}function Te(ce){if(ce.backspace||ce.delete)return G(),()=>x.backspace();switch(!0){case ce.escape:return U;case(ce.leftArrow&&(ce.ctrl||ce.meta||"fn"in ce&&ce.fn)):return()=>x.prevWord();case(ce.rightArrow&&(ce.ctrl||ce.meta||"fn"in ce&&ce.fn)):return()=>x.nextWord();case ce.ctrl:return k;case("home"in ce&&ce.home):return()=>x.startOfLine();case("end"in ce&&ce.end):return()=>x.endOfLine();case ce.pageDown:return()=>x.endOfLine();case ce.pageUp:return()=>x.startOfLine();case ce.meta:return ue;case ce.return:return()=>me(ce);case ce.upArrow:return ae;case ce.downArrow:return ee;case ce.leftArrow:return()=>x.left();case ce.rightArrow:return()=>x.right()}return function($e){switch(!0){case($e=="\x1B[H"||$e=="\x1B[1~"):return x.startOfLine();case($e=="\x1B[F"||$e=="\x1B[4~"):return x.endOfLine();case($e==="\b"||$e==="\x7F"||$e==="\b"):return G(),x.backspace();default:return x.insert($e.replace(/\r/g,`
|
|
1018
|
-
`))}}}return{onInput:xe,renderedValue:x.render(f,l,A),offset:S,setOffset:I}}function c3({value:e,placeholder:t="",focus:r=!0,mask:n,multiline:i=!1,highlightPastedText:o=!1,showCursor:s=!0,onChange:a,onSubmit:u,onExit:l,onHistoryUp:c,onHistoryDown:f,onExitMessage:A,onMessage:m,onHistoryReset:g,columns:E,onImagePaste:_,onPaste:C,isDimmed:S=!1,disableCursorMovementForUpDownKeys:I=!1,cursorOffset:x,onChangeCursorOffset:O}){let{onInput:F,renderedValue:G}=Mgt({value:e,onChange:a,onSubmit:u,onExit:l,onExitMessage:A,onMessage:m,onHistoryReset:g,onHistoryUp:c,onHistoryDown:f,focus:r,mask:n,multiline:i,cursorChar:s?" ":"",highlightPastedText:o,invert:ue=>pr.bgHex("#ffffff").hex("#000000")(ue),themeText:ue=>pr.hex(ge().text)(ue),columns:E,onImagePaste:_,disableCursorMovementForUpDownKeys:I,externalOffset:x,onOffsetChange:O}),[j,U]=zSe.default.useState({chunks:[],timeoutId:null}),$=ue=>(ue&&clearTimeout(ue),setTimeout(()=>{U(({chunks:me})=>{let ae=me.join("");return Promise.resolve().then(()=>C(ae)),{chunks:[],timeoutId:null}})},100));ur((ue,me)=>{if(C&&(ue.length>10||j.timeoutId)){U(({chunks:ae,timeoutId:ee})=>({chunks:[...ae,ue],timeoutId:$(ee)}));return}F(ue,me)},{isActive:r});let de=t?pr.hex(ge().secondaryText)(t):void 0,_e=ue=>pr.bgHex("#ffffff").hex("#000000")(ue);s&&r&&(de=t.length>0?_e(t[0])+pr.hex(ge().secondaryText)(t.slice(1)):_e(" "));let k=e.length==0&&t;return zSe.default.createElement(v,{wrap:"truncate-end",dimColor:S},k?de:G)}var YSe=te(Ee(),1),d3=te(Ee(),1);kU();vs();bi();rv();hr();var Fgt=process.platform==="darwin"?["\xB7","\u2722","\u2733","\u2217","\u273B","\u273D"]:["\xB7","\u2722","*","\u2217","\u273B","\u273D"];function dv(){let e=[...Fgt,...[...Fgt].reverse()],[t,r]=(0,d3.useState)(0);return(0,d3.useEffect)(()=>{let n=setInterval(()=>{r(i=>(i+1)%e.length)},120);return()=>clearInterval(n)},[e.length]),YSe.createElement(N,{flexWrap:"nowrap",height:1,width:2},YSe.createElement(v,{color:ge().claude},e[t]))}bi();function _C(){return Ge.getSessionContext().window_size?{...Ge.getSessionContext().window_size}:{columns:process.stdout.columns||80,rows:process.stdout.rows||24}}Me();import{homedir as y3}from"os";import{join as A2}from"path";import{existsSync as b3,mkdirSync as TEt,appendFileSync as IEt,readFileSync as vEt,constants as Rnn,writeFileSync as Onn,unlinkSync as xEt,statSync as knn}from"fs";import{platform as DEt}from"process";Ue();import{accessSync as Mnn}from"fs";Ue();var C1i=te(pIe(),1);var Nnn="1.40.
|
|
1018
|
+
`))}}}return{onInput:xe,renderedValue:x.render(f,l,A),offset:S,setOffset:I}}function c3({value:e,placeholder:t="",focus:r=!0,mask:n,multiline:i=!1,highlightPastedText:o=!1,showCursor:s=!0,onChange:a,onSubmit:u,onExit:l,onHistoryUp:c,onHistoryDown:f,onExitMessage:A,onMessage:m,onHistoryReset:g,columns:E,onImagePaste:_,onPaste:C,isDimmed:S=!1,disableCursorMovementForUpDownKeys:I=!1,cursorOffset:x,onChangeCursorOffset:O}){let{onInput:F,renderedValue:G}=Mgt({value:e,onChange:a,onSubmit:u,onExit:l,onExitMessage:A,onMessage:m,onHistoryReset:g,onHistoryUp:c,onHistoryDown:f,focus:r,mask:n,multiline:i,cursorChar:s?" ":"",highlightPastedText:o,invert:ue=>pr.bgHex("#ffffff").hex("#000000")(ue),themeText:ue=>pr.hex(ge().text)(ue),columns:E,onImagePaste:_,disableCursorMovementForUpDownKeys:I,externalOffset:x,onOffsetChange:O}),[j,U]=zSe.default.useState({chunks:[],timeoutId:null}),$=ue=>(ue&&clearTimeout(ue),setTimeout(()=>{U(({chunks:me})=>{let ae=me.join("");return Promise.resolve().then(()=>C(ae)),{chunks:[],timeoutId:null}})},100));ur((ue,me)=>{if(C&&(ue.length>10||j.timeoutId)){U(({chunks:ae,timeoutId:ee})=>({chunks:[...ae,ue],timeoutId:$(ee)}));return}F(ue,me)},{isActive:r});let de=t?pr.hex(ge().secondaryText)(t):void 0,_e=ue=>pr.bgHex("#ffffff").hex("#000000")(ue);s&&r&&(de=t.length>0?_e(t[0])+pr.hex(ge().secondaryText)(t.slice(1)):_e(" "));let k=e.length==0&&t;return zSe.default.createElement(v,{wrap:"truncate-end",dimColor:S},k?de:G)}var YSe=te(Ee(),1),d3=te(Ee(),1);kU();vs();bi();rv();hr();var Fgt=process.platform==="darwin"?["\xB7","\u2722","\u2733","\u2217","\u273B","\u273D"]:["\xB7","\u2722","*","\u2217","\u273B","\u273D"];function dv(){let e=[...Fgt,...[...Fgt].reverse()],[t,r]=(0,d3.useState)(0);return(0,d3.useEffect)(()=>{let n=setInterval(()=>{r(i=>(i+1)%e.length)},120);return()=>clearInterval(n)},[e.length]),YSe.createElement(N,{flexWrap:"nowrap",height:1,width:2},YSe.createElement(v,{color:ge().claude},e[t]))}bi();function _C(){return Ge.getSessionContext().window_size?{...Ge.getSessionContext().window_size}:{columns:process.stdout.columns||80,rows:process.stdout.rows||24}}Me();import{homedir as y3}from"os";import{join as A2}from"path";import{existsSync as b3,mkdirSync as TEt,appendFileSync as IEt,readFileSync as vEt,constants as Rnn,writeFileSync as Onn,unlinkSync as xEt,statSync as knn}from"fs";import{platform as DEt}from"process";Ue();import{accessSync as Mnn}from"fs";Ue();var C1i=te(pIe(),1);var Nnn="1.40.3",_3={VERSION:Nnn,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"};Me();var pv=A2(LI,".update.lock"),Fnn=300*1e3;function wEt(){try{if(b3(LI)||TEt(LI,{recursive:!0}),b3(pv)){let e=knn(pv);if(Date.now()-e.mtimeMs<Fnn)return!1;try{xEt(pv)}catch(r){return Ie(`Failed to remove stale lock file: ${r}`),!1}}return Onn(pv,`${process.pid}`,"utf8"),!0}catch(e){return Ie(`Failed to acquire lock: ${e}`),!1}}function BEt(){try{b3(pv)&&vEt(pv,"utf8")===`${process.pid}`&&xEt(pv)}catch(e){Ie(`Failed to release lock: ${e}`)}}async function mIe(){try{let e=await Kn("npm -g config get prefix");if(e.code!==0)return Ie("Failed to check npm permissions"),{hasPermissions:!1,npmPrefix:null};let t=e.stdout.trim(),r=!1;try{Mnn(t,Rnn.W_OK),r=!0}catch{r=!1}return r?{hasPermissions:!0,npmPrefix:t}:(Ie("Insufficient permissions for global npm install."),{hasPermissions:!1,npmPrefix:t})}catch(e){return Ie(`Failed to verify npm global install permissions: ${e}`),{hasPermissions:!1,npmPrefix:null}}}async function NEt(e){if(!wEt())throw dt("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:_3.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{b3(e)||TEt(e,{recursive:!0});let t=await Kn(`npm -g config set prefix ${e}`);if(t.code!==0)throw new Error(`Failed to set npm prefix: ${t.stderr}`);let r=`
|
|
1019
1019
|
# npm global path
|
|
1020
1020
|
export PATH="${e}/bin:$PATH"
|
|
1021
1021
|
`;if(DEt==="win32"){let n=await Kn(`setx PATH "${process.env.PATH};${e}"`);if(n.code!==0)throw new Error(`Failed to update PATH on Windows: ${n.stderr}`)}else{let n=[A2(y3(),".bashrc"),A2(y3(),".bash_profile"),A2(y3(),".zshrc"),A2(y3(),".config","fish","config.fish")];for(let i of n)if(b3(i))try{if(!vEt(i,"utf8").includes(e)){if(i.includes("fish")){let s=`
|