@whenmoon-afk/memory-mcp 2.4.1 → 2.4.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/package.json
CHANGED
|
@@ -383,23 +383,30 @@ function mergeMemories(allMemories) {
|
|
|
383
383
|
|
|
384
384
|
/**
|
|
385
385
|
* Merge entities (unique by name)
|
|
386
|
+
* Returns both the merged entities and a map from old entity IDs to new entity IDs
|
|
386
387
|
*/
|
|
387
388
|
function mergeEntities(allEntities) {
|
|
388
|
-
const byName = new Map();
|
|
389
|
+
const byName = new Map(); // name -> kept entity
|
|
390
|
+
const oldIdToNewId = new Map(); // old entity ID -> new entity ID
|
|
389
391
|
let duplicatesFound = 0;
|
|
390
392
|
|
|
391
393
|
for (const entity of allEntities) {
|
|
392
394
|
if (byName.has(entity.name)) {
|
|
393
395
|
duplicatesFound++;
|
|
394
|
-
//
|
|
396
|
+
// Map this entity's ID to the kept entity's ID
|
|
397
|
+
const keptEntity = byName.get(entity.name);
|
|
398
|
+
oldIdToNewId.set(entity.id, keptEntity.id);
|
|
395
399
|
} else {
|
|
396
400
|
byName.set(entity.name, entity);
|
|
401
|
+
// Map entity ID to itself (it's the kept one)
|
|
402
|
+
oldIdToNewId.set(entity.id, entity.id);
|
|
397
403
|
}
|
|
398
404
|
}
|
|
399
405
|
|
|
400
406
|
return {
|
|
401
407
|
entities: Array.from(byName.values()),
|
|
402
408
|
duplicatesFound,
|
|
409
|
+
oldIdToNewId,
|
|
403
410
|
};
|
|
404
411
|
}
|
|
405
412
|
|
|
@@ -592,10 +599,8 @@ function consolidate(targetPath, sourcePaths) {
|
|
|
592
599
|
}
|
|
593
600
|
}
|
|
594
601
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
entityIdMap.set(entity.name, entity.id);
|
|
598
|
-
}
|
|
602
|
+
// Entity ID mapping is returned from mergeEntities
|
|
603
|
+
const entityIdMap = mergedEntities.oldIdToNewId;
|
|
599
604
|
|
|
600
605
|
// Create target database
|
|
601
606
|
header('Step 5: Create consolidated database');
|
|
@@ -665,8 +670,9 @@ function consolidate(targetPath, sourcePaths) {
|
|
|
665
670
|
const insertMemoryEntities = targetDb.transaction((links) => {
|
|
666
671
|
for (const link of links) {
|
|
667
672
|
const newMemoryId = memoryIdMap.get(link.memory_id);
|
|
668
|
-
|
|
669
|
-
|
|
673
|
+
const newEntityId = entityIdMap.get(link.entity_id);
|
|
674
|
+
if (newMemoryId && newEntityId) {
|
|
675
|
+
insertMemoryEntity.run(newMemoryId, newEntityId, link.created_at);
|
|
670
676
|
memoryEntityCount++;
|
|
671
677
|
}
|
|
672
678
|
}
|