Private/Get-ModelConfig.ps1

function Get-ModelConfig {
    <#
    .SYNOPSIS
    Load and merge model configuration from JSON file
     
    .DESCRIPTION
    Loads model configuration with support for customer overrides.
    Load order:
    1. Module default config
    2. Customer override config (if exists)
    3. Merge configurations
     
    .PARAMETER ConfigPath
    Path to model-config.json file
     
    .EXAMPLE
    $config = Get-ModelConfig -ConfigPath "model-config.json"
     
    .OUTPUTS
    System.Object - Configuration hashtable
     
    .NOTES
    Author: waldo
    Version: 1.0.0
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [string]$ConfigPath
    )
    
    begin {
        Write-Verbose "Starting $($MyInvocation.MyCommand.Name)"
    }
    
    process {
        try {
            if (-not (Test-Path $ConfigPath)) {
                throw "Model configuration not found: $ConfigPath"
            }
            
            $config = Get-Content $ConfigPath -Raw | ConvertFrom-Json
            
            # Validate required fields
            if (-not $config.default) {
                throw "Configuration missing required 'default' section"
            }
            
            if (-not $config.default.provider) {
                throw "Configuration missing required 'default.provider' field"
            }
            
            if (-not $config.providers) {
                throw "Configuration missing required 'providers' section"
            }
            
            $providerName = $config.default.provider
            if (-not $config.providers.$providerName) {
                throw "Default provider '$providerName' not found in providers section"
            }
            
            Write-Verbose "Loaded configuration for provider: $providerName"
            
            return $config
        }
        catch {
            Write-Error "Error in $($MyInvocation.MyCommand.Name): $_"
            throw
        }
    }
    
    end {
        Write-Verbose "Completed $($MyInvocation.MyCommand.Name)"
    }
}