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

Method getTopRouteFile

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

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