#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "${ROOT}"

if ! command -v claude &>/dev/null; then
  echo "error: claude CLI not found. Install Claude Code first." >&2
  exit 1
fi

if ! command -v uv &>/dev/null; then
  echo "error: uv not found. Install uv first: https://docs.astral.sh/uv/" >&2
  exit 1
fi

if [[ ! -x .venv/bin/python ]]; then
  echo "==> Creating virtual environment and installing dependencies..."
  uv venv .venv
  uv pip install -e ".[dev]"
fi

echo "==> Validating plugin..."
claude plugin validate . ## --strict

echo "==> Launching Claude Code with language-tutor plugin..."
exec claude --plugin-dir "${ROOT}" "$@"