diff --git a/CLAUDE.md b/CLAUDE.md index 24f3264..08dcddc 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,29 +1,33 @@ # CLAUDE.md -Pipeline (`vnpipe`) that turns a public-domain play into a Ren'Py visual novel; first work: Faust I (Spanish, Llorente). +Faust I (Spanish, Llorente) as a Ren'Py visual novel. This repo is a *work*: the pipeline +(`vnpipe`) lives in `../vnpipe` (path dependency in `pyproject.toml`). ## Rules - Repo content in English; the game text is Spanish (from the source, never rewritten). -- `src/vnpipe` is work-agnostic. Anything specific to a text goes in `works//work.toml`. +- Pipeline code, schemas, prompts and GUI templates belong in `../vnpipe`, not here. + Anything specific to this text goes in `work.toml`. +- `vn/` is generated by `vnpipe renpy`; never edit it by hand. - Every stage must be deterministic and idempotent; LLM/image outputs are cached by input hash. -- Data contracts live in `src/vnpipe/schemas/*.schema.json`; change schema + tests together. - ChatGPT image MCP: max 20 generations per hour. ## Commands - `export UV_CACHE_DIR=$TMPDIR/uv-cache` first when running inside the sandbox. - `uv sync` — install. `uv run pytest` — tests. `uv run ruff check . && uv run ruff format --check .` — lint. -- `uv run vnpipe --help` — pipeline CLI. Stages: `fetch`, `parse`, `annotate {chunk,status,prompt,merge}`, - `assets {prompt,import,process,status,placeholders,sheet}`, `renpy [--with-test]`. -- Ren'Py SDK lives in `tools/renpy-sdk` (gitignored; may be a symlink shared between worktrees). - Inside the sandbox prefix SDK commands with `HOME=$TMPDIR/renpy-home`. - Lint: `tools/renpy-sdk/renpy.sh vn/faust lint`. Playthrough test and builds: `docs/running.md`. +- `uv run vnpipe --help` — pipeline CLI (the work is the repo root). Stages: `fetch`, `parse`, + `annotate {chunk,status,prompt,merge}`, `assets {...}`, `renpy [--with-test --out DIR]`. +- Ren'Py SDK lives in `tools/renpy-sdk` (gitignored; may be a symlink shared between worktrees) + or `RENPY_SDK`. Inside the sandbox prefix SDK commands with `HOME=$TMPDIR/renpy-home`. + Lint: `tools/renpy-sdk/renpy.sh vn lint`. Playthrough test and builds: `docs/running.md`. +- The `vnpipe` path in `pyproject.toml` is absolute (worktrees sit two levels deeper than the + main checkout); adjust it on another machine. ## Branches and versions - `development` is the integration branch; `main` receives reviewed merges from it. Feature work branches off `development` (`feat/...`, `fix/...`). - `VERSION` is bumped by `.github/workflows/version.yml` on push (patch on `development`, - minor on a `development` → `main` merge). Do not edit it by hand. -- CI (`.github/workflows/ci.yml`) runs ruff and pytest. + minor on a `development` -> `main` merge). Do not edit it by hand. +- CI (`.github/workflows/ci.yml`) runs ruff and pytest; it needs vnpipe available (see the TODO there). ## Layout -See `docs/plan.md`. +`work.toml`, `data/`, `annotations/`, `assets/`, `vn/`, `tests/`, `docs/`; see `docs/plan.md`. diff --git a/LESSONS.md b/LESSONS.md index e94c0b4..19b8d6b 100644 --- a/LESSONS.md +++ b/LESSONS.md @@ -12,10 +12,12 @@ Recurring problems and what worked. Read before starting; add an entry when a mi images. Always run the end-to-end playthrough (`vnpipe renpy --with-test` + `renpy.sh test`, see docs/running.md) and, ideally, click through the web build. - Ren'Py SDK commands write to `~/.renpy`: prefix them with `HOME=$TMPDIR/renpy-home` - inside the sandbox. `web_build` leaves `vn//progressive_download.txt` (gitignored). + inside the sandbox. `web_build` leaves `vn/progressive_download.txt` (gitignored). - ChatGPT image MCP: reference-image variants sometimes come back byte-identical to the base; compare sha256 against the base before approving. Sprites drift to full-body unless the prompt says "cropped just below the knees". - Small-model annotators label whole speeches with one emotion and lose stage presence across chunks; fix with `work.toml` overrides (pinned cast, emotion ranges), not by hand-editing annotated.json. +- The pipeline lives in `../vnpipe`: a pipeline bug is fixed there (and tested with its + fixtures), then `uv run vnpipe renpy` is re-run here; `vn/` must not change unless intended. diff --git a/README.md b/README.md index 7557b2a..e2da18c 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,23 @@ # faust-vn A playable visual-novel prototype of the opening of Goethe's *Faust* (Part I), in -Teodoro Llorente's public-domain Spanish translation — and `vnpipe`, the reusable -pipeline that builds it: Gutenberg text → annotated JSON → Ren'Py project. +Teodoro Llorente's public-domain Spanish translation. It is the first work built with +[`vnpipe`](../vnpipe), the reusable "classic novels to visual novels" pipeline. The game is in Spanish. Art is AI-generated (see [docs/licensing.md](docs/licensing.md)). ## Quick start +`vnpipe` is a path dependency: clone it next to this repo and adjust +`[tool.uv.sources]` in `pyproject.toml` if it lives elsewhere. + ```bash uv sync -uv run vnpipe --help +uv run vnpipe fetch # download the source into data/raw +uv run vnpipe parse # data/raw -> data/parsed.json +uv run vnpipe renpy # data/annotated.json -> vn/ +tools/renpy-sdk/renpy.sh vn # play (Ren'Py 8.5.3 SDK, see docs/running.md) ``` -Run instructions for the game: [docs/running.md](docs/running.md). -Pipeline overview: [docs/plan.md](docs/plan.md). +Run, lint and build instructions: [docs/running.md](docs/running.md). +Plan and layout: [docs/plan.md](docs/plan.md). diff --git a/docs/adaptation-rules.md b/docs/adaptation-rules.md index 24bae22..afbebc4 100644 --- a/docs/adaptation-rules.md +++ b/docs/adaptation-rules.md @@ -1,75 +1,26 @@ -# Adaptation rules +# Adaptation rules (Faust) -How a play becomes a visual novel. The text is never rewritten, abridged or reordered: -every verse line of the scoped text is shown, in order. What changes is *how* it is -shown. Generic rules are implemented in `src/vnpipe/renpy_gen.py`; work-specific choices -live in `works//work.toml` (`[staging.*]`, `[[cues]]`, `[cast.*]`). +The generic rules (text is never rewritten, NVL for lyric passages, text rhythm, sprites and +expressions, transitions, music, the `work.toml` override layer) live in vnpipe: +`../vnpipe/docs/adaptation-rules.md`. This file records how they apply to Faust; the +decisions themselves are in `work.toml` (`[staging.*]`, `[[cues]]`, `[[overrides]]`). -## Principle: show less, suggest more +## Application to Faust -A VN tempts you to draw everything. Romantic verse drama works better when the image -sets the mood and the words carry the scene. So: +- Sprites appear in dialogue scenes only: the theatre, Mephistopheles before the Lord, + Faust in his study. +- The ineffable is never drawn. The Lord is a radiance (`bg_heaven_lord`); the Earth Spirit + is a lighting change plus a flash and a shake (`bg_study_spirit`). Their lines still + carry a name and colour. +- The Dedicatoria (the poet's own voice) and the archangels' hymn are NVL poems over a + background. +- The three archangels are painted into `bg_heaven`, not drawn as three sprites. +- One background per location, plus variants only where the text changes the light + (macrocosm sign, Earth Spirit, heaven closing). +- The prototype ships without audio; music moods are annotated but only played if + `vn/game/audio/.ogg` exists. -1. **Draw people only when they converse.** Sprites appear in dialogue scenes (the - theatre, Mephistopheles before the Lord, Faust in his study). -2. **Never draw the ineffable.** The Lord is a radiance (`bg_heaven_lord`), never a - figure; the Earth Spirit is a lighting change plus a flash and a shake - (`bg_study_spirit`), never a sprite. Their lines still carry a name and colour. -3. **Lyric passages are full-screen text (NVL).** The Dedicatoria (the poet's own voice) - and the archangels' hymn are read as poems over a background, without a dialogue - box or sprites. -4. **Choral or crowd presences belong to the background.** The three archangels are - painted into `bg_heaven`, not drawn as three sprites. -5. **Stage directions are narration**, shown in italics by the narrator. Directions that - change the scene also trigger a cue (background, tint, transition). Cast lists under - a scene heading are not shown; they only inform who is on stage. -6. **One background per location**, plus variants only where the text itself changes - the light (macrocosm sign, Earth Spirit, heaven closing). - -## Text rhythm - -- Each scene opens with a title card (scene heading, centred, over black). -- Verse is grouped into text boxes of at most **4 lines**, never crossing a stanza or a - speaker change. In NVL, a whole stanza (max 8 lines) is shown before the page clears. -- Split verse lines (a line shared between two speakers, printed deeply indented) are - shown as their own box so the exchange keeps its speed. - -## Sprites and expressions - -- The annotation gives each line one emotion from a fixed vocabulary: `neutral`, - `joyful`, `melancholic`, `solemn`, `ironic`, `angry`, `fearful`, `ecstatic`. -- `work.toml` maps that vocabulary to the 3–4 expressions each character actually has - (`[cast.].expressions`). A text box uses the emotion of its first line. -- Positions (`left`, `center`, `right`) come from the annotation, but the first - position a character gets in a scene is kept for the whole scene, so nobody jumps - around between boxes. -- Characters with `sprite = false` are never drawn, even if annotated as on stage. - -## Human judgment layer - -The annotation is an LLM's first guess; `work.toml` can override it, generically: - -- `[staging.].cast = { = "" }` pins characters (sprite = true) on stage - at fixed positions for the whole scene, overriding the annotation's `on_stage`. -- A cue's `move = { = "" }` slides a visible sprite to another position. -- `[[overrides]] { from, to, emotion }` forces the emotion of an inclusive line range - (same scene) before expression mapping. - -Stage-direction lines never change who is on stage (they keep the previous box's -`on_stage`). Unknown line ids, characters, positions or emotions are errors at generation. - -## Transitions - -- `dissolve` between expressions and on sprite entry/exit, `fade` between scenes, - `slow` (2 s dissolve) for light changes, `flash` for supernatural apparitions. - -## Music - -Every line carries an optional music mood (`contemplative`, `comic`, `sacred`, -`ominous`, `mystical`, `none`). The prototype ships without audio; the generator emits -`play music` only when `game/audio/.ogg` exists, so adding files is enough. - -## Staging for Faust (work.toml) +## Staging (work.toml) | Scene | Base | Notes | |---|---|---| diff --git a/docs/art-bible.md b/docs/art-bible.md index a584c98..3f35b1e 100644 --- a/docs/art-bible.md +++ b/docs/art-bible.md @@ -2,7 +2,7 @@ The look of every asset is fixed here before anything is generated. Prompts are assembled mechanically: **base prompt + kind template + asset prompt**. The exact -strings live in `works/faust/assets/assets.json` (`base_prompt` and each asset's +strings live in `assets/assets.json` (`base_prompt` and each asset's `prompt`); this document explains them. ## Look diff --git a/docs/plan.md b/docs/plan.md index 545ef2d..5a5c189 100644 --- a/docs/plan.md +++ b/docs/plan.md @@ -1,11 +1,11 @@ # Plan Goal: a playable Ren'Py prototype of the opening of Goethe's *Faust I* (Llorente's -Spanish translation) **and** a reusable pipeline that turns any public-domain play -from Project Gutenberg into a visual novel. Faust is the first "work"; Werther and -others should only need a new `works//work.toml` plus art. +Spanish translation). The reusable pipeline lives in its own repo, `../vnpipe` +(see its `docs/pipeline.md`); this repo is the Faust "work": `work.toml`, data, +annotations, art and the generated game. -## Pipeline +## Pipeline (as run for Faust) ``` Gutenberg .txt ──fetch──▶ raw (cached, gitignored) @@ -15,7 +15,7 @@ Gutenberg .txt ──fetch──▶ raw (cached, gitignored) LLM sub-agents ─────▶ annotations/cache/*.json (one file per chunk, keyed by hash) ──merge──▶ annotated.json (schema-validated, complete) art (MCP) ──▶ assets/assets.json + images (manifest, sha256, status) - ──renpy──▶ vn/faust/ (generated Ren'Py project) + ──renpy──▶ vn/ (generated Ren'Py project) ``` Every stage is a `vnpipe` CLI subcommand, deterministic given its inputs, and @@ -27,25 +27,25 @@ hash, so they are resumable and never redone unless their input changes. | Path | Purpose | |---|---| -| `src/vnpipe/` | Generic pipeline code (no Faust-specific logic) | -| `src/vnpipe/schemas/` | JSON Schemas: parsed text, annotation, asset manifest | -| `works/faust/work.toml` | Everything work-specific: source URL, scope markers, cast, colors, locations, expression maps | -| `works/faust/data/` | `play.txt`, `parsed.json`, `annotated.json` | -| `works/faust/annotations/` | Chunk inputs and cached LLM outputs | -| `works/faust/assets/` | `assets.json` manifest, generated/processed images | -| `vn//` | Generated Ren'Py project (committed so the repo is playable) | -| `docs/` | Design and process docs | +| `work.toml` | Everything work-specific: source URL, scope markers, cast, colors, locations, expression maps, staging | +| `data/` | `play.txt`, `parsed.json`, `annotated.json` (`raw/` is the gitignored download) | +| `annotations/` | Chunk inputs and cached LLM outputs | +| `assets/` | `assets.json` manifest, generated/processed images (`raw/` is gitignored) | +| `vn/` | Generated Ren'Py project (committed so the repo is playable) | +| `tests/` | Faust integration tests (real text, e2e playthrough) | +| `docs/` | Faust design and process docs | +| `../vnpipe` | The pipeline code, schemas, prompts, GUI templates and generic docs | ## Steps 1. **Text** — fetch, clean, cut scope (`docs/scope.md`), deterministic parser + tests, `docs/licensing.md`. 2. **Annotation** — JSON Schema, chunker, merge/validate, cache. Haiku sub-agents - annotate chunks in parallel. Adaptation rules in `docs/adaptation-rules.md`. + annotate chunks in parallel. Faust adaptation rules in `docs/adaptation-rules.md`. 3. **Art** — `docs/art-bible.md` with a fixed base prompt. Backgrounds and sprites via the ChatGPT image MCP (max 20 generations/hour), background removal, manifest, placeholders for anything missing. -4. **Ren'Py** — generator from `annotated.json` + manifest; `renpy lint` clean; +4. **Ren'Py** — vnpipe generator from `annotated.json` + manifest; `renpy lint` clean; web/desktop build if feasible. 5. **Report** — `docs/report.md`: automation vs human judgment, cost/time, weaknesses, next steps. diff --git a/docs/report.md b/docs/report.md index 8fc428e..9ea80db 100644 --- a/docs/report.md +++ b/docs/report.md @@ -13,7 +13,7 @@ Earth Spirit's rejection of Faust — 630 verse lines, 7 stage directions, 4 sce | Parsing | Deterministic parser: scenes, speakers + notes, verse, stanzas, split verses, directions, cast lists; fails loudly on anything unknown | `parsed.json` (639 lines) | | Annotation | `vnpipe annotate chunk` → 16 chunks; 8 Haiku sub-agents (2 chunks each) in parallel; `status`/`merge` validate schema, input hash, line coverage, deterministic fields, cast ids | `annotated.json`, 0 fallback chunks, 0 invalid on first pass | | Art | One Sonnet sub-agent drove the ChatGPT image MCP (≤ 20 generations/hour), imported with sha256 verification, chroma-keyed sprites, reviewed every image | 7 backgrounds + 17 sprites, all approved | -| Ren'Py | `vnpipe renpy`: GUI from the SDK's `generate_gui` template, characters, images, script with title cards, NVL/ADV, cues, tints, flash/shake, expression mapping | `vn/faust/`, `renpy lint` clean | +| Ren'Py | `vnpipe renpy`: GUI from the SDK's `generate_gui` template, characters, images, script with title cards, NVL/ADV, cues, tints, flash/shake, expression mapping | `vn/`, `renpy lint` clean | | Builds | Ren'Py launcher `web_build` and `distribute --package linux` | `build/web/`, `build/dist/*.tar.bz2` | Everything except the LLM and image calls is deterministic and idempotent (re-running diff --git a/docs/running.md b/docs/running.md index 8fc80b4..c2b4762 100644 --- a/docs/running.md +++ b/docs/running.md @@ -1,7 +1,8 @@ # Running, linting and building the game -The Ren'Py project in `vn/faust/` is generated; never edit it by hand. All commands run -from the repository root. +The Ren'Py project in `vn/` is generated by vnpipe (`../vnpipe`); never edit it by hand. All +commands run from the repository root. Generic details (CLI, GUI template, SDK commands): +`../vnpipe/docs/running.md`. ## 1. Ren'Py SDK @@ -20,9 +21,9 @@ SDK commands, since Ren'Py writes to `~/.renpy`. ## 2. Regenerate the project ```sh -uv run vnpipe renpy # from works/faust/data/annotated.json +uv run vnpipe renpy # from data/annotated.json uv run vnpipe renpy --from-parsed # trivial annotations built from parsed.json -uv run vnpipe renpy --out some/dir # default output: vn/ +uv run vnpipe renpy --out some/dir # default output: vn ``` Generation is deterministic: running it twice gives identical files (no timestamps). @@ -31,13 +32,13 @@ It rewrites `game/{options,gui,screens,support,characters,images,script}.rpy`, is left alone. Music only appears in the script for moods that have a matching `game/audio/.ogg`, so drop files there and regenerate. -Images come from `works//assets/assets.json` (statuses `processed`, `approved`, +Images come from `assets/assets.json` (statuses `processed`, `approved`, `placeholder`); anything missing or unusable is replaced by a generated placeholder so the game always runs. ### GUI template and licences -`src/vnpipe/renpy_templates/` holds the default Ren'Py GUI (`gui.rpy`, `screens.rpy`, +`renpy_templates/` in vnpipe holds the default Ren'Py GUI (`gui.rpy`, `screens.rpy`, `options.rpy` and `gui/*.png`). It was generated once with the SDK's own command and then edited minimally (dark palette, ivory text, accent `#c9a25b`, Roboto Slab font, NVL tweaks, `@@TOKEN@@` placeholders for title/build name/about text/menu background): @@ -54,7 +55,7 @@ documentation assets. ## 3. Lint ```sh -HOME=$TMPDIR/renpy-home tools/renpy-sdk/renpy.sh vn/faust lint +HOME=$TMPDIR/renpy-home tools/renpy-sdk/renpy.sh vn lint ``` The expected result is a statistics block with no warnings above it. @@ -75,26 +76,26 @@ HOME=$TMPDIR/renpy-home SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy RENPY_RENDER The headless run needs the software renderer (`RENPY_RENDERER=sw`, no GL under the dummy video driver); matrix tints are therefore not rendered but all game logic is exercised. -`tests/test_renpy_gen.py` runs this for the fixture and for Faust when the SDK exists -(slow: about a minute). On a desktop with a display, drop the three variables. +`tests/test_faust_e2e.py` runs this when the SDK exists (`RENPY_SDK` or +`tools/renpy-sdk`; slow: about a minute). On a desktop with a display, drop the three variables. ## 4. Play ```sh -tools/renpy-sdk/renpy.sh vn/faust +tools/renpy-sdk/renpy.sh vn ``` ## 5. Builds (output under `build/`, gitignored) ```sh # Web (HTML5) -tools/renpy-sdk/renpy.sh tools/renpy-sdk/launcher web_build vn/faust --destination build/web +tools/renpy-sdk/renpy.sh tools/renpy-sdk/launcher web_build vn --destination build/web python3 -m http.server -d build/web 8000 # then open http://localhost:8000 # Linux desktop -tools/renpy-sdk/renpy.sh tools/renpy-sdk/launcher distribute vn/faust --package linux --destination build/dist +tools/renpy-sdk/renpy.sh tools/renpy-sdk/launcher distribute vn --package linux --destination build/dist ``` `--package` also accepts `win` and `mac`; omit it to build every package. The web build also leaves a `build/web.zip` next to the folder. A web build writes -`vn/faust/progressive_download.txt`; delete it (it is not part of the generated project). +`vn/progressive_download.txt`; delete it (it is not part of the generated project). diff --git a/docs/scope.md b/docs/scope.md index c948f31..6e4408e 100644 --- a/docs/scope.md +++ b/docs/scope.md @@ -5,7 +5,7 @@ Project Gutenberg #68566. ## Included -Raw file lines 1092-1921 (`works/faust/data/raw/pg68566.txt`), i.e. from the `DEDICATORIA` +Raw file lines 1092-1921 (`data/raw/pg68566.txt`), i.e. from the `DEDICATORIA` heading up to, but excluding, the `(_Llaman._)` direction at line 1923. | Scene id | Heading | Verse lines | Directions | Cast lines | Speeches | @@ -33,7 +33,7 @@ movement. ## Scope rule -Defined in `works/faust/work.toml` under `[scope]` and applied by `vnpipe.text.clean`: +Defined in `work.toml` under `[scope]` and applied by `vnpipe.text.clean`: - Start: the first line whose stripped text equals `start_marker`. Table of contents entries carry page numbers, so they never match as whole lines. @@ -41,6 +41,6 @@ Defined in `works/faust/work.toml` under `[scope]` and applied by `vnpipe.text.c (exclusive). - Illustration lines are dropped, trailing whitespace is removed, blank runs collapse to one. -`vnpipe parse` writes the result to `works/faust/data/play.txt` and the structured form to -`works/faust/data/parsed.json` (line ids `_`, numbered from 0001 per scene; +`vnpipe parse` writes the result to `data/play.txt` and the structured form to +`data/parsed.json` (line ids `_`, numbered from 0001 per scene; `src_line` points back to the raw file).