From 1807850fb67682dbcbd3b977aa6ddf0e02cc7156 Mon Sep 17 00:00:00 2001 From: Mike Belyaev Date: Mon, 15 Sep 2025 13:38:39 +0300 Subject: [PATCH 1/3] Add rbs gem, update prism and regexp_parser gems, and bump required Ruby version to 3.2.0 - Added 'rbs' gem with version '~> 3.4' to Gemfile - Updated 'prism' gem version from 1.4.0 to 1.5.1 in Gemfile.lock - Updated 'regexp_parser' gem version from 2.11.2 to 2.11.3 in Gemfile.lock - Bumped required Ruby version in ai_git_commit.gemspec from '>= 3.1.0' to '>= 3.2.0' This commit introduces the 'rbs' gem to the project, specifying version '~> 3.4' in the Gemfile. Additionally, it updates the versions of 'prism' and 'regexp_parser' gems in the Gemfile.lock file. Lastly, it increases the required Ruby version in the ai_git_commit.gemspec file to '>= 3.2.0'. --- Gemfile | 2 ++ Gemfile.lock | 10 +++++++--- ai_git_commit.gemspec | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 1281f97..32c9e4b 100644 --- a/Gemfile +++ b/Gemfile @@ -8,3 +8,5 @@ gemspec gem "rake", "~> 13.0" gem "rspec", "~> 3.0" gem "rubocop", "~> 1.21" +gem 'rbs', '~> 3.4' + diff --git a/Gemfile.lock b/Gemfile.lock index 4b8134c..de4830f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -16,17 +16,20 @@ GEM json (2.13.2) language_server-protocol (3.17.0.5) lint_roller (1.1.0) + logger (1.7.0) openai (0.22.1) connection_pool parallel (1.27.0) parser (3.3.9.0) ast (~> 2.4.1) racc - prism (1.4.0) + prism (1.5.1) racc (1.8.1) rainbow (3.1.1) rake (13.3.0) - regexp_parser (2.11.2) + rbs (3.9.5) + logger + regexp_parser (2.11.3) rspec (3.13.1) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) @@ -67,8 +70,9 @@ PLATFORMS DEPENDENCIES ai_git_commit! rake (~> 13.0) + rbs (~> 3.4) rspec (~> 3.0) rubocop (~> 1.21) BUNDLED WITH - 2.6.9 + 2.7.2 diff --git a/ai_git_commit.gemspec b/ai_git_commit.gemspec index a9666d7..3816e0e 100644 --- a/ai_git_commit.gemspec +++ b/ai_git_commit.gemspec @@ -15,7 +15,7 @@ Gem::Specification.new do |spec| DESCRIPTION spec.homepage = "https://github.com/drkmen/ai_git_commit" spec.license = "MIT" - spec.required_ruby_version = ">= 3.1.0" + spec.required_ruby_version = ">= 3.2.0" spec.metadata["allowed_push_host"] = "https://rubygems.org" From 206bb2f9a93549c5da9294fe90808d81831af3d3 Mon Sep 17 00:00:00 2001 From: Mike Belyaev Date: Mon, 15 Sep 2025 15:20:29 +0300 Subject: [PATCH 2/3] Add .rbs documentation --- sig/ai_git_commit.rbs | 1 - sig/ai_git_commit/cli.rbs | 14 ++++++++++++++ sig/ai_git_commit/config.rbs | 15 +++++++++++++++ sig/ai_git_commit/generator.rbs | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 sig/ai_git_commit/cli.rbs create mode 100644 sig/ai_git_commit/config.rbs create mode 100644 sig/ai_git_commit/generator.rbs diff --git a/sig/ai_git_commit.rbs b/sig/ai_git_commit.rbs index 16cf48b..d068cdc 100644 --- a/sig/ai_git_commit.rbs +++ b/sig/ai_git_commit.rbs @@ -1,4 +1,3 @@ module AiGitCommit VERSION: String - # See the writing guide of rbs: https://github.com/ruby/rbs#guides end diff --git a/sig/ai_git_commit/cli.rbs b/sig/ai_git_commit/cli.rbs new file mode 100644 index 0000000..7240659 --- /dev/null +++ b/sig/ai_git_commit/cli.rbs @@ -0,0 +1,14 @@ +module AiGitCommit + class CLI < Thor + HOOK_PATH: String + + def install: () -> void + + private + + def create_hook: () -> void + def copy_initializer: () -> void + def script: () -> ::String + def hook_file_exists?: () -> bool + end +end diff --git a/sig/ai_git_commit/config.rbs b/sig/ai_git_commit/config.rbs new file mode 100644 index 0000000..8a40bb4 --- /dev/null +++ b/sig/ai_git_commit/config.rbs @@ -0,0 +1,15 @@ +module AiGitCommit + class Config + attr_accessor openai_api_key: String + attr_accessor model: String + attr_accessor program_language: String + attr_accessor max_tokens: Integer + attr_accessor temperature: Float + attr_accessor system_role_message: String + + def initialize: () -> void + end + + def self.config: () -> Config + def self.configure: () { (Config) -> void } -> void +end diff --git a/sig/ai_git_commit/generator.rbs b/sig/ai_git_commit/generator.rbs new file mode 100644 index 0000000..74ddaa8 --- /dev/null +++ b/sig/ai_git_commit/generator.rbs @@ -0,0 +1,33 @@ +module AiGitCommit + class Generator + self.@openai: OpenAI::Client + self.@config: Config + + def self.commit_message: () -> String + + private + + def self.fetch_message: (String diff) -> String + def self.completion_payload: (String diff) -> { + model: String, + messages: ::Array[ + { + role: String, + content: String + } | { + role: String, + content: String + } + ], + max_tokens: Integer, + temperature: Float + } + + def self.user_role_message: (String diff) -> String + def self.openai: () -> OpenAI::Client + def self.config: () -> Config + def self.openai_api_key: () -> String? + def self.staged_diff: () -> String + end +end + From 5004b7a8df23ec06b2794b645626ea49c991871e Mon Sep 17 00:00:00 2001 From: Mike Belyaev Date: Mon, 15 Sep 2025 15:48:58 +0300 Subject: [PATCH 3/3] Update Ruby version to 3.2 in .rubocop.yml and fix offensec The commit updates the TargetRubyVersion in .rubocop.yml to 3.2 from 3.1. --- .rubocop.yml | 2 +- Gemfile | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 5be3d3c..0d3cce5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,5 @@ AllCops: - TargetRubyVersion: 3.1 + TargetRubyVersion: 3.2 Exclude: - 'exe/**/*' - 'vendor/**/*' diff --git a/Gemfile b/Gemfile index 32c9e4b..18975cb 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,6 @@ source "https://rubygems.org" gemspec gem "rake", "~> 13.0" +gem "rbs", "~> 3.4" gem "rspec", "~> 3.0" gem "rubocop", "~> 1.21" -gem 'rbs', '~> 3.4' -