Skip to main content

deepseek_rust_cli/tools/schemas/
mod.rs

1use crate::api::types::Tool;
2use serde_json::json;
3
4mod file_io;
5mod git;
6mod github;
7mod system;
8mod web;
9
10/// Full unfiltered tool list (used when context detection isn't available).
11pub fn get_tools_schemas() -> Vec<Tool> {
12    get_filtered_tools_schemas(true, true)
13}
14
15/// Return tool schemas filtered by context:
16/// - `is_git_repo`: include local git tools (status, diff, commit, push, etc.)
17/// - `has_github_token`: include GitHub API tools
18///
19/// Core tools (shell, file I/O, code/web) are always included.
20pub fn get_filtered_tools_schemas(is_git_repo: bool, has_github_token: bool) -> Vec<Tool> {
21    let mut tools = Vec::with_capacity(40);
22
23    // ─── Shell & System (always) ────────────────────────────
24    system::add_system_schemas(&mut tools);
25
26    // ─── File I/O (always) ──────────────────────────────────
27    file_io::add_file_io_schemas(&mut tools);
28
29    // ─── Code & Web & Refactoring (always) ──────────────────
30    web::add_web_schemas(&mut tools);
31
32    // ─── Local Git Operations (only if in a git repo) ──────
33    if is_git_repo {
34        git::add_git_schemas(&mut tools);
35    }
36
37    // ─── GitHub API Operations (only if GITHUB_TOKEN is set)
38    if has_github_token {
39        github::add_github_schemas(&mut tools);
40    }
41
42    tools
43}
44
45fn create_tool(name: &str, desc: &str, props: serde_json::Value, required: Vec<&str>) -> Tool {
46    Tool {
47        r#type: "function".to_string(),
48        function: crate::api::types::FunctionDefinition {
49            name: name.to_string(),
50            description: desc.to_string(),
51            parameters: json!({
52                "type": "object",
53                "properties": props,
54                "required": required
55            }),
56        },
57    }
58}