This commit is contained in:
Jun-te Kim 2026-05-05 17:05:46 +00:00
parent a093614b68
commit 769689a093

View file

@ -35,24 +35,61 @@ if [[ ! -d .git ]]; then
fi
# --- stage skills-lock.json ----------------------------------------------------
LOCK_FILE="$(mktemp -t skills-lock.XXXXXX.json)"
trap 'rm -f "$LOCK_FILE"' EXIT
if [[ -n "$LOCAL_LOCK" && -f "$LOCAL_LOCK" ]]; then
echo "==> Using local skills-lock.json from $LOCAL_LOCK"
cp "$LOCAL_LOCK" ./skills-lock.json
cp "$LOCAL_LOCK" "$LOCK_FILE"
else
echo "==> Fetching skills-lock.json from $LOCK_URL"
if command -v curl >/dev/null 2>&1; then
curl -fsSL "$LOCK_URL" -o ./skills-lock.json
curl -fsSL "$LOCK_URL" -o "$LOCK_FILE"
elif command -v wget >/dev/null 2>&1; then
wget -qO ./skills-lock.json "$LOCK_URL"
wget -qO "$LOCK_FILE" "$LOCK_URL"
else
echo "error: need curl or wget to fetch skills-lock.json." >&2
exit 1
fi
fi
# --- install -------------------------------------------------------------------
echo "==> Restoring skills from skills-lock.json"
npx --yes skills@latest experimental_install
AGENT_TARGET="claude-code"
# --- install (globally, grouped by source) -------------------------------------
# `skills experimental_install` only restores at project scope. Domna installs
# globally (~/.claude), so we parse the lock and call `skills add` per source
# with the explicit skill list from the lock file.
echo "==> Installing skills globally (~/.claude) from skills-lock.json"
# Group skills by source -> "source<TAB>skill1,skill2,..."
GROUPS="$(node -e '
const lock = JSON.parse(require("fs").readFileSync(process.argv[1], "utf8"));
const bySource = new Map();
for (const [name, entry] of Object.entries(lock.skills || {})) {
if (!entry.source) continue;
if (!bySource.has(entry.source)) bySource.set(entry.source, []);
bySource.get(entry.source).push(name);
}
for (const [src, names] of bySource) {
process.stdout.write(src + "\t" + names.join(",") + "\n");
}
' "$LOCK_FILE")"
if [[ -z "$GROUPS" ]]; then
echo "error: no skills found in lock file." >&2
exit 1
fi
while IFS=$'\t' read -r SOURCE SKILLS; do
[[ -z "$SOURCE" ]] && continue
echo "==> $SOURCE :: $SKILLS"
npx --yes skills@latest add "$SOURCE" \
--skill "$SKILLS" \
--agent "$AGENT_TARGET" \
--copy \
--global \
--yes
done <<< "$GROUPS"
# --- post-install reminder -----------------------------------------------------
cat <<'EOF'
@ -62,6 +99,4 @@ cat <<'EOF'
1. Run /setup-matt-pocock-skills (one-time per repo) to record the issue
tracker, triage labels, and domain-doc layout.
2. Commit skills-lock.json so the rest of the team gets the same pinned
skill versions on their next `skills experimental_install`.
EOF