feat(packs): nine skills-dir packs, profiles as settings fragments, profile.sh on one jq pass; symlink toggling and toggle-external retired
This commit is contained in:
1 parent
f3569f2689
commit
babf232594
120 files changed
+1217
-2654
No files matched your search
@@ -187,13 +187,13 @@ check T8h-template-rules-path "$rc1|$?" "0|1"
|
||||
|
||||
# ── real census: the repo's own citers against CLAUDE.global.md ──────────────
|
||||
mapfile -t FILES < <(cd "$ROOT" && find skills agents lib rules hooks -type f \( -name '*.md' -o -name '*.sh' \) \
|
||||
-not -path 'skills/graphify/*' -not -path 'skills/impeccable/*' -not -path 'skills/synced/*' \
|
||||
-not -path 'skills/graphify/*' -not -path 'skills-external/impeccable/*' -not -path 'skills/synced/*' \
|
||||
-not -path 'agents/impeccable-*' -not -path 'lib/tests/*' | sort)
|
||||
# T6 also scans the templates and this repo's own project rules; T3 must not
|
||||
# (there `CLAUDE.md` means a project CLAUDE.md, not the doctrine).
|
||||
mapfile -t FILES_ALL < <(cd "$ROOT" && find skills agents lib rules hooks \
|
||||
templates .claude/rules -type f \( -name '*.md' -o -name '*.sh' \) \
|
||||
-not -path 'skills/graphify/*' -not -path 'skills/impeccable/*' \
|
||||
-not -path 'skills/graphify/*' -not -path 'skills-external/impeccable/*' \
|
||||
-not -path 'skills/synced/*' -not -path 'agents/impeccable-*' \
|
||||
-not -path 'lib/tests/*' | sort)
|
||||
# T8f: the T6 list reaches the two blind trees, the T3 list does not
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
# shellcheck disable=SC2015,SC2016 # A && ok || ko is deliberate (ok/ko never fail)
|
||||
set -u
|
||||
R="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
skdir() { ls -d "$R"/skills/"$1" "$R"/skills/pack-*/skills/"$1" 2>/dev/null | head -1 | sed "s#^$R/##"; }
|
||||
MOD="$R/mods/model-router"
|
||||
RJ="$MOD/routing.json"
|
||||
REG="$MOD/hooks/register.ts"
|
||||
@@ -185,7 +186,7 @@ done
|
||||
# ── (e) D3 wiring markers ────────────────────────────────────────────────
|
||||
mark() { # mark <phase> <skills...>
|
||||
local ph="$1" s; shift
|
||||
for s in "$@"; do has "skills/$s/SKILL.md" "route(phase=\"$ph\")"; done
|
||||
for s in "$@"; do has "$(skdir "$s")/SKILL.md" "route(phase=\"$ph\")"; done
|
||||
}
|
||||
mark orchestrate feat hotfix bugfix ship-feature init-project code-clean seo geo harden web-validate audit-delta
|
||||
mark apply feat hotfix bugfix ship-feature init-project
|
||||
@@ -194,7 +195,7 @@ mark plan ship-feature init-project onboard code-clean audit-delta
|
||||
mark escalate ship-feature
|
||||
[ "$(grep -o 'route(phase="escalate")' "$R/lib/verify-secure-loop.md" | wc -l)" -eq 3 ] \
|
||||
&& ok || ko "verify-secure-loop.md: escalate route must appear 3 times"
|
||||
for s in ship-feature init-project; do has "skills/$s/SKILL.md" 'effort="xhigh"'; done
|
||||
for s in ship-feature init-project; do has "$(skdir "$s")/SKILL.md" 'effort="xhigh"'; done
|
||||
has "skills/tour/SKILL.md" 'effort="xhigh"'
|
||||
n_opus="$(grep -c 'model="opus",$' "$R/skills/onboard/SKILL.md")"
|
||||
n_eff="$(grep -c 'effort="xhigh",$' "$R/skills/onboard/SKILL.md")"
|
||||
@@ -203,7 +204,7 @@ n_eff="$(grep -c 'effort="xhigh",$' "$R/skills/onboard/SKILL.md")"
|
||||
bad="$(grep 'model: "fable"' "$R/agents/client-handover-writer.md" | grep -vc 'effort="high"')"
|
||||
[ "$bad" -eq 0 ] && ok || ko "client-handover-writer: $bad model: \"fable\" line(s) without effort=\"high\""
|
||||
for s in ship-feature init-project feat bugfix web-validate seo hotfix geo harden code-clean audit-delta tour onboard; do
|
||||
has "skills/$s/SKILL.md" 'ROUTING: follow $HOME/.claude/lib/effort-shift.md'
|
||||
has "$(skdir "$s")/SKILL.md" 'ROUTING: follow $HOME/.claude/lib/effort-shift.md'
|
||||
done
|
||||
has "agents/client-handover-writer.md" 'ROUTING: follow $HOME/.claude/lib/effort-shift.md'
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ls $HOME/.claude/skills/a2 skills-disabled/foo; bash lib/toggle-external.sh; cat .active-profile; lib/profiles/web.profile
|
||||
@@ -1,66 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# lib/tests/gstack-removed.test.sh — GSTACK_REMOVED denylist honored by
|
||||
# every "bring gstack back" path: profile.sh `gstack on` and
|
||||
# toggle-external.sh `enable gstack` both skip a policy-removed name and
|
||||
# leave it parked, restoring only what policy allows; gstack_is_removed()
|
||||
# itself, positive + negative. Covers contract criterion 17. Hermetic:
|
||||
# fixture repo via PROFILE_REPO_OVERRIDE / TOGGLE_EXTERNAL_REPO_OVERRIDE —
|
||||
# same harness as lib/tests/profile-default.test.sh and
|
||||
# lib/tests/toggle-external-repo-resolution.test.sh.
|
||||
set -u
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
pass=0; fail=0
|
||||
check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1));
|
||||
printf 'FAIL %s: got[%s] want[%s]\n' "$1" "$2" "$3"; fi; }
|
||||
check_has() { case "$2" in *"$3"*) pass=$((pass+1));; *) fail=$((fail+1));
|
||||
printf 'FAIL %s: [%s] does not contain [%s]\n' "$1" "$2" "$3";; esac; }
|
||||
check_not() { case "$2" in *"$3"*) fail=$((fail+1));
|
||||
printf 'FAIL %s: [%s] unexpectedly contains [%s]\n' "$1" "$2" "$3";; *) pass=$((pass+1));; esac; }
|
||||
|
||||
# mk_fixture <dir> — minimal repo: profile.sh + toggle-external.sh +
|
||||
# gstack-removed.sh under lib/, one removed name (ship) and one kept name
|
||||
# (browse) parked in skills-disabled/.
|
||||
mk_fixture() {
|
||||
local fx="$1"
|
||||
mkdir -p "$fx/skills" "$fx/skills-disabled/gstack__ship" \
|
||||
"$fx/skills-disabled/gstack__browse" "$fx/lib"
|
||||
cp "$ROOT/lib/profile.sh" "$ROOT/lib/toggle-external.sh" \
|
||||
"$ROOT/lib/gstack-removed.sh" "$fx/lib/"
|
||||
}
|
||||
|
||||
# --- T1-T5: profile.sh gstack on restores browse, skips + parks ship ---
|
||||
FX1="$(mktemp -d)"; mk_fixture "$FX1"
|
||||
out="$(PROFILE_REPO_OVERRIDE="$FX1" bash "$FX1/lib/profile.sh" gstack on 2>&1)"
|
||||
check T1-browse-restored "$([ -e "$FX1/skills/browse" ] && echo on || echo off)" on
|
||||
check T2-ship-parked "$([ -e "$FX1/skills-disabled/gstack__ship" ] && echo p || echo n)" p
|
||||
check T3-ship-not-live "$([ -e "$FX1/skills/ship" ] && echo on || echo off)" off
|
||||
check_has T4-skip-names-ship "$out" "ship"
|
||||
check_has T5-real-count "$out" "1 parked gstack skills restored"
|
||||
rm -rf "$FX1"
|
||||
|
||||
# --- T6-T9: toggle-external.sh enable gstack — same skip + restore ---
|
||||
FX2="$(mktemp -d)"; mk_fixture "$FX2"
|
||||
out="$(TOGGLE_EXTERNAL_REPO_OVERRIDE="$FX2" bash "$FX2/lib/toggle-external.sh" enable gstack 2>&1)"
|
||||
check T6-browse-restored "$([ -e "$FX2/skills/browse" ] && echo on || echo off)" on
|
||||
check T7-ship-parked "$([ -e "$FX2/skills-disabled/gstack__ship" ] && echo p || echo n)" p
|
||||
check T8-ship-not-live "$([ -e "$FX2/skills/ship" ] && echo on || echo off)" off
|
||||
check_has T9-skip-names-ship "$out" "ship"
|
||||
rm -rf "$FX2"
|
||||
|
||||
# --- T10-T11: toggle-external.sh, only removed names parked — 0 restored,
|
||||
# the policy message fires instead of the "re-run gstack setup" hint ---
|
||||
FX3="$(mktemp -d)"
|
||||
mkdir -p "$FX3/skills" "$FX3/skills-disabled/gstack__ship" "$FX3/lib"
|
||||
cp "$ROOT/lib/toggle-external.sh" "$ROOT/lib/gstack-removed.sh" "$FX3/lib/"
|
||||
out="$(TOGGLE_EXTERNAL_REPO_OVERRIDE="$FX3" bash "$FX3/lib/toggle-external.sh" enable gstack 2>&1)"
|
||||
check_has T10-policy-msg "$out" "policy-removed skills remain parked"
|
||||
check_not T11-no-setup-hint "$out" "re-run gstack setup"
|
||||
rm -rf "$FX3"
|
||||
|
||||
# --- T12-T13: gstack_is_removed() itself, positive + negative ---
|
||||
# shellcheck source=lib/gstack-removed.sh disable=SC1091
|
||||
source "$ROOT/lib/gstack-removed.sh"
|
||||
gstack_is_removed ship; check T12-removed-positive "$?" 0
|
||||
gstack_is_removed browse; check T13-removed-negative "$?" 1
|
||||
|
||||
printf 'PASS=%s FAIL=%s\n' "$pass" "$fail"; [ "$fail" -eq 0 ]
|
||||
@@ -2,9 +2,7 @@
|
||||
# lib/tests/higgsfield.test.sh — hermetic suite for the Higgsfield pack.
|
||||
# sync lib/higgsfield-skills.sh against a local git repo shaped like
|
||||
# upstream (no network), and its CLI probes against a fake CLI
|
||||
# toggle lib/toggle-external.sh `higgsfield` / `higgsfield-websites`
|
||||
# against a fixture tree, fake CLIs first on PATH
|
||||
# wiring static locks on the installers (order, off by default)
|
||||
# wiring static locks on the installers (order)
|
||||
# Each named case prints one `PASS <NAME>` or `FAIL <NAME>:<details>` line.
|
||||
set -u
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
@@ -111,7 +109,7 @@ probe() {
|
||||
# ── sync ────────────────────────────────────────────────────
|
||||
UP="$WORK/upstream"; mk_upstream "$UP"
|
||||
# The repo path carries a space on purpose: every expansion must be quoted.
|
||||
R1="$WORK/r 1"; mkdir -p "$R1/skills" "$R1/skills-disabled"
|
||||
R1="$WORK/r 1"; mkdir -p "$R1/skills"
|
||||
EXT="$R1/skills-external"
|
||||
|
||||
expect fixture "$(yn test -f "$UP/.git/HEAD")" yes
|
||||
@@ -137,16 +135,6 @@ expect stale-out "$(yn test -e "$EXT/higgsfield-generate/old.md")" no
|
||||
expect new-in "$(yn test -f "$EXT/higgsfield-generate/new.md")" yes
|
||||
verdict SYNC_REFRESH_DROPS_STALE
|
||||
|
||||
ln -s "$EXT/higgsfield-soul-id" "$R1/skills-disabled/higgsfield-soul-id"
|
||||
ln -s "$EXT/higgsfield-generate" "$R1/skills/higgsfield-generate"
|
||||
expect rc-count "$(sync_into "$R1")" "0:3"
|
||||
expect parked-link "$(yn test -L "$R1/skills-disabled/higgsfield-soul-id")" yes
|
||||
expect parked-reads \
|
||||
"$(yn test -f "$R1/skills-disabled/higgsfield-soul-id/SKILL.md")" yes
|
||||
expect not-enabled "$(yn test -e "$R1/skills/higgsfield-soul-id")" no
|
||||
expect live-reads "$(yn test -f "$R1/skills/higgsfield-generate/SKILL.md")" yes
|
||||
verdict SYNC_KEEPS_PARKED
|
||||
|
||||
BARE="$WORK/bare-upstream"; mkdir -p "$BARE"; echo "x" > "$BARE/README.md"
|
||||
git_q "$BARE" init; git_q "$BARE" add -A; git_q "$BARE" commit -m fixture
|
||||
expect no-repo "$(sync_into "$R1" "$WORK/no-such-repo")" "1:0"
|
||||
@@ -171,158 +159,10 @@ chmod +x "$GT/gtimeout"
|
||||
expect gtimeout "$(probe "$BIN:$GT:$CLEAN" higgsfield_signed_in)" "rc=0"
|
||||
verdict PROBES_SILENT
|
||||
|
||||
# ── toggle ──────────────────────────────────────────────────
|
||||
# mk_toggle_fx <dir> [skill...] — fixture repo: the toggle script plus one
|
||||
# skills-external source per named skill (none → installed-nothing tree).
|
||||
mk_toggle_fx() {
|
||||
local fx="$1" s; shift
|
||||
mkdir -p "$fx/lib" "$fx/skills"
|
||||
cp "$ROOT/lib/toggle-external.sh" "$ROOT/lib/gstack-removed.sh" "$fx/lib/"
|
||||
for s in "$@"; do
|
||||
mkdir -p "$fx/skills-external/$s"
|
||||
echo "---" > "$fx/skills-external/$s/SKILL.md"
|
||||
done
|
||||
}
|
||||
PACK=(higgsfield-generate higgsfield-soul-id higgsfield-websites)
|
||||
|
||||
# tog <fixture> <args...> — run the fixture's toggle script, fake CLIs first.
|
||||
tog() {
|
||||
local fx="$1"; shift
|
||||
TOGGLE_EXTERNAL_REPO_OVERRIDE="$fx" PATH="$BIN:$PATH" \
|
||||
bash "$fx/lib/toggle-external.sh" "$@" 2>&1
|
||||
}
|
||||
# list_row <fixture> <tool> — the status column of `list` for one tool.
|
||||
list_row() { tog "$1" list | awk -v t="$2" '$1 == t { print $2 }'; }
|
||||
|
||||
F0="$WORK/f0"; mk_toggle_fx "$F0"
|
||||
F1="$WORK/f1"; mk_toggle_fx "$F1" "${PACK[@]}"
|
||||
expect pack-missing "$(tog "$F0" status higgsfield)" missing
|
||||
expect web-missing "$(tog "$F0" status higgsfield-websites)" missing
|
||||
expect pack-disabled "$(tog "$F1" status higgsfield)" disabled
|
||||
expect web-disabled "$(tog "$F1" status higgsfield-websites)" disabled
|
||||
ln -s "$F1/skills-external/higgsfield-generate" "$F1/skills/higgsfield-generate"
|
||||
expect pack-partial "$(tog "$F1" status higgsfield)" enabled
|
||||
expect web-apart "$(tog "$F1" status higgsfield-websites)" disabled
|
||||
expect list-pack "$(list_row "$F1" higgsfield)" enabled
|
||||
expect list-web "$(list_row "$F1" higgsfield-websites)" disabled
|
||||
verdict STATUS_STATES
|
||||
|
||||
F2="$WORK/f2"; mk_toggle_fx "$F2" "${PACK[@]}"
|
||||
out="$(tog "$F2" enable higgsfield)"; rc=$?
|
||||
expect rc "$rc" 0
|
||||
expect generate "$(readlink "$F2/skills/higgsfield-generate")" \
|
||||
"$F2/skills-external/higgsfield-generate"
|
||||
expect soul-id "$(readlink "$F2/skills/higgsfield-soul-id")" \
|
||||
"$F2/skills-external/higgsfield-soul-id"
|
||||
expect no-websites "$(yn test -e "$F2/skills/higgsfield-websites")" no
|
||||
expect_has count "$out" "higgsfield enabled (2 skills: 0 restored, 2 linked)"
|
||||
out="$(tog "$F2" enable higgsfield)"; rc=$?
|
||||
expect again-rc "$rc" 0
|
||||
expect_has again "$out" "higgsfield already enabled"
|
||||
verdict ENABLE_PACK_EXCLUDES_WEBSITES
|
||||
|
||||
# The media pack is an allowlist: a synced skill nobody listed is reported,
|
||||
# never linked; neither is a listed name whose directory holds no SKILL.md.
|
||||
F8="$WORK/f 8"; mk_toggle_fx "$F8" "${PACK[@]}" higgsfield-newcomer
|
||||
mkdir -p "$F8/skills-external/higgsfield-brandkit" \
|
||||
"$F8/skills-external/higgsfield-noskill"
|
||||
out="$(tog "$F8" enable higgsfield)"; rc=$?
|
||||
expect rc "$rc" 0
|
||||
expect_has count "$out" "higgsfield enabled (2 skills: 0 restored, 2 linked)"
|
||||
expect newcomer-off "$(yn test -e "$F8/skills/higgsfield-newcomer")" no
|
||||
expect brandkit-off "$(yn test -e "$F8/skills/higgsfield-brandkit")" no
|
||||
expect_has reported "$out" "higgsfield-newcomer"
|
||||
expect_not noskill-quiet "$out" "higgsfield-noskill"
|
||||
expect links "$(entries "$F8/skills")" 2
|
||||
# Enabled is the steady state: a re-run must still name the drift.
|
||||
out="$(tog "$F8" enable higgsfield)"; rc=$?
|
||||
expect again-rc "$rc" 0
|
||||
expect_has again-state "$out" "higgsfield already enabled"
|
||||
expect_has again-reported "$out" "higgsfield-newcomer"
|
||||
verdict UNLISTED_NOT_LINKED
|
||||
|
||||
F3="$WORK/f3"; mk_toggle_fx "$F3" "${PACK[@]}"
|
||||
out="$(tog "$F3" enable higgsfield-websites)"; rc=$?
|
||||
expect rc "$rc" 0
|
||||
expect link "$(readlink "$F3/skills/higgsfield-websites")" \
|
||||
"$F3/skills-external/higgsfield-websites"
|
||||
expect no-generate "$(yn test -e "$F3/skills/higgsfield-generate")" no
|
||||
expect pack-status "$(tog "$F3" status higgsfield)" disabled
|
||||
expect web-status "$(tog "$F3" status higgsfield-websites)" enabled
|
||||
tog "$F3" disable higgsfield-websites >/dev/null
|
||||
out="$(FAKE_HF_SESSION=out tog "$F3" enable higgsfield-websites)"; rc=$?
|
||||
expect hint-rc "$rc" 0
|
||||
expect_has web-hint "$out" "higgsfield auth login"
|
||||
verdict ENABLE_WEBSITES_ALONE
|
||||
|
||||
# Continues on F2: the pack is enabled, websites is not.
|
||||
tog "$F2" enable higgsfield-websites >/dev/null
|
||||
out="$(tog "$F2" disable higgsfield)"; rc=$?
|
||||
expect rc "$rc" 0
|
||||
expect_has msg "$out" "higgsfield disabled (2 skills parked)"
|
||||
expect parked "$(yn test -L "$F2/skills-disabled/higgsfield-generate")" yes
|
||||
expect unlinked "$(yn test -e "$F2/skills/higgsfield-generate")" no
|
||||
expect web-untouched "$(yn test -e "$F2/skills/higgsfield-websites")" yes
|
||||
out="$(tog "$F2" enable higgsfield)"
|
||||
expect_has restored "$out" "2 restored, 0 linked"
|
||||
tog "$F2" disable higgsfield-websites >/dev/null
|
||||
expect web-parked "$(yn test -L "$F2/skills-disabled/higgsfield-websites")" yes
|
||||
expect pack-on "$(tog "$F2" status higgsfield)" enabled
|
||||
verdict DISABLE_PARKS
|
||||
|
||||
F4="$WORK/f4"; mk_toggle_fx "$F4" "${PACK[@]}"
|
||||
out="$(FAKE_HF_SESSION=out tog "$F4" enable higgsfield)"; rc=$?
|
||||
expect out-rc "$rc" 0
|
||||
expect out-linked "$(yn test -e "$F4/skills/higgsfield-generate")" yes
|
||||
expect_has out-hint "$out" "higgsfield auth login"
|
||||
F5="$WORK/f5"; mk_toggle_fx "$F5" "${PACK[@]}"
|
||||
out="$(FAKE_HF_SESSION=in tog "$F5" enable higgsfield)"
|
||||
expect_not in-quiet "$out" "auth login"
|
||||
expect_not in-no-token "$out" "fixture-token"
|
||||
F6="$WORK/f6"; mk_toggle_fx "$F6" "${PACK[@]}"
|
||||
out="$(TOGGLE_EXTERNAL_REPO_OVERRIDE="$F6" PATH="$CLEAN" \
|
||||
bash "$F6/lib/toggle-external.sh" enable higgsfield 2>&1)"; rc=$?
|
||||
expect absent-rc "$rc" 0
|
||||
expect absent-linked "$(yn test -e "$F6/skills/higgsfield-generate")" yes
|
||||
expect_has absent-hint "$out" "not on PATH"
|
||||
F9="$WORK/f9"; mk_toggle_fx "$F9" "${PACK[@]}"
|
||||
out="$(FAKE_HF_BINARY=missing tog "$F9" enable higgsfield)"; rc=$?
|
||||
expect shim-rc "$rc" 0
|
||||
expect_has shim-hint "$out" "does not answer"
|
||||
expect_not shim-not-login "$out" "auth login"
|
||||
verdict SIGNED_OUT_WARNS
|
||||
|
||||
out="$(tog "$F0" enable higgsfield)"; rc=$?
|
||||
expect pack-rc "$rc" 1
|
||||
expect_has pack-path "$out" "$F0/skills-external"
|
||||
out="$(tog "$F0" enable higgsfield-websites)"; rc=$?
|
||||
expect web-rc "$rc" 1
|
||||
expect_has web-path "$out" "$F0/skills-external/higgsfield-websites"
|
||||
verdict ENABLE_MISSING_ERRS
|
||||
|
||||
# The pack arms are shared with 21st: its behaviour must not move.
|
||||
F7="$WORK/f7"; mk_toggle_fx "$F7" 21st-one 21st-two
|
||||
expect off "$(tog "$F7" status 21st)" disabled
|
||||
out="$(tog "$F7" enable 21st)"
|
||||
expect_has on "$out" "21st enabled (2 skills: 0 restored, 2 linked)"
|
||||
expect_not quiet "$out" "21st login"
|
||||
expect hf-apart "$(tog "$F7" status higgsfield)" missing
|
||||
out="$(tog "$F7" disable 21st)"
|
||||
expect_has parked "$out" "21st disabled (2 skills parked)"
|
||||
verdict PACK_21ST_UNCHANGED
|
||||
|
||||
# ── wiring ──────────────────────────────────────────────────
|
||||
# count <file> <fixed string> — matching lines (0 when none).
|
||||
count() { grep -cF -- "$2" "$ROOT/$1"; }
|
||||
|
||||
# Positive control first: the pattern does bite on a line that carries it.
|
||||
expect control "$(echo 'higgsfield-x external' | grep -cF higgsfield)" 1
|
||||
expect link-sh "$(count link.sh higgsfield)" 0
|
||||
expect profile-sh "$(count lib/profile.sh higgsfield)" 0
|
||||
expect profiles \
|
||||
"$(cat "$ROOT"/lib/profiles/*.profile | grep -cF higgsfield)" 0
|
||||
verdict OFF_BY_DEFAULT_WIRING
|
||||
|
||||
# ln_first / ln_last <file> <fixed string> — line number of a match.
|
||||
ln_first() { grep -nF -- "$2" "$ROOT/$1" | head -1 | cut -d: -f1; }
|
||||
ln_last() { grep -nF -- "$2" "$ROOT/$1" | tail -1 | cut -d: -f1; }
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# lib/tests/model-routing.test.sh — census: gate wiring + pins + executor shape (BDR-066, BDR-076)
|
||||
set -u
|
||||
R="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
skdir() { ls -d "$R"/skills/"$1" "$R"/skills/pack-*/skills/"$1" 2>/dev/null | head -1 | sed "s#^$R/##"; }
|
||||
pass=0; fail=0
|
||||
ok() { pass=$((pass+1)); }
|
||||
ko() { fail=$((fail+1)); printf 'FAIL %s\n' "$1"; }
|
||||
@@ -11,11 +12,11 @@ fm_lacks() { if awk 'NR<=10' "$R/$1" | grep -qF "$2"; then ko "$1 frontmatter mu
|
||||
|
||||
# 1) gate wired in the 17 reflection skills (orchestrators, /analyze, /guardrails, /a11y)
|
||||
for s in ship-feature init-project feat bugfix onboard seo geo web-validate harden audit-delta tour code-clean hotfix client-handover analyze guardrails a11y; do
|
||||
has "skills/$s/SKILL.md" 'lib/model-gate.md'
|
||||
has "$(skdir "$s")/SKILL.md" 'lib/model-gate.md'
|
||||
done
|
||||
# 2) gate NOT wired in the pure-execution/read-only skills (exclusion list)
|
||||
for s in commit-change doc status release-candidate refactor; do
|
||||
lacks "skills/$s/SKILL.md" 'lib/model-gate.md'
|
||||
lacks "$(skdir "$s")/SKILL.md" 'lib/model-gate.md'
|
||||
done
|
||||
# 3) executor + gate pins
|
||||
has "agents/feater.md" 'model: sonnet'
|
||||
@@ -31,7 +32,7 @@ lacks "agents/feater.md" 'AskUserQuestion'
|
||||
has "skills/ship-feature/SKILL.md" 'model: "sonnet"'
|
||||
has "skills/init-project/SKILL.md" 'model: "sonnet"'
|
||||
# 6) web-validate applies via L1 applier
|
||||
has "skills/web-validate/SKILL.md" 'subagent_type="hotfixer"'
|
||||
has "skills/pack-web-validate/skills/web-validate/SKILL.md" 'subagent_type="hotfixer"'
|
||||
# 7) wave-2 — pure-execution skills dispatch their agent (pin takes effect, off the big session model)
|
||||
has "skills/doc/SKILL.md" 'subagent_type="doc-syncer"'
|
||||
has "skills/status/SKILL.md" 'subagent_type="status-reporter"'
|
||||
@@ -105,9 +106,9 @@ lacks "agents/plugin-advisor.md" 'PHASE 1 — DETECT'
|
||||
has "lib/plugin-gate.md" 'subagent_type="plugin-probe"'
|
||||
has "lib/plugin-gate.md" 'subagent_type="plugin-advisor"'
|
||||
for s in plugin-check onboard init-project ship-feature; do
|
||||
has "skills/$s/SKILL.md" 'lib/plugin-gate.md'
|
||||
has "$(skdir "$s")/SKILL.md" 'lib/plugin-gate.md'
|
||||
# shellcheck disable=SC2016 # literal $HOME wanted: matching the exact inline-load string
|
||||
lacks "skills/$s/SKILL.md" 'Load `$HOME/.claude/agents/plugin-advisor.md`'
|
||||
lacks "$(skdir "$s")/SKILL.md" 'Load `$HOME/.claude/agents/plugin-advisor.md`'
|
||||
done
|
||||
# 14) BDR-077 W2/S2 — doc pipeline: ONE agent, TWO modes around the
|
||||
# dispatcher's gate (audit = opus via call-site override — documented
|
||||
@@ -124,10 +125,10 @@ has "skills/doc/SKILL.md" 'model="opus"'
|
||||
has "skills/doc/SKILL.md" 'MODE: patch'
|
||||
lacks "agents/scaffolder.md" 'INLINE-LOAD'
|
||||
for s in bugfix hotfix feat ship-feature init-project; do
|
||||
has "skills/$s/SKILL.md" 'MODE: audit'
|
||||
has "skills/$s/SKILL.md" 'doc-syncer", model="opus"'
|
||||
has "$(skdir "$s")/SKILL.md" 'MODE: audit'
|
||||
has "$(skdir "$s")/SKILL.md" 'doc-syncer", model="opus"'
|
||||
# shellcheck disable=SC2016 # literal $HOME wanted: matching the exact inline-load string
|
||||
lacks "skills/$s/SKILL.md" 'Load `$HOME/.claude/agents/doc-syncer.md`'
|
||||
lacks "$(skdir "$s")/SKILL.md" 'Load `$HOME/.claude/agents/doc-syncer.md`'
|
||||
done
|
||||
# 15) BDR-077 W2 — last inline execution converted: scaffolder + onboarder
|
||||
# are DISPATCHED (pins live); their gates/arbitration stay in the
|
||||
@@ -166,14 +167,14 @@ has "agents/geo-analyzer.md" 'MODE: collect'
|
||||
has "agents/geo-analyzer.md" 'MODE: judge'
|
||||
has "agents/geo-analyzer.md" 'MODE: template'
|
||||
has "agents/geo-analyzer.md" 'COLLECTION COMPLETE'
|
||||
has "skills/seo/SKILL.md" 'MODE: collect'
|
||||
has "skills/seo/SKILL.md" 'seo-analyzer", model="sonnet"'
|
||||
has "skills/seo/SKILL.md" 'never re-derive a score'
|
||||
has "skills/seo/SKILL.md" 'DISPATCHER ERROR CONTRACT'
|
||||
has "skills/geo/SKILL.md" 'MODE: collect'
|
||||
has "skills/geo/SKILL.md" 'geo-analyzer", model="sonnet"'
|
||||
has "skills/geo/SKILL.md" 'ERROR CONTRACT'
|
||||
has "skills/geo/SKILL.md" 'never re-derive a score'
|
||||
has "skills/pack-seo/skills/seo/SKILL.md" 'MODE: collect'
|
||||
has "skills/pack-seo/skills/seo/SKILL.md" 'seo-analyzer", model="sonnet"'
|
||||
has "skills/pack-seo/skills/seo/SKILL.md" 'never re-derive a score'
|
||||
has "skills/pack-seo/skills/seo/SKILL.md" 'DISPATCHER ERROR CONTRACT'
|
||||
has "skills/pack-seo/skills/geo/SKILL.md" 'MODE: collect'
|
||||
has "skills/pack-seo/skills/geo/SKILL.md" 'geo-analyzer", model="sonnet"'
|
||||
has "skills/pack-seo/skills/geo/SKILL.md" 'ERROR CONTRACT'
|
||||
has "skills/pack-seo/skills/geo/SKILL.md" 'never re-derive a score'
|
||||
has "agents/handover-doc-writer.md" 'SYNTH REPORT'
|
||||
|
||||
printf 'model-routing census: %d pass, %d fail\n' "$pass" "$fail"
|
||||
|
||||
Executable
+99
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env bash
|
||||
# lib/tests/pack-census.test.sh — lib/pack-census.sh: pack layout (manifest
|
||||
# name = folder, entries resolve, no skill twice, retired gstack names absent),
|
||||
# fragment invariants (same key set, fixed values, deny set, full = manifest
|
||||
# defaults), old-layout citers. Fixture cases, then the hermetic part of the
|
||||
# census on the real repo (dangling targets are WARN without --installed).
|
||||
set -u
|
||||
unset CLAUDE_PROFILE CLAUDE_PROFILE_SETTINGS
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
pass=0; fail=0
|
||||
check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1));
|
||||
printf 'FAIL %s: got[%s] want[%s]\n' "$1" "$2" "$3"; fi; }
|
||||
check_has() { case "$2" in *"$3"*) pass=$((pass+1));; *) fail=$((fail+1));
|
||||
printf 'FAIL %s: [%s] does not contain [%s]\n' "$1" "$2" "$3";; esac; }
|
||||
|
||||
FX="$(mktemp -d)"; trap 'rm -rf "$FX"' EXIT
|
||||
mkdir -p "$FX/lib/profiles" "$FX/hooks" "$FX/skills/core-a"; touch "$FX/skills/core-a/SKILL.md"
|
||||
printf 'gs-dead\n' > "$FX/lib/gstack-removed.list"
|
||||
mk_pack() { # name defaultEnabled skill...
|
||||
local n="$1" d="$2"; shift 2
|
||||
mkdir -p "$FX/skills/pack-$n/.claude-plugin" "$FX/skills/pack-$n/skills"
|
||||
printf '{"name":"pack-%s","version":"1.0.0","defaultEnabled":%s}\n' "$n" "$d" \
|
||||
> "$FX/skills/pack-$n/.claude-plugin/plugin.json"
|
||||
for s in "$@"; do mkdir -p "$FX/skills-external/$s"; touch "$FX/skills-external/$s/SKILL.md"
|
||||
ln -s "../../../skills-external/$s" "$FX/skills/pack-$n/skills/$s"; done
|
||||
}
|
||||
mk_pack alpha true a1 a2
|
||||
mk_pack beta false b1
|
||||
frag() { # name alpha beta deny(yes|no) — the two real connector names
|
||||
local d=""; [ "$4" = yes ] && d=', "deniedMcpServers": [{"serverName": "claude.ai higgsfield"}, {"serverName": "claude.ai Higgsfield AI"}]'
|
||||
printf '{"enabledPlugins": {"model-router@skills-dir": true, "pack-alpha@skills-dir": %s, "pack-beta@skills-dir": %s, "security-guidance@claude-code-plugins": true, "example-skills@anthropic-agent-skills": false, "brightdata-plugin@synced": false}%s}\n' \
|
||||
"$2" "$3" "$d" > "$FX/lib/profiles/$1.json"; }
|
||||
frag full true false no; frag dev false false yes
|
||||
census() { bash "$ROOT/lib/pack-census.sh" --repo "$FX" "$@" 2>&1; }
|
||||
|
||||
out="$(census)"; rc=$?
|
||||
check T1-green-rc "$rc" 0; check_has T1-green "$out" "PACKS OK 2 packs 3 skills"
|
||||
|
||||
rm -r "$FX/skills-external/b1"
|
||||
out="$(census)"; rc=$?
|
||||
check T2-off-dangling-rc "$rc" 0; check_has T2-off-dangling "$out" "WARN pack-beta: b1 target missing"
|
||||
rm -r "$FX/skills-external/a2"
|
||||
out="$(census)"; rc=$?
|
||||
check T3-on-dangling-test-rc "$rc" 0; check_has T3-on-dangling-test "$out" "WARN pack-alpha: a2 target missing"
|
||||
out="$(census --installed)"; rc=$?
|
||||
check T3-on-dangling-doctor-rc "$rc" 1; check_has T3-on-dangling-doctor "$out" "RED pack-alpha: a2 target missing (pack ON)"
|
||||
mkdir -p "$FX/skills-external/a2" "$FX/skills-external/b1"; touch "$FX/skills-external/a2/SKILL.md" "$FX/skills-external/b1/SKILL.md"
|
||||
|
||||
sed -i.bak 's/"pack-alpha"/"pack-alpho"/' "$FX/skills/pack-alpha/.claude-plugin/plugin.json"
|
||||
out="$(census)"; rc=$?
|
||||
check T4-name-rc "$rc" 1; check_has T4-name "$out" "RED pack-alpha: manifest name is pack-alpho"
|
||||
mv "$FX/skills/pack-alpha/.claude-plugin/plugin.json.bak" "$FX/skills/pack-alpha/.claude-plugin/plugin.json"
|
||||
|
||||
ln -s ../skills-external/a1 "$FX/skills/a1"
|
||||
out="$(census)"; rc=$?
|
||||
check T5-dup-rc "$rc" 1; check_has T5-dup "$out" "RED a1 listed twice: skills/a1 and pack-alpha — rm skills/a1 (a flat link)"
|
||||
rm "$FX/skills/a1"
|
||||
|
||||
ln -s "../../../skills-external/a1" "$FX/skills/pack-alpha/skills/gs-dead"
|
||||
out="$(census)"; rc=$?
|
||||
check T6-retired-rc "$rc" 1; check_has T6-retired "$out" "RED pack-alpha: gs-dead is a retired gstack skill"
|
||||
rm "$FX/skills/pack-alpha/skills/gs-dead"
|
||||
mv "$FX/lib/gstack-removed.list" "$FX/lib/gstack-removed.list.off"
|
||||
out="$(census)"; rc=$?
|
||||
check T6-nolist-rc "$rc" 1; check_has T6-nolist "$out" "RED lib/gstack-removed.list missing"
|
||||
mv "$FX/lib/gstack-removed.list.off" "$FX/lib/gstack-removed.list"
|
||||
|
||||
printf 'Read ~/.claude/skills/a1/SKILL.md\n' > "$FX/hooks/x.sh"
|
||||
cp "$ROOT/lib/tests/fixtures/pack-census-old-citers.sh" "$FX/hooks/y.sh" # the old-layout terms live in a fixture, not in this file (the census scans lib/tests/)
|
||||
out="$(census)"; rc=$?
|
||||
check T7-citer-rc "$rc" 1
|
||||
check_has T7-citer-tilde "$out" "RED hooks/x.sh cites ~/.claude/skills/a1"
|
||||
check_has T7-citer-home "$out" "RED hooks/y.sh cites \$HOME/.claude/skills/a2"
|
||||
check_has T7-citer-disabled "$out" "RED hooks/y.sh cites skills-disable""d/"
|
||||
check_has T7-citer-toggle "$out" "RED hooks/y.sh cites toggle-externa""l"
|
||||
check_has T7-citer-active "$out" "RED hooks/y.sh cites .active-profil""e"
|
||||
check_has T7-citer-profile "$out" "RED hooks/y.sh cites lib/profiles/web.profil""e"
|
||||
rm "$FX/hooks/x.sh" "$FX/hooks/y.sh"
|
||||
|
||||
# fragment invariants
|
||||
printf '{"enabledPlugins": {"model-router@skills-dir": true, "pack-alpha@skills-dir": true}}\n' > "$FX/lib/profiles/short.json"
|
||||
out="$(census)"; rc=$?
|
||||
check T8-keyset-rc "$rc" 1; check_has T8-keyset "$out" "RED lib/profiles/short.json: key set differs from full.json"
|
||||
rm "$FX/lib/profiles/short.json"
|
||||
frag full true true no
|
||||
out="$(census)"; rc=$?
|
||||
check T9-full-defaults-rc "$rc" 1; check_has T9-full-defaults "$out" "RED lib/profiles/full.json: pack-beta@skills-dir is true but the manifest default is false"
|
||||
frag full true false no
|
||||
sed -i.bak 's/"security-guidance@claude-code-plugins": true/"security-guidance@claude-code-plugins": false/' "$FX/lib/profiles/dev.json"
|
||||
out="$(census)"; rc=$?
|
||||
check T10-fixed-rc "$rc" 1; check_has T10-fixed "$out" "RED lib/profiles/dev.json: security-guidance@claude-code-plugins must be true"
|
||||
mv "$FX/lib/profiles/dev.json.bak" "$FX/lib/profiles/dev.json"
|
||||
|
||||
# real repo, hermetic part
|
||||
out="$(bash "$ROOT/lib/pack-census.sh" 2>&1)"; rc=$?
|
||||
check T11-real-rc "$rc" 0; check_has T11-real "$out" "PACKS OK 9 packs 55 skills"
|
||||
check T12-shellcheck "$(shellcheck "$ROOT/lib/pack-census.sh" >/dev/null 2>&1 && echo ok)" ok
|
||||
check T12-width "$(LC_ALL=C awk 'length($0) > 80' "$ROOT/lib/pack-census.sh" | wc -l | tr -d ' ')" 0
|
||||
printf 'PASS=%s FAIL=%s\n' "$pass" "$fail"; [ "$fail" -eq 0 ]
|
||||
@@ -5,6 +5,7 @@
|
||||
# adversarial behavior needs a live model (manual smoke), not a CI gate.
|
||||
set -u
|
||||
R="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
skdir() { ls -d "$R"/skills/"$1" "$R"/skills/pack-*/skills/"$1" 2>/dev/null | head -1 | sed "s#^$R/##"; }
|
||||
pass=0; fail=0
|
||||
ok() { pass=$((pass+1)); }
|
||||
ko() { fail=$((fail+1)); printf 'FAIL %s\n' "$1"; }
|
||||
@@ -41,8 +42,8 @@ has "$L" "fix-bundle"
|
||||
# 3) every reflection orchestrator wires the phase + carries a challenge summary
|
||||
# (hotfix wires it under a logic-only guard — STEP 1.8)
|
||||
for s in ship-feature init-project feat bugfix hotfix onboard audit-delta code-clean seo geo harden web-validate; do
|
||||
has "skills/$s/SKILL.md" "lib/challenge-plan.md"
|
||||
has "skills/$s/SKILL.md" "CHALLENGE SUMMARY"
|
||||
has "$(skdir "$s")/SKILL.md" "lib/challenge-plan.md"
|
||||
has "$(skdir "$s")/SKILL.md" "CHALLENGE SUMMARY"
|
||||
done
|
||||
|
||||
printf 'plan-challenge structure lock: %d pass, %d fail\n' "$pass" "$fail"
|
||||
|
||||
@@ -1,193 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# lib/tests/profile-census.test.sh — profile catalog invariants (skill-
|
||||
# catalog prune, 2026-09-28): no GSTACK_REMOVED name listed in any
|
||||
# profile, exactly one profile carries the `# SUPERSET-OF: full` marker
|
||||
# and it is a superset of full + the parked tools + every name any
|
||||
# profile carries, and `full` carries every name any other (non-max)
|
||||
# profile carries save one named exception (pr-review-toolkit).
|
||||
#
|
||||
# Hermetic: a passing baseline fixture, then one single-change mutant per
|
||||
# invariant (each mutant is a positive control — it MUST be detected).
|
||||
# Live part runs against this repo's real lib/profiles/ (a violation
|
||||
# there fails the suite for real, same style as
|
||||
# lib/tests/skill-routing-census.test.sh).
|
||||
set -u
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
# shellcheck source=lib/gstack-removed.sh disable=SC1091
|
||||
source "$ROOT/lib/gstack-removed.sh"
|
||||
|
||||
# Parked = kept installed, out of `full`, listed only in the superset
|
||||
# profile (`max`). Names come from the single denylist above for REMOVED;
|
||||
# PARKED has no such shared source (it is a positive allowlist, not a
|
||||
# denylist), so it is spelled out here.
|
||||
PARKED=(make-pdf diagram 21st-ai 21st-ui-explore 21st-ui-review)
|
||||
|
||||
# full carries every name any other (non-max) profile carries, with one
|
||||
# named exception: pr-review-toolkit is deliberately out of full (audit
|
||||
# 2026-07-02 #12, heaviest single plugin, ~2.2k tokens/session, PR-only
|
||||
# use) — measured 2026-09-28: it is the only name any specialized
|
||||
# profile carries that full lacks (audit.profile).
|
||||
FULL_EXCEPTIONS=(pr-review-toolkit)
|
||||
|
||||
pass=0; fail=0
|
||||
check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1));
|
||||
printf 'FAIL %s: got[%s] want[%s]\n' "$1" "$2" "$3"; fi; }
|
||||
|
||||
# census_check <profiles_dir> [parked_csv] [exceptions_csv] — one
|
||||
# violation code per line on stdout, rc 0 iff none. REMOVED always comes
|
||||
# from the sourced denylist (single source, never overridden);
|
||||
# PARKED/FULL_EXCEPTIONS default to the real production sets and can be
|
||||
# overridden per call (fixture runs use a small standalone catalog).
|
||||
census_check() {
|
||||
local dir="$1"
|
||||
# Unset (arg omitted, live call) falls back to the real production
|
||||
# set; an explicitly EMPTY string (fixture calls) means "none" and
|
||||
# must stay empty — hence "-" defaults, never ":-" (which would treat
|
||||
# empty the same as unset and silently pull the real set back in).
|
||||
local parked_csv="${2-$(IFS=,; echo "${PARKED[*]}")}"
|
||||
local exc_csv="${3-$(IFS=,; echo "${FULL_EXCEPTIONS[*]}")}"
|
||||
local removed_csv out
|
||||
removed_csv="$(IFS=,; echo "${GSTACK_REMOVED[*]}")"
|
||||
out=$(python3 - "$dir" "$removed_csv" "$parked_csv" "$exc_csv" <<'PY'
|
||||
import glob, os, re, sys
|
||||
|
||||
def entries(path):
|
||||
"""Entry = first whitespace token of a non-blank, non-comment line."""
|
||||
names = set()
|
||||
for line in open(path, encoding="utf-8"):
|
||||
s = line.strip()
|
||||
if s and not s.startswith("#"):
|
||||
names.add(s.split()[0])
|
||||
return names
|
||||
|
||||
def has_marker(path):
|
||||
text = open(path, encoding="utf-8").read()
|
||||
return re.search(r'^# SUPERSET-OF: full\s*$', text, re.M) is not None
|
||||
|
||||
def check_removed(by_name, removed):
|
||||
return [f"REMOVED_LISTED:{n}:{e}" for n, ents in by_name.items()
|
||||
for e in sorted(ents & removed)]
|
||||
|
||||
def find_superset(files):
|
||||
hits = [p for p in files if has_marker(p)]
|
||||
if not hits:
|
||||
return None, ["NO_SUPERSET"]
|
||||
if len(hits) > 1:
|
||||
return None, ["MANY_SUPERSETS"]
|
||||
return os.path.basename(hits[0])[:-len(".profile")], []
|
||||
|
||||
def check_superset_gap(by_name, sname, parked, exceptions):
|
||||
full = by_name.get("full", set())
|
||||
target = full | parked | exceptions
|
||||
return [f"SUPERSET_GAP:{n}" for n in sorted(target - by_name[sname])]
|
||||
|
||||
def check_max_gap(by_name, sname, removed):
|
||||
union = set().union(*by_name.values())
|
||||
gap = (union - removed) - by_name[sname]
|
||||
return [f"MAX_GAP:{n}" for n in sorted(gap)]
|
||||
|
||||
def check_full_gap(by_name, sname, removed, exceptions):
|
||||
trio = {"21st-ai", "21st-ui-explore", "21st-ui-review"}
|
||||
src = set().union(*(e for n, e in by_name.items()
|
||||
if n not in ("full", sname)))
|
||||
full = by_name.get("full", set())
|
||||
gap = src - full - removed - trio - exceptions
|
||||
return [f"FULL_GAP:{n}" for n in sorted(gap)]
|
||||
|
||||
def main():
|
||||
d, removed_csv, parked_csv, exc_csv = sys.argv[1:5]
|
||||
removed = {x for x in removed_csv.split(",") if x}
|
||||
parked = {x for x in parked_csv.split(",") if x}
|
||||
exceptions = {x for x in exc_csv.split(",") if x}
|
||||
|
||||
files = sorted(glob.glob(os.path.join(d, "*.profile")))
|
||||
by_name = {os.path.basename(p)[:-len(".profile")]: entries(p)
|
||||
for p in files}
|
||||
|
||||
violations = check_removed(by_name, removed)
|
||||
sname, sup_violations = find_superset(files)
|
||||
violations += sup_violations
|
||||
if sname:
|
||||
violations += check_superset_gap(by_name, sname, parked, exceptions)
|
||||
violations += check_max_gap(by_name, sname, removed)
|
||||
violations += check_full_gap(by_name, sname, removed, exceptions)
|
||||
|
||||
# Reason codes only, one per line; no exit here — the bash caller
|
||||
# derives pass/fail from whether this captured output is empty.
|
||||
print("\n".join(violations))
|
||||
|
||||
main()
|
||||
PY
|
||||
)
|
||||
if [ -n "$out" ]; then
|
||||
printf '%s\n' "$out"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# run_mutant <label> <dir> <code> <flag> — census_check on <dir> (fixture
|
||||
# PARKED override, empty FULL_EXCEPTIONS), asserts a non-zero rc AND the
|
||||
# presence of <code>; echoes <flag> when both hold (the positive-control
|
||||
# marker the contract CHECK greps for).
|
||||
run_mutant() {
|
||||
local label="$1" dir="$2" code="$3" flag="$4"
|
||||
local out rc hit nonzero
|
||||
out=$(census_check "$dir" "parked-x" ""); rc=$?
|
||||
[ -n "$out" ] && printf '%s\n' "$out"
|
||||
hit=$(printf '%s\n' "$out" | grep -qxF "$code" && echo yes || echo no)
|
||||
nonzero=$([ "$rc" -ne 0 ] && echo yes || echo no)
|
||||
check "$label-code" "$hit" yes
|
||||
check "$label-nonzero" "$nonzero" yes
|
||||
[ "$hit" = yes ] && [ "$nonzero" = yes ] && echo "$flag"
|
||||
}
|
||||
|
||||
# ── live: this repo's real profiles dir (a violation here → suite RED) ──
|
||||
live_out=$(census_check "$ROOT/lib/profiles"); live_rc=$?
|
||||
[ -n "$live_out" ] && printf '%s\n' "$live_out"
|
||||
check T1-live-clean "$live_rc" 0
|
||||
|
||||
# ── fixtures: baseline + one single-change mutant per invariant ────────
|
||||
WORK="$(mktemp -d)"; trap 'rm -rf "$WORK"' EXIT
|
||||
BASE="$WORK/baseline"
|
||||
mkdir -p "$BASE"
|
||||
cat > "$BASE/full.profile" <<'EOF'
|
||||
alpha
|
||||
beta
|
||||
EOF
|
||||
cat > "$BASE/qa.profile" <<'EOF'
|
||||
alpha
|
||||
EOF
|
||||
cat > "$BASE/max.profile" <<'EOF'
|
||||
# SUPERSET-OF: full
|
||||
alpha
|
||||
beta
|
||||
parked-x
|
||||
EOF
|
||||
|
||||
base_out=$(census_check "$BASE" "parked-x" ""); base_rc=$?
|
||||
[ -n "$base_out" ] && printf '%s\n' "$base_out"
|
||||
check T2-fixture-baseline-clean "$base_rc" 0
|
||||
[ "$base_rc" -eq 0 ] && echo FIXTURE_BASELINE_OK
|
||||
|
||||
# Mutant 1: a REMOVED name (ship) added to a profile other than full.
|
||||
M1="$WORK/mutant-removed"; cp -r "$BASE" "$M1"
|
||||
printf 'ship\n' >> "$M1/qa.profile"
|
||||
run_mutant T3-mutant-removed "$M1" 'REMOVED_LISTED:qa:ship' \
|
||||
FIXTURE_REMOVED_DETECTED
|
||||
|
||||
# Mutant 2: the superset profile drops a name full carries.
|
||||
M2="$WORK/mutant-superset"; cp -r "$BASE" "$M2"
|
||||
# BSD sed -i needs a suffix argument
|
||||
sed -i.bak '/^beta$/d' "$M2/max.profile" && rm -f "$M2/max.profile.bak"
|
||||
run_mutant T4-mutant-superset "$M2" 'SUPERSET_GAP:beta' \
|
||||
FIXTURE_SUPERSET_DETECTED
|
||||
|
||||
# Mutant 3: a non-full, non-superset profile carries a name full lacks.
|
||||
M3="$WORK/mutant-fullgap"; cp -r "$BASE" "$M3"
|
||||
printf 'gamma\n' >> "$M3/qa.profile"
|
||||
run_mutant T5-mutant-fullgap "$M3" 'FULL_GAP:gamma' \
|
||||
FIXTURE_FULLGAP_DETECTED
|
||||
|
||||
echo "PASS=$pass FAIL=$fail"
|
||||
[ "$fail" -eq 0 ]
|
||||
@@ -1,136 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# lib/tests/profile-default.test.sh — default profile (full) when nothing is
|
||||
# selected: `current` is label-driven (BDR-030 — gstack starts off, so a
|
||||
# parked count says nothing about which profile is on), `reset` lands on
|
||||
# DEFAULT_PROFILE, `gstack off` resolves the default through active_profile(),
|
||||
# and hooks/statusline.sh falls back to the same constant. Covers contract
|
||||
# criteria 2/3/4/5. Hermetic: fixture repo via *_REPO_OVERRIDE + fake `claude`
|
||||
# on PATH — same harness as profile-set-managed.test.sh.
|
||||
set -u
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
pass=0; fail=0
|
||||
check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1));
|
||||
printf 'FAIL %s: got[%s] want[%s]\n' "$1" "$2" "$3"; fi; }
|
||||
check_has() { case "$2" in *"$3"*) pass=$((pass+1));; *) fail=$((fail+1));
|
||||
printf 'FAIL %s: [%s] does not contain [%s]\n' "$1" "$2" "$3";; esac; }
|
||||
check_not() { case "$2" in *"$3"*) fail=$((fail+1));
|
||||
printf 'FAIL %s: [%s] unexpectedly contains [%s]\n' "$1" "$2" "$3";; *) pass=$((pass+1));; esac; }
|
||||
|
||||
FX="$(mktemp -d)"; trap 'rm -rf "$FX"' EXIT
|
||||
mkdir -p "$FX/skills" "$FX/skills-disabled" "$FX/lib/profiles" "$FX/bin" \
|
||||
"$FX/hooks" "$FX/skills-external/emil-design-eng" \
|
||||
"$FX/skills-external/observability-and-instrumentation"
|
||||
for g in gs-a gs-b gs-c; do
|
||||
mkdir -p "$FX/skills-external/gstack/$g"
|
||||
touch "$FX/skills-external/gstack/$g/SKILL.md"
|
||||
done
|
||||
cp "$ROOT/lib/profile.sh" "$ROOT/lib/toggle-external.sh" \
|
||||
"$ROOT/lib/gstack-removed.sh" "$FX/lib/"
|
||||
cp "$ROOT/hooks/statusline.sh" "$FX/hooks/"
|
||||
|
||||
cat > "$FX/lib/profiles/full.profile" <<'EOF'
|
||||
gs-a
|
||||
gs-b
|
||||
emil-design-eng external
|
||||
observability-and-instrumentation external
|
||||
EOF
|
||||
cat > "$FX/lib/profiles/otherish.profile" <<'EOF'
|
||||
gs-c
|
||||
EOF
|
||||
|
||||
# Fake claude: logs every call, prints nothing — skill_status greps for
|
||||
# "✔ enabled" and finds nothing, so every managed plugin reads back
|
||||
# "disabled" and set/reset never touch real plugin state.
|
||||
cat > "$FX/bin/claude" <<EOF
|
||||
#!/usr/bin/env bash
|
||||
FX="$FX"
|
||||
echo "\$*" >> "\$FX/claude-calls.log"
|
||||
exit 0
|
||||
EOF
|
||||
chmod +x "$FX/bin/claude"
|
||||
|
||||
run() { PATH="$FX/bin:$PATH" PROFILE_REPO_OVERRIDE="$FX" \
|
||||
TOGGLE_EXTERNAL_REPO_OVERRIDE="$FX" bash "$FX/lib/profile.sh" "$@"; }
|
||||
statusline() { echo '{}' | bash "$FX/hooks/statusline.sh"; }
|
||||
first_word() { printf '%s' "${1%% *}"; }
|
||||
|
||||
# --- T1: clean seed, no cache — current names the default, "not applied" ---
|
||||
out="$(run current)"
|
||||
check T1-first-word "$(first_word "$out")" full
|
||||
check_has T1-not-applied "$out" "default — not applied yet"
|
||||
check_not T1-no-all-gstack "$out" "all gstack"
|
||||
|
||||
# --- T2: clean seed, no cache — gstack off is a clean no-op (rc 0) ---
|
||||
run gstack off >/dev/null 2>&1; rc=$?
|
||||
check T2-rc "$rc" 0
|
||||
|
||||
# --- T2b: one gstack skill manually linked, no cache — off parks just it ---
|
||||
ln -s "$FX/skills-external/gstack/gs-c" "$FX/skills/gs-c"
|
||||
run gstack off >/dev/null 2>&1; rc=$?
|
||||
check T2b-rc "$rc" 0
|
||||
check T2b-gsc-parked "$([ -e "$FX/skills-disabled/gstack__gs-c" ] && echo p || echo n)" p
|
||||
check T2b-gsa-absent "$([ -e "$FX/skills/gs-a" ] && echo on || echo off)" off
|
||||
rm -rf "$FX/skills-disabled/gstack__gs-c" # back to the clean seed
|
||||
|
||||
# --- T3: cache "none" (CRLF) — off is still a clean no-op ---
|
||||
printf 'none\r\n' > "$FX/.active-profile"
|
||||
run gstack off >/dev/null 2>&1; rc=$?
|
||||
check T3-rc "$rc" 0
|
||||
|
||||
# --- T4: cache names an unknown profile — off errors, current says so ---
|
||||
printf 'ghost\n' > "$FX/.active-profile"
|
||||
run gstack off >/dev/null 2>&1; rc=$?
|
||||
check T4-rc "$rc" 1
|
||||
out="$(run current)"
|
||||
check T4-first-word "$(first_word "$out")" ghost
|
||||
check_has T4-unknown "$out" "unknown profile"
|
||||
|
||||
# --- T5: reset lands on the default profile, exclusively ---
|
||||
run reset >/dev/null 2>&1
|
||||
check T5-cache "$(cat "$FX/.active-profile" 2>/dev/null)" full
|
||||
check T5-gsa-on "$([ -e "$FX/skills/gs-a" ] && echo on || echo off)" on
|
||||
check T5-gsb-on "$([ -e "$FX/skills/gs-b" ] && echo on || echo off)" on
|
||||
check T5-gsc-off "$([ -e "$FX/skills/gs-c" ] && echo on || echo off)" off
|
||||
check T5-emil-on "$([ -e "$FX/skills/emil-design-eng" ] && echo on || echo off)" on
|
||||
check T5-obs-on "$([ -e "$FX/skills/observability-and-instrumentation" ] && echo on || echo off)" on
|
||||
out="$(run current)"
|
||||
check T5-first-word "$(first_word "$out")" full
|
||||
check_has T5-match "$out" "100% match"
|
||||
check_not T5-not-applied "$out" "not applied"
|
||||
|
||||
# --- T6: current is label-driven even for a gstack-only profile ---
|
||||
run set otherish >/dev/null 2>&1
|
||||
out="$(run current)"
|
||||
check T6-first-word "$(first_word "$out")" otherish
|
||||
run reset >/dev/null 2>&1
|
||||
check T6-gsc-parked "$([ -e "$FX/skills-disabled/gstack__gs-c" ] && echo p || echo n)" p
|
||||
check T6-gsa-on "$([ -e "$FX/skills/gs-a" ] && echo on || echo off)" on
|
||||
check T6-cache "$(cat "$FX/.active-profile" 2>/dev/null)" full
|
||||
|
||||
# --- T7: gstack on restores parked skills, keeps the profile label ---
|
||||
run set otherish >/dev/null 2>&1
|
||||
run gstack on >/dev/null 2>&1
|
||||
out="$(run current)"
|
||||
check T7-first-word "$(first_word "$out")" otherish
|
||||
check_not T7-no-default "$out" "default"
|
||||
|
||||
# --- T8-T11: statusline fallback + constant read ---
|
||||
rm -f "$FX/.active-profile"
|
||||
out="$(statusline)"
|
||||
check_has T8-full "$out" "profile: full"
|
||||
|
||||
printf 'otherish\n' > "$FX/.active-profile"
|
||||
out="$(statusline)"
|
||||
check_has T9-otherish "$out" "profile: otherish"
|
||||
|
||||
printf ' none \r' > "$FX/.active-profile"
|
||||
out="$(statusline)"
|
||||
check_has T10-full "$out" "profile: full"
|
||||
|
||||
# BSD sed -i needs a suffix argument
|
||||
sed -i.bak 's/^DEFAULT_PROFILE="full"/DEFAULT_PROFILE="otherish"/' "$FX/lib/profile.sh" && rm -f "$FX/lib/profile.sh.bak"
|
||||
rm -f "$FX/.active-profile"
|
||||
out="$(statusline)"
|
||||
check_has T11-otherish "$out" "profile: otherish"
|
||||
|
||||
printf 'PASS=%s FAIL=%s\n' "$pass" "$fail"; [ "$fail" -eq 0 ]
|
||||
@@ -1,104 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# lib/tests/profile-set-managed.test.sh — `set` symmetry on managed
|
||||
# externals, gstack on-demand, external from-source (BDR-079). No MCP is
|
||||
# managed (MANAGED_MCPS is empty): the 21st skills are managed as externals,
|
||||
# so the pack's park/restore round-trip is what this covers on that side.
|
||||
# Hermetic: fixture repo via *_REPO_OVERRIDE + fake `claude` on PATH.
|
||||
set -u
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
pass=0; fail=0
|
||||
check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1));
|
||||
printf 'FAIL %s: got[%s] want[%s]\n' "$1" "$2" "$3"; fi; }
|
||||
|
||||
FX="$(mktemp -d)"; trap 'rm -rf "$FX"' EXIT
|
||||
mkdir -p "$FX/skills" "$FX/skills-disabled" "$FX/lib/profiles" "$FX/bin" \
|
||||
"$FX/skills-external/emil-design-eng" "$FX/skills-external/other-ext" \
|
||||
"$FX/skills-external/21st-ui-build" \
|
||||
"$FX/skills-external/observability-and-instrumentation"
|
||||
for g in gs-a gs-b gs-c; do
|
||||
mkdir -p "$FX/skills-external/gstack/$g"
|
||||
touch "$FX/skills-external/gstack/$g/SKILL.md"
|
||||
done
|
||||
cp "$ROOT/lib/profile.sh" "$ROOT/lib/toggle-external.sh" \
|
||||
"$ROOT/lib/gstack-removed.sh" "$FX/lib/"
|
||||
|
||||
# Non-managed external, enabled from the start — must never be touched.
|
||||
ln -s "$FX/skills-external/other-ext" "$FX/skills/other-ext"
|
||||
|
||||
cat > "$FX/lib/profiles/designish.profile" <<'EOF'
|
||||
gs-a
|
||||
gs-b
|
||||
emil-design-eng external
|
||||
21st-ui-build external
|
||||
observability-and-instrumentation external
|
||||
EOF
|
||||
cat > "$FX/lib/profiles/backendish.profile" <<'EOF'
|
||||
gs-c
|
||||
EOF
|
||||
|
||||
# Fake claude: logs every call. No MCP state to keep — MANAGED_MCPS is empty,
|
||||
# so `set` must never reach for `claude mcp` at all (asserted below).
|
||||
cat > "$FX/bin/claude" <<EOF
|
||||
#!/usr/bin/env bash
|
||||
FX="$FX"
|
||||
echo "\$*" >> "\$FX/claude-calls.log"
|
||||
exit 0
|
||||
EOF
|
||||
chmod +x "$FX/bin/claude"
|
||||
|
||||
run() { PATH="$FX/bin:$PATH" PROFILE_REPO_OVERRIDE="$FX" \
|
||||
TOGGLE_EXTERNAL_REPO_OVERRIDE="$FX" bash "$FX/lib/profile.sh" "$@"; }
|
||||
|
||||
# --- set designish: gstack on-demand + externals from-source (21st + emil) ---
|
||||
run set designish >/dev/null 2>&1
|
||||
check T1-gsa-on "$([ -e "$FX/skills/gs-a" ] && echo on || echo off)" on
|
||||
check T2-gsb-on "$([ -e "$FX/skills/gs-b" ] && echo on || echo off)" on
|
||||
check T3-gsc-off "$([ -e "$FX/skills/gs-c" ] && echo on || echo off)" off
|
||||
check T4-emil-src "$([ -L "$FX/skills/emil-design-eng" ] && echo on || echo off)" on
|
||||
check T5-21st-src "$([ -L "$FX/skills/21st-ui-build" ] && echo on || echo off)" on
|
||||
check T5b-obs-src "$([ -L "$FX/skills/observability-and-instrumentation" ] && echo on || echo off)" on
|
||||
check T6-no-mcp "$(grep -c '^mcp ' "$FX/claude-calls.log" || true)" 0
|
||||
|
||||
# --- set backendish: managed leftovers parked/unregistered ---
|
||||
run set backendish >/dev/null 2>&1
|
||||
check T7-gsc-on "$([ -e "$FX/skills/gs-c" ] && echo on || echo off)" on
|
||||
check T8-gsa-park "$([ -e "$FX/skills-disabled/gstack__gs-a" ] && echo p || echo n)" p
|
||||
check T9-emil-off "$([ -e "$FX/skills/emil-design-eng" ] && echo on || echo off)" off
|
||||
check T10-emil-park "$([ -e "$FX/skills-disabled/emil-design-eng" ] && echo p || echo n)" p
|
||||
check T11-21st-off "$([ -e "$FX/skills/21st-ui-build" ] && echo on || echo off)" off
|
||||
check T12-21st-park "$([ -e "$FX/skills-disabled/21st-ui-build" ] && echo p || echo n)" p
|
||||
check T12b-obs-off "$([ -e "$FX/skills/observability-and-instrumentation" ] && echo on || echo off)" off
|
||||
check T12c-obs-park "$([ -e "$FX/skills-disabled/observability-and-instrumentation" ] && echo p || echo n)" p
|
||||
check T13-other-untouched "$([ -e "$FX/skills/other-ext" ] && echo on || echo off)" on
|
||||
|
||||
# --- back to designish: parked external restored (not re-sourced) ---
|
||||
run set designish >/dev/null 2>&1
|
||||
check T14-emil-back "$([ -e "$FX/skills/emil-design-eng" ] && echo on || echo off)" on
|
||||
check T15-park-gone "$([ -e "$FX/skills-disabled/emil-design-eng" ] && echo p || echo n)" n
|
||||
check T16-21st-back "$([ -e "$FX/skills/21st-ui-build" ] && echo on || echo off)" on
|
||||
check T16b-obs-back "$([ -e "$FX/skills/observability-and-instrumentation" ] && echo on || echo off)" on
|
||||
check T16c-obs-park-gone "$([ -e "$FX/skills-disabled/observability-and-instrumentation" ] && echo p || echo n)" n
|
||||
check T17-no-mcp-ever "$(grep -c '^mcp ' "$FX/claude-calls.log" || true)" 0
|
||||
|
||||
# --- a failing `claude plugin enable` must warn, never abort `set` ---
|
||||
# Guards the capture-inside-the-condition form: a bare out="$(claude …)"
|
||||
# would trip errexit and skip every entry after the plugin.
|
||||
mkdir -p "$FX/failbin"
|
||||
cat > "$FX/failbin/claude" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
[ "$1 $2" = "plugin enable" ] && exit 1
|
||||
exit 0
|
||||
EOF
|
||||
chmod +x "$FX/failbin/claude"
|
||||
cat > "$FX/lib/profiles/pluginish.profile" <<'EOF'
|
||||
fake-plug plugin@fake-market
|
||||
gs-a
|
||||
EOF
|
||||
rm -f "$FX/skills/gs-a"
|
||||
PATH="$FX/failbin:$PATH" PROFILE_REPO_OVERRIDE="$FX" \
|
||||
TOGGLE_EXTERNAL_REPO_OVERRIDE="$FX" bash "$FX/lib/profile.sh" set pluginish \
|
||||
>/dev/null 2>&1
|
||||
check T18-failing-plugin-enable-keeps-going \
|
||||
"$([ -e "$FX/skills/gs-a" ] && echo on || echo off)" on
|
||||
|
||||
printf 'PASS=%s FAIL=%s\n' "$pass" "$fail"; [ "$fail" -eq 0 ]
|
||||
Executable
+137
@@ -0,0 +1,137 @@
|
||||
#!/usr/bin/env bash
|
||||
# lib/tests/profile.test.sh — lib/profile.sh + lib/profile-state.jq on a
|
||||
# fixture repo: fragments, the four precedence levels, the deniedMcpServers
|
||||
# union, set/unset/enable/disable merge semantics, refusals (rc 2, nothing
|
||||
# written), the /mcp toggle, root walk-up, timing. Hermetic:
|
||||
# PROFILE_REPO_OVERRIDE + PROFILE_USER_SETTINGS + PROFILE_CLAUDE_JSON, no claude.
|
||||
set -u
|
||||
unset CLAUDE_PROFILE CLAUDE_PROFILE_SETTINGS
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
pass=0; fail=0
|
||||
check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1));
|
||||
printf 'FAIL %s: got[%s] want[%s]\n' "$1" "$2" "$3"; fi; }
|
||||
check_has() { case "$2" in *"$3"*) pass=$((pass+1));; *) fail=$((fail+1));
|
||||
printf 'FAIL %s: [%s] does not contain [%s]\n' "$1" "$2" "$3";; esac; }
|
||||
|
||||
FX="$(mktemp -d)"; trap 'rm -rf "$FX"' EXIT
|
||||
mkdir -p "$FX/lib/profiles" "$FX/skills" "$FX/proj/.claude" "$FX/proj/sub/deeper" "$FX/home" "$FX/nowhere"
|
||||
mk_pack() { mkdir -p "$FX/skills/pack-$1/.claude-plugin"
|
||||
printf '{"name":"pack-%s","defaultEnabled":%s}\n' "$1" "$2" > "$FX/skills/pack-$1/.claude-plugin/plugin.json"; }
|
||||
mk_pack a true; mk_pack b false # pack-c has no dir (missing)
|
||||
frag() { # name pack-a pack-b pack-c ui deny(yes|no) [model]
|
||||
local d="" m=""
|
||||
[ "$6" = yes ] && d=', "deniedMcpServers": [{"serverName": "claude.ai X"}, {"serverName": "claude.ai Y"}]'
|
||||
[ -n "${7:-}" ] && m=", \"model\": \"$7\""
|
||||
printf '{"enabledPlugins": {"model-router@skills-dir": true, "pack-a@skills-dir": %s, "pack-b@skills-dir": %s, "pack-c@skills-dir": %s, "ui@mk": %s}%s%s}\n' \
|
||||
"$2" "$3" "$4" "$5" "$d" "$m" > "$FX/lib/profiles/$1.json"; }
|
||||
frag fullx true false false true no # = manifest defaults + user ui on
|
||||
frag devx true false false false yes
|
||||
frag minix false false false false yes haiku
|
||||
printf -- '- **fullx**: everything\n- **devx**: dev only\n- **minix**: nothing\n' > "$FX/lib/profiles/README.md"
|
||||
printf '{"enabledPlugins": {"ui@mk": true}}\n' > "$FX/home/settings.json"
|
||||
printf '{}\n' > "$FX/home/claude.json"
|
||||
printf '# proj\n' > "$FX/proj/CLAUDE.md"
|
||||
P() { PROFILE_REPO_OVERRIDE="$FX" PROFILE_USER_SETTINGS="$FX/home/settings.json" \
|
||||
PROFILE_CLAUDE_JSON="$FX/home/claude.json" bash "$ROOT/lib/profile.sh" -C "$FX/proj" "$@"; }
|
||||
plain() { P current --plain | tr '\n' ' '; }
|
||||
L="$FX/proj/.claude/settings.local.json"
|
||||
|
||||
out="$(P list)"; check_has T1-list "$out" "dev only"; check_has T1-list-name "$out" "devx"
|
||||
out="$(P show devx)"; check_has T2-show-on "$out" "pack-a@skills-dir"
|
||||
check_has T2-show-missing "$out" "off missing (no skills/pack-c/)"
|
||||
check_has T2-show-deny "$out" "connectors denied: claude.ai X, claude.ai Y"
|
||||
|
||||
out="$(plain)"
|
||||
check_has T3-default "$out" "profile=fullx source=default flag=- pack-a=on pack-b=off pack-c=off plugin:model-router@skills-dir=on plugin:ui@mk=on model=- model-source=- mcp-off=-"
|
||||
out="$(P current)"; check_has T3-human "$out" "profile: fullx [default]"
|
||||
|
||||
# precedence, before any local write: project settings.json over user
|
||||
printf '{"enabledPlugins": {"pack-b@skills-dir": true}, "model": "opus"}\n' > "$FX/proj/.claude/settings.json"
|
||||
out="$(plain)"; check_has T6-project "$out" "profile=custom source=default flag=- pack-a=on pack-b=on "
|
||||
check_has T6-project-model "$out" "model=opus model-source=project "
|
||||
rm "$FX/proj/.claude/settings.json"
|
||||
|
||||
# set keeps the other keys, writes the managed ones
|
||||
printf '{"permissions": {"allow": ["Bash(ls)"]}, "model": "sonnet"}\n' > "$L"
|
||||
out="$(P set devx)"; rc=$?
|
||||
check T4-set-rc "$rc" 0; check_has T4-set-hint "$out" "/reload-plugins"
|
||||
check T4-keep-perm "$(jq -c .permissions "$L")" '{"allow":["Bash(ls)"]}'
|
||||
check T4-keep-model "$(jq -r .model "$L")" sonnet
|
||||
check T4-deny "$(jq -c '[.deniedMcpServers[].serverName]' "$L")" '["claude.ai X","claude.ai Y"]'
|
||||
out="$(plain)"
|
||||
check_has T5-local "$out" "profile=devx source=local flag=- pack-a=on pack-b=off pack-c=off plugin:model-router@skills-dir=on plugin:ui@mk=off connector:claude.ai X=denied connector:claude.ai Y=denied model=sonnet model-source=local mcp-off=-"
|
||||
|
||||
# local over project; flag over local
|
||||
printf '{"enabledPlugins": {"pack-b@skills-dir": true}}\n' > "$FX/proj/.claude/settings.json"
|
||||
out="$(plain)"; check_has T6-local-over-project "$out" "profile=devx source=local flag=- pack-a=on pack-b=off "
|
||||
printf '{"enabledPlugins": {"pack-b@skills-dir": true}}\n' > "$FX/flag.json"
|
||||
out="$(CLAUDE_PROFILE_SETTINGS="$FX/flag.json" CLAUDE_PROFILE=x plain)"
|
||||
check_has T6-flag "$out" "profile=custom source=flag flag=x pack-a=on pack-b=on "
|
||||
rm "$FX/proj/.claude/settings.json"
|
||||
|
||||
# union of deniedMcpServers: flag fullx over local devx keeps the denies → custom
|
||||
out="$(CLAUDE_PROFILE_SETTINGS="$FX/lib/profiles/fullx.json" CLAUDE_PROFILE=fullx plain)"
|
||||
check_has T7-union "$out" "profile=custom source=flag flag=fullx "
|
||||
check_has T7-union-denied "$out" "connector:claude.ai X=denied "
|
||||
|
||||
# refusals
|
||||
cp "$L" "$FX/before.json"; printf '{"enabledPlugins": \n' > "$L"; cp "$L" "$FX/broken.json"
|
||||
out="$(P set devx 2>&1)"; rc=$?
|
||||
check T8-invalid-rc "$rc" 2; check_has T8-invalid-msg "$out" "not valid JSON"
|
||||
check T8-invalid-untouched "$(cmp -s "$FX/broken.json" "$L" && echo same)" same
|
||||
cp "$FX/before.json" "$L"
|
||||
out="$(PROFILE_REPO_OVERRIDE="$FX" PROFILE_USER_SETTINGS="$FX/home/settings.json" PROFILE_CLAUDE_JSON="$FX/home/claude.json" \
|
||||
bash "$ROOT/lib/profile.sh" -C "$FX/nowhere" set devx 2>&1)"; rc=$?
|
||||
check T9-root-rc "$rc" 2; check_has T9-root-msg "$out" "not a project root"; check T9-root-nothing "$(ls -A "$FX/nowhere")" ""
|
||||
out="$(P set nope 2>&1)"; rc=$?; check T10-unknown-rc "$rc" 2; check_has T10-unknown-list "$out" "fullx"
|
||||
|
||||
# enable / disable, three spellings, flag note
|
||||
P enable b >/dev/null; check T11-enable "$(jq -r '.enabledPlugins["pack-b@skills-dir"]' "$L")" true
|
||||
P disable pack-b >/dev/null; check T11-disable "$(jq -r '.enabledPlugins["pack-b@skills-dir"]' "$L")" false
|
||||
P enable pack-b@skills-dir >/dev/null; check T11-enable-id "$(jq -r '.enabledPlugins["pack-b@skills-dir"]' "$L")" true
|
||||
out="$(P enable zzz 2>&1)"; rc=$?; check T11-unknown "$rc" 2
|
||||
out="$(CLAUDE_PROFILE_SETTINGS="$FX/flag.json" CLAUDE_PROFILE=x P enable a 2>&1)"
|
||||
check_has T11-flag-note "$out" "relaunch: cc <name> <profile>"
|
||||
P disable b >/dev/null
|
||||
|
||||
# unset: managed keys gone, permissions kept; model removed only when it is the profile's
|
||||
P unset >/dev/null
|
||||
check T12-unset-ep "$(jq -c '.enabledPlugins // "gone"' "$L")" '"gone"'
|
||||
check T12-unset-deny "$(jq -c '.deniedMcpServers // "gone"' "$L")" '"gone"'
|
||||
check T12-unset-perm "$(jq -c .permissions "$L")" '{"allow":["Bash(ls)"]}'
|
||||
check T12-unset-model-kept "$(jq -r .model "$L")" sonnet
|
||||
P set minix >/dev/null; check T12-minix-model "$(jq -r .model "$L")" haiku
|
||||
P unset >/dev/null; check T12-minix-model-gone "$(jq -r '.model // "gone"' "$L")" gone
|
||||
|
||||
# /mcp toggle; unreadable ~/.claude.json; disableClaudeAiConnectors any-source
|
||||
printf '{"projects": {"%s": {"disabledMcpServers": ["foo", "bar"]}}}\n' "$FX/proj" > "$FX/home/claude.json"
|
||||
out="$(P current)"; check_has T13-mcp-off "$out" "profile: custom (off: foo,bar) [default]"
|
||||
out="$(plain)"; check_has T13-mcp-off-plain "$out" "mcp-off=foo,bar"
|
||||
printf '{broken\n' > "$FX/home/claude.json"
|
||||
out="$(plain)"; rc=$?; check T14-unknown-rc "$rc" 0; check_has T14-unknown "$out" "mcp-off=unknown"
|
||||
printf '{}\n' > "$FX/home/claude.json"
|
||||
printf '{"enabledPlugins": {"ui@mk": true}, "disableClaudeAiConnectors": true}\n' > "$FX/home/settings.json"
|
||||
out="$(plain)"; check_has T15-all-denied "$out" "connector:*=denied"; check_has T15-custom "$out" "profile=custom "
|
||||
printf '{"enabledPlugins": {"ui@mk": true}}\n' > "$FX/home/settings.json"
|
||||
|
||||
# a missing pack still written; diff
|
||||
P set devx >/dev/null; check T16-missing-written "$(jq -r '.enabledPlugins["pack-c@skills-dir"]' "$L")" false
|
||||
out="$(P diff fullx)"; check_has T17-diff-ui "$out" "ui@mk: off → on"
|
||||
check_has T17-diff-conn "$out" "connectors denied: claude.ai X, claude.ai Y → "
|
||||
out="$(P diff devx)"; check T17-nodiff "$out" "no difference from devx"
|
||||
|
||||
# shellcheck + width
|
||||
check T18-shellcheck "$(shellcheck "$ROOT/lib/profile.sh" >/dev/null 2>&1 && echo ok)" ok
|
||||
check T18-width "$(LC_ALL=C awk 'length($0) > 80' "$ROOT/lib/profile.sh" "$ROOT/lib/profile-state.jq" | wc -l | tr -d ' ')" 0
|
||||
|
||||
# root walk-up from a subdirectory; a bare dir stays itself
|
||||
out="$(PROFILE_REPO_OVERRIDE="$FX" PROFILE_USER_SETTINGS="$FX/home/settings.json" PROFILE_CLAUDE_JSON="$FX/home/claude.json" \
|
||||
bash "$ROOT/lib/profile.sh" -C "$FX/proj/sub/deeper" current --plain | tr '\n' ' ')"
|
||||
check_has T19-walkup "$out" "profile=devx source=local "
|
||||
|
||||
# timing: two jq calls, under 100 ms here (spec target 50 ms, measured in Task 12)
|
||||
t0=$(date +%s%N); P current --plain >/dev/null; t1=$(date +%s%N)
|
||||
ms=$(( (t1 - t0) / 1000000 )); echo "current --plain: ${ms} ms"
|
||||
check T20-timing "$([ "$ms" -le 100 ] && echo fast || echo "slow:${ms}ms")" fast
|
||||
|
||||
printf 'PASS=%s FAIL=%s\n' "$pass" "$fail"; [ "$fail" -eq 0 ]
|
||||
@@ -19,12 +19,12 @@ GEO=agents/geo-analyzer.md
|
||||
# skills/geo STEP 1B) fail-closes on this exact shape
|
||||
has "$SEO" 'SEO JUDGE — VERDICT: ERROR('
|
||||
has "$GEO" 'GEO JUDGE — VERDICT: ERROR('
|
||||
has "skills/seo/SKILL.md" 'SEO JUDGE — VERDICT: ERROR('
|
||||
has "skills/geo/SKILL.md" 'GEO JUDGE — VERDICT: ERROR('
|
||||
has "skills/pack-seo/skills/seo/SKILL.md" 'SEO JUDGE — VERDICT: ERROR('
|
||||
has "skills/pack-seo/skills/geo/SKILL.md" 'GEO JUDGE — VERDICT: ERROR('
|
||||
|
||||
# 2) fix-bundle section + apply sentinel — parsed by /seo STEP 1b/1.5 and
|
||||
# /geo STEP 1b/2 before any L1 apply
|
||||
for f in "$SEO" "$GEO" skills/seo/SKILL.md skills/geo/SKILL.md; do
|
||||
for f in "$SEO" "$GEO" skills/pack-seo/skills/seo/SKILL.md skills/pack-seo/skills/geo/SKILL.md; do
|
||||
has "$f" '## FIX BUNDLE'
|
||||
has "$f" 'READY TO APPLY — awaiting dispatcher confirmation'
|
||||
done
|
||||
@@ -32,8 +32,8 @@ done
|
||||
# 3) signals handoff — judge loads the collect artifact fail-closed
|
||||
has "$SEO" '.audit/seo-signals-'
|
||||
has "$GEO" '.audit/geo-signals-'
|
||||
has "skills/seo/SKILL.md" '.audit/seo-signals-<RUNID_SEO>.md'
|
||||
has "skills/geo/SKILL.md" '.audit/geo-signals-<RUNID>.md'
|
||||
has "skills/pack-seo/skills/seo/SKILL.md" '.audit/seo-signals-<RUNID_SEO>.md'
|
||||
has "skills/pack-seo/skills/geo/SKILL.md" '.audit/geo-signals-<RUNID>.md'
|
||||
|
||||
# 4) STEP numbering — dispatchers reference agent step ranges literally:
|
||||
# /seo: "STEP 2-5" collect · "STEP 6-11" seo judge · "STEP 6-12" geo
|
||||
@@ -43,14 +43,14 @@ has "skills/geo/SKILL.md" '.audit/geo-signals-<RUNID>.md'
|
||||
# and the ranges on the dispatcher side.
|
||||
for n in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14; do has "$SEO" "## STEP $n —"; done
|
||||
for n in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do has "$GEO" "## STEP $n —"; done
|
||||
has "skills/seo/SKILL.md" 'STEP 2-5'
|
||||
has "skills/seo/SKILL.md" 'STEP 6-11'
|
||||
has "skills/seo/SKILL.md" 'STEP 6-12'
|
||||
has "skills/seo/SKILL.md" 'STEP 12-14'
|
||||
has "skills/seo/SKILL.md" 'STEP 13-15'
|
||||
has "skills/geo/SKILL.md" 'STEP 0-5'
|
||||
has "skills/geo/SKILL.md" '6-12, report scoring' # "STEP\n6-12" line-wraps
|
||||
has "skills/geo/SKILL.md" 'STEP 13-15'
|
||||
has "skills/pack-seo/skills/seo/SKILL.md" 'STEP 2-5'
|
||||
has "skills/pack-seo/skills/seo/SKILL.md" 'STEP 6-11'
|
||||
has "skills/pack-seo/skills/seo/SKILL.md" 'STEP 6-12'
|
||||
has "skills/pack-seo/skills/seo/SKILL.md" 'STEP 12-14'
|
||||
has "skills/pack-seo/skills/seo/SKILL.md" 'STEP 13-15'
|
||||
has "skills/pack-seo/skills/geo/SKILL.md" 'STEP 0-5'
|
||||
has "skills/pack-seo/skills/geo/SKILL.md" '6-12, report scoring' # "STEP\n6-12" line-wraps
|
||||
has "skills/pack-seo/skills/geo/SKILL.md" 'STEP 13-15'
|
||||
|
||||
# 5) collect-mode report emission (dispatcher waits on it between phases)
|
||||
has "$SEO" 'COLLECT REPORT'
|
||||
@@ -71,7 +71,7 @@ has "$SEO" 'applier: bash'
|
||||
# The emit instruction lives in /seo's DISPATCH PROMPTS, not in the agent
|
||||
# specs (geo-analyzer.md never mentions it; seo-analyzer.md only once,
|
||||
# incidentally — NOT locked, it is prose). Lock the dispatcher side only.
|
||||
has "skills/seo/SKILL.md" 'CROSS-AGENT NOTES TO'
|
||||
has "skills/pack-seo/skills/seo/SKILL.md" 'CROSS-AGENT NOTES TO'
|
||||
|
||||
# 8) trajectory block — mandatory in envelopes (/geo audit-end deliverables,
|
||||
# /seo §1 merge)
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# lib/tests/toggle-external-repo-resolution.test.sh
|
||||
#
|
||||
# Regression test for J4-20 (BLK-006 class): toggle-external.sh:34 resolved
|
||||
# REPO with a LOGICAL `cd` (no -P). Direct invocation via a symlinked path —
|
||||
# exactly the real ~/.claude/lib -> <repo>/lib layout — resolves REPO to the
|
||||
# SYMLINK's logical parent instead of the physical repo root, so every path
|
||||
# derived from it (SKILLS_DIR, DISABLED_DIR) points at the wrong tree.
|
||||
set -u
|
||||
HELPER_SRC="$(cd "$(dirname "$0")/../.." && pwd)/lib/toggle-external.sh"
|
||||
pass=0; fail=0
|
||||
check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1));
|
||||
printf 'FAIL %s: got[%s] want[%s]\n' "$1" "$2" "$3"; fi; }
|
||||
|
||||
SANDBOX="$(mktemp -d)"
|
||||
mkdir -p "$SANDBOX/repo/lib" "$SANDBOX/repo/skills-external/emil-design-eng" \
|
||||
"$SANDBOX/repo/skills-external/observability-and-instrumentation" \
|
||||
"$SANDBOX/repo/skills" "$SANDBOX/home/.claude"
|
||||
cp "$HELPER_SRC" "$SANDBOX/repo/lib/toggle-external.sh"
|
||||
cp "$(dirname "$HELPER_SRC")/gstack-removed.sh" "$SANDBOX/repo/lib/"
|
||||
# mark emil-design-eng ENABLED in the real (physical) repo tree
|
||||
ln -s "$SANDBOX/repo/skills-external/emil-design-eng" "$SANDBOX/repo/skills/emil-design-eng"
|
||||
# replicate the real ~/.claude/lib -> <repo>/lib symlink
|
||||
ln -s "$SANDBOX/repo/lib" "$SANDBOX/home/.claude/lib"
|
||||
|
||||
out="$(bash "$SANDBOX/home/.claude/lib/toggle-external.sh" status emil-design-eng)"
|
||||
check T1-repo-resolves-through-symlink "$out" enabled
|
||||
|
||||
# Same case arm, generalized to $tool for the agent-skills trio (this PR) —
|
||||
# left unlinked, so it must resolve through the symlink as "disabled", not
|
||||
# "missing" (which would mean REPO fell back to the wrong tree again).
|
||||
out="$(bash "$SANDBOX/home/.claude/lib/toggle-external.sh" status observability-and-instrumentation)"
|
||||
check T2-generalized-tool-resolves-through-symlink "$out" disabled
|
||||
|
||||
rm -rf "$SANDBOX"
|
||||
printf 'PASS=%s FAIL=%s\n' "$pass" "$fail"; [ "$fail" -eq 0 ]
|
||||
Reference in new issue
Block a user