fix(plugins): detect npm global CLIs in plugin selection
The plugin selection checked CLI extensions such as MCPorter only on PATH, so it showed them unchecked when npm's global bin directory was missing from PATH, even though the installer already finds them there. Fall back to the npm global prefix in both PowerShell and Bash. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
870cad66ac
commit
adc4745d10
4 files changed
+51
-2
No files matched your search
+12
-1
@@ -66,6 +66,17 @@ function Get-InstalledPlugins {
|
||||
}
|
||||
}
|
||||
|
||||
function Test-CliCommand {
|
||||
param([Parameter(Mandatory=$true)][string]$Name)
|
||||
if (Get-Command $Name -ErrorAction SilentlyContinue) { return $true }
|
||||
# npm's global bin directory is often missing from PATH on Windows; match managed-extensions.py find_executable.
|
||||
if (-not (Get-Command npm -ErrorAction SilentlyContinue)) { return $false }
|
||||
$prefix = @(& npm prefix --global 2>$null | ForEach-Object { "$_".Trim() } | Where-Object { $_ }) | Select-Object -Last 1
|
||||
if (-not $prefix) { return $false }
|
||||
$directory = if ([Environment]::OSVersion.Platform -eq [PlatformID]::Win32NT) { $prefix } else { Join-Path $prefix 'bin' }
|
||||
return [bool](@('', '.cmd', '.exe', '.ps1') | Where-Object { Test-Path -LiteralPath (Join-Path $directory ($Name + $_)) -PathType Leaf })
|
||||
}
|
||||
|
||||
function Test-InstalledMCPServer {
|
||||
param([string]$HomePath, [string]$Name, [string]$Url)
|
||||
$path = Join-Path $HomePath '.mcporter/mcporter.json'
|
||||
@@ -119,7 +130,7 @@ function Select-ConfiguredPlugins {
|
||||
if ($Mode -eq 'Update') { foreach ($referenceClient in $referenceClients) { $installed[$referenceClient] = @(Get-InstalledPlugins -Client $referenceClient -HomePath $HomePath) } }
|
||||
$checked = @($toggleable | ForEach-Object {
|
||||
if ($Mode -eq 'Install') { $true; return }
|
||||
if ($_.codex_method -eq 'cli') { return $null -ne (Get-Command $_.codex_source -ErrorAction SilentlyContinue) }
|
||||
if ($_.codex_method -eq 'cli') { return Test-CliCommand -Name $_.codex_source }
|
||||
$entry = $_
|
||||
$found = if ($entry.mcporter_name -and $entry.mcporter_url) {
|
||||
Test-InstalledMCPServer -HomePath $HomePath -Name $entry.mcporter_name -Url $entry.mcporter_url
|
||||
|
||||
Reference in new issue
Block a user