#!/usr/bin/env sh
# Parry CLI Installer (macOS / Linux / WSL)
# Usage: curl -fsSL https://parry.scopeledger.net/install.sh | sh
set -eu

REPO_RAW="https://raw.githubusercontent.com/AI-Ops1/Parry/main"
INSTALL_DIR="${HOME}/.local/bin"
BIN_PATH="${INSTALL_DIR}/parry"

echo "========================================================"
echo "  Parry v0.1.0 — Deterministic AI Slop Deflector"
echo "  Source: https://github.com/AI-Ops1/Parry"
echo "========================================================"

if ! command -v python3 >/dev/null 2>&1; then
  echo "[ERROR] python3 is required to run Parry (zero external dependencies)."
  exit 1
fi

mkdir -p "${INSTALL_DIR}"
echo "[1/2] Downloading parry.py from ${REPO_RAW}/parry.py ..."
curl -fsSL "${REPO_RAW}/parry.py" -o "${BIN_PATH}"
chmod +x "${BIN_PATH}"

echo "[2/2] Installed Parry CLI to ${BIN_PATH}"
case ":${PATH}:" in
  *":${INSTALL_DIR}:"*)
    echo "[OK] ${INSTALL_DIR} is in your PATH."
    ;;
  *)
    echo "[NOTE] Add ${INSTALL_DIR} to your PATH:"
    echo "       export PATH=\"\${HOME}/.local/bin:\${PATH}\""
    ;;
esac

echo ""
echo "Run 'parry --version' or 'parry scan .' to verify your repository."
