-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup
More file actions
executable file
·180 lines (167 loc) · 6.33 KB
/
Copy pathsetup
File metadata and controls
executable file
·180 lines (167 loc) · 6.33 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
#!/usr/bin/env bash
# animus-skills setup — install Animus CLI + Animus Skills for one or more AI agent hosts.
#
# Usage:
# ./setup # auto-detect installed hosts (defaults to claude if none)
# ./setup --host claude # Claude Code
# ./setup --host codex # OpenAI Codex CLI
# ./setup --host opencode # OpenCode
# ./setup --host cursor # Cursor
# ./setup --host slate # Slate
# ./setup --host kiro # Kiro
# ./setup --host all # install for every detected host
# ./setup --no-cli # skip animus CLI install (use existing binary)
# ./setup --no-mcp # skip writing .mcp.json into the current project
set -euo pipefail
SRC="$(cd "$(dirname "$0")" && pwd)"
HOSTS=()
INSTALL_CLI=1
WRITE_MCP=1
while (("$#")); do
case "$1" in
--host)
HOSTS+=("$2"); shift 2;;
--host=*)
HOSTS+=("${1#*=}"); shift;;
--no-cli)
INSTALL_CLI=0; shift;;
--no-mcp)
WRITE_MCP=0; shift;;
-h|--help)
sed -n '2,12p' "$0" | sed 's/^# \{0,1\}//'; exit 0;;
*)
echo "unknown arg: $1" >&2; exit 2;;
esac
done
# ---------- 1. Install Animus CLI ----------
if [[ $INSTALL_CLI -eq 1 ]]; then
if command -v animus >/dev/null 2>&1; then
echo "✓ animus already installed: $(command -v animus) ($(animus --version 2>/dev/null | head -1))"
else
echo "→ installing animus CLI..."
curl -fsSL https://raw.githubusercontent.com/launchapp-dev/animus-cli/main/scripts/install.sh | bash
export PATH="$HOME/.local/bin:$PATH"
fi
fi
# ---------- 2. Resolve host list ----------
if [[ ${#HOSTS[@]} -eq 0 ]] || [[ "${HOSTS[0]:-}" == "auto" ]]; then
HOSTS=()
command -v claude >/dev/null 2>&1 && HOSTS+=("claude")
command -v codex >/dev/null 2>&1 && HOSTS+=("codex")
command -v opencode >/dev/null 2>&1 && HOSTS+=("opencode")
command -v cursor >/dev/null 2>&1 && HOSTS+=("cursor")
command -v slate >/dev/null 2>&1 && HOSTS+=("slate")
command -v kiro >/dev/null 2>&1 && HOSTS+=("kiro")
if [[ ${#HOSTS[@]} -eq 0 ]]; then
echo "→ no agent CLI detected on PATH; defaulting to claude"
HOSTS=("claude")
fi
fi
if [[ "${HOSTS[0]}" == "all" ]]; then
HOSTS=(claude codex opencode cursor slate kiro)
fi
# ---------- 3. Install skills into each host ----------
# Hosts discover skills FLAT at <host-skills-dir>/<skill-name>/SKILL.md.
# This repo nests them at skills/<skill-name>/SKILL.md, so we symlink each
# skill individually rather than the repo root.
host_skills_dir() {
case "$1" in
claude|claude-code) echo "$HOME/.claude/skills" ;;
codex) echo "$HOME/.codex/skills" ;;
opencode) echo "$HOME/.config/opencode/skills" ;;
cursor) echo "$HOME/.cursor/skills" ;;
slate) echo "$HOME/.slate/skills" ;;
kiro) echo "$HOME/.kiro/skills" ;;
*) echo ""; return 1 ;;
esac
}
for host in "${HOSTS[@]}"; do
host_dir="$(host_skills_dir "$host")" || { echo "✗ unknown host: $host" >&2; continue; }
mkdir -p "$host_dir"
# Clean up any stale whole-repo symlink at $host_dir/animus-skills.
# Detection: it's a symlink whose target has skills/ but no SKILL.md at root.
# That shape is the previous broken install; harmless to remove either way.
legacy="$host_dir/animus-skills"
if [[ -L "$legacy" ]]; then
legacy_target="$(readlink "$legacy")"
if [[ -d "$legacy_target/skills" ]] && [[ ! -f "$legacy_target/SKILL.md" ]]; then
rm "$legacy"
echo "→ $host: removed legacy whole-repo symlink at $legacy (was → $legacy_target)"
fi
fi
# Clean up dangling symlinks pointing into a (renamed) animus-skills clone.
# Pre-2.1.0 created un-prefixed names like <host>/skills/getting-started; the
# rename to animus-getting-started broke the target. Match either the current
# repo name (animus-skills) or its prior name (ao-skills), and only remove
# links that no longer resolve.
for entry in "$host_dir"/*; do
[[ -L "$entry" ]] || continue
target="$(readlink "$entry")"
case "$target" in
*"animus-skills/skills/"*|*"ao-skills/skills/"*) ;;
*) continue ;;
esac
[[ -e "$entry" ]] && continue # link still resolves; skip
rm "$entry"
echo "→ $host: removed dangling symlink $entry (was → $target)"
done
linked=0; skipped=0
for skill_path in "$SRC/skills"/*/; do
skill="$(basename "$skill_path")"
dest="$host_dir/$skill"
if [[ -L "$dest" ]]; then
cur="$(readlink "$dest")"
if [[ "$cur" == "${skill_path%/}" ]]; then
((linked++)) || true
continue
fi
# Resolve both ends to absolute paths so different paths to the same
# SKILL.md (e.g. two clones) are treated as already-installed rather than
# a conflict.
if [[ -f "$cur/SKILL.md" ]] && [[ -f "${skill_path%/}/SKILL.md" ]]; then
echo " ✓ $host/$skill: already linked (different source: $cur)"
((linked++)) || true
continue
fi
echo " ⚠ $host/$skill: symlink target invalid ($cur), leaving alone"
((skipped++)) || true
continue
fi
if [[ -e "$dest" ]]; then
echo " ⚠ $host/$skill: already exists (not a symlink), leaving alone"
((skipped++)) || true
continue
fi
ln -s "${skill_path%/}" "$dest"
((linked++)) || true
done
echo "✓ $host: $linked skill(s) linked into $host_dir${skipped:+, $skipped skipped}"
done
# ---------- 4. Optional: write .mcp.json for the current project ----------
if [[ $WRITE_MCP -eq 1 ]] && [[ -d ".git" ]] && [[ "$(pwd)" != "$SRC" ]]; then
if [[ -e ".mcp.json" ]]; then
echo "→ .mcp.json already exists in $(pwd) — leaving it alone"
else
cat > .mcp.json <<'JSON'
{
"mcpServers": {
"animus": {
"command": "animus",
"args": ["--project-root", ".", "mcp", "serve"]
}
}
}
JSON
echo "✓ wrote .mcp.json (animus MCP server) into $(pwd)"
fi
fi
# ---------- 5. Final report ----------
echo ""
echo "Animus + Animus Skills setup complete."
echo " Hosts: ${HOSTS[*]}"
echo " CLI: $(command -v animus 2>/dev/null || echo '[install pending]')"
echo ""
echo "Next:"
echo " 1. Restart your agent (e.g. Claude Code, Codex)."
echo " 2. From a project root, run /animus-setup to scaffold .animus/ and your first workflow."
echo " 3. Verify MCP: ask the agent to call animus.daemon.status."