refactor: improve AI comment pattern regex for better matching

This commit is contained in:
Paul Gauthier 2024-12-01 09:58:02 -08:00 committed by Paul Gauthier (aider)
parent 5fdbfef028
commit 221b382e69

View file

@ -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