Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesPull RequestsActionsSecurityInsightsSettings
✨ AI
More
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.tsxBlame679 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";
f1ab587Claude61import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude62import legalRoutes from "./routes/legal";
4b66018Claude63import legalDmcaRoutes from "./routes/legal/dmca";
64import legalTermsRoutes from "./routes/legal/terms";
65import legalPrivacyRoutes from "./routes/legal/privacy";
66import legalAcceptableUseRoutes from "./routes/legal/acceptable-use";
bdbd0deClaude67import importRoutes from "./routes/import";
14c3cc8Claude68import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App69import importSecretsRoutes from "./routes/import-secrets";
14c3cc8Claude70import migrationRoutes from "./routes/migrations";
71import specsRoutes from "./routes/specs";
23d0abfClaude72import refactorRoutes from "./routes/refactors";
79136bbClaude73import webRoutes from "./routes/web";
0316dbbClaude74import hookRoutes from "./routes/hooks";
75import eventsRoutes from "./routes/events";
76import passkeyRoutes from "./routes/passkeys";
77import oauthRoutes from "./routes/oauth";
78import developerAppsRoutes from "./routes/developer-apps";
79import themeRoutes from "./routes/theme";
80import auditRoutes from "./routes/audit";
81import reactionRoutes from "./routes/reactions";
82import savedReplyRoutes from "./routes/saved-replies";
83import deploymentRoutes from "./routes/deployments";
84import orgRoutes from "./routes/orgs";
85import notificationRoutes from "./routes/notifications";
86import onboardingRoutes from "./routes/onboarding";
87import adminRoutes from "./routes/admin";
f764c07Claude88import adminDeploysRoutes from "./routes/admin-deploys";
89import adminDeploysPageRoutes from "./routes/admin-deploys-page";
9dd96b9Test User90import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App91import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User92import adminDiagnoseRoutes from "./routes/admin-diagnose";
509c376Claude93import adminIntegrationsRoutes from "./routes/admin-integrations";
79ed944Claude94import adminAdvancementRoutes from "./routes/admin-advancement";
0316dbbClaude95import advisoriesRoutes from "./routes/advisories";
96import aiChangelogRoutes from "./routes/ai-changelog";
97import aiExplainRoutes from "./routes/ai-explain";
98import aiTestsRoutes from "./routes/ai-tests";
99import askRoutes from "./routes/ask";
38d31d3Claude100import repoChatRoutes from "./routes/repo-chat";
ee7e577Claude101import personalChatRoutes from "./routes/personal-chat";
0316dbbClaude102import billingRoutes from "./routes/billing";
8809b87Claude103import billingUsageRoutes from "./routes/billing-usage";
6778ad2Claude104import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude105import codeScanningRoutes from "./routes/code-scanning";
106import commitStatusesRoutes from "./routes/commit-statuses";
107import copilotRoutes from "./routes/copilot";
108import depUpdaterRoutes from "./routes/dep-updater";
109import depsRoutes from "./routes/deps";
110import discussionsRoutes from "./routes/discussions";
111import environmentsRoutes from "./routes/environments";
4bbacbeClaude112import previewsRoutes from "./routes/previews";
79ed944Claude113import docsTrackingRoutes from "./routes/docs-tracking";
0316dbbClaude114import followsRoutes from "./routes/follows";
115import gatesRoutes from "./routes/gates";
116import gistsRoutes from "./routes/gists";
117import graphqlRoutes from "./routes/graphql";
2c2163eClaude118import mcpRoutes from "./routes/mcp";
0316dbbClaude119import marketplaceRoutes from "./routes/marketplace";
5ca514aClaude120import marketplaceAgentsRoutes from "./routes/marketplace-agents";
0316dbbClaude121import mergeQueueRoutes from "./routes/merge-queue";
122import mirrorsRoutes from "./routes/mirrors";
123import orgInsightsRoutes from "./routes/org-insights";
124import packagesRoutes from "./routes/packages";
125import packagesApiRoutes from "./routes/packages-api";
126import pagesRoutes from "./routes/pages";
127import projectsRoutes from "./routes/projects";
128import protectedTagsRoutes from "./routes/protected-tags";
129import pwaRoutes from "./routes/pwa";
46d6165Claude130import installRoutes from "./routes/install";
cd4f63bTest User131import dxtRoutes from "./routes/dxt";
662ce86Claude132import connectClaudeRoutes from "./routes/connect-claude";
ebbb527Claude133import claudeDeployRoutes from "./routes/claude-deploy";
0316dbbClaude134import releasesRoutes from "./routes/releases";
135import requiredChecksRoutes from "./routes/required-checks";
136import rulesetsRoutes from "./routes/rulesets";
137import searchRoutes from "./routes/search";
138import semanticSearchRoutes from "./routes/semantic-search";
139import signingKeysRoutes from "./routes/signing-keys";
140import sponsorsRoutes from "./routes/sponsors";
141import ssoRoutes from "./routes/sso";
46d6165Claude142import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude143import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude144import symbolsRoutes from "./routes/symbols";
145import templatesRoutes from "./routes/templates";
146import trafficRoutes from "./routes/traffic";
147import wikisRoutes from "./routes/wikis";
148import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude149import workflowArtifactsRoutes from "./routes/workflow-artifacts";
150import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude151import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude152import standupRoutes from "./routes/standups";
52ad8b1Claude153import vsGithubRoutes from "./routes/vs-github";
45f3b73Claude154import voiceRoutes from "./routes/voice-to-pr";
cd4f63bTest User155import playgroundRoutes from "./routes/playground";
59b6fb2Claude156import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
157import { csrfToken, csrfProtect } from "./middleware/csrf";
79136bbClaude158
2316901Claude159import type { AuthEnv } from "./middleware/auth";
bf19c50Test User160import { softAuth } from "./middleware/auth";
2316901Claude161
162const app = new Hono<AuthEnv>();
79136bbClaude163
3ef4c9dClaude164// Request context (request ID, start time) runs before everything else
165app.use("*", requestContext);
05b973eClaude166// Middleware — compression first (wraps all responses)
167app.use("*", compress());
f1ffd50Claude168
169// ETag middleware — returns 304 Not Modified on unchanged responses.
170// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
171// SSE + the API surface where it would interfere with streaming.
172app.use("*", async (c, next) => {
173 const p = c.req.path;
174 if (
175 p.includes(".git/") ||
176 p.startsWith("/live-events") ||
177 p.startsWith("/api/events/deploy") ||
3c03977Claude178 p.startsWith("/admin/status") ||
179 // PR live co-editing SSE stream — never etag streaming responses.
180 /^\/api\/v2\/pulls\/[^/]+\/live(\/|$)/.test(p)
f1ffd50Claude181 ) {
182 return next();
183 }
184 return etag()(c, next);
185});
186
187// Cache-Control middleware — sets sensible defaults on public, anonymous
188// requests. Crontech (when wired as our edge layer) and downstream
189// browsers will honor these. Auth'd users get private,no-store
190// automatically — we never cache responses tied to a session.
191app.use("*", async (c, next) => {
192 await next();
193 // Don't overwrite explicit headers set by route handlers — BUT the
194 // ETag middleware unconditionally sets "private, no-cache, must-
195 // revalidate" so we have to treat that specific value as "no
196 // policy chosen yet" and apply ours. Any route that explicitly set
197 // a different cache-control wins.
198 const existing = c.res.headers.get("cache-control");
199 const etagDefault =
200 existing === "private, no-cache, must-revalidate" ||
201 existing === "no-cache";
202 if (existing && !etagDefault) return;
203 // Anything past auth: private + no-store (avoid leaking session
204 // content into shared caches). softAuth runs before this on the
205 // request, but the response side is what we're stamping.
206 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
207 const p = c.req.path;
208 // Always private for known-authed paths regardless of cookie.
209 if (
210 p.startsWith("/admin") ||
211 p.startsWith("/settings") ||
212 p.startsWith("/dashboard") ||
213 p.startsWith("/notifications") ||
214 p.startsWith("/connect/") ||
215 hasSession
216 ) {
217 c.res.headers.set("cache-control", "private, no-store");
218 return;
219 }
220 // Public marketing surfaces — short edge cache, longer browser cache,
221 // stale-while-revalidate so the user never waits on a stale fetch.
222 const isMarketing =
223 p === "/" ||
224 p === "/features" ||
225 p === "/pricing" ||
226 p === "/about" ||
227 p === "/vs-github" ||
228 p === "/explore" ||
229 p === "/help" ||
230 p === "/changelog" ||
231 p.startsWith("/legal/") ||
232 p === "/terms" ||
233 p === "/privacy" ||
234 p === "/acceptable-use" ||
235 p.startsWith("/docs/");
236 if (isMarketing) {
237 c.res.headers.set(
238 "cache-control",
239 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
240 );
241 return;
242 }
243 // Public repo browse pages — cache aggressively. Edge invalidates
244 // on push via the post-receive hook (future Crontech surge purge).
245 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
246 c.res.headers.set(
247 "cache-control",
248 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
249 );
250 return;
251 }
252 // Default: don't cache anything we haven't explicitly opted in.
253 c.res.headers.set("cache-control", "private, no-store");
254});
05b973eClaude255// Logger only on non-git routes to avoid overhead on clone/push
256app.use("*", async (c, next) => {
257 if (c.req.path.includes(".git/")) return next();
258 return logger()(c, next);
259});
79136bbClaude260app.use("/api/*", cors());
bf19c50Test User261// Global softAuth — populates c.get("user") for every downstream middleware
262// + route. This was previously per-route, which meant rate-limit middleware
263// (and anything else inspecting auth state) always saw a null user. Keep
264// individual routes free to add requireAuth on top for hard gating; this
265// just establishes the user object cheaply.
266app.use("*", softAuth);
290ea77Claude267
36cc17aClaude268// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude269// pre-redesign markup. JSON / static assets keep their own cache rules; only
270// text/html responses get the no-cache stamp. Without this, every push to
271// main left users staring at cached 80s-looking pages from before the design
272// landed.
36cc17aClaude273//
274// We deliberately use `private, no-cache, must-revalidate` rather than
275// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
276// which makes every Back/Forward press a cold server round-trip — that
277// contributed to the "every nav feels like a fresh login" UX complaint.
278// `no-cache` still revalidates on direct fetch but lets bfcache hold the
279// page in memory between navigations.
290ea77Claude280app.use("*", async (c, next) => {
281 await next();
282 const ct = c.res.headers.get("content-type") || "";
283 if (ct.startsWith("text/html")) {
36cc17aClaude284 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude285 }
286});
826eccfTest User287// Rate-limit API + auth endpoints.
288//
a41e675Test User289// `/api/*`: 1000/min per IP — generous so an admin clicking around the
290// operator console (or a CDN/proxy concentrating multiple users behind one
291// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
292// rate limits below, not this one.
293//
294// `authedMultiplier` is set but only fires when an upstream middleware has
295// already populated c.get("user") — most app.use() chains apply softAuth
296// per-route, so the multiplier is best-effort. Keep the anonymous base
297// high enough that humans never feel it.
298//
299// Skip-paths: dashboard plumbing endpoints that the layout polls on a
300// fixed cadence and that we don't want consuming any bucket:
301// /api/version — layout polls every 15s
826eccfTest User302// /api/notifications/count — nav bell unread-count fetcher
303// /pwa/vapid-public-key — fetched once per push-notification opt-in
304app.use(
305 "/api/*",
a41e675Test User306 rateLimit(1000, 60_000, "api", {
826eccfTest User307 authedMultiplier: 4,
308 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
309 })
310);
0316dbbClaude311app.use("/login", rateLimit(20, 60_000, "login"));
312app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude313// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
314app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User315// BLOCK Q2 — throttle magic-link sign-in for the same reason.
316app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude317
59b6fb2Claude318// CSRF protection — set token on all requests, validate on mutations
319app.use("*", csrfToken);
320app.use("*", csrfProtect);
321
45e31d0Claude322// Rate limit auth routes
323app.use("/login", authRateLimit);
324app.use("/register", authRateLimit);
325
59b6fb2Claude326// Rate limit git operations
327app.use("/:owner/:repo.git/*", gitRateLimit);
328
329// Rate limit search
330app.use("/:owner/:repo/search", searchRateLimit);
331app.use("/explore", searchRateLimit);
79136bbClaude332
333// Git Smart HTTP protocol routes (must be before web routes)
334app.route("/", gitRoutes);
335
45e31d0Claude336// REST API v1 (legacy)
79136bbClaude337app.route("/", apiRoutes);
338
52ad8b1Claude339// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
340// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
341// router's catch-shape, and BEFORE adminRoutes so the live /demo page
342// wins over the legacy /demo redirect in src/routes/admin.tsx.
343app.route("/", demoRoutes);
344
0316dbbClaude345// REST API v2 (basePath /api/v2)
346app.route("/", apiV2Routes);
347
e75eddcClaude348// Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage).
349// Mounted alongside apiV2Routes (its own basePath, no path conflict).
350app.route("/", agentsRoutes);
351
ad6d4adClaude352// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
353app.route("/", hookRoutes);
21f8dbdClaude354app.route("/api/events", eventsRoutes);
ad6d4adClaude355
45e31d0Claude356// API documentation
357app.route("/", apiDocsRoutes);
4a80519Claude358app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude359// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
360app.route("/", pullsDashboardRoutes);
e9aa4d8Claude361// Issue command center — global issue dashboard with AI-triage + autopilot signal
362app.route("/", issuesDashboardRoutes);
363// Personal activity timeline — every event across the user's repos, with
364// AI-driven events surfaced separately (the Gluecron differentiator).
365app.route("/", activityRoutes);
366// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
367app.route("/", inboxRoutes);
56801e1Claude368// AI standup feed — daily / weekly Claude-generated team brief
369app.route("/", standupRoutes);
79136bbClaude370
371// Auth routes (register, login, logout)
372app.route("/", authRoutes);
373
c63b860Claude374// BLOCK P1 — Password reset (forgot-password + reset-password)
375app.route("/", passwordResetRoutes);
376
377// BLOCK P2 — Email verification (verify-email + resend)
378app.route("/", emailVerificationRoutes);
379
cd4f63bTest User380// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
381app.route("/", magicLinkRoutes);
382
79136bbClaude383// Settings routes (profile, SSH keys)
384app.route("/", settingsRoutes);
385
7298a17Claude386// 2FA / TOTP settings (Block B4)
387app.route("/", settings2faRoutes);
388
e75eddcClaude389// Agent multiplayer — /settings/agents management UI
390app.route("/", settingsAgentsRoutes);
391
1d4ff60Claude392// Chat integrations — Slack / Discord / Teams (/settings/integrations
393// + /api/v2/integrations/{slack,discord}/*). See src/lib/chat-bot.ts.
394app.route("/", settingsIntegrationsRoutes);
395app.route("/", integrationsChatRoutes);
396
2df1f8cClaude397// WebAuthn / passkey routes (Block B5)
398app.route("/", passkeyRoutes);
399
058d752Claude400// OAuth 2.0 provider (Block B6)
401app.route("/", oauthRoutes);
402app.route("/", developerAppsRoutes);
403
6fc53bdClaude404// Theme toggle (dark/light cookie)
405app.route("/", themeRoutes);
406
407// Audit log UI
408app.route("/", auditRoutes);
409
410// Reactions API (issues, PRs, comments)
411app.route("/", reactionRoutes);
412
24cf2caClaude413// Saved replies (per-user canned comment templates)
414app.route("/", savedReplyRoutes);
415
416// Environments + deployment history UI
417app.route("/", deploymentRoutes);
418
6563f0aClaude419// Organizations + teams (Block B1)
420app.route("/", orgRoutes);
421
c81ab7aClaude422// API tokens
423app.route("/", tokenRoutes);
424
59b6fb2Claude425// Notifications
3ef4c9dClaude426app.route("/", notificationRoutes);
427
79136bbClaude428// Repo settings (description, visibility, delete)
429app.route("/", repoSettings);
430
23d1a81Claude431// Repo collaborators (add/list/remove)
432app.route("/", collaboratorRoutes);
433
04f6b7fClaude434// Team-based repo collaborators (invite a whole team)
435app.route("/", teamCollaboratorRoutes);
436
437// Collaborator invite accept flow (token-based)
438app.route("/", invitesRoutes);
439
440// Real-time SSE endpoint (topic-based live updates)
441app.route("/", liveEventsRoutes);
442
3c03977Claude443// PR live co-editing — presence + cursors + content sync via SSE.
444app.route("/", prLiveRoutes);
445
c81ab7aClaude446// Webhooks management
447app.route("/", webhookRoutes);
448
79136bbClaude449// Compare view (branch diffs)
450app.route("/", compareRoutes);
451
452// Issue tracker
453app.route("/", issueRoutes);
454
cb5a796Claude455// Comment moderation queue — owner-only `/:owner/:repo/comments/pending`
456// + per-row approve/reject/spam actions. Mounted before `pullRoutes` so
457// the `/:owner/:repo/comments/*` paths resolve before the broader PR
458// patterns kick in.
459app.route("/", commentModerationRoutes);
460
0074234Claude461// Pull requests
462app.route("/", pullRoutes);
79ed944Claude463// PR sandboxes — runnable per-PR environments. Migration 0067.
464app.route("/", prSandboxRoutes);
0074234Claude465
9b3a183Claude466// Cloud dev environments — hosted VS Code in the browser. Migration 0072.
467app.route("/", devEnvRoutes);
468
c81ab7aClaude469// Fork
470app.route("/", forkRoutes);
471
0074234Claude472// Web file editor
473app.route("/", editorRoutes);
474
43de941Claude475// Contributors
476app.route("/", contributorRoutes);
477
699e5c7Claude478// Health liveness + metrics endpoints
2c34075Claude479app.route("/", healthRoutes);
480
f295f78Dictation App481// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
482app.route("/api/platform-status", platformStatus);
483
52ad8b1Claude484// Block L4 — Public stats counters (powers landing-page social proof)
485app.route("/", publicStatsRoutes);
486
487// Block L3 — Live /demo page + /api/v2/demo/* endpoints
488app.route("/", demoRoutes);
489
2316be6Claude490// Public /status — human-readable platform health page
491app.route("/", statusRoutes);
492
b1be050CC LABS App493// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
494// Mounted near the public status route so the two surfaces are visible
495// side-by-side; routes are gated by isSiteAdmin internally.
496app.route("/", adminStatusRoutes);
497
80bed05Claude498// /help — quickstart + API cheatsheet
499app.route("/", helpRoutes);
500
5f2e749Claude501// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
502// so the new editorial pricing layout wins the route; the legacy marketing
503// pricing remains as a safety net but is shadowed at the router.
504app.route("/", pricingRoutes);
505
b0148e9Claude506// /pricing, /features, /about — marketing surface
507app.route("/", marketingRoutes);
508
5618f9aClaude509// SEO: robots.txt + sitemap.xml
510app.route("/", seoRoutes);
511
05cdb85Claude512// /api/version — live build SHA + uptime; client poller uses this to
513// surface 'New version available — reload' banners on deploy.
514app.route("/", versionRoutes);
515
699e5c7Claude516// Health dashboard (per-repo health page)
517app.route("/", healthDashboardRoutes);
518
9dd96b9Test User519// Block R1 — site-admin operations console. MUST be mounted BEFORE
520// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
521// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
522app.route("/", adminOpsRoutes);
f2c00b4CC LABS App523// BLOCK W — Self-host status + bootstrap dashboard.
524app.route("/", adminSelfHostRoutes);
826eccfTest User525// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
526app.route("/", adminDiagnoseRoutes);
9dd96b9Test User527
16b325cClaude528// Insights (time-travel, dependencies, rollback)
529app.route("/", insightRoutes);
530
f1ab587Claude531// Command center dashboard
532app.route("/", dashboardRoutes);
533
36b4cbdClaude534// Legal pages (terms, privacy, AUP)
535app.route("/", legalRoutes);
4b66018Claude536// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
537// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
538// /acceptable-use); these are the formal versions that the legal pages
539// internally link to each other.
540app.route("/", legalTermsRoutes);
541app.route("/", legalPrivacyRoutes);
542app.route("/", legalAcceptableUseRoutes);
543app.route("/", legalDmcaRoutes);
36b4cbdClaude544
bdbd0deClaude545// GitHub import / migration
546app.route("/", importRoutes);
14c3cc8Claude547app.route("/", importBulkRoutes);
f390cfaCC LABS App548app.route("/", importSecretsRoutes);
14c3cc8Claude549app.route("/", migrationRoutes);
550
551// Spec-to-PR (experimental AI-generated draft PRs)
552app.route("/", specsRoutes);
23d0abfClaude553app.route("/", refactorRoutes);
bdbd0deClaude554
c81ab7aClaude555// Explore page
556app.route("/", exploreRoutes);
557
59b6fb2Claude558// Onboarding
559app.route("/", onboardingRoutes);
560
0316dbbClaude561// Admin + feature routes
562app.route("/", adminRoutes);
509c376Claude563app.route("/", adminIntegrationsRoutes);
79ed944Claude564app.route("/", adminAdvancementRoutes);
f764c07Claude565app.route("/", adminDeploysRoutes);
566app.route("/", adminDeploysPageRoutes);
9dd96b9Test User567// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude568app.route("/", advisoriesRoutes);
569app.route("/", aiChangelogRoutes);
570app.route("/", aiExplainRoutes);
571app.route("/", aiTestsRoutes);
572app.route("/", askRoutes);
38d31d3Claude573app.route("/", repoChatRoutes);
ee7e577Claude574// Personal cross-repo chat — `/chat` (user-scoped). Mounted alongside
575// repoChatRoutes so the two surfaces share the catch-all priority.
576app.route("/", personalChatRoutes);
0316dbbClaude577app.route("/", billingRoutes);
8809b87Claude578app.route("/", billingUsageRoutes);
6778ad2Claude579app.route("/", stripeWebhookRoutes);
0316dbbClaude580app.route("/", codeScanningRoutes);
581app.route("/", commitStatusesRoutes);
582app.route("/", copilotRoutes);
583app.route("/", depUpdaterRoutes);
584app.route("/", depsRoutes);
585app.route("/", discussionsRoutes);
586app.route("/", environmentsRoutes);
4bbacbeClaude587app.route("/", previewsRoutes);
79ed944Claude588app.route("/", docsTrackingRoutes);
0316dbbClaude589app.route("/", followsRoutes);
590app.route("/", gatesRoutes);
591app.route("/", gistsRoutes);
592app.route("/", graphqlRoutes);
2c2163eClaude593app.route("/", mcpRoutes);
0316dbbClaude594app.route("/", marketplaceRoutes);
5ca514aClaude595app.route("/", marketplaceAgentsRoutes);
0316dbbClaude596app.route("/", mergeQueueRoutes);
597app.route("/", mirrorsRoutes);
598app.route("/", orgInsightsRoutes);
599app.route("/", packagesRoutes);
600app.route("/", packagesApiRoutes);
601app.route("/", pagesRoutes);
602app.route("/", projectsRoutes);
603app.route("/", protectedTagsRoutes);
604app.route("/", pwaRoutes);
46d6165Claude605app.route("/", installRoutes);
cd4f63bTest User606// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
607app.route("/", dxtRoutes);
662ce86Claude608// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
609// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
610app.route("/", connectClaudeRoutes);
ebbb527Claude611// Hosted Claude tool-use loops — paste loop, get endpoint, billing meter.
612// See src/routes/claude-deploy.tsx + src/lib/hosted-claude-loop.ts.
613app.route("/", claudeDeployRoutes);
0316dbbClaude614app.route("/", releasesRoutes);
615app.route("/", requiredChecksRoutes);
616app.route("/", rulesetsRoutes);
617app.route("/", searchRoutes);
618app.route("/", semanticSearchRoutes);
619app.route("/", signingKeysRoutes);
620app.route("/", sponsorsRoutes);
621app.route("/", ssoRoutes);
46d6165Claude622app.route("/", githubOauthRoutes);
582cdacClaude623app.route("/", googleOauthRoutes);
0316dbbClaude624app.route("/", symbolsRoutes);
625app.route("/", templatesRoutes);
626app.route("/", trafficRoutes);
627app.route("/", wikisRoutes);
628app.route("/", workflowsRoutes);
5ff9cc2Claude629app.route("/", workflowArtifactsRoutes);
630app.route("/", workflowSecretsRoutes);
46d6165Claude631app.route("/", sleepModeRoutes);
52ad8b1Claude632app.route("/", vsGithubRoutes);
0316dbbClaude633
45f3b73Claude634// Voice-to-PR — phone-first dictation → spec or issue
635app.route("/", voiceRoutes);
636
cd4f63bTest User637// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
638// before the web catch-all so the bare `/play` literal wins over the
639// `/:owner` user-profile route.
640app.route("/", playgroundRoutes);
641
79136bbClaude642// Web UI (catch-all, must be last)
643app.route("/", webRoutes);
644
c63b860Claude645// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
646// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude647app.notFound((c) => {
36cc17aClaude648 const user = c.get("user") ?? null;
79136bbClaude649 return c.html(
c63b860Claude650 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude651 404
652 );
653});
654
c63b860Claude655// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
656// view. Trace block only shown outside production.
79136bbClaude657app.onError((err, c) => {
80bed05Claude658 reportError(err, {
659 requestId: c.get("requestId"),
660 path: c.req.path,
661 method: c.req.method,
662 });
c63b860Claude663 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
664 // back to the context value set by request-context middleware.
665 const requestId =
666 c.req.header("x-request-id") ||
667 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude668 const user = c.get("user") ?? null;
c63b860Claude669 const trace =
670 process.env.NODE_ENV !== "production" && err && err.message
671 ? err.message
672 : undefined;
79136bbClaude673 return c.html(
c63b860Claude674 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude675 500
676 );
677});
678
679export default app;