Files
zesdex/apps/infrastructure/src/tools/mod.rs
T

77 lines
2.5 KiB
Rust
Raw Normal View History

//! Tool trait, execution context, and the registry of all built-in tools.
//!
//! This module defines the core `Tool` trait that every agent-invocable tool
//! must implement, the shared `ToolCtx` execution context, and utility
//! functions for path resolution, command execution, argument extraction,
//! and graduated-check rules.
//!
//! # Organisation
//!
//! ```text
//! tools/
//! ├── mod.rs — Tool trait, re-exports
//! ├── context.rs — ToolCtx, ToolCtxBuilder
//! ├── registry.rs — all_tools(), tool_defs(), tool_is_risky()
//! ├── util.rs — arg_str(), execute_cmd(), resolve_path(),
//! │ log_write_edit_tool()
//! ├── graduated.rs — GraduatedCheck, check_graduated_checks()
//! ├── executor.rs — InfrastructureToolExecutor
//! ├── fs/ — read, write, edit, delete
//! ├── git/ — git_operator, git_worktree, git_cred
//! ├── lsp/ — connect, disconnect, diagnostics, completion, etc.
//! ├── memory/ — remember, forget, recall
//! ├── utility/ — cd, dir_list, pong, todowrite, todofinish, etc.
//! ├── shell.rs — Bash tool
//! ├── bash_tools.rs
//! ├── search.rs — Grep, Glob
//! ├── semantic_search.rs
//! ├── web_search.rs
//! ├── sequential_think.rs
//! ├── plan.rs, spawn.rs, workflow.rs
//! └── parallel_delegate.rs
//! ```
use anyhow::Result;
use serde_json::Value;
pub mod bash_tools;
pub mod context;
pub mod executor;
pub mod fs;
pub mod git;
pub mod graduated;
pub mod lsp;
pub mod memory;
pub mod parallel_delegate;
pub mod plan;
pub mod registry;
pub mod search;
pub mod semantic_search;
pub mod sequential_think;
pub mod shell;
pub mod shell_filter;
pub mod spawn;
pub mod utility;
pub mod util;
pub mod web_search;
pub mod workflow;
// Re-export commonly used items at the `tools` root so existing imports
// like `crate::tools::{Tool, ToolCtx}` continue to work.
pub use context::{ToolCtx, ToolCtxBuilder};
pub use graduated::{check_graduated_checks, GraduatedCheck};
pub use registry::{all_tools, tool_defs, tool_is_risky};
pub use util::{arg_str, execute_cmd, log_write_edit_tool, resolve_path};
/// Common interface every agent-invocable tool implements.
pub trait Tool: Send + Sync {
fn name(&self) -> &'static str;
fn description(&self) -> &'static str;
fn parameters(&self) -> Value;
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String>;
}
pub use git::git_cred;
pub use git::git_operator;
pub use git::git_worktree;