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: docs/advanced-usage/available-tools/read-file.md
+39-8Lines changed: 39 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,14 +19,18 @@ The tool accepts parameters in two formats depending on your configuration:
19
19
-`start_line` (optional): The starting line number to read from (1-based indexing)
20
20
-`end_line` (optional): The ending line number to read to (1-based, inclusive)
21
21
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
+
22
26
### Enhanced Format (Multi-File - Experimental)
23
27
24
28
When [Concurrent File Reads](/features/experimental/concurrent-file-reads) is enabled, the tool accepts an `args` parameter containing multiple file entries:
25
29
26
30
-`args` (required): Container for multiple file specifications
27
31
-`file` (required): Individual file specification
28
32
-`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")
30
34
31
35
---
32
36
@@ -119,11 +123,12 @@ The tool uses a clear decision hierarchy to determine how to read a file:
119
123
- This applies only when **all** of the following conditions are met:
120
124
- Neither `start_line` nor `end_line` is specified.
121
125
- 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).
123
127
- When automatic truncation occurs:
124
128
- The tool reads only the *first*`maxReadFileLine` lines.
125
129
- It appends a notice indicating truncation (e.g., `[Showing only 500 of 1200 total lines...]`).
126
130
- 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.
127
132
128
133
3.**Default Behavior: Read Entire File**
129
134
- 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
203
208
[Showing only 500 of 1500 total lines. Use start_line and end_line to read specific ranges.]
204
209
// Optional: Source code definitions summary might appear here for code files
205
210
```
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.)*
207
238
208
239
### Attempting to Read a Non-Existent File
209
240
@@ -234,7 +265,7 @@ If the file is excluded by rules in a `.rooignore` file:
234
265
235
266
**Simulated Output (Error):**
236
267
```
237
-
Error: Access denied to file '.env' due to .rooignore rules.
268
+
Error: Access denied by .rooignore rules
238
269
```
239
270
240
271
---
@@ -305,12 +336,12 @@ To read specific sections from multiple files:
305
336
<args>
306
337
<file>
307
338
<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>
310
341
</file>
311
342
<file>
312
343
<path>src/utils.ts</path>
313
-
<lines>10-25</lines>
344
+
<line_range>10-25</line_range>
314
345
</file>
315
346
</args>
316
347
</read_file>
@@ -382,7 +413,7 @@ When some files are approved and others are denied or blocked:
0 commit comments