howtofixcli 0.7.23 → 0.7.25

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 (167) hide show
  1. package/dist/account-credential.js +136 -0
  2. package/dist/acp.js +234 -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 +250 -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 +121 -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 +381 -0
  22. package/dist/compaction-guard.js +81 -0
  23. package/dist/connect-prompt.js +22 -0
  24. package/dist/context-extension.js +17 -0
  25. package/dist/dcp/commands.js +172 -0
  26. package/dist/dcp/compress-state.js +139 -0
  27. package/dist/dcp/compress.js +329 -0
  28. package/dist/dcp/dcp-extension.js +295 -0
  29. package/dist/dcp/dedup.js +93 -0
  30. package/dist/dcp/ids.js +189 -0
  31. package/dist/dcp/index.js +25 -0
  32. package/dist/dcp/middle-prune.js +76 -0
  33. package/dist/dcp/prompts.js +68 -0
  34. package/dist/dcp/protected-content.js +221 -0
  35. package/dist/dcp/protected.js +161 -0
  36. package/dist/dcp/prune.js +418 -0
  37. package/dist/dcp/state.js +176 -0
  38. package/dist/errors.js +63 -0
  39. package/dist/extensions.js +48 -0
  40. package/dist/fatal.js +35 -0
  41. package/dist/feed.js +498 -0
  42. package/dist/fs-atomic.js +54 -0
  43. package/dist/gateway-errors.js +107 -0
  44. package/dist/git.js +230 -0
  45. package/dist/goal-extension.js +88 -0
  46. package/dist/goal.js +222 -0
  47. package/dist/hooks-extension.js +176 -0
  48. package/dist/hooks.js +443 -0
  49. package/dist/howtofix-account.js +834 -0
  50. package/dist/hud-line.js +158 -0
  51. package/dist/hwid.js +130 -0
  52. package/dist/interrupt.js +60 -0
  53. package/dist/json-events.js +50 -0
  54. package/dist/level-style.js +112 -0
  55. package/dist/loop-guard.js +95 -0
  56. package/dist/lsp-tools.js +32 -0
  57. package/dist/lsp.js +429 -0
  58. package/dist/main.js +573 -98
  59. package/dist/mcp-config.js +85 -0
  60. package/dist/mcp-lifecycle.js +147 -0
  61. package/dist/model-catalog.js +217 -0
  62. package/dist/model-facts.js +35 -0
  63. package/dist/model-resolve.js +65 -0
  64. package/dist/notes.js +78 -0
  65. package/dist/oauth-login.js +568 -0
  66. package/dist/paths.js +61 -0
  67. package/dist/permissions.js +298 -0
  68. package/dist/plan-mode.js +363 -0
  69. package/dist/preset-command.js +227 -0
  70. package/dist/preset-extension.js +35 -0
  71. package/dist/preset-mcp.js +292 -0
  72. package/dist/presets/mcp/rea/preset.json +28 -0
  73. package/dist/presets/mcp/rea/prompt.md +5 -0
  74. package/dist/presets/mcp/rea/skills/mcp-rea/SKILL.md +6 -0
  75. package/dist/presets/mcp/remotion/preset.json +27 -0
  76. package/dist/presets/mcp/remotion/prompt.md +7 -0
  77. package/dist/presets/mcp/remotion/skills/mcp-remotion/SKILL.md +6 -0
  78. package/dist/presets.js +727 -0
  79. package/dist/prompt-files.js +103 -0
  80. package/dist/prompt-text.js +41 -0
  81. package/dist/proxy.js +137 -0
  82. package/dist/quality/ast.js +196 -0
  83. package/dist/quality/cognitive.js +83 -0
  84. package/dist/quality/cyclomatic.js +30 -0
  85. package/dist/quality/halstead.js +83 -0
  86. package/dist/quality/index.js +18 -0
  87. package/dist/quality/length.js +3 -0
  88. package/dist/quality/maintainability.js +15 -0
  89. package/dist/quality/nesting.js +57 -0
  90. package/dist/quality/report.js +803 -0
  91. package/dist/quality/smells.js +67 -0
  92. package/dist/quality-tool.js +63 -0
  93. package/dist/read-only-commands.js +597 -0
  94. package/dist/repo-map.js +292 -0
  95. package/dist/roblox-connect.js +125 -0
  96. package/dist/rpc.js +91 -0
  97. package/dist/rtk.js +193 -0
  98. package/dist/sandbox.js +105 -0
  99. package/dist/schema.js +214 -0
  100. package/dist/serve.js +50 -0
  101. package/dist/session-lifecycle.js +19 -0
  102. package/dist/session-retention.js +111 -0
  103. package/dist/session.js +460 -0
  104. package/dist/sessions.js +100 -0
  105. package/dist/settings.js +148 -0
  106. package/dist/skills.js +35 -0
  107. package/dist/slop-tool.js +96 -0
  108. package/dist/spend-cap.js +43 -0
  109. package/dist/subagent.js +171 -0
  110. package/dist/tar.js +146 -0
  111. package/dist/theme.js +79 -0
  112. package/dist/thinking.js +45 -0
  113. package/dist/todo.js +114 -0
  114. package/dist/tool-loadout.js +102 -0
  115. package/dist/tool-render.js +769 -0
  116. package/dist/tools.js +176 -0
  117. package/dist/ui.js +4930 -0
  118. package/dist/update.js +551 -0
  119. package/dist/usage-segment.js +74 -0
  120. package/dist/web-tools.js +46 -0
  121. package/dist/web.js +265 -0
  122. package/dist/welcome.js +179 -0
  123. package/dist/workflow-engine.js +246 -0
  124. package/dist/workflow-progress.js +446 -0
  125. package/dist/workflow-view.js +195 -0
  126. package/dist/workflow.js +349 -0
  127. package/package.json +62 -15
  128. package/dist/chunk-27TRKD65.js +0 -2
  129. package/dist/chunk-3FYCFLNK.js +0 -1
  130. package/dist/chunk-3LZR7OEU.js +0 -1
  131. package/dist/chunk-3XL2557N.js +0 -6
  132. package/dist/chunk-56SEAGAQ.js +0 -1
  133. package/dist/chunk-7CHDNTH6.js +0 -1
  134. package/dist/chunk-7QU425F4.js +0 -1
  135. package/dist/chunk-AGGIYXN7.js +0 -2
  136. package/dist/chunk-AJJCVTO4.js +0 -2
  137. package/dist/chunk-AUDMRGWF.js +0 -189
  138. package/dist/chunk-DAPXGSGD.js +0 -12
  139. package/dist/chunk-DL5PTYAO.js +0 -5
  140. package/dist/chunk-DOD7MUGX.js +0 -1
  141. package/dist/chunk-FPXVDP32.js +0 -8
  142. package/dist/chunk-GO2QIQ5P.js +0 -1
  143. package/dist/chunk-GQHBNOPS.js +0 -2
  144. package/dist/chunk-GXB7RZHH.js +0 -1
  145. package/dist/chunk-I6CAUN2V.js +0 -1
  146. package/dist/chunk-ILDDDLRC.js +0 -1
  147. package/dist/chunk-JCBRLX44.js +0 -2
  148. package/dist/chunk-JFYVRWJI.js +0 -2
  149. package/dist/chunk-JX4PCVYT.js +0 -34
  150. package/dist/chunk-LAHVHRCS.js +0 -2
  151. package/dist/chunk-LSJC73DG.js +0 -1
  152. package/dist/chunk-MQVP243W.js +0 -117
  153. package/dist/chunk-N345KWWK.js +0 -1
  154. package/dist/chunk-ONZLNFQ2.js +0 -3
  155. package/dist/chunk-ORJ2QZBG.js +0 -3
  156. package/dist/chunk-P6WSWRXK.js +0 -5
  157. package/dist/chunk-PCALBZOO.js +0 -2
  158. package/dist/chunk-TSEKPGK4.js +0 -1
  159. package/dist/chunk-UTYFLLSM.js +0 -1
  160. package/dist/chunk-V3R4FYTJ.js +0 -1
  161. package/dist/chunk-V656XVXV.js +0 -8
  162. package/dist/chunk-WKUJ7CFO.js +0 -1
  163. package/dist/chunk-WOT6VMZA.js +0 -1
  164. package/dist/chunk-WUPU6LTD.js +0 -4
  165. package/dist/chunk-WX3V5P7U.js +0 -5
  166. package/dist/chunk-YJSES7RK.js +0 -1
  167. package/dist/chunk-YW7NORH3.js +0 -2
package/dist/theme.js ADDED
@@ -0,0 +1,79 @@
1
+ import { detectCapabilities, getTerminalColorMode, parseColor, styleText } from "@netrodev/hxf-tui";
2
+ /**
3
+ * Whether the terminal can show 24-bit colour, decided rather than assumed.
4
+ *
5
+ * This was `"truecolor"`, hardcoded, and that is wrong wherever the assumption
6
+ * does not hold: a `screen` session that never set `COLORTERM`, a `linux` console,
7
+ * an SSH client on an old terminal. The failure is not a crash — it is worse. A
8
+ * truecolor escape on a 256-colour terminal is not downsampled, it is *ignored*,
9
+ * so every colour in the interface collapses to the default foreground and the
10
+ * whole thing reads as one grey wall.
11
+ *
12
+ * `detectCapabilities` already knows the cases: it returns `trueColor: false` for
13
+ * `TERM=screen*` without a `COLORTERM` hint, for `dumb`, and for anything that
14
+ * does not advertise 24-bit. Reading it means the HUD degrades to the 256-colour
15
+ * cube instead of going monochrome.
16
+ *
17
+ * `NO_COLOR` (https://no-color.org) is honoured explicitly and beats everything
18
+ * else, because a user who sets it has asked for no colour at all — and it is
19
+ * also the escape hatch when the result on a particular terminal is unreadable.
20
+ */
21
+ function resolveColorMode() {
22
+ const noColor = process.env.NO_COLOR;
23
+ if (noColor !== undefined && noColor !== "")
24
+ return "256color";
25
+ try {
26
+ return getTerminalColorMode(detectCapabilities());
27
+ }
28
+ catch {
29
+ return "256color";
30
+ }
31
+ }
32
+ export const MODE = resolveColorMode();
33
+ /** True when the user asked for no colour: read at paint time, not once. */
34
+ function colorDisabled() {
35
+ const noColor = process.env.NO_COLOR;
36
+ return noColor !== undefined && noColor !== "";
37
+ }
38
+ export const ink = {
39
+ text: parseColor("#e6e6e6"),
40
+ mute: parseColor("#8b8b8b"),
41
+ dim: parseColor("#5c5c5c"),
42
+ user: parseColor("#d0d0d0"),
43
+ accent: parseColor("#c4b5fd"),
44
+ tool: parseColor("#6ee7b7"),
45
+ bad: parseColor("#f0a8a4"),
46
+ warn: parseColor("#e6b15a"),
47
+ line: parseColor("#3a3a3a"),
48
+ };
49
+ export function paint(text, style) {
50
+ if (colorDisabled()) {
51
+ // Keep the attributes that carry meaning without colour — bold and dim still
52
+ // separate things on a monochrome terminal, and dropping them too would make
53
+ // the output unreadable rather than plain.
54
+ const { bold, dim, italic, underline, strikethrough } = style;
55
+ if (!bold && !dim && !italic && !underline && !strikethrough)
56
+ return text;
57
+ return styleText(text, { bold, dim, italic, underline, strikethrough }, MODE);
58
+ }
59
+ return styleText(text, style, MODE);
60
+ }
61
+ export function fg(text, color, extra) {
62
+ return paint(text, { ...extra, fg: color });
63
+ }
64
+ export const mdTheme = {
65
+ heading: (text) => fg(text, ink.text, { bold: true }),
66
+ link: (text) => fg(text, ink.accent, { underline: true }),
67
+ linkUrl: (text) => fg(text, ink.mute),
68
+ code: (text) => fg(text, ink.text),
69
+ codeBlock: (text) => fg(text, ink.text),
70
+ codeBlockBorder: (text) => fg(text, ink.line),
71
+ quote: (text) => fg(text, ink.mute, { italic: true }),
72
+ quoteBorder: (text) => fg(text, ink.line),
73
+ hr: (text) => fg(text, ink.line),
74
+ listBullet: (text) => fg(text, ink.mute),
75
+ bold: (text) => fg(text, ink.text, { bold: true }),
76
+ italic: (text) => fg(text, ink.text, { italic: true }),
77
+ strikethrough: (text) => fg(text, ink.mute, { strikethrough: true }),
78
+ underline: (text) => fg(text, ink.text, { underline: true }),
79
+ };
@@ -0,0 +1,45 @@
1
+ /** Every level the CLI accepts, lowest first. One list, shared by every caller. */
2
+ export const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
3
+ /**
4
+ * The highest level this model actually reaches the provider with, or
5
+ * `undefined` when it reaches none — the ceiling decides whether the HUD may
6
+ * light the shimmer, so its three states have to stay distinguishable:
7
+ *
8
+ * - **No map** (`thinkingLevelMap` absent, or no model yet): nothing is known
9
+ * per level, so take the highest listed level. It is a guess, but the best
10
+ * available one, and it becomes exact the moment a provider fills the map in.
11
+ * - **With a map**: `null` *and* a missing key both mean unsupported — the
12
+ * type is `Partial`, so an absent entry is how a level that was never wired
13
+ * up appears. A value of `""` is still a value; `null` is the only marker
14
+ * of "does not reach the provider".
15
+ * - **Every value `null`**: the ceiling is `undefined` and the feature is off
16
+ * for this model. Falling back to `max` here would announce a top the model
17
+ * does not have.
18
+ */
19
+ export function levelCeiling(model) {
20
+ const map = model?.thinkingLevelMap;
21
+ if (map === undefined)
22
+ return THINKING_LEVELS[THINKING_LEVELS.length - 1];
23
+ for (let index = THINKING_LEVELS.length - 1; index >= 0; index -= 1) {
24
+ const value = map[THINKING_LEVELS[index]];
25
+ if (typeof value === "string")
26
+ return THINKING_LEVELS[index];
27
+ }
28
+ return undefined;
29
+ }
30
+ /**
31
+ * One step up, wrapping from the top of the list back to `off`.
32
+ *
33
+ * The wrap runs over the whole list, not over the model's ceiling: the SDK
34
+ * clamps whatever the model rejects, and a wrap that stopped at the ceiling
35
+ * would leave the raise key dead exactly where the user keeps pressing it.
36
+ */
37
+ export function nextLevel(level) {
38
+ const index = THINKING_LEVELS.indexOf(level);
39
+ return THINKING_LEVELS[(index + 1 + THINKING_LEVELS.length) % THINKING_LEVELS.length];
40
+ }
41
+ /** One step down, wrapping from `off` back to the top of the list. */
42
+ export function prevLevel(level) {
43
+ const index = THINKING_LEVELS.indexOf(level);
44
+ return THINKING_LEVELS[(index - 1 + THINKING_LEVELS.length) % THINKING_LEVELS.length];
45
+ }
package/dist/todo.js ADDED
@@ -0,0 +1,114 @@
1
+ /**
2
+ * A session-scoped task list.
3
+ *
4
+ * Adapted from the SDK's own `examples/extensions/todo.ts`, which establishes the
5
+ * pattern that matters: the authoritative state lives in each tool result's
6
+ * `details`, and the in-memory copy is rebuilt by replaying the current session
7
+ * branch. Nothing is written to disk, so the list is automatically correct after
8
+ * a fork, a rewind or a resumed session — an external todo file would silently
9
+ * disagree with the transcript.
10
+ *
11
+ * The op model (`init`/`start`/`done`/`drop`/`view`) is the `todo`
12
+ * tool (`docs/tools/todo.md`), which is what makes a long run legible: the model
13
+ * records the whole plan up front, then moves one task at a time, and a stalled
14
+ * run leaves visible evidence of where it stopped.
15
+ */
16
+ import { StringEnum } from "@netrodev/hxf-ai";
17
+ import { defineTool } from "@netrodev/hxf-coding-agent";
18
+ import { Type } from "typebox";
19
+ /** Marks the status glyph. All are non-emoji (see scripts/check-tool-render.mjs). */
20
+ const MARK = {
21
+ pending: "[ ]",
22
+ in_progress: "[>]",
23
+ completed: "[x]",
24
+ dropped: "[-]",
25
+ };
26
+ export const todoParams = Type.Object({
27
+ op: StringEnum(["init", "start", "done", "drop", "view"], {
28
+ description: "init replaces the list; start/done/drop move one task; view reads it",
29
+ }),
30
+ items: Type.Optional(Type.Array(Type.String(), {
31
+ description: "Task labels for init. 5-10 words each, specific enough to execute without re-planning",
32
+ })),
33
+ task: Type.Optional(Type.String({ description: "Exact label of the task to start, complete or drop" })),
34
+ });
35
+ /** Render the list the way the model should read it back. */
36
+ export function formatTodos(todos) {
37
+ if (todos.length === 0)
38
+ return "Todo list is empty.";
39
+ const done = todos.filter((item) => item.status === "completed").length;
40
+ const lines = todos.map((item) => `${MARK[item.status]} ${item.content}`);
41
+ const open = todos.filter((item) => item.status === "pending" || item.status === "in_progress").length;
42
+ return [`${done}/${todos.length} done, ${open} open`, ...lines].join("\n");
43
+ }
44
+ /**
45
+ * Apply one op to a list. Pure, so the policy is testable without a session:
46
+ * `start` demotes any other in-progress task (only one task
47
+ * is ever in progress).
48
+ */
49
+ export function applyOp(todos, op, items, task) {
50
+ const list = todos.map((item) => ({ ...item }));
51
+ switch (op) {
52
+ case "init": {
53
+ if (!items || items.length === 0)
54
+ return { todos: list, error: "init needs a non-empty items array" };
55
+ return { todos: items.map((content) => ({ content, status: "pending" })) };
56
+ }
57
+ case "view":
58
+ return { todos: list };
59
+ case "start":
60
+ case "done":
61
+ case "drop": {
62
+ if (!task)
63
+ return { todos: list, error: `${op} needs task` };
64
+ const target = list.find((item) => item.content === task);
65
+ if (!target)
66
+ return { todos: list, error: `no task matches ${JSON.stringify(task)}` };
67
+ if (op === "start") {
68
+ for (const item of list)
69
+ if (item.status === "in_progress")
70
+ item.status = "pending";
71
+ target.status = "in_progress";
72
+ }
73
+ else {
74
+ target.status = op === "done" ? "completed" : "dropped";
75
+ }
76
+ return { todos: list };
77
+ }
78
+ default:
79
+ return { todos: list, error: `unknown op ${JSON.stringify(op)}` };
80
+ }
81
+ }
82
+ /** Rebuild the list by replaying this branch's todo results in order. */
83
+ export function readTodos(ctx) {
84
+ let todos = [];
85
+ for (const entry of ctx.sessionManager.getBranch()) {
86
+ if (entry.type !== "message")
87
+ continue;
88
+ const message = entry.message;
89
+ if (message.role !== "toolResult" || message.toolName !== "todo")
90
+ continue;
91
+ const details = message.details;
92
+ if (details?.todos)
93
+ todos = details.todos;
94
+ }
95
+ return todos;
96
+ }
97
+ export const todoTool = defineTool({
98
+ name: "todo",
99
+ label: "todo",
100
+ description: "Track the plan for this task. Use `init` once with the whole plan (investigation through verification), then `start`/`done` as you go. Keep the list current so progress stays visible; do not re-init unless the plan materially changes.",
101
+ promptSnippet: "todo: record and advance the plan for the current task",
102
+ parameters: todoParams,
103
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
104
+ const before = readTodos(ctx);
105
+ const { todos, error } = applyOp(before, params.op, params.items, params.task);
106
+ const details = { op: params.op, todos, ...(error ? { error } : {}) };
107
+ const summary = error ? `Error: ${error}\n${formatTodos(todos)}` : formatTodos(todos);
108
+ return {
109
+ content: [{ type: "text", text: summary }],
110
+ details,
111
+ ...(error ? { isError: true } : {}),
112
+ };
113
+ },
114
+ });
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Keeps this product's tool loadout in place without starving extension tools.
3
+ *
4
+ * The SDK's active set starts as `read, bash, edit, write` when `defaultTools`
5
+ * is unset. The harness now defaults to `grep`, `find` and `ls` as well, so this
6
+ * pass is what keeps the product's own loadout stable rather than the only thing
7
+ * that makes those three callable; `bash_output` and `kill_shell` are still
8
+ * outside the default set and are the pair this exists for.
9
+ *
10
+ * `grep`, `find` and `ls` were once registered by the SDK but not active, so
11
+ * without naming them they were dead weight: `permissions.ts` carried approval
12
+ * tiers for them and `agents.ts` told every subagent to use them, while the model
13
+ * could not call them. Measured before that fix: the model reported
14
+ * `read, bash, edit, write, task, …` and answered "NO GREP TOOL".
15
+ *
16
+ * **Where this has to happen.** Not in an extension. An extension's
17
+ * `session_start` handler runs inside `AgentSession.bindExtensions()`, which the
18
+ * SDK immediately follows with `_refreshToolRegistry()` — so anything
19
+ * `setActiveTools` did there is silently overwritten before the first turn.
20
+ * Measured: the handler ran, `setActiveTools` was called, and the active set was
21
+ * still `bash, edit, read, write`. `activateExtraBuiltins` is called from
22
+ * `openSession` instead, on the session object, once the session exists.
23
+ *
24
+ * **Why not the SDK's `tools:` option.** It is an allowlist applied to *every*
25
+ * registered tool — extension tools included — in `_refreshToolRegistry` via
26
+ * `_isAllowedTool`. Two things break because of that:
27
+ *
28
+ * 1. `mcp__<server>__<tool>` names are not knowable in advance, so an allowlist
29
+ * discards them. Measured: an MCP server connected, `/mcp` reported "14
30
+ * tools", and the model could call none of them.
31
+ * 2. The MCP extension activates `codemode` at `session_start` for the default
32
+ * `exposure: "codemode"`, but the allowlist filter runs when the registry is
33
+ * rebuilt — after that activation — so a static list undid it, and the user
34
+ * was told "MCP tools are only reachable from the codemode or tool_search
35
+ * tool, but neither is active" on a fully connected server.
36
+ *
37
+ * Adding to the active set leaves everything the extensions registered exactly
38
+ * where it was.
39
+ */
40
+ /**
41
+ * The built-ins this product offers that the SDK does not enable by default.
42
+ *
43
+ * `grep`/`find`/`ls` are registered by the SDK but absent from
44
+ * `DEFAULT_TOOL_NAMES` (`read, bash, edit, write`), so without naming them they
45
+ * are dead weight: they have approval tiers and every subagent is told to use
46
+ * them, while the main agent cannot call them.
47
+ */
48
+ export const EXTRA_BUILTINS = ["grep", "find", "ls", "bash_output", "kill_shell"];
49
+ /**
50
+ * Wait, briefly, for extension-registered tools to appear.
51
+ *
52
+ * `session_start` handlers are async and the extension runner does not await them
53
+ * (`ExtensionRunner.emit` starts them and returns), so a handler that registers a
54
+ * tool — the MCP extension's `codemode` — lands some milliseconds after
55
+ * `bindExtensions()` resolves. Reading the loadout immediately would report a set
56
+ * that is about to grow, and the first turn would run without those tools.
57
+ *
58
+ * Bounded on purpose: it returns as soon as the set stops growing for a couple of
59
+ * ticks, and never waits longer than `timeoutMs` however slow a server is. A slow
60
+ * MCP server therefore cannot delay startup.
61
+ */
62
+ export async function settleExtensionTools(session, { timeoutMs = 2_000, quietTicks = 2 } = {}) {
63
+ const deadline = Date.now() + timeoutMs;
64
+ let size = session.getActiveToolNames().length;
65
+ let quiet = 0;
66
+ while (Date.now() < deadline && quiet < quietTicks) {
67
+ await new Promise((resolve) => setTimeout(resolve, 50));
68
+ const next = session.getActiveToolNames().length;
69
+ if (next > size) {
70
+ size = next;
71
+ quiet = 0;
72
+ }
73
+ else {
74
+ quiet += 1;
75
+ }
76
+ }
77
+ }
78
+ /**
79
+ * Add the extra built-ins to a session's active set.
80
+ *
81
+ * Only a tool that actually exists is added: `powershell` is registered on every
82
+ * platform but throws off Windows, and a name that was never registered would
83
+ * simply be ignored. Adding, never replacing, is what keeps `codemode` and the
84
+ * MCP tools the MCP extension activated.
85
+ *
86
+ * Returns the names that were added, so a caller (or a test) can see what
87
+ * happened instead of guessing.
88
+ */
89
+ export function activateExtraBuiltins(session) {
90
+ const active = new Set(session.getActiveToolNames());
91
+ const registered = new Set(session.getAllTools().map((tool) => tool.name));
92
+ const added = [];
93
+ for (const name of EXTRA_BUILTINS) {
94
+ if (registered.has(name) && !active.has(name)) {
95
+ active.add(name);
96
+ added.push(name);
97
+ }
98
+ }
99
+ if (added.length > 0)
100
+ session.setActiveToolsByName([...active]);
101
+ return added;
102
+ }