feat: Add automatic PR summary generator
All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 7s
All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 7s
Implements automatic PR summary generation feature that analyzes pull request diffs and generates comprehensive summaries. Features: - Auto-generates summaries for PRs with empty descriptions - Manual trigger via @codebot summarize command in PR comments - Structured output with change type, files affected, and impact assessment - Configurable (enable/disable, comment vs description update) Implementation: - Added pr_summary.md prompt template for LLM - Extended PRAgent with summary generation methods - Added auto_summary configuration in config.yml - Comprehensive test suite with 10 new tests - Updated documentation in README.md and CLAUDE.md Usage: - Automatic: Opens PR with no description → auto-generates summary - Manual: Comment '@codebot summarize' on any PR Related: Issue #2 - Milestone 2 feature delivery
This commit is contained in:
55
CLAUDE.md
55
CLAUDE.md
@@ -208,6 +208,7 @@ Key workflow pattern:
|
||||
Prompts are stored in `tools/ai-review/prompts/` as Markdown files:
|
||||
|
||||
- `base.md` - Base instructions for all reviews
|
||||
- `pr_summary.md` - PR summary generation template
|
||||
- `issue_triage.md` - Issue classification template
|
||||
- `issue_response.md` - Issue response template
|
||||
|
||||
@@ -407,6 +408,59 @@ pytest tests/test_ai_review.py::TestSecurityScanner -v
|
||||
|
||||
## Common Development Tasks
|
||||
|
||||
### PR Summary Generation
|
||||
|
||||
The PR summary feature automatically generates comprehensive summaries for pull requests.
|
||||
|
||||
**Key Features:**
|
||||
- Auto-generates summary for PRs with empty descriptions
|
||||
- Can be manually triggered with `@codebot summarize` in PR comments
|
||||
- Analyzes diff to extract key changes, files affected, and impact
|
||||
- Categorizes change type (Feature/Bugfix/Refactor/Documentation/Testing)
|
||||
- Posts as comment or updates PR description (configurable)
|
||||
|
||||
**Implementation Details:**
|
||||
|
||||
1. **Auto-Summary on PR Open** - `PRAgent.execute()`:
|
||||
- Checks if PR body is empty and `auto_summary.enabled` is true
|
||||
- Calls `_generate_pr_summary()` automatically
|
||||
- Continues with normal PR review after posting summary
|
||||
|
||||
2. **Manual Trigger** - `@codebot summarize` in PR comments:
|
||||
- `PRAgent.can_handle()` detects `summarize` command in PR comments
|
||||
- Routes to `_handle_summarize_command()`
|
||||
- Generates and posts summary on demand
|
||||
|
||||
3. **Summary Generation** - `_generate_pr_summary()`:
|
||||
- Fetches PR diff using `_get_diff()`
|
||||
- Loads `prompts/pr_summary.md` template
|
||||
- Calls LLM with diff to analyze changes
|
||||
- Returns structured JSON with summary data
|
||||
- Formats using `_format_pr_summary()`
|
||||
- Posts as comment or updates description based on config
|
||||
|
||||
4. **Configuration** - `config.yml`:
|
||||
```yaml
|
||||
agents:
|
||||
pr:
|
||||
auto_summary:
|
||||
enabled: true # Auto-generate for empty PRs
|
||||
post_as_comment: true # true = comment, false = update description
|
||||
```
|
||||
|
||||
**Summary Structure:**
|
||||
- Brief 2-3 sentence overview
|
||||
- Change type categorization (Feature/Bugfix/Refactor/etc)
|
||||
- Key changes (Added/Modified/Removed)
|
||||
- Files affected with descriptions
|
||||
- Impact assessment (scope: small/medium/large)
|
||||
|
||||
**Common Use Cases:**
|
||||
- Developers who forget to write PR descriptions
|
||||
- Quick understanding of complex changes
|
||||
- Standardized documentation format
|
||||
- Pre-review context for reviewers
|
||||
|
||||
### Review-Again Command Implementation
|
||||
|
||||
The `@codebot review-again` command allows manual re-triggering of PR reviews without new commits.
|
||||
@@ -463,6 +517,7 @@ Example commands:
|
||||
- `@codebot triage` - Full issue triage with labeling
|
||||
- `@codebot explain` - Explain the issue
|
||||
- `@codebot suggest` - Suggest solutions
|
||||
- `@codebot summarize` - Generate PR summary or issue summary (works on both)
|
||||
- `@codebot setup-labels` - Automatic label setup (built-in, not in config)
|
||||
- `@codebot review-again` - Re-run PR review without new commits (PR comments only)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user