howtofixcli 0.4.25 → 0.4.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +2 -2
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  var DP=Object.defineProperty;var u=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(r){throw n=[r],r}};var Mt=(e,t)=>{for(var n in t)DP(e,n,{get:t[n],enumerable:!0})};function Sd(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*pi-coding-agent[\\/]docs[\\/][^\n]*$/gim,"").replace(/\bpi-coding-agent\b/gi,"the harness").replace(/\n{3,}/g,`
3
3
 
4
- `).trim()}var at,Nt,Ed,Pd,Ko=u(()=>{at="HowToFix",Nt="0.4.25",Ed=["You are HowToFix, a coding agent. The user wants the actual fix, not a tour of the problem.","Lead with the diagnosis in one or two sentences, then change the code. Prefer the smallest correct change over a rewrite.","When you edit files, say which file and why in a short line. Do not narrate tool calls. Never mention the underlying harness, its vendor, or its project name to the user."].join(`
4
+ `).trim()}var at,Nt,Ed,Pd,Ko=u(()=>{at="HowToFix",Nt="0.4.26",Ed=["You are HowToFix, a coding agent. The user wants the actual fix, not a tour of the problem.","Lead with the diagnosis in one or two sentences, then change the code. Prefer the smallest correct change over a rewrite.","When you edit files, say which file and why in a short line. Do not narrate tool calls. Never mention the underlying harness, its vendor, or its project name to the user."].join(`
5
5
  `);Pd=["# Project notes","","## What this is","","## Commands","- build:","- test:","","## Conventions","-",""].join(`
6
6
  `)});var Od={};Mt(Od,{AGENTS_STORE_DIR:()=>Jr,AGENT_DIR:()=>Ve,CUBENCE_CACHE_PATH:()=>_m,USER_SKILLS_DIR:()=>Dm,WORKFLOWS_DIR:()=>Nm,pinAgentDir:()=>qm,projectSkillsDir:()=>hr});import{homedir as _P}from"node:os";import{join as Vr,resolve as NP}from"node:path";function qP(){let e=(process.env.HOWTOFIX_HOME??process.env.HOME??"").trim();return NP(e||_P())}function hr(e){return Vr(e,".howtofix","skills")}function qm(){process.env.PI_CODING_AGENT_DIR=Ve}var Ve,Dm,Jr,_m,Nm,Nn=u(()=>{Ve=process.env.HOWTOFIX_CODING_AGENT_DIR?.trim()||Vr(qP(),".howtofix","agent"),Dm=Vr(Ve,"skills");Jr=Vr(Ve,"agents"),_m=Vr(Ve,"cubence-cache.json"),Nm=Vr(Ve,"workflows")});import{closeSync as UP,fsyncSync as KP,openSync as GP,renameSync as Cd,rmSync as Um,writeSync as WP}from"node:fs";import{dirname as BP,join as zP}from"node:path";function tt(e,t){let n=zP(BP(e),`.${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}.tmp`),r=GP(n,"w");try{WP(r,t),KP(r)}finally{UP(r)}try{Cd(n,e)}catch(o){let s=o.code;if(s!=="EPERM"&&s!=="EBUSY"&&s!=="EACCES")throw Um(n,{force:!0}),o;Um(e,{force:!0});try{Cd(n,e)}catch(i){throw Um(n,{force:!0}),i}}}var Hn=u(()=>{});var qd={};Mt(qd,{DEFAULT_CONTEXT_WINDOW:()=>Dd,HOWTOFIX_BASE_URL:()=>Go,HOWTOFIX_CONSOLE_URL:()=>li,HOWTOFIX_MODEL_COMPAT:()=>Gm,HOWTOFIX_PROVIDERS:()=>Yr,HTTP_IDLE_TIMEOUT_MS:()=>jd,UNLIMITED_SENTINEL:()=>Nd,applyCompat:()=>fi,checkAccount:()=>gi,checkUsage:()=>Wo,countNewModels:()=>zm,ensureGatewaySettings:()=>YP,isHowtofixProvider:()=>xr,looksLikeToken:()=>Wm,maskToken:()=>di,mergeModels:()=>Bm,newProviderEntry:()=>Km,parseModelIds:()=>_d,probeModel:()=>Hm,repairGatewayModels:()=>JP});import{existsSync as HP,mkdirSync as VP,readFileSync as Ld}from"node:fs";import{join as Fd}from"node:path";function Km(){return{baseUrl:Go,api:"openai-completions"}}function JP(e){let t=Fd(e,"models.json"),n;try{n=JSON.parse(Ld(t,"utf8"))}catch{return 0}let r=n.providers;if(!r||typeof r!="object")return 0;let o=0;for(let s of Yr){let i=r[s];if(!i||!Array.isArray(i.models))continue;let c=fi(i.models);c.changed!==0&&(i.models=c.models,o+=c.changed)}if(o===0)return 0;try{tt(t,`${JSON.stringify(n,null,2)}
7
7
  `)}catch{return 0}return o}function YP(e){let t=Fd(e,"settings.json"),n={};try{let r=Ld(t,"utf8"),o=JSON.parse(r);o&&typeof o=="object"&&!Array.isArray(o)&&(n=o)}catch{if(HP(t))return!1}if("httpIdleTimeoutMs"in n)return!1;n.httpIdleTimeoutMs=jd;try{VP(e,{recursive:!0}),tt(t,`${JSON.stringify(n,null,2)}
@@ -141,7 +141,7 @@ ${Fm(T,Rt)}`),await v.modelRuntime.refresh(),_();return}if(g==="usage"){let b=ne
141
141
  `):"no tools enabled");return}if(g==="rewind"){cd();return}if(g==="undo"){if(!await sm(e.cwd)){E("undo","not a git repository");return}let b=await wE(e.cwd);E("undo",b.ok?`undone: ${b.output}`:`undo failed: ${b.output}`),i(!0);return}if(g==="commit"){if(!sm(e.cwd)){E("commit","not a git repository");return}if(!await IE(e.cwd)){E("commit","nothing to commit");return}let b=x||`howtofix: session update ${new Date().toISOString().slice(0,16)}`,T=await $E(e.cwd,b);E("commit",T.ok?T.output:`commit failed: ${T.output}`),i(!0);return}if(g==="review"){if(!(await kE(e.cwd)).trim()){E("review","no changes to review");return}Rm("Review the uncommitted changes. Report concrete issues with file evidence. Do not edit files.");return}if(g==="workflow"){if(x.trim()==="clear"){Qe(),E("workflow","cleared the pinned workflow panel");return}if(!L){E("workflow","no workflow run in this session yet");return}let b=Fo(L,Date.now()),T=b[O.selectedPhase];E("workflow",[`panel ${V?"pinned above the editor":"unpinned"}`,`phase ${O.selectedPhase+1}/${b.length}: ${T?.title??"(none)"}`,`filter: ${O.filter}${O.paused?" \xB7 paused":""}`,"keys: \u2191/\u2193 phase \xB7 Enter drill in \xB7 Esc unpin \xB7 f filter \xB7 p pause \xB7 x stop \xB7 s save","clear it with /workflow clear"].join(`
142
142
  `));return}if(g==="plan"){if(Gv()||Ju().state==="pending"){Co(Uv(Ju())),E("plan","plan mode off \u2014 edits are allowed again");return}Co(qv(Ju())),E("plan",`plan mode armed \u2014 send your next prompt to start planning
143
143
  plan file: ${Kv()??"(unknown)"}`);return}if(g==="goal"){let b=x.trim();if(!b){E("goal",Gu(Wu()));return}let{goal:T,error:P}=ml(Wu(),"set",b,void 0,void 0);if(P){hn(P);return}pn(T),await v.sendCustomMessage({customType:pr,content:b,display:!1,details:T}),E("goal",`goal set
144
- ${Gu(T)}`);return}if(g==="session"){let b=v.model;E("session",b?`${b.provider}/${b.id}`:"no model");return}if(g==="skills"){E("skills",QS(v.resourceLoader.getSkills().skills));return}let w=ZS(l,v.resourceLoader.getSkills().skills.map(b=>b.name));if(w){kd(w);return}let q=v.extensionRunner.getCommand(g??"");if(q){try{await q.handler(x,v.extensionRunner.createCommandContext())}catch(b){hn(b instanceof Error?b.message:String(b))}return}E("command",`/${g??""} is not available in this screen yet`)};yf((l,g)=>{let{promise:y,resolve:x}=Promise.withResolvers();return _t(l,g.map(w=>({value:w,label:w})),x,()=>x("cancelled")),y}),process.on("SIGTERM",ci),t.setTitle(`${at} ${Nt}`),e_(),n.start(),n.requestRender(!0),e.initialPrompt&&Rm(e.initialPrompt),await new Promise(()=>{})}var hP,id,$P,ud,bm,Im,$m,XD,ZD,fn,n_,r_,SP=u(()=>{Ko();oS();Gl();vS();Qm();CS();Vs();BS();rd();Hs();cc();ed();JS();Xs();Dl();Vm();XS();Nn();eP();cP();Al();Vo();ec();zu();dl();lP();Hn();hP={borderColor:()=>"",selectList:{selectedPrefix:e=>te(e,D.accent),selectedText:e=>te(e,D.text,{bold:!0}),description:e=>te(e,D.mute),scrollInfo:e=>te(e,D.dim),noMatch:e=>te(e,D.mute)}},id=["off","minimal","low","medium","high","xhigh","max"],$P=Symbol.for("@earendil-works/pi-tui/layout-node");ud=OD(MD);bm=class{folder;model;git;percent=0;meter=new pm(0);activity=zS();live=!1;activitySince=Date.now();thinking="medium";cubence="";constructor(t,n){this.folder=jD(t),this.model=n.split("/").at(-1)||"no-model",this.git=""}invalidate(){}settling(){return this.meter.moving}meterValue(){return this.meter.value!==this.percent&&this.meter.set(this.percent),this.meter.step()}beginRun(){this.live=!0,this.activitySince=Date.now()}waitedMs(){return Date.now()-this.activitySince}abandonAnimations(){this.meter.snap(this.percent)}render(t){let n=Date.now(),r=this.percent===0&&this.meter.value===0?0:this.meterValue(),o=_S(this.model,this.thinking,this.folder,this.git),s=[ri(`${NS(o,this.live?Xl():"",this.live?this.waitedMs():void 0)} ${qS(r,this.cubence)}`,t)],i=zv();i&&s.push(ri(te(i,D.warn),t));let c=Rv(Wu());c&&s.push(ri(te(c,D.accent),t));let p=VS(this.activity,Xl(),n),f=this.live?fS(p,{base:ql(this.waitedMs(),D.mute,D.warn,D.bad),bright:D.text,charMs:45},n):te(p,ql(this.waitedMs(),D.mute,D.warn,D.bad));return s.push(ri(f,t)),s}},Im=class{constructor(t){this.draw=t}draw;render(t){return this.draw(t)}invalidate(){}},$m=class{constructor(t,n){this.editor=t;this.hud=n}editor;hud;focused=!1;invalidate(){this.editor.invalidate()}render(t){let n=Math.max(10,t-4),r=this.editor.render(n).filter(c=>ym(c)>0),o=r.length>0?r:[""],s="\u2500".repeat(Math.max(0,t-2)),i=o.map(c=>{let p=Math.max(0,n-ym(c));return`\u2502 ${c}${" ".repeat(p)} \u2502`});return[`\u250C${s}\u2510`,...i,`\u2514${s}\u2518`,...this.hud.render(t)]}handleInput(t){this.editor.handleInput(t)}},XD=["deepseek","qwen","claude","gpt-5","gpt-4","gemini","glm","mimo","kimi","llama"],ZD=/(image|embedding|embed|whisper|tts|audio|video|rerank|moderation|dall-e|stable-diffusion|sora)/i;n_=1e3/30,r_=45e3});Ko();var Ad={off:!0,minimal:!0,low:!0,medium:!0,high:!0,xhigh:!0,max:!0},Rd={suggest:!0,"auto-edit":!0,"full-auto":!0};function pi(e,t,n){let r=e[t];if(r?.includes("="))return r.slice(r.indexOf("=")+1);let o=e[t+1];if(!o||o.startsWith("-"))throw new Error(`${n} needs a value`);return e.splice(t+1,1),o}function Md(e){let t={print:!1,continueSession:!1,noSession:!1,help:!1,version:!1,update:!1,checkUpdate:!1,prompt:""},n=[],r=[...e];for(let o=0;o<r.length;o++){let s=r[o]??"";if(s==="--"){n.push(...r.slice(o+1));break}if(s==="-h"||s==="--help")t.help=!0;else if(s==="-v"||s==="--version")t.version=!0;else if(s==="-p"||s==="--print")t.print=!0;else if(s==="-c"||s==="--continue")t.continueSession=!0;else if(s==="--no-session")t.noSession=!0;else if(s==="--update")t.update=!0;else if(s==="--check-update")t.checkUpdate=!0;else if(s==="-r"||s==="--resume")t.continueSession=!0;else if(s==="--session"||s.startsWith("--session="))t.sessionPath=pi(r,o,"--session");else if(s==="-m"||s==="--model"||s.startsWith("--model="))t.model=pi(r,o,"--model");else if(s==="--thinking"||s.startsWith("--thinking="))t.thinking=pi(r,o,"--thinking");else if(s==="--approval"||s.startsWith("--approval="))t.approval=pi(r,o,"--approval");else{if(s.startsWith("-"))throw new Error(`unknown option ${s}`);n.push(s)}}if(t.thinking&&!Ad[t.thinking])throw new Error(`thinking must be one of: ${Object.keys(Ad).join(", ")}`);if(t.approval&&!Rd[t.approval])throw new Error(`approval must be one of: ${Object.keys(Rd).join(", ")}`);if(t.update&&t.checkUpdate)throw new Error("--update installs; --check-update only looks. pick one");if((t.update||t.checkUpdate)&&(t.print||t.continueSession||t.sessionPath||t.prompt))throw new Error("--update and --check-update act on the installation, not a session; they take no prompt");if(t.continueSession&&t.noSession)throw new Error("--continue and --no-session cannot be combined");if(t.sessionPath&&t.noSession)throw new Error("--session and --no-session cannot be combined");if(t.sessionPath&&t.continueSession)throw new Error("--session and --continue cannot be combined");if(t.print&&(t.continueSession||t.sessionPath))throw new Error("--print runs one prompt in a throwaway session; it cannot be combined with --continue or --session");if(t.sessionPath&&!t.sessionPath.endsWith(".jsonl"))throw new Error(`--session expects a session file, got '${t.sessionPath}'`);return t.prompt=n.join(" ").trim(),t}function jm(){return`${at} ${Nt}
144
+ ${Gu(T)}`);return}if(g==="session"){let b=v.model;E("session",b?`${b.provider}/${b.id}`:"no model");return}if(g==="skills"){E("skills",QS(v.resourceLoader.getSkills().skills));return}let w=ZS(l,v.resourceLoader.getSkills().skills.map(b=>b.name));if(w){kd(w);return}let q=v.extensionRunner.getCommand(g??"");if(q){try{await q.handler(x,v.extensionRunner.createCommandContext())}catch(b){hn(b instanceof Error?b.message:String(b))}return}E("command",`/${g??""} is not available in this screen yet`)};yf((l,g)=>{let{promise:y,resolve:x}=Promise.withResolvers();return _t(l,g.map(w=>({value:w,label:w})),x,()=>x("cancelled")),y}),process.on("SIGTERM",ci),t.setTitle(`${at} ${Nt}`),e_(),n.start(),n.requestRender(!0),e.initialPrompt&&Rm(e.initialPrompt),await new Promise(()=>{})}var hP,id,$P,ud,bm,Im,$m,XD,ZD,fn,n_,r_,SP=u(()=>{Ko();oS();Gl();vS();Qm();CS();Vs();BS();rd();Hs();cc();ed();JS();Xs();Dl();Vm();XS();Nn();eP();cP();Al();Vo();ec();zu();dl();lP();Hn();hP={borderColor:()=>"",selectList:{selectedPrefix:e=>te(e,D.accent),selectedText:e=>te(e,D.text,{bold:!0}),description:e=>te(e,D.mute),scrollInfo:e=>te(e,D.dim),noMatch:e=>te(e,D.mute)}},id=["off","minimal","low","medium","high","xhigh","max"],$P=Symbol.for("@earendil-works/pi-tui/layout-node");ud=OD(MD);bm=class{folder;model;git;percent=0;meter=new pm(0);activity=zS();live=!1;activitySince=Date.now();thinking="medium";cubence="";constructor(t,n){this.folder=jD(t),this.model=n.split("/").at(-1)||"no-model",this.git=""}invalidate(){}settling(){return this.meter.moving}meterValue(){return this.meter.value!==this.percent&&this.meter.set(this.percent),this.meter.step()}beginRun(){this.live=!0,this.activitySince=Date.now()}waitedMs(){return Date.now()-this.activitySince}abandonAnimations(){this.meter.snap(this.percent)}render(t){let n=Date.now(),r=this.percent===0&&this.meter.value===0?0:this.meterValue(),o=_S(this.model,this.thinking,this.folder,this.git),s=[ri(`${NS(o,this.live?Xl():"",this.live?this.waitedMs():void 0)} ${qS(r,this.cubence)}`,t)],i=zv();i&&s.push(ri(te(i,D.warn),t));let c=Rv(Wu());c&&s.push(ri(te(c,D.accent),t));let p=VS(this.activity,Xl(),n),f=this.live?fS(p,{base:ql(this.waitedMs(),D.mute,D.warn,D.bad),bright:D.text,charMs:45},n):te(p,ql(this.waitedMs(),D.mute,D.warn,D.bad));return s.push(ri(f,t)),s}},Im=class{constructor(t){this.draw=t}draw;render(t){return this.draw(t)}invalidate(){}},$m=class{constructor(t,n){this.editor=t;this.hud=n}editor;hud;focused=!1;invalidate(){this.editor.invalidate()}render(t){let n=Math.max(10,t-4),r=this.editor.render(n).filter(c=>ym(c)>0),o=r.length>0?r:[""],s="\u2500".repeat(Math.max(0,t-2)),i=o.map(c=>{let p=Math.max(0,n-ym(c));return`\u2502 ${c}${" ".repeat(p)} \u2502`});return[`\u250C${s}\u2510`,...i,`\u2514${s}\u2518`,...this.hud.render(t)]}handleInput(t){this.editor.handleInput(t)}},XD=["deepseek","qwen","claude","gpt-5","gpt-4","gemini","glm","mimo","kimi","llama"],ZD=/(image|embedding|embed|whisper|tts|audio|video|rerank|moderation|dall-e|stable-diffusion|sora)/i;n_=1e3/30,r_=45e3});Ko();var Ad={off:!0,minimal:!0,low:!0,medium:!0,high:!0,xhigh:!0,max:!0},Rd={suggest:!0,"auto-edit":!0,"full-auto":!0};function pi(e,t,n){let r=e[t];if(r?.includes("="))return r.slice(r.indexOf("=")+1);let o=e[t+1];if(!o||o.startsWith("-"))throw new Error(`${n} needs a value`);return e.splice(t+1,1),o}function Md(e){let t={print:!1,continueSession:!1,noSession:!1,help:!1,version:!1,update:!1,checkUpdate:!1,prompt:""},n=[],r=[...e];for(let o=0;o<r.length;o++){let s=r[o]??"";if(s==="--"){n.push(...r.slice(o+1));break}if(s==="-h"||s==="--help")t.help=!0;else if(s==="-v"||s==="--version")t.version=!0;else if(s==="-p"||s==="--print")t.print=!0;else if(s==="-c"||s==="--continue")t.continueSession=!0;else if(s==="--no-session")t.noSession=!0;else if(s==="--update")t.update=!0;else if(s==="--check-update")t.checkUpdate=!0;else if(s==="-r"||s==="--resume")t.continueSession=!0;else if(s==="--session"||s.startsWith("--session="))t.sessionPath=pi(r,o,"--session");else if(s==="-m"||s==="--model"||s.startsWith("--model="))t.model=pi(r,o,"--model");else if(s==="--thinking"||s.startsWith("--thinking="))t.thinking=pi(r,o,"--thinking");else if(s==="--approval"||s.startsWith("--approval="))t.approval=pi(r,o,"--approval");else{if(s.startsWith("-"))throw new Error(`unknown option ${s}`);n.push(s)}}if(t.thinking&&!Ad[t.thinking])throw new Error(`thinking must be one of: ${Object.keys(Ad).join(", ")}`);if(t.approval&&!Rd[t.approval])throw new Error(`approval must be one of: ${Object.keys(Rd).join(", ")}`);if(t.prompt=n.join(" ").trim(),t.update&&t.checkUpdate)throw new Error("--update installs; --check-update only looks. pick one");if((t.update||t.checkUpdate)&&(t.print||t.continueSession||t.sessionPath||t.prompt))throw new Error("--update and --check-update act on the installation, not a session; they take no prompt");if(t.continueSession&&t.noSession)throw new Error("--continue and --no-session cannot be combined");if(t.sessionPath&&t.noSession)throw new Error("--session and --no-session cannot be combined");if(t.sessionPath&&t.continueSession)throw new Error("--session and --continue cannot be combined");if(t.print&&(t.continueSession||t.sessionPath))throw new Error("--print runs one prompt in a throwaway session; it cannot be combined with --continue or --session");if(t.sessionPath&&!t.sessionPath.endsWith(".jsonl"))throw new Error(`--session expects a session file, got '${t.sessionPath}'`);return t}function jm(){return`${at} ${Nt}
145
145
  coding agent. layout is a workbench, not a chat log.
146
146
 
147
147
  usage:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "howtofixcli",
3
- "version": "0.4.25",
3
+ "version": "0.4.26",
4
4
  "type": "module",
5
5
  "description": "HowToFix coding agent. Workbench TUI, sessions, background agents.",
6
6
  "license": "UNLICENSED",