You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OpenCode 1.x: rtk misses global rules under $XDG_CONFIG_HOME/opencode and in config.json #4520
On OpenCode 1.x, rtk hook opencode still judges a rewrite against OpenCode's permission rules rebuilt from config files. That's the 1.x path: 1.x sends no agent field and has no API that returns the resolved rules. #4521 covers 2.x, where the plugin can get the resolved rules from OpenCode instead.
rtk reads the global rules from ~/.config/opencode/opencode.json(c) only (global_opencode_dir and CONFIG_NAMES in src/hooks/permissions_opencode.rs, unchanged on develop). Measured on 1.18.34, OpenCode reads more:
$XDG_CONFIG_HOME/opencode when the variable is set. With {"permission":{"bash":{"ls *":"ask"}}} only in $XDG_CONFIG_HOME/opencode/opencode.json, OpenCode alone asked for ls -la, and without the variable it ran the command. rtk doesn't see that rule, so it judges ls -la and rtk ls -la the same and rewrites, and the rewritten command no longer matches the ask.
config.json as well as opencode.json/opencode.jsonc. OpenCode's log shows loading path=…/opencode/config.json first. rtk reads only the latter two names.
Found while reviewing #4187. Low priority: it needs XDG_CONFIG_HOME set, or rules kept in config.json, on a 1.x install.
Rows a fix has to pass on 1.x:
with XDG_CONFIG_HOME set, an ask in $XDG_CONFIG_HOME/opencode/opencode.json still prompts;
an ask in config.json still prompts;
with XDG_CONFIG_HOME unset, ~/.config/opencode keeps working.
rtk only reads OpenCode global config/agent files from ~/.config/opencode, ignoring $XDG_CONFIG_HOME/opencode, causing missed permission rules and incorrect rewrites
This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.
📁 Relevant files
src/hooks/permissions_opencode.rs
Suggested Actions
Update global_opencode_dir in src/hooks/permissions_opencode.rs to check $XDG_CONFIG_HOME first, falling back to ~/.c…
Apply the same fix to the global agent markdown file lookup path
Add tests for all three rows: XDG ask-rule, XDG agent-file permissions, and unset-XDG fallback
changed the title [-]OpenCode: rtk reads the global config and agent files from `~/.config/opencode` only, not `$XDG_CONFIG_HOME/opencode`[/-][+]OpenCode 1.x: rtk misses global rules under `$XDG_CONFIG_HOME/opencode` and in `config.json`[/+]on Oct 11, 2026
Hi @KuSh! While diagnosing #4638 in src/hooks/permissions_opencode.rs, I also reproduced the $XDG_CONFIG_HOME/opencode gap locally (rules placed solely under $XDG_CONFIG_HOME/opencode are currently skipped because global_opencode_dir falls back directly to $HOME/.config/opencode).
I'd love to take this one on as well — updating global_opencode_dir to respect XDG_CONFIG_HOME (when non-empty) before $HOME/.config/opencode, adding config.json support alongside opencode.json/opencode.jsonc, and covering the precedence order with unit tests in permissions_opencode::tests.
I can base it on top of #4458 (or coordinate it cleanly with the #4638 1.x follow-up) so there are no merge conflicts. Could you assign this to me?
Hi @KuSh! I've opened #4932 targeting develop to resolve this:
global_opencode_dir() now uses $XDG_CONFIG_HOME/opencode when XDG_CONFIG_HOME is non-empty (and ~/.config/opencode when unset/empty), which also covers global markdown agent checks under agents/ and agent/.
Global config loading now merges config.json -> opencode.json -> opencode.jsonc in order (keeping project discovery restricted to opencode.json and opencode.jsonc).
There are 2 open pull requests for this issue: #4522, #4932 (oldest first).
If you were about to start on it, reviewing or testing one of these helps more than another pull request: a note on which approach fits, or a test result on your setup, is welcome on the pull request itself.
Activity
rtk-wshm-sync-bot commentedon Oct 11, 2026
🔍 Automated Triage
bughighSummary
rtk only reads OpenCode global config/agent files from ~/.config/opencode, ignoring $XDG_CONFIG_HOME/opencode, causing missed permission rules and incorrect rewrites
📁 Relevant files
src/hooks/permissions_opencode.rsSuggested Actions
global_opencode_dirin src/hooks/permissions_opencode.rs to check $XDG_CONFIG_HOME first, falling back to ~/.c…rtk hook check --agent opencodejudges differently from the plugin #4518 for overlapping root causeTriaged automatically by wshm · This is an automated analysis, not a human review.
[-]OpenCode: rtk reads the global config and agent files from `~/.config/opencode` only, not `$XDG_CONFIG_HOME/opencode`[/-][+]OpenCode 1.x: rtk misses global rules under `$XDG_CONFIG_HOME/opencode` and in `config.json`[/+]feliperm17 commentedon Oct 29, 2026
Hi @KuSh! While diagnosing #4638 in
src/hooks/permissions_opencode.rs, I also reproduced the$XDG_CONFIG_HOME/opencodegap locally (rules placed solely under$XDG_CONFIG_HOME/opencodeare currently skipped becauseglobal_opencode_dirfalls back directly to$HOME/.config/opencode).I'd love to take this one on as well — updating
global_opencode_dirto respectXDG_CONFIG_HOME(when non-empty) before$HOME/.config/opencode, addingconfig.jsonsupport alongsideopencode.json/opencode.jsonc, and covering the precedence order with unit tests inpermissions_opencode::tests.I can base it on top of #4458 (or coordinate it cleanly with the #4638 1.x follow-up) so there are no merge conflicts. Could you assign this to me?
feliperm17 commentedon Nov 1, 2026
Hi @KuSh! I've opened #4932 targeting
developto resolve this:global_opencode_dir()now uses$XDG_CONFIG_HOME/opencodewhenXDG_CONFIG_HOMEis non-empty (and~/.config/opencodewhen unset/empty), which also covers global markdown agent checks underagents/andagent/.config.json->opencode.json->opencode.jsoncin order (keeping project discovery restricted toopencode.jsonandopencode.jsonc).KuSh commentedon Nov 8, 2026
There are 2 open pull requests for this issue: #4522, #4932 (oldest first).
If you were about to start on it, reviewing or testing one of these helps more than another pull request: a note on which approach fits, or a test result on your setup, is welcome on the pull request itself.