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(project_manager): prefer short image filenames, guard empty URL conversions
hugohe3049c5df7607f
diff --git a/skills/ppt-master/scripts/project_manager.py b/skills/ppt-master/scripts/project_manager.pyindex 6ff1e225..ca6b7db2 100644--- a/skills/ppt-master/scripts/project_manager.py+++ b/skills/ppt-master/scripts/project_manager.py@@ -11,6 +11,7 @@ Usage:from __future__ import annotationsimport argparse+import filecmpimport jsonimport reimport shutil@@ -162,7 +163,7 @@ class ProjectManager:"## Directories\n\n""- `svg_output/`: raw SVG output\n""- `svg_final/`: finalized SVG output\n"- "- `images/`: presentation assets\n"+ "- `images/`: runtime image pool; converter assets keep their original short filenames when possible\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"@@ -330,6 +331,15 @@ class ProjectManager:]self._run_tool(command)+ def _is_valid_imported_url_markdown(self, markdown_path: Path) -> bool:+ """Return whether web_to_md produced a usable Markdown source."""+ if not markdown_path.is_file():+ return False+ content = markdown_path.read_text(encoding="utf-8", errors="replace")+ if "[Failed URLs]:" in content:+ return False+ return bool(content.strip())+def _archive_url_record(self, sources_dir: Path, url: str) -> Path:file_path = self._ensure_unique_path(sources_dir / f"{derive_url_basename(url)}.url.txt")file_path.write_text(@@ -443,11 +453,53 @@ class ProjectManager:suffix = "_files"return name[:-len(suffix)] if name.endswith(suffix) else name+ def _image_destination_name(+ self,+ images_dir: Path,+ source_file: Path,+ namespace: str,+ existing_manifest: dict[str, dict],+ ) -> str:+ """Return a short unique image filename for the runtime image pool."""+ candidate = images_dir / source_file.name+ if not candidate.exists():+ return source_file.name+ try:+ meta = existing_manifest.get(candidate.name, {})+ if (+ meta.get("source_namespace") == namespace+ and candidate.is_file()+ and filecmp.cmp(source_file, candidate, shallow=False)+ ):+ return candidate.name+ except OSError:+ pass++ stem = source_file.stem+ suffix = source_file.suffix+ counter = 2+ while True:+ candidate = images_dir / f"{stem}_{counter}{suffix}"+ if not candidate.exists():+ return candidate.name+ try:+ meta = existing_manifest.get(candidate.name, {})+ if (+ meta.get("source_namespace") == namespace+ and candidate.is_file()+ and filecmp.cmp(source_file, candidate, shallow=False)+ ):+ return candidate.name+ except OSError:+ pass+ counter += 1+def _propagate_image_assets(self, asset_dir: Path, project_dir: Path) -> None:"""Copy converter-generated image assets and manifest into project images/.- Files are namespaced by source stem to avoid collisions when multiple- DOCX/PPTX sources contain identically-named internal media (image1.png, ...).+ Filenames are preserved when possible because source Markdown commonly+ uses short names that are meaningful in context. Only real collisions+ receive a compact numeric suffix."""manifest_path = asset_dir / "image_manifest.json"if not manifest_path.is_file():@@ -466,6 +518,19 @@ class ProjectManager:images_dir.mkdir(parents=True, exist_ok=True)namespace = self._namespace_from_asset_dir(asset_dir)+ existing_manifest: dict[str, dict] = {}+ destination_manifest = images_dir / "image_manifest.json"+ if destination_manifest.is_file():+ try:+ data = json.loads(destination_manifest.read_text(encoding="utf-8"))+ if isinstance(data, list):+ existing_manifest = {+ item["filename"]: item+ for item in data+ if isinstance(item, dict) and isinstance(item.get("filename"), str)+ }+ except (OSError, json.JSONDecodeError):+ existing_manifest = {}rename_map: dict[str, str] = {}copied_count = 0@@ -474,8 +539,15 @@ class ProjectManager:continueif source_file.suffix.lower() not in IMAGE_ASSET_SUFFIXES:continue- new_name = f"{namespace}__{source_file.name}"- shutil.copy2(source_file, images_dir / new_name)+ new_name = self._image_destination_name(+ images_dir,+ source_file,+ namespace,+ existing_manifest,+ )+ destination = images_dir / new_name+ if source_file.resolve() != destination.resolve():+ shutil.copy2(source_file, destination)rename_map[source_file.name] = new_namecopied_count += 1@@ -487,7 +559,7 @@ class ProjectManager:if not isinstance(original, str):continuenew_item = dict(item)- new_item["filename"] = rename_map.get(original, f"{namespace}__{original}")+ new_item["filename"] = rename_map.get(original, original)new_item["source_namespace"] = namespacerebased_items.append(new_item)@@ -572,17 +644,24 @@ class ProjectManager:for item in source_items:if is_url(item):- archived = self._archive_url_record(sources_dir, item)markdown_path = self._ensure_unique_path(sources_dir / f"{derive_url_basename(item)}.md")try:self._import_url(item, markdown_path)except Exception as exc: # pragma: no cover - summary path+ archived = self._archive_url_record(sources_dir, item)+ summary["archived"].append(str(archived))summary["skipped"].append(f"{item}: {exc}")continue- summary["archived"].append(str(archived))+ if not self._is_valid_imported_url_markdown(markdown_path):+ markdown_path.unlink(missing_ok=True)+ archived = self._archive_url_record(sources_dir, item)+ summary["archived"].append(str(archived))+ summary["skipped"].append(f"{item}: URL conversion produced no usable Markdown")+ continue+summary["markdown"].append(str(markdown_path))self._propagate_companion_image_assets(markdown_path, project_dir)continue