Files
Worktrunk Bot 4ef5644b69 fix(opencode): read an empty OPENCODE_CONFIG_DIR as unset, not as a relative path (#4084)
`wt config plugins opencode install` writes the plugin to a **relative**
`plugins/worktrunk.ts` — i.e. into whatever directory `wt` was run from,
typically the user's repo — when `OPENCODE_CONFIG_DIR` is exported with
an empty value. `is_plugin_installed()` and `plugin_file_exists()` then
read that same relative path back, so the install reports success while
OpenCode never sees the plugin.

The cause is a one-branch gap in `opencode_plugins_dir`: the
`XDG_CONFIG_HOME` arm filtered empty values, the `OPENCODE_CONFIG_DIR`
arm above it did not, so `PathBuf::from("")` passed through as a valid
config directory. Every other agent-config override in the tree already
reads an empty value as unset — `CLAUDE_CONFIG_DIR` in
`commands::config::show`, `PI_CODING_AGENT_DIR` and `PI_CONFIG_DIR` in
`commands::config::pi` — so this arm was the odd one out rather than a
deliberate choice.

The documented precedence is unchanged: `$OPENCODE_CONFIG_DIR` >
`$XDG_CONFIG_HOME/opencode` > `~/.config/opencode`. Only the reading of
an empty value moves, from "a directory named `""`" to "unset".

The regression test runs the real install from a scratch directory with
`OPENCODE_CONFIG_DIR=""`, then asserts the plugin landed under
`$XDG_CONFIG_HOME/opencode/plugins/` and that nothing was written
relative to the invocation directory. It fails against the previous code
on the first assertion.

---------

Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com>
2026-09-13 10:23:22 -07:00
..