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.tsxBlame913 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";
9a8b8deClaude83import migrateRoutes from "./routes/migrate";
14c3cc8Claude84import specsRoutes from "./routes/specs";
23d0abfClaude85import refactorRoutes from "./routes/refactors";
b665cacClaude86import codebaseMigratorRoutes from "./routes/codebase-migrator";
79136bbClaude87import webRoutes from "./routes/web";
0316dbbClaude88import hookRoutes from "./routes/hooks";
89import eventsRoutes from "./routes/events";
90import passkeyRoutes from "./routes/passkeys";
91import oauthRoutes from "./routes/oauth";
92import developerAppsRoutes from "./routes/developer-apps";
93import themeRoutes from "./routes/theme";
94import auditRoutes from "./routes/audit";
95import reactionRoutes from "./routes/reactions";
96import savedReplyRoutes from "./routes/saved-replies";
97import deploymentRoutes from "./routes/deployments";
98import orgRoutes from "./routes/orgs";
99import notificationRoutes from "./routes/notifications";
100import onboardingRoutes from "./routes/onboarding";
101import adminRoutes from "./routes/admin";
7293c67Claude102import adminDeletionsRoutes from "./routes/admin-deletions";
103import adminStripeRoutes from "./routes/admin-stripe";
f764c07Claude104import adminDeploysRoutes from "./routes/admin-deploys";
105import adminDeploysPageRoutes from "./routes/admin-deploys-page";
783dd46Claude106import adminServerTargetsRoutes from "./routes/admin-server-targets";
9aaa128Claude107import deployTargetsRoutes from "./routes/deploy-targets";
90c7531Claude108import claudeWebRoutes from "./routes/claude-web";
9dd96b9Test User109import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App110import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User111import adminDiagnoseRoutes from "./routes/admin-diagnose";
509c376Claude112import adminIntegrationsRoutes from "./routes/admin-integrations";
bc519aeClaude113import adminEnvHealthRoutes from "./routes/admin-env-health";
79ed944Claude114import adminAdvancementRoutes from "./routes/admin-advancement";
ba9e143Claude115import adminSecurityRoutes from "./routes/admin-security";
116import settingsSessionsRoutes from "./routes/settings-sessions";
0316dbbClaude117import advisoriesRoutes from "./routes/advisories";
118import aiChangelogRoutes from "./routes/ai-changelog";
0a69faaClaude119import explainRoutes from "./routes/explain";
0316dbbClaude120import aiExplainRoutes from "./routes/ai-explain";
121import aiTestsRoutes from "./routes/ai-tests";
122import askRoutes from "./routes/ask";
38d31d3Claude123import repoChatRoutes from "./routes/repo-chat";
ee7e577Claude124import personalChatRoutes from "./routes/personal-chat";
0316dbbClaude125import billingRoutes from "./routes/billing";
8809b87Claude126import billingUsageRoutes from "./routes/billing-usage";
6778ad2Claude127import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude128import codeScanningRoutes from "./routes/code-scanning";
da3fc18Claude129import securityRoutes from "./routes/security";
0316dbbClaude130import commitStatusesRoutes from "./routes/commit-statuses";
131import copilotRoutes from "./routes/copilot";
f5d020fClaude132import { pairProgrammerRoutes } from "./routes/pair-programmer";
0316dbbClaude133import depUpdaterRoutes from "./routes/dep-updater";
134import depsRoutes from "./routes/deps";
135import discussionsRoutes from "./routes/discussions";
136import environmentsRoutes from "./routes/environments";
4bbacbeClaude137import previewsRoutes from "./routes/previews";
79ed944Claude138import docsTrackingRoutes from "./routes/docs-tracking";
0316dbbClaude139import followsRoutes from "./routes/follows";
140import gatesRoutes from "./routes/gates";
141import gistsRoutes from "./routes/gists";
142import graphqlRoutes from "./routes/graphql";
2c2163eClaude143import mcpRoutes from "./routes/mcp";
0316dbbClaude144import marketplaceRoutes from "./routes/marketplace";
5ca514aClaude145import marketplaceAgentsRoutes from "./routes/marketplace-agents";
0316dbbClaude146import mergeQueueRoutes from "./routes/merge-queue";
147import mirrorsRoutes from "./routes/mirrors";
148import orgInsightsRoutes from "./routes/org-insights";
149import packagesRoutes from "./routes/packages";
150import packagesApiRoutes from "./routes/packages-api";
845fd8aClaude151import ociRegistryRoutes from "./routes/oci-registry";
0316dbbClaude152import pagesRoutes from "./routes/pages";
153import projectsRoutes from "./routes/projects";
154import protectedTagsRoutes from "./routes/protected-tags";
155import pwaRoutes from "./routes/pwa";
46d6165Claude156import installRoutes from "./routes/install";
cd4f63bTest User157import dxtRoutes from "./routes/dxt";
662ce86Claude158import connectClaudeRoutes from "./routes/connect-claude";
ebbb527Claude159import claudeDeployRoutes from "./routes/claude-deploy";
f5b9ef5Claude160import claudeIntegration from "./routes/claude-integration";
161import connectRoutes from "./routes/connect";
05ab9b1Claude162import pushWatchRoutes from "./routes/push-watch";
163import orgSecretsRoutes from "./routes/org-secrets";
0316dbbClaude164import releasesRoutes from "./routes/releases";
165import requiredChecksRoutes from "./routes/required-checks";
166import rulesetsRoutes from "./routes/rulesets";
167import searchRoutes from "./routes/search";
168import semanticSearchRoutes from "./routes/semantic-search";
77cf834Claude169import nlSearchRoutes from "./routes/nl-search";
0316dbbClaude170import signingKeysRoutes from "./routes/signing-keys";
171import sponsorsRoutes from "./routes/sponsors";
172import ssoRoutes from "./routes/sso";
3a845e4Claude173import samlSsoRoutes from "./routes/saml-sso";
174import scimRoutes from "./routes/scim";
175import orgSsoSettingsRoutes from "./routes/org-sso-settings";
46d6165Claude176import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude177import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude178import symbolsRoutes from "./routes/symbols";
179import templatesRoutes from "./routes/templates";
180import trafficRoutes from "./routes/traffic";
181import wikisRoutes from "./routes/wikis";
182import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude183import workflowArtifactsRoutes from "./routes/workflow-artifacts";
184import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude185import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude186import standupRoutes from "./routes/standups";
52ad8b1Claude187import vsGithubRoutes from "./routes/vs-github";
45f3b73Claude188import voiceRoutes from "./routes/voice-to-pr";
3122762Claude189import blogRoutes from "./routes/blog";
cd4f63bTest User190import playgroundRoutes from "./routes/playground";
a2b3e99Claude191import crossRepoSearchRoutes from "./routes/cross-repo-search";
192import pushNotifRoutes from "./routes/push-notifications";
9fbe6cdClaude193import velocityRoutes from "./routes/velocity";
194import { staleBranchRoutes } from "./routes/stale-branches";
22f43f3Claude195import pulseRoutes from "./routes/pulse";
74d8c4dClaude196import healthScoreRoutes from "./routes/health-score";
77cf834Claude197import repoHealthRoutes from "./routes/repo-health";
74d8c4dClaude198import hotFilesRoutes from "./routes/hot-files";
bcc4020Claude199import debtMapRoutes from "./routes/debt-map";
1d6db4dClaude200import busFactorRoutes from "./routes/bus-factor";
f5d020fClaude201import crossRepoImpactRoutes from "./routes/cross-repo-impact";
adf5e18Claude202import developerProgramRoutes from "./routes/developer-program";
891efbeClaude203import shareRoutes from "./routes/share";
70e3293Claude204import incidentHookRoutes from "./routes/incident-hooks";
77cf834Claude205import workspaceRoutes from "./routes/ai-workspace";
59b6fb2Claude206import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
207import { csrfToken, csrfProtect } from "./middleware/csrf";
f5b9ef5Claude208import { noCache } from "./middleware/no-cache";
79136bbClaude209
2316901Claude210import type { AuthEnv } from "./middleware/auth";
bf19c50Test User211import { softAuth } from "./middleware/auth";
2316901Claude212
213const app = new Hono<AuthEnv>();
79136bbClaude214
3ef4c9dClaude215// Request context (request ID, start time) runs before everything else
216app.use("*", requestContext);
05b973eClaude217// Middleware — compression first (wraps all responses)
218app.use("*", compress());
f1ffd50Claude219
220// ETag middleware — returns 304 Not Modified on unchanged responses.
221// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
222// SSE + the API surface where it would interfere with streaming.
223app.use("*", async (c, next) => {
224 const p = c.req.path;
225 if (
226 p.includes(".git/") ||
227 p.startsWith("/live-events") ||
228 p.startsWith("/api/events/deploy") ||
3c03977Claude229 p.startsWith("/admin/status") ||
230 // PR live co-editing SSE stream — never etag streaming responses.
231 /^\/api\/v2\/pulls\/[^/]+\/live(\/|$)/.test(p)
f1ffd50Claude232 ) {
233 return next();
234 }
235 return etag()(c, next);
236});
237
238// Cache-Control middleware — sets sensible defaults on public, anonymous
239// requests. Crontech (when wired as our edge layer) and downstream
240// browsers will honor these. Auth'd users get private,no-store
241// automatically — we never cache responses tied to a session.
242app.use("*", async (c, next) => {
243 await next();
244 // Don't overwrite explicit headers set by route handlers — BUT the
245 // ETag middleware unconditionally sets "private, no-cache, must-
246 // revalidate" so we have to treat that specific value as "no
247 // policy chosen yet" and apply ours. Any route that explicitly set
248 // a different cache-control wins.
249 const existing = c.res.headers.get("cache-control");
250 const etagDefault =
251 existing === "private, no-cache, must-revalidate" ||
252 existing === "no-cache";
253 if (existing && !etagDefault) return;
254 // Anything past auth: private + no-store (avoid leaking session
255 // content into shared caches). softAuth runs before this on the
256 // request, but the response side is what we're stamping.
257 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
258 const p = c.req.path;
259 // Always private for known-authed paths regardless of cookie.
260 if (
261 p.startsWith("/admin") ||
262 p.startsWith("/settings") ||
263 p.startsWith("/dashboard") ||
264 p.startsWith("/notifications") ||
265 p.startsWith("/connect/") ||
266 hasSession
267 ) {
268 c.res.headers.set("cache-control", "private, no-store");
269 return;
270 }
271 // Public marketing surfaces — short edge cache, longer browser cache,
272 // stale-while-revalidate so the user never waits on a stale fetch.
273 const isMarketing =
274 p === "/" ||
275 p === "/features" ||
276 p === "/pricing" ||
277 p === "/about" ||
278 p === "/vs-github" ||
279 p === "/explore" ||
280 p === "/help" ||
281 p === "/changelog" ||
9f29b65Claude282 p === "/enterprise" ||
f1ffd50Claude283 p.startsWith("/legal/") ||
284 p === "/terms" ||
285 p === "/privacy" ||
286 p === "/acceptable-use" ||
287 p.startsWith("/docs/");
288 if (isMarketing) {
289 c.res.headers.set(
290 "cache-control",
291 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
292 );
293 return;
294 }
295 // Public repo browse pages — cache aggressively. Edge invalidates
296 // on push via the post-receive hook (future Crontech surge purge).
297 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
298 c.res.headers.set(
299 "cache-control",
300 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
301 );
302 return;
303 }
304 // Default: don't cache anything we haven't explicitly opted in.
305 c.res.headers.set("cache-control", "private, no-store");
306});
05b973eClaude307// Logger only on non-git routes to avoid overhead on clone/push
308app.use("*", async (c, next) => {
309 if (c.req.path.includes(".git/")) return next();
310 return logger()(c, next);
311});
79136bbClaude312app.use("/api/*", cors());
bf19c50Test User313// Global softAuth — populates c.get("user") for every downstream middleware
314// + route. This was previously per-route, which meant rate-limit middleware
315// (and anything else inspecting auth state) always saw a null user. Keep
316// individual routes free to add requireAuth on top for hard gating; this
317// just establishes the user object cheaply.
318app.use("*", softAuth);
290ea77Claude319
36cc17aClaude320// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude321// pre-redesign markup. JSON / static assets keep their own cache rules; only
322// text/html responses get the no-cache stamp. Without this, every push to
323// main left users staring at cached 80s-looking pages from before the design
324// landed.
36cc17aClaude325//
326// We deliberately use `private, no-cache, must-revalidate` rather than
327// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
328// which makes every Back/Forward press a cold server round-trip — that
329// contributed to the "every nav feels like a fresh login" UX complaint.
330// `no-cache` still revalidates on direct fetch but lets bfcache hold the
331// page in memory between navigations.
290ea77Claude332app.use("*", async (c, next) => {
333 await next();
334 const ct = c.res.headers.get("content-type") || "";
335 if (ct.startsWith("text/html")) {
36cc17aClaude336 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude337 }
338});
826eccfTest User339// Rate-limit API + auth endpoints.
340//
a41e675Test User341// `/api/*`: 1000/min per IP — generous so an admin clicking around the
342// operator console (or a CDN/proxy concentrating multiple users behind one
343// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
344// rate limits below, not this one.
345//
346// `authedMultiplier` is set but only fires when an upstream middleware has
347// already populated c.get("user") — most app.use() chains apply softAuth
348// per-route, so the multiplier is best-effort. Keep the anonymous base
349// high enough that humans never feel it.
350//
351// Skip-paths: dashboard plumbing endpoints that the layout polls on a
352// fixed cadence and that we don't want consuming any bucket:
353// /api/version — layout polls every 15s
826eccfTest User354// /api/notifications/count — nav bell unread-count fetcher
355// /pwa/vapid-public-key — fetched once per push-notification opt-in
356app.use(
357 "/api/*",
a41e675Test User358 rateLimit(1000, 60_000, "api", {
826eccfTest User359 authedMultiplier: 4,
360 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
361 })
362);
0316dbbClaude363app.use("/login", rateLimit(20, 60_000, "login"));
364app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude365// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
366app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User367// BLOCK Q2 — throttle magic-link sign-in for the same reason.
368app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude369
59b6fb2Claude370// CSRF protection — set token on all requests, validate on mutations
371app.use("*", csrfToken);
372app.use("*", csrfProtect);
373
45e31d0Claude374// Rate limit auth routes
375app.use("/login", authRateLimit);
376app.use("/register", authRateLimit);
377
59b6fb2Claude378// Rate limit git operations
379app.use("/:owner/:repo.git/*", gitRateLimit);
380
381// Rate limit search
382app.use("/:owner/:repo/search", searchRateLimit);
383app.use("/explore", searchRateLimit);
79136bbClaude384
f5b9ef5Claude385// No-cache for HTML — ensures browsers and proxies never serve stale pages.
386// The middleware only stamps text/html responses so static assets keep
387// their own cache policies unchanged.
388app.use("*", noCache);
389
79136bbClaude390// Git Smart HTTP protocol routes (must be before web routes)
391app.route("/", gitRoutes);
392
45e31d0Claude393// REST API v1 (legacy)
79136bbClaude394app.route("/", apiRoutes);
395
52ad8b1Claude396// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
397// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
398// router's catch-shape, and BEFORE adminRoutes so the live /demo page
399// wins over the legacy /demo redirect in src/routes/admin.tsx.
400app.route("/", demoRoutes);
401
0316dbbClaude402// REST API v2 (basePath /api/v2)
403app.route("/", apiV2Routes);
404
e75eddcClaude405// Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage).
406// Mounted alongside apiV2Routes (its own basePath, no path conflict).
407app.route("/", agentsRoutes);
408
ef3fd93Claude409// Multi-agent pipeline UI — /:owner/:repo/agents (list, new, live view).
410// Must be before webRoutes (the catch-all) so the /agents sub-paths are
411// resolved before the generic tree/blob route takes over.
412app.route("/", agentPipelinesRoutes);
413
ad6d4adClaude414// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
415app.route("/", hookRoutes);
21f8dbdClaude416app.route("/api/events", eventsRoutes);
ad6d4adClaude417
45e31d0Claude418// API documentation
419app.route("/", apiDocsRoutes);
4a80519Claude420app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude421// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
422app.route("/", pullsDashboardRoutes);
e9aa4d8Claude423// Issue command center — global issue dashboard with AI-triage + autopilot signal
424app.route("/", issuesDashboardRoutes);
425// Personal activity timeline — every event across the user's repos, with
426// AI-driven events surfaced separately (the Gluecron differentiator).
427app.route("/", activityRoutes);
428// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
429app.route("/", inboxRoutes);
56801e1Claude430// AI standup feed — daily / weekly Claude-generated team brief
431app.route("/", standupRoutes);
cc34156Claude432// Smart morning digest — AI-curated daily developer queue (/digest)
433app.route("/", digestRoutes);
79136bbClaude434
435// Auth routes (register, login, logout)
436app.route("/", authRoutes);
437
c63b860Claude438// BLOCK P1 — Password reset (forgot-password + reset-password)
439app.route("/", passwordResetRoutes);
440
441// BLOCK P2 — Email verification (verify-email + resend)
442app.route("/", emailVerificationRoutes);
443
cd4f63bTest User444// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
445app.route("/", magicLinkRoutes);
446
79136bbClaude447// Settings routes (profile, SSH keys)
448app.route("/", settingsRoutes);
449
ba9e143Claude450// Session management (SOC 2 CC6.1 — /settings/sessions)
451app.route("/", settingsSessionsRoutes);
452
7298a17Claude453// 2FA / TOTP settings (Block B4)
454app.route("/", settings2faRoutes);
455
e75eddcClaude456// Agent multiplayer — /settings/agents management UI
457app.route("/", settingsAgentsRoutes);
458
1d4ff60Claude459// Chat integrations — Slack / Discord / Teams (/settings/integrations
460// + /api/v2/integrations/{slack,discord}/*). See src/lib/chat-bot.ts.
461app.route("/", settingsIntegrationsRoutes);
462app.route("/", integrationsChatRoutes);
463
2df1f8cClaude464// WebAuthn / passkey routes (Block B5)
465app.route("/", passkeyRoutes);
466
058d752Claude467// OAuth 2.0 provider (Block B6)
468app.route("/", oauthRoutes);
469app.route("/", developerAppsRoutes);
470
6fc53bdClaude471// Theme toggle (dark/light cookie)
472app.route("/", themeRoutes);
473
474// Audit log UI
475app.route("/", auditRoutes);
476
477// Reactions API (issues, PRs, comments)
478app.route("/", reactionRoutes);
479
24cf2caClaude480// Saved replies (per-user canned comment templates)
481app.route("/", savedReplyRoutes);
482
483// Environments + deployment history UI
484app.route("/", deploymentRoutes);
485
6563f0aClaude486// Organizations + teams (Block B1)
487app.route("/", orgRoutes);
488
c81ab7aClaude489// API tokens
490app.route("/", tokenRoutes);
491
59b6fb2Claude492// Notifications
3ef4c9dClaude493app.route("/", notificationRoutes);
494
79136bbClaude495// Repo settings (description, visibility, delete)
496app.route("/", repoSettings);
479dcd9Claude497// Per-repo automation settings (off / suggest / auto) — migration 0106
498app.route("/", automationSettingsRoutes);
79136bbClaude499
23d1a81Claude500// Repo collaborators (add/list/remove)
501app.route("/", collaboratorRoutes);
502
04f6b7fClaude503// Team-based repo collaborators (invite a whole team)
504app.route("/", teamCollaboratorRoutes);
505
506// Collaborator invite accept flow (token-based)
507app.route("/", invitesRoutes);
508
509// Real-time SSE endpoint (topic-based live updates)
510app.route("/", liveEventsRoutes);
511
3c03977Claude512// PR live co-editing — presence + cursors + content sync via SSE.
513app.route("/", prLiveRoutes);
514
c81ab7aClaude515// Webhooks management
516app.route("/", webhookRoutes);
517
79136bbClaude518// Compare view (branch diffs)
519app.route("/", compareRoutes);
520
521// Issue tracker
522app.route("/", issueRoutes);
523
85c4e13Claude524// Milestones — group issues + PRs toward a shared goal with due dates + progress tracking.
525// Mounted after issueRoutes so /:owner/:repo/issues/* paths win before the milestone patterns.
526app.route("/", milestonesRoutes);
527
f928118Claude528// Ship Agent — autonomous AI feature implementation
529app.route("/", shipAgentRoutes);
530
77cf834Claude531// AI Copilot Workspace — issue-to-PR autonomous agent
532app.route("/", workspaceRoutes);
533
cb5a796Claude534// Comment moderation queue — owner-only `/:owner/:repo/comments/pending`
535// + per-row approve/reject/spam actions. Mounted before `pullRoutes` so
536// the `/:owner/:repo/comments/*` paths resolve before the broader PR
537// patterns kick in.
538app.route("/", commentModerationRoutes);
539
0074234Claude540// Pull requests
541app.route("/", pullRoutes);
09d5f39Claude542
543// /stage PR preview — serve built static files from .stage-previews/{jobId}/
544// Registered immediately after pullRoutes so the path `/preview/:id/*` is
545// specific enough to never clash with repo browse routes (`/:owner/:repo/*`).
546app.get("/preview/:stageJobId/*", async (c) => {
547 const { stageJobId } = c.req.param();
548 // Validate job ID format (UUID)
549 if (!/^[0-9a-f-]{32,}$/i.test(stageJobId)) {
550 return c.text("Not found", 404);
551 }
552 const { getPreviewDir, isPreviewExpired } = await import("./lib/pr-stage");
553 if (isPreviewExpired(stageJobId)) {
554 return c.html(
555 "<html><body style='font-family:sans-serif;padding:40px;color:#888'>" +
556 "<h2>Preview expired</h2><p>This stage preview has expired (48h TTL). " +
557 "Comment <code>/stage</code> on the PR to redeploy.</p></body></html>",
558 410
559 );
560 }
561 const { join } = await import("path");
562 const previewDir = getPreviewDir(stageJobId);
563 // Extract the wildcard path after /preview/:id/
564 const rawPath = c.req.path.replace(/^\/preview\/[^/]+/, "") || "/";
565 const filePath = rawPath === "/" || rawPath === "" ? "/index.html" : rawPath;
566 const fullPath = join(previewDir, filePath);
567 const file = Bun.file(fullPath);
568 if (!(await file.exists())) {
569 // Try index.html fallback (SPA behaviour)
570 const indexFile = Bun.file(join(previewDir, "index.html"));
571 if (await indexFile.exists()) {
572 const html = await indexFile.text();
573 return c.html(html);
574 }
575 return c.text("Not found", 404);
576 }
577 const content = await file.arrayBuffer();
578 const ext = fullPath.split(".").pop()?.toLowerCase() ?? "";
579 const contentTypeMap: Record<string, string> = {
580 html: "text/html; charset=utf-8",
581 htm: "text/html; charset=utf-8",
582 css: "text/css; charset=utf-8",
583 js: "application/javascript; charset=utf-8",
584 mjs: "application/javascript; charset=utf-8",
585 json: "application/json; charset=utf-8",
586 png: "image/png",
587 jpg: "image/jpeg",
588 jpeg: "image/jpeg",
589 gif: "image/gif",
590 svg: "image/svg+xml",
591 ico: "image/x-icon",
592 webp: "image/webp",
593 woff: "font/woff",
594 woff2: "font/woff2",
595 ttf: "font/ttf",
596 txt: "text/plain; charset=utf-8",
597 xml: "application/xml",
598 webmanifest: "application/manifest+json",
599 };
600 const ct = contentTypeMap[ext] ?? "application/octet-stream";
601 return c.body(content, 200, {
602 "content-type": ct,
603 "cache-control": "public, max-age=300",
604 "x-stage-job-id": stageJobId,
605 });
606});
607
79ed944Claude608// PR sandboxes — runnable per-PR environments. Migration 0067.
609app.route("/", prSandboxRoutes);
0074234Claude610
9b3a183Claude611// Cloud dev environments — hosted VS Code in the browser. Migration 0072.
612app.route("/", devEnvRoutes);
613
c81ab7aClaude614// Fork
615app.route("/", forkRoutes);
616
0074234Claude617// Web file editor
618app.route("/", editorRoutes);
619
6f2809fClaude620// AI editor API routes (inline suggestions, explain, fix)
621app.route("/", aiEditorRoutes);
622
43de941Claude623// Contributors
624app.route("/", contributorRoutes);
625
699e5c7Claude626// Health liveness + metrics endpoints
2c34075Claude627app.route("/", healthRoutes);
628
f295f78Dictation App629// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
630app.route("/api/platform-status", platformStatus);
631
52ad8b1Claude632// Block L4 — Public stats counters (powers landing-page social proof)
633app.route("/", publicStatsRoutes);
634
635// Block L3 — Live /demo page + /api/v2/demo/* endpoints
636app.route("/", demoRoutes);
637
2316be6Claude638// Public /status — human-readable platform health page
639app.route("/", statusRoutes);
640
b1be050CC LABS App641// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
642// Mounted near the public status route so the two surfaces are visible
643// side-by-side; routes are gated by isSiteAdmin internally.
644app.route("/", adminStatusRoutes);
645
80bed05Claude646// /help — quickstart + API cheatsheet
647app.route("/", helpRoutes);
648
e0e4219Claude649// /docs — expanded documentation site (getting started, workflow YAML, MCP, API, agents)
650app.route("/", docsRoutes);
651
5f2e749Claude652// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
653// so the new editorial pricing layout wins the route; the legacy marketing
654// pricing remains as a safety net but is shadowed at the router.
655app.route("/", pricingRoutes);
656
e1fc7dbClaude657// /changelog — manually curated platform release history
658app.route("/", changelogRoutes);
659
9f29b65Claude660// Enterprise sales page + contact form lead capture.
661app.route("/", enterpriseRoutes);
662
b0148e9Claude663// /pricing, /features, /about — marketing surface
664app.route("/", marketingRoutes);
665
adf5e18Claude666// /developer-program — partner + marketplace revenue-share page
667app.route("/", developerProgramRoutes);
668
5618f9aClaude669// SEO: robots.txt + sitemap.xml
670app.route("/", seoRoutes);
671
05cdb85Claude672// /api/version — live build SHA + uptime; client poller uses this to
673// surface 'New version available — reload' banners on deploy.
674app.route("/", versionRoutes);
675
699e5c7Claude676// Health dashboard (per-repo health page)
677app.route("/", healthDashboardRoutes);
678
9dd96b9Test User679// Block R1 — site-admin operations console. MUST be mounted BEFORE
680// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
681// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
682app.route("/", adminOpsRoutes);
f2c00b4CC LABS App683// BLOCK W — Self-host status + bootstrap dashboard.
684app.route("/", adminSelfHostRoutes);
826eccfTest User685// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
686app.route("/", adminDiagnoseRoutes);
9dd96b9Test User687
16b325cClaude688// Insights (time-travel, dependencies, rollback)
689app.route("/", insightRoutes);
690
8286942Claude691// Engineering Intelligence Dashboard — /insights + /:owner/:repo/insights/engineering
692app.route("/", engineeringInsightsRoutes);
693
8d1483cClaude694// DORA metrics page (/:owner/:repo/insights/dora)
695app.route("/", doraRoutes);
696
f1ab587Claude697// Command center dashboard
698app.route("/", dashboardRoutes);
699
36b4cbdClaude700// Legal pages (terms, privacy, AUP)
701app.route("/", legalRoutes);
4b66018Claude702// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
703// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
704// /acceptable-use); these are the formal versions that the legal pages
705// internally link to each other.
706app.route("/", legalTermsRoutes);
707app.route("/", legalPrivacyRoutes);
708app.route("/", legalAcceptableUseRoutes);
709app.route("/", legalDmcaRoutes);
36b4cbdClaude710
bdbd0deClaude711// GitHub import / migration
712app.route("/", importRoutes);
14c3cc8Claude713app.route("/", importBulkRoutes);
f390cfaCC LABS App714app.route("/", importSecretsRoutes);
bb2dea9Claude715// GitHub Actions → Gluecron gates.yml importer (stateless converter)
716app.route("/", actionsImporterRoutes);
14c3cc8Claude717app.route("/", migrationRoutes);
9a8b8deClaude718// GitHub Org Migration Wizard — live progress bulk importer
719app.route("/", migrateRoutes);
14c3cc8Claude720
721// Spec-to-PR (experimental AI-generated draft PRs)
722app.route("/", specsRoutes);
23d0abfClaude723app.route("/", refactorRoutes);
b665cacClaude724app.route("/", codebaseMigratorRoutes);
bdbd0deClaude725
c81ab7aClaude726// Explore page
727app.route("/", exploreRoutes);
728
59b6fb2Claude729// Onboarding
730app.route("/", onboardingRoutes);
731
0316dbbClaude732// Admin + feature routes
733app.route("/", adminRoutes);
7293c67Claude734app.route("/", adminDeletionsRoutes);
735app.route("/", adminStripeRoutes);
ba9e143Claude736
737// SOC 2 security dashboard + readiness checklist (/admin/security, /admin/soc2)
738app.route("/", adminSecurityRoutes);
509c376Claude739app.route("/", adminIntegrationsRoutes);
bc519aeClaude740app.route("/", adminEnvHealthRoutes);
79ed944Claude741app.route("/", adminAdvancementRoutes);
f764c07Claude742app.route("/", adminDeploysRoutes);
743app.route("/", adminDeploysPageRoutes);
783dd46Claude744app.route("/", adminServerTargetsRoutes);
9aaa128Claude745app.route("/", deployTargetsRoutes);
90c7531Claude746app.route("/", claudeWebRoutes);
9dd96b9Test User747// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude748app.route("/", advisoriesRoutes);
749app.route("/", aiChangelogRoutes);
0a69faaClaude750// "Explain This Repo" — rich structured AI analysis dashboard (mounted before
751// the simpler aiExplainRoutes so the new routes win on /:owner/:repo/explain).
752app.route("/", explainRoutes);
0316dbbClaude753app.route("/", aiExplainRoutes);
754app.route("/", aiTestsRoutes);
755app.route("/", askRoutes);
38d31d3Claude756app.route("/", repoChatRoutes);
ee7e577Claude757// Personal cross-repo chat — `/chat` (user-scoped). Mounted alongside
758// repoChatRoutes so the two surfaces share the catch-all priority.
759app.route("/", personalChatRoutes);
0316dbbClaude760app.route("/", billingRoutes);
8809b87Claude761app.route("/", billingUsageRoutes);
6778ad2Claude762app.route("/", stripeWebhookRoutes);
0316dbbClaude763app.route("/", codeScanningRoutes);
da3fc18Claude764// Dependency CVE scanner findings page — /:owner/:repo/security/vulnerabilities
765app.route("/", securityRoutes);
0316dbbClaude766app.route("/", commitStatusesRoutes);
767app.route("/", copilotRoutes);
f5d020fClaude768app.route("/", pairProgrammerRoutes);
0316dbbClaude769app.route("/", depUpdaterRoutes);
770app.route("/", depsRoutes);
771app.route("/", discussionsRoutes);
772app.route("/", environmentsRoutes);
4bbacbeClaude773app.route("/", previewsRoutes);
79ed944Claude774app.route("/", docsTrackingRoutes);
0316dbbClaude775app.route("/", followsRoutes);
776app.route("/", gatesRoutes);
777app.route("/", gistsRoutes);
778app.route("/", graphqlRoutes);
2c2163eClaude779app.route("/", mcpRoutes);
0316dbbClaude780app.route("/", marketplaceRoutes);
5ca514aClaude781app.route("/", marketplaceAgentsRoutes);
0316dbbClaude782app.route("/", mergeQueueRoutes);
783app.route("/", mirrorsRoutes);
784app.route("/", orgInsightsRoutes);
785app.route("/", packagesRoutes);
786app.route("/", packagesApiRoutes);
845fd8aClaude787// OCI / Docker container registry — /v2/* (OCI Distribution Spec v1.0)
788app.route("/", ociRegistryRoutes);
0316dbbClaude789app.route("/", pagesRoutes);
790app.route("/", projectsRoutes);
791app.route("/", protectedTagsRoutes);
792app.route("/", pwaRoutes);
46d6165Claude793app.route("/", installRoutes);
cd4f63bTest User794// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
795app.route("/", dxtRoutes);
662ce86Claude796// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
797// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
798app.route("/", connectClaudeRoutes);
f5b9ef5Claude799// Claude Code Integration Receiver — /api/claude/connect + /api/claude/session.
800app.route("/", claudeIntegration);
801// Connect guide — public onboarding page (/connect/claude-guide).
802app.route("/", connectRoutes);
05ab9b1Claude803// Push Watch — per-commit live status (gates + deploy + latency) at /:owner/:repo/push/:sha
804app.route("/", pushWatchRoutes);
805// Org Secrets Manager — BLOCK M2 — /orgs/:slug/settings/secrets
806app.route("/", orgSecretsRoutes);
a2b3e99Claude807// Cross-repo code search — BLOCK M3 — /search/code + /api/search/code
808app.route("/", crossRepoSearchRoutes);
809// Browser push notifications — BLOCK M4 — /settings/notifications/push + /api/push/*
810app.route("/", pushNotifRoutes);
9fbe6cdClaude811// Developer Velocity Dashboard — BLOCK M9 — /:owner/:repo/insights/velocity
812app.route("/", velocityRoutes);
813// Stale Branch Cleanup — BLOCK M10 — /:owner/:repo/branches/stale
814app.route("/", staleBranchRoutes);
22f43f3Claude815// Repository Pulse — BLOCK M12 — /:owner/:repo/pulse
816app.route("/", pulseRoutes);
74d8c4dClaude817// Repository Health Score — BLOCK M14 — /:owner/:repo/insights/health
818app.route("/", healthScoreRoutes);
77cf834Claude819// Repository Health Score breakdown page — /:owner/:repo/health
820app.route("/", repoHealthRoutes);
74d8c4dClaude821// Hot Files Heatmap — BLOCK M16 — /:owner/:repo/insights/hotfiles
822app.route("/", hotFilesRoutes);
bcc4020Claude823// AI Technical Debt Map — /:owner/:repo/debt-map (visual debt graph + Claude analysis)
824app.route("/", debtMapRoutes);
1d6db4dClaude825// Bus Factor Analysis — /:owner/:repo/insights/bus-factor
826app.route("/", busFactorRoutes);
f5d020fClaude827// Cross-Repo Dependency Impact Detection — /:owner/:repo/pulls/:number/cross-repo-impact
828app.route("/", crossRepoImpactRoutes);
ebbb527Claude829// Hosted Claude tool-use loops — paste loop, get endpoint, billing meter.
830// See src/routes/claude-deploy.tsx + src/lib/hosted-claude-loop.ts.
831app.route("/", claudeDeployRoutes);
0316dbbClaude832app.route("/", releasesRoutes);
833app.route("/", requiredChecksRoutes);
834app.route("/", rulesetsRoutes);
835app.route("/", searchRoutes);
836app.route("/", semanticSearchRoutes);
77cf834Claude837app.route("/", nlSearchRoutes);
0316dbbClaude838app.route("/", signingKeysRoutes);
839app.route("/", sponsorsRoutes);
840app.route("/", ssoRoutes);
3a845e4Claude841// Enterprise per-org SAML 2.0 + OIDC SSO routes
842app.route("/", samlSsoRoutes);
843// SCIM 2.0 user provisioning endpoints
844app.route("/", scimRoutes);
845// Per-org SSO + SCIM admin settings UI
846app.route("/", orgSsoSettingsRoutes);
46d6165Claude847app.route("/", githubOauthRoutes);
582cdacClaude848app.route("/", googleOauthRoutes);
0316dbbClaude849app.route("/", symbolsRoutes);
850app.route("/", templatesRoutes);
851app.route("/", trafficRoutes);
852app.route("/", wikisRoutes);
853app.route("/", workflowsRoutes);
5ff9cc2Claude854app.route("/", workflowArtifactsRoutes);
855app.route("/", workflowSecretsRoutes);
46d6165Claude856app.route("/", sleepModeRoutes);
52ad8b1Claude857app.route("/", vsGithubRoutes);
0316dbbClaude858
45f3b73Claude859// Voice-to-PR — phone-first dictation → spec or issue
860app.route("/", voiceRoutes);
861
3122762Claude862// Blog / Devlog — public posts, no DB
863app.route("/", blogRoutes);
864
cd4f63bTest User865// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
866// before the web catch-all so the bare `/play` literal wins over the
867// `/:owner` user-profile route.
868app.route("/", playgroundRoutes);
869
891efbeClaude870// Shareable AI hours-saved OG image card + landing page.
871// /share/hours-saved?user=:username → 1200×630 SVG (og:image)
872// /share/:username → HTML page with og:image meta + Twitter share
873// Mounted BEFORE webRoutes so /share/* doesn't fall through to the /:owner profile route.
874app.route("/", shareRoutes);
875
79136bbClaude876// Web UI (catch-all, must be last)
877app.route("/", webRoutes);
878
c63b860Claude879// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
880// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude881app.notFound((c) => {
36cc17aClaude882 const user = c.get("user") ?? null;
79136bbClaude883 return c.html(
c63b860Claude884 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude885 404
886 );
887});
888
c63b860Claude889// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
890// view. Trace block only shown outside production.
79136bbClaude891app.onError((err, c) => {
80bed05Claude892 reportError(err, {
893 requestId: c.get("requestId"),
894 path: c.req.path,
895 method: c.req.method,
896 });
c63b860Claude897 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
898 // back to the context value set by request-context middleware.
899 const requestId =
900 c.req.header("x-request-id") ||
901 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude902 const user = c.get("user") ?? null;
c63b860Claude903 const trace =
904 process.env.NODE_ENV !== "production" && err && err.message
905 ? err.message
906 : undefined;
79136bbClaude907 return c.html(
c63b860Claude908 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude909 500
910 );
911});
912
913export default app;