From a200832cfb9ea463d5ccb6aa7c16b313f32d496f Mon Sep 17 00:00:00 2001 From: mnovak Date: Sun, 1 Nov 2026 15:39:17 +0100 Subject: [PATCH 1/2] [ui] LetterSlot: Add the page for A Letter from the Gardener, shown once the author writes it docs/LETTER.md holds slots as comments only, so the player sees no change until the author writes. The app bundles the letter at build time, a small Markdown subset renders without {@html}, only https: and tel: become links, and lint:copy now reads the letter. Review found turbo replaying a stale build after the letter changed; docs/LETTER.md is now in its cache key. --- .agents/FEATURES.md | 1 + .agents/GAP_ANALYSIS.md | 4 +- .agents/features/letter-slot.md | 81 ++++++++++++++++++++++++ .agents/lessons/README.md | 6 +- .agents/lessons/code.md | 15 +++++ .agents/lessons/technical.md | 15 +++++ .agents/lessons/testing.md | 15 +++++ .agents/reviews/feature-letter-slot.md | 74 ++++++++++++++++++++++ CLAUDE.md | 3 +- HANDOVER.md | 16 +++-- apps/rosea/src/App.svelte | 4 +- docs/LETTER.md | 34 +++++++++++ e2e/shell.spec.ts | 23 +++++++ packages/ui/package.json | 1 + packages/ui/src/Shell.svelte | 64 +++++++++++++++++-- packages/ui/src/copy/en.ts | 5 ++ packages/ui/src/index.ts | 1 + packages/ui/src/letter/Letter.svelte | 61 ++++++++++++++++++ packages/ui/src/letter/parse.ts | 85 ++++++++++++++++++++++++++ packages/ui/test/Shell.test.ts | 63 ++++++++++++++++++- packages/ui/test/letter-parse.test.ts | 78 +++++++++++++++++++++++ scripts/lint-copy.ts | 7 ++- turbo.json | 4 +- 23 files changed, 639 insertions(+), 21 deletions(-) create mode 100644 .agents/features/letter-slot.md create mode 100644 .agents/reviews/feature-letter-slot.md create mode 100644 docs/LETTER.md create mode 100644 packages/ui/src/letter/Letter.svelte create mode 100644 packages/ui/src/letter/parse.ts create mode 100644 packages/ui/test/letter-parse.test.ts diff --git a/.agents/FEATURES.md b/.agents/FEATURES.md index 7c5b502..fa01f98 100644 --- a/.agents/FEATURES.md +++ b/.agents/FEATURES.md @@ -7,3 +7,4 @@ One row per feature, with its analysis document (CLAUDE.md §5.1). Gaps live in |:--|:--|:--|:--|:--| | Workspace, contracts, gates, PWA shell | 0 | Merged to `main` 2026-11-01 (`d11d242`); built, not deployed. Phase 0 gate still open | [phase0-workspace.md](features/phase0-workspace.md) | [feature-phase0-workspace.md](reviews/feature-phase0-workspace.md) | | Roadmap and gameplay docs, read against the code | 0 | Merged 2026-11-01; Q1–Q7 answered by the author | — | [docs-roadmap-gameplay.md](reviews/docs-roadmap-gameplay.md) | +| The Letter slot: page at `#letter`, empty `docs/LETTER.md` | 0 | On `feature/letter-slot`; built, not deployed. Invisible until the author writes | [letter-slot.md](features/letter-slot.md) | [feature-letter-slot.md](reviews/feature-letter-slot.md) | diff --git a/.agents/GAP_ANALYSIS.md b/.agents/GAP_ANALYSIS.md index 67cecc3..4c1f3e2 100644 --- a/.agents/GAP_ANALYSIS.md +++ b/.agents/GAP_ANALYSIS.md @@ -40,7 +40,8 @@ workspace part of Phase 0 is in | G0.22 | No CI | Open. Every gate ran on this machine only. With G0.13. | | G0.23 | Source maps are built and would be published | Open. `sourcemap: true`; maps are not precached. Decide with G0.13 whether the repository is public. If not, use `'hidden'`. | | G0.24 | No art pipeline: `docs/ART.md`, `art/STYLE.md` (drafted with the author), `art/manifest.json` for Phase 1 assets, SVG placeholders, `tools/art-prep` | Open. **Phase 0 gate**: one illustration goes through prompt, paste, automatic checks, review and the author's approval into `art/final/`. | -| G0.25 | No slot for *A Letter from the Gardener* | Open. A page and an empty `docs/LETTER.md` the author fills; agents write no part of its voice. | +| ~~G0.25~~ | ~~No slot for *A Letter from the Gardener*~~ | Closed 2026-11-01 on `feature/letter-slot`. `docs/LETTER.md` holds slots as comments only; the page opens at `#letter` once it has words. 16 ui tests, and e2e on both the empty and a temporary written letter. Mutations caught: the link while empty, any link scheme, focus not moving, *heal* in the letter. | +| G0.27 | The quiet door to real help has no numbers (§5.6 rule 5) | Open. The slot is in `docs/LETTER.md`. Support lines are real-world facts the author must verify, per country, so the door exists only once the letter does. | | ~~G0.26~~ | ~~Not decided: how the sunset invitation reaches the player on the web~~ | Closed 2026-11-01 by the author (Q6): in-app only on the web, no push server; local notifications through the Tauri shell in Phase 6. Recorded in ROADMAP Phase 0 and CLAUDE.md §8. | ## Design questions — answered @@ -58,3 +59,4 @@ Raised by GAMEPLAY.md and ROADMAP.md, answered by the author 2026-11-01. Details | ~~Q6~~ | When the notification decision is due | Phase 0, in-app only (G0.26) | | ~~Q7~~ | Which phase holds the Amicitia bridge | Phase 3 | | Q8 | "Nearby days give a little more" | Open as a rule for the Phase 1 Soul review: a gap's cost is never shown | +| Q9 | May the Letter name the book and its author for the one sentence of inspiration (GAMEPLAY §7)? | Open. `lint:copy` refuses those names in the letter as everywhere in the product. A yes needs a written, letter-only exemption. | diff --git a/.agents/features/letter-slot.md b/.agents/features/letter-slot.md new file mode 100644 index 0000000..4d863ab --- /dev/null +++ b/.agents/features/letter-slot.md @@ -0,0 +1,81 @@ +# The Letter slot + +Status: on `feature/letter-slot`, reviewed in +[`feature-letter-slot.md`](../reviews/feature-letter-slot.md). Gap: G0.25. Roadmap: Phase 0, *a slot for A Letter +from the Gardener — the author writes it; agents only scaffold the page.* + +--- + +## 1. Why and what, in the player's terms + +*A Letter from the Gardener* is the help section. It holds the deeper why, it can be +re-read at any time, and it is never needed to play (GAMEPLAY §4). It also holds the +quiet door to real help (CLAUDE.md §5.6 rule 5). + +This branch makes the place for it, not the letter itself. The author writes +`docs/LETTER.md` in plain Markdown, and the app shows it as a page. **Until the author +writes something, the player sees no change at all**: there is no link to an empty +page, no "coming soon" and no dead control. + +## 2. Technical architecture + +```mermaid +flowchart LR + letter[("docs/LETTER.md
the author's words")] + app["apps/rosea
App.svelte
imports it ?raw at build time"] + ui["packages/ui
letter/parse.ts → blocks
Letter.svelte, Shell.svelte"] + lint["scripts/lint-copy.ts"] + letter -- "bundled, precached" --> app --> ui + lint -. scans .-> letter +``` + +### Decisions + +| # | Decision | Why | +|:--|:--|:--| +| L1 | `docs/LETTER.md` is the only copy of the letter. The app imports it with Vite's `?raw` at build time. | No runtime fetch, so the letter is in the precached bundle and opens offline. One file means the author edits one place, in Markdown. | +| L2 | The scaffold holds only HTML comments: one slot per thing the docs say the letter carries. Comments are dropped when the page is built, so the scaffold renders as nothing. | Agents never write the letter's voice. A heading is voice too, so the slots are comments, not headings. | +| L3 | A small Markdown subset is parsed into blocks in `packages/ui/src/letter/parse.ts`: headings, paragraphs, lists, *emphasis* and links. Everything else is shown as plain text. The component renders the blocks with Svelte, **never `{@html}`**. | No HTML is ever built from text, so nothing in the file can inject markup or script, and the CSP stays `'self'`. The parser lives in `ui` because it is presentation, and `ui → content` is not an allowed dependency. | +| L4 | Only `https:` and `tel:` become links. Anything else, including `http:`, `javascript:` and `data:`, stays text. External links open in a new tab, with `rel="noopener noreferrer"`. | The support door needs web and phone links. Nothing else does. | +| L5 | The page is reached by a link on the home view, at `#letter`. The link exists **only when the letter has content**. With an empty letter, `#letter` shows the home view. | Hash routing works offline without a server rule. An entry point to an empty page is a dead control. | +| L6 | `lint:copy` scans `docs/LETTER.md` with the full list, though it lives in `docs/`. | It is player-facing. The `docs/` exemption (§5.6 rule 4) is for design documents, where the words are being discussed. | +| L7 | When the view changes, focus moves to the new view's heading. | A screen-reader user hears where they are. A hash change alone announces nothing. | +| L8 | `docs/LETTER.md` is in turbo's `globalDependencies`. | Found in review: without it, a changed letter replayed the cached build (`lessons/technical.md`). | + +## 3. Risk analysis + +| Risk | Where | Defence | +|:--|:--|:--| +| A forbidden or medical word reaches a player through the letter | `docs/LETTER.md` | L6, with a test that the script reads the file. | +| The letter names the book | The "one sentence of inspiration" (GAMEPLAY §7) | `lint:copy` refuses *Saint-Exupéry* and the title in the letter as everywhere else. If the author wants the letter to name its source, that is a decision to write down (Q9), not an exemption made by an agent. | +| Markup or script injected through the file | The renderer | L3 and L4, with tests for ` - + diff --git a/docs/LETTER.md b/docs/LETTER.md new file mode 100644 index 0000000..1e110aa --- /dev/null +++ b/docs/LETTER.md @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + diff --git a/e2e/shell.spec.ts b/e2e/shell.spec.ts index 599c6d2..bae2287 100644 --- a/e2e/shell.spec.ts +++ b/e2e/shell.spec.ts @@ -2,6 +2,8 @@ import AxeBuilder from '@axe-core/playwright'; import { expect, test, type Page } from '@playwright/test'; import { PRODUCT_NAME } from '@rosea/schema'; import { en } from '@rosea/ui/copy'; +import { parseLetter } from '@rosea/ui/letter'; +import { readFileSync } from 'node:fs'; import { BASE, startStaticServer, type StaticServer } from './static-server.js'; let server: StaticServer; @@ -104,3 +106,24 @@ test('the shell has no accessibility violations', async ({ page }) => { const results = await new AxeBuilder({ page }).analyze(); expect(results.violations.map((v) => `${v.id}: ${v.help}`)).toEqual([]); }); + +// Tests whichever state docs/LETTER.md is in: empty now, the author's words later. +test('the Letter: no way to it while empty, and it opens from the garden once written', async ({ page }) => { + const written = parseLetter(readFileSync(new URL('../docs/LETTER.md', import.meta.url), 'utf8')).length > 0; + await open(page); + const link = page.getByRole('link', { name: en.letter.title }); + + if (!written) { + await expect(link).toHaveCount(0); + await page.goto(server.url + '#letter'); + await expect(page.getByRole('heading', { level: 1 })).toHaveText(PRODUCT_NAME); + return; + } + + await link.click(); + await expect(page.getByRole('heading', { level: 1 })).toHaveText(en.letter.title); + const results = await new AxeBuilder({ page }).analyze(); + expect(results.violations.map((v) => `${v.id}: ${v.help}`)).toEqual([]); + await page.getByRole('link', { name: en.letter.back }).click(); + await expect(page.getByRole('heading', { level: 1 })).toHaveText(PRODUCT_NAME); +}); diff --git a/packages/ui/package.json b/packages/ui/package.json index 152f42a..841e212 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -14,6 +14,7 @@ "default": "./src/index.ts" }, "./copy": "./src/copy/en.ts", + "./letter": "./src/letter/parse.ts", "./tokens.css": "./src/tokens.css" }, "scripts": { diff --git a/packages/ui/src/Shell.svelte b/packages/ui/src/Shell.svelte index 69dfc4b..7da33af 100644 --- a/packages/ui/src/Shell.svelte +++ b/packages/ui/src/Shell.svelte @@ -1,12 +1,55 @@ -
-

{PRODUCT_NAME}

-

{en.shell.preparing}

-
+{#if view === 'letter'} +
+

{en.letter.title}

+ + {en.letter.back} +
+{:else} +
+

{PRODUCT_NAME}

+

{en.shell.preparing}

+ {#if blocks.length > 0} + {en.letter.title} + {/if} +
+{/if} diff --git a/packages/ui/src/copy/en.ts b/packages/ui/src/copy/en.ts index 12c3be2..22e26d5 100644 --- a/packages/ui/src/copy/en.ts +++ b/packages/ui/src/copy/en.ts @@ -9,6 +9,11 @@ export const en = { shell: { /** The one line on the Phase 0 page. True, calm, and asks nothing. */ preparing: 'The garden is being prepared.' + }, + letter: { + /** The help section's name (ROADMAP §1). The letter itself is the author's, in docs/LETTER.md. */ + title: 'A Letter from the Gardener', + back: 'Back to the garden' } } as const; diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts index a759649..8b139d0 100644 --- a/packages/ui/src/index.ts +++ b/packages/ui/src/index.ts @@ -1,2 +1,3 @@ export { default as Shell } from './Shell.svelte'; export { en, type Copy } from './copy/en.js'; +export { parseLetter, type Inline, type LetterBlock } from './letter/parse.js'; diff --git a/packages/ui/src/letter/Letter.svelte b/packages/ui/src/letter/Letter.svelte new file mode 100644 index 0000000..5d8258b --- /dev/null +++ b/packages/ui/src/letter/Letter.svelte @@ -0,0 +1,61 @@ + + +{#snippet inlines(parts: readonly Inline[])} + {#each parts as part, i (i)} + {#if part.kind === 'link' && part.href.startsWith('tel:')} + {part.text} + {:else if part.kind === 'link'} + {part.text} + {:else if part.kind === 'em'} + {part.text} + {:else} + {part.text} + {/if} + {/each} +{/snippet} + +
+ {#each blocks as block, i (i)} + {#if block.kind === 'heading' && block.level === 2} +

{@render inlines(block.inlines)}

+ {:else if block.kind === 'heading'} +

{@render inlines(block.inlines)}

+ {:else if block.kind === 'paragraph'} +

{@render inlines(block.inlines)}

+ {:else} +
    + {#each block.items as item, j (j)} +
  • {@render inlines(item)}
  • + {/each} +
+ {/if} + {/each} +
+ + diff --git a/packages/ui/src/letter/parse.ts b/packages/ui/src/letter/parse.ts new file mode 100644 index 0000000..c85148f --- /dev/null +++ b/packages/ui/src/letter/parse.ts @@ -0,0 +1,85 @@ +/** + * The Letter from the Gardener, from the author's Markdown to blocks the page + * renders (.agents/features/letter-slot.md L3, L4). + * + * A deliberately small subset: headings, paragraphs, lists, *emphasis* and + * links. Anything else is shown as the text it is. Nothing here builds HTML, + * so nothing in the file can inject markup or script. + */ + +export type Inline = + | { readonly kind: 'text'; readonly text: string } + | { readonly kind: 'em'; readonly text: string } + | { readonly kind: 'link'; readonly text: string; readonly href: string }; + +export type LetterBlock = + | { readonly kind: 'heading'; readonly level: 2 | 3; readonly inlines: readonly Inline[] } + | { readonly kind: 'paragraph'; readonly inlines: readonly Inline[] } + | { readonly kind: 'list'; readonly items: readonly (readonly Inline[])[] }; + +/** The support door needs web and phone links, and nothing else does. */ +const ALLOWED_HREF = /^(?:https:\/\/\S+|tel:\+?[\d ()-]+)$/i; + +// A link target may hold one level of brackets, as in tel:+420 (2) 123. +const INLINE = /\[([^\]\n]+)\]\(((?:[^()\n]|\([^()\n]*\))+)\)|\*([^*\n]+)\*|_([^_\n]+)_/g; + +function inlines(source: string): Inline[] { + const parts: Inline[] = []; + const text = (t: string): void => { + if (t === '') return; + const last = parts[parts.length - 1]; + if (last?.kind === 'text') parts[parts.length - 1] = { kind: 'text', text: last.text + t }; + else parts.push({ kind: 'text', text: t }); + }; + + let at = 0; + for (const m of source.matchAll(INLINE)) { + text(source.slice(at, m.index)); + const [, label, href, star, underscore] = m; + if (label !== undefined && href !== undefined) { + if (ALLOWED_HREF.test(href.trim())) parts.push({ kind: 'link', text: label, href: href.trim() }); + else text(label); + } else { + parts.push({ kind: 'em', text: star ?? underscore ?? '' }); + } + at = m.index + m[0].length; + } + text(source.slice(at)); + return parts; +} + +export function parseLetter(markdown: string): LetterBlock[] { + // Comments are the author's notes and the scaffold's slots, never the letter. + const lines = markdown.replace(/\r\n?/g, '\n').replace(//g, '').split('\n'); + const blocks: LetterBlock[] = []; + let paragraph: string[] = []; + let list: Inline[][] = []; + + const flush = (): void => { + if (paragraph.length > 0) blocks.push({ kind: 'paragraph', inlines: inlines(paragraph.join(' ')) }); + if (list.length > 0) blocks.push({ kind: 'list', items: list }); + paragraph = []; + list = []; + }; + + for (const raw of lines) { + const line = raw.trim(); + const heading = /^(#{1,6})\s+(.+)$/.exec(line); + const item = /^[-*]\s+(.+)$/.exec(line); + + if (line === '') { + flush(); + } else if (heading !== null) { + flush(); + blocks.push({ kind: 'heading', level: heading[1] === '#' ? 2 : 3, inlines: inlines(heading[2] ?? '') }); + } else if (item !== null) { + if (paragraph.length > 0) flush(); + list.push(inlines(item[1] ?? '')); + } else { + if (list.length > 0) flush(); + paragraph.push(line); + } + } + flush(); + return blocks; +} diff --git a/packages/ui/test/Shell.test.ts b/packages/ui/test/Shell.test.ts index 4c3846d..d244fa6 100644 --- a/packages/ui/test/Shell.test.ts +++ b/packages/ui/test/Shell.test.ts @@ -1,10 +1,23 @@ import { PRODUCT_NAME } from '@rosea/schema'; -import { cleanup, render, screen } from '@testing-library/svelte'; +import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/svelte'; import { afterEach, describe, expect, it } from 'vitest'; import Shell from '../src/Shell.svelte'; import { en } from '../src/copy/en.js'; -afterEach(cleanup); +afterEach(() => { + cleanup(); + window.location.hash = ''; +}); + +const LETTER = [ + '# Why', + '', + 'A line.', + '', + '[Read](https://example.org) or [call](tel:+420123) or [not](javascript:alert(1)).' +].join('\n'); + +const h1 = (): HTMLElement => screen.getByRole('heading', { level: 1 }); describe('Shell', () => { it('names the product in the page heading, from the schema constant', () => { @@ -24,3 +37,49 @@ describe('Shell', () => { expect(screen.getByRole('main')).toBeTruthy(); }); }); + +describe('Shell and the Letter', () => { + it('with an empty letter offers no way to it, and #letter shows the garden', () => { + window.location.hash = '#letter'; + render(Shell, { letter: '\n' }); + expect(h1().textContent).toBe(PRODUCT_NAME); + expect(screen.queryAllByRole('link')).toEqual([]); + }); + + it('with a letter, a link opens it, Back returns, and focus follows each heading', async () => { + render(Shell, { letter: LETTER }); + expect(document.activeElement, 'nothing is focused on first load').toBe(document.body); + + await fireEvent.click(screen.getByRole('link', { name: en.letter.title })); + await waitFor(() => expect(h1().textContent).toBe(en.letter.title)); + await waitFor(() => expect(document.activeElement).toBe(h1())); + expect(screen.getByRole('heading', { level: 2 }).textContent).toBe('Why'); + expect(screen.getByRole('main')).toBeTruthy(); + + await fireEvent.click(screen.getByRole('link', { name: en.letter.back })); + await waitFor(() => expect(h1().textContent).toBe(PRODUCT_NAME)); + await waitFor(() => expect(document.activeElement).toBe(h1())); + }); + + it('opens straight at #letter, as from a bookmark', () => { + window.location.hash = '#letter'; + render(Shell, { letter: LETTER }); + expect(h1().textContent).toBe(en.letter.title); + }); + + it('renders https links in a new tab with no referrer, tel links in place, and nothing else as a link', () => { + window.location.hash = '#letter'; + render(Shell, { letter: LETTER }); + const read = screen.getByRole('link', { name: 'Read' }); + expect(read.getAttribute('href')).toBe('https://example.org'); + expect(read.getAttribute('target')).toBe('_blank'); + expect(read.getAttribute('rel')).toBe('noopener noreferrer'); + + const call = screen.getByRole('link', { name: 'call' }); + expect(call.getAttribute('href')).toBe('tel:+420123'); + expect(call.getAttribute('target')).toBeNull(); + + expect(screen.queryByRole('link', { name: 'not' })).toBeNull(); + expect(screen.getByText(/or not\./)).toBeTruthy(); + }); +}); diff --git a/packages/ui/test/letter-parse.test.ts b/packages/ui/test/letter-parse.test.ts new file mode 100644 index 0000000..ef46b79 --- /dev/null +++ b/packages/ui/test/letter-parse.test.ts @@ -0,0 +1,78 @@ +import { describe, expect, it } from 'vitest'; +import { parseLetter } from '../src/letter/parse.js'; + +describe('parseLetter', () => { + it('reads a file of only comments as an empty letter', () => { + const scaffold = '\n\n\n\n'; + expect(parseLetter(scaffold)).toEqual([]); + expect(parseLetter('')).toEqual([]); + expect(parseLetter(' \n\n \r\n')).toEqual([]); + }); + + it('reads headings, paragraphs joined across lines, and lists', () => { + const md = '# Why\n\nOne line\nand the next.\n\n## How\n- first\n* second\n\nLast.'; + expect(parseLetter(md)).toEqual([ + { kind: 'heading', level: 2, inlines: [{ kind: 'text', text: 'Why' }] }, + { kind: 'paragraph', inlines: [{ kind: 'text', text: 'One line and the next.' }] }, + { kind: 'heading', level: 3, inlines: [{ kind: 'text', text: 'How' }] }, + { kind: 'list', items: [[{ kind: 'text', text: 'first' }], [{ kind: 'text', text: 'second' }]] }, + { kind: 'paragraph', inlines: [{ kind: 'text', text: 'Last.' }] } + ]); + }); + + it('maps every heading below the first level to h3', () => { + expect(parseLetter('### Deep\n\n###### Deeper')).toEqual([ + { kind: 'heading', level: 3, inlines: [{ kind: 'text', text: 'Deep' }] }, + { kind: 'heading', level: 3, inlines: [{ kind: 'text', text: 'Deeper' }] } + ]); + }); + + it('reads CRLF files the same as LF', () => { + expect(parseLetter('# A\r\n\r\nB\r\nC')).toEqual(parseLetter('# A\n\nB\nC')); + }); + + it('reads emphasis and links inside a paragraph', () => { + expect(parseLetter('A *quiet* door: [call](tel:+420 123 456) or [read](https://example.org/x).')).toEqual([ + { + kind: 'paragraph', + inlines: [ + { kind: 'text', text: 'A ' }, + { kind: 'em', text: 'quiet' }, + { kind: 'text', text: ' door: ' }, + { kind: 'link', text: 'call', href: 'tel:+420 123 456' }, + { kind: 'text', text: ' or ' }, + { kind: 'link', text: 'read', href: 'https://example.org/x' }, + { kind: 'text', text: '.' } + ] + } + ]); + }); + + it('reads a phone number with brackets as one link', () => { + expect(parseLetter('[call](tel:+420 (2) 123)')).toEqual([ + { kind: 'paragraph', inlines: [{ kind: 'link', text: 'call', href: 'tel:+420 (2) 123' }] } + ]); + }); + + it('keeps only the label of a link whose scheme is not https: or tel:', () => { + for (const href of ['javascript:alert(1)', 'data:text/html,x', 'http://example.org', '/relative', 'JavaScript:x']) { + expect(parseLetter(`[label](${href})`), href).toEqual([ + { kind: 'paragraph', inlines: [{ kind: 'text', text: 'label' }] } + ]); + } + }); + + it('never produces markup: raw HTML stays text', () => { + const blocks = parseLetter('\n\nbold'); + expect(blocks).toEqual([ + { kind: 'paragraph', inlines: [{ kind: 'text', text: '' }] }, + { kind: 'paragraph', inlines: [{ kind: 'text', text: 'bold' }] } + ]); + }); + + it('drops a comment in the middle of a paragraph and keeps the words around it', () => { + expect(parseLetter('Before after.')).toEqual([ + { kind: 'paragraph', inlines: [{ kind: 'text', text: 'Before after.' }] } + ]); + }); +}); diff --git a/scripts/lint-copy.ts b/scripts/lint-copy.ts index 9c9b153..cdbc5f9 100644 --- a/scripts/lint-copy.ts +++ b/scripts/lint-copy.ts @@ -4,7 +4,8 @@ * @rosea/content (copy-lint.ts, forbidden.ts) and are tested there. * * Not scanned: .agents/ and docs/, where the forbidden words may appear because - * they are being discussed (§5.6 rule 4). + * they are being discussed (§5.6 rule 4). The one exception is docs/LETTER.md: + * it lives with the docs but a player reads it (letter-slot.md L6). */ import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs'; import { extname, join, relative } from 'node:path'; @@ -21,8 +22,8 @@ const TARGETS: readonly { dir: string; ext: readonly string[] }[] = [ { dir: 'store', ext: ['.md', '.txt', '.json'] } ]; -/** Single files: the page shell and the config that builds the web manifest. */ -const FILES: readonly string[] = ['apps/rosea/index.html', 'apps/rosea/vite.config.ts']; +/** Single files: the page shell, the config that builds the web manifest, and the Letter. */ +const FILES: readonly string[] = ['apps/rosea/index.html', 'apps/rosea/vite.config.ts', 'docs/LETTER.md']; function walk(dir: string, ext: readonly string[]): string[] { if (!existsSync(dir)) return []; diff --git a/turbo.json b/turbo.json index d028908..69ed8a9 100644 --- a/turbo.json +++ b/turbo.json @@ -1,7 +1,9 @@ { "$schema": "https://turbo.build/schema.json", "ui": "stream", - "globalDependencies": ["content/**"], + // docs/LETTER.md is bundled into the app (letter-slot.md L1). Without it here a + // changed letter replays the cached build and never reaches the player. + "globalDependencies": ["content/**", "docs/LETTER.md"], "tasks": { "build": { "dependsOn": ["^build"], From 9d294096d94758b282d06d352e04d5062650078a Mon Sep 17 00:00:00 2001 From: mnovak Date: Sun, 1 Nov 2026 19:45:06 +0100 Subject: [PATCH 2/2] [docs] LetterSlot: Mark the Letter slot merged to main --- .agents/FEATURES.md | 2 +- .agents/GAP_ANALYSIS.md | 2 +- .agents/features/letter-slot.md | 2 +- HANDOVER.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.agents/FEATURES.md b/.agents/FEATURES.md index fa01f98..511c848 100644 --- a/.agents/FEATURES.md +++ b/.agents/FEATURES.md @@ -7,4 +7,4 @@ One row per feature, with its analysis document (CLAUDE.md §5.1). Gaps live in |:--|:--|:--|:--|:--| | Workspace, contracts, gates, PWA shell | 0 | Merged to `main` 2026-11-01 (`d11d242`); built, not deployed. Phase 0 gate still open | [phase0-workspace.md](features/phase0-workspace.md) | [feature-phase0-workspace.md](reviews/feature-phase0-workspace.md) | | Roadmap and gameplay docs, read against the code | 0 | Merged 2026-11-01; Q1–Q7 answered by the author | — | [docs-roadmap-gameplay.md](reviews/docs-roadmap-gameplay.md) | -| The Letter slot: page at `#letter`, empty `docs/LETTER.md` | 0 | On `feature/letter-slot`; built, not deployed. Invisible until the author writes | [letter-slot.md](features/letter-slot.md) | [feature-letter-slot.md](reviews/feature-letter-slot.md) | +| The Letter slot: page at `#letter`, empty `docs/LETTER.md` | 0 | Merged to `main`; built, not deployed. Invisible until the author writes | [letter-slot.md](features/letter-slot.md) | [feature-letter-slot.md](reviews/feature-letter-slot.md) | diff --git a/.agents/GAP_ANALYSIS.md b/.agents/GAP_ANALYSIS.md index 4c1f3e2..fae9d69 100644 --- a/.agents/GAP_ANALYSIS.md +++ b/.agents/GAP_ANALYSIS.md @@ -40,7 +40,7 @@ workspace part of Phase 0 is in | G0.22 | No CI | Open. Every gate ran on this machine only. With G0.13. | | G0.23 | Source maps are built and would be published | Open. `sourcemap: true`; maps are not precached. Decide with G0.13 whether the repository is public. If not, use `'hidden'`. | | G0.24 | No art pipeline: `docs/ART.md`, `art/STYLE.md` (drafted with the author), `art/manifest.json` for Phase 1 assets, SVG placeholders, `tools/art-prep` | Open. **Phase 0 gate**: one illustration goes through prompt, paste, automatic checks, review and the author's approval into `art/final/`. | -| ~~G0.25~~ | ~~No slot for *A Letter from the Gardener*~~ | Closed 2026-11-01 on `feature/letter-slot`. `docs/LETTER.md` holds slots as comments only; the page opens at `#letter` once it has words. 16 ui tests, and e2e on both the empty and a temporary written letter. Mutations caught: the link while empty, any link scheme, focus not moving, *heal* in the letter. | +| ~~G0.25~~ | ~~No slot for *A Letter from the Gardener*~~ | Closed 2026-11-01, merged to `main`. `docs/LETTER.md` holds slots as comments only; the page opens at `#letter` once it has words. 16 ui tests, and e2e on both the empty and a temporary written letter. Mutations caught: the link while empty, any link scheme, focus not moving, *heal* in the letter. | | G0.27 | The quiet door to real help has no numbers (§5.6 rule 5) | Open. The slot is in `docs/LETTER.md`. Support lines are real-world facts the author must verify, per country, so the door exists only once the letter does. | | ~~G0.26~~ | ~~Not decided: how the sunset invitation reaches the player on the web~~ | Closed 2026-11-01 by the author (Q6): in-app only on the web, no push server; local notifications through the Tauri shell in Phase 6. Recorded in ROADMAP Phase 0 and CLAUDE.md §8. | diff --git a/.agents/features/letter-slot.md b/.agents/features/letter-slot.md index 4d863ab..0deba79 100644 --- a/.agents/features/letter-slot.md +++ b/.agents/features/letter-slot.md @@ -1,6 +1,6 @@ # The Letter slot -Status: on `feature/letter-slot`, reviewed in +Status: merged to `main`, reviewed in [`feature-letter-slot.md`](../reviews/feature-letter-slot.md). Gap: G0.25. Roadmap: Phase 0, *a slot for A Letter from the Gardener — the author writes it; agents only scaffold the page.* diff --git a/HANDOVER.md b/HANDOVER.md index a628e5a..3dff9cf 100644 --- a/HANDOVER.md +++ b/HANDOVER.md @@ -21,7 +21,7 @@ Rewritten at the end of each session (CLAUDE.md §5.1). code: [`.agents/reviews/docs-roadmap-gameplay.md`](.agents/reviews/docs-roadmap-gameplay.md). The author answered Q1–Q7, and the answers are written into both docs and CLAUDE.md. Merged to `main`. -- **The Letter slot:** on `feature/letter-slot`, not merged yet. `docs/LETTER.md` +- **The Letter slot:** merged to `main`. `docs/LETTER.md` holds slots as comments only. Once the author writes in it, a link to the letter appears in the garden, and the page opens at `#letter`, offline too. Review: [`.agents/reviews/feature-letter-slot.md`](.agents/reviews/feature-letter-slot.md).