MCPcopy Index your code
hub / github.com/forloopcodes/contextplus / loadGraph

Function loadGraph

src/core/memory-graph.ts:84–97  ·  view source on GitHub ↗
(rootDir: string)

Source from the content-addressed store, hash-verified

82}
83
84async function loadGraph(rootDir: string): Promise<GraphStore> {
85 if (graphCache.has(rootDir)) return graphCache.get(rootDir)!;
86 try {
87 const raw = JSON.parse(await readFile(join(rootDir, CACHE_DIR, GRAPH_FILE), "utf-8"));
88 const store: GraphStore = {
89 nodes: raw?.nodes && typeof raw.nodes === "object" ? raw.nodes : {},
90 edges: raw?.edges && typeof raw.edges === "object" ? raw.edges : {},
91 };
92 graphCache.set(rootDir, store);
93 } catch {
94 graphCache.set(rootDir, { nodes: {}, edges: {} });
95 }
96 return graphCache.get(rootDir)!;
97}
98
99async function persistGraph(rootDir: string): Promise<void> {
100 const store = graphCache.get(rootDir);

Callers 7

upsertNodeFunction · 0.85
createRelationFunction · 0.85
searchGraphFunction · 0.85
pruneStaleLinksFunction · 0.85
addInterlinkedContextFunction · 0.85
retrieveWithTraversalFunction · 0.85
getGraphStatsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected