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

@query-farm/vgi-nl-trains-cli

v0.1.2

Published

Live Dutch railway (NS) departure/arrival dashboard in your terminal — an Ink TUI over the vgi DuckDB extension.

Readme

🚆 @query-farm/vgi-nl-trains-cli

A live Dutch railway (NS) dashboard in your terminal — a station list on the left, with departures (top) and arrivals (bottom) for the selected station on the right. Built with Ink (React for the terminal).

It runs Haybarn — a derived distribution of DuckDB — via @haybarn/node-api, loads the vgi extension, attaches a VGI worker exposing real-time NS (Nederlandse Spoorwegen) data as SQL table functions, and renders it as an animated split-flap board.

 🚆 trains                                                    🕐 12:24
╭───────────────────╮ ╭──────────────────────────────────────────────╮
│ 🚉 Stations       │ │ 🚆 Departures  ·  Utrecht Centraal         8 │
│ 🔎 utr            │ │ ──────────────────────────────────────────── │
│ ───────────────── │ │   Time  │  In │ Δ │ Type       │ To    │ Trk │
│ ▸ UT   Utrecht C… │ │ ▸ 12:24 │ now │ • │ ● Sprinter │ Amst… │  1  │
│   UTLR Utrecht L… │ │   12:24 │  1m │+13│ ● Intercity│ Nijm… │ 19  │
│   ...             │ ╰──────────────────────────────────────────────╯
│                   │ ╭──────────────────────────────────────────────╮
│                   │ │ 🚉 Arrivals  ·  Utrecht Centraal           8 │
╰───────────────────╯ ╰──────────────────────────────────────────────╯

Run it

No install needed — it talks to a hosted worker by default:

npx @query-farm/vgi-nl-trains-cli            # dashboard, pick a station
npx @query-farm/vgi-nl-trains-cli UT         # focused on Utrecht Centraal
npx @query-farm/vgi-nl-trains-cli ASD -w 15  # auto-refresh both boards every 15s

Data source

By default the CLI connects to the hosted VGI worker at https://vgi-trains.fly.dev, so there's nothing to set up. Override the source with environment variables:

| Env var | Effect | |---------|--------| | VGI_TRAINS_URL | point at a different HTTP(S) worker, e.g. your own deployment | | VGI_TRAINS_DIR | run a local worker via stdio (path to a vgi-trains-python-fly checkout) | | VGI_TRAINS_LOCATION | a raw DuckDB ATTACH location string (advanced) |

If the worker requires authentication and none is provided, the ATTACH fails and the CLI shows an "Authentication required" message instead of crashing.

Develop

npm install
npm run dev -- UT --watch   # tsx runs source/cli.jsx with no build step
npm run build               # bundle source/cli.jsx → dist/cli.js (esbuild)

Keys

| Context | Keys | |---------|------| | Station list | type to filter · ↑↓ pick station (updates both boards) · / enter boards · esc quit | | A board | ↑↓ select service · trip detail · Tab switch dep ⇄ arr · back to list · q quit | | Trip detail | esc / back |

The selected station drives both panes at once; the focused pane has a cyan border and shows the row marker.

Options

| Flag | Meaning | |------|---------| | -w, --watch [secs] | auto-refresh the boards (default 30s, min 5) | | -s, --stations [q] | start with the station filter set to q | | -h, --help | help |

Layout & terminal width

The destination column flexes to stdout.columns, so the dashboard fits an 80-column terminal (destinations truncate) and widens up to ~92 columns. When stdout isn't a TTY (piped, CI), it skips the interactive layer and prints the two boards stacked as one static frame — node dist/cli.js UT | cat stays clean.

Features

  • Live dashboard — station list (left) drives departures + arrivals (right) at once; the layout fills the terminal and reflows on resize.
  • Split-flap animation — cells scramble through glyphs and settle; re-flaps when you change station and on every --watch refresh. Display-width-aware, so emoji in NS data (e.g. Alkmaar 🏳️‍🌈, Schiphol ✈️) stay column-aligned.
  • Operator coloring — non-NS operators (Arriva, Blauwnet, ICE, …) are tinted so they stand out; NS uses the default fg.
  • Via stops on the board — each departure shows its via chain inline when it fits, or on a dim ↳ via … continuation line when it doesn't.
  • Cancelled services — shown struck through on a red background.
  • Trip detail on a service shows route, planned-vs-actual time, platform change, status, via stops, and disruption messages.

How it works

  • source/vgi.js — the data layer. Opens an in-memory Haybarn database, LOADs the vgi extension, then ATTACHes the worker — by default the hosted service over HTTPS, or a local worker over stdio when VGI_TRAINS_DIR is set (Haybarn spawns it as a subprocess). Returns plain JS objects. (Note: station_arrivals has no via column — only departures do.)
  • The vgi extension ships as a real npm dependency, @haybarn/ext-vgi-h1-5-3 (a meta-package that pulls the right platform binary via optionalDependencies, like esbuild). Haybarn discovers it automatically, so we just LOAD vgi — no INSTALL ... FROM community, no network fetch, no path wiring. The -h1-5-3 suffix is tied to the DuckDB engine version (@haybarn/node-api 1.5.3); bumping the engine means switching to the matching @haybarn/ext-vgi-h1-5-x package.
  • source/cli.jsx — the Ink UI. <Dashboard> owns the navigation state (station filter/selection, pane focus, row selection, detail overlay) and fetches both boards when the selected station settles (debounced ~220ms so holding doesn't spam the API). Animation and the interactive layer auto-disable when stdout isn't a TTY. App is exported and only auto-runs as the CLI entry, so tests can drive it.

Testing

ink-testing-library drives the UI headlessly — set process.stdout.isTTY = true and process.stdout.columns, render(<App args=… />), then stdin.write('\\t') / '\\r' / arrow escapes ('\\x1b[B') and assert on lastFrame().

License

MIT © 2026 Query.Farm LLC

Powered by Haybarn, a derived distribution of DuckDB.