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

Function exportMemory

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

Source from the content-addressed store, hash-verified

53
54/** DB → MD: regenerate both memory files from the store. Best-effort; never throws. */
55export async function exportMemory(cwd: string): Promise<{ user: string; project: string }> {
56 const paths = memoryPaths(cwd);
57 try {
58 const store = getSessionStore();
59 const userFacts = store.getFactsByScope('user', cwd, 1000);
60 const projFacts = store.getFactsByScope('project', cwd, 1000);
61 await fs.mkdir(path.dirname(paths.user), { recursive: true }).catch(() => {});
62 await fs.mkdir(path.dirname(paths.project), { recursive: true }).catch(() => {});
63 await fs.writeFile(paths.user, serializeMemory(userFacts, 'user (global)'));
64 await fs.writeFile(paths.project, serializeMemory(projFacts, projectTitle(cwd)));
65 } catch { /* mirror is best-effort — a failed write never breaks a fact write */ }
66 return paths;
67}
68
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`). */

Callers 4

executeMethod · 0.85
executeMethod · 0.85
importMemoryFunction · 0.85
dispatchActionFunction · 0.85

Calls 5

memoryPathsFunction · 0.85
getSessionStoreFunction · 0.85
serializeMemoryFunction · 0.85
projectTitleFunction · 0.85
getFactsByScopeMethod · 0.80

Tested by

no test coverage detected