howtofixcli 0.7.10 → 0.7.12

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 (154) hide show
  1. package/dist/account-credential.js +136 -0
  2. package/dist/account-credential.test.js +38 -0
  3. package/dist/activity.js +124 -0
  4. package/dist/agent-defs.js +237 -0
  5. package/dist/agent-limiter.js +68 -0
  6. package/dist/agents.js +554 -0
  7. package/dist/anim.js +361 -0
  8. package/dist/args.js +228 -0
  9. package/dist/at-file.js +28 -0
  10. package/dist/brand-extension.js +87 -0
  11. package/dist/brand.js +76 -0
  12. package/dist/browser.js +58 -0
  13. package/dist/cache-report.js +139 -0
  14. package/dist/checkpoint.js +437 -0
  15. package/dist/claims.js +167 -0
  16. package/dist/cli-auth.js +142 -0
  17. package/dist/cli-checkin.js +120 -0
  18. package/dist/cli-credentials.js +254 -0
  19. package/dist/clipboard.js +149 -0
  20. package/dist/collapse.js +129 -0
  21. package/dist/commands.js +294 -0
  22. package/dist/compaction-guard.js +81 -0
  23. package/dist/context-extension.js +17 -0
  24. package/dist/dcp/commands.js +172 -0
  25. package/dist/dcp/compress-state.js +139 -0
  26. package/dist/dcp/compress.js +329 -0
  27. package/dist/dcp/dcp-extension.js +295 -0
  28. package/dist/dcp/dedup.js +93 -0
  29. package/dist/dcp/ids.js +189 -0
  30. package/dist/dcp/index.js +25 -0
  31. package/dist/dcp/middle-prune.js +76 -0
  32. package/dist/dcp/prompts.js +68 -0
  33. package/dist/dcp/protected-content.js +221 -0
  34. package/dist/dcp/protected.js +161 -0
  35. package/dist/dcp/prune.js +418 -0
  36. package/dist/dcp/state.js +176 -0
  37. package/dist/device-id.js +90 -0
  38. package/dist/device-id.test.js +23 -0
  39. package/dist/errors.js +63 -0
  40. package/dist/extensions.js +48 -0
  41. package/dist/fatal.js +35 -0
  42. package/dist/feed.js +498 -0
  43. package/dist/fs-atomic.js +54 -0
  44. package/dist/gateway-errors.js +90 -0
  45. package/dist/git.js +230 -0
  46. package/dist/goal-extension.js +88 -0
  47. package/dist/goal.js +222 -0
  48. package/dist/hooks-extension.js +176 -0
  49. package/dist/hooks.js +443 -0
  50. package/dist/howtofix-account.js +735 -0
  51. package/dist/hud-line.js +153 -0
  52. package/dist/hwid.js +130 -0
  53. package/dist/interrupt.js +60 -0
  54. package/dist/json-events.js +50 -0
  55. package/dist/level-style.js +112 -0
  56. package/dist/loop-guard.js +95 -0
  57. package/dist/lsp-tools.js +32 -0
  58. package/dist/lsp.js +429 -0
  59. package/dist/main.js +540 -94
  60. package/dist/mcp-config.js +85 -0
  61. package/dist/mcp-lifecycle.js +147 -0
  62. package/dist/model-catalog.js +217 -0
  63. package/dist/model-facts.js +35 -0
  64. package/dist/model-resolve.js +65 -0
  65. package/dist/notes.js +78 -0
  66. package/dist/oauth-login.js +568 -0
  67. package/dist/paths.js +61 -0
  68. package/dist/permissions.js +298 -0
  69. package/dist/plan-mode.js +363 -0
  70. package/dist/preset-command.js +227 -0
  71. package/dist/preset-extension.js +35 -0
  72. package/dist/preset-mcp.js +292 -0
  73. package/dist/presets.js +727 -0
  74. package/dist/prompt-files.js +103 -0
  75. package/dist/prompt-text.js +41 -0
  76. package/dist/proxy.js +137 -0
  77. package/dist/quality/ast.js +196 -0
  78. package/dist/quality/cognitive.js +83 -0
  79. package/dist/quality/cyclomatic.js +30 -0
  80. package/dist/quality/halstead.js +83 -0
  81. package/dist/quality/index.js +18 -0
  82. package/dist/quality/length.js +3 -0
  83. package/dist/quality/maintainability.js +15 -0
  84. package/dist/quality/nesting.js +57 -0
  85. package/dist/quality/report.js +803 -0
  86. package/dist/quality/smells.js +67 -0
  87. package/dist/quality-tool.js +63 -0
  88. package/dist/read-only-commands.js +597 -0
  89. package/dist/repo-map.js +292 -0
  90. package/dist/rtk.js +193 -0
  91. package/dist/sandbox.js +105 -0
  92. package/dist/schema.js +214 -0
  93. package/dist/session-lifecycle.js +19 -0
  94. package/dist/session-retention.js +111 -0
  95. package/dist/session.js +447 -0
  96. package/dist/sessions.js +100 -0
  97. package/dist/settings.js +148 -0
  98. package/dist/skills.js +35 -0
  99. package/dist/slop-tool.js +96 -0
  100. package/dist/spend-cap.js +43 -0
  101. package/dist/subagent.js +171 -0
  102. package/dist/tar.js +146 -0
  103. package/dist/theme.js +79 -0
  104. package/dist/thinking.js +45 -0
  105. package/dist/todo.js +114 -0
  106. package/dist/tool-loadout.js +97 -0
  107. package/dist/tool-render.js +769 -0
  108. package/dist/tools.js +176 -0
  109. package/dist/ui.js +4778 -0
  110. package/dist/update.js +551 -0
  111. package/dist/usage-segment.js +69 -0
  112. package/dist/web-tools.js +46 -0
  113. package/dist/web.js +265 -0
  114. package/dist/welcome.js +179 -0
  115. package/dist/workflow-engine.js +246 -0
  116. package/dist/workflow-progress.js +446 -0
  117. package/dist/workflow-view.js +195 -0
  118. package/dist/workflow.js +349 -0
  119. package/package.json +62 -15
  120. package/dist/chunk-27TRKD65.js +0 -2
  121. package/dist/chunk-2YYQ3OBQ.js +0 -1
  122. package/dist/chunk-3FYCFLNK.js +0 -1
  123. package/dist/chunk-3KT55SQP.js +0 -34
  124. package/dist/chunk-4BWDGEXH.js +0 -5
  125. package/dist/chunk-56SEAGAQ.js +0 -1
  126. package/dist/chunk-6FUWMLWO.js +0 -1
  127. package/dist/chunk-7CHDNTH6.js +0 -1
  128. package/dist/chunk-ACOMNDUL.js +0 -185
  129. package/dist/chunk-AGGIYXN7.js +0 -2
  130. package/dist/chunk-BHVBO4SC.js +0 -1
  131. package/dist/chunk-CGHISVXB.js +0 -1
  132. package/dist/chunk-FPXVDP32.js +0 -8
  133. package/dist/chunk-FRGMJPNO.js +0 -2
  134. package/dist/chunk-GXB7RZHH.js +0 -1
  135. package/dist/chunk-ILDDDLRC.js +0 -1
  136. package/dist/chunk-JFYVRWJI.js +0 -2
  137. package/dist/chunk-MTNY7MFG.js +0 -6
  138. package/dist/chunk-MVLCGU3G.js +0 -1
  139. package/dist/chunk-N345KWWK.js +0 -1
  140. package/dist/chunk-ORJ2QZBG.js +0 -3
  141. package/dist/chunk-PCALBZOO.js +0 -2
  142. package/dist/chunk-PIEAJJRE.js +0 -5
  143. package/dist/chunk-RDRF7DIS.js +0 -109
  144. package/dist/chunk-TEW62VDF.js +0 -1
  145. package/dist/chunk-TSEKPGK4.js +0 -1
  146. package/dist/chunk-UTYFLLSM.js +0 -1
  147. package/dist/chunk-V3R4FYTJ.js +0 -1
  148. package/dist/chunk-V656XVXV.js +0 -8
  149. package/dist/chunk-VICEM5Y2.js +0 -2
  150. package/dist/chunk-WKUJ7CFO.js +0 -1
  151. package/dist/chunk-WOT6VMZA.js +0 -1
  152. package/dist/chunk-WUPU6LTD.js +0 -4
  153. package/dist/chunk-WX3V5P7U.js +0 -5
  154. package/dist/chunk-WZKWT757.js +0 -2
@@ -0,0 +1,349 @@
1
+ /**
2
+ * The `workflow` tool: one script becomes a fleet of agents.
3
+ *
4
+ * The model writes a JavaScript workflow and this runs it, which is Claude
5
+ * Code's `ultracode` mode reduced to what this harness's SDK can support. The
6
+ * script's bindings live in `workflow-engine.ts`; this file owns the two things
7
+ * that are about *this* harness:
8
+ *
9
+ * 1. **Which agent a call becomes.** The engine is backend-agnostic and asks for
10
+ * an agent; here that resolves to the subagent registry in `agents.ts`
11
+ * (`scout`/`task`/`reviewer`), opened directly rather than through the `task`
12
+ * tool — the tool's `drain()` runs *every* queued run, so concurrent
13
+ * `agent()` calls would each try to execute each other's runs. One run per
14
+ * call, one session per call, no shared queue.
15
+ *
16
+ * 2. **`meta` and the load-time rules.** The spec's file grammar: the first
17
+ * statement must be `export const meta = <pure literal>`, and the body must
18
+ * not import or export. `meta.phases[].title` values are matched against
19
+ * `phase()` calls for progress grouping.
20
+ */
21
+ import { readFileSync } from "node:fs";
22
+ import { basename } from "node:path";
23
+ import { StringEnum } from "@netrodev/hxf-ai";
24
+ import { defineTool } from "@netrodev/hxf-coding-agent";
25
+ import { Type } from "typebox";
26
+ import { agents, modelRef, openAgentSession } from "./agents.js";
27
+ import { createAgentWorktree } from "./git.js";
28
+ import { createBindings, WorkflowError } from "./workflow-engine.js";
29
+ import { formatElapsed, formatProgressLine } from "./workflow-progress.js";
30
+ /** The status key the live progress line is published under. */
31
+ export const WORKFLOW_STATUS_KEY = "workflow";
32
+ let workflowControls = null;
33
+ export function setWorkflowControls(next) {
34
+ workflowControls = next;
35
+ }
36
+ /** Cap on how long one run may take, so a runaway script cannot hang the tool. */
37
+ const RUN_TIMEOUT_MS = 10 * 60 * 1000;
38
+ /**
39
+ * Read `meta` and enforce the load-time grammar.
40
+ *
41
+ * The spec allows only literal forms in `meta` (no identifiers, calls, member
42
+ * access or spreads) and forbids `import`/`export` in the body. Rather than
43
+ * writing a full AST check, the export is extracted textually and the literal is
44
+ * evaluated by a `Function` with the binding names shadowed — so an identifier
45
+ * in `meta` fails loudly instead of silently evaluating.
46
+ */
47
+ export function parseMeta(code) {
48
+ // Comments and blank lines may precede `meta`: both reference parsers skip
49
+ // them, and the contract's own checklist *requires* a header comment ("use
50
+ // case, when to use, args, patterns demonstrated, cost profile, output
51
+ // shape") above the literal. Requiring the export to be the byte-zero
52
+ // statement rejected every real workflow.
53
+ const stripped = code.replace(/^(?:\s+|\/\/[^\n]*\n|\/\*[\s\S]*?\*\/)*/, "");
54
+ const head = /^export\s+const\s+meta\s*=\s*/.exec(stripped);
55
+ if (!head) {
56
+ throw new WorkflowError("a workflow script must start with `export const meta = { name, description }`");
57
+ }
58
+ // Keep the body relative to the original source so line numbers in later
59
+ // errors still point at the file the author wrote.
60
+ const bodyStart = code.length - stripped.length;
61
+ // Find the end of the literal by brace matching rather than by looking for a
62
+ // semicolon: the reference scripts omit it (`export const meta = { ... }`),
63
+ // and requiring one rejected every real workflow.
64
+ const literalStart = head[0].length;
65
+ let depth = 0;
66
+ let inString = null;
67
+ let end = -1;
68
+ for (let index = literalStart; index < stripped.length; index++) {
69
+ const char = stripped[index];
70
+ if (inString) {
71
+ if (char === "\\")
72
+ index++;
73
+ else if (char === inString)
74
+ inString = null;
75
+ continue;
76
+ }
77
+ if (char === '"' || char === "'" || char === "`")
78
+ inString = char;
79
+ else if (char === "{" || char === "[")
80
+ depth++;
81
+ else if (char === "}" || char === "]") {
82
+ depth--;
83
+ if (depth === 0) {
84
+ end = index + 1;
85
+ break;
86
+ }
87
+ }
88
+ }
89
+ if (end === -1)
90
+ throw new WorkflowError("meta is not a closed literal object");
91
+ const literal = stripped.slice(literalStart, end);
92
+ // A trailing semicolon is optional.
93
+ const body = code.slice(bodyStart + end).replace(/^\s*;/, "");
94
+ if (/^\s*(import|export)\b/m.test(body)) {
95
+ throw new WorkflowError("a workflow body must not contain import or export declarations");
96
+ }
97
+ if (/\bimport\s*\(/.test(body)) {
98
+ throw new WorkflowError("a workflow body must not use dynamic import()");
99
+ }
100
+ let meta;
101
+ try {
102
+ meta = new Function(`"use strict"; return (${literal});`)();
103
+ }
104
+ catch (error) {
105
+ throw new WorkflowError(`meta must be a literal object: ${error instanceof Error ? error.message : String(error)}`);
106
+ }
107
+ if (typeof meta !== "object" || meta === null)
108
+ throw new WorkflowError("meta must be an object");
109
+ const record = meta;
110
+ if (typeof record.name !== "string" || !record.name.trim())
111
+ throw new WorkflowError("meta.name is required");
112
+ if (typeof record.description !== "string" || !record.description.trim()) {
113
+ throw new WorkflowError("meta.description is required");
114
+ }
115
+ const phases = Array.isArray(record.phases)
116
+ ? record.phases
117
+ .filter((entry) => typeof entry === "object" && entry !== null)
118
+ .map((entry) => ({
119
+ title: String(entry.title ?? ""),
120
+ ...(typeof entry.detail === "string" ? { detail: entry.detail } : {}),
121
+ }))
122
+ .filter((entry) => entry.title)
123
+ : undefined;
124
+ return {
125
+ meta: {
126
+ name: record.name,
127
+ description: record.description,
128
+ ...(typeof record.whenToUse === "string" ? { whenToUse: record.whenToUse } : {}),
129
+ ...(phases ? { phases } : {}),
130
+ },
131
+ body,
132
+ };
133
+ }
134
+ /**
135
+ * Compile a body into an async function.
136
+ *
137
+ * `Function` is the only option here: the sandbox `codemode` uses is not
138
+ * reachable with custom bindings (`CodemodeToolOptions` has no hook for them),
139
+ * and a workflow script is model-authored code running in the user's own
140
+ * session — the same trust level as the shell commands the agent already runs.
141
+ * The body is a module body, so top-level `await` and `return` are legal, which
142
+ * rules out a plain `Function`.
143
+ */
144
+ export function compileBody(body) {
145
+ const names = ["agent", "parallel", "pipeline", "phase", "log", "args", "budget"];
146
+ const source = `"use strict"; return (async () => {\n${body}\n})();`;
147
+ let factory;
148
+ try {
149
+ factory = new Function(...names, source);
150
+ }
151
+ catch (error) {
152
+ throw new WorkflowError(`workflow did not compile: ${error instanceof Error ? error.message : String(error)}`);
153
+ }
154
+ return factory;
155
+ }
156
+ /** Read the final text out of an agent session, whatever shape it returns. */
157
+ function finalText(session) {
158
+ return session.getLastAssistantText()?.trim() ?? "";
159
+ }
160
+ /**
161
+ * Run one agent call on a fresh subagent session.
162
+ *
163
+ * Output tokens, tool calls and the model come from the session's own stats,
164
+ * which is what makes the script's `budget` real rather than advisory and what
165
+ * fills the per-agent metric in the progress view.
166
+ *
167
+ * `isolation: "worktree"` gives the call its own checkout via `openAgentSession`,
168
+ * which is the only correct way to run parallel agents that write to the same
169
+ * files: siblings in one working tree race each other.
170
+ */
171
+ export function createInvoker(parentModel) {
172
+ return async ({ prompt, agentType, effort, model, isolation }) => {
173
+ const spec = agents.get(agentType) ?? agents.get("task");
174
+ if (!spec)
175
+ throw new WorkflowError(`no agent named ${agentType}`);
176
+ // `isolation: "worktree"` means a private checkout, not just a private cwd:
177
+ // parallel writers in one tree race each other's builds and `git add -A`.
178
+ const worktree = isolation === "worktree" ? await createAgentWorktree(process.cwd(), agentType) : null;
179
+ const session = await openAgentSession({
180
+ agent: spec.name,
181
+ effort: (effort ?? spec.effort),
182
+ // The script's `model` has to reach the session, not only the metric line:
183
+ // it used to be reported as the model that ran while the child actually
184
+ // ran the runtime default.
185
+ ...(model ? { model } : {}),
186
+ ...(parentModel ? { parentModel } : {}),
187
+ ...(worktree ? { worktree: worktree.path } : {}),
188
+ });
189
+ try {
190
+ await session.prompt(`${spec.prompt}\n\nTask:\n${prompt}`);
191
+ const stats = session.getSessionStats();
192
+ // The session first: it is the one that ran. The script's request is the
193
+ // fallback for a runtime that cannot name its own model.
194
+ const resolved = modelId(session) ?? model;
195
+ return {
196
+ text: finalText(session),
197
+ outputTokens: stats.tokens.output,
198
+ toolCalls: stats.toolCalls,
199
+ ...(resolved ? { model: resolved } : {}),
200
+ };
201
+ }
202
+ finally {
203
+ session.dispose();
204
+ await worktree?.remove();
205
+ }
206
+ };
207
+ }
208
+ /** The model a session actually ran on, when the SDK exposes it. */
209
+ function modelId(session) {
210
+ return session.model?.id ?? session.model?.name;
211
+ }
212
+ export const workflowParams = Type.Object({
213
+ code: Type.Optional(Type.String({ description: "The workflow script source" })),
214
+ path: Type.Optional(Type.String({ description: "Path to a workflow script, instead of code" })),
215
+ agent: Type.Optional(StringEnum(["scout", "task", "reviewer"], { description: "Default agent profile for calls" })),
216
+ budget: Type.Optional(Type.Number({ description: "Output-token ceiling for the whole run" })),
217
+ });
218
+ export function createWorkflowTool(options) {
219
+ // The workbench registers its panel hooks once, the same way `setAsker` and
220
+ // `setMirror` hand other modules a live surface. The tool is built during
221
+ // session construction, before the TUI exists, so it cannot be passed in.
222
+ const hooks = () => options ?? workflowControls;
223
+ return defineTool({
224
+ name: "workflow",
225
+ label: "workflow",
226
+ description: "Run a JavaScript workflow that orchestrates many agents deterministically. Provide `code` (or `path`). The script starts with `export const meta = { name, description, phases }` and then uses the injected bindings: `agent(prompt, {label, phase, schema, effort, model, agentType, isolation})`, `parallel(thunks)`, `pipeline(items, ...stages)`, `phase(title)`, `log(msg)`, `args`, `budget`. `agent()` resolves null on failure and throws only when the budget or the call cap is exhausted, so null-check every result. `parallel()` takes thunks and never rejects; `pipeline()` has no barrier between items. Use it for fan-out, for builder-verifier loops that converge on a verdict, and for anything needing many agents whose order and count must be deterministic.",
227
+ promptSnippet: "workflow: orchestrate many agents from one JavaScript script",
228
+ parameters: workflowParams,
229
+ executionMode: "sequential",
230
+ async execute(_toolCallId, params, signal, onUpdate, ctx) {
231
+ const code = params.path ? readFileSync(params.path, "utf8") : (params.code ?? "");
232
+ if (!code.trim())
233
+ throw new WorkflowError("provide code or path");
234
+ const { meta, body } = parseMeta(code);
235
+ // The contract requires `meta.name` to match the script's filename, so a
236
+ // run launched by path is identifiable in the progress list and in any
237
+ // artifact directory named after it. A mismatch is a real error, not a
238
+ // warning: it is what makes the name trustworthy.
239
+ if (params.path) {
240
+ const file = basename(params.path).replace(/\.(js|mjs|cjs|ts)$/, "");
241
+ if (file !== meta.name) {
242
+ throw new WorkflowError(`meta.name "${meta.name}" must match the script filename "${file}"`);
243
+ }
244
+ }
245
+ const factory = compileBody(body);
246
+ const startedAt = Date.now();
247
+ const steps = [];
248
+ let outputTokens = 0;
249
+ let callCount = 0;
250
+ const detailsOf = (ok, error) => ({
251
+ name: meta.name,
252
+ ...(meta.description ? { description: meta.description } : {}),
253
+ ok,
254
+ agents: callCount,
255
+ outputTokens,
256
+ startedAt,
257
+ phases: meta.phases ?? [],
258
+ steps,
259
+ ...(error ? { error } : {}),
260
+ });
261
+ // The live surface: the dock line shows the run in flight, the way the
262
+ // reference puts its progress line in the task panel under the input box.
263
+ const publish = (progress, ended) => {
264
+ ctx.ui.setStatus(WORKFLOW_STATUS_KEY, ended ? undefined : formatProgressLine(progress));
265
+ onUpdate?.({ content: [], details: detailsOf(false) });
266
+ };
267
+ const onProgress = (agents) => {
268
+ callCount = agents.length;
269
+ outputTokens = agents.reduce((sum, agent) => sum + agent.outputTokens, 0);
270
+ steps.splice(0, steps.length, ...agents.map((agent) => ({
271
+ label: agent.label,
272
+ phase: agent.phase,
273
+ agent: agent.agentType,
274
+ status: agent.status,
275
+ outputTokens: agent.outputTokens,
276
+ startedAt: agent.startedAt,
277
+ ...(agent.toolCalls !== undefined ? { toolCalls: agent.toolCalls } : {}),
278
+ ...(agent.model ? { model: agent.model } : {}),
279
+ ...(agent.endedAt ? { endedAt: agent.endedAt } : {}),
280
+ ...(agent.detail ? { detail: agent.detail } : {}),
281
+ ...(agent.tasks ? { tasks: agent.tasks } : {}),
282
+ })));
283
+ publish({ name: meta.name, ...(meta.description ? { description: meta.description } : {}), phases: meta.phases ?? [], steps, startedAt }, false);
284
+ };
285
+ const invoke = createInvoker(modelRef(ctx?.model));
286
+ const bindings = createBindings({
287
+ invoke: params.agent ? wrapAgent(invoke, params.agent) : invoke,
288
+ budgetTotal: params.budget ?? null,
289
+ onProgress,
290
+ ...(signal ? { signal } : {}),
291
+ ...(hooks()?.isPaused ? { isPaused: hooks().isPaused } : {}),
292
+ });
293
+ const controller = new AbortController();
294
+ const timer = setTimeout(() => controller.abort(), RUN_TIMEOUT_MS);
295
+ if (signal)
296
+ signal.addEventListener("abort", () => controller.abort(), { once: true });
297
+ // Hand the panel a way to stop this run. `x` in the panel calls it; the
298
+ // abort then resolves in-flight calls as `null`, which is the engine's
299
+ // normal failure mode, so a stopped run still returns a partial result
300
+ // instead of throwing.
301
+ hooks()?.onStop?.(() => controller.abort());
302
+ try {
303
+ const result = await Promise.race([
304
+ factory(bindings.agent, bindings.parallel, bindings.pipeline, bindings.phase, bindings.log, bindings.args, bindings.budget),
305
+ new Promise((_resolve, reject) => controller.signal.addEventListener("abort", () => reject(new WorkflowError("workflow timed out or was aborted")))),
306
+ ]);
307
+ const endedAt = Date.now();
308
+ ctx.ui.setStatus(WORKFLOW_STATUS_KEY, undefined);
309
+ return {
310
+ content: [
311
+ {
312
+ type: "text",
313
+ text: `${meta.name}: ${callCount} agent call(s), ${outputTokens} output tokens in ${formatElapsed(endedAt - startedAt)}\n\n${render(result)}`,
314
+ },
315
+ ],
316
+ details: { ...detailsOf(true), endedAt },
317
+ };
318
+ }
319
+ catch (error) {
320
+ const message = error instanceof Error ? error.message : String(error);
321
+ ctx.ui.setStatus(WORKFLOW_STATUS_KEY, undefined);
322
+ return {
323
+ content: [{ type: "text", text: `${meta.name} failed after ${callCount} agent call(s): ${message}` }],
324
+ details: { ...detailsOf(false, message), endedAt: Date.now() },
325
+ isError: true,
326
+ };
327
+ }
328
+ finally {
329
+ clearTimeout(timer);
330
+ hooks()?.onStop?.(null);
331
+ }
332
+ },
333
+ });
334
+ }
335
+ /** Force every call to one agent profile, whatever the script asked for. */
336
+ function wrapAgent(invoke, agentType) {
337
+ return (spec) => invoke({ ...spec, agentType });
338
+ }
339
+ /** The script's return value, as text for the model. */
340
+ function render(value) {
341
+ if (typeof value === "string")
342
+ return value;
343
+ try {
344
+ return JSON.stringify(value, null, 2);
345
+ }
346
+ catch {
347
+ return String(value);
348
+ }
349
+ }
package/package.json CHANGED
@@ -1,20 +1,8 @@
1
1
  {
2
2
  "name": "howtofixcli",
3
- "version": "0.7.10",
4
- "type": "module",
3
+ "version": "0.7.12",
5
4
  "description": "HowToFix coding agent. Workbench TUI, sessions, background agents.",
6
- "license": "UNLICENSED",
7
- "homepage": "https://howtofix.id",
8
- "author": "HowToFix",
9
- "keywords": [
10
- "coding-agent",
11
- "cli",
12
- "tui",
13
- "howtofix"
14
- ],
15
- "engines": {
16
- "node": ">=22.19"
17
- },
5
+ "type": "module",
18
6
  "bin": {
19
7
  "howtofix": "dist/main.js"
20
8
  },
@@ -23,6 +11,38 @@
23
11
  "README.md",
24
12
  "LICENSE"
25
13
  ],
14
+ "scripts": {
15
+ "build": "tsc -p tsconfig.json && node --input-type=module -e \"import { rmSync, cpSync } from 'node:fs'; rmSync('dist/presets', { recursive: true, force: true }); cpSync('presets', 'dist/presets', { recursive: true });\" && node scripts/set-executable.mjs",
16
+ "start": "node dist/main.js",
17
+ "typecheck": "tsc -p tsconfig.json --noEmit",
18
+ "check": "node scripts/check-all.mjs",
19
+ "check:hub": "node scripts/check-hub-install.mjs",
20
+ "check:tar": "node scripts/check-tar.mjs --online",
21
+ "quality": "node scripts/quality.mjs",
22
+ "frame": "node scripts/render-frame.mjs",
23
+ "frame:workflow": "node scripts/render-workflow-frame.mjs",
24
+ "probe:commands": "python3 scripts/probe-slash-commands.py",
25
+ "build:release": "node scripts/build-release.mjs",
26
+ "version": "node scripts/sync-version.mjs",
27
+ "slop": "node scripts/slop.mjs",
28
+ "slop:commits": "node scripts/slop.mjs --commits",
29
+ "hooks:install": "git config core.hooksPath .githooks && echo 'hooks installed from .githooks'",
30
+ "check:sync": "node scripts/check-hub-sync.mjs --online",
31
+ "check:level-color": "python3 scripts/probe-level-color.py",
32
+ "check:skills-wire": "node scripts/check-skill-wire.mjs",
33
+ "check:agents-live": "node scripts/check-subagent-live.mjs",
34
+ "release:patch": "node scripts/release.mjs patch",
35
+ "release:minor": "node scripts/release.mjs minor",
36
+ "release:major": "node scripts/release.mjs major",
37
+ "release:dry": "node scripts/release.mjs patch --dry",
38
+ "test": "node --test test/*.test.mjs",
39
+ "format": "prettier --write \"src/**/*.ts\" \"scripts/**/*.mjs\" \"test/**/*.mjs\"",
40
+ "format:check": "prettier --check \"src/**/*.ts\" \"scripts/**/*.mjs\" \"test/**/*.mjs\""
41
+ },
42
+ "license": "UNLICENSED",
43
+ "engines": {
44
+ "node": ">=22.19"
45
+ },
26
46
  "dependencies": {
27
47
  "@netrodev/hxf-agent-core": "^1.0.22",
28
48
  "@netrodev/hxf-ai": "^1.0.22",
@@ -31,5 +51,32 @@
31
51
  "typebox": "1.3.27",
32
52
  "typescript": "7.0.2",
33
53
  "undici": "^8.10.2"
34
- }
54
+ },
55
+ "devDependencies": {
56
+ "@types/node": "^22.20.5",
57
+ "esbuild": "^0.28.2",
58
+ "prettier": "^3.9.10"
59
+ },
60
+ "homepage": "https://howtofix.id",
61
+ "author": "HowToFix",
62
+ "keywords": [
63
+ "coding-agent",
64
+ "cli",
65
+ "tui",
66
+ "howtofix"
67
+ ],
68
+ "contributors": [
69
+ {
70
+ "name": "hshinosa",
71
+ "url": "https://github.com/hshinosa"
72
+ },
73
+ {
74
+ "name": "yhagus",
75
+ "url": "https://github.com/yhagus"
76
+ },
77
+ {
78
+ "name": "mmatttttt",
79
+ "url": "https://github.com/mmatttttt"
80
+ }
81
+ ]
35
82
  }
@@ -1,2 +0,0 @@
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};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f,g,h,i,j}from"./chunk-WZKWT757.js";import"./chunk-4BWDGEXH.js";import"./chunk-WOT6VMZA.js";export{h as CLI_CLIENT_HEADER,a as CLI_SIGNING_KEY_ID,i as cliClientHeader,c as cliSignaturePayload,f as cliSigningKeyFingerprint,e as cliSigningKeyMatchesPanel,b as cliSigningPublicKey,d as createNonce,g as describeClient,j as signLoginRequest};
@@ -1 +0,0 @@
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};
@@ -1,34 +0,0 @@
1
- import{$ as De,A as _e,B as Te,D as E,E as L,Ea as Ke,G as F,H as $e,P as Ee,Pa as Xe,Q as Ae,Qa as Ye,R as ve,S as je,T as Oe,V as Pe,W as Re,Y as Ce,_ as H,a as C,b as D,ba as Ne,c as re,ca as Fe,d as ie,da as Me,e as ae,ea as Ie,f as ce,fa as Le,g as T,i as le,ia as Ge,j as pe,k as ue,ka as Ue,l as fe,la as G,m as me,ma as Be,na as He,o as ge,p as he,pa as W,q as we,r as ye,s as be,t as $,ta as We,u as ke,ua as ze,v as xe,w as I,wa as qe,x as Se,xa as Ze}from"./chunk-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-MTNY7MFG.js";import{g as ne,k as oe}from"./chunk-VICEM5Y2.js";import"./chunk-UTYFLLSM.js";import"./chunk-WZKWT757.js";import{b as M,c as Y,d as V}from"./chunk-4BWDGEXH.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};
@@ -1,5 +0,0 @@
1
- var a="HowToFix",o="0.7.10",n=["You are HowToFix, a coding agent. The user wants the fix, not a tour of the problem.",'NEVER report a check you did not run. NEVER state a version, path, result or capability you have not verified \u2014 if you did not check it, say you are unsure. "Not found" is not "impossible": a tool missing from PATH is often installed anyway, and one that is truly absent can usually be installed. Exhaust the real options before calling anything unavailable; when you do report a limit, say plainly what you tried and what you could not do. Unexercised behaviour is not evidence.',"NEVER mention the underlying harness, its vendor or its project name to the user.","Every tool is `read`, `write` or `exec`, and each approval mode auto-approves every tier up to its own: `suggest` runs `read` only, `auto-edit` adds `write`, `full-auto` adds `exec`. A read-only shell command runs in every mode, so inspecting the tree asks nothing.","NEVER aim a command at the filesystem root, a block device or a system account file, and NEVER shut down the host: those are refused in EVERY mode, `full-auto` included, so proposing one wastes the turn. This is not a list of things to avoid \u2014 it is a list of things that will not run.","Lead with the diagnosis in one or two sentences, then change the code. SHOULD prefer the smallest correct change over a rewrite. Name the file and the reason in a short line; do not narrate tool calls.","Fix the problem that was asked for. NEVER add features, refactors, validation, error handling or dependencies nobody requested.","Something reported broken: reproduce it first, confirm the fix after. Cannot reproduce it? Say so \u2014 NEVER edit code and call it fixed.","Tests describe intended behaviour. A failing test means fix the code, not the test: NEVER delete, skip or loosen an assertion to get green, and NEVER re-pin an expected value to whatever the code happens to print.","Anything you cannot settle by reading \u2014 a page, a layout, a screenshot, a CLI, a service, a failure \u2014 run it and look at the result. For a visual task, find a browser the way a real one does: `$PUPPETEER_EXECUTABLE_PATH`, `$CHROME_PATH`, then `which` for google-chrome, chromium and chromium-browser, then /usr/bin, /snap/bin and /var/lib/flatpak, then the puppeteer and playwright caches under the home directory. Still empty? `npx -y puppeteer browsers install chrome`, or `npm i puppeteer-core` against a chrome the image already ships outside PATH. Then drive the real artifact \u2014 open it, read the DOM, click the controls, measure at the widths that matter \u2014 instead of describing what you assume it does.","Done means the requested behaviour works end to end and every stated requirement is met \u2014 not a scaffold, a narrowed test or a plausible subset. Genuinely out of reach? Finish everything else, then say exactly what is missing and what you tried.","SHOULD plan multi-step work with `todo` before starting it, and mark each step done as you finish. A plan the user can see is worth more than a narration of what you are about to do.","Genuinely ambiguous design: enter plan mode, write the plan to the plan file, then present it with `exit_plan_mode`. Use it when several reasonable approaches exist or when a restructuring would be hard to undo. In plan mode `edit` and `write` are refused for every path except the plan file itself \u2014 that limit is enforced, not advisory, so plan the work rather than starting it. Plan mode needs an interactive session in which the user can approve it; when there is no UI it is unavailable, so design the approach yourself instead of calling it.","Work that is independent and would flood this conversation belongs in `task` subagents. Give each a self-contained assignment, then verify the file it wrote rather than trusting its summary. When that work has a shape you can script \u2014 many items through the same stages, or fan-out whose results must be combined \u2014 `workflow` states the orchestration in one place and runs it deterministically; `task` is for the one-off you cannot describe in advance.","MUST give each subagent a self-contained assignment: a child starts with none of this conversation, so a brief that says 'the file we discussed' reaches it as nothing. Choose the agent by what the work is \u2014 scout looks something up, architect returns a plan, reviewer reports issues with file evidence, task changes files \u2014 and NEVER send work that needs an edit to scout or reviewer, because neither can make one.","SHOULD delegate only work that is genuinely parallel: a subagent costs its own session and its own requests on the same quota as this conversation. A single lookup, a file you can read yourself, or a step whose result decides the next step stays here. MUST keep one call to at most six agents and the session to twelve live or parked ones \u2014 a larger fan-out is refused, and the refusal is a limit rather than a failure to work around.","Record a decision, a file's role, or a fact you would otherwise re-derive with `context`: notes survive compaction and are visible to the other agents on the task.","Look it up instead of recalling it: `web_search` and `web_fetch` for anything outside this repo, `lsp` for a definition, reference or diagnostic. Name the source you checked.","Before calling changed code done, run `quality` and `slop` over it and act on what they report. A metric you did not measure is a claim you cannot make.","A command runs under a two-minute default timeout. MUST pass a longer timeout for anything that legitimately takes more than that \u2014 a recursive directory walk, a package install, a build, a network fetch \u2014 and SHOULD prefer a bounded command to an unbounded one: 'du -sh' with an explicit path beats the whole profile, and on Windows/MSYS a recursive 'du' over a profile directory takes minutes rather than seconds.","When a choice blocks the task, use `ask` instead of guessing; when you need to work something out, use `think`, whose text stays out of the transcript.","Above all: NEVER claim a check you did not run, and NEVER call done on a subset."].join(`
2
- `);function s(e){return e===void 0?void 0:e.replace(/Use \/login to log into a provider[^\n]*/gi,"Connect a provider with /connect or /login:").replace(/^[ \t]*\S*hxf-coding-agent[\\/]docs[\\/][^\n]*$/gim,"").replace(/\bhxf-coding-agent\b/gi,"the harness").replace(/\n{3,}/g,`
3
-
4
- `).trim()}var i=["# Project notes","","## What this is","","## Commands","- build:","- test:","","## Conventions","-",""].join(`
5
- `);export{a,o as b,n as c,s as d,i as e};
@@ -1 +0,0 @@
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};
@@ -1 +0,0 @@
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};
@@ -1 +0,0 @@
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};