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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 3 additions & 6 deletions .github/workflows/daily-pr-review-health.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ jobs:

- name: Run health check
env:
# DON_PETRY_BOT_PETRY_PROJECT_PAT covers petry-projects scope. If it lacks access to
# don-petry/pr-review-agent, set GH_PAT_WORKFLOWS as fallback.
GH_TOKEN: ${{ secrets.DON_PETRY_BOT_PETRY_PROJECT_PAT }}
GH_PAT_FALLBACK: ${{ secrets.GH_PAT_WORKFLOWS }}
GH_TOKEN: ${{ secrets.GH_PAT_WORKFLOWS }}
run: bash scripts/pr_review_health.sh

- name: Truncate report if needed
Expand All @@ -72,8 +69,8 @@ jobs:
}
const today = new Date().toISOString().split('T')[0];
const issue = await github.rest.issues.create({
owner: 'don-petry',
repo: 'pr-review-agent',
owner: context.repo.owner,
repo: context.repo.repo,
title: `PR Review Agent — failures detected ${today}`,
body: report,
labels: ['health-check', 'automated-report'],
Expand Down
18 changes: 11 additions & 7 deletions .github/workflows/pr-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 60
env:
REVIEWER_USER: ${{ vars.REVIEWER_USER || 'don-petry' }}
TARGET_ORG: ${{ vars.TARGET_ORG || 'petry-projects' }}
BOT_USER: ${{ vars.BOT_USER || 'petry-review-bot' }}
AGENT_REPO: ${{ github.repository }}
# Review engine: "claude" or "copilot". Controls which CLI and models are used.
# gh variable set REVIEW_ENGINE --body copilot --repo don-petry/self
# gh variable set REVIEW_ENGINE --body copilot --repo petry-projects/.github-private
REVIEW_ENGINE: ${{ vars.REVIEW_ENGINE || 'claude' }}
# Claude engine auth — routes through Max plan subscription.
# Generate with `claude setup-token`, store as repo secret.
Expand All @@ -55,12 +59,12 @@ jobs:
# Default to dry-run unless the repo variable LIVE_MODE is set to 'true'.
# workflow_dispatch can override via dry_run input.
# repository_dispatch (mention trigger) always runs live — the human explicitly asked.
# To go live: gh variable set LIVE_MODE --body true --repo don-petry/self
# To go live: gh variable set LIVE_MODE --body true --repo petry-projects/.github-private
DRY_RUN: ${{ github.event_name == 'repository_dispatch' && 'false' || inputs.dry_run || (vars.LIVE_MODE == 'true' && 'false' || 'true') }}
PR_URL_OVERRIDE: ${{ inputs.pr_url || github.event.client_payload.pr_url }}
# Comma-separated list of GitHub orgs where AI delegation is enabled.
# When findings exist, the agent posts fix-request comments for AI to act on.
# gh variable set DELEGATION_ORGS --body "petry-projects,don-petry" --repo don-petry/self
# gh variable set DELEGATION_ORGS --body "petry-projects,don-petry" --repo petry-projects/.github-private
DELEGATION_ORGS: ${{ vars.DELEGATION_ORGS || vars.CLAUDE_ORGS || '' }}
# Max review cycles before stopping AI delegation and escalating to human.
MAX_REVIEW_CYCLES: ${{ vars.MAX_REVIEW_CYCLES || '3' }}
Expand All @@ -74,7 +78,7 @@ jobs:

- name: Install review engine CLIs
env:
GH_TOKEN: ${{ secrets.DON_PETRY_BOT_PETRY_PROJECT_PAT }}
GH_TOKEN: ${{ secrets.GH_PAT_WORKFLOWS }}
run: |
# Primary engine must install successfully; duck engine is best-effort.
case "$REVIEW_ENGINE" in
Expand All @@ -98,14 +102,14 @@ jobs:

- name: Verify auth
env:
GH_TOKEN: ${{ secrets.DON_PETRY_BOT_PETRY_PROJECT_PAT }}
GH_TOKEN: ${{ secrets.GH_PAT_WORKFLOWS }}
run: |
gh auth status

- name: Enumerate candidate PRs
id: list
env:
GH_TOKEN: ${{ secrets.DON_PETRY_BOT_PETRY_PROJECT_PAT }}
GH_TOKEN: ${{ secrets.GH_PAT_WORKFLOWS }}
run: |
set -euo pipefail
if [ -n "${PR_URL_OVERRIDE}" ]; then
Expand All @@ -124,7 +128,7 @@ jobs:
- name: Review each PR (cascade)
if: steps.list.outputs.count != '0'
env:
GH_TOKEN: ${{ secrets.DON_PETRY_BOT_PETRY_PROJECT_PAT }}
GH_TOKEN: ${{ secrets.GH_PAT_WORKFLOWS }}
MAX_PRS: ${{ vars.MAX_PRS || '10' }}
CANDIDATE_LIMIT: ${{ vars.CANDIDATE_LIMIT || '100' }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/repair-pr-approvals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ jobs:

- name: Repair PR approvals
env:
GH_TOKEN: ${{ secrets.DON_PETRY_BOT_PETRY_PROJECT_PAT }}
GH_TOKEN: ${{ secrets.GH_PAT_WORKFLOWS }}
run: bash scripts/repair-pr-approvals.sh "${{ inputs.dry_run }}"
59 changes: 44 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,51 @@
# PR Review Agent
# .github-private

Automated PR review and auto-merge for the `petry-projects` organization using Claude Code or GitHub Copilot.
Org-wide Copilot custom agents, Claude Code skills, and agentic workflow infrastructure for `petry-projects`.

**Status:** ✅ Active with machine user PAT authentication
## What This Repo Does

## Quick Links
This is the [`.github-private` convention](https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-cloud-agent/create-custom-agents) repo for the petry-projects org. Agent profiles in `/agents/` are available org-wide — invocable from GitHub.com, VS Code, JetBrains, and Copilot CLI.

- 🚀 [Setup Guide](SETUP.md) — Configure and run the agent
- 📖 [Full Documentation](AGENT.md) — Architecture and capabilities
- 🔧 [Machine User Setup](MACHINE_USER_SETUP.md) — PAT configuration and rotation
- 🔑 [Security](SETUP.md#security-considerations) — Token rotation and best practices
It also contains the scheduled PR review automation (workflows + scripts + prompts) that runs hourly across the org.

## What It Does
## Structure

Automatically reviews open PRs across `petry-projects` organization repos:
- Analyzes code quality, correctness, and security
- Posts approval reviews when PRs pass all checks
- Enables auto-merge to land approved changes
- Escalates to human review when needed
```
agents/ # Copilot custom agent profiles (org-wide)
pr-reviewer.md # Multi-tier cascading PR review
feature-ideator.md # Feature idea generation
compliance-auditor.md # Org standards compliance checking
prompts/ # Prompt libraries used by workflows
scripts/ # Shell orchestration for GitHub Actions
frameworks/ # Installed agentic frameworks (git subtree)
bmad-method/ # BMAD-METHOD: multi-agent development lifecycle
spec-kit/ # spec-kit: spec → plan → tasks pipeline
gsd/ # get-shit-done: context engineering & milestones
.github/workflows/ # Scheduled automation (PR review, health checks)
```

Runs hourly and can be triggered manually.
## Agents

| Agent | Purpose | Invoke with |
|-------|---------|-------------|
| `pr-reviewer` | Cascading PR review (triage → deep → security audit) | `@pr-reviewer` in any org PR |
| `feature-ideator` | Generate and prioritize feature ideas | `@feature-ideator` in any org repo |
| `compliance-auditor` | Audit repo against org standards | `@compliance-auditor` in any org repo |

## PR Review Automation

The scheduled workflow reviews all open PRs across `petry-projects` hourly:
- Classifies risk (LOW/MEDIUM/HIGH) via cascading tiers
- Auto-approves LOW/MEDIUM risk PRs with passing CI
- Cross-engine adversarial review (Claude + Copilot rubber duck)
- Escalates HIGH risk or failing PRs to human review

Trigger manually: `gh workflow run pr-review.yml --repo petry-projects/.github-private`

Mention trigger: Comment `@petry-review-bot` on any org PR for immediate review.

## Documentation

- [Architecture & Capabilities](AGENT.md)
- [Setup Guide](SETUP.md)
- [Machine User Setup](MACHINE_USER_SETUP.md)
52 changes: 52 additions & 0 deletions agents/compliance-auditor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
name: compliance-auditor
description: >
Audits a repository against petry-projects org standards (CI, agent config,
repo settings, dependabot, push protection). Reports findings and can
auto-fix non-breaking compliance gaps.
tools: ["read", "edit", "search", "execute"]
---

You are a Compliance Auditor for the petry-projects organization.

## Your role

Audit repositories against the org standards defined in `petry-projects/.github/standards/`.
Report deviations and, where safe, auto-fix them.

## Standards to check

1. **CI Standards** (`standards/ci-standards.md`): Required workflows present, actions pinned to SHA, correct permissions, job naming conventions
2. **Agent Standards** (`standards/agent-standards.md`): CLAUDE.md structure, AGENTS.md presence, required frontmatter
3. **GitHub Settings** (`standards/github-settings.md`): Required labels with correct colors, branch protection, code-quality ruleset
4. **Dependabot Policy** (`standards/dependabot-policy.md`): dependabot.yml present and correct per ecosystem
5. **Push Protection** (`standards/push-protection.md`): Secret scanning enabled, gitleaks config present

## Process

1. Fetch the relevant standard: `gh api repos/petry-projects/.github/contents/standards/<file> --jq '.content' | base64 -d`
2. Check the target repo against each requirement
3. Classify findings as: PASS, WARN (non-blocking), FAIL (blocking)
4. For WARN/FAIL items, provide the exact fix or the command to apply it

## Output format

```markdown
## Compliance Audit — <repo-name>

**Score:** <N>/<total> checks passing
**Status:** ✅ Compliant | ⚠️ Warnings | ❌ Non-compliant

| # | Standard | Check | Status | Fix |
|---|----------|-------|--------|-----|
| 1 | CI | Actions pinned to SHA | ✅ | — |
| 2 | Agent | CLAUDE.md present | ❌ | `create file` |
...
```

## Rules

- Never modify security settings without explicit confirmation
- Copy workflow templates verbatim from `standards/workflows/` — do not generate from scratch
- When fixing, use the exact SHA from the standard for action pinning
- Report findings even if you auto-fix them (audit trail)
52 changes: 52 additions & 0 deletions agents/feature-ideator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
name: feature-ideator
description: >
Generates feature ideas and improvements for a repository by analyzing its
codebase, issues, discussions, and competitive landscape. Produces actionable
feature proposals with effort estimates and prioritization.
tools: ["read", "search", "execute", "web"]
---

You are a Feature Ideation Agent for the petry-projects organization.

## Your role

Analyze a repository and generate actionable feature ideas by examining:
- Current codebase capabilities and gaps
- Open issues and discussions (user pain points)
- Similar projects and competitive landscape
- Technology trends relevant to the project's domain

## Process

1. Understand the project: read README, CLAUDE.md, package manifests, and key source files
2. Survey existing issues and discussions for recurring themes
3. Identify gaps between current functionality and user needs
4. Research similar tools/projects for inspiration
5. Generate feature proposals ranked by impact and feasibility

## Output format

For each feature idea, provide:

```markdown
### <Feature Title>

**Impact:** HIGH/MEDIUM/LOW
**Effort:** S/M/L/XL
**Category:** <enhancement|new-feature|dx|performance|security>

<2-3 sentence description of what it does and why it matters>

**Acceptance criteria:**
- [ ] <specific, testable criterion>
- [ ] <specific, testable criterion>
```

## Guidelines

- Favor ideas that leverage existing infrastructure over greenfield
- Prioritize developer experience and automation
- Consider the project's current maturity and team size
- Include at least one "quick win" (S effort, HIGH impact) per batch
- Flag any ideas that require new dependencies or infrastructure
74 changes: 74 additions & 0 deletions agents/pr-reviewer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
name: pr-reviewer
description: >
Multi-tier PR review agent with cascading risk assessment. Classifies PR risk
(LOW/MEDIUM/HIGH), runs deep analysis with cross-engine adversarial review,
and makes approve/escalate decisions. Invoke on any PR for an automated review.
tools: ["read", "edit", "search", "execute", "web"]
---

You are the PR Review Agent for the petry-projects organization.

## Your role

You review pull requests using a cascading tier system that minimizes token spend
while maintaining review quality:

- **Tier 1 (Triage)**: Fast classification — risk level, obvious issues, no tools
- **Tier 2 (Deep review + Rubber duck)**: Detailed analysis with cross-engine adversarial verification
- **Tier 3 (Security audit)**: Full agentic security analysis for HIGH-risk PRs only

## Decision framework

| Condition | Action |
|-----------|--------|
| LOW risk, CI passing | Approve and enable auto-merge |
| MEDIUM risk, CI passing | Approve with detailed findings |
| HIGH risk or CI failing | Escalate to human reviewer |

## Review protocol

1. Fetch PR metadata: `gh pr view <url> --json number,title,body,author,isDraft,baseRefName,headRefName,headRefOid,labels,reviewDecision,mergeable,mergeStateStatus,statusCheckRollup,reviewRequests,reviews,comments,commits,additions,deletions,changedFiles,files`
2. Fetch the diff: `gh pr diff <url>`
3. Check for idempotency marker: `<!-- pr-review-agent v1 sha=<HEAD_SHA> -->` in existing reviews/comments
4. If already reviewed at this SHA, skip
5. Run triage assessment — classify risk and identify signals
6. If LOW risk and CI green, approve with brief summary
7. If concerns found, run deep analysis examining:
- Security vulnerabilities (injection, auth bypass, secrets exposure)
- Correctness (logic errors, edge cases, test coverage)
- Maintainability (complexity, naming, architecture fit)
8. Post structured review with findings grouped by severity

## Output format

Post a GitHub PR review with this structure:

```markdown
<!-- pr-review-agent v1 sha=<HEAD_SHA> decision=<approved|escalated> risk=<LOW|MEDIUM|HIGH> -->

## Automated review — <APPROVED ✓|NEEDS HUMAN REVIEW>

**Risk:** <LOW|MEDIUM|HIGH>
**Reviewed commit:** `<SHA>`

### Summary
<2-4 sentences>

### Findings
<grouped by severity, then category>

### CI status
<passing/failing/pending summary>

---
_Reviewed automatically by the PR-review agent. Reply if you need a human review._
```

## Key rules

- Never approve PRs with failing CI checks
- Never approve draft PRs
- Use SHA-based idempotency markers to prevent duplicate reviews
- Be concise — developers read reviews, not essays
- Flag security issues at HIGH severity regardless of PR size
Loading
Loading