Commit f6f95b1
refactor(proxy): single BuildInitCommand for every non-Windows launcher
The PowerShell init script that bootstraps PowerShell.MCP into a freshly
launched pwsh used to live in three near-identical inline copies. macOS
extracted it to PwshLauncherMacOS.BuildInitCommand back when issue #45
was fixed (see April 2026 work) but the Linux terminal path and the
Linux headless path each kept their own inline construction, drifted in
two ways:
- agentId went into the script unescaped — `IsValidAgentId` keeps the
current ID format quote-free in practice, but the safety net the
macOS path has (escapedAgentId) was missing on Linux, so a future ID
format change would break only the Linux launches.
- The headless path skipped Set-Location and Remove-Module PSReadLine
entirely. Set-Location was substituted with -WorkingDirectory, but
the PSReadLine cleanup was just absent.
Move BuildInitCommand from PwshLauncherMacOS into PwshLauncherShared
so all three call sites (macOS tempFile, Linux Base64, Linux headless
ArgumentList) build the script body the same way. Each platform keeps
its own delivery mechanism for documented reasons:
Windows pwsh.exe -Command "<inline>" (Win32, no shell layer)
macOS pwsh -File '/tmp/.../init.ps1' (AppleScript do script
echoes the command line —
Base64 would dump 1.2KB of
noise into Terminal.app)
Linux pwsh -EncodedCommand <base64> (setsid <terminal> -- <shell>
-l -c '<pwsh>' multi-shell
quoting through `sh -c` is
the original reason for the
encoding hop)
Linux pwsh -Command <init> (headless / ArgumentList path,
no shell layer at all)
Renamed the existing PwshLauncherMacOSTests file to
PwshLauncherSharedTests since the helper is no longer macOS-specific.
The 4 quoting / case-fix regression tests now cover every platform
that calls BuildInitCommand, and a single change to the script body
will cause exactly one test file to fail loudly instead of silently
diverging across launchers.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent bc53485 commit f6f95b1
3 files changed
Lines changed: 94 additions & 101 deletions
File tree
- PowerShell.MCP.Proxy/Services
- Tests/Unit/Proxy
Lines changed: 31 additions & 43 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
177 | 195 | | |
178 | 196 | | |
179 | 197 | | |
| |||
326 | 344 | | |
327 | 345 | | |
328 | 346 | | |
329 | | - | |
| 347 | + | |
330 | 348 | | |
331 | 349 | | |
332 | 350 | | |
| |||
351 | 369 | | |
352 | 370 | | |
353 | 371 | | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | 372 | | |
367 | 373 | | |
368 | 374 | | |
| |||
437 | 443 | | |
438 | 444 | | |
439 | 445 | | |
440 | | - | |
441 | | - | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
442 | 450 | | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
| 451 | + | |
461 | 452 | | |
462 | 453 | | |
463 | 454 | | |
| |||
537 | 528 | | |
538 | 529 | | |
539 | 530 | | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
540 | 537 | | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
| 538 | + | |
549 | 539 | | |
550 | 540 | | |
551 | 541 | | |
| |||
557 | 547 | | |
558 | 548 | | |
559 | 549 | | |
560 | | - | |
561 | | - | |
562 | 550 | | |
563 | 551 | | |
564 | 552 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
0 commit comments