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.tsxBlame940 lines · 5 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";
369ad65ccanty labs93import wellKnownRoutes from "./routes/well-known";
0316dbbClaude94import developerAppsRoutes from "./routes/developer-apps";
95import themeRoutes from "./routes/theme";
96import auditRoutes from "./routes/audit";
97import reactionRoutes from "./routes/reactions";
98import savedReplyRoutes from "./routes/saved-replies";
99import deploymentRoutes from "./routes/deployments";
2c61840Claude100import pipelineRoutes from "./routes/pipeline";
0316dbbClaude101import orgRoutes from "./routes/orgs";
102import notificationRoutes from "./routes/notifications";
103import onboardingRoutes from "./routes/onboarding";
104import adminRoutes from "./routes/admin";
7293c67Claude105import adminDeletionsRoutes from "./routes/admin-deletions";
106import adminStripeRoutes from "./routes/admin-stripe";
f764c07Claude107import adminDeploysRoutes from "./routes/admin-deploys";
108import adminDeploysPageRoutes from "./routes/admin-deploys-page";
783dd46Claude109import adminServerTargetsRoutes from "./routes/admin-server-targets";
9aaa128Claude110import deployTargetsRoutes from "./routes/deploy-targets";
90c7531Claude111import claudeWebRoutes from "./routes/claude-web";
9dd96b9Test User112import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App113import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User114import adminDiagnoseRoutes from "./routes/admin-diagnose";
f9814d2Claude115import adminCommandRoutes from "./routes/admin-command";
509c376Claude116import adminIntegrationsRoutes from "./routes/admin-integrations";
bc519aeClaude117import adminEnvHealthRoutes from "./routes/admin-env-health";
79ed944Claude118import adminAdvancementRoutes from "./routes/admin-advancement";
ba9e143Claude119import adminSecurityRoutes from "./routes/admin-security";
120import settingsSessionsRoutes from "./routes/settings-sessions";
0316dbbClaude121import advisoriesRoutes from "./routes/advisories";
122import aiChangelogRoutes from "./routes/ai-changelog";
0a69faaClaude123import explainRoutes from "./routes/explain";
0316dbbClaude124import aiExplainRoutes from "./routes/ai-explain";
2be65d0Claude125import archaeologyRoutes from "./routes/ai-archaeology";
0316dbbClaude126import aiTestsRoutes from "./routes/ai-tests";
127import askRoutes from "./routes/ask";
38d31d3Claude128import repoChatRoutes from "./routes/repo-chat";
ee7e577Claude129import personalChatRoutes from "./routes/personal-chat";
0316dbbClaude130import billingRoutes from "./routes/billing";
8809b87Claude131import billingUsageRoutes from "./routes/billing-usage";
6778ad2Claude132import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude133import codeScanningRoutes from "./routes/code-scanning";
da3fc18Claude134import securityRoutes from "./routes/security";
0316dbbClaude135import commitStatusesRoutes from "./routes/commit-statuses";
136import copilotRoutes from "./routes/copilot";
f5d020fClaude137import { pairProgrammerRoutes } from "./routes/pair-programmer";
0316dbbClaude138import depUpdaterRoutes from "./routes/dep-updater";
139import depsRoutes from "./routes/deps";
140import discussionsRoutes from "./routes/discussions";
141import environmentsRoutes from "./routes/environments";
4bbacbeClaude142import previewsRoutes from "./routes/previews";
79ed944Claude143import docsTrackingRoutes from "./routes/docs-tracking";
0316dbbClaude144import followsRoutes from "./routes/follows";
145import gatesRoutes from "./routes/gates";
146import gistsRoutes from "./routes/gists";
147import graphqlRoutes from "./routes/graphql";
2c2163eClaude148import mcpRoutes from "./routes/mcp";
0316dbbClaude149import marketplaceRoutes from "./routes/marketplace";
5ca514aClaude150import marketplaceAgentsRoutes from "./routes/marketplace-agents";
0316dbbClaude151import mergeQueueRoutes from "./routes/merge-queue";
152import mirrorsRoutes from "./routes/mirrors";
153import orgInsightsRoutes from "./routes/org-insights";
2be65d0Claude154import orgHealthRoutes from "./routes/org-health";
0316dbbClaude155import packagesRoutes from "./routes/packages";
156import packagesApiRoutes from "./routes/packages-api";
845fd8aClaude157import ociRegistryRoutes from "./routes/oci-registry";
0316dbbClaude158import pagesRoutes from "./routes/pages";
159import projectsRoutes from "./routes/projects";
160import protectedTagsRoutes from "./routes/protected-tags";
161import pwaRoutes from "./routes/pwa";
46d6165Claude162import installRoutes from "./routes/install";
cd4f63bTest User163import dxtRoutes from "./routes/dxt";
662ce86Claude164import connectClaudeRoutes from "./routes/connect-claude";
ebbb527Claude165import claudeDeployRoutes from "./routes/claude-deploy";
f5b9ef5Claude166import claudeIntegration from "./routes/claude-integration";
167import connectRoutes from "./routes/connect";
05ab9b1Claude168import pushWatchRoutes from "./routes/push-watch";
169import orgSecretsRoutes from "./routes/org-secrets";
0316dbbClaude170import releasesRoutes from "./routes/releases";
171import requiredChecksRoutes from "./routes/required-checks";
172import rulesetsRoutes from "./routes/rulesets";
173import searchRoutes from "./routes/search";
174import semanticSearchRoutes from "./routes/semantic-search";
77cf834Claude175import nlSearchRoutes from "./routes/nl-search";
0316dbbClaude176import signingKeysRoutes from "./routes/signing-keys";
177import sponsorsRoutes from "./routes/sponsors";
178import ssoRoutes from "./routes/sso";
3a845e4Claude179import samlSsoRoutes from "./routes/saml-sso";
180import scimRoutes from "./routes/scim";
181import orgSsoSettingsRoutes from "./routes/org-sso-settings";
46d6165Claude182import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude183import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude184import symbolsRoutes from "./routes/symbols";
185import templatesRoutes from "./routes/templates";
186import trafficRoutes from "./routes/traffic";
187import wikisRoutes from "./routes/wikis";
188import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude189import workflowArtifactsRoutes from "./routes/workflow-artifacts";
190import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude191import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude192import standupRoutes from "./routes/standups";
52ad8b1Claude193import vsGithubRoutes from "./routes/vs-github";
45f3b73Claude194import voiceRoutes from "./routes/voice-to-pr";
3122762Claude195import blogRoutes from "./routes/blog";
cd4f63bTest User196import playgroundRoutes from "./routes/playground";
a2b3e99Claude197import crossRepoSearchRoutes from "./routes/cross-repo-search";
198import pushNotifRoutes from "./routes/push-notifications";
9fbe6cdClaude199import velocityRoutes from "./routes/velocity";
200import { staleBranchRoutes } from "./routes/stale-branches";
22f43f3Claude201import pulseRoutes from "./routes/pulse";
74d8c4dClaude202import healthScoreRoutes from "./routes/health-score";
77cf834Claude203import repoHealthRoutes from "./routes/repo-health";
74d8c4dClaude204import hotFilesRoutes from "./routes/hot-files";
bcc4020Claude205import debtMapRoutes from "./routes/debt-map";
1d6db4dClaude206import busFactorRoutes from "./routes/bus-factor";
2be65d0Claude207import testGapsRoutes from "./routes/test-gaps";
f5d020fClaude208import crossRepoImpactRoutes from "./routes/cross-repo-impact";
adf5e18Claude209import developerProgramRoutes from "./routes/developer-program";
891efbeClaude210import shareRoutes from "./routes/share";
70e3293Claude211import incidentHookRoutes from "./routes/incident-hooks";
77cf834Claude212import workspaceRoutes from "./routes/ai-workspace";
2c61840Claude213import workspaceHubRoutes from "./routes/workspace-hub";
59b6fb2Claude214import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
215import { csrfToken, csrfProtect } from "./middleware/csrf";
f5b9ef5Claude216import { noCache } from "./middleware/no-cache";
79136bbClaude217
2316901Claude218import type { AuthEnv } from "./middleware/auth";
bf19c50Test User219import { softAuth } from "./middleware/auth";
2316901Claude220
221const app = new Hono<AuthEnv>();
79136bbClaude222
3ef4c9dClaude223// Request context (request ID, start time) runs before everything else
224app.use("*", requestContext);
05b973eClaude225// Middleware — compression first (wraps all responses)
226app.use("*", compress());
f1ffd50Claude227
228// ETag middleware — returns 304 Not Modified on unchanged responses.
229// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
230// SSE + the API surface where it would interfere with streaming.
231app.use("*", async (c, next) => {
232 const p = c.req.path;
233 if (
234 p.includes(".git/") ||
235 p.startsWith("/live-events") ||
236 p.startsWith("/api/events/deploy") ||
3c03977Claude237 p.startsWith("/admin/status") ||
238 // PR live co-editing SSE stream — never etag streaming responses.
239 /^\/api\/v2\/pulls\/[^/]+\/live(\/|$)/.test(p)
f1ffd50Claude240 ) {
241 return next();
242 }
243 return etag()(c, next);
244});
245
246// Cache-Control middleware — sets sensible defaults on public, anonymous
9ecf5a4Claude247// requests. Vapron (when wired as our edge layer) and downstream
f1ffd50Claude248// browsers will honor these. Auth'd users get private,no-store
249// automatically — we never cache responses tied to a session.
250app.use("*", async (c, next) => {
251 await next();
252 // Don't overwrite explicit headers set by route handlers — BUT the
253 // ETag middleware unconditionally sets "private, no-cache, must-
254 // revalidate" so we have to treat that specific value as "no
255 // policy chosen yet" and apply ours. Any route that explicitly set
256 // a different cache-control wins.
257 const existing = c.res.headers.get("cache-control");
258 const etagDefault =
259 existing === "private, no-cache, must-revalidate" ||
260 existing === "no-cache";
261 if (existing && !etagDefault) return;
262 // Anything past auth: private + no-store (avoid leaking session
263 // content into shared caches). softAuth runs before this on the
264 // request, but the response side is what we're stamping.
265 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
266 const p = c.req.path;
267 // Always private for known-authed paths regardless of cookie.
268 if (
269 p.startsWith("/admin") ||
270 p.startsWith("/settings") ||
271 p.startsWith("/dashboard") ||
272 p.startsWith("/notifications") ||
273 p.startsWith("/connect/") ||
274 hasSession
275 ) {
276 c.res.headers.set("cache-control", "private, no-store");
277 return;
278 }
279 // Public marketing surfaces — short edge cache, longer browser cache,
280 // stale-while-revalidate so the user never waits on a stale fetch.
281 const isMarketing =
282 p === "/" ||
283 p === "/features" ||
284 p === "/pricing" ||
285 p === "/about" ||
286 p === "/vs-github" ||
287 p === "/explore" ||
288 p === "/help" ||
289 p === "/changelog" ||
9f29b65Claude290 p === "/enterprise" ||
f1ffd50Claude291 p.startsWith("/legal/") ||
292 p === "/terms" ||
293 p === "/privacy" ||
294 p === "/acceptable-use" ||
295 p.startsWith("/docs/");
296 if (isMarketing) {
297 c.res.headers.set(
298 "cache-control",
299 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
300 );
301 return;
302 }
303 // Public repo browse pages — cache aggressively. Edge invalidates
9ecf5a4Claude304 // on push via the post-receive hook (future Vapron surge purge).
f1ffd50Claude305 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
306 c.res.headers.set(
307 "cache-control",
308 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
309 );
310 return;
311 }
312 // Default: don't cache anything we haven't explicitly opted in.
313 c.res.headers.set("cache-control", "private, no-store");
314});
05b973eClaude315// Logger only on non-git routes to avoid overhead on clone/push
316app.use("*", async (c, next) => {
317 if (c.req.path.includes(".git/")) return next();
318 return logger()(c, next);
319});
79136bbClaude320app.use("/api/*", cors());
bf19c50Test User321// Global softAuth — populates c.get("user") for every downstream middleware
322// + route. This was previously per-route, which meant rate-limit middleware
323// (and anything else inspecting auth state) always saw a null user. Keep
324// individual routes free to add requireAuth on top for hard gating; this
325// just establishes the user object cheaply.
326app.use("*", softAuth);
290ea77Claude327
36cc17aClaude328// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude329// pre-redesign markup. JSON / static assets keep their own cache rules; only
330// text/html responses get the no-cache stamp. Without this, every push to
331// main left users staring at cached 80s-looking pages from before the design
332// landed.
36cc17aClaude333//
334// We deliberately use `private, no-cache, must-revalidate` rather than
335// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
336// which makes every Back/Forward press a cold server round-trip — that
337// contributed to the "every nav feels like a fresh login" UX complaint.
338// `no-cache` still revalidates on direct fetch but lets bfcache hold the
339// page in memory between navigations.
290ea77Claude340app.use("*", async (c, next) => {
341 await next();
342 const ct = c.res.headers.get("content-type") || "";
343 if (ct.startsWith("text/html")) {
36cc17aClaude344 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude345 }
346});
826eccfTest User347// Rate-limit API + auth endpoints.
348//
a41e675Test User349// `/api/*`: 1000/min per IP — generous so an admin clicking around the
350// operator console (or a CDN/proxy concentrating multiple users behind one
351// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
352// rate limits below, not this one.
353//
354// `authedMultiplier` is set but only fires when an upstream middleware has
355// already populated c.get("user") — most app.use() chains apply softAuth
356// per-route, so the multiplier is best-effort. Keep the anonymous base
357// high enough that humans never feel it.
358//
359// Skip-paths: dashboard plumbing endpoints that the layout polls on a
360// fixed cadence and that we don't want consuming any bucket:
361// /api/version — layout polls every 15s
826eccfTest User362// /api/notifications/count — nav bell unread-count fetcher
363// /pwa/vapid-public-key — fetched once per push-notification opt-in
364app.use(
365 "/api/*",
a41e675Test User366 rateLimit(1000, 60_000, "api", {
826eccfTest User367 authedMultiplier: 4,
368 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
369 })
370);
0316dbbClaude371app.use("/login", rateLimit(20, 60_000, "login"));
372app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude373// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
374app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User375// BLOCK Q2 — throttle magic-link sign-in for the same reason.
376app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude377
59b6fb2Claude378// CSRF protection — set token on all requests, validate on mutations
379app.use("*", csrfToken);
380app.use("*", csrfProtect);
381
45e31d0Claude382// Rate limit auth routes
383app.use("/login", authRateLimit);
384app.use("/register", authRateLimit);
385
59b6fb2Claude386// Rate limit git operations
387app.use("/:owner/:repo.git/*", gitRateLimit);
388
389// Rate limit search
390app.use("/:owner/:repo/search", searchRateLimit);
391app.use("/explore", searchRateLimit);
79136bbClaude392
f5b9ef5Claude393// No-cache for HTML — ensures browsers and proxies never serve stale pages.
394// The middleware only stamps text/html responses so static assets keep
395// their own cache policies unchanged.
396app.use("*", noCache);
397
79136bbClaude398// Git Smart HTTP protocol routes (must be before web routes)
399app.route("/", gitRoutes);
400
45e31d0Claude401// REST API v1 (legacy)
79136bbClaude402app.route("/", apiRoutes);
403
52ad8b1Claude404// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
405// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
406// router's catch-shape, and BEFORE adminRoutes so the live /demo page
407// wins over the legacy /demo redirect in src/routes/admin.tsx.
408app.route("/", demoRoutes);
409
0316dbbClaude410// REST API v2 (basePath /api/v2)
411app.route("/", apiV2Routes);
412
e75eddcClaude413// Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage).
414// Mounted alongside apiV2Routes (its own basePath, no path conflict).
415app.route("/", agentsRoutes);
416
ef3fd93Claude417// Multi-agent pipeline UI — /:owner/:repo/agents (list, new, live view).
418// Must be before webRoutes (the catch-all) so the /agents sub-paths are
419// resolved before the generic tree/blob route takes over.
420app.route("/", agentPipelinesRoutes);
421
ad6d4adClaude422// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
423app.route("/", hookRoutes);
21f8dbdClaude424app.route("/api/events", eventsRoutes);
ad6d4adClaude425
45e31d0Claude426// API documentation
427app.route("/", apiDocsRoutes);
4a80519Claude428app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude429// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
430app.route("/", pullsDashboardRoutes);
e9aa4d8Claude431// Issue command center — global issue dashboard with AI-triage + autopilot signal
432app.route("/", issuesDashboardRoutes);
433// Personal activity timeline — every event across the user's repos, with
434// AI-driven events surfaced separately (the Gluecron differentiator).
435app.route("/", activityRoutes);
436// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
437app.route("/", inboxRoutes);
56801e1Claude438// AI standup feed — daily / weekly Claude-generated team brief
439app.route("/", standupRoutes);
cc34156Claude440// Smart morning digest — AI-curated daily developer queue (/digest)
441app.route("/", digestRoutes);
79136bbClaude442
443// Auth routes (register, login, logout)
444app.route("/", authRoutes);
445
c63b860Claude446// BLOCK P1 — Password reset (forgot-password + reset-password)
447app.route("/", passwordResetRoutes);
448
449// BLOCK P2 — Email verification (verify-email + resend)
450app.route("/", emailVerificationRoutes);
451
cd4f63bTest User452// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
453app.route("/", magicLinkRoutes);
454
79136bbClaude455// Settings routes (profile, SSH keys)
456app.route("/", settingsRoutes);
457
ba9e143Claude458// Session management (SOC 2 CC6.1 — /settings/sessions)
459app.route("/", settingsSessionsRoutes);
460
7298a17Claude461// 2FA / TOTP settings (Block B4)
462app.route("/", settings2faRoutes);
463
e75eddcClaude464// Agent multiplayer — /settings/agents management UI
465app.route("/", settingsAgentsRoutes);
466
1d4ff60Claude467// Chat integrations — Slack / Discord / Teams (/settings/integrations
468// + /api/v2/integrations/{slack,discord}/*). See src/lib/chat-bot.ts.
469app.route("/", settingsIntegrationsRoutes);
470app.route("/", integrationsChatRoutes);
471
2df1f8cClaude472// WebAuthn / passkey routes (Block B5)
473app.route("/", passkeyRoutes);
474
058d752Claude475// OAuth 2.0 provider (Block B6)
476app.route("/", oauthRoutes);
477app.route("/", developerAppsRoutes);
369ad65ccanty labs478// OAuth / agent discovery metadata (RFC 8414 + RFC 9728) — lets claude.ai,
479// Cursor, Copilot, etc. auto-discover how to authenticate.
480app.route("/", wellKnownRoutes);
058d752Claude481
6fc53bdClaude482// Theme toggle (dark/light cookie)
483app.route("/", themeRoutes);
484
485// Audit log UI
486app.route("/", auditRoutes);
487
488// Reactions API (issues, PRs, comments)
489app.route("/", reactionRoutes);
490
24cf2caClaude491// Saved replies (per-user canned comment templates)
492app.route("/", savedReplyRoutes);
493
494// Environments + deployment history UI
495app.route("/", deploymentRoutes);
2c61840Claude496// Unified CI/CD pipeline timeline
497app.route("/", pipelineRoutes);
24cf2caClaude498
6563f0aClaude499// Organizations + teams (Block B1)
500app.route("/", orgRoutes);
501
c81ab7aClaude502// API tokens
503app.route("/", tokenRoutes);
504
59b6fb2Claude505// Notifications
3ef4c9dClaude506app.route("/", notificationRoutes);
507
79136bbClaude508// Repo settings (description, visibility, delete)
509app.route("/", repoSettings);
479dcd9Claude510// Per-repo automation settings (off / suggest / auto) — migration 0106
511app.route("/", automationSettingsRoutes);
79136bbClaude512
23d1a81Claude513// Repo collaborators (add/list/remove)
514app.route("/", collaboratorRoutes);
515
04f6b7fClaude516// Team-based repo collaborators (invite a whole team)
517app.route("/", teamCollaboratorRoutes);
518
519// Collaborator invite accept flow (token-based)
520app.route("/", invitesRoutes);
521
522// Real-time SSE endpoint (topic-based live updates)
523app.route("/", liveEventsRoutes);
524
3c03977Claude525// PR live co-editing — presence + cursors + content sync via SSE.
526app.route("/", prLiveRoutes);
527
c81ab7aClaude528// Webhooks management
529app.route("/", webhookRoutes);
530
79136bbClaude531// Compare view (branch diffs)
532app.route("/", compareRoutes);
533
534// Issue tracker
535app.route("/", issueRoutes);
536
85c4e13Claude537// Milestones — group issues + PRs toward a shared goal with due dates + progress tracking.
538// Mounted after issueRoutes so /:owner/:repo/issues/* paths win before the milestone patterns.
539app.route("/", milestonesRoutes);
540
f928118Claude541// Ship Agent — autonomous AI feature implementation
542app.route("/", shipAgentRoutes);
543
77cf834Claude544// AI Copilot Workspace — issue-to-PR autonomous agent
545app.route("/", workspaceRoutes);
2c61840Claude546app.route("/", workspaceHubRoutes);
77cf834Claude547
cb5a796Claude548// Comment moderation queue — owner-only `/:owner/:repo/comments/pending`
549// + per-row approve/reject/spam actions. Mounted before `pullRoutes` so
550// the `/:owner/:repo/comments/*` paths resolve before the broader PR
551// patterns kick in.
552app.route("/", commentModerationRoutes);
553
0074234Claude554// Pull requests
555app.route("/", pullRoutes);
09d5f39Claude556
2be65d0Claude557// Streaming PR review — SSE stream + embeddable widget
558// Mounted immediately after pullRoutes so /:owner/:repo/pulls/:number/review/*
559// resolves before the webRoutes catch-all takes over.
560import streamingReviewRoutes from "./routes/streaming-review";
561app.route("/", streamingReviewRoutes);
562
09d5f39Claude563// /stage PR preview — serve built static files from .stage-previews/{jobId}/
564// Registered immediately after pullRoutes so the path `/preview/:id/*` is
565// specific enough to never clash with repo browse routes (`/:owner/:repo/*`).
566app.get("/preview/:stageJobId/*", async (c) => {
567 const { stageJobId } = c.req.param();
568 // Validate job ID format (UUID)
569 if (!/^[0-9a-f-]{32,}$/i.test(stageJobId)) {
570 return c.text("Not found", 404);
571 }
572 const { getPreviewDir, isPreviewExpired } = await import("./lib/pr-stage");
573 if (isPreviewExpired(stageJobId)) {
574 return c.html(
575 "<html><body style='font-family:sans-serif;padding:40px;color:#888'>" +
576 "<h2>Preview expired</h2><p>This stage preview has expired (48h TTL). " +
577 "Comment <code>/stage</code> on the PR to redeploy.</p></body></html>",
578 410
579 );
580 }
581 const { join } = await import("path");
582 const previewDir = getPreviewDir(stageJobId);
583 // Extract the wildcard path after /preview/:id/
584 const rawPath = c.req.path.replace(/^\/preview\/[^/]+/, "") || "/";
585 const filePath = rawPath === "/" || rawPath === "" ? "/index.html" : rawPath;
586 const fullPath = join(previewDir, filePath);
587 const file = Bun.file(fullPath);
588 if (!(await file.exists())) {
589 // Try index.html fallback (SPA behaviour)
590 const indexFile = Bun.file(join(previewDir, "index.html"));
591 if (await indexFile.exists()) {
592 const html = await indexFile.text();
593 return c.html(html);
594 }
595 return c.text("Not found", 404);
596 }
597 const content = await file.arrayBuffer();
598 const ext = fullPath.split(".").pop()?.toLowerCase() ?? "";
599 const contentTypeMap: Record<string, string> = {
600 html: "text/html; charset=utf-8",
601 htm: "text/html; charset=utf-8",
602 css: "text/css; charset=utf-8",
603 js: "application/javascript; charset=utf-8",
604 mjs: "application/javascript; charset=utf-8",
605 json: "application/json; charset=utf-8",
606 png: "image/png",
607 jpg: "image/jpeg",
608 jpeg: "image/jpeg",
609 gif: "image/gif",
610 svg: "image/svg+xml",
611 ico: "image/x-icon",
612 webp: "image/webp",
613 woff: "font/woff",
614 woff2: "font/woff2",
615 ttf: "font/ttf",
616 txt: "text/plain; charset=utf-8",
617 xml: "application/xml",
618 webmanifest: "application/manifest+json",
619 };
620 const ct = contentTypeMap[ext] ?? "application/octet-stream";
621 return c.body(content, 200, {
622 "content-type": ct,
623 "cache-control": "public, max-age=300",
624 "x-stage-job-id": stageJobId,
625 });
626});
627
79ed944Claude628// PR sandboxes — runnable per-PR environments. Migration 0067.
629app.route("/", prSandboxRoutes);
0074234Claude630
9b3a183Claude631// Cloud dev environments — hosted VS Code in the browser. Migration 0072.
632app.route("/", devEnvRoutes);
633
c81ab7aClaude634// Fork
635app.route("/", forkRoutes);
636
0074234Claude637// Web file editor
638app.route("/", editorRoutes);
639
6f2809fClaude640// AI editor API routes (inline suggestions, explain, fix)
641app.route("/", aiEditorRoutes);
642
43de941Claude643// Contributors
644app.route("/", contributorRoutes);
645
699e5c7Claude646// Health liveness + metrics endpoints
2c34075Claude647app.route("/", healthRoutes);
648
f295f78Dictation App649// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
650app.route("/api/platform-status", platformStatus);
651
52ad8b1Claude652// Block L4 — Public stats counters (powers landing-page social proof)
653app.route("/", publicStatsRoutes);
654
655// Block L3 — Live /demo page + /api/v2/demo/* endpoints
656app.route("/", demoRoutes);
657
2316be6Claude658// Public /status — human-readable platform health page
659app.route("/", statusRoutes);
660
b1be050CC LABS App661// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
662// Mounted near the public status route so the two surfaces are visible
663// side-by-side; routes are gated by isSiteAdmin internally.
664app.route("/", adminStatusRoutes);
665
80bed05Claude666// /help — quickstart + API cheatsheet
667app.route("/", helpRoutes);
668
e0e4219Claude669// /docs — expanded documentation site (getting started, workflow YAML, MCP, API, agents)
670app.route("/", docsRoutes);
671
5f2e749Claude672// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
673// so the new editorial pricing layout wins the route; the legacy marketing
674// pricing remains as a safety net but is shadowed at the router.
675app.route("/", pricingRoutes);
676
e1fc7dbClaude677// /changelog — manually curated platform release history
678app.route("/", changelogRoutes);
679
9f29b65Claude680// Enterprise sales page + contact form lead capture.
681app.route("/", enterpriseRoutes);
682
b0148e9Claude683// /pricing, /features, /about — marketing surface
684app.route("/", marketingRoutes);
685
adf5e18Claude686// /developer-program — partner + marketplace revenue-share page
687app.route("/", developerProgramRoutes);
688
5618f9aClaude689// SEO: robots.txt + sitemap.xml
690app.route("/", seoRoutes);
691
05cdb85Claude692// /api/version — live build SHA + uptime; client poller uses this to
693// surface 'New version available — reload' banners on deploy.
694app.route("/", versionRoutes);
695
699e5c7Claude696// Health dashboard (per-repo health page)
697app.route("/", healthDashboardRoutes);
698
9dd96b9Test User699// Block R1 — site-admin operations console. MUST be mounted BEFORE
700// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
701// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
702app.route("/", adminOpsRoutes);
f2c00b4CC LABS App703// BLOCK W — Self-host status + bootstrap dashboard.
704app.route("/", adminSelfHostRoutes);
826eccfTest User705// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
706app.route("/", adminDiagnoseRoutes);
f9814d2Claude707// Unified admin command center — /admin/command
708app.route("/", adminCommandRoutes);
9dd96b9Test User709
16b325cClaude710// Insights (time-travel, dependencies, rollback)
711app.route("/", insightRoutes);
712
8286942Claude713// Engineering Intelligence Dashboard — /insights + /:owner/:repo/insights/engineering
714app.route("/", engineeringInsightsRoutes);
715
8d1483cClaude716// DORA metrics page (/:owner/:repo/insights/dora)
717app.route("/", doraRoutes);
718
f1ab587Claude719// Command center dashboard
720app.route("/", dashboardRoutes);
721
36b4cbdClaude722// Legal pages (terms, privacy, AUP)
723app.route("/", legalRoutes);
4b66018Claude724// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
725// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
726// /acceptable-use); these are the formal versions that the legal pages
727// internally link to each other.
728app.route("/", legalTermsRoutes);
729app.route("/", legalPrivacyRoutes);
730app.route("/", legalAcceptableUseRoutes);
731app.route("/", legalDmcaRoutes);
36b4cbdClaude732
bdbd0deClaude733// GitHub import / migration
734app.route("/", importRoutes);
14c3cc8Claude735app.route("/", importBulkRoutes);
f390cfaCC LABS App736app.route("/", importSecretsRoutes);
bb2dea9Claude737// GitHub Actions → Gluecron gates.yml importer (stateless converter)
738app.route("/", actionsImporterRoutes);
14c3cc8Claude739app.route("/", migrationRoutes);
ba23fe2Claude740app.route("/", migrationAssistantRoutes);
9a8b8deClaude741// GitHub Org Migration Wizard — live progress bulk importer
742app.route("/", migrateRoutes);
14c3cc8Claude743
744// Spec-to-PR (experimental AI-generated draft PRs)
745app.route("/", specsRoutes);
23d0abfClaude746app.route("/", refactorRoutes);
b665cacClaude747app.route("/", codebaseMigratorRoutes);
bdbd0deClaude748
c81ab7aClaude749// Explore page
750app.route("/", exploreRoutes);
751
59b6fb2Claude752// Onboarding
753app.route("/", onboardingRoutes);
754
0316dbbClaude755// Admin + feature routes
756app.route("/", adminRoutes);
7293c67Claude757app.route("/", adminDeletionsRoutes);
758app.route("/", adminStripeRoutes);
ba9e143Claude759
760// SOC 2 security dashboard + readiness checklist (/admin/security, /admin/soc2)
761app.route("/", adminSecurityRoutes);
509c376Claude762app.route("/", adminIntegrationsRoutes);
bc519aeClaude763app.route("/", adminEnvHealthRoutes);
79ed944Claude764app.route("/", adminAdvancementRoutes);
f764c07Claude765app.route("/", adminDeploysRoutes);
766app.route("/", adminDeploysPageRoutes);
783dd46Claude767app.route("/", adminServerTargetsRoutes);
9aaa128Claude768app.route("/", deployTargetsRoutes);
90c7531Claude769app.route("/", claudeWebRoutes);
9dd96b9Test User770// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude771app.route("/", advisoriesRoutes);
772app.route("/", aiChangelogRoutes);
0a69faaClaude773// "Explain This Repo" — rich structured AI analysis dashboard (mounted before
774// the simpler aiExplainRoutes so the new routes win on /:owner/:repo/explain).
775app.route("/", explainRoutes);
0316dbbClaude776app.route("/", aiExplainRoutes);
2be65d0Claude777app.route("/", archaeologyRoutes);
0316dbbClaude778app.route("/", aiTestsRoutes);
779app.route("/", askRoutes);
38d31d3Claude780app.route("/", repoChatRoutes);
ee7e577Claude781// Personal cross-repo chat — `/chat` (user-scoped). Mounted alongside
782// repoChatRoutes so the two surfaces share the catch-all priority.
783app.route("/", personalChatRoutes);
0316dbbClaude784app.route("/", billingRoutes);
8809b87Claude785app.route("/", billingUsageRoutes);
6778ad2Claude786app.route("/", stripeWebhookRoutes);
0316dbbClaude787app.route("/", codeScanningRoutes);
da3fc18Claude788// Dependency CVE scanner findings page — /:owner/:repo/security/vulnerabilities
789app.route("/", securityRoutes);
0316dbbClaude790app.route("/", commitStatusesRoutes);
791app.route("/", copilotRoutes);
f5d020fClaude792app.route("/", pairProgrammerRoutes);
0316dbbClaude793app.route("/", depUpdaterRoutes);
794app.route("/", depsRoutes);
795app.route("/", discussionsRoutes);
796app.route("/", environmentsRoutes);
4bbacbeClaude797app.route("/", previewsRoutes);
79ed944Claude798app.route("/", docsTrackingRoutes);
0316dbbClaude799app.route("/", followsRoutes);
800app.route("/", gatesRoutes);
801app.route("/", gistsRoutes);
802app.route("/", graphqlRoutes);
2c2163eClaude803app.route("/", mcpRoutes);
0316dbbClaude804app.route("/", marketplaceRoutes);
5ca514aClaude805app.route("/", marketplaceAgentsRoutes);
0316dbbClaude806app.route("/", mergeQueueRoutes);
807app.route("/", mirrorsRoutes);
808app.route("/", orgInsightsRoutes);
b02ce30Claude809app.route("/", orgHealthRoutes);
0316dbbClaude810app.route("/", packagesRoutes);
811app.route("/", packagesApiRoutes);
845fd8aClaude812// OCI / Docker container registry — /v2/* (OCI Distribution Spec v1.0)
813app.route("/", ociRegistryRoutes);
0316dbbClaude814app.route("/", pagesRoutes);
815app.route("/", projectsRoutes);
816app.route("/", protectedTagsRoutes);
817app.route("/", pwaRoutes);
46d6165Claude818app.route("/", installRoutes);
cd4f63bTest User819// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
820app.route("/", dxtRoutes);
662ce86Claude821// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
822// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
823app.route("/", connectClaudeRoutes);
f5b9ef5Claude824// Claude Code Integration Receiver — /api/claude/connect + /api/claude/session.
825app.route("/", claudeIntegration);
826// Connect guide — public onboarding page (/connect/claude-guide).
827app.route("/", connectRoutes);
05ab9b1Claude828// Push Watch — per-commit live status (gates + deploy + latency) at /:owner/:repo/push/:sha
829app.route("/", pushWatchRoutes);
830// Org Secrets Manager — BLOCK M2 — /orgs/:slug/settings/secrets
831app.route("/", orgSecretsRoutes);
a2b3e99Claude832// Cross-repo code search — BLOCK M3 — /search/code + /api/search/code
833app.route("/", crossRepoSearchRoutes);
834// Browser push notifications — BLOCK M4 — /settings/notifications/push + /api/push/*
835app.route("/", pushNotifRoutes);
9fbe6cdClaude836// Developer Velocity Dashboard — BLOCK M9 — /:owner/:repo/insights/velocity
837app.route("/", velocityRoutes);
838// Stale Branch Cleanup — BLOCK M10 — /:owner/:repo/branches/stale
839app.route("/", staleBranchRoutes);
22f43f3Claude840// Repository Pulse — BLOCK M12 — /:owner/:repo/pulse
841app.route("/", pulseRoutes);
74d8c4dClaude842// Repository Health Score — BLOCK M14 — /:owner/:repo/insights/health
843app.route("/", healthScoreRoutes);
77cf834Claude844// Repository Health Score breakdown page — /:owner/:repo/health
845app.route("/", repoHealthRoutes);
74d8c4dClaude846// Hot Files Heatmap — BLOCK M16 — /:owner/:repo/insights/hotfiles
847app.route("/", hotFilesRoutes);
bcc4020Claude848// AI Technical Debt Map — /:owner/:repo/debt-map (visual debt graph + Claude analysis)
849app.route("/", debtMapRoutes);
1d6db4dClaude850// Bus Factor Analysis — /:owner/:repo/insights/bus-factor
851app.route("/", busFactorRoutes);
b02ce30Claude852// Test Gap Detector — /:owner/:repo/insights/test-gaps
853app.route("/", testGapsRoutes);
f5d020fClaude854// Cross-Repo Dependency Impact Detection — /:owner/:repo/pulls/:number/cross-repo-impact
855app.route("/", crossRepoImpactRoutes);
ebbb527Claude856// Hosted Claude tool-use loops — paste loop, get endpoint, billing meter.
857// See src/routes/claude-deploy.tsx + src/lib/hosted-claude-loop.ts.
858app.route("/", claudeDeployRoutes);
0316dbbClaude859app.route("/", releasesRoutes);
860app.route("/", requiredChecksRoutes);
861app.route("/", rulesetsRoutes);
862app.route("/", searchRoutes);
863app.route("/", semanticSearchRoutes);
77cf834Claude864app.route("/", nlSearchRoutes);
0316dbbClaude865app.route("/", signingKeysRoutes);
866app.route("/", sponsorsRoutes);
867app.route("/", ssoRoutes);
3a845e4Claude868// Enterprise per-org SAML 2.0 + OIDC SSO routes
869app.route("/", samlSsoRoutes);
870// SCIM 2.0 user provisioning endpoints
871app.route("/", scimRoutes);
872// Per-org SSO + SCIM admin settings UI
873app.route("/", orgSsoSettingsRoutes);
46d6165Claude874app.route("/", githubOauthRoutes);
582cdacClaude875app.route("/", googleOauthRoutes);
0316dbbClaude876app.route("/", symbolsRoutes);
877app.route("/", templatesRoutes);
878app.route("/", trafficRoutes);
879app.route("/", wikisRoutes);
880app.route("/", workflowsRoutes);
5ff9cc2Claude881app.route("/", workflowArtifactsRoutes);
882app.route("/", workflowSecretsRoutes);
46d6165Claude883app.route("/", sleepModeRoutes);
52ad8b1Claude884app.route("/", vsGithubRoutes);
0316dbbClaude885
45f3b73Claude886// Voice-to-PR — phone-first dictation → spec or issue
887app.route("/", voiceRoutes);
888
3122762Claude889// Blog / Devlog — public posts, no DB
890app.route("/", blogRoutes);
891
cd4f63bTest User892// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
893// before the web catch-all so the bare `/play` literal wins over the
894// `/:owner` user-profile route.
895app.route("/", playgroundRoutes);
896
891efbeClaude897// Shareable AI hours-saved OG image card + landing page.
898// /share/hours-saved?user=:username → 1200×630 SVG (og:image)
899// /share/:username → HTML page with og:image meta + Twitter share
900// Mounted BEFORE webRoutes so /share/* doesn't fall through to the /:owner profile route.
901app.route("/", shareRoutes);
902
79136bbClaude903// Web UI (catch-all, must be last)
904app.route("/", webRoutes);
905
c63b860Claude906// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
907// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude908app.notFound((c) => {
36cc17aClaude909 const user = c.get("user") ?? null;
79136bbClaude910 return c.html(
c63b860Claude911 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude912 404
913 );
914});
915
c63b860Claude916// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
917// view. Trace block only shown outside production.
79136bbClaude918app.onError((err, c) => {
80bed05Claude919 reportError(err, {
920 requestId: c.get("requestId"),
921 path: c.req.path,
922 method: c.req.method,
923 });
c63b860Claude924 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
925 // back to the context value set by request-context middleware.
926 const requestId =
927 c.req.header("x-request-id") ||
928 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude929 const user = c.get("user") ?? null;
c63b860Claude930 const trace =
931 process.env.NODE_ENV !== "production" && err && err.message
932 ? err.message
933 : undefined;
79136bbClaude934 return c.html(
c63b860Claude935 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude936 500
937 );
938});
939
940export default app;