$npx -y skills add CxyZyr/PPTX-Template-Skills --skill pptx-template-parsingUse before adapting or debugging any PPTX template-driven deck. Parses a template into a portable spec.json contract: classified shape tree, slide roles, repeated card structures, per-slide fill_plan, text style/paragraph metadata, font availability, and optional renders. This is
| 1 | # PPTX Template Parsing |
| 2 | |
| 3 | Turn a `.pptx` template into a semantic `spec.json` that downstream generation can fill |
| 4 | mechanically — without the agent ever hand-reading shape indices off the slide. |
| 5 | |
| 6 | This is the **first half** of the pipeline: |
| 7 | |
| 8 | ``` |
| 9 | template.pptx ─[THIS SKILL]→ spec.json (+ summary.txt + renders/*.png) |
| 10 | │ |
| 11 | ▼ |
| 12 | ppt-template-adaptation (authors content_plan.json, fills the deck) |
| 13 | ``` |
| 14 | |
| 15 | ## When to use |
| 16 | |
| 17 | - A user provides a PPT template that will be reused (not redesigned). |
| 18 | - Before any generation: generation needs the `spec.json` slot map this skill produces. |
| 19 | - When you need to know, per slide: what role it plays, where the title/body/cards/icons/logo/images |
| 20 | live, and which slides repeat a card structure. |
| 21 | - When a generated deck has layout, style, overlap, or missing-slot problems. Check whether parsing |
| 22 | captured the right slots and text styles before adding generation fallbacks. |
| 23 | |
| 24 | ## Operating rule |
| 25 | |
| 26 | The parser output is the contract. Do not hand-pick PowerPoint shape indices from memory, screenshots, |
| 27 | or a previous failed deck. If `fill_plan` is wrong, fix parsing/classification first, rerun this skill, |
| 28 | then regenerate with `ppt-template-adaptation`. |
| 29 | |
| 30 | ## What it produces |
| 31 | |
| 32 | | Output | Purpose | |
| 33 | |---|---| |
| 34 | | `spec.json` | The machine-readable contract consumed by generation. See `references/spec-schema.md`. | |
| 35 | | `summary.txt` | One line per slide: role + confidence + detected slots. Read this first. | |
| 36 | | `renders/*.png` | One PNG per slide when rendering is enabled. Use for human/visual review when allowed. | |
| 37 | |
| 38 | ## How to run |
| 39 | |
| 40 | ```bash |
| 41 | python3 skills/pptx-template-parsing/scripts/parse_template.py \ |
| 42 | --template "PPT模板/大气人工智能科技感PPT模板.pptx" \ |
| 43 | --out workspace/specs/ai_tech |
| 44 | ``` |
| 45 | |
| 46 | Flags: |
| 47 | - `--no-render` — skip LibreOffice rendering (faster; do this for a quick structural pass). |
| 48 | - `--limit N` — only parse the first N slides (useful while iterating). |
| 49 | - `--dpi 110` — render resolution (default 110). |
| 50 | |
| 51 | Rendering needs `libreoffice` + `pdftoppm` on PATH. If rendering fails the parser still emits |
| 52 | `spec.json` (renders are best-effort). |
| 53 | |
| 54 | ## Required workflow |
| 55 | |
| 56 | 1. Run `parse_template.py` against the original template, not a previously generated deck. |
| 57 | 2. Read `summary.txt` and flag any low-confidence slide (`role_confidence < 0.5`) or unexpected slot |
| 58 | count, especially `contents` and repeated-card slides. |
| 59 | 3. Read the relevant `fill_plan` entries in `spec.json`: `title`, `labels`, `body`, `cards`, |
| 60 | `images`, `charts`, `tables`, `logo`, and `visual_obstacles`. |
| 61 | 4. For text-sensitive templates, inspect each slot's `style.paragraphs` / `title_style.paragraphs`. |
| 62 | Mixed-format boxes must preserve paragraph/run style instead of being flattened during generation. |
| 63 | 5. Check `template.theme.font_availability`. Missing fonts explain render differences, but the PPTX |
| 64 | should still preserve the original font names in `style`. |
| 65 | 6. Only after the slot map looks coherent, hand `spec.json` to `ppt-template-adaptation` and create a |
| 66 | `content_plan.json`. |
| 67 | |
| 68 | ## Debugging checklist |
| 69 | |
| 70 | - Contents page: card count must match visible directory entries. If four entries parse as one large |
| 71 | card, fix card-list/group extraction here. |
| 72 | - Shared text boxes: if a single text box contains number/title/body with different styles, the parsed |
| 73 | style must include `paragraphs` with run-level sizes/colors. |
| 74 | - Alignment: preserve parser values such as `CENTER`, `LEFT`, and `DISTRIBUTE`. Do not reinterpret |
| 75 | WPS distributed alignment as ordinary center. |
| 76 | - Icon/image boundary: small semantic glyphs belong in `cards[].icon`; photos/screenshots belong in |
| 77 | `images[]`. |
| 78 | - Chart/table pages: if native chart/table slots are present, expose them as `charts[]` / `tables[]`; |
| 79 | do not treat them as ordinary text pages. |
| 80 | |
| 81 | ## How the classifier works (no single signal is trusted) |
| 82 | |
| 83 | Each shape gets a `role`, a `role_confidence`, and the list of `signals` that fired, so its decision is |
| 84 | reviewable against the render. Roles are assigned in priority order — hard shape types (table/chart) → |
| 85 | real placeholders → stock placeholder text (`点击输入标题`) → font-size/geometry heuristics. Groups become |
| 86 | `card` only when they carry substantive text. Full rules: `references/classification-signals.md`. |
| 87 | |
| 88 | Slide roles (cover / contents / section_divider / content / ending) and the per-slide `fill_plan` are |
| 89 | derived on top of the shape roles. Full rules: `references/slide-roles.md`. |
| 90 | |
| 91 | ## Reference read order |
| 92 | |
| 93 | Read only what the task needs: |
| 94 | |
| 95 | - `references/spec-schema.md` — required when consuming o |