#!/bin/sh # Cymatix Context installer for macOS and Linux. # # curl -fsSL https://cymatixcontext.com/install.sh | sh # # By default installs cymatix-context[cpu,mcp] with the first of these it finds: # 1. uv (uv tool install) # 2. pipx (pipx install) # 3. Python 3.11+ (a private virtualenv in ~/.local/share/cymatix-context, # with the cymatix commands linked into ~/.local/bin) # It installs no other tools and does not edit your shell profile. # # Options, as environment variables (put them after the pipe: ... | CYMATIX_VERSION=0.11.4 sh): # CYMATIX_VERSION a release to pin, for example 0.11.4 (default: latest) # CYMATIX_EXTRAS pip extras (default: cpu,mcp). With "cpu", the spaCy # en_core_web_sm model is installed too. Empty = core only. # CYMATIX_DRY_RUN 1 = print each command instead of running it set -eu SPACY_MODEL_URL="https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.8.0/en_core_web_sm-3.8.0-py3-none-any.whl" say() { printf '%s\n' "$*"; } die() { printf 'cymatix install: %s\n' "$*" >&2; exit 1; } has() { command -v "$1" >/dev/null 2>&1; } run() { if [ "${CYMATIX_DRY_RUN:-0}" = "1" ]; then say "+ $*" else "$@" fi } find_python() { for candidate in python3.13 python3.12 python3.11 python3 python; do if has "$candidate" && "$candidate" -c 'import sys; sys.exit(sys.version_info < (3, 11))' 2>/dev/null; then say "$candidate" return 0 fi done return 1 } # Everything runs inside main so a download cut off midway executes nothing. main() { version="${CYMATIX_VERSION:-}" extras="${CYMATIX_EXTRAS-cpu,mcp}" case "$version" in *[!0-9A-Za-z.+-]*) die "CYMATIX_VERSION must look like 0.11.4, got: $version" ;; esac case "$extras" in *[!a-z0-9,-]*) die "CYMATIX_EXTRAS must be a comma-separated list like cpu,mcp, got: $extras" ;; esac spec="cymatix-context" [ -n "$extras" ] && spec="$spec[$extras]" [ -n "$version" ] && spec="$spec==$version" want_model=0 case ",$extras," in *,cpu,*) want_model=1 ;; esac say "Installing $spec" if has uv; then say "Using uv" if [ "$want_model" = 1 ]; then run uv tool install --force "$spec" --with "en_core_web_sm @ $SPACY_MODEL_URL" else run uv tool install --force "$spec" fi hint="If 'cymatix' is not found, run: uv tool update-shell" elif has pipx; then say "Using pipx" run pipx install --force "$spec" [ "$want_model" = 1 ] && run pipx inject cymatix-context "$SPACY_MODEL_URL" hint="If 'cymatix' is not found, run: pipx ensurepath" else python=$(find_python) || die "needs uv, pipx, or Python 3.11 or newer. Install one and run this again." data="${XDG_DATA_HOME:-$HOME/.local/share}/cymatix-context" bin="$HOME/.local/bin" say "Using $python with a virtualenv in $data/venv" run "$python" -m venv "$data/venv" run "$data/venv/bin/python" -m pip install --upgrade pip run "$data/venv/bin/python" -m pip install --upgrade "$spec" [ "$want_model" = 1 ] && run "$data/venv/bin/python" -m pip install "$SPACY_MODEL_URL" run mkdir -p "$bin" for exe in cymatix cymatix-server cymatix-status; do run ln -sf "$data/venv/bin/$exe" "$bin/$exe" done hint="If 'cymatix' is not found, add $bin to your PATH." fi say "" say "Done. Next:" say " cymatix status" say " cymatix ingest ./docs --recursive" say " cymatix query \"what does the splice step do?\"" say "$hint" say "Guide: https://cymatixcontext.com/wiki/getting-started/" } main "$@"