fix: improve AI comment detection with case-insensitive matching

This commit is contained in:
Paul Gauthier 2024-12-02 08:57:50 -08:00 committed by Paul Gauthier (aider)
parent 5b2bd90071
commit fb005dd01b

View file

@ -11,7 +11,6 @@ from watchfiles import watch
from aider.dump import dump # noqa
# ai
def is_source_file(path: Path) -> bool:
"""
Check if a file is a source file that uses # or // style comments.
@ -226,8 +225,10 @@ Be sure to remove all these "ai" comments from the code!
if comment:
line_nums.append(i)
comments.append(comment)
# Use the ai regex, but ensure it's "ai!" ... AI!
if comment.strip().endswith("!"):
comment = comment.lower()
comment = comment.lstrip("/#-")
comment = comment.strip()
if comment.startswith("ai!") or comment.endswith("ai!"):
has_bang = True
if not line_nums:
return None, None, False