From 221b382e6956efc3bb65f7dc552e43bdbd9e40ca Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sun, 1 Dec 2024 09:58:02 -0800 Subject: [PATCH] refactor: improve AI comment pattern regex for better matching --- aider/watch.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/aider/watch.py b/aider/watch.py index 735986ed8..c17d3e0c3 100644 --- a/aider/watch.py +++ b/aider/watch.py @@ -3,10 +3,11 @@ import threading from pathlib import Path from typing import Optional -from grep_ast import TreeContext from pathspec import PathSpec from pathspec.patterns import GitWildMatchPattern from watchfiles import watch +from grep_ast import TreeContext + from aider.dump import dump # noqa @@ -65,7 +66,8 @@ class FileWatcher: """Watches source files for changes and AI comments""" # Compiled regex pattern for AI comments - ai_comment_pattern = re.compile(r"(?:#|//) *.*\bai!? *$", re.IGNORECASE) + ai_comment_pattern = re.compile(r"(?:#|//) *(ai\b.*|ai|.*\bai!?)", re.IGNORECASE) + def __init__(self, coder, gitignores=None, verbose=False): self.coder = coder