Skip to content

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(icons): per-project icons/ folder — copy chosen icons in at selection, embed project-first

hugohe3a0b76d31b43c
diff --git a/AGENTS.md b/AGENTS.md
index c38f60ef..e1c93519 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -67,6 +67,9 @@ python3 skills/ppt-master/scripts/project_manager.py init <project_name> --forma
python3 skills/ppt-master/scripts/project_manager.py import-sources <project_path> <source_files_or_URLs...> --move
python3 skills/ppt-master/scripts/project_manager.py validate <project_path>
+# Icon selection — copy chosen library icons into <project>/icons/ (missing names reported + non-zero = re-pick)
+python3 skills/ppt-master/scripts/icon_sync.py <project_path> <lib/name> [<lib/name>...]
+
# Step 4 Eight Confirmations — interactive visual page (default auto-launch; chat fallback)
python3 skills/ppt-master/scripts/confirm_ui/server.py <project_path> --daemon --wait
diff --git a/CLAUDE.md b/CLAUDE.md
index 9e5f34e1..1bbd1498 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -67,6 +67,9 @@ python3 skills/ppt-master/scripts/project_manager.py init <project_name> --forma
python3 skills/ppt-master/scripts/project_manager.py import-sources <project_path> <source_files_or_URLs...> --move
python3 skills/ppt-master/scripts/project_manager.py validate <project_path>
+# Icon selection — copy chosen library icons into <project>/icons/ (missing names reported + non-zero = re-pick)
+python3 skills/ppt-master/scripts/icon_sync.py <project_path> <lib/name> [<lib/name>...]
+
# Step 4 Eight Confirmations — interactive visual page (default auto-launch; chat fallback)
python3 skills/ppt-master/scripts/confirm_ui/server.py <project_path> --daemon --wait
diff --git a/skills/ppt-master/SKILL.md b/skills/ppt-master/SKILL.md
index 5321bf0f..69a5bf68 100644
--- a/skills/ppt-master/SKILL.md
+++ b/skills/ppt-master/SKILL.md
@@ -51,6 +51,7 @@ description: >
| `${SKILL_DIR}/scripts/source_to_md/ppt_to_md.py` | PowerPoint to Markdown |
| `${SKILL_DIR}/scripts/source_to_md/web_to_md.py` | Web page to Markdown (supports WeChat via `curl_cffi`) |
| `${SKILL_DIR}/scripts/project_manager.py` | Project init / validate / manage |
+| `${SKILL_DIR}/scripts/icon_sync.py` | Copy chosen library icons into `<project>/icons/` at selection time; missing names reported + non-zero (re-pick gate) |
| `${SKILL_DIR}/scripts/analyze_images.py` | Image analysis |
| `${SKILL_DIR}/scripts/latex_render.py` | LaTeX formula rendering (manifest-driven PNG assets) |
| `${SKILL_DIR}/scripts/image_gen.py` | AI image generation (multi-provider) |
diff --git a/skills/ppt-master/references/executor-base.md b/skills/ppt-master/references/executor-base.md
index 6bac2e9e..04371adc 100644
--- a/skills/ppt-master/references/executor-base.md
+++ b/skills/ppt-master/references/executor-base.md
@@ -215,6 +215,8 @@ Examples: `01_封面.svg` / `02_目录.svg` / `03_核心优势.svg`; `01_cover.s
Strategist chooses the library and inventory; Executor only implements. Library details and one-library rule: [`../templates/icons/README.md`](../templates/icons/README.md). This section defines placeholder syntax.
+> **Resolution is project-first.** Strategist copied the chosen icons into `<project_path>/icons/<lib>/` (via `icon_sync.py`); `finalize_svg.py embed-icons` embeds from there, falling back to the global library per-icon. **Custom icons**: drop an `.svg` into `<project_path>/icons/<lib>/` (any `<lib>`, e.g. `custom/`) and reference it as `data-icon="<lib>/<name>"` — it embeds like any other. Reference only icons in the `spec_lock.md` inventory.
+
**Built-in icons — Placeholder method (recommended)**:
```xml
diff --git a/skills/ppt-master/references/strategist.md b/skills/ppt-master/references/strategist.md
index 0c396786..737572ba 100644
--- a/skills/ppt-master/references/strategist.md
+++ b/skills/ppt-master/references/strategist.md
@@ -140,7 +140,10 @@ See [`../templates/icons/README.md`](../templates/icons/README.md) for the curre
> 3. Enumerate the concepts the deck actually needs (home, chart, users, …) based on the confirmed outline.
> 4. Search for each concept's filename in the chosen library: `ls skills/ppt-master/templates/icons/<chosen-library>/ | grep <keyword>`
> 5. Use the verified filename (without `.svg`) as the icon name; always include the library prefix (e.g., `chunk-filled/home`).
-> 6. List the final icon inventory and chosen library in `design_spec.md` §VI; record the same in `spec_lock.md icons` (including `stroke_width` for stroke-style libraries). Executor may only use icons from this list.
+> 6. **Copy each chosen icon into the project as you confirm it** — `python3 skills/ppt-master/scripts/icon_sync.py <project_path> <lib/name> [<lib/name> …]`. This populates `<project>/icons/<lib>/` (the set the Executor embeds from) and, more importantly, **validates existence on the spot**.
+> 7. List the final icon inventory and chosen library in `design_spec.md` §VI; record the same in `spec_lock.md icons` (including `stroke_width` for stroke-style libraries). Executor may only use icons from this list.
+>
+> 🚧 **GATE — missing icon = re-pick now**: if `icon_sync.py` reports any name as missing (non-zero exit), that icon is not in the library — re-pick a real filename via `ls … | grep`, fix `§VI` / `spec_lock.md`, and re-run until it exits clean. Never carry a missing icon forward to generation. Over-copying candidates is harmless — finalize embeds only the icons actually referenced by `<use data-icon>`.
>
> **Do NOT preload any index file** — when the inventory step arrives, use `ls | grep` to search on demand with zero token cost.
diff --git a/skills/ppt-master/scripts/finalize_svg.py b/skills/ppt-master/scripts/finalize_svg.py
index 2b683225..29306368 100644
--- a/skills/ppt-master/scripts/finalize_svg.py
+++ b/skills/ppt-master/scripts/finalize_svg.py
@@ -130,7 +130,12 @@ def finalize_project(
"""
svg_output = project_dir / 'svg_output'
svg_final = project_dir / 'svg_final'
- icons_dir = Path(__file__).parent.parent / 'templates' / 'icons'
+ # Project-first: embed from the deck's own icons/ (synced library icons +
+ # any custom icons), falling back to the global library per-icon.
+ global_icons_dir = Path(__file__).parent.parent / 'templates' / 'icons'
+ project_icons_dir = project_dir / 'icons'
+ icons_dir = project_icons_dir if project_icons_dir.is_dir() else global_icons_dir
+ icons_fallback_dir = global_icons_dir if icons_dir != global_icons_dir else None
# Check if svg_output exists
if not svg_output.exists():
@@ -166,7 +171,7 @@ def finalize_project(
safe_print("[1/4] Embedding icons...")
icons_count = 0
for svg_file in svg_final.glob('*.svg'):
- count = embed_icons_in_file(svg_file, icons_dir, dry_run=False, verbose=False)
+ count = embed_icons_in_file(svg_file, icons_dir, dry_run=False, verbose=False, fallback_dir=icons_fallback_dir)
icons_count += count
if not quiet:
if icons_count > 0:
diff --git a/skills/ppt-master/scripts/icon_sync.py b/skills/ppt-master/scripts/icon_sync.py
new file mode 100644
index 00000000..db8de6c7
--- /dev/null
+++ b/skills/ppt-master/scripts/icon_sync.py
@@ -0,0 +1,110 @@
+#!/usr/bin/env python3
+"""
+PPT Master - Icon Sync
+
+Copy chosen library icons into a project's own `icons/` folder at the moment they
+are selected. Run it with the icon names you are picking; each is copied from the
+global library into `<project>/icons/<lib>/`. Any name the library does not have
+is reported on the spot and the command exits non-zero — so you re-pick a valid
+icon then, not at export time. Over-copying candidates is fine: finalize only
+embeds the icons actually referenced by `<use data-icon>`, the rest sit unused.
+
+Custom icons you place in `<project>/icons/<lib>/` yourself are honored too — a
+name already present in the project is treated as satisfied, not missing.
+
+Usage:
+ python3 scripts/icon_sync.py <project_path> <lib/name> [<lib/name> ...]
+
+Examples:
+ python3 scripts/icon_sync.py projects/deck chunk-filled/home tabler-outline/chart
+ python3 scripts/icon_sync.py projects/deck simple-icons/github
+
+Dependencies:
+ None (standard library only).
+
+See references/executor-base.md §4 and templates/icons/README.md.
+"""
+
+from __future__ import annotations
+
+import argparse
+import shutil
+import sys
+from pathlib import Path
+from typing import Optional
+
+_LIB_ALIASES = {"chunk": "chunk-filled"}
+_GLOBAL_ICONS_DIR = Path(__file__).resolve().parent.parent / "templates" / "icons"
+
+
+def _split_name(icon_name: str) -> tuple[str, str]:
+ """`lib/name` -> (lib, name), applying the chunk→chunk-filled alias."""
+ if "/" not in icon_name:
+ # legacy un-prefixed names live in chunk-filled/
+ return "chunk-filled", icon_name
+ lib, name = icon_name.split("/", 1)
+ return _LIB_ALIASES.get(lib, lib), name
+
+
+def sync_icons(project_path: Path, icon_names: list[str], global_dir: Path = _GLOBAL_ICONS_DIR) -> tuple[list[str], list[str]]:
+ """Copy each `lib/name` from the global library into `<project>/icons/`.
+
+ Returns (copied, missing). A name already present in the project (e.g. a
+ custom icon) counts as satisfied, not missing.
+ """
+ project_icons = project_path / "icons"
+ copied: list[str] = []
+ missing: list[str] = []
+
+ for raw in icon_names:
+ lib, name = _split_name(raw)
+ src = global_dir / lib / f"{name}.svg"
+ dst = project_icons / lib / f"{name}.svg"
+ if src.is_file():
+ dst.parent.mkdir(parents=True, exist_ok=True)
+ shutil.copy2(src, dst)
+ copied.append(f"{lib}/{name}")
+ elif dst.is_file():
+ copied.append(f"{lib}/{name} (already in project)")
+ else:
+ missing.append(f"{lib}/{name}")
+
+ return copied, missing
+
+
+def build_parser() -> argparse.ArgumentParser:
+ parser = argparse.ArgumentParser(
+ description="Copy chosen library icons into a project's icons/ folder; report missing ones.",
+ formatter_class=argparse.RawDescriptionHelpFormatter,
+ )
+ parser.add_argument("project_path", help="Project directory")
+ parser.add_argument("icons", nargs="+", help="Icon names to copy, e.g. chunk-filled/home")
+ return parser
+
+
+def main(argv: Optional[list[str]] = None) -> int:
+ args = build_parser().parse_args(argv)
+ project = Path(args.project_path)
+ if not project.is_dir():
+ print(f"[ERROR] project not found: {project}", file=sys.stderr)
+ return 1
+
+ copied, missing = sync_icons(project, args.icons)
+
+ if copied:
+ print(f"[OK] {len(copied)} icon(s) in {project / 'icons'}:", file=sys.stderr)
+ for c in copied:
+ print(f" + {c}", file=sys.stderr)
+
+ if missing:
+ print(f"\n[MISSING] {len(missing)} icon(s) not in the library — re-pick before continuing:", file=sys.stderr)
+ for m in missing:
+ lib = m.split("/", 1)[0]
+ print(f" ✗ {m} (search: ls {_GLOBAL_ICONS_DIR}/{lib}/ | grep <keyword>)", file=sys.stderr)
+ return 1
+
+ return 0
+
+
+if __name__ == "__main__":
+ raise SystemExit(main())
diff --git a/skills/ppt-master/scripts/project_manager.py b/skills/ppt-master/scripts/project_manager.py
index 0a18140b..4fb1abda 100644
--- a/skills/ppt-master/scripts/project_manager.py
+++ b/skills/ppt-master/scripts/project_manager.py
@@ -143,6 +143,7 @@ class ProjectManager:
"svg_output",
"svg_final",
"images",
+ "icons",
"notes",
"templates",
SOURCE_DIRNAME,
@@ -161,6 +162,7 @@ class ProjectManager:
"- `svg_output/`: raw SVG output\n"
"- `svg_final/`: finalized SVG output\n"
"- `images/`: presentation assets\n"
+ "- `icons/`: project icon set — selected library icons copied in (via icon_sync.py) plus any custom icons you add; embedded from here at export\n"
"- `notes/`: speaker notes\n"
"- `templates/`: project templates\n"
"- `sources/`: source materials and normalized markdown\n"
diff --git a/skills/ppt-master/scripts/svg_finalize/embed_icons.py b/skills/ppt-master/scripts/svg_finalize/embed_icons.py
index e6bd5677..959d2f95 100644
--- a/skills/ppt-master/scripts/svg_finalize/embed_icons.py
+++ b/skills/ppt-master/scripts/svg_finalize/embed_icons.py
@@ -103,19 +103,8 @@ def _extract_shape_elements(content: str, color: str) -> list[str]:
return elements
-def resolve_icon_path(icon_name: str, icons_dir: Path) -> tuple[Path, float]:
- """
- Resolve icon name to file path and base size.
-
- Supports:
- - "chunk-filled/home" → icons_dir/chunk-filled/home.svg
- - "chunk/home" → icons_dir/chunk-filled/home.svg (backward compat alias)
- - "tabler-filled/home" → icons_dir/tabler-filled/home.svg
- - "tabler-outline/home" → icons_dir/tabler-outline/home.svg
- - "home" (no prefix) → falls back to icons_dir/chunk-filled/home.svg (legacy compat only)
-
- Returns (path, base_size). base_size=0 means not found.
- """
+def _resolve_in_dir(icon_name: str, icons_dir: Path) -> tuple[Path, float]:
+ """Resolve `icon_name` against a single icons dir (no fallback)."""
# Backward compat: 'chunk/name' → 'chunk-filled/name'
_LIB_ALIASES = {'chunk': 'chunk-filled'}
@@ -135,6 +124,25 @@ def resolve_icon_path(icon_name: str, icons_dir: Path) -> tuple[Path, float]:
return icon_path, base_size
+def resolve_icon_path(icon_name: str, icons_dir: Path, fallback_dir: Path | None = None) -> tuple[Path, float]:
+ """
+ Resolve icon name to file path and base size, e.g. "chunk-filled/home" →
+ icons_dir/chunk-filled/home.svg. "chunk/" is a backward-compat alias; an
+ un-prefixed name falls back to chunk-filled/ then a legacy flat layout.
+
+ Resolution is project-first: if the icon is absent under ``icons_dir`` and a
+ ``fallback_dir`` (the global library) is given, the fallback's path is
+ returned instead. Returns (path, base_size); the path may not exist when
+ neither dir has the icon.
+ """
+ icon_path, base_size = _resolve_in_dir(icon_name, icons_dir)
+ if fallback_dir is not None and not icon_path.exists():
+ fb_path, fb_size = _resolve_in_dir(icon_name, fallback_dir)
+ if fb_path.exists():
+ return fb_path, fb_size
+ return icon_path, base_size
+
+
def extract_paths_from_icon(icon_path: Path, target_color: str = '#000000') -> tuple[list[str], str, float]:
"""
Extract drawable elements from an icon SVG file.
@@ -275,7 +283,7 @@ def generate_icon_group(attrs: dict[str, str | float], elements: list[str], styl
</g>'''
-def process_svg_file(svg_path: Path, icons_dir: Path, dry_run: bool = False, verbose: bool = False) -> int:
+def process_svg_file(svg_path: Path, icons_dir: Path, dry_run: bool = False, verbose: bool = False, fallback_dir: Path | None = None) -> int:
"""
Process a single SVG file, replacing all icon placeholders.
@@ -315,7 +323,7 @@ def process_svg_file(svg_path: Path, icons_dir: Path, dry_run: bool = False, ver
if not icon_name:
continue
- icon_path, _ = resolve_icon_path(str(icon_name), icons_dir)
+ icon_path, _ = resolve_icon_path(str(icon_name), icons_dir, fallback_dir)
elements, style, base_size = extract_paths_from_icon(icon_path)
color = resolve_icon_color(attrs, style)
diff --git a/skills/ppt-master/templates/icons/README.md b/skills/ppt-master/templates/icons/README.md
index 1d53cdcd..754e5f1d 100644
--- a/skills/ppt-master/templates/icons/README.md
+++ b/skills/ppt-master/templates/icons/README.md
@@ -14,6 +14,18 @@ This directory provides **11,600+ high-quality SVG icons** across five libraries
---
+## Per-project icons folder
+
+This directory is the **global library**. At selection time the Strategist copies the chosen icons into the deck's own `<project>/icons/<lib>/` with `icon_sync.py`:
+
+```bash
+python3 skills/ppt-master/scripts/icon_sync.py <project_path> chunk-filled/home tabler-outline/bulb
+```
+
+A name the library does not have is reported and the command exits non-zero — re-pick a real one then, not at export. `finalize_svg.py embed-icons` embeds **project-first** (from `<project>/icons/`), falling back to this global library per-icon.
+
+**Custom icons**: drop your own `.svg` into `<project>/icons/<lib>/` (any `<lib>`, e.g. `custom/`) and reference it as `data-icon="<lib>/<name>"` — it embeds like any library icon.
+
## Usage
Use placeholder syntax **during SVG generation**: