feat(kimi): добавлен запуск Kimi Desktop через прокси
- Зачем: Kimi Desktop по умолчанию ходит в сеть напрямую, а прокси нужен как для Codex и Claude. - Что: start-kimi-proxy.ps1 запускает Kimi.exe с параметрами Electron --proxy-server и --proxy-bypass-list, run-скрипт chezmoi создаёт ярлык Kimi Proxy в меню "Пуск"; тест синхронизации списков обхода обобщён на все копии. - Проверка: синтаксис скриптов проверен парсером PowerShell, tests/test_proxy_env_sync.py зелёный, запуск через ярлык проверен вручную.
This commit is contained in:
1 parent
4f034ea840
commit
5b2eef4881
4 files changed
+115
-1
No files matched your search
@@ -0,0 +1,66 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
if (-not ($IsWindows -or $PSVersionTable.PSEdition -eq 'Desktop')) {
|
||||
return
|
||||
}
|
||||
|
||||
$LauncherPath = Join-Path $HOME '.local\bin\start-kimi-proxy.ps1'
|
||||
$ProgramsPath = [Environment]::GetFolderPath('Programs')
|
||||
if ([string]::IsNullOrWhiteSpace($ProgramsPath)) {
|
||||
Write-Warning 'Start Menu Programs folder was not found.'
|
||||
return
|
||||
}
|
||||
|
||||
$ShortcutPath = Join-Path $ProgramsPath 'Kimi Proxy.lnk'
|
||||
$PwshAliasPath = Join-Path $env:LOCALAPPDATA 'Microsoft\WindowsApps\pwsh.exe'
|
||||
$PwshCommand = Get-Command pwsh -ErrorAction SilentlyContinue
|
||||
if (Test-Path -LiteralPath $PwshAliasPath) {
|
||||
$TargetPath = $PwshAliasPath
|
||||
} elseif ($null -ne $PwshCommand) {
|
||||
$TargetPath = $PwshCommand.Source
|
||||
} else {
|
||||
$TargetPath = 'pwsh.exe'
|
||||
}
|
||||
|
||||
$Arguments = "-NoLogo -NoProfile -ExecutionPolicy Bypass -File `"$LauncherPath`""
|
||||
$WorkingDirectory = $env:USERPROFILE
|
||||
$IconLocation = "$TargetPath,0"
|
||||
|
||||
$KimiExecutable = Join-Path $env:LOCALAPPDATA 'Programs\Kimi\Kimi.exe'
|
||||
if (Test-Path -LiteralPath $KimiExecutable) {
|
||||
$IconLocation = "$KimiExecutable,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 Kimi with hproxy.local proxy environment') {
|
||||
$Shortcut.Description = 'Launch Kimi with hproxy.local proxy environment'
|
||||
$Changed = $true
|
||||
}
|
||||
|
||||
if ($Changed -or -not (Test-Path -LiteralPath $ShortcutPath)) {
|
||||
$Shortcut.Save()
|
||||
Write-Host "Kimi Proxy shortcut: updated $ShortcutPath"
|
||||
} else {
|
||||
Write-Host 'Kimi Proxy shortcut: already up to date.'
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$ProxyHostName = 'hproxy.local'
|
||||
$ProxyPort = 12334
|
||||
$HttpProxy = "http://${ProxyHostName}:${ProxyPort}"
|
||||
$ProxyBypassList = "${ProxyHostName};localhost;127.0.0.1;[::1];*.concept-software.ru;dementev.space;*.dementev.space"
|
||||
|
||||
function Get-KimiApplication {
|
||||
$Executable = Join-Path $env:LOCALAPPDATA 'Programs\Kimi\Kimi.exe'
|
||||
if (-not (Test-Path -LiteralPath $Executable)) {
|
||||
throw "Kimi Desktop не найден: ожидался файл '$Executable'."
|
||||
}
|
||||
|
||||
return $Executable
|
||||
}
|
||||
|
||||
function Assert-KimiNotRunning {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Executable
|
||||
)
|
||||
|
||||
$RunningProcess = Get-CimInstance Win32_Process -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.ExecutablePath -eq $Executable } |
|
||||
Select-Object -First 1
|
||||
|
||||
if ($null -ne $RunningProcess) {
|
||||
throw 'Kimi уже запущен. Полностью закройте приложение и повторно откройте ярлык Kimi Proxy.'
|
||||
}
|
||||
}
|
||||
|
||||
$KimiExecutable = Get-KimiApplication
|
||||
Assert-KimiNotRunning -Executable $KimiExecutable
|
||||
|
||||
Start-Process -FilePath $KimiExecutable -ArgumentList @(
|
||||
"--proxy-server=${HttpProxy}",
|
||||
"--proxy-bypass-list=${ProxyBypassList}"
|
||||
)
|
||||
Reference in new issue
Block a user