Skip to content

Commit 795d937

Browse files
Read file update (#114)
* Enhance documentation for read_file tool with usage examples and simulated outputs * Refactor section headers in read_file documentation for consistency
1 parent 4b20d2e commit 795d937

File tree

2 files changed

+85
-14
lines changed

2 files changed

+85
-14
lines changed

docs/features/tools/read-file.md

Lines changed: 76 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,26 +85,97 @@ The tool uses a clear decision hierarchy to determine how to read a file:
8585

8686
## Usage Examples
8787

88-
Reading an entire file:
89-
```
88+
Here are several scenarios demonstrating how the `read_file` tool is used and the typical output you might receive.
89+
90+
### Reading an Entire File
91+
92+
To read the complete content of a file:
93+
94+
**Input:**
95+
```xml
9096
<read_file>
9197
<path>src/app.js</path>
9298
</read_file>
9399
```
94100

95-
Reading specific lines (46-68) of a file:
101+
**Simulated Output (for a small file like `example_small.txt`):**
102+
```
103+
1 | This is the first line.
104+
2 | This is the second line.
105+
3 | This is the third line.
96106
```
107+
*(Output will vary based on the actual file content)*
108+
109+
### Reading Specific Lines
110+
111+
To read only a specific range of lines (e.g., 46-68):
112+
113+
**Input:**
114+
```xml
97115
<read_file>
98116
<path>src/app.js</path>
99117
<start_line>46</start_line>
100118
<end_line>68</end_line>
101119
</read_file>
102120
```
103121

104-
Reading a large file with auto-truncation:
122+
**Simulated Output (for lines 2-3 of `example_five_lines.txt`):**
123+
```
124+
2 | Content of line two.
125+
3 | Content of line three.
105126
```
127+
*(Output shows only the requested lines with their original line numbers)*
128+
129+
### Reading a Large File (Auto-Truncation)
130+
131+
When reading a large file without specifying lines and `auto_truncate` is enabled (or defaults to true based on settings):
132+
133+
**Input:**
134+
```xml
106135
<read_file>
107136
<path>src/large-module.js</path>
108-
<auto_truncate>true</auto_truncate>
137+
<auto_truncate>true</auto_truncate> <!-- Optional if default is true -->
109138
</read_file>
110139
```
140+
141+
**Simulated Output (for `large_file.log` with 1500 lines, limit 1000):**
142+
```
143+
1 | Log entry 1...
144+
2 | Log entry 2...
145+
...
146+
1000 | Log entry 1000...
147+
[... truncated 500 lines ...]
148+
```
149+
*(Output is limited to the configured maximum lines, with a truncation notice)*
150+
151+
### Attempting to Read a Non-Existent File
152+
153+
If the specified file does not exist:
154+
155+
**Input:**
156+
```xml
157+
<read_file>
158+
<path>non_existent_file.txt</path>
159+
</read_file>
160+
```
161+
162+
**Simulated Output (Error):**
163+
```
164+
Error: File not found at path 'non_existent_file.txt'.
165+
```
166+
167+
### Attempting to Read a Blocked File
168+
169+
If the file is excluded by rules in a `.rooignore` file:
170+
171+
**Input:**
172+
```xml
173+
<read_file>
174+
<path>.env</path>
175+
</read_file>
176+
```
177+
178+
**Simulated Output (Error):**
179+
```
180+
Error: Access denied to file '.env' due to .rooignore rules.
181+
```

sidebars.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,20 @@ const sidebars: SidebarsConfig = {
4141
label: 'Tool Use',
4242
items: [
4343
'features/tools/tool-use-overview',
44-
'features/tools/read-file',
45-
'features/tools/search-files',
46-
'features/tools/list-files',
47-
'features/tools/list-code-definition-names',
44+
'features/tools/access-mcp-resource',
4845
'features/tools/apply-diff',
49-
'features/tools/write-to-file',
50-
'features/tools/execute-command',
51-
'features/tools/browser-action',
5246
'features/tools/ask-followup-question',
5347
'features/tools/attempt-completion',
54-
'features/tools/switch-mode',
48+
'features/tools/browser-action',
49+
'features/tools/execute-command',
50+
'features/tools/list-code-definition-names',
51+
'features/tools/list-files',
5552
'features/tools/new-task',
53+
'features/tools/read-file',
54+
'features/tools/search-files',
55+
'features/tools/switch-mode',
5656
'features/tools/use-mcp-tool',
57-
'features/tools/access-mcp-resource',
57+
'features/tools/write-to-file',
5858
],
5959
},
6060
{

0 commit comments

Comments
 (0)