Skip to content

AST-180812 - Add configureApiKey and clearApiKey for a shared CLI login - #1046

Open
cx-rahul-pidde wants to merge 3 commits into
mainfrom
feature/AST-180812-configure-set-apikey
Open

cx-rahul-pidde wants to merge 3 commits into
mainfrom
feature/AST-180812-configure-set-apikey

Conversation

@cx-rahul-pidde

@cx-rahul-pidde cx-rahul-pidde commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds a way for an IDE to save its sign-in as the cx CLI's own login, so other cx processes of the same user (for example the cx-devassist Copilot plugin) use the same login without a second sign-in.

  • CxWrapper.configureApiKey(key) runs cx configure set --prop-name cx_apikey --prop-value <key>. cx decides where the login is stored.
  • CxWrapper.clearApiKey() sets cx_apikey to an empty value, for sign-out.
  • New ExecutionService.executeSensitiveCommands(...), used by both. Unlike executeCommands, it passes the arguments unchanged (no quote stripping) and never logs or returns cx's stdout or stderr, only the exit code. This matters because cx configure set prints the value it sets, so the existing path would write the key to the log.
  • These methods do not add the config's --apikey, so only the given value is sent.

Not changed: existing commands and executeCommands behave as before.

References

  • Jira: AST-180812 (VS Code self-healing / shared login with cx-devassist)
  • Used by the VS Code extension change (PR linked from there).

Testing

  • New src/tests/ConfigureApiKeyTest.test.ts (5 tests, passing). They do not need the real cx binary or credentials:
    • configureApiKey and clearApiKey send exactly configure set --prop-name cx_apikey --prop-value <value>.
    • executeSensitiveCommands returns the exit code and never puts the output in the log or the result (checked with a child process that prints a secret).
    • Arguments with quotes, commas and spaces reach the process unchanged.
    • A failure to start the binary returns exit code -1.
  • tsc and eslint pass on the changed files.
  • Not tested against a real cx and tenant: that an empty value actually removes cx_apikey. Please confirm.
  • The full suite was not run locally: the existing tests need a real tenant and the LFS cx binaries.

Add CxWrapper.configureApiKey(key) and clearApiKey(), which run
`cx configure set --prop-name cx_apikey`, so an IDE can save its sign-in
as the CLI's own login. Other cx processes of the same user, such as the
cx-devassist plugin, then use the same login. cx decides where to store it.

Both run through the new ExecutionService.executeSensitiveCommands, which
passes the arguments unchanged and never logs or returns cx's output
(cx prints the value it sets), only the exit code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cx-rahul-pidde and others added 2 commits October 29, 2026 19:58
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
An empty configure set is not the CLI logout. authLogout already runs cx auth logout, which clears the stored login.

Signed-off-by: Rahul Pidde <206018639+cx-rahul-pidde@users.noreply.github.com>
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