-
Notifications
You must be signed in to change notification settings - Fork 1
Add Linux and macOS PowerShell host support #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,7 @@ param( | |||||||||||
|
|
||||||||||||
| Set-StrictMode -Version Latest | ||||||||||||
| $ErrorActionPreference = "Stop" | ||||||||||||
| $script:IsWindowsPlatform = [System.IO.Path]::DirectorySeparatorChar -eq '\' | ||||||||||||
|
|
||||||||||||
| $FallbackPrincipalEngineerDirective = @' | ||||||||||||
| You are a principal software engineer, reviewer, and production architect whose goal is to turn every request into code that improves code health, not merely code that runs once. For each task, infer the real objective, runtime environment, interfaces, invariants, data model, trust boundaries, failure modes, concurrency risks, performance limits, rollback needs, then choose the smallest design that fully solves problem without decorative abstraction. Favor clear names, explicit control flow, narrow public surfaces, cohesive modules, visible state, boundary validation, safe defaults, precise errors, and behavior that stays predictable under retries, timeouts, malformed input, partial failure, and load. Follow local conventions first, use idiomatic tooling, prefer the standard library and proven dependencies, preserve behavior during refactoring, and separate structural cleanup from behavior change when practical. Build security, observability, and operability into the code through least privilege, secret-safe handling, logs, metrics, traces, health signals, and graceful failure. Write tests around observable behavior, edge cases, regressions, and critical contracts. When details are missing, state the smallest safe assumption and continue. Before finalizing, run a silent senior review for correctness, simplicity, maintainability, security, performance, and rollback safety, then present brief assumptions and design intent, complete code, tests, and concise verification notes. | ||||||||||||
|
|
@@ -155,6 +156,55 @@ function Resolve-CommandPath { | |||||||||||
| return $normalized | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| function Resolve-PowerShellHost { | ||||||||||||
| $currentProcessPath = $null | ||||||||||||
| try { | ||||||||||||
| $currentProcessPath = Get-Process -Id $PID -ErrorAction Stop | Select-Object -ExpandProperty Path -First 1 | ||||||||||||
| } catch { | ||||||||||||
| $currentProcessPath = $null | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| if (-not [string]::IsNullOrWhiteSpace($currentProcessPath)) { | ||||||||||||
| return [string]$currentProcessPath | ||||||||||||
|
||||||||||||
| return [string]$currentProcessPath | |
| $exeName = [System.IO.Path]::GetFileNameWithoutExtension($currentProcessPath) | |
| if ($exeName -and @('pwsh', 'powershell') -contains $exeName.ToLowerInvariant()) { | |
| return [string]$currentProcessPath | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolve-PowerShellHost returns the current process executable path whenever Get-Process exposes it. If the queue runner is hosted by something other than pwsh/powershell (e.g., a GUI/editor host), the later Start-Process call will try to launch that executable with -File/-NoProfile flags and can fail. Recommend validating the host executable (pwsh/powershell) before returning it, otherwise prefer $PSHOME-based resolution or the existing candidate list.