Merge build/1107 into main
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by oscabriel · committed by oscabriel · parents efa96f3, 90169de · Browse files · 13 files·+795 added−23 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
13 files+795 added−23 removed
- tests:+407 added−2 removed
- other:+388 added−21 removed
Provenance
- Commit
0ac60f3- Tree
c132637- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent 1
efa96f3- Parent 2
90169de
13 files changed+795 added−23 removed
added:apps/web/src/features/agents/setup-page.tsx+73 added
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273/** * The Agents page: each way an agent connects, as `@repo/agent-kit`'s * `agentSetup` gives it, so the page has no text of its own for a snippet * (principle 4). A shell line is a `CommandLine`; JSON and text to paste * sit in a block with the same copy affordance. A view: channels in, * markup out. */import type { SetupChannel, SetupSnippet } from "@repo/agent-kit/agent-setup";
import { LINK, Region } from "../ask/fields.tsx";import { CopyButton } from "../code/copy.tsx";import { CommandLine } from "../shared/command.tsx";
/** A channel's heading id, from its title: `agents-remote-mcp`. */const idOf = (title: string) => `agents-${title.toLowerCase().replaceAll(/[^a-z0-9]+/gu, "-")}`;
const SnippetBlock = ({ snippet }: { readonly snippet: SetupSnippet }) => ( <div className="border-rule bg-surface flex max-w-full min-w-0 items-start gap-2 border py-1 pr-1 pl-3"> <pre className="min-w-0 flex-1 overflow-x-auto py-0.5 font-mono text-[0.8125rem] leading-6 whitespace-pre-wrap"> <code className="[overflow-wrap:anywhere] select-all"> {snippet.text} </code> </pre> <div className="shrink-0"> <CopyButton label="Copy" text={snippet.text} /> </div> </div>);
const Snippet = ({ snippet }: { readonly snippet: SetupSnippet }) => ( <figure className="flex min-w-0 flex-col gap-1.5"> <figcaption className="text-muted-foreground text-sm"> {snippet.label} </figcaption> {snippet.language === "sh" ? ( <CommandLine command={snippet.text} /> ) : ( <SnippetBlock snippet={snippet} /> )} </figure>);
export const AgentSetupView = ({ channels,}: { readonly channels: readonly SetupChannel[];}) => ( <> <p className="max-w-[70ch]"> Pick the way your agent works. Each one reaches the same asks, claims and verdicts; an agent that reads Markdown can read{" "} <a className={LINK} href="/agents.md"> this page as Markdown </a> . </p> {channels.map((channel) => ( <Region id={idOf(channel.title)} key={channel.title} title={channel.title} > <p className="max-w-[70ch]">{channel.useWhen}</p> <div className="flex max-w-[80ch] flex-col gap-4"> {channel.snippets.map((snippet) => ( <Snippet key={snippet.label} snippet={snippet} /> ))} </div> </Region> ))} </>);modified:apps/web/src/features/shared/layout.tsx+21 added-5 removed
12345234567891022 unmodified lines33343536373839404142 unmodified lines848586878688899091924 unmodified lines979899100101102103104105106107108109110111112113114115116117/** * The shell every page shares: the site header (front page, Today, the * session), one main region per page headed by its title over a double * rule, and the footer's two ways in (plain git, and the CLI). The root * route composes them (`src/routes/__root.tsx`); a page renders `PageShell`. * The shell every page shares: the site header (front page, Today, Agents, * the session), one main region per page headed by its title over a double * rule, and the footer's ways in (plain git, the CLI, and the Agents page). * The root route composes them (`src/routes/__root.tsx`); a page renders * `PageShell`. */import { Brand } from "@repo/brand";import type { ReactNode } from "react";
22 unmodified lines
const NAV = [ { href: "/", label: "Asks" }, { href: "/today", label: "Today" }, { href: "/agents", label: "Agents" },] as const;
/** Whether `href` is the page at `pathname`, or the section it heads. */const isCurrent = (href: string, pathname: string) =>42 unmodified lines}: { readonly platformUrl: string;}) => ( <footer className="border-rule border-t"> <div className={`${COLUMN} grid gap-6 py-8 sm:grid-cols-2`}> <div className={`${COLUMN} grid gap-6 py-8 sm:grid-cols-3`}> <section className="flex min-w-0 flex-col gap-2"> <h2 className="text-muted-foreground text-xs font-medium"> Plain git: clone any project </h2>4 unmodified lines Install the {Brand.cli} CLI </h2> <CommandLine command={`curl -fsSL ${platformUrl}/install.sh | sh`} /> </section> <section className="flex min-w-0 flex-col gap-2"> <h2 className="text-muted-foreground text-xs font-medium"> Connect an agent </h2> <p className="text-sm"> <a className="decoration-rule underline hover:decoration-current" href="/agents" > MCP, the CLI, llms.txt and skills </a> , with the setup for each agent. </p> </section> </div> </footer>);added:apps/web/src/routes/agents.tsx+36 added
123456789101112131415161718192021222324252627282930313233343536import { agentSetup } from "@repo/agent-kit/agent-setup";import { createFileRoute, getRouteApi, useRouter,} from "@tanstack/react-router";
import { commands } from "../features/agents/catalog.ts";import { AgentSetupView } from "../features/agents/setup-page.tsx";import { PageShell, pageTitle } from "../features/shared/layout.tsx";
// `/agents`: how each agent connects, drawn from `@repo/agent-kit`'s// `agentSetup` for this stage's platform and the web's own origin (the// router's: the request's on the server, the page's in the browser), so// the server's render and the browser's agree. `/agents.md` is the same// text as Markdown.
const root = getRouteApi("__root__");
const AgentsPage = () => { const { platformUrl } = root.useLoaderData(); const { origin } = useRouter();
return ( <PageShell title="Agents"> <AgentSetupView channels={agentSetup({ commands, platformUrl, webUrl: origin })} /> </PageShell> );};
export const Route = createFileRoute("/agents")({ component: AgentsPage, head: () => ({ meta: [{ title: pageTitle("Agents") }] }),});added:apps/web/src/routes/agents[.]md.ts+32 added
1234567891011121314151617181920212223242526272829303132import { agentSetupMarkdown } from "@repo/agent-kit/agent-setup";import { createFileRoute } from "@tanstack/react-router";import { env } from "cloudflare:workers";
import { commands } from "../features/agents/catalog.ts";import { markdown } from "../features/agents/respond.ts";
// `/agents.md`: the Agents page as Markdown (a literal `.` is `[.]` in a// route file's name), from the same `agentSetup` the page draws, for the// web's own origin.
/** The route's handler as a function of the platform's URL, which its test hands in. */export const agentsMarkdownHandler = (platformUrl: string) => ({ request }: { readonly request: Request }): Promise<Response> => Promise.resolve( markdown( agentSetupMarkdown({ commands, platformUrl, webUrl: new URL(request.url).origin, }) ) );
export const Route = createFileRoute("/agents.md")({ server: { handlers: { GET: agentsMarkdownHandler(env.PUBLIC_PLATFORM_URL), }, },});added:apps/web/test/agents.test.tsx+104 added
1+/**2+ * The Agents page: how each agent connects, drawn from `@repo/agent-kit`'s3+ * `agentSetup`, so the page has no text of its own for a snippet4+ * (principle 4); `/agents.md` is the same channels as Markdown.5+ */6+import { describe, expect, it } from "@effect/vitest";7+import { agentSetup, agentSetupMarkdown } from "@repo/agent-kit/agent-setup";8+import { Effect } from "effect";9+import type { ReactElement } from "react";10+import { renderToStaticMarkup } from "react-dom/server";11+12+import { commands } from "../src/features/agents/catalog.ts";13+import { AgentSetupView } from "../src/features/agents/setup-page.tsx";14+import { agentsMarkdownHandler } from "../src/routes/agents[.]md.ts";15+16+const platformUrl = "https://platform-test.example.workers.dev";17+18+const webUrl = "https://web-test.example.workers.dev";19+20+const channels = agentSetup({ commands, platformUrl, webUrl });21+22+/** The entities React writes for text, and what each reads as. */23+const ENTITIES: ReadonlyMap<string, string> = new Map([24+ ["'", "'"],25+ ["&", "&"],26+ [">", ">"],27+ ["<", "<"],28+ [""", '"'],29+]);30+31+const decoded = (html: string) =>32+ html.replaceAll(33+ /&(?:#x27|amp|gt|lt|quot);/gu,34+ (entity) => ENTITIES.get(entity) ?? entity35+ );36+37+const markupOf = (element: ReactElement) => renderToStaticMarkup(element);38+39+/** What a reader sees: the markup without its tags, entities decoded. */40+const textOf = (element: ReactElement) =>41+ decoded(markupOf(element).replaceAll(/<[^>]+>/gu, ""));42+43+/** The text of every `<code>` on the page, in order. */44+const codeOf = (element: ReactElement) =>45+ [...markupOf(element).matchAll(/<code\b[^>]*>(?<body>.*?)<\/code>/gsu)].map(46+ ({ groups }) => decoded(groups?.body ?? "")47+ );48+49+describe("the Agents page", () => {50+ const page = <AgentSetupView channels={channels} />;51+52+ it("shows every snippet agentSetup gives, and no code of its own", () => {53+ expect(codeOf(page)).toStrictEqual(54+ channels.flatMap(({ snippets }) => snippets.map(({ text }) => text))55+ );56+ });57+58+ it("heads each channel with its title and says when to use it", () => {59+ const text = textOf(page);60+61+ for (const { snippets, title, useWhen } of channels) {62+ expect(text).toContain(title);63+ expect(text).toContain(useWhen);64+65+ for (const { label } of snippets) {66+ expect(text).toContain(label);67+ }68+ }69+ });70+71+ it("gives every snippet a button that copies it", () => {72+ const buttons = markupOf(page).match(73+ /<button\b[^>]*>.*?Copy.*?<\/button>/gu74+ );75+76+ expect(buttons).toHaveLength(77+ channels.reduce((count, { snippets }) => count + snippets.length, 0)78+ );79+ });80+81+ it("links the same channels as Markdown", () => {82+ expect(markupOf(page)).toMatch(/<a\b[^>]*href="\/agents\.md"[^>]*>/u);83+ });84+});85+86+describe("/agents.md", () => {87+ it.effect("answers the channels as Markdown for the web's own origin", () =>88+ Effect.gen(function* () {89+ const response = yield* Effect.promise(() =>90+ agentsMarkdownHandler(platformUrl)({91+ request: new Request(`${webUrl}/agents.md`),92+ })93+ );94+95+ expect(response.status).toBe(200);96+ expect(response.headers.get("content-type")).toBe(97+ "text/markdown; charset=utf-8"98+ );99+ expect(yield* Effect.promise(() => response.text())).toBe(100+ agentSetupMarkdown({ commands, platformUrl, webUrl })101+ );102+ })103+ );104+});modified:apps/web/test/routes.test.ts+2 added
38 unmodified lines39 describe("the web's own paths", () => {40 it("are found: every page and file the web serves at its top", () => {41 expect(segments).toStrictEqual([42 ".well-known",43+ "agents",44+ "agents.md",45 "apple-touch-icon.png",46 "assets",47 "auth",48 "favicon.ico",23 unmodified linesmodified:apps/web/test/shared.test.tsx+30 added-1 removed
409 unmodified lines410 expect(markup).not.toMatch(/<a\b[^>]*aria-current="page"[^>]*>Asks<\/a>/u);411 expect(markup).toContain(">Sign in</a>");412 });413 414+ it("links Asks, Today and Agents in the header, marking Agents current on its page", () => {415+ const markup = markupOf(<SiteHeader pathname="/agents" session={null} />);416+417+ const links = [418+ ...markup.matchAll(419+ /<a\b[^>]*href="(?<href>[^"]+)"[^>]*>(?<label>[^<]+)<\/a>/gu420+ ),421+ ].map(({ groups }) => [groups?.href, groups?.label]);422+423+ expect(links).toStrictEqual([424+ ["#main", "Skip to content"],425+ ["/", Brand.name],426+ ["/", "Asks"],427+ ["/today", "Today"],428+ ["/agents", "Agents"],429+ ]);430+ expect(markup).toMatch(/<a\b[^>]*aria-current="page"[^>]*>Agents<\/a>/u);431+ expect(markup).not.toMatch(/<a\b[^>]*aria-current="page"[^>]*>Today<\/a>/u);432+ });433+414- it("gives the two ways in at the foot of every page: plain git and the CLI", () => {434+ it("gives the command-line ways in at the foot of every page: plain git and the CLI", () => {435 const text = textOf(<SiteFooter platformUrl={platformUrl} />);436 437 expect(text).toContain("Plain git: clone any project");438 expect(text).toContain(`git clone ${platformUrl}/<project>.git`);439 expect(text).toContain(`curl -fsSL ${platformUrl}/install.sh | sh`);440 });441 442+ it("sends a reader who wants to connect an agent to the Agents page", () => {443+ const markup = markupOf(<SiteFooter platformUrl={platformUrl} />);444+445+ expect(markup).toMatch(/<a\b[^>]*href="\/agents"[^>]*>/u);446+ expect(textOf(<SiteFooter platformUrl={platformUrl} />)).toContain(447+ "Connect an agent"448+ );449+ });450+451 it("names the paper colours the theme-color meta repeats", () => {452 expect(styles).toContain(`--background: ${themeColors.light};`);453 expect(styles).toContain(`--background: ${themeColors.dark};`);454 });23 unmodified linesadded:packages/agent-kit/src/agent-setup.ts+177 added
1+/**2+ * How an agent connects to the platform, one channel at a time: remote MCP3+ * for a client that signs in over OAuth, MCP over stdio through the CLI,4+ * the CLI itself, a sentence any agent can be handed, and the skills. Each5+ * channel says when to use it and gives the snippets to copy. The web draws6+ * it as `/agents` and serves `agentSetupMarkdown` as `/agents.md`.7+ *8+ * Pure: the hosts hand in the CLI's commands as this package's one list9+ * holds them and the two hosts' URLs. Each client's MCP JSON comes from10+ * `mcpServersFor`, the builder the plugin bundles use, and every name from11+ * `Brand`, the MCP server's name being `Brand.slug`.12+ *13+ * Client facts, as each client's docs give them: Claude Code adds a remote14+ * server with `claude mcp add --transport http <name> <url>` and signs in15+ * from `/mcp`; Cursor reads `.cursor/mcp.json`'s `mcpServers`, a remote16+ * entry being its `url`; VS Code reads `.vscode/mcp.json`'s `servers`, a17+ * remote entry being `{type: "http", url}`.18+ */19+import { Brand } from "@repo/brand";20+import { Array as Arr } from "effect";21+22+import type { CommandDoc } from "./command-doc.ts";23+import { mcpServersFor } from "./platform.ts";24+import { page, printJson } from "./text.ts";25+26+export interface SetupSnippet {27+ /** What the snippet is, or where it goes: a client, a file. */28+ readonly label: string;29+ readonly language: "sh" | "json" | "text";30+ /** The text to copy, whole, with no trailing newline. */31+ readonly text: string;32+}33+34+export interface SetupChannel {35+ readonly title: string;36+ /** One plain sentence, no Markdown: the agent this channel is for. */37+ readonly useWhen: string;38+ readonly snippets: readonly SetupSnippet[];39+}40+41+export interface SetupInput {42+ /** Every CLI command, as `commandDocs` lists them. */43+ readonly commands: readonly CommandDoc[];44+ /** The platform's origin: its MCP endpoint and the CLI's sign-in. */45+ readonly platformUrl: string;46+ /** The web's origin: its Markdown, the CLI's downloads and the skills. */47+ readonly webUrl: string;48+}49+50+/** Whether the CLI has the command whose words are `words`. */51+const has = (commands: readonly CommandDoc[], words: string) =>52+ Arr.some(commands, ({ path }) => path.join(" ") === words);53+54+/** JSON as a snippet holds it: the generators' printing, without its final newline. */55+const json = (value: Parameters<typeof printJson>[0]) =>56+ printJson(value).trimEnd();57+58+const remoteMcp = ({ platformUrl }: SetupInput): SetupChannel => ({59+ snippets: [60+ {61+ label: "Claude Code, then /mcp in a session to sign in",62+ language: "sh",63+ text: `claude mcp add --transport http ${Brand.slug} ${platformUrl}/mcp`,64+ },65+ {66+ label: "Cursor, in .cursor/mcp.json",67+ language: "json",68+ text: json({ mcpServers: mcpServersFor(platformUrl, "cursor") }),69+ },70+ {71+ label: "VS Code, in .vscode/mcp.json",72+ language: "json",73+ text: json({ servers: mcpServersFor(platformUrl, "claude") }),74+ },75+ ],76+ title: "Remote MCP",77+ useWhen: `Your client signs in over OAuth: it opens a browser once, you sign in with your account on ${Brand.name}, and it calls the platform's tools at ${platformUrl}/mcp.`,78+});79+80+const stdioMcp = (): SetupChannel => ({81+ snippets: [82+ {83+ label: "The server's command, once you have signed in with the CLI",84+ language: "sh",85+ text: `${Brand.cli} mcp`,86+ },87+ ],88+ title: "MCP over stdio",89+ useWhen: `Your client starts its MCP servers as local commands, or cannot sign in over OAuth: the CLI serves the same tools over stdio, with the token the CLI stored when you signed in.`,90+});91+92+const theCli = ({93+ commands,94+ platformUrl,95+ webUrl,96+}: SetupInput): SetupChannel => ({97+ snippets: [98+ {99+ label: "Install",100+ language: "sh",101+ // The web forwards the CLI's downloads to the platform, as `llms.txt` says.102+ text: `curl -fsSL ${webUrl}/install.sh | sh`,103+ },104+ ...(has(commands, "login")105+ ? [106+ {107+ label: "Sign in once; git pushes with your token from then on",108+ language: "sh" as const,109+ text: `${Brand.cli} login --url ${platformUrl}`,110+ },111+ ]112+ : []),113+ ],114+ title: "The CLI",115+ useWhen: `Your agent has a shell: it finds and claims asks, checks an answer before it pushes and reads verdicts with the CLI, and pushes with git.`,116+});117+118+const anyAgent = ({ webUrl }: SetupInput): SetupChannel => ({119+ snippets: [120+ {121+ label: "Paste into the agent's prompt",122+ language: "text",123+ text: `Use ${webUrl}/llms.txt as the source of truth for ${Brand.name}: it says how to take an ask and lists every command and project. Each ask reads as Markdown at ${webUrl}/<project>/asks/<ask>.md.`,124+ },125+ ],126+ title: "Text for any agent",127+ useWhen:128+ "Your agent can fetch a URL but has no MCP client or CLI set up: hand it the platform's index and it reads the rest as Markdown.",129+});130+131+const skills = ({ webUrl }: SetupInput): SetupChannel => ({132+ snippets: [133+ {134+ label: "Add every project's contribute skill",135+ language: "sh",136+ text: `npx skills add ${webUrl}`,137+ },138+ ],139+ title: "Skills",140+ useWhen: `Your agent loads skills: each project's contribute skill is listed, with its digest, at ${webUrl}/.well-known/agent-skills/index.json.`,141+});142+143+/** Every channel, in the order the page shows them; stdio only when the CLI has `mcp`. */144+export const agentSetup = (input: SetupInput): readonly SetupChannel[] => [145+ remoteMcp(input),146+ ...(has(input.commands, "mcp") ? [stdioMcp()] : []),147+ theCli(input),148+ anyAgent(input),149+ skills(input),150+];151+152+const snippetLines = ({ label, language, text }: SetupSnippet) => [153+ `${label}:`,154+ "",155+ `\`\`\`${language}`,156+ text,157+ "```",158+ "",159+];160+161+const channelLines = ({ snippets, title, useWhen }: SetupChannel) => [162+ `## ${title}`,163+ "",164+ `Use this when ${useWhen.charAt(0).toLowerCase()}${useWhen.slice(1)}`,165+ "",166+ ...snippets.flatMap(snippetLines),167+];168+169+/** The same channels as one Markdown document: `/agents.md`. */170+export const agentSetupMarkdown = (input: SetupInput) =>171+ page([172+ "# Agents",173+ "",174+ `> How an agent connects to ${Brand.name}: over MCP, through the CLI, with a sentence to paste, or as skills. Each section says when to use it.`,175+ "",176+ ...agentSetup(input).flatMap(channelLines),177+ ]);modified:packages/agent-kit/src/platform.ts+43 added-12 removed
118 unmodified lines119 input: PlatformInput120 ): Effect.Effect<readonly GeneratedFile[]> =>121 skillFile(input).pipe(Effect.map((content) => [{ content, path: SKILL }]));122 123+// --- The MCP server, as each client's config names it ----------------------------124+125+/**126+ * How each config spells the platform's MCP server: Claude Code's `.mcp.json`127+ * (and VS Code's `servers`, the same entry), Agent Plugins 1.0's `mcp.json`,128+ * and Cursor's `mcp.json`, whose remote entry is a bare `url` (its docs give129+ * a `type` only for stdio).130+ */131+const servers = {132+ "agent-plugins": {133+ remote: (url: string) => ({ type: "streamable-http", url }),134+ stdio: { args: ["mcp"], command: Brand.cli, type: "stdio" },135+ },136+ claude: {137+ remote: (url: string) => ({ type: "http", url }),138+ stdio: { args: ["mcp"], command: Brand.cli },139+ },140+ cursor: {141+ remote: (url: string) => ({ url }),142+ stdio: { args: ["mcp"], command: Brand.cli, type: "stdio" },143+ },144+} as const;145+146+export type McpFlavour = keyof typeof servers;147+148+/**149+ * The `mcpServers` object a client's config holds: the platform's `/mcp`150+ * over HTTP, or `<cli> mcp` over stdio without a URL, under the brand's151+ * slug. The plugin bundles and the Agents page (`agent-setup.ts`) both152+ * build theirs here, so no client's snippet can drift from a bundle's.153+ */154+export const mcpServersFor = (155+ platformUrl: string | undefined,156+ flavour: McpFlavour157+) => ({158+ [Brand.slug]:159+ platformUrl === undefined160+ ? servers[flavour].stdio161+ : servers[flavour].remote(`${platformUrl}/mcp`),162+});163+164 // --- The Claude Code plugin ------------------------------------------------------165 166 const hookCommand = (event: HookEvent) => ({167 hooks: [{ command: `${Brand.cli} hook ${event} --json`, type: "command" }],44 unmodified lines212 },213 { content: skill, path: `${PLUGIN}/${SKILL}` },214 {215 content: printJson({175- mcpServers: {176- [Brand.slug]:177- input.platformUrl === undefined178- ? { args: ["mcp"], command: Brand.cli }179- : { type: "http", url: `${input.platformUrl}/mcp` },180- },216+ mcpServers: mcpServersFor(input.platformUrl, "claude"),217 }),218 path: `${PLUGIN}/.mcp.json`,219 },220 { content: hooksJson(), path: `${PLUGIN}/hooks/hooks.json` },27 unmodified lines248 { content: skill, path: `${PLUGIN}/${SKILL}` },249 {250 content: printJson({251 $schema: `${SCHEMAS}/mcp.schema.json`,216- mcpServers: {217- [Brand.slug]:218- input.platformUrl === undefined219- ? { args: ["mcp"], command: Brand.cli, type: "stdio" }220- : { type: "streamable-http", url: `${input.platformUrl}/mcp` },221- },252+ mcpServers: mcpServersFor(input.platformUrl, "agent-plugins"),253 }),254 path: `${PLUGIN}/mcp.json`,255 },256 ])1 unmodified lineadded:packages/agent-kit/test/golden/agent-setup.txt+84 added
1+# Agents2+3+> How an agent connects to __NAME__: over MCP, through the CLI, with a sentence to paste, or as skills. Each section says when to use it.4+5+## Remote MCP6+7+Use this when your client signs in over OAuth: it opens a browser once, you sign in with your account on __NAME__, and it calls the platform's tools at https://platform-test.example.workers.dev/mcp.8+9+Claude Code, then /mcp in a session to sign in:10+11+```sh12+claude mcp add --transport http __SLUG__ https://platform-test.example.workers.dev/mcp13+```14+15+Cursor, in .cursor/mcp.json:16+17+```json18+{19+ "mcpServers": {20+ "__SLUG__": {21+ "url": "https://platform-test.example.workers.dev/mcp"22+ }23+ }24+}25+```26+27+VS Code, in .vscode/mcp.json:28+29+```json30+{31+ "servers": {32+ "__SLUG__": {33+ "type": "http",34+ "url": "https://platform-test.example.workers.dev/mcp"35+ }36+ }37+}38+```39+40+## MCP over stdio41+42+Use this when your client starts its MCP servers as local commands, or cannot sign in over OAuth: the CLI serves the same tools over stdio, with the token the CLI stored when you signed in.43+44+The server's command, once you have signed in with the CLI:45+46+```sh47+__CLI__ mcp48+```49+50+## The CLI51+52+Use this when your agent has a shell: it finds and claims asks, checks an answer before it pushes and reads verdicts with the CLI, and pushes with git.53+54+Install:55+56+```sh57+curl -fsSL https://web-test.example.workers.dev/install.sh | sh58+```59+60+Sign in once; git pushes with your token from then on:61+62+```sh63+__CLI__ login --url https://platform-test.example.workers.dev64+```65+66+## Text for any agent67+68+Use this when your agent can fetch a URL but has no MCP client or CLI set up: hand it the platform's index and it reads the rest as Markdown.69+70+Paste into the agent's prompt:71+72+```text73+Use https://web-test.example.workers.dev/llms.txt as the source of truth for __NAME__: it says how to take an ask and lists every command and project. Each ask reads as Markdown at https://web-test.example.workers.dev/<project>/asks/<ask>.md.74+```75+76+## Skills77+78+Use this when your agent loads skills: each project's contribute skill is listed, with its digest, at https://web-test.example.workers.dev/.well-known/agent-skills/index.json.79+80+Add every project's contribute skill:81+82+```sh83+npx skills add https://web-test.example.workers.dev84+```added:packages/agent-kit/test/agent-setup.test.ts+177 added
1+/**2+ * The Agents page's one source: how each agent connects (remote MCP, MCP3+ * over stdio, the CLI, text to paste, skills), each channel with when to4+ * use it and the snippets to copy. A pure function of the CLI's commands5+ * and the two hosts' URLs; the web draws it as `/agents` and serves it as6+ * `/agents.md`, and its MCP JSON is the object the plugin bundles carry.7+ */8+import { NodeServices } from "@effect/platform-node";9+import { describe, expect, it } from "@effect/vitest";10+import { Brand } from "@repo/brand";11+import { Array as Arr, Effect, Option, Schema } from "effect";12+13+import { agentSetup, agentSetupMarkdown } from "../src/agent-setup.ts";14+import type { SetupChannel } from "../src/agent-setup.ts";15+import type { CommandDoc } from "../src/command-doc.ts";16+import { claudePlugin } from "../src/platform.ts";17+import { commands as someCommands } from "./fixtures.ts";18+import { expectGolden } from "./golden.ts";19+20+const platformUrl = "https://platform-test.example.workers.dev";21+22+const webUrl = "https://web-test.example.workers.dev";23+24+const login: CommandDoc = {25+ flags: ["--url", "--json"],26+ needsApproval: false,27+ path: ["login"],28+ positional: [],29+ readOnly: false,30+ source: "local",31+ summary: "Sign in to a platform.",32+};33+34+const mcp: CommandDoc = {35+ flags: [],36+ needsApproval: false,37+ path: ["mcp"],38+ positional: [],39+ readOnly: true,40+ source: "local",41+ summary: "Serve the platform's tools over MCP on stdio.",42+};43+44+const commands: readonly CommandDoc[] = [...someCommands, login, mcp];45+46+const channels = agentSetup({ commands, platformUrl, webUrl });47+48+/** The channel titled `title`; fails the test without one. */49+const channel = (from: readonly SetupChannel[], title: string) =>50+ Option.getOrThrow(Arr.findFirst(from, (each) => each.title === title));51+52+/** The snippet labelled `label` in the channel titled `title`. */53+const snippet = (title: string, label: string) =>54+ Option.getOrThrow(55+ Arr.findFirst(channel(channels, title).snippets, (each) =>56+ each.label.startsWith(label)57+ )58+ );59+60+/** A JSON object's text, decoded. */61+const parsed = Schema.decodeUnknownSync(62+ Schema.fromJsonString(Schema.Record(Schema.String, Schema.Unknown))63+);64+65+/** The `.mcp.json` the Claude Code plugin carries for the same platform. */66+const pluginMcpJson = claudePlugin({ commands, platformUrl }).pipe(67+ Effect.map((files) =>68+ Option.getOrThrow(69+ Arr.findFirst(files, ({ path }) => path.endsWith("/.mcp.json"))70+ )71+ )72+);73+74+describe("the Agents page's source", () => {75+ it.effect("as Markdown, is the golden text", () =>76+ expectGolden(77+ "agent-setup",78+ agentSetupMarkdown({ commands, platformUrl, webUrl })79+ ).pipe(Effect.provide(NodeServices.layer))80+ );81+82+ it("lists every channel in order, each saying when to use it", () => {83+ expect(channels.map(({ title }) => title)).toStrictEqual([84+ "Remote MCP",85+ "MCP over stdio",86+ "The CLI",87+ "Text for any agent",88+ "Skills",89+ ]);90+91+ for (const each of channels) {92+ expect(each.useWhen).not.toBe("");93+ expect(each.snippets.length).toBeGreaterThan(0);94+ }95+ });96+97+ it("adds the platform's MCP endpoint to Claude Code under the brand's slug", () => {98+ expect(snippet("Remote MCP", "Claude Code").text).toBe(99+ `claude mcp add --transport http ${Brand.slug} ${platformUrl}/mcp`100+ );101+ });102+103+ it.effect(104+ "gives VS Code the server the Claude Code plugin's .mcp.json carries",105+ () =>106+ Effect.gen(function* () {107+ const plugin = yield* pluginMcpJson;108+ const vscode = snippet("Remote MCP", "VS Code");109+110+ expect(vscode.language).toBe("json");111+ expect(parsed(vscode.text)).toStrictEqual({112+ servers: parsed(plugin.content).mcpServers,113+ });114+ expect(parsed(vscode.text)).toStrictEqual({115+ servers: {116+ [Brand.slug]: { type: "http", url: `${platformUrl}/mcp` },117+ },118+ });119+ })120+ );121+122+ it("gives Cursor its mcpServers entry with the endpoint's url", () => {123+ const cursor = snippet("Remote MCP", "Cursor");124+125+ expect(cursor.language).toBe("json");126+ expect(parsed(cursor.text)).toStrictEqual({127+ mcpServers: { [Brand.slug]: { url: `${platformUrl}/mcp` } },128+ });129+ });130+131+ it("serves MCP over stdio through the CLI only when the CLI has mcp", () => {132+ expect(snippet("MCP over stdio", "").text).toBe(`${Brand.cli} mcp`);133+134+ const without = agentSetup({135+ commands: commands.filter(({ path }) => path.join(" ") !== "mcp"),136+ platformUrl,137+ webUrl,138+ });139+140+ expect(without.map(({ title }) => title)).not.toContain("MCP over stdio");141+ });142+143+ it("installs the CLI from the web and signs in to the platform", () => {144+ expect(145+ channel(channels, "The CLI").snippets.map(({ text }) => text)146+ ).toStrictEqual([147+ `curl -fsSL ${webUrl}/install.sh | sh`,148+ `${Brand.cli} login --url ${platformUrl}`,149+ ]);150+ });151+152+ it("points any agent at llms.txt and each ask's Markdown", () => {153+ const { text } = snippet("Text for any agent", "");154+155+ expect(text).toContain(`${webUrl}/llms.txt`);156+ expect(text).toContain(`${webUrl}/<project>/asks/<ask>.md`);157+ });158+159+ it("adds the skills from the web's index", () => {160+ expect(snippet("Skills", "").text).toBe(`npx skills add ${webUrl}`);161+ expect(channel(channels, "Skills").useWhen).toContain(162+ `${webUrl}/.well-known/agent-skills/index.json`163+ );164+ });165+166+ it("writes every snippet into the Markdown whole", () => {167+ const text = agentSetupMarkdown({ commands, platformUrl, webUrl });168+169+ for (const each of channels) {170+ expect(text).toContain(`## ${each.title}`);171+172+ for (const { text: body } of each.snippets) {173+ expect(text).toContain(body);174+ }175+ }176+ });177+});modified:packages/protocol/src/ids.ts+6 added-4 removed
227 unmodified lines228 export type RepoPath = typeof RepoPath.Type;229 230 /**231 * Words a project may not be named: the web serves its own pages and files232- * at these first path segments (`/today`, `/people/<handle>`, `/auth/…`,233- * `/rpc`, `/releases/…`, `/icons/…` and the client build's `/assets/…`), so a234- * project so named would be unreachable at `<web>/<project>`. A name with a235- * dot (`llms.txt`, `install.sh`, `.well-known`) is no project's name anyway.232+ * at these first path segments (`/agents`, `/today`, `/people/<handle>`,233+ * `/auth/…`, `/rpc`, `/releases/…`, `/icons/…` and the client build's234+ * `/assets/…`), so a project so named would be unreachable at235+ * `<web>/<project>`. A name with a dot (`llms.txt`, `agents.md`,236+ * `install.sh`, `.well-known`) is no project's name anyway.237 * `apps/web/test/routes.test.ts` holds this list to the web's routes.238 */239 export const reservedProjectNames = [240+ "agents",241 "assets",242 "auth",243 "icons",244 "people",49 unmodified linesmodified:packages/protocol/test/domain.test.ts+10 added-1 removed
300 unmodified lines301 302 // The web serves its own pages and files at these first path segments, so303 // a project so named would be unreachable at `<web>/<project>`.304 // An ask may still take them: an ask's page is under its project.305- it.each(["assets", "auth", "icons", "people", "releases", "rpc", "today"])(305+ it.each([306+ "agents",307+ "assets",308+ "auth",309+ "icons",310+ "people",311+ "releases",312+ "rpc",313+ "today",314+ ])(315 "a project may not be named %j, a path the web takes for itself",316 (name) => {317 expect(refuses(ProjectName, name)).toBeTruthy();318 expect(refuses(AskId, name)).toBeFalsy();60 unmodified lines