feat: Add @codebot changelog command for Keep a Changelog format generation
All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 41s

Implements PR changelog generator that analyzes diffs and generates
Keep a Changelog format entries ready for CHANGELOG.md.

Features:
- Generates structured changelog entries (Added/Changed/Fixed/etc.)
- Automatically detects breaking changes
- Includes technical details (files, LOC, components)
- User-focused language filtering out noise
- Ready to copy-paste into CHANGELOG.md

Implementation:
- Added changelog.md prompt template with Keep a Changelog format
- Implemented _handle_changelog_command() in PRAgent
- Added _format_changelog() for markdown formatting
- Updated PRAgent.can_handle() to route changelog commands
- Added 'changelog' to config.yml commands list

Workflow Safety (prevents duplicate runs):
- Added '@codebot changelog' to ai-comment-reply.yml conditions
- Excluded from ai-chat.yml to prevent duplication
- Only triggers on PR comments (not issues)
- Manual command only (no automatic triggering)

Testing:
- 9 comprehensive tests in TestChangelogGeneration class
- Tests command detection, formatting, config validation
- Verifies prompt formatting and Keep a Changelog structure

Documentation:
- Updated README.md with changelog command and examples
- Added detailed implementation guide in CLAUDE.md
- Included example output and use cases

Related: Milestone 2 feature - PR changelog generation for release notes
This commit is contained in:
2025-12-29 10:52:48 +00:00
parent c6dbb0acf6
commit 15beb0fb5b
8 changed files with 628 additions and 3 deletions

View File

@@ -216,6 +216,7 @@ 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
- `changelog.md` - Keep a Changelog format generation template
- `issue_triage.md` - Issue classification template
- `issue_response.md` - Issue response template
@@ -468,6 +469,70 @@ The PR summary feature automatically generates comprehensive summaries for pull
- Standardized documentation format
- Pre-review context for reviewers
### PR Changelog Generation
The `@codebot changelog` command generates Keep a Changelog format entries from PR diffs.
**Key Features:**
- Generates structured changelog entries following Keep a Changelog format
- Categorizes changes: Added/Changed/Deprecated/Removed/Fixed/Security
- Automatically detects breaking changes
- Includes technical details (files changed, LOC, components)
- Output is ready to copy-paste into CHANGELOG.md
**Implementation Details:**
1. **Command Handler** - `PRAgent._handle_changelog_command()`:
- Triggered by `@codebot changelog` in PR comments
- Fetches PR title, description, and diff
- Loads `prompts/changelog.md` template
- Formats prompt with PR context
2. **LLM Analysis** - Generates structured JSON:
```json
{
"changelog": {
"added": ["New features"],
"changed": ["Changes to existing functionality"],
"fixed": ["Bug fixes"],
"security": ["Security fixes"]
},
"breaking_changes": ["Breaking changes"],
"technical_details": {
"files_changed": 15,
"insertions": 450,
"deletions": 120,
"main_components": ["auth/", "api/"]
}
}
```
3. **Formatting** - `_format_changelog()`:
- Converts JSON to Keep a Changelog markdown format
- Uses emojis for visual categorization (✨ Added, 🔄 Changed, 🐛 Fixed)
- Highlights breaking changes prominently
- Includes technical summary at the end
- Omits empty sections for clean output
4. **Prompt Engineering** - `prompts/changelog.md`:
- User-focused language (not developer jargon)
- Filters noise (formatting, typos, minor refactoring)
- Groups related changes
- Active voice, concise entries
- Maximum 100 characters per entry
**Common Use Cases:**
- Preparing release notes
- Maintaining CHANGELOG.md
- Customer-facing announcements
- Version documentation
**Workflow Safety:**
- Only triggers on PR comments (not issue comments)
- Included in ai-comment-reply.yml workflow conditions
- Excluded from ai-chat.yml to prevent duplicate runs
- No automatic triggering - manual command only
### Review-Again Command Implementation
The `@codebot review-again` command allows manual re-triggering of PR reviews without new commits.
@@ -525,6 +590,7 @@ Example commands:
- `@codebot explain` - Explain the issue
- `@codebot suggest` - Suggest solutions
- `@codebot summarize` - Generate PR summary or issue summary (works on both)
- `@codebot changelog` - Generate Keep a Changelog format entries (PR comments only)
- `@codebot setup-labels` - Automatic label setup (built-in, not in config)
- `@codebot review-again` - Re-run PR review without new commits (PR comments only)