diff --git a/aider/watch.py b/aider/watch.py index b28a2b067..2b21fe425 100644 --- a/aider/watch.py +++ b/aider/watch.py @@ -9,7 +9,7 @@ from pathspec.patterns import GitWildMatchPattern from watchfiles import watch from aider.dump import dump # noqa -from aider.watch_prompts import watch_prompt +from aider.watch_prompts import watch_ask_prompt, watch_code_prompt def is_source_file(path: Path) -> bool: @@ -188,11 +188,14 @@ class FileWatcher: self.analytics.event("ai-comments execute") self.io.tool_output("Processing your request...") - res = watch_prompt + if has_action == "!": + res = watch_code_prompt + elif has_action == "?": + res = watch_ask_prompt # Refresh all AI comments from tracked files for fname in self.coder.abs_fnames: - line_nums, comments, _has_bang = self.get_ai_comments(fname) + line_nums, comments, _action = self.get_ai_comments(fname) if not line_nums: continue diff --git a/aider/watch_prompts.py b/aider/watch_prompts.py index 138651d82..898e3bee2 100644 --- a/aider/watch_prompts.py +++ b/aider/watch_prompts.py @@ -1,6 +1,11 @@ -watch_prompt = """ +watch_code_prompt = """ Find the "AI" comments below (marked with █) in the code files I've shared with you. They contain your instructions. Make the requested changes. Be sure to remove all these "AI" comments from the code! """ + +watch_ask_prompt = """/ask +Find the "AI" comments below (marked with █) in the code files I've shared with you. +They contain your questions you need to answer and other instructions. +""" diff --git a/tests/basic/test_watch.py b/tests/basic/test_watch.py index f4d8de012..5484934a2 100644 --- a/tests/basic/test_watch.py +++ b/tests/basic/test_watch.py @@ -32,7 +32,7 @@ def test_ai_comment_pattern(): f"Expected {py_expected} unique AI comments in Python fixture, found" f" {len(unique_py_comments)}" ) - assert py_has_bang, "Expected at least one bang (!) comment in Python fixture" + assert py_has_bang == "!", "Expected at least one bang (!) comment in Python fixture" # Test JavaScript fixture js_path = fixtures_dir / "watch.js" @@ -41,18 +41,18 @@ def test_ai_comment_pattern(): assert ( len(js_lines) == js_expected ), f"Expected {js_expected} AI comments in JavaScript fixture, found {len(js_lines)}" - assert js_has_bang, "Expected at least one bang (!) comment in JavaScript fixture" + assert js_has_bang == "!", "Expected at least one bang (!) comment in JavaScript fixture" # Test watch_question.js fixture question_js_path = fixtures_dir / "watch_question.js" question_js_lines, question_js_comments, question_js_has_bang = watcher.get_ai_comments( str(question_js_path) ) - question_js_expected = 5 + question_js_expected = 6 assert len(question_js_lines) == question_js_expected, ( f"Expected {question_js_expected} AI comments in watch_question.js fixture, found" f" {len(question_js_lines)}" ) assert ( - question_js_has_bang + question_js_has_bang == "?" ), "Expected at least one bang (!) comment in watch_question.js fixture"