ClaudeSwitcher.psm1

# ClaudeSwitcher - switch Claude Code between config profiles (command: ccs)
#
# Design notes, in case the reasoning is not obvious later:
#
# * Switching is done with CLAUDE_CONFIG_DIR, not by rewriting credentials.
# Claude Code isolates its whole config home behind that variable - settings,
# credentials, plugins, history - so nothing ever has to touch a raw OAuth
# token, and two shells can run different backends at the same time.
# * A settings.json 'env' block beats shell environment variables, so status and
# doctor always read the profile's settings file rather than trusting $env:.
# * Enterprise Bedrock packages can enforce their telemetry endpoint before
# handing out AWS credentials, so such a profile's env block is copied verbatim
# and checked for completeness - never trimmed.

$ErrorActionPreference = 'Stop'

if (-not $IsWindows) {
    Write-Warning 'ClaudeSwitcher targets Windows. Profile switching itself is portable, but the AWS/credential-process and registry checks are Windows-specific.'
}

foreach ($folder in @('Private', 'Public')) {
    $dir = Join-Path $PSScriptRoot $folder
    if (-not (Test-Path -LiteralPath $dir)) { continue }
    foreach ($file in Get-ChildItem -LiteralPath $dir -Filter '*.ps1' | Sort-Object Name) {
        . $file.FullName
    }
}

Export-ModuleMember -Function @(
    'ccs'
    'Get-CcsProfileList'
    'New-CcsProfileFromCurrent'
    'New-CcsBlankProfile'
    'Rename-CcsProfileEntry'
    'Remove-CcsProfileEntry'
    'Use-CcsProfile'
    'Start-CcsClaude'
    'Get-CcsStatus'
    'Get-CcsAwsIdentity'
    'Test-CcsHealth'
    'Test-CcsProfileHealth'
    'Backup-CcsPersonalSettings'
    'Invoke-CcsAdopt'
)