From de67b1f3893331c302f3bf83863313b1a2a6e4c1 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 30 Apr 2025 22:41:16 +0000 Subject: [PATCH 01/12] - Add verification that command is accessible after installation - Improve PowerShell completion setup with better error handling - Add temporary function to make command available in current session - Provide clear instructions for manual setup if needed - Fix issue where CLI is not recognized after installation Co-Authored-By: jhaynie@agentuity.com --- install.ps1 | 66 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/install.ps1 b/install.ps1 index 4fa8e1d0..86860cb5 100644 --- a/install.ps1 +++ b/install.ps1 @@ -515,6 +515,20 @@ function Set-PowerShellCompletion { } } + # Test that the executable is actually accessible + try { + $testOutput = & $ExePath version 2>&1 + if ($LASTEXITCODE -ne 0) { + Write-Warning "Executable verification failed with exit code $LASTEXITCODE" + throw "Executable verification failed" + } + Write-Success "Verified executable is accessible: $testOutput" + } + catch { + Write-Warning "Failed to execute $ExePath: $_" + throw "Executable verification failed" + } + # Create PowerShell profile directory if it doesn't exist $profileDir = Split-Path -Parent $PROFILE if (-not (Test-Path -Path $profileDir)) { @@ -529,7 +543,20 @@ function Set-PowerShellCompletion { # Generate completion script $completionPath = Join-Path -Path $completionDir -ChildPath "agentuity.ps1" - & $ExePath completion powershell | Out-File -FilePath $completionPath -Encoding utf8 -Force + Write-Step "Generating PowerShell completion script at $completionPath" + + try { + $completionOutput = & $ExePath completion powershell 2>&1 + if ($LASTEXITCODE -ne 0) { + Write-Warning "Failed to generate completion script: $completionOutput" + throw "Completion generation failed" + } + $completionOutput | Out-File -FilePath $completionPath -Encoding utf8 -Force + } + catch { + Write-Warning "Failed to generate completion script: $_" + throw "Completion generation failed" + } # Check if the profile exists, create if not if (-not (Test-Path -Path $PROFILE)) { @@ -543,16 +570,29 @@ function Set-PowerShellCompletion { if (-not $profileContent -or -not $profileContent.Contains($completionLine)) { Add-Content -Path $PROFILE -Value "`n# Agentuity CLI completion`n$completionLine" -Force Write-Success "PowerShell completion installed to $completionPath and added to your profile" + Write-Step "NOTE: You'll need to restart PowerShell or run '. $PROFILE' for completion to take effect in future sessions" } else { Write-Success "PowerShell completion already configured in your profile" } + + # Source the completion script in the current session + try { + . $completionPath + Write-Success "PowerShell completion loaded in current session" + } + catch { + Write-Warning "Failed to load completion in current session: $_" + Write-Warning "Completion will be available in new PowerShell sessions" + } } catch { Write-Warning "Failed to set up PowerShell completion: $_" - Write-Warning "You can manually set up completion by running:" + Write-Warning "You can manually set up completion by running these commands:" + Write-Warning " mkdir -Force $HOME\Documents\WindowsPowerShell\Completion" Write-Warning " $ExePath completion powershell > $HOME\Documents\WindowsPowerShell\Completion\agentuity.ps1" Write-Warning " Add '. `"$HOME\Documents\WindowsPowerShell\Completion\agentuity.ps1`"' to your PowerShell profile" + Write-Warning " To edit your profile, run: notepad $PROFILE" } } @@ -774,8 +814,26 @@ try { exit 1 } - # Success message - Write-Success "Installation complete! Run 'agentuity --help' to get started." + # Final verification that the command is accessible + Write-Step "Verifying command is accessible in current session..." + try { + $verifyOutput = & agentuity version 2>&1 + if ($LASTEXITCODE -eq 0) { + Write-Success "Agentuity CLI is ready to use in the current session!" + Write-Success "Installation complete! Run 'agentuity --help' to get started." + } else { + Write-Warning "Command verification failed with exit code $LASTEXITCODE" + Write-Warning "You may need to restart your PowerShell session or manually add the installation directory to your PATH" + Write-Warning "Installation directory: $installDir" + Write-Warning "To manually add to PATH, run: `$env:PATH += ';$installDir'" + } + } catch { + Write-Warning "Command 'agentuity' is not accessible in the current session: $_" + Write-Warning "You may need to restart your PowerShell session or manually add the installation directory to your PATH" + Write-Warning "Installation directory: $installDir" + Write-Warning "To manually add to PATH, run: `$env:PATH += ';$installDir'" + } + Write-Step "For more information, visit: $(Write-Url "https://agentuity.dev")" } finally { From d3060af93a76d1e581af885a852873bf20276556 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 30 Apr 2025 22:48:22 +0000 Subject: [PATCH 02/12] - Fix PowerShell syntax errors with $_ variable references in catch blocks - Properly escape the automatic variable using $(install.ps1) syntax - Addresses CI failure in Windows PowerShell install script test Co-Authored-By: jhaynie@agentuity.com --- install.ps1 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/install.ps1 b/install.ps1 index 86860cb5..13fce88b 100644 --- a/install.ps1 +++ b/install.ps1 @@ -525,7 +525,7 @@ function Set-PowerShellCompletion { Write-Success "Verified executable is accessible: $testOutput" } catch { - Write-Warning "Failed to execute $ExePath: $_" + Write-Warning "Failed to execute $ExePath: $($_)" throw "Executable verification failed" } @@ -554,7 +554,7 @@ function Set-PowerShellCompletion { $completionOutput | Out-File -FilePath $completionPath -Encoding utf8 -Force } catch { - Write-Warning "Failed to generate completion script: $_" + Write-Warning "Failed to generate completion script: $($_)" throw "Completion generation failed" } @@ -582,12 +582,12 @@ function Set-PowerShellCompletion { Write-Success "PowerShell completion loaded in current session" } catch { - Write-Warning "Failed to load completion in current session: $_" + Write-Warning "Failed to load completion in current session: $($_)" Write-Warning "Completion will be available in new PowerShell sessions" } } catch { - Write-Warning "Failed to set up PowerShell completion: $_" + Write-Warning "Failed to set up PowerShell completion: $($_)" Write-Warning "You can manually set up completion by running these commands:" Write-Warning " mkdir -Force $HOME\Documents\WindowsPowerShell\Completion" Write-Warning " $ExePath completion powershell > $HOME\Documents\WindowsPowerShell\Completion\agentuity.ps1" @@ -650,7 +650,7 @@ if (-not (Test-Path -Path $installDir)) { New-Item -Path $installDir -ItemType Directory -Force | Out-Null } catch { - Write-Error "Failed to create installation directory: $_" -Exit + Write-Error "Failed to create installation directory: $($_)" -Exit } } @@ -684,7 +684,7 @@ try { $webClient.DownloadFile($downloadUrl, $msiPath) } catch { - Write-Error "Failed to download from $downloadUrl`: $_" -Exit + Write-Error "Failed to download from $downloadUrl`: $($_)" -Exit } # Download and verify checksums @@ -710,7 +710,7 @@ try { } } catch { - Write-Warning "Failed to verify checksum: $_" + Write-Warning "Failed to verify checksum: $($_)" if (-not (Get-UserConfirmation -Message "Continue without checksum verification?" -DefaultToYes $false)) { Write-Step "Installation cancelled." @@ -828,7 +828,7 @@ try { Write-Warning "To manually add to PATH, run: `$env:PATH += ';$installDir'" } } catch { - Write-Warning "Command 'agentuity' is not accessible in the current session: $_" + Write-Warning "Command 'agentuity' is not accessible in the current session: $($_)" Write-Warning "You may need to restart your PowerShell session or manually add the installation directory to your PATH" Write-Warning "Installation directory: $installDir" Write-Warning "To manually add to PATH, run: `$env:PATH += ';$installDir'" From 5e8e6a000f6fd52beb25641e21bd87f1f201084f Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 30 Apr 2025 22:54:26 +0000 Subject: [PATCH 03/12] - Fix PowerShell syntax errors with $_ variable references in catch blocks - Properly escape the automatic variable using ${_} syntax instead of $(install.ps1) - Addresses CI failure in Windows PowerShell install script test Co-Authored-By: jhaynie@agentuity.com --- install.ps1 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/install.ps1 b/install.ps1 index 13fce88b..f5818587 100644 --- a/install.ps1 +++ b/install.ps1 @@ -525,7 +525,7 @@ function Set-PowerShellCompletion { Write-Success "Verified executable is accessible: $testOutput" } catch { - Write-Warning "Failed to execute $ExePath: $($_)" + Write-Warning "Failed to execute $ExePath: ${_}" throw "Executable verification failed" } @@ -554,7 +554,7 @@ function Set-PowerShellCompletion { $completionOutput | Out-File -FilePath $completionPath -Encoding utf8 -Force } catch { - Write-Warning "Failed to generate completion script: $($_)" + Write-Warning "Failed to generate completion script: ${_}" throw "Completion generation failed" } @@ -582,12 +582,12 @@ function Set-PowerShellCompletion { Write-Success "PowerShell completion loaded in current session" } catch { - Write-Warning "Failed to load completion in current session: $($_)" + Write-Warning "Failed to load completion in current session: ${_}" Write-Warning "Completion will be available in new PowerShell sessions" } } catch { - Write-Warning "Failed to set up PowerShell completion: $($_)" + Write-Warning "Failed to set up PowerShell completion: ${_}" Write-Warning "You can manually set up completion by running these commands:" Write-Warning " mkdir -Force $HOME\Documents\WindowsPowerShell\Completion" Write-Warning " $ExePath completion powershell > $HOME\Documents\WindowsPowerShell\Completion\agentuity.ps1" @@ -650,7 +650,7 @@ if (-not (Test-Path -Path $installDir)) { New-Item -Path $installDir -ItemType Directory -Force | Out-Null } catch { - Write-Error "Failed to create installation directory: $($_)" -Exit + Write-Error "Failed to create installation directory: ${_}" -Exit } } @@ -684,7 +684,7 @@ try { $webClient.DownloadFile($downloadUrl, $msiPath) } catch { - Write-Error "Failed to download from $downloadUrl`: $($_)" -Exit + Write-Error "Failed to download from $downloadUrl`: ${_}" -Exit } # Download and verify checksums @@ -710,7 +710,7 @@ try { } } catch { - Write-Warning "Failed to verify checksum: $($_)" + Write-Warning "Failed to verify checksum: ${_}" if (-not (Get-UserConfirmation -Message "Continue without checksum verification?" -DefaultToYes $false)) { Write-Step "Installation cancelled." @@ -828,7 +828,7 @@ try { Write-Warning "To manually add to PATH, run: `$env:PATH += ';$installDir'" } } catch { - Write-Warning "Command 'agentuity' is not accessible in the current session: $($_)" + Write-Warning "Command 'agentuity' is not accessible in the current session: ${_}" Write-Warning "You may need to restart your PowerShell session or manually add the installation directory to your PATH" Write-Warning "Installation directory: $installDir" Write-Warning "To manually add to PATH, run: `$env:PATH += ';$installDir'" From 4351823eb237fadc883e3b33f18a48fd5566d258 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 30 Apr 2025 22:57:43 +0000 Subject: [PATCH 04/12] - Remove error variable references in catch blocks to avoid syntax errors - Simplify error messages to ensure compatibility with Windows PowerShell - Addresses CI failure in Windows PowerShell install script test Co-Authored-By: jhaynie@agentuity.com --- install.ps1 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/install.ps1 b/install.ps1 index f5818587..516ba167 100644 --- a/install.ps1 +++ b/install.ps1 @@ -525,7 +525,7 @@ function Set-PowerShellCompletion { Write-Success "Verified executable is accessible: $testOutput" } catch { - Write-Warning "Failed to execute $ExePath: ${_}" + Write-Warning "Failed to execute $ExePath" throw "Executable verification failed" } @@ -554,7 +554,7 @@ function Set-PowerShellCompletion { $completionOutput | Out-File -FilePath $completionPath -Encoding utf8 -Force } catch { - Write-Warning "Failed to generate completion script: ${_}" + Write-Warning "Failed to generate completion script" throw "Completion generation failed" } @@ -582,12 +582,12 @@ function Set-PowerShellCompletion { Write-Success "PowerShell completion loaded in current session" } catch { - Write-Warning "Failed to load completion in current session: ${_}" + Write-Warning "Failed to load completion in current session" Write-Warning "Completion will be available in new PowerShell sessions" } } catch { - Write-Warning "Failed to set up PowerShell completion: ${_}" + Write-Warning "Failed to set up PowerShell completion" Write-Warning "You can manually set up completion by running these commands:" Write-Warning " mkdir -Force $HOME\Documents\WindowsPowerShell\Completion" Write-Warning " $ExePath completion powershell > $HOME\Documents\WindowsPowerShell\Completion\agentuity.ps1" @@ -650,7 +650,7 @@ if (-not (Test-Path -Path $installDir)) { New-Item -Path $installDir -ItemType Directory -Force | Out-Null } catch { - Write-Error "Failed to create installation directory: ${_}" -Exit + Write-Error "Failed to create installation directory" -Exit } } @@ -684,7 +684,7 @@ try { $webClient.DownloadFile($downloadUrl, $msiPath) } catch { - Write-Error "Failed to download from $downloadUrl`: ${_}" -Exit + Write-Error "Failed to download from $downloadUrl" -Exit } # Download and verify checksums @@ -710,7 +710,7 @@ try { } } catch { - Write-Warning "Failed to verify checksum: ${_}" + Write-Warning "Failed to verify checksum" if (-not (Get-UserConfirmation -Message "Continue without checksum verification?" -DefaultToYes $false)) { Write-Step "Installation cancelled." @@ -828,7 +828,7 @@ try { Write-Warning "To manually add to PATH, run: `$env:PATH += ';$installDir'" } } catch { - Write-Warning "Command 'agentuity' is not accessible in the current session: ${_}" + Write-Warning "Command 'agentuity' is not accessible in the current session" Write-Warning "You may need to restart your PowerShell session or manually add the installation directory to your PATH" Write-Warning "Installation directory: $installDir" Write-Warning "To manually add to PATH, run: `$env:PATH += ';$installDir'" From 36f5b1544c968ce165e62eed07da3f1312e69e4f Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 30 Apr 2025 23:07:40 +0000 Subject: [PATCH 05/12] - Use local variable to store exception message in catch blocks - Replace with for better compatibility - Addresses CI failure in Windows PowerShell install script test Co-Authored-By: jhaynie@agentuity.com --- install.ps1 | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/install.ps1 b/install.ps1 index 516ba167..715b733d 100644 --- a/install.ps1 +++ b/install.ps1 @@ -525,7 +525,9 @@ function Set-PowerShellCompletion { Write-Success "Verified executable is accessible: $testOutput" } catch { + $errorMessage = $_.Exception.Message Write-Warning "Failed to execute $ExePath" + Write-Warning "Error: $errorMessage" throw "Executable verification failed" } @@ -554,7 +556,9 @@ function Set-PowerShellCompletion { $completionOutput | Out-File -FilePath $completionPath -Encoding utf8 -Force } catch { + $errorMessage = $_.Exception.Message Write-Warning "Failed to generate completion script" + Write-Warning "Error: $errorMessage" throw "Completion generation failed" } @@ -582,12 +586,16 @@ function Set-PowerShellCompletion { Write-Success "PowerShell completion loaded in current session" } catch { + $errorMessage = $_.Exception.Message Write-Warning "Failed to load completion in current session" + Write-Warning "Error: $errorMessage" Write-Warning "Completion will be available in new PowerShell sessions" } } catch { + $errorMessage = $_.Exception.Message Write-Warning "Failed to set up PowerShell completion" + Write-Warning "Error: $errorMessage" Write-Warning "You can manually set up completion by running these commands:" Write-Warning " mkdir -Force $HOME\Documents\WindowsPowerShell\Completion" Write-Warning " $ExePath completion powershell > $HOME\Documents\WindowsPowerShell\Completion\agentuity.ps1" @@ -650,7 +658,8 @@ if (-not (Test-Path -Path $installDir)) { New-Item -Path $installDir -ItemType Directory -Force | Out-Null } catch { - Write-Error "Failed to create installation directory" -Exit + $errorMessage = $_.Exception.Message + Write-Error "Failed to create installation directory: $errorMessage" -Exit } } @@ -684,7 +693,8 @@ try { $webClient.DownloadFile($downloadUrl, $msiPath) } catch { - Write-Error "Failed to download from $downloadUrl" -Exit + $errorMessage = $_.Exception.Message + Write-Error "Failed to download from $downloadUrl: $errorMessage" -Exit } # Download and verify checksums @@ -710,7 +720,9 @@ try { } } catch { + $errorMessage = $_.Exception.Message Write-Warning "Failed to verify checksum" + Write-Warning "Error: $errorMessage" if (-not (Get-UserConfirmation -Message "Continue without checksum verification?" -DefaultToYes $false)) { Write-Step "Installation cancelled." @@ -828,7 +840,9 @@ try { Write-Warning "To manually add to PATH, run: `$env:PATH += ';$installDir'" } } catch { + $errorMessage = $_.Exception.Message Write-Warning "Command 'agentuity' is not accessible in the current session" + Write-Warning "Error: $errorMessage" Write-Warning "You may need to restart your PowerShell session or manually add the installation directory to your PATH" Write-Warning "Installation directory: $installDir" Write-Warning "To manually add to PATH, run: `$env:PATH += ';$installDir'" From d812fb82335f08b88018f158a42e017dcca8f0bd Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 30 Apr 2025 23:26:04 +0000 Subject: [PATCH 06/12] Fix PowerShell variable references with proper ${} syntax for colon handling Co-Authored-By: jhaynie@agentuity.com --- install.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/install.ps1 b/install.ps1 index 715b733d..3356bba7 100644 --- a/install.ps1 +++ b/install.ps1 @@ -694,7 +694,7 @@ try { } catch { $errorMessage = $_.Exception.Message - Write-Error "Failed to download from $downloadUrl: $errorMessage" -Exit + Write-Error "Failed to download from ${downloadUrl}: ${errorMessage}" -Exit } # Download and verify checksums @@ -713,7 +713,7 @@ try { Write-Warning "Checksum for $downloadFilename not found in checksums.txt. Skipping verification." } elseif ($computedChecksum -ne $expectedChecksum) { - Write-Error "Checksum verification failed. Expected: $expectedChecksum, Got: $computedChecksum" -Exit + Write-Error "Checksum verification failed. Expected: ${expectedChecksum}, Got: ${computedChecksum}" -Exit } else { Write-Success "Checksum verification passed!" @@ -822,7 +822,7 @@ try { if (-not $installVerified) { Write-Error "Failed to verify installation. The MSI may have installed to a different location or failed silently." - Write-Warning "Please check the installation log at $env:TEMP\agentuity_install.log for details." + Write-Warning "Please check the installation log at ${env:TEMP}\agentuity_install.log for details." exit 1 } @@ -837,7 +837,7 @@ try { Write-Warning "Command verification failed with exit code $LASTEXITCODE" Write-Warning "You may need to restart your PowerShell session or manually add the installation directory to your PATH" Write-Warning "Installation directory: $installDir" - Write-Warning "To manually add to PATH, run: `$env:PATH += ';$installDir'" + Write-Warning "To manually add to PATH, run: `${env:PATH} += ';${installDir}'" } } catch { $errorMessage = $_.Exception.Message @@ -845,7 +845,7 @@ try { Write-Warning "Error: $errorMessage" Write-Warning "You may need to restart your PowerShell session or manually add the installation directory to your PATH" Write-Warning "Installation directory: $installDir" - Write-Warning "To manually add to PATH, run: `$env:PATH += ';$installDir'" + Write-Warning "To manually add to PATH, run: `${env:PATH} += ';${installDir}'" } Write-Step "For more information, visit: $(Write-Url "https://agentuity.dev")" From ee1378a11e4562b674016bcf8a7da9e5c50e9539 Mon Sep 17 00:00:00 2001 From: Jeff Haynie Date: Wed, 30 Apr 2025 18:54:46 -0500 Subject: [PATCH 07/12] a few small tweaks to test --- install.ps1 | 81 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 24 deletions(-) diff --git a/install.ps1 b/install.ps1 index 3356bba7..a589c73c 100644 --- a/install.ps1 +++ b/install.ps1 @@ -269,9 +269,6 @@ function Add-ToPath { $newSystemPath = "$systemPath;$PathToAdd" [Environment]::SetEnvironmentVariable("PATH", $newSystemPath, [EnvironmentVariableTarget]::Machine) Write-Success "Added to system PATH" - - # Also update current session - $env:PATH = "$env:PATH;$PathToAdd" } else { # User PATH update (doesn't require admin) @@ -279,38 +276,68 @@ function Add-ToPath { $newUserPath = "$userPath;$PathToAdd" [Environment]::SetEnvironmentVariable("PATH", $newUserPath, [EnvironmentVariableTarget]::User) Write-Success "Added to user PATH" - - # Also update current session - $env:PATH = "$env:PATH;$PathToAdd" } + + # Update current session PATH + $env:PATH = "$env:PATH;$PathToAdd" - # Refresh PowerShell's command discovery to make the command immediately available - # This creates a temporary function with the same name as the executable to force PowerShell to refresh - $exeName = "agentuity" + # Force PowerShell to refresh its command discovery + $ExecutionContext.SessionState.InvokeCommand.ClearCommandCache() + + Write-Success "Command 'agentuity' is now available in the current session" + } + catch { + Write-Error "Failed to update PATH: $_" + Write-Warning "You may need to manually add $PathToAdd to your PATH environment variable." + } +} + +function Load-InCurrentSession { + param ( + [Parameter(Mandatory = $true)] + [string]$ExePath + ) + + Write-Step "Loading Agentuity CLI in current session..." + + try { + # Verify the executable exists + if (-not (Test-Path -Path $ExePath)) { + Write-Warning "Executable not found at $ExePath" + return $false + } - # Remove any existing function with this name first - if (Get-Command $exeName -ErrorAction SilentlyContinue) { - if ((Get-Command $exeName).CommandType -eq "Function") { - Remove-Item -Path "Function:\$exeName" -ErrorAction SilentlyContinue + # Test that the executable is actually accessible + try { + $testOutput = & $ExePath version 2>&1 + if ($LASTEXITCODE -ne 0) { + Write-Warning "Executable verification failed with exit code $LASTEXITCODE" + return $false } + Write-Success "Verified executable is accessible: $testOutput" + } + catch { + Write-Warning "Failed to execute $ExePath" + Write-Warning "Error: $($_.Exception.Message)" + return $false } # Create a temporary function that will redirect to the actual executable $scriptBlock = { param($argumentList) - & "$PathToAdd\$exeName.exe" @argumentList - # Remove this function after first use to ensure future calls use the actual executable - Remove-Item -Path "Function:\$exeName" -ErrorAction SilentlyContinue + & $ExePath @argumentList } - # Register the function using the Function: drive instead of global: scope - Set-Item -Path "Function:\$exeName" -Value $scriptBlock -Force + # Register the function in the current session + Set-Item -Path "Function:\agentuity" -Value $scriptBlock -Force - Write-Success "Command '$exeName' is now available in the current PowerShell session" + Write-Success "Agentuity CLI loaded in current session" + return $true } catch { - Write-Error "Failed to update PATH: $_" - Write-Warning "You may need to manually add $PathToAdd to your PATH environment variable." + Write-Warning "Failed to load Agentuity CLI in current session" + Write-Warning "Error: $($_.Exception.Message)" + return $false } } @@ -685,7 +712,7 @@ New-Item -Path $tempDir -ItemType Directory -Force | Out-Null try { # Download MSI installer $msiPath = Join-Path -Path $tempDir -ChildPath $downloadFilename - Write-Step "Downloading Agentuity CLI v${Version} for Windows/$arch..." + Write-Step "Downloading Agentuity CLI v${VersionToUse} for Windows/$arch..." try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 @@ -751,7 +778,7 @@ try { $programFilesX86Path = [System.IO.Path]::Combine(${env:ProgramFiles(x86)}, "Agentuity") $localAppDataPath = [System.IO.Path]::Combine($env:LOCALAPPDATA, "Agentuity") - $installPaths = @($programFilesPath, $programFilesX86Path, $localAppDataPath, $installDir) + $installPaths = @($programFilesX86Path, $programFilesPath, $localAppDataPath, $installDir) $installVerified = $false # In CI environment, list all paths being checked @@ -783,7 +810,10 @@ try { # Add to PATH if not already there Add-ToPath -PathToAdd $path - + + # Load in current session + Load-InCurrentSession -ExePath $exePath + # Set up PowerShell completion Set-PowerShellCompletion -ExePath $exePath @@ -809,6 +839,9 @@ try { # Add to PATH if not already there Add-ToPath -PathToAdd $installDir + # Load in current session + Load-InCurrentSession -ExePath $exePath + # Set up PowerShell completion Set-PowerShellCompletion -ExePath $exePath From 663f9e64e344f52932b6c0274c93b2aff6eebeb4 Mon Sep 17 00:00:00 2001 From: Jeff Haynie Date: Wed, 30 Apr 2025 19:00:01 -0500 Subject: [PATCH 08/12] attempt to fix issue with set env var --- install.ps1 | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/install.ps1 b/install.ps1 index a589c73c..95512233 100644 --- a/install.ps1 +++ b/install.ps1 @@ -227,6 +227,15 @@ function Get-Architecture { function Get-DefaultInstallDir { if ([string]::IsNullOrEmpty($InstallDir)) { if (Test-Administrator) { + $programFilesX86Path = [System.IO.Path]::Combine(${env:ProgramFiles(x86)}, "Agentuity") + if (Test-Path -Path $programFilesX86Path) { + return $programFilesX86Path + } + else { + return [System.IO.Path]::Combine($env:ProgramFiles, "Agentuity") + } + } + else { # Return the standard Program Files path by default return [System.IO.Path]::Combine($env:ProgramFiles, "Agentuity") } @@ -280,9 +289,23 @@ function Add-ToPath { # Update current session PATH $env:PATH = "$env:PATH;$PathToAdd" - + # Force PowerShell to refresh its command discovery - $ExecutionContext.SessionState.InvokeCommand.ClearCommandCache() + # Remove any existing function with this name first + if (Get-Command "agentuity" -ErrorAction SilentlyContinue) { + if ((Get-Command "agentuity").CommandType -eq "Function") { + Remove-Item -Path "Function:\agentuity" -ErrorAction SilentlyContinue + } + } + + # Create a temporary function that will redirect to the actual executable + $scriptBlock = { + param($argumentList) + & (Join-Path -Path $PathToAdd -ChildPath "agentuity.exe") @argumentList + } + + # Register the function in the current session + Set-Item -Path "Function:\agentuity" -Value $scriptBlock -Force Write-Success "Command 'agentuity' is now available in the current session" } @@ -759,7 +782,7 @@ try { # Confirm installation if (-not $NoPrompt) { - $confirmMessage = "Ready to install Agentuity CLI v${Version} to $installDir. Continue?" + $confirmMessage = "Ready to install Agentuity CLI v${VersionToUse} to $installDir. Continue?" if (-not (Get-UserConfirmation -Message $confirmMessage -DefaultToYes $true)) { Write-Step "Installation cancelled." exit 0 From aed76727ff47d0608c8b041ba89793a1f524607e Mon Sep 17 00:00:00 2001 From: Jeff Haynie Date: Wed, 30 Apr 2025 19:03:38 -0500 Subject: [PATCH 09/12] test the program files x86 --- install.ps1 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/install.ps1 b/install.ps1 index 95512233..a75750d0 100644 --- a/install.ps1 +++ b/install.ps1 @@ -227,18 +227,15 @@ function Get-Architecture { function Get-DefaultInstallDir { if ([string]::IsNullOrEmpty($InstallDir)) { if (Test-Administrator) { - $programFilesX86Path = [System.IO.Path]::Combine(${env:ProgramFiles(x86)}, "Agentuity") + $programFilesX86Path = [System.IO.Path]::Combine(${env:ProgramFiles(x86)}) if (Test-Path -Path $programFilesX86Path) { - return $programFilesX86Path + return [System.IO.Path]::Combine(${env:ProgramFiles(x86)}, "Agentuity") } else { + # Return the standard Program Files path by default return [System.IO.Path]::Combine($env:ProgramFiles, "Agentuity") } } - else { - # Return the standard Program Files path by default - return [System.IO.Path]::Combine($env:ProgramFiles, "Agentuity") - } else { return [System.IO.Path]::Combine($env:LOCALAPPDATA, "Agentuity") } From 90279ec194d846cbfdb061c327b0f7dedf7d09b1 Mon Sep 17 00:00:00 2001 From: Jeff Haynie Date: Wed, 30 Apr 2025 19:07:11 -0500 Subject: [PATCH 10/12] try and test execution policy --- install.ps1 | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/install.ps1 b/install.ps1 index a75750d0..89f6ef55 100644 --- a/install.ps1 +++ b/install.ps1 @@ -539,6 +539,38 @@ function Test-Installation { } } +function Test-ExecutionPolicy { + $currentPolicy = Get-ExecutionPolicy + $allowedPolicies = @("Unrestricted", "RemoteSigned", "Bypass") + + if ($allowedPolicies -contains $currentPolicy) { + return $true + } + + Write-Warning "PowerShell execution policy is set to '$currentPolicy' which may prevent script execution." + Write-Warning "Allowed policies are: $($allowedPolicies -join ', ')" + + if ($NoPrompt) { + Write-Warning "Skipping PowerShell completion setup due to execution policy restrictions" + return $false + } + + $message = "Would you like to temporarily set the execution policy to 'RemoteSigned' for this session?" + if (Get-UserConfirmation -Message $message -DefaultToYes $true) { + try { + Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned -Force + Write-Success "Temporarily set execution policy to RemoteSigned for this session" + return $true + } + catch { + Write-Warning "Failed to set execution policy: $_" + return $false + } + } + + return $false +} + function Set-PowerShellCompletion { param ( [Parameter(Mandatory = $true)] @@ -547,6 +579,17 @@ function Set-PowerShellCompletion { Write-Step "Setting up PowerShell completion..." + # Check execution policy first + if (-not (Test-ExecutionPolicy)) { + Write-Warning "Skipping PowerShell completion setup due to execution policy restrictions" + Write-Warning "You can manually set up completion by running these commands:" + Write-Warning " mkdir -Force $HOME\Documents\WindowsPowerShell\Completion" + Write-Warning " $ExePath completion powershell > $HOME\Documents\WindowsPowerShell\Completion\agentuity.ps1" + Write-Warning " Add '. `"$HOME\Documents\WindowsPowerShell\Completion\agentuity.ps1`"' to your PowerShell profile" + Write-Warning " To edit your profile, run: notepad $PROFILE" + return + } + try { # Verify the executable exists if (-not (Test-Path -Path $ExePath)) { From 805f544939dfca9c964258f531987894fc87bae8 Mon Sep 17 00:00:00 2001 From: Jeff Haynie Date: Wed, 30 Apr 2025 19:11:29 -0500 Subject: [PATCH 11/12] dont print output --- install.ps1 | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/install.ps1 b/install.ps1 index 89f6ef55..5c33b52a 100644 --- a/install.ps1 +++ b/install.ps1 @@ -324,7 +324,7 @@ function Load-InCurrentSession { # Verify the executable exists if (-not (Test-Path -Path $ExePath)) { Write-Warning "Executable not found at $ExePath" - return $false + return } # Test that the executable is actually accessible @@ -332,14 +332,14 @@ function Load-InCurrentSession { $testOutput = & $ExePath version 2>&1 if ($LASTEXITCODE -ne 0) { Write-Warning "Executable verification failed with exit code $LASTEXITCODE" - return $false + return } Write-Success "Verified executable is accessible: $testOutput" } catch { Write-Warning "Failed to execute $ExePath" Write-Warning "Error: $($_.Exception.Message)" - return $false + return } # Create a temporary function that will redirect to the actual executable @@ -352,12 +352,10 @@ function Load-InCurrentSession { Set-Item -Path "Function:\agentuity" -Value $scriptBlock -Force Write-Success "Agentuity CLI loaded in current session" - return $true } catch { Write-Warning "Failed to load Agentuity CLI in current session" Write-Warning "Error: $($_.Exception.Message)" - return $false } } From f0b6b6be2cd8726e7d36e55a83debd5c34fc0c8e Mon Sep 17 00:00:00 2001 From: Jeff Haynie Date: Wed, 30 Apr 2025 19:13:23 -0500 Subject: [PATCH 12/12] update the url --- install.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.ps1 b/install.ps1 index 5c33b52a..d18e81fa 100644 --- a/install.ps1 +++ b/install.ps1 @@ -22,7 +22,7 @@ Installs the latest version of Agentuity CLI to C:\Tools. .NOTES Author: Agentuity, Inc. - Website: https://agentuity.dev + Website: https://agentuity.com #> [CmdletBinding()]