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-streaming-guard

v0.1.12

Published

Keep Pi's TUI responsive during long streamed responses with incremental Markdown rendering

Readme

🛡️ pi-streaming-guard

Keep Pi fast while long responses are still arriving.

Long thinking traces should not make your terminal feel slower.

npm version checks pi extension license


You keep using Pi exactly the way you always do. Streaming Guard quietly keeps completed Markdown blocks around instead of asking Pi to parse, style, wrap, and pad the entire accumulated response again for every incoming delta. Long reasoning traces stay responsive, the rendered output stays the same, and there is nothing new to invoke while you work.

This is a focused compatibility bridge for Pi 0.82.x–0.85.x. It is meant to disappear once the equivalent rendering fix ships upstream.

Why Streaming Guard?

| | Behavior | What you get | | :-: | -------- | ------------ | | ⚡ | Incremental rendering | Completed Markdown blocks are reused while only changed blocks are rendered again. | | 🧠 | Same transcript | Headings, lists, links, code, thinking styles, spacing, and terminal wrapping stay intact. | | 🫥 | Invisible by default | No workflow changes, prompts, tools, or model instructions. Install it and keep using Pi. | | 🔁 | Reload safe | Reference-counted patches are restored cleanly on /reload, session replacement, and shutdown. | | 🧯 | Fails closed | Unknown Pi versions are never patched; the extension reports that it is unavailable instead. |

How it works

  1. Pi streams normally. Assistant and thinking content arrive through the existing message path.
  2. The guard retains stable work. Compatible Markdown components survive updates, and unchanged top-level tokens keep their rendered terminal lines.
  3. Pi-owned transforms stay Pi-owned. Rendered Mermaid diagrams use Pi's native path so streaming modes, width fallback, warnings, and themes remain intact.
  4. Pi draws the same output with less work. Reference-link changes, width changes, and theme invalidation still trigger the required rerenders.

The patch is intentionally narrow: it touches the exported AssistantMessageComponent and Markdown prototypes only in interactive TUI sessions, and restores both when the session runtime shuts down.

Install

Requires Node.js 22.19+ and Pi 0.82.x–0.85.x.

pi install npm:pi-streaming-guard

Then start Pi normally. The guard enables itself for interactive sessions.

From GitHub:

pi install git:github.com/monotykamary/pi-streaming-guard

From a local checkout:

bun install
pi install /absolute/path/to/pi-streaming-guard

For one development run:

pi -e /absolute/path/to/pi-streaming-guard

Commands

| Command | Action | | ------- | ------ | | /streaming-guard | Show status and the detected Pi version. | | /streaming-guard on | Enable the guard for the current session. | | /streaming-guard off | Restore Pi's original renderers for the current session. |

Performance

Representative assistant-component benchmark on a 120-column terminal:

| Accumulated Markdown | Pi 0.82.x | Guarded | Speedup | | -------------------: | --------: | ------: | ------: | | 5,000 characters | 0.64 ms | 0.21 ms | 3.0× | | 20,000 characters | 2.33 ms | 0.72 ms | 3.2× | | 50,000 characters | 5.23 ms | 1.75 ms | 3.0× | | 100,000 characters | 10.63 ms | 3.53 ms | 3.0× |

Run bun run benchmark on your machine for local numbers. Actual frame time varies with terminal width, Markdown shape, syntax highlighting, and color support.

Scope and limitations

Marked resolves reference-style links through document-wide state, so changing a reference definition invalidates the token cache. Theme changes and width changes also invalidate the relevant output.

One enormous paragraph, list, or fenced code block is still a single top-level Markdown token and must be rerendered in full. Rendered Mermaid diagrams intentionally bypass the incremental token cache and remain on Pi's native rendering path. The durable upstream solution may additionally use lightweight rendering while thinking is live.

When a Pi release includes the upstream fix, this extension will refuse that new release until its compatibility range is deliberately reviewed. At that point, uninstall it with:

pi remove npm:pi-streaming-guard

Development

bun install
bun run validate
bun run benchmark

The test suite covers prototype restoration, component reuse, native Mermaid passthrough, outer-wrapper composition, document-wide link invalidation, theme invalidation, and thousands of deterministic streaming-prefix transitions. Release checks also smoke-test loading through Pi's real extension loader.

License

MIT