Implements a solution for the Vite port collision issue that allows easier development of Roo across multiple instances of VSCode in different Roo repository directories.
This may also fix crashes and strange behavior between multiple running instances that would otherwise create port conflicts. This is solved using the following automated process:
- When Vite automatically selects an alternative port, a custom plugin automatically writes the port to a '.vite-port' file in the repository root
- ClineProvider automatically reads the port from this file, falling back gracefully to port 5173 if the file doesn't exist
- No user intervention is necessary as the entire process is handled automatically
- Added detailed logging for debugging
- Added .vite-port to .gitignore
The extension now connects to the correct Vite development server port automatically, even when the default port (5173) is already in use.
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
Co-authored-by: Eric Wheeler <roo-code@z.ewheeler.org>
* Added Gemini 2.5 Pro model to Vertex AI Provider
* Adds Gemini 2.5 Pro preview model
Adds configuration for the new Gemini 2.5 Pro preview model,
including its token limits, context window size, image support, and
pricing information.
* feat: enhance rule file loading with .roo/rules directory support
- Introduced functions to safely read files and check for directory existence.
- Added capability to read all text files from a specified directory in alphabetical order.
- Updated `loadRuleFiles` to prioritize loading rules from a `.roo/rules/` directory, falling back to existing rule files if necessary.
- Enhanced `addCustomInstructions` to support loading mode-specific rules from a `.roo/rules-{mode}/` directory, improving flexibility in rule management.
This change improves the organization and retrieval of rule files, allowing for better modularity and maintainability.
* Updated strings and translations
* Add tests
* Revert changes to system prompt translations
* Fix path resolution
* Make instruction structure clearer
---------
Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
* 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.
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.
* Bedrock prompt caching
* remove whitespace only change to src/api/providers/base-provider.ts
* remove integration test that calls bedrock
* PR prep cleanup
* test file and redundant code cleanup
* updated multi-cache-point
* optimized cache strategy
* cache logic updated. commit before trying to simplify newConversationPlacements
* simplified initial cachePoint logic
* fix the missing caching params for claude 3.7 on bedrock
* undo unintentional changes to README.md files
* fix merge bug that hid use prompt cache checkbox
* prep for PR
* remove unintended changes
* revert .gitignore change
* undo unintended changes
* Issue 1998 - Unable to use ARN. https://github.com/RooVetGit/Roo-Code/issues/1998 - Simplify region extraction from Arns. Change example of ARN use from the foundational model ARN to an inference profile ARN which is what is needed.
* small updates to error message
* more flexible support for ARNs and hardening of ARN handling
* update comment on regex use for platform indipendent cosideration
* small code comment update
* remove duplicative logic to add a region to the arn when cross-region is selected
* Update README files from main branch
* improve error handling when on-demand throughput is not avialable for a foundational model
* fix prompt router bug
* minor tweaks for simplicity
* error messgae formatting
* set new version of bedrock runtime package
* fixes: 2229 - complete prompt doesn't work and appears like a no-op
* remove commented out logger.debug blocks per PR review request
* localize new prompt cache UI inputs
* single source of truth for AWS Region information
---------
Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
* feat: Add support for Azure AI Inference Service with DeepSeek-V3 model
* refactor: extract Azure AI inference path to constant to avoid duplication
* fix(tests): update RequestyHandler tests to properly handle Azure inference and streaming
* fix(api): remove duplicate constant and update requesty tests
* refactor: remove unused isAzure property from OpenAiHandler
* refactor(openai): remove unused isAzure and extract Azure check
The multi-search-replace diff strategy previously did not correctly strip line numbers (`number | `) from the SEARCH block when the REPLACE block was empty. This occurred because the condition for stripping required both blocks to consistently have line numbers.
This prevented successful deletion operations when the SEARCH block content was copied from `read_file` output (which includes line numbers) and the REPLACE block was empty.
This commit updates the line number stripping condition in `applyDiff` to also trigger if the SEARCH block has line numbers and the REPLACE block is empty or contains only whitespace, resolving the bug.
Additionally, a new test case has been added to `multi-search-replace.test.ts` to specifically verify this deletion scenario. All tests now pass with this updated logic.
* feat: add Tree-sitter TSX query support
Added support for parsing TSX files with Tree-sitter:
- Created TSX query patterns for React components and functions
- Fixed field name issues by using direct node matching
- Added comprehensive documentation about TSX component structure
- Created a debug tool to inspect the actual tree structure
- Added test coverage for TSX parsing
- Embedded test fixture directly in the test file
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* refactor: combine TypeScript and TSX queries
Reduce duplication by:
- Import TypeScript queries from typescript.ts
- Keep only TSX-specific component and JSX queries
- Update documentation to reflect combined approach
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* test: update integration for parse definitions
- Adjusted logParseResult to call the actual parse definitions function using WASM from initializeWorkingParser.
- Patched TreeSitter initialization to resolve the WASM path correctly and bypass redundant init() calls.
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* test: should successfully call parseSourceCodeDefinitionsForFile
Mock loadRequiredLanguageParsers to use real parser instance from initializeTreeSitter,
ensuring proper interaction between parseSourceCodeDefinitionsForFile and its dependencies.
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* test: improve test structure for parseSourceCodeDefinitions
- Combine component parsing tests into a single test case
- Update test assertions to match actual parser output
- Fix interface and component definition tests to use VSCodeCheckbox as sample
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* feat: improve React component detection in tree-sitter
- Add tests for complex TSX structures (nested components, HOCs)
- Enhance TSX queries to better detect React components
- Document current limitations in test file
* feat: improve React component detection in TSX files
Make TSX/React component detection more generic and robust by:
- Implementing structural pattern matching instead of specific React wrapper functions
- Adding configurable line threshold for React component inclusion (MIN_COMPONENT_LINES)
- Adding robust HTML element filtering with regex patterns
- Improving React component name handling for nested components
- Ensuring proper context handling for multi-line React components
Also update mock captures in tree-sitter tests to span at least 4 lines
to meet the MIN_COMPONENT_LINES threshold.
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* refactor: use testParseSourceCodeDefinitions in logParseResult
- Moved testParseSourceCodeDefinitions function to top level
- Updated logParseResult to use testParseSourceCodeDefinitions
- Removed duplicate function from describe block
- Added console.log for debugging output
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* refactor: improve React component detection output format
- Remove individual line output for components that don't meet MIN_COMPONENT_LINES threshold
- Update tests to match the new behavior where lines < MIN_COMPONENT_LINES are skipped
- Maintain range output (e.g., 1--4) for component definitions
- Preserve context for larger definitions as ranges only
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* feat: add switch/case statement support to tree-sitter TypeScript parser
- Added node patterns in typescript.ts query to capture switch statements, case clauses, and default clauses
- Modified index.ts to avoid duplicate line ranges in the output
- Added test for switch/case statements with complex case blocks
- Fixed line range tracking to prevent duplicate output
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* feat: add support for enum declarations in tree-sitter TypeScript parser
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* feat: add support for namespace declarations in tree-sitter TypeScript parser
Added query pattern for namespace declarations (internal_module nodes) in the TypeScript parser.
This allows the parser to identify and extract namespace declarations from TypeScript code.
- Added test case to verify namespace parsing functionality
- Added query pattern to capture namespace declarations in typescript.ts
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* feat: add decorator pattern support to tree-sitter TypeScript parser
- Added support for parsing complex decorators with arguments
- Added test case for Component decorator pattern
- Enhanced TypeScript queries to capture decorator definitions
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* feat: add generic type declaration support to tree-sitter TypeScript parser
- Added support for parsing generic types with constraints
- Added test case for Dictionary<K extends string | number, V> pattern
- Enhanced TypeScript queries to capture generic type definitions
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* test: add conditional type support to tree-sitter TypeScript parser
- Added test case for conditional type patterns like ReturnType<T>
- Verified that conditional types with infer keyword are already supported
- Enhanced inspectTreeStructure with detailed node inspection for debugging
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* test: add template literal type support to tree-sitter TypeScript parser
- Added test case for template literal type patterns like EventName<T>
- Verified that template literal types are already partially supported
- Confirmed support for complex template literal patterns in conditional types
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* feat: implement tree-sitter compatible markdown processor
Adds a special case implementation for markdown files that:
- Parses markdown headers and section line ranges
- Returns captures in a format compatible with tree-sitter
- Integrates with the existing parseFile function
- Includes comprehensive tests for the implementation
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* fix: markdown parser not detecting sections with horizontal rules
The markdownParser was incorrectly interpreting horizontal rules (---) as setext headers when they appeared after non-header text. This caused some sections to be missed in the output.
This fix:
- Makes setext header detection more strict by requiring at least 3 = or - characters
- Adds validation for the text line before a potential setext header
- Ensures horizontal rules are not confused with setext headers
Added a test case to verify the fix works correctly with horizontal rules.
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* refactor: move helper functions to dedicated file
Move test helper functions from parseSourceCodeDefinitions.test.ts to a new helpers.ts file.
Rename test file to parseSourceCodeDefinitions.tsx.test.ts to indicate it's for TSX tests.
This improves code organization by separating test helpers from test cases.
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* feat: enable JSON structure display in list_code_definitions
This change allows list_code_definitions to show JSON structures by:
- Moving JSON query patterns into the JavaScript query file
- Using the JavaScript parser for JSON files
- Removing the separate JSON parser implementation
- Adding comprehensive tests for JSON parsing
Example output for a JSON file:
# test.json
0--90 | {
1--9 | "server": {
4--8 | "ssl": {
10--45 | "database": {
11--24 | "primary": {
14--18 | "credentials": {
19--23 | "pool": {
25--44 | "replicas": [
26--43 | {
30--42 | "status": {
33--41 | "metrics": {
36--40 | "connections": {
46--73 | "features": {
47--72 | "auth": {
48--71 | "providers": {
49--53 | "local": {
54--70 | "oauth": {
56--69 | "providers": [
57--68 | {
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* fix: Add compile step to CI workflow to ensure WASM files are available
The TreeSitter tests were failing in CI because the WASM files weren't being copied to the dist directory before running the tests. This adds an explicit compile step to ensure the WASM files are properly built and copied.
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
* fix: improve tree-sitter test type safety and debug logging
- Replace 'any' types with proper Parser types in helpers.ts
- Add centralized DEBUG flag and debugLog function in helpers.ts
- Update all console.log statements to use debugLog across all test files
- This change appeases @ellipsis-dev by improving type safety and
providing a clean way to control debug logging
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>
* fix: remove -p flag from test script to prevent git operation errors
The -p flag in npm-run-all was causing tests to run in parallel, which led to 'Cannot log after tests are done' errors with git operations. These errors don't appear when running test:extension alone.
The issue occurs because git-based tests create temporary directories and run async operations that can interfere with each other when executed in parallel. Running tests sequentially resolves this cleanly.
While it might increase total test time slightly, it ensures more reliable and consistent test results.
* refactor(terminal): improve mock streams and fix test issues
- Create shell-specific mock streams (bash, cmd, pwsh) with proper line ending handling
- Fix open handles in tests by properly managing timeouts
- Standardize stderr redirection across all shell implementations using stdio option
- Improve test reliability and output cleanliness
* fix(tests): add skipVerification option to PowerShell tests to debug Linux issues
* fix(tests): use explicit variable name in PowerShell test to fix Linux compatibility
* Refactor terminal tests to use purpose-based approach instead of command mapping
* Remove reference to non-existent test file
* fix: use printf instead of echo -e for more consistent behavior across platforms
* fix: use single quotes for PowerShell commands to preserve variables on Linux
* Update code-qa workflow to run tests on both Windows and Ubuntu
* fix: use platform-specific PowerShell command execution for Linux and Windows
* Fix toggleToolAlwaysAllow to handle path normalization for cross-platform compatibility
* Fix McpHub tests to handle normalized paths on Windows
* Suppress console.error messages in McpHub tests
* fix: make Bedrock ARN regex patterns Windows-compatible
Fixed an issue where AWS Bedrock tests were timing out on Windows but passing on Linux. The root cause was path separator handling in regex patterns used for model ID extraction from ARNs.
1. Updated model ID extraction regex to handle both forward slashes (Linux) and backslashes (Windows)
2. Modified ARN matching regex to be platform-independent
3. Ensured consistent region prefix handling for all supported regions
This change maintains functionality while ensuring cross-platform compatibility.
* fix: make WorkspaceTracker test cross-platform compatible
Fixed an issue where the WorkspaceTracker test 'should initialize with workspace files' was failing on Windows but passing on Linux. The problem was in the mock implementation of toRelativePath that only handled forward slashes.
- Updated the toRelativePath mock to use path.relative which properly handles platform-specific path separators
- Ensured all paths are converted to forward slashes for consistency in test assertions
- The fix maintains cross-platform compatibility while preserving the test's intent
* fix: make WorkspaceTracker tests cross-platform compatible
Fixed cross-platform compatibility issues in the WorkspaceTracker tests that were causing failures on Windows but passing on Linux:
1. Updated the toRelativePath mock implementation to:
- Use path.relative which properly handles platform-specific path separators
- Convert paths to forward slashes for consistency in test assertions
2. Enhanced the 'should not update file paths' test to be platform-agnostic by:
- Using more flexible assertions that don't depend on specific path formats
- Checking file path length and content rather than exact string matches
- Properly typed the test assertions to fix TypeScript errors
These changes preserve the test intent while ensuring they run successfully across different operating systems.
* fix: make McpHub tests cross-platform compatible
Fixed cross-platform compatibility issues in the McpHub tests that were causing failures on Windows but passing on Linux:
1. Made the toggleToolAlwaysAllow tests more platform-agnostic by:
- No longer relying on specific path formats which differ between Windows and Linux
- Using the last write call instead of searching for a specific path string
- Adding more robust assertions that verify structure instead of exact path matches
- Properly handling array existence checks
2. These tests would fail on Windows because paths are formatted with backslashes instead of
forward slashes, causing path equality checks to fail.
The changes maintain test intent while ensuring cross-platform compatibility.
* handle escaping of slash and quote
* fix: ensure consistent line endings in git fallback strategy
Fixed an issue where tests would fail on GitHub Windows runners but pass on local Windows machines due to line ending differences. The fix ensures consistent line ending handling by:
1. Normalizing CRLF to LF when reading files in the git fallback strategy
2. Disabling Git's automatic line ending conversion
3. Maintaining consistent line ending usage throughout text operations
* feat: run tests sequentially on Windows, parallel otherwise
* Update the webview when changing settings via the API
* Update src/exports/api.ts
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
---------
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>