(rootDir: string, startNodeId: string, maxDepth: number = 2, edgeFilter?: RelationType[])
| 310 | } |
| 311 | |
| 312 | export 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 | |
| 334 | function collectTraversal( |
| 335 | graph: GraphStore, nodeId: string, depth: number, maxDepth: number, |
no test coverage detected