mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 06:15:00 +00:00
reply with new files content on /add
This commit is contained in:
parent
7a0e020c66
commit
fcaf4e15c8
3 changed files with 24 additions and 2 deletions
|
@ -122,9 +122,12 @@ class Coder:
|
||||||
|
|
||||||
self.repo = repo
|
self.repo = repo
|
||||||
|
|
||||||
def get_files_content(self):
|
def get_files_content(self, fnames=None):
|
||||||
|
if not fnames:
|
||||||
|
fnames = self.abs_fnames
|
||||||
|
|
||||||
prompt = ""
|
prompt = ""
|
||||||
for fname in self.abs_fnames:
|
for fname in fnames:
|
||||||
relative_fname = os.path.relpath(fname, self.root)
|
relative_fname = os.path.relpath(fname, self.root)
|
||||||
prompt += utils.quoted_file(fname, relative_fname)
|
prompt += utils.quoted_file(fname, relative_fname)
|
||||||
return prompt
|
return prompt
|
||||||
|
|
|
@ -144,6 +144,7 @@ class Commands:
|
||||||
def cmd_add(self, args):
|
def cmd_add(self, args):
|
||||||
"Add matching files to the chat"
|
"Add matching files to the chat"
|
||||||
|
|
||||||
|
added_fnames = []
|
||||||
files = self.coder.get_all_relative_files()
|
files = self.coder.get_all_relative_files()
|
||||||
for word in args.split():
|
for word in args.split():
|
||||||
matched_files = [file for file in files if word in file]
|
matched_files = [file for file in files if word in file]
|
||||||
|
@ -156,9 +157,22 @@ class Commands:
|
||||||
if abs_file_path not in self.coder.abs_fnames:
|
if abs_file_path not in self.coder.abs_fnames:
|
||||||
self.coder.abs_fnames.add(abs_file_path)
|
self.coder.abs_fnames.add(abs_file_path)
|
||||||
self.console.print(f"[red]Added {matched_file} to the chat")
|
self.console.print(f"[red]Added {matched_file} to the chat")
|
||||||
|
added_fnames.append(matched_file)
|
||||||
else:
|
else:
|
||||||
self.console.print(f"[red]{matched_file} is already in the chat")
|
self.console.print(f"[red]{matched_file} is already in the chat")
|
||||||
|
|
||||||
|
if not added_fnames:
|
||||||
|
return
|
||||||
|
|
||||||
|
quoted_fnames = self.coder.get_files_content(added_fnames)
|
||||||
|
reply = prompts.added_files.format(quoted_fnames=quoted_fnames)
|
||||||
|
|
||||||
|
from aider.dump import dump
|
||||||
|
|
||||||
|
dump(reply)
|
||||||
|
|
||||||
|
return reply
|
||||||
|
|
||||||
def completions_drop(self, partial):
|
def completions_drop(self, partial):
|
||||||
files = self.coder.get_inchat_relative_files()
|
files = self.coder.get_inchat_relative_files()
|
||||||
|
|
||||||
|
|
|
@ -106,3 +106,8 @@ Reply with JUST the commit message, without quotes, comments, questions, etc!
|
||||||
undo_command_reply = (
|
undo_command_reply = (
|
||||||
"I did not like those edits, so I did `git reset --hard HEAD~1` to discard them."
|
"I did not like those edits, so I did `git reset --hard HEAD~1` to discard them."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
added_files = """Here is the content of more files:
|
||||||
|
|
||||||
|
{quoted_fnames}
|
||||||
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue