Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AllCops:
TargetRubyVersion: 3.1
TargetRubyVersion: 3.2
Exclude:
- 'exe/**/*'
- 'vendor/**/*'
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ source "https://rubygems.org"
gemspec

gem "rake", "~> 13.0"
gem "rbs", "~> 3.4"
gem "rspec", "~> 3.0"
gem "rubocop", "~> 1.21"
10 changes: 7 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion ai_git_commit.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion sig/ai_git_commit.rbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
module AiGitCommit
VERSION: String
# See the writing guide of rbs: https://github.com/ruby/rbs#guides
end
14 changes: 14 additions & 0 deletions sig/ai_git_commit/cli.rbs
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions sig/ai_git_commit/config.rbs
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions sig/ai_git_commit/generator.rbs
Original file line number Diff line number Diff line change
@@ -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