From d729060a50e054b9cc4fd31c90459f811dc3bd9c Mon Sep 17 00:00:00 2001 From: Zvonimir Sabljic Date: Thu, 27 Jul 2023 14:30:32 +0200 Subject: [PATCH] Added prompts for implementing changes and task/step development --- .../development/implement_changes.prompt | 48 +++++++++++++++---- .../{task.prompt => task/breakdown.prompt} | 2 +- .../prompts/development/task/next_step.prompt | 18 +++++++ .../task/request_test_files.prompt | 2 + .../development/task/step/command_test.prompt | 2 + .../task/step/write_automated_test.prompt | 29 +++++++++++ .../development/task/step_check.prompt | 8 ++++ .../prompts/development/task/step_code.prompt | 29 +++++++++++ 8 files changed, 129 insertions(+), 9 deletions(-) rename euclid/prompts/development/{task.prompt => task/breakdown.prompt} (62%) create mode 100644 euclid/prompts/development/task/next_step.prompt create mode 100644 euclid/prompts/development/task/request_test_files.prompt create mode 100644 euclid/prompts/development/task/step/command_test.prompt create mode 100644 euclid/prompts/development/task/step/write_automated_test.prompt create mode 100644 euclid/prompts/development/task/step_check.prompt create mode 100644 euclid/prompts/development/task/step_code.prompt diff --git a/euclid/prompts/development/implement_changes.prompt b/euclid/prompts/development/implement_changes.prompt index e2e597b7..116dd14d 100644 --- a/euclid/prompts/development/implement_changes.prompt +++ b/euclid/prompts/development/implement_changes.prompt @@ -1,18 +1,50 @@ -I will show you contents from a file {{ file_name }} and the instructions of what changes need to be made to that file. The instructions will be in the following format: +I have development instructions that I need you to reformat into a JSON array that will be executed with a code. The instructions will be in the following format: -- INSTRUCTIONS -- {all_the_instructions} -- END OF INSTRUCTIONS -- -I want you to modify the file contents and respond with the entire file along with the modifications. If 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. - -Here is how the file `{{ file_name }}` looks now: -```javascript -{{ file_content }} +The instructions might include changes to files or commands that need to be run. I need you to read the instructions and respond with a JSON array that show each instruction in a JSON object format. In case a command needs to be run, the JSON object needs to look like this: +```json +{ + "type": "command", + "command": "{command_that_needs_to_be_run}" +} ``` +In case a file needs to be modified, I want you to modify the file and show me how it should look like after the modifications. Here is how the JSON object should look like in that case: +```json +{ + "type": "file_change", + "file_content": "{file_content_after_modifications}" +} +``` + +Within the new 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. + +{% if len(files) > 0 %} +Here is how files look now: +{% for file in files %} +**{{ file.name }}** +```{{ file.language }} +{{ file.content }} +``` + +{% endfor %} +{% endif%} + Here are the instructions for changes that need to be made: -- INSTRUCTIONS -- -{{ instructions }} +The existing test for the root ('/') route seems sufficient for this step. It accurately checks the intended functionality - the server responds with a status code of 200 and HTML content type when a GET request is made to the root route. + +Therefore, no changes are required in the file `tests/server.test.js`. + +To verify the changes from this step, we can run this test using the command `npm test`. + +COMMAND: npm test + +FILES_CHANGED: [] + +NEW_FILES: [] -- END OF INSTRUCTIONS -- -Do not write anything else but only the file contents. Keep in mind that the changes might be related to multiple files. You don't need to think about any other changes except for the changes in `index.js` \ No newline at end of file +Do not write anything else but the JSON array. Make sure that the JSON array preserves the order of instructions. For example, if a file needs to be modified, then a command needs to be run, and then the file should be modified again - then, the JSON array should have 3 items where the first item should be the file with the first modifications, the second item should be the command that needs to be run and the third item should be the file with the second modifications. \ No newline at end of file diff --git a/euclid/prompts/development/task.prompt b/euclid/prompts/development/task/breakdown.prompt similarity index 62% rename from euclid/prompts/development/task.prompt rename to euclid/prompts/development/task/breakdown.prompt index a1823039..6a65fa37 100644 --- a/euclid/prompts/development/task.prompt +++ b/euclid/prompts/development/task/breakdown.prompt @@ -38,4 +38,4 @@ Ok, now that you know what is Euclid about and what technologies need to be used {{ task }} -List out all commands that need to be run and all the code that needs to be written to fulfil this task. Keep in mind that you also need to write test (or tests) that will programmatically verify that your task is complete. \ No newline at end of file +First, just make a list of steps we need to do to fulfill this task. It should be in a JSON array. Every step must NOT contain both a command that needs to be run and the code that needs to be changed. It can be either command (or multiple commands) that need to be run or a change in the code. Each step must start with a keyword `COMMAND` in case the step consists of commands that need to be run or `CODE_CHANGE` in case it consists of changes in the code. After the keyword, write a description of what will be done in that step. Do not write what needs to be done for each step but only list them in an array. Also, keep in mind that you also need to write test (or tests) that will programmatically verify that your task is complete. \ No newline at end of file diff --git a/euclid/prompts/development/task/next_step.prompt b/euclid/prompts/development/task/next_step.prompt new file mode 100644 index 00000000..36affb5f --- /dev/null +++ b/euclid/prompts/development/task/next_step.prompt @@ -0,0 +1,18 @@ +{% if is_first_step %} +So far, steps {{ finished_steps }} are finished so let's do +{% else %} +Let's start with the +{% endif %} + step #{{ i }} - `{{ step_description }}`. +{% if is_command_step %} +Write all commands that need to be run to fulfill this step. Your response needs to have the following format: +COMMAND: {command_that_needs_to_be_run} +{% elif is_code_change_step %} +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: +``` +{{ file_tree }} +``` + +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 diff --git a/euclid/prompts/development/task/request_test_files.prompt b/euclid/prompts/development/task/request_test_files.prompt new file mode 100644 index 00000000..905ce754 --- /dev/null +++ b/euclid/prompts/development/task/request_test_files.prompt @@ -0,0 +1,2 @@ +Ok, now, I will show you the list of all files with automated tests that are written so far and I want you to tell me which automated tests do you want to see so that you can propriatelly modify tests or create new ones. +{{ testing_files_tree }} \ No newline at end of file diff --git a/euclid/prompts/development/task/step/command_test.prompt b/euclid/prompts/development/task/step/command_test.prompt new file mode 100644 index 00000000..cd2737a4 --- /dev/null +++ b/euclid/prompts/development/task/step/command_test.prompt @@ -0,0 +1,2 @@ +Write a list of commands that should be ran that will tell you if the implementation was successful. Write them in a JSON array where each item is a string with the following format: +COMMAND: {command_that_needs_to_be_ran} \ No newline at end of file diff --git a/euclid/prompts/development/task/step/write_automated_test.prompt b/euclid/prompts/development/task/step/write_automated_test.prompt new file mode 100644 index 00000000..0fb6b873 --- /dev/null +++ b/euclid/prompts/development/task/step/write_automated_test.prompt @@ -0,0 +1,29 @@ +{{ if len(files) > 0}} +Here are the requested files: +{% for file in files %} +**{{ file.name }}** +```{{ file.language }} +{{ file.content }} +``` + +{% endfor %} +{% else %} +Currently, no tests are written. + +{% endif %} +Now, start with the implementation of the automated test (or tests). + +If you need a CLI command to be ran, write it like this: +COMMAND: {command_that_needs_to_be_ran} + +At the end of your response, specify file names of all files that should be changed based on your instructions in the following format: +FILES_CHANGED: ["file_name_1", "file_name_2", ..., "file_name_n"] + +If you need to create a new file, at the end of the file write an array of new files that need to be created in the following format: +NEW_FILES: {new_files_array} + +`new_files_array` is a JSON array where each item in the array needs to be a JSON object with these keys: +`name` - file name with the full path relative to the root of the project +`description` - a thorough description of what this file is meant to contain so that we can know in the future if any new code needs to be put in that file. Do not describe what is currently implemented in this file but rather a description so that anyone who looks at this description knows if they should put the new code in it or not. + +You can write code in multiple files and keep in mind that you also need to write test (or tests) that will programmatically verify that your task is complete. If you need to run any commands, you can do that now but make sure that the command is not contained in any other steps outlined above. \ No newline at end of file diff --git a/euclid/prompts/development/task/step_check.prompt b/euclid/prompts/development/task/step_check.prompt new file mode 100644 index 00000000..e106194d --- /dev/null +++ b/euclid/prompts/development/task/step_check.prompt @@ -0,0 +1,8 @@ +Now, we need to verify if this change was successfully implemented. We can do that in 3 ways: +1. By writing an automated test or by running a previously written test - this is the preferred way since we can then test if this functionality works in the future. You write automated tests in Jest and you always try finding a way to test a functionality with an automated test. Even if changes seem visual or UI-based, try to find a way to validate them using an automated test, such as verifying HTTP responses or elements rendered on the page. If you think we can write an automated test, start the response with `AUTOMATED_TEST` + +2. By running a command - this is good for when an automated test is an overkill. For example, if we installed a new package or changed some configuration. If you just want to run a command (or multiple commands), respond with `COMMAND_TEST: {explanation on how to test this with a command}`. Keep in mind that in this case, there shouldn't be any human intervention needed - I will run the commands you will give me and show you the CLI output and from that, you should be able to determine if the test passed or failed. + +3. By requesting that a human checks if everything works as expected - this is the last option that we want to avoid but if we can't test the functionality programmatically, we should ask a human to check if it works as expected. For example, if something was visually changed in the UI. If you need a human to check the functionality, start the response with `MANUAL_TEST`. + +Ok, now, tell me how can we verify if this change was successful and respond only with a keyword for a type of test. \ No newline at end of file diff --git a/euclid/prompts/development/task/step_code.prompt b/euclid/prompts/development/task/step_code.prompt new file mode 100644 index 00000000..17726a33 --- /dev/null +++ b/euclid/prompts/development/task/step_code.prompt @@ -0,0 +1,29 @@ +Here are the requested files: +{% for file in files %} +**{{ file.name }}** +```{{ file.language }} +{{ file.content }} +``` + +{% endfor %} + +Now, start with the implementation of the current step. + +If you need a CLI command to be ran, write it like this: +COMMAND: {command_that_needs_to_be_ran} + +At the end of your response, specify file names of all files that should be changed based on your instructions in the following format: +FILES_CHANGED: ["file_name_1", "file_name_2", ..., "file_name_n"] + +If you need to create a new file, at the end of the file write an array of new files that need to be created in the following format: +NEW_FILES: {new_files_array} + +`new_files_array` is a JSON array where each item in the array needs to be a JSON object with these keys: +`name` - file name with the full path relative to the root of the project +`description` - a thorough description of what this file is meant to contain so that we can know in the future if any new code needs to be put in that file. Do not describe what is currently implemented in this file but rather a description so that anyone who looks at this description knows if they should put the new code in it or not. + +You can write code in multiple files and keep in mind that you also need to write test (or tests) that will programmatically verify that your task is complete. Remember, automated tests should NEVER open any of the development files (like .js, .py, .json, etc.) and test if something is written inside because this makes the tests brittle and tightly coupled to the code implementation. Automated tests should aim to verify the behavior and functionality of the code, not its internal structure or implementation. + +If you need to run any commands, you can do that now but make sure that the command is not contained in any other steps outlined above. + +If there is nothing needed to be done, respond with only `DONE` and nothing else. \ No newline at end of file