Skip to content

💫 Toolkit to help you get started with SDD or any other process!

Update scripts/powershell/update-agent-context.ps1

Den Delimarsky0672bfc6aa52
diff --git a/scripts/powershell/update-agent-context.ps1 b/scripts/powershell/update-agent-context.ps1
index 9420a227e..9c2447aa7 100644
--- a/scripts/powershell/update-agent-context.ps1
+++ b/scripts/powershell/update-agent-context.ps1
@@ -340,8 +340,12 @@ function Update-AgentFile {
if (-not (Test-Path $TargetFile)) {
if (New-AgentFile -TargetFile $TargetFile -ProjectName $projectName -Date $date) { Write-Success "Created new $AgentName context file" } else { Write-Err 'Failed to create new agent file'; return $false }
} else {
- if (-not (Get-Item $TargetFile).Attributes) { Write-Err "Cannot access existing file: $TargetFile"; return $false }
- if (Update-ExistingAgentFile -TargetFile $TargetFile -Date $date) { Write-Success "Updated existing $AgentName context file" } else { Write-Err 'Failed to update agent file'; return $false }
+ try {
+ if (Update-ExistingAgentFile -TargetFile $TargetFile -Date $date) { Write-Success "Updated existing $AgentName context file" } else { Write-Err 'Failed to update agent file'; return $false }
+ } catch {
+ Write-Err "Cannot access or update existing file: $TargetFile. $_"
+ return $false
+ }
}
return $true
}