ai_git 0.0.2 → 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 +4 -4
- data/lib/ai_git/ollama.rb +48 -17
- data/lib/ai_git/version.rb +1 -1
- data/lib/ai_git.rb +4 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 36409c80888ac303814accb279c6908e55693271fc92b22c2eb151a0539285a4
|
|
4
|
+
data.tar.gz: b17d56e53f81da126bdd231d12964b799555231eab76dc2cf7002c3a4d01e368
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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
|
-
|
|
24
|
-
|
|
23
|
+
Here are the changes:
|
|
24
|
+
#{diff}
|
|
25
25
|
|
|
26
|
-
|
|
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
|
-
|
|
34
|
-
feat: add user authentication flow
|
|
28
|
+
<short imperative title, max 72 chars>
|
|
35
29
|
|
|
36
|
-
|
|
30
|
+
<blank line>
|
|
37
31
|
|
|
38
|
-
|
|
32
|
+
## Summary
|
|
33
|
+
<2–4 bullet points covering the most important changes. Each bullet starts with a verb.>
|
|
39
34
|
|
|
40
|
-
|
|
35
|
+
## Why
|
|
36
|
+
<1–3 sentences explaining the motivation or context behind the change. Omit if the reason is obvious.>
|
|
41
37
|
|
|
42
|
-
|
|
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:
|
|
77
|
+
model: model_name,
|
|
47
78
|
prompt: prompt,
|
|
48
79
|
stream: false,
|
|
49
80
|
# These parameters help a lot with strictness:
|
data/lib/ai_git/version.rb
CHANGED
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"
|