-
-
Notifications
You must be signed in to change notification settings - Fork 753
Expand file tree
/
Copy pathsetup-opencode-pi.sh
More file actions
executable file
·65 lines (58 loc) · 1.88 KB
/
setup-opencode-pi.sh
File metadata and controls
executable file
·65 lines (58 loc) · 1.88 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
#!/bin/bash
set -e
# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[0;33m'
NC='\033[0m'
echo -e "${BLUE}=== Opencode CLI Setup for Raspberry Pi ===${NC}"
# 1. Install Opencode CLI
if ! command -v opencode &> /dev/null; then
echo -e "${GREEN}[1/3] Installing @opencode-ai/cli globally...${NC}"
npm install -g @opencode-ai/cli
else
echo -e "${GREEN}[1/3] Opencode CLI already installed.${NC}"
fi
# 2. Configure Opencode
CONFIG_DIR="$HOME/.config/opencode"
CONFIG_FILE="$CONFIG_DIR/opencode.json"
mkdir -p "$CONFIG_DIR"
if [ ! -f "$CONFIG_FILE" ]; then
echo -e "${GREEN}[2/3] Creating opencode.json...${NC}"
cat <<EOF > "$CONFIG_FILE"
{
"\$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-antigravity-auth@latest"],
"provider": {
"google": {
"models": {
"antigravity-gemini-3.1-pro": {
"name": "Gemini 3.1 Pro (Antigravity)",
"limit": { "context": 1048576, "output": 65535 },
"modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
"variants": {
"low": { "thinkingLevel": "low" },
"high": { "thinkingLevel": "high" }
}
}
}
}
}
}
EOF
echo "Configuration created at $CONFIG_FILE"
else
echo -e "${YELLOW}[2/3] opencode.json already exists. Skipping overwrite.${NC}"
echo "Make sure 'opencode-antigravity-auth@latest' is in your 'plugin' list."
fi
# 3. Auth Instructions
echo -e "${BLUE}=== Authentication Required ===${NC}"
echo -e "${YELLOW}Since you are on a headless Pi, you need to use SSH port forwarding for the OAuth callback.${NC}"
echo ""
echo "1. On your LOCAL machine (laptop), run:"
echo " ssh -L 51121:localhost:51121 pi@<YOUR_PI_IP>"
echo ""
echo "2. On the PI (this terminal), run:"
echo " opencode auth login"
echo ""
echo "3. Open the URL in your local browser. The callback will be forwarded to the Pi."