class GemHadar

def version_bump_task

version_bump_to method to perform the actual version update.
the ollama_generate method to get AI-powered suggestions, and the
The tasks utilize the version_log_diff method to gather change information,

the bump.
the current HEAD, and it prompts the user for confirmation before applying
suggestion is based on the git log diff between the previous version and
appropriate version bump type by analyzing recent changes using AI. The
- It also defines a :version:bump task that automatically suggests the
major, minor, or build versions.
- It creates subtasks in the :version:bump namespace for explicitly bumping

namespace:
This method sets up a hierarchical task structure under the :version

version number.
The version_bump_task method defines Rake tasks for incrementing the gem's
def version_bump_task
  namespace :version do
    namespace :bump do
      desc 'Bump major version'
      task :major do
        version_bump_to(:major)
      end
      desc 'Bump minor version'
      task :minor do
        version_bump_to(:minor)
      end
      desc 'Bump build version'
      task :build do
        version_bump_to(:build)
      end
    end
    desc 'Bump version with AI suggestion'
    task :bump do
      log_diff = version_log_diff(from_version: nil, to_version: 'HEAD')
      system   = xdg_config('version_bump_system_prompt.txt', default_version_bump_system_prompt)
      prompt   = xdg_config('version_bump_prompt.txt', default_version_bump_prompt) % { version:, log_diff: }
      response = ollama_generate(system:, prompt:)
      puts response
      default = nil
      if response =~ /(major|minor|build)\s*$/
        default = $1
      end
      response = ask?(
        'Bump a major, minor, or build version%{default}? ',
        /\A(major|minor|build)\z/,
        default:
      )
      if version_type = response&.[](1)
        version_bump_to(version_type)
      else
        exit 1
      end
    end
  end
end