feat: Add @codebot changelog command for Keep a Changelog format generation #25
Reference in New Issue
Block a user
Delete Branch "feature/pr-changelog-generator"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements PR changelog generator that analyzes diffs and generates
Keep a Changelog format entries ready for CHANGELOG.md.
Features:
Implementation:
Workflow Safety (prevents duplicate runs):
Testing:
Documentation:
Related: Milestone 2 feature - PR changelog generation for release notes
📋 Pull Request Summary
This PR introduces a new
@codebot changelogcommand that generates Keep a Changelog format entries from pull request diffs. It adds support for changelog generation in the AI review system, including prompt templates, command handling, formatting, and tests.Type: ✨ Feature
Changes
✅ Added:
@codebot changelogcommand for generating changelog entries from PR diffsprompts/changelog.mdfor changelog generation_format_changelogin PRAgent_handle_changelog_commandin PRAgenttests/test_ai_review.pychangelogcommand inconfig.ymlREADME.mdandCLAUDE.mddescribing the changelog featurechangelogcommand inai-comment-reply.ymland exclude fromai-chat.yml📝 Modified:
changelogcommand in PR commentschangelogcommand correctlyFiles Affected
.gitea/workflows/ai-chat.yml- Excluded@codebot changelogcommand from ai-chat workflow to prevent duplicate runs.gitea/workflows/ai-comment-reply.yml- Added@codebot changelogcommand to ai-comment-reply workflow triggersCLAUDE.md- Added detailed documentation for the changelog generation feature and command usageREADME.md- Updated command list and usage examples to include the new@codebot changelogcommandtests/test_ai_review.py- Added comprehensive tests covering changelog prompt existence, formatting, command handling, and output correctnesstools/ai-review/agents/pr_agent.py- Implemented changelog command handler and formatting logic in PRAgenttools/ai-review/config.yml- Addedchangelogto the list of recognized interaction commandstools/ai-review/prompts/changelog.md- New prompt template defining requirements and format for changelog generationImpact
🟡 Scope: Medium
Introduces a new user-invoked feature that enhances release note generation by automating changelog creation from PR diffs. This affects PR comment handling and AI response workflows but does not alter existing functionality or APIs. It improves developer productivity and release documentation quality.
AI Code Review - Inline Comments
[LOW] Testing
The tests for changelog generation are comprehensive but do not include tests for error handling paths such as empty diffs or LLM failures.
Recommendation: Add tests that simulate empty diffs and LLM call failures to verify error handling and user feedback.
[LOW] Maintainability
The _handle_changelog_command method is quite long and could be split into smaller helper methods for clarity and easier testing.
Recommendation: Refactor _handle_changelog_command by extracting diff retrieval, prompt preparation, LLM call, and comment posting into separate private methods.
[LOW] Readability
The error message posted to the PR comment on failure is informative but could be improved by including a link to documentation or support resources.
Recommendation: Add a link or reference to troubleshooting docs or contact info in the error message to help users resolve issues.
[LOW] Maintainability
The _format_changelog method manually appends lines to a list and joins them. This approach is clear but could be simplified or made more flexible using a templating engine or helper functions.
Recommendation: Consider using a markdown templating approach or helper functions to reduce boilerplate and improve maintainability.
[LOW] Readability
The prompt is comprehensive and well-written but could benefit from a brief example snippet of expected JSON output at the top for immediate clarity.
Recommendation: Add a short example JSON snippet near the top of the prompt to help the LLM understand the expected output format quickly.
AI Code Review
This PR adds a new '@codebot changelog' command to generate Keep a Changelog format entries from PR diffs. It includes workflow updates, prompt template, command handling in the PR agent, formatting logic, documentation, and comprehensive tests. The implementation is well-structured, with clear separation of concerns and good test coverage. No security or correctness issues were found. Minor suggestions for maintainability and readability are noted.
Summary
Review Findings
tools/ai-review/agents/pr_agent.py:1024- The _handle_changelog_command method is quite long and could be split into smaller helper methods for clarity and easier testing.tools/ai-review/agents/pr_agent.py:1080- The error message posted to the PR comment on failure is informative but could be improved by including a link to documentation or support resources.tools/ai-review/agents/pr_agent.py:1140- The _format_changelog method manually appends lines to a list and joins them. This approach is clear but could be simplified or made more flexible using a templating engine or helper functions.tools/ai-review/prompts/changelog.md:1- The prompt is comprehensive and well-written but could benefit from a brief example snippet of expected JSON output at the top for immediate clarity.tests/test_ai_review.py:830- The tests for changelog generation are comprehensive but do not include tests for error handling paths such as empty diffs or LLM failures.Overall Severity:
LOWAI Recommendation: Approve