Skip to content
Closed
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
61 changes: 61 additions & 0 deletions .github/workflows/detect-ai.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Runs script to detect the likelihood of a PR have being create
# by an agent, or with a human with heavy use of AI.

name: Detect AI

on:
pull_request:
branches:
- master
- uncover-agent

permissions:
contents: read
pull-requests: write
issues: write

jobs:
analyse:
name: Classify PR (AI vs human)
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CODEBERG_TOKEN: ${{ secrets.CODEBERG_TOKEN }}
steps:
- name: Check out repository
# The Codeberg repo is private, so we have to clone it with a Codeberg token
run: |
set -euo pipefail
[ -n "$CODEBERG_TOKEN" ] || { echo "::error::CODEBERG_TOKEN secret is required"; exit 1; }
clone_url="https://user:${CODEBERG_TOKEN}@codeberg.org/doublebyte/uncover-agent.git"
git clone --quiet "$clone_url" "$RUNNER_TEMP/uncover-agent"
shopt -s dotglob
mv "$RUNNER_TEMP/uncover-agent"/* .
rmdir "$RUNNER_TEMP/uncover-agent"

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12" # we can change this later

- name: Run uncover_agents.py
run: |
set -euo pipefail
PR_URL="https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}"
python uncover_agents.py "$PR_URL" | tee result.json

- name: Apply AI / human label
run: |
set -euo pipefail
LABEL=$(python3 -c "import json;print(json.load(open('result.json')).get('label',''))")
echo "Classifier label: $LABEL"
case "$LABEL" in
Low)
gh pr edit "$PR_NUMBER" --add-label "human generated" ;;
High|Very\ High)
gh pr edit "$PR_NUMBER" --add-label "AI generated" ;;
*)
echo "Label '$LABEL' maps to no auto-label; nothing to do." ;;
esac
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
4 changes: 4 additions & 0 deletions .uncover-agent/NOTE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# uncover-agent test diff
# original: https://github.com/geopython/diving-into-pygeoapi/pull/246
# kind=human
# generated 2026-10-18 19:54:27 UTC
Loading