refactor: Optimize tool guidelines and disable tools by default

This commit is contained in:
Petr Mironychev
2025-10-26 21:04:37 +01:00
parent 6cb0b14b18
commit dfd9979450
7 changed files with 43 additions and 87 deletions

View File

@ -56,50 +56,28 @@ QString EditFileTool::stringName() const
QString EditFileTool::description() const
{
return "Edit a project file with two distinct modes of operation. "
"IMPORTANT: All text fields must contain COMPLETE LINES with trailing newlines (\\n). "
"If you forget to add \\n, it will be added automatically.\n"
return "Edit project files with two modes: REPLACE (find and replace text) or INSERT_AFTER "
"(insert after specific line). All text parameters must be complete lines with trailing "
"newlines (\\n auto-added if missing).\n"
"\n"
"TWO MODES OF OPERATION:\n"
"REPLACE MODE:\n"
"- Finds search_text and replaces with new_text\n"
"- Context verification: line_before/line_after searched NEAR search_text (~500 chars), "
"not necessarily adjacent\n"
"- Both context lines: most precise matching\n"
"- One context line: directional search (before/after)\n"
"- No context: first occurrence\n"
"\n"
"1. REPLACE MODE (mode='replace'):\n"
" - Finds search_text in the file and replaces it with new_text\n"
" - REQUIRED: search_text (the text to find and replace)\n"
" - OPTIONAL: line_before and/or line_after for context verification\n"
" - Context verification strategy:\n"
" * line_before/line_after are searched NEAR search_text (within ~500 chars)\n"
" * They do NOT need to be immediately adjacent to search_text\n"
" * Both provided: BOTH must be found near search_text (most precise)\n"
" * Only line_before: must be found BEFORE search_text\n"
" * Only line_after: must be found AFTER search_text\n"
" * Neither: accepts first occurrence (use when search_text is unique)\n"
" - Use this to replace existing content\n"
"INSERT_AFTER MODE:\n"
"- Inserts new_text RIGHT AFTER line_before\n"
"- Empty line_before: inserts at file start (useful for empty files)\n"
"- line_after: must IMMEDIATELY follow line_before for verification\n"
"- search_text is ignored\n"
"\n"
"2. INSERT_AFTER MODE (mode='insert_after'):\n"
" - Inserts new_text after the line specified in line_before\n"
" - If line_before is empty, inserts at the beginning of the file (useful for empty files)\n"
" - OPTIONAL: line_before (the line to insert after; empty = insert at start)\n"
" - OPTIONAL: line_after (must IMMEDIATELY follow line_before for verification)\n"
" - search_text is IGNORED\n"
" - Use this to insert content after a specific line or at the start of file\n"
" - Note: In this mode, new_text is inserted RIGHT AFTER line_before\n"
"\n"
"BEST PRACTICES for multiple edits to the same file:\n"
"- Use INSERT_AFTER mode for sequential additions (each edit uses previous addition as line_before)\n"
"- Provide stable context lines that won't be modified by current or subsequent edits\n"
"- For empty files: use INSERT_AFTER with empty line_before\n"
"- Example: When adding multiple class properties:\n"
" * First edit: INSERT_AFTER with class declaration as line_before\n"
" * Second edit: INSERT_AFTER with first property as line_before\n"
" * Third edit: INSERT_AFTER with second property as line_before\n"
"\n"
"Parameters:\n"
"- mode: 'replace' or 'insert_after'\n"
"- filepath: absolute or relative file path to edit\n"
"- new_text: complete line(s) to insert/replace (with \\n)\n"
"- search_text: (replace mode only) complete line(s) to find and replace (with \\n)\n"
"- line_before: complete line for context (with \\n), usage depends on mode\n"
"- line_after: complete line for context (with \\n), usage depends on mode";
"BEST PRACTICES:\n"
"- Sequential additions: use INSERT_AFTER with previous addition as line_before\n"
"- Provide stable context lines that won't change\n"
"- Make atomic edits (one comprehensive change vs multiple small ones)";
}
QJsonObject EditFileTool::getDefinition(LLMCore::ToolSchemaFormat format) const

View File

@ -51,11 +51,10 @@ QString FindSymbolTool::stringName() const
QString FindSymbolTool::description() const
{
return "Find C++ symbols (classes, functions, enums, variables, typedefs, namespaces) in the "
"project. "
"Returns file paths and line numbers where symbols are defined. "
"Use read_project_file_by_path to read the actual code. "
"Supports exact match, wildcard patterns, and regular expressions.";
return "Find C++ symbols (classes, functions, enums, variables, typedefs, namespaces) in the project. "
"Returns file paths and line numbers. "
"Supports exact match, wildcards (* patterns), and regex. "
"Use read_files_by_path to read the actual code after finding symbols.";
}
QJsonObject FindSymbolTool::getDefinition(LLMCore::ToolSchemaFormat format) const

View File

@ -139,8 +139,8 @@ QString GetIssuesListTool::stringName() const
QString GetIssuesListTool::description() const
{
return "Get compilation errors, warnings, and diagnostics from Qt Creator's Issues panel. "
"Filter by severity ('error', 'warning', or 'all'). "
"Returns issue descriptions with file paths and line numbers.";
"Returns issue descriptions with file paths and line numbers. "
"Optional severity filter: 'error', 'warning', or 'all' (default).";
}
QJsonObject GetIssuesListTool::getDefinition(LLMCore::ToolSchemaFormat format) const

View File

@ -54,9 +54,9 @@ QString ReadFilesByPathTool::stringName() const
QString ReadFilesByPathTool::description() const
{
return "Read content of one or multiple project files by absolute path(s). "
"Use 'filepath' for single file or 'filepaths' for multiple files (e.g., .h and .cpp). "
"Files must exist, be within project scope, and not excluded by .qodeassistignore.";
return "Read content of project file(s) by absolute path. "
"Use 'filepath' for single file or 'filepaths' array for multiple files (e.g., .h and .cpp). "
"Files must exist and not be excluded by .qodeassistignore.";
}
QJsonObject ReadFilesByPathTool::getDefinition(LLMCore::ToolSchemaFormat format) const

View File

@ -51,10 +51,9 @@ QString SearchInProjectTool::stringName() const
QString SearchInProjectTool::description() const
{
return "Search for text or patterns across all project files. "
return "Search for text or regex patterns across project files. "
"Returns matching lines with file paths, line numbers, and context. "
"Supports plain text, regex, case-sensitive/insensitive search, whole word matching, "
"and file pattern filtering.";
"Supports case-sensitive/insensitive, whole word matching, and file pattern filtering (*.cpp, *.h).";
}
QJsonObject SearchInProjectTool::getDefinition(LLMCore::ToolSchemaFormat format) const