Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history

app.tsx

Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.

app.tsxBlame726 lines · 4 contributors
79136bbClaude1import { Hono } from "hono";
2import { logger } from "hono/logger";
3import { cors } from "hono/cors";
05b973eClaude4import { compress } from "hono/compress";
f1ffd50Claude5import { etag } from "hono/etag";
c63b860Claude6// BLOCK O2 — shared error-page surface (404 / 500 / 403).
7import { NotFoundPage, ServerErrorPage } from "./views/error-page";
80bed05Claude8import { reportError } from "./lib/observability";
3ef4c9dClaude9import { requestContext } from "./middleware/request-context";
10import { rateLimit } from "./middleware/rate-limit";
79136bbClaude11import gitRoutes from "./routes/git";
12import apiRoutes from "./routes/api";
45e31d0Claude13import apiV2Routes from "./routes/api-v2";
14import apiDocsRoutes from "./routes/api-docs";
4a80519Claude15import buildAgentSpecRoutes from "./routes/build-agent-spec";
a6ff0f2Claude16import pullsDashboardRoutes from "./routes/pulls-dashboard";
e9aa4d8Claude17import issuesDashboardRoutes from "./routes/issues-dashboard";
18import inboxRoutes from "./routes/inbox";
19import activityRoutes from "./routes/activity";
79136bbClaude20import authRoutes from "./routes/auth";
c63b860Claude21import passwordResetRoutes from "./routes/password-reset";
22import emailVerificationRoutes from "./routes/email-verification";
cd4f63bTest User23import magicLinkRoutes from "./routes/magic-link";
79136bbClaude24import settingsRoutes from "./routes/settings";
7298a17Claude25import settings2faRoutes from "./routes/settings-2fa";
e75eddcClaude26import settingsAgentsRoutes from "./routes/settings-agents";
1d4ff60Claude27import settingsIntegrationsRoutes from "./routes/settings-integrations";
28import integrationsChatRoutes from "./routes/integrations-chat";
e75eddcClaude29import agentsRoutes from "./routes/agents";
79136bbClaude30import issueRoutes from "./routes/issues";
cb5a796Claude31import commentModerationRoutes from "./routes/comment-moderation";
79136bbClaude32import repoSettings from "./routes/repo-settings";
23d1a81Claude33import collaboratorRoutes from "./routes/collaborators";
04f6b7fClaude34import teamCollaboratorRoutes from "./routes/team-collaborators";
35import invitesRoutes from "./routes/invites";
36import liveEventsRoutes from "./routes/live-events";
3c03977Claude37import prLiveRoutes from "./routes/pr-live";
79136bbClaude38import compareRoutes from "./routes/compare";
0074234Claude39import pullRoutes from "./routes/pulls";
79ed944Claude40import prSandboxRoutes from "./routes/pr-sandbox";
9b3a183Claude41import devEnvRoutes from "./routes/dev-env";
0074234Claude42import editorRoutes from "./routes/editor";
c81ab7aClaude43import forkRoutes from "./routes/fork";
44import webhookRoutes from "./routes/webhooks";
45import exploreRoutes from "./routes/explore";
46import tokenRoutes from "./routes/tokens";
43de941Claude47import contributorRoutes from "./routes/contributors";
699e5c7Claude48import healthRoutes from "./routes/health-probe";
49import healthDashboardRoutes from "./routes/health";
2316be6Claude50import statusRoutes from "./routes/status";
b1be050CC LABS App51import adminStatusRoutes from "./routes/admin-status";
80bed05Claude52import helpRoutes from "./routes/help";
b0148e9Claude53import marketingRoutes from "./routes/marketing";
5f2e749Claude54import pricingRoutes from "./routes/pricing";
5618f9aClaude55import seoRoutes from "./routes/seo";
05cdb85Claude56import versionRoutes from "./routes/version";
f295f78Dictation App57import { platformStatus } from "./routes/platform-status";
52ad8b1Claude58import publicStatsRoutes from "./routes/public-stats";
59import demoRoutes from "./routes/demo";
16b325cClaude60import insightRoutes from "./routes/insights";
8d1483cClaude61import doraRoutes from "./routes/dora";
f1ab587Claude62import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude63import legalRoutes from "./routes/legal";
4b66018Claude64import legalDmcaRoutes from "./routes/legal/dmca";
65import legalTermsRoutes from "./routes/legal/terms";
66import legalPrivacyRoutes from "./routes/legal/privacy";
67import legalAcceptableUseRoutes from "./routes/legal/acceptable-use";
bdbd0deClaude68import importRoutes from "./routes/import";
14c3cc8Claude69import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App70import importSecretsRoutes from "./routes/import-secrets";
14c3cc8Claude71import migrationRoutes from "./routes/migrations";
72import specsRoutes from "./routes/specs";
23d0abfClaude73import refactorRoutes from "./routes/refactors";
79136bbClaude74import webRoutes from "./routes/web";
0316dbbClaude75import hookRoutes from "./routes/hooks";
76import eventsRoutes from "./routes/events";
77import passkeyRoutes from "./routes/passkeys";
78import oauthRoutes from "./routes/oauth";
79import developerAppsRoutes from "./routes/developer-apps";
80import themeRoutes from "./routes/theme";
81import auditRoutes from "./routes/audit";
82import reactionRoutes from "./routes/reactions";
83import savedReplyRoutes from "./routes/saved-replies";
84import deploymentRoutes from "./routes/deployments";
85import orgRoutes from "./routes/orgs";
86import notificationRoutes from "./routes/notifications";
87import onboardingRoutes from "./routes/onboarding";
88import adminRoutes from "./routes/admin";
f764c07Claude89import adminDeploysRoutes from "./routes/admin-deploys";
90import adminDeploysPageRoutes from "./routes/admin-deploys-page";
783dd46Claude91import adminServerTargetsRoutes from "./routes/admin-server-targets";
90c7531Claude92import claudeWebRoutes from "./routes/claude-web";
9dd96b9Test User93import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App94import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User95import adminDiagnoseRoutes from "./routes/admin-diagnose";
509c376Claude96import adminIntegrationsRoutes from "./routes/admin-integrations";
79ed944Claude97import adminAdvancementRoutes from "./routes/admin-advancement";
0316dbbClaude98import advisoriesRoutes from "./routes/advisories";
99import aiChangelogRoutes from "./routes/ai-changelog";
100import aiExplainRoutes from "./routes/ai-explain";
101import aiTestsRoutes from "./routes/ai-tests";
102import askRoutes from "./routes/ask";
38d31d3Claude103import repoChatRoutes from "./routes/repo-chat";
ee7e577Claude104import personalChatRoutes from "./routes/personal-chat";
0316dbbClaude105import billingRoutes from "./routes/billing";
8809b87Claude106import billingUsageRoutes from "./routes/billing-usage";
6778ad2Claude107import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude108import codeScanningRoutes from "./routes/code-scanning";
109import commitStatusesRoutes from "./routes/commit-statuses";
110import copilotRoutes from "./routes/copilot";
111import depUpdaterRoutes from "./routes/dep-updater";
112import depsRoutes from "./routes/deps";
113import discussionsRoutes from "./routes/discussions";
114import environmentsRoutes from "./routes/environments";
4bbacbeClaude115import previewsRoutes from "./routes/previews";
79ed944Claude116import docsTrackingRoutes from "./routes/docs-tracking";
0316dbbClaude117import followsRoutes from "./routes/follows";
118import gatesRoutes from "./routes/gates";
119import gistsRoutes from "./routes/gists";
120import graphqlRoutes from "./routes/graphql";
2c2163eClaude121import mcpRoutes from "./routes/mcp";
0316dbbClaude122import marketplaceRoutes from "./routes/marketplace";
5ca514aClaude123import marketplaceAgentsRoutes from "./routes/marketplace-agents";
0316dbbClaude124import mergeQueueRoutes from "./routes/merge-queue";
125import mirrorsRoutes from "./routes/mirrors";
126import orgInsightsRoutes from "./routes/org-insights";
127import packagesRoutes from "./routes/packages";
128import packagesApiRoutes from "./routes/packages-api";
129import pagesRoutes from "./routes/pages";
130import projectsRoutes from "./routes/projects";
131import protectedTagsRoutes from "./routes/protected-tags";
132import pwaRoutes from "./routes/pwa";
46d6165Claude133import installRoutes from "./routes/install";
cd4f63bTest User134import dxtRoutes from "./routes/dxt";
662ce86Claude135import connectClaudeRoutes from "./routes/connect-claude";
ebbb527Claude136import claudeDeployRoutes from "./routes/claude-deploy";
f5b9ef5Claude137import claudeIntegration from "./routes/claude-integration";
138import connectRoutes from "./routes/connect";
05ab9b1Claude139import pushWatchRoutes from "./routes/push-watch";
140import orgSecretsRoutes from "./routes/org-secrets";
0316dbbClaude141import releasesRoutes from "./routes/releases";
142import requiredChecksRoutes from "./routes/required-checks";
143import rulesetsRoutes from "./routes/rulesets";
144import searchRoutes from "./routes/search";
145import semanticSearchRoutes from "./routes/semantic-search";
146import signingKeysRoutes from "./routes/signing-keys";
147import sponsorsRoutes from "./routes/sponsors";
148import ssoRoutes from "./routes/sso";
46d6165Claude149import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude150import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude151import symbolsRoutes from "./routes/symbols";
152import templatesRoutes from "./routes/templates";
153import trafficRoutes from "./routes/traffic";
154import wikisRoutes from "./routes/wikis";
155import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude156import workflowArtifactsRoutes from "./routes/workflow-artifacts";
157import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude158import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude159import standupRoutes from "./routes/standups";
52ad8b1Claude160import vsGithubRoutes from "./routes/vs-github";
45f3b73Claude161import voiceRoutes from "./routes/voice-to-pr";
cd4f63bTest User162import playgroundRoutes from "./routes/playground";
a2b3e99Claude163import crossRepoSearchRoutes from "./routes/cross-repo-search";
164import pushNotifRoutes from "./routes/push-notifications";
9fbe6cdClaude165import velocityRoutes from "./routes/velocity";
166import { staleBranchRoutes } from "./routes/stale-branches";
22f43f3Claude167import pulseRoutes from "./routes/pulse";
74d8c4dClaude168import healthScoreRoutes from "./routes/health-score";
169import hotFilesRoutes from "./routes/hot-files";
59b6fb2Claude170import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
171import { csrfToken, csrfProtect } from "./middleware/csrf";
f5b9ef5Claude172import { noCache } from "./middleware/no-cache";
79136bbClaude173
2316901Claude174import type { AuthEnv } from "./middleware/auth";
bf19c50Test User175import { softAuth } from "./middleware/auth";
2316901Claude176
177const app = new Hono<AuthEnv>();
79136bbClaude178
3ef4c9dClaude179// Request context (request ID, start time) runs before everything else
180app.use("*", requestContext);
05b973eClaude181// Middleware — compression first (wraps all responses)
182app.use("*", compress());
f1ffd50Claude183
184// ETag middleware — returns 304 Not Modified on unchanged responses.
185// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
186// SSE + the API surface where it would interfere with streaming.
187app.use("*", async (c, next) => {
188 const p = c.req.path;
189 if (
190 p.includes(".git/") ||
191 p.startsWith("/live-events") ||
192 p.startsWith("/api/events/deploy") ||
3c03977Claude193 p.startsWith("/admin/status") ||
194 // PR live co-editing SSE stream — never etag streaming responses.
195 /^\/api\/v2\/pulls\/[^/]+\/live(\/|$)/.test(p)
f1ffd50Claude196 ) {
197 return next();
198 }
199 return etag()(c, next);
200});
201
202// Cache-Control middleware — sets sensible defaults on public, anonymous
203// requests. Crontech (when wired as our edge layer) and downstream
204// browsers will honor these. Auth'd users get private,no-store
205// automatically — we never cache responses tied to a session.
206app.use("*", async (c, next) => {
207 await next();
208 // Don't overwrite explicit headers set by route handlers — BUT the
209 // ETag middleware unconditionally sets "private, no-cache, must-
210 // revalidate" so we have to treat that specific value as "no
211 // policy chosen yet" and apply ours. Any route that explicitly set
212 // a different cache-control wins.
213 const existing = c.res.headers.get("cache-control");
214 const etagDefault =
215 existing === "private, no-cache, must-revalidate" ||
216 existing === "no-cache";
217 if (existing && !etagDefault) return;
218 // Anything past auth: private + no-store (avoid leaking session
219 // content into shared caches). softAuth runs before this on the
220 // request, but the response side is what we're stamping.
221 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
222 const p = c.req.path;
223 // Always private for known-authed paths regardless of cookie.
224 if (
225 p.startsWith("/admin") ||
226 p.startsWith("/settings") ||
227 p.startsWith("/dashboard") ||
228 p.startsWith("/notifications") ||
229 p.startsWith("/connect/") ||
230 hasSession
231 ) {
232 c.res.headers.set("cache-control", "private, no-store");
233 return;
234 }
235 // Public marketing surfaces — short edge cache, longer browser cache,
236 // stale-while-revalidate so the user never waits on a stale fetch.
237 const isMarketing =
238 p === "/" ||
239 p === "/features" ||
240 p === "/pricing" ||
241 p === "/about" ||
242 p === "/vs-github" ||
243 p === "/explore" ||
244 p === "/help" ||
245 p === "/changelog" ||
246 p.startsWith("/legal/") ||
247 p === "/terms" ||
248 p === "/privacy" ||
249 p === "/acceptable-use" ||
250 p.startsWith("/docs/");
251 if (isMarketing) {
252 c.res.headers.set(
253 "cache-control",
254 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
255 );
256 return;
257 }
258 // Public repo browse pages — cache aggressively. Edge invalidates
259 // on push via the post-receive hook (future Crontech surge purge).
260 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
261 c.res.headers.set(
262 "cache-control",
263 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
264 );
265 return;
266 }
267 // Default: don't cache anything we haven't explicitly opted in.
268 c.res.headers.set("cache-control", "private, no-store");
269});
05b973eClaude270// Logger only on non-git routes to avoid overhead on clone/push
271app.use("*", async (c, next) => {
272 if (c.req.path.includes(".git/")) return next();
273 return logger()(c, next);
274});
79136bbClaude275app.use("/api/*", cors());
bf19c50Test User276// Global softAuth — populates c.get("user") for every downstream middleware
277// + route. This was previously per-route, which meant rate-limit middleware
278// (and anything else inspecting auth state) always saw a null user. Keep
279// individual routes free to add requireAuth on top for hard gating; this
280// just establishes the user object cheaply.
281app.use("*", softAuth);
290ea77Claude282
36cc17aClaude283// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude284// pre-redesign markup. JSON / static assets keep their own cache rules; only
285// text/html responses get the no-cache stamp. Without this, every push to
286// main left users staring at cached 80s-looking pages from before the design
287// landed.
36cc17aClaude288//
289// We deliberately use `private, no-cache, must-revalidate` rather than
290// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
291// which makes every Back/Forward press a cold server round-trip — that
292// contributed to the "every nav feels like a fresh login" UX complaint.
293// `no-cache` still revalidates on direct fetch but lets bfcache hold the
294// page in memory between navigations.
290ea77Claude295app.use("*", async (c, next) => {
296 await next();
297 const ct = c.res.headers.get("content-type") || "";
298 if (ct.startsWith("text/html")) {
36cc17aClaude299 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude300 }
301});
826eccfTest User302// Rate-limit API + auth endpoints.
303//
a41e675Test User304// `/api/*`: 1000/min per IP — generous so an admin clicking around the
305// operator console (or a CDN/proxy concentrating multiple users behind one
306// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
307// rate limits below, not this one.
308//
309// `authedMultiplier` is set but only fires when an upstream middleware has
310// already populated c.get("user") — most app.use() chains apply softAuth
311// per-route, so the multiplier is best-effort. Keep the anonymous base
312// high enough that humans never feel it.
313//
314// Skip-paths: dashboard plumbing endpoints that the layout polls on a
315// fixed cadence and that we don't want consuming any bucket:
316// /api/version — layout polls every 15s
826eccfTest User317// /api/notifications/count — nav bell unread-count fetcher
318// /pwa/vapid-public-key — fetched once per push-notification opt-in
319app.use(
320 "/api/*",
a41e675Test User321 rateLimit(1000, 60_000, "api", {
826eccfTest User322 authedMultiplier: 4,
323 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
324 })
325);
0316dbbClaude326app.use("/login", rateLimit(20, 60_000, "login"));
327app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude328// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
329app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User330// BLOCK Q2 — throttle magic-link sign-in for the same reason.
331app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude332
59b6fb2Claude333// CSRF protection — set token on all requests, validate on mutations
334app.use("*", csrfToken);
335app.use("*", csrfProtect);
336
45e31d0Claude337// Rate limit auth routes
338app.use("/login", authRateLimit);
339app.use("/register", authRateLimit);
340
59b6fb2Claude341// Rate limit git operations
342app.use("/:owner/:repo.git/*", gitRateLimit);
343
344// Rate limit search
345app.use("/:owner/:repo/search", searchRateLimit);
346app.use("/explore", searchRateLimit);
79136bbClaude347
f5b9ef5Claude348// No-cache for HTML — ensures browsers and proxies never serve stale pages.
349// The middleware only stamps text/html responses so static assets keep
350// their own cache policies unchanged.
351app.use("*", noCache);
352
79136bbClaude353// Git Smart HTTP protocol routes (must be before web routes)
354app.route("/", gitRoutes);
355
45e31d0Claude356// REST API v1 (legacy)
79136bbClaude357app.route("/", apiRoutes);
358
52ad8b1Claude359// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
360// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
361// router's catch-shape, and BEFORE adminRoutes so the live /demo page
362// wins over the legacy /demo redirect in src/routes/admin.tsx.
363app.route("/", demoRoutes);
364
0316dbbClaude365// REST API v2 (basePath /api/v2)
366app.route("/", apiV2Routes);
367
e75eddcClaude368// Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage).
369// Mounted alongside apiV2Routes (its own basePath, no path conflict).
370app.route("/", agentsRoutes);
371
ad6d4adClaude372// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
373app.route("/", hookRoutes);
21f8dbdClaude374app.route("/api/events", eventsRoutes);
ad6d4adClaude375
45e31d0Claude376// API documentation
377app.route("/", apiDocsRoutes);
4a80519Claude378app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude379// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
380app.route("/", pullsDashboardRoutes);
e9aa4d8Claude381// Issue command center — global issue dashboard with AI-triage + autopilot signal
382app.route("/", issuesDashboardRoutes);
383// Personal activity timeline — every event across the user's repos, with
384// AI-driven events surfaced separately (the Gluecron differentiator).
385app.route("/", activityRoutes);
386// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
387app.route("/", inboxRoutes);
56801e1Claude388// AI standup feed — daily / weekly Claude-generated team brief
389app.route("/", standupRoutes);
79136bbClaude390
391// Auth routes (register, login, logout)
392app.route("/", authRoutes);
393
c63b860Claude394// BLOCK P1 — Password reset (forgot-password + reset-password)
395app.route("/", passwordResetRoutes);
396
397// BLOCK P2 — Email verification (verify-email + resend)
398app.route("/", emailVerificationRoutes);
399
cd4f63bTest User400// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
401app.route("/", magicLinkRoutes);
402
79136bbClaude403// Settings routes (profile, SSH keys)
404app.route("/", settingsRoutes);
405
7298a17Claude406// 2FA / TOTP settings (Block B4)
407app.route("/", settings2faRoutes);
408
e75eddcClaude409// Agent multiplayer — /settings/agents management UI
410app.route("/", settingsAgentsRoutes);
411
1d4ff60Claude412// Chat integrations — Slack / Discord / Teams (/settings/integrations
413// + /api/v2/integrations/{slack,discord}/*). See src/lib/chat-bot.ts.
414app.route("/", settingsIntegrationsRoutes);
415app.route("/", integrationsChatRoutes);
416
2df1f8cClaude417// WebAuthn / passkey routes (Block B5)
418app.route("/", passkeyRoutes);
419
058d752Claude420// OAuth 2.0 provider (Block B6)
421app.route("/", oauthRoutes);
422app.route("/", developerAppsRoutes);
423
6fc53bdClaude424// Theme toggle (dark/light cookie)
425app.route("/", themeRoutes);
426
427// Audit log UI
428app.route("/", auditRoutes);
429
430// Reactions API (issues, PRs, comments)
431app.route("/", reactionRoutes);
432
24cf2caClaude433// Saved replies (per-user canned comment templates)
434app.route("/", savedReplyRoutes);
435
436// Environments + deployment history UI
437app.route("/", deploymentRoutes);
438
6563f0aClaude439// Organizations + teams (Block B1)
440app.route("/", orgRoutes);
441
c81ab7aClaude442// API tokens
443app.route("/", tokenRoutes);
444
59b6fb2Claude445// Notifications
3ef4c9dClaude446app.route("/", notificationRoutes);
447
79136bbClaude448// Repo settings (description, visibility, delete)
449app.route("/", repoSettings);
450
23d1a81Claude451// Repo collaborators (add/list/remove)
452app.route("/", collaboratorRoutes);
453
04f6b7fClaude454// Team-based repo collaborators (invite a whole team)
455app.route("/", teamCollaboratorRoutes);
456
457// Collaborator invite accept flow (token-based)
458app.route("/", invitesRoutes);
459
460// Real-time SSE endpoint (topic-based live updates)
461app.route("/", liveEventsRoutes);
462
3c03977Claude463// PR live co-editing — presence + cursors + content sync via SSE.
464app.route("/", prLiveRoutes);
465
c81ab7aClaude466// Webhooks management
467app.route("/", webhookRoutes);
468
79136bbClaude469// Compare view (branch diffs)
470app.route("/", compareRoutes);
471
472// Issue tracker
473app.route("/", issueRoutes);
474
cb5a796Claude475// Comment moderation queue — owner-only `/:owner/:repo/comments/pending`
476// + per-row approve/reject/spam actions. Mounted before `pullRoutes` so
477// the `/:owner/:repo/comments/*` paths resolve before the broader PR
478// patterns kick in.
479app.route("/", commentModerationRoutes);
480
0074234Claude481// Pull requests
482app.route("/", pullRoutes);
79ed944Claude483// PR sandboxes — runnable per-PR environments. Migration 0067.
484app.route("/", prSandboxRoutes);
0074234Claude485
9b3a183Claude486// Cloud dev environments — hosted VS Code in the browser. Migration 0072.
487app.route("/", devEnvRoutes);
488
c81ab7aClaude489// Fork
490app.route("/", forkRoutes);
491
0074234Claude492// Web file editor
493app.route("/", editorRoutes);
494
43de941Claude495// Contributors
496app.route("/", contributorRoutes);
497
699e5c7Claude498// Health liveness + metrics endpoints
2c34075Claude499app.route("/", healthRoutes);
500
f295f78Dictation App501// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
502app.route("/api/platform-status", platformStatus);
503
52ad8b1Claude504// Block L4 — Public stats counters (powers landing-page social proof)
505app.route("/", publicStatsRoutes);
506
507// Block L3 — Live /demo page + /api/v2/demo/* endpoints
508app.route("/", demoRoutes);
509
2316be6Claude510// Public /status — human-readable platform health page
511app.route("/", statusRoutes);
512
b1be050CC LABS App513// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
514// Mounted near the public status route so the two surfaces are visible
515// side-by-side; routes are gated by isSiteAdmin internally.
516app.route("/", adminStatusRoutes);
517
80bed05Claude518// /help — quickstart + API cheatsheet
519app.route("/", helpRoutes);
520
5f2e749Claude521// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
522// so the new editorial pricing layout wins the route; the legacy marketing
523// pricing remains as a safety net but is shadowed at the router.
524app.route("/", pricingRoutes);
525
b0148e9Claude526// /pricing, /features, /about — marketing surface
527app.route("/", marketingRoutes);
528
5618f9aClaude529// SEO: robots.txt + sitemap.xml
530app.route("/", seoRoutes);
531
05cdb85Claude532// /api/version — live build SHA + uptime; client poller uses this to
533// surface 'New version available — reload' banners on deploy.
534app.route("/", versionRoutes);
535
699e5c7Claude536// Health dashboard (per-repo health page)
537app.route("/", healthDashboardRoutes);
538
9dd96b9Test User539// Block R1 — site-admin operations console. MUST be mounted BEFORE
540// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
541// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
542app.route("/", adminOpsRoutes);
f2c00b4CC LABS App543// BLOCK W — Self-host status + bootstrap dashboard.
544app.route("/", adminSelfHostRoutes);
826eccfTest User545// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
546app.route("/", adminDiagnoseRoutes);
9dd96b9Test User547
16b325cClaude548// Insights (time-travel, dependencies, rollback)
549app.route("/", insightRoutes);
550
8d1483cClaude551// DORA metrics page (/:owner/:repo/insights/dora)
552app.route("/", doraRoutes);
553
f1ab587Claude554// Command center dashboard
555app.route("/", dashboardRoutes);
556
36b4cbdClaude557// Legal pages (terms, privacy, AUP)
558app.route("/", legalRoutes);
4b66018Claude559// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
560// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
561// /acceptable-use); these are the formal versions that the legal pages
562// internally link to each other.
563app.route("/", legalTermsRoutes);
564app.route("/", legalPrivacyRoutes);
565app.route("/", legalAcceptableUseRoutes);
566app.route("/", legalDmcaRoutes);
36b4cbdClaude567
bdbd0deClaude568// GitHub import / migration
569app.route("/", importRoutes);
14c3cc8Claude570app.route("/", importBulkRoutes);
f390cfaCC LABS App571app.route("/", importSecretsRoutes);
14c3cc8Claude572app.route("/", migrationRoutes);
573
574// Spec-to-PR (experimental AI-generated draft PRs)
575app.route("/", specsRoutes);
23d0abfClaude576app.route("/", refactorRoutes);
bdbd0deClaude577
c81ab7aClaude578// Explore page
579app.route("/", exploreRoutes);
580
59b6fb2Claude581// Onboarding
582app.route("/", onboardingRoutes);
583
0316dbbClaude584// Admin + feature routes
585app.route("/", adminRoutes);
509c376Claude586app.route("/", adminIntegrationsRoutes);
79ed944Claude587app.route("/", adminAdvancementRoutes);
f764c07Claude588app.route("/", adminDeploysRoutes);
589app.route("/", adminDeploysPageRoutes);
783dd46Claude590app.route("/", adminServerTargetsRoutes);
90c7531Claude591app.route("/", claudeWebRoutes);
9dd96b9Test User592// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude593app.route("/", advisoriesRoutes);
594app.route("/", aiChangelogRoutes);
595app.route("/", aiExplainRoutes);
596app.route("/", aiTestsRoutes);
597app.route("/", askRoutes);
38d31d3Claude598app.route("/", repoChatRoutes);
ee7e577Claude599// Personal cross-repo chat — `/chat` (user-scoped). Mounted alongside
600// repoChatRoutes so the two surfaces share the catch-all priority.
601app.route("/", personalChatRoutes);
0316dbbClaude602app.route("/", billingRoutes);
8809b87Claude603app.route("/", billingUsageRoutes);
6778ad2Claude604app.route("/", stripeWebhookRoutes);
0316dbbClaude605app.route("/", codeScanningRoutes);
606app.route("/", commitStatusesRoutes);
607app.route("/", copilotRoutes);
608app.route("/", depUpdaterRoutes);
609app.route("/", depsRoutes);
610app.route("/", discussionsRoutes);
611app.route("/", environmentsRoutes);
4bbacbeClaude612app.route("/", previewsRoutes);
79ed944Claude613app.route("/", docsTrackingRoutes);
0316dbbClaude614app.route("/", followsRoutes);
615app.route("/", gatesRoutes);
616app.route("/", gistsRoutes);
617app.route("/", graphqlRoutes);
2c2163eClaude618app.route("/", mcpRoutes);
0316dbbClaude619app.route("/", marketplaceRoutes);
5ca514aClaude620app.route("/", marketplaceAgentsRoutes);
0316dbbClaude621app.route("/", mergeQueueRoutes);
622app.route("/", mirrorsRoutes);
623app.route("/", orgInsightsRoutes);
624app.route("/", packagesRoutes);
625app.route("/", packagesApiRoutes);
626app.route("/", pagesRoutes);
627app.route("/", projectsRoutes);
628app.route("/", protectedTagsRoutes);
629app.route("/", pwaRoutes);
46d6165Claude630app.route("/", installRoutes);
cd4f63bTest User631// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
632app.route("/", dxtRoutes);
662ce86Claude633// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
634// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
635app.route("/", connectClaudeRoutes);
f5b9ef5Claude636// Claude Code Integration Receiver — /api/claude/connect + /api/claude/session.
637app.route("/", claudeIntegration);
638// Connect guide — public onboarding page (/connect/claude-guide).
639app.route("/", connectRoutes);
05ab9b1Claude640// Push Watch — per-commit live status (gates + deploy + latency) at /:owner/:repo/push/:sha
641app.route("/", pushWatchRoutes);
642// Org Secrets Manager — BLOCK M2 — /orgs/:slug/settings/secrets
643app.route("/", orgSecretsRoutes);
a2b3e99Claude644// Cross-repo code search — BLOCK M3 — /search/code + /api/search/code
645app.route("/", crossRepoSearchRoutes);
646// Browser push notifications — BLOCK M4 — /settings/notifications/push + /api/push/*
647app.route("/", pushNotifRoutes);
9fbe6cdClaude648// Developer Velocity Dashboard — BLOCK M9 — /:owner/:repo/insights/velocity
649app.route("/", velocityRoutes);
650// Stale Branch Cleanup — BLOCK M10 — /:owner/:repo/branches/stale
651app.route("/", staleBranchRoutes);
22f43f3Claude652// Repository Pulse — BLOCK M12 — /:owner/:repo/pulse
653app.route("/", pulseRoutes);
74d8c4dClaude654// Repository Health Score — BLOCK M14 — /:owner/:repo/insights/health
655app.route("/", healthScoreRoutes);
656// Hot Files Heatmap — BLOCK M16 — /:owner/:repo/insights/hotfiles
657app.route("/", hotFilesRoutes);
ebbb527Claude658// Hosted Claude tool-use loops — paste loop, get endpoint, billing meter.
659// See src/routes/claude-deploy.tsx + src/lib/hosted-claude-loop.ts.
660app.route("/", claudeDeployRoutes);
0316dbbClaude661app.route("/", releasesRoutes);
662app.route("/", requiredChecksRoutes);
663app.route("/", rulesetsRoutes);
664app.route("/", searchRoutes);
665app.route("/", semanticSearchRoutes);
666app.route("/", signingKeysRoutes);
667app.route("/", sponsorsRoutes);
668app.route("/", ssoRoutes);
46d6165Claude669app.route("/", githubOauthRoutes);
582cdacClaude670app.route("/", googleOauthRoutes);
0316dbbClaude671app.route("/", symbolsRoutes);
672app.route("/", templatesRoutes);
673app.route("/", trafficRoutes);
674app.route("/", wikisRoutes);
675app.route("/", workflowsRoutes);
5ff9cc2Claude676app.route("/", workflowArtifactsRoutes);
677app.route("/", workflowSecretsRoutes);
46d6165Claude678app.route("/", sleepModeRoutes);
52ad8b1Claude679app.route("/", vsGithubRoutes);
0316dbbClaude680
45f3b73Claude681// Voice-to-PR — phone-first dictation → spec or issue
682app.route("/", voiceRoutes);
683
cd4f63bTest User684// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
685// before the web catch-all so the bare `/play` literal wins over the
686// `/:owner` user-profile route.
687app.route("/", playgroundRoutes);
688
79136bbClaude689// Web UI (catch-all, must be last)
690app.route("/", webRoutes);
691
c63b860Claude692// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
693// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude694app.notFound((c) => {
36cc17aClaude695 const user = c.get("user") ?? null;
79136bbClaude696 return c.html(
c63b860Claude697 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude698 404
699 );
700});
701
c63b860Claude702// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
703// view. Trace block only shown outside production.
79136bbClaude704app.onError((err, c) => {
80bed05Claude705 reportError(err, {
706 requestId: c.get("requestId"),
707 path: c.req.path,
708 method: c.req.method,
709 });
c63b860Claude710 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
711 // back to the context value set by request-context middleware.
712 const requestId =
713 c.req.header("x-request-id") ||
714 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude715 const user = c.get("user") ?? null;
c63b860Claude716 const trace =
717 process.env.NODE_ENV !== "production" && err && err.message
718 ? err.message
719 : undefined;
79136bbClaude720 return c.html(
c63b860Claude721 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude722 500
723 );
724});
725
726export default app;