From ddc97dacf8985c9019948c2c4c2ed39b9cf4facb Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Fri, 26 May 2023 16:22:49 -0700 Subject: [PATCH] aider: Set default values for input and chat history files to be in the git root directory if there is one, otherwise, use the current directory. # Context: USER: have the input and chat history files default to be located in the git root, if there is one ASSISTANT: To change the default location of the input and chat history files to the git root, you need to modify the `aider/main.py` file. Update the default values for `--input-history-file` and `--chat-history-file` arguments. Here's the change: ```python aider/main.py <<<<<<< ORIGINAL parser.add_argument( "--input-history-file", metavar="INPUT_HISTORY_FILE", env_var=f"{env_prefix}INPUT_HISTORY_FILE", default=".aider.input.history", help="Specify the chat input history file (default: .aider.input.history)", ) parser.add_argument( "--chat-history-file", metavar="CHAT_HISTORY_FILE", env_var=f"{env_prefix}CHAT_HISTORY_FILE", default=".aider.chat.history.md", help="Specify the chat history file (default: .aider.chat.history.md)", ) ======= default_input_history_file = os.path.join(git_root, ".aider.input.history") if git_root else ".aider.input.history" default_chat_history_file = os.path.join(git_root, ".aider.chat.history.md") if git_root else ".aider.chat.history.md" parser.add_argument( "--input-history-file", metavar="INPUT_HISTORY_FILE", env_var=f"{env_prefix}INPUT_HISTORY_FILE", default=default_input_history_file, help=f"Specify the chat input history file (default: {default_input_history_file})", ) parser.add_argument( "--chat-history-file", metavar="CHAT_HISTORY_FILE", env_var=f"{env_prefix}CHAT_HISTORY_FILE", default=default_chat_history_file, help=f"Specify the chat history file (default: {default_chat_history_file})", ) >>>>>>> UPDATED ``` This change sets the default values for the input and chat history files to be in the git root directory if there is one, otherwise, it will use the current directory. --- aider/main.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/aider/main.py b/aider/main.py index 547ae5654..69a598d21 100644 --- a/aider/main.py +++ b/aider/main.py @@ -41,19 +41,22 @@ def main(args=None, input=None, output=None): nargs="*", help="a list of source code files (optional)", ) + default_input_history_file = os.path.join(git_root, ".aider.input.history") if git_root else ".aider.input.history" + default_chat_history_file = os.path.join(git_root, ".aider.chat.history.md") if git_root else ".aider.chat.history.md" + parser.add_argument( "--input-history-file", metavar="INPUT_HISTORY_FILE", env_var=f"{env_prefix}INPUT_HISTORY_FILE", - default=".aider.input.history", - help="Specify the chat input history file (default: .aider.input.history)", + default=default_input_history_file, + help=f"Specify the chat input history file (default: {default_input_history_file})", ) parser.add_argument( "--chat-history-file", metavar="CHAT_HISTORY_FILE", env_var=f"{env_prefix}CHAT_HISTORY_FILE", - default=".aider.chat.history.md", - help="Specify the chat history file (default: .aider.chat.history.md)", + default=default_chat_history_file, + help=f"Specify the chat history file (default: {default_chat_history_file})", ) parser.add_argument( "--model",