{"version":3,"file":"utils-DT_n0UZH.cjs","names":["spawn","styleText","logLevelMap","clack","styleText","Diagnostics","relative","process","logLevelMap","Diagnostics","relative","logLevelMap","styleText","process","canUseTTY","getAgentName","jiti","createJiti","resolve","basename","loadConfig","dirname","process","isValid","isGreater","truncate","randomUUID","x","styleText","NonZeroExitError","toError","WATCHER_IGNORED_PATHS","URL_WATCHER_TIMEOUT_MS","URL_WATCHER_INTERVAL_MS"],"sources":["../../../internals/utils/src/tools.ts","../../../internals/utils/src/time.ts","../src/loggers/banner.ts","../src/loggers/clackLogger.ts","../src/loggers/plainLogger.ts","../src/loggers/utils.ts","../../../internals/shared/src/loader.ts","../src/runners/generate/utils.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\n\n/**\n * How one formatter or linter is invoked: the executable, the argv it takes for an output\n * directory, and what to report when it is not installed.\n */\nexport type ToolCommand = {\n  command: string\n  args: (outputPath: string) => Array<string>\n  errorMessage: string\n}\n\n/**\n * CLI command descriptors for each supported code formatter.\n */\nexport const formatters = {\n  prettier: {\n    command: 'prettier',\n    args: (outputPath: string) => ['--ignore-unknown', '--write', outputPath],\n    errorMessage: 'Prettier not found',\n  },\n  biome: {\n    command: 'biome',\n    args: (outputPath: string) => ['format', '--write', outputPath],\n    errorMessage: 'Biome not found',\n  },\n  oxfmt: {\n    command: 'oxfmt',\n    args: (outputPath: string) => [outputPath],\n    errorMessage: 'Oxfmt not found',\n  },\n} as const satisfies Record<string, ToolCommand>\n\n/**\n * CLI command descriptors for each supported linter.\n */\nexport const linters = {\n  eslint: {\n    command: 'eslint',\n    args: (outputPath: string) => [outputPath, '--fix'],\n    errorMessage: 'Eslint not found',\n  },\n  biome: {\n    command: 'biome',\n    args: (outputPath: string) => ['lint', '--fix', outputPath],\n    errorMessage: 'Biome not found',\n  },\n  oxlint: {\n    command: 'oxlint',\n    // --no-ignore so oxlint lints the folder even when it's gitignored (generated output dirs usually are).\n    args: (outputPath: string) => ['--fix', '--no-ignore', outputPath],\n    errorMessage: 'Oxlint not found',\n  },\n} as const satisfies Record<string, ToolCommand>\n\n/**\n * Preference order for `format: 'auto'`, most-preferred first. Spelled out rather than taken from\n * the table's key order, which is arbitrary and would silently change what `auto` picks.\n */\nexport const FORMATTER_PREFERENCE = ['oxfmt', 'biome', 'prettier'] as const\n\n/**\n * Preference order for `lint: 'auto'`, most-preferred first.\n */\nexport const LINTER_PREFERENCE = ['oxlint', 'biome', 'eslint'] as const\n\n/**\n * Whether `name` is on PATH and answers `--version` with a zero exit.\n */\nexport function isToolAvailable(name: string): Promise<boolean> {\n  return new Promise((resolve) => {\n    const child = spawn(name, ['--version'], { stdio: 'ignore' })\n    child.on('close', (code) => resolve(code === 0))\n    child.on('error', () => resolve(false))\n  })\n}\n\n/**\n * Returns the first installed executable from `candidates`, or `null` when none are found.\n *\n * Not memoized: a long-running host that probes repeatedly should cache the result itself, and a\n * `--watch` build should keep noticing a tool installed mid-session.\n */\nexport async function detectTool<TName extends string>(candidates: ReadonlyArray<TName>): Promise<TName | null> {\n  for (const candidate of candidates) {\n    if (await isToolAvailable(candidate)) {\n      return candidate\n    }\n  }\n\n  return null\n}\n\n/**\n * Tokenizes a shell command string, respecting single and double quotes.\n *\n * @example\n * ```ts\n * tokenize('git commit -m \"initial commit\"')\n * // → ['git', 'commit', '-m', 'initial commit']\n * ```\n */\nexport function tokenize(command: string): Array<string> {\n  return (command.match(/[^\\s\"']+|\"([^\"]*)\"|'([^']*)'/g) ?? []).map((token) => token.replace(/^[\"']|[\"']$/g, ''))\n}\n","/**\n * Calculates elapsed time in milliseconds from a high-resolution `process.hrtime` start time.\n * Rounds to 2 decimal places for sub-millisecond precision without noise.\n *\n * @example\n * ```ts\n * const start = process.hrtime()\n * doWork()\n * getElapsedMs(start) // 42.35\n * ```\n */\nexport function getElapsedMs(hrStart: [number, number]): number {\n  const [seconds, nanoseconds] = process.hrtime(hrStart)\n  const ms = seconds * 1000 + nanoseconds / 1e6\n  return Math.round(ms * 100) / 100\n}\n\n/**\n * Converts a millisecond duration into a human-readable string (`ms`, `s`, or `m s`).\n *\n * @example\n * ```ts\n * formatMs(250)   // '250ms'\n * formatMs(1500)  // '1.50s'\n * formatMs(90000) // '1m 30.0s'\n * ```\n */\nexport function formatMs(ms: number): string {\n  if (ms >= 60000) {\n    const mins = Math.floor(ms / 60000)\n    const secs = ((ms % 60000) / 1000).toFixed(1)\n    return `${mins}m ${secs}s`\n  }\n\n  if (ms >= 1000) {\n    return `${(ms / 1000).toFixed(2)}s`\n  }\n  return `${Math.round(ms)}ms`\n}\n","import { styleText } from 'node:util'\nimport { formatMs } from '@internals/utils'\n\n/**\n * Parsed RGB channels from a CSS hex color string.\n */\ntype RGB = { r: number; g: number; b: number }\n\n/**\n * Parses a CSS hex color string (`#RGB`) into its RGB channels.\n * Falls back to `255` for any channel that cannot be parsed.\n */\nfunction parseHex(color: string): RGB {\n  const int = Number.parseInt(color.replace('#', ''), 16)\n  return Number.isNaN(int) ? { r: 255, g: 255, b: 255 } : { r: (int >> 16) & 0xff, g: (int >> 8) & 0xff, b: int & 0xff }\n}\n\n/**\n * Returns a function that wraps a string in a 24-bit ANSI true-color escape sequence\n * for the given hex color.\n */\nfunction hex(color: string): (text: string) => string {\n  const { r, g, b } = parseHex(color)\n  return (text: string) => `\\x1b[38;2;${r};${g};${b}m${text}\\x1b[0m`\n}\n\nfunction gradient(colorStops: Array<string>, text: string): string {\n  const chars = text.split('')\n  return chars\n    .map((char, i) => {\n      const t = chars.length <= 1 ? 0 : i / (chars.length - 1)\n      const seg = Math.min(Math.floor(t * (colorStops.length - 1)), colorStops.length - 2)\n      const lt = t * (colorStops.length - 1) - seg\n      const from = parseHex(colorStops[seg]!)\n      const to = parseHex(colorStops[seg + 1]!)\n      const r = Math.round(from.r + (to.r - from.r) * lt)\n      const g = Math.round(from.g + (to.g - from.g) * lt)\n      const b = Math.round(from.b + (to.b - from.b) * lt)\n      return `\\x1b[38;2;${r};${g};${b}m${char}\\x1b[0m`\n    })\n    .join('')\n}\n\n/**\n * ANSI color functions for each part of the Kubb mascot illustration.\n */\nconst palette = {\n  /**\n   * Top cap of the skittle.\n   */\n  lid: hex('#F55A17'),\n  /**\n   * Upper wood body.\n   */\n  woodTop: hex('#F5A217'),\n  /**\n   * Middle wood body.\n   */\n  woodMid: hex('#F58517'),\n  /**\n   * Base wood body.\n   */\n  woodBase: hex('#B45309'),\n  /**\n   * Eye whites.\n   */\n  eye: hex('#FFFFFF'),\n  /**\n   * Highlight accent.\n   */\n  highlight: hex('#adadc6'),\n  /**\n   * Cheek blush.\n   */\n  blush: hex('#FDA4AF'),\n}\n\n/**\n * Generates the Kubb mascot welcome banner as an ANSI-colored string.\n *\n * @example\n * ```ts\n * console.log(getIntro({ title: 'kubb.config.ts', description: 'generating…', version: '5.0.0', areEyesOpen: true }))\n * ```\n */\nexport function getIntro({\n  title,\n  description,\n  version,\n  areEyesOpen,\n}: {\n  /**\n   * Name of the active configuration or tool being started.\n   */\n  title: string\n  /**\n   * Short subtitle shown next to the arrow prompt.\n   */\n  description: string\n  /**\n   * Kubb version string rendered in the gradient header.\n   */\n  version: string\n  /**\n   * When `false` the eyes are shown as closed dashes instead of open blocks.\n   */\n  areEyesOpen: boolean\n}): string {\n  const kubbVersion = gradient(['#F58517', '#F5A217', '#F55A17'], `KUBB v${version}`)\n\n  const eyeTop = areEyesOpen ? palette.eye('█▀█') : palette.eye('───')\n  const eyeBottom = areEyesOpen ? palette.eye('▀▀▀') : palette.eye('───')\n\n  return `\n   ${palette.lid('▄▄▄▄▄▄▄▄▄▄▄▄▄')}\n  ${palette.woodTop('█  ')}${palette.highlight('▄▄')}${palette.woodTop('     ')}${palette.highlight('▄▄')}${palette.woodTop('  █')}  ${kubbVersion}\n  ${palette.woodMid('█ ')}${eyeTop}${palette.woodMid('     ')}${eyeTop}${palette.woodMid(' █')}  ${styleText('gray', title)}\n  ${palette.woodMid('█ ')}${eyeBottom}${palette.woodMid('  ')}${palette.blush('◡')}${palette.woodMid('  ')}${eyeBottom}${palette.woodMid(' █')}  ${styleText('yellow', '➜')} ${styleText('white', description)}\n   ${palette.woodBase('▀▀▀▀▀▀▀▀▀▀▀▀▀')}\n`\n}\n\n/**\n * Formats a millisecond duration with a threshold-based ANSI color.\n * `≤ 500 ms` → green · `≤ 1 000 ms` → yellow · `> 1 000 ms` → red.\n *\n * @example\n * ```ts\n * formatMsWithColor(200)  // '\\x1b[32m200ms\\x1b[39m'\n * formatMsWithColor(800)  // '\\x1b[33m800ms\\x1b[39m'\n * formatMsWithColor(1500) // '\\x1b[31m1.50s\\x1b[39m'\n * ```\n */\nexport function formatMsWithColor(ms: number): string {\n  const formatted = formatMs(ms)\n  if (ms <= 500) return styleText('green', formatted)\n  if (ms <= 1000) return styleText('yellow', formatted)\n\n  return styleText('red', formatted)\n}\n","import { relative } from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { getElapsedMs } from '@internals/utils'\nimport { Diagnostics, type KubbHooks, logLevel as logLevelMap } from '@kubb/core'\nimport { formatMsWithColor, getIntro } from './banner.ts'\nimport type { Logger } from './defineLogger.ts'\nimport {\n  buildProgressLine,\n  createProgressCounters,\n  formatCommandWithArgs,\n  formatErrorFrames,\n  formatMessage,\n  formatVersions,\n  getInputPath,\n  recordPluginResult,\n  resetProgressCounters,\n} from './utils.ts'\n\n/**\n * TTY logger for local development, with spinners and progress bars.\n */\nexport const clackLogger = {\n  name: 'clack',\n  install(context, options) {\n    const logLevel = options?.logLevel ?? logLevelMap.info\n    const state = {\n      ...createProgressCounters(),\n      spinner: clack.spinner(),\n      isSpinning: false,\n      runningPlugins: new Set<string>(),\n      activeProgress: new Map<string, { interval?: NodeJS.Timeout; progressBar: clack.ProgressResult }>(),\n      activeHookLogs: new Map<string, { taskLog: ReturnType<typeof clack.taskLog>; hrStart: [number, number] }>(),\n    }\n\n    // Clear every active progress bar's interval, stop it, and drop the map.\n    function stopActiveProgress() {\n      for (const [, active] of state.activeProgress) {\n        if (active.interval) {\n          clearInterval(active.interval)\n        }\n        active.progressBar?.stop()\n      }\n      state.activeProgress.clear()\n    }\n\n    function reset() {\n      stopActiveProgress()\n\n      resetProgressCounters(state)\n      state.spinner = clack.spinner()\n      state.isSpinning = false\n      state.runningPlugins.clear()\n      state.activeHookLogs.clear()\n    }\n\n    // Label for the shared plugin bar, listing the plugins currently generating.\n    function pluginProgressText(): string {\n      const running = [...state.runningPlugins].map((name) => styleText('bold', name))\n      return getMessage(running.length > 0 ? `Generating ${running.join(', ')}` : 'Generating plugins')\n    }\n\n    function showProgressStep() {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      const line = buildProgressLine(state)\n      if (line) {\n        clack.log.step(getMessage(line))\n      }\n    }\n\n    function getMessage(message: string): string {\n      return formatMessage(message, logLevel)\n    }\n\n    // Registers a handler that prints a fixed step message, skipped at silent level.\n    function onStep<E extends keyof KubbHooks>(hook: E, message: string): void {\n      context.hook(hook, () => {\n        if (logLevel <= logLevelMap.silent) {\n          return\n        }\n        clack.log.step(getMessage(message))\n      })\n    }\n\n    function stopSpinner(text?: string) {\n      if (!state.isSpinning) {\n        return\n      }\n      state.spinner.stop(text)\n      state.isSpinning = false\n    }\n\n    context.hook('kubb:info', ({ message, info = '' }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      const text = getMessage([styleText('blue', 'ℹ'), message, info ? styleText('dim', info) : undefined].filter(Boolean).join(' '))\n\n      if (state.isSpinning) {\n        state.spinner.message(text)\n        return\n      }\n      clack.log.info(text)\n    })\n\n    context.hook('kubb:success', ({ message, info = '' }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      const text = getMessage([styleText('blue', '✓'), message, logLevel >= logLevelMap.info ? styleText('dim', info) : undefined].filter(Boolean).join(' '))\n\n      if (state.isSpinning) {\n        stopSpinner(text)\n        return\n      }\n      clack.log.success(text)\n    })\n\n    context.hook('kubb:warn', ({ message, info }) => {\n      if (logLevel < logLevelMap.warn) {\n        return\n      }\n\n      const text = getMessage(\n        [styleText('yellow', '⚠'), message, logLevel >= logLevelMap.info && info ? styleText('dim', info) : undefined].filter(Boolean).join(' '),\n      )\n\n      clack.log.warn(text)\n    })\n\n    context.hook('kubb:error', ({ error }) => {\n      const text = [styleText('red', '✗'), error.message].join(' ')\n\n      if (state.isSpinning) {\n        stopSpinner(getMessage(text))\n        return\n      }\n      clack.log.error(getMessage(text))\n\n      const frames = logLevel >= logLevelMap.verbose ? formatErrorFrames(error) : null\n      if (frames) {\n        for (const frame of frames.frames) {\n          clack.log.message(getMessage(styleText('dim', frame)))\n        }\n\n        if (frames.cause) {\n          clack.log.message(styleText('dim', frames.cause.header))\n\n          for (const frame of frames.cause.frames) {\n            clack.log.message(getMessage(`    ${styleText('dim', frame)}`))\n          }\n        }\n      }\n    })\n\n    context.hook('kubb:diagnostic', ({ diagnostic }) => {\n      // Silent still surfaces errors so failures stay visible. It drops warnings and info.\n      if (logLevel <= logLevelMap.silent && diagnostic.severity !== 'error') {\n        return\n      }\n\n      stopSpinner()\n\n      // Stop any lingering progress UI so the multi-line block renders cleanly.\n      stopActiveProgress()\n\n      // The version-update notice keeps its own framed box instead of the diagnostic gutter.\n      if (Diagnostics.isUpdate(diagnostic)) {\n        clack.box(\n          `\\`v${diagnostic.currentVersion}\\` → \\`v${diagnostic.latestVersion}\\`\nRun \\`npm install -g @kubb/cli\\` to update`,\n          'Update available for `Kubb`',\n          {\n            width: 'auto',\n            formatBorder: (s: string) => styleText('yellow', s),\n            rounded: true,\n            withGuide: false,\n            contentAlign: 'center',\n            titleAlign: 'center',\n          },\n        )\n\n        return\n      }\n\n      // The diagnostic carries the code and its own indented detail rows, so clear clack's\n      // gutter and bar (`symbol`/`secondarySymbol`) and let the block stand on its own.\n      const { headline, details } = Diagnostics.format(diagnostic)\n      clack.log.message([headline, ...details], { symbol: '', secondarySymbol: '' })\n    })\n\n    // A `kubb studio` session emits these on the same emitter as its generations, so one logger\n    // renders the whole command. The socket opens without being awaited, hence the spinner.\n    context.hook('studio:connecting', ({ url }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      state.spinner = clack.spinner()\n      state.spinner.start(getMessage(`Connecting to ${styleText('cyan', url)}`))\n      state.isSpinning = true\n    })\n\n    context.hook('studio:connected', ({ url, versions }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      const text = getMessage(`Connected to ${styleText('cyan', url)} ${styleText('dim', `(${formatVersions(versions)})`)}`)\n\n      if (state.isSpinning) {\n        stopSpinner(text)\n        return\n      }\n      clack.log.success(text)\n    })\n\n    context.hook('studio:disconnected', ({ reason }) => {\n      if (logLevel < logLevelMap.warn) {\n        return\n      }\n\n      stopSpinner()\n      clack.log.warn(getMessage(`Kubb Studio ended the session (${reason})`))\n    })\n\n    context.hook('studio:command:start', ({ command }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      clack.log.info(getMessage(`Kubb Studio asked to ${styleText('bold', command)}`))\n    })\n\n    context.hook('studio:command:end', ({ command, info }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      clack.log.success(getMessage(`Finished ${command}${info ? ` ${styleText('dim', `(${info})`)}` : ''}`))\n    })\n\n    context.hook('studio:warn', ({ message }) => {\n      if (logLevel < logLevelMap.warn) {\n        return\n      }\n\n      clack.log.warn(getMessage(message))\n    })\n\n    // Unguarded, like `kubb:error`: a failure stays visible even at silent.\n    context.hook('studio:error', ({ error }) => {\n      const text = getMessage([styleText('red', '✗'), error.message].join(' '))\n\n      if (state.isSpinning) {\n        stopSpinner(text)\n        return\n      }\n      clack.log.error(text)\n    })\n\n    context.hook('kubb:lifecycle:start', async ({ version }) => {\n      console.log(`\\n${getIntro({ title: 'The meta framework for code generation', description: 'Ready to start', version, areEyesOpen: true })}\\n`)\n\n      reset()\n    })\n\n    context.hook('kubb:generation:start', ({ config }) => {\n      reset()\n\n      // Initialize progress tracking for this generation\n      state.totalPlugins = config.plugins?.length ?? 0\n\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      const text = getMessage(\n        ['Generation started', config.name ? `for ${styleText('dim', config.name)}` : undefined, getInputPath(config)].filter(Boolean).join(' '),\n      )\n\n      clack.intro(text)\n    })\n\n    // Plugins run concurrently, so they share a single progress bar. A bar per plugin\n    // would make clack render them side by side and pile up keypress listeners.\n    context.hook('kubb:plugin:start', ({ plugin }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      stopSpinner()\n\n      state.runningPlugins.add(plugin.name)\n\n      const active = state.activeProgress.get('plugins')\n      if (active) {\n        active.progressBar.advance(0, pluginProgressText())\n        return\n      }\n\n      const progressBar = clack.progress({\n        style: 'block',\n        max: Math.max(state.totalPlugins, 1),\n        size: 30,\n      })\n      progressBar.start(pluginProgressText())\n      // Catch up to plugins already finished before this bar opened.\n      progressBar.advance(state.completedPlugins + state.failedPlugins, pluginProgressText())\n      state.activeProgress.set('plugins', { progressBar })\n    })\n\n    context.hook('kubb:plugin:end', ({ plugin, success }) => {\n      stopSpinner()\n\n      const active = state.activeProgress.get('plugins')\n\n      if (!active || logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      state.runningPlugins.delete(plugin.name)\n      recordPluginResult(state, success)\n      active.progressBar.advance(1, pluginProgressText())\n\n      // Close the bar once nothing is generating, then print the progress step.\n      if (state.runningPlugins.size === 0) {\n        active.progressBar.stop(getMessage('Plugins generated'))\n        state.activeProgress.delete('plugins')\n        showProgressStep()\n      }\n    })\n\n    context.hook('kubb:files:processing:start', ({ files }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      stopSpinner()\n\n      state.totalFiles = files.length\n      state.processedFiles = 0\n\n      const text = `Writing ${files.length} files`\n      const progressBar = clack.progress({\n        style: 'block',\n        max: files.length,\n        size: 30,\n      })\n\n      context.callHook('kubb:info', { message: text })\n      progressBar.start(getMessage(text))\n      state.activeProgress.set('files', { progressBar })\n    })\n\n    context.hook('kubb:files:processing:update', ({ files }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      stopSpinner()\n\n      const active = state.activeProgress.get('files')\n      for (const { file, config } of files) {\n        state.processedFiles++\n        if (active) {\n          active.progressBar.advance(undefined, `Writing ${relative(config.root, file.path)}`)\n        }\n      }\n    })\n    context.hook('kubb:files:processing:end', () => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      stopSpinner()\n\n      const text = getMessage('Files written successfully')\n      const active = state.activeProgress.get('files')\n\n      if (!active) {\n        return\n      }\n\n      active.progressBar.stop(text)\n      state.activeProgress.delete('files')\n\n      // Show final progress step after files are written\n      showProgressStep()\n    })\n\n    context.hook('kubb:generation:end', ({ config }) => {\n      stopSpinner()\n\n      const text = getMessage(config.name ? `Generation completed for ${styleText('dim', config.name)}` : 'Generation completed')\n\n      clack.outro(text)\n    })\n\n    onStep('kubb:format:start', 'Formatting')\n    onStep('kubb:lint:start', 'Linting')\n    onStep('kubb:hooks:start', 'Running hooks')\n\n    context.hook('kubb:hook:start', ({ id, command, name, args }) => {\n      if (logLevel <= logLevelMap.silent || !id) {\n        return\n      }\n\n      stopSpinner()\n\n      const commandWithArgs = formatCommandWithArgs(command, args)\n      const title = getMessage(`Running ${styleText('dim', name ?? commandWithArgs)}`)\n      const taskLog = clack.taskLog({ title })\n\n      state.activeHookLogs.set(id, { taskLog, hrStart: process.hrtime() })\n    })\n\n    // Registered only when not silent, so its presence is what tells the runner to stream\n    // (`kubb:hook:line` listenerCount). At silent level the listener is absent, so no streaming happens.\n    if (logLevel > logLevelMap.silent) {\n      context.hook('kubb:hook:line', ({ id, line }) => {\n        const active = state.activeHookLogs.get(id)\n        active?.taskLog.message(styleText('dim', line))\n      })\n    }\n\n    context.hook('kubb:hook:end', ({ id, command, name, args, success, error, stdout, stderr }) => {\n      if (!id) {\n        return\n      }\n\n      if (logLevel <= logLevelMap.silent) {\n        // Even when silent, surface a failed hook's captured output.\n        if (!success) {\n          if (stdout) console.log(stdout)\n          if (stderr) console.error(stderr)\n        }\n        return\n      }\n\n      const active = state.activeHookLogs.get(id)\n      if (!active) {\n        return\n      }\n      state.activeHookLogs.delete(id)\n\n      const commandWithArgs = formatCommandWithArgs(command, args)\n      const duration = formatMsWithColor(getElapsedMs(active.hrStart))\n\n      if (success) {\n        active.taskLog.success(getMessage(`${styleText('dim', name ?? commandWithArgs)} completed in ${duration}`))\n      } else {\n        // The hook's output already reached the taskLog live via `kubb:hook:line`, so `showLog`\n        // replays it here. `kubb:hook:end` carries no captured output on the streaming path.\n        const reason = error?.message ? ` (${error.message})` : ''\n        active.taskLog.error(getMessage(`${styleText('dim', name ?? commandWithArgs)} failed${reason}`), { showLog: true })\n      }\n    })\n\n    context.hook('kubb:lifecycle:end', () => {\n      reset()\n    })\n  },\n} satisfies Logger\n","import { relative } from 'node:path'\nimport { formatMs } from '@internals/utils'\nimport { Diagnostics, type KubbHooks, logLevel as logLevelMap } from '@kubb/core'\nimport type { Logger } from './defineLogger.ts'\nimport { createHookTimer, formatCommandWithArgs, formatErrorFrames, formatMessage, formatVersions, getInputPath } from './utils.ts'\n\n/**\n * Plain console adapter for non-TTY environments, built on `console.log`.\n */\nexport const plainLogger = {\n  name: 'plain',\n  install(context, options) {\n    const logLevel = options?.logLevel ?? logLevelMap.info\n    const hookTimer = createHookTimer()\n\n    function getMessage(message: string): string {\n      return formatMessage(message, logLevel)\n    }\n\n    // Registers a handler that logs a fixed message, skipped at silent level.\n    function onStep<E extends keyof KubbHooks>(hook: E, message: string): void {\n      context.hook(hook, () => {\n        if (logLevel <= logLevelMap.silent) {\n          return\n        }\n        console.log(getMessage(message))\n      })\n    }\n\n    context.hook('kubb:info', ({ message, info }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      const text = getMessage(['ℹ', message, info].join(' '))\n\n      console.log(text)\n    })\n\n    context.hook('kubb:success', ({ message, info = '' }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      const text = getMessage(['✓', message, logLevel >= logLevelMap.info ? info : undefined].filter(Boolean).join(' '))\n\n      console.log(text)\n    })\n\n    context.hook('kubb:warn', ({ message, info }) => {\n      if (logLevel < logLevelMap.warn) {\n        return\n      }\n\n      const text = getMessage(['⚠', message, logLevel >= logLevelMap.info ? info : undefined].filter(Boolean).join(' '))\n\n      console.log(text)\n    })\n\n    context.hook('kubb:error', ({ error }) => {\n      const text = getMessage(['✗', error.message].join(' '))\n\n      console.log(text)\n\n      const frames = logLevel >= logLevelMap.verbose ? formatErrorFrames(error) : null\n      if (frames) {\n        for (const frame of frames.frames) {\n          console.log(getMessage(frame))\n        }\n\n        if (frames.cause) {\n          console.log(frames.cause.header)\n\n          for (const frame of frames.cause.frames) {\n            console.log(getMessage(`    ${frame}`))\n          }\n        }\n      }\n    })\n\n    context.hook('kubb:diagnostic', ({ diagnostic }) => {\n      // Silent still surfaces errors so failures stay visible. It drops warnings and info.\n      if (logLevel <= logLevelMap.silent && diagnostic.severity !== 'error') {\n        return\n      }\n      console.log(getMessage(Diagnostics.formatLines(diagnostic).join('\\n')))\n    })\n\n    // A `kubb studio` session emits these on the same emitter as its generations, so one logger\n    // renders the whole command. Nothing to animate here, so no spinner.\n    context.hook('studio:connecting', ({ url }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n      console.log(getMessage(`Connecting to ${url}`))\n    })\n\n    context.hook('studio:connected', ({ url, versions }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n      console.log(getMessage(`✓ Connected to ${url} (${formatVersions(versions)})`))\n    })\n\n    context.hook('studio:disconnected', ({ reason }) => {\n      if (logLevel < logLevelMap.warn) {\n        return\n      }\n      console.log(getMessage(`⚠ Kubb Studio ended the session (${reason})`))\n    })\n\n    context.hook('studio:command:start', ({ command }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n      console.log(getMessage(`Kubb Studio asked to ${command}`))\n    })\n\n    context.hook('studio:command:end', ({ command, info }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n      console.log(getMessage(`✓ Finished ${command}${info ? ` (${info})` : ''}`))\n    })\n\n    context.hook('studio:warn', ({ message }) => {\n      if (logLevel < logLevelMap.warn) {\n        return\n      }\n      console.log(getMessage(`⚠ ${message}`))\n    })\n\n    // Unguarded, like `kubb:error`: a failure stays visible even at silent.\n    context.hook('studio:error', ({ error }) => {\n      console.log(getMessage(`✗ ${error.message}`))\n    })\n\n    context.hook('kubb:lifecycle:start', ({ version }) => {\n      console.log(`Kubb CLI v${version}`)\n    })\n\n    context.hook('kubb:generation:start', ({ config }) => {\n      const text = getMessage(['Generation started', getInputPath(config)].filter(Boolean).join(' '))\n\n      console.log(text)\n    })\n\n    context.hook('kubb:plugin:start', ({ plugin }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n      const text = getMessage(`Generating ${plugin.name}`)\n\n      console.log(text)\n    })\n\n    context.hook('kubb:plugin:end', ({ plugin, duration, success }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      const durationStr = formatMs(duration)\n      const text = getMessage(success ? `${plugin.name} completed in ${durationStr}` : `${plugin.name} failed in ${durationStr}`)\n\n      console.log(text)\n    })\n\n    context.hook('kubb:files:processing:start', ({ files }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      const text = getMessage(`Writing ${files.length} files`)\n\n      console.log(text)\n    })\n\n    context.hook('kubb:files:processing:update', ({ files }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      for (const { file, config } of files) {\n        console.log(getMessage(`Writing ${relative(config.root, file.path)}`))\n      }\n    })\n\n    context.hook('kubb:files:processing:end', () => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      const text = getMessage('Files written successfully')\n\n      console.log(text)\n    })\n\n    context.hook('kubb:generation:end', ({ config }) => {\n      const text = getMessage(config.name ? `Generation completed for ${config.name}` : 'Generation completed')\n\n      console.log(text)\n    })\n\n    onStep('kubb:format:start', 'Format started')\n    onStep('kubb:format:end', 'Format completed')\n    onStep('kubb:lint:start', 'Lint started')\n    onStep('kubb:lint:end', 'Lint completed')\n    onStep('kubb:hooks:start', 'Hooks started')\n    onStep('kubb:hooks:end', 'Hooks completed')\n\n    context.hook('kubb:hook:start', ({ id, command, name, args }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      if (id) {\n        hookTimer.start(id)\n      }\n\n      const commandWithArgs = formatCommandWithArgs(command, args)\n      console.log(getMessage(`Hook ${name ?? commandWithArgs} started`))\n    })\n\n    context.hook('kubb:hook:end', ({ id, command, name, args, success, error, stdout, stderr }) => {\n      if (logLevel <= logLevelMap.silent) {\n        return\n      }\n\n      const ms = id ? hookTimer.end(id) : undefined\n      const durationStr = ms !== undefined ? ` in ${formatMs(ms)}` : ''\n\n      const commandWithArgs = formatCommandWithArgs(command, args)\n\n      if (success) {\n        console.log(getMessage(`✓ Hook ${name ?? commandWithArgs} completed${durationStr}`))\n      } else {\n        if (stdout) console.log(stdout)\n        if (stderr) console.error(stderr)\n        const reason = error?.message ? ` (${error.message})` : ''\n        console.log(getMessage(`✗ Hook ${name ?? commandWithArgs} failed${durationStr}${reason}`))\n      }\n    })\n  },\n} satisfies Logger\n","import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { formatMs, getElapsedMs } from '@internals/utils'\nimport type { Config, Reporter, ReporterContext } from '@kubb/core'\nimport { logLevel as logLevelMap } from '@kubb/core'\nimport type { StudioConnectedContext } from '@kubb/studio'\nimport { getAgentName } from '../agent.ts'\nimport { canUseTTY } from '../utils/env.ts'\nimport type { LoggerContext, LoggerOptions } from './defineLogger.ts'\nimport { clackLogger } from './clackLogger.ts'\nimport { plainLogger } from './plainLogger.ts'\n\n/**\n * Display path for a config's input: the string form, or its `path` field when the input is an\n * object. Loggers show it alongside `Generation started`.\n */\nexport function getInputPath(config: Config): string | undefined {\n  const { input } = config\n  if (typeof input === 'string') return input\n  return typeof input?.path === 'string' ? input.path : undefined\n}\n\n/**\n * Optionally prefix a message with a [HH:MM:SS] timestamp when logLevel >= verbose.\n * Shared across all logger adapters to avoid duplication.\n */\nexport function formatMessage(message: string, logLevel: number): string {\n  if (logLevel >= logLevelMap.verbose) {\n    const timestamp = new Date().toLocaleTimeString('en-US', {\n      hour12: false,\n      hour: '2-digit',\n      minute: '2-digit',\n      second: '2-digit',\n    })\n    return `${styleText('dim', `[${timestamp}]`)} ${message}`\n  }\n  return message\n}\n\n/**\n * Renders the versions from a `studio:connected` event as one parenthetical. The runtime is listed\n * only when it differs from the host, and Studio's only when it sent one.\n */\nexport function formatVersions({ studio, kubb, agent }: StudioConnectedContext['versions']): string {\n  return [`v${agent}`, kubb !== agent ? `runtime v${kubb}` : undefined, studio ? `Studio v${studio}` : undefined].filter(Boolean).join(', ')\n}\n\n/**\n * Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.\n */\nfunction toCause(error: Error): Error | undefined {\n  return error.cause instanceof Error ? error.cause : undefined\n}\n\n/**\n * First stack frames for verbose error output, including an optional `cause` chain.\n */\nexport function formatErrorFrames(error: Error): { frames: Array<string>; cause?: { header: string; frames: Array<string> } } | null {\n  if (!error.stack) {\n    return null\n  }\n\n  const frames = error.stack\n    .split('\\n')\n    .slice(1, 4)\n    .map((frame) => frame.trim())\n  const caused = toCause(error)\n\n  if (!caused?.stack) {\n    return { frames }\n  }\n\n  return {\n    frames,\n    cause: {\n      header: `└─ caused by ${caused.message}`,\n      frames: caused.stack\n        .split('\\n')\n        .slice(1, 4)\n        .map((frame) => frame.trim()),\n    },\n  }\n}\n\ntype ProgressState = {\n  /**\n   * Total number of plugins scheduled for this generation run.\n   */\n  totalPlugins: number\n  /**\n   * Number of plugins that have finished without error.\n   */\n  completedPlugins: number\n  /**\n   * Number of plugins that exited with an error.\n   */\n  failedPlugins: number\n  /**\n   * Total number of files expected to be written.\n   */\n  totalFiles: number\n  /**\n   * Number of files written so far.\n   */\n  processedFiles: number\n  /**\n   * `process.hrtime()` snapshot taken at the start of generation, used to compute elapsed time.\n   */\n  hrStart: [number, number]\n}\n\n/**\n * Build the progress summary line shown by the clack logger.\n * Returns null when there is nothing to display.\n */\nexport function buildProgressLine(state: ProgressState): string | null {\n  const parts: Array<string> = []\n  const duration = formatMs(getElapsedMs(state.hrStart))\n\n  if (state.totalPlugins > 0) {\n    const pluginStr =\n      state.failedPlugins > 0\n        ? `Plugins ${styleText('green', state.completedPlugins.toString())}/${state.totalPlugins} ${styleText('red', `(${state.failedPlugins} failed)`)}`\n        : `Plugins ${styleText('green', state.completedPlugins.toString())}/${state.totalPlugins}`\n    parts.push(pluginStr)\n  }\n\n  if (state.totalFiles > 0) {\n    parts.push(`Files ${styleText('green', state.processedFiles.toString())}/${state.totalFiles}`)\n  }\n\n  if (parts.length === 0) {\n    return null\n  }\n\n  parts.push(`${styleText('green', duration)} elapsed`)\n  return parts.join(styleText('dim', ' | '))\n}\n\n/**\n * Creates the per-run progress counters used by the clack logger.\n */\nexport function createProgressCounters(): ProgressState {\n  return {\n    totalPlugins: 0,\n    completedPlugins: 0,\n    failedPlugins: 0,\n    totalFiles: 0,\n    processedFiles: 0,\n    hrStart: process.hrtime(),\n  }\n}\n\n/**\n * Resets the progress counters in place at the start/end of a generation run.\n */\nexport function resetProgressCounters(state: ProgressState): void {\n  state.totalPlugins = 0\n  state.completedPlugins = 0\n  state.failedPlugins = 0\n  state.totalFiles = 0\n  state.processedFiles = 0\n  state.hrStart = process.hrtime()\n}\n\n/**\n * Records a finished plugin against the progress counters.\n */\nexport function recordPluginResult(state: ProgressState, success: boolean): void {\n  if (success) {\n    state.completedPlugins++\n  } else {\n    state.failedPlugins++\n  }\n}\n\n/**\n * Tracks per-hook start times so a logger can report a hook's elapsed duration.\n * Used by the plain logger, which keys timing by hook `id`.\n */\ntype HookTimer = {\n  start(id: string): void\n  /**\n   * Returns the elapsed milliseconds since `start(id)`, or `undefined` when no start was recorded.\n   */\n  end(id: string): number | undefined\n}\n\n/**\n * Creates a {@link HookTimer} backed by a private `id → hrtime` map.\n */\nexport function createHookTimer(): HookTimer {\n  const starts = new Map<string, [number, number]>()\n\n  return {\n    start(id: string): void {\n      starts.set(id, process.hrtime())\n    },\n    end(id: string): number | undefined {\n      const hrStart = starts.get(id)\n      if (!hrStart) {\n        return undefined\n      }\n      starts.delete(id)\n      return getElapsedMs(hrStart)\n    },\n  }\n}\n\n/**\n * Join a command and its optional args into a single display string.\n *\n * @example With args\n * `formatCommandWithArgs('prettier', ['--write', '.'])` returns `'prettier --write .'`\n */\nexport function formatCommandWithArgs(command: string, args?: ReadonlyArray<string>): string {\n  return args?.length ? `${command} ${args.join(' ')}` : command\n}\n\n/**\n * Bridges a {@link Reporter} onto the run's hook emitter: calls `report` with each config's\n * {@link GenerationResult} on `kubb:generation:end`. The reporter never touches the emitter.\n */\nexport function installReporter(context: LoggerContext, reporter: Reporter, ctx: ReporterContext): void {\n  context.hook('kubb:generation:end', async ({ config, diagnostics = [], filesCreated = 0, status = 'success', hrStart = process.hrtime() }) => {\n    await reporter.report({ config, diagnostics, filesCreated, status, hrStart }, ctx)\n  })\n\n  if (reporter.drain) {\n    context.hook('kubb:lifecycle:end', () => reporter.drain?.(ctx))\n  }\n}\n\n/**\n * Installs the live logger (the TUI view) and the given reporters (the output). The reporters are\n * already selected by the caller (the CLI maps `--reporter` to names via `selectReporters`). This\n * only wires them. Loggers receive hook subprocess output through `kubb:hook:line` and the\n * `stdout`/`stderr` on `kubb:hook:end`, so nothing is returned here.\n *\n * Loggers and reporters are independent, except for `cli`: it both installs the live logger view\n * here and registers as a reporter that prints the per-config summary. The `json` reporter owns\n * stdout, so the whole `cli` reporter (live logger and summary) is skipped whenever `json` is\n * among the reporters, even if `cli` is also listed.\n */\nasync function setupReporters(context: LoggerContext, { logLevel, reporters }: LoggerOptions & { reporters: ReadonlyArray<Reporter> }): Promise<void> {\n  const hasJson = reporters.some((reporter) => reporter.name === 'json')\n  const ctx: ReporterContext = { logLevel }\n\n  for (const reporter of reporters) {\n    if (reporter.name === 'cli') {\n      if (hasJson) {\n        continue\n      }\n      // Spinners and cursor-movement escapes are hard for an AI coding agent to parse, even over a pseudo-TTY.\n      const logger = canUseTTY() && !getAgentName() ? clackLogger : plainLogger\n      await logger.install(context, { logLevel })\n    }\n\n    installReporter(context, reporter, ctx)\n  }\n}\n\nexport default setupReporters\n\n/**\n * Picks the reporters whose `name` matches one of `names`, in the order the names are given.\n * The config carries every available reporter, and the host selects which to activate by name\n * (the CLI maps `--reporter` to this). Duplicate names and names without a matching reporter are\n * skipped.\n */\nexport function selectReporters(reporters: ReadonlyArray<Reporter>, names: ReadonlyArray<string>): Array<Reporter> {\n  const seen = new Set<string>()\n  const selected: Array<Reporter> = []\n\n  for (const name of names) {\n    if (seen.has(name)) {\n      continue\n    }\n    seen.add(name)\n\n    const reporter = reporters.find((candidate) => candidate.name === name)\n    if (reporter) {\n      selected.push(reporter)\n    }\n  }\n\n  return selected\n}\n","import { createJiti } from 'jiti'\n\n/**\n * jiti options for loading Kubb config modules: the automatic JSX runtime pointed at\n * `@kubb/renderer-jsx`, and `moduleCache` off so a re-load re-evaluates the file.\n */\nconst JITI_OPTIONS = {\n  jsx: { runtime: 'automatic', importSource: '@kubb/renderer-jsx' },\n  moduleCache: false,\n} satisfies Parameters<typeof createJiti>[1]\n\n/**\n * Per-call options for {@link ModuleLoader.load}.\n */\ntype LoadModuleOptions = {\n  /**\n   * Return the module's default export instead of the full namespace.\n   */\n  default?: boolean\n}\n\n/**\n * Loads `.ts`/`.js` modules via jiti.\n */\ntype ModuleLoader = {\n  load<T = unknown>(filePath: string, options?: LoadModuleOptions): Promise<T>\n}\n\n/**\n * Creates a jiti-based loader for Kubb's TypeScript and JavaScript config modules.\n *\n * jiti transpiles TypeScript and the `@kubb/renderer-jsx` JSX runtime on the fly.\n *\n * @example\n * ```ts\n * const config = await createModuleLoader().load('/abs/kubb.config.ts', { default: true })\n * ```\n */\nexport function createModuleLoader(): ModuleLoader {\n  const jiti = createJiti(import.meta.url, JITI_OPTIONS)\n\n  return {\n    load<T>(filePath: string, options?: LoadModuleOptions) {\n      return (options?.default ? jiti.import(filePath, { default: true }) : jiti.import(filePath)) as Promise<T>\n    },\n  }\n}\n","import { randomUUID } from 'node:crypto'\nimport { basename, dirname, resolve } from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { createModuleLoader } from '@internals/shared'\nimport { toError, tokenize } from '@internals/utils'\nimport type { CLIOptions, Config, KubbHooks, PossibleConfig, PostGenerateCommand, Hookable } from '@kubb/core'\nimport { NonZeroExitError, x } from 'tinyexec'\nimport { type LoadConfigResult, type LoadConfigSource, loadConfig } from 'unconfig'\nimport { isGreater, isValid, truncate } from 'verkit'\nimport { URL_WATCHER_INTERVAL_MS, URL_WATCHER_TIMEOUT_MS, WATCHER_DEBOUNCE_MS, WATCHER_IGNORED_PATHS } from '../../constants.ts'\n\nconst loader = createModuleLoader()\n\n// Kubb configs are JS/TS modules (they call `defineConfig`/`pluginX()`), so YAML and JSON are not\n// supported. The jiti loader handles every module format and the JSX runtime, returning the default export.\nconst tsLoader = (configFile: string) => loader.load(configFile, { default: true })\n\nconst MODULE_NAME = 'kubb'\n\nconst SEARCH_FILES = ['', '.config/', 'configs/'].flatMap((prefix) => [`${prefix}.${MODULE_NAME}rc`, `${prefix}${MODULE_NAME}.config`])\nconst SEARCH_EXTENSIONS = ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs']\n\ntype GetConfigsOptions = {\n  /**\n   * Explicit path to the Kubb config file. When omitted, the loader searches up from the current directory.\n   */\n  configPath?: string\n  /**\n   * Optional OpenAPI input path or URL that overrides `config.input` for this run.\n   */\n  input?: string\n  /**\n   * Watch flag forwarded to the user's `defineConfig` function.\n   */\n  watch?: boolean\n  /**\n   * Log level forwarded to the user's `defineConfig` function.\n   */\n  logLevel?: CLIOptions['logLevel']\n}\n\ntype GetConfigsResult = {\n  /**\n   * Absolute path to the resolved config file.\n   */\n  configPath: string\n  /**\n   * Resolved and normalized array of Kubb configs, each guaranteed to have a `plugins` array.\n   */\n  configs: Array<Config>\n}\n\n/**\n * Discovers the Kubb config and resolves it into a normalized array of configs.\n * Every config in the result is guaranteed to have a `plugins` array.\n */\nexport async function getConfigs({ configPath, input, watch, logLevel }: GetConfigsOptions): Promise<GetConfigsResult> {\n  const abs = configPath ? resolve(configPath) : undefined\n  const sources: Array<LoadConfigSource<unknown>> = abs\n    ? [{ files: [basename(abs)], extensions: [], parser: tsLoader }]\n    : [{ files: SEARCH_FILES, extensions: SEARCH_EXTENSIONS, parser: tsLoader }]\n\n  let result: LoadConfigResult<unknown>\n  try {\n    result = await loadConfig<unknown>({ cwd: abs ? dirname(abs) : process.cwd(), sources, merge: false })\n  } catch (error) {\n    throw new Error('Config failed loading', { cause: error })\n  }\n\n  const [filepath] = result.sources\n  if (!result.config || !filepath) {\n    throw new Error('Config not defined, create a kubb.config.js or pass through your config with the option --config')\n  }\n\n  const config = result.config as PossibleConfig<CLIOptions>\n  const cli: CLIOptions = { config: configPath, input, watch, logLevel }\n  const resolved = await (typeof config === 'function' ? config(cli) : config)\n  const userConfigs = Array.isArray(resolved) ? resolved : [resolved]\n\n  return {\n    configPath: filepath,\n    configs: userConfigs.map((item) => {\n      const config: Config = { ...item, plugins: item.plugins ?? [] }\n      return config\n    }),\n  }\n}\n\ntype RunPostGenerateOptions = {\n  commands: Array<PostGenerateCommand>\n  hooks: Hookable<KubbHooks>\n}\n\n/**\n * Outcome of a single hook subprocess, returned by `runHook` alongside the\n * `kubb:hook:end` hook it emits for the loggers.\n */\ntype HookResult = {\n  /**\n   * `true` when the command exited with code `0`.\n   */\n  success: boolean\n  /**\n   * What went wrong, `null` when the command succeeded.\n   */\n  error: Error | null\n  /**\n   * Captured stdout, only present on a non-zero exit.\n   */\n  stdout?: string\n  /**\n   * Captured stderr, only present on a non-zero exit.\n   */\n  stderr?: string\n}\n\n/**\n * Returns `true` when `latest` is a newer semver version than `current`. Compares each numeric\n * part, so `5.10.0` beats `5.9.0` where a plain string comparison would not. Prerelease\n * suffixes are ignored, and a malformed version never reports an update.\n *\n * @example Double-digit minor\n * `isNewerVersion('5.9.0', '5.10.0') // true`\n *\n * @example String comparison would get this wrong the other way\n * `isNewerVersion('5.10.0', '5.9.0') // false`\n */\nexport function isNewerVersion(current: string, latest: string): boolean {\n  if (!isValid(current) || !isValid(latest)) return false\n\n  return isGreater(truncate(latest, 'patch') as string, truncate(current, 'patch') as string)\n}\n\n/**\n * Runs the `output.postGenerate` commands of a Kubb config in sequence and returns each command's\n * outcome, so the caller can turn failures into diagnostics.\n */\nexport async function runPostGenerate({ commands, hooks }: RunPostGenerateOptions): Promise<Array<HookResult>> {\n  const results: Array<HookResult> = []\n\n  for (const entry of commands) {\n    const { command, name } = typeof entry === 'string' ? { command: entry, name: undefined } : entry\n    const [cmd, ...args] = tokenize(command)\n    if (!cmd) continue\n\n    const hookId = randomUUID()\n    const commandWithArgs = [cmd, ...args].join(' ')\n\n    await hooks.callHook('kubb:hook:start', { id: hookId, command: cmd, name, args })\n    results.push(await runHook({ id: hookId, command: cmd, name, args, commandWithArgs, hooks }))\n  }\n\n  return results\n}\n\ntype RunHookOptions = {\n  id: string\n  command: string\n  name?: string\n  args?: ReadonlyArray<string>\n  commandWithArgs: string\n  hooks: Hookable<KubbHooks>\n}\n\n/**\n * Spawns a hook command and returns its outcome, mirroring it through `kubb:hook:end` for the\n * loggers. A non-zero exit returns `success: false` rather than throwing, so the caller can turn\n * it into a diagnostic. Other spawn errors do the same. Output is streamed through `kubb:hook:line`\n * only while a listener is attached.\n */\nexport async function runHook({ id, command, name, args, commandWithArgs, hooks }: RunHookOptions): Promise<HookResult> {\n  const emitEnd = async (result: HookResult): Promise<HookResult> => {\n    await hooks.callHook('kubb:hook:end', { command, name, args, id, ...result })\n    return result\n  }\n\n  // Only stream line-by-line when a logger is listening, so the non-streaming plain\n  // logger doesn't pay to iterate the subprocess output.\n  const stream = hooks.listenerCount('kubb:hook:line') > 0\n\n  try {\n    const proc = x(command, [...(args ?? [])], {\n      nodeOptions: { detached: process.platform !== 'win32' },\n      throwOnError: true,\n    })\n\n    if (stream) {\n      for await (const line of proc) {\n        await hooks.callHook('kubb:hook:line', { id, line })\n      }\n    }\n\n    await proc\n    await hooks.callHook('kubb:success', { message: `${styleText('dim', name ?? commandWithArgs)} successfully executed` })\n    return emitEnd({ success: true, error: null })\n  } catch (err) {\n    if (!(err instanceof NonZeroExitError)) {\n      return emitEnd({ success: false, error: toError(err) })\n    }\n\n    const stderr = err.output?.stderr ?? ''\n    const stdout = err.output?.stdout ?? ''\n\n    const error = new Error(`Hook execute failed: ${commandWithArgs}`)\n    // Signal the failure via the result and `kubb:hook:end` only, carrying the captured output so\n    // the logger can render it. The caller turns this into a coded diagnostic and emits that\n    // through `Diagnostics.emit`, so emitting `kubb:error` here would render it twice.\n    return emitEnd({ success: false, error, stdout, stderr })\n  }\n}\n\ntype SerialRunnerOptions = {\n  /**\n   * The async work to serialize.\n   */\n  run(): Promise<void>\n  /**\n   * Receives errors thrown by `run`, so a failure never rejects the returned trigger.\n   */\n  onError(error: Error): void\n}\n\n/**\n * Wraps `run` so invocations never overlap: a trigger that lands while a run is in flight\n * marks it dirty and runs once more after it finishes, no matter how many triggers arrived.\n * Useful for event-driven reruns (a file watcher, a queue drain) where bursts should\n * coalesce into a single trailing run.\n *\n * @example\n * ```ts\n * const rebuild = createSerialRunner({\n *   run: () => build(),\n *   onError: (error) => log.error(error.message),\n * })\n * watcher.on('change', () => void rebuild())\n * ```\n */\nexport function createSerialRunner({ run, onError }: SerialRunnerOptions): () => Promise<void> {\n  let running = false\n  let dirty = false\n\n  return async (): Promise<void> => {\n    if (running) {\n      dirty = true\n      return\n    }\n    running = true\n    do {\n      dirty = false\n      try {\n        await run()\n      } catch (error) {\n        onError(toError(error))\n      }\n    } while (dirty)\n    running = false\n  }\n}\n\ntype WatcherLog = {\n  info: (message: string) => void\n  error: (message: string) => void\n}\n\n/**\n * Starts a file watcher on the given paths and calls `cb` on any change.\n * Ignores `.git` and `node_modules` directories. Event bursts (an editor save emits several)\n * are debounced into one build, and builds never overlap: changes during a build queue exactly\n * one rebuild.\n */\nexport async function startWatcher(\n  path: Array<string>,\n  cb: (path: Array<string>) => Promise<void>,\n  log: WatcherLog = { info: console.log, error: console.log },\n): Promise<void> {\n  const { watch } = await import('chokidar')\n  // `ignoreInitial` skips the `add` events chokidar fires for existing files at startup, which\n  // would otherwise rebuild right after the initial run.\n  const watcher = watch(path, { ignorePermissionErrors: true, ignored: WATCHER_IGNORED_PATHS, ignoreInitial: true })\n\n  process.once('SIGINT', () => {\n    watcher.close()\n  })\n  process.once('SIGTERM', () => {\n    watcher.close()\n  })\n\n  // Bursts never overlap builds on the shared hooks emitter: a change during a build\n  // queues exactly one rerun.\n  const runBuild = createSerialRunner({\n    run: () => cb(path),\n    onError: () => log.error(styleText('red', 'Watcher failed')),\n  })\n  let debounceTimer: ReturnType<typeof setTimeout> | null = null\n\n  watcher.on('all', (type, file) => {\n    log.info(styleText('yellow', styleText('bold', `Change detected: ${type} ${file}`)))\n    if (debounceTimer) clearTimeout(debounceTimer)\n    debounceTimer = setTimeout(() => {\n      debounceTimer = null\n      void runBuild()\n    }, WATCHER_DEBOUNCE_MS)\n  })\n}\n\n/**\n * Fetches the body of a remote spec URL, `undefined` when the server does not answer with a\n * readable 2xx body within the timeout. The caller seeds `startUrlWatcher` with the result, so\n * the watcher compares polls against the content the initial build ran on.\n */\nexport async function fetchUrlBody(url: string, timeoutMs: number = URL_WATCHER_TIMEOUT_MS): Promise<string | undefined> {\n  try {\n    const response = await fetch(url, { signal: AbortSignal.timeout(timeoutMs) })\n    if (!response.ok) return undefined\n    return await response.text()\n  } catch {\n    return undefined\n  }\n}\n\ntype UrlWatcherOptions = {\n  /**\n   * Sink for watcher messages, `console.log` by default.\n   */\n  log?: WatcherLog\n  /**\n   * Time in milliseconds between polls.\n   */\n  intervalMs?: number\n  /**\n   * Upper bound in milliseconds for one poll request, covering headers and body read.\n   */\n  timeoutMs?: number\n  /**\n   * Body the initial build ran against, the baseline for change detection. When omitted (the\n   * server was unreachable at startup), the first successful poll rebuilds so the output catches\n   * up as soon as the server responds.\n   */\n  initialBody?: string\n}\n\n/**\n * Polls a remote spec URL and calls `cb` whenever the response body changes. A remote document\n * emits no filesystem events, so this is the URL counterpart of `startWatcher`.\n *\n * `initialBody` seeds the change detection, so an edit landing between the initial build and the\n * first poll still rebuilds. An unreachable server (the API restarting between saves) is reported\n * once per outage and polling continues; after it recovers, a rebuild happens only when the body\n * actually differs from the last one seen, so a plain restart with an unchanged spec stays quiet.\n * Each request is aborted after `timeoutMs`, so a hung response delays at most one poll.\n *\n * Returns a function that stops polling and aborts the in-flight request, so callers (and tests)\n * can shut the watcher down without signaling the process.\n */\nexport function startUrlWatcher(url: string, cb: (path: Array<string>) => Promise<void>, options: UrlWatcherOptions = {}): () => void {\n  const { log = { info: console.log, error: console.log }, intervalMs = URL_WATCHER_INTERVAL_MS, timeoutMs = URL_WATCHER_TIMEOUT_MS, initialBody } = options\n\n  let lastBody = initialBody\n  let offline = false\n  let timer: ReturnType<typeof setTimeout> | null = null\n  let controller: AbortController | null = null\n  let stopped = false\n\n  const stop = () => {\n    stopped = true\n    if (timer) clearTimeout(timer)\n    controller?.abort()\n  }\n  process.once('SIGINT', stop)\n  process.once('SIGTERM', stop)\n\n  // Builds never overlap on the shared hooks emitter: a change during a build queues exactly\n  // one rerun.\n  const runBuild = createSerialRunner({\n    run: () => cb([url]),\n    onError: () => log.error(styleText('red', 'Watcher failed')),\n  })\n\n  const poll = async (): Promise<void> => {\n    controller = new AbortController()\n    try {\n      // The signal also aborts the body read, so a response that stalls mid-stream still times out.\n      const signal = AbortSignal.any([controller.signal, AbortSignal.timeout(timeoutMs)])\n      const response = await fetch(url, { signal })\n      if (!response.ok) {\n        throw new Error(`HTTP ${response.status}`)\n      }\n      const body = await response.text()\n      if (offline) {\n        offline = false\n        log.info(styleText('yellow', `${url} is reachable again`))\n      }\n      const changed = lastBody !== undefined && body !== lastBody\n      if (changed) {\n        log.info(styleText('yellow', styleText('bold', `Change detected: ${url}`)))\n      }\n      if (changed || lastBody === undefined) {\n        void runBuild()\n      }\n      lastBody = body\n    } catch {\n      // `lastBody` survives the outage so recovery rebuilds only on real content changes.\n      if (!offline && !stopped) {\n        offline = true\n        log.error(styleText('red', `Cannot reach ${url}, polling until it responds again`))\n      }\n    }\n    if (!stopped) {\n      timer = setTimeout(() => void poll(), intervalMs)\n    }\n  }\n\n  void poll()\n\n  return stop\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAeA,MAAa,aAAa;CACxB,UAAU;EACR,SAAS;EACT,OAAO,eAAuB;GAAC;GAAoB;GAAW;EAAU;EACxE,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB;GAAC;GAAU;GAAW;EAAU;EAC9D,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB,CAAC,UAAU;EACzC,cAAc;CAChB;AACF;;;;AAKA,MAAa,UAAU;CACrB,QAAQ;EACN,SAAS;EACT,OAAO,eAAuB,CAAC,YAAY,OAAO;EAClD,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB;GAAC;GAAQ;GAAS;EAAU;EAC1D,cAAc;CAChB;CACA,QAAQ;EACN,SAAS;EAET,OAAO,eAAuB;GAAC;GAAS;GAAe;EAAU;EACjE,cAAc;CAChB;AACF;;;;;AAMA,MAAa,uBAAuB;CAAC;CAAS;CAAS;AAAU;;;;AAKjE,MAAa,oBAAoB;CAAC;CAAU;CAAS;AAAQ;;;;AAK7D,SAAgB,gBAAgB,MAAgC;CAC9D,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,SAAA,GAAQA,mBAAAA,MAAAA,CAAM,MAAM,CAAC,WAAW,GAAG,EAAE,OAAO,SAAS,CAAC;EAC5D,MAAM,GAAG,UAAU,SAAS,QAAQ,SAAS,CAAC,CAAC;EAC/C,MAAM,GAAG,eAAe,QAAQ,KAAK,CAAC;CACxC,CAAC;AACH;;;;;;;AAQ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