diff --git a/aider/coder.py b/aider/coder.py index bced5fc7a..e3bce32f5 100755 --- a/aider/coder.py +++ b/aider/coder.py @@ -122,9 +122,12 @@ class Coder: self.repo = repo - def get_files_content(self): + def get_files_content(self, fnames=None): + if not fnames: + fnames = self.abs_fnames + prompt = "" - for fname in self.abs_fnames: + for fname in fnames: relative_fname = os.path.relpath(fname, self.root) prompt += utils.quoted_file(fname, relative_fname) return prompt diff --git a/aider/commands.py b/aider/commands.py index 84df70535..344ee0e64 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -144,6 +144,7 @@ class Commands: def cmd_add(self, args): "Add matching files to the chat" + added_fnames = [] files = self.coder.get_all_relative_files() for word in args.split(): 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: self.coder.abs_fnames.add(abs_file_path) self.console.print(f"[red]Added {matched_file} to the chat") + added_fnames.append(matched_file) else: 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): files = self.coder.get_inchat_relative_files() diff --git a/aider/prompts.py b/aider/prompts.py index 8d858bb5c..f9e7e5ca4 100644 --- a/aider/prompts.py +++ b/aider/prompts.py @@ -106,3 +106,8 @@ Reply with JUST the commit message, without quotes, comments, questions, etc! undo_command_reply = ( "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} +"""