Merge branch 'build/906-platform-root-page'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
# Conflicts: # apps/platform/test/w9-contracts.test.ts
authored by oscabriel · committed by oscabriel · parents 958650a, cdd07dd · Browse files · 10 files·+1050 added−333 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
10 files+1050 added−333 removed
- tests:+470 added−12 removed
- other:+580 added−321 removed
Provenance
- Commit
10c8b54- Tree
9763343- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent 1
958650a- Parent 2
cdd07dd
10 files changed+1050 added−333 removed
modified:apps/platform/src/auth/pages.ts+2 added-1 removed
54 unmodified lines5556575859596061626364130 unmodified linesExpand all54 unmodified lines.warn{background:#fff4d6;padding:.5rem .75rem}@media (prefers-color-scheme:dark){body{background:#1c1b19;color:#f6f5f2}.warn{background:#4a3b12}.error{color:#ff9b9b}}`;
/** A page titled `title` around `body`, which is HTML already escaped. */const page = (title: string, body: string) =>export const page = (title: string, body: string) => `<!doctype html><html lang="en"><head><meta charset="utf-8">130 unmodified linesExpand allmodified:apps/platform/src/home.ts+196 added-14 removed
1 /**2- * The platform's `/`: a page saying what this host serves (clone URLs, MCP,3- * agent skills, sign-in, the CLI and its releases, the web app), in HTML4- * for a browser and in Markdown for an agent. A stub until 906 lands: it5- * answers 501, naming what it read.2+ * The platform's `/`: a page saying what this host serves (clone URLs,3+ * MCP, agent skills, RPC, sign-in, the CLI and its releases, drafting, the4+ * web app), in HTML for a browser and in Markdown for an agent that asks5+ * for `text/markdown` or `text/plain`. The Markdown is the web's6+ * `/llms.txt` (`@repo/agent-kit/host-doc`), so both hosts say the same.7+ *8+ * Every URL is built from the request's origin, the one the client reached:9+ * the platform is also the git remote, the MCP base and the CLI's URL, so10+ * the page names them as the reader will type them. The projects are the11+ * front page's, and nothing else: no layer and no fork is listed. Every12+ * value that reaches the HTML is escaped. Not a redirect: the web app is a13+ * link (W9-D11).14 */7-import type { FrontPage } from "@repo/project/front-page";8-import { Effect } from "effect";15+import { commandDocs } from "@repo/agent-kit/command-doc";16+import { frontLlms, MCP_PROTOCOL } from "@repo/agent-kit/host-doc";17+import { Brand } from "@repo/brand";18+import { FrontPage } from "@repo/project/front-page";19+import { Contracts } from "@repo/protocol/contracts";20+import type { ProjectListing } from "@repo/protocol/domain/front-page";21+import { Effect, Option } from "effect";22 23+import { escapeHtml, page } from "./auth/pages.ts";24 import { HostInfo } from "./host-info.ts";25 26+/** A minute: the page changes only when a project is made. */27+const BRIEFLY = "public, max-age=60";28+29+/** The CLI's commands, as the platform's skill and the web's `llms.txt` list them. */30+const commands = commandDocs(Contracts);31+32+/** The media ranges of an `Accept` header, each its type and its quality. */33+const rangesOf = (accept: string) =>34+ accept.split(",").map((range) => {35+ const [type = "", ...params] = range.split(";").map((part) => part.trim());36+37+ const quality = Option.getOrElse(38+ Option.flatMap(39+ Option.fromUndefinedOr(40+ params.find((param) => param.toLowerCase().startsWith("q="))41+ ),42+ (param) => Option.liftPredicate(Number(param.slice(2)), Number.isFinite)43+ ),44+ () => 145+ );46+47+ return { quality, type: type.toLowerCase() };48+ });49+50+/** The highest quality `ranges` give any of `types` by name; 0 for none. */51+const qualityOf = (52+ ranges: ReturnType<typeof rangesOf>,53+ types: readonly string[]54+) =>55+ Math.max(56+ 0,57+ ...ranges.filter(({ type }) => types.includes(type)).map((r) => r.quality)58+ );59+60+/**61+ * Whether the request asks for Markdown: it names `text/markdown` or62+ * `text/plain` itself, at least as high as it names `text/html`. A63+ * wildcard alone (`*\/*`, or no `Accept`) gets the page, as a browser does.64+ */65+const wantsMarkdown = (request: Request) => {66+ const ranges = rangesOf(request.headers.get("accept") ?? "");67+ const markdown = qualityOf(ranges, ["text/markdown", "text/plain"]);68+69+ return markdown > 0 && markdown >= qualityOf(ranges, ["text/html"]);70+};71+72+const code = (text: string) => `<code>${escapeHtml(text)}</code>`;73+74+const pre = (text: string) => `<pre><code>${escapeHtml(text)}</code></pre>`;75+76+const link = (url: string, text = url) =>77+ `<a href="${escapeHtml(url)}">${escapeHtml(text)}</a>`;78+79+const item = (html: string) => `<li>${html}</li>`;80+81+const section = (title: string, ...html: readonly string[]) =>82+ `<section>\n<h2>${escapeHtml(title)}</h2>\n${html.join("\n")}\n</section>`;83+84+const list = (items: readonly string[]) =>85+ `<ul>\n${items.map(item).join("\n")}\n</ul>`;86+87+/** Wider than sign-in's column, for clone and install lines. */88+const STYLE = `<style>89+main{max-width:44rem}90+h2{font-size:1.1rem;margin:2rem 0 .5rem}91+pre{overflow-x:auto;padding:.5rem .75rem;background:rgba(127,127,127,.12)}92+code{font-family:ui-monospace,monospace;font-size:.9em}93+li{margin:.25rem 0}94+</style>`;95+96+const projectsSection = (origin: string, projects: readonly ProjectListing[]) =>97+ section(98+ "Projects",99+ projects.length === 0100+ ? "<p>No project is on the platform yet.</p>"101+ : list(102+ projects.map(103+ ({ openAsks, project }) =>104+ `<strong>${escapeHtml(project)}</strong>, ${openAsks} open ask${openAsks === 1 ? "" : "s"}${pre(`git clone ${origin}/${project}.git`)}`105+ )106+ )107+ );108+109+/** The page for a browser. */110+const homeHtml = (input: {111+ readonly origin: string;112+ readonly projects: readonly ProjectListing[];113+ readonly webUrl: Option.Option<string>;114+ readonly draftModel: string;115+}) => {116+ const { draftModel, origin, projects, webUrl } = input;117+118+ return page(119+ "What this host serves",120+ [121+ STYLE,122+ `<h1>${escapeHtml(Brand.name)}</h1>`,123+ `<p>A Git platform where everything a project ships is public. A project states each change it wants as an ask; you answer one with a commit, and the platform lands it only once its checks pass.</p>`,124+ ...Option.toArray(125+ Option.map(126+ webUrl,127+ (web) => `<p><strong>${link(web, "Open the web app")}</strong></p>`128+ )129+ ),130+ projectsSection(origin, projects),131+ section(132+ "CLI",133+ pre(`curl -fsSL ${origin}/install.sh | sh`),134+ `<p>Releases: ${link(`${origin}/releases/manifest.json`)}</p>`,135+ `<p>Then sign in: ${code(`${Brand.cli} login --url ${origin}`)}</p>`136+ ),137+ section(138+ "Agents",139+ list([140+ `MCP: ${code(`${origin}/mcp`)}, streamable HTTP, protocol ${code(MCP_PROTOCOL)}, signed in`,141+ `Agent skills: ${link(`${origin}/.well-known/agent-skills/index.json`)}`,142+ `RPC: ${code(`POST ${origin}/rpc`)}`,143+ `OAuth: ${link(`${origin}/.well-known/oauth-protected-resource`)} and ${link(`${origin}/.well-known/oauth-authorization-server`)}`,144+ `The same facts as Markdown: ask for ${code("text/markdown")}, as in ${code(`curl -H 'accept: text/markdown' ${origin}/`)}`,145+ ])146+ ),147+ section(148+ "Sign in",149+ list([150+ `Sign up: ${link(`${origin}/signup`)}`,151+ `Authorize a client: ${code(`${origin}/authorize`)}`,152+ ])153+ ),154+ section(155+ "Drafting",156+ `<p>A member can ask the platform's agent to draft a proposed ask (Workers AI, ${code(draftModel)}); a decider accepts it, and only people are credited.</p>`157+ ),158+ section("Health", `<p>${link(`${origin}/health`)}</p>`),159+ ].join("\n")160+ );161+};162+163+/** `/` for `request`: Markdown for an agent that asks for it, else the page. */164 export const homeResponse = (13- _request: Request165+ request: Request166 ): Effect.Effect<Response, never, FrontPage | HostInfo> =>15- Effect.map(16- Effect.service(HostInfo),17- ({ draftModel }) =>18- new Response(`not built: 906 (draft model ${draftModel})`, {19- status: 501,20- })21- );167+ Effect.gen(function* () {168+ const { draftModel, webUrl } = yield* HostInfo;169+ const projects = yield* FrontPage.use((frontPage) => frontPage.projects());170+ const { origin } = new URL(request.url);171+172+ if (wantsMarkdown(request)) {173+ return new Response(174+ frontLlms({175+ commands,176+ platformUrl: origin,177+ projects,178+ ...Option.match(webUrl, {179+ onNone: () => ({}),180+ onSome: (web) => ({ webUrl: web }),181+ }),182+ }),183+ {184+ headers: {185+ "cache-control": BRIEFLY,186+ "content-type": "text/markdown; charset=utf-8",187+ vary: "accept",188+ },189+ }190+ );191+ }192+193+ return new Response(homeHtml({ draftModel, origin, projects, webUrl }), {194+ headers: {195+ "cache-control": BRIEFLY,196+ "content-security-policy":197+ "default-src 'none'; style-src 'unsafe-inline'; frame-ancestors 'none'",198+ "content-type": "text/html; charset=utf-8",199+ "referrer-policy": "no-referrer",200+ vary: "accept",201+ },202+ });203+ });added:apps/platform/test/home.test.ts+231 added
1+/**2+ * The platform's `/`: what this host serves, built from the request's3+ * origin, the projects the front page lists and the host's own facts. A4+ * browser gets HTML; an agent asking for Markdown or plain text gets the5+ * text the web serves at `/llms.txt`. Open to a stale credential, as every6+ * public path is.7+ */8+import { describe, expect, it } from "@effect/vitest";9+import { commandDocs } from "@repo/agent-kit/command-doc";10+import { frontLlms } from "@repo/agent-kit/host-doc";11+import { Brand } from "@repo/brand";12+import { FrontPageMemory } from "@repo/project/front-page/memory";13+import { Contracts } from "@repo/protocol/contracts";14+import type { ProjectListing } from "@repo/protocol/domain/front-page";15+import { ProjectName } from "@repo/protocol/ids";16+import { Effect, Layer, Option } from "effect";17+18+import { MemorySessions } from "../src/sessions/memory.ts";19+import { HostInfo } from "../src/surfaces.ts";20+import { noProjects, origin, served } from "./harness.ts";21+22+const webUrl = "https://web-test.example.workers.dev";23+24+const projects: readonly ProjectListing[] = [25+ { openAsks: 3, posture: "open", project: ProjectName.make("datekit") },26+ {27+ openAsks: 1,28+ posture: "openWithSealedEvidence",29+ project: ProjectName.make("burrow"),30+ },31+];32+33+/** The platform listing `listed`, on a host whose web app is `web`. */34+const platform = (35+ listed: readonly ProjectListing[],36+ web: Option.Option<string> = Option.some(webUrl)37+) =>38+ served(39+ Layer.mergeAll(40+ noProjects,41+ MemorySessions.layer({}),42+ FrontPageMemory.layer({ credits: [], entries: [], projects: listed }),43+ Layer.succeed(44+ HostInfo,45+ HostInfo.of({ draftModel: "@cf/test/drafter", webUrl: web })46+ )47+ )48+ );49+50+/** `/` as `headers` ask for it: its status, type and text. */51+const home = (52+ listed: readonly ProjectListing[],53+ init: RequestInit = {},54+ web?: Option.Option<string>55+) =>56+ Effect.gen(function* () {57+ const { fetch } = yield* platform(listed, web);58+ const response = yield* fetch(new Request(`${origin}/`, init));59+60+ return {61+ status: response.status,62+ text: yield* Effect.promise(() => response.text()),63+ type: response.headers.get("content-type"),64+ };65+ });66+67+const html = { headers: { accept: "text/html,application/xhtml+xml" } };68+69+describe("the platform's /", () => {70+ it.effect("tells a browser what this host serves, from its origin", () =>71+ Effect.gen(function* () {72+ const { status, text, type } = yield* home(projects, html);73+74+ expect(status).toBe(200);75+ expect(type).toBe("text/html; charset=utf-8");76+ expect(text).toContain(`<h1>${Brand.name}</h1>`);77+78+ for (const named of [79+ `git clone ${origin}/datekit.git`,80+ `git clone ${origin}/burrow.git`,81+ `curl -fsSL ${origin}/install.sh | sh`,82+ `${origin}/releases/manifest.json`,83+ `${origin}/mcp`,84+ "2026-07-28",85+ `POST ${origin}/rpc`,86+ `${origin}/.well-known/agent-skills/index.json`,87+ `${origin}/.well-known/oauth-protected-resource`,88+ `${origin}/.well-known/oauth-authorization-server`,89+ `${origin}/signup`,90+ `${origin}/authorize`,91+ "@cf/test/drafter",92+ `${origin}/health`,93+ `<a href="${webUrl}">Open the web app</a>`,94+ ]) {95+ expect(text).toContain(named);96+ }97+ })98+ );99+100+ it.effect("links no web app on a host that has none", () =>101+ Effect.gen(function* () {102+ const { status, text } = yield* home(projects, html, Option.none());103+104+ expect(status).toBe(200);105+ expect(text).not.toContain("Open the web app");106+ expect(text).not.toContain(webUrl);107+ })108+ );109+110+ it.effect("says so when no project is listed yet", () =>111+ Effect.gen(function* () {112+ const { text } = yield* home([], html);113+114+ expect(text).toContain("No project is on the platform yet.");115+ expect(text).not.toContain("git clone");116+ })117+ );118+119+ it.effect("escapes whatever a listing names", () =>120+ Effect.gen(function* () {121+ const crafted = ProjectName.make(`<script>alert("x")</script>`, {122+ disableChecks: true,123+ });124+125+ const { text } = yield* home(126+ [{ openAsks: 0, posture: "open", project: crafted }],127+ html128+ );129+130+ expect(text).not.toContain("<script>");131+ expect(text).toContain(132+ "<script>alert("x")</script>"133+ );134+ })135+ );136+137+ it.effect("gives an agent the web's /llms.txt as Markdown", () =>138+ Effect.gen(function* () {139+ const expected = frontLlms({140+ commands: commandDocs(Contracts),141+ platformUrl: origin,142+ projects,143+ webUrl,144+ });145+146+ const markdown = yield* home(projects, {147+ headers: { accept: "text/markdown" },148+ });149+150+ const plain = yield* home(projects, {151+ headers: { accept: "text/plain" },152+ });153+154+ expect(markdown).toStrictEqual({155+ status: 200,156+ text: expected,157+ type: "text/markdown; charset=utf-8",158+ });159+ expect(plain.text).toBe(expected);160+ })161+ );162+163+ it.effect(164+ "gives an agent the platform's own Markdown on a host with no web app",165+ () =>166+ Effect.gen(function* () {167+ const { text, type } = yield* home(168+ projects,169+ { headers: { accept: "text/markdown" } },170+ Option.none()171+ );172+173+ expect({ text, type }).toStrictEqual({174+ text: frontLlms({175+ commands: commandDocs(Contracts),176+ platformUrl: origin,177+ projects,178+ }),179+ type: "text/markdown; charset=utf-8",180+ });181+ })182+ );183+184+ it.effect.each([185+ { accept: undefined, wants: "html" },186+ { accept: "*/*", wants: "html" },187+ {188+ accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",189+ wants: "html",190+ },191+ { accept: "text/html, text/markdown;q=0.5", wants: "html" },192+ { accept: "text/html;q=0.5, text/markdown", wants: "markdown" },193+ { accept: "text/plain, text/html", wants: "markdown" },194+ { accept: "text/markdown;q=0, text/html;q=0.1", wants: "html" },195+ ])("answers Accept $accept with $wants", ({ accept, wants }) =>196+ Effect.gen(function* () {197+ const { type } = yield* home(198+ projects,199+ accept === undefined ? {} : { headers: { accept } }200+ );201+202+ expect(type).toBe(203+ wants === "html"204+ ? "text/html; charset=utf-8"205+ : "text/markdown; charset=utf-8"206+ );207+ })208+ );209+210+ it.effect("answers a stale credential, as every public path does", () =>211+ Effect.gen(function* () {212+ const { status, text } = yield* home(projects, {213+ headers: { ...html.headers, authorization: "Bearer nope" },214+ });215+216+ expect(status).toBe(200);217+ expect(text).toContain(`git clone ${origin}/datekit.git`);218+ })219+ );220+221+ it.effect("answers HEAD with no body", () =>222+ Effect.gen(function* () {223+ const { status, text } = yield* home(projects, {224+ ...html,225+ method: "HEAD",226+ });227+228+ expect({ status, text }).toStrictEqual({ status: 200, text: "" });229+ })230+ );231+});modified:apps/platform/test/w9-contracts.test.ts+4 added-10 removed
118 unmodified lines119 120 const raw = `/${project}/raw/${"4".repeat(40)}/README.md`;121 122 expect({123- home: yield* read("/"),124- homeStale: yield* read("/", stale),123+ home: (yield* read("/")).status,124+ homeStale: (yield* read("/", stale)).status,125 raw: yield* read(raw),126 rawStale: yield* read(raw, stale),127 }).toStrictEqual({128- home: {129- status: 501,130- text: "not built: 906 (draft model test-model)",131- },132- homeStale: {133- status: 501,134- text: "not built: 906 (draft model test-model)",135- },128+ home: 200,129+ homeStale: 200,130 raw: { status: 404, text: "" },131 rawStale: { status: 404, text: "" },132 });133 })15 unmodified linesmodified:apps/web/src/features/agents/llms.ts+12 added-304 removed
1 /**2- * What an agent, or a person, reads first on the web host, as3- * plain Markdown in the `llms.txt` shape (a title, a one-line summary, then4- * sections of links): `/llms.txt` says what the platform is, how to install5- * the CLI, how to connect over MCP, how to find and take an ask, every6- * command, and which projects exist; `/<project>/llms.txt` says the same7- * for one project, with its open asks. `mcpCard` is8- * `/.well-known/mcp.json`.9- *10- * Pure: the routes hand in what the platform lists and the CLI's commands11- * as `@repo/agent-kit`'s one list holds them, so no command is written here12- * by hand. A step names a command only when the catalog has it. Every13- * name comes from `Brand`.2+ * What an agent, or a person, reads first on the web host: `/llms.txt`,3+ * `/<project>/llms.txt` and the MCP card at `/.well-known/mcp.json`. The4+ * text lives in `@repo/agent-kit/host-doc`, which the platform's own `/`5+ * serves too, so both hosts say the same thing; the routes import it from6+ * here.7 */15-import type { CommandDoc } from "@repo/agent-kit/command-doc";16-import { Brand } from "@repo/brand";17-import type { AskListing } from "@repo/protocol/domain/ask";18-import type { ProjectListing } from "@repo/protocol/domain/front-page";19-import type { ProjectName } from "@repo/protocol/ids";20-import type { Posture } from "@repo/protocol/posture";21-import { Array as Arr, Option } from "effect";8+export {9+ frontLlms,10+ mcpCard,11+ missingProjectLlms,12+ projectLlms,13+} from "@repo/agent-kit/host-doc";14 23-type Command = CommandDoc;24-25-type Commands = readonly CommandDoc[];26-27-/** The MCP protocol the platform serves over HTTP. */28-const MCP_PROTOCOL = "2026-07-28";29-30-/** Each posture as GLOSSARY.md names it. */31-const postureWords = {32- open: "Open",33- openCore: "Open core",34- openOnSchedule: "Open on schedule",35- openWithSealedEvidence: "Open with sealed evidence",36- sourceAvailable: "Source available",37-} as const satisfies Record<Posture, string>;38-39-const code = (text: string) => `\`${text}\``;40-41-const counted = (count: number, one: string) =>42- `${count} ${one}${count === 1 ? "" : "s"}`;43-44-/** The lines as one document, ending in a newline. */45-const page = (lines: readonly string[]) => `${lines.join("\n")}\n`;46-47-/** What a placeholder stands for in a command line, if the page knows it. */48-interface Known {49- readonly project?: string;50-}51-52-/** The command whose words are `words`, if the catalog has it. */53-const commandOf = (commands: Commands, words: string) =>54- Arr.findFirst(commands, ({ path }) => path.join(" ") === words);55-56-/**57- * A command as typed: the CLI's name, its words, its arguments, then58- * `flags` it takes, each with a value the page knows or a placeholder.59- */60-const usage = (61- command: Command,62- known: Known = {},63- flags: readonly ("ask" | "project")[] = []64-) => {65- const valueOf = (name: string) =>66- name === "project" && known.project !== undefined67- ? known.project68- : `<${name}>`;69-70- return [71- Brand.cli,72- ...command.path,73- ...command.positional.map((name) => `<${name}>`),74- ...flags.flatMap((flag) =>75- command.flags.includes(`--${flag}`) && !command.positional.includes(flag)76- ? [`--${flag}`, valueOf(flag)]77- : []78- ),79- ].join(" ");80-};81-82-/** `words` as typed, with `flags`, when the catalog has the command. */83-const typed = (84- commands: Commands,85- words: string,86- known: Known,87- flags: readonly ("ask" | "project")[] = []88-) =>89- Option.map(commandOf(commands, words), (command) =>90- code(usage(command, known, flags))91- );92-93-/** The sentence `make` writes around a typed command, or nothing without it. */94-const withCommand = (95- command: Option.Option<string>,96- make: (typedCommand: string) => string97-) => Option.toArray(Option.map(command, make));98-99-/**100- * How to take an ask, each step with the commands the catalog has: find,101- * read, claim, change and check, push and read the verdict. Numbered in102- * order, whatever steps the catalog leaves out.103- */104-const takeAnAsk = (commands: Commands, known: Known) => {105- const front = typed(commands, "front", known);106- const asks = typed(commands, "asks", known, ["project"]);107-108- const find = [109- ...Option.toArray(110- Option.map(front, (each) => `${each} lists the open asks across projects`)111- ),112- ...Option.toArray(113- Option.map(asks, (each) => `${each} lists one project's`)114- ),115- ];116-117- const steps = [118- ...(find.length === 0 ? [] : [`Find one: ${find.join("; ")}.`]),119- ...withCommand(120- typed(commands, "ask", known, ["project"]),121- (each) => `Read it: ${each}.`122- ),123- ...withCommand(124- typed(commands, "claim", known, ["project"]),125- (each) =>126- `Claim it: ${each}. The claim prints your fork's remote; add it with ${code(`git remote add ${Brand.slug} <remote>`)}.`127- ),128- ...withCommand(129- typed(commands, "check", known),130- (each) =>131- `Change only the ask's territory, then run ${each} and fix everything it reports.`132- ),133- `Push to your fork with ${code(`git push ${Brand.slug} HEAD:main`)}${Option.match(134- typed(commands, "verdict", known, ["ask", "project"]),135- { onNone: () => "", onSome: (each) => `, then read the verdict: ${each}` }136- )}. A refusal names the command to run next.`,137- ];138-139- return [140- "## Take an ask",141- "",142- ...steps.map((step, at) => `${at + 1}. ${step}`),143- "",144- ];145-};146-147-/** What a command row adds to its description. */148-const notes = ({ needsApproval, readOnly }: Command) => [149- ...(readOnly ? ["Only reads."] : []),150- ...(needsApproval ? [`Runs only with ${code("--yes")}.`] : []),151-];152-153-/** Every command, one line each, in the catalog's order. */154-const commandList = (commands: Commands) => [155- "## Commands",156- "",157- ...commands.map(158- (command) =>159- `- ${code(usage(command))}: ${[command.summary, ...notes(command)].join(" ")}`160- ),161- "",162-];163-164-/** Where a project's page is on the web host. */165-const projectPage = (webUrl: string, project: string) => `${webUrl}/${project}`;166-167-const projectLine = (webUrl: string, listing: ProjectListing) =>168- `- [${listing.project}](${projectPage(webUrl, listing.project)}/llms.txt): ${postureWords[listing.posture]}, ${counted(listing.openAsks, "open ask")}.`;169-170-/** `/llms.txt`: the platform, the CLI, MCP, taking an ask, the commands and the projects. */171-export const frontLlms = (input: {172- readonly projects: readonly ProjectListing[];173- readonly commands: Commands;174- readonly platformUrl: string;175- readonly webUrl: string;176-}) => {177- const { commands, platformUrl, projects, webUrl } = input;178-179- return page([180- `# ${Brand.name}`,181- "",182- `> ${Brand.name} is a Git platform where everything a project ships is public. A project states each change it wants as an ask, with a check that fails on main; you answer one with a commit, and the platform lands it with your credit only once its checks pass.`,183- "",184- `The same facts read as Markdown: each project at ${webUrl}/<project>/llms.txt, and each ask at ${webUrl}/<project>/asks/<ask>.md.`,185- "",186- "## Install the CLI",187- "",188- "```sh",189- `curl -fsSL ${webUrl}/install.sh | sh`,190- "```",191- "",192- ...Option.match(commandOf(commands, "login"), {193- onNone: () => [],194- onSome: () => [195- "Then sign in once; git pushes to the platform with your token from then on:",196- "",197- "```sh",198- `${Brand.cli} login --url ${platformUrl}`,199- "```",200- "",201- ],202- }),203- "## Connect over MCP",204- "",205- `- Endpoint: ${platformUrl}/mcp (streamable HTTP, MCP ${MCP_PROTOCOL}), described at ${webUrl}/.well-known/mcp.json.`,206- `- Auth: a bearer token from the platform's own OAuth server, which an MCP client finds at ${platformUrl}/.well-known/oauth-protected-resource; you sign in with your account on ${Brand.name}.`,207- ...withCommand(208- typed(commands, "mcp", {}),209- (each) =>210- `- Without a client that signs in: ${each} serves the same tools over stdio, with the token ${code(`${Brand.cli} login`)} stored.`211- ),212- `- Skills: ${webUrl}/.well-known/agent-skills/index.json lists each project's contribute skill, with its digest.`,213- "",214- ...takeAnAsk(commands, {}),215- ...commandList(commands),216- "## Projects",217- "",218- ...(projects.length === 0219- ? ["No project is on the platform yet."]220- : projects.map((listing) => projectLine(webUrl, listing))),221- ]);222-};223-224-/** What an ask's line adds after its want: its kind and territory, then whether it can be taken. */225-const askNotes = (listing: AskListing) => [226- `Kind ${code(listing.kind)}, territory ${code(listing.territory)}.`,227- ...(listing.claimed ? ["Claimed."] : []),228- ...(listing.reserve === undefined ? [] : [`Held for ${listing.reserve}.`]),229- ...(listing.blockedBy.length === 0230- ? []231- : [`Waits for ${listing.blockedBy.map(code).join(", ")}.`]),232-];233-234-/** An ask's want as a sentence of its own, however it was punctuated. */235-const sentence = (text: string) => `${text.replace(/[.\s]+$/u, "")}.`;236-237-const askLine = (webUrl: string, project: string, listing: AskListing) =>238- `- [${listing.ask}](${projectPage(webUrl, project)}/asks/${listing.ask}.md): ${[sentence(listing.want), ...askNotes(listing)].join(" ")}`;239-240-/** `/<project>/llms.txt`: the project, its posture, how to clone it, its open asks and how to take one. */241-export const projectLlms = (input: {242- readonly listing: ProjectListing;243- readonly asks: readonly AskListing[];244- readonly commands: Commands;245- readonly platformUrl: string;246- readonly webUrl: string;247-}) => {248- const { asks, commands, listing, platformUrl, webUrl } = input;249- const { project } = listing;250-251- return page([252- `# ${project}`,253- "",254- `> A project on ${Brand.name}. Posture: ${postureWords[listing.posture]}. ${counted(asks.length, "open ask")}.`,255- "",256- `- Page: ${projectPage(webUrl, project)}`,257- `- Clone: ${code(`git clone ${platformUrl}/${project}.git`)}`,258- `- Everything else, and every command: ${webUrl}/llms.txt`,259- "",260- "## Open asks",261- "",262- ...(asks.length === 0263- ? ["No ask is open."]264- : asks.map((each) => askLine(webUrl, project, each))),265- "",266- ...takeAnAsk(commands, { project }).slice(0, -1),267- ]);268-};269-270-/**271- * `/<project>/llms.txt` for a project the platform does not list. A name272- * that could not be a project's is not repeated back.273- */274-export const missingProjectLlms = (input: {275- readonly project: Option.Option<ProjectName>;276- readonly webUrl: string;277-}) =>278- page([279- "# Not found",280- "",281- `${Option.match(input.project, {282- onNone: () => "No such project",283- onSome: (project) => `No project named ${code(project)}`,284- })} is on ${Brand.name}. Every project is listed at ${input.webUrl}/llms.txt.`,285- ]);286-287-/**288- * `/.well-known/mcp.json`: the platform's MCP endpoint, its transport and289- * protocol, and where a client learns to sign in. No settled standard says290- * this card's shape; it follows the MCP server card draft, and names its291- * authorization the way the platform's 401 does (RFC 9728's292- * `resource_metadata`).293- */294-export const mcpCard = (input: { readonly platformUrl: string }) => ({295- authentication: {296- required: true,297- resource_metadata: `${input.platformUrl}/.well-known/oauth-protected-resource`,298- schemes: ["bearer"],299- },300- capabilities: { prompts: {}, resources: {}, tools: {} },301- description: `The contracts of ${Brand.name} as MCP tools, each ask's brief as a resource, and the contribute skill as a prompt.`,302- name: Brand.name,303- protocolVersion: MCP_PROTOCOL,304- transport: { endpoint: `${input.platformUrl}/mcp`, type: "streamable-http" },305-});306-307-export type McpCard = ReturnType<typeof mcpCard>;15+export type { McpCard } from "@repo/agent-kit/host-doc";modified:infra/smoke.ts+24 added-2 removed
10 unmodified lines11 * 4. `anonymous-unknown-project`: an anonymous `/rpc` `listAsks` for a project12 * that doesn't exist answers 200 with a typed `UnknownProject` refusal;13 * 5. `missing-repo-404`: git's `info/refs` for a repo that doesn't exist14 * answers 404;15+ * 6. `platform-root`: the platform's `GET /` answers 200 with a page that16+ * names its MCP endpoint (`/mcp`) and the CLI's `install.sh`;15- * 6. `web-front-page`: the web's `GET /` answers 200 with HTML;16- * 7. `web-llms-txt`: the web's `GET /llms.txt` answers 200 with Markdown,17+ * 7. `web-front-page`: the web's `GET /` answers 200 with HTML;18+ * 8. `web-llms-txt`: the web's `GET /llms.txt` answers 200 with Markdown,19 * which it builds from the platform's project list, so only a web that20 * reaches the platform through its service binding passes.21 *22 * The web's two run when smoke knows where the web lives: bootstrap's34 unmodified lines57 "oauth-metadata",58 "mcp-needs-credential",59 "anonymous-unknown-project",60 "missing-repo-404",61+ "platform-root",62 ] as const;63 64 /** The web's probes, run after the platform's when smoke has the web's origin. */65 export const webProbes = ["web-front-page", "web-llms-txt"] as const;282 unmodified lines348 HttpClientRequest.get(`${origin}${route}?service=git-upload-pack`)349 ).pipe(Effect.flatMap(statusIs(label, 404)), Effect.asVoid);350 };351 352+/** The platform's own `/`: a page naming its MCP endpoint and the CLI's installer. */353+const platformRoot = (origin: string) => {354+ const label = "GET /";355+356+ return send(label, HttpClientRequest.get(`${origin}/`)).pipe(357+ Effect.flatMap(statusIs(label, 200)),358+ Effect.flatMap(({ text }) =>359+ text.includes("/mcp") && text.includes("install.sh")360+ ? Effect.void361+ : Effect.fail(362+ new Missed({363+ reason: `${label} answered 200 without naming /mcp and install.sh`,364+ })365+ )366+ )367+ );368+};369+370 /** `answer`, when its content type is `wanted` (by its media type alone). */371 const typeIs =372 (label: string, wanted: string, said: string) => (answer: Answer) =>373 answer.contentType.split(";")[0]?.trim() === wanted90 unmodified lines464 ["oauth-metadata", oauthMetadata(origin)],465 ["mcp-needs-credential", mcpNeedsCredential(origin)],466 ["anonymous-unknown-project", anonymousUnknownProject(origin)],467 ["missing-repo-404", missingRepo(origin)],468+ ["platform-root", platformRoot(origin)],469 ...(options.web === undefined470 ? []471 : ([472 ["web-front-page", webFrontPage(options.web)],113 unmodified linesadded:packages/agent-kit/src/host-doc.ts+346 added
1+/**2+ * What an agent, or a person, reads first about a host, as plain Markdown3+ * in the `llms.txt` shape (a title, a one-line summary, then sections of4+ * links). `frontLlms` says what the platform is, how to install the CLI,5+ * how to connect over MCP, how to find and take an ask, every command, and6+ * which projects exist: the web serves it at `/llms.txt`, and the platform7+ * at `/` for an agent, with no web app's pages named when it knows of none.8+ * `projectLlms` is the web's `/<project>/llms.txt`, with the project's open9+ * asks, and `mcpCard` its `/.well-known/mcp.json`.10+ *11+ * Pure: the hosts hand in what the platform lists and the CLI's commands12+ * as this package's one list holds them, so no command is written here13+ * by hand. A step names a command only when the catalog has it. Every14+ * name comes from `Brand`.15+ */16+import { Brand } from "@repo/brand";17+import type { AskListing } from "@repo/protocol/domain/ask";18+import type { ProjectListing } from "@repo/protocol/domain/front-page";19+import type { ProjectName } from "@repo/protocol/ids";20+import type { Posture } from "@repo/protocol/posture";21+import { Array as Arr, Option } from "effect";22+23+import type { CommandDoc } from "./command-doc.ts";24+25+type Command = CommandDoc;26+27+type Commands = readonly CommandDoc[];28+29+/** The MCP protocol the platform serves over HTTP. */30+export const MCP_PROTOCOL = "2026-07-28";31+32+/** Each posture as GLOSSARY.md names it. */33+const postureWords = {34+ open: "Open",35+ openCore: "Open core",36+ openOnSchedule: "Open on schedule",37+ openWithSealedEvidence: "Open with sealed evidence",38+ sourceAvailable: "Source available",39+} as const satisfies Record<Posture, string>;40+41+const code = (text: string) => `\`${text}\``;42+43+const counted = (count: number, one: string) =>44+ `${count} ${one}${count === 1 ? "" : "s"}`;45+46+/** The lines as one document, ending in a newline. */47+const page = (lines: readonly string[]) => `${lines.join("\n")}\n`;48+49+/** What a placeholder stands for in a command line, if the page knows it. */50+interface Known {51+ readonly project?: string;52+}53+54+/** The command whose words are `words`, if the catalog has it. */55+const commandOf = (commands: Commands, words: string) =>56+ Arr.findFirst(commands, ({ path }) => path.join(" ") === words);57+58+/**59+ * A command as typed: the CLI's name, its words, its arguments, then60+ * `flags` it takes, each with a value the page knows or a placeholder.61+ */62+const usage = (63+ command: Command,64+ known: Known = {},65+ flags: readonly ("ask" | "project")[] = []66+) => {67+ const valueOf = (name: string) =>68+ name === "project" && known.project !== undefined69+ ? known.project70+ : `<${name}>`;71+72+ return [73+ Brand.cli,74+ ...command.path,75+ ...command.positional.map((name) => `<${name}>`),76+ ...flags.flatMap((flag) =>77+ command.flags.includes(`--${flag}`) && !command.positional.includes(flag)78+ ? [`--${flag}`, valueOf(flag)]79+ : []80+ ),81+ ].join(" ");82+};83+84+/** `words` as typed, with `flags`, when the catalog has the command. */85+const typed = (86+ commands: Commands,87+ words: string,88+ known: Known,89+ flags: readonly ("ask" | "project")[] = []90+) =>91+ Option.map(commandOf(commands, words), (command) =>92+ code(usage(command, known, flags))93+ );94+95+/** The sentence `make` writes around a typed command, or nothing without it. */96+const withCommand = (97+ command: Option.Option<string>,98+ make: (typedCommand: string) => string99+) => Option.toArray(Option.map(command, make));100+101+/**102+ * How to take an ask, each step with the commands the catalog has: find,103+ * read, claim, change and check, push and read the verdict. Numbered in104+ * order, whatever steps the catalog leaves out.105+ */106+const takeAnAsk = (commands: Commands, known: Known) => {107+ const front = typed(commands, "front", known);108+ const asks = typed(commands, "asks", known, ["project"]);109+110+ const find = [111+ ...Option.toArray(112+ Option.map(front, (each) => `${each} lists the open asks across projects`)113+ ),114+ ...Option.toArray(115+ Option.map(asks, (each) => `${each} lists one project's`)116+ ),117+ ];118+119+ const steps = [120+ ...(find.length === 0 ? [] : [`Find one: ${find.join("; ")}.`]),121+ ...withCommand(122+ typed(commands, "ask", known, ["project"]),123+ (each) => `Read it: ${each}.`124+ ),125+ ...withCommand(126+ typed(commands, "claim", known, ["project"]),127+ (each) =>128+ `Claim it: ${each}. The claim prints your fork's remote; add it with ${code(`git remote add ${Brand.slug} <remote>`)}.`129+ ),130+ ...withCommand(131+ typed(commands, "check", known),132+ (each) =>133+ `Change only the ask's territory, then run ${each} and fix everything it reports.`134+ ),135+ `Push to your fork with ${code(`git push ${Brand.slug} HEAD:main`)}${Option.match(136+ typed(commands, "verdict", known, ["ask", "project"]),137+ { onNone: () => "", onSome: (each) => `, then read the verdict: ${each}` }138+ )}. A refusal names the command to run next.`,139+ ];140+141+ return [142+ "## Take an ask",143+ "",144+ ...steps.map((step, at) => `${at + 1}. ${step}`),145+ "",146+ ];147+};148+149+/** What a command row adds to its description. */150+const notes = ({ needsApproval, readOnly }: Command) => [151+ ...(readOnly ? ["Only reads."] : []),152+ ...(needsApproval ? [`Runs only with ${code("--yes")}.`] : []),153+];154+155+/** Every command, one line each, in the catalog's order. */156+const commandList = (commands: Commands) => [157+ "## Commands",158+ "",159+ ...commands.map(160+ (command) =>161+ `- ${code(usage(command))}: ${[command.summary, ...notes(command)].join(" ")}`162+ ),163+ "",164+];165+166+/** Where a project's page is on the web host. */167+const projectPage = (webUrl: string, project: string) => `${webUrl}/${project}`;168+169+/** What a project's line says of it: its posture and its open asks. */170+const projectFacts = (listing: ProjectListing) =>171+ `${postureWords[listing.posture]}, ${counted(listing.openAsks, "open ask")}.`;172+173+/**174+ * A project's line: a link to its Markdown on the web host, or, with no175+ * web app, its clone URL on the platform.176+ */177+const projectLine = (178+ platformUrl: string,179+ webUrl: Option.Option<string>,180+ listing: ProjectListing181+) =>182+ Option.match(webUrl, {183+ onNone: () =>184+ `- ${listing.project}: ${projectFacts(listing)} Clone: ${code(`git clone ${platformUrl}/${listing.project}.git`)}.`,185+ onSome: (web) =>186+ `- [${listing.project}](${projectPage(web, listing.project)}/llms.txt): ${projectFacts(listing)}`,187+ });188+189+/**190+ * The platform, the CLI, MCP, taking an ask, the commands and the191+ * projects: the web's `/llms.txt`, and the platform's `/` for an agent.192+ * Without `webUrl` it names only what the platform serves itself: the CLI193+ * and the skills from the platform, each project by its clone URL, and no194+ * page that only a web app serves.195+ */196+export const frontLlms = (input: {197+ readonly commands: Commands;198+ readonly projects: readonly ProjectListing[];199+ readonly platformUrl: string;200+ readonly webUrl?: string;201+}) => {202+ const { commands, platformUrl, projects } = input;203+ const webUrl = Option.fromUndefinedOr(input.webUrl);204+ // The CLI's downloads and the skills: the web forwards both to the platform.205+ const served = Option.getOrElse(webUrl, () => platformUrl);206+207+ return page([208+ `# ${Brand.name}`,209+ "",210+ `> ${Brand.name} is a Git platform where everything a project ships is public. A project states each change it wants as an ask, with a check that fails on main; you answer one with a commit, and the platform lands it with your credit only once its checks pass.`,211+ "",212+ ...Option.match(webUrl, {213+ onNone: () => [],214+ onSome: (web) => [215+ `The same facts read as Markdown: each project at ${web}/<project>/llms.txt, and each ask at ${web}/<project>/asks/<ask>.md.`,216+ "",217+ ],218+ }),219+ "## Install the CLI",220+ "",221+ "```sh",222+ `curl -fsSL ${served}/install.sh | sh`,223+ "```",224+ "",225+ ...Option.match(commandOf(commands, "login"), {226+ onNone: () => [],227+ onSome: () => [228+ "Then sign in once; git pushes to the platform with your token from then on:",229+ "",230+ "```sh",231+ `${Brand.cli} login --url ${platformUrl}`,232+ "```",233+ "",234+ ],235+ }),236+ "## Connect over MCP",237+ "",238+ `- Endpoint: ${platformUrl}/mcp (streamable HTTP, MCP ${MCP_PROTOCOL})${Option.match(239+ webUrl,240+ {241+ onNone: () => "",242+ onSome: (web) => `, described at ${web}/.well-known/mcp.json`,243+ }244+ )}.`,245+ `- Auth: a bearer token from the platform's own OAuth server, which an MCP client finds at ${platformUrl}/.well-known/oauth-protected-resource; you sign in with your account on ${Brand.name}.`,246+ ...withCommand(247+ typed(commands, "mcp", {}),248+ (each) =>249+ `- Without a client that signs in: ${each} serves the same tools over stdio, with the token ${code(`${Brand.cli} login`)} stored.`250+ ),251+ `- Skills: ${served}/.well-known/agent-skills/index.json lists each project's contribute skill, with its digest.`,252+ "",253+ ...takeAnAsk(commands, {}),254+ ...commandList(commands),255+ "## Projects",256+ "",257+ ...(projects.length === 0258+ ? ["No project is on the platform yet."]259+ : projects.map((listing) => projectLine(platformUrl, webUrl, listing))),260+ ]);261+};262+263+/** What an ask's line adds after its want: its kind and territory, then whether it can be taken. */264+const askNotes = (listing: AskListing) => [265+ `Kind ${code(listing.kind)}, territory ${code(listing.territory)}.`,266+ ...(listing.claimed ? ["Claimed."] : []),267+ ...(listing.reserve === undefined ? [] : [`Held for ${listing.reserve}.`]),268+ ...(listing.blockedBy.length === 0269+ ? []270+ : [`Waits for ${listing.blockedBy.map(code).join(", ")}.`]),271+];272+273+/** An ask's want as a sentence of its own, however it was punctuated. */274+const sentence = (text: string) => `${text.replace(/[.\s]+$/u, "")}.`;275+276+const askLine = (webUrl: string, project: string, listing: AskListing) =>277+ `- [${listing.ask}](${projectPage(webUrl, project)}/asks/${listing.ask}.md): ${[sentence(listing.want), ...askNotes(listing)].join(" ")}`;278+279+/** `/<project>/llms.txt`: the project, its posture, how to clone it, its open asks and how to take one. */280+export const projectLlms = (input: {281+ readonly listing: ProjectListing;282+ readonly asks: readonly AskListing[];283+ readonly commands: Commands;284+ readonly platformUrl: string;285+ readonly webUrl: string;286+}) => {287+ const { asks, commands, listing, platformUrl, webUrl } = input;288+ const { project } = listing;289+290+ return page([291+ `# ${project}`,292+ "",293+ `> A project on ${Brand.name}. Posture: ${postureWords[listing.posture]}. ${counted(asks.length, "open ask")}.`,294+ "",295+ `- Page: ${projectPage(webUrl, project)}`,296+ `- Clone: ${code(`git clone ${platformUrl}/${project}.git`)}`,297+ `- Everything else, and every command: ${webUrl}/llms.txt`,298+ "",299+ "## Open asks",300+ "",301+ ...(asks.length === 0302+ ? ["No ask is open."]303+ : asks.map((each) => askLine(webUrl, project, each))),304+ "",305+ ...takeAnAsk(commands, { project }).slice(0, -1),306+ ]);307+};308+309+/**310+ * `/<project>/llms.txt` for a project the platform does not list. A name311+ * that could not be a project's is not repeated back.312+ */313+export const missingProjectLlms = (input: {314+ readonly project: Option.Option<ProjectName>;315+ readonly webUrl: string;316+}) =>317+ page([318+ "# Not found",319+ "",320+ `${Option.match(input.project, {321+ onNone: () => "No such project",322+ onSome: (project) => `No project named ${code(project)}`,323+ })} is on ${Brand.name}. Every project is listed at ${input.webUrl}/llms.txt.`,324+ ]);325+326+/**327+ * `/.well-known/mcp.json`: the platform's MCP endpoint, its transport and328+ * protocol, and where a client learns to sign in. No settled standard says329+ * this card's shape; it follows the MCP server card draft, and names its330+ * authorization the way the platform's 401 does (RFC 9728's331+ * `resource_metadata`).332+ */333+export const mcpCard = (input: { readonly platformUrl: string }) => ({334+ authentication: {335+ required: true,336+ resource_metadata: `${input.platformUrl}/.well-known/oauth-protected-resource`,337+ schemes: ["bearer"],338+ },339+ capabilities: { prompts: {}, resources: {}, tools: {} },340+ description: `The contracts of ${Brand.name} as MCP tools, each ask's brief as a resource, and the contribute skill as a prompt.`,341+ name: Brand.name,342+ protocolVersion: MCP_PROTOCOL,343+ transport: { endpoint: `${input.platformUrl}/mcp`, type: "streamable-http" },344+});345+346+export type McpCard = ReturnType<typeof mcpCard>;added:packages/agent-kit/test/golden/host-doc.txt+49 added
1+# __NAME__2+3+> __NAME__ is a Git platform where everything a project ships is public. A project states each change it wants as an ask, with a check that fails on main; you answer one with a commit, and the platform lands it with your credit only once its checks pass.4+5+The same facts read as Markdown: each project at https://web-test.example.workers.dev/<project>/llms.txt, and each ask at https://web-test.example.workers.dev/<project>/asks/<ask>.md.6+7+## Install the CLI8+9+```sh10+curl -fsSL https://web-test.example.workers.dev/install.sh | sh11+```12+13+Then sign in once; git pushes to the platform with your token from then on:14+15+```sh16+__CLI__ login --url https://platform-test.example.workers.dev17+```18+19+## Connect over MCP20+21+- Endpoint: https://platform-test.example.workers.dev/mcp (streamable HTTP, MCP 2026-07-28), described at https://web-test.example.workers.dev/.well-known/mcp.json.22+- Auth: a bearer token from the platform's own OAuth server, which an MCP client finds at https://platform-test.example.workers.dev/.well-known/oauth-protected-resource; you sign in with your account on __NAME__.23+- Without a client that signs in: `__CLI__ mcp` serves the same tools over stdio, with the token `__CLI__ login` stored.24+- Skills: https://web-test.example.workers.dev/.well-known/agent-skills/index.json lists each project's contribute skill, with its digest.25+26+## Take an ask27+28+1. Find one: `__CLI__ front` lists the open asks across projects; `__CLI__ asks --project <project>` lists one project's.29+2. Read it: `__CLI__ ask <ask> --project <project>`.30+3. Claim it: `__CLI__ claim <ask> --project <project>`. The claim prints your fork's remote; add it with `git remote add __SLUG__ <remote>`.31+4. Change only the ask's territory, then run `__CLI__ check` and fix everything it reports.32+5. Push to your fork with `git push __SLUG__ HEAD:main`, then read the verdict: `__CLI__ verdict --ask <ask> --project <project>`. A refusal names the command to run next.33+34+## Commands35+36+- `__CLI__ ask <ask>`: Show one ask in full, with its brief in Markdown for an answerer to read first. Only reads.37+- `__CLI__ asks`: List a project's open asks. Only reads.38+- `__CLI__ check`: Run the gate's checks on your answer locally. Only reads.39+- `__CLI__ claim <ask>`: Claim an ask: an exclusive, expiring right to answer it.40+- `__CLI__ env set <key>`: Set a sensitive env item's value from stdin. Runs only with `--yes`.41+- `__CLI__ front`: List the open asks across every project. Only reads.42+- `__CLI__ login`: Sign in to a platform.43+- `__CLI__ mcp`: Serve the platform's tools over MCP on stdio. Only reads.44+- `__CLI__ verdict`: Show the verdict on an answer to an ask. Only reads.45+46+## Projects47+48+- [datekit](https://web-test.example.workers.dev/datekit/llms.txt): Open, 3 open asks.49+- [burrow](https://web-test.example.workers.dev/burrow/llms.txt): Open with sealed evidence, 1 open ask.added:packages/agent-kit/test/host-doc.test.ts+134 added
1+/**2+ * The host's own Markdown, `frontLlms`: what the web serves at `/llms.txt`3+ * and the platform at `/` for an agent. A pure function of the CLI's4+ * commands, the listed projects and the two hosts' URLs; with no web app5+ * it points only at what the platform serves itself.6+ */7+import { NodeServices } from "@effect/platform-node";8+import { describe, expect, it } from "@effect/vitest";9+import { Brand } from "@repo/brand";10+import type { ProjectListing } from "@repo/protocol/domain/front-page";11+import { ProjectName } from "@repo/protocol/ids";12+import { Effect } from "effect";13+14+import type { CommandDoc } from "../src/command-doc.ts";15+import { frontLlms } from "../src/host-doc.ts";16+import { expectGolden } from "./golden.ts";17+18+const platformUrl = "https://platform-test.example.workers.dev";19+20+const webUrl = "https://web-test.example.workers.dev";21+22+/** A command row as the command list holds it. */23+const row = (24+ path: readonly [string, ...string[]],25+ summary: string,26+ more: Partial<CommandDoc> = {}27+): CommandDoc => ({28+ flags: ["--json"],29+ needsApproval: false,30+ path,31+ positional: [],32+ readOnly: true,33+ source: "contract",34+ summary,35+ ...more,36+});37+38+/** The web's own `llms.test.ts` catalog, so the golden file is its former output. */39+const commands: readonly CommandDoc[] = [40+ row(41+ ["ask"],42+ "Show one ask in full, with its brief in Markdown for an answerer to read first.",43+ { flags: ["--project", "--json"], positional: ["ask"] }44+ ),45+ row(["asks"], "List a project's open asks.", {46+ flags: ["--project", "--json"],47+ }),48+ row(["check"], "Run the gate's checks on your answer locally.", {49+ flags: ["--ask", "--project", "--json"],50+ source: "local",51+ }),52+ row(["claim"], "Claim an ask: an exclusive, expiring right to answer it.", {53+ flags: ["--project", "--json", "--dry-run"],54+ positional: ["ask"],55+ readOnly: false,56+ }),57+ row(["env", "set"], "Set a sensitive env item's value from stdin.", {58+ flags: ["--project", "--yes"],59+ needsApproval: true,60+ positional: ["key"],61+ readOnly: false,62+ source: "local",63+ }),64+ row(["front"], "List the open asks across every project."),65+ row(["login"], "Sign in to a platform.", {66+ flags: ["--url", "--json"],67+ readOnly: false,68+ source: "local",69+ }),70+ row(["mcp"], "Serve the platform's tools over MCP on stdio.", {71+ flags: [],72+ source: "local",73+ }),74+ row(["verdict"], "Show the verdict on an answer to an ask.", {75+ flags: ["--ask", "--head", "--project", "--json"],76+ }),77+];78+79+const projects: readonly ProjectListing[] = [80+ { openAsks: 3, posture: "open", project: ProjectName.make("datekit") },81+ {82+ openAsks: 1,83+ posture: "openWithSealedEvidence",84+ project: ProjectName.make("burrow"),85+ },86+];87+88+const linesOf = (text: string) => text.split("\n");89+90+describe("the host's Markdown", () => {91+ it.effect("with a web app, is the text the web served at /llms.txt", () =>92+ expectGolden(93+ "host-doc",94+ frontLlms({ commands, platformUrl, projects, webUrl })95+ ).pipe(Effect.provide(NodeServices.layer))96+ );97+98+ describe("without a web app", () => {99+ const text = frontLlms({ commands, platformUrl, projects });100+ const lines = linesOf(text);101+102+ it("installs the CLI and finds the skills on the platform itself", () => {103+ expect(lines).toContain(`curl -fsSL ${platformUrl}/install.sh | sh`);104+ expect(lines).toContain(105+ `- Skills: ${platformUrl}/.well-known/agent-skills/index.json lists each project's contribute skill, with its digest.`106+ );107+ expect(lines).toContain(108+ `- Endpoint: ${platformUrl}/mcp (streamable HTTP, MCP 2026-07-28).`109+ );110+ });111+112+ it("gives each project's clone URL in place of a web page", () => {113+ expect(lines).toContain(114+ `- datekit: Open, 3 open asks. Clone: \`git clone ${platformUrl}/datekit.git\`.`115+ );116+ expect(lines).toContain(117+ `- burrow: Open with sealed evidence, 1 open ask. Clone: \`git clone ${platformUrl}/burrow.git\`.`118+ );119+ });120+121+ it("names no page only a web app serves", () => {122+ expect(text).not.toContain("llms.txt");123+ expect(text).not.toContain("mcp.json");124+ expect(text).not.toContain(".md");125+ });126+127+ it("still opens with the name and lists every command", () => {128+ expect(lines[0]).toBe(`# ${Brand.name}`);129+ expect(130+ lines.filter((line) => line.startsWith(`- \`${Brand.cli} `))131+ ).toHaveLength(commands.length);132+ });133+ });134+});modified:packages/config/test/smoke.test.ts+52 added-2 removed
62 unmodified lines63 64 /**65 * The platform as smoke expects to find it: healthy, OAuth's resource66 * metadata published, MCP closed to anyone without a credential, anonymous67- * reads open, and no repo it doesn't hold.67+ * reads open, no repo it doesn't hold, and a `/` that names MCP and the68+ * CLI's installer.69 */70 const healthy = ({ authorized, body, method, path }: Seen): Reply => {71+ if (method === "GET" && path === "/") {72+ return {73+ body: "<!doctype html><p><code>http://127.0.0.1/mcp</code></p><pre>curl -fsSL http://127.0.0.1/install.sh | sh</pre>",74+ contentType: "text/html; charset=utf-8",75+ status: 200,76+ };77+ }78+79 if (method === "GET" && path === "/health") {80 return { body: '{"ok":true,"stage":"dev-oscabriel"}', status: 200 };81 }82 16 unmodified lines99 };100 101 /**102 * A platform whose 401 gate is gone and whose stage is down: `/health` and94- * `/rpc` break, MCP opens to anyone, and git's paths answer 200.103+ * `/rpc` break, MCP opens to anyone, git's paths answer 200, and `/` is104+ * gone.105 */106 const broken = (seen: Seen): Reply => {107+ if (seen.path === "/") {108+ return { status: 404 };109+ }110+111 if (seen.path === "/health") {112 return { body: "upstream connect error", status: 503 };113 }114 55 unmodified lines170 expect(report.stage).toBe("dev-oscabriel");171 expect(report.probes.map(({ probe }) => probe)).toStrictEqual([172 ...platformProbes,173 ]);174+ expect(platformProbes).toStrictEqual([175+ "health",176+ "oauth-metadata",177+ "mcp-needs-credential",178+ "anonymous-unknown-project",179+ "missing-repo-404",180+ "platform-root",181+ ]);182 expect(183 report.probes.every(({ elapsedMs }) => elapsedMs >= 0)184 ).toBeTruthy();185 }).pipe(Effect.scoped, Effect.provide(FetchHttpClient.layer))69 unmodified lines255 {256 probe: "missing-repo-404",257 reason: "GET /no-such-project.git/info/refs answered 200, not 404",258 },259+ { probe: "platform-root", reason: "GET / answered 404, not 200" },260 ]);261 }).pipe(Effect.scoped, Effect.provide(FetchHttpClient.layer))262 );263 160 unmodified lines424 },425 ]);426 }).pipe(Effect.scoped, Effect.provide(FetchHttpClient.layer))427 );428+429+ it.live(430+ "fails the platform's / when it names neither MCP nor the installer",431+ () =>432+ Effect.gen(function* () {433+ const origin = yield* fakePlatform((seen) =>434+ seen.path === "/"435+ ? {436+ body: "<!doctype html><p>Hello</p>",437+ contentType: "text/html; charset=utf-8",438+ status: 200,439+ }440+ : healthy(seen)441+ );442+443+ const result = yield* Effect.result(smoke(origin));444+445+ expect(446+ Result.isFailure(result) ? result.failure.failures : []447+ ).toStrictEqual([448+ {449+ probe: "platform-root",450+ reason: "GET / answered 200 without naming /mcp and install.sh",451+ },452+ ]);453+ }).pipe(Effect.scoped, Effect.provide(FetchHttpClient.layer))454+ );455 });456 457 describe("the smoke command", () => {458 it.live("refuses without a stage it knows, before it probes anything", () =>70 unmodified lines