167 lines
4.2 KiB
Bash
167 lines
4.2 KiB
Bash
#!/bin/bash
|
|
|
|
# Target directory defaults to .cursor/rules in the current working directory,
|
|
# but can be overridden by passing an argument.
|
|
TARGET_DIR="${1:-.cursor/rules}"
|
|
|
|
# Base URL for raw github files
|
|
BASE_URL="https://raw.githubusercontent.com/addyosmani/agent-skills/main/skills"
|
|
|
|
# Array of all 24 skills in the repository
|
|
SKILLS=(
|
|
"api-and-interface-design"
|
|
"browser-testing-with-devtools"
|
|
"ci-cd-and-automation"
|
|
"code-review-and-quality"
|
|
"code-simplification"
|
|
"context-engineering"
|
|
"debugging-and-error-recovery"
|
|
"deprecation-and-migration"
|
|
"documentation-and-adrs"
|
|
"doubt-driven-development"
|
|
"frontend-ui-engineering"
|
|
"git-workflow-and-versioning"
|
|
"idea-refine"
|
|
"incremental-implementation"
|
|
"interview-me"
|
|
"observability-and-instrumentation"
|
|
"performance-optimization"
|
|
"planning-and-task-breakdown"
|
|
"security-and-hardening"
|
|
"shipping-and-launch"
|
|
"source-driven-development"
|
|
"spec-driven-development"
|
|
"test-driven-development"
|
|
"using-agent-skills"
|
|
)
|
|
|
|
# Helper function to download file
|
|
download_file() {
|
|
local url="$1"
|
|
local dest="$2"
|
|
|
|
if command -v curl >/dev/null 2>&1; then
|
|
curl -sSL -o "$dest" "$url"
|
|
elif command -v wget >/dev/null 2>&1; then
|
|
wget -q -O "$dest" "$url"
|
|
else
|
|
echo "Error: Neither curl nor wget is installed." >&2
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Initialize active status array
|
|
ACTIVE=()
|
|
for ((i=0; i<${#SKILLS[@]}; i++)); do
|
|
ACTIVE[i]=0
|
|
done
|
|
|
|
# Auto-detect existing skills in target directory
|
|
any_exists=false
|
|
if [ -d "$TARGET_DIR" ]; then
|
|
for ((i=0; i<${#SKILLS[@]}; i++)); do
|
|
if [ -f "$TARGET_DIR/${SKILLS[i]}.md" ]; then
|
|
any_exists=true
|
|
ACTIVE[i]=1
|
|
fi
|
|
done
|
|
fi
|
|
|
|
# If no skills are currently present, enable the 3 default recommended skills
|
|
if [ "$any_exists" = false ]; then
|
|
for ((i=0; i<${#SKILLS[@]}; i++)); do
|
|
slug="${SKILLS[i]}"
|
|
if [ "$slug" = "test-driven-development" ] || [ "$slug" = "code-review-and-quality" ] || [ "$slug" = "incremental-implementation" ]; then
|
|
ACTIVE[i]=1
|
|
fi
|
|
done
|
|
fi
|
|
|
|
# Interactive selection menu loop
|
|
while true; do
|
|
clear
|
|
echo "===================================================="
|
|
echo " Cursor Agent-Skills Setup "
|
|
echo "===================================================="
|
|
echo "Target Directory: $TARGET_DIR"
|
|
echo ""
|
|
echo "Select skills to activate (toggle with number):"
|
|
echo ""
|
|
|
|
for ((i=0; i<${#SKILLS[@]}; i++)); do
|
|
idx=$((i+1))
|
|
status="[ ]"
|
|
if [ "${ACTIVE[i]}" -eq 1 ]; then
|
|
status="[x]"
|
|
fi
|
|
printf "%2d) %s %s\n" "$idx" "$status" "${SKILLS[i]}"
|
|
done
|
|
|
|
echo ""
|
|
echo "Commands:"
|
|
echo " a - Select ALL skills"
|
|
echo " n - Select NONE (clear all)"
|
|
echo " d - Confirm and apply changes (or press Enter)"
|
|
echo " q - Quit/Cancel without changes"
|
|
echo ""
|
|
read -p "Your choice: " choice
|
|
|
|
if [ -z "$choice" ] || [ "$choice" = "d" ] || [ "$choice" = "D" ]; then
|
|
break
|
|
elif [ "$choice" = "a" ] || [ "$choice" = "A" ]; then
|
|
for ((i=0; i<${#SKILLS[@]}; i++)); do
|
|
ACTIVE[i]=1
|
|
done
|
|
elif [ "$choice" = "n" ] || [ "$choice" = "N" ]; then
|
|
for ((i=0; i<${#SKILLS[@]}; i++)); do
|
|
ACTIVE[i]=0
|
|
done
|
|
elif [ "$choice" = "q" ] || [ "$choice" = "Q" ]; then
|
|
echo "Cancelled. No changes made."
|
|
exit 0
|
|
elif [[ "$choice" =~ ^[0-9]+$ ]] && [ "$choice" -ge 1 ] && [ "$choice" -le "${#SKILLS[@]}" ]; then
|
|
idx=$((choice-1))
|
|
if [ "${ACTIVE[idx]}" -eq 1 ]; then
|
|
ACTIVE[idx]=0
|
|
else
|
|
ACTIVE[idx]=1
|
|
fi
|
|
else
|
|
echo "Invalid option. Redrawing..."
|
|
sleep 1
|
|
fi
|
|
done
|
|
|
|
# Ensure directory exists if needed
|
|
if [ ! -d "$TARGET_DIR" ]; then
|
|
echo ""
|
|
echo "Creating directory: $TARGET_DIR"
|
|
mkdir -p "$TARGET_DIR"
|
|
fi
|
|
|
|
echo ""
|
|
echo "Applying changes..."
|
|
|
|
for ((i=0; i<${#SKILLS[@]}; i++)); do
|
|
slug="${SKILLS[i]}"
|
|
dest_path="$TARGET_DIR/$slug.md"
|
|
|
|
if [ "${ACTIVE[i]}" -eq 1 ]; then
|
|
url="$BASE_URL/$slug/SKILL.md"
|
|
echo "Downloading $slug..."
|
|
if download_file "$url" "$dest_path"; then
|
|
echo "Successfully activated/updated $slug.md"
|
|
else
|
|
echo "Failed to download $slug.md"
|
|
fi
|
|
else
|
|
if [ -f "$dest_path" ]; then
|
|
echo "Deactivating/removing $slug.md..."
|
|
rm -f "$dest_path"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
echo ""
|
|
echo "Done!"
|