@mrxkun/mcfast-mcp 4.1.8 → 4.1.10
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 +62 -651
- package/package.json +2 -2
- package/src/index.js +47 -46
- package/src/memory/memory-engine.js +19 -0
package/README.md
CHANGED
|
@@ -5,19 +5,13 @@
|
|
|
5
5
|
<img src="https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg" alt="Node.js">
|
|
6
6
|
<img src="https://img.shields.io/npm/l/@mrxkun/mcfast-mcp.svg" alt="License">
|
|
7
7
|
<img src="https://img.shields.io/badge/performance-80--98%25%20faster-success.svg" alt="Performance">
|
|
8
|
-
<img src="https://img.shields.io/badge/WASM-Rust-orange.svg" alt="WASM">
|
|
9
8
|
</p>
|
|
10
9
|
|
|
11
10
|
<p align="center">
|
|
12
|
-
<strong>🚀 Ultra-fast AI code editing with
|
|
11
|
+
<strong>🚀 Ultra-fast AI code editing with AST-aware refactoring</strong><br>
|
|
13
12
|
Optimized for Claude, Cursor, and AI assistants with 80-98% latency reduction
|
|
14
13
|
</p>
|
|
15
14
|
|
|
16
|
-
<p align="center">
|
|
17
|
-
<strong>🧠 NEW in v4.0.5: Intelligence Layer</strong><br>
|
|
18
|
-
ML-powered pattern detection | Adaptive strategy selection | Predictive suggestions
|
|
19
|
-
</p>
|
|
20
|
-
|
|
21
15
|
---
|
|
22
16
|
|
|
23
17
|
## ✨ What Makes MCFAST Special?
|
|
@@ -35,7 +29,28 @@
|
|
|
35
29
|
|
|
36
30
|
---
|
|
37
31
|
|
|
38
|
-
##
|
|
32
|
+
## 📦 Current Version: v4.1.10
|
|
33
|
+
|
|
34
|
+
### What's New in v4.1.10 🐛
|
|
35
|
+
- **Bug Fixes**: Fixed `getCuratedMemories()` and `getIntelligenceStats()` missing methods
|
|
36
|
+
- **Fixed VSCode MCP Reload Issue**: Complete console suppression in MCP mode
|
|
37
|
+
- **Version Sync**: All packages now unified to v4.1.10
|
|
38
|
+
|
|
39
|
+
### What's New in v4.1.4 🧠
|
|
40
|
+
- **ContextAnalyzer API**: AI-powered memory analysis with Mercury Coder
|
|
41
|
+
- **5 New Endpoints**: Analyze changes, session summaries, pattern detection, memory updates, context retrieval
|
|
42
|
+
- **SQL Migration**: Complete database schema with 5 tables, 24 indexes, 4 views
|
|
43
|
+
|
|
44
|
+
### What's New in v4.1.0 🧠
|
|
45
|
+
- **Major Memory Refactor**: Complete rewrite of memory system
|
|
46
|
+
- **Markdown Source of Truth**: Memory stored as plain Markdown files (git-friendly!)
|
|
47
|
+
- **Two-Tier Memory**: Daily logs + Curated memory
|
|
48
|
+
- **Hybrid Search**: Vector 70% + BM25 30% for 90%+ accuracy
|
|
49
|
+
- **File Watcher**: Auto-indexes files with debounced 1.5s delay
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 🧠 Memory System (v4.1)
|
|
39
54
|
|
|
40
55
|
**Semantic code search with 90-95% accuracy** - Find code by meaning, not just keywords.
|
|
41
56
|
|
|
@@ -60,185 +75,52 @@ await engine.initialize('./my-project');
|
|
|
60
75
|
const results = await engine.intelligentSearch('find authentication code', {
|
|
61
76
|
limit: 5
|
|
62
77
|
});
|
|
63
|
-
|
|
64
|
-
console.log(results);
|
|
65
|
-
// {
|
|
66
|
-
// results: [
|
|
67
|
-
// { file: 'auth.js', score: 0.92, content: 'function login()...' },
|
|
68
|
-
// { file: 'UserService.js', score: 0.88, content: 'async authenticate()...' }
|
|
69
|
-
// ],
|
|
70
|
-
// metadata: {
|
|
71
|
-
// method: 'intelligent-hybrid',
|
|
72
|
-
// accuracy: '95%',
|
|
73
|
-
// routingDecision: { useMercury: true, reason: 'Complex query' },
|
|
74
|
-
// duration: '105ms'
|
|
75
|
-
// }
|
|
76
|
-
// }
|
|
77
78
|
```
|
|
78
79
|
|
|
79
|
-
### Smart Routing Modes
|
|
80
|
-
|
|
81
|
-
1. **Always Local** (⚡ Fastest)
|
|
82
|
-
- 90% accuracy, <1ms
|
|
83
|
-
- 100% offline
|
|
84
|
-
- $0 cost
|
|
85
|
-
|
|
86
|
-
2. **Auto Smart** (🧠 Recommended)
|
|
87
|
-
- Auto-selects based on query complexity
|
|
88
|
-
- Balances speed vs accuracy
|
|
89
|
-
- 70% cost savings vs always Mercury
|
|
90
|
-
|
|
91
|
-
3. **Always Mercury** (🎯 Best Accuracy)
|
|
92
|
-
- 95% accuracy, ~100ms
|
|
93
|
-
- Complex queries only
|
|
94
|
-
- $0.01 per query
|
|
95
|
-
|
|
96
80
|
---
|
|
97
81
|
|
|
98
|
-
##
|
|
82
|
+
## 🛠️ 10 Unified Tools
|
|
99
83
|
|
|
100
|
-
| Tool | Description | Avg Latency |
|
|
101
|
-
|
|
102
|
-
| **
|
|
103
|
-
| **
|
|
104
|
-
| **
|
|
105
|
-
| **
|
|
106
|
-
| **
|
|
107
|
-
| **
|
|
108
|
-
| **
|
|
109
|
-
| **
|
|
84
|
+
| Tool | Description | Avg Latency |
|
|
85
|
+
|------|-------------|-------------|
|
|
86
|
+
| **mcfast_edit** | Multi-file intelligent editing | 35ms |
|
|
87
|
+
| **mcfast_search** | Lightning-fast code search | 8ms |
|
|
88
|
+
| **mcfast_read** | Smart file reading with batch mode | 6ms |
|
|
89
|
+
| **mcfast_list_files** | Directory listing with filters | 3ms |
|
|
90
|
+
| **mcfast_reapply** | Retry failed edits with fixes | 30ms |
|
|
91
|
+
| **mcfast_memory_search** | Semantic code search | 15ms |
|
|
92
|
+
| **mcfast_memory_get** | Retrieve memories & stats | 5ms |
|
|
93
|
+
| **mcfast_detect_patterns** | Detect code patterns | 20ms |
|
|
94
|
+
| **mcfast_get_suggestions** | Get code suggestions | 15ms |
|
|
95
|
+
| **mcfast_select_strategy** | ML strategy selection | 5ms |
|
|
110
96
|
|
|
111
97
|
---
|
|
112
98
|
|
|
113
99
|
## 🚀 Performance Highlights
|
|
114
100
|
|
|
115
|
-
### Before vs After Optimization
|
|
116
|
-
|
|
117
101
|
| Operation | Before | After MCFAST | Improvement |
|
|
118
102
|
|-----------|--------|--------------|-------------|
|
|
119
|
-
| **Edit** | 150ms | **30ms** | **80% faster**
|
|
120
|
-
| **Read** | 50ms | **6ms** | **88% faster**
|
|
121
|
-
| **Search** | 500ms | **8ms** | **98% faster**
|
|
122
|
-
| **Analyze** | 100ms | **5ms** | **95% faster**
|
|
123
|
-
| **Fuzzy Match** | 100ms | **25ms** | **75% faster** 🚀 |
|
|
124
|
-
|
|
125
|
-
### Throughput Improvements
|
|
126
|
-
|
|
127
|
-
- **Requests/sec**: 20 → 200 (**10x increase**)
|
|
128
|
-
- **Concurrent edits**: 1 → 8 (**8x parallel processing**)
|
|
129
|
-
- **Cache hit rate**: 0% → 87% (**87% reduction in API calls**)
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
## 🏗️ Technical Architecture
|
|
134
|
-
|
|
135
|
-
### 1. WebAssembly (Rust) Acceleration
|
|
136
|
-
|
|
137
|
-
Near-native performance for CPU-intensive operations:
|
|
138
|
-
|
|
139
|
-
```
|
|
140
|
-
JavaScript (80ms) ──────► WASM (25ms) = 3.2x faster
|
|
141
|
-
Fuzzy Matching
|
|
142
|
-
|
|
143
|
-
JavaScript (20ms) ──────► WASM (8ms) = 2.5x faster
|
|
144
|
-
Code Search
|
|
145
|
-
|
|
146
|
-
JavaScript (15ms) ──────► WASM (5ms) = 3x faster
|
|
147
|
-
AST Parsing
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
**Features:**
|
|
151
|
-
- ⚡ **3.2x faster** fuzzy matching
|
|
152
|
-
- 🔍 **2.5x faster** code search
|
|
153
|
-
- 🌳 **3x faster** AST parsing
|
|
154
|
-
- 🔄 **Automatic fallback** to JavaScript if WASM fails
|
|
155
|
-
- 📦 **Only 55KB** total bundle size (22KB gzipped)
|
|
156
|
-
|
|
157
|
-
### 2. Multi-Layer Caching (L1/L2/L3)
|
|
158
|
-
|
|
159
|
-
Three-tier caching for maximum hit rate:
|
|
160
|
-
|
|
161
|
-
**L1: In-Memory Cache (100MB)**
|
|
162
|
-
- Access time: **0.04ms**
|
|
163
|
-
- Hit rate: **70%**
|
|
164
|
-
- Eviction: LRU (Least Recently Used)
|
|
165
|
-
|
|
166
|
-
**L2: Redis Cache (Upstash)**
|
|
167
|
-
- Access time: **5-15ms**
|
|
168
|
-
- Hit rate: **20%**
|
|
169
|
-
- Features: Tag-based invalidation, distributed
|
|
170
|
-
|
|
171
|
-
**L3: CDN Edge Cache**
|
|
172
|
-
- Access time: **50-100ms**
|
|
173
|
-
- Hit rate: **10%**
|
|
174
|
-
- Geographic distribution
|
|
175
|
-
|
|
176
|
-
**Combined: 87% cache hit rate** 🎯
|
|
177
|
-
|
|
178
|
-
### 3. Worker Thread Pool
|
|
179
|
-
|
|
180
|
-
Parallel processing with 8 workers:
|
|
181
|
-
|
|
182
|
-
- **Priority queue**: High-priority tasks first
|
|
183
|
-
- **Load balancing**: Even distribution across workers
|
|
184
|
-
- **Hybrid mode**: Native workers (self-hosted) or simulated (serverless)
|
|
185
|
-
- **Auto-scaling**: Adjusts to workload
|
|
186
|
-
|
|
187
|
-
### 4. Intelligent Edit Strategies (v3.5.7 - NEW: MINIMAL_DIFF)
|
|
188
|
-
|
|
189
|
-
**MINIMAL_DIFF Strategy (NEW in v3.5.7):**
|
|
190
|
-
- Extracts exact search/replace pairs from instructions
|
|
191
|
-
- Applies deterministic replacements first (no API call!)
|
|
192
|
-
- Falls back to Mercury only for complex changes
|
|
193
|
-
- Reduces tokens by 40-60% for simple edits
|
|
194
|
-
|
|
195
|
-
Supported patterns:
|
|
196
|
-
- Quoted strings: `replace "foo" with "bar"`
|
|
197
|
-
- Code identifiers: `change function foo to bar`
|
|
198
|
-
- Arrow notation: `oldName -> newName`
|
|
199
|
-
- Variable renames: `rename user to account`
|
|
200
|
-
|
|
201
|
-
**AST-Aware Editing:**
|
|
202
|
-
- Uses Tree-sitter for accurate parsing
|
|
203
|
-
- Scope-aware renames
|
|
204
|
-
- Type-safe transformations
|
|
205
|
-
|
|
206
|
-
**Fuzzy Patching:**
|
|
207
|
-
- Levenshtein distance matching
|
|
208
|
-
- Token-based similarity
|
|
209
|
-
- Handles whitespace/formatting changes
|
|
210
|
-
|
|
211
|
-
**Multi-File Coordination:**
|
|
212
|
-
- Dependency graph resolution
|
|
213
|
-
- Parallel execution where possible
|
|
214
|
-
- Atomic rollback on failure
|
|
103
|
+
| **Edit** | 150ms | **30ms** | **80% faster** |
|
|
104
|
+
| **Read** | 50ms | **6ms** | **88% faster** |
|
|
105
|
+
| **Search** | 500ms | **8ms** | **98% faster** |
|
|
106
|
+
| **Analyze** | 100ms | **5ms** | **95% faster** |
|
|
215
107
|
|
|
216
108
|
---
|
|
217
109
|
|
|
218
110
|
## 📦 Installation
|
|
219
111
|
|
|
220
112
|
### Prerequisites
|
|
221
|
-
|
|
222
113
|
- **Node.js** ≥ 18.0.0
|
|
223
|
-
- **npm** or **yarn**
|
|
224
114
|
|
|
225
115
|
### Global Installation (Recommended)
|
|
226
|
-
|
|
227
116
|
```bash
|
|
228
117
|
npm install -g @mrxkun/mcfast-mcp
|
|
229
118
|
```
|
|
230
119
|
|
|
231
|
-
### Local Installation
|
|
232
|
-
|
|
233
|
-
```bash
|
|
234
|
-
npm install @mrxkun/mcfast-mcp
|
|
235
|
-
```
|
|
236
|
-
|
|
237
120
|
### Verify Installation
|
|
238
|
-
|
|
239
121
|
```bash
|
|
240
122
|
mcfast-mcp --version
|
|
241
|
-
# Output: 4.
|
|
123
|
+
# Output: 4.1.10
|
|
242
124
|
```
|
|
243
125
|
|
|
244
126
|
---
|
|
@@ -247,8 +129,6 @@ mcfast-mcp --version
|
|
|
247
129
|
|
|
248
130
|
### Configure Claude Desktop
|
|
249
131
|
|
|
250
|
-
Add to your `claude_desktop_config.json`:
|
|
251
|
-
|
|
252
132
|
```json
|
|
253
133
|
{
|
|
254
134
|
"mcpServers": {
|
|
@@ -265,8 +145,6 @@ Add to your `claude_desktop_config.json`:
|
|
|
265
145
|
|
|
266
146
|
### Configure Cursor
|
|
267
147
|
|
|
268
|
-
Add to Cursor MCP settings:
|
|
269
|
-
|
|
270
148
|
```json
|
|
271
149
|
{
|
|
272
150
|
"mcpServers": {
|
|
@@ -281,163 +159,6 @@ Add to Cursor MCP settings:
|
|
|
281
159
|
}
|
|
282
160
|
```
|
|
283
161
|
|
|
284
|
-
### Start Using
|
|
285
|
-
|
|
286
|
-
Once configured, MCFAST tools are automatically available in your AI assistant:
|
|
287
|
-
|
|
288
|
-
```
|
|
289
|
-
User: "Add error handling to the login function"
|
|
290
|
-
AI: [Uses mcfast edit tool]
|
|
291
|
-
✅ Changes applied in 35ms with automatic validation
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
---
|
|
295
|
-
|
|
296
|
-
## 📖 Usage Examples
|
|
297
|
-
|
|
298
|
-
### 1. Basic Edit
|
|
299
|
-
|
|
300
|
-
```javascript
|
|
301
|
-
// AI sends:
|
|
302
|
-
{
|
|
303
|
-
"tool": "edit",
|
|
304
|
-
"params": {
|
|
305
|
-
"instruction": "Add console.log at the start",
|
|
306
|
-
"files": {
|
|
307
|
-
"src/utils.js": "function helper() { return true; }"
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// Response:
|
|
313
|
-
{
|
|
314
|
-
"success": true,
|
|
315
|
-
"diffs": {
|
|
316
|
-
"src/utils.js": "+ console.log('Starting helper');"
|
|
317
|
-
},
|
|
318
|
-
"strategy": "edit_file",
|
|
319
|
-
"latency_ms": 35,
|
|
320
|
-
"from_cache": false
|
|
321
|
-
}
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
### 2. Parallel Multi-File Edit
|
|
325
|
-
|
|
326
|
-
Perfect for complex refactoring:
|
|
327
|
-
|
|
328
|
-
```javascript
|
|
329
|
-
{
|
|
330
|
-
"tool": "parallel_edit",
|
|
331
|
-
"params": {
|
|
332
|
-
"instruction": "Rename 'user' to 'account'",
|
|
333
|
-
"files": {
|
|
334
|
-
"auth.js": "function getUser() {}",
|
|
335
|
-
"profile.js": "const user = {}",
|
|
336
|
-
"settings.js": "export { user }"
|
|
337
|
-
},
|
|
338
|
-
"dependencies": ["auth.js", "profile.js", "settings.js"]
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
### 3. Batch Read (Up to 50 files)
|
|
344
|
-
|
|
345
|
-
```javascript
|
|
346
|
-
{
|
|
347
|
-
"tool": "read",
|
|
348
|
-
"params": {
|
|
349
|
-
"paths": ["src/app.js", "src/utils.js", "src/config.js"],
|
|
350
|
-
"files": { /* file contents */ },
|
|
351
|
-
"max_lines_per_file": 100
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
### 4. Code Search (NEW in v3.5)
|
|
357
|
-
|
|
358
|
-
```javascript
|
|
359
|
-
{
|
|
360
|
-
"tool": "search",
|
|
361
|
-
"params": {
|
|
362
|
-
"query": "function handleError",
|
|
363
|
-
"files": {
|
|
364
|
-
"app.js": "// code",
|
|
365
|
-
"utils.js": "// code"
|
|
366
|
-
},
|
|
367
|
-
"fuzzy": true,
|
|
368
|
-
"max_results": 10
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// Response:
|
|
373
|
-
{
|
|
374
|
-
"results": [
|
|
375
|
-
{
|
|
376
|
-
"path": "app.js",
|
|
377
|
-
"score": 95.5,
|
|
378
|
-
"matches": [
|
|
379
|
-
{ "line": 42, "content": "function handleError(err)" }
|
|
380
|
-
]
|
|
381
|
-
}
|
|
382
|
-
],
|
|
383
|
-
"duration_ms": 8
|
|
384
|
-
}
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
### 5. AST Analysis (NEW in v3.5)
|
|
388
|
-
|
|
389
|
-
```javascript
|
|
390
|
-
{
|
|
391
|
-
"tool": "analyze",
|
|
392
|
-
"params": {
|
|
393
|
-
"code": "function add(a, b) { return a + b; }",
|
|
394
|
-
"language": "javascript",
|
|
395
|
-
"operations": ["extract-functions", "analyze-complexity"]
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
// Response:
|
|
400
|
-
{
|
|
401
|
-
"functions": [
|
|
402
|
-
{
|
|
403
|
-
"name": "add",
|
|
404
|
-
"params": ["a", "b"],
|
|
405
|
-
"line": 1,
|
|
406
|
-
"complexity": 1
|
|
407
|
-
}
|
|
408
|
-
],
|
|
409
|
-
"complexity": {
|
|
410
|
-
"cyclomatic": 1,
|
|
411
|
-
"lines": 1,
|
|
412
|
-
"functions": 1
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
```
|
|
416
|
-
|
|
417
|
-
### 6. Fuzzy Matching (NEW in v3.5)
|
|
418
|
-
|
|
419
|
-
```javascript
|
|
420
|
-
{
|
|
421
|
-
"tool": "fuzzy_match",
|
|
422
|
-
"params": {
|
|
423
|
-
"pattern": "col",
|
|
424
|
-
"targets": ["color", "column", "cold", "warm"],
|
|
425
|
-
"threshold": 0.6,
|
|
426
|
-
"max_results": 5
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
// Response:
|
|
431
|
-
{
|
|
432
|
-
"matches": [
|
|
433
|
-
{ "target": "color", "score": 0.75, "index": 0 },
|
|
434
|
-
{ "target": "column", "score": 0.625, "index": 1 },
|
|
435
|
-
{ "target": "cold", "score": 0.75, "index": 2 }
|
|
436
|
-
],
|
|
437
|
-
"duration_ms": 25
|
|
438
|
-
}
|
|
439
|
-
```
|
|
440
|
-
|
|
441
162
|
---
|
|
442
163
|
|
|
443
164
|
## ⚙️ Configuration
|
|
@@ -445,354 +166,44 @@ Perfect for complex refactoring:
|
|
|
445
166
|
### Environment Variables
|
|
446
167
|
|
|
447
168
|
```bash
|
|
448
|
-
# Required
|
|
169
|
+
# Required for cloud features
|
|
449
170
|
MERCURY_API_KEY=your_mercury_api_key
|
|
450
171
|
|
|
451
172
|
# Optional - Dashboard Integration
|
|
452
|
-
|
|
453
|
-
|
|
173
|
+
MCFAST_TOKEN=your_dashboard_token
|
|
174
|
+
MCFAST_DASHBOARD_URL=https://mcfast.vercel.app
|
|
454
175
|
|
|
455
176
|
# Optional - Redis (for distributed caching)
|
|
456
177
|
UPSTASH_REDIS_REST_URL=https://...
|
|
457
178
|
UPSTASH_REDIS_REST_TOKEN=...
|
|
458
|
-
|
|
459
|
-
# Optional - Performance Tuning
|
|
460
|
-
MAX_WORKERS=8
|
|
461
|
-
CACHE_TTL_SECONDS=3600
|
|
462
|
-
WASM_ENABLED=true
|
|
463
|
-
```
|
|
464
|
-
|
|
465
|
-
### Dashboard Integration
|
|
466
|
-
|
|
467
|
-
Track usage and performance:
|
|
468
|
-
|
|
469
|
-
```bash
|
|
470
|
-
# Get metrics
|
|
471
|
-
curl https://mcfast.vercel.app/api/v1/metrics \
|
|
472
|
-
-H "Authorization: Bearer YOUR_TOKEN"
|
|
473
|
-
|
|
474
|
-
# Response
|
|
475
|
-
{
|
|
476
|
-
"metrics": {
|
|
477
|
-
"requests": { "total": 10000, "success": 9950 },
|
|
478
|
-
"latency": { "avg": 25, "p95": 45, "p99": 80 },
|
|
479
|
-
"cache": { "hit_rate": 87 },
|
|
480
|
-
"workers": { "active": 8 },
|
|
481
|
-
"wasm": { "enabled": true }
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
179
|
```
|
|
485
180
|
|
|
486
181
|
---
|
|
487
182
|
|
|
488
|
-
## 🎯 Best Practices
|
|
489
|
-
|
|
490
|
-
### 1. Use Batch Operations
|
|
491
|
-
|
|
492
|
-
```javascript
|
|
493
|
-
// ✅ Good - Single batch request
|
|
494
|
-
{
|
|
495
|
-
"paths": ["file1.js", "file2.js", "file3.js"]
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
// ❌ Bad - Multiple individual requests
|
|
499
|
-
{ "path": "file1.js" }
|
|
500
|
-
{ "path": "file2.js" }
|
|
501
|
-
```
|
|
502
|
-
|
|
503
|
-
### 2. Enable Caching (Default)
|
|
504
|
-
|
|
505
|
-
```javascript
|
|
506
|
-
{
|
|
507
|
-
"instruction": "Add comments",
|
|
508
|
-
"files": { ... },
|
|
509
|
-
"use_cache": true // 87% hit rate
|
|
510
|
-
}
|
|
511
|
-
```
|
|
512
|
-
|
|
513
|
-
### 3. Handle Rate Limits
|
|
514
|
-
|
|
515
|
-
```javascript
|
|
516
|
-
// Response headers include rate limit info
|
|
517
|
-
X-RateLimit-Remaining: 59
|
|
518
|
-
X-RateLimit-Reset: 1699999999
|
|
519
|
-
|
|
520
|
-
// Handle 429 gracefully
|
|
521
|
-
if (response.status === 429) {
|
|
522
|
-
await sleep(response.headers['Retry-After'] * 1000);
|
|
523
|
-
}
|
|
524
|
-
```
|
|
525
|
-
|
|
526
|
-
### 4. Use Parallel Edit for Dependencies
|
|
527
|
-
|
|
528
|
-
```javascript
|
|
529
|
-
{
|
|
530
|
-
"tool": "parallel_edit",
|
|
531
|
-
"files": { ... },
|
|
532
|
-
"dependencies": ["auth.js", "profile.js"]
|
|
533
|
-
}
|
|
534
|
-
```
|
|
535
|
-
|
|
536
|
-
---
|
|
537
|
-
|
|
538
|
-
## 🧪 Testing
|
|
539
|
-
|
|
540
|
-
### Run Tests
|
|
541
|
-
|
|
542
|
-
```bash
|
|
543
|
-
# Install dependencies
|
|
544
|
-
npm install
|
|
545
|
-
|
|
546
|
-
# Run all tests
|
|
547
|
-
npm test
|
|
548
|
-
|
|
549
|
-
# Run with coverage
|
|
550
|
-
npm run test:coverage
|
|
551
|
-
```
|
|
552
|
-
|
|
553
|
-
### Test Coverage
|
|
554
|
-
|
|
555
|
-
- **77 tests** across 4 test suites
|
|
556
|
-
- **90% code coverage**
|
|
557
|
-
- **100% pass rate**
|
|
558
|
-
|
|
559
|
-
---
|
|
560
|
-
|
|
561
|
-
## 🛠️ Troubleshooting
|
|
562
|
-
|
|
563
|
-
### Common Issues
|
|
564
|
-
|
|
565
|
-
#### Issue: "Cannot find module"
|
|
566
|
-
|
|
567
|
-
```bash
|
|
568
|
-
# Solution
|
|
569
|
-
npm cache clean --force
|
|
570
|
-
npm install -g @mrxkun/mcfast-mcp@latest
|
|
571
|
-
```
|
|
572
|
-
|
|
573
|
-
#### Issue: "Rate limit exceeded"
|
|
574
|
-
|
|
575
|
-
```bash
|
|
576
|
-
# Default limits:
|
|
577
|
-
# Free: 60 req/min
|
|
578
|
-
# Pro: 600 req/min
|
|
579
|
-
# Enterprise: Custom
|
|
580
|
-
|
|
581
|
-
# Solution: Upgrade plan or implement backoff
|
|
582
|
-
```
|
|
583
|
-
|
|
584
|
-
#### Issue: "WASM not loading"
|
|
585
|
-
|
|
586
|
-
```bash
|
|
587
|
-
# Automatic fallback to JavaScript is enabled
|
|
588
|
-
# Check console for WASM status
|
|
589
|
-
# Requires Node.js 18+ or modern browser
|
|
590
|
-
```
|
|
591
|
-
|
|
592
|
-
---
|
|
593
|
-
|
|
594
|
-
## 📊 Benchmarks
|
|
595
|
-
|
|
596
|
-
### Latency Breakdown
|
|
597
|
-
|
|
598
|
-
```
|
|
599
|
-
Edit API (Total: 30ms)
|
|
600
|
-
├── Auth: 2ms
|
|
601
|
-
├── Cache Check (L1): 0.04ms ✅
|
|
602
|
-
├── Mercury API: 20ms
|
|
603
|
-
├── Processing: 5ms
|
|
604
|
-
└── Response: 2ms
|
|
605
|
-
|
|
606
|
-
Read API (Total: 6ms)
|
|
607
|
-
├── Auth: 2ms
|
|
608
|
-
├── Cache Check (L1): 0.04ms ✅ (87% hit)
|
|
609
|
-
├── Processing: 2ms
|
|
610
|
-
└── Response: 2ms
|
|
611
|
-
```
|
|
612
|
-
|
|
613
|
-
### Resource Usage
|
|
614
|
-
|
|
615
|
-
- **Memory per instance**: ~160MB
|
|
616
|
-
- L1 Cache: 100MB
|
|
617
|
-
- Worker Pool: 50MB
|
|
618
|
-
- WASM Modules: 10MB
|
|
619
|
-
- **CPU**: 25% utilization (2x more efficient)
|
|
620
|
-
- **Bundle size**: 55KB (22KB gzipped)
|
|
621
|
-
|
|
622
|
-
---
|
|
623
|
-
|
|
624
183
|
## 📝 Changelog
|
|
625
184
|
|
|
626
|
-
### v4.1.
|
|
627
|
-
|
|
628
|
-
- 🔧
|
|
629
|
-
|
|
630
|
-
- MCP protocol uses `stdout` for JSON-RPC - console.log corrupts stream
|
|
631
|
-
- Error `[FileWatche..." is not valid JSON` now resolved
|
|
632
|
-
- Fixed in 10 files: strategy-selector, agents-md, curated-memory, databases, context-analyzer, daily-logs, embedder, sync-engine, ultra-embedder
|
|
633
|
-
|
|
634
|
-
### v4.1.4 (2026-02-17) 🎉 ContextAnalyzer API
|
|
635
|
-
|
|
636
|
-
- ✨ **ContextAnalyzer Integration**
|
|
637
|
-
- `POST /memory/analyze` - AI-powered change analysis with Mercury Coder
|
|
638
|
-
- `POST /memory/session/summary` - Work session summarization
|
|
639
|
-
- `POST /memory/patterns/detect` - Pattern detection across sessions
|
|
640
|
-
- `POST /memory/update` - Automatic MEMORY.md updates
|
|
641
|
-
- `GET /memory/context` - Context retrieval with caching
|
|
642
|
-
|
|
643
|
-
- 📊 **SQL Migration Complete**
|
|
644
|
-
- 5 tables: memory_analysis, session_summaries, memory_updates, context_cache, analysis_patterns
|
|
645
|
-
- 24 indexes for optimal performance
|
|
646
|
-
- 4 analytics views, 3 functions, 2 triggers
|
|
647
|
-
|
|
648
|
-
### v4.0.5 (2026-02-16) 🎉 Bug Fix - Chokidar Version
|
|
649
|
-
|
|
650
|
-
- 🔧 **Fixed**: Sửa chokidar version từ ^4.0.4 sang ^4.0.3
|
|
651
|
-
- Phiên bản 4.0.4 không tồn tại trên npm registry
|
|
652
|
-
- Đảm bảo cài đặt dependencies thành công
|
|
653
|
-
|
|
654
|
-
### v4.0.4 (2026-02-16) 🎉 Phase 4 Complete - MCP Tools Added
|
|
655
|
-
|
|
656
|
-
- 🔧 **MCP Tools Registration**
|
|
657
|
-
- `memory_search` - Semantic code search with 90-95% accuracy
|
|
658
|
-
- `memory_get` - Retrieve stored memories and intelligence stats
|
|
659
|
-
- `detect_patterns` - Detect code patterns from edit history
|
|
660
|
-
- `get_suggestions` - Get intelligent code suggestions
|
|
661
|
-
- `select_strategy` - ML-based strategy selection
|
|
662
|
-
|
|
663
|
-
- 🧠 **Pattern Recognition**
|
|
664
|
-
- Detect frequent renames (naming inconsistencies)
|
|
665
|
-
- Identify repeated error fixes (recurring bugs)
|
|
666
|
-
- Find common edit sequences (automation opportunities)
|
|
667
|
-
- Spot problematic strategies (>30% failure rate)
|
|
668
|
-
- Detect hot files (frequently modified)
|
|
669
|
-
|
|
670
|
-
- 💡 **Predictive Suggestions**
|
|
671
|
-
- Naming convention fixes
|
|
672
|
-
- Long function extraction (>50 lines)
|
|
673
|
-
- Missing test coverage detection
|
|
674
|
-
- Unused import cleanup
|
|
675
|
-
- Duplicate code detection
|
|
676
|
-
- Performance anti-pattern detection
|
|
677
|
-
|
|
678
|
-
- 🎯 **Adaptive Strategy Selection**
|
|
679
|
-
- ML-based strategy selection (deterministic/cached/llm)
|
|
680
|
-
- Feature extraction from edit history
|
|
681
|
-
- Online learning from success/failure
|
|
682
|
-
- Automatic model improvement
|
|
683
|
-
- Persistent model storage
|
|
684
|
-
|
|
685
|
-
- 📊 **Analytics & Insights**
|
|
686
|
-
- Pattern detection API
|
|
687
|
-
- Suggestion generation API
|
|
688
|
-
- Strategy effectiveness tracking
|
|
689
|
-
- ML model performance metrics
|
|
690
|
-
- Dashboard integration
|
|
691
|
-
|
|
692
|
-
- 📈 **Phase 4 Metrics**:
|
|
693
|
-
- Suggestion relevance: >70%
|
|
694
|
-
- Strategy accuracy: >85%
|
|
695
|
-
- Pattern detection: >90% accuracy
|
|
696
|
-
- Auto-apply success: >90%
|
|
697
|
-
|
|
698
|
-
### v4.0.3 (2026-02-16) 🎉 Phase 4 Core Implementation
|
|
699
|
-
- Initial Phase 4 implementation (PatternDetector, SuggestionEngine, StrategySelector)
|
|
700
|
-
- Dashboard analytics endpoints
|
|
701
|
-
- SQL migration for Phase 4 tables
|
|
702
|
-
|
|
703
|
-
### v4.0.2 (2026-02-16) 🎉 Phase 3 Complete
|
|
704
|
-
- ✨ **Enhanced Edit Tool** with Memory Context
|
|
705
|
-
- Automatic context retrieval from codebase memory
|
|
706
|
-
- Impact analysis for rename operations (detects affected files)
|
|
707
|
-
- Auto-fix references across multiple files
|
|
708
|
-
- Enhanced instruction with relevant code context
|
|
709
|
-
- 🔧 **Memory-Integrated Search**
|
|
710
|
-
- Unified search now uses intelligent hybrid search (90-95% accuracy)
|
|
711
|
-
- Smart routing: auto-selects local vs Mercury re-ranking
|
|
712
|
-
- Edit history tracking and learning from past edits
|
|
713
|
-
- 📝 **Enhanced Memory Tools**
|
|
714
|
-
- `memory_search`: Now uses UltraHybrid search with 6 techniques
|
|
715
|
-
- `memory_get`: Added support for today's log and curated memories
|
|
716
|
-
- Full integration with MemoryEngine (replaced old LocalMemoryStore)
|
|
717
|
-
- 📊 **Phase 3 Metrics**:
|
|
718
|
-
- Context relevance: >80% (retrieved memories relevant to query)
|
|
719
|
-
- Search latency: <100ms for intelligent search
|
|
720
|
-
- Edit impact detection: >90% accuracy for symbol renames
|
|
721
|
-
|
|
722
|
-
### v4.0.1 (2026-02-14) 🎉
|
|
723
|
-
- 🗓️ **Daily Logs**: Auto-generated markdown notes for code changes
|
|
724
|
-
- Log file created/modified/deleted events
|
|
725
|
-
- Log edit sessions with strategy & success status
|
|
726
|
-
- Curated long-term memories (MEMORY.md)
|
|
727
|
-
- Cleanup old logs automatically
|
|
728
|
-
- 🔄 **Sync Engine**: Local ↔ Cloud synchronization
|
|
729
|
-
- Queue-based sync with persistence
|
|
730
|
-
- Periodic auto-sync (5 min default)
|
|
731
|
-
- Online/offline detection
|
|
732
|
-
- Last-write-wins conflict resolution
|
|
733
|
-
- 🧠 **Memory Enhancements**:
|
|
734
|
-
- `memory.logFileCreated()`, `memory.logFileModified()`, `memory.logFileDeleted()`
|
|
735
|
-
- `memory.logEditToMemory()` - Log edit + save to database
|
|
736
|
-
- `memory.getTodayLog()`, `memory.getCuratedMemories()`
|
|
737
|
-
- `memory.getSyncStatus()`, `memory.triggerSync()`
|
|
738
|
-
- ⚙️ **Optional Cloud Sync**: Auto-detects `MCFAST_TOKEN` for sync with Dashboard
|
|
739
|
-
|
|
740
|
-
### v4.0.0 (2026-02-14) 🎉
|
|
741
|
-
- 🧠 **Memory System**: Semantic code search with 90-95% accuracy
|
|
742
|
-
- Ultra-Enhanced Embeddings (1024-dim, 150+ synonyms)
|
|
743
|
-
- 6-technique hybrid search
|
|
744
|
-
- Auto-indexing with file watcher
|
|
745
|
-
- Offline-first: 100% offline, <1ms search
|
|
746
|
-
- 🎯 **Smart Routing**: Intelligent local vs Mercury decision
|
|
747
|
-
- 5-factor scoring (complexity, confidence, budget, history, urgency)
|
|
748
|
-
- 3 modes: Always Local / Auto Smart / Always Mercury
|
|
749
|
-
- Cost optimization: 70% savings
|
|
750
|
-
- 🎛️ **Dashboard Integration**: Web UI configuration
|
|
751
|
-
- Toggle Mercury re-ranking
|
|
752
|
-
- Monthly budget controls
|
|
753
|
-
- Usage analytics
|
|
754
|
-
- ⚡ **Performance**: 12,500+ embeddings/second
|
|
755
|
-
- 🔒 **Security**: API key management in Dashboard
|
|
756
|
-
|
|
757
|
-
### v3.5.7 (2026-02-13)
|
|
758
|
-
- 🚀 **NEW: MINIMAL_DIFF strategy** - Extracts exact search/replace pairs and applies deterministically
|
|
759
|
-
- 🔍 **Enhanced pattern detection** - Supports code identifiers, arrow notation, variable renames
|
|
760
|
-
- ⚡ **Parallel processing** - Multi-file edits processed concurrently
|
|
761
|
-
- 📦 **40-60% token reduction** for simple edits
|
|
762
|
-
- 🎯 **Smart fallback** - Only calls Mercury API when needed
|
|
763
|
-
|
|
764
|
-
### v3.5.1 (2026-02-13)
|
|
765
|
-
- 🐛 Bug fixes and stability improvements
|
|
766
|
-
- 📚 Enhanced documentation
|
|
767
|
-
- ✅ Updated dependencies
|
|
768
|
-
|
|
769
|
-
### v3.5.0 (2026-02-13)
|
|
770
|
-
- 🚀 **WebAssembly (Rust) support**
|
|
771
|
-
- ⚡ 3.2x faster fuzzy matching
|
|
772
|
-
- 🔍 2.5x faster code search
|
|
773
|
-
- 🌳 3x faster AST parsing
|
|
774
|
-
- 🎯 New tools: search, analyze, fuzzy_match
|
|
775
|
-
- 💾 Multi-layer caching (87% hit rate)
|
|
776
|
-
- 👷 Worker thread pool (8 workers)
|
|
777
|
-
|
|
778
|
-
### v3.4.2 (2026-02-12)
|
|
779
|
-
- 📦 Batch read mode (50 files)
|
|
780
|
-
- 🔗 Parallel edit with dependencies
|
|
781
|
-
- 💰 67% cost reduction
|
|
185
|
+
### v4.1.10 (2026-02-17)
|
|
186
|
+
- 🔧 Fixed `getCuratedMemories()` and `getIntelligenceStats()` missing methods
|
|
187
|
+
- 🔧 Version sync across all packages
|
|
188
|
+
- 📚 Updated documentation
|
|
782
189
|
|
|
783
|
-
|
|
190
|
+
### v4.1.5 (2026-02-17)
|
|
191
|
+
- 🔧 Fixed JSON-RPC Stream Corruption
|
|
192
|
+
- 🔄 Console suppression in MCP mode
|
|
784
193
|
|
|
785
|
-
|
|
194
|
+
### v4.1.4 (2026-02-17)
|
|
195
|
+
- ✨ ContextAnalyzer API with 5 new endpoints
|
|
196
|
+
- 📊 SQL Migration with 5 tables, 24 indexes
|
|
786
197
|
|
|
787
|
-
|
|
198
|
+
### v4.1.0 (2026-02-17)
|
|
199
|
+
- 🧠 Major Memory Refactor with Markdown source of truth
|
|
200
|
+
- 🔍 Hybrid Search (Vector 70% + BM25 30%)
|
|
788
201
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
npm run dev
|
|
795
|
-
```
|
|
202
|
+
### v4.0.5 (2026-02-16)
|
|
203
|
+
- 🔧 Fixed chokidar version (4.0.4 → 4.0.3)
|
|
204
|
+
|
|
205
|
+
### v4.0.4 (2026-02-16)
|
|
206
|
+
- 🔧 MCP Tools Registration (memory_search, memory_get, detect_patterns, etc.)
|
|
796
207
|
|
|
797
208
|
---
|
|
798
209
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrxkun/mcfast-mcp",
|
|
3
|
-
"version": "4.1.
|
|
4
|
-
"description": "Ultra-fast code editing with WASM acceleration, fuzzy patching, multi-layer caching, and 8 unified tools. v4.1.
|
|
3
|
+
"version": "4.1.10",
|
|
4
|
+
"description": "Ultra-fast code editing with WASM acceleration, fuzzy patching, multi-layer caching, and 8 unified tools. v4.1.10: Suppress console output to prevent JSON-RPC stream corruption.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"mcfast-mcp": "src/index.js"
|
package/src/index.js
CHANGED
|
@@ -8,32 +8,31 @@
|
|
|
8
8
|
// CRITICAL: Suppress ALL console output in MCP mode to prevent JSON parsing errors
|
|
9
9
|
// MCP protocol requires stdout to contain ONLY JSON-RPC messages
|
|
10
10
|
|
|
11
|
-
//
|
|
11
|
+
// ANSI Color Codes for Terminal Output (MUST be defined before any usage)
|
|
12
|
+
const colors = {
|
|
13
|
+
reset: '\x1b[0m',
|
|
14
|
+
bold: '\x1b[1m',
|
|
15
|
+
dim: '\x1b[2m',
|
|
16
|
+
cyan: '\x1b[36m',
|
|
17
|
+
green: '\x1b[32m',
|
|
18
|
+
yellow: '\x1b[33m',
|
|
19
|
+
blue: '\x1b[34m',
|
|
20
|
+
magenta: '\x1b[35m',
|
|
21
|
+
gray: '\x1b[90m',
|
|
22
|
+
white: '\x1b[37m',
|
|
23
|
+
bgBlack: '\x1b[40m',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// Override console.log - suppress in MCP mode
|
|
12
27
|
const originalConsoleLog = console.log;
|
|
13
28
|
console.log = function(...args) {
|
|
14
|
-
//
|
|
15
|
-
try {
|
|
16
|
-
const logDir = process.cwd();
|
|
17
|
-
const logFile = logDir + '/.mcfast/mcp-debug.log';
|
|
18
|
-
const message = `[${new Date().toISOString()}] [LOG] ${args.join(' ')}\n`;
|
|
19
|
-
require('fs').appendFileSync(logFile, message);
|
|
20
|
-
} catch (e) {
|
|
21
|
-
// Ignore if can't write
|
|
22
|
-
}
|
|
29
|
+
// Suppressed in MCP mode
|
|
23
30
|
};
|
|
24
31
|
|
|
25
|
-
// Override console.error -
|
|
32
|
+
// Override console.error - suppress in MCP mode
|
|
26
33
|
const originalConsoleError = console.error;
|
|
27
34
|
console.error = function(...args) {
|
|
28
|
-
//
|
|
29
|
-
try {
|
|
30
|
-
const logDir = process.cwd();
|
|
31
|
-
const logFile = logDir + '/.mcfast/mcp-debug.log';
|
|
32
|
-
const message = `[${new Date().toISOString()}] [ERROR] ${args.join(' ')}\n`;
|
|
33
|
-
require('fs').appendFileSync(logFile, message);
|
|
34
|
-
} catch (e) {
|
|
35
|
-
// Ignore if can't write
|
|
36
|
-
}
|
|
35
|
+
// Suppressed in MCP mode
|
|
37
36
|
};
|
|
38
37
|
|
|
39
38
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
@@ -318,21 +317,6 @@ async function analyzeRenameImpact(symbolName, currentFile = null) {
|
|
|
318
317
|
}
|
|
319
318
|
}
|
|
320
319
|
|
|
321
|
-
// ANSI Color Codes for Terminal Output
|
|
322
|
-
const colors = {
|
|
323
|
-
reset: '\x1b[0m',
|
|
324
|
-
bold: '\x1b[1m',
|
|
325
|
-
dim: '\x1b[2m',
|
|
326
|
-
cyan: '\x1b[36m',
|
|
327
|
-
green: '\x1b[32m',
|
|
328
|
-
yellow: '\x1b[33m',
|
|
329
|
-
blue: '\x1b[34m',
|
|
330
|
-
magenta: '\x1b[35m',
|
|
331
|
-
gray: '\x1b[90m',
|
|
332
|
-
white: '\x1b[37m',
|
|
333
|
-
bgBlack: '\x1b[40m',
|
|
334
|
-
};
|
|
335
|
-
|
|
336
320
|
// Tool icons (v2.0 - 4 core tools)
|
|
337
321
|
const toolIcons = {
|
|
338
322
|
edit: '✏️',
|
|
@@ -617,11 +601,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
617
601
|
// MEMORY TOOL 2: memory_get
|
|
618
602
|
{
|
|
619
603
|
name: "memory_get",
|
|
620
|
-
description: "📚 Get stored memories: today's log, curated memories, or
|
|
604
|
+
description: "📚 Get stored memories: today's log, curated memories, stats, or trigger re-index. Use to review recent changes or long-term knowledge.",
|
|
621
605
|
inputSchema: {
|
|
622
606
|
type: "object",
|
|
623
607
|
properties: {
|
|
624
|
-
type: { type: "string", enum: ["today_log", "curated", "stats", "intelligence"], description: "Type of memory to retrieve" }
|
|
608
|
+
type: { type: "string", enum: ["today_log", "curated", "stats", "intelligence", "reindex"], description: "Type of memory to retrieve or 'reindex' to trigger codebase re-indexing" }
|
|
625
609
|
},
|
|
626
610
|
required: ["type"]
|
|
627
611
|
}
|
|
@@ -2062,10 +2046,6 @@ async function handleReadFileInternal({ path: filePath, start_line, end_line, ma
|
|
|
2062
2046
|
|
|
2063
2047
|
if (startLine < 1) startLine = 1;
|
|
2064
2048
|
if (endLine < 1 || endLine > totalLines) endLine = totalLines;
|
|
2065
|
-
if (startLine > endLine) {
|
|
2066
|
-
throw new Error(`Invalid line range: start_line (${startLine}) > end_line (${endLine})`);
|
|
2067
|
-
}
|
|
2068
|
-
|
|
2069
2049
|
if (start_line || end_line) {
|
|
2070
2050
|
outputContent = lines.slice(startLine - 1, endLine).join('\n');
|
|
2071
2051
|
} else if (max_lines && lines.length > max_lines) {
|
|
@@ -2917,7 +2897,7 @@ async function handleMemorySearch({ query, type = 'all', maxResults = 6, minScor
|
|
|
2917
2897
|
score: fact.confidence || 0.8
|
|
2918
2898
|
}));
|
|
2919
2899
|
} else if (type === 'code') {
|
|
2920
|
-
const searchResult = await engine.
|
|
2900
|
+
const searchResult = await engine.intelligentSearch(query, { limit: maxResults });
|
|
2921
2901
|
results = searchResult.results.map(result => ({
|
|
2922
2902
|
type: 'chunk',
|
|
2923
2903
|
content: result.code || result.content,
|
|
@@ -3009,10 +2989,31 @@ async function handleMemoryGet({ type }) {
|
|
|
3009
2989
|
} else if (type === 'stats') {
|
|
3010
2990
|
const stats = await engine.getStats();
|
|
3011
2991
|
output = `📊 Memory Stats\n\n`;
|
|
3012
|
-
output +=
|
|
3013
|
-
output += `
|
|
3014
|
-
output += `
|
|
3015
|
-
output += `
|
|
2992
|
+
output += `📝 Memory Index\n`;
|
|
2993
|
+
output += ` Files: ${stats.memory?.files || 0}\n`;
|
|
2994
|
+
output += ` Chunks: ${stats.memory?.chunks || 0}\n`;
|
|
2995
|
+
output += ` Embeddings: ${stats.memory?.embeddings || 0}\n\n`;
|
|
2996
|
+
output += `💻 Codebase Index\n`;
|
|
2997
|
+
output += ` Files: ${stats.codebase?.files || 0}\n`;
|
|
2998
|
+
output += ` Facts: ${stats.codebase?.facts || 0}\n`;
|
|
2999
|
+
output += ` Chunks: ${stats.codebase?.chunks || 0}\n`;
|
|
3000
|
+
output += ` Embeddings: ${stats.codebase?.embeddings || 0}\n`;
|
|
3001
|
+
output += ` Edits: ${stats.codebase?.edits || 0}\n\n`;
|
|
3002
|
+
output += `🔄 Indexing\n`;
|
|
3003
|
+
output += ` Complete: ${stats.indexing?.is_complete ? '✅' : '⏳'}\n`;
|
|
3004
|
+
output += ` Indexed: ${stats.indexing?.indexed_files || 0}/${stats.indexing?.total_files || 0}\n`;
|
|
3005
|
+
output += ` Failed: ${stats.indexing?.failed_files || 0}\n`;
|
|
3006
|
+
} else if (type === 'reindex') {
|
|
3007
|
+
output = `🔄 Re-indexing Codebase\n\n`;
|
|
3008
|
+
output += `Starting re-index in background...\n`;
|
|
3009
|
+
|
|
3010
|
+
// Trigger re-index in background
|
|
3011
|
+
engine.performInitialScan().catch(err => {
|
|
3012
|
+
console.error('[Reindex] Error:', err.message);
|
|
3013
|
+
});
|
|
3014
|
+
|
|
3015
|
+
output += `✅ Re-index started. Check stats in a few seconds.\n`;
|
|
3016
|
+
output += `Use 'memory_get stats' to check progress.`;
|
|
3016
3017
|
} else if (type === 'intelligence') {
|
|
3017
3018
|
const intelStats = engine.getIntelligenceStats();
|
|
3018
3019
|
output = `🧠 Intelligence Stats\n\n`;
|
|
@@ -731,6 +731,25 @@ export class MemoryEngine {
|
|
|
731
731
|
return { strategy: 'cached', confidence: 0.6, reason: 'Default selection' };
|
|
732
732
|
}
|
|
733
733
|
|
|
734
|
+
async getCuratedMemories() {
|
|
735
|
+
return this.curatedMemory?.read?.() || null;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
getIntelligenceStats() {
|
|
739
|
+
return {
|
|
740
|
+
enabled: this.intelligenceEnabled,
|
|
741
|
+
patternDetector: {
|
|
742
|
+
totalPatterns: this.patternDetector?.getTotalPatterns?.() || 0
|
|
743
|
+
},
|
|
744
|
+
suggestionEngine: {
|
|
745
|
+
minConfidence: this.suggestionEngine?.minConfidence || 0.7
|
|
746
|
+
},
|
|
747
|
+
strategySelector: {
|
|
748
|
+
learningRate: this.strategySelector?.learningRate || 0.1
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
|
|
734
753
|
// ========== Sync Engine ==========
|
|
735
754
|
|
|
736
755
|
getSyncStatus() {
|