diff --git a/.claude/memory/blockers.md b/.claude/memory/blockers.md index e34748f..9150a0e 100644 --- a/.claude/memory/blockers.md +++ b/.claude/memory/blockers.md @@ -232,6 +232,7 @@ rules: - **Recurred same day**: this session's shell died the same way mid-G8 (BDR-095 amendment) while the 5.9 GB still sat there; recovered the moment the user deleted the dir. Mechanism now established, not inferred: stock `/usr/lib/systemd/system/tmp.mount` mounts /tmp with `x-systemd.graceful-option=usrquota` (no override, no fstab line on this machine) and systemd caps each user at 80% of the tmpfs → 0.8 × 7.4 GB = 5.9 GB, the exact volume observed. One quota for every session AND every sub-agent of the uid: multi-session is not the cause, the shared cap is. - **Durable fix**: (1) launch claude with `TMPDIR=$HOME/.cache/claude-tmp` (in `~/.bashrc` `dtach_claude()`, before `exec claude`; `mkdir -p` it) → Claude Code's scratchpad, tool outputs, `mktemp` and npm staging all leave the tmpfs; children inherit. (2) `~/.config/user-tmpfiles.d/claude-tmp.conf` with `e %h/.cache/claude-tmp - - - 3d` + the user `systemd-tmpfiles-clean.timer` so dead-session dirs age out. (3) `make doctor` "Scratchpad" section warns while TMPDIR sits on a quota'd tmpfs. Probe rule unchanged: HOMEs with npm payloads under `~/.cache//`. - **Status**: cause established; open until the launcher exports TMPDIR (user's .bashrc, hand-managed). Links [[BDR-094]], [[BDR-095]], [[LRN-159]]. +- **Status (2026-11-02)**: resolved 2026-11-02: lib/cc.sh exports TMPDIR=$HOME/.cache/claude-tmp for every cc session (phase 5) ## BLK-022 — `hooks/guard-bash.sh` withheld by the safety classifier; executable spec shipped instead — 2026-09-22 - **Friction**: layer C item G2 (PreToolUse Bash guard: whole-command scan incl. nested `bash -c`, `docker compose run … lftp`, scripts the command runs; exit 2 + reason + `logger` trace; fail-closed without jq). The response carrying the hook body was stopped by a safety classifier mid-write; content withheld, instruction not to regenerate it. @@ -344,3 +345,15 @@ rules: - **Measured**: 13 repos, 4 v1 closures without a labelled leading closed word: orbistep BLK-021 (really open), BLK-026 (prose addendum, really resolved), BLK-030 (mixed), bchanot-cv BLK-001 (strict already resolved, no effect). No lexical rule decides prose: BLK-021 and BLK-026 same shape, opposite truth. - **Solution**: /bugfix bugfix/memory-upgrade-prose-closure: repair only from a `Status`/`Statut` label whose leading word closes; else refuse file (rc 2), name ID + v1 line + remedy `memory.sh status`. Dedupe IDs. Committed repos audited clean; orbistep + zenquality redone after fix. - **Status (2026-10-31)**: resolved 2dae528: repair writes only a single closed Status word, prose/mixed refused and named, diff captured before inserts, one upgrade line per entry; orbistep + zenquality redone (144505f, b7edb9c) + +## BLK-039 — Nested heredoc executed plan text: settings.json committed, user's stash popped [resolved] (2026-11-02) +- **Friction**: a Bash call holding a python heredoc that itself contained `<<'EOF'` blocks: the inner `EOF` closed the outer heredoc; the rest of the plan text ran as shell commands → `git stash push settings.json` (silently failed), `git commit` of settings.json WITH the UI writes (theme, switchModelsOnFlag), auto-pushed; `git stash pop` popped the USER's own stash `wip: settings+routing dirty (user)` (conflict, entry kept). +- **Real cause**: heredoc nesting with the same delimiter; `rm -r`-class rules did not matter, the damage was git state. +- **Solution**: tree restored (`git reset -q`, checkout of the three stash-touched files to HEAD, stash-brought spec removed), commit dropped with `git reset --soft HEAD~1` + `git push --force-with-lease=:` (user approved), user's stash untouched. Rule: plan/doc text via Write/Edit, never heredoc-in-heredoc; never `git stash pop` on a machine with the user's own stashes; settings.json only through the index recipe (LRN-253). +- **Status**: resolved 2026-11-01. + +## BLK-040 — Permission rules and auto-mode classifier refuse destructive-shaped compound calls and dispatches [resolved] (2026-11-02) +- **Friction**: phase 5 execution: the permission rules refused a compound Bash call holding a `trap` with `rm -f`/`rmdir` (Task 1 canary), a 53-name `rm … && rmdir && rm .active-profile` chain, and `rmdir` alone; the auto-mode classifier refused the whole Task 2 dispatch because its brief described removing ~70 symlinks, moving impeccable and rewriting settings.json. +- **Real cause**: destructive-shaped text in one call or one brief; the classifier judges the dispatch prompt, the rules judge each command. +- **Solution**: split build steps (implementer) from state steps (main loop, after the user's explicit approval); one `rm` of literal names per call; `mv` to the scratch dir instead of `rmdir`/`rm -r`; never retry a refused command through a wrapper. Cost: three extra user gates, no data loss. +- **Status**: resolved 2026-11-02. diff --git a/.claude/memory/decisions.md b/.claude/memory/decisions.md index c236319..038fbe0 100644 --- a/.claude/memory/decisions.md +++ b/.claude/memory/decisions.md @@ -474,6 +474,7 @@ rules: - **Caveats**: the symlink form (`skills/ -> skills-external/gstack/`) differs from what gstack `./setup` would create (real dir + symlinked SKILL.md) — fine here because `./setup` never populates `skills/` in this layout, so no mixed-form collision. Browse RUNTIME still needs the built binary + sandbox env ([[BDR-029]]) — on-demand makes the skill DISCOVERABLE, not the browser functional on an unsupported OS. The old "try: bash link.sh" message was wrong (link.sh never creates gstack skills) → replaced with submodule-aware messages. - **Alternatives rejected**: full gstack integration (make `./setup` install into `skills/`) — user picked option 1, too invasive/version-fragile; leave `full` broken with honest 1-line warning — worse UX; pre-symlink all gstack at install — violates OFF-by-default context policy. - **Reference**: `lib/profile.sh` `GSTACK_SRC` + `enable_skill` gstack branch. Verified: `set full` → 0 missing, 35 on-demand; `minimal`↔`full` cycle re-parks/restores; git clean (gstack symlinks gitignored, [[LRN-025]]). Linked to [[LRN-042]], [[LRN-022]], [[BDR-018]] (gstack on/off verb). +- **Status (2026-11-02)**: superseded by BDR-134 --- @@ -1459,3 +1460,13 @@ Branch feature/user-writing-web-rules, UNMERGED (human gate). **Alternatives**: ignore negation (keeps false closures); line-scope negation (`resolved, not open` would read none: wrong); NLP (no). **Consequences**: real-data replay 14 repos → 1 move (robin_petier EVAL-005 accepted → keep). mawk run in T17 guards BWK-class awk. + +## BDR-134 — Phase 5: packs are skills-dir plugins, profiles are settings fragments, nothing global (2026-11-02) +- **Context**: one `~/.claude` serves every project and conversation. Old mechanism global: `skills/` ↔ `skills-disabled/` symlink moves + user-scope `claude plugin enable|disable` + `.active-profile`. One project's switch changed every open session. +- **Decision**: heavy skill groups = skills-dir plugins `skills/pack-/` (manifest + tracked relative symlinks into `skills-external/`, 4 real dirs moved). 9 packs: design, scroll3d, seo, web-validate, gstack-dev, gstack-browser, gstack-design, higgsfield (OFF), extras (OFF). Profiles = literal settings fragments `lib/profiles/.json` (`enabledPlugins` explicit for every pack + managed plugin, `deniedMcpServers` both higgsfield connectors on minimal/dev/seo/qa/audit, optional `model`); 9 profiles (backend, web-full dropped: byte-identical to dev, full). Per project `profile.sh set` merges into `.claude/settings.local.json`; per conversation `cc ` = `claude --settings`. `profile.sh current --plain` single truth for gate, hooks, statusline, advisor. No profile = manifest defaults = full. Listing budget `SLASH_COMMAND_TOOL_CHAR_BUDGET=50000` (0 name-only on full, +4.5k tokens est.). +- **Rationale**: measured 2026-11-01 (CLI 2.1.316): pack skills listed once as `pack:skill`, both names invoke; `--settings` false beats local true; `/reload-plugins` reloads a pack mid-session from a local edit but never re-reads a `--settings` file (frozen conversation → relaunch); connectors load under `-p`, denied per project by `serverName`, union across files. +- **Alternatives rejected**: keep symlink toggling (global, races between sessions); pack `.mcp.json` for higgsfield (duplicates the claude.ai connector, needs interactive OAuth); per-request confirmation of the gate (gate reads settings state, not files). +- **Supersedes**: BDR-030 (gstack via symlinks), BDR-079 (`set` symmetric on externals/MCPs), BDR-101 mechanism (full stays the policy). **Amends**: BDR-024/025 (`show --plain` → `current --plain`), BDR-109 (`higgsfield-websites` lives in pack-higgsfield, ON in `max` only; `profile.sh enable higgsfield` replaces both toggles; npm CLI unchanged). +- **Accepted risks**: `cc.sh` keeps `set -a; . ~/.claude/.env` (all secrets in the claude env, as `dtach_claude` did); `deniedMcpServers` union = `cc x web` on a `dev` project keeps the connectors denied (`set web` in the project fixes it). +- **Branch**: feature/phase5-profiles-packs; spec docs/superpowers/specs/2026-11-01-phase5-profiles-packs-design.md; contract .claude/tasks/contracts/2026-11-01-phase5-profiles-packs-1300.md. +Supersedes [[BDR-030]]. diff --git a/.claude/memory/evals.md b/.claude/memory/evals.md index 5cc726a..0355323 100644 --- a/.claude/memory/evals.md +++ b/.claude/memory/evals.md @@ -419,3 +419,10 @@ Dogfood: 3 blind lenses attacked the v1 plan for the plan-challenge feature itse - **Method**: 3-lens plan challenge + confirmation pass, per-task reviews, final opus/xhigh whole-branch review, GATE 0 oracles (10 runnable, c1-*.sh positive-controlled before work), fresh verifier, security gate. - **Anomalies**: challenge found 4 MAJOR (c1-readers red mid-Task 3, worktree vs in place, finish blocked by user settings hunks, contract out of sync with r2); final review found the new-file Write gap (I1) everybody missed; verifier 1st run died on Fable credits (429), retry pinned opus; 2nd run ECARTS(5) all human micro-gate items (approved text not on disk, transient docs out of scope, 2 SC2016 waivers); every per-task review clean first pass. - **Action**: keep oracles + positive control before dispatch; brief reviewers on new-file Write semantics for path rules; record gate texts on disk (contract) so the verifier can match them. + +## EVAL-054 — Three-lens plan challenge + confirmation caught 5 BLOCKERs before execution (phase 5) (2026-11-02) +- **Check**: plan r1 (2060 lines) attacked by three blind opus challengers + one confirmation pass before execution. +- **Method**: challenge-plan.md; lenses correctness / robustness / simplicity; r2 rewritten; confirmation on r2. +- **Result**: r1 FATAL(11)/FATAL(10)/CONCERNS(5): BLOCKER = plan written on a stale tree (profile backend live); 30 jq per statusline refresh; settings.json procedure that would have discarded user writes; test precedence inverted; doctor abort under pipefail; worktree incompatibility. Confirmation on r2: 2 more BLOCKERs (keep list dropped the tracked `skills/model-router` link; census matched itself). All fixed before Task 1. Execution then needed 4 fix rounds (gates/reviews), none on those aspects. +- **Anomalies**: the simplicity lens duplicated two robustness findings; the confirmation pass still found BLOCKERs, so one pass is the floor, not the ceiling. +- **Action**: keep the 3+1 shape for plans over ~1000 lines; add "live state verified at Task 0" to the plan template. diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index e2972e8..24c430f 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -681,3 +681,6 @@ rules: ## 2026-11-01 - memory-v2-minors /feat shipped (e4fb8f7 + 48ade8f): negated status words, dead empty steal, body `## ` refused, blob rc 1/2, rc 6 names dropped partial stages, reflow. Verifier CONFORME, security PASS, replay 14 repos = 1 expected move. Docs synced. Next: doc half, then phase 5 spikes. - memory-v2-minors-docs /feat shipped (dfbc8a7): § WRITE says every verb takes -C and --body-file absolute; tour/deploy/audit-delta point at § WRITE; evals template Later status line. Verifier CONFORME, security PASS. Phase 4a minors fully closed; MIGRATION.md:209 parked. Next: phase 5 spikes. + +## 2026-11-02 +- phase 5 profiles+packs shipped on feature/phase5-profiles-packs (13 tasks SDD, 3-lens challenge, gates MET/CONFORME/PASS after 3 passes): 9 packs, 9 profile fragments, profile.sh one-jq current --plain, cc [profile], census; BDR-134, LRN-248..253, BLK-039/040, EVAL-054; TODO: router ask-before-Fable queued diff --git a/.claude/memory/learnings.md b/.claude/memory/learnings.md index fe5f37d..33fda44 100644 --- a/.claude/memory/learnings.md +++ b/.claude/memory/learnings.md @@ -1881,3 +1881,33 @@ Rule: when editing a doctrine file under structure locks, grep the test's lock s **Pattern**: awk `match()` sets globals `RSTART`/`RLENGTH`; shared helper calling it clobbers caller's values. Take `substr(line, RSTART)` BEFORE calling any parser helper; audit every `RSTART` reader in programs embedding the shared awk block. **Application**: any `_MEM_AWK` change touching match(); same for `$0`, `NF` side effects of `sub()`/`split()` in helpers. + +## LRN-248 — skills-dir packs and claude.ai connectors: measured facts CLI 2.1.316 (2026-11-02) +- **Pattern**: skills-dir pack = `~/.claude/skills//.claude-plugin/plugin.json` + `skills//SKILL.md`. Loads as `@skills-dir` (manifest name, not folder). Nested skills listed ONCE as `pack:skill`; `Skill(skill)`, `Skill(pack:skill)`, typed `/skill`, `/pack:skill` all resolve. `defaultEnabled:false` → OFF with nothing written; local or `--settings` true turns it on. `--settings` false beats local true. `/reload-plugins` re-reads `enabledPlugins` from the settings files (skills + hooks mid-session; pack `.mcp.json` needs a new session) but NOT a `--settings` file: a pack OFF by flag comes back only through a relaunch. claude.ai connectors load under `-p` (2.1.316; not on 2026-10-25); `deniedMcpServers:[{serverName:"claude.ai X"}]` per project drops them (199 → 192 tools), `disableClaudeAiConnectors:true` drops all (any-source-true); lists UNION across files; `serverUrl` wildcard matches nothing (no URL exposed). Tool budget bare project 199 = 28 builtin + 1 model-router + 158 higgsfield + 8 Claude Docs + 4 Indeed. +- **Context**: phase 5 spikes, scratch projects, `claude -p … --output-format stream-json --verbose`, init message `plugins[] skills[] tools[] mcp_servers[]`. +- **Apply**: any per-project/per-conversation tool switching; design gates read the effective state, not files. + +## LRN-249 — Claude Code settings root = git common dir; mirror it, stop below HOME (2026-11-02) +- **Pattern**: Claude Code reads/writes `.claude/settings.local.json` at the git repo root (worktree → main checkout root, `git rev-parse --path-format=absolute --git-common-dir` parent); shared `.claude/settings.json` from the session dir. A tool mirroring the effective state must resolve the root the same way, stop below `$HOME` (`~/.claude/` is not a project), and fall back to the nearest `.claude/`/`CLAUDE.md`/`.git` outside git. +- **Context**: `lib/profile.sh find_root`; code review caught the nearest-marker walk diverging in worktrees and monorepo packages. +- **Apply**: statusline, hooks, gates run from `.cwd`/`project_dir`; never trust `$PWD` as the project. + +## LRN-250 — One jq pass over many files beats 30 jq spawns (13 ms vs 120 ms) (2026-11-02) +- **Pattern**: one jq program beats many: 30 jq spawns ≈ 120 ms (34 × `jq -n 1` = 118-137 ms measured); `jq -rn --rawfile a f1 --rawfile b f2 … -f prog.jq inputs…` with `def parse: try fromjson catch {}` and `input_filename` reads every file (absent → /dev/null → `{}`) in one pass. `current --plain` = 2 jq processes, 13-30 ms (target 50). +- **Context**: `lib/profile-state.jq`; statusline runs it on every refresh. +- **Apply**: any hook or statusline computing state from several JSON files. + +## LRN-251 — Plan against a stale tree: re-survey at Task 0, derive removal lists at run time (2026-11-02) +- **Pattern**: a plan written against a tree surveyed hours earlier is wrong by execution time: the live machine had switched to profile `backend` (impeccable parked as a real dir, 54 parked links, 20 flat links) between survey and plan; hardcoded `rm`/`mv` lists failed, and the only fix path a blind executor sees destroys the only install. Cure: Task 0 = snapshot (`find … -printf '%y %p %l'`) + verify assumptions; derive every removal list at run time (`find -type l`, remove by name); never delete a real dir, move it; keep the snapshot as the rollback recipe. +- **Context**: phase 5 plan r1 → r2, caught by the robustness and correctness challengers before execution. +- **Apply**: every plan touching machine-owned layout (symlinks, installs, caches). + +## LRN-252 — stream-json first line is hook_started; multi-turn canary on a FIFO; OFF pack via --settings (2026-11-02) +- **Pattern**: `claude -p --output-format stream-json --verbose`: the FIRST line is a `type=system subtype=hook_started` event (session-start hook), not init; select `type == "system" && subtype == "init"` over all lines. Multi-turn headless = `--input-format stream-json` on a FIFO/coproc: send a turn, wait for its `result`, edit files, send the next (one session id throughout). A canary pack with `defaultEnabled:false` turned on only via `--settings` is invisible to every other conversation; clean up with `mv` (rm/trap calls get refused by the permission rules). +- **Context**: phase 5 Task 1 and Task 12 canaries; the first reload canary mistakenly spanned two sessions. +- **Apply**: every headless measurement of plugins/skills/tools. + +## LRN-253 — Commit a tracked file with uncommitted UI writes through the git index (2026-11-02) +- **Pattern**: commit a change to a tracked file whose working copy carries uncommitted writes you must keep (settings.json UI writes): `git show HEAD:f | jq '' > tmp && git update-index --cacheinfo 100644,"$(git hash-object -w tmp)",f && git commit`, then patch the working copy with jq into a temp file and `cp` it back. Never `git checkout -- f`, never `git stash` (pop can take someone else's stash), never `git add -p` (interactive, unavailable), never `jq … > f` (truncates on failure). +- **Context**: phase 5 Task 13 listing budget; BLK-039. +- **Apply**: any commit to settings.json or another file the harness writes to. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 37c75f0..a1c553f 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -70,7 +70,8 @@ Shared rules for every phase: - Proof: static glob check per moved rule + logged session; hook tests (design-toolchain-reminder one-liner, session-start graph branch); the four skills Read the lib (grep census); `/context` delta. - Cleanup: CLAUDE.global.md loses the moved sections (one pointer line each where needed), citers patched (doctrine-citers census); BDR-031 citers. -- [ ] **Phase 5, per-project and per-conversation profiles, native packs** (redesigned 2026-10-25, shrunk the same day) +- [ ] **model-router: ask before routing to Fable** (user ask 2026-11-02, after the phase 5 merge: both touch `mods/model-router/routing.json`). `/feat` on the mod: a `routing.json` key `askTier` (default `best`; `/route ask-tier on|off`) makes the router ask, once per span, BEFORE applying a route whose resolved model sits in that tier, with the reason (phase + its `about`, origin: skill row / `/route` / prompt rule / agent row) and the options `Fable` · `Opus instead (big tier)` · `stop asking this session`; no memory in `confirmed` (the existing first-use confirmation stays as is); never asks in `-p` (`askOr` already falls back to LATER). Files: mods/model-router/hooks/register.ts (+ register.test.ts), routing.json, USAGE.md (`/route` section). +- [x] **Phase 5, per-project and per-conversation profiles, native packs** (redesigned 2026-10-25, shrunk the same day; shipped 2026-11-02 on feature/phase5-profiles-packs: BDR-134, spec docs/superpowers/specs/2026-11-01-phase5-profiles-packs-design.md, contract .claude/tasks/contracts/2026-11-01-phase5-profiles-packs-1300.md; user steps left: MIGRATION "Profiles and packs (2026-11)" step 4 `.bashrc`, `/context` on full/dev/web; follow-ups: census `grep -qxF`, fragment top-level key allowlist, MIGRATION step 2 `$root` re-derivation + autostash-conflict note) - Facts 2026-10-24/25 (scratch projects, fresh headless sessions, canaries, run concurrently, one shared ~/.claude): `.claude/settings.local.json` `enabledPlugins` per project works both ways and concurrently; `claude --settings ''` gives two SIMULTANEOUS conversations in the SAME project different plugin sets; a skills-dir plugin obeys both; plugin skills keep their short name (`ui-styling` resolves) but verify `:` too (router rows must match both); plugin agents need the `plugin:` prefix; `permissions.deny Skill(x)` does not hide a skill; `skillOverrides` does not reach plugin skills (packs hide by disabling, guide); a user-scope MCP cannot be switched off per project by settings: project MCP belongs in a pack `.mcp.json`; claude.ai connectors do not load under `-p`. - User answers 2026-10-25: profile per project and per conversation, never one for all; tracked `.claude/settings.json` keeps deny/allow only, profiles go local; a project without a profile gets a proposal once, written on accept; the global mode (skills/ ↔ skills-disabled/ symlinks + user-scope plugin toggling) is DELETED; core = everything except the heavy packs (design, seo/geo, web-validate, scroll/3d, higgsfield, gstack); agents stay global; a skill needing an off pack proposes to enable it then `/reload-plugins` (spike first); all 11 profiles kept as pack compositions. - Packs: each heavy group becomes a skills-dir plugin `skills/pack-/` (`.claude-plugin/plugin.json` + `skills//SKILL.md`, + `.mcp.json` for higgsfield, + hooks if any). Spike first: nested skills load once as plugin skills; gstack (external installer, symlinks) as a pack. diff --git a/.claude/tasks/contracts/2026-11-01-phase5-profiles-packs-1300.md b/.claude/tasks/contracts/2026-11-01-phase5-profiles-packs-1300.md new file mode 100644 index 0000000..6ee9a45 --- /dev/null +++ b/.claude/tasks/contracts/2026-11-01-phase5-profiles-packs-1300.md @@ -0,0 +1,62 @@ +# CONTRACT — phase5-profiles-packs + +## REQUEST (verbatim — IMMUTABLE) +Phase 5 of the context mod queue (BDR-125): per-project and per-conversation profiles, native packs. Full definition in .claude/tasks/TODO.md lines 73-84 (facts measured 2026-10-24/25, user answers 2026-10-25, packs as skills-dir plugins `skills/pack-/`, profiles `lib/profiles/.json` with `enabledPlugins` + `model`, `profile.sh set` writes `.claude/settings.local.json`, per-conversation `claude --settings`, detection via /plugin-check, mid-skill pack gates, listing budget after the packs, proof with concurrent conversations and canaries, cleanup list). User instruction for this run: run the FOUR SPIKES first, before any plan or design: (1) nested skills in a pack (a skills-dir plugin with `skills//SKILL.md` loads each skill once, short name and `:`); (2) `/reload-plugins` after a settings change loads a pack mid-session; (3) claude.ai connectors per project (interactive only; they do not load under `-p`); (4) higgsfield MCP in a pack `.mcp.json`. Each spike = a measured fact in a scratch project, headless where possible, interactive where the user must run the probe. Only then brainstorm and plan. CLI 2.1.316. Default model opus; Fable credits exhausted: pin verifier, security-auditor and challengers on opus. + +## CLARIFICATIONS +- Spike facts 2026-11-01 (headless, CLI 2.1.316; scratchpad p5/FACTS.md, copied into the plan): skills-dir packs load ON by default; nested skills listed once as `:`, both names invoke; `--settings` false beats local true; `/reload-plugins` works in `-p` and reloads skills + hooks mid-session after a settings edit, pack `.mcp.json` servers need a new session; claude.ai connectors DO load under `-p` now (changed since 2026-10-25), `--strict-mcp-config` drops them per conversation; a pack `.mcp.json` HTTP server is registered as `plugin::` and needs an interactive OAuth login. +- Spike 3 closed 2026-11-01 (measured F0-F5 + docs settings-reference): per project, `.claude/settings.local.json` `deniedMcpServers:[{serverName:"claude.ai "}]` drops the named connectors (199 → 192 tools for Gmail + Higgsfield AI) and `disableClaudeAiConnectors:true` drops all nine (26 tools, model-router kept); the same two keys via `--settings` work per conversation; a `serverUrl` wildcard matches no connector (no URL exposed); `disableClaudeAiConnectors` is any-source-true; the native `/mcp` toggle writes `disabledMcpServers` per project into `~/.claude.json` (untested, interactive only). Docs, not measured: `/reload-plugins` re-reads `enabledPlugins` from every settings file; `--plugin-dir` loads a pack as `@inline` for one session; the skills-dir id is the manifest `name`. +- Spikes 1b/1c/2b 2026-11-01 (headless): a pack manifest `defaultEnabled:false` is OFF with nothing written (local or `--settings` true turns it on); the typed short slash `/` on a pack skill expands like `/:`; in a `--settings` conversation `/reload-plugins` re-reads neither the flag file nor a local true over a flag false, so a pack OFF by flag only comes back through a relaunch. +- Brainstorm answers 2026-11-01 (user): no profile = `full` (packs ON, connectors present, as today); gstack split in three packs (dev / browser / design); both higgsfield connectors denied by `deniedMcpServers` in every profile except design, web, web-full, full, max; launcher `cc [profile]` as a function in `lib/cc.sh` sourced from `~/.bashrc` (user step), exporting `CLAUDE_PROFILE`, `CLAUDE_PROFILE_SETTINGS`, `TMPDIR` and running `claude --settings`; approach A = tracked packs `skills/pack-/` (relative symlinks into `skills-external/`, five real dirs moved), profiles as literal settings fragments `lib/profiles/.json`; `profile.sh current --plain` is the single truth for gates, hooks and statusline (supersedes BDR-024); a backend/dev profile still gets the design proposal mid-skill (`set web` / `enable design` + `/reload-plugins`, or relaunch when the source is the flag); listing budget measured last. Spec: `docs/superpowers/specs/2026-11-01-phase5-profiles-packs-design.md` (sections 1-9 approved in chat). +- Pass B 2026-11-01 `[gated]` (plan `docs/superpowers/plans/2026-11-01-phase5-profiles-packs.md`, user answers): `lib/tests/higgsfield.test.sh` is kept, trimmed to the skills-external sync and CLI probes (spec said delete); the "no citer left" census covers hooks lib agents skills rules templates mods, root `*.sh`, CLAUDE.global.md, README, USAGE, ARCHITECTURE, Makefile, plugins.lock.json, .gitignore and excludes `lib/tests/fixtures/`, `docs/`, `.claude/`, CHANGELOG, MIGRATION; gstack `./setup` is skipped with a warn ("run make link first") when `skills/gstack` is not the helper tree, never run-then-clean. Defaults accepted by silence: `profile.sh -C `; `--plain` keys `flag=`, `model-source=`, `mcp-off=`, `connector:*=denied`, `plugin:=`; new files `lib/pack-census.sh`, `lib/gstack-removed.list`, suites profile/cc/pack-census/statusline; impeccable = pack symlink to `skills-external/impeccable` moved there by the installer (not tracked, no `git mv`); `~/.bashrc` user step removes `dtach_claude` + `alias cc` and sources `lib/cc.sh`; `deniedMcpServers` union documented (`cc x web` over a `dev` project keeps the connectors denied). +- Floor-guard `[gated 2026-11-02]` (user): the four shellcheck suppressions are authorized with their reasons: `lib/profile.sh:2` SC2016 (file-wide; the jq programs quote `$var` on purpose), `lib/cc.sh` SC2016,SC1003 (the inner `bash -c` expands `$HOME` itself; `'^\'` is dtach's detach key), `lib/pack-census.sh:2` SC2088 (`~/.claude/skills` is a grep pattern, not a path), `lib/tests/cc.test.sh` SC1091 (sources a fixture); the plan file's code samples mirror them. The five deleted suites `lib/tests/{profile-default,profile-set-managed,profile-census,gstack-removed,toggle-external-repo-resolution}.test.sh` tested the retired symlink mechanism; their live checks moved to `lib/tests/profile.test.sh` (set/current/unset semantics, default profile) and `lib/tests/pack-census.test.sh` (fragment invariants, retired gstack names, old-layout citers). +- STEP 6 code review `[gated 2026-11-02]` (user): `backend.json` and `web-full.json` are dropped (they were byte-identical to `dev.json` and `full.json`, so `current` named the wrong profile and the advisor looped); nine profiles remain (full, max, minimal, dev, design, web, seo, qa, audit), the advisor maps backend → dev and web-full → full, and the census forbids two fragments with equal `enabledPlugins` + deny set. `higgsfield-websites` stays in pack-higgsfield (OFF by default, ON in `max` only; amends BDR-109, recorded in the phase 5 BDR). `lib/cc.sh` keeps `set -a; . ~/.claude/.env` as `dtach_claude` did (accepted risk, recorded in the BDR). Also ruled by the controller: the project root for the local file follows Claude Code's rule (git common dir root when inside a repo, else the dir; shared `.claude/settings.json` read from the session dir); the profile-name match considers only the connector names a fragment manages; profile and session names are allowlisted `^[a-z0-9][a-z0-9-]*$`. +- Floor-guard 2 `[gated 2026-11-02]` (user): the two `# shellcheck disable=SC2086` at lib/tests/cc.test.sh:62 and lib/tests/profile.test.sh:147 are authorized (test loops that word-split an argument string on purpose). Wording fix of the STEP 6 ruling: outside a git repo the root is the nearest ancestor holding `.claude/`, `CLAUDE.md` or `.git` below `$HOME` (the walk the suite tests), not the bare dir. Criterion 3's deny set reads minimal, dev, seo, qa, audit (backend dropped). +- Scope note `[gated 2026-11-02]` (user ask in this run): commit 08ae797 adds one TODO item to `.claude/tasks/TODO.md` (model-router: ask before routing to Fable, queued after the phase 5 merge). `.claude/tasks/` is a durable registry, outside the implementation scope; it is authorized and not part of the phase 5 diff under review. +- Design-derived criteria are appended at STEP 3 `[gated]`. + +## ACCEPTANCE CRITERIA +1. The four spikes are recorded as measured facts (method, command, result) in the plan file, and the ones that changed since 2026-10-25 are named (connectors under `-p`). +2. `[gated 2026-11-02]` Pack layout: nine packs `skills/pack-{design,scroll3d,seo,web-validate,gstack-dev,gstack-browser,gstack-design,higgsfield,extras}/` with a manifest whose `name` is the folder, 55 skill entries (relative symlinks into `skills-external/` or the four moved dirs seo, geo, web-validate, site-motion), no skill listed twice, none of the nine retired gstack names; `skills-disabled/`, `.active-profile`, `lib/toggle-external.sh` and `lib/profiles/*.profile` gone; the census (`lib/pack-census.sh`) finds no reader of the old layout in the contract scope (hooks lib agents skills rules templates mods, root `*.sh`, CLAUDE.global.md, README, USAGE, ARCHITECTURE, Makefile, plugins.lock.json, .gitignore; excluded: lib/tests/fixtures/, docs/, .claude/, CHANGELOG, MIGRATION). + CHECK: cd /home/bchanot/Documents/claude && out=$(bash lib/pack-census.sh 2>&1) && printf '%s\n' "$out" | grep -q '^PACKS OK 9 packs 55 skills' && [ ! -e skills-disabled ] && [ ! -e .active-profile ] && [ ! -e lib/toggle-external.sh ] && [ -z "$(ls lib/profiles/*.profile 2>/dev/null)" ] && [ -L skills/model-router ] && echo PACKS-OK + EXPECT: PACKS-OK + EVIDENCE: MET exit=0 marker-found :: PACKS-OK +3. `[gated 2026-11-02]` Profiles: nine fragments `lib/profiles/{full,max,minimal,dev,design,web,seo,qa,audit}.json` (amended `[gated 2026-11-02]`: backend and web-full dropped as duplicates) with the invariants of lib/profiles/README.md (same key set; model-router and security-guidance true; example-skills and brightdata false; both higgsfield connectors denied on exactly minimal, dev, backend, seo, qa, audit; full = manifest defaults); `lib/profile.sh` verbs list/show/current [--plain]/set/unset/enable/disable/diff with the merge, refusal (rc 2, nothing written), union, walk-up and timing semantics of the suite; `current --plain` keys as the plan § Task 3 states. + CHECK: cd /home/bchanot/Documents/claude && [ "$(ls lib/profiles/*.json | wc -l)" = 9 ] && a=$(make test suite=lib/tests/profile.test.sh 2>&1) && printf '%s\n' "$a" | grep -q 'FAIL=0' && echo PROFILE-OK + EXPECT: PROFILE-OK + EVIDENCE: MET exit=0 marker-found :: PROFILE-OK +4. `[gated 2026-11-02]` Launcher: `lib/cc.sh` defines `cc [profile]`; unknown profile → list + rc 2 and no session; with a profile `claude --settings lib/profiles/.json` runs with `CLAUDE_PROFILE`, `CLAUDE_PROFILE_SETTINGS` and `TMPDIR=$HOME/.cache/claude-tmp` exported through systemd-run + dtach; without a profile plain `claude`, TMPDIR still set, `.env` sourced. + CHECK: cd /home/bchanot/Documents/claude && a=$(make test suite=lib/tests/cc.test.sh 2>&1) && printf '%s\n' "$a" | grep -q 'FAIL=0' && echo CC-OK + EXPECT: CC-OK + EVIDENCE: MET exit=0 marker-found :: CC-OK +5. `[gated 2026-11-02]` Gates and hooks read `profile.sh current --plain`: design-tool-gate.sh needs pack-design, pack-gstack-design and ui-ux-pro-max on plus the 21st CLI signed in, remedy `profile.sh set web` (or `enable design`) + `/reload-plugins`, or `cc web` when source=flag; statusline shows `profile: ` / ` (conv)` / `?`; the banner row shows the profile or `none (full), try /plugin-check`; no `/profile design`, `GATE-BLOCK`, `show --plain` or `skill_status` left in lib/design-gate.md, skills/feat, skills/bugfix, agents/plugin-advisor.md. + CHECK: cd /home/bchanot/Documents/claude && a=$(make test suite="lib/tests/design-tool-gate.test.sh lib/tests/statusline.test.sh" 2>&1) && printf '%s\n' "$a" | grep -q 'all suites green' && ! grep -rqn '/profile design\|GATE-BLOCK\|show design --plain\|skill_status' lib/design-gate.md skills/feat skills/bugfix agents/plugin-advisor.md && echo GATES-OK + EXPECT: GATES-OK + EVIDENCE: MET exit=0 marker-found :: GATES-OK +6. `[gated 2026-11-02]` No user-scope write anywhere outside the installers' install-time enable: no `claude plugin enable|disable` and no `toggle-external` under lib/, hooks/, skills/, agents/; `profile.sh` and `cc.sh` never touch `~/.claude/settings.json`. + CHECK: cd /home/bchanot/Documents/claude && ! grep -rqn --exclude-dir=fixtures 'claude plugin enable\|claude plugin disable\|plugin enable\|plugin disable' lib hooks skills agents --include='*.sh' --include='*.md' && ! grep -q 'settings.json' lib/cc.sh && echo NO-USER-SCOPE + (amended `[gated 2026-11-02]`, user: `--exclude-dir=fixtures` — lib/tests/fixtures/*.md are append-only registry snapshots that predate the branch; the /profile prohibition sentence is reworded without the literal.) + EXPECT: NO-USER-SCOPE + EVIDENCE: MET exit=0 marker-found :: NO-USER-SCOPE +7. `[gated 2026-11-02]` The branch is green and clean: `make test` all suites green; shellcheck clean and ≤ 80 columns on lib/profile.sh, lib/cc.sh, lib/pack-census.sh, lib/design-tool-gate.sh; `settings.json` changes on the branch limited to `env.SLASH_COMMAND_TOOL_CHAR_BUDGET` (no UI write, no `model`, no `enabledPlugins` drift committed); `doctor.sh` exits 0 (warns allowed). + CHECK: cd /home/bchanot/Documents/claude && t=$(make test 2>&1) && printf '%s\n' "$t" | grep -q 'all suites green' && shellcheck lib/profile.sh lib/cc.sh lib/pack-census.sh lib/design-tool-gate.sh && [ "$(LC_ALL=C awk 'length($0) > 80' lib/profile.sh lib/cc.sh lib/pack-census.sh lib/design-tool-gate.sh lib/profile-state.jq | wc -l)" = 0 ] && [ "$(git diff develop...HEAD -- settings.json | grep '^[-+] ' | grep -v 'SLASH_COMMAND_TOOL_CHAR_BUDGET\|ENABLE_STOP_REVIEW' | wc -l)" = 0 ] && bash doctor.sh >/dev/null 2>&1 && echo BRANCH-OK + EXPECT: BRANCH-OK + EVIDENCE: MET exit=0 marker-found :: BRANCH-OK +8. `[gated 2026-11-02]` Proof recorded (plan Task 12, judged by the verifier from the executor's report and CHANGELOG): two concurrent conversations in one project under `--settings dev.json` / `web.json` list different packs and tool counts (higgsfield tools 0 vs 158); two projects with different local profiles differ; `enable seo` + `/reload-plugins` makes `/seo` and `/pack-seo:seo` resolve in a flagless conversation; `current --plain` timing recorded against the 50 ms target; listing budget value and per-profile name-only counts in CHANGELOG. +9. `[gated 2026-11-02]` Docs: MIGRATION.md holds the "Profiles and packs (2026-11)" section (amended `[gated 2026-11-02]`, user: no version number pre-empted; the CHANGELOG bullets live under `[Unreleased]`, the number is set at release-candidate) (user-scope restore, old-layout cleanup by enumeration, `.bashrc` guarded source line and alias removal, per-project `set`); README/USAGE/ARCHITECTURE/CLAUDE.global.md name no `toggle-external.sh`, `skills-disabled` or `profile-reset`; the deniedMcpServers union is documented in `/profile` and USAGE. + CHECK: cd /home/bchanot/Documents/claude && grep -q 'Profiles and packs' MIGRATION.md && grep -q 'lib/cc.sh' MIGRATION.md && ! grep -rqn 'toggle-external\|skills-disabled\|profile-reset' README.md USAGE.md ARCHITECTURE.md CLAUDE.global.md && grep -qi 'union' skills/profile/SKILL.md && echo DOCS-OK + EXPECT: DOCS-OK + EVIDENCE: MET exit=0 marker-found :: DOCS-OK + +## FILE SCOPE (final, STEP 3) +- skills/pack-*/ (new: manifests + symlinks; moved: seo, geo, web-validate, site-motion) +- lib/profile.sh, lib/profile-state.jq (new), lib/profiles/*.json (new) + README.md, lib/profiles/*.profile (deleted) +- lib/cc.sh (new), lib/pack-census.sh (new), lib/pack-census-fragments.jq (new), lib/gstack-removed.list (new), lib/gstack-removed.sh, lib/toggle-external.sh (deleted), lib/higgsfield-skills.sh +- lib/design-tool-gate.sh, lib/design-gate.md, lib/plugin-gate.md, agents/plugin-probe.md, agents/plugin-advisor.md, agents/client-handover-writer.md +- skills/profile/SKILL.md + test-prompts.json, skills/onboard/SKILL.md, skills/plugin-check/SKILL.md, skills/feat/SKILL.md + test-prompts.json, skills/bugfix/SKILL.md +- hooks/session-start.sh, hooks/statusline.sh, lib/detect-plugins.sh, doctor.sh, lib/doctor-vendored.sh, lib/doctor-skills.sh, link.sh, Makefile, .gitignore +- install-plugins.sh, update-all.sh, plugins.lock.json, settings.json (`env` only, Task 13) +- lib/skill-routing-census.py, mods/model-router/routing.json +- lib/tests/: profile.test.sh, cc.test.sh, pack-census.test.sh, statusline.test.sh (new), fixtures/pack-census-old-citers.sh (new), design-tool-gate.test.sh, doctor-vendored.test.sh, higgsfield.test.sh, effort-routing.test.sh, model-routing.test.sh, seo-geo-contract.test.sh, plan-challenger.test.sh, doctrine-citers.test.sh, lib/seo-data/seo-data.test.sh; deleted: profile-default, profile-set-managed, profile-census, gstack-removed, toggle-external-repo-resolution +- CLAUDE.global.md, README.md, USAGE.md, MIGRATION.md, ARCHITECTURE.md, CHANGELOG.md, rules/web-building.md +- Working tree only (never committed): flat symlinks and skills-disabled/ removed, impeccable moved to skills-external/impeccable, settings.json user-scope enabledPlugins restored diff --git a/.gitignore b/.gitignore index aaf3d4e..04f26a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,80 +1,10 @@ # ── claude-config repo ignores ── -# GStack skill symlinks — auto-created by gstack setup -# Only the gstack/ dir itself + all symlinked skills inside skills/ +# Core skills linked flat by link.sh (symlinks, machine-owned); the heavy groups live in skills/pack-*/ as tracked symlinks. skills/gstack -skills/autoplan -skills/benchmark -skills/browse -skills/canary -skills/careful -skills/codex -skills/connect-chrome -skills/cso -skills/design-consultation -skills/design-html -skills/design-review -skills/design-shotgun -skills/devex-review -skills/diagram -skills/document-release -skills/freeze -skills/gstack-upgrade -skills/guard -skills/health -skills/investigate -skills/land-and-deploy -skills/learn -skills/office-hours -skills/open-gstack-browser -skills/pair-agent -skills/plan-ceo-review -skills/plan-design-review -skills/plan-devex-review -skills/plan-eng-review -skills/qa -skills/qa-only -skills/retro -skills/review -skills/setup-browser-cookies -skills/setup-deploy -skills/ship -skills/unfreeze -skills/benchmark-models -skills/context-restore -skills/context-save -skills/make-pdf -skills/plan-tune -skills/spec -skills/document-generate -skills/landing-report -skills/scrape -skills/setup-gbrain -skills/skillify -skills/sync-gbrain -# iOS device-farm skills (need a Mac daemon + Tailscale + iOS devices) — -# not linked on this Linux host; ignored so they stay out of git if a -# future gstack setup on a Mac host materializes the symlinks. -skills/ios-clean -skills/ios-design-review -skills/ios-fix -skills/ios-qa -skills/ios-sync - -# External skill symlinks — auto-created by link.sh -skills/design-motion-principles -skills/emil-design-eng -skills/frontend-design skills/ci-cd-and-automation skills/deprecation-and-migration skills/observability-and-instrumentation -skills/scroll-world-storytelling -skills/build-threejs-scroll-worlds -skills/scroll-scrubbed-visual-sequence -skills/scroll-scrubbed-word-reveal -skills/scroll-progress-timeline - -# superpowers, vendored (plugins.lock.json 'superpowers') skills/brainstorming skills/writing-plans skills/subagent-driven-development @@ -83,10 +13,11 @@ skills/requesting-code-review skills/using-git-worktrees skills/writing-skills -# Impeccable — NOT a symlink: `impeccable skills install --scope=global` -# writes the skill dir (and its ~15 MB engine binary) straight in through the -# ~/.claude/skills symlink. Machine-owned, regenerated by make plugin/update. +# Impeccable — `impeccable skills install --scope=global` writes +# impeccable/ into the skills dir through the ~/.claude/skills symlink; install-plugins.sh +# moves it to skills-external/impeccable (pack-design links it). Machine-owned. skills/impeccable +skills-external/impeccable/ # …and the 4 subagents the same installer drops through ~/.claude/agents. # agents/ is a tracked directory, so these need naming explicitly. @@ -95,17 +26,6 @@ agents/impeccable-*.md # External skills installed via `npx skills add` — auto-created by link.sh skills/darwin-skill -# 21st.dev skill pack symlinks — created on demand by toggle-external.sh / -# profile.sh (the pack is DISABLED by default, so these usually don't exist). -# A glob, not one line per skill: the `21st skills install` manifest owns the -# membership, so the pack can gain a skill with no edit here. -skills/21st-* - -# Higgsfield skill pack symlinks — created on demand by toggle-external.sh -# (`enable higgsfield` / `enable higgsfield-websites`). The pack is OFF by -# default and in no profile, so these usually don't exist. -skills/higgsfield-* - # Context7 docs-lookup skill — installed by `ctx7 setup --claude --cli` # (install-plugins.sh Step 6, when absent) into ~/.claude/skills (a symlink to # this repo's skills/). ctx7-managed and re-created on demand — not vendored here. @@ -115,9 +35,6 @@ skills/find-docs/ # symlink to this repo's rules/). ctx7-managed — not vendored here. rules/context7.md -# Staging area used by lib/toggle-external.sh when disabling a tool -skills-disabled/ - # Local project config (per-machine, not shared) .claude/* !.claude/tasks/ @@ -184,8 +101,6 @@ desktop.ini .idea/ .vscode/ -# Profile cache — written by lib/profile.sh, read by hooks/statusline.sh -.active-profile .gstack/ # Frontend Design (Anthropic) — installed/refreshed from the example-skills diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 6a05c3f..469a315 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -14,7 +14,7 @@ claude-config/ ├── .env.example # Placeholder template for ~/.claude/.env (secrets never committed) ├── settings.json # Global permissions (deny / ask / allow) + autoMode classifier tiers ├── install.sh # Bootstrap: Claude Code CLI + auth + submodules + link + plugins -├── install-plugins.sh # One-shot installer: prerequisites + all plugins + default profile +├── install-plugins.sh # One-shot installer: prerequisites + all plugins ├── link.sh # Symlinks this repo into ~/.claude/, sets git's global core.hooksPath ├── doctor.sh # Setup diagnostic ├── update-all.sh # One-command update for all components @@ -27,10 +27,11 @@ claude-config/ ├── rules/ # Rule files deployed to ~/.claude/rules (path-scoped or always-on) ├── agents/ # Execution units called by skills (never invoked directly) ├── skills/ # Entry points invoked via /skill-name +│ └── pack-/ # Skills-dir packs: manifest + tracked symlinks into skills-external/ (seo, geo, web-validate, site-motion: real dirs) ├── mods/ # Claude Code mods (function-hooks plugins), loaded through the skills/ symlink ├── skills-external/ # Vendored skill packs: gstack submodule, design skills, superpowers, agent-skills, MengTo scroll skills, 21st and Higgsfield packs (machine-owned copies gitignored) ├── templates/ # Per-project templates (CLAUDE.md, settings, memory registries, path-rule skeletons, deploy runbook, gitignore) -└── lib/ # Shared libs: gitflow, memory registry writer, profiles, vendoring, route doctrine, gates, archetypes, architecture defaults, project-rule oracle, tests +└── lib/ # Shared libs: gitflow, memory registry writer, profiles (lib/profiles/*.json fragments, profile.sh, cc.sh), vendoring, route doctrine, gates, archetypes, architecture defaults, project-rule oracle, tests ``` ## Architecture principles diff --git a/CHANGELOG.md b/CHANGELOG.md index 528a8c1..58a6ca5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and this project ### Added - **Secure-by-default guardrails**: `rules/secure-by-default.md` (always on) makes six domains baseline on every project (the Supabase and cloud-function detail lives in the path rules `rules/supabase.md` and `rules/cloud-functions.md`), plus systematic API and access hygiene (auth on every route, CORS, secrets, passwords hashed with argon2id or bcrypt, never compared in clear, logged or hardcoded): hosting (rate limit, CDN and firewall, hard spend cap), Supabase (RLS on every table, owner-scoped policies, no service role key client-side), SMS and email (recorded consent, unsubscribe, STOP), cloud functions (no self-trigger, instance cap, budget stop), injection (bound values in raw escapes, `format()` for dynamic SQL, allowlisted filters, no shell into a DB tool), exposure (no data in the console, no production source map, no debug flag, no secret in hydrated state, data attributes, hidden fields or shipped comments). `/guardrails` audits them: a stdlib Python scanner (`skills/guardrails/scripts/scan.py`, FAIL / WARN / MANUAL, exit 1 on FAIL) then judgment, report in `.claude/audits/GUARDRAILS.md`. The security-auditor gate runs the scanner's `api` and `supabase` domains and blocks on FAIL. Items only a provider dashboard can set stay MANUAL, never claimed done. An optional read-only live probe (`skills/guardrails/scripts/probe.py`, `--live`) confirms a finding from outside on a target the user owns and names: anon-read, cross-user, no-auth route, CORS reflection and a capped rate-limit burst, verdicts OPEN / CLOSED / SKIPPED / ERROR. An `exposure` block in the plan adds three read-only probes, meant for a production build or a staging URL: a served or inline source map for the page's scripts, a stack trace in a 404 or a user-named error route, sensitive keys in a JSON response (identifier-shaped names printed, never values); a target the probe could not observe is SKIPPED or ERROR, never CLOSED, and every plan path must start with `/`. It sends GET, HEAD and OPTIONS only (one opt-in POST burst, capped at 25), requires `--authorized`, takes secrets from the environment never the command line, never follows a redirect to another host, and stops at a request budget. After the report, `/guardrails` proposes fixes (plan phase, so Fable when the router can switch), applies only the ones the user accepts through the `bugfixer` executor and the `lib/verify-secure-loop.md` gates, then re-scans: each accepted fix is a contract criterion whose oracle is the scanner (`--assert-absent RULE:path`, marker `GUARDRAILS-CLEAR`), and a full pass against the pre-fix baseline (`--baseline`, marker `GUARDRAILS-NO-NEW`) catches regressions; a live probe replays on the user's go; two rounds at most, residuals reported open; `--report-only` keeps the audit alone. Suites: `lib/tests/guardrails-scan.test.sh` (clean fixture plus one mutant per rule, check modes, `gates.sh` integration) and `lib/tests/guardrails-probe.test.sh` (probe logic against a localhost fixture server). -- **/a11y skill**: accessibility leaves `/guardrails` and becomes its own skill. Same A11Y-* rules (img alt, field label, click without keyboard, focus outline removed, positive tabindex) on the shared scan engine (`skills/guardrails/scripts/scanner.py`, a `Catalogue` per CLI; `skills/a11y/scripts/scan.py`, markers `A11Y-CLEAR` / `A11Y-NO-NEW`), a Tab-only walk of the main flow on `--live` through `/browse` (marked not done otherwise), report `.claude/audits/A11Y.md`, fixes proposed with the alt and label wording as the user's choice, applied through the bugfix circuit (`bugfixer`, verify-secure gates, `bugfix/a11y-`), re-pass against a baseline. The keyboard, alt and label doctrine moves from `rules/secure-by-default.md` to the lazy `rules/a11y.md` (loads on UI files only; `rules/web-building.md` points at it). `/guardrails` scans `injection` (INJ-*) and `exposure` (EXP-*) instead, with per-language SQL patterns, shared `code_files` / `hits` / `dedupe_lines` / `client_reachable` helpers and a walker that lists files over 1 MB by path; `--domain a11y` is a usage error there. `/web-validate` keeps full WCAG conformance. Suite `lib/tests/a11y-scan.test.sh`; routing row `reflect`; profiles audit, dev, web, web-full, full, max. +- **/a11y skill**: accessibility leaves `/guardrails` and becomes its own skill. Same A11Y-* rules (img alt, field label, click without keyboard, focus outline removed, positive tabindex) on the shared scan engine (`skills/guardrails/scripts/scanner.py`, a `Catalogue` per CLI; `skills/a11y/scripts/scan.py`, markers `A11Y-CLEAR` / `A11Y-NO-NEW`), a Tab-only walk of the main flow on `--live` through `/browse` (marked not done otherwise), report `.claude/audits/A11Y.md`, fixes proposed with the alt and label wording as the user's choice, applied through the bugfix circuit (`bugfixer`, verify-secure gates, `bugfix/a11y-`), re-pass against a baseline. The keyboard, alt and label doctrine moves from `rules/secure-by-default.md` to the lazy `rules/a11y.md` (loads on UI files only; `rules/web-building.md` points at it). `/guardrails` scans `injection` (INJ-*) and `exposure` (EXP-*) instead, with per-language SQL patterns, shared `code_files` / `hits` / `dedupe_lines` / `client_reachable` helpers and a walker that lists files over 1 MB by path; `--domain a11y` is a usage error there. `/web-validate` keeps full WCAG conformance. Suite `lib/tests/a11y-scan.test.sh`; routing row `reflect`; a top-level skill in no pack, so on under every profile. - **model-router mod**: `mods/model-router/`, a Claude Code mod (function-hooks plugin), routes every repo skill and agent from phase rows (`plan`, `reflect`, `orchestrate`, `escalate`, `judge`, `audit`, `implement`, `write`, `verify`, `explore`, `apply`, `mechanical`; built-ins Explore on sonnet/medium, Plan on opus/xhigh). A typed skill routes the main loop to its row, and a best-tier row holds across turns in a run slot until `/route clear`, `/route off`, a user `/model` or a typed skill on a non-best row. Agents get their row's model at spawn (within the tier, upward only) and its effort on every step; explicit Agent params win. Orchestrators declare their phases through the `mcp__model-router__route` tool. `ultrathink` in a prompt sets the turn's minimum effort and `/route effort=max` holds until `/route clear`; the built-in `/effort` is not a lever inside a run. `/route show` names the run slot (`main: run `), and a `null` row in the override drops a default row. The model gets a `route` tool and the user a `/route` command (`show|clear|off|on|reload|pending|ask on|off|forget ||model= effort=|switch on|off|verbose on|off`). Optional per-machine config `~/.claude/model-router.json`, where `"enabled": false` turns it off on that machine. The spinner suffix and the status line show the route in force. It loads in every session through the tracked symlink `skills/model-router` (`model-router@skills-dir`). `make doctor` gains a Mods section; suite `make test suite=lib/tests/mods.test.sh`. Known limits: a main-loop switch (a `/model` hand pick excepted) runs only while the cold read it costs (the context minus what the target model's prompt cache holds) fits `upgradeMaxTokens` (200000) or `downgradeMaxTokens` (120000), and a downgrade also needs `mainModelSwitch` (on by default, off on any non-boolean value); the hooks send full model ids, so the `models` table has to follow new versions. - **model-router first-use confirmation**: `mods/model-router/routing.json` (tracked) is the single source of the phase table and of every skill and agent row, and keeps the decisions: `confirmed`, `changed` (`from`/`to`), `projects` exceptions keyed by the origin remote reduced to `host/path` (credentials and local paths never stored), and `ask`. The first use of a rowed typed skill, a rowed agent spawn or a main-loop phase declared through the `route` tool opens a dialog with context: the skill's description (first sentence of its `SKILL.md` frontmatter) or the agent's, the phase with its `about` line (a new field on each of the 12 phases) and the model id and effort the next step really runs on. A row offers Later, Keep or Change; a main-loop phase Later or Keep. Change asks the model (fable, opus, sonnet, haiku with their tier), then the effort among those the phases of that model use (skipped when there is only one), then Everywhere or This project only; the pair maps to an existing phase (rows stay phase names, the same phase counts as Keep, a pair no phase offers is added by hand as a new phase). A skill-row change toasts the model and effort it now runs on, with the `/route switch on` hint when the main loop holds back a downgrade; a free-text answer counts as Later. One dialog at a time, never in headless (`-p`) runs or inside a sub-agent. Only a dialog answer, `/route ask on|off` or `/route forget` (which takes decisions back; a changed row returns to its shipped phase, the frontmatter floors stay yours to realign) writes the file (serialized, 64 KiB cap, never created when absent); each write asks you to commit it from the config repo. `/route pending` lists unconfirmed rows and phases. Layers: routing.json < `~/.claude/model-router.json` (its `ask` wins); a project's `.claude/model-router.json` is never read. Tests: `mods/model-router/hooks/register.test.ts`. - **model-router `/model` scope**: a `/model ` typed in the composer, or a pick in the `/model` picker, with a model the table knows asks where it applies. The picker's switch is held first (PreModelSwitch deny; the engine prints that a hook blocked it); a pick while another dialog is open is refused with `answer the open dialog first`. This project writes the full id as `model` into the project's `.claude/settings.local.json` (created if absent, refused through a link) and sets a sticky model route. This conversation sets the sticky route only. Everywhere runs the native `/model` (user `settings.json`). Both non-native answers drop the run slot and keep a sticky effort. With the picker's Default, an unknown name, a headless run or another origin, the native command runs with no question. A model chosen in that dialog always switches: it bypasses the cold-read caps and the `mainUpgrade` / `mainModelSwitch` flags, and while it is marked down or outside a known window it waits and the automatic chain decides. A native switch or `/clear` drops it; `/route model=` keeps the caps. Known limits: the `/config` Model row still writes user `settings.json`; a dialog never answered has no timeout. Tests: `mods/model-router/hooks/register.test.ts`. @@ -21,6 +21,11 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and this project - **InstructionsLoaded logger**: `hooks/instructions-loaded.sh`, wired in `settings.json`, appends one JSON line per instruction file loaded to `~/.claude/logs/instructions-loaded.jsonl` (rotated above 5 MB), the proof that a path rule loaded. - **Memory registries v2, single writer**: `lib/memory.sh` is the one writer and reader of the `.claude/memory/` registries (every verb takes an optional leading `-C `): `add --title … --body-file … [--status …] [--supersedes ]` appends an entry with the next ID from the headings and prints only the new ID (a body line starting `## ` outside a code fence would split the entry and is refused, rc 2); `status ` appends a dated `**Status ()**:` line; `journal ` appends under today's `## YYYY-MM-DD`; `index []` prints ID, date, title and status from headings and bodies; `check [--staged]` verifies heading shape, unique IDs, no Index and no open fence (a v1 file is named, never failed); `upgrade` migrates v1 to v2 (Index-only dates and statuses become body lines, `format: 2` added, `## Index` removed, every v1 heading dialect becomes `## ID — title (date)`), after an oracle on IDs, check and blocker verdicts, else rc 2 with the file untouched (a duplicate ID, a non-table Index, or a blocker the v1 reader closed only through prose, a mixed or a negated Status line is refused and named with the `memory.sh status` remedy; a v1 closure is carried over only from a `Status`/`Statut` label holding one closed, non-negated word, at most one upgrade status line per entry). Writes run under a lock in the git common dir (a stale lock is stolen by one waiter at a time; a steal marker left empty over 60 s counts as a dead stealer and is cleared), on a verified backup restored on failure or signal. `templates/memory/` ships v2 templates; the session banner adds `registry v1: N file(s) (memory.sh check)` while a project registry is v1. Suite `lib/tests/memory.test.sh`. - **Architecture defaults carrier**: `lib/architecture-defaults.md`, read before proposing a stack (new project, scaffolding, stack brainstorm, whole-project rewrite): public sites never SPA, Rust by default, web APIs versioned. Path rules `rules/supabase.md` and `rules/cloud-functions.md` hold the full Supabase and cloud-function domains. Suites `lib/tests/user-rules.test.sh` and `lib/tests/doctor-automem.test.sh`. +- **Packs**: nine skills-dir packs under `skills/pack-/` (design, scroll3d, seo, web-validate, gstack-dev, gstack-browser, gstack-design, higgsfield, extras), each a manifest plus tracked symlinks into `skills-external/` (seo, geo, web-validate and site-motion are real directories inside their pack). The installers only fill `skills-external/`; a pack is on or off as a unit. `lib/pack-census.sh` checks the packs (every skill linked once, targets resolve, doc citers) and runs in `make test`. +- **Profiles as settings fragments**: `lib/profiles/.json` replaces the flat-link profiles. `lib/profile.sh` verbs: `list`, `show`, `current` (`--plain` for hooks), `set`, `unset`, `enable`, `disable`, `diff`; `-C ` targets a project, `make profile cmd="set X" dir=/path` and `make profile-current dir=/path`. A project with no local profile runs the manifest defaults (= `full`). +- Nine profiles: `full`, `max`, `minimal`, `dev`, `design`, `web`, `seo`, `qa`, `audit`. `backend` (= `dev`) and `web-full` (= `full`) were identical fragments and are gone; the census refuses two equal fragments. +- **`cc [profile]`**: `lib/cc.sh`, sourced from `~/.bashrc`, starts a conversation under a profile fragment through `--settings`. +- The design gate, the plugin gate and advisor, the statusline, the session banner and `doctor.sh` read `profile.sh current --plain`. `doctor.sh` gains Packs and Profiles sections and checks that `cc.sh` is sourced. ### Changed - **model-router bare `/model` dialog**: a bare `/model` opens the router's dialog (model, variant, scope), so the scope question also comes when the pick is the current model (fable, opus, sonnet; a current haiku goes through `/model haiku`). Step 1 asks fable, opus, sonnet or `Other model (native picker)` (the native picker, run with the slot free so a pick inside it asks its scope); step 2 asks Standard or `[1m]`; step 3 is the existing scope question. Esc or free text changes nothing. Tests: `mods/model-router/hooks/register.test.ts`. @@ -46,10 +51,15 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and this project - Context diet (BDR-125 phase 1): `CLAUDE.global.md` keeps one always-on line for the architecture defaults and points to `lib/architecture-defaults.md`. Design work moves to `rules/web-building.md` § "Design work — full toolchain", and `hooks/design-toolchain-reminder.sh` now tells the model to Read it and no longer fires on `/` paths, `~/.claude/` and `$HOME/.claude/` prefixes (mapped to this repo) and `templates/project-rules/`; a bare `.claude/rules/` citation resolves by citer (this repo's own rules from `.claude/rules/` or `rules/`, else `templates/project-rules/`); T6 also scans `templates/` and `.claude/rules/`, T3 keeps its roots. +- `link.sh` no longer links the design and scroll skills flat; impeccable moves to `skills-external/impeccable`. Docs and routing (`CLAUDE.global.md`, `/profile`, README, USAGE, ARCHITECTURE) speak packs. +- Known limit: `cc x web` on a project in `dev` keeps the higgsfield connectors denied (`deniedMcpServers` is a union); `profile.sh set web` in the project lifts them from the next session. +- Measured headless on 2026-11-02: dev = `pack-gstack-dev`, 41 tools, 0 higgsfield; web = the six web packs, 199 tools, both connectors `connected` and 158 higgsfield tools listed in init (the stderr line "blocked by enterprise policy: claude.ai higgsfield, claude.ai Higgsfield AI" appeared on the deny profiles dev, qa, seo and minimal: that is `deniedMcpServers` working); qa = `pack-gstack-browser pack-web-validate`; seo = qa + `pack-gstack-dev pack-seo`; qa and seo 41 tools, 0 higgsfield; reload canary in one flagless session (id `ee65507c-a958-411b-9580-8aca8105e326`): `/seo` unavailable on minimal, `profile.sh enable seo`, `/reload-plugins` -> "Reloaded: 3 plugins · 2 skills · 32 agents · 7 hooks", then `/seo` and `/pack-seo:seo` both load the SEO skill. `profile.sh current --plain` median 30 ms (target 50). +- Listing budget with the packs: measured headless on 2026-11-02 with `--model haiku` (name-only skills, entries 124 on full, 90 on dev): full default 58, 40000 11, 50000 0, 60000 0; dev default 9, 40000 and above 0. Set `SLASH_COMMAND_TOOL_CHAR_BUDGET=50000` in `settings.json` `env`, the smallest tested value with 0 name-only on full. Cost, estimated: full (48.5k - 30.3k bytes) / 4, about 4.5k tokens; dev 30.0k to 36.8k bytes, about 1.7k tokens. `env` is global, so every profile pays. Descriptions are no longer truncated at 50000 (natural size 48.5k). The default budget's absolute value was not read; it may depend on the model's context window. ### Removed - `rules/default-language.md`: its content is `lib/architecture-defaults.md` § Default language. - The five `effort-low` … `effort-max` skills, `lib/effort-pins.txt`, `lib/effort-pins.sh` and `lib/model-check.sh`, with their tests and the effort-pin re-apply steps of `install-plugins.sh` and `update-all.sh`. The model-router rows replace them. A typed `/effort-` no longer exists: use `ultrathink` or `/route effort=max`. Breaking: the next release is 3.0.0. +- `skills-disabled/`, `lib/toggle-external.sh`, `.profile`, `.active-profile` and `make profile-reset`. `profile.sh enable higgsfield` replaces `toggle-external.sh`. Machine steps: MIGRATION.md, "Profiles and packs". ### Fixed - `/guardrails` and the interviewer cite the secure-by-default, Supabase, cloud-function and a11y rules by their absolute `~/.claude/rules/.md` path; run from a project repo, the bare `rules/.md` path resolved against that project and missed the rule files. diff --git a/CLAUDE.global.md b/CLAUDE.global.md index 492ae5e..cd4296c 100644 --- a/CLAUDE.global.md +++ b/CLAUDE.global.md @@ -270,14 +270,15 @@ cryptic names. - SEO+GEO → seo (GEO only → geo); W3C + WCAG conformance → web-validate; security audit (secrets, CVE, OWASP) → cso - Media generation (image, video, audio, brand kit), explicit ask → - Higgsfield pack, off by default: `bash ~/.claude/lib/toggle-external.sh - enable higgsfield`, then Read the skill under `~/.claude/skills/`; - `higgsfield generate cost` before a paid run. Landing page "with - Higgsfield", named ask → `enable higgsfield-websites`: an aid inside - the Design work rules (`rules/web-building.md`), never - `website create|deploy|publish`. -gstack OFF → its skills (investigate, qa, review, health, retro, -office-hours…) are gone: use the fallback above, else say so. + pack-higgsfield, off by default: `bash ~/.claude/lib/profile.sh enable + higgsfield` then `/reload-plugins`, then Read the skill under + `~/.claude/skills/pack-higgsfield/skills/`; `higgsfield generate cost` + before a paid run. Landing page "with Higgsfield", named ask → the same + pack's `higgsfield-websites`: an aid inside the Design work rules + (`rules/web-building.md`), never `website create|deploy|publish`. +gstack packs OFF (`profile.sh current`) → their skills (investigate, qa, +review, health, retro, office-hours…) are gone: use the fallback above, +else say so. ## graphify diff --git a/MIGRATION.md b/MIGRATION.md index 1237d40..003e5cc 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -187,7 +187,7 @@ All four checks should be clean before committing the migration. ```bash git pull --recurse-submodules -make plugin # vendors the 7 superpowers skills (Step 8e), installs the Higgsfield and 21st CLIs (8.6, 8.7), re-runs link.sh (10), applies the default profile (11) +make plugin # vendors the 7 superpowers skills (Step 8e), installs the Higgsfield and 21st CLIs (8.6, 8.7), re-runs link.sh (10) claude plugin uninstall superpowers@superpowers-marketplace # once, if the plugin is still cached make doctor ``` @@ -195,9 +195,104 @@ make doctor - **Superpowers**: the plugin is gone. Its 7 wired skills are vendored at v6.4.1 and always on. The 8 other skills and the session-start injection are not replaced. - **Magic MCP**: replaced by the `21st` CLI (`21st login`, no API key). If 1.x registered the `magic` server, remove it from `~/.claude.json` and drop `MAGIC_API_KEY` from `~/.claude/.env`. Nothing reads them any more. - **Git hooks in every repo**: `link.sh` sets git's global `core.hooksPath` to `~/.claude/githooks`. Every repo on the machine now gets the gitflow pre-commit guard and pushes each commit as it lands. For a foreign clone: `git config gitflow.protect false` and `git config gitflow.autopush false`. -- **Default profile**: a machine with no profile selected now runs `full`. Check with `make profile-current`. Nine gstack skills (`ship`, `land-and-deploy`, `setup-deploy`, `autoplan`, `context-save`, `learn`, `careful`, `guard`, `design-shotgun`) left every profile and are denylisted. +- **Default profile**: a project with no local profile runs the manifest defaults (= `full`). Check with `bash ~/.claude/lib/profile.sh current` from the project. Nine gstack skills (`ship`, `land-and-deploy`, `setup-deploy`, `autoplan`, `context-save`, `learn`, `careful`, `guard`, `design-shotgun`) left every profile and are denylisted. - **Higgsfield**: installed, off by default. Nothing to do until you enable it. +### Profiles and packs (2026-11) + +Run on every machine that pulls this version (the live tree may still be in +an old profile). Run steps 1 and 2 before any commit on that machine: the +removed `.gitignore` lines expose the old links as untracked files. Step 3 +is the only one that removes a real directory (`make plugin` replaces +`skills-external/impeccable` on a refresh); steps 1 and 2 use `mv`, never +`rm -r`. + +1. From the clone root. `~/.claude` is a real directory of symlinks into + the clone, not the clone itself, so resolve the root first. `git pull + --autostash` (a plain `git pull` aborts when `settings.json` is modified + locally and the incoming commits touch it; autostash keeps your UI + writes), then restore the user-scope plugins the old `profile.sh` had + toggled. Never `git checkout -- settings.json`: it would drop your UI + writes. + + ```bash + ep= next= + root="$(dirname "$(readlink -f ~/.claude/settings.json)")" + [ -n "$root" ] && [ -f "$root/lib/profile.sh" ] && cd "$root" \ + || { echo "no clone root"; false; } \ + && git pull --autostash \ + && ep="$(mktemp)" \ + && git show HEAD:settings.json | jq -e '.enabledPlugins | objects' \ + > "$ep" \ + && next="$(mktemp)" \ + && jq --slurpfile ep "$ep" '.enabledPlugins = $ep[0]' settings.json \ + > "$next" \ + && jq -e . "$next" >/dev/null && [ -s "$next" ] \ + && cp "$next" settings.json + rm -f "$ep" "$next" + ``` + + Every command is chained with `&&` so that a failed step never reaches + `cp`, which writes through the symlink into the live tracked + `settings.json`; a failure prints `no clone root` or stops the chain + without closing your shell. `ep= next=` comes first so the final `rm -f` + never removes a file an earlier run named. `jq -e '.enabledPlugins | + objects'` fails when HEAD holds no object (a null would wipe every + plugin). `jq -e .` and `[ -s ]` refuse an invalid or empty result (an + empty file would drop the plugins, the deny rules and the hooks). + + If the autostash pop conflicts, `settings.json` holds conflict markers: + the second `jq` then fails closed and nothing is copied. Resolve the + markers (`git stash list` shows the kept stash) before re-running step 1. + +2. Old layout. List the flat links first, then remove the links of + `skills-disabled/` and the links of `skills/` that are not kept + (model-router, darwin-skill, the seven superpowers, the agent-skills + trio). If `skills/impeccable` or `skills-disabled/impeccable` is a real + directory, `mv` it to `skills-external/impeccable` (never `rm`). It + re-derives `$root`, so it also runs in a new shell; `mkdir -p + skills-disabled` lets a machine that never had that dir pass the same + chain, and `rmdir` removes it at the end. The trailing slash and + `-mindepth 1` keep `find` from matching the start point, which is itself + a symlink in `~/.claude`. + + ```bash + root="$(dirname "$(readlink -f ~/.claude/settings.json)")" + [ -f "$root/lib/profile.sh" ] && cd "$root" \ + || { echo "no clone root"; false; } \ + && mkdir -p skills-disabled skills-external \ + && find skills/ skills-disabled/ -mindepth 1 -maxdepth 1 -type l \ + && for d in skills skills-disabled; do + if [ -d "$d/impeccable" ] && [ ! -L "$d/impeccable" ] \ + && [ ! -e skills-external/impeccable ]; then + mv "$d/impeccable" skills-external/impeccable + fi + done \ + && find skills-disabled/ -mindepth 1 -maxdepth 1 -type l -delete \ + && find skills/ -mindepth 1 -maxdepth 1 -type l \ + ! -name model-router ! -name darwin-skill \ + ! -name observability-and-instrumentation \ + ! -name deprecation-and-migration ! -name ci-cd-and-automation \ + ! -name brainstorming ! -name writing-plans \ + ! -name subagent-driven-development ! -name test-driven-development \ + ! -name requesting-code-review ! -name using-git-worktrees \ + ! -name writing-skills -delete \ + && rmdir skills-disabled && rm -f .active-profile + ``` + +3. From `$root`: `make link` (link.sh no longer links the design and scroll skills flat), + `make plugin` (fills `skills-external/`; impeccable ends in + `skills-external/impeccable`). +4. `~/.bashrc`: delete `dtach_claude()` and `alias cc='dtach_claude'` (the + alias would shadow the function and drop the profile argument); add + `[ -f "$HOME/.claude/lib/cc.sh" ] && . "$HOME/.claude/lib/cc.sh"`. New + shell. `cc ` behaves as before; `cc web` starts a conversation + under `lib/profiles/web.json`. +5. Per project: `bash ~/.claude/lib/profile.sh set ` then + `/reload-plugins`. `lib/toggle-external.sh` is gone (`profile.sh enable + higgsfield` replaces it). +6. `make doctor` until no warn; `make test`. + ## Memory registries v2 (2026-10-28) A v2 registry is the same `.claude/memory/.md` file, versioned and pushed with the code, with `format: 2` in its frontmatter and no `## Index`. The session banner line `registry v1: N file(s) (memory.sh check)` flags a project still on v1. v1 stays readable and writable (lenient), and the `check --staged` chokepoint skips it. diff --git a/Makefile b/Makefile index ff136fb..ada7c10 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/README.md b/README.md index 15465f4..713c42b 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ Limits: a main-loop switch re-reads cold the part of the context the target mode All scripts use their own location to find the repo — run them from anywhere. The plugins step logs to `install-YYYYMMDD-HHMMSS.log`. -The last step applies the default profile, `full`, when none is selected, and re-applies an existing selection. +The installers fill `skills-external/`; the packs under `skills/pack-*/` link it, on or off per project (`bash ~/.claude/lib/profile.sh set ` from the project, then `/reload-plugins`) or per conversation (`cc `). `cc` is a shell function from `lib/cc.sh`: add `[ -f "$HOME/.claude/lib/cc.sh" ] && . "$HOME/.claude/lib/cc.sh"` to `~/.bashrc` (`make doctor` warns until it is there). **Optional — Context7** (fast doc lookup for React / Next.js / Prisma…): the plugins step installs the `ctx7` CLI and wires it into Claude Code. The doc-fetch surface is @@ -177,7 +177,7 @@ ctx7 login # optional: OAuth / API key for higher rate limits | Component | Type | Description | Docs | |---|---|---|---| | **Superpowers skills** | Vendored (7, always on) | brainstorming, writing-plans, subagent-driven development, TDD, code review request, git worktrees, writing-skills — pinned v6.4.1 in plugins.lock.json, no plugin, no session injection | [obra/superpowers](https://github.com/obra/superpowers) | -| **GStack** | Git submodule (per profile) | Product workflow skills: plan reviews, design, browser QA, security (`cso`), `health`. Linked per profile; 9 broken or doctrine-breaking skills are denylisted in `lib/gstack-removed.sh`. | [garrytan/gstack](https://github.com/garrytan/gstack) | +| **GStack** | Git submodule (per profile) | Product workflow skills: plan reviews, design, browser QA, security (`cso`), `health`. Linked by pack-gstack-dev, pack-gstack-browser and pack-gstack-design; 9 broken or doctrine-breaking skills are denylisted in `lib/gstack-removed.list`. | [garrytan/gstack](https://github.com/garrytan/gstack) | | **GSD v2** | External CLI | Multi-session orchestration: crash recovery, cost tracking, parallel workers, context-fresh execution. | [gsd-build/gsd-2](https://github.com/gsd-build/gsd-2) | | **RTK** | CLI + hook (always on) | Rust Token Killer: the `hooks/rtk-rewrite.sh` PreToolUse hook rewrites Bash commands through `rtk` to cut output tokens. Zero passive cost. | [rtk-ai/rtk](https://github.com/rtk-ai/rtk) | | **security-guidance** | Plugin (always on) | Security hook. Regex layer and commit/push review on; the Stop-time diff review is off (`ENABLE_STOP_REVIEW=0`). | [anthropics/claude-code](https://github.com/anthropics/claude-code) | @@ -185,7 +185,7 @@ ctx7 login # optional: OAuth / API key for higher rate limits | **Context7** | CLI (`ctx7`) | Doc lookup for fast-evolving libs (Next.js, React, Prisma...), used through the `find-docs` skill. Works anonymously; optional `ctx7 login` raises rate limits. | [context7.com](https://context7.com/) | | **pr-review-toolkit** | Plugin (toggle) | Multi-agent PR review. | [anthropics/claude-code](https://github.com/anthropics/claude-code) | | **Graphify** | Python CLI | Codebase → knowledge graph → navigable wiki. Helps Claude map and search projects efficiently. | [pypi: graphifyy](https://pypi.org/project/graphifyy/) | -| **21st.dev** | External CLI + skill pack | Component catalog and UI generation (`21st`), browser login, no API key. 7 skills in `skills-external/21st-*`, linked per profile (see the 21st.dev CLI section). | [npm: @21st-dev/cli](https://www.npmjs.com/package/@21st-dev/cli) | +| **21st.dev** | External CLI + skill pack | Component catalog and UI generation (`21st`), browser login, no API key. 8 skills in `skills-external/21st-*`, linked by pack-design and pack-extras (see the 21st.dev CLI section). | [npm: @21st-dev/cli](https://www.npmjs.com/package/@21st-dev/cli) | | **Higgsfield** | External CLI + skill pack (off by default) | Image, video, audio and brand media generation, metered credits (see the Higgsfield CLI section). | [higgsfield-ai/skills](https://github.com/higgsfield-ai/skills) | | **Semgrep** | Python CLI (pinned) | SAST engine behind the security gate (`security-auditor`). | [pypi: semgrep](https://pypi.org/project/semgrep/) | | **Impeccable** | npm CLI + skill (pinned) | Deterministic anti-slop detector (`npx impeccable detect`, 61 rules) and the `/impeccable` design verbs. | [npm: impeccable](https://www.npmjs.com/package/impeccable) | @@ -240,14 +240,17 @@ a different package, ships its own conflicting `graphify` bin) — see | `/web-validate` | W3C HTML/CSS validity + WCAG 2.1 conformance audit (keyboard/alt/label basics → /a11y) | | `/geo` | GEO-only audit — AI-search visibility (ChatGPT, Perplexity, Claude, Gemini…) | | `/client-handover` | Final project delivery — audits + branded deliverable (Markdown / HTML / PDF) | -| `/profile` | Activate a skill profile (web / seo / web-full / full / max / backend / design / dev / qa / audit / minimal) (default: full) | +| `/profile` | Set this project's pack profile (`set `, `enable `), show the effective one (`current`) | | `/tour` | Grouped all-axes sweep — cleanup + security + reconcile + doc, fix and loop until clean | | `/site-motion` | Site-level motion: scroll engine choice, page transitions, pin/scrub sequencing across a page or Astro route (design stack) | | `/route` | model-router mod: show or set the main-loop route (show, clear, off, on, reload, pending, ask on\|off, , model=… effort=…, switch on\|off, classify on\|off, verbose on\|off: transitions only) | -> This table lists personal skills. Gstack skills (investigate, review, retro, -> office-hours, cso…) and marketplace plugins add many more — run -> `/skills-perso` to list your hand-written skills, or browse `skills/`. +> This table lists personal skills. `/seo` and `/geo` (pack-seo), `/web-validate` +> (pack-web-validate) and `/site-motion` (pack-design) live in packs: a profile that +> leaves the pack off hides them (`/profile current`). Gstack skills (investigate, +> review, retro, office-hours, cso…) and marketplace plugins add many more; run +> `/skills-perso` to list your hand-written skills, or browse `skills/` and +> `skills/pack-*/skills/`. --- @@ -380,13 +383,12 @@ npm i -g @21st-dev/cli `make plugin` does both (Step 8.7 installs the CLI, then offers the login in an interactive terminal) and installs the skill pack that drives it: -`21st-ui-build`, `-ui-explore`, `-ui-review`, `-cli-use`, `-ai`, plus the two -publishing skills `-registry` and `-design-sync`. Of the five design skills, `21st-ui-build` and -`21st-cli-use` follow the active profile: on under `full`, the default profile, and under `design`, -`web` and `web-full`. The other three, `-ui-explore`, `-ui-review` and -`-ai`, are on under `max` only. The two publishing skills, -`-registry` and `-design-sync`, are in no profile and stay parked until -`bash lib/toggle-external.sh enable 21st` turns on all seven. +`21st-ui-build`, `-ui-explore`, `-ui-review`, `-cli-use`, `-ai`, plus the +publishing skills `-registry`, `-design-sync` and `-video`. `21st-ui-build` +and `21st-cli-use` sit in pack-design (on under `full`, `design` and +`web`). `-ui-explore`, `-ui-review` and `-ai` sit in pack-extras (on +under `max`, or after `bash ~/.claude/lib/profile.sh enable extras` in the project). `-registry`, +`-design-sync` and `-video` stay unlinked in `skills-external/`. The pack is machine-owned and gitignored. It cannot be installed the way upstream documents it (`21st install-skill`, i.e. `21st skills install @@ -394,7 +396,7 @@ upstream documents it (`21st install-skill`, i.e. `21st skills install follow a symlink anywhere on that path, while `~/.claude/skills` is itself a symlink to this repo's `skills/`. So the install runs under a throwaway `HOME` and the result is moved into `skills-external/21st-*`, where -`toggle-external.sh` and `profile.sh` symlink it in on demand. +the pack symlinks reach it. The permission gate is now one `autoMode.soft_deny` entry covering the outward-facing verbs (`21st publish*`, `submit`, `edit`, `delete`, @@ -424,27 +426,21 @@ The copies are machine-owned and gitignored. They follow upstream `main`, so a prompt change arrives with no diff to review, and a skill that upstream removes keeps its last local copy. -The pack is off by default and belongs to no profile. It costs nothing until -you ask for it, and no `profile set` touches it: +The pack is off by default and on in `max` only. It costs nothing until +you ask for it: ```bash -bash lib/toggle-external.sh enable higgsfield # media skills -bash lib/toggle-external.sh enable higgsfield-websites # landing-page aid -bash lib/toggle-external.sh disable higgsfield -bash lib/toggle-external.sh disable higgsfield-websites +bash ~/.claude/lib/profile.sh enable higgsfield # from the project, then /reload-plugins +bash ~/.claude/lib/profile.sh disable higgsfield ``` -`higgsfield` links a fixed list of seven media skills: generate, soul-id, -product-photoshoot, brandkit, marketplace-cards, video-explainer and -youtube-thumbnail. The list is `HIGGSFIELD_MEDIA_SKILLS` in -`lib/toggle-external.sh`. A skill that upstream adds later is synced, and -every `enable higgsfield` names it, the pack being on or not. It stays -unlinked until it is added to the list. +The pack (`skills/pack-higgsfield/skills/`) holds the 8 `higgsfield-*` +skills. -`higgsfield-websites` is kept apart. It helps with landing pages inside the +`higgsfield-websites` is one of them. It helps with landing pages inside the design stack (assets, references), and `higgsfield website -create|deploy|publish` stays unused. Claude enables either toggle itself on -an explicit ask (Skill routing in `CLAUDE.global.md`) and checks the price +create|deploy|publish` stays unused. Claude runs `bash ~/.claude/lib/profile.sh enable higgsfield` on +a named media ask, then `/reload-plugins` (Skill routing in `CLAUDE.global.md`) and checks the price with `higgsfield generate cost` before a paid run. The skills are cloned, not installed with `npx skills add`: that installer @@ -484,14 +480,13 @@ make scan-secrets [repos="…"] # gitleaks sweep of this repo's history and ~/. make help # list make targets make onboard # onboard an existing project (run from its dir) make seo-connect # connect a Google account for /seo FULL (OAuth consent) -make profile cmd="set X" # activate a skill profile (web/seo/web-full/full/max/backend/design/dev/qa/audit/minimal) +make profile cmd="set X" dir=/path/to/project # activate a skill profile (web/seo/full/max/design/dev/qa/audit/minimal) make profile-list # list skill profiles -make profile-current # show the active profile (full when none selected) -make profile-reset # go to the default profile (full) +make profile-current dir=/path/to/project # effective profile of this project and conversation make new-skill name=myskill # scaffold agent + skill files ``` -`doctor.sh` checks: symlinks, GStack submodule, vendored skills (curl-pinned externals in `plugins.lock.json` + `link.sh`'s `EXTERNAL_SKILLS`, per the active profile), Playwright browser cache, prerequisites (git, Node, Cargo, Python, Claude Code), plugins, permissions, token budget, config consistency, git hooks (global core.hooksPath + generated githooks/), mods (loading link and `@skills-dir` state), scratchpad (TMPDIR quota), Higgsfield CLI and session, seo-data layer, auto memory (`autoMemoryEnabled` false in `settings.json`, leftover files under `~/.claude/projects/*/memory/`). +`doctor.sh` checks: symlinks, GStack submodule, vendored skills (curl-pinned externals in `plugins.lock.json` + `link.sh`'s `EXTERNAL_SKILLS`), packs (census), profiles, Playwright browser cache, prerequisites (git, Node, Cargo, Python, Claude Code), plugins, permissions, token budget, config consistency, git hooks (global core.hooksPath + generated githooks/), mods (loading link and `@skills-dir` state), scratchpad (TMPDIR quota), Higgsfield CLI and session, seo-data layer, auto memory (`autoMemoryEnabled` false in `settings.json`, leftover files under `~/.claude/projects/*/memory/`). --- diff --git a/USAGE.md b/USAGE.md index ed58ce2..97f6a9c 100644 --- a/USAGE.md +++ b/USAGE.md @@ -123,7 +123,7 @@ Tu veux... | Comprendre un changement pas suivi | `/explain-diff` | | Auditer garde-fous (RLS, consentement, fonctions, mots de passe, injection SQL, fuites navigateur) puis corriger | `/guardrails` | | Sonder le projet en direct (lecture seule, cible à toi) | `/guardrails --live ` | -| Changer profil skills | `/profile` | +| Changer le profil de packs du projet (`set`), ou l'état effectif (`current`) | `/profile` | | Audit/polish design (anti-slop) | `/impeccable` | | Sweep groupé tous axes (nettoyage + sécu + reconcile + doc) | `/tour` | | Rien ne marche | `make doctor` (terminal) | @@ -171,10 +171,12 @@ Tu veux... | `/impeccable` | Audit/polish design + détecteur anti-slop déterministe | 23 verbes ; `npx impeccable detect` (exit 0/2) | | `/tour` | Sweep groupé sur un ou plusieurs projets | Sécu + nettoyage + reconcile + doc, boucle jusqu'à un pass propre | | `/route` | Voir ou fixer la route du mod model-router | show / clear / off / on / reload / pending / ask on\|off / / model=… effort=… / switch on\|off / classify on\|off (classifieur de prompt) / verbose on\|off (transitions seules) | -| `/profile` | Changer le profil de skills | web / seo / web-full / full / max / backend / design / dev / qa / audit / minimal | +| `/profile` | Changer le profil de packs du projet (`set`), ou l'état effectif (`current`) | Profils dans `lib/profiles/*.json`, packs dans `skills/pack-*/` | -> Cette table couvre les skills personnels principaux. Les plugins (gstack, -> pr-review-toolkit…) et marketplaces externes en ajoutent beaucoup d'autres — +> Cette table couvre les skills personnels principaux. `/seo` et `/geo` (pack-seo) +> et `/web-validate` (pack-web-validate) vivent dans des packs : un profil qui laisse +> le pack éteint les masque (`/profile current`). Les plugins (gstack, +> pr-review-toolkit…) et marketplaces externes en ajoutent beaucoup d'autres ; > `/skills-perso` liste tes skills personnels. --- @@ -214,6 +216,8 @@ Hotfix/quick fix → tout OFF (skills superpowers vendorisés, toujours **GSD v2** n'est pas un plugin Claude Code — c'est un CLI externe. Il ne consomme pas de tokens passifs. Tu le lances dans un terminal séparé avec `gsd`, puis `/gsd auto` pour le mode autonome. +**Profils et packs.** Un profil se règle par projet (`/profile set web` puis `/reload-plugins`) ou par conversation (`cc web`, la conversation est figée: relance-la pour changer). Neuf profils: `full`, `max`, `minimal`, `dev`, `design`, `web`, `seo`, `qa`, `audit`. Sans profil, c'est `full`. Un `--settings` édité en cours de session reste sans effet. `cc x web` sur un projet en `dev` garde les connecteurs higgsfield refusés (union); `set web` dans le projet les rend. `cc` est une fonction de `lib/cc.sh`, à sourcer depuis `~/.bashrc` (`[ -f "$HOME/.claude/lib/cc.sh" ] && . "$HOME/.claude/lib/cc.sh"`) ; `make doctor` le signale tant qu'elle manque. + --- ## Patterns de workflow diff --git a/agents/client-handover-writer.md b/agents/client-handover-writer.md index 7d7df18..b4d84ce 100644 --- a/agents/client-handover-writer.md +++ b/agents/client-handover-writer.md @@ -269,14 +269,14 @@ For web projects, dispatch in **a single message with two parallel Agent calls** | Audit (web) | Subagent | Prompt template | |---------------|-------------------|-----------------| -| SEO + GEO | `general-purpose` | "Read `~/.claude/skills/seo/SKILL.md` and execute it on this project. The /seo skill runs SEO + GEO in parallel and writes a unified report to `.claude/audits/SEO.md`. Run it in conservative mode: apply NOTHING, return the FIX BUNDLE (the handover main loop applies it — see 'Applying the bundle'). At the top of the report, the /seo skill MUST emit two distinct labeled score lines (already specified in its SKILL.md §1): `Score SEO (classique) : X.X / 20` and `Score GEO (IA) : X.X / 20`, plus the weighted global. The handover orchestrator parses SEO and GEO separately, so do not collapse them into a single `Score:` line. Return when the report file is written." | +| SEO + GEO | `general-purpose` | "Read `~/.claude/skills/pack-seo/skills/seo/SKILL.md` and execute it on this project. The /seo skill runs SEO + GEO in parallel and writes a unified report to `.claude/audits/SEO.md`. Run it in conservative mode: apply NOTHING, return the FIX BUNDLE (the handover main loop applies it — see 'Applying the bundle'). At the top of the report, the /seo skill MUST emit two distinct labeled score lines (already specified in its SKILL.md §1): `Score SEO (classique) : X.X / 20` and `Score GEO (IA) : X.X / 20`, plus the weighted global. The handover orchestrator parses SEO and GEO separately, so do not collapse them into a single `Score:` line. Return when the report file is written." | | HARDEN | `general-purpose` | "Read `~/.claude/skills/harden/SKILL.md` and execute it on this project with `--fix` up to READY TO APPLY only: prepare the FIX BUNDLE (security headers, HSTS, CSP, HTTP→HTTPS redirects, canonical, 404 page), apply NOTHING — the handover main loop gates and applies it (see 'Applying the bundle'). Write report to `.claude/audits/HARDEN.md` with `Score: X/20` (or `X/100`) at the top. Return when the report file is written." | Non-web variant: | Audit (non-web) | Subagent | Prompt template | |-----------------|-------------------|-----------------| -| CSO | `general-purpose` | "Read `~/.claude/skills/cso/SKILL.md` and execute in **daily mode** (8/10 confidence gate). Apply NOTHING: return the fixes as a FIX BUNDLE (gitignore additions and placeholder swaps tagged AUTO, dependency upgrades tagged GATED — the handover main loop applies AUTO and gates the rest, see 'Applying the bundle'). Write report to `.claude/audits/CSO.md` with `Score: X/20` (or `X/100`) at the top." | +| CSO | `general-purpose` | "Read `~/.claude/skills/pack-gstack-dev/skills/cso/SKILL.md` and execute in **daily mode** (8/10 confidence gate). Apply NOTHING: return the fixes as a FIX BUNDLE (gitignore additions and placeholder swaps tagged AUTO, dependency upgrades tagged GATED — the handover main loop applies AUTO and gates the rest, see 'Applying the bundle'). Write report to `.claude/audits/CSO.md` with `Score: X/20` (or `X/100`) at the top." | Wait for both subagents to complete (parallel return). @@ -426,7 +426,7 @@ for CSO) in the format Send to `general-purpose` subagent (`model: "fable"`, `effort="high"`): -> Read `~/.claude/skills/seo/SKILL.md` and re-run it on this project in +> Read `~/.claude/skills/pack-seo/skills/seo/SKILL.md` and re-run it on this project in > **conservative (audit-only) intervention mode**: re-score and leave both > FIX BUNDLEs in `.claude/audits/SEO.md` ready-to-apply. Apply NOTHING and > ask the user NOTHING — the handover main loop is the dispatcher: it @@ -470,7 +470,7 @@ Send to `general-purpose` subagent (`model: "fable"`, `effort="high"`): Send to `general-purpose` subagent (`model: "fable"`, `effort="high"`): -> Read `~/.claude/skills/cso/SKILL.md` and re-run it in **daily mode**. +> Read `~/.claude/skills/pack-gstack-dev/skills/cso/SKILL.md` and re-run it in **daily mode**. > Previous score: **``/20** — below threshold. > Iteration `` of ``. Apply NOTHING: return the fixes as > a FIX BUNDLE in `.claude/audits/CSO.md` — gitignore additions and secret @@ -679,7 +679,7 @@ VALIDATE as not-applicable rather than failed). Dispatch `general-purpose` subagent (`model: "fable"`, `effort="high"`): -> Read `~/.claude/skills/web-validate/SKILL.md` and execute against the +> Read `~/.claude/skills/pack-web-validate/skills/web-validate/SKILL.md` and execute against the > deployed URL: ``. Audit W3C HTML validity (validator.nu), > W3C CSS validity (jigsaw.w3.org), WCAG 2.1 a11y (axe-core, pa11y). > Apply NOTHING (the client controls deploy; the handover main loop applies diff --git a/agents/plugin-advisor.md b/agents/plugin-advisor.md index 4e1aa2e..053a9df 100644 --- a/agents/plugin-advisor.md +++ b/agents/plugin-advisor.md @@ -19,7 +19,7 @@ Detection is NOT your job (plugin-probe did it); applying is NOT your job ## INPUT — PROBE REPORT (ground truth, from plugin-probe) The dispatcher passes `REQUEST` (the project description, verbatim) and the -full `PROBE REPORT` (fields: PLUGINS, EXTERNAL, PROFILE, CLIS, MANIFESTS, +full `PROBE REPORT` (fields: PROFILE, PLUGINS, CLIS, MANIFESTS, FRAMEWORK-DEPS, TSX-JSX-COUNT, DOCKER-COUNT, ANIM, MONOREPO, EMBEDDED, CHECKPOINT). Treat it as ground truth — never re-detect, never invent a field. PROBE REPORT missing or a field absent → emit @@ -164,7 +164,7 @@ When the plugin-advisor detects a `simple` or `hotfix` signal, suggest the appro **Escalation path:** `/hotfix` → `/bugfix` → `/ship-feature` (bugs), `/feat` → `/ship-feature` (features). Each skill documents when to escalate to the next level. -**Design gate:** `/feat`, `/hotfix`, and `/bugfix` include a lightweight design gate (`lib/design-gate.md`) that auto-detects UI/style signals and, if the design toolchain is incomplete, points the user at `/profile design`. This covers the gap where lightweight skills previously had no plugin awareness for design tasks. +**Design gate:** `/feat`, `/hotfix`, and `/bugfix` include a lightweight design gate (`lib/design-gate.md`) that auto-detects UI/style signals and, if the design toolchain is incomplete, points the user at the remedy line it printed. This covers the gap where lightweight skills previously had no plugin awareness for design tasks. --- @@ -219,7 +219,7 @@ RULE: IF "monorepo" signal detected: RULE: IF "frontend" signal OR .tsx/.jsx count > 0: → ui-ux-pro-max ON if "design-system" signal (~400t) - → impeccable ON (external skill, 0t passive — ~/.claude/skills/impeccable) + → impeccable ON (external skill, 0t passive — ~/.claude/skills/pack-design/skills/impeccable) → design-motion-principles ON if anim-lib-installed or description mentions animation/motion (external, 0t passive) RULE: IF "deploy" AND "browser-qa" signals: @@ -271,60 +271,35 @@ RULE: IF `complex-arch` signal (multiple services, event bus, distributed system --- -## TOGGLING EXTERNAL TOOLS +## WRITING A PROFILE OR A PACK -Marketplace plugins toggle via `claude plugin enable|disable @`. -Non-marketplace tools (gstack per-skill symlinks, emil-design-eng, darwin-skill) -toggle via `bash $HOME/.claude/lib/toggle-external.sh enable|disable `. +Everything switches through `lib/profile.sh`, per project, never the user +scope. Emit the exact command; never write files directly. -When a recommendation flips the state of one of those tools, emit the exact -command — never write files directly. - -``` -# Enable gstack for a browser-QA signal: -bash $HOME/.claude/lib/toggle-external.sh enable gstack - -# Disable darwin-skill when passive cost is too high for a hotfix: -bash $HOME/.claude/lib/toggle-external.sh disable darwin-skill -``` - -`higgsfield` / `higgsfield-websites`: never recommended from project signals. -They drive a paid generation service; explicit user ask only (CLAUDE.md -"Skill routing"). - -### Skill profiles (fine-grained partitioning, with plugin + MCP toggle) - -For task-shaped activation (web only, seo only, backend only, design only, -etc.) prefer `lib/profile.sh` over toggling all of gstack at once. Profiles -activate a curated subset of skills + plugins + MCPs and disable the rest of -gstack + managed plugins — sessions stay focused and passive token cost drops. - -`profile set ` actually toggles plugins (`claude plugin enable|disable`) -and external skill packs (delegates to `lib/toggle-external.sh`) — not just -advisory. No MCP server is auto-toggled today. Always-on plugins (`security-guidance`) -and the vendored superpowers skills are never toggled by a profile. Managed -plugins that `set` may toggle: -`ui-ux-pro-max@ui-ux-pro-max-skill`, `plugin-dev@claude-code-plugins`, -`pr-review-toolkit@claude-code-plugins`. Other plugins are never auto-toggled. - -When the project signal matches one of the canonical profiles, recommend the -matching `profile set` command: - -| Signal | Recommended profile | Command | +| Signal | Profile | Command | |---|---|---| -| `frontend` public website (no backend, no SEO focus) | `web` | `bash $HOME/.claude/lib/profile.sh set web` | -| audit-only: SEO + GEO + W3C + WCAG | `seo` | `bash $HOME/.claude/lib/profile.sh set seo` | -| public website end-to-end (build + audit) | `web-full` | `bash $HOME/.claude/lib/profile.sh set web-full` | -| backend / API / system / library (no UI, no SEO) | `backend` | `bash $HOME/.claude/lib/profile.sh set backend` | -| `design-system` (heavy UI work, no dev) | `design` | `bash $HOME/.claude/lib/profile.sh set design` | -| `simple` / hotfix / typical dev session | `dev` | `bash $HOME/.claude/lib/profile.sh set dev` | -| `browser-qa` (e2e tests, no design work) | `qa` | `bash $HOME/.claude/lib/profile.sh set qa` | -| comprehensive audit (security + SEO + perf) | `audit` | `bash $HOME/.claude/lib/profile.sh set audit` | -| narrow session, minimal noise | `minimal` | `bash $HOME/.claude/lib/profile.sh set minimal` | +| public website, no SEO focus | `web` | `bash $HOME/.claude/lib/profile.sh set web` | +| audit-only: SEO + GEO + W3C + WCAG | `seo` | `… set seo` | +| public website end-to-end | `full` | `… set full` | +| backend / API / library | `dev` | `… set dev` | +| heavy UI, no dev | `design` | `… set design` | +| typical dev session | `dev` | `… set dev` | +| browser QA only | `qa` | `… set qa` | +| comprehensive audit | `audit` | `… set audit` | +| narrow session | `minimal` | `… set minimal` | +| one pack on top | — | `bash $HOME/.claude/lib/profile.sh enable ` | -To go back to the default profile: `bash $HOME/.claude/lib/profile.sh reset` -(= `set full`: enables full's list, parks non-listed gstack/managed items, -toggles the managed plugins like any `set`). +`` is one of design, scroll3d, seo, web-validate, gstack-dev, +gstack-browser, gstack-design, higgsfield, extras. + +Read `PROFILE :` first: when it says `source=flag`, a pack it turns off +cannot be enabled in this conversation; recommend `relaunch: cc +` instead of an `enable`. No profile = `full` (manifest defaults); +`unset` returns to it. Every write needs `/reload-plugins` to load the +packs; connectors and model apply to the next session. + +`higgsfield`: never recommended from project signals. It drives a paid +generation service; explicit user ask only (CLAUDE.md "Skill routing"). ## BLOCK if diff --git a/agents/plugin-probe.md b/agents/plugin-probe.md index 9f427be..1a4b50f 100644 --- a/agents/plugin-probe.md +++ b/agents/plugin-probe.md @@ -15,17 +15,13 @@ Facts only — no signals, no recommendations, no complexity scoring. ## PROBES (run all; a failing probe reports its fallback string, never aborts) ```bash -# Claude Code plugins +# Packs, managed plugins, connectors, model: the effective state of THIS +# 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) claude plugin list 2>/dev/null || echo "plugin-list-unavailable" -# External (non-marketplace) tools status — gstack, emil-design-eng, -# darwin-skill. Managed by lib/toggle-external.sh since -# `claude plugin enable|disable` does not apply to them. -bash "$HOME/.claude/lib/toggle-external.sh" list 2>/dev/null || echo "toggle-external-unavailable" - -# Active skill profile — design / dev / qa / audit / minimal / custom. -bash "$HOME/.claude/lib/profile.sh" current 2>/dev/null || echo "profile-unavailable" - # Context7 CLI command -v ctx7 &>/dev/null && ctx7 --version 2>/dev/null | head -1 || echo "ctx7-not-installed" @@ -60,7 +56,7 @@ ls src/*.c 2>/dev/null | head -3 ls package.json Cargo.toml go.mod pubspec.yaml setup.py pyproject.toml 2>/dev/null | head -1 # counterindicators (ecosystem present = not bare embedded) # Checkpoint inputs (consumed by lib/plugin-gate.md's validation checkpoint) -[ -x "$HOME/.claude/lib/toggle-external.sh" ] && echo "toggle-script: executable" || echo "toggle-script: UNAVAILABLE" +[ -f "$HOME/.claude/lib/profile.sh" ] && echo "profile-sh: available" || echo "profile-sh: UNAVAILABLE" ls "$HOME/.claude/plugins/cache" 2>/dev/null | head -10 ls "$HOME/.agents/skills" 2>/dev/null | head -10 ``` @@ -69,9 +65,8 @@ ls "$HOME/.agents/skills" 2>/dev/null | head -10 ``` PROBE REPORT -PLUGINS : -EXTERNAL : -PROFILE : +PROFILE : +PLUGINS : CLIS : ctx7= gsd= rtk= MANIFESTS : FRAMEWORK-DEPS: @@ -80,7 +75,7 @@ DOCKER-COUNT : ANIM : eligibility= installed= MONOREPO : dirs= configs= parent= EMBEDDED : cmake-pio= linker= makefile= src-c= ecosystem= -CHECKPOINT : toggle-script= plugin-dirs= +CHECKPOINT : profile-sh= plugin-dirs= ``` ## RULES diff --git a/doctor.sh b/doctor.sh index 12cc1da..b95732a 100644 --- a/doctor.sh +++ b/doctor.sh @@ -111,18 +111,16 @@ 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" +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) +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 "" @@ -132,29 +130,31 @@ 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 [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 [ -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 "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" +else warn "settings.json model is $_m (tracked default is opus)"; fi +unset _ep_head _ep_work _m echo "" @@ -587,7 +587,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 +643,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")") diff --git a/hooks/session-start.sh b/hooks/session-start.sh index 9cbcdac..79a0b3e 100644 --- a/hooks/session-start.sh +++ b/hooks/session-start.sh @@ -64,6 +64,11 @@ 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 +93,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 +305,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 +325,4 @@ EOF fi unset _gx_root echo "" -unset TOKEN_WARN +unset TOKEN_WARN PROFILE_PLAIN diff --git a/hooks/statusline.sh b/hooks/statusline.sh index 52200b3..fb5ad28 100755 --- a/hooks/statusline.sh +++ b/hooks/statusline.sh @@ -6,6 +6,8 @@ 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 +22,15 @@ 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 /.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="?" +_src="$(sed -n 's/^source=//p' <<<"$_plain" | head -1)" +[ "$_src" = 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 diff --git a/install-plugins.sh b/install-plugins.sh index 9a6b85d..8736fee 100644 --- a/install-plugins.sh +++ b/install-plugins.sh @@ -341,35 +341,30 @@ 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" info "Running GStack setup..." _gstack_setup_ok=0 if [ -x "$GSTACK_DIR/setup" ]; then - if (cd "$GSTACK_DIR" && ./setup); then - _gstack_setup_ok=1 + if [ -d "$HOME/.claude/skills/gstack" ] && [ ! -L "$HOME/.claude/skills/gstack" ]; then + if (cd "$GSTACK_DIR" && ./setup); then + _gstack_setup_ok=1 + else + warn "GStack ./setup failed — check output above" + fi else - warn "GStack ./setup failed — check output above" + warn "gstack: ~/.claude/skills/gstack is not the helper tree yet — run 'make link' first, then 'make plugin' (setup would write skill dirs into skills/)" fi else warn "GStack ./setup not found or not executable — skipping" fi - # Default policy: gstack is installed but DISABLED — enable on demand - # via `bash lib/toggle-external.sh enable gstack`. Rationale: gstack - # ships ~40 skills that all load into context; keep them off until - # the user signals a project where they matter (browser QA, deploy). - if [ -x "$REPO/lib/toggle-external.sh" ] \ - && [ "$(bash "$REPO/lib/toggle-external.sh" status gstack 2>/dev/null)" = "enabled" ]; then - info "Disabling gstack by default (no context cost until enabled)..." - bash "$REPO/lib/toggle-external.sh" disable gstack >/dev/null - fi # Success message gated on the real setup outcome — an unconditional ok # after a `|| warn` reads as success even when setup failed (LRN-071 class). if [ "$_gstack_setup_ok" -eq 1 ]; then - ok "GStack ready (disabled by default — enable: bash lib/toggle-external.sh enable gstack)" + ok "GStack ready (packs pack-gstack-dev / -browser / -design; profile.sh set )" else warn "GStack NOT ready — ./setup did not complete (see warnings above)" fi @@ -749,10 +744,10 @@ else fi fi # Symlink handled by link.sh -if [ -L "$HOME/.claude/skills/emil-design-eng" ]; then - ok "emil-design-eng symlink OK" +if [ -L "$HOME/.claude/skills/pack-design/skills/emil-design-eng" ]; then + ok "emil-design-eng linked by pack-design" else - info "Symlinking — will be created by link.sh" + info "pack-design link not present yet (git checkout)" fi echo "" @@ -774,10 +769,10 @@ else warn "frontend-design: anthropic-agent-skills plugin not cached — install via: claude plugin install example-skills@anthropic-agent-skills" fi fi -if [ -L "$HOME/.claude/skills/frontend-design" ]; then - ok "frontend-design symlink OK" +if [ -L "$HOME/.claude/skills/pack-design/skills/frontend-design" ]; then + ok "frontend-design linked by pack-design" else - info "Symlinking — will be created by link.sh" + info "pack-design link not present yet (git checkout)" fi echo "" @@ -790,10 +785,10 @@ if [ -f "$DMP_DIR/SKILL.md" ]; then else warn "design-motion-principles: not installed — clone from https://github.com/kylezantos/design-motion-principles" fi -if [ -L "$HOME/.claude/skills/design-motion-principles" ]; then - ok "design-motion-principles symlink OK" +if [ -L "$HOME/.claude/skills/pack-design/skills/design-motion-principles" ]; then + ok "design-motion-principles linked by pack-design" else - info "Symlinking — will be created by link.sh" + info "pack-design link not present yet (git checkout)" fi echo "" @@ -801,11 +796,12 @@ echo "" # 61 deterministic detector rules (`impeccable detect`, exit 0/2), the # /impeccable skill (23 verbs) and 4 `impeccable-*` subagents. # -# GLOBAL scope, no staging: the installer writes ~/.claude/skills/impeccable/ -# (skill + its self-contained engine binary) and ~/.claude/agents/ +# GLOBAL scope, no staging: the installer writes impeccable/ into skills/ through +# the ~/.claude/skills symlink (skill + its self-contained engine binary) and ~/.claude/agents/ # impeccable-*.md, and both of those are symlinks into this repo — so the # global install IS the repo install. Machine-owned and gitignored on both -# sides. `--scope=project` was wrong twice over: it writes /.claude/, +# sides. The skill is then moved to skills-external/impeccable (pack-design +# links it). `--scope=project` was wrong twice over: it writes /.claude/, # which serves only the directory it ran in, and the staged `mv` that # followed it moved the skill alone, silently dropping the subagents. # @@ -816,8 +812,14 @@ echo "" # @latest and says, loudly, that the lock needs bumping. echo "── Step 8d: Impeccable — design detector, skill + agents ──" echo "" -IMP_SKILL_DIR="$HOME/.claude/skills/impeccable" -IMP_PARKED="$REPO/skills-disabled/impeccable" +IMP_SKILL_DIR="$REPO/skills/impeccable" +IMP_HOME="$REPO/skills-external/impeccable" +# A real skills/impeccable (older install) is adopted, never removed. +if [ ! -e "$IMP_HOME" ] && [ -f "$IMP_SKILL_DIR/SKILL.md" ] \ + && [ ! -L "$IMP_SKILL_DIR" ]; then + mkdir -p "$REPO/skills-external" + (cd "$REPO" && mv skills/impeccable skills-external/impeccable) +fi IMP_VER=$(pinned_version "impeccable") NODE_MAJOR=$(node -v 2>/dev/null | sed 's/^v//' | cut -d. -f1) @@ -856,17 +858,12 @@ if [ "$IMP_READY" != true ]; then warn "impeccable: ~/.claude/skills and ~/.claude/agents are not this repo's symlinks yet" warn " → run 'make link' first, then re-run 'make plugin'" elif [ -z "${NODE_MAJOR:-}" ] || [ "$NODE_MAJOR" -lt 24 ]; then - if [ -f "$IMP_SKILL_DIR/SKILL.md" ] || [ -f "$IMP_PARKED/SKILL.md" ]; then + if [ -f "$IMP_HOME/SKILL.md" ]; then ok "impeccable already present (update skipped — needs Node >= 24, found ${NODE_MAJOR:-none})" else warn "impeccable: needs Node >= 24 (found ${NODE_MAJOR:-none}) — skipped. Bump Node, then: make plugin" fi else - # A profile may hold impeccable parked in skills-disabled/. Install writes - # to the live slot, so remember the state and put the fresh copy back where - # it was — otherwise `make plugin` silently re-enables a disabled skill. - IMP_WAS_PARKED=false - [ -d "$IMP_PARKED" ] && IMP_WAS_PARKED=true IMP_USED="" if [ "$IMP_VER" != "latest" ]; then info "Installing impeccable ${IMP_VER} (pinned in plugins.lock.json, global scope)..." @@ -893,14 +890,13 @@ else if [ "$IMP_AGENTS" -eq 0 ]; then warn "no impeccable-* agent landed in agents/ — the skill's finish/document verbs dispatch to them" fi - if [ "$IMP_WAS_PARKED" = true ]; then - rm -rf "${IMP_PARKED:?}" - mv "$IMP_SKILL_DIR" "$IMP_PARKED" - info "impeccable was parked by a profile — refreshed copy returned to skills-disabled/" - fi + # The CLI writes into skills/impeccable (through the ~/.claude/skills + # symlink); the copy lives in skills-external/, linked by pack-design. + [ ! -L "$IMP_SKILL_DIR" ] && cd "$REPO" && rm -rf skills-external/impeccable \ + && mv "$IMP_SKILL_DIR" skills-external/impeccable info "Per-project step, in the agent chat of each frontend project: /impeccable init" info " (writes PRODUCT.md — the design context every impeccable verb reads)" - elif [ -f "$IMP_SKILL_DIR/SKILL.md" ] || [ -f "$IMP_PARKED/SKILL.md" ]; then + elif [ -f "$IMP_HOME/SKILL.md" ]; then ok "impeccable already present (install failed: ${IMP_FAIL:-no SKILL.md written} — existing copy kept)" else warn "impeccable install failed (${IMP_FAIL:-no SKILL.md written}) — run manually: npx impeccable skills install -y --providers=claude --scope=global --no-hooks" @@ -997,11 +993,10 @@ echo "" # credits. Its skills come from github.com/higgsfield-ai/skills, cloned by # lib/higgsfield-skills.sh into skills-external/higgsfield-* (gitignored). # -# Nothing is linked here. The pack is OFF by default and belongs to no -# profile: `lib/toggle-external.sh enable higgsfield` turns the media skills -# on, `enable higgsfield-websites` the landing-page aid. Keeping it out of -# link.sh and of every profile is what stops a re-run from re-enabling it -# (BDR-093). +# Nothing is linked here. pack-higgsfield is OFF by default and ON in `max` +# only; `bash lib/profile.sh enable higgsfield` turns it on elsewhere. Its +# 8 skills include `higgsfield-websites`. Keeping it out of link.sh is what +# stops a re-run from re-enabling it (BDR-093). echo "── Step 8.6: Higgsfield CLI + skill pack ───────────────────" echo "" # shellcheck source=lib/higgsfield-skills.sh disable=SC1091 @@ -1054,7 +1049,7 @@ if higgsfield_cli_ok; then else info "Not signed in. Generation needs: higgsfield auth login" fi - info "Pack is off by default — enable: bash lib/toggle-external.sh enable higgsfield" + info "Pack is off by default — enable: bash lib/profile.sh enable higgsfield, then /reload-plugins" fi echo "" @@ -1071,13 +1066,8 @@ echo "" # /.claude/skills// and REFUSES to follow a symlink anywhere on # that path — and ~/.claude/skills IS a symlink to this repo's skills/. So # install under a staged HOME, then move each skill into skills-external/ -# (gitignored), where toggle-external.sh / profile.sh symlink it in. +# (gitignored); skills/pack-design and skills/pack-extras link it. # -# The pack's state is governed by profiles, not by this step: Step 11 -# applies the default profile (`full`), which links the five design skills -# in; the two publishing skills (21st-registry, 21st-design-sync) stay on -# demand — no profile lists them, so they are never auto-linked. A re-run -# must never re-park what the selected profile or the user already enabled. echo "── Step 8.7: 21st.dev CLI + skill pack ─────────────────────" echo "" if command -v 21st &>/dev/null; then @@ -1150,9 +1140,6 @@ if command -v 21st &>/dev/null; then fi fi -# The pack's state is governed by profiles (Step 11), not parked here: a -# re-run must never re-park what the selected profile or the user enabled. -# See the Step 11 banner for how the default profile applies. echo "" # ============================================================ @@ -1257,40 +1244,6 @@ else fi echo "" -# ============================================================ -# STEP 11 — DEFAULT PROFILE -# ============================================================ -# The profile decides which skills / externals / plugins are on. No -# selection yet (.active-profile absent, empty or legacy "none" — same -# rule as lib/profile.sh active_profile()) → apply the default via -# `profile.sh reset`. An existing selection is re-applied (`set`). Plugin legs -# are install-immutable (the EXIT guard restores settings.json, BDR-028; -# the committed enabledPlugins already match the default profile), so -# only the skill / external legs matter here. -echo "── Step 11: Default profile ────────────────────────────────" -echo "" -if [ -f "$REPO/lib/profile.sh" ]; then - SEL="$(head -n1 "$REPO/.active-profile" 2>/dev/null | tr -d '[:space:]' || true)" - case "$SEL" in - ""|none) - info "No profile selected — applying the default profile (bash lib/profile.sh reset)..." - bash "$REPO/lib/profile.sh" reset \ - || warn "default profile not applied — run: bash lib/profile.sh reset" - ;; - *) - # Steps 2 (gstack parked) and 10 (link.sh re-links the design - # externals) rewrite skill state on every run: re-apply the - # selection so its state comes back, label unchanged. - info "Profile kept: $SEL — re-applying it (bash lib/profile.sh set $SEL)..." - bash "$REPO/lib/profile.sh" set "$SEL" \ - || warn "profile $SEL not re-applied — run: bash lib/profile.sh set $SEL" - ;; - esac -else - warn "lib/profile.sh not found — skipping the default profile" -fi -echo "" - # ============================================================ # SUMMARY # ============================================================ @@ -1305,7 +1258,7 @@ echo " ✅ rtk — token compression hook (0 tokens)" echo " ✅ superpowers skills — 7 vendored (brainstorming, writing-plans, subagent-driven-development, test-driven-development, requesting-code-review, using-git-worktrees, writing-skills), pinned v6.4.1, curl → symlink, no plugin, no session injection" echo "" echo " TOGGLE (plugin state = settings.json enabledPlugins; skills/CLIs = profiles):" -echo " 🔄 gstack — disabled by default (toggle: lib/toggle-external.sh enable gstack)" +echo " 🔄 gstack — packs pack-gstack-dev / -browser / -design (bash lib/profile.sh set | enable , then /reload-plugins)" echo " 🔄 gsd v2 — standalone CLI 'gsd' (gsd-pi, not a Claude Code plugin)" echo " 🔄 pr-review-toolkit — /review-pr + 6 PR agents (~2.2k tokens when enabled) [claude-code-plugins]" echo " 🔄 ui-ux-pro-max — user scope (~780 tokens when enabled)" @@ -1318,14 +1271,14 @@ echo " 🔄 design-motion-principles — motion/animation design, 3-designer echo " 🔄 agent-skills trio — observability-and-instrumentation, deprecation-and-migration, ci-cd-and-automation (curl → symlink, pinned commit)" echo " 🔄 mengto scroll skills — scroll-world-storytelling, build-threejs-scroll-worlds, scroll-scrubbed-visual-sequence, scroll-scrubbed-word-reveal, scroll-progress-timeline (curl → symlink, pinned commit)" echo " 🔄 darwin-skill — autonomous skill optimizer (npx skills, ~/.agents/skills/)" -echo " 🔄 21st skill pack — 21st.dev CLI skills; design ones follow the profile (full by default), publishing ones on demand (toggle: lib/toggle-external.sh enable 21st)" -echo " 🔄 higgsfield pack — Higgsfield CLI media skills (image, video, audio, brand), OFF by default (toggle: lib/toggle-external.sh enable higgsfield; landing-page aid: enable higgsfield-websites)" +echo " 🔄 21st skill pack — 21st.dev CLI skills; linked by skills/pack-design and skills/pack-extras (bash lib/profile.sh set | enable , then /reload-plugins)" +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: \`higgsfield-websites\` ships in pack-higgsfield)" echo "" echo " All plugins installed at: user scope (~/.claude/plugins/)" -echo " GStack skills symlinked individually into ~/.claude/skills/ (→ submodule)" -echo " Emil Design Eng at: ~/.claude/skills/emil-design-eng/ (symlink → skills-external)" -echo " Frontend Design at: ~/.claude/skills/frontend-design/ (symlink → skills-external)" -echo " Design Motion Principles at: ~/.claude/skills/design-motion-principles/ (symlink → skills-external)" +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)" echo " Agent Skills trio at: ~/.claude/skills/{observability-and-instrumentation,deprecation-and-migration,ci-cd-and-automation}/ (symlink → skills-external)" echo " Mengto scroll skills at: ~/.claude/skills/{scroll-world-storytelling,build-threejs-scroll-worlds,scroll-scrubbed-visual-sequence,scroll-scrubbed-word-reveal,scroll-progress-timeline}/ (symlink → skills-external)" echo " Superpowers skills at: ~/.claude/skills/{brainstorming,writing-plans,subagent-driven-development,test-driven-development,requesting-code-review,using-git-worktrees,writing-skills}/ (symlink → skills-external)" diff --git a/lib/cc.sh b/lib/cc.sh new file mode 100644 index 0000000..3ce9770 --- /dev/null +++ b/lib/cc.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +# ============================================================ +# lib/cc.sh — `cc [profile]`: a named dtach session running claude, +# optionally under a per-conversation profile. +# +# Sourced from ~/.bashrc (user step, MIGRATION.md), guarded so a checkout +# without the file does not break the shell: +# [ -f "$HOME/.claude/lib/cc.sh" ] && . "$HOME/.claude/lib/cc.sh" +# The old `dtach_claude()` and `alias cc='dtach_claude'` must go (an alias +# wins over this function and drops the profile argument; doctor warns). +# +# With a profile, claude starts with `--settings lib/profiles/.json` +# and the session exports CLAUDE_PROFILE + CLAUDE_PROFILE_SETTINGS, which +# `profile.sh current` reads (source=flag). That conversation is frozen: +# `/reload-plugins` re-reads neither the flag file nor a local value the +# flag overrides; to change packs, start another `cc `. +# Without a profile: manifest defaults + local settings, as before. +# TMPDIR goes to ~/.cache/claude-tmp either way (BLK-021). +# ============================================================ + +_cc_name_ok() { [[ "$1" =~ ^[a-z0-9][a-z0-9-]*$ ]]; } + +cc() { + local name="${1:-claude-$(date +%H%M%S)}" profile="${2:-}" + local lib="$HOME/.claude/lib" settings="" + _cc_name_ok "$name" \ + || { echo "cc: invalid name '$name' (a-z 0-9 -)" >&2; return 2; } + if [ -n "$profile" ]; then + _cc_name_ok "$profile" \ + || { echo "cc: invalid profile '$profile' (a-z 0-9 -)" >&2; return 2; } + settings="$lib/profiles/$profile.json" + if [ ! -f "$settings" ]; then + echo "cc: unknown profile '$profile'. Known:" >&2 + bash "$lib/profile.sh" list >&2 + return 2 + fi + fi + mkdir -p "$HOME/.cache/claude-tmp" "$HOME/.dtach" + # 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 \ + --unit="cc-${name}" \ + dtach -c "$HOME/.dtach/${name}" -e '^\' \ + bash -c 'set -a; [ -f "$HOME/.claude/.env" ] && . "$HOME/.claude/.env" + set +a + if [ -n "$CLAUDE_PROFILE_SETTINGS" ]; then + exec claude --settings "$CLAUDE_PROFILE_SETTINGS" + fi + exec claude' +} diff --git a/lib/design-gate.md b/lib/design-gate.md index 40d3b0a..cd22927 100644 --- a/lib/design-gate.md +++ b/lib/design-gate.md @@ -25,9 +25,10 @@ Check BOTH the task description AND the filesystem: ## DECISION -Source of truth for activation is the **profile system** — never an atomic -per-tool toggle. The gate's whole job: confirm the design toolchain is active, -and if not, point at ONE command — `/profile design`. +Source of truth is `profile.sh current --plain` (packs and managed plugins of +THIS project and conversation) — never an atomic per-tool toggle. The gate's +whole job: confirm the design toolchain is active, and if not, print ONE +remedy line (see §3). ### 1. Tier — does the gate even apply? @@ -37,52 +38,48 @@ and if not, point at ONE command — `/profile design`. - In doubt (trivial tweak vs real UI change) → do NOT silently skip: ask the user, or default to the Build tier. -Tier does NOT change WHAT gets checked. Every non-trivial design tier draws from -the one `design` profile — so the gate checks that profile's **design-core -tools** (the `# GATE-BLOCK:` allowlist in `design.profile`: impeccable, -ui-ux-pro-max, emil-design-eng, design-motion-principles, design-html, -design-review, design-consultation, the `21st` CLI and `21st-ui-build` — the -canary for the whole 21st skill pack). The profile also bundles -browser/plan/shotgun tooling and graphify for convenience; those never trip the -gate. Motion (`design-motion-principles`) and static-HTML (`design-html`) are -already in the core set — checked regardless; the Design work section -(`rules/web-building.md`) names them as the motion and static tools, not a -separate activation step. +Tier does NOT change WHAT gets checked. Every non-trivial design tier needs +the same required set, declared as `NEEDED=` in `lib/design-tool-gate.sh`: +packs `design` and `gstack-design`, the `ui-ux-pro-max` plugin, and the `21st` +CLI signed in. Other packs and browser/plan tooling never trip the gate. +Motion and static-HTML skills ride inside those packs; the Design work section +(`rules/web-building.md`) names them, not a separate activation step. `site-motion` (personal skill, site-level scroll/page choreography) rides the -same Build chain but isn't on the GATE-BLOCK list: it ships with the repo, -nothing to install or verify. +same Build chain but isn't required: it ships with the repo, nothing to +install or verify. ### 2. State — run the deterministic check bash "$HOME/.claude/lib/design-tool-gate.sh" -It reads the design-core tools (`# GATE-BLOCK:` in `design.profile`) plus their -types (`profile.sh show design --plain`) and checks each on its own channel — -skill symlink, `claude plugin list`, `claude mcp list`, `command -v`. It never -reads `disabledMcpServers` (unreliable for bi-modal servers like context7). -The core set lives in `design.profile`, not in the script or here — single source. +It runs `profile.sh current --plain` and checks the `NEEDED=` entries of the +script (the single source of the required set), then `command -v 21st` and +`21st whoami`. It makes no `claude` call. Exit codes: `0` = ready · `11` = ready-but-unverified (proceed, but surface it) · `10` = incomplete (gate trips) · `12` = sign-in required (21st installed, signed out) · `2` = error. ### 3. Branch on the result - **0 / `READY`** → proceed silently. Toolchain is active. -- **10 / `INCOMPLETE`** → STOP. The script reports up to three groups; relay - them and the remedy to the user: +- **10 / `INCOMPLETE`** → STOP. The script names what is off and prints the + remedy; relay both to the user: - 🎨 DESIGN DETECTED — the design toolchain isn't fully active. - activate with /profile design: - required + manual step: - → run /profile design to activate it, then continue. + design toolchain: INCOMPLETE + off: pack-design plugin:ui-ux-pro-max@ui-ux-pro-max-skill + → run: bash ~/.claude/lib/profile.sh set web + or: bash ~/.claude/lib/profile.sh enable design + or: bash ~/.claude/lib/profile.sh enable ui-ux-pro-max@ui-ux-pro-max-skill + then /reload-plugins - - **activate with /profile design** → skills + the plugin; `/profile design` - turns them on directly. - - **required + manual step** → required tools the profile can't flip silently. - **the `21st` CLI lands here: it TRIPS the gate** (it's required for Build), - it is NOT a silent "optional". `/profile design` symlinks the 21st skills, - but the CLI they shell out to is a global npm install: tell the user to run - `npm i -g @21st-dev/cli` then `21st login` (no API key, no MCP). - - Do NOT hand-activate individual tools. The profile is the unit of activation. + - **source=local or default** → `profile.sh set web`, or one `profile.sh + enable ` per entry listed as off, then `/reload-plugins`. + - **source=flag** (the conversation runs under `claude --settings`, frozen) + → relaunch it with a design profile: `cc web`. + - **the `21st` CLI TRIPS the gate** when absent (required for Build), it is + NOT a silent "optional". It is a global npm install the profile cannot + do: tell the user to run `npm i -g @21st-dev/cli` then `21st login` + (no API key, no MCP). + - Do NOT hand-activate individual tools. Packs are the unit of activation. - **12 / `SIGN-IN REQUIRED`** → STOP. The 21st CLI is installed but `21st whoami` reports signed out. Relay the script's block, then ask the user to run `! 21st login` (the `!` prefix runs it in this session, browser flow, @@ -100,22 +97,20 @@ Exit codes: `0` = ready · `11` = ready-but-unverified (proceed, but surface it) and needs the human. `TWENTYFIRST_TOKEN` is a shell-profile setting followed by a session restart, never an in-session `export` (tool calls don't share a shell, and a secret doesn't belong in the transcript). -- **11 / `READY BUT UNVERIFIED`** → `claude` was unreachable, so the design - plugin (ui-ux-pro-max) could NOT be checked. Do NOT report a plain "ready": - proceed only after telling the user that N tool(s) went unverified and having - them confirm with `claude plugin list`. Fail-visible, not fail-silent. A - `21st (whoami: rc=… …)` entry in this block means the CLI itself could not - answer (a runtime/PATH problem, e.g. node under nvm) — the remedy is the - diagnostic the script prints, never a sign-in prompt; relay its own line. +- **11 / `READY BUT UNVERIFIED`** → `21st whoami` could not answer (a + runtime/PATH problem, e.g. node under nvm). Do NOT report a plain "ready": + proceed only after telling the user, relaying the diagnostic the script + prints (`whoami: rc=… …`). Never a sign-in prompt. Fail-visible, not + fail-silent. ### 4. Animation library — suggest-only (fires only on a real motion signal) Orthogonal to the toolchain check above: §2-3 are about Claude's design TOOLS; this is about the PROJECT's runtime dep. Evaluate it only once the toolchain is resolved and you're actually proceeding with the build (READY, after the user -ran `/profile design`, or after the sign-in re-run returns READY). Never on -the INCOMPLETE stop path — that path has one action only (`/profile -design`); don't stack an optional note on it. +applied the remedy, or after the sign-in re-run returns READY). Never on +the INCOMPLETE stop path — that path has one action only (the remedy +line); don't stack an optional note on it. **Fires only when ALL THREE hold** — drop any one → no suggestion, stay silent: @@ -160,7 +155,7 @@ count: 10 libs incl gsap / react-spring / lottie) kills it the instant any anim lib lands, so only "eligible + pure-CSS + actively declined" ever sees it twice. - **Two "motion"s (agent-facing).** The lib `motion` (npm dep, this step) ≠ the - skill `design-motion-principles` (`# GATE-BLOCK:` core set, §2-3). The + skill `design-motion-principles` (inside the design packs, §2-3). The toolchain check handles the skill; this step handles the lib. Don't conflate them when talking to the user. @@ -173,7 +168,7 @@ context, which is worse than not running it — and nothing else in the process says so, because init has to happen in the agent chat, not in an installer. **Fires when** the project has no `PRODUCT.md` at its root, else stay -silent. impeccable itself is on the `# GATE-BLOCK:` list, so §3 has already +silent. impeccable ships in the required design packs, so §3 has already guaranteed it is installed by the time this runs. Evaluate it on the same path as §4: after the toolchain resolves, never on the @@ -192,25 +187,22 @@ INCOMPLETE stop path. One line, non-blocking: ### Other toolchains -The script defaults to the `design` profile. A task needing another profile's -toolchain passes it: `design-tool-gate.sh `. Scope comes from that -profile's `# GATE-BLOCK:` line (absent → every skill/plugin/mcp entry). The -remedy is always `/profile ` — a profile, never a lone tool. +The script takes no argument: it checks the one design set (`NEEDED=`). A +task needing another toolchain adds its own gate; the remedy stays a pack +or profile, never a lone tool. ## IMPORTANT -- Remedy is ALWAYS a profile (`/profile design`), never an atomic tool toggle — - the profile system is the single source of truth for what's active. -- the `21st` CLI is REQUIRED (it trips the gate) and `/profile design` cannot +- Remedy is ALWAYS the printed line (`profile.sh set web` / `enable ` + + `/reload-plugins`, or `cc web` under a flag), never an atomic + tool toggle; `current --plain` is the single source of what's active. +- the `21st` CLI is REQUIRED (it trips the gate) and no profile can install it — the gate names the two commands; surface them to the user. Signed out → exit 12: ask `! 21st login`, wait, re-run; explicit opt-out only, never a silent skip. -- The design-core set (what trips the gate) is declared in `design.profile` on - the `# GATE-BLOCK:` line(s) — edit there to add/remove a blocking design tool, - not in the script. -- The state check shells out to `claude` (plugin/mcp list): a few seconds. - Trivial / non-design tasks skip it entirely (no signal, or trivial tier). -- `design-tool-gate.sh`'s per-type state checks MIRROR - `profile.sh:skill_status()` — change one, sync the other, except the 21st - auth state: gate-only, no skill_status counterpart. +- The required set (what trips the gate) is `NEEDED=` in + `design-tool-gate.sh` — edit there to add/remove a blocking pack or plugin. +- The gate makes no `claude` call; it runs `profile.sh current --plain` and + `21st whoami`. Trivial / non-design tasks skip it entirely. +- The 21st sign-in state is gate-only: `profile.sh` has no counterpart. - Do NOT run this gate on pure backend/API/CLI tasks (no signals = no gate). diff --git a/lib/design-tool-gate.sh b/lib/design-tool-gate.sh index 52404ae..cab3e96 100755 --- a/lib/design-tool-gate.sh +++ b/lib/design-tool-gate.sh @@ -1,95 +1,37 @@ #!/usr/bin/env bash # ============================================================ -# lib/design-tool-gate.sh — Deterministic design-toolchain state check. +# lib/design-tool-gate.sh — deterministic design-toolchain state check. # -# Answers ONE question for the design gate (design-gate.md §DECISION): -# "Is the design toolchain active enough to proceed?" +# Answers one question for lib/design-gate.md § DECISION: "is the design +# toolchain active enough to proceed?" Source of truth = `profile.sh +# current --plain` (packs + managed plugins of THIS project and +# conversation). Required: pack-design, pack-gstack-design and the +# ui-ux-pro-max plugin, plus the `21st` CLI signed in (gate-only state: +# in / out / unknown, from `21st whoami`). # -# Source of truth = the profile system. The gate never activates a single -# tool atomically; it checks whether a profile's DESIGN-CORE tools (default -# profile: `design`) are active and, if not, points at `/profile `. -# -# Two inputs from the profile, both claude-free: -# - structure: profile.sh show --plain -> "\t" -# - gate scope: the "# GATE-BLOCK:" line(s) in .profile — the -# allowlist of tools the gate trips on. A comment, so -# read_profile strips it and --plain never shows it. Absent -# -> fall back to every skill/plugin/mcp entry (coarse). -# -# State (active or not) is checked per channel, by type. These per-type -# checks MIRROR profile.sh:skill_status() — change one, sync the other, -# except the 21st auth state: gate-only, no skill_status counterpart. -# -# type channel class -# gstack|external|personal skill symlink in skills/ blocking -# plugin `claude plugin list` -> enabled blocking -# mcp | cli `claude mcp list` / command -v required-manual -# -# Class: -# blocking required + `/profile design` activates it directly. -# required-manual required but the profile can't flip it silently (API -# key / external install) — the gate STILL trips, names -# it, and the remedy is `/profile design` + a manual step. -# This is where the `21st` CLI lands: required, never -# silent (npm i -g @21st-dev/cli, then 21st login). -# 21st's sign-in state is three-valued: in (active), -# out (exit 12, ask to sign in), unknown (exit 11). -# Both classes trip the gate. Tools NOT on the GATE-BLOCK allowlist are -# ignored entirely (browser/plan/shotgun tooling, graphify). -# -# disabledMcpServers is NEVER read — unreliable for bi-modal servers -# (context7 can appear there yet be active via another channel). -# -# Exit: 0 = ready · 11 = ready-but-unverified (proceed, say so) · -# 10 = incomplete (trips) · 12 = sign-in required (21st) · 2 = error. -# Usage: design-tool-gate.sh [profile] (default profile: design) +# Exit: 0 ready · 10 incomplete (a pack or plugin off, or no 21st CLI) · +# 11 ready-but-unverified (21st could not answer) · 12 sign-in +# required · 2 error (profile.sh failed or gave no pack lines). +# Remedy on 10: source=flag → relaunch `cc web` (a --settings +# conversation is frozen); else `profile.sh set web`, or `enable ` / +# `enable ` per missing entry, then /reload-plugins. The CLI is +# a global npm install either way. +# 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="${DESIGN_GATE_REPO_OVERRIDE:-$(cd -P "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}" +REPO="$(cd -P "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" PROFILE_SH="${DESIGN_GATE_PROFILE_SH:-$REPO/lib/profile.sh}" -CLAUDE_BIN="${CLAUDE_BIN:-claude}" -PROFILES_DIR="$REPO/lib/profiles" -SKILLS_DIR="$REPO/skills" -PROFILE="${1:-design}" -PROFILE_FILE="$PROFILES_DIR/$PROFILE.profile" +SKILLS_DIR="${DESIGN_GATE_SKILLS_DIR:-$REPO/skills}" +NEEDED=(pack-design pack-gstack-design + "plugin:ui-ux-pro-max@ui-ux-pro-max-skill") -[ -x "$PROFILE_SH" ] || { echo "design-gate: profile.sh not executable at $PROFILE_SH" >&2; exit 2; } -[ -f "$PROFILE_FILE" ] || { echo "design-gate: profile '$PROFILE' not found" >&2; exit 2; } - -# Ensure the claude CLI + its node runtime are reachable even when a skill/hook -# shells this script out with a sanitized PATH. The interactive alias -# claude->dtach_claude never reaches a non-interactive subshell; the real binary -# AND its node bin dir are what matter (claude's shebang needs node, same dir). -# If `command -v claude` already resolves, do nothing; else probe known install -# dirs and prepend. nvm keeps old node versions after an upgrade, so pick the -# newest that actually ships claude (sort -V), not the first glob match. -ensure_claude_on_path() { - command -v "$CLAUDE_BIN" >/dev/null 2>&1 && return - local cand - for cand in \ - "$HOME/.claude/local/claude" \ - "$HOME/.local/bin/claude" \ - /opt/homebrew/bin/claude \ - /usr/local/bin/claude; do - [ -x "$cand" ] && { PATH="$(dirname "$cand"):$PATH"; return; } - done - local m newest matches=() - for m in "$HOME"/.nvm/versions/node/*/bin/claude; do - [ -x "$m" ] && matches+=("$m") - done - if [ "${#matches[@]}" -gt 0 ]; then - newest="$(printf '%s\n' "${matches[@]}" | sort -V | tail -1)" - PATH="$(dirname "$newest"):$PATH" - fi -} -ensure_claude_on_path - -# Same sanitized-PATH problem for `21st` (an npm global bin), with a twist: -# the repair above only fires when claude ITSELF is unresolvable, and claude -# often lives in ~/.local/bin while the npm global bin dir is missing from a -# hook's PATH. Probe for the binary directly and prepend the dir that has it, -# otherwise a perfectly installed CLI reads as "missing" and trips the gate. +# ---- 21st CLI on PATH + sign-in state --------------------------------------- +# A hook's PATH often lacks the npm global bin dir: find `21st` there and +# prepend its dir, or an installed CLI reads as missing and trips the gate. ensure_21st_on_path() { command -v 21st >/dev/null 2>&1 && return local cand @@ -142,154 +84,80 @@ twentyfirst_auth_state() { echo "unknown:whoami: rc=$rc ${line:0:60}" } -# Gate scope: the "# GATE-BLOCK:" allowlist (one or more lines, concatenated). -# Empty => fall back to "every gate-relevant entry is in scope" (coarse). -core_set="$(grep '^# GATE-BLOCK:' "$PROFILE_FILE" 2>/dev/null \ - | sed 's/^# GATE-BLOCK:[[:space:]]*//' | tr '\n' ' ' || true)" - -# Membership in the allowlist. Empty allowlist = everything in scope. -in_scope() { - [ -z "$core_set" ] && return 0 - case " $core_set " in *" $1 "*) return 0 ;; *) return 1 ;; esac -} - -# State of one tool, by type. Mirrors profile.sh:skill_status() — keep in -# sync, except the 21st auth state (gate-only, no skill_status counterpart). -# Echoes: active | inactive | unknown (can't verify, claude absent) | -# signedout | unknown: (last two: 21st CLI only) -tool_active() { - local name="$1" type="$2" - case "$type" in - gstack|external|personal) - if [ -e "$SKILLS_DIR/$name" ]; then echo active; else echo inactive; fi - ;; - plugin) - if ! command -v "$CLAUDE_BIN" >/dev/null 2>&1; then echo unknown; return; fi - # capture first, then match: an early-exit awk/grep -q in a pipe - # SIGPIPEs the producer (rc 141 under pipefail on macOS) - local plist - plist="$("$CLAUDE_BIN" plugin list 2>/dev/null)" || true - if grep -q "✔ enabled" < <(awk -v p="^[[:space:]]*❯ ${name}@" \ - '$0 ~ p {f=1; next} f && /Status:/ {print; exit}' <<<"$plist") - then echo active; else echo inactive; fi - ;; - mcp) - if ! command -v "$CLAUDE_BIN" >/dev/null 2>&1; then echo unknown; return; fi - if grep -q "^${name}" \ - <<<"$("$CLAUDE_BIN" mcp list 2>/dev/null)"; then - echo active - else - echo inactive - fi - ;; - cli) - command -v "$name" >/dev/null 2>&1 || { echo inactive; return; } - [ "$name" = "21st" ] || { echo active; return; } - local auth - auth="$(twentyfirst_auth_state)" - case "$auth" in - in) echo active ;; - out) echo signedout ;; - unknown:*) echo "$auth" ;; - esac - ;; - *) echo inactive ;; - esac -} - -# Structure via the parse contract (claude-free). Fail loud on a bad profile — -# an empty read must NOT silently report "ready". -plain="$("$PROFILE_SH" show "$PROFILE" --plain 2>/dev/null)" \ - || { echo "design-gate: 'profile.sh show $PROFILE --plain' failed" >&2; exit 2; } -[ -n "$plain" ] || { echo "design-gate: profile '$PROFILE' is empty or unreadable" >&2; exit 2; } - -blocking=() # inactive, /profile design activates it (skill/plugin) -manual=() # inactive, required but needs a manual step (mcp key / cli install) -unverified=() # can't check (claude CLI absent) -signedout=() # 21st CLI installed, not signed in -unverified_cli=() # 21st CLI: whoami answered something unexpected -while IFS=$'\t' read -r type name; do - [ -n "$type" ] || continue - in_scope "$name" || continue # ignore non-core tooling (browser, plan-*, graphify) - state="$(tool_active "$name" "$type")" - case "$state" in - active) ;; - signedout) signedout+=("$name") ;; - unknown) unverified+=("$name") ;; - unknown:*) unverified_cli+=("$name (${state#unknown:})") ;; - *) - case "$type" in - gstack|external|personal|plugin) blocking+=("$name") ;; - *) manual+=("$name") ;; - esac - ;; - esac -done <<< "$plain" - -# print_unverified — the "also unverified" lines shared by the 10, 11 and 12 -# blocks: a claude-unreachable tool keeps its existing remedy; a 21st CLI -# that answered whoami with something unexpected gets its own — the two are -# never merged, so no block blames 21st for a claude problem or vice versa. -print_unverified() { - if [ "${#unverified[@]}" -gt 0 ]; then - echo " also unverified (claude CLI unreachable): ${unverified[*]}" - fi - local entry name diag - # bash 3.2 (macOS /bin/bash) errors on an empty array under set -u - for entry in ${unverified_cli[@]+"${unverified_cli[@]}"}; do - name="${entry%% (*}" - diag="${entry#*\(}"; diag="${diag%\)}" - echo " $name could not answer: $diag —" \ - "a CLI runtime/PATH problem (node under nvm?)," \ - "not a sign-in problem; fix it, then re-run" +# ---- packs and plugin from profile.sh --------------------------------------- +plain="$(bash "$PROFILE_SH" -C "$PWD" current --plain 2>/dev/null)" \ + || { echo "design-gate: profile.sh current --plain failed" >&2; exit 2; } +grep -q '^pack-design=' <<<"$plain" || { + echo "design-gate: profile.sh current --plain gave no pack-design line" >&2 + exit 2; } +plain_get() { sed -n "s/^$1=//p" <<<"$plain" | head -1; } +missing=() +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 +if ! command -v 21st >/dev/null 2>&1; then + cli_hint=" 21st needs the CLI: npm i -g @21st-dev/cli then 21st login" +else + auth="$(twentyfirst_auth_state)" +fi + +# ---- 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" + return + fi + echo " → run: bash ~/.claude/lib/profile.sh set web" + for k in "${missing[@]}"; do + case "$k" in + pack-*) + echo " or: bash ~/.claude/lib/profile.sh enable ${k#pack-}" ;; + *) + echo " or: bash ~/.claude/lib/profile.sh enable ${k#plugin:}" ;; + esac + done + echo " then /reload-plugins" } -# Verdict — four outcomes, checked in order: -# blocking/manual non-empty -> INCOMPLETE (exit 10): the gate trips. -# else signedout non-empty -> SIGN-IN REQUIRED (exit 12): ask the user to -# run `21st login`, end the turn, wait, re-run — never a silent skip. -# else unverified/unverified_cli non-empty -> READY BUT UNVERIFIED (exit -# 11): fail-VISIBLE. claude unreachable and/or 21st couldn't answer -# whoami — never pass either as a silent READY. -# nothing pending -> READY (exit 0). -if [ "${#blocking[@]}" -gt 0 ] || [ "${#manual[@]}" -gt 0 ]; then +# ---- verdict ----------------------------------------------------------------- +if [ "${#missing[@]}" -gt 0 ] || [ "${#dangling[@]}" -gt 0 ] \ + || [ -n "$cli_hint" ]; then echo "design toolchain: INCOMPLETE" - if [ "${#blocking[@]}" -gt 0 ]; then - echo " activate with /profile $PROFILE: ${blocking[*]}" - fi - if [ "${#manual[@]}" -gt 0 ]; then - echo " required + manual step (external install / sign-in): ${manual[*]}" - case " ${manual[*]} " in - *" 21st "*) echo " 21st needs the CLI: npm i -g @21st-dev/cli then 21st login" ;; - esac - fi - print_unverified - echo " → run: /profile $PROFILE" + [ "${#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 - -if [ "${#signedout[@]}" -gt 0 ]; then - echo "design toolchain: SIGN-IN REQUIRED — 21st CLI installed, not signed in" - echo " ask the user to run in this session:" \ - " ! 21st login" \ - " (browser flow, saves a local token)" - echo " then re-run this gate before any 21st step — never skip 21st silently" - print_unverified - exit 12 -fi - -if [ "${#unverified[@]}" -gt 0 ] || [ "${#unverified_cli[@]}" -gt 0 ]; then - echo "design toolchain: READY BUT UNVERIFIED —" \ - "$(( ${#unverified[@]} + ${#unverified_cli[@]} )) tool(s) not checked" - print_unverified - if [ "${#unverified[@]}" -gt 0 ]; then - echo " the gate could NOT confirm the design plugin (ui-ux-pro-max) is" - echo " active. Proceed only after checking manually:" - echo " claude plugin list" - fi - exit 11 -fi - -echo "design toolchain: READY — profile '$PROFILE' design tools active" +case "$auth" in + out) + echo "design toolchain: SIGN-IN REQUIRED —" \ + "21st CLI installed, not signed in" + echo " ask the user to run in this session: ! 21st login (browser flow)" + echo " then re-run this gate before any 21st step —" \ + "never skip 21st silently" + exit 12 ;; + unknown:*) + echo "design toolchain: READY BUT UNVERIFIED — 21st could not answer:" \ + "${auth#unknown:}" + echo " a CLI runtime/PATH problem (node under nvm?), not a sign-in problem" + exit 11 ;; +esac +echo "design toolchain: READY —" \ + "packs design + gstack-design + ui-ux-pro-max on ($profile)" exit 0 diff --git a/lib/detect-plugins.sh b/lib/detect-plugins.sh index f641e57..547892d 100644 --- a/lib/detect-plugins.sh +++ b/lib/detect-plugins.sh @@ -26,10 +26,12 @@ detect_superpowers() { # --- Toggle plugins --- detect_gstack() { - # gstack is exposed via per-skill symlinks (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/browse" ] || [ -L "$HOME/.claude/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() { diff --git a/lib/doctor-skills.sh b/lib/doctor-skills.sh index 51ecb71..19ba1ae 100644 --- a/lib/doctor-skills.sh +++ b/lib/doctor-skills.sh @@ -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 diff --git a/lib/doctor-vendored.sh b/lib/doctor-vendored.sh index acbfcf5..390fab6 100644 --- a/lib/doctor-vendored.sh +++ b/lib/doctor-vendored.sh @@ -4,12 +4,11 @@ # 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 -# [profile_file]`, sourced and called by doctor.sh. Two things checked +# One entry point, `check_vendored_skills `, 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// — expected file # list comes from the matching plugins.lock.json entry (list shape @@ -17,13 +16,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 (or no -# is passed — the "could not resolve the active profile" case), -# the /skills/ symlink points at -# /skills-external/. 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 /skills/ symlink points at +# /skills-external/. # # 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 +27,7 @@ # Every name/file pulled from the lock or link.sh is spliced into a # filesystem path (skills-external//, # /skills/): _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/.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. @@ -63,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) — read by _dv_is_always_on, 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 @@ -123,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 } @@ -145,22 +134,6 @@ _dv_link_names() { | grep -v '^$' } -# _dv_profile_has — true when a line's FIRST -# whitespace-separated token equals (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 — true when matches the -# profile-name allowlist (letters, digits, underscore, hyphen only). -# is spliced into "lib/profiles/.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 — true when (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 +175,28 @@ allowlist — skipped" [ "$all_ok" -eq 1 ] } -# _dv_is_always_on — true when (the -# "\t[\t1]" lines from _dv_lock_expectations) carries the -# always_on third column for '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 — -# when is "1" (the name's lock entry is "always_on": true), -# the symlink is checked whatever says — never parked. -# Otherwise, when is non-empty and does not list , -# reports it parked (info), not failed. Otherwise (listed, always_on, or -# no was passed — active profile could not be resolved, -# every external is then expected linked) checks the -# /skills/ symlink points at -# /skills-external/. +# _dv_check_link — the +# /skills/ symlink points at /skills-external/. _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 )" + fail "$name: symlink missing/wrong — run: make link" fi } -# _dv_check_name — -# 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 — 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 [profile_file] — see the +# check_vendored_skills — 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 +204,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 +227,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" } diff --git a/lib/gstack-removed.list b/lib/gstack-removed.list new file mode 100644 index 0000000..3a49d3a --- /dev/null +++ b/lib/gstack-removed.list @@ -0,0 +1,25 @@ +# The gstack skills this config never exposes: one name per line, read by +# lib/pack-census.sh (grep -qx), so these comment lines never match. +# A name listed is in no pack and no profile, `max` included. Pruned +# 2026-09-28 (BDR-105); the helpers once housed in lib/gstack-removed.sh +# are gone with the symlink toggling (BDR-117). +# Why each name went: +# ship base = origin/HEAD = main on Gitea, skips develop +# land-and-deploy `gh pr merge --squash --delete-branch` then deploys +# setup-deploy companion of land-and-deploy (Claude never deploys) +# autoplan reads ~/.claude/skills/gstack/plan-*/ paths that do +# not exist in this install +# context-save its pair context-restore is not linked; never used +# learn parallel JSONL store outside .claude/memory, unused +# careful, guard hooks exit 127 (missing bin path), vacuous; the house +# permissions.deny is stricter (BDR-095) +# design-shotgun mockups need OPENAI_API_KEY, absent +ship +land-and-deploy +setup-deploy +autoplan +context-save +learn +careful +guard +design-shotgun diff --git a/lib/gstack-removed.sh b/lib/gstack-removed.sh deleted file mode 100644 index 76e2976..0000000 --- a/lib/gstack-removed.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env bash -# ============================================================ -# lib/gstack-removed.sh — the gstack skills this config never exposes -# -# Single source for the denylist. Sourced by lib/profile.sh -# (enable_all_gstack, enable_skill) and lib/toggle-external.sh -# (`enable gstack`), read by lib/tests/profile-census.test.sh. A name -# listed here is in no profile, `max` included, and every "bring gstack -# back" path skips it. Decided 2026-09-28 (skill-catalog prune, user go): -# -# ship base = origin/HEAD = main on Gitea, skips develop -# land-and-deploy `gh pr merge --squash --delete-branch` then deploys -# setup-deploy companion of land-and-deploy (Claude never deploys) -# autoplan reads ~/.claude/skills/gstack/plan-*/ paths that do -# not exist in this install -# context-save its pair context-restore is not linked; never used -# learn parallel JSONL store outside .claude/memory, unused -# careful, guard hooks exit 127 (missing bin path) — vacuous; the -# house permissions.deny is stricter (BDR-095) -# design-shotgun mockups need OPENAI_API_KEY, absent -# -# Also hosts the gstack helpers the two scripts share (gstack_skills and -# the park/unpark moves below). They live in this file because it is the -# only one the fixture suites copy next to profile.sh / toggle-external.sh: -# a new sourced file would be missing there. Each takes its directories as -# arguments (no reliance on the caller's globals). -# -# No `set -euo pipefail` here (sourced lib, mirrors lib/detect-plugins.sh). -# ============================================================ - -GSTACK_REMOVED=(ship land-and-deploy setup-deploy autoplan context-save - learn careful guard design-shotgun) - -# gstack_is_removed — exit 0 when is on the denylist. -gstack_is_removed() { - local name="$1" entry - for entry in "${GSTACK_REMOVED[@]}"; do - [ "$entry" = "$name" ] && return 0 - done - return 1 -} - -# gstack_skills — prints the directory basenames under -# /*/ that hold a SKILL.md; nothing when the dir is absent. -# Source of truth for "which skills belong to gstack". -gstack_skills() { - local src="$1" d - [ -d "$src" ] || return 0 - for d in "$src"/*/; do - [ -f "${d}SKILL.md" ] || continue - basename "$d" - done -} - -# gstack_parked_names — prints for every -# /gstack__ entry (a dangling symlink is skipped). -gstack_parked_names() { - local entry - [ -d "$1" ] || return 0 - for entry in "$1"/gstack__*; do - [ -e "$entry" ] || continue - basename "$entry" | sed 's/^gstack__//' - done -} - -# gstack_park — moves skills/ to -# skills-disabled/gstack__. A stale destination is clobbered first: -# gstack ./setup creates skills// as directories, so mv onto an -# existing dir would nest it (gstack__//) instead of renaming. -# Content is symlinks to the submodule, `gstack ./setup` regenerates it. -# Call as a plain statement (never `|| …`, `if`, `!`): errexit must stay on. -gstack_park() { - local skills_dir="$1" disabled_dir="$2" name="$3" - rm -rf "$disabled_dir/gstack__$name" - mv "$skills_dir/$name" "$disabled_dir/gstack__$name" -} - -# gstack_unpark — moves -# skills-disabled/gstack__ back to skills/, replacing whatever -# sits there. Same plain-statement rule as gstack_park. -gstack_unpark() { - local skills_dir="$1" disabled_dir="$2" name="$3" - rm -rf "${skills_dir:?}/${name:?}" - mv "$disabled_dir/gstack__$name" "$skills_dir/$name" -} diff --git a/lib/higgsfield-skills.sh b/lib/higgsfield-skills.sh index 6721a2e..332274f 100644 --- a/lib/higgsfield-skills.sh +++ b/lib/higgsfield-skills.sh @@ -4,9 +4,8 @@ # # Sourced by install-plugins.sh (Step 8.6), update-all.sh (7.3b) and # doctor.sh. The pack is machine-owned: cloned from upstream and moved -# into skills-external/higgsfield-* (gitignored), then linked on demand by -# lib/toggle-external.sh. It is listed in neither link.sh nor any profile: -# either would re-enable a parked pack on every run (BDR-093). +# into skills-external/higgsfield-* (gitignored), then linked by +# skills/pack-higgsfield (`profile.sh enable higgsfield`). # ============================================================ # Upstream skills repo, single source for both installers. An env value @@ -38,8 +37,8 @@ _higgsfield_adopt() { # The stage sits next to the destination, on the same filesystem, so each # replacement is a rename. Prints the number of skills synced. Returns 1, # existing copies untouched, when the clone fails or upstream holds no -# higgsfield-*/SKILL.md. A parked skill (skills-disabled/, a symlink -# to the source path) stays parked. Known limit: a skill that upstream +# higgsfield-*/SKILL.md. Linked by skills/pack-higgsfield (`profile.sh +# enable higgsfield`), never touched here. Known limit: a skill that upstream # removes or renames keeps its last local copy. higgsfield_sync_skills() { local dest="$1/skills-external" stage count=0 diff --git a/lib/pack-census-fragments.jq b/lib/pack-census-fragments.jq new file mode 100644 index 0000000..163d95b --- /dev/null +++ b/lib/pack-census-fragments.jq @@ -0,0 +1,43 @@ +# lib/pack-census-fragments.jq — fragment invariants (lib/pack-census.sh). +# $m = manifests [{id,on}], $deny = space-separated profiles that deny the +# two higgsfield connectors; inputs = lib/profiles/*.json. Prints RED lines, +# and WARN lines for a pack id with no manifest. +def name_of: input_filename | sub(".*/"; ""); +def dn: [(.deniedMcpServers // [])[] | .serverName] | sort; +[inputs | {f: name_of, frag: .}] as $all +| ($all[] | select(.f == "full.json") | .frag) as $full +| ($full.enabledPlugins | keys) as $keys +| ($deny | split(" ") | map(. + ".json")) as $deny_files +| ($m | map({key: .id, value: .on}) | from_entries) as $mdef +| ($m | map(.id)) as $mids +| ( [$all[] | {f, ep: .frag.enabledPlugins, d: (.frag | dn)}] as $s + | ($s | to_entries[]) as $e + | $s[$e.key + 1:][] | select(.ep == $e.value.ep and .d == $e.value.d) + | "RED lib/profiles/\($e.value.f) and \(.f) are identical fragments" ), + ( $all[] +| .f as $f | .frag as $g +| ( if ($g.enabledPlugins | keys) != $keys + then "RED lib/profiles/\($f): key set differs from full.json" + else empty end ), + ( ["model-router@skills-dir", "security-guidance@claude-code-plugins"][] + | select($g.enabledPlugins[.] != true) + | "RED lib/profiles/\($f): \(.) must be true" ), + ( ["example-skills@anthropic-agent-skills", "brightdata-plugin@synced"][] + | select($g.enabledPlugins[.] != false) + | "RED lib/profiles/\($f): \(.) must be false" ), + ( (["claude.ai higgsfield", "claude.ai Higgsfield AI"] | sort) as $both + | if (($deny_files | index($f)) != null) and (($g | dn) != $both) + then "RED lib/profiles/\($f): must deny both higgsfield connectors" + elif (($deny_files | index($f)) == null) and (($g | dn) | length) > 0 + then "RED lib/profiles/\($f): must deny no connector" + else empty end ), + ( if $f == "full.json" then + ($mdef | to_entries[] | select($g.enabledPlugins[.key] != .value) + | "RED lib/profiles/full.json: \(.key) is \($g.enabledPlugins[.key])" + + " but the manifest default is \(.value)") + else empty end ), + ( $g.enabledPlugins | keys[] + | select(startswith("pack-") and endswith("@skills-dir") + and (. as $k | $mids | index($k) == null)) + | sub("@skills-dir$"; "") as $n + | "WARN lib/profiles/\($f): names \($n) with no skills/\($n)/" ) ) diff --git a/lib/pack-census.sh b/lib/pack-census.sh new file mode 100755 index 0000000..82cae4b --- /dev/null +++ b/lib/pack-census.sh @@ -0,0 +1,139 @@ +#!/usr/bin/env bash +# shellcheck disable=SC2088 # the literal "~/.claude/skills" is a grep pattern +# ============================================================ +# lib/pack-census.sh — census of the pack layout and its readers +# +# Packs are skills-dir plugins `skills/pack-/` (manifest +# `.claude-plugin/plugin.json`, entries `skills/` = tracked relative +# symlinks into skills-external/ or real dirs). Checks: +# 1. manifest parses, name = folder; every entry resolves (dangling = +# WARN; RED with --installed on a pack ON by manifest); no skill both +# flat and in a pack; no retired gstack name (lib/gstack-removed.list). +# 2. fragments lib/profiles/*.json: same key set as full.json; model-router +# + security-guidance true, example-skills + brightdata false +# everywhere; the two higgsfield connectors denied on exactly +# DENY_PROFILES; full.json packs = manifest defaults. +# 3. no reader of the old layout left (scope and terms in check_citers). +# Shared by make test (lib/tests/pack-census.test.sh) and doctor.sh. +# Prints RED/WARN lines, then `PACKS OK

packs skills` when no RED. +# Exit: 0 clean or WARN only · 1 any RED. +# Usage: pack-census.sh [--repo

] [--installed] +# ============================================================ +set -euo pipefail + +REPO="$(cd -P "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +INSTALLED=0 +while [ $# -gt 0 ]; do + case "$1" in + --repo) REPO="$2"; shift 2 ;; + --installed) INSTALLED=1; shift ;; + *) echo "pack-census: unknown option $1" >&2; exit 2 ;; + esac +done +SKILLS="$REPO/skills" +PROFILES="$REPO/lib/profiles" +REMOVED="$REPO/lib/gstack-removed.list" +HERE="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +FRAG_JQ="$HERE/pack-census-fragments.jq" +DENY_PROFILES="audit dev minimal qa seo" # spec § 2 +red=0; packs=0; skills=0 +declare -A seen +red() { echo "RED $*"; red=1; } + +pack_on() { + jq -e '.defaultEnabled != false' "$1/.claude-plugin/plugin.json" >/dev/null +} + +check_manifest() { # $1 pack dir + local n m name; n="$(basename "$1")"; m="$1/.claude-plugin/plugin.json" + [ -f "$m" ] || { red "$n: no .claude-plugin/plugin.json"; return; } + jq -e . "$m" >/dev/null 2>&1 || { red "$n: manifest is not JSON"; return; } + name="$(jq -r '.name // ""' "$m")" + [ "$name" = "$n" ] || red "$n: manifest name is $name" +} + +dup_remedy() { # $1 skill listed flat and in a pack + if [ -L "$SKILLS/$1" ]; then echo "rm skills/$1 (a flat link)" + else echo "mv skills/$1 skills-external/$1 (a real dir)"; fi +} + +check_entry() { # $1 pack dir, $2 entry path + local n s; n="$(basename "$1")"; s="$(basename "$2")" + if [ ! -e "$2/SKILL.md" ]; then + if [ "$INSTALLED" = 1 ] && pack_on "$1"; then + red "$n: $s target missing (pack ON)" + else echo "WARN $n: $s target missing (installer not run)"; fi + fi + [ -f "$REMOVED" ] && grep -qx -- "$s" "$REMOVED" \ + && red "$n: $s is a retired gstack skill" + if [ -n "${seen[$s]:-}" ]; then + red "$s listed twice: ${seen[$s]} and $n; run: $(dup_remedy "$s")" + else seen[$s]="$n"; fi + skills=$((skills+1)) +} + +check_fragments() { + local files=("$PROFILES"/*.json) full="$PROFILES/full.json" out + [ -f "$full" ] || { red "lib/profiles/full.json missing"; return; } + out="$(jq -rn --arg deny "$DENY_PROFILES" --argjson m "$(manifests_json)" \ + -f "$FRAG_JQ" "${files[@]}")" \ + || { red "lib/profiles: a fragment is not JSON"; return; } + [ -z "$out" ] || echo "$out" + ! grep -q '^RED' <<<"$out" || red=1 +} + +manifests_json() { # [{id, on}] for every pack manifest + jq -cn '[inputs | {id: (.name + "@skills-dir"), + on: (.defaultEnabled != false)}]' \ + "$SKILLS"/pack-*/.claude-plugin/plugin.json 2>/dev/null || echo '[]' +} + +# A bare `skills//` is stale; the layout is +# `skills/pack-/skills//`, and a path with any prefix passes. +# The old-layout terms are written with a bracketed last letter so this +# file never matches itself; the test's fixture strings live in +# lib/tests/fixtures/ (excluded) for the same reason. +check_citers() { # $@ pack skill names → one grep over the contract scope + local args=(-e 'skills-disable[d]/' -e 'toggle-externa[l]' + -e '\.active-profil[e]' -e 'lib/profiles/[a-z-]*\.profil[e]') n hit + for n in "$@"; do + args+=(-e "~/.claude/skills/$n\b" -e "\$HOME/.claude/skills/$n\b" + -e "\(^\|[^A-Za-z0-9_./}~-]\)skills/$n/") + done + hit="$( { grep -rno --include='*.sh' --include='*.md' --include='*.py' \ + --include='*.json' --include='Makefile' "${args[@]}" "$REPO"/hooks \ + "$REPO"/lib "$REPO"/agents "$REPO"/skills "$REPO"/rules \ + "$REPO"/templates "$REPO"/mods "$REPO"/*.sh "$REPO"/CLAUDE.global.md \ + "$REPO"/README.md "$REPO"/USAGE.md "$REPO"/ARCHITECTURE.md \ + "$REPO"/Makefile "$REPO"/plugins.lock.json 2>/dev/null + grep -nHo "${args[@]}" "$REPO"/.gitignore 2>/dev/null; } \ + | grep -v -e '/lib/tests/fixtures/' -e '/skills-external/' \ + | sed -E 's#:[0-9]*:#\t#; s#\t[^\t](skills/[^/\t]+/)$#\t\1#' \ + | sort -u || true)" + [ -n "$hit" ] || return 0 + while IFS=$'\t' read -r f m; do + red "${f#"$REPO"/} cites $m" + done <<<"$hit" +} + +main() { + local d s p e names=() + [ -f "$REMOVED" ] || red "lib/gstack-removed.list missing" + for d in "$SKILLS"/*/; do + d="${d%/}"; s="$(basename "$d")" + case "$s" in pack-*) continue ;; esac + [ -e "$d/SKILL.md" ] && seen[$s]="skills/$s" + done + for p in "$SKILLS"/pack-*/; do + p="${p%/}"; packs=$((packs+1)); check_manifest "$p" + for e in "$p"/skills/*; do + [ -e "$e" ] || [ -L "$e" ] || continue + check_entry "$p" "$e"; names+=("$(basename "$e")") + done + done + check_fragments + [ "${#names[@]}" -gt 0 ] && check_citers "${names[@]}" + [ "$red" -eq 0 ] && echo "PACKS OK $packs packs $skills skills" + exit "$red" +} +main diff --git a/lib/plugin-gate.md b/lib/plugin-gate.md index 1f228fd..6bffbf1 100644 --- a/lib/plugin-gate.md +++ b/lib/plugin-gate.md @@ -12,18 +12,17 @@ Agent(subagent_type="plugin-probe", description="plugin gate — probe", prompt="Run your probes from . Emit the PROBE REPORT.") ``` -## 2. VALIDATION CHECKPOINT (main loop — between probe and reasoner) +## 2. VALIDATION CHECKPOINT (main loop: between probe and reasoner) Validate the PROBE REPORT before any reasoning: -- `EXTERNAL` non-empty AND each listed plugin's directory appears under - `CHECKPOINT plugin-dirs`. +- `PROFILE` block holds a `profile=` line. - At least one project signal present (MANIFESTS / FRAMEWORK-DEPS / TSX-JSX-COUNT > 0 / DOCKER-COUNT > 0 / EMBEDDED hits). Else print - `⚠️ No project signals detected — recommendations will be conservative.` + `⚠️ No project signals detected: recommendations will be conservative.` and continue. -- `CHECKPOINT toggle-script=UNAVAILABLE` → print `⚠️ toggle script - unavailable — recommendations will be advisory only, no auto-activation.` - and SKIP step 5 (apply) entirely. +- `CHECKPOINT profile-sh=UNAVAILABLE` → print `⚠️ profile.sh unavailable: + recommendations will be advisory only, no auto-activation.` and SKIP + step 5 (apply) entirely. - PROBE REPORT missing/unparsable → retry the probe ONCE fresh; a 2nd failure → STOP and surface (never reason over invented detection). @@ -45,7 +44,7 @@ Show the returned PLUGIN CHECK block. answered. - OK → print `✅ Plugin check passed — [active plugins] — complexity: %`. -## 5. APPLY GATE (main loop — only when the flow auto-activates) +## 5. APPLY GATE (main loop: only when the flow auto-activates) If any plugin has ⚡ ENABLE status: 1. List the changes: @@ -55,36 +54,17 @@ If any plugin has ⚡ ENABLE status: ⚡ Pre-fetch ctx7 docs for next.js, prisma Apply these changes? (yes / no / customize) ``` -2. "yes" → apply via the exact commands the advisor emitted. "customize" → - user picks. "no" → proceed with current config. +2. "yes" → run the advisor's commands in order, each one `bash + "$HOME/.claude/lib/profile.sh" -C set ` or `enable + `. Each call writes `.claude/settings.local.json` atomically or + refuses (rc 2, nothing written), so there is nothing to roll back: stop at + the first non-zero rc, print its stderr, and continue with the current + config. "customize" → user picks. "no" → proceed with current config. +3. After a successful write print `✅ Applied N change(s): run + /reload-plugins to load the packs in this session (connectors and model: + next session).` In a `--settings` conversation (`PROFILE :` block says + `source=flag`) the advisor emits no enable for a pack the flag turns off; + it says `relaunch: cc ` instead. -**Never auto-activate without showing the list and getting confirmation.** - -### Rollback on partial failure - -Track each toggle; roll back the partial set rather than leave a -half-applied configuration: - -```bash -applied=() -for change in "${PROPOSED_CHANGES[@]}"; do - if bash "$HOME/.claude/lib/toggle-external.sh" enable "$change"; then - applied+=("$change") - else - echo "❌ failed to enable $change — rolling back ${#applied[@]} prior change(s)" - for prior in "${applied[@]}"; do - bash "$HOME/.claude/lib/toggle-external.sh" disable "$prior" \ - || echo "⚠️ rollback of $prior also failed — manual cleanup required: see ~/.claude/plugins/cache" - done - exit 1 - fi -done -``` - -Surface: `✅ Applied N change(s).` — or on failure: - -``` -⚠️ Toggle failed at change . Rolled back the N prior change(s). - To inspect manually: ls ~/.claude/plugins/cache; bash ~/.claude/lib/toggle-external.sh list - Re-run /plugin-check after fixing the underlying cause (e.g. permissions). -``` +**Never auto-activate without showing the list and getting confirmation. +Never write the user scope.** diff --git a/lib/profile-state.jq b/lib/profile-state.jq new file mode 100644 index 0000000..cac974c --- /dev/null +++ b/lib/profile-state.jq @@ -0,0 +1,72 @@ +# lib/profile-state.jq — effective profile state of one project and +# conversation, in one pass (lib/profile.sh `current`, `unset`). +# Args: $u $p $l $f raw settings files (user, project, local, --settings; +# "" when absent), $cj raw ~/.claude.json, $m manifests [{id,on}], +# $mode "plain" | "human" | "json", $proj project dir, $flagname CLAUDE_PROFILE +# or "-", $hasflag "1" when a --settings file is in force. +# inputs = lib/profiles/*.json (one fragment per file). +def parse: try fromjson catch {}; +def name_of: input_filename | sub(".*/"; "") | sub("\\.json$"; ""); +def ep: (.enabledPlugins // {}); +def dn: [(.deniedMcpServers // [])[] | .serverName]; +def onoff: if . then "on" else "off" end; +def is_pack: startswith("pack-") and endswith("@skills-dir"); +def short: sub("@skills-dir$"; ""); +def src_word($s): + if $s.source == "flag" then "conv \($s.flag)" else $s.source end; +def listing($plugins; $on): + [$plugins | to_entries[] | select(.value == $on) | .key | short] + | if length == 0 then "none" else join(" ") end; + +[inputs | {name: name_of, frag: .}] as $profiles +| ($u | parse) as $U | ($p | parse) as $P +| ($l | parse) as $L | ($f | parse) as $F +| ([$profiles[].frag | ep | keys[]] | unique) as $ids +| ([$profiles[].frag | dn[]] | unique) as $managed +| ($m | map({key: .id, value: .on}) | from_entries) as $mdef +| ($ids | map({key: ., value: ($mdef[.] + // (if endswith("@skills-dir") and (is_pack | not) then true + else false end))}) | from_entries) as $d +| (($d + ($U|ep) + ($P|ep) + ($L|ep) + ($F|ep)) + | with_entries(select(.key as $k | $d | has($k)))) as $plugins +| ((($U|dn) + ($P|dn) + ($L|dn) + ($F|dn)) | unique) as $denied +| ([$U, $P, $L, $F] | any(.disableClaudeAiConnectors == true)) as $all +| ($F.model // $L.model // $P.model // $U.model // "-") as $model +| (if ($F | has("model")) then "flag" elif ($L | has("model")) then "local" + elif ($P | has("model")) then "project" + elif ($U | has("model")) then "user" else "-" end) as $msrc +| (if $hasflag == "1" then "flag" + elif ((($L|ep) | length) + (($L|dn) | length)) > 0 then "local" + else "default" end) as $src +| (try ($cj | fromjson | .projects[$proj].disabledMcpServers // [] + | if length == 0 then "-" else join(",") end) + catch (if $cj == "" then "-" else "unknown" end)) as $off +| ([$denied[] | select(. as $x | $managed | index($x))]) as $mdenied +| ([$profiles[] | select((.frag | ep) == $plugins + and ((.frag | dn | sort) == ($mdenied | sort)) and ($all | not)) + | .name] | .[0] // "custom") as $name +| {name: $name, source: $src, flag: $flagname, plugins: $plugins, + denied: $denied, managed_denied: $mdenied, all_denied: $all, + model: $model, model_source: $msrc, mcp_off: $off} as $s +| if $mode == "json" then $s + elif $mode == "plain" then + ( ["profile=\($s.name)", "source=\($s.source)", "flag=\($s.flag)"] + + [$plugins | to_entries | sort_by(.key)[] | select(.key | is_pack) + | "\(.key | short)=\(.value | onoff)"] + + [$plugins | to_entries | sort_by(.key)[] + | select(.key | is_pack | not) | "plugin:\(.key)=\(.value | onoff)"] + + [$denied[] | "connector:\(.)=denied"] + + (if $all then ["connector:*=denied"] else [] end) + + ["model=\($s.model)", "model-source=\($s.model_source)", + "mcp-off=\($s.mcp_off)"] ) | .[] + else + ( [ (if $s.mcp_off != "-" + then "profile: custom (off: \($s.mcp_off)) [\(src_word($s))]" + else "profile: \($s.name) [\(src_word($s))]" end), + " on : \(listing($plugins; true))", + " off: \(listing($plugins; false))", + " connectors denied: \(if $all then "all" + elif ($denied | length) == 0 then "none" + else ($denied | join(", ")) end)", + " model: \($s.model) (\($s.model_source))" ] ) | .[] + end diff --git a/lib/profile.sh b/lib/profile.sh index 20c9800..3b4dfd3 100755 --- a/lib/profile.sh +++ b/lib/profile.sh @@ -1,834 +1,303 @@ #!/usr/bin/env bash +# shellcheck disable=SC2016 # jq programs quote $vars on purpose # ============================================================ -# lib/profile.sh — Partition Claude skills + plugins + MCPs by purpose +# lib/profile.sh — profiles as settings fragments for packs + connectors # -# Profiles group skills (gstack + external + personal), plugins, MCPs, -# and CLIs for a specific kind of work: web, seo, web-full, backend, -# design, dev, qa, audit, minimal. Apply a profile to enable just the -# relevant tools and disable the rest, instead of carrying every gstack -# skill + every plugin in every session. -# -# Mechanism: -# - Skills (gstack/external/personal): symlink toggle skills/ ↔ skills-disabled/ -# - Plugins: `claude plugin enable|disable @` -# - MCPs: advisory (none managed since BDR-093 — MANAGED_MCPS is empty), -# advisory otherwise -# - CLIs: advisory only (rtk, gsd, ctx7, graphify — installed externally) -# - `set` is SYMMETRIC on managed items (BDR-079): plugins, external packs -# and MCPs in the MANAGED_* allowlists are disabled when the profile -# does not list them — nothing outside those lists is ever auto-toggled. -# -# Always-on plugins (never toggled by `set`): security-guidance + rtk -# hook + .claude internal. superpowers is vendored skills now, not a -# plugin (never in PROTECTED_PLUGINS, never in MANAGED_EXTERNALS — same -# always-on class as darwin-skill). The script refuses to disable -# anything in PROTECTED_PLUGINS. +# A profile `lib/profiles/.json` is a literal Claude Code settings +# fragment: `enabledPlugins` (every pack `pack-@skills-dir` and managed +# plugin, explicit true/false), `deniedMcpServers` (claude.ai connector +# names, optional) and `model` (optional). Per project, `set` merges it +# into `.claude/settings.local.json`; per conversation, `cc +# ` (lib/cc.sh) passes the file as `claude --settings`. Nothing +# here writes the user scope, moves a symlink or calls `claude`. # # Usage: -# profile.sh list list available profiles -# profile.sh show show contents of a profile (grouped by type) -# profile.sh show --plain parsable type+name list (no status, no claude) -# profile.sh current report the active profile (label + match) -# profile.sh apply enable items in profile (additive) -# profile.sh set enable only profile (disables rest) -# profile.sh reset go to the default profile (full): enable its -# list, park non-listed gstack/managed items -# profile.sh gstack on|off toggle gstack, keeping active-profile label -# profile.sh diff compare two profiles +# profile.sh [-C ] list +# profile.sh [-C ] show +# profile.sh [-C ] current [--plain] +# profile.sh [-C ] set +# profile.sh [-C ] unset +# profile.sh [-C ] enable|disable +# profile.sh [-C ] diff # -# Profile file format (lib/profiles/.profile): -# # DESC: -# # type defaults to "gstack" -# personal # personal skill (skills//SKILL.md is real) -# external # symlinked into skills-external/ -# plugin@ # Claude plugin — auto-toggle -# mcp # MCP — advisory or via toggle-external -# cli # standalone CLI — advisory only +# (default: cwd) is the session dir. The project root, where the +# local file lives, follows Claude Code: inside a git repo it is the parent +# of the git common dir (a worktree resolves to the main checkout), unless +# that is $HOME or above; otherwise the nearest ancestor holding .claude/, +# CLAUDE.md or .git, below $HOME. The shared .claude/settings.json is read +# from itself. +# `current` = lib/profile-state.jq, ONE jq pass over: $CLAUDE_PROFILE_SETTINGS +# (the --settings file lib/cc.sh exports), /.claude/settings.local.json, +# /.claude/settings.json, ~/.claude/settings.json; a pack absent from +# all takes its manifest `defaultEnabled` (absent key = on); a managed plugin +# absent from all is off; `enabledPlugins` and `model` per key, highest wins; +# `deniedMcpServers` = the UNION of every file; `disableClaudeAiConnectors` +# any-source-true; then ~/.claude.json `projects[].disabledMcpServers`. +# `--plain` = one `key=value` per line: the single truth for gates, hooks +# 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. # ============================================================ set -euo pipefail -REPO="${PROFILE_REPO_OVERRIDE:-$(cd -P "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}" -CLAUDE_BIN="${CLAUDE_BIN:-claude}" -SKILLS_DIR="$REPO/skills" -DISABLED_DIR="$REPO/skills-disabled" -GSTACK_SRC="$REPO/skills-external/gstack" # gstack submodule — source of truth for gstack skills +REPO="${PROFILE_REPO_OVERRIDE:-$(cd -P "$(dirname "${BASH_SOURCE[0]}")/.." \ + && pwd)}" PROFILES_DIR="$REPO/lib/profiles" -ACTIVE_CACHE="$REPO/.active-profile" # statusline reads this — keep fast (single-line file, profile name only) -DEFAULT_PROFILE="full" # profile in force when none is selected (cache absent, empty, or legacy "none") - -# GSTACK_REMOVED + gstack_is_removed() — single source, honored by every -# "bring gstack back" path below (enable_all_gstack, enable_skill) — plus the -# gstack helpers shared with toggle-external.sh (gstack_skills, gstack_park, -# gstack_unpark, gstack_parked_names). -# shellcheck source=lib/gstack-removed.sh disable=SC1091 -source "$(dirname "${BASH_SOURCE[0]}")/gstack-removed.sh" - -# Plugins that are toggle-managed by `set`. Anything NOT in this list is -# never auto-disabled — protects always-on plugins (security-guidance; -# superpowers is vendored skills now, not a plugin) and unrelated user -# plugins. Add a plugin here only when its enabled state is meaningfully -# driven by task type. -MANAGED_PLUGINS=( - "ui-ux-pro-max@ui-ux-pro-max-skill" - "plugin-dev@claude-code-plugins" - "pr-review-toolkit@claude-code-plugins" -) - -# External skill packs that are toggle-managed by `set` — same allowlist -# doctrine as MANAGED_PLUGINS: listed here only when the enabled state is -# task-type-driven. `set` disables these when the profile does not list -# them; anything else external (e.g. darwin-skill) is never auto-touched. -MANAGED_EXTERNALS=( - emil-design-eng - frontend-design - design-motion-principles - impeccable - 21st-ui-build - 21st-ui-explore - 21st-ui-review - 21st-cli-use - 21st-ai - 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 -) - -# MCP servers that are toggle-managed by `set`, both ways (enable AND -# disable), delegated to lib/toggle-external.sh. Same allowlist doctrine. -# Empty: no MCP server is managed today (the 21st design skills are managed -# as externals above). The `mcp` type itself stays supported — a profile can -# still list an MCP, it is then advisory rather than auto-toggled. -MANAGED_MCPS=() - -# Plugins that MUST stay enabled — `set` will refuse to disable these even if -# they're not in the profile. (Defensive: belt-and-suspenders alongside -# MANAGED_PLUGINS allowlist.) -PROTECTED_PLUGINS=( - "security-guidance@claude-code-plugins" -) - -GREEN='\033[0;32m'; YELLOW='\033[1;33m'; RED='\033[0;31m'; BLUE='\033[0;34m'; NC='\033[0m' -ok() { echo -e "${GREEN}✓${NC} $1"; } -warn() { echo -e "${YELLOW}⚠${NC} $1"; } -err() { echo -e "${RED}✗${NC} $1" >&2; } -info() { echo -e "${BLUE}ℹ${NC} $1"; } - -# Persist active-profile name for fast statusline lookup (cmd_current is slow -# — iterates every profile + every entry). Write profile name only; statusline -# reads the file directly without re-invoking this script. -write_active() { - local name="$1" - printf '%s\n' "$name" > "$ACTIVE_CACHE" 2>/dev/null || true -} - -# First line of the cache, all whitespace stripped (tr -d, CRLF-proof). -# Empty string when the cache is missing or empty. Never trips -# `set -euo pipefail` (head's failure on a missing file is absorbed). -read_cache() { - head -n1 "$ACTIVE_CACHE" 2>/dev/null | tr -d '[:space:]' || true -} - -# The profile actually in force: the cached label, or DEFAULT_PROFILE when -# the cache is absent, empty, or the legacy "none" sentinel. The ONE place -# that resolves "no profile selected" — every reader of the cache goes -# through this (or read_cache() when it needs the raw value). -active_profile() { - local cached; cached="$(read_cache)" - if [ -z "$cached" ] || [ "$cached" = "none" ]; then - printf '%s' "$DEFAULT_PROFILE" - else - printf '%s' "$cached" - fi -} - -# ── Profile parsing ──────────────────────────────────────── - -# Read a profile file. Output one line per entry: "\t" -# Comments (#…) and blank lines are stripped. Default type is "gstack". -read_profile() { - local prof="$1" - local file="$PROFILES_DIR/$prof.profile" - [ -f "$file" ] || { err "Profile not found: $prof (looked in $PROFILES_DIR)"; return 1; } - local skill type rest - while IFS= read -r line || [ -n "$line" ]; do - line="${line%%#*}" - # trim leading whitespace + tabs - while [[ "$line" =~ ^[[:space:]] ]]; do line="${line#?}"; done - # trim trailing whitespace + tabs - while [[ "$line" =~ [[:space:]]$ ]]; do line="${line%?}"; done - [ -z "$line" ] && continue - # split on first whitespace run - skill="${line%%[[:space:]]*}" - rest="${line#"$skill"}" - while [[ "$rest" =~ ^[[:space:]] ]]; do rest="${rest#?}"; done - type="${rest:-gstack}" - # Validate type. Accepted forms: - # gstack | external | personal — skill (symlink toggle) - # plugin@ — Claude plugin (auto-toggle) - # plugin — legacy/advisory (no marketplace known) - # mcp — MCP server (advisory or via toggle-external) - # cli — standalone CLI (advisory only) - case "$type" in - gstack|external|personal|plugin|mcp|cli) : ;; - plugin@*) : ;; - *) warn "unknown type '$type' for entry '$skill' in $prof — defaulting to gstack"; type=gstack ;; - esac - printf '%s\t%s\n' "$skill" "$type" - done < "$file" -} - -# Profile description (line starting with "# DESC: …") -profile_desc() { - local file="$1" - grep -m1 '^# DESC:' "$file" 2>/dev/null | sed 's/^# DESC:[[:space:]]*//' || true -} - -# ── Counting & formatting helpers ───────────────────────── - -# Tally a profile's entries by category (claude-free, reads the .profile only). -# Echo: " " — skills = gstack+external+personal. -count_profile() { - local prof="$1" type - local g=0 e=0 p=0 pl=0 m=0 c=0 - while IFS=$'\t' read -r _ type; do - case "$type" in - gstack) g=$((g + 1)) ;; - external) e=$((e + 1)) ;; - personal) p=$((p + 1)) ;; - plugin@*|plugin) pl=$((pl + 1)) ;; - mcp) m=$((m + 1)) ;; - cli) c=$((c + 1)) ;; - esac - done < <(read_profile "$prof") - printf '%d %d %d %d\n' "$((g + e + p))" "$pl" "$m" "$c" -} - -# " " with a plural "s" when n != 1. -_plur() { - if [ "$1" -eq 1 ]; then printf '%d %s' "$1" "$2"; else printf '%d %ss' "$1" "$2"; fi -} - -# Format four category counts. style=compact -> "12s·1p·1m·1c"; -# style=long -> "12 skills · 1 plugin · 1 mcp · 1 cli". Zero categories are -# skipped; all-zero -> "—". -fmt_counts() { - local style="$1" skills="$2" pl="$3" m="$4" c="$5" out="" - if [ "$style" = compact ]; then - [ "$skills" -gt 0 ] && out="${skills}s" - [ "$pl" -gt 0 ] && out="${out:+$out·}${pl}p" - [ "$m" -gt 0 ] && out="${out:+$out·}${m}m" - [ "$c" -gt 0 ] && out="${out:+$out·}${c}c" - else - [ "$skills" -gt 0 ] && out="$(_plur "$skills" skill)" - [ "$pl" -gt 0 ] && out="${out:+$out · }$(_plur "$pl" plugin)" - [ "$m" -gt 0 ] && out="${out:+$out · }$(_plur "$m" mcp)" - [ "$c" -gt 0 ] && out="${out:+$out · }$(_plur "$c" cli)" - fi - printf '%s' "${out:-—}" -} - -# Right-pad a string to display width $2 (character count, UTF-8 aware). -rpad() { - local s="$1" w="$2" len=${#1} - if [ "$len" -lt "$w" ]; then printf '%s%*s' "$s" "$((w - len))" ''; else printf '%s' "$s"; fi -} - -# ── Status detection ────────────────────────────────────── - -skill_status() { - local skill="$1" type="$2" - case "$type" in - gstack|external|personal) - if [ -e "$SKILLS_DIR/$skill" ]; then - echo "enabled" - elif [ -e "$DISABLED_DIR/gstack__$skill" ] || [ -e "$DISABLED_DIR/$skill" ]; then - echo "disabled" - else - echo "missing" - fi - ;; - plugin|plugin@*) - # `claude plugin list` is the source of truth — settings.json may be - # ahead of or behind reality if the user toggled outside this tool. - if command -v "$CLAUDE_BIN" >/dev/null 2>&1; then - # Match the plugin block by name then check Status line. List is - # captured first: an early-exit awk/grep -q in a pipe SIGPIPEs the - # producer (rc 141 under pipefail on macOS). - local plist - plist="$("$CLAUDE_BIN" plugin list 2>/dev/null)" || true - if grep -q "✔ enabled" < <(awk -v p="$skill" ' - /^[[:space:]]*❯ '"$skill"'@/ { found=1; next } - found && /Status:/ { print; exit } - ' <<<"$plist"); then - echo "enabled" - else - echo "disabled" - fi - else - echo "unknown" - fi - ;; - mcp) - if command -v "$CLAUDE_BIN" >/dev/null 2>&1 && \ - grep -q "^${skill}" <<<"$("$CLAUDE_BIN" mcp list 2>/dev/null)"; then - echo "enabled" - else - echo "disabled" - fi - ;; - cli) - command -v "$skill" >/dev/null 2>&1 && echo "installed" || echo "not-installed" - ;; - *) echo "unknown" ;; - esac -} - -# How much of one profile is actually available right now. An item counts -# as available when its status is "enabled" (skills, plugins, MCPs) or -# "installed" (CLIs). Echo: " " — total 0 for an empty -# profile. Used by cmd_current to score the ACTIVE label only (BDR-030: -# scanning every profile for a best guess doesn't apply — gstack is off by -# default, so a parked count says nothing about which profile is on). -profile_match() { - local prof="$1" skill type status - local total=0 available=0 - while IFS=$'\t' read -r skill type; do - total=$((total + 1)) - status="$(skill_status "$skill" "$type")" - case "$status" in - enabled|installed) available=$((available + 1)) ;; - esac - done < <(read_profile "$prof") - printf '%d %d\n' "$available" "$total" -} - -# ── Enable / disable ────────────────────────────────────── - -# Enables a gstack skill: unpark it, or link it from the submodule. -enable_gstack_skill() { - local skill="$1" - if gstack_is_removed "$skill"; then - warn "refusing to enable removed skill: $skill (lib/gstack-removed.sh \ -— a profile census failure, not a crash)" - return 0 - elif [ -e "$DISABLED_DIR/gstack__$skill" ]; then - gstack_unpark "$SKILLS_DIR" "$DISABLED_DIR" "$skill" - ok "enabled: $skill" - elif [ -e "$DISABLED_DIR/$skill" ]; then - rm -rf "${SKILLS_DIR:?}/${skill:?}" - mv "$DISABLED_DIR/$skill" "$SKILLS_DIR/$skill" - ok "enabled: $skill" - elif [ -e "$SKILLS_DIR/$skill" ]; then - : # already enabled — silent - elif [ -d "$GSTACK_SRC/$skill" ]; then - # gstack is OFF by default: its skills live only in the submodule, - # never pre-symlinked into skills/. A profile that lists this gstack - # skill activates it on demand by symlinking the submodule skill dir - # in. disable_gstack_not_in() parks it again when an unrelated profile - # is set. The gstack/bin + browse/dist infra it relies on is created - # by link.sh, independent of this. - ln -sf "$GSTACK_SRC/$skill" "$SKILLS_DIR/$skill" - ok "enabled: $skill (gstack on-demand)" - elif [ ! -d "$GSTACK_SRC" ]; then - warn "missing: $skill — gstack submodule absent, run: git submodule update --init" - else - warn "missing: $skill — not found in gstack submodule ($GSTACK_SRC)" - fi -} - -# Enables an external|personal skill: unpark it, or recreate the symlink. -enable_linked_skill() { - local skill="$1" type="$2" - if [ -e "$DISABLED_DIR/$skill" ]; then - rm -rf "${SKILLS_DIR:?}/${skill:?}" - mv "$DISABLED_DIR/$skill" "$SKILLS_DIR/$skill" - ok "enabled: $skill ($type)" - elif [ -e "$SKILLS_DIR/$skill" ]; then - : - elif [ "$type" = external ] && [ -d "$REPO/skills-external/$skill" ]; then - # Symlink never created (or hand-removed): recreate it from the - # vendored pack — mirrors toggle-external.sh's from-source path. - ln -sf "$REPO/skills-external/$skill" "$SKILLS_DIR/$skill" - ok "enabled: $skill (external, symlink created)" - else - warn "missing: $skill ($type)" - fi -} - -# Enables a plugin@ skill through the claude CLI. -enable_plugin_skill() { - local skill="$1" type="$2" - # type holds the marketplace: plugin@ - local marketplace="${type#plugin@}" - if [ "$(skill_status "$skill" "$type")" = "enabled" ]; then - : # already on - elif command -v "$CLAUDE_BIN" >/dev/null 2>&1; then - # CLI call stays inside the condition: a failing CLI must not abort - if grep -qiE "enabled|already" \ - <<<"$("$CLAUDE_BIN" plugin enable \ - "${skill}@${marketplace}" 2>&1)"; then - ok "enabled plugin: ${skill}@${marketplace}" - else - warn "could not enable plugin: ${skill}@${marketplace}" - fi - else - info "claude CLI not in PATH — manual: claude plugin enable ${skill}@${marketplace}" - fi -} - -enable_skill() { - local skill="$1" type="$2" - case "$type" in - gstack) enable_gstack_skill "$skill" ;; - external|personal) enable_linked_skill "$skill" "$type" ;; - plugin@*) enable_plugin_skill "$skill" "$type" ;; - plugin) - # No marketplace specified — purely advisory. - if [ "$(skill_status "$skill" plugin)" = "enabled" ]; then - : # already on - else - info "plugin '$skill' not enabled — run: claude plugin enable $skill@" - fi - ;; - mcp) - # Advisory only: MANAGED_MCPS is empty, nothing is auto-registered. - # Re-add a delegation branch here the day a profile owns an MCP server. - if [ "$(skill_status "$skill" mcp)" = "enabled" ]; then - : # already on - else - info "MCP '$skill' not registered — run: claude mcp add $skill -- " - fi - ;; - cli) - # CLIs install externally; we never auto-install. Just report status. - if command -v "$skill" >/dev/null 2>&1; then - : # installed — silent - else - info "CLI '$skill' not installed — install separately (npm/cargo/pipx)" - fi - ;; - esac -} - -disable_skill() { - local skill="$1" type="$2" - case "$type" in - gstack) - if [ -e "$SKILLS_DIR/$skill" ]; then - mkdir -p "$DISABLED_DIR" - gstack_park "$SKILLS_DIR" "$DISABLED_DIR" "$skill" - ok "disabled: $skill" - fi - ;; - external|personal) - if [ -e "$SKILLS_DIR/$skill" ]; then - mkdir -p "$DISABLED_DIR" - rm -rf "${DISABLED_DIR:?}/${skill:?}" - mv "$SKILLS_DIR/$skill" "$DISABLED_DIR/$skill" - ok "disabled: $skill ($type)" - fi - ;; - plugin@*) - local marketplace="${type#plugin@}" - local key="${skill}@${marketplace}" - # Defensive check against PROTECTED_PLUGINS (always-on). - local p - for p in "${PROTECTED_PLUGINS[@]}"; do - if [ "$key" = "$p" ]; then - warn "refusing to disable protected plugin: $key" - return 0 - fi - done - if [ "$(skill_status "$skill" "$type")" = "disabled" ]; then - : # already off - elif command -v "$CLAUDE_BIN" >/dev/null 2>&1; then - if grep -qiE "disabled|already" \ - <<<"$("$CLAUDE_BIN" plugin disable "$key" 2>&1)"; then - ok "disabled plugin: $key" - else - warn "could not disable plugin: $key" - fi - else - info "claude CLI not in PATH — manual: claude plugin disable $key" - fi - ;; - plugin) - info "plugin '$skill' — manual: claude plugin disable $skill@" - ;; - mcp) - info "MCP '$skill' — manual: claude mcp remove $skill" - ;; - cli) - : # never auto-uninstall CLIs - ;; - esac -} - -# ── Shared gstack operations ────────────────────────────── - -# Re-enable every gstack skill parked in skills-disabled/ (move gstack__* -# back into skills/), skipping a name lib/gstack-removed.sh denies (left -# parked — the policy line goes to stderr). Shared by cmd_reset and -# `gstack on`. Echoes the REAL restored count (skipped names excluded) on -# stdout so the caller can report it accurately; per-skill confirmations -# go to stderr so that count is the only thing captured with `$(...)`. -enable_all_gstack() { - local name restored=0 - [ -d "$DISABLED_DIR" ] || { echo 0; return 0; } - while IFS= read -r name; do - if gstack_is_removed "$name"; then - info "skipped (removed by policy, lib/gstack-removed.sh): $name" >&2 - continue - fi - gstack_unpark "$SKILLS_DIR" "$DISABLED_DIR" "$name" - ok "re-enabled: $name" >&2 - restored=$((restored + 1)) - done < <(gstack_parked_names "$DISABLED_DIR") - echo "$restored" -} - -# Disable gstack-origin skills not listed in the given profile. Shared by -# cmd_set and `gstack off`. Caller is responsible for validating the profile. -disable_gstack_not_in() { - local prof="$1" - local keep_file name - keep_file="$(mktemp)" - read_profile "$prof" | cut -f1 | sort -u > "$keep_file" - while read -r name; do - [ -n "$name" ] || continue - grep -qx "$name" "$keep_file" || disable_skill "$name" gstack - done < <(gstack_skills "$GSTACK_SRC" | sort -u) - rm -f "$keep_file" -} - -# Count gstack skills currently parked in skills-disabled/. -parked_gstack_count() { - [ -d "$DISABLED_DIR" ] || { echo 0; return 0; } - find "$DISABLED_DIR" -maxdepth 1 -name 'gstack__*' 2>/dev/null | wc -l | tr -d ' ' -} - -# ── `set` trim helpers — one per managed category ───────────── -# Each disables the managed items NOT listed in the given profile. Allowlist -# doctrine: only MANAGED_* entries are ever auto-disabled. - -disable_plugins_not_in() { - local prof="$1" keep_file p plugin_name marketplace - keep_file="$(mktemp)" - read_profile "$prof" \ - | awk -F'\t' '$2 ~ /^plugin@/ { sub(/^plugin@/, "", $2); print $1"@"$2 }' \ - | sort -u > "$keep_file" - for p in "${MANAGED_PLUGINS[@]}"; do - if ! grep -qx "$p" "$keep_file"; then - plugin_name="${p%@*}" - marketplace="${p#*@}" - disable_skill "$plugin_name" "plugin@${marketplace}" - fi - done - rm -f "$keep_file" -} - -disable_externals_not_in() { - local prof="$1" keep_file x - keep_file="$(mktemp)" - read_profile "$prof" | awk -F'\t' '$2 == "external" { print $1 }' \ - | sort -u > "$keep_file" - for x in "${MANAGED_EXTERNALS[@]}"; do - grep -qx "$x" "$keep_file" || disable_skill "$x" external - done - rm -f "$keep_file" -} - -disable_mcps_not_in() { - local prof="$1" keep_file s - keep_file="$(mktemp)" - read_profile "$prof" | awk -F'\t' '$2 == "mcp" { print $1 }' \ - | sort -u > "$keep_file" - for s in "${MANAGED_MCPS[@]}"; do - grep -qx "$s" "$keep_file" || disable_skill "$s" mcp - done - rm -f "$keep_file" -} - -# ── Commands ────────────────────────────────────────────── - -cmd_list() { - printf "%-9s %-13s %s\n" "PROFILE" "ITEMS" "DESCRIPTION" - printf "%-9s %-13s %s\n" "-------" "-----" "-----------" - local f name desc skills pl m c contents - for f in "$PROFILES_DIR"/*.profile; do - [ -f "$f" ] || continue - name="$(basename "$f" .profile)" - desc="$(profile_desc "$f")" - read -r skills pl m c <<<"$(count_profile "$name")" - contents="$(fmt_counts compact "$skills" "$pl" "$m" "$c")" - printf "%-9s %s %s\n" "$name" "$(rpad "$contents" 13)" "${desc:--}" - done -} - -# Snapshot of a profile's entries, claude-free: "" lines, -# canonical name. A plugin's marketplace (plugin@) collapses to the -# category "plugin". -_show_entries() { - local skill type cat - while IFS=$'\t' read -r skill type; do - case "$type" in plugin@*|plugin) cat=plugin ;; *) cat="$type" ;; esac - printf '%s\t%s\n' "$cat" "$skill" - done < <(read_profile "$1") -} - -# --plain: parsable contract for the design gate. One "" -# per line, grouped by type, NO status, NO claude calls. -_show_plain() { - local entries=() cat e line - while IFS= read -r line; do entries+=("$line"); done < <(_show_entries "$1") - for cat in gstack external personal plugin mcp cli; do - for e in "${entries[@]}"; do - [ "${e%%$'\t'*}" = "$cat" ] && printf '%s\t%s\n' "$cat" "${e#*$'\t'}" - done - done - return 0 -} - -# Grouped by type, fixed order; empty groups skipped. Canonical name + -# runtime status (existing skill_status — degrades to disabled if no claude). -_show_grouped() { - local entries=() cat e line names skill status - while IFS= read -r line; do entries+=("$line"); done < <(_show_entries "$1") - for cat in gstack external personal plugin mcp cli; do - names=() - for e in "${entries[@]}"; do - [ "${e%%$'\t'*}" = "$cat" ] && names+=("${e#*$'\t'}") - done - [ "${#names[@]}" -eq 0 ] && continue - printf '%s (%d):\n' "$cat" "${#names[@]}" - for skill in "${names[@]}"; do - status="$(skill_status "$skill" "$cat")" - printf ' %-24s %s\n' "$skill" "$status" - done - done - return 0 -} - -cmd_show() { - local prof="$1" plain=0 - [ "${2:-}" = "--plain" ] && plain=1 - local file="$PROFILES_DIR/$prof.profile" - [ -f "$file" ] || { err "Profile not found: $prof"; return 1; } - - if [ "$plain" -eq 1 ]; then - _show_plain "$prof" - return 0 - fi - - echo "Profile: $prof" - local desc; desc="$(profile_desc "$file")" - [ -n "$desc" ] && echo "Description: $desc" - local skills pl m c total - read -r skills pl m c <<<"$(count_profile "$prof")" - total=$((skills + pl + m + c)) - if [ "$total" -eq 0 ]; then - echo "Total: 0 items (empty — strips all gstack)" - else - echo "Total: $total items — $(fmt_counts long "$skills" "$pl" "$m" "$c")" - fi - echo "" - - _show_grouped "$prof" -} - -cmd_apply() { - local prof="$1" - info "Applying profile: $prof (additive — leaves other skills alone)" - local skill type - while IFS=$'\t' read -r skill type; do - enable_skill "$skill" "$type" - done < <(read_profile "$prof") - write_active "$prof" -} - -cmd_set() { - local prof="$1" - info "Setting profile: $prof (exclusive — disables non-listed gstack skills + managed plugins/externals/MCPs)" - - # Disable gstack-origin skills not in profile. - disable_gstack_not_in "$prof" - - # Disable managed plugins not in profile (PROTECTED_PLUGINS are excluded - # by disable_skill itself — belt and suspenders). - disable_plugins_not_in "$prof" - - # Symmetry (BDR-079): a profile switch also parks the managed external - # packs and unregisters the managed MCPs the new profile does not need — - # design leftovers (emil, the 21st pack…) no longer survive a `set backend`. - disable_externals_not_in "$prof" - disable_mcps_not_in "$prof" - - # Enable everything listed in the profile. - cmd_apply "$prof" -} - -cmd_reset() { - info "Resetting to the default profile: $DEFAULT_PROFILE (exclusive — enables its list, parks any non-listed gstack or managed item currently on)" - cmd_set "$DEFAULT_PROFILE" -} - -# gstack on|off — focused gstack-only toggle that keeps the active-profile -# label intact (unlike reset, which switches to the default profile). Lets -# the user layer all gstack on top of their current profile, or trim it -# back down to just what the active profile needs. -cmd_gstack() { - local action="${1:-}" - case "$action" in - on) - # Restore whatever is parked, but DON'T touch active-profile — the - # user is adding gstack on top of their current profile, not clearing it. - local parked restored - parked="$(parked_gstack_count)" - if [ "$parked" -eq 0 ]; then - info "nothing parked — gstack skills are linked per profile (set/apply/reset)" - else - restored="$(enable_all_gstack)" - ok "$restored parked gstack skills restored" - fi - ;; - off) - # Disable gstack skills not needed by the active profile. A cache - # naming a profile with no lib/profiles/.profile still errors; - # absent/empty/"none" resolve to the default profile via - # active_profile() and no longer hit that error. - local active - active="$(active_profile)" - if [ ! -f "$PROFILES_DIR/$active.profile" ]; then - err "no active profile — 'gstack off' needs one to know what to keep" - info "run: bash lib/profile.sh set then: gstack off" - return 1 - fi - info "Disabling gstack skills not in active profile: $active" - disable_gstack_not_in "$active" - ok "gstack trimmed to profile: $active" - ;; - ""|-h|--help|help) - cat <<'EOF' -profile gstack on|off — toggle gstack without losing the active-profile label - - on re-enable ALL gstack skills (keeps active-profile label) - off disable gstack skills not in the active profile -EOF - ;; - *) - err "Unknown gstack action: '$action' (use: on | off)"; return 1 ;; - esac -} - -cmd_current() { - # Label-driven (BDR-030): name active_profile() and score ONLY that - # profile — no cross-profile best-guess scan, no fast path keyed on the - # parked-gstack count (that count says nothing about which profile is on - # when gstack starts off, as it does on a real tree). - local label; label="$(active_profile)" - if [ ! -f "$PROFILES_DIR/$label.profile" ]; then - echo "$label (unknown profile — no lib/profiles/$label.profile; run: profile reset)" - return 0 - fi - - local available total pct - read -r available total <<<"$(profile_match "$label")" - pct=0 - [ "$total" -gt 0 ] && pct=$((available * 100 / total)) - local parked; parked="$(parked_gstack_count)" - - local cached; cached="$(read_cache)" - if [ -z "$cached" ] || [ "$cached" = "none" ]; then - echo "$label (default — not applied yet, ${pct}% of its items enabled; run: profile reset)" - else - echo "$label (${pct}% match, $parked gstack skills disabled)" - fi -} - -cmd_diff() { - local a="$1" b="$2" - local fa="$PROFILES_DIR/$a.profile" fb="$PROFILES_DIR/$b.profile" - [ -f "$fa" ] || { err "Profile not found: $a"; return 1; } - [ -f "$fb" ] || { err "Profile not found: $b"; return 1; } - local list_a list_b - list_a="$(mktemp)"; list_b="$(mktemp)" - read_profile "$a" | cut -f1 | sort -u > "$list_a" - read_profile "$b" | cut -f1 | sort -u > "$list_b" - echo "Only in $a:"; comm -23 "$list_a" "$list_b" | sed 's/^/ - /' - echo "Only in $b:"; comm -13 "$list_a" "$list_b" | sed 's/^/ + /' - echo "Common:" ; comm -12 "$list_a" "$list_b" | sed 's/^/ = /' - rm -f "$list_a" "$list_b" -} +SKILLS_DIR="$REPO/skills" +STATE_JQ="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)/profile-state.jq" +USER_SETTINGS="${PROFILE_USER_SETTINGS:-$HOME/.claude/settings.json}" +CLAUDE_JSON="${PROFILE_CLAUDE_JSON:-$HOME/.claude.json}" +LOCAL_REL=".claude/settings.local.json" +PROJECT="$PWD" # the project root: local settings, ~/.claude.json key +SESSION_DIR="$PWD" # the -C dir: shared project settings +die() { echo "profile: $*" >&2; exit 2; } usage() { - cat < show profile contents grouped by type + status - profile show --plain parsable type+name list (no status, no claude) - profile current report the active profile (label + match) - profile apply enable skills in profile (additive) - profile set enable only listed skills (disables rest of gstack) - profile reset go to the default profile (full): enable its list, - park non-listed gstack/managed items - profile gstack on|off toggle gstack only, keep active-profile label - profile diff compare two profiles - -PROFILES (in $PROFILES_DIR): -EOF - local f name desc - for f in "$PROFILES_DIR"/*.profile; do - [ -f "$f" ] || continue - name="$(basename "$f" .profile)" - desc="$(profile_desc "$f")" - printf " %-10s %s\n" "$name" "${desc:--}" - done - cat <" yourself. -EOF + sed -n '/^# Usage:/,/^#$/p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,2\}//' >&2 + exit 2 } -main() { - local cmd="${1:-}" - case "$cmd" in - list) cmd_list ;; - show) [ $# -ge 2 ] || { usage; exit 1; }; cmd_show "$2" "${3:-}" ;; - current) cmd_current ;; - apply) [ $# -ge 2 ] || { usage; exit 1; }; cmd_apply "$2" ;; - set) [ $# -ge 2 ] || { usage; exit 1; }; cmd_set "$2" ;; - reset) cmd_reset ;; - gstack) cmd_gstack "${2:-}" ;; - diff) [ $# -ge 3 ] || { usage; exit 1; }; cmd_diff "$2" "$3" ;; - ""|-h|--help|help) usage ;; - *) err "Unknown command: $cmd"; usage; exit 1 ;; +# ---- project root ---------------------------------------------------------- +NAME_RE='^[a-z0-9][a-z0-9-]*$' +PACK_RE='^[A-Za-z0-9][A-Za-z0-9@._:-]*$' +require_name() { # $1 value, $2 regex, $3 label: refuse before any path use + [[ "$1" =~ $2 ]] || die "invalid $3 '$1'" +} +home_or_above() { # $1 dir + [ "$1" = / ] && return 0 + case "$HOME/" in "$1"/*) return 0 ;; esac + return 1 +} +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 \ + 2>/dev/null)" || return 1 + [ "$(basename "$common")" = .git ] || return 1 + root="$(dirname "$common")" + home_or_above "$root" && return 1 + echo "$root" +} +find_root() { # $1 dir → the project root (see header) + local d="$1" + git_root "$d" && return 0 + while [ "$d" != / ] && [ "$d" != "$HOME" ]; do + if [ -d "$d/.claude" ] || [ -f "$d/CLAUDE.md" ] || [ -e "$d/.git" ]; then + echo "$d"; return 0 + fi + d="$(dirname "$d")" + done + echo "$1" +} +require_project_root() { + [ -f "$PROJECT/CLAUDE.md" ] || [ -e "$PROJECT/.git" ] \ + || die "not a project root (no CLAUDE.md and no .git): $PROJECT" +} + +# ---- inputs ---------------------------------------------------------------- +profile_file() { echo "$PROFILES_DIR/$1.json"; } +profile_names() { + local f + for f in "$PROFILES_DIR"/*.json; do [ -f "$f" ] && basename "$f" .json; done + return 0 +} +profile_desc() { # the `- **name**: text` line of lib/profiles/README.md + sed -n "s/^- \*\*$1\*\*: //p" "$PROFILES_DIR/README.md" 2>/dev/null | head -1 +} +managed_ids() { + jq -r '.enabledPlugins | keys[]' "$PROFILES_DIR"/*.json | sort -u +} +managed_connectors() { + jq -r '(.deniedMcpServers // [])[] | .serverName' "$PROFILES_DIR"/*.json \ + | sort -u +} +as_json_list() { jq -Rn '[inputs]'; } # stdin lines → JSON string array +json_or_empty() { # $1 file → its JSON, {} when absent; rc 2 when invalid + [ -f "$1" ] || { echo '{}'; return 0; } + jq -c . "$1" 2>/dev/null || return 2 +} +read_local() { + json_or_empty "$PROJECT/$LOCAL_REL" \ + || die "$LOCAL_REL is not valid JSON, nothing written" +} +pack_default() { # $1 id → true | false | missing (manifest defaultEnabled) + local m="$SKILLS_DIR/${1%@skills-dir}/.claude-plugin/plugin.json" + [ -f "$m" ] || { echo missing; return 0; } + jq -r 'if .defaultEnabled == false then "false" else "true" end' "$m" +} +manifests_json() { # [{id, on}] for every pack manifest, [] when none + jq -cn '[inputs | {id: (.name + "@skills-dir"), + on: (.defaultEnabled != false)}]' \ + "$SKILLS_DIR"/pack-*/.claude-plugin/plugin.json 2>/dev/null || echo '[]' +} +have_flag() { + [ -n "${CLAUDE_PROFILE_SETTINGS:-}" ] && [ -f "$CLAUDE_PROFILE_SETTINGS" ] +} +raw_or_null() { # $1 file → the path, or /dev/null when absent or unset + if [ -n "$1" ] && [ -f "$1" ]; then echo "$1"; else echo /dev/null; fi +} + +# ---- effective state: two jq calls ----------------------------------------- +state() { # $1 mode: plain | human | json + local hasflag=0; have_flag && hasflag=1 + jq -rn --arg mode "$1" --arg proj "$PROJECT" --arg hasflag "$hasflag" \ + --arg flagname "${CLAUDE_PROFILE:--}" \ + --rawfile u "$(raw_or_null "$USER_SETTINGS")" \ + --rawfile p "$(raw_or_null "$SESSION_DIR/.claude/settings.json")" \ + --rawfile l "$(raw_or_null "$PROJECT/$LOCAL_REL")" \ + --rawfile f "$(raw_or_null "${CLAUDE_PROFILE_SETTINGS:-}")" \ + --rawfile cj "$(raw_or_null "$CLAUDE_JSON")" \ + --argjson m "$(manifests_json)" -f "$STATE_JQ" "$PROFILES_DIR"/*.json +} + +# ---- commands --------------------------------------------------------------- +unknown_profile() { + echo "profile: unknown profile '$1'. Known:" >&2; cmd_list >&2; exit 2 +} +cmd_list() { + local n d + for n in $(profile_names); do + d="$(profile_desc "$n")" + printf '%-10s %s\n' "$n" "${d:-(no line in lib/profiles/README.md)}" + done +} +cmd_show() { + local f id v tag + require_name "$1" "$NAME_RE" "profile name" + f="$(profile_file "$1")"; [ -f "$f" ] || unknown_profile "$1" + echo "profile $1: $(profile_desc "$1")" + for id in $(jq -r '.enabledPlugins | keys[]' "$f"); do + v="$(jq -r --arg k "$id" '.enabledPlugins[$k] + | if . then "on" else "off" end' "$f")" + tag="" + case "$id" in pack-*@skills-dir) + [ "$(pack_default "$id")" = missing ] \ + && tag=" missing (no skills/${id%@skills-dir}/)" ;; + esac + printf ' %-42s %s%s\n' "$id" "$v" "$tag" + done + echo " connectors denied: $(jq -r '(.deniedMcpServers // []) + | if length == 0 then "none" else map(.serverName) | join(", ") end' "$f")" + echo " model: $(jq -r '.model // "-"' "$f")" +} +cmd_current() { + if [ "${1:-}" = "--plain" ]; then state plain; else state human; fi +} +write_local() { # $1 JSON → atomic replace of the local settings + local tmp + mkdir -p "$PROJECT/.claude" + tmp="$(mktemp "$PROJECT/.claude/.settings.local.XXXXXX")" + jq . <<<"$1" > "$tmp" && mv -f "$tmp" "$PROJECT/$LOCAL_REL" +} +after_write_hint() { + echo "next: /reload-plugins loads the packs in this session;" \ + "connectors and model apply to the next session" + if have_flag; then + echo "note: this conversation runs --settings ${CLAUDE_PROFILE:-?}:" \ + "the flag fragment fixes every managed key, so this write applies to" \ + "other sessions only; relaunch: cc " + fi +} +cmd_set() { + local f cur new + require_name "$1" "$NAME_RE" "profile name" + f="$(profile_file "$1")"; [ -f "$f" ] || unknown_profile "$1" + require_project_root; cur="$(read_local)" + new="$(jq --slurpfile p "$f" \ + --argjson names "$(managed_connectors | as_json_list)" ' + . as $cur | $p[0] as $p + | .enabledPlugins = (($cur.enabledPlugins // {}) + $p.enabledPlugins) + | .deniedMcpServers = ([($cur.deniedMcpServers // [])[] + | select(.serverName as $s | ($names | index($s)) == null)] + + ($p.deniedMcpServers // [])) + | if (.deniedMcpServers | length) == 0 then del(.deniedMcpServers) + else . end + | if $p.model then .model = $p.model else . end' <<<"$cur")" + write_local "$new" + echo "profile $1 → $LOCAL_REL"; after_write_hint +} +cmd_unset() { + local cur name pm new + require_project_root; cur="$(read_local)" + name="$(CLAUDE_PROFILE_SETTINGS='' state json | jq -r .name)" + pm="-" + [ "$name" != custom ] \ + && pm="$(jq -r '.model // "-"' "$(profile_file "$name")")" + new="$(jq --argjson ids "$(managed_ids | as_json_list)" \ + --argjson names "$(managed_connectors | as_json_list)" --arg pm "$pm" ' + .enabledPlugins = ((.enabledPlugins // {}) + | with_entries(select(.key as $k | ($ids | index($k)) == null))) + | if (.enabledPlugins | length) == 0 then del(.enabledPlugins) else . end + | .deniedMcpServers = [(.deniedMcpServers // [])[] + | select(.serverName as $s | ($names | index($s)) == null)] + | if (.deniedMcpServers | length) == 0 then del(.deniedMcpServers) + else . end + | if $pm != "-" and .model == $pm then del(.model) else . end' <<<"$cur")" + if [ "$(jq -c . <<<"$new")" = "$cur" ]; then + echo "nothing to unset in $LOCAL_REL (was: $name)"; return 0 + fi + write_local "$new" + echo "profile keys removed from $LOCAL_REL (was: $name)"; after_write_hint +} +resolve_id() { # design | pack-design | pack-design@skills-dir | + case "$1" in + *@*) echo "$1" ;; + pack-*) echo "$1@skills-dir" ;; + *) echo "pack-$1@skills-dir" ;; esac } +cmd_toggle() { # $1 true|false, $2 pack or plugin spelling + local id cur new + require_name "$2" "$PACK_RE" "pack or plugin name" + id="$(resolve_id "$2")" + managed_ids | grep -qxF -- "$id" \ + || die "unknown pack or plugin '$2' (known: $(managed_ids | tr '\n' ' '))" + require_project_root; cur="$(read_local)" + new="$(jq --arg id "$id" --argjson v "$1" \ + '.enabledPlugins = ((.enabledPlugins // {}) + {($id): $v})' <<<"$cur")" + write_local "$new" + echo "$id=$1 → $LOCAL_REL"; after_write_hint +} +cmd_diff() { + local f out + require_name "$1" "$NAME_RE" "profile name" + f="$(profile_file "$1")"; [ -f "$f" ] || unknown_profile "$1" + out="$(jq -r --argjson e "$(state json)" ' + def onoff: if . then "on" else "off" end; + (.enabledPlugins | to_entries[] | select($e.plugins[.key] != .value) + | .key + ": " + ($e.plugins[.key] | onoff) + " → " + (.value | onoff)), + (([(.deniedMcpServers // [])[] | .serverName] | sort) as $want + | ($e.managed_denied | sort) as $have + | if $want == $have then empty + else "connectors denied: " + ($have | join(", ")) + " → " + + ($want | join(", ")) end), + (if .model != null and .model != $e.model + then "model: " + $e.model + " → " + (.model // "-") + else empty end)' "$f")" + if [ -n "$out" ]; then echo "$out"; else echo "no difference from $1"; fi +} -main "$@" +# ---- main -------------------------------------------------------------------- +command -v jq >/dev/null 2>&1 || die "jq is required" +while [ $# -gt 0 ]; do + case "$1" in + -C) [ -n "${2:-}" ] || usage + PROJECT="$(cd "$2" 2>/dev/null && pwd)" || die "no such dir: $2" + shift 2 ;; + *) break ;; + esac +done +SESSION_DIR="$PROJECT" +PROJECT="$(find_root "$PROJECT")" +case "${1:-}" in + list) cmd_list ;; + show) [ -n "${2:-}" ] || usage; cmd_show "$2" ;; + current) cmd_current "${2:-}" ;; + set) [ -n "${2:-}" ] || usage; cmd_set "$2" ;; + unset) cmd_unset ;; + enable) [ -n "${2:-}" ] || usage; cmd_toggle true "$2" ;; + disable) [ -n "${2:-}" ] || usage; cmd_toggle false "$2" ;; + diff) [ -n "${2:-}" ] || usage; cmd_diff "$2" ;; + *) usage ;; +esac diff --git a/lib/profiles/README.md b/lib/profiles/README.md new file mode 100644 index 0000000..62d69b4 --- /dev/null +++ b/lib/profiles/README.md @@ -0,0 +1,32 @@ +# Profiles + +A profile is a literal Claude Code settings fragment: `enabledPlugins` +(every pack `pack-@skills-dir` and managed plugin, explicit), optional +`deniedMcpServers` (the two higgsfield claude.ai connectors), optional +`model`. Per project: `bash ~/.claude/lib/profile.sh set ` writes it +into `.claude/settings.local.json`, then `/reload-plugins`. Per +conversation: `cc ` (lib/cc.sh) runs +`claude --settings lib/profiles/.json`; that conversation is frozen +(no reload brings a pack back; relaunch instead). No profile = the manifest +defaults = `full` with the connectors present. `deniedMcpServers` is a union +across files: a `cc x web` over a project set to `dev` keeps the connectors +denied; `set web` in the project brings them back next session. + +`profile.sh list` reads these lines (format `- **name**: text`): + +- **full**: every pack except higgsfield and extras; ui-ux-pro-max on; connectors present. The default. +- **max**: everything on, pr-review-toolkit included; for a one-off session, not a project. +- **minimal**: no pack, no design plugin, connectors denied; the smallest listing. +- **dev**: gstack-dev only; backend or tooling work without UI. +- **design**: design, scroll3d, gstack-design, gstack-browser, ui-ux-pro-max; connectors present. +- **web**: design + scroll3d + web-validate + the three gstack packs + ui-ux-pro-max; public site work. +- **seo**: seo, web-validate, gstack-browser, gstack-dev; audit and fixes on a live site. +- **qa**: gstack-browser + web-validate; dogfooding and conformance only. +- **audit**: seo, web-validate, gstack-dev, gstack-browser, pr-review-toolkit; read-mostly audits. + +Invariants (checked by `lib/pack-census.sh`): the same key set in every +fragment; `model-router@skills-dir` and `security-guidance@claude-code-plugins` +true everywhere; `example-skills@anthropic-agent-skills` and +`brightdata-plugin@synced` false everywhere; the connectors denied on exactly +minimal, dev, seo, qa, audit; `full` equal to the manifest defaults. +Add your own profile as another `.json` with the same key set. diff --git a/lib/profiles/audit.json b/lib/profiles/audit.json new file mode 100644 index 0000000..30ccb0f --- /dev/null +++ b/lib/profiles/audit.json @@ -0,0 +1,27 @@ +{ + "enabledPlugins": { + "model-router@skills-dir": true, + "pack-design@skills-dir": false, + "pack-scroll3d@skills-dir": false, + "pack-seo@skills-dir": true, + "pack-web-validate@skills-dir": true, + "pack-gstack-dev@skills-dir": true, + "pack-gstack-browser@skills-dir": true, + "pack-gstack-design@skills-dir": false, + "pack-higgsfield@skills-dir": false, + "pack-extras@skills-dir": false, + "ui-ux-pro-max@ui-ux-pro-max-skill": false, + "security-guidance@claude-code-plugins": true, + "pr-review-toolkit@claude-code-plugins": true, + "example-skills@anthropic-agent-skills": false, + "brightdata-plugin@synced": false + }, + "deniedMcpServers": [ + { + "serverName": "claude.ai higgsfield" + }, + { + "serverName": "claude.ai Higgsfield AI" + } + ] +} diff --git a/lib/profiles/audit.profile b/lib/profiles/audit.profile deleted file mode 100644 index 61d8602..0000000 --- a/lib/profiles/audit.profile +++ /dev/null @@ -1,30 +0,0 @@ -# DESC: Comprehensive audit — security + SEO + GEO + W3C + perf + health -# Activate when: doing a top-to-bottom audit pass on an existing project. -# Wider than `seo` (adds security + dependency review). - -# Security -cso -harden personal -guardrails personal -a11y personal -analyze personal - -# SEO / GEO / web standards -seo personal -geo personal -web-validate personal - -# Code + perf health -health -benchmark -review - -# Browser tooling for live audits -browse -open-gstack-browser - -# Plugin: PR review toolkit (audit context for diffs) -pr-review-toolkit plugin@claude-code-plugins - -# CLI: graphify for code structure -graphify cli diff --git a/lib/profiles/backend.profile b/lib/profiles/backend.profile deleted file mode 100644 index a59697f..0000000 --- a/lib/profiles/backend.profile +++ /dev/null @@ -1,44 +0,0 @@ -# DESC: Backend / API / system dev — no design, no SEO, focused on logic -# Activate when: building backend services, APIs, CLIs, libraries, system -# code, data pipelines. UI/visual work is out of scope. SEO/GEO out of scope. - -# Code work — primary -feat personal -ship-feature personal -hotfix personal -bugfix personal -investigate -refactor personal -code-clean personal -commit-change personal -analyze personal - -# Dev-lifecycle skills (agent-skills trio) -observability-and-instrumentation external -deprecation-and-migration external -ci-cd-and-automation external - -# Review -review - -# Second opinion for hard problems -codex - -# Security + health (always relevant for backend) -cso -guardrails personal -health - -# Session hygiene -freeze -unfreeze -retro - -# pr-review-toolkit removed (audit 2026-07-02 #12 — ~2.2k tokens, PR-only): -# enable per PR session via `bash lib/profile.sh apply audit` or -# claude plugin enable pr-review-toolkit@claude-code-plugins - -# CLIs (advisory) -ctx7 cli -gsd cli -graphify cli diff --git a/lib/profiles/design.json b/lib/profiles/design.json new file mode 100644 index 0000000..736c146 --- /dev/null +++ b/lib/profiles/design.json @@ -0,0 +1,19 @@ +{ + "enabledPlugins": { + "model-router@skills-dir": true, + "pack-design@skills-dir": true, + "pack-scroll3d@skills-dir": true, + "pack-seo@skills-dir": false, + "pack-web-validate@skills-dir": false, + "pack-gstack-dev@skills-dir": false, + "pack-gstack-browser@skills-dir": true, + "pack-gstack-design@skills-dir": true, + "pack-higgsfield@skills-dir": false, + "pack-extras@skills-dir": false, + "ui-ux-pro-max@ui-ux-pro-max-skill": true, + "security-guidance@claude-code-plugins": true, + "pr-review-toolkit@claude-code-plugins": false, + "example-skills@anthropic-agent-skills": false, + "brightdata-plugin@synced": false + } +} diff --git a/lib/profiles/design.profile b/lib/profiles/design.profile deleted file mode 100644 index dc20f40..0000000 --- a/lib/profiles/design.profile +++ /dev/null @@ -1,55 +0,0 @@ -# DESC: Design work — visual QA, design systems, mockups, polish -# Activate when: building/reviewing UI, picking aesthetics, design tokens. -# Companion CLIs (advisory): graphify (visual structure). -# -# Gate scope (design-tool-gate.sh): only the tools on the GATE-BLOCK lines -# below trip the design gate. The rest of this profile (browser/plan/shotgun -# tooling, graphify) is bundled for convenience but never blocks. Keep these -# lines in sync when adding/removing a core design tool. -# GATE-BLOCK: impeccable ui-ux-pro-max emil-design-eng design-html -# GATE-BLOCK: design-motion-principles design-review design-consultation -# GATE-BLOCK: 21st 21st-ui-build - -# Core design skills (gstack) -design-review -design-consultation -design-html -plan-design-review - -# Browser tooling — design-review relies on it -browse -open-gstack-browser -setup-browser-cookies - -# Plan-mode review companion (taste decisions before code) -plan-ceo-review - -# External: design skills -emil-design-eng external -frontend-design external -design-motion-principles external -impeccable external - -# External: Mengto scroll-choreography skills (curl, commit-pinned) -scroll-world-storytelling external -build-threejs-scroll-worlds external -scroll-scrubbed-visual-sequence external -scroll-scrubbed-word-reveal external -scroll-progress-timeline external - -# Personal: motion implementation companion (skills/site-motion) -site-motion personal - -# External: 21st.dev pack — CLI-driven (no MCP, no API key). 21st-registry -# and 21st-design-sync are publishing flows; installed but left parked. -21st-ui-build external -21st-cli-use external - -# Plugin (auto-toggle) -ui-ux-pro-max plugin@ui-ux-pro-max-skill - -# CLIs (advisory only — installed/not-installed) -# 21st is NOT advisory: it is on the GATE-BLOCK list, so a missing CLI trips -# the design gate. Install: npm i -g @21st-dev/cli then 21st login -21st cli -graphify cli diff --git a/lib/profiles/dev.json b/lib/profiles/dev.json new file mode 100644 index 0000000..829bef0 --- /dev/null +++ b/lib/profiles/dev.json @@ -0,0 +1,27 @@ +{ + "enabledPlugins": { + "model-router@skills-dir": true, + "pack-design@skills-dir": false, + "pack-scroll3d@skills-dir": false, + "pack-seo@skills-dir": false, + "pack-web-validate@skills-dir": false, + "pack-gstack-dev@skills-dir": true, + "pack-gstack-browser@skills-dir": false, + "pack-gstack-design@skills-dir": false, + "pack-higgsfield@skills-dir": false, + "pack-extras@skills-dir": false, + "ui-ux-pro-max@ui-ux-pro-max-skill": false, + "security-guidance@claude-code-plugins": true, + "pr-review-toolkit@claude-code-plugins": false, + "example-skills@anthropic-agent-skills": false, + "brightdata-plugin@synced": false + }, + "deniedMcpServers": [ + { + "serverName": "claude.ai higgsfield" + }, + { + "serverName": "claude.ai Higgsfield AI" + } + ] +} diff --git a/lib/profiles/dev.profile b/lib/profiles/dev.profile deleted file mode 100644 index 300b4e0..0000000 --- a/lib/profiles/dev.profile +++ /dev/null @@ -1,27 +0,0 @@ -# DESC: Daily code work — small features, fixes, refactor, ship (any stack) -# Activate when: implementing features, debugging, shipping PRs without a -# specific frontend or backend bias. Lighter than `backend` (no security audit -# baggage) and lighter than `web` (no design pipeline). - -# Implementation -feat personal -ship-feature personal - -# Bug fixing -hotfix personal -bugfix personal -investigate - -# Code health -review -refactor personal -code-clean personal -commit-change personal -explain-diff personal -guardrails personal -a11y personal - -# Dev-lifecycle skills (agent-skills trio) -observability-and-instrumentation external -deprecation-and-migration external -ci-cd-and-automation external diff --git a/lib/profiles/full.json b/lib/profiles/full.json new file mode 100644 index 0000000..0aec36a --- /dev/null +++ b/lib/profiles/full.json @@ -0,0 +1,19 @@ +{ + "enabledPlugins": { + "model-router@skills-dir": true, + "pack-design@skills-dir": true, + "pack-scroll3d@skills-dir": true, + "pack-seo@skills-dir": true, + "pack-web-validate@skills-dir": true, + "pack-gstack-dev@skills-dir": true, + "pack-gstack-browser@skills-dir": true, + "pack-gstack-design@skills-dir": true, + "pack-higgsfield@skills-dir": false, + "pack-extras@skills-dir": false, + "ui-ux-pro-max@ui-ux-pro-max-skill": true, + "security-guidance@claude-code-plugins": true, + "pr-review-toolkit@claude-code-plugins": false, + "example-skills@anthropic-agent-skills": false, + "brightdata-plugin@synced": false + } +} diff --git a/lib/profiles/full.profile b/lib/profiles/full.profile deleted file mode 100644 index b792eef..0000000 --- a/lib/profiles/full.profile +++ /dev/null @@ -1,104 +0,0 @@ -# DESC: Default profile — carries everything every other profile carries -# (user rule 2026-09-28: full does what each profile does), minus the -# broken or doctrine-breaking gstack skills (lib/gstack-removed.sh) and -# the parked tools (make-pdf, diagram, 21st-ai/ui-explore/ui-review) that -# live in `max`. One named exception: pr-review-toolkit (see below). - -# === Brainstorm + plan-mode reviews ================================== -office-hours -plan-ceo-review -plan-eng-review -plan-design-review -plan-devex-review -spec - -# === Design pipeline ================================================= -design-review -design-consultation -design-html - -# === Browser + dogfooding ============================================ -browse -open-gstack-browser -setup-browser-cookies -scrape -skillify - -# === Code work — implementation ====================================== -feat personal -ship-feature personal -hotfix personal -bugfix personal -investigate -refactor personal -code-clean personal -commit-change personal - -# === Review =========================================================== -review - -# === Second opinion ================================================== -codex - -# === SEO / GEO / standards / security ================================ -seo personal -geo personal -web-validate personal -harden personal -guardrails personal -a11y personal -analyze personal -cso - -# === Perf + canary + QA ============================================== -health -benchmark -canary -qa -qa-only - -# === Docs + translation ============================================== -doc personal -document-release -pdf-translate personal -explain-diff personal - -# === Session hygiene + memory ======================================== -close personal -prune-memory personal -status personal -retro -freeze -unfreeze - -# === External + plugin + MCP ========================================= -emil-design-eng external -frontend-design external -design-motion-principles external -impeccable external -observability-and-instrumentation external -deprecation-and-migration external -ci-cd-and-automation external -scroll-world-storytelling external -build-threejs-scroll-worlds external -scroll-scrubbed-visual-sequence external -scroll-scrubbed-word-reveal external -scroll-progress-timeline external -ui-ux-pro-max plugin@ui-ux-pro-max-skill -# pr-review-toolkit REMOVED from full (audit 2026-07-02 #12): heaviest -# single plugin cost (~2.2k tokens of agent descriptions/session), useful -# only when reviewing PRs. Reactivate per PR session: -# claude plugin enable pr-review-toolkit@claude-code-plugins -# or profile-based: bash lib/profile.sh apply audit (audit.profile keeps it; -# a later `set full` re-disables it — MANAGED_PLUGINS lifecycle). -21st-ui-build external -21st-cli-use external - -# Personal: motion implementation companion (skills/site-motion) -site-motion personal - -# === CLIs (advisory) ================================================= -21st cli -ctx7 cli -graphify cli -gsd cli diff --git a/lib/profiles/max.json b/lib/profiles/max.json new file mode 100644 index 0000000..040c594 --- /dev/null +++ b/lib/profiles/max.json @@ -0,0 +1,19 @@ +{ + "enabledPlugins": { + "model-router@skills-dir": true, + "pack-design@skills-dir": true, + "pack-scroll3d@skills-dir": true, + "pack-seo@skills-dir": true, + "pack-web-validate@skills-dir": true, + "pack-gstack-dev@skills-dir": true, + "pack-gstack-browser@skills-dir": true, + "pack-gstack-design@skills-dir": true, + "pack-higgsfield@skills-dir": true, + "pack-extras@skills-dir": true, + "ui-ux-pro-max@ui-ux-pro-max-skill": true, + "security-guidance@claude-code-plugins": true, + "pr-review-toolkit@claude-code-plugins": true, + "example-skills@anthropic-agent-skills": false, + "brightdata-plugin@synced": false + } +} diff --git a/lib/profiles/max.profile b/lib/profiles/max.profile deleted file mode 100644 index 2792c78..0000000 --- a/lib/profiles/max.profile +++ /dev/null @@ -1,105 +0,0 @@ -# DESC: Everything — full + the parked generation/review tools + PR review -# SUPERSET-OF: full -# Activate when: you need make-pdf, diagram, the 21st-ai/ui-explore/ -# ui-review generation trio, or pr-review-toolkit, on top of everything -# full carries. Never a broken or doctrine-breaking gstack skill -# (lib/gstack-removed.sh) — max is full's superset, not the raw catalog. - -# === Brainstorm + plan-mode reviews ================================== -office-hours -plan-ceo-review -plan-eng-review -plan-design-review -plan-devex-review -spec - -# === Design pipeline ================================================= -design-review -design-consultation -design-html - -# === Browser + dogfooding ============================================ -browse -open-gstack-browser -setup-browser-cookies -scrape -skillify - -# === Code work — implementation ====================================== -feat personal -ship-feature personal -hotfix personal -bugfix personal -investigate -refactor personal -code-clean personal -commit-change personal - -# === Review =========================================================== -review - -# === Second opinion ================================================== -codex - -# === SEO / GEO / standards / security ================================ -seo personal -geo personal -web-validate personal -harden personal -guardrails personal -a11y personal -analyze personal -cso - -# === Perf + canary + QA ============================================== -health -benchmark -canary -qa -qa-only - -# === Docs + translation ============================================== -doc personal -document-release -diagram -make-pdf -pdf-translate personal -explain-diff personal - -# === Session hygiene + memory ======================================== -close personal -prune-memory personal -status personal -retro -freeze -unfreeze - -# === External + plugin + MCP ========================================= -emil-design-eng external -frontend-design external -design-motion-principles external -impeccable external -observability-and-instrumentation external -deprecation-and-migration external -ci-cd-and-automation external -scroll-world-storytelling external -build-threejs-scroll-worlds external -scroll-scrubbed-visual-sequence external -scroll-scrubbed-word-reveal external -scroll-progress-timeline external -ui-ux-pro-max plugin@ui-ux-pro-max-skill -pr-review-toolkit plugin@claude-code-plugins -21st-ui-build external -21st-ui-explore external -21st-ui-review external -21st-cli-use external -21st-ai external - -# Personal: motion implementation companion (skills/site-motion) -site-motion personal - -# === CLIs (advisory) ================================================= -21st cli -ctx7 cli -graphify cli -gsd cli diff --git a/lib/profiles/minimal.json b/lib/profiles/minimal.json new file mode 100644 index 0000000..d98652a --- /dev/null +++ b/lib/profiles/minimal.json @@ -0,0 +1,27 @@ +{ + "enabledPlugins": { + "model-router@skills-dir": true, + "pack-design@skills-dir": false, + "pack-scroll3d@skills-dir": false, + "pack-seo@skills-dir": false, + "pack-web-validate@skills-dir": false, + "pack-gstack-dev@skills-dir": false, + "pack-gstack-browser@skills-dir": false, + "pack-gstack-design@skills-dir": false, + "pack-higgsfield@skills-dir": false, + "pack-extras@skills-dir": false, + "ui-ux-pro-max@ui-ux-pro-max-skill": false, + "security-guidance@claude-code-plugins": true, + "pr-review-toolkit@claude-code-plugins": false, + "example-skills@anthropic-agent-skills": false, + "brightdata-plugin@synced": false + }, + "deniedMcpServers": [ + { + "serverName": "claude.ai higgsfield" + }, + { + "serverName": "claude.ai Higgsfield AI" + } + ] +} diff --git a/lib/profiles/minimal.profile b/lib/profiles/minimal.profile deleted file mode 100644 index fe4e0e2..0000000 --- a/lib/profiles/minimal.profile +++ /dev/null @@ -1,7 +0,0 @@ -# DESC: Strip all gstack skills (only essential personal skills + plugins remain) -# Activate when: you want a quiet session with no gstack noise. -# -# Empty by design — `profile set minimal` disables every gstack skill, -# leaves personal skills (analyze, doc, init-project, onboard, plugin-check, -# refactor, seo, validate, harden, etc.) untouched, and makes no plugin/MCP -# changes. To revert: `profile reset`. diff --git a/lib/profiles/qa.json b/lib/profiles/qa.json new file mode 100644 index 0000000..c8c7319 --- /dev/null +++ b/lib/profiles/qa.json @@ -0,0 +1,27 @@ +{ + "enabledPlugins": { + "model-router@skills-dir": true, + "pack-design@skills-dir": false, + "pack-scroll3d@skills-dir": false, + "pack-seo@skills-dir": false, + "pack-web-validate@skills-dir": true, + "pack-gstack-dev@skills-dir": false, + "pack-gstack-browser@skills-dir": true, + "pack-gstack-design@skills-dir": false, + "pack-higgsfield@skills-dir": false, + "pack-extras@skills-dir": false, + "ui-ux-pro-max@ui-ux-pro-max-skill": false, + "security-guidance@claude-code-plugins": true, + "pr-review-toolkit@claude-code-plugins": false, + "example-skills@anthropic-agent-skills": false, + "brightdata-plugin@synced": false + }, + "deniedMcpServers": [ + { + "serverName": "claude.ai higgsfield" + }, + { + "serverName": "claude.ai Higgsfield AI" + } + ] +} diff --git a/lib/profiles/qa.profile b/lib/profiles/qa.profile deleted file mode 100644 index 1158322..0000000 --- a/lib/profiles/qa.profile +++ /dev/null @@ -1,11 +0,0 @@ -# DESC: QA + testing — site checks, perf, canary, validation -# Activate when: running QA, checking deployed pages, perf regressions. - -qa -qa-only -browse -benchmark -canary -web-validate personal -open-gstack-browser -setup-browser-cookies diff --git a/lib/profiles/seo.json b/lib/profiles/seo.json new file mode 100644 index 0000000..0b93d92 --- /dev/null +++ b/lib/profiles/seo.json @@ -0,0 +1,27 @@ +{ + "enabledPlugins": { + "model-router@skills-dir": true, + "pack-design@skills-dir": false, + "pack-scroll3d@skills-dir": false, + "pack-seo@skills-dir": true, + "pack-web-validate@skills-dir": true, + "pack-gstack-dev@skills-dir": true, + "pack-gstack-browser@skills-dir": true, + "pack-gstack-design@skills-dir": false, + "pack-higgsfield@skills-dir": false, + "pack-extras@skills-dir": false, + "ui-ux-pro-max@ui-ux-pro-max-skill": false, + "security-guidance@claude-code-plugins": true, + "pr-review-toolkit@claude-code-plugins": false, + "example-skills@anthropic-agent-skills": false, + "brightdata-plugin@synced": false + }, + "deniedMcpServers": [ + { + "serverName": "claude.ai higgsfield" + }, + { + "serverName": "claude.ai Higgsfield AI" + } + ] +} diff --git a/lib/profiles/seo.profile b/lib/profiles/seo.profile deleted file mode 100644 index 09bb8b5..0000000 --- a/lib/profiles/seo.profile +++ /dev/null @@ -1,25 +0,0 @@ -# DESC: SEO + GEO + W3C audit — search/AI indexability + standards -# Activate when: auditing a site for Google/Bing indexability, AI search -# (ChatGPT/Perplexity/Claude/Gemini), W3C HTML/CSS validity, WCAG a11y. -# No design skills, no dev skills — pure audit pipeline. - -# SEO + GEO audits (personal) -seo personal -geo personal - -# W3C HTML/CSS validity + WCAG a11y -web-validate personal - -# Web hardening (HSTS, CSP, redirects — affects ranking signals) -harden personal - -# Code analysis (read structure for audit) -analyze personal - -# Browser tooling — needed for live-page audits -browse -open-gstack-browser - -# Health check + benchmark — Core Web Vitals, perf signals -health # gstack -benchmark # gstack diff --git a/lib/profiles/web-full.profile b/lib/profiles/web-full.profile deleted file mode 100644 index 1c49fcf..0000000 --- a/lib/profiles/web-full.profile +++ /dev/null @@ -1,66 +0,0 @@ -# DESC: Production website — design + dev + SEO + GEO + W3C + perf -# Activate when: shipping a public website end-to-end. Combines `web` -# and `seo` profiles into a single set so the same session can build, -# polish, audit, and verify. - -# === Design =========================================================== -design-review -design-consultation -design-html -plan-design-review - -# === Browser + dogfooding ============================================= -browse -open-gstack-browser -setup-browser-cookies - -# === Plan-mode reviews ================================================ -plan-ceo-review -plan-eng-review -spec - -# === Code work ======================================================== -feat personal -ship-feature personal -hotfix personal -bugfix personal -review -commit-change personal -refactor personal - -# === SEO / GEO / standards =========================================== -seo personal -geo personal -web-validate personal -harden personal -guardrails personal -a11y personal -analyze personal - -# === Perf + canary =================================================== -health -benchmark -canary -qa-only - -# === External + plugin + MCP ========================================= -emil-design-eng external -frontend-design external -design-motion-principles external -impeccable external -scroll-world-storytelling external -build-threejs-scroll-worlds external -scroll-scrubbed-visual-sequence external -scroll-scrubbed-word-reveal external -scroll-progress-timeline external -21st-ui-build external -21st-cli-use external -ui-ux-pro-max plugin@ui-ux-pro-max-skill - -# Personal: motion implementation companion (skills/site-motion) -site-motion personal - -# === CLIs ============================================================ -21st cli -ctx7 cli -graphify cli diff --git a/lib/profiles/web.json b/lib/profiles/web.json new file mode 100644 index 0000000..97e48f0 --- /dev/null +++ b/lib/profiles/web.json @@ -0,0 +1,19 @@ +{ + "enabledPlugins": { + "model-router@skills-dir": true, + "pack-design@skills-dir": true, + "pack-scroll3d@skills-dir": true, + "pack-seo@skills-dir": false, + "pack-web-validate@skills-dir": true, + "pack-gstack-dev@skills-dir": true, + "pack-gstack-browser@skills-dir": true, + "pack-gstack-design@skills-dir": true, + "pack-higgsfield@skills-dir": false, + "pack-extras@skills-dir": false, + "ui-ux-pro-max@ui-ux-pro-max-skill": true, + "security-guidance@claude-code-plugins": true, + "pr-review-toolkit@claude-code-plugins": false, + "example-skills@anthropic-agent-skills": false, + "brightdata-plugin@synced": false + } +} diff --git a/lib/profiles/web.profile b/lib/profiles/web.profile deleted file mode 100644 index 7d32538..0000000 --- a/lib/profiles/web.profile +++ /dev/null @@ -1,62 +0,0 @@ -# DESC: Public website work — frontend + content + light dev -# Activate when: building/iterating a public-facing website (landing, -# portfolio, marketing, blog) where SEO is NOT the immediate focus. -# For SEO/GEO audit on top, use web-full or apply seo afterwards. - -# Design skills (gstack) — full design pipeline -design-review -design-consultation -design-html -plan-design-review - -# Browser tooling for design + dogfooding -browse -open-gstack-browser -setup-browser-cookies - -# Plan-mode reviews relevant to web work -plan-ceo-review -plan-eng-review - -# Code work skills — needed to actually build the site -feat personal -ship-feature personal -hotfix personal -review # gstack -commit-change personal -refactor personal - -# Validation companion (basic W3C/a11y check during build) -web-validate personal -a11y personal - -# External: design skills -emil-design-eng external -frontend-design external -design-motion-principles external -impeccable external - -# External: Mengto scroll-choreography skills (curl, commit-pinned) -scroll-world-storytelling external -build-threejs-scroll-worlds external -scroll-scrubbed-visual-sequence external -scroll-scrubbed-word-reveal external -scroll-progress-timeline external - -# Personal: motion implementation companion (skills/site-motion) -site-motion personal - -# External: 21st.dev pack (publishing flows 21st-registry / -design-sync -# stay parked) -21st-ui-build external -21st-cli-use external - -# Plugin: UI/UX intelligence (auto-toggle) -ui-ux-pro-max plugin@ui-ux-pro-max-skill - -# CLI: 21st.dev component catalog + UI generation (needs `21st login`) -21st cli - -# CLI: ctx7 (doc lookup for fast-evolving libs like Next.js) -ctx7 cli -graphify cli diff --git a/lib/seo-data/seo-data.test.sh b/lib/seo-data/seo-data.test.sh index 5bbed0f..8aa6992 100644 --- a/lib/seo-data/seo-data.test.sh +++ b/lib/seo-data/seo-data.test.sh @@ -539,7 +539,7 @@ tf "gitleaks allowlist store" "$REPO/.gitleaks.toml" "seo-data/tokens" tf "gitignore venv" "$REPO/.gitignore" ".venv-seo-data" echo "── integration locks ──" -tf "skill step0 account select" "$REPO/skills/seo/SKILL.md" "COMPTE GOOGLE" +tf "skill step0 account select" "$REPO/skills/pack-seo/skills/seo/SKILL.md" "COMPTE GOOGLE" tf "analyzer calls fetch crux" "$REPO/agents/seo-analyzer.md" "fetch.sh crux" tf "analyzer calls fetch queries" "$REPO/agents/seo-analyzer.md" "fetch.sh queries" tf "analyzer gsc subsection" "$REPO/agents/seo-analyzer.md" "Performance GSC" @@ -548,10 +548,10 @@ tf "geo-analyzer wires schema_gen" "$REPO/agents/geo-analyzer.md" "fetch.sh sche tf "geo-analyzer wires content_quality" "$REPO/agents/geo-analyzer.md" "fetch.sh content_quality" echo "── account-mgmt locks ──" -tf "skill routes account verbs" "$REPO/skills/seo/SKILL.md" "forget --all" -tf "skill connect wrapper path" "$REPO/skills/seo/SKILL.md" "lib/seo-data/connect.sh" -tf "skill revocation notice" "$REPO/skills/seo/SKILL.md" "myaccount.google.com/permissions" -tf "skill label charset rule" "$REPO/skills/seo/SKILL.md" "A-Za-z0-9._-" +tf "skill routes account verbs" "$REPO/skills/pack-seo/skills/seo/SKILL.md" "forget --all" +tf "skill connect wrapper path" "$REPO/skills/pack-seo/skills/seo/SKILL.md" "lib/seo-data/connect.sh" +tf "skill revocation notice" "$REPO/skills/pack-seo/skills/seo/SKILL.md" "myaccount.google.com/permissions" +tf "skill label charset rule" "$REPO/skills/pack-seo/skills/seo/SKILL.md" "A-Za-z0-9._-" echo "── readme lock ──" tf "readme documents fetch.sh" "$REPO/lib/seo-data/README.md" "fetch.sh" diff --git a/lib/skill-routing-census.py b/lib/skill-routing-census.py index 89cb70f..dadca0e 100644 --- a/lib/skill-routing-census.py +++ b/lib/skill-routing-census.py @@ -25,6 +25,7 @@ import sys DEFAULT_ROOTS = ["~/.claude/skills", "~/.claude/plugins/cache"] ROOT_SUFFIXES = [ "*/SKILL.md", + "pack-*/skills/*/SKILL.md", "*/*/*/skills/*/SKILL.md", "*/*/*/.claude/skills/*/SKILL.md", ] diff --git a/lib/tests/cc.test.sh b/lib/tests/cc.test.sh new file mode 100644 index 0000000..e1d8d9f --- /dev/null +++ b/lib/tests/cc.test.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +# lib/tests/cc.test.sh — lib/cc.sh `cc [profile]`: unknown profile → +# list + rc 2, no session; a profile → claude --settings with +# CLAUDE_PROFILE / CLAUDE_PROFILE_SETTINGS / TMPDIR exported through +# systemd-run + dtach; no profile → plain claude, TMPDIR still set; .env +# sourced. Hermetic: PATH shims, HOME in a fixture holding .claude/lib. +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/bin" "$FX/home/.claude/lib/profiles" +cp "$ROOT/lib/cc.sh" "$ROOT/lib/profile.sh" "$FX/home/.claude/lib/" +printf '{"enabledPlugins": {"x@skills-dir": true}}\n' > "$FX/home/.claude/lib/profiles/webx.json" +printf -- '- **webx**: web fixture\n' > "$FX/home/.claude/lib/profiles/README.md" +cat > "$FX/bin/systemd-run" <<'EOT' +#!/usr/bin/env bash +while [ $# -gt 0 ]; do case "$1" in --*) shift ;; *) break ;; esac; done +echo "systemd-run" >> "$CC_LOG"; exec "$@" +EOT +cat > "$FX/bin/dtach" <<'EOT' +#!/usr/bin/env bash +while [ $# -gt 0 ]; do case "$1" in -c|-e) shift 2 ;; *) break ;; esac; done +echo "dtach" >> "$CC_LOG"; exec "$@" +EOT +cat > "$FX/bin/claude" <<'EOT' +#!/usr/bin/env bash +{ echo "claude argv: $*"; echo "CLAUDE_PROFILE=${CLAUDE_PROFILE-unset}" + echo "CLAUDE_PROFILE_SETTINGS=${CLAUDE_PROFILE_SETTINGS-unset}" + echo "TMPDIR=${TMPDIR-unset}"; echo "canary=${CC_ENV_CANARY-unset}"; } >> "$CC_LOG" +EOT +chmod +x "$FX/bin/"* +export CC_LOG="$FX/log" HOME="$FX/home" +PATH="$FX/bin:$PATH" +# shellcheck disable=SC1091 +. "$FX/home/.claude/lib/cc.sh" + +: > "$CC_LOG"; out="$(cc s1 nope 2>&1)"; rc=$? +check T1-unknown-rc "$rc" 2; check_has T1-unknown-msg "$out" "cc: unknown profile 'nope'" +check_has T1-unknown-list "$out" "webx"; check T1-no-session "$(cat "$CC_LOG")" "" + +: > "$CC_LOG"; cc s2 webx; rc=$?; log="$(cat "$CC_LOG")" +check T2-rc "$rc" 0; check_has T2-chain "$log" "systemd-run"; check_has T2-dtach "$log" "dtach" +check_has T2-argv "$log" "claude argv: --settings $FX/home/.claude/lib/profiles/webx.json" +check_has T2-profile "$log" "CLAUDE_PROFILE=webx" +check_has T2-settings "$log" "CLAUDE_PROFILE_SETTINGS=$FX/home/.claude/lib/profiles/webx.json" +check_has T2-tmpdir "$log" "TMPDIR=$FX/home/.cache/claude-tmp" +check T2-tmpdir-exists "$([ -d "$FX/home/.cache/claude-tmp" ] && echo yes)" yes + +: > "$CC_LOG"; cc s3; rc=$?; log="$(cat "$CC_LOG")" +check T3-rc "$rc" 0; check_has T3-argv "$log" "claude argv: "$'\n' +check_has T3-profile-empty "$log" "CLAUDE_PROFILE="$'\n' +check_has T3-tmpdir "$log" "TMPDIR=$FX/home/.cache/claude-tmp" + +# name allowlist: a path-like name or profile starts no session +for args in "x ../y" "../x webx" "x web/x" "-x webx"; do + : > "$CC_LOG" + # shellcheck disable=SC2086 + out="$(cc $args 2>&1)"; rc=$? + check "T6-rc-$args" "$rc" 2; check_has "T6-msg-$args" "$out" "cc: invalid" + check "T6-no-session-$args" "$(cat "$CC_LOG")" "" +done + +printf 'CC_ENV_CANARY=1\n' > "$FX/home/.claude/.env" +: > "$CC_LOG"; cc s4 webx; check_has T4-env "$(cat "$CC_LOG")" "canary=1" +check T5-shellcheck "$(shellcheck "$ROOT/lib/cc.sh" >/dev/null 2>&1 && echo ok)" ok +printf 'PASS=%s FAIL=%s\n' "$pass" "$fail"; [ "$fail" -eq 0 ] diff --git a/lib/tests/design-tool-gate.test.sh b/lib/tests/design-tool-gate.test.sh index 83a92b0..72a7130 100755 --- a/lib/tests/design-tool-gate.test.sh +++ b/lib/tests/design-tool-gate.test.sh @@ -1,22 +1,16 @@ #!/usr/bin/env bash -# lib/tests/design-tool-gate.test.sh — hermetic suite for the 21st sign-in -# state added to lib/design-tool-gate.sh (contract 2026-09-28-21st-signin- -# gate-1215): a fake `21st` CLI on a fixture PATH drives every whoami answer -# (signed in / signed out / garbage / nonzero rc) through the real gate -# script, with HOME and PATH redirected into the fixture so the machine's -# real CLI is never reachable. A loud precondition proves that redirection -# actually holds before any case runs. +# lib/tests/design-tool-gate.test.sh — lib/design-tool-gate.sh reads +# `profile.sh current --plain` (fake, $WORK/plain.txt) and the 21st sign-in +# state (fake `21st`, FAKE_21ST_MODE). READY (0); a pack off + source=local → +# INCOMPLETE (10) with the profile.sh remedy; source=flag → relaunch remedy; +# no 21st CLI → 10 with the npm hint; signed out → 12; whoami garbage → 11; +# a token → READY without whoami; bad --plain → 2. set -u +unset CLAUDE_PROFILE CLAUDE_PROFILE_SETTINGS ROOT="$(cd "$(dirname "$0")/../.." && pwd)" -GATE="$ROOT/lib/design-tool-gate.sh" PASS=0; FAIL=0 - -ok() { echo "PASS $1"; PASS=$((PASS + 1)); } -bad() { echo "FAIL $1 — $2"; FAIL=$((FAIL + 1)); } - -# Precondition, loud: the sanitized PATH below and ensure_21st_on_path()'s -# own probes must never resolve a REAL 21st — else CLI_ABSENT_10 (and every -# other case) would silently exercise this machine's CLI instead of the stub. +ok() { PASS=$((PASS+1)); echo "PASS $1"; } +bad() { FAIL=$((FAIL+1)); echo "FAIL $1 — $2"; } if PATH=/usr/bin:/bin command -v 21st >/dev/null 2>&1 \ || [ -e /usr/local/bin/21st ] || [ -e /opt/homebrew/bin/21st ]; then echo "FAIL precondition: system-wide 21st present," \ @@ -25,132 +19,62 @@ if PATH=/usr/bin:/bin command -v 21st >/dev/null 2>&1 \ echo "PASS=$PASS FAIL=$FAIL" exit 1 fi - WORK="$(mktemp -d)"; trap 'rm -rf "$WORK"' EXIT -mkdir -p "$WORK/repo/lib/profiles" "$WORK/repo/skills" "$WORK/bin" "$WORK/home" - -# GATE-BLOCK allowlist: 21st (cli) always, ghost-skill (external) only used -# by INCOMPLETE_WINS to prove a blocking miss still trips the gate. -cat > "$WORK/repo/lib/profiles/design.profile" <<'EOF' -# GATE-BLOCK: 21st ghost-skill -21st cli -ghost-skill external -EOF - -# Fake profile.sh: `show design --plain` cats whatever the case wrote to -# plain.txt. $WORK is read from the environment at run time (exported -# below), never baked in here — the heredoc is quoted on purpose. -cat > "$WORK/repo/lib/profile.sh" <<'EOF' -#!/usr/bin/env bash -[ "$1" = show ] && [ "$3" = --plain ] && { cat "$WORK/plain.txt"; exit 0; } -exit 1 -EOF -chmod +x "$WORK/repo/lib/profile.sh" -export WORK - -# Fake 21st CLI: `whoami` answers per $FAKE_21ST_MODE, the real CLI's exact -# sentences for in/out (proven by STUB_CONTROL below), a garbage line at -# rc 0, or the signed-out sentence at a nonzero rc (proves rc wins). +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 -[ "${1:-}" = whoami ] || exit 1 -signedout='Not logged in. Run `21st login`, or set TWENTYFIRST_TOKEN.' case "${FAKE_21ST_MODE:-in}" in - in) echo "Logged in as tester (saved locally)."; exit 0 ;; - out) echo "$signedout"; exit 0 ;; - garbage) echo "Something unexpected"; exit 0 ;; - fail) echo "$signedout"; exit 3 ;; + in) echo "Logged in as fake@example.com" ;; out) echo "Not logged in" ;; + garbage) echo "boom"; exit 3 ;; esac EOF -chmod +x "$WORK/bin/21st" - -# gate_run [PATH override] -# -> sets $GATE_OUT / $GATE_RC. TWENTYFIRST_TOKEN and API_KEY_21ST are -# always unset here; TOKEN_READY below sets them explicitly instead. -gate_run() { - local mode="$1" plain="$2" gate_path="${3:-$WORK/bin:/usr/bin:/bin}" - printf '%b\n' "$plain" > "$WORK/plain.txt" - GATE_OUT="$(env -u TWENTYFIRST_TOKEN -u API_KEY_21ST \ - HOME="$WORK/home" PATH="$gate_path" \ - DESIGN_GATE_REPO_OVERRIDE="$WORK/repo" \ - DESIGN_GATE_PROFILE_SH="$WORK/repo/lib/profile.sh" \ - FAKE_21ST_MODE="$mode" bash "$GATE" 2>&1)" - GATE_RC=$? +chmod +x "$WORK/bin/"* +plain() { # design gstack-design ui source profile + printf 'profile=%s\nsource=%s\nflag=-\npack-design=%s\npack-gstack-design=%s\nplugin:ui-ux-pro-max@ui-ux-pro-max-skill=%s\nmodel=-\n' \ + "$5" "$4" "$1" "$2" "$3" > "$WORK/plain.txt" } - -# ── stub positive control ──────────────────────────────────────────────── -if FAKE_21ST_MODE=in "$WORK/bin/21st" whoami | grep -q '^Logged in as ' \ - && FAKE_21ST_MODE=out "$WORK/bin/21st" whoami | grep -q '^Not logged in' -then ok STUB_CONTROL; else bad STUB_CONTROL "stub sentences wrong"; fi - -# ── SIGNED_IN_READY: whoami says logged in -> exit 0, READY ──────────────── -gate_run in 'cli\t21st' -if [ "$GATE_RC" -eq 0 ] && echo "$GATE_OUT" | grep -q 'toolchain: READY'; then - ok SIGNED_IN_READY -else - bad SIGNED_IN_READY "rc=$GATE_RC out=$GATE_OUT" -fi - -# ── SIGNED_OUT_12: whoami says not logged in -> exit 12, ask to sign in ──── -gate_run out 'cli\t21st' -if [ "$GATE_RC" -eq 12 ] && echo "$GATE_OUT" | grep -q 'SIGN-IN REQUIRED' \ - && echo "$GATE_OUT" | grep -q '21st login' \ - && ! echo "$GATE_OUT" | grep -q 'INCOMPLETE'; then - ok SIGNED_OUT_12 -else - bad SIGNED_OUT_12 "rc=$GATE_RC out=$GATE_OUT" -fi - -# ── TOKEN_READY: a token env wins even while whoami reports signed out ───── -printf 'cli\t21st\n' > "$WORK/plain.txt" -out_t="$(env HOME="$WORK/home" PATH="$WORK/bin:/usr/bin:/bin" \ - DESIGN_GATE_REPO_OVERRIDE="$WORK/repo" \ - DESIGN_GATE_PROFILE_SH="$WORK/repo/lib/profile.sh" \ - FAKE_21ST_MODE=out TWENTYFIRST_TOKEN=x bash "$GATE" 2>&1)"; rc_t=$? -out_k="$(env HOME="$WORK/home" PATH="$WORK/bin:/usr/bin:/bin" \ - DESIGN_GATE_REPO_OVERRIDE="$WORK/repo" \ - DESIGN_GATE_PROFILE_SH="$WORK/repo/lib/profile.sh" \ - FAKE_21ST_MODE=out API_KEY_21ST=x bash "$GATE" 2>&1)"; rc_k=$? -if [ "$rc_t" -eq 0 ] && [ "$rc_k" -eq 0 ]; then - ok TOKEN_READY -else - bad TOKEN_READY "TOKEN rc=$rc_t ($out_t) | API_KEY rc=$rc_k ($out_k)" -fi - -# ── CLI_ABSENT_10: 21st off PATH -> exit 10, INCOMPLETE (not sign-in) ────── -gate_run in 'cli\t21st' /usr/bin:/bin -if [ "$GATE_RC" -eq 10 ] && echo "$GATE_OUT" | grep -q 'INCOMPLETE'; then - ok CLI_ABSENT_10 -else - bad CLI_ABSENT_10 "rc=$GATE_RC out=$GATE_OUT" -fi - -# ── INCOMPLETE_WINS: a blocking miss outranks a signed-out 21st ──────────── -gate_run out 'cli\t21st\nexternal\tghost-skill' -if [ "$GATE_RC" -eq 10 ] && echo "$GATE_OUT" | grep -q 'INCOMPLETE' \ - && ! echo "$GATE_OUT" | grep -q 'SIGN-IN REQUIRED'; then - ok INCOMPLETE_WINS -else - bad INCOMPLETE_WINS "rc=$GATE_RC out=$GATE_OUT" -fi - -# ── UNKNOWN_11: whoami answers something else -> surfaced, never guessed ─── -gate_run garbage 'cli\t21st' -if [ "$GATE_RC" -eq 11 ] && echo "$GATE_OUT" | grep -q 'whoami: rc=0' \ - && echo "$GATE_OUT" | grep -q 'Something unexpected' \ - && ! echo "$GATE_OUT" | grep -q '21st login' \ - && ! echo "$GATE_OUT" | grep -q 'claude CLI unreachable'; then - ok UNKNOWN_11 -else - bad UNKNOWN_11 "garbage: rc=$GATE_RC out=$GATE_OUT" -fi - -gate_run fail 'cli\t21st' -if [ "$GATE_RC" -eq 11 ] && echo "$GATE_OUT" | grep -q 'whoami: rc=3'; then - ok UNKNOWN_11 -else - bad UNKNOWN_11 "fail: rc=$GATE_RC out=$GATE_OUT" -fi - -echo "PASS=$PASS FAIL=$FAIL" -[ "$FAIL" -eq 0 ] +gate_run() { # $1 mode, $2 PATH prefix ("" = no 21st) + local p="$2"; [ -n "$p" ] && p="$p:" + env -u TWENTYFIRST_TOKEN -u API_KEY_21ST HOME="$WORK/home" PATH="${p}/usr/bin:/bin" \ + FAKE_21ST_MODE="$1" WORK="$WORK" DESIGN_GATE_PROFILE_SH="$WORK/bin/profile.sh" \ + bash "$ROOT/lib/design-tool-gate.sh" +} +expect() { # name rc-want substring + if [ "$rc" = "$2" ] && case "$out" in *"$3"*) true;; *) false;; esac + then ok "$1"; else bad "$1" "rc=$rc out=[$out]"; fi +} +plain on on on local web; out="$(gate_run in "$WORK/bin")"; rc=$? +expect T1-ready 0 "READY — packs design + gstack-design + ui-ux-pro-max on (web)" +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 off local web; out="$(gate_run in "$WORK/bin")"; rc=$? +expect T3a-plugin 10 "profile.sh enable ui-ux-pro-max@ui-ux-pro-max-skill" +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=$? +expect T6-unverified 11 "READY BUT UNVERIFIED — 21st could not answer: whoami: rc=3 boom" +out="$(TWENTYFIRST_TOKEN=x FAKE_21ST_MODE=out HOME="$WORK/home" PATH="$WORK/bin:/usr/bin:/bin" WORK="$WORK" \ + DESIGN_GATE_PROFILE_SH="$WORK/bin/profile.sh" bash "$ROOT/lib/design-tool-gate.sh")"; rc=$? +expect T7-token 0 "READY" +printf 'nonsense\n' > "$WORK/plain.txt"; out="$(gate_run in "$WORK/bin" 2>&1)"; rc=$? +expect T8-bad-plain 2 "design-gate: profile.sh current --plain gave no pack-design line" +if shellcheck "$ROOT/lib/design-tool-gate.sh" >/dev/null 2>&1; then ok T9-shellcheck; else bad T9-shellcheck findings; fi +if [ "$(LC_ALL=C awk 'length($0) > 80' "$ROOT/lib/design-tool-gate.sh" | wc -l | tr -d ' ')" = 0 ]; then ok T9-width; else bad T9-width "lines over 80"; fi +echo "PASS=$PASS FAIL=$FAIL"; [ "$FAIL" -eq 0 ] diff --git a/lib/tests/doctor-vendored.test.sh b/lib/tests/doctor-vendored.test.sh index 639f079..7a9e557 100644 --- a/lib/tests/doctor-vendored.test.sh +++ b/lib/tests/doctor-vendored.test.sh @@ -3,25 +3,20 @@ # 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 /skills dir and a fake -# profile file. 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), 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 +47,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 +66,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 +114,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 +163,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. diff --git a/lib/tests/doctrine-citers.test.sh b/lib/tests/doctrine-citers.test.sh index 4bacae2..688d763 100644 --- a/lib/tests/doctrine-citers.test.sh +++ b/lib/tests/doctrine-citers.test.sh @@ -186,14 +186,15 @@ citers_check_files "$FIX" "$FIX/t2.md" >/dev/null check T8h-template-rules-path "$rc1|$?" "0|1" # ── real census: the repo's own citers against CLAUDE.global.md ────────────── +# (`impeccabl[e]` is a glob: the pack census must not read it as a citer.) 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/impeccabl[e]/*' -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/impeccabl[e]/*' -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 diff --git a/lib/tests/effort-routing.test.sh b/lib/tests/effort-routing.test.sh index 902865f..34545d1 100755 --- a/lib/tests/effort-routing.test.sh +++ b/lib/tests/effort-routing.test.sh @@ -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" @@ -157,6 +158,33 @@ check_skill() { 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) ─ +# Parked: written by `21st skills install` (install-plugins.sh Step 8.7), +# in no pack, so absent from a fresh clone until that step ran. +PARKED=" 21st-registry 21st-design-sync " +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 p + case "$k" in + pack-*:*) n="${k%%:*}"; p="$R/skills/$n/skills/${k#*:}" + [ -L "$p" ] || [ -e "$p/SKILL.md" ];; + *) case "$PARKED" in *" $k "*) return 0;; esac + [ -e "$R/skills/$k/SKILL.md" ] || ext_named "$k" \ + || [ -L "$R/skills/$k" ] || [ -n "$(skdir "$k")" ] \ + || [ -e "$R/skills-external/$k/SKILL.md" ];; + esac +} +[ -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 + [ "$kind" = skills ] || continue + row_resolves "$key" && ok || ko "routing.json: skills row '$key' resolves to no skill" +done <<< "$RD" + # ── (c) tracked agents with a row: tier floor == model:, effort == effort: ─ NO_ROW_AGENTS=" interviewer client-handover-writer " check_agent() { @@ -185,7 +213,7 @@ done # ── (e) D3 wiring markers ──────────────────────────────────────────────── mark() { # mark 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 +222,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 +231,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' diff --git a/lib/tests/fixtures/pack-census-old-citers.sh b/lib/tests/fixtures/pack-census-old-citers.sh new file mode 100644 index 0000000..84935e4 --- /dev/null +++ b/lib/tests/fixtures/pack-census-old-citers.sh @@ -0,0 +1 @@ +ls $HOME/.claude/skills/a2 skills-disabled/foo; bash lib/toggle-external.sh; cat .active-profile; lib/profiles/web.profile diff --git a/lib/tests/gstack-removed.test.sh b/lib/tests/gstack-removed.test.sh deleted file mode 100755 index 91ced07..0000000 --- a/lib/tests/gstack-removed.test.sh +++ /dev/null @@ -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 — 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 ] diff --git a/lib/tests/higgsfield.test.sh b/lib/tests/higgsfield.test.sh index 689218b..c3110ae 100644 --- a/lib/tests/higgsfield.test.sh +++ b/lib/tests/higgsfield.test.sh @@ -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 ` or `FAIL :
` 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 [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 — 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 — 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 — 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 — 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; } diff --git a/lib/tests/model-routing.test.sh b/lib/tests/model-routing.test.sh index ed47650..5aabff4 100755 --- a/lib/tests/model-routing.test.sh +++ b/lib/tests/model-routing.test.sh @@ -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" diff --git a/lib/tests/pack-census.test.sh b/lib/tests/pack-census.test.sh new file mode 100755 index 0000000..32b6c35 --- /dev/null +++ b/lib/tests/pack-census.test.sh @@ -0,0 +1,114 @@ +#!/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; run: rm skills/a1 (a flat link)" +rm "$FX/skills/a1" +mkdir "$FX/skills/a1"; touch "$FX/skills/a1/SKILL.md" +out="$(census)" +check_has T5-dup-real "$out" "run: mv skills/a1 skills-external/a1 (a real dir)" +rm -r "$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" + +# identical fragments; a pack id with no manifest (WARN, not RED) +cp "$FX/lib/profiles/dev.json" "$FX/lib/profiles/zdev.json" +out="$(census)"; rc=$? +check T13-same-rc "$rc" 1 +check_has T13-same "$out" "RED lib/profiles/dev.json and zdev.json are identical fragments" +rm "$FX/lib/profiles/zdev.json" +sed 's/pack-beta@skills-dir": false/pack-beta@skills-dir": false, "pack-ghost@skills-dir": false/' "$FX/lib/profiles/dev.json" > "$FX/lib/profiles/ghost.json" +out="$(census)"; rc=$? +check_has T14-ghost "$out" "WARN lib/profiles/ghost.json: names pack-ghost with no skills/pack-ghost/" +rm "$FX/lib/profiles/ghost.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 ] diff --git a/lib/tests/plan-challenger.test.sh b/lib/tests/plan-challenger.test.sh index 9733f4f..94f0743 100644 --- a/lib/tests/plan-challenger.test.sh +++ b/lib/tests/plan-challenger.test.sh @@ -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" diff --git a/lib/tests/profile-census.test.sh b/lib/tests/profile-census.test.sh deleted file mode 100755 index 8d150d0..0000000 --- a/lib/tests/profile-census.test.sh +++ /dev/null @@ -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 [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 — census_check on (fixture -# PARKED override, empty FULL_EXCEPTIONS), asserts a non-zero rc AND the -# presence of ; echoes 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 ] diff --git a/lib/tests/profile-default.test.sh b/lib/tests/profile-default.test.sh deleted file mode 100644 index b80acd8..0000000 --- a/lib/tests/profile-default.test.sh +++ /dev/null @@ -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" <> "\$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 ] diff --git a/lib/tests/profile-set-managed.test.sh b/lib/tests/profile-set-managed.test.sh deleted file mode 100644 index 7d4fdab..0000000 --- a/lib/tests/profile-set-managed.test.sh +++ /dev/null @@ -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" <> "\$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 ] diff --git a/lib/tests/profile.test.sh b/lib/tests/profile.test.sh new file mode 100755 index 0000000..83669f2 --- /dev/null +++ b/lib/tests/profile.test.sh @@ -0,0 +1,186 @@ +#!/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 " +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 " + +# managed-connector match: a user-scope deny of an unmanaged connector keeps +# the profile name, shows in the plain lines, and never appears in diff +printf '{"enabledPlugins": {"ui@mk": true}, "deniedMcpServers": [{"serverName": "claude.ai Gmail"}]}\n' > "$FX/home/settings.json" +P set devx >/dev/null; out="$(plain)" +check_has T21-managed-name "$out" "profile=devx source=local " +check_has T21-plain-all "$out" "connector:claude.ai Gmail=denied" +check T21-diff "$(P diff devx)" "no difference from devx" +printf '{"enabledPlugins": {"ui@mk": true}}\n' > "$FX/home/settings.json" + +# diff skips the model line when the fragment has none +check_has T22-diff-nomodel "$(P diff devx; jq -r .model "$L")" "no difference from devx" + +# name allowlist: a refused name writes nothing and reads no path +cp "$L" "$FX/before-names.json" +for v in "set ../../settings" "show ../x" "diff a/b" "enable ../x" "disable y/z"; do + # shellcheck disable=SC2086 + out="$(P $v 2>&1)"; rc=$? + check "T23-name-rc-$v" "$rc" 2; check_has "T23-name-msg-$v" "$out" "invalid" +done +check T23-untouched "$(cmp -s "$FX/before-names.json" "$L" && echo same)" same +check T23-no-escape "$([ -e "$FX/lib/settings.json" ] && echo leaked)" "" + +# unset with nothing managed left: no write; no local file: none created +P unset >/dev/null; cp "$L" "$FX/before-unset.json" +out="$(P unset)"; check_has T24-nothing "$out" "nothing to unset" +check T24-untouched "$(cmp -s "$FX/before-unset.json" "$L" && echo same)" same +rm "$L"; P unset >/dev/null; check T24-no-file "$([ -e "$L" ] && echo created)" "" + +# project root = parent of the git common dir; a worktree and a nested dir +# holding its own CLAUDE.md both resolve to the main checkout +G="$FX/gmain"; mkdir -p "$G/pkg/inner"; printf '# pkg\n' > "$G/pkg/inner/CLAUDE.md" +git init -q "$G" +git -C "$G" -c core.hooksPath=/dev/null -c user.email=t@t -c user.name=t commit -q --allow-empty -m x +git -C "$G" -c core.hooksPath=/dev/null worktree add -q "$FX/wt" -b wt 2>/dev/null +PX() { local d="$1"; shift; PROFILE_REPO_OVERRIDE="$FX" PROFILE_USER_SETTINGS="$FX/home/settings.json" \ + PROFILE_CLAUDE_JSON="$FX/home/claude.json" bash "$ROOT/lib/profile.sh" -C "$d" "$@"; } +PX "$FX/wt" set devx >/dev/null; rc=$? +check T25-worktree-rc "$rc" 0 +check T25-worktree-main "$(jq -r '.enabledPlugins["pack-a@skills-dir"]' "$G/.claude/settings.local.json")" true +check T25-worktree-none "$([ -e "$FX/wt/.claude/settings.local.json" ] && echo local)" "" +check_has T25-nested "$(PX "$G/pkg/inner" current --plain | tr '\n' ' ')" "profile=devx source=local " + +# the walk stops below $HOME: a repo AT $HOME is not the project root +H2="$FX/home2"; mkdir -p "$H2/work"; git init -q "$H2"; printf '# w\n' > "$H2/work/CLAUDE.md" +HOME="$H2" PX "$H2/work" set devx >/dev/null; rc=$? +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)" "" + +# 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 ] diff --git a/lib/tests/seo-geo-contract.test.sh b/lib/tests/seo-geo-contract.test.sh index 85f4f63..c9056e2 100644 --- a/lib/tests/seo-geo-contract.test.sh +++ b/lib/tests/seo-geo-contract.test.sh @@ -15,16 +15,16 @@ has() { if grep -qF "$2" "$R/$1"; then ok; else ko "$1 missing: $2"; fi; } SEO=agents/seo-analyzer.md GEO=agents/geo-analyzer.md -# 1) judge verdict grammar — DISPATCHER ERROR CONTRACT (skills/seo STEP 1, -# skills/geo STEP 1B) fail-closes on this exact shape +# 1) judge verdict grammar — DISPATCHER ERROR CONTRACT (skills/pack-seo/skills/seo STEP 1, +# skills/pack-seo/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-.md' -has "skills/geo/SKILL.md" '.audit/geo-signals-.md' +has "skills/pack-seo/skills/seo/SKILL.md" '.audit/seo-signals-.md' +has "skills/pack-seo/skills/geo/SKILL.md" '.audit/geo-signals-.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-.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) diff --git a/lib/tests/statusline.test.sh b/lib/tests/statusline.test.sh new file mode 100644 index 0000000..e50655f --- /dev/null +++ b/lib/tests/statusline.test.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# lib/tests/statusline.test.sh — hooks/statusline.sh profile segment comes +# from `profile.sh -C 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 ] diff --git a/lib/tests/toggle-external-repo-resolution.test.sh b/lib/tests/toggle-external-repo-resolution.test.sh deleted file mode 100644 index 2a752ec..0000000 --- a/lib/tests/toggle-external-repo-resolution.test.sh +++ /dev/null @@ -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 -> /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 -> /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 ] diff --git a/lib/toggle-external.sh b/lib/toggle-external.sh deleted file mode 100755 index 12b0f30..0000000 --- a/lib/toggle-external.sh +++ /dev/null @@ -1,382 +0,0 @@ -#!/usr/bin/env bash -# ============================================================ -# lib/toggle-external.sh — enable/disable non-plugin tools -# -# Marketplace plugins are toggled by `claude plugin enable|disable`. -# Tools distributed outside the marketplace (gstack submodule, emil -# curl install, npx-installed skills) have no such lever — they live -# as symlinks inside skills/. This script moves those symlinks -# to/from skills-disabled/ so Claude Code stops/starts scanning them. -# -# A multi-skill pack (gstack, 21st, higgsfield) toggles all of its skills -# at once. -# -# Usage: -# toggle-external.sh list -# toggle-external.sh status -# toggle-external.sh enable -# toggle-external.sh disable -# -# Managed tools: -# gstack — per-skill symlinks populated by gstack's own setup -# emil-design-eng — single symlink → skills-external/emil-design-eng -# darwin-skill — single symlink → ~/.agents/skills/darwin-skill -# 21st — 21st.dev skill pack (needs the `21st` CLI + login) -# higgsfield — Higgsfield media pack (needs the CLI + login) -# higgsfield-websites — single skill, landing-page aid (named ask only) -# observability-and-instrumentation, deprecation-and-migration, -# ci-cd-and-automation — the agent-skills trio, same single-symlink shape -# as emil-design-eng (commit-pinned instead of main-branch tracking) -# scroll-world-storytelling, build-threejs-scroll-worlds, -# scroll-scrubbed-visual-sequence, scroll-scrubbed-word-reveal, -# scroll-progress-timeline — the Mengto scroll skills, same shape -# -# For fine-grained activation (only design skills, only qa skills, only -# audit skills, etc.) instead of all-or-nothing gstack toggling, use: -# bash lib/profile.sh list -# bash lib/profile.sh set -# bash lib/profile.sh reset # back to the default profile (full) -# ============================================================ -set -euo pipefail - -REPO="${TOGGLE_EXTERNAL_REPO_OVERRIDE:-$(cd -P "$(dirname "$0")/.." && pwd)}" -SKILLS_DIR="$REPO/skills" -DISABLED_DIR="$REPO/skills-disabled" -GSTACK_SRC="$REPO/skills-external/gstack" # gstack submodule: its skills - -# GSTACK_REMOVED + gstack_is_removed() — single source, honored by the -# `enable gstack` loop below — plus the gstack helpers shared with -# profile.sh (gstack_skills, gstack_park, gstack_unpark, gstack_parked_names). -# Resolved from $0 like REPO above, not from $REPO/lib — gstack-removed.sh -# sits next to this file wherever it runs. -# shellcheck source=lib/gstack-removed.sh disable=SC1091 -source "$(dirname "$0")/gstack-removed.sh" - -GREEN='\033[0;32m'; YELLOW='\033[1;33m'; RED='\033[0;31m'; NC='\033[0m' -ok() { echo -e "${GREEN}✓${NC} $1"; } -warn() { echo -e "${YELLOW}⚠${NC} $1"; } -err() { echo -e "${RED}✗${NC} $1"; } - -# All non-plugin tools this script can toggle, in `list` order. The one -# roster: tool_kind() derives every tool's kind from it. -MANAGED_TOOLS=(gstack emil-design-eng darwin-skill 21st higgsfield - higgsfield-websites - 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) - -# Prints the kind of a tool: gstack | pack (21st, higgsfield) | single (one -# symlink: every other MANAGED_TOOLS entry) | unknown. Exact-match loop, so -# a name with spaces or glob characters can never match a roster entry. -tool_kind() { - local tool="$1" managed - case "$tool" in - gstack) echo gstack; return ;; - 21st|higgsfield) echo pack; return ;; - esac - for managed in "${MANAGED_TOOLS[@]}"; do - [ "$managed" = "$tool" ] && { echo single; return; } - done - echo unknown -} - -# Prints where a single-symlink tool is linked from: ~/.agents/skills for -# darwin-skill, skills-external/ for the others. -tool_source() { - case "$1" in - darwin-skill) echo "$HOME/.agents/skills/$1" ;; - *) echo "$REPO/skills-external/$1" ;; - esac -} - -# Prints the skill names that belong to the "21st" pack. Source of truth: -# skills-external/21st-* — the `21st skills install` run in install-plugins.sh -# owns that list, so adding a skill upstream needs no edit here. -twentyfirst_skills() { - local d - for d in "$REPO"/skills-external/21st-*/; do - [ -f "${d}SKILL.md" ] || continue - basename "$d" - done -} - -# Media skills of the "higgsfield" pack: an explicit allowlist. Upstream is -# unpinned, so a skill it adds or renames must never be linked by -# `enable higgsfield` without an edit here (default deny). -# higgsfield-websites is its own tool: landing-page aid, named ask only. -HIGGSFIELD_MEDIA_SKILLS=(higgsfield-generate higgsfield-soul-id - higgsfield-product-photoshoot higgsfield-brandkit - higgsfield-marketplace-cards higgsfield-video-explainer - higgsfield-youtube-thumbnail) - -# Prints the allowlisted media skills synced under skills-external/. -higgsfield_skills() { - local name - for name in "${HIGGSFIELD_MEDIA_SKILLS[@]}"; do - [ -f "$REPO/skills-external/$name/SKILL.md" ] && echo "$name" - done - return 0 -} - -# Prints the synced higgsfield-* skills no tool owns: neither on the media -# allowlist nor higgsfield-websites. Upstream added or renamed something. -higgsfield_unlisted() { - local d name - for d in "$REPO"/skills-external/higgsfield-*/; do - [ -f "${d}SKILL.md" ] || continue - name="$(basename "$d")" - case " ${HIGGSFIELD_MEDIA_SKILLS[*]} higgsfield-websites " in - *" $name "*) ;; - *) echo "$name" ;; - esac - done -} - -# Prints the member skills of a multi-skill pack tool (21st, higgsfield). -pack_skills() { - case "$1" in - 21st) twentyfirst_skills ;; - higgsfield) higgsfield_skills ;; - esac -} - -# bounded — run a CLI probe silently, 15 s at most when a timeout -# tool exists (`timeout`, or `gtimeout` from Homebrew coreutils on macOS): -# a closed-source binary must never hang a toggle, and what it prints (a -# token) must never reach the terminal. Twin of _higgsfield_probe in -# lib/higgsfield-skills.sh, kept here so the only file sourced beside this -# script stays gstack-removed.sh (the fixture suites copy just those two). -bounded() { - local tool - for tool in timeout gtimeout; do - if command -v "$tool" >/dev/null 2>&1; then - "$tool" 15 "$@" /dev/null 2>&1 - return - fi - done - "$@" /dev/null 2>&1 -} - -# Post-enable notes for a pack. Its skills shell out to a CLI: without it -# (or without a session) they can only report failure. Warn, never block: -# the pack is still correctly wired and `make plugin` installs the CLI. -pack_hints() { - local name - case "$1" in - 21st) - if ! command -v 21st >/dev/null 2>&1; then - warn "the \`21st\` CLI is not on PATH — install it: npm i -g @21st-dev/cli" - elif ! grep -q '^Logged in as ' <<<"$(21st whoami 2>/dev/null)"; then - warn "not signed in to 21st — component retrieval and 21st AI need: 21st login" - fi - ;; - higgsfield) - if ! command -v higgsfield >/dev/null 2>&1; then - warn "the \`higgsfield\` CLI is not on PATH — run: make plugin" - elif ! bounded higgsfield version; then - warn "the \`higgsfield\` CLI does not answer (npm shim without its binary) — run: make plugin" - elif ! bounded higgsfield auth token; then - warn "not signed in to Higgsfield — generation needs: higgsfield auth login" - fi - while read -r name; do - warn "$name is synced but on no allowlist, not linked — see HIGGSFIELD_MEDIA_SKILLS in lib/toggle-external.sh" - done < <(higgsfield_unlisted) - ;; - esac -} - -# Prints "enabled" / "disabled" / "missing" for a tool. -status_tool() { - local tool="$1" installed=0 name - case "$(tool_kind "$tool")" in - gstack) - [ -d "$GSTACK_SRC" ] || { echo "missing"; return; } - while read -r name; do - [ -e "$SKILLS_DIR/$name" ] && { echo "enabled"; return; } - done < <(gstack_skills "$GSTACK_SRC") - echo "disabled" - ;; - single) - [ -d "$(tool_source "$tool")" ] || { echo "missing"; return; } - [ -e "$SKILLS_DIR/$tool" ] && echo "enabled" || echo "disabled" - ;; - pack) - while read -r name; do - installed=1 - [ -e "$SKILLS_DIR/$name" ] && { echo "enabled"; return; } - done < <(pack_skills "$tool") - [ "$installed" -eq 1 ] && echo "disabled" || echo "missing" - ;; - *) - echo "unknown"; return 1 ;; - esac -} - -# Parks every live gstack skill (twin of profile.sh's disable_skill gstack -# arm, kept separate: the messages differ). -disable_gstack() { - local moved=0 name - while read -r name; do - [ -e "$SKILLS_DIR/$name" ] || continue - gstack_park "$SKILLS_DIR" "$DISABLED_DIR" "$name" - moved=$((moved + 1)) - done < <(gstack_skills "$GSTACK_SRC") - ok "gstack disabled ($moved symlinks moved)" -} - -# Parks one single-symlink external tool. -disable_external_single() { - local tool="$1" - if [ -e "$SKILLS_DIR/$tool" ]; then - rm -rf "${DISABLED_DIR:?}/${tool:?}" - mv "$SKILLS_DIR/$tool" "$DISABLED_DIR/$tool" - ok "$tool disabled" - else - warn "$tool already disabled" - fi -} - -# Parks every live skill of a pack (21st, higgsfield). Parked under the -# plain skill name — same convention as the other externals, so profile.sh's -# park/restore path stays interoperable. -disable_pack() { - local tool="$1" parked=0 name - while read -r name; do - [ -e "$SKILLS_DIR/$name" ] || continue - rm -rf "${DISABLED_DIR:?}/${name:?}" - mv "$SKILLS_DIR/$name" "$DISABLED_DIR/$name" - parked=$((parked + 1)) - done < <(pack_skills "$tool") - if [ "$parked" -gt 0 ]; then - ok "$tool disabled ($parked skills parked)" - else - warn "$tool already disabled" - fi -} - -disable_tool() { - local tool="$1" - mkdir -p "$DISABLED_DIR" - case "$(tool_kind "$tool")" in - gstack) disable_gstack ;; - single) disable_external_single "$tool" ;; - pack) disable_pack "$tool" ;; - *) err "Unknown tool: $tool"; return 1 ;; - esac -} - -# Re-links the gstack skills parked as gstack__, honoring the -# policy denylist (lib/gstack-removed.sh). -enable_gstack() { - local moved=0 skipped=0 name - while IFS= read -r name; do - if gstack_is_removed "$name"; then - warn "skipped (removed by policy, lib/gstack-removed.sh): $name" - skipped=$((skipped + 1)) - continue - fi - gstack_unpark "$SKILLS_DIR" "$DISABLED_DIR" "$name" - moved=$((moved + 1)) - done < <(gstack_parked_names "$DISABLED_DIR") - if [ "$moved" -eq 0 ] && [ "$skipped" -ge 1 ]; then - warn "only policy-removed skills remain parked (lib/gstack-removed.sh)" - elif [ "$moved" -eq 0 ]; then - warn "gstack was not disabled — re-run gstack setup to (re)create symlinks" - else - ok "gstack enabled ($moved symlinks restored)" - fi -} - -# Enables one single-symlink external tool: restore from the parking dir, -# else link its source (see tool_source). -enable_external_single() { - local tool="$1" src - src="$(tool_source "$tool")" - if [ -e "$DISABLED_DIR/$tool" ]; then - rm -rf "${SKILLS_DIR:?}/${tool:?}" - mv "$DISABLED_DIR/$tool" "$SKILLS_DIR/$tool" - ok "$tool enabled" - elif [ -e "$SKILLS_DIR/$tool" ]; then - warn "$tool already enabled" - elif [ -d "$src" ]; then - ln -sf "$src" "$SKILLS_DIR/$tool" - ok "$tool enabled (symlink created → $src)" - else - err "$tool not installed at $src — run: make plugin" - return 1 - fi - if [ "$tool" = "higgsfield-websites" ]; then pack_hints higgsfield; fi -} - -# Enables a multi-skill pack (21st, higgsfield): restore parked skills, -# link the missing ones, then print the CLI hints. -enable_pack() { - local tool="$1" restored=0 linked=0 - while read -r name; do - if [ -e "$DISABLED_DIR/$name" ]; then - rm -rf "${SKILLS_DIR:?}/${name:?}" - mv "$DISABLED_DIR/$name" "$SKILLS_DIR/$name" - restored=$((restored + 1)) - elif [ -e "$SKILLS_DIR/$name" ]; then - : # already enabled - else - ln -sf "$REPO/skills-external/$name" "$SKILLS_DIR/$name" - linked=$((linked + 1)) - fi - done < <(pack_skills "$tool") - if [ "$((restored + linked))" -eq 0 ]; then - if [ "$(status_tool "$tool")" = "missing" ]; then - err "$tool pack not installed in $REPO/skills-external — run: make plugin" - return 1 - fi - warn "$tool already enabled" - # Enabled is the steady state, and Claude re-runs this on every - # media ask: the hints (upstream drift, CLI, session) show here too. - if [ "$tool" = "higgsfield" ]; then pack_hints higgsfield; fi - return 0 - fi - ok "$tool enabled ($((restored + linked)) skills: $restored restored, $linked linked)" - pack_hints "$tool" -} - -enable_tool() { - local tool="$1" - case "$(tool_kind "$tool")" in - gstack) enable_gstack ;; - single) enable_external_single "$tool" ;; - pack) enable_pack "$tool" ;; - *) err "Unknown tool: $tool"; return 1 ;; - esac -} - -list_all() { - local t - printf "%-20s %s\n" "TOOL" "STATUS" - printf "%-20s %s\n" "----" "------" - for t in "${MANAGED_TOOLS[@]}"; do - printf "%-20s %s\n" "$t" "$(status_tool "$t")" - done -} - -usage() { - # Header comment = lines 3 .. closing banner (dropped); no numeric range, - # so a longer tool list can no longer fall out of --help. - sed -n '3,/^# ====/p' "$0" | sed '$d' | sed 's/^# \?//' - exit "${1:-0}" -} - -main() { - local cmd="${1:-}" - case "$cmd" in - list) list_all ;; - status) [ $# -ge 2 ] || usage 1; status_tool "$2" ;; - enable) [ $# -ge 2 ] || usage 1; enable_tool "$2" ;; - disable) [ $# -ge 2 ] || usage 1; disable_tool "$2" ;; - ""|-h|--help|help) usage 0 ;; - *) err "Unknown command: $cmd"; usage 1 ;; - esac -} - -main "$@" diff --git a/link.sh b/link.sh index 57abf20..5fee1c1 100644 --- a/link.sh +++ b/link.sh @@ -72,14 +72,11 @@ else echo "⚠️ GStack submodule not found — run: git submodule update --init" 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 +# impeccable is NOT here: it lives in skills-external/impeccable (moved +# there by install-plugins.sh Step 8d) and pack-design links it. +# 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 diff --git a/mods/model-router/routing.json b/mods/model-router/routing.json index 1f5cbb9..c48c563 100644 --- a/mods/model-router/routing.json +++ b/mods/model-router/routing.json @@ -74,6 +74,7 @@ "writing-plans": "plan", "requesting-code-review": "plan", "21st-ui-review": "plan", + "pack-extras:21st-ui-review": "plan", "feat": "reflect", "hotfix": "reflect", "bugfix": "reflect", @@ -82,24 +83,39 @@ "guardrails": "reflect", "a11y": "reflect", "web-validate": "reflect", + "pack-web-validate:web-validate": "reflect", "harden": "reflect", "seo": "reflect", + "pack-seo:seo": "reflect", "geo": "reflect", + "pack-seo:geo": "reflect", "site-motion": "reflect", + "pack-design:site-motion": "reflect", "frontend-design": "reflect", + "pack-design:frontend-design": "reflect", "emil-design-eng": "reflect", + "pack-design:emil-design-eng": "reflect", "design-motion-principles": "reflect", + "pack-design:design-motion-principles": "reflect", "21st-ui-build": "reflect", + "pack-design:21st-ui-build": "reflect", "scroll-world-storytelling": "reflect", + "pack-scroll3d:scroll-world-storytelling": "reflect", "build-threejs-scroll-worlds": "reflect", + "pack-scroll3d:build-threejs-scroll-worlds": "reflect", "scroll-scrubbed-visual-sequence": "reflect", + "pack-scroll3d:scroll-scrubbed-visual-sequence": "reflect", "scroll-scrubbed-word-reveal": "reflect", + "pack-scroll3d:scroll-scrubbed-word-reveal": "reflect", "scroll-progress-timeline": "reflect", + "pack-scroll3d:scroll-progress-timeline": "reflect", "subagent-driven-development": "reflect", "writing-skills": "reflect", "deprecation-and-migration": "reflect", "21st-ai": "reflect", + "pack-extras:21st-ai": "reflect", "21st-ui-explore": "reflect", + "pack-extras:21st-ui-explore": "reflect", "gitflow": "implement", "prune-memory": "implement", "pdf-translate": "implement", @@ -119,6 +135,7 @@ "skills-perso": "mechanical", "using-git-worktrees": "mechanical", "21st-cli-use": "mechanical", + "pack-design:21st-cli-use": "mechanical", "21st-registry": "mechanical", "21st-design-sync": "mechanical" }, diff --git a/plugins.lock.json b/plugins.lock.json index ee19139..7060b06 100644 --- a/plugins.lock.json +++ b/plugins.lock.json @@ -28,7 +28,7 @@ "higgsfield": { "source": "npm:@higgsfield/cli", "version": "latest", - "note": "Higgsfield CLI (bins `higgsfield`, `higgs`) — image, video, audio and brand media generation, metered credits; auth is `higgsfield auth login` (browser). Install: npm install -g @higgsfield/cli. The package vendors its binary in a postinstall script; if npm holds it back, add --allow-scripts=@higgsfield/cli. The upstream skills are git-cloned from https://github.com/higgsfield-ai/skills (tracks main, no pin) into skills-external/higgsfield-* by lib/higgsfield-skills.sh (install-plugins.sh Step 8.6, refreshed by update-all.sh); a skill upstream removes keeps its last local copy. OFF by default and in no profile: `lib/toggle-external.sh enable higgsfield` links the 7 allowlisted media skills (HIGGSFIELD_MEDIA_SKILLS), `enable higgsfield-websites` the landing-page aid." + "note": "Higgsfield CLI (bins `higgsfield`, `higgs`) — image, video, audio and brand media generation, metered credits; auth is `higgsfield auth login` (browser). Install: npm install -g @higgsfield/cli. The package vendors its binary in a postinstall script; if npm holds it back, add --allow-scripts=@higgsfield/cli. The upstream skills are git-cloned from https://github.com/higgsfield-ai/skills (tracks main, no pin) into skills-external/higgsfield-* by lib/higgsfield-skills.sh (install-plugins.sh Step 8.6, refreshed by update-all.sh); a skill upstream removes keeps its last local copy. 8 skills in pack-higgsfield (OFF by default, ON in max; `profile.sh enable higgsfield`)." }, "graphifyy": { "source": "pypi:graphifyy", @@ -44,9 +44,9 @@ }, "emil-design-eng": { "source": "https://github.com/emilkowalski/skill", - "path": "skills/emil-design-eng/SKILL.md", + "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", @@ -89,6 +89,6 @@ "impeccable": { "source": "npm:impeccable", "version": "4.1.0", - "note": "Design anti-pattern detector (61 deterministic rules, CLI 'impeccable detect', exit 0/2) + /impeccable skill (23 verbs) + 4 impeccable-* subagents, by pbakaus. Pin = CLI version ONLY: the skill dist and the engine binary have their own release tracks, fetched by 'skills install' at install time, so this pin does not freeze audit output the way a semgrep pin does. It still gates the CLI deliberately (LRN-077 class). BEWARE: the pin rots — the CLI downloads its skill dist at install time and an older release's artifact disappears upstream (3.2.0 -> 'Download failed: invalid zip data', 2026-09-22, which left 'make plugin' printing a run-it-yourself warning). install-plugins.sh Step 8d and update-all.sh therefore fall back to @latest on a pin failure and warn to bump this version. Requires Node >= 24. Installed at --scope=global: lands in ~/.claude/skills/impeccable + ~/.claude/agents/impeccable-*.md, both symlinks into this repo, both gitignored." + "note": "Design anti-pattern detector (61 deterministic rules, CLI 'impeccable detect', exit 0/2) + /impeccable skill (23 verbs) + 4 impeccable-* subagents, by pbakaus. Pin = CLI version ONLY: the skill dist and the engine binary have their own release tracks, fetched by 'skills install' at install time, so this pin does not freeze audit output the way a semgrep pin does. It still gates the CLI deliberately (LRN-077 class). BEWARE: the pin rots — the CLI downloads its skill dist at install time and an older release's artifact disappears upstream (3.2.0 -> 'Download failed: invalid zip data', 2026-09-22, which left 'make plugin' printing a run-it-yourself warning). install-plugins.sh Step 8d and update-all.sh therefore fall back to @latest on a pin failure and warn to bump this version. Requires Node >= 24. Installed at --scope=global: lands in skills/impeccable, then moves to skills-external/impeccable (linked by pack-design), plus ~/.claude/agents/impeccable-*.md, a symlink into this repo; both gitignored." } } diff --git a/rules/web-building.md b/rules/web-building.md index 76cfcdc..cab3783 100644 --- a/rules/web-building.md +++ b/rules/web-building.md @@ -65,4 +65,5 @@ Scope doubt → ask or default to Build, never silently skip. Gate: light skills run `~/.claude/lib/design-gate.md`, orchestrators plugin-check. 21st = CLI (`npm i -g @21st-dev/cli`, `21st login`), no MCP, no key; search free, `21st get`/`generate` metered → generation, not micro-tweaks. 21st-ai / -ui-explore / ui-review are `max`-profile only. +ui-explore / ui-review are `max`-profile only (pack-extras; +`profile.sh enable extras`). diff --git a/settings.json b/settings.json index 2ef0acd..5650483 100644 --- a/settings.json +++ b/settings.json @@ -1,7 +1,8 @@ { "cleanupPeriodDays": 7, "env": { - "ENABLE_STOP_REVIEW": "0" + "ENABLE_STOP_REVIEW": "0", + "SLASH_COMMAND_TOOL_CHAR_BUDGET": "50000" }, "attribution": { "commit": "", diff --git a/skills/bugfix/SKILL.md b/skills/bugfix/SKILL.md index b0f6d73..510c89b 100644 --- a/skills/bugfix/SKILL.md +++ b/skills/bugfix/SKILL.md @@ -58,7 +58,7 @@ git log --oneline -20 --all -- Follow `$HOME/.claude/lib/design-gate.md`: - Scan $ARGUMENTS and target files for design/UI/style signals (CSS, component, layout, animation). - If signals found → run `design-tool-gate.sh`; INCOMPLETE → tell the user - to run `/profile design`; SIGN-IN REQUIRED → design-gate.md §3 (ask + the remedy line it printed; SIGN-IN REQUIRED → design-gate.md §3 (ask `! 21st login`, wait) before proceeding. - If no signals → skip (zero overhead). diff --git a/skills/feat/SKILL.md b/skills/feat/SKILL.md index 2898f41..b5aa7f4 100644 --- a/skills/feat/SKILL.md +++ b/skills/feat/SKILL.md @@ -74,7 +74,7 @@ FEAT: — rule , ~ files, Follow `$HOME/.claude/lib/design-gate.md`: - Scan $ARGUMENTS and target files for design/UI/style signals. - If signals found → run `design-tool-gate.sh`; INCOMPLETE → tell the user - to run `/profile design`; SIGN-IN REQUIRED → design-gate.md §3 (ask + the remedy line it printed; SIGN-IN REQUIRED → design-gate.md §3 (ask `! 21st login`, wait) before proceeding. - If no signals → skip (zero overhead). diff --git a/skills/feat/test-prompts.json b/skills/feat/test-prompts.json index c3f5117..3c76ee7 100644 --- a/skills/feat/test-prompts.json +++ b/skills/feat/test-prompts.json @@ -1,5 +1,5 @@ [ {"id": 1, "prompt": "Add a /health endpoint to the API that returns 200 OK with version info", "expected": "Light planning, direct implementation in 1-3 files, no design brainstorm, no plugin check, run build/tests after"}, - {"id": 2, "prompt": "Add dark mode toggle to the settings page", "expected": "Detect UI signal → trigger design gate (run design-tool-gate.sh; if toolchain incomplete, point at /profile design), then implement small feature"}, + {"id": 2, "prompt": "Add dark mode toggle to the settings page", "expected": "Detect UI signal → trigger design gate (run design-tool-gate.sh; if toolchain incomplete, point at the remedy line it printed), then implement small feature"}, {"id": 3, "prompt": "Petite feature : afficher un badge 'New' à côté des items créés cette semaine", "expected": "FR trigger, scope check (≤5 files), implement directly, no orchestrator overhead"} ] diff --git a/skills/onboard/SKILL.md b/skills/onboard/SKILL.md index de4d4a4..d1bbc21 100644 --- a/skills/onboard/SKILL.md +++ b/skills/onboard/SKILL.md @@ -421,7 +421,7 @@ Agent( **Décision selon plugin state :** ```bash # gstack actif ? -bash $HOME/.claude/lib/toggle-external.sh list 2>/dev/null | grep -E "^gstack\s+(enabled|on)" +bash $HOME/.claude/lib/profile.sh -C "$PWD" current --plain 2>/dev/null | grep -q '^pack-gstack-dev=on' ``` - **gstack ON** → invoquer le skill cso via Skill tool en lui passant le contexte archétype : @@ -605,7 +605,7 @@ Options : Pré-check ressources navigateur : ```bash # gstack actif ? -bash $HOME/.claude/lib/toggle-external.sh list 2>/dev/null | grep -E "^gstack\s+(enabled|on)" +bash $HOME/.claude/lib/profile.sh -C "$PWD" current --plain 2>/dev/null | grep -q '^pack-gstack-browser=on' # URL déployée fournie par l'utilisateur en STEP 3 ? echo "${BRIEF_deployed_url:-none}" # dev server launchable ? diff --git a/skills/pack-design/.claude-plugin/plugin.json b/skills/pack-design/.claude-plugin/plugin.json new file mode 100644 index 0000000..0a94f5e --- /dev/null +++ b/skills/pack-design/.claude-plugin/plugin.json @@ -0,0 +1,7 @@ +{ + "name": "pack-design", + "version": "1.0.0", + "description": "Design and UI skills: impeccable, Emil design eng, frontend-design, motion, 21st build + CLI, site-motion.", + "author": { "name": "bchanot" }, + "defaultEnabled": true +} diff --git a/skills/pack-design/skills/21st-cli-use b/skills/pack-design/skills/21st-cli-use new file mode 120000 index 0000000..9133f3c --- /dev/null +++ b/skills/pack-design/skills/21st-cli-use @@ -0,0 +1 @@ +../../../skills-external/21st-cli-use \ No newline at end of file diff --git a/skills/pack-design/skills/21st-ui-build b/skills/pack-design/skills/21st-ui-build new file mode 120000 index 0000000..284e618 --- /dev/null +++ b/skills/pack-design/skills/21st-ui-build @@ -0,0 +1 @@ +../../../skills-external/21st-ui-build \ No newline at end of file diff --git a/skills/pack-design/skills/design-motion-principles b/skills/pack-design/skills/design-motion-principles new file mode 120000 index 0000000..6eb0ee1 --- /dev/null +++ b/skills/pack-design/skills/design-motion-principles @@ -0,0 +1 @@ +../../../skills-external/design-motion-principles \ No newline at end of file diff --git a/skills/pack-design/skills/emil-design-eng b/skills/pack-design/skills/emil-design-eng new file mode 120000 index 0000000..4790800 --- /dev/null +++ b/skills/pack-design/skills/emil-design-eng @@ -0,0 +1 @@ +../../../skills-external/emil-design-eng \ No newline at end of file diff --git a/skills/pack-design/skills/frontend-design b/skills/pack-design/skills/frontend-design new file mode 120000 index 0000000..8bd9e20 --- /dev/null +++ b/skills/pack-design/skills/frontend-design @@ -0,0 +1 @@ +../../../skills-external/frontend-design \ No newline at end of file diff --git a/skills/pack-design/skills/impeccable b/skills/pack-design/skills/impeccable new file mode 120000 index 0000000..b3f022e --- /dev/null +++ b/skills/pack-design/skills/impeccable @@ -0,0 +1 @@ +../../../skills-external/impeccable \ No newline at end of file diff --git a/skills/site-motion/SKILL.md b/skills/pack-design/skills/site-motion/SKILL.md similarity index 99% rename from skills/site-motion/SKILL.md rename to skills/pack-design/skills/site-motion/SKILL.md index 3f2f7b8..be243bd 100644 --- a/skills/site-motion/SKILL.md +++ b/skills/pack-design/skills/site-motion/SKILL.md @@ -38,7 +38,7 @@ top of it. how a route transition should morph, how a WebGL hero should degrade → this skill. - Linting already-shipped motion against anti-slop rules → - `skills/impeccable/reference/animate.md` (`impeccable detect`) as the + `skills/pack-design/skills/impeccable/reference/animate.md` (`impeccable detect`) as the deterministic floor, or design-motion-principles' own audit workflow (`skills-external/design-motion-principles/workflows/audit.md`). - Non-motion defaults (fonts, color, spacing, the public-site checklist) diff --git a/skills/site-motion/test-prompts.json b/skills/pack-design/skills/site-motion/test-prompts.json similarity index 100% rename from skills/site-motion/test-prompts.json rename to skills/pack-design/skills/site-motion/test-prompts.json diff --git a/skills/pack-extras/.claude-plugin/plugin.json b/skills/pack-extras/.claude-plugin/plugin.json new file mode 100644 index 0000000..3fe2460 --- /dev/null +++ b/skills/pack-extras/.claude-plugin/plugin.json @@ -0,0 +1,7 @@ +{ + "name": "pack-extras", + "version": "1.0.0", + "description": "Occasional skills: diagram, make-pdf, 21st-ai, 21st-ui-explore, 21st-ui-review. OFF by default.", + "author": { "name": "bchanot" }, + "defaultEnabled": false +} diff --git a/skills/pack-extras/skills/21st-ai b/skills/pack-extras/skills/21st-ai new file mode 120000 index 0000000..a307c43 --- /dev/null +++ b/skills/pack-extras/skills/21st-ai @@ -0,0 +1 @@ +../../../skills-external/21st-ai \ No newline at end of file diff --git a/skills/pack-extras/skills/21st-ui-explore b/skills/pack-extras/skills/21st-ui-explore new file mode 120000 index 0000000..4d052cb --- /dev/null +++ b/skills/pack-extras/skills/21st-ui-explore @@ -0,0 +1 @@ +../../../skills-external/21st-ui-explore \ No newline at end of file diff --git a/skills/pack-extras/skills/21st-ui-review b/skills/pack-extras/skills/21st-ui-review new file mode 120000 index 0000000..192edad --- /dev/null +++ b/skills/pack-extras/skills/21st-ui-review @@ -0,0 +1 @@ +../../../skills-external/21st-ui-review \ No newline at end of file diff --git a/skills/pack-extras/skills/diagram b/skills/pack-extras/skills/diagram new file mode 120000 index 0000000..057baed --- /dev/null +++ b/skills/pack-extras/skills/diagram @@ -0,0 +1 @@ +../../../skills-external/gstack/diagram \ No newline at end of file diff --git a/skills/pack-extras/skills/make-pdf b/skills/pack-extras/skills/make-pdf new file mode 120000 index 0000000..aa9d06a --- /dev/null +++ b/skills/pack-extras/skills/make-pdf @@ -0,0 +1 @@ +../../../skills-external/gstack/make-pdf \ No newline at end of file diff --git a/skills/pack-gstack-browser/.claude-plugin/plugin.json b/skills/pack-gstack-browser/.claude-plugin/plugin.json new file mode 100644 index 0000000..6824918 --- /dev/null +++ b/skills/pack-gstack-browser/.claude-plugin/plugin.json @@ -0,0 +1,7 @@ +{ + "name": "pack-gstack-browser", + "version": "1.0.0", + "description": "gstack browser tooling: browse, scrape, qa, benchmark, canary.", + "author": { "name": "bchanot" }, + "defaultEnabled": true +} diff --git a/skills/pack-gstack-browser/skills/benchmark b/skills/pack-gstack-browser/skills/benchmark new file mode 120000 index 0000000..7a80388 --- /dev/null +++ b/skills/pack-gstack-browser/skills/benchmark @@ -0,0 +1 @@ +../../../skills-external/gstack/benchmark \ No newline at end of file diff --git a/skills/pack-gstack-browser/skills/browse b/skills/pack-gstack-browser/skills/browse new file mode 120000 index 0000000..62c425d --- /dev/null +++ b/skills/pack-gstack-browser/skills/browse @@ -0,0 +1 @@ +../../../skills-external/gstack/browse \ No newline at end of file diff --git a/skills/pack-gstack-browser/skills/canary b/skills/pack-gstack-browser/skills/canary new file mode 120000 index 0000000..0b7c8bf --- /dev/null +++ b/skills/pack-gstack-browser/skills/canary @@ -0,0 +1 @@ +../../../skills-external/gstack/canary \ No newline at end of file diff --git a/skills/pack-gstack-browser/skills/open-gstack-browser b/skills/pack-gstack-browser/skills/open-gstack-browser new file mode 120000 index 0000000..775b026 --- /dev/null +++ b/skills/pack-gstack-browser/skills/open-gstack-browser @@ -0,0 +1 @@ +../../../skills-external/gstack/open-gstack-browser \ No newline at end of file diff --git a/skills/pack-gstack-browser/skills/qa b/skills/pack-gstack-browser/skills/qa new file mode 120000 index 0000000..9a3226f --- /dev/null +++ b/skills/pack-gstack-browser/skills/qa @@ -0,0 +1 @@ +../../../skills-external/gstack/qa \ No newline at end of file diff --git a/skills/pack-gstack-browser/skills/qa-only b/skills/pack-gstack-browser/skills/qa-only new file mode 120000 index 0000000..cba8c43 --- /dev/null +++ b/skills/pack-gstack-browser/skills/qa-only @@ -0,0 +1 @@ +../../../skills-external/gstack/qa-only \ No newline at end of file diff --git a/skills/pack-gstack-browser/skills/scrape b/skills/pack-gstack-browser/skills/scrape new file mode 120000 index 0000000..989e087 --- /dev/null +++ b/skills/pack-gstack-browser/skills/scrape @@ -0,0 +1 @@ +../../../skills-external/gstack/scrape \ No newline at end of file diff --git a/skills/pack-gstack-browser/skills/setup-browser-cookies b/skills/pack-gstack-browser/skills/setup-browser-cookies new file mode 120000 index 0000000..d7ad833 --- /dev/null +++ b/skills/pack-gstack-browser/skills/setup-browser-cookies @@ -0,0 +1 @@ +../../../skills-external/gstack/setup-browser-cookies \ No newline at end of file diff --git a/skills/pack-gstack-design/.claude-plugin/plugin.json b/skills/pack-gstack-design/.claude-plugin/plugin.json new file mode 100644 index 0000000..1472fdc --- /dev/null +++ b/skills/pack-gstack-design/.claude-plugin/plugin.json @@ -0,0 +1,7 @@ +{ + "name": "pack-gstack-design", + "version": "1.0.0", + "description": "gstack design pipeline: design-review, design-consultation, design-html, plan-design-review.", + "author": { "name": "bchanot" }, + "defaultEnabled": true +} diff --git a/skills/pack-gstack-design/skills/design-consultation b/skills/pack-gstack-design/skills/design-consultation new file mode 120000 index 0000000..130ac9b --- /dev/null +++ b/skills/pack-gstack-design/skills/design-consultation @@ -0,0 +1 @@ +../../../skills-external/gstack/design-consultation \ No newline at end of file diff --git a/skills/pack-gstack-design/skills/design-html b/skills/pack-gstack-design/skills/design-html new file mode 120000 index 0000000..a577b20 --- /dev/null +++ b/skills/pack-gstack-design/skills/design-html @@ -0,0 +1 @@ +../../../skills-external/gstack/design-html \ No newline at end of file diff --git a/skills/pack-gstack-design/skills/design-review b/skills/pack-gstack-design/skills/design-review new file mode 120000 index 0000000..35c66a1 --- /dev/null +++ b/skills/pack-gstack-design/skills/design-review @@ -0,0 +1 @@ +../../../skills-external/gstack/design-review \ No newline at end of file diff --git a/skills/pack-gstack-design/skills/plan-design-review b/skills/pack-gstack-design/skills/plan-design-review new file mode 120000 index 0000000..32a2507 --- /dev/null +++ b/skills/pack-gstack-design/skills/plan-design-review @@ -0,0 +1 @@ +../../../skills-external/gstack/plan-design-review \ No newline at end of file diff --git a/skills/pack-gstack-dev/.claude-plugin/plugin.json b/skills/pack-gstack-dev/.claude-plugin/plugin.json new file mode 100644 index 0000000..ac94400 --- /dev/null +++ b/skills/pack-gstack-dev/.claude-plugin/plugin.json @@ -0,0 +1,7 @@ +{ + "name": "pack-gstack-dev", + "version": "1.0.0", + "description": "gstack engineering skills: review, investigate, codex, cso, health, freeze, retro, spec, skillify, office-hours, plan reviews, document-release.", + "author": { "name": "bchanot" }, + "defaultEnabled": true +} diff --git a/skills/pack-gstack-dev/skills/codex b/skills/pack-gstack-dev/skills/codex new file mode 120000 index 0000000..f685065 --- /dev/null +++ b/skills/pack-gstack-dev/skills/codex @@ -0,0 +1 @@ +../../../skills-external/gstack/codex \ No newline at end of file diff --git a/skills/pack-gstack-dev/skills/cso b/skills/pack-gstack-dev/skills/cso new file mode 120000 index 0000000..ae91ca4 --- /dev/null +++ b/skills/pack-gstack-dev/skills/cso @@ -0,0 +1 @@ +../../../skills-external/gstack/cso \ No newline at end of file diff --git a/skills/pack-gstack-dev/skills/document-release b/skills/pack-gstack-dev/skills/document-release new file mode 120000 index 0000000..f4c1f6e --- /dev/null +++ b/skills/pack-gstack-dev/skills/document-release @@ -0,0 +1 @@ +../../../skills-external/gstack/document-release \ No newline at end of file diff --git a/skills/pack-gstack-dev/skills/freeze b/skills/pack-gstack-dev/skills/freeze new file mode 120000 index 0000000..7c2a740 --- /dev/null +++ b/skills/pack-gstack-dev/skills/freeze @@ -0,0 +1 @@ +../../../skills-external/gstack/freeze \ No newline at end of file diff --git a/skills/pack-gstack-dev/skills/health b/skills/pack-gstack-dev/skills/health new file mode 120000 index 0000000..f211ae6 --- /dev/null +++ b/skills/pack-gstack-dev/skills/health @@ -0,0 +1 @@ +../../../skills-external/gstack/health \ No newline at end of file diff --git a/skills/pack-gstack-dev/skills/investigate b/skills/pack-gstack-dev/skills/investigate new file mode 120000 index 0000000..8e2a499 --- /dev/null +++ b/skills/pack-gstack-dev/skills/investigate @@ -0,0 +1 @@ +../../../skills-external/gstack/investigate \ No newline at end of file diff --git a/skills/pack-gstack-dev/skills/office-hours b/skills/pack-gstack-dev/skills/office-hours new file mode 120000 index 0000000..f6759b8 --- /dev/null +++ b/skills/pack-gstack-dev/skills/office-hours @@ -0,0 +1 @@ +../../../skills-external/gstack/office-hours \ No newline at end of file diff --git a/skills/pack-gstack-dev/skills/plan-ceo-review b/skills/pack-gstack-dev/skills/plan-ceo-review new file mode 120000 index 0000000..2ce190f --- /dev/null +++ b/skills/pack-gstack-dev/skills/plan-ceo-review @@ -0,0 +1 @@ +../../../skills-external/gstack/plan-ceo-review \ No newline at end of file diff --git a/skills/pack-gstack-dev/skills/plan-devex-review b/skills/pack-gstack-dev/skills/plan-devex-review new file mode 120000 index 0000000..f6fe9b8 --- /dev/null +++ b/skills/pack-gstack-dev/skills/plan-devex-review @@ -0,0 +1 @@ +../../../skills-external/gstack/plan-devex-review \ No newline at end of file diff --git a/skills/pack-gstack-dev/skills/plan-eng-review b/skills/pack-gstack-dev/skills/plan-eng-review new file mode 120000 index 0000000..8aa43f6 --- /dev/null +++ b/skills/pack-gstack-dev/skills/plan-eng-review @@ -0,0 +1 @@ +../../../skills-external/gstack/plan-eng-review \ No newline at end of file diff --git a/skills/pack-gstack-dev/skills/retro b/skills/pack-gstack-dev/skills/retro new file mode 120000 index 0000000..bce1be0 --- /dev/null +++ b/skills/pack-gstack-dev/skills/retro @@ -0,0 +1 @@ +../../../skills-external/gstack/retro \ No newline at end of file diff --git a/skills/pack-gstack-dev/skills/review b/skills/pack-gstack-dev/skills/review new file mode 120000 index 0000000..3be4c73 --- /dev/null +++ b/skills/pack-gstack-dev/skills/review @@ -0,0 +1 @@ +../../../skills-external/gstack/review \ No newline at end of file diff --git a/skills/pack-gstack-dev/skills/skillify b/skills/pack-gstack-dev/skills/skillify new file mode 120000 index 0000000..350ea5d --- /dev/null +++ b/skills/pack-gstack-dev/skills/skillify @@ -0,0 +1 @@ +../../../skills-external/gstack/skillify \ No newline at end of file diff --git a/skills/pack-gstack-dev/skills/spec b/skills/pack-gstack-dev/skills/spec new file mode 120000 index 0000000..37ed4cd --- /dev/null +++ b/skills/pack-gstack-dev/skills/spec @@ -0,0 +1 @@ +../../../skills-external/gstack/spec \ No newline at end of file diff --git a/skills/pack-gstack-dev/skills/unfreeze b/skills/pack-gstack-dev/skills/unfreeze new file mode 120000 index 0000000..4003abc --- /dev/null +++ b/skills/pack-gstack-dev/skills/unfreeze @@ -0,0 +1 @@ +../../../skills-external/gstack/unfreeze \ No newline at end of file diff --git a/skills/pack-higgsfield/.claude-plugin/plugin.json b/skills/pack-higgsfield/.claude-plugin/plugin.json new file mode 100644 index 0000000..b71775c --- /dev/null +++ b/skills/pack-higgsfield/.claude-plugin/plugin.json @@ -0,0 +1,7 @@ +{ + "name": "pack-higgsfield", + "version": "1.0.0", + "description": "Higgsfield media generation skills (paid runs). OFF by default: profile.sh enable higgsfield.", + "author": { "name": "bchanot" }, + "defaultEnabled": false +} diff --git a/skills/pack-higgsfield/skills/higgsfield-brandkit b/skills/pack-higgsfield/skills/higgsfield-brandkit new file mode 120000 index 0000000..4c61c4e --- /dev/null +++ b/skills/pack-higgsfield/skills/higgsfield-brandkit @@ -0,0 +1 @@ +../../../skills-external/higgsfield-brandkit \ No newline at end of file diff --git a/skills/pack-higgsfield/skills/higgsfield-generate b/skills/pack-higgsfield/skills/higgsfield-generate new file mode 120000 index 0000000..054075f --- /dev/null +++ b/skills/pack-higgsfield/skills/higgsfield-generate @@ -0,0 +1 @@ +../../../skills-external/higgsfield-generate \ No newline at end of file diff --git a/skills/pack-higgsfield/skills/higgsfield-marketplace-cards b/skills/pack-higgsfield/skills/higgsfield-marketplace-cards new file mode 120000 index 0000000..9054d77 --- /dev/null +++ b/skills/pack-higgsfield/skills/higgsfield-marketplace-cards @@ -0,0 +1 @@ +../../../skills-external/higgsfield-marketplace-cards \ No newline at end of file diff --git a/skills/pack-higgsfield/skills/higgsfield-product-photoshoot b/skills/pack-higgsfield/skills/higgsfield-product-photoshoot new file mode 120000 index 0000000..b13fe59 --- /dev/null +++ b/skills/pack-higgsfield/skills/higgsfield-product-photoshoot @@ -0,0 +1 @@ +../../../skills-external/higgsfield-product-photoshoot \ No newline at end of file diff --git a/skills/pack-higgsfield/skills/higgsfield-soul-id b/skills/pack-higgsfield/skills/higgsfield-soul-id new file mode 120000 index 0000000..0664805 --- /dev/null +++ b/skills/pack-higgsfield/skills/higgsfield-soul-id @@ -0,0 +1 @@ +../../../skills-external/higgsfield-soul-id \ No newline at end of file diff --git a/skills/pack-higgsfield/skills/higgsfield-video-explainer b/skills/pack-higgsfield/skills/higgsfield-video-explainer new file mode 120000 index 0000000..59829f1 --- /dev/null +++ b/skills/pack-higgsfield/skills/higgsfield-video-explainer @@ -0,0 +1 @@ +../../../skills-external/higgsfield-video-explainer \ No newline at end of file diff --git a/skills/pack-higgsfield/skills/higgsfield-websites b/skills/pack-higgsfield/skills/higgsfield-websites new file mode 120000 index 0000000..c0eb4da --- /dev/null +++ b/skills/pack-higgsfield/skills/higgsfield-websites @@ -0,0 +1 @@ +../../../skills-external/higgsfield-websites \ No newline at end of file diff --git a/skills/pack-higgsfield/skills/higgsfield-youtube-thumbnail b/skills/pack-higgsfield/skills/higgsfield-youtube-thumbnail new file mode 120000 index 0000000..f1ed8ec --- /dev/null +++ b/skills/pack-higgsfield/skills/higgsfield-youtube-thumbnail @@ -0,0 +1 @@ +../../../skills-external/higgsfield-youtube-thumbnail \ No newline at end of file diff --git a/skills/pack-scroll3d/.claude-plugin/plugin.json b/skills/pack-scroll3d/.claude-plugin/plugin.json new file mode 100644 index 0000000..06cec00 --- /dev/null +++ b/skills/pack-scroll3d/.claude-plugin/plugin.json @@ -0,0 +1,7 @@ +{ + "name": "pack-scroll3d", + "version": "1.0.0", + "description": "Scroll-driven and Three.js world skills (Mengto set).", + "author": { "name": "bchanot" }, + "defaultEnabled": true +} diff --git a/skills/pack-scroll3d/skills/build-threejs-scroll-worlds b/skills/pack-scroll3d/skills/build-threejs-scroll-worlds new file mode 120000 index 0000000..ca261b6 --- /dev/null +++ b/skills/pack-scroll3d/skills/build-threejs-scroll-worlds @@ -0,0 +1 @@ +../../../skills-external/build-threejs-scroll-worlds \ No newline at end of file diff --git a/skills/pack-scroll3d/skills/scroll-progress-timeline b/skills/pack-scroll3d/skills/scroll-progress-timeline new file mode 120000 index 0000000..d2c129d --- /dev/null +++ b/skills/pack-scroll3d/skills/scroll-progress-timeline @@ -0,0 +1 @@ +../../../skills-external/scroll-progress-timeline \ No newline at end of file diff --git a/skills/pack-scroll3d/skills/scroll-scrubbed-visual-sequence b/skills/pack-scroll3d/skills/scroll-scrubbed-visual-sequence new file mode 120000 index 0000000..4efbdc6 --- /dev/null +++ b/skills/pack-scroll3d/skills/scroll-scrubbed-visual-sequence @@ -0,0 +1 @@ +../../../skills-external/scroll-scrubbed-visual-sequence \ No newline at end of file diff --git a/skills/pack-scroll3d/skills/scroll-scrubbed-word-reveal b/skills/pack-scroll3d/skills/scroll-scrubbed-word-reveal new file mode 120000 index 0000000..908ae68 --- /dev/null +++ b/skills/pack-scroll3d/skills/scroll-scrubbed-word-reveal @@ -0,0 +1 @@ +../../../skills-external/scroll-scrubbed-word-reveal \ No newline at end of file diff --git a/skills/pack-scroll3d/skills/scroll-world-storytelling b/skills/pack-scroll3d/skills/scroll-world-storytelling new file mode 120000 index 0000000..d51f90f --- /dev/null +++ b/skills/pack-scroll3d/skills/scroll-world-storytelling @@ -0,0 +1 @@ +../../../skills-external/scroll-world-storytelling \ No newline at end of file diff --git a/skills/pack-seo/.claude-plugin/plugin.json b/skills/pack-seo/.claude-plugin/plugin.json new file mode 100644 index 0000000..1f32bfb --- /dev/null +++ b/skills/pack-seo/.claude-plugin/plugin.json @@ -0,0 +1,7 @@ +{ + "name": "pack-seo", + "version": "1.0.0", + "description": "SEO and GEO audit skills.", + "author": { "name": "bchanot" }, + "defaultEnabled": true +} diff --git a/skills/geo/SKILL.md b/skills/pack-seo/skills/geo/SKILL.md similarity index 100% rename from skills/geo/SKILL.md rename to skills/pack-seo/skills/geo/SKILL.md diff --git a/skills/geo/test-prompts.json b/skills/pack-seo/skills/geo/test-prompts.json similarity index 100% rename from skills/geo/test-prompts.json rename to skills/pack-seo/skills/geo/test-prompts.json diff --git a/skills/seo/SKILL.md b/skills/pack-seo/skills/seo/SKILL.md similarity index 100% rename from skills/seo/SKILL.md rename to skills/pack-seo/skills/seo/SKILL.md diff --git a/skills/seo/resources/depth-matrix.md b/skills/pack-seo/skills/seo/resources/depth-matrix.md similarity index 93% rename from skills/seo/resources/depth-matrix.md rename to skills/pack-seo/skills/seo/resources/depth-matrix.md index 7d6327d..d26db29 100644 --- a/skills/seo/resources/depth-matrix.md +++ b/skills/pack-seo/skills/seo/resources/depth-matrix.md @@ -18,7 +18,7 @@ Owned by the agents, not this file — classical SEO weights are in weights varying by business type); GEO weights are in `agents/geo-analyzer.md` (STEP 10, 6 axes FULL / 5 axes LOCAL). Combined score formula (0.80/0.20 classical/GEO local-B2C, 0.75/0.25 SaaS/national) is -in `skills/seo/SKILL.md` (~line 273). +in `skills/pack-seo/skills/seo/SKILL.md` (~line 273). # Dedup rules — overlap with sibling skills @@ -32,6 +32,6 @@ in `skills/seo/SKILL.md` (~line 273). # Envelope schema for `.claude/audits/SEO.md` -Owned by `skills/seo/SKILL.md` (~lines 278-352, the real §0-§15 structure), +Owned by `skills/pack-seo/skills/seo/SKILL.md` (~lines 278-352, the real §0-§15 structure), not this file — both agents' envelopes are keyed to it (`agents/seo-analyzer.md` STEP 13, `agents/geo-analyzer.md` STEP 14). diff --git a/skills/seo/test-prompts.json b/skills/pack-seo/skills/seo/test-prompts.json similarity index 100% rename from skills/seo/test-prompts.json rename to skills/pack-seo/skills/seo/test-prompts.json diff --git a/skills/pack-web-validate/.claude-plugin/plugin.json b/skills/pack-web-validate/.claude-plugin/plugin.json new file mode 100644 index 0000000..f3dcb3a --- /dev/null +++ b/skills/pack-web-validate/.claude-plugin/plugin.json @@ -0,0 +1,7 @@ +{ + "name": "pack-web-validate", + "version": "1.0.0", + "description": "W3C and WCAG conformance skill.", + "author": { "name": "bchanot" }, + "defaultEnabled": true +} diff --git a/skills/web-validate/SKILL.md b/skills/pack-web-validate/skills/web-validate/SKILL.md similarity index 100% rename from skills/web-validate/SKILL.md rename to skills/pack-web-validate/skills/web-validate/SKILL.md diff --git a/skills/web-validate/test-prompts.json b/skills/pack-web-validate/skills/web-validate/test-prompts.json similarity index 100% rename from skills/web-validate/test-prompts.json rename to skills/pack-web-validate/skills/web-validate/test-prompts.json diff --git a/skills/plugin-check/SKILL.md b/skills/plugin-check/SKILL.md index 6ad5cbd..42ccc6e 100644 --- a/skills/plugin-check/SKILL.md +++ b/skills/plugin-check/SKILL.md @@ -12,8 +12,9 @@ plugin-probe (sonnet) → validation checkpoint → dispatch plugin-advisor dispatched, gates in this loop). /plugin-check is READ-ONLY advisory: SKIP the gate's step 5 (apply) — show -the advisor's exact toggle commands for the user instead. Never write; user -toggles via `claude plugin enable/disable`. +the advisor's exact commands for the user instead. Never write: the user runs +them (`lib/profile.sh` `set ` / `enable ` writes the +project's `.claude/settings.local.json`, never the user scope). If `$HOME/.claude/lib/plugin-gate.md` unreachable: emit `Plugin gate include missing.` and STOP. diff --git a/skills/profile/SKILL.md b/skills/profile/SKILL.md index be40ece..06c98f7 100644 --- a/skills/profile/SKILL.md +++ b/skills/profile/SKILL.md @@ -2,159 +2,65 @@ name: profile effort: low description: | - Partition Claude skills by purpose: design, dev, qa, audit, minimal. - Toggles symlinks between skills/ and skills-disabled/ to keep only - the skills relevant to the current kind of work. - Trigger: "profile", "skill profile", "design profile", "qa profile", - "switch to design", "set profile", "active profile", "quel profil", - "profil design", "active les skills design", "désactive gstack", - "réduire le bruit gstack". -argument-hint: list | show | current | apply | set | reset | gstack on|off | diff + Set the pack profile of THIS project (writes .claude/settings.local.json) + or show the effective one of this conversation. Packs are skills-dir + plugins (design, scroll3d, seo, web-validate, gstack-dev/-browser/-design, + higgsfield, extras); a profile is a settings fragment lib/profiles/.json. + Trigger: "profile", "skill profile", "design profile", "set profile", + "active profile", "quel profil", "profil design", "active les skills + design", "enable higgsfield", "désactive gstack", "réduire le listing". +argument-hint: list | show | current | set | unset | enable | disable | diff allowed-tools: - Bash - Read --- -# profile +# /profile — packs per project and per conversation -Activate a curated subset of skills for a specific kind of work — instead of -carrying every gstack + personal skill in every session. +Run `bash "$HOME/.claude/lib/profile.sh" -C "$PWD" $ARGUMENTS` and show its +output. With no argument, run `current` and then `list`. -## When to invoke +## What a profile is -- User asks to switch profile (`set design`, `profile dev`, `quel profil actif`). -- User wants to see what's in a profile (`profile show qa`). -- User wants to compare profiles (`profile diff design qa`). -- User asks to "reduce gstack noise" or "only design skills". +`lib/profiles/.json` holds `enabledPlugins` (every pack and managed +plugin, explicit), optional `deniedMcpServers` (the two higgsfield claude.ai +connectors) and optional `model`. Descriptions: `lib/profiles/README.md`. -## Profiles available +- Per project: `set ` merges the fragment into + `.claude/settings.local.json` (other keys kept). Then `/reload-plugins` + loads the packs in this session; connectors and model apply to the next + session. +- Per conversation: `cc ` (lib/cc.sh) runs + `claude --settings lib/profiles/.json`. That conversation is frozen: + editing the fragment or the local file changes nothing here, and a pack the + fragment turns off cannot come back; start another `cc`. +- No profile: the manifest defaults, which equal `full` with the connectors + present. -| Profile | Use case | -|------------|----------| -| `web` | Public website work — frontend + content + light dev | -| `seo` | SEO + GEO + W3C audit — search/AI indexability + standards | -| `web-full` | Production website end-to-end — `web` + `seo` combined | -| `full` | Default — everything the other profiles carry, minus broken or doctrine-breaking gstack | -| `max` | Everything — full + parked tools (make-pdf, diagram, 21st generation trio) + pr-review-toolkit | -| `backend` | Backend / API / system dev — no design, no SEO | -| `design` | Visual QA, design systems, mockups, polish | -| `dev` | Daily code work — features, fixes, refactor, ship (any stack) | -| `qa` | Site testing, perf, canary, validation | -| `audit` | Comprehensive audit — security + SEO + GEO + W3C + perf + health | -| `minimal` | Strip all gstack skills (quiet session) | +## Verbs -## Mechanism +| verb | effect | +|---|---| +| `list` | names + descriptions | +| `show ` | the fragment: packs on/off, denied connectors, model; `missing` on a pack with no `skills/pack-/` | +| `current [--plain]` | effective state of this project and conversation; `--plain` is what gates and the statusline read | +| `set ` | write the fragment into the local file | +| `unset` | remove the managed keys from the local file | +| `enable ` / `disable ` | one pack (`design`, `pack-design` or a plugin id) | +| `diff ` | effective state against a fragment | -Each profile is a plain-text file under `lib/profiles/.profile` that -lists items + types: +Refusals (rc 2, nothing written): unknown profile or pack, not a project +root (no `CLAUDE.md`, no `.git`), unreadable or invalid local JSON. -| Type | Toggle mechanism | -|-------------------------|------------------| -| `gstack` | symlink move skills/ ↔ skills-disabled/gstack__\ | -| `personal` | symlink move skills/ ↔ skills-disabled/\ (no prefix) | -| `external` | symlink move skills/ ↔ skills-disabled/\ | -| `plugin@` | `claude plugin enable\|disable @` (auto) | -| `mcp` | advisory — prints manual `claude mcp add …` command (no server is managed today: `MANAGED_MCPS` is empty since 21st.dev moved to a CLI) | -| `cli` | advisory only — reports installed/not-installed | +## Rules -**Always-on plugins** (`security-guidance`) and the vendored superpowers -skills are never toggled by a profile — `set` will refuse to disable the -plugin even if the profile omits it, and the 7 superpowers skills are -linked outside any profile. -**Managed plugins** that `set` may disable when not in profile: -`ui-ux-pro-max@ui-ux-pro-max-skill`, `plugin-dev@claude-code-plugins`, -`pr-review-toolkit@claude-code-plugins`. Other plugins are never auto-toggled. -**Managed externals** (`emil-design-eng`, `frontend-design`, -`design-motion-principles`, `impeccable`, and the five 21st design skills -`21st-ui-build`, `21st-ui-explore`, `21st-ui-review`, `21st-cli-use`, -`21st-ai`) follow the same symmetry (BDR-079): `set` enables them when the -profile lists them (from parked state, or from `skills-external/` if the -symlink never existed) and parks them when it does not — e.g. `set backend` -after design work turns emil and the 21st pack off. `darwin-skill`, -`21st-registry`, `21st-design-sync` and any other unlisted external are never -auto-touched. gstack works the same -all the way down: a profile listing gstack skills while the whole pack is -off (via `toggle-external.sh`) re-enables JUST those skills on demand. - -**Default profile**: `full` is in force whenever `.active-profile` is -absent, empty, or the legacy `none` (statusline, `current`, `gstack off`, -`reset` all resolve it the same way). `reset` applies it (`set full`, -exclusive); a fresh `make plugin` applies it too when nothing has ever -been selected. - -## Commands - -```bash -# List available profiles -bash "$HOME/.claude/lib/profile.sh" list - -# Show profile contents + per-skill status -bash "$HOME/.claude/lib/profile.sh" show - -# Report the active profile (label + match %) -bash "$HOME/.claude/lib/profile.sh" current - -# Enable skills in profile (additive — keeps others enabled) -bash "$HOME/.claude/lib/profile.sh" apply - -# Enable only skills in profile (disables non-listed gstack skills) -bash "$HOME/.claude/lib/profile.sh" set - -# Go to the default profile (full) — exclusive, same as `set full` -bash "$HOME/.claude/lib/profile.sh" reset - -# Toggle gstack only, keeping the active-profile label intact -bash "$HOME/.claude/lib/profile.sh" gstack on # restore parked gstack skills on top of the current profile -bash "$HOME/.claude/lib/profile.sh" gstack off # disable gstack skills not in the active profile - -# Compare two profiles -bash "$HOME/.claude/lib/profile.sh" diff -``` - -## Execution - -Run `lib/profile.sh` with the user's arguments. If user passed nothing, default -to `list`. If user named a profile without a verb (e.g. "profile design"), -treat it as `set ` — but confirm first because `set` disables other gstack -skills. - -```bash -bash "$HOME/.claude/lib/profile.sh" $ARGUMENTS -``` - -## Failure modes - -| Trigger | First move | If still stuck | -|---|---|---| -| `lib/profile.sh` absent (foreign machine, links broken) | `test -f "$HOME/.claude/lib/profile.sh"` before any verb; missing → propose `bash link.sh` from the config repo | STOP — never hand-move symlinks to emulate the script | -| Unknown profile name (rc=1, `✗ Profile not found`) | Show `list` output + the closest existing name ("`desing` → did you mean `design`?") | Let the user pick — never guess-and-`set` | -| Unknown verb (rc=1 + usage) | Re-map the request to the argument-hint verbs, retry once | Show usage, ask | -| `set`/`apply` exits nonzero MID-TOGGLE (permission, plugin CLI failure) | State may be PARTIAL. Run `current` to show what actually took; name the failed item from the script's output | run `current`, then re-run `set ` or `reset` (both are full exclusive applies, not an always-safe undo) | -| Plugin/MCP leg fails (marketplace/network) while symlink leg succeeded | Report the split state explicitly + print the manual `claude plugin`/`claude mcp` command for the failed leg | — | -| `current` names a profile other than the one just set | Cache (`.active-profile`) was written by another tool or hand-edited — show the raw script output to the user | Never hand-patch `.active-profile` — re-run `set ` (or `reset`) to force it back | - -## Output policy - -- After `set` / `apply` / `reset` / `gstack on|off`: show the count of skills - moved + tell the user to start a new Claude session to pick up the changes - (Claude scans `skills/` at session start). -- After `current`: report the active profile + match %; `default — not - applied yet` means the default profile is in force but not yet applied — - point the user at `reset`. -- After `show`: render the grouped output directly — no extra commentary unless - the user asks. - -## Tradeoffs to mention if asked - -- gstack skills still depend on `~/.claude/skills/gstack/bin/` for telemetry, - update-check, learnings — script doesn't touch that infra. Disabled skills - are just hidden from Claude Code's scanner; the gstack repo stays installed. -- Profile changes DO toggle the managed Claude Code plugins (ui-ux-pro-max, - plugin-dev, pr-review-toolkit) and the managed external packs - (emil-design-eng, frontend-design, design-motion-principles, impeccable, - the 21st design skills) — in BOTH directions: `set` enables what the profile - lists and disables the managed leftovers it doesn't (BDR-008, BDR-079). - Anything outside those allowlists stays manual: `claude plugin - enable|disable`, `bash lib/toggle-external.sh enable|disable `. -- `set` is destructive in the sense that it disables non-listed gstack skills. - Use `apply` if the user wants additive behavior. +- 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 + project set to `dev` keeps the connectors denied; `set web` in the + project brings them back for the next session. +- `max` turns on `pack-extras` (diagram, make-pdf, 21st-ai, 21st-ui-explore, + 21st-ui-review); `pack-higgsfield` is on in `max` only, else `enable + higgsfield` for a named media ask. diff --git a/skills/profile/test-prompts.json b/skills/profile/test-prompts.json index 04bb922..ea54f04 100644 --- a/skills/profile/test-prompts.json +++ b/skills/profile/test-prompts.json @@ -1,5 +1,5 @@ [ - {"id": 1, "prompt": "profile list", "expected": "Skill runs `bash $HOME/.claude/lib/profile.sh list` and prints the table of every profile defined under lib/profiles/*.profile (10 today, incl. web, full, minimal) without extra commentary."}, - {"id": 2, "prompt": "active les skills design — désactive le bruit gstack", "expected": "Skill interprets this as `set design` (destructive — disables non-listed gstack skills), confirms first since `set` is destructive, then runs `bash $HOME/.claude/lib/profile.sh set design` and reports the count of skills moved plus the reminder to start a new Claude session to pick up changes."}, - {"id": 3, "prompt": "quel profil est actif?", "expected": "Skill runs `bash $HOME/.claude/lib/profile.sh current` and reports the detected active profile with its match percentage; does NOT toggle any symlinks."} + {"id": 1, "prompt": "profile list", "expected": "Skill runs `bash $HOME/.claude/lib/profile.sh -C \"$PWD\" list` and prints the profiles defined under lib/profiles/*.json (web, full, minimal, ...) without extra commentary."}, + {"id": 2, "prompt": "active les skills design — désactive le bruit gstack", "expected": "Skill interprets this as `set design`, runs `bash $HOME/.claude/lib/profile.sh -C \"$PWD\" set design`, and reminds to run /reload-plugins (connectors and model apply to the next session)."}, + {"id": 3, "prompt": "quel profil est actif?", "expected": "Skill runs `bash $HOME/.claude/lib/profile.sh -C \"$PWD\" current` and reports 'profile: [local|default|conv ...]'; writes nothing."} ] diff --git a/update-all.sh b/update-all.sh index 85cd913..8d08bea 100644 --- a/update-all.sh +++ b/update-all.sh @@ -80,21 +80,17 @@ else _gstack_confirm="n" fi if [[ "$_gstack_confirm" =~ ^[Yy]$ ]]; then - # Capture gstack state before the update so we can restore it after - # ./setup runs (setup re-creates every symlink; without this, an - # update would silently re-enable a tool the user had disabled). - _gstack_state="unknown" - if [ -x "$REPO/lib/toggle-external.sh" ]; then - _gstack_state=$(bash "$REPO/lib/toggle-external.sh" status gstack 2>/dev/null || echo "unknown") - fi - if gstack_submodule_update_with_bump "$REPO"; then if [ -d "skills-external/gstack" ]; then if [ -x "skills-external/gstack/setup" ]; then - if (cd skills-external/gstack && ./setup) 2>/dev/null; then - ok "GStack updated" + if [ -d "$HOME/.claude/skills/gstack" ] && [ ! -L "$HOME/.claude/skills/gstack" ]; then + if (cd skills-external/gstack && ./setup) 2>/dev/null; then + ok "GStack updated" + else + warn "GStack ./setup failed — submodule updated but setup did not complete" + fi else - warn "GStack ./setup failed — submodule updated but setup did not complete" + warn "gstack: ~/.claude/skills/gstack is not the helper tree yet — run 'make link' first, then 'make plugin' (setup would write skill dirs into skills/)" fi else warn "GStack ./setup not found or not executable — skipping" @@ -112,12 +108,6 @@ if [[ "$_gstack_confirm" =~ ^[Yy]$ ]]; then if [ -d "$GSTACK_DIR" ]; then link_gstack_helpers "$GSTACK_DIR" "$GSTACK_DST" >/dev/null fi - - # Restore prior enabled/disabled state - if [ "$_gstack_state" = "disabled" ] && [ -x "$REPO/lib/toggle-external.sh" ]; then - bash "$REPO/lib/toggle-external.sh" disable gstack >/dev/null - info "gstack was disabled before update — restored to disabled" - fi else info "GStack update skipped" fi @@ -418,9 +408,15 @@ imp_install() { } echo "" echo "── Updating impeccable..." -IMP_SKILL_DIR="$HOME/.claude/skills/impeccable" -IMP_PARKED="$REPO/skills-disabled/impeccable" -if [ ! -f "$IMP_SKILL_DIR/SKILL.md" ] && [ ! -f "$IMP_PARKED/SKILL.md" ]; then +IMP_SKILL_DIR="$REPO/skills/impeccable" +IMP_HOME="$REPO/skills-external/impeccable" +# A real skills/impeccable (older install) is adopted, never removed. +if [ ! -e "$IMP_HOME" ] && [ -f "$IMP_SKILL_DIR/SKILL.md" ] \ + && [ ! -L "$IMP_SKILL_DIR" ]; then + mkdir -p "$REPO/skills-external" + (cd "$REPO" && mv skills/impeccable skills-external/impeccable) +fi +if [ ! -f "$IMP_HOME/SKILL.md" ]; then info "impeccable not installed — skipping (run: make plugin)" else IMP_VER="" @@ -436,8 +432,6 @@ print(d.get('impeccable',{}).get('version','latest')) if [ -z "${IMP_NODE:-}" ] || [ "$IMP_NODE" -lt 24 ]; then info "impeccable update skipped — needs Node >= 24 (found ${IMP_NODE:-none}); existing copy kept" else - IMP_WAS_PARKED=false - [ -d "$IMP_PARKED" ] && IMP_WAS_PARKED=true # Pin honored (LRN-077 class: a silent rules update changes audit output # on unchanged code) — bump the pin deliberately, then update. IMP_PIN="${IMP_VER:-latest}" @@ -454,11 +448,8 @@ print(d.get('impeccable',{}).get('version','latest')) if [ "$IMP_OK" = true ] && [ -f "$IMP_SKILL_DIR/SKILL.md" ]; then IMP_SKILL_VER=$(sed -n 's/^version:[[:space:]]*//p' "$IMP_SKILL_DIR/SKILL.md" | head -1) ok "impeccable refreshed (CLI ${IMP_VER:-latest}, skill ${IMP_SKILL_VER:-?})" - if [ "$IMP_WAS_PARKED" = true ]; then - rm -rf "${IMP_PARKED:?}" - mv "$IMP_SKILL_DIR" "$IMP_PARKED" - info "impeccable was parked by a profile — refreshed copy returned to skills-disabled/" - fi + [ ! -L "$IMP_SKILL_DIR" ] && cd "$REPO" && rm -rf skills-external/impeccable \ + && mv "$IMP_SKILL_DIR" skills-external/impeccable else warn "impeccable refresh failed (${IMP_FAIL:-no SKILL.md written}) — existing copy kept" fi @@ -467,8 +458,7 @@ fi # ── 7.3b. Update the Higgsfield CLI + skill pack ── # CLI: global npm bin. Skills: re-cloned by lib/higgsfield-skills.sh, which -# replaces the SOURCE under skills-external/ only: a pack parked in -# skills-disabled/ (symlinks to those sources) stays parked. +# replaces the SOURCE under skills-external/ only; the packs link it. echo "" echo "── Updating Higgsfield CLI + skill pack..." if ! command -v higgsfield &>/dev/null; then @@ -544,8 +534,7 @@ print(d.get('21st',{}).get('version','latest')) for _tfd in "$TFD_STAGE"/.claude/skills/*/; do [ -f "${_tfd}SKILL.md" ] || continue _tfd_name=$(basename "$_tfd") - # Refresh the SOURCE only. A parked copy in skills-disabled/ is left - # alone: re-enabling restores it, and the next update refreshes it. + # Refresh the SOURCE only; linked by pack-design / pack-extras. rm -rf "${REPO:?}/skills-external/${_tfd_name:?}" mv "$_tfd" "$REPO/skills-external/$_tfd_name" TFD_N=$((TFD_N + 1))