read_file_range
Read a targeted range from a file by line numbers or content anchors, streaming large files and returning a content hash to keep edits safe.
Instructions
Read a contiguous span of a file, addressed by anchors (primary) or line numbers (fallback). Streams large files and returns a content_hash for staleness-guarded edits.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute or workspace-relative path to the file. | |
| to_line | No | 1-based end line, inclusive. Supports negative indexing. Mutually exclusive with to_anchor. | |
| encoding | No | File encoding. Default: utf-8. Pass utf-8-sig to strip a BOM. | utf-8 |
| from_line | No | 1-based start line. Supports negative indexing (-1 = last line). Mutually exclusive with from_anchor. | |
| to_anchor | No | Stop at the matching line after the start (inclusive). Mutually exclusive with to_line. | |
| from_anchor | No | Start at the matching line (inclusive, substring, case-sensitive). Mutually exclusive with from_line. | |
| project_root | No | Sets (and remembers) the project root for resolving relative paths for this and subsequent calls in the session. | |
| to_anchor_total | No | Expected total occurrences of to_anchor after the start. Optional: if omitted, the ambiguity guard is skipped and the to_anchor_occurrence-th match after the start is selected. Supply a value to re-enable the guard (ANCHOR_AMBIGUOUS on mismatch). | |
| max_output_chars | No | Maximum number of characters of content to return. If the resolved span exceeds this budget, OUTPUT_TOO_LARGE is returned (reporting the actual size) instead of a truncated body. | |
| from_anchor_total | No | Expected total occurrences of from_anchor in the file. | |
| to_anchor_occurrence | No | Which occurrence of to_anchor (after the start) to use. | |
| from_anchor_occurrence | No | Which occurrence of from_anchor to use (1-based). |