fix(update.ps1): replace Unicode with ASCII + null-safety for PS 5.1

PowerShell 5.1 on Russian Windows reads .ps1 files as ANSI (CP1251),
breaking em dashes and box-drawing characters in comments/strings.
Also fix NullArray error when Select-String finds no version match.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-07 15:30:25 +03:00
parent f0161fe821
commit 0a8d8acaa1

View File

@@ -1,4 +1,4 @@
# update.ps1 Full uplift cycle for claude-skills on Windows (PowerShell) # update.ps1 -- Full uplift cycle for claude-skills on Windows (PowerShell)
# #
# Steps: # Steps:
# 1. git pull --ff-only in claude-skills repo # 1. git pull --ff-only in claude-skills repo
@@ -9,7 +9,7 @@
# 6. Print reload hints # 6. Print reload hints
# #
# Usage: update.ps1 [-Yes] # Usage: update.ps1 [-Yes]
# -Yes skip confirmation prompts (assume yes) # -Yes -- skip confirmation prompts (assume yes)
[CmdletBinding()] [CmdletBinding()]
param( param(
@@ -18,7 +18,7 @@ param(
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
# ── Paths ────────────────────────────────────────────────────────────────── # -- Paths -------------------------------------------------------------------
$root = Split-Path -Parent $PSScriptRoot $root = Split-Path -Parent $PSScriptRoot
$skillsSrc = Join-Path $root 'skills' $skillsSrc = Join-Path $root 'skills'
@@ -28,22 +28,21 @@ $commonRoot = if ($env:COMMON_ROOT) { $env:COMMON_ROOT } else { Join-Path $env:U
$metaMcp = Join-Path $commonRoot 'lib\projects-meta-mcp' $metaMcp = Join-Path $commonRoot 'lib\projects-meta-mcp'
$internsMcp = Join-Path $commonRoot 'lib\interns-mcp' $internsMcp = Join-Path $commonRoot 'lib\interns-mcp'
# ── Collect before-versions ──────────────────────────────────────────────── # -- Collect before-versions --------------------------------------------------
$beforeVersions = @{} $beforeVersions = @{}
if (Test-Path $target) { if (Test-Path $target) {
Get-ChildItem -Path $target -Directory | ForEach-Object { Get-ChildItem -Path $target -Directory -ErrorAction SilentlyContinue | ForEach-Object {
$vf = Join-Path $_.FullName 'SKILL.md' $vf = Join-Path $_.FullName 'SKILL.md'
if (Test-Path $vf) { if (Test-Path $vf) {
$ver = (Select-String -Path $vf -Pattern '^version:\s*(\d+\.\d+\.\d+)' | $match = Select-String -Path $vf -Pattern '^version:\s*(\d+\.\d+\.\d+)' -ErrorAction SilentlyContinue | Select-Object -First 1
Select-Object -First 1).Matches.Groups[1].Value $ver = if ($match) { $match.Matches.Groups[1].Value } else { '?' }
if (-not $ver) { $ver = '?' }
$beforeVersions[$_.Name] = $ver $beforeVersions[$_.Name] = $ver
} }
} }
} }
# ── Step 1: git pull ──────────────────────────────────────────────────────── # -- Step 1: git pull ---------------------------------------------------------
Write-Host "`n[update] Pulling claude-skills repo..." -ForegroundColor Cyan Write-Host "`n[update] Pulling claude-skills repo..." -ForegroundColor Cyan
Push-Location $root Push-Location $root
@@ -70,11 +69,11 @@ if ($stashed) {
Write-Host "[update] Popping stashed changes..." -ForegroundColor Cyan Write-Host "[update] Popping stashed changes..." -ForegroundColor Cyan
git stash pop 2>$null git stash pop 2>$null
if ($LASTEXITCODE -ne 0) { if ($LASTEXITCODE -ne 0) {
Write-Host "[warn] Could not pop stash resolve manually" -ForegroundColor Yellow Write-Host "[warn] Could not pop stash -- resolve manually" -ForegroundColor Yellow
} }
} }
# ── Step 2: projects-meta-mcp ───────────────────────────────────────────── # -- Step 2: projects-meta-mcp -----------------------------------------------
$mcpRebuilt = $false $mcpRebuilt = $false
@@ -101,10 +100,10 @@ if (Test-Path (Join-Path $metaMcp '.git')) {
} }
Pop-Location Pop-Location
} else { } else {
Write-Host "[warn] projects-meta-mcp not found at $metaMcp skipping." -ForegroundColor Yellow Write-Host "[warn] projects-meta-mcp not found at $metaMcp -- skipping." -ForegroundColor Yellow
} }
# ── Step 3: interns-mcp ─────────────────────────────────────────────────── # -- Step 3: interns-mcp -----------------------------------------------------
if (Test-Path (Join-Path $internsMcp '.git')) { if (Test-Path (Join-Path $internsMcp '.git')) {
Write-Host "[update] Checking interns-mcp..." -ForegroundColor Cyan Write-Host "[update] Checking interns-mcp..." -ForegroundColor Cyan
@@ -127,26 +126,25 @@ if (Test-Path (Join-Path $internsMcp '.git')) {
} }
Pop-Location Pop-Location
} else { } else {
Write-Host "[warn] interns-mcp not found at $internsMcp skipping." -ForegroundColor Yellow Write-Host "[warn] interns-mcp not found at $internsMcp -- skipping." -ForegroundColor Yellow
} }
# ── Step 4: Install skills ───────────────────────────────────────────────── # -- Step 4: Install skills ---------------------------------------------------
Pop-Location Pop-Location
Write-Host "[update] Installing skills..." -ForegroundColor Cyan Write-Host "[update] Installing skills..." -ForegroundColor Cyan
& "$root\scripts\install.ps1" & "$root\scripts\install.ps1"
Write-Host "[ok] Skills installed." -ForegroundColor Green Write-Host "[ok] Skills installed." -ForegroundColor Green
# ── Step 5: Version diff ─────────────────────────────────────────────────── # -- Step 5: Version diff -----------------------------------------------------
Write-Host "[update] Version diff:" -ForegroundColor Cyan Write-Host "[update] Version diff:" -ForegroundColor Cyan
$changes = $false $changes = $false
Get-ChildItem -Path $target -Directory | ForEach-Object { Get-ChildItem -Path $target -Directory -ErrorAction SilentlyContinue | ForEach-Object {
$vf = Join-Path $_.FullName 'SKILL.md' $vf = Join-Path $_.FullName 'SKILL.md'
if (Test-Path $vf) { if (Test-Path $vf) {
$after = (Select-String -Path $vf -Pattern '^version:\s*(\d+\.\d+\.\d+)' | $match = Select-String -Path $vf -Pattern '^version:\s*(\d+\.\d+\.\d+)' -ErrorAction SilentlyContinue | Select-Object -First 1
Select-Object -First 1).Matches.Groups[1].Value $after = if ($match) { $match.Matches.Groups[1].Value } else { '?' }
if (-not $after) { $after = '?' }
$before = $beforeVersions[$_.Name] $before = $beforeVersions[$_.Name]
if (-not $before) { $before = 'new' } if (-not $before) { $before = 'new' }
if ($before -ne $after) { if ($before -ne $after) {
@@ -159,7 +157,7 @@ if (-not $changes) {
Write-Host ' (no version changes)' Write-Host ' (no version changes)'
} }
# ── Step 6: New setup-skills hint ────────────────────────────────────────── # -- Step 6: New setup-skills hint -------------------------------------------
$newSetup = @() $newSetup = @()
Get-ChildItem -Path $skillsSrc -Directory | ForEach-Object { Get-ChildItem -Path $skillsSrc -Directory | ForEach-Object {
@@ -176,7 +174,7 @@ if ($newSetup.Count -gt 0) {
Write-Host ' Run the setup skill to configure it.' Write-Host ' Run the setup skill to configure it.'
} }
# ── Step 7: Reload hints ────────────────────────────────────────────────── # -- Step 7: Reload hints ----------------------------------------------------
Write-Host '' Write-Host ''
Write-Host '[ok] Update complete!' -ForegroundColor Green Write-Host '[ok] Update complete!' -ForegroundColor Green