read_file
Read the contents of a file at the given path.Parameters
The file path to read (relative to workspace or absolute)
Return Value
Returns the file contents as a string, or an error message if:- File not found
- Path is not a file
- File is too large (>512 KB)
- Permission denied
Example
write_file
Write content to a file at the given path. Creates parent directories if needed.Parameters
The file path to write to
The content to write to the file
Return Value
Returns a success message with the number of bytes written, or an error message.Example
edit_file
Edit a file by replacing exact text matches. The old_text must exist exactly in the file.Parameters
The file path to edit
The exact text to find and replace (must match exactly)
The text to replace with
Return Value
Returns a success message, or an error if:- File not found
- old_text not found in file (includes diff of closest match)
- old_text appears multiple times (requires more context)
Example
Error: Text Not Found
Error: Multiple Matches
list_dir
List the contents of a directory.Parameters
The directory path to list
Return Value
Returns a formatted list of directory contents with file/folder indicators, or an error message.Example
Configuration
All filesystem tools can be configured with:- workspace: Base directory for resolving relative paths
- allowed_dir: If set, restricts all operations to this directory tree
Path Resolution
Paths are resolved with the following rules:- Expand user home directory (
~) - If relative, resolve against workspace
- Resolve to absolute path
- If allowed_dir is set, verify path is within allowed directory
Size Limits
- read_file: Maximum 128,000 characters (files up to ~512 KB)
- Larger files return an error suggesting use of
exectool withhead,tail, orgrep
Implementation
Seenanobot/agent/tools/filesystem.py for full implementations:
- ReadFileTool: line 26
- WriteFileTool: line 76
- EditFileTool: line 114
- ListDirTool: line 195
Related
- Shell Tool - Execute shell commands for advanced file operations