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

@unrdf/kgc-cli

v26.4.4

Published

KGC CLI - Deterministic extension registry for ~40 workspace packages

Readme

@unrdf/kgc-cli

Deterministic CLI extension registry for ~40 UNRDF workspace packages

Overview

kgc-cli provides a deterministic, registry-based architecture for integrating CLI commands from the UNRDF workspace. Instead of hand-writing 40 separate commands, packages export extension objects that describe their CLI contract, and the registry automatically:

  • Loads extensions in stable, deterministic order
  • Detects and prevents collisions
  • Builds a unified command tree with Citty
  • Enforces JSON envelope format for machine-readable output

Architecture

Extension Contract

Every extension must satisfy this Zod schema:

{
  id: '@package/name',                    // Package name
  description: 'Human-readable description',

  nouns: {
    // CLI namespace: kgc <noun> <verb>
    snapshot: {
      description: 'Manage snapshots',
      verbs: {
        create: {
          description: 'Create a snapshot',
          handler: async (args, ctx) => ({ /* result */ }),
          argsSchema: z.object({ /* Zod schema */ }),
          meta: { /* optional metadata */ }
        },
        list: { /* ... */ }
      }
    }
  },

  priority: 10,                           // Lower = resolves collisions first
  guards: { /* optional */ },             // Preconditions
  receipts: { /* optional */ }            // Expected JSON shape
}

Registry System

  • Deterministic loading order (Λ): extensions load in explicit sequence
  • Collision detection: fails closed if two packages claim the same noun:verb
  • Override rules: manifest declares winners when collisions are acceptable
  • Contract validation: every command must have handler, description, argsSchema (if args used)

JSON Envelope Format

All commands support --json flag for machine-readable output:

# Success
kgc snapshot create --json
{
  "ok": true,
  "data": { "snapshotId": "...", "created": "..." },
  "meta": { "source": "@unrdf/kgc-4d", "timestamp": "..." }
}

# Error
kgc snapshot create --json
{
  "ok": false,
  "code": "INVALID_ARGS",
  "message": "Missing required field: universe",
  "details": { /* optional */ },
  "hint": "Try: kgc snapshot create --help",
  "meta": { "timestamp": "..." }
}

Usage

As a CLI User

# Show nouns
kgc --help

# Show verbs in a noun
kgc snapshot --help

# Execute a command
kgc snapshot create --args '{"universe":"my-universe"}'

# JSON output
kgc snapshot create --json --args '{"universe":"my-universe"}'

Creating an Extension

Create packages/my-package/src/cli-extension.mjs:

import { z } from 'zod';

export const extension = {
  id: '@unrdf/my-package',
  description: 'My package CLI',

  nouns: {
    resource: {
      description: 'Manage resources',
      verbs: {
        create: {
          description: 'Create a resource',
          handler: async (args) => {
            // Implementation
            return { resourceId: '...' };
          },
          argsSchema: z.object({
            name: z.string()
          })
        }
      }
    }
  },

  priority: 50 // Standard packages
};

Then register in packages/kgc-cli/src/manifest/extensions.mjs:

export const extensions = [
  // ... existing
  {
    id: '@unrdf/my-package',
    path: '../extensions/my-package.mjs',
    loadOrder: 50,
    enabled: true
  }
];

Manifest & Discovery

The extension manifest (src/manifest/extensions.mjs) is the authoritative list of:

  1. Which packages have CLI extensions
  2. Load order (Λ): strictly ordered, deterministic, stable
  3. Collision overrides: explicit rules when conflicts are acceptable
export const extensions = [
  // Core (0-9)
  // High-priority (10-19)
  { id: '@unrdf/kgc-4d', path: '../extensions/kgc-4d.mjs', loadOrder: 10, enabled: true },
  // Standard (20-99)
  { id: '@unrdf/oxigraph', path: '../extensions/oxigraph.mjs', loadOrder: 20, enabled: true },
];

export const overrides = [
  // If two packages want the same noun:verb, declare the winner
  { rule: 'query:advanced', package: '@unrdf/knowledge-engine', reason: 'KE has better semantics' }
];

Core Nouns (v0)

  • repo: Repository management
  • universe: KGC universes (4D snapshots)
  • event: Event streams and workflows
  • snapshot: Temporal snapshots
  • receipt: Merkle-anchored receipts
  • query: SPARQL and semantic queries
  • diff: Change analysis and diffs
  • policy: Access control and policies
  • hook: Lifecycle hooks
  • vm: Virtual machine / WASM execution
  • latex: LaTeX to PDF compilation (pure JavaScript, zero dependencies)

LaTeX to PDF Compilation

NEW: Compile LaTeX documents to PDF entirely in JavaScript with zero system dependencies.

# Compile a LaTeX document
kgc latex build --input thesis/main.tex --output dist/thesis.pdf

Features:

  • Pure JavaScript (no TeX installation required)
  • WebAssembly TeX engine (XeTeX/PDFLaTeX)
  • Automatic dependency resolution from CTAN
  • Deterministic, reproducible builds with lockfiles
  • Offline support via package caching

Documentation: See docs/latex/

Quick links:

Testing

# Run all tests
pnpm test

# Registry contract tests
pnpm test -- registry.test.mjs

# Manifest and loading tests
pnpm test -- manifest.test.mjs

# Smoke/integration tests
pnpm test -- smoke.test.mjs

# LaTeX pipeline tests
pnpm test -- latex-build.test.mjs

Implementation Status

✅ Complete

  • Registry system with collision detection
  • Extension contract (Zod schema)
  • Manifest with deterministic ordering
  • CLI root with Citty integration
  • 8+ extension wrappers (kgc-4d, blockchain, hooks, oxigraph, federation, etc.)
  • Comprehensive test suite

📋 Remaining

  • Integrate remaining 30+ packages (follow manifest pattern)
  • OTEL instrumentation for observability
  • Performance benchmarks
  • Full documentation

Performance

All operations are:

  • Deterministic: same order every run
  • Fast: registry loads in <100ms for ~40 packages
  • Hermetic: no external dependencies at load time
  • Fail-closed: collisions reject rather than hide

License

MIT