Skip to main content

ararajuba_tools_coding/
lib.rs

1//! # ararajuba-tools-coding
2//!
3//! Standard coding-agent tool set for building Cursor/Claude Code style agents.
4//!
5//! Provides pre-built `ToolDef` instances for file system operations, git,
6//! shell execution, and code analysis. Combine with `ararajuba-core`'s `generate_text`
7//! in a tool loop to create autonomous coding agents.
8
9pub mod analysis;
10pub mod fs;
11pub mod git;
12pub mod shell;
13
14use ararajuba_core::tools::tool_set::ToolSet;
15
16/// Returns a `ToolSet` containing **all** coding tools.
17///
18/// High-risk tools (`execute_command`, `git_push`, `git_pull`) have
19/// `needs_approval` set so they require explicit confirmation.
20pub fn all_tools() -> ToolSet {
21    ToolSet::new()
22        // File system
23        .add(fs::read::read_file_tool())
24        .add(fs::write::write_file_tool())
25        .add(fs::patch::patch_file_tool())
26        .add(fs::list::list_directory_tool())
27        .add(fs::find::find_files_tool())
28        .add(fs::search::search_files_tool())
29        // Git
30        .add(git::status::git_status_tool())
31        .add(git::diff::git_diff_tool())
32        .add(git::log::git_log_tool())
33        .add(git::add::git_add_tool())
34        .add(git::commit::git_commit_tool())
35        .add(git::branch::git_branch_tool())
36        .add(git::checkout::git_checkout_tool())
37        .add(git::push::git_push_tool())
38        .add(git::pull::git_pull_tool())
39        .add(git::clone::git_clone_tool())
40        // Shell
41        .add(shell::exec::execute_command_tool())
42        // Analysis
43        .add(analysis::diagnostics::get_diagnostics_tool())
44}
45
46/// Returns a `ToolSet` containing only **safe** (read-only) tools that can
47/// run autonomously without user approval.
48pub fn safe_tools() -> ToolSet {
49    ToolSet::new()
50        .add(fs::read::read_file_tool())
51        .add(fs::list::list_directory_tool())
52        .add(fs::find::find_files_tool())
53        .add(fs::search::search_files_tool())
54        .add(git::status::git_status_tool())
55        .add(git::diff::git_diff_tool())
56        .add(git::log::git_log_tool())
57        .add(analysis::diagnostics::get_diagnostics_tool())
58}
59
60#[cfg(test)]
61mod tests {
62    use super::*;
63
64    #[test]
65    fn all_tools_has_expected_count() {
66        let tools = all_tools();
67        assert_eq!(tools.len(), 18);
68    }
69
70    #[test]
71    fn safe_tools_has_expected_count() {
72        let tools = safe_tools();
73        assert_eq!(tools.len(), 8);
74    }
75
76    #[test]
77    fn safe_tools_subset_of_all() {
78        let all = all_tools();
79        let safe = safe_tools();
80        for (name, _) in safe.iter() {
81            assert!(all.get(name).is_some(), "safe tool {name} not in all_tools");
82        }
83    }
84}