"""Skill management CLI commands."""

from __future__ import annotations

import os
import shutil
from pathlib import Path


def run_skill_install() -> None:
    """Install Claude Code skill for Bandito."""
    skill_dir = Path.home() / ".claude" / "skills" / "bandito"
    
    if skill_dir.exists():
        response = input(f"\n  Skill already exists at {skill_dir}.\n  Overwrite? [y/N]: ")
        if response.lower() != "y":
            print("  Cancelled.\n")
            return
        shutil.rmtree(skill_dir)
    
    skill_dir.mkdir(parents=True, exist_ok=True)
    
    source_skill = Path(__file__).parent.parent / "skills" / "bandito" / "SKILL.md"
    
    if not source_skill.exists():
        print(f"\n  Error: Skill template not found at {source_skill}\n")
        return
    
    shutil.copy2(source_skill, skill_dir / "SKILL.md")
    
    print(f"\n  ✓ Installed Bandito skill to {skill_dir}")
    print(f"\n  Invoke in Claude Code with: /bandito\n")
