-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·65 lines (54 loc) · 2.55 KB
/
install.sh
File metadata and controls
executable file
·65 lines (54 loc) · 2.55 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
#!/usr/bin/env bash
set -euo pipefail
# ── RunanywhereAI — One-line installer ───────────────────────────────
# Usage: curl -fsSL https://raw.githubusercontent.com/RunanywhereAI/RunAnywhereAgent/main/install.sh | bash
GREEN='\033[0;32m'
BOLD='\033[1m'
RESET='\033[0m'
CONFIG_DIR="$HOME/.config/opencode"
CONFIG_URL="https://raw.githubusercontent.com/RunanywhereAI/RunAnywhereAgent/main/opencode.json"
echo ""
echo -e "${BOLD}RunanywhereAI — AI Coding Agent${RESET}"
echo ""
# ── Get token from argument or prompt ─────────────────────────────
TOKEN="${1:-}"
if [ -z "$TOKEN" ]; then
echo -n "Paste your access token: "
read -r TOKEN
if [ -z "$TOKEN" ]; then
echo "ERROR: Token is required. Get one from your hackathon organizer."
exit 1
fi
fi
# ── Install opencode if missing ──────────────────────────────────────
if ! command -v opencode &>/dev/null; then
echo -e "${GREEN}Installing OpenCode...${RESET}"
if command -v npm &>/dev/null; then
npm i -g opencode-ai@latest
elif command -v bun &>/dev/null; then
bun i -g opencode-ai@latest
else
curl -fsSL https://opencode.ai/install | bash
fi
echo ""
fi
# ── Write config (download from repo) ────────────────────────────────
mkdir -p "$CONFIG_DIR"
curl -fsSL "$CONFIG_URL" -o "$CONFIG_DIR/opencode.json"
# ── Set token ────────────────────────────────────────────────────────
SHELL_NAME=$(basename "${SHELL:-bash}")
case "$SHELL_NAME" in
zsh) PROFILE="$HOME/.zshrc" ;;
fish) PROFILE="$HOME/.config/fish/config.fish" ;;
*) PROFILE="${HOME}/.bashrc" ; [ -f "$HOME/.bash_profile" ] && PROFILE="$HOME/.bash_profile" ;;
esac
grep -v "RUNANYWHEREAI_KEY" "$PROFILE" > "$PROFILE.tmp" 2>/dev/null || true
mv "$PROFILE.tmp" "$PROFILE" 2>/dev/null || true
if [ "$SHELL_NAME" = "fish" ]; then
echo "set -gx RUNANYWHEREAI_KEY $TOKEN" >> "$PROFILE"
else
echo "export RUNANYWHEREAI_KEY=$TOKEN" >> "$PROFILE"
fi
# ── Done ─────────────────────────────────────────────────────────────
echo -e "${GREEN}${BOLD}Done!${RESET} Restart your terminal, then run: ${BOLD}opencode${RESET}"
echo ""