mj 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59cf5e3a74d7c41f0b5b2c3789d85987b3393eccd110dc4741a3bdff59058827
4
- data.tar.gz: c0772655f097653bbbd719e1791791e97bd30349973febf410ae54be24f470ae
3
+ metadata.gz: 40c3258afb7e8d688b06de487bb9286f0acb6999355a7156b099a77095206cc5
4
+ data.tar.gz: 301506dcf36dee5629e0912a6fd5d89e6d130f73daab6255a86aefc802e14763
5
5
  SHA512:
6
- metadata.gz: 5f385ad6f1354b967cde4c98e63b96b1e918c406bd6009e676bac8d61f30f4df1ebffe73d3b34ac35c246f383338b0224cf7bf1d3d606176fe7f3ac95d40df74
7
- data.tar.gz: 4ce923b46dbf190b9b233512fae4fc9163a7853926e29aa4e7f9f3cfad1ddfd274be89f0c1052b4dcaa4bde42deced0cf9e7cf3ce425154153b2dc2212202c74
6
+ metadata.gz: 32a385ff987a4ff7ebb24b4b4329bdbbe018194e976aea69c4dc650cf66679e690d609550f8be34a914adb480a82751241d1f4090921a8319176bcacb3a0c6c5
7
+ data.tar.gz: b2ef3335c6cab5e6d6da130755130f07b5e829dd1a703e6f4ecda2a5b8098a61c427d18a68923ff262a352b0ac7b15cbbc53b655a7211f0d0be891d2e51e75cf
data/Gemfile CHANGED
@@ -16,3 +16,4 @@ gem "rubocop-rake"
16
16
  gem "rubocop-rspec"
17
17
  gem "simplecov", require: false
18
18
  gem "simplecov-lcov", require: false
19
+ gem "uri", "~> 0.13"
data/Gemfile.lock CHANGED
@@ -1,84 +1,120 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mj (0.7.0)
4
+ mj (0.9.0)
5
+ colorize
5
6
  koine-rest_client
7
+ mj-hash_utils
8
+ ruby-openai (~> 6.2.0)
6
9
  thor (~> 1.2.1)
10
+ uri (~> 0.13.0)
7
11
 
8
12
  GEM
9
13
  remote: https://rubygems.org/
10
14
  specs:
11
- addressable (2.8.6)
12
- public_suffix (>= 2.0.2, < 6.0)
15
+ addressable (2.8.7)
16
+ public_suffix (>= 2.0.2, < 7.0)
13
17
  ast (2.4.2)
14
18
  awesome_print (1.9.2)
19
+ bigdecimal (3.1.8)
15
20
  coderay (1.1.3)
16
- diff-lcs (1.5.0)
17
- docile (1.4.0)
18
- httparty (0.21.0)
21
+ colorize (1.1.0)
22
+ csv (3.3.0)
23
+ diff-lcs (1.5.1)
24
+ docile (1.4.1)
25
+ event_stream_parser (0.3.0)
26
+ faraday (2.10.1)
27
+ faraday-net_http (>= 2.0, < 3.2)
28
+ logger
29
+ faraday-multipart (1.0.4)
30
+ multipart-post (~> 2)
31
+ faraday-net_http (3.1.1)
32
+ net-http
33
+ httparty (0.22.0)
34
+ csv
19
35
  mini_mime (>= 1.0.0)
20
36
  multi_xml (>= 0.5.2)
37
+ json (2.7.2)
21
38
  koine-rest_client (1.1.1)
22
39
  addressable (>= 2.3)
23
40
  httparty (>= 0.17.0)
24
41
  koine-test_runner (0.4.0)
25
- method_source (1.0.0)
42
+ language_server-protocol (3.17.0.3)
43
+ logger (1.6.0)
44
+ method_source (1.1.0)
26
45
  mini_mime (1.1.5)
27
- multi_xml (0.6.0)
28
- parallel (1.21.0)
29
- parser (3.1.1.0)
46
+ mj-hash_utils (0.1.0)
47
+ multi_xml (0.7.1)
48
+ bigdecimal (~> 3.1)
49
+ multipart-post (2.4.1)
50
+ net-http (0.4.1)
51
+ uri
52
+ parallel (1.26.1)
53
+ parser (3.3.4.2)
30
54
  ast (~> 2.4.1)
55
+ racc
31
56
  pry (0.14.2)
32
57
  coderay (~> 1.1)
33
58
  method_source (~> 1.0)
34
- public_suffix (5.0.4)
59
+ public_suffix (6.0.1)
60
+ racc (1.8.1)
35
61
  rainbow (3.1.1)
36
- rake (13.0.6)
37
- regexp_parser (2.2.1)
38
- rexml (3.2.5)
39
- rspec (3.11.0)
40
- rspec-core (~> 3.11.0)
41
- rspec-expectations (~> 3.11.0)
42
- rspec-mocks (~> 3.11.0)
43
- rspec-core (3.11.0)
44
- rspec-support (~> 3.11.0)
45
- rspec-expectations (3.11.0)
62
+ rake (13.2.1)
63
+ regexp_parser (2.9.2)
64
+ rexml (3.3.4)
65
+ strscan
66
+ rspec (3.13.0)
67
+ rspec-core (~> 3.13.0)
68
+ rspec-expectations (~> 3.13.0)
69
+ rspec-mocks (~> 3.13.0)
70
+ rspec-core (3.13.0)
71
+ rspec-support (~> 3.13.0)
72
+ rspec-expectations (3.13.1)
46
73
  diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.11.0)
48
- rspec-mocks (3.11.0)
74
+ rspec-support (~> 3.13.0)
75
+ rspec-mocks (3.13.1)
49
76
  diff-lcs (>= 1.2.0, < 2.0)
50
- rspec-support (~> 3.11.0)
51
- rspec-support (3.11.0)
52
- rubocop (1.25.1)
77
+ rspec-support (~> 3.13.0)
78
+ rspec-support (3.13.1)
79
+ rubocop (1.65.1)
80
+ json (~> 2.3)
81
+ language_server-protocol (>= 3.17.0)
53
82
  parallel (~> 1.10)
54
- parser (>= 3.1.0.0)
83
+ parser (>= 3.3.0.2)
55
84
  rainbow (>= 2.2.2, < 4.0)
56
- regexp_parser (>= 1.8, < 3.0)
57
- rexml
58
- rubocop-ast (>= 1.15.1, < 2.0)
85
+ regexp_parser (>= 2.4, < 3.0)
86
+ rexml (>= 3.2.5, < 4.0)
87
+ rubocop-ast (>= 1.31.1, < 2.0)
59
88
  ruby-progressbar (~> 1.7)
60
- unicode-display_width (>= 1.4.0, < 3.0)
61
- rubocop-ast (1.16.0)
62
- parser (>= 3.1.1.0)
63
- rubocop-performance (1.13.2)
64
- rubocop (>= 1.7.0, < 2.0)
65
- rubocop-ast (>= 0.4.0)
89
+ unicode-display_width (>= 2.4.0, < 3.0)
90
+ rubocop-ast (1.32.0)
91
+ parser (>= 3.3.1.0)
92
+ rubocop-performance (1.21.1)
93
+ rubocop (>= 1.48.1, < 2.0)
94
+ rubocop-ast (>= 1.31.1, < 2.0)
66
95
  rubocop-rake (0.6.0)
67
96
  rubocop (~> 1.0)
68
- rubocop-rspec (2.9.0)
69
- rubocop (~> 1.19)
70
- ruby-progressbar (1.11.0)
71
- simplecov (0.21.2)
97
+ rubocop-rspec (3.0.4)
98
+ rubocop (~> 1.61)
99
+ ruby-openai (6.2.0)
100
+ event_stream_parser (>= 0.3.0, < 1.0.0)
101
+ faraday (>= 1)
102
+ faraday-multipart (>= 1)
103
+ ruby-progressbar (1.13.0)
104
+ simplecov (0.22.0)
72
105
  docile (~> 1.1)
73
106
  simplecov-html (~> 0.11)
74
107
  simplecov_json_formatter (~> 0.1)
75
108
  simplecov-html (0.12.3)
76
109
  simplecov-lcov (0.8.0)
77
110
  simplecov_json_formatter (0.1.4)
111
+ strscan (3.1.0)
78
112
  thor (1.2.2)
79
- unicode-display_width (2.1.0)
113
+ unicode-display_width (2.5.0)
114
+ uri (0.13.0)
80
115
 
81
116
  PLATFORMS
117
+ arm64-darwin-23
82
118
  ruby
83
119
 
84
120
  DEPENDENCIES
@@ -94,6 +130,7 @@ DEPENDENCIES
94
130
  rubocop-rspec
95
131
  simplecov
96
132
  simplecov-lcov
133
+ uri (~> 0.13)
97
134
 
98
135
  BUNDLED WITH
99
- 2.3.16
136
+ 2.5.17
data/README.md CHANGED
@@ -16,11 +16,11 @@ gem 'mj'
16
16
 
17
17
  And then execute:
18
18
 
19
- $ bundle install
19
+ bundle install
20
20
 
21
21
  Or install it yourself as:
22
22
 
23
- $ gem install mj
23
+ gem install mj
24
24
 
25
25
  ## Usage
26
26
 
@@ -28,6 +28,72 @@ Or install it yourself as:
28
28
  mj help
29
29
  ```
30
30
 
31
+ ### Git
32
+
33
+ ```
34
+ bundle exec mj git checkout partial-branch-name # it will create a local branch if that is remote only
35
+ bundle exec mj git checkout partial-branch-name --dry-run # if you want to see the command before executing
36
+ ```
37
+
38
+ ```
39
+
40
+ ### ChatGPT
41
+
42
+ ```
43
+
44
+ bundle exec mj chatgpt ask "Who won the World Cup in 1994?" --request-file samples/chatgpt/football-team.yml | jq
45
+
46
+ ```
47
+
48
+ Where the config file looks like:
49
+
50
+ ```yaml
51
+ request:
52
+ parameters:
53
+ model: gpt-3.5-turbo-16k
54
+ temperature: 0.1
55
+ messages:
56
+ - role: system
57
+ content: You re an expert in futebool history.
58
+ ```
59
+
60
+ Response:
61
+
62
+ ```json
63
+ {
64
+ "id": "chatcmpl-90a0HhlOIqYkMPRbuICPy5m798yjQ",
65
+ "object": "chat.completion",
66
+ "created": 1709925425,
67
+ "model": "gpt-3.5-turbo-16k-0613",
68
+ "choices": [
69
+ {
70
+ "index": 0,
71
+ "message": {
72
+ "role": "assistant",
73
+ "content": "The World Cup in 1994 was won by the Brazilian national team. They defeated Italy in the final match, which was held at the Rose Bowl stadium in Pasadena, California, United States. The match ended in a 0-0 draw after extra time, and Brazil won the penalty shootout 3-2 to claim their fourth World Cup title."
74
+ },
75
+ "logprobs": null,
76
+ "finish_reason": "stop"
77
+ }
78
+ ],
79
+ "usage": {
80
+ "prompt_tokens": 31,
81
+ "completion_tokens": 71,
82
+ "total_tokens": 102
83
+ },
84
+ "system_fingerprint": null
85
+ }
86
+ ```
87
+
88
+ You can also do `jq '.choices[0].message.content'`:
89
+
90
+ ```sh
91
+ mj chatgpt ask "Who won the World Cup in 1994?" \
92
+ --config-file samples/chatgpt/football-team.yml | jq '.choices[0].message.content'
93
+
94
+ # "The World Cup in 1994 was won by the Brazilian national team. They defeated Italy in the final match, which was held at the Rose Bowl stadium in Pasadena, California, United States. The match ended in a 0-0 draw after extra time, and Brazil won the penalty shootout 3-2 to claim their fourth World Cup title."
95
+ ```
96
+
31
97
  ### GraphQl
32
98
 
33
99
  ```
@@ -40,8 +106,7 @@ Your graqphql fiel is a regular file with variables at the top:
40
106
  # gql-endpoint: http://api.myapi.me/graphql
41
107
  # gql-header: Authorization: Bearer cb923f33617877578961a19cf4566ec2
42
108
  # gql-header: Content-Type: application/json
43
- # gql-header: Cookie: ajs_user_id=ae3948ee-345e-47f2-8e2f-54277858e2c2; ajs_anonymous_id=30880a34-276e-4a86-a1d3-8869d1669199; _ga=GA1.1.649149230.1706868690; browser_id=14af87a406ec54cbe9804ea25c8f0a84; _ga_TZKSP5TS45=GS1.1.1708606615.26.1.1708606911.0.0.0
44
- # gql-variables: { "input": { "id": "yTXuIgoU88LKUNDLSVPFFjOSkgxlyyuSrNki3GY=" } }
109
+ # gql-variables: { "input": { "id": "some-id" } }
45
110
 
46
111
  query QueryAccountUsers(
47
112
  $input: AccountInput!
@@ -59,7 +124,6 @@ query QueryAccountUsers(
59
124
  }
60
125
  ```
61
126
 
62
-
63
127
  ### Alternative file
64
128
 
65
129
  Examples:
@@ -126,7 +190,6 @@ end
126
190
 
127
191
  This way I can use `<leader>a{direction}`, where `k` is `next`, and `j` is `previous` alternative file.
128
192
 
129
-
130
193
  ## Development
131
194
 
132
195
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -135,7 +198,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
135
198
 
136
199
  ## Contributing
137
200
 
138
- Bug reports and pull requests are welcome on GitHub at https://github.com/mjacobus/mj. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/mjacobus/mj/blob/main/CODE_OF_CONDUCT.md).
201
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/mjacobus/mj>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/mjacobus/mj/blob/main/CODE_OF_CONDUCT.md).
139
202
 
140
203
  ## License
141
204
 
@@ -13,10 +13,8 @@ module Mj
13
13
 
14
14
  def resolve(file)
15
15
  file = AlternativeFile::CurrentFile.new(file.to_s)
16
- resolved = []
17
-
18
- @stack.each do |resolver|
19
- resolved.push(resolver.resolve(file))
16
+ resolved = @stack.map do |resolver|
17
+ resolver.resolve(file)
20
18
  end
21
19
 
22
20
  AlternativeFile::Candidates.new(resolved.flatten.compact)
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mj
4
+ module ChatGpt
5
+ module Commands
6
+ class AskCommand
7
+ attr_reader :question
8
+ attr_reader :options
9
+
10
+ def initialize(question, options: {})
11
+ @question = question
12
+ @options = options
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "openai"
4
+ require_relative "../request"
5
+
6
+ module Mj
7
+ module ChatGpt
8
+ module Commands
9
+ class AskCommandHandler
10
+ def initialize(client:)
11
+ @client = client
12
+ end
13
+
14
+ def handle(command)
15
+ request = Request.from_config_file(command.options.fetch("config_file"))
16
+ @client.chat(**request.asking(command.question).to_h)
17
+ rescue Faraday::Error => exception
18
+ {
19
+ error: exception.message,
20
+ body: exception.response&.dig(:body, "error") || exception.response
21
+ }
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mj
4
+ module ChatGpt
5
+ class Request
6
+ def initialize(data = {})
7
+ @data = HashUtils.new.deep_symbolize_keys(data)
8
+ end
9
+
10
+ def asking(question)
11
+ data = @data.dup
12
+ data[:parameters] ||= {}
13
+ data[:parameters][:messages] ||= []
14
+ data[:parameters][:messages] << {
15
+ role: :user,
16
+ content: question
17
+ }
18
+ self.class.new(data)
19
+ end
20
+
21
+ def to_h
22
+ @data
23
+ end
24
+
25
+ def self.from_config_file(file)
26
+ data = YAML.load_file(file)
27
+ new(data.fetch("request"))
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "commands/ask_command_handler"
4
+ require_relative "commands/ask_command"
5
+
6
+ module Mj
7
+ module ChatGpt
8
+ class ThorCommand < Thor
9
+ desc "ask <question>", "Ask ChatGPT a question"
10
+ option :config_file, type: :string, desc: "Config file"
11
+ def ask(question)
12
+ client_config = {
13
+ access_token: ENV.fetch("OPENAI_ACCESS_TOKEN")
14
+ }
15
+ client = OpenAI::Client.new(**client_config.compact)
16
+ handler = Commands::AskCommandHandler.new(client: client)
17
+ data = handler.handle(Commands::AskCommand.new(question, options: options))
18
+ $stdout.puts JSON.generate(data)
19
+ end
20
+ end
21
+ end
22
+ end
data/lib/mj/cli.rb CHANGED
@@ -4,6 +4,8 @@ require "thor"
4
4
  require_relative "version"
5
5
  require_relative "alternative_file/thor_command"
6
6
  require_relative "graphql/thor_command"
7
+ require_relative "chatgpt/thor_command"
8
+ require_relative "git/thor_command"
7
9
 
8
10
  module Mj
9
11
  class Cli < Thor
@@ -21,5 +23,11 @@ module Mj
21
23
 
22
24
  desc "graphql", "CLI client for GraphQL"
23
25
  subcommand "graphql", GraphQL::ThorCommand
26
+
27
+ desc "chatgpt", "CLI client for ChatGPT"
28
+ subcommand "chatgpt", ChatGpt::ThorCommand
29
+
30
+ desc "git", "Git utilities"
31
+ subcommand "git", Git::ThorCommand
24
32
  end
25
33
  end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "local_branch"
4
+ require_relative "remote_branch"
5
+
6
+ module Mj
7
+ module Git
8
+ class Branches
9
+ include Enumerable
10
+
11
+ def self.from_branch_names(branch_names)
12
+ branches = branch_names.map do |branch|
13
+ branch = branch.sub("*", "").strip
14
+
15
+ if branch.start_with?("remotes/")
16
+ next RemoteBranch.new(branch)
17
+ end
18
+
19
+ next LocalBranch.new(branch)
20
+ end
21
+
22
+ new(branches)
23
+ end
24
+
25
+ def to_local
26
+ self.class.new(map(&:to_local))
27
+ end
28
+
29
+ def uniq
30
+ branches = {}
31
+ each do |branch|
32
+ branches[branch.name] ||= branch
33
+ end
34
+
35
+ self.class.new(branches.values)
36
+ end
37
+
38
+ def initialize(branches)
39
+ @branches = branches
40
+ end
41
+
42
+ def each(&block)
43
+ @branches.each(&block)
44
+ end
45
+
46
+ def length
47
+ @branches.length
48
+ end
49
+
50
+ def matching(pattern)
51
+ self.class.new(@branches.select { |branch| branch.name.match?(pattern) })
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "open3"
4
+
5
+ module Mj
6
+ module Git
7
+ class CommandExecuter
8
+ Error = Class.new(RuntimeError)
9
+
10
+ def execute(command)
11
+ stdout_str, stderr_str, status = Open3.capture3(command)
12
+
13
+ if status.success?
14
+ return stdout_str.split("\n")
15
+ end
16
+
17
+ raise Error, "Command '#{command}' exited with (#{status.exitstatus}): #{stderr_str.strip}"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mj
4
+ module Git
5
+ module Commands
6
+ class CheckoutCommand
7
+ attr_reader :branch
8
+
9
+ def initialize(branch:, options: {})
10
+ @branch = branch
11
+ @options = options
12
+ end
13
+
14
+ def dry_run?
15
+ @options[:dry_run]
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../branches"
4
+ require "colorize"
5
+
6
+ module Mj
7
+ module Git
8
+ module Commands
9
+ class CheckoutCommandHandler
10
+ def initialize(stdout:, command_executer: CommandExecuter.new)
11
+ @stdout = stdout
12
+ @command_executer = command_executer
13
+ end
14
+
15
+ def handle(command)
16
+ branches = @command_executer.execute("git branch -a")
17
+ branches = Git::Branches.from_branch_names(branches).matching(command.branch)
18
+
19
+ if branches.to_local.uniq.length > 1
20
+ warn_multiple_matches(branches)
21
+ end
22
+
23
+ winner = branches.min_by(&:length)
24
+
25
+ puts(winner.checkout_command, color: :green)
26
+
27
+ if command.dry_run?
28
+ return
29
+ end
30
+
31
+ @command_executer.execute(winner.checkout_command)
32
+ end
33
+
34
+ private
35
+
36
+ def warn_multiple_matches(branches)
37
+ puts("Multiple branches found:", color: :blue)
38
+
39
+ branches.each do |branch|
40
+ puts("\t#{branch.name}", color: :yellow)
41
+ end
42
+ puts("\n")
43
+ end
44
+
45
+ def puts(string, color: nil)
46
+ if color
47
+ string = string.colorize(color)
48
+ end
49
+
50
+ @stdout.puts(string)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mj
4
+ module Git
5
+ class LocalBranch
6
+ attr_reader :name
7
+
8
+ def initialize(name)
9
+ @name = name
10
+ end
11
+
12
+ def length
13
+ @name.length
14
+ end
15
+
16
+ def checkout_command
17
+ "git checkout #{name}"
18
+ end
19
+
20
+ def to_local
21
+ self
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mj
4
+ module Git
5
+ class RemoteBranch
6
+ attr_reader :name
7
+
8
+ def initialize(name)
9
+ @name = name
10
+ end
11
+
12
+ def checkout_command
13
+ "git checkout -b #{local_branch_name} #{name}"
14
+ end
15
+
16
+ def length
17
+ @name.length
18
+ end
19
+
20
+ def to_local
21
+ LocalBranch.new(local_branch_name)
22
+ end
23
+
24
+ private
25
+
26
+ def local_branch_name
27
+ pattern = %r{^remotes/\w+/}
28
+ name.sub(pattern, "")
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "commands/checkout_command_handler"
4
+ require_relative "commands/checkout_command"
5
+ require_relative "command_executer"
6
+
7
+ module Mj
8
+ module Git
9
+ class ThorCommand < Thor
10
+ desc "checkout <branch>", "Partial branch"
11
+ option :dry_run, type: :boolean, banner: "Just outputs, does not checkout", aliases: :d
12
+ def checkout(branch)
13
+ command = Commands::CheckoutCommand.new(branch: branch, options: options)
14
+ handler = Commands::CheckoutCommandHandler.new(stdout: $stdout)
15
+ handler.handle(command)
16
+ end
17
+ end
18
+ end
19
+ end
data/lib/mj/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mj
4
- VERSION = "0.7.0"
4
+ VERSION = "0.9.0"
5
5
  end
data/lib/mj.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "mj/version"
4
4
  require_relative "mj/cli"
5
+ require "mj/hash_utils"
5
6
 
6
7
  module Mj
7
8
  class Error < StandardError; end
data/mj.gemspec CHANGED
@@ -31,8 +31,12 @@ Gem::Specification.new do |spec|
31
31
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
32
  spec.require_paths = ["lib"]
33
33
 
34
+ spec.add_dependency "colorize"
34
35
  spec.add_dependency "koine-rest_client"
36
+ spec.add_dependency "mj-hash_utils"
37
+ spec.add_dependency "ruby-openai", "~> 6.2.0"
35
38
  spec.add_dependency "thor", "~> 1.2.1"
39
+ spec.add_dependency "uri", "~> 0.13.0"
36
40
 
37
41
  # For more information and examples about making a new gem, check out our
38
42
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -0,0 +1,10 @@
1
+ # samples/chatgpt/football-team.yml
2
+ # usage: bundle exec mj chatgpt ask "Who won the World Cup in 1994?" --config-file samples/chatgpt/football-team.yml | jq
3
+ request:
4
+ parameters:
5
+ model: gpt-3.5-turbo-16k
6
+ temperature: 0.1
7
+ max_tokens: 8192
8
+ messages:
9
+ - role: system
10
+ content: You re an expert in futebool history.
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Jacobus
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-22 00:00:00.000000000 Z
11
+ date: 2024-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: koine-rest_client
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +38,34 @@ dependencies:
24
38
  - - ">="
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mj-hash_utils
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ruby-openai
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 6.2.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 6.2.0
27
69
  - !ruby/object:Gem::Dependency
28
70
  name: thor
29
71
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +80,20 @@ dependencies:
38
80
  - - "~>"
39
81
  - !ruby/object:Gem::Version
40
82
  version: 1.2.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: uri
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.13.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.13.0
41
97
  description: A collection of useful commands for my personal use
42
98
  email:
43
99
  - marcelo.jacobus@gmail.com
@@ -72,7 +128,18 @@ files:
72
128
  - lib/mj/alternative_file/resolvers/ruby/vendored_gems_resolver.rb
73
129
  - lib/mj/alternative_file/resolvers/ruby/view_component_resolver.rb
74
130
  - lib/mj/alternative_file/thor_command.rb
131
+ - lib/mj/chatgpt/commands/ask_command.rb
132
+ - lib/mj/chatgpt/commands/ask_command_handler.rb
133
+ - lib/mj/chatgpt/request.rb
134
+ - lib/mj/chatgpt/thor_command.rb
75
135
  - lib/mj/cli.rb
136
+ - lib/mj/git/branches.rb
137
+ - lib/mj/git/command_executer.rb
138
+ - lib/mj/git/commands/checkout_command.rb
139
+ - lib/mj/git/commands/checkout_command_handler.rb
140
+ - lib/mj/git/local_branch.rb
141
+ - lib/mj/git/remote_branch.rb
142
+ - lib/mj/git/thor_command.rb
76
143
  - lib/mj/graphql/client.rb
77
144
  - lib/mj/graphql/commands/query_file_command.rb
78
145
  - lib/mj/graphql/commands/query_file_command_handler.rb
@@ -81,6 +148,7 @@ files:
81
148
  - lib/mj/graphql/thor_command.rb
82
149
  - lib/mj/version.rb
83
150
  - mj.gemspec
151
+ - samples/chatgpt/football-team.yml
84
152
  - sig/mj.rbs
85
153
  homepage: https://github.com/mjacobus/mj
86
154
  licenses: