1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//! # Tool System Architecture
//!
//! This module provides a modular, composable architecture for VTCode agent tools,
//! implementing a registry-based system for tool discovery, execution, and management.
//!
//! ## Architecture Overview
//!
//! The tool system is designed around several key principles:
//!
//! - **Modularity**: Each tool is a focused, reusable component
//! - **Registry Pattern**: Centralized tool registration and discovery
//! - **Policy-Based Execution**: Configurable execution policies and safety checks
//! - **Type Safety**: Strong typing for tool parameters and results
//! - **Async Support**: Full async/await support for all tool operations
//!
//! ## Core Components
//!
//! ### Tool Registry
//! ```rust,no_run
//! use vtcode_core::tools::{ToolRegistry, ToolRegistration};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let workspace = std::env::current_dir()?;
//! let mut registry = ToolRegistry::new(workspace);
//!
//! // Register a custom tool
//! let tool = ToolRegistration {
//! name: "my_tool".to_string(),
//! description: "A custom tool".to_string(),
//! parameters: serde_json::json!({"type": "object"}),
//! handler: |args| async move {
//! Ok(serde_json::json!({"result": "success"}))
//! },
//! };
//!
//! registry.register_tool(tool).await?;
//! Ok(())
//! }
//! ```
//!
//! ### Tool Categories
//!
//! #### File Operations
//! - **File Operations**: Read, write, create, delete files
//! - **Search Tools**: Grep, AST-based search, advanced search
//! - **Cache Management**: File caching and performance optimization
//!
//! #### Terminal Integration
//! - **Bash Tools**: Shell command execution
//! - **PTY Support**: Full terminal emulation
//! - **Command Policies**: Safety and execution controls
//!
//! #### Code Analysis
//! - **Tree-Sitter**: Syntax-aware code analysis
//! - **AST Grep**: Structural code search and transformation
//! - **Srgn**: Syntax-aware code modification
//!
//! ## Tool Execution
//!
//! ```rust,no_run
//! use vtcode_core::tools::ToolRegistry;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let mut registry = ToolRegistry::new(std::env::current_dir()?);
//!
//! // Execute a tool
//! let args = serde_json::json!({"path": "."});
//! let result = registry.execute_tool("list_files", args).await?;
//!
//! println!("Result: {}", result);
//! Ok(())
//! }
//! ```
//!
//! ## Safety & Policies
//!
//! The tool system includes comprehensive safety features:
//!
//! - **Path Validation**: All file operations check workspace boundaries
//! - **Command Policies**: Configurable allow/deny lists for terminal commands
//! - **Execution Limits**: Timeout and resource usage controls
//! - **Audit Logging**: Complete trail of tool executions
//!
//! ## Custom Tool Development
//!
//! ```rust,no_run
//! use vtcode_core::tools::traits::Tool;
//! use serde_json::Value;
//!
//! struct MyCustomTool;
//!
//! #[async_trait::async_trait]
//! impl Tool for MyCustomTool {
//! async fn execute(&self, args: Value) -> Result<Value, Box<dyn std::error::Error + Send + Sync>> {
//! // Tool implementation
//! Ok(serde_json::json!({"status": "completed"}))
//! }
//!
//! fn name(&self) -> &str {
//! "my_custom_tool"
//! }
//!
//! fn description(&self) -> &str {
//! "A custom tool for specific tasks"
//! }
//!
//! fn parameters(&self) -> Value {
//! serde_json::json!({
//! "type": "object",
//! "properties": {
//! "input": {"type": "string"}
//! }
//! })
//! }
//! }
//! ```
//!
//! Modular tool system for VTCode
//!
//! This module provides a composable architecture for agent tools, breaking down
//! the monolithic implementation into focused, reusable components.
// Re-export main types and traits for backward compatibility
pub use AstGrepTool;
pub use BashTool;
pub use FileCache;
pub use CurlTool;
pub use GrepSearchManager;
pub use ;
pub use ;
pub use SimpleSearchTool;
pub use SrgnTool;
pub use ;
pub use *;
// Re-export function declarations for external use
pub use build_function_declarations;
pub use build_function_declarations_for_level;
pub use build_function_declarations_with_mode;