docs: centralize environment variables into a dedicated section

This commit is contained in:
nhat.nguyenhong 2026-09-24 14:16:51 +00:00
parent 78a4f42bc0
commit 053e34d350

View File

@ -146,6 +146,30 @@ global config (`baseURL`/`ccVersion` are read from there too).
`options.headers` (with a leading `Bearer ` stripped). If neither is present, requests are sent
unauthenticated and CommandCode will reject them.
## Environment variables
All environment variables read by the provider, its scripts, and its TUI plugin. String values in
`options` also accept `{env:NAME}`, which opencode/the TUI expand generically (not a fixed set).
CommandCode-specific:
| Name | Purpose | Default |
| --- | --- | --- |
| `COMMANDCODE_API_KEY` | CommandCode API key for `smoke`/`quota`/`sync-models` and the TUI's key resolution; referenced from config as `{env:COMMANDCODE_API_KEY}`. | — |
| `COMMANDCODE_DEBUG` | Enables request/stream tracing (`1`/`true`/`yes`); the toggle file wins when its `debug` key is set. | unset |
| `COMMANDCODE_DEBUG_FILE` | Path the trace is appended to. | `<os tempdir>/commandcode-debug.log` |
| `COMMANDCODE_ZDR` | Enables the `x-cmd-zdr: 1` header (`1`/`true`/`yes`); the toggle file wins when its `zdr` key is set. | unset |
| `COMMANDCODE_TOGGLES_FILE` | Overrides the shared toggle-file path. | `$XDG_CONFIG_HOME/opencode/commandcode-toggles.json` |
| `COMMANDCODE_QUOTA_INTERVAL_MS` | Sidebar fallback quota refresh interval in ms. | `300000` (floor `120000`) |
Standard:
| Name | Purpose | Default |
| --- | --- | --- |
| `XDG_CONFIG_HOME` | Base config dir for the toggle file. | `~/.config` |
| `NO_COLOR` | Disables ANSI colors in the `sync-models` picker (any value). | unset |
| `TERM` | `dumb` disables ANSI colors in the `sync-models` picker. | — |
## Debug tracing
Set `COMMANDCODE_DEBUG=1` to write a trace of every request and stream event to a log file.
@ -158,10 +182,8 @@ $env:COMMANDCODE_DEBUG = "1"
opencode run "Reply with exactly: pong" -m commandcode/deepseek/deepseek-v4.1-flash
```
| Env var | Default | Description |
| --- | --- | --- |
| `COMMANDCODE_DEBUG` | unset | `1`/`true`/`yes` enables tracing. |
| `COMMANDCODE_DEBUG_FILE` | `<os tempdir>/commandcode-debug.log` | Where the trace is appended. |
`COMMANDCODE_DEBUG` and `COMMANDCODE_DEBUG_FILE` are described in
[Environment variables](#environment-variables).
The log captures the request (model id, body byte length), each HTTP attempt (status, retry
wait, elapsed ms), every stream event payload, and the terminal finish reason + usage. It is
@ -170,8 +192,9 @@ useful for diagnosing model selection, retry, tool-call, and finish-reason issue
## ZDR header toggle
The `x-cmd-zdr: 1` request header is **omitted by default** because it is rejected by some
models. It can be enabled with the `COMMANDCODE_ZDR` environment variable, the `/cc-zdr` slash
command, or `providerOptions.commandcode.zdr`. The value is resolved per request, so toggling it
models. It can be enabled with the `COMMANDCODE_ZDR` environment variable (see
[Environment variables](#environment-variables)), the `/cc-zdr` slash command, or
`providerOptions.commandcode.zdr`. The value is resolved per request, so toggling it
does not require restarting opencode.
Precedence, highest first:
@ -189,7 +212,8 @@ observable.
`/cc-zdr` and `/cc-debug` flip the `zdr` and `debug` values in a small JSON file the provider
reads on every request, so both settings change without restarting opencode. `/cc-status` shows
the current state. The file is `~/.config/opencode/commandcode-toggles.json` (overridable with
`COMMANDCODE_TOGGLES_FILE`); the environment variables above are used when a key is absent.
`COMMANDCODE_TOGGLES_FILE` — see [Environment variables](#environment-variables)); the environment
variables above are used when a key is absent.
These commands come from a small TUI plugin shipped in this package (`src/tui.tsx`). It is loaded
from **source** — opencode compiles the TSX and provides the Solid runtime itself — so there is no
@ -244,7 +268,8 @@ The sidebar refreshes after each completed turn (`session.idle`, plus `session.s
`session.updated`, and `message.updated` as fallbacks since `session.idle` is a server-plugin
event that may never reach the TUI bus — all debounced) and when the active session changes,
but never more than once every 2 minutes; every 5 minutes as a fallback
(`COMMANDCODE_QUOTA_INTERVAL_MS` overrides the fallback interval) and the
(`COMMANDCODE_QUOTA_INTERVAL_MS` overrides the fallback interval — see
[Environment variables](#environment-variables)) and the
countdown ticks every 30 seconds. Key resolution and fetch failures are redacted and shown
inline; the panel never stays on `loading…` and never blocks the provider. Extra trace lines
(`tui-quota`) are appended to the debug log only when debug tracing is on.