@zilliz/claude-context-mcp 0.0.1

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.
@@ -0,0 +1,564 @@
1
+ import * as fs from "fs";
2
+ import * as path from "path";
3
+ import * as crypto from "crypto";
4
+ import { COLLECTION_LIMIT_MESSAGE } from "@zilliz/claude-context-core";
5
+ import { ensureAbsolutePath, truncateContent, trackCodebasePath } from "./utils.js";
6
+ export class ToolHandlers {
7
+ constructor(codeContext, snapshotManager) {
8
+ this.indexingStats = null;
9
+ this.codeContext = codeContext;
10
+ this.snapshotManager = snapshotManager;
11
+ this.currentWorkspace = process.cwd();
12
+ console.log(`[WORKSPACE] Current workspace: ${this.currentWorkspace}`);
13
+ }
14
+ /**
15
+ * Sync indexed codebases from Zilliz Cloud collections
16
+ * This method fetches all collections from the vector database,
17
+ * gets the first document from each collection to extract codebasePath from metadata,
18
+ * and updates the snapshot with discovered codebases.
19
+ *
20
+ * Logic: Compare mcp-codebase-snapshot.json with zilliz cloud collections
21
+ * - If local snapshot has extra directories (not in cloud), remove them
22
+ * - If local snapshot is missing directories (exist in cloud), ignore them
23
+ */
24
+ async syncIndexedCodebasesFromCloud() {
25
+ try {
26
+ console.log(`[SYNC-CLOUD] ๐Ÿ”„ Syncing indexed codebases from Zilliz Cloud...`);
27
+ // Get all collections using the interface method
28
+ const vectorDb = this.codeContext['vectorDatabase'];
29
+ // Use the new listCollections method from the interface
30
+ const collections = await vectorDb.listCollections();
31
+ console.log(`[SYNC-CLOUD] ๐Ÿ“‹ Found ${collections.length} collections in Zilliz Cloud`);
32
+ if (collections.length === 0) {
33
+ console.log(`[SYNC-CLOUD] โœ… No collections found in cloud`);
34
+ // If no collections in cloud, remove all local codebases
35
+ const localCodebases = this.snapshotManager.getIndexedCodebases();
36
+ if (localCodebases.length > 0) {
37
+ console.log(`[SYNC-CLOUD] ๐Ÿงน Removing ${localCodebases.length} local codebases as cloud has no collections`);
38
+ for (const codebasePath of localCodebases) {
39
+ this.snapshotManager.removeIndexedCodebase(codebasePath);
40
+ console.log(`[SYNC-CLOUD] โž– Removed local codebase: ${codebasePath}`);
41
+ }
42
+ this.snapshotManager.saveCodebaseSnapshot();
43
+ console.log(`[SYNC-CLOUD] ๐Ÿ’พ Updated snapshot to match empty cloud state`);
44
+ }
45
+ return;
46
+ }
47
+ const cloudCodebases = new Set();
48
+ // Check each collection for codebase path
49
+ for (const collectionName of collections) {
50
+ try {
51
+ // Skip collections that don't match the code_chunks pattern
52
+ if (!collectionName.startsWith('code_chunks_')) {
53
+ console.log(`[SYNC-CLOUD] โญ๏ธ Skipping non-code collection: ${collectionName}`);
54
+ continue;
55
+ }
56
+ console.log(`[SYNC-CLOUD] ๐Ÿ” Checking collection: ${collectionName}`);
57
+ // Query the first document to get metadata
58
+ const results = await vectorDb.query(collectionName, '', // Empty filter to get all results
59
+ ['metadata'], // Only fetch metadata field
60
+ 1 // Only need one result to extract codebasePath
61
+ );
62
+ if (results && results.length > 0) {
63
+ const firstResult = results[0];
64
+ const metadataStr = firstResult.metadata;
65
+ if (metadataStr) {
66
+ try {
67
+ const metadata = JSON.parse(metadataStr);
68
+ const codebasePath = metadata.codebasePath;
69
+ if (codebasePath && typeof codebasePath === 'string') {
70
+ console.log(`[SYNC-CLOUD] ๐Ÿ“ Found codebase path: ${codebasePath} in collection: ${collectionName}`);
71
+ cloudCodebases.add(codebasePath);
72
+ }
73
+ else {
74
+ console.warn(`[SYNC-CLOUD] โš ๏ธ No codebasePath found in metadata for collection: ${collectionName}`);
75
+ }
76
+ }
77
+ catch (parseError) {
78
+ console.warn(`[SYNC-CLOUD] โš ๏ธ Failed to parse metadata JSON for collection ${collectionName}:`, parseError);
79
+ }
80
+ }
81
+ else {
82
+ console.warn(`[SYNC-CLOUD] โš ๏ธ No metadata found in collection: ${collectionName}`);
83
+ }
84
+ }
85
+ else {
86
+ console.log(`[SYNC-CLOUD] โ„น๏ธ Collection ${collectionName} is empty`);
87
+ }
88
+ }
89
+ catch (collectionError) {
90
+ console.warn(`[SYNC-CLOUD] โš ๏ธ Error checking collection ${collectionName}:`, collectionError.message || collectionError);
91
+ // Continue with next collection
92
+ }
93
+ }
94
+ console.log(`[SYNC-CLOUD] ๐Ÿ“Š Found ${cloudCodebases.size} valid codebases in cloud`);
95
+ // Get current local codebases
96
+ const localCodebases = new Set(this.snapshotManager.getIndexedCodebases());
97
+ console.log(`[SYNC-CLOUD] ๐Ÿ“Š Found ${localCodebases.size} local codebases in snapshot`);
98
+ let hasChanges = false;
99
+ // Remove local codebases that don't exist in cloud
100
+ for (const localCodebase of localCodebases) {
101
+ if (!cloudCodebases.has(localCodebase)) {
102
+ this.snapshotManager.removeIndexedCodebase(localCodebase);
103
+ hasChanges = true;
104
+ console.log(`[SYNC-CLOUD] โž– Removed local codebase (not in cloud): ${localCodebase}`);
105
+ }
106
+ }
107
+ // Note: We don't add cloud codebases that are missing locally (as per user requirement)
108
+ console.log(`[SYNC-CLOUD] โ„น๏ธ Skipping addition of cloud codebases not present locally (per sync policy)`);
109
+ if (hasChanges) {
110
+ this.snapshotManager.saveCodebaseSnapshot();
111
+ console.log(`[SYNC-CLOUD] ๐Ÿ’พ Updated snapshot to match cloud state`);
112
+ }
113
+ else {
114
+ console.log(`[SYNC-CLOUD] โœ… Local snapshot already matches cloud state`);
115
+ }
116
+ console.log(`[SYNC-CLOUD] โœ… Cloud sync completed successfully`);
117
+ }
118
+ catch (error) {
119
+ console.error(`[SYNC-CLOUD] โŒ Error syncing codebases from cloud:`, error.message || error);
120
+ // Don't throw - this is not critical for the main functionality
121
+ }
122
+ }
123
+ async handleIndexCodebase(args) {
124
+ const { path: codebasePath, force, splitter, customExtensions, ignorePatterns } = args;
125
+ const forceReindex = force || false;
126
+ const splitterType = splitter || 'ast'; // Default to AST
127
+ const customFileExtensions = customExtensions || [];
128
+ const customIgnorePatterns = ignorePatterns || [];
129
+ try {
130
+ // Sync indexed codebases from cloud first
131
+ await this.syncIndexedCodebasesFromCloud();
132
+ // Validate splitter parameter
133
+ if (splitterType !== 'ast' && splitterType !== 'langchain') {
134
+ return {
135
+ content: [{
136
+ type: "text",
137
+ text: `Error: Invalid splitter type '${splitterType}'. Must be 'ast' or 'langchain'.`
138
+ }],
139
+ isError: true
140
+ };
141
+ }
142
+ // Force absolute path resolution - warn if relative path provided
143
+ const absolutePath = ensureAbsolutePath(codebasePath);
144
+ // Validate path exists
145
+ if (!fs.existsSync(absolutePath)) {
146
+ return {
147
+ content: [{
148
+ type: "text",
149
+ text: `Error: Path '${absolutePath}' does not exist. Original input: '${codebasePath}'`
150
+ }],
151
+ isError: true
152
+ };
153
+ }
154
+ // Check if it's a directory
155
+ const stat = fs.statSync(absolutePath);
156
+ if (!stat.isDirectory()) {
157
+ return {
158
+ content: [{
159
+ type: "text",
160
+ text: `Error: Path '${absolutePath}' is not a directory`
161
+ }],
162
+ isError: true
163
+ };
164
+ }
165
+ // Check if already indexing
166
+ if (this.snapshotManager.getIndexingCodebases().includes(absolutePath)) {
167
+ return {
168
+ content: [{
169
+ type: "text",
170
+ text: `Codebase '${absolutePath}' is already being indexed in the background. Please wait for completion.`
171
+ }],
172
+ isError: true
173
+ };
174
+ }
175
+ // Check if already indexed (unless force is true)
176
+ if (!forceReindex && this.snapshotManager.getIndexedCodebases().includes(absolutePath)) {
177
+ return {
178
+ content: [{
179
+ type: "text",
180
+ text: `Codebase '${absolutePath}' is already indexed. Use force=true to re-index.`
181
+ }],
182
+ isError: true
183
+ };
184
+ }
185
+ // If force reindex and codebase is already indexed, remove it from indexed list
186
+ if (forceReindex && this.snapshotManager.getIndexedCodebases().includes(absolutePath)) {
187
+ console.log(`[FORCE-REINDEX] ๐Ÿ”„ Removing '${absolutePath}' from indexed list for re-indexing`);
188
+ this.snapshotManager.removeIndexedCodebase(absolutePath);
189
+ }
190
+ // CRITICAL: Pre-index collection creation validation
191
+ try {
192
+ const normalizedPath = path.resolve(absolutePath);
193
+ const hash = crypto.createHash('md5').update(normalizedPath).digest('hex');
194
+ const collectionName = `code_chunks_${hash.substring(0, 8)}`;
195
+ console.log(`[INDEX-VALIDATION] ๐Ÿ” Validating collection creation for: ${collectionName}`);
196
+ // Get embedding dimension for collection creation
197
+ const embeddingProvider = this.codeContext['embedding'];
198
+ const dimension = embeddingProvider.getDimension();
199
+ // If force reindex, clear existing collection first
200
+ if (forceReindex) {
201
+ console.log(`[INDEX-VALIDATION] ๐Ÿงน Force reindex enabled, clearing existing collection: ${collectionName}`);
202
+ try {
203
+ await this.codeContext['vectorDatabase'].dropCollection(collectionName);
204
+ console.log(`[INDEX-VALIDATION] โœ… Existing collection cleared: ${collectionName}`);
205
+ }
206
+ catch (dropError) {
207
+ // Collection might not exist, which is fine
208
+ console.log(`[INDEX-VALIDATION] โ„น๏ธ Collection ${collectionName} does not exist or already cleared`);
209
+ }
210
+ }
211
+ // Attempt to create collection - this will throw COLLECTION_LIMIT_MESSAGE if limit reached
212
+ await this.codeContext['vectorDatabase'].createCollection(collectionName, dimension, `Code context collection: ${collectionName}`);
213
+ // If creation succeeds, immediately drop the test collection
214
+ await this.codeContext['vectorDatabase'].dropCollection(collectionName);
215
+ console.log(`[INDEX-VALIDATION] โœ… Collection creation validated successfully`);
216
+ }
217
+ catch (validationError) {
218
+ const errorMessage = typeof validationError === 'string' ? validationError :
219
+ (validationError instanceof Error ? validationError.message : String(validationError));
220
+ if (errorMessage === COLLECTION_LIMIT_MESSAGE || errorMessage.includes(COLLECTION_LIMIT_MESSAGE)) {
221
+ console.error(`[INDEX-VALIDATION] โŒ Collection limit validation failed: ${absolutePath}`);
222
+ // CRITICAL: Immediately return the COLLECTION_LIMIT_MESSAGE to MCP client
223
+ return {
224
+ content: [{
225
+ type: "text",
226
+ text: COLLECTION_LIMIT_MESSAGE
227
+ }],
228
+ isError: true
229
+ };
230
+ }
231
+ else {
232
+ // Handle other collection creation errors
233
+ console.error(`[INDEX-VALIDATION] โŒ Collection creation validation failed:`, validationError);
234
+ return {
235
+ content: [{
236
+ type: "text",
237
+ text: `Error validating collection creation: ${validationError.message || validationError}`
238
+ }],
239
+ isError: true
240
+ };
241
+ }
242
+ }
243
+ // Add custom extensions if provided
244
+ if (customFileExtensions.length > 0) {
245
+ console.log(`[CUSTOM-EXTENSIONS] Adding ${customFileExtensions.length} custom extensions: ${customFileExtensions.join(', ')}`);
246
+ this.codeContext.addCustomExtensions(customFileExtensions);
247
+ }
248
+ // Add custom ignore patterns if provided (before loading file-based patterns)
249
+ if (customIgnorePatterns.length > 0) {
250
+ console.log(`[IGNORE-PATTERNS] Adding ${customIgnorePatterns.length} custom ignore patterns: ${customIgnorePatterns.join(', ')}`);
251
+ this.codeContext.addCustomIgnorePatterns(customIgnorePatterns);
252
+ }
253
+ // Add to indexing list and save snapshot immediately
254
+ this.snapshotManager.addIndexingCodebase(absolutePath);
255
+ this.snapshotManager.saveCodebaseSnapshot();
256
+ // Track the codebase path for syncing
257
+ trackCodebasePath(absolutePath);
258
+ // Start background indexing - now safe to proceed
259
+ this.startBackgroundIndexing(absolutePath, forceReindex, splitterType);
260
+ const pathInfo = codebasePath !== absolutePath
261
+ ? `\nNote: Input path '${codebasePath}' was resolved to absolute path '${absolutePath}'`
262
+ : '';
263
+ const extensionInfo = customFileExtensions.length > 0
264
+ ? `\nUsing ${customFileExtensions.length} custom extensions: ${customFileExtensions.join(', ')}`
265
+ : '';
266
+ const ignoreInfo = customIgnorePatterns.length > 0
267
+ ? `\nUsing ${customIgnorePatterns.length} custom ignore patterns: ${customIgnorePatterns.join(', ')}`
268
+ : '';
269
+ return {
270
+ content: [{
271
+ type: "text",
272
+ text: `Started background indexing for codebase '${absolutePath}' using ${splitterType.toUpperCase()} splitter.${pathInfo}${extensionInfo}${ignoreInfo}\n\nIndexing is running in the background. You can search the codebase while indexing is in progress, but results may be incomplete until indexing completes.`
273
+ }]
274
+ };
275
+ }
276
+ catch (error) {
277
+ // Enhanced error handling to prevent MCP service crash
278
+ console.error('Error in handleIndexCodebase:', error);
279
+ // Ensure we always return a proper MCP response, never throw
280
+ return {
281
+ content: [{
282
+ type: "text",
283
+ text: `Error starting indexing: ${error.message || error}`
284
+ }],
285
+ isError: true
286
+ };
287
+ }
288
+ }
289
+ async startBackgroundIndexing(codebasePath, forceReindex, splitterType) {
290
+ const absolutePath = codebasePath;
291
+ try {
292
+ console.log(`[BACKGROUND-INDEX] Starting background indexing for: ${absolutePath}`);
293
+ // Note: If force reindex, collection was already cleared during validation phase
294
+ if (forceReindex) {
295
+ console.log(`[BACKGROUND-INDEX] โ„น๏ธ Force reindex mode - collection was already cleared during validation`);
296
+ }
297
+ // Use the existing CodeContext instance for indexing.
298
+ let contextForThisTask = this.codeContext;
299
+ if (splitterType !== 'ast') {
300
+ console.warn(`[BACKGROUND-INDEX] Non-AST splitter '${splitterType}' requested; falling back to AST splitter`);
301
+ }
302
+ // Generate collection name
303
+ const normalizedPath = path.resolve(absolutePath);
304
+ const hash = crypto.createHash('md5').update(normalizedPath).digest('hex');
305
+ const collectionName = `code_chunks_${hash.substring(0, 8)}`;
306
+ // Initialize file synchronizer with proper ignore patterns
307
+ const { FileSynchronizer } = await import("@zilliz/claude-context-core");
308
+ const ignorePatterns = this.codeContext['ignorePatterns'] || [];
309
+ console.log(`[BACKGROUND-INDEX] Using ignore patterns: ${ignorePatterns.join(', ')}`);
310
+ const synchronizer = new FileSynchronizer(absolutePath, ignorePatterns);
311
+ await synchronizer.initialize();
312
+ // Store synchronizer in the context's internal map
313
+ this.codeContext['synchronizers'].set(collectionName, synchronizer);
314
+ if (contextForThisTask !== this.codeContext) {
315
+ contextForThisTask['synchronizers'].set(collectionName, synchronizer);
316
+ }
317
+ console.log(`[BACKGROUND-INDEX] Starting indexing with ${splitterType} splitter for: ${absolutePath}`);
318
+ // Log embedding provider information before indexing
319
+ const embeddingProvider = this.codeContext['embedding'];
320
+ console.log(`[BACKGROUND-INDEX] ๐Ÿง  Using embedding provider: ${embeddingProvider.getProvider()} with dimension: ${embeddingProvider.getDimension()}`);
321
+ // Start indexing with the appropriate context
322
+ console.log(`[BACKGROUND-INDEX] ๐Ÿš€ Beginning codebase indexing process...`);
323
+ const stats = await contextForThisTask.indexCodebase(absolutePath);
324
+ console.log(`[BACKGROUND-INDEX] โœ… Indexing completed successfully! Files: ${stats.indexedFiles}, Chunks: ${stats.totalChunks}`);
325
+ // Move from indexing to indexed list
326
+ this.snapshotManager.moveFromIndexingToIndexed(absolutePath);
327
+ this.indexingStats = { indexedFiles: stats.indexedFiles, totalChunks: stats.totalChunks };
328
+ // Save snapshot after updating codebase lists
329
+ this.snapshotManager.saveCodebaseSnapshot();
330
+ let message = `Background indexing completed for '${absolutePath}' using ${splitterType.toUpperCase()} splitter.\nIndexed ${stats.indexedFiles} files, ${stats.totalChunks} chunks.`;
331
+ if (stats.status === 'limit_reached') {
332
+ message += `\nโš ๏ธ Warning: Indexing stopped because the chunk limit (450,000) was reached. The index may be incomplete.`;
333
+ }
334
+ console.log(`[BACKGROUND-INDEX] ${message}`);
335
+ }
336
+ catch (error) {
337
+ console.error(`[BACKGROUND-INDEX] Error during indexing for ${absolutePath}:`, error);
338
+ // Remove from indexing list on error
339
+ this.snapshotManager.removeIndexingCodebase(absolutePath);
340
+ this.snapshotManager.saveCodebaseSnapshot();
341
+ // Log error but don't crash MCP service - indexing errors are handled gracefully
342
+ console.error(`[BACKGROUND-INDEX] Indexing failed for ${absolutePath}: ${error.message || error}`);
343
+ }
344
+ }
345
+ async handleSearchCode(args) {
346
+ const { path: codebasePath, query, limit = 10 } = args;
347
+ const resultLimit = limit || 10;
348
+ try {
349
+ // Sync indexed codebases from cloud first
350
+ await this.syncIndexedCodebasesFromCloud();
351
+ // Force absolute path resolution - warn if relative path provided
352
+ const absolutePath = ensureAbsolutePath(codebasePath);
353
+ // Validate path exists
354
+ if (!fs.existsSync(absolutePath)) {
355
+ return {
356
+ content: [{
357
+ type: "text",
358
+ text: `Error: Path '${absolutePath}' does not exist. Original input: '${codebasePath}'`
359
+ }],
360
+ isError: true
361
+ };
362
+ }
363
+ // Check if it's a directory
364
+ const stat = fs.statSync(absolutePath);
365
+ if (!stat.isDirectory()) {
366
+ return {
367
+ content: [{
368
+ type: "text",
369
+ text: `Error: Path '${absolutePath}' is not a directory`
370
+ }],
371
+ isError: true
372
+ };
373
+ }
374
+ trackCodebasePath(absolutePath);
375
+ // Check if this codebase is indexed or being indexed
376
+ const isIndexed = this.snapshotManager.getIndexedCodebases().includes(absolutePath);
377
+ const isIndexing = this.snapshotManager.getIndexingCodebases().includes(absolutePath);
378
+ if (!isIndexed && !isIndexing) {
379
+ return {
380
+ content: [{
381
+ type: "text",
382
+ text: `Error: Codebase '${absolutePath}' is not indexed. Please index it first using the index_codebase tool.`
383
+ }],
384
+ isError: true
385
+ };
386
+ }
387
+ // Show indexing status if codebase is being indexed
388
+ let indexingStatusMessage = '';
389
+ if (isIndexing) {
390
+ indexingStatusMessage = `\nโš ๏ธ **Indexing in Progress**: This codebase is currently being indexed in the background. Search results may be incomplete until indexing completes.`;
391
+ }
392
+ console.log(`[SEARCH] Searching in codebase: ${absolutePath}`);
393
+ console.log(`[SEARCH] Query: "${query}"`);
394
+ console.log(`[SEARCH] Indexing status: ${isIndexing ? 'In Progress' : 'Completed'}`);
395
+ // Log embedding provider information before search
396
+ const embeddingProvider = this.codeContext['embedding'];
397
+ console.log(`[SEARCH] ๐Ÿง  Using embedding provider: ${embeddingProvider.getProvider()} for semantic search`);
398
+ console.log(`[SEARCH] ๐Ÿ” Generating embeddings for query using ${embeddingProvider.getProvider()}...`);
399
+ // Search in the specified codebase
400
+ const searchResults = await this.codeContext.semanticSearch(absolutePath, query, Math.min(resultLimit, 50), 0.3);
401
+ console.log(`[SEARCH] โœ… Search completed! Found ${searchResults.length} results using ${embeddingProvider.getProvider()} embeddings`);
402
+ if (searchResults.length === 0) {
403
+ let noResultsMessage = `No results found for query: "${query}" in codebase '${absolutePath}'`;
404
+ if (isIndexing) {
405
+ noResultsMessage += `\n\nNote: This codebase is still being indexed. Try searching again after indexing completes, or the query may not match any indexed content.`;
406
+ }
407
+ return {
408
+ content: [{
409
+ type: "text",
410
+ text: noResultsMessage
411
+ }]
412
+ };
413
+ }
414
+ // Format results
415
+ const formattedResults = searchResults.map((result, index) => {
416
+ const location = `${result.relativePath}:${result.startLine}-${result.endLine}`;
417
+ const context = truncateContent(result.content, 5000);
418
+ const codebaseInfo = path.basename(absolutePath);
419
+ return `${index + 1}. Code snippet (${result.language}) [${codebaseInfo}]\n` +
420
+ ` Location: ${location}\n` +
421
+ ` Score: ${result.score.toFixed(3)}\n` +
422
+ ` Context: \n\`\`\`${result.language}\n${context}\n\`\`\`\n`;
423
+ }).join('\n');
424
+ let resultMessage = `Found ${searchResults.length} results for query: "${query}" in codebase '${absolutePath}'${indexingStatusMessage}\n\n${formattedResults}`;
425
+ if (isIndexing) {
426
+ resultMessage += `\n\n๐Ÿ’ก **Tip**: This codebase is still being indexed. More results may become available as indexing progresses.`;
427
+ }
428
+ return {
429
+ content: [{
430
+ type: "text",
431
+ text: resultMessage
432
+ }]
433
+ };
434
+ }
435
+ catch (error) {
436
+ // Check if this is the collection limit error
437
+ // Handle both direct string throws and Error objects containing the message
438
+ const errorMessage = typeof error === 'string' ? error : (error instanceof Error ? error.message : String(error));
439
+ if (errorMessage === COLLECTION_LIMIT_MESSAGE || errorMessage.includes(COLLECTION_LIMIT_MESSAGE)) {
440
+ // Return the collection limit message as a successful response
441
+ // This ensures LLM treats it as final answer, not as retryable error
442
+ return {
443
+ content: [{
444
+ type: "text",
445
+ text: COLLECTION_LIMIT_MESSAGE
446
+ }]
447
+ };
448
+ }
449
+ return {
450
+ content: [{
451
+ type: "text",
452
+ text: `Error searching code: ${errorMessage} Please check if the codebase has been indexed first.`
453
+ }],
454
+ isError: true
455
+ };
456
+ }
457
+ }
458
+ async handleClearIndex(args) {
459
+ const { path: codebasePath } = args;
460
+ if (this.snapshotManager.getIndexedCodebases().length === 0 && this.snapshotManager.getIndexingCodebases().length === 0) {
461
+ return {
462
+ content: [{
463
+ type: "text",
464
+ text: "No codebases are currently indexed or being indexed."
465
+ }]
466
+ };
467
+ }
468
+ try {
469
+ // Force absolute path resolution - warn if relative path provided
470
+ const absolutePath = ensureAbsolutePath(codebasePath);
471
+ // Validate path exists
472
+ if (!fs.existsSync(absolutePath)) {
473
+ return {
474
+ content: [{
475
+ type: "text",
476
+ text: `Error: Path '${absolutePath}' does not exist. Original input: '${codebasePath}'`
477
+ }],
478
+ isError: true
479
+ };
480
+ }
481
+ // Check if it's a directory
482
+ const stat = fs.statSync(absolutePath);
483
+ if (!stat.isDirectory()) {
484
+ return {
485
+ content: [{
486
+ type: "text",
487
+ text: `Error: Path '${absolutePath}' is not a directory`
488
+ }],
489
+ isError: true
490
+ };
491
+ }
492
+ // Check if this codebase is indexed or being indexed
493
+ const isIndexed = this.snapshotManager.getIndexedCodebases().includes(absolutePath);
494
+ const isIndexing = this.snapshotManager.getIndexingCodebases().includes(absolutePath);
495
+ if (!isIndexed && !isIndexing) {
496
+ return {
497
+ content: [{
498
+ type: "text",
499
+ text: `Error: Codebase '${absolutePath}' is not indexed or being indexed.`
500
+ }],
501
+ isError: true
502
+ };
503
+ }
504
+ console.log(`[CLEAR] Clearing codebase: ${absolutePath}`);
505
+ try {
506
+ await this.codeContext.clearIndex(absolutePath);
507
+ console.log(`[CLEAR] Successfully cleared index for: ${absolutePath}`);
508
+ }
509
+ catch (error) {
510
+ const errorMsg = `Failed to clear ${absolutePath}: ${error.message}`;
511
+ console.error(`[CLEAR] ${errorMsg}`);
512
+ return {
513
+ content: [{
514
+ type: "text",
515
+ text: errorMsg
516
+ }],
517
+ isError: true
518
+ };
519
+ }
520
+ // Remove the cleared codebase from both lists
521
+ this.snapshotManager.removeIndexedCodebase(absolutePath);
522
+ this.snapshotManager.removeIndexingCodebase(absolutePath);
523
+ // Reset indexing stats if this was the active codebase
524
+ this.indexingStats = null;
525
+ // Save snapshot after clearing index
526
+ this.snapshotManager.saveCodebaseSnapshot();
527
+ let resultText = `Successfully cleared codebase '${absolutePath}'`;
528
+ const remainingIndexed = this.snapshotManager.getIndexedCodebases().length;
529
+ const remainingIndexing = this.snapshotManager.getIndexingCodebases().length;
530
+ if (remainingIndexed > 0 || remainingIndexing > 0) {
531
+ resultText += `\n${remainingIndexed} other indexed codebase(s) and ${remainingIndexing} indexing codebase(s) remain`;
532
+ }
533
+ return {
534
+ content: [{
535
+ type: "text",
536
+ text: resultText
537
+ }]
538
+ };
539
+ }
540
+ catch (error) {
541
+ // Check if this is the collection limit error
542
+ // Handle both direct string throws and Error objects containing the message
543
+ const errorMessage = typeof error === 'string' ? error : (error instanceof Error ? error.message : String(error));
544
+ if (errorMessage === COLLECTION_LIMIT_MESSAGE || errorMessage.includes(COLLECTION_LIMIT_MESSAGE)) {
545
+ // Return the collection limit message as a successful response
546
+ // This ensures LLM treats it as final answer, not as retryable error
547
+ return {
548
+ content: [{
549
+ type: "text",
550
+ text: COLLECTION_LIMIT_MESSAGE
551
+ }]
552
+ };
553
+ }
554
+ return {
555
+ content: [{
556
+ type: "text",
557
+ text: `Error clearing index: ${errorMessage}`
558
+ }],
559
+ isError: true
560
+ };
561
+ }
562
+ }
563
+ }
564
+ //# sourceMappingURL=handlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlers.js","sourceRoot":"","sources":["../src/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAe,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAEpF,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpF,MAAM,OAAO,YAAY;IAMrB,YAAY,WAAwB,EAAE,eAAgC;QAH9D,kBAAa,GAAyD,IAAI,CAAC;QAI/E,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI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3E,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC,oBAAoB,EAAE,CAAC,MAAM,CAAC;YAE7E,IAAI,gBAAgB,GAAG,CAAC,IAAI,iBAAiB,GAAG,CAAC,EAAE,CAAC;gBAChD,UAAU,IAAI,KAAK,gBAAgB,kCAAkC,iBAAiB,8BAA8B,CAAC;YACzH,CAAC;YAED,OAAO;gBACH,OAAO,EAAE,CAAC;wBACN,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,UAAU;qBACnB,CAAC;aACL,CAAC;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,8CAA8C;YAC9C,4EAA4E;YAC5E,MAAM,YAAY,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAElH,IAAI,YAAY,KAAK,wBAAwB,IAAI,YAAY,CAAC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,CAAC;gBAC/F,+DAA+D;gBAC/D,qEAAqE;gBACrE,OAAO;oBACH,OAAO,EAAE,CAAC;4BACN,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,wBAAwB;yBACjC,CAAC;iBACL,CAAC;YACN,CAAC;YAED,OAAO;gBACH,OAAO,EAAE,CAAC;wBACN,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,yBAAyB,YAAY,EAAE;qBAChD,CAAC;gBACF,OAAO,EAAE,IAAI;aAChB,CAAC;QACN,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}