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

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 (157) hide show
  1. package/README.md +209 -51
  2. package/dist/agent-D3K_-kiv.js +68 -0
  3. package/dist/agent-D3K_-kiv.js.map +1 -0
  4. package/dist/agent-DTqKBULa.cjs +70 -0
  5. package/dist/agent-DTqKBULa.cjs.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-CZYIOngX.cjs +76 -0
  24. package/dist/generate-CZYIOngX.cjs.map +1 -0
  25. package/dist/generate-HcvbU80u.js +77 -0
  26. package/dist/generate-HcvbU80u.js.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-BMtuczv8.js +53 -0
  33. package/dist/init-BMtuczv8.js.map +1 -0
  34. package/dist/init-DybfkgNy.cjs +53 -0
  35. package/dist/init-DybfkgNy.cjs.map +1 -0
  36. package/dist/mcp-BF9dnH_F.js +39 -0
  37. package/dist/mcp-BF9dnH_F.js.map +1 -0
  38. package/dist/mcp-YzKoU6_l.cjs +39 -0
  39. package/dist/mcp-YzKoU6_l.cjs.map +1 -0
  40. package/dist/package-BCwMApnr.js +6 -0
  41. package/dist/package-BCwMApnr.js.map +1 -0
  42. package/dist/{package-BapVyQ-w.cjs → package-DPe5CA4S.cjs} +2 -2
  43. package/dist/package-DPe5CA4S.cjs.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/{init-CZ5Xq2Hd.cjs → run-C_NMctua.cjs} +107 -149
  51. package/dist/run-C_NMctua.cjs.map +1 -0
  52. package/dist/run-CkTpemme.cjs +52 -0
  53. package/dist/run-CkTpemme.cjs.map +1 -0
  54. package/dist/run-Cl4SrSob.cjs +33 -0
  55. package/dist/run-Cl4SrSob.cjs.map +1 -0
  56. package/dist/{agent-B4cAAab2.cjs → run-D-s2LdlW.cjs} +46 -43
  57. package/dist/run-D-s2LdlW.cjs.map +1 -0
  58. package/dist/{init-eNRlotJK.js → run-D8dCWepS.js} +107 -149
  59. package/dist/run-D8dCWepS.js.map +1 -0
  60. package/dist/run-DaV_NiKR.js +1509 -0
  61. package/dist/run-DaV_NiKR.js.map +1 -0
  62. package/dist/run-UWQ9wImP.cjs +1512 -0
  63. package/dist/run-UWQ9wImP.cjs.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-BHc3lUKB.js +26 -0
  69. package/dist/validate-BHc3lUKB.js.map +1 -0
  70. package/dist/validate-CqRqJxmQ.cjs +26 -0
  71. package/dist/validate-CqRqJxmQ.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 +137 -178
  82. package/src/loggers/plainLogger.ts +49 -102
  83. package/src/loggers/types.ts +6 -1
  84. package/src/loggers/utils.ts +141 -26
  85. package/src/runners/agent/run.ts +113 -0
  86. package/src/runners/agent/utils.ts +98 -0
  87. package/src/runners/generate/run.ts +404 -0
  88. package/src/runners/generate/utils.ts +219 -0
  89. package/src/runners/init/run.ts +212 -0
  90. package/src/{utils/packageManager.ts → runners/init/utils.ts} +12 -2
  91. package/src/runners/mcp/run.ts +37 -0
  92. package/src/runners/validate/run.ts +63 -0
  93. package/dist/agent-B4cAAab2.cjs.map +0 -1
  94. package/dist/agent-CR6Z96og.js +0 -56
  95. package/dist/agent-CR6Z96og.js.map +0 -1
  96. package/dist/agent-Dmxzqg4d.cjs +0 -58
  97. package/dist/agent-Dmxzqg4d.cjs.map +0 -1
  98. package/dist/agent-sdYBBgrd.js.map +0 -1
  99. package/dist/constants-CnDXa1R6.cjs +0 -148
  100. package/dist/constants-CnDXa1R6.cjs.map +0 -1
  101. package/dist/constants-aL3CP_Wq.js +0 -95
  102. package/dist/constants-aL3CP_Wq.js.map +0 -1
  103. package/dist/generate-B1Pa2ho-.cjs +0 -1756
  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 +0 -1753
  108. package/dist/generate-CNrRLY4n.js.map +0 -1
  109. package/dist/generate-DuhxPLGr.js +0 -66
  110. package/dist/generate-DuhxPLGr.js.map +0 -1
  111. package/dist/init-CZ5Xq2Hd.cjs.map +0 -1
  112. package/dist/init-CnZXHrbq.js +0 -25
  113. package/dist/init-CnZXHrbq.js.map +0 -1
  114. package/dist/init-NYJSZJSb.cjs +0 -25
  115. package/dist/init-NYJSZJSb.cjs.map +0 -1
  116. package/dist/init-eNRlotJK.js.map +0 -1
  117. package/dist/mcp-CYOgxB82.cjs +0 -47
  118. package/dist/mcp-CYOgxB82.cjs.map +0 -1
  119. package/dist/mcp-CdFWyrwi.cjs +0 -16
  120. package/dist/mcp-CdFWyrwi.cjs.map +0 -1
  121. package/dist/mcp-DhSxuDMD.js +0 -16
  122. package/dist/mcp-DhSxuDMD.js.map +0 -1
  123. package/dist/mcp-DmJm3TrU.js +0 -46
  124. package/dist/mcp-DmJm3TrU.js.map +0 -1
  125. package/dist/package-BapVyQ-w.cjs.map +0 -1
  126. package/dist/package-DyJE-qNq.js +0 -6
  127. package/dist/package-DyJE-qNq.js.map +0 -1
  128. package/dist/telemetry-DN95_2pF.cjs +0 -282
  129. package/dist/telemetry-DN95_2pF.cjs.map +0 -1
  130. package/dist/telemetry-LgT_sdPe.js +0 -245
  131. package/dist/telemetry-LgT_sdPe.js.map +0 -1
  132. package/dist/validate-C6npXzel.cjs +0 -25
  133. package/dist/validate-C6npXzel.cjs.map +0 -1
  134. package/dist/validate-kLJoT_hi.js +0 -33
  135. package/dist/validate-kLJoT_hi.js.map +0 -1
  136. package/dist/validate-n38Rh-Y7.js +0 -25
  137. package/dist/validate-n38Rh-Y7.js.map +0 -1
  138. package/dist/validate-yKKzqEZ5.cjs +0 -34
  139. package/dist/validate-yKKzqEZ5.cjs.map +0 -1
  140. package/src/loggers/fileSystemLogger.ts +0 -138
  141. package/src/loggers/githubActionsLogger.ts +0 -379
  142. package/src/runners/agent.ts +0 -155
  143. package/src/runners/generate.ts +0 -333
  144. package/src/runners/init.ts +0 -296
  145. package/src/runners/mcp.ts +0 -51
  146. package/src/runners/validate.ts +0 -39
  147. package/src/types.ts +0 -11
  148. package/src/utils/Writables.ts +0 -17
  149. package/src/utils/executeHooks.ts +0 -45
  150. package/src/utils/flags.ts +0 -9
  151. package/src/utils/getConfig.ts +0 -10
  152. package/src/utils/getCosmiConfig.ts +0 -80
  153. package/src/utils/getSummary.ts +0 -68
  154. package/src/utils/runHook.ts +0 -91
  155. package/src/utils/telemetry.ts +0 -273
  156. package/src/utils/watcher.ts +0 -19
  157. /package/dist/{chunk-ByKO4r7w.cjs → chunk-Bx3C2hgW.cjs} +0 -0
@@ -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