#!/usr/bin/env python3
from __future__ import annotations

import argparse
import json
from pathlib import Path

from aituner.tuning_report import run_tuning_report


def main() -> int:
    parser = argparse.ArgumentParser(
        description="Summarize anytime tuning progress across harness/naive study stores."
    )
    parser.add_argument("--spec", required=True, help="Path to a tuning report JSON spec.")
    args = parser.parse_args()
    summary = run_tuning_report(Path(args.spec))
    print(
        json.dumps(
            {
                "report_id": summary["report_id"],
                "report_root": summary["report_root"],
                "case_count": summary["aggregate"]["case_count"],
                "harness_vs_naive_pass_count": summary["aggregate"]["harness_vs_naive_pass_count"],
                "harness_vs_naive_check_count": summary["aggregate"]["harness_vs_naive_check_count"],
                "winner_counts": summary["aggregate"]["winner_counts"],
            },
            ensure_ascii=False,
            indent=2,
        )
    )
    return 0


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