Skip to content

Production-ready animations, transitions, backgrounds, and scenes for Remotion

feat: make remocn.dev readable for agents

kapishdimaaf8c756383e1
diff --git a/app/(home)/about/page.tsx b/app/(home)/about/page.tsx
new file mode 100644
index 00000000..bd44f806
--- /dev/null
+++ b/app/(home)/about/page.tsx
@@ -0,0 +1,47 @@
+import type { Metadata } from "next";
+import { SITE_PAGES, sitePageOgImage } from "@/config/site-pages";
+import { ABOUT } from "@/config/trust-pages";
+import { SitePageHeader } from "../components/site-page/page-header";
+import { TrustArticle } from "../components/site-page/trust-article";
+
+const DESCRIPTION = SITE_PAGES.about.description;
+
+const TITLE = "About · Remocn";
+
+export const metadata: Metadata = {
+ title: "About",
+ description: DESCRIPTION,
+ alternates: { canonical: "/about" },
+ openGraph: {
+ type: "website",
+ url: "/about",
+ siteName: "Remocn",
+ title: TITLE,
+ description: DESCRIPTION,
+ locale: "en_US",
+ images: [sitePageOgImage("about")],
+ },
+ twitter: {
+ card: "summary_large_image",
+ title: TITLE,
+ description: DESCRIPTION,
+ images: [sitePageOgImage("about").url],
+ },
+};
+
+export default function AboutPage() {
+ return (
+ <>
+ <SitePageHeader
+ eyebrow="remocn.dev/about"
+ title="About Remocn"
+ continuation="Video components your agent can use."
+ />
+ <TrustArticle
+ lead={ABOUT.lead}
+ sections={ABOUT.sections}
+ links={ABOUT.links}
+ />
+ </>
+ );
+}
diff --git a/app/(home)/components/site-page/trust-article.tsx b/app/(home)/components/site-page/trust-article.tsx
new file mode 100644
index 00000000..98b04c50
--- /dev/null
+++ b/app/(home)/components/site-page/trust-article.tsx
@@ -0,0 +1,117 @@
+import Link from "next/link";
+import type {
+ ContactChannel,
+ TrustLink,
+ TrustSection,
+} from "@/config/trust-pages";
+import { cn } from "@/lib/utils";
+import { landingButtonVariants } from "../landing/ui/landing-button";
+
+/**
+ * Body of /about and /contact, in the type and card styles of /legal: a large
+ * lead, then sections of h2 + paragraphs, with optional channel cards and a
+ * row of follow-up links.
+ */
+
+const BODY = "text-ui leading-6 text-body";
+
+/** Renders `code` spans written in backticks. */
+function Prose({ text }: { text: string }) {
+ return text
+ .split(/(`[^`]+`)/g)
+ .map((part, index) =>
+ part.startsWith("`") && part.endsWith("`") ? (
+ <code key={index}>{part.slice(1, -1)}</code>
+ ) : (
+ part
+ ),
+ );
+}
+
+export function TrustArticle({
+ lead,
+ sections,
+ channels,
+ links,
+}: {
+ lead: string;
+ sections: TrustSection[];
+ channels?: ContactChannel[];
+ links?: TrustLink[];
+}) {
+ return (
+ <div className="landing-container pb-[72px] xl:pb-section">
+ <article className="min-w-0 xl:border-t xl:border-divider xl:pt-14">
+ <div className="flex flex-col gap-12 xl:w-[680px] xl:gap-14">
+ <p className="text-[20px] leading-7 tracking-[-0.01em] text-foreground xl:text-[22px] xl:leading-8">
+ {lead}
+ </p>
+
+ {channels && (
+ <ul className="grid gap-3 sm:grid-cols-2">
+ {channels.map((channel) => (
+ <li key={channel.title}>
+ <a
+ href={channel.href}
+ {...(channel.href.startsWith("http")
+ ? { target: "_blank", rel: "noreferrer" }
+ : {})}
+ className="flex h-full flex-col gap-1.5 rounded-card bg-surface p-5 shadow-[0_0_0_1px_var(--hairline)] outline-none transition-colors hover:bg-surface-muted focus-visible:ring-2 focus-visible:ring-ring"
+ >
+ <span className="text-caption text-subtle">
+ {channel.title}
+ </span>
+ <span className="text-ui leading-6 font-medium text-foreground">
+ {channel.value}
+ </span>
+ <span className={BODY}>{channel.body}</span>
+ </a>
+ </li>
+ ))}
+ </ul>
+ )}
+
+ {sections.map((section) => (
+ <section
+ key={section.id}
+ aria-labelledby={section.id}
+ className="flex flex-col gap-3.5 xl:gap-4"
+ >
+ <h2
+ id={section.id}
+ className="scroll-mt-28 text-[22px] leading-7 font-medium tracking-title text-foreground xl:scroll-mt-8 xl:text-[24px] xl:leading-[30px]"
+ >
+ {section.title}
+ </h2>
+ {section.body.map((paragraph) => (
+ <p key={paragraph} className={BODY}>
+ <Prose text={paragraph} />
+ </p>
+ ))}
+ </section>
+ ))}
+
+ {links && (
+ <nav aria-label="Next" className="flex flex-wrap gap-2.5">
+ {links.map((link) => (
+ <Link
+ key={link.href}
+ href={link.href}
+ {...(link.external
+ ? { target: "_blank", rel: "noreferrer" }
+ : {})}
+ className={cn(
+ landingButtonVariants({ variant: "secondary" }),
+ "h-11 rounded-control-sm px-4 text-[15px] leading-5 xl:h-10 xl:text-small",
+ )}
+ >
+ {link.label}
+ </Link>
+ ))}
+ </nav>
+ )}
+ </div>
+ </article>
+ </div>
+ );
+}
diff --git a/app/(home)/contact/page.tsx b/app/(home)/contact/page.tsx
new file mode 100644
index 00000000..9cc47488
--- /dev/null
+++ b/app/(home)/contact/page.tsx
@@ -0,0 +1,47 @@
+import type { Metadata } from "next";
+import { SITE_PAGES, sitePageOgImage } from "@/config/site-pages";
+import { CONTACT } from "@/config/trust-pages";
+import { SitePageHeader } from "../components/site-page/page-header";
+import { TrustArticle } from "../components/site-page/trust-article";
+
+const DESCRIPTION = SITE_PAGES.contact.description;
+
+const TITLE = "Contact · Remocn";
+
+export const metadata: Metadata = {
+ title: "Contact",
+ description: DESCRIPTION,
+ alternates: { canonical: "/contact" },
+ openGraph: {
+ type: "website",
+ url: "/contact",
+ siteName: "Remocn",
+ title: TITLE,
+ description: DESCRIPTION,
+ locale: "en_US",
+ images: [sitePageOgImage("contact")],
+ },
+ twitter: {
+ card: "summary_large_image",
+ title: TITLE,
+ description: DESCRIPTION,
+ images: [sitePageOgImage("contact").url],
+ },
+};
+
+export default function ContactPage() {
+ return (
+ <>
+ <SitePageHeader
+ eyebrow="remocn.dev/contact"
+ title="Contact"
+ continuation="Questions, bugs, sponsorship."
+ />
+ <TrustArticle
+ lead={CONTACT.lead}
+ channels={CONTACT.channels}
+ sections={CONTACT.sections}
+ />
+ </>
+ );
+}
diff --git a/app/(home)/page.tsx b/app/(home)/page.tsx
index 53b071f3..46e2940f 100644
--- a/app/(home)/page.tsx
+++ b/app/(home)/page.tsx
@@ -1,4 +1,7 @@
import type { Metadata } from "next";
+import { JsonLd } from "@/components/json-ld";
+import { SITE_DESCRIPTION } from "@/config/site";
+import { HOME_KEYWORDS, homeJsonLd } from "@/lib/structured-data";
import { FinalCta } from "./components/landing/sections/final-cta";
import { Hero } from "./components/landing/sections/hero";
import { HowItWorks } from "./components/landing/sections/how-it-works";
@@ -12,11 +15,13 @@ import { RevealScope } from "./components/landing/ui/reveal-scope";
export const metadata: Metadata = {
alternates: { canonical: "/" },
+ keywords: HOME_KEYWORDS,
};
export default function Page() {
return (
<>
+ <JsonLd data={homeJsonLd(SITE_DESCRIPTION)} />
<Hero />
<SponsorsStrip />
<HowItWorks />
diff --git a/app/api/[...path]/__tests__/route.test.ts b/app/api/[...path]/__tests__/route.test.ts
new file mode 100644
index 00000000..5ee7bba3
--- /dev/null
+++ b/app/api/[...path]/__tests__/route.test.ts
@@ -0,0 +1,26 @@
+import { describe, expect, test } from "bun:test";
+import { DELETE, GET, PATCH, POST, PUT } from "../route";
+
+describe("unknown /api paths", () => {
+ for (const [method, handler] of Object.entries({
+ GET,
+ POST,
+ PUT,
+ PATCH,
+ DELETE,
+ })) {
+ test(`${method} answers a JSON 404 with a hint`, async () => {
+ const res = handler(
+ new Request("https://remocn.dev/api/nope", { method }),
+ );
+ expect(res.status).toBe(404);
+ expect(res.headers.get("content-type")).toContain("application/json");
+ expect(await res.json()).toEqual({
+ error: "No API endpoint at /api/nope.",
+ code: "not_found",
+ hint: "See https://remocn.dev/openapi.json for the available endpoints.",
+ docs: "https://remocn.dev/openapi.json",
+ });
+ });
+ }
+});
diff --git a/app/api/[...path]/route.ts b/app/api/[...path]/route.ts
new file mode 100644
index 00000000..1dd51ffe
--- /dev/null
+++ b/app/api/[...path]/route.ts
@@ -0,0 +1,19 @@
+import { apiError } from "@/lib/api-error";
+
+// Any /api path with no route of its own. Without this Next answers with the
+// HTML 404 page, which an API client can't parse.
+function notFound(request: Request): Response {
+ const { pathname } = new URL(request.url);
+ return apiError(
+ 404,
+ "not_found",
+ `No API endpoint at ${pathname}.`,
+ "See https://remocn.dev/openapi.json for the available endpoints.",
+ );
+}
+
+export const GET = notFound;
+export const POST = notFound;
+export const PUT = notFound;
+export const PATCH = notFound;
+export const DELETE = notFound;
diff --git a/app/index.md/__tests__/route.test.ts b/app/index.md/__tests__/route.test.ts
new file mode 100644
index 00000000..d39a51a5
--- /dev/null
+++ b/app/index.md/__tests__/route.test.ts
@@ -0,0 +1,78 @@
+/**
+ * The Markdown routes that read the docs source: app/index.md (home page as
+ * Markdown), app/llms.txt and app/llms.md (one page). `@/source` is mocked
+ * with two pages so the tests don't need the generated fumadocs collection.
+ */
+import { describe, expect, mock, test } from "bun:test";
+
+const PAGES = [
+ {
+ slugs: ["getting-started", "introduction"],
+ url: "/docs/getting-started/introduction",
+ data: {
+ title: "Introduction",
+ description: "What Remocn is",
+ getText: async () => "---\ntitle: Introduction\n---\n\nHello.",
+ },
+ },
+];
+
+mock.module("@/source", () => ({
+ source: {
+ getPages: () => PAGES,
+ getPage: (slug?: string[]) =>
+ PAGES.find((p) => p.slugs.join("/") === (slug ?? []).join("/")),
+ generateParams: () => PAGES.map((p) => ({ slug: p.slugs })),
+ },
+}));
+
+const { GET: home } = await import("../route");
+const { GET: llmsTxt } = await import("@/app/llms.txt/route");
+const { GET: docPage } = await import("@/app/llms.md/[[...slug]]/route");
+
+describe("/index.md", () => {
+ test("is the llms.txt index served as text/markdown", async () => {
+ const res = home();
+ expect(res.status).toBe(200);
+ expect(res.headers.get("content-type")).toBe(
+ "text/markdown; charset=utf-8",
+ );
+ const body = await res.text();
+ expect(body).toStartWith("# Remocn");
+ expect(body).toBe(await llmsTxt().text());
+ });
+});
+
+describe("/llms.txt", () => {
+ test("stays text/plain and lists the docs", async () => {
+ const res = llmsTxt();
+ expect(res.headers.get("content-type")).toBe("text/plain; charset=utf-8");
+ expect(await res.text()).toContain(
+ "- [Introduction](https://remocn.dev/docs/getting-started/introduction.md): What Remocn is",
+ );
+ });
+});
+
+describe("/llms.md/<slug>", () => {
+ const call = (slug: string[]) =>
+ docPage(new Request("https://remocn.dev/x"), {
+ params: Promise.resolve({ slug }),
+ });
+
+ test("serves a known page as Markdown", async () => {
+ const res = await call(["getting-started", "introduction"]);
+ expect(res.status).toBe(200);
+ expect(res.headers.get("content-type")).toBe(
+ "text/markdown; charset=utf-8",
+ );
+ });
+
+ test("answers an unknown page with a Markdown 404", async () => {
+ const res = await call(["nope"]);
+ expect(res.status).toBe(404);
+ expect(res.headers.get("content-type")).toBe(
+ "text/markdown; charset=utf-8",
+ );
+ expect(await res.text()).toContain("`/docs/nope`");
+ });
+});
diff --git a/app/index.md/route.ts b/app/index.md/route.ts
new file mode 100644
index 00000000..8173a38f
--- /dev/null
+++ b/app/index.md/route.ts
@@ -0,0 +1,17 @@
+import { buildLlmsTxt, MARKDOWN_CONTENT_TYPE } from "@/lib/agent-docs";
+import { docsIndexPages } from "@/lib/docs-index";
+
+export const revalidate = false;
+
+// The home page (and `/docs`) as Markdown: the llms.txt index, served as
+// text/markdown. Agents reach it at `/` through the rewrites in next.config.ts;
+// `Vary: Accept, User-Agent` is set there for the URLs that negotiate.
+export function GET() {
+ return new Response(buildLlmsTxt(docsIndexPages()), {
+ headers: {
+ "Content-Type": MARKDOWN_CONTENT_TYPE,
+ // A copy of the HTML home page for agents; search should index the HTML.
+ "X-Robots-Tag": "noindex",
+ },
+ });
+}
diff --git a/app/layout.tsx b/app/layout.tsx
index 0048bd3a..1f63ab9c 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -6,6 +6,7 @@ import { ThemeProvider } from "next-themes";
import { NuqsAdapter } from "nuqs/adapters/next/app";
import "./globals.css";
import { OpenPanelComponent } from "@openpanel/nextjs";
+import { SITE_DESCRIPTION } from "@/config/site";
import { cn } from "@/lib/utils";
import { ThemeShortcut } from "./theme-shortcut";
@@ -31,8 +32,6 @@ const paperMono = localFont({
const SITE_URL = "https://remocn.dev";
const SITE_TITLE = "Remocn - Make a product demo video with your AI agent";
-const SITE_DESCRIPTION =
- "Describe your product, get a demo video. Ready-made animations, transitions and app-screen sims your coding agent can use. No video editor, no motion designer.";
export const metadata: Metadata = {
// Resolves the relative `/hero.png` below into an absolute URL for crawlers.
diff --git a/app/llms.md/[[...slug]]/route.ts b/app/llms.md/[[...slug]]/route.ts
index a980cff2..20b0aa3a 100644
--- a/app/llms.md/[[...slug]]/route.ts
+++ b/app/llms.md/[[...slug]]/route.ts
@@ -1,4 +1,4 @@
-import { notFound } from "next/navigation";
+import { markdownNotFound } from "@/lib/agent-docs";
import { getLLMText } from "@/lib/get-llm-text";
import { source } from "@/source";
@@ -13,7 +13,8 @@ export async function GET(
) {
const { slug } = await params;
const page = source.getPage(slug);
- if (!page) notFound();
+ // An agent asked for Markdown, so the 404 is Markdown too.
+ if (!page) return markdownNotFound(`/docs/${(slug ?? []).join("/")}`);
return new Response(await getLLMText(page), {
headers: {
diff --git a/app/llms.txt/route.ts b/app/llms.txt/route.ts
index 20541b20..e0003e06 100644
--- a/app/llms.txt/route.ts
+++ b/app/llms.txt/route.ts
@@ -1,58 +1,12 @@
-import { SITE_URL } from "@/lib/get-llm-text";
-import { source } from "@/source";
+import { buildLlmsTxt } from "@/lib/agent-docs";
+import { docsIndexPages } from "@/lib/docs-index";
export const revalidate = false;
// llms.txt — curated index of the docs for LLMs (https://llmstxt.org).
// Each entry links to the page's raw Markdown (`*.md`) served by app/llms.md.
export function GET() {
- const scanned: string[] = [];
-
- scanned.push("# Remocn");
- scanned.push(
- "\n> shadcn registry of production-ready Remotion components — animations, transitions, backgrounds, and full scenes. Install with `npx shadcn add remocn/<component>`.",
- );
- scanned.push(
- "\nDocs are also available as raw Markdown: append `.md` to any docs URL, or read [/llms-full.txt](" +
- `${SITE_URL}/llms-full.txt) for the full corpus in a single file.`,
- );
- scanned.push(
- `\nBuilding a video? Start at [/llms-components.txt](${SITE_URL}/llms-components.txt) — every` +
- " installable component in one table with its use / avoid signal, natural length, vibe and" +
- " dependencies, linking to each component's full page.",
- );
- scanned.push(
- "\nPrefer an app to a terminal? [Remocn Studio](https://remocn.studio) is a free, open-source" +
- " macOS app where the user's own coding agent (Claude Code, Codex, GitHub Copilot or Grok)" +
- " builds Remotion videos from Remocn components, with a live preview and export. Its own" +
- " index is at [remocn.studio/llms.txt](https://remocn.studio/llms.txt).",
- );
-
- // Group pages by their top-level section (first slug segment).
- const sections = new Map<string, ReturnType<typeof source.getPages>>();
- for (const page of source.getPages()) {
- const key = page.slugs[0] ?? "";
- const bucket = sections.get(key) ?? [];
- bucket.push(page);
- sections.set(key, bucket);
- }
-
- for (const [key, pages] of sections) {
- const heading = key
- ? key.replace(
- /(^|-)([a-z])/g,
- (_, sep, c) => (sep ? " " : "") + c.toUpperCase(),
- )
- : "Overview";
- scanned.push(`\n## ${heading}`);
- for (const page of pages) {
- const data = page.data;
- const desc = data.description ? `: ${data.description}` : "";
- scanned.push(`- [${data.title}](${SITE_URL}${page.url}.md)${desc}`);
- }
- }
-
- return new Response(scanned.join("\n"), {
+ return new Response(buildLlmsTxt(docsIndexPages()), {
headers: { "Content-Type": "text/plain; charset=utf-8" },
});
}
diff --git a/app/missing.md/[[...path]]/__tests__/route.test.ts b/app/missing.md/[[...path]]/__tests__/route.test.ts
new file mode 100644
index 00000000..a4c7c830
--- /dev/null
+++ b/app/missing.md/[[...path]]/__tests__/route.test.ts
@@ -0,0 +1,22 @@
+import { expect, test } from "bun:test";
+import { GET } from "../route";
+
+const call = (path?: string[]) =>
+ GET(new Request("https://remocn.dev/missing.md"), {
+ params: Promise.resolve({ path }),
+ });
+
+test("answers 404 with a Markdown body naming the path", async () => {
+ const res = await call(["__probe-123", "deep"]);
+ expect(res.status).toBe(404);
+ expect(res.headers.get("content-type")).toBe("text/markdown; charset=utf-8");
+ const body = await res.text();
+ expect(body).toContain("`/__probe-123/deep`");
+ expect(body).toContain("https://remocn.dev/llms.txt");
+});
+
+test("still answers 404 Markdown with no path", async () => {
+ const res = await call();
+ expect(res.status).toBe(404);
+ expect(await res.text()).toContain("# 404");
+});
diff --git a/app/missing.md/[[...path]]/route.ts b/app/missing.md/[[...path]]/route.ts
new file mode 100644
index 00000000..37fe86dd
--- /dev/null
+++ b/app/missing.md/[[...path]]/route.ts
@@ -0,0 +1,14 @@
+import { markdownNotFound, safeRequestedPath } from "@/lib/agent-docs";
+
+// The 404 an agent gets when it asked for Markdown. Reached through the
+// `fallback` rewrite in next.config.ts, which only runs once no page, file or
+// dynamic route matched; the original path arrives as the catch-all segments.
+export async function GET(
+ _request: Request,
+ { params }: { params: Promise<{ path?: string[] }> },
+) {
+ const { path } = await params;
+ return markdownNotFound(
+ path?.length ? safeRequestedPath(`/${path.join("/")}`) : undefined,
+ );
+}
diff --git a/app/openapi.json/__tests__/route.test.ts b/app/openapi.json/__tests__/route.test.ts
new file mode 100644
index 00000000..8d89bdfb
--- /dev/null
+++ b/app/openapi.json/__tests__/route.test.ts
@@ -0,0 +1,13 @@
+import { expect, test } from "bun:test";
+import { OPENAPI_SPEC } from "@/lib/openapi";
+import { GET } from "../route";
+
+test("serves the spec as JSON, readable cross-origin", async () => {
+ const res = GET();
+ expect(res.status).toBe(200);
+ expect(res.headers.get("content-type")).toBe(
+ "application/json; charset=utf-8",
+ );
+ expect(res.headers.get("access-control-allow-origin")).toBe("*");
+ expect(await res.json()).toEqual(JSON.parse(JSON.stringify(OPENAPI_SPEC)));
+});
diff --git a/app/openapi.json/route.ts b/app/openapi.json/route.ts
new file mode 100644
index 00000000..f0ed4c82
--- /dev/null
+++ b/app/openapi.json/route.ts
@@ -0,0 +1,14 @@
+import { OPENAPI_SPEC } from "@/lib/openapi";
+
+export const dynamic = "force-static";
+
+// OpenAPI 3.1 description of the public API; see lib/openapi.ts.
+export function GET() {
+ return new Response(JSON.stringify(OPENAPI_SPEC, null, 2), {
+ headers: {
+ "Content-Type": "application/json; charset=utf-8",
+ // Readable by browser-based agents and API explorers on other origins.
+ "Access-Control-Allow-Origin": "*",
+ },
+ });
+}
diff --git a/app/sitemap.ts b/app/sitemap.ts
index db288af3..ebcdec91 100644
--- a/app/sitemap.ts
+++ b/app/sitemap.ts
@@ -46,6 +46,18 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
changeFrequency: "weekly",
priority: 0.6,
},
+ {
+ url: `${SITE_URL}/about`,
+ lastModified: now,
+ changeFrequency: "yearly",
+ priority: 0.4,
+ },
+ {
+ url: `${SITE_URL}/contact`,
+ lastModified: now,
+ changeFrequency: "yearly",
+ priority: 0.4,
+ },
{
url: `${SITE_URL}/legal`,
lastModified: now,
diff --git a/components/json-ld.tsx b/components/json-ld.tsx
new file mode 100644
index 00000000..6a9973d6
--- /dev/null
+++ b/components/json-ld.tsx
@@ -0,0 +1,12 @@
+import { serializeJsonLd } from "@/lib/structured-data";
+
+/** Structured data for search engines and agents (schema.org JSON-LD). */
+export function JsonLd({ data }: { data: unknown }) {
+ return (
+ <script
+ type="application/ld+json"
+ // biome-ignore lint/security/noDangerouslySetInnerHtml: escaped JSON, the pattern from Next's JSON-LD guide
+ dangerouslySetInnerHTML={{ __html: serializeJsonLd(data) }}
+ />
+ );
+}
diff --git a/config/site-pages.ts b/config/site-pages.ts
index a50fb4ed..163ce666 100644
--- a/config/site-pages.ts
+++ b/config/site-pages.ts
@@ -29,6 +29,16 @@ export const SITE_PAGES = {
description:
"Turn your repo's stars into a shareable animated video. Paste a GitHub repo and we animate every stargazer into a clip you can own.",
},
+ about: {
+ title: "About",
+ description:
+ "Remocn is an open-source registry of Remotion video components that your AI agent uses to build product demo videos. Who it is for, how it works and how it is funded.",
+ },
+ contact: {
+ title: "Contact",
+ description:
+ "How to reach Remocn: email for questions, sponsorship and purchases, GitHub issues for bugs and component requests, and X or Threads for news.",
+ },
"inspired-by": {
title: "Inspired by",
description:
diff --git a/config/site.ts b/config/site.ts
index 75258a56..d883eb94 100644
--- a/config/site.ts
+++ b/config/site.ts
@@ -20,6 +20,10 @@ export const STUDIO_URL = "https://remocn.studio";
export const SUPPORT_EMAIL = "[email protected]";
+/** The site's meta description; the home page's JSON-LD reuses it. */
+export const SITE_DESCRIPTION =
+ "Describe your product, get a demo video. Ready-made animations, transitions and app-screen sims your coding agent can use. No video editor, no motion designer.";
+
export const INSTALL_ALL_NAMES: string[] = [
...remocnRegistry.items,
...remocnUiRegistry.items,
diff --git a/config/trust-pages.test.ts b/config/trust-pages.test.ts
new file mode 100644
index 00000000..ba0872f3
--- /dev/null
+++ b/config/trust-pages.test.ts
@@ -0,0 +1,34 @@
+import { describe, expect, test } from "bun:test";
+import { existsSync } from "node:fs";
+import { join } from "node:path";
+import { ABOUT, CONTACT, trustPageText } from "./trust-pages";
+
+// Agents check trust pages for real content, not a stub.
+const MIN_CHARS = 500;
+
+describe("trust pages", () => {
+ test("/about has real content", () => {
+ expect(trustPageText(ABOUT).length).toBeGreaterThanOrEqual(MIN_CHARS);
+ });
+
+ test("/contact has real content and an email channel", () => {
+ expect(trustPageText(CONTACT).length).toBeGreaterThanOrEqual(MIN_CHARS);
+ expect(CONTACT.channels[0].href).toBe("mailto:[email protected]");
+ });
+
+ test("each page has a route", () => {
+ for (const page of ["about", "contact"]) {
+ expect(
+ existsSync(
+ join(import.meta.dir, "..", "app", "(home)", page, "page.tsx"),
+ ),
+ ).toBe(true);
+ }
+ });
+
+ test("internal links point at real pages", () => {
+ for (const link of ABOUT.links.filter((l) => !l.external)) {
+ expect(link.href).toStartWith("/");
+ }
+ });
+});
diff --git a/config/trust-pages.ts b/config/trust-pages.ts
new file mode 100644
index 00000000..d01c99d4
--- /dev/null
+++ b/config/trust-pages.ts
@@ -0,0 +1,127 @@
+import { GITHUB_URL, SUPPORT_EMAIL, THREADS_URL, X_URL } from "@/config/site";
+
+/**
+ * Copy for /about and /contact. Plain strings so the pages and the tests read
+ * the same text; a `code` span is wrapped in backticks.
+ */
+
+export type TrustSection = { id: string; title: string; body: string[] };
+
+export type TrustLink = { label: string; href: string; external?: boolean };
+
+export type ContactChannel = {
+ title: string;
+ value: string;
+ href: string;
+ body: string;
+};
+
+export const ABOUT = {
+ lead: "Remocn is an open-source registry of video components for Remotion. Describe your product to your AI agent, and it builds the demo video from Remocn's ready-made pieces.",
+ sections: [
+ {
+ id: "what-it-is",
+ title: "What Remocn is",
+ body: [
+ "Remocn is a shadcn registry for Remotion. It ships production-ready text animations, transitions, backgrounds, shaders, filters, captions, app-screen simulations, icons and full scene templates.",
+ "You add a component with `npx shadcn@latest add @remocn/<name>`, and its source file is copied into your project. You own the code and can change anything. Every component is written from scratch on the Remotion API (`useCurrentFrame()`, `interpolate()`, `spring()`) and renders the same frame every time.",
+ ],
+ },
+ {
+ id: "who-its-for",
+ title: "Who it is for",
+ body: [
+ "Solo builders and small teams who shipped a product and need a demo video for the launch, the changelog or the landing page. Usually that is a frontend developer who already knows shadcn.",
+ "No video editor and no motion designer: your coding agent (Claude Code, Codex, GitHub Copilot and others) writes the video in React, and you review it in the live preview.",
+ ],
+ },
+ {
+ id: "built-for-agents",
+ title: "Built for people and agents",
+ body: [
+ "Every component page lists its props, its natural length and when to use it, and agents can read any page as Markdown. Agents can also call the remote MCP server at `remocn.dev/mcp`, or work through the Remocn plugin for Claude Code and Codex.",
+ "Remocn Studio is a free, open-source macOS app where your agent builds the video from Remocn components while you watch the preview and export the result.",
+ ],
+ },
+ {
+ id: "open-source",
+ title: "Open source and funding",
+ body: [
+ "The components are MIT-licensed and free in personal and commercial projects. Remocn is developed in the open on GitHub and maintained by @kapishdima.",
+ "The project is funded by its sponsors and by a few paid products, sold through Creem as merchant of record. Bug reports, component ideas and pull requests are welcome.",
+ ],
+ },
+ ] satisfies TrustSection[],
+ links: [
+ { label: "Read the docs", href: "/docs/getting-started/introduction" },
+ { label: "GitHub", href: GITHUB_URL, external: true },
+ { label: "Sponsors", href: "/sponsors" },
+ { label: "Contact", href: "/contact" },
+ ] satisfies TrustLink[],
+};
+
+export const CONTACT = {
+ lead: "Remocn is a small, independent project, and every channel below is read by the maintainer. Pick the one that fits what you need.",
+ channels: [
+ {
+ title: "Email",
+ value: SUPPORT_EMAIL,
+ href: `mailto:${SUPPORT_EMAIL}`,
+ body: "Questions, partnerships and sponsorship, purchases and refunds, privacy requests, and anything you would rather not post in public.",
+ },
+ {
+ title: "GitHub issues",
+ value: "Remocn/remocn",
+ href: `${GITHUB_URL}/issues`,
+ body: "Bug reports and component requests. Name the component, your Remotion version and the smallest composition that shows the problem, so the fix lands faster.",
+ },
+ {
+ title: "X",
+ value: "@_remocn",
+ href: X_URL,
+ body: "Release news, demos of new components and quick questions.",
+ },
+ {
+ title: "Threads",
+ value: "@_remocn",
+ href: THREADS_URL,
+ body: "The same updates as on X, for people who live on Threads.",
+ },
+ ] satisfies ContactChannel[],
+ sections: [
+ {
+ id: "security",
+ title: "Security issues",
+ body: [
+ "Found a security problem on remocn.dev, in the MCP server or in a registry file? Email it instead of opening a public issue, so it can be fixed before anyone else reads about it.",
+ ],
+ },
+ {
+ id: "purchases",
+ title: "Purchases and refunds",
+ body: [
+ "If a paid product is broken or not as described, email within 14 days of purchase and we will fix it or refund you. The full terms are on the Privacy & Terms page.",
+ ],
+ },
+ {
+ id: "sponsorship",
+ title: "Sponsorship",
+ body: [
+ "To back the project or put your logo on the landing page, the Sponsors page lists the tiers. For anything custom, email.",
+ ],
+ },
+ ] satisfies TrustSection[],
+};
+
+/** Visible text of a page, for the length check in tests. */
+export function trustPageText(page: {
+ lead: string;
+ sections: TrustSection[];
+ channels?: ContactChannel[];
+}): string {
+ return [
+ page.lead,
+ ...page.sections.flatMap((s) => [s.title, ...s.body]),
+ ...(page.channels ?? []).flatMap((c) => [c.title, c.value, c.body]),
+ ].join("\n");
+}
diff --git a/lib/accept.test.ts b/lib/accept.test.ts
new file mode 100644
index 00000000..4817104d
--- /dev/null
+++ b/lib/accept.test.ts
@@ -0,0 +1,68 @@
+import { describe, expect, test } from "bun:test";
+import { negotiate, notAcceptableBody, parseAccept } from "./accept";
+
+// The test vectors from acceptmarkdown.com/guides/accept-parsing, plus the
+// headers real clients send.
+const VECTORS: [string | null, ReturnType<typeof negotiate>][] = [
+ ["text/markdown", "markdown"],
+ ["text/markdown, text/html;q=0.8", "markdown"],
+ ["text/html", "html"],
+ ["text/markdown;q=0, text/html", "html"],
+ ["text/markdown;q=0", "none"],
+ [null, "html"],
+ ["", "html"],
+ ["*/*", "html"],
+ // q-values decide, not order.
+ ["text/html;q=0.5, text/markdown;q=0.9", "markdown"],
+ ["text/markdown;q=0.5, text/html", "html"],
+ ["text/markdown;q=0.5", "markdown"],
+ // Nothing we can produce.
+ ["application/pdf", "none"],
+ ["image/png, image/*;q=0.8", "none"],
+ ["text/html;q=0, text/markdown;q=0", "none"],
+ // A wildcard ranks below an exact entry: q=0 on Markdown still excludes it.
+ ["text/markdown;q=0, */*", "html"],
+ ["text/*", "html"],
+ // Real clients.
+ ["text/markdown, text/html, */*", "markdown"], // Claude Code WebFetch
+ [
+ "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
+ "html",
+ ], // browsers
+ ["text/x-component", "html"], // Next's client router
+ // Case, whitespace and params don't matter.
+ ["TEXT/Markdown ; charset=utf-8 ; Q=0.9 , text/html;q=0.1", "markdown"],
+];
+
+describe("negotiate", () => {
+ for (const [accept, expected] of VECTORS) {
+ test(`${JSON.stringify(accept)} -> ${expected}`, () => {
+ expect(negotiate(accept)).toBe(expected);
+ });
+ }
+
+ test("a fetcher gets Markdown whenever it is acceptable", () => {
+ expect(negotiate("*/*", { preferMarkdown: true })).toBe("markdown");
+ expect(negotiate(null, { preferMarkdown: true })).toBe("markdown");
+ expect(
+ negotiate("text/html, text/markdown;q=0.1", { preferMarkdown: true }),
+ ).toBe("markdown");
+ expect(
+ negotiate("text/markdown;q=0, text/html", { preferMarkdown: true }),
+ ).toBe("html");
+ });
+});
+
+describe("parseAccept", () => {
+ test("drops malformed ranges and out-of-range q-values", () => {
+ expect(
+ parseAccept("text, /x, text/html;q=2, text/plain;q=abc, a/b;q=0.3"),
+ ).toEqual([{ type: "a", subtype: "b", q: 0.3 }]);
+ });
+});
+
+test("the 406 body lists what is available", () => {
+ const body = notAcceptableBody("application/pdf");
+ expect(body).toContain("application/pdf");
+ expect(body).toContain("text/html, text/markdown");
+});
diff --git a/lib/accept.ts b/lib/accept.ts
new file mode 100644
index 00000000..8562486a
--- /dev/null
+++ b/lib/accept.ts
@@ -0,0 +1,98 @@
+/**
+ * Accept-header negotiation between the two representations of a page: HTML
+ * (the default) and Markdown. Follows RFC 9110 §12.5.1 and the test vectors at
+ * acceptmarkdown.com/guides/accept-parsing: each type scores the q-value of
+ * its most specific matching entry (exact > type/* > *\/*), `q=0` rules a type
+ * out, and nothing acceptable means 406.
+ */
+
+export type Variant = "markdown" | "html" | "none";
+
+type Entry = { type: string; subtype: string; q: number };
+
+type Match = { q: number; specificity: number };
+
+const NO_MATCH: Match = { q: 0, specificity: -1 };
+
+export function parseAccept(header: string): Entry[] {
+ const entries: Entry[] = [];
+ for (const part of header.split(",")) {
+ const [range, ...params] = part.split(";").map((s) => s.trim());
+ const [type, subtype] = range.toLowerCase().split("/");
+ if (!type || !subtype) continue;
+ let q = 1;
+ for (const param of params) {
+ const [key, value] = param.split("=").map((s) => s.trim());
+ if (key?.toLowerCase() !== "q") continue;
+ q = Number(value);
+ }
+ if (!Number.isFinite(q) || q < 0 || q > 1) continue;
+ entries.push({ type, subtype, q });
+ }
+ return entries;
+}
+
+/** The q-value the most specific matching entry gives `mime`. */
+export function matchType(entries: Entry[], mime: string): Match {
+ const [type, subtype] = mime.split("/");
+ let best = NO_MATCH;
+ for (const entry of entries) {
+ let specificity = -1;
+ if (entry.type === type && entry.subtype === subtype) specificity = 2;
+ else if (entry.type === type && entry.subtype === "*") specificity = 1;
+ else if (entry.type === "*" && entry.subtype === "*") specificity = 0;
+ if (specificity > best.specificity) best = { q: entry.q, specificity };
+ }
+ return best;
+}
+
+// What the HTML route can answer with: the page itself, or the RSC payload
+// Next's client router asks for with `Accept: text/x-component`.
+const HTML_TYPES = ["text/html", "application/xhtml+xml", "text/x-component"];
+
+/**
+ * Pick the representation for a request.
+ *
+ * - No Accept header, or `*\/*`: HTML, the default.
+ * - Markdown wins when the client names `text/markdown` with a q-value at
+ * least as high as HTML's (so `text/markdown, text/html, *\/*`, which Claude
+ * Code sends, gets Markdown).
+ * - `preferMarkdown` (a fetcher reading the page for a user) takes Markdown
+ * whenever the client accepts it at all.
+ * - Neither type acceptable: `none`, which the caller answers with 406.
+ */
+export function negotiate(
+ header: string | null,
+ { preferMarkdown = false }: { preferMarkdown?: boolean } = {},
+): Variant {
+ if (!header?.trim()) return preferMarkdown ? "markdown" : "html";
+
+ const entries = parseAccept(header);
+ if (entries.length === 0) return preferMarkdown ? "markdown" : "html";
+
+ const markdown = matchType(entries, "text/markdown");
+ const html = HTML_TYPES.map((t) => matchType(entries, t)).reduce((a, b) =>
+ b.q > a.q ? b : a,
+ );
+
+ if (markdown.q > 0 && preferMarkdown) return "markdown";
+ if (markdown.q > 0 && markdown.specificity === 2 && markdown.q >= html.q) {
+ return "markdown";
+ }
+ if (html.q > 0) return "html";
+ if (markdown.q > 0) return "markdown";
+ return "none";
+}
+
+/** Body of the 406: what the URL can be served as. */
+export function notAcceptableBody(accept: string): string {
+ return [
+ "406 Not Acceptable",
+ "",
+ `Requested: ${accept.slice(0, 200)}`,
+ "Available: text/html, text/markdown",
+ "",
+ "Retry with Accept: text/html or Accept: text/markdown.",
+ "",
+ ].join("\n");
+}
diff --git a/lib/agent-docs.test.ts b/lib/agent-docs.test.ts
new file mode 100644
index 00000000..d4e3e69f
--- /dev/null
+++ b/lib/agent-docs.test.ts
@@ -0,0 +1,102 @@
+import { describe, expect, test } from "bun:test";
+import {
+ buildLlmsTxt,
+ buildNotFoundMarkdown,
+ markdownNotFound,
+ safeRequestedPath,
+} from "./agent-docs";
+
+const PAGES = [
+ {
+ slugs: ["getting-started", "introduction"],
+ url: "/docs/getting-started/introduction",
+ title: "Introduction",
+ description: "What Remocn is",
+ },
+ {
+ slugs: ["transitions", "zoom-blur"],
+ url: "/docs/transitions/zoom-blur",
+ title: "Zoom Blur",
+ },
+];
+
+describe("buildLlmsTxt", () => {
+ const text = buildLlmsTxt(PAGES);
+ const lines = text.split("\n");
+
+ test("follows the llms.txt layout: H1, then a blockquote summary", () => {
+ expect(lines[0]).toBe("# Remocn");
+ expect(lines.find((l) => l.startsWith(">"))).toContain("Remotion");
+ });
+
+ test("has no heading between the summary and the first H2 section", () => {
+ const firstH2 = lines.findIndex((l) => l.startsWith("## "));
+ const preamble = lines.slice(1, firstH2);
+ expect(preamble.some((l) => l.startsWith("#"))).toBe(false);
+ });
+
+ test("tells agents when to use Remocn and when not to", () => {
+ expect(text).toContain("**When to use Remocn:**");
+ expect(text).toContain("**When not to use Remocn:**");
+ expect(text).toContain("**How an agent should use Remocn:**");
+ expect(text).toContain("npx shadcn@latest add @remocn/<name>");
+ });
+
+ test("links the machine endpoints", () => {
+ expect(text).toContain("(https://remocn.dev/mcp)");
+ expect(text).toContain("(https://remocn.dev/openapi.json)");
+ expect(text).toContain("(https://remocn.dev/llms-components.txt)");
+ });
+
+ test("lists every page as a Markdown link under its section", () => {
+ expect(text).toContain(
+ "## Getting Started\n- [Introduction](https://remocn.dev/docs/getting-started/introduction.md): What Remocn is",
+ );
+ expect(text).toContain(
+ "## Transitions\n- [Zoom Blur](https://remocn.dev/docs/transitions/zoom-blur.md)",
+ );
+ });
+
+ test("every H2 section is a list of links", () => {
+ const sections = text.split("\n## ").slice(1);
+ for (const section of sections) {
+ const items = section.split("\n").slice(1).filter(Boolean);
+ expect(items.length).toBeGreaterThan(0);
+ for (const item of items)
+ expect(item).toMatch(/^- \[[^\]]+\]\(https:\/\//);
+ }
+ });
+
+ test("ends with the Optional section", () => {
+ expect(text).toMatch(/\n## Optional\n(- .+\n?)+$/);
+ });
+});
+
+describe("Markdown 404", () => {
+ test("explains the error and links the indexes", () => {
+ const body = buildNotFoundMarkdown("/nope");
+ expect(body.length).toBeGreaterThan(20);
+ expect(body).toStartWith("# 404");
+ expect(body).toContain("`/nope`");
+ expect(body).toContain("(https://remocn.dev/llms.txt)");
+ expect(body).toContain("(https://remocn.dev/sitemap.xml)");
+ });
+
+ test("responds 404 with text/markdown", async () => {
+ const res = markdownNotFound("/nope");
+ expect(res.status).toBe(404);
+ expect(res.headers.get("content-type")).toBe(
+ "text/markdown; charset=utf-8",
+ );
+ expect(await res.text()).toContain("# 404");
+ });
+
+ test("echoes only same-origin paths, without Markdown breakers", () => {
+ expect(safeRequestedPath("/a/b")).toBe("/a/b");
+ expect(safeRequestedPath("/a`b\nc")).toBe("/abc");
+ expect(safeRequestedPath("//evil.example")).toBeUndefined();
+ expect(safeRequestedPath("https://evil.example")).toBeUndefined();
+ expect(safeRequestedPath(null)).toBeUndefined();
+ expect(safeRequestedPath(`/${"a".repeat(500)}`)?.length).toBe(200);
+ });
+});
diff --git a/lib/agent-docs.ts b/lib/agent-docs.ts
new file mode 100644
index 00000000..2545556e
--- /dev/null
+++ b/lib/agent-docs.ts
@@ -0,0 +1,157 @@
+import { SITE_URL } from "@/lib/get-llm-text";
+
+/**
+ * The Markdown agents read instead of the site's HTML: the llms.txt index
+ * (also the home page and `/docs` as Markdown) and the 404 body. Pure, so the
+ * routes stay thin and the text is testable without the docs source.
+ */
+
+export type IndexPage = {
+ slugs: string[];
+ url: string;
+ title: string;
+ description?: string;
+};
+
+export const INSTALL_COMMAND = "npx shadcn@latest add @remocn/<name>";
+
+export const MCP_URL = `${SITE_URL}/mcp`;
+
+export const OPENAPI_URL = `${SITE_URL}/openapi.json`;
+
+/**
+ * When-to-use guidance. llms.txt allows free paragraphs and lists, but no
+ * headings, between the summary and the first H2 section, so this is bold
+ * labels over lists rather than its own section.
+ */
+const WHEN_TO_USE = [
+ "**When to use Remocn:**",
+ "",
+ "- The user wants a product demo, launch, feature announcement, changelog or social video, and a React/Remotion project is an acceptable way to make it.",
+ "- You are writing a Remotion composition and need ready-made pieces instead of hand-rolled ones: text animations, scene transitions, backgrounds, shaders, filters, captions, app-screen and UI simulations, icons, or full scene templates.",
+ "- The user wants to own and edit the source. Components are copied into their project (shadcn style, MIT), not installed as a runtime dependency.",
+ `- The user wants an animated video of a GitHub repo's stargazers: [${SITE_URL}/stars](${SITE_URL}/stars).`,
+ "",
+ "**When not to use Remocn:**",
+ "",
+ "- Editing, trimming or color-grading existing footage. Remocn generates motion graphics in code; it is not a video editor.",
+ "- The project cannot run React and Node.js, or the user wants a hosted text-to-video API. Remocn renders inside the user's own Remotion project.",
+ "",
+ "**How an agent should use Remocn:**",
+ "",
+ `1. Pick components from [/llms-components.txt](${SITE_URL}/llms-components.txt), or call the MCP server at ${MCP_URL} (Streamable HTTP, no auth; tools \`search_components\`, \`get_component\`, \`plan_video\`, \`preview_component\`).`,
+ "2. Read the component's page as Markdown (append `.md` to its docs URL) before writing code against it: props, natural length and a usage example live there.",
+ `3. Install with the shadcn CLI: \`${INSTALL_COMMAND}\`. The source lands in the user's project. Raw registry items are JSON at \`${SITE_URL}/r/<name>.json\`.`,
+ "4. For a whole video workflow, install the agent skill (`npx skills add Remocn/remocn --yes`) or the Claude Code plugin (`/plugin install remocn --marketplace Remocn/remocn`).",
+];
+
+/** Link lists, in llms.txt section format, for the machine endpoints. */
+const AGENT_TOOLS = [
+ "## Agent tools",
+ `- [Component index](${SITE_URL}/llms-components.txt): every installable component with its use / avoid signal, natural length, vibe and dependencies`,
+ `- [MCP server](${MCP_URL}): remote, read-only, no auth. Search components, read one, plan a video, preview a component`,
+ `- [OpenAPI spec](${OPENAPI_URL}): the HTTP API (registry items, docs search, GitHub stars video renders)`,
+ `- [Full docs corpus](${SITE_URL}/llms-full.txt): every docs page as Markdown in one file`,
+];
+
+const ABOUT_LINKS = [
+ "## Optional",
+ `- [About](${SITE_URL}/about): who builds Remocn and how the project is funded`,
+ `- [Contact](${SITE_URL}/contact): email, GitHub issues and social profiles`,
+ `- [Changelog](${SITE_URL}/changelog): every release, newest first`,
+ `- [Privacy & Terms](${SITE_URL}/legal): how the site handles data`,
+];
+
+function sectionHeading(key: string): string {
+ return key
+ ? key.replace(
+ /(^|-)([a-z])/g,
+ (_, sep, c) => (sep ? " " : "") + c.toUpperCase(),
+ )
+ : "Overview";
+}
+
+/** llms.txt (https://llmstxt.org): H1, summary, guidance, then link lists. */
+export function buildLlmsTxt(pages: IndexPage[]): string {
+ const lines: string[] = [];
+
+ lines.push("# Remocn");
+ lines.push(
+ `\n> shadcn registry of production-ready Remotion components — animations, transitions, backgrounds, and full scenes for product demo videos. Install with \`${INSTALL_COMMAND}\`.`,
+ );
+ lines.push(
+ "\nDocs are also available as raw Markdown: append `.md` to any docs URL, or read [/llms-full.txt](" +
+ `${SITE_URL}/llms-full.txt) for the full corpus in a single file.`,
+ );
+ lines.push(
+ `\nBuilding a video? Start at [/llms-components.txt](${SITE_URL}/llms-components.txt) — every` +
+ " installable component in one table with its use / avoid signal, natural length, vibe and" +
+ " dependencies, linking to each component's full page.",
+ );
+ lines.push(
+ "\nPrefer an app to a terminal? [Remocn Studio](https://remocn.studio) is a free, open-source" +
+ " macOS app where the user's own coding agent (Claude Code, Codex, GitHub Copilot or Grok)" +
+ " builds Remotion videos from Remocn components, with a live preview and export. Its own" +
+ " index is at [remocn.studio/llms.txt](https://remocn.studio/llms.txt).",
+ );
+ lines.push(`\n${WHEN_TO_USE.join("\n")}`);
+ lines.push(`\n${AGENT_TOOLS.join("\n")}`);
+
+ // Group pages by their top-level section (first slug segment).
+ const sections = new Map<string, IndexPage[]>();
+ for (const page of pages) {
+ const key = page.slugs[0] ?? "";
+ const bucket = sections.get(key) ?? [];
+ bucket.push(page);
+ sections.set(key, bucket);
+ }
+
+ for (const [key, bucket] of sections) {
+ lines.push(`\n## ${sectionHeading(key)}`);
+ for (const page of bucket) {
+ const desc = page.description ? `: ${page.description}` : "";
+ lines.push(`- [${page.title}](${SITE_URL}${page.url}.md)${desc}`);
+ }
+ }
+
+ lines.push(`\n${ABOUT_LINKS.join("\n")}`);
+
+ return lines.join("\n");
+}
+
+/** Body for a 404 an agent asked to get as Markdown. */
+export function buildNotFoundMarkdown(path?: string): string {
+ const where = path ? ` at \`${path}\`` : "";
+ return [
+ "# 404: page not found",
+ "",
+ `There is no page${where} on remocn.dev. The link is broken, or the page moved.`,
+ "",
+ "Find what you were looking for here:",
+ "",
+ `- [llms.txt](${SITE_URL}/llms.txt): index of every docs page as Markdown`,
+ `- [llms-components.txt](${SITE_URL}/llms-components.txt): every installable component`,
+ `- [Sitemap](${SITE_URL}/sitemap.xml): every public URL`,
+ `- [Docs](${SITE_URL}/docs/getting-started/introduction.md): start here`,
+ "",
+ ].join("\n");
+}
+
+export const MARKDOWN_CONTENT_TYPE = "text/markdown; charset=utf-8";
+
+/** A Markdown 404 response, for routes that answer agents. */
+export function markdownNotFound(path?: string): Response {
+ return new Response(buildNotFoundMarkdown(path), {
+ status: 404,
+ headers: {
+ "Content-Type": MARKDOWN_CONTENT_TYPE,
+ "X-Robots-Tag": "noindex",
+ },
+ });
+}
+
+/** Only an absolute, same-origin path is echoed back into the body. */
+export function safeRequestedPath(value: string | null): string | undefined {
+ if (!value || !value.startsWith("/") || value.startsWith("//")) return;
+ return value.slice(0, 200).replace(/[`\r\n]/g, "");
+}
diff --git a/lib/agent-routing.test.ts b/lib/agent-routing.test.ts
new file mode 100644
index 00000000..ee4bf18a
--- /dev/null
+++ b/lib/agent-routing.test.ts
@@ -0,0 +1,76 @@
+import { describe, expect, test } from "bun:test";
+import {
+ agentBeforeFilesRewrites,
+ agentFallbackRewrites,
+ agentHeaders,
+ FETCHER_USER_AGENT,
+ HOME_MARKDOWN,
+ markdownPathFor,
+ NOT_FOUND_MARKDOWN,
+ VARIANT_HEADER,
+} from "./agent-routing";
+
+describe("fetcher user agents", () => {
+ test("user-triggered fetchers match, search crawlers do not", () => {
+ expect(FETCHER_USER_AGENT.test("Mozilla/5.0 Claude-User/1.0")).toBe(true);
+ expect(FETCHER_USER_AGENT.test("Googlebot/2.1")).toBe(false);
+ });
+});
+
+describe("markdownPathFor", () => {
+ test("the home page and /docs map to the llms.txt index", () => {
+ expect(markdownPathFor("/")).toBe(HOME_MARKDOWN);
+ expect(markdownPathFor("/docs")).toBe(HOME_MARKDOWN);
+ expect(markdownPathFor("/docs/")).toBe(HOME_MARKDOWN);
+ });
+
+ test("a docs page maps to its Markdown route", () => {
+ expect(markdownPathFor("/docs/transitions/zoom-blur")).toBe(
+ "/llms.md/transitions/zoom-blur",
+ );
+ });
+
+ test("other pages and explicit .md URLs have no negotiated Markdown", () => {
+ expect(markdownPathFor("/blog")).toBeNull();
+ expect(markdownPathFor("/docsx")).toBeNull();
+ expect(markdownPathFor("/docs/transitions/zoom-blur.md")).toBeNull();
+ });
+});
+
+describe("rewrites", () => {
+ test("explicit .md URLs are rewritten to the Markdown routes", () => {
+ expect(agentBeforeFilesRewrites()).toEqual([
+ { source: "/docs.md", destination: HOME_MARKDOWN },
+ { source: "/docs/:path*.md", destination: "/llms.md/:path*" },
+ ]);
+ });
+
+ test("a missed URL falls back to the Markdown 404 only when proxy.ts negotiated Markdown", () => {
+ expect(agentFallbackRewrites()).toEqual([
+ {
+ source: "/:path*",
+ has: [{ type: "header", key: VARIANT_HEADER, value: "markdown" }],
+ destination: `${NOT_FOUND_MARKDOWN}/:path*`,
+ },
+ ]);
+ });
+});
+
+describe("headers", () => {
+ test("negotiated URLs vary on Accept", () => {
+ const home = agentHeaders().find(
+ (h) => h.source === "/" && h.headers.some((x) => x.key === "Vary"),
+ );
+ expect(home?.headers).toContainEqual({
+ key: "Vary",
+ value: "Accept, User-Agent",
+ });
+ });
+
+ test("the home page links the OpenAPI document (RFC 8631)", () => {
+ const link = agentHeaders()
+ .flatMap((h) => (h.source === "/" ? h.headers : []))
+ .find((x) => x.key === "Link");
+ expect(link?.value).toContain('</openapi.json>; rel="service-desc"');
+ });
+});
diff --git a/lib/agent-routing.ts b/lib/agent-routing.ts
new file mode 100644
index 00000000..c399e30e
--- /dev/null
+++ b/lib/agent-routing.ts
@@ -0,0 +1,99 @@
+/**
+ * How the site answers agents at the same URLs people use. Imported by
+ * next.config.ts, so it uses relative imports only (no `@/` alias there).
+ */
+
+type HeaderSignal = { type: "header"; key: string; value: string };
+
+type Rewrite = {
+ source: string;
+ destination: string;
+ has?: HeaderSignal[];
+};
+
+/**
+ * Fetchers that read a page for a user. They get Markdown whenever their
+ * Accept allows it. Crawlers that build a search index (Googlebot,
+ * OAI-SearchBot, Claude-SearchBot) and agentic browsers (Atlas, Claude-Agent,
+ * Google-Agent) still get HTML: the first would see cloaking, the second needs
+ * the real UI to click through.
+ */
+export const FETCHER_USER_AGENT =
+ /Claude-User|ChatGPT-User|Perplexity-User|MistralAI-User/;
+
+/**
+ * Set by proxy.ts on the request when it negotiated Markdown, so the fallback
+ * rewrite below can answer a 404 in the same representation.
+ */
+export const VARIANT_HEADER = "x-remocn-variant";
+
+/** The home page and `/docs` as Markdown (app/index.md). */
+export const HOME_MARKDOWN = "/index.md";
+
+/** The Markdown 404 body (app/missing.md). */
+export const NOT_FOUND_MARKDOWN = "/missing.md";
+
+/** The page people land on at the bare `/docs`, which has no page. */
+export const DOCS_HOME = "/docs/getting-started/introduction";
+
+/** URLs whose response depends on Accept and User-Agent. */
+export const NEGOTIATED_SOURCES = ["/", "/docs", "/docs/:path*"];
+
+/**
+ * The Markdown route behind a page URL that has both representations, or null
+ * when the URL has only HTML. Explicit `.md` URLs are rewritten in
+ * next.config.ts instead.
+ */
+export function markdownPathFor(pathname: string): string | null {
+ const path = pathname.length > 1 ? pathname.replace(/\/+$/, "") : pathname;
+ if (path === "/" || path === "/docs") return HOME_MARKDOWN;
+ if (path.startsWith("/docs/") && !path.endsWith(".md")) {
+ return `/llms.md/${path.slice("/docs/".length)}`;
+ }
+ return null;
+}
+
+export function agentBeforeFilesRewrites(): Rewrite[] {
+ // Explicit Markdown URLs. The same URLs with an Accept header are
+ // negotiated in proxy.ts, which can read q-values; a `has` regex can't.
+ return [
+ { source: "/docs.md", destination: HOME_MARKDOWN },
+ { source: "/docs/:path*.md", destination: "/llms.md/:path*" },
+ ];
+}
+
+/**
+ * Fallback rewrites run only after every page, public file and dynamic route
+ * missed, i.e. exactly when Next would render the HTML 404. An agent that
+ * asked for Markdown gets a Markdown 404 there instead, still with status 404.
+ */
+export function agentFallbackRewrites(): Rewrite[] {
+ return [
+ {
+ source: "/:path*",
+ has: [{ type: "header", key: VARIANT_HEADER, value: "markdown" }],
+ destination: `${NOT_FOUND_MARKDOWN}/:path*`,
+ },
+ ];
+}
+
+export function agentHeaders() {
+ // The response at these URLs depends on Accept and User-Agent, so a cache
+ // must not hand the Markdown variant to a browser or the other way round.
+ const negotiated = NEGOTIATED_SOURCES.map((source) => ({
+ source,
+ headers: [{ key: "Vary", value: "Accept, User-Agent" }],
+ }));
+ // RFC 8631: point API clients from the home page at the OpenAPI document.
+ const home = {
+ source: "/",
+ headers: [
+ {
+ key: "Link",
+ value:
+ '</openapi.json>; rel="service-desc"; type="application/openapi+json"',
+ },
+ ],
+ };
+ return [...negotiated, home];
+}
diff --git a/lib/api-error.ts b/lib/api-error.ts
new file mode 100644
index 00000000..f6be53e0
--- /dev/null
+++ b/lib/api-error.ts
@@ -0,0 +1,17 @@
+const OPENAPI_URL = "https://remocn.dev/openapi.json";
+
+/**
+ * The API's error shape: `{ error, code }` like every route under app/api,
+ * plus a `hint` on what to do next and a link to the API description.
+ */
+export function apiError(
+ status: number,
+ code: string,
+ error: string,
+ hint?: string,
+): Response {
+ return Response.json(
+ { error, code, ...(hint ? { hint } : {}), docs: OPENAPI_URL },
+ { status },
+ );
+}
diff --git a/lib/docs-index.ts b/lib/docs-index.ts
new file mode 100644
index 00000000..a1882fb2
--- /dev/null
+++ b/lib/docs-index.ts
@@ -0,0 +1,12 @@
+import type { IndexPage } from "@/lib/agent-docs";
+import { source } from "@/source";
+
+/** Every docs page, in source order, as the llms.txt index lists it. */
+export function docsIndexPages(): IndexPage[] {
+ return source.getPages().map((page) => ({
+ slugs: page.slugs,
+ url: page.url,
+ title: page.data.title,
+ description: page.data.description,
+ }));
+}
diff --git a/lib/openapi.test.ts b/lib/openapi.test.ts
new file mode 100644
index 00000000..0114877b
--- /dev/null
+++ b/lib/openapi.test.ts
@@ -0,0 +1,126 @@
+import { describe, expect, test } from "bun:test";
+import { readFileSync } from "node:fs";
+import { join } from "node:path";
+import { OPENAPI_SPEC } from "./openapi";
+
+const ROOT = join(import.meta.dir, "..");
+
+type Operation = {
+ operationId: string;
+ summary: string;
+ description: string;
+ parameters?: {
+ name: string;
+ in: string;
+ required: boolean;
+ description: string;
+ schema: { type: string };
+ }[];
+ requestBody?: { content: Record<string, { schema: unknown }> };
+ responses: Record<
+ string,
+ { description: string; content?: Record<string, { schema: unknown }> }
+ >;
+};
+
+const spec = JSON.parse(JSON.stringify(OPENAPI_SPEC));
+const operations: [string, string, Operation][] = Object.entries(
+ spec.paths as Record<string, Record<string, Operation>>,
+).flatMap(([path, methods]) =>
+ Object.entries(methods).map(
+ ([method, op]) => [path, method, op] as [string, string, Operation],
+ ),
+);
+
+/** `/api/render/{jobId}` -> `app/api/render/[jobId]/route.ts` */
+function routeFile(path: string): string {
+ return join(
+ ROOT,
+ "app",
+ ...path
+ .split("/")
+ .filter(Boolean)
+ .map((segment) => segment.replace(/^\{(.+)\}$/, "[$1]")),
+ "route.ts",
+ );
+}
+
+describe("OpenAPI spec", () => {
+ test("is OpenAPI 3.1 with info and a server", () => {
+ expect(spec.openapi).toBe("3.1.0");
+ expect(spec.info.title).toBeTruthy();
+ expect(spec.info.version).toBeTruthy();
+ expect(spec.servers[0].url).toBe("https://remocn.dev");
+ });
+
+ test("every path is a real route that exports the method", () => {
+ for (const [path, method] of operations) {
+ const source = readFileSync(routeFile(path), "utf8");
+ const exported = new RegExp(
+ `export (async function|function|const) ${method.toUpperCase()}\\b|export const \\{[^}]*\\b${method.toUpperCase()}\\b`,
+ );
+ expect(source).toMatch(exported);
+ }
+ });
+
+ test("operation ids are unique and function-call friendly", () => {
+ const ids = operations.map(([, , op]) => op.operationId);
+ expect(new Set(ids).size).toBe(ids.length);
+ for (const id of ids) expect(id).toMatch(/^[a-zA-Z][a-zA-Z0-9_]{0,63}$/);
+ });
+
+ test("every operation has a summary, description and typed responses", () => {
+ for (const [, , op] of operations) {
+ expect(op.summary.length).toBeGreaterThan(0);
+ expect(op.description.length).toBeGreaterThan(20);
+ const ok = Object.entries(op.responses).filter(([s]) =>
+ s.startsWith("2"),
+ );
+ expect(ok.length).toBeGreaterThan(0);
+ for (const [, response] of Object.entries(op.responses)) {
+ expect(response.description.length).toBeGreaterThan(0);
+ for (const media of Object.values(response.content ?? {})) {
+ expect(media.schema).toBeDefined();
+ }
+ }
+ }
+ });
+
+ test("every parameter is typed and described", () => {
+ for (const [path, , op] of operations) {
+ for (const param of op.parameters ?? []) {
+ expect(param.schema.type).toBeTruthy();
+ expect(param.description.length).toBeGreaterThan(0);
+ if (param.in === "path") {
+ expect(param.required).toBe(true);
+ expect(path).toContain(`{${param.name}}`);
+ }
+ }
+ }
+ });
+
+ test("error responses use the shared Error schema", () => {
+ for (const [, , op] of operations) {
+ for (const [status, response] of Object.entries(op.responses)) {
+ if (Number(status) < 400) continue;
+ expect(response.content?.["application/json"]?.schema).toEqual({
+ $ref: "#/components/schemas/Error",
+ });
+ }
+ }
+ });
+
+ test("every $ref resolves", () => {
+ const refs = JSON.stringify(spec).match(/"\$ref":"([^"]+)"/g) ?? [];
+ for (const raw of refs) {
+ const ref = raw.slice('"$ref":"'.length, -1);
+ const target = ref
+ .replace(/^#\//, "")
+ .split("/")
+ .reduce((node: Record<string, unknown> | undefined, key) => {
+ return node?.[key] as Record<string, unknown> | undefined;
+ }, spec);
+ expect(target).toBeDefined();
+ }
+ });
+});
diff --git a/lib/openapi.ts b/lib/openapi.ts
new file mode 100644
index 00000000..c21357f9
--- /dev/null
+++ b/lib/openapi.ts
@@ -0,0 +1,480 @@
+/**
+ * OpenAPI 3.1 description of remocn.dev's public HTTP API, served at
+ * `/openapi.json`. Every path here maps to a route under `app/`;
+ * lib/openapi.test.ts fails the build if one drifts from the file tree.
+ *
+ * The MCP server at `/mcp` speaks JSON-RPC (Model Context Protocol), not REST,
+ * so it is described in `info.description` rather than as operations.
+ */
+
+const SITE_URL = "https://remocn.dev";
+
+const ERROR_RESPONSE = (description: string) => ({
+ description,
+ content: {
+ "application/json": { schema: { $ref: "#/components/schemas/Error" } },
+ },
+});
+
+const JOB_ID = {
+ name: "jobId",
+ in: "path",
+ required: true,
+ description: "Render job id returned by `createRender`.",
+ schema: { type: "string", format: "uuid" },
+} as const;
+
+export const OPENAPI_SPEC = {
+ openapi: "3.1.0",
+ info: {
+ title: "Remocn API",
+ version: "1.0.0",
+ summary:
+ "Registry items, docs search and GitHub stars video renders for Remocn, the shadcn registry of Remotion components.",
+ description: [
+ "Public, unauthenticated HTTP API behind remocn.dev.",
+ "",
+ "- **Install components** with the shadcn CLI (`npx shadcn@latest add @remocn/<name>`); it fetches `getRegistryItem` for you.",
+ "- **Find components** with `getComponentIndex` (one Markdown table of every component) or `searchDocs`.",
+ "- **Render a GitHub stars video**: `getStargazers` → `createRender` → poll `getRenderStatus` → `downloadRender`.",
+ "",
+ `Agents can also use the remote MCP server at ${SITE_URL}/mcp (Streamable HTTP, JSON-RPC, no auth) with the tools \`search_components\`, \`get_component\`, \`plan_video\` and \`preview_component\`.`,
+ "",
+ "Every error is JSON: `{ error, code }`, where `code` is a stable machine-readable string and `error` a human-readable message.",
+ ].join("\n"),
+ contact: {
+ name: "Remocn",
+ url: `${SITE_URL}/contact`,
+ email: "[email protected]",
+ },
+ license: { name: "MIT", identifier: "MIT" },
+ },
+ externalDocs: {
+ description: "Docs index for LLMs",
+ url: `${SITE_URL}/llms.txt`,
+ },
+ servers: [{ url: SITE_URL }],
+ tags: [
+ { name: "Registry", description: "shadcn registry items." },
+ { name: "Docs", description: "Documentation for people and agents." },
+ {
+ name: "Stars video",
+ description:
+ "Turn a GitHub repository's stargazers into an MP4 (the /stars page).",
+ },
+ ],
+ paths: {
+ "/r/{file}": {
+ get: {
+ operationId: "getRegistryItem",
+ tags: ["Registry"],
+ summary: "Get a registry item",
+ description:
+ "Returns one shadcn registry item (the component's source files and dependencies) as JSON, the format the shadcn CLI installs from. Use `registry.json` for the whole registry index.",
+ parameters: [
+ {
+ name: "file",
+ in: "path",
+ required: true,
+ description:
+ "Component name plus `.json`, e.g. `soft-blur-in.json`, or `registry.json` for the index.",
+ schema: {
+ type: "string",
+ pattern: "^[a-z0-9][a-z0-9-]*\\.json$",
+ },
+ },
+ ],
+ responses: {
+ "200": {
+ description:
+ "The registry item, as defined by https://ui.shadcn.com/schema/registry-item.json.",
+ content: {
+ "application/json": {
+ schema: { $ref: "#/components/schemas/RegistryItem" },
+ },
+ },
+ },
+ "404": ERROR_RESPONSE("No registry item with that name."),
+ },
+ },
+ },
+ "/api/search": {
+ get: {
+ operationId: "searchDocs",
+ tags: ["Docs"],
+ summary: "Search the docs",
+ description:
+ "Full-text search over every docs page, heading and paragraph. Returns an empty array when `query` is missing.",
+ parameters: [
+ {
+ name: "query",
+ in: "query",
+ required: true,
+ description: "Search text, e.g. `blur transition`.",
+ schema: { type: "string", minLength: 1 },
+ },
+ {
+ name: "limit",
+ in: "query",
+ required: false,
+ description: "Maximum number of results.",
+ schema: { type: "integer", minimum: 1 },
+ },
+ {
+ name: "tag",
+ in: "query",
+ required: false,
+ description: "Comma-separated tags to filter by.",
+ schema: { type: "string" },
+ },
+ ],
+ responses: {
+ "200": {
+ description: "Matches, best first.",
+ content: {
+ "application/json": {
+ schema: {
+ type: "array",
+ items: { $ref: "#/components/schemas/SearchResult" },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ "/llms.txt": {
+ get: {
+ operationId: "getLlmsIndex",
+ tags: ["Docs"],
+ summary: "Get the docs index for LLMs",
+ description:
+ "llms.txt (https://llmstxt.org): when to use Remocn, how to call it, and a link to the Markdown of every docs page.",
+ responses: {
+ "200": {
+ description: "The index, in llms.txt Markdown.",
+ content: { "text/plain": { schema: { type: "string" } } },
+ },
+ },
+ },
+ },
+ "/llms-components.txt": {
+ get: {
+ operationId: "getComponentIndex",
+ tags: ["Docs"],
+ summary: "Get the component index",
+ description:
+ "Every installable component in one Markdown table: when to use and avoid it, natural length, vibe, dependencies and a link to its page.",
+ responses: {
+ "200": {
+ description: "The component index, in Markdown.",
+ content: { "text/plain": { schema: { type: "string" } } },
+ },
+ },
+ },
+ },
+ "/api/stargazers": {
+ get: {
+ operationId: "getStargazers",
+ tags: ["Stars video"],
+ summary: "Get a repository's stargazers",
+ description:
+ "Fetches a GitHub repository's stargazers server-side and returns a downsampled list ready to pass to `createRender`.",
+ parameters: [
+ {
+ name: "repo",
+ in: "query",
+ required: true,
+ description:
+ "`owner/name` or a github.com URL, e.g. `Remocn/remocn`.",
+ schema: { type: "string", minLength: 1 },
+ },
+ ],
+ responses: {
+ "200": {
+ description: "The repository's stargazers.",
+ content: {
+ "application/json": {
+ schema: { $ref: "#/components/schemas/StargazersResult" },
+ },
+ },
+ },
+ "400": ERROR_RESPONSE(
+ "Missing or malformed `repo` (code `invalid_repo`). Pass `owner/name` or a github.com URL.",
+ ),
+ "404": ERROR_RESPONSE(
+ "Repository not found or its stargazers are private (code `not_found`).",
+ ),
+ "429": ERROR_RESPONSE(
+ "GitHub rate limit reached (code `rate_limited`). Retry later.",
+ ),
+ "502": ERROR_RESPONSE(
+ "GitHub request failed (code `fetch_failed`). Retry later.",
+ ),
+ },
+ },
+ },
+ "/api/render": {
+ post: {
+ operationId: "createRender",
+ tags: ["Stars video"],
+ summary: "Start a stars video render",
+ description:
+ "Validates the props and queues a background render. Returns a job id immediately; poll `getRenderStatus`. Rate-limited per IP (5 requests per minute by default).",
+ requestBody: {
+ required: true,
+ content: {
+ "application/json": {
+ schema: { $ref: "#/components/schemas/RenderInput" },
+ },
+ },
+ },
+ responses: {
+ "202": {
+ description: "Render queued.",
+ content: {
+ "application/json": {
+ schema: {
+ type: "object",
+ required: ["jobId"],
+ properties: {
+ jobId: {
+ type: "string",
+ format: "uuid",
+ description: "Pass to `getRenderStatus`.",
+ },
+ },
+ },
+ },
+ },
+ },
+ "400": ERROR_RESPONSE(
+ "Body is not JSON (code `invalid_json`) or breaks a field rule (code `invalid_input`; the message names the field).",
+ ),
+ "429": ERROR_RESPONSE(
+ "Too many renders from this IP (code `rate_limited`). Wait a minute and retry.",
+ ),
+ "503": ERROR_RESPONSE(
+ "Render queue is full (code `queue_full`). Retry shortly.",
+ ),
+ },
+ },
+ },
+ "/api/render/{jobId}": {
+ get: {
+ operationId: "getRenderStatus",
+ tags: ["Stars video"],
+ summary: "Get a render's progress",
+ description:
+ "Poll until `status` is `done` (then follow `downloadUrl`) or `error`.",
+ parameters: [JOB_ID],
+ responses: {
+ "200": {
+ description: "The job's state.",
+ content: {
+ "application/json": {
+ schema: { $ref: "#/components/schemas/RenderStatus" },
+ },
+ },
+ },
+ "404": ERROR_RESPONSE(
+ "Unknown job (code `not_found`). Jobs live in memory and expire.",
+ ),
+ },
+ },
+ },
+ "/api/render/{jobId}/download": {
+ get: {
+ operationId: "downloadRender",
+ tags: ["Stars video"],
+ summary: "Download a finished render",
+ description:
+ "Streams the MP4 once, then deletes it from the server. Download it as soon as `getRenderStatus` reports `done`.",
+ parameters: [JOB_ID],
+ responses: {
+ "200": {
+ description: "The rendered video.",
+ content: {
+ "video/mp4": {
+ schema: { type: "string", contentMediaType: "video/mp4" },
+ },
+ },
+ },
+ "404": ERROR_RESPONSE("Unknown job (code `not_found`)."),
+ "410": ERROR_RESPONSE(
+ "Not finished yet (code `not_ready`) or already downloaded and swept (code `expired`). Start a new render.",
+ ),
+ },
+ },
+ },
+ },
+ components: {
+ schemas: {
+ Error: {
+ type: "object",
+ required: ["error", "code"],
+ properties: {
+ error: {
+ type: "string",
+ description: "Human-readable message.",
+ },
+ code: {
+ type: "string",
+ description:
+ "Stable machine-readable code, e.g. `not_found`, `invalid_input`, `rate_limited`.",
+ },
+ hint: {
+ type: "string",
+ description: "What to do next, when the API knows.",
+ },
+ docs: {
+ type: "string",
+ format: "uri",
+ description: "Where the API is described.",
+ },
+ },
+ },
+ RegistryItem: {
+ type: "object",
+ description:
+ "A shadcn registry item. Full schema: https://ui.shadcn.com/schema/registry-item.json",
+ required: ["name", "type"],
+ properties: {
+ $schema: { type: "string", format: "uri" },
+ name: { type: "string" },
+ type: { type: "string", examples: ["registry:component"] },
+ title: { type: "string" },
+ description: { type: "string" },
+ dependencies: { type: "array", items: { type: "string" } },
+ registryDependencies: { type: "array", items: { type: "string" } },
+ files: {
+ type: "array",
+ items: {
+ type: "object",
+ required: ["path", "type"],
+ properties: {
+ path: { type: "string" },
+ type: { type: "string" },
+ target: { type: "string" },
+ content: { type: "string" },
+ },
+ },
+ },
+ },
+ additionalProperties: true,
+ },
+ SearchResult: {
+ type: "object",
+ required: ["id", "url", "type", "content"],
+ properties: {
+ id: { type: "string" },
+ url: {
+ type: "string",
+ description: "Site-relative URL of the match.",
+ },
+ type: { type: "string", enum: ["page", "heading", "text"] },
+ content: {
+ type: "string",
+ description: "Matched text, with hits wrapped in `<mark>`.",
+ },
+ breadcrumbs: { type: "array", items: { type: "string" } },
+ },
+ },
+ Stargazer: {
+ type: "object",
+ required: ["login", "avatarUrl", "starredAt"],
+ properties: {
+ login: { type: "string" },
+ avatarUrl: {
+ type: "string",
+ format: "uri",
+ description: "Must be on avatars.githubusercontent.com.",
+ },
+ starredAt: {
+ type: "string",
+ description: "ISO 8601 date or timestamp.",
+ },
+ },
+ },
+ StargazersResult: {
+ type: "object",
+ required: ["owner", "repo", "totalStars", "truncated", "stargazers"],
+ properties: {
+ owner: { type: "string" },
+ repo: { type: "string" },
+ totalStars: { type: "integer", minimum: 0 },
+ truncated: {
+ type: "boolean",
+ description:
+ "True when the repo is past GitHub's ~40k-star listing ceiling.",
+ },
+ stargazers: {
+ type: "array",
+ items: { $ref: "#/components/schemas/Stargazer" },
+ },
+ },
+ },
+ RenderInput: {
+ type: "object",
+ required: ["repo", "totalStars", "stargazers", "orientation"],
+ properties: {
+ repo: {
+ type: "string",
+ minLength: 1,
+ maxLength: 200,
+ description: "Shown in the video, e.g. `Remocn/remocn`.",
+ },
+ totalStars: {
+ type: "integer",
+ minimum: 0,
+ maximum: 100000000,
+ },
+ stargazers: {
+ type: "array",
+ maxItems: 60,
+ items: { $ref: "#/components/schemas/Stargazer" },
+ },
+ orientation: {
+ type: "string",
+ enum: ["horizontal", "vertical"],
+ },
+ accentColor: {
+ type: "string",
+ pattern: "^#[0-9a-fA-F]{3,8}$",
+ default: "#ffbb00",
+ },
+ speed: {
+ type: "number",
+ minimum: 1,
+ maximum: 4,
+ default: 1,
+ },
+ theme: {
+ type: "string",
+ enum: ["light", "dark"],
+ default: "light",
+ },
+ },
+ },
+ RenderStatus: {
+ type: "object",
+ required: ["status", "progress"],
+ properties: {
+ status: {
+ type: "string",
+ enum: ["queued", "rendering", "done", "error"],
+ },
+ progress: { type: "number", minimum: 0, maximum: 1 },
+ downloadUrl: {
+ type: "string",
+ description: "Present when `status` is `done`.",
+ },
+ error: {
+ type: "string",
+ description: "Present when `status` is `error`.",
+ },
+ },
+ },
+ },
+ },
+} as const;
diff --git a/lib/proxy.test.ts b/lib/proxy.test.ts
new file mode 100644
index 00000000..7d918183
--- /dev/null
+++ b/lib/proxy.test.ts
@@ -0,0 +1,101 @@
+/**
+ * proxy.ts: Accept negotiation on the home page and docs, the 406, and the
+ * variant tag the Markdown 404 fallback reads. Next's internal response
+ * headers show what the proxy decided: `x-middleware-rewrite` for a rewrite,
+ * `x-middleware-override-headers` + `x-middleware-request-*` for a tag.
+ */
+import { describe, expect, test } from "bun:test";
+import { NextRequest } from "next/server";
+import { proxy } from "../proxy";
+
+function call(
+ path: string,
+ headers: Record<string, string> = {},
+ method = "GET",
+) {
+ return proxy(
+ new NextRequest(`https://remocn.dev${path}`, { headers, method }),
+ );
+}
+
+const rewrittenTo = (res: Response) => {
+ const target = res.headers.get("x-middleware-rewrite");
+ return target ? new URL(target).pathname : null;
+};
+
+describe("negotiated pages", () => {
+ test("Accept: text/markdown rewrites the home page to its Markdown", () => {
+ const res = call("/", { accept: "text/markdown" });
+ expect(rewrittenTo(res)).toBe("/index.md");
+ expect(res.headers.get("vary")).toBe("Accept, User-Agent");
+ });
+
+ test("a docs page rewrites to its Markdown route", () => {
+ const res = call("/docs/transitions/zoom-blur", {
+ accept: "text/markdown",
+ });
+ expect(rewrittenTo(res)).toBe("/llms.md/transitions/zoom-blur");
+ });
+
+ test("HTML stays HTML and still varies on Accept", () => {
+ const res = call("/", { accept: "text/html" });
+ expect(rewrittenTo(res)).toBeNull();
+ expect(res.status).toBe(200);
+ expect(res.headers.get("vary")).toBe("Accept, User-Agent");
+ });
+
+ test("q=0 on Markdown keeps HTML", () => {
+ const res = call("/", { accept: "text/markdown;q=0, text/html" });
+ expect(rewrittenTo(res)).toBeNull();
+ });
+
+ test("an unsupported type gets 406 with the available types", async () => {
+ const res = call("/", { accept: "application/pdf" });
+ expect(res.status).toBe(406);
+ expect(res.headers.get("content-type")).toBe("text/plain; charset=utf-8");
+ expect(res.headers.get("vary")).toBe("Accept, User-Agent");
+ expect(await res.text()).toContain("text/html, text/markdown");
+ });
+
+ test("a fetcher user agent gets Markdown with a wildcard Accept", () => {
+ const res = call("/", { accept: "*/*", "user-agent": "Claude-User/1.0" });
+ expect(rewrittenTo(res)).toBe("/index.md");
+ });
+
+ test("bare /docs: Markdown index for agents, a redirect for people", () => {
+ expect(rewrittenTo(call("/docs", { accept: "text/markdown" }))).toBe(
+ "/index.md",
+ );
+ const res = call("/docs", { accept: "text/html" });
+ expect(res.status).toBe(308);
+ expect(res.headers.get("location")).toBe(
+ "https://remocn.dev/docs/getting-started/introduction",
+ );
+ });
+
+ test("non-GET requests pass through untouched", () => {
+ const res = call("/", { accept: "text/x-component" }, "POST");
+ expect(res.status).toBe(200);
+ expect(rewrittenTo(res)).toBeNull();
+ });
+});
+
+describe("other pages", () => {
+ test("Markdown is tagged on the request for the 404 fallback", () => {
+ const res = call("/nope", { accept: "text/markdown" });
+ expect(res.headers.get("x-middleware-request-x-remocn-variant")).toBe(
+ "markdown",
+ );
+ });
+
+ test("a client can't force the tag", () => {
+ const res = call("/nope", {
+ accept: "text/html",
+ "x-remocn-variant": "markdown",
+ });
+ expect(res.headers.get("x-middleware-request-x-remocn-variant")).toBeNull();
+ expect(res.headers.get("x-middleware-override-headers")).not.toContain(
+ "x-remocn-variant",
+ );
+ });
+});
diff --git a/lib/structured-data.test.ts b/lib/structured-data.test.ts
new file mode 100644
index 00000000..6a4242ba
--- /dev/null
+++ b/lib/structured-data.test.ts
@@ -0,0 +1,61 @@
+import { describe, expect, test } from "bun:test";
+import { HOME_KEYWORDS, homeJsonLd, serializeJsonLd } from "./structured-data";
+
+type Node = Record<string, unknown>;
+
+const graph = homeJsonLd("Describe your product, get a demo video.")[
+ "@graph"
+] as Node[];
+const byType = (type: string) => graph.find((n) => n["@type"] === type);
+
+describe("home JSON-LD", () => {
+ test("uses the schema.org context", () => {
+ expect(homeJsonLd("x")["@context"]).toBe("https://schema.org");
+ });
+
+ test("describes the product as a free SoftwareApplication", () => {
+ const app = byType("SoftwareApplication");
+ expect(app).toMatchObject({
+ name: "Remocn",
+ url: "https://remocn.dev",
+ description: "Describe your product, get a demo video.",
+ applicationCategory: "DeveloperApplication",
+ offers: { "@type": "Offer", price: "0", priceCurrency: "USD" },
+ });
+ expect(app?.keywords).toBe(HOME_KEYWORDS.join(", "));
+ });
+
+ test("names the Organization with a contact point and profiles", () => {
+ const org = byType("Organization");
+ expect(org).toMatchObject({ name: "Remocn", url: "https://remocn.dev" });
+ expect(org?.contactPoint).toContainEqual(
+ expect.objectContaining({
+ "@type": "ContactPoint",
+ contactType: "customer support",
+ email: "[email protected]",
+ }),
+ );
+ expect(org?.sameAs).toContain("https://github.com/Remocn/remocn");
+ });
+
+ test("every @id reference points at a node in the graph", () => {
+ const ids = new Set(graph.map((n) => n["@id"]));
+ const refs = JSON.stringify(graph).match(/\{"@id":"[^"]+"\}/g) ?? [];
+ expect(refs.length).toBeGreaterThan(0);
+ for (const ref of refs) expect(ids.has(JSON.parse(ref)["@id"])).toBe(true);
+ });
+
+ test("leads with a product term from the page title", () => {
+ expect("Remocn - Make a product demo video with your AI agent").toContain(
+ HOME_KEYWORDS[0],
+ );
+ });
+});
+
+describe("serializeJsonLd", () => {
+ test("cannot close the script tag", () => {
+ const out = serializeJsonLd({ x: "</script><script>alert(1)</script>" });
+ expect(out).not.toContain("<");
+ expect(JSON.parse(out).x).toBe("</script><script>alert(1)</script>");
+ });
+});
diff --git a/lib/structured-data.ts b/lib/structured-data.ts
new file mode 100644
index 00000000..62613c7f
--- /dev/null
+++ b/lib/structured-data.ts
@@ -0,0 +1,98 @@
+import {
+ GITHUB_URL,
+ STUDIO_URL,
+ SUPPORT_EMAIL,
+ THREADS_URL,
+ X_URL,
+} from "@/config/site";
+
+const SITE_URL = "https://remocn.dev";
+
+const ORG_ID = `${SITE_URL}/#organization`;
+
+/**
+ * Product terms people search together with the brand. Ora and other agents
+ * read the first ones as "what Remocn is", so the most specific term leads,
+ * and each one also appears in the home page's title, copy or description.
+ */
+export const HOME_KEYWORDS = [
+ "product demo video",
+ "Remotion components",
+ "shadcn registry",
+ "Remotion animations",
+ "video transitions",
+ "AI agent video",
+];
+
+/**
+ * JSON-LD for the home page: who publishes the site (Organization), the site
+ * itself (WebSite) and the product (SoftwareApplication), linked by `@id`.
+ */
+export function homeJsonLd(description: string) {
+ return {
+ "@context": "https://schema.org",
+ "@graph": [
+ {
+ "@type": "Organization",
+ "@id": ORG_ID,
+ name: "Remocn",
+ url: SITE_URL,
+ logo: `${SITE_URL}/logo-wordmark.png`,
+ email: SUPPORT_EMAIL,
+ description:
+ "Remocn builds open-source video components for Remotion and the tools to make product demo videos with an AI agent.",
+ sameAs: [GITHUB_URL, X_URL, THREADS_URL],
+ knowsAbout: ["Remotion", "React", "Motion design", "shadcn/ui"],
+ contactPoint: [
+ {
+ "@type": "ContactPoint",
+ contactType: "customer support",
+ email: SUPPORT_EMAIL,
+ url: `${SITE_URL}/contact`,
+ availableLanguage: ["English"],
+ },
+ ],
+ },
+ {
+ "@type": "WebSite",
+ "@id": `${SITE_URL}/#website`,
+ name: "Remocn",
+ url: SITE_URL,
+ inLanguage: "en",
+ publisher: { "@id": ORG_ID },
+ },
+ {
+ "@type": "SoftwareApplication",
+ "@id": `${SITE_URL}/#software`,
+ name: "Remocn",
+ url: SITE_URL,
+ description,
+ image: `${SITE_URL}/hero.png`,
+ applicationCategory: "DeveloperApplication",
+ applicationSubCategory: "Remotion component registry",
+ operatingSystem: "Any (Node.js, React, Remotion)",
+ keywords: HOME_KEYWORDS.join(", "),
+ license: "https://opensource.org/licenses/MIT",
+ isAccessibleForFree: true,
+ offers: {
+ "@type": "Offer",
+ price: "0",
+ priceCurrency: "USD",
+ },
+ softwareHelp: {
+ "@type": "CreativeWork",
+ url: `${SITE_URL}/docs/getting-started/introduction`,
+ },
+ installUrl: `${SITE_URL}/docs/getting-started/installation`,
+ sameAs: [GITHUB_URL, STUDIO_URL],
+ publisher: { "@id": ORG_ID },
+ author: { "@id": ORG_ID },
+ },
+ ],
+ };
+}
+
+/** `JSON.stringify` safe to inline in a `<script>` (Next's JSON-LD guide). */
+export function serializeJsonLd(data: unknown): string {
+ return JSON.stringify(data).replace(/</g, "\\u003c");
+}
diff --git a/next.config.ts b/next.config.ts
index 4f5bb274..649a9b8f 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -1,19 +1,13 @@
import { createMDX } from "fumadocs-mdx/next";
import type { NextConfig } from "next";
+import {
+ agentBeforeFilesRewrites,
+ agentFallbackRewrites,
+ agentHeaders,
+} from "./lib/agent-routing";
const withMDX = createMDX();
-// Next anchors `value` as `^value$`. Browsers never put text/markdown in
-// Accept; Claude Code's WebFetch sends `text/markdown, text/html, */*`.
-const AGENT_SIGNALS = [
- { type: "header", key: "accept", value: ".*text/markdown.*" },
- {
- type: "header",
- key: "user-agent",
- value: ".*(Claude-User|ChatGPT-User|Perplexity-User|MistralAI-User).*",
- },
-] as const;
-
const DOCS_FOLDER_REDIRECTS: Record<string, string> = {
"/docs/getting-started": "/docs/getting-started/introduction",
"/docs/icons": "/docs/icons/gallery",
@@ -63,40 +57,15 @@ const nextConfig: NextConfig = {
root: __dirname,
},
async rewrites() {
+ // Agents get Markdown at the same URLs; see lib/agent-routing.ts.
return {
- beforeFiles: [
- // Explicit Markdown URL: `/docs/<slug>.md` -> app/llms.md route.
- // `/docs` itself has no page; its Markdown is the llms.txt index.
- { source: "/docs.md", destination: "/llms.txt" },
- { source: "/docs/:path*.md", destination: "/llms.md/:path*" },
- // Same URL, Markdown for agents: a docs page or the home page answers
- // with Markdown when the client asks for it or is a fetcher reading a
- // page for a user. Crawlers that build a search index (Googlebot,
- // OAI-SearchBot, Claude-SearchBot) and agentic browsers (Atlas,
- // Claude-Agent, Google-Agent) still get HTML: the first would see
- // cloaking, the second needs the real UI to click through.
- ...AGENT_SIGNALS.flatMap((signal) => [
- // Before `/docs/:path*`, which matches the bare `/docs` too.
- { source: "/docs", has: [signal], destination: "/llms.txt" },
- {
- source: "/docs/:path*",
- has: [signal],
- destination: "/llms.md/:path*",
- },
- { source: "/", has: [signal], destination: "/llms.txt" },
- ]),
- ],
+ beforeFiles: agentBeforeFilesRewrites(),
afterFiles: [],
- fallback: [],
+ fallback: agentFallbackRewrites(),
};
},
async headers() {
- // The response at these URLs depends on Accept and User-Agent, so a cache
- // must not hand the Markdown variant to a browser or the other way round.
- return ["/", "/docs/:path*"].map((source) => ({
- source,
- headers: [{ key: "Vary", value: "Accept, User-Agent" }],
- }));
+ return agentHeaders();
},
async redirects() {
// Collapse the www host into the canonical apex so Google indexes a single
@@ -108,14 +77,11 @@ const nextConfig: NextConfig = {
destination: "https://remocn.dev/:path*",
permanent: true,
},
- // `/docs` has no page; people land on the introduction. Agents get the
- // llms.txt index there instead (see rewrites), so they skip this one.
- {
- source: "/docs",
- missing: [...AGENT_SIGNALS],
- destination: "/docs/getting-started/introduction",
- permanent: true,
- },
+ // `/docs` has no page: proxy.ts sends people to the introduction and
+ // gives agents the llms.txt index, after reading their Accept header.
+ // Conventional trust-page URLs land on the matching part of /legal.
+ { source: "/privacy", destination: "/legal#privacy", permanent: true },
+ { source: "/terms", destination: "/legal#terms", permanent: true },
// Docs folders without an index.mdx would 404; send them to their
// first page.
...Object.entries(DOCS_FOLDER_REDIRECTS).map(([source, destination]) => ({
diff --git a/proxy.ts b/proxy.ts
new file mode 100644
index 00000000..6fe16d93
--- /dev/null
+++ b/proxy.ts
@@ -0,0 +1,75 @@
+import { type NextRequest, NextResponse } from "next/server";
+import { negotiate, notAcceptableBody } from "@/lib/accept";
+import {
+ DOCS_HOME,
+ FETCHER_USER_AGENT,
+ markdownPathFor,
+ VARIANT_HEADER,
+} from "@/lib/agent-routing";
+
+const VARY = "Accept, User-Agent";
+
+/**
+ * Markdown for agents at the same URLs people use. The home page and docs
+ * pages negotiate on Accept (q-values included) and answer with Markdown,
+ * HTML or 406. Elsewhere the negotiated variant is passed on as a request
+ * header, so a 404 comes back as Markdown to a client that asked for it (see
+ * the fallback rewrite in lib/agent-routing.ts).
+ */
+export function proxy(request: NextRequest) {
+ // Only reads negotiate. Server Actions POST with their own Accept.
+ if (request.method !== "GET" && request.method !== "HEAD") {
+ return NextResponse.next();
+ }
+
+ const accept = request.headers.get("accept");
+ const variant = negotiate(accept, {
+ preferMarkdown: FETCHER_USER_AGENT.test(
+ request.headers.get("user-agent") ?? "",
+ ),
+ });
+ const { pathname } = request.nextUrl;
+ const markdownPath = markdownPathFor(pathname);
+
+ if (!markdownPath) return tagVariant(request, variant);
+
+ if (variant === "none") {
+ return new NextResponse(notAcceptableBody(accept ?? ""), {
+ status: 406,
+ headers: {
+ "Content-Type": "text/plain; charset=utf-8",
+ "Cache-Control": "no-store",
+ Vary: VARY,
+ },
+ });
+ }
+
+ if (variant === "markdown") {
+ const response = NextResponse.rewrite(new URL(markdownPath, request.url));
+ response.headers.set("Vary", VARY);
+ return response;
+ }
+
+ // `/docs` has no HTML page; people land on the introduction.
+ const response =
+ pathname === "/docs"
+ ? NextResponse.redirect(new URL(DOCS_HOME, request.url), 308)
+ : NextResponse.next();
+ response.headers.set("Vary", VARY);
+ return response;
+}
+
+/** Pass the variant on, dropping any value the client sent itself. */
+function tagVariant(request: NextRequest, variant: string) {
+ const headers = new Headers(request.headers);
+ if (variant === "markdown") headers.set(VARIANT_HEADER, "markdown");
+ else headers.delete(VARIANT_HEADER);
+ return NextResponse.next({ request: { headers } });
+}
+
+export const config = {
+ matcher: [
+ // Everything but build assets, the JSON API, MCP, registry and images.
+ "/((?!_next/|api/|mcp|r/|og/|embed/|favicon\\.ico).*)",
+ ],
+};