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