Skip to content

Commit d24fcf9

Browse files
authored
fix: docs audit corrections — remove phantom features & fix 15 factual errors (#543)
1 parent 8212d29 commit d24fcf9

19 files changed

Lines changed: 141 additions & 282 deletions

docs/advanced-usage/available-tools/apply-diff.md

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -118,69 +118,3 @@ Example format for the `<diff>` block:
118118
```
119119

120120
---
121-
122-
## Experimental: Multi-File Edits (`MULTI_FILE_APPLY_DIFF`)
123-
124-
An experimental version of `apply_diff` allows for applying changes to multiple files within a single tool call. This feature is activated by the `MULTI_FILE_APPLY_DIFF` experiment flag.
125-
126-
### Key Features of Experimental Mode
127-
128-
- **Multi-File Operations**: Edit multiple files in one request, streamlining complex refactoring tasks.
129-
- **Batch Approval UI**: When multiple files are targeted, a single UI appears for the user to approve or deny all changes at once, or manage permissions for each file individually.
130-
- **New XML Format**: Introduces a new, more structured XML format using `<args>` and `<file>` tags to handle multiple operations.
131-
- **Backward Compatibility**: The experimental tool remains compatible with the legacy single-file `path` and `diff` parameter format.
132-
133-
### How It Works (Experimental)
134-
135-
1. **Experiment Check**: The tool first checks if the `MULTI_FILE_APPLY_DIFF` experiment is enabled. If not, it falls back to the legacy `apply_diff` implementation.
136-
2. **Parameter Parsing**: It parses the new `<args>` XML format to identify all target files and their corresponding diff operations. It can also handle the legacy `path`/`diff` parameters.
137-
3. **Validation and Approval**:
138-
* It validates that all target files exist and are accessible (not blocked by `.rooignore`).
139-
* If multiple files are being modified, it presents a **batch approval** dialog to the user.
140-
4. **Diff Application**: For each approved file, it applies the specified diffs using the `MultiFileSearchReplaceDiffStrategy`. This strategy can apply multiple, non-overlapping changes to a single file.
141-
5. **Results**: It returns a consolidated result message summarizing the outcome for all attempted operations.
142-
143-
### New Diff Format (Experimental)
144-
145-
The experimental mode uses a new XML structure within the `<apply_diff>` tool call.
146-
147-
- **`<args>`**: A container for all file operations.
148-
- **`<file>`**: A block for each file to be modified. Contains `<path>` and one or more `<diff>` tags.
149-
- **`<path>`**: The relative path to the file.
150-
- **`<diff>`**: A block containing the change.
151-
- **`<content>`**: The `SEARCH/REPLACE` block.
152-
- **`<start_line>`**: (Optional) A line number hint.
153-
154-
**Example: Modifying two files in one call**
155-
156-
```xml
157-
<apply_diff>
158-
<args>
159-
<file>
160-
<path>src/services/auth.service.ts</path>
161-
<diff>
162-
<content>
163-
<<<<<<< SEARCH
164-
:start_line:50
165-
-------
166-
const token_expiration = '15m';
167-
>>>>>>> REPLACE
168-
</content>
169-
</diff>
170-
</file>
171-
<file>
172-
<path>src/config/auth.config.ts</path>
173-
<diff>
174-
<content>
175-
<<<<<<< SEARCH
176-
:start_line:12
177-
-------
178-
rateLimit: 5,
179-
=======
180-
rateLimit: 10,
181-
>>>>>>> REPLACE
182-
</content>
183-
</diff>
184-
</file>
185-
</args>
186-
</apply_diff>
Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: Replace all occurrences of text in files using the edit_file search-and-replace tool in Roo Code.
2+
description: Replace a uniquely-identified occurrence of text in files using the edit_file search-and-replace tool in Roo Code.
33
keywords:
44
- edit_file
55
- search and replace
@@ -11,7 +11,7 @@ keywords:
1111

1212
# edit_file
1313

14-
The `edit_file` tool performs search-and-replace operations on files, replacing **all occurrences** of specified text. It provides a straightforward way to make consistent changes across a file when you need to update every instance of a pattern.
14+
The `edit_file` tool performs targeted search-and-replace operations on files. By default it replaces **exactly one** uniquely-identified occurrence and errors if multiple matches are found. It also supports a special file-creation mode when `old_string` is empty.
1515

1616
---
1717

@@ -20,43 +20,46 @@ The `edit_file` tool performs search-and-replace operations on files, replacing
2020
The tool accepts these parameters:
2121

2222
- `file_path` (required): The path of the file to modify relative to the current working directory.
23-
- `old_string` (required): The exact text to search for and replace.
24-
- `new_string` (required): The text to replace all occurrences with.
25-
- `expected_replacements` (optional): Expected number of replacements. If specified, the operation fails if the actual count doesn't match.
23+
- `old_string` (required): The exact text to search for and replace. Pass an empty string (`""`) to create a new file or append to an existing file.
24+
- `new_string` (required): The replacement text.
25+
- `expected_replacements` (optional): Expected number of replacements (defaults to 1). The operation fails if the actual count doesn't match. Use this only when intentionally replacing more than one occurrence.
2626

2727
---
2828

2929
## What It Does
3030

31-
This tool searches for an exact string in a file and replaces **all occurrences** with new text. The replacement is performed globally across the entire file, making it ideal for consistent updates like renaming variables, updating API endpoints, or fixing repeated patterns.
31+
This tool searches for an exact string in a file and replaces **exactly one** occurrence with new text. The search string must uniquely identify the target location. If multiple matches are found, the tool returns an error unless `expected_replacements` is explicitly set to match. When `old_string` is empty, the tool creates a new file or appends `new_string` to an existing file.
3232

3333
---
3434

3535
## When is it used?
3636

37-
- When renaming variables, functions, or identifiers throughout a file
38-
- When updating repeated string literals or configuration values
39-
- When fixing consistent typos or outdated terminology
40-
- When replacing all instances of a deprecated API or import path
37+
- When making a targeted change to a specific, uniquely identifiable location in a file
38+
- When updating a specific string literal or configuration value at a known location
39+
- When fixing a specific instance of a typo or outdated terminology
40+
- When replacing a uniquely-identified occurrence of a deprecated API or import path
41+
- When creating a new file or appending content to an existing file (`old_string=""`)
4142
- When you need to ensure exact match replacement without fuzzy logic
4243

4344
---
4445

4546
## Key Features
4647

47-
- Replaces **all occurrences** by default (global replacement)
48+
- Replaces **exactly one** uniquely-identified occurrence by default
49+
- Errors if multiple matches are found (unless `expected_replacements` is explicitly set)
50+
- `old_string=""` mode: creates a new file or appends content to an existing file
4851
- Exact string matching (no regex or fuzzy matching)
49-
- Optional validation via `expected_replacements` parameter
52+
- Optional `expected_replacements` for intentional multi-occurrence replacements
5053
- Shows preview of changes before applying
51-
- Fails safely if expected replacement count doesn't match actual
54+
- Fails safely if actual replacement count doesn't match `expected_replacements`
5255
- Preserves file formatting and structure
5356

5457
---
5558

5659
## Limitations
5760

5861
- Requires exact string matches (case-sensitive, whitespace-sensitive)
59-
- Always replaces all occurrences (cannot target specific instances)
62+
- Errors if the search string matches more than one location (unless `expected_replacements` is set)
6063
- Cannot use regular expressions or patterns
6164
- Not suitable for context-dependent replacements
6265
- Less precise than [`apply_diff`](/advanced-usage/available-tools/apply-diff) for complex edits
@@ -68,10 +71,10 @@ This tool searches for an exact string in a file and replaces **all occurrences*
6871
When the `edit_file` tool is invoked, it follows this process:
6972

7073
1. **Parameter Validation**: Validates required `file_path`, `old_string`, and `new_string` parameters.
71-
2. **File Loading**: Reads the target file content.
72-
3. **Search Operation**: Searches for all occurrences of `old_string` in the file.
73-
4. **Count Validation**: If `expected_replacements` is specified, validates the actual occurrence count matches.
74-
5. **Replacement**: Replaces all found occurrences with `new_string`.
74+
2. **File Creation Mode**: If `old_string` is empty (`""`), creates the file with `new_string` as content (or appends if the file already exists), then stops.
75+
3. **File Loading**: Reads the target file content.
76+
4. **Uniqueness Check**: Counts occurrences of `old_string`. If the count doesn't match `expected_replacements` (default: 1), returns an error.
77+
5. **Replacement**: Replaces the matched occurrence(s) with `new_string`.
7578
6. **User Review**: Shows a preview of changes for user approval.
7679
7. **Application**: Applies changes to the file if approved.
7780
8. **Feedback**: Reports the number of replacements made.
@@ -80,9 +83,9 @@ When the `edit_file` tool is invoked, it follows this process:
8083

8184
## Relation to Other Tools
8285

83-
- `edit_file`: Replaces **all occurrences** (this tool)
86+
- `edit_file`: Replaces **exactly one** uniquely-identified occurrence by default; supports `old_string=""` file creation (this tool)
8487
- [`edit`](/advanced-usage/available-tools/edit): Replaces **first occurrence** only (unless `replace_all: true`)
85-
- [`search_replace`](/advanced-usage/available-tools/search-replace): Also replaces **all occurrences**
88+
- [`search_replace`](/advanced-usage/available-tools/search-replace): Also replaces **exactly one** uniquely-identified occurrence
8689
- [`apply_diff`](/advanced-usage/available-tools/apply-diff): Use for precise, context-aware edits with fuzzy matching
8790

88-
These are different implementations of search-and-replace with varying default behaviors.
91+
These are different implementations of search-and-replace with varying capabilities.

docs/advanced-usage/available-tools/generate-image.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ keywords:
1212

1313
# generate_image
1414

15-
The `generate_image` tool creates new images from text prompts or modifies existing images using AI models through the OpenRouter API. This experimental feature enables visual content generation and transformation within your development workflow.
15+
The `generate_image` tool creates new images from text prompts or modifies existing images using AI models. It supports two providers: **OpenRouter** and the **Roo provider**. This experimental feature enables visual content generation and transformation within your development workflow.
1616

1717
---
1818

@@ -48,14 +48,14 @@ This tool generates images from text descriptions or applies transformations to
4848
- **Image-to-image transformation**: Edit or transform existing images
4949
- Supports multiple input formats (PNG, JPG, JPEG, GIF, WEBP)
5050
- Automatic file extension handling
51-
- Powered by OpenRouter API for access to various AI models
51+
- Powered by **OpenRouter** or the **Roo provider** for access to various AI models
5252
- Experimental feature with ongoing improvements
5353

5454
---
5555

5656
## Limitations
5757

58-
- Requires OpenRouter API configuration
58+
- Requires OpenRouter or Roo provider API configuration
5959
- Image quality depends on the AI model and prompt quality
6060
- Generation time varies based on complexity and model
6161
- Experimental feature: behavior may change in future releases
@@ -72,7 +72,7 @@ When the `generate_image` tool is invoked, it follows this process:
7272
2. **Mode Selection**:
7373
- If `image` parameter is provided: operates in **edit mode** (transform existing image)
7474
- Otherwise: operates in **generation mode** (create new image from prompt)
75-
3. **API Request**: Sends request to OpenRouter API with prompt and optional input image.
75+
3. **API Request**: Sends request to the configured provider (OpenRouter or Roo) with prompt and optional input image.
7676
4. **Image Processing**: Receives generated/edited image from the API.
7777
5. **File Saving**: Saves the image to the specified `path` with appropriate extension.
7878
6. **Feedback**: Reports success and the location of the generated image.

docs/advanced-usage/available-tools/read-file.md

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,25 @@ The `read_file` tool accepts multiple files via the `args` format. Concurrency a
2828

2929
## Parameters
3030

31-
The tool accepts parameters in two formats depending on your configuration:
31+
The tool accepts parameters in two formats:
3232

3333
### Standard Format (Single File)
3434

3535
- `path` (required): The path of the file to read relative to the current working directory
36-
- `start_line` (optional): The starting line number to read from (1-based indexing)
37-
- `end_line` (optional): The ending line number to read to (1-based, inclusive)
38-
39-
:::note Legacy Format
40-
While the single-file parameters (`path`, `start_line`, `end_line`) are still supported for backward compatibility, we recommend using the newer `args` format for consistency and future compatibility.
36+
- `mode` (optional): Reading mode — `"slice"` (default) or `"indentation"`
37+
- `offset` (optional): 1-based line offset to start reading from (slice mode only, default: `1`)
38+
- `limit` (optional): Maximum number of lines to return (slice mode only, default: `2000`)
39+
- `indentation` (optional): Indentation-mode options — only used when `mode="indentation"`:
40+
- `anchor_line` (required): 1-based line number to anchor the extraction. The tool extracts the complete semantic code block (function, class, method) containing this line.
41+
- `max_levels` (optional): Maximum indentation levels to include above the anchor.
42+
- `include_siblings` (optional): Whether to include sibling blocks at the same indentation level.
43+
- `include_header` (optional): Whether to include file header content (imports, module-level comments) at the top of output.
44+
- `max_lines` (optional): Hard cap on lines returned in indentation mode.
45+
46+
:::note Mode Summary
47+
- **Slice mode** (default): Reads lines sequentially from `offset` up to `limit` lines. Use for initial file exploration or reading a specific line range.
48+
- **Indentation mode**: Extracts complete, syntactically valid code blocks around `anchor_line` based on indentation hierarchy. Preferred when you have a target line number (e.g., from search results or error messages) and need the entire function/class without mid-function truncation.
49+
- **`start_line` and `end_line` do not exist** as parameters. Use `offset` and `limit` for range reads in slice mode.
4150
:::
4251

4352
### Enhanced Format (Multi-File)
@@ -147,7 +156,7 @@ When the `read_file` tool is invoked, it follows this process:
147156
The tool uses a clear decision hierarchy to determine how to read a file:
148157

149158
1. **First Priority: Explicit Line Range**
150-
- Legacy single‑file format: both `start_line` and `end_line` must be provided for a range read; otherwise it reads normally.
159+
- Single‑file format: specify `offset` and `limit` for a range read in slice mode, or use `anchor_line` in indentation mode.
151160
- Multi‑file `args` format: specify one or more `line_range` entries per file.
152161
- Range reads stream only the requested lines and bypass `maxReadFileLine`, taking precedence over other options.
153162

@@ -160,7 +169,7 @@ The tool uses a clear decision hierarchy to determine how to read a file:
160169

161170
3. **Third Priority: Automatic Truncation for Large Text Files**
162171
- Applies only when all of the following are true:
163-
- Neither `start_line` nor `end_line` is specified.
172+
- No `offset`/`limit` range is specified (slice mode) and no `anchor_line` is provided (indentation mode).
164173
- The file is identified as a text‑based file (not binary like PDF/DOCX/XLSX/IPYNB).
165174
- The file's total line count exceeds the `maxReadFileLine` setting (configurable; UI default may be 500; backend uses `-1`—no line limit—when unset).
166175
- When automatic truncation occurs:
@@ -208,14 +217,14 @@ To read the complete content of a file:
208217

209218
### Reading Specific Lines
210219

211-
To read only a specific range of lines (e.g., 46-68):
220+
To read only a specific range of lines (e.g., lines 46-68), use `offset` and `limit` in slice mode:
212221

213222
**Input:**
214223
```xml
215224
<read_file>
216225
<path>src/app.js</path>
217-
<start_line>46</start_line>
218-
<end_line>68</end_line>
226+
<offset>46</offset>
227+
<limit>23</limit>
219228
</read_file>
220229
```
221230

@@ -337,12 +346,12 @@ This behavior ensures that:
337346
- You receive guidance to use `line_range` for targeted reads
338347
- Stream errors are handled gracefully
339348

340-
**Example with line_range for targeted reading:**
349+
**Example with offset/limit for targeted reading:**
341350
```xml
342351
<read_file>
343352
<path>logs/massive-debug.log</path>
344-
<start_line>1000</start_line>
345-
<end_line>1100</end_line>
353+
<offset>1000</offset>
354+
<limit>101</limit>
346355
</read_file>
347356
```
348357

@@ -639,9 +648,9 @@ This allows Roo to analyze documentation, visual diagrams, configuration, and sp
639648
## Troubleshooting
640649

641650
- Range read returns error
642-
- Cause: `start_line`/`end_line` invalid or `start_line > end_line`
643-
- Fix: Provide both `start_line` and `end_line` as positive integers with `start_line ≤ end_line`; or use `args` with one or more `line_range` entries.
644-
- Prevention: Prefer `line_range` in the multifile format for targeted reads.
651+
- Cause: Invalid `offset` or `limit` values (e.g., non-positive integers).
652+
- Fix: Use `offset` (1-based starting line) and `limit` (max lines to return) as positive integers in slice mode; or use `anchor_line` in indentation mode; or use the multi-file `args` format with `line_range` entries.
653+
- Prevention: Prefer the multi-file `args` format with `line_range` for targeted reads across multiple files.
645654

646655
- Large file returned a preview
647656
- Cause: File exceeded token budget or the large‑file tokenization threshold; a preview was returned.

0 commit comments

Comments
 (0)