-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add install.sh for one-line agent-skills install #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| #!/bin/sh | ||
| # Install the Apache APISIX AI agent skills into your AI coding agent. | ||
| # | ||
| # Each skill is a SKILL.md knowledge pack that teaches an agent (Claude Code, | ||
| # Cursor, Copilot, Windsurf, OpenCode, ...) how to configure Apache APISIX | ||
| # through the a6 CLI. This script copies them into your agent's skills directory. | ||
| # | ||
| # Quick start (installs into ~/.claude/skills for Claude Code): | ||
| # curl -fsSL https://raw.githubusercontent.com/api7/a6/main/install.sh | sh | ||
| # | ||
| # Install somewhere else (e.g. a project-local Cursor rules dir): | ||
| # curl -fsSL https://raw.githubusercontent.com/api7/a6/main/install.sh | sh -s -- --dir ./.cursor/rules | ||
| # SKILLS_DIR=~/.config/opencode/skills sh -c "$(curl -fsSL https://raw.githubusercontent.com/api7/a6/main/install.sh)" | ||
| set -eu | ||
|
|
||
| REPO="api7/a6" | ||
| BRANCH="main" | ||
| LABEL="Apache APISIX" | ||
|
|
||
| # Target directory. Default: Claude Code personal skills. Override with | ||
| # SKILLS_DIR=... or --dir <path>. | ||
| SKILLS_DIR="${SKILLS_DIR:-$HOME/.claude/skills}" | ||
|
|
||
| while [ $# -gt 0 ]; do | ||
| case "$1" in | ||
| --dir) SKILLS_DIR="${2:?--dir needs a path}"; shift 2 ;; | ||
| --dir=*) | ||
| SKILLS_DIR="${1#*=}" | ||
| [ -n "$SKILLS_DIR" ] || { echo "install.sh: --dir needs a path" >&2; exit 1; } | ||
| shift | ||
| ;; | ||
| -h | --help) | ||
| echo "Usage: install.sh [--dir <path>] (default: \$HOME/.claude/skills)" | ||
| exit 0 | ||
| ;; | ||
| *) echo "install.sh: unknown option '$1'" >&2; exit 1 ;; | ||
| esac | ||
| done | ||
|
|
||
| if command -v curl >/dev/null 2>&1; then | ||
| fetch() { curl -fsSL "$1"; } | ||
| elif command -v wget >/dev/null 2>&1; then | ||
| fetch() { wget -qO- "$1"; } | ||
| else | ||
| echo "install.sh: need curl or wget on your PATH." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Installing ${LABEL} agent skills into ${SKILLS_DIR} ..." | ||
|
|
||
| TMP="$(mktemp -d)" | ||
| trap 'rm -rf "$TMP"' EXIT INT TERM | ||
|
|
||
| # Download the repo tarball (no git required) and extract just the skills. | ||
| fetch "https://codeload.github.com/${REPO}/tar.gz/refs/heads/${BRANCH}" >"$TMP/repo.tgz" || | ||
| { echo "install.sh: download failed." >&2; exit 1; } | ||
| tar -xzf "$TMP/repo.tgz" -C "$TMP" | ||
|
|
||
| SRC="$(find "$TMP" -maxdepth 2 -type d -name skills | head -n 1)" | ||
| if [ -z "$SRC" ] || [ ! -d "$SRC" ]; then | ||
| echo "install.sh: could not find a skills/ directory in the download." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| mkdir -p "$SKILLS_DIR" | ||
| count=0 | ||
| for dir in "$SRC"/*/; do | ||
| [ -f "${dir}SKILL.md" ] || continue | ||
| name="$(basename "$dir")" | ||
| rm -rf "${SKILLS_DIR}/${name}" | ||
| cp -R "$dir" "${SKILLS_DIR}/${name}" | ||
| count=$((count + 1)) | ||
| done | ||
|
|
||
| if [ "$count" -eq 0 ]; then | ||
| echo "install.sh: no SKILL.md packs found to install." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Installed ${count} skills to ${SKILLS_DIR}" | ||
| echo | ||
| echo "Next: ask your AI coding agent to configure ${LABEL} in plain language, e.g." | ||
| echo " \"add key-auth to my /orders route and rate-limit it to 100 requests per minute\"" | ||
| echo | ||
| echo "Browse the catalog: https://docs.api7.ai/apisix/ai-agent-skills" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Guard against empty
SKILLS_DIRinrm -rfto prevent accidental root deletion.If
SKILLS_DIRis set to an empty string (e.g.,--dir=orSKILLS_DIR=""), this line expands torm -rf "/${name}", deleting a top-level directory. Whilemkdir -p ""on line 59 would likely fail and exit first underset -eu, adding an explicit:?guard is a low-cost safety net.🛡️ Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 Shellcheck (0.11.0)
[warning] 64-64: Use "${var:?}" to ensure this never expands to / .
(SC2115)
🤖 Prompt for AI Agents
Source: Linters/SAST tools