diff --git a/README.md b/README.md index 4127683..787b44d 100644 --- a/README.md +++ b/README.md @@ -275,7 +275,7 @@ There are three special template strings that `cfme` recognizes by default: - `<__GIT_DIFF__>` (required): Replaced with the output of `git diff --cached` (i.e. the staged changes) -- `<__RESPONSE__REQUIREMENTS__>` (required): Replaced with a list of requirements +- `<__RESPONSE_FORMAT_REQUIREMENTS__>` (required): Replaced with a list of requirements that dictates how the AI should format its response. This is essential so that `cfme` can parse the AI's response. Note that these requirements merely dictate the format of the response, they diff --git a/defaults/prompts/conventional-commits/default.md b/defaults/prompts/conventional-commits/default.md index a2ddc15..295f620 100644 --- a/defaults/prompts/conventional-commits/default.md +++ b/defaults/prompts/conventional-commits/default.md @@ -2,7 +2,10 @@ You are an expert at creating git commit messages according to the Conventional --- -<__RESPONSE_REQUIREMENTS__> +<__RESPONSE_FORMAT_REQUIREMENTS__> + +**Content Requirements:** + - ONLY and EXCLUSIVELY use the commit types listed in the following YAML file: ```yaml @@ -10,6 +13,7 @@ You are an expert at creating git commit messages according to the Conventional ``` - Make sure to follow Conventional Commits: + - A header is REQUIRED and must follow the format: `(): ` - type MUST match one of the types provided - scope is OPTIONAL - breaking changes can be indicated with ! in header or BREAKING CHANGE in footer diff --git a/spec/render_prompt_spec.sh b/spec/render_prompt_spec.sh index 885a3b4..865a6be 100644 --- a/spec/render_prompt_spec.sh +++ b/spec/render_prompt_spec.sh @@ -19,7 +19,7 @@ Describe 'render_prompt' It 'renders the prompt correctly with all variables replaced' local prompt_template="$(cat spec/samples/sample-prompt-complete.md)" declare -A vars_map - vars_map["<__RESPONSE_REQUIREMENTS__>"]="$(cat spec/samples/sample-response-requirements.md)" + vars_map["<__RESPONSE_FORMAT_REQUIREMENTS__>"]="$(cat spec/samples/sample-response-requirements.md)" vars_map["<__GIT_DIFF__>"]="SAMPLE_DIFF" vars_map["<__VAR1__>"]="VAL1" vars_map["<__VAR2__>"]="VAL2" @@ -32,7 +32,7 @@ Describe 'render_prompt' It 'renders the prompt correctly with empty instructions' local prompt_template="$(cat spec/samples/sample-prompt-complete.md)" declare -A vars_map - vars_map["<__RESPONSE_REQUIREMENTS__>"]="$(cat spec/samples/sample-response-requirements.md)" + vars_map["<__RESPONSE_FORMAT_REQUIREMENTS__>"]="$(cat spec/samples/sample-response-requirements.md)" vars_map["<__GIT_DIFF__>"]="SAMPLE_DIFF" vars_map["<__VAR1__>"]="VAL1" vars_map["<__VAR2__>"]="VAL2" diff --git a/spec/samples/sample-prompt-complete.md b/spec/samples/sample-prompt-complete.md index dbb8d7d..7e4775a 100644 --- a/spec/samples/sample-prompt-complete.md +++ b/spec/samples/sample-prompt-complete.md @@ -1,4 +1,4 @@ -<__RESPONSE_REQUIREMENTS__> +<__RESPONSE_FORMAT_REQUIREMENTS__> <__GIT_DIFF__> LINE_1 <__VAR1__> diff --git a/spec/samples/sample-prompt-missing-1.md b/spec/samples/sample-prompt-missing-1.md index d4eaad4..363d99e 100644 --- a/spec/samples/sample-prompt-missing-1.md +++ b/spec/samples/sample-prompt-missing-1.md @@ -1,4 +1,4 @@ -<__RESPONSE_REQUIREMENTS__> +<__RESPONSE_FORMAT_REQUIREMENTS__> <__GIT_DIFF__> LINE_1 LINE2 diff --git a/spec/samples/sample-prompt-missing-diff.md b/spec/samples/sample-prompt-missing-diff.md index 7c5b3b4..a5e79a8 100644 --- a/spec/samples/sample-prompt-missing-diff.md +++ b/spec/samples/sample-prompt-missing-diff.md @@ -1,4 +1,4 @@ -<__RESPONSE_REQUIREMENTS__> +<__RESPONSE_FORMAT_REQUIREMENTS__> LINE_1 <__VAR1__> LINE2 diff --git a/spec/samples/sample-rendered-prompt-with-instructions.md b/spec/samples/sample-rendered-prompt-with-instructions.md index 0d8ce08..52044e1 100644 --- a/spec/samples/sample-rendered-prompt-with-instructions.md +++ b/spec/samples/sample-rendered-prompt-with-instructions.md @@ -1,4 +1,4 @@ -**Requirements:** +**Response Format Requirements:** - Each commit message MUST include a 'header'. - Optionally include 'body' and 'footer', ONLY if a 'header' @@ -8,7 +8,7 @@ ```yaml commitMessages: - - header: "[optional scope]: " + - header: "" body: "" footer: "" score: diff --git a/spec/samples/sample-rendered-prompt-without-instructions.md b/spec/samples/sample-rendered-prompt-without-instructions.md index 08775ec..5acd42c 100644 --- a/spec/samples/sample-rendered-prompt-without-instructions.md +++ b/spec/samples/sample-rendered-prompt-without-instructions.md @@ -1,4 +1,4 @@ -**Requirements:** +**Response Format Requirements:** - Each commit message MUST include a 'header'. - Optionally include 'body' and 'footer', ONLY if a 'header' @@ -8,7 +8,7 @@ ```yaml commitMessages: - - header: "[optional scope]: " + - header: "" body: "" footer: "" score: diff --git a/spec/samples/sample-response-requirements.md b/spec/samples/sample-response-requirements.md index 18e8e65..b65f554 100644 --- a/spec/samples/sample-response-requirements.md +++ b/spec/samples/sample-response-requirements.md @@ -1,4 +1,4 @@ -**Requirements:** +**Response Format Requirements:** - Each commit message MUST include a 'header'. - Optionally include 'body' and 'footer', ONLY if a 'header' @@ -8,7 +8,7 @@ ```yaml commitMessages: - - header: "[optional scope]: " + - header: "" body: "" footer: "" score: diff --git a/spec/validate_vars_map_spec.sh b/spec/validate_vars_map_spec.sh index 7b036af..6b92686 100644 --- a/spec/validate_vars_map_spec.sh +++ b/spec/validate_vars_map_spec.sh @@ -17,7 +17,7 @@ Describe 'validate_vars_map' It 'validates variables successfully when everything matches' local -A map - map["<__RESPONSE_REQUIREMENTS__>"]="SAMPLE_REQUIREMENTS" + map["<__RESPONSE_FORMAT_REQUIREMENTS__>"]="SAMPLE_FORMAT_REQUIREMENTS" map["<__GIT_DIFF__>"]="SAMPLE_DIFF" map["<__VAR1__>"]="VAL1" map["<__VAR2__>"]="VAL2" @@ -31,7 +31,7 @@ Describe 'validate_vars_map' It 'fails when a prompt is missing a custom variable present in the map' local -A map - map["<__RESPONSE_REQUIREMENTS__>"]="SAMPLE_REQUIREMENTS" + map["<__RESPONSE_FORMAT_REQUIREMENTS__>"]="SAMPLE_FORMAT_REQUIREMENTS" map["<__GIT_DIFF__>"]="SAMPLE_DIFF" map["<__VAR1__>"]="VAL1" map["<__VAR2__>"]="VAL2" @@ -44,9 +44,9 @@ Describe 'validate_vars_map' The status should be failure End - It 'fails when a prompt is missing mandatory template string RESPONSE_REQUIREMENTS in the prompt' + It 'fails when a prompt is missing mandatory template string RESPONSE_FORMAT_REQUIREMENTS in the prompt' local -A map - map["<__RESPONSE_REQUIREMENTS__>"]="SAMPLE_REQUIREMENTS" + map["<__RESPONSE_FORMAT_REQUIREMENTS__>"]="SAMPLE_FORMAT_REQUIREMENTS" map["<__GIT_DIFF__>"]="SAMPLE_DIFF" map["<__VAR1__>"]="VAL1" map["<__VAR2__>"]="VAL2" @@ -55,13 +55,13 @@ Describe 'validate_vars_map' local variables_file_path="/path/to/variables.yaml" local prompt="$(cat spec/samples/sample-prompt-missing-requirements.md)" When call validate_vars_map map "$prompt" - The stderr should eq "Error: key '<__RESPONSE_REQUIREMENTS__>' is essential for cfme to function, but not present in the prompt." + The stderr should eq "Error: key '<__RESPONSE_FORMAT_REQUIREMENTS__>' is essential for cfme to function, but not present in the prompt." The status should be failure End It 'fails when a prompt is missing mandatory template string GIT_DIFF in the prompt' local -A map - map["<__RESPONSE_REQUIREMENTS__>"]="SAMPLE_REQUIREMENTS" + map["<__RESPONSE_FORMAT_REQUIREMENTS__>"]="SAMPLE_FORMAT_REQUIREMENTS" map["<__GIT_DIFF__>"]="SAMPLE_DIFF" map["<__VAR1__>"]="VAL1" map["<__VAR2__>"]="VAL2" @@ -76,7 +76,7 @@ Describe 'validate_vars_map' It 'fails when a map is missing a variable present in the prompt' local -A map - map["<__RESPONSE_REQUIREMENTS__>"]="SAMPLE_REQUIREMENTS" + map["<__RESPONSE_FORMAT_REQUIREMENTS__>"]="SAMPLE_FORMAT_REQUIREMENTS" map["<__GIT_DIFF__>"]="SAMPLE_DIFF" map["<__VAR2__>"]="VAL2" diff --git a/src/lib/load_vars_map.sh b/src/lib/load_vars_map.sh index bb3cf5c..e7c3c28 100644 --- a/src/lib/load_vars_map.sh +++ b/src/lib/load_vars_map.sh @@ -36,9 +36,9 @@ load_vars_map() { # Add defaults to the map referenced_map["<__GIT_DIFF__>"]="$(git diff --cached)" - referenced_map["<__RESPONSE_REQUIREMENTS__>"]="$( + referenced_map["<__RESPONSE_FORMAT_REQUIREMENTS__>"]="$( cat <<'EOF' -**Requirements:** +**Response Format Requirements:** - Each commit message MUST include a 'header'. - Optionally include 'body' and 'footer', ONLY if a 'header' @@ -48,7 +48,7 @@ load_vars_map() { ```yaml commitMessages: - - header: "[optional scope]: " + - header: "" body: "" footer: "" score: diff --git a/src/lib/validate_vars_map.sh b/src/lib/validate_vars_map.sh index bb2f4e3..e441186 100644 --- a/src/lib/validate_vars_map.sh +++ b/src/lib/validate_vars_map.sh @@ -17,7 +17,7 @@ function validate_vars_map() { continue fi if ! grep -q "$key" <<<"$prompt"; then - if [[ "$key" == "<__RESPONSE_REQUIREMENTS__>" || "$key" == "<__GIT_DIFF__>" ]]; then + if [[ "$key" == "<__RESPONSE_FORMAT_REQUIREMENTS__>" || "$key" == "<__GIT_DIFF__>" ]]; then # This key is mandatory echo "Error: key '$key' is essential for cfme to function, but not present in the prompt." >&2 return 1