Install plugin without developer tools
This commit is contained in:
@@ -12,9 +12,10 @@ Codex.
|
|||||||
irm "https://dev.ast.ltr.kz/Logos/codex-plugins/raw/branch/main/install.ps1" | iex
|
irm "https://dev.ast.ltr.kz/Logos/codex-plugins/raw/branch/main/install.ps1" | iex
|
||||||
```
|
```
|
||||||
|
|
||||||
Сценарий при необходимости установит Git, Node.js LTS и Codex CLI, затем
|
Сценарий использует только встроенные средства Windows: скачивает ZIP,
|
||||||
подключит marketplace и установит `tax-code-research`. Повторный запуск
|
распаковывает marketplace в `%LOCALAPPDATA%\Logos\codex-plugins` и открывает
|
||||||
безопасен: он обновит marketplace и не будет повторно устанавливать плагин.
|
карточку `tax-code-research` в ChatGPT Desktop. Нажмите **Установить**.
|
||||||
|
Git, Node.js и отдельный Codex CLI не требуются.
|
||||||
|
|
||||||
После установки перезапустите ChatGPT Desktop или откройте новый рабочий чат.
|
После установки перезапустите ChatGPT Desktop или откройте новый рабочий чат.
|
||||||
MCP плагина доступен только внутри корпоративной сети.
|
MCP плагина доступен только внутри корпоративной сети.
|
||||||
|
|||||||
+28
-60
@@ -1,70 +1,38 @@
|
|||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
function Install-WingetPackageIfMissing {
|
$archiveUrl = "https://dev.ast.ltr.kz/Logos/codex-plugins/archive/main.zip"
|
||||||
param(
|
$installRoot = Join-Path $env:LOCALAPPDATA "Logos\codex-plugins"
|
||||||
[string]$Command,
|
$tempRoot = Join-Path ([IO.Path]::GetTempPath()) ("logos-codex-plugins-" + [guid]::NewGuid())
|
||||||
[string]$PackageId
|
$zipPath = Join-Path $tempRoot "marketplace.zip"
|
||||||
)
|
$extractRoot = Join-Path $tempRoot "extract"
|
||||||
|
|
||||||
if (Get-Command $Command -ErrorAction SilentlyContinue) {
|
New-Item -ItemType Directory -Path $tempRoot, $extractRoot -Force | Out-Null
|
||||||
return
|
|
||||||
|
try {
|
||||||
|
Invoke-WebRequest -UseBasicParsing -Uri $archiveUrl -OutFile $zipPath
|
||||||
|
Expand-Archive -Path $zipPath -DestinationPath $extractRoot -Force
|
||||||
|
|
||||||
|
$sourceRoot = Join-Path $extractRoot "codex-plugins"
|
||||||
|
$sourceMarketplace = Join-Path $sourceRoot ".agents\plugins\marketplace.json"
|
||||||
|
if (-not (Test-Path $sourceMarketplace)) {
|
||||||
|
throw "В загруженном архиве не найден marketplace.json."
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not (Get-Command winget.exe -ErrorAction SilentlyContinue)) {
|
New-Item -ItemType Directory -Path (Split-Path $installRoot -Parent) -Force | Out-Null
|
||||||
throw "winget не найден. Обновите Windows App Installer и повторите установку."
|
if (Test-Path $installRoot) {
|
||||||
|
Remove-Item -Path $installRoot -Recurse -Force
|
||||||
}
|
}
|
||||||
|
Move-Item -Path $sourceRoot -Destination $installRoot
|
||||||
winget install --id $PackageId -e --accept-package-agreements --accept-source-agreements
|
}
|
||||||
if ($LASTEXITCODE -ne 0) {
|
finally {
|
||||||
throw "Не удалось установить пакет $PackageId."
|
if (Test-Path $tempRoot) {
|
||||||
|
Remove-Item -Path $tempRoot -Recurse -Force
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Install-WingetPackageIfMissing "git.exe" "Git.Git"
|
$marketplacePath = Join-Path $installRoot ".agents\plugins\marketplace.json"
|
||||||
Install-WingetPackageIfMissing "npm.cmd" "OpenJS.NodeJS.LTS"
|
$encodedPath = [uri]::EscapeDataString($marketplacePath)
|
||||||
|
$pluginUrl = "codex://plugins/tax-code-research?marketplacePath=$encodedPath"
|
||||||
|
|
||||||
$env:Path = "$env:ProgramFiles\Git\cmd;$env:ProgramFiles\nodejs;$env:APPDATA\npm;$env:Path"
|
Start-Process $pluginUrl
|
||||||
$npm = Get-Command npm.cmd -ErrorAction SilentlyContinue
|
Write-Host "Карточка плагина открыта. Нажмите «Установить», затем откройте новый рабочий чат." -ForegroundColor Green
|
||||||
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
|
|
||||||
|
|||||||
Reference in New Issue
Block a user