Repository navigation
fix(hooks): read OpenCode 1.x global rules from XDG_CONFIG_HOME and config.json (#4520) - #4932
Open
feliperm17 wants to merge 1 commit into
Open
feliperm17 wants to merge 1 commit into
feliperm17 wants to merge 1 commit into
Conversation
📊 Automated PR Analysis
SummaryFixes OpenCode global config discovery to follow OpenCode 1.x/xdg-basedir semantics: global_opencode_dir() now resolves $XDG_CONFIG_HOME/opencode when the env var is non-empty instead of always defaulting to ~/.config/opencode, and global config loading is split from project discovery so config.json, opencode.json, and opencode.jsonc are merged in OpenCode's precedence order (with permission shorthand normalization) while project discovery still only looks at opencode.json(c). Adds unit and sub… Review Checklist
Linked issues: #4520 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4520
Summary
global_opencode_dir()insrc/hooks/permissions_opencode.rsto resolve$XDG_CONFIG_HOME/opencodewhenXDG_CONFIG_HOMEis non-empty (without falling back to~/.config/opencodewhen absent on disk, matching OpenCode 1.18.34 /xdg-basedir), covering both global JSON configs and global markdown agent rules (agents/andagent/).read_global_config) from project discovery (CONFIG_NAMES), mergingconfig.json,opencode.json, andopencode.jsoncin order (preserving key positions on overwrite and normalizing root/agentpermissionstring shorthands prior to merging) while keeping project discovery restricted toopencode.json(c).src/hooks/permissions_opencode.rsand 7 subprocess integration tests intests/hook_config_io_test.rscovering all three required 1.x rows (XDG_CONFIG_HOMEset,config.jsonasks,XDG_CONFIG_HOMEunset/empty), global file precedence/merging, XDG markdown agents, and ignoring generic projectconfig.jsonfiles.Test plan
cargo fmt --all && cargo clippy --all-targets && cargo test(5,442 passed, 0 failed, 8 ignored; zero clippy warnings or fmt diffs)rtk <command>output inspected (rtk hook opencode -- ls -laverified across$XDG_CONFIG_HOME/opencode/opencode.json,config.jsonunder both XDG and~/.config/opencode,XDG_CONFIG_HOMEunset/empty, and XDG markdown agents)