From f05f8df44c8f98d782b4713b6e2c517b61f0d127 Mon Sep 17 00:00:00 2001 From: "Matteo Landi (aider)" Date: Wed, 26 Mar 2025 08:13:09 +0100 Subject: [PATCH 1/3] refactor: Add support for Lisp-style comments in file watcher --- aider/watch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aider/watch.py b/aider/watch.py index 5dd770976..f6b77d18c 100644 --- a/aider/watch.py +++ b/aider/watch.py @@ -64,7 +64,7 @@ class FileWatcher: """Watches source files for changes and 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, analytics=None, root=None): self.coder = coder From 7d5f1143afb15fba6f623160baeb4840e0ad6933 Mon Sep 17 00:00:00 2001 From: "Matteo Landi (aider)" Date: Wed, 26 Mar 2025 08:17:29 +0100 Subject: [PATCH 2/3] test: Add Lisp-style comment tests to file watcher --- tests/basic/test_watch.py | 9 +++++++++ tests/fixtures/watch.lisp | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/fixtures/watch.lisp diff --git a/tests/basic/test_watch.py b/tests/basic/test_watch.py index 706fd1ade..524f80e08 100644 --- a/tests/basic/test_watch.py +++ b/tests/basic/test_watch.py @@ -155,3 +155,12 @@ def test_ai_comment_pattern(): assert ( question_js_has_bang == "?" ), "Expected at least one bang (!) comment in watch_question.js fixture" + + # Test Lisp fixture + lisp_path = fixtures_dir / "watch.lisp" + lisp_lines, lisp_comments, lisp_has_bang = watcher.get_ai_comments(str(lisp_path)) + lisp_expected = 7 + assert ( + len(lisp_lines) == lisp_expected + ), f"Expected {lisp_expected} AI comments in Lisp fixture, found {len(lisp_lines)}" + assert lisp_has_bang == "!", "Expected at least one bang (!) comment in Lisp fixture" diff --git a/tests/fixtures/watch.lisp b/tests/fixtures/watch.lisp new file mode 100644 index 000000000..1aae8fb8f --- /dev/null +++ b/tests/fixtures/watch.lisp @@ -0,0 +1,19 @@ +(defun hello-world () + ;; ai this is a simple hello world function + (format t "Hello, World!")) + +(defun add (a b) + ; ai! fix this function to handle nil values + (+ a b)) + +(defun multiply (a b) + ;;; ai? why is this function not working with large numbers? + (* a b)) + +; ai this is a single semicolon comment + +;; ai this is a double semicolon comment + +;;; ai this is a triple semicolon comment + +;;;; ai! this is a quadruple semicolon comment From fab713a6a8b2e814f92ffde238e449ebd4f33c07 Mon Sep 17 00:00:00 2001 From: "Matteo Landi (aider)" Date: Wed, 26 Mar 2025 13:01:53 +0100 Subject: [PATCH 3/3] fix: Handle Lisp semicolon comments in watch.py --- aider/watch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aider/watch.py b/aider/watch.py index f6b77d18c..e7b115730 100644 --- a/aider/watch.py +++ b/aider/watch.py @@ -262,7 +262,7 @@ class FileWatcher: line_nums.append(i) comments.append(comment) comment = comment.lower() - comment = comment.lstrip("/#-") + comment = comment.lstrip("/#-;") # Added semicolon for Lisp comments comment = comment.strip() if comment.startswith("ai!") or comment.endswith("ai!"): has_action = "!"