From f12fffd1ba62ae38217f618872500fb94386b4f0 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 1 Jul 2025 18:23:21 +0200 Subject: [PATCH] WIP --- Cargo.lock | 56 ++++++++++---------- Cargo.toml | 12 ++--- crates/{agent2 => acp}/Cargo.toml | 9 ++-- crates/{agent2 => acp}/LICENSE-GPL | 0 crates/{agent2 => acp}/src/acp.rs | 0 crates/{agent2 => acp}/src/agent2.rs | 18 ------- crates/{agent2 => acp}/src/thread_element.rs | 0 crates/agent_ui/Cargo.toml | 7 +-- crates/agent_ui/src/agent_panel.rs | 46 ++++++++-------- 9 files changed, 62 insertions(+), 86 deletions(-) rename crates/{agent2 => acp}/Cargo.toml (89%) rename crates/{agent2 => acp}/LICENSE-GPL (100%) rename crates/{agent2 => acp}/src/acp.rs (100%) rename crates/{agent2 => acp}/src/agent2.rs (94%) rename crates/{agent2 => acp}/src/thread_element.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index dee38013741c72842363793ab9f363daaca4c448..51e5e9371213b9815f58e5f1efe0c9170dacb57b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,33 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "acp" +version = "0.1.0" +dependencies = [ + "agentic-coding-protocol", + "anyhow", + "async-trait", + "base64 0.22.1", + "chrono", + "collections", + "editor", + "env_logger 0.11.8", + "futures 0.3.31", + "gpui", + "language", + "parking_lot", + "project", + "serde_json", + "settings", + "smol", + "ui", + "util", + "uuid", + "workspace-hack", + "zed_actions", +] + [[package]] name = "activity_indicator" version = "0.1.0" @@ -107,33 +134,6 @@ dependencies = [ "zstd", ] -[[package]] -name = "agent2" -version = "0.1.0" -dependencies = [ - "agentic-coding-protocol", - "anyhow", - "async-trait", - "base64 0.22.1", - "chrono", - "collections", - "editor", - "env_logger 0.11.8", - "futures 0.3.31", - "gpui", - "language", - "parking_lot", - "project", - "serde_json", - "settings", - "smol", - "ui", - "util", - "uuid", - "workspace-hack", - "zed_actions", -] - [[package]] name = "agent_settings" version = "0.1.0" @@ -157,8 +157,8 @@ dependencies = [ name = "agent_ui" version = "0.1.0" dependencies = [ + "acp", "agent", - "agent2", "agent_settings", "anyhow", "assistant_context", diff --git a/Cargo.toml b/Cargo.toml index f8f5c2a6d017cb8591d1a1f6426b70e7226188f5..45ed0e1dbe83f12193b1c36440d18969a399fe81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,9 +2,9 @@ resolver = "2" members = [ "crates/activity_indicator", + "crates/acp", "crates/agent_ui", "crates/agent", - "crates/agent2", "crates/agent_settings", "crates/anthropic", "crates/askpass", @@ -215,9 +215,9 @@ edition = "2024" # Workspace member crates # -activity_indicator = { path = "crates/activity_indicator" } +acp = { path = "crates/acp" } agent = { path = "crates/agent" } -agent2 = { path = "crates/agent2" } +activity_indicator = { path = "crates/activity_indicator" } agent_ui = { path = "crates/agent_ui" } agent_settings = { path = "crates/agent_settings" } ai = { path = "crates/ai" } @@ -481,7 +481,7 @@ json_dotpath = "1.1" jsonschema = "0.30.0" jsonwebtoken = "9.3" jupyter-protocol = { git = "https://github.com/ConradIrwin/runtimed", rev = "7130c804216b6914355d15d0b91ea91f6babd734" } -jupyter-websocket-client = { git = "https://github.com/ConradIrwin/runtimed" ,rev = "7130c804216b6914355d15d0b91ea91f6babd734" } +jupyter-websocket-client = { git = "https://github.com/ConradIrwin/runtimed", rev = "7130c804216b6914355d15d0b91ea91f6babd734" } libc = "0.2" libsqlite3-sys = { version = "0.30.1", features = ["bundled"] } linkify = "0.10.0" @@ -492,7 +492,7 @@ metal = "0.29" moka = { version = "0.12.10", features = ["sync"] } naga = { version = "25.0", features = ["wgsl-in"] } nanoid = "0.4" -nbformat = { git = "https://github.com/ConradIrwin/runtimed", rev = "7130c804216b6914355d15d0b91ea91f6babd734" } +nbformat = { git = "https://github.com/ConradIrwin/runtimed", rev = "7130c804216b6914355d15d0b91ea91f6babd734" } nix = "0.29" num-format = "0.4.4" objc = "0.2" @@ -532,7 +532,7 @@ reqwest = { git = "https://github.com/zed-industries/reqwest.git", rev = "951c77 "stream", ] } rsa = "0.9.6" -runtimelib = { git = "https://github.com/ConradIrwin/runtimed", rev = "7130c804216b6914355d15d0b91ea91f6babd734", default-features = false, features = [ +runtimelib = { git = "https://github.com/ConradIrwin/runtimed", rev = "7130c804216b6914355d15d0b91ea91f6babd734", default-features = false, features = [ "async-dispatcher-runtime", ] } rust-embed = { version = "8.4", features = ["include-exclude"] } diff --git a/crates/agent2/Cargo.toml b/crates/acp/Cargo.toml similarity index 89% rename from crates/agent2/Cargo.toml rename to crates/acp/Cargo.toml index 22ff0373fde1ac18f8d74ec4bc1d883ec7ea7f63..cd8be590b46f9ab2c248bc02085de4ce827ab658 100644 --- a/crates/agent2/Cargo.toml +++ b/crates/acp/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "agent2" +name = "acp" version = "0.1.0" edition.workspace = true publish.workspace = true @@ -9,14 +9,11 @@ license = "GPL-3.0-or-later" workspace = true [lib] -path = "src/agent2.rs" +path = "src/acp.rs" doctest = false [features] -test-support = [ - "gpui/test-support", - "project/test-support", -] +test-support = ["gpui/test-support", "project/test-support"] [dependencies] agentic-coding-protocol = { path = "../../../agentic-coding-protocol" } diff --git a/crates/agent2/LICENSE-GPL b/crates/acp/LICENSE-GPL similarity index 100% rename from crates/agent2/LICENSE-GPL rename to crates/acp/LICENSE-GPL diff --git a/crates/agent2/src/acp.rs b/crates/acp/src/acp.rs similarity index 100% rename from crates/agent2/src/acp.rs rename to crates/acp/src/acp.rs diff --git a/crates/agent2/src/agent2.rs b/crates/acp/src/agent2.rs similarity index 94% rename from crates/agent2/src/agent2.rs rename to crates/acp/src/agent2.rs index 7d194391359309d4c4a5b9d60274eaa6ff29aa49..ee6e8c9e559dac64179ddfd0a8b94203f5851495 100644 --- a/crates/agent2/src/agent2.rs +++ b/crates/acp/src/agent2.rs @@ -11,24 +11,6 @@ use std::{ops::Range, path::PathBuf, sync::Arc}; pub use acp::AcpAgent; pub use thread_element::ThreadElement; -#[async_trait(?Send)] -pub trait Agent: 'static { - async fn threads(&self, cx: &mut AsyncApp) -> Result>; - async fn create_thread(self: Arc, cx: &mut AsyncApp) -> Result>; - async fn open_thread(&self, id: ThreadId, cx: &mut AsyncApp) -> Result>; - async fn thread_entries( - &self, - id: ThreadId, - cx: &mut AsyncApp, - ) -> Result>; - async fn send_thread_message( - &self, - thread_id: ThreadId, - message: Message, - cx: &mut AsyncApp, - ) -> Result<()>; -} - #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ThreadId(SharedString); diff --git a/crates/agent2/src/thread_element.rs b/crates/acp/src/thread_element.rs similarity index 100% rename from crates/agent2/src/thread_element.rs rename to crates/acp/src/thread_element.rs diff --git a/crates/agent_ui/Cargo.toml b/crates/agent_ui/Cargo.toml index 33e5aa8de6be1f0a557bdacf0815c710718b2047..75c68b164469984c91d53ae8d5689a01c350116d 100644 --- a/crates/agent_ui/Cargo.toml +++ b/crates/agent_ui/Cargo.toml @@ -13,14 +13,11 @@ path = "src/agent_ui.rs" doctest = false [features] -test-support = [ - "gpui/test-support", - "language/test-support", -] +test-support = ["gpui/test-support", "language/test-support"] [dependencies] +acp.workspace = true agent.workspace = true -agent2.workspace = true agent_settings.workspace = true anyhow.workspace = true assistant_context.workspace = true diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index 7de916301c6b409f38830cbba321b58439891c68..938c1771bad1bb6d6ac56f2cf41d77aa5a8de308 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -133,7 +133,7 @@ pub fn init(cx: &mut App) { let thread = thread.read(cx).thread().clone(); AgentDiffPane::deploy_in_workspace(thread, workspace, window, cx); } - ActiveView::Agent2Thread { .. } => todo!(), + ActiveView::AcpThread { .. } => todo!(), ActiveView::TextThread { .. } | ActiveView::History | ActiveView::Configuration => {} @@ -197,7 +197,7 @@ enum ActiveView { message_editor: Entity, _subscriptions: Vec, }, - Agent2Thread { + AcpThread { thread_element: Entity, }, TextThread { @@ -219,7 +219,7 @@ enum WhichFontSize { impl ActiveView { pub fn which_font_size_used(&self) -> WhichFontSize { match self { - ActiveView::Thread { .. } | ActiveView::Agent2Thread { .. } | ActiveView::History => { + ActiveView::Thread { .. } | ActiveView::AcpThread { .. } | ActiveView::History => { WhichFontSize::AgentFont } ActiveView::TextThread { .. } => WhichFontSize::BufferFont, @@ -252,7 +252,7 @@ impl ActiveView { thread.scroll_to_bottom(cx); }); } - ActiveView::Agent2Thread { .. } => { + ActiveView::AcpThread { .. } => { // todo! } ActiveView::TextThread { .. } @@ -670,7 +670,7 @@ impl AgentPanel { .clone() .update(cx, |thread, cx| thread.get_or_init_configured_model(cx)); } - ActiveView::Agent2Thread { .. } => { + ActiveView::AcpThread { .. } => { // todo! } ActiveView::TextThread { .. } @@ -753,7 +753,7 @@ impl AgentPanel { ActiveView::Thread { thread, .. } => { thread.update(cx, |thread, cx| thread.cancel_last_completion(window, cx)); } - ActiveView::Agent2Thread { thread_element, .. } => { + ActiveView::AcpThread { thread_element, .. } => { thread_element.update(cx, |thread_element, _cx| thread_element.cancel()); } ActiveView::TextThread { .. } | ActiveView::History | ActiveView::Configuration => {} @@ -763,7 +763,7 @@ impl AgentPanel { fn active_message_editor(&self) -> Option<&Entity> { match &self.active_view { ActiveView::Thread { message_editor, .. } => Some(message_editor), - ActiveView::Agent2Thread { .. } => { + ActiveView::AcpThread { .. } => { // todo! None } @@ -921,7 +921,7 @@ impl AgentPanel { let thread_element = cx.new_window_entity(|window, cx| agent2::ThreadElement::new(thread, window, cx))?; this.update_in(cx, |this, window, cx| { - this.set_active_view(ActiveView::Agent2Thread { thread_element }, window, cx); + this.set_active_view(ActiveView::AcpThread { thread_element }, window, cx); }) }) .detach(); @@ -1092,7 +1092,7 @@ impl AgentPanel { ActiveView::Thread { message_editor, .. } => { message_editor.focus_handle(cx).focus(window); } - ActiveView::Agent2Thread { .. } => { + ActiveView::AcpThread { .. } => { todo!() } ActiveView::TextThread { context_editor, .. } => { @@ -1214,7 +1214,7 @@ impl AgentPanel { }) .log_err(); } - ActiveView::Agent2Thread { .. } => todo!(), + ActiveView::AcpThread { .. } => todo!(), ActiveView::TextThread { .. } | ActiveView::History | ActiveView::Configuration => {} } } @@ -1268,7 +1268,7 @@ impl AgentPanel { ) .detach_and_log_err(cx); } - ActiveView::Agent2Thread { .. } => { + ActiveView::AcpThread { .. } => { todo!() } ActiveView::TextThread { .. } | ActiveView::History | ActiveView::Configuration => {} @@ -1305,7 +1305,7 @@ impl AgentPanel { pub(crate) fn active_thread(&self, cx: &App) -> Option> { match &self.active_view { ActiveView::Thread { thread, .. } => Some(thread.read(cx).thread().clone()), - ActiveView::Agent2Thread { .. } => { + ActiveView::AcpThread { .. } => { // todo! None } @@ -1414,7 +1414,7 @@ impl AgentPanel { }); } } - ActiveView::Agent2Thread { .. } => { + ActiveView::AcpThread { .. } => { // todo! } _ => {} @@ -1432,7 +1432,7 @@ impl AgentPanel { } }) } - ActiveView::Agent2Thread { .. } => { + ActiveView::AcpThread { .. } => { // todo! push history entry } _ => {} @@ -1521,7 +1521,7 @@ impl Focusable for AgentPanel { fn focus_handle(&self, cx: &App) -> FocusHandle { match &self.active_view { ActiveView::Thread { message_editor, .. } => message_editor.focus_handle(cx), - ActiveView::Agent2Thread { thread_element, .. } => thread_element.focus_handle(cx), + ActiveView::AcpThread { thread_element, .. } => thread_element.focus_handle(cx), ActiveView::History => self.history.focus_handle(cx), ActiveView::TextThread { context_editor, .. } => context_editor.focus_handle(cx), ActiveView::Configuration => { @@ -1678,7 +1678,7 @@ impl AgentPanel { .into_any_element(), } } - ActiveView::Agent2Thread { thread_element } => { + ActiveView::AcpThread { thread_element } => { Label::new(thread_element.read(cx).title(cx)) .truncate() .into_any_element() @@ -1817,7 +1817,7 @@ impl AgentPanel { let active_thread = match &self.active_view { ActiveView::Thread { thread, .. } => Some(thread.read(cx).thread().clone()), - ActiveView::Agent2Thread { .. } => { + ActiveView::AcpThread { .. } => { // todo! None } @@ -1988,7 +1988,7 @@ impl AgentPanel { message_editor, .. } => (thread.read(cx), message_editor.read(cx)), - ActiveView::Agent2Thread { .. } => { + ActiveView::AcpThread { .. } => { // todo! return None; } @@ -2132,7 +2132,7 @@ impl AgentPanel { return false; } } - ActiveView::Agent2Thread { .. } => { + ActiveView::AcpThread { .. } => { // todo! return false; } @@ -2720,7 +2720,7 @@ impl AgentPanel { ) -> Option { let active_thread = match &self.active_view { ActiveView::Thread { thread, .. } => thread, - ActiveView::Agent2Thread { .. } => { + ActiveView::AcpThread { .. } => { // todo! return None; } @@ -3093,7 +3093,7 @@ impl AgentPanel { .detach(); }); } - ActiveView::Agent2Thread { .. } => { + ActiveView::AcpThread { .. } => { unimplemented!() } ActiveView::TextThread { context_editor, .. } => { @@ -3178,7 +3178,7 @@ impl Render for AgentPanel { }); this.continue_conversation(window, cx); } - ActiveView::Agent2Thread { .. } => { + ActiveView::AcpThread { .. } => { todo!() } ActiveView::TextThread { .. } @@ -3230,7 +3230,7 @@ impl Render for AgentPanel { ) }) .child(self.render_drag_target(cx)), - ActiveView::Agent2Thread { thread_element, .. } => parent + ActiveView::AcpThread { thread_element, .. } => parent .relative() .child(thread_element.clone()) // todo!