AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He
feat(confirm-ui): two-tier confirmation (anchors → re-derive → realization)
hugohe35be8a8c085f1
diff --git a/skills/ppt-master/SKILL.md b/skills/ppt-master/SKILL.mdindex 851f0c66..53d6d7bd 100644--- a/skills/ppt-master/SKILL.md+++ b/skills/ppt-master/SKILL.md@@ -314,7 +314,7 @@ Read references/strategist.md**Eight Confirmations** (full template: `templates/design_spec_reference.md`):-⛔ **BLOCKING**: present the Eight Confirmations as a single bundled recommendation set and **wait for explicit user confirmation or modification** before outputting Design Specification & Content Outline. This is the single core confirmation point — once confirmed, all subsequent steps proceed automatically.+⛔ **BLOCKING**: present the Eight Confirmations and **wait for explicit user confirmation or modification** before outputting Design Specification & Content Outline. This is the single core confirmation gate — once the final confirmation lands, all subsequent steps proceed automatically. The default Confirm UI delivers the gate in **two tiers** (anchors → re-derive → realization; see below); the chat fallback mirrors the same two steps.1. Canvas format2. Page count range@@ -325,21 +325,38 @@ Read references/strategist.md7. Typography plan, including formula rendering policy8. Image usage approach-**Confirm UI Auto-Launch (Mandatory — default visual confirmation surface)**: by default the Eight Confirmations are presented through an interactive local page (color swatches, live font previews, candidate picks); the chat path is the always-valid fallback. Steps:+**Confirm UI Auto-Launch (Mandatory — default visual confirmation surface)**: by default the Eight Confirmations are presented through an interactive local page in **two tiers within one browser session** — Tier 1 confirms the *anchors*; the AI then re-derives the realization layer from the **user's actual** anchors; Tier 2 confirms that layer. Color swatches, live font previews, candidate picks; the chat path is the always-valid fallback. The split (full field rules: [`scripts/docs/confirm_ui.md`](scripts/docs/confirm_ui.md)):-1. Write the recommendations to `<project_path>/confirm_ui/recommendations.json` (full schema + field mapping: [`scripts/docs/confirm_ui.md`](scripts/docs/confirm_ui.md)). Two kinds of field: **enumerable** (canvas / mode / visual_style / icons / formula policy / generation mode / delivery purpose; plus image usage with a Custom path; plus AI source only when image usage may include `ai`) — the page lists common options from `confirm_ui/static/catalogs.json`, so you only name the recommended canonical `id` in a `recommend` block (canvas may be a catalog id like `ppt169` or a custom size/prose; style = `mode` + `visual_style`, two independent picks; icon ids are real libraries such as `tabler-outline`, or `emoji` for system emoji; image usage uses `ai` / `web` / `provided` / `placeholder` / `none`, or a custom prose plan when several image sources are mixed; never write bare `"custom"` for image usage — write the actual mixed plan, e.g. "AI cover + user product assets + web industry images"; write `image_ai_path` only when recommending `image_usage: "ai"` or a custom plan that includes AI); **generative** (color, typography, generated-image style) — author **≥3 candidates** each (creative recommendations always offer real choice, never a single silent option — same rule as strategist h.5; fewer than 3 only on the honest-shortfall exception, with a stated reason) (color: user-facing core `palette` with background/secondary_bg/primary/accent/secondary_accent/body_text; typography: CJK + Latin for `heading` and `body` with `css` preview stacks, plus `body_size` as the body baseline shown to the user (**pt** for PPT canvases, px for non-PPT) and `delivery_purpose` (PPT only: `text` / `balanced` / `presentation`, seeds the pt default); when recommending generated images, `image_strategy.candidates` with rendering × palette combinations from strategist h.5). `page_count` / `audience` / `content_divergence` are plain values (free text). Only open fields show a Custom box: `canvas`, `mode`, `visual_style`, `icons`, `image_usage`, and typography custom text. Closed fields (`image_ai_path`, `formula_policy`, `generation_mode`, `refine_spec`, `delivery_purpose`) stay finite. `content_divergence` is a **free-text** field shown under audience in §c — the user states in their own words how closely to follow the source vs how freely to reshape it (blank = balanced; facts stay sourced at every level). Write it as `content_divergence: { "value": "<prose or empty>" }`. It is consumed by Strategist when authoring `§IX`, recorded in `design_spec.md §I`, carries no page-count coupling, and is **not** written to `spec_lock.md`. Set `lang` to the page language; visible candidate text should match `lang`, or provide bilingual `name_zh` / `name_en` and `note_zh` / `note_en` fields. Reuse the same candidate thinking as strategist h.5.-2. Launch the page **in the background and wait for the browser confirmation** (the child server runs detached; the parent command returns after `result.json` is freshly written). **Run this command with a long tool timeout — 600000 ms** — so the `--wait` (≈590 s budget) can complete:+| Tier | Confirms | Driven by |+|---|---|---|+| **1 — anchors** | canvas · audience + core message + `content_divergence` + `delivery_purpose` *(PPT only — omitted on non-PPT canvases)* (all §c key info) · `mode` + `visual_style` | the source + user intent |+| **2 — realization** (re-derived from Tier 1) | page count · color · typography (font + size) · icons · formula policy · image usage + strategy · generation mode · refine-spec toggle | the confirmed Tier 1 |++> **Why two tiers.** Every realization field is anchored by the same few choices (`visual_style` anchors color / icon / typography / image; `delivery_purpose` drives the type band, page density, **and** the page-count recommendation). Confirming anchors first, then re-deriving, means Tier 2's candidates fit the user's *real* anchors instead of your originals — the coherence reconciliation below is done by construction on this path. Page count is a **derived** field (content volume × `delivery_purpose`), which is why it lives in Tier 2, not up front.++Steps:++> ⛔ **Steps 2 → 3 → 4 are ONE uninterrupted run — do NOT yield to the user mid-flow.** When the tier-1 `--wait` (step 2) returns, the AI **immediately and autonomously** continues to step 3 (re-derive + write Tier 2) and step 4 (`--wait-only`) in the **same turn**: do **not** summarize, ask a question, report progress, or end the turn in between. The browser is sitting on a "deriving…" spinner polling for the Tier 2 you must write next — stopping here strands the page and the user must prod you in chat to finish (a bug, not the intended flow). **The tier-1 confirmation is an intermediate machine handoff, not a stopping point.** The single ⛔ BLOCKING wait is the **final** confirmation at the end of step 4. (Chat-fallback path — only when the page never opened — is the exception: there you do present each tier in chat and wait for a reply.)++1. **Write Tier 1** to `<project_path>/confirm_ui/recommendations.json` with `"tier": 1` and only the anchor fields. Enumerable anchors (`canvas` / `mode` / `visual_style` / `delivery_purpose`) name a recommended canonical `id` in a `recommend` block (the page lists common options from `confirm_ui/static/catalogs.json`); `visual_style` also carries the ≥3-style `visual_style_spectrum` (safe / shifted / bold — same hard rule as h.5). `audience` and `content_divergence` are plain `{ "value": "<free text>" }`. `content_divergence` is the **free-text** field shown under audience in §c — how closely to follow the source vs how freely to reshape it (blank = balanced; facts stay sourced at every level); it is consumed by Strategist when authoring `§IX`, recorded in `design_spec.md §I`, carries no page-count coupling, and is **not** written to `spec_lock.md`. Set `lang` to the page language; visible text matches `lang`, or provide bilingual `name_zh` / `name_en` + `note_zh` / `note_en`.+2. **Launch + wait for Tier 1.** Background launch; the parent returns when the page writes the tier-1 `result.json`. **Long tool timeout — 600000 ms** (the `--wait` ≈590 s budget):```bashpython3 ${SKILL_DIR}/scripts/confirm_ui/server.py <project_path> --daemon --wait```- Page opens at `http://localhost:5050` — the **same port as the Step 6 live preview** (they never run at once: this page shuts down at the end of Step 4, freeing the port). If another project already holds 5050, the launcher **auto-advances to the next free port** (5051, …) and serves this project there — read the actual URL from the launch log and report that. When the user clicks **Confirm**, the command exits 0 and Step 4 reads `result.json` immediately; do not require a second chat confirmation. **Launch or wait failure is non-fatal**: if it fails or times out (flask missing, port blocked, no GUI / remote / web host, browser never confirms in time), do **NOT** troubleshoot. The detached page stays open, so a slow user may confirm after the wait returns — therefore **on any non-zero exit, re-check `<project_path>/confirm_ui/result.json` once (a fresh `status: confirmed`) before** dropping to the chat-summary fallback below.-3. **Always also print the eight recommendations as a short summary in chat, with the URL.** This keeps the chat fallback valid whether or not the browser opened. If the page never appears, the user simply confirms or edits in chat as before.-4. This is the ⛔ BLOCKING wait. Preferred page path: the `--wait` command returns after the page writes a fresh `<project_path>/confirm_ui/result.json`; immediately read that file and use its values. On a non-zero exit, re-check `result.json` once (per step 2) — a fresh `status: confirmed` still wins. Chat fallback path: only if no fresh result exists (page didn't open, wait timed out with no confirmation, or the user replies in chat with edits) take the chat values directly. Either path converges. **Typography normalization is mandatory before any spec writing**: for PPT canvases, chat-confirmed `pt` values must be converted immediately to unitless px (`px = pt × 4/3`) so `design_spec.md`, `spec_lock.md`, and SVG all see px only; keep the original pt only as provenance (`body_size_pt` / `sizes_pt`) if useful. A confirmed `result.json` is an explicit user choice: `generation_mode: "split"` means split mode was chosen; `refine_spec: true` means the refine-spec workflow was chosen.-5. **Close the confirm page (Mandatory cleanup — every path).** Once you have the confirmed values (page **or** chat), shut the confirm server down before leaving Step 4 so it cannot keep holding port 5050 (which Step 6 live preview reuses):+ Page opens at `http://localhost:5050` — the **same port as the Step 6 live preview** (they never run at once: this page shuts down at the end of Step 4). If 5050 is held, the launcher **auto-advances** (5051, …) — read the actual URL from the launch log and report it. The page does **not** close after Tier 1: it shows a "deriving…" state and polls for Tier 2. **Launch or wait failure is non-fatal**: if it fails or times out (flask missing, port blocked, no GUI / remote / web host), do **NOT** troubleshoot — **on any non-zero exit, re-check `result.json` once** (a fresh `status: tier1-confirmed`) before dropping to the chat fallback. **On success (exit 0 with a tier-1 result), do not pause or report — go straight to step 3 in the same turn.**+3. **Re-derive Tier 2 from the confirmed anchors, then write it — immediately, same turn (the page is polling for it).** Read the tier-1 `result.json` (`status: tier1-confirmed`). Using the user's **actual** confirmed anchors (not your originals), author the realization candidates and **overwrite** `recommendations.json` with `"tier": 2`: page count (content volume × `delivery_purpose`); color, typography, and generated-image style as **generative ≥3-candidate** fields (creative recommendations always offer real choice — same rule as h.5; fewer than 3 only on the honest-shortfall exception, with a stated reason; color: core `palette` with background/secondary_bg/primary/accent/secondary_accent/body_text; typography: CJK + Latin for `heading` and `body` with `css` preview stacks + `body_size` as the body baseline in **pt** for PPT / px for non-PPT, derived from the confirmed `delivery_purpose` band; images: `image_strategy.candidates` rendering × palette from h.5); enumerable `icons` / `formula_policy` / `generation_mode` (recommended `id`); `image_usage` (`ai` / `web` / `provided` / `placeholder` / `none`, or a custom prose plan when several sources mix — never bare `"custom"`; write `image_ai_path` only when the plan includes AI). The still-open page polls, renders Tier 2, and preserves the user's Tier 1 picks. Closed fields (`image_ai_path`, `formula_policy`, `generation_mode`, `refine_spec`) stay finite; open fields (`icons`, `image_usage`, typography custom text) show a Custom box.+4. **Wait for the final confirmation** — attach to the already-running page, do **not** relaunch (same 600000 ms budget):+ ```bash+ python3 ${SKILL_DIR}/scripts/confirm_ui/server.py <project_path> --wait-only+ ```+ This is the ⛔ BLOCKING completion: returns when the page writes the final `result.json` (`status: confirmed`, `stage: final`, carrying all Tier 1 + Tier 2 fields). On a non-zero exit, re-check `result.json` once. **Typography normalization is mandatory before any spec writing**: for PPT canvases, confirmed `pt` values become unitless px (`px = pt × 4/3`) so `design_spec.md`, `spec_lock.md`, and SVG see px only; keep original pt only as provenance (`body_size_pt` / `sizes_pt`). `generation_mode: "split"` / `refine_spec: true` are explicit user choices.+5. **Close the confirm page (Mandatory cleanup — every path).** Shut the server down before leaving Step 4 so it cannot keep holding port 5050 (which Step 6 live preview reuses):```bashpython3 ${SKILL_DIR}/scripts/confirm_ui/server.py <project_path> --shutdown```- This is **idempotent and required regardless of whether Confirm was clicked**: clicking Confirm already shuts the page down (this is then a no-op), but the chat-fallback path leaves the page running — without this cleanup it would block the live preview launch. Run it after reading the confirmation and before proceeding to Step 5.+ **Idempotent and required regardless of whether Confirm was clicked**: clicking the final Confirm already shuts the page down (then a no-op); the chat-fallback path leaves it running. Run it after reading the confirmation, before Step 5.++**Always also print each tier's recommendations + URL in chat** as the always-valid fallback. **The chat fallback is two-step too**: if the page never opens or a wait times out with no fresh result, present Tier 1 in chat → get confirmation → re-derive → present Tier 2 → get confirmation → take those values. Either path converges.**Honoring the confirmation (result.json is authoritative — Mandatory)**: the confirmed values **override your own recommendations** when you write `design_spec.md` / `spec_lock.md`. A user who changed any field changed it on purpose. In particular, map `image_usage` to §VIII `Acquire Via` (its value names differ from §h options — translate):@@ -353,6 +370,18 @@ Read references/strategist.mdWhen the confirmed `image_usage` is not `ai` (and the plan has no AI part), do **NOT** run h.5, do **NOT** write `ai` rows, and do **NOT** generate images in Step 5 — regardless of what you recommended. The same "confirmed value wins" rule applies to every field (color → §III, typography → §IV, etc.).+**Upstream override → re-derive untouched downstream (Mandatory — chat-fallback / single-pass path).** On the **two-tier page path this is already handled** (Step 3 re-derives Tier 2 from the user's actual anchors). It still applies whenever anchors and realization are confirmed **together** — the two-step chat fallback collapsed into one bundle, or a legacy single-pass `result.json`. "Confirmed value wins" governs each field's *own* value — never recompute a value the user set (a size, canvas, or palette they edited stays verbatim). But a single-pass `result.json` can carry a changed **anchor** beside downstream fields still holding your original — now incoherent — recommendation (e.g. switched to `dark-tech` while the light palette you proposed is untouched). Before writing the spec, reconcile: when the user changed an anchor, re-derive the downstream fields the user did **not** themselves edit so they realize the new anchor; fields the user pinned stay as confirmed.++| Anchor the user changed | Re-derive (only the downstream fields the user left at your recommendation) |+|---|---|+| `visual_style` (§d Layer 2 — anchors e–h) | color neutral tiers (§e), icon library / stroke (§f), typography character (§g), image rendering (§h.5) |+| `mode` (§d Layer 1) | outline structure + register (§IX) |+| `delivery_purpose` (§g) | body baseline + per-page density / rhythm (§6.1) |+| `audience` / core message (§c) | tone across e–h, outline emphasis (§IX) |+| `color` HEX (§e) | h.5 palette (re-filter for the new HEX) |++Reconcile **without a new blocking wait** — fold the coherent values into `design_spec.md` / `spec_lock.md` and state the adjustment in the §8 next-step handoff (e.g. "you switched to `dark-tech`; the light palette you had left no longer fit, so background / accent were re-derived — tell me if you wanted the original"). Canvas is the explicit exception: font sizes are deliberately **not** rescaled on a canvas change (see strategist §g).+**Opt-out**: if the user has said they don't want the page (e.g. "不要网页" / "just confirm in chat" / "纯聊天确认"), skip the launch entirely (step 2) and present the Eight Confirmations in chat as before — steps 1, 3, 4 still apply (recommendations summary in chat; wait; take chat values).The page is a **confirmation surface only** — Strategist still authors every recommendation; the page never generates content.diff --git a/skills/ppt-master/references/strategist.md b/skills/ppt-master/references/strategist.mdindex 9e0281b6..f9840cd9 100644--- a/skills/ppt-master/references/strategist.md+++ b/skills/ppt-master/references/strategist.md@@ -22,7 +22,16 @@ As a top-tier AI presentation strategist, receive source documents, perform cont🚧 **GATE — Mandatory read first**: `read_file templates/design_spec_reference.md` before any analysis or writing. The design_spec.md output MUST follow that template's 11-section structure exactly. After writing, self-check each section is present: I Project Info → II Canvas → III Visual Theme → IV Typography → V Layout → VI Icon → VII Visualization → VIII Image → IX Outline → X Speaker Notes → XI Tech Constraints.-⛔ **BLOCKING**: After the read, present professional recommendations for the eight items below as a bundled package and wait for explicit user confirmation.+⛔ **BLOCKING**: After the read, present professional recommendations for the eight items below and wait for explicit user confirmation.++**Two-tier confirmation (the default Confirm UI flow; chat mirrors it).** The eight items split into a dependency order, confirmed in two passes:++| Tier | Items | Role |+|---|---|---|+| **1 — anchors** | `a` canvas · `c` key info — audience + `content_divergence` + **delivery purpose** *(PPT only)* (promoted out of `g`) · `d` mode + visual_style | confirmed first |+| **2 — realization** (re-derived from the user's *actual* Tier 1) | `b` page count · `e` color · `f` icon · `g` typography (font + size) · `h` image | derived from Tier 1 |++The realization items are anchored by Tier 1 — `visual_style` governs `e` / `f` / `g` / `h` (§d Layer 2), and delivery purpose drives the §g type band, page density, **and** the `b` page-count recommendation. So author Tier 2 *after* Tier 1 is confirmed, against the user's real choices. **Page count is derived, not an anchor** — it follows content volume × delivery purpose, which is why it is Tier 2. The launch / re-derive / wait mechanics live in [SKILL.md Step 4](../SKILL.md); the item specs below keep their `a`–`h` letters.> **Execution discipline**: This is the last BLOCKING checkpoint in the pipeline. After confirmation, complete the Design Spec and proceed to image generation / SVG / post-processing without further pauses.>@@ -36,12 +45,14 @@ Recommend format based on scenario (see [`canvas-formats.md`](canvas-formats.md)### b. Page Count Confirmation-Provide specific page count recommendation based on source document content volume **and the deck's delivery purpose** (文字型 packs denser → the same source fits in fewer pages; 展示型 is one-idea-per-page → the same source may need more) — see §6.1 Content Planning Strategy. The user's confirmed count still wins; delivery purpose governs density and per-page treatment within it.+**Tier-2 (derived).** Page count is not an anchor — recommend it only after the Tier-1 delivery purpose is confirmed, since the same source yields a different count by purpose. Provide a specific page count recommendation based on source document content volume **and the confirmed delivery purpose** (文字型 packs denser → the same source fits in fewer pages; 展示型 is one-idea-per-page → the same source may need more) — see §6.1 Content Planning Strategy. The user's confirmed count still wins; delivery purpose governs density and per-page treatment within it.### c. Key Information ConfirmationConfirm target audience, usage occasion, and core message; provide initial assessment based on document nature.+**Delivery purpose** (PPT only) is confirmed here, beside audience, as part of the key information — the deck's consumption mode: 文字型 (read-close) / 均衡 (business, default) / 展示型 (presentation). It is a Tier-1 anchor: it seeds the §g body-size band, the type character, page density, and the §b page-count recommendation (both re-derived in Tier 2). Recommend one (`recommend.delivery_purpose`, default `balanced`) and let the user confirm. The full size mapping and within-band density / style nudge live in §g and §6.1 — here it is surfaced as a key-information choice, not a separate typography step.+**Material divergence** — a **free-text** intent the user states beside audience (same content-strategy cluster): in their own words, how closely the deck should follow the source vs how freely it may reshape it. This is the user's own call — a free prose field (`content_divergence`), **not** a fixed set of options and **not** something you recommend from analyzing the source. Surface the question (in the confirm UI it is a text box under audience; in chat, ask it plainly); leave it for the user to fill. Blank = a balanced default.Read the user's prose as a point on a spectrum and apply judgment — from *stay close* (track the source's structure and wording, tune only for clarity, no substantive add / drop) through the default *balanced* (re-architect and distill into a narrative under the locked `mode`, keeping all substance) to *free* (regroup, reframe, expand terse points, draw out connections latent in the source, invent section structure and transitions).@@ -225,7 +236,7 @@ See [`../templates/icons/README.md`](../templates/icons/README.md) for the curre> **Unit boundary (HARD rule).** PPT canvases may use **pt only in the confirmation layer** (`recommendations.json`, the Confirm UI, or chat fallback). Before writing `design_spec.md`, normalize the confirmed font sizes to **unitless px** (`px = pt × 4/3`) and keep px as the only design/execution value in `design_spec.md`, `spec_lock.md`, and SVG. Keep original pt only as provenance (`body_size_pt` / `sizes_pt`) when useful. Non-PPT canvases use px everywhere. Never write `pt` / `px` / `em` units into `spec_lock.md` or SVG; those layers carry unitless px numbers only. Geometry — margins, gaps, card sizes — is px everywhere.-**Baseline — pick by delivery purpose first, then density.** Delivery purpose is one of the Eight Confirmations (item 7 typography); it is the primary driver because the same canvas reads very differently when read close vs. projected. It is a **deck-wide** axis — beyond the body baseline it also drives page density / count / rhythm; see §6.1 for that side. Here it sets the body baseline:+**Baseline — pick by delivery purpose first, then density.** Delivery purpose is a **Tier-1 anchor confirmed in §c key information** (beside audience, not as a separate typography step — see §1 Two-tier confirmation); it is the primary driver because the same canvas reads very differently when read close vs. projected. It is a **deck-wide** axis — beyond the body baseline it also drives page density / count / rhythm; see §6.1 for that side. Here, with the purpose already confirmed, it sets the body baseline:| Delivery purpose (PPT 16:9) | Body (pt) | Default | Reads as ||---|---|---:|---|@@ -753,7 +764,7 @@ Templates are starting points. The Strategist may adjust based on content and auContent-outline and speaker-notes strategy follow the deck's locked **mode** — see [`modes/_index.md`](./modes/_index.md) and the locked mode's file. The guidance below applies within any mode:-**Delivery purpose drives the whole plan, not just type size.** `result.json delivery_purpose` — 文字型 (read-close) / 均衡 (business, default) / 展示型 (presentation), confirmed in item 7 — is a **deck-wide consumption mode**. It seeds the normalized body baseline (§g) **and** governs how content is distributed:+**Delivery purpose drives the whole plan, not just type size.** `result.json delivery_purpose` — 文字型 (read-close) / 均衡 (business, default) / 展示型 (presentation), confirmed as a Tier-1 anchor (§1) — is a **deck-wide consumption mode**. It seeds the normalized body baseline (§g) **and** governs how content is distributed:| Delivery purpose | Per-page density & treatment | §IX content per page | page_rhythm lean ||---|---|---|---|diff --git a/skills/ppt-master/scripts/confirm_ui/server.py b/skills/ppt-master/scripts/confirm_ui/server.pyindex 5b5e4f1e..bf36e96a 100644--- a/skills/ppt-master/scripts/confirm_ui/server.py+++ b/skills/ppt-master/scripts/confirm_ui/server.py@@ -124,6 +124,84 @@ def _wait_for_result(time.sleep(0.5)+def _result_stage(result_file: Path) -> Optional[str]:+ """Return the ``stage`` field of result.json (``tier1`` / ``final``), or None."""+ try:+ data = json.loads(result_file.read_text(encoding='utf-8'))+ except (OSError, json.JSONDecodeError):+ return None+ return data.get('stage') if isinstance(data, dict) else None+++# Tier-1 anchors. On the Tier-2 page these sections are not rendered (they were+# confirmed in Tier 1), so their values live only in browser STATE — lost on a+# refresh. Folding them from result.json into the served Tier-2 recommendations+# lets the page re-initialize them from the user's actual choices.+_ANCHOR_RECOMMEND_KEYS = ('canvas', 'mode', 'visual_style', 'delivery_purpose')+_ANCHOR_VALUE_KEYS = ('audience', 'content_divergence')+++def _merge_confirmed_anchors(data: dict, result_file: Path) -> None:+ """Fold the Tier-1 anchors confirmed in result.json into a Tier-2+ recommendations payload, so a refresh / reopen re-initializes them. The+ confirmed value is truth — it overrides any stale recommend entry."""+ try:+ res = json.loads(result_file.read_text(encoding='utf-8'))+ except (OSError, json.JSONDecodeError):+ return+ if not isinstance(res, dict):+ return+ recommend = data.setdefault('recommend', {})+ if not isinstance(recommend, dict):+ recommend = data['recommend'] = {}+ for key in _ANCHOR_RECOMMEND_KEYS:+ if res.get(key) not in (None, ''):+ recommend[key] = res[key]+ for key in _ANCHOR_VALUE_KEYS:+ if key in res:+ data[key] = {'value': res.get(key) or ''}+++def _wait_only_for_result(+ result_file: Path,+ lock_file: Path,+ timeout: int,+) -> int:+ """Attach to an already-running confirm server and wait for the **final**+ (tier-2) result.json — the second leg of the two-tier flow. No child is+ launched here: the page is still open from the first ``--wait`` launch, so+ liveness is tracked via the recorded pid, not a ``proc`` handle. Only the+ ``stage == 'final'`` guard is used (no mtime gate): this run's tier-1 confirm+ already left result.json at stage ``tier1``, so any ``final`` is the tier-2+ submit, and a mtime gate would race-miss a user who confirms before this wait.+ """+ logger.info('waiting for tier-2 browser confirmation...')+ deadline = None if timeout <= 0 else time.time() + timeout+ while True:+ # `stage == 'final'` alone is the signal: this run's tier-1 confirm already+ # overwrote result.json to stage 'tier1', so any 'final' here is the tier-2+ # submit we are waiting for. Gating on mtime >= started_at would race-miss a+ # user who confirms tier 2 before this wait is even issued.+ if _result_stage(result_file) == 'final':+ logger.info('tier-2 confirmation received: %s', result_file)+ return 0++ lock = _read_lock(lock_file)+ pid = int((lock or {}).get('pid', 0) or 0)+ if not pid or not _process_alive(pid):+ logger.error('confirm server is no longer running before tier 2 was confirmed')+ return 1++ if deadline is not None and time.time() >= deadline:+ logger.error(+ 'timed out waiting for tier-2 confirmation — the page may still '+ 'be open; re-check %s before falling back to chat', result_file,+ )+ return 124++ time.sleep(0.5)++def _shutdown_existing(lock_file: Path) -> int:"""Stop a confirm server left running for this project (idempotent).@@ -265,7 +343,9 @@ def create_app("""Serve the option universe; canvas is synced live from config.py sothe static catalogs.json copy can never drift from the real formats."""try:- return jsonify(_build_catalogs())+ resp = jsonify(_build_catalogs())+ resp.headers['Cache-Control'] = 'no-store'+ return respexcept (OSError, json.JSONDecodeError) as exc:return jsonify({'error': f'invalid catalogs.json: {exc}'}), 500@@ -282,7 +362,18 @@ def create_app(# Report whether a result already exists (re-open after confirm).result_file = confirm_dir / RESULT_NAMEdata['_already_confirmed'] = result_file.exists()- return jsonify(data)+ # Tier 2 renders only realization sections, so fold the confirmed Tier-1+ # anchors from result.json back in — a refresh / reopen then re-inits+ # canvas / audience / mode / visual_style / delivery_purpose from the+ # user's choices instead of catalog defaults.+ if data.get('tier') == 2 and result_file.exists():+ _merge_confirmed_anchors(data, result_file)+ # The page polls this endpoint after a tier-1 confirm until the AI+ # overwrites the file with the re-derived tier-2 recommendations, so it+ # must never be served from a cache.+ resp = jsonify(data)+ resp.headers['Cache-Control'] = 'no-store'+ return resp@app.route('/api/confirm', methods=['POST'])def confirm():@@ -292,14 +383,19 @@ def create_app(return jsonify({'error': 'invalid payload'}), 400confirm_dir.mkdir(parents=True, exist_ok=True)result = dict(payload)- result['status'] = 'confirmed'+ # Two-tier flow: a tier-1 submit records the anchor choices but does NOT+ # close the page (the AI re-derives tier 2, the same browser session+ # renders it). Only a final submit is a full confirmation. A payload with+ # no stage is a single-pass confirmation (chat-opt-out parity).+ stage = result.get('stage')+ result['status'] = 'tier1-confirmed' if stage == 'tier1' else 'confirmed'result['confirmed_at'] = time.strftime('%Y-%m-%dT%H:%M:%S')result_file = confirm_dir / RESULT_NAMEresult_file.write_text(json.dumps(result, ensure_ascii=False, indent=2),encoding='utf-8',)- logger.info('confirmation written to %s', result_file)+ logger.info('%s confirmation written to %s', stage or 'final', result_file)return jsonify({'status': 'ok'})return app@@ -324,6 +420,13 @@ def build_parser() -> argparse.ArgumentParser:'--wait', action='store_true',help='With --daemon, wait until a fresh result.json is written',)+ parser.add_argument(+ '--wait-only', action='store_true',+ help='Do not launch. Attach to the already-running confirm server for '+ 'this project and wait for the final (tier-2) result.json. Used for '+ 'the second leg of the two-tier flow after the tier-2 '+ 'recommendations have been re-derived and written.',+ )parser.add_argument('--wait-timeout', type=int, default=WAIT_TIMEOUT_DEFAULT,help=f'Seconds the --wait parent blocks before returning (default: {WAIT_TIMEOUT_DEFAULT}; '@@ -362,6 +465,15 @@ def main(argv: Optional[list[str]] = None) -> int:if args.shutdown:return _shutdown_existing(project_path / LOCK_FILE_NAME)+ # Tier-2 wait: attach to the server already serving this project (launched by+ # the first --wait) and block until the page writes the final result.json.+ if args.wait_only:+ return _wait_only_for_result(+ project_path / CONFIRM_DIR_NAME / RESULT_NAME,+ project_path / LOCK_FILE_NAME,+ args.wait_timeout,+ )+rec_file = project_path / CONFIRM_DIR_NAME / RECOMMENDATIONS_NAMEif not rec_file.exists():logger.error(diff --git a/skills/ppt-master/scripts/confirm_ui/static/app.js b/skills/ppt-master/scripts/confirm_ui/static/app.jsindex b4eb0563..2f32306e 100644--- a/skills/ppt-master/scripts/confirm_ui/static/app.js+++ b/skills/ppt-master/scripts/confirm_ui/static/app.js@@ -16,6 +16,8 @@loading: "Loading…",load_error: "Could not load recommendations.json. The AI must write it before launch.",btn_confirm: "Confirm",+ btn_next: "Next →",+ deriving: "Generating the downstream options from your choices…",already_confirmed: "Already confirmed once. Re-submitting overwrites the previous choices.",confirmed_title: "✓ Confirmed",confirmed_hint: "Your choices are saved. You can close this page and return to the chat.",@@ -94,6 +96,8 @@loading: "加载中…",load_error: "无法加载推荐文件,需在启动前写入。",btn_confirm: "确认",+ btn_next: "下一步 →",+ deriving: "正在据你的选择生成下游选项…",already_confirmed: "已确认过一次,重新提交会覆盖之前的选择。",confirmed_title: "✓ 已确认",confirmed_hint: "选择已保存,可关闭此页并回到聊天窗口。",@@ -247,10 +251,15 @@return node;}+ // Section numbers run 1..N within the tier currently rendered; the counter is+ // reset at the top of renderForTier. The legacy `num` arg is ignored so each+ // tier numbers its own sections cleanly (tier 2 is not a continuation of 1).+ var _secCounter = 0;function section(num, titleKey, noteText) {+ _secCounter += 1;var sec = el("div", "section");var head = el("div", "section-head");- head.appendChild(el("span", "section-num", String(num)));+ head.appendChild(el("span", "section-num", String(_secCounter)));head.appendChild(el("span", "section-title", t(titleKey)));if (noteText) head.appendChild(el("span", "section-note", noteText));sec.appendChild(head);@@ -547,6 +556,20 @@textField(subDiv, function () { return STATE.content_divergence; },function (v) { STATE.content_divergence = v; }, "placeholder_divergence", false);sec.appendChild(subDiv);+ // Delivery purpose (PPT only) lives in the §c key-information confirmation,+ // beside audience — it is part of "who / how this deck is consumed". It is a+ // Tier-1 anchor: its value seeds the body-size band, type character, page+ // density, and the re-derived Tier-2 page-count recommendation. Non-PPT+ // canvases carry no PowerPoint pt semantics, so the axis does not apply.+ if (isPptCanvas(STATE.canvas)) {+ var purposeField = el("div", "subfield");+ purposeField.appendChild(el("div", "subfield-label", t("delivery_purpose")));+ enumField(purposeField, CAT.delivery_purpose,+ recOrFirst("delivery_purpose", CAT.delivery_purpose),+ function () { return STATE.delivery_purpose; },+ function (v) { STATE.delivery_purpose = v; });+ sec.appendChild(purposeField);+ }host.appendChild(sec);}@@ -977,25 +1000,10 @@refreshBodySizeHint();sizeField.appendChild(sizeRow);- // Delivery purpose (PPT only) — informs the recommended pt baseline and the- // suggested-range hint. Picking it updates the hint + strategy signal only;- // it does not rewrite the body field (inputs are independent, no cascade).- if (isPptCanvas(STATE.canvas)) {- var purposeField = el("div", "subfield");- purposeField.appendChild(el("div", "subfield-label", t("delivery_purpose")));- enumField(purposeField, CAT.delivery_purpose,- recOrFirst("delivery_purpose", CAT.delivery_purpose),- function () { return STATE.delivery_purpose; },- function (v) {- STATE.delivery_purpose = v;- // Purpose only updates the suggested-range hint and the strategy- // signal it carries to result.json — it never rewrites the body- // size the user sees (no input interlinking).- refreshBodySizeHint();- refreshStylePreview();- });- sec.appendChild(purposeField);- }+ // Delivery purpose is a Tier-1 anchor confirmed inside renderAudience (§c) —+ // it is set before this Tier-2 section exists, so its value drives the+ // body-size hint here via STATE.delivery_purpose (preserved across the+ // single-session transition). The control itself no longer lives here.sec.appendChild(sizeField);// Per-role size override (parallel to color's per-role HEX override): the@@ -1242,31 +1250,58 @@host.appendChild(sec);}- function renderAll() {+ // Stage of the two-tier confirm flow: 1 = anchors, 2 = re-derived realization,+ // "all" = legacy single-pass (recommendations.json carried no `tier`).+ var STAGE = 1;++ function renderForTier(tier) {var host = document.getElementById("sections");host.innerHTML = "";- // Detach the previous preview's repaint closure before the sections- // re-render: color/typography auto-select would otherwise call it and- // write to now-detached nodes until renderStylePreview remounts it.+ _secCounter = 0;+ // Detach the previous preview's repaint closures before the sections+ // re-render: color/typography auto-select would otherwise call them and+ // write to now-detached nodes until renderStylePreview remounts them.refreshStylePreview = function () {};refreshBodySizeHint = function () {};refreshSizeInputs = function () {};- renderCanvas(host);- renderPages(host);- renderAudience(host);- renderStyle(host);- // Group the preview with the three sections it reflects so its sticky- // scope ends when typography scrolls past — it does not linger over the- // image / mode / refine sections below.- var styleGroup = el("div", "style-group");- renderStylePreview(styleGroup);- renderColor(styleGroup);- renderIcons(styleGroup);- renderTypography(styleGroup);- host.appendChild(styleGroup);- renderImages(host);- renderMode(host);- renderRefine(host);+ if (tier === 1) {+ // Anchors — decided first; Tier 2 is re-derived from these.+ // Delivery purpose rides inside renderAudience (§c key info).+ renderCanvas(host);+ renderAudience(host);+ renderStyle(host);+ } else {+ // Tier 2 (realization) or single-pass: page count + visual treatment.+ // Single-pass also shows the anchors up front on the same page.+ if (tier === "all") {+ renderCanvas(host);+ renderAudience(host);+ renderStyle(host);+ }+ renderPages(host);+ // Group the preview with the three sections it reflects so its sticky+ // scope ends when typography scrolls past — it does not linger over the+ // image / mode / refine sections below.+ var styleGroup = el("div", "style-group");+ renderStylePreview(styleGroup);+ renderColor(styleGroup);+ renderIcons(styleGroup);+ renderTypography(styleGroup);+ host.appendChild(styleGroup);+ renderImages(host);+ renderMode(host);+ renderRefine(host);+ }+ updateActionBar(tier);+ }++ function renderAll() { renderForTier(STAGE); }++ function updateActionBar(tier) {+ var btn = document.getElementById("btn-confirm");+ btn.disabled = false;+ // Tier 1 advances to the re-derived Tier 2; Tier 2 / single-pass confirm.+ btn.textContent = (tier === 1) ? t("btn_next") : t("btn_confirm");}// ---- state init (once) ----------------------------------------------@@ -1279,13 +1314,23 @@return recOrFirst(field, catList);}- function initState() {+ function initTier1State() {STATE.canvas = pick("canvas", CAT.canvas);- STATE.page_count = (REC.page_count && REC.page_count.value != null) ? String(REC.page_count.value) : "";STATE.audience = (REC.audience && REC.audience.value) || "";STATE.content_divergence = (REC.content_divergence && REC.content_divergence.value) || ""; // free text; blank = balanced defaultSTATE.mode = pick("mode", CAT.modes);STATE.visual_style = pick("visual_style", CAT.visual_styles);+ // Delivery purpose drives the PPT confirmation pt baseline; default balanced+ // (not the catalog-first id) when the Strategist did not recommend one.+ STATE.delivery_purpose = recId("delivery_purpose") || "balanced";+ }++ // Tier-2 fields are (re-)read from the recommendations. At boot they come from+ // whatever recommendations.json carried; after a tier-1 confirm enterTier2()+ // calls this again with the re-derived candidates. Tier-1 STATE is preserved+ // across the single-session transition — this never resets the anchors.+ function initTier2State() {+ STATE.page_count = (REC.page_count && REC.page_count.value != null) ? String(REC.page_count.value) : (STATE.page_count || "");var cc = (REC.color && REC.color.candidates) || [];var csel = (REC.color && REC.color.selected) || 0;@@ -1311,9 +1356,6 @@STATE.generation_mode = pick("generation_mode", CAT.generation_mode);STATE.refine_spec = !!((REC.refine_spec && REC.refine_spec.value) || (REC.recommend && REC.recommend.refine_spec));- // Delivery purpose drives the PPT confirmation pt baseline; default balanced- // (not the catalog-first id) when the Strategist did not recommend one.- STATE.delivery_purpose = recId("delivery_purpose") || "balanced";// Guarantee a body baseline even when a candidate omitted body_size, on// any canvas (PPT → pt default by purpose, non-PPT → px from canvas height),// so role sizes never derive from an empty anchor.@@ -1322,6 +1364,11 @@}}+ function initState() {+ initTier1State();+ initTier2State();+ }+// ---- confirm + close -------------------------------------------------function showConfirmedOverlay() {var ov = document.getElementById("confirmed-overlay");@@ -1330,10 +1377,78 @@ov.style.display = "flex";}+ // ---- tier-1 submit + re-derive transition ---------------------------+ function submitTier1() {+ var btn = document.getElementById("btn-confirm");+ // Anchors only — the page stays open; the AI re-derives Tier 2 and the+ // same browser session renders it (STATE is preserved across the poll).+ var payload = {+ stage: "tier1",+ canvas: STATE.canvas,+ audience: STATE.audience,+ content_divergence: STATE.content_divergence,+ mode: STATE.mode,+ visual_style: STATE.visual_style+ };+ // Delivery purpose is PPT-only and rendered only on PPT canvases (§c).+ // On a non-PPT canvas the control is never shown, so STATE holds an unseen+ // default — do NOT write it as a confirmed anchor, or it would steer the+ // Tier-2 page-count / density re-derivation behind the user's back. (The+ // final submit drops it for non-PPT the same way, via normalizeTypographyForSubmit.)+ if (isPptCanvas(STATE.canvas)) {+ payload.delivery_purpose = STATE.delivery_purpose;+ }+ btn.disabled = true;+ fetch("/api/confirm", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify(payload)+ }).then(function (r) {+ if (!r.ok) throw new Error("tier1 failed");+ showDeriving();+ pollForTier2();+ }).catch(function () {+ btn.disabled = false;+ document.getElementById("confirm-status").textContent = t("error_retry");+ });+ }++ function showDeriving() {+ document.getElementById("sections").style.display = "none";+ document.getElementById("actionbar").style.display = "none";+ var l = document.getElementById("loading");+ l.textContent = t("deriving");+ l.style.display = "block";+ }++ // Poll the recommendations endpoint (no-store) until the AI overwrites it with+ // the re-derived Tier 2, then render Tier 2 in the same session.+ function pollForTier2() {+ fetch("/api/recommendations", { cache: "no-store" })+ .then(function (r) { if (!r.ok) throw new Error("poll failed"); return r.json(); })+ .then(function (data) {+ if (data && data.tier === 2) { enterTier2(data); }+ else { setTimeout(pollForTier2, 1200); }+ })+ .catch(function () { setTimeout(pollForTier2, 1500); });+ }++ function enterTier2(data) {+ REC = data;+ initTier2State(); // re-read realization fields; tier-1 STATE preserved+ STAGE = 2;+ document.getElementById("loading").style.display = "none";+ document.getElementById("sections").style.display = "block";+ document.getElementById("actionbar").style.display = "flex";+ document.getElementById("confirm-status").textContent = "";+ renderForTier(2);+ }+function confirm() {var btn = document.getElementById("btn-confirm");var payload = JSON.parse(JSON.stringify(STATE));normalizeTypographyForSubmit(payload);+ payload.stage = "final";var customImagePlan = usesCustomImagePlanValue(payload.image_usage);if (payload.image_usage === "custom" || (customImagePlan && !String(payload.image_usage).trim())) {document.getElementById("confirm-status").textContent = t("image_usage_custom_required");@@ -1391,7 +1506,9 @@refreshLangToggle(toggleBtn);if (REC && CAT) renderAll(); // STATE persists → selections preserved});- document.getElementById("btn-confirm").addEventListener("click", confirm);+ document.getElementById("btn-confirm").addEventListener("click", function () {+ if (STAGE === 1) { submitTier1(); } else { confirm(); }+ });Promise.all([loadCatalogs(),@@ -1405,6 +1522,8 @@if (!hasStored) { LANG = REC.lang; applyStaticTranslations(); refreshLangToggle(toggleBtn); }}initState();+ // tier 1 / 2 from the recommendations; absent → legacy single-pass.+ STAGE = (REC.tier === 1) ? 1 : (REC.tier === 2 ? 2 : "all");document.getElementById("loading").style.display = "none";document.getElementById("sections").style.display = "block";document.getElementById("actionbar").style.display = "flex";diff --git a/skills/ppt-master/scripts/docs/confirm_ui.md b/skills/ppt-master/scripts/docs/confirm_ui.mdindex d9937e63..8cc63852 100644--- a/skills/ppt-master/scripts/docs/confirm_ui.md+++ b/skills/ppt-master/scripts/docs/confirm_ui.md@@ -5,7 +5,8 @@## `confirm_ui/server.py````bash-python3 scripts/confirm_ui/server.py <project_path> --daemon --wait+python3 scripts/confirm_ui/server.py <project_path> --daemon --wait # launch + wait for Tier 1+python3 scripts/confirm_ui/server.py <project_path> --wait-only # Tier 2: attach to the running page, wait for the final resultpython3 scripts/confirm_ui/server.py <project_path> --daemonpython3 scripts/confirm_ui/server.py <project_path> --daemon --port 5051python3 scripts/confirm_ui/server.py <project_path> --no-browser@@ -16,6 +17,7 @@ python3 scripts/confirm_ui/server.py <project_path> --shutdown # Step 4 clean- Binds `127.0.0.1:5050` by default — or the next free port if another project already holds it (the launch log prints the actual URL) — and auto-opens the browser (suppress with `--no-browser`). `--port <other>` forces a specific port.- **Shares port 5050 with the live preview server** (`svg_editor/server.py`). The two never run at once: confirm is Step 4, live preview is Step 6, and Step 4 always shuts this server down on exit (see `--shutdown`) so the port is free. One port = one forward rule for the whole pipeline. They still keep **separate processes and locks** (`.confirm_ui.lock` vs `.live_preview.lock`).- `--daemon` starts the Flask process in the background; add `--wait` in the main pipeline so the parent command returns only after the page writes a fresh `result.json`. The `--wait` budget defaults to **590 s** (`--wait-timeout`), kept under the typical 600 s tool ceiling — run the launch with a long tool timeout (≈600000 ms). On timeout the parent returns non-zero but the detached server keeps running, so the caller must re-check `result.json` once before the chat fallback (a slow user may confirm just after the wait returns).+- `--wait-only` is the **second leg of the two-tier flow**: it does **not** launch a server — it attaches to the page already running from the first `--daemon --wait` and blocks until the page writes the **final** result (`stage: "final"`). It keys on the **stage alone** (no mtime gate): this run's tier-1 confirm already left result.json at `stage: "tier1"`, so any `final` is the tier-2 submit — and an mtime gate would race-miss a user who confirms tier 2 before this wait is issued. Same `--wait-timeout` budget; on timeout / server-gone it returns non-zero and the caller re-checks `result.json` once before the chat fallback.- `--shutdown` stops a confirm server left running for this project and exits — **idempotent** (a no-op when nothing is running). Tries a graceful `/api/shutdown`, falls back to killing the recorded pid, then clears the lock. SKILL.md Step 4 runs this on every path (page-confirm or chat-fallback) so the page never lingers on the shared port before live preview starts.- Refuses to start unless `<project_path>/confirm_ui/recommendations.json` exists (except `--shutdown`, which needs no recommendations).- Per-project lock at `<project_path>/.confirm_ui.lock` — duplicate launches are refused; stale locks (dead pid) are overwritten.@@ -45,6 +47,18 @@ The front-end loads `/api/catalogs` (served by the confirm server) and falls bacBoth files live under `<project_path>/confirm_ui/`.+### Two-tier flow++The page runs as a **two-tier wizard in one browser session**. `recommendations.json` carries a top-level `"tier"`:++| `tier` | Page renders | Button | On submit |+|---|---|---|---|+| `1` | anchors — canvas, audience + `content_divergence` + `delivery_purpose` *(PPT only — omitted on non-PPT canvases, not written to the result)* (all in the §c key-info area), mode + visual_style | **Next** | writes `result.json` `{ stage: "tier1", status: "tier1-confirmed", <anchors> }`; the page does **not** close — it shows a "deriving…" state and polls `GET /api/recommendations` |+| `2` | realization — page count, color, typography, icons, formula, image usage + strategy, generation mode, refine spec | **Confirm** | writes `result.json` `{ stage: "final", status: "confirmed", <all fields> }`, then shuts the page down |+| *(absent)* | legacy single-pass — every section on one page | **Confirm** | single final write (`status: "confirmed"`) — backward-compatible |++The AI launches Tier 1 (`--daemon --wait`), reads the tier-1 result, **re-derives** the realization candidates from the user's actual anchors, overwrites `recommendations.json` with `"tier": 2` (realization fields only — it need not echo the anchors), and re-attaches with `--wait-only`. The page preserves the user's Tier 1 selections across the transition (single JS session). `GET /api/recommendations` is served `no-store` so the poll sees the tier-2 overwrite, and when `tier == 2` the server **folds the confirmed anchors from `result.json` back into the payload** (`recommend.canvas` / `mode` / `visual_style` / `delivery_purpose`, plus `audience` / `content_divergence` values) — so a **page refresh / reopen on Tier 2 re-initializes the anchors from the user's choices** instead of catalog defaults, even though those sections are not rendered on the Tier-2 page.+### Input — `recommendations.json` (written by Strategist before launch)```json@@ -117,7 +131,7 @@ Both files live under `<project_path>/confirm_ui/`.- **Candidate display text may be bilingual**: color / typography candidates can provide `name_zh` / `name_en` and `note_zh` / `note_en`; the page falls back to legacy `name` / `note`.- **Typography candidates split CJK and Latin** for both `heading` and `body`; `css` is the fallback preview `font-family` stack. The page previews CJK sample text with `cjk + css` and Latin sample text with `latin + css`, so the two script choices are visible independently. Each candidate should also include `body_size` — the body baseline, **shown in pt for PPT canvases (16:9 / 4:3), in px for non-PPT canvases** (Xiaohongshu / Story / A4 have no PowerPoint pt semantics). For PPT, the page shows/edits pt; the initial value comes from the candidate's `body_size` (sized for the recommended delivery purpose: 文字型 ~16 · 均衡 ~20 · 展示型 ~24). On submit, the page normalizes PPT values to px before writing `result.json`: `typography.body_size` is px, `typography.body_size_pt` preserves the original pt for provenance. Chat fallback must produce the same normalized contract before `design_spec.md` / `spec_lock.md` are written. The page exposes `body_size` as an editable numeric field whose hint shows a canvas-appropriate range (PPT 14–28pt by delivery purpose, non-PPT ≈2.5–3.3% of height in px). **Inputs are independent — the hint updates with canvas / delivery purpose but never rewrites a value the user can see.** It also offers a custom typography text box so the user is not limited to the proposed candidates.- **Per-role size override** (parallel to color's per-role HEX override): besides `body_size`, the page exposes **independent** editable inputs for `title` / `subtitle` / `annotation`. Each role is pre-filled **once** with a starting value — the candidate's `typography.sizes[role]` if provided, otherwise a one-time ramp suggestion (`body × ` mid-band ratio) — and then holds its own value. **There is no cross-field cascade**: changing `body_size`, `delivery_purpose`, or canvas updates only the suggested-range hint, never the role values; a re-render preserves exactly what the user sees. The final values are written to `result.json` as `typography.sizes: { "title", "subtitle", "annotation" }` in px; for PPT canvases, `typography.sizes_pt` preserves the original pt values for provenance. Seeding `sizes` in a candidate is optional — omit it and each role gets its one-time ramp suggestion.-- **`delivery_purpose`** (enumerable, PPT only) is the primary driver of the body baseline: `text` (文字型 · read-close), `balanced` (均衡 · business, the default), `presentation` (展示型 · presentation). It is surfaced inside the typography section (item 7) because it informs the recommended body pt and the suggested-range hint above — but the pick itself does not rewrite the body field (inputs are independent). `recommend.delivery_purpose` pre-selects one (default `balanced`); the user's pick writes back to `result.json.delivery_purpose` as a plain id. Strategist uses it to choose the normalized px body baseline and the within-band density/style nudge (see [strategist.md §g](../../references/strategist.md)). Non-PPT canvases omit it.+- **`delivery_purpose`** (enumerable, PPT only) is the primary driver of the body baseline: `text` (文字型 · read-close), `balanced` (均衡 · business, the default), `presentation` (展示型 · presentation). It is surfaced in the **§c key-information area** (beside audience, Tier 1) as a consumption-mode choice; the Tier-2 typography section then reads the confirmed value for the recommended body pt and the suggested-range hint — the pick itself does not rewrite the body field (inputs are independent). `recommend.delivery_purpose` pre-selects one (default `balanced`); the user's pick writes back to `result.json.delivery_purpose` as a plain id. Strategist uses it to choose the normalized px body baseline and the within-band density/style nudge (see [strategist.md §g](../../references/strategist.md)). Non-PPT canvases omit it.- **Combined style preview** — a compact live "overall impression" strip sits just above the color section and is **sticky**: it pins under the topbar so it stays visible while the user scrolls through the color / icon / typography sections, keeping the picking controls and their combined effect on screen together. It applies the currently selected color palette **and** typography (heading sample in `primary` over `background`, body sample in `body_text`, an `accent` bar, a `secondary_bg` chip) and repaints on every color / HEX-override / font / `body_size` change. It does not replace the per-candidate swatches or font samples (those stay for picking); it is deliberately an abstract style chip, **not** a slide-layout preview — page layout preview remains the live-preview server's job (Step 6). No schema field; it derives entirely from the existing color + typography selections.- **Generated image style candidates** live in `image_strategy.candidates` and are shown only when `image_usage` is `ai` or a custom image plan may include generated images. Each candidate records `rendering`, `palette`, and short `visual` / `color` / `mood` lines from Strategist h.5. The chosen value is written to `result.json.image_strategy`; it is omitted when generated images are not part of the plan.- **`visual_style_spectrum`** (optional) lets the AI surface the deck's aesthetic as a **personality spectrum** instead of one badged style. Each entry is `{ "id", "tag_zh"/"tag_en", "note_zh"/"note_en" }` where `id` is a real `visual_styles` catalog id; the page badges those chips with their temperament `tag` (replacing the single ★) and appends the `note` (a real-world analogy) inline. The full grouped style list and Custom box stay visible below, and `recommend.visual_style` is still the pre-selected default (it should equal the spectrum's safe pick). Author **≥3** spanning safe / shifted / bold (mirrors h.5; honest-shortfall exception applies — fewer only when the constraints genuinely cannot yield 3). The user's pick still writes back to `result.json.visual_style` as a plain id; the spectrum is presentation-only. Omit the field to fall back to the single-recommendation badge.@@ -144,14 +158,17 @@ Both files live under `<project_path>/confirm_ui/`."image_strategy": { "name": "方案 A", "rendering": "vector-illustration", "palette": "cool-corporate", "visual": "...", "color": "...", "mood": "..." },"generation_mode": "continuous","refine_spec": false,+ "stage": "final","status": "confirmed","confirmed_at": "2026-06-15T11:44:44"}```+The shape above is the **final** (Tier 2) result, carrying all Tier 1 + Tier 2 fields. The intermediate **Tier 1** write carries only the anchor fields plus `"stage": "tier1"`, `"status": "tier1-confirmed"`; the AI reads it to re-derive Tier 2 and never treats it as the final confirmation. A legacy single-pass write has no `stage` (or `stage: "final"`) and `status: "confirmed"`.+- Any option field may instead hold a **free-text custom string** (the user picked **Custom**); `color` / `typography` custom entries set `name: "custom"`. Image usage custom values must be concrete prose plans, not the literal string `"custom"`. The AI interprets custom text against the canonical references.- `image_ai_path` and `image_strategy` are omitted from `result.json` unless `image_usage` is `ai` or a custom image plan that may include generated images. Both are honored downstream as confirmed choices — and the page is only a convenience surface over the **canonical chat channel**: the same choices made in chat are honored identically when no `result.json` exists. `image_ai_path` drives the Step 5 generation path (`image-generator.md` §7 — `host-native` forces the host tool even when `IMAGE_BACKEND` is set); the chosen `image_strategy` candidate is locked verbatim by Strategist h.5 (no re-pick).-- After the user clicks **Confirm**, the page saves `result.json` and shuts the server down (auto-close). In the default `--daemon --wait` flow, the waiting command returns and the AI reads `result.json` immediately; no second chat confirmation is required. Chat confirmation remains the fallback when the page cannot be used. Either way, Step 4 ends with a `--shutdown` cleanup so a never-confirmed page cannot keep holding port 5050 ahead of the Step 6 live preview.+- After the user clicks the **final Confirm** (Tier 2, or single-pass), the page saves `result.json` and shuts the server down (auto-close). A Tier-1 **Next** instead keeps the page open (it polls for the re-derived Tier 2). In the default flow, the first `--daemon --wait` returns on the tier-1 result and the second `--wait-only` returns on the final result; the AI reads each immediately — no extra chat confirmation is required. Chat confirmation remains the fallback when the page cannot be used. Either way, Step 4 ends with a `--shutdown` cleanup so a never-confirmed page cannot keep holding port 5050 ahead of the Step 6 live preview.## Scope