1 Commits

Author SHA1 Message Date
小橙子
4dd2ebd579
fix(plugins): smart 'Install all' with PATH refresh + per-manager fallthrough (#14)
User report: clicking 'Install all' on the reverse-engineering plugin's

missing-prereq modal showed cascading 'X command not found' errors even

after winget reported success — root cause was that the running terminal's

PATH never refreshed, so the next probe / install command couldn't see the

newly-installed binary. Compounded by the fact that the user's host had

neither winget nor scoop, and the deduped prereq row only carried the

first-encountered server's install map, dropping the powershell 'irm | iex'

fallback that ghidra's manifest declared.

Two coordinated fixes:

1. Server: pluginService.checkPluginPrerequisites now MERGES install maps

   across all servers declaring the same command (deduped by manager+cmd).

   So uvx now surfaces winget + scoop + powershell-irm together in the

   modal, not just the first server's two-step list.

2. Desktop: new smartInstallScript helper builds ONE base64-encoded

   PowerShell wrapper that:

   - Probes each missing command BEFORE running its installer (idempotent

     re-clicks, partial state)

   - For each install option in declared order, first checks whether the

     manager itself is on PATH; if not, skips the option silently with a

     yellow 'manager not on PATH' note instead of letting the user see

     'winget: command not found'

   - After each install attempt, reloads PATH from machine + user

     registry into the running PowerShell process — fixes the root issue

   - Auto-appends winget non-interactive flags so the install doesn't

     hang on license confirmation

   - Walks all install options until one produces the binary on PATH

   - Prints a colored summary (already-installed / installed-via-X / failed)

On Windows, the modal switches to this single-encoded-command path.

On macOS/Linux it keeps the existing per-command injection (POSIX shells

respect PATH updates from install scripts themselves, no equivalent

issue).

End-to-end exerciser: scripts/test-mcp-install.ps1 fetches a plugin's

live prereq state from the local API server, prints the smart-install

plan with manager-availability annotations, and (with -Run) executes

the wrapper for real, then re-fetches to verify post-install state.

Tested:

- bun test src/server/services/pluginService.test.ts: 5/5 (mergeInstallMap)

- bun test desktop/src/lib/smartInstallScript.test.ts: 11/11

- Live dry-run via test-mcp-install.ps1 against reverse-engineering

  plugin: shows winget+scoop+powershell-irm fallback chain for uvx as

  expected (merged from ghidra + lldb + jadx + apktool + frida)

- Desktop tsc --noEmit clean

Confidence: high. Scope-risk: narrow.

Tested: scripts/test-mcp-install.ps1 -Plugin reverse-engineering (dry run)

Not-tested: -Run path against a fresh VM (the install commands themselves

are unchanged data; only the wrapper logic changed).

Co-authored-by: 你的姓名 <you@example.com>
2026-06-11 21:29:07 +08:00