From 7fb16977ce368d88c98debedea0a5f6a8a92d00d Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Sat, 1 Mar 2025 00:34:28 +0100 Subject: [PATCH] chore: Extract PromptStore out of prompt_library (#25837) One step closer to removing long pole with assistant/assistant2 builds Release Notes: - N/A --- Cargo.lock | 45 +++++++++++++------ Cargo.toml | 2 + crates/assistant/Cargo.toml | 1 + crates/assistant/src/assistant.rs | 2 +- crates/assistant/src/assistant_panel.rs | 3 +- crates/assistant/src/inline_assistant.rs | 2 +- .../src/terminal_inline_assistant.rs | 2 +- crates/assistant2/Cargo.toml | 1 + crates/assistant2/src/assistant.rs | 2 +- crates/assistant2/src/assistant_panel.rs | 3 +- crates/assistant2/src/buffer_codegen.rs | 2 +- crates/assistant2/src/inline_assistant.rs | 2 +- .../src/terminal_inline_assistant.rs | 2 +- crates/assistant_context_editor/Cargo.toml | 2 +- .../assistant_context_editor/src/context.rs | 2 +- .../src/context/context_tests.rs | 4 +- .../src/context_store.rs | 2 +- crates/assistant_slash_commands/Cargo.toml | 2 +- .../src/default_command.rs | 2 +- .../src/project_command.rs | 2 +- .../src/prompt_command.rs | 2 +- crates/collab/Cargo.toml | 2 +- crates/collab/src/tests/integration_tests.rs | 2 +- crates/prompt_library/Cargo.toml | 12 +---- crates/prompt_library/src/prompt_library.rs | 6 +-- crates/prompt_store/Cargo.toml | 33 ++++++++++++++ crates/prompt_store/LICENSE-GPL | 1 + .../src/prompt_store.rs | 3 ++ .../src/prompts.rs | 0 crates/zed/Cargo.toml | 2 +- crates/zed/src/main.rs | 2 +- crates/zed/src/zed.rs | 2 +- 32 files changed, 99 insertions(+), 53 deletions(-) create mode 100644 crates/prompt_store/Cargo.toml create mode 120000 crates/prompt_store/LICENSE-GPL rename crates/{prompt_library => prompt_store}/src/prompt_store.rs (99%) rename crates/{prompt_library => prompt_store}/src/prompts.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 9a11f1606b..d1e3de1689 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -405,6 +405,7 @@ dependencies = [ "pretty_assertions", "project", "prompt_library", + "prompt_store", "proto", "rand 0.8.5", "rope", @@ -472,6 +473,7 @@ dependencies = [ "picker", "project", "prompt_library", + "prompt_store", "proto", "rand 0.8.5", "rope", @@ -526,7 +528,7 @@ dependencies = [ "picker", "pretty_assertions", "project", - "prompt_library", + "prompt_store", "rand 0.8.5", "regex", "rope", @@ -617,7 +619,7 @@ dependencies = [ "log", "pretty_assertions", "project", - "prompt_library", + "prompt_store", "rope", "schemars", "semantic_index", @@ -2842,7 +2844,7 @@ dependencies = [ "pretty_assertions", "project", "prometheus", - "prompt_library", + "prompt_store", "prost 0.9.0", "rand 0.8.5", "recent_projects", @@ -10313,12 +10315,36 @@ dependencies = [ [[package]] name = "prompt_library" version = "0.1.0" +dependencies = [ + "anyhow", + "collections", + "editor", + "gpui", + "language", + "language_model", + "log", + "menu", + "picker", + "prompt_store", + "release_channel", + "rope", + "serde", + "settings", + "theme", + "ui", + "util", + "workspace", + "zed_actions", +] + +[[package]] +name = "prompt_store" +version = "0.1.0" dependencies = [ "anyhow", "assets", "chrono", "collections", - "editor", "fs", "futures 0.3.31", "fuzzy", @@ -10326,23 +10352,14 @@ dependencies = [ "handlebars 4.5.0", "heed", "language", - "language_model", "log", - "menu", "parking_lot", "paths", - "picker", - "release_channel", "rope", "serde", - "settings", "text", - "theme", - "ui", "util", "uuid", - "workspace", - "zed_actions", ] [[package]] @@ -16828,7 +16845,7 @@ dependencies = [ "project", "project_panel", "project_symbols", - "prompt_library", + "prompt_store", "proto", "recent_projects", "release_channel", diff --git a/Cargo.toml b/Cargo.toml index 5a69ac7ff7..48c88d2be8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -103,6 +103,7 @@ members = [ "crates/project_panel", "crates/project_symbols", "crates/prompt_library", + "crates/prompt_store", "crates/proto", "crates/recent_projects", "crates/refineable", @@ -308,6 +309,7 @@ project = { path = "crates/project" } project_panel = { path = "crates/project_panel" } project_symbols = { path = "crates/project_symbols" } prompt_library = { path = "crates/prompt_library" } +prompt_store = { path = "crates/prompt_store" } proto = { path = "crates/proto" } recent_projects = { path = "crates/recent_projects" } refineable = { path = "crates/refineable" } diff --git a/crates/assistant/Cargo.toml b/crates/assistant/Cargo.toml index 7df6ff10ac..8fbfb43136 100644 --- a/crates/assistant/Cargo.toml +++ b/crates/assistant/Cargo.toml @@ -51,6 +51,7 @@ parking_lot.workspace = true paths.workspace = true project.workspace = true prompt_library.workspace = true +prompt_store.workspace = true proto.workspace = true rope.workspace = true schemars.workspace = true diff --git a/crates/assistant/src/assistant.rs b/crates/assistant/src/assistant.rs index 3c2c1db997..e50a4cea6f 100644 --- a/crates/assistant/src/assistant.rs +++ b/crates/assistant/src/assistant.rs @@ -19,7 +19,7 @@ use gpui::{actions, App, Global, UpdateGlobal}; use language_model::{ LanguageModelId, LanguageModelProviderId, LanguageModelRegistry, LanguageModelResponseMessage, }; -use prompt_library::PromptBuilder; +use prompt_store::PromptBuilder; use semantic_index::{CloudEmbeddingProvider, SemanticDb}; use serde::Deserialize; use settings::{Settings, SettingsStore}; diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rs index d40640246d..eab5add89d 100644 --- a/crates/assistant/src/assistant_panel.rs +++ b/crates/assistant/src/assistant_panel.rs @@ -24,7 +24,8 @@ use language_model::{ AuthenticateError, LanguageModelProviderId, LanguageModelRegistry, ZED_CLOUD_PROVIDER_ID, }; use project::Project; -use prompt_library::{open_prompt_library, PromptBuilder, PromptLibrary}; +use prompt_library::{open_prompt_library, PromptLibrary}; +use prompt_store::PromptBuilder; use search::{buffer_search::DivRegistrar, BufferSearchBar}; use settings::{update_settings_file, Settings}; use smol::stream::StreamExt; diff --git a/crates/assistant/src/inline_assistant.rs b/crates/assistant/src/inline_assistant.rs index e37ef141a4..f3968b6e78 100644 --- a/crates/assistant/src/inline_assistant.rs +++ b/crates/assistant/src/inline_assistant.rs @@ -39,7 +39,7 @@ use language_model_selector::{InlineLanguageModelSelector, LanguageModelSelector use multi_buffer::MultiBufferRow; use parking_lot::Mutex; use project::{CodeAction, ProjectTransaction}; -use prompt_library::PromptBuilder; +use prompt_store::PromptBuilder; use rope::Rope; use settings::{update_settings_file, Settings, SettingsStore}; use smol::future::FutureExt; diff --git a/crates/assistant/src/terminal_inline_assistant.rs b/crates/assistant/src/terminal_inline_assistant.rs index 5a12efed26..5052745a29 100644 --- a/crates/assistant/src/terminal_inline_assistant.rs +++ b/crates/assistant/src/terminal_inline_assistant.rs @@ -20,7 +20,7 @@ use language_model::{ LanguageModelRequestMessage, Role, }; use language_model_selector::{InlineLanguageModelSelector, LanguageModelSelector}; -use prompt_library::PromptBuilder; +use prompt_store::PromptBuilder; use settings::{update_settings_file, Settings}; use std::{ cmp, diff --git a/crates/assistant2/Cargo.toml b/crates/assistant2/Cargo.toml index cfa5fff513..b59b2f2e7b 100644 --- a/crates/assistant2/Cargo.toml +++ b/crates/assistant2/Cargo.toml @@ -56,6 +56,7 @@ paths.workspace = true picker.workspace = true project.workspace = true prompt_library.workspace = true +prompt_store.workspace = true proto.workspace = true rope.workspace = true serde.workspace = true diff --git a/crates/assistant2/src/assistant.rs b/crates/assistant2/src/assistant.rs index 2e3b3a3be1..ee84582e3b 100644 --- a/crates/assistant2/src/assistant.rs +++ b/crates/assistant2/src/assistant.rs @@ -27,7 +27,7 @@ use command_palette_hooks::CommandPaletteFilter; use feature_flags::{Assistant2FeatureFlag, FeatureFlagAppExt}; use fs::Fs; use gpui::{actions, App}; -use prompt_library::PromptBuilder; +use prompt_store::PromptBuilder; use settings::Settings as _; pub use crate::assistant_panel::{AssistantPanel, ConcreteAssistantPanelDelegate}; diff --git a/crates/assistant2/src/assistant_panel.rs b/crates/assistant2/src/assistant_panel.rs index 0f610260a0..a64fbd3297 100644 --- a/crates/assistant2/src/assistant_panel.rs +++ b/crates/assistant2/src/assistant_panel.rs @@ -20,7 +20,8 @@ use gpui::{ use language::LanguageRegistry; use language_model::{LanguageModelProviderTosView, LanguageModelRegistry}; use project::Project; -use prompt_library::{open_prompt_library, PromptBuilder, PromptLibrary}; +use prompt_library::{open_prompt_library, PromptLibrary}; +use prompt_store::PromptBuilder; use settings::{update_settings_file, Settings}; use time::UtcOffset; use ui::{prelude::*, ContextMenu, KeyBinding, PopoverMenu, PopoverMenuHandle, Tab, Tooltip}; diff --git a/crates/assistant2/src/buffer_codegen.rs b/crates/assistant2/src/buffer_codegen.rs index a07b288f71..c9ddc2d4e5 100644 --- a/crates/assistant2/src/buffer_codegen.rs +++ b/crates/assistant2/src/buffer_codegen.rs @@ -14,7 +14,7 @@ use language_model::{ }; use multi_buffer::MultiBufferRow; use parking_lot::Mutex; -use prompt_library::PromptBuilder; +use prompt_store::PromptBuilder; use rope::Rope; use smol::future::FutureExt; use std::{ diff --git a/crates/assistant2/src/inline_assistant.rs b/crates/assistant2/src/inline_assistant.rs index a7f7b1601d..803039bf59 100644 --- a/crates/assistant2/src/inline_assistant.rs +++ b/crates/assistant2/src/inline_assistant.rs @@ -28,7 +28,7 @@ use language_model::{report_assistant_event, LanguageModelRegistry}; use multi_buffer::MultiBufferRow; use parking_lot::Mutex; use project::{CodeAction, ProjectTransaction}; -use prompt_library::PromptBuilder; +use prompt_store::PromptBuilder; use settings::{Settings, SettingsStore}; use telemetry_events::{AssistantEvent, AssistantKind, AssistantPhase}; use terminal_view::{terminal_panel::TerminalPanel, TerminalView}; diff --git a/crates/assistant2/src/terminal_inline_assistant.rs b/crates/assistant2/src/terminal_inline_assistant.rs index 788ccc9eca..42d183e728 100644 --- a/crates/assistant2/src/terminal_inline_assistant.rs +++ b/crates/assistant2/src/terminal_inline_assistant.rs @@ -16,7 +16,7 @@ use language_model::{ report_assistant_event, LanguageModelRegistry, LanguageModelRequest, LanguageModelRequestMessage, Role, }; -use prompt_library::PromptBuilder; +use prompt_store::PromptBuilder; use std::sync::Arc; use telemetry_events::{AssistantEvent, AssistantKind, AssistantPhase}; use terminal_view::TerminalView; diff --git a/crates/assistant_context_editor/Cargo.toml b/crates/assistant_context_editor/Cargo.toml index 0feb0543bf..3a224362d3 100644 --- a/crates/assistant_context_editor/Cargo.toml +++ b/crates/assistant_context_editor/Cargo.toml @@ -37,7 +37,7 @@ parking_lot.workspace = true paths.workspace = true picker.workspace = true project.workspace = true -prompt_library.workspace = true +prompt_store.workspace = true regex.workspace = true rope.workspace = true rpc.workspace = true diff --git a/crates/assistant_context_editor/src/context.rs b/crates/assistant_context_editor/src/context.rs index d6447572bc..cac5910d0e 100644 --- a/crates/assistant_context_editor/src/context.rs +++ b/crates/assistant_context_editor/src/context.rs @@ -27,7 +27,7 @@ use language_model::{ use open_ai::Model as OpenAiModel; use paths::contexts_dir; use project::Project; -use prompt_library::PromptBuilder; +use prompt_store::PromptBuilder; use serde::{Deserialize, Serialize}; use smallvec::SmallVec; use std::{ diff --git a/crates/assistant_context_editor/src/context/context_tests.rs b/crates/assistant_context_editor/src/context/context_tests.rs index 6eadccd3e3..ffa44defb0 100644 --- a/crates/assistant_context_editor/src/context/context_tests.rs +++ b/crates/assistant_context_editor/src/context/context_tests.rs @@ -20,7 +20,7 @@ use language_model::{LanguageModelCacheConfiguration, LanguageModelRegistry, Rol use parking_lot::Mutex; use pretty_assertions::assert_eq; use project::Project; -use prompt_library::PromptBuilder; +use prompt_store::PromptBuilder; use rand::prelude::*; use serde_json::json; use settings::SettingsStore; @@ -671,7 +671,7 @@ async fn test_slash_commands(cx: &mut TestAppContext) { #[gpui::test] async fn test_workflow_step_parsing(cx: &mut TestAppContext) { - cx.update(prompt_library::init); + cx.update(prompt_store::init); let mut settings_store = cx.update(SettingsStore::test); cx.update(|cx| { settings_store diff --git a/crates/assistant_context_editor/src/context_store.rs b/crates/assistant_context_editor/src/context_store.rs index 6fe289d305..cda9f68ea7 100644 --- a/crates/assistant_context_editor/src/context_store.rs +++ b/crates/assistant_context_editor/src/context_store.rs @@ -16,7 +16,7 @@ use gpui::{App, AppContext as _, AsyncApp, Context, Entity, EventEmitter, Task, use language::LanguageRegistry; use paths::contexts_dir; use project::Project; -use prompt_library::PromptBuilder; +use prompt_store::PromptBuilder; use regex::Regex; use rpc::AnyProtoClient; use std::sync::LazyLock; diff --git a/crates/assistant_slash_commands/Cargo.toml b/crates/assistant_slash_commands/Cargo.toml index 25d762223d..376ae53b50 100644 --- a/crates/assistant_slash_commands/Cargo.toml +++ b/crates/assistant_slash_commands/Cargo.toml @@ -32,7 +32,7 @@ language.workspace = true language_model.workspace = true log.workspace = true project.workspace = true -prompt_library.workspace = true +prompt_store.workspace = true rope.workspace = true schemars.workspace = true semantic_index.workspace = true diff --git a/crates/assistant_slash_commands/src/default_command.rs b/crates/assistant_slash_commands/src/default_command.rs index b076a3a0a5..6bc7e98a1b 100644 --- a/crates/assistant_slash_commands/src/default_command.rs +++ b/crates/assistant_slash_commands/src/default_command.rs @@ -5,7 +5,7 @@ use assistant_slash_command::{ }; use gpui::{Task, WeakEntity}; use language::{BufferSnapshot, LspAdapterDelegate}; -use prompt_library::PromptStore; +use prompt_store::PromptStore; use std::{ fmt::Write, sync::{atomic::AtomicBool, Arc}, diff --git a/crates/assistant_slash_commands/src/project_command.rs b/crates/assistant_slash_commands/src/project_command.rs index 34e61fe180..62be5049fc 100644 --- a/crates/assistant_slash_commands/src/project_command.rs +++ b/crates/assistant_slash_commands/src/project_command.rs @@ -13,7 +13,7 @@ use feature_flags::FeatureFlag; use gpui::{App, Task, WeakEntity}; use language::{Anchor, CodeLabel, LspAdapterDelegate}; use language_model::{LanguageModelRegistry, LanguageModelTool}; -use prompt_library::PromptBuilder; +use prompt_store::PromptBuilder; use schemars::JsonSchema; use semantic_index::SemanticDb; use serde::Deserialize; diff --git a/crates/assistant_slash_commands/src/prompt_command.rs b/crates/assistant_slash_commands/src/prompt_command.rs index 5d5f44958f..73f75ceb05 100644 --- a/crates/assistant_slash_commands/src/prompt_command.rs +++ b/crates/assistant_slash_commands/src/prompt_command.rs @@ -5,7 +5,7 @@ use assistant_slash_command::{ }; use gpui::{Task, WeakEntity}; use language::{BufferSnapshot, LspAdapterDelegate}; -use prompt_library::PromptStore; +use prompt_store::PromptStore; use std::sync::{atomic::AtomicBool, Arc}; use ui::prelude::*; use workspace::Workspace; diff --git a/crates/collab/Cargo.toml b/crates/collab/Cargo.toml index 44849d58b0..520b7b19ff 100644 --- a/crates/collab/Cargo.toml +++ b/crates/collab/Cargo.toml @@ -111,7 +111,7 @@ node_runtime.workspace = true notifications = { workspace = true, features = ["test-support"] } pretty_assertions.workspace = true project = { workspace = true, features = ["test-support"] } -prompt_library.workspace = true +prompt_store.workspace = true recent_projects = { workspace = true } release_channel.workspace = true remote = { workspace = true, features = ["test-support"] } diff --git a/crates/collab/src/tests/integration_tests.rs b/crates/collab/src/tests/integration_tests.rs index 017367fb1f..18777fd3db 100644 --- a/crates/collab/src/tests/integration_tests.rs +++ b/crates/collab/src/tests/integration_tests.rs @@ -14,7 +14,7 @@ use client::{User, RECEIVE_TIMEOUT}; use collections::{HashMap, HashSet}; use fs::{FakeFs, Fs as _, RemoveOptions}; use futures::{channel::mpsc, StreamExt as _}; -use prompt_library::PromptBuilder; +use prompt_store::PromptBuilder; use git::status::{FileStatus, StatusCode, TrackedStatus, UnmergedStatus, UnmergedStatusCode}; use gpui::{ diff --git a/crates/prompt_library/Cargo.toml b/crates/prompt_library/Cargo.toml index c083e37fb4..1601eff2f0 100644 --- a/crates/prompt_library/Cargo.toml +++ b/crates/prompt_library/Cargo.toml @@ -13,31 +13,21 @@ path = "src/prompt_library.rs" [dependencies] anyhow.workspace = true -assets.workspace = true -chrono.workspace = true collections.workspace = true editor.workspace = true -fs.workspace = true -futures.workspace = true -fuzzy.workspace = true gpui.workspace = true -handlebars.workspace = true -heed.workspace = true language.workspace = true language_model.workspace = true log.workspace = true menu.workspace = true -parking_lot.workspace = true -paths.workspace = true picker.workspace = true +prompt_store.workspace = true release_channel.workspace = true rope.workspace = true serde.workspace = true settings.workspace = true -text.workspace = true theme.workspace = true ui.workspace = true util.workspace = true -uuid.workspace = true workspace.workspace = true zed_actions.workspace = true diff --git a/crates/prompt_library/src/prompt_library.rs b/crates/prompt_library/src/prompt_library.rs index b129a8ccbe..e65d6b0f8f 100644 --- a/crates/prompt_library/src/prompt_library.rs +++ b/crates/prompt_library/src/prompt_library.rs @@ -1,6 +1,3 @@ -mod prompt_store; -mod prompts; - use anyhow::Result; use collections::{HashMap, HashSet}; use editor::CompletionProvider; @@ -29,8 +26,7 @@ use util::{ResultExt, TryFutureExt}; use workspace::Workspace; use zed_actions::assistant::InlineAssist; -pub use crate::prompt_store::*; -pub use crate::prompts::*; +use prompt_store::*; pub fn init(cx: &mut App) { prompt_store::init(cx); diff --git a/crates/prompt_store/Cargo.toml b/crates/prompt_store/Cargo.toml new file mode 100644 index 0000000000..13bacbfad3 --- /dev/null +++ b/crates/prompt_store/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "prompt_store" +version = "0.1.0" +edition.workspace = true +publish.workspace = true +license = "GPL-3.0-or-later" + +[lints] +workspace = true + +[lib] +path = "src/prompt_store.rs" + +[dependencies] +anyhow.workspace = true +assets.workspace = true +chrono.workspace = true +collections.workspace = true +fs.workspace = true +futures.workspace = true +fuzzy.workspace = true +gpui.workspace = true +handlebars.workspace = true +heed.workspace = true +language.workspace = true +log.workspace = true +parking_lot.workspace = true +paths.workspace = true +rope.workspace = true +serde.workspace = true +text.workspace = true +util.workspace = true +uuid.workspace = true diff --git a/crates/prompt_store/LICENSE-GPL b/crates/prompt_store/LICENSE-GPL new file mode 120000 index 0000000000..89e542f750 --- /dev/null +++ b/crates/prompt_store/LICENSE-GPL @@ -0,0 +1 @@ +../../LICENSE-GPL \ No newline at end of file diff --git a/crates/prompt_library/src/prompt_store.rs b/crates/prompt_store/src/prompt_store.rs similarity index 99% rename from crates/prompt_library/src/prompt_store.rs rename to crates/prompt_store/src/prompt_store.rs index bbc20537a7..82c1f9d916 100644 --- a/crates/prompt_library/src/prompt_store.rs +++ b/crates/prompt_store/src/prompt_store.rs @@ -1,3 +1,5 @@ +mod prompts; + use anyhow::{anyhow, Result}; use chrono::{DateTime, Utc}; use collections::HashMap; @@ -10,6 +12,7 @@ use heed::{ Database, RoTxn, }; use parking_lot::RwLock; +pub use prompts::*; use rope::Rope; use serde::{Deserialize, Serialize}; use std::{ diff --git a/crates/prompt_library/src/prompts.rs b/crates/prompt_store/src/prompts.rs similarity index 100% rename from crates/prompt_library/src/prompts.rs rename to crates/prompt_store/src/prompts.rs diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 8330ee6e1f..e5190e7283 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -90,7 +90,7 @@ profiling.workspace = true project.workspace = true project_panel.workspace = true project_symbols.workspace = true -prompt_library.workspace = true +prompt_store.workspace = true proto.workspace = true recent_projects.workspace = true release_channel.workspace = true diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index ce898b33a0..59757c3ae8 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -23,7 +23,7 @@ use gpui::{App, AppContext as _, Application, AsyncApp, UpdateGlobal as _}; use gpui_tokio::Tokio; use http_client::{read_proxy_from_env, Uri}; use language::LanguageRegistry; -use prompt_library::PromptBuilder; +use prompt_store::PromptBuilder; use reqwest_client::ReqwestClient; use assets::Assets; diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 31d11104ea..81faf89f57 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -37,7 +37,7 @@ use outline_panel::OutlinePanel; use paths::{local_settings_file_relative_path, local_tasks_file_relative_path}; use project::{DirectoryLister, ProjectItem}; use project_panel::ProjectPanel; -use prompt_library::PromptBuilder; +use prompt_store::PromptBuilder; use quick_action_bar::QuickActionBar; use recent_projects::open_ssh_project; use release_channel::{AppCommitSha, ReleaseChannel};