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(beautify): inherit source deck body font size for body_size seed
hugohe30ac579c768e5
diff --git a/skills/ppt-master/scripts/beautify_identity.py b/skills/ppt-master/scripts/beautify_identity.pyindex af9f3c25..d203f239 100644--- a/skills/ppt-master/scripts/beautify_identity.py+++ b/skills/ppt-master/scripts/beautify_identity.py@@ -3,10 +3,14 @@PPT Master - Beautify Identity ExtractorExtract a source deck's visual identity as JSON for the beautify-pptx workflow:-the declared `theme` (palette + major/minor fonts) plus `observed` usage-(run-level fonts incl. CJK `ea`, and frequent explicit fill colors) sampled-across slides — so the workflow can recommend theme vs actual-usage identity-and let the user confirm. Pure read: reuses the pptx_to_svg resolver, writes+the declared `theme` (palette + major/minor fonts + master placeholder sizes,+full bodyStyle ramp in `sizes.body_levels`) plus `observed` usage (run-level+fonts incl. CJK `ea`, explicit point sizes, and frequent explicit fill colors)+sampled across slides, plus `layout_sizes_pt` (in-use layout body-placeholder+level-1 sizes — a reference hint, not an auto-seed) — so the workflow can+recommend theme vs actual-usage identity, incl. a source-derived body size+(seed chain: observed → theme.sizes.body → canvas baseline) and let the user+confirm. Pure read: reuses the pptx_to_svg resolver, writesno PPTX.Usage:@@ -54,23 +58,99 @@ def _font_pair(theme_root, font_tag: str) -> dict[str, str]:return out-def _rank(counter: dict[str, int], limit: int) -> list[dict]:+def _rank(counter: dict, limit: int) -> list[dict]:"""Frequency-ranked [{value, count}, ...], most common first."""ranked = sorted(counter.items(), key=lambda kv: (-kv[1], kv[0]))return [{"value": v, "count": n} for v, n in ranked[:limit]]+def _master_text_sizes(master_root) -> dict:+ """Declared title/body point sizes from the master's <p:txStyles>.++ `title` is <p:titleStyle> level-1; `body` is <p:bodyStyle> level-1 and+ `body_levels` is every declared body outline level in order (lvl1..lvl9).+ `sz` is in hundredths of a point. This is the *declared* size — the+ placeholder default a run inherits when it sets no explicit `sz` — the size+ counterpart of `theme.fonts`. Note level-1 is the coarsest/largest body+ level and commonly over-reads real density; `body_levels` exposes the full+ ramp. Returns {} when no txStyles are present.+ """+ out: dict[str, object] = {}+ title = master_root.find(".//p:txStyles/p:titleStyle//a:defRPr", NS)+ if title is not None:+ sz = (title.attrib.get("sz") or "").strip()+ if sz.isdigit():+ out["title"] = int(sz) / 100+ body = master_root.find(".//p:txStyles/p:bodyStyle", NS)+ levels: list[float] = []+ if body is not None:+ for lvl in body: # a:lvl1pPr .. a:lvl9pPr, in document order+ defrpr = lvl.find("a:defRPr", NS)+ if defrpr is None:+ continue+ sz = (defrpr.attrib.get("sz") or "").strip()+ if sz.isdigit():+ levels.append(int(sz) / 100)+ if levels:+ out["body"] = levels[0]+ out["body_levels"] = levels+ return out+++# Placeholder types that carry chrome, not body text — excluded from the layout+# body-size sample so a 9pt footer / slide-number doesn't masquerade as body.+_NON_BODY_PH = {"title", "ctrTitle", "ftr", "sldNum", "dt", "hdr"}+++def _layout_text_sizes(pkg: "OoxmlPackage") -> list[dict]:+ """Frequency-ranked **body** placeholder `defRPr` sizes across the layouts in use.++ For a theme/template-driven deck whose runs set no explicit `sz` (everything+ inherits its placeholder), this is where a real body size can show: each+ layout's body placeholder may declare its own size where the master only gives+ the coarse level-1 default. Only layouts actually referenced by a slide count,+ only body-ish placeholders (title / footer / slide-number / date / header+ skipped), and only the placeholder's **level-1** `defRPr` — the primary size —+ so deeper outline levels (lvl2..lvl9) don't masquerade as body. Sizes in+ points. Often sparse: placeholders that don't override level-1 inherit the+ master default and contribute nothing here.+ """+ sizes: dict[float, int] = {}+ seen: set[str] = set()+ for slide in pkg.iter_slides():+ layout = slide.layout+ if layout is None or layout.path in seen:+ continue+ seen.add(layout.path)+ for sp in layout.xml.iterfind(".//p:sp", NS):+ ph = sp.find(".//p:nvSpPr/p:nvPr/p:ph", NS)+ ph_type = ph.attrib.get("type") if ph is not None else None+ if ph_type in _NON_BODY_PH:+ continue+ lvl1 = sp.find(".//a:lstStyle/a:lvl1pPr/a:defRPr", NS)+ if lvl1 is None:+ continue+ sz = (lvl1.attrib.get("sz") or "").strip()+ if sz.isdigit():+ pt = int(sz) / 100+ sizes[pt] = sizes.get(pt, 0) + 1+ return _rank(sizes, 10)++def _sample_observed(pkg: "OoxmlPackage") -> dict:- """Aggregate run-level fonts + explicit (non-theme) fill colors across slides.+ """Aggregate run-level fonts, explicit point sizes, and explicit fill colors.Theme extraction reports the *declared* identity; a hand-edited deck oftenoverrides it per shape / run. This is a frequency sample of run-level usage(not a full style resolution — it misses schemeClr + master/layoutinheritance, and counts chart/gradient fills), enough for the workflow to- recommend theme vs observed.+ recommend theme vs observed. `sizes_pt` only counts runs that set an explicit+ `sz`; runs inheriting the placeholder size are not seen here (use+ `theme.sizes` for those), so a small sample is a hint, not the full picture."""latin: dict[str, int] = {}ea: dict[str, int] = {}+ sizes: dict[float, int] = {}colors: dict[str, int] = {}for slide in pkg.iter_slides():root = slide.part.xml@@ -79,12 +159,18 @@ def _sample_observed(pkg: "OoxmlPackage") -> dict:face = (elem.attrib.get("typeface") or "").strip()if face and not face.startswith("+"): # skip +mj-*/+mn-* theme refsbucket[face] = bucket.get(face, 0) + 1+ for elem in root.iterfind(".//a:rPr", NS):+ sz = (elem.attrib.get("sz") or "").strip()+ if sz.isdigit():+ pt = int(sz) / 100+ sizes[pt] = sizes.get(pt, 0) + 1for elem in root.iterfind(".//a:srgbClr", NS):val = (elem.attrib.get("val") or "").strip().upper()if val:colors[f"#{val}"] = colors.get(f"#{val}", 0) + 1return {"fonts": {"latin": _rank(latin, 5), "ea": _rank(ea, 5)},+ "sizes_pt": _rank(sizes, 8),"colors": _rank(colors, 8),}@@ -122,6 +208,7 @@ def extract_identity(pptx_path: Path) -> dict:"title": _font_pair(theme.xml, "majorFont"),"body": _font_pair(theme.xml, "minorFont"),}+ sizes = _master_text_sizes(master.xml) if master is not None else {}w, h = pkg.slide_size_pxcanvas = {@@ -134,14 +221,15 @@ def extract_identity(pptx_path: Path) -> dict:"source": str(pptx_path),"slide_count": pkg.slide_count,"canvas": canvas,- "theme": {"palette": palette, "fonts": fonts},+ "theme": {"palette": palette, "fonts": fonts, "sizes": sizes},"observed": _sample_observed(pkg),+ "layout_sizes_pt": _layout_text_sizes(pkg),}def build_parser() -> argparse.ArgumentParser:parser = argparse.ArgumentParser(- description="Extract a source deck's theme palette + fonts + canvas as JSON.",+ description="Extract a source deck's theme palette + fonts + sizes + canvas as JSON.",formatter_class=argparse.RawDescriptionHelpFormatter,)parser.add_argument("source", help="Source .pptx file")diff --git a/skills/ppt-master/scripts/pptx_intake.py b/skills/ppt-master/scripts/pptx_intake.pyindex 94f1ae57..58e7a468 100644--- a/skills/ppt-master/scripts/pptx_intake.py+++ b/skills/ppt-master/scripts/pptx_intake.py@@ -111,8 +111,8 @@ def build_source_profile("unless the user selected a beautify/template-fill workflow."),"beautify": (- "Promote source text, page order, page count, colors, and fonts into locked "- "constraints after user confirmation."+ "Promote source text, page order, page count, colors, fonts, and font sizes "+ "into locked constraints after user confirmation."),"template_fill": ("Use slide slots, tables, charts, and geometry as the native PPTX fill contract."@@ -126,8 +126,11 @@ def build_source_profile("identity": {"theme_palette": (identity.get("theme") or {}).get("palette", {}),"theme_fonts": (identity.get("theme") or {}).get("fonts", {}),+ "theme_sizes": (identity.get("theme") or {}).get("sizes", {}),"observed_colors": (identity.get("observed") or {}).get("colors", []),"observed_fonts": (identity.get("observed") or {}).get("fonts", {}),+ "observed_sizes_pt": (identity.get("observed") or {}).get("sizes_pt", []),+ "layout_sizes_pt": identity.get("layout_sizes_pt", []),},"structure": {"canvas_px": slide_library.get("canvas_px", {}),diff --git a/skills/ppt-master/workflows/beautify-pptx.md b/skills/ppt-master/workflows/beautify-pptx.mdindex a5266391..2b590a85 100644--- a/skills/ppt-master/workflows/beautify-pptx.md+++ b/skills/ppt-master/workflows/beautify-pptx.md@@ -74,7 +74,11 @@ python3 ${SKILL_DIR}/scripts/pptx_intake.py <project_path>/sources/<source.pptx>|---|---|| `theme.palette.background` / `text` / `primary` / `accent1..6` | the deck's *declared* colors || `theme.fonts.title` / `body` (`ea` = CJK, `latin`) | the deck's *declared* fonts |+| `theme.sizes.title` / `body` (pt) | the deck's *declared* placeholder sizes (master `txStyles`) — the size a run inherits when it sets no explicit `sz`; `body` is the **level-1** default (coarsest, commonly over-reads) |+| `theme.sizes.body_levels` (pt list) | the full master `bodyStyle` ramp (lvl1..lvl9, e.g. `[32, 28, 24, 20, …]`) — **reference context** so you can read a deeper level than the over-reading level-1, not an auto-seed || `observed.colors` / `observed.fonts` (`latin` / `ea`, frequency-ranked) | a usage **sample / frequency hint** — run-level fonts + explicit `srgbClr` fills across slides |+| `observed.sizes_pt` (pt, frequency-ranked) | a usage **sample** of run-level explicit point sizes — the **size the deck actually renders at** when it overrides the placeholder default; the source for the Step 5 `body_size` recommendation |+| `layout_sizes_pt` (pt, frequency-ranked) | **reference fact only**, NOT an auto-seed — the level-1 sizes that the in-use slide layouts' body placeholders declare. Usually empty (decks rely on runs / master) and ambiguous when present; use it as a hint when judging the body size, never as the authoritative seed || `canvas.aspect` | drives the Step 3 format choice |> Note: `theme` is what the deck declares; `observed` is a frequency sample of run-level overrides (not a complete style resolution — it misses `schemeClr` and master/layout inheritance, and counts chart/gradient fills). A hand-edited deck can diverge from `theme` — Step 5 recommends which to inherit and the user confirms.@@ -135,7 +139,7 @@ If `images/image_manifest.json` does not exist because the source deck has no ex⛔ **BLOCKING**: the scope is not hard-coded — same spirit as the Eight Confirmations. Recommend each item below from what the deck actually contains (the Step 4 inventory), present the plan, and **wait for the user to confirm or adjust** before writing any spec. Chat is the canonical channel; the confirm UI below is the visual convenience surface over it for the palette + typography review (its result is honored identically to a chat reply).This step has two halves:-- **Visual re-confirm via the confirm UI** — the **full** Step 4 confirm page (below), seeded from the source so every targeted-confirmation field (canvas, mode, visual style, palette, icons, typography incl. body baseline, image strategy, generation mode) is **pre-filled with the inherited / source-derived default and left editable**. Beautify *recommends* keeping the source's identity, but never removes the user's place to override any field — you may choose not to change a value, but you must not deny the place to change it. This is also where the deck's text size is set: `<stem>.identity.json` carries fonts and palette but **no body font size** (source decks inherit sizes from master placeholders), so the body baseline is undetermined and must be chosen here, not silently defaulted to a small dense value.+- **Visual re-confirm via the confirm UI** — the **full** Step 4 confirm page (below), seeded from the source so every targeted-confirmation field (canvas, mode, visual style, palette, icons, typography incl. body baseline, image strategy, generation mode) is **pre-filled with the inherited / source-derived default and left editable**. Beautify *recommends* keeping the source's identity, but never removes the user's place to override any field — you may choose not to change a value, but you must not deny the place to change it. This is also where the deck's text size is confirmed: `<stem>.identity.json` now carries size hints — `observed.sizes_pt` (the point sizes the deck actually renders at) and `theme.sizes` (the declared placeholder defaults) — so the `body_size` recommendation **follows the source's own font size** rather than a blind canvas default; the user still confirms or overrides it here.- **Structural scope** — the inventory-driven list decisions below (ignored, reuse, needs-confirmation, verification level) stay in **chat**; they have no confirm-UI widget.| Plan item | Recommend from | Default lean |@@ -177,8 +181,8 @@ Write `<project_path>/confirm_ui/recommendations.json` and launch the same confi{ "name_zh": "备选配色 A", "name_en": "Alternative palette A", "palette": { "background": "#...", "secondary_bg": "#...", "primary": "#...", "accent": "#...", "secondary_accent": "#...", "body_text": "#..." } }] },"typography": { "selected": 0, "candidates": [- { "name_zh": "复刻源 PPT(推荐)", "name_en": "Source replica (recommended)", "heading": { "cjk": "...", "latin": "...", "css": "<PPT-safe stack>" }, "body": { "cjk": "...", "latin": "...", "css": "<PPT-safe stack>" }, "body_size": <canvas-appropriate baseline> },- { "name_zh": "实际字体(observed)", "name_en": "Observed fonts", "heading": { "cjk": "...", "latin": "...", "css": "<PPT-safe stack>" }, "body": { "cjk": "...", "latin": "...", "css": "<PPT-safe stack>" }, "body_size": <canvas-appropriate baseline> },+ { "name_zh": "复刻源 PPT(推荐)", "name_en": "Source replica (recommended)", "heading": { "cjk": "...", "latin": "...", "css": "<PPT-safe stack>" }, "body": { "cjk": "...", "latin": "...", "css": "<PPT-safe stack>" }, "body_size": <source observed size in px = dominant observed.sizes_pt ÷ 0.75> },+ { "name_zh": "实际字体(observed)", "name_en": "Observed fonts", "heading": { "cjk": "...", "latin": "...", "css": "<PPT-safe stack>" }, "body": { "cjk": "...", "latin": "...", "css": "<PPT-safe stack>" }, "body_size": <source observed size in px> },{ "name_zh": "备选字体 A", "name_en": "Alternative pairing A", "heading": { "cjk": "...", "latin": "...", "css": "<PPT-safe stack>" }, "body": { "cjk": "...", "latin": "...", "css": "<PPT-safe stack>" }, "body_size": <canvas-appropriate baseline> }] }}@@ -187,7 +191,7 @@ Write `<project_path>/confirm_ui/recommendations.json` and launch the same confi- **Recommend keep, allow override**: pre-fill canvas / mode / visual style / icons / image strategy with the source-faithful default (canvas = Step 3 format, mode = `briefing`, image_usage = `provided` since pictures are reused). Enumerable fields already list every catalog option with the source-faithful one badged, so the user can switch. Beautify's only true non-choices are the frozen text and the strict 1:1 page count (changing those means routing to the main pipeline instead — see CLAUDE.md). The §c material-divergence field is therefore not surfaced here — beautify never reshapes content (text is verbatim).- **Our recommendation is the pre-selected default = the source replica**: for color and typography, author **several candidates** like the from-scratch flow. The pre-selected default (`selected: 0`, the first card) is what beautify recommends — the candidate that **best replicates the source deck's style** (the truest reading of `theme` / `observed`). Replicate-by-default.- **Judge the other alternatives exactly as the from-scratch flow does — fonts as much as colors**: don't invent a beautify-specific rule. Author each non-replica candidate with the **same content-driven judgment the Strategist uses when generating from scratch** (color §e, typography §g), applied to the material this project provides — the source document's content and subject, the company's own theme colors, and any brand signal. Pick the palette **and** the font pairing by what fits *this* deck's content; fonts are chosen by content fit, not just defaulted to a safe face. Reach **≥3 candidates total** (PPT-safe stacks; the same creative-choice rule used elsewhere) so a user who departs from the replica still lands on a considered, content-fitting direction — depart-by-choice.-- **`body_size` is the load-bearing field**: seed it from a canvas-appropriate baseline (the page hints ≈2.5–3.3% of canvas height) — for a presentation / projection deck lean toward the relaxed end (e.g. `24` → 18pt), for a dense document deck the compact end (e.g. `18` → 13.5pt). The user sets the final value here; this is what prevents the deck from exporting at an unintentionally small size.+- **`body_size` is the load-bearing field, and the replica follows the source's own size**: seed the replica candidate's `body_size` (px) from the source's actual body size, not a blind canvas default — take the dominant `observed.sizes_pt` value (the most frequent run-level size, the **body proxy**) and convert to px (`px = pt ÷ 0.75`, e.g. source 13.5pt → `18`). The "most frequent = body" read is a proxy, not a guarantee — `observed.sizes_pt` counts every explicit run size (titles, captions, footnotes, chart/label text included, no placeholder-type resolution), so a deck dense with small labels can let a caption size outrank true body; cross-check the proxy against the page's actual body blocks and the sanity range below before trusting it, and prefer the size the body paragraphs visibly render at over the raw mode when the two disagree. Fall back to `theme.sizes.body` (the declared placeholder size) when `observed.sizes_pt` is empty, and to a canvas-appropriate baseline (≈2.5–3.3% of canvas height) only when neither is present. Note `theme.sizes.body` is the master `bodyStyle` **level-1 declared default** — a coarse value that commonly **over-reads** the real body density (decks often render body at a deeper outline level or override it smaller), so when you land on this fallback treat it as an upper-ish guess and run it through the sanity check below, never as a precise body size. `theme.sizes.body_levels` and `layout_sizes_pt` are **reference context, not extra fallback tiers**: consult them to judge a saner body value when the deck is theme-driven (`observed` empty) — e.g. a deeper `body_levels` entry or a `layout_sizes_pt` hint may read truer than level-1 — but do not auto-seed from them; the seed chain stays `observed → theme.sizes.body → canvas baseline`, and a theme-driven deck whose body size genuinely can't be pinned cleanly is exactly the case the sanity check is for. The canvas hint stays a **sanity range**, not the seed: if the source's own size lands far outside it (a dense source doc reads tiny on a projection canvas), surface that to the user rather than silently snapping — the replica recommendation is the source's size, the user confirms or overrides. Non-replica alternatives may use the canvas baseline. This is what prevents the deck from exporting at an unintentionally small size while still honoring the source.```bashpython3 ${SKILL_DIR}/scripts/confirm_ui/server.py <project_path> --daemon --wait