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.tsxBlame908 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";
cc34156Claude19import digestRoutes from "./routes/digest";
e9aa4d8Claude20import activityRoutes from "./routes/activity";
79136bbClaude21import authRoutes from "./routes/auth";
c63b860Claude22import passwordResetRoutes from "./routes/password-reset";
23import emailVerificationRoutes from "./routes/email-verification";
cd4f63bTest User24import magicLinkRoutes from "./routes/magic-link";
79136bbClaude25import settingsRoutes from "./routes/settings";
7298a17Claude26import settings2faRoutes from "./routes/settings-2fa";
e75eddcClaude27import settingsAgentsRoutes from "./routes/settings-agents";
1d4ff60Claude28import settingsIntegrationsRoutes from "./routes/settings-integrations";
29import integrationsChatRoutes from "./routes/integrations-chat";
e75eddcClaude30import agentsRoutes from "./routes/agents";
ef3fd93Claude31import agentPipelinesRoutes from "./routes/agent-pipelines";
79136bbClaude32import issueRoutes from "./routes/issues";
85c4e13Claude33import milestonesRoutes from "./routes/milestones";
f928118Claude34import shipAgentRoutes from "./routes/ship-agent";
cb5a796Claude35import commentModerationRoutes from "./routes/comment-moderation";
79136bbClaude36import repoSettings from "./routes/repo-settings";
23d1a81Claude37import collaboratorRoutes from "./routes/collaborators";
04f6b7fClaude38import teamCollaboratorRoutes from "./routes/team-collaborators";
39import invitesRoutes from "./routes/invites";
40import liveEventsRoutes from "./routes/live-events";
3c03977Claude41import prLiveRoutes from "./routes/pr-live";
79136bbClaude42import compareRoutes from "./routes/compare";
0074234Claude43import pullRoutes from "./routes/pulls";
79ed944Claude44import prSandboxRoutes from "./routes/pr-sandbox";
9b3a183Claude45import devEnvRoutes from "./routes/dev-env";
0074234Claude46import editorRoutes from "./routes/editor";
6f2809fClaude47import aiEditorRoutes from "./routes/ai-editor";
c81ab7aClaude48import forkRoutes from "./routes/fork";
49import webhookRoutes from "./routes/webhooks";
50import exploreRoutes from "./routes/explore";
51import tokenRoutes from "./routes/tokens";
43de941Claude52import contributorRoutes from "./routes/contributors";
699e5c7Claude53import healthRoutes from "./routes/health-probe";
54import healthDashboardRoutes from "./routes/health";
2316be6Claude55import statusRoutes from "./routes/status";
b1be050CC LABS App56import adminStatusRoutes from "./routes/admin-status";
80bed05Claude57import helpRoutes from "./routes/help";
e1fc7dbClaude58import changelogRoutes from "./routes/changelog";
e0e4219Claude59import docsRoutes from "./routes/docs";
b0148e9Claude60import marketingRoutes from "./routes/marketing";
5f2e749Claude61import pricingRoutes from "./routes/pricing";
9f29b65Claude62import enterpriseRoutes from "./routes/enterprise";
5618f9aClaude63import seoRoutes from "./routes/seo";
05cdb85Claude64import versionRoutes from "./routes/version";
f295f78Dictation App65import { platformStatus } from "./routes/platform-status";
52ad8b1Claude66import publicStatsRoutes from "./routes/public-stats";
67import demoRoutes from "./routes/demo";
16b325cClaude68import insightRoutes from "./routes/insights";
8286942Claude69import engineeringInsightsRoutes from "./routes/engineering-insights";
8d1483cClaude70import doraRoutes from "./routes/dora";
f1ab587Claude71import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude72import legalRoutes from "./routes/legal";
4b66018Claude73import legalDmcaRoutes from "./routes/legal/dmca";
74import legalTermsRoutes from "./routes/legal/terms";
75import legalPrivacyRoutes from "./routes/legal/privacy";
76import legalAcceptableUseRoutes from "./routes/legal/acceptable-use";
bdbd0deClaude77import importRoutes from "./routes/import";
14c3cc8Claude78import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App79import importSecretsRoutes from "./routes/import-secrets";
bb2dea9Claude80import actionsImporterRoutes from "./routes/actions-importer";
14c3cc8Claude81import migrationRoutes from "./routes/migrations";
9a8b8deClaude82import migrateRoutes from "./routes/migrate";
14c3cc8Claude83import specsRoutes from "./routes/specs";
23d0abfClaude84import refactorRoutes from "./routes/refactors";
b665cacClaude85import codebaseMigratorRoutes from "./routes/codebase-migrator";
79136bbClaude86import webRoutes from "./routes/web";
0316dbbClaude87import hookRoutes from "./routes/hooks";
88import eventsRoutes from "./routes/events";
89import passkeyRoutes from "./routes/passkeys";
90import oauthRoutes from "./routes/oauth";
91import developerAppsRoutes from "./routes/developer-apps";
92import themeRoutes from "./routes/theme";
93import auditRoutes from "./routes/audit";
94import reactionRoutes from "./routes/reactions";
95import savedReplyRoutes from "./routes/saved-replies";
96import deploymentRoutes from "./routes/deployments";
97import orgRoutes from "./routes/orgs";
98import notificationRoutes from "./routes/notifications";
99import onboardingRoutes from "./routes/onboarding";
100import adminRoutes from "./routes/admin";
7293c67Claude101import adminDeletionsRoutes from "./routes/admin-deletions";
102import adminStripeRoutes from "./routes/admin-stripe";
f764c07Claude103import adminDeploysRoutes from "./routes/admin-deploys";
104import adminDeploysPageRoutes from "./routes/admin-deploys-page";
783dd46Claude105import adminServerTargetsRoutes from "./routes/admin-server-targets";
9aaa128Claude106import deployTargetsRoutes from "./routes/deploy-targets";
90c7531Claude107import claudeWebRoutes from "./routes/claude-web";
9dd96b9Test User108import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App109import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User110import adminDiagnoseRoutes from "./routes/admin-diagnose";
509c376Claude111import adminIntegrationsRoutes from "./routes/admin-integrations";
79ed944Claude112import adminAdvancementRoutes from "./routes/admin-advancement";
ba9e143Claude113import adminSecurityRoutes from "./routes/admin-security";
114import settingsSessionsRoutes from "./routes/settings-sessions";
0316dbbClaude115import advisoriesRoutes from "./routes/advisories";
116import aiChangelogRoutes from "./routes/ai-changelog";
0a69faaClaude117import explainRoutes from "./routes/explain";
0316dbbClaude118import aiExplainRoutes from "./routes/ai-explain";
119import aiTestsRoutes from "./routes/ai-tests";
120import askRoutes from "./routes/ask";
38d31d3Claude121import repoChatRoutes from "./routes/repo-chat";
ee7e577Claude122import personalChatRoutes from "./routes/personal-chat";
0316dbbClaude123import billingRoutes from "./routes/billing";
8809b87Claude124import billingUsageRoutes from "./routes/billing-usage";
6778ad2Claude125import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude126import codeScanningRoutes from "./routes/code-scanning";
da3fc18Claude127import securityRoutes from "./routes/security";
0316dbbClaude128import commitStatusesRoutes from "./routes/commit-statuses";
129import copilotRoutes from "./routes/copilot";
f5d020fClaude130import { pairProgrammerRoutes } from "./routes/pair-programmer";
0316dbbClaude131import depUpdaterRoutes from "./routes/dep-updater";
132import depsRoutes from "./routes/deps";
133import discussionsRoutes from "./routes/discussions";
134import environmentsRoutes from "./routes/environments";
4bbacbeClaude135import previewsRoutes from "./routes/previews";
79ed944Claude136import docsTrackingRoutes from "./routes/docs-tracking";
0316dbbClaude137import followsRoutes from "./routes/follows";
138import gatesRoutes from "./routes/gates";
139import gistsRoutes from "./routes/gists";
140import graphqlRoutes from "./routes/graphql";
2c2163eClaude141import mcpRoutes from "./routes/mcp";
0316dbbClaude142import marketplaceRoutes from "./routes/marketplace";
5ca514aClaude143import marketplaceAgentsRoutes from "./routes/marketplace-agents";
0316dbbClaude144import mergeQueueRoutes from "./routes/merge-queue";
145import mirrorsRoutes from "./routes/mirrors";
146import orgInsightsRoutes from "./routes/org-insights";
147import packagesRoutes from "./routes/packages";
148import packagesApiRoutes from "./routes/packages-api";
845fd8aClaude149import ociRegistryRoutes from "./routes/oci-registry";
0316dbbClaude150import pagesRoutes from "./routes/pages";
151import projectsRoutes from "./routes/projects";
152import protectedTagsRoutes from "./routes/protected-tags";
153import pwaRoutes from "./routes/pwa";
46d6165Claude154import installRoutes from "./routes/install";
cd4f63bTest User155import dxtRoutes from "./routes/dxt";
662ce86Claude156import connectClaudeRoutes from "./routes/connect-claude";
ebbb527Claude157import claudeDeployRoutes from "./routes/claude-deploy";
f5b9ef5Claude158import claudeIntegration from "./routes/claude-integration";
159import connectRoutes from "./routes/connect";
05ab9b1Claude160import pushWatchRoutes from "./routes/push-watch";
161import orgSecretsRoutes from "./routes/org-secrets";
0316dbbClaude162import releasesRoutes from "./routes/releases";
163import requiredChecksRoutes from "./routes/required-checks";
164import rulesetsRoutes from "./routes/rulesets";
165import searchRoutes from "./routes/search";
166import semanticSearchRoutes from "./routes/semantic-search";
77cf834Claude167import nlSearchRoutes from "./routes/nl-search";
0316dbbClaude168import signingKeysRoutes from "./routes/signing-keys";
169import sponsorsRoutes from "./routes/sponsors";
170import ssoRoutes from "./routes/sso";
3a845e4Claude171import samlSsoRoutes from "./routes/saml-sso";
172import scimRoutes from "./routes/scim";
173import orgSsoSettingsRoutes from "./routes/org-sso-settings";
46d6165Claude174import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude175import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude176import symbolsRoutes from "./routes/symbols";
177import templatesRoutes from "./routes/templates";
178import trafficRoutes from "./routes/traffic";
179import wikisRoutes from "./routes/wikis";
180import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude181import workflowArtifactsRoutes from "./routes/workflow-artifacts";
182import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude183import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude184import standupRoutes from "./routes/standups";
52ad8b1Claude185import vsGithubRoutes from "./routes/vs-github";
45f3b73Claude186import voiceRoutes from "./routes/voice-to-pr";
3122762Claude187import blogRoutes from "./routes/blog";
cd4f63bTest User188import playgroundRoutes from "./routes/playground";
a2b3e99Claude189import crossRepoSearchRoutes from "./routes/cross-repo-search";
190import pushNotifRoutes from "./routes/push-notifications";
9fbe6cdClaude191import velocityRoutes from "./routes/velocity";
192import { staleBranchRoutes } from "./routes/stale-branches";
22f43f3Claude193import pulseRoutes from "./routes/pulse";
74d8c4dClaude194import healthScoreRoutes from "./routes/health-score";
77cf834Claude195import repoHealthRoutes from "./routes/repo-health";
74d8c4dClaude196import hotFilesRoutes from "./routes/hot-files";
bcc4020Claude197import debtMapRoutes from "./routes/debt-map";
1d6db4dClaude198import busFactorRoutes from "./routes/bus-factor";
f5d020fClaude199import crossRepoImpactRoutes from "./routes/cross-repo-impact";
adf5e18Claude200import developerProgramRoutes from "./routes/developer-program";
891efbeClaude201import shareRoutes from "./routes/share";
70e3293Claude202import incidentHookRoutes from "./routes/incident-hooks";
77cf834Claude203import workspaceRoutes from "./routes/ai-workspace";
59b6fb2Claude204import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
205import { csrfToken, csrfProtect } from "./middleware/csrf";
f5b9ef5Claude206import { noCache } from "./middleware/no-cache";
79136bbClaude207
2316901Claude208import type { AuthEnv } from "./middleware/auth";
bf19c50Test User209import { softAuth } from "./middleware/auth";
2316901Claude210
211const app = new Hono<AuthEnv>();
79136bbClaude212
3ef4c9dClaude213// Request context (request ID, start time) runs before everything else
214app.use("*", requestContext);
05b973eClaude215// Middleware — compression first (wraps all responses)
216app.use("*", compress());
f1ffd50Claude217
218// ETag middleware — returns 304 Not Modified on unchanged responses.
219// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
220// SSE + the API surface where it would interfere with streaming.
221app.use("*", async (c, next) => {
222 const p = c.req.path;
223 if (
224 p.includes(".git/") ||
225 p.startsWith("/live-events") ||
226 p.startsWith("/api/events/deploy") ||
3c03977Claude227 p.startsWith("/admin/status") ||
228 // PR live co-editing SSE stream — never etag streaming responses.
229 /^\/api\/v2\/pulls\/[^/]+\/live(\/|$)/.test(p)
f1ffd50Claude230 ) {
231 return next();
232 }
233 return etag()(c, next);
234});
235
236// Cache-Control middleware — sets sensible defaults on public, anonymous
9ecf5a4Claude237// requests. Vapron (when wired as our edge layer) and downstream
f1ffd50Claude238// browsers will honor these. Auth'd users get private,no-store
239// automatically — we never cache responses tied to a session.
240app.use("*", async (c, next) => {
241 await next();
242 // Don't overwrite explicit headers set by route handlers — BUT the
243 // ETag middleware unconditionally sets "private, no-cache, must-
244 // revalidate" so we have to treat that specific value as "no
245 // policy chosen yet" and apply ours. Any route that explicitly set
246 // a different cache-control wins.
247 const existing = c.res.headers.get("cache-control");
248 const etagDefault =
249 existing === "private, no-cache, must-revalidate" ||
250 existing === "no-cache";
251 if (existing && !etagDefault) return;
252 // Anything past auth: private + no-store (avoid leaking session
253 // content into shared caches). softAuth runs before this on the
254 // request, but the response side is what we're stamping.
255 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
256 const p = c.req.path;
257 // Always private for known-authed paths regardless of cookie.
258 if (
259 p.startsWith("/admin") ||
260 p.startsWith("/settings") ||
261 p.startsWith("/dashboard") ||
262 p.startsWith("/notifications") ||
263 p.startsWith("/connect/") ||
264 hasSession
265 ) {
266 c.res.headers.set("cache-control", "private, no-store");
267 return;
268 }
269 // Public marketing surfaces — short edge cache, longer browser cache,
270 // stale-while-revalidate so the user never waits on a stale fetch.
271 const isMarketing =
272 p === "/" ||
273 p === "/features" ||
274 p === "/pricing" ||
275 p === "/about" ||
276 p === "/vs-github" ||
277 p === "/explore" ||
278 p === "/help" ||
279 p === "/changelog" ||
9f29b65Claude280 p === "/enterprise" ||
f1ffd50Claude281 p.startsWith("/legal/") ||
282 p === "/terms" ||
283 p === "/privacy" ||
284 p === "/acceptable-use" ||
285 p.startsWith("/docs/");
286 if (isMarketing) {
287 c.res.headers.set(
288 "cache-control",
289 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
290 );
291 return;
292 }
293 // Public repo browse pages — cache aggressively. Edge invalidates
9ecf5a4Claude294 // on push via the post-receive hook (future Vapron surge purge).
f1ffd50Claude295 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
296 c.res.headers.set(
297 "cache-control",
298 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
299 );
300 return;
301 }
302 // Default: don't cache anything we haven't explicitly opted in.
303 c.res.headers.set("cache-control", "private, no-store");
304});
05b973eClaude305// Logger only on non-git routes to avoid overhead on clone/push
306app.use("*", async (c, next) => {
307 if (c.req.path.includes(".git/")) return next();
308 return logger()(c, next);
309});
79136bbClaude310app.use("/api/*", cors());
bf19c50Test User311// Global softAuth — populates c.get("user") for every downstream middleware
312// + route. This was previously per-route, which meant rate-limit middleware
313// (and anything else inspecting auth state) always saw a null user. Keep
314// individual routes free to add requireAuth on top for hard gating; this
315// just establishes the user object cheaply.
316app.use("*", softAuth);
290ea77Claude317
36cc17aClaude318// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude319// pre-redesign markup. JSON / static assets keep their own cache rules; only
320// text/html responses get the no-cache stamp. Without this, every push to
321// main left users staring at cached 80s-looking pages from before the design
322// landed.
36cc17aClaude323//
324// We deliberately use `private, no-cache, must-revalidate` rather than
325// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
326// which makes every Back/Forward press a cold server round-trip — that
327// contributed to the "every nav feels like a fresh login" UX complaint.
328// `no-cache` still revalidates on direct fetch but lets bfcache hold the
329// page in memory between navigations.
290ea77Claude330app.use("*", async (c, next) => {
331 await next();
332 const ct = c.res.headers.get("content-type") || "";
333 if (ct.startsWith("text/html")) {
36cc17aClaude334 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude335 }
336});
826eccfTest User337// Rate-limit API + auth endpoints.
338//
a41e675Test User339// `/api/*`: 1000/min per IP — generous so an admin clicking around the
340// operator console (or a CDN/proxy concentrating multiple users behind one
341// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
342// rate limits below, not this one.
343//
344// `authedMultiplier` is set but only fires when an upstream middleware has
345// already populated c.get("user") — most app.use() chains apply softAuth
346// per-route, so the multiplier is best-effort. Keep the anonymous base
347// high enough that humans never feel it.
348//
349// Skip-paths: dashboard plumbing endpoints that the layout polls on a
350// fixed cadence and that we don't want consuming any bucket:
351// /api/version — layout polls every 15s
826eccfTest User352// /api/notifications/count — nav bell unread-count fetcher
353// /pwa/vapid-public-key — fetched once per push-notification opt-in
354app.use(
355 "/api/*",
a41e675Test User356 rateLimit(1000, 60_000, "api", {
826eccfTest User357 authedMultiplier: 4,
358 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
359 })
360);
0316dbbClaude361app.use("/login", rateLimit(20, 60_000, "login"));
362app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude363// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
364app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User365// BLOCK Q2 — throttle magic-link sign-in for the same reason.
366app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude367
59b6fb2Claude368// CSRF protection — set token on all requests, validate on mutations
369app.use("*", csrfToken);
370app.use("*", csrfProtect);
371
45e31d0Claude372// Rate limit auth routes
373app.use("/login", authRateLimit);
374app.use("/register", authRateLimit);
375
59b6fb2Claude376// Rate limit git operations
377app.use("/:owner/:repo.git/*", gitRateLimit);
378
379// Rate limit search
380app.use("/:owner/:repo/search", searchRateLimit);
381app.use("/explore", searchRateLimit);
79136bbClaude382
f5b9ef5Claude383// No-cache for HTML — ensures browsers and proxies never serve stale pages.
384// The middleware only stamps text/html responses so static assets keep
385// their own cache policies unchanged.
386app.use("*", noCache);
387
79136bbClaude388// Git Smart HTTP protocol routes (must be before web routes)
389app.route("/", gitRoutes);
390
45e31d0Claude391// REST API v1 (legacy)
79136bbClaude392app.route("/", apiRoutes);
393
52ad8b1Claude394// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
395// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
396// router's catch-shape, and BEFORE adminRoutes so the live /demo page
397// wins over the legacy /demo redirect in src/routes/admin.tsx.
398app.route("/", demoRoutes);
399
0316dbbClaude400// REST API v2 (basePath /api/v2)
401app.route("/", apiV2Routes);
402
e75eddcClaude403// Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage).
404// Mounted alongside apiV2Routes (its own basePath, no path conflict).
405app.route("/", agentsRoutes);
406
ef3fd93Claude407// Multi-agent pipeline UI — /:owner/:repo/agents (list, new, live view).
408// Must be before webRoutes (the catch-all) so the /agents sub-paths are
409// resolved before the generic tree/blob route takes over.
410app.route("/", agentPipelinesRoutes);
411
ad6d4adClaude412// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
413app.route("/", hookRoutes);
21f8dbdClaude414app.route("/api/events", eventsRoutes);
ad6d4adClaude415
45e31d0Claude416// API documentation
417app.route("/", apiDocsRoutes);
4a80519Claude418app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude419// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
420app.route("/", pullsDashboardRoutes);
e9aa4d8Claude421// Issue command center — global issue dashboard with AI-triage + autopilot signal
422app.route("/", issuesDashboardRoutes);
423// Personal activity timeline — every event across the user's repos, with
424// AI-driven events surfaced separately (the Gluecron differentiator).
425app.route("/", activityRoutes);
426// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
427app.route("/", inboxRoutes);
56801e1Claude428// AI standup feed — daily / weekly Claude-generated team brief
429app.route("/", standupRoutes);
cc34156Claude430// Smart morning digest — AI-curated daily developer queue (/digest)
431app.route("/", digestRoutes);
79136bbClaude432
433// Auth routes (register, login, logout)
434app.route("/", authRoutes);
435
c63b860Claude436// BLOCK P1 — Password reset (forgot-password + reset-password)
437app.route("/", passwordResetRoutes);
438
439// BLOCK P2 — Email verification (verify-email + resend)
440app.route("/", emailVerificationRoutes);
441
cd4f63bTest User442// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
443app.route("/", magicLinkRoutes);
444
79136bbClaude445// Settings routes (profile, SSH keys)
446app.route("/", settingsRoutes);
447
ba9e143Claude448// Session management (SOC 2 CC6.1 — /settings/sessions)
449app.route("/", settingsSessionsRoutes);
450
7298a17Claude451// 2FA / TOTP settings (Block B4)
452app.route("/", settings2faRoutes);
453
e75eddcClaude454// Agent multiplayer — /settings/agents management UI
455app.route("/", settingsAgentsRoutes);
456
1d4ff60Claude457// Chat integrations — Slack / Discord / Teams (/settings/integrations
458// + /api/v2/integrations/{slack,discord}/*). See src/lib/chat-bot.ts.
459app.route("/", settingsIntegrationsRoutes);
460app.route("/", integrationsChatRoutes);
461
2df1f8cClaude462// WebAuthn / passkey routes (Block B5)
463app.route("/", passkeyRoutes);
464
058d752Claude465// OAuth 2.0 provider (Block B6)
466app.route("/", oauthRoutes);
467app.route("/", developerAppsRoutes);
468
6fc53bdClaude469// Theme toggle (dark/light cookie)
470app.route("/", themeRoutes);
471
472// Audit log UI
473app.route("/", auditRoutes);
474
475// Reactions API (issues, PRs, comments)
476app.route("/", reactionRoutes);
477
24cf2caClaude478// Saved replies (per-user canned comment templates)
479app.route("/", savedReplyRoutes);
480
481// Environments + deployment history UI
482app.route("/", deploymentRoutes);
483
6563f0aClaude484// Organizations + teams (Block B1)
485app.route("/", orgRoutes);
486
c81ab7aClaude487// API tokens
488app.route("/", tokenRoutes);
489
59b6fb2Claude490// Notifications
3ef4c9dClaude491app.route("/", notificationRoutes);
492
79136bbClaude493// Repo settings (description, visibility, delete)
494app.route("/", repoSettings);
495
23d1a81Claude496// Repo collaborators (add/list/remove)
497app.route("/", collaboratorRoutes);
498
04f6b7fClaude499// Team-based repo collaborators (invite a whole team)
500app.route("/", teamCollaboratorRoutes);
501
502// Collaborator invite accept flow (token-based)
503app.route("/", invitesRoutes);
504
505// Real-time SSE endpoint (topic-based live updates)
506app.route("/", liveEventsRoutes);
507
3c03977Claude508// PR live co-editing — presence + cursors + content sync via SSE.
509app.route("/", prLiveRoutes);
510
c81ab7aClaude511// Webhooks management
512app.route("/", webhookRoutes);
513
79136bbClaude514// Compare view (branch diffs)
515app.route("/", compareRoutes);
516
517// Issue tracker
518app.route("/", issueRoutes);
519
85c4e13Claude520// Milestones — group issues + PRs toward a shared goal with due dates + progress tracking.
521// Mounted after issueRoutes so /:owner/:repo/issues/* paths win before the milestone patterns.
522app.route("/", milestonesRoutes);
523
f928118Claude524// Ship Agent — autonomous AI feature implementation
525app.route("/", shipAgentRoutes);
526
77cf834Claude527// AI Copilot Workspace — issue-to-PR autonomous agent
528app.route("/", workspaceRoutes);
529
cb5a796Claude530// Comment moderation queue — owner-only `/:owner/:repo/comments/pending`
531// + per-row approve/reject/spam actions. Mounted before `pullRoutes` so
532// the `/:owner/:repo/comments/*` paths resolve before the broader PR
533// patterns kick in.
534app.route("/", commentModerationRoutes);
535
0074234Claude536// Pull requests
537app.route("/", pullRoutes);
09d5f39Claude538
539// /stage PR preview — serve built static files from .stage-previews/{jobId}/
540// Registered immediately after pullRoutes so the path `/preview/:id/*` is
541// specific enough to never clash with repo browse routes (`/:owner/:repo/*`).
542app.get("/preview/:stageJobId/*", async (c) => {
543 const { stageJobId } = c.req.param();
544 // Validate job ID format (UUID)
545 if (!/^[0-9a-f-]{32,}$/i.test(stageJobId)) {
546 return c.text("Not found", 404);
547 }
548 const { getPreviewDir, isPreviewExpired } = await import("./lib/pr-stage");
549 if (isPreviewExpired(stageJobId)) {
550 return c.html(
551 "<html><body style='font-family:sans-serif;padding:40px;color:#888'>" +
552 "<h2>Preview expired</h2><p>This stage preview has expired (48h TTL). " +
553 "Comment <code>/stage</code> on the PR to redeploy.</p></body></html>",
554 410
555 );
556 }
557 const { join } = await import("path");
558 const previewDir = getPreviewDir(stageJobId);
559 // Extract the wildcard path after /preview/:id/
560 const rawPath = c.req.path.replace(/^\/preview\/[^/]+/, "") || "/";
561 const filePath = rawPath === "/" || rawPath === "" ? "/index.html" : rawPath;
562 const fullPath = join(previewDir, filePath);
563 const file = Bun.file(fullPath);
564 if (!(await file.exists())) {
565 // Try index.html fallback (SPA behaviour)
566 const indexFile = Bun.file(join(previewDir, "index.html"));
567 if (await indexFile.exists()) {
568 const html = await indexFile.text();
569 return c.html(html);
570 }
571 return c.text("Not found", 404);
572 }
573 const content = await file.arrayBuffer();
574 const ext = fullPath.split(".").pop()?.toLowerCase() ?? "";
575 const contentTypeMap: Record<string, string> = {
576 html: "text/html; charset=utf-8",
577 htm: "text/html; charset=utf-8",
578 css: "text/css; charset=utf-8",
579 js: "application/javascript; charset=utf-8",
580 mjs: "application/javascript; charset=utf-8",
581 json: "application/json; charset=utf-8",
582 png: "image/png",
583 jpg: "image/jpeg",
584 jpeg: "image/jpeg",
585 gif: "image/gif",
586 svg: "image/svg+xml",
587 ico: "image/x-icon",
588 webp: "image/webp",
589 woff: "font/woff",
590 woff2: "font/woff2",
591 ttf: "font/ttf",
592 txt: "text/plain; charset=utf-8",
593 xml: "application/xml",
594 webmanifest: "application/manifest+json",
595 };
596 const ct = contentTypeMap[ext] ?? "application/octet-stream";
597 return c.body(content, 200, {
598 "content-type": ct,
599 "cache-control": "public, max-age=300",
600 "x-stage-job-id": stageJobId,
601 });
602});
603
79ed944Claude604// PR sandboxes — runnable per-PR environments. Migration 0067.
605app.route("/", prSandboxRoutes);
0074234Claude606
9b3a183Claude607// Cloud dev environments — hosted VS Code in the browser. Migration 0072.
608app.route("/", devEnvRoutes);
609
c81ab7aClaude610// Fork
611app.route("/", forkRoutes);
612
0074234Claude613// Web file editor
614app.route("/", editorRoutes);
615
6f2809fClaude616// AI editor API routes (inline suggestions, explain, fix)
617app.route("/", aiEditorRoutes);
618
43de941Claude619// Contributors
620app.route("/", contributorRoutes);
621
699e5c7Claude622// Health liveness + metrics endpoints
2c34075Claude623app.route("/", healthRoutes);
624
f295f78Dictation App625// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
626app.route("/api/platform-status", platformStatus);
627
52ad8b1Claude628// Block L4 — Public stats counters (powers landing-page social proof)
629app.route("/", publicStatsRoutes);
630
631// Block L3 — Live /demo page + /api/v2/demo/* endpoints
632app.route("/", demoRoutes);
633
2316be6Claude634// Public /status — human-readable platform health page
635app.route("/", statusRoutes);
636
b1be050CC LABS App637// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
638// Mounted near the public status route so the two surfaces are visible
639// side-by-side; routes are gated by isSiteAdmin internally.
640app.route("/", adminStatusRoutes);
641
80bed05Claude642// /help — quickstart + API cheatsheet
643app.route("/", helpRoutes);
644
e0e4219Claude645// /docs — expanded documentation site (getting started, workflow YAML, MCP, API, agents)
646app.route("/", docsRoutes);
647
5f2e749Claude648// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
649// so the new editorial pricing layout wins the route; the legacy marketing
650// pricing remains as a safety net but is shadowed at the router.
651app.route("/", pricingRoutes);
652
e1fc7dbClaude653// /changelog — manually curated platform release history
654app.route("/", changelogRoutes);
655
9f29b65Claude656// Enterprise sales page + contact form lead capture.
657app.route("/", enterpriseRoutes);
658
b0148e9Claude659// /pricing, /features, /about — marketing surface
660app.route("/", marketingRoutes);
661
adf5e18Claude662// /developer-program — partner + marketplace revenue-share page
663app.route("/", developerProgramRoutes);
664
5618f9aClaude665// SEO: robots.txt + sitemap.xml
666app.route("/", seoRoutes);
667
05cdb85Claude668// /api/version — live build SHA + uptime; client poller uses this to
669// surface 'New version available — reload' banners on deploy.
670app.route("/", versionRoutes);
671
699e5c7Claude672// Health dashboard (per-repo health page)
673app.route("/", healthDashboardRoutes);
674
9dd96b9Test User675// Block R1 — site-admin operations console. MUST be mounted BEFORE
676// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
677// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
678app.route("/", adminOpsRoutes);
f2c00b4CC LABS App679// BLOCK W — Self-host status + bootstrap dashboard.
680app.route("/", adminSelfHostRoutes);
826eccfTest User681// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
682app.route("/", adminDiagnoseRoutes);
9dd96b9Test User683
16b325cClaude684// Insights (time-travel, dependencies, rollback)
685app.route("/", insightRoutes);
686
8286942Claude687// Engineering Intelligence Dashboard — /insights + /:owner/:repo/insights/engineering
688app.route("/", engineeringInsightsRoutes);
689
8d1483cClaude690// DORA metrics page (/:owner/:repo/insights/dora)
691app.route("/", doraRoutes);
692
f1ab587Claude693// Command center dashboard
694app.route("/", dashboardRoutes);
695
36b4cbdClaude696// Legal pages (terms, privacy, AUP)
697app.route("/", legalRoutes);
4b66018Claude698// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
699// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
700// /acceptable-use); these are the formal versions that the legal pages
701// internally link to each other.
702app.route("/", legalTermsRoutes);
703app.route("/", legalPrivacyRoutes);
704app.route("/", legalAcceptableUseRoutes);
705app.route("/", legalDmcaRoutes);
36b4cbdClaude706
bdbd0deClaude707// GitHub import / migration
708app.route("/", importRoutes);
14c3cc8Claude709app.route("/", importBulkRoutes);
f390cfaCC LABS App710app.route("/", importSecretsRoutes);
bb2dea9Claude711// GitHub Actions → Gluecron gates.yml importer (stateless converter)
712app.route("/", actionsImporterRoutes);
14c3cc8Claude713app.route("/", migrationRoutes);
9a8b8deClaude714// GitHub Org Migration Wizard — live progress bulk importer
715app.route("/", migrateRoutes);
14c3cc8Claude716
717// Spec-to-PR (experimental AI-generated draft PRs)
718app.route("/", specsRoutes);
23d0abfClaude719app.route("/", refactorRoutes);
b665cacClaude720app.route("/", codebaseMigratorRoutes);
bdbd0deClaude721
c81ab7aClaude722// Explore page
723app.route("/", exploreRoutes);
724
59b6fb2Claude725// Onboarding
726app.route("/", onboardingRoutes);
727
0316dbbClaude728// Admin + feature routes
729app.route("/", adminRoutes);
7293c67Claude730app.route("/", adminDeletionsRoutes);
731app.route("/", adminStripeRoutes);
ba9e143Claude732
733// SOC 2 security dashboard + readiness checklist (/admin/security, /admin/soc2)
734app.route("/", adminSecurityRoutes);
509c376Claude735app.route("/", adminIntegrationsRoutes);
79ed944Claude736app.route("/", adminAdvancementRoutes);
f764c07Claude737app.route("/", adminDeploysRoutes);
738app.route("/", adminDeploysPageRoutes);
783dd46Claude739app.route("/", adminServerTargetsRoutes);
9aaa128Claude740app.route("/", deployTargetsRoutes);
90c7531Claude741app.route("/", claudeWebRoutes);
9dd96b9Test User742// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude743app.route("/", advisoriesRoutes);
744app.route("/", aiChangelogRoutes);
0a69faaClaude745// "Explain This Repo" — rich structured AI analysis dashboard (mounted before
746// the simpler aiExplainRoutes so the new routes win on /:owner/:repo/explain).
747app.route("/", explainRoutes);
0316dbbClaude748app.route("/", aiExplainRoutes);
749app.route("/", aiTestsRoutes);
750app.route("/", askRoutes);
38d31d3Claude751app.route("/", repoChatRoutes);
ee7e577Claude752// Personal cross-repo chat — `/chat` (user-scoped). Mounted alongside
753// repoChatRoutes so the two surfaces share the catch-all priority.
754app.route("/", personalChatRoutes);
0316dbbClaude755app.route("/", billingRoutes);
8809b87Claude756app.route("/", billingUsageRoutes);
6778ad2Claude757app.route("/", stripeWebhookRoutes);
0316dbbClaude758app.route("/", codeScanningRoutes);
da3fc18Claude759// Dependency CVE scanner findings page — /:owner/:repo/security/vulnerabilities
760app.route("/", securityRoutes);
0316dbbClaude761app.route("/", commitStatusesRoutes);
762app.route("/", copilotRoutes);
f5d020fClaude763app.route("/", pairProgrammerRoutes);
0316dbbClaude764app.route("/", depUpdaterRoutes);
765app.route("/", depsRoutes);
766app.route("/", discussionsRoutes);
767app.route("/", environmentsRoutes);
4bbacbeClaude768app.route("/", previewsRoutes);
79ed944Claude769app.route("/", docsTrackingRoutes);
0316dbbClaude770app.route("/", followsRoutes);
771app.route("/", gatesRoutes);
772app.route("/", gistsRoutes);
773app.route("/", graphqlRoutes);
2c2163eClaude774app.route("/", mcpRoutes);
0316dbbClaude775app.route("/", marketplaceRoutes);
5ca514aClaude776app.route("/", marketplaceAgentsRoutes);
0316dbbClaude777app.route("/", mergeQueueRoutes);
778app.route("/", mirrorsRoutes);
779app.route("/", orgInsightsRoutes);
780app.route("/", packagesRoutes);
781app.route("/", packagesApiRoutes);
845fd8aClaude782// OCI / Docker container registry — /v2/* (OCI Distribution Spec v1.0)
783app.route("/", ociRegistryRoutes);
0316dbbClaude784app.route("/", pagesRoutes);
785app.route("/", projectsRoutes);
786app.route("/", protectedTagsRoutes);
787app.route("/", pwaRoutes);
46d6165Claude788app.route("/", installRoutes);
cd4f63bTest User789// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
790app.route("/", dxtRoutes);
662ce86Claude791// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
792// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
793app.route("/", connectClaudeRoutes);
f5b9ef5Claude794// Claude Code Integration Receiver — /api/claude/connect + /api/claude/session.
795app.route("/", claudeIntegration);
796// Connect guide — public onboarding page (/connect/claude-guide).
797app.route("/", connectRoutes);
05ab9b1Claude798// Push Watch — per-commit live status (gates + deploy + latency) at /:owner/:repo/push/:sha
799app.route("/", pushWatchRoutes);
800// Org Secrets Manager — BLOCK M2 — /orgs/:slug/settings/secrets
801app.route("/", orgSecretsRoutes);
a2b3e99Claude802// Cross-repo code search — BLOCK M3 — /search/code + /api/search/code
803app.route("/", crossRepoSearchRoutes);
804// Browser push notifications — BLOCK M4 — /settings/notifications/push + /api/push/*
805app.route("/", pushNotifRoutes);
9fbe6cdClaude806// Developer Velocity Dashboard — BLOCK M9 — /:owner/:repo/insights/velocity
807app.route("/", velocityRoutes);
808// Stale Branch Cleanup — BLOCK M10 — /:owner/:repo/branches/stale
809app.route("/", staleBranchRoutes);
22f43f3Claude810// Repository Pulse — BLOCK M12 — /:owner/:repo/pulse
811app.route("/", pulseRoutes);
74d8c4dClaude812// Repository Health Score — BLOCK M14 — /:owner/:repo/insights/health
813app.route("/", healthScoreRoutes);
77cf834Claude814// Repository Health Score breakdown page — /:owner/:repo/health
815app.route("/", repoHealthRoutes);
74d8c4dClaude816// Hot Files Heatmap — BLOCK M16 — /:owner/:repo/insights/hotfiles
817app.route("/", hotFilesRoutes);
bcc4020Claude818// AI Technical Debt Map — /:owner/:repo/debt-map (visual debt graph + Claude analysis)
819app.route("/", debtMapRoutes);
1d6db4dClaude820// Bus Factor Analysis — /:owner/:repo/insights/bus-factor
821app.route("/", busFactorRoutes);
f5d020fClaude822// Cross-Repo Dependency Impact Detection — /:owner/:repo/pulls/:number/cross-repo-impact
823app.route("/", crossRepoImpactRoutes);
ebbb527Claude824// Hosted Claude tool-use loops — paste loop, get endpoint, billing meter.
825// See src/routes/claude-deploy.tsx + src/lib/hosted-claude-loop.ts.
826app.route("/", claudeDeployRoutes);
0316dbbClaude827app.route("/", releasesRoutes);
828app.route("/", requiredChecksRoutes);
829app.route("/", rulesetsRoutes);
830app.route("/", searchRoutes);
831app.route("/", semanticSearchRoutes);
77cf834Claude832app.route("/", nlSearchRoutes);
0316dbbClaude833app.route("/", signingKeysRoutes);
834app.route("/", sponsorsRoutes);
835app.route("/", ssoRoutes);
3a845e4Claude836// Enterprise per-org SAML 2.0 + OIDC SSO routes
837app.route("/", samlSsoRoutes);
838// SCIM 2.0 user provisioning endpoints
839app.route("/", scimRoutes);
840// Per-org SSO + SCIM admin settings UI
841app.route("/", orgSsoSettingsRoutes);
46d6165Claude842app.route("/", githubOauthRoutes);
582cdacClaude843app.route("/", googleOauthRoutes);
0316dbbClaude844app.route("/", symbolsRoutes);
845app.route("/", templatesRoutes);
846app.route("/", trafficRoutes);
847app.route("/", wikisRoutes);
848app.route("/", workflowsRoutes);
5ff9cc2Claude849app.route("/", workflowArtifactsRoutes);
850app.route("/", workflowSecretsRoutes);
46d6165Claude851app.route("/", sleepModeRoutes);
52ad8b1Claude852app.route("/", vsGithubRoutes);
0316dbbClaude853
45f3b73Claude854// Voice-to-PR — phone-first dictation → spec or issue
855app.route("/", voiceRoutes);
856
3122762Claude857// Blog / Devlog — public posts, no DB
858app.route("/", blogRoutes);
859
cd4f63bTest User860// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
861// before the web catch-all so the bare `/play` literal wins over the
862// `/:owner` user-profile route.
863app.route("/", playgroundRoutes);
864
891efbeClaude865// Shareable AI hours-saved OG image card + landing page.
866// /share/hours-saved?user=:username → 1200×630 SVG (og:image)
867// /share/:username → HTML page with og:image meta + Twitter share
868// Mounted BEFORE webRoutes so /share/* doesn't fall through to the /:owner profile route.
869app.route("/", shareRoutes);
870
79136bbClaude871// Web UI (catch-all, must be last)
872app.route("/", webRoutes);
873
c63b860Claude874// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
875// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude876app.notFound((c) => {
36cc17aClaude877 const user = c.get("user") ?? null;
79136bbClaude878 return c.html(
c63b860Claude879 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude880 404
881 );
882});
883
c63b860Claude884// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
885// view. Trace block only shown outside production.
79136bbClaude886app.onError((err, c) => {
80bed05Claude887 reportError(err, {
888 requestId: c.get("requestId"),
889 path: c.req.path,
890 method: c.req.method,
891 });
c63b860Claude892 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
893 // back to the context value set by request-context middleware.
894 const requestId =
895 c.req.header("x-request-id") ||
896 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude897 const user = c.get("user") ?? null;
c63b860Claude898 const trace =
899 process.env.NODE_ENV !== "production" && err && err.message
900 ? err.message
901 : undefined;
79136bbClaude902 return c.html(
c63b860Claude903 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude904 500
905 );
906});
907
908export default app;