Skip to content

Consolidate Coana launcher env vars into SOCKET_CLI_COANA_LAUNCHER#1360

Merged
Martin Torp (mtorp) merged 2 commits into
v1.xfrom
martin/env-variable-cleanup
Jun 11, 2026
Merged

Consolidate Coana launcher env vars into SOCKET_CLI_COANA_LAUNCHER#1360
Martin Torp (mtorp) merged 2 commits into
v1.xfrom
martin/env-variable-cleanup

Conversation

@mtorp

@mtorp Martin Torp (mtorp) commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Why

Follow-up from this review discussion on the Python CLI: the two env vars tuning how the pinned @coana-tech/cli engine is launched — SOCKET_CLI_COANA_FORCE_NPM_INSTALL (skip npx, always npm install + node) and SOCKET_CLI_COANA_DISABLE_NPM_FALLBACK (npx only, never fall back) — really express three modes of one setting, so they're better off as a single variable. A matching PR updates the Python CLI.

What changed

  • New SOCKET_CLI_COANA_LAUNCHER variable:
    • auto (default / unset) — try npx/dlx first, fall back to npm install + node on launcher-level failures.
    • npx — never fall back; surface the dlx failure directly.
    • npm-install — skip dlx entirely; always npm install + node.
  • When set to a recognized value, the new variable wins outright and the legacy variables are ignored. Unrecognized values warn and behave as auto.
  • The legacy variables are still honored when the new variable is unset (no breaking change), but are intentionally undocumented; only SOCKET_CLI_COANA_LAUNCHER is documented (README).
  • SOCKET_CLI_COANA_LOCAL_PATH is unrelated (takes a path) and is unchanged.

Testing

  • New unit tests in src/utils/dlx.test.mts cover npm-install mode, npx mode, precedence over the legacy variables, and unrecognized-value handling; existing legacy-var tests are kept as back-compat coverage.
  • pnpm test:unit src/utils/dlx.test.mts — 26/26 passing; pnpm run check clean.

Note

Low Risk
Behavioral change is limited to Coana spawn strategy and preserves legacy env vars when the new one is unset; mis-set values only warn and default to auto.

Overview
Replaces two undocumented Coana launch toggles with a single SOCKET_CLI_COANA_LAUNCHER env var that selects how @coana-tech/cli is started: auto (try npx/dlx, then npm install + node on launcher failure), npx (dlx only, no fallback), or npm-install (skip dlx entirely).

When the new variable is set, it overrides SOCKET_CLI_COANA_FORCE_NPM_INSTALL and SOCKET_CLI_COANA_DISABLE_NPM_FALLBACK; those legacy flags still work if the new var is unset. Invalid launcher values log a warning and behave like auto. SOCKET_CLI_COANA_LOCAL_PATH is unchanged.

spawnCoanaDlx in src/utils/dlx.mts routes through getCoanaLauncherMode(); README documents only the new variable. Unit tests in src/utils/dlx.test.mts cover each mode, precedence, and bad values.

Reviewed by Cursor Bugbot for commit db44ab5. Configure here.

Also fixed

Cursor Bugbot flagged (correctly) that the local-path, forced npm-install, and auto-mode fallback branches only honored stdio passed via the spawnExtra argument, dropping stdio set on the options argument (e.g. socket fix --silence requests stdio: 'pipe' via options) and defaulting to inherit. This predates this PR (#1353 only fixed the dlx branch), but since it's the same plumbing, the requested stdio is now resolved once and threaded through every launch path, with regression tests for the npm-install and fallback paths.

…A_LAUNCHER

The npm-install launcher path could previously be tuned via two boolean
env vars: SOCKET_CLI_COANA_FORCE_NPM_INSTALL (skip npx, always npm
install + node) and SOCKET_CLI_COANA_DISABLE_NPM_FALLBACK (npx only,
never fall back). They really express three modes of one setting, so
replace them with a single SOCKET_CLI_COANA_LAUNCHER variable taking
auto (default), npx, or npm-install.

The legacy variables remain supported for backward compatibility when
the new variable is unset, but are intentionally left undocumented.
Unrecognized values warn and behave as auto.

Follow-up from the review discussion on SocketDev/socket-python-cli#230;
the Python CLI is getting the same change.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit db44ab5. Configure here.

Comment thread src/utils/dlx.mts
@mtorp Martin Torp (mtorp) changed the base branch from main to v1.x June 10, 2026 11:34
The dlx branch resolves the caller's requested stdio from both the
options and spawnExtra arguments, but spawnCoanaScriptViaNode only read
spawnExtra. The local-path, forced npm-install, and auto-mode fallback
branches therefore dropped stdio passed via options and defaulted to
inherit — `socket fix --silence` requests stdio 'pipe' via options, so
those paths leaked Coana output to the terminal. Resolve the requested
stdio once and thread it through every launch path.

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.

LGTM 🎉

@mtorp Martin Torp (mtorp) merged commit 597f620 into v1.x Jun 11, 2026
12 checks passed
@mtorp Martin Torp (mtorp) deleted the martin/env-variable-cleanup branch June 11, 2026 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants