full-llms.test.ts
This file
Path
packages/agent-kit/test/full-llms.test.ts
254 lines · 7.4 KiB · TypeScript
Last changed by
Merge redesign into mainoscabrielbefore adoptioncaedd21
History of this fileTake it
Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 1–5why, one step back1import { NodeServices } from "@effect/platform-node";2import { describe, expect, it } from "@effect/vitest";3import { Brand } from "@repo/brand";4import type { ProjectEvent } from "@repo/protocol/domain/event";5import type { ProjectListing } from "@repo/protocol/domain/front-page";Merge redesign into mainoscabrielbefore adoptioncaedd21
line 6why, one step back6import { RECENT_LANDINGS_CAP } from "@repo/protocol/domain/recent-landing";Merge cli/exit-codes into mainoscabrielbefore adoptionc19a862
line 7why, one step back7import { ExitCode } from "@repo/protocol/exit-code";Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 8–80why, one step back8import { ProjectName } from "@repo/protocol/ids";9import { groups } from "@repo/protocol/refusal";10import { Effect } from "effect";1112import type { CommandDoc } from "../src/command-doc.ts";13import { fullLlms } from "../src/full-llms.ts";14import { frontLlms } from "../src/host-doc.ts";15import { 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(["ask"], "Show one ask in full.", {38 flags: ["--project", "--json"],39 positional: ["ask"],40 }),41 row(["asks"], "List a project's open asks.", {42 flags: ["--project", "--json"],43 }),44 row(["check"], "Run the gate's checks on your answer locally.", {45 flags: ["--ask", "--project", "--json"],46 source: "local",47 }),48 row(["claim"], "Claim an ask.", {49 flags: ["--project", "--json", "--dry-run"],50 positional: ["ask"],51 readOnly: false,52 }),53 row(["credential"], "Answer git's credential helper.", {54 flags: [],55 positional: ["operation"],56 readOnly: false,57 source: "local",58 }),59 row(["front"], "List the open asks across every project."),60 row(["login"], "Sign in to a platform.", {61 flags: ["--url", "--json"],62 readOnly: false,63 source: "local",64 }),65 row(["status"], "Show your claims and answers.", {66 flags: ["--project", "--json"],67 }),68 row(["submit"], "Offer a commit as an answer to a claimed ask.", {69 flags: ["--base", "--head", "--project", "--requestId", "--json"],70 positional: ["ask"],71 readOnly: false,72 }),73 row(["verdict"], "Show the verdict on an answer to an ask.", {74 flags: ["--head", "--project", "--json"],75 positional: ["ask"],76 }),77];7879const projects: readonly ProjectListing[] = [80 {Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
lines 81–85why, one step back81 openAsks: 3,82 posture: "open",83 project: ProjectName.make("oscabriel/datekit"),84 },85 {Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 86–87why, one step back86 openAsks: 1,87 posture: "openWithSealedEvidence",Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8
line 88why, one step back88 project: ProjectName.make("oscabriel/burrow"),Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 89–157why, one step back89 },90];9192const input = { commands, platformUrl, projects, webUrl };9394const text = fullLlms(input);9596const lines = text.split("\n");9798const section = (title: string) => {99 const start = lines.indexOf(`## ${title}`);100 const rest = lines.slice(start + 1);101 const end = rest.findIndex((line) => line.startsWith("## "));102103 expect(start, `no section ${title}`).toBeGreaterThanOrEqual(0);104105 return end === -1 ? rest : rest.slice(0, end);106};107108// Every event's tag, written out here so the test is not the code's own table.109const eventTags: readonly ProjectEvent["_tag"][] = [110 "AskClosed",111 "AskOpened",112 "Claimed",113 "Decided",114 "Judged",115 "Landed",116 "Lapsed",117 "LedgerAppended",118 "ProposalDrafted",119 "ProposalOpened",120 "Pushed",121 "Released",122 "Warned",123];124125describe(fullLlms, () => {126 it.effect("is the text the web serves at /llms-full.txt", () =>127 expectGolden("full-llms", text).pipe(Effect.provide(NodeServices.layer))128 );129130 it("starts with the index's own text for the same input", () => {131 expect(text.startsWith(frontLlms(input))).toBeTruthy();132 expect(text.length).toBeGreaterThan(frontLlms(input).length);133 });134135 it("has a row for every refusal of the union, in every group", () => {136 const refusals = section("Refusals");137138 const missing = groups.flatMap((group) =>139 group.members140 .map((member) => member.identifier)141 .filter(142 (tag) =>143 !refusals.some((line) =>144 line.startsWith(`| \`${tag}\` | ${group.name} |`)145 )146 )147 );148149 expect(missing).toStrictEqual([]);150 });151152 it("gives the next command a refusal fixes when it is raised", () => {153 const refusals = section("Refusals");154155 expect(refusals).toContainEqual(156 expect.stringMatching(157 new RegExp(Merge cli/exit-codes into mainoscabrielbefore adoptionc19a862
line 158why, one step back158 `^\\| \`UnknownAsk\` \\| Lookup \\| no \\| 66 \\| \`${Brand.cli} asks\` \\| .+ \\|$`,Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 159–165why, one step back159 "u"160 )161 )162 );163 expect(refusals).toContainEqual(164 expect.stringMatching(165 new RegExp(Merge cli/exit-codes into mainoscabrielbefore adoptionc19a862
line 166why, one step back166 `^\\| \`DraftInProgress\` \\| Decision \\| yes \\| 75 \\| \`${Brand.cli} proposal <proposal>\` \\| .+ \\|$`,Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 167–169why, one step back167 "u"168 )169 )Merge cli/exit-codes into mainoscabrielbefore adoptionc19a862
lines 170–181why, one step back170 );171 });172173 it("lists every code the CLI exits with, once", () => {174 const listed = section("Exit codes").flatMap((line) => {175 const exit = /^\| (?<code>\d+) \|/u.exec(line)?.groups?.code;176177 return exit === undefined ? [] : [Number(exit)];178 });179180 expect(listed.toSorted((a, b) => a - b)).toStrictEqual(181 Object.values(ExitCode).toSorted((a, b) => a - b)Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 182–192why, one step back182 );183 });184185 it("has a line for every event a watcher hears", () => {186 const events = section("Events");187188 expect(189 eventTags.filter(190 (tag) => !events.some((line) => line.startsWith(`- \`${tag}\`: `))191 )192 ).toStrictEqual([]);Merge redesign into mainoscabrielbefore adoptioncaedd21
lines 193–200why, one step back193 });194195 it("names the MCP tool that lists the latest landings across projects, its cap, and what it shows of a refusal", () => {196 const landed = section("How a landing happens").join("\n");197198 expect(landed).toContain("`recentLandings`");199 expect(landed).toContain(`at most ${RECENT_LANDINGS_CAP}`);200 expect(landed).toContain("its tag and its area");Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 201–205why, one step back201 });202203 it("names the repos a person meets by their patterns", () => {204 const git = section("Git here");205Merge build/1413-docs-and-texts into mainoscabrielbefore adoptionf10338e
line 206why, one step back206 expect(git).toContainEqual(expect.stringContaining("`<owner>/<name>`"));Merge build/1108 into mainoscabrielbefore adoption8d9ece9
line 207why, one step back207 expect(git).toContainEqual(Merge build/1413-docs-and-texts into mainoscabrielbefore adoptionf10338e
line 208why, one step back208 expect.stringContaining("`<owner>/<name>--<ask>--<handle>`")Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 209–210why, one step back209 );210 expect(git).toContainEqual(Merge build/1413-docs-and-texts into mainoscabrielbefore adoptionf10338e
line 211why, one step back211 expect.stringContaining("`<owner>/<name>--me--<handle>`")Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 212–214why, one step back212 );213 });214Merge build/1413-docs-and-texts into mainoscabrielbefore adoptionf10338e
lines 215–218why, one step back215 it("spells a project as <owner>/<name>, never <project>", () => {216 expect(text).not.toContain("<project>");217 });218Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 219–233why, one step back219 it("reads the verdict note with plain git", () => {220 const ref = `refs/notes/${Brand.slug}`;221222 expect(lines).toContain(`git fetch ${Brand.slug} ${ref}:${ref}`);223 expect(lines).toContain(`git notes --ref=${Brand.slug} show <head>`);224 });225226 it("says what the gateway answers when git is not let in", () => {227 const git = section("Git here");228229 expect(git).toContainEqual(230 expect.stringContaining(231 `\`a push needs a signed-in person; sign in with ${Brand.cli} login\``232 )233 );Merge build/1413-docs-and-texts into mainoscabrielbefore adoptionf10338e
line 234why, one step back234 expect(git).toContainEqual(expect.stringContaining("`no repo <repo>`"));Merge build/1108 into mainoscabrielbefore adoption8d9ece9
lines 235–254why, one step back235 });236237 it("names only commands the catalog has in its guides", () => {238 const without = fullLlms({239 ...input,240 commands: commands.filter(({ path }) => path[0] !== "submit"),241 });242243 expect(section("Guides").join("\n")).toContain(`${Brand.cli} submit`);244 expect(without).not.toContain(`${Brand.cli} submit`);245 });246247 it("names no layer: only the refusal tags that say the word", () => {248 const tagged = text249 .replaceAll("`StaleLayer`", "")250 .replaceAll("`LayerContentInPublicTree`", "");251252 expect(tagged).not.toMatch(/layer/iu);253 });254});