pi-just-bash-tools
v0.1.1
Published
Tools for pi-agent-core backed by just-bash
Maintainers
Readme
pi-just-bash-tools
Tools for pi backed by just-bash and IFileSystem. Provides read, write, edit, bash, grep, find, and ls tools compatible with @mariozechner/pi-agent-core.
Install
bun add pi-just-bash-tools @mariozechner/pi-agent-core @mariozechner/pi-ai just-bashUsage
pi-just-bash-tools exports tool factories and a system prompt builder. You bring your own Agent, model, and just-bash instances.
import { Agent } from "@mariozechner/pi-agent-core";
import { getModel, registerBuiltInApiProviders, streamSimple } from "@mariozechner/pi-ai";
import { Bash, InMemoryFs } from "just-bash";
import { buildSystemPrompt, createTools } from "pi-just-bash-tools";
// Register API providers (reads ANTHROPIC_API_KEY from env)
registerBuiltInApiProviders();
// Set up a virtual filesystem and bash
const fs = new InMemoryFs({
"/project/src/index.ts": 'console.log("hello world");\n',
"/project/package.json": '{ "name": "my-app" }\n',
});
const bash = new Bash({ fs, cwd: "/project" });
// Create the tools and agent
const tools = createTools(bash, fs, "/project");
const model = getModel("anthropic", "claude-sonnet-4-20250514");
const agent = new Agent({
initialState: {
systemPrompt: buildSystemPrompt(),
model,
thinkingLevel: "medium",
tools,
messages: [],
},
streamFn: streamSimple,
getApiKey: () => process.env.ANTHROPIC_API_KEY,
});
await agent.prompt("Read the package.json and add a description field.");
// Print the final filesystem state
console.log(await fs.readFile("/project/package.json", "utf-8"));See examples/create-agent.ts for a runnable version.
API
createTools(bash, fs, cwd)
Returns an array of AgentTool instances for all built-in tools.
buildSystemPrompt(meta?)
Generates a system prompt from tool metadata. Uses the built-in toolMeta by default.
Individual tool factories
Each tool can be created independently:
createReadTool(fs, cwd)createWriteTool(fs, cwd)createEditTool(fs, cwd)createBashTool(bash, cwd)createGrepTool(bash, fs, cwd)createFindTool(bash, fs, cwd)createLsTool(fs, cwd)
