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(checker): add --stage page for one authored SVG

hugohe370798c86d956
diff --git a/skills/ppt-master/scripts/svg_quality/cli.py b/skills/ppt-master/scripts/svg_quality/cli.py
index 483a7a54..3cc41e67 100644
--- a/skills/ppt-master/scripts/svg_quality/cli.py
+++ b/skills/ppt-master/scripts/svg_quality/cli.py
@@ -32,6 +32,49 @@ def _first_page_target(target: str) -> str:
return str(svg_files[0]) if svg_files else target
+def _page_target(target: str, page: str) -> str:
+ """Resolve one requested page while keeping it inside ``svg_output/``."""
+ target_path = Path(target).resolve()
+ svg_root = (
+ target_path
+ if target_path.is_dir() and target_path.name == "svg_output"
+ else target_path / "svg_output"
+ )
+ if not svg_root.is_dir():
+ raise ValueError(
+ "--stage page requires a project or svg_output directory target"
+ )
+ svg_root = svg_root.resolve()
+
+ requested = Path(page)
+ if requested.is_absolute():
+ candidates = [requested]
+ else:
+ candidates = [svg_root / requested]
+ if requested.parts and requested.parts[0] == "svg_output":
+ candidates.append(svg_root.parent / requested)
+ candidates.append(Path.cwd() / requested)
+
+ inside_candidates: list[Path] = []
+ for candidate in candidates:
+ resolved = candidate.resolve()
+ try:
+ resolved.relative_to(svg_root)
+ except ValueError:
+ continue
+ if resolved not in inside_candidates:
+ inside_candidates.append(resolved)
+ if resolved.is_file() and resolved.suffix.casefold() == ".svg":
+ return str(resolved)
+
+ if not inside_candidates:
+ raise ValueError("--page must resolve to a path under svg_output/")
+ candidate = inside_candidates[0]
+ if candidate.suffix.casefold() != ".svg":
+ raise ValueError(f"--page must name an SVG file: {page}")
+ raise ValueError(f"--page SVG does not exist: {page}")
+
+
def _default_json_report_path(
checker: SVGQualityChecker,
target: str,
@@ -40,11 +83,11 @@ def _default_json_report_path(
"""Choose a stage-specific report path without overwriting the final gate."""
target_path = Path(target)
project_path = checker._resolve_project_path(target_path)
- report_name = (
- "svg_quality_report.json"
- if stage == "final"
- else "svg_quality_first_page_report.json"
- )
+ report_name = {
+ "final": "svg_quality_report.json",
+ "first-page": "svg_quality_first_page_report.json",
+ "page": "svg_quality_page_report.json",
+ }[stage]
if (
(project_path / "svg_output").is_dir()
or (project_path / "design_spec.md").is_file()
@@ -70,9 +113,13 @@ def print_usage() -> None:
print(" python3 scripts/svg_quality_checker.py templates/decks/中国电信/templates --template-mode")
print("\nOptions:")
print(" --format <ppt169|ppt43|...> Expected canvas format")
- print(" --stage <first-page|final> first-page checks only the first authored SVG")
- print(" with a partial structure roster; final (default)")
- print(" requires the complete declared page roster.")
+ print(" --stage <first-page|page|final>")
+ print(" first-page checks only the first authored SVG;")
+ print(" page checks only --page with the same partial")
+ print(" structure rules; final (default) requires the")
+ print(" complete declared page roster.")
+ print(" --page <basename|path> Required with --stage page; must resolve under")
+ print(" the target project's svg_output/ directory.")
print(" --json Write a machine-readable quality report")
print(" --json-output <path> Override the JSON report path")
print(" --export Write a plain-text quality report")
@@ -125,6 +172,7 @@ def main() -> None:
target = sys.argv[1]
expected_format = None
stage = "final"
+ page = None
if "--format" in sys.argv:
idx = sys.argv.index("--format")
@@ -132,20 +180,32 @@ def main() -> None:
expected_format = sys.argv[idx + 1]
if "--stage" in sys.argv:
idx = sys.argv.index("--stage")
- if idx + 1 >= len(sys.argv):
- print("[ERROR] --stage requires first-page or final")
+ if idx + 1 >= len(sys.argv) or sys.argv[idx + 1].startswith("--"):
+ print("[ERROR] --stage requires first-page, page, or final")
sys.exit(1)
stage = sys.argv[idx + 1]
- if stage not in {"first-page", "final"}:
+ if stage not in {"first-page", "page", "final"}:
print(f"[ERROR] Unsupported quality-check stage: {stage}")
sys.exit(1)
+ if "--page" in sys.argv:
+ idx = sys.argv.index("--page")
+ if idx + 1 >= len(sys.argv) or sys.argv[idx + 1].startswith("--"):
+ print("[ERROR] --page requires a basename or path under svg_output/")
+ sys.exit(1)
+ page = sys.argv[idx + 1]
+ if stage == "page" and page is None:
+ print("[ERROR] --stage page requires --page <basename or path under svg_output/>")
+ sys.exit(1)
+ if stage != "page" and page is not None:
+ print("[ERROR] --page is supported only with --stage page")
+ sys.exit(1)
if target == "--all":
if quick_generate:
print("[ERROR] --quick-generate does not support --all")
sys.exit(1)
if stage != "final":
- print("[ERROR] --stage first-page does not support --all")
+ print(f"[ERROR] --stage {stage} does not support --all")
sys.exit(1)
base_dir = sys.argv[2] if len(sys.argv) > 2 else "projects"
from project_utils import find_all_projects
@@ -158,7 +218,16 @@ def main() -> None:
print("=" * 80)
checker.check_directory(str(project))
else:
- check_target = _first_page_target(target) if stage == "first-page" else target
+ if stage == "first-page":
+ check_target = _first_page_target(target)
+ elif stage == "page":
+ try:
+ check_target = _page_target(target, page or "")
+ except ValueError as exc:
+ print(f"[ERROR] {exc}")
+ sys.exit(1)
+ else:
+ check_target = target
checker.check_directory(check_target, expected_format)
if stage == "final" and Path(target).is_dir():