Rename "Prompt Library" to "Rules Library" (#29349)

There's probably more to do to fully make the transition, and we'll
still debate a bit internally whether this is the name, but just opening
this PR up now for visibility.

Release Notes:

- N/A
This commit is contained in:
Danilo Leal 2025-04-24 16:42:06 -03:00 committed by GitHub
parent 1a4dab97db
commit 87f85f1863
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 283 additions and 304 deletions

56
Cargo.lock generated
View file

@ -96,12 +96,12 @@ dependencies = [
"paths", "paths",
"picker", "picker",
"project", "project",
"prompt_library",
"prompt_store", "prompt_store",
"proto", "proto",
"rand 0.8.5", "rand 0.8.5",
"release_channel", "release_channel",
"rope", "rope",
"rules_library",
"schemars", "schemars",
"serde", "serde",
"serde_json", "serde_json",
@ -498,11 +498,11 @@ dependencies = [
"parking_lot", "parking_lot",
"pretty_assertions", "pretty_assertions",
"project", "project",
"prompt_library",
"prompt_store", "prompt_store",
"proto", "proto",
"rand 0.8.5", "rand 0.8.5",
"rope", "rope",
"rules_library",
"schemars", "schemars",
"search", "search",
"serde", "serde",
@ -11083,32 +11083,6 @@ dependencies = [
"thiserror 2.0.12", "thiserror 2.0.12",
] ]
[[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",
"workspace-hack",
"zed_actions",
]
[[package]] [[package]]
name = "prompt_store" name = "prompt_store"
version = "0.1.0" version = "0.1.0"
@ -12271,6 +12245,32 @@ dependencies = [
"zeroize", "zeroize",
] ]
[[package]]
name = "rules_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",
"workspace-hack",
"zed_actions",
]
[[package]] [[package]]
name = "runtimelib" name = "runtimelib"
version = "0.25.0" version = "0.25.0"

View file

@ -109,7 +109,7 @@ members = [
"crates/project", "crates/project",
"crates/project_panel", "crates/project_panel",
"crates/project_symbols", "crates/project_symbols",
"crates/prompt_library", "crates/rules_library",
"crates/prompt_store", "crates/prompt_store",
"crates/proto", "crates/proto",
"crates/recent_projects", "crates/recent_projects",
@ -319,7 +319,7 @@ prettier = { path = "crates/prettier" }
project = { path = "crates/project" } project = { path = "crates/project" }
project_panel = { path = "crates/project_panel" } project_panel = { path = "crates/project_panel" }
project_symbols = { path = "crates/project_symbols" } project_symbols = { path = "crates/project_symbols" }
prompt_library = { path = "crates/prompt_library" } rules_library = { path = "crates/rules_library" }
prompt_store = { path = "crates/prompt_store" } prompt_store = { path = "crates/prompt_store" }
proto = { path = "crates/proto" } proto = { path = "crates/proto" }
recent_projects = { path = "crates/recent_projects" } recent_projects = { path = "crates/recent_projects" }

View file

@ -212,7 +212,7 @@
"ctrl-shift-g": "search::SelectPreviousMatch", "ctrl-shift-g": "search::SelectPreviousMatch",
"ctrl-alt-/": "assistant::ToggleModelSelector", "ctrl-alt-/": "assistant::ToggleModelSelector",
"ctrl-k h": "assistant::DeployHistory", "ctrl-k h": "assistant::DeployHistory",
"ctrl-k l": "assistant::OpenPromptLibrary", "ctrl-k l": "assistant::OpenRulesLibrary",
"new": "assistant::NewChat", "new": "assistant::NewChat",
"ctrl-t": "assistant::NewChat", "ctrl-t": "assistant::NewChat",
"ctrl-n": "assistant::NewChat" "ctrl-n": "assistant::NewChat"
@ -241,7 +241,7 @@
"ctrl-alt-n": "agent::NewTextThread", "ctrl-alt-n": "agent::NewTextThread",
"ctrl-shift-h": "agent::OpenHistory", "ctrl-shift-h": "agent::OpenHistory",
"ctrl-alt-c": "agent::OpenConfiguration", "ctrl-alt-c": "agent::OpenConfiguration",
"ctrl-alt-p": "assistant::OpenPromptLibrary", "ctrl-alt-p": "assistant::OpenRulesLibrary",
"ctrl-i": "agent::ToggleProfileSelector", "ctrl-i": "agent::ToggleProfileSelector",
"ctrl-alt-/": "assistant::ToggleModelSelector", "ctrl-alt-/": "assistant::ToggleModelSelector",
"ctrl-shift-a": "agent::ToggleContextPicker", "ctrl-shift-a": "agent::ToggleContextPicker",
@ -308,9 +308,9 @@
{ {
"context": "PromptLibrary", "context": "PromptLibrary",
"bindings": { "bindings": {
"new": "prompt_library::NewPrompt", "new": "rules_library::NewRule",
"ctrl-n": "prompt_library::NewPrompt", "ctrl-n": "rules_library::NewRule",
"ctrl-shift-s": "prompt_library::ToggleDefaultPrompt" "ctrl-shift-s": "rules_library::ToggleDefaultRule"
} }
}, },
{ {

View file

@ -5,8 +5,8 @@
"context": "PromptLibrary", "context": "PromptLibrary",
"use_key_equivalents": true, "use_key_equivalents": true,
"bindings": { "bindings": {
"cmd-n": "prompt_library::NewPrompt", "cmd-n": "rules_library::NewRule",
"cmd-shift-s": "prompt_library::ToggleDefaultPrompt", "cmd-shift-s": "rules_library::ToggleDefaultRule",
"cmd-w": "workspace::CloseWindow" "cmd-w": "workspace::CloseWindow"
} }
}, },
@ -257,7 +257,7 @@
"cmd-shift-g": "search::SelectPreviousMatch", "cmd-shift-g": "search::SelectPreviousMatch",
"cmd-alt-/": "assistant::ToggleModelSelector", "cmd-alt-/": "assistant::ToggleModelSelector",
"cmd-k h": "assistant::DeployHistory", "cmd-k h": "assistant::DeployHistory",
"cmd-k l": "assistant::OpenPromptLibrary", "cmd-k l": "assistant::OpenRulesLibrary",
"cmd-t": "assistant::NewChat", "cmd-t": "assistant::NewChat",
"cmd-n": "assistant::NewChat" "cmd-n": "assistant::NewChat"
} }
@ -286,7 +286,7 @@
"cmd-alt-n": "agent::NewTextThread", "cmd-alt-n": "agent::NewTextThread",
"cmd-shift-h": "agent::OpenHistory", "cmd-shift-h": "agent::OpenHistory",
"cmd-alt-c": "agent::OpenConfiguration", "cmd-alt-c": "agent::OpenConfiguration",
"cmd-alt-p": "assistant::OpenPromptLibrary", "cmd-alt-p": "assistant::OpenRulesLibrary",
"cmd-i": "agent::ToggleProfileSelector", "cmd-i": "agent::ToggleProfileSelector",
"cmd-alt-/": "assistant::ToggleModelSelector", "cmd-alt-/": "assistant::ToggleModelSelector",
"cmd-shift-a": "agent::ToggleContextPicker", "cmd-shift-a": "agent::ToggleContextPicker",

View file

@ -62,7 +62,7 @@ parking_lot.workspace = true
paths.workspace = true paths.workspace = true
picker.workspace = true picker.workspace = true
project.workspace = true project.workspace = true
prompt_library.workspace = true rules_library.workspace = true
prompt_store.workspace = true prompt_store.workspace = true
proto.workspace = true proto.workspace = true
release_channel.workspace = true release_channel.workspace = true

View file

@ -44,7 +44,7 @@ use ui::{
}; };
use util::ResultExt as _; use util::ResultExt as _;
use workspace::{OpenOptions, Workspace}; use workspace::{OpenOptions, Workspace};
use zed_actions::assistant::OpenPromptLibrary; use zed_actions::assistant::OpenRulesLibrary;
use crate::context_store::ContextStore; use crate::context_store::ContextStore;
@ -695,7 +695,7 @@ fn open_markdown_link(
}), }),
Some(MentionLink::Fetch(url)) => cx.open_url(&url), Some(MentionLink::Fetch(url)) => cx.open_url(&url),
Some(MentionLink::Rules(prompt_id)) => window.dispatch_action( Some(MentionLink::Rules(prompt_id)) => window.dispatch_action(
Box::new(OpenPromptLibrary { Box::new(OpenRulesLibrary {
prompt_to_select: Some(prompt_id.0), prompt_to_select: Some(prompt_id.0),
}), }),
cx, cx,
@ -2944,11 +2944,11 @@ impl ActiveThread {
.shape(ui::IconButtonShape::Square) .shape(ui::IconButtonShape::Square)
.icon_size(IconSize::XSmall) .icon_size(IconSize::XSmall)
.icon_color(Color::Ignored) .icon_color(Color::Ignored)
// TODO: Figure out a way to pass focus handle here so we can display the `OpenPromptLibrary` keybinding // TODO: Figure out a way to pass focus handle here so we can display the `OpenRulesLibrary` keybinding
.tooltip(Tooltip::text("View User Rules")) .tooltip(Tooltip::text("View User Rules"))
.on_click(move |_event, window, cx| { .on_click(move |_event, window, cx| {
window.dispatch_action( window.dispatch_action(
Box::new(OpenPromptLibrary { Box::new(OpenRulesLibrary {
prompt_to_select: first_user_rules_id, prompt_to_select: first_user_rules_id,
}), }),
cx, cx,
@ -3234,7 +3234,7 @@ pub(crate) fn open_context(
}) })
} }
AssistantContext::Rules(rules_context) => window.dispatch_action( AssistantContext::Rules(rules_context) => window.dispatch_action(
Box::new(OpenPromptLibrary { Box::new(OpenRulesLibrary {
prompt_to_select: Some(rules_context.prompt_id.0), prompt_to_select: Some(rules_context.prompt_id.0),
}), }),
cx, cx,

View file

@ -24,9 +24,9 @@ use language::LanguageRegistry;
use language_model::{LanguageModelProviderTosView, LanguageModelRegistry}; use language_model::{LanguageModelProviderTosView, LanguageModelRegistry};
use language_model_selector::ToggleModelSelector; use language_model_selector::ToggleModelSelector;
use project::Project; use project::Project;
use prompt_library::{PromptLibrary, open_prompt_library};
use prompt_store::{PromptBuilder, PromptId, UserPromptId}; use prompt_store::{PromptBuilder, PromptId, UserPromptId};
use proto::Plan; use proto::Plan;
use rules_library::{RulesLibrary, open_rules_library};
use settings::{Settings, update_settings_file}; use settings::{Settings, update_settings_file};
use time::UtcOffset; use time::UtcOffset;
use ui::{ use ui::{
@ -36,7 +36,7 @@ use util::ResultExt as _;
use workspace::Workspace; use workspace::Workspace;
use workspace::dock::{DockPosition, Panel, PanelEvent}; use workspace::dock::{DockPosition, Panel, PanelEvent};
use zed_actions::agent::OpenConfiguration; use zed_actions::agent::OpenConfiguration;
use zed_actions::assistant::{OpenPromptLibrary, ToggleFocus}; use zed_actions::assistant::{OpenRulesLibrary, ToggleFocus};
use crate::active_thread::{ActiveThread, ActiveThreadEvent}; use crate::active_thread::{ActiveThread, ActiveThreadEvent};
use crate::assistant_configuration::{AssistantConfiguration, AssistantConfigurationEvent}; use crate::assistant_configuration::{AssistantConfiguration, AssistantConfigurationEvent};
@ -79,11 +79,11 @@ pub fn init(cx: &mut App) {
panel.update(cx, |panel, cx| panel.new_prompt_editor(window, cx)); panel.update(cx, |panel, cx| panel.new_prompt_editor(window, cx));
} }
}) })
.register_action(|workspace, action: &OpenPromptLibrary, window, cx| { .register_action(|workspace, action: &OpenRulesLibrary, window, cx| {
if let Some(panel) = workspace.panel::<AssistantPanel>(cx) { if let Some(panel) = workspace.panel::<AssistantPanel>(cx) {
workspace.focus_panel::<AssistantPanel>(window, cx); workspace.focus_panel::<AssistantPanel>(window, cx);
panel.update(cx, |panel, cx| { panel.update(cx, |panel, cx| {
panel.deploy_prompt_library(action, window, cx) panel.deploy_rules_library(action, window, cx)
}); });
} }
}) })
@ -484,13 +484,13 @@ impl AssistantPanel {
context_editor.focus_handle(cx).focus(window); context_editor.focus_handle(cx).focus(window);
} }
fn deploy_prompt_library( fn deploy_rules_library(
&mut self, &mut self,
action: &OpenPromptLibrary, action: &OpenRulesLibrary,
_window: &mut Window, _window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
open_prompt_library( open_rules_library(
self.language_registry.clone(), self.language_registry.clone(),
Box::new(PromptLibraryInlineAssist::new(self.workspace.clone())), Box::new(PromptLibraryInlineAssist::new(self.workspace.clone())),
Arc::new(|| { Arc::new(|| {
@ -1120,7 +1120,7 @@ impl AssistantPanel {
"New Text Thread", "New Text Thread",
NewTextThread.boxed_clone(), NewTextThread.boxed_clone(),
) )
.action("Prompt Library", Box::new(OpenPromptLibrary::default())) .action("Rules Library", Box::new(OpenRulesLibrary::default()))
.action("Settings", Box::new(OpenConfiguration)) .action("Settings", Box::new(OpenConfiguration))
.separator() .separator()
.header("MCPs") .header("MCPs")
@ -1833,7 +1833,7 @@ impl Render for AssistantPanel {
this.open_configuration(window, cx); this.open_configuration(window, cx);
})) }))
.on_action(cx.listener(Self::open_active_thread_as_markdown)) .on_action(cx.listener(Self::open_active_thread_as_markdown))
.on_action(cx.listener(Self::deploy_prompt_library)) .on_action(cx.listener(Self::deploy_rules_library))
.on_action(cx.listener(Self::open_agent_diff)) .on_action(cx.listener(Self::open_agent_diff))
.on_action(cx.listener(Self::go_back)) .on_action(cx.listener(Self::go_back))
.child(self.render_toolbar(window, cx)) .child(self.render_toolbar(window, cx))
@ -1860,13 +1860,13 @@ impl PromptLibraryInlineAssist {
} }
} }
impl prompt_library::InlineAssistDelegate for PromptLibraryInlineAssist { impl rules_library::InlineAssistDelegate for PromptLibraryInlineAssist {
fn assist( fn assist(
&self, &self,
prompt_editor: &Entity<Editor>, prompt_editor: &Entity<Editor>,
_initial_prompt: Option<String>, _initial_prompt: Option<String>,
window: &mut Window, window: &mut Window,
cx: &mut Context<PromptLibrary>, cx: &mut Context<RulesLibrary>,
) { ) {
InlineAssistant::update_global(cx, |assistant, cx| { InlineAssistant::update_global(cx, |assistant, cx| {
let Some(project) = self let Some(project) = self

View file

@ -49,7 +49,7 @@ menu.workspace = true
multi_buffer.workspace = true multi_buffer.workspace = true
parking_lot.workspace = true parking_lot.workspace = true
project.workspace = true project.workspace = true
prompt_library.workspace = true rules_library.workspace = true
prompt_store.workspace = true prompt_store.workspace = true
proto.workspace = true proto.workspace = true
rope.workspace = true rope.workspace = true

View file

@ -101,7 +101,7 @@ pub fn init(
SlashCommandSettings::register(cx); SlashCommandSettings::register(cx);
assistant_context_editor::init(client.clone(), cx); assistant_context_editor::init(client.clone(), cx);
prompt_library::init(cx); rules_library::init(cx);
init_language_model_settings(cx); init_language_model_settings(cx);
assistant_slash_command::init(cx); assistant_slash_command::init(cx);
assistant_tool::init(cx); assistant_tool::init(cx);

View file

@ -25,8 +25,8 @@ use language_model::{
AuthenticateError, ConfiguredModel, LanguageModelProviderId, LanguageModelRegistry, AuthenticateError, ConfiguredModel, LanguageModelProviderId, LanguageModelRegistry,
}; };
use project::Project; use project::Project;
use prompt_library::{PromptLibrary, open_prompt_library};
use prompt_store::{PromptBuilder, PromptId, UserPromptId}; use prompt_store::{PromptBuilder, PromptId, UserPromptId};
use rules_library::{RulesLibrary, open_rules_library};
use search::{BufferSearchBar, buffer_search::DivRegistrar}; use search::{BufferSearchBar, buffer_search::DivRegistrar};
use settings::{Settings, update_settings_file}; use settings::{Settings, update_settings_file};
@ -43,7 +43,7 @@ use workspace::{
dock::{DockPosition, Panel, PanelEvent}, dock::{DockPosition, Panel, PanelEvent},
pane, pane,
}; };
use zed_actions::assistant::{InlineAssist, OpenPromptLibrary, ShowConfiguration, ToggleFocus}; use zed_actions::assistant::{InlineAssist, OpenRulesLibrary, ShowConfiguration, ToggleFocus};
pub fn init(cx: &mut App) { pub fn init(cx: &mut App) {
workspace::FollowableViewRegistry::register::<ContextEditor>(cx); workspace::FollowableViewRegistry::register::<ContextEditor>(cx);
@ -57,11 +57,11 @@ pub fn init(cx: &mut App) {
.register_action(AssistantPanel::show_configuration) .register_action(AssistantPanel::show_configuration)
.register_action(AssistantPanel::create_new_context) .register_action(AssistantPanel::create_new_context)
.register_action(AssistantPanel::restart_context_servers) .register_action(AssistantPanel::restart_context_servers)
.register_action(|workspace, action: &OpenPromptLibrary, window, cx| { .register_action(|workspace, action: &OpenRulesLibrary, window, cx| {
if let Some(panel) = workspace.panel::<AssistantPanel>(cx) { if let Some(panel) = workspace.panel::<AssistantPanel>(cx) {
workspace.focus_panel::<AssistantPanel>(window, cx); workspace.focus_panel::<AssistantPanel>(window, cx);
panel.update(cx, |panel, cx| { panel.update(cx, |panel, cx| {
panel.deploy_prompt_library(action, window, cx) panel.deploy_rules_library(action, window, cx)
}); });
} }
}); });
@ -272,8 +272,8 @@ impl AssistantPanel {
.action("New Chat", Box::new(NewChat)) .action("New Chat", Box::new(NewChat))
.action("History", Box::new(DeployHistory)) .action("History", Box::new(DeployHistory))
.action( .action(
"Prompt Library", "Rules Library",
Box::new(OpenPromptLibrary::default()), Box::new(OpenRulesLibrary::default()),
) )
.action("Configure", Box::new(ShowConfiguration)) .action("Configure", Box::new(ShowConfiguration))
.action(zoom_label, Box::new(ToggleZoom)) .action(zoom_label, Box::new(ToggleZoom))
@ -1043,13 +1043,13 @@ impl AssistantPanel {
} }
} }
fn deploy_prompt_library( fn deploy_rules_library(
&mut self, &mut self,
action: &OpenPromptLibrary, action: &OpenRulesLibrary,
_window: &mut Window, _window: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
open_prompt_library( open_rules_library(
self.languages.clone(), self.languages.clone(),
Box::new(PromptLibraryInlineAssist), Box::new(PromptLibraryInlineAssist),
Arc::new(|| { Arc::new(|| {
@ -1235,7 +1235,7 @@ impl Render for AssistantPanel {
this.show_configuration_tab(window, cx) this.show_configuration_tab(window, cx)
})) }))
.on_action(cx.listener(AssistantPanel::deploy_history)) .on_action(cx.listener(AssistantPanel::deploy_history))
.on_action(cx.listener(AssistantPanel::deploy_prompt_library)) .on_action(cx.listener(AssistantPanel::deploy_rules_library))
.child(registrar.size_full().child(self.pane.clone())) .child(registrar.size_full().child(self.pane.clone()))
.into_any_element() .into_any_element()
} }
@ -1350,13 +1350,13 @@ impl Focusable for AssistantPanel {
struct PromptLibraryInlineAssist; struct PromptLibraryInlineAssist;
impl prompt_library::InlineAssistDelegate for PromptLibraryInlineAssist { impl rules_library::InlineAssistDelegate for PromptLibraryInlineAssist {
fn assist( fn assist(
&self, &self,
prompt_editor: &Entity<Editor>, prompt_editor: &Entity<Editor>,
initial_prompt: Option<String>, initial_prompt: Option<String>,
window: &mut Window, window: &mut Window,
cx: &mut Context<PromptLibrary>, cx: &mut Context<RulesLibrary>,
) { ) {
InlineAssistant::update_global(cx, |assistant, cx| { InlineAssistant::update_global(cx, |assistant, cx| {
assistant.assist(&prompt_editor, None, None, initial_prompt, window, cx) assistant.assist(&prompt_editor, None, None, initial_prompt, window, cx)

View file

@ -1,5 +1,5 @@
[package] [package]
name = "prompt_library" name = "rules_library"
version = "0.1.0" version = "0.1.0"
edition.workspace = true edition.workspace = true
publish.workspace = true publish.workspace = true
@ -9,7 +9,7 @@ license = "GPL-3.0-or-later"
workspace = true workspace = true
[lib] [lib]
path = "src/prompt_library.rs" path = "src/rules_library.rs"
[dependencies] [dependencies]
anyhow.workspace = true anyhow.workspace = true

View file

@ -199,14 +199,14 @@ pub mod assistant {
#[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)] #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct OpenPromptLibrary { pub struct OpenRulesLibrary {
#[serde(skip)] #[serde(skip)]
pub prompt_to_select: Option<Uuid>, pub prompt_to_select: Option<Uuid>,
} }
impl_action_with_deprecated_aliases!( impl_action_with_deprecated_aliases!(
assistant, assistant,
OpenPromptLibrary, OpenRulesLibrary,
["assistant::DeployPromptLibrary"] ["assistant::DeployPromptLibrary"]
); );