"""CLI compatibility layer for canonical TUI persona modules."""

from __future__ import annotations

from pathlib import Path

from cleveragents.tui.persona.registry import PersonaRegistry as _TuiPersonaRegistry
from cleveragents.tui.persona.schema import Persona as PersonaConfig


class PersonaRegistry(_TuiPersonaRegistry):
    """Backwards-compatible API for CLI callers.

    Canonical persona schema/registry live in `cleveragents.tui.persona.*`.
    This class preserves old method names used by REPL and CLI command code.
    """

    @property
    def state_file(self) -> Path:
        return self.state_path

    @property
    def personas_lock_file(self) -> Path:
        return self.personas_lock_path

    @property
    def state_lock_file(self) -> Path:
        return self.state_lock_path

    def list_personas(self) -> list[PersonaConfig]:
        return super().list_personas()

    def get_persona(self, name: str) -> PersonaConfig | None:
        return super().get(name)

    def save_persona(self, persona: PersonaConfig) -> Path:
        return super().save(persona)

    def delete_persona(self, name: str) -> bool:
        return super().delete(name)

    def get_active_persona_name(self) -> str | None:
        return super().get_last_persona()

    def set_active_persona_name(self, name: str) -> None:
        super().set_last_persona(name)

    def ensure_default_persona(
        self, actor: str = "local/mock-default"
    ) -> PersonaConfig:
        return super().ensure_default(actor=actor)
