commitgpt 0.3.11 → 0.3.12

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: b8a2b39ee34a81a322ba56a693b002e1a8b29bc6adc432b4f41992c71ff3bd4a
4
- data.tar.gz: cd4289fee106ee2feb1e89c71b29889b6fe0232c542452588fd0564b4b49593f
3
+ metadata.gz: ab9b9d8c6894ba37e2e16881e28fc2772336f5056f53330f91451818c5a28e36
4
+ data.tar.gz: e4a4d6a33c7a0270725af5e79f1da44bac5111c9810bb799231631336a5aa4c5
5
5
  SHA512:
6
- metadata.gz: 77b3f3fe14333b001537c52482b3424f2b5c679434b7ea52bb06e001e64cd5cc0f0c61782ead4d8416bf01473a7099398ba2d4eea84c268f84a14e6a62e5448b
7
- data.tar.gz: 073de1a61a918be54e7ca2f2bb750b094aa1f0e1d56e195ad6239a8e4eb0431570ff4dfaedd22255e843d8c994df8c248d74f7cb1d306c6644e145e064c306ca
6
+ metadata.gz: 7610f6291cffa1b70c7d9735096962a7e1a25f62d5b6e512c6688d0d80d1cd71961798d5867e77c0bc94dd58db027cd76168ecf833ab07fb886818b370d88616
7
+ data.tar.gz: fbf38cd92931dddfdb1acdf9d7a8ec290d33376fab4fd769a480f6e45a4da8a495624e8143dd58592a51294ecd5c959316143744e9ee3eb6fce395b09cfd09fc
@@ -25,6 +25,26 @@ module CommitGpt
25
25
  'gitmoji' => ':emoji: <commit message>'
26
26
  }.freeze
27
27
 
28
+ # Worked example of the detailed shape. Models follow a sample far more
29
+ # reliably than a description of one.
30
+ DETAILED_EXAMPLE = <<~EXAMPLE
31
+ Here is an example of the expected output, showing the exact shape only.
32
+ Your subject line must still follow the format above:
33
+
34
+ feat(dfb): store and expand DFB event and speed logs
35
+
36
+ Persist DFB device logs ingested from the proactive evt (event log) and
37
+ lge (speed stats) topics, one record per message.
38
+
39
+ - Add dfb_event_logs and dfb_speed_stats tables and models, each with an
40
+ idempotent unique index so re-delivery and overlapping backfills are safe.
41
+ - Add the canonical event-code table and the loader that expands a device
42
+ event byte into a human label and tags; unknown codes fall back to
43
+ "Unknown Event".
44
+ - Associate both log tables on Product.
45
+ - Update README_DFB.md to document the new cloud tables.
46
+ EXAMPLE
47
+
28
48
  # Conventional commit types based on aicommits implementation
29
49
  CONVENTIONAL_TYPES = {
30
50
  'docs' => 'Documentation only changes',
@@ -141,13 +161,25 @@ module CommitGpt
141
161
  @commit_detail == 'detailed'
142
162
  end
143
163
 
144
- # Streaming cutoff and completion budget, both of which have to grow to fit a body
164
+ # Streaming cutoff. Generous because models that ignore disable_reasoning
165
+ # spend it on inline <think> text before the message itself arrives.
145
166
  def max_content_chars
146
- detailed? ? 2000 : 300
167
+ detailed? ? 6000 : 1500
147
168
  end
148
169
 
149
170
  def reasoning_disabled_max_tokens
150
- detailed? ? 1000 : 300
171
+ detailed? ? 1200 : 300
172
+ end
173
+
174
+ # Some models stream their chain of thought inside content instead of the
175
+ # reasoning_content field, either wrapped in <think>...</think> or with only
176
+ # the closing tag when the chat template pre-fills the opener. Keep what
177
+ # comes after the thinking, never the thinking itself.
178
+ def strip_reasoning(content)
179
+ text = content.gsub(%r{<think(?:ing)?>.*?</think(?:ing)?>}m, '')
180
+ text = text.rpartition(%r{</think(?:ing)?>}).last if text.match?(%r{</think(?:ing)?>})
181
+ # Opener with no closer: the model never came back from thinking
182
+ text.sub(/<think(?:ing)?>.*\z/m, '')
151
183
  end
152
184
 
153
185
  # Header printed before the streamed message starts arriving
@@ -166,15 +198,24 @@ module CommitGpt
166
198
  editor.empty? ? 'your editor' : editor
167
199
  end
168
200
 
201
+ # Models like to wrap the whole message in a fence despite being told not to
202
+ def strip_code_fence(text)
203
+ return text unless text.start_with?('```')
204
+
205
+ text.sub(/\A```[a-zA-Z]*\n?/, '').sub(/\n?```\s*\z/, '')
206
+ end
207
+
169
208
  # Trim the model output down to what git should receive
170
209
  def finalize_message(full_content)
210
+ content = strip_reasoning(full_content)
211
+
171
212
  unless detailed?
172
213
  # Take only the first non-empty line to avoid repetition or multi-line garbage
173
- first_line = full_content.split("\n").map(&:strip).reject(&:empty?).first
214
+ first_line = content.split("\n").map(&:strip).reject(&:empty?).first
174
215
  return first_line&.gsub(/\A["']|["']\z/, '') || ''
175
216
  end
176
217
 
177
- body = full_content.strip.gsub(/\A["']|["']\z/, '').strip
218
+ body = strip_code_fence(content.strip).gsub(/\A["']|["']\z/, '').strip
178
219
  # Keep the subject/body/bullets structure but drop trailing spaces and
179
220
  # collapse the extra blank lines models like to emit between sections
180
221
  body.split("\n").map(&:rstrip).join("\n").gsub(/\n{3,}/, "\n\n")
@@ -341,7 +382,7 @@ module CommitGpt
341
382
  end
342
383
 
343
384
  format_spec = if detailed?
344
- "The subject line must be in format:\n#{COMMIT_FORMATS[@commit_format]}"
385
+ "The subject line must be in format:\n#{COMMIT_FORMATS[@commit_format]}\n\n#{DETAILED_EXAMPLE}"
345
386
  else
346
387
  "The output response must be in format:\n#{COMMIT_FORMATS[@commit_format]}"
347
388
  end
@@ -352,8 +393,12 @@ module CommitGpt
352
393
  '- Then one blank line, then a body paragraph of 1-3 sentences explaining what changed and why.',
353
394
  '- Then one blank line, then a bullet list where each bullet starts with "- " and describes one notable change.',
354
395
  '- Wrap body and bullet text at 72 characters.',
396
+ '- Cover the whole diff in 3-6 bullets. Group related files into one bullet instead of listing every file.',
355
397
  '- Be specific: include concrete details (file, table, method, package names) rather than generic statements.',
356
398
  '- Do not use markdown headings, bold, or code fences. Plain text only.',
399
+ '- Write the message directly. Do not think out loud, do not draft and revise, do not explain your reasoning, do not mention the diff or these instructions.',
400
+ '- Do not emit <think> tags or any text before the subject line.',
401
+ '- Stop immediately after the last bullet. Do not add a summary, a closing remark, or a second version of the message.',
357
402
  '- Exclude anything unnecessary such as translation. Your entire response will be passed directly into git commit.',
358
403
  '- Return ONLY the commit message, nothing else. No explanations, no introductions, no surrounding quotes.'
359
404
  ]
@@ -402,6 +447,8 @@ module CommitGpt
402
447
 
403
448
  if can_disable_reasoning
404
449
  payload[:disable_reasoning] = true
450
+ # SGLang/vLLM back ends honour this where disable_reasoning is ignored
451
+ payload[:chat_template_kwargs] = { enable_thinking: false }
405
452
  payload[:max_tokens] = reasoning_disabled_max_tokens
406
453
  else
407
454
  payload[:max_tokens] = configured_max_tokens
@@ -450,7 +497,7 @@ module CommitGpt
450
497
  error_msg += " Raw: #{error_body}" unless error_body.to_s.strip.empty?
451
498
  end
452
499
 
453
- if can_disable_reasoning && (error_msg =~ /parameter|reasoning|unsupported/i || response.code == '400')
500
+ if can_disable_reasoning && (error_msg =~ /parameter|reasoning|template|unsupported/i || response.code == '400')
454
501
  puts "⚠ Provider does not support 'disable_reasoning'. Updating config and retrying...".yellow
455
502
  ConfigManager.update_provider(provider_config['name'], { 'can_disable_reasoning' => false })
456
503
  @is_retrying = true
@@ -644,6 +691,8 @@ module CommitGpt
644
691
 
645
692
  if can_disable_reasoning
646
693
  payload[:disable_reasoning] = true
694
+ # SGLang/vLLM back ends honour this where disable_reasoning is ignored
695
+ payload[:chat_template_kwargs] = { enable_thinking: false }
647
696
  payload[:max_tokens] = reasoning_disabled_max_tokens
648
697
  else
649
698
  payload[:max_tokens] = provider_config['max_tokens'] || 2000
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CommitGpt
4
- VERSION = '0.3.11'
4
+ VERSION = '0.3.12'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commitgpt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peng Zhang