Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 40 additions & 30 deletions doc/ai4dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,53 @@ Vibe Coding
-----------
1. In a Linux or macOS shell, set your present working directory to Matcha's
[scripts](../../scripts) directory. Enter the command
`./create-single-source-file-programs.sh`, which creates a copy of the Matcha
test suite and supporting software stack all concatenated into one file:
test-suite.F90 in [build/single-file-programs](../../build/single-file-programs).
2. Compile and execute test-suite.F90 to check that the output reports that
`./create-single-source-file-programs.sh`, which creates a copy of the
Matcha test suite and supporting software stack all concatenated into one
file in the following path relative to the project's root directory:
"./build/single-file-programs/test-suite.F90".
3. Compile and execute test-suite.F90 to check that the output reports that
all tests pass. For example, enter
```bash
gfortran -fcoarray=single -o test-suite test-suite.F90
./test-suite
```
3. Use the contents of [vibe-coding/README.md](./vibe-coding/README.md) as your
4. Use the contents of [vibe-coding/README.md](./vibe-coding/README.md) as your
prompt to a large language model (LLM).
4. In test-suite.F90, replace the lines beginning and ending with
5. Use an editor to edit the test-suite.F90 lines beginning and ending with
`module procedure laplacian` and `end procedure laplacian`, respectively,
with the LLM's response.
5. Compile test-suite.F90 as in step 2 again.
6. If test-suite.F90 doesn't compile or if running the compiled program does not
produce output indicating that all tests pass, then start over start over at
step 1 but when you reach step 3, append the following to the aforementioned
prompt:
b. The previous iteration's compile-time or run-time error messages,
a. "Please fix the above errors generated by the following response to my
previous prompt:",
c. The LLM-generated code from the previous iteration.
replacing those lines with the LLM's response.
6. Compile test-suite.F90 as in step 2 again.
7. If the test-suite program doesn't compile or if running the compiled
program doesn't produce output indicating that all tests pass, then start
over at step 1 but when you reach step 3, edit the prompt as follows:
* Append the previous iteration's compile-time error message(s) or run-time
error message(s) or test output.
* Append the text "Please fix the above errors that were generated by
compiling the following candidate solution to this prompt:". If the
program compiled but runtime errors resulted, replace "compiling" with
"running" in the previous sentence. If the program ran without errors,
but tests failed replace "compiling" with "running" and replace "errors"
with "test failures".
* Append LLM-generated code from the previous iteration.

Idiomatic Vibe Coding
---------------------
Follow the [vibe coding](#vibe-coding) steps except as described below.

* In your first prompt, attach the file test-suite.F90 with the lines
from `module procedure laplacian` to `end procedure` removed.
Rename the file test-suite.txt if the LLM rejects .F90 file extensions.
Add the text "Inserting your response into subdmodule subdomain_s,
and compiling and running the attached program must generate output
indicating that all tests pass."
* If inserting the LLM's repsonse into subdomain_s leads to compile-time or
runtime errors or if any tests fail, attach the file containing the program
with the LLM's response inserted. Add the text "Please fix the attached
program, which contains a candidate solution to the above prompt. The candidate
solution generates the following messages:" Insert any compile-time or
runtime error messages or test output.
Follow the [vibe coding](#vibe-coding) steps except as described below:
* In your first prompt, attach test-suite.F90 with the lines from
`module procedure laplacian` to `end procedure laplacian` removed. If the
LLM rejects ".F90" file extensions, change the name to "test-suite.txt".
Appened following to the prompt: "Inserting a correct response to this
prompt into the subdmodule subdomain_s and then compiling and running the
attached program must generate output indicating that all tests pass."
* In subsequent iterations, if replacing the laplacian procedure with the
LLM's most recent response leads to compile-time or runtime errors or if any
tests fail, update the test-suite program, replacing laplacian with the most
recent LLM response. Attach the updated program to each prompt.
* In the second bullet of vibe coding step 7, replace the suggested text wit
"Please fix the above errors that were generated by compiling the attached
program, which contains an incorrect laplacian procedure." If the program
compiled but runtime errors resulted, replace "compiling" with "running" in
the previous sentence. If the program ran without errors, but tests failed,
replace "compiling" with "running" and replace "errors" with "test failures".
* Skip the third bullet in vibe coding step 7 because with idiomatic vibe
coding, the complete software stack is contained in an attachment.
Loading