diff --git a/ChatView/ClientInterface.cpp b/ChatView/ClientInterface.cpp index 72ff35f..c2a075e 100644 --- a/ChatView/ClientInterface.cpp +++ b/ChatView/ClientInterface.cpp @@ -83,45 +83,43 @@ void ClientInterface::sendMessage( LLMCore::ContextData context; - // Build system prompt with tools usage guidelines if (chatAssistantSettings.useSystemPrompt()) { QString systemPrompt = chatAssistantSettings.systemPrompt(); - // Add tools usage guidelines only if tools are enabled if (Settings::generalSettings().useTools()) { - systemPrompt += "\n\n# Tool Usage Guidelines\n\n" - "You have access to powerful tools for project analysis and modification. " - "Use them proactively to provide accurate, context-aware assistance.\n\n" - "## Philosophy\n\n" - "- **Be Proactive**: Use tools when they help answer questions - don't ask permission first\n" - "- **Chain Tools**: Combine tools logically to gather complete context\n" - "- **Verify First**: Always read and understand code before proposing changes\n" - "- **Concrete Solutions**: Analyze and propose specific solutions, not just suggestions\n\n" - "## Discovery & Analysis\n\n" - "- Start with `list_project_files` or `find_file` to understand project structure\n" - "- Use `find_cpp_symbol` to locate classes, functions, enums, variables, namespaces\n" - "- Use `search_in_project` for text/pattern searches across files\n\n" - "## Reading Files\n\n" - "- `read_visible_files` - currently open editor tabs (no parameters)\n" - "- `read_project_file_by_path` - specific file by absolute path\n" - "- Always read files before proposing edits to understand context\n\n" - "## Making Changes\n\n" - "- `edit_project_file` - propose file modifications (requires user approval)\n" - "- Choose appropriate edit mode: replace, insert_before, insert_after, append\n" - "- For complex changes, use multiple sequential edits rather than one large edit\n\n" - "## Debugging\n\n" - "- `get_issues_list` - see compiler errors, warnings, and diagnostics\n" - "- Filter by severity: 'error', 'warning', or 'all'\n" - "- Use this when debugging to see actual problems\n\n" - "## Common Workflows\n\n" - "**Understanding codebase:**\n" - "list_project_files → find_cpp_symbol → read_project_file_by_path\n\n" - "**Fixing bugs:**\n" - "get_issues_list → read_project_file_by_path → edit_project_file\n\n" - "**Refactoring:**\n" - "search_in_project → read_project_file_by_path (multiple) → edit_project_file (multiple)\n\n" - "**Adding features:**\n" - "find_cpp_symbol → read_project_file_by_path → edit_project_file\n"; + systemPrompt + += "\n\n# Smart Tool Combinations\n\n" + "**Understanding code structure:**\n" + "find_cpp_symbol → read_project_file_by_path → find_cpp_symbol (for related " + "symbols)\n\n" + "**Finding usages and references:**\n" + "find_cpp_symbol (declaration) → search_in_project (with precise name) → read " + "files\n\n" + "**Fixing compilation errors:**\n" + "get_issues_list → find_cpp_symbol (error location) → read_project_file_by_path " + "→ edit_project_file\n\n" + "**Complex refactoring:**\n" + "find_cpp_symbol (all targets) → read files → search_in_project (verify " + "coverage) → edit files\n\n" + "**Adding features to existing code:**\n" + "find_cpp_symbol (target class/namespace) → read_project_file_by_path → " + "edit_project_file\n\n" + "# Best Practices\n\n" + "- **Prefer semantic over text search**: Use find_cpp_symbol before " + "search_in_project\n" + "- **Make atomic edits**: One comprehensive change instead of multiple small " + "ones\n" + "- **Read once, understand fully**: Avoid re-reading the same file multiple " + "times\n" + "- **Start with visible context**: Use read_visible_files when user references " + "current work\n" + "- **Verify before editing**: Always read and understand code before proposing " + "changes\n" + "- **Use file patterns**: Narrow search_in_project with *.cpp, *.h patterns\n" + "- **Chain intelligently**: Each tool result should inform the next tool " + "choice\n" + "- **Fix related issues together**: When fixing errors, address all related " + "problems in one edit\n"; } auto project = LLMCore::RulesLoader::getActiveProject(); @@ -142,7 +140,6 @@ void ClientInterface::sendMessage( QVector messages; for (const auto &msg : m_chatModel->getChatHistory()) { - // Skip Tool and FileEdit messages - they are UI-only and should not be in API history if (msg.role == ChatModel::ChatRole::Tool || msg.role == ChatModel::ChatRole::FileEdit) { continue; }