From fae5900749c9347021d4d226ae59fa7b6d7b5a86 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Sun, 17 Aug 2025 13:24:27 -0600 Subject: [PATCH] factor otu --- crates/agent2/src/agent.rs | 59 ++++++++++++++++--------------------- crates/agent2/src/thread.rs | 4 +-- 2 files changed, 28 insertions(+), 35 deletions(-) diff --git a/crates/agent2/src/agent.rs b/crates/agent2/src/agent.rs index 89317b921059fcfe797468819e0d68d649de3840..65f6e38c56c4cb0295a196756bda210b20445ee6 100644 --- a/crates/agent2/src/agent.rs +++ b/crates/agent2/src/agent.rs @@ -563,6 +563,30 @@ impl NativeAgentConnection { }) }) } + + fn register_tools( + thread: &mut Thread, + project: Entity, + action_log: Entity, + cx: &mut Context, + ) { + thread.add_tool(CopyPathTool::new(project.clone())); + thread.add_tool(CreateDirectoryTool::new(project.clone())); + thread.add_tool(DeletePathTool::new(project.clone(), action_log.clone())); + thread.add_tool(DiagnosticsTool::new(project.clone())); + thread.add_tool(EditFileTool::new(cx.entity())); + thread.add_tool(FetchTool::new(project.read(cx).client().http_client())); + thread.add_tool(FindPathTool::new(project.clone())); + thread.add_tool(GrepTool::new(project.clone())); + thread.add_tool(ListDirectoryTool::new(project.clone())); + thread.add_tool(MovePathTool::new(project.clone())); + thread.add_tool(NowTool); + thread.add_tool(OpenTool::new(project.clone())); + thread.add_tool(ReadFileTool::new(project.clone(), action_log)); + thread.add_tool(TerminalTool::new(project.clone(), cx)); + thread.add_tool(ThinkingTool); + thread.add_tool(WebSearchTool); // TODO: Enable this only if it's a zed model. + } } impl AgentModelSelector for NativeAgentConnection { @@ -709,22 +733,7 @@ impl acp_thread::AgentConnection for NativeAgentConnection { default_model, cx, ); - thread.add_tool(CopyPathTool::new(project.clone())); - thread.add_tool(CreateDirectoryTool::new(project.clone())); - thread.add_tool(DeletePathTool::new(project.clone(), action_log.clone())); - thread.add_tool(DiagnosticsTool::new(project.clone())); - thread.add_tool(EditFileTool::new(cx.entity())); - thread.add_tool(FetchTool::new(project.read(cx).client().http_client())); - thread.add_tool(FindPathTool::new(project.clone())); - thread.add_tool(GrepTool::new(project.clone())); - thread.add_tool(ListDirectoryTool::new(project.clone())); - thread.add_tool(MovePathTool::new(project.clone())); - thread.add_tool(NowTool); - thread.add_tool(OpenTool::new(project.clone())); - thread.add_tool(ReadFileTool::new(project.clone(), action_log)); - thread.add_tool(TerminalTool::new(project.clone(), cx)); - thread.add_tool(ThinkingTool); - thread.add_tool(WebSearchTool); // TODO: Enable this only if it's a zed model. + Self::register_tools(&mut thread, project, action_log, cx); thread }); @@ -852,23 +861,7 @@ impl acp_thread::AgentConnection for NativeAgentConnection { model, cx, ); - // todo!() factor this out - thread.add_tool(CopyPathTool::new(project.clone())); - thread.add_tool(CreateDirectoryTool::new(project.clone())); - thread.add_tool(DeletePathTool::new(project.clone(), action_log.clone())); - thread.add_tool(DiagnosticsTool::new(project.clone())); - thread.add_tool(EditFileTool::new(cx.entity())); - thread.add_tool(FetchTool::new(project.read(cx).client().http_client())); - thread.add_tool(FindPathTool::new(project.clone())); - thread.add_tool(GrepTool::new(project.clone())); - thread.add_tool(ListDirectoryTool::new(project.clone())); - thread.add_tool(MovePathTool::new(project.clone())); - thread.add_tool(NowTool); - thread.add_tool(OpenTool::new(project.clone())); - thread.add_tool(ReadFileTool::new(project.clone(), action_log)); - thread.add_tool(TerminalTool::new(project.clone(), cx)); - thread.add_tool(ThinkingTool); - thread.add_tool(WebSearchTool); // TODO: Enable this only if it's a zed model. + Self::register_tools(&mut thread, project, action_log, cx); thread }); diff --git a/crates/agent2/src/thread.rs b/crates/agent2/src/thread.rs index 784477d677a2f4af78b39757c059e471c453e2ec..33f0208ab72fcbcce3417b06df8f0c65e32c9af4 100644 --- a/crates/agent2/src/thread.rs +++ b/crates/agent2/src/thread.rs @@ -441,7 +441,7 @@ impl Thread { cx: &mut Context, ) -> Self { let profile_id = AgentSettings::get_global(cx).default_profile.clone(); - Self { + let this = Self { messages: Vec::new(), completion_mode: CompletionMode::Normal, running_turn: None, @@ -455,7 +455,7 @@ impl Thread { model, project, action_log, - } + }; } pub fn project(&self) -> &Entity {