sylvia 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/sylvia/cli.rb +4 -0
- data/lib/sylvia/llm.rb +14 -5
- data/lib/sylvia/rubocop.rb +61 -48
- data/lib/sylvia/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b36536661b2da3b7b5831f99d79b1b6d7f57c40a43eddbf2026bc68e25b6c9c7
|
4
|
+
data.tar.gz: 37ae0cb4923b95e61d12aba773f0833293cc9225a63df9221e12bec9b9f6b3de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b782bce866c39f346b0574b74662461c78ca423c5cb7c5512a81357626f35b817c8ac15c657199c5f927a41dfcd01fd1e06d49c337a6950895de06941c6a2374
|
7
|
+
data.tar.gz: 3d42cbf0b1dfffc74c13e6dfe1cebede4a2f66b57b1fa683b37390634adebb96296c589f1fcc3c2ec559852f517c5d1ed164e8e4d1859ae0507019da3f07f22a
|
data/README.md
CHANGED
data/lib/sylvia/cli.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "json"
|
2
|
+
require_relative "version"
|
2
3
|
require_relative "llm"
|
3
4
|
require_relative "prettier"
|
4
5
|
require_relative "rubocop"
|
@@ -19,6 +20,8 @@ module Sylvia
|
|
19
20
|
RuboCop.setup
|
20
21
|
when "rubocop-todo"
|
21
22
|
RuboCop.generate_todo
|
23
|
+
when "-v", "--version"
|
24
|
+
puts "Sylvia version #{Sylvia::VERSION}"
|
22
25
|
else
|
23
26
|
puts "Usage:"
|
24
27
|
puts " sylvia llm # Create setup file llm"
|
@@ -26,6 +29,7 @@ module Sylvia
|
|
26
29
|
puts " sylvia prettier # Setup Prettier for Ruby"
|
27
30
|
puts " sylvia rubocop # Create .rubocop.yml config file"
|
28
31
|
puts " sylvia rubocop-todo # Generate .rubocop_todo.yml automatically"
|
32
|
+
puts " sylvia -v, --version # Show Sylvia version"
|
29
33
|
end
|
30
34
|
end
|
31
35
|
end
|
data/lib/sylvia/llm.rb
CHANGED
@@ -6,16 +6,25 @@ module Sylvia
|
|
6
6
|
content = <<~RUBY
|
7
7
|
require 'ruby_llm'
|
8
8
|
require 'tty-markdown'
|
9
|
-
|
10
|
-
|
9
|
+
|
10
|
+
api_key = 'xxx'
|
11
|
+
model_ai = 'gemini-2.0-flash'
|
12
|
+
|
11
13
|
|
12
14
|
RubyLLM.configure do |config|
|
13
|
-
config.gemini_api_key =
|
15
|
+
config.gemini_api_key = api_key
|
14
16
|
end
|
15
17
|
|
16
|
-
chat = RubyLLM.chat(model:
|
18
|
+
chat = RubyLLM.chat(model: model_ai)
|
19
|
+
|
20
|
+
response = chat.ask <<~PROMPT, with: ["assets/example.rb", "assets/example2.rb"]
|
21
|
+
Please review the following Ruby code and suggest improvements:
|
17
22
|
|
18
|
-
|
23
|
+
1. Use descriptive variable names.
|
24
|
+
2. Follow Ruby style conventions.
|
25
|
+
3. Optimize loops and iterators.
|
26
|
+
4. Avoid unnecessary complexity.
|
27
|
+
PROMPT
|
19
28
|
|
20
29
|
markdown = response.content.to_s
|
21
30
|
|
data/lib/sylvia/rubocop.rb
CHANGED
@@ -5,70 +5,83 @@ module Sylvia
|
|
5
5
|
def self.setup
|
6
6
|
if File.exist?(CONFIG_FILE)
|
7
7
|
puts "#{CONFIG_FILE} already exists. Skipping."
|
8
|
-
|
9
|
-
|
8
|
+
else
|
9
|
+
config_content = <<~YAML
|
10
|
+
AllCops:
|
11
|
+
Include:
|
12
|
+
- "**/*.rb"
|
13
|
+
- "**/*.rake"
|
14
|
+
- "."
|
15
|
+
Exclude:
|
16
|
+
- "vendor/**/*"
|
17
|
+
- "db/schema.rb"
|
18
|
+
NewCops: enable
|
10
19
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- "**/*.rake"
|
16
|
-
- "."
|
17
|
-
Exclude:
|
18
|
-
- "vendor/**/*"
|
19
|
-
- "db/schema.rb"
|
20
|
-
NewCops: enable
|
20
|
+
Layout/LineLength:
|
21
|
+
Max: 120
|
22
|
+
Exclude:
|
23
|
+
- "spec/**/*"
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
- "spec/**/*"
|
25
|
+
Style/BlockDelimiters:
|
26
|
+
Exclude:
|
27
|
+
- "spec/**/*"
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
Lint/AmbiguousBlockAssociation:
|
30
|
+
Exclude:
|
31
|
+
- "spec/**/*"
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
Metrics/BlockLength:
|
34
|
+
Exclude:
|
35
|
+
- "spec/**/*"
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
- "spec/**/*"
|
37
|
+
Layout/HeredocIndentation:
|
38
|
+
Enabled: false
|
38
39
|
|
39
|
-
|
40
|
-
|
40
|
+
Metrics/ClassLength:
|
41
|
+
Max: 175
|
41
42
|
|
42
|
-
|
43
|
-
|
43
|
+
Metrics/MethodLength:
|
44
|
+
Max: 25
|
44
45
|
|
45
|
-
|
46
|
-
|
46
|
+
Metrics/ParameterLists:
|
47
|
+
Max: 20
|
47
48
|
|
48
|
-
|
49
|
-
|
49
|
+
Metrics/AbcSize:
|
50
|
+
Enabled: false
|
50
51
|
|
51
|
-
|
52
|
-
|
52
|
+
Metrics/PerceivedComplexity:
|
53
|
+
Enabled: false
|
53
54
|
|
54
|
-
|
55
|
-
|
55
|
+
Metrics/CyclomaticComplexity:
|
56
|
+
Enabled: false
|
56
57
|
|
57
|
-
|
58
|
-
|
58
|
+
Style/HashEachMethods:
|
59
|
+
Enabled: true
|
59
60
|
|
60
|
-
|
61
|
-
|
61
|
+
Style/HashTransformKeys:
|
62
|
+
Enabled: false
|
62
63
|
|
63
|
-
|
64
|
-
|
64
|
+
Style/HashTransformValues:
|
65
|
+
Enabled: false
|
66
|
+
YAML
|
65
67
|
|
66
|
-
|
67
|
-
|
68
|
-
|
68
|
+
File.write(CONFIG_FILE, config_content)
|
69
|
+
puts "Created #{CONFIG_FILE}"
|
70
|
+
end
|
69
71
|
|
70
|
-
|
71
|
-
|
72
|
+
gemfile = 'Gemfile'
|
73
|
+
if File.exist?(gemfile)
|
74
|
+
content = File.read(gemfile)
|
75
|
+
if content.include?('gem "rubocop"')
|
76
|
+
puts 'Gemfile already contains rubocop'
|
77
|
+
else
|
78
|
+
File.open(gemfile, 'a') { |f| f.puts "\ngem \"rubocop\", require: false" }
|
79
|
+
puts "Added gem 'rubocop' to Gemfile"
|
80
|
+
system('bundle install')
|
81
|
+
end
|
82
|
+
else
|
83
|
+
puts "No Gemfile found. Please create one and add gem 'rubocop'."
|
84
|
+
end
|
72
85
|
end
|
73
86
|
|
74
87
|
def self.generate_todo
|
data/lib/sylvia/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sylvia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- whdzera
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: ruby_llm
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
|
-
rubygems_version: 3.
|
119
|
+
rubygems_version: 3.7.1
|
120
120
|
specification_version: 4
|
121
121
|
summary: A command-line tool for generating and managing Ruby projects.
|
122
122
|
test_files: []
|