"""Lightweight command contract manifest for cross-surface parity checks."""

from __future__ import annotations

from dataclasses import dataclass
from typing import Literal

CommandStatus = Literal["stable", "partial", "unsupported"]


@dataclass(frozen=True)
class CommandContractEntry:
    id: str
    path: tuple[str, ...]
    requires_bound_workspace: bool
    status: CommandStatus
    telegram_commands: tuple[str, ...] = ()
    discord_paths: tuple[tuple[str, ...], ...] = ()
    required_capabilities: tuple[str, ...] = ()


COMMAND_CONTRACT: tuple[CommandContractEntry, ...] = (
    # Cross-surface core commands (stable parity).
    CommandContractEntry(
        id="car.bind",
        path=("car", "bind"),
        requires_bound_workspace=False,
        status="stable",
        telegram_commands=("bind",),
        discord_paths=(("car", "bind"),),
    ),
    CommandContractEntry(
        id="car.status",
        path=("car", "status"),
        requires_bound_workspace=False,
        status="stable",
        telegram_commands=("status",),
        discord_paths=(("car", "status"),),
    ),
    CommandContractEntry(
        id="car.new",
        path=("car", "new"),
        requires_bound_workspace=True,
        status="stable",
        telegram_commands=("new",),
        discord_paths=(("car", "new"),),
    ),
    CommandContractEntry(
        id="car.newt",
        path=("car", "newt"),
        requires_bound_workspace=True,
        status="stable",
        telegram_commands=("newt",),
        discord_paths=(("car", "newt"),),
    ),
    CommandContractEntry(
        id="car.debug",
        path=("car", "debug"),
        requires_bound_workspace=False,
        status="stable",
        telegram_commands=("debug",),
        discord_paths=(("car", "debug"),),
    ),
    CommandContractEntry(
        id="car.agent",
        path=("car", "agent"),
        requires_bound_workspace=True,
        status="stable",
        telegram_commands=("agent",),
        discord_paths=(("car", "agent"),),
        required_capabilities=("agent_selection",),
    ),
    CommandContractEntry(
        id="car.model",
        path=("car", "model"),
        requires_bound_workspace=True,
        status="stable",
        telegram_commands=("model",),
        discord_paths=(("car", "model"),),
        required_capabilities=("model_selection",),
    ),
    CommandContractEntry(
        id="car.update",
        path=("car", "update"),
        requires_bound_workspace=False,
        status="stable",
        telegram_commands=("update",),
        discord_paths=(("car", "update"),),
        required_capabilities=("service_update",),
    ),
    CommandContractEntry(
        id="car.help",
        path=("car", "help"),
        requires_bound_workspace=False,
        status="stable",
        telegram_commands=("help",),
        discord_paths=(("car", "help"),),
    ),
    CommandContractEntry(
        id="car.ids",
        path=("car", "ids"),
        requires_bound_workspace=False,
        status="stable",
        telegram_commands=("ids",),
        discord_paths=(("car", "ids"),),
    ),
    CommandContractEntry(
        id="car.diff",
        path=("car", "diff"),
        requires_bound_workspace=True,
        status="stable",
        telegram_commands=("diff",),
        discord_paths=(("car", "diff"),),
    ),
    CommandContractEntry(
        id="car.skills",
        path=("car", "skills"),
        requires_bound_workspace=True,
        status="stable",
        telegram_commands=("skills",),
        discord_paths=(("car", "skills"),),
    ),
    CommandContractEntry(
        id="car.mcp",
        path=("car", "mcp"),
        requires_bound_workspace=True,
        status="stable",
        telegram_commands=("mcp",),
        discord_paths=(("car", "mcp"),),
    ),
    CommandContractEntry(
        id="car.init",
        path=("car", "init"),
        requires_bound_workspace=True,
        status="stable",
        telegram_commands=("init",),
        discord_paths=(("car", "init"),),
    ),
    CommandContractEntry(
        id="car.repos",
        path=("car", "repos"),
        requires_bound_workspace=False,
        status="stable",
        telegram_commands=("repos",),
        discord_paths=(("car", "repos"),),
    ),
    # Commands with cross-surface shape differences (partial parity).
    CommandContractEntry(
        id="car.files.inbox",
        path=("car", "files", "inbox"),
        requires_bound_workspace=True,
        status="partial",
        telegram_commands=("files",),
        discord_paths=(("car", "files", "inbox"),),
        required_capabilities=("filebox_access",),
    ),
    CommandContractEntry(
        id="car.files.outbox",
        path=("car", "files", "outbox"),
        requires_bound_workspace=True,
        status="partial",
        telegram_commands=("files",),
        discord_paths=(("car", "files", "outbox"),),
        required_capabilities=("filebox_access",),
    ),
    CommandContractEntry(
        id="car.files.clear",
        path=("car", "files", "clear"),
        requires_bound_workspace=True,
        status="partial",
        telegram_commands=("files",),
        discord_paths=(("car", "files", "clear"),),
        required_capabilities=("filebox_access",),
    ),
    CommandContractEntry(
        id="car.flow.status",
        path=("car", "flow", "status"),
        requires_bound_workspace=True,
        status="partial",
        telegram_commands=("flow",),
        discord_paths=(("car", "flow", "status"),),
        required_capabilities=("ticket_flow",),
    ),
    CommandContractEntry(
        id="car.flow.runs",
        path=("car", "flow", "runs"),
        requires_bound_workspace=True,
        status="partial",
        telegram_commands=("flow",),
        discord_paths=(("car", "flow", "runs"),),
        required_capabilities=("ticket_flow",),
    ),
    CommandContractEntry(
        id="car.flow.resume",
        path=("car", "flow", "resume"),
        requires_bound_workspace=True,
        status="partial",
        telegram_commands=("flow",),
        discord_paths=(("car", "flow", "resume"),),
        required_capabilities=("ticket_flow",),
    ),
    CommandContractEntry(
        id="car.flow.stop",
        path=("car", "flow", "stop"),
        requires_bound_workspace=True,
        status="partial",
        telegram_commands=("flow",),
        discord_paths=(("car", "flow", "stop"),),
        required_capabilities=("ticket_flow",),
    ),
    CommandContractEntry(
        id="car.flow.archive",
        path=("car", "flow", "archive"),
        requires_bound_workspace=True,
        status="partial",
        telegram_commands=("flow",),
        discord_paths=(("car", "flow", "archive"),),
        required_capabilities=("ticket_flow",),
    ),
    CommandContractEntry(
        id="car.flow.reply",
        path=("car", "flow", "reply"),
        requires_bound_workspace=True,
        status="partial",
        telegram_commands=("flow", "reply"),
        discord_paths=(("car", "flow", "reply"),),
        required_capabilities=("ticket_flow",),
    ),
    CommandContractEntry(
        id="pma.on",
        path=("pma", "on"),
        requires_bound_workspace=False,
        status="stable",
        telegram_commands=("pma",),
        discord_paths=(("pma", "on"),),
        required_capabilities=("pma_mode",),
    ),
    CommandContractEntry(
        id="pma.off",
        path=("pma", "off"),
        requires_bound_workspace=False,
        status="stable",
        telegram_commands=("pma",),
        discord_paths=(("pma", "off"),),
        required_capabilities=("pma_mode",),
    ),
    CommandContractEntry(
        id="pma.status",
        path=("pma", "status"),
        requires_bound_workspace=False,
        status="stable",
        telegram_commands=("pma",),
        discord_paths=(("pma", "status"),),
        required_capabilities=("pma_mode",),
    ),
    CommandContractEntry(
        id="car.resume",
        path=("car", "resume"),
        requires_bound_workspace=True,
        status="partial",
        telegram_commands=("resume",),
        discord_paths=(("car", "session", "resume"),),
        required_capabilities=("session_resume",),
    ),
    CommandContractEntry(
        id="car.reset",
        path=("car", "reset"),
        requires_bound_workspace=True,
        status="partial",
        telegram_commands=("reset",),
        discord_paths=(("car", "session", "reset"),),
        required_capabilities=("pma_thread_reset",),
    ),
    CommandContractEntry(
        id="car.review",
        path=("car", "review"),
        requires_bound_workspace=True,
        status="partial",
        telegram_commands=("review",),
        discord_paths=(("car", "review"),),
        required_capabilities=("code_review",),
    ),
    CommandContractEntry(
        id="car.approvals",
        path=("car", "approvals"),
        requires_bound_workspace=True,
        status="partial",
        telegram_commands=("approvals",),
        discord_paths=(("car", "approvals"),),
        required_capabilities=("approval_policy", "sandbox_policy"),
    ),
    CommandContractEntry(
        id="car.mention",
        path=("car", "mention"),
        requires_bound_workspace=True,
        status="partial",
        telegram_commands=("mention",),
        discord_paths=(("car", "mention"),),
        required_capabilities=("file_mentions",),
    ),
    CommandContractEntry(
        id="car.experimental",
        path=("car", "experimental"),
        requires_bound_workspace=True,
        status="partial",
        telegram_commands=("experimental",),
        discord_paths=(("car", "experimental"),),
        required_capabilities=("feature_flags",),
    ),
    CommandContractEntry(
        id="car.compact",
        path=("car", "compact"),
        requires_bound_workspace=True,
        status="partial",
        telegram_commands=("compact",),
        discord_paths=(("car", "session", "compact"),),
        required_capabilities=("conversation_compaction",),
    ),
    CommandContractEntry(
        id="car.rollout",
        path=("car", "rollout"),
        requires_bound_workspace=True,
        status="partial",
        telegram_commands=("rollout",),
        discord_paths=(("car", "rollout"),),
    ),
    CommandContractEntry(
        id="car.logout",
        path=("car", "logout"),
        requires_bound_workspace=False,
        status="partial",
        telegram_commands=("logout",),
        discord_paths=(("car", "session", "logout"),),
        required_capabilities=("auth_session",),
    ),
    CommandContractEntry(
        id="car.feedback",
        path=("car", "feedback"),
        requires_bound_workspace=False,
        status="partial",
        telegram_commands=("feedback",),
        discord_paths=(("car", "feedback"),),
        required_capabilities=("feedback_reporting",),
    ),
    CommandContractEntry(
        id="car.interrupt",
        path=("car", "interrupt"),
        requires_bound_workspace=True,
        status="partial",
        telegram_commands=("interrupt",),
        discord_paths=(("car", "session", "interrupt"),),
        required_capabilities=("turn_control",),
    ),
)
