digraph SolitaireFast {
    graph [
        goal="Quickly build a terminal-based solitaire (Klondike) game in Python",
        rankdir=LR,
        default_max_retries=2,
        retry_target="implement_app"
    ]

    start [shape=Mdiamond, label="Start"]
    exit  [shape=Msquare, label="Exit"]

    plan_app [
        label="Plan App",
        shape=box,
        prompt="Goal: $goal

Create a concise implementation plan for a Python terminal solitaire game.

Cover:
- Game rules and data structures (Card, Deck, Pile types)
- Terminal rendering approach using the standard-library curses module
- Input handling and move validation
- Win/loss detection
- UI layout
- Test strategy

Put all app files under solitaire-app/. Include `python3 main.py --smoke` for non-interactive demo verification.

Write the plan to .ai/solitaire-fast-plan.md.
Write status.json at workspace root: outcome=succeeded if the plan is complete, outcome=failed with failure_reason otherwise."
    ]

    implement_app [
        label="Implement App",
        shape=box,
        class="hard",
        max_retries=2,
        prompt="Read .ai/solitaire-fast-plan.md.

Build the complete app under solitaire-app/ in one focused pass:
- pyproject.toml
- main.py
- src/solitaire_tui/ package
- tests/ package
- README.md

Implement:
- Card, Deck, and Pile types
- Klondike rules: initial deal, move validation, auto-complete detection, win condition, undo
- Curses UI with card rendering, board layout, keyboard input, move selection, and help text
- --smoke mode that imports the app, creates a game, renders a text snapshot or summary, and exits without curses interaction

Run:
cd solitaire-app && python3 -m pytest tests/ -v && python3 -m py_compile main.py src/solitaire_tui/*.py && python3 main.py --smoke

Write status.json at workspace root: outcome=succeeded if the app builds, tests pass, and smoke mode works, outcome=failed with failure_reason otherwise."
    ]

    verify_app [
        label="Verify App",
        shape=box,
        class="verify",
        goal_gate=true,
        prompt="Verify the completed solitaire app.

Run:
cd solitaire-app && python3 -m pytest tests/ -v && python3 -m py_compile main.py src/solitaire_tui/*.py && python3 main.py --smoke

Check:
- The app is under solitaire-app/
- It uses curses for the interactive TUI
- It implements Klondike rules
- README.md explains setup, run, tests, and controls
- No generated files are outside solitaire-app/ except .ai/ reports and root status.json

Write findings to .ai/solitaire-fast-verify.md.
Write status.json at workspace root: outcome=succeeded if the app is demo-ready, outcome=failed with specific missing or broken items."
    ]

    fix_app [
        label="Fix App",
        shape=box,
        class="hard",
        max_retries=2,
        prompt="The fast solitaire verification failed.

Read .ai/solitaire-fast-verify.md and fix the issues in solitaire-app/.

Run:
cd solitaire-app && python3 -m pytest tests/ -v && python3 -m py_compile main.py src/solitaire_tui/*.py && python3 main.py --smoke

Write status.json at workspace root: outcome=succeeded if all issues are fixed, outcome=failed with failure_reason otherwise."
    ]

    start -> plan_app -> implement_app -> verify_app

    verify_app -> exit    [condition="outcome=succeeded"]
    verify_app -> fix_app [condition="outcome=failed", label="Fix"]
    verify_app -> fix_app [label="Fallback"]
    fix_app -> verify_app
}
