cape.agent.skills.fileread: LLM-driven reading of repo files

This module defines the built-in agent skill "file-reader", which teaches the CAPE agent how to read any text file in the repo in which the agent is launched, subject to a file-size limit of about 2 MB (MAX_READ_BYTES). Editing files is deliberately out of scope here; it is restricted by the allow-list of the file-editor skill (see cape.agent.skills.fileedit).

The skill provides one tool:

  • read_file(): read a file with line numbers, truncating large files to their first and last lines

This module also hosts the path-resolution helpers get_rootdir() and resolve_fname(), which are shared with cape.agent.skills.fileedit.

Every tool resolves any symlinks in the target file’s path and rejects files outside the repo root folder.

cape.agent.skills.fileread.read_file(fname: str) → dict

Read a repo file, prefixing each line with its number

The file must be inside the repo root folder and no larger than MAX_READ_BYTES. Large files are truncated to the first HEAD_LINES and last TAIL_LINES lines.

Call:
>>> result = read_file(fname)
Inputs:
fname: str

Name of file to read; must be inside the repo root folder and smaller than 2 MB

Outputs:
result: dict

Keys include success, file, n_lines, content, and truncated

cape.agent.skills.fileread.resolve_fname(fname) → tuple | dict

Resolve a file name and check that it is inside the root folder

Returns a tuple (fabs, relname) with the resolved absolute path and the POSIX-style name relative to the root folder, or an error dict with "success": False.