matheus 0.6.4 → 0.7.0
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/CHANGELOG.md +6 -0
- data/README.md +8 -0
- data/exe/quick-commit +7 -0
- data/lib/matheus/command.rb +2 -2
- data/lib/matheus/q.rb +6 -4
- data/lib/matheus/quick_commit.rb +25 -0
- data/lib/matheus/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5a35e65053e7e649e79f1a2e2fc75b7a03e0cdcbe711374d6dd7f91c18f9316
|
4
|
+
data.tar.gz: bc5fbdbb8df7b80dcf5fbe64290a4319cbcdc9e4f3dbbb3c8b6a8b06b6caaae2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af2982cd118538f93f5092dbbd2c1ef0af7716f9a31f94ae44211b91b64f407373cbec566cf465a97ae2cdfc885c2b7f718511f8775d08a68b73d4a62b5cf2f9
|
7
|
+
data.tar.gz: e87d00e609c751f9330a444cffc131af5784f2be706d831534a8e421c196c517c1e8d0473fef5f4b192d9e2455d28108a4d9e5a2edd34f2ab887f9967271592a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -54,6 +54,14 @@ $ puts 10.days.ago
|
|
54
54
|
2024-08-17 15:50:11 -0300
|
55
55
|
```
|
56
56
|
|
57
|
+
### [`quick-commit`](./lib/matheus/quick_commit.rb)
|
58
|
+
|
59
|
+
Commits the staged changes with a generated commit message.
|
60
|
+
|
61
|
+
```sh
|
62
|
+
$ quick-commit
|
63
|
+
```
|
64
|
+
|
57
65
|
## Contributing
|
58
66
|
|
59
67
|
Probably not accepting contributions at the moment, but feel free to open an issue if you have any ideas or suggestions.
|
data/exe/quick-commit
ADDED
data/lib/matheus/command.rb
CHANGED
@@ -5,9 +5,9 @@ module Matheus
|
|
5
5
|
include Result::Methods
|
6
6
|
extend StringFormat
|
7
7
|
|
8
|
-
def self.call(
|
8
|
+
def self.call(...)
|
9
9
|
new
|
10
|
-
.call(
|
10
|
+
.call(...)
|
11
11
|
.then { Result.from(_1) } # ensure it's a Result object
|
12
12
|
.on_failure { |error_msg| abort error(error_msg) }
|
13
13
|
end
|
data/lib/matheus/q.rb
CHANGED
@@ -10,18 +10,18 @@ module Matheus
|
|
10
10
|
class Q < Command
|
11
11
|
BASE_PROMPT = "Answer this question in a short and concise way. You can use markdown in the response: "
|
12
12
|
|
13
|
-
def call(question)
|
13
|
+
def call(*question, skip_cache: false)
|
14
14
|
question = question.join(" ")
|
15
15
|
existing_entry = search_question_in_history(question)
|
16
16
|
|
17
|
-
if existing_entry && use_existing_answer?
|
17
|
+
if existing_entry && use_existing_answer?(skip_cache)
|
18
18
|
answer = existing_entry["answer"]
|
19
19
|
else
|
20
20
|
answer = ask_llm(question)
|
21
21
|
save_qa(question, answer)
|
22
22
|
end
|
23
23
|
|
24
|
-
print_markdown(
|
24
|
+
answer.tap { |it| print_markdown(it) }
|
25
25
|
rescue => e
|
26
26
|
Failure(e.message)
|
27
27
|
end
|
@@ -67,7 +67,9 @@ module Matheus
|
|
67
67
|
load_history.reverse.find { |entry| entry["question"].downcase.strip == question.downcase.strip }
|
68
68
|
end
|
69
69
|
|
70
|
-
def use_existing_answer?
|
70
|
+
def use_existing_answer?(skip_cache)
|
71
|
+
return false if skip_cache
|
72
|
+
|
71
73
|
prompt = TTY::Prompt.new
|
72
74
|
prompt.yes?("An existing answer was found. Do you want to use it?") do |q|
|
73
75
|
q.default true
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Matheus
|
2
|
+
|
3
|
+
class QuickCommit < Command
|
4
|
+
# Usage:
|
5
|
+
# $ quick-commit
|
6
|
+
def call(*)
|
7
|
+
diff = `git diff --cached`
|
8
|
+
return Failure("No changes to commit.") if diff.blank?
|
9
|
+
|
10
|
+
Q.call(["Please write a good one-line commit message for the following diff. Return only plain-text. Diff:\n#{diff}"], skip_cache: true)
|
11
|
+
.on_success { |msg| confirm("Accept commit message?", return_value: msg) }
|
12
|
+
.on_success { |commit_message| system(%(git commit -m "#{commit_message}"), :out => :close) }
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def confirm(message, return_value:)
|
18
|
+
response = TTY::Prompt.new.yes?(message) do |q|
|
19
|
+
q.default true
|
20
|
+
end
|
21
|
+
|
22
|
+
response ? Success(return_value) : Failure("Cancelled by user.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/matheus/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: matheus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matheus Richard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|
@@ -118,6 +118,7 @@ executables:
|
|
118
118
|
- puts
|
119
119
|
- q
|
120
120
|
- qs
|
121
|
+
- quick-commit
|
121
122
|
extensions: []
|
122
123
|
extra_rdoc_files: []
|
123
124
|
files:
|
@@ -133,6 +134,7 @@ files:
|
|
133
134
|
- exe/puts
|
134
135
|
- exe/q
|
135
136
|
- exe/qs
|
137
|
+
- exe/quick-commit
|
136
138
|
- lib/matheus.rb
|
137
139
|
- lib/matheus/alert_me.rb
|
138
140
|
- lib/matheus/command.rb
|
@@ -141,6 +143,7 @@ files:
|
|
141
143
|
- lib/matheus/puts.rb
|
142
144
|
- lib/matheus/q.rb
|
143
145
|
- lib/matheus/qs.rb
|
146
|
+
- lib/matheus/quick_commit.rb
|
144
147
|
- lib/matheus/result.rb
|
145
148
|
- lib/matheus/string_format.rb
|
146
149
|
- lib/matheus/version.rb
|