Clibu is a small TypeScript-first CLI builder split across focused packages so the core parser, help renderer, and configuration loader can evolve independently.
@clibu/core— Core engine: parsing, command graph, option validation, context creation, and runtime execution (exportscreateCLI, schema helpers).@clibu/help— Deterministic plain-text help renderer for root and per-command help. Implemented with small, testable modules (format / options / render).@clibu/loader— Configuration discovery and TypeScript transpilation with content-hash caching under.clibu/cache/. Implements smart picking of named/default exports and supports.ts/.mts/.ctstranspilation.clibu— Umbrella package and executable facade: loads a project config, intercepts--help/-h, runs commands via@clibu/core, and re-export functions and types across@clibupackages.
- Create a configuration file at your project root OR opt-in via
package.json(if you want to reuse an existing module or directory). For best IDE experience prefer TypeScript anddefineConfig:
// clibu.config.ts (filename discovery)
import { defineConfig } from "clibu"
export default defineConfig({
name: "mycli",
version: "0.0.1",
options: {
verbose: { kind: "flag", alias: "v", description: "Verbose output" }
},
commands: {
hello: {
description: "Greet the user",
run(ctx) {
console.log("hello", ctx.args.join(" "))
}
}
}
})Alternatively, point Clibu at a config module or directory via package.json (takes priority over filename discovery):
If configFile is a directory, Clibu resolves the first existing index.* in the order: index.ts, index.mts, index.cts, index.mjs, index.js, index.cjs, index.json.
Notes:
defineConfig(...)is exported for IDE-friendly type inference. On TS 4.9+ you can also use thesatisfiesoperator withCLIConfig.- TypeScript configs (
.ts/.mts/.cts) are transpiled on-demand and cached under.clibu/cache/.
- Run the CLI:
npx clibu --help
npx clibu hello world -v- Build:
bun run build(runs turbo/packlet pipeline) - Test:
bun run test(runs tests across packages) - Lint & format:
bun run lintandbun run format:check/bun run format
The repository uses Bun for local scripts but runs on Node 18+ at runtime.
- Two-phase parsing: a relaxed discovery pass finds the target command path, then a strict per-command parse validates options.
- Global options support inheritance and overrides; conflicts (alias/shape) are detected at creation time.
- Help rendering is intentionally deterministic and small so snapshot tests are reliable.
@clibu/helpinternals are split intoformat,options, andrendermodules. The package root re-exports the renderer functions.@clibu/loaderwas split intopick,transpile,sample, andloadmodules;index.tsre-exports the public helpers.
These refactors keep the public API stable while making the code easier to test and extend.
Clibu supports a small plugin surface (called "organs") that can observe and augment runtime behavior. See @clibu/core docs and docs/tutorial/07-plugins-organs.md for lifecycle hooks and examples.
- See
examples/quickstart/for a minimal runnable example. - A tutorial series is available under
docs/tutorial/covering setup, config authoring, validation, programmatic usage, and testing.
MIT © KazViz
{ "clibu": { "configFile": "./src" // directory: attempts index.ts/mts/cts/mjs/js/cjs/json // or: "./src/cli-config.ts" (explicit file) } }