|
| 1 | +--- |
| 2 | +name: "Reviewer" |
| 3 | +description: "Automated PR review agent that posts review summaries, CI status checks, and actionable recommendations for pull requests." |
| 4 | +file_type: "agent" |
| 5 | +version: "v1.0" |
| 6 | +created_date: "2025-12-10" |
| 7 | +last_updated: "2025-12-10" |
| 8 | +author: "LightSpeed Team" |
| 9 | +maintainer: "Ash Shaw" |
| 10 | +category: "automation" |
| 11 | +status: "active" |
| 12 | +visibility: "public" |
| 13 | +tags: ["pr-review", "automation", "ci", "quality-gate", "pull-requests"] |
| 14 | +language: "en" |
| 15 | +references: |
| 16 | + - path: "../../scripts/agents/reviewer.agent.js" |
| 17 | + description: "Main implementation script" |
| 18 | + - path: "../workflows/reviewer.yml" |
| 19 | + description: "GitHub Actions workflow" |
| 20 | + - path: "../instructions/pull-requests.instructions.md" |
| 21 | + description: "PR standards and guidelines" |
| 22 | + - path: "../instructions/coding-standards.instructions.md" |
| 23 | + description: "Coding standards reference" |
| 24 | +owners: ["lightspeedwp/maintainers"] |
| 25 | +--- |
| 26 | + |
| 27 | +# Reviewer Agent |
| 28 | + |
| 29 | +## Purpose |
| 30 | + |
| 31 | +Automatically review pull requests and post comprehensive summaries including CI status, file analysis, changelog presence, and actionable recommendations to help maintainers make informed merge decisions. |
| 32 | + |
| 33 | +## Responsibilities |
| 34 | + |
| 35 | +- **CI Status Monitoring**: Check and report combined CI/CD pipeline status |
| 36 | +- **File Analysis**: Review changed files and identify potential issues |
| 37 | +- **Changelog Validation**: Verify changelog entries are present when required |
| 38 | +- **Review Summary**: Post structured comment with all findings |
| 39 | +- **Quality Gates**: Flag PRs that don't meet quality standards |
| 40 | + |
| 41 | +## Workflow Integration |
| 42 | + |
| 43 | +Triggered by the `.github/workflows/reviewer.yml` workflow on: |
| 44 | + |
| 45 | +- Pull request opened |
| 46 | +- Pull request synchronized (new commits pushed) |
| 47 | +- Pull request ready for review |
| 48 | + |
| 49 | +## Implementation |
| 50 | + |
| 51 | +**Script**: `scripts/agents/reviewer.agent.js` |
| 52 | + |
| 53 | +### Key Functions |
| 54 | + |
| 55 | +1. **run()** - Main orchestrator |
| 56 | + - Fetches PR context |
| 57 | + - Checks CI/CD status |
| 58 | + - Analyses changed files |
| 59 | + - Posts review summary comment |
| 60 | + |
| 61 | +2. **CI Status Check** |
| 62 | + - Queries GitHub combined status API |
| 63 | + - Reports: success, pending, failure, error, or unknown |
| 64 | + |
| 65 | +3. **File Analysis** |
| 66 | + - Lists changed files |
| 67 | + - Identifies file types |
| 68 | + - Flags high-risk changes |
| 69 | + |
| 70 | +4. **Changelog Validation** |
| 71 | + - Checks for CHANGELOG.md updates |
| 72 | + - Can be required or optional (configurable) |
| 73 | + |
| 74 | +### Review Summary Format |
| 75 | + |
| 76 | +```markdown |
| 77 | +## 🤖 Automated Review Summary |
| 78 | + |
| 79 | +### CI/CD Status |
| 80 | +✅ All checks passing |
| 81 | +⏳ Checks pending |
| 82 | +❌ Some checks failed |
| 83 | + |
| 84 | +### Changed Files |
| 85 | +- `file1.js` - Modified |
| 86 | +- `file2.md` - Added |
| 87 | +- `file3.test.js` - Modified |
| 88 | + |
| 89 | +### Changelog |
| 90 | +✅ Changelog updated |
| 91 | +⚠️ No changelog entry found |
| 92 | + |
| 93 | +### Recommendations |
| 94 | +- Review test coverage |
| 95 | +- Update documentation |
| 96 | +- Consider adding migration notes |
| 97 | +``` |
| 98 | + |
| 99 | +## Configuration |
| 100 | + |
| 101 | +The workflow accepts these inputs: |
| 102 | + |
| 103 | +- `github-token`: GitHub token for API access (required) |
| 104 | +- `require-changelog`: Whether to enforce changelog entries (default: `false`) |
| 105 | + |
| 106 | +## Best Practices |
| 107 | + |
| 108 | +1. **Review Automation**: This agent assists reviewers but doesn't replace human code review |
| 109 | +2. **CI Integration**: Always wait for CI to complete before merging |
| 110 | +3. **Changelog**: Update CHANGELOG.md for user-facing changes |
| 111 | +4. **Quick Feedback**: Agent provides instant feedback to PR authors |
| 112 | + |
| 113 | +## Error Handling |
| 114 | + |
| 115 | +- Gracefully handles missing PR context |
| 116 | +- Reports API errors without failing the workflow |
| 117 | +- Provides dry-run mode for testing |
| 118 | + |
| 119 | +## Related Agents |
| 120 | + |
| 121 | +- [Testing Agent](./testing.agent.md) - Runs test suites |
| 122 | +- [Linting Agent](./linting.agent.md) - Code quality checks |
| 123 | +- [Labeling Agent](./labeling.agent.md) - PR label automation |
| 124 | +- [Release Agent](./release.agent.md) - Release preparation |
| 125 | + |
| 126 | +## Reference Documentation |
| 127 | + |
| 128 | +- [Pull Request Process](../instructions/pull-requests.instructions.md) |
| 129 | +- [Coding Standards](../instructions/coding-standards.instructions.md) |
| 130 | +- [GitHub Actions Workflows](../../docs/WORKFLOWS.md) |
| 131 | + |
| 132 | +--- |
| 133 | + |
| 134 | +*Reviewer Agent - Automated PR quality gates and review assistance* |
0 commit comments