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
fix(confirm-ui): enforce in-order stage progression with no template exemption
hugohe34bba7b38c1bd
diff --git a/skills/ppt-master/SKILL.md b/skills/ppt-master/SKILL.mdindex 09ed3652..108e6835 100644--- a/skills/ppt-master/SKILL.md+++ b/skills/ppt-master/SKILL.md@@ -419,16 +419,16 @@ Steps:python3 ${SKILL_DIR}/scripts/confirm_ui/server.py <project_path> --daemon --wait```Page opens at the launch-log URL such as `http://127.0.0.1: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 Stage 1: it shows a "deriving…" state and polls for Stage 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** for a fresh `status: stage1-confirmed` before dropping to the chat fallback. **On success (exit 0 with a stage-1 result), do not pause or report — go straight to step 3 in the same turn.**-3. **Re-derive Stage 2 from the confirmed anchors, write it, then wait for the design-system handoff — immediately, same turn (the page is polling for it).** Read the stage-1 `result.json` (`status: stage1-confirmed`). Using the user's **actual** confirmed anchors (not your originals), author the design-system candidates and **overwrite** `recommendations.json` with `"stage": "stage2"`: page count (content volume × `delivery_purpose`); color and typography as **generative ≥3-candidate** fields (creative recommendations always offer real choice; 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 **px** (every canvas) — **one fixed value per confirmed `delivery_purpose`** (`text` 20 / `balanced` 24 / `presentation` 32), not a range; each typography candidate must include topic-matched `sample_heading` / `sample_heading_latin` / `sample_body` / `sample_body_latin` preview text, never a fixed unrelated industry sample); enumerable `icons` / `formula_policy` (recommended `id`). The still-open page polls, renders Stage 2, and preserves the user's Stage 1 picks. Then attach to the already-running page; if Windows cleaned up the server, `--wait-only` auto-recovers it on the recorded/default port so the browser reconnects:+3. **Re-derive Stage 2 from the confirmed anchors, write it, then wait for the design-system handoff — immediately, same turn (the page is polling for it).** Read the stage-1 `result.json` (`status: stage1-confirmed`). Using the user's **actual** confirmed anchors (not your originals), author the design-system candidates and **overwrite** `recommendations.json` with `"stage": "stage2"`: page count (content volume × `delivery_purpose`); color and typography as **generative ≥3-candidate** fields (creative recommendations always offer real choice; 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 **px** (every canvas) — **one fixed value per confirmed `delivery_purpose`** (`text` 20 / `balanced` 24 / `presentation` 32), not a range; each typography candidate must include topic-matched `sample_heading` / `sample_heading_latin` / `sample_body` / `sample_body_latin` preview text, never a fixed unrelated industry sample); enumerable `icons` / `formula_policy` (recommended `id`). **Stage 2 is never skipped** — an active deck/layout template (`strict` adherence included) does not exempt it: the template skin becomes the recommended color / typography candidate and real alternatives fill the remaining cards. Never jump `recommendations.json` from `stage1` to `stage3`: the server refuses to render a skipped stage (the page stays on "deriving…") and the waits exit non-zero until the stages are written in order. The still-open page polls, renders Stage 2, and preserves the user's Stage 1 picks. Then attach to the already-running page; if Windows cleaned up the server, `--wait-only` auto-recovers it on the recorded/default port so the browser reconnects:```bashpython3 ${SKILL_DIR}/scripts/confirm_ui/server.py <project_path> --wait-only --wait-stage stage2```- This returns when the page writes the stage-2 `result.json` (`status: stage2-confirmed`). On a non-zero exit, re-check `result.json` once before falling back to chat.+ This returns when the page writes the stage-2 `result.json` (`status: stage2-confirmed`). On a non-zero exit, re-check `result.json` once before falling back to chat — except a `stage skip detected` error, which is not a page failure: you wrote a stage out of order; rewrite `recommendations.json` with the stage the error names and re-attach.4. **Re-derive Stage 3 from the confirmed anchors + design system, then wait for the final confirmation.** Read the stage-2 `result.json`. Author the image and execution recommendations and **overwrite** `recommendations.json` with `"stage": "stage3"`: `image_usage` as one or more source ids (`["ai"]`, `["ai","provided"]`, `["web","placeholder"]`, or `["none"]`; `none` is exclusive); `image_strategy.candidates` as **exactly three non-custom** rendering × palette recommendations from h.5 when `image_usage` includes `ai` (the page adds the fourth Custom card itself); enumerable `image_ai_path` / `generation_mode` and `refine_spec` (recommended `id` / boolean). If the recommendation involves several image sources, keep the source list structured in `recommend.image_usage` and write the usage rationale / page-role guidance into `image_notes` (for example, "封面和章节页用 AI 主视觉,产品页优先用户素材,行业背景页可用网络参考"). Write `image_ai_path` only when `image_usage` includes `ai`. Spot-illustration lean is **not** a candidate field here: it derives from the locked `visual_style`'s illustration propensity and is expressed only in the recommendation rationale / `image_notes`, never as a new confirmation field. Generated-image style palettes are **color behavior only**; final image colors follow the confirmed Stage-2 `color`. Custom image-strategy dimensions are handled by the built-in Custom card, are prose-only, and should not promise a gallery reference image. Then attach to the already-running page; `--wait-only` auto-recovers a dead server as above (same 600000 ms budget):```bashpython3 ${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 Stage 1 + Stage 2 + Stage 3 fields). On a non-zero exit, re-check `result.json` once. Confirmed sizes are **already px** (the system is px-only — no pt anywhere, no conversion): write `result.json` `typography.body_size` / `sizes` into `design_spec.md` / `spec_lock.md` / SVG verbatim. `generation_mode: "split"` / `refine_spec: true` are explicit user choices.+ This is the ⛔ BLOCKING completion: returns when the page writes the final `result.json` (`status: confirmed`, `stage: final`, carrying Stage 1 + Stage 2 + Stage 3 fields). On a non-zero exit, re-check `result.json` once (a `stage skip detected` error means Stage 2 was never confirmed — go back to step 3, not the chat fallback). Confirmed sizes are **already px** (the system is px-only — no pt anywhere, no conversion): write `result.json` `typography.body_size` / `sizes` into `design_spec.md` / `spec_lock.md` / SVG verbatim. `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> --shutdowndiff --git a/skills/ppt-master/scripts/confirm_ui/server.py b/skills/ppt-master/scripts/confirm_ui/server.pyindex ea8d8c8e..26bbe44e 100644--- a/skills/ppt-master/scripts/confirm_ui/server.py+++ b/skills/ppt-master/scripts/confirm_ui/server.py@@ -270,6 +270,11 @@ def _wait_for_result(except OSError:pass+ skip_error = _stage_skip_error(result_file.parent)+ if skip_error:+ logger.error('%s', skip_error)+ return 2+returncode = proc.poll()if returncode is not None:logger.error('confirm UI exited before a fresh result was written')@@ -346,6 +351,44 @@ def _result_stage_number(stage: Optional[str]) -> int:return 0+def _stage_skip(rec_stage_number: int, result_stage: Optional[str]) -> bool:+ """Detect a staged recommendation running ahead of the confirmed progression.++ Stages confirm strictly in order (stage1 → stage2 → stage3): a+ recommendation may only run one stage past the last confirmed result, so+ e.g. a ``stage3`` file while only stage 1 is confirmed is a skip — the+ page must not render it (an active template never exempts stage 2).+ Legacy single-pass recommendations (no ``stage``) are not staged and are+ exempt, as is any state after the final confirmation.+ """+ if rec_stage_number <= 1 or result_stage == 'final':+ return False+ return rec_stage_number > _result_stage_number(result_stage) + 1+++def _stage_skip_error(confirm_dir: Path) -> Optional[str]:+ """Return a directive error when recommendations.json skips a stage."""+ try:+ rec_data = _read_json_object(confirm_dir / RECOMMENDATIONS_NAME)+ except (OSError, json.JSONDecodeError, ValueError):+ return None+ rec_stage_number = _recommendation_stage(rec_data)+ result_stage = _result_stage(confirm_dir / RESULT_NAME)+ if not _stage_skip(rec_stage_number, result_stage):+ return None+ expected = _stage_name(_result_stage_number(result_stage) + 1)+ reattach = (+ '--daemon --wait' if expected == 'stage1'+ else '--wait-only --wait-stage stage2'+ )+ return (+ f'stage skip detected: recommendations.json is {_stage_name(rec_stage_number)} but the last '+ f'confirmed result is {result_stage or "absent"} — the page will not render a skipped stage. '+ f'Stages confirm in order and an active template does not exempt stage2 (SKILL.md Step 4). '+ f'Overwrite recommendations.json with the {expected} recommendations, then re-run with {reattach}.'+ )++def _file_version(path: Path) -> Optional[float]:"""Return a cheap file version for polling state, or None when absent."""try:@@ -389,7 +432,10 @@ def _build_session_state(result_stage = _result_stage(result_file)result_stage_number = _result_stage_number(result_stage)+ stage_skip = _stage_skip(rec_stage_number, result_stage)+ # A skipped stage is never presented: the page keeps its "deriving…" state+ # (waiting_agent) until the AI rewrites recommendations.json in order.if result_stage == 'final':expected_stage_number = Nonestatus = 'done'@@ -400,17 +446,20 @@ def _build_session_state(current_stage = _stage_name(rec_stage_number) if rec_stage_number >= 3 else 'stage2'elif result_stage == 'stage1':expected_stage_number = 2- status = 'ready_user' if rec_stage_number >= 2 else 'waiting_agent'- current_stage = _stage_name(rec_stage_number) if rec_stage_number >= 2 else 'stage1'+ ready = rec_stage_number >= 2 and not stage_skip+ status = 'ready_user' if ready else 'waiting_agent'+ current_stage = _stage_name(rec_stage_number) if ready else 'stage1'else:- expected_stage_number = rec_stage_number or 1- status = 'ready_user' if rec_stage_number else 'waiting_agent'- current_stage = rec_stage or 'stage1'+ expected_stage_number = 1 if stage_skip else (rec_stage_number or 1)+ ready = bool(rec_stage_number) and not stage_skip+ status = 'ready_user' if ready else 'waiting_agent'+ current_stage = rec_stage if ready else 'stage1'return {'session_id': previous.get('session_id') or uuid.uuid4().hex,'status': status,'current_stage': current_stage,+ 'stage_skip': stage_skip,'expected_stage': _stage_name(expected_stage_number),'expected_stage_number': expected_stage_number,'recommendation_stage': rec_stage,@@ -541,6 +590,11 @@ def _wait_only_for_result(logger.info('confirmation stage=%s received: %s', target_stage, result_file)return 0+ skip_error = _stage_skip_error(result_file.parent)+ if skip_error:+ logger.error('%s', skip_error)+ return 2+lock = _read_lock(lock_file)pid = _lock_pid(lock)if not pid or not _process_alive(pid):diff --git a/skills/ppt-master/scripts/docs/confirm_ui.md b/skills/ppt-master/scripts/docs/confirm_ui.mdindex 8a79e758..fe00677d 100644--- a/skills/ppt-master/scripts/docs/confirm_ui.md+++ b/skills/ppt-master/scripts/docs/confirm_ui.md@@ -81,6 +81,8 @@ The page runs as a **three-stage wizard in one browser session**. `recommendatioThe AI launches Stage 1 (`--daemon --wait`), reads the stage-1 result, **re-derives** the design-system candidates from the user's actual anchors, overwrites `recommendations.json` with `"stage": "stage2"`, and re-attaches with `--wait-only --wait-stage stage2`. After the Stage-2 result, it **re-derives** image and execution recommendations from the confirmed anchors + design system, overwrites `recommendations.json` with `"stage": "stage3"`, and re-attaches with `--wait-only` for the final result. The page preserves earlier selections across transitions (single JS session). `GET /api/session` is the browser's waiting-state endpoint: it is derived from `recommendations.json`, `result.json`, and the active server port, then persisted to `session.json` so a recovered server can resume the same stage state. Only after `/api/session` reports that the next recommendation stage is ready does the page fetch `GET /api/recommendations`. `GET /api/recommendations` is served `no-store` so polls see overwrites; on later stages the server folds already-confirmed choices from `result.json` back into the payload so a refresh / reopen re-initializes from the user's actual choices even though those sections are no longer rendered.+**Stage progression guard.** Stages confirm strictly in order — a staged `recommendations.json` may only run **one** stage past the last confirmed result. A file that skips ahead (e.g. `"stage3"` while only stage 1 is confirmed — typically an attempt to collapse Stage 2 because an active template already fixes color / typography) is never rendered: `/api/session` keeps reporting `waiting_agent` with `stage_skip: true`, and `--wait` / `--wait-only` exit `2` with a directive log line naming the expected stage to rewrite. An active deck/layout template — `strict` adherence included — does not exempt Stage 2: the template skin becomes the recommended color / typography candidate, not a reason to skip the confirmation. Legacy single-pass files (no `stage`) are not staged and bypass the guard.+### Input — `recommendations.json` (written by Strategist before launch)```json