Public: anyone can read this; the crew can change it.

Automate a review finding as a lint or test: Two changes before this lands. #12486

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/12393-automate-a-review-finding-as-a-lint-or-t → main 2 commits fork

  • Merged. scout/12393-automate-a-review-finding-as-a-lint-or-t was merged into main as 3b382b3.

Review

Sign in to review this change.
3 files changed +23 −4
AGENTS.md +1 −1
@@ -5,7 +5,7 @@ Read `CLAUDE.md` first: it is the rulebook for agents editing this repo.
55 The guide (`docs/guide-*.md`, ordered in `src/view/guide.ts`, served at `/docs` with search) is how a person and an outside agent are taught the forge: eleven pages, each at most 450 words, every command, path and link in them checked by `test/guide.test.ts`. A feature's `docs/features/<name>.md` is its reference; link it from the guide page it belongs to. llms.txt points at the same pages.
66
77 README.md is capped: a new feature's how-to goes in `docs/features/<name>.md`, not a new README section.
8 A pull that adds a page (`src/web/pages/*.ts`) also adds a terminal screen under `src/tui/screens/` that another module imports (its palette entry) and a `docs/features/<name>.md`, or a commit line `No door: <why>`; `bun scripts/gate.ts` refuses it otherwise ("both doors", #10628).
8 A pull that adds a page (`src/web/pages/*.ts`) also adds a terminal screen under `src/tui/screens/` that another module imports (its palette entry) and a `docs/features/<name>.md`, or a commit line `No door: <why>`; a new `src/web/render/*.ts` or `src/actions/*.ts` is asked for the screen alone; `bun scripts/gate.ts` refuses it otherwise ("both doors", #10628).
99 A pull that changes `src/web/` (a `.ts` or `.css`) names, in a commit line `Looks: <path>`, the page of `app.looks` in forge.json whose before/after pictures show it, or says `No look: <why>`; `bun scripts/gate.ts` refuses it otherwise ("before/after looks", #12362).
1010
1111 When you write an issue, end it with a `Files:` line naming the files the work touches (`Files: src/a.ts, docs/b.md`). The hot-file hold reads only that line when it is there; without it, every path the issue mentions counts.
src/kernel/both_doors.ts +11 −3
@@ -5,11 +5,17 @@
55 * (`src/web/pages/*.ts`) therefore adds a terminal screen (a new file under
66 * `src/tui/`) and a features doc, or says in a commit message
77 * `No door: <why this page needs no terminal screen or how-to>`.
8 *
9 * The same ask came back on a file kind renderer (#11287) and on an action
10 * (#11626): a new `src/web/render/*.ts` or `src/actions/*.ts` is a feature
11 * the web door shows, so it needs its terminal screen too (the how-to is
12 * asked of pages only), or the same `No door:` line.
813 */
914
1015 import type { Change } from "./pin_edits.ts";
1116
1217 const PAGE = /^src\/web\/pages\/[^/]+\.ts$/;
18 const SURFACE = /^src\/(web\/render|actions)\/[^/]+\.ts$/;
1319 const SCREEN = /^src\/tui\/screens\/[^/]+\.ts$/;
1420 const DOC = /^docs\/features\/[^/]+\.md$/;
1521 const WAIVER = /^No door:\s*\S[^\n]{9,}/im;
@@ -29,15 +35,17 @@ export function bothDoorsProblems(
2935 imported: (screen: string) => boolean,
3036 ): string[] {
3137 const pages = added(changes, PAGE);
32 if (pages.length === 0) return [];
38 const surfaces = added(changes, SURFACE);
39 if (pages.length === 0 && surfaces.length === 0) return [];
3340 if (messages.some((m) => WAIVER.test(m))) return [];
3441 const missing: string[] = [];
3542 const screens = added(changes, SCREEN);
3643 if (screens.length === 0) missing.push("terminal screen in src/tui/screens/ (entry where AGENTS.md says)");
3744 else if (!screens.some(imported)) missing.push(`entry that opens ${screens[0]} (add its palette entry per AGENTS.md)`);
38 if (added(changes, DOC).length === 0) missing.push("docs/features/<name>.md how-to");
45 if (pages.length > 0 && added(changes, DOC).length === 0) missing.push("docs/features/<name>.md how-to");
3946 if (missing.length === 0) return [];
40 const shown = pages.slice(0, 3).join(", ") + (pages.length > 3 ? ` and ${pages.length - 3} more` : "");
47 const all = [...pages, ...surfaces];
48 const shown = all.slice(0, 3).join(", ") + (all.length > 3 ? ` and ${all.length - 3} more` : "");
4149 return [
4250 `rule "both doors": this pull adds ${shown} but no ${missing.join(" and no ")}; add them, or put a "No door: <why>" line (10+ characters) in a commit message`,
4351 ];
test/both-doors.test.ts +11
@@ -40,3 +40,14 @@ test("a helper under src/tui/ is not a screen, and a screen nothing imports is n
4040 `rule "both doors": this pull adds src/web/pages/traffic.ts but no entry that opens src/tui/screens/traffic.ts (add its palette entry per AGENTS.md)${tail}`,
4141 ]);
4242 });
43
44 test("a new file renderer or action needs a terminal screen, and is not asked for a how-to (#11287, #11626)", () => {
45 for (const f of ["src/web/render/graphql.ts", "src/actions/schedules.ts"]) {
46 expect(bothDoorsProblems([ch("A", f)], [], () => true)).toEqual([
47 `rule "both doors": this pull adds ${f} but no ${TUI}${tail}`,
48 ]);
49 expect(bothDoorsProblems([ch("A", f), ch("A", "src/tui/screens/s.ts")], [], () => true)).toEqual([]);
50 expect(bothDoorsProblems([ch("A", f)], ["No door: a helper with no screen of its own"], () => true)).toEqual([]);
51 expect(bothDoorsProblems([ch("M", f)], [], () => true)).toEqual([]);
52 }
53 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs