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,283 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Index Codebase Feature
|
|
3
|
-
*
|
|
4
|
-
* Indexes a directory by:
|
|
5
|
-
* 1. Scanning for supported files
|
|
6
|
-
* 2. Chunking each file
|
|
7
|
-
* 3. Generating embeddings via Ollama
|
|
8
|
-
* 4. Storing in LanceDB
|
|
9
|
-
*/
|
|
10
|
-
import { z } from "zod";
|
|
11
|
-
import * as fs from "node:fs";
|
|
12
|
-
import * as path from "node:path";
|
|
13
|
-
import ignore from "ignore";
|
|
14
|
-
import { EMBEDDING_CONFIG } from "@config";
|
|
15
|
-
import { chunkFile, createOllamaClient, createVectorStore, enrichChunksFromFile, shouldIndexFile, } from "@core/embeddings";
|
|
16
|
-
import { logger } from "@utils";
|
|
17
|
-
import { readPathAliasesCached } from "@core/utils";
|
|
18
|
-
/** Default concurrency for parallel file processing */
|
|
19
|
-
const DEFAULT_CONCURRENCY = 4;
|
|
20
|
-
/**
|
|
21
|
-
* Process items in parallel with concurrency limit using worker pool pattern
|
|
22
|
-
*/
|
|
23
|
-
async function parallelMap(items, processor, concurrency) {
|
|
24
|
-
const results = new Array(items.length);
|
|
25
|
-
let currentIndex = 0;
|
|
26
|
-
const worker = async () => {
|
|
27
|
-
while (currentIndex < items.length) {
|
|
28
|
-
const index = currentIndex++;
|
|
29
|
-
const item = items[index];
|
|
30
|
-
if (item !== undefined) {
|
|
31
|
-
results[index] = await processor(item);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const workers = Array.from({ length: Math.min(concurrency, items.length) }, async () => worker());
|
|
36
|
-
await Promise.all(workers);
|
|
37
|
-
// Filter out undefined values (shouldn't happen but TypeScript needs this)
|
|
38
|
-
return results.filter((r) => r !== undefined);
|
|
39
|
-
}
|
|
40
|
-
export const indexCodebaseSchema = z.object({
|
|
41
|
-
directory: z
|
|
42
|
-
.string()
|
|
43
|
-
.optional()
|
|
44
|
-
.default(".")
|
|
45
|
-
.describe("Path to the directory to index (defaults to current directory)"),
|
|
46
|
-
force: z
|
|
47
|
-
.boolean()
|
|
48
|
-
.optional()
|
|
49
|
-
.default(false)
|
|
50
|
-
.describe("Force re-indexing even if index exists"),
|
|
51
|
-
exclude: z
|
|
52
|
-
.array(z.string())
|
|
53
|
-
.optional()
|
|
54
|
-
.default([])
|
|
55
|
-
.describe("Additional glob patterns to exclude"),
|
|
56
|
-
concurrency: z
|
|
57
|
-
.number()
|
|
58
|
-
.int()
|
|
59
|
-
.positive()
|
|
60
|
-
.optional()
|
|
61
|
-
.default(DEFAULT_CONCURRENCY)
|
|
62
|
-
.describe("Number of files to process in parallel (default: 4)"),
|
|
63
|
-
});
|
|
64
|
-
/**
|
|
65
|
-
* Create an ignore instance with gitignore patterns and additional exclusions
|
|
66
|
-
*/
|
|
67
|
-
function createIgnoreFilter(baseDir, additionalExclusions) {
|
|
68
|
-
const ig = ignore();
|
|
69
|
-
// Read .gitignore if it exists
|
|
70
|
-
const gitignorePath = path.join(baseDir, ".gitignore");
|
|
71
|
-
if (fs.existsSync(gitignorePath)) {
|
|
72
|
-
try {
|
|
73
|
-
const content = fs.readFileSync(gitignorePath, "utf-8");
|
|
74
|
-
ig.add(content);
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
// Ignore read errors
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// Add additional user exclusions
|
|
81
|
-
if (additionalExclusions.length > 0) {
|
|
82
|
-
ig.add(additionalExclusions);
|
|
83
|
-
}
|
|
84
|
-
return ig;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Check if a name starts with a dot (hidden file/folder)
|
|
88
|
-
*/
|
|
89
|
-
function isHidden(name) {
|
|
90
|
-
return name.startsWith(".");
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Recursively collect files from a directory
|
|
94
|
-
*/
|
|
95
|
-
function collectFiles(dir, ig, baseDir) {
|
|
96
|
-
const files = [];
|
|
97
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
98
|
-
for (const entry of entries) {
|
|
99
|
-
// Skip hidden files/folders (starting with .)
|
|
100
|
-
if (isHidden(entry.name)) {
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
const fullPath = path.join(dir, entry.name);
|
|
104
|
-
const relativePath = path.relative(baseDir, fullPath).replace(/\\/g, "/");
|
|
105
|
-
// Check if ignored by gitignore patterns
|
|
106
|
-
if (ig.ignores(relativePath)) {
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
if (entry.isDirectory()) {
|
|
110
|
-
files.push(...collectFiles(fullPath, ig, baseDir));
|
|
111
|
-
}
|
|
112
|
-
else if (entry.isFile() && shouldIndexFile(entry.name)) {
|
|
113
|
-
files.push(fullPath);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return files;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Execute the index_codebase feature
|
|
120
|
-
*/
|
|
121
|
-
export async function execute(input) {
|
|
122
|
-
const { directory, force, exclude, concurrency } = input;
|
|
123
|
-
// Validate directory exists
|
|
124
|
-
if (!fs.existsSync(directory)) {
|
|
125
|
-
return {
|
|
126
|
-
success: false,
|
|
127
|
-
error: `Directory not found: ${directory}`,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
const absoluteDir = path.resolve(directory);
|
|
131
|
-
// Initialize components
|
|
132
|
-
const ollamaClient = createOllamaClient(EMBEDDING_CONFIG);
|
|
133
|
-
const vectorStore = createVectorStore(absoluteDir, EMBEDDING_CONFIG);
|
|
134
|
-
// Check Ollama health
|
|
135
|
-
const health = await ollamaClient.healthCheck();
|
|
136
|
-
if (!health.ok) {
|
|
137
|
-
return {
|
|
138
|
-
success: false,
|
|
139
|
-
error: health.error ?? "Ollama is not available",
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
// Check if index exists and force is not set
|
|
143
|
-
if (vectorStore.exists() && !force) {
|
|
144
|
-
return {
|
|
145
|
-
success: false,
|
|
146
|
-
error: "Index already exists. Use force=true to re-index or search_code to query.",
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
const result = {
|
|
150
|
-
directory: absoluteDir,
|
|
151
|
-
filesIndexed: 0,
|
|
152
|
-
chunksCreated: 0,
|
|
153
|
-
languages: {},
|
|
154
|
-
errors: [],
|
|
155
|
-
};
|
|
156
|
-
try {
|
|
157
|
-
// Connect to vector store
|
|
158
|
-
await vectorStore.connect();
|
|
159
|
-
// Clear existing data if force re-indexing
|
|
160
|
-
if (force && vectorStore.exists()) {
|
|
161
|
-
await vectorStore.clear();
|
|
162
|
-
}
|
|
163
|
-
// Create ignore filter from .gitignore and user exclusions
|
|
164
|
-
const ig = createIgnoreFilter(absoluteDir, exclude);
|
|
165
|
-
// Collect files
|
|
166
|
-
const files = collectFiles(absoluteDir, ig, absoluteDir);
|
|
167
|
-
if (files.length === 0) {
|
|
168
|
-
return {
|
|
169
|
-
success: true,
|
|
170
|
-
message: "No indexable files found in directory",
|
|
171
|
-
data: result,
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
// Read path aliases from tsconfig.json if present
|
|
175
|
-
const pathAliases = readPathAliasesCached(absoluteDir);
|
|
176
|
-
const aliasCount = Object.keys(pathAliases).length;
|
|
177
|
-
// Enrichment options with cross-file context enabled
|
|
178
|
-
const enrichmentOptions = {
|
|
179
|
-
projectRoot: absoluteDir,
|
|
180
|
-
pathAliases,
|
|
181
|
-
includeCrossFileContext: true,
|
|
182
|
-
};
|
|
183
|
-
logger.debug(`Indexing ${String(files.length)} files with concurrency=${String(concurrency)} (projectRoot: ${absoluteDir}, ${String(aliasCount)} path aliases)`);
|
|
184
|
-
const processFile = async (filePath) => {
|
|
185
|
-
try {
|
|
186
|
-
const content = fs.readFileSync(filePath, "utf-8");
|
|
187
|
-
const chunks = await chunkFile(filePath, content, EMBEDDING_CONFIG);
|
|
188
|
-
// Enrich chunks with semantic metadata including cross-file context
|
|
189
|
-
const enrichedChunks = await enrichChunksFromFile(chunks, content, enrichmentOptions);
|
|
190
|
-
return { chunks: enrichedChunks };
|
|
191
|
-
}
|
|
192
|
-
catch (err) {
|
|
193
|
-
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
194
|
-
return {
|
|
195
|
-
chunks: [],
|
|
196
|
-
error: `Error processing ${filePath}: ${errorMsg}`,
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
// Process all files in parallel with concurrency limit
|
|
201
|
-
const fileResults = await parallelMap(files, processFile, concurrency);
|
|
202
|
-
// Aggregate results
|
|
203
|
-
const allEnrichedChunks = [];
|
|
204
|
-
for (const fileResult of fileResults) {
|
|
205
|
-
if (fileResult.error) {
|
|
206
|
-
result.errors.push(fileResult.error);
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
allEnrichedChunks.push(...fileResult.chunks);
|
|
210
|
-
result.filesIndexed++;
|
|
211
|
-
// Track language stats
|
|
212
|
-
for (const chunk of fileResult.chunks) {
|
|
213
|
-
result.languages[chunk.language] =
|
|
214
|
-
(result.languages[chunk.language] ?? 0) + 1;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
// Generate embeddings in batches using enriched content
|
|
219
|
-
const { batchSize } = EMBEDDING_CONFIG;
|
|
220
|
-
const embeddedChunks = [];
|
|
221
|
-
for (let i = 0; i < allEnrichedChunks.length; i += batchSize) {
|
|
222
|
-
const batch = allEnrichedChunks.slice(i, i + batchSize);
|
|
223
|
-
// Use enrichedContent for embedding (contains metadata header + original code)
|
|
224
|
-
const texts = batch.map((c) => c.enrichedContent);
|
|
225
|
-
try {
|
|
226
|
-
const embeddings = await ollamaClient.embedBatch(texts);
|
|
227
|
-
for (let j = 0; j < batch.length; j++) {
|
|
228
|
-
const chunk = batch[j];
|
|
229
|
-
const vector = embeddings[j];
|
|
230
|
-
if (chunk && vector) {
|
|
231
|
-
// Store original chunk data (without enrichedContent to save space)
|
|
232
|
-
embeddedChunks.push({
|
|
233
|
-
id: chunk.id,
|
|
234
|
-
content: chunk.content,
|
|
235
|
-
filePath: chunk.filePath,
|
|
236
|
-
language: chunk.language,
|
|
237
|
-
startLine: chunk.startLine,
|
|
238
|
-
endLine: chunk.endLine,
|
|
239
|
-
symbolName: chunk.symbolName,
|
|
240
|
-
symbolType: chunk.symbolType,
|
|
241
|
-
vector,
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
catch (err) {
|
|
247
|
-
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
248
|
-
result.errors.push(`Embedding batch error: ${errorMsg}`);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
// Store embeddings
|
|
252
|
-
if (embeddedChunks.length > 0) {
|
|
253
|
-
await vectorStore.addChunks(embeddedChunks);
|
|
254
|
-
result.chunksCreated = embeddedChunks.length;
|
|
255
|
-
}
|
|
256
|
-
vectorStore.close();
|
|
257
|
-
const hasErrors = result.errors.length > 0;
|
|
258
|
-
const message = hasErrors
|
|
259
|
-
? `Indexed ${String(result.filesIndexed)} files (${String(result.chunksCreated)} chunks) with ${String(result.errors.length)} errors`
|
|
260
|
-
: `Successfully indexed ${String(result.filesIndexed)} files (${String(result.chunksCreated)} chunks)`;
|
|
261
|
-
return {
|
|
262
|
-
success: true,
|
|
263
|
-
message,
|
|
264
|
-
data: result,
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
catch (err) {
|
|
268
|
-
vectorStore.close();
|
|
269
|
-
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
270
|
-
return {
|
|
271
|
-
success: false,
|
|
272
|
-
error: `Indexing failed: ${errorMsg}`,
|
|
273
|
-
data: result,
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
export const indexCodebaseFeature = {
|
|
278
|
-
name: "index_codebase",
|
|
279
|
-
description: "Index a codebase for semantic code search. USE THIS FIRST before search_code. Required once per project - creates vector embeddings for 50+ languages. After initial indexing, use update_index for incremental updates.",
|
|
280
|
-
schema: indexCodebaseSchema,
|
|
281
|
-
execute,
|
|
282
|
-
};
|
|
283
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/features/index-codebase/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;A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";
|
|
2
|
-
export { infoFeature, getServerInfo } from "@features/info";
|
|
3
|
-
export { indexCodebaseFeature } from "@features/index-codebase";
|
|
4
|
-
export { searchCodeFeature } from "@features/search-code";
|
|
5
|
-
export { getIndexStatusFeature } from "@features/get-index-status";
|
|
6
|
-
export { getCallGraphFeature } from "@features/get-call-graph";
|
|
7
|
-
export { updateIndexFeature } from "@features/update-index";
|
|
8
|
-
export { parseAstFeature } from "@features/parse-ast";
|
|
9
|
-
export { queryCodeFeature } from "@features/query-code";
|
|
10
|
-
export { listSymbolsFeature } from "@features/list-symbols";
|
|
11
|
-
export { analyzeFileFeature } from "@features/analyze-file";
|
|
12
|
-
import type { Feature } from "@features/types";
|
|
13
|
-
export declare const features: Feature[];
|
|
14
|
-
export declare function getFeature(name: string): Feature | undefined;
|
|
15
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/features/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,iBAAiB,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAG5D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAQ/C,eAAO,MAAM,QAAQ,EAAE,OAAO,EAM7B,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAE5D"}
|
package/dist/features/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export { infoFeature, getServerInfo } from "@features/info";
|
|
2
|
-
export { indexCodebaseFeature } from "@features/index-codebase";
|
|
3
|
-
export { searchCodeFeature } from "@features/search-code";
|
|
4
|
-
export { getIndexStatusFeature } from "@features/get-index-status";
|
|
5
|
-
export { getCallGraphFeature } from "@features/get-call-graph";
|
|
6
|
-
export { updateIndexFeature } from "@features/update-index";
|
|
7
|
-
// Internal features (used by other features, not exposed via CLI/MCP)
|
|
8
|
-
export { parseAstFeature } from "@features/parse-ast";
|
|
9
|
-
export { queryCodeFeature } from "@features/query-code";
|
|
10
|
-
export { listSymbolsFeature } from "@features/list-symbols";
|
|
11
|
-
export { analyzeFileFeature } from "@features/analyze-file";
|
|
12
|
-
import { getIndexStatusFeature } from "@features/get-index-status";
|
|
13
|
-
import { indexCodebaseFeature } from "@features/index-codebase";
|
|
14
|
-
import { infoFeature } from "@features/info";
|
|
15
|
-
import { searchCodeFeature } from "@features/search-code";
|
|
16
|
-
import { updateIndexFeature } from "@features/update-index";
|
|
17
|
-
// Registry of features exposed via CLI and MCP
|
|
18
|
-
export const features = [
|
|
19
|
-
infoFeature,
|
|
20
|
-
indexCodebaseFeature,
|
|
21
|
-
searchCodeFeature,
|
|
22
|
-
getIndexStatusFeature,
|
|
23
|
-
updateIndexFeature,
|
|
24
|
-
];
|
|
25
|
-
export function getFeature(name) {
|
|
26
|
-
return features.find((f) => f.name === name);
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/features/index.ts"],"names":[],"mappings":"AACA,OAA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{
|
|
4
|
-
format: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
5
|
-
json: "json";
|
|
6
|
-
text: "text";
|
|
7
|
-
}>>>;
|
|
8
|
-
}, z.core.$strip>;
|
|
9
|
-
export type InfoInput = z.infer<typeof infoSchema>;
|
|
10
|
-
export interface ServerInfo {
|
|
11
|
-
name: string;
|
|
12
|
-
fullName: string;
|
|
13
|
-
version: string;
|
|
14
|
-
description: string | undefined;
|
|
15
|
-
}
|
|
16
|
-
export declare function getServerInfo(): ServerInfo;
|
|
17
|
-
export declare function execute(input: InfoInput): FeatureResult;
|
|
18
|
-
export declare const infoFeature: Feature<typeof infoSchema>;
|
|
19
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/info/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG9D,eAAO,MAAM,UAAU;;;;;iBAMrB,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEnD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,wBAAgB,aAAa,IAAI,UAAU,CAO1C;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,aAAa,CAoBvD;AAED,eAAO,MAAM,WAAW,EAAE,OAAO,CAAC,OAAO,UAAU,CAMlD,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { config } from "@config";
|
|
3
|
-
export const infoSchema = z.object({
|
|
4
|
-
format: z
|
|
5
|
-
.enum(["json", "text"])
|
|
6
|
-
.optional()
|
|
7
|
-
.default("text")
|
|
8
|
-
.describe("Output format"),
|
|
9
|
-
});
|
|
10
|
-
export function getServerInfo() {
|
|
11
|
-
return {
|
|
12
|
-
name: config.name,
|
|
13
|
-
fullName: config.fullName,
|
|
14
|
-
version: config.version,
|
|
15
|
-
description: config.description,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export function execute(input) {
|
|
19
|
-
const info = getServerInfo();
|
|
20
|
-
if (input.format === "json") {
|
|
21
|
-
return {
|
|
22
|
-
success: true,
|
|
23
|
-
data: info,
|
|
24
|
-
message: JSON.stringify(info, null, 2),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
const description = info.description ?? "";
|
|
28
|
-
const text = `${info.fullName} (${info.name}) v${info.version}\n${description}`.trim();
|
|
29
|
-
return {
|
|
30
|
-
success: true,
|
|
31
|
-
data: info,
|
|
32
|
-
message: text,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export const infoFeature = {
|
|
36
|
-
name: "get_server_info",
|
|
37
|
-
description: "Get SRC server version and capabilities. Use to verify the MCP server is running correctly.",
|
|
38
|
-
schema: infoSchema,
|
|
39
|
-
execute,
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/features/info/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,MAAM,EAAE,CAAC;SACN,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;SACtB,QAAQ,EAAE;SACV,OAAO,CAAC,MAAM,CAAC;SACf,QAAQ,CAAC,eAAe,CAAC;CAC7B,CAAC,CAAC;AAWH,MAAM,UAAU,aAAa;IAC3B,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,WAAW,EAAE,MAAM,CAAC,WAAW;KAChC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAgB;IACtC,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC;IAE7B,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC5B,OAAO;YACL,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;SACvC,CAAC;IACJ,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC;IAC3C,MAAM,IAAI,GACR,GAAG,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,OAAO,KAAK,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;IAE5E,OAAO;QACL,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAA+B;IACrD,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACT,6FAA6F;IAC/F,MAAM,EAAE,UAAU;IAClB,OAAO;CACR,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { Feature, FeatureResult } from "@features/types";
|
|
3
|
-
export declare const listSymbolsSchema: z.ZodObject<{
|
|
4
|
-
file_path: z.ZodOptional<z.ZodString>;
|
|
5
|
-
content: z.ZodOptional<z.ZodString>;
|
|
6
|
-
language: z.ZodOptional<z.ZodString>;
|
|
7
|
-
types: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
8
|
-
function: "function";
|
|
9
|
-
enum: "enum";
|
|
10
|
-
type: "type";
|
|
11
|
-
class: "class";
|
|
12
|
-
variable: "variable";
|
|
13
|
-
constant: "constant";
|
|
14
|
-
interface: "interface";
|
|
15
|
-
method: "method";
|
|
16
|
-
property: "property";
|
|
17
|
-
}>>>;
|
|
18
|
-
}, z.core.$strip>;
|
|
19
|
-
export type ListSymbolsInput = z.infer<typeof listSymbolsSchema>;
|
|
20
|
-
export declare function execute(input: ListSymbolsInput): Promise<FeatureResult>;
|
|
21
|
-
export declare const listSymbolsFeature: Feature<typeof listSymbolsSchema>;
|
|
22
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/list-symbols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAe9D,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;iBA2B1B,CAAC;AAEL,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEjE,wBAAsB,OAAO,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,CAyC7E;AAED,eAAO,MAAM,kBAAkB,EAAE,OAAO,CAAC,OAAO,iBAAiB,CAMhE,CAAC"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { parseCode } from "@core/parser";
|
|
3
|
-
import { extractSymbols } from "@core/symbols";
|
|
4
|
-
import { errorResult, readContent, successResult } from "@features/utils";
|
|
5
|
-
const symbolTypeValues = [
|
|
6
|
-
"function",
|
|
7
|
-
"class",
|
|
8
|
-
"variable",
|
|
9
|
-
"constant",
|
|
10
|
-
"interface",
|
|
11
|
-
"type",
|
|
12
|
-
"enum",
|
|
13
|
-
"method",
|
|
14
|
-
"property",
|
|
15
|
-
];
|
|
16
|
-
export const listSymbolsSchema = z
|
|
17
|
-
.object({
|
|
18
|
-
file_path: z
|
|
19
|
-
.string()
|
|
20
|
-
.optional()
|
|
21
|
-
.describe("Path to the file to analyze (either file_path or content required)"),
|
|
22
|
-
content: z
|
|
23
|
-
.string()
|
|
24
|
-
.optional()
|
|
25
|
-
.describe("Code content to analyze directly (either file_path or content required)"),
|
|
26
|
-
language: z
|
|
27
|
-
.string()
|
|
28
|
-
.optional()
|
|
29
|
-
.describe("Language name (auto-detected from file path if not provided)"),
|
|
30
|
-
types: z
|
|
31
|
-
.array(z.enum(symbolTypeValues))
|
|
32
|
-
.optional()
|
|
33
|
-
.describe("Filter by symbol types: function, class, variable, constant, interface, type, enum, method, property"),
|
|
34
|
-
})
|
|
35
|
-
.refine((data) => data.file_path ?? data.content, {
|
|
36
|
-
message: "Either file_path or content must be provided",
|
|
37
|
-
});
|
|
38
|
-
export async function execute(input) {
|
|
39
|
-
const { file_path, content: inputContent, language, types } = input;
|
|
40
|
-
// Get content using shared helper
|
|
41
|
-
const contentResult = readContent(file_path, inputContent);
|
|
42
|
-
if (!contentResult.success) {
|
|
43
|
-
return { success: false, error: contentResult.error };
|
|
44
|
-
}
|
|
45
|
-
try {
|
|
46
|
-
// Parse the code
|
|
47
|
-
const parseResult = await parseCode(contentResult.content, {
|
|
48
|
-
language,
|
|
49
|
-
filePath: file_path,
|
|
50
|
-
});
|
|
51
|
-
// Build filter
|
|
52
|
-
const filter = {};
|
|
53
|
-
if (types && types.length > 0) {
|
|
54
|
-
filter.types = types;
|
|
55
|
-
}
|
|
56
|
-
// Extract symbols
|
|
57
|
-
const { symbols, summary } = extractSymbols(parseResult.tree, parseResult.languageInstance, parseResult.language, filter);
|
|
58
|
-
return successResult({
|
|
59
|
-
symbols,
|
|
60
|
-
summary,
|
|
61
|
-
language: parseResult.language,
|
|
62
|
-
}, `Found ${String(summary.total)} symbol${summary.total === 1 ? "" : "s"} in ${parseResult.language} code`);
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
return errorResult("extract symbols", error);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
export const listSymbolsFeature = {
|
|
69
|
-
name: "list_symbols",
|
|
70
|
-
description: "Extract all code symbols (functions, classes, variables, etc.) from a file. Returns structured information including name, type, location, and signature for each symbol.",
|
|
71
|
-
schema: listSymbolsSchema,
|
|
72
|
-
execute,
|
|
73
|
-
};
|
|
74
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/features/list-symbols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAqB,MAAM,eAAe,CAAC;AAGlE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE1E,MAAM,gBAAgB,GAAG;IACvB,UAAU;IACV,OAAO;IACP,UAAU;IACV,UAAU;IACV,WAAW;IACX,MAAM;IACN,MAAM;IACN,QAAQ;IACR,UAAU;CACF,CAAC;AAEX,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC;KAC/B,MAAM,CAAC;IACN,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,oEAAoE,CACrE;IACH,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,yEAAyE,CAC1E;IACH,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,8DAA8D,CAAC;IAC3E,KAAK,EAAE,CAAC;SACL,KAAK,C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AO,CAAC,KAAK,CAAC,UAAU,OAAO,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,WAAW,CAAC,QAAQ,OAAO,CACzG,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,WAAW,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAsC;IACnE,IAAI,EAAE,cAAc;IACpB,WAAW,EACT,2KAA2K;IAC7K,MAAM,EAAE,iBAAiB;IACzB,OAAO;CACR,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { Feature, FeatureResult } from "@features/types";
|
|
3
|
-
export declare const parseAstSchema: z.ZodObject<{
|
|
4
|
-
file_path: z.ZodOptional<z.ZodString>;
|
|
5
|
-
content: z.ZodOptional<z.ZodString>;
|
|
6
|
-
language: z.ZodOptional<z.ZodString>;
|
|
7
|
-
max_depth: z.ZodOptional<z.ZodNumber>;
|
|
8
|
-
}, z.core.$strip>;
|
|
9
|
-
export type ParseAstInput = z.infer<typeof parseAstSchema>;
|
|
10
|
-
export declare function execute(input: ParseAstInput): Promise<FeatureResult>;
|
|
11
|
-
export declare const parseAstFeature: Feature<typeof parseAstSchema>;
|
|
12
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/parse-ast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG9D,eAAO,MAAM,cAAc;;;;;iBA2BvB,CAAC;AAEL,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE3D,wBAAsB,OAAO,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CA2C1E;AAED,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,OAAO,cAAc,CAM1D,CAAC"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { getASTRoot, parseCode } from "@core/parser";
|
|
3
|
-
import { errorResult, readContent, successResult } from "@features/utils";
|
|
4
|
-
export const parseAstSchema = z
|
|
5
|
-
.object({
|
|
6
|
-
file_path: z
|
|
7
|
-
.string()
|
|
8
|
-
.optional()
|
|
9
|
-
.describe("Path to the file to parse (either file_path or content required)"),
|
|
10
|
-
content: z
|
|
11
|
-
.string()
|
|
12
|
-
.optional()
|
|
13
|
-
.describe("Code content to parse directly (either file_path or content required)"),
|
|
14
|
-
language: z
|
|
15
|
-
.string()
|
|
16
|
-
.optional()
|
|
17
|
-
.describe("Language name (auto-detected from file path if not provided)"),
|
|
18
|
-
max_depth: z
|
|
19
|
-
.number()
|
|
20
|
-
.int()
|
|
21
|
-
.positive()
|
|
22
|
-
.optional()
|
|
23
|
-
.describe("Maximum depth of AST to return (default: unlimited)"),
|
|
24
|
-
})
|
|
25
|
-
.refine((data) => data.file_path ?? data.content, {
|
|
26
|
-
message: "Either file_path or content must be provided",
|
|
27
|
-
});
|
|
28
|
-
export async function execute(input) {
|
|
29
|
-
const { file_path, content: inputContent, language, max_depth } = input;
|
|
30
|
-
// Get content
|
|
31
|
-
const contentResult = readContent(file_path, inputContent);
|
|
32
|
-
if (!contentResult.success) {
|
|
33
|
-
return { success: false, error: contentResult.error };
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
// Parse the code
|
|
37
|
-
const parseResult = await parseCode(contentResult.content, {
|
|
38
|
-
language,
|
|
39
|
-
filePath: file_path,
|
|
40
|
-
});
|
|
41
|
-
// Get AST root with optional depth limit
|
|
42
|
-
const root = getASTRoot(parseResult, max_depth);
|
|
43
|
-
// Count nodes (without depth limit for accurate count)
|
|
44
|
-
const fullRoot = getASTRoot(parseResult);
|
|
45
|
-
const countNodesRecursive = (node) => {
|
|
46
|
-
let count = 1;
|
|
47
|
-
if (node.children) {
|
|
48
|
-
for (const child of node.children) {
|
|
49
|
-
count += countNodesRecursive(child);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return count;
|
|
53
|
-
};
|
|
54
|
-
const nodeCount = countNodesRecursive(fullRoot);
|
|
55
|
-
return successResult({
|
|
56
|
-
language: parseResult.language,
|
|
57
|
-
root,
|
|
58
|
-
node_count: nodeCount,
|
|
59
|
-
}, `Parsed ${parseResult.language} code with ${String(nodeCount)} nodes`);
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
return errorResult("parse", error);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
export const parseAstFeature = {
|
|
66
|
-
name: "parse_ast",
|
|
67
|
-
description: "Parse code and return the Abstract Syntax Tree (AST). Supports multiple languages including JavaScript, TypeScript, Python, Go, Rust, Java, C, C++, and more.",
|
|
68
|
-
schema: parseAstSchema,
|
|
69
|
-
execute,
|
|
70
|
-
};
|
|
71
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/features/parse-ast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE1E,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;KAC5B,MAAM,CAAC;IACN,SAAS,EAAE,CAAC;SACT,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,kEAAkE,CACnE;IACH,OAAO,EAAE,CAAC;SAC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,CAAC;gBAClB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;oBAClC,KAAK,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAC;gBACtC,CAAC;YACH,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC;QACF,MAAM,SAAS,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QAEhD,OAAO,aAAa,CAClB;YACE,QAAQ,EAAE,WAAW,CAAC,QAAQ;YAC9B,IAAI;YACJ,UAAU,EAAE,SAAS;SACtB,EACD,UAAU,WAAW,CAAC,QAAQ,cAAc,MAAM,CAAC,SAAS,CAAC,QAAQ,CACtE,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAmC;IAC7D,IAAI,EAAE,WAAW;IACjB,WAAW,EACT,+JAA+J;IACjK,MAAM,EAAE,cAAc;IACtB,OAAO;CACR,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { Feature, FeatureResult } from "@features/types";
|
|
3
|
-
export declare const queryCodeSchema: z.ZodObject<{
|
|
4
|
-
file_path: z.ZodOptional<z.ZodString>;
|
|
5
|
-
content: z.ZodOptional<z.ZodString>;
|
|
6
|
-
language: z.ZodOptional<z.ZodString>;
|
|
7
|
-
query: z.ZodOptional<z.ZodString>;
|
|
8
|
-
preset: z.ZodOptional<z.ZodEnum<{
|
|
9
|
-
functions: "functions";
|
|
10
|
-
classes: "classes";
|
|
11
|
-
imports: "imports";
|
|
12
|
-
exports: "exports";
|
|
13
|
-
comments: "comments";
|
|
14
|
-
strings: "strings";
|
|
15
|
-
variables: "variables";
|
|
16
|
-
types: "types";
|
|
17
|
-
}>>;
|
|
18
|
-
max_matches: z.ZodOptional<z.ZodNumber>;
|
|
19
|
-
}, z.core.$strip>;
|
|
20
|
-
export type QueryCodeInput = z.infer<typeof queryCodeSchema>;
|
|
21
|
-
export declare function execute(input: QueryCodeInput): Promise<FeatureResult>;
|
|
22
|
-
export declare const queryCodeFeature: Feature<typeof queryCodeSchema>;
|
|
23
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/query-code/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAmB9D,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;iBAwCxB,CAAC;AAEL,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE7D,wBAAsB,OAAO,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAiE3E;AAED,eAAO,MAAM,gBAAgB,EAAE,OAAO,CAAC,OAAO,eAAe,CAM5D,CAAC"}
|