-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
274 lines (249 loc) · 7.86 KB
/
Copy pathinstall.sh
File metadata and controls
274 lines (249 loc) · 7.86 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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#!/usr/bin/env bash
# install.sh: install the auditor-suite into every detected harness.
#
# - Reads skills from this repo's skills/<skill>/ directory (in-tree;
# no per-skill clone needed).
# - Detects native-skill harnesses by their config directories:
# Claude Code -> ~/.claude -> writes ~/.claude/skills/<skill>/
# Codex -> ~/.codex -> writes ~/.codex/skills/<skill>/
# Cursor -> ~/.cursor -> writes ~/.cursor/skills/<skill>/
# pi -> ~/.pi -> via the neutral Agent Skills path
# OpenClaw -> ~/.openclaw -> via the neutral Agent Skills path
# - When pi or OpenClaw is detected, writes to the neutral
# ~/.agents/skills/<skill>/ path. Both harnesses read this path
# natively per the Agent Skills standard at agentskills.io. Future
# AgentSkills-compatible harnesses inherit support for free.
# - For each of the seven auditors, symlinks the runtime payload from
# skills/<skill>/ into every detected harness: SKILL.md plus the
# references/, scripts/, and assets/ folders the skill reads and runs.
# - Idempotent. Re-run anytime.
# - Bash 3.2 compatible (macOS default). No associative arrays.
#
# Usage:
# git clone https://github.com/hannsxpeter/auditor-suite && bash auditor-suite/install.sh
# or run from inside an existing clone: bash install.sh
#
# Flags:
# -v verbose (show skipped-because-correct steps)
# -h help
set -eu
VERBOSE=0
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
HUB_DIR="$SCRIPT_DIR"
SKILLS_DIR="$HUB_DIR/skills"
TIMESTAMP="$(date +%Y%m%d-%H%M%S)"
# Seven auditors, and the runtime payload each one needs.
SKILLS="codeauditor secauditor dbauditor llmauditor seoauditor uiauditor uxauditor"
PAYLOAD="SKILL.md references scripts assets"
# Platforms: name and skills-dir path. Parallel lists keep bash 3.2 compat.
# Agent_Skills is the neutral Agent Skills standard path read by pi,
# OpenClaw, and any future AgentSkills-compatible harness.
PLATFORM_NAMES="Claude_Code Codex Cursor Agent_Skills"
PLATFORM_DIRS="${HOME}/.claude/skills ${HOME}/.codex/skills ${HOME}/.cursor/skills ${HOME}/.agents/skills"
# ANSI colors only when stdout is a TTY.
if [ -t 1 ]; then
C_RESET="$(printf '\033[0m')"
C_BOLD="$(printf '\033[1m')"
C_DIM="$(printf '\033[2m')"
C_GREEN="$(printf '\033[32m')"
C_YELLOW="$(printf '\033[33m')"
C_RED="$(printf '\033[31m')"
C_CYAN="$(printf '\033[36m')"
else
C_RESET=""; C_BOLD=""; C_DIM=""; C_GREEN=""; C_YELLOW=""; C_RED=""; C_CYAN=""
fi
usage() {
cat <<EOF
auditor-suite installer
Usage: install.sh [-v] [-h]
-v verbose output
-h show this help
Detects Claude Code, Codex, Cursor, pi, and OpenClaw; installs the
seven auditor-suite skills into every detected harness via symlinks to
each skill's SKILL.md, references/, scripts/, and assets/ in this repo. pi and OpenClaw
are served via the neutral Agent Skills path at ~/.agents/skills/.
EOF
}
while [ $# -gt 0 ]; do
case "$1" in
-v|--verbose) VERBOSE=1 ;;
-h|--help) usage; exit 0 ;;
*) printf "%sunknown flag: %s%s\n" "$C_RED" "$1" "$C_RESET" >&2; usage >&2; exit 2 ;;
esac
shift
done
log() { printf "%s\n" "$*"; }
info() { printf "%s%s%s\n" "$C_DIM" "$*" "$C_RESET"; }
ok() { printf " %sok%s %s\n" "$C_GREEN" "$C_RESET" "$*"; }
warn() { printf " %swarn%s %s\n" "$C_YELLOW" "$C_RESET" "$*"; }
err() { printf " %sfail%s %s\n" "$C_RED" "$C_RESET" "$*"; }
step() { printf " %s..%s %s\n" "$C_CYAN" "$C_RESET" "$*"; }
vstep() { [ "$VERBOSE" = "1" ] && printf " %s..%s %s\n" "$C_DIM" "$C_RESET" "$*" || true; }
# Look up the skills-dir for a platform name. Returns "" if not detected.
platform_dir_for() {
local name i j n d
name="$1"
i=1
for n in $PLATFORM_NAMES; do
if [ "$n" = "$name" ]; then
j=1
for d in $PLATFORM_DIRS; do
if [ "$j" = "$i" ]; then
printf "%s" "$d"
return 0
fi
j=$((j + 1))
done
fi
i=$((i + 1))
done
return 1
}
# Human label for a platform name.
platform_label_for() {
local name markers
name="$1"
case "$name" in
Agent_Skills)
markers=""
[ -d "${HOME}/.pi" ] && markers="pi"
if [ -d "${HOME}/.openclaw" ]; then
if [ -n "$markers" ]; then markers="$markers, OpenClaw"; else markers="OpenClaw"; fi
fi
if [ -n "$markers" ]; then
printf "Agent Skills (%s)" "$markers"
else
printf "Agent Skills"
fi
;;
*)
printf '%s' "$name" | tr '_' ' '
;;
esac
}
# Detection.
DETECTED_PLATFORMS=""
for name in $PLATFORM_NAMES; do
dir="$(platform_dir_for "$name")"
parent="$(dirname "$dir")"
case "$name" in
Agent_Skills)
if [ -d "${HOME}/.pi" ] || [ -d "${HOME}/.openclaw" ]; then
DETECTED_PLATFORMS="$DETECTED_PLATFORMS $name"
fi
;;
*)
if [ -d "$parent" ]; then
DETECTED_PLATFORMS="$DETECTED_PLATFORMS $name"
fi
;;
esac
done
if [ -z "$DETECTED_PLATFORMS" ]; then
printf "%sNo Claude Code, Codex, Cursor, pi, or OpenClaw install detected.%s\n" "$C_RED" "$C_RESET" >&2
printf "Expected one of ~/.claude, ~/.codex, ~/.cursor, ~/.pi, ~/.openclaw.\n" >&2
exit 1
fi
if [ ! -d "$SKILLS_DIR" ]; then
printf "%sskills/ directory not found at %s%s\n" "$C_RED" "$SKILLS_DIR" "$C_RESET" >&2
printf "Run install.sh from inside an auditor-suite clone.\n" >&2
exit 1
fi
log ""
printf "%sauditor-suite installer%s\n" "$C_BOLD" "$C_RESET"
log ""
info "skills dir : $SKILLS_DIR"
detected_label=""
for n in $DETECTED_PLATFORMS; do
detected_label="$detected_label, $(platform_label_for "$n")"
done
detected_label="${detected_label#, }"
info "platforms : $detected_label"
log ""
INSTALLED_COUNT=0
SKIPPED_COUNT=0
PLATFORM_LINK_COUNT=0
# Symlink one item from src to dst, backing up any non-symlink target.
link_item() {
local src dst label current backup
src="$1"
dst="$2"
label="$3"
if [ ! -e "$src" ]; then
err "missing source: $src"
return 1
fi
if [ -L "$dst" ]; then
current="$(readlink "$dst" 2>/dev/null || true)"
if [ "$current" = "$src" ]; then
vstep "$label already linked"
return 0
fi
rm -f "$dst"
elif [ -e "$dst" ]; then
backup="$(dirname "$dst").backup-$TIMESTAMP"
mkdir -p "$backup"
mv "$dst" "$backup/"
warn "backed up existing $label -> $backup/"
fi
ln -s "$src" "$dst"
return 0
}
install_skill_into_platform() {
local skill platform_name platform_dir src dst_dir item
skill="$1"
platform_name="$2"
platform_dir="$3"
src="$SKILLS_DIR/$skill"
dst_dir="$platform_dir/$skill"
if [ ! -f "$src/SKILL.md" ]; then
err "$skill: SKILL.md missing at $src/SKILL.md"
return 1
fi
mkdir -p "$dst_dir"
for item in $PAYLOAD; do
[ -e "$src/$item" ] || continue
if ! link_item "$src/$item" "$dst_dir/$item" "$item"; then
return 1
fi
done
PLATFORM_LINK_COUNT=$((PLATFORM_LINK_COUNT + 1))
return 0
}
for skill in $SKILLS; do
log ""
printf "%s%s%s\n" "$C_BOLD" "$skill" "$C_RESET"
if [ ! -d "$SKILLS_DIR/$skill" ]; then
err "$skill: missing at $SKILLS_DIR/$skill"
SKIPPED_COUNT=$((SKIPPED_COUNT + 1))
continue
fi
any_ok=0
for name in $DETECTED_PLATFORMS; do
pdir="$(platform_dir_for "$name")"
label="$(platform_label_for "$name")"
if install_skill_into_platform "$skill" "$name" "$pdir"; then
ok "$label"
any_ok=1
fi
done
if [ "$any_ok" = "1" ]; then
INSTALLED_COUNT=$((INSTALLED_COUNT + 1))
else
SKIPPED_COUNT=$((SKIPPED_COUNT + 1))
fi
done
PLATFORM_COUNT=0
for n in $DETECTED_PLATFORMS; do
PLATFORM_COUNT=$((PLATFORM_COUNT + 1))
done
log ""
printf "%ssummary%s\n" "$C_BOLD" "$C_RESET"
printf " %s%d skills installed%s across %d platforms\n" "$C_GREEN" "$INSTALLED_COUNT" "$C_RESET" "$PLATFORM_COUNT"
if [ "$SKIPPED_COUNT" -gt 0 ]; then
printf " %s%d skipped%s\n" "$C_YELLOW" "$SKIPPED_COUNT" "$C_RESET"
fi
log ""
info "Re-run anytime; install.sh is idempotent."
info "Uninstall: bash uninstall.sh"
log ""