sylvia 0.2.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3400a3b8c14a722b2319389c619bbcb5fb141c0900b53eff8ab3cb0d3dfe0e4c
4
- data.tar.gz: 734a5c7955a4f6210d3d7d48e87727c8c9654d3c2ce2db19ce1c0f4ffd5d9807
3
+ metadata.gz: b36536661b2da3b7b5831f99d79b1b6d7f57c40a43eddbf2026bc68e25b6c9c7
4
+ data.tar.gz: 37ae0cb4923b95e61d12aba773f0833293cc9225a63df9221e12bec9b9f6b3de
5
5
  SHA512:
6
- metadata.gz: 61a5beda98de772f434ed84d85776925105b136ab26ab3a92f38175b615d2cfaf8c9b73181d7a0cba8f3cfff775a537a5d904264be38d6c94ffe68e887c40ab2
7
- data.tar.gz: 9e0784427701bac5cbf4b8d6ada49069cc618da76aec4c55f518a09531735d09e4175c3c89a070b6f04e6a8a9783f1344a028f33aeed3c0c18b40f274e3614ae
6
+ metadata.gz: b782bce866c39f346b0574b74662461c78ca423c5cb7c5512a81357626f35b817c8ac15c657199c5f927a41dfcd01fd1e06d49c337a6950895de06941c6a2374
7
+ data.tar.gz: 3d42cbf0b1dfffc74c13e6dfe1cebede4a2f66b57b1fa683b37390634adebb96296c589f1fcc3c2ec559852f517c5d1ed164e8e4d1859ae0507019da3f07f22a
data/.gitignore CHANGED
@@ -10,4 +10,5 @@
10
10
  node_modules
11
11
  .rspec_status
12
12
  Gemfile.lock
13
- package-lock.json
13
+ package-lock.json
14
+ .rubocop_todo.yml
data/.rubocop.yml ADDED
@@ -0,0 +1,58 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ Include:
5
+ - "**/*.rb"
6
+ - "**/*.rake"
7
+ - "."
8
+ Exclude:
9
+ - "vendor/**/*"
10
+ - "db/schema.rb"
11
+ NewCops: enable
12
+
13
+ Layout/LineLength:
14
+ Max: 120
15
+ Exclude:
16
+ - "spec/**/*"
17
+
18
+ Style/BlockDelimiters:
19
+ Exclude:
20
+ - "spec/**/*"
21
+
22
+ Lint/AmbiguousBlockAssociation:
23
+ Exclude:
24
+ - "spec/**/*"
25
+
26
+ Metrics/BlockLength:
27
+ Exclude:
28
+ - "spec/**/*"
29
+
30
+ Layout/HeredocIndentation:
31
+ Enabled: false
32
+
33
+ Metrics/ClassLength:
34
+ Max: 175
35
+
36
+ Metrics/MethodLength:
37
+ Max: 25
38
+
39
+ Metrics/ParameterLists:
40
+ Max: 20
41
+
42
+ Metrics/AbcSize:
43
+ Enabled: false
44
+
45
+ Metrics/PerceivedComplexity:
46
+ Enabled: false
47
+
48
+ Metrics/CyclomaticComplexity:
49
+ Enabled: false
50
+
51
+ Style/HashEachMethods:
52
+ Enabled: true
53
+
54
+ Style/HashTransformKeys:
55
+ Enabled: false
56
+
57
+ Style/HashTransformValues:
58
+ Enabled: false
data/Gemfile CHANGED
@@ -7,5 +7,5 @@ gemspec
7
7
 
8
8
  gem "irb"
9
9
  gem "rake", "~> 13.0"
10
-
11
10
  gem "rspec", "~> 3.0"
11
+ gem 'rubocop', '1.80.0'
data/README.md CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  ## Sylvia
3
2
 
4
3
  ![Lang](https://img.shields.io/badge/language-ruby-red)
@@ -6,7 +5,7 @@
6
5
  [![Gem Downloads](https://img.shields.io/gem/dt/sylvia.svg)](https://rubygems.org/gems/sylvia)
7
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
7
 
9
- My Private Assistant Tool for ruby development (support Ruby LLM)
8
+ My Private Assistant Tool for ruby development
10
9
 
11
10
  ## Installation
12
11
 
@@ -16,21 +15,47 @@ gem install sylvia
16
15
 
17
16
  ## Usage
18
17
 
19
- Setup Prettier
18
+ ##### Setup Prettier for ruby
19
+
20
20
  ```
21
21
  sylvia prettier
22
22
  ```
23
23
 
24
- Setup LLM (with Ruby_LLM)
24
+ ##### Setup Rubocop
25
+
26
+ ```
27
+ sylvia rubocop
28
+ ```
29
+
30
+ ##### Setup and Configuration AI LLM
31
+
25
32
  ```
26
33
  sylvia llm
27
34
  ```
28
35
 
29
- Run AI LLM
36
+ automatically created `sylvia.rb` and added configuration ruby_LLM (set your model LLM and API key)
37
+
38
+ ask to Ai like this
39
+
40
+ ```ruby
41
+ chat.ask "how to improve this code", with: ["app/example.rb", "app/example2.rb"]
42
+ ```
43
+
44
+ This is like a cursor/copilot, but manual.
45
+
46
+ ##### Run AI LLM
47
+
30
48
  ```
31
49
  sylvia ai
32
50
  ```
33
51
 
52
+ ##### Check Version
53
+
54
+ ```
55
+ sylvia -v
56
+ ```
57
+
58
+ run ruby_LLM `sylvia.rb`
34
59
 
35
60
  ## Development
36
61
 
data/lib/sylvia/cli.rb CHANGED
@@ -1,113 +1,36 @@
1
1
  require "json"
2
+ require_relative "version"
3
+ require_relative "llm"
4
+ require_relative "prettier"
5
+ require_relative "rubocop"
2
6
 
3
7
  module Sylvia
4
8
  class CLI
5
- FILE_NAME = "sylvia.rb"
6
- PRETTIER_FILE = ".prettierrc"
7
- PACKAGE_FILE = "package.json"
8
-
9
9
  def self.start(args)
10
10
  command = args.shift
11
11
 
12
12
  case command
13
13
  when "llm"
14
- setup_llm
14
+ LLM.setup
15
15
  when "ai"
16
- run_llm
16
+ LLM.run
17
17
  when "prettier"
18
- setup_prettier
18
+ Prettier.setup
19
+ when "rubocop"
20
+ RuboCop.setup
21
+ when "rubocop-todo"
22
+ RuboCop.generate_todo
23
+ when "-v", "--version"
24
+ puts "Sylvia version #{Sylvia::VERSION}"
19
25
  else
20
26
  puts "Usage:"
21
- puts " sylvia llm # Create setup file llm"
22
- puts " sylvia ai # Run llm"
23
- puts " sylvia prettier # Setup Prettier for Ruby"
24
- end
25
- end
26
-
27
- def self.setup_llm
28
- content = <<~RUBY
29
- require 'ruby_llm'
30
- require 'tty-markdown'
31
- require 'dotenv'
32
- Dotenv.load
33
-
34
- RubyLLM.configure do |config|
35
- config.gemini_api_key = ENV.fetch('gemini', nil)
36
- end
37
-
38
- chat = RubyLLM.chat(model: 'gemini-2.0-flash')
39
-
40
- response = chat.ask "how to improve this code", with: ["assets/example.rb", "assets/example2.rb"]
41
-
42
- markdown = response.content.to_s
43
-
44
- puts TTY::Markdown.parse(markdown)
45
- RUBY
46
-
47
- File.write(FILE_NAME, content)
48
- puts "✅ Created #{FILE_NAME}"
49
- end
50
-
51
- def self.run_llm
52
- unless File.exist?(FILE_NAME)
53
- puts "⚠️ #{FILE_NAME} not found. Run `sylvia install` first."
54
- return
55
- end
56
-
57
- system("ruby #{FILE_NAME}")
58
- end
59
-
60
- def self.setup_prettier
61
- if File.exist?(PRETTIER_FILE)
62
- puts "⚠️ #{PRETTIER_FILE} already exists. Skipping."
63
- return
27
+ puts " sylvia llm # Create setup file llm"
28
+ puts " sylvia ai # Run llm"
29
+ puts " sylvia prettier # Setup Prettier for Ruby"
30
+ puts " sylvia rubocop # Create .rubocop.yml config file"
31
+ puts " sylvia rubocop-todo # Generate .rubocop_todo.yml automatically"
32
+ puts " sylvia -v, --version # Show Sylvia version"
64
33
  end
65
-
66
- prettier_config = <<~JSON
67
- {
68
- "plugins": ["@prettier/plugin-ruby"],
69
- "rubyStrictMode": false,
70
- "tabWidth": 2,
71
- "useTabs": false,
72
- "singleQuote": true
73
- }
74
- JSON
75
-
76
- File.write(PRETTIER_FILE, prettier_config)
77
- puts "✅ Created #{PRETTIER_FILE}"
78
-
79
- unless File.exist?(PACKAGE_FILE)
80
- puts "⚡ Running `npm init -y`..."
81
- system("npm init -y")
82
- end
83
-
84
- package_json = JSON.parse(File.read(PACKAGE_FILE))
85
- package_json["devDependencies"] ||= {}
86
- package_json["devDependencies"]["prettier"] = "^3.5.3"
87
- package_json["devDependencies"]["@prettier/plugin-ruby"] = "^4.0.4"
88
- File.write(PACKAGE_FILE, JSON.pretty_generate(package_json))
89
- puts "✅ Updated #{PACKAGE_FILE} devDependencies"
90
-
91
- puts "⚡ Running `npm install`..."
92
- system("npm install")
93
-
94
- gemfile = "Gemfile"
95
- if File.exist?(gemfile)
96
- content = File.read(gemfile)
97
- unless content.include?('gem "syntax_tree"')
98
- File.open(gemfile, "a") { |f| f.puts "\ngem \"syntax_tree\"" }
99
- puts "✅ Added gem 'syntax_tree' to Gemfile"
100
- else
101
- puts "⚠️ Gemfile already contains syntax_tree"
102
- end
103
-
104
- puts "⚡ Running `bundle install`..."
105
- system("bundle install")
106
- else
107
- puts "⚠️ No Gemfile found. Skipping syntax_tree installation."
108
- end
109
-
110
- puts "🎉 Prettier setup complete!"
111
34
  end
112
35
  end
113
36
  end
data/lib/sylvia/llm.rb ADDED
@@ -0,0 +1,47 @@
1
+ module Sylvia
2
+ class LLM
3
+ FILE_NAME = 'sylvia.rb'
4
+
5
+ def self.setup
6
+ content = <<~RUBY
7
+ require 'ruby_llm'
8
+ require 'tty-markdown'
9
+
10
+ api_key = 'xxx'
11
+ model_ai = 'gemini-2.0-flash'
12
+
13
+
14
+ RubyLLM.configure do |config|
15
+ config.gemini_api_key = api_key
16
+ end
17
+
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:
22
+
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
28
+
29
+ markdown = response.content.to_s
30
+
31
+ puts TTY::Markdown.parse(markdown)
32
+ RUBY
33
+
34
+ File.write(FILE_NAME, content)
35
+ puts "Created #{FILE_NAME}"
36
+ end
37
+
38
+ def self.run
39
+ unless File.exist?(FILE_NAME)
40
+ puts "#{FILE_NAME} not found. Run `sylvia llm` first."
41
+ return
42
+ end
43
+
44
+ system("ruby #{FILE_NAME}")
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,61 @@
1
+ require 'json'
2
+
3
+ module Sylvia
4
+ class Prettier
5
+ PRETTIER_FILE = '.prettierrc'
6
+ PACKAGE_FILE = 'package.json'
7
+
8
+ def self.setup
9
+ if File.exist?(PRETTIER_FILE)
10
+ puts "#{PRETTIER_FILE} already exists. Skipping."
11
+ return
12
+ end
13
+
14
+ prettier_config = <<~JSON
15
+ {
16
+ "plugins": ["@prettier/plugin-ruby"],
17
+ "rubyStrictMode": false,
18
+ "tabWidth": 2,
19
+ "useTabs": false,
20
+ "singleQuote": true
21
+ }
22
+ JSON
23
+
24
+ File.write(PRETTIER_FILE, prettier_config)
25
+ puts "Created #{PRETTIER_FILE}"
26
+
27
+ unless File.exist?(PACKAGE_FILE)
28
+ puts 'Running `npm init -y`...'
29
+ system('npm init -y')
30
+ end
31
+
32
+ package_json = JSON.parse(File.read(PACKAGE_FILE))
33
+ package_json['devDependencies'] ||= {}
34
+ package_json['devDependencies']['prettier'] = '^3.5.3'
35
+ package_json['devDependencies']['@prettier/plugin-ruby'] = '^4.0.4'
36
+ File.write(PACKAGE_FILE, JSON.pretty_generate(package_json))
37
+ puts "Updated #{PACKAGE_FILE} devDependencies"
38
+
39
+ puts 'Running `npm install`...'
40
+ system('npm install')
41
+
42
+ gemfile = 'Gemfile'
43
+ if File.exist?(gemfile)
44
+ content = File.read(gemfile)
45
+ if content.include?('gem "syntax_tree"')
46
+ puts 'Gemfile already contains syntax_tree'
47
+ else
48
+ File.open(gemfile, 'a') { |f| f.puts "\ngem \"syntax_tree\"" }
49
+ puts "Added gem 'syntax_tree' to Gemfile"
50
+ end
51
+
52
+ puts 'Running `bundle install`...'
53
+ system('bundle install')
54
+ else
55
+ puts 'No Gemfile found. Skipping syntax_tree installation.'
56
+ end
57
+
58
+ puts 'Prettier setup complete!'
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,100 @@
1
+ module Sylvia
2
+ class RuboCop
3
+ CONFIG_FILE = '.rubocop.yml'
4
+
5
+ def self.setup
6
+ if File.exist?(CONFIG_FILE)
7
+ puts "#{CONFIG_FILE} already exists. Skipping."
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
19
+
20
+ Layout/LineLength:
21
+ Max: 120
22
+ Exclude:
23
+ - "spec/**/*"
24
+
25
+ Style/BlockDelimiters:
26
+ Exclude:
27
+ - "spec/**/*"
28
+
29
+ Lint/AmbiguousBlockAssociation:
30
+ Exclude:
31
+ - "spec/**/*"
32
+
33
+ Metrics/BlockLength:
34
+ Exclude:
35
+ - "spec/**/*"
36
+
37
+ Layout/HeredocIndentation:
38
+ Enabled: false
39
+
40
+ Metrics/ClassLength:
41
+ Max: 175
42
+
43
+ Metrics/MethodLength:
44
+ Max: 25
45
+
46
+ Metrics/ParameterLists:
47
+ Max: 20
48
+
49
+ Metrics/AbcSize:
50
+ Enabled: false
51
+
52
+ Metrics/PerceivedComplexity:
53
+ Enabled: false
54
+
55
+ Metrics/CyclomaticComplexity:
56
+ Enabled: false
57
+
58
+ Style/HashEachMethods:
59
+ Enabled: true
60
+
61
+ Style/HashTransformKeys:
62
+ Enabled: false
63
+
64
+ Style/HashTransformValues:
65
+ Enabled: false
66
+ YAML
67
+
68
+ File.write(CONFIG_FILE, config_content)
69
+ puts "Created #{CONFIG_FILE}"
70
+ end
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
85
+ end
86
+
87
+ def self.generate_todo
88
+ todo_file = '.rubocop_todo.yml'
89
+
90
+ if File.exist?(todo_file)
91
+ puts "#{todo_file} already exists. Skipping generation."
92
+ return
93
+ end
94
+
95
+ puts 'Generating RuboCop TODO...'
96
+ system('rubocop --auto-gen-config --no-exclude-limit')
97
+ puts "RuboCop TODO generated (see #{todo_file})"
98
+ end
99
+ end
100
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sylvia
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.3"
5
5
  end
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.1
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: 2025-08-24 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: ruby_llm
@@ -76,8 +76,8 @@ extra_rdoc_files: []
76
76
  files:
77
77
  - ".github/workflows/main.yml"
78
78
  - ".gitignore"
79
- - ".prettierrc"
80
79
  - ".rspec"
80
+ - ".rubocop.yml"
81
81
  - CHANGELOG.md
82
82
  - CODE_OF_CONDUCT.md
83
83
  - Gemfile
@@ -87,8 +87,10 @@ files:
87
87
  - bin/sylvia
88
88
  - lib/sylvia.rb
89
89
  - lib/sylvia/cli.rb
90
+ - lib/sylvia/llm.rb
91
+ - lib/sylvia/prettier.rb
92
+ - lib/sylvia/rubocop.rb
90
93
  - lib/sylvia/version.rb
91
- - package.json
92
94
  - sig/sylvia.rbs
93
95
  - spec/spec_helper.rb
94
96
  - spec/sylvia_spec.rb
@@ -114,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
116
  - !ruby/object:Gem::Version
115
117
  version: '0'
116
118
  requirements: []
117
- rubygems_version: 3.6.3
119
+ rubygems_version: 3.7.1
118
120
  specification_version: 4
119
121
  summary: A command-line tool for generating and managing Ruby projects.
120
122
  test_files: []
data/.prettierrc DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "plugins": ["@prettier/plugin-ruby"],
3
- "rubyStrictMode": false,
4
- "tabWidth": 2,
5
- "useTabs": false,
6
- "singleQuote": true
7
- }
data/package.json DELETED
@@ -1,28 +0,0 @@
1
- {
2
- "name": "sylvia",
3
- "version": "1.0.0",
4
- "description": "TODO: Delete this and the text below, and describe your gem",
5
- "main": "index.js",
6
- "directories": {
7
- "example": "examples",
8
- "lib": "lib"
9
- },
10
- "scripts": {
11
- "test": "echo \"Error: no test specified\" && exit 1"
12
- },
13
- "repository": {
14
- "type": "git",
15
- "url": "git+https://github.com/whdzera/sylvia.git"
16
- },
17
- "keywords": [],
18
- "author": "",
19
- "license": "ISC",
20
- "bugs": {
21
- "url": "https://github.com/whdzera/sylvia/issues"
22
- },
23
- "homepage": "https://github.com/whdzera/sylvia#readme",
24
- "devDependencies": {
25
- "prettier": "^3.5.3",
26
- "@prettier/plugin-ruby": "^4.0.4"
27
- }
28
- }