8
9
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
72
73
74
|
# File 'lib/aissue/issue.rb', line 8
def rescue(e)
repo_root = Dir.pwd
error_details = e.backtrace.map do |line|
line.sub(/^#{Regexp.escape(repo_root)}\//, '')
end
error_script_paths = error_details.map do |detail|
detail.split(':').first.strip
end
error_script_paths.uniq!
error_scripts = error_script_paths.map do |error_script_path|
get_file_contents(error_script_path)
end
lang = ENV['AISSUE_LANG'] || '日本語'
prompt = " [Instructions]\n Analyze the [Error Details], describe the cause and corrective actions in <<comment>>.\n Summarize the contents of <<comment>> and use it as <<title>>.\n Output the results in JSON format.\n Include items in the JSON according to [Output Items].\n\n [Format of <<comment>>]\n ## Error Occurrence\n ```\n \#{error_details}\n ```\n (Describe the occurred error)\n\n ## Cause\n (Explain the location and cause of the error\n Particularly, this error occurred when executing [Error Location].\n Within this script, while identifying where [Error Details] occurs, also consider the possibility that the [Module] might be the cause.)\n\n ## Corrective Actions\n (Describe what kind of corrections should be made to which file to resolve the error)\n\n ### Target File\n (Specify the path of the file to be corrected)\n\n ### Correction Content\n (Describe the corrected code)\n\n [Output Items]\n title: <<title>>\n comment: <<comment>>\n\n [Error Details]\n \"\#{e.class}: \#{e.message}\"\n\n [Error Location]\n \#{error_details[-1]}\n\n [Module]\n \#{error_scripts}\n\n [output language]\n \#{lang}\n PROMPT\n\n response = post_openai(prompt, json: true)\n title = response[\"title\"]\n body = response[\"comment\"]\n create_issue(title, body)\nend\n"
|