# @xyd-js/opencli

> OpenCLI core model and helpers (shared by opencli-remark and the openapi2opencli / opencli2* generators)

Latest version **0.0.0-build-868a460-20261012182029** (published 2026-10-12) · 0 weekly downloads

## Install

```sh
npm install @xyd-js/opencli
pnpm add @xyd-js/opencli
yarn add @xyd-js/opencli
bun add @xyd-js/opencli
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.0.0-build-868a460-20261012182029 |
| Published | 2026-10-12 |
| First published | 2026-06-30 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 456.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | zdunecki |

## Links

- npm: https://www.npmjs.com/package/@xyd-js/opencli
- npm.io page: https://npm.io/package/@xyd-js/opencli

## Recent versions

- 0.0.0-build-868a460-20261012182029 (latest) — 2026-10-12
- 0.0.0-canary-868a460-20261012181223 (canary) — 2026-10-12
- 0.0.0-canary-9351970-20261012155500 — 2026-10-12
- 0.0.0-build-9351970-20261012155412 — 2026-10-12
- 0.0.0-canary-7c3f4e2-20261012152212 — 2026-10-12
- 0.0.0-canary-7c3f4e2-20261012150535 — 2026-10-12
- 0.0.0-build-7c3f4e2-20261012150126 — 2026-10-12
- 0.0.0-build-55c38f4-20261012145000 — 2026-10-12
- 0.0.0-build-0167722-20260922165502 — 2026-09-22
- 0.0.0-build-e981406-20260921220136 — 2026-09-21
- 0.0.0-build-f4affb5-20260921174314 — 2026-09-21
- 0.0.0-build-ca84cb4-20260921123316 — 2026-09-21
- 0.0.0-build-bbc1436-20260921112217 — 2026-09-21
- 0.0.0-build-d24422e-20260921010612 — 2026-09-21
- 0.0.0-build-e80ab83-20260920140634 — 2026-09-20
- … 60 more at https://npm.io/package/@xyd-js/opencli/versions

## README

# @xyd-js/opencli

The **OpenCLI core** for xyd: the data model plus the pure spec/loader/generator
helpers shared by [`@xyd-js/opencli-remark`](../xyd-opencli-remark) (CLI docs) and the
`openapi2opencli` / `opencli2*` code generators.

## What's here

- **The model** (`src/types.ts`) — generated from [`opencli-spec.json`](./opencli-spec.json),
  the [OpenCLI](https://opencli.org) JSON Schema. `OpencliSpecJson`, `Command`, `Option`,
  `Argument`, `Arity`, `ExitCode`, `Conventions`, `CliInfo`, …
- **The `x-openapi` extension** — an xyd addition to the schema that binds an OpenCLI
  document back to its OpenAPI/HTTP origin so generators can build real requests:
  - `XOpenApiRoot` on the spec root — `servers`, `security` (with an `envVar` hint).
  - `XOpenApiCommand` on each command — `method`, `path`, `contentType`, `security`,
    `params[]` (each maps a CLI `argument:`/`option:` `from` token to an HTTP param),
    and `body` (`flatten` | `json` | `multipart`, per-property field mappings).
- **Helpers**
  - `loadOpencliSpec(source, { cwd? })` — load a spec from a file path or URL.
  - `findCommand(spec, "a b c")` — resolve a command by path (alias-aware).
  - `generateUsage / generateDescription / generateArguments / generateOptions /
    generateCommands / generateFlags` — render command docs (code or list style).

## Regenerating the model

After editing `opencli-spec.json`:

```bash
pnpm --filter @xyd-js/opencli generate:types   # json2ts → src/types.ts (do not hand-edit)
pnpm --filter @xyd-js/opencli build
```

---
_Source: https://npm.io/package/@xyd-js/opencli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
