mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-31 17:55:01 +00:00
improve diff-fenced prompts
This commit is contained in:
parent
b3215bed48
commit
f46deb4eb7
1 changed files with 52 additions and 5 deletions
|
@ -19,7 +19,7 @@ class EditBlockFencedPrompts(EditBlockPrompts):
|
|||
|
||||
Here are the *SEARCH/REPLACE* blocks:
|
||||
|
||||
{fence[0]}
|
||||
{fence[0]}python
|
||||
mathweb/flask/app.py
|
||||
<<<<<<< SEARCH
|
||||
from flask import Flask
|
||||
|
@ -29,7 +29,7 @@ from flask import Flask
|
|||
>>>>>>> REPLACE
|
||||
{fence[1]}
|
||||
|
||||
{fence[0]}
|
||||
{fence[0]}python
|
||||
mathweb/flask/app.py
|
||||
<<<<<<< SEARCH
|
||||
def factorial(n):
|
||||
|
@ -44,7 +44,7 @@ def factorial(n):
|
|||
>>>>>>> REPLACE
|
||||
{fence[1]}
|
||||
|
||||
{fence[0]}
|
||||
{fence[0]}python
|
||||
mathweb/flask/app.py
|
||||
<<<<<<< SEARCH
|
||||
return str(factorial(n))
|
||||
|
@ -68,7 +68,7 @@ mathweb/flask/app.py
|
|||
|
||||
Here are the *SEARCH/REPLACE* blocks:
|
||||
|
||||
{fence[0]}
|
||||
{fence[0]}python
|
||||
hello.py
|
||||
<<<<<<< SEARCH
|
||||
=======
|
||||
|
@ -79,7 +79,7 @@ def hello():
|
|||
>>>>>>> REPLACE
|
||||
{fence[1]}
|
||||
|
||||
{fence[0]}
|
||||
{fence[0]}python
|
||||
main.py
|
||||
<<<<<<< SEARCH
|
||||
def hello():
|
||||
|
@ -93,3 +93,50 @@ from hello import hello
|
|||
""",
|
||||
),
|
||||
]
|
||||
|
||||
system_reminder = """# *SEARCH/REPLACE block* Rules:
|
||||
|
||||
Every *SEARCH/REPLACE block* must use this format:
|
||||
1. The opening fence and code language, eg: {fence[0]}python
|
||||
2. The *FULL* file path alone on a line, verbatim. No bold asterisks, no quotes around it, no escaping of characters, etc.
|
||||
3. The start of search block: <<<<<<< SEARCH
|
||||
4. A contiguous chunk of lines to search for in the existing source code
|
||||
5. The dividing line: =======
|
||||
6. The lines to replace into the source code
|
||||
7. The end of the replace block: >>>>>>> REPLACE
|
||||
8. The closing fence: {fence[1]}
|
||||
|
||||
Use the *FULL* file path, as shown to you by the user.
|
||||
{quad_backtick_reminder}
|
||||
Every *SEARCH* section must *EXACTLY MATCH* the existing file content, character for character, including all comments, docstrings, etc.
|
||||
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.
|
||||
|
||||
*SEARCH/REPLACE* blocks will *only* replace the first match occurrence.
|
||||
Including multiple unique *SEARCH/REPLACE* blocks if needed.
|
||||
Include enough lines in each SEARCH section to uniquely match each set of lines that need to change.
|
||||
|
||||
Keep *SEARCH/REPLACE* blocks concise.
|
||||
Break large *SEARCH/REPLACE* blocks into a series of smaller blocks that each change a small portion of the file.
|
||||
Include just the changing lines, and a few surrounding lines if needed for uniqueness.
|
||||
Do not include long runs of unchanging lines in *SEARCH/REPLACE* blocks.
|
||||
|
||||
Only create *SEARCH/REPLACE* blocks for files that the user has added to the chat!
|
||||
|
||||
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.
|
||||
|
||||
Pay attention to which filenames the user wants you to edit, especially if they are asking you to create a new file.
|
||||
|
||||
If you want to put code in a new file, use a *SEARCH/REPLACE block* with:
|
||||
- A new file path, including dir name if needed
|
||||
- An empty `SEARCH` section
|
||||
- The new file's contents in the `REPLACE` section
|
||||
|
||||
To rename files which have been added to the chat, use shell commands at the end of your response.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
{lazy_prompt}
|
||||
ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*!
|
||||
{shell_cmd_reminder}
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue