Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

File Operations

read_file

Read the contents of a file at a given path.

Permission: Read

Parameters

NameTypeRequiredDescription
pathstringyesThe file path to read
offsetintegernoLine number to start reading from (0-based)
limitintegernoMaximum number of lines to read

Examples

Read an entire file:

agsh [r] > show me the contents of src/main.rs

Read lines 10-20:

agsh [r] > show me lines 10 through 20 of src/main.rs

The agent will call read_file with offset: 10 and limit: 10.


edit_file

Make a string replacement in a file. Replaces the first occurrence of old_string with new_string.

Permission: Write

Parameters

NameTypeRequiredDescription
pathstringyesThe file path to edit
old_stringstringyesThe exact string to find and replace
new_stringstringyesThe replacement string

Behavior

  • Reads the file, performs the replacement, and writes it back.
  • Only the first occurrence of old_string is replaced.
  • If old_string is not found, the tool returns an error message (without modifying the file).

Examples

agsh [w] > change the function name "foo" to "bar" in src/lib.rs
agsh [w] > fix the typo "recieve" to "receive" in README.md

write_file

Create or overwrite a file with the given content.

Permission: Write

Parameters

NameTypeRequiredDescription
pathstringyesThe file path to write
contentstringyesThe content to write to the file

Behavior

  • Creates parent directories if they do not exist.
  • Overwrites the file if it already exists.

Examples

agsh [w] > create a new file called hello.py that prints "hello world"
agsh [w] > write a .gitignore file for a Rust project