plugins/scripts/qa-filter.sh
Snider ecefb8a952 refactor: restructure as Claude Code marketplace plugin
- Add .claude-plugin/plugin.json manifest for auto-updates
- Move claude/ contents to root level (commands/, hooks/, scripts/, skills/)
- Update hooks.json to use ${CLAUDE_PLUGIN_ROOT} for portability
- Add .gitignore for IDE files
- Update CLAUDE.md with new structure and installation instructions

Plugin can now be installed via:
  claude plugin add host-uk/core-agent

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 19:35:06 +00:00

62 lines
1.9 KiB
Bash
Executable file

#!/bin/bash
# Filter QA output to show only actionable issues during /core:qa mode
#
# PostToolUse hook that processes QA command output and extracts
# only the failures, hiding verbose success output.
read -r input
COMMAND=$(echo "$input" | jq -r '.tool_input.command // empty')
OUTPUT=$(echo "$input" | jq -r '.tool_response.stdout // .tool_response.output // empty')
EXIT_CODE=$(echo "$input" | jq -r '.tool_response.exit_code // 0')
# Only process QA-related commands
case "$COMMAND" in
"core go qa"*|"core php qa"*|"core go test"*|"core php test"*|"core go lint"*|"core php stan"*)
;;
*)
# Not a QA command, pass through unchanged
echo "$input"
exit 0
;;
esac
# Extract failures from output
FAILURES=$(echo "$OUTPUT" | grep -E "^(FAIL|---\s*FAIL|✗|ERROR|undefined:|error:|panic:)" | head -20)
SUMMARY=$(echo "$OUTPUT" | grep -E "^(fmt:|lint:|test:|pint:|stan:|=== RESULT ===)" | tail -5)
# Also grab specific error lines with file:line references
FILE_ERRORS=$(echo "$OUTPUT" | grep -E "^[a-zA-Z0-9_/.-]+\.(go|php):[0-9]+:" | head -10)
if [ -z "$FAILURES" ] && [ "$EXIT_CODE" = "0" ]; then
# All passed - show brief confirmation
cat << 'EOF'
{
"suppressOutput": true,
"hookSpecificOutput": {
"hookEventName": "PostToolUse",
"additionalContext": "✓ QA passed"
}
}
EOF
else
# Combine failures and file errors
ISSUES="$FAILURES"
if [ -n "$FILE_ERRORS" ]; then
ISSUES="$ISSUES
$FILE_ERRORS"
fi
# Escape for JSON
ISSUES_ESCAPED=$(echo "$ISSUES" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')
SUMMARY_ESCAPED=$(echo "$SUMMARY" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/ | /g')
cat << EOF
{
"suppressOutput": true,
"hookSpecificOutput": {
"hookEventName": "PostToolUse",
"additionalContext": "## QA Issues\n\n\`\`\`\n$ISSUES_ESCAPED\n\`\`\`\n\n**Summary:** $SUMMARY_ESCAPED"
}
}
EOF
fi