From 1ba8e59c53c0240a5989e92464eafe846f47a64f Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 9 May 2023 13:15:22 -0700 Subject: [PATCH] Add files listing to `files_content` when `self.repo` is not `None` in `get_files_messages` method. # Context: USER: in get_files_messages(self): if self.repo is not none, then get a listing of the files in the repo and add it to all_content ASSISTANT: To add a listing of the files in the repo to `all_content` when `self.repo` is not `None`, you can modify the `get_files_messages` method as follows: ```python aider/coder.py <<<<<<< ORIGINAL def get_files_messages(self): files_content = prompts.files_content_prefix files_content += self.get_files_content() all_content = files_content ======= def get_files_messages(self): files_content = prompts.files_content_prefix files_content += self.get_files_content() if self.repo is not None: tracked_files = set(self.repo.git.ls_files().splitlines()) files_listing = "\n".join(tracked_files) files_content += f"\n\nFiles in the repo:\n{files_listing}\n" all_content = files_content >>>>>>> UPDATED ``` This change adds a conditional block to check if `self.repo` is not `None` and then retrieves the list of tracked files in the repo. It then adds the files listing to `files_content` before assigning it to `all_content`. --- aider/coder.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/aider/coder.py b/aider/coder.py index 1a78dee06..e2ba0ee30 100755 --- a/aider/coder.py +++ b/aider/coder.py @@ -1,6 +1,5 @@ #!/usr/bin/env python - import sys import re import traceback @@ -127,11 +126,18 @@ class Coder: return max(Path(fname).stat().st_mtime for fname in self.fnames) def get_files_messages(self): + files_content = prompts.files_content_prefix files_content += self.get_files_content() + if self.repo is not None: + tracked_files = set(self.repo.git.ls_files().splitlines()) + files_listing = "\n".join(tracked_files) + files_content += f"\n\nFiles in the repo:\n{files_listing}\n" + + all_content = files_content files_messages = [ - dict(role="user", content=files_content), + dict(role="user", content=all_content), dict(role="assistant", content="Ok."), dict( role="system",