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(pptx_to_svg): emit layered + flat views, expose all masters and layouts
hugohe31bd93903ec5b
diff --git a/skills/ppt-master/references/template-designer.md b/skills/ppt-master/references/template-designer.mdindex b8e47d9f..d71a98db 100644--- a/skills/ppt-master/references/template-designer.md+++ b/skills/ppt-master/references/template-designer.md@@ -20,9 +20,10 @@ When the workflow provides a PPTX reference source, the effective input package- `manifest.json` — single source of truth (slide size, theme, assets, layouts, masters, slides, page-type candidates)- `summary.md` — short orientation digest derived from manifest.json- exported `assets/`-- `svg/master_*.svg` / `svg/layout_*.svg` — each unique master / layout rendered once as standalone SVG (decorative + structural shapes only, no placeholders, no inlining of parent shapes)-- `svg/slide_NN.svg` — each slide's own shapes only; master / layout decoration is **not** inlined+- `svg/master_*.svg` / `svg/layout_*.svg` — every master / layout in the deck rendered once as standalone SVG, including ones no sample slide references (template packages often ship more design surfaces than the embedded samples exercise)+- `svg/slide_NN.svg` — each slide's own shapes only; master / layout decoration is **not** inlined here- `svg/inheritance.json` — which layout / master each slide consumes+- `svg-flat/slide_NN.svg` — companion view; each slide is self-contained so you can preview or screenshot a single page without losing the surrounding chrome. Use it as a sanity check for "what would PowerPoint actually show", not as an authoring source — the master/layout chrome will be duplicated across every flat slide.- optional screenshots for visual cross-checkingInput priority for PPTX-backed template creation:diff --git a/skills/ppt-master/scripts/docs/project.md b/skills/ppt-master/scripts/docs/project.mdindex 4eb28ca6..2accaf85 100644--- a/skills/ppt-master/scripts/docs/project.md+++ b/skills/ppt-master/scripts/docs/project.md@@ -89,6 +89,7 @@ python3 scripts/pptx_template_import.py <template.pptx> --manifest-onlypython3 scripts/pptx_template_import.py <template.pptx> --skip-manifestpython3 scripts/pptx_template_import.py <template.pptx> --embed-imagespython3 scripts/pptx_template_import.py <template.pptx> --inheritance-mode flat+python3 scripts/pptx_template_import.py <template.pptx> --inheritance-mode layered```Notes:@@ -96,8 +97,10 @@ Notes:- Summarizes slide size, theme colors, and font metadata- Infers background image inheritance across slide, layout, and master- Generates `manifest.json` (single source of truth for slide size, theme, assets, layouts, masters, slides, page-type candidates), `summary.md` (short orientation digest), `assets/`, and shape-level SVGs under `svg/`-- **SVG output is layered by default**: each unique master / layout is rendered once as `svg/master_*.svg` / `svg/layout_*.svg`; `svg/slide_NN.svg` contains only that slide's own shapes; `svg/inheritance.json` records which layout / master each slide consumes. This gives template designers a clear separation between shared visual language and per-slide content.-- Pass `--inheritance-mode flat` only when you need self-contained slide SVGs (round-trip use cases). The default `layered` is what `/create-template` consumes.+- **SVG output emits two views by default** (`--inheritance-mode both`):+ - `svg/` — layered template view for designers: every master and layout in the deck rendered once as `svg/master_*.svg` / `svg/layout_*.svg` (including ones no sample slide currently references); `svg/slide_NN.svg` contains only that slide's own shapes; `svg/inheritance.json` records which layout / master each slide consumes.+ - `svg-flat/` — companion view: each `slide_NN.svg` is self-contained (master + layout + slide painted into one file), so opening any slide in isolation shows the full page like PowerPoint would. Useful for previews, screenshots, and "did this slide actually render correctly" sanity checks.+- Pass `--inheritance-mode layered` to skip `svg-flat/`, or `--inheritance-mode flat` for the legacy round-trip view (single self-contained `svg/` tree without master/layout/inheritance files).- SVG export reads OOXML directly via `pptx_to_svg` — no PowerPoint or Keynote dependency, runs on any platform- `<image>` elements in `svg/` reference files in `assets/` directly; pass `--embed-images` to inline as data URIs instead- Required in `/create-template` whenever the reference source is `.pptx`diff --git a/skills/ppt-master/scripts/pptx_template_import.py b/skills/ppt-master/scripts/pptx_template_import.pyindex d95aa7e7..495740c6 100644--- a/skills/ppt-master/scripts/pptx_template_import.py+++ b/skills/ppt-master/scripts/pptx_template_import.py@@ -7,7 +7,13 @@ Reads OOXML directly via `pptx_to_svg` and writes a reusable reference workspaceasset inventory, and per-slide / per-layout / per-master metadata- `summary.md` — short human-readable digest derived from manifest.json- `assets/` — extracted reusable image assets-- `svg/` — shape-level SVG per slide (real <text>, <image>, geometry)+- `svg/` — primary view: by default the layered template view (every master+ and layout in the deck rendered once each as `master_*.svg` /+ `layout_*.svg`, slides contain only their own shapes, and an+ `inheritance.json` describes the reuse graph)+- `svg-flat/` — companion view (default mode "both"): each `slide_NN.svg`+ is self-contained — master/layout decoration is inlined — so opening any+ one slide shows the full page like PowerPoint would"""from __future__ import annotations@@ -50,16 +56,17 @@ def parse_args() -> argparse.Namespace:)parser.add_argument("--inheritance-mode",- choices=("layered", "flat"),- default="layered",+ choices=("both", "layered", "flat"),+ default="both",help=(- "How to render master/layout shapes inside slide SVGs. "- "'layered' (default for /create-template): each slide SVG contains "- "only its own shapes; master/layout are rendered once each as "- "separate svg/master_*.svg / svg/layout_*.svg files plus "- "svg/inheritance.json. 'flat': inline inherited shapes inside every "- "slide (legacy behavior; pick this only when you need self-contained "- "slide SVGs)."+ "How to render master/layout shapes for slide SVGs. "+ "'both' (default): emit both views — svg/ holds the layered "+ "renderings (template designers see master/layout/slide as "+ "separate files plus svg/inheritance.json) and svg-flat/ holds "+ "self-contained per-slide SVGs (each one renders correctly when "+ "opened on its own). 'layered': only the svg/ tree, useful when "+ "you don't need the flat view. 'flat': only self-contained slide "+ "SVGs in svg/, the round-trip view used by svg_to_pptx."),)return parser.parse_args()@@ -128,11 +135,13 @@ def main() -> int:print(f"Inheritance mode: {args.inheritance_mode}")print(f"Exported SVG slides: {len(result.slides)}")- if args.inheritance_mode == "layered":+ if args.inheritance_mode in {"layered", "both"}:print(f"Exported masters: {len(result.masters)}")print(f"Exported layouts: {len(result.layouts)}")print("Inheritance graph: svg/inheritance.json")- print(f"SVG bytes: {total_bytes}")+ if result.flat_slides:+ print(f"Flat companion slides: {len(result.flat_slides)} (svg-flat/)")+ print(f"SVG bytes (primary): {total_bytes}")print(f"Output directory: {output_dir}")return 0diff --git a/skills/ppt-master/scripts/pptx_to_svg/converter.py b/skills/ppt-master/scripts/pptx_to_svg/converter.pyindex 21b2d338..6905dc3d 100644--- a/skills/ppt-master/scripts/pptx_to_svg/converter.py+++ b/skills/ppt-master/scripts/pptx_to_svg/converter.py@@ -33,18 +33,24 @@ class ConvertOptions:embed_images: when True, base64-encode images inline instead of writingfiles. Default False (matches svg_to_pptx default of external images).keep_hidden: include shapes marked hidden="1". Default False.- inheritance_mode: how to render master/layout shapes inside each slide SVG.- - "flat" (default): inline inherited shapes into every slide. Used by- svg_to_pptx round-trip and any caller that wants self-contained slides.+ inheritance_mode: how to render master/layout shapes per slide SVG.+ - "both" (default): emit both views — layered under svg/ for template+ designers (master/layout/slide as separate files) and flat under+ svg-flat/ for previewers (each slide self-contained). Costs roughly+ 1.3-1.5× converter time and ~1.6-2× disk vs. either single mode.- "layered": skip inherited shapes inside the slide. The orchestrator- additionally renders each unique master and layout to its own SVG and- writes svg/inheritance.json so the deck's reuse graph is explicit.+ renders every master and layout to its own SVG, plus+ svg/inheritance.json describing the reuse graph. Optimised for+ template authors who need to see "what is shared vs. unique".+ - "flat": inline inherited shapes into every slide. Used by+ svg_to_pptx round-trip and any caller that wants self-contained+ slides (preview pages, screenshot pipelines)."""media_subdir: str = "assets"embed_images: bool = Falsekeep_hidden: bool = False- inheritance_mode: str = "flat"+ inheritance_mode: str = "both"@dataclass@@ -71,7 +77,13 @@ class SlideArtifact:@dataclassclass ConvertResult:- """Result of converting an entire .pptx."""+ """Result of converting an entire .pptx.++ ``slides`` holds the layered/primary view (or, in pure flat mode, the flat+ view). ``flat_slides`` is populated only in ``"both"`` mode and contains+ self-contained renderings of every slide; callers that don't care about+ the flat view can ignore it.+ """slides: list[SlideArtifact] = field(default_factory=list)canvas_px: tuple[float, float] = (1280.0, 720.0)@@ -79,6 +91,7 @@ class ConvertResult:theme_fonts: dict[str, str] = field(default_factory=dict)layouts: list[PartArtifact] = field(default_factory=list)masters: list[PartArtifact] = field(default_factory=list)+ flat_slides: list[SlideArtifact] = field(default_factory=list)# ---------------------------------------------------------------------------@@ -102,11 +115,13 @@ def convert_pptx_to_svg(ConvertResult with per-slide SVG strings and resolved theme info."""options = options or ConvertOptions()- if options.inheritance_mode not in {"flat", "layered"}:+ if options.inheritance_mode not in {"flat", "layered", "both"}:raise ValueError(- f"inheritance_mode must be 'flat' or 'layered', "+ f"inheritance_mode must be 'flat', 'layered', or 'both', "f"got {options.inheritance_mode!r}")+ emit_layered = options.inheritance_mode in {"layered", "both"}+ emit_flat = options.inheritance_mode in {"flat", "both"}result = ConvertResult()with OoxmlPackage(pptx_path) as pkg:@@ -148,13 +163,26 @@ def convert_pptx_to_svg(if cs is not None and cs.attrib.get("typeface"):result.theme_fonts[f"{role_prefix}ComplexScript"] = cs.attrib["typeface"]- # Per-slide conversion+ # Per-slide conversion. The primary view is layered when emitted+ # (template designers care most about that one); the flat view is+ # rendered alongside when needed.+ primary_mode = "layered" if emit_layered else "flat"for slide in pkg.iter_slides():- artifact = _convert_slide(pkg, slide, palette, options, result.theme_fonts)+ artifact = _convert_slide(+ pkg, slide, palette, options, result.theme_fonts,+ inheritance_mode=primary_mode,+ )result.slides.append(artifact)-- # Layered mode: also render each unique master / layout once.- if options.inheritance_mode == "layered":+ if emit_layered and emit_flat:+ for slide in pkg.iter_slides():+ artifact = _convert_slide(+ pkg, slide, palette, options, result.theme_fonts,+ inheritance_mode="flat",+ )+ result.flat_slides.append(artifact)++ # Layered mode: also render each master / layout once.+ if emit_layered:_convert_inheritance_parts(pkg, palette, options, result)if output_dir is not None:@@ -169,15 +197,27 @@ def _convert_slide(palette: ColorPalette,options: ConvertOptions,theme_fonts: dict[str, str] | None = None,+ *,+ inheritance_mode: str | None = None,) -> SlideArtifact:- """Convert a single slide via the full shape pipeline."""+ """Convert a single slide via the full shape pipeline.++ ``inheritance_mode`` overrides ``options.inheritance_mode`` so the+ orchestrator can render the same slide twice (once layered, once flat)+ when the user asked for ``"both"``. Pass ``"flat"`` or ``"layered"``;+ ``None`` falls back to ``options.inheritance_mode`` (used by direct+ callers that want a single mode).+ """+ mode = inheritance_mode or options.inheritance_mode+ if mode == "both":+ mode = "layered" # primary view in both-modesvg, media = assemble_slide(pkg, slide, palette,theme_fonts=theme_fonts,media_subdir=options.media_subdir,embed_images=options.embed_images,keep_hidden=options.keep_hidden,- inheritance_mode=options.inheritance_mode,+ inheritance_mode=mode,)return SlideArtifact(index=slide.index,@@ -194,16 +234,24 @@ def _convert_inheritance_parts(options: ConvertOptions,result: ConvertResult,) -> None:- """Render each unique master and layout to its own SVG (layered mode)."""- # Collect unique parts in slide-encounter order so output filenames are+ """Render every master and layout in the deck to its own SVG (layered mode).++ We deliberately render *all* masters / layouts, not only the ones a slide+ references. Multi-style template packages routinely ship more design+ surfaces than the embedded sample slides exercise, and dropping unused+ ones discards the bulk of the template's design intent.+ """+ # Collect unique parts in document order so output filenames are# deterministic for a given .pptx.- seen_layouts: dict[str, PartRef] = {}seen_masters: dict[str, PartRef] = {}- for slide in pkg.iter_slides():- if slide.layout is not None and slide.layout.path not in seen_layouts:- seen_layouts[slide.layout.path] = slide.layout- if slide.master is not None and slide.master.path not in seen_masters:- seen_masters[slide.master.path] = slide.master+ for master in pkg.iter_all_masters():+ if master.path not in seen_masters:+ seen_masters[master.path] = master++ seen_layouts: dict[str, PartRef] = {}+ for layout in pkg.iter_all_layouts():+ if layout.path not in seen_layouts:+ seen_layouts[layout.path] = layoutfor seq, part in enumerate(seen_masters.values(), start=1):result.masters.append(_render_part(@@ -250,7 +298,13 @@ def _render_part(def _write_artifacts(output_dir: Path, result: ConvertResult,options: ConvertOptions) -> None:- """Write SVG + media files to output_dir/svg and output_dir/<media_subdir>."""+ """Write SVG + media files to output_dir.++ Layout:+ - ``svg/`` primary view (layered when emitted, otherwise flat)+ - ``svg-flat/`` self-contained per-slide renders (only in "both" mode)+ - ``<media_subdir>/`` shared image assets, referenced by both views+ """output_dir.mkdir(parents=True, exist_ok=True)svg_dir = output_dir / "svg"svg_dir.mkdir(exist_ok=True)@@ -273,16 +327,26 @@ def _write_artifacts(output_dir: Path, result: ConvertResult,(svg_dir / art.filename).write_text(art.svg, encoding="utf-8")_write_media(art.media_files)- # Slides+ # Slides (primary view).for art in result.slides:target = svg_dir / f"slide_{art.index:02d}.svg"target.write_text(art.svg, encoding="utf-8")_write_media(art.media_files)- # Layered mode: dump the inheritance graph alongside the SVGs.- if options.inheritance_mode == "layered":+ # Inheritance graph alongside the layered SVGs (only meaningful when we+ # actually emitted a layered view).+ if options.inheritance_mode in {"layered", "both"}:_write_inheritance_json(svg_dir, result)+ # Flat companion view (only when result.flat_slides is populated).+ if result.flat_slides:+ flat_dir = output_dir / "svg-flat"+ flat_dir.mkdir(exist_ok=True)+ for art in result.flat_slides:+ target = flat_dir / f"slide_{art.index:02d}.svg"+ target.write_text(art.svg, encoding="utf-8")+ _write_media(art.media_files)+def _write_inheritance_json(svg_dir: Path, result: ConvertResult) -> None:"""Record which layout/master each slide consumes (layered mode only)."""diff --git a/skills/ppt-master/scripts/pptx_to_svg/ooxml_loader.py b/skills/ppt-master/scripts/pptx_to_svg/ooxml_loader.pyindex c5303311..9010ff69 100644--- a/skills/ppt-master/scripts/pptx_to_svg/ooxml_loader.py+++ b/skills/ppt-master/scripts/pptx_to_svg/ooxml_loader.py@@ -300,3 +300,62 @@ class OoxmlPackage:if 1 <= index <= len(self._slides):return self._slides[index - 1]return None++ def iter_all_masters(self) -> Iterator[PartRef]:+ """Yield every slideMaster declared in presentation.xml, regardless of+ whether any slide currently uses it.++ Template decks routinely ship more masters than the visible sample+ slides reference (one master per "style"). The slide-driven traversal+ in ``_load_slides`` only caches masters that are actually consumed by+ a slide — fine for an authoring deck, but it drops 90% of the design+ intent for a multi-style template package. This iterator hits the+ presentation's ``sldMasterIdLst`` directly so callers (e.g. the+ layered template export) can preserve the full template library.+ """+ if self.presentation is None:+ return+ master_id_lst = self.presentation.xml.find("p:sldMasterIdLst", NS)+ if master_id_lst is None:+ return+ for master_id in master_id_lst.findall("p:sldMasterId", NS):+ rid = master_id.attrib.get(f"{{{NS['r']}}}id")+ if not rid:+ continue+ target = self.presentation.resolve_rel(rid)+ if not target:+ continue+ cached = self._masters.get(target)+ if cached is None:+ cached = self._load_part(target)+ if cached is None:+ continue+ self._masters[target] = cached+ yield cached++ def iter_all_layouts(self) -> Iterator[PartRef]:+ """Yield every slideLayout reachable from any master, regardless of+ slide usage. Layouts live under ``master.sldLayoutIdLst`` in document+ order; we walk every master so the export reflects the full set.+ """+ seen: set[str] = set()+ for master in self.iter_all_masters():+ layout_id_lst = master.xml.find("p:sldLayoutIdLst", NS)+ if layout_id_lst is None:+ continue+ for layout_id in layout_id_lst.findall("p:sldLayoutId", NS):+ rid = layout_id.attrib.get(f"{{{NS['r']}}}id")+ if not rid:+ continue+ target = master.resolve_rel(rid)+ if not target or target in seen:+ continue+ seen.add(target)+ cached = self._layouts.get(target)+ if cached is None:+ cached = self._load_part(target)+ if cached is None:+ continue+ self._layouts[target] = cached+ yield cached+diff --git a/skills/ppt-master/workflows/create-template.md b/skills/ppt-master/workflows/create-template.mdindex dd3a2aa8..92688c52 100644--- a/skills/ppt-master/workflows/create-template.md+++ b/skills/ppt-master/workflows/create-template.md@@ -80,12 +80,14 @@ This helper reads OOXML directly via `pptx_to_svg` and produces, in one workspac- `manifest.json` — single source of truth: slide size, theme colors, fonts, asset inventory, per-slide / per-layout / per-master metadata, page-type candidates- `summary.md` — short human-readable digest derived from manifest.json (for quick scanning only)- `assets/` — extracted reusable image assets-- `svg/` — shape-level SVG, **layered by default**:- - `svg/master_*.svg` — each unique slide master rendered once (decorative / structural shapes, no placeholders)- - `svg/layout_*.svg` — each unique slide layout rendered once (its own contribution; master shapes do **not** repeat here)- - `svg/slide_NN.svg` — each slide's own shapes; master / layout shapes are **not** inlined+- `svg/` — **primary view** (layered template view):+ - `svg/master_*.svg` — every slide master in the deck rendered once, including masters that no sample slide currently uses (template packages routinely ship more masters than the visible samples reference)+ - `svg/layout_*.svg` — every slide layout in the deck rendered once (its own contribution; master shapes do **not** repeat here)+ - `svg/slide_NN.svg` — each slide's own shapes; master / layout shapes are **not** inlined here- `svg/inheritance.json` — which layout & master each slide consumes- - Pass `--inheritance-mode flat` only when you specifically want self-contained slide SVGs (round-trip use cases). The default is `layered` because every slide otherwise repeats the same master decoration, which makes it hard to tell what is shared vs. unique.+- `svg-flat/` — **companion view** (one self-contained SVG per slide):+ - `svg-flat/slide_NN.svg` — master + layout + slide painted into a single SVG so opening any slide on its own shows the full page like PowerPoint would. Use this for previews / screenshot pipelines / "what does the slide actually look like" sanity checks.+- The default `--inheritance-mode both` emits both views. Pass `layered` to skip `svg-flat/`, or `flat` for round-trip use cases (legacy: `svg/` becomes self-contained slides without the master/layout/inheritance files).It is a reconstruction aid, not a final direct template conversion.