From 5d072991120e2371ae343b272dc31a089b97d90a Mon Sep 17 00:00:00 2001 From: versnic <37933264+versnic@users.noreply.github.com> Date: Sun, 8 Nov 2026 21:39:12 +0100 Subject: [PATCH] ci: require an ai disclosure on every pull request and issue --- .github/ISSUE_TEMPLATE/bug.yml | 15 ++++++ .github/ISSUE_TEMPLATE/feature.yml | 15 ++++++ .github/ISSUE_TEMPLATE/question.yml | 15 ++++++ .github/PULL_REQUEST_TEMPLATE.md | 9 ++++ .github/workflows/ai-disclosure.yml | 77 +++++++++++++++++++++++++++++ CONTRIBUTING.md | 12 ++++- 6 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ai-disclosure.yml diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index 55e1442..a11af2c 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -45,3 +45,18 @@ body: attributes: label: Package manager of the affected project placeholder: npm 11, pnpm 10, Yarn 1, Yarn 4, Bun + - type: dropdown + id: ai-use + attributes: + label: AI use + description: Required, for everyone. Say whether AI tools helped write this issue. + options: + - No AI tool was used + - AI tools were used + validations: + required: true + - type: textarea + id: ai-tools + attributes: + label: AI tools used + description: If AI tools were used, name each one and what it did, for example "ChatGPT summarised the error log". diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml index b633fab..c340fec 100644 --- a/.github/ISSUE_TEMPLATE/feature.yml +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -27,3 +27,18 @@ body: - 'Hardening and release candidate' - 'After 1.0.0' - 'Not on the roadmap yet' + - type: dropdown + id: ai-use + attributes: + label: AI use + description: Required, for everyone. Say whether AI tools helped write this issue. + options: + - No AI tool was used + - AI tools were used + validations: + required: true + - type: textarea + id: ai-tools + attributes: + label: AI tools used + description: If AI tools were used, name each one and what it did, for example "ChatGPT summarised the error log". diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml index 05c7720..e2e0009 100644 --- a/.github/ISSUE_TEMPLATE/question.yml +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -15,3 +15,18 @@ body: label: Dev Workspace CLI version description: The output of `dws --version`. placeholder: 0.6.0 + - type: dropdown + id: ai-use + attributes: + label: AI use + description: Required, for everyone. Say whether AI tools helped write this issue. + options: + - No AI tool was used + - AI tools were used + validations: + required: true + - type: textarea + id: ai-tools + attributes: + label: AI tools used + description: If AI tools were used, name each one and what it did, for example "ChatGPT summarised the error log". diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 5465959..e494a69 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,6 +2,15 @@ +## AI use + + + +- [ ] No AI tool was used +- [ ] AI tools were used, as described here: + + + ## Checklist - [ ] The title follows Conventional Commits (`feat:`, `fix:`, `docs:`, …) and is lowercase diff --git a/.github/workflows/ai-disclosure.yml b/.github/workflows/ai-disclosure.yml new file mode 100644 index 0000000..8bdec69 --- /dev/null +++ b/.github/workflows/ai-disclosure.yml @@ -0,0 +1,77 @@ +name: AI disclosure + +# Every pull request says whether AI tools were used, the maintainer's +# included. The "AI use" section of the pull request template has two boxes: +# "No AI tool was used", or "AI tools were used" with each tool and what it +# did written under it. This check fails until exactly one box is ticked, and +# the main ruleset requires it. Editing the description runs it again. +# +# It reads the description from the event, through an environment variable, +# and needs no token and no checkout. Dependabot pull requests are exempt. +on: + pull_request: + types: [opened, edited, reopened, synchronize] + +permissions: {} + +# Only the latest description matters. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + check: + name: AI disclosure + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - name: Check the AI use section + env: + BODY: ${{ github.event.pull_request.body }} + AUTHOR: ${{ github.event.pull_request.user.login }} + run: | + if [ "$AUTHOR" = 'dependabot[bot]' ]; then + echo 'Dependabot pull request: no disclosure needed.' + exit 0 + fi + + node - <<'JS' + const body = (process.env.BODY ?? '').replace(//g, '') + const fail = (message) => { + console.log(`::error::${message}`) + process.exit(1) + } + + const section = body.match(/^##[ \t]+AI use[ \t]*$([\s\S]*?)(?=^##[ \t]|(?![\s\S]))/im) + if (!section) { + fail('The description has no "## AI use" section. Copy it from the pull request template and tick one box.') + } + + const box = /^[ \t]*[-*][ \t]+\[([ xX])\][ \t]+(.*)$/ + const lines = section[1].split(/\r?\n/) + const ticked = lines.map((line) => line.match(box)).filter((m) => m && m[1] !== ' ') + const none = ticked.some((m) => /^no ai tool/i.test(m[2])) + const used = ticked.some((m) => /^ai tools were used/i.test(m[2])) + + if (none === used) { + fail('In the "AI use" section, tick exactly one box: "No AI tool was used" or "AI tools were used".') + } + + if (used) { + // The description can follow the box on its line, or the lines under it. + const details = lines + .map((line) => { + const m = line.match(box) + return m ? (/^ai tools were used/i.test(m[2]) ? m[2].replace(/^[^:]*:?/, '') : '') : line + }) + .join(' ') + .replace(/\s+/g, ' ') + .trim() + if (details.length < 20) { + fail('"AI tools were used" is ticked: under it, name each tool and what it did.') + } + } + + console.log(none ? 'Disclosed: no AI tool was used.' : 'Disclosed: AI tools were used, and how.') + JS diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f5f5f1d..1badcc1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -86,7 +86,7 @@ Every change is made on a short-lived branch and reaches `main` through a pull r 1. Create a branch named after the change: `feat/project-search`, `fix/ctrl-c`, `docs/readme`, … 2. Commit and push as often as needed. Nothing is released from a branch. -3. Open a pull request. CI runs the test matrix (Windows, macOS and Linux with Node.js 22, 24 and 26), and a check verifies that the title follows [Conventional Commits](https://www.conventionalcommits.org/). Pull requests that change `.github/` are also audited by [zizmor](https://docs.zizmor.sh/). A final **CI passed** job succeeds only when every test and coverage job has passed. It and the title check are the checks that must pass before a pull request can be merged, so changing the test matrix never requires changing the repository rules. +3. Open a pull request. CI runs the test matrix (Windows, macOS and Linux with Node.js 22, 24 and 26), and a check verifies that the title follows [Conventional Commits](https://www.conventionalcommits.org/). Pull requests that change `.github/` are also audited by [zizmor](https://docs.zizmor.sh/). A final **CI passed** job succeeds only when every test and coverage job has passed. It, the title check and the **AI disclosure** check (see [AI use](#ai-use)) are the checks that must pass before a pull request can be merged, so changing the test matrix never requires changing the repository rules. 4. The maintainer reviews it. A pull request needs the maintainer's approval, given after its last push, and every review conversation resolved. A new push dismisses an earlier approval. The first workflow run of a first-time contributor also waits for the maintainer's approval. 5. The maintainer squash-merges it. The pull request title becomes the only commit on `main`. @@ -102,6 +102,16 @@ Keep the summary lowercase and in the imperative: `feat: add project search`, no **Do not mark changes as breaking before 1.0.0.** A `!` after the type (`feat!:`) or a `BREAKING CHANGE:` footer makes a major release, which would publish 1.0.0 early. Until then, describe incompatible changes in the pull request and release them as `feat:`. +### AI use + +AI tools are allowed, but their use is never hidden. The rule is the same for the maintainer and for contributors. + +- **Pull requests:** fill in the **AI use** section of the [pull request template](.github/PULL_REQUEST_TEMPLATE.md). Tick **No AI tool was used**, or tick **AI tools were used** and name each tool and what it did under it, for example "Claude Code wrote the first draft of the tests; I reviewed and changed them". The **AI disclosure** check fails until exactly one box is ticked, and a pull request cannot be merged without it. Editing the description runs the check again. Dependabot pull requests are exempt. +- **Issues:** every issue form asks the same question. +- **Comments and reviews:** say so when an AI tool wrote or drafted what you post. No check can verify this, so it relies on you. + +You are responsible for everything you submit, whoever or whatever wrote it: read it, test it, and be ready to explain it. + ### Labels and reviews Issues are opened from a form (bug, feature or question), which adds its kind label and `needs-triage`. The maintainer removes `needs-triage` once the issue is reviewed, and adds `good first issue` or `help wanted` when it is ready to pick up. Pull requests start from the [pull request template](.github/PULL_REQUEST_TEMPLATE.md), whose checklist lists what to check before asking for review.