@sdsrs/code-graph 0.5.30 → 0.5.32
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/claude-plugin/.mcp.json
CHANGED
|
@@ -8,6 +8,23 @@ const os = require('os');
|
|
|
8
8
|
const { CACHE_DIR, PLUGIN_ID, MARKETPLACE_NAME, readManifest, readJson, writeJsonAtomic } = require('./lifecycle');
|
|
9
9
|
const { clearCache: clearBinaryCache } = require('./find-binary');
|
|
10
10
|
|
|
11
|
+
// ── Environment Checks ────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Check if a command-line tool is available on the system PATH.
|
|
15
|
+
* @param {string} cmd - Command name (e.g., 'curl', 'tar')
|
|
16
|
+
* @returns {boolean}
|
|
17
|
+
*/
|
|
18
|
+
function commandExists(cmd) {
|
|
19
|
+
try {
|
|
20
|
+
const whichCmd = process.platform === 'win32' ? 'where' : 'which';
|
|
21
|
+
execFileSync(whichCmd, [cmd], { stdio: 'ignore' });
|
|
22
|
+
return true;
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
11
28
|
// ── Configuration ──────────────────────────────────────────
|
|
12
29
|
const GITHUB_REPO = 'sdsrss/code-graph-mcp';
|
|
13
30
|
const STATE_FILE = path.join(CACHE_DIR, 'update-state.json');
|
|
@@ -207,6 +224,13 @@ function promoteVerifiedBinary(binaryTmp, binaryDst, expectedVersion) {
|
|
|
207
224
|
// ── Download & Install ─────────────────────────────────────
|
|
208
225
|
|
|
209
226
|
async function downloadAndInstall(latest) {
|
|
227
|
+
// Pre-flight: check required CLI tools before attempting any download
|
|
228
|
+
const missingTools = ['curl', 'tar'].filter(cmd => !commandExists(cmd));
|
|
229
|
+
if (missingTools.length > 0) {
|
|
230
|
+
console.error(`[code-graph] Auto-update skipped: missing required tools: ${missingTools.join(', ')}. Install them to enable auto-updates.`);
|
|
231
|
+
return { pluginUpdated: false, binaryUpdated: false };
|
|
232
|
+
}
|
|
233
|
+
|
|
210
234
|
const tmpDir = path.join(os.tmpdir(), `code-graph-update-${Date.now()}`);
|
|
211
235
|
let pluginUpdated = false;
|
|
212
236
|
let binaryUpdated = false;
|
|
@@ -273,13 +297,15 @@ async function downloadAndInstall(latest) {
|
|
|
273
297
|
if (promoteVerifiedBinary(binaryTmp, binaryDst, latest.version)) {
|
|
274
298
|
binaryUpdated = true;
|
|
275
299
|
}
|
|
276
|
-
} catch {
|
|
300
|
+
} catch (e) {
|
|
277
301
|
// Binary download failed — plugin update still counts as success
|
|
302
|
+
console.error(`[code-graph] Binary download failed: ${e.message}`);
|
|
278
303
|
}
|
|
279
304
|
}
|
|
280
305
|
|
|
281
306
|
return { pluginUpdated, binaryUpdated };
|
|
282
|
-
} catch {
|
|
307
|
+
} catch (e) {
|
|
308
|
+
console.error(`[code-graph] Plugin download/extract failed: ${e.message}`);
|
|
283
309
|
return { pluginUpdated: false, binaryUpdated: false };
|
|
284
310
|
} finally {
|
|
285
311
|
try { fs.rmSync(tmpDir, { recursive: true, force: true }); } catch { /* ok */ }
|
|
@@ -354,7 +380,7 @@ async function checkForUpdate() {
|
|
|
354
380
|
}
|
|
355
381
|
|
|
356
382
|
module.exports = {
|
|
357
|
-
checkForUpdate, isDevMode, readState, compareVersions,
|
|
383
|
+
checkForUpdate, commandExists, isDevMode, readState, compareVersions,
|
|
358
384
|
getExtractedPluginVersion, readBinaryVersion, promoteVerifiedBinary, isSilentMode,
|
|
359
385
|
requestJson, parseLatestRelease, fetchLatestRelease,
|
|
360
386
|
};
|
|
@@ -6,6 +6,7 @@ const os = require('os');
|
|
|
6
6
|
const path = require('path');
|
|
7
7
|
|
|
8
8
|
const {
|
|
9
|
+
commandExists,
|
|
9
10
|
fetchLatestRelease,
|
|
10
11
|
getExtractedPluginVersion,
|
|
11
12
|
parseLatestRelease,
|
|
@@ -80,6 +81,16 @@ test('parseLatestRelease selects the matching platform asset', () => {
|
|
|
80
81
|
});
|
|
81
82
|
});
|
|
82
83
|
|
|
84
|
+
// ── commandExists ──────────────────────────────────────────
|
|
85
|
+
|
|
86
|
+
test('commandExists returns true for a known command (node)', () => {
|
|
87
|
+
assert.equal(commandExists('node'), true);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('commandExists returns false for a non-existent command', () => {
|
|
91
|
+
assert.equal(commandExists('__nonexistent_cmd_xyz_12345__'), false);
|
|
92
|
+
});
|
|
93
|
+
|
|
83
94
|
test('fetchLatestRelease parses JSON without relying on global fetch', async () => {
|
|
84
95
|
const latest = await fetchLatestRelease(async () => ({
|
|
85
96
|
statusCode: 200,
|
|
@@ -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
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdsrs/code-graph",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.32",
|
|
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.
|
|
37
|
-
"@sdsrs/code-graph-linux-arm64": "0.5.
|
|
38
|
-
"@sdsrs/code-graph-darwin-x64": "0.5.
|
|
39
|
-
"@sdsrs/code-graph-darwin-arm64": "0.5.
|
|
40
|
-
"@sdsrs/code-graph-win32-x64": "0.5.
|
|
36
|
+
"@sdsrs/code-graph-linux-x64": "0.5.32",
|
|
37
|
+
"@sdsrs/code-graph-linux-arm64": "0.5.32",
|
|
38
|
+
"@sdsrs/code-graph-darwin-x64": "0.5.32",
|
|
39
|
+
"@sdsrs/code-graph-darwin-arm64": "0.5.32",
|
|
40
|
+
"@sdsrs/code-graph-win32-x64": "0.5.32"
|
|
41
41
|
}
|
|
42
42
|
}
|