@kubb/cli 5.0.0-alpha.9 → 5.0.0-beta.10

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 (173) hide show
  1. package/README.md +180 -27
  2. package/bin/kubb.js +6 -0
  3. package/dist/agent-Bx2yllmS.js +68 -0
  4. package/dist/agent-Bx2yllmS.js.map +1 -0
  5. package/dist/agent-CeLwj5im.cjs +70 -0
  6. package/dist/agent-CeLwj5im.cjs.map +1 -0
  7. package/dist/{chunk--u3MIqq1.js → chunk-BvFE5Tac.js} +1 -0
  8. package/dist/constants-B2JTeRBb.js +42 -0
  9. package/dist/constants-B2JTeRBb.js.map +1 -0
  10. package/dist/constants-BINTA5VZ.cjs +77 -0
  11. package/dist/constants-BINTA5VZ.cjs.map +1 -0
  12. package/dist/constants-BYGmiFs0.cjs +139 -0
  13. package/dist/constants-BYGmiFs0.cjs.map +1 -0
  14. package/dist/constants-DSJ-Xrbv.js +116 -0
  15. package/dist/constants-DSJ-Xrbv.js.map +1 -0
  16. package/dist/define-Bdn8j5VM.cjs +54 -0
  17. package/dist/define-Bdn8j5VM.cjs.map +1 -0
  18. package/dist/define-m_fp-Aqm.js +43 -0
  19. package/dist/define-m_fp-Aqm.js.map +1 -0
  20. package/dist/errors-CINO1EIv.js +43 -0
  21. package/dist/errors-CINO1EIv.js.map +1 -0
  22. package/dist/{errors-DBW0N9w4.cjs → errors-CLCjoSg0.cjs} +22 -6
  23. package/dist/errors-CLCjoSg0.cjs.map +1 -0
  24. package/dist/{generate-Rly1EXBN.js → generate-BLvcvoIj.js} +12 -6
  25. package/dist/generate-BLvcvoIj.js.map +1 -0
  26. package/dist/{generate-DU5zzc54.cjs → generate-drLxTAnz.cjs} +11 -5
  27. package/dist/generate-drLxTAnz.cjs.map +1 -0
  28. package/dist/index.cjs +52 -21
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.ts +1 -1
  31. package/dist/index.js +53 -22
  32. package/dist/index.js.map +1 -1
  33. package/dist/init-CGu7JZEF.js +53 -0
  34. package/dist/init-CGu7JZEF.js.map +1 -0
  35. package/dist/init-CyCjvIEF.cjs +53 -0
  36. package/dist/init-CyCjvIEF.cjs.map +1 -0
  37. package/dist/mcp-Cq2sylQC.js +39 -0
  38. package/dist/mcp-Cq2sylQC.js.map +1 -0
  39. package/dist/mcp-DSF5gpI-.cjs +39 -0
  40. package/dist/mcp-DSF5gpI-.cjs.map +1 -0
  41. package/dist/{package-BJ6ionm6.cjs → package-DZ-6zAIO.cjs} +2 -2
  42. package/dist/package-DZ-6zAIO.cjs.map +1 -0
  43. package/dist/package-OLYIpjqw.js +6 -0
  44. package/dist/package-OLYIpjqw.js.map +1 -0
  45. package/dist/{generate-BHNyeQXl.js → run-Bfbr3RaM.js} +781 -502
  46. package/dist/run-Bfbr3RaM.js.map +1 -0
  47. package/dist/run-BzpYYOQs.js +121 -0
  48. package/dist/run-BzpYYOQs.js.map +1 -0
  49. package/dist/run-CCZ24VKk.js +51 -0
  50. package/dist/run-CCZ24VKk.js.map +1 -0
  51. package/dist/run-CF97BWVa.js +244 -0
  52. package/dist/run-CF97BWVa.js.map +1 -0
  53. package/dist/run-CQbj3ley.cjs +52 -0
  54. package/dist/run-CQbj3ley.cjs.map +1 -0
  55. package/dist/{generate-Cq5RDTBL.cjs → run-CVlrIZoW.cjs} +786 -507
  56. package/dist/run-CVlrIZoW.cjs.map +1 -0
  57. package/dist/run-D0hmRpHy.js +49 -0
  58. package/dist/run-D0hmRpHy.js.map +1 -0
  59. package/dist/run-DwdAwnLG.cjs +125 -0
  60. package/dist/run-DwdAwnLG.cjs.map +1 -0
  61. package/dist/run-Lr0Ctnu0.cjs +50 -0
  62. package/dist/run-Lr0Ctnu0.cjs.map +1 -0
  63. package/dist/run-YsoCk5we.cjs +248 -0
  64. package/dist/run-YsoCk5we.cjs.map +1 -0
  65. package/dist/{shell-7HPrTCJ5.cjs → shell-475fQKaX.cjs} +8 -3
  66. package/dist/shell-475fQKaX.cjs.map +1 -0
  67. package/dist/{shell-DqqWsHCD.js → shell-CN6DNqeC.js} +9 -4
  68. package/dist/shell-CN6DNqeC.js.map +1 -0
  69. package/dist/{telemetry-DZ7IrLAU.cjs → telemetry-B2iWkY5e.cjs} +53 -13
  70. package/dist/telemetry-B2iWkY5e.cjs.map +1 -0
  71. package/dist/{telemetry-BF3SMlH6.js → telemetry-BkektVz6.js} +52 -12
  72. package/dist/telemetry-BkektVz6.js.map +1 -0
  73. package/dist/validate-CAUqLaGt.js +26 -0
  74. package/dist/validate-CAUqLaGt.js.map +1 -0
  75. package/dist/validate-J6AEd5zK.cjs +26 -0
  76. package/dist/validate-J6AEd5zK.cjs.map +1 -0
  77. package/package.json +57 -48
  78. package/src/commands/agent/start.ts +27 -8
  79. package/src/commands/agent.ts +3 -1
  80. package/src/commands/generate.ts +39 -8
  81. package/src/commands/init.ts +40 -4
  82. package/src/commands/mcp.ts +28 -4
  83. package/src/commands/validate.ts +11 -4
  84. package/src/constants.ts +5 -80
  85. package/src/index.ts +12 -13
  86. package/src/loggers/clackLogger.ts +98 -88
  87. package/src/loggers/fileSystemLogger.ts +37 -25
  88. package/src/loggers/githubActionsLogger.ts +35 -48
  89. package/src/loggers/plainLogger.ts +33 -45
  90. package/src/loggers/types.ts +6 -0
  91. package/src/loggers/utils.ts +155 -9
  92. package/src/runners/agent/run.ts +113 -0
  93. package/src/runners/agent/utils.ts +98 -0
  94. package/src/runners/generate/run.ts +276 -0
  95. package/src/runners/generate/utils.ts +209 -0
  96. package/src/runners/init/run.ts +211 -0
  97. package/src/{utils/packageManager.ts → runners/init/utils.ts} +10 -0
  98. package/src/runners/mcp/run.ts +55 -0
  99. package/src/runners/validate/run.ts +63 -0
  100. package/src/{utils/telemetry.ts → telemetry.ts} +28 -8
  101. package/bin/kubb.cjs +0 -18
  102. package/dist/agent-5mmp7QzF.js +0 -56
  103. package/dist/agent-5mmp7QzF.js.map +0 -1
  104. package/dist/agent-BKphjOIF.cjs +0 -58
  105. package/dist/agent-BKphjOIF.cjs.map +0 -1
  106. package/dist/agent-BapvKB4r.cjs +0 -92
  107. package/dist/agent-BapvKB4r.cjs.map +0 -1
  108. package/dist/agent-CBrpIMMU.js +0 -88
  109. package/dist/agent-CBrpIMMU.js.map +0 -1
  110. package/dist/constants-D0XHAHeZ.cjs +0 -178
  111. package/dist/constants-D0XHAHeZ.cjs.map +0 -1
  112. package/dist/constants-DJM9zCXm.js +0 -131
  113. package/dist/constants-DJM9zCXm.js.map +0 -1
  114. package/dist/define--M_JMcDC.js +0 -25
  115. package/dist/define--M_JMcDC.js.map +0 -1
  116. package/dist/define-D6Kfm7-Z.cjs +0 -36
  117. package/dist/define-D6Kfm7-Z.cjs.map +0 -1
  118. package/dist/errors-6mF_WKxg.js +0 -27
  119. package/dist/errors-6mF_WKxg.js.map +0 -1
  120. package/dist/errors-DBW0N9w4.cjs.map +0 -1
  121. package/dist/generate-BHNyeQXl.js.map +0 -1
  122. package/dist/generate-Cq5RDTBL.cjs.map +0 -1
  123. package/dist/generate-DU5zzc54.cjs.map +0 -1
  124. package/dist/generate-Rly1EXBN.js.map +0 -1
  125. package/dist/init-BK6inBTR.cjs +0 -306
  126. package/dist/init-BK6inBTR.cjs.map +0 -1
  127. package/dist/init-BQ6zfsnw.js +0 -302
  128. package/dist/init-BQ6zfsnw.js.map +0 -1
  129. package/dist/init-CN1JFyGX.cjs +0 -25
  130. package/dist/init-CN1JFyGX.cjs.map +0 -1
  131. package/dist/init-iN7e1XwI.js +0 -25
  132. package/dist/init-iN7e1XwI.js.map +0 -1
  133. package/dist/jiti-Cd3S0xwr.cjs +0 -16
  134. package/dist/jiti-Cd3S0xwr.cjs.map +0 -1
  135. package/dist/jiti-e08mD2Ph.js +0 -11
  136. package/dist/jiti-e08mD2Ph.js.map +0 -1
  137. package/dist/mcp-BiGUvbWP.js +0 -41
  138. package/dist/mcp-BiGUvbWP.js.map +0 -1
  139. package/dist/mcp-CONmm_xT.cjs +0 -42
  140. package/dist/mcp-CONmm_xT.cjs.map +0 -1
  141. package/dist/mcp-T7Q4nWbT.cjs +0 -16
  142. package/dist/mcp-T7Q4nWbT.cjs.map +0 -1
  143. package/dist/mcp-eP1S40LZ.js +0 -16
  144. package/dist/mcp-eP1S40LZ.js.map +0 -1
  145. package/dist/package-BJ6ionm6.cjs.map +0 -1
  146. package/dist/package-BKZ0H3Zf.js +0 -6
  147. package/dist/package-BKZ0H3Zf.js.map +0 -1
  148. package/dist/shell-7HPrTCJ5.cjs.map +0 -1
  149. package/dist/shell-DqqWsHCD.js.map +0 -1
  150. package/dist/telemetry-BF3SMlH6.js.map +0 -1
  151. package/dist/telemetry-DZ7IrLAU.cjs.map +0 -1
  152. package/dist/validate-BImbbx1t.js +0 -41
  153. package/dist/validate-BImbbx1t.js.map +0 -1
  154. package/dist/validate-DAZdX_0i.js +0 -25
  155. package/dist/validate-DAZdX_0i.js.map +0 -1
  156. package/dist/validate-DucFMytl.cjs +0 -25
  157. package/dist/validate-DucFMytl.cjs.map +0 -1
  158. package/dist/validate-ujLCYSWU.cjs +0 -42
  159. package/dist/validate-ujLCYSWU.cjs.map +0 -1
  160. package/src/runners/agent.ts +0 -102
  161. package/src/runners/generate.ts +0 -343
  162. package/src/runners/init.ts +0 -323
  163. package/src/runners/mcp.ts +0 -32
  164. package/src/runners/validate.ts +0 -35
  165. package/src/types.ts +0 -11
  166. package/src/utils/Writables.ts +0 -17
  167. package/src/utils/executeHooks.ts +0 -45
  168. package/src/utils/flags.ts +0 -10
  169. package/src/utils/getCosmiConfig.ts +0 -71
  170. package/src/utils/getSummary.ts +0 -68
  171. package/src/utils/jiti.ts +0 -9
  172. package/src/utils/runHook.ts +0 -75
  173. package/src/utils/watcher.ts +0 -19
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry-BkektVz6.js","names":["dnsPromises","process"],"sources":["../../../internals/utils/src/env.ts","../../../internals/utils/src/network.ts","../src/telemetry.ts"],"sourcesContent":["/**\n * Returns `true` when running inside a GitHub Actions workflow.\n *\n * @example\n * ```ts\n * if (isGitHubActions()) {\n * core.setOutput('result', 'ok')\n * }\n * ```\n */\nexport function isGitHubActions(): boolean {\n return !!process.env.GITHUB_ACTIONS\n}\n\n/**\n * Returns `true` when the process is running in a CI environment.\n * Covers GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, Bitbucket,\n * TeamCity, Buildkite, and Azure Pipelines.\n *\n * @example\n * ```ts\n * if (isCIEnvironment()) {\n * logger.level = 'error'\n * }\n * ```\n */\nexport function isCIEnvironment(): boolean {\n return !!(\n process.env.CI ||\n process.env.GITHUB_ACTIONS ||\n process.env.GITLAB_CI ||\n process.env.BITBUCKET_BUILD_NUMBER ||\n process.env.JENKINS_URL ||\n process.env.CIRCLECI ||\n process.env.TRAVIS ||\n process.env.TEAMCITY_VERSION ||\n process.env.BUILDKITE ||\n process.env.TF_BUILD\n )\n}\n\n/**\n * Returns `true` when the process has an interactive TTY with a valid terminal\n * width and is not running in CI.\n *\n * Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,\n * which breaks clack's box-drawing helpers (they call `String.prototype.repeat`\n * with a negative count and throw a `RangeError`). We therefore require a\n * positive column count before declaring the TTY usable.\n *\n * @example\n * ```ts\n * if (canUseTTY()) {\n * renderProgressBar()\n * }\n * ```\n */\nexport function canUseTTY(): boolean {\n return !!process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !isCIEnvironment()\n}\n","import { promises as dnsPromises } from 'node:dns'\n\n/**\n * Well-known stable domains used as DNS probes to check internet connectivity.\n */\nconst TEST_DOMAINS = ['dns.google.com', 'cloudflare.com', 'one.one.one.one'] as const\n\n/**\n * Returns `true` when the system has internet connectivity.\n * Probes DNS resolution against well-known stable domains.\n *\n * @example\n * ```ts\n * if (await isOnline()) {\n * await fetchLatestVersion()\n * }\n * ```\n */\nexport async function isOnline(): Promise<boolean> {\n for (const domain of TEST_DOMAINS) {\n try {\n await dnsPromises.resolve(domain)\n return true\n } catch {\n // Try next domain\n }\n }\n\n return false\n}\n\n/**\n * Executes `fn` only when the system is online. Returns `null` when offline or on error.\n *\n * @example\n * ```ts\n * const version = await executeIfOnline(() => fetchLatestVersion('kubb'))\n * // null when offline\n * ```\n */\nexport async function executeIfOnline<T>(fn: () => Promise<T>): Promise<T | null> {\n if (!(await isOnline())) return null\n\n try {\n return await fn()\n } catch {\n return null\n }\n}\n","import { randomBytes } from 'node:crypto'\nimport os from 'node:os'\nimport process from 'node:process'\nimport { executeIfOnline, isCIEnvironment } from '@internals/utils'\nimport { OTLP_ENDPOINT } from './constants.ts'\n\n// OpenTelemetry OTLP JSON types\n// https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto\n// https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/common/v1/common.proto\n\ntype OtlpStringValue = { stringValue: string }\ntype OtlpBoolValue = { boolValue: boolean }\ntype OtlpIntValue = { intValue: number }\ntype OtlpDoubleValue = { doubleValue: number }\ntype OtlpBytesValue = { bytesValue: string }\ntype OtlpArrayValue = { arrayValue: { values: OtlpAnyValue[] } }\ntype OtlpKvListValue = { kvlistValue: { values: OtlpKeyValue[] } }\n\ntype OtlpAnyValue = OtlpStringValue | OtlpBoolValue | OtlpIntValue | OtlpDoubleValue | OtlpBytesValue | OtlpArrayValue | OtlpKvListValue\n\ntype OtlpKeyValue = {\n key: string\n value: OtlpAnyValue\n}\n\ntype OtlpResource = {\n attributes: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpInstrumentationScope = {\n name: string\n version?: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\n/** https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto#L103 */\ntype OtlpSpanKind = 0 | 1 | 2 | 3 | 4 | 5\n\n/** 0 = STATUS_CODE_UNSET, 1 = STATUS_CODE_OK, 2 = STATUS_CODE_ERROR */\ntype OtlpStatusCode = 0 | 1 | 2\n\ntype OtlpStatus = {\n code: OtlpStatusCode\n message?: string\n}\n\ntype OtlpSpan = {\n traceId: string\n spanId: string\n traceState?: string\n parentSpanId?: string\n name: string\n kind: OtlpSpanKind\n startTimeUnixNano: string\n endTimeUnixNano: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n events?: OtlpSpanEvent[]\n droppedEventsCount?: number\n links?: OtlpSpanLink[]\n droppedLinksCount?: number\n status?: OtlpStatus\n}\n\ntype OtlpSpanEvent = {\n timeUnixNano: string\n name: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpSpanLink = {\n traceId: string\n spanId: string\n traceState?: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpScopeSpans = {\n scope: OtlpInstrumentationScope\n spans: OtlpSpan[]\n schemaUrl?: string\n}\n\ntype OtlpResourceSpans = {\n resource: OtlpResource\n scopeSpans: OtlpScopeSpans[]\n schemaUrl?: string\n}\n\n/** Root payload sent to POST /v1/traces */\ntype OtlpExportTraceServiceRequest = {\n resourceSpans: OtlpResourceSpans[]\n}\n\n/**\n * Anonymous plugin name and options snapshot sent with each telemetry event.\n */\nexport type TelemetryPlugin = {\n /**\n * Plugin name as registered in the Kubb config, e.g. `'@kubb/plugin-ts'`.\n */\n name: string\n /**\n * anonymized plugin options snapshot — values are included but cannot be traced back to the user.\n */\n options: Record<string, unknown>\n}\n\ntype TelemetryEvent = {\n command: string\n kubbVersion: string\n nodeVersion: string\n platform: string\n ci: boolean\n plugins: TelemetryPlugin[]\n duration: number\n filesCreated: number\n status: 'success' | 'failed'\n}\n\n/**\n * Returns `true` when the current process runs inside a CI environment.\n */\nexport function isCi(): boolean {\n return isCIEnvironment()\n}\n\n/**\n * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.\n */\nexport function isTelemetryDisabled(): boolean {\n return (\n process.env['DO_NOT_TRACK'] === '1' ||\n process.env['DO_NOT_TRACK'] === 'true' ||\n process.env['KUBB_DISABLE_TELEMETRY'] === '1' ||\n process.env['KUBB_DISABLE_TELEMETRY'] === 'true'\n )\n}\n\n/**\n * Convert a TelemetryEvent into an OTLP-compatible JSON trace payload.\n * See https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/\n */\nexport function buildOtlpPayload(event: TelemetryEvent): OtlpExportTraceServiceRequest {\n const traceId = randomBytes(16).toString('hex')\n const spanId = randomBytes(8).toString('hex')\n const endTimeNs = BigInt(Date.now()) * 1_000_000n\n const startTimeNs = endTimeNs - BigInt(event.duration) * 1_000_000n\n\n const attributes: OtlpKeyValue[] = [\n { key: 'kubb.command', value: { stringValue: event.command } },\n { key: 'kubb.version', value: { stringValue: event.kubbVersion } },\n { key: 'kubb.node_version', value: { stringValue: event.nodeVersion } },\n { key: 'kubb.platform', value: { stringValue: event.platform } },\n { key: 'kubb.ci', value: { boolValue: event.ci } },\n { key: 'kubb.files_created', value: { intValue: event.filesCreated } },\n { key: 'kubb.status', value: { stringValue: event.status } },\n {\n key: 'kubb.plugins',\n value: {\n arrayValue: {\n values: event.plugins.map(\n (p): OtlpKvListValue => ({\n kvlistValue: {\n values: [\n { key: 'name', value: { stringValue: p.name } },\n {\n key: 'options',\n value: {\n stringValue: JSON.stringify({\n ...p.options,\n usedEnumNames: undefined,\n }),\n },\n },\n ],\n },\n }),\n ),\n },\n },\n },\n ]\n\n return {\n resourceSpans: [\n {\n resource: {\n attributes: [\n { key: 'service.name', value: { stringValue: 'kubb-cli' } },\n {\n key: 'service.version',\n value: { stringValue: event.kubbVersion },\n },\n { key: 'telemetry.sdk.language', value: { stringValue: 'nodejs' } },\n ],\n },\n scopeSpans: [\n {\n scope: { name: 'kubb-cli', version: event.kubbVersion },\n spans: [\n {\n traceId,\n spanId,\n name: event.command,\n kind: 1 satisfies OtlpSpanKind,\n startTimeUnixNano: String(startTimeNs),\n endTimeUnixNano: String(endTimeNs),\n attributes,\n status: {\n code: (event.status === 'success' ? 1 : 2) satisfies OtlpStatusCode,\n },\n },\n ],\n },\n ],\n },\n ],\n }\n}\n\n/**\n * Send an anonymous telemetry event to the Kubb OTLP endpoint.\n * Respects DO_NOT_TRACK and KUBB_DISABLE_TELEMETRY environment variables.\n * Fails silently to never interrupt the generation process.\n */\nexport async function sendTelemetry(event: TelemetryEvent): Promise<void> {\n if (isTelemetryDisabled()) {\n return\n }\n\n await executeIfOnline(async () => {\n try {\n await fetch(`${OTLP_ENDPOINT}/v1/traces`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Kubb-Telemetry-Version': '1',\n 'Kubb-Telemetry-Source': 'kubb-cli',\n },\n body: JSON.stringify(buildOtlpPayload(event)),\n signal: AbortSignal.timeout(5_000),\n })\n } catch (_e) {\n // Fail silently – telemetry must never break the CLI\n }\n })\n}\n\n/**\n * Build an anonymous telemetry payload from a completed generation run.\n * No file paths, OpenAPI specs, or secrets are included.\n */\nexport function buildTelemetryEvent(options: {\n command: 'generate' | 'mcp' | 'validate' | 'agent'\n kubbVersion: string\n plugins?: TelemetryPlugin[]\n hrStart: [number, number]\n filesCreated?: number\n status: 'success' | 'failed'\n}): TelemetryEvent {\n const [seconds, nanoseconds] = process.hrtime(options.hrStart)\n const duration = Math.round(seconds * 1000 + nanoseconds / 1e6)\n\n return {\n command: options.command,\n kubbVersion: options.kubbVersion,\n nodeVersion: process.versions.node.split('.')[0] as string,\n platform: os.platform(),\n ci: isCi(),\n plugins: options.plugins ?? [],\n duration,\n filesCreated: options.filesCreated ?? 0,\n status: options.status,\n }\n}\n"],"mappings":"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"}
@@ -0,0 +1,26 @@
1
+ import "./chunk-BvFE5Tac.js";
2
+ import { n as defineCommand } from "./define-m_fp-Aqm.js";
3
+ import { t as version } from "./package-OLYIpjqw.js";
4
+ //#region src/commands/validate.ts
5
+ const command = defineCommand({
6
+ name: "validate",
7
+ description: "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"],
9
+ options: { input: {
10
+ type: "string",
11
+ description: "Path or URL to the OpenAPI/Swagger file to validate",
12
+ short: "i",
13
+ required: true
14
+ } },
15
+ async run({ values }) {
16
+ const { run } = await import("./run-CCZ24VKk.js");
17
+ await run({
18
+ input: values.input,
19
+ version
20
+ });
21
+ }
22
+ });
23
+ //#endregion
24
+ export { command };
25
+
26
+ //# sourceMappingURL=validate-CAUqLaGt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-CAUqLaGt.js","names":[],"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\n name: 'validate',\n description:\n '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.',\n examples: ['kubb validate --input ./openapi.yaml', 'kubb validate --input https://petstore3.swagger.io/api/v3/openapi.json'],\n options: {\n input: {\n type: 'string',\n description: 'Path or URL to the OpenAPI/Swagger file to validate',\n short: 'i',\n required: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/validate/run.ts')\n\n await run({ input: values.input, version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU,CAAC,wCAAwC,yEAAyE;CAC5H,SAAS,EACP,OAAO;EACL,MAAM;EACN,aAAa;EACb,OAAO;EACP,UAAU;EACX,EACF;CACD,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI;GAAE,OAAO,OAAO;GAAO;GAAS,CAAC;;CAE9C,CAAC"}
@@ -0,0 +1,26 @@
1
+ require("./chunk-ByKO4r7w.cjs");
2
+ const require_define = require("./define-Bdn8j5VM.cjs");
3
+ const require_package = require("./package-DZ-6zAIO.cjs");
4
+ //#region src/commands/validate.ts
5
+ const command = require_define.defineCommand({
6
+ name: "validate",
7
+ description: "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"],
9
+ options: { input: {
10
+ type: "string",
11
+ description: "Path or URL to the OpenAPI/Swagger file to validate",
12
+ short: "i",
13
+ required: true
14
+ } },
15
+ async run({ values }) {
16
+ const { run } = await Promise.resolve().then(() => require("./run-CQbj3ley.cjs"));
17
+ await run({
18
+ input: values.input,
19
+ version: require_package.version
20
+ });
21
+ }
22
+ });
23
+ //#endregion
24
+ exports.command = command;
25
+
26
+ //# sourceMappingURL=validate-J6AEd5zK.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-J6AEd5zK.cjs","names":["defineCommand"],"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\n name: 'validate',\n description:\n '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.',\n examples: ['kubb validate --input ./openapi.yaml', 'kubb validate --input https://petstore3.swagger.io/api/v3/openapi.json'],\n options: {\n input: {\n type: 'string',\n description: 'Path or URL to the OpenAPI/Swagger file to validate',\n short: 'i',\n required: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/validate/run.ts')\n\n await run({ input: values.input, version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAUA,eAAAA,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU,CAAC,wCAAwC,yEAAyE;CAC5H,SAAS,EACP,OAAO;EACL,MAAM;EACN,aAAa;EACb,OAAO;EACP,UAAU;EACX,EACF;CACD,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAA,QAAA,SAAA,CAAA,WAAA,QAAM,qBAAA,CAAA;EAEtB,MAAM,IAAI;GAAE,OAAO,OAAO;GAAO,SAAA,gBAAA;GAAS,CAAC;;CAE9C,CAAC"}
package/package.json CHANGED
@@ -1,41 +1,26 @@
1
1
  {
2
2
  "name": "@kubb/cli",
3
- "version": "5.0.0-alpha.9",
4
- "description": "Command-line interface for Kubb, enabling easy generation of TypeScript, React-Query, Zod, and other code from OpenAPI specifications.",
3
+ "version": "5.0.0-beta.10",
4
+ "description": "Official CLI for Kubb. Run kubb generate, kubb init, kubb validate, kubb mcp, and kubb agent to manage the full code generation lifecycle from OpenAPI/Swagger specs.",
5
5
  "keywords": [
6
6
  "cli",
7
- "command-line",
8
- "command-line-tool",
9
- "terminal",
10
- "typescript",
11
- "openapi",
12
- "swagger",
13
- "oas",
14
7
  "code-generator",
15
8
  "codegen",
9
+ "kubb",
10
+ "openapi",
16
11
  "sdk-generator",
17
- "plugins",
18
- "kubb"
12
+ "swagger",
13
+ "typescript"
19
14
  ],
15
+ "license": "MIT",
16
+ "author": "stijnvanhulle",
20
17
  "repository": {
21
18
  "type": "git",
22
19
  "url": "git+https://github.com/kubb-labs/kubb.git",
23
20
  "directory": "packages/cli"
24
21
  },
25
- "license": "MIT",
26
- "author": "stijnvanhulle",
27
- "sideEffects": false,
28
- "type": "module",
29
- "exports": {
30
- ".": {
31
- "import": "./dist/index.js",
32
- "require": "./dist/index.cjs"
33
- },
34
- "./package.json": "./package.json"
35
- },
36
- "types": "./dist/index.d.ts",
37
22
  "bin": {
38
- "kubb": "bin/kubb.cjs"
23
+ "kubb": "bin/kubb.js"
39
24
  },
40
25
  "files": [
41
26
  "src",
@@ -45,43 +30,67 @@
45
30
  "!/**/__tests__/**",
46
31
  "!/**/__snapshots__/**"
47
32
  ],
48
- "size-limit": [
49
- {
50
- "path": "./dist/*.js",
51
- "limit": "510 KiB",
52
- "gzip": true
53
- }
54
- ],
33
+ "type": "module",
34
+ "sideEffects": false,
35
+ "main": "./dist/index.cjs",
36
+ "module": "./dist/index.js",
37
+ "types": "./dist/index.d.ts",
38
+ "exports": {
39
+ ".": {
40
+ "import": "./dist/index.js",
41
+ "require": "./dist/index.cjs"
42
+ },
43
+ "./package.json": "./package.json"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public",
47
+ "registry": "https://registry.npmjs.org/"
48
+ },
55
49
  "dependencies": {
56
- "@clack/prompts": "^1.1.0",
50
+ "@clack/prompts": "^1.3.0",
57
51
  "chokidar": "^5.0.0",
58
52
  "cosmiconfig": "^9.0.1",
59
- "jiti": "2.5.1",
60
- "tinyexec": "^1.0.4",
61
- "@kubb/core": "5.0.0-alpha.9"
53
+ "jiti": "^2.7.0",
54
+ "tinyexec": "^1.1.2",
55
+ "@kubb/core": "5.0.0-beta.10"
62
56
  },
63
57
  "devDependencies": {
64
- "source-map-support": "^0.5.21",
58
+ "@internals/shared": "0.0.0",
65
59
  "@internals/utils": "0.0.0",
66
- "@kubb/agent": "5.0.0-alpha.9",
67
- "@kubb/mcp": "5.0.0-alpha.9",
68
- "@kubb/oas": "5.0.0-alpha.9"
60
+ "@kubb/adapter-oas": "5.0.0-beta.10"
69
61
  },
70
- "engines": {
71
- "node": ">=22"
62
+ "peerDependencies": {
63
+ "@kubb/adapter-oas": "5.0.0-beta.10",
64
+ "@kubb/agent": "5.0.0-beta.10",
65
+ "@kubb/mcp": "5.0.0-beta.10"
66
+ },
67
+ "peerDependenciesMeta": {
68
+ "@kubb/adapter-oas": {
69
+ "optional": true
70
+ },
71
+ "@kubb/agent": {
72
+ "optional": true
73
+ },
74
+ "@kubb/mcp": {
75
+ "optional": true
76
+ }
72
77
  },
78
+ "size-limit": [
79
+ {
80
+ "path": "./dist/*.js",
81
+ "limit": "510 KiB",
82
+ "gzip": true
83
+ }
84
+ ],
73
85
  "preferGlobal": true,
74
- "publishConfig": {
75
- "access": "public",
76
- "registry": "https://registry.npmjs.org/"
86
+ "engines": {
87
+ "node": ">=22"
77
88
  },
78
- "main": "./dist/index.cjs",
79
- "module": "./dist/index.js",
80
89
  "scripts": {
81
90
  "build": "tsdown && size-limit",
82
91
  "clean": "npx rimraf ./dist",
83
- "lint": "bun biome lint .",
84
- "lint:fix": "bun biome lint --fix --unsafe .",
92
+ "lint": "oxlint .",
93
+ "lint:fix": "oxlint --fix .",
85
94
  "release": "pnpm publish --no-git-check",
86
95
  "release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
87
96
  "start": "tsdown --watch",
@@ -4,22 +4,41 @@ import { agentDefaults } from '../../constants.ts'
4
4
 
5
5
  export const command = defineCommand({
6
6
  name: 'start',
7
- description: 'Start the Agent server',
7
+ description:
8
+ 'Start the Kubb Agent HTTP server. Exposes a REST API that accepts a kubb.config.ts patch and returns generated code as a stream. Use --allow-write to also write files to disk.',
9
+ examples: ['kubb agent start', 'kubb agent start --port 4000', 'kubb agent start --allow-write', 'kubb agent start --config ./kubb.config.ts --allow-all'],
8
10
  options: {
9
- config: { type: 'string', description: 'Path to the Kubb config', short: 'c' },
10
- port: { type: 'string', description: `Port for the server (default: ${agentDefaults.port})`, short: 'p' },
11
- host: { type: 'string', description: 'Host for the server', default: agentDefaults.host },
11
+ config: {
12
+ type: 'string',
13
+ description: 'Path to the Kubb config file',
14
+ short: 'c',
15
+ },
16
+ port: {
17
+ type: 'string',
18
+ description: 'Port the HTTP server listens on',
19
+ short: 'p',
20
+ default: agentDefaults.port,
21
+ },
22
+ host: {
23
+ type: 'string',
24
+ description: 'Hostname the HTTP server binds to',
25
+ default: agentDefaults.host,
26
+ },
12
27
  'allow-write': {
13
28
  type: 'boolean',
14
- description: 'Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.',
29
+ description: 'Write generated files to the filesystem. When omitted, output is streamed only and no files are written.',
30
+ default: false,
31
+ },
32
+ 'allow-all': {
33
+ type: 'boolean',
34
+ description: 'Grant all permissions (implies --allow-write).',
15
35
  default: false,
16
36
  },
17
- 'allow-all': { type: 'boolean', description: 'Grant all permissions (implies --allow-write).', default: false },
18
37
  },
19
38
  async run({ values }) {
20
- const { runAgentStart } = await import('../../runners/agent.ts')
39
+ const { run } = await import('../../runners/agent/run.ts')
21
40
 
22
- await runAgentStart({
41
+ await run({
23
42
  port: values.port !== undefined ? values.port : undefined,
24
43
  host: values.host,
25
44
  configPath: values.config,
@@ -3,6 +3,8 @@ import { command as startCommand } from './agent/start.ts'
3
3
 
4
4
  export const command = defineCommand({
5
5
  name: 'agent',
6
- description: 'Manage the Kubb Agent server',
6
+ description:
7
+ 'Manage the Kubb Agent — an HTTP server that lets AI agents trigger code generation programmatically via a REST API. Useful when an AI workflow needs to generate code without direct CLI access.',
8
+ examples: ['kubb agent start', 'kubb agent start --port 4000 --allow-write', 'kubb agent start --config ./kubb.config.ts --allow-all'],
7
9
  subCommands: [startCommand],
8
10
  })
@@ -2,10 +2,16 @@ import { defineCommand } from '@internals/utils'
2
2
 
3
3
  export const command = defineCommand({
4
4
  name: 'generate',
5
- description: "[input] Generate files based on a 'kubb.config.ts' file",
5
+ description:
6
+ '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
7
  arguments: ['[input]'],
8
+ examples: ['kubb generate', 'kubb generate ./openapi.yaml', 'kubb generate --config kubb.config.ts', 'kubb generate --watch'],
7
9
  options: {
8
- config: { type: 'string', description: 'Path to the Kubb config', short: 'c' },
10
+ config: {
11
+ type: 'string',
12
+ description: 'Path to the Kubb config',
13
+ short: 'c',
14
+ },
9
15
  logLevel: {
10
16
  type: 'string',
11
17
  description: 'Info, silent, verbose or debug',
@@ -14,15 +20,40 @@ export const command = defineCommand({
14
20
  hint: 'silent|info|verbose|debug',
15
21
  enum: ['silent', 'info', 'verbose', 'debug'],
16
22
  },
17
- watch: { type: 'boolean', description: 'Watch mode based on the input file', short: 'w', default: false },
18
- debug: { type: 'boolean', description: 'Override logLevel to debug', short: 'd', default: false },
19
- verbose: { type: 'boolean', description: 'Override logLevel to verbose', short: 'v', default: false },
20
- silent: { type: 'boolean', description: 'Override logLevel to silent', short: 's', default: false },
23
+ watch: {
24
+ type: 'boolean',
25
+ description: 'Watch mode based on the input file',
26
+ short: 'w',
27
+ default: false,
28
+ },
29
+ debug: {
30
+ type: 'boolean',
31
+ description: 'Override logLevel to debug',
32
+ short: 'd',
33
+ default: false,
34
+ },
35
+ verbose: {
36
+ type: 'boolean',
37
+ description: 'Override logLevel to verbose',
38
+ short: 'v',
39
+ default: false,
40
+ },
41
+ silent: {
42
+ type: 'boolean',
43
+ description: 'Override logLevel to silent',
44
+ short: 's',
45
+ default: false,
46
+ },
21
47
  },
22
48
  async run({ values, positionals }) {
23
49
  const logLevel = values.debug ? 'debug' : values.verbose ? 'verbose' : values.silent ? 'silent' : values.logLevel
24
- const { runGenerateCommand } = await import('../runners/generate.ts')
50
+ const { run } = await import('../runners/generate/run.ts')
25
51
 
26
- await runGenerateCommand({ input: positionals[0], configPath: values.config, logLevel, watch: values.watch })
52
+ await run({
53
+ input: positionals[0],
54
+ configPath: values.config,
55
+ logLevel,
56
+ watch: values.watch,
57
+ })
27
58
  },
28
59
  })
@@ -3,13 +3,49 @@ 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
- yes: { type: 'boolean', description: 'Skip prompts and use default options', short: 'y', default: false },
15
+ yes: {
16
+ type: 'boolean',
17
+ description: 'Skip prompts and use default options',
18
+ short: 'y',
19
+ default: false,
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
+ },
9
39
  },
10
40
  async run({ values }) {
11
- const { runInit } = await import('../runners/init.ts')
41
+ const { run } = await import('../runners/init/run.ts')
12
42
 
13
- 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
+ })
14
50
  },
15
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,13 +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
- input: { type: 'string', description: 'Path to Swagger/OpenAPI file', short: 'i', required: true },
10
+ input: {
11
+ type: 'string',
12
+ description: 'Path or URL to the OpenAPI/Swagger file to validate',
13
+ short: 'i',
14
+ required: true,
15
+ },
9
16
  },
10
17
  async run({ values }) {
11
- const { runValidate } = await import('../runners/validate.ts')
18
+ const { run } = await import('../runners/validate/run.ts')
12
19
 
13
- await runValidate({ input: values.input, version })
20
+ await run({ input: values.input, version })
14
21
  },
15
22
  })
package/src/constants.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { KUBB_CONFIG_FILENAME } from '@internals/shared'
2
+
1
3
  /**
2
4
  * NPM registry endpoint used to check for @kubb/cli updates.
3
5
  */
@@ -31,93 +33,16 @@ export const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const
31
33
  /**
32
34
  * Flags that short-circuit execution (help/version) — no telemetry notice is shown.
33
35
  */
34
- export const QUITE_FLAGS = new Set(['--help', '-h', '--version', '-v'] as const)
35
-
36
- /**
37
- * Flags accepted by the `generate` command.
38
- */
39
- export const GENERATE_FLAGS = new Set(['--config', '-c', '--log-level', '-l', '--watch', '-w', '--debug', '-d', '--verbose', '-v', '--silent', '-s'] as const)
40
-
41
- /**
42
- * Flags accepted by the `validate` command.
43
- */
44
- export const VALIDATE_FLAGS = new Set(['--input', '-i'] as const)
45
-
46
- /**
47
- * Flags accepted by the `init` command.
48
- */
49
- export const INIT_FLAGS = new Set(['--yes', '-y'] as const)
50
-
51
- /**
52
- * Flags accepted by the `agent start` command.
53
- */
54
- export const AGENT_START_FLAGS = new Set(['--config', '-c', '--port', '-p', '--host', '--allow-write', '--allow-all'] as const)
55
-
56
- /**
57
- * All known CLI flags across every command.
58
- */
59
- export const ARGS = new Set([...QUITE_FLAGS, ...GENERATE_FLAGS, ...VALIDATE_FLAGS, ...INIT_FLAGS, ...AGENT_START_FLAGS] as const)
36
+ export const QUIET_FLAGS = new Set(['--help', '-h', '--version', '-v'] as const)
60
37
 
61
38
  export const agentDefaults = {
62
39
  port: '3000',
63
40
  host: 'localhost',
64
- configFile: 'kubb.config.ts',
41
+ configFile: KUBB_CONFIG_FILENAME,
65
42
  retryTimeout: '30000',
66
- studioUrl: 'https://studio.kubb.dev',
43
+ studioUrl: 'https://kubb.studio',
67
44
  /**
68
45
  * Relative path from the @kubb/agent package root to the server entry.
69
46
  */
70
47
  serverEntryPath: '.output/server/index.mjs',
71
48
  } as const
72
-
73
- /**
74
- * Default values used during interactive `init` scaffolding.
75
- */
76
- export const initDefaults = {
77
- inputPath: './openapi.yaml',
78
- outputPath: './src/gen',
79
- plugins: ['plugin-oas', 'plugin-ts'],
80
- } as const
81
-
82
- /**
83
- * Maps each plugin value to the default config snippet inserted by `init`.
84
- * The `satisfies` constraint ensures all values remain plain strings while
85
- * `as const` keeps the object deeply immutable.
86
- */
87
- export const pluginDefaultConfigs = {
88
- 'plugin-oas': 'pluginOas()',
89
- 'plugin-ts': `pluginTs({
90
- output: { path: 'models' },
91
- })`,
92
- 'plugin-client': `pluginClient({
93
- output: { path: 'clients' },
94
- })`,
95
- 'plugin-react-query': `pluginReactQuery({
96
- output: { path: 'hooks' },
97
- })`,
98
- 'plugin-solid-query': `pluginSolidQuery({
99
- output: { path: 'hooks' },
100
- })`,
101
- 'plugin-svelte-query': `pluginSvelteQuery({
102
- output: { path: 'hooks' },
103
- })`,
104
- 'plugin-vue-query': `pluginVueQuery({
105
- output: { path: 'hooks' },
106
- })`,
107
- 'plugin-swr': `pluginSwr({
108
- output: { path: 'hooks' },
109
- })`,
110
- 'plugin-zod': `pluginZod({
111
- output: { path: 'zod' },
112
- })`,
113
- 'plugin-faker': `pluginFaker({
114
- output: { path: 'mocks' },
115
- })`,
116
- 'plugin-msw': `pluginMsw({
117
- output: { path: 'msw' },
118
- })`,
119
- } as const satisfies Record<string, string>
120
-
121
- /**
122
- * Color palette used by randomCliColor() for deterministic plugin name coloring.
123
- */
package/src/index.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import { styleText } from 'node:util'
2
- import { createCLI } from '@internals/utils'
2
+ import { createCLI, isFlag } from '@internals/utils'
3
3
  import { version } from '../package.json'
4
- import { QUITE_FLAGS } from './constants.ts'
5
- import { isFlag } from './utils/flags.ts'
6
- import { isTelemetryDisabled } from './utils/telemetry.ts'
4
+ import { QUIET_FLAGS } from './constants.ts'
5
+ import { isTelemetryDisabled } from './telemetry.ts'
7
6
 
8
7
  const cli = createCLI()
9
8
 
@@ -11,14 +10,17 @@ function shouldShowTelemetryNotice(argv: Array<string>): boolean {
11
10
  if (isTelemetryDisabled()) {
12
11
  return false
13
12
  }
13
+
14
14
  // Skip when the user is just asking for help or version info
15
- if (argv.some((arg) => isFlag(QUITE_FLAGS, arg))) {
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
 
@@ -29,14 +31,11 @@ export async function run(argv: Array<string> = process.argv): Promise<void> {
29
31
  )
30
32
  }
31
33
 
32
- const [{ command: generateCommand }, { command: validateCommand }, { command: mcpCommand }, { command: agentCommand }, { command: initCommand }] =
33
- await Promise.all([
34
- import('./commands/generate.ts'),
35
- import('./commands/validate.ts'),
36
- import('./commands/mcp.ts'),
37
- import('./commands/agent.ts'),
38
- import('./commands/init.ts'),
39
- ])
34
+ const { command: generateCommand } = await import('./commands/generate.ts')
35
+ const { command: validateCommand } = await import('./commands/validate.ts')
36
+ const { command: mcpCommand } = await import('./commands/mcp.ts')
37
+ const { command: agentCommand } = await import('./commands/agent.ts')
38
+ const { command: initCommand } = await import('./commands/init.ts')
40
39
 
41
40
  await cli.run([generateCommand, validateCommand, mcpCommand, agentCommand, initCommand], argv, {
42
41
  programName: 'kubb',