#!/usr/bin/env bash
# ====================================================================
# Course-Agent-Skills - Universal Installer Wizard (POSIX / Linux / macOS)
# ====================================================================

set -e

REPO_NAME="Course-Agent-Skills"
REPO_URL="https://huggingface.co/spaces/lensetek/course-agent-skills.git"
CAPACITY="Course & Class Management AI Agent Skills Suite (17 Skills)"

echo "===================================================================="
echo "      $REPO_NAME - UNIVERSAL INSTALLER WIZARD        "
echo "===================================================================="
echo "Repository : $REPO_URL"
echo "Capacity   : $CAPACITY"
echo "Scope      : Global Installation (Available across all AI Agents)"
echo "--------------------------------------------------------------------"
echo ""

# Step 1: Check Node.js and npx setup
echo "[1/2] Checking Node.js and npx..."
if command -v npx >/dev/null 2>&1; then
    echo "[OK] Node.js and npx are ready on your system."
else
    echo "[!] npx command not found. Node.js is required to install skills."
    echo "Please install Node.js using your package manager:"
    echo "  - macOS (Homebrew): brew install node"
    echo "  - Ubuntu/Debian:    sudo apt update && sudo apt install -y nodejs npm"
    echo "  - Arch Linux:       sudo pacman -S nodejs npm"
    echo "Or visit: https://nodejs.org"
    exit 1
fi
echo ""

# Step 2: Register Skills Globally via NPX
echo "[2/2] Installing Agent Skills GLOBALLY via NPX..."
echo "Registering all 17 course management skills across AI agents..."
npx --yes skills add -g "$REPO_URL" -y
echo ""
echo "===================================================================="
echo "[SUCCESS] Course Agent Skills installed GLOBALLY!"
echo "All AI Agents (Google Antigravity, OpenCode, Claude Code, Cursor,"
echo "Codex, and ChatGPT) now recognize all 17 skills across all workspaces!"
echo "===================================================================="
echo ""
echo "Tip: Start by asking your AI agent:"
echo "\"Please analyze my course syllabus and create 14 session folders!\""
echo ""
