Skip to content

Store OpenCode 2 credentials on Windows and flag rejected keys - #1

Merged
tobiasritscher merged 2 commits into
Noser-Engineering:mainfrom
jogesr:fix/windows-opencode2-credential-store
Oct 14, 2026
Merged

tobiasritscher merged 2 commits into
Noser-Engineering:mainfrom
jogesr:fix/windows-opencode2-credential-store

Conversation

@jogesr

@jogesr jogesr commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Summary

On Windows, setup could not store API keys for OpenCode 2, so profiles had no models in OpenCode Desktop 2.

  • Setup runs the real opencode.exe: from PATH, behind the npm .cmd shim, or the CLI bundled with OpenCode Desktop. Node refuses JSON arguments to .cmd files (CVE-2024-27980).
  • credential.remove passes credentialID via --param; replacing a key failed before.
  • On 401/403 the plugin marks the connection needs_auth and clears the mark once discovery succeeds.
  • Spawn errors no longer leak the key. The declared tests now pass on Windows.

Evidence

  • Before: [error] The argument 'args[5]' contains a cmd.exe special character ... "key":"sk-..."
    After: setup stores the key. Tested with OpenCode 2.0.29.
  • Before: invalid key: provider without models, no hint.
    After: the connection shows needs_auth; with a valid key it clears and 18 models appear.
  • npm run check: 202 tests pass on Windows and in CI on Linux.

Merge Danger

Door: two-way. No data or format migration; a revert restores the old behavior.

Blast Radius: setup and the OpenCode 2 plugin, in the CLI and Desktop alike. On Windows, setup resolves a different executable. On all platforms, credential.remove uses --param, and a 401/403 marks the connection needs_auth. Executable lookup on macOS/Linux and OpenCode 1 are unchanged.

…s on Linux

The shim names its target with backslashes. path.join on POSIX keeps them inside one segment, so the test that runs the Windows lookup on Linux CI built a path that does not exist.
@tobiasritscher
tobiasritscher merged commit ef564f6 into Noser-Engineering:main Oct 14, 2026
3 checks passed
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