Skip to content

fix(init): honor OPENCODE_CONFIG_DIR for OpenCode plugin path#715

Open
cavanaug wants to merge 2 commits intortk-ai:developfrom
cavanaug:fix/init-opencode-config-dir
Open

fix(init): honor OPENCODE_CONFIG_DIR for OpenCode plugin path#715
cavanaug wants to merge 2 commits intortk-ai:developfrom
cavanaug:fix/init-opencode-config-dir

Conversation

@cavanaug
Copy link

This PR was generated using AI on behalf of @cavanaug.

Summary

  • Fix rtk init -g --opencode to honor OPENCODE_CONFIG_DIR when resolving the OpenCode plugin install directory.
  • Preserve existing fallback behavior to ~/.config/opencode when OPENCODE_CONFIG_DIR is unset or blank.
  • Add tests covering env override, blank-env fallback, and plugin path preparation using the override.
  • Update OpenCode docs/examples to use ${OPENCODE_CONFIG_DIR:-$HOME/.config/opencode}.

Test plan

  • cargo fmt --all --check
  • cargo clippy --all-targets (2 pre-existing warnings in unrelated files)
  • cargo test (982 passed)
  • cargo build --release
  • cargo test test_resolve_opencode_dir_uses_env_override
  • cargo test test_resolve_opencode_dir_falls_back_when_env_is_blank
  • cargo test test_prepare_opencode_plugin_path_uses_env_override
  • Manual: verify docs path examples are env-aware

- Resolve OpenCode plugin path via OPENCODE_CONFIG_DIR when provided

- Fall back to ~/.config/opencode when env var is unset/blank

- Add regression tests for resolver and plugin path prep

- Update OpenCode docs/examples to show env-aware plugin location

Signed-off-by: John Cavanaugh <59479+cavanaug@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 19, 2026 06:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates RTK’s OpenCode integration so rtk init -g --opencode installs the plugin under an OPENCODE_CONFIG_DIR override when provided, while preserving the existing ~/.config/opencode fallback and updating docs accordingly.

Changes:

  • Add OPENCODE_CONFIG_DIR support to OpenCode config-dir resolution (blank values fall back).
  • Add unit tests for env override, blank-env fallback, and plugin-path preparation using the override.
  • Update README + troubleshooting docs to show env-aware paths (${OPENCODE_CONFIG_DIR:-$HOME/.config/opencode}).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/init.rs Honor OPENCODE_CONFIG_DIR for OpenCode plugin install path + add tests for override/fallback behavior.
docs/TROUBLESHOOTING.md Use an env-aware path example when checking for the plugin file.
README.md Document the env override behavior and update manual install commands to use ${OPENCODE_CONFIG_DIR:-...}.
Comments suppressed due to low confidence (1)

src/init.rs:1538

  • The doc comment for opencode_plugin_path is now misleading: the plugin path is not always ~/.config/opencode/... because resolve_opencode_dir() can return OPENCODE_CONFIG_DIR. Update the comment to describe the path as $OPENCODE_CONFIG_DIR/plugins/rtk.ts when set, otherwise the ~/.config/opencode/... fallback.
/// Return OpenCode plugin path: ~/.config/opencode/plugins/rtk.ts
fn opencode_plugin_path(opencode_dir: &Path) -> PathBuf {
    opencode_dir.join("plugins").join("rtk.ts")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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