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 +4 -4
- data/lib/genie/session.rb +4 -2
- data/lib/genie/version.rb +1 -1
- data/lib/genie.rb +1 -0
- data/lib/tools/list_files.rb +8 -15
- data/test/tools/test_list_files.rb +3 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b8833039cb511082479f5b8cbe3dee54620d908900ecbcd908c13f8c99992d4
|
4
|
+
data.tar.gz: f058b13fc6b3990c169d44b83119c4d4ce282dde8c7f4ae5de790f188e8dcf3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/lib/genie.rb
CHANGED
data/lib/tools/list_files.rb
CHANGED
@@ -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
|
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
|
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
|
33
|
+
listing.reject! { |entry| @ignore_paths.any? { |ignore_path| entry.start_with?(ignore_path) } }
|
34
34
|
|
35
|
-
Genie.output listing.
|
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 =
|
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 =
|
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 =
|
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
|