@tienne/gestalt 0.9.1 → 0.10.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/CLAUDE.md +75 -0
- package/dist/package.json +2 -1
- package/dist/skills/blast-radius/SKILL.md +134 -0
- package/dist/skills/build-graph/SKILL.md +100 -0
- package/dist/skills/diff-radius/SKILL.md +125 -0
- package/dist/skills/setup/SKILL.md +150 -0
- package/dist/src/cli/commands/graph-visualize.d.ts +11 -0
- package/dist/src/cli/commands/graph-visualize.d.ts.map +1 -0
- package/dist/src/cli/commands/graph-visualize.js +26 -0
- package/dist/src/cli/commands/graph-visualize.js.map +1 -0
- package/dist/src/cli/commands/init.d.ts +5 -0
- package/dist/src/cli/commands/init.d.ts.map +1 -0
- package/dist/src/cli/commands/init.js +79 -0
- package/dist/src/cli/commands/init.js.map +1 -0
- package/dist/src/cli/index.d.ts.map +1 -1
- package/dist/src/cli/index.js +23 -0
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/code-graph/blast-radius.d.ts +9 -0
- package/dist/src/code-graph/blast-radius.d.ts.map +1 -0
- package/dist/src/code-graph/blast-radius.js +139 -0
- package/dist/src/code-graph/blast-radius.js.map +1 -0
- package/dist/src/code-graph/engine.d.ts +46 -0
- package/dist/src/code-graph/engine.d.ts.map +1 -0
- package/dist/src/code-graph/engine.js +301 -0
- package/dist/src/code-graph/engine.js.map +1 -0
- package/dist/src/code-graph/git-hook.d.ts +22 -0
- package/dist/src/code-graph/git-hook.d.ts.map +1 -0
- package/dist/src/code-graph/git-hook.js +100 -0
- package/dist/src/code-graph/git-hook.js.map +1 -0
- package/dist/src/code-graph/index.d.ts +7 -0
- package/dist/src/code-graph/index.d.ts.map +1 -0
- package/dist/src/code-graph/index.js +6 -0
- package/dist/src/code-graph/index.js.map +1 -0
- package/dist/src/code-graph/plugins/go.d.ts +3 -0
- package/dist/src/code-graph/plugins/go.d.ts.map +1 -0
- package/dist/src/code-graph/plugins/go.js +126 -0
- package/dist/src/code-graph/plugins/go.js.map +1 -0
- package/dist/src/code-graph/plugins/index.d.ts +16 -0
- package/dist/src/code-graph/plugins/index.d.ts.map +1 -0
- package/dist/src/code-graph/plugins/index.js +36 -0
- package/dist/src/code-graph/plugins/index.js.map +1 -0
- package/dist/src/code-graph/plugins/java.d.ts +3 -0
- package/dist/src/code-graph/plugins/java.d.ts.map +1 -0
- package/dist/src/code-graph/plugins/java.js +108 -0
- package/dist/src/code-graph/plugins/java.js.map +1 -0
- package/dist/src/code-graph/plugins/kotlin.d.ts +3 -0
- package/dist/src/code-graph/plugins/kotlin.d.ts.map +1 -0
- package/dist/src/code-graph/plugins/kotlin.js +94 -0
- package/dist/src/code-graph/plugins/kotlin.js.map +1 -0
- package/dist/src/code-graph/plugins/objc.d.ts +3 -0
- package/dist/src/code-graph/plugins/objc.d.ts.map +1 -0
- package/dist/src/code-graph/plugins/objc.js +129 -0
- package/dist/src/code-graph/plugins/objc.js.map +1 -0
- package/dist/src/code-graph/plugins/python.d.ts +3 -0
- package/dist/src/code-graph/plugins/python.d.ts.map +1 -0
- package/dist/src/code-graph/plugins/python.js +116 -0
- package/dist/src/code-graph/plugins/python.js.map +1 -0
- package/dist/src/code-graph/plugins/rust.d.ts +3 -0
- package/dist/src/code-graph/plugins/rust.d.ts.map +1 -0
- package/dist/src/code-graph/plugins/rust.js +108 -0
- package/dist/src/code-graph/plugins/rust.js.map +1 -0
- package/dist/src/code-graph/plugins/swift.d.ts +3 -0
- package/dist/src/code-graph/plugins/swift.d.ts.map +1 -0
- package/dist/src/code-graph/plugins/swift.js +106 -0
- package/dist/src/code-graph/plugins/swift.js.map +1 -0
- package/dist/src/code-graph/plugins/typescript.d.ts +3 -0
- package/dist/src/code-graph/plugins/typescript.d.ts.map +1 -0
- package/dist/src/code-graph/plugins/typescript.js +209 -0
- package/dist/src/code-graph/plugins/typescript.js.map +1 -0
- package/dist/src/code-graph/storage.d.ts +19 -0
- package/dist/src/code-graph/storage.d.ts.map +1 -0
- package/dist/src/code-graph/storage.js +182 -0
- package/dist/src/code-graph/storage.js.map +1 -0
- package/dist/src/code-graph/types.d.ts +93 -0
- package/dist/src/code-graph/types.d.ts.map +1 -0
- package/dist/src/code-graph/types.js +17 -0
- package/dist/src/code-graph/types.js.map +1 -0
- package/dist/src/core/config.d.ts +1 -0
- package/dist/src/core/config.d.ts.map +1 -1
- package/dist/src/core/config.js +1 -1
- package/dist/src/core/config.js.map +1 -1
- package/dist/src/core/types.d.ts +1 -0
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/execute/passthrough-engine.d.ts +4 -1
- package/dist/src/execute/passthrough-engine.d.ts.map +1 -1
- package/dist/src/execute/passthrough-engine.js +54 -4
- package/dist/src/execute/passthrough-engine.js.map +1 -1
- package/dist/src/execute/prompts.d.ts +2 -2
- package/dist/src/execute/prompts.d.ts.map +1 -1
- package/dist/src/execute/prompts.js +7 -3
- package/dist/src/execute/prompts.js.map +1 -1
- package/dist/src/execute/repository.d.ts.map +1 -1
- package/dist/src/execute/repository.js +1 -0
- package/dist/src/execute/repository.js.map +1 -1
- package/dist/src/execute/session.d.ts +3 -1
- package/dist/src/execute/session.d.ts.map +1 -1
- package/dist/src/execute/session.js +3 -1
- package/dist/src/execute/session.js.map +1 -1
- package/dist/src/graph-viz/engine.d.ts +20 -0
- package/dist/src/graph-viz/engine.d.ts.map +1 -0
- package/dist/src/graph-viz/engine.js +81 -0
- package/dist/src/graph-viz/engine.js.map +1 -0
- package/dist/src/graph-viz/html-generator.d.ts +7 -0
- package/dist/src/graph-viz/html-generator.d.ts.map +1 -0
- package/dist/src/graph-viz/html-generator.js +699 -0
- package/dist/src/graph-viz/html-generator.js.map +1 -0
- package/dist/src/graph-viz/index.d.ts +6 -0
- package/dist/src/graph-viz/index.d.ts.map +1 -0
- package/dist/src/graph-viz/index.js +5 -0
- package/dist/src/graph-viz/index.js.map +1 -0
- package/dist/src/graph-viz/port-finder.d.ts +2 -0
- package/dist/src/graph-viz/port-finder.d.ts.map +1 -0
- package/dist/src/graph-viz/port-finder.js +26 -0
- package/dist/src/graph-viz/port-finder.js.map +1 -0
- package/dist/src/graph-viz/server.d.ts +26 -0
- package/dist/src/graph-viz/server.d.ts.map +1 -0
- package/dist/src/graph-viz/server.js +104 -0
- package/dist/src/graph-viz/server.js.map +1 -0
- package/dist/src/graph-viz/types.d.ts +11 -0
- package/dist/src/graph-viz/types.d.ts.map +1 -0
- package/dist/src/graph-viz/types.js +2 -0
- package/dist/src/graph-viz/types.js.map +1 -0
- package/dist/src/mcp/schemas.d.ts +57 -0
- package/dist/src/mcp/schemas.d.ts.map +1 -1
- package/dist/src/mcp/schemas.js +28 -0
- package/dist/src/mcp/schemas.js.map +1 -1
- package/dist/src/mcp/server.d.ts.map +1 -1
- package/dist/src/mcp/server.js +28 -1
- package/dist/src/mcp/server.js.map +1 -1
- package/dist/src/mcp/tools/code-graph-passthrough.d.ts +16 -0
- package/dist/src/mcp/tools/code-graph-passthrough.d.ts.map +1 -0
- package/dist/src/mcp/tools/code-graph-passthrough.js +65 -0
- package/dist/src/mcp/tools/code-graph-passthrough.js.map +1 -0
- package/dist/src/mcp/tools/execute-passthrough.d.ts.map +1 -1
- package/dist/src/mcp/tools/execute-passthrough.js +1 -1
- package/dist/src/mcp/tools/execute-passthrough.js.map +1 -1
- package/dist/src/mcp/tools/graph-visualize-passthrough.d.ts +13 -0
- package/dist/src/mcp/tools/graph-visualize-passthrough.d.ts.map +1 -0
- package/dist/src/mcp/tools/graph-visualize-passthrough.js +26 -0
- package/dist/src/mcp/tools/graph-visualize-passthrough.js.map +1 -0
- package/dist/src/mcp/tools/index.d.ts +1 -0
- package/dist/src/mcp/tools/index.d.ts.map +1 -1
- package/dist/src/mcp/tools/index.js +1 -0
- package/dist/src/mcp/tools/index.js.map +1 -1
- package/package.json +2 -1
- package/skills/blast-radius/SKILL.md +134 -0
- package/skills/build-graph/SKILL.md +100 -0
- package/skills/diff-radius/SKILL.md +125 -0
- package/skills/setup/SKILL.md +150 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objc.d.ts","sourceRoot":"","sources":["../../../../src/code-graph/plugins/objc.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAA6C,MAAM,aAAa,CAAC;AAU7F,eAAO,MAAM,UAAU,EAAE,cAiIxB,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { basename, dirname, resolve } from 'node:path';
|
|
3
|
+
import { NodeKind, EdgeKind } from '../types.js';
|
|
4
|
+
function isTestFile(filePath) {
|
|
5
|
+
return (filePath.includes('Test.m') ||
|
|
6
|
+
filePath.includes('Tests.m') ||
|
|
7
|
+
filePath.includes('/Tests/'));
|
|
8
|
+
}
|
|
9
|
+
export const objcPlugin = {
|
|
10
|
+
language: 'objective-c',
|
|
11
|
+
extensions: ['.m', '.h'],
|
|
12
|
+
parse(filePath, content) {
|
|
13
|
+
const fileHash = createHash('sha256').update(content).digest('hex');
|
|
14
|
+
const now = Date.now();
|
|
15
|
+
const isTest = isTestFile(filePath);
|
|
16
|
+
const nodes = [];
|
|
17
|
+
const edges = [];
|
|
18
|
+
const edgeSet = new Set();
|
|
19
|
+
const fileNodeId = `file:${filePath}`;
|
|
20
|
+
nodes.push({
|
|
21
|
+
id: fileNodeId,
|
|
22
|
+
kind: NodeKind.File,
|
|
23
|
+
name: basename(filePath),
|
|
24
|
+
filePath,
|
|
25
|
+
isTest,
|
|
26
|
+
fileHash,
|
|
27
|
+
updatedAt: now,
|
|
28
|
+
});
|
|
29
|
+
const lines = content.split('\n');
|
|
30
|
+
// @interface ClassName : ParentClass
|
|
31
|
+
const interfaceRegex = /^@interface\s+(\w+)(?:\s*:\s*(\w+))?/;
|
|
32
|
+
// @implementation ClassName
|
|
33
|
+
const implementationRegex = /^@implementation\s+(\w+)/;
|
|
34
|
+
// - (ReturnType)methodName or + (ReturnType)methodName
|
|
35
|
+
const methodRegex = /^[+-]\s*\(\s*[\w*\s]+\s*\)\s*(\w+)/;
|
|
36
|
+
// #import "Header.h" or #import <Framework/Header.h>
|
|
37
|
+
const importRegex = /^#import\s+(?:"([^"]+)"|<([^>]+)>)/;
|
|
38
|
+
let currentClassId = null;
|
|
39
|
+
for (let i = 0; i < lines.length; i++) {
|
|
40
|
+
const line = lines[i].trim();
|
|
41
|
+
const lineNum = i + 1;
|
|
42
|
+
// Import
|
|
43
|
+
const importMatch = importRegex.exec(line);
|
|
44
|
+
if (importMatch) {
|
|
45
|
+
const local = importMatch[1];
|
|
46
|
+
const framework = importMatch[2];
|
|
47
|
+
if (local) {
|
|
48
|
+
// Local header — resolve relative to current file's directory
|
|
49
|
+
const resolvedPath = resolve(dirname(filePath), local);
|
|
50
|
+
const targetId = `file:${resolvedPath}`;
|
|
51
|
+
const edgeKey = `IMPORTS_FROM:${fileNodeId}:${targetId}`;
|
|
52
|
+
if (!edgeSet.has(edgeKey)) {
|
|
53
|
+
edgeSet.add(edgeKey);
|
|
54
|
+
edges.push({ kind: EdgeKind.IMPORTS_FROM, sourceId: fileNodeId, targetId, line: lineNum, updatedAt: now });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else if (framework) {
|
|
58
|
+
const targetId = `file:${framework}`;
|
|
59
|
+
const edgeKey = `IMPORTS_FROM:${fileNodeId}:${targetId}`;
|
|
60
|
+
if (!edgeSet.has(edgeKey)) {
|
|
61
|
+
edgeSet.add(edgeKey);
|
|
62
|
+
edges.push({ kind: EdgeKind.IMPORTS_FROM, sourceId: fileNodeId, targetId, line: lineNum, updatedAt: now });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
// @interface (class declaration)
|
|
68
|
+
const ifaceMatch = interfaceRegex.exec(line);
|
|
69
|
+
if (ifaceMatch) {
|
|
70
|
+
const name = ifaceMatch[1];
|
|
71
|
+
const parent = ifaceMatch[2];
|
|
72
|
+
const nodeId = `class:${filePath}:${name}`;
|
|
73
|
+
nodes.push({ id: nodeId, kind: NodeKind.Class, name, filePath, lineStart: lineNum, isTest, updatedAt: now });
|
|
74
|
+
const edgeKey = `CONTAINS:${fileNodeId}:${nodeId}`;
|
|
75
|
+
if (!edgeSet.has(edgeKey)) {
|
|
76
|
+
edgeSet.add(edgeKey);
|
|
77
|
+
edges.push({ kind: EdgeKind.CONTAINS, sourceId: fileNodeId, targetId: nodeId, line: lineNum, updatedAt: now });
|
|
78
|
+
}
|
|
79
|
+
if (parent) {
|
|
80
|
+
const parentId = `class:${filePath}:${parent}`;
|
|
81
|
+
const inheritKey = `INHERITS:${nodeId}:${parentId}`;
|
|
82
|
+
if (!edgeSet.has(inheritKey)) {
|
|
83
|
+
edgeSet.add(inheritKey);
|
|
84
|
+
edges.push({ kind: EdgeKind.INHERITS, sourceId: nodeId, targetId: parentId, line: lineNum, updatedAt: now });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
currentClassId = nodeId;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
// @implementation
|
|
91
|
+
const implMatch = implementationRegex.exec(line);
|
|
92
|
+
if (implMatch) {
|
|
93
|
+
const name = implMatch[1];
|
|
94
|
+
// Reuse or create the class node
|
|
95
|
+
currentClassId = `class:${filePath}:${name}`;
|
|
96
|
+
if (!nodes.find((n) => n.id === currentClassId)) {
|
|
97
|
+
nodes.push({ id: currentClassId, kind: NodeKind.Class, name, filePath, lineStart: lineNum, isTest, updatedAt: now });
|
|
98
|
+
const edgeKey = `CONTAINS:${fileNodeId}:${currentClassId}`;
|
|
99
|
+
if (!edgeSet.has(edgeKey)) {
|
|
100
|
+
edgeSet.add(edgeKey);
|
|
101
|
+
edges.push({ kind: EdgeKind.CONTAINS, sourceId: fileNodeId, targetId: currentClassId, line: lineNum, updatedAt: now });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
// @end
|
|
107
|
+
if (line === '@end') {
|
|
108
|
+
currentClassId = null;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
// Methods
|
|
112
|
+
if (currentClassId) {
|
|
113
|
+
const methodMatch = methodRegex.exec(line);
|
|
114
|
+
if (methodMatch) {
|
|
115
|
+
const name = methodMatch[1];
|
|
116
|
+
const nodeId = `function:${filePath}:${name}`;
|
|
117
|
+
nodes.push({ id: nodeId, kind: NodeKind.Function, name, filePath, lineStart: lineNum, isTest, updatedAt: now });
|
|
118
|
+
const edgeKey = `CONTAINS:${currentClassId}:${nodeId}`;
|
|
119
|
+
if (!edgeSet.has(edgeKey)) {
|
|
120
|
+
edgeSet.add(edgeKey);
|
|
121
|
+
edges.push({ kind: EdgeKind.CONTAINS, sourceId: currentClassId, targetId: nodeId, line: lineNum, updatedAt: now });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return { nodes, edges, fileHash };
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=objc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objc.js","sourceRoot":"","sources":["../../../../src/code-graph/plugins/objc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGjD,SAAS,UAAU,CAAC,QAAgB;IAClC,OAAO,CACL,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC3B,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC5B,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAC7B,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAmB;IACxC,QAAQ,EAAE,aAAa;IACvB,UAAU,EA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
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { basename } from 'node:path';
|
|
3
|
+
import { NodeKind, EdgeKind } from '../types.js';
|
|
4
|
+
function isTestFile(filePath) {
|
|
5
|
+
const name = basename(filePath);
|
|
6
|
+
return (name.startsWith('test_') ||
|
|
7
|
+
name.endsWith('_test.py') ||
|
|
8
|
+
filePath.includes('__tests__') ||
|
|
9
|
+
filePath.includes('/tests/') ||
|
|
10
|
+
filePath.includes('.test.'));
|
|
11
|
+
}
|
|
12
|
+
export const pythonPlugin = {
|
|
13
|
+
language: 'python',
|
|
14
|
+
extensions: ['.py'],
|
|
15
|
+
parse(filePath, content) {
|
|
16
|
+
const fileHash = createHash('sha256').update(content).digest('hex');
|
|
17
|
+
const now = Date.now();
|
|
18
|
+
const isTest = isTestFile(filePath);
|
|
19
|
+
const nodes = [];
|
|
20
|
+
const edges = [];
|
|
21
|
+
const edgeSet = new Set();
|
|
22
|
+
const fileNodeId = `file:${filePath}`;
|
|
23
|
+
nodes.push({
|
|
24
|
+
id: fileNodeId,
|
|
25
|
+
kind: NodeKind.File,
|
|
26
|
+
name: basename(filePath),
|
|
27
|
+
filePath,
|
|
28
|
+
isTest,
|
|
29
|
+
fileHash,
|
|
30
|
+
updatedAt: now,
|
|
31
|
+
});
|
|
32
|
+
const lines = content.split('\n');
|
|
33
|
+
// Parse functions and classes
|
|
34
|
+
const funcRegex = /^(\s*)(async\s+)?def\s+(\w+)\s*\(/;
|
|
35
|
+
const classRegex = /^(\s*)class\s+(\w+)(?:\s*\(([^)]*)\))?:/;
|
|
36
|
+
const importRegex = /^(?:import\s+(\S+)|from\s+(\S+)\s+import\s+)/;
|
|
37
|
+
for (let i = 0; i < lines.length; i++) {
|
|
38
|
+
const line = lines[i];
|
|
39
|
+
const lineNum = i + 1;
|
|
40
|
+
// Function
|
|
41
|
+
const funcMatch = funcRegex.exec(line);
|
|
42
|
+
if (funcMatch) {
|
|
43
|
+
const indent = funcMatch[1].length;
|
|
44
|
+
const name = funcMatch[3];
|
|
45
|
+
if (indent === 0 || indent === 4) {
|
|
46
|
+
const nodeId = `function:${filePath}:${name}`;
|
|
47
|
+
nodes.push({
|
|
48
|
+
id: nodeId,
|
|
49
|
+
kind: NodeKind.Function,
|
|
50
|
+
name,
|
|
51
|
+
filePath,
|
|
52
|
+
lineStart: lineNum,
|
|
53
|
+
isTest,
|
|
54
|
+
updatedAt: now,
|
|
55
|
+
});
|
|
56
|
+
const edgeKey = `CONTAINS:${fileNodeId}:${nodeId}`;
|
|
57
|
+
if (!edgeSet.has(edgeKey)) {
|
|
58
|
+
edgeSet.add(edgeKey);
|
|
59
|
+
edges.push({ kind: EdgeKind.CONTAINS, sourceId: fileNodeId, targetId: nodeId, line: lineNum, updatedAt: now });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
// Class
|
|
65
|
+
const classMatch = classRegex.exec(line);
|
|
66
|
+
if (classMatch) {
|
|
67
|
+
const name = classMatch[2];
|
|
68
|
+
const parents = classMatch[3];
|
|
69
|
+
const nodeId = `class:${filePath}:${name}`;
|
|
70
|
+
nodes.push({
|
|
71
|
+
id: nodeId,
|
|
72
|
+
kind: NodeKind.Class,
|
|
73
|
+
name,
|
|
74
|
+
filePath,
|
|
75
|
+
lineStart: lineNum,
|
|
76
|
+
isTest,
|
|
77
|
+
updatedAt: now,
|
|
78
|
+
});
|
|
79
|
+
const containsKey = `CONTAINS:${fileNodeId}:${nodeId}`;
|
|
80
|
+
if (!edgeSet.has(containsKey)) {
|
|
81
|
+
edgeSet.add(containsKey);
|
|
82
|
+
edges.push({ kind: EdgeKind.CONTAINS, sourceId: fileNodeId, targetId: nodeId, line: lineNum, updatedAt: now });
|
|
83
|
+
}
|
|
84
|
+
// Inheritance
|
|
85
|
+
if (parents) {
|
|
86
|
+
for (const parent of parents.split(',').map((p) => p.trim())) {
|
|
87
|
+
if (parent && parent !== 'object') {
|
|
88
|
+
const parentId = `class:${filePath}:${parent}`;
|
|
89
|
+
const inheritKey = `INHERITS:${nodeId}:${parentId}`;
|
|
90
|
+
if (!edgeSet.has(inheritKey)) {
|
|
91
|
+
edgeSet.add(inheritKey);
|
|
92
|
+
edges.push({ kind: EdgeKind.INHERITS, sourceId: nodeId, targetId: parentId, line: lineNum, updatedAt: now });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
// Import (relative: from . import or from .module import)
|
|
100
|
+
const importMatch = importRegex.exec(line);
|
|
101
|
+
if (importMatch) {
|
|
102
|
+
const fromModule = importMatch[2];
|
|
103
|
+
if (fromModule && (fromModule.startsWith('.') || fromModule.startsWith('/'))) {
|
|
104
|
+
const targetId = `file:${fromModule}`;
|
|
105
|
+
const edgeKey = `IMPORTS_FROM:${fileNodeId}:${targetId}`;
|
|
106
|
+
if (!edgeSet.has(edgeKey)) {
|
|
107
|
+
edgeSet.add(edgeKey);
|
|
108
|
+
edges.push({ kind: EdgeKind.IMPORTS_FROM, sourceId: fileNodeId, targetId, line: lineNum, updatedAt: now });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return { nodes, edges, fileHash };
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
//# sourceMappingURL=python.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python.js","sourceRoot":"","sources":["../../../../src/code-graph/plugins/python.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGjD,SAAS,UAAU,CAAC,QAAgB;IAClC,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAA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src/code-graph/plugins/rust.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAA6C,MAAM,aAAa,CAAC;AAU7F,eAAO,MAAM,UAAU,EAAE,cA4GxB,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { basename } from 'node:path';
|
|
3
|
+
import { NodeKind, EdgeKind } from '../types.js';
|
|
4
|
+
function isTestFile(filePath) {
|
|
5
|
+
return (filePath.includes('/tests/') ||
|
|
6
|
+
filePath.includes('/test/') ||
|
|
7
|
+
basename(filePath) === 'tests.rs');
|
|
8
|
+
}
|
|
9
|
+
export const rustPlugin = {
|
|
10
|
+
language: 'rust',
|
|
11
|
+
extensions: ['.rs'],
|
|
12
|
+
parse(filePath, content) {
|
|
13
|
+
const fileHash = createHash('sha256').update(content).digest('hex');
|
|
14
|
+
const now = Date.now();
|
|
15
|
+
// Rust test files have #[cfg(test)] or are in tests/ directories
|
|
16
|
+
const isTest = isTestFile(filePath) || content.includes('#[cfg(test)]');
|
|
17
|
+
const nodes = [];
|
|
18
|
+
const edges = [];
|
|
19
|
+
const edgeSet = new Set();
|
|
20
|
+
const fileNodeId = `file:${filePath}`;
|
|
21
|
+
nodes.push({
|
|
22
|
+
id: fileNodeId,
|
|
23
|
+
kind: NodeKind.File,
|
|
24
|
+
name: basename(filePath),
|
|
25
|
+
filePath,
|
|
26
|
+
isTest,
|
|
27
|
+
fileHash,
|
|
28
|
+
updatedAt: now,
|
|
29
|
+
});
|
|
30
|
+
const lines = content.split('\n');
|
|
31
|
+
const funcRegex = /^(?:pub\s+)?(?:async\s+)?fn\s+(\w+)\s*(?:<[^>]*>)?\s*\(/;
|
|
32
|
+
const structRegex = /^(?:pub\s+)?struct\s+(\w+)/;
|
|
33
|
+
const enumRegex = /^(?:pub\s+)?enum\s+(\w+)/;
|
|
34
|
+
const traitRegex = /^(?:pub\s+)?trait\s+(\w+)/;
|
|
35
|
+
const useRegex = /^use\s+([\w:]+)/;
|
|
36
|
+
for (let i = 0; i < lines.length; i++) {
|
|
37
|
+
const line = lines[i];
|
|
38
|
+
const lineNum = i + 1;
|
|
39
|
+
// use statement
|
|
40
|
+
const useMatch = useRegex.exec(line.trim());
|
|
41
|
+
if (useMatch) {
|
|
42
|
+
const mod = useMatch[1];
|
|
43
|
+
if (mod.startsWith('crate::') || mod.startsWith('super::') || mod.startsWith('self::')) {
|
|
44
|
+
const targetId = `file:${mod.replace(/::/g, '/')}`;
|
|
45
|
+
const edgeKey = `IMPORTS_FROM:${fileNodeId}:${targetId}`;
|
|
46
|
+
if (!edgeSet.has(edgeKey)) {
|
|
47
|
+
edgeSet.add(edgeKey);
|
|
48
|
+
edges.push({ kind: EdgeKind.IMPORTS_FROM, sourceId: fileNodeId, targetId, line: lineNum, updatedAt: now });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
// Function
|
|
54
|
+
const funcMatch = funcRegex.exec(line.trim());
|
|
55
|
+
if (funcMatch) {
|
|
56
|
+
const name = funcMatch[1];
|
|
57
|
+
const nodeId = `function:${filePath}:${name}`;
|
|
58
|
+
nodes.push({ id: nodeId, kind: NodeKind.Function, name, filePath, lineStart: lineNum, isTest, updatedAt: now });
|
|
59
|
+
const edgeKey = `CONTAINS:${fileNodeId}:${nodeId}`;
|
|
60
|
+
if (!edgeSet.has(edgeKey)) {
|
|
61
|
+
edgeSet.add(edgeKey);
|
|
62
|
+
edges.push({ kind: EdgeKind.CONTAINS, sourceId: fileNodeId, targetId: nodeId, line: lineNum, updatedAt: now });
|
|
63
|
+
}
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
// Struct
|
|
67
|
+
const structMatch = structRegex.exec(line.trim());
|
|
68
|
+
if (structMatch) {
|
|
69
|
+
const name = structMatch[1];
|
|
70
|
+
const nodeId = `class:${filePath}:${name}`;
|
|
71
|
+
nodes.push({ id: nodeId, kind: NodeKind.Class, name, filePath, lineStart: lineNum, isTest, updatedAt: now });
|
|
72
|
+
const edgeKey = `CONTAINS:${fileNodeId}:${nodeId}`;
|
|
73
|
+
if (!edgeSet.has(edgeKey)) {
|
|
74
|
+
edgeSet.add(edgeKey);
|
|
75
|
+
edges.push({ kind: EdgeKind.CONTAINS, sourceId: fileNodeId, targetId: nodeId, line: lineNum, updatedAt: now });
|
|
76
|
+
}
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
// Enum
|
|
80
|
+
const enumMatch = enumRegex.exec(line.trim());
|
|
81
|
+
if (enumMatch) {
|
|
82
|
+
const name = enumMatch[1];
|
|
83
|
+
const nodeId = `type:${filePath}:${name}`;
|
|
84
|
+
nodes.push({ id: nodeId, kind: NodeKind.Type, name, filePath, lineStart: lineNum, isTest, updatedAt: now });
|
|
85
|
+
const edgeKey = `CONTAINS:${fileNodeId}:${nodeId}`;
|
|
86
|
+
if (!edgeSet.has(edgeKey)) {
|
|
87
|
+
edgeSet.add(edgeKey);
|
|
88
|
+
edges.push({ kind: EdgeKind.CONTAINS, sourceId: fileNodeId, targetId: nodeId, line: lineNum, updatedAt: now });
|
|
89
|
+
}
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
// Trait (interface-like)
|
|
93
|
+
const traitMatch = traitRegex.exec(line.trim());
|
|
94
|
+
if (traitMatch) {
|
|
95
|
+
const name = traitMatch[1];
|
|
96
|
+
const nodeId = `type:${filePath}:${name}`;
|
|
97
|
+
nodes.push({ id: nodeId, kind: NodeKind.Type, name, filePath, lineStart: lineNum, isTest, updatedAt: now });
|
|
98
|
+
const edgeKey = `CONTAINS:${fileNodeId}:${nodeId}`;
|
|
99
|
+
if (!edgeSet.has(edgeKey)) {
|
|
100
|
+
edgeSet.add(edgeKey);
|
|
101
|
+
edges.push({ kind: EdgeKind.CONTAINS, sourceId: fileNodeId, targetId: nodeId, line: lineNum, updatedAt: now });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return { nodes, edges, fileHash };
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=rust.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rust.js","sourceRoot":"","sources":["../../../../src/code-graph/plugins/rust.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGjD,SAAS,UAAU,CAAC,QAAgB;IAClC,OAAO,CACL,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC5B,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC3B,QAAQ,CAAC,QAAQ,CAAC,KAAK,UAAU,CAClC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAmB;IACxC,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,CAAC,KAAK,CAAC;IAEnB,KAAK,CAAC,QAAgB,EAAE,OAAe;QACrC,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACpE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,iEAAiE;QACjE,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;QACxE,MAAM,KAAK,GAAoB,EAAE,CAAC;QAClC,MAAM,KAAK,GAAoB,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;QAElC,MAAM,UAAU,GAAG,QAAQ,QAAQ,EAAE,CAAC;QACtC,KAAK,CAAC,IAAI,CAAC;YACT,EAAE,EAAE,UAAU;YACd,IAAI,EAAE,QAAQ,CA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
|
+
{"version":3,"file":"swift.d.ts","sourceRoot":"","sources":["../../../../src/code-graph/plugins/swift.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAA6C,MAAM,aAAa,CAAC;AAU7F,eAAO,MAAM,WAAW,EAAE,cAyGzB,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { basename } from 'node:path';
|
|
3
|
+
import { NodeKind, EdgeKind } from '../types.js';
|
|
4
|
+
function isTestFile(filePath) {
|
|
5
|
+
return (filePath.includes('Tests.swift') ||
|
|
6
|
+
filePath.includes('Test.swift') ||
|
|
7
|
+
filePath.includes('/Tests/'));
|
|
8
|
+
}
|
|
9
|
+
export const swiftPlugin = {
|
|
10
|
+
language: 'swift',
|
|
11
|
+
extensions: ['.swift'],
|
|
12
|
+
parse(filePath, content) {
|
|
13
|
+
const fileHash = createHash('sha256').update(content).digest('hex');
|
|
14
|
+
const now = Date.now();
|
|
15
|
+
const isTest = isTestFile(filePath);
|
|
16
|
+
const nodes = [];
|
|
17
|
+
const edges = [];
|
|
18
|
+
const edgeSet = new Set();
|
|
19
|
+
const fileNodeId = `file:${filePath}`;
|
|
20
|
+
nodes.push({
|
|
21
|
+
id: fileNodeId,
|
|
22
|
+
kind: NodeKind.File,
|
|
23
|
+
name: basename(filePath),
|
|
24
|
+
filePath,
|
|
25
|
+
isTest,
|
|
26
|
+
fileHash,
|
|
27
|
+
updatedAt: now,
|
|
28
|
+
});
|
|
29
|
+
const lines = content.split('\n');
|
|
30
|
+
const funcRegex = /(?:override\s+|private\s+|public\s+|internal\s+|fileprivate\s+|open\s+|static\s+)?func\s+(\w+)\s*(?:<[^>]*>)?\s*\(/;
|
|
31
|
+
const classRegex = /(?:final\s+|open\s+|public\s+|private\s+)?(?:class|struct|actor)\s+(\w+)(?:\s*:\s*([\w,<> ]+))?/;
|
|
32
|
+
const protocolRegex = /(?:public\s+)?protocol\s+(\w+)/;
|
|
33
|
+
const importRegex = /^import\s+(\w+)/;
|
|
34
|
+
for (let i = 0; i < lines.length; i++) {
|
|
35
|
+
const line = lines[i];
|
|
36
|
+
const lineNum = i + 1;
|
|
37
|
+
// Import
|
|
38
|
+
const importMatch = importRegex.exec(line.trim());
|
|
39
|
+
if (importMatch) {
|
|
40
|
+
const framework = importMatch[1];
|
|
41
|
+
const targetId = `file:${framework}`;
|
|
42
|
+
const edgeKey = `IMPORTS_FROM:${fileNodeId}:${targetId}`;
|
|
43
|
+
if (!edgeSet.has(edgeKey)) {
|
|
44
|
+
edgeSet.add(edgeKey);
|
|
45
|
+
edges.push({ kind: EdgeKind.IMPORTS_FROM, sourceId: fileNodeId, targetId, line: lineNum, updatedAt: now });
|
|
46
|
+
}
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
// Protocol
|
|
50
|
+
const protoMatch = protocolRegex.exec(line.trim());
|
|
51
|
+
if (protoMatch) {
|
|
52
|
+
const name = protoMatch[1];
|
|
53
|
+
const nodeId = `type:${filePath}:${name}`;
|
|
54
|
+
nodes.push({ id: nodeId, kind: NodeKind.Type, name, filePath, lineStart: lineNum, isTest, updatedAt: now });
|
|
55
|
+
const edgeKey = `CONTAINS:${fileNodeId}:${nodeId}`;
|
|
56
|
+
if (!edgeSet.has(edgeKey)) {
|
|
57
|
+
edgeSet.add(edgeKey);
|
|
58
|
+
edges.push({ kind: EdgeKind.CONTAINS, sourceId: fileNodeId, targetId: nodeId, line: lineNum, updatedAt: now });
|
|
59
|
+
}
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
// Class / struct / actor
|
|
63
|
+
const classMatch = classRegex.exec(line.trim());
|
|
64
|
+
if (classMatch) {
|
|
65
|
+
const name = classMatch[1];
|
|
66
|
+
const parentStr = classMatch[2];
|
|
67
|
+
const nodeId = `class:${filePath}:${name}`;
|
|
68
|
+
nodes.push({ id: nodeId, kind: NodeKind.Class, name, filePath, lineStart: lineNum, isTest, updatedAt: now });
|
|
69
|
+
const edgeKey = `CONTAINS:${fileNodeId}:${nodeId}`;
|
|
70
|
+
if (!edgeSet.has(edgeKey)) {
|
|
71
|
+
edgeSet.add(edgeKey);
|
|
72
|
+
edges.push({ kind: EdgeKind.CONTAINS, sourceId: fileNodeId, targetId: nodeId, line: lineNum, updatedAt: now });
|
|
73
|
+
}
|
|
74
|
+
// Inheritance (first conformance)
|
|
75
|
+
if (parentStr) {
|
|
76
|
+
const parents = parentStr.split(',').map((p) => p.trim());
|
|
77
|
+
if (parents[0]) {
|
|
78
|
+
const parentId = `class:${filePath}:${parents[0]}`;
|
|
79
|
+
const inheritKey = `INHERITS:${nodeId}:${parentId}`;
|
|
80
|
+
if (!edgeSet.has(inheritKey)) {
|
|
81
|
+
edgeSet.add(inheritKey);
|
|
82
|
+
edges.push({ kind: EdgeKind.INHERITS, sourceId: nodeId, targetId: parentId, line: lineNum, updatedAt: now });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
// Function
|
|
89
|
+
const funcMatch = funcRegex.exec(line.trim());
|
|
90
|
+
if (funcMatch) {
|
|
91
|
+
const name = funcMatch[1];
|
|
92
|
+
if (name) {
|
|
93
|
+
const nodeId = `function:${filePath}:${name}`;
|
|
94
|
+
nodes.push({ id: nodeId, kind: NodeKind.Function, name, filePath, lineStart: lineNum, isTest, updatedAt: now });
|
|
95
|
+
const edgeKey = `CONTAINS:${fileNodeId}:${nodeId}`;
|
|
96
|
+
if (!edgeSet.has(edgeKey)) {
|
|
97
|
+
edgeSet.add(edgeKey);
|
|
98
|
+
edges.push({ kind: EdgeKind.CONTAINS, sourceId: fileNodeId, targetId: nodeId, line: lineNum, updatedAt: now });
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return { nodes, edges, fileHash };
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=swift.js.map
|
|
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