* 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 *
()
| 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 |
nothing calls this directly
no test coverage detected