Files
dotfiles/chezmoi/.chezmoiscripts/run_31-create-claude-proxy-shortcut.ps1
T
Dmitry Dementiev 69507ce96c fix(proxy): исправлены маршрутизация Codex и запуск Claude
- Зачем:
  - Codex app-server обходил прокси, а Claude удерживал окно Windows Terminal.
- Что:
  - добавлен общий ~/.codex/.env и упрощён запуск Codex Desktop.
  - ярлык Claude переведён на скрытый запуск через wscript.exe.
  - документация приведена в соответствие с новой схемой.
- Проверка:
  - соединения ChatGPT.exe и codex.exe направлены через 127.0.0.1:12334.
  - проверены синтаксис PowerShell, состояние chezmoi и ярлык; Claude проверен вручную.
2026-07-25 13:01:26 +03:00

91 lines
2.7 KiB
PowerShell

$ErrorActionPreference = 'Stop'
if (-not ($IsWindows -or $PSVersionTable.PSEdition -eq 'Desktop')) {
return
}
$LauncherPath = Join-Path $HOME '.local\bin\start-claude-proxy.ps1'
$LauncherHostPath = Join-Path $HOME '.local\bin\start-claude-proxy.vbs'
$ProgramsPath = [Environment]::GetFolderPath('Programs')
if ([string]::IsNullOrWhiteSpace($ProgramsPath)) {
Write-Warning 'Start Menu Programs folder was not found.'
return
}
$ShortcutPath = Join-Path $ProgramsPath 'Claude Proxy.lnk'
$TargetPath = Join-Path $env:WINDIR 'System32\wscript.exe'
$Arguments = "//NoLogo `"$LauncherHostPath`""
$WorkingDirectory = $env:USERPROFILE
function Get-ClaudeIconExecutable {
$LegacyExecutable = Join-Path $env:LOCALAPPDATA 'AnthropicClaude\claude.exe'
if (Test-Path -LiteralPath $LegacyExecutable) {
return $LegacyExecutable
}
$Package = Get-AppxPackage -Name 'Claude' -ErrorAction SilentlyContinue |
Select-Object -First 1
if ($null -eq $Package) {
return $null
}
try {
$Manifest = Get-AppxPackageManifest $Package
$Application = @($Manifest.Package.Applications.Application) | Select-Object -First 1
if ($null -eq $Application -or [string]::IsNullOrWhiteSpace($Application.Executable)) {
return $null
}
$Executable = Join-Path $Package.InstallLocation ([string]$Application.Executable)
if (Test-Path -LiteralPath $Executable) {
return $Executable
}
}
catch {
return $null
}
return $null
}
$ClaudeExecutable = Get-ClaudeIconExecutable
if ($null -ne $ClaudeExecutable) {
$IconLocation = "$ClaudeExecutable,0"
} else {
$IconLocation = "$LauncherPath,0"
}
New-Item -ItemType Directory -Path (Split-Path -Parent $ShortcutPath) -Force | Out-Null
$Shell = New-Object -ComObject WScript.Shell
$Shortcut = $Shell.CreateShortcut($ShortcutPath)
$Changed = $false
if ($Shortcut.TargetPath -ne $TargetPath) {
$Shortcut.TargetPath = $TargetPath
$Changed = $true
}
if ($Shortcut.Arguments -ne $Arguments) {
$Shortcut.Arguments = $Arguments
$Changed = $true
}
if ($Shortcut.WorkingDirectory -ne $WorkingDirectory) {
$Shortcut.WorkingDirectory = $WorkingDirectory
$Changed = $true
}
if ($Shortcut.IconLocation -ne $IconLocation) {
$Shortcut.IconLocation = $IconLocation
$Changed = $true
}
if ($Shortcut.Description -ne 'Launch Claude with hproxy.local proxy environment') {
$Shortcut.Description = 'Launch Claude with hproxy.local proxy environment'
$Changed = $true
}
if ($Changed -or -not (Test-Path -LiteralPath $ShortcutPath)) {
$Shortcut.Save()
Write-Host "Claude Proxy shortcut: updated $ShortcutPath"
} else {
Write-Host 'Claude Proxy shortcut: already up to date.'
}