fix(events): degrade ps variant to 'no argv' when no pwsh/powershell on PATH - #7
Merged
Merged
Conversation
…on PATH Mirrors spec-kit #4340. resolveScriptArgv's ps branch unconditionally returned ['pwsh', '-File', ...] — without probing PATH, spawnSync would raise ENOENT (confusing 'No such file or directory: pwsh') instead of the clean 'unresolvable, falling back' every other branch gets. Add a findLauncher() helper (shutil.which mirror: PATH scan, PATHEXT on Windows, X_OK on POSIX) and return null when neither pwsh nor powershell resolves, so main() degrades to body injection / fail-open. Add a regression test that scrubs PATH for the child (parent uses process.execPath) and asserts exit 0, the unresolvable warning, no ENOENT/script error, and body-injection fallback.
itaior
approved these changes
Aug 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ports upstream spec-kit #4340 to the JS dispatcher.
resolveScriptArgv'spsbranch unconditionally returned["pwsh", "-File", …]— without probing PATH. On a host withoutpwsh/powershell,spawnSyncraisesENOENT("No such file or directory: 'pwsh'") instead of the clean "unresolvable, falling back" every other branch gets.Fix
findLauncher()— ashutil.whichmirror (PATH scan,PATHEXTon Windows,X_OKon POSIX).psbranch now returnsnullwhen neither launcher resolves, somain()degrades to body injection / fail-open.Test
tests/events.test.mjs: ps-only skill with scrubbed PATH → asserts exit 0, the "unresolvable" warning, noENOENT/script error, and body-injection fallback.["pwsh", …]line, the test fails (status null / ENOENT).Full suite: 108/108 pass.
Note: spec-kit #3857 (stdin
.eofcrash) was reviewed alongside and is not applicable — the JSreadPayloadreads raw bytes into a Buffer, detects EOF vian === 0, and fail-open truncates oversized payloads.