sdl-mcp-native 0.7.2 → 0.8.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.
Files changed (3) hide show
  1. package/index.d.ts +36 -20
  2. package/index.js +146 -146
  3. package/package.json +7 -7
package/index.d.ts CHANGED
@@ -3,6 +3,36 @@
3
3
 
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
+ export interface NativeClusterSymbol {
7
+ symbolId: string
8
+ }
9
+ export interface NativeClusterEdge {
10
+ fromSymbolId: string
11
+ toSymbolId: string
12
+ }
13
+ export interface NativeClusterAssignment {
14
+ symbolId: string
15
+ clusterId: string
16
+ membershipScore: number
17
+ }
18
+ export interface NativeProcessSymbol {
19
+ symbolId: string
20
+ name: string
21
+ }
22
+ export interface NativeProcessCallEdge {
23
+ callerId: string
24
+ calleeId: string
25
+ }
26
+ export interface NativeProcessStep {
27
+ symbolId: string
28
+ stepOrder: number
29
+ }
30
+ export interface NativeProcess {
31
+ processId: string
32
+ entrySymbolId: string
33
+ steps: Array<NativeProcessStep>
34
+ depth: number
35
+ }
6
36
  /** Input file descriptor passed from TypeScript to Rust. */
7
37
  export interface NativeFileInput {
8
38
  /** Relative path from repo root (forward slashes). */
@@ -48,6 +78,10 @@ export interface NativeParsedSymbol {
48
78
  invariantsJson: string
49
79
  /** JSON-encoded side-effects array. */
50
80
  sideEffectsJson: string
81
+ /** JSON-encoded role tags inferred from name/path heuristics. */
82
+ roleTagsJson: string
83
+ /** Search-oriented text including identifier splits, summary, tags, and path hints. */
84
+ searchText: string
51
85
  }
52
86
  /** Extracted import statement. */
53
87
  export interface NativeParsedImport {
@@ -95,26 +129,8 @@ export interface NativeParsedFile {
95
129
  /** Parse error message, if any. */
96
130
  parseError?: string
97
131
  }
98
- /**
99
- * Parse and extract symbols/imports/calls from a batch of files.
100
- *
101
- * This is the primary entry point called from TypeScript.
102
- * Uses Rayon for parallel processing across files.
103
- *
104
- * Returns NativeParsedFile[] with per-file results.
105
- */
106
132
  export declare function parseFiles(files: Array<NativeFileInput>, threadCount: number): Array<NativeParsedFile>
107
- /**
108
- * SHA-256 hash of a string, returned as lowercase hex.
109
- *
110
- * Exact parity with TypeScript `hashContent()` in `util/hashing.ts`.
111
- * Exported for cross-validation in parity tests.
112
- */
113
133
  export declare function hashContentNative(content: string): string
114
- /**
115
- * Generate a stable symbol ID.
116
- *
117
- * Exact parity with TypeScript `generateSymbolId()` in `util/hashing.ts`.
118
- * Exported for cross-validation in parity tests.
119
- */
120
134
  export declare function generateSymbolIdNative(repoId: string, relPath: string, kind: string, name: string, fingerprint: string): string
135
+ export declare function computeClusters(symbols: Array<NativeClusterSymbol>, edges: Array<NativeClusterEdge>, minClusterSize: number): Array<NativeClusterAssignment>
136
+ export declare function traceProcesses(symbols: Array<NativeProcessSymbol>, callEdges: Array<NativeProcessCallEdge>, maxDepth: number, entryPatterns: Array<string>): Array<NativeProcess>
package/index.js CHANGED
@@ -1,146 +1,146 @@
1
- /* eslint-disable */
2
-
3
- /**
4
- * Platform-detection loader for sdl-mcp-native.
5
- *
6
- * Standard napi-rs pattern: detects process.platform/process.arch and loads
7
- * the correct prebuilt binary from per-platform npm packages.
8
- */
9
-
10
- const { existsSync, readFileSync } = require("fs");
11
- const { join } = require("path");
12
-
13
- /**
14
- * Determine the platform package name based on current OS/arch/libc.
15
- * @returns {string | null}
16
- */
17
- function getPackageName() {
18
- const platform = process.platform;
19
- const arch = process.arch;
20
-
21
- if (platform === "win32" && arch === "x64") {
22
- return "sdl-mcp-native-win32-x64-msvc";
23
- }
24
- if (platform === "darwin" && arch === "x64") {
25
- return "sdl-mcp-native-darwin-x64";
26
- }
27
- if (platform === "darwin" && arch === "arm64") {
28
- return "sdl-mcp-native-darwin-arm64";
29
- }
30
- if (platform === "linux" && arch === "x64") {
31
- // Detect musl vs glibc
32
- if (isMusl()) {
33
- return "sdl-mcp-native-linux-x64-musl";
34
- }
35
- return "sdl-mcp-native-linux-x64-gnu";
36
- }
37
- if (platform === "linux" && arch === "arm64") {
38
- return "sdl-mcp-native-linux-arm64-gnu";
39
- }
40
-
41
- return null;
42
- }
43
-
44
- /**
45
- * Detect musl libc on Linux.
46
- * @returns {boolean}
47
- */
48
- function isMusl() {
49
- // Check if we're running on Alpine or musl-based distro
50
- try {
51
- const output = readFileSync("/usr/bin/ldd", "utf8");
52
- if (output.includes("musl")) return true;
53
- } catch {
54
- // ldd not readable
55
- }
56
-
57
- try {
58
- if (existsSync("/etc/alpine-release")) return true;
59
- } catch {
60
- // not alpine
61
- }
62
-
63
- // Check the dynamic linker
64
- try {
65
- const maps = readFileSync("/proc/self/maps", "utf8");
66
- if (maps.includes("musl")) return true;
67
- } catch {
68
- // /proc not available
69
- }
70
-
71
- return false;
72
- }
73
-
74
- /**
75
- * Map platform package names to their .node file suffix.
76
- */
77
- const PLATFORM_NODE_FILES = {
78
- "sdl-mcp-native-win32-x64-msvc": "sdl-mcp-native.win32-x64-msvc.node",
79
- "sdl-mcp-native-darwin-x64": "sdl-mcp-native.darwin-x64.node",
80
- "sdl-mcp-native-darwin-arm64": "sdl-mcp-native.darwin-arm64.node",
81
- "sdl-mcp-native-linux-x64-gnu": "sdl-mcp-native.linux-x64-gnu.node",
82
- "sdl-mcp-native-linux-x64-musl": "sdl-mcp-native.linux-x64-musl.node",
83
- "sdl-mcp-native-linux-arm64-gnu": "sdl-mcp-native.linux-arm64-gnu.node",
84
- };
85
-
86
- let nativeBinding = null;
87
- let loadError = null;
88
-
89
- const packageName = getPackageName();
90
-
91
- if (packageName) {
92
- const nodeFileName = PLATFORM_NODE_FILES[packageName];
93
-
94
- // 1. Try local platform-suffixed .node file (dev builds via napi artifacts)
95
- const localPlatformPath = join(__dirname, nodeFileName);
96
- if (existsSync(localPlatformPath)) {
97
- try {
98
- nativeBinding = require(localPlatformPath);
99
- } catch (e) {
100
- loadError = e;
101
- }
102
- }
103
-
104
- // 2. Try per-platform npm package
105
- if (!nativeBinding) {
106
- try {
107
- nativeBinding = require(packageName);
108
- } catch (e) {
109
- loadError = e;
110
- }
111
- }
112
-
113
- // 3. Try legacy local files (backward compat with dev builds)
114
- if (!nativeBinding) {
115
- const legacyPaths = [
116
- join(__dirname, "sdl-mcp-native.node"),
117
- join(__dirname, "index.node"),
118
- ];
119
- for (const p of legacyPaths) {
120
- if (existsSync(p)) {
121
- try {
122
- nativeBinding = require(p);
123
- break;
124
- } catch (e) {
125
- loadError = e;
126
- }
127
- }
128
- }
129
- }
130
- } else {
131
- loadError = new Error(
132
- `Unsupported platform: ${process.platform}-${process.arch}. ` +
133
- `sdl-mcp-native supports: win32-x64, darwin-x64, darwin-arm64, linux-x64, linux-arm64`
134
- );
135
- }
136
-
137
- if (!nativeBinding) {
138
- if (loadError) {
139
- throw loadError;
140
- }
141
- throw new Error("Failed to load sdl-mcp-native native binding");
142
- }
143
-
144
- module.exports.parseFiles = nativeBinding.parseFiles;
145
- module.exports.hashContentNative = nativeBinding.hashContentNative;
146
- module.exports.generateSymbolIdNative = nativeBinding.generateSymbolIdNative;
1
+ /* eslint-disable */
2
+
3
+ /**
4
+ * Platform-detection loader for sdl-mcp-native.
5
+ *
6
+ * Standard napi-rs pattern: detects process.platform/process.arch and loads
7
+ * the correct prebuilt binary from per-platform npm packages.
8
+ */
9
+
10
+ const { existsSync, readFileSync } = require("fs");
11
+ const { join } = require("path");
12
+
13
+ /**
14
+ * Determine the platform package name based on current OS/arch/libc.
15
+ * @returns {string | null}
16
+ */
17
+ function getPackageName() {
18
+ const platform = process.platform;
19
+ const arch = process.arch;
20
+
21
+ if (platform === "win32" && arch === "x64") {
22
+ return "sdl-mcp-native-win32-x64-msvc";
23
+ }
24
+ if (platform === "darwin" && arch === "x64") {
25
+ return "sdl-mcp-native-darwin-x64";
26
+ }
27
+ if (platform === "darwin" && arch === "arm64") {
28
+ return "sdl-mcp-native-darwin-arm64";
29
+ }
30
+ if (platform === "linux" && arch === "x64") {
31
+ // Detect musl vs glibc
32
+ if (isMusl()) {
33
+ return "sdl-mcp-native-linux-x64-musl";
34
+ }
35
+ return "sdl-mcp-native-linux-x64-gnu";
36
+ }
37
+ if (platform === "linux" && arch === "arm64") {
38
+ return "sdl-mcp-native-linux-arm64-gnu";
39
+ }
40
+
41
+ return null;
42
+ }
43
+
44
+ /**
45
+ * Detect musl libc on Linux.
46
+ * @returns {boolean}
47
+ */
48
+ function isMusl() {
49
+ // Check if we're running on Alpine or musl-based distro
50
+ try {
51
+ const output = readFileSync("/usr/bin/ldd", "utf8");
52
+ if (output.includes("musl")) return true;
53
+ } catch {
54
+ // ldd not readable
55
+ }
56
+
57
+ try {
58
+ if (existsSync("/etc/alpine-release")) return true;
59
+ } catch {
60
+ // not alpine
61
+ }
62
+
63
+ // Check the dynamic linker
64
+ try {
65
+ const maps = readFileSync("/proc/self/maps", "utf8");
66
+ if (maps.includes("musl")) return true;
67
+ } catch {
68
+ // /proc not available
69
+ }
70
+
71
+ return false;
72
+ }
73
+
74
+ /**
75
+ * Map platform package names to their .node file suffix.
76
+ */
77
+ const PLATFORM_NODE_FILES = {
78
+ "sdl-mcp-native-win32-x64-msvc": "sdl-mcp-native.win32-x64-msvc.node",
79
+ "sdl-mcp-native-darwin-x64": "sdl-mcp-native.darwin-x64.node",
80
+ "sdl-mcp-native-darwin-arm64": "sdl-mcp-native.darwin-arm64.node",
81
+ "sdl-mcp-native-linux-x64-gnu": "sdl-mcp-native.linux-x64-gnu.node",
82
+ "sdl-mcp-native-linux-x64-musl": "sdl-mcp-native.linux-x64-musl.node",
83
+ "sdl-mcp-native-linux-arm64-gnu": "sdl-mcp-native.linux-arm64-gnu.node",
84
+ };
85
+
86
+ let nativeBinding = null;
87
+ let loadError = null;
88
+
89
+ const packageName = getPackageName();
90
+
91
+ if (packageName) {
92
+ const nodeFileName = PLATFORM_NODE_FILES[packageName];
93
+
94
+ // 1. Try local platform-suffixed .node file (dev builds via napi artifacts)
95
+ const localPlatformPath = join(__dirname, nodeFileName);
96
+ if (existsSync(localPlatformPath)) {
97
+ try {
98
+ nativeBinding = require(localPlatformPath);
99
+ } catch (e) {
100
+ loadError = e;
101
+ }
102
+ }
103
+
104
+ // 2. Try per-platform npm package
105
+ if (!nativeBinding) {
106
+ try {
107
+ nativeBinding = require(packageName);
108
+ } catch (e) {
109
+ loadError = e;
110
+ }
111
+ }
112
+
113
+ // 3. Try legacy local files (backward compat with dev builds)
114
+ if (!nativeBinding) {
115
+ const legacyPaths = [
116
+ join(__dirname, "sdl-mcp-native.node"),
117
+ join(__dirname, "index.node"),
118
+ ];
119
+ for (const p of legacyPaths) {
120
+ if (existsSync(p)) {
121
+ try {
122
+ nativeBinding = require(p);
123
+ break;
124
+ } catch (e) {
125
+ loadError = e;
126
+ }
127
+ }
128
+ }
129
+ }
130
+ } else {
131
+ loadError = new Error(
132
+ `Unsupported platform: ${process.platform}-${process.arch}. ` +
133
+ `sdl-mcp-native supports: win32-x64, darwin-x64, darwin-arm64, linux-x64, linux-arm64`
134
+ );
135
+ }
136
+
137
+ if (!nativeBinding) {
138
+ if (loadError) {
139
+ throw loadError;
140
+ }
141
+ throw new Error("Failed to load sdl-mcp-native native binding");
142
+ }
143
+
144
+ module.exports.parseFiles = nativeBinding.parseFiles;
145
+ module.exports.hashContentNative = nativeBinding.hashContentNative;
146
+ module.exports.generateSymbolIdNative = nativeBinding.generateSymbolIdNative;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdl-mcp-native",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "description": "Native Rust indexer for SDL-MCP with tree-sitter parsing and Rayon parallelism",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "main": "index.js",
@@ -29,12 +29,12 @@
29
29
  "version": "napi version"
30
30
  },
31
31
  "optionalDependencies": {
32
- "sdl-mcp-native-win32-x64-msvc": "0.7.2",
33
- "sdl-mcp-native-darwin-x64": "0.7.2",
34
- "sdl-mcp-native-darwin-arm64": "0.7.2",
35
- "sdl-mcp-native-linux-x64-gnu": "0.7.2",
36
- "sdl-mcp-native-linux-x64-musl": "0.7.2",
37
- "sdl-mcp-native-linux-arm64-gnu": "0.7.2"
32
+ "sdl-mcp-native-win32-x64-msvc": "0.8.0",
33
+ "sdl-mcp-native-darwin-x64": "0.8.0",
34
+ "sdl-mcp-native-darwin-arm64": "0.8.0",
35
+ "sdl-mcp-native-linux-x64-gnu": "0.8.0",
36
+ "sdl-mcp-native-linux-x64-musl": "0.8.0",
37
+ "sdl-mcp-native-linux-arm64-gnu": "0.8.0"
38
38
  },
39
39
  "repository": {
40
40
  "type": "git",