assistant: Add basic current project context (#11828)

This PR adds the beginnings of current project context to the Assistant.

Currently it supports reading a `Cargo.toml` file and using that to get
some basic information about the project, and its dependencies:

<img width="1264" alt="Screenshot 2024-05-14 at 6 17 03 PM"
src="https://github.com/zed-industries/zed/assets/1486634/cc8ed5ad-0ccb-45da-9c07-c96af84a14e3">

Release Notes:

- N/A

---------

Co-authored-by: Nate <nate@zed.dev>
This commit is contained in:
Marshall Bowers 2024-05-14 18:39:52 -04:00 committed by GitHub
parent 5b2c019f83
commit 26b5f34046
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 228 additions and 34 deletions

View file

@ -1,6 +1,8 @@
use gpui::{Subscription, Task, WeakModel};
use language::Buffer;
use crate::{LanguageModelRequestMessage, Role};
pub struct RecentBuffersContext {
pub enabled: bool,
pub buffers: Vec<RecentBuffer>,
@ -23,3 +25,13 @@ impl Default for RecentBuffersContext {
}
}
}
impl RecentBuffersContext {
/// Returns the [`RecentBuffersContext`] as a message to the language model.
pub fn to_message(&self) -> Option<LanguageModelRequestMessage> {
self.enabled.then(|| LanguageModelRequestMessage {
role: Role::System,
content: self.message.clone(),
})
}
}