Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·214 lines (192 loc) · 9.53 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·214 lines (192 loc) · 9.53 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
#!/usr/bin/env bash
set -euo pipefail
# Claude SEO Installer
# Wraps everything in main() to prevent partial execution on network failure
main() {
SKILL_DIR="${HOME}/.claude/skills/seo"
AGENT_DIR="${HOME}/.claude/agents"
REPO_URL="https://github.com/AgriciDaniel/claude-seo"
# Pin to a specific release tag to prevent silent updates from main.
# This default MUST be bumped on every release. CI guard
# (tests/test_manifest_consistency.py) enforces this matches plugin.json.
# Override: CLAUDE_SEO_TAG=main bash install.sh
REPO_TAG="${CLAUDE_SEO_TAG:-v3.0.0}"
echo "════════════════════════════════════════"
echo "║ Claude SEO - Installer ║"
echo "║ Claude Code SEO Skill ║"
echo "════════════════════════════════════════"
echo ""
# Check prerequisites. The runtime launcher performs cross-platform Python
# resolution and validates the minimum supported version.
command -v git >/dev/null 2>&1 || { echo "✗ Git is required but not installed."; exit 1; }
# Create directories
mkdir -p "${SKILL_DIR}"
mkdir -p "${AGENT_DIR}"
# Clone or update
TEMP_DIR=$(mktemp -d)
cleanup() { rm -rf -- "${TEMP_DIR}"; }
trap cleanup EXIT
echo "↓ Downloading Claude SEO (${REPO_TAG})..."
git clone --depth 1 --branch "${REPO_TAG}" "${REPO_URL}" "${TEMP_DIR}/claude-seo" 2>/dev/null
# Copy skill files
echo "→ Installing skill files..."
cp -r "${TEMP_DIR}/claude-seo/skills/seo/"* "${SKILL_DIR}/"
# Copy sub-skills
if [ -d "${TEMP_DIR}/claude-seo/skills" ]; then
for skill_dir in "${TEMP_DIR}/claude-seo/skills"/*/; do
skill_name=$(basename "${skill_dir}")
target="${HOME}/.claude/skills/${skill_name}"
mkdir -p "${target}"
cp -r "${skill_dir}"* "${target}/"
done
fi
# Copy schema templates
if [ -d "${TEMP_DIR}/claude-seo/schema" ]; then
mkdir -p "${SKILL_DIR}/schema"
cp -r "${TEMP_DIR}/claude-seo/schema/"* "${SKILL_DIR}/schema/"
fi
# Copy deterministic data files consumed by bundled scripts such as
# seo_updates.py. Keep the repository-relative data/ layout intact.
if [ -d "${TEMP_DIR}/claude-seo/data" ]; then
mkdir -p "${SKILL_DIR}/data"
cp -r "${TEMP_DIR}/claude-seo/data/"* "${SKILL_DIR}/data/"
fi
# Copy reference docs
if [ -d "${TEMP_DIR}/claude-seo/pdf" ]; then
mkdir -p "${SKILL_DIR}/pdf"
cp -r "${TEMP_DIR}/claude-seo/pdf/"* "${SKILL_DIR}/pdf/"
fi
# Copy agents
echo "→ Installing subagents..."
cp -r "${TEMP_DIR}/claude-seo/agents/"*.md "${AGENT_DIR}/" 2>/dev/null || true
# Copy shared scripts
if [ -d "${TEMP_DIR}/claude-seo/scripts" ]; then
mkdir -p "${SKILL_DIR}/scripts"
cp -r "${TEMP_DIR}/claude-seo/scripts/"* "${SKILL_DIR}/scripts/"
fi
# Copy the stable runtime launcher. It ships in scripts/ (never a top-level
# bin/, which hosted marketplaces reject) and resolves runtime.py as a
# sibling, so the manual layout below already matches the repository layout.
if [ -f "${TEMP_DIR}/claude-seo/scripts/claude-seo" ]; then
mkdir -p "${SKILL_DIR}/scripts"
cp "${TEMP_DIR}/claude-seo/scripts/claude-seo" "${SKILL_DIR}/scripts/claude-seo"
chmod +x "${SKILL_DIR}/scripts/claude-seo"
fi
# Copy hooks
if [ -d "${TEMP_DIR}/claude-seo/hooks" ]; then
mkdir -p "${SKILL_DIR}/hooks"
cp -r "${TEMP_DIR}/claude-seo/hooks/"* "${SKILL_DIR}/hooks/"
chmod +x "${SKILL_DIR}/hooks/"*.sh 2>/dev/null || true
chmod +x "${SKILL_DIR}/hooks/"*.py 2>/dev/null || true
# Manual installs copy hook files only; enforcement loads through the plugin manifest.
echo " Note: hook enforcement requires plugin install (/plugin install ${REPO_URL}); manual hook copy is best-effort."
fi
# Copy extensions (optional add-ons: dataforseo, banana)
if [ -d "${TEMP_DIR}/claude-seo/extensions" ]; then
echo "=> Installing extensions..."
for ext_dir in "${TEMP_DIR}/claude-seo/extensions"/*/; do
[ -d "${ext_dir}" ] || continue
ext_name=$(basename "${ext_dir}")
# Extension skills
if [ -d "${ext_dir}skills" ]; then
for ext_skill in "${ext_dir}skills"/*/; do
[ -d "${ext_skill}" ] || continue
ext_skill_name=$(basename "${ext_skill}")
target="${HOME}/.claude/skills/${ext_skill_name}"
mkdir -p "${target}"
cp -r "${ext_skill}"* "${target}/"
done
fi
# Extension agents
if [ -d "${ext_dir}agents" ]; then
cp -r "${ext_dir}agents/"*.md "${AGENT_DIR}/" 2>/dev/null || true
fi
# Extension references
if [ -d "${ext_dir}references" ]; then
mkdir -p "${SKILL_DIR}/extensions/${ext_name}/references"
cp -r "${ext_dir}references/"* "${SKILL_DIR}/extensions/${ext_name}/references/"
fi
# Extension scripts
if [ -d "${ext_dir}scripts" ]; then
mkdir -p "${SKILL_DIR}/extensions/${ext_name}/scripts"
cp -r "${ext_dir}scripts/"* "${SKILL_DIR}/extensions/${ext_name}/scripts/"
fi
done
fi
# Copy requirements.txt to skill dir so users can retry later
cp "${TEMP_DIR}/claude-seo/requirements.txt" "${SKILL_DIR}/requirements.txt" 2>/dev/null || true
cp "${TEMP_DIR}/claude-seo/.claude-plugin/plugin.json" "${SKILL_DIR}/runtime-plugin.json" 2>/dev/null || true
# Manual installs have no ${CLAUDE_PLUGIN_ROOT}, so rewrite the canonical
# launcher token to the absolute installed path. Rewrite only exact files
# copied from this checkout during this install. The substitution is
# idempotent: it consumes the plugin-root token, so a second pass matches
# nothing. In a POSIX basic regular expression "$" is literal unless it ends
# the expression, so ${CLAUDE_PLUGIN_ROOT} needs no escaping here.
# Reference paths are opened with the Read tool, which does not expand
# variables, so ${CLAUDE_PLUGIN_ROOT}/skills/ becomes the absolute path.
skills_root_esc=$(printf '%s' "${HOME}/.claude/skills/" | sed 's/[#&\\]/\\&/g')
rewrite_doc() {
local doc="$1" temp_doc
temp_doc="${doc}.claude-seo-tmp"
sed -e "s#\${CLAUDE_PLUGIN_ROOT}/skills/#${skills_root_esc}#g" \
-e 's#"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" run#"$HOME/.claude/skills/seo/scripts/claude-seo" run#g' \
-e 's#"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" setup#"$HOME/.claude/skills/seo/scripts/claude-seo" setup#g' \
-e 's#"${CLAUDE_PLUGIN_ROOT}/scripts/claude-seo" doctor#"$HOME/.claude/skills/seo/scripts/claude-seo" doctor#g' \
"${doc}" > "${temp_doc}"
mv "${temp_doc}" "${doc}"
}
for source_root in "${TEMP_DIR}/claude-seo/skills"/*; do
[ -d "${source_root}" ] || continue
skill_name=$(basename "${source_root}")
while IFS= read -r -d '' source_doc; do
relative_doc=${source_doc#"${source_root}/"}
doc="${HOME}/.claude/skills/${skill_name}/${relative_doc}"
[ -f "${doc}" ] && rewrite_doc "${doc}"
done < <(find "${source_root}" -type f -name '*.md' -print0)
done
for source_root in "${TEMP_DIR}/claude-seo/extensions"/*/skills/*; do
[ -d "${source_root}" ] || continue
skill_name=$(basename "${source_root}")
while IFS= read -r -d '' source_doc; do
relative_doc=${source_doc#"${source_root}/"}
doc="${HOME}/.claude/skills/${skill_name}/${relative_doc}"
[ -f "${doc}" ] && rewrite_doc "${doc}"
done < <(find "${source_root}" -type f -name '*.md' -print0)
done
for source_root in "${TEMP_DIR}/claude-seo/extensions"/*/references; do
[ -d "${source_root}" ] || continue
ext_name=$(basename "$(dirname "${source_root}")")
while IFS= read -r -d '' source_doc; do
relative_doc=${source_doc#"${source_root}/"}
doc="${SKILL_DIR}/extensions/${ext_name}/references/${relative_doc}"
[ -f "${doc}" ] && rewrite_doc "${doc}"
done < <(find "${source_root}" -type f -name '*.md' -print0)
done
for source_doc in "${TEMP_DIR}/claude-seo/agents"/*.md "${TEMP_DIR}/claude-seo/extensions"/*/agents/*.md; do
[ -f "${source_doc}" ] || continue
doc="${AGENT_DIR}/$(basename "${source_doc}")"
[ -f "${doc}" ] && rewrite_doc "${doc}"
done
echo "→ Creating isolated Python runtime..."
set +e
"${SKILL_DIR}/scripts/claude-seo" setup
runtime_status=$?
set -e
if [ "${runtime_status}" -ne 0 ] && [ "${runtime_status}" -ne 10 ]; then
echo "✗ Core Python runtime setup failed. Installation is incomplete." >&2
exit 1
elif [ "${runtime_status}" -eq 10 ]; then
echo "⚠ Core runtime installed, but Chromium setup is incomplete." >&2
fi
echo ""
echo "✓ Claude SEO installed successfully!"
echo ""
echo "Usage:"
echo " 1. Start Claude Code: claude"
echo " 2. Run commands: /seo audit https://example.com"
echo ""
echo "Python deps location: ${SKILL_DIR}/requirements.txt"
echo "Inspect remote scripts before piping them to bash."
echo "To uninstall: curl -fsSL ${REPO_URL}/raw/main/uninstall.sh | bash"
}
main "$@"