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

ParameterTypeDefaultDescription
source_refstring—Hash-verified handle (ref:<sha8>:<start>-<end>@<path>) returned by another tool.
symbol_idstring—Stable symbolId handle to read its exact declaration body.
pathstring—File path (used together with symbol, block, or lines).
symbolstring—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_linesinteger (0..20)2Extra surrounding lines of context.
max_linesinteger (1..400)80Maximum lines returned per call (SLICE_TRUNCATED diagnostic if exceeded).
rootstringsession rootWorkspace root directory.
max_bytesinteger (>= 512)16384Maximum UTF-8 response size.

Safety Checks

  • Stale file detection: Every source_ref embeds the first 8 hex characters of the file's SHA-256 hash. If the file changed on disk since the handle was issued, read_slice returns [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_slice calls read from disk and work even before strata init has run.