Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

### AI use

<!-- Using AI is welcome. Required: tick one, naming the tool and model if you used AI; a check fails without it. See CONTRIBUTING.md. -->
<!-- Using AI is welcome. Please tick one, naming the tool and model if you used AI; a reminder appears if it is missing. See CONTRIBUTING.md. -->

- [ ] None
- [ ] Some (tool or agent, and model: ...)
- [ ] Most (tool or agent, and model: ...)
- [ ] I wrote this description myself and I have read and tested every line.
- [ ] I have read and tested every line.
25 changes: 14 additions & 11 deletions .github/workflows/ai-disclosure.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: AI disclosure

# PRs say in the description whether AI tools were used; using them is welcome.
# See "AI-assisted contributions" in CONTRIBUTING.md. This job reads only the
# event payload: no checkout, no token permissions.
# See "AI-assisted contributions" in CONTRIBUTING.md. This check is a reminder:
# it only adds a warning and never fails the PR; maintainers ask before merging.
# It reads only the event payload: no checkout, no token permissions.
on:
pull_request:
types: [opened, edited, reopened, synchronize, ready_for_review]
Expand All @@ -23,15 +24,16 @@ jobs:
run: |
set -euo pipefail
body="${PR_BODY//$'\r'/}"
fail() {
echo "::error title=AI use disclosure::$1"
remind() {
echo "::warning title=AI use disclosure::$1"
echo "Please fill in the \"### AI use\" section of the pull request template: tick exactly one"
echo "of None, Some or Most (naming the tool and model for Some or Most), and tick \"I wrote this description myself\"."
echo "of None, Some or Most (naming the tool and model for Some or Most), and tick \"I have read and tested every line\"."
echo "This is a reminder and does not fail the PR; a maintainer will ask about it before merging."
echo "See \"AI-assisted contributions\" in CONTRIBUTING.md. Editing the description re-runs this check."
exit 1
exit 0
}
if ! grep -Eiq '^###[[:space:]]+AI use[[:space:]]*$' <<<"$body"; then
fail 'The PR description has no "### AI use" section.'
remind 'The PR description has no "### AI use" section.'
fi
section="$(awk '
tolower($0) ~ /^###[[:space:]]+ai use[[:space:]]*$/ { in_s = 1; next }
Expand All @@ -40,7 +42,7 @@ jobs:
' <<<"$body")"
ticked="$(grep -Eic '^[[:space:]]*[-*][[:space:]]+\[x\][[:space:]]+(none|some|most)([^[:alnum:]]|$)' <<<"$section" || true)"
if [ "$ticked" -ne 1 ]; then
fail "Tick exactly one of None, Some or Most under \"### AI use\" (found $ticked ticked)."
remind "Tick exactly one of None, Some or Most under \"### AI use\" (found $ticked ticked)."
fi
choice="$(grep -Ei '^[[:space:]]*[-*][[:space:]]+\[x\][[:space:]]+(none|some|most)([^[:alnum:]]|$)' <<<"$section")"
if grep -Eiq '\[x\][[:space:]]+(some|most)' <<<"$choice"; then
Expand All @@ -53,10 +55,11 @@ jobs:
}' <<<"$choice")"
named="$(tr -d '[:space:]()' <<<"$named")"
if [[ "$choice" == *"..."* || "$choice" == *"…"* || ${#named} -lt 2 ]]; then
fail 'Name the AI tool and model you used, e.g. "Claude Code, Opus 5.5".'
remind 'Name the AI tool and model you used, e.g. "Claude Code, Opus 5.5".'
fi
fi
if ! grep -Eiq '^[[:space:]]*[-*][[:space:]]+\[x\][[:space:]]+I wrote this description myself' <<<"$section"; then
fail 'Tick "I wrote this description myself and I have read and tested every line."'
# The old template's "I wrote this description myself and ..." still counts.
if ! grep -Eiq '^[[:space:]]*[-*][[:space:]]+\[x\][[:space:]]+(I have read and tested every line|I wrote this description myself)' <<<"$section"; then
remind 'Tick "I have read and tested every line."'
fi
echo "AI use disclosure present."
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ Using AI tools is fine; please just be open about it.
plain descriptions are welcome; please don't paste generated text.
- Read, run and test every line you submit, and be ready to explain it in
review.
- PRs without the disclosure may be closed.
- If the disclosure is missing, a check adds a reminder to the PR. It does
not fail the PR, but a maintainer will ask about it before merging.

## Commits

Expand Down
Loading