2026-02-01 19:15:51 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
# Verify QA passes before stopping during /core:qa mode
|
|
|
|
|
#
|
|
|
|
|
# Stop hook that runs QA checks and blocks if any failures exist.
|
|
|
|
|
# Ensures Claude fixes all issues before completing the task.
|
|
|
|
|
|
|
|
|
|
read -r input
|
|
|
|
|
STOP_ACTIVE=$(echo "$input" | jq -r '.stop_hook_active // false')
|
|
|
|
|
|
|
|
|
|
# Prevent infinite loop
|
|
|
|
|
if [ "$STOP_ACTIVE" = "true" ]; then
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
2026-02-02 07:17:36 +00:00
|
|
|
# Source module context to get CLAUDE_MODULE_TYPE
|
|
|
|
|
CONTEXT_FILE=".claude-plugin/.tmp/module_context.sh"
|
|
|
|
|
if [ -f "$CONTEXT_FILE" ]; then
|
|
|
|
|
source "$CONTEXT_FILE"
|
2026-02-01 19:15:51 +00:00
|
|
|
fi
|
|
|
|
|
|
2026-02-02 07:17:36 +00:00
|
|
|
# Run QA based on module type
|
|
|
|
|
case "$CLAUDE_MODULE_TYPE" in
|
|
|
|
|
"go")
|
|
|
|
|
RESULT=$(core go qa 2>&1) || true
|
|
|
|
|
;;
|
|
|
|
|
"php")
|
|
|
|
|
RESULT=$(core php qa 2>&1) || true
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
# Not a Go or PHP project, allow stop
|
|
|
|
|
exit 0
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
2026-02-01 19:15:51 +00:00
|
|
|
# Check if QA passed
|
|
|
|
|
if echo "$RESULT" | grep -qE "FAIL|ERROR|✗|panic:|undefined:"; then
|
|
|
|
|
# Extract top issues for context
|
|
|
|
|
ISSUES=$(echo "$RESULT" | grep -E "^(FAIL|ERROR|✗|undefined:|panic:)|^[a-zA-Z0-9_/.-]+\.(go|php):[0-9]+:" | head -5)
|
|
|
|
|
|
|
|
|
|
# Escape for JSON
|
|
|
|
|
ISSUES_ESCAPED=$(echo "$ISSUES" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')
|
|
|
|
|
|
|
|
|
|
cat << EOF
|
|
|
|
|
{
|
|
|
|
|
"decision": "block",
|
|
|
|
|
"reason": "QA still has issues:\n\n$ISSUES_ESCAPED\n\nPlease fix these before stopping."
|
|
|
|
|
}
|
|
|
|
|
EOF
|
|
|
|
|
else
|
|
|
|
|
# QA passed, allow stop
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|