While dogfooding cligentic to scaffold a new CLI, three primitives kept being re-implemented inline. Sharing as candidates for the registry.
1. http-client
A typed fetch wrapper. Every CLI that talks to a JSON API ends up writing the same thing: Authorization header injection, retry on 429/5xx with exponential backoff, content-type validation, response error classification. Highest-value extraction — it's the most copied pattern across CLIs.
Rough surface:
const api = new Http({ apiKey, baseUrl, rate: 5 });
await api.get<T>(path, { query, retries });
await api.post<T>(path, body);
// throws CliError with classified `kind` on failure
Wires to error-map for kind classification and to audit-log (optional) for request/response trace.
2. commander-root
Helper to register the standard agent-first global flags on a commander program in one call, plus a getGlobals(cmd) accessor returning a typed GlobalOpts.
Standard flags: --json, --human, --ndjson, --fields, --params, --dry-run, --yes, --no-input, --quiet, --verbose, --profile, --rate.
Rough surface:
import { registerGlobals, getGlobals } from "cligentic/commander-root";
registerGlobals(program);
// inside any subcommand:
const g = getGlobals(this);
Right now every CLI re-declares these and writes its own getGlobals shim. Centralising means consistent semantics (e.g. --no-input defaults to !process.stdin.isTTY everywhere) and one place to evolve the contract.
3. schema-registry
A typed map of operation schemas plus the {cli} schema list and {cli} schema show <op> commands. Every CLI built so far ships some version of this for agent self-discovery.
Rough surface:
import { defineSchemas, registerSchemaCommand } from "cligentic/schema-registry";
export const OPERATIONS = defineSchemas({
"noun.verb": {
tier: "T0", method: "GET", path: "/things",
description: "...", required: [], optional: [], output: "{...}",
},
});
registerSchemaCommand(program, OPERATIONS);
Drops a working schema list / schema show <op> into any CLI without re-implementing.
All three are derived from patterns already living in shipped CLIs — extracting them mostly means lifting and de-coupling. Happy to PR if there's appetite; flag which (if any) you'd want first and I'll start with that one.
While dogfooding cligentic to scaffold a new CLI, three primitives kept being re-implemented inline. Sharing as candidates for the registry.
1.
http-clientA typed
fetchwrapper. Every CLI that talks to a JSON API ends up writing the same thing:Authorizationheader injection, retry on 429/5xx with exponential backoff, content-type validation, response error classification. Highest-value extraction — it's the most copied pattern across CLIs.Rough surface:
Wires to
error-mapfor kind classification and toaudit-log(optional) for request/response trace.2.
commander-rootHelper to register the standard agent-first global flags on a commander program in one call, plus a
getGlobals(cmd)accessor returning a typedGlobalOpts.Standard flags:
--json,--human,--ndjson,--fields,--params,--dry-run,--yes,--no-input,--quiet,--verbose,--profile,--rate.Rough surface:
Right now every CLI re-declares these and writes its own
getGlobalsshim. Centralising means consistent semantics (e.g.--no-inputdefaults to!process.stdin.isTTYeverywhere) and one place to evolve the contract.3.
schema-registryA typed map of operation schemas plus the
{cli} schema listand{cli} schema show <op>commands. Every CLI built so far ships some version of this for agent self-discovery.Rough surface:
Drops a working
schema list/schema show <op>into any CLI without re-implementing.All three are derived from patterns already living in shipped CLIs — extracting them mostly means lifting and de-coupling. Happy to PR if there's appetite; flag which (if any) you'd want first and I'll start with that one.