Skip to content
Myr

docs-public.test.ts

This file

Path

packages/config/test/docs-public.test.ts

201 lines · 5.5 KiB · TypeScript

Last changed by

Merge build/comments-packages-rest into mainoscabrielbefore adoption38cd503

History of this file

Take it

Merge branch 'build/707-adr-glossary-agents-fold-ins'oscabrielbefore adoption2b1fd3c

lines 1–2why, one step back
1import { NodeServices } from "@effect/platform-node";
2import { describe, expect, it } from "@effect/vitest";

Drop the private build plan's citations from the code, and fail verify if one comes backoscabrielbefore adoptiona29cef6

line 3why, one step back
3import { Array, Effect, FileSystem, Option, Order, Path, Schema } from "effect";

Merge branch 'build/707-adr-glossary-agents-fold-ins'oscabrielbefore adoption2b1fd3c

line 4why, one step back
4

Keep W10 group A's merged gate green under a full test runoscabrielbefore adoptionbd3598e

line 5why, one step back
5import { committable, readsAtOnce, repoRoot, textOf } from "./root.ts";

Merge branch 'build/707-adr-glossary-agents-fold-ins'oscabrielbefore adoption2b1fd3c

line 6why, one step back
6

Merge build/agents-private into mainoscabrielbefore adoptionb1f69d8

lines 7–15why, one step back
7const PRIVATE_FOLDERS = [
8 ".agents/adr",9 ".agents/demo",10 ".agents/ops",11 ".agents/workflow",12 ".agents/scratch",13 ".agents/README",14] as const;15

Merge branch 'build/707-adr-glossary-agents-fold-ins'oscabrielbefore adoption2b1fd3c

lines 16–20why, one step back
16const PRIVATE = [
17 "~/",18 "/home/",19 "wanted-explainer",20 "plans.gneiss.run",

Merge build/agents-private into mainoscabrielbefore adoptionb1f69d8

line 21why, one step back
21 ...PRIVATE_FOLDERS,

Merge branch 'build/707-adr-glossary-agents-fold-ins'oscabrielbefore adoption2b1fd3c

lines 22–24why, one step back
22] as const;
2324/**

Merge build/comments-packages-rest into mainoscabrielbefore adoption38cd503

lines 25–27why, one step back
25 * A reference into the build's private plan: a section of its spec
26 * (`spec §8`, `W9 §14`), a decision (`spec D6`, `W9-D14`), an issue by wave27 * (`W3 313`), or the research synthesis (`SYN`).

Merge branch 'build/707-adr-glossary-agents-fold-ins'oscabrielbefore adoption2b1fd3c

line 28why, one step back
28 */

Drop the private build plan's citations from the code, and fail verify if one comes backoscabrielbefore adoptiona29cef6

lines 29–31why, one step back
29const PLAN_REFERENCES = [
30 /\bspec §/u,31 /\bspec D\d/u,

Close the code browser and drafting wave: its decisions in two ADRs, every rule it added held, and its leftovers folded inoscabrielbefore adoption009640c

lines 32–33why, one step back
32 /\bW\d+ §/u,
33 /\bW\d+-D\d/u,

Drop the private build plan's citations from the code, and fail verify if one comes backoscabrielbefore adoptiona29cef6

lines 34–36why, one step back
34 /\bW\d \d{3}\b/u,
35 /\bSYN\b/u,36] as const;

Merge branch 'build/707-adr-glossary-agents-fold-ins'oscabrielbefore adoption2b1fd3c

line 37why, one step back
37

Drop the private build plan's citations from the code, and fail verify if one comes backoscabrielbefore adoptiona29cef6

lines 38–48why, one step back
38const TEXT_FILE =
39 /(?:\.(?:css|html|json|jsonc|md|mjs|sh|sql|toml|ts|tsx|ya?ml)|(?:^|\/)(?:\.gitignore|\.env\.schema|[^/]*Dockerfile))$/u;4041/** This file, which spells the references out to find them. */42const QUOTES_THE_REFERENCES = "packages/config/test/docs-public.test.ts";4344const planReferencesIn = (text: string) =>45 PLAN_REFERENCES.flatMap((reference) =>46 reference.test(text) ? [reference.source] : []47 );48

Merge build/agents-private into mainoscabrielbefore adoptionb1f69d8

lines 49–62why, one step back
49/**
50 * Where the private folders may be named: the maintainer's folder itself,51 * while it is still on disk, and `.gitignore`, which keeps it out.52 */53const NAMES_THE_PRIVATE_FOLDERS = (file: string) =>54 file.startsWith(".agents/") || file === ".gitignore";5556const privateIn = (file: string, text: string) => [57 ...planReferencesIn(text),58 ...(NAMES_THE_PRIVATE_FOLDERS(file)59 ? []60 : PRIVATE_FOLDERS.filter((folder) => text.includes(folder))),61];62

Merge branch 'build/707-adr-glossary-agents-fold-ins'oscabrielbefore adoption2b1fd3c

lines 63–68why, one step back
63const TERMS = [
64 "Claim fork",65 "Decision",66 "Family",67 "Landed SHA",68 "Outcome",

Merge build/1413-docs-and-texts into mainoscabrielbefore adoptionf10338e

line 69why, one step back
69 "Owner",

Merge branch 'build/707-adr-glossary-agents-fold-ins'oscabrielbefore adoption2b1fd3c

lines 70–71why, one step back
70 "Patch id",
71 "Policy",

Merge build/1413-docs-and-texts into mainoscabrielbefore adoptionf10338e

line 72why, one step back
72 "Project name",

Merge branch 'build/707-adr-glossary-agents-fold-ins'oscabrielbefore adoption2b1fd3c

line 73why, one step back
73 "Proposal",

Merge build/1413-docs-and-texts into mainoscabrielbefore adoptionf10338e

line 74why, one step back
74 "Source namespace",

Merge branch 'build/707-adr-glossary-agents-fold-ins'oscabrielbefore adoption2b1fd3c

lines 75–96why, one step back
75 "Today",
76 "Working fork",77] as const;7879const RootPackage = Schema.Struct({80 scripts: Schema.Record(Schema.String, Schema.String),81});8283const read = (relative: string) =>84 Effect.gen(function* () {85 const fs = yield* FileSystem.FileSystem;86 const path = yield* Path.Path;87 const root = yield* repoRoot;8889 return yield* fs.readFileString(path.join(root, relative));90 });9192const withText = (paths: readonly string[]) =>93 Effect.forEach(paths, (path) =>94 Effect.map(read(path), (text) => ({ path, text }))95 );96

Merge build/agents-private into mainoscabrielbefore adoptionb1f69d8

line 97why, one step back
97const publicDocs = withText(["AGENTS.md", "GLOSSARY.md"]);

Merge branch 'build/707-adr-glossary-agents-fold-ins'oscabrielbefore adoption2b1fd3c

lines 98–124why, one step back
98
99const sectionOf = (text: string, title: string): readonly string[] => {100 const lines = text.split("\n");101 const start = lines.indexOf(`## ${title}`);102103 if (start === -1) {104 return [];105 }106107 const rest = lines.slice(start + 1);108 const end = rest.findIndex((line) => /^#{1,2} /u.test(line));109110 return end === -1 ? rest : rest.slice(0, end);111};112113const commandOf = (line: string) =>114 /^- `(?<name>[^`\s]+)/u.exec(line)?.groups?.name;115116describe("the repo's public docs", () => {117 it.live("point at no home folder and no private plan", () =>118 Effect.gen(function* () {119 const docs = yield* publicDocs;120121 expect(122 docs.flatMap(({ path, text }) =>123 [124 ...PRIVATE.filter((pointer) => text.includes(pointer)),

Drop the private build plan's citations from the code, and fail verify if one comes backoscabrielbefore adoptiona29cef6

line 125why, one step back
125 ...planReferencesIn(text),

Merge branch 'build/707-adr-glossary-agents-fold-ins'oscabrielbefore adoption2b1fd3c

lines 126–129why, one step back
126 ].map((found) => `${path}: ${found}`)
127 )128 ).toStrictEqual([]);129 }).pipe(Effect.provide(NodeServices.layer))

Drop the private build plan's citations from the code, and fail verify if one comes backoscabrielbefore adoptiona29cef6

lines 130–132why, one step back
130 );
131132 it.live(

Merge build/agents-private into mainoscabrielbefore adoptionb1f69d8

line 133why, one step back
133 "and no file the repo would commit cites the private plan or points into the private folders, comments included",

Drop the private build plan's citations from the code, and fail verify if one comes backoscabrielbefore adoptiona29cef6

lines 134–139why, one step back
134 () =>
135 Effect.gen(function* () {136 const files = (yield* committable).filter(137 (file) => TEXT_FILE.test(file) && file !== QUOTES_THE_REFERENCES138 );139

Keep W10 group A's merged gate green under a full test runoscabrielbefore adoptionbd3598e

lines 140–146why, one step back
140 const found = yield* Effect.forEach(
141 files,142 (file) =>143 Effect.map(textOf(file), (text) =>144 Option.match(text, {145 onNone: () => [],146 onSome: (content) =>

Merge build/agents-private into mainoscabrielbefore adoptionb1f69d8

line 147why, one step back
147 privateIn(file, content).map(

Keep W10 group A's merged gate green under a full test runoscabrielbefore adoptionbd3598e

lines 148–152why, one step back
148 (pattern) => `${file}: ${pattern}`
149 ),150 })151 ),152 readsAtOnce

Drop the private build plan's citations from the code, and fail verify if one comes backoscabrielbefore adoptiona29cef6

lines 153–156why, one step back
153 );
154155 expect(found.flat()).toStrictEqual([]);156 }).pipe(Effect.provide(NodeServices.layer))

Merge branch 'build/707-adr-glossary-agents-fold-ins'oscabrielbefore adoption2b1fd3c

lines 157–201why, one step back
157 );
158159 it.live("AGENTS.md describes today, with no Day 0 paragraph", () =>160 Effect.gen(function* () {161 const agents = yield* read("AGENTS.md");162163 expect(164 agents.split("\n").filter((line) => /\bDay 0\b/u.test(line))165 ).toStrictEqual([]);166 }).pipe(Effect.provide(NodeServices.layer))167 );168169 it.live(170 "AGENTS.md's Commands section names every root script, and only those",171 () =>172 Effect.gen(function* () {173 const agents = yield* read("AGENTS.md");174175 const { scripts } = yield* Schema.decodeEffect(176 Schema.fromJsonString(RootPackage)177 )(yield* read("package.json"));178179 expect(180 Array.sort(181 sectionOf(agents, "Commands").flatMap((line) => {182 const name = commandOf(line);183184 return name === undefined ? [] : [name];185 }),186 Order.String187 )188 ).toStrictEqual(Array.sort(Object.keys(scripts), Order.String));189 }).pipe(Effect.provide(NodeServices.layer))190 );191192 it.live("GLOSSARY.md defines each term the code uses", () =>193 Effect.gen(function* () {194 const glossary = (yield* read("GLOSSARY.md")).split("\n");195196 expect(197 TERMS.filter((term) => !glossary.includes(`**${term}**:`))198 ).toStrictEqual([]);199 }).pipe(Effect.provide(NodeServices.layer))200 );201});