fix(banner): plugin rows follow the effective profile, not user scope

The ✅ row and detect_uiux_pro_max read user-scope settings.json and the
plugin cache, so a dev project showed ui-ux-pro-max on and an audit
project hid pr-review-toolkit. list_on_plugins now resolves the effective
profile (user scope for unmanaged ids); status-reporter and the plugin
advisor read per-project state from it.
This commit is contained in:
bchanot committed 2026-11-10 12:39:50 +01:00
1 parent 9f9821eab7
commit 556d0e6ddf
6 files changed
+179 -17

No files matched your search

+4
View File
@@ -26,6 +26,10 @@ field. PROBE REPORT missing or a field absent → emit
`PLUGIN CHECK — VERDICT: ERROR(probe report missing/invalid: <what>)` and
STOP. Fail closed: no recommendations over invented detection.
`ACTIVE:` = the managed ids from `PROFILE` (`pack-*=on`, `plugin:<id>=on`);
an id absent from PROFILE keeps its `PLUGINS` enabled state (user scope);
CLIs from `CLIS`. `PLUGINS` alone is installed state, never per-project.
`FRAMEWORK-DEPS` carries exact `"dep": "version"` pairs (or
`framework-deps-none`). Derive signal classes from those names + versions:
`frontend` = react/react-dom/vue/nuxt/svelte/astro/next present;
+2 -1
View File
@@ -19,7 +19,8 @@ Facts only — no signals, no recommendations, no complexity scoring.
# project and conversation (lib/profile.sh, no claude call)
bash "$HOME/.claude/lib/profile.sh" -C "$PWD" current --plain 2>/dev/null || echo "profile-unavailable"
# Marketplace plugins actually installed (ids, enabled state)
# Marketplace plugins installed; the enabled column may not reflect the
# project profile or --settings: per-project state = PROFILE above
claude plugin list 2>/dev/null || echo "plugin-list-unavailable"
# Context7 CLI
+5 -3
View File
@@ -20,7 +20,9 @@ No modifications. No design. No proposals. Facts only.
# Config version
cat ~/.claude/lib/../version.txt 2>/dev/null || echo "unknown" # lib symlink resolves into the repo
# Active plugins (from session-start detection)
# Active plugins: enabled for THIS project (effective profile), not the cache
. "$HOME/.claude/lib/detect-plugins.sh" && list_on_plugins || echo "plugins-unavailable"
bash "$HOME/.claude/lib/profile.sh" -C "$PWD" current --plain 2>/dev/null | grep -E '^(profile|pack-[a-z0-9-]+)=' || echo "profile-unavailable"
command -v rtk &>/dev/null && echo "rtk: installed" || echo "rtk: missing"
command -v gsd &>/dev/null && gsd --version 2>/dev/null | head -1 || echo "gsd: not installed"
@@ -32,7 +34,7 @@ grep -E 'PLUGIN_TOKENS \+ [0-9]+' "$(readlink -f "$HOME/.claude/lib")/../doctor.
# defer cost to /plugin-check.
```
Check `~/.claude/plugins/cache` for active marketplace plugins.
`~/.claude/plugins/cache` = installed, not active. `Plugins ON:` = rtk (if present) + the names printed by `list_on_plugins` (part before `@`) + the `pack-*=on` packs.
Check `~/.claude.json` for active MCP servers.
---
@@ -178,7 +180,7 @@ The report is best-effort: a single failing data source must not abort the whole
| Failure | Behavior |
|---|---|
| Permission denied on `git` (sandbox/CI without `.git` access) | Mark `Branch: N/A (permission denied)`, `Uncommitted: N/A`, `RECENT COMMITS: N/A`. Continue to PROJECT/GSD sections. |
| Permission denied on `~/.claude/plugins/cache` or `~/.claude.json` | Mark `Plugins ON: unknown (cannot read cache)`. Continue. |
| Permission denied on `~/.claude/plugins/cache` or `~/.claude.json` | Cache unreadable: no effect on `Plugins ON:`. `profile-unavailable` → `Plugins ON:` from `list_on_plugins` (user-scope fallback) with suffix `(profile.sh unavailable: user scope)`. `plugins-unavailable` → `Plugins ON: unknown (detect-plugins.sh unavailable)`. Continue. |
| gsd CLI snapshot fails or `.gsd/` state unreadable (`gsd.db`, `STATE.md`, per-milestone `<ID>-ROADMAP.md` — post-ADR-013 layout) | Mark `Progress: N/A (gsd state unreadable)`, do NOT abort the section — still print `Status: initialized` and `Milestone: N/A`. |
| `package.json` / `pyproject.toml` parse error | Mark `Tests: N/A (manifest parse error)`. Continue. |
| `python3` not available in PATH | Skip the python parsing fallbacks; rely on log files + bash-only checks. Mark Tests as `unknown` if no log found. |
+8 -9
View File
@@ -198,23 +198,22 @@ unset _passive_t _budget_pct _budget
echo ""
echo "┌─ Claude Code config ──────────────────────────────────┐"
# "ALWAYS ON" row — actual state, not hardcoded. RTK is a binary on PATH;
# the others are marketplace plugins whose state lives in
# settings.json:enabledPlugins. Anything missing/disabled is omitted so
# the user sees the real picture instead of a misleading literal.
# the others come from list_on_plugins (lib/detect-plugins.sh, same source
# as detect_uiux_pro_max and /status): the effective profile for the ids
# lib/profiles manages, user-scope settings.json for the rest. A hardcoded
# SET under-reports newly enabled plugins (pr-review-toolkit was enabled
# yet invisible). LRN-005 class. Missing/disabled is omitted. Plugins owned
# by the toggle row below are excluded (dual display).
ALWAYS_ON=()
detect_rtk &>/dev/null && ALWAYS_ON+=("rtk")
# Derive the plugin list from settings.json:enabledPlugins (true entries)
# instead of a hardcoded name pair — a hardcoded SET under-reports newly
# enabled plugins (pr-review-toolkit was enabled yet invisible). LRN-005
# class. Plugins owned by the toggle row below are excluded (dual display).
_toggle_owned=" gstack ui-ux-pro-max plugin-dev context7 graphify "
while IFS= read -r _pl; do
[ -n "$_pl" ] || continue
case "$_toggle_owned" in
*" $_pl "*) : ;;
*) ALWAYS_ON+=("$_pl") ;;
esac
done < <(grep -oE '"[A-Za-z0-9_-]+@[A-Za-z0-9_-]+"[[:space:]]*:[[:space:]]*true' "$HOME/.claude/settings.json" 2>/dev/null \
| sed -E 's/^"([^@]+)@.*$/\1/')
done < <(sed 's/@.*//' <<<"$(list_on_plugins)")
unset _toggle_owned _pl
ALWAYS_ON_STR="${ALWAYS_ON[*]:-none}"
# Same 40-char-width split policy as the toggle row below — keeps the
+30 -4
View File
@@ -1,10 +1,10 @@
#!/usr/bin/env bash
# ============================================================
# lib/detect-plugins.sh — Single source of truth for plugin detection
# Sourced by: session-start.sh, doctor.sh
# Sourced by: session-start.sh, doctor.sh, agents/status-reporter.md
#
# Each function returns 0 (detected) or 1 (not detected).
# No output — callers handle messaging.
# detect_* return 0 (detected) or 1 (not detected), silently — callers
# handle messaging. detect_plan and list_on_plugins print to stdout.
# ============================================================
# --- Always-on plugins ---
@@ -23,6 +23,30 @@ detect_superpowers() {
}
# --- Effective plugin state ---
list_on_plugins() {
# Enabled plugin ids for this project and conversation, one per line:
# the effective profile for the ids lib/profiles manages (BDR-134),
# user-scope true for the others (LRN-005). Always returns 0.
# shortcut: unmanaged ids read user scope only (not project/local) and
# a skills-dir mod set in no scope (memory) is not seen, nor a mod's
# ~/.claude/<name>.json off switch; upgrade = jq merge of the scopes +
# plugin manifests.
local plain="${PROFILE_PLAIN:-}" user
[ -n "$plain" ] || plain="$(bash "$HOME/.claude/lib/profile.sh" -C "$PWD" \
current --plain 2>/dev/null)" || plain=""
user="$(grep -oE '"[A-Za-z0-9_-]+@[A-Za-z0-9_-]+"[[:space:]]*:[[:space:]]*true' \
"$HOME/.claude/settings.json" 2>/dev/null)" || user=""
awk -F= 'FNR == NR { if (sub(/^plugin:/, "", $1)) { m[$1] = 1
if ($2 == "on") print $1 }; next }
{ sub(/^"/, ""); sub(/".*$/, "") }
$0 != "" && !($0 in m) && $0 !~ /^pack-.*@skills-dir$/' \
<(printf '%s\n' "$plain") <(printf '%s\n' "$user")
return 0
}
# --- Toggle plugins ---
detect_gstack() {
@@ -47,8 +71,10 @@ detect_plugin_dev() {
}
detect_uiux_pro_max() {
# installed (cache) AND enabled for this project (here-string: no pipe)
local cache_dir="$HOME/.claude/plugins/cache"
[ -d "$cache_dir" ] && compgen -G "$cache_dir"/*ui-ux-pro-max* &>/dev/null
[ -d "$cache_dir" ] && compgen -G "$cache_dir"/*ui-ux-pro-max* &>/dev/null \
&& grep -q '^ui-ux-pro-max@' <<<"$(list_on_plugins)"
}
detect_context7() {
+130
View File
@@ -0,0 +1,130 @@
#!/usr/bin/env bash
# lib/tests/session-banner.test.sh — the banner and detect_uiux_pro_max
# follow the project's effective profile, not user scope / the plugin cache
# (BDR-134). Fake HOME and projects under mktemp -d; the real ~/.claude is
# never linked or touched (only lib/ and skills/ of the repo are linked).
set -u
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
SS="$ROOT/hooks/session-start.sh"
DP="$ROOT/lib/detect-plugins.sh"
WORK="$(mktemp -d)" || exit 1; trap 'rm -rf "$WORK"' EXIT
export SESSION_START_OFFLINE=1
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; }
# has <text> <word>: 1 when the text contains the word, else 0
has() { case "$1" in *"$2"*) echo 1 ;; *) echo 0 ;; esac; }
# shellcheck source=lib/tests/claude-stub.sh
. "$ROOT/lib/tests/claude-stub.sh" || exit 1
claude_stub_install "$WORK"
# rtk pinned present, whatever the machine has
printf '#!/bin/sh\nexit 0\n' >"$WORK/stub/rtk" || exit 1
chmod +x "$WORK/stub/rtk" || exit 1
UIUX='"ui-ux-pro-max@ui-ux-pro-max-skill":true'
SEC='"security-guidance@claude-code-plugins":true'
USER_ALL='{"enabledPlugins":{'"$UIUX,$SEC"',"foo-extra@somewhere":true,
"pack-seo@skills-dir":true}}'
USER_MANAGED='{"enabledPlugins":{'"$UIUX,$SEC"'}}'
# mkhome <name> <cache:1|0> <lib:1|0> <settings>: fake HOME, two links only
mkhome() {
local h="$WORK/$1"
mkdir -p "$h/.claude" || exit 1
if [ -L "$h/.claude/settings.json" ] || [ -L "$h/.claude/plugins" ]; then
echo "fixture path is a symlink: $h" >&2; exit 1
fi
printf '%s\n' "$4" >"$h/.claude/settings.json" || exit 1
[ "$2" = 1 ] && mkdir -p \
"$h/.claude/plugins/cache/ui-ux-pro-max-skill/ui-ux-pro-max"
if [ "$3" = 1 ]; then
ln -s "$ROOT/lib" "$h/.claude/lib" || exit 1
[ -L "$h/.claude/lib" ] || exit 1
fi
ln -s "$ROOT/skills" "$h/.claude/skills" || exit 1
[ -L "$h/.claude/skills" ] || exit 1
}
mkhome h1 1 1 "$USER_ALL"
mkhome h2 0 1 "$USER_ALL"
mkhome h3 1 0 "$USER_ALL"
mkhome h4 1 1 "$USER_MANAGED"
mkdir -p "$WORK/pdev/.claude" "$WORK/paudit/.claude" "$WORK/pfull/.claude" \
|| exit 1
cp "$ROOT/lib/profiles/dev.json" "$WORK/pdev/.claude/settings.local.json"
cp "$ROOT/lib/profiles/audit.json" "$WORK/paudit/.claude/settings.local.json"
# banner <home> <proj>: the hook output
banner() {
(cd "$WORK/$2" && HOME="$WORK/$1" bash "$SS" </dev/null 2>/dev/null)
}
# row <marker> <text>: the marker line plus its continuation line
row() {
awk -v m="$1" 'f && /^│ {13}/ { print; f = 0; next } { f = 0 }
index($0, m) { print; f = 1 }' <<<"$2"
}
# SB1: dev project, user scope has ui-ux-pro-max on
out="$(banner h1 pdev)"
on="$(row '🟢 ON' "$out")"; off="$(row '⚫ OFF' "$out")"
ok="$(row '✅ ON' "$out")"
check SB1-toggle-on-no-uiux "$(has "$on" ui-ux-pro-max)" 0
check SB1-toggle-off-uiux "$(has "$off" ui-ux-pro-max)" 1
for w in rtk model-router security-guidance foo-extra; do
check "SB1-onrow-$w" "$(has "$ok" "$w")" 1
done
for w in pr-review-toolkit pack-seo; do
check "SB1-onrow-no-$w" "$(has "$ok" "$w")" 0
done
# SB2: audit project shows pr-review-toolkit, hides ui-ux-pro-max
out="$(banner h1 paudit)"
check SB2-onrow-pr-review "$(has "$(row '✅ ON' "$out")" pr-review-toolkit)" 1
check SB2-toggle-on-no-uiux "$(has "$(row '🟢 ON' "$out")" ui-ux-pro-max)" 0
# SB3: no profile (full): ui-ux-pro-max on, pr-review-toolkit absent
out="$(banner h1 pfull)"
check SB3-toggle-on-uiux "$(has "$(row '🟢 ON' "$out")" ui-ux-pro-max)" 1
ok="$(row '✅ ON' "$out")"
check SB3-onrow-no-pr-review "$(has "$ok" pr-review-toolkit)" 0
# uiux <home> <proj>: exit status of detect_uiux_pro_max, PROFILE_PLAIN unset
uiux() {
(cd "$WORK/$2" && unset PROFILE_PLAIN && HOME="$WORK/$1" bash -c \
". '$DP'; detect_uiux_pro_max; echo \$?")
}
# SB4: follows the profile, still needs the cache
check SB4-dev-off "$(uiux h1 pdev)" 1
check SB4-full-on "$(uiux h1 pfull)" 0
check SB4-not-installed "$(uiux h2 pfull)" 1
# SB5: profile.sh unreachable, user-scope fallback
check SB5-uiux-fallback "$(uiux h3 pdev)" 0
lst="$(cd "$WORK/pdev" && unset PROFILE_PLAIN && HOME="$WORK/h3" bash -c \
". '$DP'; list_on_plugins")"
for w in security-guidance@claude-code-plugins \
ui-ux-pro-max@ui-ux-pro-max-skill foo-extra@somewhere; do
check "SB5-list-$w" "$(has "$lst" "$w")" 1
done
check SB5-list-no-pack "$(has "$lst" pack-seo@skills-dir)" 0
# SB6: survives set -euo pipefail (doctor.sh options)
res="$(cd "$WORK/pfull" && unset PROFILE_PLAIN && HOME="$WORK/h4" bash -c \
"set -euo pipefail; . '$DP'; detect_uiux_pro_max; echo u\$?;
list_on_plugins >/dev/null; echo l\$?; echo alive" | tr '\n' ' ')"
check SB6-pipefail "$res" 'u0 l0 alive '
# SB7: empty list_on_plugins (no profile.sh, no user id) leaves no empty
# element in the ✅ row
mkhome h5 0 0 '{"enabledPlugins":{"x@y":false}}'
out="$(banner h5 pfull)"
ao="$(row '✅ ON' "$out")"; ao="${ao#*: }"; ao="${ao%│}"
ao="${ao%"${ao##*[![:space:]]}"}"
check SB7-empty-list-rtk-only "$ao" rtk
# SB8: no hook run of this suite called the claude CLI (BLK-043)
check SB8-no-claude-calls "$(claude_stub_calls)" 0
printf 'session-banner: %d passed, %d failed\n' "$pass" "$fail"
[ "$fail" -eq 0 ]