One-liner script that: - Verifies/installs Node.js >= 18, git, codex CLI - Adds 'openai-codex' marketplace (github.com/openai/codex-plugin-cc) - Installs/updates 'codex@openai-codex' plugin - Verifies result via 'claude plugin list' Re-runs are safe — auto-detects what is already installed and only fills gaps or pulls newer plugin versions. Three platforms covered: Linux (apt/dnf/yum), macOS (brew), Windows (winget) via .sh and .ps1 wrappers + CMD entry-point. Plugin commands inside Claude Code: /codex:review, /codex:adversarial-review, /codex:rescue, /codex:status, /codex:result, /codex:cancel Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
122 lines
5.0 KiB
PowerShell
122 lines
5.0 KiB
PowerShell
# Install OpenAI Codex Plugin for Claude Code (Windows)
|
|
# Idempotent - safe to re-run; auto-installs missing prereqs.
|
|
#
|
|
# Usage (PowerShell as Administrator):
|
|
# $h=@{Authorization="token cadffcb0a6a3be728ac1ff619bb40c86588f6837"}
|
|
# Set-ExecutionPolicy Bypass -Scope Process -Force
|
|
# iwr "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/claude/install_codex_plugin.ps1" -OutFile "$env:TEMP\install_codex_plugin.ps1" -Headers $h
|
|
# . "$env:TEMP\install_codex_plugin.ps1"
|
|
|
|
$ErrorActionPreference = "Continue"
|
|
|
|
$PLUGIN_NAME = "codex"
|
|
$MARKETPLACE_NAME = "openai-codex"
|
|
$MARKETPLACE_URL = "https://github.com/openai/codex-plugin-cc"
|
|
$CODEX_NPM = "@openai/codex"
|
|
|
|
Write-Host ""
|
|
Write-Host " +------------------------------------------+" -ForegroundColor Cyan
|
|
Write-Host " | Codex Plugin for Claude Code installer |" -ForegroundColor Cyan
|
|
Write-Host " +------------------------------------------+" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
function Test-Cmd($n) { return [bool](Get-Command $n -ErrorAction SilentlyContinue) }
|
|
function Refresh-Path {
|
|
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" +
|
|
[System.Environment]::GetEnvironmentVariable("Path","User")
|
|
}
|
|
|
|
# ---- 1. Prereqs ----
|
|
|
|
if (-not (Test-Cmd "node")) {
|
|
Write-Host " Node.js not found, installing via winget..." -ForegroundColor Yellow
|
|
if (Test-Cmd "winget") {
|
|
winget install OpenJS.NodeJS.LTS --accept-package-agreements --accept-source-agreements -e 2>$null
|
|
Refresh-Path
|
|
} else {
|
|
Write-Host " winget unavailable. Install Node.js manually: https://nodejs.org/" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
}
|
|
$nodeMajor = [int](((node --version 2>$null) -replace '^v','') -split '\.')[0]
|
|
if ($nodeMajor -lt 18) {
|
|
Write-Host " Node.js >= 18 required (found v$nodeMajor). Upgrade manually." -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
Write-Host " Node.js v$nodeMajor.x OK" -ForegroundColor Green
|
|
|
|
if (-not (Test-Cmd "claude")) {
|
|
Write-Host " Claude Code CLI not found. Install it first:" -ForegroundColor Red
|
|
Write-Host ' npm config set "@anthropic-ai:registry" "https://npm.sensey24.ru/"' -ForegroundColor Yellow
|
|
Write-Host " npm install -g @anthropic-ai/claude-code" -ForegroundColor Yellow
|
|
exit 1
|
|
}
|
|
Write-Host (" Claude Code: " + (claude --version 2>$null)) -ForegroundColor Green
|
|
|
|
if (-not (Test-Cmd "git")) {
|
|
Write-Host " git not found, installing via winget..." -ForegroundColor Yellow
|
|
if (Test-Cmd "winget") {
|
|
winget install Git.Git --accept-package-agreements --accept-source-agreements -e 2>$null
|
|
Refresh-Path
|
|
} else {
|
|
Write-Host " Install git manually: https://git-scm.com/download/win" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
}
|
|
Write-Host (" git: " + (git --version)) -ForegroundColor Green
|
|
|
|
# ---- 2. Codex CLI ----
|
|
|
|
if (-not (Test-Cmd "codex")) {
|
|
Write-Host " Codex CLI not found, installing..." -ForegroundColor Cyan
|
|
npm install -g $CODEX_NPM 2>&1 | Select-Object -Last 3
|
|
Refresh-Path
|
|
}
|
|
$codexVer = (codex --version 2>$null) -replace '[^0-9.]+',' ' -split ' ' | Where-Object { $_ -match '^\d+\.\d+\.\d+' } | Select-Object -First 1
|
|
if (-not $codexVer) { $codexVer = "unknown" }
|
|
Write-Host " Codex CLI v$codexVer" -ForegroundColor Green
|
|
|
|
# ---- 3. Marketplace ----
|
|
|
|
$marketList = claude plugin marketplace list 2>&1 | Out-String
|
|
if ($marketList -match $MARKETPLACE_NAME) {
|
|
Write-Host " Marketplace '$MARKETPLACE_NAME' already configured" -ForegroundColor Green
|
|
} else {
|
|
Write-Host " Adding marketplace: $MARKETPLACE_URL" -ForegroundColor Cyan
|
|
claude plugin marketplace add $MARKETPLACE_URL 2>&1 | Select-Object -Last 3
|
|
}
|
|
|
|
# ---- 4. Plugin install / update ----
|
|
|
|
$pluginList = claude plugin list 2>&1 | Out-String
|
|
$fullName = "${PLUGIN_NAME}@${MARKETPLACE_NAME}"
|
|
if ($pluginList -match [regex]::Escape($fullName)) {
|
|
Write-Host " Plugin already installed - checking for updates..." -ForegroundColor Cyan
|
|
claude plugin update $fullName 2>&1 | Select-Object -Last 3
|
|
} else {
|
|
Write-Host " Installing plugin: $fullName" -ForegroundColor Cyan
|
|
claude plugin install $fullName 2>&1 | Select-Object -Last 5
|
|
}
|
|
|
|
# ---- 5. Verify ----
|
|
|
|
$verify = claude plugin list 2>&1 | Out-String
|
|
if ($verify -match [regex]::Escape($fullName)) {
|
|
Write-Host ""
|
|
Write-Host " === Codex plugin installed! ===" -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host " Commands inside Claude Code:"
|
|
Write-Host " /codex:review - standard code review"
|
|
Write-Host " /codex:adversarial-review - design + assumption review"
|
|
Write-Host " /codex:rescue - delegate task to Codex for fix"
|
|
Write-Host " /codex:status - check background jobs"
|
|
Write-Host " /codex:result - fetch job results"
|
|
Write-Host " /codex:cancel - cancel a running job"
|
|
Write-Host ""
|
|
Write-Host " Auth: run 'codex login' (or set OPENAI_API_KEY)" -ForegroundColor Yellow
|
|
Write-Host ""
|
|
} else {
|
|
Write-Host " Plugin install verification failed. Run: claude plugin list" -ForegroundColor Red
|
|
exit 1
|
|
}
|