feat: follow XDG spec on linux/mac and use windows known folders for config and logs (#1153)

This commit is contained in:
Kalvin C
2025-02-11 08:47:28 -08:00
committed by GitHub
parent 01aeeaf413
commit 54af4c914c
19 changed files with 163 additions and 63 deletions

View File

@@ -3,6 +3,7 @@ mod shell;
use anyhow::Result;
use base64::Engine;
use etcetera::{choose_app_strategy, AppStrategy};
use indoc::formatdoc;
use serde_json::{json, Value};
use std::{
@@ -278,9 +279,16 @@ impl DeveloperRouter {
},
};
// Check for global hints in ~/.config/goose/.goosehints
let global_hints_path =
PathBuf::from(shellexpand::tilde("~/.config/goose/.goosehints").to_string());
// choose_app_strategy().config_dir()
// - macOS/Linux: ~/.config/goose/
// - Windows: ~\AppData\Roaming\Block\goose\config\
// keep previous behavior of expanding ~/.config in case this fails
let global_hints_path = choose_app_strategy(crate::APP_STRATEGY.clone())
.map(|strategy| strategy.in_config_dir(".goosehints"))
.unwrap_or_else(|_| {
PathBuf::from(shellexpand::tilde("~/.config/goose/.goosehints").to_string())
});
// Create the directory if it doesn't exist
let _ = std::fs::create_dir_all(global_hints_path.parent().unwrap());