From c27067c974f83edfe78f47ecaee97e3c0be4b7f7 Mon Sep 17 00:00:00 2001 From: admin_d Date: Sun, 26 Jul 2026 16:26:55 +0500 Subject: [PATCH] Add Windows plugin installer --- README.md | 7 +++++- install.ps1 | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 install.ps1 diff --git a/README.md b/README.md index 80c1d88..46d2229 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,16 @@ Codex. ## Установка налогового плагина Репозиторий публичный: логин, пароль и SSH-ключ не требуются. +Откройте обычный PowerShell и выполните: ```powershell -codex plugin marketplace add "https://dev.ast.ltr.kz/Logos/codex-plugins.git" --ref main; if ($LASTEXITCODE -eq 0) { codex plugin add "tax-code-research@logos-company-plugins" } +irm "https://dev.ast.ltr.kz/Logos/codex-plugins/raw/branch/main/install.ps1" | iex ``` +Сценарий при необходимости установит Git, Node.js LTS и Codex CLI, затем +подключит marketplace и установит `tax-code-research`. Повторный запуск +безопасен: он обновит marketplace и не будет повторно устанавливать плагин. + После установки перезапустите ChatGPT Desktop или откройте новый рабочий чат. MCP плагина доступен только внутри корпоративной сети. diff --git a/install.ps1 b/install.ps1 new file mode 100644 index 0000000..8f9647d --- /dev/null +++ b/install.ps1 @@ -0,0 +1,70 @@ +$ErrorActionPreference = "Stop" + +function Install-WingetPackageIfMissing { + param( + [string]$Command, + [string]$PackageId + ) + + if (Get-Command $Command -ErrorAction SilentlyContinue) { + return + } + + if (-not (Get-Command winget.exe -ErrorAction SilentlyContinue)) { + throw "winget не найден. Обновите Windows App Installer и повторите установку." + } + + winget install --id $PackageId -e --accept-package-agreements --accept-source-agreements + if ($LASTEXITCODE -ne 0) { + throw "Не удалось установить пакет $PackageId." + } +} + +Install-WingetPackageIfMissing "git.exe" "Git.Git" +Install-WingetPackageIfMissing "npm.cmd" "OpenJS.NodeJS.LTS" + +$env:Path = "$env:ProgramFiles\Git\cmd;$env:ProgramFiles\nodejs;$env:APPDATA\npm;$env:Path" +$npm = Get-Command npm.cmd -ErrorAction SilentlyContinue +if (-not $npm) { + throw "Node.js установлен, но npm не найден. Перезапустите PowerShell и повторите команду." +} + +$codex = Get-Command codex.cmd -ErrorAction SilentlyContinue +if (-not $codex) { + & $npm.Source install --global "@openai/codex" + if ($LASTEXITCODE -ne 0) { + throw "Не удалось установить Codex CLI." + } + + $npmPrefix = (& $npm.Source config get prefix).Trim() + $env:Path = "$npmPrefix;$env:Path" + $codex = Get-Command codex.cmd -ErrorAction SilentlyContinue +} + +if (-not $codex) { + throw "Codex CLI установлен, но команда codex не найдена. Перезапустите PowerShell и повторите установку." +} + +$marketplaceName = "logos-company-plugins" +$marketplaceUrl = "https://dev.ast.ltr.kz/Logos/codex-plugins.git" +$pluginId = "tax-code-research@$marketplaceName" + +$marketplaces = (& $codex.Source plugin marketplace list --json | ConvertFrom-Json).marketplaces +if ($marketplaces.name -contains $marketplaceName) { + & $codex.Source plugin marketplace upgrade $marketplaceName +} else { + & $codex.Source plugin marketplace add $marketplaceUrl --ref main +} +if ($LASTEXITCODE -ne 0) { + throw "Не удалось подключить marketplace $marketplaceName." +} + +$installed = (& $codex.Source plugin list --json | ConvertFrom-Json).installed +if ($installed.pluginId -notcontains $pluginId) { + & $codex.Source plugin add $pluginId + if ($LASTEXITCODE -ne 0) { + throw "Не удалось установить плагин $pluginId." + } +} + +Write-Host "Готово. Перезапустите ChatGPT Desktop или откройте новый рабочий чат." -ForegroundColor Green