ollie/prompts/tools-file.md

2.3 KiB

File Tools

Use file_* tools for all file I/O. Do not substitute shell commands (cat, sed, grep, find, echo >). Args must be a JSON array of strings.


file_read

Read a file with line numbers. Prefer segments over full reads.

Calling convention:

call_tool: calls=[{tool: "file_read", args: ["/abs/path", "start", "end"]}]
call_tool: calls=[{tool: "file_read", args: ["/abs/path"]}]
call_tool: calls=[{tool: "file_read", args: ["/abs/path", "--head=50"]}]
  • start/end: 1-indexed, inclusive. Max segment: 2000 lines.
  • No start/end: reads up to 500 lines from line 1.
  • Batch parallel reads by combining multiple calls.

Constraints:

  • Absolute paths only.
  • Never read full session files ($OLLIE/s/*/chat, $OLLIE/s/*/log) or tool scripts — use $OLLIE/s/${SID}/t/idx instead.

file_write

Create or overwrite a file. Produces a unified diff.

Calling convention:

call_tool: calls=[{tool: "file_write", args: ["/abs/path", "content"]}]

Constraints:

  • Absolute paths only. Parent directory must exist.

file_edit

Replace text in a file. Has fuzzy matching (whitespace/indent flexible).

Calling convention:

call_tool: calls=[{tool: "file_edit", args: ["/abs/path", "old_string", "new_string"]}]
call_tool: calls=[{tool: "file_edit", args: ["/abs/path", "old_string", "new_string", "replace_all=true"]}]

Constraints:

  • Absolute paths only.
  • Errors if old_string matches multiple locations — add surrounding context to disambiguate, or use replace_all=true.

file_glob

Find files by glob pattern, sorted by mtime (newest first).

Calling convention:

call_tool: calls=[{tool: "file_glob", args: ["*.go", "/abs/search/dir"]}]
call_tool: calls=[{tool: "file_glob", args: ["**/*.go"]}]
  • First arg: glob pattern. Second arg: search directory (defaults to cwd).

file_grep

Search file contents with ripgrep. Capped at 50 matches by default.

Calling convention:

call_tool: calls=[{tool: "file_grep", args: ["pattern", "--path=/abs/dir"]}]
call_tool: calls=[{tool: "file_grep", args: ["TODO", "--path=src/", "--glob=*.go", "-i"]}]

Flags: --path=<dir>, --mode=files_with_matches|content|count, --glob=<pattern>, --type=<type>, -i, -A <n>, -B <n>, -C <n>, --multiline, --head=<n>, --offset=<n>.