"""
Analyze MCP tools (plan/drift/verify) for Salesforce packs.
"""

from __future__ import annotations

from pathlib import Path
from typing import Any, Callable, Dict, List, Tuple

from g_gremlin import sfdc_metadata_pack
from g_gremlin import sfdc_pack

ToolTuple = Tuple[str, Callable[..., Dict[str, Any]], str]


def sfdc_metadata_pack_plan(pack_dir: str, target: str | None = None) -> Dict[str, Any]:
    return sfdc_metadata_pack.plan_pack(Path(pack_dir), org_alias=target).to_dict()


def sfdc_metadata_pack_drift(pack_dir: str, target: str | None = None) -> Dict[str, Any]:
    return sfdc_metadata_pack.compute_drift(Path(pack_dir), org_alias=target).to_dict()


def sfdc_metadata_pack_verify(pack_dir: str, target: str | None = None) -> Dict[str, Any]:
    return sfdc_metadata_pack.verify_pack(Path(pack_dir), org_alias=target).to_dict()


def sfdc_pack_plan(pack_dir: str, target: str | None = None) -> Dict[str, Any]:
    return sfdc_pack.plan_pack(Path(pack_dir), org_alias=target).to_dict()


def get_tools() -> List[ToolTuple]:
    return [
        ("sfdc.metadata_pack.plan", sfdc_metadata_pack_plan, "Plan metadata pack changes."),
        ("sfdc.metadata_pack.drift", sfdc_metadata_pack_drift, "Compare local vs remote metadata drift."),
        ("sfdc.metadata_pack.verify", sfdc_metadata_pack_verify, "Run metadata smoke assertions."),
        ("sfdc.pack.plan", sfdc_pack_plan, "Plan data pack updates."),
    ]
