diff --git a/.githooks/commit-msg b/.githooks/commit-msg index 8c30b65..1140cd4 100755 --- a/.githooks/commit-msg +++ b/.githooks/commit-msg @@ -112,6 +112,18 @@ if printf '%s' "$CONTENT" | grep -qiE -- '@cursor\.com'; then FAIL=1 fi +# Rule 5.1 is vendor-neutral: reject attribution for every AI assistant, not just +# Claude/Cursor. Vendor names live in a list so the hook stays tool-agnostic. +AI_VENDORS="Codex Copilot Gemini ChatGPT OpenAI Anthropic" +AI_PREFIXES='Co-Authored-By:|Co-authored-by:|Generated with|Generated by|with help from|Powered by' +for vendor in $AI_VENDORS; do + if printf '%s' "$CONTENT" | grep -qiE -- "(${AI_PREFIXES}) ${vendor}"; then + printf 'commit-msg: forbidden AI attribution for %s.\n' "$vendor" >&2 + printf ' Rule: github-discipline.md Rule 5.1 (tool-agnostic)\n' >&2 + FAIL=1 + fi +done + # Author / committer identity must not be Cursor. git var resolves the exact # identity (including --author / GIT_*_IDENT overrides) this commit will record. for ident in "$(git var GIT_AUTHOR_IDENT 2>/dev/null)" "$(git var GIT_COMMITTER_IDENT 2>/dev/null)"; do diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 603a28c..b4e9b63 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -209,6 +209,17 @@ while IFS= read -r file; do FAIL=1 fi + # Vendor-neutral AI attribution (Rule 5.1 covers every assistant). + AI_VENDORS="Codex Copilot Gemini ChatGPT OpenAI Anthropic" + AI_PREFIXES='Co-Authored-By:|Co-authored-by:|Generated with|Generated by|with help from|Powered by' + for vendor in $AI_VENDORS; do + if printf '%s' "$ADDED" | grep -qiE -- "(${AI_PREFIXES}) ${vendor}"; then + printf 'pre-commit: forbidden AI attribution for %s in staged %s.\n' "$vendor" "$file" >&2 + printf ' Rule: github-discipline.md Rule 5.1 (tool-agnostic)\n' >&2 + FAIL=1 + fi + done + # AI-signature emoji check. while IFS= read -r emoji; do [ -z "$emoji" ] && continue diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b929c3..ef36ff9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,7 @@ on: permissions: contents: read + issues: read jobs: macos: @@ -22,6 +23,8 @@ jobs: - name: Install format and lint tools run: brew install swiftformat swiftlint - name: Repository gates + env: + GH_TOKEN: ${{ github.token }} run: | bash scripts/check-style.sh bash scripts/check-namespacing.sh diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 741a8a3..4fb4fdd 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -18,7 +18,6 @@ run_gate() { run_gate "style" bash scripts/check-style.sh run_gate "namespacing" bash scripts/check-namespacing.sh run_gate "forbidden patterns" bash scripts/check-forbidden-patterns.sh -run_gate "roadmap" bash scripts/check-roadmap.sh run_gate "swiftformat" swiftformat . --config .swiftformat --lint run_gate "swiftlint" swiftlint --config .swiftlint.yml --strict run_gate "swift build" swift build diff --git a/scripts/check-style.sh b/scripts/check-style.sh index 4c245f5..2553486 100755 --- a/scripts/check-style.sh +++ b/scripts/check-style.sh @@ -17,6 +17,7 @@ EMDASH=$(printf '\xe2\x80\x94') is_enforcement_file() { case "$1" in .githooks/*|scripts/check-style.sh) return 0 ;; + .github/workflows/no-cursor-attribution.yml) return 0 ;; *) return 1 ;; esac } @@ -33,6 +34,11 @@ PHRASES=( "as an AI" ) +# Vendor-neutral attribution: Rule 5.1 covers every AI assistant. Vendor names in +# a list, matched against attribution prefixes, so the gate is tool-agnostic. +AI_VENDORS="Codex Copilot Gemini ChatGPT OpenAI Anthropic Cursor" +AI_PREFIXES='Co-Authored-By:|Co-authored-by:|Generated with|Generated by|with help from|Powered by' + while IFS= read -r f; do [ -f "$f" ] || continue if LC_ALL=C grep -qF -- "$EMDASH" "$f" 2>/dev/null; then @@ -46,6 +52,13 @@ while IFS= read -r f; do FAIL=1 fi done + # Vendor-neutral attribution (Rule 5.1 covers every assistant, not just Claude). + for vendor in $AI_VENDORS; do + if LC_ALL=C grep -qiE -- "($AI_PREFIXES) $vendor" "$f" 2>/dev/null; then + echo "style: forbidden attribution phrase ($vendor) in $f" >&2 + FAIL=1 + fi + done fi done < <(git ls-files) @@ -53,4 +66,9 @@ if [ "$FAIL" -ne 0 ]; then echo "style: gate failed. Rules: docs/rules/git-discipline.md" >&2 fi +# Roadmap gate (github-discipline: the roadmap check is wired into check-style). +if ! bash scripts/check-roadmap.sh; then + FAIL=1 +fi + exit "$FAIL"