refactor: rename review tools for clarity and consistency

- Renamed `review_code` tool to `codereview` for better naming convention
- Renamed `review_changes` tool to `precommit` to better reflect its purpose
- Updated all tool descriptions to remove "Triggers:" sections and improve clarity
- Updated all imports and references throughout the codebase
- Renamed test files to match new tool names
- Updated server.py tool registrations
- All existing functionality preserved with improved naming

This refactoring improves code organization and makes tool purposes clearer.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Fahad
2025-06-10 12:30:06 +04:00
parent 67f18ef3c9
commit 5f8ed3aae8
18 changed files with 119 additions and 122 deletions

View File

@@ -4,16 +4,16 @@ Tool implementations for Gemini MCP Server
from .analyze import AnalyzeTool
from .chat import ChatTool
from .codereview import CodeReviewTool
from .debug import DebugIssueTool
from .review_changes import ReviewChanges
from .review_code import ReviewCodeTool
from .precommit import Precommit
from .think_deeper import ThinkDeeperTool
__all__ = [
"ThinkDeeperTool",
"ReviewCodeTool",
"CodeReviewTool",
"DebugIssueTool",
"AnalyzeTool",
"ChatTool",
"ReviewChanges",
"Precommit",
]

View File

@@ -37,8 +37,7 @@ class AnalyzeTool(BaseTool):
return (
"ANALYZE FILES & CODE - General-purpose analysis for understanding code. "
"Supports both individual files and entire directories. "
"Use this for examining files, understanding architecture, or investigating specific aspects. "
"Triggers: 'analyze these files', 'examine this code', 'understand this'. "
"Use this when you need to analyze files, examine code, or understand specific aspects of a codebase. "
"Perfect for: codebase exploration, dependency analysis, pattern detection. "
"Always uses file paths for clean terminal output."
)

View File

@@ -40,8 +40,8 @@ class ChatTool(BaseTool):
"Perfect for: bouncing ideas during your own analysis, getting second opinions on your plans, "
"collaborative brainstorming, validating your checklists and approaches, exploring alternatives. "
"Also great for: explanations, comparisons, general development questions. "
"Triggers: 'ask gemini', 'brainstorm with gemini', 'get gemini's opinion', 'discuss with gemini', "
"'share my thinking with gemini', 'explain', 'what is', 'how do I'."
"Use this when you want to ask Gemini questions, brainstorm ideas, get opinions, discuss topics, "
"share your thinking, or need explanations about concepts and approaches."
)
def get_input_schema(self) -> dict[str, Any]:

View File

@@ -20,14 +20,14 @@ from mcp.types import TextContent
from pydantic import Field
from config import TEMPERATURE_ANALYTICAL
from prompts import REVIEW_CODE_PROMPT
from prompts import CODEREVIEW_PROMPT
from utils import read_files
from .base import BaseTool, ToolRequest
from .models import ToolOutput
class ReviewCodeRequest(ToolRequest):
class CodeReviewRequest(ToolRequest):
"""
Request model for the code review tool.
@@ -53,7 +53,7 @@ class ReviewCodeRequest(ToolRequest):
)
class ReviewCodeTool(BaseTool):
class CodeReviewTool(BaseTool):
"""
Professional code review tool implementation.
@@ -63,14 +63,13 @@ class ReviewCodeTool(BaseTool):
"""
def get_name(self) -> str:
return "review_code"
return "codereview"
def get_description(self) -> str:
return (
"PROFESSIONAL CODE REVIEW - Comprehensive analysis for bugs, security, and quality. "
"Supports both individual files and entire directories/projects. "
"Use this for thorough code review with actionable feedback. "
"Triggers: 'review this code', 'check for issues', 'find bugs', 'security audit'. "
"Use this when you need to review code, check for issues, find bugs, or perform security audits. "
"I'll identify issues by severity (Critical→High→Medium→Low) with specific fixes. "
"Supports focused reviews: security, performance, or quick checks. "
"Choose thinking_mode based on review scope: 'low' for small code snippets, "
@@ -132,13 +131,13 @@ class ReviewCodeTool(BaseTool):
}
def get_system_prompt(self) -> str:
return REVIEW_CODE_PROMPT
return CODEREVIEW_PROMPT
def get_default_temperature(self) -> float:
return TEMPERATURE_ANALYTICAL
def get_request_model(self):
return ReviewCodeRequest
return CodeReviewRequest
async def execute(self, arguments: dict[str, Any]) -> list[TextContent]:
"""Override execute to check focus_on size before processing"""
@@ -155,7 +154,7 @@ class ReviewCodeTool(BaseTool):
# Continue with normal execution
return await super().execute(arguments)
async def prepare_prompt(self, request: ReviewCodeRequest) -> str:
async def prepare_prompt(self, request: CodeReviewRequest) -> str:
"""
Prepare the code review prompt with customized instructions.
@@ -239,7 +238,7 @@ Please provide a code review aligned with the user's context and expectations, f
return full_prompt
def format_response(self, response: str, request: ReviewCodeRequest) -> str:
def format_response(self, response: str, request: CodeReviewRequest) -> str:
"""
Format the review response with appropriate headers.

View File

@@ -37,8 +37,8 @@ class DebugIssueTool(BaseTool):
def get_description(self) -> str:
return (
"DEBUG & ROOT CAUSE ANALYSIS - Expert debugging for complex issues with 1M token capacity. "
"Use this when you need help tracking down bugs or understanding errors. "
"Triggers: 'debug this', 'why is this failing', 'root cause', 'trace error', 'diagnose issue'. "
"Use this when you need to debug code, find out why something is failing, identify root causes, "
"trace errors, or diagnose issues. "
"IMPORTANT: Share diagnostic files liberally! Gemini can handle up to 1M tokens, so include: "
"large log files, full stack traces, memory dumps, diagnostic outputs, multiple related files, "
"entire modules, test results, configuration files - anything that might help debug the issue. "

View File

@@ -1,5 +1,5 @@
"""
Tool for reviewing pending git changes across multiple repositories.
Tool for pre-commit validation of git changes across multiple repositories.
"""
import os
@@ -9,7 +9,7 @@ from mcp.types import TextContent
from pydantic import Field
from config import MAX_CONTEXT_TOKENS
from prompts.tool_prompts import REVIEW_CHANGES_PROMPT
from prompts.tool_prompts import PRECOMMIT_PROMPT
from utils.file_utils import read_files, translate_file_paths, translate_path_for_environment
from utils.git_utils import find_git_repositories, get_git_status, run_git_command
from utils.token_utils import estimate_tokens
@@ -18,8 +18,8 @@ from .base import BaseTool, ToolRequest
from .models import ToolOutput
class ReviewChangesRequest(ToolRequest):
"""Request model for review_changes tool"""
class PrecommitRequest(ToolRequest):
"""Request model for precommit tool"""
path: str = Field(
...,
@@ -71,21 +71,21 @@ class ReviewChangesRequest(ToolRequest):
)
class ReviewChanges(BaseTool):
"""Tool for reviewing git changes across multiple repositories."""
class Precommit(BaseTool):
"""Tool for pre-commit validation of git changes across multiple repositories."""
def get_name(self) -> str:
return "review_changes"
return "precommit"
def get_description(self) -> str:
return (
"REVIEW PENDING GIT CHANGES BEFORE COMMITTING - ALWAYS use this tool before creating any git commit! "
"PRECOMMIT VALIDATION FOR GIT CHANGES - ALWAYS use this tool before creating any git commit! "
"Comprehensive pre-commit validation that catches bugs, security issues, incomplete implementations, "
"and ensures changes match the original requirements. Searches all git repositories recursively and "
"provides deep analysis of staged/unstaged changes. Essential for code quality and preventing bugs. "
"Triggers: 'before commit', 'review changes', 'check my changes', 'validate changes', 'pre-commit review', "
"'about to commit', 'ready to commit'. Claude should proactively suggest using this tool whenever "
"the user mentions committing or when changes are complete. "
"Use this before committing, when reviewing changes, checking your changes, validating changes, "
"or when you're about to commit or ready to commit. Claude should proactively suggest using this tool "
"whenever the user mentions committing or when changes are complete. "
"Choose thinking_mode based on changeset size: 'low' for small focused changes, "
"'medium' for standard commits (default), 'high' for large feature branches or complex refactoring, "
"'max' for critical releases or when reviewing extensive changes across multiple systems."
@@ -103,10 +103,10 @@ class ReviewChanges(BaseTool):
return schema
def get_system_prompt(self) -> str:
return REVIEW_CHANGES_PROMPT
return PRECOMMIT_PROMPT
def get_request_model(self):
return ReviewChangesRequest
return PrecommitRequest
def get_default_temperature(self) -> float:
"""Use analytical temperature for code review."""
@@ -129,7 +129,7 @@ class ReviewChanges(BaseTool):
# Continue with normal execution
return await super().execute(arguments)
async def prepare_prompt(self, request: ReviewChangesRequest) -> str:
async def prepare_prompt(self, request: PrecommitRequest) -> str:
"""Prepare the prompt with git diff information."""
# Check for prompt.txt in files
prompt_content, updated_files = self.handle_prompt_file(request.files)
@@ -409,6 +409,6 @@ class ReviewChanges(BaseTool):
return full_prompt
def format_response(self, response: str, request: ReviewChangesRequest) -> str:
def format_response(self, response: str, request: PrecommitRequest) -> str:
"""Format the response with commit guidance"""
return f"{response}\n\n---\n\n**Commit Status:** If no critical issues found, changes are ready for commit. Otherwise, address issues first and re-run review. Check with user before proceeding with any commit."

View File

@@ -39,9 +39,8 @@ class ThinkDeeperTool(BaseTool):
def get_description(self) -> str:
return (
"EXTENDED THINKING & REASONING - Your deep thinking partner for complex problems. "
"Use this when you need to extend your analysis, explore alternatives, or validate approaches. "
"Use this when you need to think deeper about a problem, extend your analysis, explore alternatives, or validate approaches. "
"Perfect for: architecture decisions, complex bugs, performance challenges, security analysis. "
"Triggers: 'think deeper', 'ultrathink', 'extend my analysis', 'explore alternatives'. "
"I'll challenge assumptions, find edge cases, and provide alternative solutions. "
"IMPORTANT: Choose the appropriate thinking_mode based on task complexity - "
"'low' for quick analysis, 'medium' for standard problems, 'high' for complex issues (default), "