Repository navigation
fix(opencode): use ~/.config/opencode for plugin path on macOS - #2655
Conversation
`opencode_plugins_dir()` previously fell back to `dirs::config_dir()`, which on macOS returns `~/Library/Application Support`. OpenCode itself treats that path as the *managed* settings directory and looks for user plugins under `~/.config/opencode/` on every OS, so the plugin landed in the wrong place on macOS — its in-code docstring already claimed it was written to `~/.config/opencode/plugins/`, but the runtime disagreed. Mirror OpenCode's documented global-config precedence instead: `$OPENCODE_CONFIG_DIR` > `$XDG_CONFIG_HOME/opencode` > `~/.config/opencode`. The Linux behaviour is unchanged; macOS now matches the docs and the existing CLI help text. Closes #2654 Co-Authored-By: Claude <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
Verified the precedence claim against OpenCode's source — xdg-basedir resolves xdgConfig to $XDG_CONFIG_HOME then ~/.config, so OPENCODE_CONFIG_DIR > XDG_CONFIG_HOME/opencode > ~/.config/opencode matches what OpenCode actually does. Tests pass locally on Linux; the macOS leg in CI is the meaningful gate.
One observation outside the diff: now that XDG_CONFIG_HOME is a documented step in the precedence chain, the help text in src/cli/config.rs (lines 170-171 and 259) still names only OPENCODE_CONFIG_DIR as the override. A user who has XDG_CONFIG_HOME=/custom/path will see the plugin land at /custom/path/opencode/plugins/worktrunk.ts, not ~/.config/opencode/plugins/worktrunk.ts as the help text suggests. Happy to push a small follow-up that mirrors the opencode_plugins_dir doc-comment in the help text — leaving it out here since the help wasn't strictly accurate before either and an in-PR update would also need a separate snapshot pass.
|
yes please adjust also: check whether there's a more opencode-native approach to installing; I'm surprised we're building a full emulation of their paths |
The install path now follows OpenCode's documented config precedence (OPENCODE_CONFIG_DIR > XDG_CONFIG_HOME/opencode > ~/.config/opencode), but the help text still named only OPENCODE_CONFIG_DIR. A user with XDG_CONFIG_HOME set saw the plugin land somewhere other than the help text suggested.
|
Pushed the help-text adjustment in 9bd5931 — both On the "more native" question — OpenCode supports two install paths in its plugin docs, plus a dedicated CLI:
Re "full emulation": after this PR the resolver reads Alternatives, with trade-offs:
My read: install path #1 is itself one of OpenCode's two documented options, and the directory math now matches their precedence exactly, so the bug shape from #2654 is gone. Happy to prototype the npm route in a separate PR if you want to evaluate it concretely. |
worktrunk-bot
left a comment
There was a problem hiding this comment.
The help-text update in 9bd5931 covers the XDG_CONFIG_HOME gap I flagged earlier. Tests were already green; codecov/patch passes. No new code-level issues.
On the maintainer's "more opencode-native approach" question, I went looking for alternatives:
OpenCode exposes two install paths beyond "drop a file in the plugins dir":
- The
opencode plugin <module>CLI (docs) —<module>is an npm package name (with--globaland--forceflags); no local-file mode is documented. - The
"plugin": ["pkg-name"]array inopencode.json(docs) — also npm packages, auto-installed by Bun at startup.
Both require the plugin to be on npm. Today the plugin is a 28-line local TypeScript file embedded via include_str!, so neither fits without a publishing pipeline (npm package version sync, breakage when the binary and the published plugin drift, etc.). For local plugins, OpenCode's documented install method is dropping the file in …/opencode/plugins/, so what we're doing isn't a parallel scheme — we're writing into OpenCode's own loader path.
That said, the precedence chain isn't extra emulation: it's matching what OpenCode itself reads. Trimming any branch breaks the install for the corresponding user:
- Drop
OPENCODE_CONFIG_DIR→ users with that env set get the plugin written somewhere OpenCode won't load. - Drop
XDG_CONFIG_HOME→ same outcome for users who customize XDG.
The genuinely native alternative is publish the plugin as @worktrunk/opencode-plugin (or similar) and have wt config plugins opencode install shell out to opencode plugin @worktrunk/opencode-plugin --global (or just edit opencode.json to add it). OpenCode then handles its own paths and updates. The cost is a separate npm release pipeline and version-pinning the plugin against the binary version. Given the plugin is 28 lines and rarely changes, I'd lean toward keeping the embedded-file approach and the path mirror this PR adds — but flagging the trade-off so you can call it.
|
@tend-agent please review these workflows; it's overly repetitive |
|
Diagnosed: two workflows fired on your earlier comment and both answered the "more opencode-native approach" question.
The bundled review skill already says "check whether a bot reply exists after the question's timestamp before answering", but the 19:42 run treated your question as still-open and re-answered it. Existing guidance is also scoped to inline comments ("cross-reference previous bot comments before posting inline comments") — the duplication here was in the review body, which the rule doesn't explicitly cover. I'll open a follow-up PR adding a cross-workflow dedup rule to |
|
Confirmed the diagnosis from the tend side and filed max-sixty/tend#400 to track the bundled-skill fix. The near-miss rule in |
|
The repo-local overlay is already up at #2656; with tend#400 covering the bundled fix, no separate upstream issue from my side is needed. Closing the loop on this thread. |
|
merging this, we can consider whether to make more "native" later |
…rlap (#403) The dedup rule at `plugins/tend-ci-runner/skills/review/SKILL.md:89` was scoped to inline comments and review-to-review overlap, missing the case where `tend-mention` answers a maintainer question and `tend-review` then re-answers it in the **review body** on the resulting `synchronize` event. Surfaced on [worktrunk#2655](max-sixty/worktrunk#2655) per #400. Two changes: - **`running-in-ci` — Recheck Before Posting** is restructured to name two duplication paths explicitly: (1) new entries arriving during the session, and (2) a sibling tend workflow having already responded before the session even started. The rule applies equally to comment bodies, review bodies, and inline replies. - **`review` skill** drops the inline-only / review-to-review scoping and defers to the running-in-ci rule, listing the workflow sources it covers (previous review on this or earlier commit, `tend-mention`, `tend-triage`, any tend workflow). The race-condition guidance and the "use the review body, not `gh pr comment`" guidance are preserved. The fetch in step 1 of the review skill (lines 60–66) already pulls `conversation` comments alongside `prev_reviews`, so no new data is needed — only the consume-step rule was too narrow. The event-pair-specific subsection ("Dedup check for inline review comment replies") is left in place — it covers a different concern (`pull_request_review` ↔ `pull_request_review_comment` race), not content overlap. Closes #400 Co-authored-by: Claude <[email protected]>
Problem
wt config plugins opencode installwrites the plugin to~/Library/Application Support/opencode/plugins/worktrunk.tson macOS, while OpenCode itself looks for user plugins under~/.config/opencode/(the macOS Library path is its managed settings directory). Reported in #2654.The bug came from
opencode_plugins_dir()falling back todirs::config_dir(), which is platform-native (~/Library/Application Supporton macOS,%AppData%\Roamingon Windows). The function's own docstring already claimed it wrote to~/.config/opencode/plugins/, and the CLI help text insrc/cli/config.rssays the same — only the runtime disagreed on macOS.Solution
Mirror OpenCode's documented global-config precedence directly:
Linux behaviour is unchanged (the prior
dirs::config_dir()fallback already produced$XDG_CONFIG_HOME/.configthere). macOS now lands at~/.config/opencode/plugins/worktrunk.ts, matching the docs and the help text.Testing
Two tests cover the regression cross-platform — previously the only fallback test was gated
#[cfg(target_os = "linux")]because the path differed by OS, which is exactly what hid the bug:test_opencode_install_uses_xdg_config_home— un-gated and renamed; assertsXDG_CONFIG_HOME/opencode/plugins/worktrunk.tson every OS.test_opencode_install_defaults_to_home_dot_config— new; clears bothOPENCODE_CONFIG_DIRandXDG_CONFIG_HOMEand asserts$HOME/.config/opencode/plugins/worktrunk.ts.Both pass locally on Linux. The macOS leg of CI is the meaningful gate — under the prior implementation, both would have failed there.
Closes #2654 — automated triage