Public: anyone can read this; the crew can change it.
Automate a review finding as a lint or test: Both doors: there is no terminal screen in src/tui/ for the week card, and no do #12984
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/12983-automate-a-review-finding-as-a-lint-or-t → main 3 commits fork 1 thread · 1 unresolved
3 files
changed +20
−3
AGENTS.md +1 −1
| @@ -5,7 +5,7 @@ Read `CLAUDE.md` first: it is the rulebook for agents editing this repo. | ||
| 5 | 5 | Read the guide first, in this order: `docs/guide-what-a-forge-is.md`, `docs/guide-first-app.md`, `docs/guide-tell-the-crew.md`, `docs/guide-ship-and-undo.md`, `docs/guide-your-apps.md`, `docs/guide-hosting.md`, `docs/guide-own-ai.md`, `docs/guide-agents.md`, `docs/guide-backups-moving.md`, `docs/guide-settings.md`, `docs/guide-when-wrong.md`. That is the spine (ordered in `src/view/guide.ts`, served at `/docs` with search, listed first by /llms.txt): eleven pages, each at most 300 words and 60 lines, every command, path and link in them checked by `test/guide.test.ts`. A feature's `docs/features/<name>.md` is its reference; give it one row under its topic in `docs/features/README.md`, the index every spine page links (`test/feature-orphans.test.ts`). |
| 6 | 6 | |
| 7 | 7 | 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>`; a new `src/web/render/*.ts`, `src/web/studio/*.ts` or `src/actions/*.ts` is asked for the screen alone, and a new feature module under `src/` in a pull that edits an existing page is asked for both; `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`, `src/web/studio/*.ts` or `src/actions/*.ts` is asked for the screen alone, and a new feature module under `src/` in a pull that edits an existing page, MCP tool (`src/http/mcp/tools/`) or API route (`src/http/api/`) is asked for both; `bun scripts/gate.ts` refuses it otherwise ("both doors", #10628). | |
| 9 | 9 | 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). |
| 10 | 10 | |
| 11 | 11 | 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 +9 −2
| @@ -18,13 +18,20 @@ | ||
| 18 | 18 | * `src/` outside tests, the kernel and the terminal's own folders) in a pull |
| 19 | 19 | * that edits an existing page is a feature, and is asked for the screen and |
| 20 | 20 | * the how-to like a new page. |
| 21 | * | |
| 22 | * The same four findings (#12983) include a feature that reached the MCP or the | |
| 23 | * API and not the terminal (team metrics #10984, a table export #12711): an | |
| 24 | * edited MCP tool (`src/http/mcp/tools/`) or API route (`src/http/api/`) counts | |
| 25 | * as wiring a feature module in, like an edited page. | |
| 21 | 26 | */ |
| 22 | 27 | |
| 23 | 28 | import type { Change } from "./pin_edits.ts"; |
| 24 | 29 | |
| 25 | 30 | const PAGE = /^src\/web\/pages\/[^/]+\.ts$/; |
| 26 | 31 | const SURFACE = /^src\/(web\/(render|studio)|actions)\/[^/]+\.ts$/; |
| 27 | const EDITED_PAGE = PAGE; | |
| 32 | // A feature can be wired in through a door other than a page: an MCP tool or an API route | |
| 33 | // (#10984, #12711). | |
| 34 | const WIRING = /^src\/(web\/pages|http\/(api|mcp\/tools))\/[^/]+\.ts$/; | |
| 28 | 35 | const FEATURE_MODULE = /^src\/(?!tui\/|kernel\/|web\/(pages|render|studio)\/|actions\/)(?:[^/]+\/)+[^/]+\.ts$/; |
| 29 | 36 | const SCREEN = /^src\/tui\/screens\/[^/]+\.ts$/; |
| 30 | 37 | const DOC = /^docs\/features\/[^/]+\.md$/; |
| @@ -46,7 +53,7 @@ export function bothDoorsProblems( | ||
| 46 | 53 | ): string[] { |
| 47 | 54 | const pages = added(changes, PAGE); |
| 48 | 55 | const surfaces = added(changes, SURFACE); |
| 49 | const wired = changes.some((c) => c.status.startsWith("M") && EDITED_PAGE.test(c.path)); | |
| 56 | const wired = changes.some((c) => c.status.startsWith("M") && WIRING.test(c.path)); | |
| 50 | 57 | const modules = wired && pages.length === 0 ? added(changes, FEATURE_MODULE) : []; |
| 51 | 58 | const featured = modules.length > 0; |
| 52 | 59 | if (pages.length === 0 && surfaces.length === 0 && !featured) return []; |
test/both-doors.test.ts +10
| @@ -74,3 +74,13 @@ test("a new feature module wired into an existing page needs both doors (#12444, | ||
| 74 | 74 | expect(bothDoorsProblems([mod], [], () => true)).toEqual([]); |
| 75 | 75 | expect(bothDoorsProblems([edit, ch("A", "src/kernel/x.ts"), ch("A", "src/tui/ui/x.ts")], [], () => true)).toEqual([]); |
| 76 | 76 | }); |
| 77 | ||
| 78 | test("a new feature module wired into an MCP tool or API route needs both doors (#10984, #12711)", () => { | |
| 79 | const mod = ch("A", "src/metrics/team.ts"); | |
| 80 | for (const f of ["src/http/mcp/tools/team.ts", "src/http/api/tables.ts"]) { | |
| 81 | expect(bothDoorsProblems([ch("M", f), mod], [], () => true)).toEqual([ | |
| 82 | `rule "both doors": this pull adds src/metrics/team.ts but no ${TUI} and no ${DOCS}${tail}`, | |
| 83 | ]); | |
| 84 | expect(bothDoorsProblems([ch("M", f), mod, ch("A", "src/tui/screens/t.ts"), ch("A", "docs/features/t.md")], [], () => true)).toEqual([]); | |
| 85 | } | |
| 86 | }); |
new above
offline
web/studiois matched here but is not in the issue, the AGENTS.md sentence, or the test. Drop it or document and test it. Also renameEDITED_PAGE, since it no longer means only a page.