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

@spikedpunch/cbd-cli

v0.0.4

Published

The cbd binary: build, select, explain and stats over a coverage map.

Readme

@spikedpunch/cbd-cli

The cbd binary for CBD: record a coverage map, ask which tests a change reaches, and explain the answer.

pnpm add -D @spikedpunch/cbd-cli @spikedpunch/cbd
# plus the adapter for your runner, e.g. @spikedpunch/cbd-japa

Commands

cbd --version
cbd build   [--commit <sha>] [--partial] [--root <dir>] [--format json]
cbd select  [--since <ref>] [--no-worktree] [--strict] [--commit <sha>]
cbd explain <file>[:<line>] [--root <dir>] [--format json]
cbd reaches <test-title> <file>[:<line>] [--file <test-file>] [--format json]
cbd stats   [--commit <sha>] [--root <dir>] [--format json]
cbd collect [--no-select] [--no-build] [--shard <path>] -- <test command>
cbd gc      [--keep <n>] [--root <dir>] [--format json]

The root is, within the git top level, the nearest directory upward containing a cbd.config.json, else the git top level itself; outside git, the nearest config, else the working directory. A config above the git top level is not used. --root overrides it. The config is <root>/cbd.config.json unless --config names another; a missing default config means safe defaults, a missing explicit one is an error. cbd --version prints the CLI and core versions, and select --format json carries cbdVersion.

cbd collect

Runs the test command with CBD_SHARD and CBD_COMMIT set, optionally narrows it with CBD_SELECTION, then builds the map in the same process.

pnpm exec cbd collect -- pnpm test
pnpm exec cbd collect --no-select -- pnpm test   # full recording, never narrow

Select and build are on by default once collection is asked for; --no-select and --no-build turn each off. On a repository's first run there is no map, so the honest answer is a full recording, not an error. An interrupted child leaves a shard with no footer, which is refused rather than built.

The adapters are inert unless CBD_SHARD is set, so the same test script works for ordinary runs and for cbd collect.

cbd select

Diffs the map's commit against the working tree (or --since <ref> / --no-worktree for HEAD) and prints the tests to run, with the reasons.

pnpm exec cbd select
pnpm exec cbd select --since origin/main --format json

Exit codes are part of the interface:

| Exit | Meaning | | --- | --- | | 0 | A subset was selected. | | 3 | The answer is "run all"; the reason is printed. | | 1 | Failure (no map, stale shard, git error). | | 2 | Bad arguments. |

A script can therefore branch without parsing output:

pnpm exec cbd select
status=$?
case $status in
  0) run_selected_only ;;
  3) run_everything ;;
  *) exit "$status" ;;
esac

cbd explain and cbd reaches

explain answers "what reaches this file or line?": the functions and the tests whose windows touched them. reaches answers the inverse for one test, which is useful when reading a test or asking a mutation-testing question.

pnpm exec cbd explain src/router.ts:42
pnpm exec cbd reaches 'handles a refund' src/payments.ts --file tests/refund.spec.ts
pnpm exec cbd reaches 'handles a refund' src/payments.ts --format json

A bare title that names more than one test is refused; --file picks one.

cbd stats

Summarises a map: tests, mapped functions, reached and seen files, untested files, bucket sizes, tests per test file, functions per file, tests per function, and the widest files. --format json prints the same object.

cbd build

Merges shards into a map. By default it takes the shards under .cbd/shards whose header names the target commit, so a stale shard from an earlier run does not leak into a new map. --partial accepts a shard with no footer (an interrupted run) when that is deliberate.

cbd gc

Keeps the newest --keep runs of each kind (default 10) under the state directory, always keeps the map select is using, and touches nothing else in .cbd.

Typical workflows

First recording

pnpm exec cbd collect -- pnpm test

Inner loop

pnpm exec cbd select            # what does my working-tree change reach?
pnpm exec cbd select --since origin/main

CI

pnpm exec cbd collect -- pnpm test   # refresh the map for this commit
pnpm exec cbd select --format json   # branch on exit code / parse the subset

Inspect

pnpm exec cbd stats
pnpm exec cbd explain src/router.ts:42

Configuration

The CLI reads the same cbd.config.json as the library:

{
  "$schema": "./node_modules/@spikedpunch/cbd/cbd.config.schema.json",
  "include": ["src/**", "tests/**"],
  "alwaysAll": ["data/**"],
  "maxAgeCommits": 50,
  "strict": false
}

See the root README for every key.

Requirements

Node.js 20.16+ and git on PATH. The CLI depends on @spikedpunch/cbd; the runner adapter is a separate package.