MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / hubs

Function hubs

src/ui-server/api/entrypoints.ts:400–417  ·  view source on GitHub ↗

The most depended-on symbols, tests, generated files and non-navigable kinds removed.

(cg: CodeGraph, limit: number)

Source from the content-addressed store, hash-verified

398
399/** The most depended-on symbols, tests, generated files and non-navigable kinds removed. */
400function hubs(cg: CodeGraph, limit: number): WireList<WireEntryHub> {
401 const ranked = cg
402 .getTopDependedOn(SCAN_ROWS)
403 .map((row) => ({ row, node: cg.getNode(row.nodeId) }));
404 // A vendored bundle's one-letter functions are depended on by the bundle alone.
405 const generated = cg.generatedFilePredicate(ranked.flatMap(({ node }) => (node ? [node.filePath] : [])));
406
407 const items: WireEntryHub[] = [];
408 let eligible = 0;
409 for (const { row, node } of ranked) {
410 if (!node || NON_HUB_KINDS.has(node.kind) || isTestFile(node.filePath) || generated(node.filePath)) continue;
411 eligible += 1;
412 if (items.length >= limit) continue;
413 items.push({ ...toNodeRef(node), dependents: row.dependents });
414 }
415
416 return wireList(items, Math.max(eligible, items.length));
417}
418
419/** `src/bin/codegraph.ts` -> `src/bin`; a root file -> `.`. */
420function directoryOf(filePath: string): string {

Callers 1

buildEntryPointsFunction · 0.85

Calls 10

isTestFileFunction · 0.90
toNodeRefFunction · 0.90
wireListFunction · 0.90
generatedFunction · 0.85
mapMethod · 0.80
getNodeMethod · 0.80
hasMethod · 0.80
pushMethod · 0.80
getTopDependedOnMethod · 0.45

Tested by

no test coverage detected