@mammothb/pi-eval

A pi extension that adds an eval tool for executing JavaScript and Python code in isolated subprocesses

Packages

Package details

extension

Install @mammothb/pi-eval from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@mammothb/pi-eval
Package
@mammothb/pi-eval
Version
2.1.1
Published
Jun 13, 2026
Downloads
1,117/mo · 1,117/wk
Author
mammothb
License
MIT
Types
extension
Size
24.5 KB
Dependencies
1 dependency · 4 peers
Pi manifest JSON
{
  "extensions": [
    "./index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-eval

A pi extension that adds an eval tool for executing JavaScript and Python code in isolated subprocesses.

Usage

Once installed, the LLM can call the eval tool to run code snippets without managing temp files. Each call spawns a fresh subprocess — no state persists between calls.

Tool parameters

Parameter Type Default Description
language string (required) Programming language: "javascript" or "python"
code string (required) Code to execute
cwd string agent's cwd Working directory for the subprocess

Runtime configuration

Python binary and Node.js module paths are configured via JSON files, not per-call parameters:

  • Global: ~/.pi/agent/pi-eval.json
  • Project: .pi/pi-eval.json (overrides global)
{
  "pythonPath": ".venv/bin/python3",
  "nodeModulesPath": "./node_modules"
}

Relative paths in project configs are resolved relative to the project root.

Features

  • JavaScript: Writes code to a temp file, spawns node as a subprocess. Console output is captured as labeled STDOUT: / STDERR: sections. Set nodeModulesPath in config to make project packages available via require().
  • Python: Spawns python3 with -c, capturing stdout/stderr identically. By default, searches PATH for python3 (falling back to /usr/bin/python3, /usr/local/bin/python3). Set pythonPath in config to target a venv or custom binary.
  • Safety: 30-second timeout, 1 MB output cap, Escape to cancel a running evaluation.