1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
```
┌─────────────────────────────────────────────────────────────────────────────────┐
│ GIT AI COMMIT MESSAGE GENERATION │
├─────────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ ┌──────────────┐ ┌───────────────┐ ┌───────────────┐ │
│ │ git commit │───▶│ Hook Trigger │───▶│ Diff Analysis │───▶│ AI Processing │ │
│ └─────────────┘ └──────────────┘ └───────────────┘ └───────────────┘ │
│ │ │ │ │ │
│ ▼ ▼ ▼ ▼ │
│ ┌─────────────┐ ┌──────────────┐ ┌───────────────┐ ┌───────────────┐ │
│ │ No Msg? │ │ Parse Args │ │ Parse Files │ │ Multi-Step │ │
│ │ Check │ │ Load Config │ │ Count Lines │ │ Analysis │ │
│ └─────────────┘ └──────────────┘ └───────────────┘ └───────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────────┐ │
│ │ COMMIT MESSAGE GENERATED │ │
│ └─────────────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────────┘
```
```
┌─────────────────────────────────────────────────────────────────────────────────┐
│ MULTI-STEP ANALYSIS │
├─────────────────────────────────────────────────────────────────────────────────┤
│ │
│ Step 1: Parse Diff │
│ ┌─────────────────────────────────────────────────────────────────────────┐ │
│ │ diff --git a/src/auth.rs b/src/auth.rs │ │
│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
│ │ │ File 1 │ │ File 2 │ │ File 3 │ │ File N │ │ │
│ │ │ auth.rs │ │ test.rs │ │ main.rs │ │ ... │ │ │
│ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │
│ └─────────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ Step 2: Analyze Each File │
│ ┌─────────────────────────────────────────────────────────────────────────┐ │
│ │ ┌────────────────┐ ┌────────────────┐ ┌────────────────┐ │ │
│ │ │ auth.rs │ │ test.rs │ │ main.rs │ │ │
│ │ │ +89 -12 lines │ │ +45 -0 lines │ │ +5 -3 lines │ │ │
│ │ │ category:source│ │ category:test │ │ category:source│ │ │
│ │ │ summary: Add │ │ summary: Add │ │ summary: Update│ │ │
│ │ │ JWT auth │ │ auth tests │ │ imports │ │ │
│ │ └────────────────┘ └────────────────┘ └────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ Step 3: Calculate Impact Scores │
│ ┌─────────────────────────────────────────────────────────────────────────┐ │
│ │ File Impact Calculation: │ │
│ │ ┌─────────────────────────────────────────────────────────────┐ │ │
│ │ │ auth.rs: operation(0.3) + category(0.4) + lines(0.25) = 0.95│ │ │
│ │ │ test.rs: operation(0.3) + category(0.2) + lines(0.15) = 0.65│ │ │
│ │ │ main.rs: operation(0.2) + category(0.4) + lines(0.02) = 0.62│ │ │
│ │ └─────────────────────────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ Step 4: Generate Candidates │
│ ┌─────────────────────────────────────────────────────────────────────────┐ │
│ │ Based on highest impact (auth.rs @ 0.95): │ │
│ │ ┌─────────────────────────────────────────────────────────────┐ │ │
│ │ │ 1. "Add JWT authentication system" (Action-focused) │ │ │
│ │ │ 2. "auth: implement JWT token handling" (Component) │ │ │
│ │ │ 3. "New feature for authentication support" (Impact) │ │ │
│ │ └─────────────────────────────────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ Step 5: Select Best Candidate │
│ ┌─────────────────────────────────────────────────────────────────────────┐ │
│ │ Selected: "Add JWT authentication system" │ │
│ │ Reasoning: Source changes have highest impact (0.95) affecting core │ │
│ │ security functionality. Total 3 files changed with 134 lines modified. │ │
│ └─────────────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────────┘
```
```
┌─────────────────────────────────────────────────────────────────────────────────┐
│ FALLBACK STRATEGY │
├─────────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌───────────────────┐ │
│ │ Multi-Step OpenAI │ │
│ │ (Primary) │ │
│ └─────────┬─────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────┐ Success ┌─────────────────┐ │
│ │ API Call? ├───────────────▶│ Generate Message│ │
│ └────────┬────────┘ └─────────────────┘ │
│ │ Fail │
│ ▼ │
│ ┌───────────────────┐ │
│ │ Local Multi-Step │ │
│ │ (Fallback 1) │ │
│ └─────────┬─────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────┐ Success ┌─────────────────┐ │
│ │ Local Analysis? ├───────────────▶│ Generate Message│ │
│ └────────┬────────┘ └─────────────────┘ │
│ │ Fail │
│ ▼ │
│ ┌───────────────────┐ │
│ │ Single-Step API │ │
│ │ (Fallback 2) │ │
│ └─────────┬─────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────┐ Success ┌─────────────────┐ │
│ │ Final Try? ├───────────────▶│ Generate Message│ │
│ └────────┬────────┘ └─────────────────┘ │
│ │ Fail │
│ ▼ │
│ ┌─────────────────┐ │
│ │ Error Exit │ │
│ └─────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────────┘
```
```
┌─────────────────────────────────────────────────────────────────────────────────┐
│ FILE CATEGORY WEIGHTS │
├─────────────────────────────────────────────────────────────────────────────────┤
│ │
│ source ████████████████████████████████████████████████████████ 1.0 │
│ config ████████████████████████████████████████████ 0.8 │
│ build ███████████████████████████████████████ 0.7 │
│ test ██████████████████████████████ 0.6 │
│ docs ████████████████████ 0.4 │
│ binary █████ 0.1 │
│ │
│ Operation Type Weights: │
│ added ███████████████ 0.3 │
│ deleted ████████████ 0.25 │
│ modified ██████████ 0.2 │
│ renamed █████ 0.1 │
│ binary ██ 0.05 │
│ │
└─────────────────────────────────────────────────────────────────────────────────┘
```
```
┌─────────────────────────────────────────────────────────────────────────────────┐
│ EXECUTION TIMELINE │
├─────────────────────────────────────────────────────────────────────────────────┤
│ │
│ 0ms 100ms 200ms 300ms 400ms 500ms 600ms 700ms 800ms │
│ │ │ │ │ │ │ │ │ │ │
│ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤ │
│ │ │ │
│ │▓▓▓│ Hook Init (50ms) │ │
│ │ │▓▓▓▓▓│ Parse Diff (80ms) │ │
│ │ │▓▓▓▓▓▓▓▓▓▓│ File Analysis (150ms) │ │
│ │ │▓▓▓▓│ Score Calc (60ms) │ │
│ │ │▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓│ API Call (250ms) │ │
│ │ │▓▓│ Write (30ms) │ │
│ │ │ │ │
│ │ │ │
│ Total: 620ms │ │
│ │
└─────────────────────────────────────────────────────────────────────────────────┘
```
```
┌─────────────────────────────────────────────────────────────────────────────────┐
│ DATA FLOW │
├─────────────────────────────────────────────────────────────────────────────────┤
│ │
│ Git Diff Input │
│ ┌─────────────┐ │
│ │ Raw Diff │ │
│ │ Text │ │
│ └──────┬──────┘ │
│ │ │
│ ▼ │
│ ┌─────────────┐ ParsedFile struct │
│ │ Diff Parser ├────────────────────┐ │
│ └─────────────┘ │ │
│ ▼ │
│ ┌───────────────┐ │
│ │ path: String │ │
│ │ operation: Op │ │
│ │ diff: String │ │
│ └───────┬───────┘ │
│ │ │
│ ┌────────────────────────────┼────────────────────────────┐ │
│ ▼ ▼ ▼ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Analyzer │ │ Scorer │ │ Generator │ │
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ FileAnalysisResult FileWithScore CommitCandidate │
│ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │
│ │ lines_added │ │ impact_score │ │ message: str │ │
│ │ lines_removed │ │ file_category │ │ reasoning: str│ │
│ │ file_category │ │ summary │ │ score: f32 │ │
│ │ summary │ └───────────────┘ └───────────────┘ │
│ └───────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────────┘
```