Tools

edge-pi provides 7 built-in tools for file system operations and command execution. Each tool is a factory function that returns a Vercel AI SDK tool() definition.

Tool Sets

Tools are grouped into pre-configured sets. You can also create individual tools with the factory functions.

import {
  createCodingTools,    // read, bash, edit, write
  createReadOnlyTools,  // read, grep, find, ls
  createAllTools,       // all 7 tools
} from "edge-pi";

const tools = createAllTools(process.cwd());

read

Read file contents with optional offset and line limit.

import { createReadTool } from "edge-pi";
const readTool = createReadTool(process.cwd());

Parameters

NameTypeRequiredDescription
pathstringYesFile path (relative or absolute). Supports ~ expansion.
offsetnumberNoLine number to start reading from (1-indexed).
limitnumberNoMaximum number of lines to read.

Output


bash

Execute shell commands in the working directory.

import { createBashTool } from "edge-pi";
const bashTool = createBashTool(process.cwd());

Parameters

NameTypeRequiredDescription
commandstringYesThe bash command to execute.
timeoutnumberNoTimeout in seconds.

Output


edit

Make surgical edits to files by matching exact text and replacing it.

import { createEditTool } from "edge-pi";
const editTool = createEditTool(process.cwd());

Parameters

NameTypeRequiredDescription
pathstringYesFile path to edit.
oldTextstringYesText to find. Must match exactly (or via fuzzy normalization).
newTextstringYesReplacement text.

Behavior


write

Create or overwrite files.

import { createWriteTool } from "edge-pi";
const writeTool = createWriteTool(process.cwd());

Parameters

NameTypeRequiredDescription
pathstringYesFile path to write.
contentstringYesContent to write.

Behavior


grep

Search file contents with regex or literal patterns. Uses ripgrep when available, with a built-in fallback.

import { createGrepTool } from "edge-pi";
const grepTool = createGrepTool(process.cwd());

Parameters

NameTypeRequiredDescription
patternstringYesRegex or literal search pattern.
pathstringNoDirectory to search in.
globstringNoFile glob filter (e.g., *.ts).
ignoreCasebooleanNoCase-insensitive search.
literalbooleanNoTreat pattern as a literal string.
contextnumberNoLines of context before and after matches.
limitnumberNoMaximum matches (default: 100).

Behavior


find

Find files by glob pattern. Uses fd when available, with a built-in fallback.

import { createFindTool } from "edge-pi";
const findTool = createFindTool(process.cwd());

Parameters

NameTypeRequiredDescription
patternstringYesGlob pattern (e.g., **/*.ts).
pathstringNoDirectory to search in.
limitnumberNoMaximum results (default: 1000).

Behavior


ls

List directory contents with metadata.

import { createLsTool } from "edge-pi";
const lsTool = createLsTool(process.cwd());

Parameters

NameTypeRequiredDescription
pathstringNoDirectory to list (defaults to cwd).
limitnumberNoMaximum entries (default: 500).

Behavior


Custom Tools

You can add custom tools using the tools config option:

import { CodingAgent } from "edge-pi";
import { tool } from "ai";
import { z } from "zod";

const myTool = tool({
  description: "Get the current weather",
  parameters: z.object({
    city: z.string().describe("City name"),
  }),
  execute: async ({ city }) => {
    return `Weather in ${city}: Sunny, 72°F`;
  },
});

const agent = new CodingAgent({
  model,
  tools: { weather: myTool },
});