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

@alt-stack/cli

v1.6.2

Published

Type-safe command-line applications with nested routing and Zod validation

Readme

@alt-stack/cli

@alt-stack/cli builds type-safe command-line applications from immutable procedures and nested routers. Arguments and options are parsed with Zod, middleware can refine invocation context, and handlers return Result values.

Install

pnpm add @alt-stack/cli zod

Define and run a nested CLI

import { createCli, initCli, ok, runCli } from "@alt-stack/cli";
import { randomUUID } from "node:crypto";
import { z } from "zod";

interface AppContext {
  requestId: string;
}

const t = initCli<AppContext>();

const appRouter = t.router({
  users: t.router(
    {
      create: t.procedure
        .description("Create a user")
        .args({
          name: t.argument(z.string().min(1), { metavar: "name" }),
        })
        .options({
          role: t.option(z.enum(["admin", "member"]).default("member"), {
            short: "r",
            metavar: "role",
          }),
          notify: t.flag({ short: "n" }),
        })
        .command(({ input, ctx }) => {
          return ok({
            requestId: ctx.requestId,
            name: input.args.name,
            role: input.options.role,
            notify: input.options.notify,
          });
        }),
    },
    { description: "Manage users" },
  ),
});

const cli = createCli({
  name: "acme",
  version: "1.0.0",
  description: "Acme administration tools",
  router: appRouter,
  createContext: () => ({ requestId: randomUUID() }),
});

async function main(): Promise<void> {
  const exitCode = await runCli(cli, {
    argv: process.argv.slice(2),
    stdout: process.stdout,
    stderr: process.stderr,
    formatValue: (value) => JSON.stringify(value, null, 2),
  });
  process.exitCode = exitCode;
}

void main();

This produces commands such as:

acme users create Ada --role admin --notify
acme users create --help
acme --version

createCli().execute(argv) has no ambient process dependency. It returns one of executed, help, version, usage-error, or command-error, so applications can embed the same CLI in tests or another host without intercepting output or exits. runCli is the optional terminal renderer and writes only to the streams supplied by the caller.

The object returned by createContext is the invocation-scoped context container and must be a plain object (standard or null prototype). Put class-based clients, loggers, and other service instances in properties of that container rather than returning a class instance as the container itself.

See the CLI quickstart, common patterns, and API documentation.