sgr_agent_tools/lib.rs
1//! sgr-agent-tools — 14 reusable file-system tools for sgr-agent based AI agents.
2//!
3//! All tools are generic over [`FileBackend`] trait.
4//!
5//! **Core (10):** ReadTool (+ indentation mode), WriteTool (JSON repair),
6//! DeleteTool (batch), SearchTool (smart search), ListTool, TreeTool,
7//! ReadAllTool, MkDirTool, MoveTool, FindTool.
8//!
9//! **Optional:** EvalTool (feature `eval`), ShellTool (feature `shell`),
10//! ApplyPatchTool (feature `patch` — Codex-compatible diff DSL).
11//!
12//! # Usage
13//!
14//! ```rust,ignore
15//! use sgr_agent_tools::{FileBackend, TreeTool, ReadTool, SearchTool, WriteTool};
16//!
17//! // Implement FileBackend for your runtime
18//! impl FileBackend for MyBackend { ... }
19//!
20//! // Create tools
21//! let b = Arc::new(MyBackend::new());
22//! let registry = ToolRegistry::new()
23//! .register(ReadTool(b.clone()))
24//! .register(WriteTool(b.clone()))
25//! .register(SearchTool(b.clone()))
26//! .register(TreeTool(b.clone()))
27//! .register_deferred(MkDirTool(b.clone()));
28//! ```
29
30pub mod backend;
31pub mod helpers;
32pub mod trust;
33
34// Core tools
35pub mod delete;
36pub mod list;
37pub mod read;
38pub mod read_all;
39pub mod search;
40pub mod tree;
41pub mod write;
42
43// Dynamic context injection for skills
44pub mod skill_context;
45
46// Deferred tools
47pub mod find;
48pub mod mkdir;
49pub mod move_file;
50
51// Optional: eval (heavy dep on boa_engine)
52#[cfg(feature = "eval")]
53pub mod eval;
54
55// Optional: shell (needs tokio process feature)
56#[cfg(feature = "shell")]
57pub mod shell;
58
59// Optional: apply_patch (Codex-compatible diff editing)
60#[cfg(feature = "patch")]
61pub mod apply_patch;
62
63// Optional: local filesystem backend (std::fs + tokio::fs)
64#[cfg(feature = "local-fs")]
65pub mod local_fs;
66
67// Re-export the core trait
68pub use backend::FileBackend;
69
70#[cfg(feature = "local-fs")]
71pub use local_fs::LocalFs;
72
73// Re-export all tools
74pub use delete::DeleteTool;
75pub use find::FindTool;
76pub use list::ListTool;
77pub use mkdir::MkDirTool;
78pub use move_file::MoveTool;
79pub use read::ReadTool;
80pub use read_all::ReadAllTool;
81pub use search::SearchTool;
82pub use tree::TreeTool;
83pub use write::WriteTool;
84
85#[cfg(feature = "eval")]
86pub use eval::EvalTool;
87
88#[cfg(feature = "shell")]
89pub use shell::ShellTool;
90
91#[cfg(feature = "patch")]
92pub use apply_patch::ApplyPatchTool;
93
94// Re-export helpers for wrapper tools (PAC1 uses these for Pac1SearchTool, etc.)
95pub use helpers::{backend_err, has_matches, unique_files_from_search};
96pub use search::{auto_expand_search, expand_query, fuzzy_regex, is_regex, smart_search};
97pub use trust::{infer_trust, wrap_with_meta};