-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·87 lines (76 loc) · 2.84 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·87 lines (76 loc) · 2.84 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
#!/bin/sh
# Install the API7 Gateway (API7 Enterprise Edition) 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 a live API7
# Enterprise Edition gateway through the a7 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/a7/master/install.sh | sh
#
# Install somewhere else (e.g. a project-local Cursor rules dir):
# curl -fsSL https://raw.githubusercontent.com/api7/a7/master/install.sh | sh -s -- --dir ./.cursor/rules
# SKILLS_DIR=~/.config/opencode/skills sh -c "$(curl -fsSL https://raw.githubusercontent.com/api7/a7/master/install.sh)"
set -eu
REPO="api7/a7"
BRANCH="master"
LABEL="API7 Gateway"
# 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/api7-gateway/ai-agent-skills"