Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesPull RequestsActionsSecurityInsightsSettings
✨ AI
More
Blame · Line-by-line history

app.tsx

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

app.tsxBlame915 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";
122import aiTestsRoutes from "./routes/ai-tests";
123import askRoutes from "./routes/ask";
38d31d3Claude124import repoChatRoutes from "./routes/repo-chat";
ee7e577Claude125import personalChatRoutes from "./routes/personal-chat";
0316dbbClaude126import billingRoutes from "./routes/billing";
8809b87Claude127import billingUsageRoutes from "./routes/billing-usage";
6778ad2Claude128import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude129import codeScanningRoutes from "./routes/code-scanning";
da3fc18Claude130import securityRoutes from "./routes/security";
0316dbbClaude131import commitStatusesRoutes from "./routes/commit-statuses";
132import copilotRoutes from "./routes/copilot";
f5d020fClaude133import { pairProgrammerRoutes } from "./routes/pair-programmer";
0316dbbClaude134import depUpdaterRoutes from "./routes/dep-updater";
135import depsRoutes from "./routes/deps";
136import discussionsRoutes from "./routes/discussions";
137import environmentsRoutes from "./routes/environments";
4bbacbeClaude138import previewsRoutes from "./routes/previews";
79ed944Claude139import docsTrackingRoutes from "./routes/docs-tracking";
0316dbbClaude140import followsRoutes from "./routes/follows";
141import gatesRoutes from "./routes/gates";
142import gistsRoutes from "./routes/gists";
143import graphqlRoutes from "./routes/graphql";
2c2163eClaude144import mcpRoutes from "./routes/mcp";
0316dbbClaude145import marketplaceRoutes from "./routes/marketplace";
5ca514aClaude146import marketplaceAgentsRoutes from "./routes/marketplace-agents";
0316dbbClaude147import mergeQueueRoutes from "./routes/merge-queue";
148import mirrorsRoutes from "./routes/mirrors";
149import orgInsightsRoutes from "./routes/org-insights";
150import packagesRoutes from "./routes/packages";
151import packagesApiRoutes from "./routes/packages-api";
845fd8aClaude152import ociRegistryRoutes from "./routes/oci-registry";
0316dbbClaude153import pagesRoutes from "./routes/pages";
154import projectsRoutes from "./routes/projects";
155import protectedTagsRoutes from "./routes/protected-tags";
156import pwaRoutes from "./routes/pwa";
46d6165Claude157import installRoutes from "./routes/install";
cd4f63bTest User158import dxtRoutes from "./routes/dxt";
662ce86Claude159import connectClaudeRoutes from "./routes/connect-claude";
ebbb527Claude160import claudeDeployRoutes from "./routes/claude-deploy";
f5b9ef5Claude161import claudeIntegration from "./routes/claude-integration";
162import connectRoutes from "./routes/connect";
05ab9b1Claude163import pushWatchRoutes from "./routes/push-watch";
164import orgSecretsRoutes from "./routes/org-secrets";
0316dbbClaude165import releasesRoutes from "./routes/releases";
166import requiredChecksRoutes from "./routes/required-checks";
167import rulesetsRoutes from "./routes/rulesets";
168import searchRoutes from "./routes/search";
169import semanticSearchRoutes from "./routes/semantic-search";
77cf834Claude170import nlSearchRoutes from "./routes/nl-search";
0316dbbClaude171import signingKeysRoutes from "./routes/signing-keys";
172import sponsorsRoutes from "./routes/sponsors";
173import ssoRoutes from "./routes/sso";
3a845e4Claude174import samlSsoRoutes from "./routes/saml-sso";
175import scimRoutes from "./routes/scim";
176import orgSsoSettingsRoutes from "./routes/org-sso-settings";
46d6165Claude177import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude178import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude179import symbolsRoutes from "./routes/symbols";
180import templatesRoutes from "./routes/templates";
181import trafficRoutes from "./routes/traffic";
182import wikisRoutes from "./routes/wikis";
183import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude184import workflowArtifactsRoutes from "./routes/workflow-artifacts";
185import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude186import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude187import standupRoutes from "./routes/standups";
52ad8b1Claude188import vsGithubRoutes from "./routes/vs-github";
45f3b73Claude189import voiceRoutes from "./routes/voice-to-pr";
3122762Claude190import blogRoutes from "./routes/blog";
cd4f63bTest User191import playgroundRoutes from "./routes/playground";
a2b3e99Claude192import crossRepoSearchRoutes from "./routes/cross-repo-search";
193import pushNotifRoutes from "./routes/push-notifications";
9fbe6cdClaude194import velocityRoutes from "./routes/velocity";
195import { staleBranchRoutes } from "./routes/stale-branches";
22f43f3Claude196import pulseRoutes from "./routes/pulse";
74d8c4dClaude197import healthScoreRoutes from "./routes/health-score";
77cf834Claude198import repoHealthRoutes from "./routes/repo-health";
74d8c4dClaude199import hotFilesRoutes from "./routes/hot-files";
bcc4020Claude200import debtMapRoutes from "./routes/debt-map";
1d6db4dClaude201import busFactorRoutes from "./routes/bus-factor";
f5d020fClaude202import crossRepoImpactRoutes from "./routes/cross-repo-impact";
adf5e18Claude203import developerProgramRoutes from "./routes/developer-program";
891efbeClaude204import shareRoutes from "./routes/share";
70e3293Claude205import incidentHookRoutes from "./routes/incident-hooks";
77cf834Claude206import workspaceRoutes from "./routes/ai-workspace";
59b6fb2Claude207import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
208import { csrfToken, csrfProtect } from "./middleware/csrf";
f5b9ef5Claude209import { noCache } from "./middleware/no-cache";
79136bbClaude210
2316901Claude211import type { AuthEnv } from "./middleware/auth";
bf19c50Test User212import { softAuth } from "./middleware/auth";
2316901Claude213
214const app = new Hono<AuthEnv>();
79136bbClaude215
3ef4c9dClaude216// Request context (request ID, start time) runs before everything else
217app.use("*", requestContext);
05b973eClaude218// Middleware — compression first (wraps all responses)
219app.use("*", compress());
f1ffd50Claude220
221// ETag middleware — returns 304 Not Modified on unchanged responses.
222// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
223// SSE + the API surface where it would interfere with streaming.
224app.use("*", async (c, next) => {
225 const p = c.req.path;
226 if (
227 p.includes(".git/") ||
228 p.startsWith("/live-events") ||
229 p.startsWith("/api/events/deploy") ||
3c03977Claude230 p.startsWith("/admin/status") ||
231 // PR live co-editing SSE stream — never etag streaming responses.
232 /^\/api\/v2\/pulls\/[^/]+\/live(\/|$)/.test(p)
f1ffd50Claude233 ) {
234 return next();
235 }
236 return etag()(c, next);
237});
238
239// Cache-Control middleware — sets sensible defaults on public, anonymous
9ecf5a4Claude240// requests. Vapron (when wired as our edge layer) and downstream
f1ffd50Claude241// browsers will honor these. Auth'd users get private,no-store
242// automatically — we never cache responses tied to a session.
243app.use("*", async (c, next) => {
244 await next();
245 // Don't overwrite explicit headers set by route handlers — BUT the
246 // ETag middleware unconditionally sets "private, no-cache, must-
247 // revalidate" so we have to treat that specific value as "no
248 // policy chosen yet" and apply ours. Any route that explicitly set
249 // a different cache-control wins.
250 const existing = c.res.headers.get("cache-control");
251 const etagDefault =
252 existing === "private, no-cache, must-revalidate" ||
253 existing === "no-cache";
254 if (existing && !etagDefault) return;
255 // Anything past auth: private + no-store (avoid leaking session
256 // content into shared caches). softAuth runs before this on the
257 // request, but the response side is what we're stamping.
258 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
259 const p = c.req.path;
260 // Always private for known-authed paths regardless of cookie.
261 if (
262 p.startsWith("/admin") ||
263 p.startsWith("/settings") ||
264 p.startsWith("/dashboard") ||
265 p.startsWith("/notifications") ||
266 p.startsWith("/connect/") ||
267 hasSession
268 ) {
269 c.res.headers.set("cache-control", "private, no-store");
270 return;
271 }
272 // Public marketing surfaces — short edge cache, longer browser cache,
273 // stale-while-revalidate so the user never waits on a stale fetch.
274 const isMarketing =
275 p === "/" ||
276 p === "/features" ||
277 p === "/pricing" ||
278 p === "/about" ||
279 p === "/vs-github" ||
280 p === "/explore" ||
281 p === "/help" ||
282 p === "/changelog" ||
9f29b65Claude283 p === "/enterprise" ||
f1ffd50Claude284 p.startsWith("/legal/") ||
285 p === "/terms" ||
286 p === "/privacy" ||
287 p === "/acceptable-use" ||
288 p.startsWith("/docs/");
289 if (isMarketing) {
290 c.res.headers.set(
291 "cache-control",
292 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
293 );
294 return;
295 }
296 // Public repo browse pages — cache aggressively. Edge invalidates
9ecf5a4Claude297 // on push via the post-receive hook (future Vapron surge purge).
f1ffd50Claude298 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
299 c.res.headers.set(
300 "cache-control",
301 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
302 );
303 return;
304 }
305 // Default: don't cache anything we haven't explicitly opted in.
306 c.res.headers.set("cache-control", "private, no-store");
307});
05b973eClaude308// Logger only on non-git routes to avoid overhead on clone/push
309app.use("*", async (c, next) => {
310 if (c.req.path.includes(".git/")) return next();
311 return logger()(c, next);
312});
79136bbClaude313app.use("/api/*", cors());
bf19c50Test User314// Global softAuth — populates c.get("user") for every downstream middleware
315// + route. This was previously per-route, which meant rate-limit middleware
316// (and anything else inspecting auth state) always saw a null user. Keep
317// individual routes free to add requireAuth on top for hard gating; this
318// just establishes the user object cheaply.
319app.use("*", softAuth);
290ea77Claude320
36cc17aClaude321// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude322// pre-redesign markup. JSON / static assets keep their own cache rules; only
323// text/html responses get the no-cache stamp. Without this, every push to
324// main left users staring at cached 80s-looking pages from before the design
325// landed.
36cc17aClaude326//
327// We deliberately use `private, no-cache, must-revalidate` rather than
328// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
329// which makes every Back/Forward press a cold server round-trip — that
330// contributed to the "every nav feels like a fresh login" UX complaint.
331// `no-cache` still revalidates on direct fetch but lets bfcache hold the
332// page in memory between navigations.
290ea77Claude333app.use("*", async (c, next) => {
334 await next();
335 const ct = c.res.headers.get("content-type") || "";
336 if (ct.startsWith("text/html")) {
36cc17aClaude337 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude338 }
339});
826eccfTest User340// Rate-limit API + auth endpoints.
341//
a41e675Test User342// `/api/*`: 1000/min per IP — generous so an admin clicking around the
343// operator console (or a CDN/proxy concentrating multiple users behind one
344// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
345// rate limits below, not this one.
346//
347// `authedMultiplier` is set but only fires when an upstream middleware has
348// already populated c.get("user") — most app.use() chains apply softAuth
349// per-route, so the multiplier is best-effort. Keep the anonymous base
350// high enough that humans never feel it.
351//
352// Skip-paths: dashboard plumbing endpoints that the layout polls on a
353// fixed cadence and that we don't want consuming any bucket:
354// /api/version — layout polls every 15s
826eccfTest User355// /api/notifications/count — nav bell unread-count fetcher
356// /pwa/vapid-public-key — fetched once per push-notification opt-in
357app.use(
358 "/api/*",
a41e675Test User359 rateLimit(1000, 60_000, "api", {
826eccfTest User360 authedMultiplier: 4,
361 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
362 })
363);
0316dbbClaude364app.use("/login", rateLimit(20, 60_000, "login"));
365app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude366// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
367app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User368// BLOCK Q2 — throttle magic-link sign-in for the same reason.
369app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude370
59b6fb2Claude371// CSRF protection — set token on all requests, validate on mutations
372app.use("*", csrfToken);
373app.use("*", csrfProtect);
374
45e31d0Claude375// Rate limit auth routes
376app.use("/login", authRateLimit);
377app.use("/register", authRateLimit);
378
59b6fb2Claude379// Rate limit git operations
380app.use("/:owner/:repo.git/*", gitRateLimit);
381
382// Rate limit search
383app.use("/:owner/:repo/search", searchRateLimit);
384app.use("/explore", searchRateLimit);
79136bbClaude385
f5b9ef5Claude386// No-cache for HTML — ensures browsers and proxies never serve stale pages.
387// The middleware only stamps text/html responses so static assets keep
388// their own cache policies unchanged.
389app.use("*", noCache);
390
79136bbClaude391// Git Smart HTTP protocol routes (must be before web routes)
392app.route("/", gitRoutes);
393
45e31d0Claude394// REST API v1 (legacy)
79136bbClaude395app.route("/", apiRoutes);
396
52ad8b1Claude397// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
398// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
399// router's catch-shape, and BEFORE adminRoutes so the live /demo page
400// wins over the legacy /demo redirect in src/routes/admin.tsx.
401app.route("/", demoRoutes);
402
0316dbbClaude403// REST API v2 (basePath /api/v2)
404app.route("/", apiV2Routes);
405
e75eddcClaude406// Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage).
407// Mounted alongside apiV2Routes (its own basePath, no path conflict).
408app.route("/", agentsRoutes);
409
ef3fd93Claude410// Multi-agent pipeline UI — /:owner/:repo/agents (list, new, live view).
411// Must be before webRoutes (the catch-all) so the /agents sub-paths are
412// resolved before the generic tree/blob route takes over.
413app.route("/", agentPipelinesRoutes);
414
ad6d4adClaude415// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
416app.route("/", hookRoutes);
21f8dbdClaude417app.route("/api/events", eventsRoutes);
ad6d4adClaude418
45e31d0Claude419// API documentation
420app.route("/", apiDocsRoutes);
4a80519Claude421app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude422// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
423app.route("/", pullsDashboardRoutes);
e9aa4d8Claude424// Issue command center — global issue dashboard with AI-triage + autopilot signal
425app.route("/", issuesDashboardRoutes);
426// Personal activity timeline — every event across the user's repos, with
427// AI-driven events surfaced separately (the Gluecron differentiator).
428app.route("/", activityRoutes);
429// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
430app.route("/", inboxRoutes);
56801e1Claude431// AI standup feed — daily / weekly Claude-generated team brief
432app.route("/", standupRoutes);
cc34156Claude433// Smart morning digest — AI-curated daily developer queue (/digest)
434app.route("/", digestRoutes);
79136bbClaude435
436// Auth routes (register, login, logout)
437app.route("/", authRoutes);
438
c63b860Claude439// BLOCK P1 — Password reset (forgot-password + reset-password)
440app.route("/", passwordResetRoutes);
441
442// BLOCK P2 — Email verification (verify-email + resend)
443app.route("/", emailVerificationRoutes);
444
cd4f63bTest User445// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
446app.route("/", magicLinkRoutes);
447
79136bbClaude448// Settings routes (profile, SSH keys)
449app.route("/", settingsRoutes);
450
ba9e143Claude451// Session management (SOC 2 CC6.1 — /settings/sessions)
452app.route("/", settingsSessionsRoutes);
453
7298a17Claude454// 2FA / TOTP settings (Block B4)
455app.route("/", settings2faRoutes);
456
e75eddcClaude457// Agent multiplayer — /settings/agents management UI
458app.route("/", settingsAgentsRoutes);
459
1d4ff60Claude460// Chat integrations — Slack / Discord / Teams (/settings/integrations
461// + /api/v2/integrations/{slack,discord}/*). See src/lib/chat-bot.ts.
462app.route("/", settingsIntegrationsRoutes);
463app.route("/", integrationsChatRoutes);
464
2df1f8cClaude465// WebAuthn / passkey routes (Block B5)
466app.route("/", passkeyRoutes);
467
058d752Claude468// OAuth 2.0 provider (Block B6)
469app.route("/", oauthRoutes);
470app.route("/", developerAppsRoutes);
471
6fc53bdClaude472// Theme toggle (dark/light cookie)
473app.route("/", themeRoutes);
474
475// Audit log UI
476app.route("/", auditRoutes);
477
478// Reactions API (issues, PRs, comments)
479app.route("/", reactionRoutes);
480
24cf2caClaude481// Saved replies (per-user canned comment templates)
482app.route("/", savedReplyRoutes);
483
484// Environments + deployment history UI
485app.route("/", deploymentRoutes);
486
6563f0aClaude487// Organizations + teams (Block B1)
488app.route("/", orgRoutes);
489
c81ab7aClaude490// API tokens
491app.route("/", tokenRoutes);
492
59b6fb2Claude493// Notifications
3ef4c9dClaude494app.route("/", notificationRoutes);
495
79136bbClaude496// Repo settings (description, visibility, delete)
497app.route("/", repoSettings);
479dcd9Claude498// Per-repo automation settings (off / suggest / auto) — migration 0106
499app.route("/", automationSettingsRoutes);
79136bbClaude500
23d1a81Claude501// Repo collaborators (add/list/remove)
502app.route("/", collaboratorRoutes);
503
04f6b7fClaude504// Team-based repo collaborators (invite a whole team)
505app.route("/", teamCollaboratorRoutes);
506
507// Collaborator invite accept flow (token-based)
508app.route("/", invitesRoutes);
509
510// Real-time SSE endpoint (topic-based live updates)
511app.route("/", liveEventsRoutes);
512
3c03977Claude513// PR live co-editing — presence + cursors + content sync via SSE.
514app.route("/", prLiveRoutes);
515
c81ab7aClaude516// Webhooks management
517app.route("/", webhookRoutes);
518
79136bbClaude519// Compare view (branch diffs)
520app.route("/", compareRoutes);
521
522// Issue tracker
523app.route("/", issueRoutes);
524
85c4e13Claude525// Milestones — group issues + PRs toward a shared goal with due dates + progress tracking.
526// Mounted after issueRoutes so /:owner/:repo/issues/* paths win before the milestone patterns.
527app.route("/", milestonesRoutes);
528
f928118Claude529// Ship Agent — autonomous AI feature implementation
530app.route("/", shipAgentRoutes);
531
77cf834Claude532// AI Copilot Workspace — issue-to-PR autonomous agent
533app.route("/", workspaceRoutes);
534
cb5a796Claude535// Comment moderation queue — owner-only `/:owner/:repo/comments/pending`
536// + per-row approve/reject/spam actions. Mounted before `pullRoutes` so
537// the `/:owner/:repo/comments/*` paths resolve before the broader PR
538// patterns kick in.
539app.route("/", commentModerationRoutes);
540
0074234Claude541// Pull requests
542app.route("/", pullRoutes);
09d5f39Claude543
544// /stage PR preview — serve built static files from .stage-previews/{jobId}/
545// Registered immediately after pullRoutes so the path `/preview/:id/*` is
546// specific enough to never clash with repo browse routes (`/:owner/:repo/*`).
547app.get("/preview/:stageJobId/*", async (c) => {
548 const { stageJobId } = c.req.param();
549 // Validate job ID format (UUID)
550 if (!/^[0-9a-f-]{32,}$/i.test(stageJobId)) {
551 return c.text("Not found", 404);
552 }
553 const { getPreviewDir, isPreviewExpired } = await import("./lib/pr-stage");
554 if (isPreviewExpired(stageJobId)) {
555 return c.html(
556 "<html><body style='font-family:sans-serif;padding:40px;color:#888'>" +
557 "<h2>Preview expired</h2><p>This stage preview has expired (48h TTL). " +
558 "Comment <code>/stage</code> on the PR to redeploy.</p></body></html>",
559 410
560 );
561 }
562 const { join } = await import("path");
563 const previewDir = getPreviewDir(stageJobId);
564 // Extract the wildcard path after /preview/:id/
565 const rawPath = c.req.path.replace(/^\/preview\/[^/]+/, "") || "/";
566 const filePath = rawPath === "/" || rawPath === "" ? "/index.html" : rawPath;
567 const fullPath = join(previewDir, filePath);
568 const file = Bun.file(fullPath);
569 if (!(await file.exists())) {
570 // Try index.html fallback (SPA behaviour)
571 const indexFile = Bun.file(join(previewDir, "index.html"));
572 if (await indexFile.exists()) {
573 const html = await indexFile.text();
574 return c.html(html);
575 }
576 return c.text("Not found", 404);
577 }
578 const content = await file.arrayBuffer();
579 const ext = fullPath.split(".").pop()?.toLowerCase() ?? "";
580 const contentTypeMap: Record<string, string> = {
581 html: "text/html; charset=utf-8",
582 htm: "text/html; charset=utf-8",
583 css: "text/css; charset=utf-8",
584 js: "application/javascript; charset=utf-8",
585 mjs: "application/javascript; charset=utf-8",
586 json: "application/json; charset=utf-8",
587 png: "image/png",
588 jpg: "image/jpeg",
589 jpeg: "image/jpeg",
590 gif: "image/gif",
591 svg: "image/svg+xml",
592 ico: "image/x-icon",
593 webp: "image/webp",
594 woff: "font/woff",
595 woff2: "font/woff2",
596 ttf: "font/ttf",
597 txt: "text/plain; charset=utf-8",
598 xml: "application/xml",
599 webmanifest: "application/manifest+json",
600 };
601 const ct = contentTypeMap[ext] ?? "application/octet-stream";
602 return c.body(content, 200, {
603 "content-type": ct,
604 "cache-control": "public, max-age=300",
605 "x-stage-job-id": stageJobId,
606 });
607});
608
79ed944Claude609// PR sandboxes — runnable per-PR environments. Migration 0067.
610app.route("/", prSandboxRoutes);
0074234Claude611
9b3a183Claude612// Cloud dev environments — hosted VS Code in the browser. Migration 0072.
613app.route("/", devEnvRoutes);
614
c81ab7aClaude615// Fork
616app.route("/", forkRoutes);
617
0074234Claude618// Web file editor
619app.route("/", editorRoutes);
620
6f2809fClaude621// AI editor API routes (inline suggestions, explain, fix)
622app.route("/", aiEditorRoutes);
623
43de941Claude624// Contributors
625app.route("/", contributorRoutes);
626
699e5c7Claude627// Health liveness + metrics endpoints
2c34075Claude628app.route("/", healthRoutes);
629
f295f78Dictation App630// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
631app.route("/api/platform-status", platformStatus);
632
52ad8b1Claude633// Block L4 — Public stats counters (powers landing-page social proof)
634app.route("/", publicStatsRoutes);
635
636// Block L3 — Live /demo page + /api/v2/demo/* endpoints
637app.route("/", demoRoutes);
638
2316be6Claude639// Public /status — human-readable platform health page
640app.route("/", statusRoutes);
641
b1be050CC LABS App642// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
643// Mounted near the public status route so the two surfaces are visible
644// side-by-side; routes are gated by isSiteAdmin internally.
645app.route("/", adminStatusRoutes);
646
80bed05Claude647// /help — quickstart + API cheatsheet
648app.route("/", helpRoutes);
649
e0e4219Claude650// /docs — expanded documentation site (getting started, workflow YAML, MCP, API, agents)
651app.route("/", docsRoutes);
652
5f2e749Claude653// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
654// so the new editorial pricing layout wins the route; the legacy marketing
655// pricing remains as a safety net but is shadowed at the router.
656app.route("/", pricingRoutes);
657
e1fc7dbClaude658// /changelog — manually curated platform release history
659app.route("/", changelogRoutes);
660
9f29b65Claude661// Enterprise sales page + contact form lead capture.
662app.route("/", enterpriseRoutes);
663
b0148e9Claude664// /pricing, /features, /about — marketing surface
665app.route("/", marketingRoutes);
666
adf5e18Claude667// /developer-program — partner + marketplace revenue-share page
668app.route("/", developerProgramRoutes);
669
5618f9aClaude670// SEO: robots.txt + sitemap.xml
671app.route("/", seoRoutes);
672
05cdb85Claude673// /api/version — live build SHA + uptime; client poller uses this to
674// surface 'New version available — reload' banners on deploy.
675app.route("/", versionRoutes);
676
699e5c7Claude677// Health dashboard (per-repo health page)
678app.route("/", healthDashboardRoutes);
679
9dd96b9Test User680// Block R1 — site-admin operations console. MUST be mounted BEFORE
681// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
682// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
683app.route("/", adminOpsRoutes);
f2c00b4CC LABS App684// BLOCK W — Self-host status + bootstrap dashboard.
685app.route("/", adminSelfHostRoutes);
826eccfTest User686// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
687app.route("/", adminDiagnoseRoutes);
9dd96b9Test User688
16b325cClaude689// Insights (time-travel, dependencies, rollback)
690app.route("/", insightRoutes);
691
8286942Claude692// Engineering Intelligence Dashboard — /insights + /:owner/:repo/insights/engineering
693app.route("/", engineeringInsightsRoutes);
694
8d1483cClaude695// DORA metrics page (/:owner/:repo/insights/dora)
696app.route("/", doraRoutes);
697
f1ab587Claude698// Command center dashboard
699app.route("/", dashboardRoutes);
700
36b4cbdClaude701// Legal pages (terms, privacy, AUP)
702app.route("/", legalRoutes);
4b66018Claude703// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
704// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
705// /acceptable-use); these are the formal versions that the legal pages
706// internally link to each other.
707app.route("/", legalTermsRoutes);
708app.route("/", legalPrivacyRoutes);
709app.route("/", legalAcceptableUseRoutes);
710app.route("/", legalDmcaRoutes);
36b4cbdClaude711
bdbd0deClaude712// GitHub import / migration
713app.route("/", importRoutes);
14c3cc8Claude714app.route("/", importBulkRoutes);
f390cfaCC LABS App715app.route("/", importSecretsRoutes);
bb2dea9Claude716// GitHub Actions → Gluecron gates.yml importer (stateless converter)
717app.route("/", actionsImporterRoutes);
14c3cc8Claude718app.route("/", migrationRoutes);
ba23fe2Claude719app.route("/", migrationAssistantRoutes);
9a8b8deClaude720// GitHub Org Migration Wizard — live progress bulk importer
721app.route("/", migrateRoutes);
14c3cc8Claude722
723// Spec-to-PR (experimental AI-generated draft PRs)
724app.route("/", specsRoutes);
23d0abfClaude725app.route("/", refactorRoutes);
b665cacClaude726app.route("/", codebaseMigratorRoutes);
bdbd0deClaude727
c81ab7aClaude728// Explore page
729app.route("/", exploreRoutes);
730
59b6fb2Claude731// Onboarding
732app.route("/", onboardingRoutes);
733
0316dbbClaude734// Admin + feature routes
735app.route("/", adminRoutes);
7293c67Claude736app.route("/", adminDeletionsRoutes);
737app.route("/", adminStripeRoutes);
ba9e143Claude738
739// SOC 2 security dashboard + readiness checklist (/admin/security, /admin/soc2)
740app.route("/", adminSecurityRoutes);
509c376Claude741app.route("/", adminIntegrationsRoutes);
bc519aeClaude742app.route("/", adminEnvHealthRoutes);
79ed944Claude743app.route("/", adminAdvancementRoutes);
f764c07Claude744app.route("/", adminDeploysRoutes);
745app.route("/", adminDeploysPageRoutes);
783dd46Claude746app.route("/", adminServerTargetsRoutes);
9aaa128Claude747app.route("/", deployTargetsRoutes);
90c7531Claude748app.route("/", claudeWebRoutes);
9dd96b9Test User749// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude750app.route("/", advisoriesRoutes);
751app.route("/", aiChangelogRoutes);
0a69faaClaude752// "Explain This Repo" — rich structured AI analysis dashboard (mounted before
753// the simpler aiExplainRoutes so the new routes win on /:owner/:repo/explain).
754app.route("/", explainRoutes);
0316dbbClaude755app.route("/", aiExplainRoutes);
756app.route("/", aiTestsRoutes);
757app.route("/", askRoutes);
38d31d3Claude758app.route("/", repoChatRoutes);
ee7e577Claude759// Personal cross-repo chat — `/chat` (user-scoped). Mounted alongside
760// repoChatRoutes so the two surfaces share the catch-all priority.
761app.route("/", personalChatRoutes);
0316dbbClaude762app.route("/", billingRoutes);
8809b87Claude763app.route("/", billingUsageRoutes);
6778ad2Claude764app.route("/", stripeWebhookRoutes);
0316dbbClaude765app.route("/", codeScanningRoutes);
da3fc18Claude766// Dependency CVE scanner findings page — /:owner/:repo/security/vulnerabilities
767app.route("/", securityRoutes);
0316dbbClaude768app.route("/", commitStatusesRoutes);
769app.route("/", copilotRoutes);
f5d020fClaude770app.route("/", pairProgrammerRoutes);
0316dbbClaude771app.route("/", depUpdaterRoutes);
772app.route("/", depsRoutes);
773app.route("/", discussionsRoutes);
774app.route("/", environmentsRoutes);
4bbacbeClaude775app.route("/", previewsRoutes);
79ed944Claude776app.route("/", docsTrackingRoutes);
0316dbbClaude777app.route("/", followsRoutes);
778app.route("/", gatesRoutes);
779app.route("/", gistsRoutes);
780app.route("/", graphqlRoutes);
2c2163eClaude781app.route("/", mcpRoutes);
0316dbbClaude782app.route("/", marketplaceRoutes);
5ca514aClaude783app.route("/", marketplaceAgentsRoutes);
0316dbbClaude784app.route("/", mergeQueueRoutes);
785app.route("/", mirrorsRoutes);
786app.route("/", orgInsightsRoutes);
787app.route("/", packagesRoutes);
788app.route("/", packagesApiRoutes);
845fd8aClaude789// OCI / Docker container registry — /v2/* (OCI Distribution Spec v1.0)
790app.route("/", ociRegistryRoutes);
0316dbbClaude791app.route("/", pagesRoutes);
792app.route("/", projectsRoutes);
793app.route("/", protectedTagsRoutes);
794app.route("/", pwaRoutes);
46d6165Claude795app.route("/", installRoutes);
cd4f63bTest User796// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
797app.route("/", dxtRoutes);
662ce86Claude798// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
799// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
800app.route("/", connectClaudeRoutes);
f5b9ef5Claude801// Claude Code Integration Receiver — /api/claude/connect + /api/claude/session.
802app.route("/", claudeIntegration);
803// Connect guide — public onboarding page (/connect/claude-guide).
804app.route("/", connectRoutes);
05ab9b1Claude805// Push Watch — per-commit live status (gates + deploy + latency) at /:owner/:repo/push/:sha
806app.route("/", pushWatchRoutes);
807// Org Secrets Manager — BLOCK M2 — /orgs/:slug/settings/secrets
808app.route("/", orgSecretsRoutes);
a2b3e99Claude809// Cross-repo code search — BLOCK M3 — /search/code + /api/search/code
810app.route("/", crossRepoSearchRoutes);
811// Browser push notifications — BLOCK M4 — /settings/notifications/push + /api/push/*
812app.route("/", pushNotifRoutes);
9fbe6cdClaude813// Developer Velocity Dashboard — BLOCK M9 — /:owner/:repo/insights/velocity
814app.route("/", velocityRoutes);
815// Stale Branch Cleanup — BLOCK M10 — /:owner/:repo/branches/stale
816app.route("/", staleBranchRoutes);
22f43f3Claude817// Repository Pulse — BLOCK M12 — /:owner/:repo/pulse
818app.route("/", pulseRoutes);
74d8c4dClaude819// Repository Health Score — BLOCK M14 — /:owner/:repo/insights/health
820app.route("/", healthScoreRoutes);
77cf834Claude821// Repository Health Score breakdown page — /:owner/:repo/health
822app.route("/", repoHealthRoutes);
74d8c4dClaude823// Hot Files Heatmap — BLOCK M16 — /:owner/:repo/insights/hotfiles
824app.route("/", hotFilesRoutes);
bcc4020Claude825// AI Technical Debt Map — /:owner/:repo/debt-map (visual debt graph + Claude analysis)
826app.route("/", debtMapRoutes);
1d6db4dClaude827// Bus Factor Analysis — /:owner/:repo/insights/bus-factor
828app.route("/", busFactorRoutes);
f5d020fClaude829// Cross-Repo Dependency Impact Detection — /:owner/:repo/pulls/:number/cross-repo-impact
830app.route("/", crossRepoImpactRoutes);
ebbb527Claude831// Hosted Claude tool-use loops — paste loop, get endpoint, billing meter.
832// See src/routes/claude-deploy.tsx + src/lib/hosted-claude-loop.ts.
833app.route("/", claudeDeployRoutes);
0316dbbClaude834app.route("/", releasesRoutes);
835app.route("/", requiredChecksRoutes);
836app.route("/", rulesetsRoutes);
837app.route("/", searchRoutes);
838app.route("/", semanticSearchRoutes);
77cf834Claude839app.route("/", nlSearchRoutes);
0316dbbClaude840app.route("/", signingKeysRoutes);
841app.route("/", sponsorsRoutes);
842app.route("/", ssoRoutes);
3a845e4Claude843// Enterprise per-org SAML 2.0 + OIDC SSO routes
844app.route("/", samlSsoRoutes);
845// SCIM 2.0 user provisioning endpoints
846app.route("/", scimRoutes);
847// Per-org SSO + SCIM admin settings UI
848app.route("/", orgSsoSettingsRoutes);
46d6165Claude849app.route("/", githubOauthRoutes);
582cdacClaude850app.route("/", googleOauthRoutes);
0316dbbClaude851app.route("/", symbolsRoutes);
852app.route("/", templatesRoutes);
853app.route("/", trafficRoutes);
854app.route("/", wikisRoutes);
855app.route("/", workflowsRoutes);
5ff9cc2Claude856app.route("/", workflowArtifactsRoutes);
857app.route("/", workflowSecretsRoutes);
46d6165Claude858app.route("/", sleepModeRoutes);
52ad8b1Claude859app.route("/", vsGithubRoutes);
0316dbbClaude860
45f3b73Claude861// Voice-to-PR — phone-first dictation → spec or issue
862app.route("/", voiceRoutes);
863
3122762Claude864// Blog / Devlog — public posts, no DB
865app.route("/", blogRoutes);
866
cd4f63bTest User867// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
868// before the web catch-all so the bare `/play` literal wins over the
869// `/:owner` user-profile route.
870app.route("/", playgroundRoutes);
871
891efbeClaude872// Shareable AI hours-saved OG image card + landing page.
873// /share/hours-saved?user=:username → 1200×630 SVG (og:image)
874// /share/:username → HTML page with og:image meta + Twitter share
875// Mounted BEFORE webRoutes so /share/* doesn't fall through to the /:owner profile route.
876app.route("/", shareRoutes);
877
79136bbClaude878// Web UI (catch-all, must be last)
879app.route("/", webRoutes);
880
c63b860Claude881// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
882// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude883app.notFound((c) => {
36cc17aClaude884 const user = c.get("user") ?? null;
79136bbClaude885 return c.html(
c63b860Claude886 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude887 404
888 );
889});
890
c63b860Claude891// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
892// view. Trace block only shown outside production.
79136bbClaude893app.onError((err, c) => {
80bed05Claude894 reportError(err, {
895 requestId: c.get("requestId"),
896 path: c.req.path,
897 method: c.req.method,
898 });
c63b860Claude899 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
900 // back to the context value set by request-context middleware.
901 const requestId =
902 c.req.header("x-request-id") ||
903 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude904 const user = c.get("user") ?? null;
c63b860Claude905 const trace =
906 process.env.NODE_ENV !== "production" && err && err.message
907 ? err.message
908 : undefined;
79136bbClaude909 return c.html(
c63b860Claude910 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude911 500
912 );
913});
914
915export default app;