Skip to content

notque/vexjoy-agent / skills/game/game-dev

game-dev

Flagged

Game development: design, asset pipelines, Phaser, Unity CLI and builds, vanilla JS frontend, GM mode, match booking.

FileKindSize
SKILL.mdskill md14.7 KB
references/anchor-alignment.mdmarkdown16.0 KB
references/animate-scaffolds.mdmarkdown2.0 KB
references/arcade-physics.mdmarkdown7.4 KB
references/artifacts-and-prototyping.mdmarkdown1.5 KB
references/asset-sources.mdmarkdown7.9 KB
references/audit-and-red-team.mdmarkdown795 B
references/autonomous-improvement.mdmarkdown10.3 KB
references/backend-chain.mdmarkdown10.4 KB
references/bg-removal-local.mdmarkdown22.7 KB
references/build-scaffolds.mdmarkdown2.0 KB
references/capabilities/01-design-red-team-audit.mdmarkdown3.9 KB
references/capabilities/02-emotional-canvas-moodboard.mdmarkdown3.7 KB
references/capabilities/03-game-design-attribution-audit.mdmarkdown3.6 KB
references/capabilities/04-game-design-bartle-archetype-audit.mdmarkdown3.7 KB
references/capabilities/05-game-design-big-five-personality-audit.mdmarkdown3.6 KB
references/capabilities/06-game-design-brainstorm-methods.mdmarkdown3.9 KB
references/capabilities/07-game-design-core-loop-extractor.mdmarkdown3.7 KB
references/capabilities/08-game-design-craft-critique.mdmarkdown3.5 KB
references/capabilities/09-game-design-creative-unblocker.mdmarkdown3.5 KB
references/capabilities/10-game-design-design-pillars-extractor.mdmarkdown3.5 KB
references/capabilities/11-game-design-emotional-canvas.mdmarkdown3.6 KB
references/capabilities/12-game-design-failure-loop-audit.mdmarkdown3.8 KB
references/capabilities/13-game-design-fairness-frustration-audit.mdmarkdown3.6 KB
references/capabilities/14-game-design-fantasy-extractor.mdmarkdown3.6 KB
references/capabilities/15-game-design-feature-prioritization.mdmarkdown3.6 KB
references/capabilities/16-game-design-five-options.mdmarkdown3.5 KB
references/capabilities/17-game-design-flow-audit.mdmarkdown3.6 KB
references/capabilities/18-game-design-fogg-behavior-audit.mdmarkdown3.6 KB
references/capabilities/19-game-design-friction-journey-audit.mdmarkdown3.8 KB
references/capabilities/20-game-design-ftue-hero-journey-audit.mdmarkdown3.7 KB
references/capabilities/21-game-design-goal-density-and-immediacy-audit.mdmarkdown3.5 KB
references/capabilities/22-game-design-goal-framing.mdmarkdown3.5 KB
references/capabilities/23-game-design-granular-player-motivation-audit.mdmarkdown4.0 KB
references/capabilities/24-game-design-grow-design.mdmarkdown3.5 KB
references/capabilities/25-game-design-ideal-outcome-backcasting.mdmarkdown3.4 KB
references/capabilities/26-game-design-kpi-coverage-audit.mdmarkdown3.8 KB
references/capabilities/27-game-design-leaderboard-audit.mdmarkdown3.9 KB
references/capabilities/28-game-design-leaderboard-builder.mdmarkdown3.8 KB
references/capabilities/29-game-design-molyneux-lens.mdmarkdown3.5 KB
references/capabilities/30-game-design-multiplayer-feature-audit.mdmarkdown3.8 KB
references/capabilities/31-game-design-novelty-spectrum-audit.mdmarkdown3.6 KB
references/capabilities/32-game-design-one-page-design-doc.mdmarkdown3.8 KB
references/capabilities/33-game-design-one-thing-to-remove.mdmarkdown3.6 KB
references/capabilities/34-game-design-option-generation.mdmarkdown3.5 KB
references/capabilities/35-game-design-peak-end-audit.mdmarkdown3.6 KB
references/capabilities/36-game-design-perceived-randomness-audit.mdmarkdown3.7 KB
references/capabilities/37-game-design-pitch-deck-audit.mdmarkdown3.8 KB
references/capabilities/38-game-design-player-motivation-audit.mdmarkdown3.5 KB
references/capabilities/39-game-design-player-need-satisfaction-audit.mdmarkdown3.6 KB
references/capabilities/40-game-design-player-persona-extractor.mdmarkdown4.2 KB
references/capabilities/41-game-design-player-perspective-reframe.mdmarkdown3.7 KB
references/capabilities/42-game-design-player-segment-perception-audit.mdmarkdown3.6 KB
references/capabilities/43-game-design-player-values-mapper.mdmarkdown3.8 KB
references/capabilities/44-game-design-premium-pass-audit.mdmarkdown3.8 KB
references/capabilities/45-game-design-prosocial-session-chapters.mdmarkdown3.7 KB
references/capabilities/46-game-design-prototype-intent-audit.mdmarkdown3.7 KB
references/capabilities/47-game-design-prototyping-companion.mdmarkdown3.6 KB
references/capabilities/48-game-design-roadblock-reframing.mdmarkdown3.5 KB
references/capabilities/49-game-design-smart-goal-audit.mdmarkdown3.6 KB
references/capabilities/50-game-design-social-satisfaction-matrix.mdmarkdown3.7 KB
references/capabilities/51-game-design-systematizing-empathizing-audit.mdmarkdown3.6 KB
references/capabilities/52-game-design-thinking-fast-and-slow-audit.mdmarkdown3.6 KB
references/capabilities/53-game-design-transformative-reuse.mdmarkdown3.6 KB
references/capabilities/54-game-design-unknown-unknowns-prototyping.mdmarkdown3.6 KB
references/capabilities/55-game-design-zeigarnik-effect-audit.mdmarkdown3.6 KB
references/capabilities/56-game-dev-budget-estimator.mdmarkdown3.8 KB
references/capabilities/57-game-dev-first-steps.mdmarkdown3.6 KB
references/capabilities/58-game-dev-team-gap.mdmarkdown3.6 KB
references/capabilities/59-game-dev-time-estimator.mdmarkdown3.8 KB
references/capabilities/60-moodboard-generator.mdmarkdown4.0 KB
references/capabilities/61-software-team-conflict-patterns.mdmarkdown3.8 KB
references/capability-catalog.mdmarkdown18.4 KB
references/capability-map.mdmarkdown1.7 KB
references/capability-matrix.mdmarkdown12.5 KB
references/capacitor-ios.mdmarkdown7.3 KB
references/cognition-and-choice.mdmarkdown1.2 KB
references/cognitive-and-behavioral-lenses.mdmarkdown1.2 KB
references/combat-effects-upgrade.mdmarkdown13.3 KB
references/combat-effects-upgrade/css-3d-card-transforms.mdmarkdown10.1 KB
references/combat-effects-upgrade/css-particle-migration.mdmarkdown13.3 KB
references/combat-effects-upgrade/framer-motion-combat-juice.mdmarkdown11.9 KB
references/concept-and-loop.mdmarkdown1.5 KB
references/core-loop-and-pillars.mdmarkdown835 B
references/core-patterns.mdmarkdown8.2 KB
references/cpu-systems-harmony.mdmarkdown3.4 KB
references/creative-and-options.mdmarkdown2.0 KB
references/creative-direction.mdmarkdown1.3 KB
references/deploy.mdmarkdown5.3 KB
references/design-artifacts.mdmarkdown1.0 KB
references/emotion-and-presentation.mdmarkdown1.1 KB
references/error-catalog.mdmarkdown22.6 KB
references/fairness-and-failure.mdmarkdown1.2 KB
references/fairness-and-learning.mdmarkdown1.3 KB
references/fal-ai-image.mdmarkdown7.1 KB
references/frame-detection.mdmarkdown20.0 KB
references/full-diagnostic.mdmarkdown4.2 KB
references/game-asset-generator.mdmarkdown9.5 KB
references/game-audio.mdmarkdown7.5 KB
references/game-feel-patterns.mdmarkdown12.2 KB
references/game-pipeline.mdmarkdown11.5 KB
references/game-qa.mdmarkdown6.7 KB
references/game-sprite-pipeline.mdmarkdown33.4 KB
references/gm-brilliant-implementation.mdmarkdown13.4 KB
references/grid-shapes.mdmarkdown8.0 KB
references/meshyai.mdmarkdown7.3 KB
references/motion-pipeline.mdmarkdown7.6 KB
references/output-formats.mdmarkdown9.4 KB
references/pacing-and-return.mdmarkdown1.6 KB
references/performance.mdmarkdown7.8 KB
references/phaser-gamedev.mdmarkdown7.5 KB
references/pipeline-spec.jsonconfig23.5 KB
references/pixel-art-sprites.mdmarkdown8.7 KB
references/pixijs-combat-renderer.mdmarkdown12.1 KB
references/pixijs-combat-renderer/combat-visual-effects.mdmarkdown7.8 KB
references/pixijs-combat-renderer/pixi-2d-lighting.mdmarkdown6.6 KB
references/pixijs-combat-renderer/pixi-particle-systems.mdmarkdown9.2 KB
references/pixijs-combat-renderer/pixi-performance.mdmarkdown4.8 KB
references/pixijs-combat-renderer/pixi-post-processing.mdmarkdown6.3 KB
references/pixijs-combat-renderer/pixi-react-integration.mdmarkdown5.2 KB
references/planning-and-communication.mdmarkdown1.6 KB
references/planning-and-production.mdmarkdown1.8 KB
references/player-and-social.mdmarkdown2.3 KB
references/polish-scaffolds.mdmarkdown1.9 KB
references/progression-and-economy.mdmarkdown1.0 KB
references/promo-video.mdmarkdown6.6 KB
references/prompt-rules.mdmarkdown15.2 KB
references/quality-gates.mdmarkdown6.4 KB
references/rive-skeletal-animator.mdmarkdown7.6 KB
references/rive-skeletal-animator/rive-animation-library.mdmarkdown8.1 KB
references/rive-skeletal-animator/rive-async-patterns.mdmarkdown5.6 KB
references/rive-skeletal-animator/rive-character-pipeline.mdmarkdown5.6 KB
references/rive-skeletal-animator/rive-performance.mdmarkdown5.4 KB
references/rive-skeletal-animator/rive-react-setup.mdmarkdown9.9 KB
references/rive-skeletal-animator/rive-vs-spine-decision.mdmarkdown6.0 KB
references/road-to-aew-integration.mdmarkdown7.8 KB
references/social-and-competitive-design.mdmarkdown1.1 KB
references/social-and-competitive.mdmarkdown1.5 KB
references/spritesheets.mdmarkdown6.2 KB
references/stage-contracts.mdmarkdown11.1 KB
references/style-presets.mdmarkdown5.1 KB
references/subagent-delegation.mdmarkdown2.2 KB
references/tilemaps-and-physics.mdmarkdown13.6 KB
references/tilemaps.mdmarkdown7.0 KB
references/unity-batchmode-builds.mdmarkdown9.2 KB
references/unity-cli.mdmarkdown10.9 KB
references/unity-licensing.mdmarkdown5.0 KB
references/vfx-containment.mdmarkdown3.1 KB
references/workflow-dag.mdmarkdown4.1 KB
references/worldlabs.mdmarkdown7.9 KB
references/wrestler-archetypes.mdmarkdown7.2 KB
scripts/deterministic_idle.pyscript7.8 KB
scripts/fal_queue_image_run.pyscript9.4 KB
scripts/imgdiff.pyscript5.0 KB
scripts/meshy-generate.mjsscript11.1 KB
scripts/optimize-glb.mjsscript3.8 KB
scripts/portrait_pipeline.pyscript31.2 KB
scripts/qa_artifacts.pyscript14.4 KB
scripts/road_to_aew_integration.pyscript6.6 KB
scripts/row_job_status.pyscript8.6 KB
scripts/sprite_anchor.pyscript30.1 KB
scripts/sprite_assemble.pyscript16.0 KB
scripts/sprite_bg.pyscript28.5 KB
scripts/sprite_canvas.pyscript11.9 KB
scripts/sprite_generate.pyscript13.9 KB
scripts/sprite_pipeline.pyscript54.9 KB
scripts/sprite_process.pyscript13.5 KB
scripts/sprite_prompt.pyscript41.8 KB
scripts/sprite_slicing.pyscript38.7 KB
scripts/sprite_verify.pyscript58.5 KB
scripts/test_content_aware_extraction.pyscript13.4 KB
scripts/test_no_status_laundering.pyscript6.9 KB
scripts/test_phases_4_5_7_8.pyscript16.4 KB
scripts/test_pipeline_glue.pyscript20.9 KB
scripts/test_pipeline_patterns.pyscript10.9 KB
scripts/test_rc3_frames_distinct_threshold.pyscript14.2 KB
scripts/test_rc4_mass_centroid_default.pyscript8.3 KB
scripts/test_rc5_despill_pre_upscale.pyscript7.9 KB
scripts/test_slice_grid_cells.pyscript6.4 KB
scripts/test_slicer_strict_pitch_default.pyscript11.6 KB
scripts/test_verifier_cell_parity.pyscript9.0 KB
scripts/test_verify_gates.pyscript23.2 KB
scripts/tests/test_fal_queue_image_run.pyscript908 B
scripts/video_extract_frames.pyscript4.3 KB
scripts/video_process_frames.pyscript7.6 KB
scripts/video_select_frames.pyscript6.4 KB
scripts/with_server.pyscript5.8 KB

scripts/test_pipeline_glue.py

View on GitHub
#!/usr/bin/env python3
"""Smoke tests for pipeline-glue bugs surfaced on PR #529.

These tests exercise glue code that the in-skill verifier gates (which all
operate on already-rendered images) cannot reach: argv forwarding through
orchestration scripts, mode dispatch in remove-bg, the count-mismatch guard
in extract-frames cell-aware mode, and the aspect-ratio choice in the
portrait-loop generate phase.

Each test is a thin, fast, deterministic check that a specific Codex finding
no longer reproduces. Run:

    python3 skills/game/game-dev/scripts/test_pipeline_glue.py
"""

from __future__ import annotations

import json
import sys
import tempfile
from pathlib import Path
from unittest import mock

import numpy as np
import pytest
from PIL import Image

SCRIPT_DIR = Path(__file__).resolve().parent
sys.path.insert(0, str(SCRIPT_DIR))

import portrait_pipeline
import sprite_pipeline
import sprite_process


# ---------------------------------------------------------------------------
# Bug #4: --style-string must be forwarded through spritesheet orchestration
# ---------------------------------------------------------------------------
def test_sprite_pipeline_forwards_style_string_to_build_character() -> None:
    """build-character (Phase A) call must include --style-string when set."""
    captured: list[list[str]] = []

    def fake_prompt_main(argv: list[str]) -> int:
        captured.append(list(argv))
        # sprite_prompt outputs land in --output paths; create empty stubs so
        # later phases that cat/read them don't blow up before we early-exit.
        for i, tok in enumerate(argv):
            if tok == "--output" and i + 1 < len(argv):
                Path(argv[i + 1]).parent.mkdir(parents=True, exist_ok=True)
                Path(argv[i + 1]).write_text("stub prompt", encoding="utf-8")
        return 0

    with tempfile.TemporaryDirectory() as td:
        argv = [
            "--prompt",
            "wrestler walk cycle",
            "--style",
            "custom",
            "--style-string",
            "neon-noir oil painting",
            "--grid",
            "4x1",
            "--cell-size",
            "256",
            "--output-dir",
            td,
            "--dry-run",
        ]
        with mock.patch.object(sprite_pipeline.sprite_prompt, "main", side_effect=fake_prompt_main):
            sprite_pipeline.main(argv)

    # First captured call is the build-character (Phase A). Walk forward to find it.
    char_calls = [c for c in captured if c and c[0] == "build-character"]
    assert char_calls, f"expected at least one build-character call, got {captured}"
    char_argv = char_calls[0]
    assert "--style-string" in char_argv, f"--style-string missing from build-character: {char_argv}"
    idx = char_argv.index("--style-string")
    assert char_argv[idx + 1] == "neon-noir oil painting", char_argv

    sheet_calls = [c for c in captured if c and c[0] == "build-spritesheet"]
    assert sheet_calls, f"expected build-spritesheet call, got {captured}"
    sheet_argv = sheet_calls[0]
    assert "--style-string" in sheet_argv, f"--style-string missing from build-spritesheet: {sheet_argv}"
    idx = sheet_argv.index("--style-string")
    assert sheet_argv[idx + 1] == "neon-noir oil painting", sheet_argv


# ---------------------------------------------------------------------------
# Bug #5: --style-string must be forwarded through portrait-loop orchestration
# ---------------------------------------------------------------------------
def test_portrait_pipeline_forwards_style_string_to_build_portrait_loop() -> None:
    """portrait-loop's build-portrait-loop call must include --style-string."""
    captured: list[list[str]] = []

    def fake_prompt_main(argv: list[str]) -> int:
        captured.append(list(argv))
        for i, tok in enumerate(argv):
            if tok in ("--output", "--metadata-out") and i + 1 < len(argv):
                Path(argv[i + 1]).parent.mkdir(parents=True, exist_ok=True)
                Path(argv[i + 1]).write_text("stub", encoding="utf-8")
        return 0

    with tempfile.TemporaryDirectory() as td:
        argv = [
            "--mode",
            "portrait-loop",
            "--description",
            "test character",
            "--display-name",
            "Test Loop",
            "--style",
            "custom",
            "--style-string",
            "moody charcoal sketch",
            "--output-dir",
            td,
            "--dry-run",
        ]
        with mock.patch.object(portrait_pipeline.sprite_prompt, "main", side_effect=fake_prompt_main):
            # Don't care if downstream phases fail; we only need the prompt phase to fire.
            try:
                portrait_pipeline.main(argv)
            except SystemExit:
                pass

    loop_calls = [c for c in captured if c and c[0] == "build-portrait-loop"]
    assert loop_calls, f"expected build-portrait-loop call, got {captured}"
    loop_argv = loop_calls[0]
    assert "--style-string" in loop_argv, f"--style-string missing from build-portrait-loop: {loop_argv}"
    idx = loop_argv.index("--style-string")
    assert loop_argv[idx + 1] == "moody charcoal sketch", loop_argv


# ---------------------------------------------------------------------------
# Bug #3: --bg-mode gray-tolerance must reach remove_bg_gray_tolerance
# ---------------------------------------------------------------------------
def test_bg_mode_gray_tolerance_routes_to_gray_tolerance(tmp_path: Path) -> None:
    """A solid #3a3a3a image with --bg-mode gray-tolerance must zero its alpha."""
    # 64x64 of pure #3a3a3a (the default GRAY_BG) on opaque alpha.
    src = tmp_path / "gray_bg.png"
    img = Image.new("RGBA", (64, 64), (0x3A, 0x3A, 0x3A, 255))
    img.save(src)
    dst = tmp_path / "gray_bg_nobg.png"

    rc = sprite_process.main(
        [
            "remove-bg",
            str(src),
            "--output",
            str(dst),
            "--bg-mode",
            "gray-tolerance",
        ]
    )
    assert rc == 0, f"remove-bg returned {rc}"
    out = np.array(Image.open(dst).convert("RGBA"))
    transparent = (out[..., 3] == 0).sum()
    total = out.shape[0] * out.shape[1]
    # Pre-fix: 0 transparent pixels (fell into magenta branch). Post-fix: ~all
    # pixels go transparent, modulo the watermark-margin guard. Require >=80%.
    assert transparent / total >= 0.80, (
        f"gray-tolerance did not zero the #3a3a3a background: "
        f"transparent={transparent}/{total} ({transparent / total:.1%})"
    )


# ---------------------------------------------------------------------------
# Bug #2: --cell-aware count-mismatch guard must fire on missing components
# ---------------------------------------------------------------------------
def test_extract_frames_cell_aware_count_mismatch_is_reachable(tmp_path: Path) -> None:
    """Cell-aware mode must return rc=5 when components < expected grid count.

    Build a 2x2 grid where 3 of 4 cells are empty (no chroma-keyed content). The
    pre-fix outer guard `len(ordered) != expected` was always False in cell-aware
    mode (assign_components_to_cells always returns expected-length list, with
    None for empty cells), so the inner non-None check was unreachable.
    """
    sheet_size = 256
    cell = sheet_size // 2
    # Magenta background everywhere. Place ONE white blob in cell (0, 0).
    arr = np.full((sheet_size, sheet_size, 3), (255, 0, 255), dtype=np.uint8)
    cy, cx = cell // 2, cell // 2
    arr[cy - 8 : cy + 8, cx - 8 : cx + 8] = (255, 255, 255)
    sheet_path = tmp_path / "one_blob.png"
    Image.fromarray(arr, "RGB").save(sheet_path)

    out_dir = tmp_path / "frames"
    rc = sprite_process.main(
        [
            "extract-frames",
            "--input",
            str(sheet_path),
            "--grid",
            "2x2",
            "--output-dir",
            str(out_dir),
            "--cell-aware",
        ]
    )
    assert rc == 5, f"expected rc=5 (count mismatch), got rc={rc}"


def test_extract_frames_cell_aware_full_grid_passes(tmp_path: Path) -> None:
    """Sanity: cell-aware with all 4 cells populated must still pass (rc=0)."""
    sheet_size = 256
    cell = sheet_size // 2
    arr = np.full((sheet_size, sheet_size, 3), (255, 0, 255), dtype=np.uint8)
    for r in range(2):
        for c in range(2):
            cy = r * cell + cell // 2
            cx = c * cell + cell // 2
            arr[cy - 8 : cy + 8, cx - 8 : cx + 8] = (255, 255, 255)
    sheet_path = tmp_path / "full_grid.png"
    Image.fromarray(arr, "RGB").save(sheet_path)

    out_dir = tmp_path / "frames"
    rc = sprite_process.main(
        [
            "extract-frames",
            "--input",
            str(sheet_path),
            "--grid",
            "2x2",
            "--output-dir",
            str(out_dir),
            "--cell-aware",
        ]
    )
    assert rc == 0, f"expected rc=0 (4/4 cells populated), got rc={rc}"


# ---------------------------------------------------------------------------
# Bug #1: portrait-loop generate phase must request a square (1:1) image
# ---------------------------------------------------------------------------
def test_portrait_loop_uses_generate_character_not_generate_portrait() -> None:
    """portrait-loop produces a 2x2 grid; the generate phase must NOT call the
    `generate-portrait` subcommand because it forces 4:5 aspect ratio. It must
    call `generate-character` (1:1) instead so the backend returns a square."""
    captured: list[list[str]] = []

    def fake_generate_main(argv: list[str]) -> int:
        captured.append(list(argv))
        # Synthesize a 1024x1024 square fixture so downstream slicing succeeds.
        for i, tok in enumerate(argv):
            if tok == "--output" and i + 1 < len(argv):
                out = Path(argv[i + 1])
                out.parent.mkdir(parents=True, exist_ok=True)
                Image.new("RGBA", (1024, 1024), (255, 0, 255, 255)).save(out)
        return 0

    def fake_prompt_main(argv: list[str]) -> int:
        for i, tok in enumerate(argv):
            if tok in ("--output", "--metadata-out") and i + 1 < len(argv):
                Path(argv[i + 1]).parent.mkdir(parents=True, exist_ok=True)
                Path(argv[i + 1]).write_text("stub", encoding="utf-8")
        return 0

    with tempfile.TemporaryDirectory() as td:
        argv = [
            "--mode",
            "portrait-loop",
            "--description",
            "test character",
            "--display-name",
            "Aspect Test",
            "--output-dir",
            td,
            # Note: NOT --dry-run, because dry-run skips the generate path.
        ]
        with (
            mock.patch.object(portrait_pipeline.sprite_prompt, "main", side_effect=fake_prompt_main),
            mock.patch.object(portrait_pipeline.sprite_generate, "main", side_effect=fake_generate_main),
        ):
            try:
                portrait_pipeline.main(argv)
            except SystemExit:
                pass

    assert captured, "expected at least one sprite_generate call"
    subcmd = captured[0][0]
    assert subcmd == "generate-character", (
        f"portrait-loop must use generate-character (1:1), got {subcmd!r}. "
        f"generate-portrait forces 4:5 and crops the 2x2 grid."
    )


# ---------------------------------------------------------------------------
# ADR-199: --verify is default-on; --no-verify opts out.
# These tests assert the wiring stays.
# ---------------------------------------------------------------------------
def _stub_prompt_main_factory() -> object:
    """Build a fake sprite_prompt.main that writes stub --output / --metadata-out files."""

    def fake_prompt_main(argv: list[str]) -> int:
        for i, tok in enumerate(argv):
            if tok in ("--output", "--metadata-out") and i + 1 < len(argv):
                Path(argv[i + 1]).parent.mkdir(parents=True, exist_ok=True)
                Path(argv[i + 1]).write_text("stub", encoding="utf-8")
        return 0

    return fake_prompt_main


def test_sprite_pipeline_verify_default_on_emits_json(tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:
    """ADR-199: a default sprite_pipeline run produces a verifier JSON block on stdout."""
    fake_prompt = _stub_prompt_main_factory()
    argv = [
        "--prompt",
        "wrestler walk cycle",
        "--grid",
        "4x1",
        "--cell-size",
        "256",
        "--output-dir",
        str(tmp_path),
        "--dry-run",
    ]
    with mock.patch.object(sprite_pipeline.sprite_prompt, "main", side_effect=fake_prompt):
        sprite_pipeline.main(argv)
    out = capsys.readouterr().out
    assert out.strip().startswith("{") and out.strip().endswith("}"), (
        f"expected verifier JSON block on stdout, got first 200 chars: {out[:200]!r}"
    )
    payload = json.loads(out)
    assert "passed" in payload
    assert "gates_run" in payload and len(payload["gates_run"]) > 0, payload
    # The full spritesheet gate suite (minus pixel_preservation when raw is
    # absent) should be invoked; assert the irreducible four are present.
    for gate in (
        "verify_no_magenta",
        "verify_grid_alignment",
        "verify_frames_have_content",
        "verify_anchor_consistency",
    ):
        assert gate in payload["gates_run"], f"{gate} missing from gates_run: {payload['gates_run']}"
    assert "backends_available" in payload
    assert "elapsed_seconds" in payload


def test_sprite_pipeline_no_verify_skips_gates(tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:
    """spritesheet --no-verify must skip gates AND return VERIFIER_SKIPPED_EXIT_CODE.

    ADR-207 Rule 4 (RC-4): the previous contract returned exit code 0 for
    spritesheet --no-verify, which silently masked failures with the same
    exit status as success. The new contract returns
    VERIFIER_SKIPPED_EXIT_CODE (3) so orchestrators must explicitly accept
    the skipped-verifier outcome.
    """
    fake_prompt = _stub_prompt_main_factory()
    argv = [
        "--prompt",
        "wrestler walk cycle",
        "--grid",
        "4x1",
        "--cell-size",
        "256",
        "--output-dir",
        str(tmp_path),
        "--dry-run",
        "--no-verify",
    ]
    with mock.patch.object(sprite_pipeline.sprite_prompt, "main", side_effect=fake_prompt):
        rc = sprite_pipeline.main(argv)
    assert rc == sprite_pipeline.VERIFIER_SKIPPED_EXIT_CODE == 3, (
        f"expected rc=3 (VERIFIER_SKIPPED_EXIT_CODE) with spritesheet --no-verify, got {rc}"
    )
    out = capsys.readouterr().out
    assert out.strip() == "", f"expected no JSON on stdout with --no-verify, got: {out!r}"


def test_sprite_pipeline_verify_failure_returns_exit_2(tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:
    """The dry-run synthetic fixture has 4 near-identical figures, which trips
    verify_frames_distinct. The pipeline must surface that as exit code 2 and
    a passed=false JSON block (per ADR-199 exit-code contract)."""
    fake_prompt = _stub_prompt_main_factory()
    argv = [
        "--prompt",
        "wrestler walk cycle",
        "--grid",
        "4x1",
        "--cell-size",
        "256",
        "--output-dir",
        str(tmp_path),
        "--dry-run",
    ]
    with mock.patch.object(sprite_pipeline.sprite_prompt, "main", side_effect=fake_prompt):
        rc = sprite_pipeline.main(argv)
    assert rc == sprite_pipeline.VERIFIER_EXIT_CODE == 2, f"expected verifier-failure rc=2, got {rc}"
    payload = json.loads(capsys.readouterr().out)
    assert payload["passed"] is False, payload
    assert payload["failures"], "expected non-empty failures list when passed=false"
    failed_checks = {f["check"] for f in payload["failures"]}
    # The synthetic fixture's most reliable failure is frames_distinct (all
    # 4 cells use rotating colors but identical silhouettes). Other gates
    # may also fail; we only require the dups gate as a stable signal.
    assert "verify_frames_distinct" in failed_checks, (
        f"frames_distinct should fail on synthetic fixture: {failed_checks}"
    )


def test_portrait_pipeline_verify_default_on_emits_json(tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:
    """Default portrait run emits the verifier JSON block on stdout."""
    fake_prompt = _stub_prompt_main_factory()
    argv = [
        "--description",
        "test character",
        "--display-name",
        "Verify Default",
        "--style",
        "slay-the-spire-painted",
        "--output-dir",
        str(tmp_path),
        "--dry-run",
    ]
    with mock.patch.object(portrait_pipeline.sprite_prompt, "main", side_effect=fake_prompt):
        portrait_pipeline.main(argv)
    out = capsys.readouterr().out
    assert out.strip().startswith("{"), f"expected JSON on stdout: {out[:200]!r}"
    payload = json.loads(out)
    assert "verify_no_magenta" in payload["gates_run"], payload
    # Portrait mode runs ONLY verify_no_magenta (per the run_pipeline
    # docstring rationale around verify_pixel_preservation).
    assert payload["gates_run"] == ["verify_no_magenta"], payload["gates_run"]


def test_portrait_pipeline_no_verify_skips_gates(tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:
    """portrait --no-verify writes no JSON and exits 0."""
    fake_prompt = _stub_prompt_main_factory()
    argv = [
        "--description",
        "test character",
        "--display-name",
        "Verify Skip",
        "--style",
        "slay-the-spire-painted",
        "--output-dir",
        str(tmp_path),
        "--dry-run",
        "--no-verify",
    ]
    with mock.patch.object(portrait_pipeline.sprite_prompt, "main", side_effect=fake_prompt):
        rc = portrait_pipeline.main(argv)
    assert rc == 0, f"expected rc=0 with --no-verify, got {rc}"
    out = capsys.readouterr().out
    assert out.strip() == "", f"expected no JSON on stdout with --no-verify, got: {out!r}"


def test_portrait_loop_verify_default_on_emits_json(tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:
    """portrait-loop default-on emits JSON with all 4 portrait-loop gates."""
    fake_prompt = _stub_prompt_main_factory()
    argv = [
        "--mode",
        "portrait-loop",
        "--description",
        "test character",
        "--display-name",
        "Loop Verify",
        "--style",
        "slay-the-spire-painted",
        "--output-dir",
        str(tmp_path),
        "--dry-run",
    ]
    with mock.patch.object(portrait_pipeline.sprite_prompt, "main", side_effect=fake_prompt):
        portrait_pipeline.main(argv)
    out = capsys.readouterr().out
    assert out.strip().startswith("{"), f"expected JSON on stdout: {out[:200]!r}"
    payload = json.loads(out)
    expected_gates = {
        "verify_no_magenta",
        "verify_frames_have_content",
        "verify_frames_distinct",
        "verify_anchor_consistency",
    }
    assert set(payload["gates_run"]) == expected_gates, (
        f"portrait-loop gates mismatch. expected={expected_gates} got={set(payload['gates_run'])}"
    )


def test_portrait_loop_no_verify_skips_gates(tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:
    """portrait-loop --no-verify writes no JSON and exits 0."""
    fake_prompt = _stub_prompt_main_factory()
    argv = [
        "--mode",
        "portrait-loop",
        "--description",
        "test character",
        "--display-name",
        "Loop Skip",
        "--style",
        "slay-the-spire-painted",
        "--output-dir",
        str(tmp_path),
        "--dry-run",
        "--no-verify",
    ]
    with mock.patch.object(portrait_pipeline.sprite_prompt, "main", side_effect=fake_prompt):
        rc = portrait_pipeline.main(argv)
    assert rc == 0, f"expected rc=0 with --no-verify, got {rc}"
    out = capsys.readouterr().out
    assert out.strip() == "", f"expected no JSON on stdout with --no-verify, got: {out!r}"


# ---------------------------------------------------------------------------
# Test runner
# ---------------------------------------------------------------------------
def main() -> int:
    no_arg_tests = [
        test_sprite_pipeline_forwards_style_string_to_build_character,
        test_portrait_pipeline_forwards_style_string_to_build_portrait_loop,
        test_portrait_loop_uses_generate_character_not_generate_portrait,
    ]
    tmp_tests = [
        test_bg_mode_gray_tolerance_routes_to_gray_tolerance,
        test_extract_frames_cell_aware_count_mismatch_is_reachable,
        test_extract_frames_cell_aware_full_grid_passes,
    ]
    failures: list[tuple[str, str]] = []
    for t in no_arg_tests:
        try:
            t()
            print(f"PASS {t.__name__}")
        except AssertionError as e:
            print(f"FAIL {t.__name__}: {e}")
            failures.append((t.__name__, str(e)))
    for t in tmp_tests:
        with tempfile.TemporaryDirectory() as td:
            try:
                t(Path(td))
                print(f"PASS {t.__name__}")
            except AssertionError as e:
                print(f"FAIL {t.__name__}: {e}")
                failures.append((t.__name__, str(e)))
    if failures:
        print(f"\n{len(failures)} FAIL")
        return 1
    print(f"\nAll {len(no_arg_tests) + len(tmp_tests)} tests passed.")
    return 0


if __name__ == "__main__":
    sys.exit(main())
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall