Skip to content

Conversation

suhaibmujahid
Copy link
Member

@suhaibmujahid suhaibmujahid commented Oct 17, 2025

This PR introduces a modular structure for bugbug tools, separating code review, comment resolution, and core utilities into distinct subpackages.

bugbug/tools/
├── __init__.py
├── base.py
│
├── core/
│   ├── data_types.py         # InlineComment, ReviewRequest
│   ├── exceptions.py         # All custom exceptions
│   ├── llms.py               # LLM model integration for all providers
│   └── platforms/
│       ├── base.py           # Abstract Patch, ReviewData
│       ├── phabricator.py    # Phabricator integration (~704 lines)
│       ├── swarm.py          # Swarm integration (~84 lines)
│       └── bugzilla.py       # Bugzilla Bug class (~203 lines)
│
├── code_review/
│   ├── agent.py              # CodeReviewTool (~246 lines)
│   ├── prompts.py            # All prompt templates (~241 lines)
│   ├── langchain_tools.py    # LangGraph tools (~71 lines)
│   └── database.py           # ReviewCommentsDB, SuggestionsFeedbackDB (~175 lines)
│   └── utils.py 
│
└── comment_resolution/
    └── agent.py              # CodeGeneratorTool (~382 lines)

This commit introduces a modular structure for bugbug tools, separating code review, comment resolution, and core utilities into distinct subpackages.
@suhaibmujahid suhaibmujahid requested a review from Copilot October 20, 2025 18:18
@suhaibmujahid suhaibmujahid marked this pull request as ready for review October 20, 2025 18:18
@suhaibmujahid suhaibmujahid requested a review from marco-c October 20, 2025 18:18
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the bugbug tools codebase into a modular structure, organizing code review and comment resolution tools into distinct subpackages with shared core utilities.

  • Introduces a new modular package structure (core/, code_review/, comment_resolution/)
  • Separates platform-specific implementations (Phabricator, Swarm, Bugzilla) into dedicated modules
  • Maintains backward compatibility through re-exports in __init__.py files

Reviewed Changes

Copilot reviewed 18 out of 21 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
bugbug/tools/core/utils/formatting.py New module containing diff processing and formatting utilities previously in code_review.py
bugbug/tools/core/platforms/swarm.py Extracted Swarm platform implementation
bugbug/tools/core/platforms/phabricator.py Extracted Phabricator platform implementation with duplicate code
bugbug/tools/core/platforms/bugzilla.py Extracted Bugzilla integration with duplicate code
bugbug/tools/core/platforms/base.py Base classes for platform implementations
bugbug/tools/core/data_types.py Core data type definitions
bugbug/tools/core/exceptions.py Custom exception definitions
bugbug/tools/comment_resolver.py Updated with deprecation warning
bugbug/tools/comment_resolution/agent.py Extracted comment resolution agent
bugbug/tools/code_review/prompts.py Extracted prompt templates
bugbug/tools/code_review/langchain_tools.py LangGraph tools for code review
bugbug/tools/code_review/database.py Vector database implementations
bugbug/tools/code_review/agent.py Main code review agent
bugbug/tools/code_review/init.py Backward-compatible exports for code review
bugbug/tools/code_review.py Removed monolithic file (now modular)
bugbug/tools/init.py Top-level backward-compatible exports

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@marco-c
Copy link
Collaborator

marco-c commented Oct 21, 2025

langchain_tools.py # LangGraph tools (~71 lines)

We might want to have some in the top directory, shared across because they are useful outside code review, and some under code review.

marco-c
marco-c previously approved these changes Oct 21, 2025
@suhaibmujahid suhaibmujahid merged commit c26fd11 into mozilla:master Oct 21, 2025
6 checks passed
@suhaibmujahid suhaibmujahid deleted the refactor branch October 21, 2025 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants