agent-dir 0.5.0 β†’ 1.1.0

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.
@@ -5,6 +5,7 @@ import { createRequire } from "node:module";
5
5
  import { resolve } from "node:path";
6
6
  import { createInterface } from "node:readline/promises";
7
7
  import { parseArgs } from "node:util";
8
+ import { CodeGraphIntegration } from "../src/codegraph.js";
8
9
  import { configPath, loadConfig, mergeProfile, saveConfig } from "../src/config.js";
9
10
  import { printBanner, printHelp, printRequestHeader } from "../src/logging.js";
10
11
  import { startServer } from "../src/server.js";
@@ -51,7 +52,6 @@ const { values, positionals } = parseArgs({
51
52
  command: { type: "string" },
52
53
  blacklist: { type: "string" },
53
54
  token: { type: "string" },
54
- git: { type: "boolean" },
55
55
  rotate: { type: "boolean" },
56
56
  "no-tunnel": { type: "boolean" },
57
57
  random: { type: "boolean" },
@@ -344,8 +344,6 @@ if (command === "config") {
344
344
  const blacklist = parseList(values.blacklist);
345
345
  if (blacklist !== undefined)
346
346
  profile.blacklistedCommands = blacklist;
347
- if (values.git !== undefined)
348
- profile.git = values.git;
349
347
  if (profile.tunnel === "wormhole" && !profile.subdomain && !values.random) {
350
348
  fail("Wormhole profiles require --subdomain <name>, or use --random.");
351
349
  }
@@ -411,8 +409,6 @@ if (commands !== undefined)
411
409
  overrides.commands = commands;
412
410
  if (blacklist !== undefined)
413
411
  overrides.blacklistedCommands = blacklist;
414
- if (values.git !== undefined)
415
- overrides.git = values.git;
416
412
  const commandConfig = mergeProfile(profile ?? { directory, port, tunnel }, overrides);
417
413
  const telemetryConfigId = profile
418
414
  ? command
@@ -427,7 +423,6 @@ const telemetryConfigId = profile
427
423
  npm: commandConfig.npm?.allowedScripts ?? [],
428
424
  commands: commandConfig.commands ?? [],
429
425
  blacklistedCommands: commandConfig.blacklistedCommands ?? [],
430
- git: commandConfig.git ?? commandConfig.commands?.includes("git") ?? false,
431
426
  }))
432
427
  .digest("hex")
433
428
  .slice(0, 12);
@@ -451,7 +446,10 @@ if (allowedCommands)
451
446
  if (commandConfig.blacklistedCommands?.length) {
452
447
  bannerOptions.blacklistedCommands = commandConfig.blacklistedCommands;
453
448
  }
454
- bannerOptions.gitEnabled = commandConfig.git ?? commandConfig.commands?.includes("git") ?? false;
449
+ const codeGraph = new CodeGraphIntegration(directory);
450
+ const codeGraphCapability = await codeGraph.prepare();
451
+ if (codeGraphCapability.tool)
452
+ bannerOptions.codeGraph = true;
455
453
  printBanner(bannerOptions);
456
454
  const telemetrySessionId = randomUUID();
457
455
  const server = await startServer({
@@ -459,12 +457,16 @@ const server = await startServer({
459
457
  port,
460
458
  token,
461
459
  commandConfig,
460
+ codeGraph,
462
461
  telemetry: {
463
462
  ...(config.telemetry ?? { level: "none" }),
464
463
  ...(telemetryConfigId ? { configId: telemetryConfigId } : {}),
465
464
  sessionId: telemetrySessionId,
466
465
  persist: true,
467
466
  },
467
+ }).catch(async (error) => {
468
+ await codeGraph.close();
469
+ throw error;
468
470
  });
469
471
  let tunnelResult;
470
472
  console.log(" βœ“ SERVER ONLINE");
package/dist/src/auth.js CHANGED
@@ -14,7 +14,9 @@ function secureCompare(left, right) {
14
14
  return timingSafeEqual(leftHash, rightHash);
15
15
  }
16
16
  export function unauthorized() {
17
- return new Response(JSON.stringify({ error: "Unauthorized" }), {
17
+ return new Response(JSON.stringify({
18
+ error: "Unauthorized: provide a valid Authorization: Bearer <token> header.",
19
+ }), {
18
20
  status: 401,
19
21
  headers: {
20
22
  "content-type": "application/json; charset=utf-8",
@@ -18,6 +18,7 @@ export declare class CodeGraphIntegration {
18
18
  private readonly pending;
19
19
  constructor(root: string);
20
20
  capability(): Promise<CodeGraphCapability>;
21
+ prepare(): Promise<CodeGraphCapability>;
21
22
  explore(query: string, maxFiles?: number): Promise<Record<string, unknown>>;
22
23
  close(): Promise<void>;
23
24
  private detect;
@@ -27,6 +27,18 @@ export class CodeGraphIntegration {
27
27
  this.capabilityPromise = this.detect();
28
28
  return this.capabilityPromise;
29
29
  }
30
+ async prepare() {
31
+ const capability = await this.capability();
32
+ if (capability.status === "available") {
33
+ try {
34
+ await this.ensureStarted();
35
+ }
36
+ catch {
37
+ // Keep Agent Dir startup available even if CodeGraph fails to start.
38
+ }
39
+ }
40
+ return this.capability();
41
+ }
30
42
  async explore(query, maxFiles) {
31
43
  const capability = await this.capability();
32
44
  if (capability.status === "not_installed")
@@ -117,7 +117,5 @@ function isProfile(value) {
117
117
  profile.blacklistedCommands.some((item) => typeof item !== "string"))
118
118
  return false;
119
119
  }
120
- if (profile.git !== undefined && typeof profile.git !== "boolean")
121
- return false;
122
120
  return true;
123
121
  }
@@ -11,7 +11,7 @@ export declare function printBanner(options: {
11
11
  npmScripts?: string[];
12
12
  commands?: string[];
13
13
  blacklistedCommands?: string[];
14
- gitEnabled?: boolean;
14
+ codeGraph?: boolean;
15
15
  }): void;
16
16
  export declare function printRequestLog(entry: RequestLog): void;
17
17
  export declare function logRequest(entry: RequestLog): void;
@@ -9,53 +9,24 @@ const BRIGHT_BLUE = "\x1b[94m";
9
9
  const BRIGHT_CYAN = "\x1b[96m";
10
10
  const BRIGHT_MAGENTA = "\x1b[95m";
11
11
  const BRIGHT_YELLOW = "\x1b[93m";
12
- const BRIGHT_RED = "\x1b[91m";
13
- const BRIGHT_GREEN = "\x1b[92m";
14
12
  const writeLine = (line = "") => {
15
13
  process.stdout.write(`${line}\r\n`);
16
14
  };
17
15
  const color = (value, code) => `${code}${value}${RESET}`;
18
16
  const TOOL_ICONS = {
19
- list_files: "πŸ“‚",
20
- list_dirs: "πŸ—‚οΈ",
21
17
  read_range: "πŸ“",
22
- read_files: "πŸ“š",
23
- write_files: "πŸ“",
24
- patch_files: "🧩",
25
- delete_files: "πŸ—‘οΈ",
26
18
  run_npm_batch: "πŸ”§",
27
19
  run_command_batch: "πŸ› οΈ",
28
- search_files: "πŸ”Ž",
29
20
  find_files: "🧭",
30
21
  search_code: "🧠",
31
22
  find_symbol: "πŸ”Ή",
32
- find_definition: "🎯",
33
23
  find_references: "πŸ”—",
34
- find_imports: "β†ͺ",
35
- find_exports: "β†—",
36
- git_status: "🌿",
37
- git_stage: "βž•",
38
- git_unstage: "βž–",
39
- git_commit: "●",
40
- git_restore: "↩",
41
- git_push: "⬆",
42
- git_diff: "πŸ“",
43
- git_log: "πŸ“œ",
44
- project_overview: "πŸ—ΊοΈ",
45
- package_info: "πŸ“¦",
46
- allowed_commands: "πŸ”",
47
24
  file_info: "ℹ️",
48
- diagnostics: "🩺",
49
25
  project_context: "🧭",
50
- inspect: "πŸ”Ž",
51
- locate: "🎯",
52
- read_relevant: "🎯",
53
- git_changes: "πŸ“‹",
54
26
  apply_changes: "✏️",
55
27
  validate: "βœ“",
56
28
  };
57
29
  const MCP_METHOD_ICONS = {
58
- initialize: "πŸš€",
59
30
  "notifications/initialized": "βœ“",
60
31
  "notifications/cancelled": "βœ–",
61
32
  "notifications/progress": "⏳",
@@ -80,19 +51,8 @@ const MCP_METHOD_ICONS = {
80
51
  const TOOL_NAME_WIDTH = Math.max(...Object.keys(TOOL_ICONS).map((name) => name.length));
81
52
  const MCP_METHOD_NAME_WIDTH = Math.max(...Object.keys(MCP_METHOD_ICONS).map((name) => name.length));
82
53
  const TOOL_COLORS = {
83
- list_files: CYAN,
84
- list_dirs: BRIGHT_CYAN,
85
- read_files: BRIGHT_GREEN,
86
- write_files: BRIGHT_YELLOW,
87
- patch_files: BRIGHT_MAGENTA,
88
- delete_files: BRIGHT_RED,
89
54
  run_npm_batch: BRIGHT_BLUE,
90
55
  run_command_batch: BRIGHT_CYAN,
91
- git_stage: YELLOW,
92
- git_unstage: MAGENTA,
93
- git_commit: BRIGHT_GREEN,
94
- git_restore: RED,
95
- git_push: BRIGHT_BLUE,
96
56
  };
97
57
  const NARROW_TOOL_ICONS = new Set(["✎", "βœ–", "βš™", "⌘", "β†ͺ", "β†—"]);
98
58
  const TOOL_ICON_SLOT_WIDTH = 3;
@@ -126,8 +86,6 @@ export function printHelp() {
126
86
  writeLine(" --npm <scripts> Comma-separated allowed npm scripts");
127
87
  writeLine(" --command <commands> Comma-separated allowed commands");
128
88
  writeLine(" --blacklist <commands> Comma-separated blocked command prefixes");
129
- writeLine(" --git Enable dedicated Git MCP tools");
130
- writeLine(" --no-git Disable dedicated Git MCP tools");
131
89
  writeLine(" --token <token> Explicit Bearer token");
132
90
  writeLine(" --no-tunnel Disable tunneling");
133
91
  writeLine(" --random Use a random Wormhole URL (no subdomain)");
@@ -180,38 +138,20 @@ export function printBanner(options) {
180
138
  writeLine(` ${color("⚑ /mcp", CYAN)}`);
181
139
  writeLine("");
182
140
  writeLine(" TOOLS");
183
- writeLine(` ${color(toolLabel("list_files"), CYAN)}`);
184
- writeLine(` ${color(toolLabel("list_dirs"), BRIGHT_CYAN)}`);
185
- writeLine(` ${color(toolLabel("read_range"), GREEN)}`);
186
- writeLine(` ${color(toolLabel("read_files"), BRIGHT_GREEN)}`);
187
- writeLine(` ${color(toolLabel("write_files"), BRIGHT_YELLOW)}`);
188
- writeLine(` ${color(toolLabel("patch_files"), BRIGHT_MAGENTA)}`);
189
- writeLine(` ${color(toolLabel("delete_files"), BRIGHT_RED)}`);
190
- writeLine(` ${color(toolLabel("run_npm_batch"), BRIGHT_BLUE)}`);
191
- writeLine(` ${color(toolLabel("run_command_batch"), BRIGHT_CYAN)}`);
192
- writeLine(` ${color(toolLabel("search_files"), CYAN)}`);
141
+ writeLine(` ${color(toolLabel("project_context"), BRIGHT_CYAN)}`);
193
142
  writeLine(` ${color(toolLabel("find_files"), CYAN)}`);
194
143
  writeLine(` ${color(toolLabel("search_code"), BRIGHT_CYAN)}`);
195
144
  writeLine(` ${color(toolLabel("find_symbol"), GREEN)}`);
196
- writeLine(` ${color(toolLabel("find_definition"), GREEN)}`);
197
145
  writeLine(` ${color(toolLabel("find_references"), GREEN)}`);
198
- writeLine(` ${color(toolLabel("find_imports"), BRIGHT_GREEN)}`);
199
- writeLine(` ${color(toolLabel("find_exports"), BRIGHT_GREEN)}`);
200
- if (options.gitEnabled) {
201
- writeLine(` ${color(toolLabel("git_status"), CYAN)}`);
202
- writeLine(` ${color(toolLabel("git_stage"), YELLOW)}`);
203
- writeLine(` ${color(toolLabel("git_unstage"), MAGENTA)}`);
204
- writeLine(` ${color(toolLabel("git_commit"), BRIGHT_GREEN)}`);
205
- writeLine(` ${color(toolLabel("git_restore"), RED)}`);
206
- writeLine(` ${color(toolLabel("git_push"), BRIGHT_BLUE)}`);
207
- writeLine(` ${color(toolLabel("git_diff"), CYAN)}`);
208
- writeLine(` ${color(toolLabel("git_log"), CYAN)}`);
209
- }
210
- writeLine(` ${color(toolLabel("project_overview"), BRIGHT_CYAN)}`);
211
- writeLine(` ${color(toolLabel("package_info"), YELLOW)}`);
212
- writeLine(` ${color(toolLabel("allowed_commands"), YELLOW)}`);
146
+ writeLine(` ${color(toolLabel("read_range"), GREEN)}`);
147
+ writeLine(` ${color(toolLabel("apply_changes"), BRIGHT_MAGENTA)}`);
148
+ writeLine(` ${color(toolLabel("validate"), BRIGHT_YELLOW)}`);
149
+ writeLine(` ${color(toolLabel("run_npm_batch"), BRIGHT_BLUE)}`);
150
+ writeLine(` ${color(toolLabel("run_command_batch"), BRIGHT_CYAN)}`);
213
151
  writeLine(` ${color(toolLabel("file_info"), YELLOW)}`);
214
- writeLine(` ${color(toolLabel("diagnostics"), BRIGHT_YELLOW)}`);
152
+ if (options.codeGraph) {
153
+ writeLine(` ${color(toolLabel("codegraph_explore"), BRIGHT_MAGENTA)}`);
154
+ }
215
155
  writeLine("");
216
156
  if (options.npmScripts?.length) {
217
157
  writeLine(" NPM COMMANDS");
package/dist/src/mcp.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { CodeGraphIntegration } from "./codegraph.js";
1
2
  import { TelemetryRecorder } from "./telemetry/recorder.js";
2
3
  import type { TelemetryConfig } from "./telemetry/types.js";
3
4
  import type { CommandConfig } from "./types.js";
@@ -6,6 +7,6 @@ interface McpHandler {
6
7
  closeSubscriptions: () => void;
7
8
  telemetrySnapshot: () => ReturnType<TelemetryRecorder["snapshot"]>;
8
9
  }
9
- export declare function createMcpHandler(root: string, commandConfig?: CommandConfig, telemetry?: TelemetryConfig): McpHandler;
10
+ export declare function createMcpHandler(root: string, commandConfig?: CommandConfig, telemetry?: TelemetryConfig, codeGraphIntegration?: CodeGraphIntegration): McpHandler;
10
11
  export declare function validateMcpParamHeaders(inputSchema: Record<string, unknown>, args: Record<string, unknown>, headers: Headers): string | undefined;
11
12
  export {};