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

tests/test_quality_contracts.py

View on GitHub
import sys
import unittest
from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
RUNTIME_DIR = ROOT / "cli/image2ppt/runtime"
sys.path.insert(0, str(RUNTIME_DIR))

from validate_pptx import ALLOWED_SOURCE_TYPES, quality_contract_violations, required_texts_from_manifest  # noqa: E402
from build_pptx_from_manifest import shape_xml  # noqa: E402


def base_manifest():
    return {
        "visual_inventory": [],
        "background_strategy": {
            "mode": "native-or-script",
            "comparison_note": "background checked against source",
        },
        "quality_checks": {
            "font_size_calibrated": True,
            "visual_inventory_matched": True,
            "background_strategy_checked": True,
            "shape_corner_geometry_checked": True,
        },
        "shapes": [],
    }


def v2_manifest():
    manifest = base_manifest()
    manifest["schema_version"] = 2
    manifest["quality_evidence"] = {
        key: {"observation": f"Verified {key} against the source image and current render."}
        for key in manifest["quality_checks"]
    }
    return manifest


class QualityContractTest(unittest.TestCase):
    def test_quality_checks_are_required(self):
        violations = quality_contract_violations({})
        fields = {item["field"] for item in violations}
        self.assertIn("visual_inventory", fields)
        self.assertIn("background_strategy", fields)
        self.assertIn("quality_checks", fields)

    def test_round_rect_requires_source_evidence(self):
        manifest = base_manifest()
        manifest["shapes"] = [{"type": "roundRect", "box_px": [0, 0, 100, 40]}]
        violations = quality_contract_violations(manifest)
        self.assertEqual(["shapes[0]"], [item["field"] for item in violations])

    def test_rect_does_not_need_corner_evidence(self):
        manifest = base_manifest()
        manifest["shapes"] = [{"type": "rect", "box_px": [0, 0, 100, 40]}]
        self.assertEqual([], quality_contract_violations(manifest))

    def test_source_derived_assets_are_not_allowed(self):
        self.assertNotIn("source-derived-rasterization", ALLOWED_SOURCE_TYPES)

    def test_latex_rendered_formula_assets_are_allowed(self):
        self.assertIn("latex-rendered-formula", ALLOWED_SOURCE_TYPES)

    def test_asset_sheet_separated_assets_are_allowed(self):
        self.assertIn("asset-sheet-separated", ALLOWED_SOURCE_TYPES)

    def test_foreground_native_approximation_is_contract_violation(self):
        manifest = base_manifest()
        manifest["visual_inventory"] = [
            {
                "id": "bottom_icon",
                "description": "semantic icon in the bottom flow",
                "decision": "native approximation with text symbol",
            }
        ]
        violations = quality_contract_violations(manifest)
        reasons = " ".join(item["reason"] for item in violations)
        self.assertIn("foreground visual decisions", reasons)

    def test_foreground_direct_crop_provenance_is_contract_violation(self):
        manifest = base_manifest()
        manifest["visual_inventory"] = [
            {
                "id": "photo_panel",
                "description": "foreground photo panel",
                "decision": "source-faithful asset-sheet separation",
                "path": "assets/source_crops/photo.png",
            }
        ]
        manifest["asset_provenance"] = [
            {
                "path": "assets/source_crops/photo.png",
                "source_type": "user-provided",
                "source": "source.png",
                "provenance_note": "cropped from source foreground photo",
            }
        ]
        violations = quality_contract_violations(manifest)
        fields = [item["field"] for item in violations]
        self.assertIn("visual_inventory[0]", fields)
        self.assertIn("asset_provenance[0]", fields)

    def test_foreground_asset_sheet_decision_passes_contract(self):
        manifest = base_manifest()
        manifest["visual_inventory"] = [
            {
                "id": "photo_panel",
                "description": "foreground photo panel",
                "decision": "source-faithful asset-sheet separation through image2ppt image edit",
                "path": "assets/photo_panel.png",
            }
        ]
        manifest["asset_provenance"] = [
            {
                "path": "assets/photo_panel.png",
                "source_type": "asset-sheet-separated",
                "source": "assets/photo_sheet.png",
                "provenance_note": "split from source-faithful asset sheet generated with image2ppt image edit",
            }
        ]
        self.assertEqual([], quality_contract_violations(manifest))

    def test_structured_native_item_avoids_benchmark_substring_false_positive(self):
        manifest = v2_manifest()
        manifest["visual_inventory"] = [
            {
                "id": "benchmark_panel",
                "kind": "native-structure",
                "representation": "native",
                "description": "benchmark result panel",
            }
        ]
        self.assertEqual([], quality_contract_violations(manifest))

    def test_structured_foreground_item_cannot_hide_behind_background_word(self):
        manifest = v2_manifest()
        manifest["visual_inventory"] = [
            {
                "id": "icon",
                "kind": "foreground-asset",
                "representation": "native",
                "description": "foreground icon over background",
            }
        ]
        reasons = " ".join(item["reason"] for item in quality_contract_violations(manifest))
        self.assertIn("foreground-asset requires", reasons)

    def test_unrendered_formula_is_a_hard_failure_without_user_approval(self):
        manifest = v2_manifest()
        manifest["formula_inventory"] = [
            {"id": "f1", "status": "failed", "tex_source": "assets/f1.tex"}
        ]
        reasons = " ".join(item["reason"] for item in quality_contract_violations(manifest))
        self.assertIn("hard failure", reasons)

    def test_formula_visual_requires_formula_inventory(self):
        manifest = v2_manifest()
        manifest["visual_inventory"] = [
            {
                "id": "f1",
                "kind": "formula",
                "representation": "latex-rendered-formula",
                "path": "assets/f1.svg",
            }
        ]
        reasons = " ".join(item["reason"] for item in quality_contract_violations(manifest))
        self.assertIn("matching formula_inventory", reasons)

    def test_user_approved_formula_exception_requires_and_accepts_concrete_note(self):
        manifest = v2_manifest()
        manifest["formula_inventory"] = [
            {
                "id": "f1",
                "status": "failed",
                "tex_source": "assets/f1.tex",
                "user_approved_exception": True,
                "approval_note": "User explicitly approved delivery without this secondary formula.",
            }
        ]
        self.assertEqual([], quality_contract_violations(manifest))

    def test_v2_quality_booleans_require_specific_evidence(self):
        manifest = v2_manifest()
        manifest["quality_evidence"]["visual_inventory_matched"] = {"observation": "checked"}
        fields = [item["field"] for item in quality_contract_violations(manifest)]
        self.assertIn("quality_evidence.visual_inventory_matched.observation", fields)

    def test_round_rect_writes_ooxml_adjustment(self):
        xml = shape_xml(
            2,
            {
                "type": "roundRect",
                "box_px": [0, 0, 400, 200],
                "left": 0,
                "top": 0,
                "width": 4,
                "height": 2,
                "source_corner_radius_px": 10,
                "fill": "none",
                "stroke": "#000000",
            },
        )
        self.assertIn('prst="roundRect"', xml)
        self.assertIn('name="adj"', xml)
        self.assertIn('fmla="val 5000"', xml)

    def test_structured_text_inventory_flattens_to_required_strings(self):
        required = required_texts_from_manifest(
            {
                "required_text": ["市场概览"],
                "text_inventory": [
                    {"id": "metric", "text": "4280 万", "decision": "native-text"},
                    {"id": "insights", "required_text": ["扩张", "续约"]},
                    {"id": "note", "description": "not an exact text requirement"},
                ],
            }
        )
        self.assertEqual(["市场概览", "4280 万", "扩张", "续约"], required)

    def test_invalid_text_alignment_is_a_contract_violation(self):
        manifest = base_manifest()
        manifest["text_boxes"] = [
            {
                "text": "1",
                "box_px": [0, 0, 40, 40],
                "align": "sideways",
                "valign": "floating",
            }
        ]

        violations = quality_contract_violations(manifest)
        fields = {item["field"] for item in violations}

        self.assertIn("text_boxes[0].align", fields)
        self.assertIn("text_boxes[0].valign", fields)


if __name__ == "__main__":
    unittest.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