from __future__ import annotations

import json
import subprocess
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
FIXTURES = ROOT / "tests" / "fixtures" / "resolve_harness_cases.json"


def main() -> int:
    cases = json.loads(FIXTURES.read_text())
    print(f"Loaded {len(cases)} resolve harness cases")
    print()
    for case in cases:
        print(f"=== {case['name']} ===")
        cmd = [
            "mcporter",
            "--config",
            "$CONFIG",
            "call",
            "atlas",
            "resolve",
            f"subject={json.dumps(case['subject'])}",
            f"context={json.dumps(case['context'])}",
            f"constraints={json.dumps(case['constraints'])}",
            f"hints={json.dumps(case['hints'])}",
            f"strategy={json.dumps(case['strategy'])}",
            'debug={"include_candidates":true,"include_explanations":true}',
        ]
        print(" ".join(cmd))
        print()
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
