From 9c751d247b79553580da2a708e720d2389235440 Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Thu, 7 Sep 2023 19:48:16 +0200 Subject: [PATCH] Revert "Revert "Added back the functionality for tech lead to break down the project and the developer to code task by task"" This reverts commit f91da2b5eb097795ed60a439e601dea8d0894455. --- pilot/const/common.py | 2 +- pilot/helpers/Project.py | 10 +++--- pilot/helpers/agents/Developer.py | 31 +++++++++++++------ pilot/prompts/development/plan.prompt | 8 ++++- .../prompts/development/task/breakdown.prompt | 13 ++++++-- 5 files changed, 45 insertions(+), 19 deletions(-) diff --git a/pilot/const/common.py b/pilot/const/common.py index 6e39416..05269cb 100644 --- a/pilot/const/common.py +++ b/pilot/const/common.py @@ -11,8 +11,8 @@ STEPS = [ 'user_stories', 'user_tasks', 'architecture', - 'development_planning', 'environment_setup', + 'development_planning', 'coding' ] diff --git a/pilot/helpers/Project.py b/pilot/helpers/Project.py index 90d3099..117edb1 100644 --- a/pilot/helpers/Project.py +++ b/pilot/helpers/Project.py @@ -76,8 +76,11 @@ class Project: self.architect = Architect(self) self.architecture = self.architect.get_architecture() - # self.tech_lead = TechLead(self) - # self.development_plan = self.tech_lead.create_development_plan() + self.developer = Developer(self) + self.developer.set_up_environment(); + + self.tech_lead = TechLead(self) + self.development_plan = self.tech_lead.create_development_plan() # TODO move to constructor eventually if self.args['step'] is not None and STEPS.index(self.args['step']) < STEPS.index('coding'): @@ -96,9 +99,6 @@ class Project: self.save_files_snapshot(self.skip_until_dev_step) # TODO END - self.developer = Developer(self) - self.developer.set_up_environment(); - self.developer.start_coding() def get_directory_tree(self, with_descriptions=False): diff --git a/pilot/helpers/agents/Developer.py b/pilot/helpers/agents/Developer.py index a0074bc..534e9bf 100644 --- a/pilot/helpers/agents/Developer.py +++ b/pilot/helpers/agents/Developer.py @@ -30,13 +30,16 @@ class Developer(Agent): print(colored(f"Ok, great, now, let's start with the actual development...\n", "green", attrs=['bold'])) logger.info(f"Starting to create the actual code...") - self.implement_task() + for i, dev_task in enumerate(self.project.development_plan): + self.implement_task(i, dev_task) # DEVELOPMENT END logger.info('The app is DONE!!! Yay...you can use it now.') - def implement_task(self): + def implement_task(self, i, development_task=None): + print(colored(f'Implementing task #{i + 1}: ', 'green', attrs=['bold']) + colored(f' {development_task["description"]}\n', 'green')); + convo_dev_task = AgentConvo(self) task_description = convo_dev_task.send_message('development/task/breakdown.prompt', { "name": self.project.args['name'], @@ -47,13 +50,16 @@ class Developer(Agent): "technologies": self.project.architecture, "array_of_objects_to_string": array_of_objects_to_string, "directory_tree": self.project.get_directory_tree(True), + "current_task_index": i, + "development_tasks": self.project.development_plan, + "files": self.project.get_all_coded_files(), }) task_steps = convo_dev_task.send_message('development/parse_task.prompt', {}, IMPLEMENT_TASK) convo_dev_task.remove_last_x_messages(2) - self.execute_task(convo_dev_task, task_steps, continue_development=True) + self.execute_task(convo_dev_task, task_steps, development_task=development_task, continue_development=True) - def execute_task(self, convo, task_steps, test_command=None, reset_convo=True, test_after_code_changes=True, continue_development=False): + def execute_task(self, convo, task_steps, test_command=None, reset_convo=True, test_after_code_changes=True, continue_development=False, development_task=None): function_uuid = str(uuid.uuid4()) convo.save_branch(function_uuid) @@ -117,14 +123,21 @@ class Developer(Agent): if self.run_command.endswith('`'): self.run_command = self.run_command[:-1] - if continue_development: - self.continue_development(convo) + if development_task is not None: + convo.remove_last_x_messages(2) + detailed_user_review_goal = convo.send_message('development/define_user_review_goal.prompt', {}) - def continue_development(self, iteration_convo): + if continue_development: + continue_description = detailed_user_review_goal if detailed_user_review_goal is not None else None + self.continue_development(convo, continue_description) + + def continue_development(self, iteration_convo, continue_description=''): while True: - # TODO add description about how can the user check if the app works + user_description = ('Here is a description of what should be working: \n\n' + colored(continue_description, 'blue', attrs=['bold']) + '\n') if continue_description != '' else '' + user_description = 'Can you check if the app works please? ' + user_description + '\nIf you want to run the app, ' + colored('just type "r" and press ENTER and that will run `' + self.run_command + '`', 'yellow', attrs=['bold']) + continue_description = '' user_feedback = self.project.ask_for_human_intervention( - 'Can you check if the app works?\nIf you want to run the app, ' + colored('just type "r" and press ENTER', 'yellow', attrs=['bold']), + user_description, cbs={ 'r': lambda: run_command_until_success(self.run_command, None, iteration_convo, force=True) }) if user_feedback == 'continue': diff --git a/pilot/prompts/development/plan.prompt b/pilot/prompts/development/plan.prompt index 40cfbd2..99cf96e 100644 --- a/pilot/prompts/development/plan.prompt +++ b/pilot/prompts/development/plan.prompt @@ -34,4 +34,10 @@ Here are the technologies that you need to use for this project: {% endfor %} ``` -Now, based on the app's description, user stories and user tasks, and the technologies that you need to use, think step by step and write up the entire plan for the development. Start from the project setup and specify each step until the moment when the entire app should be fully working. For each step, write a description, a programmatic goal, and a user-review goal. \ No newline at end of file +OK, now, you need to create code to have this app fully working but before we go into the coding part, I want you to split the development process of creating this app into smaller tasks so that it is easier to debug and make the app work. Each smaller task of this project has to be a whole that can be reviewed by a developer to make sure we're on a right track to create this app completely. However, it cannot be split into tasks that are too small as well. + +Each task needs to be related only to the development of this app and nothing else - once the app is fully working, that is it. There shouldn't be a task for deployment, writing documentation, or anything that is not writing the actual code. Think task by task and create the least number of tasks that are relevant for this specific app. + +For each task, there must be a way for human developer to check if the task is done or not. Write how should the developer check if the task is done. + +Now, based on the app's description, user stories and user tasks, and the technologies that you need to use, think task by task and write up the entire plan for the development. Start from the project setup and specify each task until the moment when the entire app should be fully working. For each task, write a description and a user-review goal. \ No newline at end of file diff --git a/pilot/prompts/development/task/breakdown.prompt b/pilot/prompts/development/task/breakdown.prompt index 3be9d57..954ebea 100644 --- a/pilot/prompts/development/task/breakdown.prompt +++ b/pilot/prompts/development/task/breakdown.prompt @@ -31,9 +31,15 @@ So far, this code has been implemented {% endfor %} {% endif %} -Now, tell me all the code that needs to be written to implement this app and have it fully working and all commands that need to be run to implement this app. +We've broken the development of this app down to these tasks: +```{% for task in development_tasks %} +- {{ task['description'] }}{% endfor %} +``` -This should be a simple version of the app so you don't need to aim to provide a production ready code but rather something that a developer can run locally and play with the implementation. Do not leave any parts of the code to be written afterwards. Make sure that all the code you provide is working and does as outlined in the description area above. +You are currently working on this task with the following description: {{ development_tasks[current_task_index]['description'] }} +After all the code is finished, a human developer will check it works this way - {{ development_tasks[current_task_index]['user_review_goal'] }} + +Now, tell me all the code that needs to be written to implement this app and have it fully working and all commands that need to be run to implement this app. {{no_microservices}} @@ -41,4 +47,5 @@ This should be a simple version of the app so you don't need to aim to provide a Remember, I'm currently in an empty folder where I will start writing files that you tell me. Tell me how can I test the app to see if it's working or not. You do not need to make any automated tests work. -DO NOT specify commands to create any folders or files, they will be created automatically - just specify the relative path to each file that needs to be written \ No newline at end of file +DO NOT specify commands to create any folders or files, they will be created automatically - just specify the relative path to each file that needs to be written. +Never use the port 5000 to run the app, it's reserved.