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

pi-agent-shell

v0.1.0

Published

High-performance interactive shell extension for pi — OS-level read-block detection gives agents a single turn() primitive with no polling or timing heuristics

Readme

pi-agent-shell

A high-performance, general-purpose interactive shell extension for pi.

Gives AI agents a single turn() primitive to interact with any CLI program — no polling, no timing heuristics, no program-specific adapters. Uses OS-level read-block detection to know exactly when a program is waiting for input.

Install

pi install ~/Projects/pi-agent-shell

How it works

The agent interacts with shell programs through one atomic operation:

turn(sessionId, input?) → { newOutput, prompt, waitingForInput, exited }

Internally, turn() writes input to a PTY, drains output, and waits for an OS-level signal that the process is blocked on a read syscall. The agent never polls or guesses timing — every round-trip is a decision, not a timing check.

OS read-block detection

  • macOS: process state probing via ps on the leaf foreground process
  • Linux: /proc/{pid}/syscall — syscall number 0 (read) or select/epoll variants
  • Fallback: quiet-window timeout when OS probing is unavailable (CI, containers)

Tool: agent_shell

Start a session

{ "command": "python3 game.py" }
→ { "sessionId": "abc-123" }

Take a turn

{ "sessionId": "abc-123", "input": "north" }
→ { "newOutput": "You enter a dark cave.\n> ", "prompt": "> ", "waitingForInput": true }

Peek (non-blocking)

{ "sessionId": "abc-123", "peek": true }
→ { "newOutput": "...", "waitingForInput": false }

Kill a session

{ "sessionId": "abc-123", "kill": true }

Parameters

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | command | string | — | Shell command to start a new session | | sessionId | string | — | Session to interact with | | input | string | — | Text to send (appends \n if missing) | | peek | boolean | false | Non-blocking snapshot, no input | | kill | boolean | false | Terminate the session | | cwd | string | pi cwd | Working directory | | env | object | — | Additional environment variables | | timeoutMs | number | 30000 | Max wait time for turn() | | quietMs | number | 200 | Quiet-window fallback threshold |

User commands

| Command | Description | |---------|-------------| | /sessions | List all active sessions | | /attach [id] | Reattach the session overlay to watch/interact |

Session overlay

When a session is running, an overlay shows real-time output. Controls:

  • Ctrl+B — background the session (overlay hides, session keeps running)
  • Ctrl+C — kill the session
  • ↑/↓ — scroll through output

Architecture

See ARCHITECTURE.md for design details.

Development

npm test        # run tests

Limitations

  • Line-oriented programs only — full-screen TUI programs (vim, nano, htop) are not supported. The agent has better tools for file editing (read/edit/write), and most interactive CLI programs have non-interactive equivalents.
  • Unix only — requires PTY support (macOS, Linux). No Windows/ConPTY support.
  • Local processes only — no remote PTY or SSH session management.