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-grok-mermaid

v0.1.0

Published

Automatically render Mermaid code fences as Unicode diagrams in the Pi TUI

Readme

pi-grok-mermaid

A Pi extension that automatically renders fenced mermaid blocks as terminal-style Unicode diagrams.

Assistant output → Pi Markdown renderer → Unicode diagram

Only Pi's TUI display layer is patched. Assistant messages, session files, model context, JSON mode, RPC mode, and print mode remain unchanged. If rendering fails, Pi's normal fenced-code renderer is used.

Lineage and credit

This project is directly based on the Mermaid terminal renderer shipped in xAI's open-source Grok Build, not a new implementation of Mermaid parsing or diagram layout. Grok Build's xai-grok-markdown/src/mermaid.rs recognizes Mermaid fences and draws them as Unicode box art inside its terminal UI.

Simon Willison extracted that renderer from the larger Grok Build codebase, replaced its small ratatui dependency surface with a shim, and compiled it to a standalone WebAssembly module for his browser playground. This extension reuses Simon's WebAssembly artifact and applies the same idea to Pi's terminal Markdown renderer.

The work specific to this repository is the Pi integration: detecting mermaid code tokens at the TUI rendering seam, invoking the WASM module, mapping Grok's semantic styles onto the active Pi theme, managing extension reloads, and falling back safely to Pi's normal code-block rendering.

The renderer is copyright 2023–2026 SpaceXAI and licensed under Apache 2.0. Simon Willison's extraction and build details are preserved in vendor/VENDOR.md, with the full upstream license in vendor/LICENSE.grok-mermaid.

Try it

From a repository checkout:

npm install
npm test
npm run check
pi -e .

To install the local package globally:

pi install .

Or install it directly from GitHub:

pi install git:github.com/RunMintOn/pi-grok-mermaid

Then start or reload Pi and ask for a fenced Mermaid diagram.

Supported diagrams

The bundled Grok renderer supports:

  • graph / flowchart, including subgraphs
  • sequenceDiagram
  • stateDiagram
  • classDiagram
  • erDiagram

Unsupported or over-wide diagrams use the upstream framed-source fallback. The renderer does not reflow an already laid-out diagram to fit a narrower terminal.

How it works

Pi's shared Markdown component already parses fenced blocks into code tokens. During a TUI session this extension wraps the component's internal renderToken() method and handles tokens whose language is mermaid. The wrapper invokes the bundled WebAssembly renderer synchronously and maps its semantic style roles onto the active Pi Markdown theme.

The patch is removed during session_shutdown, is guarded against duplicate installation, and delegates every non-Mermaid token to Pi unchanged.

Markdown.renderToken() is currently an internal Pi TUI method, not a public extension API. The extension therefore fails closed and falls back to normal code rendering if that internal seam changes in a future Pi release.

Vendored renderer

vendor/grok-mermaid.wasm is Simon Willison's WebAssembly extraction of xAI Grok Build's Mermaid terminal renderer. The exact source revision, artifact hash, source locations, copyright, and license are recorded in vendor/VENDOR.md.