mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 18:25:00 +00:00
feat: add analytics events for file watching and AI comments
This commit is contained in:
parent
89bc3b6b16
commit
79dd0c5ba6
2 changed files with 7 additions and 5 deletions
|
@ -858,8 +858,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
|
||||||
ignores.append(args.aiderignore)
|
ignores.append(args.aiderignore)
|
||||||
|
|
||||||
if args.watch_files:
|
if args.watch_files:
|
||||||
# AI pass analytics in
|
file_watcher = FileWatcher(coder, gitignores=ignores, verbose=args.verbose, analytics=analytics)
|
||||||
file_watcher = FileWatcher(coder, gitignores=ignores, verbose=args.verbose)
|
|
||||||
coder.file_watcher = file_watcher
|
coder.file_watcher = file_watcher
|
||||||
|
|
||||||
if args.copy_paste:
|
if args.copy_paste:
|
||||||
|
|
|
@ -84,11 +84,12 @@ class FileWatcher:
|
||||||
# Compiled regex pattern for AI comments
|
# Compiled regex pattern for AI comments
|
||||||
ai_comment_pattern = re.compile(r"(?:#|//|--) *(ai\b.*|ai\b.*|.*\bai!?) *$", re.IGNORECASE)
|
ai_comment_pattern = re.compile(r"(?:#|//|--) *(ai\b.*|ai\b.*|.*\bai!?) *$", re.IGNORECASE)
|
||||||
|
|
||||||
def __init__(self, coder, gitignores=None, verbose=False):
|
def __init__(self, coder, gitignores=None, verbose=False, analytics=None):
|
||||||
self.coder = coder
|
self.coder = coder
|
||||||
self.io = coder.io
|
self.io = coder.io
|
||||||
self.root = Path(coder.root)
|
self.root = Path(coder.root)
|
||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
|
self.analytics = analytics
|
||||||
self.stop_event = None
|
self.stop_event = None
|
||||||
self.watcher_thread = None
|
self.watcher_thread = None
|
||||||
self.changed_files = set()
|
self.changed_files = set()
|
||||||
|
@ -171,7 +172,8 @@ class FileWatcher:
|
||||||
|
|
||||||
if fname in self.coder.abs_fnames:
|
if fname in self.coder.abs_fnames:
|
||||||
continue
|
continue
|
||||||
# AI: fire an event()
|
if self.analytics:
|
||||||
|
self.analytics.event("file_added", filename=fname)
|
||||||
self.coder.abs_fnames.add(fname)
|
self.coder.abs_fnames.add(fname)
|
||||||
rel_fname = self.coder.get_rel_fname(fname)
|
rel_fname = self.coder.get_rel_fname(fname)
|
||||||
self.io.tool_output(f"Added {rel_fname} to the chat")
|
self.io.tool_output(f"Added {rel_fname} to the chat")
|
||||||
|
@ -180,7 +182,8 @@ class FileWatcher:
|
||||||
if not has_bangs:
|
if not has_bangs:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
# fire a different event. AI!
|
if self.analytics:
|
||||||
|
self.analytics.event("ai_comment_request")
|
||||||
self.io.tool_output("Processing your request...")
|
self.io.tool_output("Processing your request...")
|
||||||
|
|
||||||
res = """
|
res = """
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue