@kubb/cli 5.0.0-beta.4 → 5.0.0-beta.40

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 (155) hide show
  1. package/README.md +198 -36
  2. package/dist/agent-DQerNyd8.cjs +70 -0
  3. package/dist/agent-DQerNyd8.cjs.map +1 -0
  4. package/dist/agent-ZKJkTTGN.js +68 -0
  5. package/dist/agent-ZKJkTTGN.js.map +1 -0
  6. package/dist/{chunk--u3MIqq1.js → chunk-CRm0XQPb.js} +1 -0
  7. package/dist/constants-84a47qA-.js +35 -0
  8. package/dist/constants-84a47qA-.js.map +1 -0
  9. package/dist/constants-AHhyFH15.cjs +139 -0
  10. package/dist/constants-AHhyFH15.cjs.map +1 -0
  11. package/dist/constants-BtmponZ3.cjs +58 -0
  12. package/dist/constants-BtmponZ3.cjs.map +1 -0
  13. package/dist/constants-C94RKp3A.js +116 -0
  14. package/dist/constants-C94RKp3A.js.map +1 -0
  15. package/dist/{define-Bdn8j5VM.cjs → define-C4AB3POr.cjs} +2 -2
  16. package/dist/{define-Bdn8j5VM.cjs.map → define-C4AB3POr.cjs.map} +1 -1
  17. package/dist/{define-Ctii4bel.js → define-DNG1U8ha.js} +2 -2
  18. package/dist/{define-Ctii4bel.js.map → define-DNG1U8ha.js.map} +1 -1
  19. package/dist/{errors-CjPmyZHy.js → errors-CoxrNXaA.js} +2 -2
  20. package/dist/{errors-CjPmyZHy.js.map → errors-CoxrNXaA.js.map} +1 -1
  21. package/dist/{errors-CLCjoSg0.cjs → errors-DykI11xo.cjs} +2 -2
  22. package/dist/{errors-CLCjoSg0.cjs.map → errors-DykI11xo.cjs.map} +1 -1
  23. package/dist/generate-40x9PP4o.js +77 -0
  24. package/dist/generate-40x9PP4o.js.map +1 -0
  25. package/dist/generate-DQLvFw4z.cjs +76 -0
  26. package/dist/generate-DQLvFw4z.cjs.map +1 -0
  27. package/dist/index.cjs +23 -14
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +23 -14
  31. package/dist/index.js.map +1 -1
  32. package/dist/init-CT9RChdK.js +53 -0
  33. package/dist/init-CT9RChdK.js.map +1 -0
  34. package/dist/init-sEaUN7Dj.cjs +53 -0
  35. package/dist/init-sEaUN7Dj.cjs.map +1 -0
  36. package/dist/mcp-Siyb6fTT.cjs +39 -0
  37. package/dist/mcp-Siyb6fTT.cjs.map +1 -0
  38. package/dist/mcp-cjPrOeot.js +39 -0
  39. package/dist/mcp-cjPrOeot.js.map +1 -0
  40. package/dist/{package-BapVyQ-w.cjs → package-BJ6qam2Y.cjs} +2 -2
  41. package/dist/package-BJ6qam2Y.cjs.map +1 -0
  42. package/dist/package-CR5vEK4K.js +6 -0
  43. package/dist/package-CR5vEK4K.js.map +1 -0
  44. package/dist/{agent-sdYBBgrd.js → run-BQ3Qj0xB.js} +46 -43
  45. package/dist/run-BQ3Qj0xB.js.map +1 -0
  46. package/dist/run-BQzoaxjR.js +32 -0
  47. package/dist/run-BQzoaxjR.js.map +1 -0
  48. package/dist/run-CGf0KEts.js +51 -0
  49. package/dist/run-CGf0KEts.js.map +1 -0
  50. package/dist/{generate-CNrRLY4n.js → run-CHZKHTv0.js} +832 -828
  51. package/dist/run-CHZKHTv0.js.map +1 -0
  52. package/dist/{init-CZ5Xq2Hd.cjs → run-C_NMctua.cjs} +107 -149
  53. package/dist/run-C_NMctua.cjs.map +1 -0
  54. package/dist/{generate-B1Pa2ho-.cjs → run-CcQawFNK.cjs} +784 -780
  55. package/dist/run-CcQawFNK.cjs.map +1 -0
  56. package/dist/run-CkTpemme.cjs +52 -0
  57. package/dist/run-CkTpemme.cjs.map +1 -0
  58. package/dist/run-Cl4SrSob.cjs +33 -0
  59. package/dist/run-Cl4SrSob.cjs.map +1 -0
  60. package/dist/{agent-B4cAAab2.cjs → run-D-s2LdlW.cjs} +46 -43
  61. package/dist/run-D-s2LdlW.cjs.map +1 -0
  62. package/dist/{init-eNRlotJK.js → run-D8dCWepS.js} +107 -149
  63. package/dist/run-D8dCWepS.js.map +1 -0
  64. package/dist/{shell-DLzN4fRo.js → shell-BrqyJdB7.js} +2 -2
  65. package/dist/{shell-DLzN4fRo.js.map → shell-BrqyJdB7.js.map} +1 -1
  66. package/dist/{shell-475fQKaX.cjs → shell-Lh-vLWwH.cjs} +2 -2
  67. package/dist/{shell-475fQKaX.cjs.map → shell-Lh-vLWwH.cjs.map} +1 -1
  68. package/dist/validate-8pgfxUTy.js +26 -0
  69. package/dist/validate-8pgfxUTy.js.map +1 -0
  70. package/dist/validate-CstV7Pc2.cjs +26 -0
  71. package/dist/validate-CstV7Pc2.cjs.map +1 -0
  72. package/package.json +16 -15
  73. package/src/commands/agent/start.ts +10 -7
  74. package/src/commands/agent.ts +3 -1
  75. package/src/commands/generate.ts +21 -13
  76. package/src/commands/init.ts +34 -3
  77. package/src/commands/mcp.ts +28 -4
  78. package/src/commands/validate.ts +6 -4
  79. package/src/constants.ts +3 -74
  80. package/src/index.ts +6 -4
  81. package/src/loggers/clackLogger.ts +143 -181
  82. package/src/loggers/githubActionsLogger.ts +119 -121
  83. package/src/loggers/plainLogger.ts +50 -100
  84. package/src/loggers/types.ts +6 -0
  85. package/src/loggers/utils.ts +190 -18
  86. package/src/runners/agent/run.ts +113 -0
  87. package/src/runners/agent/utils.ts +98 -0
  88. package/src/runners/generate/run.ts +411 -0
  89. package/src/runners/generate/utils.ts +222 -0
  90. package/src/runners/init/run.ts +212 -0
  91. package/src/{utils/packageManager.ts → runners/init/utils.ts} +12 -2
  92. package/src/runners/mcp/run.ts +37 -0
  93. package/src/runners/validate/run.ts +63 -0
  94. package/dist/agent-B4cAAab2.cjs.map +0 -1
  95. package/dist/agent-CR6Z96og.js +0 -56
  96. package/dist/agent-CR6Z96og.js.map +0 -1
  97. package/dist/agent-Dmxzqg4d.cjs +0 -58
  98. package/dist/agent-Dmxzqg4d.cjs.map +0 -1
  99. package/dist/agent-sdYBBgrd.js.map +0 -1
  100. package/dist/constants-CnDXa1R6.cjs +0 -148
  101. package/dist/constants-CnDXa1R6.cjs.map +0 -1
  102. package/dist/constants-aL3CP_Wq.js +0 -95
  103. package/dist/constants-aL3CP_Wq.js.map +0 -1
  104. package/dist/generate-B1Pa2ho-.cjs.map +0 -1
  105. package/dist/generate-BDGOOsBM.cjs +0 -65
  106. package/dist/generate-BDGOOsBM.cjs.map +0 -1
  107. package/dist/generate-CNrRLY4n.js.map +0 -1
  108. package/dist/generate-DuhxPLGr.js +0 -66
  109. package/dist/generate-DuhxPLGr.js.map +0 -1
  110. package/dist/init-CZ5Xq2Hd.cjs.map +0 -1
  111. package/dist/init-CnZXHrbq.js +0 -25
  112. package/dist/init-CnZXHrbq.js.map +0 -1
  113. package/dist/init-NYJSZJSb.cjs +0 -25
  114. package/dist/init-NYJSZJSb.cjs.map +0 -1
  115. package/dist/init-eNRlotJK.js.map +0 -1
  116. package/dist/mcp-CYOgxB82.cjs +0 -47
  117. package/dist/mcp-CYOgxB82.cjs.map +0 -1
  118. package/dist/mcp-CdFWyrwi.cjs +0 -16
  119. package/dist/mcp-CdFWyrwi.cjs.map +0 -1
  120. package/dist/mcp-DhSxuDMD.js +0 -16
  121. package/dist/mcp-DhSxuDMD.js.map +0 -1
  122. package/dist/mcp-DmJm3TrU.js +0 -46
  123. package/dist/mcp-DmJm3TrU.js.map +0 -1
  124. package/dist/package-BapVyQ-w.cjs.map +0 -1
  125. package/dist/package-DyJE-qNq.js +0 -6
  126. package/dist/package-DyJE-qNq.js.map +0 -1
  127. package/dist/telemetry-DN95_2pF.cjs +0 -282
  128. package/dist/telemetry-DN95_2pF.cjs.map +0 -1
  129. package/dist/telemetry-LgT_sdPe.js +0 -245
  130. package/dist/telemetry-LgT_sdPe.js.map +0 -1
  131. package/dist/validate-C6npXzel.cjs +0 -25
  132. package/dist/validate-C6npXzel.cjs.map +0 -1
  133. package/dist/validate-kLJoT_hi.js +0 -33
  134. package/dist/validate-kLJoT_hi.js.map +0 -1
  135. package/dist/validate-n38Rh-Y7.js +0 -25
  136. package/dist/validate-n38Rh-Y7.js.map +0 -1
  137. package/dist/validate-yKKzqEZ5.cjs +0 -34
  138. package/dist/validate-yKKzqEZ5.cjs.map +0 -1
  139. package/src/loggers/fileSystemLogger.ts +0 -138
  140. package/src/runners/agent.ts +0 -155
  141. package/src/runners/generate.ts +0 -333
  142. package/src/runners/init.ts +0 -296
  143. package/src/runners/mcp.ts +0 -51
  144. package/src/runners/validate.ts +0 -39
  145. package/src/types.ts +0 -11
  146. package/src/utils/Writables.ts +0 -17
  147. package/src/utils/executeHooks.ts +0 -45
  148. package/src/utils/flags.ts +0 -9
  149. package/src/utils/getConfig.ts +0 -10
  150. package/src/utils/getCosmiConfig.ts +0 -80
  151. package/src/utils/getSummary.ts +0 -68
  152. package/src/utils/runHook.ts +0 -91
  153. package/src/utils/telemetry.ts +0 -273
  154. package/src/utils/watcher.ts +0 -19
  155. /package/dist/{chunk-ByKO4r7w.cjs → chunk-Bx3C2hgW.cjs} +0 -0
@@ -1,9 +1,12 @@
1
1
  import { defineCommand } from '@internals/utils'
2
+ import type { ReporterName } from '@kubb/core'
2
3
 
3
4
  export const command = defineCommand({
4
5
  name: 'generate',
5
- description: "[input] Generate files based on a 'kubb.config.ts' file",
6
+ description:
7
+ 'Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.',
6
8
  arguments: ['[input]'],
9
+ examples: ['kubb generate', 'kubb generate ./openapi.yaml', 'kubb generate --config kubb.config.ts', 'kubb generate --watch'],
7
10
  options: {
8
11
  config: {
9
12
  type: 'string',
@@ -12,11 +15,11 @@ export const command = defineCommand({
12
15
  },
13
16
  logLevel: {
14
17
  type: 'string',
15
- description: 'Info, silent, verbose or debug',
18
+ description: 'Info, silent or verbose',
16
19
  short: 'l',
17
20
  default: 'info',
18
- hint: 'silent|info|verbose|debug',
19
- enum: ['silent', 'info', 'verbose', 'debug'],
21
+ hint: 'silent|info|verbose',
22
+ enum: ['silent', 'info', 'verbose'],
20
23
  },
21
24
  watch: {
22
25
  type: 'boolean',
@@ -24,12 +27,6 @@ export const command = defineCommand({
24
27
  short: 'w',
25
28
  default: false,
26
29
  },
27
- debug: {
28
- type: 'boolean',
29
- description: 'Override logLevel to debug',
30
- short: 'd',
31
- default: false,
32
- },
33
30
  verbose: {
34
31
  type: 'boolean',
35
32
  description: 'Override logLevel to verbose',
@@ -42,16 +39,27 @@ export const command = defineCommand({
42
39
  short: 's',
43
40
  default: false,
44
41
  },
42
+ reporter: {
43
+ type: 'string',
44
+ description: 'Reporters that render the run, comma-separated. Overrides config.reporters',
45
+ hint: 'cli|json|file',
46
+ enum: ['cli', 'json', 'file'],
47
+ },
45
48
  },
46
49
  async run({ values, positionals }) {
47
- const logLevel = values.debug ? 'debug' : values.verbose ? 'verbose' : values.silent ? 'silent' : values.logLevel
48
- const { runGenerateCommand } = await import('../runners/generate.ts')
50
+ const logLevel = values.verbose ? 'verbose' : values.silent ? 'silent' : values.logLevel
51
+ const reporters = values.reporter
52
+ ?.split(',')
53
+ .map((name) => name.trim())
54
+ .filter(Boolean) as Array<ReporterName> | undefined
55
+ const { run } = await import('../runners/generate/run.ts')
49
56
 
50
- await runGenerateCommand({
57
+ await run({
51
58
  input: positionals[0],
52
59
  configPath: values.config,
53
60
  logLevel,
54
61
  watch: values.watch,
62
+ reporters,
55
63
  })
56
64
  },
57
65
  })
@@ -3,7 +3,14 @@ import { version } from '../../package.json'
3
3
 
4
4
  export const command = defineCommand({
5
5
  name: 'init',
6
- description: 'Initialize a new Kubb project with interactive setup',
6
+ description:
7
+ '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
+ examples: [
9
+ 'kubb init',
10
+ 'kubb init --yes',
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
+ ],
7
14
  options: {
8
15
  yes: {
9
16
  type: 'boolean',
@@ -11,10 +18,34 @@ export const command = defineCommand({
11
18
  short: 'y',
12
19
  default: false,
13
20
  },
21
+ input: {
22
+ type: 'string',
23
+ description: 'Path to the OpenAPI specification',
24
+ short: 'i',
25
+ hint: 'path',
26
+ },
27
+ output: {
28
+ type: 'string',
29
+ description: 'Output directory for generated files',
30
+ short: 'o',
31
+ hint: 'path',
32
+ },
33
+ plugins: {
34
+ type: 'string',
35
+ description:
36
+ '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)',
37
+ hint: 'plugin-ts,plugin-zod,...',
38
+ },
14
39
  },
15
40
  async run({ values }) {
16
- const { runInit } = await import('../runners/init.ts')
41
+ const { run } = await import('../runners/init/run.ts')
17
42
 
18
- await runInit({ yes: values.yes, version })
43
+ await run({
44
+ yes: values.yes,
45
+ version,
46
+ input: values.input,
47
+ output: values.output,
48
+ plugins: values.plugins,
49
+ })
19
50
  },
20
51
  })
@@ -3,10 +3,34 @@ import { version } from '../../package.json'
3
3
 
4
4
  export const command = defineCommand({
5
5
  name: 'mcp',
6
- description: 'Start the server to enable the MCP client to interact with the LLM.',
7
- async run() {
8
- const { runMcp } = await import('../runners/mcp.ts')
6
+ description:
7
+ '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
+ 'kubb mcp --port 3001',
11
+ '# Then add to your MCP client config:',
12
+ '# { "mcpServers": { "kubb": { "command": "npx", "args": ["kubb", "mcp"] } } }',
13
+ ],
14
+ options: {
15
+ port: {
16
+ type: 'string',
17
+ short: 'p',
18
+ description: 'Port for HTTP MCP server (omit for stdio)',
19
+ hint: 'number',
20
+ },
21
+ host: {
22
+ type: 'string',
23
+ description: 'Hostname to bind to (HTTP mode only)',
24
+ default: 'localhost',
25
+ },
26
+ },
27
+ async run({ values }) {
28
+ const { run } = await import('../runners/mcp/run.ts')
9
29
 
10
- await runMcp({ version })
30
+ await run({
31
+ version,
32
+ port: values.port,
33
+ host: values.host,
34
+ })
11
35
  },
12
36
  })
@@ -3,18 +3,20 @@ import { version } from '../../package.json'
3
3
 
4
4
  export const command = defineCommand({
5
5
  name: 'validate',
6
- description: 'Validate a Swagger/OpenAPI file',
6
+ description:
7
+ 'Parse and validate an OpenAPI/Swagger file for structural correctness. Reports schema errors, missing required fields, and malformed references. Use this before running generate to catch spec issues early.',
8
+ examples: ['kubb validate --input ./openapi.yaml', 'kubb validate --input https://petstore3.swagger.io/api/v3/openapi.json'],
7
9
  options: {
8
10
  input: {
9
11
  type: 'string',
10
- description: 'Path to Swagger/OpenAPI file',
12
+ description: 'Path or URL to the OpenAPI/Swagger file to validate',
11
13
  short: 'i',
12
14
  required: true,
13
15
  },
14
16
  },
15
17
  async run({ values }) {
16
- const { runValidate } = await import('../runners/validate.ts')
18
+ const { run } = await import('../runners/validate/run.ts')
17
19
 
18
- await runValidate({ input: values.input, version })
20
+ await run({ input: values.input, version })
19
21
  },
20
22
  })
package/src/constants.ts CHANGED
@@ -1,42 +1,22 @@
1
- /**
2
- * Default filename for the Kubb configuration file.
3
- *
4
- * Used by the `init` command when scaffolding new projects and by the `agent` default config.
5
- */
6
- export const KUBB_CONFIG_FILENAME = 'kubb.config.ts' as const
1
+ import { KUBB_CONFIG_FILENAME } from '@internals/shared'
7
2
 
8
3
  /**
9
4
  * NPM registry endpoint used to check for @kubb/cli updates.
10
5
  */
11
6
  export const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const
12
7
 
13
- /**
14
- * OpenTelemetry ingestion endpoint for anonymous usage telemetry.
15
- */
16
- export const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const
17
-
18
8
  /**
19
9
  * Horizontal rule rendered above/below the plain-logger generation summary.
20
10
  */
21
11
  export const SUMMARY_SEPARATOR = '─'.repeat(27)
22
12
 
23
- /**
24
- * Maximum number of █ characters in a plugin timing bar.
25
- */
26
- export const SUMMARY_MAX_BAR_LENGTH = 10 as const
27
-
28
- /**
29
- * Divides elapsed milliseconds into bar-length units (1 block per 100 ms).
30
- */
31
- export const SUMMARY_TIME_SCALE_DIVISOR = 100 as const
32
-
33
13
  /**
34
14
  * Glob pattern for paths the file watcher ignores.
35
15
  */
36
16
  export const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const
37
17
 
38
18
  /**
39
- * Flags that short-circuit execution (help/version) no telemetry notice is shown.
19
+ * Flags that short-circuit execution (help/version), no telemetry notice is shown.
40
20
  */
41
21
  export const QUIET_FLAGS = new Set(['--help', '-h', '--version', '-v'] as const)
42
22
 
@@ -45,60 +25,9 @@ export const agentDefaults = {
45
25
  host: 'localhost',
46
26
  configFile: KUBB_CONFIG_FILENAME,
47
27
  retryTimeout: '30000',
48
- studioUrl: 'https://studio.kubb.dev',
28
+ studioUrl: 'https://kubb.studio',
49
29
  /**
50
30
  * Relative path from the @kubb/agent package root to the server entry.
51
31
  */
52
32
  serverEntryPath: '.output/server/index.mjs',
53
33
  } as const
54
-
55
- /**
56
- * Default values used during interactive `init` scaffolding.
57
- */
58
- export const initDefaults = {
59
- inputPath: './openapi.yaml',
60
- outputPath: './src/gen',
61
- plugins: ['plugin-ts'],
62
- } as const
63
-
64
- /**
65
- * Maps each plugin value to the default config snippet inserted by `init`.
66
- * The `satisfies` constraint ensures all values remain plain strings while
67
- * `as const` keeps the object deeply immutable.
68
- */
69
- export const pluginDefaultConfigs = {
70
- 'plugin-ts': `pluginTs({
71
- output: { path: 'models' },
72
- })`,
73
- 'plugin-client': `pluginClient({
74
- output: { path: 'clients' },
75
- })`,
76
- 'plugin-react-query': `pluginReactQuery({
77
- output: { path: 'hooks' },
78
- })`,
79
- 'plugin-vue-query': `pluginVueQuery({
80
- output: { path: 'hooks' },
81
- })`,
82
- 'plugin-zod': `pluginZod({
83
- output: { path: 'zod' },
84
- })`,
85
- 'plugin-faker': `pluginFaker({
86
- output: { path: 'mocks' },
87
- })`,
88
- 'plugin-msw': `pluginMsw({
89
- output: { path: 'msw' },
90
- })`,
91
- 'plugin-cypress': `pluginCypress({
92
- output: { path: 'cypress' },
93
- })`,
94
- 'plugin-mcp': `pluginMcp({
95
- output: { path: 'mcp' },
96
- })`,
97
- 'plugin-redoc': `pluginRedoc({
98
- output: { path: 'redoc' },
99
- })`,
100
- } as const satisfies Record<string, string>
101
-
102
- /**
103
- * Color palette used by randomCliColor() for deterministic plugin name coloring.
104
- */
package/src/index.ts CHANGED
@@ -1,24 +1,26 @@
1
1
  import { styleText } from 'node:util'
2
- import { createCLI } from '@internals/utils'
2
+ import { createCLI, isFlag } from '@internals/utils'
3
+ import { Telemetry } from '@kubb/core'
3
4
  import { version } from '../package.json'
4
5
  import { QUIET_FLAGS } from './constants.ts'
5
- import { isFlag } from './utils/flags.ts'
6
- import { isTelemetryDisabled } from './utils/telemetry.ts'
7
6
 
8
7
  const cli = createCLI()
9
8
 
10
9
  function shouldShowTelemetryNotice(argv: Array<string>): boolean {
11
- if (isTelemetryDisabled()) {
10
+ if (Telemetry.isDisabled()) {
12
11
  return false
13
12
  }
13
+
14
14
  // Skip when the user is just asking for help or version info
15
15
  if (argv.some((arg) => isFlag(QUIET_FLAGS, arg))) {
16
16
  return false
17
17
  }
18
+
18
19
  // Skip in non-interactive / scripting contexts
19
20
  if (!process.stdout.isTTY) {
20
21
  return false
21
22
  }
23
+
22
24
  return true
23
25
  }
24
26