-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
240 lines (211 loc) Β· 7.93 KB
/
Copy pathinstall.sh
File metadata and controls
240 lines (211 loc) Β· 7.93 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
#!/usr/bin/env bash
# ============================================================
# git-agent installer β one-liner setup
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/SuperInstance/git-agent/main/install.sh | bash
# bash install.sh --vessel owner/repo --token ghp_xxx
# bash install.sh --skip (skip onboarding wizard)
#
# What it does:
# 1. Checks Python 3.8+ and Git
# 2. Creates ~/.git-agent/ directory structure
# 3. Clones git-agent source
# 4. Installs CLI wrapper at ~/.local/bin/git-agent
# 5. Configures fleet services
# 6. Runs onboarding wizard (or skips with --skip)
# ============================================================
set -euo pipefail
VERSION="0.1.0"
INSTALL_DIR="${GIT_AGENT_HOME:-$HOME/.git-agent}"
BIN_DIR="$HOME/.local/bin"
REPO_URL="https://github.com/SuperInstance/git-agent"
# ---- Colors (disabled if not a terminal) ----
if [[ -t 1 ]]; then
B='\033[1m' G='\033[0;32m' C='\033[0;36m' Y='\033[0;33m' R='\033[0;31m' D='\033[2m' N='\033[0m'
else
B='' G='' C='' Y='' R='' D='' N=''
fi
info() { echo -e "${C}βΉ${N} $*"; }
ok() { echo -e "${G}β${N} $*"; }
warn() { echo -e "${Y}β ${N} $*"; }
die() { echo -e "${R}β${N} $*"; exit 1; }
# ---- Parse args ----
VESSEL="" TOKEN="" SKIP_ONBOARD=false QUIET=false
while [[ $# -gt 0 ]]; do
case $1 in
--vessel) VESSEL="$2"; shift 2 ;;
--token) TOKEN="$2"; shift 2 ;;
--skip) SKIP_ONBOARD=true; shift ;;
--quiet) QUIET=true; shift ;;
--help|-h)
echo "git-agent installer v${VERSION}"
echo ""
echo "Usage: bash install.sh [options]"
echo ""
echo " --vessel <owner/repo> Vessel repo β the agent's identity"
echo " --token <ghp_xxx> GitHub personal access token"
echo " --skip Skip onboarding wizard"
echo " --quiet Less output"
echo ""
echo "Environment variables:"
echo " GITHUB_TOKEN GitHub PAT (alternative to --token)"
echo " GIT_AGENT_HOME Install dir (default: ~/.git-agent)"
exit 0 ;;
*) die "Unknown option: $1 (try --help)" ;;
esac
done
# ---- Banner ----
echo ""
echo -e "${B}ββββββββββββββββββββββββββββββββββββββββββββ${N}"
echo -e "${B} π¦ git-agent v${VERSION}${N}"
echo -e "${B} The repo IS the agent. Git IS the nervous system.${N}"
echo -e "${B}ββββββββββββββββββββββββββββββββββββββββββββ${N}"
echo ""
# ---- 1. Dependencies ----
[[ $QUIET != true ]] && info "Checking dependencies..."
command -v python3 >/dev/null 2>&1 || die "Python 3.8+ required (https://python.org)"
command -v git >/dev/null 2>&1 || die "Git required (https://git-scm.com)"
PY_VER=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
PY_MAJOR=$(python3 -c "import sys; print(sys.version_info.major)")
PY_MINOR=$(python3 -c "import sys; print(sys.version_info.minor)")
if [[ "$PY_MAJOR" -lt 3 ]] || { [[ "$PY_MAJOR" -eq 3 ]] && [[ "$PY_MINOR" -lt 8 ]]; }; then
die "Python 3.8+ required. Found ${PY_VER}."
fi
GIT_VER=$(git --version | cut -d' ' -f2)
ok "Python ${PY_VER}, Git ${GIT_VER}"
# ---- 2. Directory structure ----
[[ $QUIET != true ]] && info "Installing to ${INSTALL_DIR}..."
mkdir -p "${INSTALL_DIR}"/{bin,config,templates,data,logs,vessels}
# ---- 3. Clone / update source ----
if [[ -d "${INSTALL_DIR}/git-agent/.git" ]]; then
[[ $QUIET != true ]] && info "Updating git-agent..."
git -C "${INSTALL_DIR}/git-agent" pull -q 2>/dev/null || warn "Update failed β using cached version"
else
[[ $QUIET != true ]] && info "Cloning git-agent..."
git clone -q "${REPO_URL}" "${INSTALL_DIR}/git-agent" 2>/dev/null || warn "Clone failed β some features may be unavailable"
fi
ok "Source ready"
# ---- 4. CLI wrapper ----
mkdir -p "${BIN_DIR}"
cat > "${BIN_DIR}/git-agent" << 'WRAPPER'
#!/usr/bin/env bash
# git-agent CLI β delegates to the unified Python entry point
GIT_AGENT_HOME="${GIT_AGENT_HOME:-$HOME/.git-agent}"
# Find the CLI script
CLI=""
for candidate in \
"${GIT_AGENT_HOME}/git-agent/cli.py" \
"${GIT_AGENT_HOME}/git-agent/src/git_agent/cli.py" \
"$(dirname "$0")/../git-agent/cli.py"; do
if [[ -f "$candidate" ]]; then
CLI="$candidate"
break
fi
done
if [[ -z "$CLI" ]]; then
# Try the onboard.py as fallback
for candidate in \
"${GIT_AGENT_HOME}/git-agent/standalone/onboard.py" \
"${GIT_AGENT_HOME}/git-agent/onboarding/config_wizard.py"; do
if [[ -f "$candidate" ]]; then
CLI="$candidate"
break
fi
done
fi
if [[ -z "$CLI" ]]; then
echo "git-agent not properly installed. Re-run: bash <(curl -fsSL https://raw.githubusercontent.com/SuperInstance/git-agent/main/install.sh)"
exit 1
fi
export PYTHONPATH="${GIT_AGENT_HOME}/git-agent:${PYTHONPATH:-}"
exec python3 "$CLI" "$@"
WRAPPER
chmod +x "${BIN_DIR}/git-agent"
ok "CLI at ${BIN_DIR}/git-agent"
# ---- 5. Fleet services config ----
cat > "${INSTALL_DIR}/config/fleet.json" << 'EOF'
{
"plato": "http://localhost:8847",
"keeper": "http://localhost:8900",
"agent_api": "http://localhost:8901",
"arena": "http://localhost:4044",
"crab_trap": "http://localhost:4042",
"the_lock": "http://localhost:4043",
"grammar": "http://localhost:4045",
"matrix": "http://localhost:6167",
"mud": "http://localhost:7777",
"purple_pincher": "http://localhost:4048"
}
EOF
ok "Fleet services configured"
# ---- 6. Shell integration ----
SHELL_FILE="$HOME/.bashrc"
if [[ -n "${ZSH_VERSION:-}" ]]; then SHELL_FILE="$HOME/.zshrc"; fi
if ! grep -q "GIT_AGENT_HOME" "$SHELL_FILE" 2>/dev/null; then
{
echo ""
echo "# git-agent"
echo "export GIT_AGENT_HOME=\"${INSTALL_DIR}\""
echo "export PATH=\"${BIN_DIR}:\$PATH\""
} >> "$SHELL_FILE"
ok "Added to ${SHELL_FILE}"
fi
# Export for current session
export GIT_AGENT_HOME="${INSTALL_DIR}"
export PATH="${BIN_DIR}:${PATH}"
# ---- 7. Onboarding ----
if [[ "$SKIP_ONBOARD" == false ]]; then
echo ""
echo -e "${B}βββ Onboarding βββ${N}"
echo ""
# GitHub token
if [[ -z "$TOKEN" ]]; then
TOKEN="${GITHUB_TOKEN:-}"
if [[ -n "$TOKEN" ]]; then
ok "Using GITHUB_TOKEN from environment"
else
echo -e "${Y}A GitHub token is needed for vessel operations.${N}"
echo -ne " Enter PAT (or press Enter to skip): "
read -r TOKEN
fi
fi
# Vessel repo
if [[ -z "$VESSEL" ]]; then
echo ""
echo -e "${Y}What vessel does this agent board?${N}"
echo " ${D}(The vessel repo IS the agent's identity, memory, and career)${N}"
echo ""
echo -ne " Vessel repo (owner/name): "
read -r VESSEL
fi
# Run onboarding
if [[ -n "$VESSEL" ]]; then
export GITHUB_TOKEN="${TOKEN}"
# Find onboard.py in the cloned repo
for onboard_script in \
"${INSTALL_DIR}/git-agent/standalone/onboard.py" \
"${INSTALL_DIR}/git-agent/onboarding/config_wizard.py"; do
if [[ -f "$onboard_script" ]]; then
python3 "$onboard_script" --vessel "$VESSEL" && break
fi
done || warn "Onboarding wizard encountered an error β run 'git-agent onboard' manually"
else
warn "No vessel specified β run 'git-agent onboard --vessel owner/repo' when ready"
fi
fi
# ---- Done ----
echo ""
echo -e "${B}ββββββββββββββββββββββββββββββββββββββββββββ${N}"
echo -e "${G}β git-agent installed${N}"
echo ""
echo " ${D}CLI:${N} ${BIN_DIR}/git-agent"
echo " ${D}Config:${N} ${INSTALL_DIR}/config/"
echo " ${D}Vessel:${N} ${VESSEL:-not set}"
echo ""
echo " ${C}git-agent onboard${N} Board a vessel"
echo " ${C}git-agent chat${N} Talk to your agent"
echo " ${C}git-agent start${N} Start working"
echo " ${C}git-agent status${N} Check state"
echo ""
echo -e "${B}ββββββββββββββββββββββββββββββββββββββββββββ${N}"