Skip to main content
Pi provides a set of built-in tools for file system operations and shell command execution. These tools are available to the agent by default.

Import

Tool Factories

All tools are created using factory functions that accept a working directory and optional configuration.

createReadTool

Create a tool for reading file contents.
string
required
Working directory for file operations
ReadToolOptions
Input Schema:
Features:
  • Reads text files and images (jpg, png, gif, webp)
  • Auto-truncates to 2000 lines or 50KB
  • Supports offset/limit for large files
  • Images sent as base64 attachments

createWriteTool

Create a tool for writing file contents.
string
required
Working directory for file operations
WriteToolOptions
Input Schema:
Features:
  • Creates parent directories automatically
  • Overwrites existing files
  • Returns confirmation message

createEditTool

Create a tool for editing files using exact string replacement.
string
required
Working directory for file operations
EditToolOptions
Input Schema:
Features:
  • Exact string matching (no regex)
  • Fails if oldString not found
  • Fails if multiple matches without replaceAll
  • Shows unified diff of changes

createBashTool

Create a tool for executing bash commands.
string
required
Working directory for command execution
BashToolOptions
Input Schema:
Features:
  • Executes in persistent shell session
  • Streams output in real-time
  • Preserves environment variables
  • Auto-truncates output to 2000 lines or 50KB

createGrepTool

Create a tool for searching file contents using regex.
string
required
Working directory for search operations
Input Schema:
Features:
  • Full regex support
  • File filtering by glob pattern
  • Returns file paths and line numbers
  • Fast implementation using ripgrep

createFindTool

Create a tool for finding files by name pattern.
string
required
Working directory for search operations
Input Schema:
Features:
  • Glob pattern matching
  • Sorted by modification time
  • Works with any codebase size

createLsTool

Create a tool for listing directory contents.
string
required
Working directory for file operations
Input Schema:
Features:
  • Shows file sizes and types
  • Supports recursive listing
  • Sorted output

Pre-built Tool Sets

codingTools

All tools for full file system access.
Includes: read, write, edit, bash, grep, find, ls

createCodingTools

Factory for creating coding tools with custom working directory.

readOnlyTools

Read-only tools (no write, edit, or bash).
Includes: read, grep, find, ls

createReadOnlyTools

Factory for creating read-only tools with custom working directory.

Example: Custom Tool Set

Custom Operations

All tool factories support custom operations for remote file systems: