# lib/output.ps1 - output helpers, mode colours, the banner and usage. # # Part of claude-mode.ps1, which dot-sources it into its own script scope after # the settings at its top. Not meant to run on its own. ASCII only: Windows # PowerShell 5.1 reads a .ps1 without a BOM as ANSI. $PSScriptRoot here would be # lib\, so paths beside the main script go through $script:Here. # --------------------------------------------------------------------------- # Output helpers # --------------------------------------------------------------------------- function Write-Ok ($m) { Write-Host " ok $m" -ForegroundColor Green } function Write-Warn2 ($m) { Write-Host " warn $m" -ForegroundColor Yellow } function Write-Err2 ($m) { Write-Host " FAIL $m" -ForegroundColor Red } function Write-Head ($m) { Write-Host ""; Write-Host $m -ForegroundColor Cyan } # Each mode gets an identity colour, reused for its menu row, its banner tagline # and its status line - so "which mode am I in" is answerable at a glance. $script:ModeColor = @{ 'anthropic' = 'Magenta' } $__colors = @{ cyan = 'Cyan'; green = 'Green'; yellow = 'Yellow'; magenta = 'Magenta' white = 'White'; gray = 'Gray'; dkcyan = 'DarkCyan'; red = 'Red' } foreach ($__p in $script:Providers) { $__c = $__colors[[string]$__p.color] $script:ModeColor[[string]$__p.id] = $(if ($__c) { $__c } else { 'Gray' }) } # Deliberately ASCII-only. This file is read by Windows PowerShell 5.1, which # assumes the ANSI codepage for a .ps1 without a BOM - box-drawing characters # would arrive mangled on some machines. Plain ASCII always renders. $script:Banner = @( ' ____ _ _ __ __ _ ', ' / ___| | __ _ _ _ __| | ___ | \/ | ___ __| | ___ ', ' | | | |/ _` | | | |/ _` |/ _ \ | |\/| |/ _ \ / _` |/ _ \', ' | |___| | (_| | |_| | (_| | __/ | | | | (_) | (_| | __/', ' \____|_|\__,_|\__,_|\__,_|\___| |_| |_|\___/ \__,_|\___|' ) function Show-Banner { param([string] $Mode, [string] $Preset) $shades = @('DarkCyan', 'Cyan', 'Cyan', 'Cyan', 'DarkCyan') Write-Host '' for ($i = 0; $i -lt $script:Banner.Count; $i++) { Write-Host $script:Banner[$i] -ForegroundColor $shades[$i] } $accent = $script:ModeColor[$Mode] if (-not $accent) { $accent = 'Gray' } $tag = if ($Preset) { "$Mode / $Preset" } else { $Mode } Write-Host ' ' -NoNewline Write-Host ('-' * 59) -ForegroundColor DarkGray Write-Host ' now ' -NoNewline -ForegroundColor DarkGray Write-Host $tag -NoNewline -ForegroundColor $accent Write-Host ' ' -NoNewline Write-Host 'switch Claude Code between providers' -ForegroundColor DarkGray } function Show-Usage { @' claude-mode - switch Claude Code between Anthropic and gateway providers claude-mode interactive menu claude-mode status active mode, preset, model map claude-mode anthropic native login/subscription (clears all gateway config) '@ | Write-Host # One line per provider in providers.json, so a new one documents itself. foreach ($p in $script:Providers) { $desc = ([string]$p.label) -replace '^[^-]*-\s*', '' Write-Host (" claude-mode {0,-26} {1} (default preset: {2})" -f "$($p.id) [preset]", $desc, $script:ProviderDefaultPreset[[string]$p.id]) } @' claude-mode presets list presets claude-mode preset show claude-mode preset new [from] create a preset (copies 'from') claude-mode preset set tier = opus | sonnet | haiku | fable | subagent claude-mode preset all point every tier at one model claude-mode preset rm claude-mode set-key [ref] [key] store an API key (hidden prompt, DPAPI-encrypted) claude-mode models [filter] models available from the active provider claude-mode doctor verify auth, endpoint, model ids, stray env vars claude-mode repair [--all] strip [1m] tags from cached model ids (default: gateway ids only; --all includes Anthropic) '@ | Write-Host }