-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·150 lines (127 loc) · 4.39 KB
/
install.sh
File metadata and controls
executable file
·150 lines (127 loc) · 4.39 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
#!/usr/bin/env bash
set -euo pipefail
# agent-persona installer
# Works both locally (git clone) and via curl:
# curl -fsSL https://raw.githubusercontent.com/GoodFarming/agent-persona/main/install.sh | bash
# Pin a version/tag:
# AGENT_PERSONA_VERSION=v1.0.0 bash install.sh
VERSION="${AGENT_PERSONA_VERSION:-main}"
REPO_URL="https://raw.githubusercontent.com/GoodFarming/agent-persona/${VERSION}"
BIN_DIR="${HOME}/.local/bin"
SHARE_DIR="${HOME}/.local/share/agent-persona"
info() { echo "[install] $*"; }
warn() { echo "[install] WARNING: $*" >&2; }
die() { echo "[install] ERROR: $*" >&2; exit 1; }
# Detect if running from local clone or curl
SCRIPT_DIR=""
if [[ -n "${BASH_SOURCE[0]:-}" && -f "${BASH_SOURCE[0]}" ]]; then
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
fi
# Check for curl or wget
fetch() {
local url="$1" dest="$2"
if command -v curl >/dev/null 2>&1; then
curl -fsSL "$url" -o "$dest"
elif command -v wget >/dev/null 2>&1; then
wget -q "$url" -O "$dest"
else
die "Neither curl nor wget found. Please install one."
fi
}
# Create directories
mkdir -p "$BIN_DIR" "$SHARE_DIR/.personas" "$SHARE_DIR/.personas/.shared"
# Install launcher
if [[ -n "$SCRIPT_DIR" && -f "$SCRIPT_DIR/agent-persona" ]]; then
# Local install
cp "$SCRIPT_DIR/agent-persona" "$BIN_DIR/agent-persona"
info "Installed from local: $BIN_DIR/agent-persona"
else
# Remote install
info "Downloading agent-persona..."
fetch "$REPO_URL/agent-persona" "$BIN_DIR/agent-persona"
info "Installed from GitHub: $BIN_DIR/agent-persona"
fi
chmod +x "$BIN_DIR/agent-persona"
# Create tool shims
for shim in codex-persona claude-persona gemini-persona opencode-persona; do
ln -sf "$BIN_DIR/agent-persona" "$BIN_DIR/$shim"
done
info "Created shims: codex-persona, claude-persona, gemini-persona, opencode-persona"
# Install personas
install_persona() {
local name="$1"
local src="$2" # local path or empty for remote
if [[ -d "$SHARE_DIR/.personas/$name" ]]; then
info "Persona exists, skipping: $name"
return
fi
mkdir -p "$SHARE_DIR/.personas/$name"
if [[ -n "$src" && -f "$src/AGENTS.md" ]]; then
cp "$src/AGENTS.md" "$SHARE_DIR/.personas/$name/"
[[ -f "$src/persona.json" ]] && cp "$src/persona.json" "$SHARE_DIR/.personas/$name/"
else
fetch "$REPO_URL/.personas/$name/AGENTS.md" "$SHARE_DIR/.personas/$name/AGENTS.md"
fi
info "Installed persona: $name"
}
# Install shared blocks used by shipped personas
install_shared_file() {
local rel="$1" # path relative to .personas/.shared/
local src="$2" # local base dir or empty for remote
local dest="$SHARE_DIR/.personas/.shared/$rel"
if [[ -f "$dest" ]]; then
info "Shared file exists, skipping: .shared/$rel"
return
fi
mkdir -p "$(dirname "$dest")"
if [[ -n "$src" && -f "$src/$rel" ]]; then
cp "$src/$rel" "$dest"
else
fetch "$REPO_URL/.personas/.shared/$rel" "$dest"
fi
info "Installed shared file: .shared/$rel"
}
if [[ -n "$SCRIPT_DIR" && -d "$SCRIPT_DIR/.personas" ]]; then
SHARED_SRC=""
[[ -d "$SCRIPT_DIR/.personas/.shared" ]] && SHARED_SRC="$SCRIPT_DIR/.personas/.shared"
install_shared_file "agent-contract-posture.md" "$SHARED_SRC"
install_shared_file "communication-discipline.md" "$SHARED_SRC"
install_shared_file "knowledge-dilligence.md" "$SHARED_SRC"
install_shared_file "continuity.md" "$SHARED_SRC"
install_shared_file "meta.AGENTS.md" "$SHARED_SRC"
for persona in "$SCRIPT_DIR/.personas"/*; do
[[ -d "$persona" ]] || continue
install_persona "$(basename "$persona")" "$persona"
done
else
install_shared_file "agent-contract-posture.md" ""
install_shared_file "communication-discipline.md" ""
install_shared_file "knowledge-dilligence.md" ""
install_shared_file "continuity.md" ""
install_shared_file "meta.AGENTS.md" ""
install_persona "blank" ""
install_persona "template" ""
fi
# Check PATH
if [[ ":$PATH:" != *":$BIN_DIR:"* ]]; then
warn "$BIN_DIR is not in PATH"
echo ""
echo "Add to your shell config (~/.bashrc or ~/.zshrc):"
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
echo ""
echo "Then restart your shell or run:"
echo " source ~/.bashrc"
echo ""
fi
echo ""
info "Installation complete!"
echo ""
echo "Verify with:"
echo " agent-persona doctor"
echo " agent-persona --list"
echo ""
echo "Quick start:"
echo " agent-persona claude blank"
echo ""
echo "Documentation:"
echo " https://github.com/GoodFarming/agent-persona"