@kubb/cli 5.0.0-beta.6 → 5.0.0-beta.60

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 (142) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +170 -51
  3. package/dist/Telemetry-CVdyJarO.js +283 -0
  4. package/dist/Telemetry-CVdyJarO.js.map +1 -0
  5. package/dist/Telemetry-DrppRqqW.cjs +320 -0
  6. package/dist/Telemetry-DrppRqqW.cjs.map +1 -0
  7. package/dist/{define-Bdn8j5VM.cjs → define-C4AB3POr.cjs} +2 -2
  8. package/dist/{define-Bdn8j5VM.cjs.map → define-C4AB3POr.cjs.map} +1 -1
  9. package/dist/{define-Ctii4bel.js → define-C63T4jp6.js} +2 -2
  10. package/dist/{define-Ctii4bel.js.map → define-C63T4jp6.js.map} +1 -1
  11. package/dist/{errors-CjPmyZHy.js → errors-BsemQCMn.js} +2 -2
  12. package/dist/{errors-CjPmyZHy.js.map → errors-BsemQCMn.js.map} +1 -1
  13. package/dist/{errors-CLCjoSg0.cjs → errors-DykI11xo.cjs} +2 -2
  14. package/dist/{errors-CLCjoSg0.cjs.map → errors-DykI11xo.cjs.map} +1 -1
  15. package/dist/{generate-BB2Q7I9s.cjs → generate-CMsFCzhp.cjs} +22 -17
  16. package/dist/generate-CMsFCzhp.cjs.map +1 -0
  17. package/dist/{generate-BmulGxIM.js → generate-CNXTYKOV.js} +22 -17
  18. package/dist/generate-CNXTYKOV.js.map +1 -0
  19. package/dist/index.cjs +10 -27
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +10 -27
  23. package/dist/index.js.map +1 -1
  24. package/dist/{init-Dpg8e1HN.cjs → init--vszxTGP.cjs} +6 -6
  25. package/dist/{init-Dpg8e1HN.cjs.map → init--vszxTGP.cjs.map} +1 -1
  26. package/dist/{init-BTp9if7K.js → init-BD4zelZR.js} +6 -6
  27. package/dist/{init-BTp9if7K.js.map → init-BD4zelZR.js.map} +1 -1
  28. package/dist/{mcp-C9RoU-Dg.js → mcp-CKrpwcmV.js} +6 -6
  29. package/dist/{mcp-C9RoU-Dg.js.map → mcp-CKrpwcmV.js.map} +1 -1
  30. package/dist/{mcp-wpl6sYYR.cjs → mcp-DSYDu-Tk.cjs} +6 -6
  31. package/dist/{mcp-wpl6sYYR.cjs.map → mcp-DSYDu-Tk.cjs.map} +1 -1
  32. package/dist/package-BFdHEmb9.js +6 -0
  33. package/dist/package-BFdHEmb9.js.map +1 -0
  34. package/dist/{package-iheSdfas.cjs → package-CwCIaoAJ.cjs} +2 -2
  35. package/dist/package-CwCIaoAJ.cjs.map +1 -0
  36. package/dist/run-9ZhHuNZQ.cjs +33 -0
  37. package/dist/run-9ZhHuNZQ.cjs.map +1 -0
  38. package/dist/run-BG7Giryi.js +296 -0
  39. package/dist/run-BG7Giryi.js.map +1 -0
  40. package/dist/{validate-BU4fPTMc.cjs → run-BQO_tPlc.cjs} +25 -20
  41. package/dist/run-BQO_tPlc.cjs.map +1 -0
  42. package/dist/run-CIcMzR6i.js +1377 -0
  43. package/dist/run-CIcMzR6i.js.map +1 -0
  44. package/dist/run-CYnDu3ch.js +51 -0
  45. package/dist/run-CYnDu3ch.js.map +1 -0
  46. package/dist/run-DQZAMhO5.cjs +1380 -0
  47. package/dist/run-DQZAMhO5.cjs.map +1 -0
  48. package/dist/run-DpKny2hT.cjs +300 -0
  49. package/dist/run-DpKny2hT.cjs.map +1 -0
  50. package/dist/run-h8NTawHO.js +32 -0
  51. package/dist/run-h8NTawHO.js.map +1 -0
  52. package/dist/tools-BU99bhi8.js +152 -0
  53. package/dist/tools-BU99bhi8.js.map +1 -0
  54. package/dist/tools-_Xp8-_zy.cjs +175 -0
  55. package/dist/tools-_Xp8-_zy.cjs.map +1 -0
  56. package/dist/{validate-BfJoCxrC.js → validate-BPHQK1kh.js} +6 -6
  57. package/dist/{validate-BfJoCxrC.js.map → validate-BPHQK1kh.js.map} +1 -1
  58. package/dist/{validate-DIDBROB2.cjs → validate-R-AOm0fm.cjs} +6 -6
  59. package/dist/{validate-DIDBROB2.cjs.map → validate-R-AOm0fm.cjs.map} +1 -1
  60. package/package.json +12 -27
  61. package/src/Telemetry.ts +297 -0
  62. package/src/commands/generate.ts +18 -12
  63. package/src/commands/init.ts +2 -2
  64. package/src/commands/mcp.ts +2 -2
  65. package/src/commands/validate.ts +2 -2
  66. package/src/constants.ts +2 -35
  67. package/src/index.ts +5 -21
  68. package/src/loggers/clackLogger.ts +136 -202
  69. package/src/loggers/defineLogger.ts +59 -0
  70. package/src/loggers/plainLogger.ts +48 -103
  71. package/src/loggers/types.ts +6 -1
  72. package/src/loggers/utils.ts +167 -24
  73. package/src/runners/generate/run.ts +399 -0
  74. package/src/runners/generate/utils.ts +229 -0
  75. package/src/runners/{init.ts → init/run.ts} +81 -78
  76. package/src/runners/init/utils.ts +39 -0
  77. package/src/runners/mcp/run.ts +37 -0
  78. package/src/runners/{validate.ts → validate/run.ts} +25 -20
  79. package/dist/agent-BJEvbSiP.js +0 -68
  80. package/dist/agent-BJEvbSiP.js.map +0 -1
  81. package/dist/agent-CXNO6dgj.cjs +0 -70
  82. package/dist/agent-CXNO6dgj.cjs.map +0 -1
  83. package/dist/agent-D9CKYh4K.cjs +0 -122
  84. package/dist/agent-D9CKYh4K.cjs.map +0 -1
  85. package/dist/agent-VXKxLCho.js +0 -118
  86. package/dist/agent-VXKxLCho.js.map +0 -1
  87. package/dist/constants-BPJBMT_6.js +0 -45
  88. package/dist/constants-BPJBMT_6.js.map +0 -1
  89. package/dist/constants-BYGmiFs0.cjs +0 -139
  90. package/dist/constants-BYGmiFs0.cjs.map +0 -1
  91. package/dist/constants-DSJ-Xrbv.js +0 -116
  92. package/dist/constants-DSJ-Xrbv.js.map +0 -1
  93. package/dist/constants-Rcaqzyd-.cjs +0 -80
  94. package/dist/constants-Rcaqzyd-.cjs.map +0 -1
  95. package/dist/generate-BB2Q7I9s.cjs.map +0 -1
  96. package/dist/generate-B_p5dl68.cjs +0 -1755
  97. package/dist/generate-B_p5dl68.cjs.map +0 -1
  98. package/dist/generate-BmulGxIM.js.map +0 -1
  99. package/dist/generate-DAsdUw3z.js +0 -1752
  100. package/dist/generate-DAsdUw3z.js.map +0 -1
  101. package/dist/init-CJ80lKSP.cjs +0 -239
  102. package/dist/init-CJ80lKSP.cjs.map +0 -1
  103. package/dist/init-DCqcEq86.js +0 -235
  104. package/dist/init-DCqcEq86.js.map +0 -1
  105. package/dist/mcp-D1llTaRM.cjs +0 -50
  106. package/dist/mcp-D1llTaRM.cjs.map +0 -1
  107. package/dist/mcp-DNUw8nqb.js +0 -49
  108. package/dist/mcp-DNUw8nqb.js.map +0 -1
  109. package/dist/package-iheSdfas.cjs.map +0 -1
  110. package/dist/package-vLafMWCe.js +0 -6
  111. package/dist/package-vLafMWCe.js.map +0 -1
  112. package/dist/shell-475fQKaX.cjs +0 -62
  113. package/dist/shell-475fQKaX.cjs.map +0 -1
  114. package/dist/shell-DLzN4fRo.js +0 -51
  115. package/dist/shell-DLzN4fRo.js.map +0 -1
  116. package/dist/telemetry-BLX0NzRk.cjs +0 -282
  117. package/dist/telemetry-BLX0NzRk.cjs.map +0 -1
  118. package/dist/telemetry-juq4QBf7.js +0 -245
  119. package/dist/telemetry-juq4QBf7.js.map +0 -1
  120. package/dist/validate-BU4fPTMc.cjs.map +0 -1
  121. package/dist/validate-k9s_hFah.js +0 -46
  122. package/dist/validate-k9s_hFah.js.map +0 -1
  123. package/src/commands/agent/start.ts +0 -50
  124. package/src/commands/agent.ts +0 -10
  125. package/src/loggers/fileSystemLogger.ts +0 -138
  126. package/src/loggers/githubActionsLogger.ts +0 -379
  127. package/src/runners/agent.ts +0 -155
  128. package/src/runners/generate.ts +0 -333
  129. package/src/runners/mcp.ts +0 -56
  130. package/src/types.ts +0 -11
  131. package/src/utils/Writables.ts +0 -17
  132. package/src/utils/executeHooks.ts +0 -45
  133. package/src/utils/flags.ts +0 -9
  134. package/src/utils/getConfig.ts +0 -10
  135. package/src/utils/getCosmiConfig.ts +0 -75
  136. package/src/utils/getSummary.ts +0 -68
  137. package/src/utils/packageManager.ts +0 -23
  138. package/src/utils/runHook.ts +0 -91
  139. package/src/utils/telemetry.ts +0 -273
  140. package/src/utils/watcher.ts +0 -19
  141. /package/dist/{chunk-ByKO4r7w.cjs → chunk-Bx3C2hgW.cjs} +0 -0
  142. /package/dist/{chunk--u3MIqq1.js → chunk-C0LytTxp.js} +0 -0
@@ -0,0 +1,297 @@
1
+ import { randomBytes } from 'node:crypto'
2
+ import os from 'node:os'
3
+ import process from 'node:process'
4
+ import { isCIEnvironment, runtime } from '@internals/utils'
5
+ import { OTLP_ENDPOINT } from './constants.ts'
6
+
7
+ // OpenTelemetry OTLP JSON types
8
+ // https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto
9
+ // https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/common/v1/common.proto
10
+
11
+ type OtlpStringValue = { stringValue: string }
12
+ type OtlpBoolValue = { boolValue: boolean }
13
+ type OtlpIntValue = { intValue: number }
14
+ type OtlpDoubleValue = { doubleValue: number }
15
+ type OtlpBytesValue = { bytesValue: string }
16
+ type OtlpArrayValue = { arrayValue: { values: Array<OtlpAnyValue> } }
17
+ type OtlpKvListValue = { kvlistValue: { values: Array<OtlpKeyValue> } }
18
+
19
+ type OtlpAnyValue = OtlpStringValue | OtlpBoolValue | OtlpIntValue | OtlpDoubleValue | OtlpBytesValue | OtlpArrayValue | OtlpKvListValue
20
+
21
+ type OtlpKeyValue = {
22
+ key: string
23
+ value: OtlpAnyValue
24
+ }
25
+
26
+ type OtlpResource = {
27
+ attributes: Array<OtlpKeyValue>
28
+ droppedAttributesCount?: number
29
+ }
30
+
31
+ type OtlpInstrumentationScope = {
32
+ name: string
33
+ version?: string
34
+ attributes?: Array<OtlpKeyValue>
35
+ droppedAttributesCount?: number
36
+ }
37
+
38
+ /**
39
+ * @see https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto#L103
40
+ */
41
+ type OtlpSpanKind = 0 | 1 | 2 | 3 | 4 | 5
42
+
43
+ /**
44
+ * Span status code.
45
+ * - `0` is unset
46
+ * - `1` is OK
47
+ * - `2` is error
48
+ */
49
+ type OtlpStatusCode = 0 | 1 | 2
50
+
51
+ type OtlpStatus = {
52
+ code: OtlpStatusCode
53
+ message?: string
54
+ }
55
+
56
+ type OtlpSpan = {
57
+ traceId: string
58
+ spanId: string
59
+ traceState?: string
60
+ parentSpanId?: string
61
+ name: string
62
+ kind: OtlpSpanKind
63
+ startTimeUnixNano: string
64
+ endTimeUnixNano: string
65
+ attributes?: Array<OtlpKeyValue>
66
+ droppedAttributesCount?: number
67
+ events?: Array<OtlpSpanEvent>
68
+ droppedEventsCount?: number
69
+ links?: Array<OtlpSpanLink>
70
+ droppedLinksCount?: number
71
+ status?: OtlpStatus
72
+ }
73
+
74
+ type OtlpSpanEvent = {
75
+ timeUnixNano: string
76
+ name: string
77
+ attributes?: Array<OtlpKeyValue>
78
+ droppedAttributesCount?: number
79
+ }
80
+
81
+ type OtlpSpanLink = {
82
+ traceId: string
83
+ spanId: string
84
+ traceState?: string
85
+ attributes?: Array<OtlpKeyValue>
86
+ droppedAttributesCount?: number
87
+ }
88
+
89
+ type OtlpScopeSpans = {
90
+ scope: OtlpInstrumentationScope
91
+ spans: Array<OtlpSpan>
92
+ schemaUrl?: string
93
+ }
94
+
95
+ type OtlpResourceSpans = {
96
+ resource: OtlpResource
97
+ scopeSpans: Array<OtlpScopeSpans>
98
+ schemaUrl?: string
99
+ }
100
+
101
+ /**
102
+ * Root payload sent to POST /v1/traces.
103
+ */
104
+ type OtlpExportTraceServiceRequest = {
105
+ resourceSpans: Array<OtlpResourceSpans>
106
+ }
107
+
108
+ /**
109
+ * Anonymous plugin name and options snapshot sent with each telemetry event.
110
+ */
111
+ export type TelemetryPlugin = {
112
+ /**
113
+ * Plugin name as registered in the Kubb config, e.g. `'@kubb/plugin-ts'`.
114
+ */
115
+ name: string
116
+ /**
117
+ * Anonymized snapshot of the plugin options. Values are included but cannot be traced back to a user.
118
+ */
119
+ options: Record<string, unknown>
120
+ }
121
+
122
+ export type TelemetryEvent = {
123
+ command: string
124
+ kubbVersion: string
125
+ nodeVersion: string
126
+ /**
127
+ * Name of the JavaScript runtime that executed the run, `'bun'`, `'deno'`, or `'node'`.
128
+ */
129
+ runtime: string
130
+ /**
131
+ * Major version of the active runtime, e.g. `'1'` under Bun or `'22'` under Node.
132
+ */
133
+ runtimeVersion: string
134
+ platform: string
135
+ ci: boolean
136
+ plugins: Array<TelemetryPlugin>
137
+ duration: number
138
+ filesCreated: number
139
+ status: 'success' | 'failed'
140
+ }
141
+
142
+ /**
143
+ * Anonymous OTLP usage telemetry for a Kubb run. The API is static, so call it as `Telemetry.build(...)`
144
+ * and `Telemetry.send(...)`. No file paths, OpenAPI specs, or secrets are sent, and sending fails
145
+ * silently so a failed request never breaks the run.
146
+ */
147
+ export class Telemetry {
148
+ /**
149
+ * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.
150
+ */
151
+ static get isDisabled(): boolean {
152
+ return (
153
+ process.env['DO_NOT_TRACK'] === '1' ||
154
+ process.env['DO_NOT_TRACK'] === 'true' ||
155
+ process.env['KUBB_DISABLE_TELEMETRY'] === '1' ||
156
+ process.env['KUBB_DISABLE_TELEMETRY'] === 'true'
157
+ )
158
+ }
159
+
160
+ /**
161
+ * Build an anonymous telemetry payload from a completed generation run.
162
+ */
163
+ static build(options: {
164
+ command: 'generate' | 'mcp' | 'validate' | 'agent'
165
+ kubbVersion: string
166
+ plugins?: Array<TelemetryPlugin>
167
+ hrStart: [number, number]
168
+ filesCreated?: number
169
+ status: 'success' | 'failed'
170
+ }): TelemetryEvent {
171
+ const [seconds, nanoseconds] = process.hrtime(options.hrStart)
172
+ const duration = Math.round(seconds * 1000 + nanoseconds / 1e6)
173
+
174
+ return {
175
+ command: options.command,
176
+ kubbVersion: options.kubbVersion,
177
+ nodeVersion: process.versions.node.split('.')[0] as string,
178
+ runtime: runtime.name,
179
+ runtimeVersion: runtime.version.split('.')[0] as string,
180
+ platform: os.platform(),
181
+ ci: isCIEnvironment(),
182
+ plugins: options.plugins ?? [],
183
+ duration,
184
+ filesCreated: options.filesCreated ?? 0,
185
+ status: options.status,
186
+ }
187
+ }
188
+
189
+ /**
190
+ * Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.
191
+ * See https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/
192
+ */
193
+ static buildOtlpPayload(event: TelemetryEvent): OtlpExportTraceServiceRequest {
194
+ const traceId = randomBytes(16).toString('hex')
195
+ const spanId = randomBytes(8).toString('hex')
196
+ const endTimeNs = BigInt(Date.now()) * 1_000_000n
197
+ const startTimeNs = endTimeNs - BigInt(event.duration) * 1_000_000n
198
+
199
+ const attributes: Array<OtlpKeyValue> = [
200
+ { key: 'kubb.command', value: { stringValue: event.command } },
201
+ { key: 'kubb.version', value: { stringValue: event.kubbVersion } },
202
+ { key: 'kubb.node_version', value: { stringValue: event.nodeVersion } },
203
+ { key: 'kubb.runtime', value: { stringValue: event.runtime } },
204
+ { key: 'kubb.runtime_version', value: { stringValue: event.runtimeVersion } },
205
+ { key: 'kubb.platform', value: { stringValue: event.platform } },
206
+ { key: 'kubb.ci', value: { boolValue: event.ci } },
207
+ { key: 'kubb.files_created', value: { intValue: event.filesCreated } },
208
+ { key: 'kubb.status', value: { stringValue: event.status } },
209
+ {
210
+ key: 'kubb.plugins',
211
+ value: {
212
+ arrayValue: {
213
+ values: event.plugins.map(
214
+ (p): OtlpKvListValue => ({
215
+ kvlistValue: {
216
+ values: [
217
+ { key: 'name', value: { stringValue: p.name } },
218
+ {
219
+ key: 'options',
220
+ value: {
221
+ stringValue: JSON.stringify({
222
+ ...p.options,
223
+ usedEnumNames: undefined,
224
+ }),
225
+ },
226
+ },
227
+ ],
228
+ },
229
+ }),
230
+ ),
231
+ },
232
+ },
233
+ },
234
+ ]
235
+
236
+ return {
237
+ resourceSpans: [
238
+ {
239
+ resource: {
240
+ attributes: [
241
+ { key: 'service.name', value: { stringValue: 'kubb-core' } },
242
+ {
243
+ key: 'service.version',
244
+ value: { stringValue: event.kubbVersion },
245
+ },
246
+ { key: 'telemetry.sdk.language', value: { stringValue: 'nodejs' } },
247
+ ],
248
+ },
249
+ scopeSpans: [
250
+ {
251
+ scope: { name: 'kubb-core', version: event.kubbVersion },
252
+ spans: [
253
+ {
254
+ traceId,
255
+ spanId,
256
+ name: event.command,
257
+ kind: 1 satisfies OtlpSpanKind,
258
+ startTimeUnixNano: String(startTimeNs),
259
+ endTimeUnixNano: String(endTimeNs),
260
+ attributes,
261
+ status: {
262
+ code: (event.status === 'success' ? 1 : 2) satisfies OtlpStatusCode,
263
+ },
264
+ },
265
+ ],
266
+ },
267
+ ],
268
+ },
269
+ ],
270
+ }
271
+ }
272
+
273
+ /**
274
+ * Send an anonymous telemetry event to the Kubb OTLP endpoint. Respects `DO_NOT_TRACK` and
275
+ * `KUBB_DISABLE_TELEMETRY`, and fails silently so telemetry never interrupts a run.
276
+ */
277
+ static async send(event: TelemetryEvent): Promise<void> {
278
+ if (Telemetry.isDisabled) {
279
+ return
280
+ }
281
+
282
+ try {
283
+ await fetch(`${OTLP_ENDPOINT}/v1/traces`, {
284
+ method: 'POST',
285
+ headers: {
286
+ 'Content-Type': 'application/json',
287
+ 'Kubb-Telemetry-Version': '1',
288
+ 'Kubb-Telemetry-Source': 'kubb-core',
289
+ },
290
+ body: JSON.stringify(Telemetry.buildOtlpPayload(event)),
291
+ signal: AbortSignal.timeout(5_000),
292
+ })
293
+ } catch (_e) {
294
+ // Fail silently, telemetry must never break the run
295
+ }
296
+ }
297
+ }
@@ -1,4 +1,5 @@
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',
@@ -14,11 +15,11 @@ export const command = defineCommand({
14
15
  },
15
16
  logLevel: {
16
17
  type: 'string',
17
- description: 'Info, silent, verbose or debug',
18
+ description: 'Info, silent or verbose',
18
19
  short: 'l',
19
20
  default: 'info',
20
- hint: 'silent|info|verbose|debug',
21
- enum: ['silent', 'info', 'verbose', 'debug'],
21
+ hint: 'silent|info|verbose',
22
+ enum: ['silent', 'info', 'verbose'],
22
23
  },
23
24
  watch: {
24
25
  type: 'boolean',
@@ -26,12 +27,6 @@ export const command = defineCommand({
26
27
  short: 'w',
27
28
  default: false,
28
29
  },
29
- debug: {
30
- type: 'boolean',
31
- description: 'Override logLevel to debug',
32
- short: 'd',
33
- default: false,
34
- },
35
30
  verbose: {
36
31
  type: 'boolean',
37
32
  description: 'Override logLevel to verbose',
@@ -44,16 +39,27 @@ export const command = defineCommand({
44
39
  short: 's',
45
40
  default: false,
46
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
+ },
47
48
  },
48
49
  async run({ values, positionals }) {
49
- const logLevel = values.debug ? 'debug' : values.verbose ? 'verbose' : values.silent ? 'silent' : values.logLevel
50
- 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')
51
56
 
52
- await runGenerateCommand({
57
+ await run({
53
58
  input: positionals[0],
54
59
  configPath: values.config,
55
60
  logLevel,
56
61
  watch: values.watch,
62
+ reporters,
57
63
  })
58
64
  },
59
65
  })
@@ -38,9 +38,9 @@ export const command = defineCommand({
38
38
  },
39
39
  },
40
40
  async run({ values }) {
41
- const { runInit } = await import('../runners/init.ts')
41
+ const { run } = await import('../runners/init/run.ts')
42
42
 
43
- await runInit({
43
+ await run({
44
44
  yes: values.yes,
45
45
  version,
46
46
  input: values.input,
@@ -25,9 +25,9 @@ export const command = defineCommand({
25
25
  },
26
26
  },
27
27
  async run({ values }) {
28
- const { runMcp } = await import('../runners/mcp.ts')
28
+ const { run } = await import('../runners/mcp/run.ts')
29
29
 
30
- await runMcp({
30
+ await run({
31
31
  version,
32
32
  port: values.port,
33
33
  host: values.host,
@@ -15,8 +15,8 @@ export const command = defineCommand({
15
15
  },
16
16
  },
17
17
  async run({ values }) {
18
- const { runValidate } = await import('../runners/validate.ts')
18
+ const { run } = await import('../runners/validate/run.ts')
19
19
 
20
- await runValidate({ input: values.input, version })
20
+ await run({ input: values.input, version })
21
21
  },
22
22
  })
package/src/constants.ts CHANGED
@@ -1,5 +1,3 @@
1
- import { KUBB_CONFIG_FILENAME } from '@internals/shared'
2
-
3
1
  /**
4
2
  * NPM registry endpoint used to check for @kubb/cli updates.
5
3
  */
@@ -10,43 +8,12 @@ export const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest
10
8
  */
11
9
  export const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const
12
10
 
13
- /**
14
- * Horizontal rule rendered above/below the plain-logger generation summary.
15
- */
16
- export const SUMMARY_SEPARATOR = '─'.repeat(27)
17
-
18
- /**
19
- * Maximum number of █ characters in a plugin timing bar.
20
- */
21
- export const SUMMARY_MAX_BAR_LENGTH = 10 as const
22
-
23
- /**
24
- * Divides elapsed milliseconds into bar-length units (1 block per 100 ms).
25
- */
26
- export const SUMMARY_TIME_SCALE_DIVISOR = 100 as const
27
-
28
11
  /**
29
12
  * Glob pattern for paths the file watcher ignores.
30
13
  */
31
14
  export const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const
32
15
 
33
16
  /**
34
- * Flags that short-circuit execution (help/version) no telemetry notice is shown.
35
- */
36
- export const QUIET_FLAGS = new Set(['--help', '-h', '--version', '-v'] as const)
37
-
38
- export const agentDefaults = {
39
- port: '3000',
40
- host: 'localhost',
41
- configFile: KUBB_CONFIG_FILENAME,
42
- retryTimeout: '30000',
43
- studioUrl: 'https://kubb.studio',
44
- /**
45
- * Relative path from the @kubb/agent package root to the server entry.
46
- */
47
- serverEntryPath: '.output/server/index.mjs',
48
- } as const
49
-
50
- /**
51
- * Color palette used by randomCliColor() for deterministic plugin name coloring.
17
+ * Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these.
52
18
  */
19
+ export const QUIET_FLAGS = new Set<string>(['--help', '-h', '--version', '-v'])
package/src/index.ts CHANGED
@@ -1,29 +1,14 @@
1
1
  import { styleText } from 'node:util'
2
2
  import { createCLI } from '@internals/utils'
3
+ import { Telemetry } from './Telemetry.ts'
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
-
10
- function shouldShowTelemetryNotice(argv: Array<string>): boolean {
11
- if (isTelemetryDisabled()) {
12
- return false
13
- }
14
- // Skip when the user is just asking for help or version info
15
- if (argv.some((arg) => isFlag(QUIET_FLAGS, arg))) {
16
- return false
17
- }
18
- // Skip in non-interactive / scripting contexts
19
- if (!process.stdout.isTTY) {
20
- return false
21
- }
22
- return true
23
- }
24
-
25
8
  export async function run(argv: Array<string> = process.argv): Promise<void> {
26
- if (shouldShowTelemetryNotice(argv)) {
9
+ const isQuietFlag = argv.some((arg) => QUIET_FLAGS.has(arg))
10
+
11
+ if (!Telemetry.isDisabled && !isQuietFlag) {
27
12
  console.log(
28
13
  `${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`,
29
14
  )
@@ -32,10 +17,9 @@ export async function run(argv: Array<string> = process.argv): Promise<void> {
32
17
  const { command: generateCommand } = await import('./commands/generate.ts')
33
18
  const { command: validateCommand } = await import('./commands/validate.ts')
34
19
  const { command: mcpCommand } = await import('./commands/mcp.ts')
35
- const { command: agentCommand } = await import('./commands/agent.ts')
36
20
  const { command: initCommand } = await import('./commands/init.ts')
37
21
 
38
- await cli.run([generateCommand, validateCommand, mcpCommand, agentCommand, initCommand], argv, {
22
+ await cli.run([generateCommand, validateCommand, mcpCommand, initCommand], argv, {
39
23
  programName: 'kubb',
40
24
  defaultCommandName: 'generate',
41
25
  version,