MCPcopy
hub / github.com/colbymchenry/codegraph / getTopRouteFile

Method getTopRouteFile

src/db/queries.ts:603–622  ·  view source on GitHub ↗

* Find the file that holds the densest concentration of the project's * `route` nodes (framework-emitted: Express/Gin/Flask/Rails/Drupal/etc.). * Used by handleContext on small repos to inline the project's routing * config when the agent's query is about request flow — eliminating the *

()

Source from the content-addressed store, hash-verified

601 * 30% of them (diffuse routing → no single answer file).
602 */
603 getTopRouteFile(): { filePath: string; routeCount: number; totalRoutes: number } | null {
604 if (!this.stmts.getTopRouteFile) {
605 this.stmts.getTopRouteFile = this.db.prepare(`
606 SELECT file_path, COUNT(*) AS cnt
607 FROM nodes
608 WHERE kind = 'route'
609 GROUP BY file_path
610 ORDER BY cnt DESC
611 LIMIT 20
612 `);
613 }
614 const rows = this.stmts.getTopRouteFile.all() as Array<{ file_path: string; cnt: number }>;
615 const filtered = rows.filter(r => !isLowValueFile(r.file_path));
616 if (filtered.length === 0) return null;
617 const totalRoutes = filtered.reduce((sum, r) => sum + r.cnt, 0);
618 const top = filtered[0]!;
619 if (totalRoutes < 3 || top.cnt < 3) return null;
620 if (top.cnt / totalRoutes < 0.30) return null;
621 return { filePath: top.file_path, routeCount: top.cnt, totalRoutes };
622 }
623
624 /**
625 * Build a URL → handler manifest from the index. Each route node's

Callers

nothing calls this directly

Calls 3

isLowValueFileFunction · 0.85
prepareMethod · 0.65
allMethod · 0.65

Tested by

no test coverage detected