-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·89 lines (80 loc) · 2.6 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·89 lines (80 loc) · 2.6 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
#!/usr/bin/env bash
# One-command setup for expert-mentor.
#
# ./install.sh
#
# Installs:
# - the `mentor` command into ~/.local/bin
# - the skill into ~/.claude/skills and ~/.config/opencode/skills
# - ~/.local/bin on PATH (appended to your shell rc, idempotent)
#
# Override locations with env vars: BIN_DIR, CLAUDE_SKILLS, OPENCODE_SKILLS, PYTHON
set -euo pipefail
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
PYTHON=${PYTHON:-python3}
BIN_DIR=${BIN_DIR:-$HOME/.local/bin}
CLAUDE_SKILLS=${CLAUDE_SKILLS:-$HOME/.claude/skills}
OPENCODE_SKILLS=${OPENCODE_SKILLS:-$HOME/.config/opencode/skills}
MARKER="# >>> expert-mentor setup >>>"
say() { printf '%s\n' "$*"; }
say "expert-mentor installer"
say " source: $ROOT"
say ""
if ! command -v "$PYTHON" >/dev/null 2>&1; then
echo "error: python3 is required but was not found on PATH" >&2
exit 1
fi
# 1. Launcher on PATH
mkdir -p "$BIN_DIR"
chmod +x "$ROOT/bin/mentor" "$ROOT/scripts/expert_mentor.py" "$ROOT/scripts/selftest.py"
ln -sf "$ROOT/bin/mentor" "$BIN_DIR/mentor"
say "[1/4] installed launcher: $BIN_DIR/mentor"
# 2. Skill (opencode auto-loads ~/.claude/skills too)
say "[2/4] installing skill"
"$PYTHON" "$ROOT/scripts/expert_mentor.py" skill \
--dir "$CLAUDE_SKILLS" --dir "$OPENCODE_SKILLS" \
| sed 's/^/ /'
# 3. Ensure ~/.local/bin is on PATH
case ":$PATH:" in
*":$BIN_DIR:"*) PATH_OK=1 ;;
*) PATH_OK=0 ;;
esac
if [ "$PATH_OK" -eq 0 ]; then
RC=""
for candidate in "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.profile"; do
[ -e "$candidate" ] && RC="$candidate" && break
done
RC=${RC:-$HOME/.bashrc}
if [ -f "$RC" ] && grep -qF "$MARKER" "$RC"; then
say "[3/4] PATH: already configured in $RC"
else
{
printf '\n%s\n' "$MARKER"
printf 'export PATH="%s:$PATH"\n' "$BIN_DIR"
printf '%s\n' "# <<< expert-mentor setup <<<"
} >> "$RC"
say "[3/4] PATH: added $BIN_DIR to $RC"
fi
else
say "[3/4] PATH: $BIN_DIR already on PATH"
fi
# 4. Health check
say "[4/4] running doctor"
say ""
# shellcheck disable=SC2086
"$PYTHON" "$ROOT/scripts/expert_mentor.py" doctor || true
say ""
say "Setup complete."
say ""
if [ "$PATH_OK" -eq 0 ]; then
say "For this shell, run: export PATH=\"$BIN_DIR:\$PATH\""
say "or open a new terminal."
say ""
fi
say "Try it:"
say " mentor --field 'quantum computing' --level beginner"
say " mentor save rustbuddy --field 'Rust' --level intermediate"
say " mentor ollama rusttutor --field 'Rust' --compact"
say " mentor doctor"
say ""
say "Prefer an isolated install? 'pipx install .' also provides the 'mentor' command."