allErrors.ts
1 /** 2 * Combines settings validation errors with MCP configuration errors. 3 * 4 * This module exists to break a circular dependency: 5 * settings.ts → mcp/config.ts → settings.ts 6 * 7 * By moving the MCP error aggregation here (a leaf that imports both 8 * settings.ts and mcp/config.ts, but is imported by neither), the cycle 9 * is eliminated. 10 */ 11 12 import { getMcpConfigsByScope } from '../../services/mcp/config.js' 13 import { getSettingsWithErrors } from './settings.js' 14 import type { SettingsWithErrors } from './validation.js' 15 16 /** 17 * Get merged settings with all validation errors, including MCP config errors. 18 * 19 * Use this instead of getSettingsWithErrors() when you need the full set of 20 * errors (settings + MCP). The underlying getSettingsWithErrors() no longer 21 * includes MCP errors to avoid the circular dependency. 22 */ 23 export function getSettingsWithAllErrors(): SettingsWithErrors { 24 const result = getSettingsWithErrors() 25 // 'dynamic' scope does not have errors returned; it throws and is set on cli startup 26 const scopes = ['user', 'project', 'local'] as const 27 const mcpErrors = scopes.flatMap(scope => getMcpConfigsByScope(scope).errors) 28 return { 29 settings: result.settings, 30 errors: [...result.errors, ...mcpErrors], 31 } 32 }