From 9f0ef26e4c72d165e70fee307dd62abc6834bf8c Mon Sep 17 00:00:00 2001 From: ericnoam Date: Thu, 2 Apr 2026 21:10:21 +0200 Subject: [PATCH] fix: correct variable scope in PowerShell deduplication and update docs - Fix Update-IfNew in PowerShell update-agent-context.ps1 - Changed from $script: scope to Set-Variable -Scope 1 - Properly mutates parent function's local variables - Fixes deduplication tracking for shared AGENTS.md file - Prevents incorrect default Claude file creation - Update create-release-packages.sh documentation - Add missing 'forge' to AGENTS list in header comment - Documentation now matches actual ALL_AGENTS array Without this fix, AGENTS.md would be updated multiple times (once for each agent sharing it: opencode, codex, amp, kiro, bob, pi, forge) and the script would always create a default Claude file even when agent files exist. --- .github/workflows/scripts/create-release-packages.sh | 2 +- scripts/powershell/update-agent-context.ps1 | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/scripts/create-release-packages.sh b/.github/workflows/scripts/create-release-packages.sh index 482ba7619..0df90881e 100755 --- a/.github/workflows/scripts/create-release-packages.sh +++ b/.github/workflows/scripts/create-release-packages.sh @@ -6,7 +6,7 @@ set -euo pipefail # Usage: .github/workflows/scripts/create-release-packages.sh # Version argument should include leading 'v'. # Optionally set AGENTS and/or SCRIPTS env vars to limit what gets built. -# AGENTS : space or comma separated subset of: claude gemini copilot cursor-agent qwen opencode windsurf junie codex kilocode auggie roo codebuddy amp shai tabnine kiro-cli agy bob vibe qodercli kimi trae pi iflow generic (default: all) +# AGENTS : space or comma separated subset of: claude gemini copilot cursor-agent qwen opencode windsurf junie codex kilocode auggie roo codebuddy amp shai tabnine kiro-cli agy bob vibe qodercli kimi trae pi iflow forge generic (default: all) # SCRIPTS : space or comma separated subset of: sh ps (default: both) # Examples: # AGENTS=claude SCRIPTS=sh $0 v0.2.0 diff --git a/scripts/powershell/update-agent-context.ps1 b/scripts/powershell/update-agent-context.ps1 index ee9109417..63df006cf 100644 --- a/scripts/powershell/update-agent-context.ps1 +++ b/scripts/powershell/update-agent-context.ps1 @@ -447,8 +447,9 @@ function Update-AllExistingAgents { } # Record the file as seen before attempting the update - $script:updatedPaths += $realPath - $script:found = $true + # Use parent scope (1) to modify Update-AllExistingAgents' local variables + Set-Variable -Name updatedPaths -Value ($updatedPaths + $realPath) -Scope 1 + Set-Variable -Name found -Value $true -Scope 1 # Perform the update return (Update-AgentFile -TargetFile $FilePath -AgentName $AgentName)