From 88c254c2c263363ead4d41749d1ea428cec081e2 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Fri, 16 May 2025 11:55:44 -0700 Subject: [PATCH 1/2] Update install script to install PSRL if needed --- tools/scripts/install-aishell.ps1 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/scripts/install-aishell.ps1 b/tools/scripts/install-aishell.ps1 index 3d1317fc..77856d36 100644 --- a/tools/scripts/install-aishell.ps1 +++ b/tools/scripts/install-aishell.ps1 @@ -19,6 +19,8 @@ $Script:WinInstallationLocation = "$env:LOCALAPPDATA\Programs\AIShell" $Script:InstallLocation = $null $Script:PackageURL = $null $Script:ModuleVersion = $null +$Script:NewPSRLInstalled = $false +$Script:PSRLDependencyMap = @{ '1.0.4-preview4' = '2.4.2-beta2' } function Resolve-Environment { if ($PSVersionTable.PSVersion -lt [version]"7.4.6") { @@ -209,6 +211,18 @@ function Install-AIShellModule { Write-Host "Installing the PowerShell module 'AIShell' $modVersion ..." Install-PSResource -Name AIShell -Repository PSGallery -Prerelease -TrustRepository -Version $modVersion -ErrorAction Stop -WarningAction SilentlyContinue + $psrldep = $Script:PSRLDependencyMap[$modVersion] + if ($psrldep) { + $psrlModule = Get-Module -Name PSReadLine + $psrlVer = $psrldep.Contains('-') ? $psrldep.Split('-')[0] : $psrldep + if ($null -eq $psrlModule -or $psrlModule.Version -lt [version]$psrlVer) { + Write-Host " - This version of AIShell module depends on PSReadLine '$psrldep', which is missing." + Write-Host " Installing the PowerShell module 'PSReadLine' $psrldep ..." + Install-PSResource -Name PSReadLine -Repository PSGallery -Prerelease -TrustRepository -Version $psrldep -ErrorAction Stop -WarningAction SilentlyContinue + $Script:NewPSRLInstalled = $true + } + } + if ($IsMacOS) { Write-Host -ForegroundColor Yellow "NOTE: The 'AIShell' PowerShell module only works in iTerm2 terminal in order to provide the sidecar experience." } @@ -249,4 +263,10 @@ Installation succeeded. To learn more about AI Shell please visit https://aka.ms/AIShell-Docs. To get started, please run 'Start-AIShell' to use the sidecar experience${condition}, or run 'aish' to use the standalone experience. "@ + if ($Script:NewPSRLInstalled) { + Write-Host -ForegroundColor Yellow -Object @" +NOTE: A new version of the PSReadLine module was installed as a dependency. +To ensure the new PSReadLine gets used, please run 'Start-AIShell' from a new session. +"@ + } } From 1d539fb3d3dc14535c57683fafd61940bc9350be Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Fri, 16 May 2025 12:20:12 -0700 Subject: [PATCH 2/2] Make the dependency version the minimum inclusive version --- tools/scripts/install-aishell.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/scripts/install-aishell.ps1 b/tools/scripts/install-aishell.ps1 index 77856d36..4a24a57c 100644 --- a/tools/scripts/install-aishell.ps1 +++ b/tools/scripts/install-aishell.ps1 @@ -216,9 +216,9 @@ function Install-AIShellModule { $psrlModule = Get-Module -Name PSReadLine $psrlVer = $psrldep.Contains('-') ? $psrldep.Split('-')[0] : $psrldep if ($null -eq $psrlModule -or $psrlModule.Version -lt [version]$psrlVer) { - Write-Host " - This version of AIShell module depends on PSReadLine '$psrldep', which is missing." - Write-Host " Installing the PowerShell module 'PSReadLine' $psrldep ..." - Install-PSResource -Name PSReadLine -Repository PSGallery -Prerelease -TrustRepository -Version $psrldep -ErrorAction Stop -WarningAction SilentlyContinue + Write-Host " - This version of AIShell module depends on PSReadLine '$psrldep' or higher, which is missing." + Write-Host " Installing the PowerShell module 'PSReadLine' $psrldep or a higher version ..." + Install-PSResource -Name PSReadLine -Repository PSGallery -Prerelease -TrustRepository -Version "[$psrldep, ]" -ErrorAction Stop -WarningAction SilentlyContinue $Script:NewPSRLInstalled = $true } }