Repository: Pythagora-io/gpt-pilot
File: pilot/helpers/agents/Developer.py (Python)

Code before:
        response = ask_user(self.project, execute_question)
        if response.lower() in NEGATIVE_ANSWERS + ['skip task']:
            # remove task from development plan if it is being skipped
            self.project.development_plan = [
                element for element in self.project.development_plan
                if element['description'] != task['description']
            ]
            if task_source == 'app':
                edit_development_plan(self.project.args['app_id'], {'development_plan': self.project.development_plan})
            else:
                edit_feature_plan(self.project.args['app_id'], {'llm_response': {'text': json.dumps({'plan': self.project.development_plan})}})
            return False
        elif response.lower() == 'edit task':
            edit_question = 'Write full edited description of the task here:'
            if self.project.check_ipc():
                print(edit_question, type='ipc')
                print(task['description'], type='inputPrefill')
            edited_task = ask_user(self.project, edit_question)
            task['description'] = edited_task
            if task_source == 'app':
                edit_development_plan(self.project.args['app_id'], {'development_plan': self.project.development_plan})
            else:
                edit_feature_plan(self.project.args['app_id'], {'llm_response': {'text': json.dumps({'plan': self.project.development_plan})}})

        return True

    def step_delete_file(self, convo, step, i, test_after_code_changes):
        """
        Delete a file from the project.

        This doesn't delete the files yet, but measures how often LLM
        neads to clean up (delete) entire files.
        """
        data = step['delete_file']
        trace_code_event(
            "delete-file-stub",
            data,
        )
        return {"success": True}


    def step_save_file(self, convo, step, i, test_after_code_changes):
        # Backwards
        if 'modify_file' in step:
            step['save_file'] = step.pop('modify_file')
        elif 'code_change' in step:
            step['save_file'] = step.pop('code_change')

        step['save_file']['name'] = os.path.basename(step['save_file']['path'])
        data = step['save_file']
        code_monkey = CodeMonkey(self.project)

Review comment (suggestion):
You just know some users are going to not write anything and this may mess up everything. My suggestion is to have a "cancel" button here and treat "cancel" or empty string as user deciding not to change the task, and do nothing (just execute it as is).

Code after:
        response = ask_user(self.project, execute_question)
        if response.lower() in NEGATIVE_ANSWERS + ['skip task']:
            # remove task from development plan if it is being skipped
            self.project.development_plan = [
                element for element in self.project.development_plan
                if element['description'] != task['description']
            ]
            if task_source == 'app':
                db_task_skip = edit_development_plan(self.project.args['app_id'], {'development_plan': self.project.development_plan})
            else:
                db_task_skip = edit_feature_plan(self.project.args['app_id'], {'llm_response': {'text': json.dumps({'plan': self.project.development_plan})}})

            if db_task_skip:
                print('Successfully skipped task.', category='Pythagora')
            return False
        elif response.lower() == 'edit task':
            edit_question = 'Write full edited description of the task here:'
            if self.project.check_ipc():
                print('continue/cancel', type='button')
                print(edit_question, type='ipc')
                print(task['description'], type='inputPrefill')
            edited_task = ask_user(self.project, edit_question)
            if edited_task.lower() in NEGATIVE_ANSWERS + ['', 'continue']:
                return True

            task['description'] = edited_task
            if task_source == 'app':
                db_task_edit = edit_development_plan(self.project.args['app_id'], {'development_plan': self.project.development_plan})
            else:
                db_task_edit = edit_feature_plan(self.project.args['app_id'], {'llm_response': {'text': json.dumps({'plan': self.project.development_plan})}})

            if db_task_edit:
                print('Successfully edited task.', category='Pythagora')

        return True

    def step_delete_file(self, convo, step, i, test_after_code_changes):
        """
        Delete a file from the project.

        This doesn't delete the files yet, but measures how often LLM
        neads to clean up (delete) entire files.
        """
        data = step['delete_file']
        trace_code_event(
            "delete-file-stub",
            data,
        )
        return {"success": True}