dorian-commit 1.1.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/commit +34 -27
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1cfd254ac72b0cb783a5617779fb203ed8fe84cec8685702a9f52ab18ac6de0b
4
- data.tar.gz: 8158f5df736374fa3c9fc3e203755344dcdd93610d42227c127da25f14d577e1
3
+ metadata.gz: 91a09f92909e81f2a2f56cbf28b961c78f93299473f58357b00cbbee95026edc
4
+ data.tar.gz: 77c2efb3a5803bd1ae6a24c94ce5395f65f02fc7c493b90a9fb3a7683b340749
5
5
  SHA512:
6
- metadata.gz: a328add85459b999de4436e92db6ea24cfd03912d3c0672fabe13823d24a88cfbe247db4bb2b0a2c43b1be596e3144ca2cbb5d2e67015bb25cdbcce7b480d1bb
7
- data.tar.gz: 9dc85ba07932fc0be0c5781b4c5d6d94bbe5de98d686c61dc8cd234f9982608f350bd3b8436735ca48c483d2466f784c50d09994ac44325b4bf9b30a17adae91
6
+ metadata.gz: ef4bde195f715f6133c703794ef3e6b6498be8ae04bfd51163d5aef9adef5cba5afaf62fc690cdd2f6cc72a8a260770a9e808afa7fd99e6dd1a8a360b30f79a7
7
+ data.tar.gz: 4ba57647e46452ba87af5ebfd59a9c9f873dfd1fcd718b6baf9a219ae41336bc966b69dc79e64ab9c4a56d1b026f31384d3ffb2869c6b38638aefdad7f44a940
data/bin/commit CHANGED
@@ -24,12 +24,25 @@ PROMPT_2 = "for the following diff:"
24
24
  PROMPT_3 = "for the following git status:"
25
25
  PROMPT_4 = "for the following comment:"
26
26
 
27
- parsed = Dorian::Arguments.parse(tokens: { type: :integer, alias: :t, default: 1000 }, version: { alias: :v }, help: { alias: :h })
27
+ parsed =
28
+ Dorian::Arguments.parse(
29
+ tokens: {
30
+ type: :integer,
31
+ alias: :t,
32
+ default: 1000
33
+ },
34
+ version: {
35
+ alias: :v
36
+ },
37
+ help: {
38
+ alias: :h
39
+ }
40
+ )
28
41
 
29
42
  abort parsed.help if parsed.options.help
30
43
 
31
44
  if parsed.options.version
32
- abort File.read(File.expand_path("../../VERSION", __FILE__))
45
+ abort File.read(File.expand_path("../VERSION", __dir__))
33
46
  end
34
47
 
35
48
  content_2 = `git diff --staged`
@@ -43,34 +56,28 @@ encoder = Tiktoken.encoding_for_model("gpt-4o")
43
56
 
44
57
  content_2_encoded = encoder.encode(content_2)
45
58
 
46
- if content_2_encoded.length > parsed.options.tokens
47
- messages_2 = []
48
- else
49
- messages_2 = [
50
- { role: :system, content: PROMPT_2 },
51
- { role: :user, content: content_2 }
52
- ]
53
- end
59
+ messages_2 =
60
+ if content_2_encoded.length > parsed.options.tokens
61
+ []
62
+ else
63
+ [{ role: :system, content: PROMPT_2 }, { role: :user, content: content_2 }]
64
+ end
54
65
 
55
66
  content_3_encoded = encoder.encode(content_3)
56
67
 
57
- if content_3_encoded.length > parsed.options.tokens
58
- messages_3 = []
59
- else
60
- messages_3 = [
61
- { role: :system, content: PROMPT_3 },
62
- { role: :user, content: content_3 },
63
- ]
64
- end
65
-
66
- if content_4.empty?
67
- messages_4 = []
68
- else
69
- messages_4 = [
70
- { role: :system, content: PROMPT_4 },
71
- { role: :user, content: content_4 }
72
- ]
73
- end
68
+ messages_3 =
69
+ if content_3_encoded.length > parsed.options.tokens
70
+ []
71
+ else
72
+ [{ role: :system, content: PROMPT_3 }, { role: :user, content: content_3 }]
73
+ end
74
+
75
+ messages_4 =
76
+ if content_4.empty?
77
+ []
78
+ else
79
+ [{ role: :system, content: PROMPT_4 }, { role: :user, content: content_4 }]
80
+ end
74
81
 
75
82
  uri = URI.parse("https://api.openai.com/v1/chat/completions")
76
83
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dorian-commit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-25 00:00:00.000000000 Z
11
+ date: 2024-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dorian-arguments
@@ -73,14 +73,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="
75
75
  - !ruby/object:Gem::Version
76
- version: '0'
76
+ version: '3'
77
77
  required_rubygems_version: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  requirements: []
83
- rubygems_version: 3.5.11
83
+ rubygems_version: 3.5.16
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: commit with ai