-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplanet-codex-startup
More file actions
78 lines (68 loc) · 3.04 KB
/
planet-codex-startup
File metadata and controls
78 lines (68 loc) · 3.04 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
#!/usr/bin/env bash
set -euo pipefail
REPO="open-learning-exchange/planet"
WORKDIR="/workspace/planet"
# --- 1) GitHub CLI ------------------------------------------------------------
if ! command -v gh >/dev/null 2>&1; then
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
| sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg >/dev/null
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] \
https://cli.github.com/packages stable main" \
| sudo tee /etc/apt/sources.list.d/github-cli.list >/dev/null
sudo apt-get update -qq
sudo apt-get install -y gh >/dev/null
fi
# --- 2) Git remotes -----------------------------------------------------------
if [ -d "${WORKDIR}" ]; then
cd "${WORKDIR}"
if git remote get-url origin >/dev/null 2>&1; then
git remote set-url origin "https://github.com/${REPO}.git"
else
git remote add origin "https://github.com/${REPO}.git"
fi
gh repo set-default "${REPO}" || true
cd -
fi
# --- 3) Python venv + llm -----------------------------------------------------
if [ ! -d "$HOME/.llm-env" ]; then
python3 -m venv "$HOME/.llm-env"
fi
# shellcheck disable=SC1091
source "$HOME/.llm-env/bin/activate"
python3 -m pip -q install --upgrade pip llm llm-anthropic llm-gemini
# Auto-activate venv in future shells
if ! grep -q 'source ~/.llm-env/bin/activate' "$HOME/.bashrc" 2>/dev/null; then
echo 'source ~/.llm-env/bin/activate' >> "$HOME/.bashrc"
fi
# --- 4) Keys from Codex secrets -----------------------------------------------
[ -n "${OPENAI_API_KEY:-}" ] && llm keys set openai --value "$OPENAI_API_KEY" || true
[ -n "${GOOGLE_API_KEY:-}" ] && llm keys set google --value "$GOOGLE_API_KEY" || true
[ -n "${GOOGLE_API_KEY:-}" ] && llm keys set gemini --value "$GOOGLE_API_KEY" || true
[ -n "${ANTHROPIC_API_KEY:-}" ] && llm keys set anthropic --value "$ANTHROPIC_API_KEY" || true
# --- 5) Review script ---------------------------------------------------------
if [ ! -x /usr/local/bin/review-core ]; then
sudo curl -fsSL https://raw.githubusercontent.com/ole-vi/ai-code-review/main/review \
-o /usr/local/bin/review-core
sudo chmod +x /usr/local/bin/review-core
fi
sudo tee /usr/local/bin/review >/dev/null <<'SH'
#!/usr/bin/env bash
set -euo pipefail
want_models=""
for arg in "$@"; do
if [ "$arg" = "--models" ]; then want_models="set"; break; fi
done
if [ -z "${want_models}" ]; then
MODELS="${LLM_MODELS:-gpt-4o,gemini/gemini-1.5-flash-latest,anthropic/claude-3-7-sonnet-latest}"
exec /usr/local/bin/review-core --models "$MODELS" "$@"
else
exec /usr/local/bin/review-core "$@"
fi
SH
sudo chmod +x /usr/local/bin/review
# --- 6) Persist model list ----------------------------------------------------
if ! grep -q 'export LLM_MODELS=' "$HOME/.bashrc" 2>/dev/null; then
echo 'export LLM_MODELS="gpt-4o,gemini/gemini-1.5-flash-latest,anthropic/claude-3-7-sonnet-latest"' >> "$HOME/.bashrc"
fi
echo "✅ Setup complete. Run inside repo: review master...HEAD"