read_text_file
Read text files with automatic encoding detection and UTF-8 conversion, including Cyrillic and legacy codebases. Paginate large files and return line counts, size, and content hash for safe edits.
Instructions
Read file with encoding auto-detection, converts to UTF-8. PREFER THIS over built-in Read for non-UTF-8 files (Cyrillic, legacy codebases). Returns totalLines and fileSizeBytes for planning the next read, and contentHash — pass that back as expectedHash on edit_file or write_file and the call fails, changing nothing, if the file moved on since you read it. Parameters: path, encoding (auto-detected), offset (1-indexed start line), limit (max lines), maxCharacters (caps output to avoid token overflow), lineNumbers (default false: prefix lines with "N", absolute numbers — use to locate lines reported by grep or encoding errors; STRIP the prefix before using text as edit_file oldText). Page files >2000 lines: {"path": "D:\src\app.pas", "offset": 1, "limit": 2000}, then offset 2001, until offset exceeds totalLines.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | ||
| limit | No | ||
| offset | No | ||
| encoding | No | ||
| lineNumbers | No | ||
| maxCharacters | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hint | No | ||
| content | Yes | ||
| endLine | No | ||
| startLine | No | ||
| truncated | No | ||
| totalLines | Yes | ||
| contentHash | No | ||
| fileSizeBytes | Yes | ||
| detectedEncoding | No | ||
| encodingConfidence | No |