@xyd-js/opencli 0.0.0-build-b7bd05c-20260701151111

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @xyd-js/opencli
2
+
3
+ ## 0.0.0-build-b7bd05c-20260701151111
4
+
5
+ ### Patch Changes
6
+
7
+ - update all packages
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) LiveSession Sp.z.o.o
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # @xyd-js/opencli
2
+
3
+ The **OpenCLI core** for xyd: the data model plus the pure spec/loader/generator
4
+ helpers shared by [`@xyd-js/opencli-remark`](../xyd-opencli-remark) (CLI docs) and the
5
+ `openapi2opencli` / `opencli2*` code generators.
6
+
7
+ ## What's here
8
+
9
+ - **The model** (`src/types.ts`) — generated from [`opencli-spec.json`](./opencli-spec.json),
10
+ the [OpenCLI](https://opencli.org) JSON Schema. `OpencliSpecJson`, `Command`, `Option`,
11
+ `Argument`, `Arity`, `ExitCode`, `Conventions`, `CliInfo`, …
12
+ - **The `x-openapi` extension** — an xyd addition to the schema that binds an OpenCLI
13
+ document back to its OpenAPI/HTTP origin so generators can build real requests:
14
+ - `XOpenApiRoot` on the spec root — `servers`, `security` (with an `envVar` hint).
15
+ - `XOpenApiCommand` on each command — `method`, `path`, `contentType`, `security`,
16
+ `params[]` (each maps a CLI `argument:`/`option:` `from` token to an HTTP param),
17
+ and `body` (`flatten` | `json` | `multipart`, per-property field mappings).
18
+ - **Helpers**
19
+ - `loadOpencliSpec(source, { cwd? })` — load a spec from a file path or URL.
20
+ - `findCommand(spec, "a b c")` — resolve a command by path (alias-aware).
21
+ - `generateUsage / generateDescription / generateArguments / generateOptions /
22
+ generateCommands / generateFlags` — render command docs (code or list style).
23
+
24
+ ## Regenerating the model
25
+
26
+ After editing `opencli-spec.json`:
27
+
28
+ ```bash
29
+ pnpm --filter @xyd-js/opencli generate:types # json2ts → src/types.ts (do not hand-edit)
30
+ pnpm --filter @xyd-js/opencli build
31
+ ```
package/biome.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
3
+ "files": {
4
+ "ignore": ["dist/**", "node_modules/**", "src/types.ts"]
5
+ },
6
+ "organizeImports": { "enabled": true },
7
+ "formatter": {
8
+ "enabled": true,
9
+ "indentWidth": 2,
10
+ "indentStyle": "space",
11
+ "lineWidth": 120
12
+ },
13
+ "javascript": {
14
+ "formatter": {
15
+ "quoteStyle": "single",
16
+ "semicolons": "asNeeded"
17
+ }
18
+ },
19
+ "linter": {
20
+ "enabled": true,
21
+ "rules": {
22
+ "recommended": true
23
+ }
24
+ }
25
+ }
package/dist/index.cjs ADDED
@@ -0,0 +1,457 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ findCommand: () => findCommand,
34
+ generateArguments: () => generateArguments,
35
+ generateCommands: () => generateCommands,
36
+ generateDescription: () => generateDescription,
37
+ generateFlags: () => generateFlags,
38
+ generateOptions: () => generateOptions,
39
+ generateUsage: () => generateUsage,
40
+ loadOpencliSpec: () => loadOpencliSpec,
41
+ opencliToReferences: () => opencliToReferences
42
+ });
43
+ module.exports = __toCommonJS(index_exports);
44
+
45
+ // src/spec.ts
46
+ async function loadOpencliSpec(source, opts) {
47
+ try {
48
+ let content;
49
+ if (source.startsWith("http://") || source.startsWith("https://")) {
50
+ const response = await fetch(source);
51
+ if (!response.ok) {
52
+ throw new Error(`Failed to fetch OpenCLI spec: ${response.statusText}`);
53
+ }
54
+ content = await response.text();
55
+ } else {
56
+ const fs = await import("fs/promises");
57
+ const path = await import("path");
58
+ const base = (opts == null ? void 0 : opts.cwd) ?? process.cwd();
59
+ const resolvedPath = path.isAbsolute(source) ? source : path.resolve(base, source);
60
+ content = await fs.readFile(resolvedPath, "utf-8");
61
+ }
62
+ return JSON.parse(content);
63
+ } catch (error) {
64
+ console.error(`Error loading OpenCLI spec from ${source}:`, error);
65
+ return null;
66
+ }
67
+ }
68
+ function findCommand(spec, commandPath) {
69
+ var _a, _b, _c, _d, _e, _f, _g;
70
+ let parts = commandPath.trim().split(/\s+/).filter(Boolean);
71
+ if (parts.length === 0) {
72
+ return {
73
+ name: ((_a = spec.info) == null ? void 0 : _a.title) || "root",
74
+ description: ((_b = spec.info) == null ? void 0 : _b.description) || ((_c = spec.info) == null ? void 0 : _c.summary),
75
+ options: spec.options || [],
76
+ arguments: spec.arguments || [],
77
+ commands: spec.commands || [],
78
+ examples: spec.examples || [],
79
+ exitCodes: spec.exitCodes || [],
80
+ interactive: spec.interactive
81
+ };
82
+ }
83
+ if (parts.length > 0 && ((_d = spec.info) == null ? void 0 : _d.title) && parts[0] === spec.info.title) {
84
+ parts = parts.slice(1);
85
+ }
86
+ if (parts.length === 0) {
87
+ return {
88
+ name: ((_e = spec.info) == null ? void 0 : _e.title) || "root",
89
+ description: ((_f = spec.info) == null ? void 0 : _f.description) || ((_g = spec.info) == null ? void 0 : _g.summary),
90
+ options: spec.options || [],
91
+ arguments: spec.arguments || [],
92
+ commands: spec.commands || [],
93
+ examples: spec.examples || [],
94
+ exitCodes: spec.exitCodes || [],
95
+ interactive: spec.interactive
96
+ };
97
+ }
98
+ let currentCommands = spec.commands || [];
99
+ let foundCommand = null;
100
+ for (const part of parts) {
101
+ foundCommand = currentCommands.find((cmd) => {
102
+ var _a2;
103
+ return cmd.name === part || ((_a2 = cmd.aliases) == null ? void 0 : _a2.includes(part));
104
+ }) || null;
105
+ if (!foundCommand) {
106
+ return null;
107
+ }
108
+ currentCommands = foundCommand.commands || [];
109
+ }
110
+ return foundCommand;
111
+ }
112
+
113
+ // src/generate.ts
114
+ function generateUsage(_spec, command, commandPath, opts = {}) {
115
+ const parts = [];
116
+ parts.push(commandPath);
117
+ if (opts.commandPlaceholder && command.commands && command.commands.filter((c) => !c.hidden).length > 0) {
118
+ parts.push("<command>");
119
+ }
120
+ if (command.options && command.options.length > 0) {
121
+ const visibleOptions = command.options.filter((opt) => !opt.hidden);
122
+ if (visibleOptions.length > 0) {
123
+ parts.push("[options]");
124
+ }
125
+ }
126
+ if (command.arguments && command.arguments.length > 0) {
127
+ const visibleArgs = command.arguments.filter((arg) => !arg.hidden);
128
+ const argParts = visibleArgs.map((arg) => {
129
+ const name = arg.name.toLowerCase();
130
+ const suffix = arg.variadic ? "..." : "";
131
+ return arg.required ? `<${name}${suffix}>` : `[${name}${suffix}]`;
132
+ });
133
+ parts.push(...argParts);
134
+ }
135
+ return parts.join(" ");
136
+ }
137
+ function generateDescription(command) {
138
+ return command.description || "";
139
+ }
140
+ function generateArguments(command, indentStyle = "code") {
141
+ if (!command.arguments || command.arguments.length === 0) {
142
+ return "";
143
+ }
144
+ const visibleArgs = command.arguments.filter((arg) => !arg.hidden);
145
+ if (visibleArgs.length === 0) {
146
+ return "";
147
+ }
148
+ const lines = [];
149
+ for (const arg of visibleArgs) {
150
+ const name = arg.name.toLowerCase();
151
+ const desc = arg.description || "";
152
+ if (indentStyle === "list") {
153
+ lines.push(`- \`${name}\`${desc ? ` ${desc}` : ""}`);
154
+ } else {
155
+ const paddedName = name.padEnd(30);
156
+ lines.push(` ${paddedName}${desc}`);
157
+ }
158
+ }
159
+ return lines.join("\n");
160
+ }
161
+ function generateOptions(command, indentStyle = "code") {
162
+ var _a;
163
+ if (!command.options || command.options.length === 0) {
164
+ return "";
165
+ }
166
+ const visibleOptions = command.options.filter((opt) => !opt.hidden);
167
+ if (visibleOptions.length === 0) {
168
+ return "";
169
+ }
170
+ const lines = [];
171
+ for (const option of visibleOptions) {
172
+ const aliases = ((_a = option.aliases) == null ? void 0 : _a.filter((a) => a.length === 1)) || [];
173
+ const short = aliases.length > 0 ? `-${aliases[0]}` : "";
174
+ const long = `--${option.name}`;
175
+ let argPlaceholder = "";
176
+ if (option.arguments && option.arguments.length > 0) {
177
+ const argNames = option.arguments.filter((arg) => !arg.hidden).map((arg) => `<${arg.name.toLowerCase()}>`);
178
+ argPlaceholder = " " + argNames.join(" ");
179
+ }
180
+ const desc = option.description || "";
181
+ if (indentStyle === "list") {
182
+ const shortPart = short ? `\`${short}\`, ` : "";
183
+ lines.push(`- ${shortPart}\`${long}\`${argPlaceholder}${desc ? ` ${desc}` : ""}`);
184
+ } else {
185
+ const signature = `${short ? `${short}, ` : ""}${long}${argPlaceholder}`;
186
+ const paddedSignature = signature.padEnd(30);
187
+ lines.push(` ${paddedSignature}${desc}`);
188
+ }
189
+ }
190
+ return lines.join("\n");
191
+ }
192
+ function generateFlags(command) {
193
+ var _a;
194
+ if (!command.options || command.options.length === 0) {
195
+ return "No flags available.";
196
+ }
197
+ const visibleOptions = command.options.filter((opt) => !opt.hidden);
198
+ if (visibleOptions.length === 0) {
199
+ return "No flags available.";
200
+ }
201
+ const lines = [];
202
+ for (const option of visibleOptions) {
203
+ const optionParts = [];
204
+ const aliases = ((_a = option.aliases) == null ? void 0 : _a.filter((a) => a.length === 1)) || [];
205
+ const short = aliases.length > 0 ? `-${aliases[0]}` : "";
206
+ const long = `--${option.name}`;
207
+ const name = short ? `\`${short}\`, \`${long}\`` : `\`${long}\``;
208
+ optionParts.push(name);
209
+ if (option.required) {
210
+ optionParts.push("**(required)**");
211
+ }
212
+ lines.push(`- ${optionParts.join(" ")}`);
213
+ if (option.description) {
214
+ lines.push(` ${option.description}`);
215
+ }
216
+ if (option.arguments && option.arguments.length > 0) {
217
+ const argParts = option.arguments.filter((arg) => !arg.hidden).map((arg) => {
218
+ const name2 = arg.name.toUpperCase();
219
+ return arg.required ? `<${name2}>` : `[${name2}]`;
220
+ });
221
+ if (argParts.length > 0) {
222
+ lines.push(` Arguments: ${argParts.join(" ")}`);
223
+ }
224
+ }
225
+ }
226
+ return lines.join("\n");
227
+ }
228
+ function generateCommands(command) {
229
+ if (!command.commands || command.commands.length === 0) {
230
+ return "No subcommands available.";
231
+ }
232
+ const visibleCommands = command.commands.filter((cmd) => !cmd.hidden);
233
+ if (visibleCommands.length === 0) {
234
+ return "No subcommands available.";
235
+ }
236
+ const lines = [];
237
+ for (const subcommand of visibleCommands) {
238
+ lines.push(`- \`${subcommand.name}\``);
239
+ if (subcommand.aliases && subcommand.aliases.length > 0) {
240
+ lines.push(` Aliases: ${subcommand.aliases.map((a) => `\`${a}\``).join(", ")}`);
241
+ }
242
+ if (subcommand.description) {
243
+ lines.push(` ${subcommand.description}`);
244
+ }
245
+ }
246
+ return lines.join("\n");
247
+ }
248
+
249
+ // src/converters.ts
250
+ var GLOBAL_OPTIONS_REGION = "global-options";
251
+ function opencliToReferences(spec, options = {}) {
252
+ var _a, _b;
253
+ if (!spec) return [];
254
+ const cliTitle = ((_a = spec.info) == null ? void 0 : _a.title) || "cli";
255
+ const regionSet = ((_b = options.regions) == null ? void 0 : _b.length) ? new Set(options.regions) : null;
256
+ const perCommand = options.globalOptionsPerCommand ?? false;
257
+ const refs = [];
258
+ const globalOptions = (spec.options || []).filter((o) => o.recursive && !o.hidden);
259
+ const walk = (commands, parentPath) => {
260
+ var _a2;
261
+ for (const cmd of commands || []) {
262
+ if (cmd.hidden) continue;
263
+ const cmdPath = [...parentPath, cmd.name];
264
+ const region = cmdPath.join(" ");
265
+ if (!regionSet || regionSet.has(region)) {
266
+ refs.push(commandToReference(spec, cmd, cmdPath, cliTitle, perCommand ? globalOptions : []));
267
+ }
268
+ if ((_a2 = cmd.commands) == null ? void 0 : _a2.length) walk(cmd.commands, cmdPath);
269
+ }
270
+ };
271
+ walk(spec.commands, []);
272
+ if (!perCommand && globalOptions.length && (!regionSet || regionSet.has(GLOBAL_OPTIONS_REGION))) {
273
+ refs.push(globalOptionsReference(globalOptions));
274
+ }
275
+ return refs;
276
+ }
277
+ function globalOptionsReference(globalOptions) {
278
+ return {
279
+ title: "Global options",
280
+ canonical: GLOBAL_OPTIONS_REGION,
281
+ description: "Options available on every command.",
282
+ category: "cli",
283
+ context: { path: GLOBAL_OPTIONS_REGION, fullPath: "", group: ["Global options"] },
284
+ examples: { groups: [] },
285
+ definitions: [{ title: "Global options", properties: globalOptions.map(optionToProperty) }]
286
+ };
287
+ }
288
+ function commandToReference(spec, cmd, cmdPath, cliTitle, globalOptions = []) {
289
+ const region = cmdPath.join(" ");
290
+ const displayPath = `${cliTitle} ${region}`.trim();
291
+ const definitions = [];
292
+ const args = (cmd.arguments || []).filter((a) => !a.hidden);
293
+ if (args.length) {
294
+ definitions.push({ title: "Arguments", properties: args.map(argumentToProperty) });
295
+ }
296
+ const opts = (cmd.options || []).filter((o) => !o.hidden);
297
+ if (opts.length) {
298
+ definitions.push({ title: "Options", properties: opts.map(optionToProperty) });
299
+ }
300
+ const subs = (cmd.commands || []).filter((c) => !c.hidden);
301
+ if (subs.length) {
302
+ definitions.push({
303
+ title: "Commands",
304
+ properties: subs.map((s) => ({
305
+ name: s.name,
306
+ type: "command",
307
+ description: s.description || ""
308
+ }))
309
+ });
310
+ }
311
+ if (globalOptions.length) {
312
+ definitions.push({ title: "Global options", properties: globalOptions.map(optionToProperty) });
313
+ }
314
+ const hasSubcommands = (cmd.commands || []).some((c) => !c.hidden);
315
+ const group = cmdPath.length === 1 && !hasSubcommands ? ["Commands"] : ["Commands", ...hasSubcommands ? cmdPath : cmdPath.slice(0, -1)];
316
+ const groups = [{ examples: cliToolExamples(cliTitle, cmd, cmdPath) }];
317
+ const responseGroup = responseExampleGroup(cmd);
318
+ if (responseGroup) groups.push(responseGroup);
319
+ return {
320
+ // A command that owns subcommands reads as "<path> <command>" so it's
321
+ // distinct from its group and shows it takes a subcommand.
322
+ title: (hasSubcommands ? `${region} <command>` : region) || cliTitle,
323
+ canonical: cmdPath.join("/") || cliTitle,
324
+ description: cmd.description || "",
325
+ category: "cli",
326
+ // context.path is the region key the docs engine writes into the page
327
+ // frontmatter (`cli: <spec>#<path>`) and reads back to re-resolve the command.
328
+ // api.cli shows the more specific form — a command group carries `<command>`.
329
+ context: { path: region, fullPath: generateUsage(spec, cmd, displayPath, { commandPlaceholder: true }), group },
330
+ examples: { groups },
331
+ definitions
332
+ };
333
+ }
334
+ function responseLanguage(contentType) {
335
+ if (!contentType) return "json";
336
+ if (/json/i.test(contentType)) return "json";
337
+ if (/xml/i.test(contentType)) return "xml";
338
+ return "text";
339
+ }
340
+ function responseExampleGroup(cmd) {
341
+ var _a;
342
+ const responses = (_a = cmd["x-openapi"]) == null ? void 0 : _a.responses;
343
+ if (!(responses == null ? void 0 : responses.length)) return null;
344
+ const examples = [];
345
+ for (const res of responses) {
346
+ if (res.example == null) continue;
347
+ const code = typeof res.example === "string" ? res.example : JSON.stringify(res.example, null, 2);
348
+ examples.push({
349
+ codeblock: {
350
+ title: res.status || "200",
351
+ tabs: [{ title: res.contentType || "application/json", language: responseLanguage(res.contentType), code }]
352
+ }
353
+ });
354
+ }
355
+ if (!examples.length) return null;
356
+ return { description: "Example response", examples };
357
+ }
358
+ function shellQuote(value) {
359
+ return /[\s'"$`\\<>|&;()]/.test(value) ? `'${value.replace(/'/g, "'\\''")}'` : value;
360
+ }
361
+ function exampleValue(arg) {
362
+ var _a, _b, _c;
363
+ const example = (_b = (_a = arg == null ? void 0 : arg.metadata) == null ? void 0 : _a.find((m) => m.name === "example")) == null ? void 0 : _b.value;
364
+ if (typeof example === "string" && example) return example;
365
+ if ((_c = arg == null ? void 0 : arg.acceptedValues) == null ? void 0 : _c.length) return String(arg.acceptedValues[0]);
366
+ return "Example data";
367
+ }
368
+ function cliToolExamples(cliTitle, cmd, cmdPath) {
369
+ var _a;
370
+ const reqArgs = (cmd.arguments || []).filter((a) => a.required && !a.hidden);
371
+ const variantArg = [...reqArgs].reverse().find((a) => {
372
+ var _a2;
373
+ return ((_a2 = a.acceptedValues) == null ? void 0 : _a2.length) || argExampleValue(a) != null;
374
+ });
375
+ const values = ((_a = variantArg == null ? void 0 : variantArg.acceptedValues) == null ? void 0 : _a.length) ? variantArg.acceptedValues.map(String) : variantArg ? [String(argExampleValue(variantArg))] : null;
376
+ if (variantArg && values) {
377
+ return values.map((value) => ({
378
+ codeblock: {
379
+ title: value,
380
+ tabs: [
381
+ {
382
+ title: "CLI Tool",
383
+ language: "shell",
384
+ code: generateCliExample(cliTitle, cmd, cmdPath, { [variantArg.name]: value })
385
+ }
386
+ ]
387
+ }
388
+ }));
389
+ }
390
+ return [{ codeblock: { tabs: [{ title: "CLI Tool", language: "shell", code: generateCliExample(cliTitle, cmd, cmdPath) }] } }];
391
+ }
392
+ function argExampleValue(arg) {
393
+ var _a, _b;
394
+ const example = (_b = (_a = arg.metadata) == null ? void 0 : _a.find((m) => m.name === "example")) == null ? void 0 : _b.value;
395
+ return typeof example === "string" && example ? example : null;
396
+ }
397
+ function generateCliExample(cliTitle, cmd, cmdPath, overrides = {}) {
398
+ var _a;
399
+ let head = [cliTitle, ...cmdPath].join(" ");
400
+ if ((cmd.commands || []).some((c) => !c.hidden)) {
401
+ head += " <command>";
402
+ }
403
+ for (const arg of (cmd.arguments || []).filter((a) => a.required && !a.hidden)) {
404
+ head += ` ${shellQuote(overrides[arg.name] ?? exampleValue(arg))}`;
405
+ }
406
+ const lines = [head];
407
+ for (const opt of (cmd.options || []).filter((o) => o.required && !o.hidden)) {
408
+ if (!((_a = opt.arguments) == null ? void 0 : _a.length)) {
409
+ lines.push(`--${opt.name}`);
410
+ } else {
411
+ lines.push(`--${opt.name} ${shellQuote(exampleValue(opt.arguments[0]))}`);
412
+ }
413
+ }
414
+ return lines.join(" \\\n ");
415
+ }
416
+ function argumentToProperty(arg) {
417
+ var _a, _b, _c;
418
+ const meta = [];
419
+ if (arg.required) meta.push({ name: "required", value: "true" });
420
+ if ((_a = arg.acceptedValues) == null ? void 0 : _a.length) {
421
+ meta.push({ name: "examples", value: arg.acceptedValues });
422
+ } else {
423
+ const example = (_c = (_b = arg.metadata) == null ? void 0 : _b.find((m) => m.name === "example")) == null ? void 0 : _c.value;
424
+ if (example != null && example !== "") meta.push({ name: "example", value: example });
425
+ }
426
+ return {
427
+ name: arg.name,
428
+ type: arg.arity ? "array" : "string",
429
+ description: arg.description || "",
430
+ ...meta.length ? { meta } : {}
431
+ };
432
+ }
433
+ function optionToProperty(opt) {
434
+ var _a, _b;
435
+ const aliasNote = ((_a = opt.aliases) == null ? void 0 : _a.length) ? ` (alias: ${opt.aliases.map((a) => a.length === 1 ? `-${a}` : `--${a}`).join(", ")})` : "";
436
+ const meta = opt.required ? [{ name: "required", value: "true" }] : void 0;
437
+ return {
438
+ name: `--${opt.name}`,
439
+ // an option that takes a value vs. a boolean flag
440
+ type: ((_b = opt.arguments) == null ? void 0 : _b.length) ? "string" : "boolean",
441
+ description: `${opt.description || ""}${aliasNote}`,
442
+ ...meta ? { meta } : {}
443
+ };
444
+ }
445
+ // Annotate the CommonJS export names for ESM import in node:
446
+ 0 && (module.exports = {
447
+ findCommand,
448
+ generateArguments,
449
+ generateCommands,
450
+ generateDescription,
451
+ generateFlags,
452
+ generateOptions,
453
+ generateUsage,
454
+ loadOpencliSpec,
455
+ opencliToReferences
456
+ });
457
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../index.ts","../src/spec.ts","../src/generate.ts","../src/converters.ts"],"sourcesContent":["export * from './src';\n","import type { OpencliSpecJson, Command } from './types.js';\n\nexport interface LoadOpencliSpecOptions {\n /**\n * Base directory used to resolve a relative file `source`.\n * Defaults to `process.cwd()`. (The remark plugin passes the markdown file's dirname.)\n */\n cwd?: string;\n}\n\n/**\n * Load an OpenCLI spec from a file path or an HTTP(S) URL.\n *\n * Returns `null` (and logs) on any failure so callers can leave placeholders\n * untouched rather than throwing.\n */\nexport async function loadOpencliSpec(\n source: string,\n opts?: LoadOpencliSpecOptions,\n): Promise<OpencliSpecJson | null> {\n try {\n let content: string;\n\n if (source.startsWith('http://') || source.startsWith('https://')) {\n // Load from URL\n const response = await fetch(source);\n if (!response.ok) {\n throw new Error(`Failed to fetch OpenCLI spec: ${response.statusText}`);\n }\n content = await response.text();\n } else {\n // Load from file\n const fs = await import('node:fs/promises');\n const path = await import('node:path');\n\n // Resolve relative to the provided cwd (or process.cwd())\n const base = opts?.cwd ?? process.cwd();\n const resolvedPath = path.isAbsolute(source) ? source : path.resolve(base, source);\n\n content = await fs.readFile(resolvedPath, 'utf-8');\n }\n\n return JSON.parse(content) as OpencliSpecJson;\n } catch (error) {\n console.error(`Error loading OpenCLI spec from ${source}:`, error);\n return null;\n }\n}\n\n/**\n * Find a command in the spec by path (e.g., \"spice install\").\n * If the path is empty, returns a synthetic root command built from the spec root.\n */\nexport function findCommand(spec: OpencliSpecJson, commandPath: string): Command | null {\n let parts = commandPath.trim().split(/\\s+/).filter(Boolean);\n\n // If no path specified, create a synthetic root command from spec root\n if (parts.length === 0) {\n return {\n name: spec.info?.title || 'root',\n description: spec.info?.description || spec.info?.summary,\n options: spec.options || [],\n arguments: spec.arguments || [],\n commands: spec.commands || [],\n examples: spec.examples || [],\n exitCodes: spec.exitCodes || [],\n interactive: spec.interactive,\n };\n }\n\n // Skip the CLI name if it matches the first part (e.g., \"spice install\" -> \"install\")\n if (parts.length > 0 && spec.info?.title && parts[0] === spec.info.title) {\n parts = parts.slice(1);\n }\n\n // If only the CLI name was provided, return root command\n if (parts.length === 0) {\n return {\n name: spec.info?.title || 'root',\n description: spec.info?.description || spec.info?.summary,\n options: spec.options || [],\n arguments: spec.arguments || [],\n commands: spec.commands || [],\n examples: spec.examples || [],\n exitCodes: spec.exitCodes || [],\n interactive: spec.interactive,\n };\n }\n\n // Start from root commands\n let currentCommands = spec.commands || [];\n let foundCommand: Command | null = null;\n\n for (const part of parts) {\n foundCommand = currentCommands.find((cmd) => cmd.name === part || cmd.aliases?.includes(part)) || null;\n\n if (!foundCommand) {\n return null;\n }\n\n // Move to subcommands for next iteration\n currentCommands = foundCommand.commands || [];\n }\n\n return foundCommand;\n}\n","import type { OpencliSpecJson, Command } from './types.js';\n\nexport type IndentStyle = 'code' | 'list';\n\n/**\n * Generate usage line for a command (like: \"shadcn init [options] [components...]\")\n */\nexport function generateUsage(\n _spec: OpencliSpecJson,\n command: Command,\n commandPath: string,\n opts: { commandPlaceholder?: boolean } = {},\n): string {\n const parts: string[] = [];\n\n // Command path\n parts.push(commandPath);\n\n // A command that owns subcommands takes one as its next token. Opt-in, so\n // consumers that render a command's own usage (e.g. opencli-remark) keep their\n // output — only api.cli asks for the placeholder.\n if (opts.commandPlaceholder && command.commands && command.commands.filter((c) => !c.hidden).length > 0) {\n parts.push('<command>');\n }\n\n // Options indicator\n if (command.options && command.options.length > 0) {\n const visibleOptions = command.options.filter((opt) => !opt.hidden);\n if (visibleOptions.length > 0) {\n parts.push('[options]');\n }\n }\n\n // Arguments\n if (command.arguments && command.arguments.length > 0) {\n const visibleArgs = command.arguments.filter((arg) => !arg.hidden);\n const argParts = visibleArgs.map((arg) => {\n const name = arg.name.toLowerCase();\n // Use ... suffix if argument can accept multiple values (variadic)\n const suffix = arg.variadic ? '...' : '';\n return arg.required ? `<${name}${suffix}>` : `[${name}${suffix}]`;\n });\n parts.push(...argParts);\n }\n\n return parts.join(' ');\n}\n\n/**\n * Generate description for a command\n */\nexport function generateDescription(command: Command): string {\n return command.description || '';\n}\n\n/**\n * Generate arguments documentation\n * @param indentStyle - 'code' for tab-indented CLI style, 'list' for markdown list style\n */\nexport function generateArguments(command: Command, indentStyle: IndentStyle = 'code'): string {\n if (!command.arguments || command.arguments.length === 0) {\n return '';\n }\n\n const visibleArgs = command.arguments.filter((arg) => !arg.hidden);\n if (visibleArgs.length === 0) {\n return '';\n }\n\n const lines: string[] = [];\n\n for (const arg of visibleArgs) {\n const name = arg.name.toLowerCase();\n const desc = arg.description || '';\n\n if (indentStyle === 'list') {\n // Markdown list format: - `package` Package name\n lines.push(`- \\`${name}\\`${desc ? ` ${desc}` : ''}`);\n } else {\n // Code/CLI format with tab indentation\n const paddedName = name.padEnd(30);\n lines.push(`\\t${paddedName}${desc}`);\n }\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Generate options documentation\n * @param indentStyle - 'code' for tab-indented CLI style, 'list' for markdown list style\n */\nexport function generateOptions(command: Command, indentStyle: IndentStyle = 'code'): string {\n if (!command.options || command.options.length === 0) {\n return '';\n }\n\n const visibleOptions = command.options.filter((opt) => !opt.hidden);\n if (visibleOptions.length === 0) {\n return '';\n }\n\n const lines: string[] = [];\n\n for (const option of visibleOptions) {\n // Build option signature\n const aliases = option.aliases?.filter((a) => a.length === 1) || [];\n const short = aliases.length > 0 ? `-${aliases[0]}` : '';\n const long = `--${option.name}`;\n\n // Add argument placeholder if option takes arguments\n let argPlaceholder = '';\n if (option.arguments && option.arguments.length > 0) {\n const argNames = option.arguments.filter((arg) => !arg.hidden).map((arg) => `<${arg.name.toLowerCase()}>`);\n argPlaceholder = ' ' + argNames.join(' ');\n }\n\n const desc = option.description || '';\n\n if (indentStyle === 'list') {\n // Markdown list format: - `-g`, `--global` Install globally\n const shortPart = short ? `\\`${short}\\`, ` : '';\n lines.push(`- ${shortPart}\\`${long}\\`${argPlaceholder}${desc ? ` ${desc}` : ''}`);\n } else {\n // Code/CLI format with tab indentation\n const signature = `${short ? `${short}, ` : ''}${long}${argPlaceholder}`;\n const paddedSignature = signature.padEnd(30);\n lines.push(`\\t${paddedSignature}${desc}`);\n }\n }\n\n return lines.join('\\n');\n}\n\n/**\n * TODO: OPTIONS DO ALMOST THE SAME\n * Generate flags/options documentation\n */\nexport function generateFlags(command: Command): string {\n if (!command.options || command.options.length === 0) {\n return 'No flags available.';\n }\n\n const visibleOptions = command.options.filter((opt) => !opt.hidden);\n if (visibleOptions.length === 0) {\n return 'No flags available.';\n }\n\n const lines: string[] = [];\n\n for (const option of visibleOptions) {\n const optionParts: string[] = [];\n\n // Option name and aliases\n const aliases = option.aliases?.filter((a) => a.length === 1) || [];\n const short = aliases.length > 0 ? `-${aliases[0]}` : '';\n const long = `--${option.name}`;\n const name = short ? `\\`${short}\\`, \\`${long}\\`` : `\\`${long}\\``;\n optionParts.push(name);\n\n // Required indicator\n if (option.required) {\n optionParts.push('**(required)**');\n }\n\n lines.push(`- ${optionParts.join(' ')}`);\n\n // Description\n if (option.description) {\n lines.push(` ${option.description}`);\n }\n\n // Option arguments\n if (option.arguments && option.arguments.length > 0) {\n const argParts = option.arguments\n .filter((arg) => !arg.hidden)\n .map((arg) => {\n const name = arg.name.toUpperCase();\n return arg.required ? `<${name}>` : `[${name}]`;\n });\n if (argParts.length > 0) {\n lines.push(` Arguments: ${argParts.join(' ')}`);\n }\n }\n }\n\n return lines.join('\\n');\n}\n\n/**\n * Generate subcommands documentation\n */\nexport function generateCommands(command: Command): string {\n if (!command.commands || command.commands.length === 0) {\n return 'No subcommands available.';\n }\n\n const visibleCommands = command.commands.filter((cmd) => !cmd.hidden);\n if (visibleCommands.length === 0) {\n return 'No subcommands available.';\n }\n\n const lines: string[] = [];\n\n for (const subcommand of visibleCommands) {\n lines.push(`- \\`${subcommand.name}\\``);\n\n if (subcommand.aliases && subcommand.aliases.length > 0) {\n lines.push(` Aliases: ${subcommand.aliases.map((a) => `\\`${a}\\``).join(', ')}`);\n }\n\n if (subcommand.description) {\n lines.push(` ${subcommand.description}`);\n }\n }\n\n return lines.join('\\n');\n}\n","import { generateUsage } from './generate';\nimport type { Argument, Command, OpencliSpecJson, Option } from './types';\n\n// Structural subset of @xyd-js/uniform's `Reference` — kept local so the OpenCLI\n// core stays free of the (React-typed) uniform package. The docs engine consumes\n// these as uniform References (api.cli → Atlas).\ninterface OpencliRefProperty {\n name: string;\n type: string;\n description: string;\n meta?: { name: string; value: unknown }[];\n}\ninterface OpencliRefDefinition {\n title: string;\n properties: OpencliRefProperty[];\n}\ninterface OpencliRefCodeTab {\n title: string;\n code: string;\n language: string;\n}\ninterface OpencliRefExampleGroup {\n description?: string;\n examples: { description?: string; codeblock: { title?: string; tabs: OpencliRefCodeTab[] } }[];\n}\nexport interface OpencliReference {\n title: string;\n canonical: string;\n description: string;\n // Marks these as CLI references so the docs engine / Atlas can render the\n // usage-formula header (mirrors an OpenAPI page's method + path).\n category: 'cli';\n // `group` drives sidebar placement (the docs engine groups references by it);\n // `path` is the region key round-tripped through the page frontmatter.\n context: { path: string; fullPath: string; group: string[] };\n // a runnable CLI invocation, rendered by Atlas as a code sample (like the\n // request/response samples on an OpenAPI page).\n examples: { groups: OpencliRefExampleGroup[] };\n definitions: OpencliRefDefinition[];\n}\n\nexport interface OpencliToReferencesOptions {\n /**\n * Restrict output to specific commands. Each region is a command path,\n * space-joined from the CLI root (e.g. `\"install\"`, `\"remote add\"`).\n */\n regions?: string[];\n\n /**\n * Render the CLI's global (root recursive) options on every command page.\n * When false (the default), a single \"Global options\" reference is emitted\n * instead — so the options appear once in the sidebar rather than repeated\n * on every command.\n */\n globalOptionsPerCommand?: boolean;\n}\n\nconst GLOBAL_OPTIONS_REGION = 'global-options';\n\n/**\n * Convert an OpenCLI document to uniform `Reference[]` — one Reference per\n * command — so the docs engine can render CLI reference pages the same way it\n * renders OpenAPI/GraphQL (`api.cli`). Mirrors `oapSchemaToReferences`.\n */\nexport function opencliToReferences(\n spec: OpencliSpecJson | null | undefined,\n options: OpencliToReferencesOptions = {},\n): OpencliReference[] {\n if (!spec) return [];\n\n const cliTitle = spec.info?.title || 'cli';\n const regionSet = options.regions?.length ? new Set(options.regions) : null;\n const perCommand = options.globalOptionsPerCommand ?? false;\n const refs: OpencliReference[] = [];\n\n // Root-level recursive options (e.g. a CLI's global flags) apply to every\n // command. By default they get their own page; with `globalOptionsPerCommand`\n // they're rendered as a \"Global options\" section on each command instead.\n const globalOptions = (spec.options || []).filter((o) => o.recursive && !o.hidden);\n\n const walk = (commands: Command[] | undefined, parentPath: string[]) => {\n for (const cmd of commands || []) {\n if (cmd.hidden) continue;\n const cmdPath = [...parentPath, cmd.name];\n const region = cmdPath.join(' ');\n if (!regionSet || regionSet.has(region)) {\n refs.push(commandToReference(spec, cmd, cmdPath, cliTitle, perCommand ? globalOptions : []));\n }\n if (cmd.commands?.length) walk(cmd.commands, cmdPath);\n }\n };\n walk(spec.commands, []);\n\n // Default: the global options live on a single dedicated page in the sidebar.\n if (!perCommand && globalOptions.length && (!regionSet || regionSet.has(GLOBAL_OPTIONS_REGION))) {\n refs.push(globalOptionsReference(globalOptions));\n }\n\n return refs;\n}\n\nfunction globalOptionsReference(globalOptions: Option[]): OpencliReference {\n return {\n title: 'Global options',\n canonical: GLOBAL_OPTIONS_REGION,\n description: 'Options available on every command.',\n category: 'cli',\n context: { path: GLOBAL_OPTIONS_REGION, fullPath: '', group: ['Global options'] },\n examples: { groups: [] },\n definitions: [{ title: 'Global options', properties: globalOptions.map(optionToProperty) }],\n };\n}\n\nfunction commandToReference(\n spec: OpencliSpecJson,\n cmd: Command,\n cmdPath: string[],\n cliTitle: string,\n globalOptions: Option[] = [],\n): OpencliReference {\n const region = cmdPath.join(' ');\n const displayPath = `${cliTitle} ${region}`.trim();\n\n const definitions: OpencliRefDefinition[] = [];\n\n const args = (cmd.arguments || []).filter((a) => !a.hidden);\n if (args.length) {\n definitions.push({ title: 'Arguments', properties: args.map(argumentToProperty) });\n }\n\n const opts = (cmd.options || []).filter((o) => !o.hidden);\n if (opts.length) {\n definitions.push({ title: 'Options', properties: opts.map(optionToProperty) });\n }\n\n const subs = (cmd.commands || []).filter((c) => !c.hidden);\n if (subs.length) {\n definitions.push({\n title: 'Commands',\n properties: subs.map((s) => ({\n name: s.name,\n type: 'command',\n description: s.description || '',\n })),\n });\n }\n\n // Global flags (root-level recursive options) available on every command.\n if (globalOptions.length) {\n definitions.push({ title: 'Global options', properties: globalOptions.map(optionToProperty) });\n }\n\n // Sidebar grouping: a leaf top-level command sits directly under \"Commands\".\n // A command that owns subcommands becomes a nested group (named after itself)\n // under \"Commands\", and each of its subcommands sits inside that same group —\n // e.g. `components` + `components install` → \"Commands\" › \"components\".\n const hasSubcommands = (cmd.commands || []).some((c) => !c.hidden);\n const group =\n cmdPath.length === 1 && !hasSubcommands ? ['Commands'] : ['Commands', ...(hasSubcommands ? cmdPath : cmdPath.slice(0, -1))];\n\n // The runnable invocation (\"CLI Tool\") at groups[0], plus — when the OpenAPI\n // binding carried one — an \"Example response\" group rendered as a JSON sample.\n // This mirrors an OpenAPI page's request + response code samples; Atlas stacks\n // the groups vertically. Keep the CLI Tool group first.\n const groups: OpencliRefExampleGroup[] = [{ examples: cliToolExamples(cliTitle, cmd, cmdPath) }];\n const responseGroup = responseExampleGroup(cmd);\n if (responseGroup) groups.push(responseGroup);\n\n return {\n // A command that owns subcommands reads as \"<path> <command>\" so it's\n // distinct from its group and shows it takes a subcommand.\n title: (hasSubcommands ? `${region} <command>` : region) || cliTitle,\n canonical: cmdPath.join('/') || cliTitle,\n description: cmd.description || '',\n category: 'cli',\n // context.path is the region key the docs engine writes into the page\n // frontmatter (`cli: <spec>#<path>`) and reads back to re-resolve the command.\n // api.cli shows the more specific form — a command group carries `<command>`.\n context: { path: region, fullPath: generateUsage(spec, cmd, displayPath, { commandPlaceholder: true }), group },\n examples: { groups },\n definitions,\n };\n}\n\n/** Map a response content type to a code-sample language. */\nfunction responseLanguage(contentType: string | undefined): string {\n if (!contentType) return 'json';\n if (/json/i.test(contentType)) return 'json';\n if (/xml/i.test(contentType)) return 'xml';\n return 'text';\n}\n\n/**\n * The \"Example response\" group built from the command's `x-openapi.responses`\n * binding (emitted by openapi2opencli) — one code sample per captured response,\n * rendered alongside the \"CLI Tool\" invocation like an OpenAPI page's\n * request/response samples. Returns null when no response example is available.\n */\nfunction responseExampleGroup(cmd: Command): OpencliRefExampleGroup | null {\n const responses = cmd['x-openapi']?.responses;\n if (!responses?.length) return null;\n\n const examples: OpencliRefExampleGroup['examples'] = [];\n for (const res of responses) {\n if (res.example == null) continue; // skip missing / null bodies (no useful sample)\n const code = typeof res.example === 'string' ? res.example : JSON.stringify(res.example, null, 2);\n examples.push({\n codeblock: {\n title: res.status || '200',\n tabs: [{ title: res.contentType || 'application/json', language: responseLanguage(res.contentType), code }],\n },\n });\n }\n if (!examples.length) return null;\n return { description: 'Example response', examples };\n}\n\n/** Shell-quote a value only when it needs it (spaces / special chars). */\nfunction shellQuote(value: string): string {\n return /[\\s'\"$`\\\\<>|&;()]/.test(value) ? `'${value.replace(/'/g, \"'\\\\''\")}'` : value;\n}\n\n/** A representative value for an argument: an explicit example, an accepted/enum value, else a placeholder. */\nfunction exampleValue(arg: Argument | undefined): string {\n const example = arg?.metadata?.find((m) => m.name === 'example')?.value;\n if (typeof example === 'string' && example) return example;\n if (arg?.acceptedValues?.length) return String(arg.acceptedValues[0]);\n return 'Example data';\n}\n\n/**\n * The \"CLI Tool\" example(s) for a command. When a required argument enumerates\n * its accepted values (e.g. `completion <zsh|fish>`), each value becomes its own\n * example (`codeblock.title` = the value) — so Atlas renders an example-level\n * switcher (`[zsh] [fish]`) rather than language tabs inside a single code\n * block. Otherwise a single \"CLI Tool\" example.\n */\nfunction cliToolExamples(cliTitle: string, cmd: Command, cmdPath: string[]): OpencliRefExampleGroup['examples'] {\n const reqArgs = (cmd.arguments || []).filter((a) => a.required && !a.hidden);\n // The argument whose representative value(s) label the example(s): an enum\n // (acceptedValues) gives one tab per value; a single example value gives one.\n const variantArg = [...reqArgs].reverse().find((a) => a.acceptedValues?.length || argExampleValue(a) != null);\n const values = variantArg?.acceptedValues?.length\n ? variantArg.acceptedValues.map(String)\n : variantArg\n ? [String(argExampleValue(variantArg))]\n : null;\n\n if (variantArg && values) {\n // Each value is its own example (`codeblock.title` = the value) so Atlas\n // renders an example switcher — `[zsh] [fish]`, `[diagrams]`, etc.\n return values.map((value) => ({\n codeblock: {\n title: value,\n tabs: [\n {\n title: 'CLI Tool',\n language: 'shell',\n code: generateCliExample(cliTitle, cmd, cmdPath, { [variantArg.name]: value }),\n },\n ],\n },\n }));\n }\n\n return [{ codeblock: { tabs: [{ title: 'CLI Tool', language: 'shell', code: generateCliExample(cliTitle, cmd, cmdPath) }] } }];\n}\n\n/** An argument's explicit example value (from metadata), or null. */\nfunction argExampleValue(arg: Argument): string | null {\n const example = arg.metadata?.find((m) => m.name === 'example')?.value;\n return typeof example === 'string' && example ? example : null;\n}\n\n/**\n * A runnable, concrete CLI invocation for a command — the command path plus its\n * required arguments and options filled with example values, one option per line\n * (the shape shown on an OpenAPI page's request sample). `overrides` pins a\n * specific value for a named argument (used to render one tab per accepted value).\n */\nfunction generateCliExample(\n cliTitle: string,\n cmd: Command,\n cmdPath: string[],\n overrides: Record<string, string> = {},\n): string {\n let head = [cliTitle, ...cmdPath].join(' ');\n\n // A command group takes a subcommand — shown as a placeholder (unquoted, like\n // the usage formula), e.g. `xyd components <command>`.\n if ((cmd.commands || []).some((c) => !c.hidden)) {\n head += ' <command>';\n }\n\n for (const arg of (cmd.arguments || []).filter((a) => a.required && !a.hidden)) {\n head += ` ${shellQuote(overrides[arg.name] ?? exampleValue(arg))}`;\n }\n\n const lines = [head];\n for (const opt of (cmd.options || []).filter((o) => o.required && !o.hidden)) {\n if (!opt.arguments?.length) {\n lines.push(`--${opt.name}`); // boolean flag\n } else {\n lines.push(`--${opt.name} ${shellQuote(exampleValue(opt.arguments[0]))}`);\n }\n }\n\n return lines.join(' \\\\\\n ');\n}\n\nfunction argumentToProperty(arg: Argument): OpencliRefProperty {\n const meta: { name: string; value: unknown }[] = [];\n if (arg.required) meta.push({ name: 'required', value: 'true' });\n // Surface the argument's accepted values / example in the Arguments section\n // (e.g. `component` → diagrams, `shell` → zsh, fish).\n if (arg.acceptedValues?.length) {\n meta.push({ name: 'examples', value: arg.acceptedValues });\n } else {\n const example = arg.metadata?.find((m) => m.name === 'example')?.value;\n if (example != null && example !== '') meta.push({ name: 'example', value: example });\n }\n return {\n name: arg.name,\n type: arg.arity ? 'array' : 'string',\n description: arg.description || '',\n ...(meta.length ? { meta } : {}),\n };\n}\n\nfunction optionToProperty(opt: Option): OpencliRefProperty {\n const aliasNote = opt.aliases?.length\n ? ` (alias: ${opt.aliases.map((a) => (a.length === 1 ? `-${a}` : `--${a}`)).join(', ')})`\n : '';\n const meta = opt.required ? [{ name: 'required', value: 'true' }] : undefined;\n return {\n name: `--${opt.name}`,\n // an option that takes a value vs. a boolean flag\n type: opt.arguments?.length ? 'string' : 'boolean',\n description: `${opt.description || ''}${aliasNote}`,\n ...(meta ? { meta } : {}),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACgBA,eAAsB,gBACpB,QACA,MACiC;AACjC,MAAI;AACF,QAAI;AAEJ,QAAI,OAAO,WAAW,SAAS,KAAK,OAAO,WAAW,UAAU,GAAG;AAEjE,YAAM,WAAW,MAAM,MAAM,MAAM;AACnC,UAAI,CAAC,SAAS,IAAI;AAChB,cAAM,IAAI,MAAM,iCAAiC,SAAS,UAAU,EAAE;AAAA,MACxE;AACA,gBAAU,MAAM,SAAS,KAAK;AAAA,IAChC,OAAO;AAEL,YAAM,KAAK,MAAM,OAAO,aAAkB;AAC1C,YAAM,OAAO,MAAM,OAAO,MAAW;AAGrC,YAAM,QAAO,6BAAM,QAAO,QAAQ,IAAI;AACtC,YAAM,eAAe,KAAK,WAAW,MAAM,IAAI,SAAS,KAAK,QAAQ,MAAM,MAAM;AAEjF,gBAAU,MAAM,GAAG,SAAS,cAAc,OAAO;AAAA,IACnD;AAEA,WAAO,KAAK,MAAM,OAAO;AAAA,EAC3B,SAAS,OAAO;AACd,YAAQ,MAAM,mCAAmC,MAAM,KAAK,KAAK;AACjE,WAAO;AAAA,EACT;AACF;AAMO,SAAS,YAAY,MAAuB,aAAqC;AArDxF;AAsDE,MAAI,QAAQ,YAAY,KAAK,EAAE,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