#!/usr/bin/env bash # KHAELOR # File: scripts/check-headers.sh # Description: Enforce Absolute Rule #0 — every first-party source file must carry the author header. # # Author: Simon-Pierre Boucher # Contact: contact@spboucher.ai set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$ROOT" AUTHOR="Simon-Pierre Boucher" CONTACT="contact@spboucher.ai" fail=0 checked=0 # First-party source files: src/, scripts/, and deliverable docs (docs/**/*.md). # Exemptions: references/ (third-party), node_modules/, pure data files (.json, lockfiles). files=$(find src scripts docs -type f \ \( -name '*.ts' -o -name '*.tsx' -o -name '*.js' -o -name '*.mjs' -o -name '*.cjs' \ -o -name '*.sh' -o -name '*.rs' -o -name '*.md' -o -name '*.yaml' -o -name '*.yml' \ -o -name '*.toml' -o -name '*.jsonc' \) \ 2>/dev/null | grep -v -E '(^|/)(node_modules|references|dist|build)/' || true) for f in $files; do checked=$((checked + 1)) head_block=$(head -n 12 "$f") if ! grep -q "KHAELOR" <<<"$head_block"; then echo "MISSING HEADER (no KHAELOR marker): $f" fail=1 continue fi if ! grep -q "$AUTHOR" <<<"$head_block"; then echo "MISSING HEADER (no author line): $f" fail=1 continue fi if ! grep -q "$CONTACT" <<<"$head_block"; then echo "MISSING HEADER (no contact line): $f" fail=1 continue fi done if [ "$fail" -ne 0 ]; then echo "check-headers: FAILED" exit 1 fi echo "check-headers: OK ($checked files checked)"