Skip to content

fix: check multiple OpenCode config locations#318

Merged
marcusquinn merged 1 commit intomainfrom
fix/opencode-config-locations
Feb 5, 2026
Merged

fix: check multiple OpenCode config locations#318
marcusquinn merged 1 commit intomainfrom
fix/opencode-config-locations

Conversation

@marcusquinn
Copy link
Copy Markdown
Owner

@marcusquinn marcusquinn commented Feb 5, 2026

Summary

Fixes setup failing to configure OpenCode agents when the config file is in a non-standard location.

Adds find_opencode_config() helper that checks multiple possible locations:

  • ~/.config/opencode/opencode.json (XDG standard - Linux, some macOS)
  • ~/.opencode/opencode.json (alternative location)
  • ~/Library/Application Support/opencode/opencode.json (macOS standard)

Problem

On a fresh Mac install, the user had OpenCode installed at ~/.opencode/ but setup.sh was only checking ~/.config/opencode/opencode.json, resulting in:

[INFO] OpenCode config not found at /Users/claudia/.config/opencode/opencode.json - skipping

This caused:

  • Custom agents (Build+, Plan+, SEO, WordPress, etc.) not being configured
  • Default Build/Plan agents showing instead of aidevops agents

Solution

Replace all hardcoded config paths with calls to find_opencode_config() which checks multiple locations and returns the first one found.

Test Plan

  1. Install OpenCode to ~/.opencode/ (non-standard location)
  2. Run bash <(curl -fsSL https://aidevops.sh/install)
  3. Verify setup finds the config and configures agents
  4. Verify custom agents appear in OpenCode

Related

Follow-up to #316 (bootstrap detection fix)

Summary by CodeRabbit

  • Chores
    • Improved setup process to automatically detect OpenCode configuration files from multiple standard locations instead of relying on hardcoded paths.
    • Enhanced logging to display where configuration files are discovered during setup and maintenance routines.

Add find_opencode_config() helper that checks:
- ~/.config/opencode/opencode.json (XDG standard)
- ~/.opencode/opencode.json (alternative)
- ~/Library/Application Support/opencode/opencode.json (macOS)

This fixes setup failing to configure OpenCode agents when the config
file is in a non-standard location.
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the setup.sh script's ability to locate the OpenCode configuration file. Previously, the script relied on a single, hardcoded path, which could lead to setup failures for users with non-standard installations. By introducing a new helper function that intelligently searches multiple common and standard locations, the script can now reliably find the configuration, ensuring proper setup of OpenCode agents and plugins across various operating systems and user configurations.

Highlights

  • Multi-location OpenCode config detection: Introduced a new find_opencode_config() helper function that checks ~/.config/opencode/opencode.json, ~/.opencode/opencode.json, and ~/Library/Application Support/opencode/opencode.json to locate the OpenCode configuration file.
  • Integration of new config detection: Replaced hardcoded OpenCode config paths in cleanup_deprecated_mcps, disable_ondemand_mcps, update_opencode_config, update_mcp_paths_in_opencode, setup_opencode_plugins, setup_oh_my_opencode, and setup_google_analytics_mcp functions with calls to the new find_opencode_config() helper.
  • Improved user experience: Enhanced the setup script's robustness by ensuring OpenCode agents are correctly configured even when the opencode.json file is in a non-standard location, particularly addressing issues on macOS.
Changelog
  • setup.sh
    • Added a new find_opencode_config() function to check multiple standard and alternative paths for the opencode.json file.
    • Updated cleanup_deprecated_mcps() to use the new find_opencode_config() for locating the OpenCode configuration.
    • Updated disable_ondemand_mcps() to use the new find_opencode_config() for locating the OpenCode configuration.
    • Modified update_opencode_config() to utilize find_opencode_config() and added improved logging to indicate where the config file was found or if it was not found.
    • Updated update_mcp_paths_in_opencode() to use the new find_opencode_config() for locating the OpenCode configuration.
    • Updated setup_opencode_plugins() to use the new find_opencode_config() for locating the OpenCode configuration.
    • Updated setup_oh_my_opencode() to use the new find_opencode_config() for locating the OpenCode configuration.
    • Updated setup_google_analytics_mcp() to use the new find_opencode_config() for locating the OpenCode configuration.
Activity
  • No specific activity (comments, reviews, etc.) was provided in the context for this pull request.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 5, 2026

Walkthrough

Introduced a new find_opencode_config() function that dynamically searches multiple standard locations for the OpenCode config file. Replaced hardcoded config paths throughout setup.sh with calls to this discovery function, updating cleanup, update, and setup routines to log and use the dynamically located configuration path.

Changes

Cohort / File(s) Summary
Config Discovery Function
setup.sh
Added find_opencode_config() function to search standard config locations (\$HOME/.config/opencode/, /etc/opencode/, etc.). Updated cleanup, update, and setup routines to call this function, determine config path dynamically, and log discovery. Modified error and info messages to reflect multi-location search behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🔍 Config paths once carved in stone,

Now dance through directories unknown,

A search that finds what's really there,

Dynamic magic in the air! ✨

Setup.sh learns to adapt and roam. 🚀

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding support for multiple OpenCode config file locations, which directly addresses the core problem and solution outlined in the PR objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/opencode-config-locations

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Feb 5, 2026

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively addresses the issue of locating the OpenCode configuration file in non-standard locations by introducing the find_opencode_config helper function. The changes are well-contained within setup.sh and correctly replace hardcoded paths with calls to the new function, improving the script's robustness, especially for macOS users.

My review includes a few suggestions to improve consistency in how the new function is called and to remove some redundant code, which will enhance the script's readability and maintainability.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 5, 2026

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 2 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Thu Feb 5 00:42:24 UTC 2026: Code review monitoring started
Thu Feb 5 00:42:25 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 2
Thu Feb 5 00:42:25 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Thu Feb 5 00:42:27 UTC 2026: Codacy analysis completed with auto-fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 2
  • VULNERABILITIES: 0

Generated on: Thu Feb 5 00:44:01 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@marcusquinn marcusquinn merged commit 6a46a5c into main Feb 5, 2026
10 of 11 checks passed
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@setup.sh`:
- Around line 2075-2082: The generator scripts hardcode $HOME/.config/opencode;
change generate-opencode-agents.sh and generate-opencode-commands.sh to accept
the discovered config path via an OPENCODE_CONFIG environment variable or a
command argument (falling back to current default only if OPENCODE_CONFIG is
unset), and update callers to pass the path returned by
update_opencode_config()/find_opencode_config (the opencode_config local
variable shown in the diff) instead of assuming ~/.config/opencode; ensure the
scripts use OPENCODE_CONFIG when present to locate files and preserve existing
behavior when it is not set.
🧹 Nitpick comments (1)
setup.sh (1)

31-46: Honor XDG_CONFIG_HOME for truly standard XDG support.

Right now the search only checks ~/.config. If users set XDG_CONFIG_HOME, the config won’t be found. This is a small but important edge case for standards compliance.

♻️ Recommended refactor (XDG-aware)
 find_opencode_config() {
-    local candidates=(
-        "$HOME/.config/opencode/opencode.json"      # XDG standard (Linux, some macOS)
+    local xdg_config="${XDG_CONFIG_HOME:-$HOME/.config}"
+    local candidates=(
+        "$xdg_config/opencode/opencode.json"        # XDG standard (Linux, some macOS)
         "$HOME/.opencode/opencode.json"             # Alternative location
         "$HOME/Library/Application Support/opencode/opencode.json"  # macOS standard
     )

Comment on lines +2075 to +2082
local opencode_config
if ! opencode_config=$(find_opencode_config); then
print_info "OpenCode config not found (checked ~/.config/opencode/, ~/.opencode/, ~/Library/Application Support/opencode/) - skipping"
return 0
fi

print_info "Found OpenCode config at: $opencode_config"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, find all generator scripts that might reference opencode
find . -name "generate-opencode*.sh" -o -name "*generate*opencode*.sh" | head -20

Repository: marcusquinn/aidevops

Length of output: 155


🏁 Script executed:

#!/bin/bash
# Search for hardcoded opencode.json and config paths in all shell scripts
rg -n "opencode\.json|\.config/opencode|OPENCODE_CONFIG" --type sh | grep -i "generate\|script" | head -30

Repository: marcusquinn/aidevops

Length of output: 3235


🏁 Script executed:

#!/bin/bash
# Get more context on update_opencode_config and how config path is passed to generators
rg -B 5 -A 15 "update_opencode_config" setup.sh

Repository: marcusquinn/aidevops

Length of output: 2380


Generator scripts hardcode OpenCode config path—non-standard installs will fail.

update_opencode_config() dynamically discovers the config location, but generate-opencode-agents.sh (lines 23–25) and generate-opencode-commands.sh (line 18) hardcode $HOME/.config/opencode/. This breaks installs with configs at ~/.opencode/ or ~/Library/Application Support/opencode/.

The generator scripts must accept the discovered config path as a parameter (e.g., OPENCODE_CONFIG environment variable or argument) instead of assuming a fixed location.

🤖 Prompt for AI Agents
In `@setup.sh` around lines 2075 - 2082, The generator scripts hardcode
$HOME/.config/opencode; change generate-opencode-agents.sh and
generate-opencode-commands.sh to accept the discovered config path via an
OPENCODE_CONFIG environment variable or a command argument (falling back to
current default only if OPENCODE_CONFIG is unset), and update callers to pass
the path returned by update_opencode_config()/find_opencode_config (the
opencode_config local variable shown in the diff) instead of assuming
~/.config/opencode; ensure the scripts use OPENCODE_CONFIG when present to
locate files and preserve existing behavior when it is not set.

@marcusquinn marcusquinn deleted the fix/opencode-config-locations branch February 21, 2026 01:59
@marcusquinn marcusquinn added the code-reviews-actioned All review feedback has been actioned label Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-reviews-actioned All review feedback has been actioned

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant