Skip to main content

Crate sgr_agent_tools

Crate sgr_agent_tools 

Source
Expand description

sgr-agent-tools — 15 reusable file-system tools for sgr-agent based AI agents.

All tools are generic over FileBackend trait.

Core (11): ReadTool (+ indentation mode), WriteTool (JSON repair), DeleteTool (batch), SearchTool (smart search), ListTool, TreeTool, ReadAllTool, CopyTool, MkDirTool, MoveTool, FindTool.

Optional: EvalTool (feature eval), ShellTool (feature shell), ApplyPatchTool (feature patch — Codex-compatible diff DSL).

§Usage

use sgr_agent_tools::{FileBackend, TreeTool, ReadTool, SearchTool, WriteTool};

// Implement FileBackend for your runtime
impl FileBackend for MyBackend { ... }

// Create tools
let b = Arc::new(MyBackend::new());
let registry = ToolRegistry::new()
    .register(ReadTool(b.clone()))
    .register(WriteTool(b.clone()))
    .register(SearchTool(b.clone()))
    .register(TreeTool(b.clone()))
    .register_deferred(MkDirTool(b.clone()));

Re-exports§

pub use mock_fs::MockFs;
pub use copy::CopyTool;
pub use delete::DeleteTool;
pub use find::FindTool;
pub use list::ListTool;
pub use mkdir::MkDirTool;
pub use move_file::MoveTool;
pub use prepend::PrependTool;
pub use read::ReadTool;
pub use read_all::ReadAllTool;
pub use search::SearchTool;
pub use tree::TreeTool;
pub use write::WriteTool;
pub use plan::PlanState;
pub use plan::PlanStep;
pub use plan::UpdatePlanTool;
pub use helpers::backend_err;
pub use helpers::has_matches;
pub use helpers::truncate_output;
pub use search::expand_query;
pub use search::fuzzy_regex;
pub use search::is_regex;
pub use trust::infer_trust;
pub use trust::wrap_with_meta;

Modules§

backend
FileBackend trait — re-exported from sgr-agent-core.
copy
CopyTool — copy a file without LLM in the loop (byte-perfect).
delete
DeleteTool — delete one or more files (batch delete support).
find
FindTool — find files/directories by name pattern.
helpers
Shared helpers for tool implementations.
list
ListTool — list directory contents.
mkdir
MkDirTool — create a directory.
mock_fs
MockFs — in-memory FileBackend for testing.
move_file
MoveTool — move or rename a file.
plan
UpdatePlanTool — task checklist that persists to disk.
prepend
PrependTool — prepend header text to a file without touching the body.
read
ReadTool — read file contents with trust metadata.
read_all
ReadAllTool — batch read all files in a directory.
search
SearchTool — smart search with query expansion, fuzzy matching, and auto-expand.
skill_context
Dynamic context injection for skills.
tree
TreeTool — show directory tree structure.
trust
Trust metadata — tag file reads with trust level for LLM safety.
write
WriteTool — write content to a file with JSON auto-repair.

Traits§

FileBackend
Filesystem backend that tools delegate to.