chore(template): clean-slate template snapshot from bb4a0c7
Curated, product-agnostic snapshot of the post-story-04 tree: demo content deleted, auth-only reference feature, web-next shell, all gates green. Product-specific docs, ADRs 027-029, PRDs/epics/archive, editor library traces, and product naming are curated out; generic template repairs (coverage provider devDeps, root test:coverage script, live lint fixes, root-only release-please) are kept. See TEMPLATE.md for provenance, curation list, and usage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016j8z4VHjedXDTjEDNg7qHK
This commit is contained in:
73
.claude/hooks/library-policy-nudge.test.sh
Executable file
73
.claude/hooks/library-policy-nudge.test.sh
Executable file
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env bash
|
||||
# Smoke tests for library-policy-nudge.sh
|
||||
# Usage: bash .claude/hooks/library-policy-nudge.test.sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/library-policy-nudge.sh"
|
||||
MARKER="/evaluate-library"
|
||||
PASS=0
|
||||
FAIL=0
|
||||
|
||||
assert_contains() {
|
||||
local name="$1"
|
||||
local input="$2"
|
||||
local output
|
||||
output=$(printf '%s' "$input" | bash "$SCRIPT" 2>/dev/null)
|
||||
if echo "$output" | grep -qF "$MARKER"; then
|
||||
echo " PASS: $name"
|
||||
PASS=$((PASS + 1))
|
||||
else
|
||||
echo " FAIL: $name"
|
||||
echo " Expected stdout to contain: $MARKER"
|
||||
echo " Got: ${output:-<empty>}"
|
||||
FAIL=$((FAIL + 1))
|
||||
fi
|
||||
}
|
||||
|
||||
assert_no_output() {
|
||||
local name="$1"
|
||||
local input="$2"
|
||||
local output
|
||||
output=$(printf '%s' "$input" | bash "$SCRIPT" 2>/dev/null)
|
||||
if ! echo "$output" | grep -qF "$MARKER"; then
|
||||
echo " PASS: $name"
|
||||
PASS=$((PASS + 1))
|
||||
else
|
||||
echo " FAIL: $name"
|
||||
echo " Expected no $MARKER in stdout, got: $output"
|
||||
FAIL=$((FAIL + 1))
|
||||
fi
|
||||
}
|
||||
|
||||
echo "library-policy-nudge.sh smoke tests"
|
||||
echo "------------------------------------"
|
||||
|
||||
# pnpm add <pkg> → reminder (runtime dep)
|
||||
assert_contains \
|
||||
"pnpm add foo triggers reminder" \
|
||||
'{"tool_input":{"command":"pnpm add foo"}}'
|
||||
|
||||
# pnpm add -D <pkg> → no reminder (dev dep)
|
||||
assert_no_output \
|
||||
"pnpm add -D foo produces no reminder" \
|
||||
'{"tool_input":{"command":"pnpm add -D foo"}}'
|
||||
|
||||
# pnpm add --save-dev <pkg> → no reminder (dev dep, long flag)
|
||||
assert_no_output \
|
||||
"pnpm add --save-dev foo produces no reminder" \
|
||||
'{"tool_input":{"command":"pnpm add --save-dev foo"}}'
|
||||
|
||||
# Edit on non-package.json → no reminder
|
||||
assert_no_output \
|
||||
"Edit on feature.manifest.ts produces no reminder" \
|
||||
'{"tool_input":{"file_path":"/workspace/packages/auth/src/feature.manifest.ts"}}'
|
||||
|
||||
# Edit on package.json → reminder
|
||||
assert_contains \
|
||||
"Edit on package.json triggers reminder" \
|
||||
'{"tool_input":{"file_path":"/workspace/packages/auth/package.json"}}'
|
||||
|
||||
echo ""
|
||||
echo "Results: $PASS passed, $FAIL failed"
|
||||
[[ $FAIL -eq 0 ]]
|
||||
Reference in New Issue
Block a user