#!/usr/bin/env python3
"""
Score market Agent framework capability evidence.

Usage:
  python scripts/agent-market-capability-scorecard.py \
    --input docs/ai/agent-market-capability-evidence-2026-06-01.json \
    --output docs/evaluations/agent_market_capability_scorecard_2026-06-01.json
"""

from __future__ import annotations

import argparse
import json
import sys
from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
API_SRC = ROOT / "apps" / "api"
sys.path.insert(0, str(API_SRC))

from src.services.agent_market_scorecard import score_market_capabilities  # noqa: E402


def main() -> int:
    parser = argparse.ArgumentParser(
        description="Score official market capability evidence for Agent candidates."
    )
    parser.add_argument("--input", required=True, help="Market evidence JSON path")
    parser.add_argument("--output", help="Scorecard JSON path")
    args = parser.parse_args()

    payload = json.loads(Path(args.input).read_text(encoding="utf-8"))
    report = score_market_capabilities(payload).to_dict()
    rendered = json.dumps(report, ensure_ascii=False, indent=2, sort_keys=True)
    if args.output:
        Path(args.output).write_text(rendered + "\n", encoding="utf-8")
    else:
        print(rendered)
    return 0


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