Allow loading external content during review#6086
Draft
padenot wants to merge 7 commits into
Draft
Conversation
8d9321b to
8a640ef
Compare
Improves editability by loading them at import time from prompts/system.md and prompts/first_message.md instead of keeping them as inline Python strings.
Step 1 now says to read the commit message. Step 3 tool guidance is
updated with a {context_tools} placeholder and Mozilla-specific tools
(Phabricator, Bugzilla, fx-docs). Step 5 drops several "What NOT to
Include" items that were overly restrictive.
Adds the moz.tools MCP server to the Anthropic client so the agent can call mozilla__ tools during review. URL is overridable via BUGBUG_MOZ_MCP_URL.
LocalPatch wraps a raw unified diff string as a first-class Patch so it can flow through the review pipeline without a Phabricator backing. It accepts an optional commit_message and parses from it: the patch title (first line), description (remaining lines), bug ID (Bug NNN), and Differential Revision URL, and date if present in the format-patch header. On the MCP server side, patch_review now accepts optional diff= and commit_message= parameters alongside patch_url=, and a new patch_review_tool exposes the same logic as an @mcp.tool(). A shared _patch_review_impl handles both cases, using a lighter CodeReviewTool instance (no DB, no suggestion filtering) for local diffs. LOCAL_SYSTEM_PROMPT_TEMPLATE uses searchfox-cli and local agent tools instead of the agent-specific expand_context and searchfox tools.
ExternalContent (in data_types.py) fetches any URL and injects its content as context for the review. Frontmatter is stripped before injection. Fetches are retried on transient errors via tenacity and cached per-instance. skill_rules.py implements the rule engine: it fetches skill-rules.toml from the reviewed repository (with retry and a 5-minute in-process TTL cache), matches changed files against rules (by extension, path glob, or Bugzilla component), deduplicates actions across rules, and returns (name, content) pairs ready for injection. Changed files are extracted using unidiff (consistent with the rest of the codebase). Supports load_file (from the same repo or another GitHub repo) and fetch_revision (Phabricator or GitHub commit diff) action types. Extra rules can be merged at call time for testing before landing. Logging added throughout for auditability.
Wires load_external_content_for_diff into CodeReviewTool.run(): fetches skill-rules.toml when BUGBUG_REVIEW_RULES_URL is set (opt-in for now, until we're ready to generalize), matches rules against the diff, and injects matched content as <external_context> blocks in the review prompt. generate_initial_prompt and generate_review_comments gain an external_context parameter. patch_review and patch_review_tool on the MCP server accept extra_rules_toml and content_overrides so callers can test rule and content changes before landing.
8a640ef to
0048d1b
Compare
Documents skill-rules.toml format, rule matching semantics, action types (load_file, fetch_revision), and the testing workflow using extra_rules_toml and content_overrides. Includes a reference table of key files and a gotchas section.
0048d1b to
fac1b71
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.