Skip to content

Commit 4b20d2e

Browse files
authored
Update experimental-features.md (#112)
* Update experimental-features.md * Remove more
1 parent beb1508 commit 4b20d2e

File tree

4 files changed

+12
-196
lines changed

4 files changed

+12
-196
lines changed

docs/features/experimental/experimental-features.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@ To enable or disable experimental features:
1818

1919
The following experimental features are currently available:
2020

21-
### Unified Diff Editing Strategy
22-
23-
This is an alternate diff editing strategy to the standard search-and-replace algorithm. It evaluates multiple different approaches to applying a unified diff to a file, and selects the best approach for the given file.
24-
25-
**Note:** You must have "Enable editing through diffs" checked to use this feature.
26-
27-
### Multi-block Diff Editing Strategy
28-
29-
Multi-block diff strategy allows updating multiple code blocks in a file in one request.
30-
3121
### Search and Replace
3222

3323
Adds a new tool for searching and replacing text in a file.
@@ -44,4 +34,4 @@ When enabled, Roo will remind the model about the details of its current mode de
4434

4535
If you encounter any issues with experimental features, or if you have suggestions for improvements, please report them on the [Roo Code GitHub Issues page](https://github.com/RooVetGit/Roo-Code/issues).
4636

47-
Your feedback is valuable and helps us improve Roo Code!
37+
Your feedback is valuable and helps us improve Roo Code!

docs/features/fast-edits.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,4 @@ This slider controls how closely the code sections identified by the AI must mat
3333

3434
**Use values below 100% with extreme caution.** Lower precision might be necessary occasionally, but always review the proposed changes carefully.
3535

36-
Internally, this setting adjusts a `fuzzyMatchThreshold` used with algorithms like Levenshtein distance to compare code similarity.
37-
38-
39-
## Experimental Features
40-
41-
Under the "Experimental Features" section, you will find this option:
42-
43-
<img src="/img/fast-edits/fast-edits-2.png" alt="Roo Code settings showing the Experimental Features section with the experimental unified diff strategy checkbox" width="500" />
44-
45-
* **Use experimental unified diff strategy**: This checkbox might appear to enable specific variations or optimizations of the `UnifiedDiffStrategy`. Enabling this could potentially reduce retries caused by model errors but might also introduce unexpected behavior or incorrect edits. Enable only if you understand the risks and are prepared to carefully review all changes.
36+
Internally, this setting adjusts a `fuzzyMatchThreshold` used with algorithms like Levenshtein distance to compare code similarity.

docs/features/tools/apply-diff.md

Lines changed: 10 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ This tool applies targeted changes to existing files using sophisticated strateg
2424

2525
## Key Features
2626

27-
- Implements two primary diff strategies: `MultiSearchReplaceDiffStrategy` and `UnifiedDiffStrategy`.
2827
- Uses intelligent fuzzy matching with configurable confidence thresholds (typically 0.8-1.0).
2928
- Provides context around matches using `BUFFER_LINES` (default 40).
3029
- Employs an overlapping window approach for searching large files.
@@ -49,21 +48,20 @@ When the `apply_diff` tool is invoked, it follows this process:
4948

5049
1. **Parameter Validation**: Validates required `path` and `diff` parameters.
5150
2. **RooIgnore Check**: Validates if the target file path is allowed by `.rooignore` rules.
52-
3. **Strategy Selection**: Determines the appropriate diff strategy (`MultiSearchReplaceDiffStrategy` or `UnifiedDiffStrategy`) based on the `diff` format and configuration.
53-
4. **File Analysis**: Loads the target file content.
54-
5. **Match Finding**: Uses the selected strategy's algorithms (exact, fuzzy, overlapping windows) to locate the target content, considering confidence thresholds and context (`BUFFER_LINES`).
55-
6. **Change Preparation**: Generates the proposed changes, preserving indentation.
56-
7. **User Interaction**:
51+
3. **File Analysis**: Loads the target file content.
52+
4. **Match Finding**: Uses the selected strategy's algorithms (exact, fuzzy, overlapping windows) to locate the target content, considering confidence thresholds and context (`BUFFER_LINES`).
53+
5. **Change Preparation**: Generates the proposed changes, preserving indentation.
54+
6. **User Interaction**:
5755
* Displays the changes in a diff view.
5856
* Allows the user to review and potentially edit the proposed changes.
5957
* Waits for user approval or rejection.
60-
8. **Change Application**: If approved, applies the changes (potentially including user edits) to the file.
61-
9. **Error Handling**: If errors occur (e.g., match failure, partial application), increments the `consecutiveMistakeCountForApplyDiff` for the file and reports the failure type.
62-
10. **Feedback**: Returns the result, including any user feedback or error details.
58+
7. **Change Application**: If approved, applies the changes (potentially including user edits) to the file.
59+
8. **Error Handling**: If errors occur (e.g., match failure, partial application), increments the `consecutiveMistakeCountForApplyDiff` for the file and reports the failure type.
60+
9. **Feedback**: Returns the result, including any user feedback or error details.
6361

64-
## Diff Strategies
62+
## Diff Strategy
6563

66-
Roo Code uses these primary strategies for applying diffs:
64+
Roo Code uses this strategy for applying diffs:
6765

6866
### MultiSearchReplaceDiffStrategy
6967

@@ -97,167 +95,4 @@ Example format for the `<diff>` block:
9795
=======
9896
const defaultTimeout = 10000; // Increased timeout
9997
>>>>>>> REPLACE
100-
```
101-
102-
### UnifiedDiffStrategy
103-
104-
Uses the standard unified diff format but incorporates advanced matching algorithms. It supports fuzzy matching with confidence scoring, overlapping windows for large files, and a git-based fallback mechanism for complex changes. This strategy is often used by default when "Enable editing through diffs" is turned on in settings.
105-
106-
* **Best for**: Applying standard patches, handling complex changes, situations where line numbers might be inaccurate, or when fuzzy matching is beneficial.
107-
* **Requires**: Standard unified diff format.
108-
109-
Example format for the `<diff>` block:
110-
111-
```diff
112-
--- a/src/utils.ts
113-
+++ b/src/utils.ts
114-
@@ -1,5 +1,5 @@
115-
import { Logger } from '../logger';
116-
117-
function calculateTotal(items: number[]): number {
118-
- return items.reduce((sum, item) => sum + item, 0);
119-
+ // Add 10% markup and round
120-
+ const total = items.reduce((sum, item) => sum + item * 1.1, 0);
121-
+ return Math.round(total * 100) / 100;
122-
}
123-
```
124-
125-
## Technical Details
126-
127-
### Confidence Thresholds
128-
- Fuzzy matching relies on confidence scores (typically 0.8 to 1.0).
129-
- A score of 1.0 requires a near-exact match, while lower values (e.g., 0.8) allow more flexibility but increase the risk of incorrect matches.
130-
- The threshold can be adjusted in Roo Code settings ("Match precision" slider).
131-
132-
<img src="/img/fast-edits/fast-edits-1.png" alt="Match precision slider in Roo Code settings" width="600" />
133-
*Description: Settings screen showing the 'Match precision' slider for diffs.*
134-
135-
### Context Buffer (`BUFFER_LINES`)
136-
- When searching, the strategies often use surrounding lines (`BUFFER_LINES`, default 40) to help confirm the correct match location, especially for fuzzy matching.
137-
138-
### Overlapping Window Search
139-
- For large files (`LARGE_FILE_THRESHOLD`, default 1000 lines), search is performed in overlapping windows (`MAX_WINDOW_SIZE`, default 500 lines) to manage memory and improve performance.
140-
141-
### Indentation Preservation
142-
- The tool automatically detects and preserves the indentation of the surrounding code when applying changes.
143-
144-
### Overlapping Matches
145-
- The `UnifiedDiffStrategy` can combine multiple potential matches that overlap, improving confidence in the final selected location.
146-
147-
## User Interaction
148-
149-
### Diff View
150-
- Before applying any changes, Roo presents them in a standard diff view within VS Code.
151-
- This allows you to visually inspect the exact changes proposed.
152-
153-
### Editing Changes
154-
- You can directly edit the proposed changes within the diff view before applying them. Roo will use your modified version.
155-
156-
### User Feedback
157-
- After applying (or attempting to apply) the diff, Roo reports success or failure, often including details about the process or specific errors encountered.
158-
159-
## Error Handling
160-
161-
### Consecutive Error Tracking
162-
- Roo tracks `consecutiveMistakeCountForApplyDiff` for each file. If `apply_diff` fails repeatedly on the same file, Roo might switch strategies or suggest alternative approaches.
163-
164-
### Failure Types
165-
- The system distinguishes between partial failures (some changes applied, others failed) and complete failures.
166-
167-
### Common Error Messages
168-
- **Marker Sequencing:** Errors if `<<<<<<< SEARCH`, `=======`, `>>>>>>> REPLACE` markers are missing, misplaced, or duplicated in `MultiSearchReplaceDiffStrategy`.
169-
- **Match Not Found:** The specified `SEARCH` content couldn't be located with sufficient confidence.
170-
- **File Access Denied:** The file path is blocked by a `.rooignore` rule.
171-
172-
Example Marker Sequencing Error:
173-
```
174-
ERROR: Special marker '=======' found in your diff content at line X:
175-
[...]
176-
```
177-
178-
## Marker Handling (MultiSearchReplaceDiffStrategy)
179-
180-
### Validation
181-
- The `MultiSearchReplaceDiffStrategy` strictly validates the sequence and presence of markers (`<<<<<<< SEARCH`, `:start_line:`, `:end_line:`, `-------`, `=======`, `>>>>>>> REPLACE`).
182-
183-
### Escaping Markers
184-
- If your actual code *contains* text that looks like a diff marker (e.g., `<<<<<<< SEARCH`), you **must** escape it in the `diff` block by adding a backslash (`\`) at the beginning of the line when using `apply_diff`.
185-
186-
Example Escaping in `<diff>` block:
187-
```diff
188-
<<<<<<< SEARCH
189-
:start_line:5
190-
:end_line:7
191-
-------
192-
Code before marker
193-
\<<<<<<< SEARCH // Escaped marker in original code
194-
Code after marker
195-
=======
196-
Replacement content
197-
>>>>>>> REPLACE
198-
```
199-
- Escape `\<<<<<<< SEARCH`, `\=======`, and `\>>>>>>> REPLACE` as needed within both `SEARCH` and `REPLACE` blocks if they appear as literal text in your code.
200-
201-
## Integration
202-
203-
### RooIgnore
204-
- The tool respects `.rooignore` files. If a file path matches a pattern in `.rooignore`, `apply_diff` will be blocked. See [Advanced Usage -> Large Projects](/advanced-usage/large-projects) for more on `.rooignore`.
205-
206-
### Cline Integration
207-
- `apply_diff` is integrated into the core `Cline` class, ensuring it respects overall tool permissions and settings like "Enable editing through diffs".
208-
209-
## Best Practices
210-
211-
- **Multiple Changes:** Use the `MultiSearchReplaceDiffStrategy` to apply multiple, independent changes to a file in a single `apply_diff` request for efficiency.
212-
- **Escaping (for `apply_diff`):** When using `apply_diff` with `MultiSearchReplaceDiffStrategy`, always escape literal diff markers (`<<<<<<< SEARCH`, `=======`, `>>>>>>> REPLACE`) within your code snippets using a preceding backslash (`\`).
213-
- **Clarity:** Provide clear and unique `SEARCH` blocks. If the content is highly repetitive, include more surrounding lines for context.
214-
- **Review:** Always review the changes presented in the diff view carefully before approving, especially when fuzzy matching might be involved.
215-
- **Large/Complex Changes:** For very complex refactoring across multiple files, consider breaking down the task or guiding Roo step-by-step. The `UnifiedDiffStrategy` offers the best chance for complex single-file edits due to its advanced matching capabilities.
216-
217-
## Examples When Used
218-
219-
- Fixing a bug: Roo identifies the buggy function and uses `apply_diff` to modify only that function, potentially using `UnifiedDiffStrategy` if the code has slightly changed since it was last read (leveraging fuzzy matching).
220-
- Refactoring: Roo applies targeted improvements using `MultiSearchReplaceDiffStrategy` for several small changes or `UnifiedDiffStrategy` for a standard patch.
221-
- Feature Enhancement: Roo adds new logic within an existing function using a precise diff, relying on indentation preservation.
222-
223-
## Usage Examples
224-
225-
Using `MultiSearchReplaceDiffStrategy` (Requires line numbers):
226-
```xml
227-
<apply_diff>
228-
<path>src/calculation.py</path>
229-
<diff>
230-
<<<<<<< SEARCH
231-
:start_line:1
232-
:end_line:5
233-
-------
234-
def calculate_total(items):
235-
total = 0
236-
for item in items:
237-
total += item
238-
return total
239-
=======
240-
def calculate_total(items):
241-
"""Calculate total with 10% markup"""
242-
return sum(item * 1.1 for item in items)
243-
>>>>>>> REPLACE
244-
</diff>
245-
</apply_diff>
246-
```
247-
248-
Using `UnifiedDiffStrategy`:
249-
```xml
250-
<apply_diff>
251-
<path>src/utils.ts</path>
252-
<diff>
253-
--- a/src/utils.ts
254-
+++ b/src/utils.ts
255-
@@ -24,7 +24,7 @@
256-
function formatUsername(name: string): string {
257-
return name
258-
.toLowerCase()
259-
- .replace(/[^a-z0-9]/g, '');
260-
+ .replace(/[^a-z0-9_-]/g, ''); // Allow underscores and hyphens
261-
}
262-
</diff>
263-
</apply_diff>
98+
```
-45.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)