"""Skill registry — backward-compatible shim.

New code should use alive.core.skill_registry or alive.sharing directly.
"""

from pathlib import Path

from alive.core.skill_registry import SkillInfo, get_registry

# Backward-compatible alias
SkillMeta = SkillInfo


def list_skills() -> list[SkillInfo]:
    """Return metadata for all installed skills."""
    return get_registry().list_all()


def export_skill(skill_name: str, output_path: Path | None = None) -> Path:
    """Export a skill directory as a .tar.gz archive."""
    from alive.sharing.export import export_skill as _export

    result = _export(
        skill_name,
        output_dir=output_path.parent if output_path else None,
    )
    return result.archive_path


def import_skill(source: str) -> str:
    """Import a skill from a .tar.gz archive path."""
    from alive.sharing.import_skill import import_skill as _import

    result = _import(source, run_tests=False)
    return result.skill_name
