Files
claude/lib/tests/design-toolchain-reminder.test.sh
T
Bastien ChanotandClaude Opus 4.8 3d0ee262c1 fix(hooks): tighten design-toolchain trigger + add fire-log counter
The 07-02 tightening left bare tokens common in non-UI talk (design, component, theme, transition, frontend, palette) -> ~6 false-fires/session during the ECC config audit. Dropped them; dashboard now word-boundary matched (kills the ecc_dashboard.py filename match, keeps 'admin dashboard'); kept animation; added 'front-end design' bigram. Each fire now logs time+token+excerpt to a light file so 're-firing?' is measured, not argued. Regression test 18/18, shellcheck clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XpphkdTosUzokBDNG7PToS
2026-07-03 15:52:37 +02:00

40 lines
2.0 KiB
Bash

#!/usr/bin/env bash
# lib/tests/design-toolchain-reminder.test.sh
set -u
H="$(cd "$(dirname "$0")/../.." && pwd)/hooks/design-toolchain-reminder.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; }
# fire() -> "fire" if the hook emits the reminder, else "quiet".
fire() { if printf '{"prompt":"%s"}' "$1" | bash "$H" | grep -q "design-toolchain"; then
echo fire; else echo quiet; fi; }
# --- Dropped/neutralized tokens must be QUIET (non-UI senses) ---
check D1-design "$(fire 'a design decision for the API')" quiet
check D2-component "$(fire 'this system component')" quiet
check D3-composant "$(fire 'le composant backend')" quiet
check D4-theme "$(fire 'the theme of the audit')" quiet
check D5-transition "$(fire 'state transition to develop')" quiet
check D6-frontend "$(fire 'frontend architecture')" quiet
check D7-palette "$(fire 'a palette of options')" quiet
check D8-dash-file "$(fire 'ecc_dashboard.py')" quiet
# --- Real UI signals must still FIRE ---
check F1-button "$(fire 'add a button')" fire
check F2-navbar "$(fire 'the navbar layout')" fire
check F3-landing "$(fire 'build a landing page')" fire
check F4-glass "$(fire 'a glassmorphism card')" fire
check F5-redesign "$(fire 'redesign the app')" fire
check F6-frontdesign "$(fire 'frontend design work')" fire
check F7-admin-dash "$(fire 'admin dashboard screen')" fire
check F8-animation "$(fire 'add an animation')" fire
check F9-designsys "$(fire 'our design system')" fire
# --- Fire is logged (time + token + excerpt) ---
tmp="$(mktemp -d)"
printf '{"prompt":"a glassmorphism card"}' | HOME="$tmp" bash "$H" >/dev/null 2>&1
check L1-logged "$(grep -c 'glassmorph' "$tmp/.claude/logs/design-toolchain-fires.log" 2>/dev/null)" 1
rm -rf "$tmp"
printf 'PASS=%s FAIL=%s\n' "$pass" "$fail"; [ "$fail" -eq 0 ]