gpterminal 0.1.0 → 0.1.2
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/README.md +12 -8
- data/lib/client.rb +3 -3
- data/lib/config.rb +0 -3
- data/lib/gpterminal.rb +72 -58
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02a3cd7d8a3c238a428e6485c53423a5395826671bb8ab6e4f948654960badb5
|
4
|
+
data.tar.gz: a9a00538c4ed4ccce09164c38870a885135b6fb50423cb8366d90a40add7fbf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 650b1a3dc9509bf784bfdd9a5dd70b5a62346d26c35983cb051b1b02c7ac57f690718007262147ca05ea62795a0692efd9a2c171e39e0a1a9381c50ee8065141
|
7
|
+
data.tar.gz: 3c3871a02fdf8dce366fb29266ada88fcb5ac3f482062d493d0181e0574e0fd6d86b3397ac9822c552e916f45ef150e3c165c3591690249eddfaebf3b6813db8
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
`gpterminal` is a powerful, flexible and dangerous command-line tool designed to help you generate commands for your terminal using OpenAI's Chat Completions. It will not execute commands without your consent, but please do check which commands it is presenting before you let it execute them. Like so:
|
6
6
|
|
7
7
|
```bash
|
8
|
-
$
|
8
|
+
$ gpterminal "Using git diff to gather info, commit all the latest changes with a descriptive commit message, then push the changes"
|
9
9
|
$ # It gathers info, asks for consent, and does the thing
|
10
10
|
$ [main 94a9292] Update README with gpterminal usage example
|
11
11
|
$ 1 file changed, 4 insertions(+)
|
@@ -13,7 +13,9 @@ $ 1 file changed, 4 insertions(+)
|
|
13
13
|
|
14
14
|
## Getting Started
|
15
15
|
|
16
|
-
|
16
|
+
You can install it from RubyGems using `gem install gpterminal`, or you can clone it and run it straight from the source.
|
17
|
+
|
18
|
+
Ensure you have Ruby installed on your system. Then, follow these steps:
|
17
19
|
|
18
20
|
- Clone the repository or download the source code.
|
19
21
|
- Navigate to the gpterminal directory and run `bundle install` to install dependencies.
|
@@ -25,13 +27,15 @@ On first run, you'll be prompted to enter your OpenAI API key. This is required
|
|
25
27
|
|
26
28
|
## Usage
|
27
29
|
|
28
|
-
gpterminal
|
30
|
+
`gpterminal <prompt> [options] [subcommand [options]]`
|
31
|
+
|
32
|
+
**Subcommands:**
|
33
|
+
|
34
|
+
- `preset` - `gpterminal preset <name> <prompt>`
|
35
|
+
- `config` - `gpterminal config [--openapi_key <value>|--send_path <true|false>]`
|
29
36
|
|
30
|
-
|
31
|
-
|
32
|
-
Without any options, gpterminal will prompt you to enter a text prompt manually.
|
33
|
-
- `-k`, `--key KEY`: Set the OpenAI API key
|
34
|
-
- `-P`, `--send-path`: Send the PATH environment variable to OpenAI.
|
37
|
+
**Options:**
|
38
|
+
`-v`, `--verbose` Run verbosely
|
35
39
|
|
36
40
|
## Presets
|
37
41
|
|
data/lib/client.rb
CHANGED
@@ -79,7 +79,7 @@ class Client
|
|
79
79
|
|
80
80
|
response = openapi_client.chat(
|
81
81
|
parameters: {
|
82
|
-
model: "gpt-
|
82
|
+
model: "gpt-4-turbo-preview",
|
83
83
|
messages: @messages,
|
84
84
|
temperature: 0.6,
|
85
85
|
}
|
@@ -108,7 +108,7 @@ class Client
|
|
108
108
|
|
109
109
|
response = openapi_client.chat(
|
110
110
|
parameters: {
|
111
|
-
model: "gpt-4",
|
111
|
+
model: "gpt-4-turbo-preview",
|
112
112
|
messages: @messages,
|
113
113
|
temperature: 0.6,
|
114
114
|
}
|
@@ -151,7 +151,7 @@ class Client
|
|
151
151
|
|
152
152
|
response = openapi_client.chat(
|
153
153
|
parameters: {
|
154
|
-
model: "gpt-4",
|
154
|
+
model: "gpt-4-turbo-preview",
|
155
155
|
messages: @messages,
|
156
156
|
temperature: 0.6,
|
157
157
|
}
|
data/lib/config.rb
CHANGED
data/lib/gpterminal.rb
CHANGED
@@ -12,7 +12,22 @@ class GPTerminal
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def run
|
15
|
-
|
15
|
+
puts "gpterminal has been renamed to gpterm. Please use gpterm instead. Exiting...".colorize(:red)
|
16
|
+
exit
|
17
|
+
if @options[:preset_prompt]
|
18
|
+
name = @options[:preset_prompt][0]
|
19
|
+
prompt = @options[:preset_prompt][1]
|
20
|
+
AppConfig.add_preset(@config, name, prompt)
|
21
|
+
puts "Preset prompt '#{name}' saved with prompt '#{prompt}'".colorize(:green)
|
22
|
+
exit
|
23
|
+
elsif @options[:prompt]
|
24
|
+
start_prompt(@options[:prompt])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def start_prompt(prompt)
|
16
31
|
message = @client.first_prompt(prompt)
|
17
32
|
|
18
33
|
if message.downcase == '$$cannot_compute$$'
|
@@ -77,20 +92,18 @@ class GPTerminal
|
|
77
92
|
puts output
|
78
93
|
end
|
79
94
|
|
80
|
-
private
|
81
|
-
|
82
95
|
def load_config
|
83
96
|
unless File.exist?(AppConfig::CONFIG_FILE)
|
84
97
|
puts 'Welcome to GPTerminal! It looks like this is your first time using this application.'.colorize(:magenta)
|
85
98
|
|
86
99
|
new_config = {}
|
87
|
-
|
100
|
+
puts "Before we get started, we need to configure the application. All the info you provide will be saved in #{AppConfig::CONFIG_FILE}.".colorize(:magenta)
|
88
101
|
|
89
|
-
|
102
|
+
puts "Enter your OpenAI API key's \"SECRET KEY\" value: ".colorize(:yellow)
|
90
103
|
new_config['openapi_key'] = STDIN.gets.chomp
|
91
104
|
|
92
|
-
|
93
|
-
|
105
|
+
puts "Your PATH environment variable is: #{ENV['PATH']}".colorize(:magenta)
|
106
|
+
puts 'Are you happy for your PATH to be sent to OpenAI to help with command generation? (Y/n) '.colorize(:yellow)
|
94
107
|
|
95
108
|
if STDIN.gets.chomp.downcase == 'y'
|
96
109
|
new_config['send_path'] = true
|
@@ -108,66 +121,67 @@ class GPTerminal
|
|
108
121
|
|
109
122
|
def parse_options
|
110
123
|
options = {}
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
124
|
+
subcommands = {
|
125
|
+
'preset' => {
|
126
|
+
option_parser: OptionParser.new do |opts|
|
127
|
+
opts.banner = "gpterminal preset <name> <prompt>"
|
128
|
+
end,
|
129
|
+
argument_parser: ->(args) {
|
130
|
+
if args.length < 2
|
131
|
+
options[:prompt] = @config['presets'][args[0]]
|
132
|
+
else
|
133
|
+
options[:preset_prompt] = [args[0], args[1]]
|
134
|
+
end
|
135
|
+
}
|
136
|
+
},
|
137
|
+
'config' => {
|
138
|
+
option_parser: OptionParser.new do |opts|
|
139
|
+
opts.banner = "gpterminal config [--openapi_key <value>|--send_path <true|false>]"
|
140
|
+
opts.on("--openapi_key VALUE", "Set the OpenAI API key") do |v|
|
141
|
+
AppConfig.add_openapi_key(@config, v)
|
142
|
+
puts "OpenAI API key saved"
|
143
|
+
exit
|
144
|
+
end
|
145
|
+
opts.on("--send_path", "Send the PATH environment variable to OpenAI") do
|
146
|
+
@config['send_path'] = true
|
147
|
+
AppConfig.save_config(@config)
|
148
|
+
puts "Your PATH environment variable will be sent to OpenAI to help with command generation"
|
149
|
+
exit
|
150
|
+
end
|
151
|
+
end
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
main = OptionParser.new do |opts|
|
156
|
+
opts.banner = "Usage:"
|
157
|
+
opts.banner += "\n\ngpterminal <prompt> [options] [subcommand [options]]"
|
158
|
+
opts.banner += "\n\nSubcommands:"
|
159
|
+
subcommands.each do |name, subcommand|
|
160
|
+
opts.banner += "\n #{name} - #{subcommand[:option_parser].banner}"
|
120
161
|
end
|
121
|
-
|
122
|
-
opts.on("-
|
123
|
-
|
124
|
-
exit
|
162
|
+
opts.banner += "\n\nOptions:"
|
163
|
+
opts.on("-v", "--verbose", "Run verbosely") do |v|
|
164
|
+
options[:verbose] = true
|
125
165
|
end
|
126
|
-
|
127
|
-
opts.on("-k", "--key KEY", "Set the OpenAI API key") do |v|
|
128
|
-
AppConfig.add_openapi_key(@config, v)
|
129
|
-
puts "OpenAI API key saved"
|
130
|
-
exit
|
131
|
-
end
|
132
|
-
|
133
|
-
opts.on("-P", "--send-path", "Send the PATH environment variable to OpenAI") do
|
134
|
-
@config['send_path'] = true
|
135
|
-
AppConfig.save_config(@config)
|
136
|
-
puts "Your PATH environment variable will be sent to OpenAI to help with command generation"
|
137
|
-
exit
|
138
|
-
end
|
139
|
-
end.parse!
|
140
|
-
|
141
|
-
options
|
142
|
-
end
|
143
|
-
|
144
|
-
def determine_prompt
|
145
|
-
if @options[:preset_prompt]
|
146
|
-
name = @options[:preset_prompt][0]
|
147
|
-
prompt = @options[:preset_prompt][1]
|
148
|
-
AppConfig.add_preset(@config, name, prompt)
|
149
|
-
puts "Preset prompt '#{name}' saved with prompt '#{prompt}'".colorize(:green)
|
150
|
-
exit
|
151
166
|
end
|
152
167
|
|
153
|
-
|
154
|
-
# collect a prompt from the preset prompts
|
155
|
-
prompt = @config['presets'][ARGV[0]]
|
156
|
-
|
157
|
-
unless prompt
|
158
|
-
puts "Preset prompt not found: #{ARGV[0]}".colorize(:red)
|
159
|
-
exit
|
160
|
-
end
|
168
|
+
command = ARGV.shift
|
161
169
|
|
162
|
-
|
163
|
-
|
164
|
-
|
170
|
+
main.order!
|
171
|
+
if subcommands.key?(command)
|
172
|
+
subcommands[command][:option_parser].parse!
|
173
|
+
subcommands[command][:argument_parser].call(ARGV) if subcommands[command][:argument_parser]
|
174
|
+
elsif command == 'help'
|
175
|
+
puts main
|
176
|
+
exit
|
177
|
+
elsif command
|
178
|
+
options[:prompt] = command
|
165
179
|
else
|
166
180
|
puts 'Enter a prompt to generate text from:'.colorize(:yellow)
|
167
|
-
prompt = STDIN.gets.chomp
|
181
|
+
options[:prompt] = STDIN.gets.chomp
|
168
182
|
end
|
169
183
|
|
170
|
-
|
184
|
+
options
|
171
185
|
end
|
172
186
|
|
173
187
|
def offer_more_information(output)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gpterminal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Hough
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-openai
|
@@ -24,8 +24,8 @@ dependencies:
|
|
24
24
|
- - "<"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '7'
|
27
|
-
description: gpterminal
|
28
|
-
|
27
|
+
description: "[DEPRECATED] gpterminal has been renamed to gpterm. Please use the gpterm
|
28
|
+
gem instead."
|
29
29
|
email:
|
30
30
|
- daniel.hough@gmail.com
|
31
31
|
executables:
|
@@ -39,12 +39,12 @@ files:
|
|
39
39
|
- lib/client.rb
|
40
40
|
- lib/config.rb
|
41
41
|
- lib/gpterminal.rb
|
42
|
-
homepage: https://github.com/basicallydan/
|
42
|
+
homepage: https://github.com/basicallydan/gpterm
|
43
43
|
licenses:
|
44
44
|
- MIT
|
45
45
|
metadata:
|
46
|
-
homepage_uri: https://github.com/basicallydan/
|
47
|
-
source_code_uri: https://github.com/basicallydan/
|
46
|
+
homepage_uri: https://github.com/basicallydan/gpterm
|
47
|
+
source_code_uri: https://github.com/basicallydan/gpterm
|
48
48
|
post_install_message:
|
49
49
|
rdoc_options: []
|
50
50
|
require_paths:
|
@@ -63,5 +63,6 @@ requirements: []
|
|
63
63
|
rubygems_version: 3.5.3
|
64
64
|
signing_key:
|
65
65
|
specification_version: 4
|
66
|
-
summary:
|
66
|
+
summary: "[DEPRECATED] gpterminal has been renamed to gpterm. Please use the gpterm
|
67
|
+
gem instead."
|
67
68
|
test_files: []
|