git_auto 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -8
- data/lib/git_auto/commands/commit_message_command.rb +1 -2
- data/lib/git_auto/commands/config_command.rb +3 -3
- data/lib/git_auto/services/ai_service.rb +37 -30
- data/lib/git_auto/version.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 22c8ad3c04eb8a867d883b2691754ad36929589071ecad9c2fb7e064405ccc3b
         | 
| 4 | 
            +
              data.tar.gz: 820042feceec36279aa4a1de8fb396d9c30d58257ded1ba0976b8d1c843ce2d6
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 3cc3d42b26dad5d0425201c8e9dfd674fe4ffef4fd89ba26671a2d0bbfb4c2f053ae31a92afdd8279015c3688f9c62c0fb846ad2a8464737b8c5fa6f4f0dd38d
         | 
| 7 | 
            +
              data.tar.gz: 853b80adf98ed8b3be60f2bf6a84f4c861d564c01bd67981adec30091cfd85136a8f3ab7b3479a0159c5aec797016ea37eef20f872446f163e5256423a454417
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,16 +1,33 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            # Changelog
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 3 | 
            +
            All notable changes to this project will be documented in this file.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
         | 
| 6 | 
            +
            and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            ## [0.2.1] - 2024-03-21
         | 
| 6 9 |  | 
| 7 10 | 
             
            ### Fixed
         | 
| 8 | 
            -
            -  | 
| 9 | 
            -
            - Improved  | 
| 11 | 
            +
            - Fixed error when displaying repository status with no staged files
         | 
| 12 | 
            +
            - Improved error handling in repository status display
         | 
| 13 | 
            +
            - Simplified status output when no changes are staged
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            ## [0.2.0] - 2024-03-20
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            ### Added
         | 
| 18 | 
            +
            - Support for multiple AI providers (OpenAI and Anthropic)
         | 
| 19 | 
            +
            - New commit message styles (minimal, conventional, simple)
         | 
| 20 | 
            +
            - Commit history analysis
         | 
| 21 | 
            +
            - Pattern detection for commit types and scopes
         | 
| 22 | 
            +
            - Secure API key storage with encryption
         | 
| 10 23 |  | 
| 11 24 | 
             
            ### Changed
         | 
| 12 | 
            -
            -  | 
| 13 | 
            -
            -  | 
| 25 | 
            +
            - Improved error messages and validation
         | 
| 26 | 
            +
            - Enhanced diff formatting and preview
         | 
| 27 | 
            +
            - Better handling of commit message generation
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            ### Fixed
         | 
| 30 | 
            +
            - Various bug fixes and performance improvements
         | 
| 14 31 |  | 
| 15 32 | 
             
            ## [0.1.1] - 2024-12-13
         | 
| 16 33 |  | 
| @@ -51,8 +51,7 @@ module GitAuto | |
| 51 51 | 
             
                    return if status[:has_staged_changes]
         | 
| 52 52 |  | 
| 53 53 | 
             
                    puts "ℹ️  Status:".blue
         | 
| 54 | 
            -
                    puts "   | 
| 55 | 
            -
                    puts "  Staged files: #{status[:staged_files].join(", ")}"
         | 
| 54 | 
            +
                    puts "  No changes staged for commit"
         | 
| 56 55 | 
             
                    puts "\n❌ No changes staged for commit. Use 'git add' to stage changes.".red
         | 
| 57 56 | 
             
                    exit 1
         | 
| 58 57 | 
             
                  end
         | 
| @@ -156,19 +156,19 @@ module GitAuto | |
| 156 156 | 
             
                                             "Simple (description only)" => "simple"
         | 
| 157 157 | 
             
                                           })
         | 
| 158 158 |  | 
| 159 | 
            -
                    @settings. | 
| 159 | 
            +
                    @settings.save(commit_style: style)
         | 
| 160 160 | 
             
                    puts "✓ Commit style updated to #{style}".green
         | 
| 161 161 | 
             
                  end
         | 
| 162 162 |  | 
| 163 163 | 
             
                  def configure_preferences
         | 
| 164 164 | 
             
                    show_diff = @prompt.yes?("Show diff before committing?")
         | 
| 165 | 
            -
                    @settings. | 
| 165 | 
            +
                    @settings.save(show_diff: show_diff)
         | 
| 166 166 | 
             
                    puts "✓ Show diff preference updated".green
         | 
| 167 167 | 
             
                  end
         | 
| 168 168 |  | 
| 169 169 | 
             
                  def configure_history_settings
         | 
| 170 170 | 
             
                    save_history = @prompt.yes?("Save commit history for analysis?")
         | 
| 171 | 
            -
                    @settings. | 
| 171 | 
            +
                    @settings.save(save_history: save_history)
         | 
| 172 172 | 
             
                    puts "✓ History settings updated".green
         | 
| 173 173 | 
             
                  end
         | 
| 174 174 | 
             
                end
         | 
| @@ -216,16 +216,17 @@ module GitAuto | |
| 216 216 | 
             
                                       "6. Be descriptive but concise\n" \
         | 
| 217 217 | 
             
                                       "7. Do not include a period at the end"
         | 
| 218 218 | 
             
                                     when "conventional"
         | 
| 219 | 
            -
                                       "You are a commit message generator that MUST follow  | 
| 220 | 
            -
                                       " | 
| 221 | 
            -
                                       " | 
| 222 | 
            -
                                       " | 
| 223 | 
            -
                                       " | 
| 224 | 
            -
                                       " | 
| 225 | 
            -
                                       " | 
| 226 | 
            -
                                       " | 
| 227 | 
            -
                                       " | 
| 228 | 
            -
                                       " | 
| 219 | 
            +
                                       "You are a commit message generator that MUST follow these rules EXACTLY:\n" \
         | 
| 220 | 
            +
                                       "1. ONLY output a single line containing the commit message\n" \
         | 
| 221 | 
            +
                                       "2. Use format: <type>(<scope>): <description>\n" \
         | 
| 222 | 
            +
                                       "3. Valid types are: #{commit_types}\n" \
         | 
| 223 | 
            +
                                       "4. Keep under 72 characters\n" \
         | 
| 224 | 
            +
                                       "5. Use lowercase\n" \
         | 
| 225 | 
            +
                                       "6. Use present tense\n" \
         | 
| 226 | 
            +
                                       "7. Be descriptive but concise\n" \
         | 
| 227 | 
            +
                                       "8. No period at the end\n" \
         | 
| 228 | 
            +
                                       "9. NO explanations or additional text\n" \
         | 
| 229 | 
            +
                                       "10. NO markdown formatting"
         | 
| 229 230 | 
             
                                     else
         | 
| 230 231 | 
             
                                       "You are an expert in writing clear and concise git commit messages..."
         | 
| 231 232 | 
             
                                     end
         | 
| @@ -277,16 +278,17 @@ module GitAuto | |
| 277 278 | 
             
                                       "6. Be descriptive but concise\n" \
         | 
| 278 279 | 
             
                                       "7. Do not include a period at the end"
         | 
| 279 280 | 
             
                                     when "conventional"
         | 
| 280 | 
            -
                                       "You are a commit message generator that MUST follow  | 
| 281 | 
            -
                                       " | 
| 282 | 
            -
                                       " | 
| 283 | 
            -
                                       " | 
| 284 | 
            -
                                       " | 
| 285 | 
            -
                                       " | 
| 286 | 
            -
                                       " | 
| 287 | 
            -
                                       " | 
| 288 | 
            -
                                       " | 
| 289 | 
            -
                                       " | 
| 281 | 
            +
                                       "You are a commit message generator that MUST follow these rules EXACTLY:\n" \
         | 
| 282 | 
            +
                                       "1. ONLY output a single line containing the commit message\n" \
         | 
| 283 | 
            +
                                       "2. Use format: <type>(<scope>): <description>\n" \
         | 
| 284 | 
            +
                                       "3. Valid types are: #{commit_types}\n" \
         | 
| 285 | 
            +
                                       "4. Keep under 72 characters\n" \
         | 
| 286 | 
            +
                                       "5. Use lowercase\n" \
         | 
| 287 | 
            +
                                       "6. Use present tense\n" \
         | 
| 288 | 
            +
                                       "7. Be descriptive but concise\n" \
         | 
| 289 | 
            +
                                       "8. No period at the end\n" \
         | 
| 290 | 
            +
                                       "9. NO explanations or additional text\n" \
         | 
| 291 | 
            +
                                       "10. NO markdown formatting"
         | 
| 290 292 | 
             
                                     else
         | 
| 291 293 | 
             
                                       "You are an expert in writing clear and concise git commit messages..."
         | 
| 292 294 | 
             
                                     end
         | 
| @@ -353,33 +355,38 @@ module GitAuto | |
| 353 355 | 
             
                    case response.code
         | 
| 354 356 | 
             
                    when 200
         | 
| 355 357 | 
             
                      json = JSON.parse(response.body.to_s)
         | 
| 356 | 
            -
                       | 
| 358 | 
            +
                      puts "\nDebug - API Response: #{json.inspect}"
         | 
| 359 | 
            +
             | 
| 357 360 | 
             
                      case @settings.get(:ai_provider)
         | 
| 358 361 | 
             
                      when "openai"
         | 
| 359 362 | 
             
                        message = json.dig("choices", 0, "message", "content")
         | 
| 360 363 | 
             
                        if message.nil? || message.empty?
         | 
| 361 | 
            -
                           | 
| 364 | 
            +
                          puts "Debug - No content in response: #{json}"
         | 
| 362 365 | 
             
                          raise Error, "No message content in response"
         | 
| 363 366 | 
             
                        end
         | 
| 364 367 |  | 
| 368 | 
            +
                        puts "Debug - OpenAI message: #{message}"
         | 
| 365 369 | 
             
                        message.split("\n").first.strip
         | 
| 370 | 
            +
             | 
| 366 371 | 
             
                      when "claude"
         | 
| 367 372 | 
             
                        content = json.dig("content", 0, "text")
         | 
| 368 | 
            -
                         | 
| 373 | 
            +
                        puts "Debug - Claude content: #{content.inspect}"
         | 
| 369 374 |  | 
| 370 375 | 
             
                        if content.nil? || content.empty?
         | 
| 371 | 
            -
                           | 
| 376 | 
            +
                          puts "Debug - No content in response: #{json}"
         | 
| 372 377 | 
             
                          raise Error, "No message content in response"
         | 
| 373 378 | 
             
                        end
         | 
| 374 379 |  | 
| 375 | 
            -
                         | 
| 376 | 
            -
                         | 
| 380 | 
            +
                        # Extract the first actual commit message from the response
         | 
| 381 | 
            +
                        commit_message = content.scan(/(?:feat|fix|docs|style|refactor|test|chore|perf|ci|build|revert)(?:\([^)]+\))?:.*/)&.first
         | 
| 377 382 |  | 
| 378 | 
            -
                         | 
| 379 | 
            -
             | 
| 380 | 
            -
             | 
| 383 | 
            +
                        if commit_message.nil?
         | 
| 384 | 
            +
                          puts "Debug - No valid commit message pattern found in content"
         | 
| 385 | 
            +
                          raise Error, "No valid commit message found in response"
         | 
| 386 | 
            +
                        end
         | 
| 381 387 |  | 
| 382 | 
            -
                        message
         | 
| 388 | 
            +
                        puts "Debug - Extracted commit message: #{commit_message}"
         | 
| 389 | 
            +
                        commit_message.strip
         | 
| 383 390 | 
             
                      end
         | 
| 384 391 | 
             
                    when 401
         | 
| 385 392 | 
             
                      raise APIKeyError, "Invalid API key" unless ENV["RACK_ENV"] == "test"
         | 
    
        data/lib/git_auto/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: git_auto
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.2. | 
| 4 | 
            +
              version: 0.2.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Guillermo Diaz
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2024-12- | 
| 11 | 
            +
            date: 2024-12-19 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: thor
         |