ai_refactor 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +22 -4
- data/lib/ai_refactor/base_refactor.rb +8 -12
- data/lib/ai_refactor/refactors/generic.rb +0 -4
- data/lib/ai_refactor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aae248c6a2c5342ea8990e2a672b455c48ec79645e8d88eb20f9afc1af9e7cce
|
4
|
+
data.tar.gz: f86584d15b6467600be12797e4f34bf4ce4545ad6be3bbaef8f9ce62817dd66f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4d1aa38dc497acd25038229da1fe3e46bcbb4dd26cf33770f2bfe1a8a44a48c656023a2b9342a0b81c9fb620ecc4bc28dba215ef2225da8e5e22b13a8d73d92
|
7
|
+
data.tar.gz: e1a7e38d44b83b81da06dcb684e8ce61532fe37818c1e4c41f14451923cd9ad9c3f78092fba5b0fe65e316c1fe75681bf34b81501d2f99694a6ceb85826cede3
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -11,8 +11,9 @@ This is based on the assumption that the LLM AIs are pretty good at identifying
|
|
11
11
|
|
12
12
|
Currently available:
|
13
13
|
|
14
|
-
- `
|
15
|
-
- `
|
14
|
+
- `rspec_to_minitest_rails`: convert RSpec specs to minitest tests in Rails apps
|
15
|
+
- `generic`: provide your own prompt for the AI and run against the input files
|
16
|
+
|
16
17
|
|
17
18
|
### `rspec_to_minitest_rails`
|
18
19
|
|
@@ -47,7 +48,20 @@ Done processing all files!
|
|
47
48
|
|
48
49
|
Applies the refactor specified by prompting the AI with the user supplied prompt. You must supply a prompt file with the `-p` option.
|
49
50
|
|
50
|
-
The output is written to `stdout
|
51
|
+
The output is written to `stdout`, or to a file with the `--output` option. If `--output` is used without a value it overwrites the input.
|
52
|
+
|
53
|
+
You can also output to a file using a template, `--output-template` to determine the output file name given a template string:
|
54
|
+
|
55
|
+
The template is used to create the output name, where the it can have substitutions, '[FILE]', '[NAME]', '[DIR]', '[REFACTOR]' & '[EXT]'.
|
56
|
+
|
57
|
+
Eg `--output-template "[DIR]/[NAME]_[REFACTOR][EXT]"`
|
58
|
+
|
59
|
+
eg for the input `my_dir/my_class.rb`
|
60
|
+
- `[FILE]`: `my_class.rb`
|
61
|
+
- `[NAME]`: `my_class`
|
62
|
+
- `[DIR]`: `my_dir`
|
63
|
+
- `[REFACTOR]`: `generic`
|
64
|
+
- `[EXT]`: `.rb`
|
51
65
|
|
52
66
|
## Installation
|
53
67
|
|
@@ -66,7 +80,7 @@ See `ai_refactor --help` for more information.
|
|
66
80
|
```
|
67
81
|
Usage: ai_refactor REFACTOR_TYPE INPUT_FILE_OR_DIR [options]
|
68
82
|
|
69
|
-
Where REFACTOR_TYPE is one of: ["
|
83
|
+
Where REFACTOR_TYPE is one of: ["rspec_to_minitest_rails", "generic"]
|
70
84
|
|
71
85
|
-p, --prompt PROMPT_FILE Specify path to a text file that contains the ChatGPT 'system' prompt.
|
72
86
|
-c, --continue [MAX_MESSAGES] If ChatGPT stops generating due to the maximum token count being reached, continue to generate more messages, until a stop condition or MAX_MESSAGES. MAX_MESSAGES defaults to 3
|
@@ -77,6 +91,10 @@ Where REFACTOR_TYPE is one of: ["generic", "rspec_to_minitest_rails", "minitest_
|
|
77
91
|
-v, --verbose Show extra output and progress info
|
78
92
|
-d, --debug Show debugging output to help diagnose issues
|
79
93
|
-h, --help Prints this help
|
94
|
+
|
95
|
+
For refactor type 'generic':
|
96
|
+
--output [FILE] Write output to file instead of stdout. If no path provided will overwrite input file (will prompt to overwrite existing files)
|
97
|
+
--output-template TEMPLATE Write outputs to files instead of stdout. The template is used to create the output name, where the it can have substitutions, '[FILE]', '[NAME]', '[DIR]', '[REFACTOR]' & '[EXT]'. Eg `[DIR]/[NAME]_[REFACTOR][EXT]` (will prompt to overwrite existing files)
|
80
98
|
```
|
81
99
|
|
82
100
|
|
@@ -33,7 +33,14 @@ module AIRefactor
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def prompt_file_path
|
36
|
-
|
36
|
+
file = if options && options[:prompt_file_path]&.length&.positive?
|
37
|
+
options[:prompt_file_path]
|
38
|
+
else
|
39
|
+
File.join(File.dirname(File.expand_path(__FILE__)), "refactors", "prompts", "#{refactor_name}.md")
|
40
|
+
end
|
41
|
+
file.tap do |prompt|
|
42
|
+
raise "No prompt file '#{prompt}' found for #{refactor_name}" unless File.exist?(prompt)
|
43
|
+
end
|
37
44
|
end
|
38
45
|
|
39
46
|
def ai_client
|
@@ -54,17 +61,6 @@ module AIRefactor
|
|
54
61
|
.tr("-", "_")
|
55
62
|
.downcase
|
56
63
|
end
|
57
|
-
|
58
|
-
def prompt_file_path
|
59
|
-
file = if options[:prompt_file_path]&.length&.positive?
|
60
|
-
options[:prompt_file_path]
|
61
|
-
else
|
62
|
-
File.join(File.dirname(File.expand_path(__FILE__)), "prompts", "#{refactor_name}.md")
|
63
|
-
end
|
64
|
-
file.tap do |prompt|
|
65
|
-
raise "No prompt file '#{prompt}' found for #{refactor_name}" unless File.exist?(prompt)
|
66
|
-
end
|
67
|
-
end
|
68
64
|
end
|
69
65
|
end
|
70
66
|
end
|
data/lib/ai_refactor/version.rb
CHANGED