mcp-codebase-intelligence 0.1.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/LICENSE +21 -0
- package/README.md +166 -0
- package/dist/graph/code-graph.d.ts +119 -0
- package/dist/graph/code-graph.js +279 -0
- package/dist/graph/code-graph.js.map +1 -0
- package/dist/graph/schema.d.ts +2 -0
- package/dist/graph/schema.js +62 -0
- package/dist/graph/schema.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +171 -0
- package/dist/index.js.map +1 -0
- package/dist/indexer/file-watcher.d.ts +13 -0
- package/dist/indexer/file-watcher.js +106 -0
- package/dist/indexer/file-watcher.js.map +1 -0
- package/dist/indexer/lang-go.d.ts +2 -0
- package/dist/indexer/lang-go.js +246 -0
- package/dist/indexer/lang-go.js.map +1 -0
- package/dist/indexer/lang-java.d.ts +2 -0
- package/dist/indexer/lang-java.js +307 -0
- package/dist/indexer/lang-java.js.map +1 -0
- package/dist/indexer/lang-python.d.ts +2 -0
- package/dist/indexer/lang-python.js +232 -0
- package/dist/indexer/lang-python.js.map +1 -0
- package/dist/indexer/lang-rust.d.ts +2 -0
- package/dist/indexer/lang-rust.js +323 -0
- package/dist/indexer/lang-rust.js.map +1 -0
- package/dist/indexer/language-plugin.d.ts +22 -0
- package/dist/indexer/language-plugin.js +22 -0
- package/dist/indexer/language-plugin.js.map +1 -0
- package/dist/indexer/tree-sitter-indexer.d.ts +12 -0
- package/dist/indexer/tree-sitter-indexer.js +618 -0
- package/dist/indexer/tree-sitter-indexer.js.map +1 -0
- package/dist/lsp/lsp-client.d.ts +45 -0
- package/dist/lsp/lsp-client.js +315 -0
- package/dist/lsp/lsp-client.js.map +1 -0
- package/dist/lsp/lsp-manager.d.ts +13 -0
- package/dist/lsp/lsp-manager.js +96 -0
- package/dist/lsp/lsp-manager.js.map +1 -0
- package/dist/tools/analyze-impact.d.ts +38 -0
- package/dist/tools/analyze-impact.js +126 -0
- package/dist/tools/analyze-impact.js.map +1 -0
- package/dist/tools/architecture-diagram.d.ts +33 -0
- package/dist/tools/architecture-diagram.js +216 -0
- package/dist/tools/architecture-diagram.js.map +1 -0
- package/dist/tools/find-implementations.d.ts +33 -0
- package/dist/tools/find-implementations.js +68 -0
- package/dist/tools/find-implementations.js.map +1 -0
- package/dist/tools/find-symbol.d.ts +39 -0
- package/dist/tools/find-symbol.js +52 -0
- package/dist/tools/find-symbol.js.map +1 -0
- package/dist/tools/get-call-graph.d.ts +40 -0
- package/dist/tools/get-call-graph.js +174 -0
- package/dist/tools/get-call-graph.js.map +1 -0
- package/dist/tools/get-dependencies.d.ts +28 -0
- package/dist/tools/get-dependencies.js +68 -0
- package/dist/tools/get-dependencies.js.map +1 -0
- package/dist/tools/get-exports.d.ts +23 -0
- package/dist/tools/get-exports.js +40 -0
- package/dist/tools/get-exports.js.map +1 -0
- package/dist/tools/get-references.d.ts +28 -0
- package/dist/tools/get-references.js +53 -0
- package/dist/tools/get-references.js.map +1 -0
- package/dist/tools/get-stats.d.ts +15 -0
- package/dist/tools/get-stats.js +23 -0
- package/dist/tools/get-stats.js.map +1 -0
- package/dist/tools/get-type-info.d.ts +33 -0
- package/dist/tools/get-type-info.js +69 -0
- package/dist/tools/get-type-info.js.map +1 -0
- package/dist/tools/goto-definition.d.ts +33 -0
- package/dist/tools/goto-definition.js +77 -0
- package/dist/tools/goto-definition.js.map +1 -0
- package/dist/tools/natural-language-query.d.ts +23 -0
- package/dist/tools/natural-language-query.js +426 -0
- package/dist/tools/natural-language-query.js.map +1 -0
- package/dist/tools/reindex.d.ts +15 -0
- package/dist/tools/reindex.js +20 -0
- package/dist/tools/reindex.js.map +1 -0
- package/dist/tools/semantic-diff.d.ts +32 -0
- package/dist/tools/semantic-diff.js +407 -0
- package/dist/tools/semantic-diff.js.map +1 -0
- package/dist/utils/logger.d.ts +6 -0
- package/dist/utils/logger.js +15 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
export const getCallGraphTool = {
|
|
2
|
+
name: "get_call_graph",
|
|
3
|
+
description: "Get the call graph for a function — who calls it (callers) and what it calls (callees). Returns as a tree or mermaid diagram.",
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object",
|
|
6
|
+
properties: {
|
|
7
|
+
function_name: {
|
|
8
|
+
type: "string",
|
|
9
|
+
description: "Name of the function to get the call graph for",
|
|
10
|
+
},
|
|
11
|
+
direction: {
|
|
12
|
+
type: "string",
|
|
13
|
+
enum: ["callers", "callees", "both"],
|
|
14
|
+
description: "Direction of the graph (default: both)",
|
|
15
|
+
},
|
|
16
|
+
depth: {
|
|
17
|
+
type: "number",
|
|
18
|
+
description: "How many levels to traverse (default: 2, max: 5)",
|
|
19
|
+
},
|
|
20
|
+
format: {
|
|
21
|
+
type: "string",
|
|
22
|
+
enum: ["tree", "mermaid"],
|
|
23
|
+
description: "Output format (default: tree)",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
required: ["function_name"],
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
export function handleGetCallGraph(graph, args) {
|
|
30
|
+
const direction = args.direction ?? "both";
|
|
31
|
+
const depth = Math.min(Math.max(args.depth ?? 2, 1), 5);
|
|
32
|
+
const format = args.format ?? "tree";
|
|
33
|
+
const sections = [];
|
|
34
|
+
// Callers: who calls this function?
|
|
35
|
+
if (direction === "callers" || direction === "both") {
|
|
36
|
+
const callers = graph.getReferences(args.function_name, depth);
|
|
37
|
+
if (callers.length > 0) {
|
|
38
|
+
if (format === "mermaid") {
|
|
39
|
+
sections.push(buildMermaid(args.function_name, callers, "callers"));
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
sections.push(buildTree(args.function_name, callers, "callers"));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
sections.push(`Callers of "${args.function_name}": none found`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Callees: what does this function call?
|
|
50
|
+
if (direction === "callees" || direction === "both") {
|
|
51
|
+
const db = graph.getDb();
|
|
52
|
+
const callees = getCallees(db, args.function_name, depth);
|
|
53
|
+
if (callees.length > 0) {
|
|
54
|
+
if (format === "mermaid") {
|
|
55
|
+
sections.push(buildCalleeMermaid(args.function_name, callees));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
sections.push(buildCalleeTree(args.function_name, callees));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
sections.push(`Callees of "${args.function_name}": none found`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
content: [
|
|
67
|
+
{
|
|
68
|
+
type: "text",
|
|
69
|
+
text: sections.join("\n\n"),
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function getCallees(db, functionName, maxDepth) {
|
|
75
|
+
const sql = `
|
|
76
|
+
WITH RECURSIVE callee_chain(caller_name, callee_name, callee_bare, ref_kind, line, depth) AS (
|
|
77
|
+
-- Base: what does the target function call?
|
|
78
|
+
SELECT s.name, r.to_symbol_name, r.to_symbol_bare_name, r.kind, r.line, 1
|
|
79
|
+
FROM symbols s
|
|
80
|
+
JOIN references_ r ON r.from_symbol_id = s.id
|
|
81
|
+
WHERE s.name = ? AND r.kind IN ('call', 'instantiation')
|
|
82
|
+
|
|
83
|
+
UNION ALL
|
|
84
|
+
|
|
85
|
+
-- Recursive: what do those callees call?
|
|
86
|
+
SELECT s.name, r.to_symbol_name, r.to_symbol_bare_name, r.kind, r.line, cc.depth + 1
|
|
87
|
+
FROM symbols s
|
|
88
|
+
JOIN references_ r ON r.from_symbol_id = s.id
|
|
89
|
+
JOIN callee_chain cc ON s.name = cc.callee_bare OR s.name = cc.callee_name
|
|
90
|
+
WHERE cc.depth < ? AND r.kind IN ('call', 'instantiation')
|
|
91
|
+
)
|
|
92
|
+
SELECT callee_name as callee, callee_bare as calleeBare, ref_kind as refKind, line, depth
|
|
93
|
+
FROM callee_chain
|
|
94
|
+
ORDER BY depth, line
|
|
95
|
+
LIMIT 100
|
|
96
|
+
`;
|
|
97
|
+
return db.prepare(sql).all(functionName, maxDepth);
|
|
98
|
+
}
|
|
99
|
+
function buildTree(rootName, refs, label) {
|
|
100
|
+
const lines = [`${label === "callers" ? "Callers" : "Callees"} of "${rootName}":`];
|
|
101
|
+
lines.push(` ${rootName}`);
|
|
102
|
+
const byDepth = new Map();
|
|
103
|
+
for (const ref of refs) {
|
|
104
|
+
const list = byDepth.get(ref.depth) ?? [];
|
|
105
|
+
list.push(ref);
|
|
106
|
+
byDepth.set(ref.depth, list);
|
|
107
|
+
}
|
|
108
|
+
for (const [d, depthRefs] of byDepth) {
|
|
109
|
+
const indent = " ".repeat(d + 1);
|
|
110
|
+
const seen = new Set();
|
|
111
|
+
for (const ref of depthRefs) {
|
|
112
|
+
const key = `${ref.fromSymbol}:${ref.fromFile}`;
|
|
113
|
+
if (seen.has(key))
|
|
114
|
+
continue;
|
|
115
|
+
seen.add(key);
|
|
116
|
+
lines.push(`${indent}<-- ${ref.fromSymbol} (${ref.fromFile}:${ref.fromLine})`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return lines.join("\n");
|
|
120
|
+
}
|
|
121
|
+
function buildCalleeTree(rootName, callees) {
|
|
122
|
+
const lines = [`Callees of "${rootName}":`];
|
|
123
|
+
lines.push(` ${rootName}`);
|
|
124
|
+
const byDepth = new Map();
|
|
125
|
+
for (const c of callees) {
|
|
126
|
+
const list = byDepth.get(c.depth) ?? [];
|
|
127
|
+
list.push(c);
|
|
128
|
+
byDepth.set(c.depth, list);
|
|
129
|
+
}
|
|
130
|
+
for (const [d, depthCallees] of byDepth) {
|
|
131
|
+
const indent = " ".repeat(d + 1);
|
|
132
|
+
const seen = new Set();
|
|
133
|
+
for (const c of depthCallees) {
|
|
134
|
+
if (seen.has(c.callee))
|
|
135
|
+
continue;
|
|
136
|
+
seen.add(c.callee);
|
|
137
|
+
lines.push(`${indent}--> ${c.callee} [${c.refKind}] (line ${c.line})`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return lines.join("\n");
|
|
141
|
+
}
|
|
142
|
+
function buildMermaid(rootName, refs, label) {
|
|
143
|
+
const lines = ["```mermaid", "graph TD"];
|
|
144
|
+
const sanitize = (s) => s.replace(/[^a-zA-Z0-9_]/g, "_");
|
|
145
|
+
const edges = new Set();
|
|
146
|
+
for (const ref of refs) {
|
|
147
|
+
const from = sanitize(ref.fromSymbol);
|
|
148
|
+
const to = sanitize(rootName);
|
|
149
|
+
const edge = ` ${from}["${ref.fromSymbol}"] -->|${ref.refKind}| ${to}["${rootName}"]`;
|
|
150
|
+
if (!edges.has(edge)) {
|
|
151
|
+
edges.add(edge);
|
|
152
|
+
lines.push(edge);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
lines.push("```");
|
|
156
|
+
return `Callers of "${rootName}" (mermaid):\n${lines.join("\n")}`;
|
|
157
|
+
}
|
|
158
|
+
function buildCalleeMermaid(rootName, callees) {
|
|
159
|
+
const lines = ["```mermaid", "graph TD"];
|
|
160
|
+
const sanitize = (s) => s.replace(/[^a-zA-Z0-9_]/g, "_");
|
|
161
|
+
const edges = new Set();
|
|
162
|
+
for (const c of callees) {
|
|
163
|
+
const from = sanitize(rootName);
|
|
164
|
+
const to = sanitize(c.calleeBare);
|
|
165
|
+
const edge = ` ${from}["${rootName}"] -->|${c.refKind}| ${to}["${c.calleeBare}"]`;
|
|
166
|
+
if (!edges.has(edge)) {
|
|
167
|
+
edges.add(edge);
|
|
168
|
+
lines.push(edge);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
lines.push("```");
|
|
172
|
+
return `Callees of "${rootName}" (mermaid):\n${lines.join("\n")}`;
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=get-call-graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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AAC;IACjE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAEhC,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAChC,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;QAClC,MAAM,IAAI,GAAG,KAAK,IAAI,KAAK,QAAQ,UAAU,CAAC,CAAC,OAAO,KAAK,EAAE,KAAK,CAAC,CAAC,UAAU,IAAI,CAAC;QACnF,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAChB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,OAAO,eAAe,QAAQ,iBAAiB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CodeGraph } from "../graph/code-graph.js";
|
|
2
|
+
export declare const getDependenciesTool: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {
|
|
8
|
+
file_path: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
depth: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
required: string[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare function handleGetDependencies(graph: CodeGraph, args: {
|
|
21
|
+
file_path: string;
|
|
22
|
+
depth?: number;
|
|
23
|
+
}): {
|
|
24
|
+
content: {
|
|
25
|
+
type: "text";
|
|
26
|
+
text: string;
|
|
27
|
+
}[];
|
|
28
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export const getDependenciesTool = {
|
|
2
|
+
name: "get_dependencies",
|
|
3
|
+
description: "Get the import/dependency graph for a file — what it imports and optionally what those files import (transitive).",
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object",
|
|
6
|
+
properties: {
|
|
7
|
+
file_path: {
|
|
8
|
+
type: "string",
|
|
9
|
+
description: "Absolute path to the file to inspect",
|
|
10
|
+
},
|
|
11
|
+
depth: {
|
|
12
|
+
type: "number",
|
|
13
|
+
description: "How many levels of transitive dependencies to follow (default: 1, max: 5)",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
required: ["file_path"],
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
export function handleGetDependencies(graph, args) {
|
|
20
|
+
const imports = graph.getImports(args.file_path);
|
|
21
|
+
if (imports.length === 0) {
|
|
22
|
+
return {
|
|
23
|
+
content: [
|
|
24
|
+
{
|
|
25
|
+
type: "text",
|
|
26
|
+
text: `No imports found in "${args.file_path}"`,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
// Group imports by source
|
|
32
|
+
const bySource = new Map();
|
|
33
|
+
for (const imp of imports) {
|
|
34
|
+
const list = bySource.get(imp.sourcePath) ?? [];
|
|
35
|
+
list.push(imp);
|
|
36
|
+
bySource.set(imp.sourcePath, list);
|
|
37
|
+
}
|
|
38
|
+
const sections = [];
|
|
39
|
+
for (const [source, sourceImports] of bySource) {
|
|
40
|
+
const names = sourceImports.map((i) => {
|
|
41
|
+
if (i.isNamespace)
|
|
42
|
+
return `* as ${i.localName}`;
|
|
43
|
+
if (i.isDefault)
|
|
44
|
+
return `${i.localName} (default)`;
|
|
45
|
+
return i.importedName === i.localName ? i.importedName : `${i.importedName} as ${i.localName}`;
|
|
46
|
+
});
|
|
47
|
+
sections.push(` from "${source}": ${names.join(", ")}`);
|
|
48
|
+
}
|
|
49
|
+
// Also get transitive dependencies if requested
|
|
50
|
+
let transitiveSection = "";
|
|
51
|
+
const depth = args.depth ?? 1;
|
|
52
|
+
if (depth > 1) {
|
|
53
|
+
const deps = graph.getDependencyGraph(args.file_path, depth);
|
|
54
|
+
if (deps.length > 0) {
|
|
55
|
+
const transLines = deps.map((d) => ` ${" ".repeat(d.depth - 1)}${d.file} -> ${d.imports}`);
|
|
56
|
+
transitiveSection = `\n\nDependency tree (depth ${depth}):\n${transLines.join("\n")}`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
type: "text",
|
|
63
|
+
text: `Imports in ${args.file_path} (${imports.length} from ${bySource.size} modules):\n\n${sections.join("\n")}${transitiveSection}`,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=get-dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-dependencies.js","sourceRoot":"","sources":["../../src/tools/get-dependencies.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EACT,mHAAmH;IACrH,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,sCAAsC;aACpD;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,2EAA2E;aACzF;SACF;QACD,QAAQ,EAAE,CAAC,WAAW,CAAC;KACxB;CACF,CAAC;AAEF,MAAM,UAAU,qBAAqB,CACnC,KAAgB,EAChB,IAA2C;IAE3C,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAEjD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAA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,KAAK,IAAI,CAAC,CAAC;IAC9B,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,MAAM,IAAI,GAAG,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC7D,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpB,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YAC7F,iBAAiB,GAAG,8BAA8B,KAAK,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACxF,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,cAAc,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC,MAAM,SAAS,QAAQ,CAAC,IAAI,iBAAiB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,iBAAiB,EAAE;aACtI;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CodeGraph } from "../graph/code-graph.js";
|
|
2
|
+
export declare const getExportsTool: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {
|
|
8
|
+
file_path: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
required: string[];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare function handleGetExports(graph: CodeGraph, args: {
|
|
17
|
+
file_path: string;
|
|
18
|
+
}): {
|
|
19
|
+
content: {
|
|
20
|
+
type: "text";
|
|
21
|
+
text: string;
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const getExportsTool = {
|
|
2
|
+
name: "get_exports",
|
|
3
|
+
description: "Get the public API surface of a file or module — all exported symbols with their types and signatures.",
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object",
|
|
6
|
+
properties: {
|
|
7
|
+
file_path: {
|
|
8
|
+
type: "string",
|
|
9
|
+
description: "Absolute path to the file to inspect",
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
required: ["file_path"],
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export function handleGetExports(graph, args) {
|
|
16
|
+
const exports = graph.getExports(args.file_path);
|
|
17
|
+
if (exports.length === 0) {
|
|
18
|
+
return {
|
|
19
|
+
content: [
|
|
20
|
+
{
|
|
21
|
+
type: "text",
|
|
22
|
+
text: `No exports found in "${args.file_path}"`,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const formatted = exports.map((e) => {
|
|
28
|
+
const sig = e.signature ? ` — ${e.signature}` : "";
|
|
29
|
+
return ` ${e.kind} ${e.name} (line ${e.lineStart})${sig}`;
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
content: [
|
|
33
|
+
{
|
|
34
|
+
type: "text",
|
|
35
|
+
text: `Exports from ${args.file_path} (${exports.length}):\n\n${formatted.join("\n")}`,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=get-exports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-exports.js","sourceRoot":"","sources":["../../src/tools/get-exports.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,wGAAwG;IAC1G,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,sCAAsC;aACpD;SACF;QACD,QAAQ,EAAE,CAAC,WAAW,CAAC;KACxB;CACF,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAC9B,KAAgB,EAChB,IAA2B;IAE3B,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAEjD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,wBAAwB,IAAI,CAAC,SAAS,GAAG;iBAChD;aACF;SACF,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAClC,MAAM,GAAG,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,SAAS,IAAI,GAAG,EAAE,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,gBAAgB,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC,MAAM,SAAS,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;aACvF;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CodeGraph } from "../graph/code-graph.js";
|
|
2
|
+
export declare const getReferencesTool: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {
|
|
8
|
+
symbol_name: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
depth: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
required: string[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare function handleGetReferences(graph: CodeGraph, args: {
|
|
21
|
+
symbol_name: string;
|
|
22
|
+
depth?: number;
|
|
23
|
+
}): {
|
|
24
|
+
content: {
|
|
25
|
+
type: "text";
|
|
26
|
+
text: string;
|
|
27
|
+
}[];
|
|
28
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export const getReferencesTool = {
|
|
2
|
+
name: "get_references",
|
|
3
|
+
description: "Find all references to a symbol — who calls it, uses it, or depends on it. Supports transitive reference discovery via depth parameter.",
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object",
|
|
6
|
+
properties: {
|
|
7
|
+
symbol_name: {
|
|
8
|
+
type: "string",
|
|
9
|
+
description: "Name of the symbol to find references for",
|
|
10
|
+
},
|
|
11
|
+
depth: {
|
|
12
|
+
type: "number",
|
|
13
|
+
description: "How many levels of transitive references to follow (1 = direct only, default: 1, max: 10)",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
required: ["symbol_name"],
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
export function handleGetReferences(graph, args) {
|
|
20
|
+
const refs = graph.getReferences(args.symbol_name, args.depth ?? 1);
|
|
21
|
+
if (refs.length === 0) {
|
|
22
|
+
return {
|
|
23
|
+
content: [
|
|
24
|
+
{
|
|
25
|
+
type: "text",
|
|
26
|
+
text: `No references found for "${args.symbol_name}"`,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
// Group by depth
|
|
32
|
+
const byDepth = new Map();
|
|
33
|
+
for (const ref of refs) {
|
|
34
|
+
const list = byDepth.get(ref.depth) ?? [];
|
|
35
|
+
list.push(ref);
|
|
36
|
+
byDepth.set(ref.depth, list);
|
|
37
|
+
}
|
|
38
|
+
const sections = [];
|
|
39
|
+
for (const [depth, depthRefs] of byDepth) {
|
|
40
|
+
const label = depth === 1 ? "Direct references" : `Depth ${depth} (transitive)`;
|
|
41
|
+
const lines = depthRefs.map((r) => ` ${r.fromKind} ${r.fromSymbol} (${r.fromFile}:${r.fromLine}) --[${r.refKind}]--> ${r.toSymbol} at line ${r.refLine}`);
|
|
42
|
+
sections.push(`${label}:\n${lines.join("\n")}`);
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
content: [
|
|
46
|
+
{
|
|
47
|
+
type: "text",
|
|
48
|
+
text: `References to "${args.symbol_name}" (${refs.length} total):\n\n${sections.join("\n\n")}`,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=get-references.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-references.js","sourceRoot":"","sources":["../../src/tools/get-references.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACT,yIAAyI;IAC3I,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,2CAA2C;aACzD;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,2FAA2F;aAC9F;SACF;QACD,QAAQ,EAAE,CAAC,aAAa,CAAC;KAC1B;CACF,CAAC;AAEF,MAAM,UAAU,mBAAmB,CACjC,KAAgB,EAChB,IAA6C;IAE7C,MAAM,IAAI,GAAG,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;IAEpE,IAAI,IAAI,CAAC,MAAM,KAAK,C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AAe,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;aAChG;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CodeGraph } from "../graph/code-graph.js";
|
|
2
|
+
export declare const getStatsTool: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {};
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare function handleGetStats(graph: CodeGraph, projectRoot?: string): {
|
|
11
|
+
content: {
|
|
12
|
+
type: "text";
|
|
13
|
+
text: string;
|
|
14
|
+
}[];
|
|
15
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const getStatsTool = {
|
|
2
|
+
name: "get_index_stats",
|
|
3
|
+
description: "Get statistics about the indexed codebase — number of files, symbols, references, and imports.",
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object",
|
|
6
|
+
properties: {},
|
|
7
|
+
},
|
|
8
|
+
};
|
|
9
|
+
export function handleGetStats(graph, projectRoot) {
|
|
10
|
+
const stats = graph.getStats();
|
|
11
|
+
const header = projectRoot
|
|
12
|
+
? `Indexed project: ${projectRoot}\n\n`
|
|
13
|
+
: "";
|
|
14
|
+
return {
|
|
15
|
+
content: [
|
|
16
|
+
{
|
|
17
|
+
type: "text",
|
|
18
|
+
text: `${header}Codebase index statistics:\n Files indexed: ${stats.files}\n Symbols: ${stats.symbols}\n References: ${stats.references}\n Imports: ${stats.imports}`,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=get-stats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-stats.js","sourceRoot":"","sources":["../../src/tools/get-stats.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,gGAAgG;IAC7G,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE,EAAE;KACf;CACF,CAAC;AAEF,MAAM,UAAU,cAAc,CAAC,KAAgB,EAAE,WAAoB;IACnE,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;IAE/B,MAAM,MAAM,GAAG,WAAW;QACxB,CAAC,CAAC,oBAAoB,WAAW,MAAM;QACvC,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,GAAG,MAAM,gDAAgD,KAAK,CAAC,KAAK,gBAAgB,KAAK,CAAC,OAAO,mBAAmB,KAAK,CAAC,UAAU,gBAAgB,KAAK,CAAC,OAAO,EAAE;aAC1K;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { LspManager } from "../lsp/lsp-manager.js";
|
|
2
|
+
export declare const getTypeInfoTool: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {
|
|
8
|
+
file_path: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
line: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
character: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
required: string[];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare function handleGetTypeInfo(lspManager: LspManager, args: {
|
|
25
|
+
file_path: string;
|
|
26
|
+
line: number;
|
|
27
|
+
character: number;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
content: {
|
|
30
|
+
type: "text";
|
|
31
|
+
text: string;
|
|
32
|
+
}[];
|
|
33
|
+
}>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export const getTypeInfoTool = {
|
|
2
|
+
name: "get_type_info",
|
|
3
|
+
description: "Get the type information for a symbol at a specific position. Uses LSP to resolve the full type, including generics, union types, and inferred types.",
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object",
|
|
6
|
+
properties: {
|
|
7
|
+
file_path: {
|
|
8
|
+
type: "string",
|
|
9
|
+
description: "Absolute path to the file",
|
|
10
|
+
},
|
|
11
|
+
line: {
|
|
12
|
+
type: "number",
|
|
13
|
+
description: "Line number (1-based)",
|
|
14
|
+
},
|
|
15
|
+
character: {
|
|
16
|
+
type: "number",
|
|
17
|
+
description: "Column number (0-based)",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
required: ["file_path", "line", "character"],
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
export async function handleGetTypeInfo(lspManager, args) {
|
|
24
|
+
const client = lspManager.getClientForFile(args.file_path);
|
|
25
|
+
if (!client) {
|
|
26
|
+
return {
|
|
27
|
+
content: [
|
|
28
|
+
{
|
|
29
|
+
type: "text",
|
|
30
|
+
text: `No LSP server available for ${args.file_path}. LSP features require a running language server.`,
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
// Get hover info (contains type information)
|
|
36
|
+
const hoverInfo = await client.getHover(args.file_path, args.line, args.character);
|
|
37
|
+
// Also try to get type definition location
|
|
38
|
+
const typeDefs = await client.getTypeDefinition(args.file_path, args.line, args.character);
|
|
39
|
+
const sections = [];
|
|
40
|
+
if (hoverInfo) {
|
|
41
|
+
sections.push(`Type info at ${args.file_path}:${args.line}:${args.character}:\n\n${hoverInfo}`);
|
|
42
|
+
}
|
|
43
|
+
if (typeDefs.length > 0) {
|
|
44
|
+
const defLines = typeDefs.map((loc) => {
|
|
45
|
+
const filePath = loc.uri.replace("file://", "");
|
|
46
|
+
return ` ${filePath}:${loc.line}:${loc.character}`;
|
|
47
|
+
});
|
|
48
|
+
sections.push(`Type defined at:\n${defLines.join("\n")}`);
|
|
49
|
+
}
|
|
50
|
+
if (sections.length === 0) {
|
|
51
|
+
return {
|
|
52
|
+
content: [
|
|
53
|
+
{
|
|
54
|
+
type: "text",
|
|
55
|
+
text: `No type information available at ${args.file_path}:${args.line}:${args.character}`,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
content: [
|
|
62
|
+
{
|
|
63
|
+
type: "text",
|
|
64
|
+
text: sections.join("\n\n"),
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=get-type-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-type-info.js","sourceRoot":"","sources":["../../src/tools/get-type-info.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,eAAe;IACrB,WAAW,EACT,uJAAuJ;IACzJ,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,2BAA2B;aACzC;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,uBAAuB;aACrC;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yBAAyB;aACvC;SACF;QACD,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,CAAC;KAC7C;CACF,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,UAAsB,EACtB,IAA4D;IAE5D,MAAM,MAAM,GAAG,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC3D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,I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,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE;iBAC1F;aACF;SACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;aAC5B;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { LspManager } from "../lsp/lsp-manager.js";
|
|
2
|
+
export declare const gotoDefinitionTool: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {
|
|
8
|
+
file_path: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
line: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
character: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
required: string[];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare function handleGotoDefinition(lspManager: LspManager, args: {
|
|
25
|
+
file_path: string;
|
|
26
|
+
line: number;
|
|
27
|
+
character: number;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
content: {
|
|
30
|
+
type: "text";
|
|
31
|
+
text: string;
|
|
32
|
+
}[];
|
|
33
|
+
}>;
|