rubycode 0.1.0 ā 0.1.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 +4 -4
- data/.rubocop.yml +8 -0
- data/README.md +82 -13
- data/USAGE.md +93 -0
- data/config/tools/bash.json +17 -0
- data/config/tools/done.json +17 -0
- data/config/tools/read.json +25 -0
- data/config/tools/search.json +29 -0
- data/lib/rubycode/adapters/base.rb +16 -0
- data/lib/rubycode/adapters/ollama.rb +65 -0
- data/lib/rubycode/agent_loop.rb +134 -0
- data/lib/rubycode/client/display_formatter.rb +53 -0
- data/lib/rubycode/client/response_handler.rb +55 -0
- data/lib/rubycode/client.rb +74 -0
- data/lib/rubycode/configuration.rb +21 -0
- data/lib/rubycode/context_builder.rb +21 -0
- data/lib/rubycode/errors.rb +21 -0
- data/lib/rubycode/history.rb +39 -0
- data/lib/rubycode/tools/base.rb +80 -0
- data/lib/rubycode/tools/bash.rb +66 -0
- data/lib/rubycode/tools/done.rb +14 -0
- data/lib/rubycode/tools/read.rb +60 -0
- data/lib/rubycode/tools/search.rb +64 -0
- data/lib/rubycode/tools.rb +37 -0
- data/lib/rubycode/value_objects.rb +102 -0
- data/lib/rubycode/version.rb +2 -2
- data/lib/rubycode.rb +24 -3
- data/rubycode_cli.rb +88 -0
- metadata +29 -3
data/rubycode_cli.rb
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative "lib/rubycode"
|
|
5
|
+
require "readline"
|
|
6
|
+
|
|
7
|
+
puts "\n#{"=" * 80}"
|
|
8
|
+
puts "š RubyCode - AI Ruby/Rails Code Assistant"
|
|
9
|
+
puts "=" * 80
|
|
10
|
+
|
|
11
|
+
# Ask for directory
|
|
12
|
+
print "\nWhat directory do you want to work on? (default: current directory): "
|
|
13
|
+
directory = gets.chomp
|
|
14
|
+
directory = Dir.pwd if directory.empty?
|
|
15
|
+
|
|
16
|
+
# Resolve the full path
|
|
17
|
+
full_path = File.expand_path(directory)
|
|
18
|
+
|
|
19
|
+
unless Dir.exist?(full_path)
|
|
20
|
+
puts "\nā Error: Directory '#{full_path}' does not exist!"
|
|
21
|
+
exit 1
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
puts "\nš Working directory: #{full_path}"
|
|
25
|
+
|
|
26
|
+
# Ask if debug mode should be enabled
|
|
27
|
+
print "Enable debug mode? (shows JSON requests/responses) [y/N]: "
|
|
28
|
+
debug_input = gets.chomp.downcase
|
|
29
|
+
debug_mode = %w[y yes].include?(debug_input)
|
|
30
|
+
|
|
31
|
+
# Configure the client
|
|
32
|
+
RubyCode.configure do |config|
|
|
33
|
+
config.adapter = :ollama
|
|
34
|
+
config.url = "http://localhost:11434"
|
|
35
|
+
config.model = "deepseek-v3.1:671b-cloud"
|
|
36
|
+
config.root_path = full_path
|
|
37
|
+
config.debug = debug_mode
|
|
38
|
+
|
|
39
|
+
# Enable workaround to force tool-calling for models that don't follow instructions
|
|
40
|
+
config.enable_tool_injection_workaround = true
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
puts "š Debug mode: #{debug_mode ? "ON" : "OFF"}" if debug_mode
|
|
44
|
+
|
|
45
|
+
# Create a client
|
|
46
|
+
client = RubyCode::Client.new
|
|
47
|
+
|
|
48
|
+
puts "\n#{"=" * 80}"
|
|
49
|
+
puts "⨠Agent initialized! You can now ask questions or request code changes."
|
|
50
|
+
puts " Type 'exit' or 'quit' to exit, 'clear' to clear history"
|
|
51
|
+
puts "=" * 80
|
|
52
|
+
|
|
53
|
+
# Interactive loop
|
|
54
|
+
loop do
|
|
55
|
+
print "\nš¬ You: "
|
|
56
|
+
prompt = Readline.readline("", true)
|
|
57
|
+
|
|
58
|
+
# Handle empty input
|
|
59
|
+
next if prompt.nil? || prompt.strip.empty?
|
|
60
|
+
|
|
61
|
+
# Handle commands
|
|
62
|
+
case prompt.strip.downcase
|
|
63
|
+
when "exit", "quit"
|
|
64
|
+
puts "\nš Goodbye!"
|
|
65
|
+
break
|
|
66
|
+
when "clear"
|
|
67
|
+
client.clear_history
|
|
68
|
+
puts "\nšļø History cleared!"
|
|
69
|
+
next
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
puts "\n#{"-" * 80}"
|
|
73
|
+
|
|
74
|
+
begin
|
|
75
|
+
# Get response from agent
|
|
76
|
+
response = client.ask(prompt: prompt)
|
|
77
|
+
|
|
78
|
+
puts "\nš¤ Agent:"
|
|
79
|
+
puts "-" * 80
|
|
80
|
+
puts response
|
|
81
|
+
puts "-" * 80
|
|
82
|
+
rescue Interrupt
|
|
83
|
+
puts "\n\nā ļø Interrupted! Type 'exit' to quit or continue chatting."
|
|
84
|
+
rescue StandardError => e
|
|
85
|
+
puts "\nā Error: #{e.message}"
|
|
86
|
+
puts e.backtrace.first(3).join("\n")
|
|
87
|
+
end
|
|
88
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubycode
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonas Medeiros
|
|
@@ -21,14 +21,40 @@ files:
|
|
|
21
21
|
- LICENSE.txt
|
|
22
22
|
- README.md
|
|
23
23
|
- Rakefile
|
|
24
|
+
- USAGE.md
|
|
25
|
+
- config/tools/bash.json
|
|
26
|
+
- config/tools/done.json
|
|
27
|
+
- config/tools/read.json
|
|
28
|
+
- config/tools/search.json
|
|
24
29
|
- lib/rubycode.rb
|
|
30
|
+
- lib/rubycode/adapters/base.rb
|
|
31
|
+
- lib/rubycode/adapters/ollama.rb
|
|
32
|
+
- lib/rubycode/agent_loop.rb
|
|
33
|
+
- lib/rubycode/client.rb
|
|
34
|
+
- lib/rubycode/client/display_formatter.rb
|
|
35
|
+
- lib/rubycode/client/response_handler.rb
|
|
36
|
+
- lib/rubycode/configuration.rb
|
|
37
|
+
- lib/rubycode/context_builder.rb
|
|
38
|
+
- lib/rubycode/errors.rb
|
|
39
|
+
- lib/rubycode/history.rb
|
|
40
|
+
- lib/rubycode/tools.rb
|
|
41
|
+
- lib/rubycode/tools/base.rb
|
|
42
|
+
- lib/rubycode/tools/bash.rb
|
|
43
|
+
- lib/rubycode/tools/done.rb
|
|
44
|
+
- lib/rubycode/tools/read.rb
|
|
45
|
+
- lib/rubycode/tools/search.rb
|
|
46
|
+
- lib/rubycode/value_objects.rb
|
|
25
47
|
- lib/rubycode/version.rb
|
|
48
|
+
- rubycode_cli.rb
|
|
26
49
|
- sig/rubycode.rbs
|
|
27
|
-
homepage: https://
|
|
50
|
+
homepage: https://github.com/jonasmedeiros/rubycode
|
|
28
51
|
licenses:
|
|
29
52
|
- MIT
|
|
30
53
|
metadata:
|
|
31
|
-
homepage_uri: https://
|
|
54
|
+
homepage_uri: https://github.com/jonasmedeiros/rubycode
|
|
55
|
+
source_code_uri: https://github.com/jonasmedeiros/rubycode
|
|
56
|
+
bug_tracker_uri: https://github.com/jonasmedeiros/rubycode/issues
|
|
57
|
+
rubygems_mfa_required: 'true'
|
|
32
58
|
rdoc_options: []
|
|
33
59
|
require_paths:
|
|
34
60
|
- lib
|