mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
Stronger prompting to only modify full files, not parts of the repo map
This commit is contained in:
parent
4e557baad4
commit
a886ea472b
3 changed files with 14 additions and 10 deletions
|
@ -168,7 +168,10 @@ class Coder:
|
||||||
if self.abs_fnames:
|
if self.abs_fnames:
|
||||||
files_content = prompts.files_content_prefix
|
files_content = prompts.files_content_prefix
|
||||||
files_content += self.get_files_content()
|
files_content += self.get_files_content()
|
||||||
all_content += files_content
|
else:
|
||||||
|
files_content = prompts.files_no_full_files
|
||||||
|
|
||||||
|
all_content += files_content
|
||||||
|
|
||||||
other_files = set(self.get_all_abs_files()) - set(self.abs_fnames)
|
other_files = set(self.get_all_abs_files()) - set(self.abs_fnames)
|
||||||
repo_content = self.repo_map.get_repo_map(self.abs_fnames, other_files)
|
repo_content = self.repo_map.get_repo_map(self.abs_fnames, other_files)
|
||||||
|
|
|
@ -8,14 +8,12 @@ Take requests for changes to the supplied code.
|
||||||
If the request is ambiguous, ask questions.
|
If the request is ambiguous, ask questions.
|
||||||
|
|
||||||
Once you understand the request you MUST:
|
Once you understand the request you MUST:
|
||||||
1. List the files you need to modify.
|
1. List the files you need to modify. If they are *read-only* ask the user to make them *read-write* using the file's full path name.
|
||||||
2. Think step-by-step and explain the needed changes.
|
2. Think step-by-step and explain the needed changes.
|
||||||
3. Describe each change with an *edit block* per the example below.
|
3. Describe each change with an *edit block* per the example below.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
system_reminder = """Base any edits off the files shown in the user's last msg.
|
system_reminder = """You MUST format EVERY code change with an *edit block* like this:
|
||||||
|
|
||||||
You MUST format EVERY code change with an *edit block* like this:
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
some/dir/example.py
|
some/dir/example.py
|
||||||
|
@ -29,11 +27,11 @@ some/dir/example.py
|
||||||
def add(a,b):
|
def add(a,b):
|
||||||
>>>>>>> UPDATED
|
>>>>>>> UPDATED
|
||||||
|
|
||||||
|
Every *edit block* must be fenced w/triple backticks with the correct code language.
|
||||||
|
Every *edit block* must start with the full path! *NEVER* propose edit blocks for *read-only* files.
|
||||||
The ORIGINAL section must be an *exact* set of lines from the file:
|
The ORIGINAL section must be an *exact* set of lines from the file:
|
||||||
- NEVER SKIP LINES!
|
- NEVER SKIP LINES!
|
||||||
- Include all original leading spaces and indentation!
|
- Include all original leading spaces and indentation!
|
||||||
Every *edit block* must be fenced w/triple backticks with the correct code language.
|
|
||||||
Every *edit block* must start with the full path!
|
|
||||||
|
|
||||||
Edits to different parts of a file each need their own *edit block*.
|
Edits to different parts of a file each need their own *edit block*.
|
||||||
|
|
||||||
|
@ -54,11 +52,13 @@ files_content_gpt_no_edits = "I didn't see any properly formatted edits in your
|
||||||
|
|
||||||
files_content_local_edits = "I edited the files myself."
|
files_content_local_edits = "I edited the files myself."
|
||||||
|
|
||||||
files_content_prefix = "Propose changes to *only* these files (ask before editing others):\n"
|
files_content_prefix = "These are the *read-write* files:\n"
|
||||||
|
|
||||||
|
files_no_full_files = "I am not sharing any *read-write* files yet."
|
||||||
|
|
||||||
repo_content_prefix = (
|
repo_content_prefix = (
|
||||||
"Here is a map of all the {other}files{ctags_msg}. You *must* ask with the"
|
"All the files below here are *read-only* files. Notice that files in directories are indented."
|
||||||
" full path before editing these:\n\n"
|
" Use their parent dirs to build their full path.\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,7 @@ class RepoMap:
|
||||||
|
|
||||||
def split_path(self, path):
|
def split_path(self, path):
|
||||||
path = os.path.relpath(path, self.root)
|
path = os.path.relpath(path, self.root)
|
||||||
|
return [path]
|
||||||
return fname_to_components(path, True)
|
return fname_to_components(path, True)
|
||||||
|
|
||||||
def get_tags(self, filename):
|
def get_tags(self, filename):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue