@zilliz/claude-context-mcp 0.1.11 → 0.1.13
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/README.md +49 -2
- package/dist/config.d.ts +8 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +40 -0
- package/dist/config.js.map +1 -1
- package/dist/embedding.d.ts.map +1 -1
- package/dist/embedding.js +4 -3
- package/dist/embedding.js.map +1 -1
- package/dist/handlers.d.ts +8 -0
- package/dist/handlers.d.ts.map +1 -1
- package/dist/handlers.js +77 -25
- package/dist/handlers.js.map +1 -1
- package/dist/snapshot.d.ts +6 -4
- package/dist/snapshot.d.ts.map +1 -1
- package/dist/snapshot.js +26 -3
- package/dist/snapshot.js.map +1 -1
- package/dist/snapshot.request-options.test.d.ts +2 -0
- package/dist/snapshot.request-options.test.d.ts.map +1 -0
- package/dist/snapshot.request-options.test.js +111 -0
- package/dist/snapshot.request-options.test.js.map +1 -0
- package/dist/splitter.d.ts +6 -0
- package/dist/splitter.d.ts.map +1 -0
- package/dist/splitter.js +16 -0
- package/dist/splitter.js.map +1 -0
- package/dist/sync.d.ts +16 -0
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +155 -6
- package/dist/sync.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -100,7 +100,7 @@ Google's Gemini provides competitive embeddings with good multilingual support.
|
|
|
100
100
|
# Required: Your Gemini API key
|
|
101
101
|
GEMINI_API_KEY=your-gemini-api-key
|
|
102
102
|
|
|
103
|
-
# Optional: Specify embedding model (default: gemini-embedding-001)
|
|
103
|
+
# Optional: Specify embedding model (default: gemini-embedding-001; supports gemini-embedding-2)
|
|
104
104
|
EMBEDDING_MODEL=gemini-embedding-001
|
|
105
105
|
|
|
106
106
|
# Optional: Custom API base URL (for custom endpoints)
|
|
@@ -130,6 +130,9 @@ EMBEDDING_MODEL=nomic-embed-text
|
|
|
130
130
|
|
|
131
131
|
# Optional: Specify Ollama host (default: http://127.0.0.1:11434)
|
|
132
132
|
OLLAMA_HOST=http://127.0.0.1:11434
|
|
133
|
+
|
|
134
|
+
# Optional: Override embedding dimension to skip runtime dimension detection
|
|
135
|
+
EMBEDDING_DIMENSION=768
|
|
133
136
|
```
|
|
134
137
|
|
|
135
138
|
**Setup Instructions:**
|
|
@@ -197,6 +200,49 @@ CODE_CHUNKS_COLLECTION_NAME_OVERRIDE=my_project
|
|
|
197
200
|
|
|
198
201
|
The per-codebase `<pathHash>` suffix is preserved even when the override is set, so the same MCP server can still index multiple repos without collapsing them onto one collection. The override value is sanitized to letters, numbers, and underscores, and truncated to keep the full name within Milvus's 255-char limit. If you unset the variable later, Claude Context switches back to the plain `code_chunks_<pathHash>` naming.
|
|
199
202
|
|
|
203
|
+
#### Trigger File Watcher (Optional)
|
|
204
|
+
|
|
205
|
+
In addition to the periodic background sync, the MCP server watches a sentinel file at `~/.context/.sync-trigger` and starts an immediate re-index whenever the file is modified. This lets external tools (Claude Code `PostToolUse` hooks, editor save hooks, CI scripts, etc.) request a sync on demand instead of waiting for the next polling tick.
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# Default: watcher enabled. Set to false to disable filesystem watching entirely
|
|
209
|
+
# (useful on read-only filesystems or sandboxed environments).
|
|
210
|
+
CLAUDE_CONTEXT_TRIGGER_WATCHER=true
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Example — Claude Code hook that re-indexes after every Edit/Write:
|
|
214
|
+
|
|
215
|
+
```json
|
|
216
|
+
"hooks": {
|
|
217
|
+
"PostToolUse": [
|
|
218
|
+
{ "matcher": "Edit|Write", "hooks": [
|
|
219
|
+
{ "type": "command", "command": "touch ~/.context/.sync-trigger" }
|
|
220
|
+
]}
|
|
221
|
+
]
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Notes:
|
|
226
|
+
- The trigger fires a debounced re-index (2 s window) so rapid touches collapse to a single sync.
|
|
227
|
+
- Triggered syncs go through the same global cross-process lock as background sync, so when multiple MCP processes share `$HOME` only one process performs the work per trigger.
|
|
228
|
+
- The trigger file's *contents* are ignored — only the modification event matters.
|
|
229
|
+
|
|
230
|
+
#### Background Sync Configuration (Optional)
|
|
231
|
+
|
|
232
|
+
By default, the MCP server runs startup + periodic background sync for compatibility with existing installations. The global cross-process sync lock ensures only one local MCP process performs a sync cycle at a time.
|
|
233
|
+
|
|
234
|
+
You can tune or disable periodic polling with environment variables:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
# Default: true. Set to false to disable startup + periodic polling.
|
|
238
|
+
CLAUDE_CONTEXT_BACKGROUND_SYNC=false
|
|
239
|
+
|
|
240
|
+
# Optional: control how often sync runs (default: 300000 = 5 minutes)
|
|
241
|
+
CLAUDE_CONTEXT_SYNC_INTERVAL_MS=60000
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
For multi-instance local stdio setups, set `CLAUDE_CONTEXT_BACKGROUND_SYNC=false` and keep the trigger watcher enabled. That avoids idle polling while still allowing external tools to request immediate re-indexing by touching `~/.context/.sync-trigger`.
|
|
245
|
+
|
|
200
246
|
## Usage with MCP Clients
|
|
201
247
|
|
|
202
248
|
<details>
|
|
@@ -361,6 +407,7 @@ Pasting the following configuration into your Cursor `~/.cursor/mcp.json` file i
|
|
|
361
407
|
"EMBEDDING_PROVIDER": "Ollama",
|
|
362
408
|
"EMBEDDING_MODEL": "nomic-embed-text",
|
|
363
409
|
"OLLAMA_HOST": "http://127.0.0.1:11434",
|
|
410
|
+
"EMBEDDING_DIMENSION": "768",
|
|
364
411
|
"MILVUS_TOKEN": "your-zilliz-cloud-api-key"
|
|
365
412
|
}
|
|
366
413
|
}
|
|
@@ -471,7 +518,7 @@ Cherry Studio allows for visual MCP server configuration through its settings in
|
|
|
471
518
|
- **Name**: `claude-context`
|
|
472
519
|
- **Type**: `STDIO`
|
|
473
520
|
- **Command**: `npx`
|
|
474
|
-
- **Arguments**: `["@zilliz/claude-context-mcp@latest"]`
|
|
521
|
+
- **Arguments**: `["-y", "@zilliz/claude-context-mcp@latest"]`
|
|
475
522
|
- **Environment Variables**:
|
|
476
523
|
- `OPENAI_API_KEY`: `your-openai-api-key`
|
|
477
524
|
- `MILVUS_TOKEN`: `your-zilliz-cloud-api-key`
|
package/dist/config.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface ContextMcpConfig {
|
|
|
11
11
|
openrouterApiKey?: string;
|
|
12
12
|
ollamaModel?: string;
|
|
13
13
|
ollamaHost?: string;
|
|
14
|
+
ollamaDimension?: number;
|
|
14
15
|
milvusAddress?: string;
|
|
15
16
|
milvusToken?: string;
|
|
16
17
|
collectionNameOverride?: string;
|
|
@@ -20,7 +21,13 @@ export interface CodebaseSnapshotV1 {
|
|
|
20
21
|
indexingCodebases: string[] | Record<string, number>;
|
|
21
22
|
lastUpdated: string;
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
+
export type RequestSplitterType = 'ast' | 'langchain';
|
|
25
|
+
export interface CodebaseIndexOptions {
|
|
26
|
+
requestSplitter?: RequestSplitterType;
|
|
27
|
+
requestCustomExtensions?: string[];
|
|
28
|
+
requestIgnorePatterns?: string[];
|
|
29
|
+
}
|
|
30
|
+
interface CodebaseInfoBase extends CodebaseIndexOptions {
|
|
24
31
|
lastUpdated: string;
|
|
25
32
|
}
|
|
26
33
|
export interface CodebaseInfoIndexing extends CodebaseInfoBase {
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAEhB,iBAAiB,EAAE,QAAQ,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,YAAY,CAAC;IAC9E,cAAc,EAAE,MAAM,CAAC;IAEvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,a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FtC"}
|
package/dist/config.js
CHANGED
|
@@ -35,11 +35,24 @@ export function getEmbeddingModelForProvider(provider) {
|
|
|
35
35
|
return selectedModel;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
+
function getPositiveIntegerFromEnv(name) {
|
|
39
|
+
const rawValue = envManager.get(name);
|
|
40
|
+
if (!rawValue) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const parsedValue = Number(rawValue);
|
|
44
|
+
if (Number.isInteger(parsedValue) && parsedValue > 0) {
|
|
45
|
+
return parsedValue;
|
|
46
|
+
}
|
|
47
|
+
console.warn(`[DEBUG] ⚠️ Ignoring invalid ${name}: ${rawValue}. Expected a positive integer.`);
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
38
50
|
export function createMcpConfig() {
|
|
39
51
|
// Debug: Print all environment variables related to Context
|
|
40
52
|
console.log(`[DEBUG] 🔍 Environment Variables Debug:`);
|
|
41
53
|
console.log(`[DEBUG] EMBEDDING_PROVIDER: ${envManager.get('EMBEDDING_PROVIDER') || 'NOT SET'}`);
|
|
42
54
|
console.log(`[DEBUG] EMBEDDING_MODEL: ${envManager.get('EMBEDDING_MODEL') || 'NOT SET'}`);
|
|
55
|
+
console.log(`[DEBUG] EMBEDDING_DIMENSION: ${envManager.get('EMBEDDING_DIMENSION') || 'NOT SET'}`);
|
|
43
56
|
console.log(`[DEBUG] OLLAMA_MODEL: ${envManager.get('OLLAMA_MODEL') || 'NOT SET'}`);
|
|
44
57
|
console.log(`[DEBUG] GEMINI_API_KEY: ${envManager.get('GEMINI_API_KEY') ? 'SET (length: ' + envManager.get('GEMINI_API_KEY').length + ')' : 'NOT SET'}`);
|
|
45
58
|
console.log(`[DEBUG] OPENAI_API_KEY: ${envManager.get('OPENAI_API_KEY') ? 'SET (length: ' + envManager.get('OPENAI_API_KEY').length + ')' : 'NOT SET'}`);
|
|
@@ -63,6 +76,7 @@ export function createMcpConfig() {
|
|
|
63
76
|
// Ollama configuration
|
|
64
77
|
ollamaModel: envManager.get('OLLAMA_MODEL'),
|
|
65
78
|
ollamaHost: envManager.get('OLLAMA_HOST'),
|
|
79
|
+
ollamaDimension: getPositiveIntegerFromEnv('EMBEDDING_DIMENSION'),
|
|
66
80
|
// Vector database configuration - address can be auto-resolved from token
|
|
67
81
|
milvusAddress: envManager.get('MILVUS_ADDRESS'), // Optional, can be resolved from token
|
|
68
82
|
milvusToken: envManager.get('MILVUS_TOKEN'),
|
|
@@ -104,6 +118,9 @@ export function logConfigurationSummary(config) {
|
|
|
104
118
|
case 'Ollama':
|
|
105
119
|
console.log(`[MCP] Ollama Host: ${config.ollamaHost || 'http://127.0.0.1:11434'}`);
|
|
106
120
|
console.log(`[MCP] Ollama Model: ${config.embeddingModel}`);
|
|
121
|
+
if (config.ollamaDimension) {
|
|
122
|
+
console.log(`[MCP] Ollama Embedding Dimension: ${config.ollamaDimension}`);
|
|
123
|
+
}
|
|
107
124
|
break;
|
|
108
125
|
}
|
|
109
126
|
console.log(`[MCP] 🔧 Initializing server components...`);
|
|
@@ -124,6 +141,7 @@ Environment Variables:
|
|
|
124
141
|
Embedding Provider Configuration:
|
|
125
142
|
EMBEDDING_PROVIDER Embedding provider: OpenAI, VoyageAI, Gemini, Ollama, OpenRouter (default: OpenAI)
|
|
126
143
|
EMBEDDING_MODEL Embedding model name (works for all providers)
|
|
144
|
+
EMBEDDING_DIMENSION Optional embedding dimension override for Ollama
|
|
127
145
|
|
|
128
146
|
Provider-specific API Keys:
|
|
129
147
|
OPENAI_API_KEY OpenAI API key (required for OpenAI provider)
|
|
@@ -147,6 +165,25 @@ Environment Variables:
|
|
|
147
165
|
The per-codebase pathHash is preserved so multiple
|
|
148
166
|
codebases stay distinct under the same override.
|
|
149
167
|
|
|
168
|
+
MCP Sync Configuration:
|
|
169
|
+
CLAUDE_CONTEXT_BACKGROUND_SYNC
|
|
170
|
+
Enable/disable startup + periodic background sync
|
|
171
|
+
for indexed codebases (default: true). Set to false
|
|
172
|
+
to disable polling while keeping trigger-based sync.
|
|
173
|
+
CLAUDE_CONTEXT_SYNC_INTERVAL_MS
|
|
174
|
+
Background sync interval in milliseconds when enabled
|
|
175
|
+
(default: 300000).
|
|
176
|
+
|
|
177
|
+
Sync Trigger Watcher:
|
|
178
|
+
CLAUDE_CONTEXT_TRIGGER_WATCHER
|
|
179
|
+
Enable/disable the ~/.context/.sync-trigger filesystem
|
|
180
|
+
watcher (default: true). When enabled, touching the
|
|
181
|
+
trigger file kicks off an immediate, debounced re-index.
|
|
182
|
+
Triggered syncs share the same global cross-process
|
|
183
|
+
lock as background sync, so multi-instance setups stay
|
|
184
|
+
coordinated. Set to false to disable filesystem
|
|
185
|
+
watching entirely (read-only / sandboxed environments).
|
|
186
|
+
|
|
150
187
|
Examples:
|
|
151
188
|
# Start MCP server with OpenAI (default) and explicit Milvus address
|
|
152
189
|
OPENAI_API_KEY=sk-xxx MILVUS_ADDRESS=localhost:19530 npx @zilliz/claude-context-mcp@latest
|
|
@@ -168,6 +205,9 @@ Examples:
|
|
|
168
205
|
|
|
169
206
|
# Start MCP server with a human-readable collection name override
|
|
170
207
|
OPENAI_API_KEY=sk-xxx MILVUS_TOKEN=your-token CODE_CHUNKS_COLLECTION_NAME_OVERRIDE=my_project npx @zilliz/claude-context-mcp@latest
|
|
208
|
+
|
|
209
|
+
# Start MCP server with background sync enabled every minute
|
|
210
|
+
OPENAI_API_KEY=sk-xxx MILVUS_TOKEN=your-token CLAUDE_CONTEXT_BACKGROUND_SYNC=true CLAUDE_CONTEXT_SYNC_INTERVAL_MS=60000 npx @zilliz/claude-context-mcp@latest
|
|
171
211
|
`);
|
|
172
212
|
}
|
|
173
213
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version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CAAC,4CAA4C,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,eAAe;IAC3B,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAkFP,CAAC,CAAC;AACX,CAAC"}
|
package/dist/embedding.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../src/embedding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,GAAG,eAAe,GAAG,iBAAiB,GAAG,eAAe,GAAG,eAAe,
|
|
1
|
+
{"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../src/embedding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,GAAG,eAAe,GAAG,iBAAiB,GAAG,eAAe,GAAG,eAAe,CA2EzI;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,eAAe,GAAG,iBAAiB,GAAG,eAAe,GAAG,eAAe,GAAG,IAAI,CAsB3J"}
|
package/dist/embedding.js
CHANGED
|
@@ -57,10 +57,11 @@ export function createEmbeddingInstance(config) {
|
|
|
57
57
|
return openrouterEmbedding;
|
|
58
58
|
case 'Ollama':
|
|
59
59
|
const ollamaHost = config.ollamaHost || 'http://127.0.0.1:11434';
|
|
60
|
-
console.log(`[EMBEDDING] 🔧 Configuring Ollama with model: ${config.embeddingModel}, host: ${ollamaHost}`);
|
|
60
|
+
console.log(`[EMBEDDING] 🔧 Configuring Ollama with model: ${config.embeddingModel}, host: ${ollamaHost}${config.ollamaDimension ? `, dimension: ${config.ollamaDimension}` : ''}`);
|
|
61
61
|
const ollamaEmbedding = new OllamaEmbedding({
|
|
62
62
|
model: config.embeddingModel,
|
|
63
|
-
host: ollamaHost
|
|
63
|
+
host: ollamaHost,
|
|
64
|
+
...(config.ollamaDimension && { dimension: config.ollamaDimension })
|
|
64
65
|
});
|
|
65
66
|
console.log(`[EMBEDDING] ✅ Ollama embedding instance created successfully`);
|
|
66
67
|
return ollamaEmbedding;
|
|
@@ -87,7 +88,7 @@ export function logEmbeddingProviderInfo(config, embedding) {
|
|
|
87
88
|
console.log(`[EMBEDDING] OpenRouter configuration - API Key: ${config.openrouterApiKey ? '✅ Provided' : '❌ Missing'}`);
|
|
88
89
|
break;
|
|
89
90
|
case 'Ollama':
|
|
90
|
-
console.log(`[EMBEDDING] Ollama configuration - Host: ${config.ollamaHost || 'http://127.0.0.1:11434'}, Model: ${config.embeddingModel}`);
|
|
91
|
+
console.log(`[EMBEDDING] Ollama configuration - Host: ${config.ollamaHost || 'http://127.0.0.1:11434'}, Model: ${config.embeddingModel}${config.ollamaDimension ? `, Dimension: ${config.ollamaDimension}` : ''}`);
|
|
91
92
|
break;
|
|
92
93
|
}
|
|
93
94
|
}
|
package/dist/embedding.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding.js","sourceRoot":"","sources":["../src/embedding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAGnH,iEAAiE;AACjE,MAAM,UAAU,uBAAuB,CAAC,MAAwB;IAC5D,OAAO,CAAC,GAAG,CAAC,wBAAwB,MAAM,CAAC,iBAAiB,wBAAwB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W,EAAE,CAAC,CAAC;YACnH,MAAM;QACV,KAAK,QAAQ;YACT,OAAO,CAAC,GAAG,CAAC,+CAA+C,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,eAAe,MAAM,CAAC,aAAa,IAAI,SAAS,EAAE,CAAC,CAAC;YAC/J,MAAM;QACV,KAAK,YAAY;YACb,OAAO,CAAC,GAAG,CAAC,mDAAmD,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;YACvH,MAAM;QACV,KAAK,QAAQ;YACT,OAAO,CAAC,GAAG,CAAC,4CAA4C,MAAM,CAAC,UAAU,IAAI,wBAAwB,YAAY,MAAM,CAAC,cAAc,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,gBAAgB,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACnN,MAAM;IACd,CAAC;AACL,CAAC"}
|
package/dist/handlers.d.ts
CHANGED
|
@@ -5,6 +5,14 @@ export declare class ToolHandlers {
|
|
|
5
5
|
private snapshotManager;
|
|
6
6
|
private indexingStats;
|
|
7
7
|
private currentWorkspace;
|
|
8
|
+
/**
|
|
9
|
+
* Tracks active background indexing tasks per absolute codebase path so
|
|
10
|
+
* clear_index can cancel and await them before dropping the collection.
|
|
11
|
+
* Without this, a clear_index call returns "successfully cleared" while
|
|
12
|
+
* the background task keeps embedding chunks and writing them into the
|
|
13
|
+
* just-cleared collection (issue #199).
|
|
14
|
+
*/
|
|
15
|
+
private indexingTasks;
|
|
8
16
|
constructor(context: Context, snapshotManager: SnapshotManager);
|
|
9
17
|
/**
|
|
10
18
|
* Query Milvus for the real row count of a codebase's collection.
|
package/dist/handlers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../src/handlers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../src/handlers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAA+D,MAAM,6BAA6B,CAAC;AACnH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAKhD,qBAAa,YAAY;IACrB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,aAAa,CAA8D;IACnF,OAAO,CAAC,gBAAgB,CAAS;IACjC;;;;;;OAMG;IACH,OAAO,CAAC,aAAa,CAAmF;gBAE5F,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe;IAO9D;;;;;;;OAOG;YACW,oBAAoB;IAuBlC;;;;;;;;OAQG;IACU,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC;IAqFvD;;;;;;;;;;OAUG;YACW,6BAA6B;IA6J9B,mBAAmB,CAAC,IAAI,EAAE,GAAG;;;;;;;;;;;;;YA2N5B,uBAAuB;IAwGxB,gBAAgB,CAAC,IAAI,EAAE,GAAG;;;;;;;;;;;;;IA+M1B,gBAAgB,CAAC,IAAI,EAAE,GAAG;;;;;;;;;;;;;IA0I1B,uBAAuB,CAAC,IAAI,EAAE,GAAG;;;;;;;;;;;;;CAmHjD"}
|
package/dist/handlers.js
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import * as path from "path";
|
|
3
|
-
import { COLLECTION_LIMIT_MESSAGE } from "@zilliz/claude-context-core";
|
|
3
|
+
import { COLLECTION_LIMIT_MESSAGE, FileSynchronizer, IndexAbortError } from "@zilliz/claude-context-core";
|
|
4
|
+
import { createRequestSplitter, isRequestSplitterType } from "./splitter.js";
|
|
4
5
|
import { ensureAbsolutePath, truncateContent, trackCodebasePath } from "./utils.js";
|
|
5
6
|
export class ToolHandlers {
|
|
6
7
|
constructor(context, snapshotManager) {
|
|
7
8
|
this.indexingStats = null;
|
|
9
|
+
/**
|
|
10
|
+
* Tracks active background indexing tasks per absolute codebase path so
|
|
11
|
+
* clear_index can cancel and await them before dropping the collection.
|
|
12
|
+
* Without this, a clear_index call returns "successfully cleared" while
|
|
13
|
+
* the background task keeps embedding chunks and writing them into the
|
|
14
|
+
* just-cleared collection (issue #199).
|
|
15
|
+
*/
|
|
16
|
+
this.indexingTasks = new Map();
|
|
8
17
|
this.context = context;
|
|
9
18
|
this.snapshotManager = snapshotManager;
|
|
10
19
|
this.currentWorkspace = process.cwd();
|
|
@@ -245,6 +254,12 @@ export class ToolHandlers {
|
|
|
245
254
|
if (!cloudCodebases.has(localCodebase)) {
|
|
246
255
|
this.snapshotManager.removeCodebaseCompletely(localCodebase);
|
|
247
256
|
hasChanges = true;
|
|
257
|
+
try {
|
|
258
|
+
await FileSynchronizer.deleteSnapshot(localCodebase);
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
console.warn(`[SYNC-CLOUD] ⚠️ Failed to delete local merkle snapshot for removed codebase '${localCodebase}':`, error?.message || error);
|
|
262
|
+
}
|
|
248
263
|
console.log(`[SYNC-CLOUD] ➖ Removed local codebase (not in cloud): ${localCodebase}`);
|
|
249
264
|
}
|
|
250
265
|
}
|
|
@@ -284,22 +299,28 @@ export class ToolHandlers {
|
|
|
284
299
|
async handleIndexCodebase(args) {
|
|
285
300
|
const { path: codebasePath, force, splitter, customExtensions, ignorePatterns } = args;
|
|
286
301
|
const forceReindex = force || false;
|
|
287
|
-
const
|
|
302
|
+
const requestedSplitter = splitter || 'ast'; // Default to AST
|
|
288
303
|
const customFileExtensions = customExtensions || [];
|
|
289
304
|
const customIgnorePatterns = ignorePatterns || [];
|
|
290
305
|
try {
|
|
291
306
|
// Sync indexed codebases from cloud first
|
|
292
307
|
await this.syncIndexedCodebasesFromCloud();
|
|
293
308
|
// Validate splitter parameter
|
|
294
|
-
if (
|
|
309
|
+
if (!isRequestSplitterType(requestedSplitter)) {
|
|
295
310
|
return {
|
|
296
311
|
content: [{
|
|
297
312
|
type: "text",
|
|
298
|
-
text: `Error: Invalid splitter type '${
|
|
313
|
+
text: `Error: Invalid splitter type '${requestedSplitter}'. Must be 'ast' or 'langchain'.`
|
|
299
314
|
}],
|
|
300
315
|
isError: true
|
|
301
316
|
};
|
|
302
317
|
}
|
|
318
|
+
const splitterType = requestedSplitter;
|
|
319
|
+
const indexOptions = {
|
|
320
|
+
requestSplitter: splitterType,
|
|
321
|
+
requestCustomExtensions: customFileExtensions,
|
|
322
|
+
requestIgnorePatterns: customIgnorePatterns
|
|
323
|
+
};
|
|
303
324
|
// Force absolute path resolution - warn if relative path provided
|
|
304
325
|
const absolutePath = ensureAbsolutePath(codebasePath);
|
|
305
326
|
// Validate path exists
|
|
@@ -411,10 +432,8 @@ export class ToolHandlers {
|
|
|
411
432
|
isError: true
|
|
412
433
|
};
|
|
413
434
|
}
|
|
414
|
-
// Add custom extensions if provided
|
|
415
435
|
if (customFileExtensions.length > 0) {
|
|
416
|
-
console.log(`[CUSTOM-EXTENSIONS]
|
|
417
|
-
this.context.addCustomExtensions(customFileExtensions);
|
|
436
|
+
console.log(`[CUSTOM-EXTENSIONS] Using ${customFileExtensions.length} request-scoped custom extensions: ${customFileExtensions.join(', ')}`);
|
|
418
437
|
}
|
|
419
438
|
// Check current status and log if retrying after failure
|
|
420
439
|
const currentStatus = this.snapshotManager.getCodebaseStatus(absolutePath);
|
|
@@ -423,12 +442,23 @@ export class ToolHandlers {
|
|
|
423
442
|
console.log(`[BACKGROUND-INDEX] Retrying indexing for previously failed codebase. Previous error: ${failedInfo?.errorMessage || 'Unknown error'}`);
|
|
424
443
|
}
|
|
425
444
|
// Set to indexing status and save snapshot immediately
|
|
426
|
-
this.snapshotManager.setCodebaseIndexing(absolutePath, 0);
|
|
445
|
+
this.snapshotManager.setCodebaseIndexing(absolutePath, 0, indexOptions);
|
|
427
446
|
this.snapshotManager.saveCodebaseSnapshot();
|
|
428
447
|
// Track the codebase path for syncing
|
|
429
448
|
trackCodebasePath(absolutePath);
|
|
430
|
-
// Start background indexing - now safe to proceed
|
|
431
|
-
|
|
449
|
+
// Start background indexing - now safe to proceed.
|
|
450
|
+
// Track the controller + promise so clear_index can cancel and
|
|
451
|
+
// await us before dropping the underlying collection.
|
|
452
|
+
const controller = new AbortController();
|
|
453
|
+
const promise = this.startBackgroundIndexing(absolutePath, forceReindex, splitterType, customIgnorePatterns, customFileExtensions, indexOptions, controller.signal).finally(() => {
|
|
454
|
+
// Only clear the entry if it still points at this run — a
|
|
455
|
+
// concurrent re-index may have replaced us.
|
|
456
|
+
const current = this.indexingTasks.get(absolutePath);
|
|
457
|
+
if (current && current.controller === controller) {
|
|
458
|
+
this.indexingTasks.delete(absolutePath);
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
this.indexingTasks.set(absolutePath, { controller, promise });
|
|
432
462
|
const pathInfo = codebasePath !== absolutePath
|
|
433
463
|
? `\nNote: Input path '${codebasePath}' was resolved to absolute path '${absolutePath}'`
|
|
434
464
|
: '';
|
|
@@ -458,7 +488,7 @@ export class ToolHandlers {
|
|
|
458
488
|
};
|
|
459
489
|
}
|
|
460
490
|
}
|
|
461
|
-
async startBackgroundIndexing(codebasePath, forceReindex, splitterType, customIgnorePatterns = []) {
|
|
491
|
+
async startBackgroundIndexing(codebasePath, forceReindex, splitterType, customIgnorePatterns = [], customFileExtensions = [], indexOptions, signal) {
|
|
462
492
|
const absolutePath = codebasePath;
|
|
463
493
|
let lastSaveTime = 0; // Track last save timestamp
|
|
464
494
|
try {
|
|
@@ -467,34 +497,30 @@ export class ToolHandlers {
|
|
|
467
497
|
if (forceReindex) {
|
|
468
498
|
console.log(`[BACKGROUND-INDEX] ℹ️ Force reindex mode - collection was already cleared during validation`);
|
|
469
499
|
}
|
|
470
|
-
|
|
471
|
-
let contextForThisTask = this.context;
|
|
472
|
-
if (splitterType !== 'ast') {
|
|
473
|
-
console.warn(`[BACKGROUND-INDEX] Non-AST splitter '${splitterType}' requested; falling back to AST splitter`);
|
|
474
|
-
}
|
|
500
|
+
const requestSplitter = createRequestSplitter(splitterType);
|
|
475
501
|
// Load ignore patterns from files first (including .ignore, .gitignore, etc.)
|
|
476
502
|
// and merge them with this request's custom ignore patterns without
|
|
477
503
|
// relying on shared Context state for this background indexing task.
|
|
478
504
|
const ignorePatterns = await this.context.getEffectiveIgnorePatterns(absolutePath, customIgnorePatterns);
|
|
505
|
+
const supportedExtensions = this.context.getEffectiveSupportedExtensions(customFileExtensions);
|
|
479
506
|
// Initialize file synchronizer with proper ignore patterns (including project-specific patterns)
|
|
480
|
-
const { FileSynchronizer } = await import("@zilliz/claude-context-core");
|
|
481
507
|
console.log(`[BACKGROUND-INDEX] Using ignore patterns: ${ignorePatterns.join(', ')}`);
|
|
482
|
-
|
|
508
|
+
if (customFileExtensions.length > 0) {
|
|
509
|
+
console.log(`[BACKGROUND-INDEX] Using ${customFileExtensions.length} request-scoped custom extensions: ${customFileExtensions.join(', ')}`);
|
|
510
|
+
}
|
|
511
|
+
const synchronizer = new FileSynchronizer(absolutePath, ignorePatterns, supportedExtensions);
|
|
483
512
|
await synchronizer.initialize();
|
|
484
513
|
// Store synchronizer in the context (let context manage collection names)
|
|
485
514
|
await this.context.getPreparedCollection(absolutePath);
|
|
486
515
|
const collectionName = this.context.getCollectionName(absolutePath);
|
|
487
516
|
this.context.setSynchronizer(collectionName, synchronizer);
|
|
488
|
-
if (contextForThisTask !== this.context) {
|
|
489
|
-
contextForThisTask.setSynchronizer(collectionName, synchronizer);
|
|
490
|
-
}
|
|
491
517
|
console.log(`[BACKGROUND-INDEX] Starting indexing with ${splitterType} splitter for: ${absolutePath}`);
|
|
492
518
|
// Log embedding provider information before indexing
|
|
493
519
|
const embeddingProvider = this.context.getEmbedding();
|
|
494
520
|
console.log(`[BACKGROUND-INDEX] 🧠 Using embedding provider: ${embeddingProvider.getProvider()} with dimension: ${embeddingProvider.getDimension()}`);
|
|
495
521
|
// Start indexing with the appropriate context and progress tracking
|
|
496
522
|
console.log(`[BACKGROUND-INDEX] 🚀 Beginning codebase indexing process...`);
|
|
497
|
-
const stats = await
|
|
523
|
+
const stats = await this.context.indexCodebase(absolutePath, (progress) => {
|
|
498
524
|
// Update progress in snapshot manager using new method
|
|
499
525
|
this.snapshotManager.setCodebaseIndexing(absolutePath, progress.percentage);
|
|
500
526
|
// Save snapshot periodically (every 2 seconds to avoid too frequent saves)
|
|
@@ -505,10 +531,10 @@ export class ToolHandlers {
|
|
|
505
531
|
console.log(`[BACKGROUND-INDEX] 💾 Saved progress snapshot at ${progress.percentage.toFixed(1)}%`);
|
|
506
532
|
}
|
|
507
533
|
console.log(`[BACKGROUND-INDEX] Progress: ${progress.phase} - ${progress.percentage}% (${progress.current}/${progress.total})`);
|
|
508
|
-
}, false, customIgnorePatterns);
|
|
534
|
+
}, false, customIgnorePatterns, customFileExtensions, requestSplitter, signal);
|
|
509
535
|
console.log(`[BACKGROUND-INDEX] ✅ Indexing completed successfully! Files: ${stats.indexedFiles}, Chunks: ${stats.totalChunks}`);
|
|
510
536
|
// Set codebase to indexed status with complete statistics
|
|
511
|
-
this.snapshotManager.setCodebaseIndexed(absolutePath, stats);
|
|
537
|
+
this.snapshotManager.setCodebaseIndexed(absolutePath, stats, indexOptions);
|
|
512
538
|
this.indexingStats = { indexedFiles: stats.indexedFiles, totalChunks: stats.totalChunks };
|
|
513
539
|
// Save snapshot after updating codebase lists
|
|
514
540
|
this.snapshotManager.saveCodebaseSnapshot();
|
|
@@ -519,12 +545,20 @@ export class ToolHandlers {
|
|
|
519
545
|
console.log(`[BACKGROUND-INDEX] ${message}`);
|
|
520
546
|
}
|
|
521
547
|
catch (error) {
|
|
548
|
+
// Cooperative cancel from clear_index — clear_index is responsible
|
|
549
|
+
// for tearing down the snapshot/collection right after, so do not
|
|
550
|
+
// overwrite the snapshot with an "indexfailed" entry that would
|
|
551
|
+
// race the clear and leave a tombstone behind.
|
|
552
|
+
if (error instanceof IndexAbortError) {
|
|
553
|
+
console.log(`[BACKGROUND-INDEX] Indexing for ${absolutePath} was cancelled: ${error.message}`);
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
522
556
|
console.error(`[BACKGROUND-INDEX] Error during indexing for ${absolutePath}:`, error);
|
|
523
557
|
// Get the last attempted progress
|
|
524
558
|
const lastProgress = this.snapshotManager.getIndexingProgress(absolutePath);
|
|
525
559
|
// Set codebase to failed status with error information
|
|
526
560
|
const errorMessage = error.message || String(error);
|
|
527
|
-
this.snapshotManager.setCodebaseIndexFailed(absolutePath, errorMessage, lastProgress);
|
|
561
|
+
this.snapshotManager.setCodebaseIndexFailed(absolutePath, errorMessage, lastProgress, indexOptions);
|
|
528
562
|
this.snapshotManager.saveCodebaseSnapshot();
|
|
529
563
|
// Log error but don't crash MCP service - indexing errors are handled gracefully
|
|
530
564
|
console.error(`[BACKGROUND-INDEX] Indexing failed for ${absolutePath}: ${errorMessage}`);
|
|
@@ -758,6 +792,24 @@ export class ToolHandlers {
|
|
|
758
792
|
};
|
|
759
793
|
}
|
|
760
794
|
console.log(`[CLEAR] Clearing codebase: ${absolutePath}`);
|
|
795
|
+
// Cancel any in-flight background indexing for this codebase and
|
|
796
|
+
// wait for it to wind down before we drop the collection.
|
|
797
|
+
// Otherwise the background task keeps embedding chunks and writes
|
|
798
|
+
// them into the just-cleared collection (issue #199).
|
|
799
|
+
const activeTask = this.indexingTasks.get(absolutePath);
|
|
800
|
+
if (activeTask) {
|
|
801
|
+
console.log(`[CLEAR] Cancelling in-flight background indexing for: ${absolutePath}`);
|
|
802
|
+
activeTask.controller.abort();
|
|
803
|
+
try {
|
|
804
|
+
await activeTask.promise;
|
|
805
|
+
}
|
|
806
|
+
catch (waitError) {
|
|
807
|
+
// startBackgroundIndexing already logs and never re-throws,
|
|
808
|
+
// so this catch only guards against future refactors.
|
|
809
|
+
console.warn(`[CLEAR] Background indexing wind-down reported: ${waitError?.message || waitError}`);
|
|
810
|
+
}
|
|
811
|
+
this.indexingTasks.delete(absolutePath);
|
|
812
|
+
}
|
|
761
813
|
try {
|
|
762
814
|
await this.context.clearIndex(absolutePath);
|
|
763
815
|
console.log(`[CLEAR] Successfully cleared index for: ${absolutePath}`);
|