Import claude-code-switcher from the Windows build
Source of truth so far has been c:\Users\smoido\projects\cli on the Windows box, which has no git history of its own. This is that tree copied verbatim over SSH, minus dist/ - the PowerShell build, the POSIX port under linux/, and the presets both share. Recorded as its own commit so that everything after it is a reviewable diff rather than an undifferentiated first drop.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
# >>> claude-mode >>>
|
||||
# Installed by claude-code-switcher. Do not edit between the markers;
|
||||
# re-run install.ps1 instead.
|
||||
|
||||
function claude-mode {
|
||||
& (Join-Path $env:USERPROFILE '.claude-mode\claude-mode.ps1') @args
|
||||
}
|
||||
|
||||
# Wrapper around claude.exe. settings.json is the single source of truth for
|
||||
# gateway config, so any inherited process-level copy of these variables is
|
||||
# stripped before launch: a stale ANTHROPIC_API_KEY would silently bypass the
|
||||
# OpenRouter gateway, and stale ANTHROPIC_BASE_URL / *_MODEL values would break
|
||||
# native Anthropic auth. Restored afterwards so other tools in the shell are
|
||||
# unaffected.
|
||||
function claude {
|
||||
$exe = Get-Command 'claude.exe' -CommandType Application -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
if (-not $exe) { Write-Error 'claude.exe not found on PATH'; return }
|
||||
|
||||
$names = @(
|
||||
'ANTHROPIC_API_KEY',
|
||||
'ANTHROPIC_AUTH_TOKEN',
|
||||
'ANTHROPIC_BASE_URL',
|
||||
'ANTHROPIC_DEFAULT_OPUS_MODEL',
|
||||
'ANTHROPIC_DEFAULT_SONNET_MODEL',
|
||||
'ANTHROPIC_DEFAULT_HAIKU_MODEL',
|
||||
'ANTHROPIC_DEFAULT_FABLE_MODEL',
|
||||
'CLAUDE_CODE_SUBAGENT_MODEL',
|
||||
'CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY',
|
||||
'CLAUDE_CODE_ATTRIBUTION_HEADER',
|
||||
'CLAUDE_CODE_AUTO_COMPACT_WINDOW',
|
||||
'CLAUDE_CODE_MAX_CONTEXT_TOKENS',
|
||||
'CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC',
|
||||
'API_TIMEOUT_MS'
|
||||
)
|
||||
|
||||
$saved = @{}
|
||||
foreach ($n in $names) {
|
||||
$v = [Environment]::GetEnvironmentVariable($n, 'Process')
|
||||
if ($null -ne $v) {
|
||||
$saved[$n] = $v
|
||||
[Environment]::SetEnvironmentVariable($n, $null, 'Process')
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
& $exe.Source @args
|
||||
} finally {
|
||||
foreach ($n in $saved.Keys) { [Environment]::SetEnvironmentVariable($n, $saved[$n], 'Process') }
|
||||
}
|
||||
}
|
||||
# <<< claude-mode <<<
|
||||
Reference in New Issue
Block a user