πŸ“„ File detail

utils/settings/allErrors.ts

🧩 .tsπŸ“ 33 linesπŸ’Ύ 1,257 bytesπŸ“ text
← Back to All Files

🎯 Use case

This file lives under β€œutils/”, which covers cross-cutting helpers (shell, tempfiles, settings, messages, process input, …). On the API surface it exposes getSettingsWithAllErrors β€” mainly functions, hooks, or classes. It composes internal code from services, settings, and validation (relative imports). What the file header says: Combines settings validation errors with MCP configuration errors. This module exists to break a circular dependency: settings.ts β†’ mcp/config.ts β†’ settings.ts By moving the MCP error aggregation here (a leaf that imports both settings.ts and mcp/config.ts, but is imported by nei.

Generated from folder role, exports, dependency roots, and inline comments β€” not hand-reviewed for every path.

🧠 Inline summary

Combines settings validation errors with MCP configuration errors. This module exists to break a circular dependency: settings.ts β†’ mcp/config.ts β†’ settings.ts By moving the MCP error aggregation here (a leaf that imports both settings.ts and mcp/config.ts, but is imported by neither), the cycle is eliminated.

πŸ“€ Exports (heuristic)

  • getSettingsWithAllErrors

πŸ–₯️ Source preview

/**
 * Combines settings validation errors with MCP configuration errors.
 *
 * This module exists to break a circular dependency:
 *   settings.ts β†’ mcp/config.ts β†’ settings.ts
 *
 * By moving the MCP error aggregation here (a leaf that imports both
 * settings.ts and mcp/config.ts, but is imported by neither), the cycle
 * is eliminated.
 */

import { getMcpConfigsByScope } from '../../services/mcp/config.js'
import { getSettingsWithErrors } from './settings.js'
import type { SettingsWithErrors } from './validation.js'

/**
 * Get merged settings with all validation errors, including MCP config errors.
 *
 * Use this instead of getSettingsWithErrors() when you need the full set of
 * errors (settings + MCP). The underlying getSettingsWithErrors() no longer
 * includes MCP errors to avoid the circular dependency.
 */
export function getSettingsWithAllErrors(): SettingsWithErrors {
  const result = getSettingsWithErrors()
  // 'dynamic' scope does not have errors returned; it throws and is set on cli startup
  const scopes = ['user', 'project', 'local'] as const
  const mcpErrors = scopes.flatMap(scope => getMcpConfigsByScope(scope).errors)
  return {
    settings: result.settings,
    errors: [...result.errors, ...mcpErrors],
  }
}