-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·214 lines (182 loc) · 5.53 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·214 lines (182 loc) · 5.53 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
#!/usr/bin/env bash
set -euo pipefail
REPO="vincents-ai/engram"
GITHUB="https://github.com"
info() { printf "\033[1;34m[info]\033[0m %s\n" "$*"; }
ok() { printf "\033[1;32m[ok]\033[0m %s\n" "$*"; }
warn() { printf "\033[1;33m[warn]\033[0m %s\n" "$*"; }
die() { printf "\033[1;31m[error]\033[0m %s\n" "$*" >&2; exit 1; }
confirm() {
local prompt="$1"
local response
printf "%s [Y/n] " "$prompt"
read -r response
case "$response" in
[yY]|[yY][eE][sS]|"") return 0 ;;
*) return 1 ;;
esac
}
detect_platform() {
local os arch
os="$(uname -s)"
arch="$(uname -m)"
case "$os" in
Linux)
case "$arch" in
x86_64|amd64)
if ldd --version 2>&1 | grep -q musl; then
echo "linux-musl-amd64"
else
echo "linux-amd64"
fi
;;
aarch64|arm64) echo "linux-arm64" ;;
*) die "Unsupported architecture: $arch on $os" ;;
esac
;;
Darwin)
case "$arch" in
x86_64|amd64) echo "macos-amd64" ;;
aarch64|arm64) echo "macos-arm64" ;;
*) die "Unsupported architecture: $arch on $os" ;;
esac
;;
MINGW*|MSYS*|CYGWIN*)
case "$arch" in
x86_64|amd64) echo "windows-amd64" ;;
*) die "Unsupported architecture: $arch on $os" ;;
esac
;;
*) die "Unsupported OS: $os" ;;
esac
}
get_latest_tag() {
local tag
tag="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')"
[ -n "$tag" ] || die "Could not determine latest release tag"
echo "$tag"
}
install_binary() {
local tag="$1"
local platform="$2"
local asset_name ext
if [ "$platform" = "windows-amd64" ]; then
asset_name="engram-windows-amd64"
ext="zip"
else
asset_name="engram-${platform}"
ext="tar.gz"
fi
local url="${GITHUB}/${REPO}/releases/download/${tag}/${asset_name}.${ext}"
local tmp
tmp="$(mktemp -d)"
info "Downloading ${asset_name}.${ext} ..."
curl -fsSL "$url" -o "${tmp}/${asset_name}.${ext}" || die "Download failed: $url"
info "Extracting ..."
if [ "$ext" = "zip" ]; then
unzip -qo "${tmp}/${asset_name}.${ext}" -d "${tmp}" || die "Extraction failed"
else
tar xzf "${tmp}/${asset_name}.${ext}" -C "${tmp}" || die "Extraction failed"
fi
local bin="${tmp}/engram"
if [ "$ext" = "zip" ]; then
bin="${tmp}/engram.exe"
fi
[ -f "$bin" ] || die "Binary not found after extraction"
local install_dir="${ENGRAM_INSTALL_DIR:-/usr/local/bin}"
if [ "$platform" = "windows-amd64" ]; then
install_dir="${ENGRAM_INSTALL_DIR:-$HOME/bin}"
mkdir -p "$install_dir"
cp "$bin" "${install_dir}/engram.exe"
ok "Installed to ${install_dir}/engram.exe"
rm -rf "${tmp}"
else
if [ "$(id -u)" -eq 0 ]; then
cp "$bin" "${install_dir}/engram"
chmod 755 "${install_dir}/engram"
ok "Installed to ${install_dir}/engram"
elif confirm "Install to ${install_dir} (requires sudo)?"; then
sudo cp "$bin" "${install_dir}/engram"
sudo chmod 755 "${install_dir}/engram"
ok "Installed to ${install_dir}/engram"
else
mkdir -p "$HOME/.local/bin"
cp "$bin" "$HOME/.local/bin/engram"
chmod 755 "$HOME/.local/bin/engram"
ok "Installed to $HOME/.local/bin/engram"
warn "Make sure \$HOME/.local/bin is in your PATH"
fi
rm -rf "${tmp}"
fi
}
verify_install() {
if command -v engram >/dev/null 2>&1; then
local version
version="$(engram --version 2>/dev/null || echo "unknown")"
ok "engram is installed: ${version}"
return 0
else
warn "engram not found in PATH"
return 1
fi
}
run_bootstrap() {
printf "\n"
info "=== Bootstrap for AI agent setup ==="
printf "\n"
if confirm "Initialise engram workspace in current directory?"; then
engram setup workspace || warn "Workspace setup failed"
fi
printf "\n"
if confirm "Register an agent profile?"; then
local agent_name
printf "Agent name (default: claude): "
read -r agent_name
agent_name="${agent_name:-claude}"
local agent_type
printf "Agent type (implementation|operator|quality_assurance|architecture, default: implementation): "
read -r agent_type
agent_type="${agent_type:-implementation}"
engram setup agent --name "$agent_name" --agent-type "$agent_type" || warn "Agent setup failed"
fi
printf "\n"
if confirm "Install core engram skills (14 skills for your AI coding tool)?"; then
engram skills setup || warn "Skills setup failed"
fi
printf "\n"
if confirm "Install all skills (44 skills across all categories)?"; then
engram setup skills --force || warn "Full skills setup failed"
fi
printf "\n"
if confirm "Install the commit-msg hook (enforces task linkage)?"; then
engram validate hook install || warn "Hook install failed"
fi
printf "\n"
ok "Bootstrap complete!"
}
main() {
printf "\n\033[1m Engram Installer\033[0m\n\n"
local tag="${ENGRAM_VERSION:-}"
if [ -z "$tag" ]; then
tag="$(get_latest_tag)"
fi
info "Installing Engram ${tag}"
local platform
platform="$(detect_platform)"
info "Detected platform: ${platform}"
install_binary "$tag" "$platform"
export PATH="${PATH}:$HOME/.local/bin"
if verify_install; then
printf "\n"
if confirm "Run interactive bootstrap for an AI agent?"; then
run_bootstrap
fi
printf "\n"
ok "Done! Run 'engram --help' to get started."
else
printf "\n"
warn "Install succeeded but engram is not in your PATH."
warn "Add its location to your PATH and run 'engram --help'."
fi
}
main "$@"