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

Method getTopRouteFile

src/db/queries.ts:1497–1516  ·  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

1495 * window saved next to nothing.
1496 */
1497 getTopRouteFile(): { filePath: string; routeCount: number; totalRoutes: number } | null {
1498 if (!this.stmts.getTopRouteFile) {
1499 this.stmts.getTopRouteFile = this.db.prepare(`
1500 SELECT file_path, COUNT(*) AS cnt
1501 FROM nodes
1502 WHERE kind = 'route'
1503 GROUP BY file_path
1504 ORDER BY cnt DESC, file_path
1505 `);
1506 }
1507 const rows = this.stmts.getTopRouteFile.all() as Array<{ file_path: string; cnt: number }>;
1508 const generated = this.getGeneratedPathsAmong(rows.map(r => r.file_path));
1509 const filtered = rows.filter(r => !isLowValueFile(r.file_path, generated));
1510 if (filtered.length === 0) return null;
1511 const totalRoutes = filtered.reduce((sum, r) => sum + r.cnt, 0);
1512 const top = filtered[0]!;
1513 if (totalRoutes < 3 || top.cnt < 3) return null;
1514 if (top.cnt / totalRoutes < 0.30) return null;
1515 return { filePath: top.file_path, routeCount: top.cnt, totalRoutes };
1516 }
1517
1518 /**
1519 * Build a URL → handler manifest from the index. Each route node's

Callers

nothing calls this directly

Calls 5

isLowValueFileFunction · 0.85
mapMethod · 0.80
prepareMethod · 0.65
allMethod · 0.65

Tested by

no test coverage detected