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.tsxBlame894 lines · 4 contributors
79136bbClaude1import { Hono } from "hono";
2import { logger } from "hono/logger";
3import { cors } from "hono/cors";
05b973eClaude4import { compress } from "hono/compress";
f1ffd50Claude5import { etag } from "hono/etag";
c63b860Claude6// BLOCK O2 — shared error-page surface (404 / 500 / 403).
7import { NotFoundPage, ServerErrorPage } from "./views/error-page";
80bed05Claude8import { reportError } from "./lib/observability";
3ef4c9dClaude9import { requestContext } from "./middleware/request-context";
10import { rateLimit } from "./middleware/rate-limit";
79136bbClaude11import gitRoutes from "./routes/git";
12import apiRoutes from "./routes/api";
45e31d0Claude13import apiV2Routes from "./routes/api-v2";
14import apiDocsRoutes from "./routes/api-docs";
4a80519Claude15import buildAgentSpecRoutes from "./routes/build-agent-spec";
a6ff0f2Claude16import pullsDashboardRoutes from "./routes/pulls-dashboard";
e9aa4d8Claude17import issuesDashboardRoutes from "./routes/issues-dashboard";
18import inboxRoutes from "./routes/inbox";
cc34156Claude19import digestRoutes from "./routes/digest";
e9aa4d8Claude20import activityRoutes from "./routes/activity";
79136bbClaude21import authRoutes from "./routes/auth";
c63b860Claude22import passwordResetRoutes from "./routes/password-reset";
23import emailVerificationRoutes from "./routes/email-verification";
cd4f63bTest User24import magicLinkRoutes from "./routes/magic-link";
79136bbClaude25import settingsRoutes from "./routes/settings";
7298a17Claude26import settings2faRoutes from "./routes/settings-2fa";
e75eddcClaude27import settingsAgentsRoutes from "./routes/settings-agents";
1d4ff60Claude28import settingsIntegrationsRoutes from "./routes/settings-integrations";
29import integrationsChatRoutes from "./routes/integrations-chat";
e75eddcClaude30import agentsRoutes from "./routes/agents";
ef3fd93Claude31import agentPipelinesRoutes from "./routes/agent-pipelines";
79136bbClaude32import issueRoutes from "./routes/issues";
85c4e13Claude33import milestonesRoutes from "./routes/milestones";
f928118Claude34import shipAgentRoutes from "./routes/ship-agent";
cb5a796Claude35import commentModerationRoutes from "./routes/comment-moderation";
79136bbClaude36import repoSettings from "./routes/repo-settings";
23d1a81Claude37import collaboratorRoutes from "./routes/collaborators";
04f6b7fClaude38import teamCollaboratorRoutes from "./routes/team-collaborators";
39import invitesRoutes from "./routes/invites";
40import liveEventsRoutes from "./routes/live-events";
3c03977Claude41import prLiveRoutes from "./routes/pr-live";
79136bbClaude42import compareRoutes from "./routes/compare";
0074234Claude43import pullRoutes from "./routes/pulls";
79ed944Claude44import prSandboxRoutes from "./routes/pr-sandbox";
9b3a183Claude45import devEnvRoutes from "./routes/dev-env";
0074234Claude46import editorRoutes from "./routes/editor";
6f2809fClaude47import aiEditorRoutes from "./routes/ai-editor";
c81ab7aClaude48import forkRoutes from "./routes/fork";
49import webhookRoutes from "./routes/webhooks";
50import exploreRoutes from "./routes/explore";
51import tokenRoutes from "./routes/tokens";
43de941Claude52import contributorRoutes from "./routes/contributors";
699e5c7Claude53import healthRoutes from "./routes/health-probe";
54import healthDashboardRoutes from "./routes/health";
2316be6Claude55import statusRoutes from "./routes/status";
b1be050CC LABS App56import adminStatusRoutes from "./routes/admin-status";
80bed05Claude57import helpRoutes from "./routes/help";
e1fc7dbClaude58import changelogRoutes from "./routes/changelog";
e0e4219Claude59import docsRoutes from "./routes/docs";
b0148e9Claude60import marketingRoutes from "./routes/marketing";
5f2e749Claude61import pricingRoutes from "./routes/pricing";
9f29b65Claude62import enterpriseRoutes from "./routes/enterprise";
5618f9aClaude63import seoRoutes from "./routes/seo";
05cdb85Claude64import versionRoutes from "./routes/version";
f295f78Dictation App65import { platformStatus } from "./routes/platform-status";
52ad8b1Claude66import publicStatsRoutes from "./routes/public-stats";
67import demoRoutes from "./routes/demo";
16b325cClaude68import insightRoutes from "./routes/insights";
8286942Claude69import engineeringInsightsRoutes from "./routes/engineering-insights";
8d1483cClaude70import doraRoutes from "./routes/dora";
f1ab587Claude71import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude72import legalRoutes from "./routes/legal";
4b66018Claude73import legalDmcaRoutes from "./routes/legal/dmca";
74import legalTermsRoutes from "./routes/legal/terms";
75import legalPrivacyRoutes from "./routes/legal/privacy";
76import legalAcceptableUseRoutes from "./routes/legal/acceptable-use";
bdbd0deClaude77import importRoutes from "./routes/import";
14c3cc8Claude78import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App79import importSecretsRoutes from "./routes/import-secrets";
bb2dea9Claude80import actionsImporterRoutes from "./routes/actions-importer";
14c3cc8Claude81import migrationRoutes from "./routes/migrations";
9a8b8deClaude82import migrateRoutes from "./routes/migrate";
14c3cc8Claude83import specsRoutes from "./routes/specs";
23d0abfClaude84import refactorRoutes from "./routes/refactors";
b665cacClaude85import codebaseMigratorRoutes from "./routes/codebase-migrator";
79136bbClaude86import webRoutes from "./routes/web";
0316dbbClaude87import hookRoutes from "./routes/hooks";
88import eventsRoutes from "./routes/events";
89import passkeyRoutes from "./routes/passkeys";
90import oauthRoutes from "./routes/oauth";
91import developerAppsRoutes from "./routes/developer-apps";
92import themeRoutes from "./routes/theme";
93import auditRoutes from "./routes/audit";
94import reactionRoutes from "./routes/reactions";
95import savedReplyRoutes from "./routes/saved-replies";
96import deploymentRoutes from "./routes/deployments";
97import orgRoutes from "./routes/orgs";
98import notificationRoutes from "./routes/notifications";
99import onboardingRoutes from "./routes/onboarding";
100import adminRoutes from "./routes/admin";
7293c67Claude101import adminDeletionsRoutes from "./routes/admin-deletions";
102import adminStripeRoutes from "./routes/admin-stripe";
f764c07Claude103import adminDeploysRoutes from "./routes/admin-deploys";
104import adminDeploysPageRoutes from "./routes/admin-deploys-page";
783dd46Claude105import adminServerTargetsRoutes from "./routes/admin-server-targets";
9aaa128Claude106import deployTargetsRoutes from "./routes/deploy-targets";
90c7531Claude107import claudeWebRoutes from "./routes/claude-web";
9dd96b9Test User108import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App109import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User110import adminDiagnoseRoutes from "./routes/admin-diagnose";
509c376Claude111import adminIntegrationsRoutes from "./routes/admin-integrations";
79ed944Claude112import adminAdvancementRoutes from "./routes/admin-advancement";
ba9e143Claude113import adminSecurityRoutes from "./routes/admin-security";
114import settingsSessionsRoutes from "./routes/settings-sessions";
0316dbbClaude115import advisoriesRoutes from "./routes/advisories";
116import aiChangelogRoutes from "./routes/ai-changelog";
0a69faaClaude117import explainRoutes from "./routes/explain";
0316dbbClaude118import aiExplainRoutes from "./routes/ai-explain";
119import aiTestsRoutes from "./routes/ai-tests";
120import askRoutes from "./routes/ask";
38d31d3Claude121import repoChatRoutes from "./routes/repo-chat";
ee7e577Claude122import personalChatRoutes from "./routes/personal-chat";
0316dbbClaude123import billingRoutes from "./routes/billing";
8809b87Claude124import billingUsageRoutes from "./routes/billing-usage";
6778ad2Claude125import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude126import codeScanningRoutes from "./routes/code-scanning";
da3fc18Claude127import securityRoutes from "./routes/security";
0316dbbClaude128import commitStatusesRoutes from "./routes/commit-statuses";
129import copilotRoutes from "./routes/copilot";
130import depUpdaterRoutes from "./routes/dep-updater";
131import depsRoutes from "./routes/deps";
132import discussionsRoutes from "./routes/discussions";
133import environmentsRoutes from "./routes/environments";
4bbacbeClaude134import previewsRoutes from "./routes/previews";
79ed944Claude135import docsTrackingRoutes from "./routes/docs-tracking";
0316dbbClaude136import followsRoutes from "./routes/follows";
137import gatesRoutes from "./routes/gates";
138import gistsRoutes from "./routes/gists";
139import graphqlRoutes from "./routes/graphql";
2c2163eClaude140import mcpRoutes from "./routes/mcp";
0316dbbClaude141import marketplaceRoutes from "./routes/marketplace";
5ca514aClaude142import marketplaceAgentsRoutes from "./routes/marketplace-agents";
0316dbbClaude143import mergeQueueRoutes from "./routes/merge-queue";
144import mirrorsRoutes from "./routes/mirrors";
145import orgInsightsRoutes from "./routes/org-insights";
146import packagesRoutes from "./routes/packages";
147import packagesApiRoutes from "./routes/packages-api";
845fd8aClaude148import ociRegistryRoutes from "./routes/oci-registry";
0316dbbClaude149import pagesRoutes from "./routes/pages";
150import projectsRoutes from "./routes/projects";
151import protectedTagsRoutes from "./routes/protected-tags";
152import pwaRoutes from "./routes/pwa";
46d6165Claude153import installRoutes from "./routes/install";
cd4f63bTest User154import dxtRoutes from "./routes/dxt";
662ce86Claude155import connectClaudeRoutes from "./routes/connect-claude";
ebbb527Claude156import claudeDeployRoutes from "./routes/claude-deploy";
f5b9ef5Claude157import claudeIntegration from "./routes/claude-integration";
158import connectRoutes from "./routes/connect";
05ab9b1Claude159import pushWatchRoutes from "./routes/push-watch";
160import orgSecretsRoutes from "./routes/org-secrets";
0316dbbClaude161import releasesRoutes from "./routes/releases";
162import requiredChecksRoutes from "./routes/required-checks";
163import rulesetsRoutes from "./routes/rulesets";
164import searchRoutes from "./routes/search";
165import semanticSearchRoutes from "./routes/semantic-search";
166import signingKeysRoutes from "./routes/signing-keys";
167import sponsorsRoutes from "./routes/sponsors";
168import ssoRoutes from "./routes/sso";
3a845e4Claude169import samlSsoRoutes from "./routes/saml-sso";
170import scimRoutes from "./routes/scim";
171import orgSsoSettingsRoutes from "./routes/org-sso-settings";
46d6165Claude172import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude173import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude174import symbolsRoutes from "./routes/symbols";
175import templatesRoutes from "./routes/templates";
176import trafficRoutes from "./routes/traffic";
177import wikisRoutes from "./routes/wikis";
178import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude179import workflowArtifactsRoutes from "./routes/workflow-artifacts";
180import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude181import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude182import standupRoutes from "./routes/standups";
52ad8b1Claude183import vsGithubRoutes from "./routes/vs-github";
45f3b73Claude184import voiceRoutes from "./routes/voice-to-pr";
3122762Claude185import blogRoutes from "./routes/blog";
cd4f63bTest User186import playgroundRoutes from "./routes/playground";
a2b3e99Claude187import crossRepoSearchRoutes from "./routes/cross-repo-search";
188import pushNotifRoutes from "./routes/push-notifications";
9fbe6cdClaude189import velocityRoutes from "./routes/velocity";
190import { staleBranchRoutes } from "./routes/stale-branches";
22f43f3Claude191import pulseRoutes from "./routes/pulse";
74d8c4dClaude192import healthScoreRoutes from "./routes/health-score";
193import hotFilesRoutes from "./routes/hot-files";
bcc4020Claude194import debtMapRoutes from "./routes/debt-map";
1d6db4dClaude195import busFactorRoutes from "./routes/bus-factor";
adf5e18Claude196import developerProgramRoutes from "./routes/developer-program";
891efbeClaude197import shareRoutes from "./routes/share";
70e3293Claude198import incidentHookRoutes from "./routes/incident-hooks";
59b6fb2Claude199import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
200import { csrfToken, csrfProtect } from "./middleware/csrf";
f5b9ef5Claude201import { noCache } from "./middleware/no-cache";
79136bbClaude202
2316901Claude203import type { AuthEnv } from "./middleware/auth";
bf19c50Test User204import { softAuth } from "./middleware/auth";
2316901Claude205
206const app = new Hono<AuthEnv>();
79136bbClaude207
3ef4c9dClaude208// Request context (request ID, start time) runs before everything else
209app.use("*", requestContext);
05b973eClaude210// Middleware — compression first (wraps all responses)
211app.use("*", compress());
f1ffd50Claude212
213// ETag middleware — returns 304 Not Modified on unchanged responses.
214// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
215// SSE + the API surface where it would interfere with streaming.
216app.use("*", async (c, next) => {
217 const p = c.req.path;
218 if (
219 p.includes(".git/") ||
220 p.startsWith("/live-events") ||
221 p.startsWith("/api/events/deploy") ||
3c03977Claude222 p.startsWith("/admin/status") ||
223 // PR live co-editing SSE stream — never etag streaming responses.
224 /^\/api\/v2\/pulls\/[^/]+\/live(\/|$)/.test(p)
f1ffd50Claude225 ) {
226 return next();
227 }
228 return etag()(c, next);
229});
230
231// Cache-Control middleware — sets sensible defaults on public, anonymous
232// requests. Crontech (when wired as our edge layer) and downstream
233// browsers will honor these. Auth'd users get private,no-store
234// automatically — we never cache responses tied to a session.
235app.use("*", async (c, next) => {
236 await next();
237 // Don't overwrite explicit headers set by route handlers — BUT the
238 // ETag middleware unconditionally sets "private, no-cache, must-
239 // revalidate" so we have to treat that specific value as "no
240 // policy chosen yet" and apply ours. Any route that explicitly set
241 // a different cache-control wins.
242 const existing = c.res.headers.get("cache-control");
243 const etagDefault =
244 existing === "private, no-cache, must-revalidate" ||
245 existing === "no-cache";
246 if (existing && !etagDefault) return;
247 // Anything past auth: private + no-store (avoid leaking session
248 // content into shared caches). softAuth runs before this on the
249 // request, but the response side is what we're stamping.
250 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
251 const p = c.req.path;
252 // Always private for known-authed paths regardless of cookie.
253 if (
254 p.startsWith("/admin") ||
255 p.startsWith("/settings") ||
256 p.startsWith("/dashboard") ||
257 p.startsWith("/notifications") ||
258 p.startsWith("/connect/") ||
259 hasSession
260 ) {
261 c.res.headers.set("cache-control", "private, no-store");
262 return;
263 }
264 // Public marketing surfaces — short edge cache, longer browser cache,
265 // stale-while-revalidate so the user never waits on a stale fetch.
266 const isMarketing =
267 p === "/" ||
268 p === "/features" ||
269 p === "/pricing" ||
270 p === "/about" ||
271 p === "/vs-github" ||
272 p === "/explore" ||
273 p === "/help" ||
274 p === "/changelog" ||
9f29b65Claude275 p === "/enterprise" ||
f1ffd50Claude276 p.startsWith("/legal/") ||
277 p === "/terms" ||
278 p === "/privacy" ||
279 p === "/acceptable-use" ||
280 p.startsWith("/docs/");
281 if (isMarketing) {
282 c.res.headers.set(
283 "cache-control",
284 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
285 );
286 return;
287 }
288 // Public repo browse pages — cache aggressively. Edge invalidates
289 // on push via the post-receive hook (future Crontech surge purge).
290 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
291 c.res.headers.set(
292 "cache-control",
293 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
294 );
295 return;
296 }
297 // Default: don't cache anything we haven't explicitly opted in.
298 c.res.headers.set("cache-control", "private, no-store");
299});
05b973eClaude300// Logger only on non-git routes to avoid overhead on clone/push
301app.use("*", async (c, next) => {
302 if (c.req.path.includes(".git/")) return next();
303 return logger()(c, next);
304});
79136bbClaude305app.use("/api/*", cors());
bf19c50Test User306// Global softAuth — populates c.get("user") for every downstream middleware
307// + route. This was previously per-route, which meant rate-limit middleware
308// (and anything else inspecting auth state) always saw a null user. Keep
309// individual routes free to add requireAuth on top for hard gating; this
310// just establishes the user object cheaply.
311app.use("*", softAuth);
290ea77Claude312
36cc17aClaude313// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude314// pre-redesign markup. JSON / static assets keep their own cache rules; only
315// text/html responses get the no-cache stamp. Without this, every push to
316// main left users staring at cached 80s-looking pages from before the design
317// landed.
36cc17aClaude318//
319// We deliberately use `private, no-cache, must-revalidate` rather than
320// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
321// which makes every Back/Forward press a cold server round-trip — that
322// contributed to the "every nav feels like a fresh login" UX complaint.
323// `no-cache` still revalidates on direct fetch but lets bfcache hold the
324// page in memory between navigations.
290ea77Claude325app.use("*", async (c, next) => {
326 await next();
327 const ct = c.res.headers.get("content-type") || "";
328 if (ct.startsWith("text/html")) {
36cc17aClaude329 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude330 }
331});
826eccfTest User332// Rate-limit API + auth endpoints.
333//
a41e675Test User334// `/api/*`: 1000/min per IP — generous so an admin clicking around the
335// operator console (or a CDN/proxy concentrating multiple users behind one
336// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
337// rate limits below, not this one.
338//
339// `authedMultiplier` is set but only fires when an upstream middleware has
340// already populated c.get("user") — most app.use() chains apply softAuth
341// per-route, so the multiplier is best-effort. Keep the anonymous base
342// high enough that humans never feel it.
343//
344// Skip-paths: dashboard plumbing endpoints that the layout polls on a
345// fixed cadence and that we don't want consuming any bucket:
346// /api/version — layout polls every 15s
826eccfTest User347// /api/notifications/count — nav bell unread-count fetcher
348// /pwa/vapid-public-key — fetched once per push-notification opt-in
349app.use(
350 "/api/*",
a41e675Test User351 rateLimit(1000, 60_000, "api", {
826eccfTest User352 authedMultiplier: 4,
353 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
354 })
355);
0316dbbClaude356app.use("/login", rateLimit(20, 60_000, "login"));
357app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude358// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
359app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User360// BLOCK Q2 — throttle magic-link sign-in for the same reason.
361app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude362
59b6fb2Claude363// CSRF protection — set token on all requests, validate on mutations
364app.use("*", csrfToken);
365app.use("*", csrfProtect);
366
45e31d0Claude367// Rate limit auth routes
368app.use("/login", authRateLimit);
369app.use("/register", authRateLimit);
370
59b6fb2Claude371// Rate limit git operations
372app.use("/:owner/:repo.git/*", gitRateLimit);
373
374// Rate limit search
375app.use("/:owner/:repo/search", searchRateLimit);
376app.use("/explore", searchRateLimit);
79136bbClaude377
f5b9ef5Claude378// No-cache for HTML — ensures browsers and proxies never serve stale pages.
379// The middleware only stamps text/html responses so static assets keep
380// their own cache policies unchanged.
381app.use("*", noCache);
382
79136bbClaude383// Git Smart HTTP protocol routes (must be before web routes)
384app.route("/", gitRoutes);
385
45e31d0Claude386// REST API v1 (legacy)
79136bbClaude387app.route("/", apiRoutes);
388
52ad8b1Claude389// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
390// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
391// router's catch-shape, and BEFORE adminRoutes so the live /demo page
392// wins over the legacy /demo redirect in src/routes/admin.tsx.
393app.route("/", demoRoutes);
394
0316dbbClaude395// REST API v2 (basePath /api/v2)
396app.route("/", apiV2Routes);
397
e75eddcClaude398// Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage).
399// Mounted alongside apiV2Routes (its own basePath, no path conflict).
400app.route("/", agentsRoutes);
401
ef3fd93Claude402// Multi-agent pipeline UI — /:owner/:repo/agents (list, new, live view).
403// Must be before webRoutes (the catch-all) so the /agents sub-paths are
404// resolved before the generic tree/blob route takes over.
405app.route("/", agentPipelinesRoutes);
406
ad6d4adClaude407// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
408app.route("/", hookRoutes);
21f8dbdClaude409app.route("/api/events", eventsRoutes);
ad6d4adClaude410
45e31d0Claude411// API documentation
412app.route("/", apiDocsRoutes);
4a80519Claude413app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude414// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
415app.route("/", pullsDashboardRoutes);
e9aa4d8Claude416// Issue command center — global issue dashboard with AI-triage + autopilot signal
417app.route("/", issuesDashboardRoutes);
418// Personal activity timeline — every event across the user's repos, with
419// AI-driven events surfaced separately (the Gluecron differentiator).
420app.route("/", activityRoutes);
421// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
422app.route("/", inboxRoutes);
56801e1Claude423// AI standup feed — daily / weekly Claude-generated team brief
424app.route("/", standupRoutes);
cc34156Claude425// Smart morning digest — AI-curated daily developer queue (/digest)
426app.route("/", digestRoutes);
79136bbClaude427
428// Auth routes (register, login, logout)
429app.route("/", authRoutes);
430
c63b860Claude431// BLOCK P1 — Password reset (forgot-password + reset-password)
432app.route("/", passwordResetRoutes);
433
434// BLOCK P2 — Email verification (verify-email + resend)
435app.route("/", emailVerificationRoutes);
436
cd4f63bTest User437// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
438app.route("/", magicLinkRoutes);
439
79136bbClaude440// Settings routes (profile, SSH keys)
441app.route("/", settingsRoutes);
442
ba9e143Claude443// Session management (SOC 2 CC6.1 — /settings/sessions)
444app.route("/", settingsSessionsRoutes);
445
7298a17Claude446// 2FA / TOTP settings (Block B4)
447app.route("/", settings2faRoutes);
448
e75eddcClaude449// Agent multiplayer — /settings/agents management UI
450app.route("/", settingsAgentsRoutes);
451
1d4ff60Claude452// Chat integrations — Slack / Discord / Teams (/settings/integrations
453// + /api/v2/integrations/{slack,discord}/*). See src/lib/chat-bot.ts.
454app.route("/", settingsIntegrationsRoutes);
455app.route("/", integrationsChatRoutes);
456
2df1f8cClaude457// WebAuthn / passkey routes (Block B5)
458app.route("/", passkeyRoutes);
459
058d752Claude460// OAuth 2.0 provider (Block B6)
461app.route("/", oauthRoutes);
462app.route("/", developerAppsRoutes);
463
6fc53bdClaude464// Theme toggle (dark/light cookie)
465app.route("/", themeRoutes);
466
467// Audit log UI
468app.route("/", auditRoutes);
469
470// Reactions API (issues, PRs, comments)
471app.route("/", reactionRoutes);
472
24cf2caClaude473// Saved replies (per-user canned comment templates)
474app.route("/", savedReplyRoutes);
475
476// Environments + deployment history UI
477app.route("/", deploymentRoutes);
478
6563f0aClaude479// Organizations + teams (Block B1)
480app.route("/", orgRoutes);
481
c81ab7aClaude482// API tokens
483app.route("/", tokenRoutes);
484
59b6fb2Claude485// Notifications
3ef4c9dClaude486app.route("/", notificationRoutes);
487
79136bbClaude488// Repo settings (description, visibility, delete)
489app.route("/", repoSettings);
490
23d1a81Claude491// Repo collaborators (add/list/remove)
492app.route("/", collaboratorRoutes);
493
04f6b7fClaude494// Team-based repo collaborators (invite a whole team)
495app.route("/", teamCollaboratorRoutes);
496
497// Collaborator invite accept flow (token-based)
498app.route("/", invitesRoutes);
499
500// Real-time SSE endpoint (topic-based live updates)
501app.route("/", liveEventsRoutes);
502
3c03977Claude503// PR live co-editing — presence + cursors + content sync via SSE.
504app.route("/", prLiveRoutes);
505
c81ab7aClaude506// Webhooks management
507app.route("/", webhookRoutes);
508
79136bbClaude509// Compare view (branch diffs)
510app.route("/", compareRoutes);
511
512// Issue tracker
513app.route("/", issueRoutes);
514
85c4e13Claude515// Milestones — group issues + PRs toward a shared goal with due dates + progress tracking.
516// Mounted after issueRoutes so /:owner/:repo/issues/* paths win before the milestone patterns.
517app.route("/", milestonesRoutes);
518
f928118Claude519// Ship Agent — autonomous AI feature implementation
520app.route("/", shipAgentRoutes);
521
cb5a796Claude522// Comment moderation queue — owner-only `/:owner/:repo/comments/pending`
523// + per-row approve/reject/spam actions. Mounted before `pullRoutes` so
524// the `/:owner/:repo/comments/*` paths resolve before the broader PR
525// patterns kick in.
526app.route("/", commentModerationRoutes);
527
0074234Claude528// Pull requests
529app.route("/", pullRoutes);
09d5f39Claude530
531// /stage PR preview — serve built static files from .stage-previews/{jobId}/
532// Registered immediately after pullRoutes so the path `/preview/:id/*` is
533// specific enough to never clash with repo browse routes (`/:owner/:repo/*`).
534app.get("/preview/:stageJobId/*", async (c) => {
535 const { stageJobId } = c.req.param();
536 // Validate job ID format (UUID)
537 if (!/^[0-9a-f-]{32,}$/i.test(stageJobId)) {
538 return c.text("Not found", 404);
539 }
540 const { getPreviewDir, isPreviewExpired } = await import("./lib/pr-stage");
541 if (isPreviewExpired(stageJobId)) {
542 return c.html(
543 "<html><body style='font-family:sans-serif;padding:40px;color:#888'>" +
544 "<h2>Preview expired</h2><p>This stage preview has expired (48h TTL). " +
545 "Comment <code>/stage</code> on the PR to redeploy.</p></body></html>",
546 410
547 );
548 }
549 const { join } = await import("path");
550 const previewDir = getPreviewDir(stageJobId);
551 // Extract the wildcard path after /preview/:id/
552 const rawPath = c.req.path.replace(/^\/preview\/[^/]+/, "") || "/";
553 const filePath = rawPath === "/" || rawPath === "" ? "/index.html" : rawPath;
554 const fullPath = join(previewDir, filePath);
555 const file = Bun.file(fullPath);
556 if (!(await file.exists())) {
557 // Try index.html fallback (SPA behaviour)
558 const indexFile = Bun.file(join(previewDir, "index.html"));
559 if (await indexFile.exists()) {
560 const html = await indexFile.text();
561 return c.html(html);
562 }
563 return c.text("Not found", 404);
564 }
565 const content = await file.arrayBuffer();
566 const ext = fullPath.split(".").pop()?.toLowerCase() ?? "";
567 const contentTypeMap: Record<string, string> = {
568 html: "text/html; charset=utf-8",
569 htm: "text/html; charset=utf-8",
570 css: "text/css; charset=utf-8",
571 js: "application/javascript; charset=utf-8",
572 mjs: "application/javascript; charset=utf-8",
573 json: "application/json; charset=utf-8",
574 png: "image/png",
575 jpg: "image/jpeg",
576 jpeg: "image/jpeg",
577 gif: "image/gif",
578 svg: "image/svg+xml",
579 ico: "image/x-icon",
580 webp: "image/webp",
581 woff: "font/woff",
582 woff2: "font/woff2",
583 ttf: "font/ttf",
584 txt: "text/plain; charset=utf-8",
585 xml: "application/xml",
586 webmanifest: "application/manifest+json",
587 };
588 const ct = contentTypeMap[ext] ?? "application/octet-stream";
589 return c.body(content, 200, {
590 "content-type": ct,
591 "cache-control": "public, max-age=300",
592 "x-stage-job-id": stageJobId,
593 });
594});
595
79ed944Claude596// PR sandboxes — runnable per-PR environments. Migration 0067.
597app.route("/", prSandboxRoutes);
0074234Claude598
9b3a183Claude599// Cloud dev environments — hosted VS Code in the browser. Migration 0072.
600app.route("/", devEnvRoutes);
601
c81ab7aClaude602// Fork
603app.route("/", forkRoutes);
604
0074234Claude605// Web file editor
606app.route("/", editorRoutes);
607
6f2809fClaude608// AI editor API routes (inline suggestions, explain, fix)
609app.route("/", aiEditorRoutes);
610
43de941Claude611// Contributors
612app.route("/", contributorRoutes);
613
699e5c7Claude614// Health liveness + metrics endpoints
2c34075Claude615app.route("/", healthRoutes);
616
f295f78Dictation App617// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
618app.route("/api/platform-status", platformStatus);
619
52ad8b1Claude620// Block L4 — Public stats counters (powers landing-page social proof)
621app.route("/", publicStatsRoutes);
622
623// Block L3 — Live /demo page + /api/v2/demo/* endpoints
624app.route("/", demoRoutes);
625
2316be6Claude626// Public /status — human-readable platform health page
627app.route("/", statusRoutes);
628
b1be050CC LABS App629// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
630// Mounted near the public status route so the two surfaces are visible
631// side-by-side; routes are gated by isSiteAdmin internally.
632app.route("/", adminStatusRoutes);
633
80bed05Claude634// /help — quickstart + API cheatsheet
635app.route("/", helpRoutes);
636
e0e4219Claude637// /docs — expanded documentation site (getting started, workflow YAML, MCP, API, agents)
638app.route("/", docsRoutes);
639
5f2e749Claude640// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
641// so the new editorial pricing layout wins the route; the legacy marketing
642// pricing remains as a safety net but is shadowed at the router.
643app.route("/", pricingRoutes);
644
e1fc7dbClaude645// /changelog — manually curated platform release history
646app.route("/", changelogRoutes);
647
9f29b65Claude648// Enterprise sales page + contact form lead capture.
649app.route("/", enterpriseRoutes);
650
b0148e9Claude651// /pricing, /features, /about — marketing surface
652app.route("/", marketingRoutes);
653
adf5e18Claude654// /developer-program — partner + marketplace revenue-share page
655app.route("/", developerProgramRoutes);
656
5618f9aClaude657// SEO: robots.txt + sitemap.xml
658app.route("/", seoRoutes);
659
05cdb85Claude660// /api/version — live build SHA + uptime; client poller uses this to
661// surface 'New version available — reload' banners on deploy.
662app.route("/", versionRoutes);
663
699e5c7Claude664// Health dashboard (per-repo health page)
665app.route("/", healthDashboardRoutes);
666
9dd96b9Test User667// Block R1 — site-admin operations console. MUST be mounted BEFORE
668// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
669// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
670app.route("/", adminOpsRoutes);
f2c00b4CC LABS App671// BLOCK W — Self-host status + bootstrap dashboard.
672app.route("/", adminSelfHostRoutes);
826eccfTest User673// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
674app.route("/", adminDiagnoseRoutes);
9dd96b9Test User675
16b325cClaude676// Insights (time-travel, dependencies, rollback)
677app.route("/", insightRoutes);
678
8286942Claude679// Engineering Intelligence Dashboard — /insights + /:owner/:repo/insights/engineering
680app.route("/", engineeringInsightsRoutes);
681
8d1483cClaude682// DORA metrics page (/:owner/:repo/insights/dora)
683app.route("/", doraRoutes);
684
f1ab587Claude685// Command center dashboard
686app.route("/", dashboardRoutes);
687
36b4cbdClaude688// Legal pages (terms, privacy, AUP)
689app.route("/", legalRoutes);
4b66018Claude690// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
691// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
692// /acceptable-use); these are the formal versions that the legal pages
693// internally link to each other.
694app.route("/", legalTermsRoutes);
695app.route("/", legalPrivacyRoutes);
696app.route("/", legalAcceptableUseRoutes);
697app.route("/", legalDmcaRoutes);
36b4cbdClaude698
bdbd0deClaude699// GitHub import / migration
700app.route("/", importRoutes);
14c3cc8Claude701app.route("/", importBulkRoutes);
f390cfaCC LABS App702app.route("/", importSecretsRoutes);
bb2dea9Claude703// GitHub Actions → Gluecron gates.yml importer (stateless converter)
704app.route("/", actionsImporterRoutes);
14c3cc8Claude705app.route("/", migrationRoutes);
9a8b8deClaude706// GitHub Org Migration Wizard — live progress bulk importer
707app.route("/", migrateRoutes);
14c3cc8Claude708
709// Spec-to-PR (experimental AI-generated draft PRs)
710app.route("/", specsRoutes);
23d0abfClaude711app.route("/", refactorRoutes);
b665cacClaude712app.route("/", codebaseMigratorRoutes);
bdbd0deClaude713
c81ab7aClaude714// Explore page
715app.route("/", exploreRoutes);
716
59b6fb2Claude717// Onboarding
718app.route("/", onboardingRoutes);
719
0316dbbClaude720// Admin + feature routes
721app.route("/", adminRoutes);
7293c67Claude722app.route("/", adminDeletionsRoutes);
723app.route("/", adminStripeRoutes);
ba9e143Claude724
725// SOC 2 security dashboard + readiness checklist (/admin/security, /admin/soc2)
726app.route("/", adminSecurityRoutes);
509c376Claude727app.route("/", adminIntegrationsRoutes);
79ed944Claude728app.route("/", adminAdvancementRoutes);
f764c07Claude729app.route("/", adminDeploysRoutes);
730app.route("/", adminDeploysPageRoutes);
783dd46Claude731app.route("/", adminServerTargetsRoutes);
9aaa128Claude732app.route("/", deployTargetsRoutes);
90c7531Claude733app.route("/", claudeWebRoutes);
9dd96b9Test User734// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude735app.route("/", advisoriesRoutes);
736app.route("/", aiChangelogRoutes);
0a69faaClaude737// "Explain This Repo" — rich structured AI analysis dashboard (mounted before
738// the simpler aiExplainRoutes so the new routes win on /:owner/:repo/explain).
739app.route("/", explainRoutes);
0316dbbClaude740app.route("/", aiExplainRoutes);
741app.route("/", aiTestsRoutes);
742app.route("/", askRoutes);
38d31d3Claude743app.route("/", repoChatRoutes);
ee7e577Claude744// Personal cross-repo chat — `/chat` (user-scoped). Mounted alongside
745// repoChatRoutes so the two surfaces share the catch-all priority.
746app.route("/", personalChatRoutes);
0316dbbClaude747app.route("/", billingRoutes);
8809b87Claude748app.route("/", billingUsageRoutes);
6778ad2Claude749app.route("/", stripeWebhookRoutes);
0316dbbClaude750app.route("/", codeScanningRoutes);
da3fc18Claude751// Dependency CVE scanner findings page — /:owner/:repo/security/vulnerabilities
752app.route("/", securityRoutes);
0316dbbClaude753app.route("/", commitStatusesRoutes);
754app.route("/", copilotRoutes);
755app.route("/", depUpdaterRoutes);
756app.route("/", depsRoutes);
757app.route("/", discussionsRoutes);
758app.route("/", environmentsRoutes);
4bbacbeClaude759app.route("/", previewsRoutes);
79ed944Claude760app.route("/", docsTrackingRoutes);
0316dbbClaude761app.route("/", followsRoutes);
762app.route("/", gatesRoutes);
763app.route("/", gistsRoutes);
764app.route("/", graphqlRoutes);
2c2163eClaude765app.route("/", mcpRoutes);
0316dbbClaude766app.route("/", marketplaceRoutes);
5ca514aClaude767app.route("/", marketplaceAgentsRoutes);
0316dbbClaude768app.route("/", mergeQueueRoutes);
769app.route("/", mirrorsRoutes);
770app.route("/", orgInsightsRoutes);
771app.route("/", packagesRoutes);
772app.route("/", packagesApiRoutes);
845fd8aClaude773// OCI / Docker container registry — /v2/* (OCI Distribution Spec v1.0)
774app.route("/", ociRegistryRoutes);
0316dbbClaude775app.route("/", pagesRoutes);
776app.route("/", projectsRoutes);
777app.route("/", protectedTagsRoutes);
778app.route("/", pwaRoutes);
46d6165Claude779app.route("/", installRoutes);
cd4f63bTest User780// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
781app.route("/", dxtRoutes);
662ce86Claude782// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
783// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
784app.route("/", connectClaudeRoutes);
f5b9ef5Claude785// Claude Code Integration Receiver — /api/claude/connect + /api/claude/session.
786app.route("/", claudeIntegration);
787// Connect guide — public onboarding page (/connect/claude-guide).
788app.route("/", connectRoutes);
05ab9b1Claude789// Push Watch — per-commit live status (gates + deploy + latency) at /:owner/:repo/push/:sha
790app.route("/", pushWatchRoutes);
791// Org Secrets Manager — BLOCK M2 — /orgs/:slug/settings/secrets
792app.route("/", orgSecretsRoutes);
a2b3e99Claude793// Cross-repo code search — BLOCK M3 — /search/code + /api/search/code
794app.route("/", crossRepoSearchRoutes);
795// Browser push notifications — BLOCK M4 — /settings/notifications/push + /api/push/*
796app.route("/", pushNotifRoutes);
9fbe6cdClaude797// Developer Velocity Dashboard — BLOCK M9 — /:owner/:repo/insights/velocity
798app.route("/", velocityRoutes);
799// Stale Branch Cleanup — BLOCK M10 — /:owner/:repo/branches/stale
800app.route("/", staleBranchRoutes);
22f43f3Claude801// Repository Pulse — BLOCK M12 — /:owner/:repo/pulse
802app.route("/", pulseRoutes);
74d8c4dClaude803// Repository Health Score — BLOCK M14 — /:owner/:repo/insights/health
804app.route("/", healthScoreRoutes);
805// Hot Files Heatmap — BLOCK M16 — /:owner/:repo/insights/hotfiles
806app.route("/", hotFilesRoutes);
bcc4020Claude807// AI Technical Debt Map — /:owner/:repo/debt-map (visual debt graph + Claude analysis)
808app.route("/", debtMapRoutes);
1d6db4dClaude809// Bus Factor Analysis — /:owner/:repo/insights/bus-factor
810app.route("/", busFactorRoutes);
ebbb527Claude811// Hosted Claude tool-use loops — paste loop, get endpoint, billing meter.
812// See src/routes/claude-deploy.tsx + src/lib/hosted-claude-loop.ts.
813app.route("/", claudeDeployRoutes);
0316dbbClaude814app.route("/", releasesRoutes);
815app.route("/", requiredChecksRoutes);
816app.route("/", rulesetsRoutes);
817app.route("/", searchRoutes);
818app.route("/", semanticSearchRoutes);
819app.route("/", signingKeysRoutes);
820app.route("/", sponsorsRoutes);
821app.route("/", ssoRoutes);
3a845e4Claude822// Enterprise per-org SAML 2.0 + OIDC SSO routes
823app.route("/", samlSsoRoutes);
824// SCIM 2.0 user provisioning endpoints
825app.route("/", scimRoutes);
826// Per-org SSO + SCIM admin settings UI
827app.route("/", orgSsoSettingsRoutes);
46d6165Claude828app.route("/", githubOauthRoutes);
582cdacClaude829app.route("/", googleOauthRoutes);
0316dbbClaude830app.route("/", symbolsRoutes);
831app.route("/", templatesRoutes);
832app.route("/", trafficRoutes);
833app.route("/", wikisRoutes);
834app.route("/", workflowsRoutes);
5ff9cc2Claude835app.route("/", workflowArtifactsRoutes);
836app.route("/", workflowSecretsRoutes);
46d6165Claude837app.route("/", sleepModeRoutes);
52ad8b1Claude838app.route("/", vsGithubRoutes);
0316dbbClaude839
45f3b73Claude840// Voice-to-PR — phone-first dictation → spec or issue
841app.route("/", voiceRoutes);
842
3122762Claude843// Blog / Devlog — public posts, no DB
844app.route("/", blogRoutes);
845
cd4f63bTest User846// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
847// before the web catch-all so the bare `/play` literal wins over the
848// `/:owner` user-profile route.
849app.route("/", playgroundRoutes);
850
891efbeClaude851// Shareable AI hours-saved OG image card + landing page.
852// /share/hours-saved?user=:username → 1200×630 SVG (og:image)
853// /share/:username → HTML page with og:image meta + Twitter share
854// Mounted BEFORE webRoutes so /share/* doesn't fall through to the /:owner profile route.
855app.route("/", shareRoutes);
856
79136bbClaude857// Web UI (catch-all, must be last)
858app.route("/", webRoutes);
859
c63b860Claude860// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
861// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude862app.notFound((c) => {
36cc17aClaude863 const user = c.get("user") ?? null;
79136bbClaude864 return c.html(
c63b860Claude865 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude866 404
867 );
868});
869
c63b860Claude870// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
871// view. Trace block only shown outside production.
79136bbClaude872app.onError((err, c) => {
80bed05Claude873 reportError(err, {
874 requestId: c.get("requestId"),
875 path: c.req.path,
876 method: c.req.method,
877 });
c63b860Claude878 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
879 // back to the context value set by request-context middleware.
880 const requestId =
881 c.req.header("x-request-id") ||
882 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude883 const user = c.get("user") ?? null;
c63b860Claude884 const trace =
885 process.env.NODE_ENV !== "production" && err && err.message
886 ? err.message
887 : undefined;
79136bbClaude888 return c.html(
c63b860Claude889 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude890 500
891 );
892});
893
894export default app;