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
18 changes: 9 additions & 9 deletions .github/agents/contribution-checker.agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ You will be called with a PR reference in `owner/repo#number` format. Parse the

## Step 1: Fetch Contributing Guidelines

Fetch the target repository's contributing guidelines. Look for these files in order and use the **first one found**:
If the CONTRIBUTING.md content was provided inline at the start of this prompt (inside `<contributing-guidelines>` tags), use that content directly and skip this step. If the inline content is `# No CONTRIBUTING.md found`, treat it as missing guidelines and return a single row with verdict `❓` and quality `no-guidelines`.

Otherwise, fetch the target repository's contributing guidelines. Look for these files in order and use the **first one found**:

1. `CONTRIBUTING.md` (repo root)
2. `.github/CONTRIBUTING.md`
Expand All @@ -30,17 +32,15 @@ For the given PR, retrieve:
- list of changed file paths (use `get_files`)
- diff content (use `get_diff`)

## Step 2.5: Deep Research
## Step 2.5: Targeted Context

Before running the checklist, do a deep dive into both the **target repository** and the **PR branch** to build enough context for high-quality, specific feedback:
Before running the checklist, gather targeted context:

1. **Understand the codebase** — browse the target repo's directory structure, README, and architecture docs. Identify the project's tech stack, module layout, and conventions (e.g., where tests live, how modules are organized, what frameworks are used).
2. **Understand the changed area** — for each file touched by the PR, read the surrounding code (not just the diff). Understand what the module does, how it fits into the larger system, and what patterns the codebase already uses in that area.
3. **Check for related issues** — if the PR body references an issue, read that issue to understand the original requirements and acceptance criteria.
4. **Check for existing tests** — look at the test directory/files adjacent to the changed code. Understand the testing patterns and frameworks the project uses so your feedback and agentic prompts reference the right tools and conventions.
5. **Check for duplicated effort** — search for open PRs that touch the same files or address the same issue to flag potential conflicts.
- Read the PR diff and changed files carefully to understand what's changing.
- If the PR body references an issue number, read that issue to understand the original requirements.

This research ensures the comment and agentic prompt you generate are **specific to the actual codebase** — referencing real file paths, real test patterns, and real conventions rather than generic advice.
Do not browse the repo directory, read surrounding code, or search for duplicate PRs.
This focused approach gives you enough context for a high-quality checklist without expensive exploration.

## Step 3: Run the Checklist

Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/contribution-check.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 27 additions & 3 deletions .github/workflows/contribution-check.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:

tools:
github:
toolsets: [default]
toolsets: [pull_requests, repos, issues]
allowed-repos: all
min-integrity: none
safe-outputs:
Expand Down Expand Up @@ -57,8 +57,8 @@ steps:
TOTAL=$(echo "$ALL_PRS" | jq 'length')
echo "Found $TOTAL open PRs created in the last 24 hours"

# Cap the number of PRs to evaluate at 10
MAX_EVALUATE=10
# Cap the number of PRs to evaluate at 5
MAX_EVALUATE=5
EVALUATED=$(echo "$ALL_PRS" | jq --argjson max "$MAX_EVALUATE" '[.[0:$max][] | .number]')
EVALUATED_COUNT=$(echo "$EVALUATED" | jq 'length')
SKIPPED_COUNT=$((TOTAL - EVALUATED_COUNT))
Expand All @@ -73,6 +73,21 @@ steps:

echo "✓ Wrote pr-filter-results.json: $EVALUATED_COUNT to evaluate, $SKIPPED_COUNT skipped"
cat "$GITHUB_WORKSPACE/pr-filter-results.json"

# Pre-fetch CONTRIBUTING.md once so all subagent calls can reuse it
CONTRIBUTING_FETCHED=false
for CONTRIBUTING_PATH in "CONTRIBUTING.md" ".github/CONTRIBUTING.md" "docs/CONTRIBUTING.md"; do
if gh api "repos/$TARGET_REPOSITORY/contents/$CONTRIBUTING_PATH" \
--jq '.content' 2>/dev/null | base64 -d > "$GITHUB_WORKSPACE/contributing-guidelines.md" 2>/dev/null; then
echo "✓ Pre-fetched contributing guidelines from $CONTRIBUTING_PATH"
CONTRIBUTING_FETCHED=true
break
fi
done
if [ "$CONTRIBUTING_FETCHED" = "false" ]; then
echo "# No CONTRIBUTING.md found" > "$GITHUB_WORKSPACE/contributing-guidelines.md"
echo "ℹ No CONTRIBUTING.md found in $TARGET_REPOSITORY (checked root, .github/, docs/)"
fi
---

## Target Repository
Expand Down Expand Up @@ -105,9 +120,18 @@ For each PR number in the comma-separated list, delegate evaluation to the **con

### How to dispatch

Read the contents of `contributing-guidelines.md` from the workspace root. This file was pre-fetched in the `pre-agent` step and contains the target repository's contributing guidelines. Include it verbatim in every subagent dispatch prompt to avoid redundant fetches.

Call the contribution-checker subagent for each PR with this prompt:

```
Comment on lines +123 to 127
The CONTRIBUTING.md content for this repository is attached below.
Skip Step 1 — do not fetch CONTRIBUTING.md again.

<contributing-guidelines>
{contents of contributing-guidelines.md}
</contributing-guidelines>

Evaluate PR ${{ env.TARGET_REPOSITORY }}#<number> against the contribution guidelines.
```

Expand Down
Loading