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

@zfadhli/koko-cli

v0.3.0

Published

Composition-based CLI toolkit — wraps cac, picocolors, cli-progress, cli-spinners

Readme

koko

Composition-based CLI toolkit — wraps cac, picocolors, cli-progress, and cli-spinners into a cohesive, function-based API.

Design

koko follows a function-based Composition API (inspired by Vue 3):

  • Stateless utilities (colors, CLI builder) are plain objects — no factory needed
  • Stateful widgets (spinner, progress) are factory functions — closures, not classes
  • Progressive complexityctx.spinner() is a one-liner; import { createSpinner } for standalone use
  • Minimal API surface — 4 imports cover everything

Install

npm install @zfadhli/koko-cli

Quick start

import { color, createSpinner, createProgress, createCLI } from "@zfadhli/koko-cli";

// Colors
console.log(color.red("error"));
console.log(color.bold(color.green("success")));

// Spinner
const spin = createSpinner("Loading...");
spin.start();
await someWork();
spin.succeed("Done!");

// Progress bar
const bar = createProgress({ total: 100 });
bar.update(50);
bar.stop();

// CLI app
const cli = createCLI("my-app", "1.0.0").description("My CLI");
cli.command("build <input>", "Build project", (cmd) => {
  cmd.option("--out <dir>", "Output dir", { default: "dist" });
  cmd.action(async (options, ctx) => {
    const spin = ctx.spinner("Building...");
    spin.start();
    // ...
    spin.succeed("Built!");
  });
});
cli.parse();

API

color

A plain object with all picocolors functions:

color.red("text")         // red text
color.green("text")       // green text
color.bold("text")        // bold text
color.dim("text")         // dim text
color.italic("text")      // italic
color.underline("text")   // underline
// ... and 18 more (all bright variants, bg variants omitted for brevity)

// Nesting
color.bold(color.red("bold red text"))

createSpinner(text?, options?)

Creates a terminal spinner with start/stop lifecycle.

const spin = createSpinner("Installing...");
spin.start();
// ... async work
spin.succeed("Installed!");   // ✔ Installed!
spin.fail("Failed!");         // ✘ Failed!
spin.warn("Caution!");        // ⚠ Caution!
spin.info("Note!");           // ℹ Note!

// Custom style
createSpinner("Loading", { style: "arc", color: "cyan" });

Options:

| Option | Type | Default | |--------|------|---------| | text | string | "" | | style | SpinnerStyle | "dots" | | color | ColorName | — (no color) | | frames | string[] | from style | | interval | number | from style |

createProgress(options)

Creates a terminal progress bar.

const bar = createProgress({ total: 100 });
bar.update(50);          // set exact value
bar.increment(10);       // increment by delta
bar.stop();

// With custom format and payload
const bar = createProgress({
  total: 10,
  format: "  {bar}  {percentage}%  |  Installing {package}",
});
bar.increment(1, { package: "koko" });

Options:

| Option | Type | Default | |--------|------|---------| | total | number | (required) | | start | number | 0 | | format | string | rect preset | | barsize | number | terminal width | | barCompleteChar | string | | | barIncompleteChar | string | (space) | | clearOnComplete | boolean | false | | stopOnComplete | boolean | false |

createCLI(name, version?, options?)

Creates an opinionated CLI application builder (wraps cac).

  • Auto-attaches --help and --version
  • Action handlers receive (options, ctx) with typed options
  • ctx provides .spinner(), .progress(), .color

Banner — When a version is provided, a styled banner (name v{version}) is automatically printed to stderr before each command action. Customize or disable it with .banner().

const cli = createCLI("deploy", "1.0.0")
  .description("Deployment tool");

cli.command("build <input>", "Build project", (cmd) => {
  cmd.option("--out <dir>", "Output dir", { default: "dist" });
  cmd.option("--prod", "Production mode");
  cmd.action(async (options, ctx) => {
    // options: { input: string; out: string; prod: boolean }
    // ctx:     { spinner, progress, color }
    const spin = ctx.spinner("Compiling...");
    spin.start();
    await build(options.input);
    spin.succeed("Built!");
  });
});

cli.parse();

.banner(text?)

Controls the startup banner shown before command actions.

| Argument | Behavior | |----------|----------| | (none) or true | Default name v{version} (bold cyan + yellow) | | false | Disable banner entirely | | "Custom {name} {version}" | Custom text; {name} and {version} are substituted |

// Disable the banner
cli.banner(false)

// Custom banner text
cli.banner("=== {name} v{version} ===")

The banner can also be controlled via the third argument to createCLI:

createCLI("myapp", "1.0.0", { banner: false })

Icons

Standardized icon constants:

import { ICON_SUCCESS, ICON_ERROR, ICON_WARN, ICON_INFO } from "@zfadhli/koko-cli";

| Constant | Character | Description | |----------|-----------|-------------| | ICON_SUCCESS | | Success / complete | | ICON_ERROR | | Error / failure | | ICON_WARN | | Warning | | ICON_INFO | | Info |

Errors

import { CliToolkitError } from "@zfadhli/koko-cli";

try {
  createProgress({ total: 0 });
} catch (err) {
  if (err instanceof CliToolkitError) {
    console.error(err.message); // "total must be > 0, got 0"
  }
}

Examples

# Run any example
nub examples/01-color.ts         # all color functions
nub examples/02-spinner.ts       # spinner lifecycle + styles
nub examples/03-progress.ts      # progress bars + payloads
nub examples/04-cli-app.ts       # full CLI app with ctx
nub examples/05-composition.ts   # real-world patterns

# All at once
nub run examples

License

MIT