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-clear-screen

v0.3.1

Published

Pi extension: /clear wipes the visible transcript only. Session file, session name, and model context are untouched — unlike every other /clear package, which maps to /new.

Readme

pi-clear-screen

/clear for Pi that behaves like clear in a shell: it wipes what is on screen and nothing else.

Your session file, session name, message history, and token count are untouched.

pi install npm:pi-clear-screen

Then /clear (or /cls).

Part of the pi-extensions collection. Want to delete the session from disk instead of just the screen? That's pi-dump-session.

⚠️ Read this before installing

Several published packages already register /clear, and all of them do the opposite of this one — they map /clear to /new, which replaces the session file and throws away your session name:

If you install one of those and this one, Pi keeps both and disambiguates them as /clear:1 and /clear:2. One nukes your session, one doesn't, and you will not enjoy guessing which is which. Pick one. Use /cls here if you want to keep another package's /clear.

What it does, precisely

| | session file | session name | model context / tokens | screen | |---|---|---|---|---| | /new | new one | gone | reset | wiped | | /compact | same | same | summarised | kept | | /clear (this) | same | same | untouched | wiped |

Nothing in the session is read or written, so the name survives for free.

This is a display command. If you want to actually reclaim context window, use /compact.

How it works

Pi's interactive TUI mounts a document container holding [header, loadedResources, chat]. Extensions get no direct handle on it, but ctx.ui.custom() passes the live TUI instance into its factory. So the extension:

  1. Grabs the TUI inside the factory and calls done() synchronously. showExtensionCustom sees closed === true and skips mounting entirely, so the editor is restored with no flicker and no stray component.
  2. Empties the three document containers.
  3. Writes CSI 3J (erase scrollback) followed by clearScreen() (CSI 2J + cursor home).
  4. Calls restoreRenderState() with a blank frame, so the differential renderer does not diff against rows that were just erased behind its back.
  5. requestRender(true) for a full repaint.

Success is silent, like real clear. It only notifies on failure or if the TUI shape is unrecognised.

Known limitation

The transcript is hidden, not deleted. Anything that makes Pi rebuild the chat from session entries repaints the full history:

  • ctrl+o (tool output expansion toggle)
  • theme change
  • /reload
  • branch / tree navigation

Run /clear again after those.

This cannot be automated soundly with the current extension API: Pi fires no event when it rebuilds the chat (ctrl+o, theme change), /reload restarts extensions so any "was cleared" flag is lost, and re-wiping after session_tree would hide the branch you just navigated to see. Persisting the flag in the session file would break this package's core promise of never touching the session.

Compatibility

Written against Pi 0.84.x. It reaches into TUI internals that are not part of the documented extension API, so it degrades defensively:

  • Unrecognised container layout → does nothing, warns, leaves the render state alone.
  • Fullscreen (alt-screen) mode → works; terminal and restoreRenderState are optional.
  • Non-TUI modes (print, json, rpc) → refuses up front. The host stubs ui.custom() as async () => undefined there, so the factory never runs.

Every one of those paths is covered by a test, and test/smoke.test.ts verifies the internals assumptions (document container layout, Container contract, TuiMainScreen render-state shape) against the actually installed Pi on every npm test / CI run, so version drift is caught before users hit it.

No hotkey is registered — ctrl+l is already Pi's model selector.

Development

See the monorepo README. Quick loop:

npm test -w packages/pi-clear-screen
pi -e ./packages/pi-clear-screen

License

MIT