mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 16:54:59 +00:00
feat: Add support for ! and ? action comments
This commit is contained in:
parent
b16ba547ab
commit
11512c6281
3 changed files with 16 additions and 8 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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.
|
||||
"""
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue