npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@4fu/pi-python

v0.4.8

Published

Execute Python code in pi as persistent background tasks

Readme

pi-python

Latest release

Persistent Python execution for pi. Long-running scripts, local analysis, and temporary services keep running while the agent moves on, with results delivered through durable notifications and snapshots.

Why pi-python

Pi can launch Python from a shell, but that does not give the agent a durable execution lifecycle. pi-python turns each run into managed work that remains observable after the original tool call has returned.

  • Keep working while Python runs — execution is detached by default and survives later tool calls, wait timeouts, tool aborts, /reload, and pi restarts.
  • Know when work is ready — optional literal readiness and automatic terminal notifications remove the need for repeated polling.
  • Inspect results safely — every query returns a bounded snapshot of current state and latest output without consuming the log.
  • Stop the whole workload — explicit cancellation terminates the Python process and its descendants rather than leaving child processes behind.
  • Readable in the TUI — source is syntax-highlighted, output previews are ANSI-safe, and active tasks remain visible with status and duration.

The extension intentionally manages independent Python processes rather than emulating a shared notebook or REPL session.

Features

Persistent Python tasks

Every Python invocation creates a persistent task and returns immediately unless the current turn explicitly needs to wait. Waiting can end at completion or at an optional case-sensitive readiness phrase, including one split across output chunks; a timeout or cancelled wait never stops the program.

The returned task ID lets the model inspect the latest snapshot, wait again, or explicitly terminate the complete process tree. Snapshots are bounded and repeatable rather than consumable. Task IDs belong to the parent session that launched them. Active tasks recover across /reload and pi restarts, and terminal records are retained for 24 hours.

Task notifications and TUI

Readiness, completion, failure, and cancellation are reported automatically. Notification state is durable and deduplicated, and notifications aggregate with other installed @4fu background-task plugins. Explicitly retrieving a ready or terminal result cancels its pending notification.

Tool rows use a compact contiguous layout with Python syntax highlighting, ANSI-safe output previews, duration, and expandable details. Active tasks share the Tasks widget with other installed @4fu task plugins; /tasks shows active and recently retained terminal tasks. Upgrade related task plugins together so they use compatible shared task presentation packages.

Configuration

Configuration is optional. Create ~/.pi/agent/python.json and run /reload after changing it:

{
  "executable": "auto",
  "utf8": true,
  "unbuffered": true
}

| Setting | Default | Effect | | --- | --- | --- | | executable | "auto" | Tries python3, then python. Set an absolute path to select a specific Python 3 executable. | | utf8 | true | Defaults PYTHONIOENCODING=utf-8 and PYTHONUTF8=1 unless already set. | | unbuffered | true | Defaults PYTHONUNBUFFERED=1 and launches Python with -u. |

Environment variables override the JSON file:

| Environment variable | Setting | | --- | --- | | PI_PYTHON_CONFIG | Alternate configuration file path | | PI_PYTHON_EXECUTABLE | executable | | PI_PYTHON_UTF8 | utf8 | | PI_PYTHON_UNBUFFERED | unbuffered |

Boolean environment values accept true/false, 1/0, yes/no, and on/off. Existing Python environment values win. Configuration is strict: unknown fields, invalid values, or an unavailable configured executable produce a visible error.

Requirements

  • Node.js 22.19 or newer.
  • Python 3, available as python3 or python, or selected with an absolute executable path.
  • macOS, Linux, or Windows wherever pi and the selected Python runtime are available.

Installation

pi install npm:@4fu/pi-python

Try it for one run without installing:

pi -e npm:@4fu/pi-python

From source

Run npm install, then add the repository path to ~/.pi/agent/settings.json:

{
  "extensions": ["/path/to/pi-python"]
}

Run /reload in pi after changing the extension.

Development

npm install
npm test
npm pack --dry-run

The test suite covers configuration, schema validation, persistent task recovery, session ownership, snapshots, notifications, readiness matching, waits, and process-tree termination.

License

MIT