diff --git a/aider/args.py b/aider/args.py index ce8256dfa..8dee479b4 100644 --- a/aider/args.py +++ b/aider/args.py @@ -295,7 +295,7 @@ def get_parser(default_config_files, git_root): default=None, help=( "Specify a directory to archive dated chat history files (e.g., .ai-chats). If set," - " chat history files will be saved as YYYY-MM-DD HH-MM.aider.md (or YYYY-MM-DD HH-MM" + " chat history files will be saved as YYYY-MM-DD HH-MM.aider.md (or YYYY-MM-DD" " TASK_TITLE.aider.md if --task is used) in this directory, overriding the" " --chat-history-file setting." ), @@ -306,7 +306,7 @@ def get_parser(default_config_files, git_root): default=None, help=( "Specify a title for the chat session. If --chat-history-archive is enabled, this" - " title will be included in the archived chat history filename (e.g., YYYY-MM-DD HH-MM" + " title will be included in the archived chat history filename (e.g., YYYY-MM-DD" " TASK_TITLE.aider.md)." ), ) diff --git a/aider/main.py b/aider/main.py index 39f489028..b15b62e3a 100644 --- a/aider/main.py +++ b/aider/main.py @@ -506,18 +506,20 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F if args.chat_history_archive: archive_dir = Path(args.chat_history_archive).resolve() - datetime_str = datetime.datetime.now().strftime("%Y-%m-%d %H-%M") + now = datetime.datetime.now() + + datetime_str = now.strftime("%Y-%m-%d %H-%M") + dated_filename = f"{datetime_str}.aider.md" - task_title_for_filename = "" if args.task: # Sanitize the task title for use in a filename. Keep only allowed characters. allowed_chars = ".,_-+#%&'!()[]=; " core_sanitized_title = "".join([c for c in args.task if c.isalnum() or c in allowed_chars]).strip() if core_sanitized_title: - task_title_for_filename = " " + core_sanitized_title + date_str = now.strftime("%Y-%m-%d") + dated_filename = f"{date_str} {core_sanitized_title}.aider.md" - dated_filename = f"{datetime_str}{task_title_for_filename}.aider.md" final_chat_history_path = archive_dir / dated_filename os.makedirs(archive_dir, exist_ok=True) diff --git a/aider/website/assets/sample.aider.conf.yml b/aider/website/assets/sample.aider.conf.yml index 671104516..3a19057e7 100644 --- a/aider/website/assets/sample.aider.conf.yml +++ b/aider/website/assets/sample.aider.conf.yml @@ -153,7 +153,7 @@ #restore-chat-history: false ## Specify a directory to archive dated chat history files. -## If set, files like YYYY-MM-DD HH-MM.aider.md (or YYYY-MM-DD HH-MM TASK_TITLE.aider.md if --task is used) +## If set, files like YYYY-MM-DD HH-MM.aider.md (or YYYY-MM-DD TASK_TITLE.aider.md if --task is used) ## will be saved here, overriding the chat-history-file setting. #chat-history-archive: .ai-chats diff --git a/aider/website/docs/config/aider_conf.md b/aider/website/docs/config/aider_conf.md index ffcf266ec..b812a84bf 100644 --- a/aider/website/docs/config/aider_conf.md +++ b/aider/website/docs/config/aider_conf.md @@ -208,7 +208,7 @@ cog.outl("```") #restore-chat-history: false ## Specify a directory to archive dated chat history files. -## If set, files like YYYY-MM-DD HH-MM.aider.md (or YYYY-MM-DD HH-MM TASK_TITLE.aider.md if --task is used) +## If set, files like YYYY-MM-DD HH-MM.aider.md (or YYYY-MM-DD TASK_TITLE.aider.md if --task is used) ## will be saved here, overriding the chat-history-file setting. #chat-history-archive: .ai-chats diff --git a/aider/website/docs/config/options.md b/aider/website/docs/config/options.md index e66f72776..712581452 100644 --- a/aider/website/docs/config/options.md +++ b/aider/website/docs/config/options.md @@ -289,12 +289,12 @@ Aliases: - `--no-restore-chat-history` ### `chat-history-archive CHAT_HISTORY_ARCHIVE_DIR` -Specify a directory to archive dated chat history files (e.g., `.ai-chats`). If set, chat history files will be saved as `YYYY-MM-DD HH-MM.aider.md` (or `YYYY-MM-DD HH-MM TASK_TITLE.aider.md` if `--task` is used) in this directory, overriding the `--chat-history-file` setting. This option is typically set in the `.aider.conf.yml` file or via the `AIDER_CHAT_HISTORY_ARCHIVE` environment variable. +Specify a directory to archive dated chat history files (e.g., `.ai-chats`). If set, chat history files will be saved as `YYYY-MM-DD HH-MM.aider.md` (or `YYYY-MM-DD TASK_TITLE.aider.md` if `--task` is used) in this directory, overriding the `--chat-history-file` setting. This option is typically set in the `.aider.conf.yml` file or via the `AIDER_CHAT_HISTORY_ARCHIVE` environment variable. Default: None Environment variable: `AIDER_CHAT_HISTORY_ARCHIVE` ### `--task TASK_TITLE` -Specify a title for the chat session. If `--chat-history-archive` is enabled, this title will be included in the archived chat history filename (e.g., `YYYY-MM-DD HH-MM TASK_TITLE.aider.md`). +Specify a title for the chat session. If `--chat-history-archive` is enabled, this title will be included in the archived chat history filename (e.g., `YYYY-MM-DD TASK_TITLE.aider.md`). Environment variable: `AIDER_TASK` ### `--llm-history-file LLM_HISTORY_FILE`