howtofixcli 0.7.15 → 0.7.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{chunk-Y7YM5R75.js → chunk-5Y3G5FLR.js} +1 -1
- package/dist/{chunk-7DTQKDO4.js → chunk-7FD3JD6B.js} +1 -1
- package/dist/{chunk-DV2BBBBJ.js → chunk-AIQOTZSL.js} +1 -1
- package/dist/{chunk-V2RPZMLK.js → chunk-JLDLDP2U.js} +1 -1
- package/dist/{chunk-CPJKKHGH.js → chunk-KPOBCSCA.js} +1 -1
- package/dist/{chunk-LOOFOBTS.js → chunk-OD3QGNZU.js} +1 -1
- package/dist/{chunk-EIBOS5KO.js → chunk-ORFX4QTT.js} +1 -1
- package/dist/{chunk-EYWOVCSS.js → chunk-RC7UG24C.js} +1 -1
- package/dist/{chunk-SX5VE6XA.js → chunk-RYRVZAU6.js} +57 -51
- package/dist/{chunk-UNK5HRQR.js → chunk-SYR3CZ3C.js} +1 -1
- package/dist/{chunk-JMKK26AT.js → chunk-W7KLNX6W.js} +1 -1
- package/dist/chunk-WGBDEDF6.js +34 -0
- package/dist/main.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-HT3MFLAV.js +0 -34
|
@@ -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-
|
|
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-RC7UG24C.js";import"./chunk-UTYFLLSM.js";import"./chunk-W7KLNX6W.js";import"./chunk-5Y3G5FLR.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,2 +1,2 @@
|
|
|
1
|
-
import{b as o}from"./chunk-
|
|
1
|
+
import{b as o}from"./chunk-5Y3G5FLR.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};
|
|
@@ -0,0 +1,34 @@
|
|
|
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-RC7UG24C.js";import{g as oe,k as se}from"./chunk-AIQOTZSL.js";import"./chunk-UTYFLLSM.js";import"./chunk-W7KLNX6W.js";import{b as I,c as V,d as J}from"./chunk-5Y3G5FLR.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
|
+
`),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
|
+
|
|
4
|
+
${vt}`],t=Ot(Je);return t&&s.push(`# Standing instructions from ${Je}
|
|
5
|
+
${t}`),s}function Pt(e){return e.replace(/operating inside hxf, a coding agent harness/gi,"operating as HowToFix, a coding agent harness").replace(/^HowToFix documentation \(read only when the user asks about[^\n]*\):?$/gim,"Harness documentation (internal reference; the user is never told the harness name):").replace(/\bhxf itself\b/gi,"the harness itself").replace(/^- When reading hxf docs or examples/m,"- When reading harness docs or examples").replace(/^- When working on hxf topics/m,"- When working on harness topics").replace(/^- Always read hxf \.md files/m,"- Always read the harness .md files").replace(/\bhxf packages\b/gi,"harness packages").replace(/\bhxf \.md files\b/gi,"harness .md files").replace(/\bhxf docs\b/gi,"harness docs").replace(/^-\s*You can inspect HXF_\* environment variables/m,"- You can inspect the harness's environment variables")}var Rt=["preamble","rules","docs","addendum"];function Ct(e){if(!e)return;let o=!1,s={...e};for(let t of Rt){let n=s[t];if(typeof n!="string")continue;let r=Pt(n);r!==n&&(s[t]=r,o=!0)}return o?s:void 0}function et(){return e=>{e.on("context_with_system",async o=>{let s=o.messages[0];if(!s||s.role!=="system")return;let t=Ct(s.sections);return t?{messages:o.messages.map(r=>r===s?{...s,sections:t}:r)}:void 0})}}var x={hooks:{}},N;function tt(){return e=>{let o=ce(ie);x=o.config,N=void 0,le(),e.on("session_start",async(s,t)=>{for(let a of o.diagnostics)t.ui.notify(`hooks.json: ${a.message}`,"warning");let{outcome:n,ran:r}=await $(x,"SessionStart",{hook_event_name:"SessionStart",cwd:t.cwd},{cwd:t.cwd});n.context&&(N=n.context),n.error&&t.ui.notify(`SessionStart hook: ${n.error}`,"warning"),r&&N&&t.ui.notify(`SessionStart hooks added ${N.length} characters of context`,"info")}),e.on("input",async(s,t)=>{if(!x.hooks.UserPromptSubmit)return;let n={hook_event_name:"UserPromptSubmit",cwd:t.cwd,prompt:s.text},{outcome:r}=await $(x,"UserPromptSubmit",n,{cwd:t.cwd});if(r.error&&t.ui.notify(`UserPromptSubmit hook: ${r.error}`,"warning"),r.block)return t.ui.notify(r.reason??"blocked by a hook","warning"),{action:"handled"};if(r.context)return{action:"transform",text:`${s.text}
|
|
6
|
+
|
|
7
|
+
${r.context}`}}),e.on("tool_call",async(s,t)=>{if(!x.hooks.PreToolUse)return;let n={hook_event_name:"PreToolUse",cwd:t.cwd,tool_name:s.toolName,tool_input:s.input},{outcome:r}=await $(x,"PreToolUse",n,{cwd:t.cwd});if(r.error&&t.ui.notify(`PreToolUse hook: ${r.error}`,"warning"),r.block)return{block:!0,reason:r.reason??"blocked by a hook"};if(r.updatedInput){let i=e.getAllTools().find(f=>f.name===s.toolName)?.parameters;if(!i)t.ui.notify(`PreToolUse hook rewrote \`${s.toolName}\`, but no schema is known for that tool \u2014 the rewrite was ignored`,"warning");else{let f=ae(i,r.updatedInput);f?t.ui.notify(`PreToolUse hook rewrite ignored \u2014 ${f}`,"warning"):Object.assign(s.input,r.updatedInput)}}}),e.on("tool_result",async(s,t)=>{if(!x.hooks.PostToolUse)return;let n=s.content.map(i=>i.type==="text"?i.text:"").join(`
|
|
8
|
+
`),r={hook_event_name:"PostToolUse",cwd:t.cwd,tool_name:s.toolName,tool_input:s.input,tool_result:n,tool_is_error:s.isError},{outcome:a}=await $(x,"PostToolUse",r,{cwd:t.cwd});if(a.error&&t.ui.notify(`PostToolUse hook: ${a.error}`,"warning"),!!a.context)return{content:[...s.content,{type:"text",text:`
|
|
9
|
+
[hook] ${a.context}`}],structuredContent:s.structuredContent}}),e.on("context_with_system",async s=>{if(!N)return;let t=s.messages[0];if(!t||t.role!=="system")return;let n=`${C(t.content)}
|
|
10
|
+
|
|
11
|
+
${N}`;return{messages:s.messages.map(a=>a===t?{...t,content:D(t.content,n)}:a)}}),e.on("session_before_compact",async(s,t)=>{if(!x.hooks.PreCompact)return;let{outcome:n}=await $(x,"PreCompact",{hook_event_name:"PreCompact",cwd:t.cwd,compact_reason:s.reason},{cwd:t.cwd});n.error&&t.ui.notify(`PreCompact hook: ${n.error}`,"warning")}),e.on("session_shutdown",async(s,t)=>{if(!x.hooks.SessionEnd)return;let{outcome:n}=await $(x,"SessionEnd",{hook_event_name:"SessionEnd",cwd:t.cwd,reason:s.reason},{cwd:t.cwd});n.error&&t.ui.notify(`SessionEnd hook: ${n.error}`,"warning")}),e.on("agent_settled",async(s,t)=>{if(!x.hooks.Stop)return;let{outcome:n}=await $(x,"Stop",{hook_event_name:"Stop",cwd:t.cwd},{cwd:t.cwd});n.error&&t.ui.notify(`Stop hook: ${n.error}`,"warning")})}}var Dt=new Set(["bash","grep","find","ls","bash_output","powershell"]),Nt=new Set(["bash","bash_output","powershell"]),Ft=40,Mt=12,It=8,ot=6;function Lt(e,o){let s=e.trim();return!!(s===""||/^[-=*_~+#]{3,}$/.test(s)||o!==void 0&&e===o)}function nt(e){return e.replace(/\d+/g,"#").trimEnd()}function Gt(e){let o=[],s=0,t=0;for(;t<e.length;){let n=nt(e[t]);if(n===""||!/\d/.test(e[t])){o.push(e[t]),t+=1;continue}let r=t+1;for(;r<e.length&&nt(e[r])===n&&/\d/.test(e[r]);)r+=1;let a=r-t;if(a>=ot)o.push(e[t]),o.push(` \u2026 ${a-2} more line${a-2===1?"":"s"} of the same shape \u2026`),o.push(e[r-1]),s+=1;else for(let i=t;i<r;i+=1)o.push(e[i]);t=r}return{out:o,collapsed:s}}function Ut(e,o,s={}){if(o?.truncated)return;let t=e.split(`
|
|
12
|
+
`);if(t.length<Ft)return;let n=[],r=0;for(let g=0;g<t.length;g+=1){if(Lt(t[g],n[n.length-1])){if(t[g].trim()===""&&n[n.length-1]?.trim()!==""){n.push("");continue}r+=1;continue}n.push(t[g])}let a=s.toolName===void 0||Nt.has(s.toolName),{out:i,collapsed:f}=a?Gt(n):{out:n,collapsed:0},p=s.head??Mt,u=s.tail??It,c=i,d=0;if(i.length>p+u+ot&&(d=i.length-p-u,c=[...i.slice(0,p),` \u2026 ${d} line${d===1?"":"s"} omitted (${p} kept from the top, ${u} from the end) \u2026`,...i.slice(i.length-u)]),!(r+f===0&&d===0))return{text:c.join(`
|
|
13
|
+
`),stats:{before:t.length,after:c.length,collapsed:f}}}function st(e){return o=>{o.on("tool_result",s=>{if(!e.enabled()||s.isError||!Dt.has(s.toolName))return;let t=s.content.find(i=>i.type==="text");if(!t||t.type!=="text")return;let n=s.details,r=Ut(t.text,n,{toolName:s.toolName});return r?{content:s.content.map(i=>i===t?{type:"text",text:r.text}:i)}:void 0})}}import{readdirSync as Bt,readFileSync as Ht,statSync as Wt}from"node:fs";import{extname as zt,join as rt,relative as qt,resolve as Zt,sep as it}from"node:path";import{Type as P}from"@netrodev/hxf-ai";import{defineTool as Kt}from"@netrodev/hxf-coding-agent";var Xt=new Set(["node_modules",".git","dist","build","out","coverage","vendor","target","__pycache__",".venv","venv",".next",".turbo",".cache"]),v={".ts":{kind:"ts",patterns:[/^\s*export\s+(?:default\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/gm,/^\s*export\s+(?:abstract\s+)?class\s+([A-Za-z_$][\w$]*)/gm,/^\s*export\s+(?:interface|type)\s+([A-Za-z_$][\w$]*)/gm,/^\s*export\s+const\s+([A-Za-z_$][\w$]*)/gm,/^\s*(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/gm,/^\s*(?:export\s+)?class\s+([A-Za-z_$][\w$]*)/gm]},".tsx":{kind:"tsx",patterns:[]},".js":{kind:"js",patterns:[]},".mjs":{kind:"js",patterns:[]},".go":{kind:"go",patterns:[/^func\s+(?:\([^)]*\)\s*)?([A-Za-z_]\w*)/gm,/^type\s+([A-Za-z_]\w*)\s+(?:struct|interface)/gm]},".py":{kind:"py",patterns:[/^(?:async\s+)?def\s+([A-Za-z_]\w*)/gm,/^class\s+([A-Za-z_]\w*)/gm]},".rs":{kind:"rs",patterns:[/^\s*(?:pub\s+)?(?:async\s+)?fn\s+([A-Za-z_]\w*)/gm,/^\s*(?:pub\s+)?(?:struct|enum|trait)\s+([A-Za-z_]\w*)/gm]}};v[".tsx"].patterns=v[".ts"].patterns;v[".js"].patterns=v[".ts"].patterns;v[".mjs"].patterns=v[".ts"].patterns;var Yt=512*1024,Vt=12;function Jt(e,o){let s=v[o];if(!s)return[];let t=new Set,n=[];for(let r of s.patterns){r.lastIndex=0;for(let a of e.matchAll(r)){let i=a[1];i&&!t.has(i)&&(t.add(i),n.push(i))}}return n}function Qt(e,o){let s=new Set,t=n=>{n&&(n.startsWith("./")||n.startsWith("../"))&&s.add(n)};if(o===".ts"||o===".tsx"||o===".js"||o===".mjs"){for(let n of e.matchAll(/(?:from|require\()\s*["']([^"']+)["']/g))t(n[1]);for(let n of e.matchAll(/^\s*import\s+["']([^"']+)["']/gm))t(n[1])}else if(o===".go")for(let n of e.matchAll(/^\s*(?:[\w.]+\s+)?"([^"]+)"/gm))t(n[1]);else if(o===".py")for(let n of e.matchAll(/^\s*from\s+(\.+[\w.]*)\s+import/gm)){let r=n[1].replace(/\./g,"/");t(r.startsWith("/")?`.${r}`:`./${r}`)}else if(o===".rs")for(let n of e.matchAll(/^\s*use\s+(?:crate|super|self)::([\w:]+)/gm))t(`./${n[1].split("::").join("/")}`);return[...s]}function en(e,o,s){let t=e.split("/").slice(0,-1).join("/"),n=rt(t,o).split(it).join("/").replace(/^\.\//,"");return[n,`${n}.ts`,`${n}.tsx`,`${n}.js`,`${n}.mjs`,`${n}.go`,`${n}.py`,`${n}.rs`,`${n}/index.ts`,`${n}/index.tsx`,`${n}/index.js`,`${n}/mod.rs`,`${n}.py`].find(a=>s.has(a))}function tn(e,o="."){let s=[],t=(n,r)=>{if(r>Vt)return;let a;try{a=Bt(n,{withFileTypes:!0})}catch{return}for(let i of a){let f=rt(n,i.name);if(i.isDirectory()){if(Xt.has(i.name)||i.name.startsWith("."))continue;t(f,r+1);continue}let p=zt(i.name);if(v[p])try{if(Wt(f).size>Yt)continue;let u=Ht(f,"utf8"),c=qt(e,f).split(it).join("/");s.push({path:c,symbols:Jt(u,p),imports:Qt(u,p)})}catch{}}};return t(Zt(e,o),0),s}function nn(e,o){if(e.length===0)return[];let s=new Set(e.map(c=>c.path)),t=new Map(e.map((c,d)=>[c.path,d])),n=e.map(()=>[]),r=e.map(()=>[]);e.forEach((c,d)=>{for(let l of c.imports){let g=en(c.path,l,s);if(!g||g===c.path)continue;let b=t.get(g);b!==void 0&&(n[d].push(b),r[b].push(d))}});let a=e.length,i=o?.trim().toLowerCase(),f=e.map(c=>i&&`${c.path} ${c.symbols.join(" ")}`.toLowerCase().includes(i)?4/a:1/a),p=f.reduce((c,d)=>c+d,0),u=e.map((c,d)=>f[d]/p);for(let c=0;c<20;c++){let d=e.map((l,g)=>.15*(f[g]/p));for(let l=0;l<a;l++){if(n[l].length===0){for(let g=0;g<a;g++)d[g]+=.85*u[l]/a;continue}for(let g of n[l])d[g]+=.85*u[l]/n[l].length}u=d}return e.map((c,d)=>({file:c,score:u[d],match:i?`${c.path} ${c.symbols.join(" ")}`.toLowerCase().includes(i):!1})).sort((c,d)=>Number(d.match)-Number(c.match)||d.score-c.score||c.file.path.localeCompare(d.file.path)).map(c=>c.file)}function on(e,o={}){let t=Math.max(200,Math.min(8e3,o.budget??1200))*4,n=nn(e,o.query),r=[],a=0;for(let f of n){let p=f.symbols.slice(0,8).join(", "),u=p?`${f.path}: ${p}`:`${f.path}`;if(a+u.length+1>t)break;r.push(u),a+=u.length+1}if(r.length===0)return"(no source files found)";let i=n.length-r.length;return i>0&&r.push(`\u2026 ${i} more file${i===1?"":"s"} not shown`),r.join(`
|
|
14
|
+
`)}var at;function ct(e){at=e}var lt=Kt({name:"repo_map",label:"repo_map",description:"A ranked outline of the repository: files by importance with their top declarations. Use it to find where something lives before reading files, instead of listing directories.",promptSnippet:"repo_map: ranked file outline of the project",parameters:P.Object({path:P.Optional(P.String({description:"Subdirectory to map, relative to the project root"})),query:P.Optional(P.String({description:"Keyword to bias the ranking, e.g. 'billing'"})),budget:P.Optional(P.Number({description:"Token budget, default 1200"}))}),async execute(e,o){let s=at?.()??process.cwd(),t=tn(s,o.path??".");return{content:[{type:"text",text:on(t,{budget:o.budget,query:o.query})}],details:{files:t.length}}}});function q(){return{consecutiveFailures:0,tripped:!1}}function sn(e,o){return o==="manual"?!1:e.consecutiveFailures>=3}function rn(e,o){if(o)return e;let s=e.consecutiveFailures+1;return{consecutiveFailures:s,tripped:e.tripped||s>=3}}function an(){return q()}function cn(e){return[`Auto-compaction failed ${e.consecutiveFailures} times in a row, so it is switched off for this session.`,"The context is over the limit and compaction cannot recover it. Start a new session, or switch to a model with a larger context window.","Manual /compact is still allowed."].join(" ")}var j=q();function dt(){return e=>{e.on("session_start",async()=>{j=q()}),e.on("session_compact",async()=>{j=an()}),e.on("session_compact_failed",async(o,s)=>{let t=j;j=rn(j,o.aborted),!t.tripped&&j.tripped&&s?.ui&&s.ui.notify(cn(j),"warning")}),e.on("session_before_compact",async o=>{if(sn(j,o.reason))return{cancel:!0}})}}function ln(e){A(M(e))}function pt(e){return`budget exhausted (${e.budget??"default"} continuations)`}function ut(){return e=>{e.on("session_start",async(o,s)=>{ln(s)}),e.on("context_with_system",async(o,s)=>{let t=M(s);if(A(t),!t||t.status!=="active")return;let n=o.messages[0];if(!n||n.role!=="system")return;let r=`${C(n.content)}
|
|
15
|
+
|
|
16
|
+
${Te(t)}`;return{messages:o.messages.map(i=>i===n?{...n,content:D(n.content,r)}:i)}}),e.on("agent_before_settle",async(o,s)=>{try{let t=M(s);if(A(t),G(t).action==="stop"||!t||o.continue||!o.context.canContinue)return;let n={...t,used:t.used+1};if(e.appendEntry(L,n),A(n),G(n).action==="stop"){let r={...n,status:"done",note:pt(n)};e.appendEntry(L,r),A(r);return}return{entries:[{type:"custom_message",customType:_e,content:$e(n),display:!0}],continue:!0}}catch{return}}),e.on("agent_settled",async(o,s)=>{try{let t=M(s),n=G(t);if(t&&n.action==="stop"&&n.close){let r={...t,status:"done",note:pt(t)};e.appendEntry(L,r),A(r)}else A(t)}catch{return}})}}function dn(e){let o=ee(e);return o.length===0?"":["The user installed the following presets. Their rules apply to this session.","",...o.map(t=>`<preset name="${t.name}">
|
|
17
|
+
${t.text}
|
|
18
|
+
</preset>`)].join(`
|
|
19
|
+
`)}function ft(e){return o=>{o.on("resources_discover",async()=>{let s=Q(e);return s.length>0?{skillPaths:s}:void 0}),o.on("context_with_system",async s=>{let t=dn(e);if(!t)return;let n=s.messages[0];if(!n||n.role!=="system")return;let r=`${C(n.content)}
|
|
20
|
+
|
|
21
|
+
${t}`;return{messages:s.messages.map(i=>i===n?{...n,content:D(n.content,r)}:i)}})}}import{Type as w}from"@netrodev/hxf-ai";import{defineTool as pn}from"@netrodev/hxf-coding-agent";function un(){return[...U.values()].map(e=>`${e.name} (${e.description})`).join(", ")}function mt(){return pn({name:"task",label:"task",description:`Spawn subagents. Available: ${un()}. One call can carry tasks[]; each item may set agent, model, effort and isolation. Agents run concurrently, park when done, and can be resumed or messaged with /agents. Pass background: true to return as soon as they start instead of waiting for them. Use architect to design an approach before a large change. Set isolation: "worktree" on every task that writes files.`,promptSnippet:"task: spawn background agents",parameters:w.Object({agent:w.Optional(w.String()),effort:w.Optional(w.String()),model:w.Optional(w.String()),task:w.Optional(w.String()),isolation:w.Optional(w.String()),background:w.Optional(w.Boolean()),tasks:w.Optional(w.Array(w.Object({agent:w.Optional(w.String()),effort:w.Optional(w.String()),model:w.Optional(w.String()),task:w.String(),isolation:w.Optional(w.String())})))}),executionMode:"parallel",async execute(e,o,s,t,n){let r=o.tasks&&o.tasks.length>0?o.tasks.map(l=>({agent:l.agent??o.agent??"task",task:l.task,effort:l.effort??o.effort,model:l.model??o.model,isolation:l.isolation??o.isolation})):[{agent:o.agent??"task",task:o.task??"",effort:o.effort,model:o.model,isolation:o.isolation}],a=r.slice(0,z),i=r.length-a.length,f=!!o.background,p=[],u=[],c=[],d=[];try{for(let m of a){if(!m.task.trim())continue;let _;if(m.isolation==="worktree"){let h=await Xe(n?.cwd??process.cwd(),m.agent);if(h){u.push(h),_=h.path;for(let S of h.skipped)d.push(`${m.agent}:${S}`)}else c.push(m.agent)}p.push(await qe({...m,cwd:n?.cwd,background:f,parentModel:ze(n?.model),worktree:_})),t?.({content:[],details:{agents:p.map(h=>({id:h.id,agent:h.agent,status:h.status}))}})}if(p.length===0)throw new Error("task or tasks is required");let l=i>0?`(only the first ${z} of ${r.length} tasks ran)`:"",g=p.filter(m=>m.worktree).length,b=[l,c.length>0?`isolation: "worktree" was requested but not available for: ${c.join(", ")}. Those agents ran in the shared working tree \u2014 check their edits for collisions before trusting them.`:"",d.length>0?`too large to copy into the isolated worktree, so it was left out: ${d.join(", ")}. An agent that needs it cannot install or build \u2014 treat any "done" from those runs as unverified.`:""].filter(Boolean),y={agents:p.map(m=>({id:m.id,status:m.status,isolated:!!m.worktree}))};if(f){Ze();let m=p.map(_=>`${_.agent}#${_.id}`).join(", ");return{content:[{type:"text",text:`started ${p.length} agent${p.length===1?"":"s"} in the background: ${m}.`+(g>0?` ${g} of them in their own worktree.`:"")+`
|
|
22
|
+
Their results are not part of this turn \u2014 keep working. Read them with /agents, or message one with /agents <id> <text>.`+(b.length>0?`
|
|
23
|
+
${b.join(`
|
|
24
|
+
`)}`:"")}],details:y}}await Ke(s);let T=p.map(m=>`${We(m)}${m.worktree?" [isolated]":""}
|
|
25
|
+
${m.result??""}`);return b.length>0&&T.push(b.join(`
|
|
26
|
+
`)),{content:[{type:"text",text:T.join(`
|
|
27
|
+
|
|
28
|
+
`)}],details:y}}finally{for(let l of u)try{await l.remove()}catch{}}}})}import{readFileSync as fn,readdirSync as mn,statSync as gn}from"node:fs";import{dirname as hn,join as Z}from"node:path";import{getAgentDir as wn,parseFrontmatter as yn}from"@netrodev/hxf-coding-agent";var gt=["off","minimal","low","medium","high","xhigh","max"],bn=["name","description","tools","model","effort"],kn=["read","bash","edit","write","grep","find","ls","bash_output","kill_shell","todo","context","goal","task","workflow","web_search","web_fetch","lsp","quality","slop","claim","repo_map"],xn=["read","bash","edit","write","grep","find","ls","context","todo","web_search","web_fetch","lsp","claim"];function Sn(e){let s=(typeof e=="string"?e.split(","):Array.isArray(e)?e:[]).map(t=>String(t).trim().replace(/^["']|["']$/g,"")).filter(Boolean);return s.length>0?s:void 0}function _n(e){try{return gn(e).isDirectory()}catch{return!1}}function Tn(e){let o=e;for(;;){let s=Z(o,".howtofix","agents");if(_n(s))return s;let t=hn(o);if(t===o)return;o=t}}function $n(e){let o=[{scope:"user",dir:Z(wn(),"agents")}],s=Tn(e);return s&&o.push({scope:"project",dir:s}),o}function En(e,o){let s=[],t=[],n=e.replace(/^\uFEFF/,"");if(!/^---\r?\n/.test(n))return{notes:s,problems:[`${o}: no frontmatter \u2014 the file must start with --- and end the block with ---`]};let r={},a="";try{let m=yn(n);r=m.frontmatter??{},a=(m.body??"").trim()}catch(m){return{notes:s,problems:[`${o}: the frontmatter is not readable YAML \u2014 ${m instanceof Error?m.message:String(m)}`]}}for(let m of Object.keys(r))bn.includes(m)||s.push(`${o}: ignoring the unknown frontmatter key '${m}'`);let i=(o.split(/[\\/]/).pop()??o).replace(/\.md$/i,""),f=r.name,p=(typeof f=="string"&&f.trim()?f:i).trim();/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(p)||t.push(`${o}: '${p}' is not a usable agent name \u2014 letters, digits, dot, dash and underscore only`);let u=r.description,c=typeof u=="string"?u.trim():"";c||t.push(`${o}: a description is required \u2014 it is how the model decides to use this agent`),a||t.push(`${o}: no prompt body \u2014 the text below the frontmatter is the agent's standing instruction`);let d=r.effort,l=typeof d=="string"?d.trim().toLowerCase():"";l&&!gt.includes(l)&&t.push(`${o}: effort '${l}' is not one of ${gt.join(", ")}`);let g=Sn(r.tools),b=g??[...xn];if(g){let m=g.filter(_=>!kn.includes(_)&&!_.startsWith("mcp__"));m.length>0&&s.push(`${o}: unknown tool${m.length===1?"":"s"} ${m.join(", ")} \u2014 kept, but nothing registers them yet`)}let y=r.model,T=typeof y=="string"&&y.trim()?y.trim():void 0;return t.length>0?{notes:s,problems:t}:{def:{name:p,description:c,tools:b,prompt:a,effort:l||"medium",model:T,source:o},notes:s,problems:t}}function ht(e,o){let s=[],t=[],n=[],r=[];for(let{scope:a,dir:i}of $n(e)){let f;try{f=mn(i)}catch{continue}for(let p of f.filter(u=>u.toLowerCase().endsWith(".md")).sort()){let u=Z(i,p),c;try{c=fn(u,"utf8")}catch(g){n.push(`${u}: ${g instanceof Error?g.message:String(g)}`);continue}let d=En(c,u);t.push(...d.notes),n.push(...d.problems);let l=d.def;l&&(o.has(l.name)&&t.push(`${u}: replaces ${He.has(l.name)?"the built-in":"an earlier"} '${l.name}'`),o.set(l.name,l),s.push(l),r.includes(a)||r.push(a))}}if(s.length>0){let a=s.filter(i=>o.get(i.name)===i);t.unshift(`loaded ${a.length} subagent definition${a.length===1?"":"s"} (${r.join(" and ")}): ${a.map(i=>i.name).join(", ")}`)}return{loaded:s,notes:t,problems:n}}var An=["grep","find","ls","bash_output","kill_shell"];async function wt(e,{timeoutMs:o=2e3,quietTicks:s=2}={}){let t=Date.now()+o,n=e.getActiveToolNames().length,r=0;for(;Date.now()<t&&r<s;){await new Promise(i=>setTimeout(i,50));let a=e.getActiveToolNames().length;a>n?(n=a,r=0):r+=1}}function yt(e){let o=new Set(e.getActiveToolNames()),s=new Set(e.getAllTools().map(n=>n.name)),t=[];for(let n of An)s.has(n)&&!o.has(n)&&(o.add(n),t.push(n));return t.length>0&&e.setActiveToolsByName([...o]),t}import{spawnSync as vn}from"node:child_process";import{join as jn}from"node:path";import{defineTool as On}from"@netrodev/hxf-coding-agent";var Pn=6e3,bt=On({name:"slop",label:"slop",description:"Check code against the project's slop gate: naming, comments, placeholder values, swallowed errors, and the LLM tells that appear in model-written code. Read-only. Use it before reporting a task finished; it returns each finding as a rule id, a line, and what is wrong, so a claim of clean code becomes something the user can verify. Defaults to the changed files; pass a path to narrow it.",promptSnippet:"slop: naming, comment and placeholder findings for changed code",parameters:E.Object({path:E.Optional(E.String({description:"One file or directory, relative to the project root. Omit to scan the changed set."})),changes:E.Optional(E.Boolean({description:"Scan only files changed against the base ref. Default true when path is omitted."})),base:E.Optional(E.String({description:"Git ref for `changes`. Defaults to HEAD."}))}),async execute(e,o,s,t,n){let r=n.cwd??process.cwd(),i=[jn(r,"scripts","slop.mjs"),"--json"];o.path!==void 0?i.push(o.path):(o.changes??!0)&&i.push("--changes"),o.base!==void 0&&i.push("--base",o.base);let f=vn("node",i,{cwd:r,encoding:"utf8",timeout:12e4}),p;try{p=JSON.parse(f.stdout)}catch{p=void 0}if(!p){let b=(f.stderr||f.stdout||"").trim()||f.error?.message||(f.signal?`killed by ${f.signal} (timed out after 120 s?)`:"no output");return{content:[{type:"text",text:`slop gate produced no report: ${b.slice(0,400)}`}],details:{error:b.slice(0,400)}}}if(p.off)return{content:[{type:"text",text:"slop gate is off"}],details:{off:!0}};let u=p.files??{},c=[],d=0;for(let[b,y]of Object.entries(u)){c.push(`${b}`);for(let T of y)d+=1,c.push(` ${T.rule} L${T.line} ${T.message}`)}if(d===0)return{content:[{type:"text",text:"slop gate: no findings in the scanned files"}],details:{files:Object.keys(u).length,findings:0}};let l=c.join(`
|
|
29
|
+
`).slice(0,Pn),g=l.length<c.join(`
|
|
30
|
+
`).length?`
|
|
31
|
+
\u2026 truncated`:"";return{content:[{type:"text",text:`${d} finding${d===1?"":"s"}:
|
|
32
|
+
|
|
33
|
+
${l}${g}`}],details:{files:Object.keys(u).length,findings:d}}}});function K(e){return e.extensionRunner.emit({type:"session_shutdown",reason:"quit"}).catch(()=>{}).finally(()=>e.dispose())}import{readdir as kt,rmdir as Rn,stat as Cn,unlink as Dn}from"node:fs/promises";import{dirname as Nn,join as X,resolve as xt}from"node:path";async function St(e={}){let o={removed:[],failed:[],removedDirs:[]},s=X(e.agentDir??k,"sessions"),t=(e.now??Date.now())-Ve*24*60*60*1e3,n=e.keep?xt(e.keep):void 0,r;try{r=await kt(s,{withFileTypes:!0})}catch{return o}for(let a of r){if(!a.isDirectory())continue;let i=X(s,a.name),f;try{f=await kt(i)}catch{continue}let p=f.filter(u=>!u.endsWith(".jsonl"));for(let u of f){if(!u.endsWith(".jsonl"))continue;let c=X(i,u),d;try{n&&xt(c)===n?d=!1:d=(await Cn(c)).mtimeMs<t}catch{d=!1}if(!d){p.push(u);continue}try{await Dn(c),o.removed.push(c)}catch{o.failed.push(c),p.push(u)}}if(p.length===0){if(n&&Nn(n)===i)continue;try{await Rn(i),o.removedDirs.push(i)}catch{}}}return o}var Y="howtofix.build",Ts=["read","repo_map","bash","edit","write","grep","find","ls","bash_output","kill_shell","task","think","ask","claim","sessions","todo","context","goal","enter_plan_mode","exit_plan_mode","workflow","web_search","web_fetch","lsp","quality","compress","slop"],Hn=()=>({exclude:process.platform==="win32"?[]:["powershell"]}),Tt=!1;async function $s(e){let o=new Un(k),s=Bn.create(e.cwd,k,{projectTrusted:o.get(e.cwd)===!0}),t=pe(k).compressToolOutput,n=e.sessionPath?B.open(e.sessionPath):e.noSession?B.inMemory(e.cwd):e.continueSession?B.continueRecent(e.cwd):B.create(e.cwd),r=(()=>{try{let S=n.getEntries().find(F=>F.type==="custom"&&F.customType===Y)?.data?.version;return!S||S===I?void 0:`this session was written by HowToFix ${S}; you are running ${I}`}catch{return}})(),a=new Gn({cwd:e.cwd,agentDir:k,settingsManager:s,appendSystemPrompt:Qe(V,e.interactive??!0),additionalSkillPaths:te(e.cwd),extensionFactories:[Ae(),re(),et(),tt(),Ne(),Pe(),ft(e.cwd),ut(),ve(),dt(),In(),st({enabled:()=>t}),Ln({loadConfig:h=>de({cwd:h.cwd,projectTrusted:h.isProjectTrusted?.()??!1})})]});await a.reload();let i=ht(e.cwd,U),f=mt(),p=n.getSessionId();ct(()=>e.cwd);let u=_t(k,fe);ye({root:()=>e.cwd,holder:()=>`session:${p}`,presenceDir:()=>u,selfId:()=>p});let c=()=>{try{me({dir:u},{id:p,cwd:e.cwd,host:Fn(),pid:process.pid,at:Date.now()})}catch{}};c();let d=setInterval(c,Math.max(5e3,Math.floor(ue/3)));d.unref?.();let l=await Mn({cwd:e.cwd,agentDir:k,settingsManager:s,sessionManager:n,resourceLoader:a,excludeTools:Hn().exclude,customTools:[f,lt,he,we,ke,be,xe,Se,Ee,je,Oe,Ye(),Fe,Me,Le,Ge,bt,Re({state:()=>Ce(W()??"dcp-sessionless"),messages:()=>De(W()??"dcp-sessionless")})],thinkingLevel:e.thinking});await l.session.bindExtensions({mode:"print",onError:()=>{}});let g=oe(k),b=[];if(g){let h=await se(k,g);h.renewed?await l.session.modelRuntime.setRuntimeApiKey("howtofix",h.credential.accessToken):(h.terminal&&h.message||h.message)&&b.push(h.message)}await wt(l.session),yt(l.session);let y=l.session.model;if(e.model){let h=await l.session.modelRuntime.getAvailable(),S=Ue(h,e.model);if(!S)throw await K(l.session),new Error(`unknown model '${e.model}'`);(y?.id!==S.id||y.provider!==S.provider)&&(await l.session.setModel(S),y=l.session.model)}else{let h=await l.session.modelRuntime.getAvailable(),S=new Map,F=[];for(let O of h){let R=S.get(O.provider);R===void 0&&(R=!!(await l.session.modelRuntime.getAuth(O.provider))?.auth?.apiKey,S.set(O.provider,R)),R&&F.push(O)}let H=ne;if(!H.includes(y?.provider??"")){let O=Be(F.filter(R=>H.includes(R.provider)),H);O&&(await l.session.setModel(O),y=l.session.model)}}if(!e.noSession&&n.getEntries().every(h=>h.type!=="custom"||h.customType!==Y))try{n.appendCustomEntry(Y,{version:I})}catch{}Tt||(Tt=!0,St({keep:l.session.sessionFile}).catch(()=>{}));let T=y?`${y.provider}/${y.id}`:"no model",m=!!(y&&y.cost&&(y.cost.input>0||y.cost.output>0)),_=[J(l.modelFallbackMessage),...b,...i.notes,...i.problems].filter(h=>!!h);return y||_.push(`no model configured. run \`howtofix\` and use /login, or edit ${_t(k,"models.json")}`),{session:l.session,dispose:async()=>{Ie(),await K(l.session),clearInterval(d),ge({dir:u},p)},modelLabel:T,priced:m,setCompressToolOutput:h=>{t=h},note:[r,..._].filter(Boolean).join(`
|
|
34
|
+
`)||void 0}}export{Y as BUILD_ENTRY,Ts as MAIN_TOOLS,$s as openSession};
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{b as U,c as I}from"./chunk-6FUWMLWO.js";import{b as N}from"./chunk-YW7NORH3.js";import{a as R,b as O}from"./chunk-AGGIYXN7.js";import{D as j,K as F}from"./chunk-V656XVXV.js";import"./chunk-UTYFLLSM.js";import{a as r,b as x}from"./chunk-
|
|
2
|
+
import{b as U,c as I}from"./chunk-6FUWMLWO.js";import{b as N}from"./chunk-YW7NORH3.js";import{a as R,b as O}from"./chunk-AGGIYXN7.js";import{D as j,K as F}from"./chunk-V656XVXV.js";import"./chunk-UTYFLLSM.js";import{a as r,b as x}from"./chunk-5Y3G5FLR.js";import"./chunk-WOT6VMZA.js";var W={rpc:!0,acp:!0},B={off:!0,minimal:!0,low:!0,medium:!0,high:!0,xhigh:!0,max:!0},L={suggest:!0,"auto-edit":!0,"full-auto":!0},D={text:!0,json:!0,"stream-json":!0};function he(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 v(c,e,l){let d=c[e];if(d?.includes("="))return d.slice(d.indexOf("=")+1);let p=c[e+1];if(!p||p.startsWith("-"))throw new Error(`${l} needs a value`);return c.splice(e+1,1),p}function G(c){let e={print:!1,continueSession:!1,noSession:!1,help:!1,version:!1,update:!1,checkUpdate:!1,outputFormat:"text",dangerouslySkipPermissions:!1,sandbox:!1,prompt:""},l=[],d=[...c];for(let p=0;p<d.length;p++){let s=d[p]??"";if(s==="--"){l.push(...d.slice(p+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=v(d,p,"--session");else if(s==="-m"||s==="--model"||s.startsWith("--model="))e.model=v(d,p,"--model");else if(s==="--thinking"||s.startsWith("--thinking="))e.thinking=v(d,p,"--thinking");else if(s==="--approval"||s.startsWith("--approval="))e.approval=v(d,p,"--approval");else if(s==="--output-format"||s.startsWith("--output-format="))e.outputFormat=v(d,p,"--output-format");else if(s==="--max-budget-usd"||s.startsWith("--max-budget-usd="))e.maxBudgetUsd=he(v(d,p,"--max-budget-usd"));else if(s==="--mode"||s.startsWith("--mode=")){let h=v(d,p,"--mode");if(!W[h])throw new Error(`--mode must be one of: ${Object.keys(W).join(", ")}`);e.mode=h}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}`);l.push(s)}}if(e.thinking&&!B[e.thinking])throw new Error(`thinking must be one of: ${Object.keys(B).join(", ")}`);if(e.approval&&!L[e.approval])throw new Error(`approval must be one of: ${Object.keys(L).join(", ")}`);if(!D[e.outputFormat])throw new Error(`output-format must be one of: ${Object.keys(D).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=l.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 P(){return`${r} ${x}
|
|
3
3
|
coding agent. layout is a workbench, not a chat log.
|
|
4
4
|
|
|
5
5
|
usage:
|
|
@@ -59,7 +59,7 @@ commands:
|
|
|
59
59
|
/copy /agents /goal /plan /workflow /session /help /quit /exit
|
|
60
60
|
/dcp /context /decompress /sweep
|
|
61
61
|
/update /usage /sync
|
|
62
|
-
/skills /preset /settings /proxy /roblox
|
|
62
|
+
/skills /preset /settings /trust /proxy /roblox
|
|
63
63
|
/roblox login|logout|status|tunnel manages the Roblox connection: sign in with Roblox
|
|
64
64
|
(no API key), see what is connected, and link this machine to the hosted workspace.
|
|
65
65
|
|
|
@@ -90,11 +90,11 @@ 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 fe(c,e=!1){let{message:l}=R(c);if(!e)return l;let d=c instanceof Error?c.stack:void 0;return d&&d.includes(`
|
|
92
92
|
`)?`${l}
|
|
93
|
-
${d}`:l}function H(c,e){let l=e?.debug??process.env.HOWTOFIX_DEBUG==="1",d=e?.exit??(s=>process.exit(s)),p=s=>{console.error(`${c}: ${fe(s,l)}`),d(1)};process.on("uncaughtException",p),process.on("unhandledRejection",p)}function ge(){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 we(){process.stdout.on("error",c=>{throw c.code==="EPIPE"&&process.exit(0),c})}async function ke(){we(),F();let c=performance.now(),e=ge();if("error"in e){console.error(`${r}: ${e.error}`),process.exitCode=1;return}let l=e.cwd,d=process.env.HXF_FAKE_NODE??process.versions.node,[p,s]=d.split(".").map(o=>Number.parseInt(o,10));if(!Number.isFinite(p)||p<22||p===22&&Number.isFinite(s)&&s<19){console.error(`${r}: 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(P());return}if(o.some(a=>a==="-v"||a==="--version")){console.log(`${r} ${x}`);return}return}let h=process.argv.slice(2);if(h[0]==="doctor"||h[0]==="models"||h[0]==="sessions"){let o=h[0];try{let a=await import("./chunk-
|
|
94
|
-
${P()}`),process.exitCode=2;return}if(S.print&&!S.prompt){console.error(`${r}: --print needs a prompt`),process.exitCode=2;return}let{repairGatewayModels:J,ensureGatewaySettings:V,repairModelFacts:q,syncGatewayModelsOnStart:K,checkAccount:Y,fetchGatewayPrices:z}=await import("./chunk-
|
|
93
|
+
${d}`:l}function H(c,e){let l=e?.debug??process.env.HOWTOFIX_DEBUG==="1",d=e?.exit??(s=>process.exit(s)),p=s=>{console.error(`${c}: ${fe(s,l)}`),d(1)};process.on("uncaughtException",p),process.on("unhandledRejection",p)}function ge(){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 we(){process.stdout.on("error",c=>{throw c.code==="EPIPE"&&process.exit(0),c})}async function ke(){we(),F();let c=performance.now(),e=ge();if("error"in e){console.error(`${r}: ${e.error}`),process.exitCode=1;return}let l=e.cwd,d=process.env.HXF_FAKE_NODE??process.versions.node,[p,s]=d.split(".").map(o=>Number.parseInt(o,10));if(!Number.isFinite(p)||p<22||p===22&&Number.isFinite(s)&&s<19){console.error(`${r}: 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(P());return}if(o.some(a=>a==="-v"||a==="--version")){console.log(`${r} ${x}`);return}return}let h=process.argv.slice(2);if(h[0]==="doctor"||h[0]==="models"||h[0]==="sessions"){let o=h[0];try{let a=await import("./chunk-ORFX4QTT.js");o==="doctor"?process.exitCode=await a.runDoctor():o==="models"?process.exitCode=a.runModels():process.exitCode=a.runSessions(h.slice(1))}catch(a){O(r,o,a),process.exitCode=1}return}let X=h[0]==="acp"?["--acp",...h.slice(1)]:h,S;try{S=G(X)}catch(o){let a=o instanceof Error?o.message:String(o);console.error(`${r}: ${a}
|
|
94
|
+
${P()}`),process.exitCode=2;return}if(S.print&&!S.prompt){console.error(`${r}: --print needs a prompt`),process.exitCode=2;return}let{repairGatewayModels:J,ensureGatewaySettings:V,repairModelFacts:q,syncGatewayModelsOnStart:K,checkAccount:Y,fetchGatewayPrices:z}=await import("./chunk-SYR3CZ3C.js"),{readCliCredential:Q,renewCliCredentialIfNeeded:Z}=await import("./chunk-KPOBCSCA.js"),{AGENT_DIR:w}=await import("./chunk-GXB7RZHH.js"),A=J(w);A>0&&console.error(`${r}: repaired ${A} howtofix model(s) that the gateway would have rejected`);let _,C;try{let o=Q(w);if(o){let b=(await Z(w,o)).credential.accessToken,[m,f]=await Promise.all([z(b),Y(b)]);m.size>0&&(_=m),f.ok&&(C=f.models)}}catch{}let $=await q(w,_?{prices:_}:void 0);if($.changed>0?console.error(`${r}: filled in the context window, reasoning flag and price for ${$.changed} model(s)`):$.message&&console.error(`${r}: model catalogue unavailable (${$.message}); context windows stay at their conservative defaults`),V(w)&&console.error(`${r}: set httpIdleTimeoutMs in settings.json so a stalled provider recovers instead of hanging`),C)try{let o=await K(w,C,_);o.added>0&&console.error(`${r}: added ${o.added} model(s) this account can now reach`)}catch{}let t=S;if(t.help){console.log(P());return}if(t.version){console.log(`${r} ${x}`);let{cliSigningKeyMatchesPanel:o,cliSigningKeyFingerprint:a}=await import("./chunk-OD3QGNZU.js");o()||(console.error(`${r}: 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:b}=await import("./chunk-N345KWWK.js"),m=o();if(!m){console.error(`${r}: --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(b(m)),process.exitCode=a(m,{cwd:l,agentDir:j,argv:[process.execPath,...process.argv.slice(1)]});return}let{installProxy:ee}=await import("./chunk-WKUJ7CFO.js");if(ee(j),t.update||t.checkUpdate){let{PACKAGE_NAME:o,checkForUpdate:a,installUpdate:b,isInstalledCopy:m}=await import("./chunk-7CHDNTH6.js"),f=await a(x);if(!f.latest){console.error(`${r}: ${f.message}`),process.exitCode=t.update?1:0;return}if(console.log(f.message),t.checkUpdate||!f.available)return;if(!m()){console.error(`${r}: this copy was not installed by npm, so npm cannot replace it. install it with: npm install -g ${o}`),process.exitCode=1;return}let y=await b({version:f.latest});console.log(y.message),y.ok||(process.exitCode=1);return}let T=process.argv.slice(2);if(T[0]==="preset"){let{runPresetCommand:o}=await import("./chunk-FPXVDP32.js");process.exitCode=o(T.slice(1));return}let{expandFileReferences:se}=await import("./chunk-TSEKPGK4.js"),{isApprovalMode:te,setApprovalMode:oe,setDangerousBypass:ne,isDangerousBypass:re}=await import("./chunk-56SEAGAQ.js"),{openSession:ie}=await import("./chunk-WGBDEDF6.js");oe(t.approval&&te(t.approval)?t.approval:"full-auto");let{readWorkbenchSettings:ae}=await import("./chunk-V3R4FYTJ.js");if((t.dangerouslySkipPermissions||ae(w).skipPermissions)&&ne(!0),re()&&console.error(`${r}: 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-JLDLDP2U.js");await o(t.mode,{cwd:l,model:t.model,thinking:t.thinking});return}let M=o=>ie({cwd:l,model:t.model,thinking:t.thinking,continueSession:o.continueSession??!1,noSession:o.noSession??!1,sessionPath:o.sessionPath,interactive:!t.print}),n=await M({continueSession:t.continueSession,sessionPath:t.sessionPath,noSession:t.noSession||t.print});if(t.print&&n.note&&console.error(n.note),t.maxBudgetUsd!==void 0&&!n.priced){console.error(`${r}: ${I(n.modelLabel,w)}`),await n.dispose(),process.exitCode=2;return}if(t.print){let o=t.prompt.trimStart();if(o.startsWith("/")){let u=o.slice(1).split(/\s+/)[0]??"",{skillInvocation:g}=await import("./chunk-ILDDDLRC.js"),i=n.session.resourceLoader.getSkills().skills.map(E=>E.name);if(!(g(o,i)!==void 0)){let{slashCommands:E}=await import("./chunk-RYRVZAU6.js");if(E(n.session).some(me=>me.name===u)){console.error(`${r}: /${u} runs in the TUI only \u2014 --print sends prompts straight to the model. Run \`howtofix\` without --print for interactive commands.`),await n.dispose(),process.exitCode=2;return}}}let a=t.outputFormat==="stream-json",b=t.outputFormat==="json",m=a||b;if(a){let u={type:"system",subtype:"init",cwd:l,session_id:n.session.sessionId,model:n.modelLabel,output_format:t.outputFormat,max_budget_usd:t.maxBudgetUsd??null,dangerously_skip_permissions:t.dangerouslySkipPermissions,cli_version:x};process.stdout.write(`${JSON.stringify(u)}
|
|
95
95
|
`)}let f,y,ue=()=>{if(t.maxBudgetUsd===void 0||y!==void 0)return;let u=n.session.getSessionStats().cost;u>t.maxBudgetUsd&&(y={spent:u},n.session.abort())};try{f=n.session.subscribe(i=>{if(a){let k=N(i);k!==void 0&&process.stdout.write(k)}ue()}),await n.session.prompt(se(t.prompt,l));let u=n.session.getLastAssistantText()??"";if(y){if(console.error(`${r}: ${U(y.spent,t.maxBudgetUsd)}`),m){let i=n.session.getSessionStats();process.stdout.write(`${JSON.stringify({type:"result",subtype:"error_max_budget_usd",is_error:!0,result:u,session_id:n.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}if(m){let i=n.session.getSessionStats(),k=n.session.state.messages.at(-1);process.stdout.write(`${JSON.stringify({type:"result",subtype:"success",is_error:!1,result:u,session_id:n.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?.role==="assistant"?k.stopReason:void 0})}
|
|
97
97
|
`)}else process.stdout.write(u.endsWith(`
|
|
98
98
|
`)?u:`${u}
|
|
99
99
|
`);let g=n.session.state.messages.at(-1);if(g?.role==="assistant"){if((g.stopReason==="error"||g.stopReason==="aborted"||g.errorMessage)&&(process.exitCode=1),process.exitCode===1&&g.errorMessage){console.error(`${r}: ${g.errorMessage}`);let{diagnoseGatewayFailure:i}=await import("./chunk-VLMQSD25.js"),k=i(g.errorMessage);k!==void 0&&console.error(`${r}: ${k}`)}if(m&&process.exitCode===1){let i=n.session.getSessionStats();process.stdout.write(`${JSON.stringify({type:"result",subtype:g.stopReason==="aborted"?"error_aborted":"error_during_execution",is_error:!0,result:u,session_id:n.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:g.stopReason})}
|
|
100
|
-
`)}}}finally{f?.(),await n.dispose()}return}if(!process.stdin.isTTY||!process.stdout.isTTY){console.error(`${r}: interactive mode needs a terminal. use --print for pipes.`),await n.dispose(),process.exitCode=2;return}let{runWorkbench:ce}=await import("./chunk-
|
|
100
|
+
`)}}}finally{f?.(),await n.dispose()}return}if(!process.stdin.isTTY||!process.stdout.isTTY){console.error(`${r}: interactive mode needs a terminal. use --print for pipes.`),await n.dispose(),process.exitCode=2;return}let{runWorkbench:ce}=await import("./chunk-RYRVZAU6.js"),{autoUpdateEnabled:de,isInstalledCopy:pe}=await import("./chunk-7CHDNTH6.js"),le=pe()&&de(`${w}/settings.json`);await ce({cwd:l,modelLabel:n.modelLabel,session:n.session,setCompressToolOutput:n.setCompressToolOutput,initialPrompt:t.prompt||void 0,note:n.note,maxBudgetUsd:t.maxBudgetUsd,update:le?{current:x,install:!0}:void 0,reopen:M})}H(r);ke().catch(c=>{O(r,void 0,c),process.exitCode=1});
|
package/package.json
CHANGED
package/dist/chunk-HT3MFLAV.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import{$ as De,A as _e,B as Te,D as E,E as L,Ea as Ke,G as F,H as $e,P as Ee,Pa as Xe,Q as Ae,Qa as Ye,R as ve,S as je,T as Oe,V as Pe,W as Re,Y as Ce,_ as H,a as C,b as D,ba as Ne,c as re,ca as Fe,d as ie,da as Me,e as ae,ea as Ie,f as ce,fa as Le,g as T,i as le,ia as Ge,j as pe,k as ue,ka as Ue,l as fe,la as G,m as me,ma as Be,na as He,o as ge,p as he,pa as W,q as we,r as ye,s as be,t as $,ta as We,u as ke,ua as ze,v as xe,w as I,wa as qe,x as Se,xa as Ze}from"./chunk-AUDMRGWF.js";import{r as se}from"./chunk-JFYVRWJI.js";import{b as de}from"./chunk-27TRKD65.js";import{D as x,G as ee,r as J,s as Q}from"./chunk-V656XVXV.js";import{c as te}from"./chunk-EYWOVCSS.js";import{g as ne,k as oe}from"./chunk-DV2BBBBJ.js";import"./chunk-UTYFLLSM.js";import"./chunk-JMKK26AT.js";import{b as M,c as Y,d as V}from"./chunk-Y7YM5R75.js";import"./chunk-WOT6VMZA.js";import{join as St}from"node:path";import{hostname as Nn}from"node:os";import{createAgentSession as Fn,createCodemodeExtension as Mn,createMcpExtension as In,DefaultResourceLoader as Ln,SessionManager as U,SettingsManager as Gn}from"@netrodev/hxf-coding-agent";import{existsSync as Tt,readFileSync as $t}from"node:fs";import{join as Et}from"node:path";var Ve=Et(x,"APPEND_SYSTEM.md"),At=["<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
|
-
`),vt=16*1024;function jt(e){try{if(!Tt(e))return;let o=$t(e,"utf8").trim();return!o||Buffer.byteLength(o,"utf8")>vt?void 0:o}catch{return}}function Je(e,o){let s=[o?e:`${e}
|
|
3
|
-
|
|
4
|
-
${At}`],t=jt(Ve);return t&&s.push(`# Standing instructions from ${Ve}
|
|
5
|
-
${t}`),s}function Ot(e){return e.replace(/operating inside hxf, a coding agent harness/gi,"operating as HowToFix, a coding agent harness").replace(/^HowToFix documentation \(read only when the user asks about[^\n]*\):?$/gim,"Harness documentation (internal reference; the user is never told the harness name):").replace(/\bhxf itself\b/gi,"the harness itself").replace(/^- When reading hxf docs or examples/m,"- When reading harness docs or examples").replace(/^- When working on hxf topics/m,"- When working on harness topics").replace(/^- Always read hxf \.md files/m,"- Always read the harness .md files").replace(/\bhxf packages\b/gi,"harness packages").replace(/\bhxf \.md files\b/gi,"harness .md files").replace(/\bhxf docs\b/gi,"harness docs").replace(/^-\s*You can inspect HXF_\* environment variables/m,"- You can inspect the harness's environment variables")}var Pt=["preamble","rules","docs","addendum"];function Rt(e){if(!e)return;let o=!1,s={...e};for(let t of Pt){let n=s[t];if(typeof n!="string")continue;let r=Ot(n);r!==n&&(s[t]=r,o=!0)}return o?s:void 0}function Qe(){return e=>{e.on("context_with_system",async o=>{let s=o.messages[0];if(!s||s.role!=="system")return;let t=Rt(s.sections);return t?{messages:o.messages.map(r=>r===s?{...s,sections:t}:r)}:void 0})}}var k={hooks:{}},N;function et(){return e=>{let o=ae(re);k=o.config,N=void 0,ce(),e.on("session_start",async(s,t)=>{for(let c of o.diagnostics)t.ui.notify(`hooks.json: ${c.message}`,"warning");let{outcome:n,ran:r}=await T(k,"SessionStart",{hook_event_name:"SessionStart",cwd:t.cwd},{cwd:t.cwd});n.context&&(N=n.context),n.error&&t.ui.notify(`SessionStart hook: ${n.error}`,"warning"),r&&N&&t.ui.notify(`SessionStart hooks added ${N.length} characters of context`,"info")}),e.on("input",async(s,t)=>{if(!k.hooks.UserPromptSubmit)return;let n={hook_event_name:"UserPromptSubmit",cwd:t.cwd,prompt:s.text},{outcome:r}=await T(k,"UserPromptSubmit",n,{cwd:t.cwd});if(r.error&&t.ui.notify(`UserPromptSubmit hook: ${r.error}`,"warning"),r.block)return t.ui.notify(r.reason??"blocked by a hook","warning"),{action:"handled"};if(r.context)return{action:"transform",text:`${s.text}
|
|
6
|
-
|
|
7
|
-
${r.context}`}}),e.on("tool_call",async(s,t)=>{if(!k.hooks.PreToolUse)return;let n={hook_event_name:"PreToolUse",cwd:t.cwd,tool_name:s.toolName,tool_input:s.input},{outcome:r}=await T(k,"PreToolUse",n,{cwd:t.cwd});if(r.error&&t.ui.notify(`PreToolUse hook: ${r.error}`,"warning"),r.block)return{block:!0,reason:r.reason??"blocked by a hook"};if(r.updatedInput){let i=e.getAllTools().find(d=>d.name===s.toolName)?.parameters;if(!i)t.ui.notify(`PreToolUse hook rewrote \`${s.toolName}\`, but no schema is known for that tool \u2014 the rewrite was ignored`,"warning");else{let d=ie(i,r.updatedInput);d?t.ui.notify(`PreToolUse hook rewrite ignored \u2014 ${d}`,"warning"):Object.assign(s.input,r.updatedInput)}}}),e.on("tool_result",async(s,t)=>{if(!k.hooks.PostToolUse)return;let n=s.content.map(i=>i.type==="text"?i.text:"").join(`
|
|
8
|
-
`),r={hook_event_name:"PostToolUse",cwd:t.cwd,tool_name:s.toolName,tool_input:s.input,tool_result:n,tool_is_error:s.isError},{outcome:c}=await T(k,"PostToolUse",r,{cwd:t.cwd});if(c.error&&t.ui.notify(`PostToolUse hook: ${c.error}`,"warning"),!!c.context)return{content:[...s.content,{type:"text",text:`
|
|
9
|
-
[hook] ${c.context}`}],structuredContent:s.structuredContent}}),e.on("context_with_system",async s=>{if(!N)return;let t=s.messages[0];if(!t||t.role!=="system")return;let n=`${C(t.content)}
|
|
10
|
-
|
|
11
|
-
${N}`;return{messages:s.messages.map(c=>c===t?{...t,content:D(t.content,n)}:c)}}),e.on("session_before_compact",async(s,t)=>{if(!k.hooks.PreCompact)return;let{outcome:n}=await T(k,"PreCompact",{hook_event_name:"PreCompact",cwd:t.cwd,compact_reason:s.reason},{cwd:t.cwd});n.error&&t.ui.notify(`PreCompact hook: ${n.error}`,"warning")}),e.on("session_shutdown",async(s,t)=>{if(!k.hooks.SessionEnd)return;let{outcome:n}=await T(k,"SessionEnd",{hook_event_name:"SessionEnd",cwd:t.cwd,reason:s.reason},{cwd:t.cwd});n.error&&t.ui.notify(`SessionEnd hook: ${n.error}`,"warning")}),e.on("agent_settled",async(s,t)=>{if(!k.hooks.Stop)return;let{outcome:n}=await T(k,"Stop",{hook_event_name:"Stop",cwd:t.cwd},{cwd:t.cwd});n.error&&t.ui.notify(`Stop hook: ${n.error}`,"warning")})}}var Ct=new Set(["bash","grep","find","ls","bash_output","powershell"]),Dt=new Set(["bash","bash_output","powershell"]),Nt=40,Ft=12,Mt=8,nt=6;function It(e,o){let s=e.trim();return!!(s===""||/^[-=*_~+#]{3,}$/.test(s)||o!==void 0&&e===o)}function tt(e){return e.replace(/\d+/g,"#").trimEnd()}function Lt(e){let o=[],s=0,t=0;for(;t<e.length;){let n=tt(e[t]);if(n===""||!/\d/.test(e[t])){o.push(e[t]),t+=1;continue}let r=t+1;for(;r<e.length&&tt(e[r])===n&&/\d/.test(e[r]);)r+=1;let c=r-t;if(c>=nt)o.push(e[t]),o.push(` \u2026 ${c-2} more line${c-2===1?"":"s"} of the same shape \u2026`),o.push(e[r-1]),s+=1;else for(let i=t;i<r;i+=1)o.push(e[i]);t=r}return{out:o,collapsed:s}}function Gt(e,o,s={}){if(o?.truncated)return;let t=e.split(`
|
|
12
|
-
`);if(t.length<Nt)return;let n=[],r=0;for(let g=0;g<t.length;g+=1){if(It(t[g],n[n.length-1])){if(t[g].trim()===""&&n[n.length-1]?.trim()!==""){n.push("");continue}r+=1;continue}n.push(t[g])}let c=s.toolName===void 0||Dt.has(s.toolName),{out:i,collapsed:d}=c?Lt(n):{out:n,collapsed:0},p=s.head??Ft,u=s.tail??Mt,l=i,a=0;if(i.length>p+u+nt&&(a=i.length-p-u,l=[...i.slice(0,p),` \u2026 ${a} line${a===1?"":"s"} omitted (${p} kept from the top, ${u} from the end) \u2026`,...i.slice(i.length-u)]),!(r+d===0&&a===0))return{text:l.join(`
|
|
13
|
-
`),stats:{before:t.length,after:l.length,collapsed:d}}}function ot(e){return o=>{o.on("tool_result",s=>{if(!e.enabled()||s.isError||!Ct.has(s.toolName))return;let t=s.content.find(i=>i.type==="text");if(!t||t.type!=="text")return;let n=s.details,r=Gt(t.text,n,{toolName:s.toolName});return r?{content:s.content.map(i=>i===t?{type:"text",text:r.text}:i)}:void 0})}}import{readdirSync as Ut,readFileSync as Bt,statSync as Ht}from"node:fs";import{extname as Wt,join as st,relative as zt,resolve as qt,sep as rt}from"node:path";import{Type as P}from"@netrodev/hxf-ai";import{defineTool as Zt}from"@netrodev/hxf-coding-agent";var Kt=new Set(["node_modules",".git","dist","build","out","coverage","vendor","target","__pycache__",".venv","venv",".next",".turbo",".cache"]),A={".ts":{kind:"ts",patterns:[/^\s*export\s+(?:default\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/gm,/^\s*export\s+(?:abstract\s+)?class\s+([A-Za-z_$][\w$]*)/gm,/^\s*export\s+(?:interface|type)\s+([A-Za-z_$][\w$]*)/gm,/^\s*export\s+const\s+([A-Za-z_$][\w$]*)/gm,/^\s*(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/gm,/^\s*(?:export\s+)?class\s+([A-Za-z_$][\w$]*)/gm]},".tsx":{kind:"tsx",patterns:[]},".js":{kind:"js",patterns:[]},".mjs":{kind:"js",patterns:[]},".go":{kind:"go",patterns:[/^func\s+(?:\([^)]*\)\s*)?([A-Za-z_]\w*)/gm,/^type\s+([A-Za-z_]\w*)\s+(?:struct|interface)/gm]},".py":{kind:"py",patterns:[/^(?:async\s+)?def\s+([A-Za-z_]\w*)/gm,/^class\s+([A-Za-z_]\w*)/gm]},".rs":{kind:"rs",patterns:[/^\s*(?:pub\s+)?(?:async\s+)?fn\s+([A-Za-z_]\w*)/gm,/^\s*(?:pub\s+)?(?:struct|enum|trait)\s+([A-Za-z_]\w*)/gm]}};A[".tsx"].patterns=A[".ts"].patterns;A[".js"].patterns=A[".ts"].patterns;A[".mjs"].patterns=A[".ts"].patterns;var Xt=512*1024,Yt=12;function Vt(e,o){let s=A[o];if(!s)return[];let t=new Set,n=[];for(let r of s.patterns){r.lastIndex=0;for(let c of e.matchAll(r)){let i=c[1];i&&!t.has(i)&&(t.add(i),n.push(i))}}return n}function Jt(e,o){let s=new Set,t=n=>{n&&(n.startsWith("./")||n.startsWith("../"))&&s.add(n)};if(o===".ts"||o===".tsx"||o===".js"||o===".mjs"){for(let n of e.matchAll(/(?:from|require\()\s*["']([^"']+)["']/g))t(n[1]);for(let n of e.matchAll(/^\s*import\s+["']([^"']+)["']/gm))t(n[1])}else if(o===".go")for(let n of e.matchAll(/^\s*(?:[\w.]+\s+)?"([^"]+)"/gm))t(n[1]);else if(o===".py")for(let n of e.matchAll(/^\s*from\s+(\.+[\w.]*)\s+import/gm)){let r=n[1].replace(/\./g,"/");t(r.startsWith("/")?`.${r}`:`./${r}`)}else if(o===".rs")for(let n of e.matchAll(/^\s*use\s+(?:crate|super|self)::([\w:]+)/gm))t(`./${n[1].split("::").join("/")}`);return[...s]}function Qt(e,o,s){let t=e.split("/").slice(0,-1).join("/"),n=st(t,o).split(rt).join("/").replace(/^\.\//,"");return[n,`${n}.ts`,`${n}.tsx`,`${n}.js`,`${n}.mjs`,`${n}.go`,`${n}.py`,`${n}.rs`,`${n}/index.ts`,`${n}/index.tsx`,`${n}/index.js`,`${n}/mod.rs`,`${n}.py`].find(c=>s.has(c))}function en(e,o="."){let s=[],t=(n,r)=>{if(r>Yt)return;let c;try{c=Ut(n,{withFileTypes:!0})}catch{return}for(let i of c){let d=st(n,i.name);if(i.isDirectory()){if(Kt.has(i.name)||i.name.startsWith("."))continue;t(d,r+1);continue}let p=Wt(i.name);if(A[p])try{if(Ht(d).size>Xt)continue;let u=Bt(d,"utf8"),l=zt(e,d).split(rt).join("/");s.push({path:l,symbols:Vt(u,p),imports:Jt(u,p)})}catch{}}};return t(qt(e,o),0),s}function tn(e,o){if(e.length===0)return[];let s=new Set(e.map(l=>l.path)),t=new Map(e.map((l,a)=>[l.path,a])),n=e.map(()=>[]),r=e.map(()=>[]);e.forEach((l,a)=>{for(let f of l.imports){let g=Qt(l.path,f,s);if(!g||g===l.path)continue;let w=t.get(g);w!==void 0&&(n[a].push(w),r[w].push(a))}});let c=e.length,i=o?.trim().toLowerCase(),d=e.map(l=>i&&`${l.path} ${l.symbols.join(" ")}`.toLowerCase().includes(i)?4/c:1/c),p=d.reduce((l,a)=>l+a,0),u=e.map((l,a)=>d[a]/p);for(let l=0;l<20;l++){let a=e.map((f,g)=>.15*(d[g]/p));for(let f=0;f<c;f++){if(n[f].length===0){for(let g=0;g<c;g++)a[g]+=.85*u[f]/c;continue}for(let g of n[f])a[g]+=.85*u[f]/n[f].length}u=a}return e.map((l,a)=>({file:l,score:u[a],match:i?`${l.path} ${l.symbols.join(" ")}`.toLowerCase().includes(i):!1})).sort((l,a)=>Number(a.match)-Number(l.match)||a.score-l.score||l.file.path.localeCompare(a.file.path)).map(l=>l.file)}function nn(e,o={}){let t=Math.max(200,Math.min(8e3,o.budget??1200))*4,n=tn(e,o.query),r=[],c=0;for(let d of n){let p=d.symbols.slice(0,8).join(", "),u=p?`${d.path}: ${p}`:`${d.path}`;if(c+u.length+1>t)break;r.push(u),c+=u.length+1}if(r.length===0)return"(no source files found)";let i=n.length-r.length;return i>0&&r.push(`\u2026 ${i} more file${i===1?"":"s"} not shown`),r.join(`
|
|
14
|
-
`)}var it;function at(e){it=e}var ct=Zt({name:"repo_map",label:"repo_map",description:"A ranked outline of the repository: files by importance with their top declarations. Use it to find where something lives before reading files, instead of listing directories.",promptSnippet:"repo_map: ranked file outline of the project",parameters:P.Object({path:P.Optional(P.String({description:"Subdirectory to map, relative to the project root"})),query:P.Optional(P.String({description:"Keyword to bias the ranking, e.g. 'billing'"})),budget:P.Optional(P.Number({description:"Token budget, default 1200"}))}),async execute(e,o){let s=it?.()??process.cwd(),t=en(s,o.path??".");return{content:[{type:"text",text:nn(t,{budget:o.budget,query:o.query})}],details:{files:t.length}}}});function z(){return{consecutiveFailures:0,tripped:!1}}function on(e,o){return o==="manual"?!1:e.consecutiveFailures>=3}function sn(e,o){if(o)return e;let s=e.consecutiveFailures+1;return{consecutiveFailures:s,tripped:e.tripped||s>=3}}function rn(){return z()}function an(e){return[`Auto-compaction failed ${e.consecutiveFailures} times in a row, so it is switched off for this session.`,"The context is over the limit and compaction cannot recover it. Start a new session, or switch to a model with a larger context window.","Manual /compact is still allowed."].join(" ")}var v=z();function lt(){return e=>{e.on("session_start",async()=>{v=z()}),e.on("session_compact",async()=>{v=rn()}),e.on("session_compact_failed",async(o,s)=>{let t=v;v=sn(v,o.aborted),!t.tripped&&v.tripped&&s?.ui&&s.ui.notify(an(v),"warning")}),e.on("session_before_compact",async o=>{if(on(v,o.reason))return{cancel:!0}})}}function cn(e){E(F(e))}function dt(e){return`budget exhausted (${e.budget??"default"} continuations)`}function pt(){return e=>{e.on("session_start",async(o,s)=>{cn(s)}),e.on("context_with_system",async(o,s)=>{let t=F(s);if(E(t),!t||t.status!=="active")return;let n=o.messages[0];if(!n||n.role!=="system")return;let r=`${C(n.content)}
|
|
15
|
-
|
|
16
|
-
${_e(t)}`;return{messages:o.messages.map(i=>i===n?{...n,content:D(n.content,r)}:i)}}),e.on("agent_before_settle",async(o,s)=>{try{let t=F(s);if(E(t),L(t).action==="stop"||!t||o.continue||!o.context.canContinue)return;let n={...t,used:t.used+1};if(e.appendEntry(I,n),E(n),L(n).action==="stop"){let r={...n,status:"done",note:dt(n)};e.appendEntry(I,r),E(r);return}return{entries:[{type:"custom_message",customType:Se,content:Te(n),display:!0}],continue:!0}}catch{return}}),e.on("agent_settled",async(o,s)=>{try{let t=F(s),n=L(t);if(t&&n.action==="stop"&&n.close){let r={...t,status:"done",note:dt(t)};e.appendEntry(I,r),E(r)}else E(t)}catch{return}})}}function ln(e){let o=Q(e);return o.length===0?"":["The user installed the following presets. Their rules apply to this session.","",...o.map(t=>`<preset name="${t.name}">
|
|
17
|
-
${t.text}
|
|
18
|
-
</preset>`)].join(`
|
|
19
|
-
`)}function ut(e){return o=>{o.on("resources_discover",async()=>{let s=J(e);return s.length>0?{skillPaths:s}:void 0}),o.on("context_with_system",async s=>{let t=ln(e);if(!t)return;let n=s.messages[0];if(!n||n.role!=="system")return;let r=`${C(n.content)}
|
|
20
|
-
|
|
21
|
-
${t}`;return{messages:s.messages.map(i=>i===n?{...n,content:D(n.content,r)}:i)}})}}import{Type as y}from"@netrodev/hxf-ai";import{defineTool as dn}from"@netrodev/hxf-coding-agent";function pn(){return[...G.values()].map(e=>`${e.name} (${e.description})`).join(", ")}function ft(){return dn({name:"task",label:"task",description:`Spawn subagents. Available: ${pn()}. One call can carry tasks[]; each item may set agent, model, effort and isolation. Agents run concurrently, park when done, and can be resumed or messaged with /agents. Pass background: true to return as soon as they start instead of waiting for them. Use architect to design an approach before a large change. Set isolation: "worktree" on every task that writes files.`,promptSnippet:"task: spawn background agents",parameters:y.Object({agent:y.Optional(y.String()),effort:y.Optional(y.String()),model:y.Optional(y.String()),task:y.Optional(y.String()),isolation:y.Optional(y.String()),background:y.Optional(y.Boolean()),tasks:y.Optional(y.Array(y.Object({agent:y.Optional(y.String()),effort:y.Optional(y.String()),model:y.Optional(y.String()),task:y.String(),isolation:y.Optional(y.String())})))}),executionMode:"parallel",async execute(e,o,s,t,n){let r=o.tasks&&o.tasks.length>0?o.tasks.map(f=>({agent:f.agent??o.agent??"task",task:f.task,effort:f.effort??o.effort,model:f.model??o.model,isolation:f.isolation??o.isolation})):[{agent:o.agent??"task",task:o.task??"",effort:o.effort,model:o.model,isolation:o.isolation}],c=r.slice(0,W),i=r.length-c.length,d=!!o.background,p=[],u=[],l=[],a=[];try{for(let m of c){if(!m.task.trim())continue;let h;if(m.isolation==="worktree"){let b=await Ke(n?.cwd??process.cwd(),m.agent);if(b){u.push(b),h=b.path;for(let j of b.skipped)a.push(`${m.agent}:${j}`)}else l.push(m.agent)}p.push(await ze({...m,cwd:n?.cwd,background:d,parentModel:We(n?.model),worktree:h})),t?.({content:[],details:{agents:p.map(b=>({id:b.id,agent:b.agent,status:b.status}))}})}if(p.length===0)throw new Error("task or tasks is required");let f=i>0?`(only the first ${W} of ${r.length} tasks ran)`:"",g=p.filter(m=>m.worktree).length,w=[f,l.length>0?`isolation: "worktree" was requested but not available for: ${l.join(", ")}. Those agents ran in the shared working tree \u2014 check their edits for collisions before trusting them.`:"",a.length>0?`too large to copy into the isolated worktree, so it was left out: ${a.join(", ")}. An agent that needs it cannot install or build \u2014 treat any "done" from those runs as unverified.`:""].filter(Boolean),S={agents:p.map(m=>({id:m.id,status:m.status,isolated:!!m.worktree}))};if(d){qe();let m=p.map(h=>`${h.agent}#${h.id}`).join(", ");return{content:[{type:"text",text:`started ${p.length} agent${p.length===1?"":"s"} in the background: ${m}.`+(g>0?` ${g} of them in their own worktree.`:"")+`
|
|
22
|
-
Their results are not part of this turn \u2014 keep working. Read them with /agents, or message one with /agents <id> <text>.`+(w.length>0?`
|
|
23
|
-
${w.join(`
|
|
24
|
-
`)}`:"")}],details:S}}await Ze(s);let _=p.map(m=>`${He(m)}${m.worktree?" [isolated]":""}
|
|
25
|
-
${m.result??""}`);return w.length>0&&_.push(w.join(`
|
|
26
|
-
`)),{content:[{type:"text",text:_.join(`
|
|
27
|
-
|
|
28
|
-
`)}],details:S}}finally{for(let f of u)try{await f.remove()}catch{}}}})}import{readFileSync as un,readdirSync as fn,statSync as mn}from"node:fs";import{dirname as gn,join as q}from"node:path";import{getAgentDir as hn,parseFrontmatter as wn}from"@netrodev/hxf-coding-agent";var mt=["off","minimal","low","medium","high","xhigh","max"],yn=["name","description","tools","model","effort"],bn=["read","bash","edit","write","grep","find","ls","bash_output","kill_shell","todo","context","goal","task","workflow","web_search","web_fetch","lsp","quality","slop","claim","repo_map"],kn=["read","bash","edit","write","grep","find","ls","context","todo","web_search","web_fetch","lsp","claim"];function xn(e){let s=(typeof e=="string"?e.split(","):Array.isArray(e)?e:[]).map(t=>String(t).trim().replace(/^["']|["']$/g,"")).filter(Boolean);return s.length>0?s:void 0}function Sn(e){try{return mn(e).isDirectory()}catch{return!1}}function _n(e){let o=e;for(;;){let s=q(o,".howtofix","agents");if(Sn(s))return s;let t=gn(o);if(t===o)return;o=t}}function Tn(e){let o=[{scope:"user",dir:q(hn(),"agents")}],s=_n(e);return s&&o.push({scope:"project",dir:s}),o}function $n(e,o){let s=[],t=[],n=e.replace(/^\uFEFF/,"");if(!/^---\r?\n/.test(n))return{notes:s,problems:[`${o}: no frontmatter \u2014 the file must start with --- and end the block with ---`]};let r={},c="";try{let m=wn(n);r=m.frontmatter??{},c=(m.body??"").trim()}catch(m){return{notes:s,problems:[`${o}: the frontmatter is not readable YAML \u2014 ${m instanceof Error?m.message:String(m)}`]}}for(let m of Object.keys(r))yn.includes(m)||s.push(`${o}: ignoring the unknown frontmatter key '${m}'`);let i=(o.split(/[\\/]/).pop()??o).replace(/\.md$/i,""),d=r.name,p=(typeof d=="string"&&d.trim()?d:i).trim();/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(p)||t.push(`${o}: '${p}' is not a usable agent name \u2014 letters, digits, dot, dash and underscore only`);let u=r.description,l=typeof u=="string"?u.trim():"";l||t.push(`${o}: a description is required \u2014 it is how the model decides to use this agent`),c||t.push(`${o}: no prompt body \u2014 the text below the frontmatter is the agent's standing instruction`);let a=r.effort,f=typeof a=="string"?a.trim().toLowerCase():"";f&&!mt.includes(f)&&t.push(`${o}: effort '${f}' is not one of ${mt.join(", ")}`);let g=xn(r.tools),w=g??[...kn];if(g){let m=g.filter(h=>!bn.includes(h)&&!h.startsWith("mcp__"));m.length>0&&s.push(`${o}: unknown tool${m.length===1?"":"s"} ${m.join(", ")} \u2014 kept, but nothing registers them yet`)}let S=r.model,_=typeof S=="string"&&S.trim()?S.trim():void 0;return t.length>0?{notes:s,problems:t}:{def:{name:p,description:l,tools:w,prompt:c,effort:f||"medium",model:_,source:o},notes:s,problems:t}}function gt(e,o){let s=[],t=[],n=[],r=[];for(let{scope:c,dir:i}of Tn(e)){let d;try{d=fn(i)}catch{continue}for(let p of d.filter(u=>u.toLowerCase().endsWith(".md")).sort()){let u=q(i,p),l;try{l=un(u,"utf8")}catch(g){n.push(`${u}: ${g instanceof Error?g.message:String(g)}`);continue}let a=$n(l,u);t.push(...a.notes),n.push(...a.problems);let f=a.def;f&&(o.has(f.name)&&t.push(`${u}: replaces ${Be.has(f.name)?"the built-in":"an earlier"} '${f.name}'`),o.set(f.name,f),s.push(f),r.includes(c)||r.push(c))}}if(s.length>0){let c=s.filter(i=>o.get(i.name)===i);t.unshift(`loaded ${c.length} subagent definition${c.length===1?"":"s"} (${r.join(" and ")}): ${c.map(i=>i.name).join(", ")}`)}return{loaded:s,notes:t,problems:n}}var En=["grep","find","ls","bash_output","kill_shell"];async function ht(e,{timeoutMs:o=2e3,quietTicks:s=2}={}){let t=Date.now()+o,n=e.getActiveToolNames().length,r=0;for(;Date.now()<t&&r<s;){await new Promise(i=>setTimeout(i,50));let c=e.getActiveToolNames().length;c>n?(n=c,r=0):r+=1}}function wt(e){let o=new Set(e.getActiveToolNames()),s=new Set(e.getAllTools().map(n=>n.name)),t=[];for(let n of En)s.has(n)&&!o.has(n)&&(o.add(n),t.push(n));return t.length>0&&e.setActiveToolsByName([...o]),t}import{spawnSync as An}from"node:child_process";import{join as vn}from"node:path";import{defineTool as jn}from"@netrodev/hxf-coding-agent";var On=6e3,yt=jn({name:"slop",label:"slop",description:"Check code against the project's slop gate: naming, comments, placeholder values, swallowed errors, and the LLM tells that appear in model-written code. Read-only. Use it before reporting a task finished; it returns each finding as a rule id, a line, and what is wrong, so a claim of clean code becomes something the user can verify. Defaults to the changed files; pass a path to narrow it.",promptSnippet:"slop: naming, comment and placeholder findings for changed code",parameters:$.Object({path:$.Optional($.String({description:"One file or directory, relative to the project root. Omit to scan the changed set."})),changes:$.Optional($.Boolean({description:"Scan only files changed against the base ref. Default true when path is omitted."})),base:$.Optional($.String({description:"Git ref for `changes`. Defaults to HEAD."}))}),async execute(e,o,s,t,n){let r=n.cwd??process.cwd(),i=[vn(r,"scripts","slop.mjs"),"--json"];o.path!==void 0?i.push(o.path):(o.changes??!0)&&i.push("--changes"),o.base!==void 0&&i.push("--base",o.base);let d=An("node",i,{cwd:r,encoding:"utf8",timeout:12e4}),p;try{p=JSON.parse(d.stdout)}catch{p=void 0}if(!p){let w=(d.stderr||d.stdout||"").trim()||d.error?.message||(d.signal?`killed by ${d.signal} (timed out after 120 s?)`:"no output");return{content:[{type:"text",text:`slop gate produced no report: ${w.slice(0,400)}`}],details:{error:w.slice(0,400)}}}if(p.off)return{content:[{type:"text",text:"slop gate is off"}],details:{off:!0}};let u=p.files??{},l=[],a=0;for(let[w,S]of Object.entries(u)){l.push(`${w}`);for(let _ of S)a+=1,l.push(` ${_.rule} L${_.line} ${_.message}`)}if(a===0)return{content:[{type:"text",text:"slop gate: no findings in the scanned files"}],details:{files:Object.keys(u).length,findings:0}};let f=l.join(`
|
|
29
|
-
`).slice(0,On),g=f.length<l.join(`
|
|
30
|
-
`).length?`
|
|
31
|
-
\u2026 truncated`:"";return{content:[{type:"text",text:`${a} finding${a===1?"":"s"}:
|
|
32
|
-
|
|
33
|
-
${f}${g}`}],details:{files:Object.keys(u).length,findings:a}}}});function Z(e){return e.extensionRunner.emit({type:"session_shutdown",reason:"quit"}).catch(()=>{}).finally(()=>e.dispose())}import{readdir as bt,rmdir as Pn,stat as Rn,unlink as Cn}from"node:fs/promises";import{dirname as Dn,join as K,resolve as kt}from"node:path";async function xt(e={}){let o={removed:[],failed:[],removedDirs:[]},s=K(e.agentDir??x,"sessions"),t=(e.now??Date.now())-Ye*24*60*60*1e3,n=e.keep?kt(e.keep):void 0,r;try{r=await bt(s,{withFileTypes:!0})}catch{return o}for(let c of r){if(!c.isDirectory())continue;let i=K(s,c.name),d;try{d=await bt(i)}catch{continue}let p=d.filter(u=>!u.endsWith(".jsonl"));for(let u of d){if(!u.endsWith(".jsonl"))continue;let l=K(i,u),a;try{n&&kt(l)===n?a=!1:a=(await Rn(l)).mtimeMs<t}catch{a=!1}if(!a){p.push(u);continue}try{await Cn(l),o.removed.push(l)}catch{o.failed.push(l),p.push(u)}}if(p.length===0){if(n&&Dn(n)===i)continue;try{await Pn(i),o.removedDirs.push(i)}catch{}}}return o}var X="howtofix.build",Ss=["read","repo_map","bash","edit","write","grep","find","ls","bash_output","kill_shell","task","think","ask","claim","sessions","todo","context","goal","enter_plan_mode","exit_plan_mode","workflow","web_search","web_fetch","lsp","quality","compress","slop"],Un=()=>({exclude:process.platform==="win32"?[]:["powershell"]}),_t=!1;async function _s(e){let o=Gn.create(e.cwd,x,{projectTrusted:!0}),s=de(x).compressToolOutput,t=e.sessionPath?U.open(e.sessionPath):e.noSession?U.inMemory(e.cwd):e.continueSession?U.continueRecent(e.cwd):U.create(e.cwd),n=(()=>{try{let b=t.getEntries().find(j=>j.type==="custom"&&j.customType===X)?.data?.version;return!b||b===M?void 0:`this session was written by HowToFix ${b}; you are running ${M}`}catch{return}})(),r=new Ln({cwd:e.cwd,agentDir:x,settingsManager:o,appendSystemPrompt:Je(Y,e.interactive??!0),additionalSkillPaths:ee(e.cwd),extensionFactories:[Ee(),se(),Qe(),et(),De(),Oe(),ut(e.cwd),pt(),Ae(),lt(),Mn(),ot({enabled:()=>s}),In({loadConfig:h=>le({cwd:h.cwd,projectTrusted:h.isProjectTrusted?.()??!1})})]});await r.reload();let c=gt(e.cwd,G),i=ft(),d=t.getSessionId();at(()=>e.cwd);let p=St(x,ue);we({root:()=>e.cwd,holder:()=>`session:${d}`,presenceDir:()=>p,selfId:()=>d});let u=()=>{try{fe({dir:p},{id:d,cwd:e.cwd,host:Nn(),pid:process.pid,at:Date.now()})}catch{}};u();let l=setInterval(u,Math.max(5e3,Math.floor(pe/3)));l.unref?.();let a=await Fn({cwd:e.cwd,agentDir:x,settingsManager:o,sessionManager:t,resourceLoader:r,excludeTools:Un().exclude,customTools:[i,ct,ge,he,be,ye,ke,xe,$e,ve,je,Xe(),Ne,Fe,Ie,Le,yt,Pe({state:()=>Re(H()??"dcp-sessionless"),messages:()=>Ce(H()??"dcp-sessionless")})],thinkingLevel:e.thinking});await a.session.bindExtensions({mode:"print",onError:()=>{}});let f=ne(x),g=[];if(f){let h=await oe(x,f);h.renewed?await a.session.modelRuntime.setRuntimeApiKey("howtofix",h.credential.accessToken):(h.terminal&&h.message||h.message)&&g.push(h.message)}await ht(a.session),wt(a.session);let w=a.session.model;if(e.model){let h=await a.session.modelRuntime.getAvailable(),b=Ge(h,e.model);if(!b)throw await Z(a.session),new Error(`unknown model '${e.model}'`);(w?.id!==b.id||w.provider!==b.provider)&&(await a.session.setModel(b),w=a.session.model)}else{let h=await a.session.modelRuntime.getAvailable(),b=new Map,j=[];for(let O of h){let R=b.get(O.provider);R===void 0&&(R=!!(await a.session.modelRuntime.getAuth(O.provider))?.auth?.apiKey,b.set(O.provider,R)),R&&j.push(O)}let B=te;if(!B.includes(w?.provider??"")){let O=Ue(j.filter(R=>B.includes(R.provider)),B);O&&(await a.session.setModel(O),w=a.session.model)}}if(!e.noSession&&t.getEntries().every(h=>h.type!=="custom"||h.customType!==X))try{t.appendCustomEntry(X,{version:M})}catch{}_t||(_t=!0,xt({keep:a.session.sessionFile}).catch(()=>{}));let S=w?`${w.provider}/${w.id}`:"no model",_=!!(w&&w.cost&&(w.cost.input>0||w.cost.output>0)),m=[V(a.modelFallbackMessage),...g,...c.notes,...c.problems].filter(h=>!!h);return w||m.push(`no model configured. run \`howtofix\` and use /login, or edit ${St(x,"models.json")}`),{session:a.session,dispose:async()=>{Me(),await Z(a.session),clearInterval(l),me({dir:p},d)},modelLabel:S,priced:_,setCompressToolOutput:h=>{s=h},note:[n,...m].filter(Boolean).join(`
|
|
34
|
-
`)||void 0}}export{X as BUILD_ENTRY,Ss as MAIN_TOOLS,_s as openSession};
|