#!/bin/sh # KHAELOR # File: website/public/install.sh # Description: Hosted installer for the KHAELOR CLI — checks Node >= 22 and npm, installs the tarball globally, verifies. # # Author: Simon-Pierre Boucher # Contact: contact@spboucher.ai # # Usage: curl -fsSL https://www.khaelor.sh/install.sh | sh # # This script never runs sudo on its own. If a global npm install needs # elevated permissions, it prints exactly what to do instead. set -eu TARBALL_URL="https://www.khaelor.sh/khaelor.tgz" MIN_NODE_MAJOR=22 say() { printf '%s\n' "$*"; } fail() { printf 'khaelor install: error: %s\n' "$*" >&2; exit 1; } say "" say " KHAELOR installer" say " https://www.khaelor.sh" say "" # ── 1. node ───────────────────────────────────────────────────────────── if ! command -v node >/dev/null 2>&1; then fail "Node.js was not found on your PATH. KHAELOR requires Node.js ${MIN_NODE_MAJOR} or newer. Install it with one of: - https://nodejs.org (official installers) - brew install node (Homebrew, macOS) - nvm install ${MIN_NODE_MAJOR} (nvm) then re-run: curl -fsSL https://www.khaelor.sh/install.sh | sh" fi NODE_VERSION="$(node --version 2>/dev/null || true)" # node --version prints e.g. v22.11.0 — extract the major. NODE_MAJOR="$(printf '%s' "$NODE_VERSION" | sed -e 's/^v//' -e 's/\..*$//')" case "$NODE_MAJOR" in ''|*[!0-9]*) fail "could not parse Node.js version from 'node --version' (got: ${NODE_VERSION:-nothing})." ;; esac if [ "$NODE_MAJOR" -lt "$MIN_NODE_MAJOR" ]; then fail "Node.js ${NODE_VERSION} is too old. KHAELOR requires Node.js ${MIN_NODE_MAJOR} or newer. Upgrade with one of: - https://nodejs.org - brew upgrade node (Homebrew, macOS) - nvm install ${MIN_NODE_MAJOR} (nvm)" fi say " node ${NODE_VERSION} ... ok" # ── 2. npm ────────────────────────────────────────────────────────────── if ! command -v npm >/dev/null 2>&1; then fail "npm was not found on your PATH. npm normally ships with Node.js. If you installed Node another way, install npm too, then re-run this script." fi say " npm $(npm --version 2>/dev/null || say '?') ... ok" # ── 3. install ────────────────────────────────────────────────────────── say "" say " Installing KHAELOR from ${TARBALL_URL} ..." say "" if ! npm install -g "$TARBALL_URL"; then say "" >&2 say "khaelor install: 'npm install -g' failed." >&2 say "" >&2 say "If the error above mentions EACCES (permission denied), your global npm" >&2 say "prefix is owned by root. The clean fix is a user-owned prefix — this" >&2 say "script will NOT run sudo for you:" >&2 say "" >&2 say " mkdir -p ~/.npm-global" >&2 say " npm config set prefix ~/.npm-global" >&2 say " export PATH=\"\$HOME/.npm-global/bin:\$PATH\" # add to your shell profile" >&2 say " npm install -g ${TARBALL_URL}" >&2 say "" >&2 say "For any other error, the npm output above has the details." >&2 exit 1 fi # ── 4. verify ─────────────────────────────────────────────────────────── if ! command -v khaelor >/dev/null 2>&1; then fail "install completed but 'khaelor' is not on your PATH. Your npm global bin directory is probably not on PATH. Find it with: npm prefix -g then add '/bin' to PATH in your shell profile and open a new shell." fi KHAELOR_VERSION="$(khaelor --version 2>/dev/null || true)" if [ -z "$KHAELOR_VERSION" ]; then fail "'khaelor --version' did not run cleanly. Try running it directly to see the error." fi # ── 5. next steps ─────────────────────────────────────────────────────── say "" say " KHAELOR ${KHAELOR_VERSION} installed." say "" say " Next steps:" say "" say " 1. Set your Anthropic API key (add to your shell profile to persist):" say " export ANTHROPIC_API_KEY=sk-ant-..." say "" say " 2. Start it inside a project:" say " cd your-project && khaelor" say "" say " Docs: https://www.khaelor.sh/docs/getting-started.html" say ""