Skip to content

Yuan1z0825/nature-skills / skills/nature-image2ppt

nature-image2ppt

Flagged

Reconstruct slide images, screenshots, scanned PDFs, or image-only PPTX files as object-level editable PowerPoint. Use for 图片转可编辑PPT、截图还原PPT and diagram reconstruction; not authoring a new deck from research notes.

FileKindSize
.gitignoreother573 B
LICENSEother1.1 KB
README.mdmarkdown4.0 KB
README_EN.mdmarkdown4.3 KB
SKILL.mdskill md9.8 KB
agents/openai.yamlconfig272 B
cli/image2ppt/__init__.pyscript22 B
cli/image2ppt/cli.pyscript698 B
cli/image2ppt/runtime/__init__.pyscript69 B
cli/image2ppt/runtime/_input_normalization.pyscript15.9 KB
cli/image2ppt/runtime/_page_artifacts.pyscript4.5 KB
cli/image2ppt/runtime/build_pptx_from_manifest.pyscript54.0 KB
cli/image2ppt/runtime/configure_image_backend.pyscript5.8 KB
cli/image2ppt/runtime/deck_run_state.pyscript5.6 KB
cli/image2ppt/runtime/deck_text_hints.pyscript6.8 KB
cli/image2ppt/runtime/finalize_deck_run.pyscript3.1 KB
cli/image2ppt/runtime/formula_renderer.pyscript9.6 KB
cli/image2ppt/runtime/image_gen.pyscript37.1 KB
cli/image2ppt/runtime/main.pyscript39.7 KB
cli/image2ppt/runtime/make_page_contact_sheet.pyscript1.1 KB
cli/image2ppt/runtime/paddle_text_hints.pyscript10.7 KB
cli/image2ppt/runtime/page_job_status.pyscript2.1 KB
cli/image2ppt/runtime/page_text_metrics.pyscript11.6 KB
cli/image2ppt/runtime/prepare_deck_run.pyscript7.3 KB
cli/image2ppt/runtime/process_asset_sheet.pyscript6.0 KB
cli/image2ppt/runtime/record_imagegen_result.pyscript5.9 KB
cli/image2ppt/runtime/record_page_dispatch.pyscript2.8 KB
cli/image2ppt/runtime/record_page_result.pyscript4.6 KB
cli/image2ppt/runtime/remove_chroma_key.pyscript13.5 KB
cli/image2ppt/runtime/reset_page_job.pyscript2.6 KB
cli/image2ppt/runtime/runtime_env.pyscript18.8 KB
cli/image2ppt/runtime/split_alpha_components.pyscript9.2 KB
cli/image2ppt/runtime/text_hints.pyscript14.0 KB
cli/image2ppt/runtime/validate_pptx.pyscript38.7 KB
cli/pyproject.tomlmanifest570 B
config.example.yamlconfig1.0 KB
manifest.yamlconfig480 B
prompts/page-worker-base.mdmarkdown7.4 KB
prompts/page-worker.mdmarkdown5.1 KB
references/assets-provenance-contract.mdmarkdown2.9 KB
references/cli-helper.mdmarkdown17.8 KB
references/manifest-arrow-extension.mdmarkdown2.5 KB
references/manifest-schema.mdmarkdown19.9 KB
references/object-routing.mdmarkdown3.4 KB
references/ocr-text-hints-contract.mdmarkdown3.0 KB
references/page-decision-tree.mdmarkdown21.7 KB
references/qa-contract.mdmarkdown5.4 KB
references/region-decomposition.mdmarkdown6.5 KB
references/runtime-dependencies.mdmarkdown2.5 KB
references/workflow.mdmarkdown6.7 KB
requirements.txtmanifest176 B
schemas/page-manifest-v2.schema.jsonconfig2.9 KB
scripts/build_page_worker_prompt.pyscript4.1 KB
scripts/inspect_arrow_atomicity.pyscript7.3 KB
scripts/inspect_region_decomposition.pyscript18.1 KB
scripts/postprocess_manifest_arrows.pyscript18.4 KB
scripts/render_image2ppt_qa.pyscript11.1 KB
scripts/run_final_image2ppt_qa.pyscript9.0 KB
scripts/run_image2ppt_qa.pyscript9.5 KB
scripts/runtime_paths.pyscript4.0 KB
scripts/visual_review_evidence.pyscript5.4 KB
tests/support.pyscript6.4 KB
tests/test_console_portability.pyscript1021 B
tests/test_deck_slide_size.pyscript1.1 KB
tests/test_dispatch_concurrency.pyscript2.9 KB
tests/test_formula_renderer.pyscript4.3 KB
tests/test_independence.pyscript2.2 KB
tests/test_input_normalization_alpha.pyscript2.3 KB
tests/test_input_normalization_opc_targets.pyscript1.9 KB
tests/test_isolated_lifecycle.pyscript9.5 KB
tests/test_manifest_arrows.pyscript8.6 KB
tests/test_migration_parity.pyscript3.2 KB
tests/test_multi_agent_backend.pyscript80.8 KB
tests/test_ocr_http.pyscript16.7 KB
tests/test_paddle_result_url_safety.pyscript3.2 KB
tests/test_page_hints.pyscript10.4 KB
tests/test_path_confinement.pyscript7.5 KB
tests/test_pdf_backend.pyscript4.3 KB
tests/test_project_metadata.pyscript4.7 KB
tests/test_quality_contracts.pyscript9.1 KB
tests/test_region_decomposition.pyscript6.2 KB
tests/test_render_guard.pyscript2.4 KB
tests/test_runtime_config.pyscript2.6 KB
tests/test_runtime_paths.pyscript2.2 KB
tests/test_script_inventory.pyscript2.1 KB
tests/test_slide_layout.pyscript9.3 KB
tests/test_state_e2e.pyscript7.8 KB
tests/test_structure_reconstruction.pyscript12.5 KB
tests/test_thin_profile.pyscript4.0 KB
tests/test_visual_review_evidence.pyscript2.3 KB
tests/test_visual_review_runtime.pyscript2.9 KB

scripts/run_image2ppt_qa.py

View on GitHub
#!/usr/bin/env python3
"""Run Image2PPT's supplemental page gate on standard image2ppt artifacts."""

from __future__ import annotations

import argparse
import json
import subprocess
import sys

if hasattr(sys.stdout, "reconfigure"):
    sys.stdout.reconfigure(encoding="utf-8")
if hasattr(sys.stderr, "reconfigure"):
    sys.stderr.reconfigure(encoding="utf-8")
from pathlib import Path
from typing import Any

from runtime_paths import SCRIPT_DIR, image2ppt_command, resolve_inside
from visual_review_evidence import expected_page, validate_evidence, write_template


def read_json(path: Path) -> dict[str, Any]:
    try:
        return json.loads(path.read_text(encoding="utf-8")) if path.is_file() else {}
    except (OSError, ValueError, TypeError):
        return {}


def write_json(path: Path, payload: dict[str, Any]) -> None:
    path.parent.mkdir(parents=True, exist_ok=True)
    path.write_text(json.dumps(payload, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")


def run(command: list[str]) -> dict[str, Any]:
    result = subprocess.run(command, text=True, capture_output=True, check=False)
    return {
        "command": command,
        "returncode": result.returncode,
        "stdout": result.stdout[-8000:],
        "stderr": result.stderr[-8000:],
    }


def main() -> int:
    parser = argparse.ArgumentParser(
        description="Inspect regions, postprocess arrows, rerun image2ppt validation, inspect atomicity, and render one page"
    )
    parser.add_argument("page_dir", type=Path)
    parser.add_argument("--visual-review-status", choices=["needs_review", "reviewed", "failed"], default="needs_review")
    parser.add_argument("--visual-review-notes", default="")
    parser.add_argument("--visual-review-evidence", type=Path)
    parser.add_argument("--existing-rendered", type=Path)
    parser.add_argument("--render-timeout", type=int, default=120)
    args = parser.parse_args()

    page_dir = args.page_dir.expanduser().resolve()
    manifest = page_dir / "manifest.json"
    pptx = page_dir / "page.pptx"
    source = page_dir / "source.png"
    paths = {
        "postprocess": page_dir / "arrow_postprocess_report.json",
        "regions": page_dir / "region_decomposition_report.json",
        "source_validation": page_dir / "validation.json",
        "inspection": page_dir / "arrow_inspection_report.json",
        "render": page_dir / "render_report.json",
        "profile": page_dir / "image2ppt_qa.json",
        "review_template": page_dir / "visual-review-evidence.template.json",
    }
    errors: list[str] = []
    checks: dict[str, Any] = {}
    expected_review_pages: list[dict[str, Any]] = []
    review_evidence: dict[str, Any] = {}
    review_evidence_path: Path | None = None
    for path, label in ((manifest, "manifest.json"), (pptx, "page.pptx"), (source, "source.png")):
        if not path.is_file():
            errors.append(f"missing standard image2ppt artifact: {label}")

    if not errors:
        command = [
            sys.executable,
            str(SCRIPT_DIR / "inspect_region_decomposition.py"),
            "--manifest",
            str(manifest),
            "--out",
            str(paths["regions"]),
        ]
        checks["region_decomposition_command"] = run(command)
        checks["region_decomposition"] = read_json(paths["regions"])
        if (
            checks["region_decomposition_command"]["returncode"] != 0
            or checks["region_decomposition"].get("passed") is not True
        ):
            errors.append("semantic-region or compound-diagram inspection failed")

    if not errors:
        command = [
            sys.executable,
            str(SCRIPT_DIR / "postprocess_manifest_arrows.py"),
            str(pptx),
            "--manifest",
            str(manifest),
            "--report",
            str(paths["postprocess"]),
        ]
        checks["arrow_postprocess_command"] = run(command)
        checks["arrow_postprocess"] = read_json(paths["postprocess"])
        if checks["arrow_postprocess_command"]["returncode"] != 0 or checks["arrow_postprocess"].get("passed") is not True:
            errors.append("manifest arrow postprocessing failed")

    if not errors:
        command = [
            *image2ppt_command(),
            "page",
            "validate",
            str(page_dir),
            "--report",
            "validation.json",
        ]
        checks["image2ppt_validation_command"] = run(command)
        checks["image2ppt_validation"] = read_json(paths["source_validation"])
        if checks["image2ppt_validation_command"]["returncode"] != 0 or checks["image2ppt_validation"].get("passed") is not True:
            errors.append("local image2ppt page validation failed after arrow postprocessing")

    if not errors:
        command = [
            sys.executable,
            str(SCRIPT_DIR / "inspect_arrow_atomicity.py"),
            str(pptx),
            "--manifest",
            str(manifest),
            "--out",
            str(paths["inspection"]),
        ]
        checks["arrow_inspection_command"] = run(command)
        checks["arrow_inspection"] = read_json(paths["inspection"])
        if checks["arrow_inspection_command"]["returncode"] != 0 or checks["arrow_inspection"].get("passed") is not True:
            errors.append("one-arrow-one-object inspection failed")

    if not errors:
        command = [
            sys.executable,
            str(SCRIPT_DIR / "render_image2ppt_qa.py"),
            str(pptx),
            "--out-dir",
            str(page_dir / "render"),
            "--report",
            str(paths["render"]),
            "--source",
            str(source),
            "--timeout",
            str(args.render_timeout),
        ]
        if args.existing_rendered:
            try:
                existing_rendered = resolve_inside(page_dir, args.existing_rendered)
            except ValueError as exc:
                raise SystemExit(
                    f"existing render must stay inside page directory: {args.existing_rendered}"
                ) from exc
            command.extend(["--existing-rendered", str(existing_rendered)])
        checks["render_command"] = run(command)
        checks["render"] = read_json(paths["render"])
        if checks["render_command"]["returncode"] != 0 or checks["render"].get("status") != "rendered":
            errors.append("PowerPoint/LibreOffice rendered QA failed")
        else:
            rendered = page_dir / "render" / "rendered.png"
            expected_review_pages = [
                expected_page(
                    page_id=page_dir.name,
                    source=source,
                    rendered=rendered,
                    manifest=read_json(manifest),
                )
            ]
            write_template(paths["review_template"], expected_review_pages)

    if args.visual_review_status == "reviewed":
        try:
            review_evidence_path = resolve_inside(
                page_dir, args.visual_review_evidence or "visual-review-evidence.json"
            )
        except ValueError as exc:
            errors.append(str(exc))
        if review_evidence_path and expected_review_pages:
            review_evidence, evidence_errors = validate_evidence(
                review_evidence_path, expected_review_pages
            )
            errors.extend(evidence_errors)
        elif not expected_review_pages:
            errors.append("reviewed visual QA requires a successful current render")
    if args.visual_review_status == "failed":
        errors.append("source-versus-render comparison was marked failed")
    passed = not errors and args.visual_review_status == "reviewed"
    report = {
        "schema_version": "image2ppt-supplemental-page-qa-v1",
        "passed": passed,
        "page_dir": str(page_dir),
        "state_owner": "page_jobs.json",
        "manifest": str(manifest),
        "pptx": str(pptx),
        "visual_review": {
            "status": args.visual_review_status,
            "notes": args.visual_review_notes,
            "source": str(source),
            "rendered": str(page_dir / "render" / "rendered.png"),
            "evidence": str(review_evidence_path) if review_evidence_path else None,
            "evidence_template": str(paths["review_template"]),
            "evidence_payload": review_evidence,
        },
        "checks": checks,
        "errors": errors,
    }
    write_json(paths["profile"], report)

    # Keep the local validation document authoritative while adding the
    # supplemental gate that image2ppt run record reads through top-level passed.
    validation = read_json(paths["source_validation"])
    if not validation:
        validation = {"passed": False}
    validation["image2ppt_profile"] = {
        "passed": passed,
        "report": paths["profile"].name,
        "arrow_postprocess": paths["postprocess"].name,
        "arrow_inspection": paths["inspection"].name,
        "region_decomposition": paths["regions"].name,
        "render_report": paths["render"].name,
        "visual_review_status": args.visual_review_status,
        "visual_review_evidence": (
            str(review_evidence_path.relative_to(page_dir)) if review_evidence_path else None
        ),
        "errors": errors,
    }
    validation["passed"] = bool(validation.get("passed") is True and passed)
    write_json(paths["source_validation"], validation)
    # stdout may use a legacy code page on Windows CI. JSON escapes preserve
    # Unicode content while keeping the command-line transport ASCII-safe.
    print(json.dumps(report, ensure_ascii=True, indent=2))
    return 0 if passed else 2


if __name__ == "__main__":
    raise SystemExit(main())
canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall