mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 09:44:59 +00:00
feat: add AI marker detection in source file watcher
This commit is contained in:
parent
d957adf062
commit
43790db48e
1 changed files with 11 additions and 2 deletions
|
@ -93,8 +93,17 @@ def watch_source_files(
|
|||
if ignore_func and ignore_func(rel_path):
|
||||
return False
|
||||
|
||||
# ai: check to see if the file contains "# *ai\w", "// *ai\w", case insensitive and only return files that do
|
||||
return is_source_file(path_obj)
|
||||
if not is_source_file(path_obj):
|
||||
return False
|
||||
|
||||
# Check if file contains AI markers
|
||||
try:
|
||||
with open(path_abs) as f:
|
||||
content = f.read()
|
||||
import re
|
||||
return bool(re.search(r'(?:^|\n)(?:#|//) *ai\w', content, re.IGNORECASE))
|
||||
except (IOError, UnicodeDecodeError):
|
||||
return False
|
||||
|
||||
# Watch the directory for changes
|
||||
for changes in watch(root, watch_filter=filter_func, stop_event=stop_event):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue