From 769689a0937cb37e39d8e73e0baed388373b63fb Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Tue, 5 May 2026 17:05:46 +0000 Subject: [PATCH] 0.0.3 --- setup.sh | 51 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/setup.sh b/setup.sh index d2a3067..ba8db1e 100755 --- a/setup.sh +++ b/setup.sh @@ -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 -> "sourceskill1,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