Skip to content

Commit 9fcdb21

Browse files
committed
refactor: improve prompt handling in git-context and apply-md
Enhance prompt file handling by: - Consolidating prompt files to a standard naming convention - Adding optional conventional commit guidance - Improving handling of prompt files in different output formats
1 parent 9b627d9 commit 9fcdb21

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

apply-md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,6 @@ if [ "$VERBOSE" = true ]; then
224224
if [ "$DRY_RUN" = true ]; then
225225
echo "Running in DRY RUN mode (no changes will be applied)"
226226
fi
227-
if [ -f "prompts/apply_prompt.txt" ]; then
228-
echo "Applying with prompt:"
229-
cat "prompts/apply_prompt.txt"
230-
echo ""
231-
fi
232227
fi
233228

234229
extract_blocks

git-context

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -378,39 +378,36 @@ if [ $RECENT_COMMITS -gt 0 ]; then
378378
fi
379379

380380
# Include default prompt if available
381-
if [ -f "prompts/git-context_prompt.txt" ]; then
381+
if [ -f "prompts/commit_prompt.txt" ]; then
382382
case $FORMAT in
383383
md)
384384
echo "## Commit Message Guidance"
385385
echo ""
386-
cat "prompts/git-context_prompt.txt"
387-
if [ "$CONVENTIONAL" = true ]; then
386+
cat "prompts/commit_prompt.txt"
387+
if [ "$CONVENTIONAL" = true ] && [ -f "prompts/conventional_commit.txt" ]; then
388388
echo ""
389-
echo "Please use conventional commit format: type(scope): description"
390-
echo "- Types: feat, fix, docs, style, refactor, perf, test, chore"
391-
echo "- Example: \"feat(button): add disabled state handling\""
389+
cat "prompts/conventional_commit.txt"
392390
fi
393391
echo ""
394392
;;
395393
json)
396394
echo ","
397395
echo " \"commit_guidance\": {"
398-
guidance_json=$(cat "prompts/git-context_prompt.txt" | sed 's/"/\\"/g' | sed 's/\\n/\\\\n/g')
396+
guidance_json=$(cat "prompts/commit_prompt.txt" | sed 's/"/\\"/g' | sed 's/\\n/\\\\n/g')
399397
echo " \"content\": \"$guidance_json\""
400-
if [ "$CONVENTIONAL" = true ]; then
401-
echo " \"conventional\": true"
398+
if [ "$CONVENTIONAL" = true ] && [ -f "prompts/conventional_commit.txt" ]; then
399+
conventional_json=$(cat "prompts/conventional_commit.txt" | sed 's/"/\\"/g' | sed 's/\\n/\\\\n/g')
400+
echo " ,\"conventional\": \"$conventional_json\""
402401
fi
403402
echo " }"
404403
;;
405404
text)
406405
echo "COMMIT MESSAGE GUIDANCE"
407406
echo "----------------------"
408-
cat "prompts/git-context_prompt.txt"
409-
if [ "$CONVENTIONAL" = true ]; then
407+
cat "prompts/commit_prompt.txt"
408+
if [ "$CONVENTIONAL" = true ] && [ -f "prompts/conventional_commit.txt" ]; then
410409
echo ""
411-
echo "Please use conventional commit format: type(scope): description"
412-
echo "- Types: feat, fix, docs, style, refactor, perf, test, chore"
413-
echo "- Example: \"feat(button): add disabled state handling\""
410+
cat "prompts/conventional_commit.txt"
414411
fi
415412
echo ""
416413
;;

0 commit comments

Comments
 (0)