refactor(toggle-external,profile): one tool roster, split arms, shared gstack helpers

code-clean B5 (enable_tool split into enable_gstack/
enable_external_single/enable_pack), B7 (enable_skill into
enable_gstack_skill/enable_linked_skill/enable_plugin_skill), B9
(cmd_show into _show_entries/_show_plain/_show_grouped, `_show_plain`
ends with an explicit return 0), B18 (locals), B19 (comment).

/refactor C4: tool_kind/tool_source replace the 3 hand-copied name
lists with the MANAGED_TOOLS roster (exact-match loop), and disable_* is
split to mirror enable_*.

/refactor C5: gstack_skills/gstack_parked_names/gstack_park/
gstack_unpark move into lib/gstack-removed.sh, the only sourced file the
fixture suites copy, and profile.sh and toggle-external.sh both use
them.

496-run golden capture identical; make test 47 green, shellcheck 0.
This commit is contained in:
bchanot committed 2026-10-12 22:51:41 +02:00
1 parent 4c966ebdfc
commit 84446612ae
3 files changed
+225 -147

No files matched your search

+50
View File
@@ -19,6 +19,12 @@
# house permissions.deny is stricter (BDR-095) # house permissions.deny is stricter (BDR-095)
# design-shotgun mockups need OPENAI_API_KEY, absent # design-shotgun mockups need OPENAI_API_KEY, absent
# #
# Also hosts the gstack helpers the two scripts share (gstack_skills and
# the park/unpark moves below). They live in this file because it is the
# only one the fixture suites copy next to profile.sh / toggle-external.sh:
# a new sourced file would be missing there. Each takes its directories as
# arguments (no reliance on the caller's globals).
#
# No `set -euo pipefail` here (sourced lib, mirrors lib/detect-plugins.sh). # No `set -euo pipefail` here (sourced lib, mirrors lib/detect-plugins.sh).
# ============================================================ # ============================================================
@@ -33,3 +39,47 @@ gstack_is_removed() {
done done
return 1 return 1
} }
# gstack_skills <gstack_src> — prints the directory basenames under
# <gstack_src>/*/ that hold a SKILL.md; nothing when the dir is absent.
# Source of truth for "which skills belong to gstack".
gstack_skills() {
local src="$1" d
[ -d "$src" ] || return 0
for d in "$src"/*/; do
[ -f "${d}SKILL.md" ] || continue
basename "$d"
done
}
# gstack_parked_names <disabled_dir> — prints <name> for every
# <disabled_dir>/gstack__<name> entry (a dangling symlink is skipped).
gstack_parked_names() {
local entry
[ -d "$1" ] || return 0
for entry in "$1"/gstack__*; do
[ -e "$entry" ] || continue
basename "$entry" | sed 's/^gstack__//'
done
}
# gstack_park <skills_dir> <disabled_dir> <name> — moves skills/<name> to
# skills-disabled/gstack__<name>. A stale destination is clobbered first:
# gstack ./setup creates skills/<name>/ as directories, so mv onto an
# existing dir would nest it (gstack__<name>/<name>/) instead of renaming.
# Content is symlinks to the submodule, `gstack ./setup` regenerates it.
# Call as a plain statement (never `|| …`, `if`, `!`): errexit must stay on.
gstack_park() {
local skills_dir="$1" disabled_dir="$2" name="$3"
rm -rf "$disabled_dir/gstack__$name"
mv "$skills_dir/$name" "$disabled_dir/gstack__$name"
}
# gstack_unpark <skills_dir> <disabled_dir> <name> — moves
# skills-disabled/gstack__<name> back to skills/<name>, replacing whatever
# sits there. Same plain-statement rule as gstack_park.
gstack_unpark() {
local skills_dir="$1" disabled_dir="$2" name="$3"
rm -rf "${skills_dir:?}/${name:?}"
mv "$disabled_dir/gstack__$name" "$skills_dir/$name"
}
+77 -63
View File
@@ -58,7 +58,9 @@ ACTIVE_CACHE="$REPO/.active-profile" # statusline reads this — keep fast (sin
DEFAULT_PROFILE="full" # profile in force when none is selected (cache absent, empty, or legacy "none") DEFAULT_PROFILE="full" # profile in force when none is selected (cache absent, empty, or legacy "none")
# GSTACK_REMOVED + gstack_is_removed() — single source, honored by every # GSTACK_REMOVED + gstack_is_removed() — single source, honored by every
# "bring gstack back" path below (enable_all_gstack, enable_skill). # "bring gstack back" path below (enable_all_gstack, enable_skill) — plus the
# gstack helpers shared with toggle-external.sh (gstack_skills, gstack_park,
# gstack_unpark, gstack_parked_names).
# shellcheck source=lib/gstack-removed.sh disable=SC1091 # shellcheck source=lib/gstack-removed.sh disable=SC1091
source "$(dirname "${BASH_SOURCE[0]}")/gstack-removed.sh" source "$(dirname "${BASH_SOURCE[0]}")/gstack-removed.sh"
@@ -181,16 +183,6 @@ read_profile() {
done < "$file" done < "$file"
} }
# All skills bundled in skills-external/gstack/
gstack_skills() {
local src="$REPO/skills-external/gstack"
[ -d "$src" ] || return 0
for d in "$src"/*/; do
[ -f "${d}SKILL.md" ] || continue
basename "$d"
done
}
# Profile description (line starting with "# DESC: …") # Profile description (line starting with "# DESC: …")
profile_desc() { profile_desc() {
local file="$1" local file="$1"
@@ -318,17 +310,15 @@ profile_match() {
# ── Enable / disable ────────────────────────────────────── # ── Enable / disable ──────────────────────────────────────
enable_skill() { # Enables a gstack skill: unpark it, or link it from the submodule.
local skill="$1" type="$2" enable_gstack_skill() {
case "$type" in local skill="$1"
gstack)
if gstack_is_removed "$skill"; then if gstack_is_removed "$skill"; then
warn "refusing to enable removed skill: $skill (lib/gstack-removed.sh \ warn "refusing to enable removed skill: $skill (lib/gstack-removed.sh \
— a profile census failure, not a crash)" — a profile census failure, not a crash)"
return 0 return 0
elif [ -e "$DISABLED_DIR/gstack__$skill" ]; then elif [ -e "$DISABLED_DIR/gstack__$skill" ]; then
rm -rf "${SKILLS_DIR:?}/${skill:?}" gstack_unpark "$SKILLS_DIR" "$DISABLED_DIR" "$skill"
mv "$DISABLED_DIR/gstack__$skill" "$SKILLS_DIR/$skill"
ok "enabled: $skill" ok "enabled: $skill"
elif [ -e "$DISABLED_DIR/$skill" ]; then elif [ -e "$DISABLED_DIR/$skill" ]; then
rm -rf "${SKILLS_DIR:?}/${skill:?}" rm -rf "${SKILLS_DIR:?}/${skill:?}"
@@ -350,8 +340,11 @@ enable_skill() {
else else
warn "missing: $skill — not found in gstack submodule ($GSTACK_SRC)" warn "missing: $skill — not found in gstack submodule ($GSTACK_SRC)"
fi fi
;; }
external|personal)
# Enables an external|personal skill: unpark it, or recreate the symlink.
enable_linked_skill() {
local skill="$1" type="$2"
if [ -e "$DISABLED_DIR/$skill" ]; then if [ -e "$DISABLED_DIR/$skill" ]; then
rm -rf "${SKILLS_DIR:?}/${skill:?}" rm -rf "${SKILLS_DIR:?}/${skill:?}"
mv "$DISABLED_DIR/$skill" "$SKILLS_DIR/$skill" mv "$DISABLED_DIR/$skill" "$SKILLS_DIR/$skill"
@@ -366,8 +359,11 @@ enable_skill() {
else else
warn "missing: $skill ($type)" warn "missing: $skill ($type)"
fi fi
;; }
plugin@*)
# Enables a plugin@<marketplace> skill through the claude CLI.
enable_plugin_skill() {
local skill="$1" type="$2"
# type holds the marketplace: plugin@<marketplace> # type holds the marketplace: plugin@<marketplace>
local marketplace="${type#plugin@}" local marketplace="${type#plugin@}"
if [ "$(skill_status "$skill" "$type")" = "enabled" ]; then if [ "$(skill_status "$skill" "$type")" = "enabled" ]; then
@@ -384,7 +380,14 @@ enable_skill() {
else else
info "claude CLI not in PATH — manual: claude plugin enable ${skill}@${marketplace}" info "claude CLI not in PATH — manual: claude plugin enable ${skill}@${marketplace}"
fi fi
;; }
enable_skill() {
local skill="$1" type="$2"
case "$type" in
gstack) enable_gstack_skill "$skill" ;;
external|personal) enable_linked_skill "$skill" "$type" ;;
plugin@*) enable_plugin_skill "$skill" "$type" ;;
plugin) plugin)
# No marketplace specified — purely advisory. # No marketplace specified — purely advisory.
if [ "$(skill_status "$skill" plugin)" = "enabled" ]; then if [ "$(skill_status "$skill" plugin)" = "enabled" ]; then
@@ -419,8 +422,7 @@ disable_skill() {
gstack) gstack)
if [ -e "$SKILLS_DIR/$skill" ]; then if [ -e "$SKILLS_DIR/$skill" ]; then
mkdir -p "$DISABLED_DIR" mkdir -p "$DISABLED_DIR"
rm -rf "$DISABLED_DIR/gstack__$skill" gstack_park "$SKILLS_DIR" "$DISABLED_DIR" "$skill"
mv "$SKILLS_DIR/$skill" "$DISABLED_DIR/gstack__$skill"
ok "disabled: $skill" ok "disabled: $skill"
fi fi
;; ;;
@@ -477,20 +479,17 @@ disable_skill() {
# stdout so the caller can report it accurately; per-skill confirmations # stdout so the caller can report it accurately; per-skill confirmations
# go to stderr so that count is the only thing captured with `$(...)`. # go to stderr so that count is the only thing captured with `$(...)`.
enable_all_gstack() { enable_all_gstack() {
local entry name restored=0 local name restored=0
[ -d "$DISABLED_DIR" ] || { echo 0; return 0; } [ -d "$DISABLED_DIR" ] || { echo 0; return 0; }
for entry in "$DISABLED_DIR"/gstack__*; do while IFS= read -r name; do
[ -e "$entry" ] || continue
name="$(basename "$entry" | sed 's/^gstack__//')"
if gstack_is_removed "$name"; then if gstack_is_removed "$name"; then
info "skipped (removed by policy, lib/gstack-removed.sh): $name" >&2 info "skipped (removed by policy, lib/gstack-removed.sh): $name" >&2
continue continue
fi fi
rm -rf "${SKILLS_DIR:?}/${name:?}" gstack_unpark "$SKILLS_DIR" "$DISABLED_DIR" "$name"
mv "$entry" "$SKILLS_DIR/$name"
ok "re-enabled: $name" >&2 ok "re-enabled: $name" >&2
restored=$((restored + 1)) restored=$((restored + 1))
done done < <(gstack_parked_names "$DISABLED_DIR")
echo "$restored" echo "$restored"
} }
@@ -504,7 +503,7 @@ disable_gstack_not_in() {
while read -r name; do while read -r name; do
[ -n "$name" ] || continue [ -n "$name" ] || continue
grep -qx "$name" "$keep_file" || disable_skill "$name" gstack grep -qx "$name" "$keep_file" || disable_skill "$name" gstack
done < <(gstack_skills | sort -u) done < <(gstack_skills "$GSTACK_SRC" | sort -u)
rm -f "$keep_file" rm -f "$keep_file"
} }
@@ -572,29 +571,58 @@ cmd_list() {
done done
} }
# Snapshot of a profile's entries, claude-free: "<cat><TAB><name>" lines,
# canonical name. A plugin's marketplace (plugin@<mp>) collapses to the
# category "plugin".
_show_entries() {
local skill type cat
while IFS=$'\t' read -r skill type; do
case "$type" in plugin@*|plugin) cat=plugin ;; *) cat="$type" ;; esac
printf '%s\t%s\n' "$cat" "$skill"
done < <(read_profile "$1")
}
# --plain: parsable contract for the design gate. One "<type><TAB><name>"
# per line, grouped by type, NO status, NO claude calls.
_show_plain() {
local entries=() cat e line
while IFS= read -r line; do entries+=("$line"); done < <(_show_entries "$1")
for cat in gstack external personal plugin mcp cli; do
for e in "${entries[@]}"; do
[ "${e%%$'\t'*}" = "$cat" ] && printf '%s\t%s\n' "$cat" "${e#*$'\t'}"
done
done
return 0
}
# Grouped by type, fixed order; empty groups skipped. Canonical name +
# runtime status (existing skill_status — degrades to disabled if no claude).
_show_grouped() {
local entries=() cat e line names skill status
while IFS= read -r line; do entries+=("$line"); done < <(_show_entries "$1")
for cat in gstack external personal plugin mcp cli; do
names=()
for e in "${entries[@]}"; do
[ "${e%%$'\t'*}" = "$cat" ] && names+=("${e#*$'\t'}")
done
[ "${#names[@]}" -eq 0 ] && continue
printf '%s (%d):\n' "$cat" "${#names[@]}"
for skill in "${names[@]}"; do
status="$(skill_status "$skill" "$cat")"
printf ' %-24s %s\n' "$skill" "$status"
done
done
return 0
}
cmd_show() { cmd_show() {
local prof="$1" plain=0 local prof="$1" plain=0
[ "${2:-}" = "--plain" ] && plain=1 [ "${2:-}" = "--plain" ] && plain=1
local file="$PROFILES_DIR/$prof.profile" local file="$PROFILES_DIR/$prof.profile"
[ -f "$file" ] || { err "Profile not found: $prof"; return 1; } [ -f "$file" ] || { err "Profile not found: $prof"; return 1; }
# Snapshot entries once (claude-free): "<cat><TAB><name>", canonical name.
# A plugin's marketplace (plugin@<mp>) collapses to category "plugin".
local entries=() skill type cat
while IFS=$'\t' read -r skill type; do
case "$type" in plugin@*|plugin) cat=plugin ;; *) cat="$type" ;; esac
entries+=("$cat"$'\t'"$skill")
done < <(read_profile "$prof")
# --plain: parsable contract for the design gate. One "<type><TAB><name>"
# per line, grouped by type, NO status, NO claude calls.
if [ "$plain" -eq 1 ]; then if [ "$plain" -eq 1 ]; then
local e _show_plain "$prof"
for cat in gstack external personal plugin mcp cli; do
for e in "${entries[@]}"; do
[ "${e%%$'\t'*}" = "$cat" ] && printf '%s\t%s\n' "$cat" "${e#*$'\t'}"
done
done
return 0 return 0
fi fi
@@ -611,21 +639,7 @@ cmd_show() {
fi fi
echo "" echo ""
# Grouped by type, fixed order; empty groups skipped. Canonical name + _show_grouped "$prof"
# runtime status (existing skill_status — degrades to disabled if no claude).
local e names status
for cat in gstack external personal plugin mcp cli; do
names=()
for e in "${entries[@]}"; do
[ "${e%%$'\t'*}" = "$cat" ] && names+=("${e#*$'\t'}")
done
[ "${#names[@]}" -eq 0 ] && continue
printf '%s (%d):\n' "$cat" "${#names[@]}"
for skill in "${names[@]}"; do
status="$(skill_status "$skill" "$cat")"
printf ' %-24s %s\n' "$skill" "$status"
done
done
} }
cmd_apply() { cmd_apply() {
+98 -84
View File
@@ -42,10 +42,13 @@ set -euo pipefail
REPO="${TOGGLE_EXTERNAL_REPO_OVERRIDE:-$(cd -P "$(dirname "$0")/.." && pwd)}" REPO="${TOGGLE_EXTERNAL_REPO_OVERRIDE:-$(cd -P "$(dirname "$0")/.." && pwd)}"
SKILLS_DIR="$REPO/skills" SKILLS_DIR="$REPO/skills"
DISABLED_DIR="$REPO/skills-disabled" DISABLED_DIR="$REPO/skills-disabled"
GSTACK_SRC="$REPO/skills-external/gstack" # gstack submodule: its skills
# GSTACK_REMOVED + gstack_is_removed() — single source, honored by the # GSTACK_REMOVED + gstack_is_removed() — single source, honored by the
# `enable gstack` loop below. Resolved from $0 like REPO above, not from # `enable gstack` loop below — plus the gstack helpers shared with
# $REPO/lib — gstack-removed.sh sits next to this file wherever it runs. # profile.sh (gstack_skills, gstack_park, gstack_unpark, gstack_parked_names).
# Resolved from $0 like REPO above, not from $REPO/lib — gstack-removed.sh
# sits next to this file wherever it runs.
# shellcheck source=lib/gstack-removed.sh disable=SC1091 # shellcheck source=lib/gstack-removed.sh disable=SC1091
source "$(dirname "$0")/gstack-removed.sh" source "$(dirname "$0")/gstack-removed.sh"
@@ -54,14 +57,40 @@ ok() { echo -e "${GREEN}✓${NC} $1"; }
warn() { echo -e "${YELLOW}⚠${NC} $1"; } warn() { echo -e "${YELLOW}⚠${NC} $1"; }
err() { echo -e "${RED}✗${NC} $1"; } err() { echo -e "${RED}✗${NC} $1"; }
# All non-plugin tools this script can toggle. # All non-plugin tools this script can toggle, in `list` order. The one
# roster: tool_kind() derives every tool's kind from it.
MANAGED_TOOLS=(gstack emil-design-eng darwin-skill 21st higgsfield MANAGED_TOOLS=(gstack emil-design-eng darwin-skill 21st higgsfield
higgsfield-websites higgsfield-websites
observability-and-instrumentation deprecation-and-migration ci-cd-and-automation observability-and-instrumentation deprecation-and-migration
ci-cd-and-automation
scroll-world-storytelling build-threejs-scroll-worlds scroll-world-storytelling build-threejs-scroll-worlds
scroll-scrubbed-visual-sequence scroll-scrubbed-word-reveal scroll-scrubbed-visual-sequence scroll-scrubbed-word-reveal
scroll-progress-timeline) scroll-progress-timeline)
# Prints the kind of a tool: gstack | pack (21st, higgsfield) | single (one
# symlink: every other MANAGED_TOOLS entry) | unknown. Exact-match loop, so
# a name with spaces or glob characters can never match a roster entry.
tool_kind() {
local tool="$1" managed
case "$tool" in
gstack) echo gstack; return ;;
21st|higgsfield) echo pack; return ;;
esac
for managed in "${MANAGED_TOOLS[@]}"; do
[ "$managed" = "$tool" ] && { echo single; return; }
done
echo unknown
}
# Prints where a single-symlink tool is linked from: ~/.agents/skills for
# darwin-skill, skills-external/ for the others.
tool_source() {
case "$1" in
darwin-skill) echo "$HOME/.agents/skills/$1" ;;
*) echo "$REPO/skills-external/$1" ;;
esac
}
# Prints the skill names that belong to the "21st" pack. Source of truth: # Prints the skill names that belong to the "21st" pack. Source of truth:
# skills-external/21st-* — the `21st skills install` run in install-plugins.sh # skills-external/21st-* — the `21st skills install` run in install-plugins.sh
# owns that list, so adding a skill upstream needs no edit here. # owns that list, so adding a skill upstream needs no edit here.
@@ -117,8 +146,8 @@ pack_skills() {
# tool exists (`timeout`, or `gtimeout` from Homebrew coreutils on macOS): # tool exists (`timeout`, or `gtimeout` from Homebrew coreutils on macOS):
# a closed-source binary must never hang a toggle, and what it prints (a # a closed-source binary must never hang a toggle, and what it prints (a
# token) must never reach the terminal. Twin of _higgsfield_probe in # token) must never reach the terminal. Twin of _higgsfield_probe in
# lib/higgsfield-skills.sh, kept here because this script takes no extra # lib/higgsfield-skills.sh, kept here so the only file sourced beside this
# `source` (the fixture suites copy it alone). # script stays gstack-removed.sh (the fixture suites copy just those two).
bounded() { bounded() {
local tool local tool
for tool in timeout gtimeout; do for tool in timeout gtimeout; do
@@ -158,41 +187,22 @@ pack_hints() {
esac esac
} }
# Prints the names (directory basenames) that belong to "gstack".
# Source of truth: skills-external/gstack/*/SKILL.md. The repo's
# skills/<name> symlinks are generated from these by gstack ./setup.
gstack_skills() {
local gstack_src="$REPO/skills-external/gstack"
[ -d "$gstack_src" ] || return 0
for d in "$gstack_src"/*/; do
[ -f "${d}SKILL.md" ] || continue
basename "$d"
done
}
# Prints "enabled" / "disabled" / "missing" for a tool. # Prints "enabled" / "disabled" / "missing" for a tool.
status_tool() { status_tool() {
local tool="$1" local tool="$1" installed=0 name
case "$tool" in case "$(tool_kind "$tool")" in
gstack) gstack)
[ -d "$REPO/skills-external/gstack" ] || { echo "missing"; return; } [ -d "$GSTACK_SRC" ] || { echo "missing"; return; }
while read -r name; do while read -r name; do
[ -e "$SKILLS_DIR/$name" ] && { echo "enabled"; return; } [ -e "$SKILLS_DIR/$name" ] && { echo "enabled"; return; }
done < <(gstack_skills) done < <(gstack_skills "$GSTACK_SRC")
echo "disabled" echo "disabled"
;; ;;
emil-design-eng|observability-and-instrumentation|deprecation-and-migration|ci-cd-and-automation| \ single)
scroll-world-storytelling|build-threejs-scroll-worlds|scroll-scrubbed-visual-sequence| \ [ -d "$(tool_source "$tool")" ] || { echo "missing"; return; }
scroll-scrubbed-word-reveal|scroll-progress-timeline|higgsfield-websites)
[ -d "$REPO/skills-external/$tool" ] || { echo "missing"; return; }
[ -e "$SKILLS_DIR/$tool" ] && echo "enabled" || echo "disabled" [ -e "$SKILLS_DIR/$tool" ] && echo "enabled" || echo "disabled"
;; ;;
darwin-skill) pack)
[ -d "$HOME/.agents/skills/$tool" ] || { echo "missing"; return; }
[ -e "$SKILLS_DIR/$tool" ] && echo "enabled" || echo "disabled"
;;
21st|higgsfield)
local installed=0
while read -r name; do while read -r name; do
installed=1 installed=1
[ -e "$SKILLS_DIR/$name" ] && { echo "enabled"; return; } [ -e "$SKILLS_DIR/$name" ] && { echo "enabled"; return; }
@@ -204,28 +214,21 @@ status_tool() {
esac esac
} }
disable_tool() { # Parks every live gstack skill (twin of profile.sh's disable_skill gstack
local tool="$1" # arm, kept separate: the messages differ).
mkdir -p "$DISABLED_DIR" disable_gstack() {
case "$tool" in local moved=0 name
gstack)
local moved=0
while read -r name; do while read -r name; do
[ -e "$SKILLS_DIR/$name" ] || continue [ -e "$SKILLS_DIR/$name" ] || continue
# Clobber any stale destination. gstack ./setup now creates gstack_park "$SKILLS_DIR" "$DISABLED_DIR" "$name"
# skills/<name>/ as directories, so mv onto an existing dir
# would nest it (gstack__<name>/<name>/) instead of renaming.
# Content is symlinks to the submodule — `gstack ./setup` regenerates.
rm -rf "$DISABLED_DIR/gstack__$name"
mv "$SKILLS_DIR/$name" "$DISABLED_DIR/gstack__$name"
moved=$((moved + 1)) moved=$((moved + 1))
done < <(gstack_skills) done < <(gstack_skills "$GSTACK_SRC")
ok "gstack disabled ($moved symlinks moved)" ok "gstack disabled ($moved symlinks moved)"
;; }
emil-design-eng|darwin-skill|observability-and-instrumentation|deprecation-and-migration| \
ci-cd-and-automation|scroll-world-storytelling|build-threejs-scroll-worlds| \ # Parks one single-symlink external tool.
scroll-scrubbed-visual-sequence|scroll-scrubbed-word-reveal|scroll-progress-timeline| \ disable_external_single() {
higgsfield-websites) local tool="$1"
if [ -e "$SKILLS_DIR/$tool" ]; then if [ -e "$SKILLS_DIR/$tool" ]; then
rm -rf "${DISABLED_DIR:?}/${tool:?}" rm -rf "${DISABLED_DIR:?}/${tool:?}"
mv "$SKILLS_DIR/$tool" "$DISABLED_DIR/$tool" mv "$SKILLS_DIR/$tool" "$DISABLED_DIR/$tool"
@@ -233,11 +236,13 @@ disable_tool() {
else else
warn "$tool already disabled" warn "$tool already disabled"
fi fi
;; }
21st|higgsfield)
# Parked under the plain skill name — same convention as the other # Parks every live skill of a pack (21st, higgsfield). Parked under the
# externals, so profile.sh's park/restore path stays interoperable. # plain skill name — same convention as the other externals, so profile.sh's
local parked=0 # park/restore path stays interoperable.
disable_pack() {
local tool="$1" parked=0 name
while read -r name; do while read -r name; do
[ -e "$SKILLS_DIR/$name" ] || continue [ -e "$SKILLS_DIR/$name" ] || continue
rm -rf "${DISABLED_DIR:?}/${name:?}" rm -rf "${DISABLED_DIR:?}/${name:?}"
@@ -249,31 +254,32 @@ disable_tool() {
else else
warn "$tool already disabled" warn "$tool already disabled"
fi fi
;; }
disable_tool() {
local tool="$1"
mkdir -p "$DISABLED_DIR"
case "$(tool_kind "$tool")" in
gstack) disable_gstack ;;
single) disable_external_single "$tool" ;;
pack) disable_pack "$tool" ;;
*) err "Unknown tool: $tool"; return 1 ;; *) err "Unknown tool: $tool"; return 1 ;;
esac esac
} }
enable_tool() { # Re-links the gstack skills parked as gstack__<name>, honoring the
local tool="$1" # policy denylist (lib/gstack-removed.sh).
case "$tool" in enable_gstack() {
gstack) local moved=0 skipped=0 name
local moved=0 skipped=0 while IFS= read -r name; do
if [ -d "$DISABLED_DIR" ]; then
for entry in "$DISABLED_DIR"/gstack__*; do
[ -e "$entry" ] || continue
local name
name="$(basename "$entry" | sed 's/^gstack__//')"
if gstack_is_removed "$name"; then if gstack_is_removed "$name"; then
warn "skipped (removed by policy, lib/gstack-removed.sh): $name" warn "skipped (removed by policy, lib/gstack-removed.sh): $name"
skipped=$((skipped + 1)) skipped=$((skipped + 1))
continue continue
fi fi
rm -rf "${SKILLS_DIR:?}/${name:?}" gstack_unpark "$SKILLS_DIR" "$DISABLED_DIR" "$name"
mv "$entry" "$SKILLS_DIR/$name"
moved=$((moved + 1)) moved=$((moved + 1))
done done < <(gstack_parked_names "$DISABLED_DIR")
fi
if [ "$moved" -eq 0 ] && [ "$skipped" -ge 1 ]; then if [ "$moved" -eq 0 ] && [ "$skipped" -ge 1 ]; then
warn "only policy-removed skills remain parked (lib/gstack-removed.sh)" warn "only policy-removed skills remain parked (lib/gstack-removed.sh)"
elif [ "$moved" -eq 0 ]; then elif [ "$moved" -eq 0 ]; then
@@ -281,16 +287,13 @@ enable_tool() {
else else
ok "gstack enabled ($moved symlinks restored)" ok "gstack enabled ($moved symlinks restored)"
fi fi
;; }
emil-design-eng|darwin-skill|observability-and-instrumentation|deprecation-and-migration| \
ci-cd-and-automation|scroll-world-storytelling|build-threejs-scroll-worlds| \ # Enables one single-symlink external tool: restore from the parking dir,
scroll-scrubbed-visual-sequence|scroll-scrubbed-word-reveal|scroll-progress-timeline| \ # else link its source (see tool_source).
higgsfield-websites) enable_external_single() {
local src local tool="$1" src
case "$tool" in src="$(tool_source "$tool")"
darwin-skill) src="$HOME/.agents/skills/$tool" ;;
*) src="$REPO/skills-external/$tool" ;;
esac
if [ -e "$DISABLED_DIR/$tool" ]; then if [ -e "$DISABLED_DIR/$tool" ]; then
rm -rf "${SKILLS_DIR:?}/${tool:?}" rm -rf "${SKILLS_DIR:?}/${tool:?}"
mv "$DISABLED_DIR/$tool" "$SKILLS_DIR/$tool" mv "$DISABLED_DIR/$tool" "$SKILLS_DIR/$tool"
@@ -305,9 +308,12 @@ enable_tool() {
return 1 return 1
fi fi
if [ "$tool" = "higgsfield-websites" ]; then pack_hints higgsfield; fi if [ "$tool" = "higgsfield-websites" ]; then pack_hints higgsfield; fi
;; }
21st|higgsfield)
local restored=0 linked=0 # Enables a multi-skill pack (21st, higgsfield): restore parked skills,
# link the missing ones, then print the CLI hints.
enable_pack() {
local tool="$1" restored=0 linked=0
while read -r name; do while read -r name; do
if [ -e "$DISABLED_DIR/$name" ]; then if [ -e "$DISABLED_DIR/$name" ]; then
rm -rf "${SKILLS_DIR:?}/${name:?}" rm -rf "${SKILLS_DIR:?}/${name:?}"
@@ -333,12 +339,20 @@ enable_tool() {
fi fi
ok "$tool enabled ($((restored + linked)) skills: $restored restored, $linked linked)" ok "$tool enabled ($((restored + linked)) skills: $restored restored, $linked linked)"
pack_hints "$tool" pack_hints "$tool"
;; }
enable_tool() {
local tool="$1"
case "$(tool_kind "$tool")" in
gstack) enable_gstack ;;
single) enable_external_single "$tool" ;;
pack) enable_pack "$tool" ;;
*) err "Unknown tool: $tool"; return 1 ;; *) err "Unknown tool: $tool"; return 1 ;;
esac esac
} }
list_all() { list_all() {
local t
printf "%-20s %s\n" "TOOL" "STATUS" printf "%-20s %s\n" "TOOL" "STATUS"
printf "%-20s %s\n" "----" "------" printf "%-20s %s\n" "----" "------"
for t in "${MANAGED_TOOLS[@]}"; do for t in "${MANAGED_TOOLS[@]}"; do