rbs_goose 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/.env.sample +1 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +42 -0
  5. data/.ruby-version +1 -0
  6. data/CHANGELOG.md +5 -0
  7. data/CODE_OF_CONDUCT.md +84 -0
  8. data/Gemfile +20 -0
  9. data/Gemfile.lock +190 -0
  10. data/LICENSE.txt +21 -0
  11. data/README-EN-US.md +78 -0
  12. data/README.md +78 -0
  13. data/Rakefile +61 -0
  14. data/Steepfile +14 -0
  15. data/assets/logo.svg +1 -0
  16. data/lib/rbs_goose/configuration.rb +49 -0
  17. data/lib/rbs_goose/examples/rbs_samples/Steepfile +6 -0
  18. data/lib/rbs_goose/examples/rbs_samples/lib/email.rb +16 -0
  19. data/lib/rbs_goose/examples/rbs_samples/lib/person.rb +19 -0
  20. data/lib/rbs_goose/examples/rbs_samples/lib/phone.rb +22 -0
  21. data/lib/rbs_goose/examples/rbs_samples/refined/sig/email.rbs +11 -0
  22. data/lib/rbs_goose/examples/rbs_samples/refined/sig/person.rbs +13 -0
  23. data/lib/rbs_goose/examples/rbs_samples/refined/sig/phone.rbs +15 -0
  24. data/lib/rbs_goose/examples/rbs_samples/sig/email.rbs +11 -0
  25. data/lib/rbs_goose/examples/rbs_samples/sig/person.rbs +13 -0
  26. data/lib/rbs_goose/examples/rbs_samples/sig/phone.rbs +15 -0
  27. data/lib/rbs_goose/io/example.rb +27 -0
  28. data/lib/rbs_goose/io/example_group.rb +45 -0
  29. data/lib/rbs_goose/io/file.rb +64 -0
  30. data/lib/rbs_goose/io/target_group.rb +21 -0
  31. data/lib/rbs_goose/io/typed_ruby.rb +33 -0
  32. data/lib/rbs_goose/io.rb +12 -0
  33. data/lib/rbs_goose/templates/default_template.rb +49 -0
  34. data/lib/rbs_goose/templates.rb +8 -0
  35. data/lib/rbs_goose/type_inferrer.rb +13 -0
  36. data/lib/rbs_goose/version.rb +5 -0
  37. data/lib/rbs_goose.rb +38 -0
  38. data/rbs_collection.lock.yaml +188 -0
  39. data/rbs_collection.yaml +19 -0
  40. data/renovate.json +15 -0
  41. data/sig/rbs_goose/configuration.rbs +14 -0
  42. data/sig/rbs_goose/error.rbs +2 -0
  43. data/sig/rbs_goose/io/example.rbs +9 -0
  44. data/sig/rbs_goose/io/example_group.rbs +8 -0
  45. data/sig/rbs_goose/io/file.rbs +19 -0
  46. data/sig/rbs_goose/io/target_group.rbs +3 -0
  47. data/sig/rbs_goose/io/typed_ruby.rbs +9 -0
  48. data/sig/rbs_goose/io.rbs +2 -0
  49. data/sig/rbs_goose/templates/default_template.rbs +10 -0
  50. data/sig/rbs_goose/templates.rbs +2 -0
  51. data/sig/rbs_goose/type_inferrer.rbs +3 -0
  52. data/sig/rbs_goose.rbs +12 -0
  53. data/sig_ext/class.rbs +3 -0
  54. data/sig_ext/langchain/llm.rbs +19 -0
  55. metadata +128 -0
@@ -0,0 +1,188 @@
1
+ ---
2
+ path: ".gem_rbs_collection"
3
+ gems:
4
+ - name: activesupport
5
+ version: '7.0'
6
+ source:
7
+ type: git
8
+ name: ruby/gem_rbs_collection
9
+ revision: ec140aff951e3af39846eed4525ba5d040d294fa
10
+ remote: https://github.com/ruby/gem_rbs_collection.git
11
+ repo_dir: gems
12
+ - name: addressable
13
+ version: '2.8'
14
+ source:
15
+ type: git
16
+ name: ruby/gem_rbs_collection
17
+ revision: ec140aff951e3af39846eed4525ba5d040d294fa
18
+ remote: https://github.com/ruby/gem_rbs_collection.git
19
+ repo_dir: gems
20
+ - name: ast
21
+ version: '2.4'
22
+ source:
23
+ type: git
24
+ name: ruby/gem_rbs_collection
25
+ revision: ec140aff951e3af39846eed4525ba5d040d294fa
26
+ remote: https://github.com/ruby/gem_rbs_collection.git
27
+ repo_dir: gems
28
+ - name: baran
29
+ version: 0.1.10
30
+ source:
31
+ type: rubygems
32
+ - name: base64
33
+ version: '0'
34
+ source:
35
+ type: stdlib
36
+ - name: bigdecimal
37
+ version: '0'
38
+ source:
39
+ type: stdlib
40
+ - name: concurrent-ruby
41
+ version: '1.1'
42
+ source:
43
+ type: git
44
+ name: ruby/gem_rbs_collection
45
+ revision: ec140aff951e3af39846eed4525ba5d040d294fa
46
+ remote: https://github.com/ruby/gem_rbs_collection.git
47
+ repo_dir: gems
48
+ - name: connection_pool
49
+ version: '2.4'
50
+ source:
51
+ type: git
52
+ name: ruby/gem_rbs_collection
53
+ revision: ec140aff951e3af39846eed4525ba5d040d294fa
54
+ remote: https://github.com/ruby/gem_rbs_collection.git
55
+ repo_dir: gems
56
+ - name: date
57
+ version: '0'
58
+ source:
59
+ type: stdlib
60
+ - name: erb
61
+ version: '0'
62
+ source:
63
+ type: stdlib
64
+ - name: faraday
65
+ version: '2.5'
66
+ source:
67
+ type: git
68
+ name: ruby/gem_rbs_collection
69
+ revision: ec140aff951e3af39846eed4525ba5d040d294fa
70
+ remote: https://github.com/ruby/gem_rbs_collection.git
71
+ repo_dir: gems
72
+ - name: fileutils
73
+ version: '0'
74
+ source:
75
+ type: stdlib
76
+ - name: forwardable
77
+ version: '0'
78
+ source:
79
+ type: stdlib
80
+ - name: i18n
81
+ version: '1.10'
82
+ source:
83
+ type: git
84
+ name: ruby/gem_rbs_collection
85
+ revision: ec140aff951e3af39846eed4525ba5d040d294fa
86
+ remote: https://github.com/ruby/gem_rbs_collection.git
87
+ repo_dir: gems
88
+ - name: json
89
+ version: '0'
90
+ source:
91
+ type: stdlib
92
+ - name: logger
93
+ version: '0'
94
+ source:
95
+ type: stdlib
96
+ - name: minitest
97
+ version: '0'
98
+ source:
99
+ type: stdlib
100
+ - name: monitor
101
+ version: '0'
102
+ source:
103
+ type: stdlib
104
+ - name: mutex_m
105
+ version: '0'
106
+ source:
107
+ type: stdlib
108
+ - name: parallel
109
+ version: '1.20'
110
+ source:
111
+ type: git
112
+ name: ruby/gem_rbs_collection
113
+ revision: ec140aff951e3af39846eed4525ba5d040d294fa
114
+ remote: https://github.com/ruby/gem_rbs_collection.git
115
+ repo_dir: gems
116
+ - name: parser
117
+ version: '3.2'
118
+ source:
119
+ type: git
120
+ name: ruby/gem_rbs_collection
121
+ revision: ec140aff951e3af39846eed4525ba5d040d294fa
122
+ remote: https://github.com/ruby/gem_rbs_collection.git
123
+ repo_dir: gems
124
+ - name: rainbow
125
+ version: '3.0'
126
+ source:
127
+ type: git
128
+ name: ruby/gem_rbs_collection
129
+ revision: ec140aff951e3af39846eed4525ba5d040d294fa
130
+ remote: https://github.com/ruby/gem_rbs_collection.git
131
+ repo_dir: gems
132
+ - name: rake
133
+ version: '13.0'
134
+ source:
135
+ type: git
136
+ name: ruby/gem_rbs_collection
137
+ revision: ec140aff951e3af39846eed4525ba5d040d294fa
138
+ remote: https://github.com/ruby/gem_rbs_collection.git
139
+ repo_dir: gems
140
+ - name: regexp_parser
141
+ version: '2.8'
142
+ source:
143
+ type: git
144
+ name: ruby/gem_rbs_collection
145
+ revision: ec140aff951e3af39846eed4525ba5d040d294fa
146
+ remote: https://github.com/ruby/gem_rbs_collection.git
147
+ repo_dir: gems
148
+ - name: rubocop
149
+ version: '1.57'
150
+ source:
151
+ type: git
152
+ name: ruby/gem_rbs_collection
153
+ revision: ec140aff951e3af39846eed4525ba5d040d294fa
154
+ remote: https://github.com/ruby/gem_rbs_collection.git
155
+ repo_dir: gems
156
+ - name: rubocop-ast
157
+ version: '1.30'
158
+ source:
159
+ type: git
160
+ name: ruby/gem_rbs_collection
161
+ revision: ec140aff951e3af39846eed4525ba5d040d294fa
162
+ remote: https://github.com/ruby/gem_rbs_collection.git
163
+ repo_dir: gems
164
+ - name: securerandom
165
+ version: '0'
166
+ source:
167
+ type: stdlib
168
+ - name: singleton
169
+ version: '0'
170
+ source:
171
+ type: stdlib
172
+ - name: tiktoken_ruby
173
+ version: 0.0.6
174
+ source:
175
+ type: rubygems
176
+ - name: time
177
+ version: '0'
178
+ source:
179
+ type: stdlib
180
+ - name: timeout
181
+ version: '0'
182
+ source:
183
+ type: stdlib
184
+ - name: uri
185
+ version: '0'
186
+ source:
187
+ type: stdlib
188
+ gemfile_lock_path: Gemfile.lock
@@ -0,0 +1,19 @@
1
+ # Download sources
2
+ sources:
3
+ - type: git
4
+ name: ruby/gem_rbs_collection
5
+ remote: https://github.com/ruby/gem_rbs_collection.git
6
+ revision: main
7
+ repo_dir: gems
8
+
9
+ # You can specify local directories as sources also.
10
+ # - type: local
11
+ # path: path/to/your/local/repository
12
+
13
+ # A directory to install the downloaded RBSs
14
+ path: .gem_rbs_collection
15
+
16
+ # gems:
17
+ # # If you want to avoid installing rbs files for gems, you can specify them here.
18
+ # - name: GEM_NAME
19
+ # ignore: true
data/renovate.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "config:recommended"
5
+ ],
6
+ "labels": [
7
+ "dependencies"
8
+ ],
9
+ "packageRules": [
10
+ {
11
+ "groupName": "rubocop",
12
+ "matchPackagePatterns": [ "rubocop" ]
13
+ }
14
+ ]
15
+ }
@@ -0,0 +1,14 @@
1
+ class RbsGoose::Configuration
2
+ @llm: Langchain::LLM::OpenAI
3
+ @template: Langchain::Prompt::FewShotPromptTemplate
4
+ def initialize: () ?{ (RbsGoose::Configuration)[self: RbsGoose::Configuration] -> void } -> void
5
+ attr_accessor llm: Langchain::LLM::OpenAI
6
+ attr_accessor instruction: String
7
+ attr_accessor example_groups: Array[untyped]
8
+ attr_accessor template_class: singleton(RbsGoose::Templates::DefaultTemplate)
9
+ def use_open_ai: (String open_ai_access_token, ?default_options: ::Hash[untyped, untyped]) -> untyped
10
+ def template: () -> RbsGoose::Templates::DefaultTemplate
11
+ private def default_template_class: () -> singleton(RbsGoose::Templates::DefaultTemplate)
12
+ private def default_instruction: () -> String
13
+ private def default_example_groups: () -> Array[untyped]
14
+ end
@@ -0,0 +1,2 @@
1
+ class RbsGoose::Error < ::StandardError
2
+ end
@@ -0,0 +1,9 @@
1
+ class RbsGoose::IO::Example
2
+ @typed_ruby: RbsGoose::IO::TypedRuby
3
+ @refined_rbs: RbsGoose::IO::File
4
+ def self.from_path: (ruby_path: String, rbs_path: String, refined_rbs_dir: String, base_path: untyped) -> RbsGoose::IO::Example
5
+ def initialize: (typed_ruby: RbsGoose::IO::TypedRuby, refined_rbs: RbsGoose::IO::File) -> void
6
+ def to_h: () -> { typed_ruby: RbsGoose::IO::TypedRuby, refined_rbs: RbsGoose::IO::File }
7
+ attr_reader typed_ruby: RbsGoose::IO::TypedRuby
8
+ attr_reader refined_rbs: RbsGoose::IO::File
9
+ end
@@ -0,0 +1,8 @@
1
+ class RbsGoose::IO::ExampleGroup < ::Array[RbsGoose::IO::Example]
2
+ self.@default_examples: Hash[Symbol, Array[RbsGoose::IO::Example]]
3
+ def self.load_from: (untyped base_path, ?code_dir: ::String, ?sig_dir: ::String, ?refined_dir: ::String) -> RbsGoose::IO::ExampleGroup
4
+ def self.default_examples: () -> Hash[Symbol, Array[RbsGoose::IO::Example]]
5
+ private def self.to_rbs_path: (String, String) -> String
6
+ def to_target_group: () -> RbsGoose::IO::TargetGroup
7
+ def to_refined_rbs_list: () -> Array[RbsGoose::IO::File]
8
+ end
@@ -0,0 +1,19 @@
1
+ class RbsGoose::IO::File
2
+ @path: String
3
+ @base_path: untyped
4
+ @content: String
5
+ @type: :ruby | :rbs
6
+ MARKDOWN_REGEXP: ::Regexp
7
+ def self.from_markdown: (String) -> RbsGoose::IO::File
8
+ def initialize: (path: String, ?content: String, ?base_path: untyped) -> void
9
+ def load_content: () -> String
10
+ def absolute_path: () -> String
11
+ def type: () -> (:ruby | :rbs)
12
+ def to_s: () -> String
13
+ def content=: (String) -> String
14
+ def write: () -> untyped
15
+ def ==: (untyped) -> untyped
16
+ attr_reader path: String
17
+ attr_reader content: String
18
+ attr_reader base_path: untyped
19
+ end
@@ -0,0 +1,3 @@
1
+ class RbsGoose::IO::TargetGroup < ::Array[RbsGoose::IO::TypedRuby]
2
+ def self.load_from: (untyped base_path, ?code_dir: ::String, ?sig_dir: ::String) -> RbsGoose::IO::TargetGroup
3
+ end
@@ -0,0 +1,9 @@
1
+ class RbsGoose::IO::TypedRuby
2
+ @ruby: RbsGoose::IO::File
3
+ @rbs: RbsGoose::IO::File | nil
4
+ def self.from_path: (ruby_path: String, rbs_path: String, base_path: untyped) -> RbsGoose::IO::TypedRuby
5
+ def initialize: (ruby: RbsGoose::IO::File, rbs: RbsGoose::IO::File | nil) -> void
6
+ def to_s: () -> (untyped | String)
7
+ attr_reader ruby: RbsGoose::IO::File
8
+ attr_reader rbs: RbsGoose::IO::File | nil
9
+ end
@@ -0,0 +1,2 @@
1
+ module RbsGoose::IO
2
+ end
@@ -0,0 +1,10 @@
1
+ class RbsGoose::Templates::DefaultTemplate
2
+ @template: Langchain::Prompt::FewShotPromptTemplate
3
+ def initialize: (instruction: String, example_groups: Array[untyped]) -> void
4
+ def format: (Array[untyped]) -> untyped
5
+ def parse_result: (untyped) -> untyped
6
+ private attr_reader template: Langchain::Prompt::FewShotPromptTemplate
7
+ private def example_prompt: () -> Langchain::Prompt::PromptTemplate
8
+ private def input_template_string: () -> String
9
+ private def transform_example_group: (untyped) -> { typed_ruby_list: untyped, refined_rbs_list: untyped }
10
+ end
@@ -0,0 +1,2 @@
1
+ module RbsGoose::Templates
2
+ end
@@ -0,0 +1,3 @@
1
+ class RbsGoose::TypeInferrer
2
+ def infer: (untyped) -> untyped
3
+ end
data/sig/rbs_goose.rbs ADDED
@@ -0,0 +1,12 @@
1
+ module RbsGoose
2
+ VERSION: "0.1.0"
3
+ self.@configuration: RbsGoose::Configuration
4
+ extend Forwardable
5
+ def self.configure: () { (RbsGoose::Configuration)[self: RbsGoose::Configuration] -> void } -> void
6
+ def self.reset_configuration: () -> untyped
7
+ def self.run: (?code_dir: ::String, ?sig_dir: ::String, ?base_path: untyped) -> untyped
8
+ attr_reader self.configuration: RbsGoose::Configuration
9
+ def self.llm: () -> Langchain::LLM::OpenAI
10
+ def self.instruction: () -> String
11
+ def self.example_groups: () -> Array[untyped]
12
+ end
data/sig_ext/class.rbs ADDED
@@ -0,0 +1,3 @@
1
+ class Class
2
+ def self.def_delegators: (*untyped) -> untyped
3
+ end
@@ -0,0 +1,19 @@
1
+ module Langchain
2
+ module LLM
3
+ class OpenAI
4
+ def initialize: (untyped) ->void
5
+ def complete: (untyped) -> untyped
6
+ end
7
+ end
8
+
9
+ module Prompt
10
+ class PromptTemplate
11
+ def initialize: (template: String, input_variables: Array[String]) -> void
12
+ end
13
+
14
+ class FewShotPromptTemplate
15
+ def initialize: (prefix: String, suffix: String, example_prompt: ::Langchain::Prompt::PromptTemplate, examples: Array[untyped], input_variables: Array[String]) -> void
16
+ def format: (untyped) -> untyped
17
+ end
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rbs_goose
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - kokuyouwind
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-01-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: langchainrb
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.8.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruby-openai
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 6.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 6.1.0
41
+ description: RBS type inferrer with LLM
42
+ email:
43
+ - kokuyouwind@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".env.sample"
49
+ - ".rspec"
50
+ - ".rubocop.yml"
51
+ - ".ruby-version"
52
+ - CHANGELOG.md
53
+ - CODE_OF_CONDUCT.md
54
+ - Gemfile
55
+ - Gemfile.lock
56
+ - LICENSE.txt
57
+ - README-EN-US.md
58
+ - README.md
59
+ - Rakefile
60
+ - Steepfile
61
+ - assets/logo.svg
62
+ - lib/rbs_goose.rb
63
+ - lib/rbs_goose/configuration.rb
64
+ - lib/rbs_goose/examples/rbs_samples/Steepfile
65
+ - lib/rbs_goose/examples/rbs_samples/lib/email.rb
66
+ - lib/rbs_goose/examples/rbs_samples/lib/person.rb
67
+ - lib/rbs_goose/examples/rbs_samples/lib/phone.rb
68
+ - lib/rbs_goose/examples/rbs_samples/refined/sig/email.rbs
69
+ - lib/rbs_goose/examples/rbs_samples/refined/sig/person.rbs
70
+ - lib/rbs_goose/examples/rbs_samples/refined/sig/phone.rbs
71
+ - lib/rbs_goose/examples/rbs_samples/sig/email.rbs
72
+ - lib/rbs_goose/examples/rbs_samples/sig/person.rbs
73
+ - lib/rbs_goose/examples/rbs_samples/sig/phone.rbs
74
+ - lib/rbs_goose/io.rb
75
+ - lib/rbs_goose/io/example.rb
76
+ - lib/rbs_goose/io/example_group.rb
77
+ - lib/rbs_goose/io/file.rb
78
+ - lib/rbs_goose/io/target_group.rb
79
+ - lib/rbs_goose/io/typed_ruby.rb
80
+ - lib/rbs_goose/templates.rb
81
+ - lib/rbs_goose/templates/default_template.rb
82
+ - lib/rbs_goose/type_inferrer.rb
83
+ - lib/rbs_goose/version.rb
84
+ - rbs_collection.lock.yaml
85
+ - rbs_collection.yaml
86
+ - renovate.json
87
+ - sig/rbs_goose.rbs
88
+ - sig/rbs_goose/configuration.rbs
89
+ - sig/rbs_goose/error.rbs
90
+ - sig/rbs_goose/io.rbs
91
+ - sig/rbs_goose/io/example.rbs
92
+ - sig/rbs_goose/io/example_group.rbs
93
+ - sig/rbs_goose/io/file.rbs
94
+ - sig/rbs_goose/io/target_group.rbs
95
+ - sig/rbs_goose/io/typed_ruby.rbs
96
+ - sig/rbs_goose/templates.rbs
97
+ - sig/rbs_goose/templates/default_template.rbs
98
+ - sig/rbs_goose/type_inferrer.rbs
99
+ - sig_ext/class.rbs
100
+ - sig_ext/langchain/llm.rbs
101
+ homepage: https://github.com/kokuyouwind/rbs_goose
102
+ licenses:
103
+ - MIT
104
+ metadata:
105
+ homepage_uri: https://github.com/kokuyouwind/rbs_goose
106
+ source_code_uri: https://github.com/kokuyouwind/rbs_goose
107
+ changelog_uri: https://github.com/kokuyouwind/rbs_goose/CHANGELOG.md
108
+ rubygems_mfa_required: 'true'
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 3.0.0
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubygems_version: 3.5.3
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: RBS type inferrer with LLM
128
+ test_files: []