sylvia 0.2.1 → 0.2.2

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: 7f9ecbb50b89f7254c1283157123b2113eea53c62898ce089dfb83ea65ea8d28
4
+ data.tar.gz: d7f8883c1b1ec0a3b1735308b9d29edf184f9bccca2065f61f3fc503b24f9b7c
5
5
  SHA512:
6
- metadata.gz: 61a5beda98de772f434ed84d85776925105b136ab26ab3a92f38175b615d2cfaf8c9b73181d7a0cba8f3cfff775a537a5d904264be38d6c94ffe68e887c40ab2
7
- data.tar.gz: 9e0784427701bac5cbf4b8d6ada49069cc618da76aec4c55f518a09531735d09e4175c3c89a070b6f04e6a8a9783f1344a028f33aeed3c0c18b40f274e3614ae
6
+ metadata.gz: a76aaefa7ab89f2e7530e786561ea0fa7ee78c075f73030e0f3681024dd78f7d6a4dfb962759d613df1baabbf9d9f6d08823d978c2e77c09d535033ecd931d68
7
+ data.tar.gz: 2e91b75f6734d6fab43fde3330082765953ffcd2a4966343ab2bac2512c5d6a8ab6c84c4d0dab460c0d9e61066b9c823506bd1ca84460f83abf01602cb62e2b2
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,41 @@ 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
+ run ruby_LLM `sylvia.rb`
34
53
 
35
54
  ## Development
36
55
 
data/lib/sylvia/cli.rb CHANGED
@@ -1,113 +1,32 @@
1
1
  require "json"
2
+ require_relative "llm"
3
+ require_relative "prettier"
4
+ require_relative "rubocop"
2
5
 
3
6
  module Sylvia
4
7
  class CLI
5
- FILE_NAME = "sylvia.rb"
6
- PRETTIER_FILE = ".prettierrc"
7
- PACKAGE_FILE = "package.json"
8
-
9
8
  def self.start(args)
10
9
  command = args.shift
11
10
 
12
11
  case command
13
12
  when "llm"
14
- setup_llm
13
+ LLM.setup
15
14
  when "ai"
16
- run_llm
15
+ LLM.run
17
16
  when "prettier"
18
- setup_prettier
17
+ Prettier.setup
18
+ when "rubocop"
19
+ RuboCop.setup
20
+ when "rubocop-todo"
21
+ RuboCop.generate_todo
19
22
  else
20
23
  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
24
+ puts " sylvia llm # Create setup file llm"
25
+ puts " sylvia ai # Run llm"
26
+ puts " sylvia prettier # Setup Prettier for Ruby"
27
+ puts " sylvia rubocop # Create .rubocop.yml config file"
28
+ puts " sylvia rubocop-todo # Generate .rubocop_todo.yml automatically"
64
29
  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
30
  end
112
31
  end
113
32
  end
data/lib/sylvia/llm.rb ADDED
@@ -0,0 +1,38 @@
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
+ require 'dotenv'
10
+ Dotenv.load
11
+
12
+ RubyLLM.configure do |config|
13
+ config.gemini_api_key = ENV.fetch('gemini', nil)
14
+ end
15
+
16
+ chat = RubyLLM.chat(model: 'gemini-2.0-flash')
17
+
18
+ response = chat.ask "how to improve this code", with: ["assets/example.rb", "assets/example2.rb"]
19
+
20
+ markdown = response.content.to_s
21
+
22
+ puts TTY::Markdown.parse(markdown)
23
+ RUBY
24
+
25
+ File.write(FILE_NAME, content)
26
+ puts "Created #{FILE_NAME}"
27
+ end
28
+
29
+ def self.run
30
+ unless File.exist?(FILE_NAME)
31
+ puts "#{FILE_NAME} not found. Run `sylvia llm` first."
32
+ return
33
+ end
34
+
35
+ system("ruby #{FILE_NAME}")
36
+ end
37
+ end
38
+ 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,87 @@
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
+ return
9
+ end
10
+
11
+ config_content = <<~YAML
12
+ AllCops:
13
+ Include:
14
+ - "**/*.rb"
15
+ - "**/*.rake"
16
+ - "."
17
+ Exclude:
18
+ - "vendor/**/*"
19
+ - "db/schema.rb"
20
+ NewCops: enable
21
+
22
+ Layout/LineLength:
23
+ Max: 120
24
+ Exclude:
25
+ - "spec/**/*"
26
+
27
+ Style/BlockDelimiters:
28
+ Exclude:
29
+ - "spec/**/*"
30
+
31
+ Lint/AmbiguousBlockAssociation:
32
+ Exclude:
33
+ - "spec/**/*"
34
+
35
+ Metrics/BlockLength:
36
+ Exclude:
37
+ - "spec/**/*"
38
+
39
+ Layout/HeredocIndentation:
40
+ Enabled: false
41
+
42
+ Metrics/ClassLength:
43
+ Max: 175
44
+
45
+ Metrics/MethodLength:
46
+ Max: 25
47
+
48
+ Metrics/ParameterLists:
49
+ Max: 20
50
+
51
+ Metrics/AbcSize:
52
+ Enabled: false
53
+
54
+ Metrics/PerceivedComplexity:
55
+ Enabled: false
56
+
57
+ Metrics/CyclomaticComplexity:
58
+ Enabled: false
59
+
60
+ Style/HashEachMethods:
61
+ Enabled: true
62
+
63
+ Style/HashTransformKeys:
64
+ Enabled: false
65
+
66
+ Style/HashTransformValues:
67
+ Enabled: false
68
+ YAML
69
+
70
+ File.write(CONFIG_FILE, config_content)
71
+ puts "Created #{CONFIG_FILE}"
72
+ end
73
+
74
+ def self.generate_todo
75
+ todo_file = '.rubocop_todo.yml'
76
+
77
+ if File.exist?(todo_file)
78
+ puts "#{todo_file} already exists. Skipping generation."
79
+ return
80
+ end
81
+
82
+ puts 'Generating RuboCop TODO...'
83
+ system('rubocop --auto-gen-config --no-exclude-limit')
84
+ puts "RuboCop TODO generated (see #{todo_file})"
85
+ end
86
+ end
87
+ 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.2"
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.2
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: 2025-09-05 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
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
- }