@kubb/cli 5.0.0-beta.9 → 5.0.0-beta.93

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.
Files changed (136) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +48 -79
  3. package/bin/kubb.js +9 -3
  4. package/dist/Telemetry-7z2tIqPm.js +282 -0
  5. package/dist/Telemetry-7z2tIqPm.js.map +1 -0
  6. package/dist/{telemetry-B2iWkY5e.cjs → Telemetry-xcWb-UWT.cjs} +167 -116
  7. package/dist/Telemetry-xcWb-UWT.cjs.map +1 -0
  8. package/dist/{errors-CINO1EIv.js → errors-CMvLO2NE.js} +3 -15
  9. package/dist/{errors-CINO1EIv.js.map → errors-CMvLO2NE.js.map} +1 -1
  10. package/dist/{errors-CLCjoSg0.cjs → errors-DNxBUo3k.cjs} +2 -20
  11. package/dist/{errors-CLCjoSg0.cjs.map → errors-DNxBUo3k.cjs.map} +1 -1
  12. package/dist/generate-Cc9j2-lg.js +87 -0
  13. package/dist/generate-Cc9j2-lg.js.map +1 -0
  14. package/dist/generate-DwTTaSpB.cjs +87 -0
  15. package/dist/generate-DwTTaSpB.cjs.map +1 -0
  16. package/dist/index.cjs +33 -261
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.ts +6 -1
  19. package/dist/index.js +34 -262
  20. package/dist/index.js.map +1 -1
  21. package/dist/{init-DOSXtcyb.js → init-BlTepVY_.js} +13 -13
  22. package/dist/init-BlTepVY_.js.map +1 -0
  23. package/dist/{init-bKtEOvhK.cjs → init-CvVRvhfJ.cjs} +12 -13
  24. package/dist/init-CvVRvhfJ.cjs.map +1 -0
  25. package/dist/mcp-CTs7ogBF.js +21 -0
  26. package/dist/mcp-CTs7ogBF.js.map +1 -0
  27. package/dist/mcp-szP8HzB7.cjs +20 -0
  28. package/dist/mcp-szP8HzB7.cjs.map +1 -0
  29. package/dist/package-CfWW74Ug.js +6 -0
  30. package/dist/package-CfWW74Ug.js.map +1 -0
  31. package/dist/{package-DHGhrRW-.cjs → package-DPdskCYh.cjs} +2 -2
  32. package/dist/package-DPdskCYh.cjs.map +1 -0
  33. package/dist/{chunk-BvFE5Tac.js → rolldown-runtime-C0LytTxp.js} +0 -1
  34. package/dist/run-B8sdHsE4.js +1262 -0
  35. package/dist/run-B8sdHsE4.js.map +1 -0
  36. package/dist/{run-YsoCk5we.cjs → run-BNOCBw2y.cjs} +152 -98
  37. package/dist/run-BNOCBw2y.cjs.map +1 -0
  38. package/dist/{run-CQbj3ley.cjs → run-BdtVrLKu.cjs} +9 -15
  39. package/dist/run-BdtVrLKu.cjs.map +1 -0
  40. package/dist/{run-CF97BWVa.js → run-CINOocLR.js} +138 -84
  41. package/dist/run-CINOocLR.js.map +1 -0
  42. package/dist/{run-CCZ24VKk.js → run-CaOjZRiQ.js} +7 -13
  43. package/dist/run-CaOjZRiQ.js.map +1 -0
  44. package/dist/run-D2vd34xp.cjs +33 -0
  45. package/dist/run-D2vd34xp.cjs.map +1 -0
  46. package/dist/run-DFXppyRD.cjs +1265 -0
  47. package/dist/run-DFXppyRD.cjs.map +1 -0
  48. package/dist/run-lgrTO14E.js +32 -0
  49. package/dist/run-lgrTO14E.js.map +1 -0
  50. package/dist/tools-B23ltmWP.js +152 -0
  51. package/dist/tools-B23ltmWP.js.map +1 -0
  52. package/dist/tools-CeIABV0T.cjs +175 -0
  53. package/dist/tools-CeIABV0T.cjs.map +1 -0
  54. package/dist/{validate-Bj8vbvPt.cjs → validate-BhSbvuiq.cjs} +9 -10
  55. package/dist/validate-BhSbvuiq.cjs.map +1 -0
  56. package/dist/{validate-bHUrnYBv.js → validate-Cfi4pIS0.js} +10 -10
  57. package/dist/validate-Cfi4pIS0.js.map +1 -0
  58. package/package.json +14 -28
  59. package/dist/agent-C5F4itrc.js +0 -68
  60. package/dist/agent-C5F4itrc.js.map +0 -1
  61. package/dist/agent-d-lmeOr1.cjs +0 -70
  62. package/dist/agent-d-lmeOr1.cjs.map +0 -1
  63. package/dist/constants-B2JTeRBb.js +0 -42
  64. package/dist/constants-B2JTeRBb.js.map +0 -1
  65. package/dist/constants-BINTA5VZ.cjs +0 -77
  66. package/dist/constants-BINTA5VZ.cjs.map +0 -1
  67. package/dist/constants-BYGmiFs0.cjs +0 -139
  68. package/dist/constants-BYGmiFs0.cjs.map +0 -1
  69. package/dist/constants-DSJ-Xrbv.js +0 -116
  70. package/dist/constants-DSJ-Xrbv.js.map +0 -1
  71. package/dist/define-Bdn8j5VM.cjs +0 -54
  72. package/dist/define-Bdn8j5VM.cjs.map +0 -1
  73. package/dist/define-m_fp-Aqm.js +0 -43
  74. package/dist/define-m_fp-Aqm.js.map +0 -1
  75. package/dist/generate-BhfRufgh.js +0 -72
  76. package/dist/generate-BhfRufgh.js.map +0 -1
  77. package/dist/generate-BvuSxNYj.cjs +0 -71
  78. package/dist/generate-BvuSxNYj.cjs.map +0 -1
  79. package/dist/init-DOSXtcyb.js.map +0 -1
  80. package/dist/init-bKtEOvhK.cjs.map +0 -1
  81. package/dist/mcp-CKkbG0kp.cjs +0 -39
  82. package/dist/mcp-CKkbG0kp.cjs.map +0 -1
  83. package/dist/mcp-DzOfqX_j.js +0 -39
  84. package/dist/mcp-DzOfqX_j.js.map +0 -1
  85. package/dist/package-BgAYWN7y.js +0 -6
  86. package/dist/package-BgAYWN7y.js.map +0 -1
  87. package/dist/package-DHGhrRW-.cjs.map +0 -1
  88. package/dist/run-BObDb2qe.cjs +0 -1741
  89. package/dist/run-BObDb2qe.cjs.map +0 -1
  90. package/dist/run-BzpYYOQs.js +0 -121
  91. package/dist/run-BzpYYOQs.js.map +0 -1
  92. package/dist/run-CCZ24VKk.js.map +0 -1
  93. package/dist/run-CF97BWVa.js.map +0 -1
  94. package/dist/run-CQbj3ley.cjs.map +0 -1
  95. package/dist/run-D0hmRpHy.js +0 -49
  96. package/dist/run-D0hmRpHy.js.map +0 -1
  97. package/dist/run-DwdAwnLG.cjs +0 -125
  98. package/dist/run-DwdAwnLG.cjs.map +0 -1
  99. package/dist/run-Lr0Ctnu0.cjs +0 -50
  100. package/dist/run-Lr0Ctnu0.cjs.map +0 -1
  101. package/dist/run-P6D8TnXf.js +0 -1738
  102. package/dist/run-P6D8TnXf.js.map +0 -1
  103. package/dist/run-YsoCk5we.cjs.map +0 -1
  104. package/dist/shell-475fQKaX.cjs +0 -62
  105. package/dist/shell-475fQKaX.cjs.map +0 -1
  106. package/dist/shell-CN6DNqeC.js +0 -51
  107. package/dist/shell-CN6DNqeC.js.map +0 -1
  108. package/dist/telemetry-B2iWkY5e.cjs.map +0 -1
  109. package/dist/telemetry-BkektVz6.js +0 -243
  110. package/dist/telemetry-BkektVz6.js.map +0 -1
  111. package/dist/validate-Bj8vbvPt.cjs.map +0 -1
  112. package/dist/validate-bHUrnYBv.js.map +0 -1
  113. package/src/commands/agent/start.ts +0 -50
  114. package/src/commands/agent.ts +0 -10
  115. package/src/commands/generate.ts +0 -59
  116. package/src/commands/init.ts +0 -51
  117. package/src/commands/mcp.ts +0 -36
  118. package/src/commands/validate.ts +0 -22
  119. package/src/constants.ts +0 -48
  120. package/src/index.ts +0 -45
  121. package/src/loggers/clackLogger.ts +0 -460
  122. package/src/loggers/fileSystemLogger.ts +0 -151
  123. package/src/loggers/githubActionsLogger.ts +0 -367
  124. package/src/loggers/plainLogger.ts +0 -243
  125. package/src/loggers/types.ts +0 -7
  126. package/src/loggers/utils.ts +0 -252
  127. package/src/runners/agent/run.ts +0 -113
  128. package/src/runners/agent/utils.ts +0 -98
  129. package/src/runners/generate/run.ts +0 -276
  130. package/src/runners/generate/utils.ts +0 -209
  131. package/src/runners/init/run.ts +0 -211
  132. package/src/runners/init/utils.ts +0 -33
  133. package/src/runners/mcp/run.ts +0 -55
  134. package/src/runners/validate/run.ts +0 -63
  135. package/src/telemetry.ts +0 -280
  136. /package/dist/{chunk-ByKO4r7w.cjs → rolldown-runtime-Bx3C2hgW.cjs} +0 -0
package/dist/index.js CHANGED
@@ -1,275 +1,47 @@
1
- import "./chunk-BvFE5Tac.js";
2
- import { t as defineCLIAdapter } from "./define-m_fp-Aqm.js";
3
- import { n as isTelemetryDisabled } from "./telemetry-BkektVz6.js";
4
- import { t as version } from "./package-BgAYWN7y.js";
5
- import { r as QUIET_FLAGS } from "./constants-B2JTeRBb.js";
6
- import { parseArgs, styleText } from "node:util";
7
- //#region ../../internals/utils/src/cli/schema.ts
1
+ import "./rolldown-runtime-C0LytTxp.js";
2
+ import { a as QUIET_FLAGS, n as isDisabled } from "./Telemetry-7z2tIqPm.js";
3
+ import { t as version } from "./package-CfWW74Ug.js";
4
+ import { styleText } from "node:util";
5
+ import { cli } from "gunshi";
6
+ //#region src/index.ts
8
7
  /**
9
- * Serializes `CommandDefinition[]` to a plain, JSON-serializable structure.
10
- * Use to expose CLI capabilities to AI agents or MCP tools.
11
- *
12
- * @example
13
- * ```ts
14
- * getCommandSchema([generateCommand, agentCommand])
15
- * // [{ name: 'generate', options: [...], subCommands: [] }, ...]
16
- * ```
8
+ * Strips the leading executable + script entries when `process.argv` is passed directly.
9
+ * Handles Node.js (`/usr/bin/node`), Bun (`/usr/local/bin/bun`), Deno, tsx, etc. All runtime
10
+ * executable paths contain a path separator; bare command names do not.
17
11
  */
18
- function getCommandSchema(defs) {
19
- return defs.map(serializeCommand);
20
- }
21
- function serializeCommand(def) {
22
- return {
23
- name: def.name,
24
- description: def.description,
25
- arguments: def.arguments,
26
- ...def.examples?.length ? { examples: def.examples } : {},
27
- options: serializeOptions(def.options ?? {}),
28
- subCommands: def.subCommands ? def.subCommands.map(serializeCommand) : []
29
- };
30
- }
31
- function serializeOptions(options) {
32
- return Object.entries(options).map(([name, opt]) => {
33
- return {
34
- name,
35
- flags: `${opt.short ? `-${opt.short}, ` : ""}--${name}${opt.type === "string" ? ` <${opt.hint ?? name}>` : ""}`,
36
- type: opt.type,
37
- description: opt.description,
38
- ...opt.default !== void 0 ? { default: opt.default } : {},
39
- ...opt.hint ? { hint: opt.hint } : {},
40
- ...opt.enum ? { enum: opt.enum } : {},
41
- ...opt.required ? { required: opt.required } : {}
42
- };
43
- });
12
+ function stripExecArgs(argv) {
13
+ const firstArgIsExecutablePath = (argv[0]?.includes("/") || argv[0]?.includes("\\")) ?? false;
14
+ return argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv;
44
15
  }
45
- //#endregion
46
- //#region ../../internals/utils/src/cli/help.ts
47
- /** Prints formatted help output for `def` using its `CommandDefinition`.
48
- *
49
- * @example
50
- * ```ts
51
- * renderHelp({ name: 'generate', description: 'Generate client code' })
52
- * // prints Usage: generate [options] ...
53
- * ```
16
+ /**
17
+ * Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a
18
+ * quiet flag is passed, then runs the generate, validate, mcp, and init commands. Defaults to
19
+ * `generate` when no command is given.
54
20
  */
55
- function renderHelp(def, parentName) {
56
- const schema = getCommandSchema([def])[0];
57
- const programName = parentName ? `${parentName} ${schema.name}` : schema.name;
58
- const argsPart = schema.arguments?.length ? ` ${schema.arguments.join(" ")}` : "";
59
- const subCmdPart = schema.subCommands.length ? " <command>" : "";
60
- console.log(`\n${styleText("bold", "Usage:")} ${programName}${argsPart}${subCmdPart} [options]\n`);
61
- if (schema.description) console.log(` ${schema.description}\n`);
62
- if (schema.subCommands.length) {
63
- console.log(styleText("bold", "Commands:"));
64
- for (const sub of schema.subCommands) console.log(` ${styleText("cyan", sub.name.padEnd(16))}${sub.description}`);
65
- console.log();
66
- }
67
- const options = [...schema.options, {
68
- name: "help",
69
- flags: "-h, --help",
70
- type: "boolean",
71
- description: "Show help"
72
- }];
73
- console.log(styleText("bold", "Options:"));
74
- for (const opt of options) {
75
- const flags = styleText("cyan", opt.flags.padEnd(30));
76
- const defaultPart = opt.default !== void 0 ? styleText("dim", ` (default: ${opt.default})`) : "";
77
- console.log(` ${flags}${opt.description}${defaultPart}`);
78
- }
79
- console.log();
80
- if (schema.examples?.length) {
81
- console.log(styleText("bold", "Examples:"));
82
- for (const ex of schema.examples) console.log(` ${styleText("dim", ex)}`);
83
- console.log();
84
- }
85
- }
86
- //#endregion
87
- //#region ../../internals/utils/src/cli/adapters/nodeAdapter.ts
88
- function buildParseOptions(def) {
89
- const result = { help: {
90
- type: "boolean",
91
- short: "h"
92
- } };
93
- for (const [name, opt] of Object.entries(def.options ?? {})) result[name] = {
94
- type: opt.type,
95
- ...opt.short ? { short: opt.short } : {},
96
- ...opt.default !== void 0 ? { default: opt.default } : {}
97
- };
98
- return result;
99
- }
100
- async function runCommand(def, argv, parentName) {
101
- const parseOptions = buildParseOptions(def);
102
- let parsed;
21
+ async function run(argv = process.argv) {
22
+ const isQuietFlag = argv.some((arg) => QUIET_FLAGS.has(arg));
23
+ if (!isDisabled() && !isQuietFlag) console.log(`${styleText("yellow", "Notice:")} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \nTo disable, set ${styleText("cyan", "KUBB_DISABLE_TELEMETRY=1")}.\n`);
24
+ const { command: generateCommand } = await import("./generate-Cc9j2-lg.js");
25
+ const { command: validateCommand } = await import("./validate-Cfi4pIS0.js");
26
+ const { command: mcpCommand } = await import("./mcp-CTs7ogBF.js");
27
+ const { command: initCommand } = await import("./init-BlTepVY_.js");
103
28
  try {
104
- const result = parseArgs({
105
- args: argv,
106
- options: parseOptions,
107
- allowPositionals: true,
108
- strict: false
29
+ await cli(stripExecArgs(argv), generateCommand, {
30
+ name: "kubb",
31
+ version,
32
+ description: generateCommand.description,
33
+ subCommands: {
34
+ generate: generateCommand,
35
+ init: initCommand,
36
+ validate: validateCommand,
37
+ mcp: mcpCommand
38
+ },
39
+ fallbackToEntry: true
109
40
  });
110
- parsed = {
111
- values: result.values,
112
- positionals: result.positionals
113
- };
114
41
  } catch {
115
- renderHelp(def, parentName);
116
- process.exit(1);
117
- }
118
- if (parsed.values["help"]) {
119
- renderHelp(def, parentName);
120
- process.exit(0);
121
- }
122
- for (const [name, opt] of Object.entries(def.options ?? {})) if (opt.required && parsed.values[name] === void 0) {
123
- console.error(styleText("red", `Error: --${name} is required`));
124
- renderHelp(def, parentName);
125
- process.exit(1);
126
- }
127
- if (!def.run) {
128
- renderHelp(def, parentName);
129
- process.exit(0);
130
- }
131
- try {
132
- await def.run(parsed);
133
- } catch (err) {
134
- console.error(styleText("red", `Error: ${err instanceof Error ? err.message : String(err)}`));
135
- renderHelp(def, parentName);
136
42
  process.exit(1);
137
43
  }
138
44
  }
139
- function printRootHelp(programName, version, defs) {
140
- console.log(`\n${styleText("bold", "Usage:")} ${programName} <command> [options]\n`);
141
- console.log(` Kubb v${version} — Generate TypeScript types, API clients, React Query hooks,`);
142
- console.log(` Zod schemas, and more from an OpenAPI specification.\n`);
143
- console.log(` Quick start: ${styleText("cyan", `${programName} init`)} to scaffold a config, then ${styleText("cyan", `${programName} generate`)} to run.\n`);
144
- console.log(styleText("bold", "Commands:"));
145
- for (const def of defs) console.log(` ${styleText("cyan", def.name.padEnd(16))}${def.description}`);
146
- console.log();
147
- console.log(styleText("bold", "Options:"));
148
- console.log(` ${styleText("cyan", "-v, --version".padEnd(30))}Show version number`);
149
- console.log(` ${styleText("cyan", "-h, --help".padEnd(30))}Show help`);
150
- console.log();
151
- console.log(`Run ${styleText("cyan", `${programName} <command> --help`)} for command-specific help.\n`);
152
- }
153
- /**
154
- * CLI adapter using `node:util parseArgs`. No external dependencies.
155
- */
156
- const nodeAdapter = defineCLIAdapter({
157
- renderHelp(def, parentName) {
158
- renderHelp(def, parentName);
159
- },
160
- async run(defs, argv, opts) {
161
- const { programName, defaultCommandName, version } = opts;
162
- const firstArgIsExecutablePath = (argv[0]?.includes("/") || argv[0]?.includes("\\")) ?? false;
163
- const args = argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv;
164
- if (args[0] === "--version" || args[0] === "-v") {
165
- console.log(version);
166
- process.exit(0);
167
- }
168
- if (args[0] === "--help" || args[0] === "-h") {
169
- printRootHelp(programName, version, defs);
170
- process.exit(0);
171
- }
172
- if (args.length === 0) {
173
- const defaultDef = defs.find((d) => d.name === defaultCommandName);
174
- if (defaultDef?.run) await runCommand(defaultDef, [], programName);
175
- else printRootHelp(programName, version, defs);
176
- return;
177
- }
178
- const [first, ...rest] = args;
179
- const isKnownSubcommand = defs.some((d) => d.name === first);
180
- let def;
181
- let commandArgv;
182
- let parentName;
183
- if (isKnownSubcommand) {
184
- def = defs.find((d) => d.name === first);
185
- commandArgv = rest;
186
- parentName = programName;
187
- } else {
188
- def = defs.find((d) => d.name === defaultCommandName);
189
- commandArgv = args;
190
- parentName = programName;
191
- }
192
- if (!def) {
193
- console.error(`Unknown command: ${first}`);
194
- printRootHelp(programName, version, defs);
195
- process.exit(1);
196
- }
197
- if (def.subCommands?.length) {
198
- const [subName, ...subRest] = commandArgv;
199
- const subDef = def.subCommands.find((s) => s.name === subName);
200
- if (subName === "--help" || subName === "-h") {
201
- renderHelp(def, parentName);
202
- process.exit(0);
203
- }
204
- if (!subDef) {
205
- renderHelp(def, parentName);
206
- process.exit(subName ? 1 : 0);
207
- }
208
- await runCommand(subDef, subRest, `${parentName} ${def.name}`);
209
- return;
210
- }
211
- await runCommand(def, commandArgv, parentName);
212
- }
213
- });
214
- //#endregion
215
- //#region ../../internals/utils/src/cli/parse.ts
216
- /**
217
- * Creates a CLI runner bound to a specific adapter.
218
- *
219
- * @default nodeAdapter (Node.js `node:util parseArgs`)
220
- *
221
- * @example
222
- * ```ts
223
- * await createCLI().run(commands, process.argv.slice(2), {
224
- * programName: 'kubb',
225
- * defaultCommandName: 'generate',
226
- * version: '5.0.0',
227
- * })
228
- * ```
229
- */
230
- function createCLI(options) {
231
- const adapter = options?.adapter ?? nodeAdapter;
232
- return { run(commands, argv, opts) {
233
- return adapter.run(commands, argv, opts);
234
- } };
235
- }
236
- //#endregion
237
- //#region ../../internals/utils/src/isFlag.ts
238
- /**
239
- * Type guard that confirms `value` is a member of `set`. Avoids type assertions with `Set<T extends string>`.
240
- */
241
- function isFlag(set, value) {
242
- for (const flag of set) if (flag === value) return true;
243
- return false;
244
- }
245
- //#endregion
246
- //#region src/index.ts
247
- const cli = createCLI();
248
- function shouldShowTelemetryNotice(argv) {
249
- if (isTelemetryDisabled()) return false;
250
- if (argv.some((arg) => isFlag(QUIET_FLAGS, arg))) return false;
251
- if (!process.stdout.isTTY) return false;
252
- return true;
253
- }
254
- async function run(argv = process.argv) {
255
- if (shouldShowTelemetryNotice(argv)) console.log(`${styleText("yellow", "Notice:")} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \nTo disable, set ${styleText("cyan", "KUBB_DISABLE_TELEMETRY=1")}.\n`);
256
- const { command: generateCommand } = await import("./generate-BhfRufgh.js");
257
- const { command: validateCommand } = await import("./validate-bHUrnYBv.js");
258
- const { command: mcpCommand } = await import("./mcp-DzOfqX_j.js");
259
- const { command: agentCommand } = await import("./agent-C5F4itrc.js");
260
- const { command: initCommand } = await import("./init-DOSXtcyb.js");
261
- await cli.run([
262
- generateCommand,
263
- validateCommand,
264
- mcpCommand,
265
- agentCommand,
266
- initCommand
267
- ], argv, {
268
- programName: "kubb",
269
- defaultCommandName: "generate",
270
- version
271
- });
272
- }
273
45
  //#endregion
274
46
  export { run };
275
47
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../internals/utils/src/cli/schema.ts","../../../internals/utils/src/cli/help.ts","../../../internals/utils/src/cli/adapters/nodeAdapter.ts","../../../internals/utils/src/cli/parse.ts","../../../internals/utils/src/isFlag.ts","../src/index.ts"],"sourcesContent":["import type { CommandDefinition, CommandSchema, OptionDefinition, OptionSchema } from './types.ts'\n\n/**\n * Serializes `CommandDefinition[]` to a plain, JSON-serializable structure.\n * Use to expose CLI capabilities to AI agents or MCP tools.\n *\n * @example\n * ```ts\n * getCommandSchema([generateCommand, agentCommand])\n * // [{ name: 'generate', options: [...], subCommands: [] }, ...]\n * ```\n */\nexport function getCommandSchema(defs: CommandDefinition[]): CommandSchema[] {\n return defs.map(serializeCommand)\n}\n\nfunction serializeCommand(def: CommandDefinition): CommandSchema {\n return {\n name: def.name,\n description: def.description,\n arguments: def.arguments,\n ...(def.examples?.length ? { examples: def.examples } : {}),\n options: serializeOptions(def.options ?? {}),\n subCommands: def.subCommands ? def.subCommands.map(serializeCommand) : [],\n }\n}\n\nfunction serializeOptions(options: Record<string, OptionDefinition>): OptionSchema[] {\n return Object.entries(options).map(([name, opt]) => {\n const shortPart = opt.short ? `-${opt.short}, ` : ''\n const valuePart = opt.type === 'string' ? ` <${opt.hint ?? name}>` : ''\n const flags = `${shortPart}--${name}${valuePart}`\n\n return {\n name,\n flags,\n type: opt.type,\n description: opt.description,\n ...(opt.default !== undefined ? { default: opt.default } : {}),\n ...(opt.hint ? { hint: opt.hint } : {}),\n ...(opt.enum ? { enum: opt.enum } : {}),\n ...(opt.required ? { required: opt.required } : {}),\n }\n })\n}\n","import { styleText } from 'node:util'\nimport { getCommandSchema } from './schema.ts'\nimport type { CommandDefinition, OptionSchema } from './types.ts'\n\n/** Prints formatted help output for `def` using its `CommandDefinition`.\n *\n * @example\n * ```ts\n * renderHelp({ name: 'generate', description: 'Generate client code' })\n * // prints Usage: generate [options] ...\n * ```\n */\nexport function renderHelp(def: CommandDefinition, parentName?: string): void {\n const schema = getCommandSchema([def])[0]!\n\n const programName = parentName ? `${parentName} ${schema.name}` : schema.name\n\n const argsPart = schema.arguments?.length ? ` ${schema.arguments.join(' ')}` : ''\n const subCmdPart = schema.subCommands.length ? ' <command>' : ''\n console.log(`\\n${styleText('bold', 'Usage:')} ${programName}${argsPart}${subCmdPart} [options]\\n`)\n\n if (schema.description) {\n console.log(` ${schema.description}\\n`)\n }\n\n if (schema.subCommands.length) {\n console.log(styleText('bold', 'Commands:'))\n for (const sub of schema.subCommands) {\n console.log(` ${styleText('cyan', sub.name.padEnd(16))}${sub.description}`)\n }\n console.log()\n }\n\n const options: OptionSchema[] = [\n ...schema.options,\n {\n name: 'help',\n flags: '-h, --help',\n type: 'boolean' as const,\n description: 'Show help',\n },\n ]\n\n console.log(styleText('bold', 'Options:'))\n for (const opt of options) {\n const flags = styleText('cyan', opt.flags.padEnd(30))\n const defaultPart = opt.default !== undefined ? styleText('dim', ` (default: ${opt.default})`) : ''\n console.log(` ${flags}${opt.description}${defaultPart}`)\n }\n console.log()\n\n if (schema.examples?.length) {\n console.log(styleText('bold', 'Examples:'))\n for (const ex of schema.examples) {\n console.log(` ${styleText('dim', ex)}`)\n }\n console.log()\n }\n}\n","import { parseArgs, styleText } from 'node:util'\nimport { defineCLIAdapter } from '../define.ts'\nimport { renderHelp } from '../help.ts'\nimport type { CommandDefinition, OptionType, ParsedArgs, RunOptions } from '../types.ts'\n\ntype ParseOption = {\n type: OptionType\n short?: string\n default?: string | boolean\n}\ntype ParseOptions = Record<string, ParseOption>\n\nfunction buildParseOptions(def: CommandDefinition): ParseOptions {\n const result: ParseOptions = {\n help: { type: 'boolean', short: 'h' },\n }\n\n for (const [name, opt] of Object.entries(def.options ?? {})) {\n result[name] = {\n type: opt.type,\n ...(opt.short ? { short: opt.short } : {}),\n ...(opt.default !== undefined ? { default: opt.default } : {}),\n }\n }\n\n return result\n}\n\nasync function runCommand(def: CommandDefinition, argv: string[], parentName?: string): Promise<void> {\n const parseOptions = buildParseOptions(def)\n\n let parsed: ParsedArgs\n try {\n const result = parseArgs({\n args: argv,\n options: parseOptions,\n allowPositionals: true,\n strict: false,\n })\n parsed = {\n values: result.values as ParsedArgs['values'],\n positionals: result.positionals,\n }\n } catch {\n renderHelp(def, parentName)\n process.exit(1)\n }\n\n if (parsed.values['help']) {\n renderHelp(def, parentName)\n process.exit(0)\n }\n\n // Validate required options before running the command\n for (const [name, opt] of Object.entries(def.options ?? {})) {\n if (opt.required && parsed.values[name] === undefined) {\n console.error(styleText('red', `Error: --${name} is required`))\n renderHelp(def, parentName)\n process.exit(1)\n }\n }\n\n if (!def.run) {\n renderHelp(def, parentName)\n process.exit(0)\n }\n\n try {\n await def.run(parsed)\n } catch (err) {\n console.error(styleText('red', `Error: ${err instanceof Error ? err.message : String(err)}`))\n renderHelp(def, parentName)\n process.exit(1)\n }\n}\n\nfunction printRootHelp(programName: string, version: string, defs: CommandDefinition[]): void {\n console.log(`\\n${styleText('bold', 'Usage:')} ${programName} <command> [options]\\n`)\n console.log(` Kubb v${version} — Generate TypeScript types, API clients, React Query hooks,`)\n console.log(` Zod schemas, and more from an OpenAPI specification.\\n`)\n console.log(` Quick start: ${styleText('cyan', `${programName} init`)} to scaffold a config, then ${styleText('cyan', `${programName} generate`)} to run.\\n`)\n console.log(styleText('bold', 'Commands:'))\n for (const def of defs) {\n console.log(` ${styleText('cyan', def.name.padEnd(16))}${def.description}`)\n }\n console.log()\n console.log(styleText('bold', 'Options:'))\n console.log(` ${styleText('cyan', '-v, --version'.padEnd(30))}Show version number`)\n console.log(` ${styleText('cyan', '-h, --help'.padEnd(30))}Show help`)\n console.log()\n console.log(`Run ${styleText('cyan', `${programName} <command> --help`)} for command-specific help.\\n`)\n}\n\n/**\n * CLI adapter using `node:util parseArgs`. No external dependencies.\n */\nexport const nodeAdapter = defineCLIAdapter({\n renderHelp(def: CommandDefinition, parentName?: string): void {\n renderHelp(def, parentName)\n },\n\n async run(defs: CommandDefinition[], argv: string[], opts: RunOptions): Promise<void> {\n const { programName, defaultCommandName, version } = opts\n\n // Strip the leading executable + script entries when process.argv is passed directly.\n // Handles Node.js (/usr/bin/node), Bun (/usr/local/bin/bun), Deno, tsx, etc.\n // All runtime executable paths contain a path separator; bare command names do not.\n const firstArgIsExecutablePath = (argv[0]?.includes('/') || argv[0]?.includes('\\\\')) ?? false\n const args = argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv\n\n if (args[0] === '--version' || args[0] === '-v') {\n console.log(version)\n process.exit(0)\n }\n\n if (args[0] === '--help' || args[0] === '-h') {\n printRootHelp(programName, version, defs)\n process.exit(0)\n }\n\n if (args.length === 0) {\n const defaultDef = defs.find((d) => d.name === defaultCommandName)\n if (defaultDef?.run) {\n await runCommand(defaultDef, [], programName)\n } else {\n printRootHelp(programName, version, defs)\n }\n return\n }\n\n const [first, ...rest] = args\n const isKnownSubcommand = defs.some((d) => d.name === first)\n\n let def: CommandDefinition | undefined\n let commandArgv: string[]\n let parentName: string | undefined\n\n if (isKnownSubcommand) {\n def = defs.find((d) => d.name === first)\n commandArgv = rest\n parentName = programName\n } else {\n def = defs.find((d) => d.name === defaultCommandName)\n commandArgv = args\n parentName = programName\n }\n\n if (!def) {\n console.error(`Unknown command: ${first}`)\n printRootHelp(programName, version, defs)\n process.exit(1)\n }\n\n if (def.subCommands?.length) {\n const [subName, ...subRest] = commandArgv\n const subDef = def.subCommands.find((s) => s.name === subName)\n\n if (subName === '--help' || subName === '-h') {\n renderHelp(def, parentName)\n process.exit(0)\n }\n\n if (!subDef) {\n renderHelp(def, parentName)\n process.exit(subName ? 1 : 0)\n }\n\n await runCommand(subDef, subRest, `${parentName} ${def.name}`)\n return\n }\n\n await runCommand(def, commandArgv, parentName)\n },\n})\n","import { nodeAdapter } from './adapters/nodeAdapter.ts'\nimport type { CLIAdapter, CommandDefinition, RunOptions } from './types.ts'\n\n/**\n * Creates a CLI runner bound to a specific adapter.\n *\n * @default nodeAdapter (Node.js `node:util parseArgs`)\n *\n * @example\n * ```ts\n * await createCLI().run(commands, process.argv.slice(2), {\n * programName: 'kubb',\n * defaultCommandName: 'generate',\n * version: '5.0.0',\n * })\n * ```\n */\nexport function createCLI(options?: { adapter?: CLIAdapter }): {\n run(commands: CommandDefinition[], argv: string[], opts: RunOptions): Promise<void>\n} {\n const adapter = options?.adapter ?? nodeAdapter\n\n return {\n run(commands, argv, opts) {\n return adapter.run(commands, argv, opts)\n },\n }\n}\n","/**\n * Type guard that confirms `value` is a member of `set`. Avoids type assertions with `Set<T extends string>`.\n */\nexport function isFlag<T extends string>(set: ReadonlySet<T>, value: string): value is T {\n for (const flag of set) {\n if (flag === value) return true\n }\n return false\n}\n","import { styleText } from 'node:util'\nimport { createCLI, isFlag } from '@internals/utils'\nimport { version } from '../package.json'\nimport { QUIET_FLAGS } from './constants.ts'\nimport { isTelemetryDisabled } from './telemetry.ts'\n\nconst cli = createCLI()\n\nfunction shouldShowTelemetryNotice(argv: Array<string>): boolean {\n if (isTelemetryDisabled()) {\n return false\n }\n\n // Skip when the user is just asking for help or version info\n if (argv.some((arg) => isFlag(QUIET_FLAGS, arg))) {\n return false\n }\n\n // Skip in non-interactive / scripting contexts\n if (!process.stdout.isTTY) {\n return false\n }\n\n return true\n}\n\nexport async function run(argv: Array<string> = process.argv): Promise<void> {\n if (shouldShowTelemetryNotice(argv)) {\n console.log(\n `${styleText('yellow', 'Notice:')} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \\nTo disable, set ${styleText('cyan', 'KUBB_DISABLE_TELEMETRY=1')}.\\n`,\n )\n }\n\n const { command: generateCommand } = await import('./commands/generate.ts')\n const { command: validateCommand } = await import('./commands/validate.ts')\n const { command: mcpCommand } = await import('./commands/mcp.ts')\n const { command: agentCommand } = await import('./commands/agent.ts')\n const { command: initCommand } = await import('./commands/init.ts')\n\n await cli.run([generateCommand, validateCommand, mcpCommand, agentCommand, initCommand], argv, {\n programName: 'kubb',\n defaultCommandName: 'generate',\n version,\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAYA,SAAgB,iBAAiB,MAA4C;CAC3E,OAAO,KAAK,IAAI,iBAAiB;;AAGnC,SAAS,iBAAiB,KAAuC;CAC/D,OAAO;EACL,MAAM,IAAI;EACV,aAAa,IAAI;EACjB,WAAW,IAAI;EACf,GAAI,IAAI,UAAU,SAAS,EAAE,UAAU,IAAI,UAAU,GAAG,EAAE;EAC1D,SAAS,iBAAiB,IAAI,WAAW,EAAE,CAAC;EAC5C,aAAa,IAAI,cAAc,IAAI,YAAY,IAAI,iBAAiB,GAAG,EAAE;EAC1E;;AAGH,SAAS,iBAAiB,SAA2D;CACnF,OAAO,OAAO,QAAQ,QAAQ,CAAC,KAAK,CAAC,MAAM,SAAS;EAKlD,OAAO;GACL;GACA,OAAA,G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AAa;EACb,oBAAoB;EACpB;EACD,CAAC"}
1
+ {"version":3,"file":"index.js","names":["isTelemetryDisabled"],"sources":["../src/index.ts"],"sourcesContent":["import { styleText } from 'node:util'\nimport { cli } from 'gunshi'\nimport { isDisabled as isTelemetryDisabled } from './Telemetry.ts'\nimport { version } from '../package.json'\nimport { QUIET_FLAGS } from './constants.ts'\n\n/**\n * Strips the leading executable + script entries when `process.argv` is passed directly.\n * Handles Node.js (`/usr/bin/node`), Bun (`/usr/local/bin/bun`), Deno, tsx, etc. All runtime\n * executable paths contain a path separator; bare command names do not.\n */\nfunction stripExecArgs(argv: Array<string>): Array<string> {\n const firstArgIsExecutablePath = (argv[0]?.includes('/') || argv[0]?.includes('\\\\')) ?? false\n return argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv\n}\n\n/**\n * Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a\n * quiet flag is passed, then runs the generate, validate, mcp, and init commands. Defaults to\n * `generate` when no command is given.\n */\nexport async function run(argv: Array<string> = process.argv): Promise<void> {\n const isQuietFlag = argv.some((arg) => QUIET_FLAGS.has(arg))\n\n if (!isTelemetryDisabled() && !isQuietFlag) {\n console.log(\n `${styleText('yellow', 'Notice:')} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \\nTo disable, set ${styleText('cyan', 'KUBB_DISABLE_TELEMETRY=1')}.\\n`,\n )\n }\n\n const { command: generateCommand } = await import('./commands/generate.ts')\n const { command: validateCommand } = await import('./commands/validate.ts')\n const { command: mcpCommand } = await import('./commands/mcp.ts')\n const { command: initCommand } = await import('./commands/init.ts')\n\n try {\n await cli(stripExecArgs(argv), generateCommand, {\n name: 'kubb',\n version,\n description: generateCommand.description,\n subCommands: {\n generate: generateCommand,\n init: initCommand,\n validate: validateCommand,\n mcp: mcpCommand,\n },\n fallbackToEntry: true,\n })\n } catch {\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;AAWA,SAAS,cAAc,MAAoC;CACzD,MAAM,4BAA4B,KAAK,EAAE,EAAE,SAAS,GAAG,KAAK,KAAK,EAAE,EAAE,SAAS,IAAI,MAAM;CACxF,OAAO,KAAK,UAAU,KAAK,2BAA2B,KAAK,MAAM,CAAC,IAAI;AACxE;;;;;;AAOA,eAAsB,IAAI,OAAsB,QAAQ,MAAqB;CAC3E,MAAM,cAAc,KAAK,MAAM,QAAQ,YAAY,IAAI,GAAG,CAAC;CAE3D,IAAI,CAACA,WAAoB,KAAK,CAAC,aAC7B,QAAQ,IACN,GAAG,UAAU,UAAU,SAAS,EAAE,uIAAuI,UAAU,QAAQ,0BAA0B,EAAE,IACzN;CAGF,MAAM,EAAE,SAAS,oBAAoB,MAAM,OAAO;CAClD,MAAM,EAAE,SAAS,oBAAoB,MAAM,OAAO;CAClD,MAAM,EAAE,SAAS,eAAe,MAAM,OAAO;CAC7C,MAAM,EAAE,SAAS,gBAAgB,MAAM,OAAO;CAE9C,IAAI;EACF,MAAM,IAAI,cAAc,IAAI,GAAG,iBAAiB;GAC9C,MAAM;GACN;GACA,aAAa,gBAAgB;GAC7B,aAAa;IACX,UAAU;IACV,MAAM;IACN,UAAU;IACV,KAAK;GACP;GACA,iBAAiB;EACnB,CAAC;CACH,QAAQ;EACN,QAAQ,KAAK,CAAC;CAChB;AACF"}
@@ -1,17 +1,17 @@
1
- import "./chunk-BvFE5Tac.js";
2
- import { n as defineCommand } from "./define-m_fp-Aqm.js";
3
- import { t as version } from "./package-BgAYWN7y.js";
1
+ import "./rolldown-runtime-C0LytTxp.js";
2
+ import { t as version } from "./package-CfWW74Ug.js";
3
+ import { define } from "gunshi";
4
4
  //#region src/commands/init.ts
5
- const command = defineCommand({
5
+ const command = define({
6
6
  name: "init",
7
7
  description: "Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.",
8
8
  examples: [
9
9
  "kubb init",
10
10
  "kubb init --yes",
11
11
  "kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod",
12
- "kubb init --plugins plugin-ts,plugin-client,plugin-react-query"
13
- ],
14
- options: {
12
+ "kubb init --plugins plugin-ts,plugin-axios,plugin-react-query"
13
+ ].join("\n"),
14
+ args: {
15
15
  yes: {
16
16
  type: "boolean",
17
17
  description: "Skip prompts and use default options",
@@ -22,22 +22,22 @@ const command = defineCommand({
22
22
  type: "string",
23
23
  description: "Path to the OpenAPI specification",
24
24
  short: "i",
25
- hint: "path"
25
+ metavar: "path"
26
26
  },
27
27
  output: {
28
28
  type: "string",
29
29
  description: "Output directory for generated files",
30
30
  short: "o",
31
- hint: "path"
31
+ metavar: "path"
32
32
  },
33
33
  plugins: {
34
34
  type: "string",
35
- description: "Comma-separated list of plugins to use (plugin-ts, plugin-client, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)",
36
- hint: "plugin-ts,plugin-zod,..."
35
+ description: "Comma-separated list of plugins to use (plugin-ts, plugin-axios, plugin-fetch, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)",
36
+ metavar: "plugin-ts,plugin-zod,..."
37
37
  }
38
38
  },
39
39
  async run({ values }) {
40
- const { run } = await import("./run-CF97BWVa.js");
40
+ const { run } = await import("./run-CINOocLR.js");
41
41
  await run({
42
42
  yes: values.yes,
43
43
  version,
@@ -50,4 +50,4 @@ const command = defineCommand({
50
50
  //#endregion
51
51
  export { command };
52
52
 
53
- //# sourceMappingURL=init-DOSXtcyb.js.map
53
+ //# sourceMappingURL=init-BlTepVY_.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-BlTepVY_.js","names":[],"sources":["../src/commands/init.ts"],"sourcesContent":["import { define } from 'gunshi'\nimport { version } from '../../package.json'\n\nexport const command = define({\n name: 'init',\n description:\n 'Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n ].join('\\n'),\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use default options',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated list of plugins to use (plugin-ts, plugin-axios, plugin-fetch, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/init/run.ts')\n\n await run({\n yes: values.yes,\n version,\n input: values.input,\n output: values.output,\n plugins: values.plugins,\n })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAU,OAAO;CAC5B,MAAM;CACN,aACE;CACF,UAAU;EACR;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,MAAM;EACJ,KAAK;GACH,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aACE;GACF,SAAS;EACX;CACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI;GACR,KAAK,OAAO;GACZ;GACA,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,SAAS,OAAO;EAClB,CAAC;CACH;AACF,CAAC"}
@@ -1,17 +1,16 @@
1
- require("./chunk-ByKO4r7w.cjs");
2
- const require_define = require("./define-Bdn8j5VM.cjs");
3
- const require_package = require("./package-DHGhrRW-.cjs");
1
+ require("./rolldown-runtime-Bx3C2hgW.cjs");
2
+ const require_package = require("./package-DPdskCYh.cjs");
4
3
  //#region src/commands/init.ts
5
- const command = require_define.defineCommand({
4
+ const command = (0, require("gunshi").define)({
6
5
  name: "init",
7
6
  description: "Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.",
8
7
  examples: [
9
8
  "kubb init",
10
9
  "kubb init --yes",
11
10
  "kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod",
12
- "kubb init --plugins plugin-ts,plugin-client,plugin-react-query"
13
- ],
14
- options: {
11
+ "kubb init --plugins plugin-ts,plugin-axios,plugin-react-query"
12
+ ].join("\n"),
13
+ args: {
15
14
  yes: {
16
15
  type: "boolean",
17
16
  description: "Skip prompts and use default options",
@@ -22,22 +21,22 @@ const command = require_define.defineCommand({
22
21
  type: "string",
23
22
  description: "Path to the OpenAPI specification",
24
23
  short: "i",
25
- hint: "path"
24
+ metavar: "path"
26
25
  },
27
26
  output: {
28
27
  type: "string",
29
28
  description: "Output directory for generated files",
30
29
  short: "o",
31
- hint: "path"
30
+ metavar: "path"
32
31
  },
33
32
  plugins: {
34
33
  type: "string",
35
- description: "Comma-separated list of plugins to use (plugin-ts, plugin-client, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)",
36
- hint: "plugin-ts,plugin-zod,..."
34
+ description: "Comma-separated list of plugins to use (plugin-ts, plugin-axios, plugin-fetch, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)",
35
+ metavar: "plugin-ts,plugin-zod,..."
37
36
  }
38
37
  },
39
38
  async run({ values }) {
40
- const { run } = await Promise.resolve().then(() => require("./run-YsoCk5we.cjs"));
39
+ const { run } = await Promise.resolve().then(() => require("./run-BNOCBw2y.cjs"));
41
40
  await run({
42
41
  yes: values.yes,
43
42
  version: require_package.version,
@@ -50,4 +49,4 @@ const command = require_define.defineCommand({
50
49
  //#endregion
51
50
  exports.command = command;
52
51
 
53
- //# sourceMappingURL=init-bKtEOvhK.cjs.map
52
+ //# sourceMappingURL=init-CvVRvhfJ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-CvVRvhfJ.cjs","names":[],"sources":["../src/commands/init.ts"],"sourcesContent":["import { define } from 'gunshi'\nimport { version } from '../../package.json'\n\nexport const command = define({\n name: 'init',\n description:\n 'Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n ].join('\\n'),\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use default options',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated list of plugins to use (plugin-ts, plugin-axios, plugin-fetch, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/init/run.ts')\n\n await run({\n yes: values.yes,\n version,\n input: values.input,\n output: values.output,\n plugins: values.plugins,\n })\n },\n})\n"],"mappings":";;;AAGA,MAAa,WAAA,mBAAA,CAAA,CAAA,OAAA,CAAiB;CAC5B,MAAM;CACN,aACE;CACF,UAAU;EACR;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,MAAM;EACJ,KAAK;GACH,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aACE;GACF,SAAS;EACX;CACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI;GACR,KAAK,OAAO;GACZ,SAAA,gBAAA;GACA,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,SAAS,OAAO;EAClB,CAAC;CACH;AACF,CAAC"}
@@ -0,0 +1,21 @@
1
+ import "./rolldown-runtime-C0LytTxp.js";
2
+ import { t as version } from "./package-CfWW74Ug.js";
3
+ import { define } from "gunshi";
4
+ //#region src/commands/mcp.ts
5
+ const command = define({
6
+ name: "mcp",
7
+ description: "Start a Model Context Protocol (MCP) server that exposes Kubb code generation as tools for AI assistants. Once running, configure your AI client (Claude, Cursor, Windsurf, etc.) to connect to it — the assistant can then call kubb generate directly without leaving the chat.",
8
+ examples: [
9
+ "kubb mcp",
10
+ "# Then add to your MCP client config:",
11
+ "# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }"
12
+ ].join("\n"),
13
+ async run() {
14
+ const { run } = await import("./run-lgrTO14E.js");
15
+ await run({ version });
16
+ }
17
+ });
18
+ //#endregion
19
+ export { command };
20
+
21
+ //# sourceMappingURL=mcp-CTs7ogBF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-CTs7ogBF.js","names":[],"sources":["../src/commands/mcp.ts"],"sourcesContent":["import { define } from 'gunshi'\nimport { version } from '../../package.json'\n\nexport const command = define({\n name: 'mcp',\n description:\n 'Start a Model Context Protocol (MCP) server that exposes Kubb code generation as tools for AI assistants. Once running, configure your AI client (Claude, Cursor, Windsurf, etc.) to connect to it — the assistant can then call kubb generate directly without leaving the chat.',\n examples: ['kubb mcp', '# Then add to your MCP client config:', '# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }'].join('\\n'),\n async run() {\n const { run } = await import('../runners/mcp/run.ts')\n\n await run({ version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAU,OAAO;CAC5B,MAAM;CACN,aACE;CACF,UAAU;EAAC;EAAY;EAAyC;CAA+E,CAAC,CAAC,KAAK,IAAI;CAC1J,MAAM,MAAM;EACV,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI,EAAE,QAAQ,CAAC;CACvB;AACF,CAAC"}
@@ -0,0 +1,20 @@
1
+ require("./rolldown-runtime-Bx3C2hgW.cjs");
2
+ const require_package = require("./package-DPdskCYh.cjs");
3
+ //#region src/commands/mcp.ts
4
+ const command = (0, require("gunshi").define)({
5
+ name: "mcp",
6
+ description: "Start a Model Context Protocol (MCP) server that exposes Kubb code generation as tools for AI assistants. Once running, configure your AI client (Claude, Cursor, Windsurf, etc.) to connect to it — the assistant can then call kubb generate directly without leaving the chat.",
7
+ examples: [
8
+ "kubb mcp",
9
+ "# Then add to your MCP client config:",
10
+ "# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }"
11
+ ].join("\n"),
12
+ async run() {
13
+ const { run } = await Promise.resolve().then(() => require("./run-D2vd34xp.cjs"));
14
+ await run({ version: require_package.version });
15
+ }
16
+ });
17
+ //#endregion
18
+ exports.command = command;
19
+
20
+ //# sourceMappingURL=mcp-szP8HzB7.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-szP8HzB7.cjs","names":[],"sources":["../src/commands/mcp.ts"],"sourcesContent":["import { define } from 'gunshi'\nimport { version } from '../../package.json'\n\nexport const command = define({\n name: 'mcp',\n description:\n 'Start a Model Context Protocol (MCP) server that exposes Kubb code generation as tools for AI assistants. Once running, configure your AI client (Claude, Cursor, Windsurf, etc.) to connect to it — the assistant can then call kubb generate directly without leaving the chat.',\n examples: ['kubb mcp', '# Then add to your MCP client config:', '# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }'].join('\\n'),\n async run() {\n const { run } = await import('../runners/mcp/run.ts')\n\n await run({ version })\n },\n})\n"],"mappings":";;;AAGA,MAAa,WAAA,mBAAA,CAAA,CAAA,OAAA,CAAiB;CAC5B,MAAM;CACN,aACE;CACF,UAAU;EAAC;EAAY;EAAyC;CAA+E,CAAC,CAAC,KAAK,IAAI;CAC1J,MAAM,MAAM;EACV,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI,EAAE,SAAA,gBAAA,QAAQ,CAAC;CACvB;AACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ //#region package.json
2
+ var version = "5.0.0-beta.93";
3
+ //#endregion
4
+ export { version as t };
5
+
6
+ //# sourceMappingURL=package-CfWW74Ug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-CfWW74Ug.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "5.0.0-beta.9";
2
+ var version = "5.0.0-beta.93";
3
3
  //#endregion
4
4
  Object.defineProperty(exports, "version", {
5
5
  enumerable: true,
@@ -8,4 +8,4 @@ Object.defineProperty(exports, "version", {
8
8
  }
9
9
  });
10
10
 
11
- //# sourceMappingURL=package-DHGhrRW-.cjs.map
11
+ //# sourceMappingURL=package-DPdskCYh.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-DPdskCYh.cjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
@@ -1,4 +1,3 @@
1
- import "node:module";
2
1
  //#region \0rolldown/runtime.js
3
2
  var __defProp = Object.defineProperty;
4
3
  var __name = (target, value) => __defProp(target, "name", {