* feat: Add folder deletion when custom mode is deleted (#5210)
* fix: address PR feedback - fix Korean translation typo and add missing German translation
* fix: use os.homedir() instead of vscode.env.userHome
* fix: use dynamic home directory in webview tests for cross-platform compatibility
* fix: normalize path separators in tests for Windows compatibility
* feat: implement DeleteModeDialog component for mode deletion confirmation
* fix: use ref to store current modeToDelete value for consistent state handling
* feat: add error handling for rules folder deletion and localize error messages
* Update src/i18n/locales/ja/common.json
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
* Update src/i18n/locales/zh-CN/common.json
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
* fix: remove redundant rulesFolderExists from deleteCustomModeCheck response
* fix: update webviewMessageHandler tests to match fs import style
---------
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
Co-authored-by: Daniel <57051444+daniel-lxs@users.noreply.github.com>
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>
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
Co-authored-by: Daniel <57051444+daniel-lxs@users.noreply.github.com>
Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
Co-authored-by: Daniel <57051444+daniel-lxs@users.noreply.github.com>
* Fixes#5294: Add instruction to Architect mode to avoid time estimates
- Updated Architect mode custom instructions to explicitly prohibit providing time estimates
- Added clear guidance to focus on actionable plans without speculating about implementation timeframes
- Updated test snapshot to reflect the new instruction
- All tests passing
* More tweaks to prompt
---------
Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
* chore: adding x-title header and testing for litellm
* chore: indentation fi and headers order fix
* chore: spacing fix
* chore: removed white space
* fix: allow user headers to override default headers and clean up formatting
- Reorder header spread in router-provider.ts so user-provided openAiHeaders can override DEFAULT_HEADERS
- Remove unnecessary blank lines after imports for consistency
- This matches the pattern used in openai.ts where DEFAULT_HEADERS come first
---------
Co-authored-by: Brendan-Z <brendanzhou.99@gmail.com>
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
* feat: change default mode to architect for new installations
- Reordered modes array to put architect mode first
- Updated test to reflect architect as the default mode
- Maintains backward compatibility for existing users
* test: update snapshots and fix tests for architect default mode
- Update all snapshot tests to reflect architect as the default mode
- Fix mode destructuring in validateToolUse tests
- All tests now pass with the new default mode configuration
* docs: add comment explaining mode ordering for default selection
Addresses PR review feedback to clarify that the first mode in the array
serves as the default for new installations
* fix: Update integration test to use lowercase mode name
The test was using 'Ask' (capitalized) but modes are now lowercase 'ask'.
This was causing the test to timeout as the mode validation failed.
* https parsing in URL sanatizing for git repo
* fix: remove duplicate JSDoc and add SSH to HTTPS conversion test
- Remove duplicate JSDoc comment from convertGitUrlToHttps function
- Add test case to verify getGitRepositoryInfo converts SSH URLs to HTTPS format
---------
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
* fix: resolve E2BIG error by passing large prompts via stdin to Claude CLI
- Pass messages via stdin instead of command line arguments to avoid Linux argument length limits
- Add --input-format text flag to claude CLI command
- Update execa configuration to use stdin pipe
- Fix corresponding unit tests with proper async iterator mocking
- Resolves spawn E2BIG errors when using very large conversation histories
* fix: address race condition and improve error handling
- Use setImmediate to ensure process is spawned before writing to stdin
- Add proper error handling for stdin write operations
- Add tests for error scenarios
- Update existing tests to handle async behavior properly
* fix: remove --input-format text flag to prevent CLI parsing errors
The --input-format text flag was causing the Claude CLI to misinterpret
the JSON content passed via stdin, leading to errors like 'unknown option -------'
when the system prompt contained dashes. Removing this flag allows the CLI
to properly handle the JSON input via stdin.
---------
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
## Fix terminal keyboard shortcut error when adding content to context
**Fixes:** [#2276](https://github.com/RooCodeInc/Roo-Code/issues/2276)
**Problem:**
- Using keyboard shortcuts to add terminal content to context threw error: "Cannot read properties of undefined (reading 'selection')"
- Context menu worked correctly, but keyboard shortcuts failed
**Root Cause:**
- Command handler accessed `args.selection` without null checking
- When triggered via keyboard shortcut, VS Code passes `undefined` for `args` parameter
- When triggered via context menu, VS Code passes an object with `selection` property
**Solution:**
- Changed `args.selection` to `args?.selection` using optional chaining
- Maintains existing fallback behavior when no selection is available
- Preserves backward compatibility with context menu functionality
**Files Modified:**
- `src/activate/registerTerminalActions.ts` - Added null safety for args parameter
**Testing:**
- ✅ Keyboard shortcuts now work without errors
- ✅ Context menu functionality preserved
- ✅ Fallback to `Terminal.getTerminalContents()` works in both scenarios
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Co-authored-by: Matt Rubens <mrubens@users.noreply.github.com>
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
Co-authored-by: Daniel <57051444+daniel-lxs@users.noreply.github.com>
* fix: resolve Claude Code token counting inefficiency and enable caching (#5104)
- Remove 1.5x fudge factor from Claude Code token counting
- Enable prompt caching support for all Claude Code models
- Add comprehensive tests for token counting and caching
- Update existing tests to reflect accurate token counting
This fixes the extreme token inefficiency where simple messages would
jump from ~40k to over 60k tokens, causing API hangs when approaching
the artificial 120k limit. Claude Code now properly utilizes its full
200k context window with accurate token counting.
* fix: address PR review comments
- Extract IMAGE_TOKEN_ESTIMATE as a named constant for clarity
- Update token counting tests to use exact counts instead of ranges for deterministic testing
- Fix test expectations to match actual tokenizer output
* Remove token counting changes, keep only cache support
- Removed custom countTokens override from claude-code.ts
- Deleted claude-code-token-counting.spec.ts test file
- Kept cache token collection and reporting functionality
- Kept supportsPromptCache: true for all Claude Code models
- Kept claude-code-caching.spec.ts tests
This focuses the PR on enabling cache support without modifying token counting behavior.
* fix: update webview test to expect supportsPromptCache=true for Claude Code models
---------
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
* Fix temperature parameter error for Azure OpenAI reasoning models
* Fix tests: Update O3 family model tests to expect temperature: undefined
- Updated failing tests in openai.spec.ts to expect temperature: undefined for O3 models
- This aligns with the PR changes that remove temperature parameter for Azure OpenAI o1, o3, and o4 models
- All 4 previously failing tests now pass
---------
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
* fix: handle YAML parsing edge cases in CustomModesManager
- Add BOM (Byte Order Mark) stripping for UTF-8 and UTF-16
- Normalize invisible characters including non-breaking spaces
- Replace fancy quotes and dashes with standard characters
- Remove zero-width characters that can cause parsing issues
- Add comprehensive test coverage for all edge cases
This fixes the YAML parsing limitations documented in PR #237 by
implementing proper preprocessing before parsing YAML content.
* fix: address PR review comments
- Fix BOM handling to correctly handle UTF-16 (all BOMs appear as \uFEFF when decoded)
- Optimize cleanInvisibleCharacters with single regex pass for better performance
- Prevent duplicate error messages by marking errors as already handled
- Refactor test file to use mockFsReadFile helper function to reduce duplication
- Fix YAML indentation in tests (use spaces instead of tabs)
- Add ESLint disable comment for character class warning (regex is correct)
* fix: prevent YAML line breaks by setting lineWidth to 0
- Added lineWidth: 0 option to all yaml.stringify() calls
- Prevents automatic line wrapping at 80 characters
- Improves readability of YAML output for long strings
- Applied to CustomModesManager, SimpleInstaller, and migrateSettings
* fix: add defaultStringType option to yaml.stringify calls
- Added defaultStringType: 'PLAIN' to minimize formatting changes
- This helps preserve plain scalars when possible
- Works alongside lineWidth: 0 to prevent automatic line wrapping
* refactor: extract problematic characters regex as a named constant
- Move regex pattern to PROBLEMATIC_CHARS_REGEX static constant
- Add comprehensive documentation for each character range
- Improves maintainability and makes the pattern reusable
* test: add comprehensive edge case tests for YAML parsing
- Add test for mixed line endings (CRLF vs LF)
- Add test for multiple BOMs in sequence
- Add test for deeply nested structures with problematic characters
- Ensures robustness across different real-world scenarios
* feat(i18n): add error messages for custom modes in multiple languages
* fix: update tests to expect i18n keys instead of hardcoded strings
- Update CustomModesManager tests to expect translation keys
- Fix YAML edge case tests to match new i18n error messages
- All tests now pass with the i18n integration
* refactor: use strip-bom package and fix error handling
- Replace custom stripBOM method with existing strip-bom package
- Fix duplicate error handling in parseYamlSafely by returning empty object instead of re-throwing
- Addresses review comments from PR #5099
---------
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
This PR adds filtering of git repository properties from telemetry data and includes git info in telemetry properties, with comprehensive tests.
Behavior:
PostHogTelemetryClient now filters out repositoryUrl, repositoryName, and defaultBranch from telemetry events.
ClineProvider includes git repository information in telemetry properties, filtered by clients.
Functions:
Added isPropertyCapturable() in BaseTelemetryClient to allow property filtering.
Implemented getGitRepositoryInfo() and getWorkspaceGitInfo() in git.ts to extract git info.
Tests:
Added tests for isPropertyCapturable() in PostHogTelemetryClient.test.ts.
Added tests for getGitRepositoryInfo() and getWorkspaceGitInfo() in git.spec.ts.