@sdsrs/code-graph 0.5.29 → 0.5.31

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.
@@ -4,7 +4,7 @@
4
4
  "author": {
5
5
  "name": "sdsrs"
6
6
  },
7
- "version": "0.5.29",
7
+ "version": "0.5.31",
8
8
  "keywords": [
9
9
  "code-graph",
10
10
  "ast",
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "mcpServers": {
3
3
  "code-graph": {
4
- "command": "code-graph-mcp",
5
- "args": ["serve"],
4
+ "command": "node",
5
+ "args": ["${CLAUDE_PLUGIN_ROOT}/scripts/mcp-launcher.js"],
6
6
  "env": {}
7
7
  }
8
8
  }
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /**
4
+ * MCP server launcher — resolves binary via find-binary.js, auto-installs
5
+ * if missing, then spawns with stdio forwarding for JSON-RPC.
6
+ *
7
+ * Used by .mcp.json so the plugin controls binary discovery instead of
8
+ * relying on the binary being in PATH.
9
+ */
10
+ const { spawn, execFileSync } = require('child_process');
11
+ const path = require('path');
12
+ const fs = require('fs');
13
+
14
+ // Set plugin root so find-binary.js can locate bundled/dev binaries
15
+ process.env._FIND_BINARY_ROOT = process.env.CLAUDE_PLUGIN_ROOT || path.resolve(__dirname, '..');
16
+
17
+ const { findBinary, clearCache } = require('./find-binary');
18
+
19
+ let binary = findBinary();
20
+
21
+ // Auto-install binary if not found (first-time install)
22
+ if (!binary) {
23
+ let version = 'latest';
24
+ try {
25
+ const pj = path.join(__dirname, '..', '.claude-plugin', 'plugin.json');
26
+ version = JSON.parse(fs.readFileSync(pj, 'utf8')).version || 'latest';
27
+ } catch { /* use latest */ }
28
+
29
+ process.stderr.write(`[code-graph] Binary not found, installing @sdsrs/code-graph@${version}...\n`);
30
+ try {
31
+ execFileSync('npm', ['install', '-g', `@sdsrs/code-graph@${version}`], {
32
+ timeout: 60000, stdio: 'pipe',
33
+ });
34
+ clearCache();
35
+ binary = findBinary();
36
+ if (binary) {
37
+ process.stderr.write(`[code-graph] Installed at ${binary}\n`);
38
+ }
39
+ } catch {
40
+ process.stderr.write('[code-graph] npm install failed. Trying direct download...\n');
41
+ }
42
+
43
+ // Fallback: direct binary download from GitHub release
44
+ if (!binary) {
45
+ try {
46
+ const { downloadBinarySync } = require('./auto-update');
47
+ if (typeof downloadBinarySync === 'function') {
48
+ downloadBinarySync(version);
49
+ clearCache();
50
+ binary = findBinary();
51
+ }
52
+ } catch { /* not available */ }
53
+ }
54
+ }
55
+
56
+ if (!binary) {
57
+ process.stderr.write(
58
+ '[code-graph] Binary not found. Install manually:\n' +
59
+ ' npm install -g @sdsrs/code-graph\n'
60
+ );
61
+ process.exit(1);
62
+ }
63
+
64
+ // Spawn binary with stdio inheritance for MCP JSON-RPC
65
+ const child = spawn(binary, ['serve'], {
66
+ stdio: 'inherit',
67
+ env: process.env,
68
+ });
69
+
70
+ child.on('error', (err) => {
71
+ process.stderr.write(`[code-graph] Failed to start: ${err.message}\n`);
72
+ process.exit(1);
73
+ });
74
+
75
+ child.on('exit', (code, signal) => {
76
+ if (signal) {
77
+ process.kill(process.pid, signal);
78
+ } else {
79
+ process.exit(code ?? 1);
80
+ }
81
+ });
@@ -7,7 +7,9 @@
7
7
  */
8
8
  const { execFileSync } = require('child_process');
9
9
  const path = require('path');
10
- const { cleanupDisabledStatusline, readRegistry } = require('./lifecycle');
10
+ const lifecycle = require('./lifecycle');
11
+ const { readRegistry } = lifecycle;
12
+ const cleanupDisabledStatusline = lifecycle.cleanupDisabledStatusline || (() => ({ cleaned: false }));
11
13
 
12
14
  const SEPARATOR = ' \x1b[2m|\x1b[0m ';
13
15
 
@@ -4,7 +4,8 @@ const { execFileSync } = require('child_process');
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
6
  const { findBinary } = require('./find-binary');
7
- const { cleanupDisabledStatusline } = require('./lifecycle');
7
+ const lifecycle = require('./lifecycle');
8
+ const cleanupDisabledStatusline = lifecycle.cleanupDisabledStatusline || (() => ({ cleaned: false }));
8
9
 
9
10
  const disabledCleanup = cleanupDisabledStatusline();
10
11
  if (disabledCleanup.cleaned) process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdsrs/code-graph",
3
- "version": "0.5.29",
3
+ "version": "0.5.31",
4
4
  "description": "MCP server that indexes codebases into an AST knowledge graph with semantic search, call graph traversal, and HTTP route tracing",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -33,10 +33,10 @@
33
33
  "node": ">=16"
34
34
  },
35
35
  "optionalDependencies": {
36
- "@sdsrs/code-graph-linux-x64": "0.5.29",
37
- "@sdsrs/code-graph-linux-arm64": "0.5.29",
38
- "@sdsrs/code-graph-darwin-x64": "0.5.29",
39
- "@sdsrs/code-graph-darwin-arm64": "0.5.29",
40
- "@sdsrs/code-graph-win32-x64": "0.5.29"
36
+ "@sdsrs/code-graph-linux-x64": "0.5.31",
37
+ "@sdsrs/code-graph-linux-arm64": "0.5.31",
38
+ "@sdsrs/code-graph-darwin-x64": "0.5.31",
39
+ "@sdsrs/code-graph-darwin-arm64": "0.5.31",
40
+ "@sdsrs/code-graph-win32-x64": "0.5.31"
41
41
  }
42
42
  }