feat: Add automatic PR summary generator #20

Merged
Latte merged 2 commits from feature/pr-summary-generator into dev 2025-12-29 10:30:02 +00:00
Owner

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

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
Latte added this to the Milestone 2: PR Workflow Enhancement milestone 2025-12-29 10:25:45 +00:00
Latte self-assigned this 2025-12-29 10:25:45 +00:00
Latte added 1 commit 2025-12-29 10:25:45 +00:00
feat: Add automatic PR summary generator
All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 7s
e21ec5f57a
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
Latte added 1 commit 2025-12-29 10:26:09 +00:00
Merge branch 'dev' into feature/pr-summary-generator
All checks were successful
Enterprise AI Code Review / ai-review (pull_request) Successful in 30s
92840d820b
Owner

📋 Pull Request Summary

This PR introduces an automated PR summary generation feature that creates comprehensive, structured summaries for pull requests, especially when descriptions are missing. It supports both automatic generation on PR creation and manual triggering via the @codebot summarize command, enhancing review efficiency and standardization.

Type: Feature

Changes

Added:

  • PR summary generation functionality in PRAgent
  • New prompt template pr_summary.md for structured summary generation
  • Configuration options for auto-summary in config.yml
  • Support for @codebot summarize command in PR comments
  • Extensive tests for PR summary generation

📝 Modified:

  • PRAgent to handle summarize commands and auto-generate summaries on empty PR descriptions
  • README.md to document the new PR summary feature and command
  • CLAUDE.md to include detailed workflow and usage instructions for PR summaries
  • config.yml to add auto_summary configuration under PR agent

Files Affected

  • 📝 tools/ai-review/agents/pr_agent.py - Added PR summary generation methods, command handling for summarize, and auto-summary on PR open with empty description
  • tools/ai-review/prompts/pr_summary.md - New prompt template defining the structure and requirements for PR summary generation
  • 📝 tools/ai-review/config.yml - Added configuration for enabling/disabling auto-summary and choosing comment vs description posting
  • 📝 README.md - Updated documentation to include PR summary feature and @codebot summarize command usage
  • 📝 CLAUDE.md - Expanded developer workflow documentation with detailed explanation of PR summary generation feature and commands
  • 📝 tests/test_ai_review.py - Added comprehensive tests covering prompt existence, formatting, command handling, summary formatting, and config validation for PR summaries

Impact

🟡 Scope: Medium
Introduces a new automated feature that improves PR documentation and review workflows without altering existing review logic. It adds new commands and configuration but maintains backward compatibility and does not affect core functionality.

## 📋 Pull Request Summary This PR introduces an automated PR summary generation feature that creates comprehensive, structured summaries for pull requests, especially when descriptions are missing. It supports both automatic generation on PR creation and manual triggering via the `@codebot summarize` command, enhancing review efficiency and standardization. **Type:** ✨ Feature ## Changes **✅ Added:** - PR summary generation functionality in PRAgent - New prompt template `pr_summary.md` for structured summary generation - Configuration options for auto-summary in `config.yml` - Support for `@codebot summarize` command in PR comments - Extensive tests for PR summary generation **📝 Modified:** - PRAgent to handle summarize commands and auto-generate summaries on empty PR descriptions - README.md to document the new PR summary feature and command - CLAUDE.md to include detailed workflow and usage instructions for PR summaries - config.yml to add auto_summary configuration under PR agent ## Files Affected - 📝 `tools/ai-review/agents/pr_agent.py` - Added PR summary generation methods, command handling for summarize, and auto-summary on PR open with empty description - ➕ `tools/ai-review/prompts/pr_summary.md` - New prompt template defining the structure and requirements for PR summary generation - 📝 `tools/ai-review/config.yml` - Added configuration for enabling/disabling auto-summary and choosing comment vs description posting - 📝 `README.md` - Updated documentation to include PR summary feature and `@codebot summarize` command usage - 📝 `CLAUDE.md` - Expanded developer workflow documentation with detailed explanation of PR summary generation feature and commands - 📝 `tests/test_ai_review.py` - Added comprehensive tests covering prompt existence, formatting, command handling, summary formatting, and config validation for PR summaries ## Impact 🟡 **Scope:** Medium Introduces a new automated feature that improves PR documentation and review workflows without altering existing review logic. It adds new commands and configuration but maintains backward compatibility and does not affect core functionality.
Bartender reviewed 2025-12-29 10:26:49 +00:00
Bartender left a comment
Owner

AI Code Review - Inline Comments

AI Code Review - Inline Comments
Owner

[LOW] Maintainability

The _generate_pr_summary method continues with the regular PR review after posting the summary for empty PR descriptions, but it does not explicitly handle the case where summary generation fails. This could lead to silent failures without clear feedback.

Recommendation: Add explicit logging or error handling to notify if summary generation fails during auto-summary on PR open, to improve observability.

**[LOW] Maintainability** The _generate_pr_summary method continues with the regular PR review after posting the summary for empty PR descriptions, but it does not explicitly handle the case where summary generation fails. This could lead to silent failures without clear feedback. **Recommendation:** Add explicit logging or error handling to notify if summary generation fails during auto-summary on PR open, to improve observability.
Owner

[LOW] Readability

The _format_pr_summary method uses hardcoded emoji mappings and string literals for formatting the summary. While functional, this could be extracted to constants or configuration for easier updates and localization.

Recommendation: Extract emoji mappings and repeated strings into class-level constants or configuration to improve maintainability and facilitate future changes.

**[LOW] Readability** The _format_pr_summary method uses hardcoded emoji mappings and string literals for formatting the summary. While functional, this could be extracted to constants or configuration for easier updates and localization. **Recommendation:** Extract emoji mappings and repeated strings into class-level constants or configuration to improve maintainability and facilitate future changes.
Owner

[LOW] Architecture

The method _generate_pr_summary mixes concerns of generating the summary, formatting it, and posting it to Gitea. This tight coupling could make testing and future extensions harder.

Recommendation: Separate concerns by splitting summary generation, formatting, and posting into distinct methods or services to improve modularity and testability.

**[LOW] Architecture** The method _generate_pr_summary mixes concerns of generating the summary, formatting it, and posting it to Gitea. This tight coupling could make testing and future extensions harder. **Recommendation:** Separate concerns by splitting summary generation, formatting, and posting into distinct methods or services to improve modularity and testability.
Owner

[LOW] Correctness

The fallback logic when updating the PR description fails is to post the summary as a comment. However, the comment is posted without indicating it is a fallback, which might confuse users.

Recommendation: Include a note in the fallback comment indicating that updating the PR description failed and the summary is posted as a comment instead.

**[LOW] Correctness** The fallback logic when updating the PR description fails is to post the summary as a comment. However, the comment is posted without indicating it is a fallback, which might confuse users. **Recommendation:** Include a note in the fallback comment indicating that updating the PR description failed and the summary is posted as a comment instead.
Owner

[LOW] Testing

The tests cover prompt existence, formatting, command handling, and summary formatting well. However, there is no test verifying the behavior when the LLM returns malformed or incomplete JSON data.

Recommendation: Add tests simulating malformed or incomplete LLM responses to ensure the agent handles such cases gracefully without crashing or posting invalid summaries.

**[LOW] Testing** The tests cover prompt existence, formatting, command handling, and summary formatting well. However, there is no test verifying the behavior when the LLM returns malformed or incomplete JSON data. **Recommendation:** Add tests simulating malformed or incomplete LLM responses to ensure the agent handles such cases gracefully without crashing or posting invalid summaries.
Owner

[LOW] Readability

The can_handle method checks for both 'review-again' and 'summarize' commands in a single conditional, which slightly reduces clarity.

Recommendation: Separate the checks for 'review-again' and 'summarize' commands into distinct conditionals or helper methods to improve readability and future extensibility.

**[LOW] Readability** The can_handle method checks for both 'review-again' and 'summarize' commands in a single conditional, which slightly reduces clarity. **Recommendation:** Separate the checks for 'review-again' and 'summarize' commands into distinct conditionals or helper methods to improve readability and future extensibility.
Owner

AI Code Review

This PR introduces an automated PR summary generation feature within the PRAgent, enabling automatic and manual generation of structured, informative summaries for pull requests. It includes a new prompt template, configuration options, and command handling for '@codebot summarize'. Comprehensive tests cover prompt existence, formatting, command handling, and configuration validation.

Summary

Severity Count
HIGH 0
MEDIUM 0
LOW 5

Review Findings

  • [LOW] tools/ai-review/agents/pr_agent.py:130 - The method _generate_pr_summary attempts to update the PR description via the Gitea API, but the comment notes that this may not be supported and falls back to posting a comment. This fallback logic is appropriate but could be clarified or improved by explicitly checking API capabilities or documenting limitations.
  • [LOW] tools/ai-review/agents/pr_agent.py:123 - The execute method handles multiple commands (@codebot summarize and review-again) in a single conditional block, which could grow as more commands are added.
  • [LOW] tools/ai-review/agents/pr_agent.py:140 - The _generate_pr_summary method loads the entire PR diff and sends it to the LLM for analysis. For very large diffs, this could be inefficient or exceed LLM input limits.
  • [LOW] tools/ai-review/prompts/pr_summary.md:1 - The prompt template is well-structured and clear, but the JSON output example uses double curly braces '{{' and '}}' which may confuse some users or tools that do not expect escaped braces.
  • [LOW] tests/test_ai_review.py:600 - The tests for PR summary generation cover prompt existence, formatting, command handling, and config validation but do not include tests for failure scenarios such as LLM call failures or empty diffs.

Overall Severity: LOW
AI Recommendation: Approve

<!-- AI_PR_REVIEW --> ## AI Code Review This PR introduces an automated PR summary generation feature within the PRAgent, enabling automatic and manual generation of structured, informative summaries for pull requests. It includes a new prompt template, configuration options, and command handling for '@codebot summarize'. Comprehensive tests cover prompt existence, formatting, command handling, and configuration validation. ### Summary | Severity | Count | |----------|-------| | HIGH | 0 | | MEDIUM | 0 | | LOW | 5 | ### Review Findings - **[LOW]** `tools/ai-review/agents/pr_agent.py:130` - The method _generate_pr_summary attempts to update the PR description via the Gitea API, but the comment notes that this may not be supported and falls back to posting a comment. This fallback logic is appropriate but could be clarified or improved by explicitly checking API capabilities or documenting limitations. - **[LOW]** `tools/ai-review/agents/pr_agent.py:123` - The execute method handles multiple commands (@codebot summarize and review-again) in a single conditional block, which could grow as more commands are added. - **[LOW]** `tools/ai-review/agents/pr_agent.py:140` - The _generate_pr_summary method loads the entire PR diff and sends it to the LLM for analysis. For very large diffs, this could be inefficient or exceed LLM input limits. - **[LOW]** `tools/ai-review/prompts/pr_summary.md:1` - The prompt template is well-structured and clear, but the JSON output example uses double curly braces '{{' and '}}' which may confuse some users or tools that do not expect escaped braces. - **[LOW]** `tests/test_ai_review.py:600` - The tests for PR summary generation cover prompt existence, formatting, command handling, and config validation but do not include tests for failure scenarios such as LLM call failures or empty diffs. --- **Overall Severity:** `LOW` **AI Recommendation:** Approve
Owner

📋 Pull Request Summary

This PR introduces an automated PR summary generation feature that creates comprehensive, structured summaries for pull requests, especially when descriptions are missing. It supports both automatic generation on PR open events and manual triggering via the @codebot summarize command in PR comments.

Type: Feature

Changes

Added:

  • PR summary generation functionality in PRAgent
  • New prompt template pr_summary.md for instructing the LLM on summary generation
  • Configuration options for auto-summary behavior in config.yml
  • Tests covering PR summary generation and related command handling

📝 Modified:

  • PRAgent to handle @codebot summarize command and auto-generate summaries on empty PR descriptions
  • README.md to document the new PR summary feature and command
  • CLAUDE.md to include detailed explanation and workflow of the PR summary feature
  • config.yml to add auto_summary configuration under PR agent

Files Affected

  • 📝 tools/ai-review/agents/pr_agent.py - Added PR summary generation methods, command handling for @codebot summarize, and auto-summary on PR open with empty description
  • tools/ai-review/prompts/pr_summary.md - New prompt template defining the structure and requirements for PR summary generation by the LLM
  • 📝 tools/ai-review/config.yml - Added configuration for enabling/disabling auto-summary and choosing whether to post as comment or update PR description
  • 📝 README.md - Updated documentation to include the PR summary feature and the @codebot summarize command
  • 📝 CLAUDE.md - Extended internal documentation with detailed explanation of the PR summary feature, its workflow, configuration, and usage
  • 📝 tests/test_ai_review.py - Added comprehensive tests for PR summary prompt existence, formatting, command handling, and configuration validation

Impact

🟡 Scope: Medium
Introduces a new automated feature that improves PR documentation and reviewer experience without altering existing review functionality. The feature is opt-in and configurable, minimizing risk while enhancing usability.

## 📋 Pull Request Summary This PR introduces an automated PR summary generation feature that creates comprehensive, structured summaries for pull requests, especially when descriptions are missing. It supports both automatic generation on PR open events and manual triggering via the `@codebot summarize` command in PR comments. **Type:** ✨ Feature ## Changes **✅ Added:** - PR summary generation functionality in PRAgent - New prompt template `pr_summary.md` for instructing the LLM on summary generation - Configuration options for auto-summary behavior in `config.yml` - Tests covering PR summary generation and related command handling **📝 Modified:** - PRAgent to handle `@codebot summarize` command and auto-generate summaries on empty PR descriptions - README.md to document the new PR summary feature and command - CLAUDE.md to include detailed explanation and workflow of the PR summary feature - config.yml to add auto_summary configuration under PR agent ## Files Affected - 📝 `tools/ai-review/agents/pr_agent.py` - Added PR summary generation methods, command handling for `@codebot summarize`, and auto-summary on PR open with empty description - ➕ `tools/ai-review/prompts/pr_summary.md` - New prompt template defining the structure and requirements for PR summary generation by the LLM - 📝 `tools/ai-review/config.yml` - Added configuration for enabling/disabling auto-summary and choosing whether to post as comment or update PR description - 📝 `README.md` - Updated documentation to include the PR summary feature and the `@codebot summarize` command - 📝 `CLAUDE.md` - Extended internal documentation with detailed explanation of the PR summary feature, its workflow, configuration, and usage - 📝 `tests/test_ai_review.py` - Added comprehensive tests for PR summary prompt existence, formatting, command handling, and configuration validation ## Impact 🟡 **Scope:** Medium Introduces a new automated feature that improves PR documentation and reviewer experience without altering existing review functionality. The feature is opt-in and configurable, minimizing risk while enhancing usability.
Bartender reviewed 2025-12-29 10:27:40 +00:00
Bartender left a comment
Owner

AI Code Review - Inline Comments

AI Code Review - Inline Comments
Owner

[LOW] Testing

The tests for PR summary generation cover prompt existence, formatting, command handling, and config validation but do not include tests for failure scenarios such as LLM call failures or empty diffs.

Recommendation: Add tests simulating LLM failures, empty diffs, and API errors to ensure robust error handling and user feedback.

**[LOW] Testing** The tests for PR summary generation cover prompt existence, formatting, command handling, and config validation but do not include tests for failure scenarios such as LLM call failures or empty diffs. **Recommendation:** Add tests simulating LLM failures, empty diffs, and API errors to ensure robust error handling and user feedback.
Owner

[LOW] Architecture

The method _generate_pr_summary attempts to update the PR description via the Gitea API, but the comment notes that this may not be supported and falls back to posting a comment. This fallback logic is appropriate but could be clarified or improved by explicitly checking API capabilities or documenting limitations.

Recommendation: Consider adding a capability check or a dedicated method to update PR descriptions if supported by the API, or document this limitation clearly in the code and user documentation.

**[LOW] Architecture** The method _generate_pr_summary attempts to update the PR description via the Gitea API, but the comment notes that this may not be supported and falls back to posting a comment. This fallback logic is appropriate but could be clarified or improved by explicitly checking API capabilities or documenting limitations. **Recommendation:** Consider adding a capability check or a dedicated method to update PR descriptions if supported by the API, or document this limitation clearly in the code and user documentation.
Owner

[LOW] Maintainability

The execute method handles multiple commands (@codebot summarize and review-again) in a single conditional block, which could grow as more commands are added.

Recommendation: Refactor command handling into a dispatch method or dictionary mapping commands to handlers to improve scalability and readability.

**[LOW] Maintainability** The execute method handles multiple commands (@codebot summarize and review-again) in a single conditional block, which could grow as more commands are added. **Recommendation:** Refactor command handling into a dispatch method or dictionary mapping commands to handlers to improve scalability and readability.
Owner

[LOW] Performance

The _generate_pr_summary method loads the entire PR diff and sends it to the LLM for analysis. For very large diffs, this could be inefficient or exceed LLM input limits.

Recommendation: Implement diff size checks and consider summarizing or chunking large diffs before sending to the LLM to avoid performance degradation or failures.

**[LOW] Performance** The _generate_pr_summary method loads the entire PR diff and sends it to the LLM for analysis. For very large diffs, this could be inefficient or exceed LLM input limits. **Recommendation:** Implement diff size checks and consider summarizing or chunking large diffs before sending to the LLM to avoid performance degradation or failures.
Owner

[LOW] Readability

The prompt template is well-structured and clear, but the JSON output example uses double curly braces '{{' and '}}' which may confuse some users or tools that do not expect escaped braces.

Recommendation: Add a comment or note in the prompt explaining the use of double curly braces for escaping in the template to avoid confusion.

**[LOW] Readability** The prompt template is well-structured and clear, but the JSON output example uses double curly braces '{{' and '}}' which may confuse some users or tools that do not expect escaped braces. **Recommendation:** Add a comment or note in the prompt explaining the use of double curly braces for escaping in the template to avoid confusion.
Owner

@None

Summary:
Please provide the issue title and body you would like summarized.

@None **Summary:** Please provide the issue title and body you would like summarized.
Latte merged commit 17302361e6 into dev 2025-12-29 10:30:02 +00:00
Latte deleted branch feature/pr-summary-generator 2025-12-29 10:30:02 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Hiddenden/openrabbit#20