Skip to main content

deepseek_rust_cli/tools/schemas/
mod.rs

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