|
| 1 | +# Prompts for Copilot Edits Agent |
| 2 | + |
| 3 | +Most of the project source code was generated by the Copilot Edits Agent mode, with a except in the `scripts` directory |
| 4 | +where AI didn't perform well in generating CMD batch script under Windows environment. |
| 5 | + |
| 6 | +During the process, we found that the Agent mode was capable to fulfill small scope tasks (maybe the scope of a typical |
| 7 | +pull request), but not that well-performed on more complex scope. In that case, we may need more manual care, reverts, |
| 8 | +fine-tune the prompts, etc., which results in longer time consumed. So, during the project authoring, we manually split |
| 9 | +the goal into smaller pieces, and run each piece with a concrete prompt in the Agent mode. |
| 10 | + |
| 11 | +Here is the list of some prompts used during the project creation, for your reference. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +```markdown |
| 16 | +I have a blank Java project created from Spring Initializer, with the spring-web and thymeleaf dependency. |
| 17 | + |
| 18 | +I want to build a web based AWS S3 client, that allows me to upload pictures to S3 buckets, list all the pictures, view a given picture, and delete pictures from S3 buckets. |
| 19 | + |
| 20 | +Please generate the frontend UI using Thymeleaf templates and the backend web server that actually talks to S3 buckets when it receives the request from the frontend. |
| 21 | +``` |
| 22 | +--- |
| 23 | + |
| 24 | +``` |
| 25 | +I don't have an AWS S3 account. I want to try all the application logic locally except for the actual communication with AWS S3. |
| 26 | +
|
| 27 | +Extract the APIs of `S3Service` to a interface, generate another service implementation of this interface based on local files. Use profiles `dev` to register this service instead of the actual S3 one, so that I can test the app with profile `dev`. |
| 28 | +``` |
| 29 | +--- |
| 30 | + |
| 31 | +```markdown |
| 32 | +The View button current opens a new window for the image, which will directly download the image rather than view the image in the browser. |
| 33 | + |
| 34 | +Generate a View page, to allow the user to view the big picture in the web view. |
| 35 | +``` |
| 36 | +--- |
| 37 | + |
| 38 | +``` |
| 39 | +The current upload use the traditional upload UI. Please add the drag and drop support to allow the customer to upload a file by droping the file to a control in the page. |
| 40 | +``` |
| 41 | +--- |
| 42 | + |
| 43 | +``` |
| 44 | +I need to add another app to the project, which connects to the same storage as the current project. It will do some background processing for the files uploaded. |
| 45 | +
|
| 46 | +1. Convert the current project to a submodule `web` under the folder `web` |
| 47 | +2. Add a top level parent pom.xml that includes the `web` folder as a submodule |
| 48 | +3. Create another module `worker`, with dummy code that simply get the file lists and log to console |
| 49 | +``` |
| 50 | +--- |
| 51 | + |
| 52 | +``` |
| 53 | +The top level project should only be an index to submodule, without any code logic. Move the current project src to the web submodule. |
| 54 | +``` |
| 55 | +--- |
| 56 | + |
| 57 | +``` |
| 58 | +I see the following warning when I compile the top level parent project, please help to fix them. |
| 59 | +
|
| 60 | +[WARNING] Some problems were encountered while building the effective model for com.microsoft.migration:assets-manager-web:jar:0.0.1-SNAPSHOT |
| 61 | +[WARNING] 'build.plugins.plugin.version' for org.springframework.boot:spring-boot-maven-plugin is missing. @ line 54, column 21 |
| 62 | +[WARNING] |
| 63 | +[WARNING] Some problems were encountered while building the effective model for com.microsoft.migration:assets-manager-worker:jar:0.0.1-SNAPSHOT |
| 64 | +[WARNING] 'build.plugins.plugin.version' for org.springframework.boot:spring-boot-maven-plugin is missing. @ line 39, column 21 |
| 65 | +[WARNING] |
| 66 | +[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. |
| 67 | +[WARNING] |
| 68 | +[WARNING] For this reason, future Maven versions might no longer support building such malformed projects. |
| 69 | +``` |
| 70 | + |
| 71 | +This didn't work well. It will add the version to the plugin explicitly. Refined to the following: |
| 72 | + |
| 73 | +``` |
| 74 | +I see the following warning when I compile the top level parent project, please help to fix them. Will it resolve the problem if you update the top level pom.xml to use spring boot as parent, rather than import it in dependencyManagement? |
| 75 | +
|
| 76 | +[WARNING] Some problems were encountered while building the effective model for com.microsoft.migration:assets-manager-web:jar:0.0.1-SNAPSHOT [WARNING] 'build.plugins.plugin.version' for org.springframework.boot:spring-boot-maven-plugin is missing. @ line 54, column 21 [WARNING] [WARNING] Some problems were encountered while building the effective model for com.microsoft.migration:assets-manager-worker:jar:0.0.1-SNAPSHOT [WARNING] 'build.plugins.plugin.version' for org.springframework.boot:spring-boot-maven-plugin is missing. @ line 39, column 21 [WARNING] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. [WARNING] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects. |
| 77 | +``` |
| 78 | +--- |
| 79 | + |
| 80 | +``` |
| 81 | +I need to use a queue in RabbitMQ to connect the web module and the worker module. When an image is uploaded from the web project, a message containing the image properties is sent to the queue. The worker listen to the queue, and when it receives the message properties from the queue, it creates a thumbnail image with width and height no more than 150px, the aspect ratio need to be the same as the original image. The thumbnail is then stored in the same location, local dir or a separate bucket, with a `_thumbnail` suffix in the file name. |
| 82 | +``` |
| 83 | + |
| 84 | +Copilot Agent incorrectly adds the dependency version configuration for AMQP in the parent pom's dependencyManagement section, which leads to compilation error. I manually removed it. |
| 85 | + |
| 86 | +--- |
| 87 | + |
| 88 | +``` |
| 89 | +Just like the web project that supports falling back to local storage when running in `dev` profile, the `FileProcessingService` should also be aware of local storage. Extract the key methods in `FileProcessingService` to a interface, and add another service implementation that processes the files from the local file storage, when the dev profile is activated. Create abstract parent class if necessary to ensure reusing common logics for different service implementation. Ensure the message in the message queue has enough information to identify if the file is from prod S3 or dev local storage. |
| 90 | +``` |
| 91 | +--- |
| 92 | +``` |
| 93 | +Is `FileProcessingService` still needed, given in previous step it was refactored to two different implementation: s3 for prod and local file for dev? |
| 94 | +``` |
| 95 | +--- |
| 96 | + |
| 97 | +``` |
| 98 | +Add Spring Boot data JPA support to the web module. Sync the uploaded image's detailed metadata (without the image content) to the PostgreSQL database. And update or delete the metadata according to the client operation on the given image. |
| 99 | +``` |
| 100 | +--- |
| 101 | + |
| 102 | +``` |
| 103 | +Add a cmd script for windows and a bash script for Linux in the scripts directory of the parent project root. The two scripts need to have identical flow: |
| 104 | +
|
| 105 | +1. Spawn a PostgreSQL server with Docker |
| 106 | +2. Spawn a RabbitMQ server with Docker |
| 107 | +3. Start the web module in `dev` profile, and ensure the configuration for the above PostgreSQL and RabbitMQ is passed to the app through environment variables |
| 108 | +4. Start the worker module in `dev` profile, also properly inject the PostgreSQL and RabbitMQ configurations. |
| 109 | +
|
| 110 | +The logging output of the two apps needs to be redirected into two separate log files. |
| 111 | +``` |
| 112 | +--- |
| 113 | + |
| 114 | +``` |
| 115 | +update the scripts so that they can run without error like "cannot find project" regardless of what the current directory is |
| 116 | +``` |
| 117 | +--- |
| 118 | + |
| 119 | +``` |
| 120 | +I see the following error when run start.cmd: |
| 121 | +
|
| 122 | +'mvnw' is not recognized as an internal or external command, operable program or batch file. |
| 123 | +
|
| 124 | +The wrapper script locates in project root, and needs to use absolute path to invoke. |
| 125 | +
|
| 126 | +Same fix required for start.sh |
| 127 | +``` |
| 128 | +--- |
| 129 | + |
| 130 | +``` |
| 131 | +The following error raied when I run stop.cmd |
| 132 | +
|
| 133 | +'wmic' is not recognized as an internal or external command, operable program or batch file. |
| 134 | +``` |
| 135 | +--- |
| 136 | + |
| 137 | +``` |
| 138 | +ERROR: The search filter cannot be recognized. |
| 139 | +``` |
| 140 | +--- |
| 141 | + |
| 142 | +``` |
| 143 | +Update the web and the worker Spring Boot app to use `ApplicationPidFileWriter` so that they will write down the process PID to a file. Update the start.cmd script to pass in the desired pid file path to the pid file writer in the app, and update the stop.cmd script so that it will read the PID from that file and kill the process. |
| 144 | +
|
| 145 | +the `start /B cmd /c` command needs to be updated because currently there seems to be some problem with the double quote escaping in the long command. |
| 146 | +``` |
| 147 | +--- |
| 148 | + |
| 149 | +``` |
| 150 | +I don't have ImageMagik installed, so I cannot use it to generate thumbnail. Please replace it with some pure Java implementation so that I don't have a dependency to external ImageMagik. |
| 151 | +``` |
| 152 | +--- |
| 153 | + |
| 154 | +``` |
| 155 | +Currently, the RabbitListener will remove the message from the queue regardless whether the message processing is successful or not. Please update the logic so that only when the client successfully processes the message (i.e., the thumbnail is generated correctly) then the message is removed from the queue. Otherwise, the message is available for retry. |
| 156 | +
|
| 157 | +To avoid indefinite retry, when the previous processing failed, the message should only be rerouted after some delay, say 1 minute. |
| 158 | +``` |
0 commit comments