feat: Add BYO (Bring Your Own) prompt instruction feature #47
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR introduces a new
--byo(Bring Your Own) flag that allows users to provide custom prompt instructions from a file, enabling teams and individuals to define their own commit message rules and conventions.Motivation
While diffsense provides excellent built-in prompt styles (
default,verbose,minimal), different teams have unique commit message conventions, style guides, and requirements. This feature allows users to:Changes
1. Updated
resources/diffsense.shNew
--byoflag support--byo <file>and--byo=<file>syntax~to home directory for convenienceNew
load_byo_prompt()functionUpdated
parse_args()functionwhileloop withshiftfor robust argument parsing--helphandling within the parser--byo "file.md" --gpt --verbose)Enhanced prompt composition in
diffsense()main functionUpdated help text
--byo <file>option2. Added
cstm_cmt_msg_rules.mdA comprehensive example template that users can use as a starting point for their own custom rules:
This template is intentionally concise (~250 words) to leave plenty of room for diff content while demonstrating best practices.
Technical Details
Character Budget Management
The existing
truncate_diff()function already accounts for prompt length using${#prompt}. This PR enhances this by:Prompt Combination Strategy
When
--byois used:This approach:
Usage Examples
Testing Recommendations
--byowith various file paths~/file.mdworks correctlyBreaking Changes
None. This is a purely additive feature. All existing functionality remains unchanged.
Future Enhancements
Potential improvements for future PRs:
Checklist
--byoflag supportload_byo_prompt()helper functionwhileloop