Packages

fnord

0.4.25

AI code archaeology

Current section

Files

Jump to
fnord lib ai tools list_files.ex
Raw

lib/ai/tools/list_files.ex

defmodule AI.Tools.ListFiles do
@behaviour AI.Tools
@impl AI.Tools
def spec() do
%{
type: "function",
function: %{
name: "list_files_tool",
description: """
Lists all files in the project database. You can discover quite a bit
about a project by examining the layout of the repository.
""",
parameters: %{
type: "object",
required: [],
properties: %{}
}
}
}
end
@impl AI.Tools
def call(agent, _args) do
status_id = Tui.add_step("Listing files in project", agent.opts.project)
Store.new(agent.opts.project)
|> Store.list_files()
|> Enum.join("\n")
|> then(fn res ->
Tui.finish_step(status_id, :ok)
{:ok, "[list_files_tool]\n#{res}"}
end)
end
end