MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / flowNodes

Function flowNodes

graph-ui/src/pseudocode/flow-model.ts:96–136  ·  view source on GitHub ↗
(closure: ClosureDocument)

Source from the content-addressed store, hash-verified

94 * timeline of calls and not a set of symbols.
95 */
96export function flowNodes(closure: ClosureDocument): FlowNode[] {
97 const symbols = new Map<string, SymbolRef>();
98 for (const symbol of closure.symbols) {
99 symbols.set(identityOf(symbol), symbol);
100 }
101 const outgoing = adjacencyOf(closure.edges);
102 const out: FlowNode[] = [];
103 const rootKey = identityOf(closure.root);
104
105 const walk = (from: string, path: readonly string[], depth: number): void => {
106 for (const to of outgoing.get(from) ?? []) {
107 if (out.length >= FLOW_NODE_CAP) {
108 return;
109 }
110 const ref = symbols.get(to);
111 if (ref === undefined) {
112 continue;
113 }
114 const cycle = path.includes(to);
115 const next = cycle ? path : [...path, to];
116 out.push({
117 kind: 'symbol',
118 id: `flow.${out.length}`,
119 ref,
120 badges: cycle ? { cycle: true } : {},
121 depth,
122 path: next,
123 // Nothing here looked up whether the symbol is test code or
124 // whether the step constructs a class, so nothing here claims to
125 // have. The badges a closure can support are the cycle and
126 // nothing else.
127 enriched: false,
128 });
129 if (!cycle) {
130 walk(to, next, depth + 1);
131 }
132 }
133 };
134 walk(rootKey, [rootKey], 1);
135 return out;
136}
137
138/** Which symbols each symbol calls, in the order the walk recorded, deduplicated. */
139function adjacencyOf(edges: readonly ClosureEdge[]): Map<string, string[]> {

Callers 2

flow-model.test.tsFile · 0.90
buildFlowViewFunction · 0.90

Calls 3

identityOfFunction · 0.90
adjacencyOfFunction · 0.85
walkFunction · 0.70

Tested by

no test coverage detected