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

@llms-sdk/cli

v2.2.0

Published

Type-safe CLI argument parsing with provider/model validation and schema introspection

Readme

@llms-sdk/cli

Type-safe CLI argument parsing with provider/model validation and schema introspection for LLMS SDK applications.

Features

  • Type-safe argument parsing with automatic validation
  • Provider and model validation for LLM integrations
  • Schema introspection for runtime type checking
  • Commander.js integration for robust CLI applications
  • Zod schema validation for runtime safety
  • Built-in help generation with proper documentation

Installation

npm install @llms-sdk/cli

Quick Start

import { createCLI, defineCliSchema } from "@llms-sdk/cli";

// Define your CLI schema
const schema = defineCliSchema({
	provider: {
		type: "string",
		choices: ["anthropic", "openai", "google"],
		description: "LLM provider to use",
		required: true,
	},
	model: {
		type: "string",
		description: "Model name",
		default: "claude-3-5-sonnet-20241022",
	},
	temperature: {
		type: "number",
		description: "Sampling temperature",
		default: 0.7,
		min: 0,
		max: 2,
	},
});

// Create CLI instance
const cli = createCLI(schema);

// Parse arguments with type safety
const args = cli.parse(process.argv);

console.log(args.provider); // TypeScript knows this is 'anthropic' | 'openai' | 'google'
console.log(args.model); // TypeScript knows this is string
console.log(args.temperature); // TypeScript knows this is number

Advanced Usage

Provider/Model Validation

import { validateProvider, validateModel } from "@llms-sdk/cli";

// Validate provider exists
if (!validateProvider(args.provider)) {
	console.error(`Invalid provider: ${args.provider}`);
	process.exit(1);
}

// Validate model for specific provider
if (!validateModel(args.provider, args.model)) {
	console.error(`Invalid model ${args.model} for provider ${args.provider}`);
	process.exit(1);
}

Schema Introspection

import { introspectSchema } from "@llms-sdk/cli";

const schemaInfo = introspectSchema(schema);
console.log("Available options:", schemaInfo.fields);
console.log("Required fields:", schemaInfo.required);
console.log("Default values:", schemaInfo.defaults);

Custom Validation

const schema = defineCliSchema({
	input: {
		type: "string",
		description: "Input file path",
		validate: (value) => {
			if (!fs.existsSync(value)) {
				throw new Error(`File does not exist: ${value}`);
			}
			return value;
		},
	},
});

API Reference

createCLI(schema)

Creates a new CLI instance with the given schema.

Parameters:

  • schema - CLI schema definition

Returns: CLI instance with type-safe parse() method

defineCliSchema(definition)

Defines a CLI schema with type safety and validation.

Parameters:

  • definition - Schema definition object

Returns: Typed schema for use with createCLI()

validateProvider(provider)

Validates if a provider is supported by LLMS SDK.

Parameters:

  • provider - Provider name to validate

Returns: boolean

validateModel(provider, model)

Validates if a model is available for the specified provider.

Parameters:

  • provider - Provider name
  • model - Model name to validate

Returns: boolean

introspectSchema(schema)

Introspects a CLI schema to extract metadata.

Parameters:

  • schema - CLI schema to introspect

Returns: Schema metadata object

Integration with LLMS SDK

This package is designed to work seamlessly with other LLMS SDK packages:

import { createCLI } from "@llms-sdk/cli";
import { LLMSClient } from "@llms-sdk/core";

const args = cli.parse(process.argv);

const client = new LLMSClient({
	provider: args.provider,
	model: args.model,
	temperature: args.temperature,
});

License

MIT

Contributing

See the main LLMS SDK repository for contribution guidelines.