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

@iamps6/pi-lens

v0.2.1

Published

The terminal previewer for pi — tabbed side drawer for markdown, syntax-highlighted code, images, and PDFs (text + visual pages).

Downloads

270

Readme

pi-lens

The file previewer for pi — read, browse, and peek at files without leaving your terminal session.

pi-lens adds a tabbed side drawer to pi that previews markdown, source code, PDFs, and images — plus a one-key peek that opens the OS-native previewer (Quick Look on macOS) for pixel-perfect viewing. The drawer stays open while you keep chatting with pi.

pi-lens

Features

  • Markdown — headings, tables, and fenced code rendered with pi's own theme
  • Code — syntax highlighting + line numbers for .ts .js .py .html .css .go .rs and dozens more (via pi's highlighter — matches your theme)
  • PDF · text view — full text extraction via Mozilla pdf.js (handles real-world encodings, CMaps, embedded fonts), with per-page markers
  • PDF · visual view (v) — all pages rendered as one continuous scrollable strip of in-terminal pixels; n/p jump between pages
  • Images — in-drawer thumbnail (ANSI quadrant blocks, any truecolor terminal)
  • Peek (enter) — the active file opens in the OS previewer: pixel-perfect images and fully rendered PDFs in a floating panel, esc to come back
  • Tabs — open many files, switch with ←/→ or 1..9
  • Three widths — Regular 50% · Focus 70% · Sideshow 30% (/lens-mode)
  • Chat-friendly — ctrl+shift+l toggles focus between drawer and chat; the drawer stays visible either way
  • npm-only install — pdfjs-dist (pure JS) + optional @napi-rs/canvas (prebuilt binaries). No brew/apt. Everything degrades gracefully if absent.

Install

pi install npm:@iamps6/pi-lens        # from npm
# or
pi install git:github.com/iamps6/pi-lens   # from source

Or clone for development:

git clone https://github.com/iamps6/pi-lens
cd pi-lens && npm install
# then symlink into pi's extension dir:
ln -s "$(pwd)" ~/.pi/agent/extensions/pi-lens

Usage

| Command | Description | |---|---| | /lens | Open the drawer with a welcome screen | | /lens <path> | Preview a file (adds a tab). Absolute, ~, and relative paths all work | | /lens-mode [regular\|focus\|sideshow] | Drawer width — 50% / 70% / 30% (picker if no arg) | | /lens-close | Close the drawer |

Global shortcut: ctrl+shift+l — focus in/out of the drawer from anywhere.

Keys inside the drawer

| Key | Action | Key | Action | |---|---|---|---| | ↑/↓ j/k | scroll | ←/→ Tab [/] | switch tabs | | space/pgdn pgup | page | 1..9 | jump to tab | | g / G | top / bottom | w | close current tab | | enter / o | peek in OS previewer | q | close drawer | | v | PDF: text ⇄ visual pages | n / p | PDF visual: next/prev page | | ctrl+shift+l | back to chat | | |

Quick tour

/lens README.md              ← rendered markdown, scroll with ↑↓
/lens src/index.ts           ← highlighted code with line numbers
/lens ~/Documents/report.pdf ← extracted text · press v for pages · enter to peek
/lens ~/Pictures/photo.png   ← thumbnail · enter for pixel-perfect Quick Look
/lens-mode focus             ← widen the drawer to 70%

Supported formats

| Type | Extensions | In-drawer rendering | Peek (enter) | |---|---|---|---| | Markdown | .md .markdown .mdx | full markdown renderer | Quick Look | | Code | .ts .js .py .html .css + many more | syntax highlight + line numbers | Quick Look | | PDF | .pdf | pdf.js text extraction · visual page strip (v) | full PDF, scrollable | | Image | .png .jpg .jpeg .gif .webp .bmp | quadrant-block thumbnail | pixel-perfect | | Everything else | any | plain text, soft-wrapped | Quick Look |

How visuals work

Images and PDF pages are converted to pixels and rendered as ANSI quadrant-block characters (▘▝▞▛ with truecolor fg/bg = 2×2 pixels per cell, chafa-style). Because that's plain styled text, it works inside the drawer with scrolling, tabs, and borders in any truecolor terminal. For full detail, enter opens the file in the OS-native previewer.

Limitations

Why aren't drawer visuals full-detail?

pi itself can show crisp inline images in the chat transcript — so why are pi-lens visuals blocky? Two different rendering worlds:

1. The drawer is made of text. The drawer is a floating overlay that pi's TUI composites by rewriting styled text lines every frame. A text cell shows at most 2 colors; quadrant glyphs squeeze 2×2 "pixels" per cell out of that — the best known encoding. A 70-cell drawer is ~140 px of horizontal resolution. That's the information-density ceiling of character-cell graphics, not an implementation choice.

2. The crisp path is closed to extensions. Raster protocols (iTerm2 OSC 1337, Kitty graphics) draw at the cursor inside a linear, append-only flow — pi's transcript is such a flow, which is why pi's own inline images are sharp. Extension surfaces (overlays, widgets) are composited: lines are partially rewritten at arbitrary positions each frame, and a raster protocol inside a compositor corrupts (we verified this on all three extension surfaces). There is currently no pi extension API for appending rich content to the transcript — the only crisp surface.

Hence the design: drawer = navigate (text is perfect, visuals are thumbnails) · enter = look (OS previewer, pixel-perfect).

Other limitations

  • Scanned/image-only PDFs have no text layer — use visual mode (v) or peek (OCR is out of scope).
  • Without optional @napi-rs/canvas: images show an info card, PDFs are text-only. Without pdfjs-dist: PDF falls back to a basic built-in extractor.
  • The drawer overlays the right side of the transcript (pi has no split-pane API for extensions). /lens-mode sideshow minimizes coverage.
  • Peek uses Quick Look on macOS; Linux/Windows open the default app (xdg-open / start).

Roadmap

  • [ ] Opt-in /lens-send — push the current visual into the chat as a tool-result image (crisp in-transcript rendering; enters LLM context)
  • [ ] Truecolor capability detection with 256-color fallback
  • [ ] CSV/TSV table rendering
  • [ ] Zoom + pan for visual mode
  • [ ] Upstream pi proposals: split/dock API for the drawer; extension API for rich transcript content

License

MIT © iamps6