diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 565da3c2e..3b05b90b4 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -446,6 +446,9 @@ class Coder: files_content = self.gpt_prompts.files_content_prefix files_content += self.get_files_content() files_reply = "Ok, any changes I propose will be to those files." + elif repo_content: + files_content = self.gpt_prompts.files_no_full_files_with_repo_map + files_reply = "Ok, based on your requests I will suggest which files need to be edited." else: files_content = self.gpt_prompts.files_no_full_files files_reply = "Ok." diff --git a/aider/coders/base_prompts.py b/aider/coders/base_prompts.py index 0cec0fe9a..7d12ef308 100644 --- a/aider/coders/base_prompts.py +++ b/aider/coders/base_prompts.py @@ -20,6 +20,11 @@ You always COMPLETELY IMPLEMENT the needed code! files_no_full_files = "I am not sharing any files that you can edit yet." + files_no_full_files_with_repo_map = """Tell me which files in my repo are the most likely to **need changes** to solve the requests I make. +Only include the 1-2 files that are most likely to actually need to be edited. +Don't include files that might contain relevant context, just files that will need to be changed. +""" # noqa: E501 + repo_content_prefix = """Here are summaries of some files present in my git repository. Do not propose changes to these files, treat them as *read-only*. If you need to edit any of these files, ask me to *add them to the chat* first. diff --git a/aider/repomap.py b/aider/repomap.py index 10bb41998..59be99325 100644 --- a/aider/repomap.py +++ b/aider/repomap.py @@ -61,8 +61,13 @@ class RepoMap: if not other_files: return + max_map_tokens = self.max_map_tokens + if not chat_files: + # with no code in the chat, give a bigger view of the entire repo + max_map_tokens *= 4 + try: - files_listing = self.get_ranked_tags_map(chat_files, other_files) + files_listing = self.get_ranked_tags_map(chat_files, other_files, max_map_tokens) except RecursionError: self.io.tool_error("Disabling repo map, git repo too large?") self.max_map_tokens = 0 @@ -327,9 +332,11 @@ class RepoMap: return ranked_tags - def get_ranked_tags_map(self, chat_fnames, other_fnames=None): + def get_ranked_tags_map(self, chat_fnames, other_fnames=None, max_map_tokens=None): if not other_fnames: other_fnames = list() + if not max_map_tokens: + max_map_tokens = self.max_map_tokens ranked_tags = self.get_ranked_tags(chat_fnames, other_fnames) num_tags = len(ranked_tags) @@ -345,7 +352,7 @@ class RepoMap: tree = self.to_tree(ranked_tags[:middle], chat_rel_fnames) num_tokens = self.token_count(tree) - if num_tokens < self.max_map_tokens: + if num_tokens < max_map_tokens: best_tree = tree lower_bound = middle + 1 else: