diff --git a/Makefile b/Makefile index 6aa49f1..ff136fb 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ seo-connect: ## Connect a Google account for /seo FULL (creates venv, OAuth cons @bash -c 'read -r -p "Label for this account (e.g. client-a): " label; \ bash lib/seo-data/connect.sh --label "$$label"' -SUITES = lib/tests/*.test.sh lib/seo-data/*.test.sh lib/gitflow-test.sh lib/tests/run-*.sh +SUITES = lib/tests/*.test.sh lib/seo-data/*.test.sh lib/gitflow-test.sh lib/tests/run-*.sh skills/prune-memory/tests/run-deterministic.sh test: ## Run deterministic tests hermetically (one: make test suite=lib/tests/x.test.sh) @# Hermetic git: the machine's global core.hooksPath (BDR-095) must not @# fire inside the throwaway repos the suites build. The export lives diff --git a/hooks/design-toolchain-reminder.sh b/hooks/design-toolchain-reminder.sh index 68547eb..0c23fbd 100755 --- a/hooks/design-toolchain-reminder.sh +++ b/hooks/design-toolchain-reminder.sh @@ -48,7 +48,21 @@ lc="$(printf '%s' "$prompt" | tr '[:upper:]' '[:lower:]')" # French prose ("changement ux vu…"; 2 logged FPs, both FR). \bui\b KEPT # (zero logged FP, one logged true positive). NB: the log records only the # FIRST match per fire (head -1), so per-token FP rates aren't derivable. -pattern='redesign|refonte|refont|ui/ux|ux/ui|\bui\b|ui kit|design system|design-system|front-?end design|\bnavbar\b|\bsidebar\b|\bmodal\b|\bbouton\b|\bbutton\b|formulaire|\bhero\b|\bheader\b|\bfooter\b|dropdown|tooltip|\bbadge\b|\bchart\b|graphique|accordion|carousel|\bslider\b|landing|\bdashboard\b|homepage|home page|\baccueil\b|\bécran\b|\becran\b|portfolio|maquette|mockup|wireframe|prototype|\bjoli\b|\bjolie\b|\bbeau\b|\bbelle\b|esth[eé]tique|aesthetic|\bvisuel\b|\bvisual\b|embellir|fignol|peaufin|polish|styliser|styling|stylesheet|\bskin\b|charte graphique|\bbrand\b|branding|\blogo\b|favicon|ic[oô]ne|\bicon\b|\bcss\b|tailwind|shadcn|couleur|gradient|d[eé]grad[eé]|\bombre\b|spacing|espacement|\bmarge\b|\bpadding\b|\bmargin\b|\bradius\b|arrondi|\bhover\b|dark mode|light mode|typograph|\bfont\b|\bfonts\b|font pairing|\bpolice\b|animation|\bmotion\b|micro-interaction|keyframe|glassmorph|neumorph|claymorph|skeuomorph|brutalis|bento|minimalis|responsive|figma' +pattern='redesign|refonte|refont|ui/ux|ux/ui|\bui\b|ui kit|design system' +pattern+='|design-system|front-?end design|\bnavbar\b|\bsidebar\b|\bmodal\b' +pattern+='|\bbouton\b|\bbutton\b|formulaire|\bhero\b|\bheader\b|\bfooter\b' +pattern+='|dropdown|tooltip|\bbadge\b|\bchart\b|graphique|accordion|carousel' +pattern+='|\bslider\b|landing|\bdashboard\b|homepage|home page|\baccueil\b' +pattern+='|\bécran\b|\becran\b|portfolio|maquette|mockup|wireframe|prototype' +pattern+='|\bjoli\b|\bjolie\b|\bbeau\b|\bbelle\b|esth[eé]tique|aesthetic' +pattern+='|\bvisuel\b|\bvisual\b|embellir|fignol|peaufin|polish|styliser' +pattern+='|styling|stylesheet|\bskin\b|charte graphique|\bbrand\b|branding' +pattern+='|\blogo\b|favicon|ic[oô]ne|\bicon\b|\bcss\b|tailwind|shadcn|couleur' +pattern+='|gradient|d[eé]grad[eé]|\bombre\b|spacing|espacement|\bmarge\b' +pattern+='|\bpadding\b|\bmargin\b|\bradius\b|arrondi|\bhover\b|dark mode' +pattern+='|light mode|typograph|\bfont\b|\bfonts\b|font pairing|\bpolice\b' +pattern+='|animation|\bmotion\b|micro-interaction|keyframe|glassmorph|neumorph' +pattern+='|claymorph|skeuomorph|brutalis|bento|minimalis|responsive|figma' if printf '%s' "$lc" | grep -Eq "$pattern"; then # Counter: log the fire (time, matched token, excerpt) — best-effort, never blocks. diff --git a/lib/deploy-commit.sh b/lib/deploy-commit.sh index d237385..ee2d1e9 100644 --- a/lib/deploy-commit.sh +++ b/lib/deploy-commit.sh @@ -35,6 +35,19 @@ _out_of_scope() { # 0 = forbidden, 1 = in scope _scope_violations() { local p; for p in "$@"; do _out_of_scope "$p" && printf '%s\n' "$p"; done; } +# Exits 4 with the REFUSED text (parsed by the calling skill) when any +# passed path is outside the allowlist; returns normally otherwise. +_refuse_outside_allowlist() { + local violations + mapfile -t violations < <(_scope_violations "$@") + if [ "${#violations[@]}" -gt 0 ]; then + { echo "deploy-commit: REFUSED — path(s) outside .claude/deploy/ allowlist:"; + printf ' - %s\n' "${violations[@]}"; + echo "deploy-commit: NOTHING committed. Caller must pass only .claude/deploy/ files."; } >&2 + exit 4 + fi +} + _ignored() { git check-ignore -q "$1"; } # rc 0 = ignored _changed_only() { # echo passed files that actually have changes @@ -48,24 +61,12 @@ _in_git_repo || { echo "deploy-commit: not a git repo" >&2; exit 2; } case "$cmd" in pending) [ "$#" -gt 0 ] || { echo "deploy-commit: pending needs file args" >&2; exit 2; } - mapfile -t violations < <(_scope_violations "$@") - if [ "${#violations[@]}" -gt 0 ]; then - { echo "deploy-commit: REFUSED — path(s) outside .claude/deploy/ allowlist:"; - printf ' - %s\n' "${violations[@]}"; - echo "deploy-commit: NOTHING committed. Caller must pass only .claude/deploy/ files."; } >&2 - exit 4 - fi + _refuse_outside_allowlist "$@" [ -n "$(_changed_only "$@")" ] && exit 0 || exit 1 ;; commit) msg="${1:-}"; shift || true [ -n "$msg" ] && [ "$#" -gt 0 ] || { echo "deploy-commit: commit needs ..." >&2; exit 2; } - mapfile -t violations < <(_scope_violations "$@") - if [ "${#violations[@]}" -gt 0 ]; then - { echo "deploy-commit: REFUSED — path(s) outside .claude/deploy/ allowlist:"; - printf ' - %s\n' "${violations[@]}"; - echo "deploy-commit: NOTHING committed. Caller must pass only .claude/deploy/ files."; } >&2 - exit 4 - fi + _refuse_outside_allowlist "$@" mapfile -t ignored_paths < <(for p in "$@"; do _ignored "$p" && printf '%s\n' "$p"; done) if [ "${#ignored_paths[@]}" -gt 0 ]; then { echo "deploy-commit: REFUSED — path(s) are git-ignored and will NOT persist; \`.claude/deploy/\` must be committable in this project:"; diff --git a/lib/detect-plugins.sh b/lib/detect-plugins.sh index 6707450..f641e57 100644 --- a/lib/detect-plugins.sh +++ b/lib/detect-plugins.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # ============================================================ # lib/detect-plugins.sh — Single source of truth for plugin detection -# Sourced by: session-start.sh, doctor.sh, install-plugins.sh +# Sourced by: session-start.sh, doctor.sh, install-plugins.sh, update-all.sh # # Each function returns 0 (detected) or 1 (not detected). # No output — callers handle messaging. diff --git a/lib/seo-data/google_seo.py b/lib/seo-data/google_seo.py index 8914c67..7970f89 100644 --- a/lib/seo-data/google_seo.py +++ b/lib/seo-data/google_seo.py @@ -214,45 +214,52 @@ def inspect(store_path, account, property, url): "last_crawl": isr.get("lastCrawlTime"), "rich_results": _norm_rich(ir)} +def _build_parser(): + p = argparse.ArgumentParser() + sub = p.add_subparsers(dest="cmd", required=True) + pc = sub.add_parser("crux") + pc.add_argument("--url", required=True) + pc.add_argument("--strategy", default="mobile", choices=["mobile", "desktop"]) + pc.add_argument("--store", default=None) # accepted+ignored: uniform fetch.sh dispatch + pq = sub.add_parser("queries") + pq.add_argument("--store", required=True) + pq.add_argument("--account", required=True) + pq.add_argument("--property", required=True) + pq.add_argument("--days", type=int, default=90) + pq.add_argument("--dim", default="query", + help="one dimension, or a comma-separated list (query,page)") + pq.add_argument("--rows", type=int, default=100) + pn = sub.add_parser("cannibal") + pn.add_argument("--store", required=True) + pn.add_argument("--account", required=True) + pn.add_argument("--property", required=True) + pn.add_argument("--days", type=int, default=90) + pn.add_argument("--rows", type=int, default=1000) + pi = sub.add_parser("inspect") + pi.add_argument("--store", required=True) + pi.add_argument("--account", required=True) + pi.add_argument("--property", required=True) + pi.add_argument("--url", required=True) + return p + + +def _dispatch(args): + if args.cmd == "crux": + print(json.dumps(crux(args.url, args.strategy), indent=2)) + elif args.cmd == "queries": + print(json.dumps(queries(args.store, args.account, args.property, + args.days, args.dim, args.rows), indent=2)) + elif args.cmd == "cannibal": + print(json.dumps(cannibal(args.store, args.account, args.property, + args.days, args.rows), indent=2)) + elif args.cmd == "inspect": + print(json.dumps(inspect(args.store, args.account, args.property, + args.url), indent=2)) + + def _cli(): try: - p = argparse.ArgumentParser() - sub = p.add_subparsers(dest="cmd", required=True) - pc = sub.add_parser("crux") - pc.add_argument("--url", required=True) - pc.add_argument("--strategy", default="mobile", choices=["mobile", "desktop"]) - pc.add_argument("--store", default=None) # accepted+ignored: uniform fetch.sh dispatch - pq = sub.add_parser("queries") - pq.add_argument("--store", required=True) - pq.add_argument("--account", required=True) - pq.add_argument("--property", required=True) - pq.add_argument("--days", type=int, default=90) - pq.add_argument("--dim", default="query", - help="one dimension, or a comma-separated list (query,page)") - pq.add_argument("--rows", type=int, default=100) - pn = sub.add_parser("cannibal") - pn.add_argument("--store", required=True) - pn.add_argument("--account", required=True) - pn.add_argument("--property", required=True) - pn.add_argument("--days", type=int, default=90) - pn.add_argument("--rows", type=int, default=1000) - pi = sub.add_parser("inspect") - pi.add_argument("--store", required=True) - pi.add_argument("--account", required=True) - pi.add_argument("--property", required=True) - pi.add_argument("--url", required=True) - args = p.parse_args() - if args.cmd == "crux": - print(json.dumps(crux(args.url, args.strategy), indent=2)) - elif args.cmd == "queries": - print(json.dumps(queries(args.store, args.account, args.property, - args.days, args.dim, args.rows), indent=2)) - elif args.cmd == "cannibal": - print(json.dumps(cannibal(args.store, args.account, args.property, - args.days, args.rows), indent=2)) - elif args.cmd == "inspect": - print(json.dumps(inspect(args.store, args.account, args.property, - args.url), indent=2)) + _dispatch(_build_parser().parse_args()) except SystemExit as e: # argparse usage error if e.code not in (0, None): print(json.dumps({"status": "error", "reason": "bad_usage"})) diff --git a/lib/seo-data/safe_fetch.py b/lib/seo-data/safe_fetch.py index 820abd8..daade53 100644 --- a/lib/seo-data/safe_fetch.py +++ b/lib/seo-data/safe_fetch.py @@ -27,7 +27,6 @@ separate process and cannot be pinned from here. Their surface is smaller (a fixed set against an operator-typed/confirmed $DOMAIN). Closing them needs `curl --resolve` and is a separate change. """ -import gzip import http.client import ipaddress import socket diff --git a/lib/seo-data/seo-data.test.sh b/lib/seo-data/seo-data.test.sh index bc24cbf..5bbed0f 100644 --- a/lib/seo-data/seo-data.test.sh +++ b/lib/seo-data/seo-data.test.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash # Deterministic tests for the seo-data engine (no network, no venv). +# shellcheck disable=SC2015 # A && ok || no is deliberate (ok/no never fail) set -u REPO="$(cd "$(dirname "$0")/../.." && pwd)" SD="$REPO/lib/seo-data" diff --git a/lib/tests/push-guard.test.sh b/lib/tests/push-guard.test.sh index 2a341e3..d5ffa29 100644 --- a/lib/tests/push-guard.test.sh +++ b/lib/tests/push-guard.test.sh @@ -2,6 +2,7 @@ # lib/tests/push-guard.test.sh # hooks/push-guard.sh (BDR-111): denies `git push` in manual push mode, # silent otherwise. Also locks the settings.json wiring and the banner line. +# shellcheck disable=SC2016 # single-quoted forms are the commands under test set -u export GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null ROOT="$(cd "$(dirname "$0")/../.." && pwd)" diff --git a/lib/tests/run-review-guards.sh b/lib/tests/run-review-guards.sh index b52e563..e49f6b9 100644 --- a/lib/tests/run-review-guards.sh +++ b/lib/tests/run-review-guards.sh @@ -11,7 +11,7 @@ set -uo pipefail GREP=/usr/bin/grep # LRN-074: pin grep HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO="$(cd "$HERE/../.." && pwd)" -cd "$REPO" +cd "$REPO" || exit 1 pass=0; fail=0; skip=0 ok() { echo "GREEN ✓ $*"; pass=$((pass+1)); } diff --git a/lib/tests/url-guard.test.sh b/lib/tests/url-guard.test.sh index 679c832..3b4478e 100644 --- a/lib/tests/url-guard.test.sh +++ b/lib/tests/url-guard.test.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash # lib/tests/url-guard.test.sh +# shellcheck disable=SC2016 # single-quoted forms are the commands under test set -u G="$(cd "$(dirname "$0")/../.." && pwd)/lib/url-guard.sh" pass=0; fail=0