--- name: generate-illustrated-article description: Produce a COMPLETE illustrated help-centre article in one pass — draft the prose, deliberately choose which steps benefit from a screenshot, render source-grounded mockups, and optionally generate missing raster content or separately-ledgered external surfaces with OpenAI. Use when the user asks for a how-to guide, user-facing documentation, or help-centre article. Triggers on "write an article", "generate a guide", "document how to…", "write an illustrated article", "article with screenshots". allowed-tools: Read Glob Grep Bash Write arguments: - name: topic description: The how-to topic, e.g. "How do I invite a teammate". - name: max_images description: 'Optional. Hard limit on the number of screenshots (default: the RTFM_MAX_IMAGES environment variable, else 3). Never exceeded: group same-surface actions into one screenshot, give the main path priority, and leave the remaining actions as text.' - name: article_type description: 'Optional. how-to | troubleshooting | concept | faq. Shapes the prose structure (see "Article types"). Default: the type from the job context, else how-to.' - name: watermark description: 'Optional. on | off. Appends a slim "Screenshot created automatically by supportpages.io" strip to the bottom of every rendered PNG (default: on). Headless callers can export RTFM_WATERMARK instead; the arg takes precedence when both are given.' - name: polish description: 'Optional. on | off | only. After the post-process block, a POLISH pass (Phase 4) compares every rendered PNG against its source files and repairs omissions by adding what is missing (default: on). only skips Phases 1–3 and polishes the existing ./output/articles// for this topic. Headless callers can export RTFM_POLISH instead; the arg takes precedence when both are given.' --- You are producing a **complete illustrated help-centre article** for "$topic" — prose plus rendered PNG screenshots — in **this single session**. Doing both phases in one session lets you reuse the project map, branding, and resolved view sources instead of re-loading them cold. The crucial difference from illustrating everything: **you deliberately cover the user-performed UI actions on the main path, then choose whether any non-action steps also earn a screenshot.** `$max_images` is a **hard limit** — the `max_images` argument, else `RTFM_MAX_IMAGES` (echoed in STEP 0), else 3 — and the lint fails an article with more screenshots. Reuse one action-ready screenshot across same-surface actions; when the actions still do not fit, cover the main path first and leave conditional branches and secondary tasks as text. Rendering each mockup is the slowest part of the job, so fewer, well-chosen screenshots are the goal. Publish the article progressively: write `article.json` as soon as the prose is complete, then publish each `block_.png` immediately after that section mockup is ready. Do not hold completed screenshots until every mockup has been authored. **The reader is waiting from the first second and sees nothing until `article.json` exists, so the prose is written from a minimal grounding (Phase 1's reading budget) and the deep source resolution the mockups need happens in Phase 3, after the article is on disk — the same reading, later.** Final output remains `./output/articles//` with `article.json`, `view_sources.json`, `block_.html`, `block_.png`, `lint_report.json`, and `branding.css`, plus generated-asset files only when needed. ## Phase 1 — Draft the article prose Resolve the topic's source files and author the prose: - STEP 0 bootstrap. Derive the slug and **write the run-trace marker** (so the trace hook logs this run for later analysis), then build the image manifest: ```bash echo "rtfm-skills v$(cat ${RTFM_SKILLS_DIR:-$HOME/.rtfm-skills}/VERSION 2>/dev/null || echo '?') — generate-illustrated-article" RTFM_WORKSPACE="${RTFM_WORKSPACE:-$(${RTFM_SKILLS_DIR:-$HOME/.rtfm-skills}/generate-illustrated-article/scripts/resolve_workspace.sh)}" cd "$RTFM_WORKSPACE" || exit 1 echo "workspace=$RTFM_WORKSPACE" echo "related_repos:"; bash ${RTFM_SKILLS_DIR:-$HOME/.rtfm-skills}/generate-illustrated-article/scripts/related_repos.sh SLUG=$(echo "$topic" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//') OUT="./output/articles/$SLUG"; mkdir -p "$OUT" rm -f "$OUT/generated_image_requests.json" "$OUT/generated_images.json"; rm -rf "$OUT/generated-assets" mkdir -p ./.rtfm-trace && printf '%s\n' "$SLUG" > ./.rtfm-trace/CURRENT # trace marker — DO NOT skip mkdir -p ./.rtfm && node ${RTFM_SKILLS_DIR:-$HOME/.rtfm-skills}/generate-illustrated-article/scripts/extract_images.js . ./.rtfm/images_base64.json --cache echo "RTFM_CONTEXT_FILE=${RTFM_CONTEXT_FILE:-}" echo "RTFM_POLISH=${RTFM_POLISH:-on}" echo "RTFM_MAX_IMAGES=${RTFM_MAX_IMAGES:-3} # screenshot limit unless the max_images argument sets one" S=${RTFM_SKILLS_DIR:-$HOME/.rtfm-skills}/generate-illustrated-article/scripts echo "toolbox — one call each, instead of a file or a grep per turn:" echo " node $S/screen_pack.js [--depth N] ... a flow's markup (each view + the components it composes), its UI strings resolved from the locale files, and its icon names" echo " node $S/screen_pack.js --shell [] the app chrome every in-app mockup shares: app_shell, layout + chrome markup, strings, icons, logo" echo " node $S/mockup_kit.js classes ... bundle / source / missing for every class a mockup uses" echo " {{icon:}} in a mockup inlined as SVG by the injector (names as the source spells them: bi:x, mdi-x, mdiX, i-lucide-x, IconX, icon(\"x\"))" node $S/map_digest.js # the capability index in one screen: match the topic against it ``` **`polish=only`** (re-polish an existing article): run STEP 0 WITHOUT its `rm -f … generated_image_requests.json …` line (the existing `$OUT` is the input, keep every file), skip STEP 0.5 through Phase 3 entirely, and go straight to **Phase 4 — POLISH**. Everything else about the run (workspace, trace marker, `$OUT`) is unchanged. - **Run contract — workspace and no lint archaeology.** If the prompt or `$RTFM_WORKSPACE` names a directory, that is the target repo — use it as Cwd for every later shell command. STEP 0 also prints `workspace=`. Do not search `$HOME`, Desktop, or shell history for the project, and do not use `~/.gemini/antigravity-cli/scratch`. `$OUT` is the only artifact set for this run. Do not read prior `./output/articles/` directories (other slugs, legacy `step_N.html` naming) as templates. Do not open `scripts/lint_*.js`, `scripts/render_*.js`, or `scripts/article_blocks.js` — run the post-process linters below and fix their reports. - **Related repositories.** If STEP 0 listed anything under `related_repos:`, this product spans several repositories checked out side by side. The working directory is the one whose screens you depict: its `.rtfm/` cache, `project_map.json`, `primary_view`s, mockups and outputs all stay there. Each listed `../` is another repository of the same product (typically its API or a shared library, with its role alongside). Read a sibling wherever the behaviour you describe is decided there — validations, limits, permissions, what a server call returns, server-sent messages — and cite such files as `..//` (label evidence `found_in` accepts that form). A sibling listed with a surface other than `none` (third column) is another interface of the product with its own articles — never depict its screens here. Never `cd` into a sibling or write to it. If nothing was listed, ignore this. - STEP 0.5 — read the job context. If `RTFM_CONTEXT_FILE` is set (echoed above), Read that JSON file **before drafting anything** — it carries the product-side job context that shapes the copy: - `article_description` — the one-sentence scope the user accepted for this article. Treat it as the **scope contract**: the finished article must cover exactly what it names — a mode, qualifier, or sub-feature it mentions is load-bearing (and feeds Phase 2's screen choice). It is context, not topic text: never append it to the title, the slug, or the route matching below. - `article_justification` — why this guide was accepted; use it to angle the introduction at the reader's real goal. - `writing_style` — composed voice guidance. Apply it to EVERY prose field you write (title, introduction, prerequisites, step titles and content, tips, summary). It overrides the default tone in the prose rules below; the grounding rules (verbatim UI names, no filler) always still hold. - `content_locale` / `content_language` — the language every reader-facing word is written in (blank or `en` = English). Title, every block's title and content, and list items are in that language, and the type framing below uses the language's natural equivalent (French: how-to "Comment …" as a statement, concept "Comprendre …" or "Qu'est-ce que … ?", faq a question ending "?", troubleshooting never "Comment …"). For a non-English locale, run once in STEP 1.0: ```bash node ~/.rtfm-skills/generate-illustrated-article/scripts/find_locale_files.js "$RTFM_WORKSPACE" "" ``` **Screen labels are never translated by you.** If it reports `has_locale: true`, every on-screen label — bold terms in the prose and the text in the mockups — is the product's own translation: find the key the view references (`t(".save")`, `$t('save')`, `R.string.save`, …) in `target_files`, quote that value verbatim, add that file to the step's `partials_expanded`, and cite it as the `found_in` of its `verbatim_evidence`; mockups render those translated strings. Where a key has no translation, or `has_locale` is `false`, quote the default-language string exactly as the source has it. - `regeneration_guidance` — present only when a human reviewed a previous version of this article and asked for changes. Follow it precisely — it outranks every stylistic default, though never factual grounding (don't invent UI to satisfy it) — and re-check that the rest of the article still complies with it before you finish. - `article_type` — the article's type (see "Article types" below). The `$article_type` argument wins over this when both are set. If `RTFM_CONTEXT_FILE` is unset (interactive use), skip this step — the arguments and the defaults below are the whole contract. - STEP 1.0 — STEP 0 printed `./.rtfm/project_map.json`'s capability index (one line per entry); match the topic to a `route_index` entry **by meaning, not literal string**, and on a hit reuse its resolved `primary_view` / `partials_expanded` / `controller_action` and skip rediscovery. A route (or layout) that carries `render_chain` — the detect-resolved include tree, `[{file, via, depth, kind}]` — is fully grounded: those files are Phase 3's reading list, so never grep for the components behind a matched view. Only when no route covers the topic, discover: detect the framework from `Gemfile` / `package.json` / `mix.exs` / `manage.py` / `composer.json`, locate routes → controllers/handlers → views/templates the framework's usual way, and grep the topic keywords across templates. **Budget: commit after ~10 searches** to your best grounding; if the topic names a feature with no dedicated page, infer the closest real flow from what you've found rather than re-grepping synonyms. **Phase 1 reading budget — write the prose from the primary views, then stop reading.** The prose needs the flow's screens, the order the user moves through them, and the exact labels of the controls each step names. That comes from the matched route's `primary_view` (open it once per screen in the flow) and, when a label is not literal in that file, the one locale/i18n file that defines it. It does NOT need the layout, the shell, the partials, the components the view composes, the CSS bundle, or the modal templates — those ground the mockups and are resolved in Phase 3, after `article.json` is on disk. Aim for `article.json` within a handful of file reads of finding the route; a Phase 1 that has opened more than ~10 source files is doing Phase 3's work early. Do not write `view_sources.json` in Phase 1. **Read the flow in one call:** once you know the flow's screens, run `node ${RTFM_SKILLS_DIR:-$HOME/.rtfm-skills}/generate-illustrated-article/scripts/screen_pack.js --depth 1 [ …]` (pass `--locale ` for a non-English article). It prints each screen's markup with the components it composes and every UI string they reference, resolved from the product's locale files. That output is the Phase 1 reading: write `article.json` next (its `NEXT:` line says so), opening a file on its own only when a step's label is missing from it. **Terminal projects:** if the project map has `app_type: "terminal"`, match the topic against `command_index` instead of `route_index` (same by-meaning rule) — on a hit reuse its `definition_file`, `flags`, and `help_evidence` and skip rediscovery. Fallback discovery: identify the CLI framework from the manifest (`cli_metadata` names it) and grep for the command/flag definitions — same ~10-search budget. Everything else in Phases 1 and 2 applies unchanged, except how a step is illustrated: the steps describe commands the user types, and a step whose action is "run this command" carries the runnable command as a fenced `bash` block in its `content` (flags and paths as inline code) and takes **no screenshot slot** — a screenshot is not copyable. Terminal mockups are for full-screen TUI states (`cli_metadata.has_tui`) and for steps where the command's *output* is what the reader must read or act on. **Mobile projects:** if the project map has `app_type: "mobile"`, match the topic against `screen_index` instead of `route_index` (same by-meaning rule) — on a hit reuse its `definition_file`, `title`, `tab`, and `ui_evidence` and skip rediscovery. Fallback discovery: `mobile_metadata` names the framework and navigation library — find the screen through its route table / screen registrations (Expo Router file routes, `` registrations, `GoRoute(path:` tables), then open the screen component/widget file — same ~10-search budget. Everything else in Phases 1 and 2 applies unchanged; the steps describe screens the user taps through. **Desktop projects:** if the project map has `app_type: "desktop"`, match against `route_index` exactly as for web — desktop renderers are SPAs and the index is the same shape (router-less apps have one entry per window instead, keyed by window name). Fallback discovery: `desktop_metadata` names the renderer framework, `renderer_root`, and the `windows` list — search the renderer's router table / window entry components, same ~10-search budget. Everything else applies unchanged; the steps describe screens the user clicks through in the app window. **Win32 projects:** if the project map has `app_type: "win32"`, match the topic against `dialog_index` instead of `route_index` (same by-meaning rule; the main window lives under `""`) — on a hit reuse its `definition_file`, `title`, `controls`, `invoked_from`, and `ui_evidence` and skip rediscovery. Fallback discovery: grep the `.rc` files (`win32_metadata.rc_files`) for `CAPTION`/control labels and the menu tree — same ~10-search budget. Everything else applies unchanged; the steps describe menus the user opens and dialogs they fill in, with `invoked_from` giving each dialog's real menu path. **macOS projects:** if the project map has `app_type: "macos"`, match the topic against `view_index` instead of `route_index` (same by-meaning rule; the main window lives under `""`, hosted panes under `"/"`) — on a hit reuse its `definition_file`, `title`, `kind`, `invoked_from`, `controls`, and `ui_evidence` and skip rediscovery. Fallback discovery: grep the `.xib`/`.storyboard` files (`macos_metadata.xib_dir`) for `title="…"` attributes — same ~10-search budget. Everything else applies unchanged; the steps describe menus the user opens (menu paths from `app_shell.menus`) and windows/sheets/panes they act in. **Game projects:** if the project map has `app_type: "game"`, match against `route_index` exactly as for web — the entries are the game's screens/states, each tagged `method: "UI"` (a DOM overlay screen) or `method: "CANVAS"` (a canvas-drawn state carrying a `scene_anatomy` reproduction recipe); on a hit reuse its `primary_view`, `partials_expanded`, and `scene_anatomy` and skip rediscovery. Fallback discovery: `game_metadata` names the engine, the draw-code file, and the state variable — find the state's draw functions there, same ~10-search budget. Everything else applies unchanged; the steps describe screens and in-game states the player moves through. - Write `$OUT/article.json` with this shape: ```json { "schema_version": 2, "title": "Article title", "article_type": "how-to", "blocks": [ {"id": "introduction", "type": "prose", "presentation": "lead", "content": "1-2 sentence introduction"}, {"id": "prerequisites", "type": "list", "presentation": "checklist", "title": "Prerequisites", "items": ["What users need"]}, {"id": "open-settings", "type": "section", "presentation": "numbered", "title": "Open settings", "content": "Detailed instructions", "has_image": false}, {"id": "tips", "type": "list", "presentation": "tips", "title": "Tips", "items": ["Helpful tip"]}, {"id": "summary", "type": "prose", "presentation": "summary", "title": "Summary", "content": "1-2 sentence wrap-up"} ] } ``` **This schema-v2 shape is a fixed contract and blocks are the sole prose representation.** Do not emit the legacy `introduction`, `prerequisites`, `steps`, `tips`, or `summary` keys. Block IDs are unique, stable, URL-safe kebab-case identifiers. Preserve array order. Allowed blocks are: `prose` with `lead|body|summary`; `section` with `numbered|plain`, title/content/has_image; and `list` with `bullets|checklist|tips`, title/items. Set `has_image: false` on every section initially. `content` may carry Markdown inline code anywhere; fenced code blocks only in `section` content and `prose` body/summary — never in the lead prose or in `list` items (the app renders those inline-only, and the copy lint fails them as schema errors). Prose rules: write for **end users**, not developers; each step `content` is 1-3 short sentences; direct imperatives ("Enter your email", not "The Email field is where…"); **bold** UI element names — bold is reserved for real on-screen labels copied verbatim from the source files (the copy lint checks them against the sources); commands, flags, and paths are inline code, never bold; happy path only — no edge cases, no behind-the-scenes explanation, no filler. Default tone (when the context supplies no `writing_style`): Stripe-docs — clean, direct, minimal. These rules describe the `how-to` shape; the other article types adjust them as follows. **Code formatting** (linted): terminal commands, flags, file paths, and keys/values the user types are inline code (`--env`, `~/.config/app.toml`, `port = 8080`), never bold — bold stays for on-screen UI labels. A command the user runs on its own line, or any multi-line snippet, is a fenced block — three backticks plus a language tag (`bash`, `json`, `toml`, `text` for command output) — placed in the section `content` below the instruction sentence, in the positions the contract above allows. Inline code and flags are checked against the sources like bold terms. **Numbered sections walk runtime states.** For actionable flows, use at least one numbered section per applicable recorded state. Concept and FAQ articles normally use plain sections instead. ### Article types `article_type` resolves in this order: the `$article_type` argument → job context → `how-to`. Every type uses the same ordered-block schema: - **how-to**: lead prose, optional checklist, numbered task sections, optional tips, summary. Title starts with "How to" (or the content language's equivalent, see STEP 0.5). - **troubleshooting**: symptom-focused lead, numbered checks/fixes ordered by likelihood, optional prevention tips, summary. - **concept**: lead definition followed by plain sections for the concept's facets; no artificial steps or click path. - **faq**: direct-answer lead followed by only the plain supporting sections/lists the answer needs. Then validate the file (shape only — Phase 2 flips `has_image` later): ```bash node ${RTFM_SKILLS_DIR:-$HOME/.rtfm-skills}/generate-illustrated-article/scripts/check_article_json.js "$OUT/article.json" ``` Fix the file and re-validate if the check fails. (The copy lint in the post-process block re-checks the final file, including the prose rules.) Keep the project map, layout, chrome, branding, and the article in working memory — Phases 2 and 3 reuse them. ## Phase 2 — Cover user actions, then choose supplementary illustrations (at most `$max_images`) Now go step by step and judge, for each: **would a screenshot make this instruction materially clearer than the text alone?** - **An image helps** when the step points the user at a specific place or state in the UI — a particular form, a button's location, a filled-in field, an opened modal, a list/table the user must recognise. Seeing it removes ambiguity. - **An image does NOT help** when the step is purely textual or off-screen — "wait for approval", "you're done", a conceptual note, or a step whose UI is identical to one you're already illustrating. Merely saying "you'll receive an email" does not earn a slot; a step that requires the reader to **recognise or act in** that email (find its confirmation CTA, distinguish it from a notification, copy a code) may earn one as an external surface under Phase 2.5. **Every user-performed UI action requires screenshot coverage, within the `$max_images` limit.** Inventory every imperative that tells the reader to click, select, choose, press, tap, open, enter, type, fill, check, enable, toggle, drag, upload, paste, save, submit, send, delete, add, remove, edit, change, set, configure, pause, resume, stop, or start something in the interface. Each action's target must appear in at least one selected screenshot in its **action-ready state**: immediately BEFORE a click/select/toggle changes or removes the target; focused or populated WHILE text entry is happening, but before a later submit/navigation changes the surface. A post-action result, success state, toast, or replacement control never substitutes for the control the reader must use. An icon-only target must show its real icon and accessible label/tooltip from source. (Terminal projects: a typed command is covered by its fenced block, not a screenshot — see the terminal allocation rule below.) **Group same-surface actions instead of duplicating screenshots.** One screenshot may cover actions from several section blocks when every target is simultaneously visible. Attach it to the earliest useful section and record stable `article_block_id` and `screenshot_block_id` values in `action_coverage`. Set `has_image: true` only on sections that own a screenshot; never add `has_image` to prose or list blocks. **The limit is hard; when actions outnumber it, the main path wins.** Number the action-ready states in flow order and mark each one **main path** (every reader does it) or **conditional** (only some readers: steps written "If you…", "When…", optional settings, error recovery, alternative providers, second accounts). Group simultaneously visible targets first. If the main-path states still exceed `$max_images`, keep the earliest ones in flow order and leave the rest as text; conditional states get screenshots only from slots the main path leaves free. A step left as text keeps its precise prose — name the control in **bold** and say where it is — and gets no `action_coverage` entry. The lint reports these as text-only warnings once the limit is reached, and still fails uncovered actions while slots remain. **Keep the article to one task.** A second task a reader might do afterwards ("switch accounts", "sign out") is not a section of this article: mention it in the summary or tips instead of spending a screenshot on it. **Supplementary image budgets differ by article type; mandatory action coverage does not.** `how-to`: as described here. `troubleshooting`: after covering every check/fix control the reader uses, spend optional slots on states they must recognise. `concept`: at most ONE orienting screenshot when it contains no UI actions. `faq`: usually zero, but any answer that directs the reader to a specific control must cover that control in its action-ready state. **One screenshot per distinct action-ready state — a bounded set, not a maximum.** A screenshot earns its place only when it shows an action target no other screenshot shows; two screenshots whose targets are all visible in one faithful state are ONE screenshot. A navigation step and the entry step it leads to share one screenshot when that state contains both the navigation target and the inputs; record both actions in its coverage ledger. A new UI state the user must act on (a further form, a confirmation or selection dialog, a follow-on screen) earns a slot; a terminal success or landing screen almost never does. **A terminal *action* panel is not a terminal landing screen:** a pre-save/pre-publish/confirm panel the user acts *in* ("Are you ready to publish?", a send-confirm sheet) is an act-on state and requires coverage — the exclusion is about *passive feedback* (a toast, a success pill), not the confirmation surface itself. Deduplication never removes action-target coverage; adding a screenshot never adds coverage that an existing one already shows. **Depict the action-ready state, not its aftermath.** A screen usually exists in several states. For a click/select/toggle action, render the state immediately BEFORE activation with the named target visible; if activation removes **Start Recording** and reveals **Pause**, the action screenshot shows **Start Recording**, not **Pause**. For text entry, render the input focused or populated mid-entry so its location and expected value are clear, before submission changes the surface. An item being edited appears OPEN in its editor with real values mid-change; a panel being configured appears expanded to the control the step names. Browse/list states earn a slot only when the action target lives there or the topic itself is about finding/browsing. Outcome/confirmation states are separate, optional coverage unless the reader must act in them. **Show the control change without inventing a new product theme.** Opening a color, typography, density, or appearance control does not authorize an invented surrounding-canvas redesign. Unless the selected runtime state or opened source records the exact changed value, keep the document/canvas on its source-backed default colors, typography, spacing, and content; depict the action through the open control, focus/selection indicator, or checked option. A plausible-looking new palette is still invented and harms brand fidelity. A subsequent confirm/save screenshot clones that same canvas byte-for-byte and adds only the recorded confirmation surface (plus an explicitly recorded backdrop); it never recolors or restyles the underlying document to imply the pending change. **Allocate the budget: cover the action targets first, main path before conditional, then stop at `$max_images`.** Before marking any `has_image`, list each action-ready state the topic's verbs require. Cover every target that fits, grouping simultaneously visible targets into one screenshot. Spend a remaining slot on the entry or outcome state only when it adds recognition the action screens lack; a passive outcome/confirmation never displaces an uncovered action, and a second screenshot of an unchanged state is redundant. **When a schema-v4 runtime layout records states, allocation is topic-aware and mechanical:** (1) select every action state needed to expose the article's targets, starting with the state whose `topic_tags` best match the title and step verbs; (2) select applicable `screenshot_required`/`terminal-action` states; (3) include the `orientation` state when its visible skeleton differs and a slot remains; (4) only then include additional variants or passive outcomes. Drop an unrelated or `secondary-action` branch before orientation. Write selected/dropped IDs and topic-tag matches in `runtime_state_selection`; a generic “outside budget” reason is insufficient. For legacy schema-v2/v3 recipes without topic tags, use recorded flow order while preserving every action-ready state. A save/confirm screenshot renders the actionable panel BEFORE its confirming control is activated. **Terminal projects (`app_type: "terminal"`) allocate by output, not by typing.** A "run this command" step is `has_image: false`: its fenced block is the copyable artefact. Spend slots only on (1) each full-screen TUI state the topic passes through (`cli_metadata.has_tui`), (2) command output the reader must read or act on — a listing they pick from, a prompt they answer, a table or error they interpret — and (3) at most one orienting `--help` state when the topic is discovery itself. A step that shows both keeps both: the fence in `content`, the output in the mockup. **Stay inside the topic's surface once entered.** When the topic's flow lives inside one surface (an editor, builder, designer, wizard), every illustrated step from the entry point onward stays inside that surface and its own panels/states — do not spend a slot returning to the surrounding admin/dashboard chrome unless the flow genuinely ends there. A screenshot of the familiar outer shell is cheap to author and reads as coverage, but it is off-flow. **Stay within the topic's stated actions.** A topic that names a mode or qualifier (**automatically**, scheduled, private, shared…) must spend one slot on the screen where that mode is configured — the qualifier is the topic's most load-bearing word, and an article that never shows where it's turned on has missed its own subject. **A dedicated mode beats a generic affordance:** when the sources reveal a purpose-built mode/screen for the topic's action (a tag mode for assigning tags, a bulk-select mode, a dedicated wizard), illustrate that surface rather than a generic right-click/context-menu path — the dedicated surface is what the feature's designers built for exactly this task, and it's what the reader will be told to use. **The illustrated set is the minimum that covers the topic's actions:** an interstitial type-chooser, a confirmation pill/toast, or a second variant of a menu you already show never earns a slot — two well-chosen screens beat three. **When the topic's action exists at both the app level and a per-item level** (global speed limits vs one torrent's limits, workspace notifications vs one channel's), the topic names the **app-level** surface unless it names a specific item — a per-item screen for an app-level topic is the wrong feature, not extra coverage. Illustrate the screens the topic's own verbs name — nothing adjacent. For a "**view and manage** a collection" article, that's the collection screen itself plus its *in-place management affordances* (a per-row/item action menu, an inline toggle, an inline confirmation dialog) — those **are** "managing" and they keep you on one recognisable screen. Do NOT spend a slot on a tangential flow the topic doesn't name — creating a brand-new item, or a deep multi-tab editor sub-page — those are separate tasks (and often a different layout) that pull coverage off the article's actual subject. **For game projects,** a topic naming playing, starting, or gameplay must spend one slot on the canvas gameplay state itself (a `method: "CANVAS"` route) — menu screens alone miss the article's subject. ## Phase 2.5 — Generate missing content images or external surfaces only when required Before writing mockups, inspect the selected states for **intrinsically raster content** that the real UI requires but the repository image manifest cannot supply. Examples: a fictional participant's live camera image, an uploaded photo preview, product photography, or artwork shown inside a real media region. Prefer a suitable `{{img:…}}` repository asset whenever one exists. **Never use image generation for the mockup itself.** Build all application chrome, screens, controls, dialogs, charts, diagrams, document shells, file-type icons, logos, avatars that can be initials, and layout structure in source-grounded HTML/CSS/inline SVG. For a file upload, generation may supply the uploaded photo/video preview; it must not draw the dropzone, file icon, filename row, or surrounding interface. For a video call, generated pixels may fill camera tiles; tile layout, names, mute controls, and call chrome remain HTML/CSS. There is one separately-authorised exception: an **external surface** the user encounters outside the product application and must recognise or act in. Allowed surfaces are `confirmation-email`, `invitation-email`, `os-permission-dialog`, `browser-permission-dialog`, `push-notification`, `document`, `receipt`, and `third-party-consent`. Prefer, in order: a real repository asset; a directly renderable repository template; then an external-surface generation request. Do not generate an external surface merely for decoration or passive "you will receive…" prose. It must be the instructional state for that step, and it must never depict or extend the product application's own UI. If no content images or external surfaces qualify, do not write a request file and skip this phase. Otherwise write `$OUT/generated_image_requests.json` with at most **5 unique assets**: ```json { "version": 1, "assets": [ { "id": "participant-alex", "kind": "video-frame", "purpose": "Fictional participant visible inside the source-backed call tile", "reason": "The depicted state requires a live camera feed and the repo has no suitable image", "prompt": "Natural webcam view of a fictional adult in a bright home office", "aspect_ratio": "landscape", "alt": "Fictional participant on camera", "used_in_blocks": ["join-call", "review-notes"] } ] } ``` `kind` is `photo`, `portrait`, `video-frame`, `artwork`, `media-preview`, or `external-surface`; `aspect_ratio` is `landscape`, `portrait`, or `square`. `used_in_blocks` contains stable article block IDs. Reuse an asset when the same content persists. Keep prompts anonymous and free of secrets/customer data. For ordinary content kinds, do not ask the model to render UI, text, logos, controls, frames, icons, charts, or watermarks. An `external-surface` request additionally requires `surface`, `source_basis` (`repository|user-description|platform-convention`), `source_files` (safe project-relative paths; non-empty for `repository`), and `required_text` (1–20 exact visible strings). Put **every** name, heading, body sentence, button label, link label, code, date, and legal phrase that must be legible into `required_text`; do not leave copy for the model to invent. The helper places the exact-text ledger and external-only UI authorization into the prompt and records it in `generated_images.json`: ```json { "id": "confirmation-email", "kind": "external-surface", "surface": "confirmation-email", "source_basis": "user-description", "source_files": [], "required_text": ["Confirm your email address", "Confirm email"], "purpose": "The email in which the reader must confirm their address", "reason": "The action occurs outside the product and no renderable email template exists", "prompt": "Straight-on transactional email on a neutral mail canvas; one primary CTA", "aspect_ratio": "portrait", "alt": "Confirmation email with a Confirm email button", "used_in_steps": [2] } ``` ```bash if [ -f "$OUT/generated_image_requests.json" ]; then node ${RTFM_SKILLS_DIR:-$HOME/.rtfm-skills}/generate-illustrated-article/scripts/generate_content_images.js \ --requests "$OUT/generated_image_requests.json" \ --out "$OUT" \ --cache ./.rtfm/generated-content fi ``` The helper uses `gpt-image-2` (`OPENAI_IMAGE_MODEL` overrides), caches by prompt/model/size, and writes `$OUT/generated_images.json` plus successful files in `$OUT/generated-assets/`. Missing credentials or an API error records a failure and produces no fallback. If a failed asset was a standalone external surface, set its owning section's `has_image` false, remove its block HTML/source/coverage entry, and record the failed block ID in `generation_omissions`. Embed each ordinary content result only as an image inside the real UI: ```html Fictional participant on camera ``` The marker is mandatory. Never place `{{generated:…}}` in CSS, a background, ``, ``, or a mockup-wide container. Generated content never satisfies a repo-backed `representative_assets` obligation. For `external-surface`, make the image the standalone instructional surface instead. Add the matching body/image markers and record the same ledger in that step's `view_sources.json`; do not render any `data-rtfm-region` product regions in the step: ```html Confirmation email with a Confirm email button ``` ```json { "index": 2, "url_or_route": "external:confirmation-email", "external_surface": { "asset_id": "confirmation-email", "surface": "confirmation-email", "source_basis": "user-description", "source_files": [], "required_text": ["Confirm your email address", "Confirm email"] }, "default_user_assumptions": [], "verbatim_evidence": [] } ``` An external step omits `primary_view`, `layout`, `partials_expanded`, and runtime-state fields. Lint permits its generated `` to fill the step only when the request manifest, generated manifest, HTML markers, and `view_sources.json` ledger match exactly. Ordinary generated content remains leaf-only inside source-grounded product UI. ## Phase 3 — Progressively render the selected mockups, CHROME AUTHORED ONCE **Terminal projects** (`project_map.app_type == "terminal"`): author `view_sources.json` and the mockups per the **Terminal mockup contract** at the end of this section instead of the web chrome-once rules that follow, then rejoin at the post-process bash block — it is identical for all modes. **Mobile projects** (`project_map.app_type == "mobile"`): same routing, but per the **Mobile mockup contract** (after the terminal one). **Desktop projects** (`project_map.app_type == "desktop"`): follow the web rules below — the CSS is the app's own — but wrap every mockup per the **Desktop mockup contract** (after the mobile one). **Win32 projects** (`project_map.app_type == "win32"`): like terminal/mobile, replace the web rules with the **Win32 mockup contract** (after the desktop one). **macOS projects** (`project_map.app_type == "macos"`): same routing, per the **Macos mockup contract** (after the win32 one). **Game projects** (`project_map.app_type == "game"`): DOM overlay screens follow the web rules below — the CSS is the app's own — and canvas-drawn states follow the scene rules in the **Game mockup contract** (after the macos one); every mockup of either kind wraps in the playfield frame per that contract. **Resolve the mockup sources now, not earlier.** For each illustrated block: open its `primary_view` in full, walk the layout and its chrome files (`project_map.layouts[].chrome`), and expand every include the view renders (the classification rule below) — this is where the deep reading belongs, after the article has been published. Read the shared chrome once with `screen_pack.js --shell ` (the map's `app_shell`, the layout and its chrome files' markup, their strings and icon names, the logo), and each screen with one call — `screen_pack.js --depth 3 ` prints the view and the includes beneath it shallow-first (the `render_chain` files among them) with their UI strings, icon names and the route's `view_sources.json` fields (`primary_view`, `layout`, `partials_expanded`, the layout's chrome files) ready to copy — and Read on its own only a file they list as not printed that a region you depict needs. While authoring, check every class a mockup uses with one `mockup_kit.js classes …` call instead of grepping the bundle, and write each icon as `{{icon:}}` with a name the packs list. Then write `$OUT/view_sources.json` before the first mockup, with top-level `action_coverage` and `blocks` arrays. Include one entry per illustrated section using `block_id` equal to the section's stable ID, plus the existing source/runtime evidence fields. Each action-coverage entry uses singular `article_block_id` and `screenshot_block_id` fields, and the pictured control is marked `data-rtfm-action-target=""`; never use positional indexes. Files are `block_.html/.png`. The external-surface exception and all source-grounding requirements remain unchanged. Record one `action_coverage` entry per distinct user-performed UI action. Several entries may point to the same screenshot when it faithfully shows all targets at once: ```json { "framework": "...", "action_coverage": [ { "article_block_id": "open-settings", "screenshot_block_id": "open-settings", "kind": "click", "target": "Home", "state": "action-ready" }, { "article_block_id": "start-recording", "screenshot_block_id": "open-settings", "kind": "click", "target": "Start Recording", "state": "action-ready" } ], "runtime_state_selection": { "layout": "", "selected": [""], "dropped": [{"id": "", "reason": ""}] }, "blocks": [{"block_id": "open-settings", "...": "source/runtime evidence fields"}] } ``` `kind` is `click`, `type`, `select`, `toggle`, `drag`, `upload`, or `keyboard`; `target` is the exact visible label or source-backed accessible name of the control; `state` is always `action-ready`. `article_block_id` is the id of the article section block whose prose performs the action; `screenshot_block_id` is the id of the illustrated block whose mockup shows the target — every `screenshot_block_id` must be a `block_id` present in `blocks` with a `block_.html` mockup and `has_image: true` on its section. Put `data-rtfm-action-target=""` on the real target element in the named screenshot (`