diff --git a/euclid/helpers/Project.py b/euclid/helpers/Project.py index f65aab5..8010bfa 100644 --- a/euclid/helpers/Project.py +++ b/euclid/helpers/Project.py @@ -66,8 +66,12 @@ class Project: self.developer.start_coding() - def get_directory_tree(self): - return build_directory_tree(self.root_path + '/', ignore=IGNORE_FOLDERS) + def get_directory_tree(self, with_descriptions=False): + 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): # TODO remove hardcoded path diff --git a/euclid/helpers/agents/CodeMonkey.py b/euclid/helpers/agents/CodeMonkey.py index a9cc4ab..0ee2d5a 100644 --- a/euclid/helpers/agents/CodeMonkey.py +++ b/euclid/helpers/agents/CodeMonkey.py @@ -15,7 +15,7 @@ class CodeMonkey(Agent): files_needed = convo.send_message('development/task/request_files_for_code_changes.prompt', { "step_description": code_changes_description, - "directory_tree": self.project.get_directory_tree(), + "directory_tree": self.project.get_directory_tree(True), "step_index": step_index, "finished_steps": ', '.join(f"#{j}" for j in range(step_index)) }, GET_FILES) diff --git a/euclid/helpers/agents/Developer.py b/euclid/helpers/agents/Developer.py index 3095d84..7231016 100644 --- a/euclid/helpers/agents/Developer.py +++ b/euclid/helpers/agents/Developer.py @@ -46,7 +46,7 @@ class Developer(Agent): "user_tasks": self.project.user_tasks, "technologies": self.project.architecture, "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, "sibling_tasks": sibling_tasks, "parent_task": parent_task, @@ -170,7 +170,7 @@ class Developer(Agent): def implement_step(self, convo, step_index, type, description): # 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', { 'finished_steps': [], 'step_description': description, diff --git a/euclid/helpers/cli.py b/euclid/helpers/cli.py index 2b76753..dba9eb5 100644 --- a/euclid/helpers/cli.py +++ b/euclid/helpers/cli.py @@ -110,7 +110,7 @@ def execute_command(project, command, timeout=5000): 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. Args: @@ -133,17 +133,17 @@ def build_directory_tree(path, prefix="", ignore=None, is_last=False): if os.path.isdir(path): # 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 items = os.listdir(path) for index, item in enumerate(items): 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: # 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