#!/usr/bin/env node
/**
 * Install Vaspera Hardening skills to ~/.claude/skills/
 *
 * Usage:
 *   npx vaspera-install-skills
 *   # or after global install:
 *   vaspera-install-skills
 */
import { copyFile, mkdir, readdir, stat } from "fs/promises";
import { join, dirname } from "path";
import { homedir } from "os";
import { fileURLToPath } from "url";
const __dirname = dirname(fileURLToPath(import.meta.url));
function getSkillsSource() {
    // When running from dist/, skills are at ../skills/
    // When running from src/, skills are at ../skills/
    const fromDist = join(__dirname, "..", "skills");
    return fromDist;
}
const SKILLS_TARGET = join(homedir(), ".claude", "skills");
async function installSkills() {
    console.log("🔧 Installing Vaspera Hardening skills...\n");
    const skillsSource = getSkillsSource();
    // Ensure target directory exists
    await mkdir(SKILLS_TARGET, { recursive: true });
    // Get list of skills
    let skills;
    try {
        skills = await readdir(skillsSource);
    }
    catch {
        console.error(`❌ Skills directory not found at: ${skillsSource}`);
        console.error("   Make sure the package is installed correctly.");
        process.exit(1);
    }
    const vasperaSkills = skills.filter((s) => s.startsWith("vaspera-"));
    if (vasperaSkills.length === 0) {
        console.error("❌ No Vaspera skills found in package.");
        process.exit(1);
    }
    let installed = 0;
    let skipped = 0;
    for (const skill of vasperaSkills) {
        const sourceDir = join(skillsSource, skill);
        const targetDir = join(SKILLS_TARGET, skill);
        const sourceFile = join(sourceDir, "SKILL.md");
        const targetFile = join(targetDir, "SKILL.md");
        try {
            await stat(sourceFile);
            await mkdir(targetDir, { recursive: true });
            await copyFile(sourceFile, targetFile);
            console.log(`  ✅ ${skill}`);
            installed++;
        }
        catch (error) {
            if (error.code === "ENOENT") {
                console.log(`  ⚠️  ${skill} - source not found, skipping`);
                skipped++;
            }
            else {
                console.log(`  ❌ ${skill} - ${error.message}`);
                skipped++;
            }
        }
    }
    console.log(`\n📊 Summary: ${installed} installed, ${skipped} skipped`);
    console.log(`📁 Skills installed to: ${SKILLS_TARGET}`);
    console.log("\n🎉 Done! Skills are now available in Claude Code.");
    console.log("\nAvailable commands:");
    console.log("  /vaspera-help          Show all Vaspera skills");
    console.log("  /vaspera-audit         Run security audit");
    console.log("  /vaspera-harden        Full hardening pipeline");
    console.log("  /vaspera-ai-verify     AI code verification");
    console.log("  /vaspera-certify       Full production readiness certification");
}
installSkills().catch((error) => {
    console.error("Failed to install skills:", error);
    process.exit(1);
});
//# sourceMappingURL=install-skills.js.map