feat: add update scripts for all tools + Update section in README

- gemini/ugemini_update.sh + .ps1
- codex/ucodex_update.sh + .ps1
- qwen/uqwen_update.sh + .ps1
- README.md: added Update section with one-line and cloned-repo commands
- README.md: removed outdated Codex update instructions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
delta-cloud-208e
2026-03-08 07:44:38 +00:00
parent 1fa1dbae11
commit 9adb786bec
7 changed files with 557 additions and 7 deletions

View File

@@ -199,13 +199,6 @@ powershell -ExecutionPolicy Bypass -File codex\ucodex_install.ps1
Verify: `codex exec "Hello"`
**Update (Linux):**
```bash
cd unlimitedcoding/codex
git pull
sudo bash update-codex.sh && sudo python3 codex_patcher.py --apply
```
See [codex/README.md](codex/README.md) for details, troubleshooting, and configuration.
### Qwen Code — Install
@@ -268,6 +261,34 @@ cd unlimitedcoding
| Windows PowerShell | `powershell -ExecutionPolicy Bypass -File claude\releases\v2.1.71\install.ps1` |
<!-- MANUAL_VERSION:END -->
## Update
Update scripts check for latest version, download and re-apply patches automatically.
**One-line update (no repo clone needed):**
| Tool | Linux / macOS | Windows (PowerShell) |
|------|---------------|----------------------|
| Claude Code | `curl -fsSL -H "Authorization: token cadffcb0a6a3be728ac1ff619bb40c86588f6837" https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/claude/uclaude_update.sh -o /tmp/uclaude_update.sh && sudo bash /tmp/uclaude_update.sh` | `powershell -ExecutionPolicy Bypass -File claude\uclaude_update.ps1` |
| Gemini CLI | `curl -fsSL -H "Authorization: token cadffcb0a6a3be728ac1ff619bb40c86588f6837" https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/gemini/ugemini_update.sh -o /tmp/ugemini_update.sh && sudo bash /tmp/ugemini_update.sh` | `powershell -ExecutionPolicy Bypass -File gemini\ugemini_update.ps1` |
| Codex CLI | `curl -fsSL -H "Authorization: token cadffcb0a6a3be728ac1ff619bb40c86588f6837" https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/codex/ucodex_update.sh -o /tmp/ucodex_update.sh && sudo bash /tmp/ucodex_update.sh` | `powershell -ExecutionPolicy Bypass -File codex\ucodex_update.ps1` |
| Qwen Code | `curl -fsSL -H "Authorization: token cadffcb0a6a3be728ac1ff619bb40c86588f6837" https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen/uqwen_update.sh -o /tmp/uqwen_update.sh && sudo bash /tmp/uqwen_update.sh` | `powershell -ExecutionPolicy Bypass -File qwen\uqwen_update.ps1` |
**Or from cloned repo:**
```bash
git clone --depth 1 https://x-token:cadffcb0a6a3be728ac1ff619bb40c86588f6837@git.sensey24.ru/aibot777/unlimitedcoding.git
cd unlimitedcoding
```
| Tool | Linux / macOS | Windows (PowerShell) |
|------|---------------|----------------------|
| Claude Code | `sudo bash claude/uclaude_update.sh` | `powershell -ExecutionPolicy Bypass -File claude\uclaude_update.ps1` |
| Gemini CLI | `sudo bash gemini/ugemini_update.sh` | `powershell -ExecutionPolicy Bypass -File gemini\ugemini_update.ps1` |
| Codex CLI | `sudo bash codex/ucodex_update.sh` | `powershell -ExecutionPolicy Bypass -File codex\ucodex_update.ps1` |
| Qwen Code | `sudo bash qwen/uqwen_update.sh` | `powershell -ExecutionPolicy Bypass -File qwen\uqwen_update.ps1` |
Each updater: checks current version, downloads latest, re-applies patches.
## Uninstall
Clone repo (if not already cloned):

124
codex/ucodex_update.ps1 Normal file
View File

@@ -0,0 +1,124 @@
# Codex CLI — Windows Updater
# Downloads latest binary from GitHub + re-applies config patches.
#
# Usage: powershell -ExecutionPolicy Bypass -File codex\ucodex_update.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Codex CLI -- Windows Updater |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
function Refresh-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
}
# ---- Check current version ----
$oldVer = "not installed"
if (Get-Command codex -ErrorAction SilentlyContinue) {
$oldVer = [regex]::Match((codex --version 2>$null), '\d+\.\d+\.\d+').Value
}
Write-Host " Current: $oldVer" -ForegroundColor Cyan
# ---- Get latest version ----
Write-Host " Checking latest version..." -ForegroundColor Cyan
try {
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/openai/codex/releases/latest" -UseBasicParsing -TimeoutSec 15
$latestVer = ($release.tag_name -replace '^rust-v', '')
Write-Host " Latest: $latestVer" -ForegroundColor Green
} catch {
Write-Host " Could not fetch latest version from GitHub." -ForegroundColor Red
exit 1
}
if ($oldVer -eq $latestVer) {
Write-Host " Already up to date ($latestVer)" -ForegroundColor Green
} else {
# ---- Download binary ----
$arch = if ([System.Environment]::Is64BitOperatingSystem) { "x86_64" } else { "i686" }
$binarySuffix = "$arch-pc-windows-msvc"
$downloadUrl = "https://github.com/openai/codex/releases/download/rust-v$latestVer/codex-$binarySuffix.zip"
Write-Host " Downloading codex-$binarySuffix..." -ForegroundColor Cyan
$tempDir = Join-Path $env:TEMP "codex-update-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
$zipFile = Join-Path $tempDir "codex.zip"
try {
Invoke-WebRequest -Uri $downloadUrl -OutFile $zipFile -UseBasicParsing
} catch {
# Try tar.gz fallback
$downloadUrl = "https://github.com/openai/codex/releases/download/rust-v$latestVer/codex-$binarySuffix.tar.gz"
$tgzFile = Join-Path $tempDir "codex.tar.gz"
try {
Invoke-WebRequest -Uri $downloadUrl -OutFile $tgzFile -UseBasicParsing
tar -xzf $tgzFile -C $tempDir
} catch {
Write-Host " Download failed." -ForegroundColor Red
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
exit 1
}
}
if (Test-Path $zipFile) {
Expand-Archive -Path $zipFile -DestinationPath $tempDir -Force
}
$codexExe = Get-ChildItem -Path $tempDir -Recurse -Filter "codex.exe" | Select-Object -First 1
if (-not $codexExe) {
$codexExe = Get-ChildItem -Path $tempDir -Recurse -Filter "codex" | Where-Object { -not $_.PSIsContainer } | Select-Object -First 1
}
if (-not $codexExe) {
Write-Host " Binary not found in archive" -ForegroundColor Red
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
exit 1
}
Get-Process -Name "codex" -ErrorAction SilentlyContinue | Stop-Process -Force
$installDir = "$env:LOCALAPPDATA\Programs\codex"
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
Copy-Item -Path $codexExe.FullName -Destination "$installDir\codex.exe" -Force
$userPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$installDir*") {
[System.Environment]::SetEnvironmentVariable("Path", "$userPath;$installDir", "User")
$env:Path = "$env:Path;$installDir"
}
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
Refresh-Path
$newVer = [regex]::Match((codex --version 2>$null), '\d+\.\d+\.\d+').Value
Write-Host " Updated: $oldVer -> $newVer" -ForegroundColor Green
}
# ---- Download and apply patches ----
$pyCmd = if (Get-Command python3 -ErrorAction SilentlyContinue) { "python3" } else { "python" }
$patchDir = Join-Path $env:TEMP "codex-patch-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $patchDir | Out-Null
$repoRaw = "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/codex"
$token = "cadffcb0a6a3be728ac1ff619bb40c86588f6837"
$headers = @{ "Authorization" = "token $token" }
Write-Host " Downloading patcher..." -ForegroundColor Cyan
Invoke-WebRequest -Uri "$repoRaw/codex_patcher.py" -OutFile "$patchDir\codex_patcher.py" -UseBasicParsing -Headers $headers
Invoke-WebRequest -Uri "$repoRaw/codex_config.json" -OutFile "$patchDir\codex_config.json" -UseBasicParsing -Headers $headers
Write-Host " Applying patches..." -ForegroundColor Cyan
& $pyCmd "$patchDir\codex_patcher.py" --apply --config "$patchDir\codex_config.json"
Remove-Item -Recurse -Force $patchDir -ErrorAction SilentlyContinue
Write-Host ""
Write-Host " Update complete!" -ForegroundColor Green
Write-Host ""

103
codex/ucodex_update.sh Normal file
View File

@@ -0,0 +1,103 @@
#!/usr/bin/env bash
# Codex CLI — Updater
# Downloads latest binary from GitHub + re-applies config patches.
#
# Usage: sudo bash ucodex_update.sh
set -euo pipefail
REPO_RAW="https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/codex"
GITHUB_API="https://api.github.com/repos/openai/codex/releases/latest"
GREEN="\033[92m"
CYAN="\033[96m"
YELLOW="\033[93m"
RED="\033[91m"
BOLD="\033[1m"
RESET="\033[0m"
log() { echo -e "${GREEN}[+]${RESET} $*"; }
info() { echo -e "${CYAN}[i]${RESET} $*"; }
warn() { echo -e "${YELLOW}[~]${RESET} $*"; }
err() { echo -e "${RED}[!]${RESET} $*" >&2; }
echo -e "${BOLD}"
echo " +--------------------------------------+"
echo " | Codex CLI — Updater |"
echo " +--------------------------------------+"
echo -e "${RESET}"
# ---- Check current version ----
OLD_VER="not installed"
if command -v codex &>/dev/null; then
OLD_VER=$(codex --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || echo "unknown")
info "Current version: $OLD_VER"
fi
# ---- Get latest version ----
info "Checking latest version..."
LATEST_VER=$(curl -s "$GITHUB_API" | grep -oP '"tag_name":\s*"rust-v\K[0-9]+\.[0-9]+\.[0-9]+' | head -1)
if [ -z "$LATEST_VER" ]; then
err "Could not fetch latest version from GitHub"
exit 1
fi
info "Latest version: $LATEST_VER"
if [ "$OLD_VER" = "$LATEST_VER" ]; then
log "Already up to date ($LATEST_VER)"
else
# ---- Download binary ----
ARCH=$(uname -m)
case "$ARCH" in
x86_64) BINARY_SUFFIX="x86_64-unknown-linux-musl" ;;
aarch64|arm64) BINARY_SUFFIX="aarch64-unknown-linux-musl" ;;
*) err "Unsupported architecture: $ARCH"; exit 1 ;;
esac
DOWNLOAD_URL="https://github.com/openai/codex/releases/download/rust-v${LATEST_VER}/codex-${BINARY_SUFFIX}.tar.gz"
TEMP_DIR=$(mktemp -d)
info "Downloading codex-${BINARY_SUFFIX}..."
curl -L -# -o "$TEMP_DIR/codex.tar.gz" "$DOWNLOAD_URL"
tar -xzf "$TEMP_DIR/codex.tar.gz" -C "$TEMP_DIR"
# Find binary
BINARY_FILE=$(find "$TEMP_DIR" -maxdepth 1 -name 'codex*' -type f ! -name '*.gz' | head -1)
if [ -z "$BINARY_FILE" ]; then
err "Binary not found in archive"
rm -rf "$TEMP_DIR"
exit 1
fi
# Kill running processes
pkill -9 -x "codex" 2>/dev/null || true
# Install
CODEX_PATH=$(which codex 2>/dev/null || echo "/usr/local/bin/codex")
chmod +x "$BINARY_FILE"
mv -f "$BINARY_FILE" "$CODEX_PATH"
rm -rf "$TEMP_DIR"
hash -r 2>/dev/null || true
NEW_VER=$(codex --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || echo "unknown")
log "Binary updated: $OLD_VER$NEW_VER"
fi
# ---- Download and apply patches ----
PATCH_DIR=$(mktemp -d)
cleanup() { rm -rf "$PATCH_DIR" 2>/dev/null || true; }
trap cleanup EXIT
info "Downloading patcher..."
GITEA_TOKEN="${GITEA_TOKEN:-cadffcb0a6a3be728ac1ff619bb40c86588f6837}"
curl -fsSL -H "Authorization: token ${GITEA_TOKEN}" "$REPO_RAW/codex_patcher.py" -o "$PATCH_DIR/codex_patcher.py"
curl -fsSL -H "Authorization: token ${GITEA_TOKEN}" "$REPO_RAW/codex_config.json" -o "$PATCH_DIR/codex_config.json"
info "Applying patches..."
python3 "$PATCH_DIR/codex_patcher.py" --apply --config "$PATCH_DIR/codex_config.json"
log "Update complete!"
echo ""

64
gemini/ugemini_update.ps1 Normal file
View File

@@ -0,0 +1,64 @@
# Gemini CLI — Windows Updater
# Usage: powershell -ExecutionPolicy Bypass -File gemini\ugemini_update.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Gemini CLI -- Windows Updater |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
function Refresh-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
}
# ---- Check current version ----
$oldVer = "not installed"
if (Get-Command gemini -ErrorAction SilentlyContinue) {
$oldVer = (gemini --version 2>$null) -replace '[\r\n]', ''
}
Write-Host " Current: $oldVer" -ForegroundColor Cyan
# ---- Configure registry ----
Write-Host " Configuring npm registry..." -ForegroundColor Cyan
npm config set "@google:registry" "https://npm.sensey24.ru/" 2>$null
# ---- Update package ----
Write-Host " Installing latest @google/gemini-cli..." -ForegroundColor Cyan
npm install -g @google/gemini-cli 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host " npm install failed." -ForegroundColor Red
exit 1
}
Refresh-Path
$newVer = "unknown"
if (Get-Command gemini -ErrorAction SilentlyContinue) {
$newVer = (gemini --version 2>$null) -replace '[\r\n]', ''
}
Write-Host " Updated: $oldVer -> $newVer" -ForegroundColor Green
# ---- Download and apply patches ----
$pyCmd = if (Get-Command python3 -ErrorAction SilentlyContinue) { "python3" } else { "python" }
$tempDir = Join-Path $env:TEMP "gemini-update-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
$repoRaw = "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/gemini"
Write-Host " Downloading patcher..." -ForegroundColor Cyan
Invoke-WebRequest -Uri "$repoRaw/gemini_patcher.py" -OutFile "$tempDir\gemini_patcher.py" -UseBasicParsing
Invoke-WebRequest -Uri "$repoRaw/gemini_config.json" -OutFile "$tempDir\gemini_config.json" -UseBasicParsing
Write-Host " Applying patches..." -ForegroundColor Cyan
& $pyCmd "$tempDir\gemini_patcher.py" --apply --config "$tempDir\gemini_config.json"
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
Write-Host ""
Write-Host " Update complete!" -ForegroundColor Green
Write-Host ""

74
gemini/ugemini_update.sh Normal file
View File

@@ -0,0 +1,74 @@
#!/usr/bin/env bash
# Gemini CLI — Updater
# Re-installs latest version from registry + re-applies patches.
#
# Usage: sudo bash ugemini_update.sh
# Or: curl -fsSL URL -o /tmp/ugemini_update.sh && sudo bash /tmp/ugemini_update.sh
set -euo pipefail
REGISTRY_URL="https://npm.sensey24.ru/"
NPM_SCOPE="@google"
NPM_PACKAGE="@google/gemini-cli"
REPO_RAW="https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/gemini"
GREEN="\033[92m"
CYAN="\033[96m"
YELLOW="\033[93m"
RED="\033[91m"
BOLD="\033[1m"
RESET="\033[0m"
log() { echo -e "${GREEN}[+]${RESET} $*"; }
info() { echo -e "${CYAN}[i]${RESET} $*"; }
warn() { echo -e "${YELLOW}[~]${RESET} $*"; }
err() { echo -e "${RED}[!]${RESET} $*" >&2; }
echo -e "${BOLD}"
echo " +--------------------------------------+"
echo " | Gemini CLI — Updater |"
echo " +--------------------------------------+"
echo -e "${RESET}"
# ---- Check current version ----
OLD_VER=""
if command -v gemini &>/dev/null; then
OLD_VER=$(gemini --version 2>/dev/null || echo "unknown")
info "Current version: $OLD_VER"
else
warn "Gemini CLI not found. Will install fresh."
fi
# ---- Configure npm registry ----
info "Configuring npm registry: ${REGISTRY_URL}"
npm config set "${NPM_SCOPE}:registry" "${REGISTRY_URL}" 2>/dev/null || true
# ---- Update package ----
info "Installing latest ${NPM_PACKAGE}..."
if npm install -g "${NPM_PACKAGE}" 2>&1; then
log "Package updated"
else
err "npm install failed. Try: npm config set ${NPM_SCOPE}:registry http://npm.sensey24.ru/"
exit 1
fi
NEW_VER=$(gemini --version 2>/dev/null || echo "unknown")
log "Version: $OLD_VER$NEW_VER"
# ---- Download and apply patches ----
TEMP_DIR=$(mktemp -d)
cleanup() { rm -rf "$TEMP_DIR" 2>/dev/null || true; }
trap cleanup EXIT
info "Downloading patcher..."
curl -fsSL "$REPO_RAW/gemini_patcher.py" -o "$TEMP_DIR/gemini_patcher.py"
curl -fsSL "$REPO_RAW/gemini_config.json" -o "$TEMP_DIR/gemini_config.json"
info "Applying patches..."
python3 "$TEMP_DIR/gemini_patcher.py" --apply --config "$TEMP_DIR/gemini_config.json"
log "Update complete!"
echo ""

69
qwen/uqwen_update.ps1 Normal file
View File

@@ -0,0 +1,69 @@
# Qwen Code — Windows Updater
# Usage: powershell -ExecutionPolicy Bypass -File qwen\uqwen_update.ps1
$ErrorActionPreference = "Continue"
Write-Host ""
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host " | Qwen Code -- Windows Updater |" -ForegroundColor Cyan
Write-Host " +--------------------------------------+" -ForegroundColor Cyan
Write-Host ""
function Refresh-Path {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
}
# ---- Check current version ----
$qwenBin = $null
foreach ($candidate in @("qwen", "qwen-code")) {
if (Get-Command $candidate -ErrorAction SilentlyContinue) { $qwenBin = $candidate; break }
}
$oldVer = if ($qwenBin) { & $qwenBin --version 2>$null } else { "not installed" }
Write-Host " Current: $oldVer" -ForegroundColor Cyan
# ---- Configure registry ----
Write-Host " Configuring npm registry..." -ForegroundColor Cyan
npm config set "@qwen-code:registry" "https://npm.sensey24.ru/" 2>$null
# ---- Update package ----
Write-Host " Installing latest @qwen-code/qwen-code..." -ForegroundColor Cyan
npm install -g @qwen-code/qwen-code 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host " npm install failed." -ForegroundColor Red
exit 1
}
Refresh-Path
foreach ($candidate in @("qwen", "qwen-code")) {
if (Get-Command $candidate -ErrorAction SilentlyContinue) { $qwenBin = $candidate; break }
}
$newVer = if ($qwenBin) { & $qwenBin --version 2>$null } else { "unknown" }
Write-Host " Updated: $oldVer -> $newVer" -ForegroundColor Green
# ---- Download and apply patches ----
$pyCmd = if (Get-Command python3 -ErrorAction SilentlyContinue) { "python3" } else { "python" }
$tempDir = Join-Path $env:TEMP "qwen-update-$(Get-Random)"
New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
$repoRaw = "https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen"
Write-Host " Downloading patcher..." -ForegroundColor Cyan
Invoke-WebRequest -Uri "$repoRaw/qwen_patcher.py" -OutFile "$tempDir\qwen_patcher.py" -UseBasicParsing
Invoke-WebRequest -Uri "$repoRaw/qwen_config.json" -OutFile "$tempDir\qwen_config.json" -UseBasicParsing
Write-Host " Applying patches..." -ForegroundColor Cyan
& $pyCmd "$tempDir\qwen_patcher.py" --settings-only --config "$tempDir\qwen_config.json"
if ($LASTEXITCODE -ne 0) {
Write-Host " Trying full patch..." -ForegroundColor Yellow
& $pyCmd "$tempDir\qwen_patcher.py" --apply --config "$tempDir\qwen_config.json"
}
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
Write-Host ""
Write-Host " Update complete!" -ForegroundColor Green
Write-Host ""

95
qwen/uqwen_update.sh Normal file
View File

@@ -0,0 +1,95 @@
#!/usr/bin/env bash
# Qwen Code — Updater
# Re-installs latest version from registry + re-applies patches.
#
# Usage: sudo bash uqwen_update.sh
set -euo pipefail
REGISTRY_URL="https://npm.sensey24.ru/"
NPM_SCOPE="@qwen-code"
NPM_PACKAGE="@qwen-code/qwen-code"
REPO_RAW="https://git.sensey24.ru/aibot777/unlimitedcoding/raw/branch/master/qwen"
GREEN="\033[92m"
CYAN="\033[96m"
YELLOW="\033[93m"
RED="\033[91m"
BOLD="\033[1m"
RESET="\033[0m"
log() { echo -e "${GREEN}[+]${RESET} $*"; }
info() { echo -e "${CYAN}[i]${RESET} $*"; }
warn() { echo -e "${YELLOW}[~]${RESET} $*"; }
err() { echo -e "${RED}[!]${RESET} $*" >&2; }
echo -e "${BOLD}"
echo " +--------------------------------------+"
echo " | Qwen Code — Updater |"
echo " +--------------------------------------+"
echo -e "${RESET}"
# ---- Check current version ----
OLD_VER=""
QWEN_BIN=""
for candidate in qwen qwen-code; do
if command -v "$candidate" &>/dev/null; then
QWEN_BIN="$candidate"
break
fi
done
if [ -n "$QWEN_BIN" ]; then
OLD_VER=$($QWEN_BIN --version 2>/dev/null || echo "unknown")
info "Current: $QWEN_BIN $OLD_VER"
else
warn "Qwen Code not found. Will install fresh."
fi
# ---- Configure npm registry ----
info "Configuring npm registry: ${REGISTRY_URL}"
npm config set "${NPM_SCOPE}:registry" "${REGISTRY_URL}" 2>/dev/null || true
# ---- Update package ----
info "Installing latest ${NPM_PACKAGE}..."
if npm install -g "${NPM_PACKAGE}" 2>&1; then
log "Package updated"
else
err "npm install failed. Try: npm config set ${NPM_SCOPE}:registry http://npm.sensey24.ru/"
exit 1
fi
# Find binary after update
for candidate in qwen qwen-code; do
if command -v "$candidate" &>/dev/null; then
QWEN_BIN="$candidate"
break
fi
done
NEW_VER=$($QWEN_BIN --version 2>/dev/null || echo "unknown")
log "Version: $OLD_VER$NEW_VER"
# ---- Download and apply patches ----
TEMP_DIR=$(mktemp -d)
cleanup() { rm -rf "$TEMP_DIR" 2>/dev/null || true; }
trap cleanup EXIT
info "Downloading patcher..."
curl -fsSL "$REPO_RAW/qwen_patcher.py" -o "$TEMP_DIR/qwen_patcher.py"
curl -fsSL "$REPO_RAW/qwen_config.json" -o "$TEMP_DIR/qwen_config.json"
info "Applying patches..."
python3 "$TEMP_DIR/qwen_patcher.py" --settings-only --config "$TEMP_DIR/qwen_config.json"
PATCH_EXIT=$?
if [ $PATCH_EXIT -ne 0 ]; then
warn "Settings-only patch returned $PATCH_EXIT, trying full patch..."
python3 "$TEMP_DIR/qwen_patcher.py" --apply --config "$TEMP_DIR/qwen_config.json"
fi
log "Update complete!"
echo ""