src-mcp 1.0.1 → 1.0.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/dist/bin.d.mts +1 -0
- package/dist/bin.mjs +205 -0
- package/dist/bin.mjs.map +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +8 -0
- package/dist/index.mjs.map +1 -0
- package/dist/server-B2Ms4jQx.mjs +3889 -0
- package/dist/server-B2Ms4jQx.mjs.map +1 -0
- package/package.json +10 -9
- package/dist/bin.d.ts +0 -3
- package/dist/bin.d.ts.map +0 -1
- package/dist/bin.js +0 -4
- package/dist/bin.js.map +0 -1
- package/dist/cli/adapter.d.ts +0 -7
- package/dist/cli/adapter.d.ts.map +0 -1
- package/dist/cli/adapter.js +0 -39
- package/dist/cli/adapter.js.map +0 -1
- package/dist/cli/commands/index.d.ts +0 -24
- package/dist/cli/commands/index.d.ts.map +0 -1
- package/dist/cli/commands/index.js +0 -13
- package/dist/cli/commands/index.js.map +0 -1
- package/dist/cli/commands/serve.command.d.ts +0 -21
- package/dist/cli/commands/serve.command.d.ts.map +0 -1
- package/dist/cli/commands/serve.command.js +0 -62
- package/dist/cli/commands/serve.command.js.map +0 -1
- package/dist/cli/commands/version.command.d.ts +0 -2
- package/dist/cli/commands/version.command.d.ts.map +0 -1
- package/dist/cli/commands/version.command.js +0 -12
- package/dist/cli/commands/version.command.js.map +0 -1
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -15
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/parser.d.ts +0 -7
- package/dist/cli/parser.d.ts.map +0 -1
- package/dist/cli/parser.js +0 -99
- package/dist/cli/parser.js.map +0 -1
- package/dist/config/index.d.ts +0 -24
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js +0 -38
- package/dist/config/index.js.map +0 -1
- package/dist/core/ast/index.d.ts +0 -82
- package/dist/core/ast/index.d.ts.map +0 -1
- package/dist/core/ast/index.js +0 -204
- package/dist/core/ast/index.js.map +0 -1
- package/dist/core/ast/types.d.ts +0 -152
- package/dist/core/ast/types.d.ts.map +0 -1
- package/dist/core/ast/types.js +0 -5
- package/dist/core/ast/types.js.map +0 -1
- package/dist/core/constants.d.ts +0 -17
- package/dist/core/constants.d.ts.map +0 -1
- package/dist/core/constants.js +0 -49
- package/dist/core/constants.js.map +0 -1
- package/dist/core/embeddings/callgraph.d.ts +0 -98
- package/dist/core/embeddings/callgraph.d.ts.map +0 -1
- package/dist/core/embeddings/callgraph.js +0 -415
- package/dist/core/embeddings/callgraph.js.map +0 -1
- package/dist/core/embeddings/chunker.d.ts +0 -37
- package/dist/core/embeddings/chunker.d.ts.map +0 -1
- package/dist/core/embeddings/chunker.js +0 -298
- package/dist/core/embeddings/chunker.js.map +0 -1
- package/dist/core/embeddings/client.d.ts +0 -30
- package/dist/core/embeddings/client.d.ts.map +0 -1
- package/dist/core/embeddings/client.js +0 -65
- package/dist/core/embeddings/client.js.map +0 -1
- package/dist/core/embeddings/crossfile.d.ts +0 -58
- package/dist/core/embeddings/crossfile.d.ts.map +0 -1
- package/dist/core/embeddings/crossfile.js +0 -202
- package/dist/core/embeddings/crossfile.js.map +0 -1
- package/dist/core/embeddings/enricher.d.ts +0 -53
- package/dist/core/embeddings/enricher.d.ts.map +0 -1
- package/dist/core/embeddings/enricher.js +0 -308
- package/dist/core/embeddings/enricher.js.map +0 -1
- package/dist/core/embeddings/index.d.ts +0 -13
- package/dist/core/embeddings/index.d.ts.map +0 -1
- package/dist/core/embeddings/index.js +0 -20
- package/dist/core/embeddings/index.js.map +0 -1
- package/dist/core/embeddings/reranker.d.ts +0 -41
- package/dist/core/embeddings/reranker.d.ts.map +0 -1
- package/dist/core/embeddings/reranker.js +0 -117
- package/dist/core/embeddings/reranker.js.map +0 -1
- package/dist/core/embeddings/store.d.ts +0 -93
- package/dist/core/embeddings/store.d.ts.map +0 -1
- package/dist/core/embeddings/store.js +0 -304
- package/dist/core/embeddings/store.js.map +0 -1
- package/dist/core/embeddings/types.d.ts +0 -77
- package/dist/core/embeddings/types.d.ts.map +0 -1
- package/dist/core/embeddings/types.js +0 -5
- package/dist/core/embeddings/types.js.map +0 -1
- package/dist/core/embeddings/watcher.d.ts +0 -130
- package/dist/core/embeddings/watcher.d.ts.map +0 -1
- package/dist/core/embeddings/watcher.js +0 -448
- package/dist/core/embeddings/watcher.js.map +0 -1
- package/dist/core/fallback/index.d.ts +0 -26
- package/dist/core/fallback/index.d.ts.map +0 -1
- package/dist/core/fallback/index.js +0 -76
- package/dist/core/fallback/index.js.map +0 -1
- package/dist/core/parser/index.d.ts +0 -64
- package/dist/core/parser/index.d.ts.map +0 -1
- package/dist/core/parser/index.js +0 -205
- package/dist/core/parser/index.js.map +0 -1
- package/dist/core/parser/languages.d.ts +0 -26
- package/dist/core/parser/languages.d.ts.map +0 -1
- package/dist/core/parser/languages.js +0 -101
- package/dist/core/parser/languages.js.map +0 -1
- package/dist/core/queries/helpers.d.ts +0 -72
- package/dist/core/queries/helpers.d.ts.map +0 -1
- package/dist/core/queries/helpers.js +0 -101
- package/dist/core/queries/helpers.js.map +0 -1
- package/dist/core/queries/index.d.ts +0 -144
- package/dist/core/queries/index.d.ts.map +0 -1
- package/dist/core/queries/index.js +0 -396
- package/dist/core/queries/index.js.map +0 -1
- package/dist/core/queries/loader.d.ts +0 -46
- package/dist/core/queries/loader.d.ts.map +0 -1
- package/dist/core/queries/loader.js +0 -216
- package/dist/core/queries/loader.js.map +0 -1
- package/dist/core/queries/patterns.d.ts +0 -10
- package/dist/core/queries/patterns.d.ts.map +0 -1
- package/dist/core/queries/patterns.js +0 -112
- package/dist/core/queries/patterns.js.map +0 -1
- package/dist/core/symbols/index.d.ts +0 -70
- package/dist/core/symbols/index.d.ts.map +0 -1
- package/dist/core/symbols/index.js +0 -359
- package/dist/core/symbols/index.js.map +0 -1
- package/dist/core/unified/index.d.ts +0 -118
- package/dist/core/unified/index.d.ts.map +0 -1
- package/dist/core/unified/index.js +0 -428
- package/dist/core/unified/index.js.map +0 -1
- package/dist/core/utils/assets.d.ts +0 -34
- package/dist/core/utils/assets.d.ts.map +0 -1
- package/dist/core/utils/assets.js +0 -85
- package/dist/core/utils/assets.js.map +0 -1
- package/dist/core/utils/cache.d.ts +0 -43
- package/dist/core/utils/cache.d.ts.map +0 -1
- package/dist/core/utils/cache.js +0 -60
- package/dist/core/utils/cache.js.map +0 -1
- package/dist/core/utils/index.d.ts +0 -7
- package/dist/core/utils/index.d.ts.map +0 -1
- package/dist/core/utils/index.js +0 -10
- package/dist/core/utils/index.js.map +0 -1
- package/dist/core/utils/tsconfig.d.ts +0 -34
- package/dist/core/utils/tsconfig.d.ts.map +0 -1
- package/dist/core/utils/tsconfig.js +0 -173
- package/dist/core/utils/tsconfig.js.map +0 -1
- package/dist/features/analyze-file/index.d.ts +0 -15
- package/dist/features/analyze-file/index.d.ts.map +0 -1
- package/dist/features/analyze-file/index.js +0 -164
- package/dist/features/analyze-file/index.js.map +0 -1
- package/dist/features/get-call-graph/index.d.ts +0 -24
- package/dist/features/get-call-graph/index.d.ts.map +0 -1
- package/dist/features/get-call-graph/index.js +0 -246
- package/dist/features/get-call-graph/index.js.map +0 -1
- package/dist/features/get-index-status/index.d.ts +0 -20
- package/dist/features/get-index-status/index.d.ts.map +0 -1
- package/dist/features/get-index-status/index.js +0 -90
- package/dist/features/get-index-status/index.js.map +0 -1
- package/dist/features/index-codebase/index.d.ts +0 -24
- package/dist/features/index-codebase/index.d.ts.map +0 -1
- package/dist/features/index-codebase/index.js +0 -283
- package/dist/features/index-codebase/index.js.map +0 -1
- package/dist/features/index.d.ts +0 -15
- package/dist/features/index.d.ts.map +0 -1
- package/dist/features/index.js +0 -28
- package/dist/features/index.js.map +0 -1
- package/dist/features/info/index.d.ts +0 -19
- package/dist/features/info/index.d.ts.map +0 -1
- package/dist/features/info/index.js +0 -41
- package/dist/features/info/index.js.map +0 -1
- package/dist/features/list-symbols/index.d.ts +0 -22
- package/dist/features/list-symbols/index.d.ts.map +0 -1
- package/dist/features/list-symbols/index.js +0 -74
- package/dist/features/list-symbols/index.js.map +0 -1
- package/dist/features/parse-ast/index.d.ts +0 -12
- package/dist/features/parse-ast/index.d.ts.map +0 -1
- package/dist/features/parse-ast/index.js +0 -71
- package/dist/features/parse-ast/index.js.map +0 -1
- package/dist/features/query-code/index.d.ts +0 -23
- package/dist/features/query-code/index.d.ts.map +0 -1
- package/dist/features/query-code/index.js +0 -96
- package/dist/features/query-code/index.js.map +0 -1
- package/dist/features/search-code/index.d.ts +0 -39
- package/dist/features/search-code/index.d.ts.map +0 -1
- package/dist/features/search-code/index.js +0 -258
- package/dist/features/search-code/index.js.map +0 -1
- package/dist/features/types.d.ts +0 -14
- package/dist/features/types.d.ts.map +0 -1
- package/dist/features/types.js +0 -2
- package/dist/features/types.js.map +0 -1
- package/dist/features/update-index/index.d.ts +0 -24
- package/dist/features/update-index/index.d.ts.map +0 -1
- package/dist/features/update-index/index.js +0 -358
- package/dist/features/update-index/index.js.map +0 -1
- package/dist/features/utils/content.d.ts +0 -30
- package/dist/features/utils/content.d.ts.map +0 -1
- package/dist/features/utils/content.js +0 -49
- package/dist/features/utils/content.js.map +0 -1
- package/dist/features/utils/index.d.ts +0 -6
- package/dist/features/utils/index.d.ts.map +0 -1
- package/dist/features/utils/index.js +0 -8
- package/dist/features/utils/index.js.map +0 -1
- package/dist/features/utils/result.d.ts +0 -37
- package/dist/features/utils/result.d.ts.map +0 -1
- package/dist/features/utils/result.js +0 -53
- package/dist/features/utils/result.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +0 -1
- package/dist/prompts/index.d.ts +0 -9
- package/dist/prompts/index.d.ts.map +0 -1
- package/dist/prompts/index.js +0 -188
- package/dist/prompts/index.js.map +0 -1
- package/dist/resources/index.d.ts +0 -3
- package/dist/resources/index.d.ts.map +0 -1
- package/dist/resources/index.js +0 -17
- package/dist/resources/index.js.map +0 -1
- package/dist/server.d.ts +0 -4
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js +0 -24
- package/dist/server.js.map +0 -1
- package/dist/tools/adapter.d.ts +0 -4
- package/dist/tools/adapter.d.ts.map +0 -1
- package/dist/tools/adapter.js +0 -28
- package/dist/tools/adapter.js.map +0 -1
- package/dist/tools/index.d.ts +0 -5
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -9
- package/dist/tools/index.js.map +0 -1
- package/dist/types/index.d.ts +0 -20
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +0 -1
- package/dist/utils/colors.d.ts +0 -24
- package/dist/utils/colors.d.ts.map +0 -1
- package/dist/utils/colors.js +0 -30
- package/dist/utils/colors.js.map +0 -1
- package/dist/utils/index.d.ts +0 -4
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -4
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/logger.d.ts +0 -8
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/logger.js +0 -57
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/spinner.d.ts +0 -11
- package/dist/utils/spinner.d.ts.map +0 -1
- package/dist/utils/spinner.js +0 -36
- package/dist/utils/spinner.js.map +0 -1
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get Call Graph Feature
|
|
3
|
-
*
|
|
4
|
-
* Analyzes function call relationships in a codebase.
|
|
5
|
-
* Can either:
|
|
6
|
-
* 1. Build a full call graph for a directory
|
|
7
|
-
* 2. Query callers/callees for a specific function
|
|
8
|
-
*/
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
import type { Feature, FeatureResult } from "@features/types";
|
|
11
|
-
export declare const getCallGraphSchema: z.ZodObject<{
|
|
12
|
-
directory: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
13
|
-
functionName: z.ZodOptional<z.ZodString>;
|
|
14
|
-
filePath: z.ZodOptional<z.ZodString>;
|
|
15
|
-
maxDepth: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
16
|
-
exclude: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
17
|
-
}, z.core.$strip>;
|
|
18
|
-
export type GetCallGraphInput = z.infer<typeof getCallGraphSchema>;
|
|
19
|
-
/**
|
|
20
|
-
* Execute the get_call_graph feature
|
|
21
|
-
*/
|
|
22
|
-
export declare function execute(input: GetCallGraphInput): Promise<FeatureResult>;
|
|
23
|
-
export declare const getCallGraphFeature: Feature<typeof getCallGraphSchema>;
|
|
24
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/get-call-graph/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAU9D,eAAO,MAAM,kBAAkB;;;;;;iBA4B7B,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAsFnE;;GAEG;AACH,wBAAsB,OAAO,CAC3B,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,aAAa,CAAC,CA0LxB;AAED,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC,OAAO,kBAAkB,CAMlE,CAAC"}
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get Call Graph Feature
|
|
3
|
-
*
|
|
4
|
-
* Analyzes function call relationships in a codebase.
|
|
5
|
-
* Can either:
|
|
6
|
-
* 1. Build a full call graph for a directory
|
|
7
|
-
* 2. Query callers/callees for a specific function
|
|
8
|
-
*/
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
import * as fs from "node:fs";
|
|
11
|
-
import * as path from "node:path";
|
|
12
|
-
import ignore from "ignore";
|
|
13
|
-
import { buildCallGraph, getCallContext, formatCallContext, shouldIndexFile, } from "@core/embeddings";
|
|
14
|
-
import { logger } from "@utils";
|
|
15
|
-
export const getCallGraphSchema = z.object({
|
|
16
|
-
directory: z
|
|
17
|
-
.string()
|
|
18
|
-
.optional()
|
|
19
|
-
.default(".")
|
|
20
|
-
.describe("Path to the directory to analyze"),
|
|
21
|
-
functionName: z
|
|
22
|
-
.string()
|
|
23
|
-
.optional()
|
|
24
|
-
.describe("Optional: specific function name to query callers/callees for"),
|
|
25
|
-
filePath: z
|
|
26
|
-
.string()
|
|
27
|
-
.optional()
|
|
28
|
-
.describe("Optional: file path to narrow down function search (used with functionName)"),
|
|
29
|
-
maxDepth: z
|
|
30
|
-
.number()
|
|
31
|
-
.int()
|
|
32
|
-
.positive()
|
|
33
|
-
.optional()
|
|
34
|
-
.default(2)
|
|
35
|
-
.describe("Maximum depth for call chain traversal (default: 2)"),
|
|
36
|
-
exclude: z
|
|
37
|
-
.array(z.string())
|
|
38
|
-
.optional()
|
|
39
|
-
.default([])
|
|
40
|
-
.describe("Glob patterns to exclude from analysis"),
|
|
41
|
-
});
|
|
42
|
-
/**
|
|
43
|
-
* Create gitignore filter from .gitignore file
|
|
44
|
-
*/
|
|
45
|
-
function createIgnoreFilter(directory, extraPatterns) {
|
|
46
|
-
const ig = ignore();
|
|
47
|
-
// Add default ignores
|
|
48
|
-
ig.add(["node_modules", ".git", "dist", "build", ".src-index"]);
|
|
49
|
-
// Add extra patterns
|
|
50
|
-
if (extraPatterns.length > 0) {
|
|
51
|
-
ig.add(extraPatterns);
|
|
52
|
-
}
|
|
53
|
-
// Read .gitignore if exists
|
|
54
|
-
const gitignorePath = path.join(directory, ".gitignore");
|
|
55
|
-
if (fs.existsSync(gitignorePath)) {
|
|
56
|
-
const content = fs.readFileSync(gitignorePath, "utf-8");
|
|
57
|
-
ig.add(content);
|
|
58
|
-
}
|
|
59
|
-
return ig;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Check if a name starts with a dot (hidden file/folder)
|
|
63
|
-
*/
|
|
64
|
-
function isHidden(name) {
|
|
65
|
-
return name.startsWith(".");
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Recursively collect files from a directory
|
|
69
|
-
*/
|
|
70
|
-
function collectFiles(dir, ig, baseDir) {
|
|
71
|
-
const files = [];
|
|
72
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
73
|
-
for (const entry of entries) {
|
|
74
|
-
if (isHidden(entry.name)) {
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
const fullPath = path.join(dir, entry.name);
|
|
78
|
-
const relativePath = path.relative(baseDir, fullPath).replace(/\\/g, "/");
|
|
79
|
-
if (ig.ignores(relativePath)) {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
if (entry.isDirectory()) {
|
|
83
|
-
files.push(...collectFiles(fullPath, ig, baseDir));
|
|
84
|
-
}
|
|
85
|
-
else if (entry.isFile() && shouldIndexFile(entry.name)) {
|
|
86
|
-
files.push(fullPath);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return files;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Execute the get_call_graph feature
|
|
93
|
-
*/
|
|
94
|
-
export async function execute(input) {
|
|
95
|
-
const { directory, functionName, filePath, maxDepth, exclude } = input;
|
|
96
|
-
// Validate directory exists
|
|
97
|
-
if (!fs.existsSync(directory)) {
|
|
98
|
-
return {
|
|
99
|
-
success: false,
|
|
100
|
-
error: `Directory not found: ${directory}`,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
const absoluteDir = path.resolve(directory);
|
|
104
|
-
try {
|
|
105
|
-
// Create ignore filter
|
|
106
|
-
const ig = createIgnoreFilter(absoluteDir, exclude);
|
|
107
|
-
// Collect files
|
|
108
|
-
const files = collectFiles(absoluteDir, ig, absoluteDir);
|
|
109
|
-
if (files.length === 0) {
|
|
110
|
-
return {
|
|
111
|
-
success: true,
|
|
112
|
-
message: "No analyzable files found in directory",
|
|
113
|
-
data: {
|
|
114
|
-
directory: absoluteDir,
|
|
115
|
-
mode: "full",
|
|
116
|
-
totalFunctions: 0,
|
|
117
|
-
totalCalls: 0,
|
|
118
|
-
filesAnalyzed: 0,
|
|
119
|
-
},
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
logger.debug(`Analyzing call graph for ${String(files.length)} files`);
|
|
123
|
-
// Read file contents and build call graph
|
|
124
|
-
const fileContents = files.map((f) => ({
|
|
125
|
-
path: f,
|
|
126
|
-
content: fs.readFileSync(f, "utf-8"),
|
|
127
|
-
}));
|
|
128
|
-
const graph = await buildCallGraph(fileContents);
|
|
129
|
-
const result = {
|
|
130
|
-
directory: absoluteDir,
|
|
131
|
-
mode: functionName ? "query" : "full",
|
|
132
|
-
totalFunctions: graph.nodes.size,
|
|
133
|
-
totalCalls: Array.from(graph.nodes.values()).reduce((sum, node) => sum + node.calls.length, 0),
|
|
134
|
-
filesAnalyzed: files.length,
|
|
135
|
-
};
|
|
136
|
-
// If querying for a specific function
|
|
137
|
-
if (functionName) {
|
|
138
|
-
const targetFilePath = filePath
|
|
139
|
-
? path.resolve(directory, filePath)
|
|
140
|
-
: undefined;
|
|
141
|
-
const callContext = getCallContext(graph, targetFilePath ?? "", functionName);
|
|
142
|
-
if (!callContext) {
|
|
143
|
-
// Try to find function in any file
|
|
144
|
-
let foundContext = null;
|
|
145
|
-
let foundFilePath = "";
|
|
146
|
-
for (const node of graph.nodes.values()) {
|
|
147
|
-
if (node.name === functionName) {
|
|
148
|
-
foundFilePath = node.filePath;
|
|
149
|
-
foundContext = getCallContext(graph, node.filePath, functionName);
|
|
150
|
-
if (foundContext) {
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (foundContext) {
|
|
156
|
-
result.query = {
|
|
157
|
-
functionName,
|
|
158
|
-
filePath: foundFilePath,
|
|
159
|
-
callers: foundContext.callers,
|
|
160
|
-
callees: foundContext.callees,
|
|
161
|
-
formattedContext: formatCallContext(foundContext.callers, foundContext.callees, maxDepth),
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
return {
|
|
166
|
-
success: false,
|
|
167
|
-
error: `Function '${functionName}' not found in the codebase`,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
result.query = {
|
|
173
|
-
functionName,
|
|
174
|
-
filePath: targetFilePath,
|
|
175
|
-
callers: callContext.callers,
|
|
176
|
-
callees: callContext.callees,
|
|
177
|
-
formattedContext: formatCallContext(callContext.callers, callContext.callees, maxDepth),
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
const message = `Call graph for '${functionName}':\n\n${result.query.formattedContext}`;
|
|
181
|
-
return {
|
|
182
|
-
success: true,
|
|
183
|
-
message,
|
|
184
|
-
data: result,
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
// Full graph mode - compute top callers and callees
|
|
188
|
-
const callerCounts = new Map();
|
|
189
|
-
const calleeCounts = new Map();
|
|
190
|
-
for (const node of graph.nodes.values()) {
|
|
191
|
-
callerCounts.set(node.name, node.calls.length);
|
|
192
|
-
calleeCounts.set(node.name, node.calledBy.length);
|
|
193
|
-
}
|
|
194
|
-
const topCallers = Array.from(callerCounts.entries())
|
|
195
|
-
.sort((a, b) => b[1] - a[1])
|
|
196
|
-
.slice(0, 10)
|
|
197
|
-
.map(([name, callCount]) => ({ name, callCount }));
|
|
198
|
-
const topCallees = Array.from(calleeCounts.entries())
|
|
199
|
-
.sort((a, b) => b[1] - a[1])
|
|
200
|
-
.slice(0, 10)
|
|
201
|
-
.map(([name, calledByCount]) => ({ name, calledByCount }));
|
|
202
|
-
result.graph = {
|
|
203
|
-
nodes: Object.fromEntries(graph.nodes),
|
|
204
|
-
topCallers,
|
|
205
|
-
topCallees,
|
|
206
|
-
};
|
|
207
|
-
// Build summary message
|
|
208
|
-
const topCallersStr = topCallers
|
|
209
|
-
.map((c) => ` - ${c.name}: ${String(c.callCount)} calls`)
|
|
210
|
-
.join("\n");
|
|
211
|
-
const topCalleesStr = topCallees
|
|
212
|
-
.map((c) => ` - ${c.name}: called by ${String(c.calledByCount)} functions`)
|
|
213
|
-
.join("\n");
|
|
214
|
-
const message = `Call graph analysis complete:
|
|
215
|
-
- Files analyzed: ${String(files.length)}
|
|
216
|
-
- Functions found: ${String(result.totalFunctions)}
|
|
217
|
-
- Total calls: ${String(result.totalCalls)}
|
|
218
|
-
|
|
219
|
-
Top callers (functions that call the most):
|
|
220
|
-
${topCallersStr}
|
|
221
|
-
|
|
222
|
-
Most called (functions called by the most):
|
|
223
|
-
${topCalleesStr}
|
|
224
|
-
|
|
225
|
-
Use functionName parameter to query specific function relationships.`;
|
|
226
|
-
return {
|
|
227
|
-
success: true,
|
|
228
|
-
message,
|
|
229
|
-
data: result,
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
catch (err) {
|
|
233
|
-
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
234
|
-
return {
|
|
235
|
-
success: false,
|
|
236
|
-
error: `Call graph analysis failed: ${errorMsg}`,
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
export const getCallGraphFeature = {
|
|
241
|
-
name: "get_call_graph",
|
|
242
|
-
description: "Analyze function call relationships in a codebase. Query callers/callees for a specific function or get full call graph statistics.",
|
|
243
|
-
schema: getCallGraphSchema,
|
|
244
|
-
execute,
|
|
245
|
-
};
|
|
246
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/features/get-call-graph/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE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AC7B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC;aACzD,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,MAAM,aAAa,GAAG,UAAU;aAC7B,GAAG,CACF,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,eAAe,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,YAAY,CACvE;aACA,IAAI,CAAC,IAAI,CAAC,CAAC;QAEd,MAAM,OAAO,GAAG;oBACA,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;qBACnB,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;iBACjC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;;;EAGxC,aAAa;;;EAGb,aAAa;;qEAEsD,CAAC;QAElE,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO;YACP,IAAI,EAAE,MAAM;SACb,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,QAAQ,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAClE,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,+BAA+B,QAAQ,EAAE;SACjD,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAuC;IACrE,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACT,qIAAqI;IACvI,MAAM,EAAE,kBAAkB;IAC1B,OAAO;CACR,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get Index Status Feature
|
|
3
|
-
*
|
|
4
|
-
* Returns information about the embedding index for a directory:
|
|
5
|
-
* - Whether an index exists
|
|
6
|
-
* - Total chunks and files indexed
|
|
7
|
-
* - Language breakdown
|
|
8
|
-
*/
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
import type { Feature, FeatureResult } from "@features/types";
|
|
11
|
-
export declare const getIndexStatusSchema: z.ZodObject<{
|
|
12
|
-
directory: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
13
|
-
}, z.core.$strip>;
|
|
14
|
-
export type GetIndexStatusInput = z.infer<typeof getIndexStatusSchema>;
|
|
15
|
-
/**
|
|
16
|
-
* Execute the get_index_status feature
|
|
17
|
-
*/
|
|
18
|
-
export declare function execute(input: GetIndexStatusInput): Promise<FeatureResult>;
|
|
19
|
-
export declare const getIndexStatusFeature: Feature<typeof getIndexStatusSchema>;
|
|
20
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/get-index-status/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAQ9D,eAAO,MAAM,oBAAoB;;iBAM/B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAEvE;;GAEG;AACH,wBAAsB,OAAO,CAC3B,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,aAAa,CAAC,CAmExB;AAED,eAAO,MAAM,qBAAqB,EAAE,OAAO,CAAC,OAAO,oBAAoB,CAMtE,CAAC"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get Index Status Feature
|
|
3
|
-
*
|
|
4
|
-
* Returns information about the embedding index for a directory:
|
|
5
|
-
* - Whether an index exists
|
|
6
|
-
* - Total chunks and files indexed
|
|
7
|
-
* - Language breakdown
|
|
8
|
-
*/
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
import * as fs from "node:fs";
|
|
11
|
-
import * as path from "node:path";
|
|
12
|
-
import { EMBEDDING_CONFIG } from "@config";
|
|
13
|
-
import { createVectorStore, getIndexPath, } from "@core/embeddings";
|
|
14
|
-
export const getIndexStatusSchema = z.object({
|
|
15
|
-
directory: z
|
|
16
|
-
.string()
|
|
17
|
-
.optional()
|
|
18
|
-
.default(".")
|
|
19
|
-
.describe("Path to the directory to check (defaults to current directory)"),
|
|
20
|
-
});
|
|
21
|
-
/**
|
|
22
|
-
* Execute the get_index_status feature
|
|
23
|
-
*/
|
|
24
|
-
export async function execute(input) {
|
|
25
|
-
const { directory } = input;
|
|
26
|
-
// Validate directory exists
|
|
27
|
-
if (!fs.existsSync(directory)) {
|
|
28
|
-
return {
|
|
29
|
-
success: false,
|
|
30
|
-
error: `Directory not found: ${directory}`,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
const absoluteDir = path.resolve(directory);
|
|
34
|
-
const indexPath = getIndexPath(absoluteDir);
|
|
35
|
-
// Check if index exists
|
|
36
|
-
if (!fs.existsSync(indexPath)) {
|
|
37
|
-
const status = {
|
|
38
|
-
directory: absoluteDir,
|
|
39
|
-
indexPath,
|
|
40
|
-
exists: false,
|
|
41
|
-
totalChunks: 0,
|
|
42
|
-
totalFiles: 0,
|
|
43
|
-
languages: {},
|
|
44
|
-
};
|
|
45
|
-
return {
|
|
46
|
-
success: true,
|
|
47
|
-
message: `No index found for ${absoluteDir}. Run index_codebase to create one.`,
|
|
48
|
-
data: status,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
try {
|
|
52
|
-
const vectorStore = createVectorStore(absoluteDir, EMBEDDING_CONFIG);
|
|
53
|
-
await vectorStore.connect();
|
|
54
|
-
const status = await vectorStore.getStatus(absoluteDir);
|
|
55
|
-
vectorStore.close();
|
|
56
|
-
// Format language breakdown
|
|
57
|
-
const languageLines = Object.entries(status.languages)
|
|
58
|
-
.sort(([, a], [, b]) => b - a)
|
|
59
|
-
.map(([lang, count]) => ` - ${lang}: ${String(count)} chunks`);
|
|
60
|
-
const message = [
|
|
61
|
-
`Index Status for ${absoluteDir}`,
|
|
62
|
-
``,
|
|
63
|
-
`Index Path: ${status.indexPath}`,
|
|
64
|
-
`Total Files: ${String(status.totalFiles)}`,
|
|
65
|
-
`Total Chunks: ${String(status.totalChunks)}`,
|
|
66
|
-
``,
|
|
67
|
-
`Languages:`,
|
|
68
|
-
...languageLines,
|
|
69
|
-
].join("\n");
|
|
70
|
-
return {
|
|
71
|
-
success: true,
|
|
72
|
-
message,
|
|
73
|
-
data: status,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
catch (err) {
|
|
77
|
-
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
78
|
-
return {
|
|
79
|
-
success: false,
|
|
80
|
-
error: `Failed to read index status: ${errorMsg}`,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
export const getIndexStatusFeature = {
|
|
85
|
-
name: "get_index_status",
|
|
86
|
-
description: "Check if a codebase is indexed and ready for search. USE THIS to verify index exists before searching. Returns file count, chunk count, and indexed languages.",
|
|
87
|
-
schema: getIndexStatusSchema,
|
|
88
|
-
execute,
|
|
89
|
-
};
|
|
90
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/features/get-index-status/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EACL,iBAAiB,EACjB,YAAY,GAEb,MAAM,kBAAkB,CAAC;AAE1B,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MA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chunking each file
|
|
7
|
-
* 3. Generating embeddings via Ollama
|
|
8
|
-
* 4. Storing in LanceDB
|
|
9
|
-
*/
|
|
10
|
-
import { z } from "zod";
|
|
11
|
-
import type { Feature, FeatureResult } from "@features/types";
|
|
12
|
-
export declare const indexCodebaseSchema: z.ZodObject<{
|
|
13
|
-
directory: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
14
|
-
force: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
15
|
-
exclude: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
16
|
-
concurrency: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
17
|
-
}, z.core.$strip>;
|
|
18
|
-
export type IndexCodebaseInput = z.infer<typeof indexCodebaseSchema>;
|
|
19
|
-
/**
|
|
20
|
-
* Execute the index_codebase feature
|
|
21
|
-
*/
|
|
22
|
-
export declare function execute(input: IndexCodebaseInput): Promise<FeatureResult>;
|
|
23
|
-
export declare const indexCodebaseFeature: Feature<typeof indexCodebaseSchema>;
|
|
24
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/index-codebase/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAiD9D,eAAO,MAAM,mBAAmB;;;;;iBAuB9B,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AA6ErE;;GAEG;AACH,wBAAsB,OAAO,CAC3B,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,aAAa,CAAC,CAoMxB;AAED,eAAO,MAAM,oBAAoB,EAAE,OAAO,CAAC,OAAO,mBAAmB,CAMpE,CAAC"}
|