aissue 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 47d3313efd9564d56156a382e337910abf05d3ded0d787986054351ea7f8ac74
4
+ data.tar.gz: cde1f513eb861092d7e2ffe7f22864cdb2697fca1613be4517a64a21b6e022ca
5
+ SHA512:
6
+ metadata.gz: 7ec9935c3e66b5801a6c009137787d26ab03fb1d2ed32f2defff4bb0edebdd0f618cd68d7eea9ad9ca50a847489abf89f8f66658211ed8532a272ab0d7f4966f
7
+ data.tar.gz: 2e1b54e7cfa447bfcebff324e9dee285e384c7eb7e6604400f2a4fadf6bd5b381e057b16a46900dc863d2b161224d412bfa18e88153f6ed946647726454d3a3f
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-10-09
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at ysk91.engineer@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 ysk91
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,226 @@
1
+ # Aissue
2
+
3
+ Aissue is a tool that utilizes generative AI to provide a code creation CLI and a feature to log the causes and solutions of errors as issues.
4
+
5
+ By using the Aissue gem, you gain the following two benefits:
6
+
7
+ - Speed up handling of issues by checking the causes and solutions in the issues logged.
8
+ - Increase development speed by referencing automatically generated code.
9
+
10
+ ## Installation
11
+
12
+ ### Install Aissue gem
13
+
14
+ Install the gem and add to the application's Gemfile by executing:
15
+
16
+ ```
17
+ $ bundle add aissue
18
+ ```
19
+
20
+ If bundler is not being used to manage dependencies, install the gem by executing:
21
+
22
+ ```
23
+ $ gem install aissue
24
+ ```
25
+
26
+ ### create .env
27
+
28
+ Create a `.env` file in the root of the project and add the following:
29
+
30
+ ```
31
+ OPENAI_API_KEY=sk-xxx
32
+ GPT_MODEL=gpt-4o-mini
33
+
34
+ GITHUB_TOKEN=ghp_xxx
35
+ GITHUB_OWNER=your-github-username
36
+ REPOSITORY=your-repository-name
37
+ AISSUE_LANG=if-you-want-to-specify-the-language(default: ja)
38
+ ```
39
+
40
+ get your API Keys from here:
41
+ - OPENAI_API_KEY
42
+ - https://platform.openai.com/settings/profile?tab=api-keys
43
+ - GITHUB_TOKEN
44
+ - https://github.com/settings/tokens
45
+
46
+ ## Usage
47
+
48
+ ### Creating Issues on Error
49
+
50
+ By inserting `Aissue::Issue.rescue(e)` in the rescue block of a begin/rescue structure, you can analyze the cause and solution based on the error and create an issue.
51
+
52
+ For example, you can use it as follows:
53
+
54
+ ```ruby
55
+ begin
56
+ 100 / 0 # Process where an error might occur
57
+ rescue => e
58
+ Aissue::Issue.rescue(e)
59
+ end
60
+ ```
61
+
62
+ The `rescue(e)` method outputs the issue URL as a return value, making it easier to notice errors when combined with Slack notifications.
63
+
64
+ #### ToDo
65
+
66
+ Currently, the code suggested here does not critically address the points where errors occur.
67
+ In my opinion, this issue is expected to be resolved by using the forthcoming publicly available o1 model.
68
+
69
+ ### Code Generation via CLI Tool
70
+
71
+ Executing `aissue start` launches the CLI tool.
72
+ Initially, it prompts the user for the following three inputs:
73
+
74
+ - Requirements of the code to be created
75
+ - Data (optional)
76
+ - Path to the target script (optional)
77
+
78
+ If the path to the target script is not entered (or not found on the GitHub repository), it will create standalone code independent of the repository.
79
+ After create code, it will ask whether to execute the created code.
80
+ At this time, **if the code poses no risks**, you can enter y to see the result.
81
+
82
+ If the path to the target script is provided, it will propose modified code for that script.
83
+
84
+ Finally, you will be asked whether to log the created code as an issue.
85
+ Enter y to create an issue and display the URL.
86
+
87
+ #### Example
88
+
89
+ **without target script**
90
+
91
+ ```shell
92
+ % aissue start
93
+ Please enter your requirements: 配列の中身をすべて大文字にし、実行するたびに順番をシャッフルする関数を作りたい
94
+ Please enter the relevant data: ['dog', 'cat', 'bird']
95
+ Please enter the path of the target script:
96
+ def shuffle_and_upcase(array)
97
+ array.map(&:upcase).shuffle
98
+ end
99
+
100
+ result = shuffle_and_upcase(['dog', 'cat', 'bird'])
101
+ result
102
+ Do you want to run this code?(y/n): y
103
+ [WARNING] Attempted to create command "shuffle_and_upcase" without usage or description. Call desc if you want this method to be available as command or declare it inside a no_commands{} block. Invoked from "/Users/yusukesonoki/work_mine/aissue/lib/aissue/cli.rb:57:in `start'".
104
+ ["BIRD", "CAT", "DOG"]
105
+ Would you like to record this code in a GitHub Issue?(y/n): y
106
+ https://github.com/ysk91/aissue/issues/10
107
+ ```
108
+
109
+ After executing the created code, a message starting with `[WARNING] Attempted to create command` may be displayed.
110
+ This occurs when using a function not declared within the disc, and it is dependent on Thor.
111
+ While it does not affect usage, if you know of a better approach, we welcome your suggestions via a pull request.
112
+
113
+ **with target script**
114
+
115
+ ```shell
116
+ % aissue start
117
+ Please enter your requirements: post_openaiの引数からjsonを削除し、常にJSONモードで使用したい
118
+ Please enter the relevant data:
119
+ Please enter the path of the target script: lib/aissue/util.rb
120
+ require 'net/http'
121
+ require 'uri'
122
+ require 'json'
123
+ require 'base64'
124
+ require 'dotenv/load'
125
+ require 'octokit'
126
+
127
+ module Aissue
128
+ class << self
129
+ def client
130
+ @client ||= Octokit::Client.new(access_token: ENV['GITHUB_TOKEN'])
131
+ end
132
+
133
+ def repository
134
+ ENV['GITHUB_OWNER'] + '/' + ENV['REPOSITORY']
135
+ end
136
+ end
137
+
138
+ module Util
139
+ # OpenAI API
140
+ def post_openai(prompt, model: ENV['GPT_MODEL'], temperature: 0.7)
141
+ data = {
142
+ model: model,
143
+ messages: [{"role" => "user", "content" => prompt}],
144
+ temperature: temperature
145
+ }
146
+
147
+ data["response_format"] = {"type" => "json_object"}
148
+
149
+ uri = URI.parse("https://api.openai.com/v1/chat/completions")
150
+ request = Net::HTTP::Post.new(uri)
151
+ request.content_type = "application/json"
152
+ request['Authorization'] = "Bearer #{ENV['OPENAI_API_KEY']}"
153
+ request.body = data.to_json
154
+
155
+ response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
156
+ http.request(request)
157
+ end
158
+
159
+ response_body = JSON.parse(response.body)
160
+ content = response_body["choices"][0]["message"]["content"] if response_body
161
+
162
+ content if content
163
+ end
164
+
165
+ # GitHub API
166
+ def get_file_contents(path, base_path: nil)
167
+ full_path = base_path ? "#{base_path}/#{path}" : path
168
+
169
+ begin
170
+ file_content = Aissue.client.contents(Aissue.repository, path: full_path)
171
+ decoded_content = Base64.decode64(file_content[:content]).force_encoding('UTF-8')
172
+ { full_path => decoded_content }
173
+ rescue Octokit::NotFound
174
+ puts "Skipping #{full_path} (not found in repo)"
175
+ nil
176
+ rescue => e
177
+ puts "Error retrieving #{full_path}: #{e}"
178
+ nil
179
+ end
180
+ end
181
+
182
+ def create_issue(title, body)
183
+ issue = Aissue.client.create_issue(Aissue.repository, title, body)
184
+ puts "Issue created: #{issue[:html_url]}"
185
+ end
186
+
187
+ def record_issue(purpose, ruby_code, script_path: nil)
188
+ issue_title = purpose
189
+ issue_body = <<~BODY
190
+ ## 対象スクリプト
191
+ #{script_path}
192
+
193
+ ## 実装コード
194
+ ```ruby
195
+ #{ruby_code}
196
+ ```
197
+ BODY
198
+
199
+ create_issue(issue_title, issue_body)
200
+ end
201
+ end
202
+ end
203
+ Would you like to record this code in a GitHub Issue?(y/n): y
204
+ https://github.com/ysk91/aissue/issues/11
205
+ ```
206
+
207
+ For those of you using AI for programming, you might already know that it can be risky to take the generated code at face value.
208
+ Please make sure to review the code thoroughly before implementing it.
209
+
210
+ ## Development
211
+
212
+ 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.
213
+
214
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
215
+
216
+ ## Contributing
217
+
218
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ysk91/aissue. 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/[USERNAME]/aissue/blob/main/CODE_OF_CONDUCT.md).
219
+
220
+ ## License
221
+
222
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
223
+
224
+ ## Code of Conduct
225
+
226
+ Everyone interacting in the Aissue project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ysk91/aissue/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/exe/aissue ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'aissue/cli'
4
+
5
+ Aissue::CLI.start
data/lib/aissue/cli.rb ADDED
@@ -0,0 +1,73 @@
1
+ require 'thor'
2
+ require 'dotenv/load'
3
+ require_relative 'util'
4
+
5
+ module Aissue
6
+ class CLI < Thor
7
+ include Aissue::Util
8
+
9
+ desc "start", "Start the Aissue CLI"
10
+ def start
11
+ print "Please enter your requirements: "
12
+ purpose = $stdin.gets.chomp
13
+
14
+ print "Please enter the relevant data: "
15
+ data = $stdin.gets.chomp
16
+
17
+ print "Please enter the path of the target script: "
18
+ script_path = $stdin.gets.chomp
19
+
20
+ script = get_file_contents(script_path)
21
+
22
+ lang = ENV['AISSUE_LANG'] || '日本語'
23
+
24
+ prompt = <<~PROMPT
25
+ [Instructions]
26
+ Create a Ruby code to achieve the [Purpose].
27
+ If there is a [Script], please refer to it for the code.
28
+ Output only the Ruby code without any explanations or results.
29
+
30
+ [Purpose]
31
+ #{purpose}
32
+
33
+ [Data]
34
+ #{data}
35
+
36
+ [Script]
37
+ #{script}
38
+
39
+ [Output Constraints] # Most Important
40
+ The [Output Result] will be executed with `exec([Output Result])`.
41
+ Please output in a plain text format suitable for this process.
42
+ Code blocks for markdown are unnecessary.
43
+ Ensure that the result of executing the process is returned as a return value.
44
+
45
+ [output language]
46
+ #{lang}
47
+ PROMPT
48
+
49
+ ruby_code = post_openai(prompt, json: false)
50
+ puts ruby_code
51
+
52
+ if script.nil?
53
+ print "Do you want to run this code?(y/n): "
54
+ is_execute = $stdin.gets.chomp
55
+
56
+ if ["Y", "YES"].include?(is_execute.upcase)
57
+ eval(ruby_code, binding, __FILE__, __LINE__)
58
+ result = binding.local_variable_get(:result)
59
+ p result
60
+ else
61
+ puts "Finished without execution."
62
+ end
63
+ end
64
+
65
+ print "Would you like to record this code in a GitHub Issue?(y/n): "
66
+ is_record_issue = $stdin.gets.chomp
67
+
68
+ if ["Y", "YES"].include?(is_record_issue.upcase)
69
+ puts record_issue(purpose, ruby_code, script_path: script_path)
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,77 @@
1
+ require_relative 'util'
2
+
3
+ module Aissue
4
+ include Aissue::Util
5
+
6
+ class Issue
7
+ class << self
8
+ def rescue(e)
9
+ repo_root = Dir.pwd
10
+ error_details = e.backtrace.map do |line|
11
+ line.sub(/^#{Regexp.escape(repo_root)}\//, '')
12
+ end
13
+
14
+ error_script_paths = error_details.map do |detail|
15
+ detail.split(':').first.strip
16
+ end
17
+ error_script_paths.uniq!
18
+
19
+ error_scripts = error_script_paths.map do |error_script_path|
20
+ get_file_contents(error_script_path)
21
+ end
22
+
23
+ lang = ENV['AISSUE_LANG'] || '日本語'
24
+
25
+ prompt = <<~PROMPT
26
+ [Instructions]
27
+ Analyze the [Error Details], describe the cause and corrective actions in <<comment>>.
28
+ Summarize the contents of <<comment>> and use it as <<title>>.
29
+ Output the results in JSON format.
30
+ Include items in the JSON according to [Output Items].
31
+
32
+ [Format of <<comment>>]
33
+ ## Error Occurrence
34
+ ```
35
+ #{error_details}
36
+ ```
37
+ (Describe the occurred error)
38
+
39
+ ## Cause
40
+ (Explain the location and cause of the error
41
+ Particularly, this error occurred when executing [Error Location].
42
+ Within this script, while identifying where [Error Details] occurs, also consider the possibility that the [Module] might be the cause.)
43
+
44
+ ## Corrective Actions
45
+ (Describe what kind of corrections should be made to which file to resolve the error)
46
+
47
+ ### Target File
48
+ (Specify the path of the file to be corrected)
49
+
50
+ ### Correction Content
51
+ (Describe the corrected code)
52
+
53
+ [Output Items]
54
+ title: <<title>>
55
+ comment: <<comment>>
56
+
57
+ [Error Details]
58
+ "#{e.class}: #{e.message}"
59
+
60
+ [Error Location]
61
+ #{error_details[-1]}
62
+
63
+ [Module]
64
+ #{error_scripts}
65
+
66
+ [output language]
67
+ #{lang}
68
+ PROMPT
69
+
70
+ response = post_openai(prompt, json: true)
71
+ title = response["title"]
72
+ body = response["comment"]
73
+ create_issue(title, body)
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,83 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'json'
4
+ require 'base64'
5
+ require 'dotenv/load'
6
+ require 'octokit'
7
+
8
+ module Aissue
9
+ class << self
10
+ def client
11
+ @client ||= Octokit::Client.new(access_token: ENV['GITHUB_TOKEN'])
12
+ end
13
+
14
+ def repository
15
+ ENV['GITHUB_OWNER'] + '/' + ENV['REPOSITORY']
16
+ end
17
+ end
18
+
19
+ module Util
20
+ # OpenAI API
21
+ def post_openai(prompt, model: ENV['GPT_MODEL'], temperature: 0.7, json: false)
22
+ data = {
23
+ model: model,
24
+ messages: [{"role" => "user", "content" => prompt}],
25
+ temperature: temperature
26
+ }
27
+
28
+ data["response_format"] = {"type" => "json_object"} if json
29
+
30
+ uri = URI.parse("https://api.openai.com/v1/chat/completions")
31
+ request = Net::HTTP::Post.new(uri)
32
+ request.content_type = "application/json"
33
+ request['Authorization'] = "Bearer #{ENV['OPENAI_API_KEY']}"
34
+ request.body = data.to_json
35
+
36
+ response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
37
+ http.request(request)
38
+ end
39
+
40
+ response_body = JSON.parse(response.body)
41
+ content = response_body["choices"][0]["message"]["content"] if response_body
42
+
43
+ if content
44
+ json ? JSON.parse(content) : content
45
+ end
46
+ end
47
+
48
+ # GitHub API
49
+ def get_file_contents(path, base_path: nil)
50
+ full_path = base_path ? "#{base_path}/#{path}" : path
51
+
52
+ begin
53
+ file_content = Aissue.client.contents(Aissue.repository, path: full_path)
54
+ decoded_content = Base64.decode64(file_content[:content]).force_encoding('UTF-8')
55
+ { full_path => decoded_content }
56
+ rescue Octokit::NotFound
57
+ nil
58
+ rescue => e
59
+ nil
60
+ end
61
+ end
62
+
63
+ def create_issue(title, body)
64
+ issue = Aissue.client.create_issue(Aissue.repository, title, body)
65
+ return issue[:html_url]
66
+ end
67
+
68
+ def record_issue(purpose, ruby_code, script_path: nil)
69
+ issue_title = purpose
70
+ issue_body = <<~BODY
71
+ ## 対象スクリプト
72
+ #{script_path}
73
+
74
+ ## 実装コード
75
+ ```ruby
76
+ #{ruby_code}
77
+ ```
78
+ BODY
79
+
80
+ create_issue(issue_title, issue_body)
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aissue
4
+ VERSION = "0.1.0"
5
+ end
data/lib/aissue.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "aissue/version"
4
+ require_relative "aissue/issue"
5
+
6
+ module Aissue
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+ end
data/sig/aissue.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Aissue
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aissue
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - ysk91
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-10-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dotenv
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'
27
+ - !ruby/object:Gem::Dependency
28
+ name: octokit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
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
+ description: This gem creates a new issue on GitHub by using AI.
56
+ email:
57
+ - ysk91.engineer@gmail.com
58
+ executables:
59
+ - aissue
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".rspec"
64
+ - ".rubocop.yml"
65
+ - CHANGELOG.md
66
+ - CODE_OF_CONDUCT.md
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - exe/aissue
71
+ - lib/aissue.rb
72
+ - lib/aissue/cli.rb
73
+ - lib/aissue/issue.rb
74
+ - lib/aissue/util.rb
75
+ - lib/aissue/version.rb
76
+ - sig/aissue.rbs
77
+ homepage: https://github.com/ysk91/aissue
78
+ licenses:
79
+ - MIT
80
+ metadata:
81
+ allowed_push_host: https://rubygems.org
82
+ homepage_uri: https://github.com/ysk91/aissue
83
+ source_code_uri: https://github.com/ysk91/aissue
84
+ changelog_uri: https://github.com/ysk91/aissue
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: 2.6.0
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubygems_version: 3.4.19
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: This gem creates a new issue on GitHub by using AI.
104
+ test_files: []