@tienne/gestalt 0.9.0 → 0.9.2
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 +78 -1
- package/dist/package.json +3 -1
- package/dist/schemas/gestalt.schema.json +5 -0
- 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/execute/SKILL.md +90 -8
- package/dist/skills/interview/SKILL.md +5 -4
- package/dist/skills/spec/SKILL.md +7 -1
- 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/commands/setup.d.ts.map +1 -1
- package/dist/src/cli/commands/setup.js +1 -0
- package/dist/src/cli/commands/setup.js.map +1 -1
- package/dist/src/cli/index.d.ts.map +1 -1
- package/dist/src/cli/index.js +9 -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 +18 -0
- package/dist/src/code-graph/storage.d.ts.map +1 -0
- package/dist/src/code-graph/storage.js +175 -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 +4 -0
- package/dist/src/core/config.d.ts.map +1 -1
- package/dist/src/core/config.js +6 -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/mcp/schemas.d.ts +46 -0
- package/dist/src/mcp/schemas.d.ts.map +1 -1
- package/dist/src/mcp/schemas.js +23 -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 +21 -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 +28 -2
- package/dist/src/mcp/tools/execute-passthrough.js.map +1 -1
- 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/dist/src/mcp/tools/interview-passthrough.d.ts.map +1 -1
- package/dist/src/mcp/tools/interview-passthrough.js +5 -0
- package/dist/src/mcp/tools/interview-passthrough.js.map +1 -1
- package/dist/src/mcp/tools/spec-passthrough.d.ts.map +1 -1
- package/dist/src/mcp/tools/spec-passthrough.js +9 -0
- package/dist/src/mcp/tools/spec-passthrough.js.map +1 -1
- package/dist/src/utils/notifier.d.ts +10 -0
- package/dist/src/utils/notifier.d.ts.map +1 -0
- package/dist/src/utils/notifier.js +21 -0
- package/dist/src/utils/notifier.js.map +1 -0
- package/package.json +3 -1
- package/schemas/gestalt.schema.json +5 -0
- 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/execute/SKILL.md +90 -8
- package/skills/interview/SKILL.md +5 -4
- package/skills/spec/SKILL.md +7 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { extname } from 'node:path';
|
|
2
|
+
export { typescriptPlugin } from './typescript.js';
|
|
3
|
+
export { pythonPlugin } from './python.js';
|
|
4
|
+
export { goPlugin } from './go.js';
|
|
5
|
+
export { javaPlugin } from './java.js';
|
|
6
|
+
export { kotlinPlugin } from './kotlin.js';
|
|
7
|
+
export { rustPlugin } from './rust.js';
|
|
8
|
+
export { swiftPlugin } from './swift.js';
|
|
9
|
+
export { objcPlugin } from './objc.js';
|
|
10
|
+
import { typescriptPlugin } from './typescript.js';
|
|
11
|
+
import { pythonPlugin } from './python.js';
|
|
12
|
+
import { goPlugin } from './go.js';
|
|
13
|
+
import { javaPlugin } from './java.js';
|
|
14
|
+
import { kotlinPlugin } from './kotlin.js';
|
|
15
|
+
import { rustPlugin } from './rust.js';
|
|
16
|
+
import { swiftPlugin } from './swift.js';
|
|
17
|
+
import { objcPlugin } from './objc.js';
|
|
18
|
+
export const pluginRegistry = [
|
|
19
|
+
typescriptPlugin,
|
|
20
|
+
pythonPlugin,
|
|
21
|
+
goPlugin,
|
|
22
|
+
javaPlugin,
|
|
23
|
+
kotlinPlugin,
|
|
24
|
+
rustPlugin,
|
|
25
|
+
swiftPlugin,
|
|
26
|
+
objcPlugin,
|
|
27
|
+
];
|
|
28
|
+
/**
|
|
29
|
+
* Returns the appropriate plugin for a given file path based on extension.
|
|
30
|
+
* Returns null if no plugin supports the file type.
|
|
31
|
+
*/
|
|
32
|
+
export function getPluginForFile(filePath) {
|
|
33
|
+
const ext = extname(filePath).toLowerCase();
|
|
34
|
+
return pluginRegistry.find((p) => p.extensions.includes(ext)) ?? null;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/code-graph/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,CAAC,MAAM,cAAc,GAAqB;IAC9C,gBAAgB;IAChB,YAAY;IACZ,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,UAAU;IACV,WAAW;IACX,UAAU;CACX,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;IAC5C,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java.d.ts","sourceRoot":"","sources":["../../../../src/code-graph/plugins/java.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAA6C,MAAM,aAAa,CAAC;AAU7F,eAAO,MAAM,UAAU,EAAE,cA6GxB,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('Test.java') ||
|
|
6
|
+
filePath.includes('/test/') ||
|
|
7
|
+
filePath.includes('/tests/'));
|
|
8
|
+
}
|
|
9
|
+
export const javaPlugin = {
|
|
10
|
+
language: 'java',
|
|
11
|
+
extensions: ['.java'],
|
|
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 classRegex = /(?:public\s+|private\s+|protected\s+|abstract\s+|final\s+)*(?:class|enum)\s+(\w+)(?:\s+extends\s+(\w+))?(?:\s+implements\s+([\w,\s]+))?/;
|
|
31
|
+
const interfaceRegex = /(?:public\s+)?interface\s+(\w+)/;
|
|
32
|
+
const methodRegex = /(?:public|private|protected|static|final|abstract|synchronized|native|default)\s+[\w<>\[\]]+\s+(\w+)\s*\(/;
|
|
33
|
+
const importRegex = /^import\s+(?:static\s+)?([\w.]+);/;
|
|
34
|
+
let currentClassId = null;
|
|
35
|
+
for (let i = 0; i < lines.length; i++) {
|
|
36
|
+
const line = lines[i].trim();
|
|
37
|
+
const lineNum = i + 1;
|
|
38
|
+
// Import
|
|
39
|
+
const importMatch = importRegex.exec(line);
|
|
40
|
+
if (importMatch) {
|
|
41
|
+
const pkg = importMatch[1];
|
|
42
|
+
const targetId = `file:${pkg.replace(/\./g, '/')}`;
|
|
43
|
+
const edgeKey = `IMPORTS_FROM:${fileNodeId}:${targetId}`;
|
|
44
|
+
if (!edgeSet.has(edgeKey)) {
|
|
45
|
+
edgeSet.add(edgeKey);
|
|
46
|
+
edges.push({ kind: EdgeKind.IMPORTS_FROM, sourceId: fileNodeId, targetId, line: lineNum, updatedAt: now });
|
|
47
|
+
}
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
// Interface
|
|
51
|
+
const ifaceMatch = interfaceRegex.exec(line);
|
|
52
|
+
if (ifaceMatch) {
|
|
53
|
+
const name = ifaceMatch[1];
|
|
54
|
+
const nodeId = `type:${filePath}:${name}`;
|
|
55
|
+
nodes.push({ id: nodeId, kind: NodeKind.Type, name, filePath, lineStart: lineNum, isTest, updatedAt: now });
|
|
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
|
+
currentClassId = nodeId;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
// Class
|
|
65
|
+
const classMatch = classRegex.exec(line);
|
|
66
|
+
if (classMatch) {
|
|
67
|
+
const name = classMatch[1];
|
|
68
|
+
const nodeId = `class:${filePath}:${name}`;
|
|
69
|
+
nodes.push({ id: nodeId, kind: NodeKind.Class, name, filePath, lineStart: lineNum, isTest, updatedAt: now });
|
|
70
|
+
const edgeKey = `CONTAINS:${fileNodeId}:${nodeId}`;
|
|
71
|
+
if (!edgeSet.has(edgeKey)) {
|
|
72
|
+
edgeSet.add(edgeKey);
|
|
73
|
+
edges.push({ kind: EdgeKind.CONTAINS, sourceId: fileNodeId, targetId: nodeId, line: lineNum, updatedAt: now });
|
|
74
|
+
}
|
|
75
|
+
// Inheritance
|
|
76
|
+
const parent = classMatch[2];
|
|
77
|
+
if (parent) {
|
|
78
|
+
const parentId = `class:${filePath}:${parent}`;
|
|
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
|
+
currentClassId = nodeId;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
// Method (only inside a class)
|
|
89
|
+
if (currentClassId) {
|
|
90
|
+
const methodMatch = methodRegex.exec(line);
|
|
91
|
+
if (methodMatch && !line.includes('class ') && !line.includes('interface ')) {
|
|
92
|
+
const name = methodMatch[1];
|
|
93
|
+
if (name !== 'if' && name !== 'while' && name !== 'for' && name !== 'return') {
|
|
94
|
+
const nodeId = `function:${filePath}:${name}`;
|
|
95
|
+
nodes.push({ id: nodeId, kind: NodeKind.Function, name, filePath, lineStart: lineNum, isTest, updatedAt: now });
|
|
96
|
+
const edgeKey = `CONTAINS:${currentClassId}:${nodeId}`;
|
|
97
|
+
if (!edgeSet.has(edgeKey)) {
|
|
98
|
+
edgeSet.add(edgeKey);
|
|
99
|
+
edges.push({ kind: EdgeKind.CONTAINS, sourceId: currentClassId, targetId: nodeId, line: lineNum, updatedAt: now });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return { nodes, edges, fileHash };
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=java.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java.js","sourceRoot":"","sources":["../../../../src/code-graph/plugins/java.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,WAAW,CAAC;QAC9B,Q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AE,CAAC,CAAC;wBAChH,MAAM,OAAO,GAAG,YAAY,cAAc,IAAI,MAAM,EAAE,CAAC;wBACvD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;4BAC1B,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;4BACrB,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;wBACrH,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IACpC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kotlin.d.ts","sourceRoot":"","sources":["../../../../src/code-graph/plugins/kotlin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAA6C,MAAM,aAAa,CAAC;AAU7F,eAAO,MAAM,YAAY,EAAE,cA4F1B,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
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('Test.kt') ||
|
|
6
|
+
filePath.includes('/test/') ||
|
|
7
|
+
filePath.includes('/androidTest/'));
|
|
8
|
+
}
|
|
9
|
+
export const kotlinPlugin = {
|
|
10
|
+
language: 'kotlin',
|
|
11
|
+
extensions: ['.kt', '.kts'],
|
|
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+|suspend\s+|inline\s+|private\s+|internal\s+|public\s+|protected\s+)*fun\s+(\w+)\s*(?:<[^>]*>)?\s*\(/;
|
|
31
|
+
const classRegex = /(?:data\s+|sealed\s+|abstract\s+|open\s+|inner\s+)?(?:class|object|interface)\s+(\w+)(?:\s*(?::\s*([\w<>, ]+))?)?/;
|
|
32
|
+
const importRegex = /^import\s+([\w.]+)/;
|
|
33
|
+
for (let i = 0; i < lines.length; i++) {
|
|
34
|
+
const line = lines[i];
|
|
35
|
+
const lineNum = i + 1;
|
|
36
|
+
// Import
|
|
37
|
+
const importMatch = importRegex.exec(line.trim());
|
|
38
|
+
if (importMatch) {
|
|
39
|
+
const pkg = importMatch[1];
|
|
40
|
+
if (pkg.includes('.')) {
|
|
41
|
+
const targetId = `file:${pkg.replace(/\./g, '/')}`;
|
|
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
|
+
}
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
// Class / object / interface
|
|
51
|
+
const classMatch = classRegex.exec(line.trim());
|
|
52
|
+
if (classMatch && !line.trim().startsWith('//')) {
|
|
53
|
+
const name = classMatch[1];
|
|
54
|
+
const parentStr = classMatch[2];
|
|
55
|
+
const nodeId = `class:${filePath}:${name}`;
|
|
56
|
+
nodes.push({ id: nodeId, kind: NodeKind.Class, name, filePath, lineStart: lineNum, isTest, updatedAt: now });
|
|
57
|
+
const edgeKey = `CONTAINS:${fileNodeId}:${nodeId}`;
|
|
58
|
+
if (!edgeSet.has(edgeKey)) {
|
|
59
|
+
edgeSet.add(edgeKey);
|
|
60
|
+
edges.push({ kind: EdgeKind.CONTAINS, sourceId: fileNodeId, targetId: nodeId, line: lineNum, updatedAt: now });
|
|
61
|
+
}
|
|
62
|
+
// Inheritance (first part before comma = superclass)
|
|
63
|
+
if (parentStr) {
|
|
64
|
+
const firstParent = (parentStr.split(',')[0] ?? '').trim().replace(/\(.*\)/, '').trim();
|
|
65
|
+
if (firstParent) {
|
|
66
|
+
const parentId = `class:${filePath}:${firstParent}`;
|
|
67
|
+
const inheritKey = `INHERITS:${nodeId}:${parentId}`;
|
|
68
|
+
if (!edgeSet.has(inheritKey)) {
|
|
69
|
+
edgeSet.add(inheritKey);
|
|
70
|
+
edges.push({ kind: EdgeKind.INHERITS, sourceId: nodeId, targetId: parentId, line: lineNum, updatedAt: now });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
// Function
|
|
77
|
+
const funcMatch = funcRegex.exec(line.trim());
|
|
78
|
+
if (funcMatch) {
|
|
79
|
+
const name = funcMatch[1];
|
|
80
|
+
if (name) {
|
|
81
|
+
const nodeId = `function:${filePath}:${name}`;
|
|
82
|
+
nodes.push({ id: nodeId, kind: NodeKind.Function, name, filePath, lineStart: lineNum, isTest, updatedAt: now });
|
|
83
|
+
const edgeKey = `CONTAINS:${fileNodeId}:${nodeId}`;
|
|
84
|
+
if (!edgeSet.has(edgeKey)) {
|
|
85
|
+
edgeSet.add(edgeKey);
|
|
86
|
+
edges.push({ kind: EdgeKind.CONTAINS, sourceId: fileNodeId, targetId: nodeId, line: lineNum, updatedAt: now });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return { nodes, edges, fileHash };
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=kotlin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kotlin.js","sourceRoot":"","sources":["../../../../src/code-graph/plugins/kotlin.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,eAAe,CAAC,CACnC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAmB;IAC1C,QAAQ,EAAE,QAAQ;IAClB,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;IAE3B,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,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;QACpC,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,EA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,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;oBACjH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IACpC,CAAC;CACF,CAAC"}
|
|
@@ -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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AK,EAAE,QAAQ,EAAE,CAAC;IACpC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"python.d.ts","sourceRoot":"","sources":["../../../../src/code-graph/plugins/python.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAA6C,MAAM,aAAa,CAAC;AAa7F,eAAO,MAAM,YAAY,EAAE,cAgH1B,CAAC"}
|
|
@@ -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/plug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