howtofixcli 0.7.22 → 0.7.24

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.
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j}from"./chunk-C52X7EKC.js";import"./chunk-MWUEV7YF.js";import"./chunk-WOT6VMZA.js";export{h as CLI_CLIENT_HEADER,a as CLI_SIGNING_KEY_ID,i as cliClientHeader,c as cliSignaturePayload,f as cliSigningKeyFingerprint,e as cliSigningKeyMatchesPanel,b as cliSigningPublicKey,d as createNonce,g as describeClient,j as signLoginRequest};
1
+ import{a,b,c,d,e,f,g,h,i,j}from"./chunk-C5E3SFOQ.js";import"./chunk-N3J2J7EQ.js";import"./chunk-WOT6VMZA.js";export{h as CLI_CLIENT_HEADER,a as CLI_SIGNING_KEY_ID,i as cliClientHeader,c as cliSignaturePayload,f as cliSigningKeyFingerprint,e as cliSigningKeyMatchesPanel,b as cliSigningPublicKey,d as createNonce,g as describeClient,j as signLoginRequest};
@@ -1 +1 @@
1
- import{A,B,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-LLQEHSZP.js";import"./chunk-UTYFLLSM.js";import"./chunk-C52X7EKC.js";import"./chunk-MWUEV7YF.js";import"./chunk-WOT6VMZA.js";export{g as CATALOG_CACHE_TTL_MS,m as DEFAULT_CONTEXT_WINDOW,a as HOWTOFIX_BASE_URL,b as HOWTOFIX_CONSOLE_URL,l as HOWTOFIX_MODEL_COMPAT,c as HOWTOFIX_PROVIDERS,j as HTTP_IDLE_TIMEOUT_MS,r as UNLIMITED_SENTINEL,v as applyCatalog,w as applyCompat,A as checkAccount,s as checkUsage,d as configuredProviderIds,x as countNewModels,k as ensureGatewaySettings,B as fetchGatewayPrices,z as findLiveModels,q as isHowtofixProvider,h as loadCatalog,o as looksLikeToken,n as maskToken,u as mergeModels,e as newProviderEntry,p as parseModelIds,y as probeModel,f as repairGatewayModels,i as repairModelFacts,t as syncGatewayModelsOnStart};
1
+ import{A,B,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-MNDKS6UH.js";import"./chunk-UTYFLLSM.js";import"./chunk-C5E3SFOQ.js";import"./chunk-N3J2J7EQ.js";import"./chunk-WOT6VMZA.js";export{g as CATALOG_CACHE_TTL_MS,m as DEFAULT_CONTEXT_WINDOW,a as HOWTOFIX_BASE_URL,b as HOWTOFIX_CONSOLE_URL,l as HOWTOFIX_MODEL_COMPAT,c as HOWTOFIX_PROVIDERS,j as HTTP_IDLE_TIMEOUT_MS,r as UNLIMITED_SENTINEL,v as applyCatalog,w as applyCompat,A as checkAccount,s as checkUsage,d as configuredProviderIds,x as countNewModels,k as ensureGatewaySettings,B as fetchGatewayPrices,z as findLiveModels,q as isHowtofixProvider,h as loadCatalog,o as looksLikeToken,n as maskToken,u as mergeModels,e as newProviderEntry,p as parseModelIds,y as probeModel,f as repairGatewayModels,i as repairModelFacts,t as syncGatewayModelsOnStart};
@@ -1,4 +1,4 @@
1
- import{$ as Ne,A as Te,B as $e,D as A,E as G,Ea as Xe,G as M,H as Ee,P as Ae,Pa as Ye,Q as ve,Qa as Ve,R as je,S as Oe,T as Pe,V as Re,W as Ce,Y as De,_ as W,a as C,b as D,ba as Fe,c as ie,ca as Me,d as ae,da as Ie,e as ce,ea as Le,f as le,fa as Ge,g as $,i as de,ia as Ue,j as ue,k as fe,ka as Be,l as me,la as U,m as ge,ma as He,na as We,o as he,p as we,pa as z,q as ye,r as be,s as ke,t as E,ta as ze,u as xe,ua as qe,v as Se,w as L,wa as Ze,x as _e,xa as Ke}from"./chunk-AUDMRGWF.js";import{r as re}from"./chunk-JFYVRWJI.js";import{b as pe}from"./chunk-27TRKD65.js";import{D as k,G as te,r as Q,s as ee}from"./chunk-V656XVXV.js";import{c as ne}from"./chunk-LLQEHSZP.js";import{h as oe,l as se}from"./chunk-FC7RDN2F.js";import"./chunk-UTYFLLSM.js";import"./chunk-C52X7EKC.js";import{b as I,c as V,d as J}from"./chunk-MWUEV7YF.js";import"./chunk-WOT6VMZA.js";import{join as _t}from"node:path";import{hostname as Fn}from"node:os";import{createAgentSession as Mn,createCodemodeExtension as In,createMcpExtension as Ln,DefaultResourceLoader as Gn,ProjectTrustStore as Un,SessionManager as B,SettingsManager as Bn}from"@netrodev/hxf-coding-agent";import{existsSync as $t,readFileSync as Et}from"node:fs";import{join as At}from"node:path";var Je=At(k,"APPEND_SYSTEM.md"),vt=["<non-interactive>","This run has no user attached: it was started with --print, and there is nobody to answer a question. Anything that stops and waits for a reply \u2014 `ask`, a confirmation, a skill that resolves a mode by asking which mode to use \u2014 will simply end the run with the task unfinished.","So do not ask. Where an instruction tells you to ask the user and wait, take the default it describes and continue, and say which default you took and why in your final answer. The user reads that answer; they cannot answer mid-run.","Where a skill offers a choice of modes, prefer the one that applies the rules while you work over the one that audits afterwards: this is the mode for building something now, and the audit mode can still be run later by the same person who reads your answer.","</non-interactive>"].join(`
1
+ import{$ as Ne,A as Te,B as $e,D as A,E as G,Ea as Xe,G as M,H as Ee,P as Ae,Pa as Ye,Q as ve,Qa as Ve,R as je,S as Oe,T as Pe,V as Re,W as Ce,Y as De,_ as W,a as C,b as D,ba as Fe,c as ie,ca as Me,d as ae,da as Ie,e as ce,ea as Le,f as le,fa as Ge,g as $,i as de,ia as Ue,j as ue,k as fe,ka as Be,l as me,la as U,m as ge,ma as He,na as We,o as he,p as we,pa as z,q as ye,r as be,s as ke,t as E,ta as ze,u as xe,ua as qe,v as Se,w as L,wa as Ze,x as _e,xa as Ke}from"./chunk-AUDMRGWF.js";import{r as re}from"./chunk-JFYVRWJI.js";import{b as pe}from"./chunk-27TRKD65.js";import{D as k,G as te,r as Q,s as ee}from"./chunk-V656XVXV.js";import{c as ne}from"./chunk-MNDKS6UH.js";import{h as oe,l as se}from"./chunk-QPHSHL7H.js";import"./chunk-UTYFLLSM.js";import"./chunk-C5E3SFOQ.js";import{b as I,c as V,d as J}from"./chunk-N3J2J7EQ.js";import"./chunk-WOT6VMZA.js";import{join as _t}from"node:path";import{hostname as Fn}from"node:os";import{createAgentSession as Mn,createCodemodeExtension as In,createMcpExtension as Ln,DefaultResourceLoader as Gn,ProjectTrustStore as Un,SessionManager as B,SettingsManager as Bn}from"@netrodev/hxf-coding-agent";import{existsSync as $t,readFileSync as Et}from"node:fs";import{join as At}from"node:path";var Je=At(k,"APPEND_SYSTEM.md"),vt=["<non-interactive>","This run has no user attached: it was started with --print, and there is nobody to answer a question. Anything that stops and waits for a reply \u2014 `ask`, a confirmation, a skill that resolves a mode by asking which mode to use \u2014 will simply end the run with the task unfinished.","So do not ask. Where an instruction tells you to ask the user and wait, take the default it describes and continue, and say which default you took and why in your final answer. The user reads that answer; they cannot answer mid-run.","Where a skill offers a choice of modes, prefer the one that applies the rules while you work over the one that audits afterwards: this is the mode for building something now, and the audit mode can still be run later by the same person who reads your answer.","</non-interactive>"].join(`
2
2
  `),jt=16*1024;function Ot(e){try{if(!$t(e))return;let o=Et(e,"utf8").trim();return!o||Buffer.byteLength(o,"utf8")>jt?void 0:o}catch{return}}function Qe(e,o){let s=[o?e:`${e}
3
3
 
4
4
  ${vt}`],t=Ot(Je);return t&&s.push(`# Standing instructions from ${Je}
@@ -1,2 +1,2 @@
1
- import{b as o}from"./chunk-MWUEV7YF.js";import{createPrivateKey as p,createPublicKey as f,createHash as l,randomBytes as y,sign as m}from"node:crypto";import{arch as s,cpus as I,hostname as d,platform as c}from"node:os";var a="hf-cli-1",x="MC4CAQAwBQYDK2VwBCIEIDmKoNgInS7oDpncee1d1+Mnci1R/q4aE5xxHeCKq4Dc",C="howtofix-cli-auth-v1",i;function u(){return i||(i=p({key:Buffer.from(x,"base64"),format:"der",type:"pkcs8"})),i}function g(){return f(u())}function K(t,e,n,r){return Buffer.from([C,t,e,n,r].join(`
1
+ import{b as o}from"./chunk-N3J2J7EQ.js";import{createPrivateKey as p,createPublicKey as f,createHash as l,randomBytes as y,sign as m}from"node:crypto";import{arch as s,cpus as I,hostname as d,platform as c}from"node:os";var a="hf-cli-1",x="MC4CAQAwBQYDK2VwBCIEIDmKoNgInS7oDpncee1d1+Mnci1R/q4aE5xxHeCKq4Dc",C="howtofix-cli-auth-v1",i;function u(){return i||(i=p({key:Buffer.from(x,"base64"),format:"der",type:"pkcs8"})),i}function g(){return f(u())}function K(t,e,n,r){return Buffer.from([C,t,e,n,r].join(`
2
2
  `),"utf8")}function h(){return y(16).toString("hex")}var E="tQ91uspGl0sw5Y8x+soLYnFNX6a9vEzSzCuuvalzdKk=";function P(){let t=g().export({format:"der",type:"spki"});return t.subarray(t.length-32).toString("base64")===E}function N(){let t=g().export({format:"der",type:"spki"});return l("sha256").update(t).digest("hex").slice(0,16)}function $(){let e=(I()[0]?.model??"").replace(/\s+/g," ").trim(),n=d(),r=e?`${n} (${c()}/${s()}, ${e})`:`${n} (${c()}/${s()})`;return`CLI (${o}, ${r})`}var k="X-HowToFix-Client";function A(){return`CLI (${o})`}function B(t,e){let n=h(),r=m(null,K(a,t,e,n),u());return{keyId:a,nonce:n,signature:r.toString("base64")}}export{a,g as b,K as c,h as d,P as e,N as f,$ as g,k as h,A as i,B as j};
@@ -1 +1 @@
1
- import{b as r}from"./chunk-MWUEV7YF.js";import"./chunk-WOT6VMZA.js";function a(e){return{prompt:s=>e.session.prompt(s),abort:()=>e.session.abort(),subscribe:s=>e.session.subscribe(n=>s(n)),getLastAssistantText:()=>e.session.getLastAssistantText(),lastStopReason:()=>{let s=e.session.state.messages.at(-1);return s?.role==="assistant"?s.stopReason:void 0},dispose:()=>e.dispose()}}async function u(e,s){let{openSession:n}=await import("./chunk-BSYK5SMR.js"),i=t=>n({cwd:t,model:s.model,thinking:s.thinking,continueSession:!1,noSession:!1,sessionPath:void 0,interactive:!1});if(e==="acp"){let{runAcp:t}=await import("./chunk-DAPXGSGD.js");await t({input:process.stdin,output:process.stdout,version:r,createAgent:async d=>a(await i(d))});return}let{runRpc:p}=await import("./chunk-ONZLNFQ2.js"),{jsonLine:c}=await import("./chunk-DOD7MUGX.js"),o=await i(s.cwd);await p({input:process.stdin,output:process.stdout,agent:a(o),encodeEvent:t=>c(t),state:()=>({sessionId:o.session.sessionId,model:o.modelLabel,cwd:s.cwd})})}export{a as agentFromSession,u as serveProtocol};
1
+ import{b as r}from"./chunk-N3J2J7EQ.js";import"./chunk-WOT6VMZA.js";function a(e){return{prompt:s=>e.session.prompt(s),abort:()=>e.session.abort(),subscribe:s=>e.session.subscribe(n=>s(n)),getLastAssistantText:()=>e.session.getLastAssistantText(),lastStopReason:()=>{let s=e.session.state.messages.at(-1);return s?.role==="assistant"?s.stopReason:void 0},dispose:()=>e.dispose()}}async function u(e,s){let{openSession:n}=await import("./chunk-7PHRNXLN.js"),i=t=>n({cwd:t,model:s.model,thinking:s.thinking,continueSession:!1,noSession:!1,sessionPath:void 0,interactive:!1});if(e==="acp"){let{runAcp:t}=await import("./chunk-DAPXGSGD.js");await t({input:process.stdin,output:process.stdout,version:r,createAgent:async d=>a(await i(d))});return}let{runRpc:p}=await import("./chunk-ONZLNFQ2.js"),{jsonLine:c}=await import("./chunk-DOD7MUGX.js"),o=await i(s.cwd);await p({input:process.stdin,output:process.stdout,agent:a(o),encodeEvent:t=>c(t),state:()=>({sessionId:o.session.sessionId,model:o.modelLabel,cwd:s.cwd})})}export{a as agentFromSession,u as serveProtocol};
@@ -1,2 +1,2 @@
1
- import{b as c,d as l}from"./chunk-27TRKD65.js";import{D as s}from"./chunk-V656XVXV.js";import"./chunk-UTYFLLSM.js";import{a as i,b as r}from"./chunk-MWUEV7YF.js";import"./chunk-WOT6VMZA.js";var d=[["/connect","sign in with your howtofix.id email:password \u2014 no browser needed"],["/model","choose which model answers"],["/help","list every command"],["/quit","leave"]],u=[" \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557"," \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2554\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D"," \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2557 "," \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2554\u2550\u2550\u255D "," \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u255D \u2588\u2588\u2557\u2588\u2588\u2551 "," \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D "],m=[" _ _ _____ ","| | | | __ __ | ___|","| |_| | \\ \\/ / | |_ ","| _ | > < | _| ","|_| |_| /_/\\_\\ |_| "];function g(){if(process.platform==="win32")return!1;let e=(process.env.LC_ALL||process.env.LC_CTYPE||process.env.LANG||"").toLowerCase();return e===""||e==="c"||e==="posix"||!e.includes("utf-8")&&!e.includes("utf8")?!1:!/ja|ko|zh|_kr|_jp|_cn|_tw|_hk/.test(e)}function h(){return g()?u:m}var _="https://howtofix.id/cli";function p(e){let n=process.env.HOME??"",t=n!==""&&e.startsWith(n)?`~${e.slice(n.length)}`:e,o=t.split("/").filter(Boolean);return o.length>3?`\u2026/${o.slice(-2).join("/")}`:t}function f(e){let n=e.signedIn?d.filter(([t])=>t!=="/connect"):d;return[...h(),"",`${i} ${r} \u2014 a terminal coding agent. Describe the change you want and it reads, edits and runs the code in front of you.`,"",` working in ${p(e.cwd)}`,...e.note?[` session ${e.note}`]:[],"",...e.signedIn?[" already signed in to howtofix.id",""]:[],...n.map(([t,o])=>` ${t.padEnd(11)}${o}`),"",' Or just start typing. Every message goes to the model; anything beginning with "/" stays local.'].join(`
1
+ import{b as c,d as l}from"./chunk-27TRKD65.js";import{D as s}from"./chunk-V656XVXV.js";import"./chunk-UTYFLLSM.js";import{a as i,b as r}from"./chunk-N3J2J7EQ.js";import"./chunk-WOT6VMZA.js";var d=[["/connect","sign in with your howtofix.id email:password \u2014 no browser needed"],["/model","choose which model answers"],["/help","list every command"],["/quit","leave"]],u=[" \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557"," \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2554\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D"," \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2557 "," \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2554\u2550\u2550\u255D "," \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u255D \u2588\u2588\u2557\u2588\u2588\u2551 "," \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D "],m=[" _ _ _____ ","| | | | __ __ | ___|","| |_| | \\ \\/ / | |_ ","| _ | > < | _| ","|_| |_| /_/\\_\\ |_| "];function g(){if(process.platform==="win32")return!1;let e=(process.env.LC_ALL||process.env.LC_CTYPE||process.env.LANG||"").toLowerCase();return e===""||e==="c"||e==="posix"||!e.includes("utf-8")&&!e.includes("utf8")?!1:!/ja|ko|zh|_kr|_jp|_cn|_tw|_hk/.test(e)}function h(){return g()?u:m}var _="https://howtofix.id/cli";function p(e){let n=process.env.HOME??"",t=n!==""&&e.startsWith(n)?`~${e.slice(n.length)}`:e,o=t.split("/").filter(Boolean);return o.length>3?`\u2026/${o.slice(-2).join("/")}`:t}function f(e){let n=e.signedIn?d.filter(([t])=>t!=="/connect"):d;return[...h(),"",`${i} ${r} \u2014 a terminal coding agent. Describe the change you want and it reads, edits and runs the code in front of you.`,"",` working in ${p(e.cwd)}`,...e.note?[` session ${e.note}`]:[],"",...e.signedIn?[" already signed in to howtofix.id",""]:[],...n.map(([t,o])=>` ${t.padEnd(11)}${o}`),"",' Or just start typing. Every message goes to the model; anything beginning with "/" stays local.'].join(`
2
2
  `)}function w(){return[{value:"connect",label:"Sign in to howtofix.id",description:"opens the browser, or paste a key from the panel"},{value:"ready",label:"I have a key \u2014 just give me the prompt",description:"drops you at the prompt; run /connect whenever you like"},{value:"release",label:"What's in this release",description:`opens the ${r} notes in your browser`}]}async function E(e,n,t){c(s).welcomeSeen||(l(s),t(`welcome to ${i}`,f(e)),!e.signedIn&&await new Promise(o=>{n("First run \u2014 how do you want to begin?",w(),a=>{a==="connect"&&e.runSlash("/connect"),a==="release"&&e.openExternal(_),o()},()=>o())}))}export{E as maybeShowWelcome};
@@ -1,4 +1,4 @@
1
- import{a as y}from"./chunk-UTYFLLSM.js";import{h as k,i as T}from"./chunk-C52X7EKC.js";import{existsSync as L,mkdirSync as $,readFileSync as b}from"node:fs";import{join as M}from"node:path";var F="https://models.dev/api.json";var O=["anthropic","openai","google","deepseek","zai","xai","moonshotai","minimax","alibaba","xiaomi","meta","tencent","nvidia","venice","openrouter"];function x(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"")}function S(n){let r=n.split("/");return x(r[r.length-1]??n)}function W(n){let r=new Map,o=new Map;if(!n||typeof n!="object")return r;let t=n,s=i=>{let e=O.indexOf(i);return e===-1?O.length:e};for(let i of Object.keys(t).sort()){let e=t[i]?.models;if(!(!e||typeof e!="object"))for(let a of Object.keys(e)){let c=e[a],u=Number(c?.limit?.context);if(!Number.isFinite(u)||u<=0)continue;let l=x(a),d=s(i),m=o.get(l);if(m!==void 0&&m<=d)continue;let f=Number(c?.limit?.output);r.set(l,{contextWindow:Math.floor(u),maxTokens:Number.isFinite(f)&&f>0?Math.floor(f):void 0,reasoning:c?.reasoning===!0,vision:Array.isArray(c?.modalities?.input)&&c.modalities.input.includes("image")}),o.set(l,d)}}return r}function A(n,r){let o=x(r);if(!o)return;let t=n.get(o);if(t)return t;let s=S(r);for(let[i,e]of n)if(S(i)===s)return e;for(let[i,e]of n)if(i.endsWith(o)||o.endsWith(i))return e}function v(n){return`${n}/models-dev-cache.json`}function N(n){let r={};for(let[o,t]of n)r[o]=[t.contextWindow,t.maxTokens??0,t.reasoning?1:0,t.vision?1:0];return JSON.stringify(r)}function R(n){let r=new Map,o;try{o=JSON.parse(n)}catch{return r}if(!o||typeof o!="object")return r;for(let[t,s]of Object.entries(o)){if(!Array.isArray(s)||s.length<3)continue;let i=Number(s[0]),e=Number(s[1]);!Number.isFinite(i)||i<=0||r.set(t,{contextWindow:Math.floor(i),maxTokens:Number.isFinite(e)&&e>0?Math.floor(e):void 0,reasoning:s[2]===1||s[2]===!0,vision:s[3]===1||s[3]===!0})}return r}async function I(n){let r=n?.url??F,o=n?.fetchImpl??fetch,t=n?.timeoutMs??2e4,s=new AbortController,i=setTimeout(()=>s.abort(),t);try{let e=await o(r,{signal:s.signal,headers:{Accept:"application/json"}});if(!e.ok)return{ok:!1,message:`the model catalogue answered ${e.status}`};let a=W(await e.json());return a.size===0?{ok:!1,message:"the model catalogue was empty or in an unexpected shape"}:{ok:!0,index:a}}catch(e){return{ok:!1,message:e instanceof Error&&e.name==="AbortError"?`the model catalogue did not answer within ${Math.round(t/1e3)}s`:"could not reach the model catalogue"}}finally{clearTimeout(i)}}var _="https://api.howtofix.id/v1",ne="https://howtofix.id/keys",C=["howtofix","howtofix-free"];function re(n){try{let o=JSON.parse(b(M(n,"models.json"),"utf8")).providers;return!o||typeof o!="object"?new Set:new Set(Object.keys(o))}catch{return new Set}}function oe(){return{baseUrl:_,api:"openai-completions",headers:{[k]:T()}}}function se(n){let r=M(n,"models.json"),o;try{o=JSON.parse(b(r,"utf8"))}catch{return 0}let t=o.providers;if(!t||typeof t!="object")return 0;let s=0;for(let i of C){let e=t[i];if(!e||!Array.isArray(e.models))continue;let a=X(e.models),c={...e.headers??{},[k]:T()},u=e.headers?.[k]!==c[k];a.changed===0&&!u||(e.models=a.models,e.headers=c,s+=a.changed===0?1:a.changed)}if(s===0)return 0;try{y(r,`${JSON.stringify(o,null,2)}
1
+ import{a as y}from"./chunk-UTYFLLSM.js";import{h as k,i as T}from"./chunk-C5E3SFOQ.js";import{existsSync as L,mkdirSync as $,readFileSync as b}from"node:fs";import{join as M}from"node:path";var F="https://models.dev/api.json";var O=["anthropic","openai","google","deepseek","zai","xai","moonshotai","minimax","alibaba","xiaomi","meta","tencent","nvidia","venice","openrouter"];function x(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"")}function S(n){let r=n.split("/");return x(r[r.length-1]??n)}function W(n){let r=new Map,o=new Map;if(!n||typeof n!="object")return r;let t=n,s=i=>{let e=O.indexOf(i);return e===-1?O.length:e};for(let i of Object.keys(t).sort()){let e=t[i]?.models;if(!(!e||typeof e!="object"))for(let a of Object.keys(e)){let c=e[a],u=Number(c?.limit?.context);if(!Number.isFinite(u)||u<=0)continue;let l=x(a),d=s(i),m=o.get(l);if(m!==void 0&&m<=d)continue;let f=Number(c?.limit?.output);r.set(l,{contextWindow:Math.floor(u),maxTokens:Number.isFinite(f)&&f>0?Math.floor(f):void 0,reasoning:c?.reasoning===!0,vision:Array.isArray(c?.modalities?.input)&&c.modalities.input.includes("image")}),o.set(l,d)}}return r}function A(n,r){let o=x(r);if(!o)return;let t=n.get(o);if(t)return t;let s=S(r);for(let[i,e]of n)if(S(i)===s)return e;for(let[i,e]of n)if(i.endsWith(o)||o.endsWith(i))return e}function v(n){return`${n}/models-dev-cache.json`}function N(n){let r={};for(let[o,t]of n)r[o]=[t.contextWindow,t.maxTokens??0,t.reasoning?1:0,t.vision?1:0];return JSON.stringify(r)}function R(n){let r=new Map,o;try{o=JSON.parse(n)}catch{return r}if(!o||typeof o!="object")return r;for(let[t,s]of Object.entries(o)){if(!Array.isArray(s)||s.length<3)continue;let i=Number(s[0]),e=Number(s[1]);!Number.isFinite(i)||i<=0||r.set(t,{contextWindow:Math.floor(i),maxTokens:Number.isFinite(e)&&e>0?Math.floor(e):void 0,reasoning:s[2]===1||s[2]===!0,vision:s[3]===1||s[3]===!0})}return r}async function I(n){let r=n?.url??F,o=n?.fetchImpl??fetch,t=n?.timeoutMs??2e4,s=new AbortController,i=setTimeout(()=>s.abort(),t);try{let e=await o(r,{signal:s.signal,headers:{Accept:"application/json"}});if(!e.ok)return{ok:!1,message:`the model catalogue answered ${e.status}`};let a=W(await e.json());return a.size===0?{ok:!1,message:"the model catalogue was empty or in an unexpected shape"}:{ok:!0,index:a}}catch(e){return{ok:!1,message:e instanceof Error&&e.name==="AbortError"?`the model catalogue did not answer within ${Math.round(t/1e3)}s`:"could not reach the model catalogue"}}finally{clearTimeout(i)}}var _="https://api.howtofix.id/v1",ne="https://howtofix.id/keys",C=["howtofix","howtofix-free"];function re(n){try{let o=JSON.parse(b(M(n,"models.json"),"utf8")).providers;return!o||typeof o!="object"?new Set:new Set(Object.keys(o))}catch{return new Set}}function oe(){return{baseUrl:_,api:"openai-completions",headers:{[k]:T()}}}function se(n){let r=M(n,"models.json"),o;try{o=JSON.parse(b(r,"utf8"))}catch{return 0}let t=o.providers;if(!t||typeof t!="object")return 0;let s=0;for(let i of C){let e=t[i];if(!e||!Array.isArray(e.models))continue;let a=X(e.models),c={...e.headers??{},[k]:T()},u=e.headers?.[k]!==c[k];a.changed===0&&!u||(e.models=a.models,e.headers=c,s+=a.changed===0?1:a.changed)}if(s===0)return 0;try{y(r,`${JSON.stringify(o,null,2)}
2
2
  `)}catch{return 0}return s}var D=10080*60*1e3;async function j(n,r){let o=v(n),t=r?.now??Date.now(),s,i=0;try{let c=JSON.parse(b(o,"utf8"));typeof c?.entries=="string"&&(s=R(c.entries),i=Number(c.at)||0)}catch{s=void 0}if(s&&s.size>0&&t-i<D&&!r?.force)return{index:s};let a=await I({fetchImpl:r?.fetchImpl});if(!a.ok)return s&&s.size>0?{index:s,message:a.message}:{index:new Map,message:a.message};try{$(n,{recursive:!0}),y(o,`${JSON.stringify({at:t,entries:N(a.index)})}
3
3
  `)}catch{}return{index:a.index}}async function ie(n,r){let o=M(n,"models.json"),t;try{t=JSON.parse(b(o,"utf8"))}catch{return{changed:0}}let s=t.providers;if(!s||typeof s!="object")return{changed:0};let{index:i,message:e}=await j(n,r);if(i.size===0&&!r?.prices)return{changed:0,message:e};let a=0;for(let c of C){let u=s[c];if(!u||!Array.isArray(u.models))continue;let l=B(u.models,i,r?.prices);l.changed!==0&&(u.models=l.models,a+=l.changed)}if(a>0)try{y(o,`${JSON.stringify(t,null,2)}
4
4
  `)}catch{return{changed:0,message:"the models file could not be written"}}return{changed:a,message:e}}var z=3e5;function ae(n){let r=M(n,"settings.json"),o={};try{let t=b(r,"utf8"),s=JSON.parse(t);s&&typeof s=="object"&&!Array.isArray(s)&&(o=s)}catch{if(L(r))return!1}if("httpIdleTimeoutMs"in o)return!1;o.httpIdleTimeoutMs=z;try{$(n,{recursive:!0}),y(r,`${JSON.stringify(o,null,2)}
@@ -1,4 +1,4 @@
1
- var a="HowToFix",o="0.7.22",n=["You are HowToFix, a coding agent. The user wants the fix, not a tour of the problem.",'NEVER report a check you did not run. NEVER state a version, path, result or capability you have not verified \u2014 if you did not check it, say you are unsure. "Not found" is not "impossible": a tool missing from PATH is often installed anyway, and one that is truly absent can usually be installed. Exhaust the real options before calling anything unavailable; when you do report a limit, say plainly what you tried and what you could not do. Unexercised behaviour is not evidence.',"NEVER mention the underlying harness, its vendor or its project name to the user.","Every tool is `read`, `write` or `exec`, and each approval mode auto-approves every tier up to its own: `suggest` runs `read` only, `auto-edit` adds `write`, `full-auto` adds `exec`. A read-only shell command runs in every mode, so inspecting the tree asks nothing.","NEVER aim a command at the filesystem root, a block device or a system account file, and NEVER shut down the host: those are refused in EVERY mode, `full-auto` included, so proposing one wastes the turn. This is not a list of things to avoid \u2014 it is a list of things that will not run.","Lead with the diagnosis in one or two sentences, then change the code. SHOULD prefer the smallest correct change over a rewrite. Name the file and the reason in a short line; do not narrate tool calls.","Fix the problem that was asked for. NEVER add features, refactors, validation, error handling or dependencies nobody requested.","Something reported broken: reproduce it first, confirm the fix after. Cannot reproduce it? Say so \u2014 NEVER edit code and call it fixed.","Tests describe intended behaviour. A failing test means fix the code, not the test: NEVER delete, skip or loosen an assertion to get green, and NEVER re-pin an expected value to whatever the code happens to print.","Anything you cannot settle by reading \u2014 a page, a layout, a screenshot, a CLI, a service, a failure \u2014 run it and look at the result. For a visual task, find a browser the way a real one does: `$PUPPETEER_EXECUTABLE_PATH`, `$CHROME_PATH`, then `which` for google-chrome, chromium and chromium-browser, then /usr/bin, /snap/bin and /var/lib/flatpak, then the puppeteer and playwright caches under the home directory. Still empty? `npx -y puppeteer browsers install chrome`, or `npm i puppeteer-core` against a chrome the image already ships outside PATH. Then drive the real artifact \u2014 open it, read the DOM, click the controls, measure at the widths that matter \u2014 instead of describing what you assume it does.","Done means the requested behaviour works end to end and every stated requirement is met \u2014 not a scaffold, a narrowed test or a plausible subset. Genuinely out of reach? Finish everything else, then say exactly what is missing and what you tried.","SHOULD plan multi-step work with `todo` before starting it, and mark each step done as you finish. A plan the user can see is worth more than a narration of what you are about to do.","Genuinely ambiguous design: enter plan mode, write the plan to the plan file, then present it with `exit_plan_mode`. Use it when several reasonable approaches exist or when a restructuring would be hard to undo. In plan mode `edit` and `write` are refused for every path except the plan file itself \u2014 that limit is enforced, not advisory, so plan the work rather than starting it. Plan mode needs an interactive session in which the user can approve it; when there is no UI it is unavailable, so design the approach yourself instead of calling it.","Work that is independent and would flood this conversation belongs in `task` subagents. Give each a self-contained assignment, then verify the file it wrote rather than trusting its summary. When that work has a shape you can script \u2014 many items through the same stages, or fan-out whose results must be combined \u2014 `workflow` states the orchestration in one place and runs it deterministically; `task` is for the one-off you cannot describe in advance.","MUST give each subagent a self-contained assignment: a child starts with none of this conversation, so a brief that says 'the file we discussed' reaches it as nothing. Choose the agent by what the work is \u2014 scout looks something up, architect returns a plan, reviewer reports issues with file evidence, task changes files \u2014 and NEVER send work that needs an edit to scout or reviewer, because neither can make one.","SHOULD delegate only work that is genuinely parallel: a subagent costs its own session and its own requests on the same quota as this conversation. A single lookup, a file you can read yourself, or a step whose result decides the next step stays here. MUST keep one call to at most six agents and the session to twelve live or parked ones \u2014 a larger fan-out is refused, and the refusal is a limit rather than a failure to work around.","Record a decision, a file's role, or a fact you would otherwise re-derive with `context`: notes survive compaction and are visible to the other agents on the task.","Look it up instead of recalling it: `web_search` and `web_fetch` for anything outside this repo, `lsp` for a definition, reference or diagnostic. Name the source you checked.","Before calling changed code done, run `quality` and `slop` over it and act on what they report. A metric you did not measure is a claim you cannot make.","A command runs under a two-minute default timeout. MUST pass a longer timeout for anything that legitimately takes more than that \u2014 a recursive directory walk, a package install, a build, a network fetch \u2014 and SHOULD prefer a bounded command to an unbounded one: 'du -sh' with an explicit path beats the whole profile, and on Windows/MSYS a recursive 'du' over a profile directory takes minutes rather than seconds.","When a choice blocks the task, use `ask` instead of guessing; when you need to work something out, use `think`, whose text stays out of the transcript.","Above all: NEVER claim a check you did not run, and NEVER call done on a subset."].join(`
1
+ var a="HowToFix",o="0.7.24",n=["You are HowToFix, a coding agent. The user wants the fix, not a tour of the problem.",'NEVER report a check you did not run. NEVER state a version, path, result or capability you have not verified \u2014 if you did not check it, say you are unsure. "Not found" is not "impossible": a tool missing from PATH is often installed anyway, and one that is truly absent can usually be installed. Exhaust the real options before calling anything unavailable; when you do report a limit, say plainly what you tried and what you could not do. Unexercised behaviour is not evidence.',"NEVER mention the underlying harness, its vendor or its project name to the user.","Every tool is `read`, `write` or `exec`, and each approval mode auto-approves every tier up to its own: `suggest` runs `read` only, `auto-edit` adds `write`, `full-auto` adds `exec`. A read-only shell command runs in every mode, so inspecting the tree asks nothing.","NEVER aim a command at the filesystem root, a block device or a system account file, and NEVER shut down the host: those are refused in EVERY mode, `full-auto` included, so proposing one wastes the turn. This is not a list of things to avoid \u2014 it is a list of things that will not run.","Lead with the diagnosis in one or two sentences, then change the code. SHOULD prefer the smallest correct change over a rewrite. Name the file and the reason in a short line; do not narrate tool calls.","Fix the problem that was asked for. NEVER add features, refactors, validation, error handling or dependencies nobody requested.","Something reported broken: reproduce it first, confirm the fix after. Cannot reproduce it? Say so \u2014 NEVER edit code and call it fixed.","Tests describe intended behaviour. A failing test means fix the code, not the test: NEVER delete, skip or loosen an assertion to get green, and NEVER re-pin an expected value to whatever the code happens to print.","Anything you cannot settle by reading \u2014 a page, a layout, a screenshot, a CLI, a service, a failure \u2014 run it and look at the result. For a visual task, find a browser the way a real one does: `$PUPPETEER_EXECUTABLE_PATH`, `$CHROME_PATH`, then `which` for google-chrome, chromium and chromium-browser, then /usr/bin, /snap/bin and /var/lib/flatpak, then the puppeteer and playwright caches under the home directory. Still empty? `npx -y puppeteer browsers install chrome`, or `npm i puppeteer-core` against a chrome the image already ships outside PATH. Then drive the real artifact \u2014 open it, read the DOM, click the controls, measure at the widths that matter \u2014 instead of describing what you assume it does.","Done means the requested behaviour works end to end and every stated requirement is met \u2014 not a scaffold, a narrowed test or a plausible subset. Genuinely out of reach? Finish everything else, then say exactly what is missing and what you tried.","SHOULD plan multi-step work with `todo` before starting it, and mark each step done as you finish. A plan the user can see is worth more than a narration of what you are about to do.","Genuinely ambiguous design: enter plan mode, write the plan to the plan file, then present it with `exit_plan_mode`. Use it when several reasonable approaches exist or when a restructuring would be hard to undo. In plan mode `edit` and `write` are refused for every path except the plan file itself \u2014 that limit is enforced, not advisory, so plan the work rather than starting it. Plan mode needs an interactive session in which the user can approve it; when there is no UI it is unavailable, so design the approach yourself instead of calling it.","Work that is independent and would flood this conversation belongs in `task` subagents. Give each a self-contained assignment, then verify the file it wrote rather than trusting its summary. When that work has a shape you can script \u2014 many items through the same stages, or fan-out whose results must be combined \u2014 `workflow` states the orchestration in one place and runs it deterministically; `task` is for the one-off you cannot describe in advance.","MUST give each subagent a self-contained assignment: a child starts with none of this conversation, so a brief that says 'the file we discussed' reaches it as nothing. Choose the agent by what the work is \u2014 scout looks something up, architect returns a plan, reviewer reports issues with file evidence, task changes files \u2014 and NEVER send work that needs an edit to scout or reviewer, because neither can make one.","SHOULD delegate only work that is genuinely parallel: a subagent costs its own session and its own requests on the same quota as this conversation. A single lookup, a file you can read yourself, or a step whose result decides the next step stays here. MUST keep one call to at most six agents and the session to twelve live or parked ones \u2014 a larger fan-out is refused, and the refusal is a limit rather than a failure to work around.","Record a decision, a file's role, or a fact you would otherwise re-derive with `context`: notes survive compaction and are visible to the other agents on the task.","Look it up instead of recalling it: `web_search` and `web_fetch` for anything outside this repo, `lsp` for a definition, reference or diagnostic. Name the source you checked.","Before calling changed code done, run `quality` and `slop` over it and act on what they report. A metric you did not measure is a claim you cannot make.","A command runs under a two-minute default timeout. MUST pass a longer timeout for anything that legitimately takes more than that \u2014 a recursive directory walk, a package install, a build, a network fetch \u2014 and SHOULD prefer a bounded command to an unbounded one: 'du -sh' with an explicit path beats the whole profile, and on Windows/MSYS a recursive 'du' over a profile directory takes minutes rather than seconds.","When a choice blocks the task, use `ask` instead of guessing; when you need to work something out, use `think`, whose text stays out of the transcript.","Above all: NEVER claim a check you did not run, and NEVER call done on a subset."].join(`
2
2
  `);function s(e){return e===void 0?void 0:e.replace(/Use \/login to log into a provider[^\n]*/gi,"Connect a provider with /connect or /login:").replace(/^[ \t]*\S*hxf-coding-agent[\\/]docs[\\/][^\n]*$/gim,"").replace(/\bhxf-coding-agent\b/gi,"the harness").replace(/\n{3,}/g,`
3
3
 
4
4
  `).trim()}var i=["# Project notes","","## What this is","","## Commands","- build:","- test:","","## Conventions","-",""].join(`
@@ -1,2 +1,2 @@
1
- import{a as x}from"./chunk-UTYFLLSM.js";import{g as P,j as M}from"./chunk-C52X7EKC.js";import{existsSync as z,readFileSync as ye}from"node:fs";import{join as xe}from"node:path";import{createHash as J,randomBytes as G}from"node:crypto";import{createServer as ne}from"node:http";import{execFileSync as X}from"node:child_process";import{createHmac as Q}from"node:crypto";import{readFileSync as ee}from"node:fs";import{arch as N,cpus as $,hostname as O,platform as _,userInfo as H}from"node:os";var te="howtofix-cli-hwid-v1";function v(e){try{let t=ee(e,"utf8").trim();return t.length>0?t:void 0}catch{return}}function F(e,t){try{let r=X(e,t,{encoding:"utf8",timeout:3e3,stdio:["ignore","pipe","ignore"]});return r.trim().length>0?r.trim():void 0}catch{return}}function re(){let e=_();if(e==="linux"){let t=v("/etc/machine-id");if(t)return{value:t,source:"machine-id",strong:!0};let r=v("/var/lib/dbus/machine-id");if(r)return{value:r,source:"dbus-machine-id",strong:!0};let s=v("/sys/class/dmi/id/product_uuid");return s?{value:s,source:"dmi-product-uuid",strong:!0}:void 0}if(e==="win32"){let r=F("reg",["query","HKLM\\SOFTWARE\\Microsoft\\Cryptography","/v","MachineGuid"])?.match(/MachineGuid\s+REG_SZ\s+(\S+)/i);return r?.[1]?{value:r[1],source:"windows-machine-guid",strong:!0}:void 0}if(e==="darwin"){let r=F("ioreg",["-rd1","-c","IOPlatformExpertDevice"])?.match(/"IOPlatformUUID"\s*=\s*"([^"]+)"/);return r?.[1]?{value:r[1],source:"platform-uuid",strong:!0}:void 0}}function U(){let e=re(),t=e?.value??[O(),_(),N(),H().username].join("\0"),r=e?.source??"hostname";return{id:Q("sha256",te).update(t).digest("hex").slice(0,32),source:r,strong:e?.strong??!1}}function j(e){return[e.id,e.source,O(),_(),N(),H().username,String($().length),$()[0]?.model??""]}var I="https://howtofix.id",se=300*1e3,L=3e3,K="/callback";function A(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function oe(){return A(G(32))}function ie(e){return A(J("sha256").update(e).digest())}function ae(){return A(G(16))}var ce="howtofix-cli-",ue="x-howtofix-client",le="cli";function C(e){let t=e??j(U());return ce+J("sha256").update(t.join("\0")).digest("hex").slice(0,32)}function de(){return{"content-type":"application/json",[ue]:le}}var fe=()=>new Promise((e,t)=>{let r=ne();r.once("error",t),r.listen(0,"127.0.0.1",()=>{let{port:s}=r.address();e({port:s,close:()=>r.close(),waitForCode:(o,n)=>new Promise((i,a)=>{let c=(l,m)=>{let h=new URL(l.url??"/","http://127.0.0.1");if(h.pathname!==K){m.writeHead(404).end("not found");return}let y=(V,Z)=>m.writeHead(200,{"content-type":"text/html; charset=utf-8"}).end(`<!doctype html><meta charset="utf-8"><h2>${V}</h2><p>${Z}</p>`),T=h.searchParams.get("error")??"",R=h.searchParams.get("code")??"",Y=h.searchParams.get("state")??"";if(T){y("Sign-in was refused","You can close this tab."),u(new Error(`the browser reported: ${T}`));return}if(!R||Y!==o){y("This callback did not belong to the login","You can close this tab."),u(new Error("the callback carried the wrong state"));return}y("Signed in","You can close this tab and go back to HowToFix."),u(void 0,R)},u=(l,m)=>{r.off("request",c),n?.removeEventListener("abort",f),l?a(l):i(m)},f=()=>u(new Error("cancelled"));n?.addEventListener("abort",f,{once:!0}),r.on("request",c)})})})});function k(e,t){e.onProgress?.(t)}async function g(e,t,r,s){let o=await e(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(r),signal:s}),n={};try{n=await o.json()}catch{}let i=Number(o.headers?.get?.("retry-after"));return{status:o.status,body:n,retryAfterSeconds:Number.isFinite(i)&&i>0?i:void 0}}function d(...e){for(let t of e)if(typeof t=="string"&&t.trim()!=="")return t.trim()}function D(...e){for(let t of e)if(typeof t=="number"&&Number.isFinite(t))return t;return 0}function me(e){try{let t=new URL(e).searchParams.get("code");return t&&t.trim()!==""?t.trim():void 0}catch{return}}async function pe(e,t,r){let s=await e(t,{headers:de(),signal:r}),o={};try{o=await s.json()}catch{}let n=Number(s.headers?.get?.("retry-after"));return{status:s.status,body:o,retryAfterSeconds:Number.isFinite(n)&&n>0?n:void 0}}function S(e){let t=e.data,r=[e.token,e.api_key,e.apiKey,e.key,t?.token,t?.api_key,t?.apiKey,t?.key];for(let s of r)if(typeof s=="string"&&s.trim().startsWith("sk-"))return s.trim()}function ge(e){let t=e.data,r=d(e.token,t?.token),s=d(e.refresh_token,t?.refresh_token),o=d(e.device_id,t?.device_id);if(!r||!s||!o)return;let n=D(e.access_expires_at,t?.access_expires_at),i=D(e.refresh_expires_at,t?.refresh_expires_at);return{accessToken:r,accessExpiresAt:n,refreshToken:s,deviceId:o,refreshExpiresAt:i}}function p(e,t){let r=e.message??e.error;return typeof r=="string"&&r.trim()?r.trim():t}async function Oe(e){let t=e.fetchImpl??fetch,r=(e.panelUrl??I).replace(/\/+$/,""),s=e.timeoutMs??se,o={...e,panel:r,fetchImpl:t,timeoutMs:s},n=await ke(o);if(n.ok||n.terminal)return n.result;let i=await he(o);if(i.ok||i.terminal)return i.result;let a=await we(o);return a.ok?a:{ok:!1,message:`${n.result.ok?"":n.result.message}; ${i.result.ok?"":i.result.message}; ${a.message}. howtofix.id does not offer a browser login a local client can complete yet \u2014 run /connect and paste a token from ${r}/keys instead.`}}async function he(e){let t=oe(),r=ae(),s;try{s=await(e.loopback??fe)();let o=`http://127.0.0.1:${s.port}${K}`,n=await g(e.fetchImpl,`${e.panel}/api/oauth/device/start`,{redirect_uri:o,code_challenge:ie(t),code_challenge_method:"S256",state:r},e.signal);if(n.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no loopback login endpoint"}};if(n.status>=400)return{ok:!1,terminal:!1,result:{ok:!1,message:p(n.body,`the panel refused the login (${n.status})`)}};let i=typeof n.body.authorize_url=="string"?n.body.authorize_url:"";if(!i)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not say where to send the browser"}};k(e,{kind:"browser",url:i});let a=await be(s.waitForCode(r,e.signal),e.timeoutMs),c=await g(e.fetchImpl,`${e.panel}/api/oauth/device/token`,{flow_token:n.body.flow_token,code:a,code_verifier:t},e.signal);if(c.status>=400)return{ok:!1,terminal:!0,result:{ok:!1,message:p(c.body,`the panel refused the exchange (${c.status})`)}};let u=S(c.body);return u?{ok:!0,result:{ok:!0,token:u}}:{ok:!1,terminal:!0,result:{ok:!1,message:"the panel did not return an API key"}}}catch(o){let n=o instanceof Error?o.message:String(o);return{ok:!1,terminal:n==="cancelled",result:{ok:!1,message:n}}}finally{s?.close()}}async function ke(e){let t=e.pollIntervalMs??L,r=e.fingerprintId??C(),s=e.clientInfo??P(),o=M(r,s);try{let n=await g(e.fetchImpl,`${e.panel}/api/auth/cli/code`,{fingerprintId:r,clientInfo:s,...o},e.signal);if(n.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no CLI login endpoint"}};if(n.status===401)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not recognise this build as the HowToFix CLI \u2014 update it with `npm install -g howtofixcli@latest`"}};if(n.status===429)return{ok:!1,terminal:!0,result:{ok:!1,message:`too many sign-in attempts from this machine right now.${n.retryAfterSeconds?` Try again in ${Math.ceil(n.retryAfterSeconds/60)} minute(s).`:""}`}};if(n.status>=400)return{ok:!1,terminal:!1,result:{ok:!1,message:p(n.body,`the panel refused the login (${n.status})`)}};let i=n.body.data??{},a=d(n.body.login_url,i.login_url),c=d(n.body.code,i.code)??(a?me(a):void 0),u=d(n.body.secret,i.secret);return!a||!c?{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not return a login URL"}}:u?(k(e,{kind:"browser",url:a}),await q(e,c,u)):(k(e,{kind:"browser",url:a}),await q(e,c,void 0))}catch(n){let i=n instanceof Error?n.message:String(n);return{ok:!1,terminal:i==="cancelled",result:{ok:!1,message:i}}}}async function q(e,t,r){let s=e.pollIntervalMs??L,o=Date.now()+e.timeoutMs;for(;Date.now()<o;){await w(s,e.signal);let n=new URLSearchParams(r?{code:t,secret:r}:{code:t});n.set("capability","device-refresh");let i=await pe(e.fetchImpl,`${e.panel}/api/auth/cli/status?${n}`,e.signal);if(i.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no CLI login status endpoint"}};if(i.status===403)return{ok:!1,terminal:!0,result:{ok:!1,message:"the panel rejected this poll \u2014 run /connect again"}};if(i.status===429){let u=Math.min(Math.max(i.retryAfterSeconds??5,1)*1e3,3e4);await w(u,e.signal);continue}let a=S(i.body);if(a)return{ok:!0,result:{ok:!0,token:a,credential:ge(i.body)}};if(d(i.body.data?.status,i.body.status)==="expired")return{ok:!1,terminal:!0,result:{ok:!1,message:"the sign-in link expired before it was approved"}};if(i.status>=400)return{ok:!1,terminal:!0,result:{ok:!1,message:p(i.body,`the panel refused the poll (${i.status})`)}}}return{ok:!1,terminal:!0,result:{ok:!1,message:"the sign-in was not approved in time"}}}async function we(e){let t=e.pollIntervalMs??L;try{let r=await g(e.fetchImpl,`${e.panel}/api/oauth/device`,{},e.signal);if(r.status===404)return{ok:!1,message:"the panel has no device-code endpoint"};if(r.status>=400)return{ok:!1,message:p(r.body,`the panel refused the request (${r.status})`)};let s=typeof r.body.device_code=="string"?r.body.device_code:"",o=typeof r.body.user_code=="string"?r.body.user_code:"",n=typeof r.body.verification_uri=="string"?r.body.verification_uri:`${e.panel}/oauth/device`;if(!s||!o)return{ok:!1,message:"the panel did not return a code to show"};k(e,{kind:"code",code:o,url:n});let i=Date.now()+e.timeoutMs;for(;Date.now()<i;){await w(t,e.signal);let a=await g(e.fetchImpl,`${e.panel}/api/oauth/device/poll`,{device_code:s},e.signal);if(a.status===404)return{ok:!1,message:"the panel has no device-code poll endpoint"};let c=typeof a.body.status=="string"?a.body.status:"";if(c==="pending")continue;if(c==="slow_down"){await w(t,e.signal);continue}if(c==="denied")return{ok:!1,message:"the sign-in was refused in the browser"};if(c==="expired")return{ok:!1,message:"the code expired; run /connect again"};let u=S(a.body);if(u)return{ok:!0,token:u};if(a.status>=400)return{ok:!1,message:p(a.body,`the panel refused the poll (${a.status})`)}}return{ok:!1,message:"the code was not approved in time"}}catch(r){return{ok:!1,message:r instanceof Error?r.message:String(r)}}}function be(e,t){return new Promise((r,s)=>{let o=setTimeout(()=>s(new Error("the sign-in was not finished in time")),t);e.then(n=>{clearTimeout(o),r(n)},n=>{clearTimeout(o),s(n)})})}function w(e,t){return new Promise((r,s)=>{let o=setTimeout(r,e);t?.addEventListener("abort",()=>{clearTimeout(o),s(new Error("cancelled"))},{once:!0})})}function b(e){return xe(e,"cli-credentials.json")}var ve=300*1e3;function _e(e,t=Date.now()){return e.accessToken?!Number.isFinite(e.accessExpiresAt)||e.accessExpiresAt<=0?!0:e.accessExpiresAt*1e3-ve>t:!1}function Ie(e,t=Date.now()){return!e.refreshToken||!e.deviceId?!1:!Number.isFinite(e.refreshExpiresAt)||e.refreshExpiresAt<=0?!0:e.refreshExpiresAt*1e3>t}function Je(e){let t=b(e);if(!z(t))return;let r;try{r=JSON.parse(ye(t,"utf8"))}catch{return}if(!r||typeof r!="object"||Array.isArray(r))return;let s=r,o=typeof s.accessToken=="string"?s.accessToken.trim():"",n=typeof s.refreshToken=="string"?s.refreshToken.trim():"",i=typeof s.deviceId=="string"?s.deviceId.trim():"";if(!(!o||!n||!i))return{accessToken:o,accessExpiresAt:W(s.accessExpiresAt),refreshToken:n,deviceId:i,refreshExpiresAt:W(s.refreshExpiresAt)}}function Le(e,t){try{return x(b(e),`${JSON.stringify(t,null,2)}
1
+ import{a as x}from"./chunk-UTYFLLSM.js";import{g as P,j as M}from"./chunk-C5E3SFOQ.js";import{existsSync as z,readFileSync as ye}from"node:fs";import{join as xe}from"node:path";import{createHash as J,randomBytes as G}from"node:crypto";import{createServer as ne}from"node:http";import{execFileSync as X}from"node:child_process";import{createHmac as Q}from"node:crypto";import{readFileSync as ee}from"node:fs";import{arch as N,cpus as $,hostname as O,platform as _,userInfo as H}from"node:os";var te="howtofix-cli-hwid-v1";function v(e){try{let t=ee(e,"utf8").trim();return t.length>0?t:void 0}catch{return}}function F(e,t){try{let r=X(e,t,{encoding:"utf8",timeout:3e3,stdio:["ignore","pipe","ignore"]});return r.trim().length>0?r.trim():void 0}catch{return}}function re(){let e=_();if(e==="linux"){let t=v("/etc/machine-id");if(t)return{value:t,source:"machine-id",strong:!0};let r=v("/var/lib/dbus/machine-id");if(r)return{value:r,source:"dbus-machine-id",strong:!0};let s=v("/sys/class/dmi/id/product_uuid");return s?{value:s,source:"dmi-product-uuid",strong:!0}:void 0}if(e==="win32"){let r=F("reg",["query","HKLM\\SOFTWARE\\Microsoft\\Cryptography","/v","MachineGuid"])?.match(/MachineGuid\s+REG_SZ\s+(\S+)/i);return r?.[1]?{value:r[1],source:"windows-machine-guid",strong:!0}:void 0}if(e==="darwin"){let r=F("ioreg",["-rd1","-c","IOPlatformExpertDevice"])?.match(/"IOPlatformUUID"\s*=\s*"([^"]+)"/);return r?.[1]?{value:r[1],source:"platform-uuid",strong:!0}:void 0}}function U(){let e=re(),t=e?.value??[O(),_(),N(),H().username].join("\0"),r=e?.source??"hostname";return{id:Q("sha256",te).update(t).digest("hex").slice(0,32),source:r,strong:e?.strong??!1}}function j(e){return[e.id,e.source,O(),_(),N(),H().username,String($().length),$()[0]?.model??""]}var I="https://howtofix.id",se=300*1e3,L=3e3,K="/callback";function A(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function oe(){return A(G(32))}function ie(e){return A(J("sha256").update(e).digest())}function ae(){return A(G(16))}var ce="howtofix-cli-",ue="x-howtofix-client",le="cli";function C(e){let t=e??j(U());return ce+J("sha256").update(t.join("\0")).digest("hex").slice(0,32)}function de(){return{"content-type":"application/json",[ue]:le}}var fe=()=>new Promise((e,t)=>{let r=ne();r.once("error",t),r.listen(0,"127.0.0.1",()=>{let{port:s}=r.address();e({port:s,close:()=>r.close(),waitForCode:(o,n)=>new Promise((i,a)=>{let c=(l,m)=>{let h=new URL(l.url??"/","http://127.0.0.1");if(h.pathname!==K){m.writeHead(404).end("not found");return}let y=(V,Z)=>m.writeHead(200,{"content-type":"text/html; charset=utf-8"}).end(`<!doctype html><meta charset="utf-8"><h2>${V}</h2><p>${Z}</p>`),T=h.searchParams.get("error")??"",R=h.searchParams.get("code")??"",Y=h.searchParams.get("state")??"";if(T){y("Sign-in was refused","You can close this tab."),u(new Error(`the browser reported: ${T}`));return}if(!R||Y!==o){y("This callback did not belong to the login","You can close this tab."),u(new Error("the callback carried the wrong state"));return}y("Signed in","You can close this tab and go back to HowToFix."),u(void 0,R)},u=(l,m)=>{r.off("request",c),n?.removeEventListener("abort",f),l?a(l):i(m)},f=()=>u(new Error("cancelled"));n?.addEventListener("abort",f,{once:!0}),r.on("request",c)})})})});function k(e,t){e.onProgress?.(t)}async function g(e,t,r,s){let o=await e(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(r),signal:s}),n={};try{n=await o.json()}catch{}let i=Number(o.headers?.get?.("retry-after"));return{status:o.status,body:n,retryAfterSeconds:Number.isFinite(i)&&i>0?i:void 0}}function d(...e){for(let t of e)if(typeof t=="string"&&t.trim()!=="")return t.trim()}function D(...e){for(let t of e)if(typeof t=="number"&&Number.isFinite(t))return t;return 0}function me(e){try{let t=new URL(e).searchParams.get("code");return t&&t.trim()!==""?t.trim():void 0}catch{return}}async function pe(e,t,r){let s=await e(t,{headers:de(),signal:r}),o={};try{o=await s.json()}catch{}let n=Number(s.headers?.get?.("retry-after"));return{status:s.status,body:o,retryAfterSeconds:Number.isFinite(n)&&n>0?n:void 0}}function S(e){let t=e.data,r=[e.token,e.api_key,e.apiKey,e.key,t?.token,t?.api_key,t?.apiKey,t?.key];for(let s of r)if(typeof s=="string"&&s.trim().startsWith("sk-"))return s.trim()}function ge(e){let t=e.data,r=d(e.token,t?.token),s=d(e.refresh_token,t?.refresh_token),o=d(e.device_id,t?.device_id);if(!r||!s||!o)return;let n=D(e.access_expires_at,t?.access_expires_at),i=D(e.refresh_expires_at,t?.refresh_expires_at);return{accessToken:r,accessExpiresAt:n,refreshToken:s,deviceId:o,refreshExpiresAt:i}}function p(e,t){let r=e.message??e.error;return typeof r=="string"&&r.trim()?r.trim():t}async function Oe(e){let t=e.fetchImpl??fetch,r=(e.panelUrl??I).replace(/\/+$/,""),s=e.timeoutMs??se,o={...e,panel:r,fetchImpl:t,timeoutMs:s},n=await ke(o);if(n.ok||n.terminal)return n.result;let i=await he(o);if(i.ok||i.terminal)return i.result;let a=await we(o);return a.ok?a:{ok:!1,message:`${n.result.ok?"":n.result.message}; ${i.result.ok?"":i.result.message}; ${a.message}. howtofix.id does not offer a browser login a local client can complete yet \u2014 run /connect and paste a token from ${r}/keys instead.`}}async function he(e){let t=oe(),r=ae(),s;try{s=await(e.loopback??fe)();let o=`http://127.0.0.1:${s.port}${K}`,n=await g(e.fetchImpl,`${e.panel}/api/oauth/device/start`,{redirect_uri:o,code_challenge:ie(t),code_challenge_method:"S256",state:r},e.signal);if(n.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no loopback login endpoint"}};if(n.status>=400)return{ok:!1,terminal:!1,result:{ok:!1,message:p(n.body,`the panel refused the login (${n.status})`)}};let i=typeof n.body.authorize_url=="string"?n.body.authorize_url:"";if(!i)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not say where to send the browser"}};k(e,{kind:"browser",url:i});let a=await be(s.waitForCode(r,e.signal),e.timeoutMs),c=await g(e.fetchImpl,`${e.panel}/api/oauth/device/token`,{flow_token:n.body.flow_token,code:a,code_verifier:t},e.signal);if(c.status>=400)return{ok:!1,terminal:!0,result:{ok:!1,message:p(c.body,`the panel refused the exchange (${c.status})`)}};let u=S(c.body);return u?{ok:!0,result:{ok:!0,token:u}}:{ok:!1,terminal:!0,result:{ok:!1,message:"the panel did not return an API key"}}}catch(o){let n=o instanceof Error?o.message:String(o);return{ok:!1,terminal:n==="cancelled",result:{ok:!1,message:n}}}finally{s?.close()}}async function ke(e){let t=e.pollIntervalMs??L,r=e.fingerprintId??C(),s=e.clientInfo??P(),o=M(r,s);try{let n=await g(e.fetchImpl,`${e.panel}/api/auth/cli/code`,{fingerprintId:r,clientInfo:s,...o},e.signal);if(n.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no CLI login endpoint"}};if(n.status===401)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not recognise this build as the HowToFix CLI \u2014 update it with `npm install -g howtofixcli@latest`"}};if(n.status===429)return{ok:!1,terminal:!0,result:{ok:!1,message:`too many sign-in attempts from this machine right now.${n.retryAfterSeconds?` Try again in ${Math.ceil(n.retryAfterSeconds/60)} minute(s).`:""}`}};if(n.status>=400)return{ok:!1,terminal:!1,result:{ok:!1,message:p(n.body,`the panel refused the login (${n.status})`)}};let i=n.body.data??{},a=d(n.body.login_url,i.login_url),c=d(n.body.code,i.code)??(a?me(a):void 0),u=d(n.body.secret,i.secret);return!a||!c?{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not return a login URL"}}:u?(k(e,{kind:"browser",url:a}),await q(e,c,u)):(k(e,{kind:"browser",url:a}),await q(e,c,void 0))}catch(n){let i=n instanceof Error?n.message:String(n);return{ok:!1,terminal:i==="cancelled",result:{ok:!1,message:i}}}}async function q(e,t,r){let s=e.pollIntervalMs??L,o=Date.now()+e.timeoutMs;for(;Date.now()<o;){await w(s,e.signal);let n=new URLSearchParams(r?{code:t,secret:r}:{code:t});n.set("capability","device-refresh");let i=await pe(e.fetchImpl,`${e.panel}/api/auth/cli/status?${n}`,e.signal);if(i.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no CLI login status endpoint"}};if(i.status===403)return{ok:!1,terminal:!0,result:{ok:!1,message:"the panel rejected this poll \u2014 run /connect again"}};if(i.status===429){let u=Math.min(Math.max(i.retryAfterSeconds??5,1)*1e3,3e4);await w(u,e.signal);continue}let a=S(i.body);if(a)return{ok:!0,result:{ok:!0,token:a,credential:ge(i.body)}};if(d(i.body.data?.status,i.body.status)==="expired")return{ok:!1,terminal:!0,result:{ok:!1,message:"the sign-in link expired before it was approved"}};if(i.status>=400)return{ok:!1,terminal:!0,result:{ok:!1,message:p(i.body,`the panel refused the poll (${i.status})`)}}}return{ok:!1,terminal:!0,result:{ok:!1,message:"the sign-in was not approved in time"}}}async function we(e){let t=e.pollIntervalMs??L;try{let r=await g(e.fetchImpl,`${e.panel}/api/oauth/device`,{},e.signal);if(r.status===404)return{ok:!1,message:"the panel has no device-code endpoint"};if(r.status>=400)return{ok:!1,message:p(r.body,`the panel refused the request (${r.status})`)};let s=typeof r.body.device_code=="string"?r.body.device_code:"",o=typeof r.body.user_code=="string"?r.body.user_code:"",n=typeof r.body.verification_uri=="string"?r.body.verification_uri:`${e.panel}/oauth/device`;if(!s||!o)return{ok:!1,message:"the panel did not return a code to show"};k(e,{kind:"code",code:o,url:n});let i=Date.now()+e.timeoutMs;for(;Date.now()<i;){await w(t,e.signal);let a=await g(e.fetchImpl,`${e.panel}/api/oauth/device/poll`,{device_code:s},e.signal);if(a.status===404)return{ok:!1,message:"the panel has no device-code poll endpoint"};let c=typeof a.body.status=="string"?a.body.status:"";if(c==="pending")continue;if(c==="slow_down"){await w(t,e.signal);continue}if(c==="denied")return{ok:!1,message:"the sign-in was refused in the browser"};if(c==="expired")return{ok:!1,message:"the code expired; run /connect again"};let u=S(a.body);if(u)return{ok:!0,token:u};if(a.status>=400)return{ok:!1,message:p(a.body,`the panel refused the poll (${a.status})`)}}return{ok:!1,message:"the code was not approved in time"}}catch(r){return{ok:!1,message:r instanceof Error?r.message:String(r)}}}function be(e,t){return new Promise((r,s)=>{let o=setTimeout(()=>s(new Error("the sign-in was not finished in time")),t);e.then(n=>{clearTimeout(o),r(n)},n=>{clearTimeout(o),s(n)})})}function w(e,t){return new Promise((r,s)=>{let o=setTimeout(r,e);t?.addEventListener("abort",()=>{clearTimeout(o),s(new Error("cancelled"))},{once:!0})})}function b(e){return xe(e,"cli-credentials.json")}var ve=300*1e3;function _e(e,t=Date.now()){return e.accessToken?!Number.isFinite(e.accessExpiresAt)||e.accessExpiresAt<=0?!0:e.accessExpiresAt*1e3-ve>t:!1}function Ie(e,t=Date.now()){return!e.refreshToken||!e.deviceId?!1:!Number.isFinite(e.refreshExpiresAt)||e.refreshExpiresAt<=0?!0:e.refreshExpiresAt*1e3>t}function Je(e){let t=b(e);if(!z(t))return;let r;try{r=JSON.parse(ye(t,"utf8"))}catch{return}if(!r||typeof r!="object"||Array.isArray(r))return;let s=r,o=typeof s.accessToken=="string"?s.accessToken.trim():"",n=typeof s.refreshToken=="string"?s.refreshToken.trim():"",i=typeof s.deviceId=="string"?s.deviceId.trim():"";if(!(!o||!n||!i))return{accessToken:o,accessExpiresAt:W(s.accessExpiresAt),refreshToken:n,deviceId:i,refreshExpiresAt:W(s.refreshExpiresAt)}}function Le(e,t){try{return x(b(e),`${JSON.stringify(t,null,2)}
2
2
  `,{mode:384}),!0}catch{return!1}}function Ae(e){try{let t=b(e);z(t)&&x(t,"",{mode:384})}catch{}}function W(e){return typeof e=="number"&&Number.isFinite(e)?e:0}async function Ce(e,t){let r=(t?.panelUrl??I).replace(/\/+$/,""),s=t?.fetchImpl??fetch,o=t?.timeoutMs??15e3,n=new AbortController,i=setTimeout(()=>n.abort(),o);try{let a=await s(`${r}/api/auth/cli/refresh`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({device_id:e.deviceId,refresh_token:e.refreshToken,fingerprint_id:C()}),signal:n.signal}),c=await a.json().catch(()=>({}));if(a.status===401||a.status===403)return{ok:!1,terminal:!0,message:"this sign-in is no longer valid \u2014 run /connect to sign in again"};if(!a.ok)return{ok:!1,terminal:!1,message:`the panel refused the renewal (${a.status})`};let u=c.data??{},f=E(c.token,u.token),l=E(c.refresh_token,u.refresh_token),m=E(c.device_id,u.device_id)??e.deviceId;return!f||!l?{ok:!1,terminal:!1,message:"the panel did not return a renewed credential"}:{ok:!0,terminal:!1,credential:{accessToken:f,accessExpiresAt:B(c.access_expires_at,u.access_expires_at),refreshToken:l,deviceId:m,refreshExpiresAt:B(c.refresh_expires_at,u.refresh_expires_at)}}}catch(a){return{ok:!1,terminal:!1,message:a instanceof Error&&a.name==="AbortError"?`the panel did not answer within ${Math.round(o/1e3)}s`:"could not reach the panel"}}finally{clearTimeout(i)}}function E(...e){for(let t of e)if(typeof t=="string"&&t.trim())return t.trim()}function B(...e){for(let t of e)if(typeof t=="number"&&Number.isFinite(t))return t;return 0}async function Ge(e,t,r){let s=r?.now??Date.now();if(_e(t,s)||!Ie(t,s))return{credential:t,renewed:!1,terminal:!1};let o=await Ce(t,r);if(!o.ok||!o.credential)return o.terminal&&Ae(e),{credential:t,renewed:!1,terminal:o.terminal,message:o.message};let n=Le(e,o.credential);return{credential:o.credential,renewed:!0,terminal:!1,message:n?void 0:`the renewed sign-in could not be saved to ${b(e)}`}}export{U as a,I as b,Oe as c,b as d,ve as e,_e as f,Ie as g,Je as h,Le as i,Ae as j,Ce as k,Ge as l};
@@ -1,4 +1,4 @@
1
- import{b as k}from"./chunk-AGGIYXN7.js";import{D as p}from"./chunk-V656XVXV.js";import{a as E}from"./chunk-PCALBZOO.js";import"./chunk-UTYFLLSM.js";import{a as g}from"./chunk-MWUEV7YF.js";import"./chunk-WOT6VMZA.js";import{spawnSync as A}from"node:child_process";import{readdirSync as j,readFileSync as S,statSync as D,writeFileSync as C,unlinkSync as v}from"node:fs";import{join as m}from"node:path";var x=[22,19];async function J(e="https://api.howtofix.id/api/status"){let s=[],[n,t]=process.versions.node.split(".").map(Number),r=n>x[0]||n===x[0]&&t>=x[1];s.push({name:"node",ok:r,detail:`${process.versions.node} (needs >= ${x[0]}.${x[1]})`});let a=A("git",["--version"],{encoding:"utf8"});s.push({name:"git",ok:a.status===0,detail:a.status===0?a.stdout.trim():"not found on PATH"});let o=E();s.push({name:"sandbox",ok:!!o,detail:o??"no working bubblewrap (Linux) or sandbox-exec (macOS); --sandbox unavailable",optional:!0});let c=!1,i=p;try{let l=m(p,`.doctor-${process.pid}`);C(l,"ok"),v(l),c=!0}catch(l){i=`${p} is not writable: ${l instanceof Error?l.message:String(l)}`}s.push({name:"state dir",ok:c,detail:i});let u=m(p,"auth.json"),f="no auth.json \u2014 run `howtofix` and sign in",h=!1;try{let l=JSON.parse(S(u,"utf8")),d=Object.keys(l).length;h=d>0,f=h?`${d} provider credential${d===1?"":"s"}`:f}catch{}s.push({name:"auth",ok:h,detail:f,optional:!0});try{let l=Date.now(),d=await fetch(e,{signal:AbortSignal.timeout(5e3)});s.push({name:"gateway",ok:d.ok,detail:`${e} \u2192 ${d.status} in ${Date.now()-l}ms`,optional:!0})}catch(l){s.push({name:"gateway",ok:!1,detail:`${e} unreachable: ${l instanceof Error?l.message:String(l)}`,optional:!0})}return s}async function Z(){let e=await J(),s=Math.max(...e.map(t=>t.name.length));for(let t of e){let r=t.ok?"ok ":t.optional?"warn":"FAIL";console.log(` ${r} ${t.name.padEnd(s)} ${t.detail}`)}let n=e.filter(t=>!t.ok&&!t.optional);return n.length>0?(console.log(`
1
+ import{b as k}from"./chunk-AGGIYXN7.js";import{D as p}from"./chunk-V656XVXV.js";import{a as E}from"./chunk-PCALBZOO.js";import"./chunk-UTYFLLSM.js";import{a as g}from"./chunk-N3J2J7EQ.js";import"./chunk-WOT6VMZA.js";import{spawnSync as A}from"node:child_process";import{readdirSync as j,readFileSync as S,statSync as D,writeFileSync as C,unlinkSync as v}from"node:fs";import{join as m}from"node:path";var x=[22,19];async function J(e="https://api.howtofix.id/api/status"){let s=[],[n,t]=process.versions.node.split(".").map(Number),r=n>x[0]||n===x[0]&&t>=x[1];s.push({name:"node",ok:r,detail:`${process.versions.node} (needs >= ${x[0]}.${x[1]})`});let a=A("git",["--version"],{encoding:"utf8"});s.push({name:"git",ok:a.status===0,detail:a.status===0?a.stdout.trim():"not found on PATH"});let o=E();s.push({name:"sandbox",ok:!!o,detail:o??"no working bubblewrap (Linux) or sandbox-exec (macOS); --sandbox unavailable",optional:!0});let c=!1,i=p;try{let l=m(p,`.doctor-${process.pid}`);C(l,"ok"),v(l),c=!0}catch(l){i=`${p} is not writable: ${l instanceof Error?l.message:String(l)}`}s.push({name:"state dir",ok:c,detail:i});let u=m(p,"auth.json"),f="no auth.json \u2014 run `howtofix` and sign in",h=!1;try{let l=JSON.parse(S(u,"utf8")),d=Object.keys(l).length;h=d>0,f=h?`${d} provider credential${d===1?"":"s"}`:f}catch{}s.push({name:"auth",ok:h,detail:f,optional:!0});try{let l=Date.now(),d=await fetch(e,{signal:AbortSignal.timeout(5e3)});s.push({name:"gateway",ok:d.ok,detail:`${e} \u2192 ${d.status} in ${Date.now()-l}ms`,optional:!0})}catch(l){s.push({name:"gateway",ok:!1,detail:`${e} unreachable: ${l instanceof Error?l.message:String(l)}`,optional:!0})}return s}async function Z(){let e=await J(),s=Math.max(...e.map(t=>t.name.length));for(let t of e){let r=t.ok?"ok ":t.optional?"warn":"FAIL";console.log(` ${r} ${t.name.padEnd(s)} ${t.detail}`)}let n=e.filter(t=>!t.ok&&!t.optional);return n.length>0?(console.log(`
2
2
  ${n.length} problem${n.length===1?"":"s"} must be fixed before a session will work.`),1):0}function K(e=p){let s=m(e,"models.json"),n;try{n=S(s,"utf8")}catch(o){return o.code==="ENOENT"?console.log(` no models.json at ${s} \u2014 run \`howtofix /connect\` to pull the catalogue`):k(g,"models",o),1}let t;try{t=JSON.parse(n)}catch(o){return console.error(`${g}: models: ${s} is not valid JSON (${o instanceof Error?o.message:String(o)})`),console.error(" fix the file, or delete it and run `howtofix /connect` to write a new one"),1}let r=t.providers??{},a=0;for(let[o,c]of Object.entries(r)){let i=(c.models??[]).map(u=>u.id).filter(Boolean);a+=i.length,console.log(` ${o} (${i.length})`);for(let u of i)console.log(` ${u}`)}return a===0?(console.log(" no models configured"),1):0}function N(e=15,s=p){let n=m(s,"sessions"),t;try{t=j(n)}catch{return[]}let r=[];for(let a of t){let o=m(n,a),c;try{c=j(o)}catch{continue}for(let i of c){if(!i.endsWith(".jsonl"))continue;let u=m(o,i);try{let f=D(u);r.push({file:u,project:a,modified:f.mtimeMs,bytes:f.size})}catch{}}}return r.sort((a,o)=>o.modified-a.modified).slice(0,e)}function Q(e){let s=e.indexOf("--search");if(s>=0){let o=e[s+1]?.trim();if(!o)return console.error(`${g}: sessions: --search needs a word or phrase`),2;let c=P(o);if(c.length===0)return console.log(` no session mentions "${o}"`),0;for(let i of c){let u=new Date(i.row.modified).toISOString().replace("T"," ").slice(0,16),f=`${i.matches} hit${i.matches===1?"":"s"}`;console.log(` ${u} ${i.row.project} (${f})`),console.log(` ${i.row.file}`),console.log(` ${i.snippet}`)}return 0}let n=e.indexOf("--limit"),t=n>=0&&Number(e[n+1])||15,r=N(t);if(r.length===0)return console.log(` no saved sessions under ${m(p,"sessions")}`),e.includes("--export")?1:0;let a=e.indexOf("--export");if(a>=0){let o=Number(e[a+1]);if(!Number.isInteger(o)||o<1||o>r.length)return console.error(`${g}: sessions: --export needs a number from the list (1-${r.length})`),2;let c=r[o-1];try{console.log(_(c.file))}catch(i){return k(g,"sessions",i),1}return 0}return r.forEach((o,c)=>{let i=new Date(o.modified).toISOString().replace("T"," ").slice(0,16),u=Math.round(o.bytes/1024);console.log(` ${String(c+1).padStart(2)} ${i} ${String(u).padStart(6)}k ${o.project}`),console.log(` ${o.file}`)}),0}function R(e){try{let s=JSON.parse(e),n=s.message?.content??s.content;if(typeof n=="string"&&n.trim())return O(n).replace(/\s+/g," ").trim();if(Array.isArray(n)){let t=O(n.map(r=>r&&typeof r=="object"&&"text"in r?String(r.text):"").join(" ")).replace(/\s+/g," ").trim();if(t)return t}}catch{}return O(e).replace(/\s+/g," ").trim()}function O(e){return e.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]|\u001b\][^\u0007]*\u0007|\u001b[@-Z\\-_]/g,"")}function L(e,s,n=80){let t=e.toLowerCase().indexOf(s);if(t<0)return e.slice(0,n*2).trim();let r=Math.max(0,t-n),a=Math.min(e.length,t+s.length+n);return`${r>0?"\u2026":""}${e.slice(r,a).trim()}${a<e.length?"\u2026":""}`}function P(e,s=10,n=p){let t=e.toLowerCase(),r=new RegExp(`\\b${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"i"),a=[];for(let o of N(Number.MAX_SAFE_INTEGER,n)){let c;try{c=S(o.file,"utf8")}catch{continue}let i=0,u=0,f=0,h=0,l=!1,d="";for(let y of c.split(`
3
3
  `)){let w=y.toLowerCase(),b=w.indexOf(t);if(b<0)continue;let $=0;for(;b>=0;)$++,b=w.indexOf(t,b+t.length);i+=$;let M=w.includes('"role":"user"'),T=w.includes('"role":"toolresult"')||w.includes('"role":"tool"');M?u+=$:T?h+=$:f+=$,r.test(y)&&(l=!0),d||(d=L(R(y),t))}if(i===0)continue;let I=(u>0?100:0)+(f>0?10:0)+Math.min(h,5)+(l?5:0)+Math.min(i,10)/100;a.push({row:o,matches:i,score:I,snippet:d})}return a.sort((o,c)=>c.score-o.score||c.row.modified-o.row.modified).slice(0,s)}function _(e){let s=[`# Session ${e.split(/[\\/]/).pop()??e}`,""];for(let n of S(e,"utf8").split(`
4
4
  `)){if(!n.trim())continue;let t;try{t=JSON.parse(n)}catch{continue}if(t.type!=="message")continue;let r=R(n);r&&s.push(`## ${t.message?.role??"unknown"}`,"",r,"")}return s.join(`
@@ -1,4 +1,4 @@
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-LLQEHSZP.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-FC7RDN2F.js";import{a as oe}from"./chunk-UTYFLLSM.js";import{h as mi,i as pi}from"./chunk-C52X7EKC.js";import{a as on,b as lt,e as Yo}from"./chunk-MWUEV7YF.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(`
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
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
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
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(`
@@ -114,4 +114,4 @@ ${kn(p)}`);return}if(r==="session"){let c=k.model;m("session",c?`${c.provider}/$
114
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
115
  Enable with /preset enable rotoolbox
116
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-BY2ANCVM.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};
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};
@@ -1 +1 @@
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-FC7RDN2F.js";import"./chunk-UTYFLLSM.js";import"./chunk-C52X7EKC.js";import"./chunk-MWUEV7YF.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};
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/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{b as I,d as W,e as B}from"./chunk-3LZR7OEU.js";import{b as U}from"./chunk-YW7NORH3.js";import{a as F,b as R}from"./chunk-AGGIYXN7.js";import{D as M,K as N}from"./chunk-V656XVXV.js";import"./chunk-UTYFLLSM.js";import{a as n,b as y}from"./chunk-MWUEV7YF.js";import"./chunk-WOT6VMZA.js";var L={rpc:!0,acp:!0},D={off:!0,minimal:!0,low:!0,medium:!0,high:!0,xhigh:!0,max:!0},G={suggest:!0,"auto-edit":!0,"full-auto":!0},H={text:!0,json:!0,"stream-json":!0};function fe(c){let e=Number(c);if(!Number.isFinite(e)||e<=0)throw new Error(`--max-budget-usd needs a positive number of dollars, got '${c}'`);return e}function $(c,e,p){let d=c[e];if(d?.includes("="))return d.slice(d.indexOf("=")+1);let l=c[e+1];if(!l||l.startsWith("-"))throw new Error(`${p} needs a value`);return c.splice(e+1,1),l}function X(c){let e={print:!1,continueSession:!1,noSession:!1,help:!1,version:!1,update:!1,checkUpdate:!1,outputFormat:"text",dangerouslySkipPermissions:!1,sandbox:!1,prompt:""},p=[],d=[...c];for(let l=0;l<d.length;l++){let s=d[l]??"";if(s==="--"){p.push(...d.slice(l+1));break}if(s==="-h"||s==="--help")e.help=!0;else if(s==="-v"||s==="--version")e.version=!0;else if(s==="-p"||s==="--print")e.print=!0;else if(s==="-c"||s==="--continue")e.continueSession=!0;else if(s==="--no-session")e.noSession=!0;else if(s==="--sandbox")e.sandbox=!0;else if(s==="--update")e.update=!0;else if(s==="--check-update")e.checkUpdate=!0;else if(s==="-r"||s==="--resume")e.continueSession=!0;else if(s==="--session"||s.startsWith("--session="))e.sessionPath=$(d,l,"--session");else if(s==="-m"||s==="--model"||s.startsWith("--model="))e.model=$(d,l,"--model");else if(s==="--thinking"||s.startsWith("--thinking="))e.thinking=$(d,l,"--thinking");else if(s==="--approval"||s.startsWith("--approval="))e.approval=$(d,l,"--approval");else if(s==="--output-format"||s.startsWith("--output-format="))e.outputFormat=$(d,l,"--output-format");else if(s==="--max-budget-usd"||s.startsWith("--max-budget-usd="))e.maxBudgetUsd=fe($(d,l,"--max-budget-usd"));else if(s==="--mode"||s.startsWith("--mode=")){let u=$(d,l,"--mode");if(!L[u])throw new Error(`--mode must be one of: ${Object.keys(L).join(", ")}`);e.mode=u}else if(s==="--acp")e.mode="acp";else if(s==="--dangerously-skip-permissions")e.dangerouslySkipPermissions=!0;else{if(s.startsWith("-"))throw new Error(`unknown option ${s}`);p.push(s)}}if(e.thinking&&!D[e.thinking])throw new Error(`thinking must be one of: ${Object.keys(D).join(", ")}`);if(e.approval&&!G[e.approval])throw new Error(`approval must be one of: ${Object.keys(G).join(", ")}`);if(!H[e.outputFormat])throw new Error(`output-format must be one of: ${Object.keys(H).join(", ")}`);if(e.outputFormat!=="text"&&!e.print)throw new Error(`--output-format ${e.outputFormat} is a machine contract; it needs --print`);if(e.dangerouslySkipPermissions&&!e.print)throw new Error("--dangerously-skip-permissions is for unattended runs; it needs --print. interactively, pick an approval mode instead (/approval, or --approval)");if(e.prompt=p.join(" ").trim(),e.update&&e.checkUpdate)throw new Error("--update installs; --check-update only looks. pick one");if((e.update||e.checkUpdate)&&(e.print||e.continueSession||e.sessionPath||e.prompt))throw new Error("--update and --check-update act on the installation, not a session; they take no prompt");if(e.continueSession&&e.noSession)throw new Error("--continue and --no-session cannot be combined");if(e.sessionPath&&e.noSession)throw new Error("--session and --no-session cannot be combined");if(e.sessionPath&&e.continueSession)throw new Error("--session and --continue cannot be combined");if(e.print&&(e.continueSession||e.sessionPath))throw new Error("--print runs one prompt in a throwaway session; it cannot be combined with --continue or --session");if(e.mode&&(e.print||e.prompt))throw new Error(`--mode ${e.mode} is a protocol server: prompts arrive over the protocol, not the command line`);if(e.mode&&(e.continueSession||e.sessionPath))throw new Error(`--mode ${e.mode} opens its own sessions; it cannot be combined with --continue or --session`);if(e.sessionPath&&!e.sessionPath.endsWith(".jsonl"))throw new Error(`--session expects a session file, got '${e.sessionPath}'`);return e}function C(){return`${n} ${y}
2
+ import{b as I,d as W,e as B}from"./chunk-3LZR7OEU.js";import{b as U}from"./chunk-YW7NORH3.js";import{a as F,b as R}from"./chunk-AGGIYXN7.js";import{D as M,K as N}from"./chunk-V656XVXV.js";import"./chunk-UTYFLLSM.js";import{a as n,b as y}from"./chunk-N3J2J7EQ.js";import"./chunk-WOT6VMZA.js";var L={rpc:!0,acp:!0},D={off:!0,minimal:!0,low:!0,medium:!0,high:!0,xhigh:!0,max:!0},G={suggest:!0,"auto-edit":!0,"full-auto":!0},H={text:!0,json:!0,"stream-json":!0};function fe(c){let e=Number(c);if(!Number.isFinite(e)||e<=0)throw new Error(`--max-budget-usd needs a positive number of dollars, got '${c}'`);return e}function $(c,e,p){let d=c[e];if(d?.includes("="))return d.slice(d.indexOf("=")+1);let l=c[e+1];if(!l||l.startsWith("-"))throw new Error(`${p} needs a value`);return c.splice(e+1,1),l}function X(c){let e={print:!1,continueSession:!1,noSession:!1,help:!1,version:!1,update:!1,checkUpdate:!1,outputFormat:"text",dangerouslySkipPermissions:!1,sandbox:!1,prompt:""},p=[],d=[...c];for(let l=0;l<d.length;l++){let s=d[l]??"";if(s==="--"){p.push(...d.slice(l+1));break}if(s==="-h"||s==="--help")e.help=!0;else if(s==="-v"||s==="--version")e.version=!0;else if(s==="-p"||s==="--print")e.print=!0;else if(s==="-c"||s==="--continue")e.continueSession=!0;else if(s==="--no-session")e.noSession=!0;else if(s==="--sandbox")e.sandbox=!0;else if(s==="--update")e.update=!0;else if(s==="--check-update")e.checkUpdate=!0;else if(s==="-r"||s==="--resume")e.continueSession=!0;else if(s==="--session"||s.startsWith("--session="))e.sessionPath=$(d,l,"--session");else if(s==="-m"||s==="--model"||s.startsWith("--model="))e.model=$(d,l,"--model");else if(s==="--thinking"||s.startsWith("--thinking="))e.thinking=$(d,l,"--thinking");else if(s==="--approval"||s.startsWith("--approval="))e.approval=$(d,l,"--approval");else if(s==="--output-format"||s.startsWith("--output-format="))e.outputFormat=$(d,l,"--output-format");else if(s==="--max-budget-usd"||s.startsWith("--max-budget-usd="))e.maxBudgetUsd=fe($(d,l,"--max-budget-usd"));else if(s==="--mode"||s.startsWith("--mode=")){let u=$(d,l,"--mode");if(!L[u])throw new Error(`--mode must be one of: ${Object.keys(L).join(", ")}`);e.mode=u}else if(s==="--acp")e.mode="acp";else if(s==="--dangerously-skip-permissions")e.dangerouslySkipPermissions=!0;else{if(s.startsWith("-"))throw new Error(`unknown option ${s}`);p.push(s)}}if(e.thinking&&!D[e.thinking])throw new Error(`thinking must be one of: ${Object.keys(D).join(", ")}`);if(e.approval&&!G[e.approval])throw new Error(`approval must be one of: ${Object.keys(G).join(", ")}`);if(!H[e.outputFormat])throw new Error(`output-format must be one of: ${Object.keys(H).join(", ")}`);if(e.outputFormat!=="text"&&!e.print)throw new Error(`--output-format ${e.outputFormat} is a machine contract; it needs --print`);if(e.dangerouslySkipPermissions&&!e.print)throw new Error("--dangerously-skip-permissions is for unattended runs; it needs --print. interactively, pick an approval mode instead (/approval, or --approval)");if(e.prompt=p.join(" ").trim(),e.update&&e.checkUpdate)throw new Error("--update installs; --check-update only looks. pick one");if((e.update||e.checkUpdate)&&(e.print||e.continueSession||e.sessionPath||e.prompt))throw new Error("--update and --check-update act on the installation, not a session; they take no prompt");if(e.continueSession&&e.noSession)throw new Error("--continue and --no-session cannot be combined");if(e.sessionPath&&e.noSession)throw new Error("--session and --no-session cannot be combined");if(e.sessionPath&&e.continueSession)throw new Error("--session and --continue cannot be combined");if(e.print&&(e.continueSession||e.sessionPath))throw new Error("--print runs one prompt in a throwaway session; it cannot be combined with --continue or --session");if(e.mode&&(e.print||e.prompt))throw new Error(`--mode ${e.mode} is a protocol server: prompts arrive over the protocol, not the command line`);if(e.mode&&(e.continueSession||e.sessionPath))throw new Error(`--mode ${e.mode} opens its own sessions; it cannot be combined with --continue or --session`);if(e.sessionPath&&!e.sessionPath.endsWith(".jsonl"))throw new Error(`--session expects a session file, got '${e.sessionPath}'`);return e}function C(){return`${n} ${y}
3
3
  coding agent. layout is a workbench, not a chat log.
4
4
 
5
5
  usage:
@@ -90,10 +90,10 @@ an npm install checks for a newer release at startup and can install it itself;
90
90
  token; /login takes another provider's key.
91
91
  `}function ge(c,e=!1){let{message:p}=F(c);if(!e)return p;let d=c instanceof Error?c.stack:void 0;return d&&d.includes(`
92
92
  `)?`${p}
93
- ${d}`:p}function V(c,e){let p=e?.debug??process.env.HOWTOFIX_DEBUG==="1",d=e?.exit??(s=>process.exit(s)),l=s=>{console.error(`${c}: ${ge(s,p)}`),d(1)};process.on("uncaughtException",l),process.on("unhandledRejection",l)}function we(){try{return{cwd:process.cwd()}}catch{return{error:"the current directory no longer exists (it was deleted while the shell stayed in it). cd to a directory that exists, or pass one on the command line."}}}function be(){process.stdout.on("error",c=>{throw c.code==="EPIPE"&&process.exit(0),c})}async function ke(){be(),N();let c=performance.now(),e=we();if("error"in e){console.error(`${n}: ${e.error}`),process.exitCode=1;return}let p=e.cwd,d=process.env.HXF_FAKE_NODE??process.versions.node,[l,s]=d.split(".").map(o=>Number.parseInt(o,10));if(!Number.isFinite(l)||l<22||l===22&&Number.isFinite(s)&&s<19){console.error(`${n}: Node ${d} is too old. Node 22.19 or newer is required (run "node --version" to check yours), because undici needs zstd, which Node added in 22.19. Upgrade Node and run this again.`),process.exitCode=1;let o=process.argv.slice(2);if(o.some(a=>a==="-h"||a==="--help")){console.log(C());return}if(o.some(a=>a==="-v"||a==="--version")){console.log(`${n} ${y}`);return}return}let u=process.argv.slice(2);if(u[0]==="doctor"||u[0]==="models"||u[0]==="sessions"){let o=u[0];try{let a=await import("./chunk-J5BGXOYK.js");o==="doctor"?process.exitCode=await a.runDoctor():o==="models"?process.exitCode=a.runModels():process.exitCode=a.runSessions(u.slice(1))}catch(a){R(n,o,a),process.exitCode=1}return}let q=u[0]==="acp"?["--acp",...u.slice(1)]:u,_;try{_=X(q)}catch(o){let a=o instanceof Error?o.message:String(o);console.error(`${n}: ${a}
94
- ${C()}`),process.exitCode=2;return}if(_.print&&!_.prompt){console.error(`${n}: --print needs a prompt`),process.exitCode=2;return}let{repairGatewayModels:J,ensureGatewaySettings:K,repairModelFacts:Y,syncGatewayModelsOnStart:z,checkAccount:Q,fetchGatewayPrices:Z}=await import("./chunk-AJBPAFOX.js"),{readCliCredential:ee,renewCliCredentialIfNeeded:se}=await import("./chunk-WCYEZS6X.js"),{AGENT_DIR:b}=await import("./chunk-GXB7RZHH.js"),j=J(b);j>0&&console.error(`${n}: repaired ${j} howtofix model(s) that the gateway would have rejected`);let P,O;try{let o=ee(b);if(o){let x=(await se(b,o)).credential.accessToken,[m,h]=await Promise.all([Z(x),Q(x)]);m.size>0&&(P=m),h.ok&&(O=h.models)}}catch{}let E=await Y(b,P?{prices:P}:void 0);if(E.changed>0?console.error(`${n}: filled in the context window, reasoning flag and price for ${E.changed} model(s)`):E.message&&console.error(`${n}: model catalogue unavailable (${E.message}); context windows stay at their conservative defaults`),K(b)&&console.error(`${n}: set httpIdleTimeoutMs in settings.json so a stalled provider recovers instead of hanging`),O)try{let o=await z(b,O,P);o.added>0&&console.error(`${n}: added ${o.added} model(s) this account can now reach`)}catch{}let t=_;if(t.help){console.log(C());return}if(t.version){console.log(`${n} ${y}`);let{cliSigningKeyMatchesPanel:o,cliSigningKeyFingerprint:a}=await import("./chunk-RHJM547Q.js");o()||(console.error(`${n}: this build's CLI signing key (${a()}) does not match the key the panel verifies against, so sign-in will be refused.`),process.exitCode=1);return}if(t.sandbox&&!process.env.HOWTOFIX_SANDBOXED){let{detectSandbox:o,enterSandbox:a,describeSandbox:x}=await import("./chunk-N345KWWK.js"),m=o();if(!m){console.error(`${n}: --sandbox needs a working bubblewrap (Linux) or sandbox-exec (macOS). Neither could be used here \u2014 on Linux this usually means unprivileged user namespaces are disabled.`),process.exitCode=1;return}console.error(x(m)),process.exitCode=a(m,{cwd:p,agentDir:M,argv:[process.execPath,...process.argv.slice(1)]});return}let{installProxy:te}=await import("./chunk-WKUJ7CFO.js");if(te(M),t.update||t.checkUpdate){let{PACKAGE_NAME:o,checkForUpdate:a,installUpdate:x,isInstalledCopy:m}=await import("./chunk-7CHDNTH6.js"),h=await a(y);if(!h.latest){console.error(`${n}: ${h.message}`),process.exitCode=t.update?1:0;return}if(console.log(h.message),t.checkUpdate||!h.available)return;if(!m()){console.error(`${n}: this copy was not installed by npm, so npm cannot replace it. install it with: npm install -g ${o}`),process.exitCode=1;return}let v=await x({version:h.latest});console.log(v.message),v.ok||(process.exitCode=1);return}let A=process.argv.slice(2);if(A[0]==="preset"){let{runPresetCommand:o}=await import("./chunk-FPXVDP32.js");process.exitCode=o(A.slice(1));return}let{expandFileReferences:oe}=await import("./chunk-TSEKPGK4.js"),{isApprovalMode:ne,setApprovalMode:re,setDangerousBypass:ie,isDangerousBypass:ae}=await import("./chunk-56SEAGAQ.js"),{openSession:de}=await import("./chunk-BSYK5SMR.js");re(t.approval&&ne(t.approval)?t.approval:"full-auto");let{readWorkbenchSettings:ce}=await import("./chunk-V3R4FYTJ.js");if((t.dangerouslySkipPermissions||ce(b).skipPermissions)&&ie(!0),ae()&&console.error(`${n}: permission checks are OFF \u2014 critical commands (filesystem wipes, fork bombs, host shutdown) and the repeated-call guard are NOT enforced for this run. Turn it off with /settings, or by removing skipPermissions from settings.json.`),t.mode){let{serveProtocol:o}=await import("./chunk-JXB342NI.js");await o(t.mode,{cwd:p,model:t.model,thinking:t.thinking});return}let T=o=>de({cwd:p,model:t.model,thinking:t.thinking,continueSession:o.continueSession??!1,noSession:o.noSession??!1,sessionPath:o.sessionPath,interactive:!t.print}),r=await T({continueSession:t.continueSession,sessionPath:t.sessionPath,noSession:t.noSession||t.print});if(t.print&&r.note&&console.error(r.note),t.maxBudgetUsd!==void 0&&!r.priced){console.error(`${n}: ${B(r.modelLabel,b)}`),await r.dispose(),process.exitCode=2;return}if(t.print){let o=t.prompt.trimStart();if(o.startsWith("/")){let f=o.slice(1).split(/\s+/)[0]??"",{skillInvocation:S}=await import("./chunk-ILDDDLRC.js"),g=r.session.resourceLoader.getSkills().skills.map(i=>i.name);if(!(S(o,g)!==void 0)){let{slashCommands:i}=await import("./chunk-JVPQ7HQM.js");if(i(r.session).some(w=>w.name===f)){console.error(`${n}: /${f} runs in the TUI only \u2014 --print sends prompts straight to the model. Run \`howtofix\` without --print for interactive commands.`),await r.dispose(),process.exitCode=2;return}}}let a=t.outputFormat==="stream-json",x=t.outputFormat==="json",m=a||x;if(a){let f={type:"system",subtype:"init",cwd:p,session_id:r.session.sessionId,model:r.modelLabel,output_format:t.outputFormat,max_budget_usd:t.maxBudgetUsd??null,dangerously_skip_permissions:t.dangerouslySkipPermissions,cli_version:y};process.stdout.write(`${JSON.stringify(f)}
93
+ ${d}`:p}function V(c,e){let p=e?.debug??process.env.HOWTOFIX_DEBUG==="1",d=e?.exit??(s=>process.exit(s)),l=s=>{console.error(`${c}: ${ge(s,p)}`),d(1)};process.on("uncaughtException",l),process.on("unhandledRejection",l)}function we(){try{return{cwd:process.cwd()}}catch{return{error:"the current directory no longer exists (it was deleted while the shell stayed in it). cd to a directory that exists, or pass one on the command line."}}}function be(){process.stdout.on("error",c=>{throw c.code==="EPIPE"&&process.exit(0),c})}async function ke(){be(),N();let c=performance.now(),e=we();if("error"in e){console.error(`${n}: ${e.error}`),process.exitCode=1;return}let p=e.cwd,d=process.env.HXF_FAKE_NODE??process.versions.node,[l,s]=d.split(".").map(o=>Number.parseInt(o,10));if(!Number.isFinite(l)||l<22||l===22&&Number.isFinite(s)&&s<19){console.error(`${n}: Node ${d} is too old. Node 22.19 or newer is required (run "node --version" to check yours), because undici needs zstd, which Node added in 22.19. Upgrade Node and run this again.`),process.exitCode=1;let o=process.argv.slice(2);if(o.some(a=>a==="-h"||a==="--help")){console.log(C());return}if(o.some(a=>a==="-v"||a==="--version")){console.log(`${n} ${y}`);return}return}let u=process.argv.slice(2);if(u[0]==="doctor"||u[0]==="models"||u[0]==="sessions"){let o=u[0];try{let a=await import("./chunk-TKROS3BE.js");o==="doctor"?process.exitCode=await a.runDoctor():o==="models"?process.exitCode=a.runModels():process.exitCode=a.runSessions(u.slice(1))}catch(a){R(n,o,a),process.exitCode=1}return}let q=u[0]==="acp"?["--acp",...u.slice(1)]:u,_;try{_=X(q)}catch(o){let a=o instanceof Error?o.message:String(o);console.error(`${n}: ${a}
94
+ ${C()}`),process.exitCode=2;return}if(_.print&&!_.prompt){console.error(`${n}: --print needs a prompt`),process.exitCode=2;return}let{repairGatewayModels:J,ensureGatewaySettings:K,repairModelFacts:Y,syncGatewayModelsOnStart:z,checkAccount:Q,fetchGatewayPrices:Z}=await import("./chunk-75P2SCOT.js"),{readCliCredential:ee,renewCliCredentialIfNeeded:se}=await import("./chunk-XW6LMQGX.js"),{AGENT_DIR:b}=await import("./chunk-GXB7RZHH.js"),j=J(b);j>0&&console.error(`${n}: repaired ${j} howtofix model(s) that the gateway would have rejected`);let P,O;try{let o=ee(b);if(o){let x=(await se(b,o)).credential.accessToken,[m,h]=await Promise.all([Z(x),Q(x)]);m.size>0&&(P=m),h.ok&&(O=h.models)}}catch{}let E=await Y(b,P?{prices:P}:void 0);if(E.changed>0?console.error(`${n}: filled in the context window, reasoning flag and price for ${E.changed} model(s)`):E.message&&console.error(`${n}: model catalogue unavailable (${E.message}); context windows stay at their conservative defaults`),K(b)&&console.error(`${n}: set httpIdleTimeoutMs in settings.json so a stalled provider recovers instead of hanging`),O)try{let o=await z(b,O,P);o.added>0&&console.error(`${n}: added ${o.added} model(s) this account can now reach`)}catch{}let t=_;if(t.help){console.log(C());return}if(t.version){console.log(`${n} ${y}`);let{cliSigningKeyMatchesPanel:o,cliSigningKeyFingerprint:a}=await import("./chunk-5AWTL34S.js");o()||(console.error(`${n}: this build's CLI signing key (${a()}) does not match the key the panel verifies against, so sign-in will be refused.`),process.exitCode=1);return}if(t.sandbox&&!process.env.HOWTOFIX_SANDBOXED){let{detectSandbox:o,enterSandbox:a,describeSandbox:x}=await import("./chunk-N345KWWK.js"),m=o();if(!m){console.error(`${n}: --sandbox needs a working bubblewrap (Linux) or sandbox-exec (macOS). Neither could be used here \u2014 on Linux this usually means unprivileged user namespaces are disabled.`),process.exitCode=1;return}console.error(x(m)),process.exitCode=a(m,{cwd:p,agentDir:M,argv:[process.execPath,...process.argv.slice(1)]});return}let{installProxy:te}=await import("./chunk-WKUJ7CFO.js");if(te(M),t.update||t.checkUpdate){let{PACKAGE_NAME:o,checkForUpdate:a,installUpdate:x,isInstalledCopy:m}=await import("./chunk-7CHDNTH6.js"),h=await a(y);if(!h.latest){console.error(`${n}: ${h.message}`),process.exitCode=t.update?1:0;return}if(console.log(h.message),t.checkUpdate||!h.available)return;if(!m()){console.error(`${n}: this copy was not installed by npm, so npm cannot replace it. install it with: npm install -g ${o}`),process.exitCode=1;return}let v=await x({version:h.latest});console.log(v.message),v.ok||(process.exitCode=1);return}let A=process.argv.slice(2);if(A[0]==="preset"){let{runPresetCommand:o}=await import("./chunk-FPXVDP32.js");process.exitCode=o(A.slice(1));return}let{expandFileReferences:oe}=await import("./chunk-TSEKPGK4.js"),{isApprovalMode:ne,setApprovalMode:re,setDangerousBypass:ie,isDangerousBypass:ae}=await import("./chunk-56SEAGAQ.js"),{openSession:de}=await import("./chunk-7PHRNXLN.js");re(t.approval&&ne(t.approval)?t.approval:"full-auto");let{readWorkbenchSettings:ce}=await import("./chunk-V3R4FYTJ.js");if((t.dangerouslySkipPermissions||ce(b).skipPermissions)&&ie(!0),ae()&&console.error(`${n}: permission checks are OFF \u2014 critical commands (filesystem wipes, fork bombs, host shutdown) and the repeated-call guard are NOT enforced for this run. Turn it off with /settings, or by removing skipPermissions from settings.json.`),t.mode){let{serveProtocol:o}=await import("./chunk-CMTKCUL5.js");await o(t.mode,{cwd:p,model:t.model,thinking:t.thinking});return}let T=o=>de({cwd:p,model:t.model,thinking:t.thinking,continueSession:o.continueSession??!1,noSession:o.noSession??!1,sessionPath:o.sessionPath,interactive:!t.print}),r=await T({continueSession:t.continueSession,sessionPath:t.sessionPath,noSession:t.noSession||t.print});if(t.print&&r.note&&console.error(r.note),t.maxBudgetUsd!==void 0&&!r.priced){console.error(`${n}: ${B(r.modelLabel,b)}`),await r.dispose(),process.exitCode=2;return}if(t.print){let o=t.prompt.trimStart();if(o.startsWith("/")){let f=o.slice(1).split(/\s+/)[0]??"",{skillInvocation:S}=await import("./chunk-ILDDDLRC.js"),g=r.session.resourceLoader.getSkills().skills.map(i=>i.name);if(!(S(o,g)!==void 0)){let{slashCommands:i}=await import("./chunk-UP7ENLEL.js");if(i(r.session).some(w=>w.name===f)){console.error(`${n}: /${f} runs in the TUI only \u2014 --print sends prompts straight to the model. Run \`howtofix\` without --print for interactive commands.`),await r.dispose(),process.exitCode=2;return}}}let a=t.outputFormat==="stream-json",x=t.outputFormat==="json",m=a||x;if(a){let f={type:"system",subtype:"init",cwd:p,session_id:r.session.sessionId,model:r.modelLabel,output_format:t.outputFormat,max_budget_usd:t.maxBudgetUsd??null,dangerously_skip_permissions:t.dangerouslySkipPermissions,cli_version:y};process.stdout.write(`${JSON.stringify(f)}
95
95
  `)}let h,v,he=()=>{if(t.maxBudgetUsd===void 0||v!==void 0)return;let f=r.session.getSessionStats().cost;f>t.maxBudgetUsd&&(v={spent:f},r.session.abort())};try{let f;h=r.session.subscribe(i=>{if(a){let w=U(i);w!==void 0&&process.stdout.write(w)}if(i.type==="turn_end"&&i.message?.role==="assistant"){let w=i.message;w.stopReason==="error"||w.stopReason==="aborted"||w.errorMessage?f={stopReason:w.stopReason??"error",errorMessage:w.errorMessage}:f=void 0}he()}),await r.session.prompt(oe(t.prompt,p));let S=r.session.getLastAssistantText()??"";if(v){if(console.error(`${n}: ${W(v.spent,t.maxBudgetUsd)}`),m){let i=r.session.getSessionStats();process.stdout.write(`${JSON.stringify({type:"result",subtype:"error_max_budget_usd",is_error:!0,result:S,session_id:r.session.sessionId,duration_ms:Math.round(performance.now()-c),num_turns:i.assistantMessages,total_cost_usd:i.cost,usage:{input_tokens:i.tokens.input,output_tokens:i.tokens.output,cache_read_input_tokens:i.tokens.cacheRead,cache_creation_input_tokens:i.tokens.cacheWrite}})}
96
96
  `)}process.exitCode=1;return}let g=r.session.state.messages.at(-1),k=f??(g?.role==="assistant"&&(g.stopReason==="error"||g.stopReason==="aborted"||g.errorMessage)?{stopReason:g.stopReason??"error",errorMessage:g.errorMessage}:void 0);if(m){let i=r.session.getSessionStats();process.stdout.write(`${JSON.stringify({type:"result",subtype:k?k.stopReason==="aborted"?"error_aborted":"error_during_execution":"success",is_error:k!==void 0,result:S,session_id:r.session.sessionId,duration_ms:Math.round(performance.now()-c),num_turns:i.assistantMessages,total_cost_usd:i.cost,usage:{input_tokens:i.tokens.input,output_tokens:i.tokens.output,cache_read_input_tokens:i.tokens.cacheRead,cache_creation_input_tokens:i.tokens.cacheWrite},stop_reason:k?.stopReason??(g?.role==="assistant"?g.stopReason:void 0)})}
97
97
  `)}else process.stdout.write(S.endsWith(`
98
98
  `)?S:`${S}
99
- `);if(k&&(process.exitCode=1,k.errorMessage)){console.error(`${n}: ${k.errorMessage}`);let i=I(k.errorMessage);i!==void 0&&console.error(`${n}: ${i}`)}}finally{h?.(),await r.dispose()}return}if(!process.stdin.isTTY||!process.stdout.isTTY){console.error(`${n}: interactive mode needs a terminal. use --print for pipes.`),await r.dispose(),process.exitCode=2;return}let{runWorkbench:le}=await import("./chunk-JVPQ7HQM.js"),{autoUpdateEnabled:pe,isInstalledCopy:ue}=await import("./chunk-7CHDNTH6.js"),me=ue()&&pe(`${b}/settings.json`);await le({cwd:p,modelLabel:r.modelLabel,session:r.session,setCompressToolOutput:r.setCompressToolOutput,initialPrompt:t.prompt||void 0,note:r.note,maxBudgetUsd:t.maxBudgetUsd,update:me?{current:y,install:!0}:void 0,reopen:T})}V(n);ke().catch(c=>{R(n,void 0,c),process.exitCode=1});
99
+ `);if(k&&(process.exitCode=1,k.errorMessage)){console.error(`${n}: ${k.errorMessage}`);let i=I(k.errorMessage);i!==void 0&&console.error(`${n}: ${i}`)}}finally{h?.(),await r.dispose()}return}if(!process.stdin.isTTY||!process.stdout.isTTY){console.error(`${n}: interactive mode needs a terminal. use --print for pipes.`),await r.dispose(),process.exitCode=2;return}let{runWorkbench:le}=await import("./chunk-UP7ENLEL.js"),{autoUpdateEnabled:pe,isInstalledCopy:ue}=await import("./chunk-7CHDNTH6.js"),me=ue()&&pe(`${b}/settings.json`);await le({cwd:p,modelLabel:r.modelLabel,session:r.session,setCompressToolOutput:r.setCompressToolOutput,initialPrompt:t.prompt||void 0,note:r.note,maxBudgetUsd:t.maxBudgetUsd,update:me?{current:y,install:!0}:void 0,reopen:T})}V(n);ke().catch(c=>{R(n,void 0,c),process.exitCode=1});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "howtofixcli",
3
- "version": "0.7.22",
3
+ "version": "0.7.24",
4
4
  "type": "module",
5
5
  "description": "HowToFix coding agent. Workbench TUI, sessions, background agents.",
6
6
  "license": "UNLICENSED",