rag-memory-epf-mcp 3.3.0 → 3.3.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.
- package/dist/index.js +13 -13
- package/dist/rag-memory.db +0 -0
- package/dist/rag-memory.db-shm +0 -0
- package/dist/rag-memory.db-wal +0 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -154,7 +154,7 @@ class RAGKnowledgeGraphManager {
|
|
|
154
154
|
VALUES (?, ?, ?, ?, ?)
|
|
155
155
|
`);
|
|
156
156
|
for (const entity of entities) {
|
|
157
|
-
const entityId = `entity_${entity.name.toLowerCase().replace(/[
|
|
157
|
+
const entityId = `entity_${entity.name.toLowerCase().replace(/[^\p{L}\p{N}]/gu, '_')}`;
|
|
158
158
|
const timestamped = (entity.observations || []).map(o => this._timestampObservation(o));
|
|
159
159
|
// Try insert first
|
|
160
160
|
const insertResult = insertStmt.run(entityId, entity.name, entity.entityType, JSON.stringify(timestamped), '{}');
|
|
@@ -199,8 +199,8 @@ class RAGKnowledgeGraphManager {
|
|
|
199
199
|
{ name: relation.from, entityType: 'CONCEPT', observations: [] },
|
|
200
200
|
{ name: relation.to, entityType: 'CONCEPT', observations: [] }
|
|
201
201
|
]);
|
|
202
|
-
const sourceId = `entity_${relation.from.toLowerCase().replace(/[
|
|
203
|
-
const targetId = `entity_${relation.to.toLowerCase().replace(/[
|
|
202
|
+
const sourceId = `entity_${relation.from.toLowerCase().replace(/[^\p{L}\p{N}]/gu, '_')}`;
|
|
203
|
+
const targetId = `entity_${relation.to.toLowerCase().replace(/[^\p{L}\p{N}]/gu, '_')}`;
|
|
204
204
|
const relationId = `rel_${sourceId}_${relation.relationType}_${targetId}`.toLowerCase();
|
|
205
205
|
const stmt = this.db.prepare(`
|
|
206
206
|
INSERT OR IGNORE INTO relationships
|
|
@@ -219,7 +219,7 @@ class RAGKnowledgeGraphManager {
|
|
|
219
219
|
throw new Error('Database not initialized');
|
|
220
220
|
const results = [];
|
|
221
221
|
for (const obs of observations) {
|
|
222
|
-
const entityId = `entity_${obs.entityName.toLowerCase().replace(/[
|
|
222
|
+
const entityId = `entity_${obs.entityName.toLowerCase().replace(/[^\p{L}\p{N}]/gu, '_')}`;
|
|
223
223
|
// Get current observations
|
|
224
224
|
const entity = this.db.prepare(`
|
|
225
225
|
SELECT observations FROM entities WHERE id = ?
|
|
@@ -250,7 +250,7 @@ class RAGKnowledgeGraphManager {
|
|
|
250
250
|
throw new Error('Database not initialized');
|
|
251
251
|
console.error(`🗑️ Deleting entities: ${entityNames.join(', ')}`);
|
|
252
252
|
for (const name of entityNames) {
|
|
253
|
-
const entityId = `entity_${name.toLowerCase().replace(/[
|
|
253
|
+
const entityId = `entity_${name.toLowerCase().replace(/[^\p{L}\p{N}]/gu, '_')}`;
|
|
254
254
|
try {
|
|
255
255
|
// Check if entity exists first
|
|
256
256
|
const entityExists = this.db.prepare(`
|
|
@@ -312,7 +312,7 @@ class RAGKnowledgeGraphManager {
|
|
|
312
312
|
if (!this.db)
|
|
313
313
|
throw new Error('Database not initialized');
|
|
314
314
|
for (const deletion of deletions) {
|
|
315
|
-
const entityId = `entity_${deletion.entityName.toLowerCase().replace(/[
|
|
315
|
+
const entityId = `entity_${deletion.entityName.toLowerCase().replace(/[^\p{L}\p{N}]/gu, '_')}`;
|
|
316
316
|
const entity = this.db.prepare(`
|
|
317
317
|
SELECT observations FROM entities WHERE id = ?
|
|
318
318
|
`).get(entityId);
|
|
@@ -329,8 +329,8 @@ class RAGKnowledgeGraphManager {
|
|
|
329
329
|
if (!this.db)
|
|
330
330
|
throw new Error('Database not initialized');
|
|
331
331
|
for (const relation of relations) {
|
|
332
|
-
const sourceId = `entity_${relation.from.toLowerCase().replace(/[
|
|
333
|
-
const targetId = `entity_${relation.to.toLowerCase().replace(/[
|
|
332
|
+
const sourceId = `entity_${relation.from.toLowerCase().replace(/[^\p{L}\p{N}]/gu, '_')}`;
|
|
333
|
+
const targetId = `entity_${relation.to.toLowerCase().replace(/[^\p{L}\p{N}]/gu, '_')}`;
|
|
334
334
|
this.db.prepare(`
|
|
335
335
|
DELETE FROM relationships
|
|
336
336
|
WHERE source_entity = ? AND target_entity = ? AND relationType = ?
|
|
@@ -343,8 +343,8 @@ class RAGKnowledgeGraphManager {
|
|
|
343
343
|
let updated = 0;
|
|
344
344
|
let notFound = 0;
|
|
345
345
|
for (const update of updates) {
|
|
346
|
-
const sourceId = `entity_${update.from.toLowerCase().replace(/[
|
|
347
|
-
const targetId = `entity_${update.to.toLowerCase().replace(/[
|
|
346
|
+
const sourceId = `entity_${update.from.toLowerCase().replace(/[^\p{L}\p{N}]/gu, '_')}`;
|
|
347
|
+
const targetId = `entity_${update.to.toLowerCase().replace(/[^\p{L}\p{N}]/gu, '_')}`;
|
|
348
348
|
const relationId = `rel_${sourceId}_${update.relationType}_${targetId}`.toLowerCase();
|
|
349
349
|
// Check if relation exists
|
|
350
350
|
const existing = this.db.prepare(`
|
|
@@ -407,7 +407,7 @@ class RAGKnowledgeGraphManager {
|
|
|
407
407
|
// Cap depth at 5 to prevent runaway queries
|
|
408
408
|
const effectiveDepth = Math.min(Math.max(depth, 1), 5);
|
|
409
409
|
// Convert entity names to IDs
|
|
410
|
-
const seedIds = entityNames.map(name => `entity_${name.toLowerCase().replace(/[
|
|
410
|
+
const seedIds = entityNames.map(name => `entity_${name.toLowerCase().replace(/[^\p{L}\p{N}]/gu, '_')}`);
|
|
411
411
|
// Build dynamic placeholders for the seed IDs
|
|
412
412
|
const seedPlaceholders = seedIds.map(() => '?').join(',');
|
|
413
413
|
// Build the recursive CTE query
|
|
@@ -1364,7 +1364,7 @@ class RAGKnowledgeGraphManager {
|
|
|
1364
1364
|
INSERT OR IGNORE INTO chunk_entities (chunk_rowid, entity_id) VALUES (?, ?)
|
|
1365
1365
|
`);
|
|
1366
1366
|
for (const entityName of entityNames) {
|
|
1367
|
-
const entityId = `entity_${entityName.toLowerCase().replace(/[
|
|
1367
|
+
const entityId = `entity_${entityName.toLowerCase().replace(/[^\p{L}\p{N}]/gu, '_')}`;
|
|
1368
1368
|
// Verify entity exists
|
|
1369
1369
|
const entity = this.db.prepare(`
|
|
1370
1370
|
SELECT id FROM entities WHERE id = ?
|
|
@@ -2144,7 +2144,7 @@ class RAGKnowledgeGraphManager {
|
|
|
2144
2144
|
if (entityNames && entityNames.length > 0) {
|
|
2145
2145
|
const targetIds = new Set();
|
|
2146
2146
|
for (const name of entityNames) {
|
|
2147
|
-
const id = `entity_${name.toLowerCase().replace(/[
|
|
2147
|
+
const id = `entity_${name.toLowerCase().replace(/[^\p{L}\p{N}]/gu, '_')}`;
|
|
2148
2148
|
if (graph.hasNode(id))
|
|
2149
2149
|
targetIds.add(id);
|
|
2150
2150
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|