Skip to content

Commit f9a77fb

Browse files
committed
fix: update parameter names and enhance documentation for read_file tool
1 parent f1431ea commit f9a77fb

File tree

1 file changed

+39
-8
lines changed

1 file changed

+39
-8
lines changed

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

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ The tool accepts parameters in two formats depending on your configuration:
1919
- `start_line` (optional): The starting line number to read from (1-based indexing)
2020
- `end_line` (optional): The ending line number to read to (1-based, inclusive)
2121

22+
:::note Legacy Format
23+
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.
24+
:::
25+
2226
### Enhanced Format (Multi-File - Experimental)
2327

2428
When [Concurrent File Reads](/features/experimental/concurrent-file-reads) is enabled, the tool accepts an `args` parameter containing multiple file entries:
2529

2630
- `args` (required): Container for multiple file specifications
2731
- `file` (required): Individual file specification
2832
- `path` (required): The path of the file to read
29-
- `lines` (optional): Line range specification (e.g., "1-50" or "100-150")
33+
- `line_range` (optional): Line range specification (e.g., "1-50" or "100-150")
3034

3135
---
3236

@@ -119,11 +123,12 @@ The tool uses a clear decision hierarchy to determine how to read a file:
119123
- This applies only when **all** of the following conditions are met:
120124
- Neither `start_line` nor `end_line` is specified.
121125
- The file is identified as a text-based file (not binary like PDF/DOCX).
122-
- The file's total line count exceeds an internal limit (e.g., `maxReadFileLine`, often around 500 lines).
126+
- The file's total line count exceeds the `maxReadFileLine` setting (default: 500 lines).
123127
- When automatic truncation occurs:
124128
- The tool reads only the *first* `maxReadFileLine` lines.
125129
- It appends a notice indicating truncation (e.g., `[Showing only 500 of 1200 total lines...]`).
126130
- For code files, it may also append a summary of source code definitions found within the truncated portion.
131+
- **Special Case - Definitions Only Mode**: When `maxReadFileLine` is set to `0`, the tool returns only source code definitions without any file content.
127132

128133
3. **Default Behavior: Read Entire File**
129134
- If neither an explicit range is given nor automatic truncation applies (e.g., the file is within the line limit, or it's a supported binary type), the tool reads the entire content.
@@ -203,7 +208,33 @@ When reading a large text file without specifying a line range, the tool automat
203208
[Showing only 500 of 1500 total lines. Use start_line and end_line to read specific ranges.]
204209
// Optional: Source code definitions summary might appear here for code files
205210
```
206-
*(Output shows the beginning lines up to the internal limit, plus a truncation notice. Use line ranges for full access.)*
211+
*(Output shows the beginning lines up to the `maxReadFileLine` limit, plus a truncation notice. Use line ranges for full access.)*
212+
213+
### Reading Definitions Only
214+
215+
When `maxReadFileLine` is set to `0` in user settings, the tool returns only source code definitions without file content:
216+
217+
**Input:**
218+
```xml
219+
<!-- Assuming maxReadFileLine is set to 0 in user settings -->
220+
<read_file>
221+
<path>src/services/auth.service.ts</path>
222+
</read_file>
223+
```
224+
225+
**Simulated Output:**
226+
```xml
227+
<file>
228+
<path>src/services/auth.service.ts</path>
229+
<list_code_definition_names>
230+
class AuthService
231+
method validateUser
232+
method generateToken
233+
</list_code_definition_names>
234+
<notice>Showing only 0 of 150 total lines. Use start_line and end_line to read specific ranges.</notice>
235+
</file>
236+
```
237+
*(This mode provides a quick overview of file structure without reading content.)*
207238

208239
### Attempting to Read a Non-Existent File
209240

@@ -234,7 +265,7 @@ If the file is excluded by rules in a `.rooignore` file:
234265

235266
**Simulated Output (Error):**
236267
```
237-
Error: Access denied to file '.env' due to .rooignore rules.
268+
Error: Access denied by .rooignore rules
238269
```
239270

240271
---
@@ -305,12 +336,12 @@ To read specific sections from multiple files:
305336
<args>
306337
<file>
307338
<path>src/app.ts</path>
308-
<lines>1-20</lines>
309-
<lines>45-60</lines>
339+
<line_range>1-20</line_range>
340+
<line_range>45-60</line_range>
310341
</file>
311342
<file>
312343
<path>src/utils.ts</path>
313-
<lines>10-25</lines>
344+
<line_range>10-25</line_range>
314345
</file>
315346
</args>
316347
</read_file>
@@ -382,7 +413,7 @@ When some files are approved and others are denied or blocked:
382413
</file>
383414
<file>
384415
<path>src/secret-config.ts</path>
385-
<error>User denied access</error>
416+
<error>User denied access to file</error>
386417
</file>
387418
</files>
388419
```

0 commit comments

Comments
 (0)