howtofixcli 0.7.7 → 0.7.9

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 (152) hide show
  1. package/dist/chunk-27TRKD65.js +2 -0
  2. package/dist/chunk-3FYCFLNK.js +1 -0
  3. package/dist/chunk-56SEAGAQ.js +1 -0
  4. package/dist/chunk-63ZCQDXH.js +6 -0
  5. package/dist/chunk-6FUWMLWO.js +1 -0
  6. package/dist/chunk-7CHDNTH6.js +1 -0
  7. package/dist/chunk-ACOMNDUL.js +185 -0
  8. package/dist/chunk-AEVPET7X.js +2 -0
  9. package/dist/chunk-AGGIYXN7.js +2 -0
  10. package/dist/chunk-BHVBO4SC.js +1 -0
  11. package/dist/chunk-FPXVDP32.js +8 -0
  12. package/dist/chunk-GIUYIKH3.js +109 -0
  13. package/dist/chunk-GQCAJ56I.js +5 -0
  14. package/dist/chunk-GXB7RZHH.js +1 -0
  15. package/dist/chunk-IGEY3AWF.js +1 -0
  16. package/dist/chunk-ILDDDLRC.js +1 -0
  17. package/dist/chunk-JFYVRWJI.js +2 -0
  18. package/dist/chunk-MVLCGU3G.js +1 -0
  19. package/dist/chunk-N345KWWK.js +1 -0
  20. package/dist/chunk-NBQFPCRT.js +1 -0
  21. package/dist/chunk-OIPSLIZE.js +5 -0
  22. package/dist/chunk-ORJ2QZBG.js +3 -0
  23. package/dist/chunk-PCALBZOO.js +2 -0
  24. package/dist/chunk-PDNBGUYP.js +2 -0
  25. package/dist/chunk-S656RE4A.js +1 -0
  26. package/dist/chunk-TSEKPGK4.js +1 -0
  27. package/dist/chunk-U6CI6KXN.js +34 -0
  28. package/dist/chunk-UTYFLLSM.js +1 -0
  29. package/dist/chunk-V3R4FYTJ.js +1 -0
  30. package/dist/chunk-V656XVXV.js +8 -0
  31. package/dist/chunk-WKUJ7CFO.js +1 -0
  32. package/dist/chunk-WOT6VMZA.js +1 -0
  33. package/dist/chunk-WUPU6LTD.js +4 -0
  34. package/dist/chunk-WX3V5P7U.js +5 -0
  35. package/dist/chunk-ZKZ6WCI3.js +2 -0
  36. package/dist/main.js +94 -536
  37. package/package.json +15 -62
  38. package/dist/account-credential.js +0 -136
  39. package/dist/account-credential.test.js +0 -38
  40. package/dist/activity.js +0 -124
  41. package/dist/agent-defs.js +0 -237
  42. package/dist/agent-limiter.js +0 -68
  43. package/dist/agents.js +0 -554
  44. package/dist/anim.js +0 -361
  45. package/dist/args.js +0 -228
  46. package/dist/at-file.js +0 -28
  47. package/dist/brand-extension.js +0 -87
  48. package/dist/brand.js +0 -76
  49. package/dist/browser.js +0 -58
  50. package/dist/cache-report.js +0 -139
  51. package/dist/checkpoint.js +0 -437
  52. package/dist/claims.js +0 -167
  53. package/dist/cli-auth.js +0 -142
  54. package/dist/cli-checkin.js +0 -116
  55. package/dist/cli-credentials.js +0 -254
  56. package/dist/clipboard.js +0 -149
  57. package/dist/collapse.js +0 -129
  58. package/dist/commands.js +0 -301
  59. package/dist/compaction-guard.js +0 -81
  60. package/dist/context-extension.js +0 -17
  61. package/dist/dcp/commands.js +0 -172
  62. package/dist/dcp/compress-state.js +0 -139
  63. package/dist/dcp/compress.js +0 -329
  64. package/dist/dcp/dcp-extension.js +0 -288
  65. package/dist/dcp/dedup.js +0 -93
  66. package/dist/dcp/ids.js +0 -189
  67. package/dist/dcp/index.js +0 -25
  68. package/dist/dcp/prompts.js +0 -68
  69. package/dist/dcp/protected-content.js +0 -221
  70. package/dist/dcp/protected.js +0 -161
  71. package/dist/dcp/prune.js +0 -418
  72. package/dist/dcp/state.js +0 -176
  73. package/dist/device-id.js +0 -90
  74. package/dist/device-id.test.js +0 -23
  75. package/dist/errors.js +0 -63
  76. package/dist/extensions.js +0 -48
  77. package/dist/fatal.js +0 -35
  78. package/dist/feed.js +0 -498
  79. package/dist/fs-atomic.js +0 -54
  80. package/dist/gateway-errors.js +0 -90
  81. package/dist/git.js +0 -230
  82. package/dist/goal-extension.js +0 -88
  83. package/dist/goal.js +0 -222
  84. package/dist/hooks-extension.js +0 -176
  85. package/dist/hooks.js +0 -443
  86. package/dist/howtofix-account.js +0 -715
  87. package/dist/hud-line.js +0 -153
  88. package/dist/hwid.js +0 -130
  89. package/dist/interrupt.js +0 -60
  90. package/dist/json-events.js +0 -50
  91. package/dist/level-style.js +0 -112
  92. package/dist/loop-guard.js +0 -95
  93. package/dist/lsp-tools.js +0 -32
  94. package/dist/lsp.js +0 -347
  95. package/dist/mcp-config.js +0 -85
  96. package/dist/mcp-lifecycle.js +0 -147
  97. package/dist/model-catalog.js +0 -217
  98. package/dist/model-resolve.js +0 -65
  99. package/dist/notes.js +0 -78
  100. package/dist/oauth-login.js +0 -568
  101. package/dist/paths.js +0 -61
  102. package/dist/permissions.js +0 -298
  103. package/dist/plan-mode.js +0 -363
  104. package/dist/preset-command.js +0 -227
  105. package/dist/preset-extension.js +0 -35
  106. package/dist/preset-mcp.js +0 -292
  107. package/dist/presets.js +0 -727
  108. package/dist/prompt-files.js +0 -103
  109. package/dist/prompt-text.js +0 -41
  110. package/dist/proxy.js +0 -137
  111. package/dist/quality/ast.js +0 -196
  112. package/dist/quality/cognitive.js +0 -83
  113. package/dist/quality/cyclomatic.js +0 -30
  114. package/dist/quality/halstead.js +0 -83
  115. package/dist/quality/index.js +0 -18
  116. package/dist/quality/length.js +0 -3
  117. package/dist/quality/maintainability.js +0 -15
  118. package/dist/quality/nesting.js +0 -57
  119. package/dist/quality/report.js +0 -803
  120. package/dist/quality/smells.js +0 -67
  121. package/dist/quality-tool.js +0 -63
  122. package/dist/read-only-commands.js +0 -597
  123. package/dist/repo-map.js +0 -292
  124. package/dist/rtk.js +0 -193
  125. package/dist/sandbox.js +0 -105
  126. package/dist/schema.js +0 -214
  127. package/dist/session-lifecycle.js +0 -19
  128. package/dist/session-retention.js +0 -111
  129. package/dist/session.js +0 -446
  130. package/dist/sessions.js +0 -100
  131. package/dist/settings.js +0 -148
  132. package/dist/skills.js +0 -35
  133. package/dist/slop-tool.js +0 -96
  134. package/dist/spend-cap.js +0 -43
  135. package/dist/subagent.js +0 -171
  136. package/dist/tar.js +0 -146
  137. package/dist/theme.js +0 -79
  138. package/dist/thinking.js +0 -45
  139. package/dist/todo.js +0 -114
  140. package/dist/tool-loadout.js +0 -97
  141. package/dist/tool-render.js +0 -769
  142. package/dist/tools.js +0 -176
  143. package/dist/ui.js +0 -4751
  144. package/dist/update.js +0 -533
  145. package/dist/usage-segment.js +0 -69
  146. package/dist/web-tools.js +0 -46
  147. package/dist/web.js +0 -265
  148. package/dist/welcome.js +0 -179
  149. package/dist/workflow-engine.js +0 -246
  150. package/dist/workflow-progress.js +0 -446
  151. package/dist/workflow-view.js +0 -195
  152. package/dist/workflow.js +0 -349
@@ -0,0 +1,2 @@
1
+ import{a as x}from"./chunk-UTYFLLSM.js";import{g as P,j as M}from"./chunk-ZKZ6WCI3.js";import{existsSync as z,readFileSync as ye}from"node:fs";import{join as xe}from"node:path";import{createHash as J,randomBytes as G}from"node:crypto";import{createServer as ne}from"node:http";import{execFileSync as X}from"node:child_process";import{createHmac as Q}from"node:crypto";import{readFileSync as ee}from"node:fs";import{arch as N,cpus as $,hostname as O,platform as _,userInfo as H}from"node:os";var te="howtofix-cli-hwid-v1";function v(e){try{let t=ee(e,"utf8").trim();return t.length>0?t:void 0}catch{return}}function F(e,t){try{let r=X(e,t,{encoding:"utf8",timeout:3e3,stdio:["ignore","pipe","ignore"]});return r.trim().length>0?r.trim():void 0}catch{return}}function re(){let e=_();if(e==="linux"){let t=v("/etc/machine-id");if(t)return{value:t,source:"machine-id",strong:!0};let r=v("/var/lib/dbus/machine-id");if(r)return{value:r,source:"dbus-machine-id",strong:!0};let s=v("/sys/class/dmi/id/product_uuid");return s?{value:s,source:"dmi-product-uuid",strong:!0}:void 0}if(e==="win32"){let r=F("reg",["query","HKLM\\SOFTWARE\\Microsoft\\Cryptography","/v","MachineGuid"])?.match(/MachineGuid\s+REG_SZ\s+(\S+)/i);return r?.[1]?{value:r[1],source:"windows-machine-guid",strong:!0}:void 0}if(e==="darwin"){let r=F("ioreg",["-rd1","-c","IOPlatformExpertDevice"])?.match(/"IOPlatformUUID"\s*=\s*"([^"]+)"/);return r?.[1]?{value:r[1],source:"platform-uuid",strong:!0}:void 0}}function U(){let e=re(),t=e?.value??[O(),_(),N(),H().username].join("\0"),r=e?.source??"hostname";return{id:Q("sha256",te).update(t).digest("hex").slice(0,32),source:r,strong:e?.strong??!1}}function j(e){return[e.id,e.source,O(),_(),N(),H().username,String($().length),$()[0]?.model??""]}var I="https://howtofix.id",se=300*1e3,L=3e3,K="/callback";function A(e){return e.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function oe(){return A(G(32))}function ie(e){return A(J("sha256").update(e).digest())}function ae(){return A(G(16))}var ce="howtofix-cli-",ue="x-howtofix-client",le="cli";function C(e){let t=e??j(U());return ce+J("sha256").update(t.join("\0")).digest("hex").slice(0,32)}function de(){return{"content-type":"application/json",[ue]:le}}var fe=()=>new Promise((e,t)=>{let r=ne();r.once("error",t),r.listen(0,"127.0.0.1",()=>{let{port:s}=r.address();e({port:s,close:()=>r.close(),waitForCode:(o,n)=>new Promise((i,a)=>{let c=(l,m)=>{let h=new URL(l.url??"/","http://127.0.0.1");if(h.pathname!==K){m.writeHead(404).end("not found");return}let y=(V,Z)=>m.writeHead(200,{"content-type":"text/html; charset=utf-8"}).end(`<!doctype html><meta charset="utf-8"><h2>${V}</h2><p>${Z}</p>`),T=h.searchParams.get("error")??"",R=h.searchParams.get("code")??"",Y=h.searchParams.get("state")??"";if(T){y("Sign-in was refused","You can close this tab."),u(new Error(`the browser reported: ${T}`));return}if(!R||Y!==o){y("This callback did not belong to the login","You can close this tab."),u(new Error("the callback carried the wrong state"));return}y("Signed in","You can close this tab and go back to HowToFix."),u(void 0,R)},u=(l,m)=>{r.off("request",c),n?.removeEventListener("abort",f),l?a(l):i(m)},f=()=>u(new Error("cancelled"));n?.addEventListener("abort",f,{once:!0}),r.on("request",c)})})})});function k(e,t){e.onProgress?.(t)}async function g(e,t,r,s){let o=await e(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(r),signal:s}),n={};try{n=await o.json()}catch{}let i=Number(o.headers?.get?.("retry-after"));return{status:o.status,body:n,retryAfterSeconds:Number.isFinite(i)&&i>0?i:void 0}}function d(...e){for(let t of e)if(typeof t=="string"&&t.trim()!=="")return t.trim()}function D(...e){for(let t of e)if(typeof t=="number"&&Number.isFinite(t))return t;return 0}function me(e){try{let t=new URL(e).searchParams.get("code");return t&&t.trim()!==""?t.trim():void 0}catch{return}}async function pe(e,t,r){let s=await e(t,{headers:de(),signal:r}),o={};try{o=await s.json()}catch{}let n=Number(s.headers?.get?.("retry-after"));return{status:s.status,body:o,retryAfterSeconds:Number.isFinite(n)&&n>0?n:void 0}}function S(e){let t=e.data,r=[e.token,e.api_key,e.apiKey,e.key,t?.token,t?.api_key,t?.apiKey,t?.key];for(let s of r)if(typeof s=="string"&&s.trim().startsWith("sk-"))return s.trim()}function ge(e){let t=e.data,r=d(e.token,t?.token),s=d(e.refresh_token,t?.refresh_token),o=d(e.device_id,t?.device_id);if(!r||!s||!o)return;let n=D(e.access_expires_at,t?.access_expires_at),i=D(e.refresh_expires_at,t?.refresh_expires_at);return{accessToken:r,accessExpiresAt:n,refreshToken:s,deviceId:o,refreshExpiresAt:i}}function p(e,t){let r=e.message??e.error;return typeof r=="string"&&r.trim()?r.trim():t}async function Oe(e){let t=e.fetchImpl??fetch,r=(e.panelUrl??I).replace(/\/+$/,""),s=e.timeoutMs??se,o={...e,panel:r,fetchImpl:t,timeoutMs:s},n=await ke(o);if(n.ok||n.terminal)return n.result;let i=await he(o);if(i.ok||i.terminal)return i.result;let a=await we(o);return a.ok?a:{ok:!1,message:`${n.result.ok?"":n.result.message}; ${i.result.ok?"":i.result.message}; ${a.message}. howtofix.id does not offer a browser login a local client can complete yet \u2014 run /connect and paste a token from ${r}/keys instead.`}}async function he(e){let t=oe(),r=ae(),s;try{s=await(e.loopback??fe)();let o=`http://127.0.0.1:${s.port}${K}`,n=await g(e.fetchImpl,`${e.panel}/api/oauth/device/start`,{redirect_uri:o,code_challenge:ie(t),code_challenge_method:"S256",state:r},e.signal);if(n.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no loopback login endpoint"}};if(n.status>=400)return{ok:!1,terminal:!1,result:{ok:!1,message:p(n.body,`the panel refused the login (${n.status})`)}};let i=typeof n.body.authorize_url=="string"?n.body.authorize_url:"";if(!i)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not say where to send the browser"}};k(e,{kind:"browser",url:i});let a=await be(s.waitForCode(r,e.signal),e.timeoutMs),c=await g(e.fetchImpl,`${e.panel}/api/oauth/device/token`,{flow_token:n.body.flow_token,code:a,code_verifier:t},e.signal);if(c.status>=400)return{ok:!1,terminal:!0,result:{ok:!1,message:p(c.body,`the panel refused the exchange (${c.status})`)}};let u=S(c.body);return u?{ok:!0,result:{ok:!0,token:u}}:{ok:!1,terminal:!0,result:{ok:!1,message:"the panel did not return an API key"}}}catch(o){let n=o instanceof Error?o.message:String(o);return{ok:!1,terminal:n==="cancelled",result:{ok:!1,message:n}}}finally{s?.close()}}async function ke(e){let t=e.pollIntervalMs??L,r=e.fingerprintId??C(),s=e.clientInfo??P(),o=M(r,s);try{let n=await g(e.fetchImpl,`${e.panel}/api/auth/cli/code`,{fingerprintId:r,clientInfo:s,...o},e.signal);if(n.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no CLI login endpoint"}};if(n.status===401)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not recognise this build as the HowToFix CLI \u2014 update it with `npm install -g howtofixcli@latest`"}};if(n.status===429)return{ok:!1,terminal:!0,result:{ok:!1,message:`too many sign-in attempts from this machine right now.${n.retryAfterSeconds?` Try again in ${Math.ceil(n.retryAfterSeconds/60)} minute(s).`:""}`}};if(n.status>=400)return{ok:!1,terminal:!1,result:{ok:!1,message:p(n.body,`the panel refused the login (${n.status})`)}};let i=n.body.data??{},a=d(n.body.login_url,i.login_url),c=d(n.body.code,i.code)??(a?me(a):void 0),u=d(n.body.secret,i.secret);return!a||!c?{ok:!1,terminal:!1,result:{ok:!1,message:"the panel did not return a login URL"}}:u?(k(e,{kind:"browser",url:a}),await q(e,c,u)):(k(e,{kind:"browser",url:a}),await q(e,c,void 0))}catch(n){let i=n instanceof Error?n.message:String(n);return{ok:!1,terminal:i==="cancelled",result:{ok:!1,message:i}}}}async function q(e,t,r){let s=e.pollIntervalMs??L,o=Date.now()+e.timeoutMs;for(;Date.now()<o;){await w(s,e.signal);let n=new URLSearchParams(r?{code:t,secret:r}:{code:t});n.set("capability","device-refresh");let i=await pe(e.fetchImpl,`${e.panel}/api/auth/cli/status?${n}`,e.signal);if(i.status===404)return{ok:!1,terminal:!1,result:{ok:!1,message:"the panel has no CLI login status endpoint"}};if(i.status===403)return{ok:!1,terminal:!0,result:{ok:!1,message:"the panel rejected this poll \u2014 run /connect again"}};if(i.status===429){let u=Math.min(Math.max(i.retryAfterSeconds??5,1)*1e3,3e4);await w(u,e.signal);continue}let a=S(i.body);if(a)return{ok:!0,result:{ok:!0,token:a,credential:ge(i.body)}};if(d(i.body.data?.status,i.body.status)==="expired")return{ok:!1,terminal:!0,result:{ok:!1,message:"the sign-in link expired before it was approved"}};if(i.status>=400)return{ok:!1,terminal:!0,result:{ok:!1,message:p(i.body,`the panel refused the poll (${i.status})`)}}}return{ok:!1,terminal:!0,result:{ok:!1,message:"the sign-in was not approved in time"}}}async function we(e){let t=e.pollIntervalMs??L;try{let r=await g(e.fetchImpl,`${e.panel}/api/oauth/device`,{},e.signal);if(r.status===404)return{ok:!1,message:"the panel has no device-code endpoint"};if(r.status>=400)return{ok:!1,message:p(r.body,`the panel refused the request (${r.status})`)};let s=typeof r.body.device_code=="string"?r.body.device_code:"",o=typeof r.body.user_code=="string"?r.body.user_code:"",n=typeof r.body.verification_uri=="string"?r.body.verification_uri:`${e.panel}/oauth/device`;if(!s||!o)return{ok:!1,message:"the panel did not return a code to show"};k(e,{kind:"code",code:o,url:n});let i=Date.now()+e.timeoutMs;for(;Date.now()<i;){await w(t,e.signal);let a=await g(e.fetchImpl,`${e.panel}/api/oauth/device/poll`,{device_code:s},e.signal);if(a.status===404)return{ok:!1,message:"the panel has no device-code poll endpoint"};let c=typeof a.body.status=="string"?a.body.status:"";if(c==="pending")continue;if(c==="slow_down"){await w(t,e.signal);continue}if(c==="denied")return{ok:!1,message:"the sign-in was refused in the browser"};if(c==="expired")return{ok:!1,message:"the code expired; run /connect again"};let u=S(a.body);if(u)return{ok:!0,token:u};if(a.status>=400)return{ok:!1,message:p(a.body,`the panel refused the poll (${a.status})`)}}return{ok:!1,message:"the code was not approved in time"}}catch(r){return{ok:!1,message:r instanceof Error?r.message:String(r)}}}function be(e,t){return new Promise((r,s)=>{let o=setTimeout(()=>s(new Error("the sign-in was not finished in time")),t);e.then(n=>{clearTimeout(o),r(n)},n=>{clearTimeout(o),s(n)})})}function w(e,t){return new Promise((r,s)=>{let o=setTimeout(r,e);t?.addEventListener("abort",()=>{clearTimeout(o),s(new Error("cancelled"))},{once:!0})})}function b(e){return xe(e,"cli-credentials.json")}var ve=300*1e3;function _e(e,t=Date.now()){return e.accessToken?!Number.isFinite(e.accessExpiresAt)||e.accessExpiresAt<=0?!0:e.accessExpiresAt*1e3-ve>t:!1}function Ie(e,t=Date.now()){return!e.refreshToken||!e.deviceId?!1:!Number.isFinite(e.refreshExpiresAt)||e.refreshExpiresAt<=0?!0:e.refreshExpiresAt*1e3>t}function Je(e){let t=b(e);if(!z(t))return;let r;try{r=JSON.parse(ye(t,"utf8"))}catch{return}if(!r||typeof r!="object"||Array.isArray(r))return;let s=r,o=typeof s.accessToken=="string"?s.accessToken.trim():"",n=typeof s.refreshToken=="string"?s.refreshToken.trim():"",i=typeof s.deviceId=="string"?s.deviceId.trim():"";if(!(!o||!n||!i))return{accessToken:o,accessExpiresAt:W(s.accessExpiresAt),refreshToken:n,deviceId:i,refreshExpiresAt:W(s.refreshExpiresAt)}}function Le(e,t){try{return x(b(e),`${JSON.stringify(t,null,2)}
2
+ `,{mode:384}),!0}catch{return!1}}function Ae(e){try{let t=b(e);z(t)&&x(t,"",{mode:384})}catch{}}function W(e){return typeof e=="number"&&Number.isFinite(e)?e:0}async function Ce(e,t){let r=(t?.panelUrl??I).replace(/\/+$/,""),s=t?.fetchImpl??fetch,o=t?.timeoutMs??15e3,n=new AbortController,i=setTimeout(()=>n.abort(),o);try{let a=await s(`${r}/api/auth/cli/refresh`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({device_id:e.deviceId,refresh_token:e.refreshToken,fingerprint_id:C()}),signal:n.signal}),c=await a.json().catch(()=>({}));if(a.status===401||a.status===403)return{ok:!1,terminal:!0,message:"this sign-in is no longer valid \u2014 run /connect to sign in again"};if(!a.ok)return{ok:!1,terminal:!1,message:`the panel refused the renewal (${a.status})`};let u=c.data??{},f=E(c.token,u.token),l=E(c.refresh_token,u.refresh_token),m=E(c.device_id,u.device_id)??e.deviceId;return!f||!l?{ok:!1,terminal:!1,message:"the panel did not return a renewed credential"}:{ok:!0,terminal:!1,credential:{accessToken:f,accessExpiresAt:B(c.access_expires_at,u.access_expires_at),refreshToken:l,deviceId:m,refreshExpiresAt:B(c.refresh_expires_at,u.refresh_expires_at)}}}catch(a){return{ok:!1,terminal:!1,message:a instanceof Error&&a.name==="AbortError"?`the panel did not answer within ${Math.round(o/1e3)}s`:"could not reach the panel"}}finally{clearTimeout(i)}}function E(...e){for(let t of e)if(typeof t=="string"&&t.trim())return t.trim()}function B(...e){for(let t of e)if(typeof t=="number"&&Number.isFinite(t))return t;return 0}async function Ge(e,t,r){let s=r?.now??Date.now();if(_e(t,s)||!Ie(t,s))return{credential:t,renewed:!1,terminal:!1};let o=await Ce(t,r);if(!o.ok||!o.credential)return o.terminal&&Ae(e),{credential:t,renewed:!1,terminal:o.terminal,message:o.message};let n=Le(e,o.credential);return{credential:o.credential,renewed:!0,terminal:!1,message:n?void 0:`the renewed sign-in could not be saved to ${b(e)}`}}export{I as a,Oe as b,b as c,ve as d,_e as e,Ie as f,Je as g,Le as h,Ae as i,Ce as j,Ge as k};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h,i,j}from"./chunk-ZKZ6WCI3.js";import"./chunk-OIPSLIZE.js";import"./chunk-WOT6VMZA.js";export{h as CLI_CLIENT_HEADER,a as CLI_SIGNING_KEY_ID,i as cliClientHeader,c as cliSignaturePayload,f as cliSigningKeyFingerprint,e as cliSigningKeyMatchesPanel,b as cliSigningPublicKey,d as createNonce,g as describeClient,j as signLoginRequest};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-ORJ2QZBG.js";import"./chunk-WOT6VMZA.js";export{a as expandFileReferences};
@@ -0,0 +1,34 @@
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-ACOMNDUL.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-63ZCQDXH.js";import{g as ne,k as oe}from"./chunk-PDNBGUYP.js";import"./chunk-UTYFLLSM.js";import"./chunk-ZKZ6WCI3.js";import{b as M,c as Y,d as V}from"./chunk-OIPSLIZE.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","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};
@@ -0,0 +1 @@
1
+ import{closeSync as S,fsyncSync as d,openSync as f,renameSync as i,rmSync as t,writeSync as a}from"node:fs";import{dirname as u,join as E}from"node:path";function l(o,m,s){let r=E(u(o),`.${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}.tmp`),e=f(r,"w",s?.mode);try{a(e,m),d(e)}finally{S(e)}try{i(r,o)}catch(n){let c=n.code;if(c!=="EPERM"&&c!=="EBUSY"&&c!=="EACCES")throw t(r,{force:!0}),n;t(o,{force:!0});try{i(r,o)}catch(y){throw t(r,{force:!0}),y}}}export{l as a};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g,h}from"./chunk-27TRKD65.js";import"./chunk-UTYFLLSM.js";import"./chunk-WOT6VMZA.js";export{a as DEFAULT_WORKBENCH_SETTINGS,d as markWelcomeSeen,b as readWorkbenchSettings,f as rightClickPastesHere,g as writeAgentsSetting,e as writeRightClickPasteSetting,h as writeStringSetting,c as writeWorkbenchSetting};
@@ -0,0 +1,8 @@
1
+ import{a as j}from"./chunk-UTYFLLSM.js";import{homedir as we}from"node:os";import{join as $,resolve as Ae}from"node:path";import{cpSync as ue,existsSync as S,mkdirSync as P,mkdtempSync as D,readdirSync as R,readFileSync as O,renameSync as pe,rmSync as k,statSync as x,writeFileSync as T}from"node:fs";import{tmpdir as X}from"node:os";import{dirname as Z,isAbsolute as me,join as l,relative as ge,resolve as N}from"node:path";import{fileURLToPath as de}from"node:url";import{execFileSync as ye}from"node:child_process";import{createHash as U}from"node:crypto";import{existsSync as w,readFileSync as H}from"node:fs";import{dirname as oe,join as L}from"node:path";import{fileURLToPath as ae}from"node:url";function F(e=y){return L(e,"mcp.json")}function z(e){let r=[];if(e===void 0)return r;if(typeof e!="object"||e===null||Array.isArray(e))return["mcp must be an object of server names"];for(let[t,s]of Object.entries(e)){if(!/^[A-Za-z0-9_-]+$/.test(t)){r.push(`mcp server "${t}" must use only letters, digits, _ and -`);continue}if(typeof s!="object"||s===null||Array.isArray(s)){r.push(`mcp server "${t}" must be an object`);continue}let n=s,i=typeof n.command=="string"&&n.command.trim()!=="",o=typeof n.url=="string"&&n.url.trim()!=="";!i&&!o&&r.push(`mcp server "${t}" needs either a command or a url`),n.args!==void 0&&!Array.isArray(n.args)&&r.push(`mcp server "${t}": args must be an array`);for(let c of["env","headers"]){let a=n[c];if(a!==void 0){if(typeof a!="object"||a===null||Array.isArray(a)){r.push(`mcp server "${t}": ${c} must be an object of strings`);continue}for(let[f,u]of Object.entries(a))typeof u!="string"&&r.push(`mcp server "${t}": ${c}.${f} must be a string`)}}}return r}function J(e){if(!w(e))return{mcpServers:{}};try{let r=JSON.parse(H(e,"utf8"));if(!r||typeof r!="object"||Array.isArray(r))return{mcpServers:{}};let t=r.mcpServers;return!t||typeof t!="object"||Array.isArray(t)?{mcpServers:{}}:{mcpServers:t}}catch{return{mcpServers:{}}}}function Te(e,r=y){let t=Object.keys(e);if(t.length===0)return{added:[],skipped:[],problems:[]};let s=F(r),n=[];if(w(s))try{JSON.parse(H(s,"utf8"))}catch{return{added:[],skipped:[],problems:[`${s} is not valid JSON; leaving it alone`]}}let i=J(s),o=[],c=[];for(let a of t){if(i.mcpServers[a]!==void 0){c.push(a);continue}i.mcpServers[a]=e[a],o.push(a)}if(o.length>0)try{j(s,`${JSON.stringify(i,null,2)}
2
+ `)}catch(a){return{added:[],skipped:c,problems:[`could not write ${s}: ${a instanceof Error?a.message:String(a)}`]}}return{added:o,skipped:c,problems:n}}function Ne(e,r=new Set,t=y){let s=F(t),n=[];if(e.length===0||!w(s))return{removed:[],kept:[],problems:n};let i=J(s),o=[],c=[];for(let a of e)if(i.mcpServers[a]!==void 0){if(r.has(a)){c.push(a);continue}delete i.mcpServers[a],o.push(a)}if(o.length>0)try{j(s,`${JSON.stringify(i,null,2)}
3
+ `)}catch(a){return{removed:[],kept:c,problems:[`could not write ${s}: ${a instanceof Error?a.message:String(a)}`]}}return{removed:o,kept:c,problems:n}}function Ce(e){if(typeof e.url=="string"&&e.url)return`http: ${e.url}`;let r=typeof e.command=="string"?e.command:"",t=Array.isArray(e.args)?e.args.filter(s=>typeof s=="string"):[];return`stdio: ${[r,...t].join(" ")}`.trim()}function ce(){return L(oe(ae(import.meta.url)),"presets","mcp-hub.json")}function De(e=ce()){let r=[];if(!w(e))return{entries:[],problems:[`no MCP catalogue at ${e}`]};let t;try{t=JSON.parse(H(e,"utf8"))}catch(i){return{entries:[],problems:[`${e} is not valid JSON: ${i instanceof Error?i.message:String(i)}`]}}let s=t?.entries;if(!Array.isArray(s))return{entries:[],problems:[`${e} has no entries array`]};let n=[];for(let i of s){if(typeof i!="object"||i===null||Array.isArray(i))continue;let o=i,c=typeof o.name=="string"?o.name.trim():"";if(!c){r.push("an entry has no name");continue}if(!/^[A-Za-z0-9_-]+$/.test(c)){r.push(`"${c}" is not a usable server name`);continue}let a=typeof o.command=="string"&&o.command.trim()!=="",f=typeof o.url=="string"&&o.url.trim()!=="";if(!a&&!f){r.push(`"${c}" has neither a command nor a url`);continue}n.push({name:c,title:typeof o.title=="string"?o.title:c,description:typeof o.description=="string"?o.description:"",category:typeof o.category=="string"?o.category:"other",preset:typeof o.preset=="string"?o.preset:void 0,command:typeof o.command=="string"?o.command:void 0,url:typeof o.url=="string"?o.url:void 0,args:Array.isArray(o.args)?o.args.filter(u=>typeof u=="string"):void 0,env:o.env&&typeof o.env=="object"&&!Array.isArray(o.env)?o.env:void 0,needs:Array.isArray(o.needs)?o.needs.filter(u=>typeof u=="string"):void 0,docs:typeof o.docs=="string"?o.docs:void 0})}return{entries:n,problems:r}}function _e(e){return[...new Set(e.map(r=>r.category))].sort()}function Le(e,r){return e.filter(t=>t.category===r).sort((t,s)=>t.title.localeCompare(s.title))}function Fe(e,r){return e.find(t=>t.name===r)}function ze(e){let r={};return e.command&&(r.command=e.command),e.url&&(r.url=e.url),e.args&&e.args.length>0&&(r.args=[...e.args]),e.env&&Object.keys(e.env).length>0&&(r.env={...e.env}),e.description&&(r.description=e.description),r}function Je(e,r=process.env){return(e.needs??[]).filter(t=>!r[t])}import{gunzipSync as le}from"node:zlib";var v=512;function A(e,r,t){let s=e.subarray(r,r+t),n=s.indexOf(0);return s.subarray(0,n===-1?s.length:n).toString("utf8").trim()}function B(e,r,t){let s=A(e,r,t);if(!s)return 0;let n=Number.parseInt(s,8);return Number.isFinite(n)?n:0}function fe(e){let r={},t=0;for(;t<e.length;){let s=e.indexOf(32,t);if(s===-1)break;let n=Number.parseInt(e.toString("utf8",t,s),10);if(!Number.isFinite(n)||n<=0)break;let i=e.toString("utf8",s+1,t+n-1),o=i.indexOf("=");o>0&&(r[i.slice(0,o)]=i.slice(o+1)),t+=n}return r}function G(e){let r=le(e),t=[],s=0,n,i={};for(;s+v<=r.length;){let o=r.subarray(s,s+v);if(o.every(ie=>ie===0))break;let c=A(o,0,100),a=A(o,345,155),f=B(o,124,12),u=B(o,100,8),m=String.fromCharCode(o[156]??48),p=A(o,157,100),d=f>0?r.subarray(s+v,s+v+f):Buffer.alloc(0);if(s+=v+Math.ceil(f/v)*v,m==="x"||m==="g"){i=fe(d);continue}if(m==="L"){n=d.toString("utf8").replace(/\0.*$/s,"").trim();continue}let h=i.path??n??(a?`${a}/${c}`:c);n=void 0,i={};let g=h.indexOf("/");if(g===-1||(h=h.slice(g+1),h=h.replace(/\/+$/,""),!h))continue;let b=m==="5"?"directory":m==="2"?"symlink":m==="0"||m==="\0"||m===""?"file":"other";t.push({path:h,kind:b,size:f,mode:u&511,...b==="file"?{data:Buffer.from(d)}:{},...b==="symlink"?{link:p}:{}})}return t}function K(e){if(!e||e.startsWith("/")||e.startsWith("\\")||/^[a-zA-Z]:/.test(e))return!1;let r=e.replace(/\/+$/,"");return r?r.split("/").every(s=>s!==""&&s!=="."&&s!==".."):!1}function W(e,r){let t=`${r.replace(/\/+$/,"")}/`,s=[];for(let n of e){if(!n.path.startsWith(t))continue;let i=n.path.slice(t.length);i&&s.push({...n,path:i})}return s}function he(){return l(y,"presets")}function q(e){return l(e,".howtofix","presets")}function V(e){return S(l(e,".disabled"))}function Q(){return l(Z(de(import.meta.url)),"presets")}function M(e){return[q(e),he()]}var Y=/^[a-z0-9][a-z0-9-]*$/,be=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;function C(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function E(e,r){let t=ge(N(e),N(r));return t!==""&&!t.startsWith("..")&&!me(t)}function ee(e,r){let t=[];if(!C(r))return["preset.json must be a JSON object"];let s=p=>{let d=r[p];return typeof d!="string"||d.trim()===""?(t.push(`${p} must be a non-empty string`),""):d.trim()},n=s("name"),i=s("title"),o=s("description"),c=s("category"),a=s("version");n&&!Y.test(n)&&t.push(`name "${n}" must be lowercase letters, digits and dashes`),a&&!be.test(a)&&t.push(`version "${a}" is not a version like 1.0.0`);let f=r.skills;if(!Array.isArray(f)||f.length===0)t.push("skills must be a non-empty array of directory names");else for(let p of f){if(typeof p!="string"||p.trim()===""){t.push("every skills entry must be a non-empty string");continue}let d=l(e,"skills",p.trim());if(!E(l(e,"skills"),d)){t.push(`skill "${p}" escapes the preset directory`);continue}S(l(d,"SKILL.md"))||t.push(`skill "${p}" has no SKILL.md at ${l("skills",p)}`)}let u=r.prompt;if(u!==void 0)if(typeof u!="string"||u.trim()==="")t.push("prompt must be a non-empty string when present");else{let p=l(e,u.trim());E(e,p)?S(p)||t.push(`prompt file "${u}" does not exist`):t.push(`prompt "${u}" escapes the preset directory`)}let m=r.tags;return m!==void 0&&!Array.isArray(m)&&t.push("tags must be an array when present"),t.push(...z(r.mcp)),t}function te(e){let r=l(e,"preset.json");if(!S(r))return{problems:[`no preset.json in ${e}`]};let t;try{t=JSON.parse(O(r,"utf8"))}catch(o){return{problems:[`preset.json is not valid JSON: ${o instanceof Error?o.message:String(o)}`]}}let s=ee(e,t);if(s.length>0)return{problems:s};let n=t,i=Array.isArray(n.tags)?n.tags.filter(o=>typeof o=="string"):[];return{problems:[],manifest:{name:String(n.name),title:String(n.title),description:String(n.description),category:String(n.category),tags:i,version:String(n.version),skills:n.skills.map(o=>String(o)),prompt:typeof n.prompt=="string"?n.prompt:void 0,mcp:n.mcp&&typeof n.mcp=="object"&&!Array.isArray(n.mcp)?n.mcp:void 0,integrates:typeof n.integrates=="string"&&n.integrates.trim()!==""?n.integrates.trim():void 0}}}function _(e){return e.filter(r=>{try{return x(r).isDirectory()}catch{return!1}})}function I(e,r){let t=[],s=[],n=(o,c)=>{if(!S(l(o,"preset.json")))return;let{manifest:a,problems:f}=te(o);a?t.push({manifest:a,dir:o,source:r}):s.push(`${c}: ${f.join("; ")}`)},i;try{i=R(e).sort()}catch{return{entries:t,problems:s}}for(let o of i){if(o.startsWith("."))continue;let c=l(e,o);try{if(!x(c).isDirectory())continue}catch{continue}if(S(l(c,"preset.json"))){n(c,o);continue}let a;try{a=R(c).sort()}catch{continue}for(let f of a){if(f.startsWith("."))continue;let u=l(c,f);try{if(!x(u).isDirectory())continue}catch{continue}n(u,l(o,f))}}return{entries:t,problems:s}}function tt(e){let r=I(Q(),"bundled"),t=[...r.entries],s=[...r.problems],n=new Map(t.map(i=>[i.manifest.name,i]));for(let i of _(M(e))){let o=I(i,"installed");s.push(...o.problems);for(let c of o.entries){let a=n.get(c.manifest.name);if(a){let f=t.indexOf(a);f>=0&&(t[f]=c),n.set(c.manifest.name,c)}else t.push(c),n.set(c.manifest.name,c)}}return{entries:t,problems:s}}function rt(e){return[...new Set(e.map(r=>r.manifest.category))].sort()}function nt(e,r){return e.filter(t=>t.manifest.category===r).sort((t,s)=>t.manifest.title.localeCompare(s.manifest.title))}function re(e){let r=[];for(let t of _(M(e))){let{entries:s}=I(t,"installed");for(let n of s)V(n.dir)||r.push(l(n.dir,"skills"))}return r}function st(e){let r=[];for(let t of _(M(e))){let{entries:s}=I(t,"installed");for(let n of s){if(V(n.dir))continue;let i=n.manifest.prompt;if(!i)continue;let o=l(n.dir,i);if(E(n.dir,o))try{let c=O(o,"utf8").trim();c&&r.push({name:n.manifest.name,title:n.manifest.title,text:c})}catch{}}}return r}function it(e,r){let t=0;for(let s of r.skills)try{t+=x(l(e,"skills",s,"SKILL.md")).size}catch{}return t}function ke(e){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}var Se=".install.lock";function ve(e,r){P(e,{recursive:!0});let t=l(e,Se),s=Date.now()+6e4;for(;;)try{T(t,`${process.pid}
4
+ `,{flag:"wx"});break}catch(n){if(n.code!=="EEXIST")throw n;let i=!1;try{i=Date.now()-x(t).mtimeMs>12e4}catch{continue}if(i){k(t,{force:!0});continue}if(Date.now()>s)throw new Error(`another install is holding ${t}; remove it if no install is running`);ke(100)}try{for(let n of R(e))n.startsWith(".staging-")&&k(l(e,n),{recursive:!0,force:!0});return r()}finally{k(t,{force:!0})}}function ne(e,r,t){let s=l(r,t.name);return ve(r,()=>{P(r,{recursive:!0});let n=D(l(r,".staging-"));try{ue(e,n,{recursive:!0}),k(s,{recursive:!0,force:!0}),pe(n,s)}catch(i){throw k(n,{recursive:!0,force:!0}),i}return s})}function se(e,r){if(!S(e))return{ok:!1,problems:[`no such directory: ${e}`]};let{manifest:t,problems:s}=te(e);if(!t)return{ok:!1,problems:s};let n=ne(e,r,t);return{ok:!0,name:t.name,target:n,problems:[]}}function xe(e,r){let t=D(l(X(),"howtofix-preset-"));try{return ye("git",["clone","--depth","1","--quiet",e,t],{stdio:"pipe"}),se(t,r)}catch(s){return{ok:!1,problems:[`git clone failed: ${(s instanceof Error?s.message:String(s)).split(`
5
+ `)[0]}`]}}finally{k(t,{recursive:!0,force:!0})}}function ot(e,r){return/^(https?:\/\/|git@|git:\/\/)/.test(e)?xe(e,r):se(N(e),r)}function at(e,r){let t=[],s=[];if(!Y.test(e))return{removed:t,problems:[`"${e}" is not a preset name`]};for(let n of M(r)){let i=l(n,e);if(S(i)){if(!E(n,i)){s.push(`refusing to remove ${i}: outside ${n}`);continue}k(i,{recursive:!0,force:!0}),t.push(i)}}return t.length===0&&s.push(`"${e}" is not installed`),{removed:t,problems:s}}function ct(e){return q(e)}function $e(e){let r=[],t=(i,o)=>{for(let c of R(i,{withFileTypes:!0}).sort((a,f)=>a.name.localeCompare(f.name))){let a=l(i,c.name),f=o?`${o}/${c.name}`:c.name;c.isSymbolicLink()||(c.isDirectory()?t(a,f):c.isFile()&&r.push([f,U("sha256").update(O(a)).digest("hex")]))}};t(e,"");let s=0;for(let[i]of r)s+=x(l(e,i)).size;let n=r.map(([i,o])=>`${o} ${i}`).join(`
6
+ `);return{digest:U("sha256").update(n).digest("hex").slice(0,16),fileCount:r.length,bytes:s}}function lt(){let e=l(Q(),"hub.json");try{let r=O(e,"utf8"),t=JSON.parse(r),s=C(t)&&Array.isArray(t.entries)?t.entries:[],n=[];for(let i of s)C(i)&&(typeof i.name!="string"||typeof i.repo!="string"||typeof i.sha!="string"||typeof i.path!="string"||typeof i.category!="string"||n.push({name:i.name,title:typeof i.title=="string"?i.title:i.name,description:typeof i.description=="string"?i.description:"",category:i.category,skill:typeof i.skill=="string"?i.skill:i.name,path:i.path,repo:i.repo,sha:i.sha,license:typeof i.license=="string"?i.license:"unknown",stars:typeof i.stars=="number"?i.stars:0,sizeKb:typeof i.sizeKb=="number"?i.sizeKb:0,...typeof i.digest=="string"?{digest:i.digest}:{},...typeof i.fileCount=="number"?{fileCount:i.fileCount}:{},...typeof i.modelInvocable=="boolean"?{modelInvocable:i.modelInvocable}:{}}));return{entries:n,problems:[]}}catch(r){return r?.code==="ENOENT"?{entries:[],problems:[]}:{entries:[],problems:[`registry unreadable: ${r instanceof Error?r.message:String(r)}`]}}}function ft(e){return[...new Set(e.map(r=>r.category))].sort()}function ut(e,r){return e.filter(t=>t.category===r).sort((t,s)=>s.stars-t.stars||t.name.localeCompare(s.name))}function pt(e,r){return e.find(t=>t.name===r)}function Ee(e){return`https://codeload.github.com/${e.repo}/tar.gz/${e.sha}`}async function mt(e,r,t=12e4){let s=D(l(X(),"howtofix-hub-"));try{let n=await fetch(Ee(e),{signal:AbortSignal.timeout(t),redirect:"follow"});if(!n.ok)return{ok:!1,problems:[`${e.repo}: HTTP ${n.status} from codeload`]};let i=Buffer.from(await n.arrayBuffer()),o=G(i),c=W(o,e.path).filter(g=>g.kind==="file"||g.kind==="directory");if(!c.some(g=>g.path==="SKILL.md"))return{ok:!1,problems:[`${e.repo}@${e.sha.slice(0,7)} has no ${e.path}/SKILL.md`]};let a=l(s,"preset",e.name),f=l(a,"skills",e.skill),u=0;for(let g of c){if(!K(g.path))return{ok:!1,problems:[`refusing unsafe path in archive: ${g.path}`]};let b=l(f,g.path);if(!E(f,b))return{ok:!1,problems:[`refusing path outside the skill: ${g.path}`]};if(g.kind==="directory"){P(b,{recursive:!0});continue}P(Z(b),{recursive:!0}),T(b,g.data??Buffer.alloc(0)),u+=1}let m={name:e.name,title:e.title,description:e.description,category:e.category,version:"1.0.0",skills:[e.skill],source:`${e.repo}@${e.sha}`,license:e.license};if(T(l(a,"preset.json"),`${JSON.stringify(m,null,2)}
7
+ `),!e.digest)return{ok:!1,problems:[`${e.repo}@${e.sha.slice(0,7)}: registry entry has no digest`,"refusing to install; content cannot be verified against what was reviewed"]};let p=$e(f);if(p.digest!==e.digest)return{ok:!1,problems:[`${e.repo}@${e.sha.slice(0,7)}: content changed under a pinned commit`,`expected ${e.digest} (${e.fileCount??"?"} files), got ${p.digest} (${p.fileCount} files)`,"refusing to install; the registry needs regenerating"]};let d=ee(a,m);if(d.length>0)return{ok:!1,problems:d};let h=ne(a,r,m);return{ok:!0,name:e.name,target:h,problems:[],skill:e.skill,modelInvocable:e.modelInvocable}}catch(n){return{ok:!1,problems:[`download failed: ${(n instanceof Error?n.message:String(n)).split(`
8
+ `)[0]}`]}}finally{k(s,{recursive:!0,force:!0})}}function Pe(){let e=(process.env.HOWTOFIX_HOME??process.env.HOME??"").trim();return Ae(e||we())}var y=process.env.HOWTOFIX_CODING_AGENT_DIR?.trim()||$(Pe(),".howtofix","agent"),bt=$(y,"skills");function Re(e){return $(e,".howtofix","skills")}function kt(e){let r=[Re(e)];return r.push(...re(e)),r}var St=$(y,"agents"),vt=$(y,"usage-cache.json"),xt=$(y,"workflows");function $t(){process.env.HXF_CODING_AGENT_DIR=y}export{F as a,Te as b,Ne as c,Ce as d,De as e,_e as f,Le as g,Fe as h,ze as i,Je as j,V as k,Q as l,ee as m,te as n,tt as o,rt as p,nt as q,re as r,st as s,it as t,se as u,ot as v,at as w,ct as x,lt as y,ft as z,ut as A,pt as B,mt as C,y as D,bt as E,Re as F,kt as G,St as H,vt as I,xt as J,$t as K};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e}from"./chunk-3FYCFLNK.js";import"./chunk-WOT6VMZA.js";export{a as PROXY_SETTING_KEY,b as configuredProxy,c as environmentProxy,e as installProxy,d as validateProxyUrl};
@@ -0,0 +1 @@
1
+ var d=Object.defineProperty;var e=(c,a)=>{for(var b in a)d(c,b,{get:a[b],enumerable:!0})};export{e as a};
@@ -0,0 +1,4 @@
1
+ import{execFile as M}from"node:child_process";import{closeSync as v,existsSync as f,mkdirSync as N,openSync as C,readFileSync as w,realpathSync as k,statSync as T,unlinkSync as E,writeFileSync as _}from"node:fs";import{homedir as p}from"node:os";import{delimiter as I,dirname as $,join as d,sep as m}from"node:path";var l="howtofixcli",g=["npm","npm.cmd","npm.exe"],A=2e4,O=2,P=12e4,R=600*1e3,U=5*1e3;function F(e,t){let r=s=>{let i=s.trim().split("-")[0]?.split("+")[0]??"";if(/^\d+(\.\d+)*$/.test(i))return i.split(".").map(c=>Number(c))},n=r(e),o=r(t);if(!n||!o)return 0;let a=Math.max(n.length,o.length);for(let s=0;s<a;s+=1){let i=n[s]??0,c=o[s]??0;if(i>c)return 1;if(i<c)return-1}return 0}function L(e,t){return e.includes("-")?!1:F(e,t)>0}var h=(e,t,r)=>new Promise(n=>{M(e,t,{cwd:r.cwd,timeout:r.timeoutMs,windowsHide:!0},(o,a,s)=>{let i=o?o.code:void 0,c=typeof i=="number"?i:o?1:0,u=typeof i=="string"?i:void 0;n({code:c,stdout:String(a??""),stderr:String(s??""),...u?{errorCode:u}:{}})})}),H=new Set(["ENOENT","EACCES","EINVAL","EPERM"]);function b(){let e=$(process.execPath);for(let r of[["..","lib","node_modules","npm","bin","npm-cli.js"],["node_modules","npm","bin","npm-cli.js"]]){let n=d(e,...r);if(f(n))return{command:process.execPath,args:[n]}}let t=process.env.PATH?.split(I).filter(Boolean)??[];for(let r of t)for(let n of g){let o=d(r,n);if(!(n.endsWith(".cmd")||n.endsWith(".bat"))&&f(o))return{command:o,args:[]}}if(process.platform==="win32")for(let r of t)for(let n of g){if(!n.endsWith(".cmd")&&!n.endsWith(".bat"))continue;let o=d(r,n);if(f(o))return{command:process.env.ComSpec||"cmd.exe",args:["/d","/s","/c",`"${o}"`]}}}var D="could not check for a newer version: npm was not found, so run `npm install -g howtofixcli@latest` yourself",G="could not check for a newer version: the registry did not answer";function Q(e){if(e.latest===void 0)return`${e.message} (this is why no update was offered; /update retries it)`}function K(e){if(e.code===-2)return!0;let t=e.errorCode??(e.stderr??"").trim();return H.has(t)}function x(){let t=process.env.HOWTOFIX_CODING_AGENT_DIR?.trim()||d(p(),".howtofix","agent");try{N(t,{recursive:!0})}catch{}return d(t,"update.lock")}function B(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(t){return t?.code==="EPERM"}}function S(e,t){try{let r=t-T(e).mtimeMs,n=w(e,"utf8").trim();return{pid:/^\d+$/.test(n)?Number.parseInt(n,10):void 0,ageMs:r}}catch{return}}function W(e){return e?e.pid===void 0?e.ageMs<U:B(e.pid)?e.ageMs<R:!1:!1}function j(e=Date.now()){let t=x();for(let r=0;r<2;r+=1)try{let n=C(t,"wx",384);try{_(n,String(process.pid))}finally{v(n)}return!0}catch(n){if(n.code!=="EEXIST")return!0;if(W(S(t,e)))return!1;try{E(t)}catch{return!1}}return!1}function J(){let e=x();try{let t=S(e,Date.now());if(t&&t.pid!==void 0&&t.pid!==process.pid)return;E(e)}catch{}}async function y(e){let t=e?.runner??h,r=b();if(!r)return{reason:"no-npm"};let n="no-answer";for(let o=0;o<O;o+=1){let a;try{a=await t(r.command,[...r.args,"view",`${l}@latest`,"version","--prefer-online"],{cwd:p(),timeoutMs:e?.timeoutMs??A})}catch{n="no-answer";continue}if(a.code!==0){if(K(a))return{reason:"no-npm"};n="no-answer";continue}let s=a.stdout.trim().split(`
2
+ `).pop()?.trim()??"";if(/^\d+\.\d+/.test(s))return{version:s};n="no-answer"}return{reason:n}}async function Z(e){return(await y(e)).version}async function ee(e,t){let r=await y(t);if(!r.version)return{current:e,available:!1,message:r.reason==="no-npm"?D:G};let n=r.version;return L(n,e)?{current:e,latest:n,available:!0,message:`HowToFix ${n} is available (you have ${e})`}:{current:e,latest:n,available:!1,message:`HowToFix ${e} is up to date`}}function V(e,t,r){let n=`${t}
3
+ ${e}`.split(`
4
+ `).map(u=>u.trim()).filter(Boolean).filter(u=>!/^npm warn\b/i.test(u)),o=n.filter(u=>/^npm error\b/i.test(u)||/\bERR!/i.test(u)),s=(o.find(u=>/^npm error code\b/i.test(u))??o.at(-1)??n.at(-1)??r??"").replace(/^npm error\s*/i,"").trim(),i=`${n.join(" ")} ${r??""}`,c="";return/EACCES|EPERM|permission denied/i.test(i)?c=" \u2014 npm could not write its files (permission denied); close other HowToFix windows and run the terminal as Administrator":/EBUSY|EEXIST|ENOTEMPTY|resource busy|being used by another process/i.test(i)?c=" \u2014 a file is in use; close other HowToFix windows and try again":/ENOSPC/i.test(i)?c=" \u2014 the disk is full":/ETIMEDOUT|ENOTFOUND|EAI_AGAIN|ECONNREFUSED/i.test(i)&&(c=" \u2014 npm could not reach the registry"),{detail:s,hint:c}}async function ne(e){let t=e?.runner??h;if(!j())return{ok:!1,message:"another HowToFix is already installing an update"};try{let r=b();if(!r)return{ok:!1,message:"npm was not found, so run `npm install -g howtofixcli@latest` yourself"};let n=e?.version?`${l}@${e.version}`:`${l}@latest`,o=await t(r.command,[...r.args,"install","-g",n],{cwd:p(),timeoutMs:e?.timeoutMs??P});if(o.code!==0){let{detail:a,hint:s}=V(o.stdout,o.stderr,o.errorCode);return{ok:!1,message:`the update did not install${s}${a?`: ${a}`:""}`}}return{ok:!0,version:e?.version,message:"updated; it takes effect the next time HowToFix starts"}}catch(r){return{ok:!1,message:`the update failed: ${r instanceof Error?r.message:String(r)}`}}finally{J()}}function te(e=process.argv[1]){if(!e)return!1;let t=e;try{t=k(e)}catch{}return t.includes(`${m}node_modules${m}${l}${m}`)}function re(e){try{return JSON.parse(w(e,"utf8")).autoUpdate!==!1}catch{return!0}}export{l as a,A as b,O as c,P as d,R as e,U as f,F as g,L as h,b as i,D as j,G as k,Q as l,B as m,j as n,J as o,Z as p,ee as q,V as r,ne as s,te as t,re as u};
@@ -0,0 +1,5 @@
1
+ import{E as s,F as l}from"./chunk-V656XVXV.js";function c(i){return[s,l(i)]}function d(i,n){let t=i.trim(),r=/^\/skill:([^\s]+)(?:\s+([\s\S]*))?$/.exec(t)??/^\/skill\s+([^\s]+)(?:\s+([\s\S]*))?$/.exec(t);if(!r)return;let e=r[1]??"";if(!n.includes(e))return;let o=(r[2]??"").trim();return o?`/skill:${e} ${o}`:`/skill:${e}`}function u(i){if(i.length===0){let[n,t]=c(process.cwd());return["no skills loaded.",`put a SKILL.md in ${n}`,`or in ${t}`,"invoke with /skill:<name>"].join(`
2
+ `)}return i.map(n=>{let t=n.disableModelInvocation?" (invoke only)":"";return`${n.name}${t}
3
+ ${n.description}
4
+ ${n.filePath}`}).join(`
5
+ `)}export{c as a,d as b,u as c};
@@ -0,0 +1,2 @@
1
+ import{b as o}from"./chunk-OIPSLIZE.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
+ `),"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};