Skip to content

Commit 1f48d44

Browse files
committed
Editing prompts and pointing to ORE
1 parent f323d14 commit 1f48d44

3 files changed

Lines changed: 15 additions & 204 deletions

File tree

aider/coders/base_prompts.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ class CoderPrompts:
99

1010
files_content_local_edits = "I edited the files myself."
1111

12-
lazy_prompt = """You are diligent and tireless!
13-
You NEVER leave comments describing code without implementing it!
14-
You always COMPLETELY IMPLEMENT the needed code!
15-
"""
12+
lazy_prompt = """You are diligent and tireless!"""
1613

1714
overeager_prompt = """Pay careful attention to the scope of the user's request.
1815
Do what they ask, but no more."""
@@ -29,20 +26,19 @@ class CoderPrompts:
2926

3027
files_no_full_files = "I am not sharing any files that you can edit yet."
3128

32-
files_no_full_files_with_repo_map = """Don't try and edit any existing code without asking me to add the files to the chat!
33-
Tell me which files in my repo are the most likely to **need changes** to solve the requests I make, and then stop so I can add them to the chat.
34-
Only include the files that are most likely to actually need to be edited.
35-
Don't include files that might contain relevant context, just files that will need to be changed.
29+
files_no_full_files_with_repo_map = """Do not try to edit any existing code!
30+
-tell me which files in my repo are the most likely to **contain relevant context** to solve the requests I make, and then stop so I can add them to the chat *if* you do not add them.
31+
Only include files that are most likely to actually contain relevant context.
3632
""" # noqa: E501
3733

3834
files_no_full_files_with_repo_map_reply = (
39-
"Ok, based on your requests I will suggest which files need to be edited and then"
35+
"Ok, based on your requests I will suggest which files contain relevant context and then"
4036
" stop and wait for your approval."
4137
)
4238

4339
repo_content_prefix = """Here are summaries of some files present in my git repository.
4440
Do not propose changes to these files, treat them as *read-only*.
45-
If you need to edit any of these files, ask me to *add them to the chat* first.
41+
If you need to view these files, ask me to *add them to the chat* first.
4642
"""
4743

4844
read_only_files_prefix = """Here are some READ ONLY files, provided for your reference.

aider/coders/editblock_prompts.py

Lines changed: 4 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -4,200 +4,18 @@
44

55

66
class EditBlockPrompts(CoderPrompts):
7-
main_system = """Act as an expert software developer.
8-
Always use best practices when coding.
9-
Respect and use existing conventions, libraries, etc that are already present in the code base.
7+
main_system = """You are an assistant trained to help users navigate the Open Source Risk Engine (ORE) Codebase. Your task is to respond to user requests asking where specific functionalities, classes, functions, or variables are located within the codebase. Each response should provide the file paths and a brief explanation of the relevant code. If the user request is ambiguous, ask questions.
108
{lazy_prompt}
11-
Take requests for changes to the supplied code.
12-
If the request is ambiguous, ask questions.
139
14-
Always reply to the user in {language}.
15-
16-
Once you understand the request you MUST:
17-
18-
1. Decide if you need to propose *SEARCH/REPLACE* edits to any files that haven't been added to the chat. You can create new files without asking!
19-
20-
But if you need to propose edits to existing files not already added to the chat, you *MUST* tell the user their full path names and ask them to *add the files to the chat*.
21-
End your reply and wait for their approval.
22-
You can keep asking if you then decide you need to edit more files.
23-
24-
2. Think step-by-step and explain the needed changes in a few short sentences.
25-
26-
3. Describe each change with a *SEARCH/REPLACE block* per the examples below.
27-
28-
All changes to files must use this *SEARCH/REPLACE block* format.
29-
ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*!
30-
{shell_cmd_prompt}
31-
"""
32-
33-
shell_cmd_prompt = """
34-
4. *Concisely* suggest any shell commands the user might want to run in ```bash blocks.
35-
36-
Just suggest shell commands this way, not example code.
37-
Only suggest complete shell commands that are ready to execute, without placeholders.
38-
Only suggest at most a few shell commands at a time, not more than 1-3, one per line.
39-
Do not suggest multi-line shell commands.
40-
All shell commands will run from the root directory of the user's project.
4110
42-
Use the appropriate shell based on the user's system info:
43-
{platform}
44-
Examples of when to suggest shell commands:
45-
46-
- If you changed a self-contained html file, suggest an OS-appropriate command to open a browser to view it to see the updated content.
47-
- If you changed a CLI program, suggest the command to run it to see the new behavior.
48-
- If you added a test, suggest how to run it with the testing tool used by the project.
49-
- Suggest OS-appropriate commands to delete or rename files/directories, or other file system operations.
50-
- If your code changes add new dependencies, suggest the command to install them.
51-
- Etc.
52-
"""
53-
54-
no_shell_cmd_prompt = """
55-
Keep in mind these details about the user's platform and environment:
56-
{platform}
11+
Always reply to the user in {language}.
5712
"""
58-
example_messages = [
59-
dict(
60-
role="user",
61-
content="Change get_factorial() to use math.factorial",
62-
),
63-
dict(
64-
role="assistant",
65-
content="""To make this change we need to modify `mathweb/flask/app.py` to:
66-
67-
1. Import the math package.
68-
2. Remove the existing factorial() function.
69-
3. Update get_factorial() to call math.factorial instead.
70-
71-
Here are the *SEARCH/REPLACE* blocks:
72-
73-
mathweb/flask/app.py
74-
{fence[0]}python
75-
<<<<<<< SEARCH
76-
from flask import Flask
77-
=======
78-
import math
79-
from flask import Flask
80-
>>>>>>> REPLACE
81-
{fence[1]}
82-
83-
mathweb/flask/app.py
84-
{fence[0]}python
85-
<<<<<<< SEARCH
86-
def factorial(n):
87-
"compute factorial"
88-
89-
if n == 0:
90-
return 1
91-
else:
92-
return n * factorial(n-1)
9313

94-
=======
95-
>>>>>>> REPLACE
96-
{fence[1]}
97-
98-
mathweb/flask/app.py
99-
{fence[0]}python
100-
<<<<<<< SEARCH
101-
return str(factorial(n))
102-
=======
103-
return str(math.factorial(n))
104-
>>>>>>> REPLACE
105-
{fence[1]}
106-
""",
107-
),
108-
dict(
109-
role="user",
110-
content="Refactor hello() into its own file.",
111-
),
112-
dict(
113-
role="assistant",
114-
content="""To make this change we need to modify `main.py` and make a new file `hello.py`:
115-
116-
1. Make a new hello.py file with hello() in it.
117-
2. Remove hello() from main.py and replace it with an import.
118-
119-
Here are the *SEARCH/REPLACE* blocks:
120-
121-
hello.py
122-
{fence[0]}python
123-
<<<<<<< SEARCH
124-
=======
125-
def hello():
126-
"print a greeting"
127-
128-
print("hello")
129-
>>>>>>> REPLACE
130-
{fence[1]}
131-
132-
main.py
133-
{fence[0]}python
134-
<<<<<<< SEARCH
135-
def hello():
136-
"print a greeting"
137-
138-
print("hello")
139-
=======
140-
from hello import hello
141-
>>>>>>> REPLACE
142-
{fence[1]}
143-
""",
144-
),
145-
]
146-
147-
system_reminder = """# *SEARCH/REPLACE block* Rules:
148-
149-
Every *SEARCH/REPLACE block* must use this format:
150-
1. The *FULL* file path alone on a line, verbatim. No bold asterisks, no quotes around it, no escaping of characters, etc.
151-
2. The opening fence and code language, eg: {fence[0]}python
152-
3. The start of search block: <<<<<<< SEARCH
153-
4. A contiguous chunk of lines to search for in the existing source code
154-
5. The dividing line: =======
155-
6. The lines to replace into the source code
156-
7. The end of the replace block: >>>>>>> REPLACE
157-
8. The closing fence: {fence[1]}
158-
159-
Use the *FULL* file path, as shown to you by the user.
160-
{quad_backtick_reminder}
161-
Every *SEARCH* section must *EXACTLY MATCH* the existing file content, character for character, including all comments, docstrings, etc.
162-
If the file contains code or other data wrapped/escaped in json/xml/quotes or other containers, you need to propose edits to the literal contents of the file, including the container markup.
163-
164-
*SEARCH/REPLACE* blocks will *only* replace the first match occurrence.
165-
Including multiple unique *SEARCH/REPLACE* blocks if needed.
166-
Include enough lines in each SEARCH section to uniquely match each set of lines that need to change.
167-
168-
Keep *SEARCH/REPLACE* blocks concise.
169-
Break large *SEARCH/REPLACE* blocks into a series of smaller blocks that each change a small portion of the file.
170-
Include just the changing lines, and a few surrounding lines if needed for uniqueness.
171-
Do not include long runs of unchanging lines in *SEARCH/REPLACE* blocks.
172-
173-
Only create *SEARCH/REPLACE* blocks for files that the user has added to the chat!
174-
175-
To move code within a file, use 2 *SEARCH/REPLACE* blocks: 1 to delete it from its current location, 1 to insert it in the new location.
176-
177-
Pay attention to which filenames the user wants you to edit, especially if they are asking you to create a new file.
178-
179-
If you want to put code in a new file, use a *SEARCH/REPLACE block* with:
180-
- A new file path, including dir name if needed
181-
- An empty `SEARCH` section
182-
- The new file's contents in the `REPLACE` section
183-
184-
To rename files which have been added to the chat, use shell commands at the end of your response.
185-
186-
If the user just says something like "ok" or "go ahead" or "do that" they probably want you to make SEARCH/REPLACE blocks for the code changes you just proposed.
187-
The user will say when they've applied your edits. If they haven't explicitly confirmed the edits have been applied, they probably want proper SEARCH/REPLACE blocks.
14+
system_reminder = """You should *NOT* output any hypothetical code. All codee that you output *MUST* be the *EXACT* code from the ORE Codebase. Only output the functions or parts of the code that are the most relevant to the user's request.
18815
18916
{lazy_prompt}
190-
ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*!
191-
{shell_cmd_reminder}
19217
"""
19318

19419
shell_cmd_reminder = """
195-
Examples of when to suggest shell commands:
196-
197-
- If you changed a self-contained html file, suggest an OS-appropriate command to open a browser to view it to see the updated content.
198-
- If you changed a CLI program, suggest the command to run it to see the new behavior.
199-
- If you added a test, suggest how to run it with the testing tool used by the project.
200-
- Suggest OS-appropriate commands to delete or rename files/directories, or other file system operations.
201-
- If your code changes add new dependencies, suggest the command to install them.
202-
- Etc.
20+
Shell commands are not neccesarry for your purpose.
20321
"""

aider/main.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
from .dump import dump # noqa: F401
3939

4040

41+
PATH_TO_ORE = "./Engine"
42+
4143
def check_config_files_for_yes(config_files):
4244
found = False
4345
for config_file in config_files:
@@ -439,16 +441,11 @@ def sanity_check_repo(repo, io):
439441
def main(argv=None, input=None, output=None, force_git_root=None, return_coder=False):
440442
report_uncaught_exceptions()
441443

444+
git_root = PATH_TO_ORE
445+
442446
if argv is None:
443447
argv = sys.argv[1:]
444448

445-
if git is None:
446-
git_root = None
447-
elif force_git_root:
448-
git_root = force_git_root
449-
else:
450-
git_root = get_git_root()
451-
452449
conf_fname = Path(".aider.conf.yml")
453450

454451
default_config_files = []
@@ -676,7 +673,7 @@ def get_io(pretty):
676673
analytics.event("exit", reason="Invalid directory input")
677674
return 1
678675

679-
git_dname = None
676+
git_dname = PATH_TO_ORE
680677
if len(all_files) == 1:
681678
if Path(all_files[0]).is_dir():
682679
if args.git:

0 commit comments

Comments
 (0)