host-doc.test.ts
This file
Path
packages/agent-kit/test/host-doc.test.ts
219 lines · 6.6 KiB · TypeScript
Last changed by
Merge build/comments-packages-rest into mainoscabrielbefore adoption38cd503
History of this fileTake it
Merge branch 'build/906-platform-root-page'oscabrielbefore adoption10c8b54
lines 1–8why, one step back1import { NodeServices } from "@effect/platform-node";2import { describe, expect, it } from "@effect/vitest";3import { Brand } from "@repo/brand";4import type { ProjectListing } from "@repo/protocol/domain/front-page";5import { ProjectName } from "@repo/protocol/ids";6import { Effect } from "effect";78import type { CommandDoc } from "../src/command-doc.ts";Merge fix/banner-below-title into mainoscabrielbefore adoptionca95612
lines 9–14why, one step back9import {10 frontLlms,11 indexBanner,12 projectLlms,13 underTitle,14} from "../src/host-doc.ts";Merge branch 'build/906-platform-root-page'oscabrielbefore adoption10c8b54
lines 15–77why, one step back15import { expectGolden } from "./golden.ts";1617const platformUrl = "https://platform-test.example.workers.dev";1819const webUrl = "https://web-test.example.workers.dev";2021const row = (22 path: readonly [string, ...string[]],23 summary: string,24 more: Partial<CommandDoc> = {}25): CommandDoc => ({26 flags: ["--json"],27 needsApproval: false,28 path,29 positional: [],30 readOnly: true,31 source: "contract",32 summary,33 ...more,34});3536const commands: readonly CommandDoc[] = [37 row(38 ["ask"],39 "Show one ask in full, with its brief in Markdown for an answerer to read first.",40 { flags: ["--project", "--json"], positional: ["ask"] }41 ),42 row(["asks"], "List a project's open asks.", {43 flags: ["--project", "--json"],44 }),45 row(["check"], "Run the gate's checks on your answer locally.", {46 flags: ["--ask", "--project", "--json"],47 source: "local",48 }),49 row(["claim"], "Claim an ask: an exclusive, expiring right to answer it.", {50 flags: ["--project", "--json", "--dry-run"],51 positional: ["ask"],52 readOnly: false,53 }),54 row(["env", "set"], "Set a sensitive env item's value from stdin.", {55 flags: ["--project", "--yes"],56 needsApproval: true,57 positional: ["key"],58 readOnly: false,59 source: "local",60 }),61 row(["front"], "List the open asks across every project."),62 row(["login"], "Sign in to a platform.", {63 flags: ["--url", "--json"],64 readOnly: false,65 source: "local",66 }),67 row(["mcp"], "Serve the platform's tools over MCP on stdio.", {68 flags: [],69 source: "local",70 }),71 row(["verdict"], "Show the verdict on an answer to an ask.", {72 flags: ["--ask", "--head", "--project", "--json"],73 }),74];7576const projects: readonly ProjectListing[] = [77 {Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
lines 78–82why, one step back78 openAsks: 3,79 posture: "open",80 project: ProjectName.make("oscabriel/datekit"),81 },82 {Merge branch 'build/906-platform-root-page'oscabrielbefore adoption10c8b54
lines 83–84why, one step back83 openAsks: 1,84 posture: "openWithSealedEvidence",Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 85why, one step back85 project: ProjectName.make("oscabriel/burrow"),Merge branch 'build/906-platform-root-page'oscabrielbefore adoption10c8b54
lines 86–114why, one step back86 },87];8889const linesOf = (text: string) => text.split("\n");9091describe("the host's Markdown", () => {92 it.effect("with a web app, is the text the web served at /llms.txt", () =>93 expectGolden(94 "host-doc",95 frontLlms({ commands, platformUrl, projects, webUrl })96 ).pipe(Effect.provide(NodeServices.layer))97 );9899 describe("without a web app", () => {100 const text = frontLlms({ commands, platformUrl, projects });101 const lines = linesOf(text);102103 it("installs the CLI and finds the skills on the platform itself", () => {104 expect(lines).toContain(`curl -fsSL ${platformUrl}/install.sh | sh`);105 expect(lines).toContain(106 `- Skills: ${platformUrl}/.well-known/agent-skills/index.json lists each project's contribute skill, with its digest.`107 );108 expect(lines).toContain(109 `- Endpoint: ${platformUrl}/mcp (streamable HTTP, MCP 2026-07-28).`110 );111 });112113 it("gives each project's clone URL in place of a web page", () => {114 expect(lines).toContain(Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 115why, one step back115 `- oscabriel/datekit: Open, 3 open asks. Clone: \`git clone ${platformUrl}/oscabriel/datekit.git\`.`Merge branch 'build/906-platform-root-page'oscabrielbefore adoption10c8b54
lines 116–117why, one step back116 );117 expect(lines).toContain(Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 118why, one step back118 `- oscabriel/burrow: Open with sealed evidence, 1 open ask. Clone: \`git clone ${platformUrl}/oscabriel/burrow.git\`.`Merge branch 'build/906-platform-root-page'oscabrielbefore adoption10c8b54
lines 119–121why, one step back119 );120 });121Merge build/1413-docs-and-texts into mainoscabrielbefore adoptionf10338e
lines 122–126why, one step back122 it("spells a project as <owner>/<name>, never <project>", () => {123 expect(text).not.toContain("<project>");124 expect(text).toContain("--project <owner>/<name>");125 });126Merge branch 'build/906-platform-root-page'oscabrielbefore adoption10c8b54
lines 127–138why, one step back127 it("names no page only a web app serves", () => {128 expect(text).not.toContain("llms.txt");129 expect(text).not.toContain("mcp.json");130 expect(text).not.toContain(".md");131 });132133 it("still opens with the name and lists every command", () => {134 expect(lines[0]).toBe(`# ${Brand.name}`);135 expect(136 lines.filter((line) => line.startsWith(`- \`${Brand.cli} `))137 ).toHaveLength(commands.length);138 });Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 139–153why, one step back139 });140141 it("with a web app, names /llms-full.txt in its opening sentence", () => {142 const lines = linesOf(143 frontLlms({ commands, platformUrl, projects, webUrl })144 );145146 expect(lines[4]).toContain(`${webUrl}/llms-full.txt`);147 });148149 it("without a web app, names no /llms-full.txt", () => {150 expect(frontLlms({ commands, platformUrl, projects })).not.toContain(151 "llms-full.txt"152 );153 });Merge build/1313-docs into mainoscabrielbefore adoption9000f4e
lines 154–166why, one step back154155 it("with a web app, names the docs for people under its opening", () => {156 const lines = linesOf(157 frontLlms({ commands, platformUrl, projects, webUrl })158 );159160 expect(lines[6]).toBe(161 `Guides and a reference written for people are at ${webUrl}/docs, each page also as Markdown at ${webUrl}/docs/<page>.md.`162 );163 expect(frontLlms({ commands, platformUrl, projects })).not.toContain(164 "/docs"165 );166 });Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 167–178why, one step back167});168169describe("the index banner", () => {170 it("is one blockquote naming the index and the full text", () => {171 const banner = indexBanner({ webUrl });172173 expect(banner.split("\n")).toHaveLength(1);174 expect(banner.startsWith("> ")).toBeTruthy();175 expect(banner).toContain(`${webUrl}/llms.txt`);176 expect(banner).toContain(`${webUrl}/llms-full.txt`);177 });178Merge fix/banner-below-title into mainoscabrielbefore adoptionca95612
lines 179–189why, one step back179 it("goes under a page's title, and on top of a page without one", () => {180 const banner = indexBanner({ webUrl });181182 expect(underTitle("# A title\n\nThe body.\n", banner)).toBe(183 `# A title\n\n${banner}\n\nThe body.\n`184 );185 expect(underTitle("No title here.\n", banner)).toBe(186 `${banner}\n\nNo title here.\n`187 );188 });189Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 190–191why, one step back190 it("names a project's own index when it has one", () => {191 expect(Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
lines 192–193why, one step back192 indexBanner({ project: ProjectName.make("oscabriel/datekit"), webUrl })193 ).toContain(`${webUrl}/oscabriel/datekit/llms.txt`);Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 194–195why, one step back194 });195Merge fix/banner-below-title into mainoscabrielbefore adoptionca95612
line 196why, one step back196 it("follows a project's heading and summary in its llms.txt", () => {Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 197–203why, one step back197 const lines = linesOf(198 projectLlms({199 asks: [],200 commands,201 listing: projects[0] ?? {202 openAsks: 0,203 posture: "open",Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 204why, one step back204 project: ProjectName.make("oscabriel/datekit"),Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 205–210why, one step back205 },206 platformUrl,207 webUrl,208 })209 );210Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 211why, one step back211 expect(lines[0]).toBe("# oscabriel/datekit");Merge fix/banner-below-title into mainoscabrielbefore adoptionca95612
lines 212–214why, one step back212 expect(lines[2]?.startsWith("> A project on ")).toBeTruthy();213 expect(lines.slice(3, 6)).toStrictEqual([214 "",Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 215why, one step back215 indexBanner({ project: ProjectName.make("oscabriel/datekit"), webUrl }),Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 216–217why, one step back216 "",217 ]);Merge branch 'build/906-platform-root-page'oscabrielbefore adoption10c8b54
lines 218–219why, one step back218 });219});