-
Notifications
You must be signed in to change notification settings - Fork 544
chore(CI): Add agents.md and ai-policy.yml #18312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nickvergessen
wants to merge
7
commits into
main
Choose a base branch
from
chore/noid/start-agents-md
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+298
−0
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
89ae7a4
chore(AI): Add agents.md based on latest fable5 analysis
nickvergessen 2bf863f
chore(AI): Add general Nextcloud Contribution Policy
nickvergessen 2dd554c
chore(AI): Add info about frontend to AGENTS.md
nickvergessen 2fe651a
chore(AI): Extend agents.md with findings from other apps
nickvergessen c7a3401
ci(workflows): Add AI policy action
nickvergessen e7939d1
docs(AI): Update after review
nickvergessen eba5516
docs(AI): Optimize Agents.md
nickvergessen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| # This workflow is provided via the organization template repository | ||
| # | ||
| # https://github.com/nextcloud/.github | ||
| # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization | ||
| # | ||
| # SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| name: AI Policy | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| branches: [master, main] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| # Required to add the "AI assisted" label via `gh pr edit --add-label` | ||
| pull-requests: write | ||
| # Required to create the "AI assisted" label via the REST labels endpoint | ||
| # (labels are an issues-scoped resource in the GitHub API) | ||
| issues: write | ||
|
|
||
| concurrency: | ||
| group: ai-policy-${{ github.head_ref || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| check-ai-trailers: | ||
| runs-on: ubuntu-latest-low | ||
| steps: | ||
| - name: Collect PR commit messages | ||
| id: collect | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| COMMITS_URL: ${{ github.event.pull_request.commits_url }} | ||
| run: | | ||
| set -euo pipefail | ||
| gh api ${COMMITS_URL} | jq -r '.[] | .commit.message' > /tmp/pr_commits.txt | ||
| echo "--- PR commit messages ---" | ||
| cat /tmp/pr_commits.txt | ||
| echo "--------------------------" | ||
|
|
||
| - name: Define shared agent detection patterns | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| # Email addresses known to be used by coding agents. | ||
| # These should never appear in Signed-off-by because the DCO can only be attested by a human. | ||
| EMAIL_PATTERN="copilot@github\.com\ | ||
| |noreply@anthropic\.com\ | ||
| |devin@cognition\.ai\ | ||
| |devin@cognition-labs\.com\ | ||
| |aider@aider\.chat\ | ||
| |noreply@aider\.chat\ | ||
| |codex@openai\.com\ | ||
| |cursor@anysphere\.com\ | ||
| |windsurf@codeium\.com\ | ||
| |codeium@codeium\.com\ | ||
| |amazon-q@amazon\.com\ | ||
| |codewhisperer@amazon\.com\ | ||
| |gemini-code-assist@google\.com\ | ||
| |openhands@all-hands\.dev\ | ||
| |swe-agent@princeton\.edu" | ||
|
|
||
| # Strip embedded whitespace (used above only for readability) | ||
| EMAIL_PATTERN=$(echo "$EMAIL_PATTERN" | tr -d ' \n') | ||
| echo "AGENT_EMAIL_PATTERN=${EMAIL_PATTERN}" >> "$GITHUB_ENV" | ||
|
|
||
| # Display-name prefixes used by known coding agents (shared by Signed-off-by and Co-Authored-By checks) | ||
| # shellcheck disable=SC2016 | ||
| echo 'AGENT_NAMES=GitHub Copilot|Claude( [A-Za-z0-9. -]+)?|Devin( AI)?|aider( \(.*\))?|OpenAI Codex|Cursor( AI)?|Windsurf|Amazon Q|CodeWhisperer|Gemini Code Assist|OpenHands|SWE-agent|AutoCodeRover|Tabnine' >> "$GITHUB_ENV" | ||
|
|
||
| - name: Check for AI-assistant / Assisted-by trailers | ||
| id: ai_trailers | ||
| run: | | ||
| set -euo pipefail | ||
| AI_ASSISTED=false | ||
| if grep -qiE '^(AI-assistant|Assisted-by|AI-Assisted-By):' /tmp/pr_commits.txt; then | ||
| AI_ASSISTED=true | ||
| echo "Found AI-assistant/Assisted-by/AI-Assisted-By trailer(s):" | ||
| grep -iE '^(AI-assistant|Assisted-by|AI-Assisted-By):' /tmp/pr_commits.txt | ||
| fi | ||
| echo "ai_assisted=${AI_ASSISTED}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Check for coding-agent Signed-off-by trailers | ||
| id: agent_signoff | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| EMAIL_HITS=$(grep -iE "^Signed-off-by:.*<(${AGENT_EMAIL_PATTERN})>" /tmp/pr_commits.txt 2>/dev/null || true) | ||
| NAME_HITS=$(grep -iE "^Signed-off-by: *(${AGENT_NAMES}) *[<(]" /tmp/pr_commits.txt 2>/dev/null || true) | ||
|
|
||
| AGENT_LINES=$(printf '%s\n%s' "$EMAIL_HITS" "$NAME_HITS" | sort -u | sed '/^[[:space:]]*$/d') | ||
|
|
||
| AGENT_SIGNOFF=false | ||
| if [ -n "$AGENT_LINES" ]; then | ||
| AGENT_SIGNOFF=true | ||
| fi | ||
|
|
||
| echo "agent_signoff=${AGENT_SIGNOFF}" >> "$GITHUB_OUTPUT" | ||
| { | ||
| echo "agent_lines<<AGENT_EOF" | ||
| echo "${AGENT_LINES}" | ||
| echo "AGENT_EOF" | ||
| } >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Check for coding-agent Co-Authored-By trailers | ||
| id: co_authored | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| EMAIL_HITS=$(grep -iE "^Co-Authored-By:.*<(${AGENT_EMAIL_PATTERN})>" /tmp/pr_commits.txt 2>/dev/null || true) | ||
| NAME_HITS=$(grep -iE "^Co-Authored-By: *(${AGENT_NAMES}) *[<(]" /tmp/pr_commits.txt 2>/dev/null || true) | ||
|
|
||
| CO_AUTHORED=false | ||
| if [ -n "$EMAIL_HITS" ] || [ -n "$NAME_HITS" ]; then | ||
| CO_AUTHORED=true | ||
| echo "Found coding-agent Co-Authored-By trailer(s):" | ||
| printf '%s\n%s' "$EMAIL_HITS" "$NAME_HITS" | sort -u | sed '/^[[:space:]]*$/d' | ||
| fi | ||
|
|
||
| echo "co_authored=${CO_AUTHORED}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Create 'AI assisted' label if absent | ||
| if: steps.ai_trailers.outputs.ai_assisted == 'true' || steps.agent_signoff.outputs.agent_signoff == 'true' || steps.co_authored.outputs.co_authored == 'true' | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| gh api "repos/${{ github.repository }}/labels" \ | ||
| --method POST \ | ||
| -f name="AI assisted" \ | ||
| -f color="d93f0b" \ | ||
| -f description="This PR contains AI-assisted commits" \ | ||
| 2>/dev/null || true | ||
|
|
||
| - name: Label PR as AI assisted | ||
| if: steps.ai_trailers.outputs.ai_assisted == 'true' || steps.agent_signoff.outputs.agent_signoff == 'true' || steps.co_authored.outputs.co_authored == 'true' | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| gh pr edit "${{ github.event.pull_request.number }}" \ | ||
| --repo "${{ github.repository }}" \ | ||
| --add-label "AI assisted" | ||
| echo "Added 'AI assisted' label to PR #${{ github.event.pull_request.number }}" | ||
|
|
||
| - name: Fail on coding-agent Signed-off-by | ||
| if: steps.agent_signoff.outputs.agent_signoff == 'true' | ||
| env: | ||
| AGENT_LINES: ${{ steps.agent_signoff.outputs.agent_lines }} | ||
| AGENTS_MD_URL: https://github.com/${{ github.repository }}/blob/${{ github.base_ref }}/AGENTS.md | ||
| run: | | ||
| echo "::error title=Coding-agent sign-off detected::A Signed-off-by trailer from a known coding agent was found in one or more commits." | ||
| echo "" | ||
| echo "Offending trailer(s):" | ||
| echo "${AGENT_LINES}" | ||
| echo "" | ||
| echo "The 'Signed-off-by' trailer represents the Developer Certificate of Origin (DCO)" | ||
| echo "and must only be attested by a human contributor." | ||
| echo "Please amend the affected commit(s) to remove the coding-agent sign-off" | ||
| echo "and replace it with an 'Assisted-by' trailer, for example:" | ||
| echo "" | ||
| echo " Assisted-by: Claude Code:claude-sonnet-4-6" | ||
| echo "" | ||
| echo "References:" | ||
| echo " • AGENTS.md (this repository)" | ||
| echo " ${AGENTS_MD_URL}" | ||
| echo " • AI Contribution Policy" | ||
| echo " https://github.com/nextcloud/.github/blob/master/AI_POLICY.md" | ||
| echo " • Contribution Guidelines" | ||
| echo " https://github.com/nextcloud/.github/blob/master/CONTRIBUTING.md" | ||
| exit 1 | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the checklist checkbox?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean the github PR template checking that the box was ticked? Sounds like a good idea, but should be upstream, I just copied from the template repo