Skip to content

Fix bundled CLI invocation in installed extensions#19

Merged
azizbecha merged 1 commit into
mainfrom
fix/cli-bundled-spawn
May 4, 2026
Merged

Fix bundled CLI invocation in installed extensions#19
azizbecha merged 1 commit into
mainfrom
fix/cli-bundled-spawn

Conversation

@azizbecha

Copy link
Copy Markdown
Owner

Summary

The packaged .vsix never contained npm's node_modules/.bin/agent-device shim — that's a local symlink layer npm creates at install time, not a real artifact. Result: every installed extension (in VS Code, Cursor, etc.) hit ENOENT on the first run step:

spawn /Users/.../azizbecha.agent-device-vscode-0.1.0-universal/node_modules/.bin/agent-device ENOENT

Fix

Resolve the bundled CLI as process.execPath (the host Electron binary) plus the actual .mjs entrypoint (node_modules/agent-device/bin/agent-device.mjs), and set ELECTRON_RUN_AS_NODE=1 in the spawned env so Electron behaves as a plain Node interpreter for the child process. This is the standard VS Code extension pattern for invoking Node scripts and works identically in Cursor / VSCodium / code-server.

User-supplied agentDevice.cliPath overrides are still spawned directly — assumed to point at an executable.

Type changes

BinPath now accepts the structured { command, prefixArgs, env } shape in addition to the plain-string shorthand. xcrun, open, adb, and emulator call sites in DeviceCatalog keep their string form unchanged.

Verification

  • npm run lint clean
  • npm run format:check clean
  • npm test (35 specs pass)
  • npm run compile clean
  • Smoke test: node node_modules/agent-device/bin/agent-device.mjs --help produces the agent-device help text
  • Confirmed node_modules/agent-device/bin/agent-device.mjs is included in the .vsix (unzip -l check)
  • After merge + Marketplace publish: install in Cursor and verify open com.apple.Preferences step actually runs

Bumps to 0.1.2.

The packaged .vsix never contained npm's `node_modules/.bin/agent-device`
shim, so installed extensions hit `ENOENT` on the first run step.

Resolve the bundled CLI as `process.execPath` plus the actual `.mjs`
entrypoint (`node_modules/agent-device/bin/agent-device.mjs`), with
`ELECTRON_RUN_AS_NODE=1` set so the host's Electron binary runs the
script as Node. Same pattern works in VS Code and every Electron fork
(Cursor, VSCodium, etc.). User-supplied `agentDevice.cliPath` overrides
still spawn directly.

Bumps to 0.1.2.
@azizbecha azizbecha merged commit 5b45390 into main May 4, 2026
1 check passed
@azizbecha azizbecha deleted the fix/cli-bundled-spawn branch May 8, 2026 21:29
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.

1 participant