howtofixcli 0.7.14 → 0.7.16

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 (165) hide show
  1. package/dist/chunk-27TRKD65.js +2 -0
  2. package/dist/chunk-2XG6XQZR.js +1 -0
  3. package/dist/chunk-3FYCFLNK.js +1 -0
  4. package/dist/chunk-56SEAGAQ.js +1 -0
  5. package/dist/chunk-5HR4WOW7.js +2 -0
  6. package/dist/chunk-6FUWMLWO.js +1 -0
  7. package/dist/chunk-7CHDNTH6.js +1 -0
  8. package/dist/chunk-A5WOL324.js +34 -0
  9. package/dist/chunk-AGGIYXN7.js +2 -0
  10. package/dist/chunk-AUDMRGWF.js +189 -0
  11. package/dist/chunk-BX5KIC4R.js +2 -0
  12. package/dist/chunk-DAPXGSGD.js +12 -0
  13. package/dist/chunk-DOD7MUGX.js +1 -0
  14. package/dist/chunk-DVYH677E.js +5 -0
  15. package/dist/chunk-FFNDHUCQ.js +5 -0
  16. package/dist/chunk-FPXVDP32.js +8 -0
  17. package/dist/chunk-GXB7RZHH.js +1 -0
  18. package/dist/chunk-ILDDDLRC.js +1 -0
  19. package/dist/chunk-JFYVRWJI.js +2 -0
  20. package/dist/chunk-LAHVHRCS.js +2 -0
  21. package/dist/chunk-LJEKOS4S.js +6 -0
  22. package/dist/chunk-LSJC73DG.js +1 -0
  23. package/dist/chunk-MOKUBKE7.js +1 -0
  24. package/dist/chunk-MVTU4M3W.js +2 -0
  25. package/dist/chunk-N345KWWK.js +1 -0
  26. package/dist/chunk-ONZLNFQ2.js +3 -0
  27. package/dist/chunk-ORJ2QZBG.js +3 -0
  28. package/dist/chunk-PCALBZOO.js +2 -0
  29. package/dist/chunk-Q7VRW74X.js +1 -0
  30. package/dist/chunk-QJ6MIM5Z.js +1 -0
  31. package/dist/chunk-TSEKPGK4.js +1 -0
  32. package/dist/chunk-UTYFLLSM.js +1 -0
  33. package/dist/chunk-V3R4FYTJ.js +1 -0
  34. package/dist/chunk-V656XVXV.js +8 -0
  35. package/dist/chunk-VLMQSD25.js +1 -0
  36. package/dist/chunk-WKUJ7CFO.js +1 -0
  37. package/dist/chunk-WLU3WFCK.js +1 -0
  38. package/dist/chunk-WOT6VMZA.js +1 -0
  39. package/dist/chunk-WUPU6LTD.js +4 -0
  40. package/dist/chunk-WX3V5P7U.js +5 -0
  41. package/dist/chunk-YW7NORH3.js +2 -0
  42. package/dist/chunk-ZNS6H44M.js +110 -0
  43. package/dist/main.js +99 -551
  44. package/package.json +17 -64
  45. package/dist/account-credential.js +0 -136
  46. package/dist/account-credential.test.js +0 -38
  47. package/dist/acp.js +0 -234
  48. package/dist/activity.js +0 -124
  49. package/dist/agent-defs.js +0 -237
  50. package/dist/agent-limiter.js +0 -68
  51. package/dist/agents.js +0 -554
  52. package/dist/anim.js +0 -361
  53. package/dist/args.js +0 -250
  54. package/dist/at-file.js +0 -28
  55. package/dist/brand-extension.js +0 -87
  56. package/dist/brand.js +0 -76
  57. package/dist/browser.js +0 -58
  58. package/dist/cache-report.js +0 -139
  59. package/dist/checkpoint.js +0 -437
  60. package/dist/claims.js +0 -167
  61. package/dist/cli-auth.js +0 -142
  62. package/dist/cli-checkin.js +0 -120
  63. package/dist/cli-credentials.js +0 -254
  64. package/dist/clipboard.js +0 -149
  65. package/dist/collapse.js +0 -129
  66. package/dist/commands.js +0 -294
  67. package/dist/compaction-guard.js +0 -81
  68. package/dist/context-extension.js +0 -17
  69. package/dist/dcp/commands.js +0 -172
  70. package/dist/dcp/compress-state.js +0 -139
  71. package/dist/dcp/compress.js +0 -329
  72. package/dist/dcp/dcp-extension.js +0 -295
  73. package/dist/dcp/dedup.js +0 -93
  74. package/dist/dcp/ids.js +0 -189
  75. package/dist/dcp/index.js +0 -25
  76. package/dist/dcp/middle-prune.js +0 -76
  77. package/dist/dcp/prompts.js +0 -68
  78. package/dist/dcp/protected-content.js +0 -221
  79. package/dist/dcp/protected.js +0 -161
  80. package/dist/dcp/prune.js +0 -418
  81. package/dist/dcp/state.js +0 -176
  82. package/dist/device-id.js +0 -90
  83. package/dist/device-id.test.js +0 -23
  84. package/dist/errors.js +0 -63
  85. package/dist/extensions.js +0 -48
  86. package/dist/fatal.js +0 -35
  87. package/dist/feed.js +0 -498
  88. package/dist/fs-atomic.js +0 -54
  89. package/dist/gateway-errors.js +0 -90
  90. package/dist/git.js +0 -230
  91. package/dist/goal-extension.js +0 -88
  92. package/dist/goal.js +0 -222
  93. package/dist/hooks-extension.js +0 -176
  94. package/dist/hooks.js +0 -443
  95. package/dist/howtofix-account.js +0 -735
  96. package/dist/hud-line.js +0 -153
  97. package/dist/hwid.js +0 -130
  98. package/dist/interrupt.js +0 -60
  99. package/dist/json-events.js +0 -50
  100. package/dist/level-style.js +0 -112
  101. package/dist/loop-guard.js +0 -95
  102. package/dist/lsp-tools.js +0 -32
  103. package/dist/lsp.js +0 -429
  104. package/dist/mcp-config.js +0 -85
  105. package/dist/mcp-lifecycle.js +0 -147
  106. package/dist/model-catalog.js +0 -217
  107. package/dist/model-facts.js +0 -35
  108. package/dist/model-resolve.js +0 -65
  109. package/dist/notes.js +0 -78
  110. package/dist/oauth-login.js +0 -568
  111. package/dist/paths.js +0 -61
  112. package/dist/permissions.js +0 -298
  113. package/dist/plan-mode.js +0 -363
  114. package/dist/preset-command.js +0 -227
  115. package/dist/preset-extension.js +0 -35
  116. package/dist/preset-mcp.js +0 -292
  117. package/dist/presets.js +0 -727
  118. package/dist/prompt-files.js +0 -103
  119. package/dist/prompt-text.js +0 -41
  120. package/dist/proxy.js +0 -137
  121. package/dist/quality/ast.js +0 -196
  122. package/dist/quality/cognitive.js +0 -83
  123. package/dist/quality/cyclomatic.js +0 -30
  124. package/dist/quality/halstead.js +0 -83
  125. package/dist/quality/index.js +0 -18
  126. package/dist/quality/length.js +0 -3
  127. package/dist/quality/maintainability.js +0 -15
  128. package/dist/quality/nesting.js +0 -57
  129. package/dist/quality/report.js +0 -803
  130. package/dist/quality/smells.js +0 -67
  131. package/dist/quality-tool.js +0 -63
  132. package/dist/read-only-commands.js +0 -597
  133. package/dist/repo-map.js +0 -292
  134. package/dist/roblox-connect.js +0 -125
  135. package/dist/rpc.js +0 -91
  136. package/dist/rtk.js +0 -193
  137. package/dist/sandbox.js +0 -105
  138. package/dist/schema.js +0 -214
  139. package/dist/serve.js +0 -50
  140. package/dist/session-lifecycle.js +0 -19
  141. package/dist/session-retention.js +0 -111
  142. package/dist/session.js +0 -447
  143. package/dist/sessions.js +0 -100
  144. package/dist/settings.js +0 -148
  145. package/dist/skills.js +0 -35
  146. package/dist/slop-tool.js +0 -96
  147. package/dist/spend-cap.js +0 -43
  148. package/dist/subagent.js +0 -171
  149. package/dist/tar.js +0 -146
  150. package/dist/theme.js +0 -79
  151. package/dist/thinking.js +0 -45
  152. package/dist/todo.js +0 -114
  153. package/dist/tool-loadout.js +0 -97
  154. package/dist/tool-render.js +0 -769
  155. package/dist/tools.js +0 -176
  156. package/dist/ui.js +0 -4814
  157. package/dist/update.js +0 -551
  158. package/dist/usage-segment.js +0 -69
  159. package/dist/web-tools.js +0 -46
  160. package/dist/web.js +0 -265
  161. package/dist/welcome.js +0 -179
  162. package/dist/workflow-engine.js +0 -246
  163. package/dist/workflow-progress.js +0 -446
  164. package/dist/workflow-view.js +0 -195
  165. package/dist/workflow.js +0 -349
@@ -0,0 +1,2 @@
1
+ import{a as u}from"./chunk-UTYFLLSM.js";import{existsSync as l,mkdirSync as f,readFileSync as c}from"node:fs";import{dirname as p,join as m}from"node:path";var a={skipPermissions:!1,autoUpdate:!0,rightClickPaste:"auto",welcomeSeen:!1,compressToolOutput:!1};function g(t){return m(t,"settings.json")}function k(t){try{let e=JSON.parse(c(g(t),"utf8")),n=r=>{let i=e[r];return typeof i=="boolean"?i:a[r]},o=e.rightClickPaste;return{skipPermissions:n("skipPermissions"),autoUpdate:n("autoUpdate"),rightClickPaste:o==="on"||o==="off"||o==="auto"?o:a.rightClickPaste,welcomeSeen:n("welcomeSeen"),compressToolOutput:n("compressToolOutput"),...typeof e.agents=="number"&&Number.isInteger(e.agents)&&e.agents>0?{agents:e.agents}:{}}}catch{return{...a}}}function h(t,e,n){return s(t,e,n)}function w(t){return s(t,"welcomeSeen",!0)}function P(t,e){return s(t,"rightClickPaste",e==="auto"?void 0:e)}function y(t){return t==="on"?!0:t==="off"?!1:process.platform!=="win32"}function x(t,e){let n=typeof e=="number"&&Number.isInteger(e)&&e>0?e:void 0;return s(t,"agents",n)}function C(t,e,n){let o=n.trim();return s(t,e,o===""?void 0:o)}function s(t,e,n){let o=g(t),r={};try{let i=JSON.parse(c(o,"utf8"));i&&typeof i=="object"&&!Array.isArray(i)&&(r=i)}catch{if(l(o))return!1}n===void 0?delete r[e]:r[e]=n;try{f(p(o),{recursive:!0}),u(o,`${JSON.stringify(r,null,2)}
2
+ `)}catch{return!1}return!0}export{a,k as b,h as c,w as d,P as e,y as f,x as g,C as h};
@@ -0,0 +1 @@
1
+ import{c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i}from"./chunk-BX5KIC4R.js";import"./chunk-UTYFLLSM.js";import"./chunk-MVTU4M3W.js";import"./chunk-DVYH677E.js";import"./chunk-WOT6VMZA.js";export{b as CLI_REFRESH_SKEW_MS,c as accessTokenIsFresh,g as clearCliCredential,a as cliCredentialsPath,e as readCliCredential,h as refreshCliCredential,d as refreshTokenIsUsable,i as renewCliCredentialIfNeeded,f as writeCliCredential};
@@ -0,0 +1 @@
1
+ import{readFileSync as u}from"node:fs";import{join as c}from"node:path";import{EnvHttpProxyAgent as p,ProxyAgent as l,getGlobalDispatcher as a,setGlobalDispatcher as s}from"undici";var f="httpsProxy";function d(n){let e;try{e=JSON.parse(u(c(n,"settings.json"),"utf8"))}catch{return}let r=e[f];if(typeof r!="string")return;let t=r.trim();return t===""?void 0:t}function m(){let e=(process.env.HTTPS_PROXY??process.env.HTTP_PROXY??process.env.ALL_PROXY)?.trim();return e||void 0}function g(n){let e=n.trim();if(e==="")return{ok:!1,problem:"empty"};let r;try{r=new URL(e)}catch{return{ok:!1,problem:`"${e}" is not a URL`}}let t=r.protocol.replace(/:$/,"").toLowerCase();return t!=="http"&&t!=="https"?{ok:!1,problem:`unsupported scheme "${t}"; use http:// or https://`}:r.hostname?{ok:!0,url:e}:{ok:!1,problem:"no host in the proxy URL"}}var i;function P(n){let e=()=>{i===void 0&&(i=a()),s(i)},r=d(n);if(r){let o=g(r);if(!o.ok)return{source:"settings"};try{s(new l(o.url))}catch{return e(),{source:"settings"}}return{url:o.url,source:"settings"}}let t=m();if(t){try{s(new p)}catch{return e(),{source:"env"}}return{url:t,source:"env"}}return e(),{source:"none"}}export{f as a,d as b,m as c,g as d,P as e};
@@ -0,0 +1 @@
1
+ import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i,k as j,l as k,m as l,n as m,o as n,p as o,q as p,r as q}from"./chunk-JFYVRWJI.js";import"./chunk-WOT6VMZA.js";export{c as APPROVAL_LABELS,b as APPROVAL_MODES,f as MODE_MAX_TIER,e as TIER_RANK,q as createPermissionExtension,h as criticalCommand,n as decideToolCall,o as describeToolCall,p as formatApprovalPrompt,j as getApprovalMode,d as isApprovalMode,l as isDangerousBypass,a as isReadOnlyCommand,g as resolveTier,i as setApprovalMode,m as setApprovalPrompt,k as setDangerousBypass};
@@ -0,0 +1,2 @@
1
+ import{b as c,d as l}from"./chunk-27TRKD65.js";import{D as s}from"./chunk-V656XVXV.js";import"./chunk-UTYFLLSM.js";import{a as i,b as r}from"./chunk-DVYH677E.js";import"./chunk-WOT6VMZA.js";var d=[["/connect","sign in with your howtofix.id email:password \u2014 no browser needed"],["/model","choose which model answers"],["/help","list every command"],["/quit","leave"]],u=[" \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557"," \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2554\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D"," \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2557 "," \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2554\u2550\u2550\u255D "," \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u255D \u2588\u2588\u2557\u2588\u2588\u2551 "," \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D "],m=[" _ _ _____ ","| | | | __ __ | ___|","| |_| | \\ \\/ / | |_ ","| _ | > < | _| ","|_| |_| /_/\\_\\ |_| "];function g(){if(process.platform==="win32")return!1;let e=(process.env.LC_ALL||process.env.LC_CTYPE||process.env.LANG||"").toLowerCase();return e===""||e==="c"||e==="posix"||!e.includes("utf-8")&&!e.includes("utf8")?!1:!/ja|ko|zh|_kr|_jp|_cn|_tw|_hk/.test(e)}function h(){return g()?u:m}var _="https://howtofix.id/cli";function p(e){let n=process.env.HOME??"",t=n!==""&&e.startsWith(n)?`~${e.slice(n.length)}`:e,o=t.split("/").filter(Boolean);return o.length>3?`\u2026/${o.slice(-2).join("/")}`:t}function f(e){let n=e.signedIn?d.filter(([t])=>t!=="/connect"):d;return[...h(),"",`${i} ${r} \u2014 a terminal coding agent. Describe the change you want and it reads, edits and runs the code in front of you.`,"",` working in ${p(e.cwd)}`,...e.note?[` session ${e.note}`]:[],"",...e.signedIn?[" already signed in to howtofix.id",""]:[],...n.map(([t,o])=>` ${t.padEnd(11)}${o}`),"",' Or just start typing. Every message goes to the model; anything beginning with "/" stays local.'].join(`
2
+ `)}function w(){return[{value:"connect",label:"Sign in to howtofix.id",description:"opens the browser, or paste a key from the panel"},{value:"ready",label:"I have a key \u2014 just give me the prompt",description:"drops you at the prompt; run /connect whenever you like"},{value:"release",label:"What's in this release",description:`opens the ${r} notes in your browser`}]}async function E(e,n,t){c(s).welcomeSeen||(l(s),t(`welcome to ${i}`,f(e)),!e.signedIn&&await new Promise(o=>{n("First run \u2014 how do you want to begin?",w(),a=>{a==="connect"&&e.runSlash("/connect"),a==="release"&&e.openExternal(_),o()},()=>o())}))}export{E as maybeShowWelcome};
@@ -0,0 +1 @@
1
+ function o(e){let n=0,r;return{limit:e,close(t){n+=t},total(t){return n+t},check(t){if(e===void 0||r!==void 0)return r;let d=n+t;return d-e>1e-9&&(r={spent:d,limit:e}),r}}}function u(e,n){return`stopped \u2014 spent $${e.toFixed(4)} of a $${n.toFixed(2)} budget.`}function i(e,n){return`--max-budget-usd needs a model with prices, and ${e} declares none (its rates are zero, so every turn costs $0 and the budget would never fire). Add a cost to that model in ${n}/models.json, or drop the flag.`}export{o as a,u as b,i as c};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u}from"./chunk-WUPU6LTD.js";import"./chunk-WOT6VMZA.js";export{f as BROKEN_LOCK_GRACE_MS,c as CHECK_ATTEMPTS,k as CHECK_FAILED_MESSAGE,b as CHECK_TIMEOUT_MS,d as INSTALL_TIMEOUT_MS,e as LOCK_TIMEOUT_MS,j as NPM_MISSING_MESSAGE,a as PACKAGE_NAME,n as acquireUpdateLock,u as autoUpdateEnabled,l as checkFailedNote,q as checkForUpdate,g as compareVersions,s as installUpdate,t as isInstalledCopy,h as isNewer,p as latestVersion,r as npmFailureDetail,m as pidAlive,o as releaseUpdateLock,i as resolveNpm};
@@ -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-LJEKOS4S.js";import{g as oe,k as se}from"./chunk-BX5KIC4R.js";import"./chunk-UTYFLLSM.js";import"./chunk-MVTU4M3W.js";import{b as I,c as V,d as J}from"./chunk-DVYH677E.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};
@@ -0,0 +1,2 @@
1
+ function d(n,t){let e=`${n??""} ${t}`;if(/EACCES|EPERM/.test(e))return"the file or directory is not writable; check permissions and try again";if(/ENOENT/.test(e))return"a file or directory this command needs is missing";if(/ENOSPC/.test(e))return"the disk is full";if(/ECONNREFUSED|ENOTFOUND|EAI_AGAIN|ETIMEDOUT|UND_ERR|fetch failed/i.test(e))return"the network request failed; check the connection and the gateway address";if(/EADDRINUSE/.test(e))return"another process is already using that port";if(/MODULE_NOT_FOUND|ERR_MODULE_NOT_FOUND/.test(e))return"a required file or package is missing; reinstall HowToFix";if(/JSON/i.test(e)&&/parse|unexpected token|end of input/i.test(e))return"a configuration file is not valid JSON";if(/not a git repository/i.test(e))return"run the command inside a project, or pass --cwd"}function c(n){let e=(n instanceof Error?n.message:String(n)).trim()||"unknown error",i=n?.code;return{message:e,hint:d(i,e)}}function u(n,t,e,i=!1){let{message:r,hint:s}=c(e),o=[t?`${n}: ${t}: ${r}`:`${n}: ${r}`];return s&&o.push(` ${s}`),i&&e instanceof Error&&e.stack&&o.push(e.stack),o.join(`
2
+ `)}function f(n,t,e,i){let r=i?.debug??process.env.HOWTOFIX_DEBUG==="1";(i?.write??(a=>console.error(a)))(u(n,t,e,r))}export{c as a,f as b};