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-persistent-term

v0.3.1

Published

Integrated terminal panel for pi coding agent — persistent PTY shell, colored overlay, LLM tools

Readme

pi-persistent-term

Integrated terminal panel for the pi coding agent. Provides a persistent PTY shell inside pi — state (cwd, virtualenvs, environment variables) survives across calls, unlike pi's built-in bash tool which spawns a fresh subshell each time.

Features

  • Persistent shellcd, source .venv/bin/activate, export, etc. all carry over between calls
  • Terminal overlay/term or Ctrl+\`` opens a full-color interactive panel, Ctrl+Q` returns to pi
  • LLM toolsrun_in_terminal, write_terminal, read_terminal let the LLM drive the shell
  • Context injection — recent terminal output is automatically prepended to every LLM prompt
  • Colored display — uses @xterm/headless for proper terminal emulation in the overlay
  • ScrollbackPgUp/PgDn to scroll, Shift+PgUp/Shift+PgDn for fine scroll

Installation

git clone https://github.com/vahidkowsari/pi-persistent-term
cd pi-persistent-term
npm install
pi install .

Commands

| Command | Description | |---|---| | /term | Open terminal overlay | | /term-clear | Clear the terminal buffer | | /term-restart | Restart the terminal shell process | | /term-context | Toggle auto-injecting terminal output into LLM prompts | | /monitor-stop | Stop the currently monitored background process | | `Ctrl+`` | Shortcut to open terminal overlay |

Keybindings (inside overlay)

| Key | Action | |---|---| | Ctrl+Q | Close overlay, return to pi | | Ctrl+C | Interrupt running process | | PgUp / PgDn | Scroll by page | | Shift+PgUp / Shift+PgDn | Scroll by 5 lines |

LLM Tools

monitor_process

Start, stop, or check a background process monitor. Output is captured from a child process (separate from the PTY shell) and can optionally be pushed into the conversation in real-time.

# Silent mode — output buffered, readable via read_terminal
monitor_process(action="start", command="npm run build -- --watch")

# React mode — each output chunk triggers a new LLM turn
monitor_process(action="start", command="pytest tests/ -v", react=True)

# Stop the monitor
monitor_process(action="stop")

# Check what's running
monitor_process(action="status")

Silent vs react mode:

| Mode | Behavior | Best for | |---|---|---| | react=false (default) | Output buffered quietly, check with read_terminal | Dev servers, chatty watchers | | react=true | Each output chunk → new LLM turn | Test runners, log monitors, error watching |

Note: The monitor spawns an independent child process using the session's cwd and outer environment. It does not inherit PTY shell state (active virtualenvs, cds inside the shell). Prefix with source .venv/bin/activate && when needed. Only one monitor can run at a time.

run_in_terminal

Runs a command in the persistent PTY shell and waits for it to complete (sentinel-based). Returns the full output. Best for commands that finish — npm install, pytest, git status, etc.

run_in_terminal("npm install")
run_in_terminal("pytest tests/", wait_ms=60000)

write_terminal

Sends raw text or keypresses to the shell. Use for interactive prompts.

write_terminal("yes\n")
write_terminal("\x03")   # Ctrl+C

read_terminal

Reads recent output from the terminal buffer (includes monitor output when running).

read_terminal(lines=100)

Tool comparison

| | bash tool | run_in_terminal | monitor_process | |---|---|---|---| | Shell state | Fresh subshell | Persistent PTY | Own child process | | Blocking | Yes | Yes (sentinel) | No — background | | Output delivery | On completion | On completion | Push (react) or buffer | | Infinite processes | ❌ timeout only | ❌ timeout only | ✅ natural fit | | LLM reacts in real-time | ❌ | ❌ | ✅ react mode | | Best for | Stateless one-offs | Stateful commands | Watchers, log monitors |

Requirements

  • pi coding agent installed globally
  • pi-interactive-shell installed globally (provides @xterm/headless)
  • Node.js ≥ 18
  • macOS or Linux (node-pty requires native compilation)

Architecture

  • PtyManager — wraps node-pty, manages the shell process lifecycle
  • MonitorManager — spawns an independent child_process for background monitoring; buffers output and flushes every 750ms (or at 4KB) into the pi conversation via pi.sendMessage({ triggerTurn: true }) in react mode
  • XtermBuffer — wraps @xterm/headless for display only; renders colored lines for the overlay from raw PTY data
  • SimpleBuffer — plain-text append buffer for read_terminal and sentinel-based command completion detection in run_in_terminal; also receives monitor output so read_terminal sees it

The two buffers serve different purposes: xterm is a screen emulator (viewport model) which handles display correctly but can't be used for line-based output capture. SimpleBuffer handles the text side reliably.