Supermaven (#10788)

Adds a supermaven provider for completions. There are various other
refactors amidst this branch, primarily to make copilot no longer a
dependency of project as well as show LSP Logs for global LSPs like
copilot properly.

This feature is not enabled by default. We're going to seek to refine it
in the coming weeks.

Release Notes:

- N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Max <max@zed.dev>
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
Kyle Kelley 2024-05-03 12:50:42 -07:00 committed by GitHub
parent 610968815c
commit 6563330239
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
47 changed files with 2242 additions and 827 deletions

View file

@ -0,0 +1,152 @@
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SetApiKey {
pub api_key: String,
}
// Outbound messages
#[derive(Debug, Serialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum OutboundMessage {
SetApiKey(SetApiKey),
StateUpdate(StateUpdateMessage),
#[allow(dead_code)]
UseFreeVersion,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StateUpdateMessage {
pub new_id: String,
pub updates: Vec<StateUpdate>,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum StateUpdate {
FileUpdate(FileUpdateMessage),
CursorUpdate(CursorPositionUpdateMessage),
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub struct FileUpdateMessage {
pub path: String,
pub content: String,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub struct CursorPositionUpdateMessage {
pub path: String,
pub offset: usize,
}
// Inbound messages coming in on stdout
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum ResponseItem {
// A completion
Text { text: String },
// Vestigial message type from old versions -- safe to ignore
Del { text: String },
// Be able to delete whitespace prior to the cursor, likely for the rest of the completion
Dedent { text: String },
// When the completion is over
End,
// Got the closing parentheses and shouldn't show any more after
Barrier,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SupermavenResponse {
pub state_id: String,
pub items: Vec<ResponseItem>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct SupermavenMetadataMessage {
pub dust_strings: Option<Vec<String>>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct SupermavenTaskUpdateMessage {
pub task: String,
pub status: TaskStatus,
pub percent_complete: Option<f32>,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum TaskStatus {
InProgress,
Complete,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct SupermavenActiveRepoMessage {
pub repo_simple_name: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum SupermavenPopupAction {
OpenUrl { label: String, url: String },
NoOp { label: String },
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub struct SupermavenPopupMessage {
pub message: String,
pub actions: Vec<SupermavenPopupAction>,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "camelCase")]
pub struct ActivationRequest {
pub activate_url: Option<String>,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SupermavenSetMessage {
pub key: String,
pub value: serde_json::Value,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum ServiceTier {
FreeNoLicense,
#[serde(other)]
Unknown,
}
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum SupermavenMessage {
Response(SupermavenResponse),
Metadata(SupermavenMetadataMessage),
Apology {
message: Option<String>,
},
ActivationRequest(ActivationRequest),
ActivationSuccess,
Passthrough {
passthrough: Box<SupermavenMessage>,
},
Popup(SupermavenPopupMessage),
TaskStatus(SupermavenTaskUpdateMessage),
ActiveRepo(SupermavenActiveRepoMessage),
ServiceTier {
service_tier: ServiceTier,
},
Set(SupermavenSetMessage),
#[serde(other)]
Unknown,
}