ai_git 0.0.1 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 046ac04594b50d98c5f50ecdadbd9c7749ceda68c07f91746da902884481fbfa
4
- data.tar.gz: fa3629eba9981f8b8c6f93ee6ac4fa5aaa60677fd4931346da4a8b1a064a93cc
3
+ metadata.gz: 36409c80888ac303814accb279c6908e55693271fc92b22c2eb151a0539285a4
4
+ data.tar.gz: b17d56e53f81da126bdd231d12964b799555231eab76dc2cf7002c3a4d01e368
5
5
  SHA512:
6
- metadata.gz: 8be61808da7eee3c957dd3c685acf9c09a67fcd06f9bd1a7e20afa9b467b228658f6c499bcbc4b0ff56348199b81a1a740f1a4f009eee6c38c4e809e56e1b170
7
- data.tar.gz: fb5275d0f7cdc4da88b383e1a8771306ff20d513b6ff4b35a01afa553eac3b5361febaa8c20f8b413558765986fda9aff3d0d075d8904c7bde052b5a47bc8655
6
+ metadata.gz: e760bbd37b63c7ba1cfcb486e084742718033924990b590f03e51fd9c3ec31ece730c287c0f364680fff34962a68a9d4046f66611d2f9b350c8ac520a76f165d
7
+ data.tar.gz: e2d581350863a6b9dd6ff67a537b57aa126233f9cbfc921dcd63cd5f64b79cd404befff9e4157940f3ee921a4c47c4f749f37e12ed3d750fdb41f0e5303624c9
data/lib/ai_git/ollama.rb CHANGED
@@ -14,36 +14,67 @@ module AIGit
14
14
  .gsub("\t", '\\t')
15
15
  end
16
16
 
17
- def generate_commit_message(diff)
17
+ def generate_commit_message(diff, model_name)
18
18
  raise 'No staged changes to generate commit message for' if diff.to_s.strip.empty?
19
19
 
20
20
  prompt = <<~PROMPT
21
- You are an expert Git commit message writer. Your only job is to output a commit message nothing else.
21
+ You are an expert Git commit message writer. Output ONLY the commit message no explanations, no markdown, no backticks, no preamble.
22
22
 
23
- Here are the changes:
24
- #{diff}
23
+ Here are the changes:
24
+ #{diff}
25
25
 
26
- Rules you MUST follow exactly:
27
- - Output ONLY the commit message. No explanations, no quotes, no markdown, no "Here is the commit message", no backticks.
28
- - Use this exact structure:
29
- 1. First line: Conventional commit type + short imperative title (max 72 chars, ideally < 50)
30
- 2. Second line: blank
31
- 3. Body (optional but recommended): Clear, concise explanation of WHAT changed and WHY.
26
+ STRICT OUTPUT FORMAT (follow exactly):
32
27
 
33
- Examples of good output:
34
- feat: add user authentication flow
28
+ <short imperative title, max 72 chars>
35
29
 
36
- Implemented JWT-based login with refresh tokens. Added protected routes middleware.
30
+ <blank line>
37
31
 
38
- fix: prevent null pointer on missing metadata
32
+ ## Summary
33
+ <2–4 bullet points covering the most important changes. Each bullet starts with a verb.>
39
34
 
40
- Added nil check in ReportGenerator#process before accessing user preferences.
35
+ ## Why
36
+ <1–3 sentences explaining the motivation or context behind the change. Omit if the reason is obvious.>
41
37
 
42
- Now generate the commit message:
38
+ RULES:
39
+ - Title line: short, specific, imperative mood (e.g. "Add JWT login with refresh token support"). Avoid vague titles like "Update stuff" or "Fix bug".
40
+ - Summary bullets: describe WHAT changed, not HOW the code looks. Focus on behaviour and impact.
41
+ - Why section: explain the problem being solved or the goal being achieved. Skip if it adds no value.
42
+ - No filler phrases ("this commit", "this PR", "as per discussion").
43
+ - No line should exceed 72 characters.
44
+
45
+ EXAMPLES OF GOOD OUTPUT:
46
+
47
+ Add JWT-based login with refresh token support
48
+
49
+ ## Summary
50
+ - Implement login endpoint with access and refresh token issuance
51
+ - Add token refresh route with rotation and expiry validation
52
+ - Protect private routes via middleware that verifies access tokens
53
+ - Store refresh tokens using encrypted HTTP-only cookies
54
+
55
+ ## Why
56
+ Users were being logged out on every page reload. Refresh tokens allow
57
+ sessions to persist securely without requiring re-authentication.
58
+
59
+ ---
60
+
61
+ Prevent nil crash when user preferences are missing
62
+
63
+ ## Summary
64
+ - Add nil guard in ReportGenerator#process before accessing preferences
65
+ - Fall back to system defaults when preferences object is absent
66
+
67
+ ## Why
68
+ Reports were raising NoMethodError in production for users created
69
+ before the preferences feature shipped.
70
+
71
+ ---
72
+
73
+ Now generate the commit message:
43
74
  PROMPT
44
75
 
45
76
  json_body = {
46
- model: 'phi4:14b',
77
+ model: model_name,
47
78
  prompt: prompt,
48
79
  stream: false,
49
80
  # These parameters help a lot with strictness:
@@ -1,3 +1,3 @@
1
1
  module AIGit
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/ai_git.rb CHANGED
@@ -7,18 +7,21 @@ module AIGit
7
7
  module_function
8
8
 
9
9
  def run
10
+ model_name = ENV["AI_GIT_MODEL_NAME"] || "phi4:14b"
11
+
10
12
  staged = AIGit::Git.staged_files
11
13
  abort 'Error: No staged files. Use `git add` first.' if staged.to_s.strip.empty?
12
14
 
13
15
  diff = AIGit::Git.diff
14
16
  branch = AIGit::Git.current_branch
15
17
 
18
+ puts "\e[1mModel Name:\e[0m #{model_name}"
16
19
  puts "\e[1mStaged Files:\e[0m #{staged}"
17
20
  puts "\e[1mBranch:\e[0m #{branch}"
18
21
  puts "\e[1mAI Generating Commit Message\e[0m"
19
22
 
20
23
  result = Benchmark.measure do
21
- message = AIGit::Ollama.generate_commit_message(diff)
24
+ message = AIGit::Ollama.generate_commit_message(diff, model_name)
22
25
  message = message.gsub(/\n{2,}/, "\n")
23
26
 
24
27
  puts "\e[1mCommit Message:\e[0m\n\n#{message}\n"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ai_git
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaíque Kandy Koga
@@ -20,7 +20,7 @@ files:
20
20
  - lib/ai_git/git.rb
21
21
  - lib/ai_git/ollama.rb
22
22
  - lib/ai_git/version.rb
23
- homepage: https://github.com/koga/ai_git
23
+ homepage: https://github.com/kaiquekandykoga/ai_git
24
24
  licenses:
25
25
  - BSD-3-Clause
26
26
  metadata: {}