10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/aissue/cli.rb', line 10
def start
print "Please enter your requirements: "
purpose = $stdin.gets.chomp
print "Please enter the relevant data: "
data = $stdin.gets.chomp
print "Please enter the path of the target script: "
script_path = $stdin.gets.chomp
script = get_file_contents(script_path)
lang = ENV['AISSUE_LANG'] || '日本語'
prompt = " [Instructions]\n Create a Ruby code to achieve the [Purpose].\n If there is a [Script], please refer to it for the code.\n Output only the Ruby code without any explanations or results.\n\n [Purpose]\n \#{purpose}\n\n [Data]\n \#{data}\n\n [Script]\n \#{script}\n\n [Output Constraints] # Most Important\n The [Output Result] will be executed with `exec([Output Result])`.\n Please output in a plain text format suitable for this process.\n Code blocks for markdown are unnecessary.\n Ensure that the result of executing the process is returned as a return value.\n\n [output language]\n \#{lang}\n PROMPT\n\n ruby_code = post_openai(prompt, json: false)\n puts ruby_code\n\n if script.nil?\n print \"Do you want to run this code?(y/n): \"\n is_execute = $stdin.gets.chomp\n\n if [\"Y\", \"YES\"].include?(is_execute.upcase)\n eval(ruby_code, binding, __FILE__, __LINE__)\n result = binding.local_variable_get(:result)\n p result\n else\n puts \"Finished without execution.\"\n end\n end\n\n print \"Would you like to record this code in a GitHub Issue?(y/n): \"\n is_record_issue = $stdin.gets.chomp\n\n if [\"Y\", \"YES\"].include?(is_record_issue.upcase)\n puts record_issue(purpose, ruby_code, script_path: script_path)\n end\nend\n"
|