chore(code-clean): lint directives, guarded cd, hook regex split, helper extractions
A1 drop unused `import gzip`; B1/B2 file-level shellcheck directives placed before `set -u`; B3 `cd "$REPO" || exit 1`; B4 hook regex split into `pattern+=` lines (sha256 of $pattern unchanged); B11 `_build_parser`/`_dispatch` pulled out of google_seo `_cli`; B20 detect-plugins header names update-all.sh; C2 prune-memory deterministic suite wired into SUITES (literal path); C3 `_refuse_outside_allowlist` moved up in deploy-commit. No behavior change except B3 (a failed cd now exits 1) and C2 (one more suite). B5/B7/B9/B18/B19 land in the refactor commit.
This commit is contained in:
1 parent
d08929d0e8
commit
381ed9fa5d
10 files changed
+46
-22
No files matched your search
@@ -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 -c 'read -r -p "Label for this account (e.g. client-a): " label; \
|
||||||
bash lib/seo-data/connect.sh --label "$$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)
|
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
|
@# Hermetic git: the machine's global core.hooksPath (BDR-095) must not
|
||||||
@# fire inside the throwaway repos the suites build. The export lives
|
@# fire inside the throwaway repos the suites build. The export lives
|
||||||
|
|||||||
@@ -48,7 +48,21 @@ lc="$(printf '%s' "$prompt" | tr '[:upper:]' '[:lower:]')"
|
|||||||
# French prose ("changement ux vu…"; 2 logged FPs, both FR). \bui\b KEPT
|
# 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
|
# (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.
|
# 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
|
if printf '%s' "$lc" | grep -Eq "$pattern"; then
|
||||||
# Counter: log the fire (time, matched token, excerpt) — best-effort, never blocks.
|
# Counter: log the fire (time, matched token, excerpt) — best-effort, never blocks.
|
||||||
|
|||||||
+15
-14
@@ -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; }
|
_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
|
_ignored() { git check-ignore -q "$1"; } # rc 0 = ignored
|
||||||
|
|
||||||
_changed_only() { # echo passed files that actually have changes
|
_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
|
case "$cmd" in
|
||||||
pending)
|
pending)
|
||||||
[ "$#" -gt 0 ] || { echo "deploy-commit: pending needs file args" >&2; exit 2; }
|
[ "$#" -gt 0 ] || { echo "deploy-commit: pending needs file args" >&2; exit 2; }
|
||||||
mapfile -t violations < <(_scope_violations "$@")
|
_refuse_outside_allowlist "$@"
|
||||||
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
|
|
||||||
[ -n "$(_changed_only "$@")" ] && exit 0 || exit 1 ;;
|
[ -n "$(_changed_only "$@")" ] && exit 0 || exit 1 ;;
|
||||||
commit)
|
commit)
|
||||||
msg="${1:-}"; shift || true
|
msg="${1:-}"; shift || true
|
||||||
[ -n "$msg" ] && [ "$#" -gt 0 ] || { echo "deploy-commit: commit needs <msg> <file>..." >&2; exit 2; }
|
[ -n "$msg" ] && [ "$#" -gt 0 ] || { echo "deploy-commit: commit needs <msg> <file>..." >&2; exit 2; }
|
||||||
mapfile -t violations < <(_scope_violations "$@")
|
_refuse_outside_allowlist "$@"
|
||||||
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
|
|
||||||
mapfile -t ignored_paths < <(for p in "$@"; do _ignored "$p" && printf '%s\n' "$p"; done)
|
mapfile -t ignored_paths < <(for p in "$@"; do _ignored "$p" && printf '%s\n' "$p"; done)
|
||||||
if [ "${#ignored_paths[@]}" -gt 0 ]; then
|
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:";
|
{ echo "deploy-commit: REFUSED — path(s) are git-ignored and will NOT persist; \`.claude/deploy/\` must be committable in this project:";
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# lib/detect-plugins.sh — Single source of truth for plugin detection
|
# 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).
|
# Each function returns 0 (detected) or 1 (not detected).
|
||||||
# No output — callers handle messaging.
|
# No output — callers handle messaging.
|
||||||
|
|||||||
@@ -214,8 +214,7 @@ def inspect(store_path, account, property, url):
|
|||||||
"last_crawl": isr.get("lastCrawlTime"),
|
"last_crawl": isr.get("lastCrawlTime"),
|
||||||
"rich_results": _norm_rich(ir)}
|
"rich_results": _norm_rich(ir)}
|
||||||
|
|
||||||
def _cli():
|
def _build_parser():
|
||||||
try:
|
|
||||||
p = argparse.ArgumentParser()
|
p = argparse.ArgumentParser()
|
||||||
sub = p.add_subparsers(dest="cmd", required=True)
|
sub = p.add_subparsers(dest="cmd", required=True)
|
||||||
pc = sub.add_parser("crux")
|
pc = sub.add_parser("crux")
|
||||||
@@ -241,7 +240,10 @@ def _cli():
|
|||||||
pi.add_argument("--account", required=True)
|
pi.add_argument("--account", required=True)
|
||||||
pi.add_argument("--property", required=True)
|
pi.add_argument("--property", required=True)
|
||||||
pi.add_argument("--url", required=True)
|
pi.add_argument("--url", required=True)
|
||||||
args = p.parse_args()
|
return p
|
||||||
|
|
||||||
|
|
||||||
|
def _dispatch(args):
|
||||||
if args.cmd == "crux":
|
if args.cmd == "crux":
|
||||||
print(json.dumps(crux(args.url, args.strategy), indent=2))
|
print(json.dumps(crux(args.url, args.strategy), indent=2))
|
||||||
elif args.cmd == "queries":
|
elif args.cmd == "queries":
|
||||||
@@ -253,6 +255,11 @@ def _cli():
|
|||||||
elif args.cmd == "inspect":
|
elif args.cmd == "inspect":
|
||||||
print(json.dumps(inspect(args.store, args.account, args.property,
|
print(json.dumps(inspect(args.store, args.account, args.property,
|
||||||
args.url), indent=2))
|
args.url), indent=2))
|
||||||
|
|
||||||
|
|
||||||
|
def _cli():
|
||||||
|
try:
|
||||||
|
_dispatch(_build_parser().parse_args())
|
||||||
except SystemExit as e: # argparse usage error
|
except SystemExit as e: # argparse usage error
|
||||||
if e.code not in (0, None):
|
if e.code not in (0, None):
|
||||||
print(json.dumps({"status": "error", "reason": "bad_usage"}))
|
print(json.dumps({"status": "error", "reason": "bad_usage"}))
|
||||||
|
|||||||
@@ -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
|
(a fixed set against an operator-typed/confirmed $DOMAIN). Closing them needs
|
||||||
`curl --resolve` and is a separate change.
|
`curl --resolve` and is a separate change.
|
||||||
"""
|
"""
|
||||||
import gzip
|
|
||||||
import http.client
|
import http.client
|
||||||
import ipaddress
|
import ipaddress
|
||||||
import socket
|
import socket
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Deterministic tests for the seo-data engine (no network, no venv).
|
# 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
|
set -u
|
||||||
REPO="$(cd "$(dirname "$0")/../.." && pwd)"
|
REPO="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||||
SD="$REPO/lib/seo-data"
|
SD="$REPO/lib/seo-data"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
# lib/tests/push-guard.test.sh
|
# lib/tests/push-guard.test.sh
|
||||||
# hooks/push-guard.sh (BDR-111): denies `git push` in manual push mode,
|
# 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.
|
# 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
|
set -u
|
||||||
export GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null
|
export GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null
|
||||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ set -uo pipefail
|
|||||||
GREP=/usr/bin/grep # LRN-074: pin grep
|
GREP=/usr/bin/grep # LRN-074: pin grep
|
||||||
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
REPO="$(cd "$HERE/../.." && pwd)"
|
REPO="$(cd "$HERE/../.." && pwd)"
|
||||||
cd "$REPO"
|
cd "$REPO" || exit 1
|
||||||
|
|
||||||
pass=0; fail=0; skip=0
|
pass=0; fail=0; skip=0
|
||||||
ok() { echo "GREEN ✓ $*"; pass=$((pass+1)); }
|
ok() { echo "GREEN ✓ $*"; pass=$((pass+1)); }
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# lib/tests/url-guard.test.sh
|
# lib/tests/url-guard.test.sh
|
||||||
|
# shellcheck disable=SC2016 # single-quoted forms are the commands under test
|
||||||
set -u
|
set -u
|
||||||
G="$(cd "$(dirname "$0")/../.." && pwd)/lib/url-guard.sh"
|
G="$(cd "$(dirname "$0")/../.." && pwd)/lib/url-guard.sh"
|
||||||
pass=0; fail=0
|
pass=0; fail=0
|
||||||
|
|||||||
Reference in new issue
Block a user