Vastly improved debug tool and related instructions

Accompanying simulation test
Cleanup - A single source of truth for parameter descriptions
This commit is contained in:
Fahad
2025-06-17 16:23:26 +04:00
parent 9bf2a2a51c
commit 044a8621a3
12 changed files with 829 additions and 238 deletions

View File

@@ -23,6 +23,28 @@ from systemprompts import CODEREVIEW_PROMPT
from .base import BaseTool, ToolRequest
# Field descriptions to avoid duplication between Pydantic and JSON schema
CODEREVIEW_FIELD_DESCRIPTIONS = {
"files": "Code files or directories to review (must be absolute paths)",
"prompt": (
"User's summary of what the code does, expected behavior, constraints, and review objectives. "
"IMPORTANT: Before using this tool, Claude should first perform its own preliminary review - "
"examining the code structure, identifying potential issues, understanding the business logic, "
"and noting areas of concern. Include Claude's initial observations about code quality, potential "
"bugs, architectural patterns, and specific areas that need deeper scrutiny. This dual-perspective "
"approach (Claude's analysis + external model's review) provides more comprehensive feedback and "
"catches issues that either reviewer might miss alone."
),
"images": (
"Optional images of architecture diagrams, UI mockups, design documents, or visual references "
"for code review context"
),
"review_type": "Type of review to perform",
"focus_on": "Specific aspects to focus on, or additional context that would help understand areas of concern",
"standards": "Coding standards to enforce",
"severity_filter": "Minimum severity level to report",
}
class CodeReviewRequest(ToolRequest):
"""
@@ -33,39 +55,13 @@ class CodeReviewRequest(ToolRequest):
review focus and standards.
"""
files: list[str] = Field(
...,
description="Code files or directories to review (must be absolute paths)",
)
prompt: str = Field(
...,
description=(
"User's summary of what the code does, expected behavior, constraints, and review objectives. "
"IMPORTANT: Before using this tool, Claude should first perform its own preliminary review - "
"examining the code structure, identifying potential issues, understanding the business logic, "
"and noting areas of concern. Include Claude's initial observations about code quality, potential "
"bugs, architectural patterns, and specific areas that need deeper scrutiny. This dual-perspective "
"approach (Claude's analysis + external model's review) provides more comprehensive feedback and "
"catches issues that either reviewer might miss alone."
),
)
images: Optional[list[str]] = Field(
None,
description=(
"Optional images of architecture diagrams, UI mockups, design documents, or visual references "
"for code review context"
),
)
review_type: str = Field("full", description="Type of review: full|security|performance|quick")
focus_on: Optional[str] = Field(
None,
description=("Specific aspects to focus on, or additional context that would help understand areas of concern"),
)
standards: Optional[str] = Field(None, description="Coding standards or guidelines to enforce")
severity_filter: str = Field(
"all",
description="Minimum severity to report: critical|high|medium|low|all",
)
files: list[str] = Field(..., description=CODEREVIEW_FIELD_DESCRIPTIONS["files"])
prompt: str = Field(..., description=CODEREVIEW_FIELD_DESCRIPTIONS["prompt"])
images: Optional[list[str]] = Field(None, description=CODEREVIEW_FIELD_DESCRIPTIONS["images"])
review_type: str = Field("full", description=CODEREVIEW_FIELD_DESCRIPTIONS["review_type"])
focus_on: Optional[str] = Field(None, description=CODEREVIEW_FIELD_DESCRIPTIONS["focus_on"])
standards: Optional[str] = Field(None, description=CODEREVIEW_FIELD_DESCRIPTIONS["standards"])
severity_filter: str = Field("all", description=CODEREVIEW_FIELD_DESCRIPTIONS["severity_filter"])
class CodeReviewTool(BaseTool):
@@ -103,52 +99,37 @@ class CodeReviewTool(BaseTool):
"files": {
"type": "array",
"items": {"type": "string"},
"description": "Code files or directories to review (must be absolute paths)",
"description": CODEREVIEW_FIELD_DESCRIPTIONS["files"],
},
"model": self.get_model_field_schema(),
"prompt": {
"type": "string",
"description": (
"User's summary of what the code does, expected behavior, constraints, and review "
"objectives. IMPORTANT: Before using this tool, Claude should first perform its own "
"preliminary review - examining the code structure, identifying potential issues, "
"understanding the business logic, and noting areas of concern. Include Claude's initial "
"observations about code quality, potential bugs, architectural patterns, and specific "
"areas that need deeper scrutiny. This dual-perspective approach (Claude's analysis + "
"external model's review) provides more comprehensive feedback and catches issues that "
"either reviewer might miss alone."
),
"description": CODEREVIEW_FIELD_DESCRIPTIONS["prompt"],
},
"images": {
"type": "array",
"items": {"type": "string"},
"description": (
"Optional images of architecture diagrams, UI mockups, design documents, or visual "
"references for code review context"
),
"description": CODEREVIEW_FIELD_DESCRIPTIONS["images"],
},
"review_type": {
"type": "string",
"enum": ["full", "security", "performance", "quick"],
"default": "full",
"description": "Type of review to perform",
"description": CODEREVIEW_FIELD_DESCRIPTIONS["review_type"],
},
"focus_on": {
"type": "string",
"description": (
"Specific aspects to focus on, or additional context that would help understand "
"areas of concern"
),
"description": CODEREVIEW_FIELD_DESCRIPTIONS["focus_on"],
},
"standards": {
"type": "string",
"description": "Coding standards to enforce",
"description": CODEREVIEW_FIELD_DESCRIPTIONS["standards"],
},
"severity_filter": {
"type": "string",
"enum": ["critical", "high", "medium", "low", "all"],
"default": "all",
"description": "Minimum severity level to report",
"description": CODEREVIEW_FIELD_DESCRIPTIONS["severity_filter"],
},
"temperature": {
"type": "number",