Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

docs: sync templates from eve-examples (#1907)

Colton Padden337fa21daa84
diff --git a/apps/docs/app/[lang]/templates/[slug]/page.tsx b/apps/docs/app/[lang]/templates/[slug]/page.tsx
index 03f5dadb1..34ac29506 100644
--- a/apps/docs/app/[lang]/templates/[slug]/page.tsx
+++ b/apps/docs/app/[lang]/templates/[slug]/page.tsx
@@ -146,7 +146,7 @@ const TemplateDetailPage = async ({ params }: { params: Promise<PageParams> }) =
<dd className="mt-2 text-copy-14">
<a
className="break-words rounded-sm font-medium text-gray-900 underline decoration-gray-400 underline-offset-4 outline-none transition-colors hover:text-gray-1000 hover:decoration-gray-1000 focus-visible:ring-2 focus-visible:ring-blue-700 focus-visible:ring-offset-2 focus-visible:ring-offset-background-100 motion-reduce:transition-none"
- href={`https://github.com/${entry.githubOwner}/${entry.githubRepo}`}
+ href={entry.sourceRevisionHref}
rel="noopener noreferrer"
target="_blank"
>
diff --git a/apps/docs/app/[lang]/templates/[slug]/template-readme.tsx b/apps/docs/app/[lang]/templates/[slug]/template-readme.tsx
index ac946ee8c..56aabe61a 100644
--- a/apps/docs/app/[lang]/templates/[slug]/template-readme.tsx
+++ b/apps/docs/app/[lang]/templates/[slug]/template-readme.tsx
@@ -3,8 +3,8 @@
import { createCodePlugin } from "@streamdown/code";
import { geistShikiTheme } from "@vercel/geistdocs/shiki-theme";
import { useMemo } from "react";
-import { type Components, Streamdown } from "streamdown";
-import { resolveReadmeHref } from "@/lib/templates/readme-links";
+import { type Components, defaultRemarkPlugins, Streamdown } from "streamdown";
+import { createResolveReadmeLinksPlugin, resolveReadmeHref } from "@/lib/templates/readme-links";
interface TemplateReadmeProps {
readme: string;
@@ -16,6 +16,13 @@ export const TemplateReadme = ({ readme, sourceRevisionHref }: TemplateReadmePro
() => createCodePlugin({ themes: [geistShikiTheme, geistShikiTheme] }),
[],
);
+ const remarkPlugins = useMemo(
+ () => [
+ ...Object.values(defaultRemarkPlugins),
+ createResolveReadmeLinksPlugin(sourceRevisionHref),
+ ],
+ [sourceRevisionHref],
+ );
const components = useMemo<Partial<Components>>(
() => ({
a: ({ href, ...props }) => {
@@ -63,6 +70,7 @@ export const TemplateReadme = ({ readme, sourceRevisionHref }: TemplateReadmePro
disallowedElements={["img"]}
mode="static"
plugins={{ code: codePlugin }}
+ remarkPlugins={remarkPlugins}
shikiTheme={[geistShikiTheme, geistShikiTheme]}
>
{readme}
diff --git a/apps/docs/lib/templates/compose.test.ts b/apps/docs/lib/templates/compose.test.ts
index 16785e17b..014f3f7c4 100644
--- a/apps/docs/lib/templates/compose.test.ts
+++ b/apps/docs/lib/templates/compose.test.ts
@@ -52,6 +52,24 @@ describe("composeTemplateEntries", () => {
expect(entry).not.toHaveProperty("github");
});
+ it("includes a monorepo path in the pinned source URL", () => {
+ const monorepoEntry: TemplateManifestEntry = {
+ ...manifestEntry,
+ github: {
+ owner: "vercel",
+ repo: "eve-examples",
+ ref: "main",
+ pathPrefix: "example-template",
+ },
+ };
+
+ const [entry] = composeTemplateEntries([monorepoEntry], generated);
+
+ expect(entry.sourceRevisionHref).toBe(
+ "https://github.com/vercel/eve-examples/tree/0123456789abcdef0123456789abcdef01234567/example-template",
+ );
+ });
+
it("throws when a manifest slug has no generated data", () => {
expect(() => composeTemplateEntries([manifestEntry], { templates: {} })).toThrow(
/No generated data for template "example"/,
diff --git a/apps/docs/lib/templates/manifest.ts b/apps/docs/lib/templates/manifest.ts
index cfec9fa0c..f08a6e0a4 100644
--- a/apps/docs/lib/templates/manifest.ts
+++ b/apps/docs/lib/templates/manifest.ts
@@ -47,16 +47,21 @@ export const templateManifest: TemplateManifestEntry[] = [
slug: "eve-chat-template",
title: "Chat",
setupPrompt:
- "Set up the eve chat template in my current workspace using https://github.com/vercel-labs/eve-chat-template/tree/main as the source. Copy the project files, install its dependencies, and follow the repository README to configure it. Preserve the existing project if the workspace is not empty, and tell me about any required environment variables or manual setup steps.",
+ "Set up the eve chat template in my current workspace using https://github.com/vercel/eve-examples/tree/main/eve-chat-template as the source. Copy the project files, install its dependencies, and follow the repository README to configure it. Preserve the existing project if the workspace is not empty, and tell me about any required environment variables or manual setup steps.",
description:
"A persisted Next.js chat template for eve, built with shadcn/ui, Tailwind CSS, Streamdown, Better Auth, Drizzle, Neon, and Upstash Redis.",
demoHref: "https://eve-chat-template.labs.vercel.dev",
- sourceHref: "https://github.com/vercel-labs/eve-chat-template/tree/main",
+ sourceHref: "https://github.com/vercel/eve-examples/tree/main/eve-chat-template",
category: "Chat",
model: "anthropic/claude-sonnet-5",
integrations: ["Web chat", "Slack"],
source: "Vercel Templates",
- github: { owner: "vercel-labs", repo: "eve-chat-template", ref: "main" },
+ github: {
+ owner: "vercel",
+ repo: "eve-examples",
+ ref: "main",
+ pathPrefix: "eve-chat-template",
+ },
files: [
"agent/agent.ts",
"agent/channels/eve.ts",
@@ -97,15 +102,20 @@ export const templateManifest: TemplateManifestEntry[] = [
slug: "eve-slack-agent",
title: "Slack",
setupPrompt:
- "Set up the eve Slack agent template in my current workspace using https://github.com/vercel-labs/eve-slack-agent-template/tree/main as the source. Copy the project files, install its dependencies, and follow the repository README to configure it. Preserve the existing project if the workspace is not empty, and tell me about any required environment variables or manual setup steps.",
+ "Set up the eve Slack agent template in my current workspace using https://github.com/vercel/eve-examples/tree/main/eve-slack-agent-template as the source. Copy the project files, install its dependencies, and follow the repository README to configure it. Preserve the existing project if the workspace is not empty, and tell me about any required environment variables or manual setup steps.",
description:
"A Slack agent template with webhook handling, Vercel Connect, a starter agent, and an example tool ready to deploy on Vercel.",
- sourceHref: "https://github.com/vercel-labs/eve-slack-agent-template/tree/main",
+ sourceHref: "https://github.com/vercel/eve-examples/tree/main/eve-slack-agent-template",
category: "Collaboration",
model: "anthropic/claude-sonnet-5",
integrations: ["Slack"],
source: "Vercel Templates",
- github: { owner: "vercel-labs", repo: "eve-slack-agent-template", ref: "main" },
+ github: {
+ owner: "vercel",
+ repo: "eve-examples",
+ ref: "main",
+ pathPrefix: "eve-slack-agent-template",
+ },
files: [
"agent/agent.ts",
"agent/channels/slack.ts",
diff --git a/apps/docs/lib/templates/readme-links.test.ts b/apps/docs/lib/templates/readme-links.test.ts
index f24ce9e47..ede73fab7 100644
--- a/apps/docs/lib/templates/readme-links.test.ts
+++ b/apps/docs/lib/templates/readme-links.test.ts
@@ -1,6 +1,10 @@
import { describe, expect, it } from "vitest";
-import { resolveReadmeHref, sanitizeReadmeHref } from "./readme-links";
+import {
+ createResolveReadmeLinksPlugin,
+ resolveReadmeHref,
+ sanitizeReadmeHref,
+} from "./readme-links";
const sourceRevisionHref =
"https://github.com/vercel/eve/tree/0123456789abcdef/apps/fixtures/weather-agent";
@@ -30,6 +34,22 @@ describe("resolveReadmeHref", () => {
});
});
+describe("createResolveReadmeLinksPlugin", () => {
+ it("resolves links before the markdown renderer sanitizes relative URLs", () => {
+ const tree = {
+ type: "root",
+ children: [
+ { type: "link", url: "docs/setup.md", children: [{ type: "text", value: "Setup" }] },
+ { type: "paragraph", children: [{ type: "text", value: "No link" }] },
+ ],
+ };
+
+ createResolveReadmeLinksPlugin(sourceRevisionHref)()(tree);
+
+ expect(tree.children[0].url).toBe(`${sourceRevisionHref}/docs/setup.md`);
+ });
+});
+
describe("sanitizeReadmeHref", () => {
it("allows web, email, telephone, relative, and anchor links", () => {
expect(sanitizeReadmeHref("https://eve.dev")).toBe("https://eve.dev/");
diff --git a/apps/docs/lib/templates/readme-links.ts b/apps/docs/lib/templates/readme-links.ts
index e577ca4f2..e06370411 100644
--- a/apps/docs/lib/templates/readme-links.ts
+++ b/apps/docs/lib/templates/readme-links.ts
@@ -1,5 +1,18 @@
const SAFE_ABSOLUTE_PROTOCOLS = new Set(["http:", "https:", "mailto:", "tel:"]);
+interface MarkdownNode {
+ type?: unknown;
+ url?: unknown;
+ children?: unknown;
+}
+
+export const createResolveReadmeLinksPlugin =
+ (sourceRevisionHref: string) =>
+ () =>
+ (tree: unknown): void => {
+ resolveMarkdownLinks(tree, sourceRevisionHref);
+ };
+
export const resolveReadmeHref = (
href: string | undefined,
sourceRevisionHref: string,
@@ -72,6 +85,22 @@ const getGitHubBases = (
};
};
+const resolveMarkdownLinks = (value: unknown, sourceRevisionHref: string): void => {
+ if (!value || typeof value !== "object") {
+ return;
+ }
+
+ const node = value as MarkdownNode;
+ if (node.type === "link" && typeof node.url === "string") {
+ node.url = resolveReadmeHref(node.url, sourceRevisionHref);
+ }
+ if (Array.isArray(node.children)) {
+ for (const child of node.children) {
+ resolveMarkdownLinks(child, sourceRevisionHref);
+ }
+ }
+};
+
const stripAsciiControlCharacters = (value: string): string => {
let normalized = "";
for (const character of value) {