ollama-code

Ollama Code file system tools

Ollama Code provides a comprehensive suite of tools for interacting with the local file system. These tools allow the model to read from, write to, list, search, and modify files and directories, all under your control and typically with confirmation for sensitive operations.

Note: All file system tools operate within a rootDirectory (usually the current working directory where you launched the CLI) for security. Paths that you provide to these tools are generally expected to be absolute or are resolved relative to this root directory.

1. list_directory (ListFiles)

list_directory lists the names of files and subdirectories directly within a specified directory path. It can optionally ignore entries matching provided glob patterns.

2. read_file (ReadFile)

read_file reads and returns the content of a specified file. This tool handles text, images (PNG, JPG, GIF, WEBP, SVG, BMP), and PDF files. For text files, it can read specific line ranges. Other binary file types are generally skipped.

3. write_file (WriteFile)

write_file writes content to a specified file. If the file exists, it will be overwritten. If the file doesn’t exist, it (and any necessary parent directories) will be created.

4. glob (Glob)

glob finds files matching specific glob patterns (e.g., src/**/*.ts, *.md), returning absolute paths sorted by modification time (newest first).

5. grep_search (Grep)

grep_search searches for a regular expression pattern within the content of files in a specified directory. Can filter files by a glob pattern. Returns the lines containing matches, along with their file paths and line numbers.

grep_search examples

Search for a pattern with default result limiting:

grep_search(pattern="function\\s+myFunction", path="src")

Search for a pattern with custom result limiting:

grep_search(pattern="function", path="src", limit=50)

Search for a pattern with file filtering and custom result limiting:

grep_search(pattern="function", glob="*.js", limit=10)

6. edit (Edit)

edit replaces text within a file. By default it requires old_string to match a single unique location; set replace_all to true when you intentionally want to change every occurrence. This tool is designed for precise, targeted changes and requires significant context around the old_string to ensure it modifies the correct location.

These file system tools provide a foundation for Ollama Code to understand and interact with your local project context.