main
 1# frozen_string_literal: true
 2
 3Elelem::Plugins.register(:glob) do |agent|
 4  agent.toolbox.add("glob",
 5    description: "Find files matching pattern",
 6    params: { pattern: { type: "string" }, path: { type: "string" } },
 7    required: ["pattern"]
 8  ) do |a|
 9    path = a["path"] || "."
10    result = agent.toolbox.exec("fd", "--glob", a["pattern"], path)
11    result[:ok] ? result : agent.toolbox.exec("find", path, "-name", a["pattern"])
12  end
13end