code-graph-builder 0.9.0 → 0.12.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/bin/cli.mjs +66 -39
- package/package.json +1 -1
package/bin/cli.mjs
CHANGED
|
@@ -351,31 +351,32 @@ async function runSetup() {
|
|
|
351
351
|
// Timeout after 15s
|
|
352
352
|
const timer = setTimeout(() => finish(false, "Server did not respond within 15s"), 15000);
|
|
353
353
|
|
|
354
|
+
child.stderr.on("data", () => {}); // Suppress server logs
|
|
355
|
+
|
|
354
356
|
child.stdout.on("data", (chunk) => {
|
|
355
357
|
stdout += chunk.toString();
|
|
356
|
-
//
|
|
358
|
+
// MCP stdio uses JSON lines (one JSON-RPC message per line)
|
|
357
359
|
const lines = stdout.split("\n");
|
|
358
360
|
for (const line of lines) {
|
|
359
|
-
|
|
360
|
-
if (
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}
|
|
361
|
+
const trimmed = line.trim();
|
|
362
|
+
if (!trimmed || !trimmed.startsWith("{")) continue;
|
|
363
|
+
try {
|
|
364
|
+
const msg = JSON.parse(trimmed);
|
|
365
|
+
if (msg.result && msg.result.capabilities) {
|
|
366
|
+
// Got initialize response, now request tools/list
|
|
367
|
+
const toolsReq = JSON.stringify({
|
|
368
|
+
jsonrpc: "2.0", id: 2, method: "tools/list", params: {},
|
|
369
|
+
});
|
|
370
|
+
child.stdin.write(toolsReq + "\n");
|
|
371
|
+
stdout = "";
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (msg.result && msg.result.tools) {
|
|
375
|
+
clearTimeout(timer);
|
|
376
|
+
finish(true, `${msg.result.tools.length} tools available`);
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
} catch { /* partial JSON, wait for more */ }
|
|
379
380
|
}
|
|
380
381
|
});
|
|
381
382
|
|
|
@@ -389,7 +390,7 @@ async function runSetup() {
|
|
|
389
390
|
if (!resolved) finish(false, `Server exited with code ${code}`);
|
|
390
391
|
});
|
|
391
392
|
|
|
392
|
-
// Send MCP initialize request
|
|
393
|
+
// Send MCP initialize request as JSON line
|
|
393
394
|
const initReq = JSON.stringify({
|
|
394
395
|
jsonrpc: "2.0",
|
|
395
396
|
id: 1,
|
|
@@ -400,8 +401,7 @@ async function runSetup() {
|
|
|
400
401
|
clientInfo: { name: "setup-verify", version: "1.0.0" },
|
|
401
402
|
},
|
|
402
403
|
});
|
|
403
|
-
|
|
404
|
-
child.stdin.write(header + initReq);
|
|
404
|
+
child.stdin.write(initReq + "\n");
|
|
405
405
|
});
|
|
406
406
|
|
|
407
407
|
if (verified.success) {
|
|
@@ -411,21 +411,48 @@ async function runSetup() {
|
|
|
411
411
|
log(" The server may still work — try: npx code-graph-builder --server");
|
|
412
412
|
}
|
|
413
413
|
|
|
414
|
+
// Step 4: Auto-register in Claude Code if available
|
|
414
415
|
log("");
|
|
415
|
-
log("──
|
|
416
|
-
log("");
|
|
417
|
-
log(" Add to your MCP client config:");
|
|
416
|
+
log("── Registering MCP server ─────────────────────────────────");
|
|
418
417
|
log("");
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
418
|
+
|
|
419
|
+
if (commandExists("claude")) {
|
|
420
|
+
try {
|
|
421
|
+
// Remove existing entry first (ignore errors if not found)
|
|
422
|
+
try {
|
|
423
|
+
execSync("claude mcp remove code-graph-builder", { stdio: "pipe", shell: true });
|
|
424
|
+
} catch { /* not found, fine */ }
|
|
425
|
+
|
|
426
|
+
const addCmd = IS_WIN
|
|
427
|
+
? 'claude mcp add --scope user --transport stdio code-graph-builder -- cmd /c npx -y code-graph-builder@latest --server'
|
|
428
|
+
: 'claude mcp add --scope user --transport stdio code-graph-builder -- npx -y code-graph-builder@latest --server';
|
|
429
|
+
|
|
430
|
+
execSync(addCmd, { stdio: "pipe", shell: true });
|
|
431
|
+
log(" ✓ Registered in Claude Code (global): code-graph-builder");
|
|
432
|
+
} catch (err) {
|
|
433
|
+
log(" ⚠ Failed to register in Claude Code automatically");
|
|
434
|
+
log(" Run manually:");
|
|
435
|
+
if (IS_WIN) {
|
|
436
|
+
log(' claude mcp add --scope user --transport stdio code-graph-builder -- cmd /c npx -y code-graph-builder@latest --server');
|
|
437
|
+
} else {
|
|
438
|
+
log(' claude mcp add --scope user --transport stdio code-graph-builder -- npx -y code-graph-builder@latest --server');
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
} else {
|
|
442
|
+
log(" Claude Code CLI not found. Add manually to your MCP client config:");
|
|
443
|
+
log("");
|
|
444
|
+
log(' {');
|
|
445
|
+
log(' "mcpServers": {');
|
|
446
|
+
log(' "code-graph-builder": {');
|
|
447
|
+
log(' "command": "npx",');
|
|
448
|
+
log(' "args": ["-y", "code-graph-builder@latest", "--server"]');
|
|
449
|
+
log(" }");
|
|
450
|
+
log(" }");
|
|
451
|
+
log(" }");
|
|
452
|
+
}
|
|
453
|
+
|
|
427
454
|
log("");
|
|
428
|
-
log("
|
|
455
|
+
log("── Setup complete ─────────────────────────────────────────");
|
|
429
456
|
log("");
|
|
430
457
|
}
|
|
431
458
|
|
|
@@ -544,11 +571,11 @@ async function runUninstall() {
|
|
|
544
571
|
const hasWorkspace = existsSync(WORKSPACE_DIR);
|
|
545
572
|
const hasEnv = existsSync(ENV_FILE);
|
|
546
573
|
|
|
547
|
-
// Check Claude Code
|
|
574
|
+
// Check if code-graph-builder is registered in Claude Code
|
|
548
575
|
let hasClaudeConfig = false;
|
|
549
576
|
try {
|
|
550
|
-
execFileSync("claude", ["mcp", "list"], { stdio: "pipe" });
|
|
551
|
-
hasClaudeConfig =
|
|
577
|
+
const mcpList = execFileSync("claude", ["mcp", "list"], { stdio: "pipe" }).toString();
|
|
578
|
+
hasClaudeConfig = mcpList.includes("code-graph-builder");
|
|
552
579
|
} catch { /* claude CLI not available */ }
|
|
553
580
|
|
|
554
581
|
log(" The following will be removed:");
|