(names: string[])
| 212 | } |
| 213 | |
| 214 | async openNodes(names: string[]): Promise<KnowledgeGraph> { |
| 215 | const graph = await this.loadGraph(); |
| 216 | |
| 217 | // Filter entities |
| 218 | const filteredEntities = graph.entities.filter(e => names.includes(e.name)); |
| 219 | |
| 220 | // Create a Set of filtered entity names for quick lookup |
| 221 | const filteredEntityNames = new Set(filteredEntities.map(e => e.name)); |
| 222 | |
| 223 | // Include relations where at least one endpoint is in the requested set. |
| 224 | // Previously this required BOTH endpoints, which meant relations from a |
| 225 | // requested node to an unrequested node were silently dropped — making it |
| 226 | // impossible to discover a node's connections without reading the full graph. |
| 227 | const filteredRelations = graph.relations.filter(r => |
| 228 | filteredEntityNames.has(r.from) || filteredEntityNames.has(r.to) |
| 229 | ); |
| 230 | |
| 231 | const filteredGraph: KnowledgeGraph = { |
| 232 | entities: filteredEntities, |
| 233 | relations: filteredRelations, |
| 234 | }; |
| 235 | |
| 236 | return filteredGraph; |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | let knowledgeGraphManager: KnowledgeGraphManager; |
no test coverage detected