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

Function retrieveWithTraversal

src/core/memory-graph.ts:312–332  ·  view source on GitHub ↗
(rootDir: string, startNodeId: string, maxDepth: number = 2, edgeFilter?: RelationType[])

Source from the content-addressed store, hash-verified

310}
311
312export async function retrieveWithTraversal(rootDir: string, startNodeId: string, maxDepth: number = 2, edgeFilter?: RelationType[]): Promise<TraversalResult[]> {
313 const graph = await loadGraph(rootDir);
314 const startNode = graph.nodes[startNodeId];
315 if (!startNode) return [];
316
317 startNode.lastAccessed = Date.now();
318 startNode.accessCount++;
319
320 const results: TraversalResult[] = [{
321 node: startNode,
322 depth: 0,
323 pathRelations: [startNode.label],
324 relevanceScore: 100,
325 }];
326
327 const visited = new Set([startNodeId]);
328 collectTraversal(graph, startNodeId, 1, maxDepth, [startNode.label], visited, results, edgeFilter);
329
330 scheduleSave(rootDir);
331 return results;
332}
333
334function collectTraversal(
335 graph: GraphStore, nodeId: string, depth: number, maxDepth: number,

Callers 2

Calls 3

loadGraphFunction · 0.85
collectTraversalFunction · 0.85
scheduleSaveFunction · 0.85

Tested by

no test coverage detected