forked from openclaw/openclaw
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·432 lines (370 loc) · 14.9 KB
/
install.sh
File metadata and controls
executable file
·432 lines (370 loc) · 14.9 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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
#!/usr/bin/env bash
set -euo pipefail
REPO="refreshdotdev/proactive-engineer"
BRANCH="main"
INSTALL_DIR="$HOME/.proactive-engineer"
BASE_PORT=18789
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
DIM='\033[2m'
BOLD='\033[1m'
NC='\033[0m'
info() { echo -e "${CYAN}[proactive-engineer]${NC} $1"; }
ok() { echo -e "${GREEN}[proactive-engineer]${NC} $1"; }
warn() { echo -e "${YELLOW}[proactive-engineer]${NC} $1"; }
err() { echo -e "${RED}[proactive-engineer]${NC} $1" >&2; exit 1; }
prompt_key() {
local var_name="$1"
local label="$2"
local hint="$3"
local current="${!var_name:-}"
if [ -n "$current" ]; then
ok "$label: set via environment"
return
fi
echo ""
echo -e " ${CYAN}$label${NC}"
echo -e " ${DIM}$hint${NC}"
echo -n " > "
read -r value
if [ -z "$value" ]; then
err "$label is required."
fi
eval "export $var_name='$value'"
}
prompt_optional() {
local var_name="$1"
local label="$2"
local hint="$3"
local default="$4"
local current="${!var_name:-}"
if [ -n "$current" ]; then
ok "$label: $current"
return
fi
echo ""
echo -e " ${CYAN}$label${NC} ${DIM}(default: $default)${NC}"
echo -e " ${DIM}$hint${NC}"
echo -n " > "
read -r value
if [ -z "$value" ]; then
value="$default"
fi
eval "export $var_name='$value'"
}
count_existing_profiles() {
local count=0
for d in "$HOME"/.openclaw-pe-*/; do
[ -d "$d" ] && count=$((count + 1))
done
echo "$count"
}
# ── Banner ─────────────────────────────────────────────────────
clear 2>/dev/null || true
echo ""
echo -e "${CYAN}"
echo " ┌──────────────────────────────────────────┐"
echo " │ │"
echo " │ proactive.engineer │"
echo " │ an AI that ships while you sleep │"
echo " │ │"
echo " └──────────────────────────────────────────┘"
echo -e "${NC}"
echo -e " This script sets up a Proactive Engineer agent on this"
echo -e " machine. You can run it multiple times to add more agents."
echo ""
echo -e " ${DIM}https://proactive.engineer${NC}"
echo -e " ${DIM}https://github.com/refreshdotdev/proactive-engineer${NC}"
echo ""
# ── Agent Identity ─────────────────────────────────────────────
echo -e "${YELLOW}━━━ Agent Identity ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
prompt_optional "AGENT_NAME" \
"Agent Name" \
"A short identifier for this agent (letters, numbers, hyphens). Used in config paths and service names." \
"default"
prompt_optional "AGENT_DISPLAY_NAME" \
"Slack Display Name" \
"How this agent appears in Slack messages. Use different names for different agents." \
"Proactive Engineer"
PROFILE_NAME="pe-${AGENT_NAME}"
CONFIG_DIR="$HOME/.openclaw-${PROFILE_NAME}"
CONFIG_FILE="$CONFIG_DIR/openclaw.json"
WORKSPACE_DIR="$HOME/.openclaw/workspace-${PROFILE_NAME}"
SKILL_DIR="$HOME/.openclaw/skills/proactive-engineer"
NUM_EXISTING=$(count_existing_profiles)
AGENT_PORT=$((BASE_PORT + NUM_EXISTING * 10))
if [ -d "$CONFIG_DIR" ]; then
info "Profile '${AGENT_NAME}' already exists. This will update it."
EXISTING_PORT=$(grep -o '"port":[[:space:]]*[0-9]*' "$CONFIG_FILE" 2>/dev/null | grep -o '[0-9]*' || echo "")
if [ -n "$EXISTING_PORT" ]; then
AGENT_PORT=$EXISTING_PORT
fi
fi
ok "Agent: ${AGENT_NAME} (display: ${AGENT_DISPLAY_NAME})"
ok "Port: ${AGENT_PORT}"
# ── Collect API keys ───────────────────────────────────────────
echo ""
echo -e "${YELLOW}━━━ Integration Keys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo -e " Set these as env vars to skip prompts."
echo -e " ${DIM}Setup guide: https://github.com/refreshdotdev/proactive-engineer#setting-up-your-keys${NC}"
prompt_key "SLACK_APP_TOKEN" \
"Slack App Token" \
"Starts with xapp-... — api.slack.com/apps → Socket Mode → App-Level Tokens"
prompt_key "SLACK_BOT_TOKEN" \
"Slack Bot Token" \
"Starts with xoxb-... — api.slack.com/apps → OAuth & Permissions"
# GitHub: prefer App (bot identity) over PAT
USE_GITHUB_APP=""
if [ -n "${GITHUB_APP_ID:-}" ] && [ -n "${GITHUB_APP_INSTALLATION_ID:-}" ] && [ -n "${GITHUB_APP_PEM_PATH:-}" ]; then
USE_GITHUB_APP="yes"
ok "GitHub App: configured via environment"
elif [ -n "${GITHUB_TOKEN:-}" ]; then
ok "GitHub Token: set via environment (PAT fallback)"
else
echo ""
echo -e " ${CYAN}GitHub Authentication${NC}"
echo -e " ${DIM}A GitHub App gives the agent its own identity (commits show as 'Proactive Engineer[bot]').${NC}"
echo -e " ${DIM}A Personal Access Token is simpler but commits show as your account.${NC}"
echo -n " Use GitHub App? [Y/n] > "
read -r gh_choice
if [[ ! "$gh_choice" =~ ^[Nn] ]]; then
USE_GITHUB_APP="yes"
prompt_key "GITHUB_APP_ID" \
"GitHub App ID" \
"From github.com/settings/apps → your app → App ID"
prompt_key "GITHUB_APP_INSTALLATION_ID" \
"GitHub App Installation ID" \
"From github.com/settings/installations → click your app → ID in the URL"
prompt_key "GITHUB_APP_PEM_PATH" \
"Path to Private Key (.pem file)" \
"Downloaded when you created the app. E.g. ~/proactive-engineer.pem"
else
prompt_key "GITHUB_TOKEN" \
"GitHub Personal Access Token" \
"Starts with ghp_... — github.com/settings/tokens (needs repo scope)"
fi
fi
prompt_key "GEMINI_API_KEY" \
"Google Gemini API Key" \
"From aistudio.google.com/apikey"
echo ""
ok "All keys collected."
# ── Install OpenClaw ───────────────────────────────────────────
echo ""
echo -e "${YELLOW}━━━ Installing Dependencies ━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
if ! command -v openclaw >/dev/null 2>&1; then
info "Installing OpenClaw (handles Node.js, Git, npm)..."
curl -fsSL https://openclaw.ai/install.sh | bash -s -- --no-onboard
export PATH="$HOME/.local/bin:$PATH"
command -v openclaw >/dev/null 2>&1 || err "OpenClaw installation failed. See https://docs.openclaw.ai/start/getting-started"
ok "OpenClaw installed."
else
ok "OpenClaw already installed."
fi
# ── Clone / update proactive-engineer ──────────────────────────
echo ""
echo -e "${YELLOW}━━━ Setting Up Proactive Engineer ━━━━━━━━━━━━━━━${NC}"
echo ""
if [ -d "$INSTALL_DIR/.git" ]; then
info "Updating source..."
git -C "$INSTALL_DIR" pull --quiet origin "$BRANCH" 2>/dev/null || true
ok "Updated."
else
info "Downloading proactive-engineer..."
rm -rf "$INSTALL_DIR"
git clone --depth 1 --branch "$BRANCH" "https://github.com/$REPO.git" "$INSTALL_DIR"
ok "Downloaded to $INSTALL_DIR"
fi
# Copy GitHub App private key if using App auth
if [ "$USE_GITHUB_APP" = "yes" ] && [ -n "${GITHUB_APP_PEM_PATH:-}" ]; then
mkdir -p "$CONFIG_DIR"
PEM_DEST="$CONFIG_DIR/github-app.pem"
cp "$GITHUB_APP_PEM_PATH" "$PEM_DEST" 2>/dev/null || true
chmod 600 "$PEM_DEST" 2>/dev/null || true
export GITHUB_APP_PEM_PATH="$PEM_DEST"
ok "Private key copied."
fi
# ── Symlink skill (shared across all agents) ───────────────────
info "Installing agent skill..."
mkdir -p "$(dirname "$SKILL_DIR")"
[ -L "$SKILL_DIR" ] && rm "$SKILL_DIR"
[ -d "$SKILL_DIR" ] && rm -rf "$SKILL_DIR"
ln -sf "$INSTALL_DIR/skills/proactive-engineer" "$SKILL_DIR"
ok "Skill installed."
# ── Install Tailscale (optional) ───────────────────────────────
SETUP_TAILSCALE="${SETUP_TAILSCALE:-}"
TAILSCALE_IP=""
if [ -z "$SETUP_TAILSCALE" ]; then
echo ""
echo -e " ${CYAN}Set up Tailscale for dashboard access?${NC}"
echo -e " ${DIM}Lets you access the agent's web UI from any device on your Tailnet.${NC}"
echo -e " ${DIM}Skip this if you only need Slack. You can set it up later.${NC}"
echo -n " [y/N] > "
read -r SETUP_TAILSCALE
fi
if [[ "$SETUP_TAILSCALE" =~ ^[Yy] ]]; then
echo ""
echo -e "${YELLOW}━━━ Setting Up Dashboard Access (Tailscale) ━━━━━${NC}"
echo ""
if ! command -v tailscale >/dev/null 2>&1; then
info "Installing Tailscale..."
curl -fsSL https://tailscale.com/install.sh | sh
ok "Tailscale installed."
else
ok "Tailscale already installed."
fi
if ! sudo tailscale status >/dev/null 2>&1; then
info "Starting Tailscale — follow the link below to authenticate:"
echo ""
sudo tailscale up
echo ""
ok "Tailscale connected."
else
ok "Tailscale already connected."
fi
TAILSCALE_IP=$(tailscale ip -4 2>/dev/null || echo "")
if [ -n "$TAILSCALE_IP" ]; then
ok "Tailscale IP: $TAILSCALE_IP"
fi
else
info "Skipping Tailscale. You can set it up later — see the README."
fi
# ── Set up agent workspace + heartbeat ─────────────────────────
info "Setting up workspace for agent '${AGENT_NAME}'..."
mkdir -p "$WORKSPACE_DIR"
for f in HEARTBEAT.md IDENTITY.md SOUL.md AGENTS.md; do
ln -sf "$INSTALL_DIR/skills/proactive-engineer/workspace/$f" "$WORKSPACE_DIR/$f" 2>/dev/null || \
ln -sf "$INSTALL_DIR/skills/proactive-engineer/$f" "$WORKSPACE_DIR/$f" 2>/dev/null || true
done
ok "Workspace ready at $WORKSPACE_DIR"
# ── Write config ───────────────────────────────────────────────
mkdir -p "$CONFIG_DIR"
info "Writing configuration for agent '${AGENT_NAME}'..."
GATEWAY_EXTRA=""
if [ -n "$TAILSCALE_IP" ]; then
GATEWAY_EXTRA=',
"auth": { "allowTailscale": true },
"tailscale": { "mode": "serve" }'
fi
# Determine GitHub env block
if [ "$USE_GITHUB_APP" = "yes" ]; then
GITHUB_ENV_BLOCK="\"GITHUB_APP_ID\": \"${GITHUB_APP_ID}\",
\"GITHUB_APP_INSTALLATION_ID\": \"${GITHUB_APP_INSTALLATION_ID}\",
\"GITHUB_APP_PEM_PATH\": \"${GITHUB_APP_PEM_PATH}\""
else
GITHUB_ENV_BLOCK="\"GITHUB_TOKEN\": \"${GITHUB_TOKEN}\""
fi
cat > "$CONFIG_FILE" <<CONF
{
"gateway": {
"mode": "local",
"port": ${AGENT_PORT}${GATEWAY_EXTRA}
},
"env": {
${GITHUB_ENV_BLOCK},
"GEMINI_API_KEY": "${GEMINI_API_KEY}"
},
"agents": {
"defaults": {
"workspace": "${WORKSPACE_DIR}",
"heartbeat": {
"every": "30m"
},
"model": {
"primary": "google/gemini-3.1-pro-preview"
}
}
},
"channels": {
"slack": {
"enabled": true,
"appToken": "${SLACK_APP_TOKEN}",
"botToken": "${SLACK_BOT_TOKEN}",
"groupPolicy": "open",
"channels": { "*": { "requireMention": true } },
"dmPolicy": "open",
"allowFrom": ["*"]
}
},
"skills": {
"entries": {
"proactive-engineer": {
"enabled": true,
"env": {
"AGENT_NAME": "${AGENT_NAME}",
"AGENT_DISPLAY_NAME": "${AGENT_DISPLAY_NAME}"
}
}
}
}
}
CONF
ok "Configuration saved to $CONFIG_FILE"
# ── Install daemon ─────────────────────────────────────────────
echo ""
echo -e "${YELLOW}━━━ Starting Background Service ━━━━━━━━━━━━━━━━━${NC}"
echo ""
info "Installing service for agent '${AGENT_NAME}'..."
openclaw --profile "$PROFILE_NAME" gateway install 2>/dev/null \
|| warn "Gateway install returned non-zero (may already be configured)."
if command -v loginctl >/dev/null 2>&1; then
sudo loginctl enable-linger "$(whoami)" 2>/dev/null \
|| warn "Could not enable-linger — service may not survive logout."
fi
systemctl --user enable "openclaw-gateway-${PROFILE_NAME}" 2>/dev/null || true
systemctl --user restart "openclaw-gateway-${PROFILE_NAME}" 2>/dev/null || true
sleep 3
if openclaw --profile "$PROFILE_NAME" gateway status 2>/dev/null | grep -qi "running"; then
ok "Agent '${AGENT_NAME}' is running."
else
warn "Agent may still be starting. Check: openclaw --profile ${PROFILE_NAME} gateway status"
fi
# ── Register daily digest cron ─────────────────────────────────
info "Registering daily digest cron job..."
openclaw --profile "$PROFILE_NAME" cron add \
--name "daily-digest-${AGENT_NAME}" \
--cron "0 9 * * *" \
--session isolated \
--message "Post your daily digest to #proactive-engineer. Include: (1) What you did today (PRs with one-line summaries), (2) What you considered but chose not to do and why, (3) What you're watching. Post as '${AGENT_DISPLAY_NAME}'." \
2>/dev/null || warn "Could not register daily digest cron (may need gateway running first)."
ok "Daily digest scheduled for 9am."
# ── Done ───────────────────────────────────────────────────────
echo ""
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""
echo -e " ${GREEN}${BOLD}Agent '${AGENT_NAME}' is installed and running.${NC}"
echo ""
echo -e " Display name: ${AGENT_DISPLAY_NAME}"
echo -e " Profile: ${PROFILE_NAME}"
echo -e " Port: ${AGENT_PORT}"
echo -e " Heartbeat: every 30 minutes"
echo -e " Daily digest: 9:00 AM"
if [ -n "$TAILSCALE_IP" ]; then
echo -e " Dashboard: ${CYAN}http://${TAILSCALE_IP}:${AGENT_PORT}${NC}"
fi
echo ""
echo -e " ${CYAN}Useful commands:${NC}"
echo ""
echo " openclaw --profile ${PROFILE_NAME} gateway status"
echo " openclaw --profile ${PROFILE_NAME} skills list"
echo " openclaw --profile ${PROFILE_NAME} gateway restart"
echo " openclaw --profile ${PROFILE_NAME} dashboard"
echo " journalctl --user -u openclaw-gateway-${PROFILE_NAME} -f"
echo ""
echo -e " ${CYAN}Add another agent:${NC}"
echo ""
echo " AGENT_NAME=frontend AGENT_DISPLAY_NAME=\"PE - Frontend\" \\"
echo " SLACK_APP_TOKEN=\$SLACK_APP_TOKEN SLACK_BOT_TOKEN=\$SLACK_BOT_TOKEN \\"
echo " GITHUB_TOKEN=\$GITHUB_TOKEN GEMINI_API_KEY=\$GEMINI_API_KEY \\"
echo " curl -fsSL https://proactive.engineer/install.sh | bash"
echo ""
echo -e " ${DIM}Config: $CONFIG_FILE${NC}"
echo -e " ${DIM}Workspace: $WORKSPACE_DIR${NC}"
echo -e " ${DIM}Source: $INSTALL_DIR${NC}"
echo ""
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo ""