Skip to content

Add powershell (windows) support#238

Open
cnukaus wants to merge 1 commit intomicrosoft:mainfrom
what-cloud:main
Open

Add powershell (windows) support#238
cnukaus wants to merge 1 commit intomicrosoft:mainfrom
what-cloud:main

Conversation

@cnukaus
Copy link
Copy Markdown

@cnukaus cnukaus commented Apr 9, 2026

Enhanced Powershell support:

I added Windows command resolution helpers, added codex detection, expanded the “no CLI found” message to include Codex, and changed npm-installed CLIs to prefer <name>.cmd on Windows before spawning.
That fixes the exact failure mode where PowerShell can run codex but child_process.spawn(\"codex\") cannot.

I also updated the CLI surface and docs, now advertises codex in --cli

@cnukaus
Copy link
Copy Markdown
Author

cnukaus commented Apr 9, 2026

@microsoft-github-policy-service agree

@Alan-Jowett
Copy link
Copy Markdown
Member

Thank you for this contribution, @cnukaus! 🎉 Adding Codex CLI support and fixing the Windows .cmd shim resolution issue with child_process.spawn() is a great improvement — this is a real pain point for Windows users.

The resolveSpawnCommand() approach is well thought out, the test coverage is solid, and the documentation updates are thorough. I've left a few review comments below — mostly around spec sync and a test edge case. Really appreciate you taking the time to submit this!

Copy link
Copy Markdown
Member

@Alan-Jowett Alan-Jowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for this well-structured PR! A few items to address before merge:

IMPLEMENTATION_PLAN.md — please remove (must fix)

This appears to be a development log from the implementation process. PromptKit doesn't maintain implementation plans at the repo root, and this would add noise to the project structure.

Spec files need codex added (should fix):

requirements.md has several references to the supported CLI list that need codex added:

  • REQ-CLI-010 — detection order (copilot → gh copilot → claude)
  • REQ-CLI-011 — valid --cli values (copilot, gh-copilot, claude)
  • REQ-CLI-017 — per-CLI spawn commands (missing codex entry)
  • ASSUMPTION-003 — accepted --cli values

validation.md should document the new TC-CLI-072A test case alongside existing TC-CLI-072.

assert.strictEqual(
parsedCmd,
`${cliName}.cmd`,
`${cliName} should spawn the Windows .cmd shim`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion will fail on Windows — which is ironic given the PR's intent! 😄

The dry-run test uses an empty PATH directory (emptyBinDir), so when resolveSpawnCommand() runs, it can't find any .cmd file and correctly falls back to the bare command name. But this assertion expects ${cliName}.cmd on Windows.

To fix, create a .cmd stub in emptyBinDir so resolveSpawnCommand() can find it:

// Create a .cmd stub so resolveSpawnCommand finds it
if (process.platform === "win32" && cliName !== "gh-copilot") {
  fs.writeFileSync(path.join(emptyBinDir, `${cliName}.cmd`), "");
}

Alternatively, accept the bare command name when no .cmd shim is present on PATH (since that is the correct resolveSpawnCommand behavior).

(Unix) — this is the most reliable cross-platform way to check if a
command exists on PATH without actually executing it.
- The detection order (copilot → gh-copilot → claude) prioritizes GitHub
- The detection order (copilot → gh-copilot → claude → codex) prioritizes GitHub
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-existing nit (optional fix): This line says detection uses execFileSync with where/which, but the implementation was changed to use direct PATH scanning in a previous PR. Since you're editing this section anyway, it might be worth correcting. Totally optional — not something you introduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants