From b36ce50e1233caeadb64cb93e1bca000db7a8c10 Mon Sep 17 00:00:00 2001 From: Dmitriy Dementiev Date: Fri, 23 Oct 2026 14:15:46 +0300 Subject: [PATCH] =?UTF-8?q?fix(kimi):=20=D1=81=D0=BA=D1=80=D1=8B=D1=82?= =?UTF-8?q?=D1=8B=D0=B9=20=D0=B7=D0=B0=D0=BF=D1=83=D1=81=D0=BA=D0=B0=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=20=D0=B8=20=D0=B7=D0=B0=D0=BF=D0=B0=D1=81?= =?UTF-8?q?=D0=BD=D0=BE=D0=B9=20=D0=BF=D1=83=D1=82=D1=8C=20=D1=83=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Зачем: при повторном запуске через ярлык Kimi цеплялся к консоли pwsh и удерживал окно терминала открытым ради своих логов. - Что: ярлык переведён на скрытый VBS-запускатель (как у Claude Proxy); добавлен запасной путь %ProgramFiles%\Kimi для установки на всех пользователей. - Проверка: синтаксис скриптов проверен парсером PowerShell, tests/test_proxy_env_sync.py зелёный. --- README.md | 10 +++++-- .../run_32-create-kimi-proxy-shortcut.ps1 | 24 +++++++--------- chezmoi/dot_local/bin/start-kimi-proxy.ps1 | 14 +++++++--- chezmoi/dot_local/bin/start-kimi-proxy.vbs | 28 +++++++++++++++++++ 4 files changed, 55 insertions(+), 21 deletions(-) create mode 100644 chezmoi/dot_local/bin/start-kimi-proxy.vbs diff --git a/README.md b/README.md index d62ce61..ce3e7aa 100644 --- a/README.md +++ b/README.md @@ -129,9 +129,12 @@ Codex и Claude Code могут брать прокси из своих наст Если Claude уже запущен обычным способом, его нужно полностью закрыть перед запуском через `Claude Proxy`. -Ярлык `Kimi Proxy` запускает Kimi Desktop (`%LOCALAPPDATA%\Programs\Kimi\Kimi.exe`) -с теми же параметрами Electron `--proxy-server` и `--proxy-bypass-list`, что и -`Codex Proxy`. Если Kimi уже запущен, его нужно полностью закрыть перед запуском +Ярлык `Kimi Proxy` запускает Kimi Desktop с теми же параметрами Electron +`--proxy-server` и `--proxy-bypass-list`, что и `Codex Proxy`. Исполняемый файл +ищется в `%LOCALAPPDATA%\Programs\Kimi` и в `%ProgramFiles%\Kimi` (установка на +всех пользователей). Ярлык использует скрытый промежуточный запускатель, иначе +Kimi цепляется к консоли ярлыка и удерживает окно терминала открытым ради своих +логов. Если Kimi уже запущен, его нужно полностью закрыть перед запуском через `Kimi Proxy`. Список хостов, которые идут мимо прокси, продублирован в профилях Codex, @@ -219,6 +222,7 @@ PowerShell и VS Code: одного общего файла у Windows и WSL н | `~/.local/bin/start-claude-proxy.vbs` | Скрытый запуск PowerShell-скрипта без привязки Claude к видимому окну терминала | | `~/.local/bin/start-codex-proxy.ps1` | Запуск Codex для Windows через системный идентификатор; прокси Electron задается параметрами, а `codex.exe` читает `~/.codex/.env` | | `~/.local/bin/start-kimi-proxy.ps1` | Запуск Kimi Desktop для Windows с параметрами прокси Electron | +| `~/.local/bin/start-kimi-proxy.vbs` | Скрытый запуск PowerShell-скрипта без привязки Kimi к видимому окну терминала | | `~/.local/bin/start-chatgpt-proxy` | Запуск Linux-приложения ChatGPT через активную настройку `proxy-client` | | `~/.local/share/applications/chatgpt-proxy.desktop` | Отдельный Linux-ярлык `ChatGPT Proxy`, не подменяющий штатный `ChatGPT` | | `~/.config/powershell/profile.extra.ps1` | Локальные дополнения к pwsh-профилю | diff --git a/chezmoi/.chezmoiscripts/run_32-create-kimi-proxy-shortcut.ps1 b/chezmoi/.chezmoiscripts/run_32-create-kimi-proxy-shortcut.ps1 index 8189a13..70b7ab5 100644 --- a/chezmoi/.chezmoiscripts/run_32-create-kimi-proxy-shortcut.ps1 +++ b/chezmoi/.chezmoiscripts/run_32-create-kimi-proxy-shortcut.ps1 @@ -5,6 +5,7 @@ if (-not ($IsWindows -or $PSVersionTable.PSEdition -eq 'Desktop')) { } $LauncherPath = Join-Path $HOME '.local\bin\start-kimi-proxy.ps1' +$LauncherHostPath = Join-Path $HOME '.local\bin\start-kimi-proxy.vbs' $ProgramsPath = [Environment]::GetFolderPath('Programs') if ([string]::IsNullOrWhiteSpace($ProgramsPath)) { Write-Warning 'Start Menu Programs folder was not found.' @@ -12,23 +13,18 @@ if ([string]::IsNullOrWhiteSpace($ProgramsPath)) { } $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`"" +$TargetPath = Join-Path $env:WINDIR 'System32\wscript.exe' +$Arguments = "//NoLogo `"$LauncherHostPath`"" $WorkingDirectory = $env:USERPROFILE -$IconLocation = "$TargetPath,0" -$KimiExecutable = Join-Path $env:LOCALAPPDATA 'Programs\Kimi\Kimi.exe' -if (Test-Path -LiteralPath $KimiExecutable) { +$KimiExecutable = @( + (Join-Path $env:LOCALAPPDATA 'Programs\Kimi\Kimi.exe'), + (Join-Path $env:ProgramFiles 'Kimi\Kimi.exe') +) | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1 +if ($null -ne $KimiExecutable) { $IconLocation = "$KimiExecutable,0" +} else { + $IconLocation = "$LauncherPath,0" } New-Item -ItemType Directory -Path (Split-Path -Parent $ShortcutPath) -Force | Out-Null diff --git a/chezmoi/dot_local/bin/start-kimi-proxy.ps1 b/chezmoi/dot_local/bin/start-kimi-proxy.ps1 index 0d600b3..d48ce64 100644 --- a/chezmoi/dot_local/bin/start-kimi-proxy.ps1 +++ b/chezmoi/dot_local/bin/start-kimi-proxy.ps1 @@ -6,12 +6,18 @@ $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'." + $Candidates = @( + (Join-Path $env:LOCALAPPDATA 'Programs\Kimi\Kimi.exe'), + (Join-Path $env:ProgramFiles 'Kimi\Kimi.exe') + ) + + foreach ($Executable in $Candidates) { + if (Test-Path -LiteralPath $Executable) { + return $Executable + } } - return $Executable + throw "Kimi Desktop не найден: проверены пути '$($Candidates -join "', '")'." } function Assert-KimiNotRunning { diff --git a/chezmoi/dot_local/bin/start-kimi-proxy.vbs b/chezmoi/dot_local/bin/start-kimi-proxy.vbs new file mode 100644 index 0000000..69bc1cd --- /dev/null +++ b/chezmoi/dot_local/bin/start-kimi-proxy.vbs @@ -0,0 +1,28 @@ +Option Explicit + +Dim fileSystem +Dim launcherPath +Dim powerShellPath +Dim command +Dim exitCode +Dim shell + +Set fileSystem = CreateObject("Scripting.FileSystemObject") +Set shell = CreateObject("WScript.Shell") + +launcherPath = shell.ExpandEnvironmentStrings("%USERPROFILE%\.local\bin\start-kimi-proxy.ps1") +powerShellPath = shell.ExpandEnvironmentStrings("%LOCALAPPDATA%\Microsoft\WindowsApps\pwsh.exe") + +If Not fileSystem.FileExists(powerShellPath) Then + powerShellPath = "pwsh.exe" +End If + +command = """" & powerShellPath & _ + """ -NoLogo -NoProfile -ExecutionPolicy Bypass -File """ & _ + launcherPath & """" + +exitCode = shell.Run(command, 0, True) +If exitCode <> 0 Then + MsgBox "Не удалось запустить Kimi Proxy. Код ошибки: " & exitCode, _ + vbCritical, "Kimi Proxy" +End If