From 7122ceb16c9c1b9a3af530b003757c5006c5d9eb Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Mon, 25 Nov 2024 18:34:05 -0800 Subject: [PATCH] feat: add --detect-urls flag to control URL detection behavior --- aider/args.py | 6 ++++++ aider/coders/base_coder.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/aider/args.py b/aider/args.py index 0ea85182f..f38113a3f 100644 --- a/aider/args.py +++ b/aider/args.py @@ -738,6 +738,12 @@ def get_parser(default_config_files, git_root): default=True, help="Enable/disable fancy input with history and completion (default: True)", ) + group.add_argument( + "--detect-urls", + action=argparse.BooleanOptionalAction, + default=True, + help="Enable/disable detection and offering to add URLs to chat (default: True)", + ) group.add_argument( "--editor", help="Specify which editor to use for the /editor command", diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index e1f4cfc04..11d05929f 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -91,6 +91,7 @@ class Coder: cache_warming_thread = None num_cache_warming_pings = 0 suggest_shell_commands = True + detect_urls = True ignore_mentions = None chat_language = None @@ -267,6 +268,7 @@ class Coder: num_cache_warming_pings=0, suggest_shell_commands=True, chat_language=None, + detect_urls=True, ): # Fill in a dummy Analytics if needed, but it is never .enable()'d self.analytics = analytics if analytics is not None else Analytics() @@ -280,6 +282,7 @@ class Coder: self.ignore_mentions = set() self.suggest_shell_commands = suggest_shell_commands + self.detect_urls = detect_urls self.num_cache_warming_pings = num_cache_warming_pings @@ -812,6 +815,9 @@ class Coder: def check_for_urls(self, inp: str) -> List[str]: """Check input for URLs and offer to add them to the chat.""" + if not self.detect_urls: + return [] + url_pattern = re.compile(r"(https?://[^\s/$.?#].[^\s]*[^\s,.])") urls = list(set(url_pattern.findall(inp))) # Use set to remove duplicates added_urls = []