MingaAgent.Tools (Minga v0.1.0)

Copy Markdown View Source

Tool definitions for the native agent provider.

Each tool is a ReqLLM.Tool struct with a name, description, JSON Schema parameters, and a callback that executes the operation. Tools are scoped to the project root directory for safety: file operations refuse to escape the project boundary.

Available tools

ToolDescription
read_fileRead file contents (supports offset/limit for slices)
write_fileWrite content to a file (creates or overwrites)
edit_fileReplace exact text in a file
multi_edit_fileApply multiple edits to one file in a single call
apply_diffApply a unified diff to one file
delete_fileDelete a file
list_directoryList files and directories at a path
findFind files by name/glob pattern
grepSearch file contents for a pattern
fetch_urlFetch a URL and return readable text content
shellRun a shell command in the project root
git_statusShow changed files with structured status (read-only)
git_diffShow unified diff for files or all changes (read-only)
git_logShow recent commits with structured output (read-only)
git_stageStage files for commit (destructive)
git_commitCreate a commit with a message (destructive)
memory_writeSave a learning or preference to persistent memory
diagnosticsGet current LSP diagnostics for a file (read-only)
definitionFind where a symbol is defined via LSP (read-only)
referencesFind all usages of a symbol via LSP (read-only)
hoverGet type info and docs for a symbol via LSP (read-only)
document_symbolsList all symbols in a file via LSP (read-only)
workspace_symbolsSearch for symbols project-wide via LSP (read-only)
renameSemantic rename across the project via LSP (destructive)
code_actionsList/apply LSP code actions (apply is destructive)
describe_runtimeDescribe the runtime's capabilities and features
describe_toolsList all available tools with descriptions

Summary

Types

Options passed to all/1.

Functions

Returns all available tools scoped to the given project root.

Returns all core built-in tool names.

Returns source-owned built-in tool declarations.

Returns true if the named tool is classified as destructive.

Returns the file/project read tool subset for constrained rewrite sessions.

Returns true when the tool name is allowed in constrained file-read sessions.

Returns the read-only tool subset for ephemeral inline ask sessions.

Returns true when the tool name is allowed in read-only sessions.

Resolves a relative path against the project root and validates that the resolved path does not escape the root directory.

Types

tools_opts()

@type tools_opts() :: [
  project_root: String.t(),
  project_view: MingaAgent.ProjectView.t() | nil,
  changeset: pid() | nil,
  fork_store: pid() | nil,
  parent_session: GenServer.server() | nil,
  shell_output_callback: (String.t() -> :ok) | nil
]

Options passed to all/1.

Functions

all(opts \\ [])

@spec all(tools_opts()) :: [ReqLLM.Tool.t()]

Returns all available tools scoped to the given project root.

The project_root is baked into each tool's callback closure so that every file operation is sandboxed to that directory tree.

builtin_names()

@spec builtin_names() :: [String.t()]

Returns all core built-in tool names.

builtin_specs()

@spec builtin_specs() :: [MingaAgent.Tool.Spec.t()]

Returns source-owned built-in tool declarations.

destructive?(name)

@spec destructive?(String.t()) :: boolean()

Returns true if the named tool is classified as destructive.

Reads the configured list from :agent_destructive_tools. Accepts an optional list override for testing without starting the Options agent.

Some tools have conditional destructiveness based on their arguments. Pass the tool arguments map to check parameter-dependent cases like code_actions with apply set.

destructive?(name, args)

@spec destructive?(String.t(), map()) :: boolean()

destructive?(name, args, destructive_list)

@spec destructive?(String.t(), map(), [String.t()]) :: boolean()

file_read(opts \\ [])

@spec file_read(tools_opts()) :: [ReqLLM.Tool.t()]

Returns the file/project read tool subset for constrained rewrite sessions.

file_read_name?(name)

@spec file_read_name?(ReqLLM.Tool.t() | String.t()) :: boolean()

Returns true when the tool name is allowed in constrained file-read sessions.

read_only(opts \\ [])

@spec read_only(tools_opts()) :: [ReqLLM.Tool.t()]

Returns the read-only tool subset for ephemeral inline ask sessions.

read_only_name?(name)

@spec read_only_name?(ReqLLM.Tool.t() | String.t()) :: boolean()

Returns true when the tool name is allowed in read-only sessions.

resolve_and_validate_path!(root, relative_path)

@spec resolve_and_validate_path!(String.t(), String.t()) :: String.t()

Resolves a relative path against the project root and validates that the resolved path does not escape the root directory.

Raises ArgumentError if the path escapes the project root.