Read
read_slice
Read a targeted, hash-verified slice of source code instead of loading an entire file.
read_slice fetches only the exact symbol body, SFC block, or line range you need after orienting with map_workspace, inspect_file, query_graph, or search_code.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
source_ref | string | — | Hash-verified handle (ref:<sha8>:<start>-<end>@<path>) returned by another tool. |
symbol_id | string | — | Stable symbolId handle to read its exact declaration body. |
path | string | — | File path (used together with symbol, block, or lines). |
symbol | string | — | Symbol name inside path. |
block | 'script' | 'scriptSetup' | 'template' | 'style' | — | Specific single-file component block to read. |
lines | [number, number] | — | Explicit 1-based inclusive [startLine, endLine] range. |
context_lines | integer (0..20) | 2 | Extra surrounding lines of context. |
max_lines | integer (1..400) | 80 | Maximum lines returned per call (SLICE_TRUNCATED diagnostic if exceeded). |
root | string | session root | Workspace root directory. |
max_bytes | integer (>= 512) | 16384 | Maximum UTF-8 response size. |
Safety Checks
- Stale file detection: Every
source_refembeds the first 8 hex characters of the file's SHA-256 hash. If the file changed on disk since the handle was issued,read_slicereturns[STALE_SOURCE]instead of returning shifted lines. - Workspace boundary check: Paths escaping
root(such as../../../etc/passwd) are rejected with[WORKSPACE_BOUNDARY_ERROR]. - No index required: Direct
read_slicecalls read from disk and work even beforestrata inithas run.