fix: replace hardcoded opencode path with dynamic binary discovery in query scripts#83
Conversation
|
This PR updates the shell scripts to dynamically locate the Bro, finally killing those hardcoded paths—about time. The discovery logic matches the app's Swift implementation perfectly (checking One gotcha though: you have Quick fix: OPENCODE_BIN=$(find_opencode_bin || true)This lets the script survive the assignment failure so it can meaningful scream at the user in the next block. This is just a quick preview. For a detailed, line-by-line code review (including bug detection and security checks), please write a comment like |
|
@opgginc/op-gg-ai-devops |
|
this is cool |
✅ AI Code Review Completed
Reviewed with |
There was a problem hiding this comment.
🤖 OP.GG DevOps AI Code Review
The changes successfully align the shell scripts with the main application's logic by implementing dynamic binary discovery. This significantly improves robustness for users who install opencode via Homebrew or other non-standard paths, as recommended in AGENTS.md.
The logic handles both Bash and Zsh environments correctly, and the fallback strategies cover the most common installation scenarios on macOS.
CI/CD Status
No CI/CD checks are associated with this commit (shell script updates only).
Note: To set a default language for future reviews, add the following to your AGENTS.md:
Default review language: English (or your preferred language)
The bot will verify this PR again automatically if you push new commits.
You can trigger a re-review by mentioning @opgginc/op-gg-ai-devops in a comment with specific instructions.
Examples:
@opgginc/op-gg-ai-devops review typos@opgginc/op-gg-ai-devops check for security issues@opgginc/op-gg-ai-devops suggest improvements for error handling
|
|
||
| OPENCODE_BIN="$HOME/.opencode/bin/opencode" | ||
| # Find opencode binary using multiple strategies (matches Swift app approach) | ||
| find_opencode_bin() { |
There was a problem hiding this comment.
This function is identical to the one in scripts/query-opencode-history.sh. If more scripts are added in the future, consider extracting this logic into a shared scripts/common.sh file and sourcing it to reduce duplication and maintenance overhead.
Summary
~/.opencode/bin/opencodepath with a multi-strategy binary discovery function in bothquery-opencode.shandquery-opencode-history.shMotivation
The query scripts previously hardcoded the OpenCode binary path to
$HOME/.opencode/bin/opencode. Users who install OpenCode via Homebrew, pip, or other package managers would get "CLI not found" errors. This mirrors the same fix already applied to the Swift app (seeAGENTS.mdreflection: "Dynamic Binary Search for External Dependencies").Changes
scripts/query-opencode.shandscripts/query-opencode-history.shBoth scripts receive the same
find_opencode_bin()function with three discovery strategies:command -v opencode— checks the current PATH (works for most installations)$SHELL -lc 'which opencode'to pick up PATH additions from.zshrc/.bashrcthat aren't in the current environment/opt/homebrew/bin/opencode(Apple Silicon Homebrew)/usr/local/bin/opencode(Intel Homebrew)$HOME/.opencode/bin/opencode(OpenCode default)$HOME/.local/bin/opencode(pip/pipx)/usr/bin/opencode(system-wide)Error messages now go to stderr and suggest checking PATH rather than pointing to a single hardcoded location.
Whitespace cleanup
Trailing whitespace removed from ~20 lines across both scripts. No functional changes.
Files Changed
scripts/query-opencode.shfind_opencode_bin(), update error messagesscripts/query-opencode-history.shfind_opencode_bin(), update error messages, whitespace cleanup