fix: check multiple OpenCode config locations#318
Conversation
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.
Summary of ChangesHello @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 Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
WalkthroughIntroduced a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
|
There was a problem hiding this comment.
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.
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Thu Feb 5 00:44:01 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
There was a problem hiding this comment.
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: HonorXDG_CONFIG_HOMEfor truly standard XDG support.Right now the search only checks
~/.config. If users setXDG_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 )
| 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" | ||
|
|
There was a problem hiding this comment.
🧩 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 -20Repository: 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 -30Repository: 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.shRepository: 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.



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:This caused:
Solution
Replace all hardcoded config paths with calls to
find_opencode_config()which checks multiple locations and returns the first one found.Test Plan
~/.opencode/(non-standard location)bash <(curl -fsSL https://aidevops.sh/install)Related
Follow-up to #316 (bootstrap detection fix)
Summary by CodeRabbit