@mwillbanks/ast-mcp 0.1.3 → 0.2.1

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 (58) hide show
  1. package/README.md +59 -20
  2. package/dist/ast-mcp.js +232 -130
  3. package/dist/ast-mcp.js.map +107 -27
  4. package/package.json +2 -1
  5. package/src/ast-bro/capability.ts +3 -8
  6. package/src/ast-bro/client.ts +18 -2
  7. package/src/ast-bro/result.ts +5 -12
  8. package/src/cli.ts +70 -95
  9. package/src/config-cli.ts +54 -0
  10. package/src/config.ts +886 -0
  11. package/src/helpers/aider.ts +252 -0
  12. package/src/helpers/ast-bro.ts +64 -0
  13. package/src/helpers/config.ts +149 -0
  14. package/src/helpers/hook.ts +60 -0
  15. package/src/helpers/installer.ts +249 -0
  16. package/src/helpers/json.ts +19 -0
  17. package/src/helpers/mcp-schema.ts +31 -0
  18. package/src/helpers/process.ts +31 -0
  19. package/src/helpers/string.ts +97 -0
  20. package/src/hook.ts +135 -40
  21. package/src/http-entry.ts +1 -1
  22. package/src/http.ts +118 -103
  23. package/src/installer-transport.ts +190 -0
  24. package/src/installer.ts +604 -247
  25. package/src/mcp-cli.ts +104 -0
  26. package/src/patch/aider.ts +6 -199
  27. package/src/patch/engine.ts +271 -197
  28. package/src/runtime/dependencies.ts +48 -29
  29. package/src/runtime/file-delete.ts +13 -9
  30. package/src/runtime/file-read.ts +91 -57
  31. package/src/runtime/file-rename.ts +158 -0
  32. package/src/runtime/format.ts +57 -34
  33. package/src/runtime/paths.ts +30 -16
  34. package/src/runtime/policy.ts +21 -0
  35. package/src/runtime/process-input.ts +14 -4
  36. package/src/service.ts +217 -0
  37. package/src/shell-policy.ts +331 -0
  38. package/src/stdio.ts +47 -35
  39. package/src/tools/ast-bro.ts +12 -6
  40. package/src/tools/configured.ts +28 -0
  41. package/src/tools/files.ts +24 -27
  42. package/src/tools/index.ts +5 -3
  43. package/src/tools/lifecycle.ts +69 -55
  44. package/templates/skills/ast-mcp/SKILL.md +7 -6
  45. package/templates/skills/ast-mcp/evals/batch.evals.json +48 -0
  46. package/templates/skills/ast-mcp/evals/evals.json +1 -0
  47. package/templates/skills/ast-mcp/evals/score.test.ts +175 -0
  48. package/templates/skills/ast-mcp/evals/score.ts +304 -267
  49. package/templates/skills/ast-mcp/evals/semantic.test.ts +322 -0
  50. package/templates/skills/ast-mcp/evals/semantic.ts +390 -135
  51. package/templates/skills/ast-mcp/evals/shell-policy.ts +252 -0
  52. package/templates/skills/ast-mcp/evals/source.test.ts +46 -0
  53. package/templates/skills/ast-mcp/evals/source.ts +164 -0
  54. package/templates/skills/ast-mcp/evals/trigger-queries.json +1 -1
  55. package/templates/skills/ast-mcp/references/installation.md +9 -8
  56. package/templates/skills/ast-mcp/references/patch-state-machine.md +5 -5
  57. package/templates/skills/ast-mcp/references/tool-catalog.md +4 -2
  58. package/templates/skills/ast-mcp/scripts/check-install.ts +323 -131
@@ -5,46 +5,104 @@ import path from "node:path";
5
5
 
6
6
  type Scope = "local" | "global";
7
7
  type Target = "codex" | "claude" | "copilot";
8
+ type Transport = "stdio" | "http";
8
9
 
9
- function parse(args: string[]) {
10
- let scope: Scope = "local";
11
- let target: Target = "codex";
12
- let root = process.cwd();
13
- for (let index = 0; index < args.length; index += 1) {
14
- if (args[index] === "--scope") scope = args[++index] as Scope;
15
- else if (args[index] === "--target") target = args[++index] as Target;
16
- else if (args[index] === "--root") root = path.resolve(args[++index]);
17
- else throw new Error(`Unknown argument: ${args[index]}`);
10
+ type CheckOptions = {
11
+ host: string;
12
+ port: number;
13
+ root: string;
14
+ scope: Scope;
15
+ service: boolean;
16
+ target: Target;
17
+ transport: Transport;
18
+ url: string;
19
+ };
20
+ type MutableCheckOptions = Omit<CheckOptions, "url">;
21
+ function applyOption(
22
+ options: MutableCheckOptions,
23
+ args: string[],
24
+ index: number,
25
+ ) {
26
+ const option = args[index];
27
+ const value = args[index + 1];
28
+ switch (option) {
29
+ case "--scope":
30
+ options.scope = value as Scope;
31
+ return index + 1;
32
+ case "--target":
33
+ options.target = value as Target;
34
+ return index + 1;
35
+ case "--root":
36
+ options.root = path.resolve(value);
37
+ return index + 1;
38
+ case "--transport":
39
+ options.transport = value as Transport;
40
+ return index + 1;
41
+ case "--host":
42
+ options.host = value;
43
+ return index + 1;
44
+ case "--port":
45
+ options.port = Number(value);
46
+ return index + 1;
47
+ case "--service":
48
+ options.service = true;
49
+ return index;
50
+ default:
51
+ throw new Error(`Unknown argument: ${option}`);
18
52
  }
53
+ }
54
+ function validateOptions(options: MutableCheckOptions) {
55
+ if (
56
+ !["local", "global"].includes(options.scope) ||
57
+ !["codex", "claude", "copilot"].includes(options.target) ||
58
+ !["stdio", "http"].includes(options.transport)
59
+ )
60
+ throw new Error("Invalid --scope, --target, or --transport");
19
61
  if (
20
- !["local", "global"].includes(scope) ||
21
- !["codex", "claude", "copilot"].includes(target)
62
+ !Number.isInteger(options.port) ||
63
+ options.port < 1 ||
64
+ options.port > 65_535
22
65
  )
23
- throw new Error("Invalid --scope or --target");
24
- return { root, scope, target };
66
+ throw new Error("Invalid --port");
67
+ if (options.service && options.transport !== "http")
68
+ throw new Error("--service requires --transport http");
69
+ }
70
+ function clientHost(host: string) {
71
+ if (host === "0.0.0.0") return "127.0.0.1";
72
+ if (host === "::") return "::1";
73
+ return host.startsWith("[") && host.endsWith("]") ? host.slice(1, -1) : host;
74
+ }
75
+ function endpointUrl(host: string, port: number) {
76
+ const client = clientHost(host);
77
+ return `http://${client.includes(":") ? `[${client}]` : client}:${port}/mcp`;
78
+ }
79
+ function parse(args: string[]): CheckOptions {
80
+ const options: MutableCheckOptions = {
81
+ host: "127.0.0.1",
82
+ port: 3768,
83
+ root: process.cwd(),
84
+ scope: "local",
85
+ service: false,
86
+ target: "codex",
87
+ transport: "stdio",
88
+ };
89
+ for (let index = 0; index < args.length; index += 1)
90
+ index = applyOption(options, args, index);
91
+ validateOptions(options);
92
+ return { ...options, url: endpointUrl(options.host, options.port) };
25
93
  }
26
94
 
27
95
  const instructionsBegin = "<!-- ast-mcp:begin -->";
28
96
  const instructionsEnd = "<!-- ast-mcp:end -->";
29
97
 
30
98
  async function astMcpEntry(entry: unknown): Promise<boolean> {
31
- if (typeof entry !== "string" || path.basename(entry) !== "ast-mcp.js")
99
+ if (entry === "./node_modules/.bin/ast-mcp") return true;
100
+ if (typeof entry !== "string" || path.basename(entry) !== "ast-mcp")
32
101
  return false;
33
- let folder = path.dirname(path.resolve(entry));
34
- while (true) {
35
- try {
36
- const manifest = JSON.parse(
37
- await readFile(path.join(folder, "package.json"), "utf8"),
38
- );
39
- return (
40
- manifest.name === "@mwillbanks/ast-mcp" &&
41
- path.resolve(entry) === path.join(folder, "dist/ast-mcp.js")
42
- );
43
- } catch {}
44
- const parent = path.dirname(folder);
45
- if (parent === folder) return false;
46
- folder = parent;
47
- }
102
+ const bin = path.dirname(entry);
103
+ return (
104
+ path.basename(bin) === "bin" && path.basename(path.dirname(bin)) === ".bun"
105
+ );
48
106
  }
49
107
 
50
108
  async function expectedReference(
@@ -105,7 +163,7 @@ async function hookCurrent(
105
163
  );
106
164
  for (const command of commands) {
107
165
  if (typeof command !== "string") continue;
108
- const match = command.match(/^bun (.+) hook$/);
166
+ const match = command.match(/^(.+) hook$/);
109
167
  if (!match) continue;
110
168
  try {
111
169
  if (await astMcpEntry(JSON.parse(match[1]))) return true;
@@ -114,170 +172,304 @@ async function hookCurrent(
114
172
  return false;
115
173
  }
116
174
 
175
+ type McpEntry = {
176
+ args?: unknown[];
177
+ command?: unknown;
178
+ env?: Record<string, unknown>;
179
+ tools?: unknown;
180
+ type?: unknown;
181
+ url?: unknown;
182
+ };
183
+ function httpJsonMcpCurrent(
184
+ entry: McpEntry | undefined,
185
+ type: "local" | "stdio" | undefined,
186
+ url: string | undefined,
187
+ ) {
188
+ return (
189
+ entry?.type === "http" &&
190
+ entry.url === url &&
191
+ (type !== "local" || Array.isArray(entry.tools))
192
+ );
193
+ }
194
+ async function stdioCommandCurrent(entry: McpEntry | undefined) {
195
+ return (
196
+ (await astMcpEntry(entry?.command)) &&
197
+ Array.isArray(entry?.args) &&
198
+ entry.args.length === 1 &&
199
+ entry.args[0] === "mcp"
200
+ );
201
+ }
202
+
203
+ function entryTypeCurrent(
204
+ entry: McpEntry,
205
+ type: "local" | "stdio" | undefined,
206
+ ) {
207
+ if (!type) return true;
208
+ if (entry.type !== type) return false;
209
+ return type !== "local" || Array.isArray(entry.tools);
210
+ }
211
+
212
+ function entryRootCurrent(entry: McpEntry, root: string | undefined) {
213
+ return root
214
+ ? entry.env?.AST_MCP_PROJECT_ROOT === root
215
+ : Object.keys(entry.env ?? {}).length === 0;
216
+ }
217
+
218
+ function stdioMetadataCurrent(
219
+ entry: McpEntry,
220
+ root: string | undefined,
221
+ type: "local" | "stdio" | undefined,
222
+ ) {
223
+ return entryTypeCurrent(entry, type) && entryRootCurrent(entry, root);
224
+ }
225
+
226
+ async function stdioJsonMcpCurrent(
227
+ entry: McpEntry | undefined,
228
+ root: string | undefined,
229
+ type: "local" | "stdio" | undefined,
230
+ ) {
231
+ return (
232
+ (await stdioCommandCurrent(entry)) &&
233
+ stdioMetadataCurrent(entry as McpEntry, root, type)
234
+ );
235
+ }
117
236
  async function jsonMcpCurrent(
118
237
  file: string,
119
238
  section: "mcpServers" | "servers",
120
239
  root?: string,
121
240
  type?: "local" | "stdio",
241
+ transport: Transport = "stdio",
242
+ url?: string,
122
243
  ) {
123
244
  const value = JSON.parse(await readFile(file, "utf8").catch(() => "{}"));
124
- const entry = value[section]?.["ast-mcp"];
125
- if (
126
- entry?.command !== "bun" ||
127
- !Array.isArray(entry.args) ||
128
- !(await astMcpEntry(entry.args[0])) ||
129
- entry.args[1] !== "mcp"
130
- )
131
- return false;
132
- if (type && entry.type !== type) return false;
133
- if (
134
- root &&
135
- (entry.env?.AST_MCP_ROOTS !== root ||
136
- entry.env?.AST_MCP_ALLOW_EXTERNAL_ROOTS !== "1")
137
- )
138
- return false;
139
- if (!root && Object.keys(entry.env ?? {}).length !== 0) return false;
140
- if (type === "local" && !Array.isArray(entry.tools)) return false;
141
- return true;
245
+ const entry: McpEntry | undefined = value[section]?.["ast-mcp"];
246
+ return transport === "http"
247
+ ? httpJsonMcpCurrent(entry, type, url)
248
+ : stdioJsonMcpCurrent(entry, root, type);
142
249
  }
143
250
 
144
- async function codexMcpCurrent(file: string, root?: string) {
145
- const content = await readFile(file, "utf8").catch(() => "");
146
- const block =
147
- content.match(/# ast-mcp:begin\n([\s\S]*?)# ast-mcp:end/)?.[1] ?? "";
148
- const args = block.match(/args = \[(".*"), "mcp"\]/);
251
+ function codexHttpMcpCurrent(block: string, url: string | undefined) {
252
+ return (
253
+ block.includes("[mcp_servers.ast-mcp]") &&
254
+ block.includes(`url = ${JSON.stringify(url)}`) &&
255
+ !block.includes("command =")
256
+ );
257
+ }
258
+ async function codexStdioMcpCurrent(block: string, root: string | undefined) {
259
+ const command = block.match(/command = (".*")/);
149
260
  if (
150
261
  !block.includes("[mcp_servers.ast-mcp]") ||
151
- !block.includes('command = "bun"') ||
152
- !args ||
153
- !(await astMcpEntry(JSON.parse(args[1])))
262
+ !block.includes('args = ["mcp"]') ||
263
+ !command ||
264
+ !(await astMcpEntry(JSON.parse(command[1])))
154
265
  )
155
266
  return false;
156
267
  return root
157
- ? block.includes(`AST_MCP_ROOTS = ${JSON.stringify(root)}`) &&
158
- block.includes('AST_MCP_ALLOW_EXTERNAL_ROOTS = "1"')
159
- : !block.includes("AST_MCP_ROOTS");
268
+ ? block.includes(`AST_MCP_PROJECT_ROOT = ${JSON.stringify(root)}`)
269
+ : !block.includes("AST_MCP_PROJECT_ROOT");
160
270
  }
161
- export async function checkInstall(
162
- args = process.argv.slice(2),
163
- home = os.homedir(),
271
+ async function codexMcpCurrent(
272
+ file: string,
273
+ root?: string,
274
+ transport: Transport = "stdio",
275
+ url?: string,
164
276
  ) {
165
- const options = parse(args);
166
- const global = options.scope === "global";
167
- const checks: Record<string, boolean> = {};
168
- if (options.target === "codex") {
169
- const base = global
170
- ? path.join(home, ".codex")
171
- : path.join(options.root, ".codex");
172
- checks.mcp = await codexMcpCurrent(
277
+ const content = await readFile(file, "utf8").catch(() => "");
278
+ const block =
279
+ content.match(/# ast-mcp:begin\n([\s\S]*?)# ast-mcp:end/)?.[1] ?? "";
280
+ return transport === "http"
281
+ ? codexHttpMcpCurrent(block, url)
282
+ : codexStdioMcpCurrent(block, root);
283
+ }
284
+
285
+ type InstallChecks = Record<string, boolean>;
286
+ async function codexChecks(
287
+ options: CheckOptions,
288
+ home: string,
289
+ global: boolean,
290
+ ): Promise<InstallChecks> {
291
+ const base = global
292
+ ? path.join(home, ".codex")
293
+ : path.join(options.root, ".codex");
294
+ const [mcp, hook, skill, instructions] = await Promise.all([
295
+ codexMcpCurrent(
173
296
  path.join(base, "config.toml"),
174
297
  global ? undefined : options.root,
175
- );
176
- checks.hook = await hookCurrent(
298
+ options.transport,
299
+ options.url,
300
+ ),
301
+ hookCurrent(
177
302
  path.join(base, "hooks.json"),
178
303
  "PreToolUse",
179
304
  path.join(base, "hooks/ast-mcp.ts"),
180
305
  global ? path.join(base, "hooks/ast-mcp.ts") : ".codex/hooks/ast-mcp.ts",
181
- );
182
- checks.skill = await skillCurrent(
183
- path.join(base, "skills/ast-mcp/SKILL.md"),
184
- );
185
- checks.instructions = await instructionsCurrent(
306
+ ),
307
+ skillCurrent(path.join(base, "skills/ast-mcp/SKILL.md")),
308
+ instructionsCurrent(
186
309
  global
187
310
  ? path.join(base, "AGENTS.md")
188
311
  : path.join(options.root, "AGENTS.md"),
189
- );
190
- } else if (options.target === "claude") {
191
- const base = global
192
- ? path.join(home, ".claude")
193
- : path.join(options.root, ".claude");
194
- checks.mcp = await jsonMcpCurrent(
312
+ ),
313
+ ]);
314
+ return { hook, instructions, mcp, skill };
315
+ }
316
+ async function claudeChecks(
317
+ options: CheckOptions,
318
+ home: string,
319
+ global: boolean,
320
+ ): Promise<InstallChecks> {
321
+ const base = global
322
+ ? path.join(home, ".claude")
323
+ : path.join(options.root, ".claude");
324
+ const [mcp, hook, skill, instructions] = await Promise.all([
325
+ jsonMcpCurrent(
195
326
  global
196
327
  ? path.join(home, ".claude.json")
197
328
  : path.join(options.root, ".mcp.json"),
198
329
  "mcpServers",
199
330
  global ? undefined : options.root,
200
- );
201
- checks.hook = await hookCurrent(
331
+ undefined,
332
+ options.transport,
333
+ options.url,
334
+ ),
335
+ hookCurrent(
202
336
  path.join(base, "settings.json"),
203
337
  "PreToolUse",
204
338
  path.join(base, "hooks/ast-mcp.ts"),
205
339
  global
206
340
  ? path.join(base, "hooks/ast-mcp.ts")
207
341
  : `\${CLAUDE_PROJECT_DIR}/.claude/hooks/ast-mcp.ts`,
208
- );
209
- checks.skill = await skillCurrent(
210
- path.join(base, "skills/ast-mcp/SKILL.md"),
211
- );
212
- checks.instructions = await instructionsCurrent(
342
+ ),
343
+ skillCurrent(path.join(base, "skills/ast-mcp/SKILL.md")),
344
+ instructionsCurrent(
213
345
  global
214
346
  ? path.join(base, "CLAUDE.md")
215
347
  : path.join(options.root, "AGENTS.md"),
216
- );
217
- } else {
218
- const base = global
219
- ? path.join(home, ".copilot")
220
- : path.join(options.root, ".github");
221
- checks.mcp = await jsonMcpCurrent(
348
+ ),
349
+ ]);
350
+ return { hook, instructions, mcp, skill };
351
+ }
352
+ async function copilotChecks(
353
+ options: CheckOptions,
354
+ home: string,
355
+ global: boolean,
356
+ ): Promise<InstallChecks> {
357
+ const base = global
358
+ ? path.join(home, ".copilot")
359
+ : path.join(options.root, ".github");
360
+ const [mcp, hook, skill, instructions] = await Promise.all([
361
+ jsonMcpCurrent(
222
362
  global
223
363
  ? path.join(base, "mcp-config.json")
224
364
  : path.join(options.root, ".github/mcp.json"),
225
365
  "mcpServers",
226
366
  global ? undefined : options.root,
227
367
  "local",
228
- );
229
- checks.hook = await hookCurrent(
368
+ options.transport,
369
+ options.url,
370
+ ),
371
+ hookCurrent(
230
372
  path.join(base, "hooks/ast-mcp.json"),
231
373
  "preToolUse",
232
374
  path.join(base, "hooks/ast-mcp.ts"),
233
375
  global ? path.join(base, "hooks/ast-mcp.ts") : ".github/hooks/ast-mcp.ts",
234
- );
235
- checks.skill = await skillCurrent(
236
- path.join(base, "skills/ast-mcp/SKILL.md"),
237
- );
238
- checks.instructions = await instructionsCurrent(
376
+ ),
377
+ skillCurrent(path.join(base, "skills/ast-mcp/SKILL.md")),
378
+ instructionsCurrent(
239
379
  global
240
380
  ? path.join(base, "copilot-instructions.md")
241
381
  : path.join(options.root, "AGENTS.md"),
382
+ ),
383
+ ]);
384
+ const checks: InstallChecks = { hook, instructions, mcp, skill };
385
+ if (!global)
386
+ checks.vscode = await jsonMcpCurrent(
387
+ path.join(options.root, ".vscode/mcp.json"),
388
+ "servers",
389
+ options.root,
390
+ "stdio",
391
+ options.transport,
392
+ options.url,
242
393
  );
243
- if (!global)
244
- checks.vscode = await jsonMcpCurrent(
245
- path.join(options.root, ".vscode/mcp.json"),
246
- "servers",
247
- options.root,
248
- "stdio",
249
- );
250
- }
394
+ return checks;
395
+ }
396
+ function targetChecks(options: CheckOptions, home: string, global: boolean) {
397
+ if (options.target === "codex") return codexChecks(options, home, global);
398
+ if (options.target === "claude") return claudeChecks(options, home, global);
399
+ return copilotChecks(options, home, global);
400
+ }
401
+ function serviceFile(options: CheckOptions, home: string) {
402
+ const digest = new Bun.CryptoHasher("sha256")
403
+ .update(path.resolve(options.root))
404
+ .digest("hex")
405
+ .slice(0, 12);
406
+ const id = options.scope === "global" ? "ast-mcp" : `ast-mcp-${digest}`;
407
+ return process.platform === "darwin"
408
+ ? path.join(home, "Library/LaunchAgents", `com.mwillbanks.${id}.plist`)
409
+ : path.join(home, ".config/systemd/user", `${id}.service`);
410
+ }
411
+ async function serviceCurrent(options: CheckOptions, home: string) {
412
+ if (process.platform !== "darwin" && process.platform !== "linux")
413
+ return false;
414
+ const content = await readFile(serviceFile(options, home), "utf8").catch(
415
+ () => "",
416
+ );
417
+ return (
418
+ content.includes("--transport") &&
419
+ content.includes("http") &&
420
+ content.includes(options.host) &&
421
+ content.includes(String(options.port)) &&
422
+ (options.scope === "global" || content.includes(path.resolve(options.root)))
423
+ );
424
+ }
425
+ function installOperation(checks: InstallChecks) {
426
+ if (Object.values(checks).every(Boolean)) return "none" as const;
427
+ return Object.values(checks).some(Boolean)
428
+ ? ("update" as const)
429
+ : ("install" as const);
430
+ }
431
+ function commandSuffix(options: CheckOptions, global: boolean) {
432
+ return `--scope ${options.scope} --target ${options.target}${global ? "" : ` --root ${JSON.stringify(options.root)}`}${options.transport === "http" ? ` --transport http --host ${JSON.stringify(options.host)} --port ${options.port}` : ""}${options.service ? " --service" : ""}`;
433
+ }
434
+ function installCommands(options: CheckOptions, global: boolean) {
435
+ const suffix = commandSuffix(options, global);
436
+ return {
437
+ installCommand: global
438
+ ? `bun add --global --trust @ast-bro/cli dprint @mwillbanks/ast-mcp && ast-mcp install ${suffix}`
439
+ : `bun add --dev @mwillbanks/ast-mcp && bun pm trust @ast-bro/cli dprint && ./node_modules/.bin/ast-mcp install ${suffix}`,
440
+ uninstallCommand: global
441
+ ? `ast-mcp uninstall ${suffix}`
442
+ : `./node_modules/.bin/ast-mcp uninstall ${suffix}`,
443
+ updateCommand: global
444
+ ? `ast-mcp update ${suffix}`
445
+ : `./node_modules/.bin/ast-mcp update ${suffix}`,
446
+ };
447
+ }
448
+ export async function checkInstall(
449
+ args = process.argv.slice(2),
450
+ home = os.homedir(),
451
+ ) {
452
+ const options = parse(args);
453
+ const global = options.scope === "global";
454
+ const checks = await targetChecks(options, home, global);
455
+ if (options.service) checks.service = await serviceCurrent(options, home);
251
456
  const installed = Object.values(checks).every(Boolean);
252
- const operation = installed
253
- ? "none"
254
- : Object.values(checks).some(Boolean)
255
- ? "update"
256
- : "install";
257
- const suffix = `--scope ${options.scope} --target ${options.target}${global ? "" : ` --root ${JSON.stringify(options.root)}`}`;
258
- const installCommand = global
259
- ? `bun add --global --trust @ast-bro/cli dprint @mwillbanks/ast-mcp && ast-mcp install ${suffix}`
260
- : `bun add --dev @mwillbanks/ast-mcp && bun pm trust @ast-bro/cli dprint && ./node_modules/.bin/ast-mcp install ${suffix}`;
261
- const updateCommand = global
262
- ? `ast-mcp update ${suffix}`
263
- : `./node_modules/.bin/ast-mcp update ${suffix}`;
264
- const uninstallCommand = global
265
- ? `ast-mcp uninstall ${suffix}`
266
- : `./node_modules/.bin/ast-mcp uninstall ${suffix}`;
457
+ const operation = installOperation(checks);
458
+ const commands = installCommands(options, global);
267
459
  return {
268
460
  checks,
269
- installCommand,
461
+ installCommand: commands.installCommand,
270
462
  installed,
271
463
  needsUpdate: operation === "update",
272
464
  operation,
273
465
  recommendedCommand:
274
466
  operation === "update"
275
- ? updateCommand
467
+ ? commands.updateCommand
276
468
  : operation === "install"
277
- ? installCommand
469
+ ? commands.installCommand
278
470
  : undefined,
279
- uninstallCommand,
280
- updateCommand,
471
+ uninstallCommand: commands.uninstallCommand,
472
+ updateCommand: commands.updateCommand,
281
473
  ...options,
282
474
  };
283
475
  }