Skip to content

Read

Read a file from the workspace and return its content as cat -n-style numbered lines.

ParamTypeRequiredDefaultNotes
file_pathstringyesAbsolute or workspace-relative path.
offsetnumberno11-based line to start reading at.
limitnumberno2000Maximum lines to return.
  • Path goes through Workspace.Resolve first. Any path that resolves outside the workspace is rejected.
  • Output format: LINENO\tCONTENT\n per line — standard cat -n shape.
  • On success, the path is recorded in the session’s read-tracker. This is the gate that Edit and overwriting Write check.
  • If the target doesn’t exist or is a directory, returns an error result.
  • If offset exceeds total line count, returns an error result.
1 package main
2
3 import "fmt"
4
5 func main() { fmt.Println("hello") }
  • Single lines must be ≤ 1 MiB (bufio.Scanner token cap). Minified JS/CSS with no newlines beyond that limit returns bufio.Scanner: token too long.
  • Binary files with embedded NULs are not specifically detected — the scanner splits on \n and garbage may be emitted. Read is intended for text.
  • Offsets < 1 are treated as 1.
  • Edit — requires a prior Read of the edited file.
  • Write — requires a prior Read when overwriting an existing file.
  • Glob — find paths, then Read them.