#!/usr/bin/env python3
"""Report external MCP/RAG absorption into internal MCP/RAG planes."""

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.external_mcp_rag_integration_service import (  # noqa: E402
    build_external_mcp_rag_integration_readback,
)


def main() -> int:
    parser = argparse.ArgumentParser(
        description="輸出外部 MCP/RAG 導入內部 MCP/RAG 治理面的機器可讀狀態。"
    )
    parser.add_argument(
        "--family",
        choices=["external_mcp", "internal_mcp", "external_rag", "internal_rag"],
        help="只輸出指定 capability family。",
    )
    args = parser.parse_args()

    payload = build_external_mcp_rag_integration_readback(
        target_family=args.family,
    )
    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())
