mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 10:45:00 +00:00
refactor: Move shell command prompts to shell.py, add final reminders
This commit is contained in:
parent
e17c7d938c
commit
bdba0ca1c5
10 changed files with 26 additions and 51 deletions
|
@ -15,7 +15,9 @@ You always COMPLETELY IMPLEMENT the needed code!
|
|||
"""
|
||||
|
||||
overeager_prompt = """Pay careful attention to the scope of the user's request.
|
||||
Do what they ask, but no more."""
|
||||
Do what they ask, but no more.
|
||||
Do not improve, comment, fix or modify unrelated parts of the code in any way!
|
||||
"""
|
||||
|
||||
example_messages = []
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ To rename files which have been added to the chat, use shell commands at the end
|
|||
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}
|
||||
{final_reminders}
|
||||
ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*!
|
||||
{shell_cmd_reminder}
|
||||
"""
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# flake8: noqa: E501
|
||||
|
||||
from . import shell
|
||||
from .base_prompts import CoderPrompts
|
||||
|
||||
|
||||
|
@ -7,7 +8,7 @@ class EditBlockPrompts(CoderPrompts):
|
|||
main_system = """Act as an expert software developer.
|
||||
Always use best practices when coding.
|
||||
Respect and use existing conventions, libraries, etc that are already present in the code base.
|
||||
{lazy_prompt}
|
||||
{final_reminders}
|
||||
Take requests for changes to the supplied code.
|
||||
If the request is ambiguous, ask questions.
|
||||
|
||||
|
@ -28,32 +29,6 @@ You can keep asking if you then decide you need to edit more files.
|
|||
All changes to files must use this *SEARCH/REPLACE block* format.
|
||||
ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*!
|
||||
{shell_cmd_prompt}
|
||||
"""
|
||||
|
||||
shell_cmd_prompt = """
|
||||
4. *Concisely* suggest any shell commands the user might want to run in ```bash blocks.
|
||||
|
||||
Just suggest shell commands this way, not example code.
|
||||
Only suggest complete shell commands that are ready to execute, without placeholders.
|
||||
Only suggest at most a few shell commands at a time, not more than 1-3, one per line.
|
||||
Do not suggest multi-line shell commands.
|
||||
All shell commands will run from the root directory of the user's project.
|
||||
|
||||
Use the appropriate shell based on the user's system info:
|
||||
{platform}
|
||||
Examples of when to suggest shell commands:
|
||||
|
||||
- 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.
|
||||
- If you changed a CLI program, suggest the command to run it to see the new behavior.
|
||||
- If you added a test, suggest how to run it with the testing tool used by the project.
|
||||
- Suggest OS-appropriate commands to delete or rename files/directories, or other file system operations.
|
||||
- If your code changes add new dependencies, suggest the command to install them.
|
||||
- Etc.
|
||||
"""
|
||||
|
||||
no_shell_cmd_prompt = """
|
||||
Keep in mind these details about the user's platform and environment:
|
||||
{platform}
|
||||
"""
|
||||
example_messages = [
|
||||
dict(
|
||||
|
@ -181,7 +156,7 @@ If you want to put code in a new file, use a *SEARCH/REPLACE block* with:
|
|||
- An empty `SEARCH` section
|
||||
- The new file's contents in the `REPLACE` section
|
||||
|
||||
{rename_with_shell}{go_ahead_tip}{lazy_prompt}ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*!
|
||||
{rename_with_shell}{go_ahead_tip}{final_reminders}ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*!
|
||||
{shell_cmd_reminder}
|
||||
"""
|
||||
|
||||
|
@ -194,14 +169,6 @@ The user will say when they've applied your edits. If they haven't explicitly co
|
|||
|
||||
"""
|
||||
|
||||
shell_cmd_reminder = """
|
||||
Examples of when to suggest shell commands:
|
||||
|
||||
- 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.
|
||||
- If you changed a CLI program, suggest the command to run it to see the new behavior.
|
||||
- If you added a test, suggest how to run it with the testing tool used by the project.
|
||||
- Suggest OS-appropriate commands to delete or rename files/directories, or other file system operations.
|
||||
- If your code changes add new dependencies, suggest the command to install them.
|
||||
- Etc.
|
||||
|
||||
"""
|
||||
shell_cmd_prompt = shell.shell_cmd_prompt
|
||||
no_shell_cmd_prompt = shell.no_shell_cmd_prompt
|
||||
shell_cmd_reminder = shell.shell_cmd_reminder
|
||||
|
|
|
@ -5,7 +5,7 @@ from .editblock_prompts import EditBlockPrompts
|
|||
|
||||
class EditorEditBlockPrompts(EditBlockPrompts):
|
||||
main_system = """Act as an expert software developer who edits source code.
|
||||
{lazy_prompt}
|
||||
{final_reminders}
|
||||
Describe each change with a *SEARCH/REPLACE block* per the examples below.
|
||||
All changes to files must use this *SEARCH/REPLACE block* format.
|
||||
ONLY EVER RETURN CODE IN A *SEARCH/REPLACE BLOCK*!
|
||||
|
|
|
@ -5,6 +5,6 @@ from .wholefile_prompts import WholeFilePrompts
|
|||
|
||||
class EditorWholeFilePrompts(WholeFilePrompts):
|
||||
main_system = """Act as an expert software developer and make changes to source code.
|
||||
{lazy_prompt}
|
||||
{final_reminders}
|
||||
Output a copy of each file that needs changes.
|
||||
"""
|
||||
|
|
|
@ -11,7 +11,7 @@ class PatchPrompts(EditBlockPrompts):
|
|||
main_system = """Act as an expert software developer.
|
||||
Always use best practices when coding.
|
||||
Respect and use existing conventions, libraries, etc that are already present in the code base.
|
||||
{lazy_prompt}
|
||||
{final_reminders}
|
||||
Take requests for changes to the supplied code.
|
||||
If the request is ambiguous, ask questions.
|
||||
|
||||
|
@ -156,6 +156,6 @@ For `Add` actions, use the `*** Add File: [path/to/new/file]` marker, followed b
|
|||
|
||||
For `Delete` actions, use the `*** Delete File: [path/to/file]` marker. No other lines are needed for the deletion.
|
||||
|
||||
{rename_with_shell}{go_ahead_tip}{lazy_prompt}ONLY EVER RETURN CODE IN THE SPECIFIED V4A DIFF FORMAT!
|
||||
{rename_with_shell}{go_ahead_tip}{final_reminders}ONLY EVER RETURN CODE IN THE SPECIFIED V4A DIFF FORMAT!
|
||||
{shell_cmd_reminder}
|
||||
"""
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
# flake8: noqa: E501
|
||||
|
||||
from . import shell
|
||||
from .base_prompts import CoderPrompts
|
||||
|
||||
|
||||
class UnifiedDiffPrompts(CoderPrompts):
|
||||
main_system = """Act as an expert software developer.
|
||||
{lazy_prompt}
|
||||
{final_reminders}
|
||||
Always use best practices when coding.
|
||||
Respect and use existing conventions, libraries, etc that are already present in the code base.
|
||||
|
||||
|
@ -106,5 +107,9 @@ To move code within a file, use 2 hunks: 1 to delete it from its current locatio
|
|||
|
||||
To make a new file, show a diff from `--- /dev/null` to `+++ path/to/new/file.ext`.
|
||||
|
||||
{lazy_prompt}
|
||||
{final_reminders}
|
||||
"""
|
||||
|
||||
shell_cmd_prompt = shell.shell_cmd_prompt
|
||||
no_shell_cmd_prompt = shell.no_shell_cmd_prompt
|
||||
shell_cmd_reminder = shell.shell_cmd_reminder
|
||||
|
|
|
@ -21,5 +21,5 @@ Don't leave out any lines or the diff patch won't apply correctly.
|
|||
|
||||
To make a new file, show a diff from `--- /dev/null` to `+++ path/to/new/file.ext`.
|
||||
|
||||
{lazy_prompt}
|
||||
"""
|
||||
{final_reminders}
|
||||
""" # noqa
|
||||
|
|
|
@ -10,7 +10,7 @@ If the request is ambiguous, ask questions.
|
|||
|
||||
Always reply to the user in {language}.
|
||||
|
||||
{lazy_prompt}
|
||||
{final_reminders}
|
||||
Once you understand the request you MUST:
|
||||
1. Determine if any code changes are needed.
|
||||
2. Explain any needed changes.
|
||||
|
@ -61,7 +61,7 @@ To suggest changes to a file you MUST return a *file listing* that contains the
|
|||
*NEVER* skip, omit or elide content from a *file listing* using "..." or by adding comments like "... rest of code..."!
|
||||
Create a new file you MUST return a *file listing* which includes an appropriate filename, including any appropriate path.
|
||||
|
||||
{lazy_prompt}
|
||||
{final_reminders}
|
||||
"""
|
||||
|
||||
redacted_edit_message = "No changes are needed."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue