From 04b9b865f851c323cc13c593beb1cabc16f76007 Mon Sep 17 00:00:00 2001 From: bchanot Date: Mon, 2 Nov 2026 09:47:13 +0100 Subject: [PATCH] fix(phase5): final review wave: cc.sh width, design-gate remedy + resolve check, routing test on a fresh clone, doctor fail-closed, dead column --- doctor.sh | 12 ++++++-- install-plugins.sh | 4 +-- lib/cc.sh | 3 +- lib/design-tool-gate.sh | 48 +++++++++++++++++++++++------- lib/doctor-vendored.sh | 14 ++++----- lib/tests/design-tool-gate.test.sh | 14 ++++++++- lib/tests/doctor-vendored.test.sh | 5 ++-- lib/tests/effort-routing.test.sh | 14 ++++++--- plugins.lock.json | 2 +- skills/profile/SKILL.md | 4 +-- 10 files changed, 84 insertions(+), 36 deletions(-) diff --git a/doctor.sh b/doctor.sh index 519ac8f..b95732a 100644 --- a/doctor.sh +++ b/doctor.sh @@ -115,7 +115,11 @@ echo "── Packs ──" _pc="$(bash "$REPO/lib/pack-census.sh" --installed 2>&1)" && _pc_rc=0 || _pc_rc=$? while read -r _w; do [ -n "$_w" ] && warn "${_w#WARN }"; done < <(grep '^WARN' <<<"$_pc" || true) while read -r _r; do [ -n "$_r" ] && fail "${_r#RED }"; done < <(grep '^RED' <<<"$_pc" || true) -[ "$_pc_rc" -eq 0 ] && pass "$(tail -1 <<<"$_pc")" +if [ "$_pc_rc" -eq 0 ]; then + pass "$(tail -1 <<<"$_pc")" +elif ! grep -q '^RED' <<<"$_pc"; then + fail "pack census failed (rc=$_pc_rc)" +fi unset _pc _pc_rc _w _r echo "" @@ -140,10 +144,12 @@ if grep -Eq 'alias cc=|dtach_claude' "$HOME/.bashrc" 2>/dev/null; then fi _ep_head="$(git -C "$REPO" show HEAD:settings.json 2>/dev/null | jq -S .enabledPlugins 2>/dev/null || true)" _ep_work="$(jq -S .enabledPlugins "$REPO/settings.json" 2>/dev/null || true)" -if [ "$_ep_head" = "$_ep_work" ]; then +if [ -z "$_ep_head" ] || [ -z "$_ep_work" ]; then + warn "enabledPlugins check skipped (jq or git show failed)" +elif [ "$_ep_head" = "$_ep_work" ]; then pass "settings.json enabledPlugins matches HEAD (no user-scope residue)" else - warn "user-scope residue: $(diff <(echo "$_ep_head") <(echo "$_ep_work") | grep '^[<>]' | tr -s ' ' | tr '\n' ';'); restore per MIGRATION 2.1.0 step 1" + warn "user-scope residue: $(diff <(echo "$_ep_head") <(echo "$_ep_work") | grep '^[<>]' | tr -s ' ' | tr '\n' ';'); restore per MIGRATION "Profiles and packs" step 1" fi _m="$(jq -r '.model // "-"' "$REPO/settings.json" 2>/dev/null || echo "-")" if [ "$_m" = opus ]; then pass "settings.json model is opus" diff --git a/install-plugins.sh b/install-plugins.sh index 5471e4b..23d2eee 100644 --- a/install-plugins.sh +++ b/install-plugins.sh @@ -341,7 +341,7 @@ if [ -d "$GSTACK_DIR" ]; then # On a distro newer than gstack's pinned Playwright supports, bump Playwright # BEFORE ./setup so its frozen-lockfile install picks up the new version and # the browse binary is rebuilt against it (avoids the "does not support - # chromium" fail). Non-fatal if it can't — gstack is OFF by default. + # chromium" fail). Non-fatal if it can't — gstack packs follow the profile (full = on). # See BLK-008 / LRN-040 / BDR-029; logic lives in lib/gstack-playwright.sh. gstack_bump_playwright_if_unsupported "$GSTACK_DIR" @@ -1269,7 +1269,7 @@ echo " 🔄 21st skill pack — 21st.dev CLI skills; linked by skills/pac echo " 🔄 higgsfield pack — Higgsfield CLI media skills (image, video, audio, brand), OFF by default (bash lib/profile.sh enable higgsfield, then /reload-plugins; landing-page aid: enable higgsfield-websites)" echo "" echo " All plugins installed at: user scope (~/.claude/plugins/)" -echo " GStack skills symlinked individually into ~/.claude/skills/ (→ submodule)" +echo " GStack skills live in packs skills/pack-gstack-*/ (symlinks into the submodule)" echo " Emil Design Eng at: ~/.claude/skills/pack-design/skills/emil-design-eng/ (symlink → skills-external)" echo " Frontend Design at: ~/.claude/skills/pack-design/skills/frontend-design/ (symlink → skills-external)" echo " Design Motion Principles at: skills/pack-design/skills/design-motion-principles/ (symlink → skills-external)" diff --git a/lib/cc.sh b/lib/cc.sh index d3ba15d..f78686b 100644 --- a/lib/cc.sh +++ b/lib/cc.sh @@ -30,7 +30,8 @@ cc() { fi fi mkdir -p "$HOME/.cache/claude-tmp" "$HOME/.dtach" - # shellcheck disable=SC2016,SC1003 # the inner shell expands $HOME; '^\' is dtach's detach key + # The inner shell expands $HOME; '^\' is dtach's detach key. + # shellcheck disable=SC2016,SC1003 CLAUDE_PROFILE="$profile" CLAUDE_PROFILE_SETTINGS="$settings" \ TMPDIR="$HOME/.cache/claude-tmp" \ systemd-run --user --quiet --collect --scope --slice=dev.slice \ diff --git a/lib/design-tool-gate.sh b/lib/design-tool-gate.sh index a22de7d..0186d0a 100755 --- a/lib/design-tool-gate.sh +++ b/lib/design-tool-gate.sh @@ -15,16 +15,20 @@ # Remedy on 10: source=flag → relaunch `cc web` (a --settings # conversation is frozen); else `profile.sh set web` (or `enable design`) # then /reload-plugins. The CLI is a global npm install either way. -# Usage: design-tool-gate.sh (no argument; env DESIGN_GATE_PROFILE_SH) +# READY also needs the packs to resolve: every skills/pack-/skills/* +# entry of pack-design and pack-gstack-design must have a SKILL.md. +# Usage: design-tool-gate.sh (no argument; env DESIGN_GATE_PROFILE_SH, +# DESIGN_GATE_SKILLS_DIR) # ============================================================ set -euo pipefail REPO="$(cd -P "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" PROFILE_SH="${DESIGN_GATE_PROFILE_SH:-$REPO/lib/profile.sh}" +SKILLS_DIR="${DESIGN_GATE_SKILLS_DIR:-$REPO/skills}" NEEDED=(pack-design pack-gstack-design "plugin:ui-ux-pro-max@ui-ux-pro-max-skill") -# ---- 21st CLI on PATH + sign-in state (kept from the previous version) ---- +# ---- 21st CLI on PATH + sign-in state --------------------------------------- # Same sanitized-PATH problem for `21st` (an npm global bin): a PATH repair # for the 21st CLI only (claude is no longer called here). The npm global # bin dir is often missing from a hook's PATH. Probe for the binary directly @@ -94,6 +98,13 @@ for k in "${NEEDED[@]}"; do [ "$(plain_get "$k")" = on ] || missing+=("$k") done source="$(plain_get source)"; profile="$(plain_get profile)" +dangling=() +for n in design gstack-design; do + for e in "$SKILLS_DIR/pack-$n/skills/"*; do + [ -e "$e" ] || [ -L "$e" ] || continue + [ -e "$e/SKILL.md" ] || dangling+=("pack-$n:${e##*/}") + done +done # ---- 21st: CLI present, then signed in --------------------------------------- cli_hint=""; auth=in @@ -103,19 +114,34 @@ else auth="$(twentyfirst_auth_state)" fi -# ---- verdict ----------------------------------------------------------------- -if [ "${#missing[@]}" -gt 0 ] || [ -n "$cli_hint" ]; then - echo "design toolchain: INCOMPLETE" - [ "${#missing[@]}" -gt 0 ] && echo " off: ${missing[*]}" - [ -n "$cli_hint" ] && echo "$cli_hint" +# ---- remedy lines: set web, one enable per missing pack --------------------- +print_remedy() { + local k if [ "$source" = flag ]; then echo " → relaunch this conversation with a design profile:" \ " cc web" - else - echo " → run: bash ~/.claude/lib/profile.sh set web" \ - " (or: enable design)" - echo " then /reload-plugins" + return fi + echo " → run: bash ~/.claude/lib/profile.sh set web" + for k in "${missing[@]}"; do + case "$k" in + pack-*) echo " or: profile.sh enable ${k#pack-}" ;; + *) echo " (enable the plugin in a profile: set web)" ;; + esac + done + echo " then /reload-plugins" +} + +# ---- verdict ----------------------------------------------------------------- +if [ "${#missing[@]}" -gt 0 ] || [ "${#dangling[@]}" -gt 0 ] \ + || [ -n "$cli_hint" ]; then + echo "design toolchain: INCOMPLETE" + [ "${#missing[@]}" -gt 0 ] && echo " off: ${missing[*]}" + for e in ${dangling[@]+"${dangling[@]}"}; do + echo " not installed: $e (run make plugin)" + done + [ -n "$cli_hint" ] && echo "$cli_hint" + [ "${#missing[@]}" -gt 0 ] && print_remedy exit 10 fi case "$auth" in diff --git a/lib/doctor-vendored.sh b/lib/doctor-vendored.sh index 661bf9d..390fab6 100644 --- a/lib/doctor-vendored.sh +++ b/lib/doctor-vendored.sh @@ -4,9 +4,8 @@ # skills (curl-pinned externals in plugins.lock.json + link.sh's # EXTERNAL_SKILLS array). doctor.sh's "GStack submodule" section only # covers the gstack submodule — this covers the OTHER external skill -# packs (emil-design-eng, the agent-skills trio, the five Mengto scroll -# skills, the seven superpowers skills, and any name link.sh links with -# no lock entry at all, e.g. frontend-design, design-motion-principles). +# packs (the agent-skills trio, the seven superpowers skills, and any +# name link.sh links with no lock entry at all). # # One entry point, `check_vendored_skills `, sourced # and called by doctor.sh. Two things checked @@ -56,9 +55,7 @@ fi # _dv_lock_expectations — prints "\t" for every # skill named under a plugins.lock.json entry whose "managed_by" is -# "curl", plus a THIRD column "\t1" when that entry is "always_on": true -# (the superpowers entry is), ignored by the -# $1==n {print $2} awk in _dv_check_files: a bare list defaults each name +# "curl". A bare list defaults each name # to ["SKILL.md"]; a dict names its own per-skill file list; an entry # with neither (the emil-design-eng single-file "path" shape) is itself # the skill name, file "SKILL.md" (the literal "path" value is upstream @@ -116,13 +113,12 @@ for key, entry in data.items(): sys.exit(1) if not valid_skills(skills): sys.exit(1) - suffix = "\t1" if entry.get("always_on") is True else "" if skills is None: - print(f"{key}\tSKILL.md{suffix}") + print(f"{key}\tSKILL.md") continue for name, files in skill_files(skills).items(): for file in files: - print(f"{name}\t{file}{suffix}") + print(f"{name}\t{file}") PY } diff --git a/lib/tests/design-tool-gate.test.sh b/lib/tests/design-tool-gate.test.sh index e368cab..c388c74 100755 --- a/lib/tests/design-tool-gate.test.sh +++ b/lib/tests/design-tool-gate.test.sh @@ -21,6 +21,7 @@ if PATH=/usr/bin:/bin command -v 21st >/dev/null 2>&1 \ fi WORK="$(mktemp -d)"; trap 'rm -rf "$WORK"' EXIT mkdir -p "$WORK/bin" "$WORK/home"; export WORK +export DESIGN_GATE_SKILLS_DIR="$WORK/none" printf '#!/usr/bin/env bash\ncat "$WORK/plain.txt"\n' > "$WORK/bin/profile.sh" cat > "$WORK/bin/21st" <<'EOF' #!/usr/bin/env bash @@ -49,11 +50,22 @@ expect T1-ready 0 "READY — packs design + gstack-design + ui-ux-pro-max on (we plain off on on local dev; out="$(gate_run in "$WORK/bin")"; rc=$? expect T2-incomplete 10 "INCOMPLETE"; expect T2-remedy-local 10 "bash ~/.claude/lib/profile.sh set web" expect T2-names 10 "off: pack-design" +expect T2-enable 10 "profile.sh enable design" plain on off off flag dev; out="$(gate_run in "$WORK/bin")"; rc=$? expect T3-remedy-flag 10 "relaunch this conversation with a design profile: cc web" expect T3-names 10 "off: pack-gstack-design plugin:ui-ux-pro-max@ui-ux-pro-max-skill" -plain on on on local web; out="$(gate_run in "")"; rc=$? +plain on on off local web; out="$(gate_run in "$WORK/bin")"; rc=$? +expect T3a-plugin 10 "enable the plugin in a profile: set web" +plain on on on local web +mkdir -p "$WORK/repo/skills/pack-design/skills" +ln -s /nonexistent "$WORK/repo/skills/pack-design/skills/x" +out="$(DESIGN_GATE_SKILLS_DIR="$WORK/repo/skills" gate_run in "$WORK/bin")" +rc=$? +expect T3b-dangling 10 "not installed: pack-design:x (run make plugin)" +rm -r "$WORK/repo" +out="$(gate_run in "")"; rc=$? expect T4-no-cli 10 "21st needs the CLI: npm i -g @21st-dev/cli then 21st login" +case "$out" in *"profile.sh set web"*) bad T4-no-remedy "pack remedy shown";; *) ok T4-no-remedy;; esac out="$(gate_run out "$WORK/bin")"; rc=$? expect T5-signed-out 12 "SIGN-IN REQUIRED"; expect T5-ask 12 "! 21st login" out="$(gate_run garbage "$WORK/bin")"; rc=$? diff --git a/lib/tests/doctor-vendored.test.sh b/lib/tests/doctor-vendored.test.sh index 87a4d03..7a9e557 100644 --- a/lib/tests/doctor-vendored.test.sh +++ b/lib/tests/doctor-vendored.test.sh @@ -3,10 +3,11 @@ # check_vendored_skills(): a fixture repo under mktemp with a fake # plugins.lock.json (single-path shape, list shape, dict shape with a # references/ file), a fake link.sh holding a multi-line -# EXTERNAL_SKILLS=(...) array and a fake /skills dir. Cases: every file present + linked (ALL_PRESENT), a +# EXTERNAL_SKILLS=(...) array and a fake /skills dir. +# Cases: every file present + linked (ALL_PRESENT), a # list-shape skill missing its SKILL.md (FILE_MISSING), a dict-shape # skill missing one of two files — only that file is named -# (DICT_FILES_COMPLETE), a profile-listed name with no symlink +# (DICT_FILES_COMPLETE), a linked name with no symlink # (SYMLINK_MISSING_ACTIVE) or a symlink to the wrong target # (SYMLINK_WRONG_TARGET), an unreadable lock file degrading to a # warn instead of a fail (LOCK_UNREADABLE, rc 0), a lock entry whose diff --git a/lib/tests/effort-routing.test.sh b/lib/tests/effort-routing.test.sh index b56d428..0e4cafb 100755 --- a/lib/tests/effort-routing.test.sh +++ b/lib/tests/effort-routing.test.sh @@ -159,15 +159,21 @@ while IFS= read -r f; do check_skill "$f"; done < <( cd "$R" && git ls-files 'skills/*/SKILL.md' 'skills-external/*/SKILL.md') # ── (b2) every skills row resolves to a skill (short, pack entry, parked) ─ +ext_named() { # ext_named : is in link.sh EXTERNAL_SKILLS + sed -n '/^EXTERNAL_SKILLS=(/,/)/p' "$R/link.sh" | grep -qw -- "$1" +} row_resolves() { # row_resolves - local k="$1" n + local k="$1" n p case "$k" in - pack-*:*) n="${k%%:*}"; [ -e "$R/skills/$n/skills/${k#*:}/SKILL.md" ];; - *) [ -e "$R/skills/$k/SKILL.md" ] || [ -n "$(skdir "$k")" ] \ + pack-*:*) n="${k%%:*}"; p="$R/skills/$n/skills/${k#*:}" + [ -L "$p" ] || [ -e "$p/SKILL.md" ];; + *) [ -e "$R/skills/$k/SKILL.md" ] || ext_named "$k" \ + || [ -L "$R/skills/$k" ] || [ -n "$(skdir "$k")" ] \ || [ -e "$R/skills-external/$k/SKILL.md" ];; esac } -[ -n "$(skdir seo)" ] && ! row_resolves ghost-skill \ +[ -L "$R/skills/pack-seo/skills/seo" ] || [ -d "$R/skills/pack-seo/skills/seo" ] \ + && ! row_resolves ghost-skill \ && ! row_resolves pack-seo:ghost && ! row_resolves pack-ghost:seo \ && ok || ko "row_resolves: flip-test (ghost rows must fail)" while read -r kind key _; do diff --git a/plugins.lock.json b/plugins.lock.json index 330b4d2..67c69df 100644 --- a/plugins.lock.json +++ b/plugins.lock.json @@ -46,7 +46,7 @@ "source": "https://github.com/emilkowalski/skill", "path": "skills/emil-design-eng/SKILL.md", "managed_by": "curl", - "note": "Emil Kowalski's design engineering skill — UI polish, animations, component craft. Machine-owned: curl'd to skills-external/emil-design-eng/ (gitignored, re-fetched by update-all.sh), symlinked by link.sh." + "note": "Emil Kowalski's design engineering skill — UI polish, animations, component craft. Machine-owned: curl'd to skills-external/emil-design-eng/ (gitignored, re-fetched by update-all.sh), linked by skills/pack-design." }, "agent-skills": { "source": "https://github.com/addyosmani/agent-skills", diff --git a/skills/profile/SKILL.md b/skills/profile/SKILL.md index d194bdd..107e9a6 100644 --- a/skills/profile/SKILL.md +++ b/skills/profile/SKILL.md @@ -51,8 +51,8 @@ root (no `CLAUDE.md`, no `.git`), unreadable or invalid local JSON. ## Rules -- Never write the user scope (`~/.claude/settings.json`); never run - `claude plugin enable|disable`. A pack need found mid-skill is proposed to +- Never write the user scope (`~/.claude/settings.json`); never toggle + plugins through the `claude plugin` CLI. A pack need found mid-skill is proposed to the user (`set ` or `enable ` + `/reload-plugins`, or a relaunch under `--settings`), written only on consent (lib/plugin-gate.md). - `deniedMcpServers` is a union across settings files: a `cc x web` over a