genie_cli 0.2.1 → 0.2.4

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: f9431dda686ce68a45532465d2d0f75baabb62e7dee4dc5278d51cdbd0cf00b7
4
- data.tar.gz: 86a77baeb167e1bdf058d020368a9069599f44c69fee4d290830bc02fb83cf96
3
+ metadata.gz: 9b8833039cb511082479f5b8cbe3dee54620d908900ecbcd908c13f8c99992d4
4
+ data.tar.gz: f058b13fc6b3990c169d44b83119c4d4ce282dde8c7f4ae5de790f188e8dcf3b
5
5
  SHA512:
6
- metadata.gz: 8cc795dbe839e79b4e2d859051f2bb7c7fdcbaad70c50d17ded96d581aca5fe15cf2482c6d13fd39657f35872e0f997deb7a1bda4f54ad9b89c619600508cffa
7
- data.tar.gz: d9a87bb13bfd5e679baa1934904c348e6e957b7737211c06992d85439e1740cc52e2be77cd5820fd47279d5c04ae5c4582266e6df29afa906e812b8206f3879d
6
+ metadata.gz: 6b281e4cbfde5084204a0cfca381a018d707c8e08dfc006e088c7dc7544df57b19710fe8861a616c9cb2cd2e375489a88f553a90b3db2798efc745e0b52af1e3
7
+ data.tar.gz: f6d58af389ae61f318b97d89d6fae5c24a9f494d571c86b94a93820fff1e032d81f103298abad5ba6c3c8c98281569e75e56af7d5d3276f2d99cdba2e90e44ad
data/lib/genie/session.rb CHANGED
@@ -8,7 +8,7 @@ module Genie
8
8
  QUIT_COMMANDS = ["q", "quit", "done", "exit", "bye"].freeze
9
9
 
10
10
  # Config holds these for us
11
- def_delegators :@config, :model, :base_path, :run_tests_cmd, :instructions
11
+ def_delegators :@config, :model, :base_path, :run_tests_cmd, :instructions, :ignore_paths
12
12
 
13
13
  # Initializes the session with a pre-loaded configuration
14
14
  # config: instance of Genie::SessionConfig
@@ -20,6 +20,8 @@ module Genie
20
20
  Genie.output "Your wish is my command!", color: :magenta
21
21
  Genie.output " base_path: #{base_path}", color: :cyan, include_genie_icon: false
22
22
  Genie.output " model: #{model}", color: :cyan, include_genie_icon: false
23
+ Genie.output " run_tests_cmd: #{run_tests_cmd}", color: :cyan, include_genie_icon: false
24
+ Genie.output " ignore_paths: #{ignore_paths}", color: :cyan, include_genie_icon: false
23
25
 
24
26
  # Initialize the LLM chat with the specified model
25
27
  @chat = RubyLLM.chat(model: model)
@@ -32,7 +34,7 @@ module Genie
32
34
  Genie::AppendToFile.new(base_path: base_path),
33
35
  Genie::AskForHelp.new,
34
36
  # Genie::InsertIntoFile.new(base_path: base_path),
35
- Genie::ListFiles.new(base_path: base_path),
37
+ Genie::ListFiles.new(base_path: base_path, ignore_paths: ignore_paths),
36
38
  Genie::ReadFile.new(base_path: base_path),
37
39
  Genie::RenameFile.new(base_path: base_path),
38
40
  # Genie::ReplaceLinesInFile.new(base_path: base_path),
data/lib/genie/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Genie
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.4'
3
3
  end
data/lib/genie.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "yaml"
1
2
  require "ruby_llm"
2
3
  require "dotenv/load"
3
4
  require "tty-command"
@@ -4,7 +4,7 @@ module Genie
4
4
  include SandboxedFileTool
5
5
 
6
6
  description "Lists the files in the given directory"
7
- param :directory, desc: "Directory path to list files from (e.g., '/home/user/documents')"
7
+ param :directory, desc: "Directory path to list files from (e.g., '/home/user/documents') Default is '.' (current directory)"
8
8
  param :recursive, desc: "Whether to list files recursively (default: false)"
9
9
  param :filter, desc: "Filter string to include only paths that include this substring (Optional)"
10
10
 
@@ -15,7 +15,7 @@ module Genie
15
15
  @ignore_paths = ignore_paths
16
16
  end
17
17
 
18
- def execute(directory:, recursive: false, filter: nil)
18
+ def execute(directory: '.', recursive: false, filter: nil)
19
19
  directory = File.expand_path(directory, @base_path)
20
20
 
21
21
  Genie.output "Listing files in directory: #{directory} (recursive: #{recursive})", color: :blue
@@ -26,15 +26,15 @@ module Genie
26
26
 
27
27
  # Apply filter if provided
28
28
  if filter && !filter.empty?
29
- listing = listing.select { |entry| entry[:name].include?(filter) }
29
+ listing = listing.select { |entry| entry.include?(filter) }
30
30
  end
31
31
 
32
32
  # Apply ignore paths
33
- listing.reject! { |entry| @ignore_paths.any? { |ignore_path| entry[:name].gsub(@base_path, '').start_with?(ignore_path) } }
33
+ listing.reject! { |entry| @ignore_paths.any? { |ignore_path| entry.start_with?(ignore_path) } }
34
34
 
35
- Genie.output listing.map { |e| e[:name] }.join("\n") + "\n", color: :green
35
+ Genie.output listing.join("\n") + "\n", color: :green
36
36
 
37
- listing
37
+ listing.join("\n")
38
38
  rescue => e
39
39
  Genie.output "Error: #{e.message}", color: :red
40
40
  { error: e.message }
@@ -45,11 +45,7 @@ module Genie
45
45
  def list_recursive(directory)
46
46
  Dir.glob(File.join(directory, '**', '*')).map do |file_path|
47
47
  # next if File.basename(file_path).start_with?('.') # Skip hidden files
48
-
49
- {
50
- name: file_path,
51
- type: File.file?(file_path) ? 'file' : 'directory',
52
- }
48
+ file_path.gsub(@base_path, '')
53
49
  end.compact
54
50
  end
55
51
 
@@ -59,10 +55,7 @@ module Genie
59
55
 
60
56
  file_path = File.join(directory, filename)
61
57
 
62
- {
63
- name: filename,
64
- type: File.file?(file_path) ? 'file' : 'directory',
65
- }
58
+ file_path.gsub(@base_path, '')
66
59
  end.compact # Remove any nil entries (e.g., hidden files or directories)
67
60
  end
68
61
 
@@ -4,9 +4,7 @@ class TestListFiles < TLDR
4
4
  def test_list_files
5
5
  actual = Genie::ListFiles.new(base_path: File.expand_path("../../", __dir__)).execute(directory: "./test/data/sample_files")
6
6
 
7
- expected = [{ name: "read_file_test.txt", type: "file" },
8
- { name: "one.txt", type: "file" },
9
- { name: "a_dir", type: "directory" }]
7
+ expected = "/test/data/sample_files/read_file_test.txt\n/test/data/sample_files/one.txt\n/test/data/sample_files/a_dir"
10
8
 
11
9
  assert_equal expected, actual
12
10
  end
@@ -24,7 +22,7 @@ class TestListFiles < TLDR
24
22
  t = Genie::ListFiles.new(base_path: base_path)
25
23
  actual = t.execute(directory: "./test/data/sample_files", filter: "one")
26
24
 
27
- expected = [{ name: "one.txt", type: "file" }]
25
+ expected = "/test/data/sample_files/one.txt"
28
26
 
29
27
  assert_equal expected, actual
30
28
  end
@@ -35,8 +33,7 @@ class TestListFiles < TLDR
35
33
 
36
34
  actual = t.execute(directory: "./test/data/sample_files")
37
35
 
38
- expected = [{ name: "read_file_test.txt", type: "file" },
39
- { name: "one.txt", type: "file" }]
36
+ expected = "/test/data/sample_files/read_file_test.txt\n/test/data/sample_files/one.txt\n/test/data/sample_files/a_dir"
40
37
 
41
38
  assert_equal expected, actual
42
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genie_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff McFadden