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(import-sources): give same-stem sources distinct archive stems
hugohe3ca04346de145
diff --git a/skills/ppt-master/scripts/docs/conversion.md b/skills/ppt-master/scripts/docs/conversion.mdindex a02498ce..e175611c 100644--- a/skills/ppt-master/scripts/docs/conversion.md+++ b/skills/ppt-master/scripts/docs/conversion.md@@ -84,8 +84,13 @@ Useful options:refuses an existing file except its own Markdown/text passthrough.For multi-source project intake, use `project_manager.py import-sources` with-all source paths / URLs. For local files, the default is to keep generated-Markdown and profile outputs beside the original source.+all source paths / URLs. Same-stem convertible sources receive distinct+archive names such as `budget_2.xlsm`, so their Markdown, profiles, assets, and+PPTX intake artifacts stay separate. Pre-existing Markdown and explicitly+supplied same-stem Markdown still suppress automatic conversion; PPTX intake+remains separate for each archived deck. See+[`project.md`](project.md). For standalone local conversion, the default is to+keep generated Markdown and profiles beside the original source.`source_to_md.py` and the backend converters support single files, explicitmulti-file inputs, and non-recursive directory inputs.@@ -260,7 +265,7 @@ Outputs (per source deck, prefixed by file stem):- `<stem>.slide_library.json` — text slots, geometry, native tables, native chart display caches, and SmartArt nodes/connections- `source_profile.json` — the single multi-deck index: a compact Strategist-facing digest per deck (over identity, tables, charts, SmartArt, and page types) under `decks[]`, with prefixed artifact pointers-`project_manager.py import-sources` runs this automatically for PPTX/PPTM/PPSX/PPSM/POTX/POTM inputs and stores the bundle directly under `analysis/`. Multi-deck per project: importing several PPTX files gives each its own `<stem>.*` artifacts and a `decks[]` entry in the shared `source_profile.json` index (re-importing the same stem replaces its entry). The beautify profile stays single-deck and reads one chosen deck's `<stem>.*` artifacts.+`project_manager.py import-sources` runs this automatically for PPTX/PPTM/PPSX/PPSM/POTX/POTM inputs and stores the bundle directly under `analysis/`. Multi-deck per project: each deck uses its archived stem, including any collision suffix, for `<stem>.*` artifacts and its `decks[]` entry in the shared `source_profile.json` index. Re-running intake for an existing archived stem replaces its entry. The beautify profile stays single-deck and reads one chosen deck's `<stem>.*` artifacts.Usage boundary:- Standard generation uses these fields as facts and recommendation candidates; it does not inherit source slide coordinates or page order by default.diff --git a/skills/ppt-master/scripts/docs/project.md b/skills/ppt-master/scripts/docs/project.mdindex 76b101f0..7f3402c8 100644--- a/skills/ppt-master/scripts/docs/project.md+++ b/skills/ppt-master/scripts/docs/project.md@@ -58,6 +58,11 @@ Notes:pass the source file/directory once when generated Markdown lives beside theoriginal source. If Step 1 used `-o` to write Markdown elsewhere, pass boththe original source path/directory and the Markdown output path/directory.+- Distinct same-stem convertible sources in one `import-sources` call+ receive archive suffixes (`budget.xlsm` → `budget_2.xlsm`). Markdown, conversion+ profiles, `_files/` assets, and PPTX analysis follow the archived stem.+ Pre-existing Markdown and explicitly supplied same-stem Markdown still+ suppress automatic conversion; PPTX intake still keeps each deck separate.- A projects-local supplied source directory left strictly empty after import(or empty from the start) is removed; every directory outside `projects/`remains untouched. `--copy` never removes directories.@@ -101,8 +106,9 @@ Notes:- PPTX-family inputs are enriched automatically under `analysis/` withper-deck `<stem>.identity.json` / `<stem>.slide_library.json` plus the sharedmulti-deck index `source_profile.json` (`decks[]`).- Multi-deck per project: several PPTX imports each get their own `<stem>.*`- artifacts and a `decks[]` entry; re-importing the same stem replaces its entry.+ Multi-deck per project: `<stem>` is the archived stem, including any collision+ suffix. Each deck gets its own artifacts and `decks[]` entry; re-running+ intake for an existing archived stem replaces its entry.### On-demand page execution viewdiff --git a/skills/ppt-master/scripts/project_management/cli.py b/skills/ppt-master/scripts/project_management/cli.pyindex 53e555e0..8a269069 100644--- a/skills/ppt-master/scripts/project_management/cli.py+++ b/skills/ppt-master/scripts/project_management/cli.py@@ -820,6 +820,8 @@ class ProjectManager:raise ValueError("At least one source path or URL is required")sources_dir = self._source_dir(project_dir)+ existing_markdown = {path.resolve() for path in sources_dir.glob("*.md")}+ reserved_markdown: set[Path] = set()summary: dict[str, list[str]] = {"archived": [],"url_records": [],@@ -998,12 +1000,48 @@ class ProjectManager:summary["notes"].append(note)continue+ archive_target = sources_dir / source_path.name+ if source_path.resolve() != archive_target.resolve():+ archive_target = self._ensure_unique_path(archive_target)+ canonical_markdown_path = archive_target.with_suffix(".md")+ has_explicit_markdown = archive_target.stem in explicit_markdown_stems+ if suffix in PDF_SUFFIXES | PRESENTATION_SUFFIXES | EXCEL_SUFFIXES | DOC_SUFFIXES:+ markdown_target = canonical_markdown_path+ keep_markdown = (+ has_explicit_markdown or markdown_target.resolve() in existing_markdown+ )+ if not keep_markdown or markdown_target.resolve() in reserved_markdown:+ # Reserve the source stem before conversion, including failed+ # conversions that may already have written intake or assets.+ stem = archive_target.stem+ counter = 2+ while (+ markdown_target.resolve() in reserved_markdown+ or markdown_target.exists()+ or archive_target.stem in explicit_markdown_stems+ or (archive_target.exists() and archive_target.resolve() != source_path.resolve())+ or markdown_target.with_suffix(".conversion_profile.json").exists()+ or (sources_dir / f"{archive_target.stem}_files").exists()+ or (project_dir / "analysis" / f"{archive_target.stem}.identity.json").exists()+ or (project_dir / "analysis" / f"{archive_target.stem}.slide_library.json").exists()+ ):+ archive_target = archive_target.with_name(f"{stem}_{counter}{source_path.suffix}")+ markdown_target = archive_target.with_suffix(".md")+ counter += 1+ # PPTX intake still writes analysis when Markdown is reused.+ reserved_markdown.add(markdown_target.resolve())+ if not keep_markdown:+ canonical_markdown_path = markdown_targetarchived_path = self._copy_or_move_file(source_path,- sources_dir / source_path.name,+ archive_target,move=effective_move,)summary["archived"].append(str(archived_path))+ if archived_path.name != source_path.name:+ summary["notes"].append(+ f"{item}: archived as {archived_path.name} to avoid a filename or source-stem collision"+ )if suffix in BITMAP_IMAGE_SUFFIXES:images_dir = project_dir / "images"@@ -1017,8 +1055,7 @@ class ProjectManager:"to avoid a filename collision")elif suffix in PDF_SUFFIXES:- canonical_markdown_path = sources_dir / f"{archived_path.stem}.md"- if archived_path.stem in explicit_markdown_stems:+ if has_explicit_markdown:summary["notes"].append(f"{item}: skipped PDF auto-conversion because a same-stem Markdown source was provided")@@ -1040,7 +1077,6 @@ class ProjectManager:except Exception as exc: # pragma: no cover - summary pathsummary["skipped"].append(f"{item}: PDF conversion failed ({exc})")elif suffix in PRESENTATION_SUFFIXES:- canonical_markdown_path = sources_dir / f"{archived_path.stem}.md"try:intake_dir = self._import_pptx_intake(archived_path, project_dir)intake_str = str(intake_dir)@@ -1048,7 +1084,7 @@ class ProjectManager:summary["analysis"].append(intake_str)except Exception as exc: # pragma: no cover - summary pathsummary["notes"].append(f"{item}: PPTX intake analysis failed ({exc})")- if archived_path.stem in explicit_markdown_stems:+ if has_explicit_markdown:summary["notes"].append(f"{item}: skipped presentation auto-conversion because a same-stem Markdown source was provided")@@ -1070,8 +1106,7 @@ class ProjectManager:except Exception as exc: # pragma: no cover - summary pathsummary["skipped"].append(f"{item}: presentation conversion failed ({exc})")elif suffix in EXCEL_SUFFIXES:- canonical_markdown_path = sources_dir / f"{archived_path.stem}.md"- if archived_path.stem in explicit_markdown_stems:+ if has_explicit_markdown:summary["notes"].append(f"{item}: skipped Excel auto-conversion because a same-stem Markdown source was provided")@@ -1102,8 +1137,7 @@ class ProjectManager:f"{item}: archived as a plain-text table source; no Markdown conversion needed")elif suffix in DOC_SUFFIXES:- canonical_markdown_path = sources_dir / f"{archived_path.stem}.md"- if archived_path.stem in explicit_markdown_stems:+ if has_explicit_markdown:summary["notes"].append(f"{item}: skipped document auto-conversion because a same-stem Markdown source was provided")diff --git a/skills/ppt-master/scripts/tests/test_audit_r3_sources.py b/skills/ppt-master/scripts/tests/test_audit_r3_sources.pyindex 476cd907..1c02319c 100644--- a/skills/ppt-master/scripts/tests/test_audit_r3_sources.py+++ b/skills/ppt-master/scripts/tests/test_audit_r3_sources.py@@ -13,6 +13,7 @@ Dependencies:from __future__ import annotationsimport contextlib+import base64import ioimport jsonimport socket@@ -412,6 +413,226 @@ class ArchivedProjectImportTests(unittest.TestCase):)+class SameStemProjectImportTests(unittest.TestCase):+ def setUp(self) -> None:+ self.temporary = tempfile.TemporaryDirectory()+ self.addCleanup(self.temporary.cleanup)+ self.root = Path(self.temporary.name)+ self.manager = project_cli.ProjectManager(base_dir=self.root / "projects")++ def _project(self, name="target") -> Path:+ with contextlib.redirect_stdout(io.StringIO()):+ return Path(self.manager.init_project(name, quick_generate=True))++ def _workbooks(self, root: Path) -> list[Path]:+ from openpyxl import Workbook++ root.mkdir(parents=True)+ sources = []+ for suffix, total in ((".xlsx", 20000), (".xlsm", 22500)):+ workbook = Workbook()+ workbook.active.append(["Category", "Amount"])+ workbook.active.append(["Total", total])+ source = root / f"budget{suffix}"+ workbook.save(source)+ workbook.close()+ sources.append(source)+ return sources++ def _import(self, project: Path, sources: list[Path]) -> dict:+ with contextlib.redirect_stdout(io.StringIO()):+ return self.manager.import_sources(str(project), list(map(str, sources)), copy=True)++ def _assert_conversions(self, project: Path, summary: dict, labels: list[str]) -> None:+ self.assertEqual(summary["skipped"], [])+ self.assertEqual(len(summary["markdown"]), len(labels))+ self.assertEqual(len(set(summary["markdown"])), len(labels))+ for raw_path, markdown_path, label in zip(summary["archived"], summary["markdown"], labels):+ source = Path(raw_path)+ markdown = Path(markdown_path)+ self.assertEqual(source.stem, markdown.stem)+ content = markdown.read_text(encoding="utf-8").replace(r"\-", "-")+ self.assertIn(label, content)+ for other_label in labels:+ if other_label != label:+ self.assertNotIn(other_label, content)+ profile = json.loads(profile_path_for(markdown).read_text(encoding="utf-8"))+ self.assertEqual(profile["source"]["name"], source.name)+ self.assertEqual(profile["outputs"]["markdown"], markdown.name)++ def test_same_stem_workbooks_each_convert_with_matching_archived_names(self) -> None:+ for reverse in (False, True):+ with self.subTest(reverse=reverse):+ sources = self._workbooks(self.root / f"inputs_{reverse}")+ labels = ["20000", "22500"]+ if reverse:+ sources.reverse()+ labels.reverse()+ originals = {source: source.read_bytes() for source in sources}+ project = self._project(f"target_{reverse}")+ summary = self._import(project, sources)+ self._assert_conversions(project, summary, labels)+ self.assertEqual([Path(path).name for path in summary["markdown"]],+ ["budget.md", "budget_2.md"])+ for source, archived in zip(sources, summary["archived"]):+ self.assertEqual(Path(archived).read_bytes(), originals[source])+ self.assertEqual(source.read_bytes(), originals[source])++ def test_document_and_presentation_assets_and_intake_keep_each_source(self) -> None:+ from docx import Document+ from PIL import Image+ from pptx import Presentation+ from pptx.util import Inches++ for kind in ("document", "presentation"):+ with self.subTest(kind=kind):+ inputs = self.root / kind+ inputs.mkdir()+ sources = []+ expected_images = []+ labels = ["FIRST-SOURCE-20000", "SECOND-SOURCE-22500"]+ for index, color in enumerate(("red", "blue")):+ buffer = io.BytesIO()+ Image.new("RGB", (16, 16), color).save(buffer, format="PNG")+ raw = buffer.getvalue()+ expected_images.append(raw)+ if kind == "document":+ source = inputs / ("report.docx" if index == 0 else "report.html")+ if index == 0:+ document = Document()+ document.add_paragraph(labels[index])+ document.add_picture(io.BytesIO(raw))+ document.save(source)+ else:+ encoded = base64.b64encode(raw).decode("ascii")+ source.write_text(+ f'<p>{labels[index]}</p><img src="data:image/png;base64,{encoded}">',+ encoding="utf-8",+ )+ else:+ source = inputs / ("deck.pptx" if index == 0 else "deck.potx")+ presentation = Presentation()+ slide = presentation.slides.add_slide(presentation.slide_layouts[6])+ slide.shapes.add_textbox(Inches(1), Inches(1), Inches(5), Inches(1)).text = labels[index]+ slide.shapes.add_picture(io.BytesIO(raw), Inches(1), Inches(2))+ presentation.save(source)+ sources.append(source)+ project = self._project(kind)+ summary = self._import(project, sources)+ self._assert_conversions(project, summary, labels)+ stems = {Path(path).stem for path in summary["archived"]}+ manifest = json.loads((project / "images/image_manifest.json").read_text(encoding="utf-8"))+ self.assertEqual({row["source_namespace"] for row in manifest}, stems)+ self.assertEqual({(project / "images" / row["filename"]).read_bytes() for row in manifest},+ set(expected_images))+ for source, raw in zip(summary["archived"], expected_images):+ assets = project / "sources" / f"{Path(source).stem}_files"+ self.assertEqual(len(list(assets.glob("*.png"))), 1)+ self.assertEqual(next(assets.glob("*.png")).read_bytes(), raw)+ if kind == "presentation":+ index = json.loads((project / "analysis/source_profile.json").read_text(encoding="utf-8"))+ self.assertEqual(index["deck_count"], 2)+ self.assertEqual({deck["stem"] for deck in index["decks"]}, stems)+ self.assertEqual({deck["source_pptx"] for deck in index["decks"]}, set(summary["archived"]))+ for stem, label in zip(("deck", "deck_2"), labels):+ self.assertTrue((project / "analysis" / f"{stem}.identity.json").is_file())+ library = project / "analysis" / f"{stem}.slide_library.json"+ self.assertIn(label, library.read_text(encoding="utf-8"))++ def test_reused_markdown_does_not_merge_same_stem_presentation_intake(self) -> None:+ from pptx import Presentation+ from pptx.util import Inches++ for explicit in (False, True):+ with self.subTest(explicit=explicit):+ inputs = self.root / f"companion_{explicit}"+ inputs.mkdir()+ sources = []+ labels = ["FIRST-SOURCE-20000", "SECOND-SOURCE-22500"]+ for suffix, label in zip((".pptx", ".potx"), labels):+ presentation = Presentation()+ slide = presentation.slides.add_slide(presentation.slide_layouts[6])+ slide.shapes.add_textbox(Inches(1), Inches(1), Inches(5), Inches(1)).text = label+ source = inputs / f"deck{suffix}"+ presentation.save(source)+ sources.append(source)+ project = self._project(f"companion_{explicit}")+ (project / "sources").mkdir()+ markdown = (inputs if explicit else project / "sources") / "deck.md"+ markdown.write_text("# Authoritative Markdown\n", encoding="utf-8")+ summary = self._import(project, [*sources, markdown] if explicit else sources)+ self.assertEqual(summary["skipped"], [])+ self.assertEqual([Path(path).name for path in summary["archived"][:2]],+ ["deck.pptx", "deck_2.potx"])+ self.assertEqual((project / "sources/deck.md").read_text(encoding="utf-8"),+ "# Authoritative Markdown\n")+ self.assertEqual(list((project / "sources").glob("*.conversion_profile.json")), [])+ self.assertEqual(sum("skipped presentation auto-conversion" in note+ for note in summary["notes"]), 2)+ index = json.loads((project / "analysis/source_profile.json").read_text(encoding="utf-8"))+ self.assertEqual(index["deck_count"], 2)+ self.assertEqual({deck["stem"] for deck in index["decks"]}, {"deck", "deck_2"})+ self.assertEqual({deck["source_pptx"] for deck in index["decks"]},+ set(summary["archived"][:2]))+ for stem, label, other_label in zip(("deck", "deck_2"), labels, reversed(labels)):+ self.assertTrue((project / "analysis" / f"{stem}.identity.json").is_file())+ library = (project / "analysis" / f"{stem}.slide_library.json").read_text(encoding="utf-8")+ self.assertIn(label, library)+ self.assertNotIn(other_label, library)++ def test_explicit_markdown_still_suppresses_both_conversions(self) -> None:+ for markdown_first in (False, True):+ with self.subTest(markdown_first=markdown_first):+ sources = self._workbooks(self.root / f"explicit_{markdown_first}")+ markdown = sources[0].with_suffix(".md")+ markdown.write_text("# Authoritative Markdown\n", encoding="utf-8")+ inputs = [markdown, *sources] if markdown_first else [*sources, markdown]+ project = self._project(f"explicit_{markdown_first}")+ summary = self._import(project, inputs)+ self.assertEqual(summary["skipped"], [])+ self.assertEqual((project / "sources/budget.md").read_text(encoding="utf-8"),+ "# Authoritative Markdown\n")+ self.assertEqual(list((project / "sources").glob("*.conversion_profile.json")), [])+ self.assertEqual(sum("same-stem Markdown source was provided" in note+ for note in summary["notes"]), 2)++ def test_markdown_existing_before_import_is_reused(self) -> None:+ sources = self._workbooks(self.root / "existing")+ project = self._project()+ (project / "sources").mkdir()+ markdown = project / "sources/budget.md"+ markdown.write_text("# Previous conversion\n", encoding="utf-8")+ summary = self._import(project, sources)+ self.assertEqual(summary["markdown"], [str(markdown), str(markdown)])+ self.assertEqual(markdown.read_text(encoding="utf-8"), "# Previous conversion\n")+ self.assertEqual(sum("budget.md already exists" in note for note in summary["notes"]), 2)+ self.assertEqual(list((project / "sources").glob("*.conversion_profile.json")), [])++ def test_generated_suffix_avoids_existing_markdown_and_source_names(self) -> None:+ sources = self._workbooks(self.root / "suffixes")+ project = self._project()+ (project / "sources").mkdir()+ existing = project / "sources/budget_2.md"+ existing.write_text("# Unrelated existing source\n", encoding="utf-8")+ occupied = project / "sources/budget_3.xlsm"+ occupied.write_bytes(b"archived original")+ summary = self._import(project, sources)+ self._assert_conversions(project, summary, ["20000", "22500"])+ self.assertEqual([Path(path).name for path in summary["markdown"]],+ ["budget.md", "budget_4.md"])+ self.assertEqual(existing.read_text(encoding="utf-8"), "# Unrelated existing source\n")+ self.assertEqual(occupied.read_bytes(), b"archived original")++ def test_failed_conversion_still_reserves_its_source_stem(self) -> None:+ sources = self._workbooks(self.root / "failure")+ sources[0].write_bytes(b"invalid workbook")+ project = self._project()+ summary = self._import(project, sources)+ self.assertEqual(len(summary["skipped"]), 1)+ self.assertEqual([Path(path).name for path in summary["markdown"]], ["budget_2.md"])+ self.assertIn("22500", Path(summary["markdown"][0]).read_text(encoding="utf-8"))++class _CurlHeaders(dict):"""Represent repeated curl headers without importing optional curl_cffi."""