Merge build/1108 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 1a26053, 8d26192 · Browse files · 20 files·+1053 added−49 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
20 files+1053 added−49 removed
- tests:+623 added−19 removed
- other:+430 added−30 removed
Provenance
- Commit
8d9ece9- Tree
e61f754- Author
oscabriel <oscarhernandeziv@gmail.com>- Committer
oscabriel <oscarhernandeziv@gmail.com>- Parent 1
1a26053- Parent 2
8d26192
20 files changed+1053 added−49 removed
modified:apps/web/src/features/agents/llms.ts+8 added-4 removed
123456345678910111213141516172 unmodified lines/** * What an agent, or a person, reads first on the web host: `/llms.txt`, * `/<project>/llms.txt` and the MCP card at `/.well-known/mcp.json`. The * text lives in `@repo/agent-kit/host-doc`, which the platform's own `/` * serves too, so both hosts say the same thing; the routes import it from * here. * `/llms-full.txt`, `/<project>/llms.txt` and the MCP card at * `/.well-known/mcp.json`, and the banner that opens the web's other * Markdown. The text lives in `@repo/agent-kit` (`host-doc`, which the * platform's own `/` serves too, so both hosts say the same thing, and * `full-llms`, which only the web serves); the routes import it from here. */export { fullLlms } from "@repo/agent-kit/full-llms";
export { frontLlms, indexBanner, mcpCard, missingProjectLlms, projectLlms,} from "@repo/agent-kit/host-doc";2 unmodified linesmodified:apps/web/src/features/ask/markdown.ts+19 added-6 removed
2 unmodified lines3 * fetch, either with `Accept: text/markdown` on the ask's own URL or at the4 * same URL with `.md`. The request decides; no user-agent list does.5 *6 * The brief is the platform's: `showAsk` renders it once, and the web only7- * serves it. A refusal is set the way `git push` printed it, from8- * `@repo/protocol/render` (AGENTS.md principle 3), then its next command.7+ * serves it, under the banner that names the web's indexes. A refusal is8+ * set the way `git push` printed it, from `@repo/protocol/render`9+ * (AGENTS.md principle 3), then its next command.10 * Pure: a `Request` or an `Exit` in, a string or a `Response` out.11 */12+import { indexBanner } from "@repo/agent-kit/host-doc";13 import { Brand } from "@repo/brand";14 import type { Visibility } from "@repo/protocol/annotations";15+import type { ProjectName } from "@repo/protocol/ids";16 import { Refusal } from "@repo/protocol/refusal";17 import { explain } from "@repo/protocol/render";18 import { Array, Cause, Exit, Option, Schema } from "effect";19 132 unmodified lines152 "The platform did not answer, so the web cannot read this ask now. Ask again in a moment.",153 "",154 ].join("\n");155 156+/** Where the web's indexes are, for the banner over an ask's brief. */157+export interface AskIndex {158+ readonly project: ProjectName;159+ readonly webUrl: string;160+}161+162 /**163 * How reading an ask ended, as the Markdown response: the brief (200,155- * cacheable as its contract's visibility allows); a refusal (404, its156- * Markdown); or no answer from the platform (502). Only a brief is cached.164+ * cacheable as its contract's visibility allows), opened by the banner165+ * naming `index`'s `llms.txt` files; a refusal (404, its166+ * Markdown, no banner); or no answer from the platform (502). Only a brief167+ * is cached.168 */169 export const askMarkdownResponse = <E>(170 result: Exit.Exit<{ readonly brief: string }, E>,160- visibility: ContractVisibility171+ visibility: ContractVisibility,172+ index: AskIndex173 ): Response =>174 Exit.match(result, {175 onFailure: (cause) =>176 Option.match(Option.filter(Cause.findErrorOption(cause), isRefusal), {177 onNone: () => markdown(UNANSWERED, 502, "no-store"),178 onSome: (refusal) =>179 markdown(refusalsMarkdown([refusal]), 404, "no-store"),180 }),169- onSuccess: ({ brief }) => markdown(brief, 200, cacheFor(visibility)),181+ onSuccess: ({ brief }) =>182+ markdown(`${indexBanner(index)}\n\n${brief}`, 200, cacheFor(visibility)),183 });184 185 /**186 * The answer to a path that can name no ask: a project's and an ask's names21 unmodified linesmodified:apps/web/src/routes/$project/asks/{$ask}[.]md.ts+9 added-3 removed
31 unmodified lines3233343536373637383940414210 unmodified lines5354555656575859606162636465668 unmodified lines31 unmodified linesconst visibility = Context.get(ShowAsk.annotations, Visibility);
/** * The `.md` route's handler as a function of its client, which its test * drives with a stub platform: the brief `showAsk` gives, a refusal as a * 404, or a 404 without asking when the path can name no ask. * drives with a stub platform: the brief `showAsk` gives, under the banner * naming this host's indexes, a refusal as a 404, or a 404 without asking * when the path can name no ask. */export const askMarkdownHandler = (clientFor: ClientFor) => ({10 unmodified lines Effect.flatMap(Effect.service(Client), (client) => client.showAsk(path) ).pipe( Effect.exit, Effect.map((exit) => askMarkdownResponse(exit, visibility)), Effect.map((exit) => askMarkdownResponse(exit, visibility, { project: path.project, webUrl: new URL(request.url).origin, }) ), Effect.provide(clientFor(request)) ), }) );8 unmodified linesadded:apps/web/src/routes/llms-full[.]txt.ts+52 added
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152import { Client } from "@repo/protocol/contracts";import { createFileRoute } from "@tanstack/react-router";import { env } from "cloudflare:workers";import { Effect } from "effect";import type { Layer } from "effect";
import { commands } from "../features/agents/catalog.ts";import { fullLlms } from "../features/agents/llms.ts";import { markdown, unavailable } from "../features/agents/respond.ts";import { serverClient } from "../server/client.ts";
/** * `/llms-full.txt`: the index, then every refusal, how git meets the * platform, how a landing happens, the events and the guides, with the * projects the platform lists now. The web alone serves it: the platform's * `/` stays the index (`apps/platform/test/home.test.ts`). */
/** The route's handler as a function of its client and the platform's URL, which its test hands in. */export const llmsFullHandler = (clientFor: (request: Request) => Layer.Layer<Client>, platformUrl: string) => ({ request }: { readonly request: Request }): Promise<Response> => Effect.runPromise( Effect.gen(function* () { const client = yield* Client; const { projects } = yield* client.listProjects({});
return markdown( fullLlms({ commands, platformUrl, projects, webUrl: new URL(request.url).origin, }) ); }).pipe( Effect.provide(clientFor(request)), // Unanswered or unreachable alike: try again soon, and keep nothing. Effect.catchCause(() => Effect.succeed(unavailable())) ) );
export const Route = createFileRoute("/llms-full.txt")({ server: { handlers: { GET: llmsFullHandler( (request) => serverClient(env, request), env.PUBLIC_PLATFORM_URL ), }, },});modified:apps/web/test/ask-markdown.test.ts+47 added-6 removed
1 /**2 * An ask answers as Markdown, so a harness reads it with one plain fetch:3 * the ask's URL with `Accept: text/markdown`, or the same URL with `.md`.4- * The body is the brief the platform rendered (`showAsk`), untouched; an5- * unknown ask is a 404 whose body is the refusal, as git would print it.4+ * The body is the banner naming the web's indexes, then the brief the5+ * platform rendered (`showAsk`), untouched; an unknown ask is a 404 whose6+ * body is the refusal, as git would print it.7 * A browser asking for HTML gets the page.8 */9 import { describe, expect, it } from "@effect/vitest";10 import { Brand } from "@repo/brand";4 unmodified lines15 import { asTester, unanswered } from "@repo/protocol/testing";16 import { Effect, Exit, Layer, Ref } from "effect";17 import { RpcTest } from "effect/rpc";18 19+import { indexBanner } from "../src/features/agents/llms.ts";20 import {21 askMarkdownResponse,22 refusalsMarkdown,23 wantsMarkdown,6 unmodified lines30 import { ask, askId, brief, project } from "./ask-fixtures.ts";31 32 const WEB = "https://web-test.example.workers.dev";33 34+/** Where the web's indexes are for datekit's asks, as the routes find them. */35+const index = { project, webUrl: WEB };36+37+/** An ask's Markdown as served: the banner naming the indexes, then the brief unchanged. */38+const served = `${indexBanner(index)}\n\n${brief}`;39+40 const MARKDOWN = "text/markdown; charset=utf-8";41 42 const BROWSER =43 "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";76 unmodified lines120 )121 );122 123 expect(yield* read(response)).toStrictEqual({116- body: brief,124+ body: served,125 cacheControl: "public, max-age=60",126 contentType: MARKDOWN,127 status: 200,128 vary: "Accept",34 unmodified lines163 })164 );165 166 expect(yield* read(response)).toStrictEqual({159- body: brief,167+ body: served,168 cacheControl: "public, max-age=60",169 contentType: MARKDOWN,170 status: 200,171 vary: "Accept",122 unmodified lines294 "never lets a cache keep the answer of a contract only maintainers may see",295 () =>296 Effect.gen(function* () {297 const seen = yield* read(290- askMarkdownResponse(Exit.succeed({ brief }), "maintainers")298+ askMarkdownResponse(Exit.succeed({ brief }), "maintainers", index)299 );300 301 expect([seen.status, seen.cacheControl, seen.body]).toStrictEqual([302 200,303 "private, no-store",296- brief,304+ served,305 ]);306 })307 );308 });309 310+describe("an ask's Markdown with the index named", () => {311+ it.effect(312+ "opens with the banner naming its project's llms.txt, then the brief unchanged",313+ () =>314+ Effect.gen(function* () {315+ const seen = yield* read(316+ askMarkdownResponse(Exit.succeed({ brief }), "public", index)317+ );318+319+ expect(seen.status).toBe(200);320+ expect(seen.body).toBe(served);321+ expect(seen.body.split("\n")[0]).toContain(322+ `${WEB}/${project}/llms.txt`323+ );324+ })325+ );326+327+ it.effect("keeps a refusal's Markdown as it is, with no banner", () =>328+ Effect.gen(function* () {329+ const refusal = new UnknownAsk({ ask: AskId.make("no-such-ask") });330+331+ const seen = yield* read(332+ askMarkdownResponse(Exit.fail(refusal), "public", index)333+ );334+335+ expect([seen.status, seen.body]).toStrictEqual([336+ 404,337+ refusalsMarkdown([refusal]),338+ ]);339+ })340+ );341+});342+343 describe(refusalsMarkdown, () => {344 it("sets every refusal's explain lines in one text block, then each distinct next command once", () => {345 const refusals = [346 new UnknownProject({ project: ProjectName.make("nowhere") }),44 unmodified linesmodified:apps/web/test/llms.test.ts+102 added-4 removed
6 unmodified lines7 */8 import { describe, expect, it } from "@effect/vitest";9 import type { CommandDoc } from "@repo/agent-kit/command-doc";10 import { Brand } from "@repo/brand";11+import { claimForkName, workingForkName } from "@repo/project/repo-names";12+import { Client, Contracts } from "@repo/protocol/contracts";13 import type { AskListing } from "@repo/protocol/domain/ask";14 import type { ProjectListing } from "@repo/protocol/domain/front-page";13-import { AskId, KindName, ProjectName } from "@repo/protocol/ids";14-import { Option } from "effect";15+import { AskId, Handle, KindName, ProjectName } from "@repo/protocol/ids";16+import { asTester, unanswered } from "@repo/protocol/testing";17+import { Effect, Layer, Option } from "effect";18+import { RpcTest } from "effect/rpc";19 20 import { commands as catalog } from "../src/features/agents/catalog.ts";21 import {22 frontLlms,23+ fullLlms,24+ indexBanner,25 mcpCard,26 missingProjectLlms,27 projectLlms,28 } from "../src/features/agents/llms.ts";29+import { llmsFullHandler } from "../src/routes/llms-full[.]txt.ts";30 31 const platformUrl = "https://platform-test.example.workers.dev";32 33 const webUrl = "https://web-test.example.workers.dev";203 unmodified lines237 });238 239 const lines = linesOf(text);240 234- it("opens with the project, its posture and how many asks are open", () => {235- expect(lines.slice(0, 3)).toStrictEqual([241+ it("opens with the banner, then the project, its posture and how many asks are open", () => {242+ expect(lines.slice(0, 5)).toStrictEqual([243+ indexBanner({ project: datekit, webUrl }),244+ "",245 "# datekit",246 "",247 `> A project on ${Brand.name}. Posture: Open with sealed evidence. 3 open asks.`,248 ]);83 unmodified lines332 ).toStrictEqual([]);333 });334 });335 336+/** A platform that lists `listed` as its projects, and answers nothing else. */337+const listing = (listed: readonly ProjectListing[]) => () =>338+ Layer.effect(Client, RpcTest.makeClient(Contracts)).pipe(339+ Layer.provide([340+ Layer.mergeAll(341+ unanswered,342+ Contracts.toLayerHandler("listProjects", () =>343+ Effect.succeed({ projects: listed })344+ )345+ ),346+ asTester,347+ ])348+ );349+350+/** A platform that cannot be reached: every call dies on the way. */351+const unreachable = () =>352+ Layer.effect(Client, RpcTest.makeClient(Contracts)).pipe(353+ Layer.provide([unanswered, asTester])354+ );355+356+const getFull = () => new Request(`${webUrl}/llms-full.txt`);357+358+const read = (response: Response) =>359+ Effect.map(360+ Effect.promise(() => response.text()),361+ (body) => ({362+ body,363+ contentType: response.headers.get("content-type"),364+ status: response.status,365+ })366+ );367+368+describe("/llms-full.txt", () => {369+ it.effect("is fullLlms over the projects the platform lists", () =>370+ Effect.gen(function* () {371+ const response = yield* Effect.promise(() =>372+ llmsFullHandler(listing(projects), platformUrl)({ request: getFull() })373+ );374+375+ expect(yield* read(response)).toStrictEqual({376+ body: fullLlms({ commands: catalog, platformUrl, projects, webUrl }),377+ contentType: "text/markdown; charset=utf-8",378+ status: 200,379+ });380+ })381+ );382+383+ it.effect("is unavailable when the platform does not answer", () =>384+ Effect.gen(function* () {385+ const response = yield* Effect.promise(() =>386+ llmsFullHandler(unreachable, platformUrl)({ request: getFull() })387+ );388+389+ const seen = yield* read(response);390+391+ expect(seen.status).toBe(503);392+ expect(seen.body).toContain("# Unavailable");393+ })394+ );395+396+ describe("its fork names", () => {397+ const text = fullLlms({ commands: catalog, platformUrl, projects, webUrl });398+ const parseIso = AskId.make("parse-iso");399+ const ada = Handle.make("Ada");400+401+ /** A name pattern the doc states, with its placeholders filled in. */402+ const filled = (pattern: string) =>403+ pattern404+ .replaceAll("<project>", datekit)405+ .replaceAll("<ask>", parseIso)406+ .replaceAll("<handle>", ada.toLowerCase());407+408+ /** The patterns in the doc's code spans that name a fork. */409+ const patterns = [...text.matchAll(/`(?<name><project>--[^`]+)`/gu)].map(410+ (match) => match.groups?.name ?? ""411+ );412+413+ it("spell a claim's fork as the platform names it", () => {414+ expect(patterns.map(filled)).toContain(415+ claimForkName(datekit, parseIso, ada)416+ );417+ });418+419+ it("spell a working fork as the platform names it", () => {420+ expect(patterns.map(filled)).toContain(workingForkName(datekit, ada));421+ });422+ });423+});424+425 describe(mcpCard, () => {426 it("describes the platform's MCP endpoint and where its auth is found", () => {427 expect(mcpCard({ platformUrl })).toStrictEqual({428 authentication: {12 unmodified linesmodified:apps/web/test/routes.test.ts+1 added
46 unmodified lines47484950515253545517 unmodified lines46 unmodified lines "auth", "favicon.ico", "icons", "install.sh", "llms-full.txt", "llms.txt", "people", "releases", "robots.txt",17 unmodified linesadded:packages/agent-kit/src/full-llms.ts+204 added
1+/**2+ * `/llms-full.txt`: what an agent needs beyond the index, in one file.3+ * `frontLlms`' text, then every refusal of the closed union (every group,4+ * from `refusalCatalog`), how git meets the platform, how a landing5+ * happens (ADR 0014), one line per event a watcher hears, and the guides6+ * for the moments an answer goes sideways.7+ *8+ * Pure, and every name comes from `Brand`. The refusals come from the9+ * union and the events from a table the type holds to `ProjectEvent`, so a10+ * new tag cannot be missing; a guide names a command only when the catalog11+ * has it. Nothing here names a private repo, its files or its readers12+ * (AGENTS.md principle 7): the gateway lines below are the ones anyone13+ * outside one can meet.14+ */15+import { Brand } from "@repo/brand";16+import type { ProjectEvent } from "@repo/protocol/domain/event";17+import type { ProjectListing } from "@repo/protocol/domain/front-page";18+import { Option } from "effect";19+20+import type { CommandDoc } from "./command-doc.ts";21+import { frontLlms, typed, withCommand } from "./host-doc.ts";22+import { refusalCatalog } from "./refusals.ts";23+import { code, page, table } from "./text.ts";24+25+type Commands = readonly CommandDoc[];26+27+const cli = (...words: readonly string[]) => [Brand.cli, ...words].join(" ");28+29+const notesRef = `refs/notes/${Brand.slug}`;30+31+const pushAnswer = code(`git push ${Brand.slug} HEAD:main`);32+33+/** What the gateway says when git is not let in: `<reason>; sign in with <cli> login`. */34+const signIn = (reason: string) => `${reason}; sign in with ${cli("login")}`;35+36+// --- Refusals -----------------------------------------------------------------37+38+const refusals = () => [39+ "## Refusals",40+ "",41+ `Every refusal the platform gives, in every group of its closed union. Each has a \`_tag\`, \`retryable\` (whether trying the same thing again can help) and \`next\` (the command to run next), and no message: match on the tag. Git prints them on its \`remote:\` lines, ${code(cli("check"))} and ${code(cli("status"))} print them, an MCP tool returns them as JSON, and the verdict note holds them. The refusals about an answer's files arrive together, so one push hears about all of them.`,42+ "",43+ ...table(44+ ["`_tag`", "Group", "Retryable", "`next`", "What to do"],45+ refusalCatalog().map(({ group, next, retryable, tag, todo }) => [46+ code(tag),47+ group,48+ retryable ? "yes" : "no",49+ next,50+ todo,51+ ])52+ ),53+ "",54+];55+56+// --- Git here -------------------------------------------------------------------57+58+const gitHere = (platformUrl: string) => [59+ "## Git here",60+ "",61+ `Git reaches each repo at ${code(`${platformUrl}/<repo>.git`)} over smart HTTP and signs in with Basic auth. The password is your platform token, which ${code(cli("login"))} stores and hands to git through its credential helper. The username is an audit tag, ${code("audit;harness=<harness>")} (with ${code("&model=…")} and ${code("&session=…")} when the harness names them): it records which harness pushed and is never identity. The token alone says who you are.`,62+ "",63+ ...table(64+ ["Repo", "Name", "Who reads it", "Who pushes to it"],65+ [66+ [67+ "The project's",68+ code("<project>"),69+ "Anyone",70+ "No one: `main` moves only by a landing (the project's first push is its initializer's)",71+ ],72+ [73+ "A claim's fork",74+ code("<project>--<ask>--<handle>"),75+ "Signed-in people",76+ "Its claimant while the claim is live, and a decider who finishes the answer",77+ ],78+ [79+ "A working fork",80+ code("<project>--me--<handle>"),81+ "Signed-in people",82+ "Its owner",83+ ],84+ ]85+ ),86+ "",87+ `A fork's name spells the handle in lowercase. A fork takes branches only: push your answer with ${pushAnswer}. A push of a note, a tag or any other ref outside ${code("refs/heads/")} is refused whole with ${code("DirectPush")}, since the platform writes those refs itself.`,88+ "",89+ "After a push, read the verdict on your head in a clone of your fork. It is one JSON note per head: match on its `_tag`, and run a refusal's `next`. A newer verdict on the same head replaces its note.",90+ "",91+ "```sh",92+ `git fetch ${Brand.slug} ${notesRef}:${notesRef}`,93+ `git notes --ref=${Brand.slug} show <head>`,94+ "```",95+ "",96+ "When it does not let git in, the platform answers in plain text:",97+ "",98+ `- 401 ${code(signIn("a push needs a signed-in person"))}: a push without a token.`,99+ `- 401 ${code(signIn("a fork is read by signed-in people"))}: a fork read without a token.`,100+ `- 401 ${code(signIn("that token is not one we know"))}: the token expired or was revoked.`,101+ `- 404 ${code("no repo <name>")}: no repo you may reach has that name.`,102+ `- 404 ${code("not a git endpoint")}: the path is not one git asks for.`,103+ "",104+];105+106+// --- How a landing happens ----------------------------------------------------107+108+const landing = () => [109+ "## How a landing happens",110+ "",111+ "1. The platform checks the answer's merged tree: the ask's check and the project's lanes.",112+ "2. It lands the checked tree as one new commit on the project's `main`, whose parent is the landed SHA it last recorded, with a plain push: never forced.",113+ "3. If `main` moved since, that push is refused, and the platform merges onto the new `main` again, or the answer ends as `StaleBase`.",114+ "4. Only once `main` has moved does it write its bookkeeping, each in a push of its own: the ref that mirrors the landed SHA, then the verdict note. Either may trail `main` for a moment, and nothing decides by them.",115+ "5. A landing tried again finds its own commit on `main` by its `Request-Id` trailer and writes only what is missing, so it never makes a second commit.",116+ "",117+];118+119+// --- Events ---------------------------------------------------------------------120+121+/** What each event says happened, one line per tag of `ProjectEvent`. */122+const eventLines = {123+ AskClosed: "An ask closed, with the landing that answered it.",124+ AskOpened: "A new ask opened.",125+ Claimed: "Someone claimed an ask.",126+ Decided: "A decider took a decision.",127+ Judged: "An answer was checked, with the outcome its verdict holds.",128+ Landed: "A landing reached `main`.",129+ Lapsed: "A claim lapsed: no push for too long.",130+ LedgerAppended: "The project's public ledger gained an entry.",131+ ProposalDrafted:132+ "A proposal's draft settled: ready for a decider, or failed.",133+ ProposalOpened: "A proposal opened.",134+ Pushed: "A claimant pushed to their fork.",135+ Released: "A claim was released.",136+ Warned: "A claim was warned that it lapses without a push.",137+} as const satisfies Record<ProjectEvent["_tag"], string>;138+139+const events = () => [140+ "## Events",141+ "",142+ "A project's page follows its events as they happen (the `watch` contract). Each event carries `seq`, its place in the project's sequence, and `at`, its time; a watcher resumes after the last `seq` it saw.",143+ "",144+ ...Object.entries(eventLines).map(([tag, line]) => `- ${code(tag)}: ${line}`),145+ "",146+];147+148+// --- Guides ---------------------------------------------------------------------149+150+const guides = (commands: Commands, platformUrl: string) => [151+ "## Guides",152+ "",153+ "### Recover from `StaleBase`",154+ "",155+ `\`main\` moved under your answer, and the answer did not merge onto it. Rebase onto the new \`main\`, resolve what the rebase stops on, and push again: ${code(`git pull --rebase ${platformUrl}/<project>.git main`)}, then ${pushAnswer}.`,156+ "",157+ "### Follow an answer until it lands",158+ "",159+ ...withCommand(160+ typed(commands, "status", {}, ["project"]),161+ (each) => `- ${each} shows your claims and answers and where each stands.`162+ ),163+ ...withCommand(164+ typed(commands, "verdict", {}, ["project"]),165+ (each) => `- ${each} shows the verdict on an answer.`166+ ),167+ "- The project's events say when it was checked and when it landed (see Events).",168+ "- The verdict note on your head holds the verdict (see Git here).",169+ "",170+ ...Option.match(typed(commands, "submit", {}, ["project"]), {171+ onNone: () => [],172+ onSome: (each) => [173+ "### Offer the same answer again",174+ "",175+ `Offering an answer again (${each}) with the same \`requestId\` returns the same receipt: it is checked once, however many times it is offered.`,176+ "",177+ ],178+ }),179+ "### Resume on a new machine",180+ "",181+ `Clone your claim's fork, with your handle in lowercase: ${code(`git clone ${platformUrl}/<project>--<ask>--<handle>.git`)}.${withCommand(182+ typed(commands, "claim", {}, ["project"]),183+ (each) =>184+ ` Claiming the ask again (${each}) returns the claim you hold, with its remote.`185+ ).join("")}`,186+];187+188+/**189+ * `/llms-full.txt`: the index, then the refusals, git, landings, events190+ * and guides. The web serves it; the platform's `/` stays the index alone.191+ */192+export const fullLlms = (input: {193+ readonly commands: Commands;194+ readonly projects: readonly ProjectListing[];195+ readonly platformUrl: string;196+ readonly webUrl: string;197+}) =>198+ `${frontLlms(input)}\n${page([199+ ...refusals(),200+ ...gitHere(input.platformUrl),201+ ...landing(),202+ ...events(),203+ ...guides(input.commands, input.platformUrl),204+ ])}`;modified:packages/agent-kit/src/host-doc.ts+23 added-4 removed
4 unmodified lines5 * 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`.9+ * asks, and `mcpCard` its `/.well-known/mcp.json`. With a web app,10+ * `frontLlms` names `/llms-full.txt` (`full-llms.ts`), and `indexBanner`11+ * opens every other Markdown answer the web serves, so a reader that lands12+ * on one finds the rest.13 *14 * Pure: the hosts hand in what the platform lists and the CLI's commands15 * as this package's one list holds them, so no command is written here16 * by hand. A step names a command only when the catalog has it. Every67 unmodified lines84 ].join(" ");85 };86 87 /** `words` as typed, with `flags`, when the catalog has the command. */85-const typed = (88+export const typed = (89 commands: Commands,90 words: string,91 known: Known,92 flags: readonly ("ask" | "project")[] = []2 unmodified lines95 code(usage(command, known, flags))96 );97 98 /** The sentence `make` writes around a typed command, or nothing without it. */96-const withCommand = (99+export const withCommand = (100 command: Option.Option<string>,101 make: (typedCommand: string) => string102 ) => Option.toArray(Option.map(command, make));103 110 unmodified lines214 "",215 ...Option.match(webUrl, {216 onNone: () => [],217 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.`,218+ `The same facts read as Markdown: each project at ${web}/<project>/llms.txt, and each ask at ${web}/<project>/asks/<ask>.md. Every refusal, how git meets the platform, how a landing happens, the events and the guides are in ${web}/llms-full.txt.`,219 "",220 ],221 }),222 "## Install the CLI",55 unmodified lines278 279 const askLine = (webUrl: string, project: string, listing: AskListing) =>280 `- [${listing.ask}](${projectPage(webUrl, project)}/asks/${listing.ask}.md): ${[sentence(listing.want), ...askNotes(listing)].join(" ")}`;281 282+/**283+ * The line that opens a Markdown answer the web serves: where the index is,284+ * where the full text is, and, for a project's answer, the project's own285+ * index. One blockquote, so a reader that lands on any page finds the rest.286+ */287+export const indexBanner = (input: {288+ readonly webUrl: string;289+ readonly project?: ProjectName;290+}) => {291+ const { project, webUrl } = input;292+293+ return `> For agents: the index is ${webUrl}/llms.txt, and everything beyond it (refusals, git, landings, events, guides) is ${webUrl}/llms-full.txt${project === undefined ? "" : `; this project's index is ${projectPage(webUrl, project)}/llms.txt`}.`;294+};295+296 /** `/<project>/llms.txt`: the project, its posture, how to clone it, its open asks and how to take one. */297 export const projectLlms = (input: {298 readonly listing: ProjectListing;299 readonly asks: readonly AskListing[];4 unmodified lines304 const { asks, commands, listing, platformUrl, webUrl } = input;305 const { project } = listing;306 307 return page([308+ indexBanner({ project, webUrl }),309+ "",310 `# ${project}`,311 "",312 `> A project on ${Brand.name}. Posture: ${postureWords[listing.posture]}. ${counted(asks.length, "open ask")}.`,313 "",52 unmodified linesmodified:packages/agent-kit/src/refusals.ts+115 added-13 removed
1 unmodified line2 * The refusals an answer can meet, read from the closed union: each one's3 * tag, whether retrying can help and its `next` come from its schema, and4 * what to do about it from the table below, which the type holds to the5 * union's groups (a refusal added to one fails the typecheck until it has6- * a line here).6+ * a line here). `refusalCatalog` walks every group the same way, for7+ * `/llms-full.txt`, with a second table for the refusals no answer meets.8 */9 import { Brand } from "@repo/brand";10 import { groups } from "@repo/protocol/refusal";11 import { Exit, Predicate, SchemaAST } from "effect";19 unmodified lines31 >["members"][number];32 33 type AnswerTag = InstanceType<AnswerMember>["_tag"];34 35+type Tag = InstanceType<Member>["_tag"];36+37 /**38 * What to do on meeting it. A refusal whose `next` is set when it is raised39 * gives the command's form here, or what it names when no form fits.40 */64 unmodified lines105 VerifierBlocked: {106 todo: "Nothing: the platform could not run the checks, and runs them again.",107 },108 Weakened: {106- todo: "Take the marker out, or give it a reason for a decider to weigh; never raise a ratchet.",109+ todo: "Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet.",110 },111 } as const satisfies Record<AnswerTag, Repair>;112 113+/**114+ * What to do on meeting a refusal no answer meets: at an ask's opening, a115+ * maintainer's own push, a decision, a lookup, setup or the env.116+ */117+const elsewhere = {118+ DecisionClosed: {119+ todo: "Nothing to decide: it was taken already, or expired to its default.",120+ },121+ DraftInProgress: {122+ next: cli("proposal", "<proposal>"),123+ todo: "Wait: the platform is drafting this proposal's ask already, and `next` shows when it settles.",124+ },125+ ImportFailed: { todo: "Read `reason`, then import again." },126+ IncompleteBrief: {127+ todo: "Fill in the fields `missing` names: the ask's kind requires them.",128+ },129+ LayerContentInPublicTree: {130+ todo: "Take the paths it names out: their files stay private and never enter a public tree.",131+ },132+ NotDecider: {133+ todo: "Only one of the project's deciders may do this: ask one of them.",134+ },135+ NotRedFirst: {136+ todo: "Make the ask's check fail on main by an assertion, the same way twice, then open the ask again.",137+ },138+ NotSensitive: {139+ todo: "Only an `@sensitive` item holds a write-only value: `next` shows which items are.",140+ },141+ PostureChange: {142+ todo: "Wait for a decider to take the posture change it names (`from`, `to`); `next` lists the decisions waiting.",143+ },144+ ProjectExists: { todo: "Pick another name: that one is taken." },145+ ProposalClosed: {146+ todo: "Nothing more is drafted for it: the proposal was accepted, declined or expired.",147+ },148+ SecretInOutput: {149+ todo: "Take the write-only value of `item` out of the output or the tree (`where`), then check again.",150+ },151+ UnknownAsk: {152+ todo: "Check the ask's name: `next` lists the project's open asks.",153+ },154+ UnknownCommit: {155+ todo: "Fetch the project, then name a commit it holds.",156+ },157+ UnknownDecision: {158+ todo: "Check the decision's id: `next` lists the decisions waiting on you.",159+ },160+ UnknownEnvItem: {161+ todo: "Name a key the project's env shape has: `next` lists them.",162+ },163+ UnknownPath: {164+ todo: "Name a path the commit holds: `next` lists its files.",165+ },166+ UnknownProject: {167+ todo: "Check the project's name: every project is listed in the index.",168+ },169+ UnknownProposal: {170+ todo: "Check the proposal's id: `next` lists the proposals waiting on you.",171+ },172+ UnknownRevision: {173+ todo: "Name `main`, a commit the project holds or one of its tags: `next` lists its refs.",174+ },175+ UnstatedRequirement: {176+ todo: "State in public what the area's held-back check holds, or take the check out of the suite.",177+ },178+ ValueTooShort: {179+ nextNames: `${code(cli("env", "set", "<key>"))}, with ${code("--acknowledge-short")} when the value is above the floor`,180+ todo: "Give a longer value, or acknowledge a short one where the floor allows it.",181+ },182+ WeakCheck: {183+ todo: "Strengthen the check: as it stands, the trivial answer `weakness` names would pass it.",184+ },185+} as const satisfies Record<Exclude<Tag, AnswerTag>, Repair>;186+187 const repairOf = new Map<string, Repair>(Object.entries(repairs));188 189+const everyRepairOf = new Map<string, Repair>([190+ ...repairOf,191+ ...Object.entries(elsewhere),192+]);193+194 /** A field's value when the constructor fills it in, as it does a fixed `next`. */195 const constructorDefault = (ast: SchemaAST.AST) => {196 const fill = ast.context?.constructorDefault;197 23 unmodified lines221 ? (repair?.nextNames ?? "")222 : code(repair.next);223 };224 225+/** One member's row, from its schema and the repair `repairTable` gives it. */226+const rowOf = (227+ member: Member,228+ repairTable: ReadonlyMap<string, Repair>229+): AnswerRefusal => {230+ const { ast: retryable } = member.fields.retryable;231+ const fixed = constructorDefault(member.fields.next.ast);232+ const repair = repairTable.get(member.identifier);233+234+ return {235+ next: nextOf(fixed, repair),236+ retryable: SchemaAST.isLiteral(retryable) && retryable.literal === true,237+ tag: member.identifier,238+ todo: repair?.todo ?? "",239+ };240+};241+242 /** Every refusal an answer can meet, in the union's order. */243 export const answerRefusals: readonly AnswerRefusal[] = groups244 .flatMap((group): readonly Member[] =>245 answerGroups.some((answer) => answer === group.name) ? group.members : []246 )148- .map((member) => {149- const { ast: retryable } = member.fields.retryable;150- const fixed = constructorDefault(member.fields.next.ast);151- const repair = repairOf.get(member.identifier);247+ .map((member) => rowOf(member, repairOf));248 153- return {154- next: nextOf(fixed, repair),155- retryable: SchemaAST.isLiteral(retryable) && retryable.literal === true,156- tag: member.identifier,157- todo: repair?.todo ?? "",158- };159- });249+/** One refusal of the closed union, with the group the union files it under. */250+export interface CatalogRow extends AnswerRefusal {251+ readonly group: string;252+}253 254+/** Every refusal of the closed union, every group, in the union's order. */255+export const refusalCatalog = (): readonly CatalogRow[] =>256+ groups.flatMap((group) =>257+ group.members.map((member: Member) => ({258+ ...rowOf(member, everyRepairOf),259+ group: group.name,260+ }))261+ );262+263 /** The refusals section every skill carries. */264 export const refusalSection = () => [265 "## Refusals",266 "",13 unmodified linesmodified:packages/agent-kit/test/golden/agent-plugins-stdio.txt+1 added-1 removed
62 unmodified lines63 | `AskBlocked` | yes | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |64 | `Denounced` | no | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |65 | `OutOfScope` | no | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |66 | `TouchedJudge` | no | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |67-| `Weakened` | no | `__CLI__ check` | Take the marker out, or give it a reason for a decider to weigh; never raise a ratchet. |67+| `Weakened` | no | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |68 | `PrivatePathInPublicTree` | no | `__CLI__ check` | Take the held-back paths it names out of your answer. |69 | `ReachedInternals` | no | `__CLI__ check` | Import the other module only through its public files. |70 | `StaleBase` | yes | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |71 | `StaleLayer` | yes | `__CLI__ status` | Nothing: the answer is checked again. |26 unmodified linesmodified:packages/agent-kit/test/golden/agent-plugins.txt+1 added-1 removed
63 unmodified lines64 | `AskBlocked` | yes | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |65 | `Denounced` | no | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |66 | `OutOfScope` | no | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |67 | `TouchedJudge` | no | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |68-| `Weakened` | no | `__CLI__ check` | Take the marker out, or give it a reason for a decider to weigh; never raise a ratchet. |68+| `Weakened` | no | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |69 | `PrivatePathInPublicTree` | no | `__CLI__ check` | Take the held-back paths it names out of your answer. |70 | `ReachedInternals` | no | `__CLI__ check` | Import the other module only through its public files. |71 | `StaleBase` | yes | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |72 | `StaleLayer` | yes | `__CLI__ status` | Nothing: the answer is checked again. |23 unmodified linesmodified:packages/agent-kit/test/golden/claude-plugin-stdio.txt+1 added-1 removed
61 unmodified lines62 | `AskBlocked` | yes | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |63 | `Denounced` | no | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |64 | `OutOfScope` | no | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |65 | `TouchedJudge` | no | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |66-| `Weakened` | no | `__CLI__ check` | Take the marker out, or give it a reason for a decider to weigh; never raise a ratchet. |66+| `Weakened` | no | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |67 | `PrivatePathInPublicTree` | no | `__CLI__ check` | Take the held-back paths it names out of your answer. |68 | `ReachedInternals` | no | `__CLI__ check` | Import the other module only through its public files. |69 | `StaleBase` | yes | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |70 | `StaleLayer` | yes | `__CLI__ status` | Nothing: the answer is checked again. |61 unmodified linesmodified:packages/agent-kit/test/golden/claude-plugin.txt+1 added-1 removed
62 unmodified lines63 | `AskBlocked` | yes | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |64 | `Denounced` | no | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |65 | `OutOfScope` | no | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |66 | `TouchedJudge` | no | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |67-| `Weakened` | no | `__CLI__ check` | Take the marker out, or give it a reason for a decider to weigh; never raise a ratchet. |67+| `Weakened` | no | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |68 | `PrivatePathInPublicTree` | no | `__CLI__ check` | Take the held-back paths it names out of your answer. |69 | `ReachedInternals` | no | `__CLI__ check` | Import the other module only through its public files. |70 | `StaleBase` | yes | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |71 | `StaleLayer` | yes | `__CLI__ status` | Nothing: the answer is checked again. |59 unmodified linesadded:packages/agent-kit/test/golden/full-llms.txt+175 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. Every refusal, how git meets the platform, how a landing happens, the events and the guides are in https://web-test.example.workers.dev/llms-full.txt.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+- Skills: https://web-test.example.workers.dev/.well-known/agent-skills/index.json lists each project's contribute skill, with its digest.24+25+## Take an ask26+27+1. Find one: `__CLI__ front` lists the open asks across projects; `__CLI__ asks --project <project>` lists one project's.28+2. Read it: `__CLI__ ask <ask> --project <project>`.29+3. Claim it: `__CLI__ claim <ask> --project <project>`. The claim prints your fork's remote; add it with `git remote add __SLUG__ <remote>`.30+4. Change only the ask's territory, then run `__CLI__ check` and fix everything it reports.31+5. Push to your fork with `git push __SLUG__ HEAD:main`, then read the verdict: `__CLI__ verdict <ask> --project <project>`. A refusal names the command to run next.32+33+## Commands34+35+- `__CLI__ ask <ask>`: Show one ask in full. Only reads.36+- `__CLI__ asks`: List a project's open asks. Only reads.37+- `__CLI__ check`: Run the gate's checks on your answer locally. Only reads.38+- `__CLI__ claim <ask>`: Claim an ask.39+- `__CLI__ credential <operation>`: Answer git's credential helper.40+- `__CLI__ front`: List the open asks across every project. Only reads.41+- `__CLI__ login`: Sign in to a platform.42+- `__CLI__ status`: Show your claims and answers. Only reads.43+- `__CLI__ submit <ask>`: Offer a commit as an answer to a claimed ask.44+- `__CLI__ verdict <ask>`: 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.50+51+## Refusals52+53+Every refusal the platform gives, in every group of its closed union. Each has a `_tag`, `retryable` (whether trying the same thing again can help) and `next` (the command to run next), and no message: match on the tag. Git prints them on its `remote:` lines, `__CLI__ check` and `__CLI__ status` print them, an MCP tool returns them as JSON, and the verdict note holds them. The refusals about an answer's files arrive together, so one push hears about all of them.54+55+| `_tag` | Group | Retryable | `next` | What to do |56+| --- | --- | --- | --- | --- |57+| `NotClaimed` | Push and claim | yes | `__CLI__ claim <ask>` | Claim the ask, then push again. |58+| `ClaimLapsed` | Push and claim | yes | `__CLI__ claim <ask>` | Your claim lapsed after a spell without a push: claim the ask again if it is still open. |59+| `NotVouched` | Push and claim | no | `__CLI__ status` | Ask a member of the project to vouch for you. |60+| `CapReached` | Push and claim | yes | `__CLI__ status` | Read `limit`: for claims, release or land a claim you hold; for proposals, wait for an open one to be decided; for drafts, the proposal has had every draft round it takes; with `retryAfter`, wait that many seconds and try again. |61+| `AskFull` | Push and claim | yes | `__CLI__ asks` | Someone else holds the claim: pick another ask. |62+| `NoAsk` | Push and claim | no | `__CLI__ asks` | Push to the fork your claim gave you, which names its ask. |63+| `RepoBusy` | Push and claim | yes | `git push` | Push again. |64+| `DirectPush` | Push and claim | no | `__CLI__ asks` | Main moves only by a landing: push your answer to your claim's fork. |65+| `AskBlocked` | Push and claim | yes | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |66+| `Denounced` | Push and claim | no | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |67+| `OutOfScope` | Shape | no | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |68+| `TouchedJudge` | Shape | no | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |69+| `Weakened` | Shape | no | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |70+| `PrivatePathInPublicTree` | Shape | no | `__CLI__ check` | Take the held-back paths it names out of your answer. |71+| `ReachedInternals` | Shape | no | `__CLI__ check` | Import the other module only through its public files. |72+| `StaleBase` | Merge | yes | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |73+| `StaleLayer` | Merge | yes | `__CLI__ status` | Nothing: the answer is checked again. |74+| `ChecksFailed` | Checks | no | the command that reproduces the failure | Run `next` to see the failure, fix it, and push again. |75+| `HeldBackFailed` | Checks | no | `__CLI__ status` | A held-back check failed; you see only its area and suite. Fix the behaviour and push again. |76+| `AttemptsExhausted` | Checks | yes | `__CLI__ status` | Wait until `resetsAt`: you used every attempt on that area's held-back checks for now. |77+| `Flake` | Never counted against the answerer | yes | `__CLI__ status` | Nothing: the check failed and then passed on the same tree, and the platform runs it again. |78+| `VerifierBlocked` | Never counted against the answerer | yes | `__CLI__ status` | Nothing: the platform could not run the checks, and runs them again. |79+| `NotRedFirst` | At ask open | no | `__CLI__ check` | Make the ask's check fail on main by an assertion, the same way twice, then open the ask again. |80+| `WeakCheck` | At ask open | no | `__CLI__ check` | Strengthen the check: as it stands, the trivial answer `weakness` names would pass it. |81+| `IncompleteBrief` | At ask open | no | `__CLI__ check` | Fill in the fields `missing` names: the ask's kind requires them. |82+| `LayerContentInPublicTree` | Maintainers only | no | `__CLI__ check` | Take the paths it names out: their files stay private and never enter a public tree. |83+| `SecretInOutput` | Maintainers only | no | `__CLI__ check` | Take the write-only value of `item` out of the output or the tree (`where`), then check again. |84+| `UnstatedRequirement` | Maintainers only | no | `__CLI__ check` | State in public what the area's held-back check holds, or take the check out of the suite. |85+| `PostureChange` | Decision | no | `__CLI__ today` | Wait for a decider to take the posture change it names (`from`, `to`); `next` lists the decisions waiting. |86+| `NotDecider` | Decision | no | `__CLI__ status` | Only one of the project's deciders may do this: ask one of them. |87+| `DecisionClosed` | Decision | no | `__CLI__ today` | Nothing to decide: it was taken already, or expired to its default. |88+| `ProposalClosed` | Decision | no | `__CLI__ today` | Nothing more is drafted for it: the proposal was accepted, declined or expired. |89+| `DraftInProgress` | Decision | yes | `__CLI__ proposal <proposal>` | Wait: the platform is drafting this proposal's ask already, and `next` shows when it settles. |90+| `UnknownProject` | Lookup | no | `__CLI__ asks` | Check the project's name: every project is listed in the index. |91+| `UnknownAsk` | Lookup | no | `__CLI__ asks` | Check the ask's name: `next` lists the project's open asks. |92+| `UnknownCommit` | Lookup | no | `git fetch` | Fetch the project, then name a commit it holds. |93+| `UnknownDecision` | Lookup | no | `__CLI__ today` | Check the decision's id: `next` lists the decisions waiting on you. |94+| `UnknownPath` | Lookup | no | `git ls-tree` | Name a path the commit holds: `next` lists its files. |95+| `UnknownRevision` | Lookup | no | `git ls-remote` | Name `main`, a commit the project holds or one of its tags: `next` lists its refs. |96+| `UnknownProposal` | Lookup | no | `__CLI__ today` | Check the proposal's id: `next` lists the proposals waiting on you. |97+| `ProjectExists` | Setup | no | `__CLI__ asks` | Pick another name: that one is taken. |98+| `ImportFailed` | Setup | yes | `__CLI__ init` | Read `reason`, then import again. |99+| `UnknownEnvItem` | Env | no | `__CLI__ env shape` | Name a key the project's env shape has: `next` lists them. |100+| `NotSensitive` | Env | no | `__CLI__ env shape` | Only an `@sensitive` item holds a write-only value: `next` shows which items are. |101+| `ValueTooShort` | Env | no | `__CLI__ env set <key>`, with `--acknowledge-short` when the value is above the floor | Give a longer value, or acknowledge a short one where the floor allows it. |102+103+## Git here104+105+Git reaches each repo at `https://platform-test.example.workers.dev/<repo>.git` over smart HTTP and signs in with Basic auth. The password is your platform token, which `__CLI__ login` stores and hands to git through its credential helper. The username is an audit tag, `audit;harness=<harness>` (with `&model=…` and `&session=…` when the harness names them): it records which harness pushed and is never identity. The token alone says who you are.106+107+| Repo | Name | Who reads it | Who pushes to it |108+| --- | --- | --- | --- |109+| The project's | `<project>` | Anyone | No one: `main` moves only by a landing (the project's first push is its initializer's) |110+| A claim's fork | `<project>--<ask>--<handle>` | Signed-in people | Its claimant while the claim is live, and a decider who finishes the answer |111+| A working fork | `<project>--me--<handle>` | Signed-in people | Its owner |112+113+A fork's name spells the handle in lowercase. A fork takes branches only: push your answer with `git push __SLUG__ HEAD:main`. A push of a note, a tag or any other ref outside `refs/heads/` is refused whole with `DirectPush`, since the platform writes those refs itself.114+115+After a push, read the verdict on your head in a clone of your fork. It is one JSON note per head: match on its `_tag`, and run a refusal's `next`. A newer verdict on the same head replaces its note.116+117+```sh118+git fetch __SLUG__ refs/notes/__SLUG__:refs/notes/__SLUG__119+git notes --ref=__SLUG__ show <head>120+```121+122+When it does not let git in, the platform answers in plain text:123+124+- 401 `a push needs a signed-in person; sign in with __SLUG__ login`: a push without a token.125+- 401 `a fork is read by signed-in people; sign in with __SLUG__ login`: a fork read without a token.126+- 401 `that token is not one we know; sign in with __SLUG__ login`: the token expired or was revoked.127+- 404 `no repo <name>`: no repo you may reach has that name.128+- 404 `not a git endpoint`: the path is not one git asks for.129+130+## How a landing happens131+132+1. The platform checks the answer's merged tree: the ask's check and the project's lanes.133+2. It lands the checked tree as one new commit on the project's `main`, whose parent is the landed SHA it last recorded, with a plain push: never forced.134+3. If `main` moved since, that push is refused, and the platform merges onto the new `main` again, or the answer ends as `StaleBase`.135+4. Only once `main` has moved does it write its bookkeeping, each in a push of its own: the ref that mirrors the landed SHA, then the verdict note. Either may trail `main` for a moment, and nothing decides by them.136+5. A landing tried again finds its own commit on `main` by its `Request-Id` trailer and writes only what is missing, so it never makes a second commit.137+138+## Events139+140+A project's page follows its events as they happen (the `watch` contract). Each event carries `seq`, its place in the project's sequence, and `at`, its time; a watcher resumes after the last `seq` it saw.141+142+- `AskClosed`: An ask closed, with the landing that answered it.143+- `AskOpened`: A new ask opened.144+- `Claimed`: Someone claimed an ask.145+- `Decided`: A decider took a decision.146+- `Judged`: An answer was checked, with the outcome its verdict holds.147+- `Landed`: A landing reached `main`.148+- `Lapsed`: A claim lapsed: no push for too long.149+- `LedgerAppended`: The project's public ledger gained an entry.150+- `ProposalDrafted`: A proposal's draft settled: ready for a decider, or failed.151+- `ProposalOpened`: A proposal opened.152+- `Pushed`: A claimant pushed to their fork.153+- `Released`: A claim was released.154+- `Warned`: A claim was warned that it lapses without a push.155+156+## Guides157+158+### Recover from `StaleBase`159+160+`main` moved under your answer, and the answer did not merge onto it. Rebase onto the new `main`, resolve what the rebase stops on, and push again: `git pull --rebase https://platform-test.example.workers.dev/<project>.git main`, then `git push __SLUG__ HEAD:main`.161+162+### Follow an answer until it lands163+164+- `__CLI__ status --project <project>` shows your claims and answers and where each stands.165+- `__CLI__ verdict <ask> --project <project>` shows the verdict on an answer.166+- The project's events say when it was checked and when it landed (see Events).167+- The verdict note on your head holds the verdict (see Git here).168+169+### Offer the same answer again170+171+Offering an answer again (`__CLI__ submit <ask> --project <project>`) with the same `requestId` returns the same receipt: it is checked once, however many times it is offered.172+173+### Resume on a new machine174+175+Clone your claim's fork, with your handle in lowercase: `git clone https://platform-test.example.workers.dev/<project>--<ask>--<handle>.git`. Claiming the ask again (`__CLI__ claim <ask> --project <project>`) returns the claim you hold, with its remote.modified:packages/agent-kit/test/golden/host-doc.txt+1 added-1 removed
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.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. Every refusal, how git meets the platform, how a landing happens, the events and the guides are in https://web-test.example.workers.dev/llms-full.txt.6 7 ## Install the CLI8 9 ```sh40 unmodified linesmodified:packages/agent-kit/test/golden/platform-skill.txt+1 added-1 removed
55 unmodified lines56 | `AskBlocked` | yes | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |57 | `Denounced` | no | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |58 | `OutOfScope` | no | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |59 | `TouchedJudge` | no | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |60-| `Weakened` | no | `__CLI__ check` | Take the marker out, or give it a reason for a decider to weigh; never raise a ratchet. |60+| `Weakened` | no | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |61 | `PrivatePathInPublicTree` | no | `__CLI__ check` | Take the held-back paths it names out of your answer. |62 | `ReachedInternals` | no | `__CLI__ check` | Import the other module only through its public files. |63 | `StaleBase` | yes | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |64 | `StaleLayer` | yes | `__CLI__ status` | Nothing: the answer is checked again. |12 unmodified linesmodified:packages/agent-kit/test/golden/project-skill.txt+2 added-2 removed
89 unmodified lines90 | `AskBlocked` | yes | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |91 | `Denounced` | no | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |92 | `OutOfScope` | no | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |93 | `TouchedJudge` | no | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |94-| `Weakened` | no | `__CLI__ check` | Take the marker out, or give it a reason for a decider to weigh; never raise a ratchet. |94+| `Weakened` | no | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |95 | `PrivatePathInPublicTree` | no | `__CLI__ check` | Take the held-back paths it names out of your answer. |96 | `ReachedInternals` | no | `__CLI__ check` | Import the other module only through its public files. |97 | `StaleBase` | yes | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |98 | `StaleLayer` | yes | `__CLI__ status` | Nothing: the answer is checked again. |102 unmodified lines201 | `AskBlocked` | yes | `__CLI__ asks` | Wait for the asks it names to land, or answer one of them first. |202 | `Denounced` | no | `__CLI__ status` | The project's vouch file denounces you: it takes no claims or proposals from you. |203 | `OutOfScope` | no | `__CLI__ check` | Undo your changes to the paths it names: they are outside the ask's territory. |204 | `TouchedJudge` | no | `__CLI__ check` | Undo your changes to the paths it names: they decide what the checks do. |205-| `Weakened` | no | `__CLI__ check` | Take the marker out, or give it a reason for a decider to weigh; never raise a ratchet. |205+| `Weakened` | no | `__CLI__ check` | Take the marker out; a marker without a reason may get one after ` -- ` for a decider to weigh, but one a decider declined stays out; never raise a ratchet. |206 | `PrivatePathInPublicTree` | no | `__CLI__ check` | Take the held-back paths it names out of your answer. |207 | `ReachedInternals` | no | `__CLI__ check` | Import the other module only through its public files. |208 | `StaleBase` | yes | `git pull --rebase` | Main moved: rebase onto it, resolve the conflicts it names, and push again. |209 | `StaleLayer` | yes | `__CLI__ status` | Nothing: the answer is checked again. |12 unmodified linesadded:packages/agent-kit/test/full-llms.test.ts+233 added
1+/**2+ * `/llms-full.txt`: what an agent needs beyond the index. `frontLlms`'3+ * text, then every refusal of the closed union, how git meets the4+ * platform, how a landing happens, every event a watcher hears, and the5+ * guides for the moments an answer goes sideways. A pure function of the6+ * CLI's commands, the listed projects and the two hosts' URLs.7+ */8+import { NodeServices } from "@effect/platform-node";9+import { describe, expect, it } from "@effect/vitest";10+import { Brand } from "@repo/brand";11+import type { ProjectEvent } from "@repo/protocol/domain/event";12+import type { ProjectListing } from "@repo/protocol/domain/front-page";13+import { ProjectName } from "@repo/protocol/ids";14+import { groups } from "@repo/protocol/refusal";15+import { Effect } from "effect";16+17+import type { CommandDoc } from "../src/command-doc.ts";18+import { fullLlms } from "../src/full-llms.ts";19+import { frontLlms } from "../src/host-doc.ts";20+import { expectGolden } from "./golden.ts";21+22+const platformUrl = "https://platform-test.example.workers.dev";23+24+const webUrl = "https://web-test.example.workers.dev";25+26+/** A command row as the command list holds it. */27+const row = (28+ path: readonly [string, ...string[]],29+ summary: string,30+ more: Partial<CommandDoc> = {}31+): CommandDoc => ({32+ flags: ["--json"],33+ needsApproval: false,34+ path,35+ positional: [],36+ readOnly: true,37+ source: "contract",38+ summary,39+ ...more,40+});41+42+const commands: readonly CommandDoc[] = [43+ row(["ask"], "Show one ask in full.", {44+ flags: ["--project", "--json"],45+ positional: ["ask"],46+ }),47+ row(["asks"], "List a project's open asks.", {48+ flags: ["--project", "--json"],49+ }),50+ row(["check"], "Run the gate's checks on your answer locally.", {51+ flags: ["--ask", "--project", "--json"],52+ source: "local",53+ }),54+ row(["claim"], "Claim an ask.", {55+ flags: ["--project", "--json", "--dry-run"],56+ positional: ["ask"],57+ readOnly: false,58+ }),59+ row(["credential"], "Answer git's credential helper.", {60+ flags: [],61+ positional: ["operation"],62+ readOnly: false,63+ source: "local",64+ }),65+ row(["front"], "List the open asks across every project."),66+ row(["login"], "Sign in to a platform.", {67+ flags: ["--url", "--json"],68+ readOnly: false,69+ source: "local",70+ }),71+ row(["status"], "Show your claims and answers.", {72+ flags: ["--project", "--json"],73+ }),74+ row(["submit"], "Offer a commit as an answer to a claimed ask.", {75+ flags: ["--base", "--head", "--project", "--requestId", "--json"],76+ positional: ["ask"],77+ readOnly: false,78+ }),79+ row(["verdict"], "Show the verdict on an answer to an ask.", {80+ flags: ["--head", "--project", "--json"],81+ positional: ["ask"],82+ }),83+];84+85+const projects: readonly ProjectListing[] = [86+ { openAsks: 3, posture: "open", project: ProjectName.make("datekit") },87+ {88+ openAsks: 1,89+ posture: "openWithSealedEvidence",90+ project: ProjectName.make("burrow"),91+ },92+];93+94+const input = { commands, platformUrl, projects, webUrl };95+96+const text = fullLlms(input);97+98+const lines = text.split("\n");99+100+/** The lines of the section headed `## <title>`, up to the next `## `. */101+const section = (title: string) => {102+ const start = lines.indexOf(`## ${title}`);103+ const rest = lines.slice(start + 1);104+ const end = rest.findIndex((line) => line.startsWith("## "));105+106+ expect(start, `no section ${title}`).toBeGreaterThanOrEqual(0);107+108+ return end === -1 ? rest : rest.slice(0, end);109+};110+111+// Every event's tag, written out here so the test is not the code's own table.112+const eventTags: readonly ProjectEvent["_tag"][] = [113+ "AskClosed",114+ "AskOpened",115+ "Claimed",116+ "Decided",117+ "Judged",118+ "Landed",119+ "Lapsed",120+ "LedgerAppended",121+ "ProposalDrafted",122+ "ProposalOpened",123+ "Pushed",124+ "Released",125+ "Warned",126+];127+128+describe(fullLlms, () => {129+ it.effect("is the text the web serves at /llms-full.txt", () =>130+ expectGolden("full-llms", text).pipe(Effect.provide(NodeServices.layer))131+ );132+133+ it("starts with the index's own text for the same input", () => {134+ expect(text.startsWith(frontLlms(input))).toBeTruthy();135+ expect(text.length).toBeGreaterThan(frontLlms(input).length);136+ });137+138+ it("has a row for every refusal of the union, in every group", () => {139+ const refusals = section("Refusals");140+141+ const missing = groups.flatMap((group) =>142+ group.members143+ .map((member) => member.identifier)144+ .filter(145+ (tag) =>146+ !refusals.some((line) =>147+ line.startsWith(`| \`${tag}\` | ${group.name} |`)148+ )149+ )150+ );151+152+ expect(missing).toStrictEqual([]);153+ });154+155+ it("gives the next command a refusal fixes when it is raised", () => {156+ const refusals = section("Refusals");157+158+ expect(refusals).toContainEqual(159+ expect.stringMatching(160+ new RegExp(161+ `^\\| \`UnknownAsk\` \\| Lookup \\| no \\| \`${Brand.cli} asks\` \\| .+ \\|$`,162+ "u"163+ )164+ )165+ );166+ expect(refusals).toContainEqual(167+ expect.stringMatching(168+ new RegExp(169+ `^\\| \`DraftInProgress\` \\| Decision \\| yes \\| \`${Brand.cli} proposal <proposal>\` \\| .+ \\|$`,170+ "u"171+ )172+ )173+ );174+ });175+176+ it("has a line for every event a watcher hears", () => {177+ const events = section("Events");178+179+ expect(180+ eventTags.filter(181+ (tag) => !events.some((line) => line.startsWith(`- \`${tag}\`: `))182+ )183+ ).toStrictEqual([]);184+ });185+186+ it("names the repos a person meets by their patterns", () => {187+ const git = section("Git here");188+189+ expect(git).toContainEqual(expect.stringContaining("`<project>`"));190+ expect(git).toContainEqual(191+ expect.stringContaining("`<project>--<ask>--<handle>`")192+ );193+ expect(git).toContainEqual(194+ expect.stringContaining("`<project>--me--<handle>`")195+ );196+ });197+198+ it("reads the verdict note with plain git", () => {199+ const ref = `refs/notes/${Brand.slug}`;200+201+ expect(lines).toContain(`git fetch ${Brand.slug} ${ref}:${ref}`);202+ expect(lines).toContain(`git notes --ref=${Brand.slug} show <head>`);203+ });204+205+ it("says what the gateway answers when git is not let in", () => {206+ const git = section("Git here");207+208+ expect(git).toContainEqual(209+ expect.stringContaining(210+ `\`a push needs a signed-in person; sign in with ${Brand.cli} login\``211+ )212+ );213+ expect(git).toContainEqual(expect.stringContaining("`no repo <name>`"));214+ });215+216+ it("names only commands the catalog has in its guides", () => {217+ const without = fullLlms({218+ ...input,219+ commands: commands.filter(({ path }) => path[0] !== "submit"),220+ });221+222+ expect(section("Guides").join("\n")).toContain(`${Brand.cli} submit`);223+ expect(without).not.toContain(`${Brand.cli} submit`);224+ });225+226+ it("names no layer: only the refusal tags that say the word", () => {227+ const tagged = text228+ .replaceAll("`StaleLayer`", "")229+ .replaceAll("`LayerContentInPublicTree`", "");230+231+ expect(tagged).not.toMatch(/layer/iu);232+ });233+});modified:packages/agent-kit/test/host-doc.test.ts+57 added-1 removed
10 unmodified lines11 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";15+import { frontLlms, indexBanner, projectLlms } from "../src/host-doc.ts";16 import { expectGolden } from "./golden.ts";17 18 const platformUrl = "https://platform-test.example.workers.dev";19 110 unmodified lines130 lines.filter((line) => line.startsWith(`- \`${Brand.cli} `))131 ).toHaveLength(commands.length);132 });133 });134+135+ it("with a web app, names /llms-full.txt in its opening sentence", () => {136+ const lines = linesOf(137+ frontLlms({ commands, platformUrl, projects, webUrl })138+ );139+140+ expect(lines[4]).toContain(`${webUrl}/llms-full.txt`);141+ });142+143+ it("without a web app, names no /llms-full.txt", () => {144+ expect(frontLlms({ commands, platformUrl, projects })).not.toContain(145+ "llms-full.txt"146+ );147+ });148 });149+150+describe("the index banner", () => {151+ it("is one blockquote naming the index and the full text", () => {152+ const banner = indexBanner({ webUrl });153+154+ expect(banner.split("\n")).toHaveLength(1);155+ expect(banner.startsWith("> ")).toBeTruthy();156+ expect(banner).toContain(`${webUrl}/llms.txt`);157+ expect(banner).toContain(`${webUrl}/llms-full.txt`);158+ });159+160+ it("names a project's own index when it has one", () => {161+ expect(162+ indexBanner({ project: ProjectName.make("datekit"), webUrl })163+ ).toContain(`${webUrl}/datekit/llms.txt`);164+ });165+166+ it("opens a project's llms.txt, then its heading", () => {167+ const lines = linesOf(168+ projectLlms({169+ asks: [],170+ commands,171+ listing: projects[0] ?? {172+ openAsks: 0,173+ posture: "open",174+ project: ProjectName.make("datekit"),175+ },176+ platformUrl,177+ webUrl,178+ })179+ );180+181+ expect(lines.slice(0, 3)).toStrictEqual([182+ indexBanner({ project: ProjectName.make("datekit"), webUrl }),183+ "",184+ "# datekit",185+ ]);186+ expect(lines[0]).toContain(`${webUrl}/llms.txt`);187+ expect(lines[0]).toContain(`${webUrl}/llms-full.txt`);188+ expect(lines[0]).toContain(`${webUrl}/datekit/llms.txt`);189+ });190+});