Split the Windows script into modules; drop the Arkylx Index pieces
claude-mode.ps1 was 2,407 lines. It is now 153: the help block, parameters, paths, the managed-key list, a loader, and the dispatch. The rest moved, verbatim, into eleven files under lib/ - providers, output, files, core, vault, switch, guards, health, catalogue, commands, menu - dot-sourced into the script's scope in their original order, with the same check as the bash split that every original line landed in exactly one file. Inside a module $PSScriptRoot is lib\, so the one path beside the main script (providers.json) now goes through $script:Here. install.ps1 ships lib\, clearing old modules first. The Windows suite parses every module and install.ps1 (36 checks, all green on Windows PowerShell 5.1); install.ps1 is parsed but never run, since it edits the real profile and User PATH. linux/bootstrap.sh and scripts/build-package.ps1 existed only to build and serve packages for the Arkylx Index. Both installers fetch the repository's own archive, so a push to master is the release; the two scripts, the dist/ ignore and their mentions in the docs are gone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
# 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 <name>
|
||||
claude-mode preset new <name> [from] create a preset (copies 'from')
|
||||
claude-mode preset set <name> <tier> <model-id>
|
||||
tier = opus | sonnet | haiku | fable | subagent
|
||||
claude-mode preset all <name> <model-id>
|
||||
point every tier at one model
|
||||
claude-mode preset rm <name>
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user