MCPcopy Create free account
hub / github.com/EvoMap/evolver / findMemoryGraph

Function findMemoryGraph

src/adapters/scripts/_runtimePaths.js:380–403  ·  view source on GitHub ↗
(evolverRoot)

Source from the content-addressed store, hash-verified

378// outcomes (#536). Callers that need a "does the file already exist" check
379// should use `fs.existsSync()` separately.
380function findMemoryGraph(evolverRoot) {
381 if (process.env.MEMORY_GRAPH_PATH) {
382 return process.env.MEMORY_GRAPH_PATH;
383 }
384 if (evolverRoot) {
385 const lower = path.join(evolverRoot, 'memory', 'evolution', 'memory_graph.jsonl');
386 if (fs.existsSync(lower)) return lower;
387 const upper = path.join(evolverRoot, 'MEMORY', 'evolution', 'memory_graph.jsonl');
388 if (fs.existsSync(upper)) return upper;
389 // Neither exists yet — prefer lowercase under the evolver root if the
390 // root itself is writable (dev/local install case).
391 try {
392 fs.accessSync(evolverRoot, fs.constants.W_OK);
393 const dir = path.dirname(lower);
394 try { fs.mkdirSync(dir, { recursive: true }); } catch { /* fall through */ }
395 return lower;
396 } catch { /* not writable, fall through to user-level */ }
397 }
398
399 // User-level fallback. Always writable, consistent across platforms.
400 const userDir = path.join(os.homedir(), '.evolver', 'memory', 'evolution');
401 try { fs.mkdirSync(userDir, { recursive: true }); } catch { /* best-effort */ }
402 return path.join(userDir, 'memory_graph.jsonl');
403}
404
405// Is `dir` inside a git work tree? Cheap, no-shell `git rev-parse`. Returns
406// false on any error (git missing, not a repo, timeout) and never throws.

Callers 2

mainFunction · 0.85
runInjectionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected