返回 DeepSeek-TUI-2026
tool_setup.rs
根目录 / crates / tui / src / core / engine / tool_setup.rs
1 //! Per-turn tool registry setup.
2 //!
3 //! This keeps mode/feature-specific registry construction out of the send path.
4
5 use super::*;
6
7 impl Engine {
8 pub(super) fn build_turn_tool_registry_builder(
9 &self,
10 mode: AppMode,
11 todo_list: SharedTodoList,
12 plan_state: SharedPlanState,
13 ) -> ToolRegistryBuilder {
14 let mut builder = if mode == AppMode::Plan {
15 ToolRegistryBuilder::new()
16 .with_read_only_file_tools()
17 .with_search_tools()
18 .with_git_tools()
19 .with_git_history_tools()
20 .with_diagnostics_tool()
21 .with_skill_tools()
22 .with_validation_tools()
23 .with_runtime_task_tools()
24 .with_todo_tool(todo_list)
25 .with_plan_tool(plan_state)
26 } else {
27 ToolRegistryBuilder::new()
28 .with_agent_tools(self.session.allow_shell)
29 .with_todo_tool(todo_list)
30 .with_plan_tool(plan_state)
31 };
32
33 builder = builder
34 .with_review_tool(self.deepseek_client.clone(), self.session.model.clone())
35 .with_rlm_tool(self.deepseek_client.clone(), self.session.model.clone())
36 .with_fim_tool(self.deepseek_client.clone(), self.session.model.clone())
37 .with_user_input_tool()
38 .with_parallel_tool();
39
40 if self.config.features.enabled(Feature::ApplyPatch) && mode != AppMode::Plan {
41 builder = builder.with_patch_tools();
42 }
43 if self.config.features.enabled(Feature::WebSearch) {
44 builder = builder.with_web_tools();
45 }
46 // Plan mode keeps shell available when the session allows it; command
47 // safety and approval checks still gate risky commands.
48 if self.config.features.enabled(Feature::ShellTool) && self.session.allow_shell {
49 builder = builder.with_shell_tools();
50 }
51
52 // Register the `remember` tool only when the user has opted in to
53 // user-memory (#489). Without that opt-in the tool would always
54 // fail; surfacing it would just waste catalog slots.
55 if self.config.memory_enabled {
56 builder = builder.with_remember_tool();
57 }
58
59 builder
60 }
61 }
62
62 lines RUST