forked from bchanot/claude
feat(hooks,doctor): statusline and banner read profile.sh current --plain once; doctor runs the pack census and checks cc.sh sourcing, user-scope residue and the opus default
This commit is contained in:
1 parent
58958229d9
commit
6509ab2958
10 files changed
+131
-202
No files matched your search
@@ -1,4 +1,4 @@
|
||||
.PHONY: help install plugin link doctor update new-skill profile profile-list profile-current profile-reset onboard test scan-secrets seo-connect
|
||||
.PHONY: help install plugin link doctor update new-skill profile profile-list profile-current onboard test scan-secrets seo-connect
|
||||
|
||||
help: ## Show available commands
|
||||
@grep -E '^[a-zA-Z_-]+:.*##' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*## "}; {printf " make %-16s %s\n", $$1, $$2}'
|
||||
@@ -33,7 +33,7 @@ test: ## Run deterministic tests hermetically (one: make test suite=lib/tests/x.
|
||||
@# Hermetic git: the machine's global core.hooksPath (BDR-095) must not
|
||||
@# fire inside the throwaway repos the suites build. The export lives
|
||||
@# HERE so nobody has to type the (denied) env-prefix form by hand.
|
||||
@export GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null; \
|
||||
@export GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null; unset CLAUDE_PROFILE CLAUDE_PROFILE_SETTINGS; \
|
||||
fail=0; red=""; for t in $(or $(suite),$(SUITES)); do \
|
||||
echo "== $$t"; \
|
||||
case "$$(basename "$$t")" in \
|
||||
@@ -59,17 +59,14 @@ scan-secrets: ## Gitleaks sweep: this repo's history + ~/.claude. Extra repos: m
|
||||
echo "Reports: .audit/scan-secrets-*.json (redacted; gitignored — keep local, do NOT commit)"; \
|
||||
exit $$fail
|
||||
|
||||
profile: ## Run profile.sh (usage: make profile cmd="set design")
|
||||
@bash lib/profile.sh $(cmd)
|
||||
profile: ## profile.sh on a project (usage: make profile cmd="set design" dir=/path/to/project; default: this repo)
|
||||
@bash lib/profile.sh -C "$(or $(dir),$(CURDIR))" $(cmd)
|
||||
|
||||
profile-list: ## List skill profiles (audit, backend, design, dev, full, max, minimal, qa, seo, web, web-full)
|
||||
profile-list: ## List pack profiles (lib/profiles/*.json)
|
||||
@bash lib/profile.sh list
|
||||
|
||||
profile-current: ## Show the active profile (label + match)
|
||||
@bash lib/profile.sh current
|
||||
|
||||
profile-reset: ## Go to the default profile (full)
|
||||
@bash lib/profile.sh reset
|
||||
profile-current: ## Effective profile of a project (dir=…; default: this repo)
|
||||
@bash lib/profile.sh -C "$(or $(dir),$(CURDIR))" current
|
||||
|
||||
new-skill: ## Create a new skill scaffold (usage: make new-skill name=myskill)
|
||||
@test -n "$(name)" || (echo "Usage: make new-skill name=myskill" && exit 1)
|
||||
|
||||
@@ -111,18 +111,12 @@ else
|
||||
warn "GStack submodule missing — run: git submodule update --init"
|
||||
fi
|
||||
|
||||
# GStack skills are exposed as PER-SKILL symlinks directly under skills/ (browse,
|
||||
# cso, review, …) pointing into skills-external/gstack/ — there is NO single
|
||||
# skills/gstack symlink (link.sh deliberately removes it: it duplicated the
|
||||
# top-level gstack SKILL.md alongside the per-skill entries). The bin/ +
|
||||
# browse/dist/ helper links under skills/gstack/ are checked in §7 Consistency.
|
||||
# `|| true` guards pipefail if skills/ is unexpectedly absent (checked above).
|
||||
gstack_skill_links=$( { find "$HOME/.claude/skills/" -maxdepth 1 -type l -lname '*skills-external/gstack/*' 2>/dev/null || true; } | wc -l | tr -d ' ')
|
||||
if [ "${gstack_skill_links:-0}" -gt 0 ]; then
|
||||
pass "GStack: ${gstack_skill_links} skills linked (per-skill symlinks)"
|
||||
else
|
||||
warn "GStack skills not linked — run: cd skills-external/gstack && ./setup"
|
||||
fi
|
||||
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")"
|
||||
unset _pc _pc_rc _w _r
|
||||
|
||||
echo ""
|
||||
|
||||
@@ -132,29 +126,29 @@ echo ""
|
||||
# externals the GStack section above does not cover)
|
||||
# ────────────────────────────────────────────────────────────
|
||||
echo "── Vendored skills ──"
|
||||
# Mirrors lib/profile.sh's active_profile() (read_cache + the
|
||||
# blank/"none" -> DEFAULT_PROFILE fallback) without sourcing profile.sh
|
||||
# itself (its main() would run unconditionally) and without ever
|
||||
# invoking `claude`.
|
||||
_dv_active_profile=$(head -n1 "$REPO/.active-profile" 2>/dev/null \
|
||||
| tr -d '[:space:]')
|
||||
[ -z "$_dv_active_profile" ] && _dv_active_profile="none"
|
||||
[ "$_dv_active_profile" = "none" ] && _dv_active_profile="full"
|
||||
# .active-profile's value is spliced into a lib/profiles/ path below —
|
||||
# reject anything outside the profile-name allowlist before that splice.
|
||||
if ! _dv_valid_profile_name "$_dv_active_profile"; then
|
||||
warn ".active-profile has invalid value \"$_dv_active_profile\" — \
|
||||
falling back to profile full"
|
||||
_dv_active_profile="full"
|
||||
fi
|
||||
_dv_profile_file="$REPO/lib/profiles/$_dv_active_profile.profile"
|
||||
if [ -f "$_dv_profile_file" ]; then
|
||||
check_vendored_skills "$REPO" "$HOME/.claude" "$_dv_profile_file"
|
||||
check_vendored_skills "$REPO" "$HOME/.claude"
|
||||
|
||||
echo ""
|
||||
echo "── Profiles ──"
|
||||
if grep -q 'lib/cc\.sh' "$HOME/.bashrc" 2>/dev/null; then
|
||||
pass "\$HOME/.bashrc sources lib/cc.sh (cc <name> [profile])"
|
||||
else
|
||||
# Active profile unresolved — every external is expected linked.
|
||||
check_vendored_skills "$REPO" "$HOME/.claude"
|
||||
warn "\$HOME/.bashrc does not source lib/cc.sh, add: [ -f \"\$HOME/.claude/lib/cc.sh\" ] && . \"\$HOME/.claude/lib/cc.sh\""
|
||||
fi
|
||||
unset _dv_active_profile _dv_profile_file
|
||||
if grep -Eq 'alias cc=|dtach_claude' "$HOME/.bashrc" 2>/dev/null; then
|
||||
warn "\$HOME/.bashrc still has alias cc= or dtach_claude: remove them, the alias shadows cc()"
|
||||
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
|
||||
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"
|
||||
fi
|
||||
_m="$(jq -r '.model // "-"' "$REPO/settings.json" 2>/dev/null || echo "-")"
|
||||
if [ "$_m" = opus ]; then pass "settings.json model is opus"
|
||||
else warn "settings.json model is $_m (tracked default is opus)"; fi
|
||||
unset _ep_head _ep_work _m
|
||||
|
||||
echo ""
|
||||
|
||||
@@ -587,7 +581,7 @@ fi
|
||||
# every owned skill — permanent false-warn since. Inverted: warn if any
|
||||
# owned skill REintroduces the key (regression watch on BDR-019).
|
||||
PRESENT_DMI=()
|
||||
for f in "$HOME/.claude/skills/"*/SKILL.md; do
|
||||
for f in "$HOME/.claude/skills/"*/SKILL.md "$REPO"/skills/pack-*/skills/*/SKILL.md; do
|
||||
[ -f "$f" ] || continue
|
||||
dir=$(dirname "$f")
|
||||
# Skip external skills (symlinked directory or symlinked SKILL.md — not owned by this repo)
|
||||
@@ -643,7 +637,7 @@ fi
|
||||
|
||||
# Check CRLF — portable: grep -P not available on macOS BSD grep
|
||||
CRLF_FILES=()
|
||||
for f in "$REPO"/*.md "$REPO"/agents/*.md "$REPO"/skills/*/SKILL.md; do
|
||||
for f in "$REPO"/*.md "$REPO"/agents/*.md "$REPO"/skills/*/SKILL.md "$REPO"/skills/pack-*/skills/*/SKILL.md; do
|
||||
[ -f "$f" ] || continue
|
||||
if grep -c $'\r' "$f" 2>/dev/null | grep -q "^[^0]"; then
|
||||
CRLF_FILES+=("$(basename "$f")")
|
||||
|
||||
+17
-2
@@ -64,6 +64,10 @@ unset _gg_lib
|
||||
|
||||
# ── Toggle plugin detection ──
|
||||
|
||||
# One profile.sh run, shared with detect_gstack through PROFILE_PLAIN.
|
||||
PROFILE_PLAIN="$(bash "$HOME/.claude/lib/profile.sh" -C "$PWD" current --plain 2>/dev/null)" || PROFILE_PLAIN=""
|
||||
export PROFILE_PLAIN
|
||||
|
||||
TOGGLE_ACTIVE=()
|
||||
TOGGLE_INACTIVE=()
|
||||
|
||||
@@ -88,6 +92,17 @@ done
|
||||
ACTIVE_STR="${TOGGLE_ACTIVE[*]:-none}"
|
||||
INACTIVE_STR="${TOGGLE_INACTIVE[*]:-none}"
|
||||
|
||||
# Profile row: the project's local profile, the conversation's --settings
|
||||
# one, or none (manifest defaults = full) with the /plugin-check pointer.
|
||||
_pname="$(sed -n 's/^profile=//p' <<<"$PROFILE_PLAIN" | head -1)"
|
||||
case "$(sed -n 's/^source=//p' <<<"$PROFILE_PLAIN" | head -1)" in
|
||||
flag) PROFILE_ROW="profile: ${_pname} (conv)" ;;
|
||||
local) PROFILE_ROW="profile: ${_pname} (local)" ;;
|
||||
default) PROFILE_ROW="profile: none (full), try /plugin-check" ;;
|
||||
*) PROFILE_ROW="profile: ? (profile.sh failed)" ;;
|
||||
esac
|
||||
unset _pname
|
||||
|
||||
# GSD v2 — standalone CLI (not a Claude Code plugin — shown separately)
|
||||
if detect_gsd 2>/dev/null; then
|
||||
GSD_STATUS="gsd v2 ✓"
|
||||
@@ -289,7 +304,7 @@ if [ -n "$_remote_ver" ] && [ "$_remote_ver" != "$CONFIG_VERSION" ]; then
|
||||
fi
|
||||
unset _remote_ver REPO_DIR
|
||||
|
||||
echo "│ 💡 /plugin-check before starting a new project │"
|
||||
printf "│ 🎛 %-46s│\n" "$PROFILE_ROW"
|
||||
echo "│ 🩺 make doctor full diagnostic │"
|
||||
echo "└───────────────────────────────────────────────────┘"
|
||||
[ -n "$EFFORT_WARN" ] && printf '%s\n' "$EFFORT_WARN"
|
||||
@@ -309,4 +324,4 @@ EOF
|
||||
fi
|
||||
unset _gx_root
|
||||
echo ""
|
||||
unset TOKEN_WARN
|
||||
unset TOKEN_WARN PROFILE_PLAIN
|
||||
+8
-12
@@ -6,6 +6,7 @@ INPUT=$(cat)
|
||||
|
||||
MODEL=$(echo "$INPUT" | jq -r '.model.display_name // "?"')
|
||||
DIR=$(echo "$INPUT" | jq -r '.cwd // "?"')
|
||||
PROJ=$(echo "$INPUT" | jq -r '.workspace.project_dir // .cwd // "."' 2>/dev/null)
|
||||
FOLDER="${DIR##*/}"
|
||||
PCT=$(echo "$INPUT" | jq -r \
|
||||
'.context_window.used_percentage // 0' \
|
||||
@@ -20,18 +21,13 @@ BRANCH_STR="${BRANCH:+ ($BRANCH)}"
|
||||
|
||||
REPO="$(cd -P "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
# Default profile — same constant as lib/profile.sh's active_profile(),
|
||||
# read without sourcing the lib (speed). Unreadable lib → literal fallback.
|
||||
DEFAULT_PROFILE=$(sed -n 's/^DEFAULT_PROFILE="\([^"]*\)".*/\1/p' "$REPO/lib/profile.sh" 2>/dev/null)
|
||||
[ -n "$DEFAULT_PROFILE" ] || DEFAULT_PROFILE=full
|
||||
|
||||
# Active profile (written by lib/profile.sh set|apply|reset to <repo>/.active-profile).
|
||||
# Read directly — `profile.sh current` is 12s+ and unusable in a statusline.
|
||||
# Cache absent/empty/legacy "none" (same rule as active_profile()) → default.
|
||||
PROFILE=$(head -n1 "$REPO/.active-profile" 2>/dev/null | tr -d '[:space:]')
|
||||
if [ -z "$PROFILE" ] || [ "$PROFILE" = "none" ]; then
|
||||
PROFILE="$DEFAULT_PROFILE"
|
||||
fi
|
||||
# Profile of this project and conversation: `profile.sh current --plain`
|
||||
# (two jq calls) on the session's project dir. `(conv)` = a --settings
|
||||
# conversation. Any failure -> "?".
|
||||
_plain="$(bash "$REPO/lib/profile.sh" -C "$PROJ" current --plain 2>/dev/null)" || _plain=""
|
||||
PROFILE="$(sed -n 's/^profile=//p' <<<"$_plain" | head -1)"
|
||||
[ -n "$PROFILE" ] || PROFILE="?"
|
||||
[ "$(sed -n 's/^source=//p' <<<"$_plain" | head -1)" = flag ] && PROFILE="$PROFILE (conv)"
|
||||
|
||||
# Effort level: the live value when the harness exports it (skill/agent
|
||||
# `effort:` shifts included, BDR-107), else the persisted settings.json key
|
||||
|
||||
@@ -26,11 +26,12 @@ detect_superpowers() {
|
||||
# --- Toggle plugins ---
|
||||
|
||||
detect_gstack() {
|
||||
# gstack is exposed via per-skill symlinks in pack-gstack-* (browse, canary, qa, …);
|
||||
# the legacy top-level symlink was removed to avoid duplicate entries.
|
||||
# Detect by checking any of its individual skills.
|
||||
[ -L "$HOME/.claude/skills/pack-gstack-browser/skills/browse" ] \
|
||||
|| [ -L "$HOME/.claude/skills/pack-gstack-browser/skills/qa" ]
|
||||
# gstack = the three packs; "on" = pack-gstack-dev on for this project and
|
||||
# conversation. PROFILE_PLAIN (session-start) avoids a second profile.sh run.
|
||||
local plain="${PROFILE_PLAIN:-}"
|
||||
[ -n "$plain" ] || plain="$(bash "$HOME/.claude/lib/profile.sh" -C "$PWD" \
|
||||
current --plain 2>/dev/null)" || return 1
|
||||
grep -q '^pack-gstack-dev=on' <<<"$plain"
|
||||
}
|
||||
|
||||
detect_gsd() {
|
||||
|
||||
@@ -47,6 +47,7 @@ module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
|
||||
paths = glob.glob(skills_dir + "/*/SKILL.md")
|
||||
paths += glob.glob(skills_dir + "/pack-*/skills/*/SKILL.md")
|
||||
chars = sum(len(module.extract_description(p) or "") for p in paths)
|
||||
print(len(paths), chars)
|
||||
PY
|
||||
|
||||
+19
-73
@@ -8,8 +8,8 @@
|
||||
# skills, the seven superpowers skills, and any name link.sh links with
|
||||
# no lock entry at all, e.g. frontend-design, design-motion-principles).
|
||||
#
|
||||
# One entry point, `check_vendored_skills <repo> <claude_home>
|
||||
# [profile_file]`, sourced and called by doctor.sh. Two things checked
|
||||
# One entry point, `check_vendored_skills <repo> <claude_home>`, sourced
|
||||
# and called by doctor.sh. Two things checked
|
||||
# per name in link.sh's EXTERNAL_SKILLS array:
|
||||
# 1. its file(s) exist under skills-external/<name>/ — expected file
|
||||
# list comes from the matching plugins.lock.json entry (list shape
|
||||
@@ -17,13 +17,8 @@
|
||||
# emil-design-eng single-file "path" shape -> the key itself is the
|
||||
# name, file "SKILL.md") or, when no lock entry names it at all,
|
||||
# defaults to ["SKILL.md"].
|
||||
# 2. when the name is listed in <profile_file> (or no <profile_file>
|
||||
# is passed — the "could not resolve the active profile" case),
|
||||
# the <claude_home>/skills/<name> symlink points at
|
||||
# <repo>/skills-external/<name>. A name absent from the profile is
|
||||
# reported parked, not failed — unless its lock entry is
|
||||
# "always_on": true (the superpowers entry is), in which case the
|
||||
# symlink is checked regardless of the profile (see _dv_check_link).
|
||||
# 2. the <claude_home>/skills/<name> symlink points at
|
||||
# <repo>/skills-external/<name>.
|
||||
#
|
||||
# Lock parsing via python3 argv (never string-spliced) — same pattern as
|
||||
# lib/vendor-skills.sh's _vendor_read_lock. link.sh's EXTERNAL_SKILLS
|
||||
@@ -33,9 +28,7 @@
|
||||
# Every name/file pulled from the lock or link.sh is spliced into a
|
||||
# filesystem path (skills-external/<name>/<file>,
|
||||
# <claude_home>/skills/<name>): _dv_valid_item_name allowlists it first
|
||||
# (a rejection is a warn + skip, never a fail). doctor.sh's active
|
||||
# profile splices into lib/profiles/<name>.profile the same way, guarded
|
||||
# by _dv_valid_profile_name.
|
||||
# (a rejection is a warn + skip, never a fail).
|
||||
#
|
||||
# No `set -euo pipefail` here (mirrors lib/vendor-skills.sh): a sourced
|
||||
# lib must not change the caller's shell options.
|
||||
@@ -64,7 +57,7 @@ fi
|
||||
# _dv_lock_expectations <lockfile> — prints "<name>\t<file>" 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) — read by _dv_is_always_on, ignored by the
|
||||
# (the superpowers entry is), ignored by the
|
||||
# $1==n {print $2} awk in _dv_check_files: 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
|
||||
@@ -145,22 +138,6 @@ _dv_link_names() {
|
||||
| grep -v '^$'
|
||||
}
|
||||
|
||||
# _dv_profile_has <profile_file> <name> — true when a line's FIRST
|
||||
# whitespace-separated token equals <name> (the profile line's label
|
||||
# column — comments and the type column are ignored).
|
||||
_dv_profile_has() {
|
||||
local profile_file="$1" name="$2"
|
||||
awk -v n="$name" '$1 == n { found=1 } END { exit !found }' "$profile_file"
|
||||
}
|
||||
|
||||
# _dv_valid_profile_name <name> — true when <name> matches the
|
||||
# profile-name allowlist (letters, digits, underscore, hyphen only).
|
||||
# <name> is spliced into "lib/profiles/<name>.profile" by doctor.sh, so
|
||||
# a path-traversal or separator character must never reach it.
|
||||
_dv_valid_profile_name() {
|
||||
[[ "$1" =~ ^[A-Za-z0-9_-]+$ ]]
|
||||
}
|
||||
|
||||
# _dv_valid_item_name <name> — true when <name> (a skill name from
|
||||
# link.sh's EXTERNAL_SKILLS array, or a relative file named by a
|
||||
# plugins.lock.json entry) matches the item-name allowlist (letters,
|
||||
@@ -202,59 +179,28 @@ allowlist — skipped"
|
||||
[ "$all_ok" -eq 1 ]
|
||||
}
|
||||
|
||||
# _dv_is_always_on <name> <lock_out> — true when <lock_out> (the
|
||||
# "<name>\t<file>[\t1]" lines from _dv_lock_expectations) carries the
|
||||
# always_on third column for <name>'s lock entry.
|
||||
_dv_is_always_on() {
|
||||
local name="$1" lock_out="$2"
|
||||
awk -F'\t' -v n="$name" '$1 == n && $3 == 1 { found=1 } \
|
||||
END { exit !found }' <<< "$lock_out"
|
||||
}
|
||||
|
||||
# _dv_check_link <claude_home> <repo> <name> <profile_file> <always_on> —
|
||||
# when <always_on> is "1" (the name's lock entry is "always_on": true),
|
||||
# the symlink is checked whatever <profile_file> says — never parked.
|
||||
# Otherwise, when <profile_file> is non-empty and does not list <name>,
|
||||
# reports it parked (info), not failed. Otherwise (listed, always_on, or
|
||||
# no <profile_file> was passed — active profile could not be resolved,
|
||||
# every external is then expected linked) checks the
|
||||
# <claude_home>/skills/<name> symlink points at
|
||||
# <repo>/skills-external/<name>.
|
||||
# _dv_check_link <claude_home> <repo> <name> — the
|
||||
# <claude_home>/skills/<name> symlink points at <repo>/skills-external/<name>.
|
||||
_dv_check_link() {
|
||||
local claude_home="$1" repo="$2" name="$3" profile_file="$4" \
|
||||
always_on="$5"
|
||||
local link target label
|
||||
if [ "$always_on" != "1" ] && [ -n "$profile_file" ] \
|
||||
&& ! _dv_profile_has "$profile_file" "$name"; then
|
||||
label="$(basename "$profile_file" .profile)"
|
||||
info "$name: parked by profile $label"
|
||||
return
|
||||
fi
|
||||
link="$claude_home/skills/$name"
|
||||
target="$repo/skills-external/$name"
|
||||
local claude_home="$1" repo="$2" name="$3"
|
||||
local link="$claude_home/skills/$name"
|
||||
local target="$repo/skills-external/$name"
|
||||
if [ -L "$link" ] && [ "$(readlink "$link")" = "$target" ]; then
|
||||
pass "$name: vendored + linked"
|
||||
else
|
||||
fail "$name: symlink missing/wrong — run: make link (or: bash \
|
||||
lib/profile.sh apply <profile>)"
|
||||
fail "$name: symlink missing/wrong — run: make link"
|
||||
fi
|
||||
}
|
||||
|
||||
# _dv_check_name <repo> <claude_home> <name> <profile_file> <lock_out> —
|
||||
# per-name dispatch for check_vendored_skills's loop: files first (the
|
||||
# link check runs only when every expected file is present, same as
|
||||
# before), then the symlink, passing _dv_is_always_on's verdict as
|
||||
# _dv_check_link's 5th param.
|
||||
# _dv_check_name <repo> <claude_home> <name> <lock_out> — per-name
|
||||
# dispatch: files first, the symlink only when every file is present.
|
||||
_dv_check_name() {
|
||||
local repo="$1" claude_home="$2" name="$3" profile_file="$4" lock_out="$5"
|
||||
local always_on=""
|
||||
_dv_is_always_on "$name" "$lock_out" && always_on=1
|
||||
local repo="$1" claude_home="$2" name="$3" lock_out="$4"
|
||||
_dv_check_files "$repo" "$name" "$lock_out" \
|
||||
&& _dv_check_link "$claude_home" "$repo" "$name" "$profile_file" \
|
||||
"$always_on"
|
||||
&& _dv_check_link "$claude_home" "$repo" "$name"
|
||||
}
|
||||
|
||||
# check_vendored_skills <repo> <claude_home> [profile_file] — see the
|
||||
# check_vendored_skills <repo> <claude_home> — see the
|
||||
# file header. Either the lock or link.sh being unreadable (or a
|
||||
# malformed lock entry — _dv_lock_expectations rc 1) is a warn, never a
|
||||
# fail; link.sh unreadable skips the whole check (there is nothing to
|
||||
@@ -262,7 +208,7 @@ _dv_check_name() {
|
||||
# allowlist before it is spliced into a path — a rejected one is
|
||||
# warned and skipped, not failed.
|
||||
check_vendored_skills() {
|
||||
local repo="$1" claude_home="$2" profile_file="${3:-}"
|
||||
local repo="$1" claude_home="$2"
|
||||
local lock_out names name
|
||||
|
||||
if ! lock_out="$(_dv_lock_expectations "$repo/plugins.lock.json")"; then
|
||||
@@ -285,6 +231,6 @@ check skipped"
|
||||
item-name allowlist — skipped"
|
||||
continue
|
||||
fi
|
||||
_dv_check_name "$repo" "$claude_home" "$name" "$profile_file" "$lock_out"
|
||||
_dv_check_name "$repo" "$claude_home" "$name" "$lock_out"
|
||||
done <<< "$names"
|
||||
}
|
||||
@@ -3,25 +3,19 @@
|
||||
# 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, a fake <claude_home>/skills dir and a fake
|
||||
# profile file. Cases: every file present + linked (ALL_PRESENT), a
|
||||
# EXTERNAL_SKILLS=(...) array and a fake <claude_home>/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
|
||||
# (SYMLINK_MISSING_ACTIVE) or a symlink to the wrong target
|
||||
# (SYMLINK_WRONG_TARGET), a name absent from the profile reported parked
|
||||
# rather than failed (SYMLINK_PARKED), the same name treated as
|
||||
# expected-linked (fail, not parked) when no profile file is passed at
|
||||
# all (NO_PROFILE_EXPECTS_LINK), an unreadable lock file degrading to a
|
||||
# (SYMLINK_WRONG_TARGET), an unreadable lock file degrading to a
|
||||
# warn instead of a fail (LOCK_UNREADABLE, rc 0), a lock entry whose
|
||||
# "skills" is neither null/list/dict degrading the same way with no
|
||||
# Python traceback leaking (LOCK_MALFORMED_ENTRY, rc 0), the
|
||||
# profile-name allowlist rejecting a path-traversal value
|
||||
# (REJECTS_BAD_PROFILE_NAME), the item-name allowlist rejecting a
|
||||
# item-name allowlist rejecting a
|
||||
# link.sh entry with a ".." segment — warned and skipped, not failed
|
||||
# (REJECTS_BAD_NAME), and an "always_on": true lock entry's name, absent
|
||||
# from the profile and with no symlink, checked (and failed) instead of
|
||||
# reported parked (ALWAYS_ON_LINK_CHECKED).
|
||||
# (REJECTS_BAD_NAME), and an "always_on": true lock entry's name with no
|
||||
# symlink failing like any other (ALWAYS_ON_LINK_CHECKED).
|
||||
set -u
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
LIB="$ROOT/lib/doctor-vendored.sh"
|
||||
@@ -52,8 +46,7 @@ cat > "$REPO/plugins.lock.json" <<'JSON'
|
||||
"list-entry": {
|
||||
"managed_by": "curl",
|
||||
"skills": [
|
||||
"missing-skill", "active-nolink-skill", "active-wronglink-skill",
|
||||
"parked-skill", "noprofile-skill"
|
||||
"missing-skill", "active-nolink-skill", "active-wronglink-skill"
|
||||
]
|
||||
},
|
||||
"dict-entry": {
|
||||
@@ -72,43 +65,28 @@ JSON
|
||||
cat > "$REPO/link.sh" <<'SH'
|
||||
#!/usr/bin/env bash
|
||||
EXTERNAL_SKILLS=(ok-skill missing-skill dict-skill
|
||||
active-nolink-skill active-wronglink-skill
|
||||
parked-skill noprofile-skill always-on-skill)
|
||||
active-nolink-skill active-wronglink-skill always-on-skill)
|
||||
SH
|
||||
|
||||
# ── skills-external/ tree: every name's SKILL.md present, except
|
||||
# missing-skill (nothing at all) and dict-skill's references/notes.md.
|
||||
# always-on-skill has its SKILL.md too — only its symlink is missing.
|
||||
for n in ok-skill dict-skill active-nolink-skill active-wronglink-skill \
|
||||
parked-skill noprofile-skill always-on-skill; do
|
||||
always-on-skill; do
|
||||
mkdir -p "$REPO/skills-external/$n"
|
||||
echo "v1" > "$REPO/skills-external/$n/SKILL.md"
|
||||
done
|
||||
|
||||
# ── claude_home symlinks: ok-skill correct, active-wronglink-skill
|
||||
# points elsewhere, active-nolink-skill, noprofile-skill and
|
||||
# always-on-skill have none.
|
||||
# points elsewhere, active-nolink-skill and always-on-skill have none.
|
||||
ln -sf "$REPO/skills-external/ok-skill" "$CLAUDE_HOME/skills/ok-skill"
|
||||
mkdir -p "$WORK/elsewhere"
|
||||
ln -sf "$WORK/elsewhere" "$CLAUDE_HOME/skills/active-wronglink-skill"
|
||||
|
||||
# ── active.profile: lists everything EXCEPT parked-skill,
|
||||
# noprofile-skill and always-on-skill (all three proven absent from it).
|
||||
cat > "$REPO/active.profile" <<'PROF'
|
||||
# DESC: fixture profile
|
||||
ok-skill external
|
||||
missing-skill external
|
||||
dict-skill external
|
||||
active-nolink-skill external
|
||||
active-wronglink-skill external
|
||||
PROF
|
||||
|
||||
# shellcheck source=../doctor-vendored.sh disable=SC1091
|
||||
source "$LIB"
|
||||
|
||||
# ── With the active profile passed ──────────────────────────────────
|
||||
out1="$(check_vendored_skills "$REPO" "$CLAUDE_HOME" \
|
||||
"$REPO/active.profile" 2>&1)"
|
||||
out1="$(check_vendored_skills "$REPO" "$CLAUDE_HOME" 2>&1)"
|
||||
|
||||
check_bool ALL_PRESENT \
|
||||
"$(printf '%s' "$out1" | grep -qF 'ok-skill: vendored + linked' \
|
||||
@@ -135,28 +113,9 @@ check_bool SYMLINK_WRONG_TARGET \
|
||||
grep -qF 'active-wronglink-skill: symlink missing/wrong' \
|
||||
&& echo 1 || echo 0)"
|
||||
|
||||
check_bool SYMLINK_PARKED \
|
||||
"$(printf '%s' "$out1" | grep -qF 'parked-skill: parked by profile active' \
|
||||
&& ! printf '%s' "$out1" | \
|
||||
grep -qF 'parked-skill: symlink missing/wrong' \
|
||||
&& echo 1 || echo 0)"
|
||||
|
||||
# ── always-on-skill: absent from active.profile (same as parked-skill)
|
||||
# but its lock entry is "always_on": true — checked (and failed, no
|
||||
# symlink) instead of reported parked.
|
||||
check_bool ALWAYS_ON_LINK_CHECKED \
|
||||
"$(printf '%s' "$out1" | \
|
||||
grep -qF 'always-on-skill: symlink missing/wrong' \
|
||||
&& ! printf '%s' "$out1" | \
|
||||
grep -qF 'always-on-skill: parked by profile' \
|
||||
&& echo 1 || echo 0)"
|
||||
|
||||
# ── No profile file passed at all: noprofile-skill (absent from
|
||||
# active.profile, parked above) must now be treated as expected-linked.
|
||||
out2="$(check_vendored_skills "$REPO" "$CLAUDE_HOME" 2>&1)"
|
||||
check_bool NO_PROFILE_EXPECTS_LINK \
|
||||
"$(printf '%s' "$out2" | \
|
||||
grep -qF 'noprofile-skill: symlink missing/wrong' && echo 1 || echo 0)"
|
||||
grep -qF 'always-on-skill: symlink missing/wrong' && echo 1 || echo 0)"
|
||||
|
||||
# ── LOCK_UNREADABLE — a second, minimal fixture with an invalid
|
||||
# plugins.lock.json: check_vendored_skills degrades to a warn (not a
|
||||
@@ -203,14 +162,6 @@ check_bool LOCK_MALFORMED_ENTRY \
|
||||
&& ! printf '%s' "$out4" | grep -q 'Error:' \
|
||||
&& echo 1 || echo 0)"
|
||||
|
||||
# ── REJECTS_BAD_PROFILE_NAME — the profile-name allowlist helper
|
||||
# rejects a path-traversal value and accepts a plain one.
|
||||
check_bool REJECTS_BAD_PROFILE_NAME \
|
||||
"$( { _dv_valid_profile_name "full" \
|
||||
&& ! _dv_valid_profile_name "../x" \
|
||||
&& ! _dv_valid_profile_name "a/b" \
|
||||
&& ! _dv_valid_profile_name "a.b"; } && echo 1 || echo 0)"
|
||||
|
||||
# ── REJECTS_BAD_NAME — a link.sh EXTERNAL_SKILLS entry with a ".."
|
||||
# segment: warned and skipped, never reaches _dv_check_files/
|
||||
# _dv_check_link (no fail line names it), rc 0.
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
# lib/tests/statusline.test.sh — hooks/statusline.sh profile segment comes
|
||||
# from `profile.sh -C <project_dir> current --plain`; a --settings
|
||||
# conversation shows "(conv)"; profile.sh failing or missing prints
|
||||
# "profile: ?" and never breaks the line.
|
||||
set -u
|
||||
unset CLAUDE_PROFILE CLAUDE_PROFILE_SETTINGS
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
pass=0; fail=0
|
||||
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/hooks" "$FX/lib" "$FX/proj" "$FX/cwd"
|
||||
cp "$ROOT/hooks/statusline.sh" "$FX/hooks/"
|
||||
printf '{"effortLevel": "high"}\n' > "$FX/settings.json"
|
||||
cat > "$FX/lib/profile.sh" <<'PROF'
|
||||
#!/usr/bin/env bash
|
||||
[ "$2" = "$FAKE_DIR" ] || { echo "wrong -C: $2" >&2; exit 2; }
|
||||
printf 'profile=%s\nsource=%s\n' "$FAKE_PROFILE" "$FAKE_SOURCE"
|
||||
PROF
|
||||
# The project dir differs from the cwd: the segment must follow project_dir.
|
||||
sl() { printf '{"cwd": "%s", "workspace": {"project_dir": "%s"}}\n' \
|
||||
"$FX/cwd" "$FX/proj" | FAKE_DIR="$FX/proj" bash "$FX/hooks/statusline.sh"; }
|
||||
out="$(FAKE_PROFILE=web FAKE_SOURCE=local sl)"; check_has T1-local "$out" "profile: web |"
|
||||
out="$(FAKE_PROFILE=dev FAKE_SOURCE=flag sl)"; check_has T2-conv "$out" "profile: dev (conv) |"
|
||||
out="$(FAKE_PROFILE=full FAKE_SOURCE=default sl)"; check_has T3-default "$out" "profile: full |"
|
||||
printf 'exit 2\n' > "$FX/lib/profile.sh"
|
||||
out="$(sl 2>&1)"; check_has T4-failing "$out" "profile: ? |"
|
||||
rm "$FX/lib/profile.sh"; out="$(sl 2>&1)"; check_has T5-missing "$out" "profile: ? |"
|
||||
printf 'PASS=%s FAIL=%s\n' "$pass" "$fail"; [ "$fail" -eq 0 ]
|
||||
@@ -75,11 +75,9 @@ fi
|
||||
# impeccable is NOT here: its installer writes the skill straight into
|
||||
# skills/ (and its agents into agents/) at --scope=global, so there is no
|
||||
# skills-external/ copy to symlink. See install-plugins.sh Step 8d.
|
||||
EXTERNAL_SKILLS=(emil-design-eng frontend-design design-motion-principles
|
||||
observability-and-instrumentation deprecation-and-migration ci-cd-and-automation
|
||||
scroll-world-storytelling build-threejs-scroll-worlds
|
||||
scroll-scrubbed-visual-sequence scroll-scrubbed-word-reveal
|
||||
scroll-progress-timeline brainstorming writing-plans
|
||||
# The design and scroll skills are pack symlinks now (skills/pack-*).
|
||||
EXTERNAL_SKILLS=(observability-and-instrumentation deprecation-and-migration
|
||||
ci-cd-and-automation brainstorming writing-plans
|
||||
subagent-driven-development test-driven-development
|
||||
requesting-code-review using-git-worktrees writing-skills)
|
||||
for _ext_skill in "${EXTERNAL_SKILLS[@]}"; do
|
||||
|
||||
Reference in new issue
Block a user