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

Method getTopRouteFile

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

944 * 30% of them (diffuse routing → no single answer file).
945 */
946 getTopRouteFile(): { filePath: string; routeCount: number; totalRoutes: number } | null {
947 if (!this.stmts.getTopRouteFile) {
948 this.stmts.getTopRouteFile = this.db.prepare(`
949 SELECT file_path, COUNT(*) AS cnt
950 FROM nodes
951 WHERE kind = 'route'
952 GROUP BY file_path
953 ORDER BY cnt DESC
954 LIMIT 20
955 `);
956 }
957 const rows = this.stmts.getTopRouteFile.all() as Array<{ file_path: string; cnt: number }>;
958 const filtered = rows.filter(r => !isLowValueFile(r.file_path));
959 if (filtered.length === 0) return null;
960 const totalRoutes = filtered.reduce((sum, r) => sum + r.cnt, 0);
961 const top = filtered[0]!;
962 if (totalRoutes < 3 || top.cnt < 3) return null;
963 if (top.cnt / totalRoutes < 0.30) return null;
964 return { filePath: top.file_path, routeCount: top.cnt, totalRoutes };
965 }
966
967 /**
968 * 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