fix(install): make install self-sufficient + npx skills add from $HOME
Two root causes found via the install log (install-20260623-181416.log): A. install.sh runs link.sh BEFORE install-plugins.sh, and install-plugins never re-linked, so npx/external skill symlinks were missing on a fresh run. Add a final Step 10 that re-runs link.sh (idempotent), so `make plugin`/`make install` finish with nothing left to link by hand. B. `npx skills add` resolves its target (.agents/skills, skills-lock.json) relative to the CWD. Run from the repo (which carries gitignored .agents/ and .claude/), skills landed in $REPO/.agents/skills instead of $HOME/.agents/skills where link.sh looks — self-reinforcing once $REPO/.agents exists. Run `skills add` from $HOME in both install and update paths, and clean the stray repo-local skills dirs (gitignored, safe to rm). Refs LRN-042. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0169vjUD1sP9Nx4ZiCa8wvAw
This commit is contained in:
parent
ed5b54e87e
commit
29c4c9ea67
@ -659,6 +659,11 @@ NPX_SKILLS=(
|
||||
"alchaincyf/find-skills"
|
||||
)
|
||||
|
||||
# `skills add` resolves its target (.agents/skills/, skills-lock.json) RELATIVE
|
||||
# TO THE CWD. Running it from the repo (which carries gitignored .agents/ and
|
||||
# .claude/ dirs) makes skills land in $REPO/.agents/skills instead of
|
||||
# $HOME/.agents/skills — where link.sh expects them — and the bug is
|
||||
# self-reinforcing once $REPO/.agents exists. Always install from $HOME.
|
||||
if ! command -v npx &>/dev/null; then
|
||||
warn "npx not available — skipping external skills"
|
||||
else
|
||||
@ -669,18 +674,28 @@ else
|
||||
ok "$_name already installed ($_dst)"
|
||||
continue
|
||||
fi
|
||||
info "Installing $_name via: npx -y skills add $_src"
|
||||
if npx -y skills add "$_src" 2>/dev/null; then
|
||||
info "Installing $_name via: npx -y skills add $_src (from \$HOME)"
|
||||
if (cd "$HOME" && npx -y skills add "$_src" 2>/dev/null); then
|
||||
if [ -d "$_dst" ]; then
|
||||
ok "$_name installed"
|
||||
else
|
||||
warn "$_name installed but not at expected path $_dst"
|
||||
fi
|
||||
else
|
||||
err "$_name install failed — run manually: npx -y skills add $_src"
|
||||
err "$_name install failed — run manually: (cd \"\$HOME\" && npx -y skills add $_src)"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Earlier runs (before this CWD fix) scattered skills into the repo's gitignored
|
||||
# .agents/skills and .claude/skills. They shadow the canonical $HOME copies and
|
||||
# confuse skill discovery — remove them. Both are gitignored, so this is safe.
|
||||
for _stray in "$REPO/.agents/skills" "$REPO/.claude/skills"; do
|
||||
if [ -d "$_stray" ]; then
|
||||
rm -rf "$_stray"
|
||||
info "Removed stray repo-local skills dir: $_stray"
|
||||
fi
|
||||
done
|
||||
echo ""
|
||||
|
||||
# ============================================================
|
||||
@ -790,6 +805,23 @@ if [ "$ADDED" -eq 1 ]; then
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# ============================================================
|
||||
# STEP 10 — REFRESH SYMLINKS (final, so this script is self-sufficient)
|
||||
# ============================================================
|
||||
# Steps 2/8/8.5 INSTALL skills (gstack submodule, emil/frontend/motion, npx
|
||||
# darwin/find-skills) that link.sh must symlink into ~/.claude/skills/. Since
|
||||
# link.sh runs BEFORE this script in install.sh, those symlinks would be missing
|
||||
# on a fresh run until link.sh is run again by hand. Re-run it here so
|
||||
# `make plugin` (and `make install`) finish complete — nothing left to do.
|
||||
echo "── Step 10: Refreshing symlinks (link.sh) ─────────────────"
|
||||
echo ""
|
||||
if [ -f "$REPO/link.sh" ]; then
|
||||
bash "$REPO/link.sh"
|
||||
else
|
||||
warn "link.sh not found — run it manually to create skill symlinks"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# ============================================================
|
||||
# SUMMARY
|
||||
# ============================================================
|
||||
|
||||
@ -287,10 +287,13 @@ if command -v npx &>/dev/null; then
|
||||
fi
|
||||
# `skills add` is idempotent and pulls latest from the source repo,
|
||||
# which is the closest thing to an update operation the CLI exposes.
|
||||
if npx -y skills add "$_src" 2>/dev/null; then
|
||||
# Run from $HOME: the CLI resolves .agents/skills/ relative to the CWD, so
|
||||
# running from the repo would write into $REPO/.agents/skills (gitignored)
|
||||
# instead of $HOME/.agents/skills where link.sh expects it.
|
||||
if (cd "$HOME" && npx -y skills add "$_src" 2>/dev/null); then
|
||||
ok "$_name refreshed from $_src"
|
||||
else
|
||||
warn "$_name refresh failed — run manually: npx -y skills add $_src"
|
||||
warn "$_name refresh failed — run manually: (cd \"\$HOME\" && npx -y skills add $_src)"
|
||||
fi
|
||||
done
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user