diff --git a/.gitignore b/.gitignore index 04f26a6..08e43a3 100644 --- a/.gitignore +++ b/.gitignore @@ -52,9 +52,9 @@ rules/context7.md graphify-out/ .ctx7-cache/ -# graphify's vendored skill — written into the repo by `graphify claude -# install` (install-plugins.sh STEP graphify), since ~/.claude/skills is a -# symlink to skills/. Untracked so a tool upgrade stops dirtying the tree. +# graphify's vendored skill — written by `graphify install` (install-plugins.sh +# STEP graphify) into ~/.claude/skills, a symlink to skills/. +# Untracked so a tool upgrade stops dirtying the tree. # test-prompts.json is hand-written for darwin and stays tracked. skills/graphify/SKILL.md skills/graphify/references/ diff --git a/USAGE.md b/USAGE.md index 5eaa617..fe4dfe6 100644 --- a/USAGE.md +++ b/USAGE.md @@ -176,11 +176,12 @@ Tu veux... | `/route` | Voir ou fixer la route du mod model-router | show / clear / off / on / reload / pending / ask on\|off / ask-tier on\|off / / model=… effort=… / switch on\|off / classify on\|off (classifieur de prompt) / verbose on\|off (transitions seules) ; `clear`, `off` et `/clear` réarment le garde d'écriture (voir ci-dessous) | | `/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. `/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 packs gstack-dev, -> gstack-browser et gstack-design, les plugins (pr-review-toolkit…) et marketplaces externes en ajoutent beaucoup d'autres ; -> `/skills-perso` liste tes skills personnels. +> 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 packs +> gstack-dev, gstack-browser et gstack-design, les plugins +> (pr-review-toolkit…) et marketplaces externes en ajoutent beaucoup +> d'autres ; `/skills-perso` liste tes skills personnels. --- @@ -1019,7 +1020,7 @@ SIGNALS: simple, CLI/embedded COST: ~0t (skills superpowers vendorisés, toujours actifs, 0 t passif) RECOMMENDATIONS: - SET : minimal (embedded : tous les packs éteints) + ↻ SET : minimal (embedded : tous les packs éteints) NOTE : skills superpowers (brainstorming, writing-plans...) restent disponibles par nom bare, même pour un firmware minimal. diff --git a/agents/client-handover-writer.md b/agents/client-handover-writer.md index ff81579..a696067 100644 --- a/agents/client-handover-writer.md +++ b/agents/client-handover-writer.md @@ -106,7 +106,9 @@ ROUTING: follow $HOME/.claude/lib/effort-shift.md (phases via mcp__model-router_ git rev-parse --is-inside-work-tree 2>/dev/null || { echo "NOT_GIT_REPO"; exit 1; } # Project root -PROJECT_ROOT=$(git rev-parse --show-toplevel) +# Sentinel keeps a trailing newline that $(...) would strip +PROJECT_ROOT=$(git rev-parse --show-toplevel; printf x) +PROJECT_ROOT=${PROJECT_ROOT%x}; PROJECT_ROOT=${PROJECT_ROOT%$'\n'} cd "$PROJECT_ROOT" # First commit (the start of the project) @@ -123,6 +125,9 @@ PIPELINE_BASE_SHA=$(git rev-parse HEAD) ``` If not in a git repo: stop and report `STATUS: BLOCKED — not a git repository`. +A `PROJECT_ROOT` holding a newline or control character (`case +"$PROJECT_ROOT" in *[[:cntrl:]]*`) → `STATUS: BLOCKED` before anything +is written, the PACKAGE line cannot carry it. --- @@ -1110,6 +1115,10 @@ it, don't recompute) or resolved in 9.1–9.5: `is_local_business` (`IS_LOCAL_BUSINESS`), `deployed_url` (`DEPLOYED_URL`), `period` (`FIRST_COMMIT_DATE` → `LAST_COMMIT_DATE`, reformatted DD/MM/YYYY). +- `PROJECT_ROOT` — its own line `PROJECT_ROOT: `, the STEP 1 + `PROJECT_ROOT` verbatim (the `PROJECT` line is space-separated and + mis-parses a root holding a space; the doc-writer reads this line + whole). - `SCORES` — `SCORE_SEO_BEFORE/AFTER`, `SCORE_GEO_BEFORE/AFTER`, `SCORE_HARDEN_BEFORE/AFTER`, `SCORE_VALIDATE_AFTER` (web) or `SCORE_CSO_BEFORE/AFTER` (non-web), each with the pass-status and @@ -1136,7 +1145,7 @@ contract. Dispatch the two-mode pipeline (BDR-077 — synthesis on opus, render on the sonnet pin, full PACKAGE both times per LRN-126). Mint a RUNID first (`RUNID=$(date +%s)`); the draft crosses via the run-scoped, gitignored -`.audit/handover-draft-.md`; clean it after 9.7. +`"${PROJECT_ROOT:?}/.audit/handover-draft-.md"`; clean it after 9.7. FIRST — synthesize: @@ -1163,6 +1172,7 @@ prompt: "MODE: render RUNID: PACKAGE: LANG: +PROJECT_ROOT: PROJECT: name= root= type= sub-type= is_local_business= deployed_url= period= SCORES: seo= geo= @@ -1199,8 +1209,9 @@ Parse the returned `HANDOVER-DOC REPORT`: add the bullet: - Memory: For unreadable IDs, give the remedy: `bash ~/.claude/lib/memory.sh -C - status ", …"` (a status word, e.g. resolved or - open), then re-run. + '' status ", …"` (a status word, e.g. resolved or + open), then re-run. A root holding `'` → print the remedy with a + warning that the path needs manual quoting, never run it. - `STATUS: BLOCKED` → surface the report verbatim (including which PACKAGE field the doc-writer flagged) and stop — do not retry or patch the PACKAGE silently. Re-run PUSH STATE READ and add the same @@ -1208,5 +1219,5 @@ Parse the returned `HANDOVER-DOC REPORT`: - Push: In BOTH branches, then clean the transient draft: -`rm -f ".audit/handover-draft-${RUNID}.md"` (run-scoped, gitignored — -cleanup keeps `.audit/` from accumulating stranded drafts). +`rm -f "${PROJECT_ROOT:?}/.audit/handover-draft-${RUNID}.md"` (run-scoped, +gitignored — cleanup keeps `.audit/` from accumulating stranded drafts). diff --git a/agents/handover-doc-writer.md b/agents/handover-doc-writer.md index baf2714..26addd0 100644 --- a/agents/handover-doc-writer.md +++ b/agents/handover-doc-writer.md @@ -18,6 +18,9 @@ parent already resolved: - `LANG` — output language (`fr` | `en`). - `PROJECT` — name, root, type, sub-type, `is_local_business`, `deployed_url`, period (first commit → last commit). +- `PROJECT_ROOT` — the project root on its own line, `PROJECT_ROOT: `. + Read it whole-line (a path may hold spaces); every git and file read + below is rooted on it. - `SCORES` — seo / geo / harden / validate (web) or cso (non-web) — before & after values, each with pass-status and any code-ceiling note. Source of truth for §2 — do not recompute. @@ -52,8 +55,8 @@ The parent dispatches this agent TWICE, with the FULL PACKAGE both times - **`MODE: synthesize`** — dispatched with `model: "opus"` (judgment tier; call-site override over the sonnet pin). Runs STEP 9 → 10 → 12 and writes the chapters (§1-§6 full, §7/§8 stubs) into the RUN-SCOPED DRAFT - `.audit/handover-draft-.md`, ending the file with the line - `DRAFT COMPLETE — RUNID: `. Then emits a `SYNTH REPORT` + `"${ROOT:?}/.audit/handover-draft-.md"`, ending the file with + the line `DRAFT COMPLETE — RUNID: `. Then emits a `SYNTH REPORT` (template below, `MEMORY:` line mandatory on DONE) and STOPS — STEP 13-16, the final MD, HTML and PDF are NEVER this mode's job. - **`MODE: render`** — runs on its sonnet row (frontmatter = off-state floor). FIRST loads the @@ -79,9 +82,23 @@ MEMORY: unreadable BLK: | no blockers file | reader ## STEP 9 — LOAD MEMORY REGISTRIES +The PACKAGE `PROJECT_ROOT` value pasted between the markers below is +exactly one line with no control character, checked BEFORE the paste: a +value holding a newline or a control character → `STATUS: BLOCKED` +before any Bash call (the block cannot see a newline, `read -r` keeps +only the first line and a line equal to `ROOT_END` would close the +heredoc). + ```bash -ROOT="" -MEMORY_DIR="$ROOT/.claude/memory" +# Whole-line read of the PACKAGE `PROJECT_ROOT: ` value (spaces kept, +# nothing expanded): replace the placeholder line with the path, never +# paste it into a double-quoted literal. This block opens EVERY Bash call +# that uses $ROOT (the shell keeps no state between calls). +IFS= read -r ROOT <<'ROOT_END' + +ROOT_END +case "$ROOT" in *[[:cntrl:]]*) echo "ROOT_UNSAFE"; exit 1 ;; esac +MEMORY_DIR="${ROOT:?}/.claude/memory" test -d "$MEMORY_DIR" || MEMORY_DIR="" # Blocker statuses through the shared reader (BDR-129): never parsed by hand. B="$MEMORY_DIR/blockers.md" @@ -96,6 +113,21 @@ SYNTH REPORT `MEMORY:` line. `blockers: no-file` → no blocker in §5, `MEMORY: no blockers file`. `blockers: reader-unavailable` → no blocker in §5, `MEMORY: reader unavailable`. +Decision statuses come from the same shared reader, never from the +entry prose: + +```bash +bash "$HOME/.claude/lib/memory.sh" -C "${ROOT:?}" index decision +``` + +Only BDRs whose current word is `accepted`, `implemented` or `proposed` +feed §6.1; `superseded` and `deprecated` ones are left out. A decision +whose word is empty is counted as unreadable, not dropped silently. + +A `ROOT_UNSAFE` print (the first line of the root holds a control +character) or a pre-paste refusal (see above) → `STATUS: BLOCKED` naming +the PACKAGE `PROJECT_ROOT` field. + If memory dir exists, read each file in full for the narrative fields (titles, decisions, why, alternatives, cause, solution, journal summaries). A blocker's status is never taken from the file's prose, @@ -116,22 +148,29 @@ final report that memory was unavailable. ## STEP 10 — GIT HISTORY SUMMARY +Every git command is rooted on the PACKAGE root (`$ROOT`, STEP 9), never +on the working directory: + ```bash -git log --reverse --format='%h|%aI|%an|%s' | head -200 -git log --name-only --format='---COMMIT---' | grep -v '^---' | sort -u | head -50 +git -C "${ROOT:?}" log --reverse --format='%h|%aI|%an|%s' | head -200 +git -C "${ROOT:?}" log --name-only --format='---COMMIT---' \ + | grep -v '^---' | sort -u | head -50 -git log --diff-filter=A --name-only --format='' | sort -u | wc -l # added -git log --diff-filter=M --name-only --format='' | sort -u | wc -l # modified -git log --diff-filter=D --name-only --format='' | sort -u | wc -l # deleted +git -C "${ROOT:?}" log --diff-filter=A --name-only --format='' \ + | sort -u | wc -l # added +git -C "${ROOT:?}" log --diff-filter=M --name-only --format='' \ + | sort -u | wc -l # modified +git -C "${ROOT:?}" log --diff-filter=D --name-only --format='' \ + | sort -u | wc -l # deleted -git tag --sort=-creatordate | head -5 +git -C "${ROOT:?}" tag --sort=-creatordate | head -5 ``` Cluster commits into 3-7 chronological phases based on commit message themes. Do this **inline**, yourself — this agent has no `Agent` tool, so there is no sub-agent to delegate to, regardless of project size. -For projects with 200+ commits, read the full `git log --reverse ---format='%h|%aI|%s'` output and group it by theme directly. For each +For projects with 200+ commits, read the full `git -C "${ROOT:?}" log +--reverse --format='%h|%aI|%s'` output and group it by theme directly. For each phase: name, commit count, 2-line summary. Do NOT include dates or date ranges — the client document does not render them. @@ -339,7 +378,8 @@ End with two callouts: ## 5. Ce qui vous reste à faire [Action-only checklist for the client. Pull from: -**`.claude/audits/HUMAN-ACTIONS.md` FIRST when present** (the /seo//geo +**`"${ROOT:?}/.claude/audits/HUMAN-ACTIONS.md"` FIRST when present** +(the /seo//geo audit-end checklist — carry its automation notes, vulgarized), then open blockers from STEP 9 (unreadable ones excluded), ongoing-monitoring items, external platforms to claim, content updates only the client can make, deploy steps if @@ -419,10 +459,14 @@ visibilité."] ### 6.1 Choix techniques importants -[Vulgarize 3–7 BDR entries. Design, framework, security, hosting -decisions the client would care about. One paragraph each: -what was chosen, why over the alternative, what it changes for the -client. Drop entries the client cannot act on or care about.] +[Vulgarize 3–7 BDR entries whose STEP 9 status is accepted, +implemented or proposed (superseded and deprecated ones stay out). +Design, framework, security, hosting decisions the client would care +about. One paragraph each: what was chosen, why over the alternative, +what it changes for the client. Drop entries the client cannot act on +or care about. Close §6.1 with one method sentence: superseded and +deprecated decisions are left out, and "status unreadable (n)" counts those with +an empty status word.] ### 6.2 Comment on en est arrivé là (phases) @@ -503,7 +547,7 @@ des audits de santé. Pour toute question, contactez [contact].* --- > **MODE BOUNDARY.** STEP 12 is the last synthesize-mode step: write the -> drafted chapters to `.audit/handover-draft-.md` (+ the +> drafted chapters to `"${ROOT:?}/.audit/handover-draft-.md"` (+ the > `DRAFT COMPLETE — RUNID: ` terminal line), emit the SYNTH > REPORT, stop. Everything below (STEP 13-16) is `MODE: render` and > operates ON that draft. diff --git a/agents/plugin-advisor.md b/agents/plugin-advisor.md index 8d572cd..c208743 100644 --- a/agents/plugin-advisor.md +++ b/agents/plugin-advisor.md @@ -214,8 +214,8 @@ RULE: IF "simple" OR "hotfix": → recommend the lightweight skill only (see Skill routing by task size); a REQUEST-only signal drives no SET and no DISABLE (both are project-wide, persistent) -RULE: IF "embedded" signal (firmware, bare-metal, microcontroller, or Makefile+C without Node/Rust/Go): - → all packs off (profile `minimal`) +RULE: IF "embedded" signal from a project-level probe (`platformio.ini`, linker script, or Makefile+C without Node/Rust/Go): + → all packs off (profile `minimal`, `↻ SET : minimal`) → superpowers skills stay on (vendored, no toggle): useful for initial design brainstorm on complex drivers, unnecessary for single-function patches; just don't invoke them, no disable needed @@ -223,6 +223,9 @@ RULE: IF "embedded" signal (firmware, bare-metal, microcontroller, or Makefile+C → Recommend workflow: /analyze → /hotfix (patch) or /bugfix (investigation) or /ship-feature (multi-file) → NOTE: print "embedded project detected — minimal plugin footprint recommended" +RULE: IF "embedded" keywords appear in the REQUEST only (firmware, bare-metal, microcontroller, driver, kernel…), no project-level probe: + → NOTE only, no SET and no DISABLE (both are project-wide, persistent) + RULE: IF `browser-qa` signal (e2e tests, Playwright/Cypress/Puppeteer in deps): → pack gstack-browser ON — browser automation and QA → ctx7 CLI OPTIONAL (depends on framework version) @@ -260,7 +263,7 @@ the command. Never write files directly. | one pack off | — | `⚠️ DISABLE : … — disable ` | `` is one of design, scroll3d, seo, web-validate, gstack-dev, -gstack-browser, gstack-design, higgsfield, extras. Managed plugins take +gstack-browser, gstack-design, higgsfield. Managed plugins take their full id, never the bare name: `ui-ux-pro-max@ui-ux-pro-max-skill`, `pr-review-toolkit@claude-code-plugins`. @@ -278,7 +281,7 @@ generation service; explicit user ask only (CLAUDE.md "Skill routing"). ## BLOCK if -- Superpowers skills missing → `make plugin` (vendors them) then `make link` +- Superpowers skills missing → run `make plugin` in your claude-config checkout (vendors them) then `make link` ## WARN (no block) @@ -286,7 +289,7 @@ generation service; explicit user ask only (CLAUDE.md "Skill routing"). - Multi-session feature + `gsd` CLI not installed → `npm install -g gsd-pi` - **Next.js/React 18+/Prisma/Supabase detected + context7 not configured** → Risk: Claude may generate code using outdated APIs (App Router changes frequently) - → Fix: `npm install -g ctx7` (`make plugin` from the claude-config repo pins the version and wires find-docs) + → Fix: `npm install -g ctx7` (`make plugin` in your claude-config checkout installs ctx7 (latest, plugins.lock.json pins `latest`) and wires find-docs) → Or standalone: `ctx7 docs /vercel/next.js "middleware"` → Free higher rate limits: `ctx7 login` (OAuth) or API key from context7.com/dashboard → Type "force" to proceed without context7 (not recommended for fast-evolving libs) diff --git a/install-plugins.sh b/install-plugins.sh index 00cc32e..4e6c533 100644 --- a/install-plugins.sh +++ b/install-plugins.sh @@ -687,16 +687,17 @@ else fi if command -v graphify &>/dev/null; then _graphify_ok=1 - info "Running graphify install (dependencies)..." + info "Running graphify install (appends its block to ~/.claude/CLAUDE.md; the exit trap reverts the repo copy)..." graphify install 2>/dev/null || { warn "graphify install failed — run manually"; _graphify_ok=0; } - info "Configuring Claude Code integration..." + info "Running graphify claude install (CLAUDE.md block + PreToolUse hook; the exit trap reverts both)..." (cd "$REPO" && graphify claude install) 2>/dev/null || warn "graphify claude install failed" - # Success message gated on the real outcome (LRN-071 class: an - # unconditional ok after `|| warn` lies when a step failed). + # The message below is gated on `graphify install` only (LRN-071 class: + # an unconditional ok after `|| warn` lies when a step failed); `graphify + # claude install` just warns, the trap reverts what it wrote. if [ "$_graphify_ok" -eq 1 ]; then - ok "Graphify configured for Claude Code" + ok "Graphify installed (its CLAUDE.md block and hook reverted by the guard)" else - warn "Graphify NOT fully configured — re-run the failed step manually" + warn "Graphify install failed — re-run it manually" fi fi echo "" @@ -1268,7 +1269,7 @@ echo " 🔄 gsd v2 — standalone CLI 'gsd' (gsd-pi, not a Claud 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)" echo " 🔄 context7 CLI — ctx7 (npm global, standalone or MCP setup)" -echo " 🔄 graphifyy (CLI: graphify) — codebase knowledge graph (pipx, PreToolUse hook)" +echo " 🔄 graphifyy (CLI: graphify) — codebase knowledge graph (pipx; its CLAUDE.md block and hook are reverted by the guard)" echo " 🔄 emil-design-eng — UI polish, animations, component craft (curl → symlink)" echo " 🔄 frontend-design — distinctive frontend interfaces, anti-AI-slop (anthropic-agent-skills)" echo " 🔄 impeccable — /impeccable design verbs + 61-rule deterministic detector (npx impeccable detect)" diff --git a/lib/plugin-gate.md b/lib/plugin-gate.md index bd0bf9b..3ad2da3 100644 --- a/lib/plugin-gate.md +++ b/lib/plugin-gate.md @@ -41,24 +41,28 @@ PROBE REPORT (ground truth — do not re-detect): Show the returned PLUGIN CHECK block. The advisor emits tokens only; the main loop builds every command from the fixed templates of step 5, never -pastes the advisor's text into a shell. Before running ANY command (the -step-4 diff included) check each token: a profile name is one of the advisor's own set -(web, seo, dev, design, qa, audit, minimal; never `full`, `max` or a +pastes the advisor's text into a shell. A PROJECT_ROOT holding `'`, a +newline or a control character is never substituted into a template: print +the commands with the root shown as `''` and a warning that the +user must quote it by hand, and run nothing. Before running ANY command (the step-4 diff +included) check each token: a profile name is one of the advisor's own +set (web, seo, dev, design, qa, audit, minimal; never `full`, `max` or a user-added profile) and matches `^[a-z0-9][a-z0-9-]*$` with an existing -`$HOME/.claude/lib/profiles/.json`; -a pack is one of design, scroll3d, seo, web-validate, gstack-dev, -gstack-browser, gstack-design, extras (`higgsfield` is never accepted from an -advisor token: paid service, explicit user ask only); a plugin is one of the -two managed full ids `ui-ux-pro-max@ui-ux-pro-max-skill`, -`pr-review-toolkit@claude-code-plugins`. A token matching none is printed as -rejected and skipped, never run. +`$HOME/.claude/lib/profiles/.json`; a pack is one of design, scroll3d, +seo, web-validate, gstack-dev, gstack-browser, gstack-design (`higgsfield` +and `extras` are never accepted from an advisor token: paid or +credit-metered services, explicit user ask only, `profile.sh enable extras` +by hand); a plugin is one of the two managed full ids +`ui-ux-pro-max@ui-ux-pro-max-skill`, `pr-review-toolkit@claude-code-plugins`. +A token matching none is printed as rejected and skipped, never run. For a `↻ SET ` line run -`bash "$HOME/.claude/lib/profile.sh" -C "" diff ""` and +`bash "$HOME/.claude/lib/profile.sh" -C '' diff ''` and print its `→ off` lines under it as "turns off" (none → "turns off: nothing") and its `→ on` lines as "turns on" (none → "turns on: nothing"). The diff exits non-zero on a bad name, an unknown profile or a missing profiles dir: on any non-zero exit print "turns off: unknown" and continue. -- `ACTION REQUIRED? YES` → offer: A) fix plugins B) type "force". STOP until +- `ACTION REQUIRED? YES` → offer: A) fix plugins (print "run `make plugin` + in your claude-config checkout", run nothing) B) type "force". STOP until answered. - OK → print `✅ Plugin check passed — [active plugins] — complexity: %`. @@ -66,10 +70,13 @@ profiles dir: on any non-zero exit print "turns off: unknown" and continue. Trigger: a `↻ SET`, `⚡ ENABLE` or `⚠️ DISABLE` line. Under `source=flag` (`PROFILE :` block) the advisor emits only `relaunch: cc `: -nothing is applied. Apply only when -`git -C "" rev-parse --show-toplevel` equals PROJECT_ROOT; -otherwise print the commands and apply nothing ("no git root yet: run them -after git init"). +nothing is applied. Apply only when the parent of +`git -C '' rev-parse --path-format=absolute --git-common-dir` +(the root profile.sh writes at, same in a linked worktree) equals +PROJECT_ROOT and PROJECT_ROOT is not `$HOME`; +otherwise print the commands and apply nothing, naming the cause: no git +root yet (run them after git init), a linked worktree or submodule, or +PROJECT_ROOT is `$HOME`. 1. List the changes, saying they are project-wide and persist in `/.claude/settings.local.json`: ``` @@ -82,9 +89,9 @@ after git init"). ``` 2. "yes" → run the changes in order, the SET first, then the deltas (after "customize" too). Each one is - `bash "$HOME/.claude/lib/profile.sh" -C "" set ""`, - `... enable ""` or - `... disable ""` (same prefix). Each call + `bash "$HOME/.claude/lib/profile.sh" -C '' set ''`, + `... enable ''` or + `... disable ''` (same prefix). Each call writes `.claude/settings.local.json` atomically or refuses (rc 2, nothing written): stop at the first non-zero rc, print its stderr, and continue with the current config. "customize" → user picks. "no" → proceed with @@ -93,7 +100,7 @@ after git init"). /reload-plugins to load the packs in this session (connectors and model: next session).` Say the change is project-wide and persists in `/.claude/settings.local.json`. Print the undo: after a SET: - `bash "$HOME/.claude/lib/profile.sh" -C "" unset`, after + `bash "$HOME/.claude/lib/profile.sh" -C '' unset`, after deltas the inverse enable / disable. **Never auto-activate without showing the list and getting confirmation. diff --git a/lib/profile.sh b/lib/profile.sh index 3b4dfd3..ad3e6d7 100755 --- a/lib/profile.sh +++ b/lib/profile.sh @@ -37,8 +37,8 @@ # and the statusline (supersedes `show --plain`, BDR-024). # # Exit: 0 ok · 2 usage, unknown profile or pack, not a project root (no -# CLAUDE.md and no .git), unreadable or invalid local JSON; nothing -# is written on any refusal. +# CLAUDE.md and no .git), refusing $HOME as the project root, +# unreadable or invalid local JSON; nothing is written on any refusal. # ============================================================ set -euo pipefail @@ -70,6 +70,12 @@ home_or_above() { # $1 dir case "$HOME/" in "$1"/*) return 0 ;; esac return 1 } +is_home() { # $1 dir: same physical dir as $HOME (symlinks resolved) + local d h + d="$(cd -P "$1" 2>/dev/null && pwd -P)" || return 1 + h="$(cd -P "$HOME" 2>/dev/null && pwd -P)" || return 1 + [ "$d" = "$h" ] +} git_root() { # $1 dir → parent of the git common dir, unless $HOME or above local common root common="$(git -C "$1" rev-parse --path-format=absolute --git-common-dir \ @@ -82,7 +88,7 @@ git_root() { # $1 dir → parent of the git common dir, unless $HOME or above find_root() { # $1 dir → the project root (see header) local d="$1" git_root "$d" && return 0 - while [ "$d" != / ] && [ "$d" != "$HOME" ]; do + while [ "$d" != / ] && ! is_home "$d"; do if [ -d "$d/.claude" ] || [ -f "$d/CLAUDE.md" ] || [ -e "$d/.git" ]; then echo "$d"; return 0 fi @@ -91,6 +97,7 @@ find_root() { # $1 dir → the project root (see header) echo "$1" } require_project_root() { + is_home "$PROJECT" && die "refusing \$HOME as the project root: $PROJECT" [ -f "$PROJECT/CLAUDE.md" ] || [ -e "$PROJECT/.git" ] \ || die "not a project root (no CLAUDE.md and no .git): $PROJECT" } diff --git a/lib/tests/profile.test.sh b/lib/tests/profile.test.sh index 83669f2..5196b31 100755 --- a/lib/tests/profile.test.sh +++ b/lib/tests/profile.test.sh @@ -178,6 +178,13 @@ check T26-home-rc "$rc" 0 check T26-home-local "$([ -f "$H2/work/.claude/settings.local.json" ] && echo yes)" yes check T26-home-not-root "$([ -e "$H2/.claude" ] && echo leaked)" "" +# a root that is $HOME (even through a symlink) is refused, rc 2, nothing written +H3="$FX/home3"; mkdir -p "$H3"; printf '# h\n' > "$H3/CLAUDE.md"; ln -s "$H3" "$FX/home3-link" +out="$(HOME="$FX/home3-link" PX "$H3" set devx 2>&1)"; rc=$? +check T27-home-root-rc "$rc" 2 +check_has T27-home-root-msg "$out" "refusing \$HOME as the project root" +check T27-home-root-nothing "$([ -e "$H3/.claude" ] && echo leaked)" "" + # timing: two jq calls, under 100 ms here (spec target 50 ms, measured in Task 12) t0=$(date +%s%N); P current --plain >/dev/null; t1=$(date +%s%N) ms=$(( (t1 - t0) / 1000000 )); echo "current --plain: ${ms} ms" diff --git a/lib/tests/session-banner.test.sh b/lib/tests/session-banner.test.sh index 55bf88b..0a6b9eb 100644 --- a/lib/tests/session-banner.test.sh +++ b/lib/tests/session-banner.test.sh @@ -163,8 +163,8 @@ check SB10-gate-vocab "$(gone lib/plugin-gate.md \ 'Pre-fetch ctx7|Enable ui-ux-pro-max \(')" 1 gate="$(cat "$ROOT/lib/plugin-gate.md")" check SB10-gate-diff "$(has "$gate" 'profile.sh" -C')" 1 -check SB10-gate-diff2 "$(has "$gate" 'diff ""')" 1 -check SB10-gate-root "$(has "$gate" 'rev-parse --show-toplevel')" 1 +check SB10-gate-diff2 "$(has "$gate" "diff ''")" 1 +check SB10-gate-root "$(has "$gate" '--git-common-dir')" 1 check SB10-gate-rejected "$(has "$gate" 'rejected')" 1 check SB10-gate-quoted "$(gone lib/plugin-gate.md '-C ')" 1 check SB10-advisor-fullid "$(has "$(cat "$ROOT/agents/plugin-advisor.md")" \ diff --git a/plugins.lock.json b/plugins.lock.json index 7060b06..2126086 100644 --- a/plugins.lock.json +++ b/plugins.lock.json @@ -34,7 +34,7 @@ "source": "pypi:graphifyy", "version": "latest", "managed_by": "pipx", - "note": "Codebase knowledge graph. CLI is 'graphify'. Install: pipx install graphifyy && graphify install && graphify claude install. Adds PreToolUse hook for Glob/Grep. pipx/PyPI ONLY — never npm/npx: a different publisher (rhanka/graphify) squats the same 'graphifyy' name on npm, a version-shadowing shim with its own conflicting 'graphify' bin." + "note": "Codebase knowledge graph. CLI is 'graphify'. Install: `make plugin` (pipx install graphifyy, then graphify install and graphify claude install; the installer's exit trap reverts the CLAUDE.md block and PreToolUse hook it writes into the repo). pipx/PyPI ONLY — never npm/npx: a different publisher (rhanka/graphify) squats the same 'graphifyy' name on npm, a version-shadowing shim with its own conflicting 'graphify' bin." }, "semgrep": { "source": "pypi:semgrep", diff --git a/skills/init-project/SKILL.md b/skills/init-project/SKILL.md index b16d468..1f5d501 100644 --- a/skills/init-project/SKILL.md +++ b/skills/init-project/SKILL.md @@ -40,7 +40,9 @@ so the user does not assume Claude has hung. ## STEP 0 — PLUGIN CHECK + AUTO-ACTIVATE Run `$HOME/.claude/lib/plugin-gate.md`. Feed request (dispatch plugin-probe → checkpoint → dispatch plugin-advisor; gates stay in this loop — BDR-077). -- ACTION REQUIRED → show RECOMMENDATIONS block, offer: A) fix plugins B) type "force". STOP. +- ACTION REQUIRED → show RECOMMENDATIONS block, offer: A) fix plugins + (print "run `make plugin` in your claude-config checkout", run nothing) + B) type "force". STOP. - PROPOSED CHANGES exist → show list, ask "Apply? (yes / no / customize)". Apply on confirm. - OK → `✅ Plugin check passed — [active plugins] — complexity: %`, continue. diff --git a/skills/onboard/SKILL.md b/skills/onboard/SKILL.md index 2d1360d..0f6d770 100644 --- a/skills/onboard/SKILL.md +++ b/skills/onboard/SKILL.md @@ -252,7 +252,7 @@ Pour chaque fast-lib détectée : ⚠️ ctx7 non installé — risque de code utilisant des APIs obsolètes sur : [liste fast-libs] Install : `npm install -g ctx7` - Version épinglée et find-docs : `make plugin` depuis le dépôt claude-config + Installe ctx7 (latest, plugins.lock.json pin `latest`) et find-docs : `make plugin` depuis le dépôt claude-config Ou continuer sans (non recommandé pour fast-libs). ``` Demander : `yes install now / continue without / skip audit`. @@ -384,12 +384,12 @@ passer ce chemin dans chaque brief d'audit. |---|---|---| | `analyze` | Déjà fait en STEP 5 | L3a | | `code-clean` | Spawn subagent `general-purpose` (audit-only, `model="opus"`, `effort="xhigh"` — BDR-076: dispatched audits off the session model) | L3a | -| `cso` | Si gstack ON → Skill(cso). Sinon → Agent general-purpose avec checklist OWASP + deps audit | L3a | +| `cso` | Si `pack gstack-dev on` → Skill(cso). Sinon → Agent general-purpose avec checklist OWASP + deps audit | L3a | | `doc` | Spawn subagent `doc-syncer` (auto-mode OFF, report-only) | L3a | | `seo` | Subagents seo-analyzer + geo-analyzer en parallèle | L3b | -| `design-review` | Si gstack ON → Skill design-review. Sinon → Agent ui-ux-pro-max context statique | L3b | -| `perf` | Si gstack ON + URL → Lighthouse. Sinon → static bundle audit | L3b | -| `a11y` | Si gstack ON + URL → axe-core. Sinon → Agent static a11y audit | L3b | +| `design-review` | Si `pack gstack-design on` → Skill design-review. Sinon → Agent ui-ux-pro-max context statique | L3b | +| `perf` | Si `pack gstack-browser on` + URL → Lighthouse. Sinon → static bundle audit | L3b | +| `a11y` | Si `pack gstack-browser on` + URL → axe-core. Sinon → Agent static a11y audit | L3b | ### STEP 6 dispatch (L3a portion) @@ -423,17 +423,17 @@ Agent( **Décision selon plugin state :** ```bash -# gstack actif ? +# pack gstack-dev actif ? (`profile.sh current`) 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 : +- **`pack gstack-dev on`** → invoquer le skill cso via Skill tool en lui passant le contexte archétype : ``` Skill(skill="cso", args="comprehensive --report-only --output .onboard-audit/cso.md --archetype --context-file .onboard-audit/archetype-context.md") ``` Note : le skill cso écrit son rapport lui-même ; on redirige via `--output` si supporté, sinon on capture la sortie et on écrit `.onboard-audit/cso.md` dans le skill parent. Les flags `--archetype` / `--context-file` informent le skill même s'il ne les consomme pas nativement (lisibilité + compat future). -- **gstack OFF** → fallback via Agent general-purpose, prompt **archetype-adaptive** : +- **`pack gstack-dev off`** → fallback via Agent general-purpose, prompt **archetype-adaptive** : ``` Agent( subagent_type="general-purpose", @@ -530,7 +530,7 @@ bash $HOME/.claude/lib/profile.sh -C "$PWD" current --plain 2>/dev/null | grep - En complément de cso (ON) OU du fallback (OFF) — un moteur SAST déterministe à côté de l'audit grep/raisonné. cso est un submodule gstack non modifiable ; -semgrep vit dans cet agent local. Lancé dans les DEUX branches gstack. +semgrep vit dans cet agent local. Lancé dans les DEUX branches (pack gstack-dev on / off). ``` Agent( @@ -547,7 +547,8 @@ Agent( ) ``` Si semgrep absent → l'agent rend DEGRADED (checklist seule) + recommande -`make plugin` ; NON bloquant en onboard (audit, pas gate). +`make plugin` (dans ton checkout claude-config) ; NON bloquant en +onboard (audit, pas gate). **Onboard n'a PAS de boucle verify→dev (`lib/verify-secure-loop.md`) — par conception.** onboard produit un RAPPORT d'audit, pas une modification à @@ -607,8 +608,10 @@ Options : Pré-check ressources navigateur : ```bash -# gstack actif ? +# pack gstack-browser actif ? bash $HOME/.claude/lib/profile.sh -C "$PWD" current --plain 2>/dev/null | grep -q '^pack-gstack-browser=on' +# pack gstack-design actif ? (condition du dispatch design-review) +bash "$HOME"/.claude/lib/profile.sh -C "$PWD" current --plain 2>/dev/null | grep -q '^pack-gstack-design=on' # URL déployée fournie par l'utilisateur en STEP 3 ? echo "${BRIEF_deployed_url:-none}" # dev server launchable ? @@ -636,7 +639,7 @@ Agent( - Core Web Vitals (estimé si pas d'URL live) - headings hierarchy, alt attrs, images formats - i18n / lang attribute - Si URL live fournie AND gstack actif: utiliser les outils live. + Si URL live fournie AND `pack gstack-browser on`: utiliser les outils live. Sinon: audit statique sur le code (HTML templates, Astro pages, Next Metadata API, etc.). Write report to `/.onboard-audit/seo.md`. Structure sections par catégorie, chaque issue cite fichier:ligne + sévérité. @@ -670,7 +673,7 @@ Agent( #### Dispatch design-review (si `design-review` dans audit_stack) -**Cas gstack ON + URL live OU dev server launchable :** +**Cas `pack gstack-design on` + URL live OU dev server launchable :** ``` Skill( skill="design-review", @@ -679,7 +682,7 @@ Skill( ``` Si le skill ne supporte pas `--output`, capturer la sortie et écrire à la main vers `.onboard-audit/design.md`. -**Cas gstack OFF OU pas de site déployable (ex: react-spa sans dev server):** +**Cas `pack gstack-design off` OU pas de site déployable (ex: react-spa sans dev server):** ``` Agent( subagent_type="general-purpose", @@ -703,7 +706,7 @@ Agent( 8. Interactions : focus visible, hover states, disabled states 9. Micro-interactions (billboard design ? transform scale(0.97) on :active ?) Write report to `/.onboard-audit/design.md`. - Note en haut : "STATIC MODE — gstack inactif ou pas de dev server ; audit limité au code." + Note en haut : "STATIC MODE — pack gstack-design off ou pas de dev server ; audit limité au code." Max 500 lignes. Cite fichier:ligne. """ ) @@ -715,7 +718,7 @@ Agent( #### Dispatch perf (si `perf` dans audit_stack) -**Cas gstack ON + URL live :** +**Cas `pack gstack-browser on` + URL live :** ``` Skill( skill="browse", @@ -724,7 +727,7 @@ Skill( ``` Puis parser le JSON Lighthouse (scores perf/a11y/bp/seo/pwa + top opportunities) → écrire `.onboard-audit/perf.md`. -**Cas gstack OFF OU pas d'URL :** +**Cas `pack gstack-browser off` OU pas d'URL :** ``` Agent( subagent_type="general-purpose", @@ -759,7 +762,7 @@ Agent( #### Dispatch a11y (si `a11y` dans audit_stack) -**Cas gstack ON + URL live :** +**Cas `pack gstack-browser on` + URL live :** ``` Skill( skill="browse", diff --git a/skills/plugin-check/SKILL.md b/skills/plugin-check/SKILL.md index 6135465..1fd1248 100644 --- a/skills/plugin-check/SKILL.md +++ b/skills/plugin-check/SKILL.md @@ -13,9 +13,13 @@ dispatched, gates in this loop). /plugin-check is READ-ONLY advisory: SKIP the gate's step 5 (apply) — show the commands the main loop builds from the gate's step-5 templates (`set` / -`enable` / `disable`, with `-C ""`), after the gate's token -check, 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). +`enable` / `disable`, with `-C ''`), after the gate's token +check, for the user instead. A PROJECT_ROOT holding `'`, a newline or a +control character is never substituted: print the commands with the root shown as `''` and a warning that +the user must quote it by hand, run nothing. +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/ship-feature/SKILL.md b/skills/ship-feature/SKILL.md index d9802b3..ecf8ba4 100644 --- a/skills/ship-feature/SKILL.md +++ b/skills/ship-feature/SKILL.md @@ -24,7 +24,9 @@ $ARGUMENTS ## STEP 0 — PLUGIN CHECK + AUTO-ACTIVATE Run `$HOME/.claude/lib/plugin-gate.md`. Feed request (dispatch plugin-probe → checkpoint → dispatch plugin-advisor; gates stay in this loop — BDR-077). -- ACTION REQUIRED → show RECOMMENDATIONS block, offer: A) fix plugins B) type "force". STOP. +- ACTION REQUIRED → show RECOMMENDATIONS block, offer: A) fix plugins + (print "run `make plugin` in your claude-config checkout", run nothing) + B) type "force". STOP. - PROPOSED CHANGES exist → show list, ask "Apply? (yes / no / customize)". Apply on confirm. - OK → `✅ Plugin check passed — [active plugins] — complexity: %`, continue. diff --git a/skills/tour/SKILL.md b/skills/tour/SKILL.md index 49f99ee..6283e58 100644 --- a/skills/tour/SKILL.md +++ b/skills/tour/SKILL.md @@ -152,8 +152,9 @@ honestly in the summary. Never loop past 3. ``` semgrep ABSENT → DEGRADED (checklist only) is surfaced in the report, not a silent downgrade and not a blocker. -2. gstack ON (`/cso` available) → **iteration 1 only**, dispatch a cso - posture audit (deps CVE, OWASP) in audit mode; fold its findings in. +2. `pack gstack-dev on` (`profile.sh current`; `/cso` available) → + **iteration 1 only**, dispatch a cso posture audit (deps CVE, OWASP) + in audit mode; fold its findings in. 3. Fix policy (skip in `--report-only`): CRITICAL/HIGH → fix now. MEDIUM/LOW → fix only if local and behavior-preserving, else leave `open`. Every fix minimal, CLAUDE.md security defaults apply. diff --git a/update-all.sh b/update-all.sh index bbba001..64a26ff 100644 --- a/update-all.sh +++ b/update-all.sh @@ -308,8 +308,9 @@ else fi # NOT updated here, deliberately (audit 2026-07-02): # - graphify Claude integration (`graphify claude install`): rewrites curated -# CLAUDE.md / .claude/settings.json (BDR-028 guard territory) — re-run -# MANUALLY only if a graphify upgrade changes its hook format. +# CLAUDE.md / .claude/settings.json (BDR-028 guard territory) — run +# `make plugin` in your claude-config checkout (its exit trap reverts the +# drift); never run `graphify claude install` by hand. # - gsd: pinned in plugins.lock.json — Step 4 reinstalls the PIN, it does not # advance it. Bump the lock deliberately, then re-run.