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.
- package/README.md +40 -421
- package/SECURITY.md +39 -0
- package/assets/agent-dir-banner.svg +38 -0
- package/dist/bin/agent-dir.js +9 -7
- package/dist/src/auth.js +3 -1
- package/dist/src/codegraph.d.ts +1 -0
- package/dist/src/codegraph.js +12 -0
- package/dist/src/config.js +0 -2
- package/dist/src/logging.d.ts +1 -1
- package/dist/src/logging.js +9 -69
- package/dist/src/mcp.d.ts +2 -1
- package/dist/src/mcp.js +191 -653
- package/dist/src/server.d.ts +2 -2
- package/dist/src/server.js +45 -146
- package/dist/src/telemetry/privacy.js +2 -0
- package/dist/src/telemetry/types.d.ts +2 -0
- package/dist/src/tools/code.d.ts +0 -12
- package/dist/src/tools/code.js +9 -29
- package/dist/src/tools/diagnostics.js +3 -1
- package/dist/src/tools/files.d.ts +2 -21
- package/dist/src/tools/files.js +85 -70
- package/dist/src/tools/git.d.ts +0 -7
- package/dist/src/tools/git.js +0 -64
- package/dist/src/tools/metadata.d.ts +0 -1
- package/dist/src/tools/metadata.js +0 -22
- package/dist/src/tools/skills.d.ts +1 -0
- package/dist/src/tools/skills.js +65 -0
- package/dist/src/types.d.ts +1 -2
- package/docs/CONFIGURATION.md +154 -0
- package/docs/MCP.md +106 -0
- package/docs/RELEASING.md +204 -0
- package/docs/telemetry.md +109 -0
- package/package.json +4 -1
package/dist/bin/agent-dir.js
CHANGED
|
@@ -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
|
-
|
|
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({
|
|
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",
|
package/dist/src/codegraph.d.ts
CHANGED
|
@@ -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;
|
package/dist/src/codegraph.js
CHANGED
|
@@ -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")
|
package/dist/src/config.js
CHANGED
package/dist/src/logging.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare function printBanner(options: {
|
|
|
11
11
|
npmScripts?: string[];
|
|
12
12
|
commands?: string[];
|
|
13
13
|
blacklistedCommands?: string[];
|
|
14
|
-
|
|
14
|
+
codeGraph?: boolean;
|
|
15
15
|
}): void;
|
|
16
16
|
export declare function printRequestLog(entry: RequestLog): void;
|
|
17
17
|
export declare function logRequest(entry: RequestLog): void;
|
package/dist/src/logging.js
CHANGED
|
@@ -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("
|
|
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("
|
|
199
|
-
writeLine(` ${color(toolLabel("
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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
|
-
|
|
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 {};
|