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.tsxBlame928 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";
479dcd9Claude37import automationSettingsRoutes from "./routes/automation-settings";
23d1a81Claude38import collaboratorRoutes from "./routes/collaborators";
04f6b7fClaude39import teamCollaboratorRoutes from "./routes/team-collaborators";
40import invitesRoutes from "./routes/invites";
41import liveEventsRoutes from "./routes/live-events";
3c03977Claude42import prLiveRoutes from "./routes/pr-live";
79136bbClaude43import compareRoutes from "./routes/compare";
0074234Claude44import pullRoutes from "./routes/pulls";
79ed944Claude45import prSandboxRoutes from "./routes/pr-sandbox";
9b3a183Claude46import devEnvRoutes from "./routes/dev-env";
0074234Claude47import editorRoutes from "./routes/editor";
6f2809fClaude48import aiEditorRoutes from "./routes/ai-editor";
c81ab7aClaude49import forkRoutes from "./routes/fork";
50import webhookRoutes from "./routes/webhooks";
51import exploreRoutes from "./routes/explore";
52import tokenRoutes from "./routes/tokens";
43de941Claude53import contributorRoutes from "./routes/contributors";
699e5c7Claude54import healthRoutes from "./routes/health-probe";
55import healthDashboardRoutes from "./routes/health";
2316be6Claude56import statusRoutes from "./routes/status";
b1be050CC LABS App57import adminStatusRoutes from "./routes/admin-status";
80bed05Claude58import helpRoutes from "./routes/help";
e1fc7dbClaude59import changelogRoutes from "./routes/changelog";
e0e4219Claude60import docsRoutes from "./routes/docs";
b0148e9Claude61import marketingRoutes from "./routes/marketing";
5f2e749Claude62import pricingRoutes from "./routes/pricing";
9f29b65Claude63import enterpriseRoutes from "./routes/enterprise";
5618f9aClaude64import seoRoutes from "./routes/seo";
05cdb85Claude65import versionRoutes from "./routes/version";
f295f78Dictation App66import { platformStatus } from "./routes/platform-status";
52ad8b1Claude67import publicStatsRoutes from "./routes/public-stats";
68import demoRoutes from "./routes/demo";
16b325cClaude69import insightRoutes from "./routes/insights";
8286942Claude70import engineeringInsightsRoutes from "./routes/engineering-insights";
8d1483cClaude71import doraRoutes from "./routes/dora";
f1ab587Claude72import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude73import legalRoutes from "./routes/legal";
4b66018Claude74import legalDmcaRoutes from "./routes/legal/dmca";
75import legalTermsRoutes from "./routes/legal/terms";
76import legalPrivacyRoutes from "./routes/legal/privacy";
77import legalAcceptableUseRoutes from "./routes/legal/acceptable-use";
bdbd0deClaude78import importRoutes from "./routes/import";
14c3cc8Claude79import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App80import importSecretsRoutes from "./routes/import-secrets";
bb2dea9Claude81import actionsImporterRoutes from "./routes/actions-importer";
14c3cc8Claude82import migrationRoutes from "./routes/migrations";
ba23fe2Claude83import migrationAssistantRoutes from "./routes/migration-assistant";
9a8b8deClaude84import migrateRoutes from "./routes/migrate";
14c3cc8Claude85import specsRoutes from "./routes/specs";
23d0abfClaude86import refactorRoutes from "./routes/refactors";
b665cacClaude87import codebaseMigratorRoutes from "./routes/codebase-migrator";
79136bbClaude88import webRoutes from "./routes/web";
0316dbbClaude89import hookRoutes from "./routes/hooks";
90import eventsRoutes from "./routes/events";
91import passkeyRoutes from "./routes/passkeys";
92import oauthRoutes from "./routes/oauth";
93import developerAppsRoutes from "./routes/developer-apps";
94import themeRoutes from "./routes/theme";
95import auditRoutes from "./routes/audit";
96import reactionRoutes from "./routes/reactions";
97import savedReplyRoutes from "./routes/saved-replies";
98import deploymentRoutes from "./routes/deployments";
99import orgRoutes from "./routes/orgs";
100import notificationRoutes from "./routes/notifications";
101import onboardingRoutes from "./routes/onboarding";
102import adminRoutes from "./routes/admin";
7293c67Claude103import adminDeletionsRoutes from "./routes/admin-deletions";
104import adminStripeRoutes from "./routes/admin-stripe";
f764c07Claude105import adminDeploysRoutes from "./routes/admin-deploys";
106import adminDeploysPageRoutes from "./routes/admin-deploys-page";
783dd46Claude107import adminServerTargetsRoutes from "./routes/admin-server-targets";
9aaa128Claude108import deployTargetsRoutes from "./routes/deploy-targets";
90c7531Claude109import claudeWebRoutes from "./routes/claude-web";
9dd96b9Test User110import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App111import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User112import adminDiagnoseRoutes from "./routes/admin-diagnose";
509c376Claude113import adminIntegrationsRoutes from "./routes/admin-integrations";
bc519aeClaude114import adminEnvHealthRoutes from "./routes/admin-env-health";
79ed944Claude115import adminAdvancementRoutes from "./routes/admin-advancement";
ba9e143Claude116import adminSecurityRoutes from "./routes/admin-security";
117import settingsSessionsRoutes from "./routes/settings-sessions";
0316dbbClaude118import advisoriesRoutes from "./routes/advisories";
119import aiChangelogRoutes from "./routes/ai-changelog";
0a69faaClaude120import explainRoutes from "./routes/explain";
0316dbbClaude121import aiExplainRoutes from "./routes/ai-explain";
2be65d0Claude122import archaeologyRoutes from "./routes/ai-archaeology";
0316dbbClaude123import aiTestsRoutes from "./routes/ai-tests";
124import askRoutes from "./routes/ask";
38d31d3Claude125import repoChatRoutes from "./routes/repo-chat";
ee7e577Claude126import personalChatRoutes from "./routes/personal-chat";
0316dbbClaude127import billingRoutes from "./routes/billing";
8809b87Claude128import billingUsageRoutes from "./routes/billing-usage";
6778ad2Claude129import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude130import codeScanningRoutes from "./routes/code-scanning";
da3fc18Claude131import securityRoutes from "./routes/security";
0316dbbClaude132import commitStatusesRoutes from "./routes/commit-statuses";
133import copilotRoutes from "./routes/copilot";
f5d020fClaude134import { pairProgrammerRoutes } from "./routes/pair-programmer";
0316dbbClaude135import depUpdaterRoutes from "./routes/dep-updater";
136import depsRoutes from "./routes/deps";
137import discussionsRoutes from "./routes/discussions";
138import environmentsRoutes from "./routes/environments";
4bbacbeClaude139import previewsRoutes from "./routes/previews";
79ed944Claude140import docsTrackingRoutes from "./routes/docs-tracking";
0316dbbClaude141import followsRoutes from "./routes/follows";
142import gatesRoutes from "./routes/gates";
143import gistsRoutes from "./routes/gists";
144import graphqlRoutes from "./routes/graphql";
2c2163eClaude145import mcpRoutes from "./routes/mcp";
0316dbbClaude146import marketplaceRoutes from "./routes/marketplace";
5ca514aClaude147import marketplaceAgentsRoutes from "./routes/marketplace-agents";
0316dbbClaude148import mergeQueueRoutes from "./routes/merge-queue";
149import mirrorsRoutes from "./routes/mirrors";
150import orgInsightsRoutes from "./routes/org-insights";
2be65d0Claude151import orgHealthRoutes from "./routes/org-health";
0316dbbClaude152import packagesRoutes from "./routes/packages";
153import packagesApiRoutes from "./routes/packages-api";
845fd8aClaude154import ociRegistryRoutes from "./routes/oci-registry";
0316dbbClaude155import pagesRoutes from "./routes/pages";
156import projectsRoutes from "./routes/projects";
157import protectedTagsRoutes from "./routes/protected-tags";
158import pwaRoutes from "./routes/pwa";
46d6165Claude159import installRoutes from "./routes/install";
cd4f63bTest User160import dxtRoutes from "./routes/dxt";
662ce86Claude161import connectClaudeRoutes from "./routes/connect-claude";
ebbb527Claude162import claudeDeployRoutes from "./routes/claude-deploy";
f5b9ef5Claude163import claudeIntegration from "./routes/claude-integration";
164import connectRoutes from "./routes/connect";
05ab9b1Claude165import pushWatchRoutes from "./routes/push-watch";
166import orgSecretsRoutes from "./routes/org-secrets";
0316dbbClaude167import releasesRoutes from "./routes/releases";
168import requiredChecksRoutes from "./routes/required-checks";
169import rulesetsRoutes from "./routes/rulesets";
170import searchRoutes from "./routes/search";
171import semanticSearchRoutes from "./routes/semantic-search";
77cf834Claude172import nlSearchRoutes from "./routes/nl-search";
0316dbbClaude173import signingKeysRoutes from "./routes/signing-keys";
174import sponsorsRoutes from "./routes/sponsors";
175import ssoRoutes from "./routes/sso";
3a845e4Claude176import samlSsoRoutes from "./routes/saml-sso";
177import scimRoutes from "./routes/scim";
178import orgSsoSettingsRoutes from "./routes/org-sso-settings";
46d6165Claude179import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude180import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude181import symbolsRoutes from "./routes/symbols";
182import templatesRoutes from "./routes/templates";
183import trafficRoutes from "./routes/traffic";
184import wikisRoutes from "./routes/wikis";
185import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude186import workflowArtifactsRoutes from "./routes/workflow-artifacts";
187import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude188import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude189import standupRoutes from "./routes/standups";
52ad8b1Claude190import vsGithubRoutes from "./routes/vs-github";
45f3b73Claude191import voiceRoutes from "./routes/voice-to-pr";
3122762Claude192import blogRoutes from "./routes/blog";
cd4f63bTest User193import playgroundRoutes from "./routes/playground";
a2b3e99Claude194import crossRepoSearchRoutes from "./routes/cross-repo-search";
195import pushNotifRoutes from "./routes/push-notifications";
9fbe6cdClaude196import velocityRoutes from "./routes/velocity";
197import { staleBranchRoutes } from "./routes/stale-branches";
22f43f3Claude198import pulseRoutes from "./routes/pulse";
74d8c4dClaude199import healthScoreRoutes from "./routes/health-score";
77cf834Claude200import repoHealthRoutes from "./routes/repo-health";
74d8c4dClaude201import hotFilesRoutes from "./routes/hot-files";
bcc4020Claude202import debtMapRoutes from "./routes/debt-map";
1d6db4dClaude203import busFactorRoutes from "./routes/bus-factor";
2be65d0Claude204import testGapsRoutes from "./routes/test-gaps";
f5d020fClaude205import crossRepoImpactRoutes from "./routes/cross-repo-impact";
adf5e18Claude206import developerProgramRoutes from "./routes/developer-program";
891efbeClaude207import shareRoutes from "./routes/share";
70e3293Claude208import incidentHookRoutes from "./routes/incident-hooks";
77cf834Claude209import workspaceRoutes from "./routes/ai-workspace";
59b6fb2Claude210import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
211import { csrfToken, csrfProtect } from "./middleware/csrf";
f5b9ef5Claude212import { noCache } from "./middleware/no-cache";
79136bbClaude213
2316901Claude214import type { AuthEnv } from "./middleware/auth";
bf19c50Test User215import { softAuth } from "./middleware/auth";
2316901Claude216
217const app = new Hono<AuthEnv>();
79136bbClaude218
3ef4c9dClaude219// Request context (request ID, start time) runs before everything else
220app.use("*", requestContext);
05b973eClaude221// Middleware — compression first (wraps all responses)
222app.use("*", compress());
f1ffd50Claude223
224// ETag middleware — returns 304 Not Modified on unchanged responses.
225// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
226// SSE + the API surface where it would interfere with streaming.
227app.use("*", async (c, next) => {
228 const p = c.req.path;
229 if (
230 p.includes(".git/") ||
231 p.startsWith("/live-events") ||
232 p.startsWith("/api/events/deploy") ||
3c03977Claude233 p.startsWith("/admin/status") ||
234 // PR live co-editing SSE stream — never etag streaming responses.
235 /^\/api\/v2\/pulls\/[^/]+\/live(\/|$)/.test(p)
f1ffd50Claude236 ) {
237 return next();
238 }
239 return etag()(c, next);
240});
241
242// Cache-Control middleware — sets sensible defaults on public, anonymous
9ecf5a4Claude243// requests. Vapron (when wired as our edge layer) and downstream
f1ffd50Claude244// browsers will honor these. Auth'd users get private,no-store
245// automatically — we never cache responses tied to a session.
246app.use("*", async (c, next) => {
247 await next();
248 // Don't overwrite explicit headers set by route handlers — BUT the
249 // ETag middleware unconditionally sets "private, no-cache, must-
250 // revalidate" so we have to treat that specific value as "no
251 // policy chosen yet" and apply ours. Any route that explicitly set
252 // a different cache-control wins.
253 const existing = c.res.headers.get("cache-control");
254 const etagDefault =
255 existing === "private, no-cache, must-revalidate" ||
256 existing === "no-cache";
257 if (existing && !etagDefault) return;
258 // Anything past auth: private + no-store (avoid leaking session
259 // content into shared caches). softAuth runs before this on the
260 // request, but the response side is what we're stamping.
261 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
262 const p = c.req.path;
263 // Always private for known-authed paths regardless of cookie.
264 if (
265 p.startsWith("/admin") ||
266 p.startsWith("/settings") ||
267 p.startsWith("/dashboard") ||
268 p.startsWith("/notifications") ||
269 p.startsWith("/connect/") ||
270 hasSession
271 ) {
272 c.res.headers.set("cache-control", "private, no-store");
273 return;
274 }
275 // Public marketing surfaces — short edge cache, longer browser cache,
276 // stale-while-revalidate so the user never waits on a stale fetch.
277 const isMarketing =
278 p === "/" ||
279 p === "/features" ||
280 p === "/pricing" ||
281 p === "/about" ||
282 p === "/vs-github" ||
283 p === "/explore" ||
284 p === "/help" ||
285 p === "/changelog" ||
9f29b65Claude286 p === "/enterprise" ||
f1ffd50Claude287 p.startsWith("/legal/") ||
288 p === "/terms" ||
289 p === "/privacy" ||
290 p === "/acceptable-use" ||
291 p.startsWith("/docs/");
292 if (isMarketing) {
293 c.res.headers.set(
294 "cache-control",
295 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
296 );
297 return;
298 }
299 // Public repo browse pages — cache aggressively. Edge invalidates
9ecf5a4Claude300 // on push via the post-receive hook (future Vapron surge purge).
f1ffd50Claude301 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
302 c.res.headers.set(
303 "cache-control",
304 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
305 );
306 return;
307 }
308 // Default: don't cache anything we haven't explicitly opted in.
309 c.res.headers.set("cache-control", "private, no-store");
310});
05b973eClaude311// Logger only on non-git routes to avoid overhead on clone/push
312app.use("*", async (c, next) => {
313 if (c.req.path.includes(".git/")) return next();
314 return logger()(c, next);
315});
79136bbClaude316app.use("/api/*", cors());
bf19c50Test User317// Global softAuth — populates c.get("user") for every downstream middleware
318// + route. This was previously per-route, which meant rate-limit middleware
319// (and anything else inspecting auth state) always saw a null user. Keep
320// individual routes free to add requireAuth on top for hard gating; this
321// just establishes the user object cheaply.
322app.use("*", softAuth);
290ea77Claude323
36cc17aClaude324// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude325// pre-redesign markup. JSON / static assets keep their own cache rules; only
326// text/html responses get the no-cache stamp. Without this, every push to
327// main left users staring at cached 80s-looking pages from before the design
328// landed.
36cc17aClaude329//
330// We deliberately use `private, no-cache, must-revalidate` rather than
331// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
332// which makes every Back/Forward press a cold server round-trip — that
333// contributed to the "every nav feels like a fresh login" UX complaint.
334// `no-cache` still revalidates on direct fetch but lets bfcache hold the
335// page in memory between navigations.
290ea77Claude336app.use("*", async (c, next) => {
337 await next();
338 const ct = c.res.headers.get("content-type") || "";
339 if (ct.startsWith("text/html")) {
36cc17aClaude340 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude341 }
342});
826eccfTest User343// Rate-limit API + auth endpoints.
344//
a41e675Test User345// `/api/*`: 1000/min per IP — generous so an admin clicking around the
346// operator console (or a CDN/proxy concentrating multiple users behind one
347// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
348// rate limits below, not this one.
349//
350// `authedMultiplier` is set but only fires when an upstream middleware has
351// already populated c.get("user") — most app.use() chains apply softAuth
352// per-route, so the multiplier is best-effort. Keep the anonymous base
353// high enough that humans never feel it.
354//
355// Skip-paths: dashboard plumbing endpoints that the layout polls on a
356// fixed cadence and that we don't want consuming any bucket:
357// /api/version — layout polls every 15s
826eccfTest User358// /api/notifications/count — nav bell unread-count fetcher
359// /pwa/vapid-public-key — fetched once per push-notification opt-in
360app.use(
361 "/api/*",
a41e675Test User362 rateLimit(1000, 60_000, "api", {
826eccfTest User363 authedMultiplier: 4,
364 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
365 })
366);
0316dbbClaude367app.use("/login", rateLimit(20, 60_000, "login"));
368app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude369// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
370app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User371// BLOCK Q2 — throttle magic-link sign-in for the same reason.
372app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude373
59b6fb2Claude374// CSRF protection — set token on all requests, validate on mutations
375app.use("*", csrfToken);
376app.use("*", csrfProtect);
377
45e31d0Claude378// Rate limit auth routes
379app.use("/login", authRateLimit);
380app.use("/register", authRateLimit);
381
59b6fb2Claude382// Rate limit git operations
383app.use("/:owner/:repo.git/*", gitRateLimit);
384
385// Rate limit search
386app.use("/:owner/:repo/search", searchRateLimit);
387app.use("/explore", searchRateLimit);
79136bbClaude388
f5b9ef5Claude389// No-cache for HTML — ensures browsers and proxies never serve stale pages.
390// The middleware only stamps text/html responses so static assets keep
391// their own cache policies unchanged.
392app.use("*", noCache);
393
79136bbClaude394// Git Smart HTTP protocol routes (must be before web routes)
395app.route("/", gitRoutes);
396
45e31d0Claude397// REST API v1 (legacy)
79136bbClaude398app.route("/", apiRoutes);
399
52ad8b1Claude400// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
401// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
402// router's catch-shape, and BEFORE adminRoutes so the live /demo page
403// wins over the legacy /demo redirect in src/routes/admin.tsx.
404app.route("/", demoRoutes);
405
0316dbbClaude406// REST API v2 (basePath /api/v2)
407app.route("/", apiV2Routes);
408
e75eddcClaude409// Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage).
410// Mounted alongside apiV2Routes (its own basePath, no path conflict).
411app.route("/", agentsRoutes);
412
ef3fd93Claude413// Multi-agent pipeline UI — /:owner/:repo/agents (list, new, live view).
414// Must be before webRoutes (the catch-all) so the /agents sub-paths are
415// resolved before the generic tree/blob route takes over.
416app.route("/", agentPipelinesRoutes);
417
ad6d4adClaude418// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
419app.route("/", hookRoutes);
21f8dbdClaude420app.route("/api/events", eventsRoutes);
ad6d4adClaude421
45e31d0Claude422// API documentation
423app.route("/", apiDocsRoutes);
4a80519Claude424app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude425// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
426app.route("/", pullsDashboardRoutes);
e9aa4d8Claude427// Issue command center — global issue dashboard with AI-triage + autopilot signal
428app.route("/", issuesDashboardRoutes);
429// Personal activity timeline — every event across the user's repos, with
430// AI-driven events surfaced separately (the Gluecron differentiator).
431app.route("/", activityRoutes);
432// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
433app.route("/", inboxRoutes);
56801e1Claude434// AI standup feed — daily / weekly Claude-generated team brief
435app.route("/", standupRoutes);
cc34156Claude436// Smart morning digest — AI-curated daily developer queue (/digest)
437app.route("/", digestRoutes);
79136bbClaude438
439// Auth routes (register, login, logout)
440app.route("/", authRoutes);
441
c63b860Claude442// BLOCK P1 — Password reset (forgot-password + reset-password)
443app.route("/", passwordResetRoutes);
444
445// BLOCK P2 — Email verification (verify-email + resend)
446app.route("/", emailVerificationRoutes);
447
cd4f63bTest User448// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
449app.route("/", magicLinkRoutes);
450
79136bbClaude451// Settings routes (profile, SSH keys)
452app.route("/", settingsRoutes);
453
ba9e143Claude454// Session management (SOC 2 CC6.1 — /settings/sessions)
455app.route("/", settingsSessionsRoutes);
456
7298a17Claude457// 2FA / TOTP settings (Block B4)
458app.route("/", settings2faRoutes);
459
e75eddcClaude460// Agent multiplayer — /settings/agents management UI
461app.route("/", settingsAgentsRoutes);
462
1d4ff60Claude463// Chat integrations — Slack / Discord / Teams (/settings/integrations
464// + /api/v2/integrations/{slack,discord}/*). See src/lib/chat-bot.ts.
465app.route("/", settingsIntegrationsRoutes);
466app.route("/", integrationsChatRoutes);
467
2df1f8cClaude468// WebAuthn / passkey routes (Block B5)
469app.route("/", passkeyRoutes);
470
058d752Claude471// OAuth 2.0 provider (Block B6)
472app.route("/", oauthRoutes);
473app.route("/", developerAppsRoutes);
474
6fc53bdClaude475// Theme toggle (dark/light cookie)
476app.route("/", themeRoutes);
477
478// Audit log UI
479app.route("/", auditRoutes);
480
481// Reactions API (issues, PRs, comments)
482app.route("/", reactionRoutes);
483
24cf2caClaude484// Saved replies (per-user canned comment templates)
485app.route("/", savedReplyRoutes);
486
487// Environments + deployment history UI
488app.route("/", deploymentRoutes);
489
6563f0aClaude490// Organizations + teams (Block B1)
491app.route("/", orgRoutes);
492
c81ab7aClaude493// API tokens
494app.route("/", tokenRoutes);
495
59b6fb2Claude496// Notifications
3ef4c9dClaude497app.route("/", notificationRoutes);
498
79136bbClaude499// Repo settings (description, visibility, delete)
500app.route("/", repoSettings);
479dcd9Claude501// Per-repo automation settings (off / suggest / auto) — migration 0106
502app.route("/", automationSettingsRoutes);
79136bbClaude503
23d1a81Claude504// Repo collaborators (add/list/remove)
505app.route("/", collaboratorRoutes);
506
04f6b7fClaude507// Team-based repo collaborators (invite a whole team)
508app.route("/", teamCollaboratorRoutes);
509
510// Collaborator invite accept flow (token-based)
511app.route("/", invitesRoutes);
512
513// Real-time SSE endpoint (topic-based live updates)
514app.route("/", liveEventsRoutes);
515
3c03977Claude516// PR live co-editing — presence + cursors + content sync via SSE.
517app.route("/", prLiveRoutes);
518
c81ab7aClaude519// Webhooks management
520app.route("/", webhookRoutes);
521
79136bbClaude522// Compare view (branch diffs)
523app.route("/", compareRoutes);
524
525// Issue tracker
526app.route("/", issueRoutes);
527
85c4e13Claude528// Milestones — group issues + PRs toward a shared goal with due dates + progress tracking.
529// Mounted after issueRoutes so /:owner/:repo/issues/* paths win before the milestone patterns.
530app.route("/", milestonesRoutes);
531
f928118Claude532// Ship Agent — autonomous AI feature implementation
533app.route("/", shipAgentRoutes);
534
77cf834Claude535// AI Copilot Workspace — issue-to-PR autonomous agent
536app.route("/", workspaceRoutes);
537
cb5a796Claude538// Comment moderation queue — owner-only `/:owner/:repo/comments/pending`
539// + per-row approve/reject/spam actions. Mounted before `pullRoutes` so
540// the `/:owner/:repo/comments/*` paths resolve before the broader PR
541// patterns kick in.
542app.route("/", commentModerationRoutes);
543
0074234Claude544// Pull requests
545app.route("/", pullRoutes);
09d5f39Claude546
2be65d0Claude547// Streaming PR review — SSE stream + embeddable widget
548// Mounted immediately after pullRoutes so /:owner/:repo/pulls/:number/review/*
549// resolves before the webRoutes catch-all takes over.
550import streamingReviewRoutes from "./routes/streaming-review";
551app.route("/", streamingReviewRoutes);
552
09d5f39Claude553// /stage PR preview — serve built static files from .stage-previews/{jobId}/
554// Registered immediately after pullRoutes so the path `/preview/:id/*` is
555// specific enough to never clash with repo browse routes (`/:owner/:repo/*`).
556app.get("/preview/:stageJobId/*", async (c) => {
557 const { stageJobId } = c.req.param();
558 // Validate job ID format (UUID)
559 if (!/^[0-9a-f-]{32,}$/i.test(stageJobId)) {
560 return c.text("Not found", 404);
561 }
562 const { getPreviewDir, isPreviewExpired } = await import("./lib/pr-stage");
563 if (isPreviewExpired(stageJobId)) {
564 return c.html(
565 "<html><body style='font-family:sans-serif;padding:40px;color:#888'>" +
566 "<h2>Preview expired</h2><p>This stage preview has expired (48h TTL). " +
567 "Comment <code>/stage</code> on the PR to redeploy.</p></body></html>",
568 410
569 );
570 }
571 const { join } = await import("path");
572 const previewDir = getPreviewDir(stageJobId);
573 // Extract the wildcard path after /preview/:id/
574 const rawPath = c.req.path.replace(/^\/preview\/[^/]+/, "") || "/";
575 const filePath = rawPath === "/" || rawPath === "" ? "/index.html" : rawPath;
576 const fullPath = join(previewDir, filePath);
577 const file = Bun.file(fullPath);
578 if (!(await file.exists())) {
579 // Try index.html fallback (SPA behaviour)
580 const indexFile = Bun.file(join(previewDir, "index.html"));
581 if (await indexFile.exists()) {
582 const html = await indexFile.text();
583 return c.html(html);
584 }
585 return c.text("Not found", 404);
586 }
587 const content = await file.arrayBuffer();
588 const ext = fullPath.split(".").pop()?.toLowerCase() ?? "";
589 const contentTypeMap: Record<string, string> = {
590 html: "text/html; charset=utf-8",
591 htm: "text/html; charset=utf-8",
592 css: "text/css; charset=utf-8",
593 js: "application/javascript; charset=utf-8",
594 mjs: "application/javascript; charset=utf-8",
595 json: "application/json; charset=utf-8",
596 png: "image/png",
597 jpg: "image/jpeg",
598 jpeg: "image/jpeg",
599 gif: "image/gif",
600 svg: "image/svg+xml",
601 ico: "image/x-icon",
602 webp: "image/webp",
603 woff: "font/woff",
604 woff2: "font/woff2",
605 ttf: "font/ttf",
606 txt: "text/plain; charset=utf-8",
607 xml: "application/xml",
608 webmanifest: "application/manifest+json",
609 };
610 const ct = contentTypeMap[ext] ?? "application/octet-stream";
611 return c.body(content, 200, {
612 "content-type": ct,
613 "cache-control": "public, max-age=300",
614 "x-stage-job-id": stageJobId,
615 });
616});
617
79ed944Claude618// PR sandboxes — runnable per-PR environments. Migration 0067.
619app.route("/", prSandboxRoutes);
0074234Claude620
9b3a183Claude621// Cloud dev environments — hosted VS Code in the browser. Migration 0072.
622app.route("/", devEnvRoutes);
623
c81ab7aClaude624// Fork
625app.route("/", forkRoutes);
626
0074234Claude627// Web file editor
628app.route("/", editorRoutes);
629
6f2809fClaude630// AI editor API routes (inline suggestions, explain, fix)
631app.route("/", aiEditorRoutes);
632
43de941Claude633// Contributors
634app.route("/", contributorRoutes);
635
699e5c7Claude636// Health liveness + metrics endpoints
2c34075Claude637app.route("/", healthRoutes);
638
f295f78Dictation App639// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
640app.route("/api/platform-status", platformStatus);
641
52ad8b1Claude642// Block L4 — Public stats counters (powers landing-page social proof)
643app.route("/", publicStatsRoutes);
644
645// Block L3 — Live /demo page + /api/v2/demo/* endpoints
646app.route("/", demoRoutes);
647
2316be6Claude648// Public /status — human-readable platform health page
649app.route("/", statusRoutes);
650
b1be050CC LABS App651// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
652// Mounted near the public status route so the two surfaces are visible
653// side-by-side; routes are gated by isSiteAdmin internally.
654app.route("/", adminStatusRoutes);
655
80bed05Claude656// /help — quickstart + API cheatsheet
657app.route("/", helpRoutes);
658
e0e4219Claude659// /docs — expanded documentation site (getting started, workflow YAML, MCP, API, agents)
660app.route("/", docsRoutes);
661
5f2e749Claude662// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
663// so the new editorial pricing layout wins the route; the legacy marketing
664// pricing remains as a safety net but is shadowed at the router.
665app.route("/", pricingRoutes);
666
e1fc7dbClaude667// /changelog — manually curated platform release history
668app.route("/", changelogRoutes);
669
9f29b65Claude670// Enterprise sales page + contact form lead capture.
671app.route("/", enterpriseRoutes);
672
b0148e9Claude673// /pricing, /features, /about — marketing surface
674app.route("/", marketingRoutes);
675
adf5e18Claude676// /developer-program — partner + marketplace revenue-share page
677app.route("/", developerProgramRoutes);
678
5618f9aClaude679// SEO: robots.txt + sitemap.xml
680app.route("/", seoRoutes);
681
05cdb85Claude682// /api/version — live build SHA + uptime; client poller uses this to
683// surface 'New version available — reload' banners on deploy.
684app.route("/", versionRoutes);
685
699e5c7Claude686// Health dashboard (per-repo health page)
687app.route("/", healthDashboardRoutes);
688
9dd96b9Test User689// Block R1 — site-admin operations console. MUST be mounted BEFORE
690// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
691// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
692app.route("/", adminOpsRoutes);
f2c00b4CC LABS App693// BLOCK W — Self-host status + bootstrap dashboard.
694app.route("/", adminSelfHostRoutes);
826eccfTest User695// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
696app.route("/", adminDiagnoseRoutes);
9dd96b9Test User697
16b325cClaude698// Insights (time-travel, dependencies, rollback)
699app.route("/", insightRoutes);
700
8286942Claude701// Engineering Intelligence Dashboard — /insights + /:owner/:repo/insights/engineering
702app.route("/", engineeringInsightsRoutes);
703
8d1483cClaude704// DORA metrics page (/:owner/:repo/insights/dora)
705app.route("/", doraRoutes);
706
f1ab587Claude707// Command center dashboard
708app.route("/", dashboardRoutes);
709
36b4cbdClaude710// Legal pages (terms, privacy, AUP)
711app.route("/", legalRoutes);
4b66018Claude712// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
713// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
714// /acceptable-use); these are the formal versions that the legal pages
715// internally link to each other.
716app.route("/", legalTermsRoutes);
717app.route("/", legalPrivacyRoutes);
718app.route("/", legalAcceptableUseRoutes);
719app.route("/", legalDmcaRoutes);
36b4cbdClaude720
bdbd0deClaude721// GitHub import / migration
722app.route("/", importRoutes);
14c3cc8Claude723app.route("/", importBulkRoutes);
f390cfaCC LABS App724app.route("/", importSecretsRoutes);
bb2dea9Claude725// GitHub Actions → Gluecron gates.yml importer (stateless converter)
726app.route("/", actionsImporterRoutes);
14c3cc8Claude727app.route("/", migrationRoutes);
ba23fe2Claude728app.route("/", migrationAssistantRoutes);
9a8b8deClaude729// GitHub Org Migration Wizard — live progress bulk importer
730app.route("/", migrateRoutes);
14c3cc8Claude731
732// Spec-to-PR (experimental AI-generated draft PRs)
733app.route("/", specsRoutes);
23d0abfClaude734app.route("/", refactorRoutes);
b665cacClaude735app.route("/", codebaseMigratorRoutes);
bdbd0deClaude736
c81ab7aClaude737// Explore page
738app.route("/", exploreRoutes);
739
59b6fb2Claude740// Onboarding
741app.route("/", onboardingRoutes);
742
0316dbbClaude743// Admin + feature routes
744app.route("/", adminRoutes);
7293c67Claude745app.route("/", adminDeletionsRoutes);
746app.route("/", adminStripeRoutes);
ba9e143Claude747
748// SOC 2 security dashboard + readiness checklist (/admin/security, /admin/soc2)
749app.route("/", adminSecurityRoutes);
509c376Claude750app.route("/", adminIntegrationsRoutes);
bc519aeClaude751app.route("/", adminEnvHealthRoutes);
79ed944Claude752app.route("/", adminAdvancementRoutes);
f764c07Claude753app.route("/", adminDeploysRoutes);
754app.route("/", adminDeploysPageRoutes);
783dd46Claude755app.route("/", adminServerTargetsRoutes);
9aaa128Claude756app.route("/", deployTargetsRoutes);
90c7531Claude757app.route("/", claudeWebRoutes);
9dd96b9Test User758// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude759app.route("/", advisoriesRoutes);
760app.route("/", aiChangelogRoutes);
0a69faaClaude761// "Explain This Repo" — rich structured AI analysis dashboard (mounted before
762// the simpler aiExplainRoutes so the new routes win on /:owner/:repo/explain).
763app.route("/", explainRoutes);
0316dbbClaude764app.route("/", aiExplainRoutes);
2be65d0Claude765app.route("/", archaeologyRoutes);
0316dbbClaude766app.route("/", aiTestsRoutes);
767app.route("/", askRoutes);
38d31d3Claude768app.route("/", repoChatRoutes);
ee7e577Claude769// Personal cross-repo chat — `/chat` (user-scoped). Mounted alongside
770// repoChatRoutes so the two surfaces share the catch-all priority.
771app.route("/", personalChatRoutes);
0316dbbClaude772app.route("/", billingRoutes);
8809b87Claude773app.route("/", billingUsageRoutes);
6778ad2Claude774app.route("/", stripeWebhookRoutes);
0316dbbClaude775app.route("/", codeScanningRoutes);
da3fc18Claude776// Dependency CVE scanner findings page — /:owner/:repo/security/vulnerabilities
777app.route("/", securityRoutes);
0316dbbClaude778app.route("/", commitStatusesRoutes);
779app.route("/", copilotRoutes);
f5d020fClaude780app.route("/", pairProgrammerRoutes);
0316dbbClaude781app.route("/", depUpdaterRoutes);
782app.route("/", depsRoutes);
783app.route("/", discussionsRoutes);
784app.route("/", environmentsRoutes);
4bbacbeClaude785app.route("/", previewsRoutes);
79ed944Claude786app.route("/", docsTrackingRoutes);
0316dbbClaude787app.route("/", followsRoutes);
788app.route("/", gatesRoutes);
789app.route("/", gistsRoutes);
790app.route("/", graphqlRoutes);
2c2163eClaude791app.route("/", mcpRoutes);
0316dbbClaude792app.route("/", marketplaceRoutes);
5ca514aClaude793app.route("/", marketplaceAgentsRoutes);
0316dbbClaude794app.route("/", mergeQueueRoutes);
795app.route("/", mirrorsRoutes);
796app.route("/", orgInsightsRoutes);
b02ce30Claude797app.route("/", orgHealthRoutes);
0316dbbClaude798app.route("/", packagesRoutes);
799app.route("/", packagesApiRoutes);
845fd8aClaude800// OCI / Docker container registry — /v2/* (OCI Distribution Spec v1.0)
801app.route("/", ociRegistryRoutes);
0316dbbClaude802app.route("/", pagesRoutes);
803app.route("/", projectsRoutes);
804app.route("/", protectedTagsRoutes);
805app.route("/", pwaRoutes);
46d6165Claude806app.route("/", installRoutes);
cd4f63bTest User807// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
808app.route("/", dxtRoutes);
662ce86Claude809// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
810// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
811app.route("/", connectClaudeRoutes);
f5b9ef5Claude812// Claude Code Integration Receiver — /api/claude/connect + /api/claude/session.
813app.route("/", claudeIntegration);
814// Connect guide — public onboarding page (/connect/claude-guide).
815app.route("/", connectRoutes);
05ab9b1Claude816// Push Watch — per-commit live status (gates + deploy + latency) at /:owner/:repo/push/:sha
817app.route("/", pushWatchRoutes);
818// Org Secrets Manager — BLOCK M2 — /orgs/:slug/settings/secrets
819app.route("/", orgSecretsRoutes);
a2b3e99Claude820// Cross-repo code search — BLOCK M3 — /search/code + /api/search/code
821app.route("/", crossRepoSearchRoutes);
822// Browser push notifications — BLOCK M4 — /settings/notifications/push + /api/push/*
823app.route("/", pushNotifRoutes);
9fbe6cdClaude824// Developer Velocity Dashboard — BLOCK M9 — /:owner/:repo/insights/velocity
825app.route("/", velocityRoutes);
826// Stale Branch Cleanup — BLOCK M10 — /:owner/:repo/branches/stale
827app.route("/", staleBranchRoutes);
22f43f3Claude828// Repository Pulse — BLOCK M12 — /:owner/:repo/pulse
829app.route("/", pulseRoutes);
74d8c4dClaude830// Repository Health Score — BLOCK M14 — /:owner/:repo/insights/health
831app.route("/", healthScoreRoutes);
77cf834Claude832// Repository Health Score breakdown page — /:owner/:repo/health
833app.route("/", repoHealthRoutes);
74d8c4dClaude834// Hot Files Heatmap — BLOCK M16 — /:owner/:repo/insights/hotfiles
835app.route("/", hotFilesRoutes);
bcc4020Claude836// AI Technical Debt Map — /:owner/:repo/debt-map (visual debt graph + Claude analysis)
837app.route("/", debtMapRoutes);
1d6db4dClaude838// Bus Factor Analysis — /:owner/:repo/insights/bus-factor
839app.route("/", busFactorRoutes);
b02ce30Claude840// Test Gap Detector — /:owner/:repo/insights/test-gaps
841app.route("/", testGapsRoutes);
f5d020fClaude842// Cross-Repo Dependency Impact Detection — /:owner/:repo/pulls/:number/cross-repo-impact
843app.route("/", crossRepoImpactRoutes);
ebbb527Claude844// Hosted Claude tool-use loops — paste loop, get endpoint, billing meter.
845// See src/routes/claude-deploy.tsx + src/lib/hosted-claude-loop.ts.
846app.route("/", claudeDeployRoutes);
0316dbbClaude847app.route("/", releasesRoutes);
848app.route("/", requiredChecksRoutes);
849app.route("/", rulesetsRoutes);
850app.route("/", searchRoutes);
851app.route("/", semanticSearchRoutes);
77cf834Claude852app.route("/", nlSearchRoutes);
0316dbbClaude853app.route("/", signingKeysRoutes);
854app.route("/", sponsorsRoutes);
855app.route("/", ssoRoutes);
3a845e4Claude856// Enterprise per-org SAML 2.0 + OIDC SSO routes
857app.route("/", samlSsoRoutes);
858// SCIM 2.0 user provisioning endpoints
859app.route("/", scimRoutes);
860// Per-org SSO + SCIM admin settings UI
861app.route("/", orgSsoSettingsRoutes);
46d6165Claude862app.route("/", githubOauthRoutes);
582cdacClaude863app.route("/", googleOauthRoutes);
0316dbbClaude864app.route("/", symbolsRoutes);
865app.route("/", templatesRoutes);
866app.route("/", trafficRoutes);
867app.route("/", wikisRoutes);
868app.route("/", workflowsRoutes);
5ff9cc2Claude869app.route("/", workflowArtifactsRoutes);
870app.route("/", workflowSecretsRoutes);
46d6165Claude871app.route("/", sleepModeRoutes);
52ad8b1Claude872app.route("/", vsGithubRoutes);
0316dbbClaude873
45f3b73Claude874// Voice-to-PR — phone-first dictation → spec or issue
875app.route("/", voiceRoutes);
876
3122762Claude877// Blog / Devlog — public posts, no DB
878app.route("/", blogRoutes);
879
cd4f63bTest User880// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
881// before the web catch-all so the bare `/play` literal wins over the
882// `/:owner` user-profile route.
883app.route("/", playgroundRoutes);
884
891efbeClaude885// Shareable AI hours-saved OG image card + landing page.
886// /share/hours-saved?user=:username → 1200×630 SVG (og:image)
887// /share/:username → HTML page with og:image meta + Twitter share
888// Mounted BEFORE webRoutes so /share/* doesn't fall through to the /:owner profile route.
889app.route("/", shareRoutes);
890
79136bbClaude891// Web UI (catch-all, must be last)
892app.route("/", webRoutes);
893
c63b860Claude894// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
895// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude896app.notFound((c) => {
36cc17aClaude897 const user = c.get("user") ?? null;
79136bbClaude898 return c.html(
c63b860Claude899 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude900 404
901 );
902});
903
c63b860Claude904// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
905// view. Trace block only shown outside production.
79136bbClaude906app.onError((err, c) => {
80bed05Claude907 reportError(err, {
908 requestId: c.get("requestId"),
909 path: c.req.path,
910 method: c.req.method,
911 });
c63b860Claude912 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
913 // back to the context value set by request-context middleware.
914 const requestId =
915 c.req.header("x-request-id") ||
916 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude917 const user = c.get("user") ?? null;
c63b860Claude918 const trace =
919 process.env.NODE_ENV !== "production" && err && err.message
920 ? err.message
921 : undefined;
79136bbClaude922 return c.html(
c63b860Claude923 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude924 500
925 );
926});
927
928export default app;