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

@danypops/pi-tui-harness

v0.0.2

Published

Tests real @earendil-works/pi-tui Component instances without hand-rolled ANSI-stripping regexes: named-key input helpers, and a real VT state machine (@xterm/headless) for structured cell/plain-text assertions and golden-file snapshots -- Ghostty's libgh

Readme

@danypops/pi-tui-harness

Tests real @earendil-works/pi-tui Component instances without a hand-rolled ANSI-stripping regex. Applies Ghostty's libghostty-vt testing philosophy (Mitchell Hashimoto: "isolate side effects, use a real engine for the rest") to Pi's own TUI layer.

Three layers, in order of speed and coverage:

  1. driveComponent -- fast, in-process, named-key input helpers. No terminal, no ANSI interpretation, just direct handleInput() calls with real legacy byte sequences (cross-checked against @earendil-works/pi-tui's own matchesKey).
  2. renderToTerminal -- feeds a component's real render() output through @xterm/headless (the same VT engine VS Code's integrated terminal uses) for structured plainLines()/cellAt() assertions -- real bold/underline/color interpretation, not regex guesses.
  3. expectSnapshot -- golden-file snapshot testing for a captured frame. "One frame in, one frame out": tightly control the input state, run one render pass, diff the result against a known-good copy.

runMultiSelectViewportScenario supplies the thin production regression path for a four-row multi-select: move to the fifth row, toggle it twice, then move back to the first row. Component owners keep navigation rules in pure model tests and assert this helper's VT-interpreted frames at the integration layer.

A real subprocess/node-pty layer (an actual terminal emulator, real keyboard-driver-level input) is deliberately out of scope for now -- driveComponent + renderToTerminal already cover unit and structural assertions; a future fourth layer would only add value for behavior that depends on a real pty (resize signals, real terminal capability detection).

Install

npm install --save-dev @danypops/pi-tui-harness @earendil-works/pi-tui

Example

import { driveComponent, renderToTerminal, expectSnapshot } from "@danypops/pi-tui-harness";
import { MyComponent } from "../src/my-component.js";

const component = new MyComponent();
const driven = driveComponent(component);

driven.pressKey("down");
driven.pressKey("space");

// Layer 2: real VT interpretation, structured cell assertions.
const terminal = await renderToTerminal(driven.render(40));
expect(terminal.plainLines()[0]).toBe("[x] selected item");
expect(terminal.cellAt(0, 0)?.bold).toBe(true);
terminal.dispose();

// Layer 3: golden-file snapshot of one captured frame.
expectSnapshot("test/__snapshots__/my-component.snap", terminal.plainLines());

Set UPDATE_SNAPSHOTS=1 to accept a new golden file after an intentional rendering change.