#!/usr/bin/env python3
"""Report the PixelRAG application portfolio as machine-readable JSON."""

from __future__ import annotations

import argparse
import json
import sys
from pathlib import Path


ROOT = Path(__file__).resolve().parents[2]
if str(ROOT) not in sys.path:
    sys.path.insert(0, str(ROOT))

from services.pixelrag_application_portfolio_service import (  # noqa: E402
    build_pixelrag_application_portfolio,
)


def main() -> int:
    parser = argparse.ArgumentParser(
        description="輸出 PixelRAG 還可整合/運用場景的機器可讀 portfolio。"
    )
    parser.add_argument(
        "--area",
        help="限制 area，例如 commerce / rag / ux / ops / marketing / governance。",
    )
    parser.add_argument(
        "--priority",
        help="限制 priority，例如 P0 / P1 / P2 / P3。",
    )
    parser.add_argument(
        "--include-forbidden",
        action="store_true",
        help="包含 forbidden guardrail lane。",
    )
    args = parser.parse_args()

    payload = build_pixelrag_application_portfolio(
        area=args.area,
        priority=args.priority,
        include_forbidden=args.include_forbidden,
    )
    print(json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True))
    return 0 if payload.get("success") else 1


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