wip: Changed the prompt messages and added a function to show messages.

This commit is contained in:
Paul Gauthier 2023-05-19 08:57:56 -07:00
parent e4d38f89bb
commit d4845dfb43
3 changed files with 13 additions and 10 deletions

View file

@ -164,8 +164,7 @@ class Coder:
all_content = files_content
if self.repo is not None:
tracked_files = set(self.repo.git.ls_files().splitlines())
files_listing = "\n".join(tracked_files)
files_listing = get_tags_map(self.get_all_abs_files())
repo_content = prompts.repo_content_prefix
repo_content += files_listing
@ -180,6 +179,7 @@ class Coder:
),
]
utils.show_messages(messages, "FILES")
return files_messages
def run(self):

View file

@ -6,10 +6,13 @@ import subprocess
# from aider.dump import dump
def get_tags_map(filenames):
def get_tags_map(filenames, root_dname=None):
if not root_dname:
root_dname = os.getcwd()
tags = []
for filename in filenames:
tags += get_tags(filename)
tags += get_tags(filename, root_dname)
if not tags:
return
@ -32,16 +35,16 @@ def get_tags_map(filenames):
return output
def split_path(path):
path = os.path.relpath(path, os.getcwd())
def split_path(path, root_dname):
path = os.path.relpath(path, root_dname)
path_components = path.split(os.sep)
res = [pc + os.sep for pc in path_components[:-1]]
res.append(path_components[-1])
return res
def get_tags(filename):
yield split_path(filename)
def get_tags(filename, root_dname):
yield split_path(filename, root_dname)
cmd = ["ctags", "--fields=+S", "--output-format=json", filename]
output = subprocess.check_output(cmd).decode("utf-8")

View file

@ -79,10 +79,10 @@ files_content_gpt_no_edits = "I wasn't able to see any properly formatted edits
files_content_local_edits = "I made some changes to the files myself."
repo_content_prefix = "These are the files in the git repo:\n\n"
repo_content_prefix = "Here is a map showing all the other files and their content:\n\n"
files_content_prefix = (
"These are the *ONLY* files you can propose changes to (ask if you need to see others):\n\n"
"You can propose changes to *only* these files (ask if you need to see others):\n\n"
)
files_content_suffix = (