-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh
More file actions
98 lines (87 loc) · 3.18 KB
/
Copy pathinstall.sh
File metadata and controls
98 lines (87 loc) · 3.18 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
#!/usr/bin/env bash
# One-command setup for infermatrix-copilot.
#
# bash install.sh install (idempotent)
# bash install.sh --uninstall remove ONLY what this installer created
#
# Creates/reuses a venv, installs the package, seeds .env from the template if
# absent (never overwrites, never prints secret values), writes a repo-local
# ./infermatrix-copilot wrapper (no PATH mutation), and finishes with the doctor.
set -euo pipefail
cd "$(dirname "$0")"
MANIFEST=".install-manifest"
WRAPPER="./infermatrix-copilot"
if [[ "${1:-}" == "--uninstall" ]]; then
# remove only installer-created artifacts, recorded in the manifest
if [[ -f "$MANIFEST" ]]; then
while IFS= read -r item; do
[[ -e "$item" ]] && rm -rf "$item" && echo "removed $item"
done < "$MANIFEST"
rm -f "$MANIFEST"
else
echo "no $MANIFEST — nothing this installer created to remove"
fi
echo "note: .env was NOT touched (it may hold your keys)"
exit 0
fi
created=()
# 1. venv: reuse an active one, else create ./.venv
if [[ -n "${VIRTUAL_ENV:-}" ]]; then
VENV="$VIRTUAL_ENV"
echo "using active virtualenv: $VENV"
elif [[ -d .venv && -x .venv/bin/pip ]]; then
VENV="$PWD/.venv"
echo "reusing existing ./.venv"
else
# newest available interpreter; a failed creation (missing python3-venv)
# is cleaned up and reported with the exact fix, not left half-made
PY="${OMNI_PYTHON:-}"
if [[ -z "$PY" ]]; then
for cand in python3.12 python3.11 python3; do
command -v "$cand" >/dev/null && PY="$cand" && break
done
fi
if ! "$PY" -m venv .venv 2>/tmp/omni-venv-err || [[ ! -x .venv/bin/pip ]]; then
rm -rf .venv
echo "✗ could not create a virtualenv with $PY:"
sed -n 1,4p /tmp/omni-venv-err 2>/dev/null || true
echo " fix: install the venv module (e.g. sudo apt install ${PY}-venv),"
echo " or activate an existing venv / set OMNI_PYTHON and re-run."
exit 1
fi
VENV="$PWD/.venv"
created+=(".venv")
echo "created ./.venv with $PY"
fi
# 2. install the package (editable)
"$VENV/bin/pip" install -q -e . || {
echo "✗ pip install failed — see output above; fix and re-run bash install.sh"
exit 1
}
echo "installed infermatrix-copilot into the venv"
# 3. seed .env (never overwrite)
if [[ ! -f .env ]]; then
cp .env.template .env
echo "created .env from template — EDIT IT: set ANTHROPIC_API_KEY (and"
echo " REPO_PATHS if your checkouts are elsewhere). Values are never printed."
else
echo ".env already present — left untouched"
fi
# 4. repo-local wrapper (invokable immediately; PATH is never modified)
cat > "$WRAPPER" <<EOF
#!/usr/bin/env bash
exec "$VENV/bin/infermatrix-copilot" "\$@"
EOF
chmod +x "$WRAPPER"
created+=("$WRAPPER")
echo "wrote wrapper $WRAPPER"
# 5. record what we created, then diagnose
printf '%s\n' "${created[@]}" > "$MANIFEST"
echo
"$VENV/bin/infermatrix-copilot" doctor || true
cat <<'EOF'
next steps:
./infermatrix-copilot # conversational chat
./infermatrix-copilot -p "review pr 5134" # one-shot
optional: ln -s "$PWD/infermatrix-copilot" ~/.local/bin/infermatrix-copilot
EOF