-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·347 lines (299 loc) · 10.1 KB
/
install.sh
File metadata and controls
executable file
·347 lines (299 loc) · 10.1 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
#!/usr/bin/env bash
# Rho — Universal installer
#
# Two modes, auto-detected:
#
# User install (curl | bash, or run standalone):
# curl -fsSL https://rhobot.dev/install | bash
# Installs rho via npm. No repo clone needed.
#
# Developer install (run from a git checkout):
# git clone https://github.com/mikeyobrien/rho.git
# cd rho && ./install.sh
# Symlinks rho CLI from local source, installs local deps.
#
# Both paths end with: rho init + rho sync.
#
# Usage: ./install.sh [--force]
# --force: overwrite existing config files
#
# Idempotent: safe to run multiple times.
set -e
# ── Colors ─────────────────────────────────────────────────
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'
info() { echo -e "${CYAN}>${NC} $1"; }
ok() { echo -e "${GREEN}ok${NC} $1"; }
warn() { echo -e "${YELLOW}!!${NC} $1"; }
fail() { echo -e "${RED}error${NC} $1"; exit 1; }
# ── Parse args ─────────────────────────────────────────────
FORCE=0
for arg in "$@"; do
case "$arg" in
--force) FORCE=1 ;;
esac
done
# ── Detect install mode ───────────────────────────────────
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" 2>/dev/null && pwd)"
detect_mode() {
# Dev mode: script lives alongside our package.json (git checkout or extracted archive)
if [ -f "$SCRIPT_DIR/package.json" ]; then
if grep -q '"@rhobot-dev/rho"' "$SCRIPT_DIR/package.json" 2>/dev/null; then
MODE="dev"
REPO_DIR="$SCRIPT_DIR"
return
fi
fi
MODE="user"
}
# ── Detect platform ───────────────────────────────────────
detect_platform() {
if [ -n "$TERMUX_VERSION" ]; then
PLATFORM="android"
else
case "$(uname -s)" in
Darwin) PLATFORM="macos" ;;
Linux) PLATFORM="linux" ;;
*) fail "Unsupported OS: $(uname -s)" ;;
esac
fi
}
# ── Banner ─────────────────────────────────────────────────
show_banner() {
echo ""
echo -e "${CYAN}rho${NC} -- persistent ai agent"
echo -e "${CYAN}---${NC} $PLATFORM / $MODE install"
echo ""
}
# ── System dependencies ───────────────────────────────────
install_deps_android() {
if ! command -v termux-battery-status &>/dev/null; then
warn "Termux:API not installed"
echo " Install from F-Droid: https://f-droid.org/packages/com.termux.api/"
echo " Rho will work without it, but you'll miss notifications, sensors, etc."
echo ""
read -p "Continue anyway? [Y/n] " -n 1 -r
echo
[[ $REPLY =~ ^[Nn]$ ]] && exit 1
fi
info "Installing system packages..."
pkg update -y -q 2>/dev/null
pkg install -y -q nodejs-lts tmux 2>/dev/null
if [ "$MODE" = "dev" ]; then
pkg install -y -q git 2>/dev/null
fi
ok "nodejs $(node --version), tmux"
}
install_deps_macos() {
local missing=()
command -v node &>/dev/null || missing+=("node")
command -v npm &>/dev/null || missing+=("npm")
command -v tmux &>/dev/null || missing+=("tmux")
if [ ${#missing[@]} -gt 0 ]; then
warn "Missing: ${missing[*]}"
if command -v brew &>/dev/null; then
info "Installing via Homebrew..."
for pkg in "${missing[@]}"; do
case "$pkg" in
node|npm) brew install node ;;
*) brew install "$pkg" ;;
esac
done
else
echo ""
echo " Install Homebrew: https://brew.sh"
echo " Then: brew install node tmux"
fail "Missing dependencies"
fi
fi
ok "node $(node --version), tmux"
}
install_deps_linux() {
local missing=()
command -v node &>/dev/null || missing+=("node")
command -v npm &>/dev/null || missing+=("npm")
command -v tmux &>/dev/null || missing+=("tmux")
if [ ${#missing[@]} -gt 0 ]; then
warn "Missing: ${missing[*]}"
echo ""
if [ -f /etc/NIXOS ] || command -v nixos-rebuild &>/dev/null; then
echo " Add nodejs and tmux to environment.systemPackages, or:"
echo " nix-shell -p nodejs tmux"
elif command -v apt &>/dev/null; then
echo " sudo apt update && sudo apt install -y nodejs npm tmux"
elif command -v pacman &>/dev/null; then
echo " sudo pacman -S nodejs npm tmux"
elif command -v dnf &>/dev/null; then
echo " sudo dnf install nodejs npm tmux"
else
echo " Install node (18+), npm, and tmux using your package manager"
fi
echo ""
fail "Install missing dependencies and re-run"
fi
ok "node $(node --version), tmux"
}
# ── Install pi ─────────────────────────────────────────────
install_pi() {
if command -v pi &>/dev/null; then
ok "pi already installed"
else
info "Installing pi coding agent..."
npm install -g @mariozechner/pi-coding-agent
ok "pi installed"
fi
}
# ── Install rho (user mode: npm) ──────────────────────────
install_rho_npm() {
info "Installing rho via npm..."
if command -v rho &>/dev/null; then
local current
current=$(rho --version 2>/dev/null || echo "unknown")
ok "rho already installed ($current), upgrading..."
fi
npm install -g @rhobot-dev/rho
ok "rho $(rho --version 2>/dev/null)"
}
# ── Install rho (dev mode: local checkout) ────────────────
install_rho_dev() {
info "Installing rho from local checkout: $REPO_DIR"
# Local node deps
info "Installing Node dependencies..."
(cd "$REPO_DIR" && npm install)
# Install extension-level dependencies
for ext_pkg in "$REPO_DIR"/extensions/*/package.json; do
[ -f "$ext_pkg" ] || continue
local ext_dir
ext_dir="$(dirname "$ext_pkg")"
info "Installing deps for extension: $(basename "$ext_dir")"
(cd "$ext_dir" && npm install)
done
# Clean up old-style symlinks from previous installs
local pi_dir="$HOME/.pi/agent"
if [ -L "$pi_dir/extensions" ]; then
rm -f "$pi_dir/extensions"
elif [ -d "$pi_dir/extensions" ]; then
find "$pi_dir/extensions" -maxdepth 1 -type l -delete 2>/dev/null || true
fi
if [ -L "$pi_dir/skills" ]; then
rm -f "$pi_dir/skills"
elif [ -d "$pi_dir/skills" ]; then
find "$pi_dir/skills" -maxdepth 1 -type l -delete 2>/dev/null || true
fi
# Symlink rho CLI from this checkout
local bin_dir
if [ -n "$PREFIX" ] && [ -d "$PREFIX/bin" ]; then
bin_dir="$PREFIX/bin"
else
bin_dir="$HOME/.local/bin"
mkdir -p "$bin_dir"
fi
# Remove legacy wrapper symlinks
for name in rho-daemon rho-status rho-stop rho-trigger rho-login; do
[ -L "$bin_dir/$name" ] && rm -f "$bin_dir/$name"
done
chmod +x "$REPO_DIR/cli/index.ts" 2>/dev/null || true
ln -sf "$REPO_DIR/cli/index.ts" "$bin_dir/rho"
ok "rho CLI -> $bin_dir/rho (linked to $REPO_DIR/cli/index.ts)"
# Platform-specific scripts
if [ "$PLATFORM" = "android" ]; then
local stt_dir="$REPO_DIR/platforms/android/scripts/bin"
if [ -d "$stt_dir" ]; then
mkdir -p "$HOME/bin"
for script in "$stt_dir"/stt "$stt_dir"/stt-send; do
[ -f "$script" ] || continue
chmod +x "$script"
ln -sf "$script" "$HOME/bin/$(basename "$script")"
done
ok "STT scripts -> ~/bin"
fi
fi
# Warn about PATH on non-Termux
if [ "$PLATFORM" != "android" ]; then
case ":$PATH:" in
*":$bin_dir:"*) ;;
*)
warn "$bin_dir is not in your PATH. Add to your shell profile:"
echo " export PATH=\"$bin_dir:\$PATH\""
;;
esac
fi
}
# ── Bootstrap config ──────────────────────────────────────
bootstrap_config() {
echo ""
info "Initializing config..."
local init_args="--name rho"
if [ "$FORCE" -eq 1 ]; then
init_args="$init_args --force"
fi
if [ "$MODE" = "dev" ]; then
# Run CLI directly from checkout, sync with local source
node --experimental-strip-types "$REPO_DIR/cli/index.ts" init $init_args
echo ""
info "Syncing config (source: $REPO_DIR)..."
RHO_SOURCE="$REPO_DIR" node --experimental-strip-types "$REPO_DIR/cli/index.ts" sync
else
rho init $init_args
echo ""
info "Syncing config..."
rho sync
fi
}
# ── Platform setup ────────────────────────────────────────
run_platform_setup() {
if [ "$MODE" = "dev" ]; then
local setup="$REPO_DIR/platforms/$PLATFORM/setup.sh"
if [ -f "$setup" ]; then
echo ""
chmod +x "$setup"
bash "$setup"
fi
fi
}
# ── Done ───────────────────────────────────────────────────
show_done() {
echo ""
echo -e "${GREEN}rho is ready.${NC}"
echo ""
echo " rho start and attach"
echo " rho start start in background"
echo " rho login connect your LLM provider"
echo ""
echo " /rho status check heartbeat (inside session)"
echo " /rho now trigger check-in"
echo ""
case "$PLATFORM" in
android)
echo " optional:"
echo " install Tasker for UI automation"
echo " use /brain to manage memory and reminders"
;;
*)
echo " optional:"
echo " use /brain to manage memory and reminders"
;;
esac
echo ""
}
# ── Main ───────────────────────────────────────────────────
detect_mode
detect_platform
show_banner
case "$PLATFORM" in
android) install_deps_android ;;
macos) install_deps_macos ;;
linux) install_deps_linux ;;
esac
install_pi
if [ "$MODE" = "dev" ]; then
install_rho_dev
else
install_rho_npm
fi
bootstrap_config
run_platform_setup
show_done