feat: Load OAuth keys from ~/.aider/oauth-keys.env

This commit is contained in:
Paul Gauthier (aider) 2025-03-28 17:33:30 -10:00
parent 15cec5bd50
commit 290fd99b6d

View file

@ -358,11 +358,21 @@ def register_models(git_root, model_settings_fname, io, verbose=False):
def load_dotenv_files(git_root, dotenv_fname, encoding="utf-8"):
# Standard .env file search path
dotenv_files = generate_search_path_list(
".env",
git_root,
dotenv_fname,
)
# Explicitly add the OAuth keys file to the beginning of the list
oauth_keys_file = Path.home() / ".aider" / "oauth-keys.env"
if oauth_keys_file.exists():
# Insert at the beginning so it's loaded first (and potentially overridden)
dotenv_files.insert(0, str(oauth_keys_file.resolve()))
# Remove duplicates if it somehow got included by generate_search_path_list
dotenv_files = list(dict.fromkeys(dotenv_files))
loaded = []
for fname in dotenv_files:
try: