bestdeejay-design/agent-skills / skills/presentation-maker
presentation-maker
VerifiedEnd-to-end presentations from a topic — outline -> JSON spec -> 16:9 HTML slides (with mandatory Playwright verification) and real .pptx (full 14-type design system), plus strategy presets, PDF export, and deck-quality audits. One command per stage.
scripts/qa_pptx.py
View on GitHub#!/usr/bin/env python3
"""Geometric QA for presentation-maker .pptx decks.
Checks every slide of a deck generated by build_pptx.py:
* bounds — every shape must stay inside the 1600x900 design canvas;
* content — content shapes must not end lower than BOTTOM_STOP (80px from bottom);
* overlap — text-bearing shapes must not intersect each other;
* tables — tables must fit the canvas and have positive cell sizes.
Design elements (ghost-num, decor ovals, chrome logo/page indicator) are
exempt from bounds/content checks by name prefix: `ghost*`, `decor*`, `chrome-*`.
Optionally renders the deck to JPEGs via LibreOffice (soffice -> PDF -> pdftoppm)
so the human (or a vision-capable agent) can eyeball it.
Usage:
python3 qa_pptx.py deck.pptx [--render] [--out dir] [--json report.json]
Exit codes: 0 = clean, 1 = issues found, 2 = error.
"""
from __future__ import annotations
import argparse
import json
import shutil
import subprocess
import sys
import tempfile
from pathlib import Path
try:
from pptx import Presentation
from pptx.util import Emu
except ImportError:
sys.exit("qa_pptx.py requires python-pptx: pip install python-pptx")
PX = 7620 # EMU per design pixel (same constant as build_pptx.py)
W, H = 1600, 900 # design canvas, px
BOTTOM_STOP = 80 # content must not end lower than this, px
OVERLAP_TOLERANCE = 2 # px of intersection allowed before flagging
EXEMPT_BOUNDS_PREFIXES = ("ghost", "decor", "chrome-")
EXEMPT_OVERLAP_PREFIXES = ("ghost", "decor", "chrome-", "hairline")
def _px(emu) -> float:
"""EMU -> design px."""
return emu / PX
def _shape_rect(shape):
"""Return (x, y, w, h) in design px for a shape, or None if unpositioned."""
try:
if shape.left is None or shape.top is None:
return None
return (
_px(shape.left), _px(shape.top),
_px(shape.width), _px(shape.height),
)
except Exception:
return None
def _is_exempt(name: str, prefixes) -> bool:
for p in prefixes:
if name.lower().startswith(p):
return True
return False
def _has_text(shape) -> bool:
if shape.has_text_frame:
text = shape.text_frame.text.strip()
if text:
return True
if shape.shape_type == 19: # TABLE
return True
return False
def _rects_overlap(a, b, tol=OVERLAP_TOLERANCE) -> bool:
ax, ay, aw, ah = a
bx, by, bw, bh = b
return not (
ax + aw - tol <= bx or bx + bw - tol <= ax
or ay + ah - tol <= by or by + bh - tol <= ay
)
def _check_slide(slide, idx: int, issues: list):
slide_issues = []
shapes = list(slide.shapes)
# Pass 1: bounds + content bottom.
for shp in shapes:
name = shp.name or "?"
rect = _shape_rect(shp)
if rect is None:
continue
x, y, w, h = rect
if _is_exempt(name, EXEMPT_BOUNDS_PREFIXES):
continue
if x < -1 or y < -1 or x + w > W + 1 or y + h > H + 1:
slide_issues.append({
"kind": "bounds",
"name": name,
"message": (f"shape outside canvas: x={x:.0f} y={y:.0f} "
f"w={w:.0f} h={h:.0f} (canvas {W}x{H})"),
})
if y + h > H - BOTTOM_STOP + 1:
slide_issues.append({
"kind": "content",
"name": name,
"message": (f"content ends at y={y + h:.0f}px, lower than "
f"BOTTOM_STOP ({H - BOTTOM_STOP}px from top)"),
})
# Pass 2: overlap between text-bearing, non-exempt shapes.
texts = []
for shp in shapes:
name = shp.name or "?"
if _is_exempt(name, EXEMPT_OVERLAP_PREFIXES):
continue
rect = _shape_rect(shp)
if rect is None or not _has_text(shp):
continue
texts.append((name, rect))
for i in range(len(texts)):
for j in range(i + 1, len(texts)):
n1, r1 = texts[i]
n2, r2 = texts[j]
if _rects_overlap(r1, r2):
slide_issues.append({
"kind": "overlap",
"name": f"{n1} <-> {n2}",
"message": (f"text shapes overlap: {n1} {tuple(round(v) for v in r1)} "
f"vs {n2} {tuple(round(v) for v in r2)}"),
})
# Pass 3: tables fit canvas.
for shp in shapes:
if not shp.has_table:
continue
rect = _shape_rect(shp)
if rect is None:
continue
x, y, w, h = rect
if w <= 0 or h <= 0:
slide_issues.append({"kind": "table", "name": shp.name,
"message": "table has zero size"})
if x < -1 or y < -1 or x + w > W + 1 or y + h > H + 1:
slide_issues.append({"kind": "table", "name": shp.name,
"message": "table exceeds canvas bounds"})
for issue in slide_issues:
issue["slide"] = idx + 1
issues.append(issue)
def _render(pptx_path: Path, out_dir: Path) -> list:
"""Render deck to JPEGs via LibreOffice + pdftoppm. Returns render errors."""
errors = []
soffice = shutil.which("soffice") or shutil.which("libreoffice")
pdftoppm = shutil.which("pdftoppm")
if not soffice or not pdftoppm:
errors.append("render skipped: soffice or pdftoppm not found in PATH")
return errors
with tempfile.TemporaryDirectory() as tmp:
tmp = Path(tmp)
try:
subprocess.run(
[soffice, "--headless", "--convert-to", "pdf",
"--outdir", str(tmp), str(pptx_path)],
check=True, capture_output=True, timeout=120,
)
except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as e:
errors.append(f"soffice conversion failed: {e}")
return errors
pdf = tmp / (pptx_path.stem + ".pdf")
if not pdf.exists():
errors.append("soffice produced no PDF")
return errors
out_dir.mkdir(parents=True, exist_ok=True)
try:
subprocess.run(
[pdftoppm, "-jpeg", "-r", "100", str(pdf), str(out_dir / "slide")],
check=True, capture_output=True, timeout=120,
)
except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as e:
errors.append(f"pdftoppm failed: {e}")
return errors
n = len(list(out_dir.glob("slide-*.jpg")))
if n == 0:
errors.append("render produced no JPEGs")
return errors
def main() -> int:
ap = argparse.ArgumentParser(description="Geometric QA for presentation-maker .pptx")
ap.add_argument("pptx", help="path to .pptx deck")
ap.add_argument("--render", action="store_true",
help="render slides to JPEGs (LibreOffice + pdftoppm)")
ap.add_argument("--out", default=None, help="dir for render output (default: qa/ next to deck)")
ap.add_argument("--json", default=None, help="write machine-readable report to this path")
args = ap.parse_args()
pptx_path = Path(args.pptx)
if not pptx_path.exists():
print(f"error: {pptx_path} not found", file=sys.stderr)
return 2
try:
prs = Presentation(str(pptx_path))
except Exception as e:
print(f"error: cannot open deck: {e}", file=sys.stderr)
return 2
issues: list = []
for idx, slide in enumerate(prs.slides):
_check_slide(slide, idx, issues)
errors = [i for i in issues if i["kind"] in ("bounds", "overlap", "table")]
warnings = [i for i in issues if i["kind"] == "content"]
report = {
"deck": str(pptx_path),
"slides": len(prs.slides._sldIdLst), # count of slides
"issues": issues,
"counts": {"errors": len(errors), "warnings": len(warnings), "total": len(issues)},
"verdict": "PASS" if not errors else "FAIL",
}
if args.render:
out_dir = Path(args.out) if args.out else pptx_path.parent / "qa"
report["render"] = _render(pptx_path, out_dir)
if args.json:
Path(args.json).write_text(json.dumps(report, ensure_ascii=False, indent=2),
encoding="utf-8")
print(f"{report['verdict']} {len(prs.slides)} slides, "
f"{len(errors)} errors, {len(warnings)} warnings")
for issue in issues:
loc = f"[slide {issue['slide']}]"
print(f" {issue['kind']:9s} {loc} {issue['name']}: {issue['message']}")
if "render" in report:
for line in report["render"]:
print(f" render: {line}")
return 0 if not errors else 1
if __name__ == "__main__":
sys.exit(main())
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |