* test: add comprehensive Rust Tree-sitter tests
Add test suite for Rust language support in Tree-sitter:
- Verify parsing of struct definitions
- Verify parsing of method definitions within impl blocks
- Verify parsing of standalone function definitions
- Add tests for complex Rust structures
- Include skipped debug test for future diagnostics
These tests confirm the existing Rust support in Tree-sitter is working correctly and provide a foundation for future enhancements to the Rust parser.
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* feat: enhance Rust tree-sitter parser with advanced language structures
- Add support for additional Rust language structures:
- Enum definitions
- Trait definitions
- Impl trait for struct
- Generic structs with lifetime parameters
- Macro definitions
- Module definitions
- Union types
- Closures
- Match expressions
- Where clauses
- Async functions
- Impl blocks with generic parameters
- Complex trait bounds
- Update tests to verify capture of these structures
- Modify debug helper to use environment variables
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
---------
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
Co-authored-by: Eric Wheeler <roo-code@z.ewheeler.org>
Improve handling of AI-generated line numbers:
- Clamp negative startLine values to 0 instead of throwing errors
- Convert non-integer line numbers to integers automatically
- Only reject when line numbers aren't numbers at all
These changes prevent unnecessary model retries by handling imperfect
AI-generated line numbers gracefully, making the system more robust
when interacting with AI models.
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
Co-authored-by: Eric Wheeler <roo-code@z.ewheeler.org>
* Remove unused imports
* Restore protected status for mcpHub property
* More mcpHub tidy-up
* Remove need for access to private "view" property
Increase type flexibility so we can directly use postMessageToWebview()
* Make ensureCacheDirectoryExists private again
expose new public writeDataToCache() method to commonize code.
also decided to leave updateApiConfiguration as public, since widely used in diverse ways.
* Match naming of readModelsFromCache.
Symmetric naming of functions that complement each other.
* Decision: Leave readModelsFromCache as public
* Make updateGlobalState and setGlobalState private again
Stop using deprecated (private) method. Use contextProxy set/getValue methods instead.
Utility functions provided for brevity.
* Add clarifying comment to explain presence of utility functions
* Prefer this/provider.log over outputChannel.appendLine
log is already public, outputChannel should be private.
But also prefer log internally for the additional value of console logging, plus code brevity.
* Lock down access to properties as far as reasonably possible
* PR feedback - don't relax type checks
---------
Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
* feat: Add support for .roorules configuration files
- Add .roorules to the list of supported rule files
- Improve mode-specific rule file handling to prioritize .roorules over .clinerules
- Update file loading logic to track which rule file was successfully loaded
- Add test cases for .roorules functionality
This change maintains backward compatibility with existing .clinerules while
introducing support for the new .roorules format as the preferred configuration
method.
* refactor: simplify rule file loading by removing unused rules
- Removed .cursorrules and .windsurfrules from the list of rule files in loadRuleFiles function.
* refactor: update loadRuleFiles to return single rule file content
- Modified loadRuleFiles function to return content from the first available rule file instead of combining multiple rule files.
- Updated tests to reflect the new behavior of loading only the .roorules file content when available, ensuring clarity in rule file handling.
* fix: update prompts for deprecated rule file references
- Updated prompts in the English locale to reflect the deprecation of .clinerules in favor of .roorules.
- Added notes in the prompts indicating that .clinerules will stop working soon, ensuring users are aware of the upcoming changes.
* Translations
* Update links
* Revert README changes
* Add missing spans around links
---------
Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
Track the current workspace path in history items to enable filtering and organization of history by workspace. This change adds the workspace property to the history schema and ensures it's saved with each history entry.
- Replace Select with Command+Popover components in ApiConfigManager
- Add search functionality to filter configuration profiles
- Add clear search button and selected item indicator
- Add internationalization support for all languages
- Match UX pattern from ModelPicker component for consistency
Problem:
Closing auxiliary windows (e.g., from "open in editor") could prematurely dispose the shared singleton McpHub instance, shutting down MCP servers unexpectedly while other panels (like the sidebar) might still be active.
Solution:
Implemented reference counting directly within the McpHub class to manage its own lifecycle based on active clients (ClineProvider instances).
- Added `refCount`, `registerClient()`, and `unregisterClient()` methods to McpHub.
- McpHub now disposes itself only when the last registered client unregisters (`refCount` reaches 0).
- ClineProvider instances now call `mcpHub.registerClient()` upon initialization and `mcpHub.unregisterClient()` upon disposal.
- Removed the direct `mcpHub.dispose()` call from ClineProvider.dispose.
Benefit:
This ensures the shared McpHub instance remains active as long as at least one ClineProvider instance is using it. Cleanup now correctly occurs only when the last provider is closed or during full extension deactivation. This centralizes the resource's lifecycle logic within the resource class itself.
Files Changed:
- src/services/mcp/McpHub.ts
- src/core/webview/ClineProvider.ts
* refactor: Change read_file result format to XML
Modifies how the result of the `read_file` tool is presented
in the conversation history sent to the AI model.
Previously, the format was:
[read_file for 'path/to/file'] Result:
{content_or_error}
This commit changes the format to use XML tags for better
structure and potentially easier parsing by the model:
<file>
<path>path/to/file</path>
<content>
{content_or_error}
</content>
</file>
This change only affects the `read_file` tool result formatting
within the user context message constructed in `src/core/Cline.ts`.
Other tool result formats remain unchanged.
* fix: Update error message for better clarity in multi-search-replace strategy
Refines the error message returned when no sufficiently similar match is found during the multi-search-replace operation. The message now includes a clearer instruction to use the read_file tool for obtaining the latest file content before attempting to apply the diff again.
* refactor: Update readFileTool to return results in XML format
Modifies the `readFileTool` function to format the output as XML, enhancing the structure of the returned file content. This change aligns with previous updates to ensure consistent result formatting across tools.
* refactor: Simplify result handling for tool responses in Cline
This update refines the handling of tool responses in the `Cline` class by removing the XML formatting for `read_file` results and consolidating the logic for pushing results to the user message content. The changes ensure that all tool results are processed uniformly, improving code clarity and maintainability.
* test: Update read_file tests to validate XML formatted results
This commit modifies the assertions in the `read_file` tool tests to check for the expected XML format in the results. The changes ensure that the output structure aligns with recent updates to the tool's response formatting, enhancing test accuracy and reliability.
* test: Refactor assertions in read_file tests to use expected XML variable
This commit updates the `read_file` tool tests to utilize a predefined variable for the expected XML output, improving readability and maintainability of the test code. The changes ensure consistency in the expected results across multiple test cases.
* fix: Improve handling of escaped markers in apply_diff
unescapeMarkers() is supposed to fix escaped merge conflict markers so
that they match the code. However the function has a bug which requires
SEARCH and REPLACE strings in the markers to be replaced. This is not
part of merge conflict markers, so many valid cases were previously
missed.
* Revert test changes
* Add new test
---------
Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
Currently all errors in apply_diff diff structure are assumed to be
related to merge conflicts. This is unfortunate because it is way more
likely that LLM simply made an error structuring the diff. The LLM is
then directed to fix escaping in the diff from which it doesn't recover.
It is safe to assume that missing or extra "<<<<<<< SEARCH" or ">>>>>>>
REPLACE" strings are likely bad diff structure, because while "<<<<<<<"
and ">>>>>>>" are common merge conflict markers, no tools add "SEARCH"
and "REPLACE" strings after them. This is likely output of the LLM
itself.
LLM not recovering has been observed in Claude 3.5 Sonnet and Claude 3.7
Sonnet models.
To address the issue, error message now mentions merge conflict markers
and their escaping only if it's clear that errors may come from this
source. In the rest of cases the error message repeats the expected diff
structure back to the LLM.