(cwd: string)
| 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`). */ |
| 71 | export 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 | } |
nothing calls this directly
no test coverage detected