#!/usr/bin/env bash # One-shot: clone (optional) + build CST-Agent on Linux, WSL or macOS. set -euo pipefail REPO_URL="${CST_AGENT_REPO:-https://git.whcself.xyz/WHC/CST-agent.git}" DIR="${1:-}" if [[ -z "$DIR" ]]; then if [[ -f Makefile && -d src ]]; then DIR="$(pwd)" else DIR="CST-agent" fi fi if [[ ! -f "$DIR/Makefile" ]]; then echo "==> git clone $REPO_URL -> $DIR" git clone "$REPO_URL" "$DIR" fi cd "$DIR" echo "==> deps hint: gcc/clang make cmake libcurl ncursesw" if [[ "$(uname -s)" == Darwin ]]; then echo " macOS: xcode-select --install && brew install ncurses curl pkg-config" elif command -v pacman >/dev/null 2>&1; then echo " Arch: sudo pacman -S --needed base-devel cmake curl ncurses" elif command -v apt-get >/dev/null 2>&1; then echo " Debian/Ubuntu/WSL: sudo apt install build-essential cmake pkg-config libcurl4-openssl-dev libncurses-dev" elif command -v dnf >/dev/null 2>&1; then echo " Fedora: sudo dnf install gcc make cmake pkgconf libcurl-devel ncurses-devel" elif command -v apk >/dev/null 2>&1; then echo " Alpine: sudo apk add build-base pkgconf curl-dev ncurses-dev" elif command -v nix-shell >/dev/null 2>&1; then echo " Nix: nix-shell (uses shell.nix), then rerun this script" fi JOBS="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)" echo "==> make" make -j"$JOBS" make check || true echo echo "OK: ./cst-agent" echo "Install: make install PREFIX=\$HOME/.local" echo "Run it inside a project directory: cst-agent" echo " (the first start asks for the provider and its API key and saves them)"