Skip to content

[codex] Restore Windows CLI runtime detection#3

Open
tackcrypto1031 wants to merge 1 commit into
nexu-io:mainfrom
tackcrypto1031:codex/windows-cli-detection
Open

[codex] Restore Windows CLI runtime detection#3
tackcrypto1031 wants to merge 1 commit into
nexu-io:mainfrom
tackcrypto1031:codex/windows-cli-detection

Conversation

@tackcrypto1031
Copy link
Copy Markdown

Summary

Fixes Windows CLI install and agent detection paths for the local Studio.

Root cause

The runtime assumed Unix command lookup and executable semantics:

  • agent detection used which, so Windows npm shims such as codex.cmd and claude.cmd were not found
  • agent spawning used the logical binary name instead of the resolved path
  • the CLI build script used Unix chmod, which fails on Windows
  • package test scripts failed when a package declared node --test test/ but shipped no test/ directory

Changes

  • use where.exe on Windows and prefer .exe, .cmd, or .bat matches during CLI detection
  • resolve the actual binary path before spawning child-process agents
  • execute Windows .cmd / .bat shims through cmd.exe
  • replace Unix chmod with a cross-platform Node script
  • make empty package test directories an explicit no-op instead of a failure
  • add a /favicon.ico no-content response to avoid Studio browser 404 noise
  • update doctor so Windows ffmpeg and Chrome/Edge installs are detected correctly

Validation

  • pnpm -r build
  • pnpm -r typecheck
  • pnpm -r test
  • pnpm smoke
  • /api/agents?force=1 returns claude.available=true and codex.available=true
  • /api/agents/claude/test returned hello
  • /api/agents/codex/test returned hello

Notes

The test command now skips packages with no test/ directory. That preserves the current repo state while allowing future package tests to run automatically when added.

The runtime assumed Unix command lookup and Unix executable semantics, so Windows npm shims for Codex and Claude were invisible to the Studio even though they were installed on PATH. The CLI package also used Unix chmod during build, which blocked a clean Windows install.

This teaches detection to use where.exe on Windows, resolves the actual command path before spawning agents, wraps Windows .cmd/.bat shims through cmd.exe, and keeps package build/test scripts portable for fresh Windows checkouts.

Constraint: Windows npm global CLIs are exposed as .cmd/.ps1 shims rather than executable Unix-style binaries.

Rejected: Require users to launch Studio from a special shell | the app should use the same PATH-visible CLIs users already have.

Confidence: high

Scope-risk: moderate

Directive: Do not reintroduce Unix-only which/chmod/test assumptions into CLI install or runtime detection.

Tested: pnpm -r build; pnpm -r typecheck; pnpm -r test; pnpm smoke; /api/agents?force=1 shows claude and codex available; /api/agents/claude/test and /api/agents/codex/test returned hello
@tackcrypto1031 tackcrypto1031 marked this pull request as ready for review June 5, 2026 11:45
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 19e038bc72

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (process.platform === 'win32' && ['.cmd', '.bat'].includes(ext)) {
return {
bin: 'cmd.exe',
args: ['/d', '/s', '/c', [bin, ...args].map(quoteCmdArg).join(' ')],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Escape cmd.exe arguments safely

On Windows .cmd/.bat shims this builds a single cmd.exe /c command line, but quoteCmdArg escapes embedded quotes with backslashes, which cmd.exe does not treat as quote escaping. For agents that pass user/source text in argv, such as Hermes (packages/runtime/src/defs/hermes.ts:25), a prompt containing a quote followed by & ... can break out of the quoted argument and execute another shell command instead of being delivered as data.

Useful? React with 👍 / 👎.

@nettee
Copy link
Copy Markdown

nettee commented Jun 5, 2026

@tackcrypto1031 I'm holding off on generating review comments for #3 because this pull request has merge conflicts right now.

Please resolve the conflicts with main and push the updated branch. Once that's done, request or wait for the review to run again and I'll take another look.

🔁 Powered by Looper · runner=reviewer · agent=codex · An autonomous AI dev team for your GitHub repos.

@lefarcen
Copy link
Copy Markdown

lefarcen commented Jun 7, 2026

Heads-up: PR #29 is also open against the same Windows CLI runtime path. Both PRs touch packages/runtime/src/detect.ts and packages/runtime/src/spawn.ts around where-based detection and Windows CLI launch behavior.

Sharing this so the approaches can be compared before maintainers decide what lands.

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.

3 participants