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

Function fitGraphFact

graph-ui/src/browser-ai/explanation-context.ts:167–179  ·  view source on GitHub ↗
(fact: string, budget: number)

Source from the content-addressed store, hash-verified

165}
166
167function fitGraphFact(fact: string, budget: number): string {
168 if (fact.length <= budget) return fact;
169 const lines = fact.split('\n');
170 const included: string[] = [];
171 for (const line of lines) {
172 const note = `${lines.length - included.length - 1} additional graph summary lines omitted.`;
173 if (included.join('\n').length + line.length + note.length + 2 > budget) break;
174 included.push(line);
175 }
176 const note = `${lines.length - included.length} additional graph summary lines omitted.`;
177 if (included.length && included.join('\n').length + note.length + 1 <= budget) return [...included, note].join('\n');
178 return '';
179}
180
181/** Relationships of one side: complete totals first, then each edge type with as
182 * many names as its fair share of the budget holds, then "+N more". */

Callers 1

fixedFactFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected