-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·243 lines (209 loc) · 7.11 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·243 lines (209 loc) · 7.11 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
#!/usr/bin/env bash
# =============================================================================
# ACF — Universal Multi-Agent Skill Installer
# =============================================================================
# Installs the ACF orchestrator (acf/SKILL.md) and all 9 sub-skills
# (01-context-load/ through 09-graph-scope/) into a target project, for one or
# more AI coding agents.
#
# Usage:
# ./install.sh /target/project # auto-detect existing agent dirs
# ./install.sh /target/project --all # install to ALL supported agents
# ./install.sh /target/project --agent devin
#
# Supported agents and their skill directory paths:
# devin → .devin/skills/
# claude → .claude/skills/
# cursor → .cursor/skills/
# codex → .codex/skills/
# agents → .agents/skills/
# opencode → .opencode/skills/
#
# The script is idempotent: re-running it overwrites in place safely.
# =============================================================================
set -euo pipefail
# -----------------------------------------------------------------------------
# Configuration
# -----------------------------------------------------------------------------
# Resolve the directory where this script lives (the ACF repo root).
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Read the version from the VERSION file (single source of truth).
VERSION_FILE="${SCRIPT_DIR}/VERSION"
ACF_VERSION="unknown"
if [[ -f "$VERSION_FILE" ]]; then
ACF_VERSION="$(tr -d '[:space:]' < "$VERSION_FILE")"
fi
# Source skill locations inside the ACF repo.
# - Orchestrator lives at .devin/skills/acf/
# - The 9 sub-skills live at skills/01-context-load/ ... skills/09-graph-scope/
ORCHESTRATOR_SRC="${SCRIPT_DIR}/.devin/skills/acf"
SUBSKILLS_SRC="${SCRIPT_DIR}/skills"
# Associative mapping: agent name → relative skill directory path.
declare -A AGENT_PATHS=(
["devin"]=".devin/skills"
["claude"]=".claude/skills"
["cursor"]=".cursor/skills"
["codex"]=".codex/skills"
["agents"]=".agents/skills"
["opencode"]=".opencode/skills"
)
# Ordered list of agent names (for deterministic output).
AGENT_ORDER=(devin claude cursor codex agents opencode)
# -----------------------------------------------------------------------------
# Helpers
# -----------------------------------------------------------------------------
# Print a usage message to stderr.
usage() {
cat >&2 <<EOF
Usage: $(basename "$0") <target-project> [--all | --agent <name>]
$(basename "$0") --version
$(basename "$0") -h | --help
Arguments:
<target-project> Path to the project where ACF skills will be installed.
Flags:
--all Install to ALL supported agent directories (creating them
if they do not exist).
--agent <name> Install only to the specified agent's directory.
<name> must be one of: ${AGENT_ORDER[*]}
--version Print the ACF version and exit.
-h, --help Print this help message and exit.
If no flag is given, the script auto-detects which agent directories already
exist in the target project and installs to all of them.
EOF
}
# Print an error and exit 1.
die() {
echo "ERROR: $*" >&2
exit 1
}
# Install the orchestrator + sub-skills into one agent's skill directory.
# $1 = target project root (absolute)
# $2 = agent name
install_for_agent() {
local target_root="$1"
local agent="$2"
local rel_path="${AGENT_PATHS[$agent]:-}"
[[ -n "$rel_path" ]] || die "Unknown agent: ${agent}"
local dest="${target_root}/${rel_path}"
# Create the destination directory if it does not exist.
mkdir -p "$dest"
# Copy the orchestrator (acf/).
if [[ -d "$ORCHESTRATOR_SRC" ]]; then
cp -R "$ORCHESTRATOR_SRC" "$dest/"
else
die "Orchestrator source not found: $ORCHESTRATOR_SRC"
fi
# Copy all 9 sub-skills (01-context-load/ through 09-graph-scope/).
# Skip acf/ — it's the orchestrator, already copied above.
if [[ -d "$SUBSKILLS_SRC" ]]; then
local sub
for sub in "$SUBSKILLS_SRC"/*/; do
[[ -d "$sub" ]] || continue
local base
base="$(basename "$sub")"
[[ "$base" == "acf" ]] && continue
cp -R "$sub" "$dest/"
done
else
die "Sub-skills source not found: $SUBSKILLS_SRC"
fi
echo " ✓ Installed to ${agent} → ${rel_path}/"
}
# -----------------------------------------------------------------------------
# Argument parsing
# -----------------------------------------------------------------------------
# Handle --version and --help before requiring a target path.
if [[ $# -ge 1 ]]; then
case "$1" in
--version)
echo "ACF v${ACF_VERSION}"
exit 0
;;
-h|--help)
usage
exit 0
;;
esac
fi
# Need at least one argument (the target path).
if [[ $# -lt 1 ]]; then
usage
exit 1
fi
# First positional argument is the target project path.
TARGET="$1"
shift
# Parse optional flags.
MODE="auto" # auto | all | single
SINGLE_AGENT=""
while [[ $# -gt 0 ]]; do
case "$1" in
--all)
MODE="all"
shift
;;
--agent)
[[ $# -ge 2 ]] || { usage; die "--agent requires a value"; }
MODE="single"
SINGLE_AGENT="$2"
shift 2
# Validate the agent name.
valid=0
for a in "${AGENT_ORDER[@]}"; do
[[ "$a" == "$SINGLE_AGENT" ]] && valid=1
done
[[ $valid -eq 1 ]] || die "Unknown agent '${SINGLE_AGENT}'. Valid: ${AGENT_ORDER[*]}"
;;
*)
usage
die "Unknown argument: $1"
;;
esac
done
# Save the original target for error messages before resolving.
TARGET_RAW="$TARGET"
# Validate the target path exists before resolving to an absolute path.
[[ -d "$TARGET_RAW" ]] || die "Target path does not exist or is not a directory: ${TARGET_RAW}"
# Resolve to an absolute path.
TARGET="$(cd "$TARGET_RAW" && pwd)"
# -----------------------------------------------------------------------------
# Determine which agents to install for
# -----------------------------------------------------------------------------
SELECTED_AGENTS=()
case "$MODE" in
all)
# Install to every supported agent.
SELECTED_AGENTS=("${AGENT_ORDER[@]}")
;;
single)
SELECTED_AGENTS=("$SINGLE_AGENT")
;;
auto)
# Auto-detect: check which agent directories already exist in the target.
for agent in "${AGENT_ORDER[@]}"; do
rel="${AGENT_PATHS[$agent]}"
if [[ -d "${TARGET}/${rel}" ]]; then
SELECTED_AGENTS+=("$agent")
fi
done
if [[ ${#SELECTED_AGENTS[@]} -eq 0 ]]; then
echo "No agent skill directories detected in ${TARGET}."
echo "Use --all to install to all supported agents, or --agent <name>."
exit 1
fi
;;
esac
# -----------------------------------------------------------------------------
# Install
# -----------------------------------------------------------------------------
echo "ACF skill installer"
echo "Target: ${TARGET}"
echo "Source: ${SCRIPT_DIR}"
echo "Agents: ${SELECTED_AGENTS[*]}"
echo ""
for agent in "${SELECTED_AGENTS[@]}"; do
install_for_agent "$TARGET" "$agent"
done
echo ""
echo "Done. Installed ACF orchestrator + 9 sub-skills to ${#SELECTED_AGENTS[@]} agent(s)."
exit 0