Add consistent policy for what hook output to show vs suppress: - EXPOSE: errors, warnings, debug statements, uncommitted work - HIDE: format success, coverage stable, pass confirmations New files: - output-policy.sh: helper functions (expose_error, expose_warning, hide_success) - hook-output-policy.md: documentation Updated hooks to use proper Claude Code JSON output format: - check-debug.sh: expose warnings via additionalContext - post-commit-check.sh: expose uncommitted work warnings - check-coverage.sh: expose coverage drops - go-format.sh: suppress output on success - php-format.sh: suppress output on success Closes #17 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
21 lines
667 B
Bash
Executable file
21 lines
667 B
Bash
Executable file
#!/bin/bash
|
|
# Auto-format PHP files after edits using core php fmt
|
|
# Policy: HIDE success (formatting is silent background operation)
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "$SCRIPT_DIR/output-policy.sh"
|
|
|
|
read -r input
|
|
FILE_PATH=$(echo "$input" | jq -r '.tool_input.file_path // empty')
|
|
|
|
if [[ -n "$FILE_PATH" && -f "$FILE_PATH" ]]; then
|
|
# Run Pint on the file silently
|
|
if command -v core &> /dev/null; then
|
|
core php fmt --fix "$FILE_PATH" 2>/dev/null || true
|
|
elif [[ -f "./vendor/bin/pint" ]]; then
|
|
./vendor/bin/pint "$FILE_PATH" 2>/dev/null || true
|
|
fi
|
|
fi
|
|
|
|
# Silent success - no output needed
|
|
hide_success
|