feat: install full skill pack

This commit is contained in:
Andy Dixon
2026-07-06 16:08:36 +01:00
parent f8e3da22cf
commit b3e0d839ed
11 changed files with 1266 additions and 122 deletions
+67 -25
View File
@@ -3,10 +3,11 @@ set -euo pipefail
REPO_SLUG="${1:-${SECURITYAUDIT_REPO:-andydixon/securityaudit-skill}}"
REF="${2:-${SECURITYAUDIT_REF:-main}}"
SKILL_PATH="${SECURITYAUDIT_SKILL_PATH:-securityaudit}"
DEFAULT_SKILLS="securityaudit aitm debullshit summarise"
SKILLS="${SECURITYAUDIT_SKILLS:-${SECURITYAUDIT_SKILL_PATH:-$DEFAULT_SKILLS}}"
SKILLS="${SKILLS//,/ }"
CODEX_HOME_DIR="${CODEX_HOME:-$HOME/.codex}"
DEST_PARENT="$CODEX_HOME_DIR/skills"
DEST="$DEST_PARENT/securityaudit"
say() {
printf '%s\n' "$*"
@@ -21,28 +22,58 @@ need_command() {
command -v "$1" >/dev/null 2>&1 || fail "Missing required command: $1"
}
validate_skill_name() {
skill="$1"
case "$skill" in
""|*[!A-Za-z0-9_-]*)
fail "Invalid skill name: $skill"
;;
esac
}
print_usage() {
say "Restart Codex, then use:"
for skill in $SKILLS; do
case "$skill" in
securityaudit)
say ' $securityaudit'
say ' $securityaudit --fix'
;;
*)
say " \$$skill"
;;
esac
done
}
copy_skill() {
src="$1"
skill="$2"
dest="$DEST_PARENT/$skill"
validate_skill_name "$skill"
[ -f "$src/SKILL.md" ] || fail "Could not find SKILL.md at $src"
grep -q '^name: securityaudit$' "$src/SKILL.md" || fail "SKILL.md does not look like the securityaudit skill"
grep -q "^name: $skill$" "$src/SKILL.md" || fail "SKILL.md at $src does not look like the $skill skill"
mkdir -p "$DEST_PARENT"
stage="$(mktemp -d "$DEST_PARENT/.securityaudit-install.XXXXXX")"
mkdir -p "$stage/securityaudit"
cp -R "$src/." "$stage/securityaudit/"
stage="$(mktemp -d "$DEST_PARENT/.$skill-install.XXXXXX")"
mkdir -p "$stage/$skill"
cp -R "$src/." "$stage/$skill/"
[ -f "$stage/securityaudit/SKILL.md" ] || fail "Install staging failed"
grep -q '^name: securityaudit$' "$stage/securityaudit/SKILL.md" || fail "Install validation failed"
[ -f "$stage/$skill/SKILL.md" ] || fail "Install staging failed for $skill"
grep -q "^name: $skill$" "$stage/$skill/SKILL.md" || fail "Install validation failed for $skill"
if [ -e "$DEST" ]; then
backup="$DEST.backup.$(date +%Y%m%d-%H%M%S)"
say "Existing securityaudit skill found. Backing it up to:"
if [ -e "$dest" ]; then
backup="$dest.backup.$(date +%Y%m%d-%H%M%S)"
say "Existing $skill skill found. Backing it up to:"
say "$backup"
mv "$DEST" "$backup"
mv "$dest" "$backup"
fi
mv "$stage/securityaudit" "$DEST"
mv "$stage/$skill" "$dest"
rmdir "$stage" 2>/dev/null || true
say "Installed $skill to $dest"
}
SCRIPT_PATH="${BASH_SOURCE[0]:-}"
@@ -52,9 +83,15 @@ else
SCRIPT_DIR=""
fi
if [ -n "$SCRIPT_DIR" ] && [ -f "$SCRIPT_DIR/$SKILL_PATH/SKILL.md" ]; then
say "Installing securityaudit from local checkout..."
copy_skill "$SCRIPT_DIR/$SKILL_PATH"
if [ -n "$SCRIPT_DIR" ] && [ -f "$SCRIPT_DIR/securityaudit/SKILL.md" ]; then
say "Installing skills from local checkout..."
installed_any=false
for skill in $SKILLS; do
[ -f "$SCRIPT_DIR/$skill/SKILL.md" ] || fail "Could not find $skill/SKILL.md in local checkout"
copy_skill "$SCRIPT_DIR/$skill" "$skill"
installed_any=true
done
[ "$installed_any" = true ] || fail "No skills requested"
else
need_command curl
need_command tar
@@ -68,19 +105,24 @@ else
archive="$tmp/repo.tar.gz"
url="https://github.com/$REPO_SLUG/archive/refs/heads/$REF.tar.gz"
say "Downloading securityaudit from $REPO_SLUG ($REF)..."
say "Downloading skills from $REPO_SLUG ($REF)..."
curl -fsSL "$url" -o "$archive"
tar -xzf "$archive" -C "$tmp"
src="$(find "$tmp" -path "*/$SKILL_PATH/SKILL.md" -print -quit)"
[ -n "$src" ] || fail "Could not find $SKILL_PATH/SKILL.md in the downloaded repo"
copy_skill "$(dirname "$src")"
installed_any=false
for skill in $SKILLS; do
src="$(find "$tmp" -path "*/$skill/SKILL.md" -print -quit)"
[ -n "$src" ] || fail "Could not find $skill/SKILL.md in the downloaded repo"
copy_skill "$(dirname "$src")" "$skill"
installed_any=true
done
[ "$installed_any" = true ] || fail "No skills requested"
fi
say ""
say "Installed securityaudit to:"
say "$DEST"
say "Installed skills:"
for skill in $SKILLS; do
say " $skill -> $DEST_PARENT/$skill"
done
say ""
say "Restart Codex, then use:"
say ' $securityaudit'
say ' $securityaudit --fix'
print_usage