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
list_directoryList files and directories at a path
findFind files by name/glob pattern
grepSearch file contents for a pattern
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 true if the named tool is classified as destructive.

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(),
  changeset: pid() | nil,
  fork_store: pid() | 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.

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 (defaults to ["write_file", "edit_file", "shell"]). 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()

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.