From 55475e4c84dc0dc2f18dfb921e386fb2d6ccbb8f Mon Sep 17 00:00:00 2001 From: LeonOstrez Date: Mon, 4 Dec 2023 11:06:13 +0000 Subject: [PATCH 01/14] ask user for permission before we start debugging --- pilot/const/messages.py | 2 ++ pilot/helpers/Debugger.py | 12 +++++++++++- pilot/helpers/agents/Developer.py | 2 -- pilot/helpers/cli.py | 6 ++++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/pilot/const/messages.py b/pilot/const/messages.py index 05a1321561..b3f59b3e2b 100644 --- a/pilot/const/messages.py +++ b/pilot/const/messages.py @@ -1,2 +1,4 @@ CHECK_AND_CONTINUE = 'If something is wrong, tell me or type "continue" to continue.' WHEN_USER_DONE = 'Once you\'re done, type "continue"' +AFFIRMATIVE_ANSWERS = ['', 'y', 'yes', 'ok', 'okay', 'sure'] +NEGATIVE_ANSWERS = ['n', 'no', 'skip'] \ No newline at end of file diff --git a/pilot/helpers/Debugger.py b/pilot/helpers/Debugger.py index 83d8c33731..fb21ac2261 100644 --- a/pilot/helpers/Debugger.py +++ b/pilot/helpers/Debugger.py @@ -3,9 +3,11 @@ import uuid from const.code_execution import MAX_COMMAND_DEBUG_TRIES, MAX_RECUSION_LAYER from const.function_calls import DEBUG_STEPS_BREAKDOWN +from const.messages import AFFIRMATIVE_ANSWERS, NEGATIVE_ANSWERS from helpers.exceptions.TokenLimitError import TokenLimitError from helpers.exceptions.TooDeepRecursionError import TooDeepRecursionError from logger.logger import logger +from prompts.prompts import ask_user class Debugger: @@ -13,7 +15,7 @@ class Debugger: self.agent = agent self.recursion_layer = 0 - def debug(self, convo, command=None, user_input=None, issue_description=None, is_root_task=False): + def debug(self, convo, command=None, user_input=None, issue_description=None, is_root_task=False, ask_before_debug=False): """ Debug a conversation. @@ -23,10 +25,18 @@ class Debugger: user_input (str, optional): User input for debugging. Default is None. Should provide `command` or `user_input`. issue_description (str, optional): Description of the issue to debug. Default is None. + ask_before_debug (bool, optional): True if we have to ask user for permission to start debugging. Returns: bool: True if debugging was successful, False otherwise. """ + if ask_before_debug: + answer = ask_user(self.agent.project, 'Can I start debugging this issue?', require_some_input=False) + if answer in NEGATIVE_ANSWERS: + return True + if answer and answer not in AFFIRMATIVE_ANSWERS: + user_input = answer + logger.info('Debugging %s', command) self.recursion_layer += 1 if self.recursion_layer > MAX_RECUSION_LAYER: diff --git a/pilot/helpers/agents/Developer.py b/pilot/helpers/agents/Developer.py index e00069196e..ad525261f7 100644 --- a/pilot/helpers/agents/Developer.py +++ b/pilot/helpers/agents/Developer.py @@ -487,8 +487,6 @@ class Developer(Agent): "user_input": user_feedback, }) - # self.debugger.debug(iteration_convo, user_input=user_feedback) - llm_response = iteration_convo.send_message('development/parse_task.prompt', { 'running_processes': running_processes, 'os': platform.system(), diff --git a/pilot/helpers/cli.py b/pilot/helpers/cli.py index 24c6927a14..9ee8661102 100644 --- a/pilot/helpers/cli.py +++ b/pilot/helpers/cli.py @@ -16,6 +16,7 @@ from helpers.exceptions.TokenLimitError import TokenLimitError from helpers.exceptions.CommandFinishedEarly import CommandFinishedEarly from prompts.prompts import ask_user from const.code_execution import MIN_COMMAND_RUN_TIME, MAX_COMMAND_RUN_TIME, MAX_COMMAND_OUTPUT_LENGTH +from const.messages import AFFIRMATIVE_ANSWERS, NEGATIVE_ANSWERS interrupted = False @@ -214,9 +215,9 @@ def execute_command(project, command, timeout=None, success_message=None, comman 'successfully executed.', False, hint=question) # TODO can we use .confirm(question, default='yes').ask() https://questionary.readthedocs.io/en/stable/pages/types.html#confirmation print('answer: ' + answer) - if answer.lower() in ['n', 'no', 'skip']: + if answer.lower() in NEGATIVE_ANSWERS: return None, 'SKIP', None - elif answer.lower() not in ['', 'y', 'yes', 'ok', 'okay', 'sure']: + elif answer.lower() not in AFFIRMATIVE_ANSWERS: # "That's not going to work, let's do X instead" # https://github.com/Pythagora-io/gpt-pilot/issues/198 # https://github.com/Pythagora-io/gpt-pilot/issues/43#issuecomment-1756352056 @@ -509,6 +510,7 @@ def run_command_until_success(convo, command, 'timeout': timeout, 'command_id': command_id, 'success_message': success_message, + 'ask_before_debug': True, }, user_input=cli_response, is_root_task=is_root_task) return {'success': success, 'cli_response': cli_response} except TooDeepRecursionError as e: From e9e94dcf479b777174dc005335c80eae38cb8ea3 Mon Sep 17 00:00:00 2001 From: LeonOstrez Date: Wed, 6 Dec 2023 15:48:05 +0000 Subject: [PATCH 02/14] update prompts for task creation --- pilot/const/function_calls.py | 2 +- pilot/helpers/agents/TechLead.py | 4 +- pilot/prompts/components/project_tasks.prompt | 37 +++++++++++++++++++ pilot/prompts/development/feature_plan.prompt | 8 +--- pilot/prompts/development/plan.prompt | 8 +--- .../system_messages/code_monkey.prompt | 2 +- .../prompts/system_messages/tech_lead.prompt | 8 +--- 7 files changed, 45 insertions(+), 24 deletions(-) create mode 100644 pilot/prompts/components/project_tasks.prompt diff --git a/pilot/const/function_calls.py b/pilot/const/function_calls.py index 787335d3e3..3371158c1f 100644 --- a/pilot/const/function_calls.py +++ b/pilot/const/function_calls.py @@ -394,7 +394,7 @@ DEVELOPMENT_PLAN = { }, 'user_review_goal': { 'type': 'string', - 'description': 'user-review goal that will determine if a task is done or not but from a user perspective since it will be reviewed by a human', + 'description': 'User review goal that will determine if a task is done or not, but from a user perspective since it will be reviewed by a human.', } }, 'required': ['description', 'programmatic_goal', 'user_review_goal'], diff --git a/pilot/helpers/agents/TechLead.py b/pilot/helpers/agents/TechLead.py index ff19ab917f..1f3c06d475 100644 --- a/pilot/helpers/agents/TechLead.py +++ b/pilot/helpers/agents/TechLead.py @@ -39,7 +39,8 @@ class TechLead(Agent): "clarifications": self.project.clarifications, "user_stories": self.project.user_stories, "user_tasks": self.project.user_tasks, - "technologies": self.project.architecture + "technologies": self.project.architecture, + "task_type": 'app', }, DEVELOPMENT_PLAN) self.project.development_plan = llm_response['plan'] @@ -69,6 +70,7 @@ class TechLead(Agent): "files": self.project.get_all_coded_files(), "previous_features": previous_features, "feature_description": feature_description, + "task_type": 'feature', }, DEVELOPMENT_PLAN) self.project.development_plan = llm_response['plan'] diff --git a/pilot/prompts/components/project_tasks.prompt b/pilot/prompts/components/project_tasks.prompt new file mode 100644 index 0000000000..193129b2c3 --- /dev/null +++ b/pilot/prompts/components/project_tasks.prompt @@ -0,0 +1,37 @@ +Before we go into the coding part, I want you to split the development process of creating this {{ task_type }} into smaller tasks so that it is easier to develop, debug and make the {{ task_type }} work. Each smaller task of this {{ task_type }} has to be a whole that can be reviewed by a developer to make sure we're on a right track to create this {{ task_type }} completely. + +Each task needs to be related only to the development of this {{ task_type }} and nothing else - once the {{ task_type }} is fully working, that is it. There shouldn't be a task for researching, deployment, writing documentation, or anything that is not writing the actual code. + +Now, based on the project details provided{% if task_type == 'feature' %} and new feature description{% endif %}, think task by task and create the entire development plan{% if task_type == 'feature' %} for new feature{% endif %}.{% if task_type == 'app' %} Start from the project setup and specify each task until the moment when the entire app should be fully working.{% endif %} For each task, write a description and a user-review goal. + +**IMPORTANT** +Dividing project into tasks is extremely important job and has to be done carefully. +There should never be a task that is only testing or ensuring something works, every task must have coding involved. Have this in mind for every task, but it is extremely important for last task of project. Testing if {{ task_type }} works will be done as part of each task. +You have to make sure the project is not split into tasks that are too small or simple for no reason but also not too big or complex so that they are hard to develop, debug and review. Here are examples of poorly created tasks: + +**too simple tasks** +- Set up a Node.js project and install all necessary dependencies. +- Establish a MongoDB database connection using Mongoose with the IP '127.0.0.1'. + +**too complex tasks** +- Set up Node.js project with /home, /profile, /register and /login routes that will have user authentication, connection to MongoDB with user schemas, mailing of new users and frontend with nice design. + +You must to avoid creating tasks that are too simple or too complex. You have to aim to create tasks that are medium complexity. Here are examples of tasks that are good: + +**good tasks** +- Set up a Node.js project, install all necessary dependencies and set up an express server with a simple route to `/ping` that returns the status 200. +- Establish a MongoDB database connection and implement the message schema using Mongoose for persistent storage of messages. + +Every {{ task_type }} should have different number of tasks depending on complexity. Think task by task and create the minimum number of tasks that are relevant for this specific {{ task_type }}.{% if task_type == 'feature' %} If the feature is small, it is ok to have only 1 task.{% endif %} Here are some examples of apps with different complexity that can give you guidance on how many tasks you should create: + +Example #1: +app description: "I want to create an app that will just say 'Hello World' when I open it on my localhost:3000." +number of tasks: 1-3 + +Example #2: +app description: "Create a node.js app that enables users to register and log into the app. On frontend it should have /home (shows user data), /register and /login. It should use sessions to keep user logged in." +number of tasks: 2-6 + +Example #3: +app description: "A cool online shoe store, with a sleek look. In terms of data models, there are shoes, categories and user profiles. For web pages: product listing, details, shopping cart. It must look cool and jazzy." +number of tasks: 5-15 \ No newline at end of file diff --git a/pilot/prompts/development/feature_plan.prompt b/pilot/prompts/development/feature_plan.prompt index e9887b5a7b..a1e190c435 100644 --- a/pilot/prompts/development/feature_plan.prompt +++ b/pilot/prompts/development/feature_plan.prompt @@ -70,10 +70,4 @@ Finally, here is the description of new feature that needs to be added to {{ app {{ feature_description }} ``` -OK, now, you need to create code to have this feature fully working but before we go into the coding part, I want you to split the development process of creating this feature into smaller tasks so that it is easier to debug and make the feature work. Each smaller task of this feature has to be a whole that can be reviewed by a developer to make sure we're on a right track to create this feature. Make sure that you do NOT split feature into tasks that are too small as well, they need to be split logically for developer to keep track of his progress. - -Each task needs to be related only to the development of this feature and nothing else - once the feature is fully working, that is it. There shouldn't be a task for researching, deployment, writing documentation, or anything that is not writing the actual code. Think task by task and create the minimum number of tasks that are relevant for this specific feature. If the feature is small, it is ok to have only 1 task. - -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 project details provided and new feature description, think task by task and create the entire development plan for new feature. For each task, write a description and a user-review goal. \ No newline at end of file +{{ project_tasks }} \ No newline at end of file diff --git a/pilot/prompts/development/plan.prompt b/pilot/prompts/development/plan.prompt index d47277b3a7..ced64cc60c 100644 --- a/pilot/prompts/development/plan.prompt +++ b/pilot/prompts/development/plan.prompt @@ -40,10 +40,4 @@ Here are the technologies that you need to use for this project: {% endfor %} ``` -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. Also, make sure it is not be split into tasks that are too small for no reason. - -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 researching, 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,{% if user_stories %} user stories,{% endif %}{% if user_tasks %} user tasks,{% endif %} and the technologies that you need to use, think task by task and create the entire development plan. 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 +{{ project_tasks }} \ No newline at end of file diff --git a/pilot/prompts/system_messages/code_monkey.prompt b/pilot/prompts/system_messages/code_monkey.prompt index c0ef55bf66..ec5bd20af1 100644 --- a/pilot/prompts/system_messages/code_monkey.prompt +++ b/pilot/prompts/system_messages/code_monkey.prompt @@ -1 +1 @@ -You are a full stack software developer who works in a software development agency. You write very modular code and you practice TDD (test driven development) whenever is suitable to use it. Your job is to implement tasks that your tech lead assigns you. \ No newline at end of file +You are a full stack software developer who works in a software development agency. You write very modular code. Your job is to implement tasks that your tech lead assigns you. \ No newline at end of file diff --git a/pilot/prompts/system_messages/tech_lead.prompt b/pilot/prompts/system_messages/tech_lead.prompt index 18f33f7095..95e8cdf2f6 100644 --- a/pilot/prompts/system_messages/tech_lead.prompt +++ b/pilot/prompts/system_messages/tech_lead.prompt @@ -1,7 +1 @@ -You are a tech lead in a software development agency and your main task is to break down the project into smaller tasks that developers will do. Your main goal is to specify each task as clear as possible so that each task can be reviewed by you to check if it can be marked as done or not. Each task needs to have a description of what needs to be implemented, a programmatic goal that will determine if a task can be marked as done from a programmatic perspective (this will result in an automated test that is run before the task is sent to you for a review) and user-review goal that will determine if a task is done or not but from a user perspective since it will be reviewed by a human. Here are examples of parts of a task: - -**description** - set up an express server with a simple route to `/ping` that returns the status 200 with the response "Hello World" - -** programmatic goal** - server needs to be able to start running on a port 3000 and accept API request to the URL `http://localhost:3000/ping` when it will return the status code 200 - -**user-review goal** - user needs to be able to run the server by running a command `npm run start` and open the URL `http://localhost:3000/ping` in a browser that shows "Hello World" on the screen \ No newline at end of file +You are an experienced tech lead in a software development agency and your main task is to break down the project into smaller tasks that developers will do. You must specify each task as clear as possible. Each task must have a description of what needs to be implemented, a programmatic goal that will determine if a task can be marked as done from a programmatic perspective and user-review goal that will determine if a task is done or not but from a user perspective since it will be reviewed by a human. \ No newline at end of file From f03196f7d73face849d95d010066272ead95e029 Mon Sep 17 00:00:00 2001 From: LeonOstrez Date: Thu, 7 Dec 2023 10:26:34 +0000 Subject: [PATCH 03/14] ask before debugging inside every debug loop --- pilot/helpers/Debugger.py | 14 +++++++------- pilot/helpers/Project.py | 5 +++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pilot/helpers/Debugger.py b/pilot/helpers/Debugger.py index 1021e2b5a4..c01bc26082 100644 --- a/pilot/helpers/Debugger.py +++ b/pilot/helpers/Debugger.py @@ -31,13 +31,6 @@ class Debugger: Returns: bool: True if debugging was successful, False otherwise. """ - if ask_before_debug: - answer = ask_user(self.agent.project, 'Can I start debugging this issue?', require_some_input=False) - if answer in NEGATIVE_ANSWERS: - return True - if answer and answer not in AFFIRMATIVE_ANSWERS: - user_input = answer - logger.info('Debugging %s', command) self.recursion_layer += 1 if self.recursion_layer > MAX_RECUSION_LAYER: @@ -52,6 +45,13 @@ class Debugger: if success: break + if ask_before_debug or i > 0: + answer = ask_user(self.agent.project, 'Can I start debugging this issue?', require_some_input=False) + if answer in NEGATIVE_ANSWERS: + return True + if answer and answer not in AFFIRMATIVE_ANSWERS: + user_input = answer + llm_response = convo.send_message('dev_ops/debug.prompt', { 'command': command['command'] if command is not None else None, diff --git a/pilot/helpers/Project.py b/pilot/helpers/Project.py index 65a9cdc7f4..905f8f40da 100644 --- a/pilot/helpers/Project.py +++ b/pilot/helpers/Project.py @@ -4,7 +4,7 @@ from pathlib import Path import re from typing import Tuple -from const.messages import CHECK_AND_CONTINUE +from const.messages import CHECK_AND_CONTINUE, AFFIRMATIVE_ANSWERS from utils.style import color_yellow_bold, color_cyan, color_white_bold, color_green from const.common import IGNORE_FOLDERS, STEPS from database.database import delete_unconnected_steps_from, delete_all_app_development_data, update_app_status @@ -271,7 +271,8 @@ class Project: for line_number, line_content in inputs_required: user_input = '' print(color_yellow_bold(f'Input required on line {line_number}:\n{line_content}') + '\n') - while user_input.lower() not in ['y']: + while user_input.lower() not in AFFIRMATIVE_ANSWERS: + print('yes', type='button') user_input = styled_text( self, f'Please open the file {data["path"]} on the line {line_number} and add the required input. Once you\'re done, type "y" to continue.', From 0e62f7e3b39b08070f172426808cce602048d42b Mon Sep 17 00:00:00 2001 From: LeonOstrez Date: Thu, 7 Dec 2023 13:09:34 +0000 Subject: [PATCH 04/14] add rules to task creation --- pilot/prompts/architecture/technologies.prompt | 2 +- pilot/prompts/components/project_tasks.prompt | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pilot/prompts/architecture/technologies.prompt b/pilot/prompts/architecture/technologies.prompt index a97706e608..8d769bce8f 100644 --- a/pilot/prompts/architecture/technologies.prompt +++ b/pilot/prompts/architecture/technologies.prompt @@ -33,7 +33,7 @@ Here are user tasks that specify what users need to do to interact with "{{ name ``` {% endif %} -Now, based on the app's description, user stories and user tasks, think step by step and list the names of the technologies that will be used by your development team to create the app "{{ name }}". Do not write any explanations behind your choices but only a list of technologies that will be used. +Now, based on the projects details, think step by step and list the names of the technologies that will be used by your development team to create the app "{{ name }}". Do not give any subjective thoughts or options, give exact technologies, for example: Instead of ["D3.js or other suitable charting library", "axios or other http client library"] answer with ["D3.js", "axios"]. diff --git a/pilot/prompts/components/project_tasks.prompt b/pilot/prompts/components/project_tasks.prompt index 193129b2c3..051f5c9e95 100644 --- a/pilot/prompts/components/project_tasks.prompt +++ b/pilot/prompts/components/project_tasks.prompt @@ -2,11 +2,15 @@ Before we go into the coding part, I want you to split the development process o Each task needs to be related only to the development of this {{ task_type }} and nothing else - once the {{ task_type }} is fully working, that is it. There shouldn't be a task for researching, deployment, writing documentation, or anything that is not writing the actual code. -Now, based on the project details provided{% if task_type == 'feature' %} and new feature description{% endif %}, think task by task and create the entire development plan{% if task_type == 'feature' %} for new feature{% endif %}.{% if task_type == 'app' %} Start from the project setup and specify each task until the moment when the entire app should be fully working.{% endif %} For each task, write a description and a user-review goal. +Now, based on the project details provided{% if task_type == 'feature' %} and new feature description{% endif %}, think task by task and create the entire development plan{% if task_type == 'feature' %} for new feature{% endif %}.{% if task_type == 'app' %} Start from the project setup and specify each task until the moment when the entire app should be fully working.{% endif %} **IMPORTANT** -Dividing project into tasks is extremely important job and has to be done carefully. +Dividing project into tasks is extremely important job and has to be done carefully while always strictly following all rules listed bellow. + +Rule #1 There should never be a task that is only testing or ensuring something works, every task must have coding involved. Have this in mind for every task, but it is extremely important for last task of project. Testing if {{ task_type }} works will be done as part of each task. + +Rule #2 You have to make sure the project is not split into tasks that are too small or simple for no reason but also not too big or complex so that they are hard to develop, debug and review. Here are examples of poorly created tasks: **too simple tasks** @@ -22,6 +26,7 @@ You must to avoid creating tasks that are too simple or too complex. You have to - Set up a Node.js project, install all necessary dependencies and set up an express server with a simple route to `/ping` that returns the status 200. - Establish a MongoDB database connection and implement the message schema using Mongoose for persistent storage of messages. +Rule #3 Every {{ task_type }} should have different number of tasks depending on complexity. Think task by task and create the minimum number of tasks that are relevant for this specific {{ task_type }}.{% if task_type == 'feature' %} If the feature is small, it is ok to have only 1 task.{% endif %} Here are some examples of apps with different complexity that can give you guidance on how many tasks you should create: Example #1: From a0f06b96d7ff37fc270c156a8e73991eaf2c1009 Mon Sep 17 00:00:00 2001 From: LeonOstrez Date: Thu, 7 Dec 2023 18:21:10 +0000 Subject: [PATCH 05/14] fix issue when gpt pilot picks technologies that are not needed for the project --- .../prompts/system_messages/architect.prompt | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/pilot/prompts/system_messages/architect.prompt b/pilot/prompts/system_messages/architect.prompt index 7261a5585d..eec2c2abfb 100644 --- a/pilot/prompts/system_messages/architect.prompt +++ b/pilot/prompts/system_messages/architect.prompt @@ -1,10 +1,11 @@ -You are an experienced software architect. Your expertise is in creating an architecture for an MVP (minimum viable products) for {{ app_type }}s that can be developed as fast as possible by using as many ready-made technologies as possible. The technologies that you prefer using when other technologies are not explicitly specified are: -**Scripts**: You prefer using Node.js for writing scripts that are meant to be ran just with the CLI. - -**Backend**: You prefer using Node.js with Mongo database if not explicitly specified otherwise. When you're using Mongo, you always use Mongoose and when you're using a relational database, you always use PeeWee as an ORM. - -**Testing**: To create unit and integration tests, you prefer using Jest for Node.js projects and pytest for Python projects. To create end-to-end tests, you prefer using Cypress. - -**Frontend**: You prefer using Bootstrap for creating HTML and CSS while you use plain (vanilla) Javascript. - -**Other**: From other technologies, if the project requires periodical script run, you prefer using cronjob (for making automated tasks), and if the project requires real time communication, you prefer Socket.io for web sockets +You are an experienced software architect. Your expertise is in creating an architecture for an MVP (minimum viable products) for {{ app_type }}s that can be developed as fast as possible by using as many ready-made technologies as possible. + +Never list technologies that are not needed in the project. If for specific part of project you have to choose between multiple technologies, in that case, here are technologies that you prefer using: +- Node.js, +- MongoDB, +- PeeWee, +- Bootstrap, +- HTML, +- CSS3, +- cronjob, +- Socket.io \ No newline at end of file From d6495408405c188bf25e0311b0e99778b17032bd Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Fri, 8 Dec 2023 09:07:01 +0100 Subject: [PATCH 06/14] Fix --- pilot/prompts/development/implement_changes.prompt | 2 +- pilot/prompts/development/parse_task.prompt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pilot/prompts/development/implement_changes.prompt b/pilot/prompts/development/implement_changes.prompt index de88721eff..befc309ad2 100644 --- a/pilot/prompts/development/implement_changes.prompt +++ b/pilot/prompts/development/implement_changes.prompt @@ -16,7 +16,7 @@ This task is broken down into steps. Please tell me the changes needed to implem {{ step_description }} ``` -Within the file modifications, anything needs to be written by the user, add the comment in the same line as the code that starts with `// INPUT_REQUIRED {input_description}` where `input_description` is a description of what needs to be added here by the user. Finally, you can save the modified files on the disk by calling `save_files` function. +Within the file modifications, anything needs to be written by the user, add the comment in the same line as the code that starts with `// INPUT_REQUIRED {input_description}` where `input_description` is a description of what needs to be added here by the user. Just make sure that you put comments only inside files that support comments (e.g. not in JSON files).. **IMPORTANT** When you think about in which file should the new code go to, always try to make files as small as possible and put code in more smaller files rather than in one big file. Whenever a file becomes too large (more than 50 lines of code) split it into smaller files. diff --git a/pilot/prompts/development/parse_task.prompt b/pilot/prompts/development/parse_task.prompt index 02cdd244dc..f01d819abb 100644 --- a/pilot/prompts/development/parse_task.prompt +++ b/pilot/prompts/development/parse_task.prompt @@ -1,7 +1,7 @@ Ok, now, take your previous message and convert it to actionable items. An item might be a code change or a command run. When you need to change code, make sure that you put the entire content of the file in the value of `content` key even though you will likely copy and paste the most of the previous message. The commands must be able to run on a {{ os }} machine. **IMPORTANT** -Within the file modifications, anything needs to be written by the user, add the comment in the same line as the code that starts with `// INPUT_REQUIRED {input_description}` where `input_description` is a description of what needs to be added here by the user. Finally, you can save the modified files on the disk by calling `save_files` function. +Within the file modifications, anything needs to be written by the user, add the comment in the same line as the code that starts with `// INPUT_REQUIRED {input_description}` where `input_description` is a description of what needs to be added here by the user. Just make sure that you put comments only inside files that support comments (e.g. not in JSON files). **IMPORTANT** When you want to add a comment that tells the user to add the previous implementation at that place, make sure that the comment starts with `[OLD CODE]` and add a description of what old code should be inserted here. For example, `[OLD CODE] Login route`. From 9c6839a4fc77504f43601aa298c43adf51d38967 Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Fri, 8 Dec 2023 12:21:42 +0100 Subject: [PATCH 07/14] Update files within prompts before sending the message to the LLM --- pilot/helpers/AgentConvo.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pilot/helpers/AgentConvo.py b/pilot/helpers/AgentConvo.py index fe434ab756..47b2045cc5 100644 --- a/pilot/helpers/AgentConvo.py +++ b/pilot/helpers/AgentConvo.py @@ -81,6 +81,7 @@ class AgentConvo: else: # if we don't, get the response from LLM try: + self.replace_files() response = create_gpt_chat_completion(self.messages, self.high_level_step, self.agent.project, function_calls=function_calls) except TokenLimitError as e: @@ -187,7 +188,7 @@ class AgentConvo: for msg in self.messages: if msg['role'] == 'user': for file in files: - msg['content'] = self.replace_file_content(msg['content'], file['path'], file['content']) + msg['content'] = self.replace_file_content(msg['content'], f"{file['path']}/{file['name']}", file['content']) def escape_specials(self, s): s = s.replace("\\", "\\\\") @@ -213,7 +214,7 @@ class AgentConvo: def replace_file_content(self, message, file_path, new_content): escaped_file_path = re.escape(file_path) - pattern = rf'\*\*{escaped_file_path}\*\*\n```\n(.*?)\n```' + pattern = rf'\*\*{escaped_file_path}\*\*:\n```\n(.*?)\n```' # Escape special characters in new_content for the sake of regex replacement new_content_escaped = self.escape_specials(new_content) From 4146e624b8f7f312d44f23fca90e66e680cf5f14 Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Fri, 8 Dec 2023 12:33:46 +0100 Subject: [PATCH 08/14] Updated file names in all prompts now that path doesn't have name inside it --- pilot/prompts/development/get_fully_coded_file.prompt | 2 +- pilot/prompts/development/get_snippet_from_comment.prompt | 6 +++--- pilot/prompts/development/implement_changes.prompt | 2 +- pilot/prompts/development/task/breakdown.prompt | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pilot/prompts/development/get_fully_coded_file.prompt b/pilot/prompts/development/get_fully_coded_file.prompt index 030d99b8fa..2b265c3339 100644 --- a/pilot/prompts/development/get_fully_coded_file.prompt +++ b/pilot/prompts/development/get_fully_coded_file.prompt @@ -1,4 +1,4 @@ -Here is how the file `{{ file.path }}` looks like right now: +Here is how the file `{{ file.path }}/{{ file.name }}` looks like right now: ``` {{ file.content }} ``` diff --git a/pilot/prompts/development/get_snippet_from_comment.prompt b/pilot/prompts/development/get_snippet_from_comment.prompt index 90644981c9..fbe8e2dda9 100644 --- a/pilot/prompts/development/get_snippet_from_comment.prompt +++ b/pilot/prompts/development/get_snippet_from_comment.prompt @@ -1,6 +1,6 @@ Here are previously coded files: {% for file in previously_coded_files %} -**{{ file.path }}**: +**{{ file.path }}/{{ file.name }}**: ``` {{ file.content }} ``` @@ -8,7 +8,7 @@ Here are previously coded files: And here are the new implementations of these same files: {% for file in files_with_comments -%} -**{{ file.path }}**: +**{{ file.path }}/{{ file.name }}**: ``` {{ file.content }} ``` @@ -18,7 +18,7 @@ Look at the following lines of code: {% for file in files_with_comments -%} {% if file.comments|length > 0 -%} {%- for comment in file['comments'] -%} -`{{ comment }}` inside `{{ file['path'] }}` +`{{ comment }}` inside `{{ file['path'] }}/{{ file['name'] }}` {% endfor %} {%- endif -%} {%- endfor %} diff --git a/pilot/prompts/development/implement_changes.prompt b/pilot/prompts/development/implement_changes.prompt index de88721eff..4c639e3912 100644 --- a/pilot/prompts/development/implement_changes.prompt +++ b/pilot/prompts/development/implement_changes.prompt @@ -1,6 +1,6 @@ {% if files|length > 0 %}Here is how files look now: {% for file in files %} -**{{ file.path }}/{{ file.name }}** +**{{ file.path }}/{{ file.name }}**: ```{# file.language #} {{ file.content }} ``` diff --git a/pilot/prompts/development/task/breakdown.prompt b/pilot/prompts/development/task/breakdown.prompt index a383398ffd..e7f1bafb3b 100644 --- a/pilot/prompts/development/task/breakdown.prompt +++ b/pilot/prompts/development/task/breakdown.prompt @@ -27,7 +27,7 @@ Here are the technologies that {% if task_type == 'app' %}you need to use{% else {% if current_task_index != 0 or task_type == 'feature' %} So far, this code has been implemented: {% for file in files %} -**{{ file.path }}/{{ file.name }}** +**{{ file.path }}/{{ file.name }}**: ```{# file.language #} {{ file.content }} ``` From a2d4e3ab5a30f0798707e8e3421748659d4b328a Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Fri, 8 Dec 2023 12:35:17 +0100 Subject: [PATCH 09/14] Removing old messaging inside prompts --- pilot/helpers/agents/Developer.py | 2 +- pilot/prompts/dev_ops/debug.prompt | 13 +++++++++---- .../development/define_user_review_goal.prompt | 8 ++++---- pilot/prompts/development/iteration.prompt | 2 +- pilot/prompts/development/task/breakdown.prompt | 7 ++++--- pilot/prompts/development/task/next_step.prompt | 7 +++---- 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/pilot/helpers/agents/Developer.py b/pilot/helpers/agents/Developer.py index 83affe354e..0ad9253b68 100644 --- a/pilot/helpers/agents/Developer.py +++ b/pilot/helpers/agents/Developer.py @@ -173,7 +173,7 @@ class Developer(Agent): else: data = step['command'] # TODO END - additional_message = 'Let\'s start with the step #0:\n' if i == 0 else f'So far, steps { ", ".join(f"#{j}" for j in range(i+1)) } are finished so let\'s do step #{i + 1} now.\n' + additional_message = '' #'Let\'s start with the step #0:\n' if i == 0 else f'So far, steps { ", ".join(f"#{j}" for j in range(i+1)) } are finished so let\'s do step #{i + 1} now.\n' command_id = data['command_id'] if 'command_id' in data else None success_message = data['success_message'] if 'success_message' in data else None diff --git a/pilot/prompts/dev_ops/debug.prompt b/pilot/prompts/dev_ops/debug.prompt index f4b98a0d6b..a3c97a02db 100644 --- a/pilot/prompts/dev_ops/debug.prompt +++ b/pilot/prompts/dev_ops/debug.prompt @@ -10,12 +10,17 @@ Here is a brief explanation of what's happening: ``` {% endif -%} {{ context }} -I want you to debug this issue by yourself using the `steps` of the `start_debugging` function. +I want you to create a list of steps that are needed to debug this issue. -`command` step will run a command on the machine and will return the CLI output to you so you can see what to do next. Note that the command will run on a {{ os }} machine. +A step can be either a `command` or `code_change`. -`code_change` step will change the code where you just need to thoroughly describe what needs to be implemented, I will implement the requested changes and let you know. When you think about in which file should the new code go to, always try to make files as small as possible and put code in more smaller files rather than in one big file. +`command` step will run a command on the machine and will return the CLI output to you so you can see what to do next. Note that the command will be run on a {{ os }} machine. -Return a list of steps that are needed to debug this issue. By the time we execute the last step, the issue should be fixed completely. Also, make sure that at least the last step has `check_if_fixed` set to TRUE. +`code_change` step will change the code and you need to thoroughly describe what needs to be implemented. I will implement the requested changes and let you know. + +Also, make sure that at least the last step has `check_if_fixed` set to TRUE. + +**IMPORTANT** +When you think about in which file should the new code go to, always try to make files as small as possible and put code in more smaller files rather than in one big file. Whenever a file becomes too large (more than 50 lines of code) split it into smaller files. {# After this, you need to decide what to do next. You can rerun the command `{{ command }}` to check if the problem is fixed or run another command with `run_command` or change more code with `implement_code_changes`. #} diff --git a/pilot/prompts/development/define_user_review_goal.prompt b/pilot/prompts/development/define_user_review_goal.prompt index 715f077639..7039d9f83c 100644 --- a/pilot/prompts/development/define_user_review_goal.prompt +++ b/pilot/prompts/development/define_user_review_goal.prompt @@ -1,8 +1,8 @@ -How can a human user test if this task was completed successfully? If you specify a command that needs to be run or give example, be very specific. You don't want the user to have to think anything through but rather that they just follow your instructions. Note that the command will run on a {{ os }} machine. +How can a human user test if this task was completed successfully? If you specify a command that needs to be run or give example, be very specific. You don't want the user to have to think anything through but rather that they just follow your instructions. Note that any commands will be run on a {{ os }} machine. -!IMPORTANT! +**IMPORTANT** In case the task can be tested by making an API request, do not suggest how can a request be made with Postman but rather write a full cURL command that the user can just run. -!IMPORTANT! +**IMPORTANT** Do not require any code writing form the user for testing this task. -Try your best to avoid this if possible, but if it is very difficult to test the task, you can just answer with only this sentence - `There is nothing specific to test for this task so you can write "continue" and we'll move on to the next task.` \ No newline at end of file +Try your best to avoid this if possible, but if it is very difficult to test the task, you can just answer with only this sentence - `There is nothing specific to test for this task so you can write "continue" and we'll move on to the next task.` diff --git a/pilot/prompts/development/iteration.prompt b/pilot/prompts/development/iteration.prompt index 0c4f3fa489..c94a565e6f 100644 --- a/pilot/prompts/development/iteration.prompt +++ b/pilot/prompts/development/iteration.prompt @@ -13,7 +13,7 @@ Here are the technologies that you need to use for this project: {% if development_tasks and current_task %} Development process of this app was split into smaller tasks. Here is the list of all tasks: ```{% for task in development_tasks %} -- {{ loop.index }}. {{ task['description'] }} +{{ loop.index }}. {{ task['description'] }} {% endfor %} ``` You are currently working on task "{{ current_task.description }}" and you have to focus only on that task. diff --git a/pilot/prompts/development/task/breakdown.prompt b/pilot/prompts/development/task/breakdown.prompt index e7f1bafb3b..74e348eb19 100644 --- a/pilot/prompts/development/task/breakdown.prompt +++ b/pilot/prompts/development/task/breakdown.prompt @@ -37,11 +37,11 @@ So far, this code has been implemented: We've broken the development of this {{ task_type }} down to these tasks: ```{% for task in development_tasks %} -- {{ loop.index }}. {{ task['description'] }} +{{ loop.index }}. {{ task['description'] }} {% endfor %} ``` -You are currently working on task {{ current_task_index + 1 }} with the following description: +You are currently working on task #{{ current_task_index + 1 }} with the following description: ``` {{ development_tasks[current_task_index]['description'] }} ``` @@ -54,9 +54,10 @@ Now, tell me all the code that needs to be written to implement ONLY this task a When you think about in which file should the new code go to, always try to make files as small as possible and put code in more smaller files rather than in one big file. Whenever a file becomes too large (more than 50 lines of code) split it into smaller files. **IMPORTANT** -{% if task_type == 'app' %} +{%- if task_type == 'app' %} Remember, I created an empty folder where I will start writing files that you tell me and that are needed for this app. You do not need to make any automated tests work. {% endif %} 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. diff --git a/pilot/prompts/development/task/next_step.prompt b/pilot/prompts/development/task/next_step.prompt index 28d97ab175..f6f73fca42 100644 --- a/pilot/prompts/development/task/next_step.prompt +++ b/pilot/prompts/development/task/next_step.prompt @@ -1,13 +1,13 @@ {% if step_index != 0 %} So far, steps {{ finished_steps }} are finished so let's do {% else %} -Let's start with the{% endif %} step #{{ step_index }}: +Let's start with the{% endif %} step #{{ step_index }}. Here is the description of this step: ``` {{ step_description }} ``` -This step by step about what needs to be done to fulfill this step. +Think step by step about what needs to be done to fulfill this step. {% if step_type == 'COMMAND' %} -Respond with all commands that need to be run to fulfill this step. In case this is a complex step that can't be completed by only running commands (maybe it requires some code changes or user review), respond with an array with only one item `COMPLEX`. Like this - `[{"command": "COMPLEX", "timeout": 0}]` +Respond with all commands that need to be run to fulfill this step. {% elif step_type == 'CODE_CHANGE' %} First, you need to know the code that's currently written so that you can appropriately write new or update the existing code. {# Here are all the file that are written so far in a file tree format: ``` @@ -16,4 +16,3 @@ First, you need to know the code that's currently written so that you can approp #} Respond with a list of files that you need to see before you can write the code for the current step. This list needs to be in a JSON array where each item is a file name. Do not respond with anything other than the mentioned JSON array. {% endif %} - \ No newline at end of file From ccc76873ae05d467632b129aab78d99eb0b722ae Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Fri, 8 Dec 2023 13:23:17 +0100 Subject: [PATCH 10/14] Fixed test --- pilot/helpers/test_Debugger.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pilot/helpers/test_Debugger.py b/pilot/helpers/test_Debugger.py index 78c932ce39..34fafda0ef 100644 --- a/pilot/helpers/test_Debugger.py +++ b/pilot/helpers/test_Debugger.py @@ -112,6 +112,7 @@ def test_debug_need_to_see_output(mock_save_step, mock_get_completion, mock_get_ debugger = Debugger(developer) convo = AgentConvo(developer) convo.load_branch = MagicMock() + convo.replace_files = MagicMock() # hard-wired LLM responses, 1st response asks to see output mock_get_completion.side_effect = [{'text': json.dumps(response)} for response in [{ 'thoughts': 'Hmmm, testing', From bca76e7f8f228f0b10fe502cfed298d80edba2b0 Mon Sep 17 00:00:00 2001 From: LeonOstrez Date: Fri, 8 Dec 2023 12:59:38 +0000 Subject: [PATCH 11/14] add buttons for extension and check user answer in lower case --- pilot/helpers/Debugger.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pilot/helpers/Debugger.py b/pilot/helpers/Debugger.py index c01bc26082..76a2328107 100644 --- a/pilot/helpers/Debugger.py +++ b/pilot/helpers/Debugger.py @@ -46,10 +46,11 @@ class Debugger: break if ask_before_debug or i > 0: + print('yes/no', type='button') answer = ask_user(self.agent.project, 'Can I start debugging this issue?', require_some_input=False) - if answer in NEGATIVE_ANSWERS: + if answer.lower() in NEGATIVE_ANSWERS: return True - if answer and answer not in AFFIRMATIVE_ANSWERS: + if answer and answer.lower() not in AFFIRMATIVE_ANSWERS: user_input = answer llm_response = convo.send_message('dev_ops/debug.prompt', From 687c89ef4a56b2e14cf677b249bad4ee54438e6c Mon Sep 17 00:00:00 2001 From: LeonOstrez Date: Fri, 8 Dec 2023 18:42:13 +0000 Subject: [PATCH 12/14] update rules when picking technologies, do not mix tech that is not compatible --- pilot/prompts/architecture/technologies.prompt | 13 +++++++++++++ pilot/prompts/system_messages/architect.prompt | 12 +----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/pilot/prompts/architecture/technologies.prompt b/pilot/prompts/architecture/technologies.prompt index 8d769bce8f..a988ffc1a8 100644 --- a/pilot/prompts/architecture/technologies.prompt +++ b/pilot/prompts/architecture/technologies.prompt @@ -39,4 +39,17 @@ Instead of ["D3.js or other suitable charting library", "axios or other http cli You do not need to list any technologies related to automated tests (like Jest, Cypress, Mocha, Selenium, etc) or any technologies related to deployment (like Heroku). +**Project Technology Guidelines** +Relevance: Only include technologies that are essential and will be actively used in the project. Avoid mentioning any technologies that are not required. For example, don't suggest MongoDB if database is not needed for project. +Compatibility: Ensure that the listed technologies are compatible with each other. Exclude any technologies that cannot be integrated or used in conjunction with others. For example, Pandas (Python library) and Node.js can't be used together. Another example is MongoDB (NoSQL database) and MySQL (SQL database) shouldn't be used together unless that is specified in project description. +Technology Preferences: In scenarios where multiple technology options are available for a specific project component, prioritize the following preferred technologies: +- Node.js, +- MongoDB, +- PeeWee, +- Bootstrap, +- HTML, +- CSS3, +- cronjob, +- Socket.io + {{no_microservices}} diff --git a/pilot/prompts/system_messages/architect.prompt b/pilot/prompts/system_messages/architect.prompt index eec2c2abfb..62e9b62e83 100644 --- a/pilot/prompts/system_messages/architect.prompt +++ b/pilot/prompts/system_messages/architect.prompt @@ -1,11 +1 @@ -You are an experienced software architect. Your expertise is in creating an architecture for an MVP (minimum viable products) for {{ app_type }}s that can be developed as fast as possible by using as many ready-made technologies as possible. - -Never list technologies that are not needed in the project. If for specific part of project you have to choose between multiple technologies, in that case, here are technologies that you prefer using: -- Node.js, -- MongoDB, -- PeeWee, -- Bootstrap, -- HTML, -- CSS3, -- cronjob, -- Socket.io \ No newline at end of file +You are an experienced software architect. Your expertise is in creating an architecture for an MVP (minimum viable products) for {{ app_type }}s that can be developed as fast as possible by using as many ready-made technologies as possible. \ No newline at end of file From 6e1f7845bf25fcccc6217e5b6f1d0b737453184a Mon Sep 17 00:00:00 2001 From: LeonOstrez Date: Fri, 8 Dec 2023 20:15:15 +0000 Subject: [PATCH 13/14] fixes for extension part1 - add buttons, fix asking to debug --- pilot/helpers/agents/Developer.py | 4 ++-- pilot/helpers/cli.py | 3 +-- pilot/utils/llm_connection.py | 6 ++++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pilot/helpers/agents/Developer.py b/pilot/helpers/agents/Developer.py index 039f93f7c5..794618b796 100644 --- a/pilot/helpers/agents/Developer.py +++ b/pilot/helpers/agents/Developer.py @@ -208,7 +208,7 @@ class Developer(Agent): if (self.project.ipc_client_instance is None or self.project.ipc_client_instance.client is None): human_intervention_description += color_yellow_bold('\n\nIf you want to run the app, just type "r" and press ENTER and that will run `' + self.run_command + '`') else: - print(self.run_command, type="run_command") + print(self.run_command, type='run_command') response = self.project.ask_for_human_intervention('I need human intervention:', human_intervention_description, @@ -447,7 +447,7 @@ class Developer(Agent): if self.project.ipc_client_instance is None or self.project.ipc_client_instance.client is None: user_description += color_yellow_bold('\n\nIf you want to run the app, just type "r" and press ENTER and that will run `' + self.run_command + '`') else: - print(self.run_command, type="run_command") + print(self.run_command, type='run_command') # continue_description = '' # TODO: Wait for a specific string in the output or timeout? diff --git a/pilot/helpers/cli.py b/pilot/helpers/cli.py index 13d7d06c92..5b11b4b1e7 100644 --- a/pilot/helpers/cli.py +++ b/pilot/helpers/cli.py @@ -511,8 +511,7 @@ def run_command_until_success(convo, command, 'timeout': timeout, 'command_id': command_id, 'success_message': success_message, - 'ask_before_debug': True, - }, user_input=cli_response, is_root_task=is_root_task) + },user_input=cli_response, is_root_task=is_root_task, ask_before_debug=True) return {'success': success, 'cli_response': cli_response} except TooDeepRecursionError as e: # this is only to put appropriate message in the response after TooDeepRecursionError is raised diff --git a/pilot/utils/llm_connection.py b/pilot/utils/llm_connection.py index cfbcd1d314..67ccc5e964 100644 --- a/pilot/utils/llm_connection.py +++ b/pilot/utils/llm_connection.py @@ -10,7 +10,8 @@ from prompt_toolkit.styles import Style from jsonschema import validate, ValidationError from utils.style import color_red from typing import List -from const.llm import MIN_TOKENS_FOR_GPT_RESPONSE, MAX_GPT_MODEL_TOKENS +from const.llm import MAX_GPT_MODEL_TOKENS +from const.messages import AFFIRMATIVE_ANSWERS from logger.logger import logger, logging from helpers.exceptions import TokenLimitError, ApiKeyNotDefinedError from utils.utils import fix_json, get_prompt @@ -236,6 +237,7 @@ def retry_on_exception(func): logger.error(f'There was a problem with request to openai API: {err_str}') project = args[2] + print('yes/no', type='button') user_message = styled_text( project, 'Do you want to try make the same request again? If yes, just press ENTER. Otherwise, type "no".', @@ -247,7 +249,7 @@ def retry_on_exception(func): # TODO: take user's input into consideration - send to LLM? # https://github.com/Pythagora-io/gpt-pilot/issues/122 - if user_message != '': + if user_message.lower() not in AFFIRMATIVE_ANSWERS: return {} return wrapper From 6340fe2228d41d020cc67f28ff9b646d205bdb95 Mon Sep 17 00:00:00 2001 From: LeonOstrez Date: Sat, 9 Dec 2023 13:37:33 +0000 Subject: [PATCH 14/14] change accepted user inputs when loading app and added buttons for extension --- pilot/helpers/Project.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pilot/helpers/Project.py b/pilot/helpers/Project.py index 905f8f40da..6c51790ca7 100644 --- a/pilot/helpers/Project.py +++ b/pilot/helpers/Project.py @@ -4,7 +4,7 @@ from pathlib import Path import re from typing import Tuple -from const.messages import CHECK_AND_CONTINUE, AFFIRMATIVE_ANSWERS +from const.messages import CHECK_AND_CONTINUE, AFFIRMATIVE_ANSWERS, NEGATIVE_ANSWERS from utils.style import color_yellow_bold, color_cyan, color_white_bold, color_green from const.common import IGNORE_FOLDERS, STEPS from database.database import delete_unconnected_steps_from, delete_all_app_development_data, update_app_status @@ -116,8 +116,9 @@ class Project: delete_all_app_development_data(self.args['app_id']) self.skip_steps = False elif self.skip_until_dev_step is not None: - should_overwrite_files = '' - while should_overwrite_files.lower() not in ['y', 'n']: + should_overwrite_files = None + while should_overwrite_files is None or should_overwrite_files.lower() not in AFFIRMATIVE_ANSWERS + NEGATIVE_ANSWERS: + print('yes/no', type='button') should_overwrite_files = styled_text( self, f'Do you want to overwrite the dev step {self.args["skip_until_dev_step"]} code with system changes? Type y/n', @@ -125,9 +126,9 @@ class Project: ) logger.info('should_overwrite_files: %s', should_overwrite_files) - if should_overwrite_files == 'n': + if should_overwrite_files in NEGATIVE_ANSWERS: break - elif should_overwrite_files == 'y': + elif should_overwrite_files in AFFIRMATIVE_ANSWERS: FileSnapshot.delete().where( FileSnapshot.app == self.app and FileSnapshot.development_step == self.skip_until_dev_step).execute() self.save_files_snapshot(self.skip_until_dev_step)