mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 16:43:05 +02:00
Move every multi-line python heredoc/`-c` block into a dedicated .py file so ruff, mypy, pylint, bandit, and pytest can apply to it: - linux_configuration/zsh/calc-live.zsh → python_pkg/live_calc/calc_eval.py (100% branch cov, 46 tests) - meta/scripts/check_ai_evidence.sh → meta/scripts/validate_evidence.py - meta/scripts/check_agent_contract.sh → meta/scripts/validate_contract.py - phone_focus_mode/lib/monitor.sh → phone_focus_mode/lib/monitor_report.py - phone_focus_mode/deploy.sh → phone_focus_mode/strip_workout_hosts.py - linux_configuration/.../analyze_repo.sh → fast_count.py Also: add zsh-syntax pre-commit hook (zsh -n); exclude zsh from shellcheck; add tests for all 4 non-python_pkg helpers; update CLAUDE.md Shell Style with the no-inline-Python rule. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
56 lines
1.4 KiB
Bash
Executable File
56 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Enforce evidence artifacts for commits that touch source code.
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
readonly SCRIPT_DIR
|
|
readonly EVIDENCE_GLOB='docs/superpowers/evidence/*.json'
|
|
|
|
has_code_changes() {
|
|
git diff --cached --name-only --diff-filter=ACMR | grep -Eq '\.(py|sh|c|h|cpp|hpp|cc|go|rs|ts|tsx|js|jsx|dart)$'
|
|
}
|
|
|
|
find_staged_evidence_files() {
|
|
git diff --cached --name-only --diff-filter=ACMR | grep -E '^docs/superpowers/evidence/.*\.json$' || true
|
|
}
|
|
|
|
validate_json_schema() {
|
|
local file_path="$1"
|
|
python "${SCRIPT_DIR}/validate_evidence.py" "$file_path"
|
|
}
|
|
|
|
main() {
|
|
if ! has_code_changes; then
|
|
echo "✓ No code changes detected; evidence artifact not required"
|
|
exit 0
|
|
fi
|
|
|
|
local evidence_files
|
|
evidence_files="$(find_staged_evidence_files)"
|
|
|
|
if [[ -z "$evidence_files" ]]; then
|
|
echo "❌ Code changes detected, but no staged evidence artifact found."
|
|
echo " Required: ${EVIDENCE_GLOB}"
|
|
echo " Tip: copy docs/superpowers/evidence/template.json and fill it in."
|
|
exit 1
|
|
fi
|
|
|
|
local failed=0
|
|
while IFS= read -r file_path; do
|
|
[[ -z "$file_path" ]] && continue
|
|
if ! validate_json_schema "$file_path"; then
|
|
failed=1
|
|
fi
|
|
done <<< "$evidence_files"
|
|
|
|
if [[ $failed -eq 1 ]]; then
|
|
echo "❌ Evidence artifact validation failed"
|
|
exit 1
|
|
fi
|
|
|
|
echo "✓ Evidence artifact checks passed"
|
|
}
|
|
|
|
main "$@"
|