Returns the path to opencode config (global). Prefers `$HOME/.config/opencode/opencode.json`. Falls back to `$XDG_CONFIG_HOME/opencode/opencode.json` only when the XDG path is under `home` (so tests with temp-dir homes are never polluted by the real user's environment).
(home: &Path)
| 166 | /// is under `home` (so tests with temp-dir homes are never polluted by |
| 167 | /// the real user's environment). |
| 168 | fn opencode_config_path(home: &Path) -> std::path::PathBuf { |
| 169 | if let Ok(xdg) = std::env::var("XDG_CONFIG_HOME") { |
| 170 | let xdg_path = std::path::PathBuf::from(&xdg); |
| 171 | if xdg_path.starts_with(home) { |
| 172 | return xdg_path.join("opencode/opencode.json"); |
| 173 | } |
| 174 | } |
| 175 | home.join(".config/opencode/opencode.json") |
| 176 | } |
| 177 | |
| 178 | /// Returns the path to the global AGENTS.md prompt file. |
| 179 | fn opencode_prompt_path(home: &Path) -> std::path::PathBuf { |
no outgoing calls
no test coverage detected