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>
23 lines
925 B
Bash
Executable file
23 lines
925 B
Bash
Executable file
#!/bin/bash
|
|
# Check for a drop in test coverage.
|
|
# Policy: EXPOSE warning when coverage drops, HIDE when stable/improved
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "$SCRIPT_DIR/output-policy.sh"
|
|
|
|
# Source the main coverage script to use its functions
|
|
source claude/code/commands/coverage.sh 2>/dev/null || true
|
|
|
|
read -r input
|
|
|
|
# Get current and previous coverage (with fallbacks)
|
|
CURRENT_COVERAGE=$(get_current_coverage 2>/dev/null || echo "0")
|
|
PREVIOUS_COVERAGE=$(get_previous_coverage 2>/dev/null || echo "0")
|
|
|
|
# Compare coverage
|
|
if awk -v current="$CURRENT_COVERAGE" -v previous="$PREVIOUS_COVERAGE" 'BEGIN {exit !(current < previous)}'; then
|
|
DROP=$(awk -v c="$CURRENT_COVERAGE" -v p="$PREVIOUS_COVERAGE" 'BEGIN {printf "%.1f", p - c}')
|
|
expose_warning "Test coverage dropped by ${DROP}%" "Previous: ${PREVIOUS_COVERAGE}% → Current: ${CURRENT_COVERAGE}%"
|
|
else
|
|
pass_through "$input"
|
|
fi
|