Class: Yorishiro::Tools::ListFiles
Instance Method Summary
collapse
#configure, #definition, #permission_check, #preview
Instance Method Details
#description ⇒ Object
14
15
16
|
# File 'lib/yorishiro/tools/list_files.rb', line 14
def description
"List files in a directory. Optionally filter with a glob pattern."
end
|
#execute(**params) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/yorishiro/tools/list_files.rb', line 29
def execute(**params)
path = params[:path] || params["path"] || "."
pattern = params[:pattern] || params["pattern"]
raise "Directory not found: #{path}" unless Dir.exist?(path)
entries = if pattern
Dir.glob(File.join(path, pattern)).map { |f| [f, f] }
else
Dir.children(path).sort.map { |name| [name, File.join(path, name)] }
end
entries.map { |display, full| File.directory?(full) ? "#{display}/" : display }.join("\n")
end
|
#name ⇒ Object
10
11
12
|
# File 'lib/yorishiro/tools/list_files.rb', line 10
def name
"list_files"
end
|
#parameters ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/yorishiro/tools/list_files.rb', line 18
def parameters
{
type: "object",
properties: {
path: { type: "string", description: "The directory path to list (default: current directory)" },
pattern: { type: "string", description: "Glob pattern to filter files (e.g., '**/*.rb')" }
},
required: []
}
end
|
#read_only? ⇒ Boolean
6
7
8
|
# File 'lib/yorishiro/tools/list_files.rb', line 6
def read_only?
true
end
|