diff --git a/scripts/update.ps1 b/scripts/update.ps1 index ae7f518..4a89cac 100644 --- a/scripts/update.ps1 +++ b/scripts/update.ps1 @@ -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: # 1. git pull --ff-only in claude-skills repo @@ -9,7 +9,7 @@ # 6. Print reload hints # # Usage: update.ps1 [-Yes] -# -Yes — skip confirmation prompts (assume yes) +# -Yes -- skip confirmation prompts (assume yes) [CmdletBinding()] param( @@ -18,7 +18,7 @@ param( $ErrorActionPreference = 'Stop' -# ── Paths ────────────────────────────────────────────────────────────────── +# -- Paths ------------------------------------------------------------------- $root = Split-Path -Parent $PSScriptRoot $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' $internsMcp = Join-Path $commonRoot 'lib\interns-mcp' -# ── Collect before-versions ──────────────────────────────────────────────── +# -- Collect before-versions -------------------------------------------------- $beforeVersions = @{} 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' if (Test-Path $vf) { - $ver = (Select-String -Path $vf -Pattern '^version:\s*(\d+\.\d+\.\d+)' | - Select-Object -First 1).Matches.Groups[1].Value - if (-not $ver) { $ver = '?' } + $match = Select-String -Path $vf -Pattern '^version:\s*(\d+\.\d+\.\d+)' -ErrorAction SilentlyContinue | Select-Object -First 1 + $ver = if ($match) { $match.Matches.Groups[1].Value } else { '?' } $beforeVersions[$_.Name] = $ver } } } -# ── Step 1: git pull ──────────────────────────────────────────────────────── +# -- Step 1: git pull --------------------------------------------------------- Write-Host "`n[update] Pulling claude-skills repo..." -ForegroundColor Cyan Push-Location $root @@ -70,11 +69,11 @@ if ($stashed) { Write-Host "[update] Popping stashed changes..." -ForegroundColor Cyan git stash pop 2>$null 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 @@ -101,10 +100,10 @@ if (Test-Path (Join-Path $metaMcp '.git')) { } Pop-Location } 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')) { Write-Host "[update] Checking interns-mcp..." -ForegroundColor Cyan @@ -127,26 +126,25 @@ if (Test-Path (Join-Path $internsMcp '.git')) { } Pop-Location } 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 Write-Host "[update] Installing skills..." -ForegroundColor Cyan & "$root\scripts\install.ps1" Write-Host "[ok] Skills installed." -ForegroundColor Green -# ── Step 5: Version diff ─────────────────────────────────────────────────── +# -- Step 5: Version diff ----------------------------------------------------- Write-Host "[update] Version diff:" -ForegroundColor Cyan $changes = $false -Get-ChildItem -Path $target -Directory | ForEach-Object { +Get-ChildItem -Path $target -Directory -ErrorAction SilentlyContinue | ForEach-Object { $vf = Join-Path $_.FullName 'SKILL.md' if (Test-Path $vf) { - $after = (Select-String -Path $vf -Pattern '^version:\s*(\d+\.\d+\.\d+)' | - Select-Object -First 1).Matches.Groups[1].Value - if (-not $after) { $after = '?' } + $match = Select-String -Path $vf -Pattern '^version:\s*(\d+\.\d+\.\d+)' -ErrorAction SilentlyContinue | Select-Object -First 1 + $after = if ($match) { $match.Matches.Groups[1].Value } else { '?' } $before = $beforeVersions[$_.Name] if (-not $before) { $before = 'new' } if ($before -ne $after) { @@ -159,7 +157,7 @@ if (-not $changes) { Write-Host ' (no version changes)' } -# ── Step 6: New setup-skills hint ────────────────────────────────────────── +# -- Step 6: New setup-skills hint ------------------------------------------- $newSetup = @() 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.' } -# ── Step 7: Reload hints ────────────────────────────────────────────────── +# -- Step 7: Reload hints ---------------------------------------------------- Write-Host '' Write-Host '[ok] Update complete!' -ForegroundColor Green