-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·137 lines (122 loc) · 4.01 KB
/
install.sh
File metadata and controls
executable file
·137 lines (122 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2024-2026 Raphael Southall
set -euo pipefail
# NeuroStack Installer
# Usage: curl -fsSL https://raw.githubusercontent.com/raphasouthall/neurostack/main/install.sh | bash
# Options: NEUROSTACK_MODE=full (default: lite)
REPO="https://github.com/raphasouthall/neurostack.git"
INSTALL_DIR="${NEUROSTACK_INSTALL_DIR:-$HOME/.local/share/neurostack/repo}"
CONFIG_DIR="$HOME/.config/neurostack"
MODE="${NEUROSTACK_MODE:-lite}"
info() { echo " [*] $*"; }
warn() { echo " [!] $*" >&2; }
error() { echo " [X] $*" >&2; exit 1; }
# --- OS Check ---
case "$(uname -s)" in
Linux) info "Linux detected" ;;
Darwin) warn "macOS support is experimental" ;;
*) error "Unsupported OS: $(uname -s). NeuroStack requires Linux." ;;
esac
# --- Python Check ---
PYTHON=""
for cmd in python3.13 python3.12 python3.11 python3; do
if command -v "$cmd" &>/dev/null; then
ver=$("$cmd" -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
major="${ver%%.*}"
minor="${ver#*.}"
if [ "$major" -ge 3 ] && [ "$minor" -ge 11 ]; then
PYTHON="$cmd"
break
fi
fi
done
[ -z "$PYTHON" ] && error "Python 3.11+ required. Found: $(python3 --version 2>/dev/null || echo 'none')"
info "Python: $($PYTHON --version)"
# --- FTS5 Check ---
$PYTHON -c "
import sqlite3
conn = sqlite3.connect(':memory:')
conn.execute('CREATE VIRTUAL TABLE t USING fts5(c)')
conn.close()
" 2>/dev/null || error "SQLite FTS5 extension required but not available in your Python build"
info "FTS5: available"
# --- uv Check/Install ---
if ! command -v uv &>/dev/null; then
info "Installing uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
fi
info "uv: $(uv --version)"
# --- Clone/Update ---
if [ -d "$INSTALL_DIR/.git" ]; then
info "Updating existing installation..."
git -C "$INSTALL_DIR" pull --ff-only
else
info "Cloning NeuroStack..."
mkdir -p "$(dirname "$INSTALL_DIR")"
git clone "$REPO" "$INSTALL_DIR"
fi
# --- Install ---
cd "$INSTALL_DIR"
case "$MODE" in
lite)
info "Installing in lite mode (FTS5 only, no ML)..."
uv sync
;;
full)
info "Installing in full mode (embeddings + summaries)..."
uv sync --extra full
;;
community)
info "Installing with community detection..."
uv sync --extra full --extra community
;;
*)
error "Unknown mode: $MODE. Use: lite, full, or community"
;;
esac
# --- Create symlink ---
mkdir -p "$HOME/.local/bin"
NEUROSTACK_BIN="$HOME/.local/bin/neurostack"
cat > "$NEUROSTACK_BIN" << WRAPPER
#!/usr/bin/env bash
exec uv run --project "$INSTALL_DIR" python -m neurostack.cli "\$@"
WRAPPER
chmod +x "$NEUROSTACK_BIN"
info "CLI installed: $NEUROSTACK_BIN"
# --- Default Config ---
if [ ! -f "$CONFIG_DIR/config.toml" ]; then
mkdir -p "$CONFIG_DIR"
cat > "$CONFIG_DIR/config.toml" << TOML
# NeuroStack Configuration
# See: https://github.com/raphasouthall/neurostack#configuration
vault_root = "$HOME/brain"
embed_url = "http://localhost:11435"
llm_url = "http://localhost:11434"
llm_model = "phi3.5" # phi3.5 is MIT licensed
TOML
info "Config written: $CONFIG_DIR/config.toml"
else
info "Config exists: $CONFIG_DIR/config.toml"
fi
# --- Summary ---
echo ""
echo " NeuroStack installed! ($MODE mode)"
echo ""
echo " Quick start:"
echo " neurostack init # Set up vault structure"
echo " neurostack index # Index your vault"
echo " neurostack search 'q' # Search"
echo " neurostack doctor # Health check"
echo ""
if [ "$MODE" = "lite" ]; then
echo " Upgrade to full mode:"
echo " curl -fsSL https://raw.githubusercontent.com/raphasouthall/neurostack/main/install.sh | NEUROSTACK_MODE=full bash"
echo ""
fi
# Check PATH
if ! echo "$PATH" | tr ':' '\n' | grep -q "$HOME/.local/bin"; then
warn "Add ~/.local/bin to your PATH:"
warn " export PATH=\"\$HOME/.local/bin:\$PATH\""
fi