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(scripts): filename-matched notes always win, batch source conversion never overwrites an input, editor list cache keeps parse errors
hugohe32d6e36864f30
diff --git a/skills/ppt-master/scripts/docs/conversion.md b/skills/ppt-master/scripts/docs/conversion.mdindex e624f4d8..8901d230 100644--- a/skills/ppt-master/scripts/docs/conversion.md+++ b/skills/ppt-master/scripts/docs/conversion.md@@ -69,6 +69,9 @@ Useful options:A path that names an existing directory, or ends in `/`, is always treated asa directory, even for a single input: the file keeps its default `<stem>.md`name inside it; an extension-less `-o` for one input gains `.md`.+ Local batch outputs are planned together; input/output collisions gain `_2`,+ `_3`, etc. suffixes and are reported on stderr. A single-input file `-o`+ refuses an existing file except its own Markdown/text passthrough.For multi-source project intake, use `project_manager.py import-sources` withall source paths / URLs. For local files, the default is to keep generateddiff --git a/skills/ppt-master/scripts/source_to_md.py b/skills/ppt-master/scripts/source_to_md.pyindex 491594fa..2a29d231 100644--- a/skills/ppt-master/scripts/source_to_md.py+++ b/skills/ppt-master/scripts/source_to_md.py@@ -91,14 +91,17 @@ def _dispatch_output_arg(batch_mode = Trueif output_arg and batch_mode and conversion_type == "web":return None- if output_arg and batch_mode:- return str(- unique_output_path(- Path(output_arg),- default_markdown_path(input_arg).stem,- used_outputs,+ if batch_mode and conversion_type != "web":+ default_output = default_markdown_path(input_arg)+ if output_arg:+ default_output = Path(output_arg) / default_output.name+ output = unique_output_path(default_output.parent, default_output.stem, used_outputs)+ if output != default_output:+ _print_status(+ f"[INFO] Renamed output for {input_arg}: {default_output} -> {output} "+ "(input/output collision)")- )+ return str(output)if output_arg:# One input with an extension-less -o names the Markdown file, not a# directory: `-o sources_cf` writes `sources_cf.md` (a directory is@@ -106,8 +109,6 @@ def _dispatch_output_arg(if not Path(output_arg).suffix:return f"{output_arg}.md"return output_arg- if batch_mode and conversion_type != "web":- return str(default_markdown_path(input_arg))return None@@ -462,17 +463,35 @@ def dispatch_many(if output_dir.exists() and not output_dir.is_dir():print(f"[ERROR] Batch output path is not a directory: {args.output}", file=sys.stderr)return 1- output_dir.mkdir(parents=True, exist_ok=True)- used_outputs: set[Path] = set()- for input_arg, conversion_type in zip(inputs, conversion_types):- output_arg = _dispatch_output_arg(+ input_paths = {Path(item).resolve() for item in inputs if not is_url(item)}+ used_outputs = set(input_paths)+ output_args = [+ _dispatch_output_arg(input_arg,conversion_type,args.output,batch_mode,used_outputs,)+ for input_arg, conversion_type in zip(inputs, conversion_types)+ ]+ if args.output and not batch_mode and output_args:+ output = Path(output_args[0])+ own_passthrough = (+ output.resolve() in input_paths and conversion_types[0] in {"markdown", "text"}+ )+ if output.exists() and not own_passthrough:+ print(+ f"[ERROR] Refusing to overwrite existing file: {output}. Choose a different -o path.",+ file=sys.stderr,+ )+ return 1++ if args.output and batch_mode:+ Path(args.output).mkdir(parents=True, exist_ok=True)++ for input_arg, conversion_type, output_arg in zip(inputs, conversion_types, output_args):web_output_dir = (args.outputif args.output and batch_mode and conversion_type == "web"diff --git a/skills/ppt-master/scripts/svg_editor/server.py b/skills/ppt-master/scripts/svg_editor/server.pyindex 414debb2..54bb96a9 100644--- a/skills/ppt-master/scripts/svg_editor/server.py+++ b/skills/ppt-master/scripts/svg_editor/server.py@@ -108,7 +108,7 @@ _SLIDE_CACHE_LOCK = threading.Lock()_SLIDE_CACHE: dict = {} # path -> (mtime, (content, warnings))_LIST_CACHE_LOCK = threading.Lock()-_LIST_CACHE: dict = {} # path -> (mtime, annotation_count_on_disk)+_LIST_CACHE: dict = {} # path -> (mtime, (annotation_count_on_disk, ok, error))# Keep live preview on a separate range from Confirm UI so a stale preview tab# cannot send ``/api/shutdown`` to a later Confirm UI process.@@ -558,8 +558,8 @@ def create_app(ok = Trueerror_msg: Optional[str] = None- disk_count = _cache_get(_LIST_CACHE, _LIST_CACHE_LOCK, path_str, mtime)- if disk_count is None:+ cached = _cache_get(_LIST_CACHE, _LIST_CACHE_LOCK, path_str, mtime)+ if cached is None:try:tree = ET.parse(path_str)disk_count = len(parse_annotations(tree.getroot()))@@ -568,7 +568,9 @@ def create_app(error_msg = f'XML parse error: {exc}'disk_count = 0logger.warning('slide parse failed: %s: %s', svg_file.name, exc)- _cache_put(_LIST_CACHE, _LIST_CACHE_LOCK, path_str, mtime, disk_count)+ _cache_put(_LIST_CACHE, _LIST_CACHE_LOCK, path_str, mtime, (disk_count, ok, error_msg))+ else:+ disk_count, ok, error_msg = cachedif svg_file.name in annotations:annotation_count = len(annotations[svg_file.name])diff --git a/skills/ppt-master/scripts/svg_to_pptx/pptx_package/discovery.py b/skills/ppt-master/scripts/svg_to_pptx/pptx_package/discovery.pyindex 9cd91c7a..d9232744 100644--- a/skills/ppt-master/scripts/svg_to_pptx/pptx_package/discovery.py+++ b/skills/ppt-master/scripts/svg_to_pptx/pptx_package/discovery.py@@ -3,6 +3,7 @@from __future__ import annotationsimport re+import sysfrom pathlib import Pathfrom slide_roster import discover_slide_svgs@@ -75,10 +76,11 @@ def find_notes_files(Dict mapping SVG filename stem to notes content."""notes_dir = project_path / 'notes'- notes: dict[str, str] = {}+ index_notes: dict[str, tuple[Path, str]] = {}+ filename_notes: dict[str, tuple[Path, str]] = {}if not notes_dir.exists():- return notes+ return {}svg_stems_mapping: dict[str, int] = {}svg_index_mapping: dict[int, str] = {}@@ -111,10 +113,19 @@ def find_notes_files(continueif mapped_stem:- notes[mapped_stem] = content+ index_notes[mapped_stem] = (notes_file, content)- # Filename-based matching overrides index-based matching.if filename_match:- notes[stem] = content-- return notes+ filename_notes[stem] = (notes_file, content)++ # Apply filename priority after collecting both modes, regardless of glob order.+ for stem, (notes_file, _content) in filename_notes.items():+ indexed = index_notes.get(stem)+ if indexed is not None and indexed[0] != notes_file:+ print(+ f" Note: {stem}.svg uses filename-matched notes {notes_file} "+ f"instead of index-matched {indexed[0]}",+ file=sys.stderr,+ )+ index_notes.update(filename_notes)+ return {stem: content for stem, (_path, content) in index_notes.items()}diff --git a/skills/ppt-master/scripts/tests/test_native_export_guards.py b/skills/ppt-master/scripts/tests/test_native_export_guards.pyindex 1d15340f..144a65a1 100644--- a/skills/ppt-master/scripts/tests/test_native_export_guards.py+++ b/skills/ppt-master/scripts/tests/test_native_export_guards.py@@ -3,10 +3,13 @@from __future__ import annotations+import ioimport sysimport tempfileimport unittest+from contextlib import redirect_stderrfrom pathlib import Path+from unittest.mock import patchfrom xml.etree import ElementTree as ET@@ -23,6 +26,7 @@ from svg_to_pptx.drawingml.converter import ( # noqa: E402convert_svg_to_slide_shapes,)from svg_to_pptx.drawingml.styles import build_gradient_fill # noqa: E402+from svg_to_pptx.pptx_package.discovery import find_notes_files # noqa: E402NS = {@@ -424,5 +428,44 @@ class NativeExportGuardTests(unittest.TestCase):self.assertEqual([n.get('y') for n in tree.getroot()], ['120', '116'])+class NotesDiscoveryTests(unittest.TestCase):+ def setUp(self) -> None:+ self.temporary = tempfile.TemporaryDirectory()+ self.addCleanup(self.temporary.cleanup)+ self.root = Path(self.temporary.name)+ self.notes_dir = self.root / 'notes'+ self.notes_dir.mkdir()++ def test_filename_notes_win_in_both_glob_orders(self) -> None:+ exact = self.notes_dir / '01_intro.md'+ legacy = self.notes_dir / 'slide01.md'+ exact.write_text('EXACT FILENAME NOTE\n', encoding='utf-8')+ legacy.write_text('LEGACY INDEX NOTE\n', encoding='utf-8')+ for order in ([exact, legacy], [legacy, exact]):+ with self.subTest(order=[path.name for path in order]):+ stderr = io.StringIO()+ with patch.object(Path, 'glob', return_value=iter(order)), redirect_stderr(stderr):+ notes = find_notes_files(self.root, [self.root / '01_intro.svg'])+ self.assertEqual(notes, {'01_intro': 'EXACT FILENAME NOTE'})+ self.assertEqual(len(stderr.getvalue().splitlines()), 1)+ self.assertIn('01_intro.svg', stderr.getvalue())+ self.assertIn(str(exact), stderr.getvalue())++ def test_legacy_notes_still_match_by_slide_index(self) -> None:+ (self.notes_dir / 'slide01.md').write_text('LEGACY INDEX NOTE\n', encoding='utf-8')+ self.assertEqual(+ find_notes_files(self.root, [self.root / '01_intro.svg']),+ {'01_intro': 'LEGACY INDEX NOTE'},+ )++ def test_one_file_matching_both_modes_does_not_warn(self) -> None:+ (self.notes_dir / 'slide01.md').write_text('SLIDE NOTE\n', encoding='utf-8')+ stderr = io.StringIO()+ with redirect_stderr(stderr):+ notes = find_notes_files(self.root, [self.root / 'slide01.svg'])+ self.assertEqual(notes, {'slide01': 'SLIDE NOTE'})+ self.assertEqual(stderr.getvalue(), '')++if __name__ == '__main__':unittest.main()diff --git a/skills/ppt-master/scripts/tests/test_source_to_md_cli.py b/skills/ppt-master/scripts/tests/test_source_to_md_cli.pyindex fc42738b..4c7c41ee 100644--- a/skills/ppt-master/scripts/tests/test_source_to_md_cli.py+++ b/skills/ppt-master/scripts/tests/test_source_to_md_cli.py@@ -4,6 +4,8 @@from __future__ import annotationsimport argparse+import json+import subprocessimport sysimport tempfileimport unittest@@ -111,5 +113,103 @@ class RawTextUrlTests(unittest.TestCase):self.assertFalse(source_to_md._skips_images(_args(images="all")))+class SourceCollisionTests(unittest.TestCase):+ def setUp(self) -> None:+ self.temporary = tempfile.TemporaryDirectory()+ self.addCleanup(self.temporary.cleanup)+ self.root = Path(self.temporary.name)++ def _run_cli(self, *arguments: str) -> subprocess.CompletedProcess:+ return subprocess.run(+ [sys.executable, str(SCRIPTS_DIR / "source_to_md.py"), *arguments, "--json"],+ capture_output=True,+ text=True,+ encoding="utf-8",+ check=False,+ )++ def _outputs(self, result: subprocess.CompletedProcess) -> list[Path]:+ return [+ Path(json.loads(line)["markdown"])+ for line in result.stdout.splitlines() if line.startswith("{")+ ]++ def test_same_stem_batch_preserves_markdown_in_both_orders(self) -> None:+ for reverse in (False, True):+ for output_directory in (False, True):+ with self.subTest(reverse=reverse, output_directory=output_directory):+ root = self.root / f"{reverse}_{output_directory}"+ root.mkdir()+ text_source = root / "same.txt"+ markdown_source = root / "same.md"+ text_source.write_text("TEXT-SOURCE\n", encoding="utf-8")+ markdown_source.write_text("ORIGINAL-MARKDOWN\n", encoding="utf-8")+ inputs = [text_source, markdown_source]+ if reverse:+ inputs.reverse()+ arguments = [str(path) for path in inputs]+ if output_directory:+ arguments.extend(["-o", str(root)])+ result = self._run_cli(*arguments)+ self.assertEqual(result.returncode, 0, result.stderr)+ self.assertEqual(markdown_source.read_text(encoding="utf-8"), "ORIGINAL-MARKDOWN\n")+ self.assertEqual(text_source.read_text(encoding="utf-8"), "TEXT-SOURCE\n")+ outputs = self._outputs(result)+ self.assertEqual(outputs, [root / "same_2.md", root / "same_3.md"])+ for source, output in zip(inputs, outputs):+ self.assertEqual(output.read_text(encoding="utf-8"), source.read_text(encoding="utf-8"))+ self.assertIn("Renamed output", result.stderr)+ self.assertIn("Success: 2/2", result.stderr)++ def test_batch_outputs_with_the_same_stem_are_distinct(self) -> None:+ text_source = self.root / "same.txt"+ markdown_source = self.root / "same.markdown"+ text_source.write_text("TEXT-SOURCE\n", encoding="utf-8")+ markdown_source.write_text("ORIGINAL-MARKDOWN\n", encoding="utf-8")+ result = self._run_cli(str(text_source), str(markdown_source))+ self.assertEqual(result.returncode, 0, result.stderr)+ outputs = self._outputs(result)+ self.assertEqual(outputs, [self.root / "same.md", self.root / "same_2.md"])+ self.assertEqual([path.read_text(encoding="utf-8") for path in outputs],+ ["TEXT-SOURCE\n", "ORIGINAL-MARKDOWN\n"])++ def test_batch_suffixes_also_avoid_input_paths(self) -> None:+ inputs = [self.root / name for name in ("same.txt", "same.md", "same_2.md")]+ for index, source in enumerate(inputs):+ source.write_text(f"SOURCE-{index}\n", encoding="utf-8")+ result = self._run_cli(*(str(path) for path in inputs))+ self.assertEqual(result.returncode, 0, result.stderr)+ outputs = self._outputs(result)+ self.assertEqual(len(set(outputs)), 3)+ self.assertFalse(set(inputs) & set(outputs))+ for index, (source, output) in enumerate(zip(inputs, outputs)):+ self.assertEqual(source.read_text(encoding="utf-8"), f"SOURCE-{index}\n")+ self.assertEqual(output.read_text(encoding="utf-8"), f"SOURCE-{index}\n")++ def test_explicit_output_refuses_another_existing_file(self) -> None:+ source = self.root / "same.txt"+ destination = self.root / "same.md"+ source.write_text("TEXT-SOURCE\n", encoding="utf-8")+ destination.write_text("ORIGINAL-MARKDOWN\n", encoding="utf-8")+ result = self._run_cli(str(source), "-o", str(destination))+ self.assertNotEqual(result.returncode, 0)+ self.assertIn("[ERROR]", result.stderr)+ self.assertIn(str(destination), result.stderr)+ self.assertEqual(destination.read_text(encoding="utf-8"), "ORIGINAL-MARKDOWN\n")+ self.assertEqual(source.read_text(encoding="utf-8"), "TEXT-SOURCE\n")+ self.assertEqual(self._outputs(result), [])+ self.assertFalse(destination.with_suffix(".conversion_profile.json").exists())++ def test_single_markdown_passthrough_keeps_its_own_source(self) -> None:+ source = self.root / "same.md"+ source.write_text("ORIGINAL-MARKDOWN\n", encoding="utf-8")+ for options in ([], ["-o", str(source)]):+ with self.subTest(options=options):+ result = self._run_cli(str(source), *options)+ self.assertEqual(result.returncode, 0, result.stderr)+ self.assertEqual(self._outputs(result), [source])+ self.assertEqual(source.read_text(encoding="utf-8"), "ORIGINAL-MARKDOWN\n")++if __name__ == "__main__":unittest.main()diff --git a/skills/ppt-master/scripts/tests/test_svg_editor_server.py b/skills/ppt-master/scripts/tests/test_svg_editor_server.pynew file mode 100644index 00000000..45b86486--- /dev/null+++ b/skills/ppt-master/scripts/tests/test_svg_editor_server.py@@ -0,0 +1,67 @@+#!/usr/bin/env python3+"""Regression tests for SVG editor slide-list caching without a running server."""++import os+import sys+import tempfile+import unittest+from pathlib import Path+from unittest.mock import patch+++SCRIPTS_DIR = Path(__file__).resolve().parents[1]+if str(SCRIPTS_DIR) not in sys.path:+ sys.path.insert(0, str(SCRIPTS_DIR))++from svg_editor import server # noqa: E402+++class SlideListCacheTests(unittest.TestCase):+ def setUp(self) -> None:+ self.temporary = tempfile.TemporaryDirectory()+ self.addCleanup(self.temporary.cleanup)+ self.root = Path(self.temporary.name)+ svg_dir = self.root / 'svg_output'+ svg_dir.mkdir()+ self.svg_path = svg_dir / '01.svg'+ cache_patch = patch.dict(server._LIST_CACHE, clear=True)+ cache_patch.start()+ self.addCleanup(cache_patch.stop)+ with patch.object(server.threading.Thread, 'start'):+ app = server.create_app(str(self.root), idle_timeout=0)+ app.config['TESTING'] = True+ self.client = app.test_client()++ def _slide(self) -> dict:+ response = self.client.get('/api/slides')+ self.assertEqual(response.status_code, 200)+ slides = response.get_json()['slides']+ self.assertEqual(len(slides), 1)+ return slides[0]++ def test_invalid_svg_keeps_error_on_repeated_requests(self) -> None:+ self.svg_path.write_text('<svg><g>', encoding='utf-8')+ first = self._slide()+ second = self._slide()+ for slide in (first, second):+ self.assertIs(slide['ok'], False)+ self.assertIn('XML parse error:', slide['error'])+ self.assertEqual(slide['annotation_count'], 0)+ self.assertEqual(second, first)++ def test_changed_mtime_refreshes_parse_status(self) -> None:+ self.svg_path.write_text('<svg><g>', encoding='utf-8')+ first = self._slide()+ self.assertIs(first['ok'], False)+ self.svg_path.write_text('<svg xmlns="http://www.w3.org/2000/svg"/>', encoding='utf-8')+ mtime = first['mtime'] + 1+ os.utime(self.svg_path, (mtime, mtime))+ for _ in range(2):+ slide = self._slide()+ self.assertIs(slide['ok'], True)+ self.assertIsNone(slide['error'])+ self.assertEqual(slide['mtime'], mtime)+++if __name__ == '__main__':+ unittest.main()