read-file
模拟输出:
<files>
<file>
<path>src/app.ts</path>
<content>
1 | import React from 'react'
2 | import { Utils } from './utils'
3 | // ... 文件其余内容
</read_file>
模拟输出:
<file>
<path>src/services/auth.service.ts</path>
<list_code_definition_names>
class AuthService
method validateUser
method generateToken
</list_code_definition_names>
<notice>仅显示150总行中的0行。使用start_line和end_line读取特定范围。</notice>
</file>
(此模式提供文件结构的快速概览而不读取内容。)
尝试读取不存在的文件
如果指定的文件不存在:
输入:
<read_file>
<path>non_existent_file.txt</path>
</read_file>
模拟输出(错误):
Error: 在路径'non_existent_file.txt'找不到文件
尝试读取被阻止的文件
如果文件被.rooignore
规则排除:
输入:
<read_file>
<path>.env</path>
</read_file>
模拟输出(错误):
Error: 访问被.rooignore规则拒绝
多文件示例(实验性功能)
当启用并发文件读取实验性功能时,您可以使用增强的XML格式同时读取多个文件。
读取多个完整文件
同时读取多个完整文件:
输入:
<read_file>
<args>
<file>
<path>src/app.ts</path>
</file>
<file>
<path>src/utils.ts</path>
</file>
<file>
<path>src/config.json</path>
</file>
</args>
</read_file>