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

@kkothari/tokenpilot

v0.1.0

Published

Terminal-first AI assistant that analyzes coding prompts before they reach AI tools, flags broad prompts, estimates token cost, and rewrites vague prompts into focused ones.

Readme

TokenPilot

Terminal-first AI assistant for vibecoders. TokenPilot sits between you and your AI coding tool (Claude Code, Cursor, Codex, Gemini CLI, …). Before a prompt is sent, it estimates how expensive the prompt will be, flags whether it's too broad, and rewrites it into a focused version that keeps the AI working on the right part of your project instead of searching the whole codebase.

Like Grammarly for AI coding prompts — but built for the terminal.

This repo is the CLI core (MVP). Analysis, token estimation, prompt rewriting, and session tracking all run locally, offline, with no API key.


Quick start

No install needed to try it (zero runtime dependencies, Node ≥ 18):

node bin/tokenpilot.js analyze "Fix the dashboard bug"

Or link it globally so tokenpilot is on your PATH:

npm link          # from this directory
tokenpilot start

What you get

$ tokenpilot analyze "Fix the dashboard bug related to token usage"

⚠ BROAD  breadth 68/100
  ████████████████░░░░░░░░

  Projected cost  ~30,867 tokens  (prompt 11 + exploration 30,856)  ≈ $0.19

  Issues
  ✕ Broad scope ("the dashboard") — likely to trigger a full-project search.
  ✕ Vague instruction ("fix") with no specific target.
  ! No file, path, or symbol referenced — the assistant must go find it.

  Likely-relevant files
  ▫ src/Dashboard.tsx
  ▫ src/tokenCalc.ts
  ▫ src/usageApi.ts

  ────────────────────────────────────────────────────────────
  Suggested prompt   saves ~25,801 tokens (84%)

  Fix the dashboard bug related to token usage. Begin by checking
  `src/Dashboard.tsx`, `src/tokenCalc.ts`, `src/usageApi.ts`. Do not
  redesign the UI or refactor unrelated components. Make the smallest
  change necessary. Briefly explain which files you modified and why.

Commands

| Command | What it does | | --- | --- | | tokenpilot start | Interactive REPL — analyzes every prompt before you send it, tracks running savings. The primary experience. | | tokenpilot analyze "<prompt>" | Analyze one prompt and print a focused rewrite. | | tokenpilot stats | Session analytics: tokens projected, saved, $ saved, most expensive prompts. | | tokenpilot history | Every prompt analyzed this session. | | tokenpilot reset | Start a fresh session. | | tokenpilot help | Full help. |

Options

| Flag | Meaning | | --- | --- | | --provider <id> | Pricing model for $ estimates: claude-opus, claude-sonnet (default), claude-haiku, gpt-4o, gemini-pro. | | --json | Machine-readable output (for analyze). | | --no-scan | Skip the project file scan. | | --no-track | Don't record the prompt in the session. |

In the start REPL: :stats, :clear, :quit.


How it works

Everything is local, deterministic, and dependency-free.

  • src/core/tokenizer.js — offline token estimator (blends chars/4 and words/0.75, with a punctuation bump). Within ~10–15% of real BPE counts.
  • src/core/analyzer.js — the heuristic engine. Detects vague verbs, broad scope, heavy-change verbs, missing file references, over-short/over-long prompts, missing scope guards, and near-duplicate prompts. Produces a 0–100 breadth score and projects total token cost. A concrete file reference and an explicit scope guard each measurably lower the projected exploration cost — because those are what actually bound how far the AI wanders.
  • src/core/scanner.js — scans the working directory for source files whose names/paths match your prompt keywords, so rewrites can name real files.
  • src/core/rewrite.js — turns intent + missing pieces into a focused prompt: original intent → concrete starting point → scope guard → report-back.
  • src/core/session.js — local session log at ~/.tokenpilot/session.json.

Roadmap

The MVP CLI is here. Still to come, per the product vision:

  • Browser-based account auth (GitHub / Google) and terminal ↔ account linking
  • Dashboard sync + web analytics
  • Optional AI-powered rewrites (hybrid: heuristics for detection, an LLM call for the rewrite) via the Vercel AI Gateway
  • Landing page and npx tokenpilot install

Development

npm test        # run the unit test suite (node --test)

MIT.