cortex-mcp 2.7.2 → 2.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/db/memory-store.js +36 -8
- package/package.json +1 -1
package/dist/db/memory-store.js
CHANGED
|
@@ -205,14 +205,42 @@ class MemoryStore {
|
|
|
205
205
|
}
|
|
206
206
|
/** Full-text search via FTS5 */
|
|
207
207
|
searchFTS(query, limit = 20) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
.
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
208
|
+
// Sanitize: remove FTS5 special characters that cause syntax errors
|
|
209
|
+
const sanitized = query
|
|
210
|
+
.replace(/["*():^~]/g, ' ') // strip FTS5 operators
|
|
211
|
+
.replace(/\b(AND|OR|NOT)\b/g, ' ') // strip boolean keywords
|
|
212
|
+
.replace(/\s+/g, ' ')
|
|
213
|
+
.trim();
|
|
214
|
+
// If nothing left after sanitization, return empty
|
|
215
|
+
if (!sanitized)
|
|
216
|
+
return [];
|
|
217
|
+
try {
|
|
218
|
+
const rows = this.db
|
|
219
|
+
.prepare(`SELECT m.*, fts.rank FROM memory_fts fts JOIN memory_units m ON m.id = fts.id WHERE memory_fts MATCH ? AND m.is_active = 1 ORDER BY fts.rank LIMIT ?`)
|
|
220
|
+
.all(sanitized, limit);
|
|
221
|
+
return rows.map((row) => ({
|
|
222
|
+
memory: this.rowToMemory(row),
|
|
223
|
+
score: -row.rank, // FTS5 rank is negative (lower = better)
|
|
224
|
+
matchMethod: 'fts',
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
// FTS failed (index corrupt or tricky query) — fall back to LIKE search
|
|
229
|
+
try {
|
|
230
|
+
const likeQuery = `%${sanitized.split(' ').filter(Boolean)[0] || sanitized}%`;
|
|
231
|
+
const rows = this.db
|
|
232
|
+
.prepare(`SELECT * FROM memory_units WHERE is_active = 1 AND (intent LIKE ? OR action LIKE ? OR reason LIKE ?) LIMIT ?`)
|
|
233
|
+
.all(likeQuery, likeQuery, likeQuery, limit);
|
|
234
|
+
return rows.map((row) => ({
|
|
235
|
+
memory: this.rowToMemory(row),
|
|
236
|
+
score: 0.5,
|
|
237
|
+
matchMethod: 'fts',
|
|
238
|
+
}));
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
return [];
|
|
242
|
+
}
|
|
243
|
+
}
|
|
216
244
|
}
|
|
217
245
|
// ═══ VECTOR SEARCH (JS cosine similarity — M1 fallback) ═══
|
|
218
246
|
/** Store a vector embedding */
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "cortex-mcp",
|
|
3
3
|
"displayName": "Cortex MCP Server",
|
|
4
4
|
"description": "Persistent memory for AI coding assistants. Injects context from past sessions into every LLM request.",
|
|
5
|
-
"version": "2.7.
|
|
5
|
+
"version": "2.7.3",
|
|
6
6
|
"publisher": "cortex",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"engines": {
|