CoolFace
Modelpublic

Engram-protocol/engram

sourceHugging Faceapache-2.0updated 6mo agoView on Hugging Face
0likes
setup.sh147 linesDownload Raw Back to scripts
1#!/usr/bin/env bash2# ENGRAM Protocol — One-command setup3#4# Usage:5#   ./scripts/setup.sh            # Full setup with sbert embedder6#   ./scripts/setup.sh --minimal  # Core only (no sbert, no MCP)7#   ./scripts/setup.sh --dev      # Full setup + dev tools8#9# Requirements:10#   - Python >= 3.1111#   - pip (comes with Python)12#   - git (for cloning)13 14set -euo pipefail15 16SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"17PROJECT_DIR="$(dirname "$SCRIPT_DIR")"18 19# Colors (if terminal supports them)20RED='\033[0;31m'21GREEN='\033[0;32m'22YELLOW='\033[1;33m'23NC='\033[0m'24 25info()  { echo -e "${GREEN}[ENGRAM]${NC} $*"; }26warn()  { echo -e "${YELLOW}[ENGRAM]${NC} $*"; }27error() { echo -e "${RED}[ENGRAM]${NC} $*" >&2; }28 29# Parse arguments30MINIMAL=false31DEV=false32for arg in "$@"; do33    case "$arg" in34        --minimal) MINIMAL=true ;;35        --dev)     DEV=true ;;36        --help|-h)37            echo "Usage: ./scripts/setup.sh [--minimal] [--dev]"38            echo ""39            echo "  --minimal  Core dependencies only (no sbert, no MCP)"40            echo "  --dev      Include development tools (pytest, ruff, mypy)"41            exit 042            ;;43        *) error "Unknown argument: $arg"; exit 1 ;;44    esac45done46 47cd "$PROJECT_DIR"48 49# ── 1. Check Python version ──────────────────────────────────────────50info "Checking Python version..."51PYTHON=""52for cmd in python3.14 python3.13 python3.12 python3.11 python3; do53    if command -v "$cmd" &>/dev/null; then54        version=$("$cmd" -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")55        major=$("$cmd" -c "import sys; print(sys.version_info.major)")56        minor=$("$cmd" -c "import sys; print(sys.version_info.minor)")57        if [ "$major" -ge 3 ] && [ "$minor" -ge 11 ]; then58            PYTHON="$cmd"59            break60        fi61    fi62done63 64if [ -z "$PYTHON" ]; then65    error "Python >= 3.11 required but not found."66    error "Install from https://python.org or via your package manager."67    exit 168fi69info "Using $PYTHON ($(${PYTHON} --version 2>&1))"70 71# ── 2. Create virtual environment ────────────────────────────────────72if [ ! -d ".venv" ]; then73    info "Creating virtual environment..."74    "$PYTHON" -m venv .venv75else76    info "Virtual environment already exists."77fi78 79# Activate80source .venv/bin/activate81info "Activated .venv"82 83# ── 3. Upgrade pip ───────────────────────────────────────────────────84info "Upgrading pip..."85pip install --upgrade pip --quiet86 87# ── 4. Install core package ──────────────────────────────────────────88info "Installing ENGRAM core dependencies..."89pip install -e . --quiet90 91if [ "$MINIMAL" = false ]; then92    # ── 5. Install sbert embedder ────────────────────────────────────93    info "Installing sentence-transformers embedder..."94    pip install -e ".[sbert]" --quiet95 96    # ── 6. Install MCP server ────────────────────────────────────────97    info "Installing MCP server dependencies..."98    pip install -e ".[mcp]" --quiet 2>/dev/null || \99        warn "MCP package not available (optional — needed for Claude Code integration)"100fi101 102if [ "$DEV" = true ]; then103    # ── 7. Install dev tools ─────────────────────────────────────────104    info "Installing development tools..."105    pip install -e ".[dev]" --quiet106fi107 108# ── 8. Create config from template ───────────────────────────────────109if [ ! -f ".env" ]; then110    cp .env.template .env111    info "Created .env from template. Edit it to set ENGRAM_MODEL_PATH."112else113    info ".env already exists."114fi115 116# ── 9. Create ENGRAM directories ─────────────────────────────────────117mkdir -p ~/.engram/sessions118mkdir -p ~/.engram/knowledge119mkdir -p ~/.engram/index120info "Created ~/.engram/ directories."121 122# ── 10. Verify installation ──────────────────────────────────────────123info "Verifying installation..."124if python -c "import kvcos; print(f'  kvcos OK (v{kvcos.core.types.ENGRAM_VERSION})')"; then125    info "Core library loaded successfully."126else127    error "Failed to import kvcos. Check error messages above."128    exit 1129fi130 131# ── 11. Run tests (if dev mode) ──────────────────────────────────────132if [ "$DEV" = true ]; then133    info "Running test suite..."134    KMP_DUPLICATE_LIB_OK=TRUE OMP_NUM_THREADS=1 PYTHONPATH=. \135        pytest tests/ -x -q --tb=short 2>&1 | tail -5136fi137 138# ── Done ─────────────────────────────────────────────────────────────139echo ""140info "Setup complete."141echo ""142echo "  Activate:  source .venv/bin/activate"143echo "  Tests:     KMP_DUPLICATE_LIB_OK=TRUE PYTHONPATH=. pytest tests/ -x -q"144echo "  Server:    engram-server"145echo "  Config:    Edit .env to set ENGRAM_MODEL_PATH"146echo ""147