acp: Tool name prep (#36726)
Prep work for deduping tool names Release Notes: - N/A
This commit is contained in:
parent
ca139b701e
commit
e1a96b68f0
21 changed files with 126 additions and 123 deletions
|
@ -1,7 +1,7 @@
|
|||
use crate::{AgentTool, ToolCallEventStream};
|
||||
use agent_client_protocol::ToolKind;
|
||||
use anyhow::{Context as _, Result, anyhow};
|
||||
use gpui::{App, AppContext, Entity, SharedString, Task};
|
||||
use gpui::{App, AppContext, Entity, Task};
|
||||
use project::Project;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -50,11 +50,11 @@ impl AgentTool for CopyPathTool {
|
|||
type Input = CopyPathToolInput;
|
||||
type Output = String;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"copy_path".into()
|
||||
fn name() -> &'static str {
|
||||
"copy_path"
|
||||
}
|
||||
|
||||
fn kind(&self) -> ToolKind {
|
||||
fn kind() -> ToolKind {
|
||||
ToolKind::Move
|
||||
}
|
||||
|
||||
|
|
|
@ -41,11 +41,11 @@ impl AgentTool for CreateDirectoryTool {
|
|||
type Input = CreateDirectoryToolInput;
|
||||
type Output = String;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"create_directory".into()
|
||||
fn name() -> &'static str {
|
||||
"create_directory"
|
||||
}
|
||||
|
||||
fn kind(&self) -> ToolKind {
|
||||
fn kind() -> ToolKind {
|
||||
ToolKind::Read
|
||||
}
|
||||
|
||||
|
|
|
@ -44,11 +44,11 @@ impl AgentTool for DeletePathTool {
|
|||
type Input = DeletePathToolInput;
|
||||
type Output = String;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"delete_path".into()
|
||||
fn name() -> &'static str {
|
||||
"delete_path"
|
||||
}
|
||||
|
||||
fn kind(&self) -> ToolKind {
|
||||
fn kind() -> ToolKind {
|
||||
ToolKind::Delete
|
||||
}
|
||||
|
||||
|
|
|
@ -63,11 +63,11 @@ impl AgentTool for DiagnosticsTool {
|
|||
type Input = DiagnosticsToolInput;
|
||||
type Output = String;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"diagnostics".into()
|
||||
fn name() -> &'static str {
|
||||
"diagnostics"
|
||||
}
|
||||
|
||||
fn kind(&self) -> acp::ToolKind {
|
||||
fn kind() -> acp::ToolKind {
|
||||
acp::ToolKind::Read
|
||||
}
|
||||
|
||||
|
|
|
@ -186,11 +186,11 @@ impl AgentTool for EditFileTool {
|
|||
type Input = EditFileToolInput;
|
||||
type Output = EditFileToolOutput;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"edit_file".into()
|
||||
fn name() -> &'static str {
|
||||
"edit_file"
|
||||
}
|
||||
|
||||
fn kind(&self) -> acp::ToolKind {
|
||||
fn kind() -> acp::ToolKind {
|
||||
acp::ToolKind::Edit
|
||||
}
|
||||
|
||||
|
@ -517,7 +517,6 @@ fn resolve_path(
|
|||
mod tests {
|
||||
use super::*;
|
||||
use crate::{ContextServerRegistry, Templates};
|
||||
use action_log::ActionLog;
|
||||
use client::TelemetrySettings;
|
||||
use fs::Fs;
|
||||
use gpui::{TestAppContext, UpdateGlobal};
|
||||
|
@ -535,7 +534,6 @@ mod tests {
|
|||
fs.insert_tree("/root", json!({})).await;
|
||||
let project = Project::test(fs.clone(), [path!("/root").as_ref()], cx).await;
|
||||
let language_registry = project.read_with(cx, |project, _cx| project.languages().clone());
|
||||
let action_log = cx.new(|_| ActionLog::new(project.clone()));
|
||||
let context_server_registry =
|
||||
cx.new(|cx| ContextServerRegistry::new(project.read(cx).context_server_store(), cx));
|
||||
let model = Arc::new(FakeLanguageModel::default());
|
||||
|
@ -544,7 +542,6 @@ mod tests {
|
|||
project,
|
||||
cx.new(|_cx| ProjectContext::default()),
|
||||
context_server_registry,
|
||||
action_log,
|
||||
Templates::new(),
|
||||
Some(model),
|
||||
cx,
|
||||
|
@ -735,7 +732,6 @@ mod tests {
|
|||
}
|
||||
});
|
||||
|
||||
let action_log = cx.new(|_| ActionLog::new(project.clone()));
|
||||
let context_server_registry =
|
||||
cx.new(|cx| ContextServerRegistry::new(project.read(cx).context_server_store(), cx));
|
||||
let model = Arc::new(FakeLanguageModel::default());
|
||||
|
@ -744,7 +740,6 @@ mod tests {
|
|||
project,
|
||||
cx.new(|_cx| ProjectContext::default()),
|
||||
context_server_registry,
|
||||
action_log.clone(),
|
||||
Templates::new(),
|
||||
Some(model.clone()),
|
||||
cx,
|
||||
|
@ -801,7 +796,9 @@ mod tests {
|
|||
"Code should be formatted when format_on_save is enabled"
|
||||
);
|
||||
|
||||
let stale_buffer_count = action_log.read_with(cx, |log, cx| log.stale_buffers(cx).count());
|
||||
let stale_buffer_count = thread
|
||||
.read_with(cx, |thread, _cx| thread.action_log.clone())
|
||||
.read_with(cx, |log, cx| log.stale_buffers(cx).count());
|
||||
|
||||
assert_eq!(
|
||||
stale_buffer_count, 0,
|
||||
|
@ -879,14 +876,12 @@ mod tests {
|
|||
let context_server_registry =
|
||||
cx.new(|cx| ContextServerRegistry::new(project.read(cx).context_server_store(), cx));
|
||||
let language_registry = project.read_with(cx, |project, _cx| project.languages().clone());
|
||||
let action_log = cx.new(|_| ActionLog::new(project.clone()));
|
||||
let model = Arc::new(FakeLanguageModel::default());
|
||||
let thread = cx.new(|cx| {
|
||||
Thread::new(
|
||||
project,
|
||||
cx.new(|_cx| ProjectContext::default()),
|
||||
context_server_registry,
|
||||
action_log.clone(),
|
||||
Templates::new(),
|
||||
Some(model.clone()),
|
||||
cx,
|
||||
|
@ -1008,14 +1003,12 @@ mod tests {
|
|||
let context_server_registry =
|
||||
cx.new(|cx| ContextServerRegistry::new(project.read(cx).context_server_store(), cx));
|
||||
let language_registry = project.read_with(cx, |project, _cx| project.languages().clone());
|
||||
let action_log = cx.new(|_| ActionLog::new(project.clone()));
|
||||
let model = Arc::new(FakeLanguageModel::default());
|
||||
let thread = cx.new(|cx| {
|
||||
Thread::new(
|
||||
project,
|
||||
cx.new(|_cx| ProjectContext::default()),
|
||||
context_server_registry,
|
||||
action_log.clone(),
|
||||
Templates::new(),
|
||||
Some(model.clone()),
|
||||
cx,
|
||||
|
@ -1146,14 +1139,12 @@ mod tests {
|
|||
let language_registry = project.read_with(cx, |project, _cx| project.languages().clone());
|
||||
let context_server_registry =
|
||||
cx.new(|cx| ContextServerRegistry::new(project.read(cx).context_server_store(), cx));
|
||||
let action_log = cx.new(|_| ActionLog::new(project.clone()));
|
||||
let model = Arc::new(FakeLanguageModel::default());
|
||||
let thread = cx.new(|cx| {
|
||||
Thread::new(
|
||||
project,
|
||||
cx.new(|_cx| ProjectContext::default()),
|
||||
context_server_registry,
|
||||
action_log.clone(),
|
||||
Templates::new(),
|
||||
Some(model.clone()),
|
||||
cx,
|
||||
|
@ -1254,7 +1245,6 @@ mod tests {
|
|||
)
|
||||
.await;
|
||||
let language_registry = project.read_with(cx, |project, _cx| project.languages().clone());
|
||||
let action_log = cx.new(|_| ActionLog::new(project.clone()));
|
||||
let context_server_registry =
|
||||
cx.new(|cx| ContextServerRegistry::new(project.read(cx).context_server_store(), cx));
|
||||
let model = Arc::new(FakeLanguageModel::default());
|
||||
|
@ -1263,7 +1253,6 @@ mod tests {
|
|||
project.clone(),
|
||||
cx.new(|_cx| ProjectContext::default()),
|
||||
context_server_registry.clone(),
|
||||
action_log.clone(),
|
||||
Templates::new(),
|
||||
Some(model.clone()),
|
||||
cx,
|
||||
|
@ -1336,7 +1325,6 @@ mod tests {
|
|||
.await;
|
||||
let project = Project::test(fs.clone(), [path!("/project").as_ref()], cx).await;
|
||||
let language_registry = project.read_with(cx, |project, _cx| project.languages().clone());
|
||||
let action_log = cx.new(|_| ActionLog::new(project.clone()));
|
||||
let context_server_registry =
|
||||
cx.new(|cx| ContextServerRegistry::new(project.read(cx).context_server_store(), cx));
|
||||
let model = Arc::new(FakeLanguageModel::default());
|
||||
|
@ -1345,7 +1333,6 @@ mod tests {
|
|||
project.clone(),
|
||||
cx.new(|_cx| ProjectContext::default()),
|
||||
context_server_registry.clone(),
|
||||
action_log.clone(),
|
||||
Templates::new(),
|
||||
Some(model.clone()),
|
||||
cx,
|
||||
|
@ -1421,7 +1408,6 @@ mod tests {
|
|||
.await;
|
||||
let project = Project::test(fs.clone(), [path!("/project").as_ref()], cx).await;
|
||||
let language_registry = project.read_with(cx, |project, _cx| project.languages().clone());
|
||||
let action_log = cx.new(|_| ActionLog::new(project.clone()));
|
||||
let context_server_registry =
|
||||
cx.new(|cx| ContextServerRegistry::new(project.read(cx).context_server_store(), cx));
|
||||
let model = Arc::new(FakeLanguageModel::default());
|
||||
|
@ -1430,7 +1416,6 @@ mod tests {
|
|||
project.clone(),
|
||||
cx.new(|_cx| ProjectContext::default()),
|
||||
context_server_registry.clone(),
|
||||
action_log.clone(),
|
||||
Templates::new(),
|
||||
Some(model.clone()),
|
||||
cx,
|
||||
|
@ -1503,7 +1488,6 @@ mod tests {
|
|||
let fs = project::FakeFs::new(cx.executor());
|
||||
let project = Project::test(fs.clone(), [path!("/project").as_ref()], cx).await;
|
||||
let language_registry = project.read_with(cx, |project, _cx| project.languages().clone());
|
||||
let action_log = cx.new(|_| ActionLog::new(project.clone()));
|
||||
let context_server_registry =
|
||||
cx.new(|cx| ContextServerRegistry::new(project.read(cx).context_server_store(), cx));
|
||||
let model = Arc::new(FakeLanguageModel::default());
|
||||
|
@ -1512,7 +1496,6 @@ mod tests {
|
|||
project.clone(),
|
||||
cx.new(|_cx| ProjectContext::default()),
|
||||
context_server_registry,
|
||||
action_log.clone(),
|
||||
Templates::new(),
|
||||
Some(model.clone()),
|
||||
cx,
|
||||
|
|
|
@ -118,11 +118,11 @@ impl AgentTool for FetchTool {
|
|||
type Input = FetchToolInput;
|
||||
type Output = String;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"fetch".into()
|
||||
fn name() -> &'static str {
|
||||
"fetch"
|
||||
}
|
||||
|
||||
fn kind(&self) -> acp::ToolKind {
|
||||
fn kind() -> acp::ToolKind {
|
||||
acp::ToolKind::Fetch
|
||||
}
|
||||
|
||||
|
|
|
@ -85,11 +85,11 @@ impl AgentTool for FindPathTool {
|
|||
type Input = FindPathToolInput;
|
||||
type Output = FindPathToolOutput;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"find_path".into()
|
||||
fn name() -> &'static str {
|
||||
"find_path"
|
||||
}
|
||||
|
||||
fn kind(&self) -> acp::ToolKind {
|
||||
fn kind() -> acp::ToolKind {
|
||||
acp::ToolKind::Search
|
||||
}
|
||||
|
||||
|
|
|
@ -67,11 +67,11 @@ impl AgentTool for GrepTool {
|
|||
type Input = GrepToolInput;
|
||||
type Output = String;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"grep".into()
|
||||
fn name() -> &'static str {
|
||||
"grep"
|
||||
}
|
||||
|
||||
fn kind(&self) -> acp::ToolKind {
|
||||
fn kind() -> acp::ToolKind {
|
||||
acp::ToolKind::Search
|
||||
}
|
||||
|
||||
|
|
|
@ -51,11 +51,11 @@ impl AgentTool for ListDirectoryTool {
|
|||
type Input = ListDirectoryToolInput;
|
||||
type Output = String;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"list_directory".into()
|
||||
fn name() -> &'static str {
|
||||
"list_directory"
|
||||
}
|
||||
|
||||
fn kind(&self) -> ToolKind {
|
||||
fn kind() -> ToolKind {
|
||||
ToolKind::Read
|
||||
}
|
||||
|
||||
|
|
|
@ -52,11 +52,11 @@ impl AgentTool for MovePathTool {
|
|||
type Input = MovePathToolInput;
|
||||
type Output = String;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"move_path".into()
|
||||
fn name() -> &'static str {
|
||||
"move_path"
|
||||
}
|
||||
|
||||
fn kind(&self) -> ToolKind {
|
||||
fn kind() -> ToolKind {
|
||||
ToolKind::Move
|
||||
}
|
||||
|
||||
|
|
|
@ -32,11 +32,11 @@ impl AgentTool for NowTool {
|
|||
type Input = NowToolInput;
|
||||
type Output = String;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"now".into()
|
||||
fn name() -> &'static str {
|
||||
"now"
|
||||
}
|
||||
|
||||
fn kind(&self) -> acp::ToolKind {
|
||||
fn kind() -> acp::ToolKind {
|
||||
acp::ToolKind::Other
|
||||
}
|
||||
|
||||
|
|
|
@ -37,11 +37,11 @@ impl AgentTool for OpenTool {
|
|||
type Input = OpenToolInput;
|
||||
type Output = String;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"open".into()
|
||||
fn name() -> &'static str {
|
||||
"open"
|
||||
}
|
||||
|
||||
fn kind(&self) -> ToolKind {
|
||||
fn kind() -> ToolKind {
|
||||
ToolKind::Execute
|
||||
}
|
||||
|
||||
|
|
|
@ -59,11 +59,11 @@ impl AgentTool for ReadFileTool {
|
|||
type Input = ReadFileToolInput;
|
||||
type Output = LanguageModelToolResultContent;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"read_file".into()
|
||||
fn name() -> &'static str {
|
||||
"read_file"
|
||||
}
|
||||
|
||||
fn kind(&self) -> acp::ToolKind {
|
||||
fn kind() -> acp::ToolKind {
|
||||
acp::ToolKind::Read
|
||||
}
|
||||
|
||||
|
|
|
@ -63,11 +63,11 @@ impl AgentTool for TerminalTool {
|
|||
type Input = TerminalToolInput;
|
||||
type Output = String;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"terminal".into()
|
||||
fn name() -> &'static str {
|
||||
"terminal"
|
||||
}
|
||||
|
||||
fn kind(&self) -> acp::ToolKind {
|
||||
fn kind() -> acp::ToolKind {
|
||||
acp::ToolKind::Execute
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,11 @@ impl AgentTool for ThinkingTool {
|
|||
type Input = ThinkingToolInput;
|
||||
type Output = String;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"thinking".into()
|
||||
fn name() -> &'static str {
|
||||
"thinking"
|
||||
}
|
||||
|
||||
fn kind(&self) -> acp::ToolKind {
|
||||
fn kind() -> acp::ToolKind {
|
||||
acp::ToolKind::Think
|
||||
}
|
||||
|
||||
|
|
|
@ -40,11 +40,11 @@ impl AgentTool for WebSearchTool {
|
|||
type Input = WebSearchToolInput;
|
||||
type Output = WebSearchToolOutput;
|
||||
|
||||
fn name(&self) -> SharedString {
|
||||
"web_search".into()
|
||||
fn name() -> &'static str {
|
||||
"web_search"
|
||||
}
|
||||
|
||||
fn kind(&self) -> acp::ToolKind {
|
||||
fn kind() -> acp::ToolKind {
|
||||
acp::ToolKind::Fetch
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue