mirror of
https://github.com/OMGeeky/gpt-pilot.git
synced 2026-02-23 15:49:50 +01:00
Implemented fetching of directory tree with descriptions
This commit is contained in:
@@ -66,8 +66,12 @@ class Project:
|
|||||||
|
|
||||||
self.developer.start_coding()
|
self.developer.start_coding()
|
||||||
|
|
||||||
def get_directory_tree(self):
|
def get_directory_tree(self, with_descriptions=False):
|
||||||
return build_directory_tree(self.root_path + '/', ignore=IGNORE_FOLDERS)
|
files = {}
|
||||||
|
if with_descriptions:
|
||||||
|
files = File.select().where(File.app_id == self.args['app_id'])
|
||||||
|
files = {snapshot.name: snapshot for snapshot in files}
|
||||||
|
return build_directory_tree(self.root_path + '/', ignore=IGNORE_FOLDERS, files=files, add_descriptions=True)
|
||||||
|
|
||||||
def get_test_directory_tree(self):
|
def get_test_directory_tree(self):
|
||||||
# TODO remove hardcoded path
|
# TODO remove hardcoded path
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class CodeMonkey(Agent):
|
|||||||
|
|
||||||
files_needed = convo.send_message('development/task/request_files_for_code_changes.prompt', {
|
files_needed = convo.send_message('development/task/request_files_for_code_changes.prompt', {
|
||||||
"step_description": code_changes_description,
|
"step_description": code_changes_description,
|
||||||
"directory_tree": self.project.get_directory_tree(),
|
"directory_tree": self.project.get_directory_tree(True),
|
||||||
"step_index": step_index,
|
"step_index": step_index,
|
||||||
"finished_steps": ', '.join(f"#{j}" for j in range(step_index))
|
"finished_steps": ', '.join(f"#{j}" for j in range(step_index))
|
||||||
}, GET_FILES)
|
}, GET_FILES)
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class Developer(Agent):
|
|||||||
"user_tasks": self.project.user_tasks,
|
"user_tasks": self.project.user_tasks,
|
||||||
"technologies": self.project.architecture,
|
"technologies": self.project.architecture,
|
||||||
"array_of_objects_to_string": array_of_objects_to_string,
|
"array_of_objects_to_string": array_of_objects_to_string,
|
||||||
"directory_tree": self.project.get_directory_tree(),
|
"directory_tree": self.project.get_directory_tree(True),
|
||||||
"current_task_index": current_task_index,
|
"current_task_index": current_task_index,
|
||||||
"sibling_tasks": sibling_tasks,
|
"sibling_tasks": sibling_tasks,
|
||||||
"parent_task": parent_task,
|
"parent_task": parent_task,
|
||||||
@@ -170,7 +170,7 @@ class Developer(Agent):
|
|||||||
|
|
||||||
def implement_step(self, convo, step_index, type, description):
|
def implement_step(self, convo, step_index, type, description):
|
||||||
# TODO remove hardcoded folder path
|
# TODO remove hardcoded folder path
|
||||||
directory_tree = self.project.get_directory_tree()
|
directory_tree = self.project.get_directory_tree(True)
|
||||||
step_details = convo.send_message('development/task/next_step.prompt', {
|
step_details = convo.send_message('development/task/next_step.prompt', {
|
||||||
'finished_steps': [],
|
'finished_steps': [],
|
||||||
'step_description': description,
|
'step_description': description,
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ def execute_command(project, command, timeout=5000):
|
|||||||
|
|
||||||
return return_value
|
return return_value
|
||||||
|
|
||||||
def build_directory_tree(path, prefix="", ignore=None, is_last=False):
|
def build_directory_tree(path, prefix="", ignore=None, is_last=False, files=None, add_descriptions=False):
|
||||||
"""Build the directory tree structure in tree-like format.
|
"""Build the directory tree structure in tree-like format.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -133,17 +133,17 @@ def build_directory_tree(path, prefix="", ignore=None, is_last=False):
|
|||||||
|
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
# It's a directory, add its name to the output and then recurse into it
|
# It's a directory, add its name to the output and then recurse into it
|
||||||
output += prefix + "|-- " + os.path.basename(path) + "/\n"
|
output += prefix + "|-- " + os.path.basename(path) + ((' - ' + files[os.path.basename(path)].description + ' ' if files and os.path.basename(path) in files and add_descriptions else '')) + "/\n"
|
||||||
|
|
||||||
# List items in the directory
|
# List items in the directory
|
||||||
items = os.listdir(path)
|
items = os.listdir(path)
|
||||||
for index, item in enumerate(items):
|
for index, item in enumerate(items):
|
||||||
item_path = os.path.join(path, item)
|
item_path = os.path.join(path, item)
|
||||||
output += build_directory_tree(item_path, prefix + indent, ignore, index == len(items) - 1)
|
output += build_directory_tree(item_path, prefix + indent, ignore, index == len(items) - 1, files, add_descriptions)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# It's a file, add its name to the output
|
# It's a file, add its name to the output
|
||||||
output += prefix + "|-- " + os.path.basename(path) + "\n"
|
output += prefix + "|-- " + os.path.basename(path) + ((' - ' + files[os.path.basename(path)].description + ' ' if files and os.path.basename(path) in files and add_descriptions else '')) + "\n"
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user