fix(agents): close the 10 prose BUGS-FOUND items, root quoting and $HOME refusal

Handover: rooted reads, whole-line PROJECT_ROOT read with a one-line
pre-paste rule, BDR status filter. plugin-gate: single-quoted templates,
unsafe roots printed never run, apply check against the git common dir,
$HOME refused (and in profile.sh). Advisor: minimal only from project
signals, no extras token, ctx7 wording, print-only plugin remedy. Packs
vocabulary in onboard/tour; graphify labels match the trap.
This commit is contained in:
bchanot committed 2026-11-13 20:43:59 +01:00
1 parent a967fd93dc
commit 77041e5360
17 files changed
+192 -98

No files matched your search

+27 -20
View File
@@ -41,24 +41,28 @@ PROBE REPORT (ground truth — do not re-detect):
Show the returned PLUGIN CHECK block. The advisor emits tokens only; the
main loop builds every command from the fixed templates of step 5, never
pastes the advisor's text into a shell. Before running ANY command (the
step-4 diff included) check each token: a profile name is one of the advisor's own set
(web, seo, dev, design, qa, audit, minimal; never `full`, `max` or a
pastes the advisor's text into a shell. A PROJECT_ROOT holding `'`, a
newline or a control character is never substituted into a template: print
the commands with the root shown as `'<root>'` and a warning that the
user must quote it by hand, and run nothing. Before running ANY command (the step-4 diff
included) check each token: a profile name is one of the advisor's own
set (web, seo, dev, design, qa, audit, minimal; never `full`, `max` or a
user-added profile) and matches `^[a-z0-9][a-z0-9-]*$` with an existing
`$HOME/.claude/lib/profiles/<name>.json`;
a pack is one of design, scroll3d, seo, web-validate, gstack-dev,
gstack-browser, gstack-design, extras (`higgsfield` is never accepted from an
advisor token: paid service, explicit user ask only); a plugin is one of the
two managed full ids `ui-ux-pro-max@ui-ux-pro-max-skill`,
`pr-review-toolkit@claude-code-plugins`. A token matching none is printed as
rejected and skipped, never run.
`$HOME/.claude/lib/profiles/<name>.json`; a pack is one of design, scroll3d,
seo, web-validate, gstack-dev, gstack-browser, gstack-design (`higgsfield`
and `extras` are never accepted from an advisor token: paid or
credit-metered services, explicit user ask only, `profile.sh enable extras`
by hand); a plugin is one of the two managed full ids
`ui-ux-pro-max@ui-ux-pro-max-skill`, `pr-review-toolkit@claude-code-plugins`.
A token matching none is printed as rejected and skipped, never run.
For a `↻ SET <profile>` line run
`bash "$HOME/.claude/lib/profile.sh" -C "<PROJECT_ROOT>" diff "<profile>"` and
`bash "$HOME/.claude/lib/profile.sh" -C '<PROJECT_ROOT>' diff '<profile>'` and
print its `→ off` lines under it as "turns off" (none → "turns off: nothing")
and its `→ on` lines as "turns on" (none → "turns on: nothing").
The diff exits non-zero on a bad name, an unknown profile or a missing
profiles dir: on any non-zero exit print "turns off: unknown" and continue.
- `ACTION REQUIRED? YES` → offer: A) fix plugins B) type "force". STOP until
- `ACTION REQUIRED? YES` → offer: A) fix plugins (print "run `make plugin`
in your claude-config checkout", run nothing) B) type "force". STOP until
answered.
- OK → print `✅ Plugin check passed — [active plugins] — complexity: <score>%`.
@@ -66,10 +70,13 @@ profiles dir: on any non-zero exit print "turns off: unknown" and continue.
Trigger: a `↻ SET`, `⚡ ENABLE` or `⚠️ DISABLE` line. Under `source=flag`
(`PROFILE :` block) the advisor emits only `relaunch: cc <name> <profile>`:
nothing is applied. Apply only when
`git -C "<PROJECT_ROOT>" rev-parse --show-toplevel` equals PROJECT_ROOT;
otherwise print the commands and apply nothing ("no git root yet: run them
after git init").
nothing is applied. Apply only when the parent of
`git -C '<PROJECT_ROOT>' rev-parse --path-format=absolute --git-common-dir`
(the root profile.sh writes at, same in a linked worktree) equals
PROJECT_ROOT and PROJECT_ROOT is not `$HOME`;
otherwise print the commands and apply nothing, naming the cause: no git
root yet (run them after git init), a linked worktree or submodule, or
PROJECT_ROOT is `$HOME`.
1. List the changes, saying they are project-wide and persist in
`<PROJECT_ROOT>/.claude/settings.local.json`:
```
@@ -82,9 +89,9 @@ after git init").
```
2. "yes" → run the changes in order, the SET first, then the deltas (after
"customize" too). Each one is
`bash "$HOME/.claude/lib/profile.sh" -C "<PROJECT_ROOT>" set "<name>"`,
`... enable "<pack | full plugin id>"` or
`... disable "<pack | full plugin id>"` (same prefix). Each call
`bash "$HOME/.claude/lib/profile.sh" -C '<PROJECT_ROOT>' set '<name>'`,
`... enable '<pack | full plugin id>'` or
`... disable '<pack | full plugin id>'` (same prefix). Each call
writes `.claude/settings.local.json` atomically or refuses (rc 2, nothing
written): stop at the first non-zero rc, print its stderr, and continue
with the current config. "customize" → user picks. "no" → proceed with
@@ -93,7 +100,7 @@ after git init").
/reload-plugins to load the packs in this session (connectors and model:
next session).` Say the change is project-wide and persists in
`<PROJECT_ROOT>/.claude/settings.local.json`. Print the undo: after a SET:
`bash "$HOME/.claude/lib/profile.sh" -C "<PROJECT_ROOT>" unset`, after
`bash "$HOME/.claude/lib/profile.sh" -C '<PROJECT_ROOT>' unset`, after
deltas the inverse enable / disable.
**Never auto-activate without showing the list and getting confirmation.
+10 -3
View File
@@ -37,8 +37,8 @@
# and the statusline (supersedes `show --plain`, BDR-024).
#
# Exit: 0 ok · 2 usage, unknown profile or pack, not a project root (no
# CLAUDE.md and no .git), unreadable or invalid local JSON; nothing
# is written on any refusal.
# CLAUDE.md and no .git), refusing $HOME as the project root,
# unreadable or invalid local JSON; nothing is written on any refusal.
# ============================================================
set -euo pipefail
@@ -70,6 +70,12 @@ home_or_above() { # $1 dir
case "$HOME/" in "$1"/*) return 0 ;; esac
return 1
}
is_home() { # $1 dir: same physical dir as $HOME (symlinks resolved)
local d h
d="$(cd -P "$1" 2>/dev/null && pwd -P)" || return 1
h="$(cd -P "$HOME" 2>/dev/null && pwd -P)" || return 1
[ "$d" = "$h" ]
}
git_root() { # $1 dir → parent of the git common dir, unless $HOME or above
local common root
common="$(git -C "$1" rev-parse --path-format=absolute --git-common-dir \
@@ -82,7 +88,7 @@ git_root() { # $1 dir → parent of the git common dir, unless $HOME or above
find_root() { # $1 dir → the project root (see header)
local d="$1"
git_root "$d" && return 0
while [ "$d" != / ] && [ "$d" != "$HOME" ]; do
while [ "$d" != / ] && ! is_home "$d"; do
if [ -d "$d/.claude" ] || [ -f "$d/CLAUDE.md" ] || [ -e "$d/.git" ]; then
echo "$d"; return 0
fi
@@ -91,6 +97,7 @@ find_root() { # $1 dir → the project root (see header)
echo "$1"
}
require_project_root() {
is_home "$PROJECT" && die "refusing \$HOME as the project root: $PROJECT"
[ -f "$PROJECT/CLAUDE.md" ] || [ -e "$PROJECT/.git" ] \
|| die "not a project root (no CLAUDE.md and no .git): $PROJECT"
}
+7
View File
@@ -178,6 +178,13 @@ check T26-home-rc "$rc" 0
check T26-home-local "$([ -f "$H2/work/.claude/settings.local.json" ] && echo yes)" yes
check T26-home-not-root "$([ -e "$H2/.claude" ] && echo leaked)" ""
# a root that is $HOME (even through a symlink) is refused, rc 2, nothing written
H3="$FX/home3"; mkdir -p "$H3"; printf '# h\n' > "$H3/CLAUDE.md"; ln -s "$H3" "$FX/home3-link"
out="$(HOME="$FX/home3-link" PX "$H3" set devx 2>&1)"; rc=$?
check T27-home-root-rc "$rc" 2
check_has T27-home-root-msg "$out" "refusing \$HOME as the project root"
check T27-home-root-nothing "$([ -e "$H3/.claude" ] && echo leaked)" ""
# 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"
+2 -2
View File
@@ -163,8 +163,8 @@ check SB10-gate-vocab "$(gone lib/plugin-gate.md \
'Pre-fetch ctx7|Enable ui-ux-pro-max \(')" 1
gate="$(cat "$ROOT/lib/plugin-gate.md")"
check SB10-gate-diff "$(has "$gate" 'profile.sh" -C')" 1
check SB10-gate-diff2 "$(has "$gate" 'diff "<profile>"')" 1
check SB10-gate-root "$(has "$gate" 'rev-parse --show-toplevel')" 1
check SB10-gate-diff2 "$(has "$gate" "diff '<profile>'")" 1
check SB10-gate-root "$(has "$gate" '--git-common-dir')" 1
check SB10-gate-rejected "$(has "$gate" 'rejected')" 1
check SB10-gate-quoted "$(gone lib/plugin-gate.md '-C <PROJECT_ROOT>')" 1
check SB10-advisor-fullid "$(has "$(cat "$ROOT/agents/plugin-advisor.md")" \