Skip to main content

git_iris/agents/tools/
registry.rs

1//! Tool registry for consistent tool attachment across agents
2//!
3//! This module provides macros and utilities for attaching the standard tool set
4//! to agents in a consistent manner, preventing drift between main agents and subagents.
5
6/// Attach the core analysis tools to an agent builder.
7///
8/// These are the standard tools available to all agents and subagents for
9/// code analysis tasks. Does NOT include delegation tools (`Workspace`, `ParallelAnalyze`,
10/// sub-agent) to prevent recursion.
11///
12/// # Usage
13/// ```ignore
14/// let agent = attach_core_tools!(client.agent(model).preamble("..."));
15/// ```
16#[macro_export]
17macro_rules! attach_core_tools {
18    ($builder:expr) => {{
19        use $crate::agents::debug_tool::DebugTool;
20        use $crate::agents::tools::{
21            CodeSearch, FileRead, GitBlame, GitChangedFiles, GitDiff, GitLog, GitShow, GitStatus,
22            ProjectDocs, RepoMapTool, StaticAnalysis,
23        };
24
25        $builder
26            .tool(DebugTool::new(GitStatus))
27            .tool(DebugTool::new(GitDiff))
28            .tool(DebugTool::new(GitLog))
29            .tool(DebugTool::new(GitShow))
30            .tool(DebugTool::new(GitChangedFiles))
31            .tool(DebugTool::new(GitBlame))
32            .tool(DebugTool::new(FileRead))
33            .tool(DebugTool::new(CodeSearch))
34            .tool(DebugTool::new(RepoMapTool))
35            .tool(DebugTool::new(StaticAnalysis))
36            .tool(DebugTool::new(ProjectDocs))
37    }};
38}
39
40/// Core tools list for reference - these are the tools attached by `attach_core_tools!`
41pub const CORE_TOOLS: &[&str] = &[
42    "git_status",
43    "git_diff",
44    "git_log",
45    "git_show",
46    "git_changed_files",
47    "git_blame",
48    "file_read",
49    "code_search",
50    "repo_map",
51    "static_analysis",
52    "project_docs",
53];
54
55// Re-export the macro at module level
56pub use attach_core_tools;
57
58#[cfg(test)]
59mod tests {
60    use super::*;
61
62    #[test]
63    fn core_tools_count() {
64        assert_eq!(CORE_TOOLS.len(), 11);
65    }
66}