@@ -110,10 +110,17 @@ replace_tokens() {
110110# Exports GIV_TOKEN_SUMMARY (and any of PROJECT_TITLE, VERSION, EXAMPLE, RULES
111111# if passed) then runs replace_tokens on the template.
112112build_prompt () {
113- project_title=$( parse_project_title)
114- version=" ${GIV_TOKEN_VERSION:- } "
115- example=" ${GIV_TOKEN_EXAMPLE:- } "
116- rules=" ${GIV_TOKEN_RULES:- } "
113+ project_title=" $( parse_project_title) "
114+
115+ version=" ${output_version:- ${GIV_TOKEN_VERSION:- } } "
116+ if [ -z " ${version} " ] || [ " ${version} " = " auto" ]; then
117+ print_debug " No version set or version is 'auto', trying to find it from version file"
118+ # Try to find the version file and extract the version
119+ version_file=" $( find_version_file) "
120+ version=" $( get_version_info --current " ${version_file:- } " ) "
121+ fi
122+ example=" "
123+ rules=" "
117124 # parse flags
118125 while [ $# -gt 2 ]; do
119126 case " $1 " in
@@ -156,13 +163,19 @@ build_prompt() {
156163 # export our tokens
157164 export GIV_TOKEN_SUMMARY
158165 GIV_TOKEN_SUMMARY=$( cat " ${diff_file} " )
159- [ -n " $project_title " ] && export GIV_TOKEN_PROJECT_TITLE=" $project_title "
160- [ -n " $version " ] && export GIV_TOKEN_VERSION=" $version "
161- [ -n " $example " ] && export GIV_TOKEN_EXAMPLE=" $example "
162- [ -n " $rules " ] && export GIV_TOKEN_RULES=" $rules "
163166
164- # run the replacement
165- replace_tokens < " $prompt_template "
167+ export GIV_TOKEN_PROJECT_TITLE=" ${project_title:- ${GIV_TOKEN_PROJECT_TITLE} } "
168+ export GIV_TOKEN_VERSION=" ${version:- ${GIV_TOKEN_VERSION} } "
169+ export GIV_TOKEN_EXAMPLE=" ${example:- ${GIV_TOKEN_EXAMPLE} } "
170+ export GIV_TOKEN_RULES=" ${rules:- ${GIV_TOKEN_RULES} } "
171+
172+ # Append the extra instructions to the prompt content before passing to replace_tokens
173+ {
174+ cat " ${prompt_template} "
175+ printf ' \nOutput just the final content—no extra commentary or code fencing. '
176+ printf ' Use only information contained in this prompt and the summaries provided above.'
177+ } | replace_tokens
178+ return
166179}
167180
168181# Locate the project from the codebase. Looks for common project files
0 commit comments