howtofixcli 0.7.24 → 0.7.26
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/dist/account-credential.js +136 -0
- package/dist/acp.js +234 -0
- package/dist/activity.js +124 -0
- package/dist/agent-defs.js +237 -0
- package/dist/agent-limiter.js +68 -0
- package/dist/agents.js +554 -0
- package/dist/anim.js +361 -0
- package/dist/args.js +250 -0
- package/dist/at-file.js +28 -0
- package/dist/brand-extension.js +87 -0
- package/dist/brand.js +76 -0
- package/dist/browser.js +58 -0
- package/dist/cache-report.js +139 -0
- package/dist/checkpoint.js +437 -0
- package/dist/claims.js +167 -0
- package/dist/cli-auth.js +142 -0
- package/dist/cli-checkin.js +121 -0
- package/dist/cli-credentials.js +254 -0
- package/dist/clipboard.js +149 -0
- package/dist/collapse.js +129 -0
- package/dist/commands.js +381 -0
- package/dist/compaction-guard.js +81 -0
- package/dist/connect-prompt.js +22 -0
- package/dist/context-extension.js +17 -0
- package/dist/dcp/commands.js +172 -0
- package/dist/dcp/compress-state.js +139 -0
- package/dist/dcp/compress.js +329 -0
- package/dist/dcp/dcp-extension.js +295 -0
- package/dist/dcp/dedup.js +93 -0
- package/dist/dcp/ids.js +189 -0
- package/dist/dcp/index.js +25 -0
- package/dist/dcp/middle-prune.js +76 -0
- package/dist/dcp/prompts.js +68 -0
- package/dist/dcp/protected-content.js +221 -0
- package/dist/dcp/protected.js +161 -0
- package/dist/dcp/prune.js +418 -0
- package/dist/dcp/state.js +176 -0
- package/dist/errors.js +63 -0
- package/dist/extensions.js +48 -0
- package/dist/fatal.js +35 -0
- package/dist/feed.js +498 -0
- package/dist/fs-atomic.js +54 -0
- package/dist/gateway-errors.js +107 -0
- package/dist/git.js +230 -0
- package/dist/goal-extension.js +88 -0
- package/dist/goal.js +222 -0
- package/dist/hooks-extension.js +176 -0
- package/dist/hooks.js +443 -0
- package/dist/howtofix-account.js +834 -0
- package/dist/hud-line.js +158 -0
- package/dist/hwid.js +130 -0
- package/dist/interrupt.js +60 -0
- package/dist/json-events.js +50 -0
- package/dist/level-style.js +112 -0
- package/dist/loop-guard.js +95 -0
- package/dist/lsp-tools.js +32 -0
- package/dist/lsp.js +429 -0
- package/dist/main.js +573 -98
- package/dist/mcp-config.js +85 -0
- package/dist/mcp-lifecycle.js +147 -0
- package/dist/model-catalog.js +217 -0
- package/dist/model-facts.js +35 -0
- package/dist/model-resolve.js +65 -0
- package/dist/notes.js +78 -0
- package/dist/oauth-login.js +568 -0
- package/dist/paths.js +61 -0
- package/dist/permissions.js +298 -0
- package/dist/plan-mode.js +363 -0
- package/dist/preset-command.js +227 -0
- package/dist/preset-extension.js +35 -0
- package/dist/preset-mcp.js +292 -0
- package/dist/presets/mcp/rea/preset.json +28 -0
- package/dist/presets/mcp/rea/prompt.md +5 -0
- package/dist/presets/mcp/rea/skills/mcp-rea/SKILL.md +6 -0
- package/dist/presets/mcp/remotion/preset.json +27 -0
- package/dist/presets/mcp/remotion/prompt.md +7 -0
- package/dist/presets/mcp/remotion/skills/mcp-remotion/SKILL.md +6 -0
- package/dist/presets.js +727 -0
- package/dist/prompt-files.js +103 -0
- package/dist/prompt-text.js +41 -0
- package/dist/proxy.js +137 -0
- package/dist/quality/ast.js +196 -0
- package/dist/quality/cognitive.js +83 -0
- package/dist/quality/cyclomatic.js +30 -0
- package/dist/quality/halstead.js +83 -0
- package/dist/quality/index.js +18 -0
- package/dist/quality/length.js +3 -0
- package/dist/quality/maintainability.js +15 -0
- package/dist/quality/nesting.js +57 -0
- package/dist/quality/report.js +803 -0
- package/dist/quality/smells.js +67 -0
- package/dist/quality-tool.js +63 -0
- package/dist/read-only-commands.js +597 -0
- package/dist/repo-map.js +292 -0
- package/dist/roblox-connect.js +125 -0
- package/dist/rpc.js +91 -0
- package/dist/rtk.js +193 -0
- package/dist/sandbox.js +105 -0
- package/dist/schema.js +214 -0
- package/dist/serve.js +50 -0
- package/dist/session-lifecycle.js +19 -0
- package/dist/session-retention.js +111 -0
- package/dist/session.js +460 -0
- package/dist/sessions.js +100 -0
- package/dist/settings.js +148 -0
- package/dist/skills.js +35 -0
- package/dist/slop-tool.js +96 -0
- package/dist/spend-cap.js +43 -0
- package/dist/subagent.js +171 -0
- package/dist/tar.js +146 -0
- package/dist/theme.js +79 -0
- package/dist/thinking.js +45 -0
- package/dist/todo.js +114 -0
- package/dist/tool-loadout.js +102 -0
- package/dist/tool-render.js +769 -0
- package/dist/tools.js +176 -0
- package/dist/ui.js +4931 -0
- package/dist/update.js +551 -0
- package/dist/usage-segment.js +74 -0
- package/dist/web-tools.js +46 -0
- package/dist/web.js +265 -0
- package/dist/welcome.js +179 -0
- package/dist/workflow-engine.js +246 -0
- package/dist/workflow-progress.js +446 -0
- package/dist/workflow-view.js +195 -0
- package/dist/workflow.js +349 -0
- package/package.json +62 -15
- package/dist/chunk-27TRKD65.js +0 -2
- package/dist/chunk-3FYCFLNK.js +0 -1
- package/dist/chunk-3LZR7OEU.js +0 -1
- package/dist/chunk-56SEAGAQ.js +0 -1
- package/dist/chunk-5AWTL34S.js +0 -1
- package/dist/chunk-75P2SCOT.js +0 -1
- package/dist/chunk-7CHDNTH6.js +0 -1
- package/dist/chunk-7PHRNXLN.js +0 -34
- package/dist/chunk-AGGIYXN7.js +0 -2
- package/dist/chunk-AUDMRGWF.js +0 -189
- package/dist/chunk-C5E3SFOQ.js +0 -2
- package/dist/chunk-CMTKCUL5.js +0 -1
- package/dist/chunk-DAPXGSGD.js +0 -12
- package/dist/chunk-DOD7MUGX.js +0 -1
- package/dist/chunk-FPXVDP32.js +0 -8
- package/dist/chunk-GXB7RZHH.js +0 -1
- package/dist/chunk-I7KVLBMF.js +0 -2
- package/dist/chunk-ILDDDLRC.js +0 -1
- package/dist/chunk-JFYVRWJI.js +0 -2
- package/dist/chunk-LAHVHRCS.js +0 -2
- package/dist/chunk-LSJC73DG.js +0 -1
- package/dist/chunk-MNDKS6UH.js +0 -6
- package/dist/chunk-N345KWWK.js +0 -1
- package/dist/chunk-N3J2J7EQ.js +0 -5
- package/dist/chunk-ONZLNFQ2.js +0 -3
- package/dist/chunk-ORJ2QZBG.js +0 -3
- package/dist/chunk-PCALBZOO.js +0 -2
- package/dist/chunk-QPHSHL7H.js +0 -2
- package/dist/chunk-TKROS3BE.js +0 -5
- package/dist/chunk-TSEKPGK4.js +0 -1
- package/dist/chunk-UP7ENLEL.js +0 -117
- package/dist/chunk-UTYFLLSM.js +0 -1
- package/dist/chunk-V3R4FYTJ.js +0 -1
- package/dist/chunk-V656XVXV.js +0 -8
- package/dist/chunk-WKUJ7CFO.js +0 -1
- package/dist/chunk-WOT6VMZA.js +0 -1
- package/dist/chunk-WUPU6LTD.js +0 -4
- package/dist/chunk-WX3V5P7U.js +0 -5
- package/dist/chunk-XW6LMQGX.js +0 -1
- package/dist/chunk-YW7NORH3.js +0 -2
package/dist/chunk-UP7ENLEL.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import{b as Tr,c as Mr}from"./chunk-WX3V5P7U.js";import{a as Be}from"./chunk-LSJC73DG.js";import{a as pt,b as pn,c as hn,d as Oi,e as ht}from"./chunk-3FYCFLNK.js";import{u as Li}from"./chunk-WUPU6LTD.js";import{a as Ni}from"./chunk-ORJ2QZBG.js";import{Aa as dr,Ba as ur,C as wt,Ca as fr,D as Yi,Da as mr,F as Xi,Fa as ae,Ga as T,Ha as O,I as Ji,Ia as pr,J as Zi,Ja as hr,K as yt,Ka as gr,L as Qi,La as br,M as er,Ma as Cn,N as tr,Na as wr,O as $n,Oa as yr,Ra as kr,Sa as $r,Ta as vr,U as Ue,Ua as xr,Va as Sr,Wa as Cr,X as vn,Xa as Ar,Z as xn,aa as Ke,c as Wi,e as Ui,g as Ki,ga as nr,h as Hi,ha as He,ja as kt,n as qi,na as or,oa as ir,qa as rr,ra as sr,sa as ar,va as lr,w as Vi,y as kn,ya as Sn,z as zi,za as cr}from"./chunk-AUDMRGWF.js";import{a as Fi,c as gt,d as gn,j as ji,l as bn,m as wn,n as Di}from"./chunk-JFYVRWJI.js";import{b as ke,c as We,e as Bi,f as yn,g as Gi,h as bt}from"./chunk-27TRKD65.js";import{a as cn,b as dn,c as ui,d as fi}from"./chunk-3LZR7OEU.js";import{A as an,B as ln,C as ci,D as P,I as De,J as di,b as rn,c as ct,d as dt,e as Xo,f as Jo,g as Zo,h as Qo,i as ut,j as ei,k as sn,l as ti,o as te,p as ni,q as oi,t as ii,u as ri,v as si,w as ai,x as ft,y as mt,z as li}from"./chunk-V656XVXV.js";import{A as mn,B as Si,b as un,c as ye,d as hi,e as gi,h as bi,n as fn,o as wi,q as ie,s as Ae,u as yi,w as ki,x as $i,y as vi,z as xi}from"./chunk-MNDKS6UH.js";import{a as Ci,b as Ai,c as Ti,d as Mi,f as Ri,g as Ei,h as Pi,i as Ii,l as _i}from"./chunk-QPHSHL7H.js";import{a as oe}from"./chunk-UTYFLLSM.js";import{h as mi,i as pi}from"./chunk-C5E3SFOQ.js";import{a as on,b as lt,e as Yo}from"./chunk-N3J2J7EQ.js";import"./chunk-WOT6VMZA.js";import{execFile as wl}from"node:child_process";import{promisify as yl}from"node:util";import{appendFileSync as kl,existsSync as Pt,mkdirSync as Jn,readFileSync as Zn,rmSync as $l,writeFileSync as Qn}from"node:fs";import{basename as vl,dirname as xl,join as le,resolve as Sl}from"node:path";function Rr(e){if(e==="")return!0;let t=/^\x1b\[(\d+);(\d+)u$/.exec(e);if(t&&Number(t[1])===99&&(Number(t[2])&5)!==0)return!0;let n=/^\x1b\[27;(\d+);(\d+)~$/.exec(e);return!!(n&&Number(n[2])===99&&(Number(n[1])&5)!==0)}function Er(e){let t=!1;process.on("SIGINT",()=>{t||(t=!0,e())})}function fa(e){if(!e||typeof e!="object")return;let t=e;if(!(typeof t.input!="number"&&typeof t.cacheRead!="number"&&typeof t.cacheWrite!="number"))return t}function ma(e){let t=e?.input??0,n=e?.cacheRead??0,i=e?.cacheWrite??0;return{input:t,cacheRead:n,cacheWrite:i,prompt:t+n+i}}function pa(e){if(typeof e!="string")return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function ha(e){if(!e||typeof e!="object")return;let t=e,i=(t.message&&typeof t.message=="object"?t.message:void 0)??t,s=fa(i.usage);if(!s)return;let d=typeof i.provider=="string"?i.provider:"",f=typeof i.model=="string"?i.model:"";return{usage:s,model:[d,f].filter(Boolean).join("/")}}function Pr(e){let t=0,n=0,i=[],s=0,d=null;for(let h of e){let w=ha(h);if(!w)continue;let{input:S,cacheRead:M,cacheWrite:D,prompt:F}=ma(w.usage);if(F===0)continue;t+=M,n+=S+D;let K=pa(h.timestamp),I=d,H=I?I.at:null;if(I!==null&&M===0&&S>=1e3){let L=K!==null&&H!==null?Math.max(0,K-H):0;i.push({missedTokens:S,idleMs:L,modelChanged:w.model!==""&&I.model!==""&&w.model!==I.model}),s+=S}d={prompt:F,at:K??H??null,model:w.model}}let f=t+n;return{cachedTokens:t,billedTokens:n,hitRate:f>0?t/f*100:null,misses:i,missedTokens:s}}function Ir(e){return e.modelChanged?"model changed, so its cache had to be built":e.idleMs>=3e5?`cache expired after ${Math.round(e.idleMs/1e3)}s idle`:e.idleMs>0?"prompt changed too early in the prefix to hit":"reason not recorded"}import{copyToClipboard as Cl,ProjectTrustStore as Al,SessionManager as Tl}from"@netrodev/hxf-coding-agent";import{CombinedAutocompleteProvider as Us,Container as Ml,Editor as Rl,matchesKey as Y,ProcessTerminal as El,ScrollView as Pl,KeybindingsManager as Gs,setKeybindings as qs,TUI_KEYBINDINGS as Vs,SelectList as Il,TuiAltScreen as _l,truncateToWidth as Ee,VStack as Ol,visibleWidth as _t,wrapTextWithAnsi as Ll}from"@netrodev/hxf-tui";import{spawn as ga}from"node:child_process";function ba(e,t,n=2e3){return new Promise(i=>{let s=!1,d,f=S=>{s||(s=!0,d!==void 0&&clearTimeout(d),i(S))},h;try{h=ga(e,[...t],{stdio:["ignore","pipe","ignore"]})}catch{f({ok:!1,stdout:""});return}d=setTimeout(()=>{h.kill("SIGKILL"),f({ok:!1,stdout:""})},n);let w=[];h.stdout?.on("data",S=>w.push(S)),h.on("error",()=>f({ok:!1,stdout:""})),h.on("close",S=>{f({ok:S===0,stdout:Buffer.concat(w).toString("utf8")})})})}function An(){return process.env.XDG_SESSION_TYPE==="wayland"||(process.env.WAYLAND_DISPLAY?.length??0)>0}async function wa(){let e=[];process.platform==="darwin"?e.push({command:"pbpaste",args:[]}):process.platform==="win32"?e.push({command:"powershell.exe",args:["-NoProfile","-Command","Get-Clipboard -Raw"]}):(An()&&(e.push({command:"wl-paste",args:["--no-newline","--type","text/plain;charset=utf-8"]}),e.push({command:"wl-paste",args:["--no-newline","--type","text/plain"]}),e.push({command:"wl-paste",args:["--no-newline"]})),((process.env.DISPLAY?.length??0)>0||!An())&&(e.push({command:"xclip",args:["-selection","clipboard","-o"]}),e.push({command:"xsel",args:["--clipboard","--output"]})),e.push({command:"termux-clipboard-get",args:[]}));for(let t of e){let n=await ba(t.command,t.args);if(n.ok&&n.stdout.length>0)return n.stdout}}async function _r(){let e;try{let{getNativeClipboard:i}=await import("@netrodev/hxf-tui");e=i()}catch{e=void 0}if(e)try{let i=await e.getText();if(typeof i=="string"&&i.length>0)return{ok:!0,text:i}}catch{}let t=await wa();return t!==void 0?{ok:!0,text:t}:{ok:!1,reason:`no clipboard tool could read it \u2014 ${An()?"install wl-clipboard (wl-paste)":process.platform==="darwin"?"pbpaste should be present on macOS":process.platform==="win32"?"Get-Clipboard should be present on Windows":"install xclip or xsel, or run under a display"}`}}import{TreeSelectorComponent as Nl,initTheme as Fl}from"@netrodev/hxf-coding-agent";import{getKeybindings as Ks}from"@netrodev/hxf-tui";import{mixColors as ya,parseColor as ka,styleText as de}from"@netrodev/hxf-tui";var ue=process.env.HOWTOFIX_NO_MOTION!=="1",$a=45,Or=5,Lr=8,Tn=1e4,Nr=6e4,Fr=3,jr=4,Mn=e=>e<0?0:e>1?1:e;function fe(e,t,n){let i=Mn(n);return i>=1?t:i<=0?e:ya(e,t,i)}var $t=class{value;velocity=0;last=Date.now();target;constructor(t,n=t){this.value=t,this.target=n}set(t){this.target=t}get moving(){return Math.abs(this.target-this.value)>.15}snap(t){this.value=t,this.target=t,this.velocity=0,this.last=Date.now()}step(t=Date.now()){let n=Math.max(0,t-this.last),i=Math.min(250,n)/1e3;if(this.last=t,!ue)return this.value=this.target,this.velocity=0,this.value;n>250&&(this.velocity=0);let s=150,d=2*Math.sqrt(s),f=Math.max(1,Math.ceil(i/.008)),h=i/f;for(let w=0;w<f;w+=1)this.velocity+=(this.target-this.value)*s*h-this.velocity*d*h,this.value+=this.velocity*h;return this.moving||(this.value=this.target,this.velocity=0),this.value}};function Rn(e,t,n,i){return!ue||e<=Tn?t:e>=Nr?i:fe(n,i,(e-Tn)/(Nr-Tn))}function Dr(e,t){return!ue||t<=0||e<0?1:1-(1-Mn(e/t))**3}function Wr(e,t){return ue&&e>=0&&e<t}var En=260,va=45;function Pn(e,t,n=va,i=400){return!ue||n<=0||e<0||e>=i?t:Math.min(t,Math.floor(e/n)+1)}function Ur(e,t,n=Date.now(),i=1400){if(!ue||i<=0)return e;let s=n%i/i;return fe(e,t,s<.5?s*2:(1-s)*2)}function Kr(e,t,n){let i=de(e,{fg:t.rest},ae);if(!ue||e.length===0)return i;let s=Mn(n);if(s>=1)return i;let d=t.band??1,f=e.length+jr*2,w=Math.min(f-1,Math.floor(s*f))-jr,S=H=>{let L=Math.abs(H-w);return L>d?0:1-L/(d+1)},M="",D=0,F=null,K=0,I=0;for(let H of e){let L=S(I);F===null?F=L:L!==F&&(M+=de(e.slice(D,K),{fg:fe(t.rest,t.lit,F)},ae),D=K,F=L),K+=H.length,I+=1}return M+de(e.slice(D),{fg:fe(t.rest,t.lit,F??0)},ae)}function In(e,t,n=Date.now(),i=90){let s=t[0]??ka("#e6e6e6");if(t.length===0||e.length===0)return de(e,{fg:s},ae);if(!ue||i<=0)return de(e,{fg:t[t.length-1]??s},ae);let d=t.length*i,f=(n%d+d)%d,h="",w=0,S=null,M=0,D=0,F=K=>{let I=(f+K*i)/d%1*t.length,H=Math.floor(I)%t.length,L=(H+1)%t.length;return fe(t[H]??s,t[L]??s,I-Math.floor(I))};for(let K of e){let I=F(D);S===null?S=I:I!==S&&(h+=de(e.slice(w,M),{fg:S},ae),w=M,S=I),M+=K.length,D+=1}return h+de(e.slice(w),{fg:S??s},ae)}function xa(e,t){let n=Math.abs(e-t);return n>=Or?0:Math.ceil((1-n/Or)*Fr)/Fr}function Hr(e,t,n=Date.now()){let i=t.charMs??$a;if(!ue||e.length===0||i<=0)return de(e,{fg:t.base},ae);let s=e.length+Lr*2,d=n/i%s-Lr,f=(F,K)=>de(F,{fg:fe(t.base,t.bright,K)},ae),h="",w=0,S=null,M=0,D=0;for(let F of e){let K=xa(D,d);S===null?S=K:K!==S&&(h+=f(e.slice(w,M),S),w=M,S=K),M+=F.length,D+=1}return h+f(e.slice(w),S??0)}import{Markdown as Ua,wrapTextWithAnsi as Ka}from"@netrodev/hxf-tui";import{homedir as Sa}from"node:os";import{isAbsolute as Ca,relative as Aa,resolve as Ta,sep as Br}from"node:path";var Ma="\u25CF",Ln="\u2514",xt="\u22EF",_n=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function Ve(e=90){let t=Math.floor(Date.now()/e)%_n.length;return _n[t]??_n[0]}var Ra="\u25B2";var Ea="\u25CB",Pa=["create_object","set_properties","delete_object","clone_instance","reparent_instance","set_script_source","edit_script_lines","insert_script_lines","execute_luau","generate_mesh","generate_material","generate_procedural_model"];function Nn(e){return e.includes("__")?e.slice(e.lastIndexOf("__")+2):e}function zr(e){return Pa.includes(Nn(e))}function Ge(e,t=process.cwd()){if(!e||!Ca(e))return e;let n=Ta(e),i=Aa(t,n);if(i==="")return".";if(i&&!i.startsWith(`..${Br}`)&&i!=="..")return i;let s=Sa();return s&&(n===s||n.startsWith(s+Br))?`~${n.slice(s.length)}`:n}function ne(e,t){let n=e.replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,Math.max(1,t-1))}\u2026`:n}function N(e,t){if(e&&typeof e=="object"){let n=e[t];if(typeof n=="string"&&n.length>0)return n;if(typeof n=="number")return String(n)}}function Ia(e,t=160){if(!e||typeof e!="object")return"";try{let n=JSON.stringify(e);return n&&n!=="{}"?ne(n,t):""}catch{return""}}function _a(e,t){switch(e){case"read":{let n=Ge(N(t,"path")??""),i=[N(t,"offset"),N(t,"limit")].filter(Boolean);return i.length>0?`${n} ${i.length===1?`offset=${i[0]}`:`offset=${i[0]}, limit=${i[1]}`}`:n}case"edit":case"write":return Ge(N(t,"path")??"");case"bash":case"powershell":{let n=N(t,"command")??"";return t?.run_in_background===!0?`${n} [background]`:n}case"bash_output":{let n=N(t,"task_id"),i=N(t,"filter");return n?i?`${n} filter=${i}`:n:"all tasks"}case"kill_shell":return N(t,"task_id")??"";case"compress":{let n=N(t,"topic")??"",i=Array.isArray(t.content)?t.content.length:0;return i>1?`${n} (${i} ranges)`:n}case"grep":{let n=N(t,"pattern")??"",i=N(t,"path");return i?`${n} in ${Ge(i)}`:n}case"find":case"glob":{let n=N(t,"pattern")??N(t,"glob")??"",i=N(t,"path");return i?`${n} in ${Ge(i)}`:n}case"ls":return Ge(N(t,"path")??".");case"task":return N(t,"agent")??"task";case"ask":return N(t,"question")??"";case"web_search":return N(t,"query")??"";case"web_fetch":return N(t,"url")??"";case"lsp":{let n=N(t,"action")??"lsp",i=N(t,"file")??"",s=N(t,"line");return s?`${n} ${i}:${s}`:`${n} ${i}`}case"quality":return N(t,"path")??"changed files";case"think":return"private";case"todo":{let n=N(t,"op")??"view",i=N(t,"task"),s=t?.items;return n==="init"&&Array.isArray(s)?`init ${s.length} task${s.length===1?"":"s"}`:i?`${n} ${i}`:n}case"context":{let n=N(t,"op")??"list",i=N(t,"key");return i?`${n} ${i}`:n}case"workflow":{let n=N(t,"path");if(n)return n;let i=N(t,"code")??"",s=/export\s+const\s+meta\s*=\s*\{[\s\S]*?name\s*:\s*["'`]([^"'`]+)/.exec(i)?.[1];if(s)return s;let d=i.trim().split(`
|
|
2
|
-
`)[0]??"";return d.length>40?`${d.slice(0,40)}\u2026`:d}default:return Ia(t)}}function $e(e,t,n=100){let i=Nn(e),d=i!==e?i:i.charAt(0).toUpperCase()+i.slice(1),f=zr(e)?Ra:Ma,h=ne(_a(i,t),n);return h?`${f} ${d}(${h})`:`${f} ${d}`}function Oa(e){let t=0,n=0;for(let i of e.split(`
|
|
3
|
-
`))i.startsWith("+")&&!i.startsWith("+++")?t+=1:i.startsWith("-")&&!i.startsWith("---")&&(n+=1);return{additions:t,removals:n}}function Te(e){let t=e?.content;return typeof t=="string"?t:Array.isArray(t)?t.map(n=>n&&typeof n=="object"&&n.type==="text"?String(n.text??""):"").join(""):""}function ze(e){let t=e?.details;return t&&typeof t=="object"?t:{}}function Fn(e){let t=e?.structuredContent;return t&&typeof t=="object"?t:{}}function Gr(e){let t=e.exit_code;return typeof t=="number"&&Number.isFinite(t)?t:void 0}function La(e){let t=[];if(e&&typeof e=="object"){t.push(e);let i=e.content;if(Array.isArray(i))for(let s of i){let d=s?.text;if(typeof d=="string")try{let f=JSON.parse(d);f&&typeof f=="object"&&t.push(f)}catch{}}}let n=[];for(let i of t){let s=["instances","instanceCount","count","parts","partsCreated"].map(w=>i[w]).find(w=>typeof w=="number"&&Number.isFinite(w));typeof s=="number"&&n.push(`${s} instance${s===1?"":"s"}`);let d=On(i,["files","written","paths"]);d&&n.push(d.join(", "));let f=On(i,["images","renders","screenshots"]);f&&n.push(`renders ${Ea} ${f.join(", ")}`);let h=On(i,["findings","warnings","errors"]);if(h&&n.push(`${h.length} finding${h.length===1?"":"s"}`),n.length>0)break}return n.length>0?n.join(" \xB7 "):void 0}function On(e,t){for(let n of t){let i=e[n];if(!Array.isArray(i))continue;let s=i.filter(d=>typeof d=="string"&&d!=="");if(s.length>0)return s}}function qr(e){return e.trim().split(`
|
|
4
|
-
`).find(t=>t.trim())??""}function Na(e,t){let n=typeof e.output=="string"?e.output:t.replace(/\n*Command exited with code \d+\s*$/,""),i=qe(n);return i>0?` (${i} line${i===1?"":"s"})`:""}function Fa(e,t,n){return e===1?t:n}function qe(e){let t=e.trim();return t?t.split(`
|
|
5
|
-
`).length:0}function Vr(e){return e<1e3?`${e} tokens`:`${(e/1e3).toFixed(1)}k tokens`}function St(e,t,n){let i=Te(t),s=ze(t),d=Fn(t);if(n){let f=Gr(d);if(f!==void 0&&(e==="bash"||e==="powershell"))return`exit ${f}`;let h=i.trim().split(`
|
|
6
|
-
`).find(w=>w.trim());return ne(h??"failed",120)}if(zr(e)){let f=La(t);if(f)return f;let h=Nn(e);return h==="execute_luau"?"ran":ne(h.replace(/_/g," "),120)}switch(e){case"task":{let f=i.split(`
|
|
7
|
-
`).filter(h=>h.startsWith("## ")).map(h=>h.replace(/^##\s*/,"").trim());if(f.length===0){let h=i.trim().split(`
|
|
8
|
-
`).find(w=>w.trim());return ne(h??"done",120)}return f.map(h=>ne(h,120)).join(`
|
|
9
|
-
`)}case"read":{let f=s.truncation,h=qe(i.replace(/\n*\[[^\]]*\]\s*$/,"")),w=h===0?"empty":`${h} line${h===1?"":"s"}`;return f?.truncated?`${w} (truncated from ${f.totalLines??"?"})`:w}case"compress":{let f=Array.isArray(s.blockIds)?s.blockIds:[],h=typeof s.compressedTokens=="number"?s.compressedTokens:0,w=typeof s.summaryTokens=="number"?s.summaryTokens:0,S=f.length===1?`b${String(f[0])}`:`${f.length} blocks`;if(h===0)return S;let M=h-w;return M<0?`${S} \xB7 ${Vr(-M)} LARGER than the range`:`${S} \xB7 ${Vr(M)} saved`}case"edit":{let f=typeof s.diff=="string"?s.diff:"";if(!f)return"applied";let{additions:h,removals:w}=Oa(f);return`+${h} / -${w}`}case"write":{let f=qe(i);return f===0?"written":`written (${f} ${Fa(f,"line","lines")})`}case"bash":case"powershell":{let f=Gr(d);if(f===void 0)return i.trim()?ne(qr(i),120):"done";let h=Na(d,i);return f===0?`exit 0${h}`:`exit ${f}`}case"grep":{let f=qe(i);return f===0?"no matches":`${f} match${f===1?"":"es"}`}case"web_search":{let f=typeof s.count=="number"?s.count:qe(i);return f===0?"no results":`${f} result${f===1?"":"s"}`}case"web_fetch":return`${typeof s.chars=="number"?s.chars:i.length} chars`;case"lsp":{let f=typeof s.count=="number"?s.count:void 0;return typeof s.error=="string"?ne(s.error,120):f===void 0?ne(qr(i),120):`${f} location${f===1?"":"s"}`}case"quality":{if(typeof s.error=="string")return ne(s.error,120);if(s.off===!0)return"off";let f=typeof s.files=="number"?s.files:0,h=typeof s.functions=="number"?s.functions:0,w=typeof s.findings=="number"?s.findings:0,S=typeof s.score=="number"?` \xB7 ${Math.round(s.score)}`:"";return f===0?"no files":`${f} file${f===1?"":"s"} \xB7 ${h} fn \xB7 ${w} finding${w===1?"":"s"}${S}`}case"todo":{let f=s.todos??[];if(!Array.isArray(f)||f.length===0)return"list cleared";let h=f.filter(S=>S.status==="completed").length,w=f.filter(S=>S.status==="pending"||S.status==="in_progress").length;return`${h}/${f.length} done, ${w} open`}case"context":{let f=s.notes,h=f?Object.keys(f).length:0;return h===0?"no notes":`${h} note${h===1?"":"s"} held`}case"workflow":{let f=typeof s.agents=="number"?s.agents:0,h=typeof s.outputTokens=="number"?s.outputTokens:0,w=Array.isArray(s.steps)?s.steps.filter(M=>M.status==="failed").length:0;if(typeof s.error=="string")return`failed after ${f} agent(s)`;let S=typeof s.startedAt=="number"&&typeof s.endedAt=="number"?`, ${gr(s.endedAt-s.startedAt)}`:"";return`${f} agent(s), ${h} tokens${S}${w>0?`, ${w} failed`:""}`}case"bash_output":{let f=i.trim().split(`
|
|
10
|
-
`)[0]??"",h=/running/.test(f)?"running":/finished/.test(f)?"finished":"task",w=i.trim().split(`
|
|
11
|
-
`).slice(2).filter(S=>S.trim()).length;return w===0?h:`${h} \xB7 ${w} line${w===1?"":"s"}`}case"kill_shell":{let f=i.trim().split(`
|
|
12
|
-
`)[0]??"";return f.startsWith("Stopped")?"stopped":ne(f,120)}default:{let f=i.trim().split(`
|
|
13
|
-
`).find(h=>h.trim());return f?ne(f,120):"done"}}}function Yr(e,t){let n=ze(t);if(e==="edit"&&typeof n.diff=="string")return n.diff.split(`
|
|
14
|
-
`).filter(i=>i.length>0).slice(0,12);if(e==="bash"||e==="powershell"){if(Te(t).startsWith("Started bash_"))return[];let s=Fn(t);return(typeof s.output=="string"?s.output:Te(t).replace(/\n*Command exited with code \d+\s*$/,"")).trimEnd().split(`
|
|
15
|
-
`).filter(h=>h.trim()).slice(-4)}if(e==="bash_output")return Te(t).split(`
|
|
16
|
-
`).slice(2).filter(s=>s.trim()).slice(-6);if(e==="todo"){let i=n.todos??[],s={pending:"[ ]",in_progress:"[>]",completed:"[x]",dropped:"[-]"};return i.slice(0,6).map(d=>`${s[d.status??"pending"]??"[ ]"} ${d.content??""}`)}return e==="task"?Te(t).split(`
|
|
17
|
-
`).filter(i=>i.trim()&&!i.startsWith("## ")).slice(0,6):e==="workflow"?(n.steps??[]).map(d=>{let f=d.status==="running"?"\u25B8":d.status==="failed"?"\xD7":"\u2713",h=d.phase?`${d.phase} \xB7 `:"";return`${f} ${h}${d.label??"agent"}`}).slice(-6):[]}var vt=400;function Xr(e,t){let n=ze(t);if(e==="edit"&&typeof n.diff=="string")return n.diff.split(`
|
|
18
|
-
`).filter(h=>h.length>0).slice(0,vt);let i=Fn(t),d=(typeof i.output=="string"?i.output:Te(t).replace(/\n*Command exited with code \d+\s*$/,"")).trimEnd().split(`
|
|
19
|
-
`),f=d.slice(0,vt);return d.length>vt&&f.push(`\u2026 ${d.length-vt} more line(s)`),f}var ja={read:{active:"Reading",done:"Read",one:"file",many:"files"},search:{active:"Searching for",done:"Searched for",one:"pattern",many:"patterns"},list:{active:"Listing",done:"Listed",one:"directory",many:"directories"}};function Da(e){if(e==="read")return"read";if(e==="grep"||e==="find"||e==="glob")return"search";if(e==="ls")return"list"}function Jr(e,t=!1){let n=[],i,s=()=>{if(!i||i.indices.length<2){i=void 0;return}n.push({start:i.indices[0],indices:i.indices,counts:i.counts,summary:Wa(i.counts,t)}),i=void 0};for(let[d,f]of e.entries()){let h=Da(f.toolName);if(h===void 0){s();continue}i||(i={indices:[],counts:{}}),i.indices.push(d),i.counts[h]=(i.counts[h]??0)+1}return s(),n}function Wa(e,t){let n=[];for(let i of["search","read","list"]){let s=e[i];if(s===void 0)continue;let d=ja[i],f=t?d.active:d.done,h=s===1?d.one:d.many;n.push(`${n.length===0?f:f.toLowerCase()} ${s} ${h}`)}return n.join(", ")}function Qr(e,t){let n=e[e.length-1];return n&&n.kind==="note"&&n.title===t.title?[...e.slice(0,-1),t]:[...e,t]}function jn(e){return typeof e=="string"?Ue(e):Ue(e.map(t=>t.type==="text"?t.text:t.type==="thinking"?"":t.type==="image"?"[image]":(t.type==="toolCall","")).filter(Boolean).join(""))}function es(e){return e.role==="user"?jn(e.content).trim():""}function ts(e,t,n){let i=t.trim();if(!i)return e;let s=e.findIndex(f=>f.kind==="user"&&f.body.trim()===i);if(s===-1)return[...e,{id:n,kind:"user",title:"you",body:i}];let d=[...e];return d[s]={id:n,kind:"user",title:"you",body:i},d}function Ha(e){return e.content.filter(t=>t.type==="toolCall").map(t=>({name:t.name,arguments:t.arguments}))}function Ba(e){return e.content.filter(t=>t.type==="toolCall").map(t=>t.id)}function Ga(e){let t=e.map(f=>({toolName:f.kind==="result"||f.kind==="tool"?f.title:"",line:f.call??f.body})),n=Jr(t);if(n.length===0)return e;let i=new Map(n.map(f=>[f.start,f])),s=new Set(n.flatMap(f=>f.indices)),d=[];for(let[f,h]of e.entries()){let w=i.get(f);if(w){let S=e[w.start];d.push({id:S?.id??`g-${w.start}`,kind:"collapsed",title:"collapsed",body:w.summary,full:w.indices.map(M=>e[M]?.call??e[M]?.body??"").filter(Boolean)});continue}s.has(f)||d.push(h)}return d}function At(e){let t=[];for(let n of e)if(n.role==="user"){let i=jn(n.content).trim();if(!i)continue;t.push({id:`u-${n.timestamp}`,kind:"user",title:"you",body:i})}else if(n.role==="assistant"){let i=jn(n.content).trim(),s=Ha(n),d=Ba(n);i?t.push({id:`a-${n.timestamp}`,kind:n.stopReason==="error"?"error":"assistant",title:n.errorMessage?"failed":"fix",body:n.errorMessage?`${n.errorMessage}
|
|
20
|
-
|
|
21
|
-
${i}`:i}):n.errorMessage&&t.push({id:`e-${n.timestamp}`,kind:"error",title:"failed",body:n.errorMessage}),s.forEach((f,h)=>{let w=d[h];t.push({id:w?`tool-${w}`:`c-${n.timestamp}-${h}`,kind:"tool",title:f.name,body:$e(f.name,f.arguments),...w?{call:$e(f.name,f.arguments)}:{}})})}else if(n.role==="toolResult"){let i=St(n.toolName,{content:n.content},n.isError),s=t.find(d=>d.id===`tool-${n.toolCallId}`);s?(s.kind="result",s.body=i,s.title=n.toolName):t.push({id:`r-${n.toolCallId}`,kind:"result",title:n.toolName,body:i})}return Ga(t)}function Zr(e,t,n){return Ka(e,Math.max(8,t)).map(i=>O(i,n))}var Ye=new Map;function qa(e){let t=e.body||" ",n=Ye.get(e.id);if(n)return n.text!==t&&(n.component.setText(t),n.text=t),n.component;let i=new Ua(t,0,0,pr);return Ye.set(e.id,{text:t,component:i}),i}var Dn=class{constructor(t){this.item=t}item;invalidate(){}shade(t){let n=Date.now()-(this.item.born??0);return fe(T.dim,t,Dr(n,En))}render(t){let n=this.item.body;if(this.item.kind==="user"){let s=this.item.pending?[O(" queued \u2014 the run reads this at its next step",T.dim)]:[];return["",...Zr(`> ${n}`,t,this.shade(T.user)),...s]}if(this.item.kind==="tool")return[O(`${Ve()} ${n}`,this.shade(T.tool))];if(this.item.kind==="collapsed"){let s=[O(`${xt} ${n}`,this.shade(T.mute))],d=this.item.full??[];if(d.length>0)if(this.item.expanded===!0)for(let f of d)s.push(O(` ${f}`,this.shade(T.dim)));else s.push(O(` ${d.length} call(s) \xB7 ctrl+e to expand`,T.dim));return s}if(this.item.kind==="result"){let s=n.startsWith("exit ")&&n!=="exit 0";if(this.item.panel)return["",...this.item.panel(t),...n?[O(` ${Ln} ${n}`,s?T.bad:T.mute)]:[]];let d=[];this.item.call&&d.push(O(this.item.call,this.shade(T.tool)));let f=` ${Ln} ${n}`;if(d.push(O(f,s?T.bad:this.shade(T.mute))),this.item.expanded===!0&&(this.item.full?.length??0)>0){let M=O(` ${this.item.full.length} line(s) \xB7 ctrl+e to collapse`,T.dim);d.push(O(` ${xt}`,T.dim));for(let D of this.item.full){let F=D.startsWith("+")?T.tool:D.startsWith("-")?T.bad:T.dim;d.push(O(` ${D}`,F))}return d.push(M),d}let w=this.item.detail??[],S=Pn(Date.now()-(this.item.born??0),w.length);for(let M of w.slice(0,S)){let D=M.startsWith("+")?T.tool:M.startsWith("-")?T.bad:T.dim;d.push(O(` ${M}`,this.shade(D)))}return(this.item.full?.length??0)>0&&d.push(O(` ${xt} ${this.item.full.length} line(s) \xB7 ctrl+e to expand`,T.dim)),d}if(this.item.kind==="error"||this.item.kind==="note"){let s=this.item.kind==="error"?T.bad:T.mute;return["",...Zr(n,t,this.shade(s))]}return["",...qa(this.item).render(Math.max(8,t-2))]}},Ct=class{items=[];status="";scrollOffset=0;scrollAnchor;settledOffset=0;viewportHeight=0;invalidate(){}entering(){let t=Date.now();return this.items.some(n=>{if(n.born===void 0)return!1;let i=t-n.born;return Wr(i,En)?!0:(n.detail?.length??0)>Pn(i,n.detail?.length??0)})}render(t){if(Ye.size>this.items.length){let s=new Set(this.items.map(d=>d.id));for(let d of Ye.keys())s.has(d)||Ye.delete(d)}let n=[];for(let s of this.items)s.born??=Date.now(),n.push(...new Dn(s).render(t));this.status&&n.push(O(this.status,T.mute));let i=this.viewportHeight;if(i>0&&n.length>i){let s=n.length-i;this.scrollOffset!==this.settledOffset&&(this.scrollAnchor=void 0);let d=this.scrollAnchor,f;if(d!==void 0){let h=n.length-d;h>=0&&h<=s?f=h:f=Math.max(0,Math.min(this.scrollOffset,s))}else f=Math.max(0,Math.min(this.scrollOffset,s));return d===void 0&&(this.scrollOffset=f),this.settledOffset=this.scrollOffset,f===0?this.scrollAnchor=void 0:this.scrollAnchor===void 0&&(this.scrollAnchor=n.length-f),n.slice(s-f,s-f+i)}return n}};function ns(){let e=null;return{get armed(){return e!==null},arm(t){return e=t,!0},disarm(){let t=e;return t===null?!1:(e=null,t(),!0)}}}import{parseColor as Q}from"@netrodev/hxf-tui";var me={off:Q("okhsl(230 12% 46%)"),minimal:Q("okhsl(240 55% 49%)"),low:Q("okhsl(252 60% 55%)"),medium:Q("okhsl(270 64% 60%)"),high:Q("okhsl(298 70% 64%)"),xhigh:Q("okhsl(332 80% 66%)"),max:Q("okhsl(42 95% 64%)")},os={off:Q("okhsl(230 14% 64%)"),minimal:Q("okhsl(240 60% 64%)"),low:Q("okhsl(252 64% 68%)"),medium:Q("okhsl(270 68% 72%)"),high:Q("okhsl(298 74% 76%)"),xhigh:Q("okhsl(332 82% 78%)"),max:Q("okhsl(42 96% 76%)")};function Tt(e){return me[e]??me.medium}var Wn=[me.minimal,me.low,me.medium,me.high,me.xhigh,me.max];function rs(e){return os[e]??os.medium}var is=460;function Mt(e){return!Number.isFinite(e)||e<0||e>=is?0:1-e/is}var q=["off","minimal","low","medium","high","xhigh","max"];function ss(e){let t=e?.thinkingLevelMap;if(t===void 0)return q[q.length-1];for(let n=q.length-1;n>=0;n-=1)if(typeof t[q[n]]=="string")return q[n]}function as(e){let t=q.indexOf(e);return q[(t+1+q.length)%q.length]}function ls(e){let t=q.indexOf(e);return q[(t-1+q.length)%q.length]}import{mkdirSync as Xa,readFileSync as Ja}from"node:fs";import{dirname as Za}from"node:path";var Kn="\x1B[0m",V="\x1B[2m",Va="\x1B[1m",za="\x1B[31m",Hn="\x1B[32m",ds="\x1B[33m",cs="\x1B[35m",Un="\x1B[36m";function j(e,t){return`${t}${e}${Kn}`}function us(e,t){return O(e,Tt(t))}function fs(e){return e>=85?za:e>=70?ds:Hn}var Ya="\u2726";function ms(e,t,n,i){let s=j(`[${e}]`,Un),d=`${j(Ya,V)} ${t}`,f=j(n,ds),h=i?` ${j("git:(",cs)}${j(i.replace(/^git:\(/,"").replace(/\)$/,""),Un)}${j(")",cs)}`:"";return`${s}${j(" \u2502 ",V)}${d}${j(" \u2502 ",V)}${f}${h}`}function ps(e,t,n){if(!t)return e;let i=n===void 0?t:`${t} ${j(br(n),V)}`;return`${j(i,Un)} ${j("\u2502",V)} ${e}`}function hs(e,...t){let n=Number.isFinite(e)?Math.min(100,Math.max(0,e)):0,i=Math.round(n/10),s=fs(n),d=`${s}${"\u2588".repeat(i)}${V}${"\u2591".repeat(10-i)}${Kn}`,f=j(`${Math.round(n)}%`,s),h=t.filter(Boolean).join(j(" \u2502 ",V));return`${j("Context",V)} ${d} ${f}${h?`${j(" \u2502 ",V)}${h}`:""}`}function gs(e){return!Number.isFinite(e)||e<=0?"":`${j("Spent",V)} ${j(`$${e.toFixed(3)}`,Hn)}`}function Bn(e,t,n,i){let s=Number.isFinite(t)&&t>0?t:0,d=Number.isFinite(n)?Math.max(0,n):0,f=Math.max(0,s-d),h=s>0?Math.min(100,d/s*100):0,w=Math.round(h/10),S=fs(h),M=`${S}${"\u2588".repeat(w)}${V}${"\u2591".repeat(10-w)}${Kn}`,D=F=>F!==0&&Math.abs(F)<.01?`${F.toFixed(6).replace(/0+$/,"").replace(/\.$/,"")} ${i}`:`${F.toFixed(2)} ${i}`;return[`${j(e,Va)}${j(" account",V)}`,` ${j("used",V)} ${M} ${j(`${h.toFixed(1)}%`,S)}`,` ${j("granted",V)} ${D(s)}`,` ${j("spent",V)} ${D(d)}`,` ${j("remaining",V)} ${j(D(f),S)}`]}function Me(e,t,n){let i=n===null?"":j(` ${n}ms`,V),s=t&&t!=="USD"?`${t} `:"";return`${j("Balance",V)} ${j(`${s}${e}`,Hn)}${i}`}var Gn=De,Qa=18e4;async function el(e){let t=new Set((await e.modelRuntime.getAvailable()).map(s=>s.provider).filter(s=>ie(s))),n=ye.find(s=>t.has(s));return n?(await e.modelRuntime.getAuth(n))?.auth?.apiKey:void 0}function tl(){try{let e=JSON.parse(Ja(Gn,"utf8"));return!e.data||typeof e.cachedAt!="number"?void 0:{data:e.data,cachedAt:e.cachedAt}}catch{return}}function Rt(e){if(e.unlimited)return Me("unlimited","",e.latencyMs);let n=e.unit==="USD"||e.unit==="CNY"?`$${e.remaining.toFixed(2)}`:`${e.remaining.toLocaleString()}`,i=e.limit>0?Math.min(100,(1-e.remaining/e.limit)*100):0,s=e.limit>0?`${n} ${i.toFixed(0)}%`:n;return Me(s,e.unit,e.latencyMs)}async function bs(e){let t=tl();if(t&&Date.now()-t.cachedAt<Qa)return Rt(t.data);let n=await el(e);if(!n)return t?Rt(t.data):void 0;let i=Date.now(),s=await Ae(n,{timeoutMs:3e3});if(!s.ok)return t?Rt(t.data):void 0;let d={remaining:s.remaining??0,limit:s.limit??0,unit:s.unit,unlimited:s.unlimited,latencyMs:Date.now()-i};return Xa(Za(Gn),{recursive:!0}),oe(Gn,JSON.stringify({data:d,cachedAt:Date.now()})),Rt(d)}import{chmodSync as nl,existsSync as ol,readFileSync as il}from"node:fs";import{join as rl}from"node:path";function ws(e){return rl(e,"account-credential.json")}function ys(e,t){return Buffer.from(`${e}:${t}`,"utf8").toString("base64")}function qn(e){let t=e.trim();if(!t)return null;let n=s=>{let d=s.indexOf(":");return d<=0||d===s.length-1?null:{username:s.slice(0,d),password:s.slice(d+1)}},i=n(t);if(i)return i;try{let s=Buffer.from(t,"base64").toString("utf8");return s.includes(":")?n(s):null}catch{return null}}function ks(e,t,n){try{let i={credential:ys(t,n),username:t,savedAt:Math.floor(Date.now()/1e3)},s=ws(e);return oe(s,JSON.stringify(i,null,2)),nl(s,384),!0}catch{return!1}}function $s(e){try{let t=ws(e);if(!ol(t))return null;let n=JSON.parse(il(t,"utf8"));return!n?.credential||!n?.username?null:n}catch{return null}}async function sl(e,t){let n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:AbortSignal.timeout(2e4)}),i=await n.text(),s;try{s=JSON.parse(i)}catch{throw new Error(`the panel answered ${n.status} with something that is not JSON`)}let d=s;if(!n.ok||d.success===!1)throw new Error(d.message||`the panel answered ${n.status}`);return d.data}async function vs(e,t,n,i){let s=await sl(`${e}/api/auth/cli/credential`,{credential:ys(t,n),client_info:i});if(!s?.token)throw new Error("the panel accepted the credential but returned no key");return{token:s.token}}var al="/cli/checkin",ll=["Bearer",""].join(" ").trim(),cl=5e5;function Vn(e){return`$${(e/cl).toFixed(2)}`}async function xs(e,t,n,i,s){let d=new AbortController,f=setTimeout(()=>d.abort(),s);try{let h=await i(`${n}${al}`,{method:t,headers:{[mi]:pi(),"X-HowToFix-Device":Ci().id,Authorization:`${ll} ${e}`},signal:d.signal}),w={};try{w=await h.json()}catch{}return{status:h.status,body:w}}finally{clearTimeout(f)}}async function zn(e,t){let n=(t?.baseUrl??"https://api.howtofix.id/v1").replace(/\/+$/,""),i=t?.fetchImpl??fetch,s=t?.timeoutMs??1e4,d=e.trim();if(!d)return{ok:!1,enabled:!1,checkedInToday:!1,quotaToday:0,message:"no token given"};try{let{status:f,body:h}=await xs(d,"GET",n,i,s);if(f===401||f===403)return{ok:!1,enabled:!1,checkedInToday:!1,quotaToday:0,message:"the gateway rejected that token for the check-in status"};if(f>=400||h.success!==!0)return{ok:!1,enabled:!1,checkedInToday:!1,quotaToday:0,message:typeof h.message=="string"?h.message:`the gateway answered ${f}`};let w=h.data??{};return{ok:!0,enabled:w.enabled===!0,checkedInToday:w.checked_in_today===!0,quotaToday:Number(w.quota_today??0)||0,message:""}}catch(f){return{ok:!1,enabled:!1,checkedInToday:!1,quotaToday:0,message:f instanceof Error&&f.name==="AbortError"?"the gateway did not answer the check-in in time":"could not reach the gateway"}}}async function Ss(e,t){let n=(t?.baseUrl??"https://api.howtofix.id/v1").replace(/\/+$/,""),i=t?.fetchImpl??fetch,s=t?.timeoutMs??15e3,d=e.trim();if(!d)return{ok:!1,alreadyClaimed:!1,blocked:!1,quotaAwarded:0,message:"no token given"};try{let{status:f,body:h}=await xs(d,"POST",n,i,s);if(h.success===!0){let D=h.data??{};return{ok:!0,alreadyClaimed:!1,blocked:!1,quotaAwarded:Number(D.quota_awarded??0)||0,message:""}}let w=typeof h.message=="string"?h.message:`the gateway answered ${f}`,S=/device already claimed|account blocked|appeal/i.test(w);return{ok:!1,alreadyClaimed:!S&&/签到|check-?in|already|今日/.test(w)&&!/not enabled/i.test(w),blocked:S,quotaAwarded:0,message:w}}catch(f){return{ok:!1,alreadyClaimed:!1,blocked:!1,quotaAwarded:0,message:f instanceof Error&&f.name==="AbortError"?"the gateway did not answer the check-in in time":"could not reach the gateway"}}}function dl(e){return!e||!Number.isFinite(e)||e<=0?"":e>=1e6?`${Number((e/1e6).toFixed(1))}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function ul(e){if(!e)return"";if(e.input<=0&&e.output<=0)return"free";let t=n=>n===0?"0":String(Number(n>=1?n.toFixed(2):n.toFixed(3)));return`$${t(e.input)}/$${t(e.output)} per M`}function Cs(e){let t=dl(e.contextWindow),n=ul(e.cost);return[t?`${t} ctx`:"",n].filter(Boolean).join(" \xB7 ")}function As(){return{}}function Ts(e,t,n,i=Date.now()){let s={...e};return t==="run"?(n===void 0||n===""?delete s.run:s.run={label:n,since:e.run?.since??i},s):(n===void 0||n===""?delete s[t]:s[t]=n,s)}function Ms(e,t){let n={...e};return t===void 0?delete n.retry:n.retry=t,n}function fl(e){let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60);return n>0?`${n}m ${String(t%60).padStart(2,"0")}s`:`${t}s`}function Yn(e,t=72){let n=e.split(`
|
|
22
|
-
`).map(i=>i.trim()).find(i=>i!=="")??"";return n.length>t?`${n.slice(0,t-1)}\u2026`:n}function ml(e,t){let n=Math.max(0,Math.ceil((e.until-t)/1e3)),i=n>0?`in ${n}s`:"now",s=`retry ${e.attempt}/${e.maxAttempts} ${i}`,d=Yn(e.error);return d===""?s:`${s} \xB7 ${d}`}function Rs(e,t,n=Date.now()){return e.prompt?`? ${e.prompt}`:e.retry?`* ${ml(e.retry,n)}`:e.note?`* ${e.note}`:e.run?`${t} ${e.run.label} \xB7 ${fl(n-e.run.since)}`:e.tally?e.tally:""}function Es(e){return e instanceof Error?e.message:String(e)}var Xe=class{active;apply;report;pending;running;constructor(t){this.active=new Set(t.initial??[]),this.apply=t.apply,this.report=t.report??(n=>console.error(n))}activeServers(){return[...this.active]}reconcile(t){return this.pending=new Set(t),this.running?this.running:(this.running=this.drain().finally(()=>{this.running=void 0}),this.running)}async drain(){let t={added:[],removed:[],unchanged:[],problems:[]};for(;this.pending!==void 0;){let i=this.pending;this.pending=void 0;let s=await this.applyOnce(i);t.added.push(...s.added),t.removed.push(...s.removed),t.unchanged.push(...s.unchanged),t.problems.push(...s.problems)}let n=this.active;return t.added=t.added.filter(i=>n.has(i)),t.removed=[...new Set(t.removed.filter(i=>!n.has(i)))],t.added=[...new Set(t.added)],t.unchanged=[...new Set(t.unchanged.filter(i=>n.has(i)))],t}async applyOnce(t){let n=[...t].filter(d=>!this.active.has(d)),i=[...this.active].filter(d=>!t.has(d)),s=[...t].filter(d=>this.active.has(d));if(n.length===0&&i.length===0)return{added:[],removed:[],unchanged:s,problems:[]};try{await this.apply(n,i)}catch(d){let f=`mcp reconciliation failed: ${Es(d)}`;return this.report(f),{added:[],removed:[],unchanged:[],problems:[f]}}for(let d of n)this.active.add(d);for(let d of i)this.active.delete(d);return{added:n,removed:i,unchanged:s,problems:[]}}async dispose(){this.running&&await this.running.catch(()=>{});let t=[...this.active];if(t.length===0)return{added:[],removed:[],unchanged:[],problems:[]};try{return await this.apply([],t),this.active.clear(),{added:[],removed:t,unchanged:[],problems:[]}}catch(n){let i=`mcp teardown failed: ${Es(n)}`;return this.report(i),{added:[],removed:[],unchanged:[],problems:[i]}}}};import{mkdirSync as pl}from"node:fs";import{join as hl}from"node:path";import{matchesKey as Et}from"@netrodev/hxf-tui";var Xn=["all","running","failed","done"];function Is(){return{selectedPhase:0,filter:"all",paused:!1,expanded:!1,follow:!0}}function _s(e){if(Et(e,"up"))return"up";if(Et(e,"down"))return"down";if(Et(e,"enter"))return"enter";if(Et(e,"escape"))return"escape";if(e==="f")return"filter";if(e==="p")return"pause";if(e==="x")return"stop";if(e==="s")return"save"}function Ps(e,t,n){if(t.length===0)return e;let i=Math.max(0,Math.min(t.length-1,e.selectedPhase+n));return{...e,selectedPhase:i,follow:!1}}function gl(e){let t=Xn.indexOf(e);return Xn[(t+1)%Xn.length]}function Os(e,t,n){switch(t){case"up":return Ps(e,n,-1);case"down":return Ps(e,n,1);case"enter":return{...e,expanded:!e.expanded};case"filter":return{...e,filter:gl(e.filter)};case"pause":return{...e,paused:!e.paused};default:return e}}function Ls(e,t){switch(t){case"running":return e.filter(n=>n.status==="running");case"failed":return e.filter(n=>n.status==="failed");case"done":return e.filter(n=>n.status!=="running");default:return[...e]}}function Ns(e){return e==="all"?"":` \xB7 ${e}`}var Fs="ctrl+f";function js(e,t,n=!0){if(!n)return"Ctrl+F panel keys \xB7 Esc unpin";let i=["\u2191/\u2193 phase",e.expanded?"Enter collapse":"Enter drill in"];return i.push(e.expanded?"Esc back out":"Esc unpin"),i.push(`f filter${e.filter==="all"?"":` (${e.filter})`}`),t?(i.push(e.paused?"p resume":"p pause"),i.push("x stop")):e.paused&&i.push("p resume"),i.push("s save script"),e.paused&&i.unshift("paused"),i.join(" \xB7 ")}function bl(e){let t=e.trim();if(!(!t||t.length>64)&&!(t==="."||t==="..")&&/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(t)&&!t.includes(".."))return t}function Ds(e,t){if(!e)return{ok:!1,reason:"this run was started from a file, so it is already saved where you pointed the tool"};let n=bl(e.name);if(!n)return{ok:!1,reason:`"${e.name}" is not a usable filename, so the script was not written`};let i=hl(t,`${n}.js`);try{pl(t,{recursive:!0}),oe(i,e.code)}catch(s){return{ok:!1,reason:s instanceof Error?s.message:String(s)}}return{ok:!0,path:i}}function Ws(e){let t=()=>{};return{select:(n,i)=>e.select(n,i),confirm:(n,i)=>e.confirm(n,i),input:n=>e.input(n),notify:(n,i)=>e.notify(n,i),onTerminalInput:()=>t,setStatus:(n,i)=>e.setStatus(n,i),setWorkingMessage:t,setWorkingVisible:t,setWorkingIndicator:t,setHiddenThinkingLabel:t,setWidget:(n,i,s)=>{i!==void 0&&!Array.isArray(i)||e.setWidget?.(n,i,s?.placement)},setFooter:t,setHeader:t,setTitle:t,custom:async()=>{throw new Error("this screen has no custom component host; use the text commands instead")},pasteToEditor:t,setEditorText:t,getEditorText:()=>"",editor:async()=>{},addAutocompleteProvider:t,setEditorComponent:t,getEditorComponent:()=>{},theme:void 0,getAllThemes:()=>[],getTheme:()=>{},setTheme:()=>({success:!1,error:"themes are not available in the workbench"}),getToolsExpanded:()=>!1,setToolsExpanded:t}}var Hs={borderColor:()=>"",selectList:{selectedPrefix:e=>O(e,T.accent),selectedText:e=>O(e,T.text,{bold:!0}),description:e=>O(e,T.mute),scrollInfo:e=>O(e,T.dim),noMatch:e=>O(e,T.mute)}},zs=Symbol.for("@netrodev/hxf-tui/layout-node");function jl(e){if(typeof e!="object"||e===null)return;let t=e[zs];return typeof t=="function"?t.call(e):void 0}var to=yl(wl);async function Bs(e){try{let{stdout:t}=await to("git",["-C",e,"rev-parse","--abbrev-ref","HEAD"],{encoding:"utf8"}),n=t.trim();if(!n||n==="HEAD")return"";let{stdout:i}=await to("git",["-C",e,"status","--porcelain"],{encoding:"utf8"});return`git:(${n}${i.trim()?"*":""})`}catch{return null}}var no=class{folder;model;git;percent=0;meter=new $t(0);activity=As();live=!1;activitySince=Date.now();thinking="medium";ceiling=void 0;usage="";cost=0;skipPermissions=!1;constructor(t,n){this.folder=vl(t),this.model=n.split("/").at(-1)||"no-model",this.git=""}invalidate(){}settling(){return this.meter.moving}atCeiling(){return this.ceiling!==void 0&&this.thinking===this.ceiling}levelChangedAt=0;upgradeAt=0;upgradeFrom=void 0;setThinking(t){if(t===this.thinking)return;let n=d=>d==="high"||d==="xhigh"||d==="max",i=d=>({off:0,minimal:1,low:2,medium:3,high:4,xhigh:5,max:6})[d]??0,s=i(t)>i(this.thinking);s&&n(t)?(this.upgradeAt=Date.now(),this.upgradeFrom=this.thinking):!s&&this.upgradeAt!==0&&(this.upgradeAt=0,this.upgradeFrom=void 0),this.thinking=t,this.levelChangedAt=Date.now()}upgradeAmount(t=Date.now()){if(this.upgradeAt===0)return 0;let n=t-this.upgradeAt;return n<0||n>=3e3?0:1-n/3e3}upgrading(){return this.upgradeAmount()>0}levelFlashAmount(){return this.levelChangedAt===0?0:Mt(Date.now()-this.levelChangedAt)}flashing(){return this.levelFlashAmount()>0}levelText(t){if(this.upgrading())return In(this.thinking,Wn,t,45);if(this.atCeiling())return In(this.thinking,Wn,t);let n=this.levelChangedAt===0?Number.POSITIVE_INFINITY:t-this.levelChangedAt;return Mt(n)<=0?us(this.thinking,this.thinking):Kr(this.thinking,{rest:Tt(this.thinking),lit:rs(this.thinking)},1-Mt(n))}meterValue(){return this.meter.value!==this.percent&&this.meter.set(this.percent),this.meter.step()}beginRun(){this.live=!0,this.activitySince=Date.now()}waitedMs(){return Date.now()-this.activitySince}abandonAnimations(){this.meter.snap(this.percent)}render(t){let n=Date.now(),i=this.percent===0&&this.meter.value===0?0:this.meterValue(),s=this.levelText(n),d=ms(this.model,s,this.folder,this.git),f=[Ee(`${ps(d,this.live?Ve():"",this.live?this.waitedMs():void 0)} ${hs(i,this.usage,gs(this.cost))}`,t)];this.skipPermissions&&f.push(Ee(O("Permissions OFF \u2014 critical commands and the repeat guard are not enforced",T.bad),t));let h=tr();h&&f.push(Ee(O(h,T.warn),t));let w=zi(wt());w&&f.push(Ee(O(w,T.accent),t));let S=Rs(this.activity,Ve(),n),M=this.live?Hr(S,{base:Rn(this.waitedMs(),T.mute,T.warn,T.bad),bright:T.text,charMs:45},n):O(S,Rn(this.waitedMs(),T.mute,T.warn,T.bad));return f.push(Ee(M,t)),f}},oo=class{constructor(t){this.draw=t}draw;render(t){return this.draw(t)}invalidate(){}},io=class{constructor(t,n){this.editor=t;this.hud=n}editor;hud;focused=!1;invalidate(){this.editor.invalidate()}render(t){let n=Math.max(10,t-4),i=this.editor.render(n).filter(h=>_t(h)>0),s=i.length>0?i:[""],d="\u2500".repeat(Math.max(0,t-2)),f=s.map(h=>{let w=Math.max(0,n-_t(h));return`\u2502 ${h}${" ".repeat(w)} \u2502`});return[`\u250C${d}\u2510`,...f,`\u2514${d}\u2518`,...this.hud.render(t)]}handleInput(t){this.editor.handleInput(t)}};function Dl(e,t,n,i=!1,s=[]){let d=Math.max(24,n),f=d-4,h=(L,Z)=>{let pe=_t(L)>f?Ee(L,f,"\u2026"):L,ee=`${pe}${" ".repeat(Math.max(0,f-_t(pe)))}`;return`\u2502 ${Z?Z(ee):ee} \u2502`},w="\u2500".repeat(d-2),S=[h(` ${t}`),...e.render(f).map(L=>h(L))];S.push(h(" type to filter \xB7 \u2191\u2193 move \xB7 enter select \xB7 esc cancel"));let M=s.flatMap(L=>L===""?[""]:Ll(L,f)),D=M.length>0?[h(""),...M.map(L=>h(L,Z=>O(Z,T.mute)))]:[];if(!i)return["",`\u250C${w}\u2510`,...S,...D,`\u2514${w}\u2518`];let F=Ur(T.line,T.warn,Date.now(),1400),K=O("\u2502",F),I=(L,Z)=>O(`${L}${w}${Z}`,F),H=[...S,...D].map(L=>`${K}${L.slice(1,-1)}${K}`);return["",I("\u250C","\u2510"),...H,I("\u2514","\u2518")]}function Wl(e,t){let n=t.split(`
|
|
23
|
-
`).filter(Boolean),i=n.filter(f=>f.startsWith("Reason:")),s=n.filter(f=>!f.startsWith("Reason:")&&!f.startsWith("Allow tool:"));return[...e.endsWith(" wants to run")?[]:[e],...i,...s.length>0?["",...s]:[]]}function Re(e){let t=e.getContextUsage();if(t?.percent!==null&&t?.percent!==void 0)return Math.min(100,Math.round(t.percent));let n=e.model,s=[...e.state.messages].reverse().find(d=>d.role==="assistant")?.usage?.totalTokens;return!n||typeof s!="number"||!Number.isFinite(s)||n.contextWindow<=0?0:Math.min(100,Math.round(s/n.contextWindow*100))}function eo(e){let n=[["init","write project notes to AGENTS.md"],["model","choose a model"],["providers","list providers"],["thinking","set thinking level"],["approval","set what needs approval"],["settings","turn permission checks on or off"],["trust","trust this folder's .hxf settings, prompts and skills (status | on | off)"],["connect","sign in with email:password (or a base64 credential), or paste a key"],["sync","re-sync models from howtofix.id"],["usage","show the account's quota and what it has spent"],["update","install the newest release"],["login","save a provider API key"],["logout","remove a provider"],["new","start a new session"],["resume","resume another session"],["compact","compact the session"],["name","name this session"],["stats","session tokens and cost, cache hit rate and misses"],["rtk","compress long tool output before the model reads it"],["diff","show the working tree diff"],["commit","stage everything and commit"],["undo","undo the last commit"],["rewind","go back to an earlier message (Esc Esc)"],["review","ask the agent to review the diff"],["tools","list active tools"],["skills","list loaded skills"],["preset","browse, install and remove preset skill bundles"],["roblox","login | logout | status | tunnel on/off \u2014 Roblox sign-in and workspace link (alone: RoToolbox status)"],["proxy","route requests through a proxy, or show the current one"],["export","write the transcript to a markdown file"],["copy","copy the last answer to the clipboard"],["agents","show spawned agents"],["goal","set or view this session's goal"],["plan","toggle plan mode (design before editing)"],["workflow","show or clear the pinned workflow panel"],["dcp","dynamic context pruning: on | off | status | blocks | stats | context | decompress <bN> | sweep"],["context","what the next request carries, and what pruning saved"],["decompress","reopen one compressed block, e.g. /decompress b2"],["sweep","close compressed blocks no ref resolves"],["session","show the current model"],["help","list commands"],["quit","quit"],["exit","quit (alias)"]].map(([i,s])=>({name:i,description:s}));for(let i of e.promptTemplates)n.push({name:i.name,description:i.description});for(let i of e.extensionRunner.getRegisteredCommands())n.push({name:i.invocationName,description:i.description});return n}function ro(e,t){if(e!=="workflow")return;let n=ze(t);if(!(typeof n.name!="string"||!Array.isArray(n.steps)))return n}function Ul(e,t){let n=ro(e,t);return n?It(n):void 0}function It(e,t,n=!1){return i=>wr(e,[],i,t?.selectedPhase,t?Kl(e,t,n):void 0)}function Kl(e,t,n){return{filter:i=>Ls(i,t.filter),footerText:js(t,e.endedAt===void 0,n),filterLabel:Ns(t.filter),drill:t.expanded}}function Hl(){let e=new Gs(Vs,{"tui.altScreen.pageUp":[],"tui.altScreen.pageDown":[],"tui.altScreen.halfPageUp":[],"tui.altScreen.halfPageDown":[],"tui.altScreen.top":[],"tui.altScreen.bottom":[]});qs(e)}async function Qd(e){let t=new El,n,i=new _l(t,!0,void 0,{mouse:!0,onRightClickPaste:()=>n?.()}),s=new Ct,d=new no(e.cwd,e.modelLabel);d.skipPermissions=wn();let f=o=>{let r=Date.now();(async()=>{try{let a=Je(),l=k.getSessionStats().sessionId;if(!po){po=!0;try{await Cr(a,{keep:l})}catch{}}let u=await vr(a,l,o);u&&r>=Wt&&(mo=u,Wt=r)}catch{}})()},h=(o=!1)=>{!o&&!d.live||Bs(e.cwd).then(r=>{r!==null&&(d.git=r,v())})},w=new Rl(i,Hs,{paddingX:1}),S=new Map,M=(o,r)=>{r===void 0?S.delete(o):typeof r=="function"?S.set(o,r):S.set(o,()=>r)},D=()=>Math.max(20,t.columns),F,K=0,I=Is(),H,L=null,Z=!1,pe,ee=!1,Ys,Ot=()=>{!H||!Z||M("workflow",o=>It(H,I,ee)(o))},so=()=>{H&&(pe=H.name),Z=!1,ee=!1,M("workflow",void 0)};yr({onStop:o=>{L=o},isPaused:()=>I.paused});let ao=o=>{if(pe===o.name)return;F=o;let r=o.endedAt??Date.now();K=Math.max(K,r+hr),H=o,Z=!0,M("workflow",a=>It(o,I,ee)(a))},lo=new io(w,d),k=e.session,co=e.setCompressToolOutput,uo=!1,Lt=()=>{let o=k.getSessionStats().cost;return d.cost=o,o},Nt=ui(e.maxBudgetUsd),fo=!1,Xs=()=>{let o=Nt.check(Lt());o===void 0||fo||(fo=!0,k.isStreaming&&k.abort(),m("budget",fi(o.spent,o.limit)))},he=()=>{d.ceiling=ss(k.model)},ge=Pi(P),Ft,Js=async()=>!ge||!Ei(ge)||Ri(ge)?!1:(Ft??=(async()=>{try{let o=await _i(P,ge);return o.renewed?(ge=o.credential,o.message&&m("connect",o.message),await k.modelRuntime.setRuntimeApiKey("howtofix",o.credential.accessToken),!0):(o.message&&m("connect",o.message),!1)}catch{return!1}finally{Ft=void 0}})(),await Ft),jt,Je=()=>jt??=kr(e.cwd),mo,Dt="",Wt=0,po=!1,be,Zs=()=>{let o=new Set(["session_info","usage","label","context_edit","custom","model_change","thinking_level_change"]),r=[],a=l=>{for(let u of l)o.has(u.entry.type)||r.push(u.entry.id),a(u.children)};return a(k.sessionManager.getTree()),r},ho=!1,Qs=()=>{if(ho)return;ho=!0;let o=Ks().getResolvedBindings();qs(new Gs(Vs,{...o,"app.tree.foldOrUp":["alt+left","ctrl+left"],"app.tree.unfoldOrDown":["alt+right","ctrl+right"],"app.tree.editLabel":["shift+l"],"app.tree.toggleLabelTimestamp":["shift+t"],"app.message.copy":["ctrl+x"],"app.tree.filter.default":["alt+0"],"app.tree.filter.noTools":["alt+1"],"app.tree.filter.userOnly":["alt+2"],"app.tree.filter.labeledOnly":["alt+3"],"app.tree.filter.all":["alt+4"],"app.tree.filter.cycleForward":["alt+f"],"app.tree.filter.cycleBackward":["alt+shift+f"]}))},go=!1,ea=()=>{go||(go=!0,Fl())},bo=()=>{let o=k.sessionManager.getTree();if(o.length===0){m("rewind","nothing to rewind to yet");return}Je().disabled&&m("rewind","conversation rewind only; this directory is not a git repository"),ea(),Qs();let r=Math.max(8,Math.floor(t.rows*.6)),a=new Nl(o,k.sessionManager.getLeafId(),r*2,l=>{Ut(),ta(l)},()=>Ut());if(!a.getTreeList().getSelectedNode()){m("rewind","nothing to rewind to yet");return}be=a,be.focused=!0,M("rewind",l=>be?.render(l)??[]),v()},Ut=()=>{be=void 0,M("rewind",void 0),v()},ta=async o=>{let r=Je(),l=k.getUserMessagesForForking().findIndex(c=>c.entryId===o),u=l>=0?$r(r,k.getSessionStats().sessionId)[l]:void 0,y=u?(await Sr(r,u)).length:0;if(y===0){await wo(o,void 0,"conversation");return}_(`Rewind to this point? ${y} file(s) differ`,[{value:"both",label:"conversation and code",description:`drop the messages after this point and restore ${y} file(s)`},{value:"conversation",label:"conversation only",description:"drop the messages after this point, leave the files alone"},{value:"code",label:"code only",description:`restore ${y} file(s), keep the conversation`}],c=>{wo(o,u,c)})},wo=async(o,r,a)=>{let l=[];if((a==="both"||a==="conversation")&&!k.isStreaming)try{let u=await k.navigateTree(o);if(u.cancelled){m("rewind","conversation rewind cancelled");return}l.push("conversation rewound"),s.items=At(k.state.messages),u.editorText&&(w.setText(u.editorText),l.push("prompt restored to the editor"))}catch(u){G(`conversation rewind failed: ${u instanceof Error?u.message:String(u)}`);return}if((a==="both"||a==="code")&&r){let u=await xr(Je(),r);if(!u.ok){G(`code rewind failed: ${u.output}`);return}l.push(u.output),u.removed.length>0&&l.push(`removed ${u.removed.length} file(s)`),h()}m("rewind",l.join(`
|
|
24
|
-
`)||"nothing to do"),v()};h(!0),f("session start"),e.note&&s.items.push({id:"note",kind:"note",title:"note",body:e.note}),s.items.push(...At(k.state.messages)),d.percent=Re(k),Lt(),d.abandonAnimations(),d.setThinking(k.thinkingLevel),he(),w.setAutocompleteProvider(new Us(eo(k),e.cwd)),bs(k).then(o=>{o&&(d.usage=o,i.requestRender())});let yo=async o=>{let{checkForUpdate:r,checkFailedNote:a,installUpdate:l}=await import("./chunk-7CHDNTH6.js"),u=await r(o.current);if(!u.available){let c=a(u);c?m("update",c):o.install&&m("update",u.message);return}if(!o.install){m("update",`${u.message}. run /update to install it.`);return}A("note",`installing HowToFix ${u.latest}\u2026`);let y=await l({version:u.latest});A("note",void 0),m("update",y.message),v()};e.update&&yo(e.update);let se=null,ko="",$o=!1,vo=[],Pe,Kt=()=>{},v=()=>{Kt(),i.requestRender()},A=(o,r)=>{d.activity=Ts(d.activity,o,r)},Ht=o=>{d.activity=Ms(d.activity,o)},Ze=new Map,Bt=new Set,na=()=>[...Ze].map(([o,r])=>`${Bt.has(o)?"!":"\u2713"} ${o} \xD7${r}`).join(" | "),oa=()=>{let o=na();A("tally",o||void 0)},_=(o,r,a,l,u=!1,y=[])=>{let c=new Il(r,8,Hs.selectList);c.onSelect=p=>{se=null,Pe=void 0,a(p.value)},c.onCancel=()=>{se=null,Pe=void 0,l?.(),v()},Pe=()=>c.onCancel?.(),ko=o,$o=u,vo=y,se=c,Ao+=1,v()},m=(o,r)=>{s.items=Qr(s.items,{id:`cmd-${Date.now()}-${s.items.length}`,kind:"note",title:o,body:r}),A("tally",void 0),v()};lr(o=>{o.background&&m("agent",`${or(o)}
|
|
25
|
-
read it with /agents ${o.id}`)});let Gt=!1,xo=o=>{Gt||(Gt=!0,(async()=>{try{let r=(await k.modelRuntime.getAvailable()).filter(g=>ie(g.provider)),a=new Set(r.map(g=>g.provider)),l=ye.find(g=>a.has(g)),u=l?(await k.modelRuntime.getAuth(l))?.auth?.apiKey:void 0;if(!u)return;let y=kt(r.map(g=>g.id)),{live:c,probed:p}=await xi(y,u,{exclude:o,limit:4});if(c.length===0)return;let b=se===null;m("gateway",`${c.length} of ${p.length} probed models answer right now (${c.join(", ")}); ${b?"the model picker is open below":"switch with /model"}.`),b&&Fe("/model")}catch{}finally{Gt=!1}})())},G=o=>{s.items.push({id:`err-${Date.now()}-${s.items.length}`,kind:"error",title:"failed",body:o});let r=dn(o);r!==void 0&&m("gateway",r);let a=cn(o);a!==void 0&&xo(a),A("tally",void 0),v()},Ie=o=>{k.setThinkingLevel(o,{persist:!0}),d.setThinking(o),he(),A("note",`thinking ${o}`),v()};Di((o,r)=>{let{promise:a,resolve:l}=Promise.withResolvers();return _(o,[{value:"allow",label:"allow"},{value:"deny",label:"deny"}],u=>l(u==="allow"),()=>l(!1),!0,Wl(o,r)),a});let qt=new Map,So=o=>{let r=Ws({select:(a,l)=>{let{promise:u,resolve:y}=Promise.withResolvers();return _(a,l.map(c=>({value:c,label:c})),y,()=>y(void 0)),u},confirm:(a,l)=>{let{promise:u,resolve:y}=Promise.withResolvers();return _(`${a} \u2014 ${l}`,[{value:"yes",label:"yes"},{value:"no",label:"no"}],c=>y(c==="yes"),()=>y(!1)),u},input:a=>{let{promise:l,resolve:u}=Promise.withResolvers();return A("prompt",a),v(),re=y=>{re=void 0,A("prompt",void 0),u(y),v()},l},notify:(a,l)=>{l==="error"?G(a):m("mcp",a)},setStatus:(a,l)=>{l===void 0?qt.delete(a):qt.set(a,l),A("note",[...qt.values()].join(" | ")||void 0),v()},setWidget:(a,l)=>{M(a,l),v()}});o.bindExtensions({uiContext:r,mode:"print",onError:a=>G(`${a.event}: ${a.error}`)}).catch(a=>G(a instanceof Error?a.message:String(a)))};So(k);let ve=new Ml,ia={invalidate:()=>s.invalidate(),render:o=>{let r=ve.render(Math.max(20,o)).length;return s.viewportHeight=Math.max(1,Math.max(8,t.rows)-r),s.render(o)},handleMouse:o=>{if(No(o))return it(),{handled:!0};let r=o.type==="wheel"?o.wheelDelta??0:0;if(r!==0)return s.scrollOffset=Math.max(0,s.scrollOffset-r*3),v(),{handled:!0}}},ra=new Pl(ia,{follow:"none",overscroll:"contain"}),Qe=new Ol([{component:ra,grow:1,shrink:1},{component:ve,grow:0,shrink:0,basis:"auto"}]),Co="",Ao=0,sa=()=>`${se?`picker:${Ao}`:"dock"}|${[...S.keys()].join(",")}`;Kt=()=>{let o=sa();if(o===Co)return;Co=o,ve.clear();for(let a of S.values())ve.addChild(new oo(a));let r=se;if(r){let a=ko,l=$o,u=vo;ve.addChild({render:y=>Dl(r,a,y,l,u),invalidate:()=>{}})}else ve.addChild(lo);Qe.invalidate()},Kt();let To={focused:!1,invalidate(){s.invalidate(),lo.invalidate(),se?.invalidate(),Qe.invalidate()},[zs]:()=>jl(Qe),render:o=>Qe.render(o),handleMouse(o){if(No(o))return it(),{handled:!0}},handleInput(o){w.handleInput(o)}};i.setLayoutRoot(To),i.setFocus(To);let X=0,ce="",Vt=!1,we=!1,zt,xe="",Mo=0,_e=!1,et=Date.now(),tt=!1,nt=new Map,Ro=()=>{let o=new Set(k.getSteeringMessages().map(r=>r.trim()).filter(Boolean));for(let r of s.items)r.kind!=="user"||!r.pending||o.has(r.body.trim())||(r.pending=void 0)},Eo=o=>{if(o.type==="agent_start"&&Ro(),o.type==="agent_start"||o.type==="turn_start")o.type==="agent_start"&&Fi(),d.live||d.beginRun(),ce="",we=!1,_e=!1,et=Date.now(),xe="";else if(o.type==="message_update"&&o.assistantMessageEvent.type==="thinking_delta"){we=!0,xe===""&&(Mo=Date.now()),xe+=o.assistantMessageEvent.delta;let r=`think-${X}`,a=s.items.find(u=>u.id===r),l=xe.split(`
|
|
26
|
-
`).slice(-6).join(`
|
|
27
|
-
`);a?a.body=l:s.items.push({id:r,kind:"note",title:"thinking",body:l})}else if(o.type==="message_update"&&o.assistantMessageEvent.type==="thinking_end"){let r=`think-${X}`,a=s.items.find(l=>l.id===r);if(a){let l=Math.max(1,Math.round((Date.now()-Mo)/1e3));a.title="thought",a.body=`${l}s \xB7 ${xe.length} chars of reasoning`}xe=""}else if(o.type==="message_update"&&o.assistantMessageEvent.type==="text_delta"){we=!0,ce+=o.assistantMessageEvent.delta;let r=Ue(ce),a=`live-${X}`,l=s.items.find(u=>u.id===a);l?l.body=r:s.items.push({id:a,kind:"assistant",title:"HowToFix",body:r})}else if(o.type==="tool_execution_start"){nt.set(o.toolCallId,o.args),we=!1,_e=!1,et=Date.now();let r=`tool-${o.toolCallId}`,a=$e(o.toolName,o.args),l=s.items.find(u=>u.id===r);if(l?(l.kind="tool",l.title=o.toolName,l.body=a,l.live=!0):s.items.push({id:r,kind:"tool",title:o.toolName,body:a,live:!0}),zt=o.toolName,o.toolName==="task"){let u=ir.filter(y=>y.status==="queued"||y.status==="running");A("note",u.map(y=>`${y.agent} ${y.status}`).join(" | ")||"agent running")}}else if(o.type==="tool_execution_update"){let r=Ul(o.toolName,o.partialResult);if(r){let a=`tool-${o.toolCallId}`,l=s.items.find(y=>y.id===a);l?l.panel=r:s.items.push({id:a,kind:"tool",title:o.toolName,body:$e(o.toolName,nt.get(o.toolCallId)),panel:r,live:!0});let u=ro(o.toolName,o.partialResult);u&&pe!==u.name&&ao(u),v()}}else if(o.type==="tool_execution_end"){d.percent=Re(k);let r=s.items.find(b=>b.id===`tool-${o.toolCallId}`);r&&(r.live=!1,r.body=$e(o.toolName,nt.get(o.toolCallId))),nt.delete(o.toolCallId),zt=void 0,we=!0,_e=!1,Ze.set(o.toolName,(Ze.get(o.toolName)??0)+1),o.isError&&Bt.add(o.toolName),oa();let a=Yr(o.toolName,o.result),l=Xr(o.toolName,o.result),u=ro(o.toolName,o.result),y=u?It(u):void 0;u&&pe!==u.name&&ao(u);let c=s.items.find(b=>b.id===`tool-${o.toolCallId}`),p=St(o.toolName,o.result,o.isError);c?(c.kind="result",c.call=c.body,c.body=p,c.live=!1,a.length>0&&(c.detail=a),l.length>0&&(c.full=l),y&&(c.panel=y)):s.items.push({id:`tool-${o.toolCallId}`,kind:"result",title:o.toolName,body:p,...a.length>0?{detail:a}:{},...l.length>0?{full:l}:{},...y?{panel:y}:{}}),(o.toolName==="bash"||o.toolName==="powershell"||o.toolName==="edit"||o.toolName==="write")&&h()}else if(o.type==="compaction_start"){we=!0;let r=o.reason==="manual"?"on request":"context is nearly full",a=s.items.find(y=>y.id===`compact-${X}`),l="compacting context",u=`${r} \xB7 summarizing the older turns`;a?(a.title=l,a.body=u):s.items.push({id:`compact-${X}`,kind:"note",title:l,body:u,live:!0}),A("note","compacting context")}else if(o.type==="compaction_end"){let r=s.items.find(y=>y.id===`compact-${X}`),a=o.result,l="compacted",u;if(o.aborted)u="cancelled";else if(o.errorMessage)u=`failed: ${o.errorMessage}`;else if(a){let y=Math.round(a.tokensBefore/1e3),c=a.estimatedTokensAfter!==void 0?Math.round(a.estimatedTokensAfter/1e3):void 0,p=a.estimatedTokensAfter!==void 0?a.tokensBefore-a.estimatedTokensAfter:void 0,b=p!==void 0&&p<2e3;u=c!==void 0?`${y}k \u2192 ${c}k tokens \xB7 older turns summarized${b?`
|
|
28
|
-
this freed almost nothing; the window may be too small for this work`:""}`:`${y}k tokens \xB7 older turns summarized`}else u="nothing to compact";r?(r.title=l,r.body=u,r.live=!1):s.items.push({id:`compact-${X}`,kind:"note",title:l,body:u}),d.percent=Re(k),A("note",void 0)}else if(o.type==="message_start"&&o.message.role==="user"){let r=es(o.message);r&&(s.items=ts(s.items,r,`u-${o.message.timestamp}`)),Ro()}else if(o.type==="message_end"&&o.message.role==="assistant"){let r=s.items.find(l=>l.id===`live-${X}`);r&&(r.id=`done-${X}`);let a=o.message.errorMessage;if(a&&r){r.title="failed",r.kind="error",r.body=ce.trim()?`${a}
|
|
29
|
-
|
|
30
|
-
${ce.trim()}`:a;let l=dn(a);l!==void 0&&m("gateway",l);let u=cn(a);u!==void 0&&xo(u)}else a&&G(a);X+=1,ce="",d.percent=Re(k)}else if(o.type==="agent_settled"){d.live=!1;let r=[...k.getSteeringMessages()].map(a=>a.trim()).filter(Boolean);if(r.length>0){let a=w.getText().trim();w.setText(a?`${r.join(`
|
|
31
|
-
`)}
|
|
32
|
-
${a}`:r.join(`
|
|
33
|
-
`));let l=new Set(r);for(let u of s.items)u.kind==="user"&&u.pending&&l.has(u.body.trim())&&(u.pending=void 0);m("queued",`${r.length} unread message${r.length===1?"":"s"} were never read and are back in the editor`)}for(let a of s.items)a.kind==="user"&&a.pending&&(a.pending=void 0);if(f(Dt),Dt="",A("run",void 0),Vt){let a=s.items.find(l=>l.id===`live-${X}`);a?(a.id=`stopped-${X}`,a.title="stopped",a.body=ce.trim()||"(no output)",a.live=!1):s.items.push({id:`stopped-${X}`,kind:"note",title:"stopped",body:"run cancelled"}),X+=1,ce="",m("stopped","run cancelled by Esc"),Vt=!1}d.percent=Re(k),A("note",void 0),Ht(void 0),Bs(e.cwd).then(a=>{a!==null&&(d.git=a,v())}),w.disableSubmit=!1}else o.type==="thinking_level_changed"?d.setThinking(o.level):o.type==="auto_retry_start"?(A("note",void 0),Ht({attempt:o.attempt,maxAttempts:o.maxAttempts,error:o.errorMessage,until:Date.now()+o.delayMs})):o.type==="auto_retry_end"&&(Ht(void 0),o.success?m("retry",`answered on attempt ${o.attempt} after a retry`):A("note",`retry ${o.attempt} gave up${o.finalError?` \xB7 ${Yn(o.finalError)}`:""}`));Xs(),v()},Yt=k.subscribe(Eo),Po=setInterval(()=>{let o=F!==void 0&&Date.now()<K;if((tt||k.isStreaming||d.settling()||s.entering()||se||o||d.atCeiling()||d.flashing()||d.upgrading()||d.activity.retry!==void 0)&&v(),(tt||k.isStreaming)&&!we&&!_e&&Date.now()-et>Gl){_e=!0;let r=zt,a=Math.round((Date.now()-et)/1e3);A("note",r?`${r} has been running for ${a}s \u2014 it may be blocked; esc cancels`:`no answer yet after ${a}s \u2014 the provider may be stalled; ctrl+c cancels`),v()}},Bl);Po.unref?.();let Io=async o=>{Pe?.(),Pe=void 0,Yt(),jt&&Ar(jt,k.getSessionStats().sessionId),mo=void 0,Wt=0;let r=k.getSessionStats().sessionId;vn(r),xn(r),await st.dispose(),k.dispose(),k=o.session,co=o.setCompressToolOutput,st=new Xe({initial:Object.keys(Ne().mcpServers),apply:async(a,l)=>{if(await Se(),a.length>0||l.length>0){let u=[];a.length>0&&u.push(`connected ${a.join(", ")}`),l.length>0&&u.push(`stopped ${l.join(", ")}`),m(a.length>0?"mcp connected":"mcp stopped",u.join("; "))}},report:a=>G(a)}),X=0,ce="",s.items=[],s.scrollOffset=0,o.note&&s.items.push({id:"note",kind:"note",title:"note",body:o.note}),s.items.push(...At(k.state.messages)),d.model=o.modelLabel.split("/").at(-1)||"no-model",d.setThinking(k.thinkingLevel),he(),d.percent=Re(k),Lt(),d.abandonAnimations(),A("tally",void 0),A("run",void 0),w.setAutocompleteProvider(new Us(eo(k),e.cwd)),w.disableSubmit=!1,So(k),Yt=k.subscribe(Eo),v()},Oe=async()=>{if(uo)return;uo=!0,clearInterval(Po),Yt();try{let r=Ui(Wi);if(r.config.hooks.SessionEnd){let{outcome:a}=await Ki(r.config,"SessionEnd",{hook_event_name:"SessionEnd",cwd:process.cwd(),reason:"quit"},{cwd:process.cwd()});a.error&&m("hooks",`SessionEnd hook: ${a.error}`)}}catch{}await st.dispose();let o=k.getSessionStats().sessionId;Nt.close(k.getSessionStats().cost),vn(o),xn(o),k.dispose(),i.stop(),process.stdout.write("\x1B[0m"),process.exit(0)},_o=0,Xt=async(o=!1)=>{let r=Date.now();if(!o&&r-_o<600*1e3)return;_o=r;let a=u=>{if(process.env.HOWTOFIX_CHECKIN_DEBUG==="1")try{kl(`${P}/checkin-debug.log`,`${new Date().toISOString()} ${u}
|
|
34
|
-
`)}catch{}},l=async()=>{try{let u=new Set((await k.modelRuntime.getAvailable()).map(C=>C.provider).filter(C=>ie(C))),y=ye.find(C=>u.has(C));if(a(`providers=${[...u].join(",")||"(none)"} target=${y??"(none)"}`),!y)return!1;let c=(await k.modelRuntime.getAuth(y))?.auth?.apiKey,p=c?.trim().match(/^\$\{?([A-Za-z_][A-Za-z0-9_]*)\}?$|^\{env:([A-Za-z_][A-Za-z0-9_]*)\}$/),b=C=>C?(process.env[C]??"").trim():"",g=p?b(p[1]??p[2])||void 0:c?.trim()||void 0;if(!g)for(let C of["HOWTOFIX_API_KEY","HOWTOFIX_VIP_API_KEY","HOWTOFIX_FREE_API_KEY"]){let R=b(C);if(R){g=R,a(`key dari fallback ${C}`);break}}if(a(`key=${g?`ada(${g.length})`:"(kosong)"}${p?" dari env":""}`),!g)return!1;let x=await zn(g);if(a(`status ok=${x.ok} enabled=${x.enabled} claimed=${x.checkedInToday} msg=${x.message}`),!x.ok||!x.enabled||x.checkedInToday)return!0;let $=await Ss(g);return a(`claim ok=${$.ok} awarded=${$.quotaAwarded} msg=${$.message}`),$.ok?(m("check-in",`daily check-in claimed: +${Vn($.quotaAwarded)} credited to your howtofix.id account`),v()):$.blocked&&m("check-in",$.message),!0}catch(u){return a(`error ${u.message}`),!1}};await l()||(await new Promise(u=>setTimeout(u,4e3)),await l())},Oo=async o=>{let r=Nt.check(k.getSessionStats().cost);if(r!==void 0){G(`budget reached: $${r.spent.toFixed(4)} of $${r.limit.toFixed(2)} \u2014 raise it with --max-budget-usd, or start without the flag`);return}let a=k.isStreaming,l=`you-${Date.now()}`;s.items.push({id:l,kind:"user",title:"you",body:o,pending:a?!0:void 0}),a||(A("tally",void 0),Ze.clear(),Bt.clear(),A("run","thinking"),d.beginRun()),v(),w.disableSubmit=!1;let u=Ni(o,e.cwd);Dt=o,await Js(),tt=!0;let y=a?k.prompt(u,{streamingBehavior:"steer"}):k.prompt(u);tt=!1,y.then(()=>Xt()).catch(c=>G(c instanceof Error?c.message:String(c)))},Jt=o=>{let r=o.trim();if(r){if(re){let a=re;re=void 0,w.setText(""),a(r);return}if(w.setText(""),w.addToHistory(r),r.startsWith("!")){let a=r.slice(1).trim();if(!a)return;s.items.push({id:`sh-${Date.now()}`,kind:"tool",title:"$",body:a}),A("run","shell"),v(),k.executeBash(a,l=>{A("run",`shell \xB7 ${l.length} bytes`),v()}).then(l=>{let u=l.output.trim();s.items.push({id:`sh-out-${Date.now()}`,kind:l.exitCode===0?"result":"error",title:`exit ${l.exitCode??"?"}`,body:u||"(no output)"}),A("tally",void 0),v()}).catch(l=>G(l instanceof Error?l.message:String(l)));return}if(r.startsWith("/")){Fe(r);return}Oo(r)}};w.onSubmit=Jt;let Zt=0,ot=ns(),Lo=0,it=()=>{_r().then(o=>{o.ok?w.insertTextAtCursor(o.text):m("paste",o.reason),v()}).catch(o=>{m("paste",`could not read the clipboard: ${o instanceof Error?o.message:String(o)}`),v()})};n=it;let No=o=>yn(ke(P).rightClickPaste)&&o.type==="press"&&o.button==="right";i.addInputListener(o=>{if(be){if(Y(o,"escape"))return Ut(),{consume:!0};let a=Ks(),l=a.matches(o,"tui.select.up"),u=a.matches(o,"tui.select.down");if(l||u){let c=be.getTreeList().getSelectedNode()?.entry.id,p=Zs(),b=c===void 0?-1:p.indexOf(c);if(l?b===0:b===p.length-1)return v(),{consume:!0}}return be.handleInput(o),v(),{consume:!0}}if(Z&&H&&Y(o,"escape"))return ee?(ee=!1,m("workflow","panel keys off; the editor has the keyboard")):I.expanded?(I.expanded=!1,m("workflow","collapsed the drill-in")):(so(),m("workflow","panel unpinned; the run is still in the transcript")),Ot(),v(),{consume:!0};if(se)return se.handleInput(o),v(),{consume:!0};if(Y(o,"escape")){if(ot.disarm())return m("connect","sign-in cancelled \u2014 run /connect again when you have a token"),v(),{consume:!0};if(k.isStreaming){Vt=!0;let l=[...k.getSteeringMessages()].map(u=>u.trim()).filter(Boolean);if(l.length>0){let u=w.getText().trim();w.setText(u?`${l.join(`
|
|
35
|
-
`)}
|
|
36
|
-
${u}`:l.join(`
|
|
37
|
-
`));let y=new Set(l);for(let c of s.items)c.kind==="user"&&c.pending&&y.has(c.body.trim())&&(c.pending=void 0);m("queued",`${l.length} unread message${l.length===1?"":"s"} returned to the editor`)}return k.abort(),A("note","stopping"),v(),{consume:!0}}let a=Date.now();if(w.getText().length===0&&a-Zt<600)return Zt=0,bo(),{consume:!0};Zt=a;return}if(Y(o,"ctrl+c")||Rr(o)){if(k.isStreaming)k.abort(),A("note","stopping"),v();else if(w.getText().length>0)w.setText(""),A("note","draft cleared; ctrl+c again quits"),v();else{let a=Date.now();a-Lo<2e3?Oe():(Lo=a,A("note","press ctrl+c again to quit"),v())}return{consume:!0}}if(Y(o,"ctrl+d")&&w.getText().length===0)return Oe(),{consume:!0};let r=Math.max(1,s.viewportHeight-1);if(Y(o,"pageUp"))return s.scrollOffset+=r,v(),{consume:!0};if(Y(o,"pageDown"))return s.scrollOffset=Math.max(0,s.scrollOffset-r),v(),{consume:!0};if(Y(o,"home"))return s.scrollOffset=Number.MAX_SAFE_INTEGER,v(),{consume:!0};if(Y(o,"end"))return s.scrollOffset=0,v(),{consume:!0};if(Y(o,"ctrl+v"))return it(),{consume:!0};if(Y(o,"ctrl+l"))return s.scrollOffset=0,i.scrollToBottom(),v(),{consume:!0};if(Y(o,"ctrl+e")){let a=[...s.items].reverse().find(l=>(l.full?.length??0)>0);return a?(a.expanded=a.expanded!==!0,v(),{consume:!0}):(m("expand","nothing to expand in this transcript yet"),{consume:!0})}if(Y(o,"ctrl+o")&&!k.isStreaming)return s.items=[{id:"cleared",kind:"note",title:"bench",body:"screen cleared. session history is still stored."}],v(),{consume:!0};if(Y(o,"ctrl+t"))return Ie(as(d.thinking)),{consume:!0};if(Y(o,"ctrl+shift+t"))return Ie(ls(d.thinking)),{consume:!0};if(Y(o,Fs)&&Z&&H)return ee=!ee,m("workflow",ee?"panel keys active; Esc gives the keyboard back":"panel keys off; the editor has the keyboard"),Ot(),v(),{consume:!0};if(ee&&Z&&H){let a=_s(o);if(a){let l=Cn(H,Date.now());if(a==="stop")return L?(L(),L=null,m("workflow","stopping the run; in-flight agents resolve as null")):m("workflow","the run has already finished"),{consume:!0};if(a==="save"){let u=Ds(Ys,di);return m("workflow",u.ok?`saved ${u.path}`:u.reason),v(),{consume:!0}}return Object.assign(I,Os(I,a,l)),Ot(),v(),{consume:!0}}}});let Qt=o=>{let r=a=>{A("prompt",`API key for ${a}. Paste it, then press enter.`),v();let l=re;re=u=>{re=l;let y=u.trim();if(!y){A("prompt",void 0),v();return}k.modelRuntime.setRuntimeApiKey(a,y).then(()=>k.modelRuntime.login(a,"api_key",{prompt:async()=>y,notify:()=>{}}).then(()=>m("login",`saved API key for ${a}`),c=>m("login",`key set for this session, but it could not be saved (${c instanceof Error?c.message:String(c)}); run /login again after restarting`)),c=>m("login",c instanceof Error?c.message:String(c)))}};if(o){r(o);return}k.modelRuntime.getAvailable().then(a=>{let l=[...new Set(a.map(u=>u.provider))].sort();if(l.length===0){m("login","no providers are configured; pass one explicitly, e.g. /login nrimo");return}_("Login",l.map(u=>({value:u,label:u})),r)},a=>m("login",a instanceof Error?a.message:String(a)))},Fo=async(o,r)=>{let a=le(P,"models.json"),l,u=!1;try{l=JSON.parse(Zn(a,"utf8"))}catch(W){if(!(W instanceof Error&&"code"in W&&W.code==="ENOENT"))return`could not read ${a}; the models were not added`;l={providers:{}},u=!0}(!l.providers||typeof l.providers!="object")&&(l.providers={});let y=l.providers[o];y||(y=gi(),l.providers[o]=y,u=!0);let c=Array.isArray(y.models)?y.models:[],p=$i(c,r),b=await bi(P).catch(()=>({index:new Map})),g=await Si((await k.modelRuntime.getAuth(o))?.auth?.apiKey??""),x=ki(yi(c,r,b.index,g));y.models=x.models;try{Jn(P,{recursive:!0}),oe(a,`${JSON.stringify(l,null,2)}
|
|
38
|
-
`)}catch{return`could not write ${a}; the models were not added`}let $=!1;try{await k.modelRuntime.refresh(),$=!0}catch{$=!1}let C=x.changed>0?`, repaired ${x.changed}`:"",R=$?"":"; restart the CLI to see them all",U=u?` (created ${a})`:"";return p===0?`all ${r.length} models were already configured${C}${U}${R}`:`added ${p} model(s) to "${o}"${C}${U}${R}`},Le=(o,r)=>{(async()=>{if(!o){let g=await Ti({onProgress:$=>{let C="";try{let U=le(P,".howtofix");Jn(U,{recursive:!0,mode:448});let W=le(U,"connect-url.txt"),B=$.kind==="browser"?[$.url]:[$.url,`code: ${$.code}`];Qn(W,B.join(`
|
|
39
|
-
`)+`
|
|
40
|
-
`,{mode:384}),C=W}catch{C=""}let R=C?[` saved to ${C}`]:[];$.kind==="browser"?(Be($.url),m("connect",["finish signing in to howtofix.id:"," a browser window is opening \u2014 approve the sign-in there",` if it did not open, visit ${$.url}`,...R].join(`
|
|
41
|
-
`))):(Be($.url),m("connect",["finish signing in to howtofix.id:",` 1. go to ${$.url}`,` 2. enter the code: ${$.code}`," waiting\u2026",...R].join(`
|
|
42
|
-
`))),v()}});if(g.ok){ot.disarm(),A("prompt",void 0),Le(g.token,g.credential);return}let x=await Be(un);m("connect",[`browser sign-in: ${g.message}`,"","connect with a token instead:",` 1. ${x?"the keys page is opening in your browser":`open ${un}`}`," 2. sign in if asked, then create a key (starts with sk-)"," 3. run /connect <token>"," or /connect again, and paste the key when asked"].join(`
|
|
43
|
-
`)),v();return}if(!wi(o)){m("connect","that does not look like a howtofix token; the Console issues tokens that start with sk-");return}A("note",`connecting to howtofix.id (${fn(o)})`),v();let a=await mn(o);if(!a.ok){A("note",void 0),m("connect",a.message),v();return}let l=await Fo("howtofix",a.models);await k.modelRuntime.setRuntimeApiKey("howtofix",o);let u;try{await k.modelRuntime.login("howtofix","api_key",{prompt:async()=>o,notify:()=>{}})}catch(g){u=`this sign-in could not be saved (${g instanceof Error?g.message:String(g)}); run /connect again after restarting`}r&&(Ii(P,r)?ge=r:u=`this sign-in renews itself, but the pair could not be saved to ${Mi(P)}; it will expire in hours and need /connect again`);let y=!!k.model&&k.model?.provider!==void 0&&d.model!=="unknown",c,p;if(!y)try{let g=(await k.modelRuntime.getAvailable()).filter(C=>ie(C.provider)),$=kt(g.map(C=>C.id)).slice(0,4);for(let C of $){if(!(await vi(C,o)).ok)continue;let U=g.find(W=>W.id===C);if(U){await k.setModel(U),d.model=U.id,he(),c=`${U.provider}/${U.id}`;break}}c||(p=$.length>0?`none of the first ${$.length} models answered (${$[0]} did not)`:"the account lists no chat model")}catch(g){p=g instanceof Error?g.message:String(g)}A("note",void 0),Xt(!0);let b=await Ae(o);if(b.ok&&!b.unlimited){let g=b.unit,x=b.remaining??0,$=g==="USD"||g==="CNY"?`$${x.toFixed(2)}`:`${x.toLocaleString()} ${g}`;d.usage=Me($,g,null);try{Jn(xl(De),{recursive:!0}),oe(De,JSON.stringify({data:{remaining:x,limit:b.limit??0,unit:g,unlimited:!1,latencyMs:null},cachedAt:Date.now()}))}catch{}}else b.ok&&b.unlimited&&(d.usage=Me("unlimited","",null));m("connect",[`connected ${fn(o)} \u2014 ${a.message}`,l,rt("howtofix",b),c?`using ${c} (change it with /model)`:`pick a model with /model, then send a prompt${p?` (auto-select failed: ${p})`:""}`,u].filter(g=>!!g).join(`
|
|
44
|
-
`)),v()})().catch(a=>{A("note",void 0),m("connect",a instanceof Error?a.message:String(a)),v()})},jo=o=>{(async()=>{let r=qn(o);if(!r){m("connect",["that is not an account credential."," /connect <email>:<password>"," /connect <base64 of email:password>"].join(`
|
|
45
|
-
`)),v();return}A("note",`signing in as ${r.username}`),v();let{token:a}=await vs(Ai,r.username,r.password,lt),l=ks(P,r.username,r.password);A("note",void 0),m("connect",[`signed in as ${r.username}`,"using the CLI key this account owns \u2014 no new key was made",l?"credential stored \u2014 /connect will not ask again":"could not store the credential, so the next connect will ask again"].join(`
|
|
46
|
-
`)),v(),Le(a)})().catch(r=>{A("note",void 0),m("connect",r instanceof Error?r.message:String(r)),v()})},rt=(o,r)=>{if(!r.ok)return[`${o} account`,` ${r.message}`].join(`
|
|
47
|
-
`);if(r.unlimited)return r.limit!==void 0&&r.used!==void 0?Bn(o,r.limit,r.used,r.unit).join(`
|
|
48
|
-
`):[`${o} account`," quota no limit on this token"].join(`
|
|
49
|
-
`);if(r.limit===void 0||r.used===void 0){let a=[`${o} account`],l=u=>`${u.toFixed(2)} ${r.unit}`;return r.limit!==void 0&&a.push(` granted ${l(r.limit)}`),r.used!==void 0&&a.push(` spent ${l(r.used)}`),r.remaining!==void 0&&a.push(` remaining ${l(r.remaining)}`),a.join(`
|
|
50
|
-
`)}return Bn(o,r.limit,r.used,r.unit).join(`
|
|
51
|
-
`)},Ne=()=>({mcpServers:Hi()}),aa=o=>{let r=Object.keys(o??{});return r.length===0?[]:r.map(a=>` mcp ${a} ${dt(o[a])}`)},la=o=>{let r=ii(o.dir,o.manifest),a=o.manifest.skills.join(", ");return[o.manifest.description,` category ${o.manifest.category}`,` version ${o.manifest.version}`,` skills ${a}`,o.manifest.prompt?` prompt ${o.manifest.prompt}`:" prompt (none)",` size ${r} bytes of skill text`,` source ${o.source}`,...aa(o.manifest.mcp)].join(`
|
|
52
|
-
`)},Do=o=>{let r=[la(o),""];if(o.manifest.prompt){let a=le(o.dir,o.manifest.prompt);Pt(a)&&r.push(`--- ${o.manifest.prompt} ---`,Zn(a,"utf8").trim(),"")}for(let a of o.manifest.skills){let l=le(o.dir,"skills",a,"SKILL.md");Pt(l)&&r.push(`--- skills/${a}/SKILL.md ---`,Zn(l,"utf8").trim(),"")}return r.join(`
|
|
53
|
-
`)},Se=async()=>{await k.reload()},en=!1,Wo=async o=>{if(en){m("preset","an install is already running; wait for it to finish");return}en=!0;try{let r;try{r=await o()}catch(c){G(`preset not installed: ${c instanceof Error?c.message:String(c)}`);return}if(!r.ok||!r.name){G(`preset not installed:
|
|
54
|
-
${r.problems.join(`
|
|
55
|
-
`)}`);return}await Se();let a=te(e.cwd).entries.find(c=>c.manifest.name===r.name),l=a?.manifest.integrates||a?.manifest.mcp,u=l?`
|
|
56
|
-
integration disabled by default; run /preset enable ${r.name} when you want to use it`:await Uo(r.name);l&&a&&Qn(le(a.dir,".disabled"),`installed
|
|
57
|
-
`);let y=r.modelInvocable===!1?`its skill ${r.skill} is invoke-only (disable-model-invocation): the model cannot choose it, run /skill:${r.skill} yourself`:"its skill is in the model's catalogue from the next message";m("preset",`installed ${r.name} into ${r.target}
|
|
58
|
-
${y}${u}`)}finally{en=!1}},st=new Xe({initial:Object.keys(Ne().mcpServers),apply:async(o,r)=>{if(await Se(),o.length>0||r.length>0){let a=[];o.length>0&&a.push(`connected ${o.join(", ")}`),r.length>0&&a.push(`stopped ${r.join(", ")}`),m(o.length>0?"mcp connected":"mcp stopped",a.join("; "))}},report:o=>G(o)}),at=async()=>{let o=Object.keys(Ne().mcpServers);return await st.reconcile(o)},Uo=async o=>{let{entries:r}=te(e.cwd),l=r.find(c=>c.manifest.name===o)?.manifest.mcp;if(!l||Object.keys(l).length===0)return"";let u=rn(l);if(u.problems.length>0)return`
|
|
59
|
-
MCP: ${u.problems.join("; ")}`;let y=[];if(u.added.length>0){let c=await at(),p=u.added.filter(b=>c.added.includes(b));y.push(p.length>0?`MCP servers connected: ${p.join(", ")}`:`MCP servers added to mcp.json: ${u.added.join(", ")}`)}return u.skipped.length>0&&y.push(`MCP servers kept as they were (already configured): ${u.skipped.join(", ")}`),y.length>0?`
|
|
60
|
-
${y.join(`
|
|
61
|
-
`)}`:""},Ko=o=>Wo(async()=>si(o,ft(e.cwd))),Ho=o=>{let r=o.sizeKb>=1024?`${(o.sizeKb/1024).toFixed(1)} MB`:`${o.sizeKb} KB`;return m("preset",[`downloading ${o.title}`,` from ${o.repo} @ ${o.sha.slice(0,7)}`,` skill ${o.skill}${o.modelInvocable===!1?" (invoke-only: the model cannot choose it)":""}`,` size ~${r} \xB7 ${o.license}`," checking the pinned commit and the contents the registry recorded\u2026"].join(`
|
|
62
|
-
`)),Wo(()=>ci(o,ft(e.cwd)))},tn=(o,r)=>{_(r,o.map(a=>({value:a.name,label:a.title,description:a.description})),a=>{let l=o.find(y=>y.name===a);if(!l)return;let u=l.sizeKb>=1024?`${(l.sizeKb/1024).toFixed(1)} MB`:`${l.sizeKb} KB`;_(l.title,[{value:"install",label:"Install",description:`download ~${u} and add its skill to this project`},{value:"view",label:"View contents",description:"read what it contains before downloading"},{value:"back",label:"Back",description:"return to the menu"}],y=>{if(y==="install"){Ho(l);return}if(y==="view"){m(`preset ${l.name}`,[`${l.description}`,"",`skill ${l.skill}`,`source ${l.repo} @ ${l.sha.slice(0,7)}`,`licence ${l.license}`,`size ~${u}`,`category ${l.category}`,`model ${l.modelInvocable===!1?"invoke-only \u2014 the model cannot choose it, only /skill:"+l.skill:"the model can choose it from its catalogue"}`,"","Install downloads the skill and adds it to this project."].join(`
|
|
63
|
-
`));return}Go()})},()=>v())},Ce=(o,r)=>{_(r,o.map(a=>({value:a.manifest.name,label:a.manifest.title,description:a.manifest.skills.length>0?`${a.manifest.skills.join(", ")} \u2014 ${a.manifest.description}`:a.manifest.description})),a=>{let l=o.find(u=>u.manifest.name===a);l&&_(l.manifest.title,[{value:"install",label:"Install",description:"add its skills and rules to this project"},{value:"view",label:"View contents",description:"read the skills and prompt first"},{value:"back",label:"Back",description:"return to the menu"}],u=>{if(u==="install"){Ko(l.dir);return}if(u==="view"){m(`preset ${l.manifest.name}`,Do(l));return}zo("")})},()=>v())},Bo=o=>o.filter(r=>r.manifest.integrates!==void 0),ca=()=>{let{entries:o}=te(e.cwd),r=Bo(o);if(r.length===0){m("integrations","nothing installed that drives another application. /preset lists the rest.");return}Ce(r,"Integrations")},Go=()=>{let{entries:o}=te(e.cwd),r=[{value:"skills",label:"Skills",description:"bundles of skills and prompt text, installed into the project"},{value:"mcp",label:"MCP",description:"Model Context Protocol servers, added to mcp.json"}],a=Bo(o).length;a>0&&r.push({value:"integrations",label:"Integrations",description:`${a} that drive another application, and need setup there first`}),_("Presets",r,l=>l==="mcp"?nn():l==="integrations"?ca():da())},nn=()=>{let{entries:o,problems:r}=Xo();if(r.length>0&&m("mcp problems",r.join(`
|
|
64
|
-
`)),o.length===0){m("mcp catalogue","no servers in the catalogue. run /mcp to inspect the ones already configured.");return}let a=new Set(Object.keys(Ne().mcpServers)),l=new Map,u=[];for(let y of Jo(o)){let c=Zo(o,y);l.set(y,()=>qo(c,y));let p=c.filter(b=>a.has(b.name)).length;u.push({value:y,label:y,description:`${c.map(b=>b.title).join(", ")}${p>0?` \xB7 ${p} configured`:""}`})}l.set("all-mcp",()=>qo(o,"All MCP servers")),u.push({value:"all-mcp",label:"All servers",description:`${o.length} available${a.size>0?`, ${a.size} already configured`:""}`}),_("MCP servers",u,y=>l.get(y)?.())},qo=(o,r)=>{let a=Ne().mcpServers;_(r,o.map(l=>{let u=a[l.name]!==void 0?"configured \xB7 ":"";return{value:l.name,label:l.title,description:`${u}${l.description}`}}),l=>{let u=Qo(o,l);if(!u)return;let y=a[u.name]!==void 0,c=ei(u),p=[u.description,"",`server ${u.name}`,`runs ${dt(ut(u))}`,...u.needs&&u.needs.length>0?[`needs ${u.needs.join(", ")}`,c.length>0?` ${c.join(", ")} ${c.length===1?"is":"are"} not set in this shell \u2014 the value is read at connect time, so export it before the next session`:" all set in this shell"]:[],...u.docs?[`docs ${u.docs}`]:[],"",y?"already in mcp.json \u2014 removing it takes the entry out; nothing else changes":"install writes this server into mcp.json. nothing is downloaded, and it connects on the next session"].join(`
|
|
65
|
-
`),b=y?[{value:"remove",label:"Remove",description:"take the server out of mcp.json"},{value:"view",label:"Details",description:"what it runs and what it needs"},{value:"back",label:"Back",description:"return to the list"}]:[{value:"install",label:"Install",description:"add the server to mcp.json"},{value:"view",label:"Details",description:"what it runs and what it needs"},{value:"back",label:"Back",description:"return to the list"}];_(u.title,b,g=>{if(g==="view"){m(`mcp ${u.name}`,p);return}if(g==="install"){let x=[];if(u.preset){let R=le(ti(),"mcp",u.preset.replace(/^mcp-/,""));if(Pt(le(R,"preset.json"))){let U=ri(R,ft(e.cwd));U.ok||x.push(...U.problems)}}let $=rn({[u.name]:ut(u)});if(x.push(...$.problems),x.length>0){G(`mcp not installed:
|
|
66
|
-
${x.join(`
|
|
67
|
-
`)}`);return}if($.skipped.length>0){m("mcp install",`${u.name} is already in mcp.json; it was left as it is.`);return}let C=c.length>0?`
|
|
68
|
-
${c.join(", ")} ${c.length===1?"is":"are"} not set in this shell \u2014 the value is read when the server connects, so export ${c.length===1?"it":"them"} and reload, or it will fail every call`:"";m("mcp installed",[`added ${u.name} to mcp.json${u.preset?" and installed its skill preset":""}`,` runs ${dt(ut(u))}`,` connecting now; /mcp shows its state and its tools${C}`].join(`
|
|
69
|
-
`)),at().catch(R=>{G(`mcp installed but the session was not updated: ${R instanceof Error?R.message:String(R)}`)});return}if(g==="remove"){let x=ct([u.name]);if(x.problems.length>0){G(`mcp not removed:
|
|
70
|
-
${x.problems.join(`
|
|
71
|
-
`)}`);return}at().then($=>{m("mcp remove",$.removed.length>0?`removed ${$.removed.join(", ")} from mcp.json and stopped ${$.removed.length===1?"it":"them"}`:x.removed.length>0?`removed ${u.name} from mcp.json`:`${u.name} was not in mcp.json`)}).catch($=>{G(`mcp removed from config but the session was not updated: ${$ instanceof Error?$.message:String($)}`)});return}nn()})},()=>nn())},da=()=>{let{entries:o,problems:r}=te(e.cwd),{entries:a,problems:l}=mt();r.length>0&&m("preset problems",r.join(`
|
|
72
|
-
`)),l.length>0&&m("preset problems",l.join(`
|
|
73
|
-
`));let u=o.filter(p=>p.source==="installed"),y=new Map,c=[];u.length>0&&(y.set("installed",()=>Ce(u,"Installed presets")),c.push({value:"installed",label:"Installed",description:`${u.length} active`}));for(let p of ni(o)){let b=oi(o,p),g=an(a,p);y.set(p,()=>g.length>0?Vo(b,p,g):Ce(b,p));let x=b.map($=>`${$.manifest.title} (${$.manifest.skills.join(", ")})`).join(", ");c.push({value:p,label:p,description:`${x}${g.length>0?` \xB7 ${g.length} more to download`:""}`})}for(let p of li(a)){if(o.some(g=>g.manifest.category===p))continue;let b=an(a,p);y.set(p,()=>tn(b,p)),c.push({value:p,label:p,description:`${b.length} to download`})}if(y.set("all",()=>Ce(o,"All presets")),c.push({value:"all",label:"All presets",description:`${o.length} ready to install`}),a.length>0){y.set("hub",()=>Vo([],"Community presets",a));let p=new Set(a.map(b=>b.repo)).size;c.push({value:"hub",label:"Community",description:`${a.length} to download, from ${p} projects`})}_("Skill presets",c,p=>y.get(p)?.())},Vo=(o,r,a)=>{if(a.length===0){Ce(o,r);return}if(o.length===0){tn(a,`${r} (download)`);return}_(r,[{value:"local",label:`Included (${o.length})`,description:"already on disk, no download"},{value:"hub",label:`Downloadable (${a.length})`,description:"fetched when installed"}],l=>l==="local"?Ce(o,r):tn(a,r))},zo=o=>{let[r,...a]=o.trim().split(/\s+/),l=a.join(" ").trim();if(!r){Go();return}if(r==="list"){let{entries:u}=te(e.cwd),y=u.filter(c=>c.source==="installed");if(y.length===0){m("preset list","nothing installed. run /preset to browse the catalogue.");return}m("preset list",y.map(c=>`${c.manifest.name} ${c.manifest.version} [${sn(c.dir)?"disabled":"active"}]
|
|
74
|
-
${c.manifest.description}
|
|
75
|
-
${c.dir}`).join(`
|
|
76
|
-
`));return}if(r==="show"){if(!l){m("preset show","usage: /preset show <name>");return}let{entries:u}=te(e.cwd),y=u.find(g=>g.manifest.name===l);if(y){m(`preset ${l}`,Do(y));return}let{entries:c}=mt(),p=ln(c,l);if(!p){m("preset show",`no preset named "${l}". run /preset to list them.`);return}let b=p.sizeKb>=1024?`${(p.sizeKb/1024).toFixed(1)} MB`:`${p.sizeKb} KB`;m(`preset ${l}`,[p.description,"",`skill ${p.skill}`,`source ${p.repo} @ ${p.sha.slice(0,7)}`,`licence ${p.license}`,`size ~${b}`,`category ${p.category}`,"","not installed. install it from /preset, or: /preset add-hub "+p.name].join(`
|
|
77
|
-
`));return}if(r==="add"){if(!l){m("preset add","usage: /preset add <git-url | directory>");return}Ko(l);return}if(r==="add-hub"){if(!l){m("preset add-hub","usage: /preset add-hub <name> (see /preset for names)");return}let{entries:u}=mt(),y=ln(u,l);if(!y){m("preset add-hub",`"${l}" is not in the community registry. run /preset to browse it.`);return}Ho(y);return}if(r==="enable"||r==="disable"){if(!l){m(`preset ${r}`,`usage: /preset ${r} <name>`);return}let u=te(e.cwd).entries.find(c=>c.manifest.name===l&&c.source==="installed");if(!u){m(`preset ${r}`,`no installed preset named "${l}"`);return}let y=le(u.dir,".disabled");if(r==="disable"){Qn(y,`disabled
|
|
78
|
-
`);let c=u.manifest.mcp?ct(Object.keys(u.manifest.mcp)):{removed:[],kept:[],problems:[]};at().then(()=>Se()).then(()=>m("preset",`disabled ${l}${c.removed.length?`; stopped ${c.removed.join(", ")}`:""}`)).catch(p=>G(`preset disable failed: ${p instanceof Error?p.message:String(p)}`));return}$l(y,{force:!0}),Uo(l).then(c=>Se().then(()=>m("preset",`enabled ${l}${c}`))).catch(c=>G(`preset enable failed: ${c instanceof Error?c.message:String(c)}`));return}if(r==="remove"){if(!l){m("preset remove","usage: /preset remove <name>");return}let u=ai(l,e.cwd);if(u.problems.length>0){m("preset remove",u.problems.join(`
|
|
79
|
-
`));return}let c=te(e.cwd).entries.find($=>$.manifest.name===l),p=new Set;for(let $ of te(e.cwd).entries)if($.manifest.name!==l)for(let C of Object.keys($.manifest.mcp??{}))p.add(C);let b=c?.manifest.mcp?ct(Object.keys(c.manifest.mcp),p):{removed:[],kept:[],problems:[]},g=b.removed.length>0?`
|
|
80
|
-
MCP servers removed from mcp.json: ${b.removed.join(", ")}`:b.kept.length>0?`
|
|
81
|
-
MCP servers kept (still used by another preset): ${b.kept.join(", ")}`:"",x=b.problems.length>0?`
|
|
82
|
-
MCP: ${b.problems.join("; ")}`:"";Se().then(()=>{m("preset",`removed ${l}
|
|
83
|
-
${u.removed.join(`
|
|
84
|
-
`)}${g}${x}`)});return}m("preset",`unknown subcommand "${r}". try: list, show, add, add-hub, remove.`)},Fe=async o=>{let[r,...a]=o.slice(1).split(/\s+/),l=a.join(" ");if(r==="quit"||r==="exit"){Oe();return}if(r==="help"){m("help",eo(k).map(c=>`/${c.name} ${c.description??""}`).join(`
|
|
85
|
-
`));return}if(r==="trust"){let c=new Al(P),p=c.get(e.cwd);if(l==="on"||l==="off"){let g=l==="on";c.set(e.cwd,g),m("trust",g?`trusted ${e.cwd}
|
|
86
|
-
its .hxf settings, SYSTEM.md and skills apply to the next session`:`no longer trusting ${e.cwd}
|
|
87
|
-
its .hxf settings, SYSTEM.md and skills are ignored`);return}let b=p===!0?"trusted":p===!1?"not trusted":"not decided (treated as not trusted)";m("trust",`${e.cwd}
|
|
88
|
-
${b}
|
|
89
|
-
|
|
90
|
-
/trust on trust this folder
|
|
91
|
-
/trust off stop trusting it`);return}if(r==="init"){let c=le(e.cwd,"AGENTS.md");if(Pt(c)&&l!=="force"){m("init",`AGENTS.md already exists at ${c}. run /init force to overwrite.`);return}oe(c,Yo),m("init",`wrote ${c}; asking the agent to fill it in`),await k.prompt("Read AGENTS.md, then fill it in with the real build, test, and layout facts of this repo. Keep it short.");return}if(r==="login"){Qt(l);return}if(r==="connect"){let c=l.trim();if(c&&!c.startsWith("sk-")&&qn(c)){jo(c);return}if(c){Le(c);return}let p=$s(P);if(p){jo(p.credential);return}Le(""),A("prompt","paste your howtofix.id token, then press enter"),v();let b=re;ot.arm(()=>{re=b,A("prompt",void 0)}),re=g=>{ot.disarm(),Le(g.trim())};return}if(r==="sync"){let c=new Set((await k.modelRuntime.getAvailable()).map(R=>R.provider).filter(R=>ie(R))),p=ye.find(R=>c.has(R));if(!p){m("sync","no howtofix.id account is connected; run /connect first");return}A("note",`re-syncing ${p} from howtofix.id`),v();let g=(await k.modelRuntime.getAuth(p))?.auth?.apiKey;if(!g){A("note",void 0),m("sync",`${p} has no usable key; run /connect to sign in again`),v();return}let x=await mn(g);if(!x.ok){A("note",void 0),m("sync",x.message),v();return}let $=await Fo(p,x.models),C=await Ae(g);A("note",void 0),m("sync",`${$}
|
|
92
|
-
${rt(p,C)}`),await k.modelRuntime.refresh(),v();return}if(r==="usage"){let c=new Set((await k.modelRuntime.getAvailable()).map(R=>R.provider).filter(R=>ie(R))),p=ye.find(R=>c.has(R));if(!p){m("usage","no howtofix.id account is connected; run /connect first");return}A("note","asking howtofix.id for the account usage"),v();let g=(await k.modelRuntime.getAuth(p))?.auth?.apiKey;if(!g){A("note",void 0),m("usage",`${p} has no usable key; run /connect to sign in again`),v();return}let x=await Ae(g),$=await zn(g);A("note",void 0);let C=$.ok&&$.enabled?$.checkedInToday?`check-in: claimed today (+${Vn($.quotaToday)})`:"check-in: not claimed yet today (it claims itself on the next start)":"";m("usage",C?`${rt(p,x)}
|
|
93
|
-
${C}`:rt(p,x)),v();return}if(r==="logout"){let c=await k.modelRuntime.getAvailable(),p=[...new Set(c.map(b=>b.provider))].sort();if(p.length===0){m("logout","no providers are configured");return}_("Logout",p.map(b=>({value:b,label:b})),b=>{k.modelRuntime.logout(b).then(()=>m("logout",`logged out ${b}`),g=>m("logout",g instanceof Error?g.message:String(g)))});return}if(r==="providers"){let c=await k.modelRuntime.getAvailable(),p=[...new Set(c.map(b=>b.provider))].sort();p.sort((b,g)=>Number(ie(g))-Number(ie(b))),_("Providers",p.map(b=>({value:b,label:b})),b=>{let g=k.modelRuntime.getModels(b);if(g.length===0){Qt(b);return}_(b,g.map(x=>({value:x.id,label:x.id})),x=>{let $=g.find(C=>C.id===x);$&&k.setModel($,{persist:!0}).then(()=>{d.model=$.id,he(),m("providers",`${b}/${$.id}`)},()=>Qt(b))})});return}if(r==="name"){if(!l){m("name","usage: /name <session name>");return}k.setSessionName(l),m("name",`session name: ${l}`);return}if(r==="update"){A("note","checking for a newer release");try{await yo({current:lt,install:!0})}finally{A("note",void 0)}return}if(r==="stats"){let c=k.getSessionStats(),p=k.getContextUsage(),b=$=>Number.isFinite($)?String($):";",g=Pr(k.sessionManager.getEntries()),x=g.hitRate===null?"cache hit rate unknown (no prompt billed yet)":`cache hit ${g.hitRate.toFixed(1)}% of ${g.cachedTokens+g.billedTokens} prompt tokens`;m("stats",[`session ${c.sessionId}`,c.sessionFile?`file ${c.sessionFile}`:"not persisted",`messages ${b(c.totalMessages)} (user ${b(c.userMessages)}, assistant ${b(c.assistantMessages)}, tools ${b(c.toolCalls)})`,`tokens in ${b(c.tokens.input)} out ${b(c.tokens.output)} cache ${b(c.tokens.cacheRead)}/${b(c.tokens.cacheWrite)}`,x,g.misses.length>0?`cache misses ${g.misses.length} (${b(g.missedTokens)} tokens re-billed) \u2014 last: ${Ir(g.misses[g.misses.length-1])}`:"cache misses none counted",`cost $${Number.isFinite(c.cost)?c.cost.toFixed(4):";"}`,p?`context ${p.percent===null||!Number.isFinite(p.percent)?"?":`${Math.round(p.percent)}%`} of ${p.contextWindow}`:"context unknown"].join(`
|
|
94
|
-
`));return}if(r==="diff"){let c=async $=>{try{let{stdout:C}=await to("git",$,{cwd:e.cwd,encoding:"utf8"});return C.trim()}catch{return""}},p=await c(["diff","--stat"])+`
|
|
95
|
-
|
|
96
|
-
`+await c(["diff","--","."]),[b="",g=""]=p.split(`
|
|
97
|
-
|
|
98
|
-
`,2),x=mr(g);m("diff",[b.trim(),x].filter(Boolean).join(`
|
|
99
|
-
|
|
100
|
-
`)||"working tree clean");return}if(r==="copy"){let c=[...k.state.messages].reverse().find(g=>g.role==="assistant"),b=(Array.isArray(c?.content)?c.content:[]).filter(g=>g.type==="text").map(g=>g.text).join("");if(!b){m("copy","nothing to copy");return}try{await Cl(b),m("copy",`copied ${b.length} characters`)}catch(g){m("copy",g instanceof Error?g.message:String(g))}return}if(r==="export"){let c=s.items.filter(g=>g.body.trim().length>0);if(c.length===0){m("export","nothing to export yet; the transcript is empty");return}let p=Sl(e.cwd,l||`howtofix-session-${Date.now()}.md`),b=[`# ${on} session`,"",`model ${d.model}`,""];for(let g of c)b.push(`## ${g.title||g.kind}`,"",g.body,"");try{oe(p,b.join(`
|
|
101
|
-
`))}catch(g){m("export",`could not write ${p}: ${g instanceof Error?g.message:String(g)}`);return}m("export",`wrote ${p}`);return}if(r==="agents"){let[c="",...p]=l.split(/\s+/).filter(Boolean),b=p.join(" ").trim();if(c&&b){m("agents",await ar(c,b));return}m("agents",c?sr(c):rr());return}if(r==="new"){let c=await e.reopen({noSession:!1});await Io(c),m("new","started a new session");return}if(r==="resume"){let c=await Tl.list(e.cwd);if(c.length===0){m("resume","no saved sessions for this folder");return}_("Resume session",c.slice(0,30).map(p=>({value:p.path,label:p.name||`${p.id.slice(0,8)} ${p.firstMessage.slice(0,40)}`,description:`${p.modified.toISOString().slice(0,16)} ${p.messageCount} messages`})),p=>{e.reopen({sessionPath:p}).then(Io,b=>G(b instanceof Error?b.message:String(b)))});return}if(r==="model"){let c=await k.modelRuntime.getAvailable(),p=c.filter($=>ie($.provider)),b=hi(P),g=p.length>0?p:b.size>0?c.filter($=>b.has($.provider)):[];if(g.length===0){m("model","no model configured yet \u2014 run /connect to sign in first");return}let x=l?g.find($=>`${$.provider}/${$.id}`===l||$.id===l):void 0;if(!l){_("Select model",g.map($=>({value:`${$.provider}/${$.id}`,label:$.id,description:[Cs($),$.provider].filter(Boolean).join(" \xB7 ")})),$=>{let C=g.find(R=>`${R.provider}/${R.id}`===$);C&&k.setModel(C,{persist:!0}).then(()=>{d.model=C.id,he(),m("model",`model ${$}`)})});return}if(!x){m("model",`unknown model ${l}`);return}await k.setModel(x,{persist:!0}),d.model=x.id,he(),m("model",`model ${x.provider}/${x.id}`);return}if(r==="thinking"){if(!l){_("Thinking level",q.map(c=>({value:c,label:c})),c=>Ie(c));return}if(!q.includes(l)){m("thinking",`thinking: ${q.join(", ")}`);return}Ie(l);return}if(r==="rtk"){let c=ke(P).compressToolOutput;if(!l){m("rtk",`compress tool output: ${c?"on":"off"}
|
|
102
|
-
/rtk on | /rtk off`);return}let p=l.toLowerCase();if(p!=="on"&&p!=="off"){m("rtk","rtk: on | off");return}let b=p==="on";if(b===c){m("rtk",`already ${p}`);return}if(!We(P,"compressToolOutput",b)){m("rtk","could not write the setting");return}co(b),m("rtk",`compress tool output ${p}
|
|
103
|
-
long results are ${b?"summarised before the model reads them":"sent in full"}`);return}if(r==="compact"){try{await k.compact(l||void 0),m("compact","session compacted")}catch(c){m("compact",c instanceof Error?c.message:String(c))}return}if(r==="approval"){let c=p=>{ji(p),m("approval",gn[p])};if(!l){_("Approval mode",gt.map(p=>({value:p,label:p,description:gn[p]})),p=>c(p));return}if(!gt.includes(l)){m("approval",`modes: ${gt.join(", ")}`);return}c(l);return}if(r==="settings"){let c=()=>wn()?"off \u2014 everything runs":"on \u2014 critical commands are refused",p=()=>{_("Permission checks",[{value:"on",label:"on",description:"refuse critical commands and repeated calls (the default)"},{value:"off",label:"off",description:"run everything without asking \u2014 for unattended runs"}],E=>{let J=E==="off",z=We(P,"skipPermissions",J);if(bn(J),d.skipPermissions=J,v(),!z){m("settings","changed for this session, but settings.json could not be written (is it valid JSON?)");return}m("settings",J?"permission checks are OFF \u2014 critical commands and the repeat guard will not stop anything. Stored for future sessions.":"permission checks are ON \u2014 critical commands and repeated calls are refused again.")},void 0,!1,[`Currently ${c()}.`])},b=()=>{_("Thinking level",q.map(E=>({value:E,label:E,description:E===d.thinking?"current":void 0})),E=>Ie(E),void 0,!1,[`Currently ${d.thinking}.`])},g=()=>{_("Auto-update",[{value:"on",label:"on",description:"install a newer release on start (the default)"},{value:"off",label:"off",description:"stay on this version until you update by hand"}],E=>{let J=E!=="off",z=We(P,"autoUpdate",J);m("settings",z?`auto-update ${J?"on":"off"} \u2014 takes effect on the next start.`:"auto-update changed for this session, but settings.json could not be written (is it valid JSON?)")},void 0,!1,[`Currently ${Li(`${P}/settings.json`)?"on":"off"}.`])},x=()=>{let E=Ke("status",e.cwd,k.getSessionStats().sessionId);_("Dynamic context pruning",[{value:"on",label:"on",description:"fold stale ranges so long sessions stay affordable"},{value:"off",label:"off",description:"send the full transcript, unpruned"},{value:"status",label:"status",description:"what it has pruned so far"}],J=>m("dcp",Ke(J,e.cwd,k.getSessionStats().sessionId)),void 0,!1,E.split(`
|
|
104
|
-
`).slice(0,2))},$=()=>{Fe("/model")},C=()=>{Fe("/proxy")},R=()=>{let E=ke(P).rightClickPaste,J=process.platform==="win32"?"off":"on";_("Right click",[{value:"auto",label:"auto",description:`follow the terminal (${J} on ${process.platform})`},{value:"on",label:"on",description:"the CLI pastes the clipboard itself"},{value:"off",label:"off",description:"the terminal handles it, or the click does nothing"}],z=>{let je=Bi(P,z);m("settings",je?z==="auto"?`right click follows the terminal \u2014 ${yn("auto")?"the CLI pastes":"the terminal pastes"} here.`:`right click ${z==="on"?"pastes from the CLI":"is left to the terminal"}.`:"right click changed for this session, but settings.json could not be written (is it valid JSON?)")},void 0,!1,[`Currently ${E}.`])},U=()=>{let E=ke(P).agents,J=[1,2,3,4].map(z=>({value:String(z),label:String(z),description:z===1?"one child at a time":z===He()?"current \u2014 sized to this machine":`${z} children at once`}));_("Agent concurrency",[{value:"auto",label:"auto",description:`size it to the machine (now ${He()}, max ${nr})`},...J],z=>{let je=z==="auto"?void 0:Number(z),ua=Gi(P,je);m("settings",ua?je===void 0?`agent concurrency follows the machine \u2014 ${He()} at a time.`:`agent concurrency set to ${je} \u2014 shared by task and workflow.`:"agent concurrency changed for this session, but settings.json could not be written (is it valid JSON?)"),v()},void 0,!1)},W=[{value:"permissions",label:"permissions",description:c()},{value:"thinking",label:"thinking",description:`${d.thinking} \u2014 how hard the model reasons`},{value:"model",label:"model",description:d.model},{value:"dcp",label:"context pruning",description:"fold stale ranges to save tokens"},{value:"proxy",label:"proxy",description:pn(P)??hn()??"none \u2014 direct to the API"},{value:"rightclick",label:"right click",description:`paste: ${ke(P).rightClickPaste}`},{value:"agents",label:"agents",description:`${ke(P).agents??`auto (${He()})`} at once, shared by task and workflow`},{value:"autoupdate",label:"auto-update",description:"install a newer release on start"}];if(!l){_("Settings",W,E=>{E==="permissions"?p():E==="thinking"?b():E==="dcp"?x():E==="autoupdate"?g():E==="model"?$():E==="proxy"?C():E==="rightclick"?R():E==="agents"&&U()});return}let B=W.find(E=>E.value===l||E.label===l);if(B){B.value==="permissions"?p():B.value==="thinking"?b():B.value==="dcp"?x():B.value==="autoupdate"?g():B.value==="model"?$():B.value==="proxy"?C():B.value==="rightclick"?R():B.value==="agents"&&U();return}if(l==="on"||l==="off"){let E=l==="off",J=We(P,"skipPermissions",E);bn(E),d.skipPermissions=E,v(),m("settings",J?E?"permission checks are OFF \u2014 critical commands and the repeat guard will not stop anything.":"permission checks are ON.":"changed for this session, but settings.json could not be written (is it valid JSON?)");return}m("settings",`settings: ${W.map(E=>E.value).join(", ")} | on, off (permission checks)
|
|
105
|
-
usage: /settings <name>, or /settings to choose`);return}if(r==="proxy"){let c=pn(P),p=hn(),b=()=>c?`proxy: ${c} (set here, in settings.json)`:p?`proxy: ${p} (from the environment, not this file)`:"proxy: none \u2014 requests go straight to the API";if(!l){m("proxy",`${b()}
|
|
106
|
-
usage: /proxy <url> route requests through a proxy
|
|
107
|
-
/proxy off stop using one
|
|
108
|
-
/proxy env use HTTPS_PROXY / HTTP_PROXY / ALL_PROXY
|
|
109
|
-
Only traffic to the HowToFix API goes through it; a change applies on the next start.`);return}let g=l.trim();if(g==="off"||g==="none"){let R=bt(P,pt,""),U=ht(P),W=U.source==="env"?`the environment still sets one (${U.url})`:"requests go straight to the API";m("proxy",R?`proxy off \u2014 ${W} from the next message.`:"proxy changed for this session, but settings.json could not be written (is it valid JSON?)");return}if(g==="env"){let R=bt(P,pt,""),U=ht(P),W=U.source==="env"?U.url:void 0;m("proxy",R?W?`using the environment from the next message: ${W}`:"settings cleared, but no HTTPS_PROXY / HTTP_PROXY / ALL_PROXY is set \u2014 requests go straight to the API.":"settings.json could not be written (is it valid JSON?)");return}let x=Oi(g);if(!x.ok){m("proxy",`not set: ${x.problem}`);return}if(!bt(P,pt,x.url)){m("proxy","settings.json could not be written (is it valid JSON?)");return}let C=ht(P);m("proxy",C.url?`proxy set to ${x.url} \u2014 requests go through it from the next message.`:`proxy saved as ${x.url}, but it could not be applied this session; it will be tried on the next start.`);return}if(r==="tools"){let c=k.getActiveToolNames().sort();m("tools",c.length?c.join(`
|
|
110
|
-
`):"no tools enabled");return}if(r==="dcp"){m("dcp",Ke(l,e.cwd,k.getSessionStats().sessionId));return}if(r==="context"||r==="decompress"||r==="sweep"){m(r,Ke(`${r} ${l}`.trim(),e.cwd,k.getSessionStats().sessionId));return}if(r==="rewind"){bo();return}if(r==="undo"){if(!await Sn(e.cwd)){m("undo","not a git repository");return}let c=await ur(e.cwd);m("undo",c.ok?`undone: ${c.output}`:`undo failed: ${c.output}`),h(!0);return}if(r==="commit"){if(!Sn(e.cwd)){m("commit","not a git repository");return}if(!await cr(e.cwd)){m("commit","nothing to commit");return}let c=l||`howtofix: session update ${new Date().toISOString().slice(0,16)}`,p=await dr(e.cwd,c);m("commit",p.ok?p.output:`commit failed: ${p.output}`),h(!0);return}if(r==="review"){if(!(await fr(e.cwd)).trim()){m("review","no changes to review");return}Jt("Review the uncommitted changes. Report concrete issues with file evidence. Do not edit files.");return}if(r==="workflow"){if(l.trim()==="clear"){so(),m("workflow","cleared the pinned workflow panel");return}if(!H){m("workflow","no workflow run in this session yet");return}let c=Cn(H,Date.now()),p=c[I.selectedPhase];m("workflow",[`panel ${Z?"pinned above the editor":"unpinned"}`,`phase ${I.selectedPhase+1}/${c.length}: ${p?.title??"(none)"}`,`filter: ${I.filter}${I.paused?" \xB7 paused":""}`,"keys: \u2191/\u2193 phase \xB7 Enter drill in \xB7 Esc unpin \xB7 f filter \xB7 p pause \xB7 x stop \xB7 s save","clear it with /workflow clear"].join(`
|
|
111
|
-
`));return}if(r==="plan"){if(er()||yt().state==="pending"){$n(Zi(yt())),m("plan","plan mode off; edits are allowed again");return}$n(Ji(yt())),m("plan",`plan mode armed \u2014 send your next prompt to start planning
|
|
112
|
-
plan file: ${Qi()??"(unknown)"}`);return}if(r==="goal"){let c=l.trim();if(!c){m("goal",kn(wt()));return}let{goal:p,error:b}=Xi(wt(),"set",c,void 0,void 0);if(b){G(b);return}Yi(p),await k.sendCustomMessage({customType:Vi,content:c,display:!1,details:p}),m("goal",`goal set
|
|
113
|
-
${kn(p)}`);return}if(r==="session"){let c=k.model;m("session",c?`${c.provider}/${c.id}`:"no model");return}if(r==="skills"){m("skills",Mr(k.resourceLoader.getSkills().skills));return}if(r==="preset"){zo(l);return}if(r==="roblox"){let{RobloxConnect:c,readBridgeEndpoint:p,describeStatus:b,parseRobloxSubcommand:g}=await import("./chunk-LAHVHRCS.js"),x=g(l);if(x){let W=new c(p(P));try{if(x.sub==="status"){let B=await W.tunnel("status").catch(()=>{});m("roblox",b(await W.status(),B))}else if(x.sub==="login"){m("roblox","opening Roblox in your browser to sign in\u2026");let B=await W.login({onUrl:E=>m("roblox",`if the browser did not open, go to:
|
|
114
|
-
${E}`)});m("roblox",B.message)}else if(x.sub==="logout")await W.logout(),m("roblox","signed out of Roblox");else{let B=x.rest==="off"?"stop":x.rest==="on"||x.rest===""?"start":void 0;if(!B)m("roblox","usage: /roblox tunnel on | off");else{let E=await W.tunnel(B);m("roblox",E.message??"done")}}}catch(B){m("roblox",B instanceof Error?B.message:String(B))}return}let $=te(e.cwd).entries.find(W=>W.manifest.name==="rotoolbox");if(!$||$.source!=="installed"){m("roblox","RoToolbox is not installed. Run /preset and install RoToolbox first.");return}let C=sn($.dir),R=k.getActiveToolNames().filter(W=>/roblox[-_]studio/i.test(W)),U=R.length>0;m("roblox",C?`RoToolbox: disabled
|
|
115
|
-
Enable with /preset enable rotoolbox
|
|
116
|
-
The MCP server and manager stay stopped while disabled.`:["RoToolbox: active",`MCP server: ${U?`connected \u2014 ${R.length} tool${R.length===1?"":"s"} registered`:"not connected yet"}`,"Open Roblox Studio with a place, then use a prompt to inspect it.","Disable with /preset disable rotoolbox"].join(`
|
|
117
|
-
`));return}let u=Tr(o,k.resourceLoader.getSkills().skills.map(c=>c.name));if(u){Oo(u);return}let y=k.extensionRunner.getCommand(r??"");if(y){try{await y.handler(l,k.extensionRunner.createCommandContext())}catch(c){G(c instanceof Error?c.message:String(c))}return}m("command",`/${r??""} is not available in this screen yet`)};qi((o,r)=>{let{promise:a,resolve:l}=Promise.withResolvers();return _(o,r.map(u=>({value:u,label:u})),l,()=>l("cancelled")),a}),process.on("SIGTERM",Oe),Er(()=>{Oe()}),t.setTitle(`${on} ${lt}`),Hl(),i.start(),i.requestRender(!0),Xt(!0);{let{maybeShowWelcome:o}=await import("./chunk-I7KVLBMF.js");await o({cwd:e.cwd,note:e.note,signedIn:ge!==void 0,runSlash:r=>{Fe(r)},openExternal:r=>{Be(r)}},_,m)}e.initialPrompt&&Jt(e.initialPrompt),await new Promise(()=>{})}var re,Bl=1e3/30,Gl=45e3;export{io as Dock,no as Hud,oo as PinnedBlock,Wl as approvalDetail,kt as orderModelsForDefault,Dl as pickerPanel,Qd as runWorkbench,eo as slashCommands,Ul as workflowPanel,It as workflowPanelFromRun,ro as workflowRunOf};
|
package/dist/chunk-UTYFLLSM.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{closeSync as S,fsyncSync as d,openSync as f,renameSync as i,rmSync as t,writeSync as a}from"node:fs";import{dirname as u,join as E}from"node:path";function l(o,m,s){let r=E(u(o),`.${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}.tmp`),e=f(r,"w",s?.mode);try{a(e,m),d(e)}finally{S(e)}try{i(r,o)}catch(n){let c=n.code;if(c!=="EPERM"&&c!=="EBUSY"&&c!=="EACCES")throw t(r,{force:!0}),n;t(o,{force:!0});try{i(r,o)}catch(y){throw t(r,{force:!0}),y}}}export{l as a};
|
package/dist/chunk-V3R4FYTJ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h}from"./chunk-27TRKD65.js";import"./chunk-UTYFLLSM.js";import"./chunk-WOT6VMZA.js";export{a as DEFAULT_WORKBENCH_SETTINGS,d as markWelcomeSeen,b as readWorkbenchSettings,f as rightClickPastesHere,g as writeAgentsSetting,e as writeRightClickPasteSetting,h as writeStringSetting,c as writeWorkbenchSetting};
|
package/dist/chunk-V656XVXV.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{a as j}from"./chunk-UTYFLLSM.js";import{homedir as we}from"node:os";import{join as $,resolve as Ae}from"node:path";import{cpSync as ue,existsSync as S,mkdirSync as P,mkdtempSync as D,readdirSync as R,readFileSync as O,renameSync as pe,rmSync as k,statSync as x,writeFileSync as T}from"node:fs";import{tmpdir as X}from"node:os";import{dirname as Z,isAbsolute as me,join as l,relative as ge,resolve as N}from"node:path";import{fileURLToPath as de}from"node:url";import{execFileSync as ye}from"node:child_process";import{createHash as U}from"node:crypto";import{existsSync as w,readFileSync as H}from"node:fs";import{dirname as oe,join as L}from"node:path";import{fileURLToPath as ae}from"node:url";function F(e=y){return L(e,"mcp.json")}function z(e){let r=[];if(e===void 0)return r;if(typeof e!="object"||e===null||Array.isArray(e))return["mcp must be an object of server names"];for(let[t,s]of Object.entries(e)){if(!/^[A-Za-z0-9_-]+$/.test(t)){r.push(`mcp server "${t}" must use only letters, digits, _ and -`);continue}if(typeof s!="object"||s===null||Array.isArray(s)){r.push(`mcp server "${t}" must be an object`);continue}let n=s,i=typeof n.command=="string"&&n.command.trim()!=="",o=typeof n.url=="string"&&n.url.trim()!=="";!i&&!o&&r.push(`mcp server "${t}" needs either a command or a url`),n.args!==void 0&&!Array.isArray(n.args)&&r.push(`mcp server "${t}": args must be an array`);for(let c of["env","headers"]){let a=n[c];if(a!==void 0){if(typeof a!="object"||a===null||Array.isArray(a)){r.push(`mcp server "${t}": ${c} must be an object of strings`);continue}for(let[f,u]of Object.entries(a))typeof u!="string"&&r.push(`mcp server "${t}": ${c}.${f} must be a string`)}}}return r}function J(e){if(!w(e))return{mcpServers:{}};try{let r=JSON.parse(H(e,"utf8"));if(!r||typeof r!="object"||Array.isArray(r))return{mcpServers:{}};let t=r.mcpServers;return!t||typeof t!="object"||Array.isArray(t)?{mcpServers:{}}:{mcpServers:t}}catch{return{mcpServers:{}}}}function Te(e,r=y){let t=Object.keys(e);if(t.length===0)return{added:[],skipped:[],problems:[]};let s=F(r),n=[];if(w(s))try{JSON.parse(H(s,"utf8"))}catch{return{added:[],skipped:[],problems:[`${s} is not valid JSON; leaving it alone`]}}let i=J(s),o=[],c=[];for(let a of t){if(i.mcpServers[a]!==void 0){c.push(a);continue}i.mcpServers[a]=e[a],o.push(a)}if(o.length>0)try{j(s,`${JSON.stringify(i,null,2)}
|
|
2
|
-
`)}catch(a){return{added:[],skipped:c,problems:[`could not write ${s}: ${a instanceof Error?a.message:String(a)}`]}}return{added:o,skipped:c,problems:n}}function Ne(e,r=new Set,t=y){let s=F(t),n=[];if(e.length===0||!w(s))return{removed:[],kept:[],problems:n};let i=J(s),o=[],c=[];for(let a of e)if(i.mcpServers[a]!==void 0){if(r.has(a)){c.push(a);continue}delete i.mcpServers[a],o.push(a)}if(o.length>0)try{j(s,`${JSON.stringify(i,null,2)}
|
|
3
|
-
`)}catch(a){return{removed:[],kept:c,problems:[`could not write ${s}: ${a instanceof Error?a.message:String(a)}`]}}return{removed:o,kept:c,problems:n}}function Ce(e){if(typeof e.url=="string"&&e.url)return`http: ${e.url}`;let r=typeof e.command=="string"?e.command:"",t=Array.isArray(e.args)?e.args.filter(s=>typeof s=="string"):[];return`stdio: ${[r,...t].join(" ")}`.trim()}function ce(){return L(oe(ae(import.meta.url)),"presets","mcp-hub.json")}function De(e=ce()){let r=[];if(!w(e))return{entries:[],problems:[`no MCP catalogue at ${e}`]};let t;try{t=JSON.parse(H(e,"utf8"))}catch(i){return{entries:[],problems:[`${e} is not valid JSON: ${i instanceof Error?i.message:String(i)}`]}}let s=t?.entries;if(!Array.isArray(s))return{entries:[],problems:[`${e} has no entries array`]};let n=[];for(let i of s){if(typeof i!="object"||i===null||Array.isArray(i))continue;let o=i,c=typeof o.name=="string"?o.name.trim():"";if(!c){r.push("an entry has no name");continue}if(!/^[A-Za-z0-9_-]+$/.test(c)){r.push(`"${c}" is not a usable server name`);continue}let a=typeof o.command=="string"&&o.command.trim()!=="",f=typeof o.url=="string"&&o.url.trim()!=="";if(!a&&!f){r.push(`"${c}" has neither a command nor a url`);continue}n.push({name:c,title:typeof o.title=="string"?o.title:c,description:typeof o.description=="string"?o.description:"",category:typeof o.category=="string"?o.category:"other",preset:typeof o.preset=="string"?o.preset:void 0,command:typeof o.command=="string"?o.command:void 0,url:typeof o.url=="string"?o.url:void 0,args:Array.isArray(o.args)?o.args.filter(u=>typeof u=="string"):void 0,env:o.env&&typeof o.env=="object"&&!Array.isArray(o.env)?o.env:void 0,needs:Array.isArray(o.needs)?o.needs.filter(u=>typeof u=="string"):void 0,docs:typeof o.docs=="string"?o.docs:void 0})}return{entries:n,problems:r}}function _e(e){return[...new Set(e.map(r=>r.category))].sort()}function Le(e,r){return e.filter(t=>t.category===r).sort((t,s)=>t.title.localeCompare(s.title))}function Fe(e,r){return e.find(t=>t.name===r)}function ze(e){let r={};return e.command&&(r.command=e.command),e.url&&(r.url=e.url),e.args&&e.args.length>0&&(r.args=[...e.args]),e.env&&Object.keys(e.env).length>0&&(r.env={...e.env}),e.description&&(r.description=e.description),r}function Je(e,r=process.env){return(e.needs??[]).filter(t=>!r[t])}import{gunzipSync as le}from"node:zlib";var v=512;function A(e,r,t){let s=e.subarray(r,r+t),n=s.indexOf(0);return s.subarray(0,n===-1?s.length:n).toString("utf8").trim()}function B(e,r,t){let s=A(e,r,t);if(!s)return 0;let n=Number.parseInt(s,8);return Number.isFinite(n)?n:0}function fe(e){let r={},t=0;for(;t<e.length;){let s=e.indexOf(32,t);if(s===-1)break;let n=Number.parseInt(e.toString("utf8",t,s),10);if(!Number.isFinite(n)||n<=0)break;let i=e.toString("utf8",s+1,t+n-1),o=i.indexOf("=");o>0&&(r[i.slice(0,o)]=i.slice(o+1)),t+=n}return r}function G(e){let r=le(e),t=[],s=0,n,i={};for(;s+v<=r.length;){let o=r.subarray(s,s+v);if(o.every(ie=>ie===0))break;let c=A(o,0,100),a=A(o,345,155),f=B(o,124,12),u=B(o,100,8),m=String.fromCharCode(o[156]??48),p=A(o,157,100),d=f>0?r.subarray(s+v,s+v+f):Buffer.alloc(0);if(s+=v+Math.ceil(f/v)*v,m==="x"||m==="g"){i=fe(d);continue}if(m==="L"){n=d.toString("utf8").replace(/\0.*$/s,"").trim();continue}let h=i.path??n??(a?`${a}/${c}`:c);n=void 0,i={};let g=h.indexOf("/");if(g===-1||(h=h.slice(g+1),h=h.replace(/\/+$/,""),!h))continue;let b=m==="5"?"directory":m==="2"?"symlink":m==="0"||m==="\0"||m===""?"file":"other";t.push({path:h,kind:b,size:f,mode:u&511,...b==="file"?{data:Buffer.from(d)}:{},...b==="symlink"?{link:p}:{}})}return t}function K(e){if(!e||e.startsWith("/")||e.startsWith("\\")||/^[a-zA-Z]:/.test(e))return!1;let r=e.replace(/\/+$/,"");return r?r.split("/").every(s=>s!==""&&s!=="."&&s!==".."):!1}function W(e,r){let t=`${r.replace(/\/+$/,"")}/`,s=[];for(let n of e){if(!n.path.startsWith(t))continue;let i=n.path.slice(t.length);i&&s.push({...n,path:i})}return s}function he(){return l(y,"presets")}function q(e){return l(e,".howtofix","presets")}function V(e){return S(l(e,".disabled"))}function Q(){return l(Z(de(import.meta.url)),"presets")}function M(e){return[q(e),he()]}var Y=/^[a-z0-9][a-z0-9-]*$/,be=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;function C(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function E(e,r){let t=ge(N(e),N(r));return t!==""&&!t.startsWith("..")&&!me(t)}function ee(e,r){let t=[];if(!C(r))return["preset.json must be a JSON object"];let s=p=>{let d=r[p];return typeof d!="string"||d.trim()===""?(t.push(`${p} must be a non-empty string`),""):d.trim()},n=s("name"),i=s("title"),o=s("description"),c=s("category"),a=s("version");n&&!Y.test(n)&&t.push(`name "${n}" must be lowercase letters, digits and dashes`),a&&!be.test(a)&&t.push(`version "${a}" is not a version like 1.0.0`);let f=r.skills;if(!Array.isArray(f)||f.length===0)t.push("skills must be a non-empty array of directory names");else for(let p of f){if(typeof p!="string"||p.trim()===""){t.push("every skills entry must be a non-empty string");continue}let d=l(e,"skills",p.trim());if(!E(l(e,"skills"),d)){t.push(`skill "${p}" escapes the preset directory`);continue}S(l(d,"SKILL.md"))||t.push(`skill "${p}" has no SKILL.md at ${l("skills",p)}`)}let u=r.prompt;if(u!==void 0)if(typeof u!="string"||u.trim()==="")t.push("prompt must be a non-empty string when present");else{let p=l(e,u.trim());E(e,p)?S(p)||t.push(`prompt file "${u}" does not exist`):t.push(`prompt "${u}" escapes the preset directory`)}let m=r.tags;return m!==void 0&&!Array.isArray(m)&&t.push("tags must be an array when present"),t.push(...z(r.mcp)),t}function te(e){let r=l(e,"preset.json");if(!S(r))return{problems:[`no preset.json in ${e}`]};let t;try{t=JSON.parse(O(r,"utf8"))}catch(o){return{problems:[`preset.json is not valid JSON: ${o instanceof Error?o.message:String(o)}`]}}let s=ee(e,t);if(s.length>0)return{problems:s};let n=t,i=Array.isArray(n.tags)?n.tags.filter(o=>typeof o=="string"):[];return{problems:[],manifest:{name:String(n.name),title:String(n.title),description:String(n.description),category:String(n.category),tags:i,version:String(n.version),skills:n.skills.map(o=>String(o)),prompt:typeof n.prompt=="string"?n.prompt:void 0,mcp:n.mcp&&typeof n.mcp=="object"&&!Array.isArray(n.mcp)?n.mcp:void 0,integrates:typeof n.integrates=="string"&&n.integrates.trim()!==""?n.integrates.trim():void 0}}}function _(e){return e.filter(r=>{try{return x(r).isDirectory()}catch{return!1}})}function I(e,r){let t=[],s=[],n=(o,c)=>{if(!S(l(o,"preset.json")))return;let{manifest:a,problems:f}=te(o);a?t.push({manifest:a,dir:o,source:r}):s.push(`${c}: ${f.join("; ")}`)},i;try{i=R(e).sort()}catch{return{entries:t,problems:s}}for(let o of i){if(o.startsWith("."))continue;let c=l(e,o);try{if(!x(c).isDirectory())continue}catch{continue}if(S(l(c,"preset.json"))){n(c,o);continue}let a;try{a=R(c).sort()}catch{continue}for(let f of a){if(f.startsWith("."))continue;let u=l(c,f);try{if(!x(u).isDirectory())continue}catch{continue}n(u,l(o,f))}}return{entries:t,problems:s}}function tt(e){let r=I(Q(),"bundled"),t=[...r.entries],s=[...r.problems],n=new Map(t.map(i=>[i.manifest.name,i]));for(let i of _(M(e))){let o=I(i,"installed");s.push(...o.problems);for(let c of o.entries){let a=n.get(c.manifest.name);if(a){let f=t.indexOf(a);f>=0&&(t[f]=c),n.set(c.manifest.name,c)}else t.push(c),n.set(c.manifest.name,c)}}return{entries:t,problems:s}}function rt(e){return[...new Set(e.map(r=>r.manifest.category))].sort()}function nt(e,r){return e.filter(t=>t.manifest.category===r).sort((t,s)=>t.manifest.title.localeCompare(s.manifest.title))}function re(e){let r=[];for(let t of _(M(e))){let{entries:s}=I(t,"installed");for(let n of s)V(n.dir)||r.push(l(n.dir,"skills"))}return r}function st(e){let r=[];for(let t of _(M(e))){let{entries:s}=I(t,"installed");for(let n of s){if(V(n.dir))continue;let i=n.manifest.prompt;if(!i)continue;let o=l(n.dir,i);if(E(n.dir,o))try{let c=O(o,"utf8").trim();c&&r.push({name:n.manifest.name,title:n.manifest.title,text:c})}catch{}}}return r}function it(e,r){let t=0;for(let s of r.skills)try{t+=x(l(e,"skills",s,"SKILL.md")).size}catch{}return t}function ke(e){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}var Se=".install.lock";function ve(e,r){P(e,{recursive:!0});let t=l(e,Se),s=Date.now()+6e4;for(;;)try{T(t,`${process.pid}
|
|
4
|
-
`,{flag:"wx"});break}catch(n){if(n.code!=="EEXIST")throw n;let i=!1;try{i=Date.now()-x(t).mtimeMs>12e4}catch{continue}if(i){k(t,{force:!0});continue}if(Date.now()>s)throw new Error(`another install is holding ${t}; remove it if no install is running`);ke(100)}try{for(let n of R(e))n.startsWith(".staging-")&&k(l(e,n),{recursive:!0,force:!0});return r()}finally{k(t,{force:!0})}}function ne(e,r,t){let s=l(r,t.name);return ve(r,()=>{P(r,{recursive:!0});let n=D(l(r,".staging-"));try{ue(e,n,{recursive:!0}),k(s,{recursive:!0,force:!0}),pe(n,s)}catch(i){throw k(n,{recursive:!0,force:!0}),i}return s})}function se(e,r){if(!S(e))return{ok:!1,problems:[`no such directory: ${e}`]};let{manifest:t,problems:s}=te(e);if(!t)return{ok:!1,problems:s};let n=ne(e,r,t);return{ok:!0,name:t.name,target:n,problems:[]}}function xe(e,r){let t=D(l(X(),"howtofix-preset-"));try{return ye("git",["clone","--depth","1","--quiet",e,t],{stdio:"pipe"}),se(t,r)}catch(s){return{ok:!1,problems:[`git clone failed: ${(s instanceof Error?s.message:String(s)).split(`
|
|
5
|
-
`)[0]}`]}}finally{k(t,{recursive:!0,force:!0})}}function ot(e,r){return/^(https?:\/\/|git@|git:\/\/)/.test(e)?xe(e,r):se(N(e),r)}function at(e,r){let t=[],s=[];if(!Y.test(e))return{removed:t,problems:[`"${e}" is not a preset name`]};for(let n of M(r)){let i=l(n,e);if(S(i)){if(!E(n,i)){s.push(`refusing to remove ${i}: outside ${n}`);continue}k(i,{recursive:!0,force:!0}),t.push(i)}}return t.length===0&&s.push(`"${e}" is not installed`),{removed:t,problems:s}}function ct(e){return q(e)}function $e(e){let r=[],t=(i,o)=>{for(let c of R(i,{withFileTypes:!0}).sort((a,f)=>a.name.localeCompare(f.name))){let a=l(i,c.name),f=o?`${o}/${c.name}`:c.name;c.isSymbolicLink()||(c.isDirectory()?t(a,f):c.isFile()&&r.push([f,U("sha256").update(O(a)).digest("hex")]))}};t(e,"");let s=0;for(let[i]of r)s+=x(l(e,i)).size;let n=r.map(([i,o])=>`${o} ${i}`).join(`
|
|
6
|
-
`);return{digest:U("sha256").update(n).digest("hex").slice(0,16),fileCount:r.length,bytes:s}}function lt(){let e=l(Q(),"hub.json");try{let r=O(e,"utf8"),t=JSON.parse(r),s=C(t)&&Array.isArray(t.entries)?t.entries:[],n=[];for(let i of s)C(i)&&(typeof i.name!="string"||typeof i.repo!="string"||typeof i.sha!="string"||typeof i.path!="string"||typeof i.category!="string"||n.push({name:i.name,title:typeof i.title=="string"?i.title:i.name,description:typeof i.description=="string"?i.description:"",category:i.category,skill:typeof i.skill=="string"?i.skill:i.name,path:i.path,repo:i.repo,sha:i.sha,license:typeof i.license=="string"?i.license:"unknown",stars:typeof i.stars=="number"?i.stars:0,sizeKb:typeof i.sizeKb=="number"?i.sizeKb:0,...typeof i.digest=="string"?{digest:i.digest}:{},...typeof i.fileCount=="number"?{fileCount:i.fileCount}:{},...typeof i.modelInvocable=="boolean"?{modelInvocable:i.modelInvocable}:{}}));return{entries:n,problems:[]}}catch(r){return r?.code==="ENOENT"?{entries:[],problems:[]}:{entries:[],problems:[`registry unreadable: ${r instanceof Error?r.message:String(r)}`]}}}function ft(e){return[...new Set(e.map(r=>r.category))].sort()}function ut(e,r){return e.filter(t=>t.category===r).sort((t,s)=>s.stars-t.stars||t.name.localeCompare(s.name))}function pt(e,r){return e.find(t=>t.name===r)}function Ee(e){return`https://codeload.github.com/${e.repo}/tar.gz/${e.sha}`}async function mt(e,r,t=12e4){let s=D(l(X(),"howtofix-hub-"));try{let n=await fetch(Ee(e),{signal:AbortSignal.timeout(t),redirect:"follow"});if(!n.ok)return{ok:!1,problems:[`${e.repo}: HTTP ${n.status} from codeload`]};let i=Buffer.from(await n.arrayBuffer()),o=G(i),c=W(o,e.path).filter(g=>g.kind==="file"||g.kind==="directory");if(!c.some(g=>g.path==="SKILL.md"))return{ok:!1,problems:[`${e.repo}@${e.sha.slice(0,7)} has no ${e.path}/SKILL.md`]};let a=l(s,"preset",e.name),f=l(a,"skills",e.skill),u=0;for(let g of c){if(!K(g.path))return{ok:!1,problems:[`refusing unsafe path in archive: ${g.path}`]};let b=l(f,g.path);if(!E(f,b))return{ok:!1,problems:[`refusing path outside the skill: ${g.path}`]};if(g.kind==="directory"){P(b,{recursive:!0});continue}P(Z(b),{recursive:!0}),T(b,g.data??Buffer.alloc(0)),u+=1}let m={name:e.name,title:e.title,description:e.description,category:e.category,version:"1.0.0",skills:[e.skill],source:`${e.repo}@${e.sha}`,license:e.license};if(T(l(a,"preset.json"),`${JSON.stringify(m,null,2)}
|
|
7
|
-
`),!e.digest)return{ok:!1,problems:[`${e.repo}@${e.sha.slice(0,7)}: registry entry has no digest`,"refusing to install; content cannot be verified against what was reviewed"]};let p=$e(f);if(p.digest!==e.digest)return{ok:!1,problems:[`${e.repo}@${e.sha.slice(0,7)}: content changed under a pinned commit`,`expected ${e.digest} (${e.fileCount??"?"} files), got ${p.digest} (${p.fileCount} files)`,"refusing to install; the registry needs regenerating"]};let d=ee(a,m);if(d.length>0)return{ok:!1,problems:d};let h=ne(a,r,m);return{ok:!0,name:e.name,target:h,problems:[],skill:e.skill,modelInvocable:e.modelInvocable}}catch(n){return{ok:!1,problems:[`download failed: ${(n instanceof Error?n.message:String(n)).split(`
|
|
8
|
-
`)[0]}`]}}finally{k(s,{recursive:!0,force:!0})}}function Pe(){let e=(process.env.HOWTOFIX_HOME??process.env.HOME??"").trim();return Ae(e||we())}var y=process.env.HOWTOFIX_CODING_AGENT_DIR?.trim()||$(Pe(),".howtofix","agent"),bt=$(y,"skills");function Re(e){return $(e,".howtofix","skills")}function kt(e){let r=[Re(e)];return r.push(...re(e)),r}var St=$(y,"agents"),vt=$(y,"usage-cache.json"),xt=$(y,"workflows");function $t(){process.env.HXF_CODING_AGENT_DIR=y}export{F as a,Te as b,Ne as c,Ce as d,De as e,_e as f,Le as g,Fe as h,ze as i,Je as j,V as k,Q as l,ee as m,te as n,tt as o,rt as p,nt as q,re as r,st as s,it as t,se as u,ot as v,at as w,ct as x,lt as y,ft as z,ut as A,pt as B,mt as C,y as D,bt as E,Re as F,kt as G,St as H,vt as I,xt as J,$t as K};
|
package/dist/chunk-WKUJ7CFO.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e}from"./chunk-3FYCFLNK.js";import"./chunk-WOT6VMZA.js";export{a as PROXY_SETTING_KEY,b as configuredProxy,c as environmentProxy,e as installProxy,d as validateProxyUrl};
|
package/dist/chunk-WOT6VMZA.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0})};export{e as a};
|
package/dist/chunk-WUPU6LTD.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{execFile as M}from"node:child_process";import{closeSync as v,existsSync as f,mkdirSync as N,openSync as C,readFileSync as w,realpathSync as k,statSync as T,unlinkSync as E,writeFileSync as _}from"node:fs";import{homedir as p}from"node:os";import{delimiter as I,dirname as $,join as d,sep as m}from"node:path";var l="howtofixcli",g=["npm","npm.cmd","npm.exe"],A=2e4,O=2,P=12e4,R=600*1e3,U=5*1e3;function F(e,t){let r=s=>{let i=s.trim().split("-")[0]?.split("+")[0]??"";if(/^\d+(\.\d+)*$/.test(i))return i.split(".").map(c=>Number(c))},n=r(e),o=r(t);if(!n||!o)return 0;let a=Math.max(n.length,o.length);for(let s=0;s<a;s+=1){let i=n[s]??0,c=o[s]??0;if(i>c)return 1;if(i<c)return-1}return 0}function L(e,t){return e.includes("-")?!1:F(e,t)>0}var h=(e,t,r)=>new Promise(n=>{M(e,t,{cwd:r.cwd,timeout:r.timeoutMs,windowsHide:!0},(o,a,s)=>{let i=o?o.code:void 0,c=typeof i=="number"?i:o?1:0,u=typeof i=="string"?i:void 0;n({code:c,stdout:String(a??""),stderr:String(s??""),...u?{errorCode:u}:{}})})}),H=new Set(["ENOENT","EACCES","EINVAL","EPERM"]);function b(){let e=$(process.execPath);for(let r of[["..","lib","node_modules","npm","bin","npm-cli.js"],["node_modules","npm","bin","npm-cli.js"]]){let n=d(e,...r);if(f(n))return{command:process.execPath,args:[n]}}let t=process.env.PATH?.split(I).filter(Boolean)??[];for(let r of t)for(let n of g){let o=d(r,n);if(!(n.endsWith(".cmd")||n.endsWith(".bat"))&&f(o))return{command:o,args:[]}}if(process.platform==="win32")for(let r of t)for(let n of g){if(!n.endsWith(".cmd")&&!n.endsWith(".bat"))continue;let o=d(r,n);if(f(o))return{command:process.env.ComSpec||"cmd.exe",args:["/d","/s","/c",`"${o}"`]}}}var D="could not check for a newer version: npm was not found, so run `npm install -g howtofixcli@latest` yourself",G="could not check for a newer version: the registry did not answer";function Q(e){if(e.latest===void 0)return`${e.message} (this is why no update was offered; /update retries it)`}function K(e){if(e.code===-2)return!0;let t=e.errorCode??(e.stderr??"").trim();return H.has(t)}function x(){let t=process.env.HOWTOFIX_CODING_AGENT_DIR?.trim()||d(p(),".howtofix","agent");try{N(t,{recursive:!0})}catch{}return d(t,"update.lock")}function B(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return t?.code==="EPERM"}}function S(e,t){try{let r=t-T(e).mtimeMs,n=w(e,"utf8").trim();return{pid:/^\d+$/.test(n)?Number.parseInt(n,10):void 0,ageMs:r}}catch{return}}function W(e){return e?e.pid===void 0?e.ageMs<U:B(e.pid)?e.ageMs<R:!1:!1}function j(e=Date.now()){let t=x();for(let r=0;r<2;r+=1)try{let n=C(t,"wx",384);try{_(n,String(process.pid))}finally{v(n)}return!0}catch(n){if(n.code!=="EEXIST")return!0;if(W(S(t,e)))return!1;try{E(t)}catch{return!1}}return!1}function J(){let e=x();try{let t=S(e,Date.now());if(t&&t.pid!==void 0&&t.pid!==process.pid)return;E(e)}catch{}}async function y(e){let t=e?.runner??h,r=b();if(!r)return{reason:"no-npm"};let n="no-answer";for(let o=0;o<O;o+=1){let a;try{a=await t(r.command,[...r.args,"view",`${l}@latest`,"version","--prefer-online"],{cwd:p(),timeoutMs:e?.timeoutMs??A})}catch{n="no-answer";continue}if(a.code!==0){if(K(a))return{reason:"no-npm"};n="no-answer";continue}let s=a.stdout.trim().split(`
|
|
2
|
-
`).pop()?.trim()??"";if(/^\d+\.\d+/.test(s))return{version:s};n="no-answer"}return{reason:n}}async function Z(e){return(await y(e)).version}async function ee(e,t){let r=await y(t);if(!r.version)return{current:e,available:!1,message:r.reason==="no-npm"?D:G};let n=r.version;return L(n,e)?{current:e,latest:n,available:!0,message:`HowToFix ${n} is available (you have ${e})`}:{current:e,latest:n,available:!1,message:`HowToFix ${e} is up to date`}}function V(e,t,r){let n=`${t}
|
|
3
|
-
${e}`.split(`
|
|
4
|
-
`).map(u=>u.trim()).filter(Boolean).filter(u=>!/^npm warn\b/i.test(u)),o=n.filter(u=>/^npm error\b/i.test(u)||/\bERR!/i.test(u)),s=(o.find(u=>/^npm error code\b/i.test(u))??o.at(-1)??n.at(-1)??r??"").replace(/^npm error\s*/i,"").trim(),i=`${n.join(" ")} ${r??""}`,c="";return/EACCES|EPERM|permission denied/i.test(i)?c=" \u2014 npm could not write its files (permission denied); close other HowToFix windows and run the terminal as Administrator":/EBUSY|EEXIST|ENOTEMPTY|resource busy|being used by another process/i.test(i)?c=" \u2014 a file is in use; close other HowToFix windows and try again":/ENOSPC/i.test(i)?c=" \u2014 the disk is full":/ETIMEDOUT|ENOTFOUND|EAI_AGAIN|ECONNREFUSED/i.test(i)&&(c=" \u2014 npm could not reach the registry"),{detail:s,hint:c}}async function ne(e){let t=e?.runner??h;if(!j())return{ok:!1,message:"another HowToFix is already installing an update"};try{let r=b();if(!r)return{ok:!1,message:"npm was not found, so run `npm install -g howtofixcli@latest` yourself"};let n=e?.version?`${l}@${e.version}`:`${l}@latest`,o=await t(r.command,[...r.args,"install","-g",n],{cwd:p(),timeoutMs:e?.timeoutMs??P});if(o.code!==0){let{detail:a,hint:s}=V(o.stdout,o.stderr,o.errorCode);return{ok:!1,message:`the update did not install${s}${a?`: ${a}`:""}`}}return{ok:!0,version:e?.version,message:"updated; it takes effect the next time HowToFix starts"}}catch(r){return{ok:!1,message:`the update failed: ${r instanceof Error?r.message:String(r)}`}}finally{J()}}function te(e=process.argv[1]){if(!e)return!1;let t=e;try{t=k(e)}catch{}return t.includes(`${m}node_modules${m}${l}${m}`)}function re(e){try{return JSON.parse(w(e,"utf8")).autoUpdate!==!1}catch{return!0}}export{l as a,A as b,O as c,P as d,R as e,U as f,F as g,L as h,b as i,D as j,G as k,Q as l,B as m,j as n,J as o,Z as p,ee as q,V as r,ne as s,te as t,re as u};
|
package/dist/chunk-WX3V5P7U.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{E as s,F as l}from"./chunk-V656XVXV.js";function c(i){return[s,l(i)]}function d(i,n){let t=i.trim(),r=/^\/skill:([^\s]+)(?:\s+([\s\S]*))?$/.exec(t)??/^\/skill\s+([^\s]+)(?:\s+([\s\S]*))?$/.exec(t);if(!r)return;let e=r[1]??"";if(!n.includes(e))return;let o=(r[2]??"").trim();return o?`/skill:${e} ${o}`:`/skill:${e}`}function u(i){if(i.length===0){let[n,t]=c(process.cwd());return["no skills loaded.",`put a SKILL.md in ${n}`,`or in ${t}`,"invoke with /skill:<name>"].join(`
|
|
2
|
-
`)}return i.map(n=>{let t=n.disableModelInvocation?" (invoke only)":"";return`${n.name}${t}
|
|
3
|
-
${n.description}
|
|
4
|
-
${n.filePath}`}).join(`
|
|
5
|
-
`)}export{c as a,d as b,u as c};
|
package/dist/chunk-XW6LMQGX.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as a,e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i}from"./chunk-QPHSHL7H.js";import"./chunk-UTYFLLSM.js";import"./chunk-C5E3SFOQ.js";import"./chunk-N3J2J7EQ.js";import"./chunk-WOT6VMZA.js";export{b as CLI_REFRESH_SKEW_MS,c as accessTokenIsFresh,g as clearCliCredential,a as cliCredentialsPath,e as readCliCredential,h as refreshCliCredential,d as refreshTokenIsUsable,i as renewCliCredentialIfNeeded,f as writeCliCredential};
|
package/dist/chunk-YW7NORH3.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
function o(n){return n.type==="message_update"}function r(n){if(n.type==="toolcall_start"){let s=n.contentIndex,t=s===void 0?void 0:n.partial?.content[s];if(t?.type!=="toolCall")return;let{partial:u,...i}=n;return{...i,id:t.id,toolName:t.name}}if(!("partial"in n))return n;let{partial:e,...a}=n;return a}function d(n){if(!o(n))return n;if(n.message.role!=="assistant")return;let e=r(n.assistantMessageEvent);if(e!==void 0)return{type:"message_update",usage:n.message.usage,assistantMessageEvent:e}}function p(n){let e=d(n);if(e!==void 0)return`${JSON.stringify(e)}
|
|
2
|
-
`}export{d as a,p as b};
|