#!/bin/sh
# Ribbon Cable harness installer. Read it first: curl -fsSL https://comp4020-final-da-w1nn3r.fly.dev/harness/install.sh
set -eu
URL='https://comp4020-final-da-w1nn3r.fly.dev/harness/ribbon-cable-harness.tar.gz'
DIR='ribbon-cable-harness'

command -v node >/dev/null 2>&1 || { echo "Node 24+ is required: https://nodejs.org" >&2; exit 1; }
[ "$(node -p 'process.versions.node.split(".")[0]')" -ge 24 ] || echo "Warning: Node 24+ is needed to run the harness (you have $(node -v))." >&2
command -v tar >/dev/null 2>&1 || { echo "tar is required" >&2; exit 1; }
[ ! -e "$DIR" ] || { echo "$DIR already exists here; move or remove it first (it holds your settings)." >&2; exit 1; }

if command -v curl >/dev/null 2>&1; then curl -fsSL "$URL" | tar -xz
elif command -v wget >/dev/null 2>&1; then wget -qO- "$URL" | tar -xz
else echo "curl or wget is required" >&2; exit 1; fi

echo "Installed in ./$DIR"
echo "Next: cd $DIR && node src/main.ts   (it finds a local model or API key by itself; see QUICKSTART.md)"
