feat: refactored and tweaked model descriptions / schema to use fewer tokens at launch (average reduction per field description: 60-80%) without sacrificing tool effectiveness

Disabled secondary tools by default (for new installations), updated README.md with instructions on how to enable these in .env
run-server.sh now displays disabled / enabled tools (when DISABLED_TOOLS is set)
This commit is contained in:
Fahad
2025-08-22 09:23:59 +04:00
parent 6921616db3
commit 4b202f5d1d
31 changed files with 409 additions and 609 deletions

View File

@@ -35,18 +35,9 @@ logger = logging.getLogger(__name__)
# Tool-specific field descriptions for refactor tool
REFACTOR_FIELD_DESCRIPTIONS = {
"step": (
"Describe what you're currently investigating for refactoring by thinking deeply about the code structure, "
"patterns, and potential improvements. In step 1, clearly state your refactoring investigation plan and begin "
"forming a systematic approach after thinking carefully about what needs to be analyzed. CRITICAL: Remember to "
"thoroughly examine code quality, performance implications, maintainability concerns, and architectural patterns. "
"Consider not only obvious code smells and issues but also opportunities for decomposition, modernization, "
"organization improvements, and ways to reduce complexity while maintaining functionality. Map out the codebase "
"structure, understand the business logic, and identify areas requiring refactoring. In all later steps, continue "
"exploring with precision: trace dependencies, verify assumptions, and adapt your understanding as you uncover "
"more refactoring opportunities."
"IMPORTANT: When referring to code, use the relevant_files parameter to pass relevant files and only use the prompt to refer to "
"function / method names or very small code snippets if absolutely necessary to explain the issue. Do NOT "
"pass large code snippets in the prompt as this is exclusively reserved for descriptive text only. "
"The refactoring plan. Step 1: State strategy. Later steps: Report findings. "
"CRITICAL: Examine code for smells, and opportunities for decomposition, modernization, and organization. "
"Use 'relevant_files' for code. FORBIDDEN: Large code snippets."
),
"step_number": (
"The index of the current step in the refactoring investigation sequence, beginning at 1. Each step should "
@@ -61,51 +52,33 @@ REFACTOR_FIELD_DESCRIPTIONS = {
"refactoring analysis is complete and ready for expert validation."
),
"findings": (
"Summarize everything discovered in this step about refactoring opportunities in the code. Include analysis of "
"code smells, decomposition opportunities, modernization possibilities, organization improvements, architectural "
"patterns, design decisions, potential performance optimizations, and maintainability enhancements. Be specific "
"and avoid vague language—document what you now know about the code and how it could be improved. IMPORTANT: "
"Document both positive aspects (good patterns, well-designed components) and improvement opportunities "
"(code smells, overly complex functions, outdated patterns, organization issues). In later steps, confirm or "
"update past findings with additional evidence."
"Summary of discoveries from this step, including code smells and opportunities for decomposition, modernization, or organization. "
"Document both strengths and weaknesses. In later steps, confirm or update past findings."
),
"files_checked": (
"List all files (as absolute paths, do not clip or shrink file names) examined during the refactoring "
"investigation so far. Include even files ruled out or found to need no refactoring, as this tracks your "
"exploration path."
"List all files examined (absolute paths). Include even ruled-out files to track exploration path."
),
"relevant_files": (
"Subset of files_checked (as full absolute paths) that contain code requiring refactoring or are directly "
"relevant to the refactoring opportunities identified. Only list those that are directly tied to specific "
"refactoring opportunities, code smells, decomposition needs, or improvement areas. This could include files "
"with code smells, overly large functions/classes, outdated patterns, or organization issues."
"Subset of files_checked with code requiring refactoring (absolute paths). Include files with "
"code smells, decomposition needs, or improvement opportunities."
),
"relevant_context": (
"List methods, functions, classes, or modules that are central to the refactoring opportunities identified, "
"in the format 'ClassName.methodName', 'functionName', or 'module.ClassName'. Prioritize those that contain "
"code smells, need decomposition, could benefit from modernization, or require organization improvements."
"List methods/functions central to refactoring opportunities, in 'ClassName.methodName' or 'functionName' format. "
"Prioritize those with code smells or needing improvement."
),
"issues_found": (
"List of refactoring opportunities identified during the investigation. Each opportunity should be a dictionary "
"with 'severity' (critical, high, medium, low), 'type' (codesmells, decompose, modernize, organization), and "
"'description' fields. Include code smells, decomposition opportunities, modernization possibilities, "
"organization improvements, performance optimizations, maintainability enhancements, etc."
"Refactoring opportunities as dictionaries with 'severity' (critical/high/medium/low), "
"'type' (codesmells/decompose/modernize/organization), and 'description'. "
"Include all improvement opportunities found."
),
"confidence": (
"Indicate your current confidence in the refactoring analysis completeness. Use: 'exploring' (starting "
"analysis), 'incomplete' (just started or significant work remaining), 'partial' (some refactoring "
"opportunities identified but more analysis needed), 'complete' (comprehensive refactoring analysis "
"finished with all major opportunities identified and the CLI agent can handle 100% confidently without help). "
"Use 'complete' ONLY when you have fully analyzed all code, identified all significant refactoring "
"opportunities, and can provide comprehensive recommendations without expert assistance. When files are "
"too large to read fully or analysis is uncertain, use 'partial'. Using 'complete' prevents expert "
"analysis to save time and money. Do NOT set confidence to 'certain' if the user has strongly requested that "
"external validation MUST be performed."
),
"backtrack_from_step": (
"If an earlier finding or assessment needs to be revised or discarded, specify the step number from which to "
"start over. Use this to acknowledge investigative dead ends and correct the course."
"Your confidence in refactoring analysis: exploring (starting), incomplete (significant work remaining), "
"partial (some opportunities found, more analysis needed), complete (comprehensive analysis finished, "
"all major opportunities identified). "
"WARNING: Use 'complete' ONLY when fully analyzed and can provide recommendations without expert help. "
"'complete' PREVENTS expert validation. Use 'partial' for large files or uncertain analysis."
),
"backtrack_from_step": ("If an earlier finding needs revision, specify the step number to backtrack from."),
"images": (
"Optional list of absolute paths to architecture diagrams, UI mockups, design documents, or visual references "
"that help with refactoring context. Only include if they materially assist understanding or assessment."