From 949dad4fd26f68934d382d32e5a76969799f8b60 Mon Sep 17 00:00:00 2001 From: Petr Mironychev <9195189+Palm1r@users.noreply.github.com> Date: Mon, 8 Dec 2025 11:09:21 +0100 Subject: [PATCH] feat: Update built in roles and docs --- README.md | 2 + docs/agent-roles.md | 9 ++- docs/chat-summarization.md | 115 +++++++++++++++++++++++++++++++++++++ settings/AgentRole.cpp | 99 +++++++++++++++++++++++++------ settings/AgentRole.hpp | 1 + 5 files changed, 207 insertions(+), 19 deletions(-) create mode 100644 docs/chat-summarization.md diff --git a/README.md b/README.md index 9c79797..f305a95 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,7 @@ For optimal coding assistance, we recommend using these top-tier models: ### Additional Configuration - **[Agent Roles](docs/agent-roles.md)** - Create AI personas with specialized system prompts +- **[Chat Summarization](docs/chat-summarization.md)** - Compress conversations to save context tokens - **[Project Rules](docs/project-rules.md)** - Customize AI behavior for your project - **[Ignoring Files](docs/ignoring-files.md)** - Exclude files from context using `.qodeassistignore` @@ -196,6 +197,7 @@ Configure in: `Tools → Options → QodeAssist → Code Completion → General - Chat history with auto-save and restore - Token usage monitoring - **[Agent Roles](docs/agent-roles.md)** - Switch between AI personas (Developer, Reviewer, custom roles) +- **[Chat Summarization](docs/chat-summarization.md)** - Compress long conversations into AI-generated summaries - **[File Context](docs/file-context.md)** - Attach or link files for better context - Automatic syncing with open editor files (optional) - Extended thinking mode (Claude, other providers in plan) - Enable deeper reasoning for complex tasks diff --git a/docs/agent-roles.md b/docs/agent-roles.md index 9150c35..c8195a5 100644 --- a/docs/agent-roles.md +++ b/docs/agent-roles.md @@ -15,13 +15,16 @@ Agent Roles are reusable system prompt configurations that modify how the AI ass ## Default Roles -QodeAssist comes with two built-in roles: +QodeAssist comes with three built-in roles: ### Developer -General coding assistance focused on writing clean, maintainable code following industry standards. Best for implementation tasks, debugging, and code explanations. +Experienced Qt/C++ developer with a structured workflow: analyze the problem, propose a solution, wait for approval, then implement. Best for implementation tasks where you want thoughtful, minimal code changes. ### Code Reviewer -Expert code review persona that identifies bugs, performance issues, and adherence to best practices. Provides constructive feedback with specific suggestions for improvement. +Expert C++/QML code reviewer specializing in C++20 and Qt6. Checks for bugs, memory leaks, thread safety, Qt patterns, and production readiness. Provides direct, specific feedback with code examples. + +### Researcher +Research-oriented developer who investigates problems and explores solutions. Analyzes problems, presents multiple approaches with trade-offs, and recommends the best option. Does not write implementation code — focuses on helping you make informed decisions. ## Using Agent Roles diff --git a/docs/chat-summarization.md b/docs/chat-summarization.md new file mode 100644 index 0000000..a98d030 --- /dev/null +++ b/docs/chat-summarization.md @@ -0,0 +1,115 @@ +# Chat Summarization + +Chat Summarization allows you to compress long conversations into concise AI-generated summaries. This helps save context tokens and makes it easier to continue work on complex topics without losing important information. + +## Overview + +When conversations grow long, they consume more context tokens with each message. Chat Summarization uses your configured Chat Assistant provider to create an intelligent summary that preserves: + +- Key decisions and conclusions +- Technical details and code references +- Important context for continuing the conversation + +**Key Features:** +- **One-click compression**: Summarize directly from the chat toolbar +- **Preserves original**: Creates a new chat file, keeping the original intact +- **Smart summaries**: AI extracts the most relevant information +- **Markdown formatted**: Summaries are well-structured and readable + +## Using Chat Summarization + +### Compressing a Chat + +1. Open any chat with conversation history +2. Click the **Compress** button (📦) in the chat top bar +3. Wait for the AI to generate the summary +4. A new chat opens with the compressed summary + +### What Gets Preserved + +The summarization process: +- Maintains chronological flow of the discussion +- Keeps technical details, code snippets, and file references +- Preserves key decisions and conclusions +- Aims for 30-40% of the original conversation length + +### What Gets Filtered + +The following message types are excluded from summarization: +- Tool call results (file reads, searches) +- File edit blocks +- Thinking/reasoning blocks + +## How It Works + +``` +┌─────────────────────────────────────────────────────────────┐ +│ CHAT SUMMARIZATION │ +├─────────────────────────────────────────────────────────────┤ +│ 1. Original chat messages are collected │ +│ 2. Tool/thinking messages are filtered out │ +│ 3. AI generates a structured summary │ +│ 4. New chat file is created with summary as first message │ +│ 5. Original chat remains unchanged │ +└─────────────────────────────────────────────────────────────┘ +``` + +### File Naming + +Compressed chats are saved with a unique suffix: +``` +original_chat.json → original_chat_a1b2c.json +``` + +Both files appear in your chat history, allowing you to switch between the full conversation and the summary. + +## Best Practices + +1. **Summarize at natural breakpoints**: Compress after completing a major task or topic +2. **Review the summary**: Ensure important details were captured before continuing +3. **Keep originals**: Don't delete original chats until you've verified the summary is sufficient +4. **Use for long sessions**: Most beneficial for conversations with 20+ messages + +## When to Use + +**Good candidates for summarization:** +- Long debugging sessions with resolved issues +- Feature implementation discussions with final decisions +- Research conversations where conclusions were reached +- Any chat approaching context limits + +**Consider keeping full history for:** +- Ongoing work that may need exact message references +- Conversations with important code snippets you'll copy +- Discussions where the reasoning process matters + +## Configuration + +Chat Summarization uses your current Chat Assistant settings: +- **Provider**: Same as Chat Assistant (Settings → QodeAssist → General) +- **Model**: Same as Chat Assistant +- **Template**: Same as Chat Assistant + +No additional configuration is required. + +## Troubleshooting + +### Compression Button Not Visible +- Ensure you have an active chat with messages +- Check that the chat top bar is visible + +### Compression Fails +- Verify your Chat Assistant provider is configured correctly +- Check network connectivity +- Ensure the model supports chat completions + +### Summary Missing Details +- The AI aims for 30-40% compression; some details may be condensed +- For critical information, keep the original chat +- Consider summarizing smaller conversation segments + +## Related Documentation + +- [Agent Roles](agent-roles.md) - Switch between AI personas +- [File Context](file-context.md) - Attach files to chat +- [Project Rules](project-rules.md) - Customize AI behavior diff --git a/settings/AgentRole.cpp b/settings/AgentRole.cpp index 09ce9ff..75e63dc 100644 --- a/settings/AgentRole.cpp +++ b/settings/AgentRole.cpp @@ -124,6 +124,9 @@ void AgentRolesManager::ensureDefaultRoles() if (!dir.exists("reviewer.json")) saveRole(getDefaultReviewerRole()); + + if (!dir.exists("researcher.json")) + saveRole(getDefaultResearcherRole()); } AgentRole AgentRolesManager::getDefaultDeveloperRole() @@ -131,12 +134,34 @@ AgentRole AgentRolesManager::getDefaultDeveloperRole() return AgentRole{ "developer", "Developer", - "General coding assistance and implementation", - "You are an advanced AI assistant specializing in C++, Qt, and QML development. " - "Your role is to provide helpful, accurate, and detailed responses to questions " - "about coding, debugging, and best practices in these technologies. " - "Focus on writing clean, maintainable code following industry standards.", - false}; + "Experienced Qt/C++ developer for implementation tasks", + "You are an experienced Qt/C++ developer working on a Qt Creator plugin.\n\n" + "Your workflow:\n" + "1. **Analyze** - understand the problem and what needs to be done\n" + "2. **Propose solution** - explain your approach in 2-3 sentences\n" + "3. **Wait for approval** - don't write code until the solution is confirmed\n" + "4. **Implement** - write clean, minimal code that solves the task\n\n" + "When analyzing:\n" + "- Ask clarifying questions if requirements are unclear\n" + "- Check existing code for similar patterns\n" + "- Consider edge cases and potential issues\n\n" + "When proposing:\n" + "- Explain what you'll change and why\n" + "- Mention files you'll modify\n" + "- Note any architectural implications\n\n" + "When implementing:\n" + "- Use C++20, Qt6, follow existing codebase style\n" + "- Write only what's needed (MVP approach)\n" + "- Include file paths and necessary changes\n" + "- Handle errors properly\n" + "- Make sure it compiles\n\n" + "Keep it practical:\n" + "- Short explanations, let code speak\n" + "- No over-engineering or unnecessary refactoring\n" + "- No TODOs, debug code, or unfinished work\n" + "- Point out non-obvious things\n\n" + "You're a pragmatic team member who thinks before coding.", + true}; } AgentRole AgentRolesManager::getDefaultReviewerRole() @@ -144,16 +169,58 @@ AgentRole AgentRolesManager::getDefaultReviewerRole() return AgentRole{ "reviewer", "Code Reviewer", - "Code review, quality assurance, and best practices", - "You are an expert code reviewer specializing in C++, Qt, and QML. " - "Your role is to:\n" - "- Identify potential bugs, memory leaks, and performance issues\n" - "- Check adherence to coding standards and best practices\n" - "- Suggest improvements for readability and maintainability\n" - "- Verify proper error handling and edge cases\n" - "- Ensure thread safety and proper Qt object lifetime management\n" - "Provide constructive, specific feedback with examples.", - false}; + "Expert C++/QML code reviewer for quality assurance", + "You are an expert C++/QML code reviewer specializing in C++20 and Qt6.\n\n" + "What you check:\n" + "- Bugs, memory leaks, undefined behavior\n" + "- C++20 compliance and Qt6 patterns\n" + "- RAII, move semantics, smart pointers\n" + "- Qt parent-child ownership and signal/slot correctness\n" + "- Thread safety and Qt concurrent usage\n" + "- const-correctness and Qt container usage\n" + "- Performance bottlenecks\n" + "- Production readiness: error handling, no debug leftovers\n\n" + "What you do:\n" + "- Point out problems with clear explanations\n" + "- Suggest specific fixes with code examples\n" + "- Remove unnecessary comments, keep essential docs only\n" + "- Flag anything that's not production-ready\n" + "- Recommend optimizations when you spot them\n\n" + "Focus on: correctness, performance, maintainability, Qt idioms.\n\n" + "Be direct and specific. Show, don't just tell.", + true}; +} + +AgentRole AgentRolesManager::getDefaultResearcherRole() +{ + return AgentRole{ + "researcher", + "Researcher", + "Research-oriented developer for exploring solutions", + "You are a research-oriented Qt/C++ developer who investigates problems and explores " + "solutions.\n\n" + "Your job is to think, not to code:\n" + "- Deep dive into the problem before suggesting anything\n" + "- Research Qt docs, patterns, and best practices\n" + "- Find multiple ways to solve it\n" + "- Compare trade-offs: performance, complexity, maintainability\n" + "- Look for relevant Qt APIs and modules\n" + "- Think about architectural consequences\n\n" + "How you work:\n" + "1. **Problem Analysis** - what exactly needs solving\n" + "2. **Research Findings** - what you learned about this problem space\n" + "3. **Solution Options** - present 2-3 approaches with honest pros/cons\n" + "4. **Recommendation** - which one fits best and why\n" + "5. **Next Steps** - what to consider before implementing\n\n" + "What you provide:\n" + "- Clear comparison of different approaches\n" + "- Code snippets as examples (not ready-to-use patches)\n" + "- Links to docs, examples, similar implementations\n" + "- Questions to clarify requirements\n" + "- Warning about potential problems\n\n" + "You DO NOT write implementation code. You explore options and let the developer choose.\n\n" + "Think like a consultant: research thoroughly, present clearly, stay objective.", + true}; } } // namespace QodeAssist::Settings diff --git a/settings/AgentRole.hpp b/settings/AgentRole.hpp index 9908a9f..c3b70c8 100644 --- a/settings/AgentRole.hpp +++ b/settings/AgentRole.hpp @@ -76,6 +76,7 @@ public: private: static AgentRole getDefaultDeveloperRole(); static AgentRole getDefaultReviewerRole(); + static AgentRole getDefaultResearcherRole(); }; } // namespace QodeAssist::Settings