Skip to content

Commit 40f4b3f

Browse files
committed
fix(cli): harden ocx opencode launcher review follow-ups
Merge inherited OPENCODE_CONFIG_CONTENT instead of replacing it, probe the live proxy hostname for baseURL, resolve admission from env/service token/ config keys, add x-opencodex-api-key on non-loopback binds, omit native slugs in Codex Direct mode, and widen global override detection. Stabilize the Windows storage-policy concurrency test timing.
1 parent a768eca commit 40f4b3f

5 files changed

Lines changed: 352 additions & 75 deletions

File tree

‎docs-site/src/content/docs/guides/opencode.md‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ opencodex/gpt-5.6-sol # native slugs stay unprefixed
2828

2929
## Your own config is never modified
3030

31-
The launcher does not read, copy, or rewrite `~/.config/opencode/opencode.json`,
32-
project `opencode.json` / `opencode.jsonc`, or any other on-disk config layer. Your
31+
The launcher does not copy or rewrite `~/.config/opencode/opencode.json`,
32+
project `opencode.json` / `opencode.jsonc`, or any other on-disk config layer. It may
33+
read global or project config to detect a `provider.opencodex` override, while your
3334
existing providers, agents, keybinds, MCP entries, and relative `{file:…}` references
3435
keep resolving from their original files.
3536

@@ -49,18 +50,23 @@ informational note: the runtime layer from `ocx opencode` overrides it for that
4950
## The admission key is not written to disk
5051

5152
When the proxy requires an API key, the inline runtime config carries opencode's
52-
`{env:…}` reference rather than the secret:
53+
`{env:…}` reference rather than the secret. Non-loopback binds also send
54+
`x-opencodex-api-key` from the same env var so proxy admission stays separate from any
55+
upstream Authorization header:
5356

5457
```json
5558
"options": {
5659
"baseURL": "http://127.0.0.1:10100/v1",
57-
"apiKey": "{env:OPENCODEX_OPENCODE_API_KEY}"
60+
"apiKey": "{env:OPENCODEX_OPENCODE_API_KEY}",
61+
"headers": {
62+
"x-opencodex-api-key": "{env:OPENCODEX_OPENCODE_API_KEY}"
63+
}
5864
}
5965
```
6066

6167
The real value is passed only through the child process environment.
62-
`OPENCODEX_API_AUTH_TOKEN` takes precedence over a configured API key, which is what
63-
a non-loopback bind requires.
68+
`OPENCODEX_API_AUTH_TOKEN` takes precedence, then the hardened service token file, then
69+
a configured API key — which is what a non-loopback bind requires.
6470

6571
## Reverting
6672

‎src/cli/help.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,13 @@ const helpEntries: Record<string, HelpEntry> = {
186186
},
187187
opencode: {
188188
usage: "ocx opencode [opencode args...]",
189-
summary: "Launch opencode wired to the proxy (generated provider config).",
189+
summary: "Launch opencode wired to the proxy (runtime provider config).",
190190
details: [
191-
"Ensures the proxy is running, then execs `opencode` with OPENCODE_CONFIG pointed at a",
192-
"generated config in the opencodex config dir. Your own opencode.json is never modified —",
193-
"its settings are merged forward into the generated copy, and only the `opencodex`",
194-
"provider key is overwritten.",
191+
"Ensures the proxy is running, then execs `opencode` with the generated `provider.opencodex`",
192+
"block injected through OpenCode's inline runtime layer (`OPENCODE_CONFIG_CONTENT`). Any",
193+
"existing inline config in the environment is preserved and only `provider.opencodex` is",
194+
"overwritten for this launch.",
195+
"Your on-disk opencode.json / opencode.jsonc files are never modified.",
195196
"Routed models appear in the model picker as opencodex/<provider>/<model>.",
196197
"Stop using `ocx opencode` and plain `opencode` behaves exactly as before.",
197198
],

0 commit comments

Comments
 (0)