You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .roomodes
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@
23
23
"slug": "release-notes-writer",
24
24
"name": "Release Notes Writer",
25
25
"roleDefinition": "You are a technical writer specializing in creating and maintaining release notes for the Roo Code VS Code extension, specifically within the `docs/update-notes` directory. Your focus is on accuracy, consistency, and clarity, ensuring users can easily understand recent changes. You adhere strictly to the project's release note standards.",
26
-
"customInstructions": "**Release Notes (`docs/update-notes`) Standards:**\n\nWhen creating or updating release notes (`.md` files within the `docs/update-notes` directory), adhere to the following standards:\n\n1. **File Naming:**\n * **Patch Releases:** Use the full version number (e.g., `v3.3.1.md`). These files should detail specific bug fixes or minor changes since the last patch or minor release.\n * **Minor/Major Releases:** Use the major.minor version number (e.g., `v3.11.md`). These files should summarize all changes included in that version cycle, including features, improvements, and bug fixes from all associated patch releases (e.g., `v3.11.0`, `v3.11.1`, `v3.11.2`, etc.).\n2. **File Structure (`vX.Y.Z.md` or `vX.Y.md`):**\n * **Title:** The H1 title must follow the format: `# Roo Code X.Y.Z Release Notes (YYYY-MM-DD)` or `# Roo Code X.Y Release Notes (YYYY-MM-DD)`. Ensure the date reflects the release date and is always included.\n * **Summary Sentence:** Include a brief sentence below the title summarizing the key changes in the release. For minor/major releases, this should cover the scope of the entire version cycle.\n * **Section Headings:** Use consistent `##` headings. Recommended headings include:\n * `## Highlights` (for major features or changes, especially in minor/major releases)\n * `## Bug Fixes`\n * `## Improvements` (can include performance, UX, or other enhancements)\n * `## Provider Updates` (for changes related to specific integrations like Cloud providers)\n * `## Documentation Updates`\n * *(Avoid overly generic terms like \"Changes\" or \"Updates\" as section headers)*\n3. **`index.md` File (Main Index):**\n * The main `index.md` file in the `docs/update-notes` directory should list all release versions chronologically (newest first).\n * Each entry should link to the corresponding release note file (e.g., `v3.11.md` for the summary page, `v3.3.1.md` for a specific patch). Use absolute paths from `/docs/` and omit the `.md` extension (e.g., `[3.11.8](/update-notes/v3.11.8)`).\n * Ensure the date `(YYYY-MM-DD)` is included next to each version link.\n4. **Contributor Acknowledgments:** If acknowledging contributors for specific changes (e.g., bug fixes), do so consistently. Add `(thanks username!)` at the end of the relevant bullet point, omitting the `@` symbol.\n5. **Content Style:** Maintain a clear, concise, and informative writing style. Use Markdown formatting correctly (e.g., use backticks `` for code or version numbers). Ensure consistent terminology (e.g., \"release notes\" vs. \"changelog\").\n6. **Sidebar Update (`sidebars.ts`):**\n * When a new **release note page** (e.g., `vX.Y.md` or `vX.Y.Z.md`) is created, you **must** update the `sidebars.ts` file.\n * Add the Docusaurus ID for the new page (e.g., `'update-notes/vX.Y'` or `'update-notes/vX.Y.Z'`) to the `items` array within the appropriate 'Update Notes' category.",
26
+
"customInstructions": "**Release Notes (`docs/update-notes`) Standards:**\n\nWhen creating or updating release notes (`.md` files within the `docs/update-notes` directory), adhere to the following standards:\n\n1. **File Naming:**\n * **Patch Releases:** Use the full version number (e.g., `v3.3.1.md`). These files should detail specific bug fixes or minor changes since the last patch or minor release.\n * **Minor/Major Releases:** Use the major.minor version number (e.g., `v3.11.md`). These files should summarize all changes included in that version cycle, including features, improvements, and bug fixes from all associated patch releases (e.g., `v3.11.0`, `v3.11.1`, `v3.11.2`, etc.).\n2. **File Structure (`vX.Y.Z.md` or `vX.Y.md`):**\n * **Title:** The H1 title must follow the format: `# Roo Code X.Y.Z Release Notes (YYYY-MM-DD)` or `# Roo Code X.Y Release Notes (YYYY-MM-DD)`. Ensure the date reflects the release date and is always included.\n * **Summary Sentence:** Include a brief sentence below the title summarizing the key changes in the release. For minor/major releases, this should cover the scope of the entire version cycle.\n * **Section Headings:** Use consistent `##` headings. Recommended headings include:\n * `## Bug Fixes`\n * `## QOL Improvements` (for user experience, UI, or workflow enhancements)\n * `## Misc Improvements` (for performance, internal changes, etc.)\n * `## Provider Updates` (for changes related to specific integrations like Cloud providers)\n * `## Documentation Updates`\n * *(Avoid overly generic terms like \"Changes\" or \"Updates\" as section headers. Do NOT use `## Highlights`)*\n3. **`index.md` File (Main Index):**\n * The main `index.md` file in the `docs/update-notes` directory should list all release versions chronologically (newest first).\n * Each entry should link to the corresponding release note file (e.g., `v3.11.md` for the summary page, `v3.3.1.md` for a specific patch). Use absolute paths from `/docs/` and omit the `.md` extension (e.g., `[3.11.8](/update-notes/v3.11.8)`).\n * Ensure the date `(YYYY-MM-DD)` is included next to each version link.\n* **Updating Combined Notes:** When creating a patch release note (`vX.Y.Z.md`), you must also update the corresponding minor/major release note (`vX.Y.md`) by adding the changes from the patch release to the relevant sections. Do *not* include the patch version number (e.g., `(vX.Y.Z)`) in the combined notes.\n4. **Contributor Acknowledgments:** If acknowledging contributors for specific changes (e.g., bug fixes), do so consistently. Add `(thanks username!)` at the end of the relevant bullet point, omitting the `@` symbol.\n5. **Content Style:** Maintain a clear, concise, and informative writing style. Use Markdown formatting correctly (e.g., use backticks `` for code or version numbers). Ensure consistent terminology (e.g., \"release notes\" vs. \"changelog\").\n6. **Sidebar Update (`sidebars.ts`):**\n * When a new **release note page** (e.g., `vX.Y.md` or `vX.Y.Z.md`) is created, you **must** update the `sidebars.ts` file.\n * Add the Docusaurus ID for the new page (e.g., `'update-notes/vX.Y'` or `'update-notes/vX.Y.Z'`) to the `items` array within the appropriate 'Update Notes' category.",
Copy file name to clipboardExpand all lines: docs/advanced-usage/available-tools/apply-diff.md
+13-20Lines changed: 13 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,19 @@
1
1
# apply_diff
2
2
3
-
The `apply_diff` tool makes precise, surgical changes to files by specifying exactly what content to replace. It uses multiple sophisticated strategies for finding and applying changes while maintaining proper code formatting and structure.
3
+
The `apply_diff` tool makes precise, surgical changes to files by specifying exactly what content to replace. It uses a sophisticated strategy for finding and applying changes while maintaining proper code formatting and structure.
4
4
5
5
## Parameters
6
6
7
7
The tool accepts these parameters:
8
8
9
9
-`path` (required): The path of the file to modify relative to the current working directory.
10
10
-`diff` (required): The search/replace block defining the changes using a format specific to the active diff strategy.
11
-
-`start_line` (optional): A hint for where the search content begins, used by some strategies.
12
-
-`end_line` (optional): A hint for where the search content ends, used by some strategies.
11
+
-`start_line` (optional): A hint for where the search content begins. _Note: This top-level parameter appears unused by the current main strategy, which relies on `:start_line:` within the diff content._
12
+
-`end_line` (optional): A hint for where the search content ends. _Note: This top-level parameter appears unused by the current main strategy._
13
13
14
14
## What It Does
15
15
16
-
This tool applies targeted changes to existing files using sophisticated strategies to locate and replace content precisely. Unlike simple search and replace, it uses intelligent matching algorithms (including fuzzy matching) that adapt to different content types and file sizes, with fallback mechanisms for complex edits.
16
+
This tool applies targeted changes to existing files using fuzzy matching guided by line number hints to locate and replace content precisely. Unlike simple search and replace, it identifies the exact block for replacement based on the provided content and location hints.
17
17
18
18
## When is it used?
19
19
@@ -24,11 +24,10 @@ This tool applies targeted changes to existing files using sophisticated strateg
- Uses fuzzy matching (Levenshtein distance on normalized strings) guided by a `:start_line:` hint, with configurable confidence thresholds (typically 0.8-1.0).
28
28
- Provides context around matches using `BUFFER_LINES` (default 40).
29
-
- Employs an overlapping window approach for searching large files.
30
-
- Preserves code formatting and indentation automatically.
31
-
- Combines overlapping matches for improved confidence scoring.
29
+
- Performs a middle-out search within a configurable context window (`bufferLines`) around the hinted start line.
30
+
- Preserves code formatting and indentation passively by replacing exact blocks.
32
31
- Shows changes in a diff view for user review and editing before applying.
33
32
- Tracks consecutive errors per file (`consecutiveMistakeCountForApplyDiff`) to prevent repeated failures.
34
33
- Validates file access against `.rooignore` rules.
@@ -49,8 +48,8 @@ When the `apply_diff` tool is invoked, it follows this process:
49
48
1.**Parameter Validation**: Validates required `path` and `diff` parameters.
50
49
2.**RooIgnore Check**: Validates if the target file path is allowed by `.rooignore` rules.
51
50
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.
51
+
4.**Match Finding**: Uses a fuzzy matching algorithm (Levenshtein on normalized strings) guided by the `:start_line:` hint within a context window (`BUFFER_LINES`), searching middle-out to locate the target content based on the confidence threshold.
52
+
5.**Change Preparation**: Generates the proposed changes by replacing the identified block.
54
53
6.**User Interaction**:
55
54
* Displays the changes in a diff view.
56
55
* Allows the user to review and potentially edit the proposed changes.
@@ -59,16 +58,11 @@ When the `apply_diff` tool is invoked, it follows this process:
59
58
8.**Error Handling**: If errors occur (e.g., match failure, partial application), increments the `consecutiveMistakeCountForApplyDiff` for the file and reports the failure type.
60
59
9.**Feedback**: Returns the result, including any user feedback or error details.
61
60
62
-
## Diff Strategy
61
+
## Diff Format Requirements
63
62
64
-
Roo Code uses this strategy for applying diffs:
63
+
The `<diff>` parameter requires a specific format supporting one or more changes in a single request. Each change block requires a line number hint for the original content.
65
64
66
-
### MultiSearchReplaceDiffStrategy
67
-
68
-
An enhanced search/replace format supporting multiple changes in one request. Requires line numbers for each search block.
69
-
70
-
***Best for**: Multiple, distinct changes where line numbers are known or can be estimated.
71
-
***Requires**: Exact match for the `SEARCH` block content, including whitespace and indentation. Line numbers (`:start_line:`, `:end_line:`) are mandatory. Markers within content must be escaped (`\`).
65
+
***Requires**: Exact match for the `SEARCH` block content (within the fuzzy threshold), including whitespace and indentation. The `:start_line:` number hint is mandatory within each block. The `:end_line:` hint is optional (but supported by the parser). Markers like `<<<<<<<` within the file's content must be escaped (`\\`) in the SEARCH block.
72
66
73
67
Example format for the `<diff>` block:
74
68
@@ -94,5 +88,4 @@ Example format for the `<diff>` block:
The `insert_content` tool adds new lines of content into an existing file without modifying the original content. It's ideal for inserting code blocks, configuration entries, or log lines at specific locations.
4
+
5
+
## Parameters
6
+
7
+
The tool accepts these parameters:
8
+
9
+
-`path` (required): The relative path (from the workspace root) of the file to insert content into.
10
+
-`line` (required): The 1-based line number *before* which the content should be inserted. Use `0` to append the content to the end of the file.
11
+
-`content` (required): The text content to insert.
12
+
13
+
## What It Does
14
+
15
+
This tool reads the target file, identifies the specified insertion point based on the `line` parameter, and inserts the provided `content` at that location. If `line` is `0`, the content is added to the end. Changes are presented in a diff view for user approval before being saved.
16
+
17
+
## When is it used?
18
+
19
+
- When adding new import statements at the beginning of a file.
20
+
- When inserting new functions or methods into existing code.
21
+
- When adding configuration blocks to settings files.
22
+
- When appending log entries or data records.
23
+
- When adding any multi-line text block without altering existing lines.
24
+
25
+
## Key Features
26
+
27
+
-**Targeted Insertion**: Adds content precisely at the specified line number or appends to the end.
28
+
-**Preserves Existing Content**: Does not modify or delete original file lines.
29
+
-**Interactive Approval**: Shows proposed insertions in a diff view, requiring explicit user approval.
30
+
-**User Edit Support**: Allows editing the proposed content directly within the diff view before final approval.
31
+
-**Handles Line Numbers**: Correctly interprets the `line` parameter (1-based or 0 for append).
32
+
-**Context Tracking**: Records the file edit operation for context management.
33
+
-**Error Handling**: Checks for missing parameters, invalid line numbers, and file access issues.
34
+
35
+
## Limitations
36
+
37
+
-**Insert Only**: Cannot replace or delete existing content. Use `apply_diff` or `search_and_replace` for modifications.
38
+
-**Requires Existing File**: The target file specified by `path` must exist.
39
+
-**Review Overhead**: The mandatory diff view approval adds an interactive step.
40
+
41
+
## How It Works
42
+
43
+
When the `insert_content` tool is invoked, it follows this process:
44
+
45
+
1.**Parameter Validation**: Checks for required `path`, `line`, and `content`. Validates `line` is a non-negative integer.
46
+
2.**File Reading**: Reads the content of the target file specified by `path`.
47
+
3.**Insertion Point Calculation**: Converts the 1-based `line` parameter to a 0-based index for internal processing (`-1` for appending).
48
+
4.**Content Insertion**: Uses an internal utility (`insertGroups`) to merge the original file lines with the new `content` at the calculated index.
49
+
5.**Diff View Interaction**:
50
+
* Opens the file in the diff view (`cline.diffViewProvider.open`).
51
+
* Updates the diff view with the proposed content (`cline.diffViewProvider.update`).
52
+
6.**User Approval**: Presents the change via `askApproval`. Reverts if rejected.
53
+
7.**Saving Changes**: If approved, saves the changes using `cline.diffViewProvider.saveChanges`.
54
+
8.**File Context Tracking**: Tracks the edit using `cline.getFileContextTracker().trackFileContext`.
55
+
9.**Handling User Edits**: If the user edited the content in the diff view, reports the final merged content back.
56
+
10.**Result Reporting**: Reports success (including user edits) or failure back to the AI model.
57
+
58
+
## Usage Examples
59
+
60
+
Inserting import statements at the beginning of a file (`line: 1`):
61
+
62
+
```xml
63
+
<insert_content>
64
+
<path>src/utils.ts</path>
65
+
<line>1</line>
66
+
<content>
67
+
// Add imports at start of file
68
+
import { sum } from './math';
69
+
import { parse } from 'date-fns';
70
+
</content>
71
+
</insert_content>
72
+
```
73
+
74
+
Appending content to the end of a file (`line: 0`):
0 commit comments