MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / importMemory

Function importMemory

src/context/memory-mirror.ts:71–85  ·  view source on GitHub ↗
(cwd: string)

Source from the content-addressed store, hash-verified

69/** MD → DB: add any bullet present in a mirror file but missing from the store. Returns the count
70 * added per scope. Additive only (removing a line won't delete a fact — use `/memory forget`). */
71export async function importMemory(cwd: string): Promise<{ user: number; project: number }> {
72 const store = getSessionStore();
73 const paths = memoryPaths(cwd);
74 const result = { user: 0, project: 0 };
75 for (const scope of ['user', 'project'] as const) {
76 const md = await fs.readFile(paths[scope], 'utf-8').catch(() => '');
77 if (!md) continue;
78 const inDb = new Set(store.getFactsByScope(scope, cwd, 5000));
79 for (const fact of parseMemory(md)) {
80 if (!inDb.has(fact)) { store.addFact('memory-import', cwd, fact, scope); result[scope]++; }
81 }
82 }
83 if (result.user || result.project) await exportMemory(cwd); // re-render so files + DB match exactly
84 return result;
85}

Callers

nothing calls this directly

Calls 7

getSessionStoreFunction · 0.85
memoryPathsFunction · 0.85
parseMemoryFunction · 0.85
exportMemoryFunction · 0.85
getFactsByScopeMethod · 0.80
addFactMethod · 0.80
hasMethod · 0.45

Tested by

no test coverage detected