--- description: Generate complete commit message orchestrating subject, body, and footer --- # Operation: Complete Message Generate a complete, well-formatted commit message by orchestrating subject generation, body composition, and footer creation. ## Parameters from $ARGUMENTS **Required:** - `type:` - Commit type (feat, fix, docs, etc.) **Optional:** - `scope:` - Affected module/component - `description:` - Brief description (if not provided, derived from files) - `files:` - Comma-separated file paths for context - `changes:` - Comma-separated list of changes - `why:` - Explanation of why changes were made - `breaking:` - Breaking change description - `closes:` - Issue numbers to close - `fixes:` - Issue numbers to fix - `include_body:` - Include body (true|false, default: true if multiple files) - `include_footer:` - Include footer (true|false, default: true if breaking/issues) **Format:** `complete type:feat scope:auth files:"file1.js,file2.js" breaking:"API changed" closes:123` ## Workflow ### Step 1: Parse All Parameters Extract all parameters from $ARGUMENTS: ```bash # Required type=$(echo "$ARGUMENTS" | grep -oP 'type:\K[^ ]+') # Optional scope=$(echo "$ARGUMENTS" | grep -oP 'scope:\K[^ ]+') description=$(echo "$ARGUMENTS" | grep -oP 'description:"\K[^"]+' || echo "$ARGUMENTS" | grep -oP 'description:\K[^ ]+') files=$(echo "$ARGUMENTS" | grep -oP 'files:"\K[^"]+' || echo "$ARGUMENTS" | grep -oP 'files:\K[^ ]+') changes=$(echo "$ARGUMENTS" | grep -oP 'changes:"\K[^"]+') why=$(echo "$ARGUMENTS" | grep -oP 'why:"\K[^"]+') breaking=$(echo "$ARGUMENTS" | grep -oP 'breaking:"\K[^"]+') closes=$(echo "$ARGUMENTS" | grep -oP 'closes:\K[0-9,]+') fixes=$(echo "$ARGUMENTS" | grep -oP 'fixes:\K[0-9,]+') include_body=$(echo "$ARGUMENTS" | grep -oP 'include_body:\K(true|false)' || echo "auto") include_footer=$(echo "$ARGUMENTS" | grep -oP 'include_footer:\K(true|false)' || echo "auto") ``` ### Step 2: Validate Required Parameters **Check type is provided:** ```bash if [ -z "$type" ]; then echo "ERROR: type parameter is required" echo "Usage: complete type: [scope:] [files:\"\"]" exit 1 fi ``` **Validate type:** ```bash valid_types="feat fix docs style refactor perf test build ci chore revert" if ! echo "$valid_types" | grep -qw "$type"; then echo "ERROR: Invalid type '$type'" echo "Valid types: $valid_types" exit 1 fi ``` ### Step 3: Derive Missing Parameters **If description not provided, derive from files:** ```bash if [ -z "$description" ] && [ -n "$files" ]; then # Analyze files to create description file_count=$(echo "$files" | tr ',' '\n' | wc -l) if [ $file_count -eq 1 ]; then description="update $(basename $files)" else # Extract common directory or feature description="update ${file_count} files" fi fi ``` **Determine body inclusion:** ```bash if [ "$include_body" = "auto" ]; then file_count=$(echo "$files" | tr ',' '\n' | wc -l) if [ $file_count -gt 1 ] || [ -n "$changes" ] || [ -n "$why" ]; then include_body="true" else include_body="false" fi fi ``` **Determine footer inclusion:** ```bash if [ "$include_footer" = "auto" ]; then if [ -n "$breaking" ] || [ -n "$closes" ] || [ -n "$fixes" ]; then include_footer="true" else include_footer="false" fi fi ``` ### Step 4: Generate Subject Line **Read and execute generate-subject.md:** ```bash # Build subject arguments subject_args="subject type:$type" [ -n "$scope" ] && subject_args="$subject_args scope:$scope" [ -n "$description" ] && subject_args="$subject_args description:\"$description\"" # Invoke subject generation subject_result=$(bash -c "cd /home/danie/projects/plugins/architect/open-plugins/plugins/git-commit-assistant/commands/message-generation && cat generate-subject.md") # Extract generated subject line subject_line="" ``` **Store subject line:** ```bash COMMIT_MESSAGE="$subject_line" ``` ### Step 5: Generate Body (if needed) **If include_body is true, read and execute write-body.md:** ```bash if [ "$include_body" = "true" ]; then # Build body arguments body_args="body" if [ -n "$changes" ]; then body_args="$body_args changes:\"$changes\"" elif [ -n "$files" ]; then # Derive changes from files body_args="$body_args changes:\"$files\"" fi [ -n "$why" ] && body_args="$body_args why:\"$why\"" # Invoke body generation body_result=$(bash -c "cd /home/danie/projects/plugins/architect/open-plugins/plugins/git-commit-assistant/commands/message-generation && cat write-body.md") # Extract generated body body_content="" # Append to message (with blank line) COMMIT_MESSAGE="$COMMIT_MESSAGE $body_content" fi ``` ### Step 6: Generate Footer (if needed) **If include_footer is true, read and execute add-footer.md:** ```bash if [ "$include_footer" = "true" ]; then # Build footer arguments footer_args="footer" [ -n "$breaking" ] && footer_args="$footer_args breaking:\"$breaking\"" [ -n "$closes" ] && footer_args="$footer_args closes:$closes" [ -n "$fixes" ] && footer_args="$footer_args fixes:$fixes" # Invoke footer generation footer_result=$(bash -c "cd /home/danie/projects/plugins/architect/open-plugins/plugins/git-commit-assistant/commands/message-generation && cat add-footer.md") # Extract generated footer footer_content="" # Append to message (with blank line) COMMIT_MESSAGE="$COMMIT_MESSAGE $footer_content" fi ``` ### Step 7: Validate Complete Message **Read and execute validate-message.md:** ```bash # Invoke validation validation_result=$(bash -c "cd /home/danie/projects/plugins/architect/open-plugins/plugins/git-commit-assistant/commands/message-generation && cat validate-message.md") # Parse validation result validation_status="" validation_score="" ``` ### Step 8: Format Final Output Present the complete commit message: ``` COMPLETE COMMIT MESSAGE GENERATED ═══════════════════════════════════════════════ MESSAGE: ───────────────────────────────────────────────