Skip to content

Repository files navigation

pi-callscript

pi-callscript

Pi package npm Bun Effect

pi-callscript lets Pi run several tool calls as one checked script. It supports parallel work, dependencies, decision checkpoints, background jobs, and file rollback.

Requirements

  • Pi running from npm or Node.js
  • Node.js 22.19 or newer

Install

pi install npm:pi-callscript

Restart Pi, or reload packages in an active session:

/reload
/callscript status

Install from GitHub or a local checkout when needed:

pi install git:github.com/codewithkenzo/pi-callscript
pi install /path/to/pi-callscript

Use

CallScript starts enabled. Ask Pi to use it when work needs several related tool calls. You do not need to write CallScript code.

Example requests:

Use CallScript to inspect package scripts and source imports in parallel.

Use CallScript to snapshot these files, apply the edits, then run focused checks.

CallScript can:

  • Run independent calls in parallel.
  • Pass results between dependent calls.
  • Call built-in Pi tools and installed extension tools.
  • Pause before queued work so Pi can continue, stop, or revise it.
  • Track background jobs.
  • Restore files from a snapshot.

Pi shows each operation in its normal tool view. Use Ctrl+O to expand details.

Commands

Command Purpose
/callscript status Show mode, fixed tools, and Pi bridge status
/callscript on Enable the callscript tool
/callscript off Disable the callscript tool
/callscript jobs Show background jobs
/callscript doctor Show runtime and output limits
/callscript reload Reload config while preserving retained state
/callscript reset Cancel owned jobs and clear retained state

off removes only callscript. Other Pi tools keep their current state.

Configuration

Global config: ~/.pi/agent/callscript.json

Project config: .pi/callscript.json

Project values override global values.

{
  "mode": "on",
  "limits": {
    "maxSteps": 30,
    "maxItemsPerStep": 100,
    "maxTotalCalls": 200,
    "maxConcurrency": 12,
    "maxCallResultBytes": 10485760
  },
  "httpTimeoutMs": 30000,
  "maxHttpResultBytes": 5242880
}

File and shell calls use the current Pi working directory. run uses PowerShell on Windows and Bash on Linux and macOS.

Pi's native names work too: bash is run, grep is search, ls is list. Every other registered Pi tool with a valid identifier name is callable directly, for example hypa_shell({ command }). Names and schemas come from tools({ query }). Other names, and tools registered after the last reload, go through pi({ tool, args }). The prompt lists no per-tool schemas, so it stays the same however many tools are installed.

A failing call, including a timeout, fails the run. Wrap it in try/catch, or pass { onError: "skip" } as the call's second argument to continue with undefined. Returned values are capped at about 10 KiB (maxOutputBytes, up to 20 KiB); full values stay usable inside the script, so page by returning slices. Scripts cannot define local helper functions that call tools; write the call inline.

Compatibility

Supports Pi 0.84.4 and Pi 1.x starting at 1.0.2. Pi 1.0 uses native nested-tool execution; Pi 0.84.4 uses the optional legacy bridge. Compatibility CI checks locked, legacy, and latest Pi packages. The latest-Pi matrix runs weekly and on manual dispatch; core checks run on Linux, macOS, and Windows.

A standalone compiled Pi binary cannot expose its tool registry to this extension. Fixed CallScript tools still work, and /callscript status reports that the Pi bridge is unavailable.

Optional agent skill

The included skill teaches Pi when to use CallScript and how to keep scripts small.

npx pi-callscript

Or with Bun:

bunx pi-callscript

This installs SKILL.md at ~/.agents/skills/pi-callscript/.

Development

git clone https://github.com/codewithkenzo/pi-callscript.git
cd pi-callscript
bun install
bun run check
bun run smoke

bun run matrix tests cold install, source, built output, packed package, user extension, and reload paths.

Releases

Packages

Used by

Contributors

Languages