"""Slash command catalog for TUI command overlay."""

from __future__ import annotations

from dataclasses import dataclass


@dataclass(frozen=True, slots=True)
class SlashCommandSpec:
    """Single slash command descriptor."""

    command: str
    group: str
    description: str


SLASH_COMMAND_SPECS: tuple[SlashCommandSpec, ...] = (
    SlashCommandSpec("session:create", "Session", "Create a new session tab"),
    SlashCommandSpec("session:list", "Session", "Display all sessions"),
    SlashCommandSpec("session:show", "Session", "Show session details"),
    SlashCommandSpec("session:switch", "Session", "Switch to a session"),
    SlashCommandSpec("session:close", "Session", "Close the current session"),
    SlashCommandSpec("session:delete", "Session", "Delete a saved session"),
    SlashCommandSpec("session:rename", "Session", "Rename current session"),
    SlashCommandSpec("session:export", "Session", "Export session to JSON"),
    SlashCommandSpec("session:import", "Session", "Import session from JSON"),
    SlashCommandSpec("persona:list", "Persona", "Display all personas"),
    SlashCommandSpec("persona:set", "Persona", "Switch active persona"),
    SlashCommandSpec("persona:create", "Persona", "Create a persona"),
    SlashCommandSpec("persona:edit", "Persona", "Edit a persona"),
    SlashCommandSpec("persona:delete", "Persona", "Delete a persona"),
    SlashCommandSpec("persona:export", "Persona", "Export persona YAML"),
    SlashCommandSpec("persona:import", "Persona", "Import persona YAML"),
    SlashCommandSpec("scope:add", "Scope", "Add scope reference"),
    SlashCommandSpec("scope:remove", "Scope", "Remove scope reference"),
    SlashCommandSpec("scope:clear", "Scope", "Clear session scope additions"),
    SlashCommandSpec("scope:show", "Scope", "Show effective scope"),
    SlashCommandSpec("plan:use", "Plan", "Start a new plan"),
    SlashCommandSpec("plan:list", "Plan", "List plans"),
    SlashCommandSpec("plan:status", "Plan", "Show plan status"),
    SlashCommandSpec("plan:tree", "Plan", "Show decision tree"),
    SlashCommandSpec("plan:execute", "Plan", "Execute a plan"),
    SlashCommandSpec("plan:apply", "Plan", "Apply a completed plan"),
    SlashCommandSpec("plan:cancel", "Plan", "Cancel a plan"),
    SlashCommandSpec("plan:diff", "Plan", "Show plan diff"),
    SlashCommandSpec("plan:correct", "Plan", "Correct a decision"),
    SlashCommandSpec("plan:resume", "Plan", "Resume a plan"),
    SlashCommandSpec("plan:revert", "Plan", "Revert plan state"),
    SlashCommandSpec("plan:rollback", "Plan", "Rollback to checkpoint"),
    SlashCommandSpec("plan:explain", "Plan", "Explain a decision"),
    SlashCommandSpec("plan:errors", "Plan", "Show plan errors"),
    SlashCommandSpec("plan:artifacts", "Plan", "Show plan artifacts"),
    SlashCommandSpec("plan:inspect", "Plan", "Inspect plan details"),
    SlashCommandSpec("project:list", "Project", "List projects"),
    SlashCommandSpec("project:create", "Project", "Create project"),
    SlashCommandSpec("project:show", "Project", "Show project details"),
    SlashCommandSpec("project:delete", "Project", "Delete project"),
    SlashCommandSpec("project:inspect", "Project", "Inspect project details"),
    SlashCommandSpec("project:context:show", "Project", "Show project context policy"),
    SlashCommandSpec("actor:list", "Actor", "List actors"),
    SlashCommandSpec("actor:show", "Actor", "Show actor details"),
    SlashCommandSpec("actor:set-default", "Actor", "Set default actor"),
    SlashCommandSpec("resource:list", "Resource", "List resources"),
    SlashCommandSpec("resource:show", "Resource", "Show resource details"),
    SlashCommandSpec("resource:tree", "Resource", "Show resource tree"),
    SlashCommandSpec("resource:inspect", "Resource", "Inspect resource details"),
    SlashCommandSpec("config:list", "Config", "List config entries"),
    SlashCommandSpec("config:get", "Config", "Get config value"),
    SlashCommandSpec("config:set", "Config", "Set config value"),
    SlashCommandSpec("tool:list", "Tool", "List tools"),
    SlashCommandSpec("tool:show", "Tool", "Show tool details"),
    SlashCommandSpec("skill:list", "Skill", "List skills"),
    SlashCommandSpec("skill:show", "Skill", "Show skill details"),
    SlashCommandSpec("invariant:list", "Invariant", "List invariants"),
    SlashCommandSpec("invariant:add", "Invariant", "Add invariant"),
    SlashCommandSpec("invariant:remove", "Invariant", "Remove invariant"),
    SlashCommandSpec("profile:list", "Profile", "List automation profiles"),
    SlashCommandSpec("profile:show", "Profile", "Show automation profile"),
    SlashCommandSpec("context:inspect", "Context", "Inspect context state"),
    SlashCommandSpec("context:set", "Context", "Set context policy"),
    SlashCommandSpec("context:simulate", "Context", "Simulate context assembly"),
    SlashCommandSpec("clear", "Utility", "Clear conversation display"),
    SlashCommandSpec("theme", "Utility", "Switch color theme"),
    SlashCommandSpec("settings", "Utility", "Open settings"),
    SlashCommandSpec("help", "Utility", "Show help"),
    SlashCommandSpec("about", "Utility", "Show version information"),
    SlashCommandSpec("debug", "Utility", "Toggle debug mode"),
)


def slash_command_names() -> list[str]:
    """Return command names for overlay filtering and completion."""
    return [spec.command for spec in SLASH_COMMAND_SPECS]


def slash_command_specs() -> list[SlashCommandSpec]:
    """Return all slash command specs for the overlay (includes descriptions)."""
    return list(SLASH_COMMAND_SPECS)


def slash_command_groups() -> set[str]:
    """Return unique slash command groups represented in the catalog."""
    return {spec.group for spec in SLASH_COMMAND_SPECS}
