diff --git a/Cargo.lock b/Cargo.lock index 1ae85aa6ce..5697f66370 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -477,18 +477,6 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" -[[package]] -name = "auditable-serde" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c7bf8143dfc3c0258df908843e169b5cc5fcf76c7718bd66135ef4a9cd558c5" -dependencies = [ - "semver", - "serde", - "serde_json", - "topological-sort", -] - [[package]] name = "autocfg" version = "1.5.0" @@ -504,7 +492,7 @@ dependencies = [ "anyhow", "arrayvec", "log", - "nom 7.1.3", + "nom", "num-rational", "v_frame", ] @@ -880,7 +868,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" dependencies = [ - "nom 7.1.3", + "nom", ] [[package]] @@ -928,33 +916,6 @@ dependencies = [ "windows-link 0.2.1", ] -[[package]] -name = "ciborium" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" -dependencies = [ - "ciborium-io", - "ciborium-ll", - "serde", -] - -[[package]] -name = "ciborium-io" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" - -[[package]] -name = "ciborium-ll" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" -dependencies = [ - "ciborium-io", - "half", -] - [[package]] name = "cipher" version = "0.4.4" @@ -983,48 +944,6 @@ dependencies = [ "libloading", ] -[[package]] -name = "cloud_api_client" -version = "0.1.0" -dependencies = [ - "anyhow", - "cloud_api_types", - "futures", - "gpui", - "gpui_tokio", - "http_client", - "parking_lot", - "serde_json", - "yawc", -] - -[[package]] -name = "cloud_api_types" -version = "0.1.0" -dependencies = [ - "anyhow", - "chrono", - "ciborium", - "cloud_llm_client", - "pretty_assertions", - "serde", - "serde_json", -] - -[[package]] -name = "cloud_llm_client" -version = "0.1.0" -dependencies = [ - "anyhow", - "chrono", - "indoc", - "pretty_assertions", - "serde", - "serde_json", - "strum 0.27.2", - "uuid", -] - [[package]] name = "cmake" version = "0.1.54" @@ -2822,12 +2741,6 @@ dependencies = [ "zerovec", ] -[[package]] -name = "id-arena" -version = "2.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" - [[package]] name = "idna" version = "1.1.0" @@ -3139,12 +3052,6 @@ dependencies = [ "leak", ] -[[package]] -name = "leb128fmt" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" - [[package]] name = "lebe" version = "0.5.3" @@ -3590,15 +3497,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "nom" -version = "8.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" -dependencies = [ - "memchr", -] - [[package]] name = "noop_proc_macro" version = "0.3.0" @@ -5207,17 +5105,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest", -] - [[package]] name = "sha1_smol" version = "1.0.1" @@ -5344,15 +5231,6 @@ dependencies = [ "windows-sys 0.60.2", ] -[[package]] -name = "spdx" -version = "0.10.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3e17e880bafaeb362a7b751ec46bdc5b61445a188f80e0606e68167cd540fa3" -dependencies = [ - "smallvec", -] - [[package]] name = "spin" version = "0.9.8" @@ -5919,21 +5797,9 @@ dependencies = [ "mio", "pin-project-lite", "socket2", - "tokio-macros", "windows-sys 0.61.2", ] -[[package]] -name = "tokio-macros" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.106", -] - [[package]] name = "tokio-rustls" version = "0.26.2" @@ -6061,12 +5927,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df8b2b54733674ad286d16267dcfc7a71ed5c776e4ac7aa3c3e2561f7c637bf2" -[[package]] -name = "topological-sort" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d" - [[package]] name = "tower" version = "0.5.2" @@ -6254,12 +6114,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" -[[package]] -name = "unicode-xid" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" - [[package]] name = "untrusted" version = "0.9.0" @@ -6507,7 +6361,7 @@ version = "1.0.1+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" dependencies = [ - "wit-bindgen 0.46.0", + "wit-bindgen", ] [[package]] @@ -6582,35 +6436,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "wasm-encoder" -version = "0.227.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80bb72f02e7fbf07183443b27b0f3d4144abf8c114189f2e088ed95b696a7822" -dependencies = [ - "leb128fmt", - "wasmparser", -] - -[[package]] -name = "wasm-metadata" -version = "0.227.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce1ef0faabbbba6674e97a56bee857ccddf942785a336c8b47b42373c922a91d" -dependencies = [ - "anyhow", - "auditable-serde", - "flate2", - "indexmap", - "serde", - "serde_derive", - "serde_json", - "spdx", - "url", - "wasm-encoder", - "wasmparser", -] - [[package]] name = "wasm-streams" version = "0.4.2" @@ -6624,18 +6449,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "wasmparser" -version = "0.227.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f51cad774fb3c9461ab9bccc9c62dfb7388397b5deda31bf40e8108ccd678b2" -dependencies = [ - "bitflags 2.9.4", - "hashbrown 0.15.5", - "indexmap", - "semver", -] - [[package]] name = "watch" version = "0.1.0" @@ -6788,15 +6601,6 @@ dependencies = [ "rustls-pki-types", ] -[[package]] -name = "webpki-roots" -version = "0.26.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2210b291f7ea53617fbafcc4939f10914214ec15aace5ba62293a668f322c5c9" -dependencies = [ - "rustls-pki-types", -] - [[package]] name = "weezl" version = "0.1.10" @@ -7422,112 +7226,12 @@ dependencies = [ "winapi", ] -[[package]] -name = "wit-bindgen" -version = "0.41.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10fb6648689b3929d56bbc7eb1acf70c9a42a29eb5358c67c10f54dbd5d695de" -dependencies = [ - "wit-bindgen-rt", - "wit-bindgen-rust-macro", -] - [[package]] name = "wit-bindgen" version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" -[[package]] -name = "wit-bindgen-core" -version = "0.41.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92fa781d4f2ff6d3f27f3cc9b74a73327b31ca0dc4a3ef25a0ce2983e0e5af9b" -dependencies = [ - "anyhow", - "heck 0.5.0", - "wit-parser", -] - -[[package]] -name = "wit-bindgen-rt" -version = "0.41.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4db52a11d4dfb0a59f194c064055794ee6564eb1ced88c25da2cf76e50c5621" -dependencies = [ - "bitflags 2.9.4", - "futures", - "once_cell", -] - -[[package]] -name = "wit-bindgen-rust" -version = "0.41.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d0809dc5ba19e2e98661bf32fc0addc5a3ca5bf3a6a7083aa6ba484085ff3ce" -dependencies = [ - "anyhow", - "heck 0.5.0", - "indexmap", - "prettyplease", - "syn 2.0.106", - "wasm-metadata", - "wit-bindgen-core", - "wit-component", -] - -[[package]] -name = "wit-bindgen-rust-macro" -version = "0.41.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad19eec017904e04c60719592a803ee5da76cb51c81e3f6fbf9457f59db49799" -dependencies = [ - "anyhow", - "prettyplease", - "proc-macro2", - "quote", - "syn 2.0.106", - "wit-bindgen-core", - "wit-bindgen-rust", -] - -[[package]] -name = "wit-component" -version = "0.227.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "635c3adc595422cbf2341a17fb73a319669cc8d33deed3a48368a841df86b676" -dependencies = [ - "anyhow", - "bitflags 2.9.4", - "indexmap", - "log", - "serde", - "serde_derive", - "serde_json", - "wasm-encoder", - "wasm-metadata", - "wasmparser", - "wit-parser", -] - -[[package]] -name = "wit-parser" -version = "0.227.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddf445ed5157046e4baf56f9138c124a0824d4d1657e7204d71886ad8ce2fc11" -dependencies = [ - "anyhow", - "id-arena", - "indexmap", - "log", - "semver", - "serde", - "serde_derive", - "serde_json", - "unicode-xid", - "wasmparser", -] - [[package]] name = "writeable" version = "0.6.1" @@ -7658,35 +7362,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" -[[package]] -name = "yawc" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19a5d82922135b4ae73a079a4ffb5501e9aadb4d785b8c660eaa0a8b899028c5" -dependencies = [ - "base64", - "bytes", - "flate2", - "futures", - "http-body-util", - "hyper", - "hyper-util", - "js-sys", - "nom 8.0.0", - "pin-project", - "rand 0.8.5", - "sha1", - "thiserror 1.0.69", - "tokio", - "tokio-rustls", - "tokio-util", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "webpki-roots", -] - [[package]] name = "yazi" version = "0.2.1" @@ -7896,15 +7571,6 @@ dependencies = [ "xim-parser", ] -[[package]] -name = "zed_extension_api" -version = "0.8.0" -dependencies = [ - "serde", - "serde_json", - "wit-bindgen 0.41.0", -] - [[package]] name = "zeno" version = "0.3.3" diff --git a/Cargo.toml b/Cargo.toml index c1979c63e2..06d21ec132 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,7 @@ [workspace] resolver = "2" members = [ - "crates/cloud_api_client", - "crates/cloud_api_types", - "crates/cloud_llm_client", "crates/collections", - "crates/extension_api", "crates/gpui", "crates/gpui_macros", "crates/gpui_tokio", @@ -34,9 +30,6 @@ edition = "2024" # Workspace member crates # -cloud_api_client = { path = "crates/cloud_api_client" } -cloud_api_types = { path = "crates/cloud_api_types" } -cloud_llm_client = { path = "crates/cloud_llm_client" } collections = { path = "crates/collections", version = "0.1.0" } derive_refineable = { path = "crates/refineable/derive_refineable" } gpui = { path = "crates/gpui", default-features = false } diff --git a/crates/cloud_api_client/Cargo.toml b/crates/cloud_api_client/Cargo.toml deleted file mode 100644 index 9dc009bf2e..0000000000 --- a/crates/cloud_api_client/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "cloud_api_client" -version = "0.1.0" -edition.workspace = true -publish.workspace = true -license = "Apache-2.0" - -[lints] -workspace = true - -[lib] -path = "src/cloud_api_client.rs" - -[dependencies] -anyhow.workspace = true -cloud_api_types.workspace = true -futures.workspace = true -gpui.workspace = true -gpui_tokio.workspace = true -http_client.workspace = true -parking_lot.workspace = true -serde_json.workspace = true -yawc.workspace = true diff --git a/crates/cloud_api_client/LICENSE-APACHE b/crates/cloud_api_client/LICENSE-APACHE deleted file mode 120000 index 1cd601d0a3..0000000000 --- a/crates/cloud_api_client/LICENSE-APACHE +++ /dev/null @@ -1 +0,0 @@ -../../LICENSE-APACHE \ No newline at end of file diff --git a/crates/cloud_api_client/src/cloud_api_client.rs b/crates/cloud_api_client/src/cloud_api_client.rs deleted file mode 100644 index 9206e5e7ef..0000000000 --- a/crates/cloud_api_client/src/cloud_api_client.rs +++ /dev/null @@ -1,198 +0,0 @@ -mod websocket; - -use std::sync::Arc; - -use anyhow::{Context, Result, anyhow}; -use cloud_api_types::websocket_protocol::{PROTOCOL_VERSION, PROTOCOL_VERSION_HEADER_NAME}; -pub use cloud_api_types::*; -use futures::AsyncReadExt as _; -use gpui::{App, Task}; -use gpui_tokio::Tokio; -use http_client::http::request; -use http_client::{AsyncBody, HttpClientWithUrl, HttpRequestExt, Method, Request, StatusCode}; -use parking_lot::RwLock; -use yawc::WebSocket; - -use crate::websocket::Connection; - -struct Credentials { - user_id: u32, - access_token: String, -} - -pub struct CloudApiClient { - credentials: RwLock>, - http_client: Arc, -} - -impl CloudApiClient { - pub fn new(http_client: Arc) -> Self { - Self { - credentials: RwLock::new(None), - http_client, - } - } - - pub fn has_credentials(&self) -> bool { - self.credentials.read().is_some() - } - - pub fn set_credentials(&self, user_id: u32, access_token: String) { - *self.credentials.write() = Some(Credentials { - user_id, - access_token, - }); - } - - pub fn clear_credentials(&self) { - *self.credentials.write() = None; - } - - fn build_request( - &self, - req: request::Builder, - body: impl Into, - ) -> Result> { - let credentials = self.credentials.read(); - let credentials = credentials.as_ref().context("no credentials provided")?; - build_request(req, body, credentials) - } - - pub async fn get_authenticated_user(&self) -> Result { - let request = self.build_request( - Request::builder().method(Method::GET).uri( - self.http_client - .build_zed_cloud_url("/client/users/me")? - .as_ref(), - ), - AsyncBody::default(), - )?; - - let mut response = self.http_client.send(request).await?; - - if !response.status().is_success() { - let mut body = String::new(); - response.body_mut().read_to_string(&mut body).await?; - - anyhow::bail!( - "Failed to get authenticated user.\nStatus: {:?}\nBody: {body}", - response.status() - ) - } - - let mut body = String::new(); - response.body_mut().read_to_string(&mut body).await?; - - Ok(serde_json::from_str(&body)?) - } - - pub fn connect(&self, cx: &App) -> Result>> { - let mut connect_url = self - .http_client - .build_zed_cloud_url("/client/users/connect")?; - connect_url - .set_scheme(match connect_url.scheme() { - "https" => "wss", - "http" => "ws", - scheme => Err(anyhow!("invalid URL scheme: {scheme}"))?, - }) - .map_err(|_| anyhow!("failed to set URL scheme"))?; - - let credentials = self.credentials.read(); - let credentials = credentials.as_ref().context("no credentials provided")?; - let authorization_header = format!("{} {}", credentials.user_id, credentials.access_token); - - Ok(Tokio::spawn_result(cx, async move { - let ws = WebSocket::connect(connect_url) - .with_request( - request::Builder::new() - .header("Authorization", authorization_header) - .header(PROTOCOL_VERSION_HEADER_NAME, PROTOCOL_VERSION.to_string()), - ) - .await?; - - Ok(Connection::new(ws)) - })) - } - - pub async fn create_llm_token( - &self, - system_id: Option, - ) -> Result { - let request_builder = Request::builder() - .method(Method::POST) - .uri( - self.http_client - .build_zed_cloud_url("/client/llm_tokens")? - .as_ref(), - ) - .when_some(system_id, |builder, system_id| { - builder.header(ZED_SYSTEM_ID_HEADER_NAME, system_id) - }); - - let request = self.build_request(request_builder, AsyncBody::default())?; - - let mut response = self.http_client.send(request).await?; - - if !response.status().is_success() { - let mut body = String::new(); - response.body_mut().read_to_string(&mut body).await?; - - anyhow::bail!( - "Failed to create LLM token.\nStatus: {:?}\nBody: {body}", - response.status() - ) - } - - let mut body = String::new(); - response.body_mut().read_to_string(&mut body).await?; - - Ok(serde_json::from_str(&body)?) - } - - pub async fn validate_credentials(&self, user_id: u32, access_token: &str) -> Result { - let request = build_request( - Request::builder().method(Method::GET).uri( - self.http_client - .build_zed_cloud_url("/client/users/me")? - .as_ref(), - ), - AsyncBody::default(), - &Credentials { - user_id, - access_token: access_token.into(), - }, - )?; - - let mut response = self.http_client.send(request).await?; - - if response.status().is_success() { - Ok(true) - } else { - let mut body = String::new(); - response.body_mut().read_to_string(&mut body).await?; - if response.status() == StatusCode::UNAUTHORIZED { - Ok(false) - } else { - Err(anyhow!( - "Failed to get authenticated user.\nStatus: {:?}\nBody: {body}", - response.status() - )) - } - } - } -} - -fn build_request( - req: request::Builder, - body: impl Into, - credentials: &Credentials, -) -> Result> { - Ok(req - .header("Content-Type", "application/json") - .header( - "Authorization", - format!("{} {}", credentials.user_id, credentials.access_token), - ) - .body(body.into())?) -} diff --git a/crates/cloud_api_client/src/websocket.rs b/crates/cloud_api_client/src/websocket.rs deleted file mode 100644 index 48a628db78..0000000000 --- a/crates/cloud_api_client/src/websocket.rs +++ /dev/null @@ -1,73 +0,0 @@ -use std::pin::Pin; -use std::time::Duration; - -use anyhow::Result; -use cloud_api_types::websocket_protocol::MessageToClient; -use futures::channel::mpsc::unbounded; -use futures::stream::{SplitSink, SplitStream}; -use futures::{FutureExt as _, SinkExt as _, Stream, StreamExt as _, TryStreamExt as _, pin_mut}; -use gpui::{App, BackgroundExecutor, Task}; -use yawc::WebSocket; -use yawc::frame::{FrameView, OpCode}; - -const KEEPALIVE_INTERVAL: Duration = Duration::from_secs(1); - -pub type MessageStream = Pin>>>; - -pub struct Connection { - tx: SplitSink, - rx: SplitStream, -} - -impl Connection { - pub fn new(ws: WebSocket) -> Self { - let (tx, rx) = ws.split(); - - Self { tx, rx } - } - - pub fn spawn(self, cx: &App) -> (MessageStream, Task<()>) { - let (mut tx, rx) = (self.tx, self.rx); - - let (message_tx, message_rx) = unbounded(); - - let handle_io = |executor: BackgroundExecutor| async move { - // Send messages on this frequency so the connection isn't closed. - let keepalive_timer = executor.timer(KEEPALIVE_INTERVAL).fuse(); - futures::pin_mut!(keepalive_timer); - - let rx = rx.fuse(); - pin_mut!(rx); - - loop { - futures::select_biased! { - _ = keepalive_timer => { - let _ = tx.send(FrameView::ping(Vec::new())).await; - - keepalive_timer.set(executor.timer(KEEPALIVE_INTERVAL).fuse()); - } - frame = rx.next() => { - let Some(frame) = frame else { - break; - }; - - match frame.opcode { - OpCode::Binary => { - let message_result = MessageToClient::deserialize(&frame.payload); - message_tx.unbounded_send(message_result).ok(); - } - OpCode::Close => { - break; - } - _ => {} - } - } - } - } - }; - - let task = cx.spawn(async move |cx| handle_io(cx.background_executor().clone()).await); - - (message_rx.into_stream().boxed(), task) - } -} diff --git a/crates/cloud_api_types/Cargo.toml b/crates/cloud_api_types/Cargo.toml deleted file mode 100644 index 46d5d109b1..0000000000 --- a/crates/cloud_api_types/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -name = "cloud_api_types" -version = "0.1.0" -edition.workspace = true -publish.workspace = true -license = "Apache-2.0" - -[lints] -workspace = true - -[lib] -path = "src/cloud_api_types.rs" - -[dependencies] -anyhow.workspace = true -chrono.workspace = true -ciborium.workspace = true -cloud_llm_client.workspace = true -serde.workspace = true - -[dev-dependencies] -pretty_assertions.workspace = true -serde_json.workspace = true diff --git a/crates/cloud_api_types/LICENSE-APACHE b/crates/cloud_api_types/LICENSE-APACHE deleted file mode 120000 index 1cd601d0a3..0000000000 --- a/crates/cloud_api_types/LICENSE-APACHE +++ /dev/null @@ -1 +0,0 @@ -../../LICENSE-APACHE \ No newline at end of file diff --git a/crates/cloud_api_types/src/cloud_api_types.rs b/crates/cloud_api_types/src/cloud_api_types.rs deleted file mode 100644 index fddf505f10..0000000000 --- a/crates/cloud_api_types/src/cloud_api_types.rs +++ /dev/null @@ -1,65 +0,0 @@ -mod timestamp; -pub mod websocket_protocol; - -use cloud_llm_client::Plan; -use serde::{Deserialize, Serialize}; - -pub use crate::timestamp::Timestamp; - -pub const ZED_SYSTEM_ID_HEADER_NAME: &str = "x-zed-system-id"; - -#[derive(Debug, PartialEq, Serialize, Deserialize)] -pub struct GetAuthenticatedUserResponse { - pub user: AuthenticatedUser, - pub feature_flags: Vec, - pub plan: PlanInfo, -} - -#[derive(Debug, PartialEq, Serialize, Deserialize)] -pub struct AuthenticatedUser { - pub id: i32, - pub metrics_id: String, - pub avatar_url: String, - pub github_login: String, - pub name: Option, - pub is_staff: bool, - pub accepted_tos_at: Option, -} - -#[derive(Debug, PartialEq, Serialize, Deserialize)] -pub struct PlanInfo { - pub plan: cloud_llm_client::PlanV1, - #[serde(default)] - pub plan_v2: Option, - pub subscription_period: Option, - pub usage: cloud_llm_client::CurrentUsage, - pub trial_started_at: Option, - pub is_usage_based_billing_enabled: bool, - pub is_account_too_young: bool, - pub has_overdue_invoices: bool, -} - -impl PlanInfo { - pub fn plan(&self) -> Plan { - self.plan_v2.map(Plan::V2).unwrap_or(Plan::V1(self.plan)) - } -} - -#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize)] -pub struct SubscriptionPeriod { - pub started_at: Timestamp, - pub ended_at: Timestamp, -} - -#[derive(Debug, PartialEq, Serialize, Deserialize)] -pub struct AcceptTermsOfServiceResponse { - pub user: AuthenticatedUser, -} - -#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] -pub struct LlmToken(pub String); - -#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] -pub struct CreateLlmTokenResponse { - pub token: LlmToken, -} diff --git a/crates/cloud_api_types/src/timestamp.rs b/crates/cloud_api_types/src/timestamp.rs deleted file mode 100644 index 1f055d58ef..0000000000 --- a/crates/cloud_api_types/src/timestamp.rs +++ /dev/null @@ -1,166 +0,0 @@ -use chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc}; -use serde::{Deserialize, Deserializer, Serialize, Serializer}; - -/// A timestamp with a serialized representation in RFC 3339 format. -#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)] -pub struct Timestamp(pub DateTime); - -impl Timestamp { - pub fn new(datetime: DateTime) -> Self { - Self(datetime) - } -} - -impl From> for Timestamp { - fn from(value: DateTime) -> Self { - Self(value) - } -} - -impl From for Timestamp { - fn from(value: NaiveDateTime) -> Self { - Self(value.and_utc()) - } -} - -impl Serialize for Timestamp { - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let rfc3339_string = self.0.to_rfc3339_opts(SecondsFormat::Millis, true); - serializer.serialize_str(&rfc3339_string) - } -} - -impl<'de> Deserialize<'de> for Timestamp { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - let value = String::deserialize(deserializer)?; - let datetime = DateTime::parse_from_rfc3339(&value) - .map_err(serde::de::Error::custom)? - .to_utc(); - Ok(Self(datetime)) - } -} - -#[cfg(test)] -mod tests { - use chrono::NaiveDate; - use pretty_assertions::assert_eq; - - use super::*; - - #[test] - fn test_timestamp_serialization() { - let datetime = DateTime::parse_from_rfc3339("2023-12-25T14:30:45.123Z") - .unwrap() - .to_utc(); - let timestamp = Timestamp::new(datetime); - - let json = serde_json::to_string(×tamp).unwrap(); - assert_eq!(json, "\"2023-12-25T14:30:45.123Z\""); - } - - #[test] - fn test_timestamp_deserialization() { - let json = "\"2023-12-25T14:30:45.123Z\""; - let timestamp: Timestamp = serde_json::from_str(json).unwrap(); - - let expected = DateTime::parse_from_rfc3339("2023-12-25T14:30:45.123Z") - .unwrap() - .to_utc(); - - assert_eq!(timestamp.0, expected); - } - - #[test] - fn test_timestamp_roundtrip() { - let original = DateTime::parse_from_rfc3339("2023-12-25T14:30:45.123Z") - .unwrap() - .to_utc(); - - let timestamp = Timestamp::new(original); - let json = serde_json::to_string(×tamp).unwrap(); - let deserialized: Timestamp = serde_json::from_str(&json).unwrap(); - - assert_eq!(deserialized.0, original); - } - - #[test] - fn test_timestamp_from_datetime_utc() { - let datetime = DateTime::parse_from_rfc3339("2023-12-25T14:30:45.123Z") - .unwrap() - .to_utc(); - - let timestamp = Timestamp::from(datetime); - assert_eq!(timestamp.0, datetime); - } - - #[test] - fn test_timestamp_from_naive_datetime() { - let naive_dt = NaiveDate::from_ymd_opt(2023, 12, 25) - .unwrap() - .and_hms_milli_opt(14, 30, 45, 123) - .unwrap(); - - let timestamp = Timestamp::from(naive_dt); - let expected = naive_dt.and_utc(); - - assert_eq!(timestamp.0, expected); - } - - #[test] - fn test_timestamp_serialization_with_microseconds() { - // Test that microseconds are truncated to milliseconds - let datetime = NaiveDate::from_ymd_opt(2023, 12, 25) - .unwrap() - .and_hms_micro_opt(14, 30, 45, 123456) - .unwrap() - .and_utc(); - - let timestamp = Timestamp::new(datetime); - let json = serde_json::to_string(×tamp).unwrap(); - - // Should be truncated to milliseconds - assert_eq!(json, "\"2023-12-25T14:30:45.123Z\""); - } - - #[test] - fn test_timestamp_deserialization_without_milliseconds() { - let json = "\"2023-12-25T14:30:45Z\""; - let timestamp: Timestamp = serde_json::from_str(json).unwrap(); - - let expected = NaiveDate::from_ymd_opt(2023, 12, 25) - .unwrap() - .and_hms_opt(14, 30, 45) - .unwrap() - .and_utc(); - - assert_eq!(timestamp.0, expected); - } - - #[test] - fn test_timestamp_deserialization_with_timezone() { - let json = "\"2023-12-25T14:30:45.123+05:30\""; - let timestamp: Timestamp = serde_json::from_str(json).unwrap(); - - // Should be converted to UTC - let expected = NaiveDate::from_ymd_opt(2023, 12, 25) - .unwrap() - .and_hms_milli_opt(9, 0, 45, 123) // 14:30:45 + 5:30 = 20:00:45, but we want UTC so subtract 5:30 - .unwrap() - .and_utc(); - - assert_eq!(timestamp.0, expected); - } - - #[test] - fn test_timestamp_deserialization_with_invalid_format() { - let json = "\"invalid-date\""; - let result: Result = serde_json::from_str(json); - assert!(result.is_err()); - } -} diff --git a/crates/cloud_api_types/src/websocket_protocol.rs b/crates/cloud_api_types/src/websocket_protocol.rs deleted file mode 100644 index 75f6a73b43..0000000000 --- a/crates/cloud_api_types/src/websocket_protocol.rs +++ /dev/null @@ -1,28 +0,0 @@ -use anyhow::{Context as _, Result}; -use serde::{Deserialize, Serialize}; - -/// The version of the Cloud WebSocket protocol. -pub const PROTOCOL_VERSION: u32 = 0; - -/// The name of the header used to indicate the protocol version in use. -pub const PROTOCOL_VERSION_HEADER_NAME: &str = "x-zed-protocol-version"; - -/// A message from Cloud to the Zed client. -#[derive(Debug, Serialize, Deserialize)] -pub enum MessageToClient { - /// The user was updated and should be refreshed. - UserUpdated, -} - -impl MessageToClient { - pub fn serialize(&self) -> Result> { - let mut buffer = Vec::new(); - ciborium::into_writer(self, &mut buffer).context("failed to serialize message")?; - - Ok(buffer) - } - - pub fn deserialize(data: &[u8]) -> Result { - ciborium::from_reader(data).context("failed to deserialize message") - } -} diff --git a/crates/cloud_llm_client/Cargo.toml b/crates/cloud_llm_client/Cargo.toml deleted file mode 100644 index c6a551a1fb..0000000000 --- a/crates/cloud_llm_client/Cargo.toml +++ /dev/null @@ -1,27 +0,0 @@ -[package] -name = "cloud_llm_client" -version = "0.1.0" -publish.workspace = true -edition.workspace = true -license = "Apache-2.0" - -[features] -test-support = [] - -[lints] -workspace = true - -[lib] -path = "src/cloud_llm_client.rs" - -[dependencies] -anyhow.workspace = true -chrono.workspace = true -serde = { workspace = true, features = ["derive", "rc"] } -serde_json.workspace = true -strum = { workspace = true, features = ["derive"] } -uuid = { workspace = true, features = ["serde"] } - -[dev-dependencies] -pretty_assertions.workspace = true -indoc.workspace = true diff --git a/crates/cloud_llm_client/LICENSE-APACHE b/crates/cloud_llm_client/LICENSE-APACHE deleted file mode 120000 index 1cd601d0a3..0000000000 --- a/crates/cloud_llm_client/LICENSE-APACHE +++ /dev/null @@ -1 +0,0 @@ -../../LICENSE-APACHE \ No newline at end of file diff --git a/crates/cloud_llm_client/src/cloud_llm_client.rs b/crates/cloud_llm_client/src/cloud_llm_client.rs deleted file mode 100644 index 917929a985..0000000000 --- a/crates/cloud_llm_client/src/cloud_llm_client.rs +++ /dev/null @@ -1,464 +0,0 @@ -pub mod predict_edits_v3; - -use std::str::FromStr; -use std::sync::Arc; - -use anyhow::Context as _; -use serde::{Deserialize, Serialize}; -use strum::{Display, EnumIter, EnumString}; -use uuid::Uuid; - -/// The name of the header used to indicate which version of Zed the client is running. -pub const ZED_VERSION_HEADER_NAME: &str = "x-zed-version"; - -/// The name of the header used to indicate when a request failed due to an -/// expired LLM token. -/// -/// The client may use this as a signal to refresh the token. -pub const EXPIRED_LLM_TOKEN_HEADER_NAME: &str = "x-zed-expired-token"; - -/// The name of the header used to indicate what plan the user is currently on. -pub const CURRENT_PLAN_HEADER_NAME: &str = "x-zed-plan"; - -/// The name of the header used to indicate the usage limit for model requests. -pub const MODEL_REQUESTS_USAGE_LIMIT_HEADER_NAME: &str = "x-zed-model-requests-usage-limit"; - -/// The name of the header used to indicate the usage amount for model requests. -pub const MODEL_REQUESTS_USAGE_AMOUNT_HEADER_NAME: &str = "x-zed-model-requests-usage-amount"; - -/// The name of the header used to indicate the usage limit for edit predictions. -pub const EDIT_PREDICTIONS_USAGE_LIMIT_HEADER_NAME: &str = "x-zed-edit-predictions-usage-limit"; - -/// The name of the header used to indicate the usage amount for edit predictions. -pub const EDIT_PREDICTIONS_USAGE_AMOUNT_HEADER_NAME: &str = "x-zed-edit-predictions-usage-amount"; - -/// The name of the header used to indicate the resource for which the subscription limit has been reached. -pub const SUBSCRIPTION_LIMIT_RESOURCE_HEADER_NAME: &str = "x-zed-subscription-limit-resource"; - -pub const MODEL_REQUESTS_RESOURCE_HEADER_VALUE: &str = "model_requests"; -pub const EDIT_PREDICTIONS_RESOURCE_HEADER_VALUE: &str = "edit_predictions"; - -/// The name of the header used to indicate that the maximum number of consecutive tool uses has been reached. -pub const TOOL_USE_LIMIT_REACHED_HEADER_NAME: &str = "x-zed-tool-use-limit-reached"; - -/// The name of the header used to indicate the minimum required Zed version. -/// -/// This can be used to force a Zed upgrade in order to continue communicating -/// with the LLM service. -pub const MINIMUM_REQUIRED_VERSION_HEADER_NAME: &str = "x-zed-minimum-required-version"; - -/// The name of the header used by the client to indicate to the server that it supports receiving status messages. -pub const CLIENT_SUPPORTS_STATUS_MESSAGES_HEADER_NAME: &str = - "x-zed-client-supports-status-messages"; - -/// The name of the header used by the server to indicate to the client that it supports sending status messages. -pub const SERVER_SUPPORTS_STATUS_MESSAGES_HEADER_NAME: &str = - "x-zed-server-supports-status-messages"; - -/// The name of the header used by the client to indicate that it supports receiving xAI models. -pub const CLIENT_SUPPORTS_X_AI_HEADER_NAME: &str = "x-zed-client-supports-x-ai"; - -/// The maximum number of edit predictions that can be rejected per request. -pub const MAX_EDIT_PREDICTION_REJECTIONS_PER_REQUEST: usize = 100; - -#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum UsageLimit { - Limited(i32), - Unlimited, -} - -impl FromStr for UsageLimit { - type Err = anyhow::Error; - - fn from_str(value: &str) -> Result { - match value { - "unlimited" => Ok(Self::Unlimited), - limit => limit - .parse::() - .map(Self::Limited) - .context("failed to parse limit"), - } - } -} - -#[derive(Debug, Clone, Copy, PartialEq)] -pub enum Plan { - V1(PlanV1), - V2(PlanV2), -} - -impl Plan { - pub fn is_v2(&self) -> bool { - matches!(self, Self::V2(_)) - } -} - -#[derive(Debug, Clone, Copy, Default, PartialEq, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum PlanV1 { - #[default] - #[serde(alias = "Free")] - ZedFree, - #[serde(alias = "ZedPro")] - ZedPro, - #[serde(alias = "ZedProTrial")] - ZedProTrial, -} - -impl FromStr for PlanV1 { - type Err = anyhow::Error; - - fn from_str(value: &str) -> Result { - match value { - "zed_free" => Ok(Self::ZedFree), - "zed_pro" => Ok(Self::ZedPro), - "zed_pro_trial" => Ok(Self::ZedProTrial), - plan => Err(anyhow::anyhow!("invalid plan: {plan:?}")), - } - } -} - -#[derive(Debug, Clone, Copy, Default, PartialEq, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum PlanV2 { - #[default] - ZedFree, - ZedPro, - ZedProTrial, -} - -impl FromStr for PlanV2 { - type Err = anyhow::Error; - - fn from_str(value: &str) -> Result { - match value { - "zed_free" => Ok(Self::ZedFree), - "zed_pro" => Ok(Self::ZedPro), - "zed_pro_trial" => Ok(Self::ZedProTrial), - plan => Err(anyhow::anyhow!("invalid plan: {plan:?}")), - } - } -} - -#[derive( - Debug, PartialEq, Eq, Hash, Clone, Copy, Serialize, Deserialize, EnumString, EnumIter, Display, -)] -#[serde(rename_all = "snake_case")] -#[strum(serialize_all = "snake_case")] -pub enum LanguageModelProvider { - Anthropic, - OpenAi, - Google, - XAi, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct PredictEditsBody { - #[serde(skip_serializing_if = "Option::is_none", default)] - pub outline: Option, - pub input_events: String, - pub input_excerpt: String, - #[serde(skip_serializing_if = "Option::is_none", default)] - pub speculated_output: Option, - /// Whether the user provided consent for sampling this interaction. - #[serde(default, alias = "data_collection_permission")] - pub can_collect_data: bool, - #[serde(skip_serializing_if = "Option::is_none", default)] - pub diagnostic_groups: Option>, - /// Info about the git repository state, only present when can_collect_data is true. - #[serde(skip_serializing_if = "Option::is_none", default)] - pub git_info: Option, - /// The trigger for this request. - #[serde(default)] - pub trigger: PredictEditsRequestTrigger, -} - -#[derive(Default, Debug, Clone, Copy, Serialize, Deserialize)] -pub enum PredictEditsRequestTrigger { - Diagnostics, - Cli, - #[default] - Other, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct PredictEditsGitInfo { - /// SHA of git HEAD commit at time of prediction. - #[serde(skip_serializing_if = "Option::is_none", default)] - pub head_sha: Option, - /// URL of the remote called `origin`. - #[serde(skip_serializing_if = "Option::is_none", default)] - pub remote_origin_url: Option, - /// URL of the remote called `upstream`. - #[serde(skip_serializing_if = "Option::is_none", default)] - pub remote_upstream_url: Option, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct PredictEditsResponse { - pub request_id: String, - pub output_excerpt: String, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct AcceptEditPredictionBody { - pub request_id: String, -} - -#[derive(Debug, Clone, Deserialize)] -pub struct RejectEditPredictionsBody { - pub rejections: Vec, -} - -#[derive(Debug, Clone, Serialize)] -pub struct RejectEditPredictionsBodyRef<'a> { - pub rejections: &'a [EditPredictionRejection], -} - -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] -pub struct EditPredictionRejection { - pub request_id: String, - #[serde(default)] - pub reason: EditPredictionRejectReason, - pub was_shown: bool, -} - -#[derive(Default, Debug, Clone, Copy, Serialize, Deserialize, PartialEq)] -pub enum EditPredictionRejectReason { - /// New requests were triggered before this one completed - Canceled, - /// No edits returned - Empty, - /// Edits returned, but none remained after interpolation - InterpolatedEmpty, - /// The new prediction was preferred over the current one - Replaced, - /// The current prediction was preferred over the new one - CurrentPreferred, - /// The current prediction was discarded - #[default] - Discarded, -} - -#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum CompletionMode { - Normal, - Max, -} - -#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum CompletionIntent { - UserPrompt, - ToolResults, - ThreadSummarization, - ThreadContextSummarization, - CreateFile, - EditFile, - InlineAssist, - TerminalInlineAssist, - GenerateGitCommitMessage, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct CompletionBody { - #[serde(skip_serializing_if = "Option::is_none", default)] - pub thread_id: Option, - #[serde(skip_serializing_if = "Option::is_none", default)] - pub prompt_id: Option, - #[serde(skip_serializing_if = "Option::is_none", default)] - pub intent: Option, - #[serde(skip_serializing_if = "Option::is_none", default)] - pub mode: Option, - pub provider: LanguageModelProvider, - pub model: String, - pub provider_request: serde_json::Value, -} - -#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum CompletionRequestStatus { - Queued { - position: usize, - }, - Started, - Failed { - code: String, - message: String, - request_id: Uuid, - /// Retry duration in seconds. - retry_after: Option, - }, - UsageUpdated { - amount: usize, - limit: UsageLimit, - }, - ToolUseLimitReached, -} - -#[derive(Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum CompletionEvent { - Status(CompletionRequestStatus), - Event(T), -} - -impl CompletionEvent { - pub fn into_status(self) -> Option { - match self { - Self::Status(status) => Some(status), - Self::Event(_) => None, - } - } - - pub fn into_event(self) -> Option { - match self { - Self::Event(event) => Some(event), - Self::Status(_) => None, - } - } -} - -#[derive(Serialize, Deserialize)] -pub struct WebSearchBody { - pub query: String, -} - -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct WebSearchResponse { - pub results: Vec, -} - -#[derive(Debug, Serialize, Deserialize, Clone)] -pub struct WebSearchResult { - pub title: String, - pub url: String, - pub text: String, -} - -#[derive(Serialize, Deserialize)] -pub struct CountTokensBody { - pub provider: LanguageModelProvider, - pub model: String, - pub provider_request: serde_json::Value, -} - -#[derive(Serialize, Deserialize)] -pub struct CountTokensResponse { - pub tokens: usize, -} - -#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize)] -pub struct LanguageModelId(pub Arc); - -impl std::fmt::Display for LanguageModelId { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.0) - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct LanguageModel { - pub provider: LanguageModelProvider, - pub id: LanguageModelId, - pub display_name: String, - pub max_token_count: usize, - pub max_token_count_in_max_mode: Option, - pub max_output_tokens: usize, - pub supports_tools: bool, - pub supports_images: bool, - pub supports_thinking: bool, - pub supports_max_mode: bool, - // only used by OpenAI and xAI - #[serde(default)] - pub supports_parallel_tool_calls: bool, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct ListModelsResponse { - pub models: Vec, - pub default_model: Option, - pub default_fast_model: Option, - pub recommended_models: Vec, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct GetSubscriptionResponse { - pub plan: PlanV1, - pub usage: Option, -} - -#[derive(Debug, PartialEq, Serialize, Deserialize)] -pub struct CurrentUsage { - pub model_requests: UsageData, - pub edit_predictions: UsageData, -} - -#[derive(Debug, PartialEq, Serialize, Deserialize)] -pub struct UsageData { - pub used: u32, - pub limit: UsageLimit, -} - -#[cfg(test)] -mod tests { - use pretty_assertions::assert_eq; - use serde_json::json; - - use super::*; - - #[test] - fn test_plan_v1_deserialize_snake_case() { - let plan = serde_json::from_value::(json!("zed_free")).unwrap(); - assert_eq!(plan, PlanV1::ZedFree); - - let plan = serde_json::from_value::(json!("zed_pro")).unwrap(); - assert_eq!(plan, PlanV1::ZedPro); - - let plan = serde_json::from_value::(json!("zed_pro_trial")).unwrap(); - assert_eq!(plan, PlanV1::ZedProTrial); - } - - #[test] - fn test_plan_v1_deserialize_aliases() { - let plan = serde_json::from_value::(json!("Free")).unwrap(); - assert_eq!(plan, PlanV1::ZedFree); - - let plan = serde_json::from_value::(json!("ZedPro")).unwrap(); - assert_eq!(plan, PlanV1::ZedPro); - - let plan = serde_json::from_value::(json!("ZedProTrial")).unwrap(); - assert_eq!(plan, PlanV1::ZedProTrial); - } - - #[test] - fn test_plan_v2_deserialize_snake_case() { - let plan = serde_json::from_value::(json!("zed_free")).unwrap(); - assert_eq!(plan, PlanV2::ZedFree); - - let plan = serde_json::from_value::(json!("zed_pro")).unwrap(); - assert_eq!(plan, PlanV2::ZedPro); - - let plan = serde_json::from_value::(json!("zed_pro_trial")).unwrap(); - assert_eq!(plan, PlanV2::ZedProTrial); - } - - #[test] - fn test_usage_limit_from_str() { - let limit = UsageLimit::from_str("unlimited").unwrap(); - assert!(matches!(limit, UsageLimit::Unlimited)); - - let limit = UsageLimit::from_str(&0.to_string()).unwrap(); - assert!(matches!(limit, UsageLimit::Limited(0))); - - let limit = UsageLimit::from_str(&50.to_string()).unwrap(); - assert!(matches!(limit, UsageLimit::Limited(50))); - - for value in ["not_a_number", "50xyz"] { - let limit = UsageLimit::from_str(value); - assert!(limit.is_err()); - } - } -} diff --git a/crates/cloud_llm_client/src/predict_edits_v3.rs b/crates/cloud_llm_client/src/predict_edits_v3.rs deleted file mode 100644 index 9e590dc4cf..0000000000 --- a/crates/cloud_llm_client/src/predict_edits_v3.rs +++ /dev/null @@ -1,298 +0,0 @@ -use chrono::Duration; -use serde::{Deserialize, Serialize}; -use std::{ - fmt::{Display, Write as _}, - ops::{Add, Range, Sub}, - path::Path, - sync::Arc, -}; -use strum::EnumIter; -use uuid::Uuid; - -use crate::{PredictEditsGitInfo, PredictEditsRequestTrigger}; - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct PlanContextRetrievalRequest { - pub excerpt: String, - pub excerpt_path: Arc, - pub excerpt_line_range: Range, - pub cursor_file_max_row: Line, - pub events: Vec>, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct PredictEditsRequest { - pub excerpt: String, - pub excerpt_path: Arc, - /// Within file - pub excerpt_range: Range, - pub excerpt_line_range: Range, - pub cursor_point: Point, - /// Within `signatures` - pub excerpt_parent: Option, - #[serde(skip_serializing_if = "Vec::is_empty", default)] - pub related_files: Vec, - pub events: Vec>, - #[serde(default)] - pub can_collect_data: bool, - /// Info about the git repository state, only present when can_collect_data is true. - #[serde(skip_serializing_if = "Option::is_none", default)] - pub git_info: Option, - // Only available to staff - #[serde(default)] - pub debug_info: bool, - #[serde(skip_serializing_if = "Option::is_none", default)] - pub prompt_max_bytes: Option, - #[serde(default)] - pub prompt_format: PromptFormat, - #[serde(default)] - pub trigger: PredictEditsRequestTrigger, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct RelatedFile { - pub path: Arc, - pub max_row: Line, - pub excerpts: Vec, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct Excerpt { - pub start_line: Line, - pub text: Arc, -} - -#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, EnumIter)] -pub enum PromptFormat { - /// XML old_tex/new_text - OldTextNewText, - /// Prompt format intended for use via edit_prediction_cli - OnlySnippets, - /// One-sentence instructions used in fine-tuned models - Minimal, - /// One-sentence instructions + FIM-like template - MinimalQwen, - /// No instructions, Qwen chat + Seed-Coder 1120 FIM-like template - SeedCoder1120, -} - -impl PromptFormat { - pub const DEFAULT: PromptFormat = PromptFormat::Minimal; -} - -impl Default for PromptFormat { - fn default() -> Self { - Self::DEFAULT - } -} - -impl PromptFormat { - pub fn iter() -> impl Iterator { - ::iter() - } -} - -impl std::fmt::Display for PromptFormat { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - PromptFormat::OnlySnippets => write!(f, "Only Snippets"), - PromptFormat::OldTextNewText => write!(f, "Old Text / New Text"), - PromptFormat::Minimal => write!(f, "Minimal"), - PromptFormat::MinimalQwen => write!(f, "Minimal + Qwen FIM"), - PromptFormat::SeedCoder1120 => write!(f, "Seed-Coder 1120"), - } - } -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[cfg_attr(any(test, feature = "test-support"), derive(PartialEq))] -#[serde(tag = "event")] -pub enum Event { - BufferChange { - path: Arc, - old_path: Arc, - diff: String, - predicted: bool, - in_open_source_repo: bool, - }, -} - -impl Display for Event { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Event::BufferChange { - path, - old_path, - diff, - predicted, - .. - } => { - if *predicted { - write!( - f, - "// User accepted prediction:\n--- a/{}\n+++ b/{}\n{diff}", - DiffPathFmt(old_path), - DiffPathFmt(path) - ) - } else { - write!( - f, - "--- a/{}\n+++ b/{}\n{diff}", - DiffPathFmt(old_path), - DiffPathFmt(path) - ) - } - } - } - } -} - -/// always format the Path as a unix path with `/` as the path sep in Diffs -pub struct DiffPathFmt<'a>(pub &'a Path); - -impl<'a> std::fmt::Display for DiffPathFmt<'a> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let mut is_first = true; - for component in self.0.components() { - if !is_first { - f.write_char('/')?; - } else { - is_first = false; - } - write!(f, "{}", component.as_os_str().display())?; - } - Ok(()) - } -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct PredictEditsResponse { - pub request_id: Uuid, - pub edits: Vec, - pub debug_info: Option, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct DebugInfo { - pub prompt: String, - pub prompt_planning_time: Duration, - pub model_response: String, - pub inference_time: Duration, - pub parsing_time: Duration, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct Edit { - pub path: Arc, - pub range: Range, - pub content: String, -} - -#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, PartialOrd, Eq, Ord)] -pub struct Point { - pub line: Line, - pub column: u32, -} - -#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, PartialOrd, Eq, Ord)] -#[serde(transparent)] -pub struct Line(pub u32); - -impl Add for Line { - type Output = Self; - - fn add(self, rhs: Self) -> Self::Output { - Self(self.0 + rhs.0) - } -} - -impl Sub for Line { - type Output = Self; - - fn sub(self, rhs: Self) -> Self::Output { - Self(self.0 - rhs.0) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use indoc::indoc; - use pretty_assertions::assert_eq; - - #[test] - fn test_event_display() { - let ev = Event::BufferChange { - path: Path::new("untitled").into(), - old_path: Path::new("untitled").into(), - diff: "@@ -1,2 +1,2 @@\n-a\n-b\n".into(), - predicted: false, - in_open_source_repo: true, - }; - assert_eq!( - ev.to_string(), - indoc! {" - --- a/untitled - +++ b/untitled - @@ -1,2 +1,2 @@ - -a - -b - "} - ); - - let ev = Event::BufferChange { - path: Path::new("foo/bar.txt").into(), - old_path: Path::new("foo/bar.txt").into(), - diff: "@@ -1,2 +1,2 @@\n-a\n-b\n".into(), - predicted: false, - in_open_source_repo: true, - }; - assert_eq!( - ev.to_string(), - indoc! {" - --- a/foo/bar.txt - +++ b/foo/bar.txt - @@ -1,2 +1,2 @@ - -a - -b - "} - ); - - let ev = Event::BufferChange { - path: Path::new("abc.txt").into(), - old_path: Path::new("123.txt").into(), - diff: "@@ -1,2 +1,2 @@\n-a\n-b\n".into(), - predicted: false, - in_open_source_repo: true, - }; - assert_eq!( - ev.to_string(), - indoc! {" - --- a/123.txt - +++ b/abc.txt - @@ -1,2 +1,2 @@ - -a - -b - "} - ); - - let ev = Event::BufferChange { - path: Path::new("abc.txt").into(), - old_path: Path::new("123.txt").into(), - diff: "@@ -1,2 +1,2 @@\n-a\n-b\n".into(), - predicted: true, - in_open_source_repo: true, - }; - assert_eq!( - ev.to_string(), - indoc! {" - // User accepted prediction: - --- a/123.txt - +++ b/abc.txt - @@ -1,2 +1,2 @@ - -a - -b - "} - ); - } -} diff --git a/crates/extension_api/Cargo.toml b/crates/extension_api/Cargo.toml deleted file mode 100644 index 829455e629..0000000000 --- a/crates/extension_api/Cargo.toml +++ /dev/null @@ -1,25 +0,0 @@ -[package] -name = "zed_extension_api" -version = "0.8.0" -description = "APIs for creating Zed extensions in Rust" -repository = "https://github.com/zed-industries/zed" -documentation = "https://docs.rs/zed_extension_api" -keywords = ["zed", "extension"] -edition.workspace = true -# Change back to `true` when we're ready to publish v0.8.0. -publish = false -license = "Apache-2.0" - -[lints] -workspace = true - -[lib] -path = "src/extension_api.rs" - -[dependencies] -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -wit-bindgen = "0.41" - -[package.metadata.component] -target = { path = "wit" } diff --git a/crates/extension_api/LICENSE-APACHE b/crates/extension_api/LICENSE-APACHE deleted file mode 120000 index 1cd601d0a3..0000000000 --- a/crates/extension_api/LICENSE-APACHE +++ /dev/null @@ -1 +0,0 @@ -../../LICENSE-APACHE \ No newline at end of file diff --git a/crates/extension_api/PENDING_CHANGES.md b/crates/extension_api/PENDING_CHANGES.md deleted file mode 100644 index 1d9875671b..0000000000 --- a/crates/extension_api/PENDING_CHANGES.md +++ /dev/null @@ -1,12 +0,0 @@ -# Pending Changes - -This is a list of pending changes to the Zed extension API that require a breaking change. - -This list should be updated as we notice things that should be changed so that we can batch them up in a single release. - -## vNext - -### Slash Commands - -- Rename `SlashCommand.tooltip_text` to `SlashCommand.menu_text` - - We may even want to remove it entirely, as right now this is only used for featured slash commands, and slash commands defined by extensions aren't currently able to be featured. diff --git a/crates/extension_api/README.md b/crates/extension_api/README.md deleted file mode 100644 index 89631269e7..0000000000 --- a/crates/extension_api/README.md +++ /dev/null @@ -1,77 +0,0 @@ -# The Zed Rust Extension API - -This crate lets you write extensions for Zed in Rust. - -## Extension Manifest - -You'll need an `extension.toml` file at the root of your extension directory, with the following structure: - -```toml -id = "my-extension" -name = "My Extension" -description = "..." -version = "0.0.1" -schema_version = 1 -authors = ["Your Name "] -repository = "https://github.com/your/extension-repository" -``` - -## Cargo metadata - -Zed extensions are packaged as WebAssembly files. In your Cargo.toml, you'll -need to set your `crate-type` accordingly: - -```toml -[dependencies] -zed_extension_api = "0.6.0" - -[lib] -crate-type = ["cdylib"] -``` - -## Implementing an Extension - -To define your extension, create a type that implements the `Extension` trait, and register it. - -```rust -use zed_extension_api as zed; - -struct MyExtension { - // ... state -} - -impl zed::Extension for MyExtension { - // ... -} - -zed::register_extension!(MyExtension); -``` - -## Testing your extension - -To run your extension in Zed as you're developing it: - -- Make sure you have [Rust installed](https://www.rust-lang.org/learn/get-started) -- Have the `wasm32-wasip2` target installed (`rustup target add wasm32-wasip2`) -- Open the extensions view using the `zed: extensions` action in the command palette. -- Click the `Install Dev Extension` button in the top right -- Choose the path to your extension directory. - -## Compatible Zed versions - -Extensions created using newer versions of the Zed extension API won't be compatible with older versions of Zed. - -Here is the compatibility of the `zed_extension_api` with versions of Zed: - -| Zed version | `zed_extension_api` version | -| ----------- | --------------------------- | -| `0.192.x` | `0.0.1` - `0.6.0` | -| `0.186.x` | `0.0.1` - `0.5.0` | -| `0.184.x` | `0.0.1` - `0.4.0` | -| `0.178.x` | `0.0.1` - `0.3.0` | -| `0.162.x` | `0.0.1` - `0.2.0` | -| `0.149.x` | `0.0.1` - `0.1.0` | -| `0.131.x` | `0.0.1` - `0.0.6` | -| `0.130.x` | `0.0.1` - `0.0.5` | -| `0.129.x` | `0.0.1` - `0.0.4` | -| `0.128.x` | `0.0.1` | diff --git a/crates/extension_api/build.rs b/crates/extension_api/build.rs deleted file mode 100644 index bd9149578a..0000000000 --- a/crates/extension_api/build.rs +++ /dev/null @@ -1,15 +0,0 @@ -fn main() { - let version = std::env::var("CARGO_PKG_VERSION").unwrap(); - let out_dir = std::env::var("OUT_DIR").unwrap(); - - let mut parts = version.split(|c: char| !c.is_ascii_digit()); - let major = parts.next().unwrap().parse::().unwrap().to_be_bytes(); - let minor = parts.next().unwrap().parse::().unwrap().to_be_bytes(); - let patch = parts.next().unwrap().parse::().unwrap().to_be_bytes(); - - std::fs::write( - std::path::Path::new(&out_dir).join("version_bytes"), - [major[0], major[1], minor[0], minor[1], patch[0], patch[1]], - ) - .unwrap(); -} diff --git a/crates/extension_api/src/extension_api.rs b/crates/extension_api/src/extension_api.rs deleted file mode 100644 index 9418623224..0000000000 --- a/crates/extension_api/src/extension_api.rs +++ /dev/null @@ -1,586 +0,0 @@ -//! The Zed Rust Extension API allows you write extensions for [Zed](https://zed.dev/) in Rust. - -pub mod http_client; -pub mod process; -pub mod settings; - -use core::fmt; - -use wit::*; - -pub use serde_json; - -// WIT re-exports. -// -// We explicitly enumerate the symbols we want to re-export, as there are some -// that we may want to shadow to provide a cleaner Rust API. -pub use wit::{ - CodeLabel, CodeLabelSpan, CodeLabelSpanLiteral, Command, DownloadedFileType, EnvVars, - KeyValueStore, LanguageServerInstallationStatus, Project, Range, Worktree, download_file, - make_file_executable, - zed::extension::context_server::ContextServerConfiguration, - zed::extension::dap::{ - AttachRequest, BuildTaskDefinition, BuildTaskDefinitionTemplatePayload, BuildTaskTemplate, - DebugAdapterBinary, DebugConfig, DebugRequest, DebugScenario, DebugTaskDefinition, - LaunchRequest, StartDebuggingRequestArguments, StartDebuggingRequestArgumentsRequest, - TaskTemplate, TcpArguments, TcpArgumentsTemplate, resolve_tcp_template, - }, - zed::extension::github::{ - GithubRelease, GithubReleaseAsset, GithubReleaseOptions, github_release_by_tag_name, - latest_github_release, - }, - zed::extension::nodejs::{ - node_binary_path, npm_install_package, npm_package_installed_version, - npm_package_latest_version, - }, - zed::extension::platform::{Architecture, Os, current_platform}, - zed::extension::slash_command::{ - SlashCommand, SlashCommandArgumentCompletion, SlashCommandOutput, SlashCommandOutputSection, - }, -}; - -// Undocumented WIT re-exports. -// -// These are symbols that need to be public for the purposes of implementing -// the extension host, but aren't relevant to extension authors. -#[doc(hidden)] -pub use wit::Guest; - -/// Constructs for interacting with language servers over the -/// Language Server Protocol (LSP). -pub mod lsp { - pub use crate::wit::zed::extension::lsp::{ - Completion, CompletionKind, InsertTextFormat, Symbol, SymbolKind, - }; -} - -/// A result returned from a Zed extension. -pub type Result = core::result::Result; - -/// Updates the installation status for the given language server. -pub fn set_language_server_installation_status( - language_server_id: &LanguageServerId, - status: &LanguageServerInstallationStatus, -) { - wit::set_language_server_installation_status(&language_server_id.0, status) -} - -/// A Zed extension. -pub trait Extension: Send + Sync { - /// Returns a new instance of the extension. - fn new() -> Self - where - Self: Sized; - - /// Returns the command used to start the language server for the specified - /// language. - fn language_server_command( - &mut self, - _language_server_id: &LanguageServerId, - _worktree: &Worktree, - ) -> Result { - Err("`language_server_command` not implemented".to_string()) - } - - /// Returns the initialization options to pass to the specified language server. - fn language_server_initialization_options( - &mut self, - _language_server_id: &LanguageServerId, - _worktree: &Worktree, - ) -> Result> { - Ok(None) - } - - /// Returns the workspace configuration options to pass to the language server. - fn language_server_workspace_configuration( - &mut self, - _language_server_id: &LanguageServerId, - _worktree: &Worktree, - ) -> Result> { - Ok(None) - } - - /// Returns the initialization options to pass to the other language server. - fn language_server_additional_initialization_options( - &mut self, - _language_server_id: &LanguageServerId, - _target_language_server_id: &LanguageServerId, - _worktree: &Worktree, - ) -> Result> { - Ok(None) - } - - /// Returns the workspace configuration options to pass to the other language server. - fn language_server_additional_workspace_configuration( - &mut self, - _language_server_id: &LanguageServerId, - _target_language_server_id: &LanguageServerId, - _worktree: &Worktree, - ) -> Result> { - Ok(None) - } - - /// Returns the label for the given completion. - fn label_for_completion( - &self, - _language_server_id: &LanguageServerId, - _completion: Completion, - ) -> Option { - None - } - - /// Returns the label for the given symbol. - fn label_for_symbol( - &self, - _language_server_id: &LanguageServerId, - _symbol: Symbol, - ) -> Option { - None - } - - /// Returns the completions that should be shown when completing the provided slash command with the given query. - fn complete_slash_command_argument( - &self, - _command: SlashCommand, - _args: Vec, - ) -> Result, String> { - Ok(Vec::new()) - } - - /// Returns the output from running the provided slash command. - fn run_slash_command( - &self, - _command: SlashCommand, - _args: Vec, - _worktree: Option<&Worktree>, - ) -> Result { - Err("`run_slash_command` not implemented".to_string()) - } - - /// Returns the command used to start a context server. - fn context_server_command( - &mut self, - _context_server_id: &ContextServerId, - _project: &Project, - ) -> Result { - Err("`context_server_command` not implemented".to_string()) - } - - /// Returns the configuration options for the specified context server. - fn context_server_configuration( - &mut self, - _context_server_id: &ContextServerId, - _project: &Project, - ) -> Result> { - Ok(None) - } - - /// Returns a list of package names as suggestions to be included in the - /// search results of the `/docs` slash command. - /// - /// This can be used to provide completions for known packages (e.g., from the - /// local project or a registry) before a package has been indexed. - fn suggest_docs_packages(&self, _provider: String) -> Result, String> { - Ok(Vec::new()) - } - - /// Indexes the docs for the specified package. - fn index_docs( - &self, - _provider: String, - _package: String, - _database: &KeyValueStore, - ) -> Result<(), String> { - Err("`index_docs` not implemented".to_string()) - } - - /// Returns the debug adapter binary for the specified adapter name and configuration. - fn get_dap_binary( - &mut self, - _adapter_name: String, - _config: DebugTaskDefinition, - _user_provided_debug_adapter_path: Option, - _worktree: &Worktree, - ) -> Result { - Err("`get_dap_binary` not implemented".to_string()) - } - - /// Determines whether the specified adapter configuration should *launch* a new debuggee process - /// or *attach* to an existing one. This function should not perform any further validation (outside of determining the kind of a request). - /// This function should return an error when the kind cannot be determined (rather than fall back to a known default). - fn dap_request_kind( - &mut self, - _adapter_name: String, - _config: serde_json::Value, - ) -> Result { - Err("`dap_request_kind` not implemented".to_string()) - } - /// Converts a high-level definition of a debug scenario (originating in a new session UI) to a "low-level" configuration suitable for a particular adapter. - /// - /// In layman's terms: given a program, list of arguments, current working directory and environment variables, - /// create a configuration that can be used to start a debug session. - fn dap_config_to_scenario(&mut self, _config: DebugConfig) -> Result { - Err("`dap_config_to_scenario` not implemented".to_string()) - } - - /// Locators are entities that convert a Zed task into a debug scenario. - /// - /// They can be provided even by extensions that don't provide a debug adapter. - /// For all tasks applicable to a given buffer, Zed will query all locators to find one that can turn the task into a debug scenario. - /// A converted debug scenario can include a build task (it shouldn't contain any configuration in such case); a build task result will later - /// be resolved with [`Extension::run_dap_locator`]. - /// - /// To work through a real-world example, take a `cargo run` task and a hypothetical `cargo` locator: - /// 1. We may need to modify the task; in this case, it is problematic that `cargo run` spawns a binary. We should turn `cargo run` into a debug scenario with - /// `cargo build` task. This is the decision we make at `dap_locator_create_scenario` scope. - /// 2. Then, after the build task finishes, we will run `run_dap_locator` of the locator that produced the build task to find the program to be debugged. This function - /// should give us a debugger-agnostic configuration for launching a debug target (that we end up resolving with [`Extension::dap_config_to_scenario`]). It's almost as if the user - /// found the artifact path by themselves. - /// - /// Note that you're not obliged to use build tasks with locators. Specifically, it is sufficient to provide a debug configuration directly in the return value of - /// `dap_locator_create_scenario` if you're able to do that. Make sure to not fill out `build` field in that case, as that will prevent Zed from running second phase of resolution in such case. - /// This might be of particular relevance to interpreted languages. - fn dap_locator_create_scenario( - &mut self, - _locator_name: String, - _build_task: TaskTemplate, - _resolved_label: String, - _debug_adapter_name: String, - ) -> Option { - None - } - - /// Runs the second phase of locator resolution. - /// See [`Extension::dap_locator_create_scenario`] for a hefty comment on locators. - fn run_dap_locator( - &mut self, - _locator_name: String, - _build_task: TaskTemplate, - ) -> Result { - Err("`run_dap_locator` not implemented".to_string()) - } -} - -/// Registers the provided type as a Zed extension. -/// -/// The type must implement the [`Extension`] trait. -#[macro_export] -macro_rules! register_extension { - ($extension_type:ty) => { - #[cfg(target_os = "wasi")] - mod wasi_ext { - unsafe extern "C" { - static mut errno: i32; - pub static mut __wasilibc_cwd: *mut std::ffi::c_char; - } - - pub fn init_cwd() { - unsafe { - // Ensure that our chdir function is linked, instead of the - // one from wasi-libc in the chdir.o translation unit. Otherwise - // we risk linking in `__wasilibc_find_relpath_alloc` which - // is a weak symbol and is being used by - // `__wasilibc_find_relpath`, which we do not want on - // Windows. - chdir(std::ptr::null()); - - __wasilibc_cwd = std::ffi::CString::new(std::env::var("PWD").unwrap()) - .unwrap() - .into_raw() - .cast(); - } - } - - #[unsafe(no_mangle)] - pub unsafe extern "C" fn chdir(raw_path: *const std::ffi::c_char) -> i32 { - // Forbid extensions from changing CWD and so return an appropriate error code. - errno = 58; // NOTSUP - return -1; - } - } - - #[unsafe(export_name = "init-extension")] - pub extern "C" fn __init_extension() { - #[cfg(target_os = "wasi")] - wasi_ext::init_cwd(); - - zed_extension_api::register_extension(|| { - Box::new(<$extension_type as zed_extension_api::Extension>::new()) - }); - } - }; -} - -#[doc(hidden)] -pub fn register_extension(build_extension: fn() -> Box) { - unsafe { EXTENSION = Some((build_extension)()) } -} - -fn extension() -> &'static mut dyn Extension { - #[expect(static_mut_refs)] - unsafe { - EXTENSION.as_deref_mut().unwrap() - } -} - -static mut EXTENSION: Option> = None; - -#[cfg(target_arch = "wasm32")] -#[unsafe(link_section = "zed:api-version")] -#[doc(hidden)] -pub static ZED_API_VERSION: [u8; 6] = *include_bytes!(concat!(env!("OUT_DIR"), "/version_bytes")); - -mod wit { - - wit_bindgen::generate!({ - skip: ["init-extension"], - path: "./wit/since_v0.8.0", - }); -} - -wit::export!(Component); - -struct Component; - -impl wit::Guest for Component { - fn language_server_command( - language_server_id: String, - worktree: &wit::Worktree, - ) -> Result { - let language_server_id = LanguageServerId(language_server_id); - extension().language_server_command(&language_server_id, worktree) - } - - fn language_server_initialization_options( - language_server_id: String, - worktree: &Worktree, - ) -> Result, String> { - let language_server_id = LanguageServerId(language_server_id); - Ok(extension() - .language_server_initialization_options(&language_server_id, worktree)? - .and_then(|value| serde_json::to_string(&value).ok())) - } - - fn language_server_workspace_configuration( - language_server_id: String, - worktree: &Worktree, - ) -> Result, String> { - let language_server_id = LanguageServerId(language_server_id); - Ok(extension() - .language_server_workspace_configuration(&language_server_id, worktree)? - .and_then(|value| serde_json::to_string(&value).ok())) - } - - fn language_server_additional_initialization_options( - language_server_id: String, - target_language_server_id: String, - worktree: &Worktree, - ) -> Result, String> { - let language_server_id = LanguageServerId(language_server_id); - let target_language_server_id = LanguageServerId(target_language_server_id); - Ok(extension() - .language_server_additional_initialization_options( - &language_server_id, - &target_language_server_id, - worktree, - )? - .and_then(|value| serde_json::to_string(&value).ok())) - } - - fn language_server_additional_workspace_configuration( - language_server_id: String, - target_language_server_id: String, - worktree: &Worktree, - ) -> Result, String> { - let language_server_id = LanguageServerId(language_server_id); - let target_language_server_id = LanguageServerId(target_language_server_id); - Ok(extension() - .language_server_additional_workspace_configuration( - &language_server_id, - &target_language_server_id, - worktree, - )? - .and_then(|value| serde_json::to_string(&value).ok())) - } - - fn labels_for_completions( - language_server_id: String, - completions: Vec, - ) -> Result>, String> { - let language_server_id = LanguageServerId(language_server_id); - let mut labels = Vec::new(); - for (ix, completion) in completions.into_iter().enumerate() { - let label = extension().label_for_completion(&language_server_id, completion); - if let Some(label) = label { - labels.resize(ix + 1, None); - *labels.last_mut().unwrap() = Some(label); - } - } - Ok(labels) - } - - fn labels_for_symbols( - language_server_id: String, - symbols: Vec, - ) -> Result>, String> { - let language_server_id = LanguageServerId(language_server_id); - let mut labels = Vec::new(); - for (ix, symbol) in symbols.into_iter().enumerate() { - let label = extension().label_for_symbol(&language_server_id, symbol); - if let Some(label) = label { - labels.resize(ix + 1, None); - *labels.last_mut().unwrap() = Some(label); - } - } - Ok(labels) - } - - fn complete_slash_command_argument( - command: SlashCommand, - args: Vec, - ) -> Result, String> { - extension().complete_slash_command_argument(command, args) - } - - fn run_slash_command( - command: SlashCommand, - args: Vec, - worktree: Option<&Worktree>, - ) -> Result { - extension().run_slash_command(command, args, worktree) - } - - fn context_server_command( - context_server_id: String, - project: &Project, - ) -> Result { - let context_server_id = ContextServerId(context_server_id); - extension().context_server_command(&context_server_id, project) - } - - fn context_server_configuration( - context_server_id: String, - project: &Project, - ) -> Result, String> { - let context_server_id = ContextServerId(context_server_id); - extension().context_server_configuration(&context_server_id, project) - } - - fn suggest_docs_packages(provider: String) -> Result, String> { - extension().suggest_docs_packages(provider) - } - - fn index_docs( - provider: String, - package: String, - database: &KeyValueStore, - ) -> Result<(), String> { - extension().index_docs(provider, package, database) - } - - fn get_dap_binary( - adapter_name: String, - config: DebugTaskDefinition, - user_installed_path: Option, - worktree: &Worktree, - ) -> Result { - extension().get_dap_binary(adapter_name, config, user_installed_path, worktree) - } - - fn dap_request_kind( - adapter_name: String, - config: String, - ) -> Result { - extension().dap_request_kind( - adapter_name, - serde_json::from_str(&config).map_err(|e| format!("Failed to parse config: {e}"))?, - ) - } - fn dap_config_to_scenario(config: DebugConfig) -> Result { - extension().dap_config_to_scenario(config) - } - fn dap_locator_create_scenario( - locator_name: String, - build_task: TaskTemplate, - resolved_label: String, - debug_adapter_name: String, - ) -> Option { - extension().dap_locator_create_scenario( - locator_name, - build_task, - resolved_label, - debug_adapter_name, - ) - } - fn run_dap_locator( - locator_name: String, - build_task: TaskTemplate, - ) -> Result { - extension().run_dap_locator(locator_name, build_task) - } -} - -/// The ID of a language server. -#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone)] -pub struct LanguageServerId(String); - -impl AsRef for LanguageServerId { - fn as_ref(&self) -> &str { - &self.0 - } -} - -impl fmt::Display for LanguageServerId { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.0) - } -} - -/// The ID of a context server. -#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone)] -pub struct ContextServerId(String); - -impl AsRef for ContextServerId { - fn as_ref(&self) -> &str { - &self.0 - } -} - -impl fmt::Display for ContextServerId { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.0) - } -} - -impl CodeLabelSpan { - /// Returns a [`CodeLabelSpan::CodeRange`]. - pub fn code_range(range: impl Into) -> Self { - Self::CodeRange(range.into()) - } - - /// Returns a [`CodeLabelSpan::Literal`]. - pub fn literal(text: impl Into, highlight_name: Option) -> Self { - Self::Literal(CodeLabelSpanLiteral { - text: text.into(), - highlight_name, - }) - } -} - -impl From> for wit::Range { - fn from(value: std::ops::Range) -> Self { - Self { - start: value.start, - end: value.end, - } - } -} - -impl From> for wit::Range { - fn from(value: std::ops::Range) -> Self { - Self { - start: value.start as u32, - end: value.end as u32, - } - } -} diff --git a/crates/extension_api/src/http_client.rs b/crates/extension_api/src/http_client.rs deleted file mode 100644 index 9e30da8db4..0000000000 --- a/crates/extension_api/src/http_client.rs +++ /dev/null @@ -1,101 +0,0 @@ -//! An HTTP client. - -pub use crate::wit::zed::extension::http_client::{ - HttpMethod, HttpRequest, HttpResponse, HttpResponseStream, RedirectPolicy, fetch, fetch_stream, -}; - -impl HttpRequest { - /// Returns a builder for an [`HttpRequest`]. - pub fn builder() -> HttpRequestBuilder { - HttpRequestBuilder::new() - } - - /// Executes the [`HttpRequest`] with [`fetch`]. - pub fn fetch(&self) -> Result { - fetch(self) - } - - /// Executes the [`HttpRequest`] with [`fetch_stream`]. - pub fn fetch_stream(&self) -> Result { - fetch_stream(self) - } -} - -/// A builder for an [`HttpRequest`]. -#[derive(Clone)] -pub struct HttpRequestBuilder { - method: Option, - url: Option, - headers: Vec<(String, String)>, - body: Option>, - redirect_policy: RedirectPolicy, -} - -impl Default for HttpRequestBuilder { - fn default() -> Self { - Self::new() - } -} - -impl HttpRequestBuilder { - /// Returns a new [`HttpRequestBuilder`]. - pub fn new() -> Self { - HttpRequestBuilder { - method: None, - url: None, - headers: Vec::new(), - body: None, - redirect_policy: RedirectPolicy::NoFollow, - } - } - - /// Sets the HTTP method for the request. - pub fn method(mut self, method: HttpMethod) -> Self { - self.method = Some(method); - self - } - - /// Sets the URL for the request. - pub fn url(mut self, url: impl Into) -> Self { - self.url = Some(url.into()); - self - } - - /// Adds a header to the request. - pub fn header(mut self, name: impl Into, value: impl Into) -> Self { - self.headers.push((name.into(), value.into())); - self - } - - /// Adds the specified headers to the request. - pub fn headers(mut self, headers: impl IntoIterator) -> Self { - self.headers.extend(headers); - self - } - - /// Sets the body of the request. - pub fn body(mut self, body: impl Into>) -> Self { - self.body = Some(body.into()); - self - } - - /// Sets the redirect policy for the request. - pub fn redirect_policy(mut self, policy: RedirectPolicy) -> Self { - self.redirect_policy = policy; - self - } - - /// Builds the [`HttpRequest`]. - pub fn build(self) -> Result { - let method = self.method.ok_or_else(|| "Method not set".to_string())?; - let url = self.url.ok_or_else(|| "URL not set".to_string())?; - - Ok(HttpRequest { - method, - url, - headers: self.headers, - body: self.body, - redirect_policy: self.redirect_policy, - }) - } -} diff --git a/crates/extension_api/src/process.rs b/crates/extension_api/src/process.rs deleted file mode 100644 index 1068fd9c17..0000000000 --- a/crates/extension_api/src/process.rs +++ /dev/null @@ -1,44 +0,0 @@ -//! A module for working with processes. - -use crate::wit::zed::extension::process; -pub use crate::wit::zed::extension::process::{Command, Output}; - -impl Command { - pub fn new(program: impl Into) -> Self { - Self { - command: program.into(), - args: Vec::new(), - env: Vec::new(), - } - } - - pub fn arg(mut self, arg: impl Into) -> Self { - self.args.push(arg.into()); - self - } - - pub fn args(mut self, args: impl IntoIterator>) -> Self { - self.args.extend(args.into_iter().map(Into::into)); - self - } - - pub fn env(mut self, key: impl Into, value: impl Into) -> Self { - self.env.push((key.into(), value.into())); - self - } - - pub fn envs( - mut self, - envs: impl IntoIterator, impl Into)>, - ) -> Self { - self.env.extend( - envs.into_iter() - .map(|(key, value)| (key.into(), value.into())), - ); - self - } - - pub fn output(&mut self) -> Result { - process::run_command(self) - } -} diff --git a/crates/extension_api/src/settings.rs b/crates/extension_api/src/settings.rs deleted file mode 100644 index a133a8027a..0000000000 --- a/crates/extension_api/src/settings.rs +++ /dev/null @@ -1,56 +0,0 @@ -//! Provides access to Zed settings. - -#[path = "../wit/since_v0.2.0/settings.rs"] -mod types; - -use crate::{Project, Result, SettingsLocation, Worktree, wit}; -use serde_json; -pub use types::*; - -impl LanguageSettings { - /// Returns the [`LanguageSettings`] for the given language. - pub fn for_worktree(language: Option<&str>, worktree: &Worktree) -> Result { - get_settings("language", language, Some(worktree.id())) - } -} - -impl LspSettings { - /// Returns the [`LspSettings`] for the given language server. - pub fn for_worktree(language_server_name: &str, worktree: &Worktree) -> Result { - get_settings("lsp", Some(language_server_name), Some(worktree.id())) - } -} - -impl ContextServerSettings { - /// Returns the [`ContextServerSettings`] for the given context server. - pub fn for_project(context_server_id: &str, project: &Project) -> Result { - let global_setting: Self = get_settings("context_servers", Some(context_server_id), None)?; - - for worktree_id in project.worktree_ids() { - let settings = get_settings( - "context_servers", - Some(context_server_id), - Some(worktree_id), - )?; - if settings != global_setting { - return Ok(settings); - } - } - - Ok(global_setting) - } -} - -fn get_settings( - settings_type: &str, - settings_name: Option<&str>, - worktree_id: Option, -) -> Result { - let location = worktree_id.map(|worktree_id| SettingsLocation { - worktree_id, - path: String::new(), - }); - let settings_json = wit::get_settings(location.as_ref(), settings_type, settings_name)?; - let settings: T = serde_json::from_str(&settings_json).map_err(|err| err.to_string())?; - Ok(settings) -} diff --git a/crates/extension_api/wit/since_v0.0.1/extension.wit b/crates/extension_api/wit/since_v0.0.1/extension.wit deleted file mode 100644 index 339a974169..0000000000 --- a/crates/extension_api/wit/since_v0.0.1/extension.wit +++ /dev/null @@ -1,70 +0,0 @@ -package zed:extension; - -world extension { - use github.{github-release, github-release-options}; - use platform.{os, architecture}; - - export init-extension: func(); - - enum downloaded-file-type { - gzip, - gzip-tar, - zip, - uncompressed, - } - - variant language-server-installation-status { - checking-for-update, - downloaded, - downloading, - cached, - failed(string), - } - - /// Gets the current operating system and architecture - import current-platform: func() -> tuple; - - /// Get the path to the node binary used by Zed. - import node-binary-path: func() -> result; - - /// Gets the latest version of the given NPM package. - import npm-package-latest-version: func(package-name: string) -> result; - - /// Returns the installed version of the given NPM package, if it exists. - import npm-package-installed-version: func(package-name: string) -> result, string>; - - /// Installs the specified NPM package. - import npm-install-package: func(package-name: string, version: string) -> result<_, string>; - - /// Gets the latest release for the given GitHub repository. - import latest-github-release: func(repo: string, options: github-release-options) -> result; - - /// Downloads a file from the given url, and saves it to the given filename within the extension's - /// working directory. Extracts the file according to the given file type. - import download-file: func(url: string, output-filename: string, file-type: downloaded-file-type) -> result<_, string>; - - /// Updates the installation status for the given language server. - import set-language-server-installation-status: func(language-server-name: string, status: language-server-installation-status); - - type env-vars = list>; - - record command { - command: string, - args: list, - env: env-vars, - } - - resource worktree { - read-text-file: func(path: string) -> result; - which: func(binary-name: string) -> option; - shell-env: func() -> env-vars; - } - - record language-server-config { - name: string, - language-name: string, - } - - export language-server-command: func(config: language-server-config, worktree: borrow) -> result; - export language-server-initialization-options: func(config: language-server-config, worktree: borrow) -> result, string>; -} diff --git a/crates/extension_api/wit/since_v0.0.1/github.wit b/crates/extension_api/wit/since_v0.0.1/github.wit deleted file mode 100644 index 53ecacb720..0000000000 --- a/crates/extension_api/wit/since_v0.0.1/github.wit +++ /dev/null @@ -1,28 +0,0 @@ -interface github { - /// A GitHub release. - record github-release { - /// The version of the release. - version: string, - /// The list of assets attached to the release. - assets: list, - } - - /// An asset from a GitHub release. - record github-release-asset { - /// The name of the asset. - name: string, - /// The download URL for the asset. - download-url: string, - } - - /// The options used to filter down GitHub releases. - record github-release-options { - /// Whether releases without assets should be included. - require-assets: bool, - /// Whether pre-releases should be included. - pre-release: bool, - } - - /// Returns the latest release for the given GitHub repository. - latest-github-release: func(repo: string, options: github-release-options) -> result; -} diff --git a/crates/extension_api/wit/since_v0.0.1/platform.wit b/crates/extension_api/wit/since_v0.0.1/platform.wit deleted file mode 100644 index 48472a99bc..0000000000 --- a/crates/extension_api/wit/since_v0.0.1/platform.wit +++ /dev/null @@ -1,24 +0,0 @@ -interface platform { - /// An operating system. - enum os { - /// macOS. - mac, - /// Linux. - linux, - /// Windows. - windows, - } - - /// A platform architecture. - enum architecture { - /// AArch64 (e.g., Apple Silicon). - aarch64, - /// x86. - x86, - /// x86-64. - x8664, - } - - /// Gets the current operating system and architecture. - current-platform: func() -> tuple; -} diff --git a/crates/extension_api/wit/since_v0.0.4/extension.wit b/crates/extension_api/wit/since_v0.0.4/extension.wit deleted file mode 100644 index c6f3e73506..0000000000 --- a/crates/extension_api/wit/since_v0.0.4/extension.wit +++ /dev/null @@ -1,72 +0,0 @@ -package zed:extension; - -world extension { - use github.{github-release, github-release-options}; - use platform.{os, architecture}; - - export init-extension: func(); - - enum downloaded-file-type { - gzip, - gzip-tar, - zip, - uncompressed, - } - - variant language-server-installation-status { - none, - downloading, - checking-for-update, - failed(string), - } - - /// Gets the current operating system and architecture - import current-platform: func() -> tuple; - - /// Get the path to the node binary used by Zed. - import node-binary-path: func() -> result; - - /// Gets the latest version of the given NPM package. - import npm-package-latest-version: func(package-name: string) -> result; - - /// Returns the installed version of the given NPM package, if it exists. - import npm-package-installed-version: func(package-name: string) -> result, string>; - - /// Installs the specified NPM package. - import npm-install-package: func(package-name: string, version: string) -> result<_, string>; - - /// Gets the latest release for the given GitHub repository. - import latest-github-release: func(repo: string, options: github-release-options) -> result; - - /// Downloads a file from the given url, and saves it to the given path within the extension's - /// working directory. Extracts the file according to the given file type. - import download-file: func(url: string, file-path: string, file-type: downloaded-file-type) -> result<_, string>; - - /// Makes the file at the given path executable. - import make-file-executable: func(filepath: string) -> result<_, string>; - - /// Updates the installation status for the given language server. - import set-language-server-installation-status: func(language-server-name: string, status: language-server-installation-status); - - type env-vars = list>; - - record command { - command: string, - args: list, - env: env-vars, - } - - resource worktree { - read-text-file: func(path: string) -> result; - which: func(binary-name: string) -> option; - shell-env: func() -> env-vars; - } - - record language-server-config { - name: string, - language-name: string, - } - - export language-server-command: func(config: language-server-config, worktree: borrow) -> result; - export language-server-initialization-options: func(config: language-server-config, worktree: borrow) -> result, string>; -} diff --git a/crates/extension_api/wit/since_v0.0.4/github.wit b/crates/extension_api/wit/since_v0.0.4/github.wit deleted file mode 100644 index 53ecacb720..0000000000 --- a/crates/extension_api/wit/since_v0.0.4/github.wit +++ /dev/null @@ -1,28 +0,0 @@ -interface github { - /// A GitHub release. - record github-release { - /// The version of the release. - version: string, - /// The list of assets attached to the release. - assets: list, - } - - /// An asset from a GitHub release. - record github-release-asset { - /// The name of the asset. - name: string, - /// The download URL for the asset. - download-url: string, - } - - /// The options used to filter down GitHub releases. - record github-release-options { - /// Whether releases without assets should be included. - require-assets: bool, - /// Whether pre-releases should be included. - pre-release: bool, - } - - /// Returns the latest release for the given GitHub repository. - latest-github-release: func(repo: string, options: github-release-options) -> result; -} diff --git a/crates/extension_api/wit/since_v0.0.4/platform.wit b/crates/extension_api/wit/since_v0.0.4/platform.wit deleted file mode 100644 index 48472a99bc..0000000000 --- a/crates/extension_api/wit/since_v0.0.4/platform.wit +++ /dev/null @@ -1,24 +0,0 @@ -interface platform { - /// An operating system. - enum os { - /// macOS. - mac, - /// Linux. - linux, - /// Windows. - windows, - } - - /// A platform architecture. - enum architecture { - /// AArch64 (e.g., Apple Silicon). - aarch64, - /// x86. - x86, - /// x86-64. - x8664, - } - - /// Gets the current operating system and architecture. - current-platform: func() -> tuple; -} diff --git a/crates/extension_api/wit/since_v0.0.6/extension.wit b/crates/extension_api/wit/since_v0.0.6/extension.wit deleted file mode 100644 index 2f42cc0365..0000000000 --- a/crates/extension_api/wit/since_v0.0.6/extension.wit +++ /dev/null @@ -1,130 +0,0 @@ -package zed:extension; - -world extension { - import github; - import platform; - import nodejs; - - use lsp.{completion, symbol}; - - /// Initializes the extension. - export init-extension: func(); - - /// The type of a downloaded file. - enum downloaded-file-type { - /// A gzipped file (`.gz`). - gzip, - /// A gzipped tar archive (`.tar.gz`). - gzip-tar, - /// A ZIP file (`.zip`). - zip, - /// An uncompressed file. - uncompressed, - } - - /// The installation status for a language server. - variant language-server-installation-status { - /// The language server has no installation status. - none, - /// The language server is being downloaded. - downloading, - /// The language server is checking for updates. - checking-for-update, - /// The language server installation failed for specified reason. - failed(string), - } - - record settings-location { - worktree-id: u64, - path: string, - } - - import get-settings: func(path: option, category: string, key: option) -> result; - - /// Downloads a file from the given URL and saves it to the given path within the extension's - /// working directory. - /// - /// The file will be extracted according to the given file type. - import download-file: func(url: string, file-path: string, file-type: downloaded-file-type) -> result<_, string>; - - /// Makes the file at the given path executable. - import make-file-executable: func(filepath: string) -> result<_, string>; - - /// Updates the installation status for the given language server. - import set-language-server-installation-status: func(language-server-name: string, status: language-server-installation-status); - - /// A list of environment variables. - type env-vars = list>; - - /// A command. - record command { - /// The command to execute. - command: string, - /// The arguments to pass to the command. - args: list, - /// The environment variables to set for the command. - env: env-vars, - } - - /// A Zed worktree. - resource worktree { - /// Returns the ID of the worktree. - id: func() -> u64; - /// Returns the root path of the worktree. - root-path: func() -> string; - /// Returns the textual contents of the specified file in the worktree. - read-text-file: func(path: string) -> result; - /// Returns the path to the given binary name, if one is present on the `$PATH`. - which: func(binary-name: string) -> option; - /// Returns the current shell environment. - shell-env: func() -> env-vars; - } - - /// Returns the command used to start up the language server. - export language-server-command: func(language-server-id: string, worktree: borrow) -> result; - - /// Returns the initialization options to pass to the language server on startup. - /// - /// The initialization options are represented as a JSON string. - export language-server-initialization-options: func(language-server-id: string, worktree: borrow) -> result, string>; - - /// Returns the workspace configuration options to pass to the language server. - export language-server-workspace-configuration: func(language-server-id: string, worktree: borrow) -> result, string>; - - /// A label containing some code. - record code-label { - /// The source code to parse with Tree-sitter. - code: string, - /// The spans to display in the label. - spans: list, - /// The range of the displayed label to include when filtering. - filter-range: range, - } - - /// A span within a code label. - variant code-label-span { - /// A range into the parsed code. - code-range(range), - /// A span containing a code literal. - literal(code-label-span-literal), - } - - /// A span containing a code literal. - record code-label-span-literal { - /// The literal text. - text: string, - /// The name of the highlight to use for this literal. - highlight-name: option, - } - - /// A (half-open) range (`[start, end)`). - record range { - /// The start of the range (inclusive). - start: u32, - /// The end of the range (exclusive). - end: u32, - } - - export labels-for-completions: func(language-server-id: string, completions: list) -> result>, string>; - export labels-for-symbols: func(language-server-id: string, symbols: list) -> result>, string>; -} diff --git a/crates/extension_api/wit/since_v0.0.6/github.wit b/crates/extension_api/wit/since_v0.0.6/github.wit deleted file mode 100644 index 53ecacb720..0000000000 --- a/crates/extension_api/wit/since_v0.0.6/github.wit +++ /dev/null @@ -1,28 +0,0 @@ -interface github { - /// A GitHub release. - record github-release { - /// The version of the release. - version: string, - /// The list of assets attached to the release. - assets: list, - } - - /// An asset from a GitHub release. - record github-release-asset { - /// The name of the asset. - name: string, - /// The download URL for the asset. - download-url: string, - } - - /// The options used to filter down GitHub releases. - record github-release-options { - /// Whether releases without assets should be included. - require-assets: bool, - /// Whether pre-releases should be included. - pre-release: bool, - } - - /// Returns the latest release for the given GitHub repository. - latest-github-release: func(repo: string, options: github-release-options) -> result; -} diff --git a/crates/extension_api/wit/since_v0.0.6/lsp.wit b/crates/extension_api/wit/since_v0.0.6/lsp.wit deleted file mode 100644 index 19e81b6b14..0000000000 --- a/crates/extension_api/wit/since_v0.0.6/lsp.wit +++ /dev/null @@ -1,83 +0,0 @@ -interface lsp { - /// An LSP completion. - record completion { - label: string, - detail: option, - kind: option, - insert-text-format: option, - } - - /// The kind of an LSP completion. - variant completion-kind { - text, - method, - function, - %constructor, - field, - variable, - class, - %interface, - module, - property, - unit, - value, - %enum, - keyword, - snippet, - color, - file, - reference, - folder, - enum-member, - constant, - struct, - event, - operator, - type-parameter, - other(s32), - } - - /// Defines how to interpret the insert text in a completion item. - variant insert-text-format { - plain-text, - snippet, - other(s32), - } - - /// An LSP symbol. - record symbol { - kind: symbol-kind, - name: string, - } - - /// The kind of an LSP symbol. - variant symbol-kind { - file, - module, - namespace, - %package, - class, - method, - property, - field, - %constructor, - %enum, - %interface, - function, - variable, - constant, - %string, - number, - boolean, - array, - object, - key, - null, - enum-member, - struct, - event, - operator, - type-parameter, - other(s32), - } -} diff --git a/crates/extension_api/wit/since_v0.0.6/nodejs.wit b/crates/extension_api/wit/since_v0.0.6/nodejs.wit deleted file mode 100644 index c814548314..0000000000 --- a/crates/extension_api/wit/since_v0.0.6/nodejs.wit +++ /dev/null @@ -1,13 +0,0 @@ -interface nodejs { - /// Returns the path to the Node binary used by Zed. - node-binary-path: func() -> result; - - /// Returns the latest version of the given NPM package. - npm-package-latest-version: func(package-name: string) -> result; - - /// Returns the installed version of the given NPM package, if it exists. - npm-package-installed-version: func(package-name: string) -> result, string>; - - /// Installs the specified NPM package. - npm-install-package: func(package-name: string, version: string) -> result<_, string>; -} diff --git a/crates/extension_api/wit/since_v0.0.6/platform.wit b/crates/extension_api/wit/since_v0.0.6/platform.wit deleted file mode 100644 index 48472a99bc..0000000000 --- a/crates/extension_api/wit/since_v0.0.6/platform.wit +++ /dev/null @@ -1,24 +0,0 @@ -interface platform { - /// An operating system. - enum os { - /// macOS. - mac, - /// Linux. - linux, - /// Windows. - windows, - } - - /// A platform architecture. - enum architecture { - /// AArch64 (e.g., Apple Silicon). - aarch64, - /// x86. - x86, - /// x86-64. - x8664, - } - - /// Gets the current operating system and architecture. - current-platform: func() -> tuple; -} diff --git a/crates/extension_api/wit/since_v0.0.6/settings.rs b/crates/extension_api/wit/since_v0.0.6/settings.rs deleted file mode 100644 index 5c6cae7064..0000000000 --- a/crates/extension_api/wit/since_v0.0.6/settings.rs +++ /dev/null @@ -1,29 +0,0 @@ -use serde::{Deserialize, Serialize}; -use std::num::NonZeroU32; - -/// The settings for a particular language. -#[derive(Debug, Serialize, Deserialize)] -pub struct LanguageSettings { - /// How many columns a tab should occupy. - pub tab_size: NonZeroU32, -} - -/// The settings for a particular language server. -#[derive(Default, Debug, Serialize, Deserialize)] -pub struct LspSettings { - /// The settings for the language server binary. - pub binary: Option, - /// The initialization options to pass to the language server. - pub initialization_options: Option, - /// The settings to pass to language server. - pub settings: Option, -} - -/// The settings for a language server binary. -#[derive(Debug, Serialize, Deserialize)] -pub struct BinarySettings { - /// The path to the binary. - pub path: Option, - /// The arguments to pass to the binary. - pub arguments: Option>, -} diff --git a/crates/extension_api/wit/since_v0.1.0/common.wit b/crates/extension_api/wit/since_v0.1.0/common.wit deleted file mode 100644 index c4f321f4c7..0000000000 --- a/crates/extension_api/wit/since_v0.1.0/common.wit +++ /dev/null @@ -1,9 +0,0 @@ -interface common { - /// A (half-open) range (`[start, end)`). - record range { - /// The start of the range (inclusive). - start: u32, - /// The end of the range (exclusive). - end: u32, - } -} diff --git a/crates/extension_api/wit/since_v0.1.0/extension.wit b/crates/extension_api/wit/since_v0.1.0/extension.wit deleted file mode 100644 index c7599f93ff..0000000000 --- a/crates/extension_api/wit/since_v0.1.0/extension.wit +++ /dev/null @@ -1,147 +0,0 @@ -package zed:extension; - -world extension { - import github; - import http-client; - import platform; - import nodejs; - - use common.{range}; - use lsp.{completion, symbol}; - use slash-command.{slash-command, slash-command-argument-completion, slash-command-output}; - - /// Initializes the extension. - export init-extension: func(); - - /// The type of a downloaded file. - enum downloaded-file-type { - /// A gzipped file (`.gz`). - gzip, - /// A gzipped tar archive (`.tar.gz`). - gzip-tar, - /// A ZIP file (`.zip`). - zip, - /// An uncompressed file. - uncompressed, - } - - /// The installation status for a language server. - variant language-server-installation-status { - /// The language server has no installation status. - none, - /// The language server is being downloaded. - downloading, - /// The language server is checking for updates. - checking-for-update, - /// The language server installation failed for specified reason. - failed(string), - } - - record settings-location { - worktree-id: u64, - path: string, - } - - import get-settings: func(path: option, category: string, key: option) -> result; - - /// Downloads a file from the given URL and saves it to the given path within the extension's - /// working directory. - /// - /// The file will be extracted according to the given file type. - import download-file: func(url: string, file-path: string, file-type: downloaded-file-type) -> result<_, string>; - - /// Makes the file at the given path executable. - import make-file-executable: func(filepath: string) -> result<_, string>; - - /// Updates the installation status for the given language server. - import set-language-server-installation-status: func(language-server-name: string, status: language-server-installation-status); - - /// A list of environment variables. - type env-vars = list>; - - /// A command. - record command { - /// The command to execute. - command: string, - /// The arguments to pass to the command. - args: list, - /// The environment variables to set for the command. - env: env-vars, - } - - /// A Zed worktree. - resource worktree { - /// Returns the ID of the worktree. - id: func() -> u64; - /// Returns the root path of the worktree. - root-path: func() -> string; - /// Returns the textual contents of the specified file in the worktree. - read-text-file: func(path: string) -> result; - /// Returns the path to the given binary name, if one is present on the `$PATH`. - which: func(binary-name: string) -> option; - /// Returns the current shell environment. - shell-env: func() -> env-vars; - } - - /// A key-value store. - resource key-value-store { - /// Inserts an entry under the specified key. - insert: func(key: string, value: string) -> result<_, string>; - } - - /// Returns the command used to start up the language server. - export language-server-command: func(language-server-id: string, worktree: borrow) -> result; - - /// Returns the initialization options to pass to the language server on startup. - /// - /// The initialization options are represented as a JSON string. - export language-server-initialization-options: func(language-server-id: string, worktree: borrow) -> result, string>; - - /// Returns the workspace configuration options to pass to the language server. - export language-server-workspace-configuration: func(language-server-id: string, worktree: borrow) -> result, string>; - - /// A label containing some code. - record code-label { - /// The source code to parse with Tree-sitter. - code: string, - /// The spans to display in the label. - spans: list, - /// The range of the displayed label to include when filtering. - filter-range: range, - } - - /// A span within a code label. - variant code-label-span { - /// A range into the parsed code. - code-range(range), - /// A span containing a code literal. - literal(code-label-span-literal), - } - - /// A span containing a code literal. - record code-label-span-literal { - /// The literal text. - text: string, - /// The name of the highlight to use for this literal. - highlight-name: option, - } - - export labels-for-completions: func(language-server-id: string, completions: list) -> result>, string>; - export labels-for-symbols: func(language-server-id: string, symbols: list) -> result>, string>; - - /// Returns the completions that should be shown when completing the provided slash command with the given query. - export complete-slash-command-argument: func(command: slash-command, args: list) -> result, string>; - - /// Returns the output from running the provided slash command. - export run-slash-command: func(command: slash-command, args: list, worktree: option>) -> result; - - /// Returns a list of packages as suggestions to be included in the `/docs` - /// search results. - /// - /// This can be used to provide completions for known packages (e.g., from the - /// local project or a registry) before a package has been indexed. - export suggest-docs-packages: func(provider-name: string) -> result, string>; - - /// Indexes the docs for the specified package. - export index-docs: func(provider-name: string, package-name: string, database: borrow) -> result<_, string>; -} diff --git a/crates/extension_api/wit/since_v0.1.0/github.wit b/crates/extension_api/wit/since_v0.1.0/github.wit deleted file mode 100644 index bb138f5d31..0000000000 --- a/crates/extension_api/wit/since_v0.1.0/github.wit +++ /dev/null @@ -1,33 +0,0 @@ -interface github { - /// A GitHub release. - record github-release { - /// The version of the release. - version: string, - /// The list of assets attached to the release. - assets: list, - } - - /// An asset from a GitHub release. - record github-release-asset { - /// The name of the asset. - name: string, - /// The download URL for the asset. - download-url: string, - } - - /// The options used to filter down GitHub releases. - record github-release-options { - /// Whether releases without assets should be included. - require-assets: bool, - /// Whether pre-releases should be included. - pre-release: bool, - } - - /// Returns the latest release for the given GitHub repository. - latest-github-release: func(repo: string, options: github-release-options) -> result; - - /// Returns the GitHub release with the specified tag name for the given GitHub repository. - /// - /// Returns an error if a release with the given tag name does not exist. - github-release-by-tag-name: func(repo: string, tag: string) -> result; -} diff --git a/crates/extension_api/wit/since_v0.1.0/http-client.wit b/crates/extension_api/wit/since_v0.1.0/http-client.wit deleted file mode 100644 index bb0206c17a..0000000000 --- a/crates/extension_api/wit/since_v0.1.0/http-client.wit +++ /dev/null @@ -1,67 +0,0 @@ -interface http-client { - /// An HTTP request. - record http-request { - /// The HTTP method for the request. - method: http-method, - /// The URL to which the request should be made. - url: string, - /// The headers for the request. - headers: list>, - /// The request body. - body: option>, - /// The policy to use for redirects. - redirect-policy: redirect-policy, - } - - /// HTTP methods. - enum http-method { - /// `GET` - get, - /// `HEAD` - head, - /// `POST` - post, - /// `PUT` - put, - /// `DELETE` - delete, - /// `OPTIONS` - options, - /// `PATCH` - patch, - } - - /// The policy for dealing with redirects received from the server. - variant redirect-policy { - /// Redirects from the server will not be followed. - /// - /// This is the default behavior. - no-follow, - /// Redirects from the server will be followed up to the specified limit. - follow-limit(u32), - /// All redirects from the server will be followed. - follow-all, - } - - /// An HTTP response. - record http-response { - /// The response headers. - headers: list>, - /// The response body. - body: list, - } - - /// Performs an HTTP request and returns the response. - fetch: func(req: http-request) -> result; - - /// An HTTP response stream. - resource http-response-stream { - /// Retrieves the next chunk of data from the response stream. - /// - /// Returns `Ok(None)` if the stream has ended. - next-chunk: func() -> result>, string>; - } - - /// Performs an HTTP request and returns a response stream. - fetch-stream: func(req: http-request) -> result; -} diff --git a/crates/extension_api/wit/since_v0.1.0/lsp.wit b/crates/extension_api/wit/since_v0.1.0/lsp.wit deleted file mode 100644 index 19e81b6b14..0000000000 --- a/crates/extension_api/wit/since_v0.1.0/lsp.wit +++ /dev/null @@ -1,83 +0,0 @@ -interface lsp { - /// An LSP completion. - record completion { - label: string, - detail: option, - kind: option, - insert-text-format: option, - } - - /// The kind of an LSP completion. - variant completion-kind { - text, - method, - function, - %constructor, - field, - variable, - class, - %interface, - module, - property, - unit, - value, - %enum, - keyword, - snippet, - color, - file, - reference, - folder, - enum-member, - constant, - struct, - event, - operator, - type-parameter, - other(s32), - } - - /// Defines how to interpret the insert text in a completion item. - variant insert-text-format { - plain-text, - snippet, - other(s32), - } - - /// An LSP symbol. - record symbol { - kind: symbol-kind, - name: string, - } - - /// The kind of an LSP symbol. - variant symbol-kind { - file, - module, - namespace, - %package, - class, - method, - property, - field, - %constructor, - %enum, - %interface, - function, - variable, - constant, - %string, - number, - boolean, - array, - object, - key, - null, - enum-member, - struct, - event, - operator, - type-parameter, - other(s32), - } -} diff --git a/crates/extension_api/wit/since_v0.1.0/nodejs.wit b/crates/extension_api/wit/since_v0.1.0/nodejs.wit deleted file mode 100644 index c814548314..0000000000 --- a/crates/extension_api/wit/since_v0.1.0/nodejs.wit +++ /dev/null @@ -1,13 +0,0 @@ -interface nodejs { - /// Returns the path to the Node binary used by Zed. - node-binary-path: func() -> result; - - /// Returns the latest version of the given NPM package. - npm-package-latest-version: func(package-name: string) -> result; - - /// Returns the installed version of the given NPM package, if it exists. - npm-package-installed-version: func(package-name: string) -> result, string>; - - /// Installs the specified NPM package. - npm-install-package: func(package-name: string, version: string) -> result<_, string>; -} diff --git a/crates/extension_api/wit/since_v0.1.0/platform.wit b/crates/extension_api/wit/since_v0.1.0/platform.wit deleted file mode 100644 index 48472a99bc..0000000000 --- a/crates/extension_api/wit/since_v0.1.0/platform.wit +++ /dev/null @@ -1,24 +0,0 @@ -interface platform { - /// An operating system. - enum os { - /// macOS. - mac, - /// Linux. - linux, - /// Windows. - windows, - } - - /// A platform architecture. - enum architecture { - /// AArch64 (e.g., Apple Silicon). - aarch64, - /// x86. - x86, - /// x86-64. - x8664, - } - - /// Gets the current operating system and architecture. - current-platform: func() -> tuple; -} diff --git a/crates/extension_api/wit/since_v0.1.0/settings.rs b/crates/extension_api/wit/since_v0.1.0/settings.rs deleted file mode 100644 index 5c6cae7064..0000000000 --- a/crates/extension_api/wit/since_v0.1.0/settings.rs +++ /dev/null @@ -1,29 +0,0 @@ -use serde::{Deserialize, Serialize}; -use std::num::NonZeroU32; - -/// The settings for a particular language. -#[derive(Debug, Serialize, Deserialize)] -pub struct LanguageSettings { - /// How many columns a tab should occupy. - pub tab_size: NonZeroU32, -} - -/// The settings for a particular language server. -#[derive(Default, Debug, Serialize, Deserialize)] -pub struct LspSettings { - /// The settings for the language server binary. - pub binary: Option, - /// The initialization options to pass to the language server. - pub initialization_options: Option, - /// The settings to pass to language server. - pub settings: Option, -} - -/// The settings for a language server binary. -#[derive(Debug, Serialize, Deserialize)] -pub struct BinarySettings { - /// The path to the binary. - pub path: Option, - /// The arguments to pass to the binary. - pub arguments: Option>, -} diff --git a/crates/extension_api/wit/since_v0.1.0/slash-command.wit b/crates/extension_api/wit/since_v0.1.0/slash-command.wit deleted file mode 100644 index f52561c2ef..0000000000 --- a/crates/extension_api/wit/since_v0.1.0/slash-command.wit +++ /dev/null @@ -1,41 +0,0 @@ -interface slash-command { - use common.{range}; - - /// A slash command for use in the Assistant. - record slash-command { - /// The name of the slash command. - name: string, - /// The description of the slash command. - description: string, - /// The tooltip text to display for the run button. - tooltip-text: string, - /// Whether this slash command requires an argument. - requires-argument: bool, - } - - /// The output of a slash command. - record slash-command-output { - /// The text produced by the slash command. - text: string, - /// The list of sections to show in the slash command placeholder. - sections: list, - } - - /// A section in the slash command output. - record slash-command-output-section { - /// The range this section occupies. - range: range, - /// The label to display in the placeholder for this section. - label: string, - } - - /// A completion for a slash command argument. - record slash-command-argument-completion { - /// The label to display for this completion. - label: string, - /// The new text that should be inserted into the command when this completion is accepted. - new-text: string, - /// Whether the command should be run when accepting this completion. - run-command: bool, - } -} diff --git a/crates/extension_api/wit/since_v0.2.0/common.wit b/crates/extension_api/wit/since_v0.2.0/common.wit deleted file mode 100644 index c4f321f4c7..0000000000 --- a/crates/extension_api/wit/since_v0.2.0/common.wit +++ /dev/null @@ -1,9 +0,0 @@ -interface common { - /// A (half-open) range (`[start, end)`). - record range { - /// The start of the range (inclusive). - start: u32, - /// The end of the range (exclusive). - end: u32, - } -} diff --git a/crates/extension_api/wit/since_v0.2.0/extension.wit b/crates/extension_api/wit/since_v0.2.0/extension.wit deleted file mode 100644 index 3e54c5be89..0000000000 --- a/crates/extension_api/wit/since_v0.2.0/extension.wit +++ /dev/null @@ -1,156 +0,0 @@ -package zed:extension; - -world extension { - import github; - import http-client; - import platform; - import nodejs; - - use common.{range}; - use lsp.{completion, symbol}; - use slash-command.{slash-command, slash-command-argument-completion, slash-command-output}; - - /// Initializes the extension. - export init-extension: func(); - - /// The type of a downloaded file. - enum downloaded-file-type { - /// A gzipped file (`.gz`). - gzip, - /// A gzipped tar archive (`.tar.gz`). - gzip-tar, - /// A ZIP file (`.zip`). - zip, - /// An uncompressed file. - uncompressed, - } - - /// The installation status for a language server. - variant language-server-installation-status { - /// The language server has no installation status. - none, - /// The language server is being downloaded. - downloading, - /// The language server is checking for updates. - checking-for-update, - /// The language server installation failed for specified reason. - failed(string), - } - - record settings-location { - worktree-id: u64, - path: string, - } - - import get-settings: func(path: option, category: string, key: option) -> result; - - /// Downloads a file from the given URL and saves it to the given path within the extension's - /// working directory. - /// - /// The file will be extracted according to the given file type. - import download-file: func(url: string, file-path: string, file-type: downloaded-file-type) -> result<_, string>; - - /// Makes the file at the given path executable. - import make-file-executable: func(filepath: string) -> result<_, string>; - - /// Updates the installation status for the given language server. - import set-language-server-installation-status: func(language-server-name: string, status: language-server-installation-status); - - /// A list of environment variables. - type env-vars = list>; - - /// A command. - record command { - /// The command to execute. - command: string, - /// The arguments to pass to the command. - args: list, - /// The environment variables to set for the command. - env: env-vars, - } - - /// A Zed worktree. - resource worktree { - /// Returns the ID of the worktree. - id: func() -> u64; - /// Returns the root path of the worktree. - root-path: func() -> string; - /// Returns the textual contents of the specified file in the worktree. - read-text-file: func(path: string) -> result; - /// Returns the path to the given binary name, if one is present on the `$PATH`. - which: func(binary-name: string) -> option; - /// Returns the current shell environment. - shell-env: func() -> env-vars; - } - - /// A Zed project. - resource project { - /// Returns the IDs of all of the worktrees in this project. - worktree-ids: func() -> list; - } - - /// A key-value store. - resource key-value-store { - /// Inserts an entry under the specified key. - insert: func(key: string, value: string) -> result<_, string>; - } - - /// Returns the command used to start up the language server. - export language-server-command: func(language-server-id: string, worktree: borrow) -> result; - - /// Returns the initialization options to pass to the language server on startup. - /// - /// The initialization options are represented as a JSON string. - export language-server-initialization-options: func(language-server-id: string, worktree: borrow) -> result, string>; - - /// Returns the workspace configuration options to pass to the language server. - export language-server-workspace-configuration: func(language-server-id: string, worktree: borrow) -> result, string>; - - /// A label containing some code. - record code-label { - /// The source code to parse with Tree-sitter. - code: string, - /// The spans to display in the label. - spans: list, - /// The range of the displayed label to include when filtering. - filter-range: range, - } - - /// A span within a code label. - variant code-label-span { - /// A range into the parsed code. - code-range(range), - /// A span containing a code literal. - literal(code-label-span-literal), - } - - /// A span containing a code literal. - record code-label-span-literal { - /// The literal text. - text: string, - /// The name of the highlight to use for this literal. - highlight-name: option, - } - - export labels-for-completions: func(language-server-id: string, completions: list) -> result>, string>; - export labels-for-symbols: func(language-server-id: string, symbols: list) -> result>, string>; - - /// Returns the completions that should be shown when completing the provided slash command with the given query. - export complete-slash-command-argument: func(command: slash-command, args: list) -> result, string>; - - /// Returns the output from running the provided slash command. - export run-slash-command: func(command: slash-command, args: list, worktree: option>) -> result; - - /// Returns the command used to start up a context server. - export context-server-command: func(context-server-id: string, project: borrow) -> result; - - /// Returns a list of packages as suggestions to be included in the `/docs` - /// search results. - /// - /// This can be used to provide completions for known packages (e.g., from the - /// local project or a registry) before a package has been indexed. - export suggest-docs-packages: func(provider-name: string) -> result, string>; - - /// Indexes the docs for the specified package. - export index-docs: func(provider-name: string, package-name: string, database: borrow) -> result<_, string>; -} diff --git a/crates/extension_api/wit/since_v0.2.0/github.wit b/crates/extension_api/wit/since_v0.2.0/github.wit deleted file mode 100644 index 21cd5d4805..0000000000 --- a/crates/extension_api/wit/since_v0.2.0/github.wit +++ /dev/null @@ -1,35 +0,0 @@ -interface github { - /// A GitHub release. - record github-release { - /// The version of the release. - version: string, - /// The list of assets attached to the release. - assets: list, - } - - /// An asset from a GitHub release. - record github-release-asset { - /// The name of the asset. - name: string, - /// The download URL for the asset. - download-url: string, - } - - /// The options used to filter down GitHub releases. - record github-release-options { - /// Whether releases without assets should be included. - require-assets: bool, - /// Whether pre-releases should be included. - pre-release: bool, - } - - /// Returns the latest release for the given GitHub repository. - /// - /// Takes repo as a string in the form "/", for example: "zed-industries/zed". - latest-github-release: func(repo: string, options: github-release-options) -> result; - - /// Returns the GitHub release with the specified tag name for the given GitHub repository. - /// - /// Returns an error if a release with the given tag name does not exist. - github-release-by-tag-name: func(repo: string, tag: string) -> result; -} diff --git a/crates/extension_api/wit/since_v0.2.0/http-client.wit b/crates/extension_api/wit/since_v0.2.0/http-client.wit deleted file mode 100644 index bb0206c17a..0000000000 --- a/crates/extension_api/wit/since_v0.2.0/http-client.wit +++ /dev/null @@ -1,67 +0,0 @@ -interface http-client { - /// An HTTP request. - record http-request { - /// The HTTP method for the request. - method: http-method, - /// The URL to which the request should be made. - url: string, - /// The headers for the request. - headers: list>, - /// The request body. - body: option>, - /// The policy to use for redirects. - redirect-policy: redirect-policy, - } - - /// HTTP methods. - enum http-method { - /// `GET` - get, - /// `HEAD` - head, - /// `POST` - post, - /// `PUT` - put, - /// `DELETE` - delete, - /// `OPTIONS` - options, - /// `PATCH` - patch, - } - - /// The policy for dealing with redirects received from the server. - variant redirect-policy { - /// Redirects from the server will not be followed. - /// - /// This is the default behavior. - no-follow, - /// Redirects from the server will be followed up to the specified limit. - follow-limit(u32), - /// All redirects from the server will be followed. - follow-all, - } - - /// An HTTP response. - record http-response { - /// The response headers. - headers: list>, - /// The response body. - body: list, - } - - /// Performs an HTTP request and returns the response. - fetch: func(req: http-request) -> result; - - /// An HTTP response stream. - resource http-response-stream { - /// Retrieves the next chunk of data from the response stream. - /// - /// Returns `Ok(None)` if the stream has ended. - next-chunk: func() -> result>, string>; - } - - /// Performs an HTTP request and returns a response stream. - fetch-stream: func(req: http-request) -> result; -} diff --git a/crates/extension_api/wit/since_v0.2.0/lsp.wit b/crates/extension_api/wit/since_v0.2.0/lsp.wit deleted file mode 100644 index 91a36c93a6..0000000000 --- a/crates/extension_api/wit/since_v0.2.0/lsp.wit +++ /dev/null @@ -1,90 +0,0 @@ -interface lsp { - /// An LSP completion. - record completion { - label: string, - label-details: option, - detail: option, - kind: option, - insert-text-format: option, - } - - /// The kind of an LSP completion. - variant completion-kind { - text, - method, - function, - %constructor, - field, - variable, - class, - %interface, - module, - property, - unit, - value, - %enum, - keyword, - snippet, - color, - file, - reference, - folder, - enum-member, - constant, - struct, - event, - operator, - type-parameter, - other(s32), - } - - /// Label details for an LSP completion. - record completion-label-details { - detail: option, - description: option, - } - - /// Defines how to interpret the insert text in a completion item. - variant insert-text-format { - plain-text, - snippet, - other(s32), - } - - /// An LSP symbol. - record symbol { - kind: symbol-kind, - name: string, - } - - /// The kind of an LSP symbol. - variant symbol-kind { - file, - module, - namespace, - %package, - class, - method, - property, - field, - %constructor, - %enum, - %interface, - function, - variable, - constant, - %string, - number, - boolean, - array, - object, - key, - null, - enum-member, - struct, - event, - operator, - type-parameter, - other(s32), - } -} diff --git a/crates/extension_api/wit/since_v0.2.0/nodejs.wit b/crates/extension_api/wit/since_v0.2.0/nodejs.wit deleted file mode 100644 index c814548314..0000000000 --- a/crates/extension_api/wit/since_v0.2.0/nodejs.wit +++ /dev/null @@ -1,13 +0,0 @@ -interface nodejs { - /// Returns the path to the Node binary used by Zed. - node-binary-path: func() -> result; - - /// Returns the latest version of the given NPM package. - npm-package-latest-version: func(package-name: string) -> result; - - /// Returns the installed version of the given NPM package, if it exists. - npm-package-installed-version: func(package-name: string) -> result, string>; - - /// Installs the specified NPM package. - npm-install-package: func(package-name: string, version: string) -> result<_, string>; -} diff --git a/crates/extension_api/wit/since_v0.2.0/platform.wit b/crates/extension_api/wit/since_v0.2.0/platform.wit deleted file mode 100644 index 48472a99bc..0000000000 --- a/crates/extension_api/wit/since_v0.2.0/platform.wit +++ /dev/null @@ -1,24 +0,0 @@ -interface platform { - /// An operating system. - enum os { - /// macOS. - mac, - /// Linux. - linux, - /// Windows. - windows, - } - - /// A platform architecture. - enum architecture { - /// AArch64 (e.g., Apple Silicon). - aarch64, - /// x86. - x86, - /// x86-64. - x8664, - } - - /// Gets the current operating system and architecture. - current-platform: func() -> tuple; -} diff --git a/crates/extension_api/wit/since_v0.2.0/settings.rs b/crates/extension_api/wit/since_v0.2.0/settings.rs deleted file mode 100644 index 19e28c1ba9..0000000000 --- a/crates/extension_api/wit/since_v0.2.0/settings.rs +++ /dev/null @@ -1,40 +0,0 @@ -use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, num::NonZeroU32}; - -/// The settings for a particular language. -#[derive(Debug, Serialize, Deserialize)] -pub struct LanguageSettings { - /// How many columns a tab should occupy. - pub tab_size: NonZeroU32, -} - -/// The settings for a particular language server. -#[derive(Default, Debug, Serialize, Deserialize)] -pub struct LspSettings { - /// The settings for the language server binary. - pub binary: Option, - /// The initialization options to pass to the language server. - pub initialization_options: Option, - /// The settings to pass to language server. - pub settings: Option, -} - -/// The settings for a particular context server. -#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Eq)] -pub struct ContextServerSettings { - /// The settings for the context server binary. - pub command: Option, - /// The settings to pass to the context server. - pub settings: Option, -} - -/// The settings for a command. -#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] -pub struct CommandSettings { - /// The path to the command. - pub path: Option, - /// The arguments to pass to the command. - pub arguments: Option>, - /// The environment variables. - pub env: Option>, -} diff --git a/crates/extension_api/wit/since_v0.2.0/slash-command.wit b/crates/extension_api/wit/since_v0.2.0/slash-command.wit deleted file mode 100644 index f52561c2ef..0000000000 --- a/crates/extension_api/wit/since_v0.2.0/slash-command.wit +++ /dev/null @@ -1,41 +0,0 @@ -interface slash-command { - use common.{range}; - - /// A slash command for use in the Assistant. - record slash-command { - /// The name of the slash command. - name: string, - /// The description of the slash command. - description: string, - /// The tooltip text to display for the run button. - tooltip-text: string, - /// Whether this slash command requires an argument. - requires-argument: bool, - } - - /// The output of a slash command. - record slash-command-output { - /// The text produced by the slash command. - text: string, - /// The list of sections to show in the slash command placeholder. - sections: list, - } - - /// A section in the slash command output. - record slash-command-output-section { - /// The range this section occupies. - range: range, - /// The label to display in the placeholder for this section. - label: string, - } - - /// A completion for a slash command argument. - record slash-command-argument-completion { - /// The label to display for this completion. - label: string, - /// The new text that should be inserted into the command when this completion is accepted. - new-text: string, - /// Whether the command should be run when accepting this completion. - run-command: bool, - } -} diff --git a/crates/extension_api/wit/since_v0.3.0/common.wit b/crates/extension_api/wit/since_v0.3.0/common.wit deleted file mode 100644 index 139e7ba0ca..0000000000 --- a/crates/extension_api/wit/since_v0.3.0/common.wit +++ /dev/null @@ -1,12 +0,0 @@ -interface common { - /// A (half-open) range (`[start, end)`). - record range { - /// The start of the range (inclusive). - start: u32, - /// The end of the range (exclusive). - end: u32, - } - - /// A list of environment variables. - type env-vars = list>; -} diff --git a/crates/extension_api/wit/since_v0.3.0/extension.wit b/crates/extension_api/wit/since_v0.3.0/extension.wit deleted file mode 100644 index 95aaec5469..0000000000 --- a/crates/extension_api/wit/since_v0.3.0/extension.wit +++ /dev/null @@ -1,145 +0,0 @@ -package zed:extension; - -world extension { - import github; - import http-client; - import platform; - import process; - import nodejs; - - use common.{env-vars, range}; - use lsp.{completion, symbol}; - use process.{command}; - use slash-command.{slash-command, slash-command-argument-completion, slash-command-output}; - - /// Initializes the extension. - export init-extension: func(); - - /// The type of a downloaded file. - enum downloaded-file-type { - /// A gzipped file (`.gz`). - gzip, - /// A gzipped tar archive (`.tar.gz`). - gzip-tar, - /// A ZIP file (`.zip`). - zip, - /// An uncompressed file. - uncompressed, - } - - /// The installation status for a language server. - variant language-server-installation-status { - /// The language server has no installation status. - none, - /// The language server is being downloaded. - downloading, - /// The language server is checking for updates. - checking-for-update, - /// The language server installation failed for specified reason. - failed(string), - } - - record settings-location { - worktree-id: u64, - path: string, - } - - import get-settings: func(path: option, category: string, key: option) -> result; - - /// Downloads a file from the given URL and saves it to the given path within the extension's - /// working directory. - /// - /// The file will be extracted according to the given file type. - import download-file: func(url: string, file-path: string, file-type: downloaded-file-type) -> result<_, string>; - - /// Makes the file at the given path executable. - import make-file-executable: func(filepath: string) -> result<_, string>; - - /// Updates the installation status for the given language server. - import set-language-server-installation-status: func(language-server-name: string, status: language-server-installation-status); - - /// A Zed worktree. - resource worktree { - /// Returns the ID of the worktree. - id: func() -> u64; - /// Returns the root path of the worktree. - root-path: func() -> string; - /// Returns the textual contents of the specified file in the worktree. - read-text-file: func(path: string) -> result; - /// Returns the path to the given binary name, if one is present on the `$PATH`. - which: func(binary-name: string) -> option; - /// Returns the current shell environment. - shell-env: func() -> env-vars; - } - - /// A Zed project. - resource project { - /// Returns the IDs of all of the worktrees in this project. - worktree-ids: func() -> list; - } - - /// A key-value store. - resource key-value-store { - /// Inserts an entry under the specified key. - insert: func(key: string, value: string) -> result<_, string>; - } - - /// Returns the command used to start up the language server. - export language-server-command: func(language-server-id: string, worktree: borrow) -> result; - - /// Returns the initialization options to pass to the language server on startup. - /// - /// The initialization options are represented as a JSON string. - export language-server-initialization-options: func(language-server-id: string, worktree: borrow) -> result, string>; - - /// Returns the workspace configuration options to pass to the language server. - export language-server-workspace-configuration: func(language-server-id: string, worktree: borrow) -> result, string>; - - /// A label containing some code. - record code-label { - /// The source code to parse with Tree-sitter. - code: string, - /// The spans to display in the label. - spans: list, - /// The range of the displayed label to include when filtering. - filter-range: range, - } - - /// A span within a code label. - variant code-label-span { - /// A range into the parsed code. - code-range(range), - /// A span containing a code literal. - literal(code-label-span-literal), - } - - /// A span containing a code literal. - record code-label-span-literal { - /// The literal text. - text: string, - /// The name of the highlight to use for this literal. - highlight-name: option, - } - - export labels-for-completions: func(language-server-id: string, completions: list) -> result>, string>; - export labels-for-symbols: func(language-server-id: string, symbols: list) -> result>, string>; - - /// Returns the completions that should be shown when completing the provided slash command with the given query. - export complete-slash-command-argument: func(command: slash-command, args: list) -> result, string>; - - /// Returns the output from running the provided slash command. - export run-slash-command: func(command: slash-command, args: list, worktree: option>) -> result; - - /// Returns the command used to start up a context server. - export context-server-command: func(context-server-id: string, project: borrow) -> result; - - /// Returns a list of packages as suggestions to be included in the `/docs` - /// search results. - /// - /// This can be used to provide completions for known packages (e.g., from the - /// local project or a registry) before a package has been indexed. - export suggest-docs-packages: func(provider-name: string) -> result, string>; - - /// Indexes the docs for the specified package. - export index-docs: func(provider-name: string, package-name: string, database: borrow) -> result<_, string>; -} diff --git a/crates/extension_api/wit/since_v0.3.0/github.wit b/crates/extension_api/wit/since_v0.3.0/github.wit deleted file mode 100644 index 21cd5d4805..0000000000 --- a/crates/extension_api/wit/since_v0.3.0/github.wit +++ /dev/null @@ -1,35 +0,0 @@ -interface github { - /// A GitHub release. - record github-release { - /// The version of the release. - version: string, - /// The list of assets attached to the release. - assets: list, - } - - /// An asset from a GitHub release. - record github-release-asset { - /// The name of the asset. - name: string, - /// The download URL for the asset. - download-url: string, - } - - /// The options used to filter down GitHub releases. - record github-release-options { - /// Whether releases without assets should be included. - require-assets: bool, - /// Whether pre-releases should be included. - pre-release: bool, - } - - /// Returns the latest release for the given GitHub repository. - /// - /// Takes repo as a string in the form "/", for example: "zed-industries/zed". - latest-github-release: func(repo: string, options: github-release-options) -> result; - - /// Returns the GitHub release with the specified tag name for the given GitHub repository. - /// - /// Returns an error if a release with the given tag name does not exist. - github-release-by-tag-name: func(repo: string, tag: string) -> result; -} diff --git a/crates/extension_api/wit/since_v0.3.0/http-client.wit b/crates/extension_api/wit/since_v0.3.0/http-client.wit deleted file mode 100644 index bb0206c17a..0000000000 --- a/crates/extension_api/wit/since_v0.3.0/http-client.wit +++ /dev/null @@ -1,67 +0,0 @@ -interface http-client { - /// An HTTP request. - record http-request { - /// The HTTP method for the request. - method: http-method, - /// The URL to which the request should be made. - url: string, - /// The headers for the request. - headers: list>, - /// The request body. - body: option>, - /// The policy to use for redirects. - redirect-policy: redirect-policy, - } - - /// HTTP methods. - enum http-method { - /// `GET` - get, - /// `HEAD` - head, - /// `POST` - post, - /// `PUT` - put, - /// `DELETE` - delete, - /// `OPTIONS` - options, - /// `PATCH` - patch, - } - - /// The policy for dealing with redirects received from the server. - variant redirect-policy { - /// Redirects from the server will not be followed. - /// - /// This is the default behavior. - no-follow, - /// Redirects from the server will be followed up to the specified limit. - follow-limit(u32), - /// All redirects from the server will be followed. - follow-all, - } - - /// An HTTP response. - record http-response { - /// The response headers. - headers: list>, - /// The response body. - body: list, - } - - /// Performs an HTTP request and returns the response. - fetch: func(req: http-request) -> result; - - /// An HTTP response stream. - resource http-response-stream { - /// Retrieves the next chunk of data from the response stream. - /// - /// Returns `Ok(None)` if the stream has ended. - next-chunk: func() -> result>, string>; - } - - /// Performs an HTTP request and returns a response stream. - fetch-stream: func(req: http-request) -> result; -} diff --git a/crates/extension_api/wit/since_v0.3.0/lsp.wit b/crates/extension_api/wit/since_v0.3.0/lsp.wit deleted file mode 100644 index 91a36c93a6..0000000000 --- a/crates/extension_api/wit/since_v0.3.0/lsp.wit +++ /dev/null @@ -1,90 +0,0 @@ -interface lsp { - /// An LSP completion. - record completion { - label: string, - label-details: option, - detail: option, - kind: option, - insert-text-format: option, - } - - /// The kind of an LSP completion. - variant completion-kind { - text, - method, - function, - %constructor, - field, - variable, - class, - %interface, - module, - property, - unit, - value, - %enum, - keyword, - snippet, - color, - file, - reference, - folder, - enum-member, - constant, - struct, - event, - operator, - type-parameter, - other(s32), - } - - /// Label details for an LSP completion. - record completion-label-details { - detail: option, - description: option, - } - - /// Defines how to interpret the insert text in a completion item. - variant insert-text-format { - plain-text, - snippet, - other(s32), - } - - /// An LSP symbol. - record symbol { - kind: symbol-kind, - name: string, - } - - /// The kind of an LSP symbol. - variant symbol-kind { - file, - module, - namespace, - %package, - class, - method, - property, - field, - %constructor, - %enum, - %interface, - function, - variable, - constant, - %string, - number, - boolean, - array, - object, - key, - null, - enum-member, - struct, - event, - operator, - type-parameter, - other(s32), - } -} diff --git a/crates/extension_api/wit/since_v0.3.0/nodejs.wit b/crates/extension_api/wit/since_v0.3.0/nodejs.wit deleted file mode 100644 index c814548314..0000000000 --- a/crates/extension_api/wit/since_v0.3.0/nodejs.wit +++ /dev/null @@ -1,13 +0,0 @@ -interface nodejs { - /// Returns the path to the Node binary used by Zed. - node-binary-path: func() -> result; - - /// Returns the latest version of the given NPM package. - npm-package-latest-version: func(package-name: string) -> result; - - /// Returns the installed version of the given NPM package, if it exists. - npm-package-installed-version: func(package-name: string) -> result, string>; - - /// Installs the specified NPM package. - npm-install-package: func(package-name: string, version: string) -> result<_, string>; -} diff --git a/crates/extension_api/wit/since_v0.3.0/platform.wit b/crates/extension_api/wit/since_v0.3.0/platform.wit deleted file mode 100644 index 48472a99bc..0000000000 --- a/crates/extension_api/wit/since_v0.3.0/platform.wit +++ /dev/null @@ -1,24 +0,0 @@ -interface platform { - /// An operating system. - enum os { - /// macOS. - mac, - /// Linux. - linux, - /// Windows. - windows, - } - - /// A platform architecture. - enum architecture { - /// AArch64 (e.g., Apple Silicon). - aarch64, - /// x86. - x86, - /// x86-64. - x8664, - } - - /// Gets the current operating system and architecture. - current-platform: func() -> tuple; -} diff --git a/crates/extension_api/wit/since_v0.3.0/process.wit b/crates/extension_api/wit/since_v0.3.0/process.wit deleted file mode 100644 index d9a5728a3d..0000000000 --- a/crates/extension_api/wit/since_v0.3.0/process.wit +++ /dev/null @@ -1,29 +0,0 @@ -interface process { - use common.{env-vars}; - - /// A command. - record command { - /// The command to execute. - command: string, - /// The arguments to pass to the command. - args: list, - /// The environment variables to set for the command. - env: env-vars, - } - - /// The output of a finished process. - record output { - /// The status (exit code) of the process. - /// - /// On Unix, this will be `None` if the process was terminated by a signal. - status: option, - /// The data that the process wrote to stdout. - stdout: list, - /// The data that the process wrote to stderr. - stderr: list, - } - - /// Executes the given command as a child process, waiting for it to finish - /// and collecting all of its output. - run-command: func(command: command) -> result; -} diff --git a/crates/extension_api/wit/since_v0.3.0/settings.rs b/crates/extension_api/wit/since_v0.3.0/settings.rs deleted file mode 100644 index 19e28c1ba9..0000000000 --- a/crates/extension_api/wit/since_v0.3.0/settings.rs +++ /dev/null @@ -1,40 +0,0 @@ -use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, num::NonZeroU32}; - -/// The settings for a particular language. -#[derive(Debug, Serialize, Deserialize)] -pub struct LanguageSettings { - /// How many columns a tab should occupy. - pub tab_size: NonZeroU32, -} - -/// The settings for a particular language server. -#[derive(Default, Debug, Serialize, Deserialize)] -pub struct LspSettings { - /// The settings for the language server binary. - pub binary: Option, - /// The initialization options to pass to the language server. - pub initialization_options: Option, - /// The settings to pass to language server. - pub settings: Option, -} - -/// The settings for a particular context server. -#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Eq)] -pub struct ContextServerSettings { - /// The settings for the context server binary. - pub command: Option, - /// The settings to pass to the context server. - pub settings: Option, -} - -/// The settings for a command. -#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] -pub struct CommandSettings { - /// The path to the command. - pub path: Option, - /// The arguments to pass to the command. - pub arguments: Option>, - /// The environment variables. - pub env: Option>, -} diff --git a/crates/extension_api/wit/since_v0.3.0/slash-command.wit b/crates/extension_api/wit/since_v0.3.0/slash-command.wit deleted file mode 100644 index f52561c2ef..0000000000 --- a/crates/extension_api/wit/since_v0.3.0/slash-command.wit +++ /dev/null @@ -1,41 +0,0 @@ -interface slash-command { - use common.{range}; - - /// A slash command for use in the Assistant. - record slash-command { - /// The name of the slash command. - name: string, - /// The description of the slash command. - description: string, - /// The tooltip text to display for the run button. - tooltip-text: string, - /// Whether this slash command requires an argument. - requires-argument: bool, - } - - /// The output of a slash command. - record slash-command-output { - /// The text produced by the slash command. - text: string, - /// The list of sections to show in the slash command placeholder. - sections: list, - } - - /// A section in the slash command output. - record slash-command-output-section { - /// The range this section occupies. - range: range, - /// The label to display in the placeholder for this section. - label: string, - } - - /// A completion for a slash command argument. - record slash-command-argument-completion { - /// The label to display for this completion. - label: string, - /// The new text that should be inserted into the command when this completion is accepted. - new-text: string, - /// Whether the command should be run when accepting this completion. - run-command: bool, - } -} diff --git a/crates/extension_api/wit/since_v0.4.0/common.wit b/crates/extension_api/wit/since_v0.4.0/common.wit deleted file mode 100644 index 139e7ba0ca..0000000000 --- a/crates/extension_api/wit/since_v0.4.0/common.wit +++ /dev/null @@ -1,12 +0,0 @@ -interface common { - /// A (half-open) range (`[start, end)`). - record range { - /// The start of the range (inclusive). - start: u32, - /// The end of the range (exclusive). - end: u32, - } - - /// A list of environment variables. - type env-vars = list>; -} diff --git a/crates/extension_api/wit/since_v0.4.0/extension.wit b/crates/extension_api/wit/since_v0.4.0/extension.wit deleted file mode 100644 index 3caf8b60b7..0000000000 --- a/crates/extension_api/wit/since_v0.4.0/extension.wit +++ /dev/null @@ -1,151 +0,0 @@ -package zed:extension; - -world extension { - import github; - import http-client; - import platform; - import process; - import nodejs; - - use common.{env-vars, range}; - use lsp.{completion, symbol}; - use process.{command}; - use slash-command.{slash-command, slash-command-argument-completion, slash-command-output}; - - /// Initializes the extension. - export init-extension: func(); - - /// The type of a downloaded file. - enum downloaded-file-type { - /// A gzipped file (`.gz`). - gzip, - /// A gzipped tar archive (`.tar.gz`). - gzip-tar, - /// A ZIP file (`.zip`). - zip, - /// An uncompressed file. - uncompressed, - } - - /// The installation status for a language server. - variant language-server-installation-status { - /// The language server has no installation status. - none, - /// The language server is being downloaded. - downloading, - /// The language server is checking for updates. - checking-for-update, - /// The language server installation failed for specified reason. - failed(string), - } - - record settings-location { - worktree-id: u64, - path: string, - } - - import get-settings: func(path: option, category: string, key: option) -> result; - - /// Downloads a file from the given URL and saves it to the given path within the extension's - /// working directory. - /// - /// The file will be extracted according to the given file type. - import download-file: func(url: string, file-path: string, file-type: downloaded-file-type) -> result<_, string>; - - /// Makes the file at the given path executable. - import make-file-executable: func(filepath: string) -> result<_, string>; - - /// Updates the installation status for the given language server. - import set-language-server-installation-status: func(language-server-name: string, status: language-server-installation-status); - - /// A Zed worktree. - resource worktree { - /// Returns the ID of the worktree. - id: func() -> u64; - /// Returns the root path of the worktree. - root-path: func() -> string; - /// Returns the textual contents of the specified file in the worktree. - read-text-file: func(path: string) -> result; - /// Returns the path to the given binary name, if one is present on the `$PATH`. - which: func(binary-name: string) -> option; - /// Returns the current shell environment. - shell-env: func() -> env-vars; - } - - /// A Zed project. - resource project { - /// Returns the IDs of all of the worktrees in this project. - worktree-ids: func() -> list; - } - - /// A key-value store. - resource key-value-store { - /// Inserts an entry under the specified key. - insert: func(key: string, value: string) -> result<_, string>; - } - - /// Returns the command used to start up the language server. - export language-server-command: func(language-server-id: string, worktree: borrow) -> result; - - /// Returns the initialization options to pass to the language server on startup. - /// - /// The initialization options are represented as a JSON string. - export language-server-initialization-options: func(language-server-id: string, worktree: borrow) -> result, string>; - - /// Returns the workspace configuration options to pass to the language server. - export language-server-workspace-configuration: func(language-server-id: string, worktree: borrow) -> result, string>; - - /// Returns the initialization options to pass to the other language server. - export language-server-additional-initialization-options: func(language-server-id: string, target-language-server-id: string, worktree: borrow) -> result, string>; - - /// Returns the workspace configuration options to pass to the other language server. - export language-server-additional-workspace-configuration: func(language-server-id: string, target-language-server-id: string, worktree: borrow) -> result, string>; - - /// A label containing some code. - record code-label { - /// The source code to parse with Tree-sitter. - code: string, - /// The spans to display in the label. - spans: list, - /// The range of the displayed label to include when filtering. - filter-range: range, - } - - /// A span within a code label. - variant code-label-span { - /// A range into the parsed code. - code-range(range), - /// A span containing a code literal. - literal(code-label-span-literal), - } - - /// A span containing a code literal. - record code-label-span-literal { - /// The literal text. - text: string, - /// The name of the highlight to use for this literal. - highlight-name: option, - } - - export labels-for-completions: func(language-server-id: string, completions: list) -> result>, string>; - export labels-for-symbols: func(language-server-id: string, symbols: list) -> result>, string>; - - /// Returns the completions that should be shown when completing the provided slash command with the given query. - export complete-slash-command-argument: func(command: slash-command, args: list) -> result, string>; - - /// Returns the output from running the provided slash command. - export run-slash-command: func(command: slash-command, args: list, worktree: option>) -> result; - - /// Returns the command used to start up a context server. - export context-server-command: func(context-server-id: string, project: borrow) -> result; - - /// Returns a list of packages as suggestions to be included in the `/docs` - /// search results. - /// - /// This can be used to provide completions for known packages (e.g., from the - /// local project or a registry) before a package has been indexed. - export suggest-docs-packages: func(provider-name: string) -> result, string>; - - /// Indexes the docs for the specified package. - export index-docs: func(provider-name: string, package-name: string, database: borrow) -> result<_, string>; -} diff --git a/crates/extension_api/wit/since_v0.4.0/github.wit b/crates/extension_api/wit/since_v0.4.0/github.wit deleted file mode 100644 index 21cd5d4805..0000000000 --- a/crates/extension_api/wit/since_v0.4.0/github.wit +++ /dev/null @@ -1,35 +0,0 @@ -interface github { - /// A GitHub release. - record github-release { - /// The version of the release. - version: string, - /// The list of assets attached to the release. - assets: list, - } - - /// An asset from a GitHub release. - record github-release-asset { - /// The name of the asset. - name: string, - /// The download URL for the asset. - download-url: string, - } - - /// The options used to filter down GitHub releases. - record github-release-options { - /// Whether releases without assets should be included. - require-assets: bool, - /// Whether pre-releases should be included. - pre-release: bool, - } - - /// Returns the latest release for the given GitHub repository. - /// - /// Takes repo as a string in the form "/", for example: "zed-industries/zed". - latest-github-release: func(repo: string, options: github-release-options) -> result; - - /// Returns the GitHub release with the specified tag name for the given GitHub repository. - /// - /// Returns an error if a release with the given tag name does not exist. - github-release-by-tag-name: func(repo: string, tag: string) -> result; -} diff --git a/crates/extension_api/wit/since_v0.4.0/http-client.wit b/crates/extension_api/wit/since_v0.4.0/http-client.wit deleted file mode 100644 index bb0206c17a..0000000000 --- a/crates/extension_api/wit/since_v0.4.0/http-client.wit +++ /dev/null @@ -1,67 +0,0 @@ -interface http-client { - /// An HTTP request. - record http-request { - /// The HTTP method for the request. - method: http-method, - /// The URL to which the request should be made. - url: string, - /// The headers for the request. - headers: list>, - /// The request body. - body: option>, - /// The policy to use for redirects. - redirect-policy: redirect-policy, - } - - /// HTTP methods. - enum http-method { - /// `GET` - get, - /// `HEAD` - head, - /// `POST` - post, - /// `PUT` - put, - /// `DELETE` - delete, - /// `OPTIONS` - options, - /// `PATCH` - patch, - } - - /// The policy for dealing with redirects received from the server. - variant redirect-policy { - /// Redirects from the server will not be followed. - /// - /// This is the default behavior. - no-follow, - /// Redirects from the server will be followed up to the specified limit. - follow-limit(u32), - /// All redirects from the server will be followed. - follow-all, - } - - /// An HTTP response. - record http-response { - /// The response headers. - headers: list>, - /// The response body. - body: list, - } - - /// Performs an HTTP request and returns the response. - fetch: func(req: http-request) -> result; - - /// An HTTP response stream. - resource http-response-stream { - /// Retrieves the next chunk of data from the response stream. - /// - /// Returns `Ok(None)` if the stream has ended. - next-chunk: func() -> result>, string>; - } - - /// Performs an HTTP request and returns a response stream. - fetch-stream: func(req: http-request) -> result; -} diff --git a/crates/extension_api/wit/since_v0.4.0/lsp.wit b/crates/extension_api/wit/since_v0.4.0/lsp.wit deleted file mode 100644 index 91a36c93a6..0000000000 --- a/crates/extension_api/wit/since_v0.4.0/lsp.wit +++ /dev/null @@ -1,90 +0,0 @@ -interface lsp { - /// An LSP completion. - record completion { - label: string, - label-details: option, - detail: option, - kind: option, - insert-text-format: option, - } - - /// The kind of an LSP completion. - variant completion-kind { - text, - method, - function, - %constructor, - field, - variable, - class, - %interface, - module, - property, - unit, - value, - %enum, - keyword, - snippet, - color, - file, - reference, - folder, - enum-member, - constant, - struct, - event, - operator, - type-parameter, - other(s32), - } - - /// Label details for an LSP completion. - record completion-label-details { - detail: option, - description: option, - } - - /// Defines how to interpret the insert text in a completion item. - variant insert-text-format { - plain-text, - snippet, - other(s32), - } - - /// An LSP symbol. - record symbol { - kind: symbol-kind, - name: string, - } - - /// The kind of an LSP symbol. - variant symbol-kind { - file, - module, - namespace, - %package, - class, - method, - property, - field, - %constructor, - %enum, - %interface, - function, - variable, - constant, - %string, - number, - boolean, - array, - object, - key, - null, - enum-member, - struct, - event, - operator, - type-parameter, - other(s32), - } -} diff --git a/crates/extension_api/wit/since_v0.4.0/nodejs.wit b/crates/extension_api/wit/since_v0.4.0/nodejs.wit deleted file mode 100644 index c814548314..0000000000 --- a/crates/extension_api/wit/since_v0.4.0/nodejs.wit +++ /dev/null @@ -1,13 +0,0 @@ -interface nodejs { - /// Returns the path to the Node binary used by Zed. - node-binary-path: func() -> result; - - /// Returns the latest version of the given NPM package. - npm-package-latest-version: func(package-name: string) -> result; - - /// Returns the installed version of the given NPM package, if it exists. - npm-package-installed-version: func(package-name: string) -> result, string>; - - /// Installs the specified NPM package. - npm-install-package: func(package-name: string, version: string) -> result<_, string>; -} diff --git a/crates/extension_api/wit/since_v0.4.0/platform.wit b/crates/extension_api/wit/since_v0.4.0/platform.wit deleted file mode 100644 index 48472a99bc..0000000000 --- a/crates/extension_api/wit/since_v0.4.0/platform.wit +++ /dev/null @@ -1,24 +0,0 @@ -interface platform { - /// An operating system. - enum os { - /// macOS. - mac, - /// Linux. - linux, - /// Windows. - windows, - } - - /// A platform architecture. - enum architecture { - /// AArch64 (e.g., Apple Silicon). - aarch64, - /// x86. - x86, - /// x86-64. - x8664, - } - - /// Gets the current operating system and architecture. - current-platform: func() -> tuple; -} diff --git a/crates/extension_api/wit/since_v0.4.0/process.wit b/crates/extension_api/wit/since_v0.4.0/process.wit deleted file mode 100644 index d9a5728a3d..0000000000 --- a/crates/extension_api/wit/since_v0.4.0/process.wit +++ /dev/null @@ -1,29 +0,0 @@ -interface process { - use common.{env-vars}; - - /// A command. - record command { - /// The command to execute. - command: string, - /// The arguments to pass to the command. - args: list, - /// The environment variables to set for the command. - env: env-vars, - } - - /// The output of a finished process. - record output { - /// The status (exit code) of the process. - /// - /// On Unix, this will be `None` if the process was terminated by a signal. - status: option, - /// The data that the process wrote to stdout. - stdout: list, - /// The data that the process wrote to stderr. - stderr: list, - } - - /// Executes the given command as a child process, waiting for it to finish - /// and collecting all of its output. - run-command: func(command: command) -> result; -} diff --git a/crates/extension_api/wit/since_v0.4.0/settings.rs b/crates/extension_api/wit/since_v0.4.0/settings.rs deleted file mode 100644 index 19e28c1ba9..0000000000 --- a/crates/extension_api/wit/since_v0.4.0/settings.rs +++ /dev/null @@ -1,40 +0,0 @@ -use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, num::NonZeroU32}; - -/// The settings for a particular language. -#[derive(Debug, Serialize, Deserialize)] -pub struct LanguageSettings { - /// How many columns a tab should occupy. - pub tab_size: NonZeroU32, -} - -/// The settings for a particular language server. -#[derive(Default, Debug, Serialize, Deserialize)] -pub struct LspSettings { - /// The settings for the language server binary. - pub binary: Option, - /// The initialization options to pass to the language server. - pub initialization_options: Option, - /// The settings to pass to language server. - pub settings: Option, -} - -/// The settings for a particular context server. -#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Eq)] -pub struct ContextServerSettings { - /// The settings for the context server binary. - pub command: Option, - /// The settings to pass to the context server. - pub settings: Option, -} - -/// The settings for a command. -#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] -pub struct CommandSettings { - /// The path to the command. - pub path: Option, - /// The arguments to pass to the command. - pub arguments: Option>, - /// The environment variables. - pub env: Option>, -} diff --git a/crates/extension_api/wit/since_v0.4.0/slash-command.wit b/crates/extension_api/wit/since_v0.4.0/slash-command.wit deleted file mode 100644 index f52561c2ef..0000000000 --- a/crates/extension_api/wit/since_v0.4.0/slash-command.wit +++ /dev/null @@ -1,41 +0,0 @@ -interface slash-command { - use common.{range}; - - /// A slash command for use in the Assistant. - record slash-command { - /// The name of the slash command. - name: string, - /// The description of the slash command. - description: string, - /// The tooltip text to display for the run button. - tooltip-text: string, - /// Whether this slash command requires an argument. - requires-argument: bool, - } - - /// The output of a slash command. - record slash-command-output { - /// The text produced by the slash command. - text: string, - /// The list of sections to show in the slash command placeholder. - sections: list, - } - - /// A section in the slash command output. - record slash-command-output-section { - /// The range this section occupies. - range: range, - /// The label to display in the placeholder for this section. - label: string, - } - - /// A completion for a slash command argument. - record slash-command-argument-completion { - /// The label to display for this completion. - label: string, - /// The new text that should be inserted into the command when this completion is accepted. - new-text: string, - /// Whether the command should be run when accepting this completion. - run-command: bool, - } -} diff --git a/crates/extension_api/wit/since_v0.5.0/common.wit b/crates/extension_api/wit/since_v0.5.0/common.wit deleted file mode 100644 index 139e7ba0ca..0000000000 --- a/crates/extension_api/wit/since_v0.5.0/common.wit +++ /dev/null @@ -1,12 +0,0 @@ -interface common { - /// A (half-open) range (`[start, end)`). - record range { - /// The start of the range (inclusive). - start: u32, - /// The end of the range (exclusive). - end: u32, - } - - /// A list of environment variables. - type env-vars = list>; -} diff --git a/crates/extension_api/wit/since_v0.5.0/context-server.wit b/crates/extension_api/wit/since_v0.5.0/context-server.wit deleted file mode 100644 index 7234e0e6d0..0000000000 --- a/crates/extension_api/wit/since_v0.5.0/context-server.wit +++ /dev/null @@ -1,11 +0,0 @@ -interface context-server { - /// Configuration for context server setup and installation. - record context-server-configuration { - /// Installation instructions in Markdown format. - installation-instructions: string, - /// JSON schema for settings validation. - settings-schema: string, - /// Default settings template. - default-settings: string, - } -} diff --git a/crates/extension_api/wit/since_v0.5.0/extension.wit b/crates/extension_api/wit/since_v0.5.0/extension.wit deleted file mode 100644 index f21cc1bf21..0000000000 --- a/crates/extension_api/wit/since_v0.5.0/extension.wit +++ /dev/null @@ -1,156 +0,0 @@ -package zed:extension; - -world extension { - import context-server; - import github; - import http-client; - import platform; - import process; - import nodejs; - - use common.{env-vars, range}; - use context-server.{context-server-configuration}; - use lsp.{completion, symbol}; - use process.{command}; - use slash-command.{slash-command, slash-command-argument-completion, slash-command-output}; - - /// Initializes the extension. - export init-extension: func(); - - /// The type of a downloaded file. - enum downloaded-file-type { - /// A gzipped file (`.gz`). - gzip, - /// A gzipped tar archive (`.tar.gz`). - gzip-tar, - /// A ZIP file (`.zip`). - zip, - /// An uncompressed file. - uncompressed, - } - - /// The installation status for a language server. - variant language-server-installation-status { - /// The language server has no installation status. - none, - /// The language server is being downloaded. - downloading, - /// The language server is checking for updates. - checking-for-update, - /// The language server installation failed for specified reason. - failed(string), - } - - record settings-location { - worktree-id: u64, - path: string, - } - - import get-settings: func(path: option, category: string, key: option) -> result; - - /// Downloads a file from the given URL and saves it to the given path within the extension's - /// working directory. - /// - /// The file will be extracted according to the given file type. - import download-file: func(url: string, file-path: string, file-type: downloaded-file-type) -> result<_, string>; - - /// Makes the file at the given path executable. - import make-file-executable: func(filepath: string) -> result<_, string>; - - /// Updates the installation status for the given language server. - import set-language-server-installation-status: func(language-server-name: string, status: language-server-installation-status); - - /// A Zed worktree. - resource worktree { - /// Returns the ID of the worktree. - id: func() -> u64; - /// Returns the root path of the worktree. - root-path: func() -> string; - /// Returns the textual contents of the specified file in the worktree. - read-text-file: func(path: string) -> result; - /// Returns the path to the given binary name, if one is present on the `$PATH`. - which: func(binary-name: string) -> option; - /// Returns the current shell environment. - shell-env: func() -> env-vars; - } - - /// A Zed project. - resource project { - /// Returns the IDs of all of the worktrees in this project. - worktree-ids: func() -> list; - } - - /// A key-value store. - resource key-value-store { - /// Inserts an entry under the specified key. - insert: func(key: string, value: string) -> result<_, string>; - } - - /// Returns the command used to start up the language server. - export language-server-command: func(language-server-id: string, worktree: borrow) -> result; - - /// Returns the initialization options to pass to the language server on startup. - /// - /// The initialization options are represented as a JSON string. - export language-server-initialization-options: func(language-server-id: string, worktree: borrow) -> result, string>; - - /// Returns the workspace configuration options to pass to the language server. - export language-server-workspace-configuration: func(language-server-id: string, worktree: borrow) -> result, string>; - - /// Returns the initialization options to pass to the other language server. - export language-server-additional-initialization-options: func(language-server-id: string, target-language-server-id: string, worktree: borrow) -> result, string>; - - /// Returns the workspace configuration options to pass to the other language server. - export language-server-additional-workspace-configuration: func(language-server-id: string, target-language-server-id: string, worktree: borrow) -> result, string>; - - /// A label containing some code. - record code-label { - /// The source code to parse with Tree-sitter. - code: string, - /// The spans to display in the label. - spans: list, - /// The range of the displayed label to include when filtering. - filter-range: range, - } - - /// A span within a code label. - variant code-label-span { - /// A range into the parsed code. - code-range(range), - /// A span containing a code literal. - literal(code-label-span-literal), - } - - /// A span containing a code literal. - record code-label-span-literal { - /// The literal text. - text: string, - /// The name of the highlight to use for this literal. - highlight-name: option, - } - - export labels-for-completions: func(language-server-id: string, completions: list) -> result>, string>; - export labels-for-symbols: func(language-server-id: string, symbols: list) -> result>, string>; - - /// Returns the completions that should be shown when completing the provided slash command with the given query. - export complete-slash-command-argument: func(command: slash-command, args: list) -> result, string>; - - /// Returns the output from running the provided slash command. - export run-slash-command: func(command: slash-command, args: list, worktree: option>) -> result; - - /// Returns the command used to start up a context server. - export context-server-command: func(context-server-id: string, project: borrow) -> result; - - /// Returns the configuration for a context server. - export context-server-configuration: func(context-server-id: string, project: borrow) -> result, string>; - - /// Returns a list of packages as suggestions to be included in the `/docs` - /// search results. - /// - /// This can be used to provide completions for known packages (e.g., from the - /// local project or a registry) before a package has been indexed. - export suggest-docs-packages: func(provider-name: string) -> result, string>; - - /// Indexes the docs for the specified package. - export index-docs: func(provider-name: string, package-name: string, database: borrow) -> result<_, string>; -} diff --git a/crates/extension_api/wit/since_v0.5.0/github.wit b/crates/extension_api/wit/since_v0.5.0/github.wit deleted file mode 100644 index 21cd5d4805..0000000000 --- a/crates/extension_api/wit/since_v0.5.0/github.wit +++ /dev/null @@ -1,35 +0,0 @@ -interface github { - /// A GitHub release. - record github-release { - /// The version of the release. - version: string, - /// The list of assets attached to the release. - assets: list, - } - - /// An asset from a GitHub release. - record github-release-asset { - /// The name of the asset. - name: string, - /// The download URL for the asset. - download-url: string, - } - - /// The options used to filter down GitHub releases. - record github-release-options { - /// Whether releases without assets should be included. - require-assets: bool, - /// Whether pre-releases should be included. - pre-release: bool, - } - - /// Returns the latest release for the given GitHub repository. - /// - /// Takes repo as a string in the form "/", for example: "zed-industries/zed". - latest-github-release: func(repo: string, options: github-release-options) -> result; - - /// Returns the GitHub release with the specified tag name for the given GitHub repository. - /// - /// Returns an error if a release with the given tag name does not exist. - github-release-by-tag-name: func(repo: string, tag: string) -> result; -} diff --git a/crates/extension_api/wit/since_v0.5.0/http-client.wit b/crates/extension_api/wit/since_v0.5.0/http-client.wit deleted file mode 100644 index bb0206c17a..0000000000 --- a/crates/extension_api/wit/since_v0.5.0/http-client.wit +++ /dev/null @@ -1,67 +0,0 @@ -interface http-client { - /// An HTTP request. - record http-request { - /// The HTTP method for the request. - method: http-method, - /// The URL to which the request should be made. - url: string, - /// The headers for the request. - headers: list>, - /// The request body. - body: option>, - /// The policy to use for redirects. - redirect-policy: redirect-policy, - } - - /// HTTP methods. - enum http-method { - /// `GET` - get, - /// `HEAD` - head, - /// `POST` - post, - /// `PUT` - put, - /// `DELETE` - delete, - /// `OPTIONS` - options, - /// `PATCH` - patch, - } - - /// The policy for dealing with redirects received from the server. - variant redirect-policy { - /// Redirects from the server will not be followed. - /// - /// This is the default behavior. - no-follow, - /// Redirects from the server will be followed up to the specified limit. - follow-limit(u32), - /// All redirects from the server will be followed. - follow-all, - } - - /// An HTTP response. - record http-response { - /// The response headers. - headers: list>, - /// The response body. - body: list, - } - - /// Performs an HTTP request and returns the response. - fetch: func(req: http-request) -> result; - - /// An HTTP response stream. - resource http-response-stream { - /// Retrieves the next chunk of data from the response stream. - /// - /// Returns `Ok(None)` if the stream has ended. - next-chunk: func() -> result>, string>; - } - - /// Performs an HTTP request and returns a response stream. - fetch-stream: func(req: http-request) -> result; -} diff --git a/crates/extension_api/wit/since_v0.5.0/lsp.wit b/crates/extension_api/wit/since_v0.5.0/lsp.wit deleted file mode 100644 index 91a36c93a6..0000000000 --- a/crates/extension_api/wit/since_v0.5.0/lsp.wit +++ /dev/null @@ -1,90 +0,0 @@ -interface lsp { - /// An LSP completion. - record completion { - label: string, - label-details: option, - detail: option, - kind: option, - insert-text-format: option, - } - - /// The kind of an LSP completion. - variant completion-kind { - text, - method, - function, - %constructor, - field, - variable, - class, - %interface, - module, - property, - unit, - value, - %enum, - keyword, - snippet, - color, - file, - reference, - folder, - enum-member, - constant, - struct, - event, - operator, - type-parameter, - other(s32), - } - - /// Label details for an LSP completion. - record completion-label-details { - detail: option, - description: option, - } - - /// Defines how to interpret the insert text in a completion item. - variant insert-text-format { - plain-text, - snippet, - other(s32), - } - - /// An LSP symbol. - record symbol { - kind: symbol-kind, - name: string, - } - - /// The kind of an LSP symbol. - variant symbol-kind { - file, - module, - namespace, - %package, - class, - method, - property, - field, - %constructor, - %enum, - %interface, - function, - variable, - constant, - %string, - number, - boolean, - array, - object, - key, - null, - enum-member, - struct, - event, - operator, - type-parameter, - other(s32), - } -} diff --git a/crates/extension_api/wit/since_v0.5.0/nodejs.wit b/crates/extension_api/wit/since_v0.5.0/nodejs.wit deleted file mode 100644 index c814548314..0000000000 --- a/crates/extension_api/wit/since_v0.5.0/nodejs.wit +++ /dev/null @@ -1,13 +0,0 @@ -interface nodejs { - /// Returns the path to the Node binary used by Zed. - node-binary-path: func() -> result; - - /// Returns the latest version of the given NPM package. - npm-package-latest-version: func(package-name: string) -> result; - - /// Returns the installed version of the given NPM package, if it exists. - npm-package-installed-version: func(package-name: string) -> result, string>; - - /// Installs the specified NPM package. - npm-install-package: func(package-name: string, version: string) -> result<_, string>; -} diff --git a/crates/extension_api/wit/since_v0.5.0/platform.wit b/crates/extension_api/wit/since_v0.5.0/platform.wit deleted file mode 100644 index 48472a99bc..0000000000 --- a/crates/extension_api/wit/since_v0.5.0/platform.wit +++ /dev/null @@ -1,24 +0,0 @@ -interface platform { - /// An operating system. - enum os { - /// macOS. - mac, - /// Linux. - linux, - /// Windows. - windows, - } - - /// A platform architecture. - enum architecture { - /// AArch64 (e.g., Apple Silicon). - aarch64, - /// x86. - x86, - /// x86-64. - x8664, - } - - /// Gets the current operating system and architecture. - current-platform: func() -> tuple; -} diff --git a/crates/extension_api/wit/since_v0.5.0/process.wit b/crates/extension_api/wit/since_v0.5.0/process.wit deleted file mode 100644 index d9a5728a3d..0000000000 --- a/crates/extension_api/wit/since_v0.5.0/process.wit +++ /dev/null @@ -1,29 +0,0 @@ -interface process { - use common.{env-vars}; - - /// A command. - record command { - /// The command to execute. - command: string, - /// The arguments to pass to the command. - args: list, - /// The environment variables to set for the command. - env: env-vars, - } - - /// The output of a finished process. - record output { - /// The status (exit code) of the process. - /// - /// On Unix, this will be `None` if the process was terminated by a signal. - status: option, - /// The data that the process wrote to stdout. - stdout: list, - /// The data that the process wrote to stderr. - stderr: list, - } - - /// Executes the given command as a child process, waiting for it to finish - /// and collecting all of its output. - run-command: func(command: command) -> result; -} diff --git a/crates/extension_api/wit/since_v0.5.0/settings.rs b/crates/extension_api/wit/since_v0.5.0/settings.rs deleted file mode 100644 index 19e28c1ba9..0000000000 --- a/crates/extension_api/wit/since_v0.5.0/settings.rs +++ /dev/null @@ -1,40 +0,0 @@ -use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, num::NonZeroU32}; - -/// The settings for a particular language. -#[derive(Debug, Serialize, Deserialize)] -pub struct LanguageSettings { - /// How many columns a tab should occupy. - pub tab_size: NonZeroU32, -} - -/// The settings for a particular language server. -#[derive(Default, Debug, Serialize, Deserialize)] -pub struct LspSettings { - /// The settings for the language server binary. - pub binary: Option, - /// The initialization options to pass to the language server. - pub initialization_options: Option, - /// The settings to pass to language server. - pub settings: Option, -} - -/// The settings for a particular context server. -#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Eq)] -pub struct ContextServerSettings { - /// The settings for the context server binary. - pub command: Option, - /// The settings to pass to the context server. - pub settings: Option, -} - -/// The settings for a command. -#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] -pub struct CommandSettings { - /// The path to the command. - pub path: Option, - /// The arguments to pass to the command. - pub arguments: Option>, - /// The environment variables. - pub env: Option>, -} diff --git a/crates/extension_api/wit/since_v0.5.0/slash-command.wit b/crates/extension_api/wit/since_v0.5.0/slash-command.wit deleted file mode 100644 index f52561c2ef..0000000000 --- a/crates/extension_api/wit/since_v0.5.0/slash-command.wit +++ /dev/null @@ -1,41 +0,0 @@ -interface slash-command { - use common.{range}; - - /// A slash command for use in the Assistant. - record slash-command { - /// The name of the slash command. - name: string, - /// The description of the slash command. - description: string, - /// The tooltip text to display for the run button. - tooltip-text: string, - /// Whether this slash command requires an argument. - requires-argument: bool, - } - - /// The output of a slash command. - record slash-command-output { - /// The text produced by the slash command. - text: string, - /// The list of sections to show in the slash command placeholder. - sections: list, - } - - /// A section in the slash command output. - record slash-command-output-section { - /// The range this section occupies. - range: range, - /// The label to display in the placeholder for this section. - label: string, - } - - /// A completion for a slash command argument. - record slash-command-argument-completion { - /// The label to display for this completion. - label: string, - /// The new text that should be inserted into the command when this completion is accepted. - new-text: string, - /// Whether the command should be run when accepting this completion. - run-command: bool, - } -} diff --git a/crates/extension_api/wit/since_v0.6.0/common.wit b/crates/extension_api/wit/since_v0.6.0/common.wit deleted file mode 100644 index 139e7ba0ca..0000000000 --- a/crates/extension_api/wit/since_v0.6.0/common.wit +++ /dev/null @@ -1,12 +0,0 @@ -interface common { - /// A (half-open) range (`[start, end)`). - record range { - /// The start of the range (inclusive). - start: u32, - /// The end of the range (exclusive). - end: u32, - } - - /// A list of environment variables. - type env-vars = list>; -} diff --git a/crates/extension_api/wit/since_v0.6.0/context-server.wit b/crates/extension_api/wit/since_v0.6.0/context-server.wit deleted file mode 100644 index 7234e0e6d0..0000000000 --- a/crates/extension_api/wit/since_v0.6.0/context-server.wit +++ /dev/null @@ -1,11 +0,0 @@ -interface context-server { - /// Configuration for context server setup and installation. - record context-server-configuration { - /// Installation instructions in Markdown format. - installation-instructions: string, - /// JSON schema for settings validation. - settings-schema: string, - /// Default settings template. - default-settings: string, - } -} diff --git a/crates/extension_api/wit/since_v0.6.0/dap.wit b/crates/extension_api/wit/since_v0.6.0/dap.wit deleted file mode 100644 index 693befe02f..0000000000 --- a/crates/extension_api/wit/since_v0.6.0/dap.wit +++ /dev/null @@ -1,123 +0,0 @@ -interface dap { - use common.{env-vars}; - - /// Resolves a specified TcpArgumentsTemplate into TcpArguments - resolve-tcp-template: func(template: tcp-arguments-template) -> result; - - record launch-request { - program: string, - cwd: option, - args: list, - envs: env-vars, - } - - record attach-request { - process-id: option, - } - - variant debug-request { - launch(launch-request), - attach(attach-request) - } - - record tcp-arguments { - port: u16, - host: u32, - timeout: option, - } - - record tcp-arguments-template { - port: option, - host: option, - timeout: option, - } - - /// Debug Config is the "highest-level" configuration for a debug session. - /// It comes from a new process modal UI; thus, it is essentially debug-adapter-agnostic. - /// It is expected of the extension to translate this generic configuration into something that can be debugged by the adapter (debug scenario). - record debug-config { - /// Name of the debug task - label: string, - /// The debug adapter to use - adapter: string, - request: debug-request, - stop-on-entry: option, - } - - record task-template { - /// Human readable name of the task to display in the UI. - label: string, - /// Executable command to spawn. - command: string, - args: list, - env: env-vars, - cwd: option, - } - - /// A task template with substituted task variables. - type resolved-task = task-template; - - /// A task template for building a debug target. - type build-task-template = task-template; - - variant build-task-definition { - by-name(string), - template(build-task-definition-template-payload ) - } - record build-task-definition-template-payload { - locator-name: option, - template: build-task-template - } - - /// Debug Scenario is the user-facing configuration type (used in debug.json). It is still concerned with what to debug and not necessarily how to do it (except for any - /// debug-adapter-specific configuration options). - record debug-scenario { - /// Unsubstituted label for the task.DebugAdapterBinary - label: string, - /// Name of the Debug Adapter this configuration is intended for. - adapter: string, - /// An optional build step to be ran prior to starting a debug session. Build steps are used by Zed's locators to locate the executable to debug. - build: option, - /// JSON-encoded configuration for a given debug adapter. - config: string, - /// TCP connection parameters (if they were specified by user) - tcp-connection: option, - } - - enum start-debugging-request-arguments-request { - launch, - attach, - } - - record debug-task-definition { - /// Unsubstituted label for the task.DebugAdapterBinary - label: string, - /// Name of the Debug Adapter this configuration is intended for. - adapter: string, - /// JSON-encoded configuration for a given debug adapter. - config: string, - /// TCP connection parameters (if they were specified by user) - tcp-connection: option, - } - - record start-debugging-request-arguments { - /// JSON-encoded configuration for a given debug adapter. It is specific to each debug adapter. - /// `configuration` will have it's Zed variable references substituted prior to being passed to the debug adapter. - configuration: string, - request: start-debugging-request-arguments-request, - } - - /// The lowest-level representation of a debug session, which specifies: - /// - How to start a debug adapter process - /// - How to start a debug session with it (using DAP protocol) - /// for a given debug scenario. - record debug-adapter-binary { - command: option, - arguments: list, - envs: env-vars, - cwd: option, - /// Zed will use TCP transport if `connection` is specified. - connection: option, - request-args: start-debugging-request-arguments - } -} diff --git a/crates/extension_api/wit/since_v0.6.0/extension.wit b/crates/extension_api/wit/since_v0.6.0/extension.wit deleted file mode 100644 index 8195162b89..0000000000 --- a/crates/extension_api/wit/since_v0.6.0/extension.wit +++ /dev/null @@ -1,167 +0,0 @@ -package zed:extension; - -world extension { - import context-server; - import dap; - import github; - import http-client; - import platform; - import process; - import nodejs; - - use common.{env-vars, range}; - use context-server.{context-server-configuration}; - use dap.{attach-request, build-task-template, debug-config, debug-adapter-binary, debug-task-definition, debug-request, debug-scenario, launch-request, resolved-task, start-debugging-request-arguments-request}; - use lsp.{completion, symbol}; - use process.{command}; - use slash-command.{slash-command, slash-command-argument-completion, slash-command-output}; - - /// Initializes the extension. - export init-extension: func(); - - /// The type of a downloaded file. - enum downloaded-file-type { - /// A gzipped file (`.gz`). - gzip, - /// A gzipped tar archive (`.tar.gz`). - gzip-tar, - /// A ZIP file (`.zip`). - zip, - /// An uncompressed file. - uncompressed, - } - - /// The installation status for a language server. - variant language-server-installation-status { - /// The language server has no installation status. - none, - /// The language server is being downloaded. - downloading, - /// The language server is checking for updates. - checking-for-update, - /// The language server installation failed for specified reason. - failed(string), - } - - record settings-location { - worktree-id: u64, - path: string, - } - - import get-settings: func(path: option, category: string, key: option) -> result; - - /// Downloads a file from the given URL and saves it to the given path within the extension's - /// working directory. - /// - /// The file will be extracted according to the given file type. - import download-file: func(url: string, file-path: string, file-type: downloaded-file-type) -> result<_, string>; - - /// Makes the file at the given path executable. - import make-file-executable: func(filepath: string) -> result<_, string>; - - /// Updates the installation status for the given language server. - import set-language-server-installation-status: func(language-server-name: string, status: language-server-installation-status); - - /// A Zed worktree. - resource worktree { - /// Returns the ID of the worktree. - id: func() -> u64; - /// Returns the root path of the worktree. - root-path: func() -> string; - /// Returns the textual contents of the specified file in the worktree. - read-text-file: func(path: string) -> result; - /// Returns the path to the given binary name, if one is present on the `$PATH`. - which: func(binary-name: string) -> option; - /// Returns the current shell environment. - shell-env: func() -> env-vars; - } - - /// A Zed project. - resource project { - /// Returns the IDs of all of the worktrees in this project. - worktree-ids: func() -> list; - } - - /// A key-value store. - resource key-value-store { - /// Inserts an entry under the specified key. - insert: func(key: string, value: string) -> result<_, string>; - } - - /// Returns the command used to start up the language server. - export language-server-command: func(language-server-id: string, worktree: borrow) -> result; - - /// Returns the initialization options to pass to the language server on startup. - /// - /// The initialization options are represented as a JSON string. - export language-server-initialization-options: func(language-server-id: string, worktree: borrow) -> result, string>; - - /// Returns the workspace configuration options to pass to the language server. - export language-server-workspace-configuration: func(language-server-id: string, worktree: borrow) -> result, string>; - - /// Returns the initialization options to pass to the other language server. - export language-server-additional-initialization-options: func(language-server-id: string, target-language-server-id: string, worktree: borrow) -> result, string>; - - /// Returns the workspace configuration options to pass to the other language server. - export language-server-additional-workspace-configuration: func(language-server-id: string, target-language-server-id: string, worktree: borrow) -> result, string>; - - /// A label containing some code. - record code-label { - /// The source code to parse with Tree-sitter. - code: string, - /// The spans to display in the label. - spans: list, - /// The range of the displayed label to include when filtering. - filter-range: range, - } - - /// A span within a code label. - variant code-label-span { - /// A range into the parsed code. - code-range(range), - /// A span containing a code literal. - literal(code-label-span-literal), - } - - /// A span containing a code literal. - record code-label-span-literal { - /// The literal text. - text: string, - /// The name of the highlight to use for this literal. - highlight-name: option, - } - - export labels-for-completions: func(language-server-id: string, completions: list) -> result>, string>; - export labels-for-symbols: func(language-server-id: string, symbols: list) -> result>, string>; - - - /// Returns the completions that should be shown when completing the provided slash command with the given query. - export complete-slash-command-argument: func(command: slash-command, args: list) -> result, string>; - - /// Returns the output from running the provided slash command. - export run-slash-command: func(command: slash-command, args: list, worktree: option>) -> result; - - /// Returns the command used to start up a context server. - export context-server-command: func(context-server-id: string, project: borrow) -> result; - - /// Returns the configuration for a context server. - export context-server-configuration: func(context-server-id: string, project: borrow) -> result, string>; - - /// Returns a list of packages as suggestions to be included in the `/docs` - /// search results. - /// - /// This can be used to provide completions for known packages (e.g., from the - /// local project or a registry) before a package has been indexed. - export suggest-docs-packages: func(provider-name: string) -> result, string>; - - /// Indexes the docs for the specified package. - export index-docs: func(provider-name: string, package-name: string, database: borrow) -> result<_, string>; - - /// Returns a configured debug adapter binary for a given debug task. - export get-dap-binary: func(adapter-name: string, config: debug-task-definition, user-installed-path: option, worktree: borrow) -> result; - /// Returns the kind of a debug scenario (launch or attach). - export dap-request-kind: func(adapter-name: string, config: string) -> result; - export dap-config-to-scenario: func(config: debug-config) -> result; - export dap-locator-create-scenario: func(locator-name: string, build-config-template: build-task-template, resolved-label: string, debug-adapter-name: string) -> option; - export run-dap-locator: func(locator-name: string, config: resolved-task) -> result; -} diff --git a/crates/extension_api/wit/since_v0.6.0/github.wit b/crates/extension_api/wit/since_v0.6.0/github.wit deleted file mode 100644 index 21cd5d4805..0000000000 --- a/crates/extension_api/wit/since_v0.6.0/github.wit +++ /dev/null @@ -1,35 +0,0 @@ -interface github { - /// A GitHub release. - record github-release { - /// The version of the release. - version: string, - /// The list of assets attached to the release. - assets: list, - } - - /// An asset from a GitHub release. - record github-release-asset { - /// The name of the asset. - name: string, - /// The download URL for the asset. - download-url: string, - } - - /// The options used to filter down GitHub releases. - record github-release-options { - /// Whether releases without assets should be included. - require-assets: bool, - /// Whether pre-releases should be included. - pre-release: bool, - } - - /// Returns the latest release for the given GitHub repository. - /// - /// Takes repo as a string in the form "/", for example: "zed-industries/zed". - latest-github-release: func(repo: string, options: github-release-options) -> result; - - /// Returns the GitHub release with the specified tag name for the given GitHub repository. - /// - /// Returns an error if a release with the given tag name does not exist. - github-release-by-tag-name: func(repo: string, tag: string) -> result; -} diff --git a/crates/extension_api/wit/since_v0.6.0/http-client.wit b/crates/extension_api/wit/since_v0.6.0/http-client.wit deleted file mode 100644 index bb0206c17a..0000000000 --- a/crates/extension_api/wit/since_v0.6.0/http-client.wit +++ /dev/null @@ -1,67 +0,0 @@ -interface http-client { - /// An HTTP request. - record http-request { - /// The HTTP method for the request. - method: http-method, - /// The URL to which the request should be made. - url: string, - /// The headers for the request. - headers: list>, - /// The request body. - body: option>, - /// The policy to use for redirects. - redirect-policy: redirect-policy, - } - - /// HTTP methods. - enum http-method { - /// `GET` - get, - /// `HEAD` - head, - /// `POST` - post, - /// `PUT` - put, - /// `DELETE` - delete, - /// `OPTIONS` - options, - /// `PATCH` - patch, - } - - /// The policy for dealing with redirects received from the server. - variant redirect-policy { - /// Redirects from the server will not be followed. - /// - /// This is the default behavior. - no-follow, - /// Redirects from the server will be followed up to the specified limit. - follow-limit(u32), - /// All redirects from the server will be followed. - follow-all, - } - - /// An HTTP response. - record http-response { - /// The response headers. - headers: list>, - /// The response body. - body: list, - } - - /// Performs an HTTP request and returns the response. - fetch: func(req: http-request) -> result; - - /// An HTTP response stream. - resource http-response-stream { - /// Retrieves the next chunk of data from the response stream. - /// - /// Returns `Ok(None)` if the stream has ended. - next-chunk: func() -> result>, string>; - } - - /// Performs an HTTP request and returns a response stream. - fetch-stream: func(req: http-request) -> result; -} diff --git a/crates/extension_api/wit/since_v0.6.0/lsp.wit b/crates/extension_api/wit/since_v0.6.0/lsp.wit deleted file mode 100644 index 91a36c93a6..0000000000 --- a/crates/extension_api/wit/since_v0.6.0/lsp.wit +++ /dev/null @@ -1,90 +0,0 @@ -interface lsp { - /// An LSP completion. - record completion { - label: string, - label-details: option, - detail: option, - kind: option, - insert-text-format: option, - } - - /// The kind of an LSP completion. - variant completion-kind { - text, - method, - function, - %constructor, - field, - variable, - class, - %interface, - module, - property, - unit, - value, - %enum, - keyword, - snippet, - color, - file, - reference, - folder, - enum-member, - constant, - struct, - event, - operator, - type-parameter, - other(s32), - } - - /// Label details for an LSP completion. - record completion-label-details { - detail: option, - description: option, - } - - /// Defines how to interpret the insert text in a completion item. - variant insert-text-format { - plain-text, - snippet, - other(s32), - } - - /// An LSP symbol. - record symbol { - kind: symbol-kind, - name: string, - } - - /// The kind of an LSP symbol. - variant symbol-kind { - file, - module, - namespace, - %package, - class, - method, - property, - field, - %constructor, - %enum, - %interface, - function, - variable, - constant, - %string, - number, - boolean, - array, - object, - key, - null, - enum-member, - struct, - event, - operator, - type-parameter, - other(s32), - } -} diff --git a/crates/extension_api/wit/since_v0.6.0/nodejs.wit b/crates/extension_api/wit/since_v0.6.0/nodejs.wit deleted file mode 100644 index c814548314..0000000000 --- a/crates/extension_api/wit/since_v0.6.0/nodejs.wit +++ /dev/null @@ -1,13 +0,0 @@ -interface nodejs { - /// Returns the path to the Node binary used by Zed. - node-binary-path: func() -> result; - - /// Returns the latest version of the given NPM package. - npm-package-latest-version: func(package-name: string) -> result; - - /// Returns the installed version of the given NPM package, if it exists. - npm-package-installed-version: func(package-name: string) -> result, string>; - - /// Installs the specified NPM package. - npm-install-package: func(package-name: string, version: string) -> result<_, string>; -} diff --git a/crates/extension_api/wit/since_v0.6.0/platform.wit b/crates/extension_api/wit/since_v0.6.0/platform.wit deleted file mode 100644 index 48472a99bc..0000000000 --- a/crates/extension_api/wit/since_v0.6.0/platform.wit +++ /dev/null @@ -1,24 +0,0 @@ -interface platform { - /// An operating system. - enum os { - /// macOS. - mac, - /// Linux. - linux, - /// Windows. - windows, - } - - /// A platform architecture. - enum architecture { - /// AArch64 (e.g., Apple Silicon). - aarch64, - /// x86. - x86, - /// x86-64. - x8664, - } - - /// Gets the current operating system and architecture. - current-platform: func() -> tuple; -} diff --git a/crates/extension_api/wit/since_v0.6.0/process.wit b/crates/extension_api/wit/since_v0.6.0/process.wit deleted file mode 100644 index d9a5728a3d..0000000000 --- a/crates/extension_api/wit/since_v0.6.0/process.wit +++ /dev/null @@ -1,29 +0,0 @@ -interface process { - use common.{env-vars}; - - /// A command. - record command { - /// The command to execute. - command: string, - /// The arguments to pass to the command. - args: list, - /// The environment variables to set for the command. - env: env-vars, - } - - /// The output of a finished process. - record output { - /// The status (exit code) of the process. - /// - /// On Unix, this will be `None` if the process was terminated by a signal. - status: option, - /// The data that the process wrote to stdout. - stdout: list, - /// The data that the process wrote to stderr. - stderr: list, - } - - /// Executes the given command as a child process, waiting for it to finish - /// and collecting all of its output. - run-command: func(command: command) -> result; -} diff --git a/crates/extension_api/wit/since_v0.6.0/settings.rs b/crates/extension_api/wit/since_v0.6.0/settings.rs deleted file mode 100644 index 19e28c1ba9..0000000000 --- a/crates/extension_api/wit/since_v0.6.0/settings.rs +++ /dev/null @@ -1,40 +0,0 @@ -use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, num::NonZeroU32}; - -/// The settings for a particular language. -#[derive(Debug, Serialize, Deserialize)] -pub struct LanguageSettings { - /// How many columns a tab should occupy. - pub tab_size: NonZeroU32, -} - -/// The settings for a particular language server. -#[derive(Default, Debug, Serialize, Deserialize)] -pub struct LspSettings { - /// The settings for the language server binary. - pub binary: Option, - /// The initialization options to pass to the language server. - pub initialization_options: Option, - /// The settings to pass to language server. - pub settings: Option, -} - -/// The settings for a particular context server. -#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Eq)] -pub struct ContextServerSettings { - /// The settings for the context server binary. - pub command: Option, - /// The settings to pass to the context server. - pub settings: Option, -} - -/// The settings for a command. -#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] -pub struct CommandSettings { - /// The path to the command. - pub path: Option, - /// The arguments to pass to the command. - pub arguments: Option>, - /// The environment variables. - pub env: Option>, -} diff --git a/crates/extension_api/wit/since_v0.6.0/slash-command.wit b/crates/extension_api/wit/since_v0.6.0/slash-command.wit deleted file mode 100644 index f52561c2ef..0000000000 --- a/crates/extension_api/wit/since_v0.6.0/slash-command.wit +++ /dev/null @@ -1,41 +0,0 @@ -interface slash-command { - use common.{range}; - - /// A slash command for use in the Assistant. - record slash-command { - /// The name of the slash command. - name: string, - /// The description of the slash command. - description: string, - /// The tooltip text to display for the run button. - tooltip-text: string, - /// Whether this slash command requires an argument. - requires-argument: bool, - } - - /// The output of a slash command. - record slash-command-output { - /// The text produced by the slash command. - text: string, - /// The list of sections to show in the slash command placeholder. - sections: list, - } - - /// A section in the slash command output. - record slash-command-output-section { - /// The range this section occupies. - range: range, - /// The label to display in the placeholder for this section. - label: string, - } - - /// A completion for a slash command argument. - record slash-command-argument-completion { - /// The label to display for this completion. - label: string, - /// The new text that should be inserted into the command when this completion is accepted. - new-text: string, - /// Whether the command should be run when accepting this completion. - run-command: bool, - } -} diff --git a/crates/extension_api/wit/since_v0.8.0/common.wit b/crates/extension_api/wit/since_v0.8.0/common.wit deleted file mode 100644 index 139e7ba0ca..0000000000 --- a/crates/extension_api/wit/since_v0.8.0/common.wit +++ /dev/null @@ -1,12 +0,0 @@ -interface common { - /// A (half-open) range (`[start, end)`). - record range { - /// The start of the range (inclusive). - start: u32, - /// The end of the range (exclusive). - end: u32, - } - - /// A list of environment variables. - type env-vars = list>; -} diff --git a/crates/extension_api/wit/since_v0.8.0/context-server.wit b/crates/extension_api/wit/since_v0.8.0/context-server.wit deleted file mode 100644 index 7234e0e6d0..0000000000 --- a/crates/extension_api/wit/since_v0.8.0/context-server.wit +++ /dev/null @@ -1,11 +0,0 @@ -interface context-server { - /// Configuration for context server setup and installation. - record context-server-configuration { - /// Installation instructions in Markdown format. - installation-instructions: string, - /// JSON schema for settings validation. - settings-schema: string, - /// Default settings template. - default-settings: string, - } -} diff --git a/crates/extension_api/wit/since_v0.8.0/dap.wit b/crates/extension_api/wit/since_v0.8.0/dap.wit deleted file mode 100644 index 693befe02f..0000000000 --- a/crates/extension_api/wit/since_v0.8.0/dap.wit +++ /dev/null @@ -1,123 +0,0 @@ -interface dap { - use common.{env-vars}; - - /// Resolves a specified TcpArgumentsTemplate into TcpArguments - resolve-tcp-template: func(template: tcp-arguments-template) -> result; - - record launch-request { - program: string, - cwd: option, - args: list, - envs: env-vars, - } - - record attach-request { - process-id: option, - } - - variant debug-request { - launch(launch-request), - attach(attach-request) - } - - record tcp-arguments { - port: u16, - host: u32, - timeout: option, - } - - record tcp-arguments-template { - port: option, - host: option, - timeout: option, - } - - /// Debug Config is the "highest-level" configuration for a debug session. - /// It comes from a new process modal UI; thus, it is essentially debug-adapter-agnostic. - /// It is expected of the extension to translate this generic configuration into something that can be debugged by the adapter (debug scenario). - record debug-config { - /// Name of the debug task - label: string, - /// The debug adapter to use - adapter: string, - request: debug-request, - stop-on-entry: option, - } - - record task-template { - /// Human readable name of the task to display in the UI. - label: string, - /// Executable command to spawn. - command: string, - args: list, - env: env-vars, - cwd: option, - } - - /// A task template with substituted task variables. - type resolved-task = task-template; - - /// A task template for building a debug target. - type build-task-template = task-template; - - variant build-task-definition { - by-name(string), - template(build-task-definition-template-payload ) - } - record build-task-definition-template-payload { - locator-name: option, - template: build-task-template - } - - /// Debug Scenario is the user-facing configuration type (used in debug.json). It is still concerned with what to debug and not necessarily how to do it (except for any - /// debug-adapter-specific configuration options). - record debug-scenario { - /// Unsubstituted label for the task.DebugAdapterBinary - label: string, - /// Name of the Debug Adapter this configuration is intended for. - adapter: string, - /// An optional build step to be ran prior to starting a debug session. Build steps are used by Zed's locators to locate the executable to debug. - build: option, - /// JSON-encoded configuration for a given debug adapter. - config: string, - /// TCP connection parameters (if they were specified by user) - tcp-connection: option, - } - - enum start-debugging-request-arguments-request { - launch, - attach, - } - - record debug-task-definition { - /// Unsubstituted label for the task.DebugAdapterBinary - label: string, - /// Name of the Debug Adapter this configuration is intended for. - adapter: string, - /// JSON-encoded configuration for a given debug adapter. - config: string, - /// TCP connection parameters (if they were specified by user) - tcp-connection: option, - } - - record start-debugging-request-arguments { - /// JSON-encoded configuration for a given debug adapter. It is specific to each debug adapter. - /// `configuration` will have it's Zed variable references substituted prior to being passed to the debug adapter. - configuration: string, - request: start-debugging-request-arguments-request, - } - - /// The lowest-level representation of a debug session, which specifies: - /// - How to start a debug adapter process - /// - How to start a debug session with it (using DAP protocol) - /// for a given debug scenario. - record debug-adapter-binary { - command: option, - arguments: list, - envs: env-vars, - cwd: option, - /// Zed will use TCP transport if `connection` is specified. - connection: option, - request-args: start-debugging-request-arguments - } -} diff --git a/crates/extension_api/wit/since_v0.8.0/extension.wit b/crates/extension_api/wit/since_v0.8.0/extension.wit deleted file mode 100644 index 8195162b89..0000000000 --- a/crates/extension_api/wit/since_v0.8.0/extension.wit +++ /dev/null @@ -1,167 +0,0 @@ -package zed:extension; - -world extension { - import context-server; - import dap; - import github; - import http-client; - import platform; - import process; - import nodejs; - - use common.{env-vars, range}; - use context-server.{context-server-configuration}; - use dap.{attach-request, build-task-template, debug-config, debug-adapter-binary, debug-task-definition, debug-request, debug-scenario, launch-request, resolved-task, start-debugging-request-arguments-request}; - use lsp.{completion, symbol}; - use process.{command}; - use slash-command.{slash-command, slash-command-argument-completion, slash-command-output}; - - /// Initializes the extension. - export init-extension: func(); - - /// The type of a downloaded file. - enum downloaded-file-type { - /// A gzipped file (`.gz`). - gzip, - /// A gzipped tar archive (`.tar.gz`). - gzip-tar, - /// A ZIP file (`.zip`). - zip, - /// An uncompressed file. - uncompressed, - } - - /// The installation status for a language server. - variant language-server-installation-status { - /// The language server has no installation status. - none, - /// The language server is being downloaded. - downloading, - /// The language server is checking for updates. - checking-for-update, - /// The language server installation failed for specified reason. - failed(string), - } - - record settings-location { - worktree-id: u64, - path: string, - } - - import get-settings: func(path: option, category: string, key: option) -> result; - - /// Downloads a file from the given URL and saves it to the given path within the extension's - /// working directory. - /// - /// The file will be extracted according to the given file type. - import download-file: func(url: string, file-path: string, file-type: downloaded-file-type) -> result<_, string>; - - /// Makes the file at the given path executable. - import make-file-executable: func(filepath: string) -> result<_, string>; - - /// Updates the installation status for the given language server. - import set-language-server-installation-status: func(language-server-name: string, status: language-server-installation-status); - - /// A Zed worktree. - resource worktree { - /// Returns the ID of the worktree. - id: func() -> u64; - /// Returns the root path of the worktree. - root-path: func() -> string; - /// Returns the textual contents of the specified file in the worktree. - read-text-file: func(path: string) -> result; - /// Returns the path to the given binary name, if one is present on the `$PATH`. - which: func(binary-name: string) -> option; - /// Returns the current shell environment. - shell-env: func() -> env-vars; - } - - /// A Zed project. - resource project { - /// Returns the IDs of all of the worktrees in this project. - worktree-ids: func() -> list; - } - - /// A key-value store. - resource key-value-store { - /// Inserts an entry under the specified key. - insert: func(key: string, value: string) -> result<_, string>; - } - - /// Returns the command used to start up the language server. - export language-server-command: func(language-server-id: string, worktree: borrow) -> result; - - /// Returns the initialization options to pass to the language server on startup. - /// - /// The initialization options are represented as a JSON string. - export language-server-initialization-options: func(language-server-id: string, worktree: borrow) -> result, string>; - - /// Returns the workspace configuration options to pass to the language server. - export language-server-workspace-configuration: func(language-server-id: string, worktree: borrow) -> result, string>; - - /// Returns the initialization options to pass to the other language server. - export language-server-additional-initialization-options: func(language-server-id: string, target-language-server-id: string, worktree: borrow) -> result, string>; - - /// Returns the workspace configuration options to pass to the other language server. - export language-server-additional-workspace-configuration: func(language-server-id: string, target-language-server-id: string, worktree: borrow) -> result, string>; - - /// A label containing some code. - record code-label { - /// The source code to parse with Tree-sitter. - code: string, - /// The spans to display in the label. - spans: list, - /// The range of the displayed label to include when filtering. - filter-range: range, - } - - /// A span within a code label. - variant code-label-span { - /// A range into the parsed code. - code-range(range), - /// A span containing a code literal. - literal(code-label-span-literal), - } - - /// A span containing a code literal. - record code-label-span-literal { - /// The literal text. - text: string, - /// The name of the highlight to use for this literal. - highlight-name: option, - } - - export labels-for-completions: func(language-server-id: string, completions: list) -> result>, string>; - export labels-for-symbols: func(language-server-id: string, symbols: list) -> result>, string>; - - - /// Returns the completions that should be shown when completing the provided slash command with the given query. - export complete-slash-command-argument: func(command: slash-command, args: list) -> result, string>; - - /// Returns the output from running the provided slash command. - export run-slash-command: func(command: slash-command, args: list, worktree: option>) -> result; - - /// Returns the command used to start up a context server. - export context-server-command: func(context-server-id: string, project: borrow) -> result; - - /// Returns the configuration for a context server. - export context-server-configuration: func(context-server-id: string, project: borrow) -> result, string>; - - /// Returns a list of packages as suggestions to be included in the `/docs` - /// search results. - /// - /// This can be used to provide completions for known packages (e.g., from the - /// local project or a registry) before a package has been indexed. - export suggest-docs-packages: func(provider-name: string) -> result, string>; - - /// Indexes the docs for the specified package. - export index-docs: func(provider-name: string, package-name: string, database: borrow) -> result<_, string>; - - /// Returns a configured debug adapter binary for a given debug task. - export get-dap-binary: func(adapter-name: string, config: debug-task-definition, user-installed-path: option, worktree: borrow) -> result; - /// Returns the kind of a debug scenario (launch or attach). - export dap-request-kind: func(adapter-name: string, config: string) -> result; - export dap-config-to-scenario: func(config: debug-config) -> result; - export dap-locator-create-scenario: func(locator-name: string, build-config-template: build-task-template, resolved-label: string, debug-adapter-name: string) -> option; - export run-dap-locator: func(locator-name: string, config: resolved-task) -> result; -} diff --git a/crates/extension_api/wit/since_v0.8.0/github.wit b/crates/extension_api/wit/since_v0.8.0/github.wit deleted file mode 100644 index 21cd5d4805..0000000000 --- a/crates/extension_api/wit/since_v0.8.0/github.wit +++ /dev/null @@ -1,35 +0,0 @@ -interface github { - /// A GitHub release. - record github-release { - /// The version of the release. - version: string, - /// The list of assets attached to the release. - assets: list, - } - - /// An asset from a GitHub release. - record github-release-asset { - /// The name of the asset. - name: string, - /// The download URL for the asset. - download-url: string, - } - - /// The options used to filter down GitHub releases. - record github-release-options { - /// Whether releases without assets should be included. - require-assets: bool, - /// Whether pre-releases should be included. - pre-release: bool, - } - - /// Returns the latest release for the given GitHub repository. - /// - /// Takes repo as a string in the form "/", for example: "zed-industries/zed". - latest-github-release: func(repo: string, options: github-release-options) -> result; - - /// Returns the GitHub release with the specified tag name for the given GitHub repository. - /// - /// Returns an error if a release with the given tag name does not exist. - github-release-by-tag-name: func(repo: string, tag: string) -> result; -} diff --git a/crates/extension_api/wit/since_v0.8.0/http-client.wit b/crates/extension_api/wit/since_v0.8.0/http-client.wit deleted file mode 100644 index bb0206c17a..0000000000 --- a/crates/extension_api/wit/since_v0.8.0/http-client.wit +++ /dev/null @@ -1,67 +0,0 @@ -interface http-client { - /// An HTTP request. - record http-request { - /// The HTTP method for the request. - method: http-method, - /// The URL to which the request should be made. - url: string, - /// The headers for the request. - headers: list>, - /// The request body. - body: option>, - /// The policy to use for redirects. - redirect-policy: redirect-policy, - } - - /// HTTP methods. - enum http-method { - /// `GET` - get, - /// `HEAD` - head, - /// `POST` - post, - /// `PUT` - put, - /// `DELETE` - delete, - /// `OPTIONS` - options, - /// `PATCH` - patch, - } - - /// The policy for dealing with redirects received from the server. - variant redirect-policy { - /// Redirects from the server will not be followed. - /// - /// This is the default behavior. - no-follow, - /// Redirects from the server will be followed up to the specified limit. - follow-limit(u32), - /// All redirects from the server will be followed. - follow-all, - } - - /// An HTTP response. - record http-response { - /// The response headers. - headers: list>, - /// The response body. - body: list, - } - - /// Performs an HTTP request and returns the response. - fetch: func(req: http-request) -> result; - - /// An HTTP response stream. - resource http-response-stream { - /// Retrieves the next chunk of data from the response stream. - /// - /// Returns `Ok(None)` if the stream has ended. - next-chunk: func() -> result>, string>; - } - - /// Performs an HTTP request and returns a response stream. - fetch-stream: func(req: http-request) -> result; -} diff --git a/crates/extension_api/wit/since_v0.8.0/lsp.wit b/crates/extension_api/wit/since_v0.8.0/lsp.wit deleted file mode 100644 index 91a36c93a6..0000000000 --- a/crates/extension_api/wit/since_v0.8.0/lsp.wit +++ /dev/null @@ -1,90 +0,0 @@ -interface lsp { - /// An LSP completion. - record completion { - label: string, - label-details: option, - detail: option, - kind: option, - insert-text-format: option, - } - - /// The kind of an LSP completion. - variant completion-kind { - text, - method, - function, - %constructor, - field, - variable, - class, - %interface, - module, - property, - unit, - value, - %enum, - keyword, - snippet, - color, - file, - reference, - folder, - enum-member, - constant, - struct, - event, - operator, - type-parameter, - other(s32), - } - - /// Label details for an LSP completion. - record completion-label-details { - detail: option, - description: option, - } - - /// Defines how to interpret the insert text in a completion item. - variant insert-text-format { - plain-text, - snippet, - other(s32), - } - - /// An LSP symbol. - record symbol { - kind: symbol-kind, - name: string, - } - - /// The kind of an LSP symbol. - variant symbol-kind { - file, - module, - namespace, - %package, - class, - method, - property, - field, - %constructor, - %enum, - %interface, - function, - variable, - constant, - %string, - number, - boolean, - array, - object, - key, - null, - enum-member, - struct, - event, - operator, - type-parameter, - other(s32), - } -} diff --git a/crates/extension_api/wit/since_v0.8.0/nodejs.wit b/crates/extension_api/wit/since_v0.8.0/nodejs.wit deleted file mode 100644 index c814548314..0000000000 --- a/crates/extension_api/wit/since_v0.8.0/nodejs.wit +++ /dev/null @@ -1,13 +0,0 @@ -interface nodejs { - /// Returns the path to the Node binary used by Zed. - node-binary-path: func() -> result; - - /// Returns the latest version of the given NPM package. - npm-package-latest-version: func(package-name: string) -> result; - - /// Returns the installed version of the given NPM package, if it exists. - npm-package-installed-version: func(package-name: string) -> result, string>; - - /// Installs the specified NPM package. - npm-install-package: func(package-name: string, version: string) -> result<_, string>; -} diff --git a/crates/extension_api/wit/since_v0.8.0/platform.wit b/crates/extension_api/wit/since_v0.8.0/platform.wit deleted file mode 100644 index 48472a99bc..0000000000 --- a/crates/extension_api/wit/since_v0.8.0/platform.wit +++ /dev/null @@ -1,24 +0,0 @@ -interface platform { - /// An operating system. - enum os { - /// macOS. - mac, - /// Linux. - linux, - /// Windows. - windows, - } - - /// A platform architecture. - enum architecture { - /// AArch64 (e.g., Apple Silicon). - aarch64, - /// x86. - x86, - /// x86-64. - x8664, - } - - /// Gets the current operating system and architecture. - current-platform: func() -> tuple; -} diff --git a/crates/extension_api/wit/since_v0.8.0/process.wit b/crates/extension_api/wit/since_v0.8.0/process.wit deleted file mode 100644 index d9a5728a3d..0000000000 --- a/crates/extension_api/wit/since_v0.8.0/process.wit +++ /dev/null @@ -1,29 +0,0 @@ -interface process { - use common.{env-vars}; - - /// A command. - record command { - /// The command to execute. - command: string, - /// The arguments to pass to the command. - args: list, - /// The environment variables to set for the command. - env: env-vars, - } - - /// The output of a finished process. - record output { - /// The status (exit code) of the process. - /// - /// On Unix, this will be `None` if the process was terminated by a signal. - status: option, - /// The data that the process wrote to stdout. - stdout: list, - /// The data that the process wrote to stderr. - stderr: list, - } - - /// Executes the given command as a child process, waiting for it to finish - /// and collecting all of its output. - run-command: func(command: command) -> result; -} diff --git a/crates/extension_api/wit/since_v0.8.0/settings.rs b/crates/extension_api/wit/since_v0.8.0/settings.rs deleted file mode 100644 index 19e28c1ba9..0000000000 --- a/crates/extension_api/wit/since_v0.8.0/settings.rs +++ /dev/null @@ -1,40 +0,0 @@ -use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, num::NonZeroU32}; - -/// The settings for a particular language. -#[derive(Debug, Serialize, Deserialize)] -pub struct LanguageSettings { - /// How many columns a tab should occupy. - pub tab_size: NonZeroU32, -} - -/// The settings for a particular language server. -#[derive(Default, Debug, Serialize, Deserialize)] -pub struct LspSettings { - /// The settings for the language server binary. - pub binary: Option, - /// The initialization options to pass to the language server. - pub initialization_options: Option, - /// The settings to pass to language server. - pub settings: Option, -} - -/// The settings for a particular context server. -#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Eq)] -pub struct ContextServerSettings { - /// The settings for the context server binary. - pub command: Option, - /// The settings to pass to the context server. - pub settings: Option, -} - -/// The settings for a command. -#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] -pub struct CommandSettings { - /// The path to the command. - pub path: Option, - /// The arguments to pass to the command. - pub arguments: Option>, - /// The environment variables. - pub env: Option>, -} diff --git a/crates/extension_api/wit/since_v0.8.0/slash-command.wit b/crates/extension_api/wit/since_v0.8.0/slash-command.wit deleted file mode 100644 index f52561c2ef..0000000000 --- a/crates/extension_api/wit/since_v0.8.0/slash-command.wit +++ /dev/null @@ -1,41 +0,0 @@ -interface slash-command { - use common.{range}; - - /// A slash command for use in the Assistant. - record slash-command { - /// The name of the slash command. - name: string, - /// The description of the slash command. - description: string, - /// The tooltip text to display for the run button. - tooltip-text: string, - /// Whether this slash command requires an argument. - requires-argument: bool, - } - - /// The output of a slash command. - record slash-command-output { - /// The text produced by the slash command. - text: string, - /// The list of sections to show in the slash command placeholder. - sections: list, - } - - /// A section in the slash command output. - record slash-command-output-section { - /// The range this section occupies. - range: range, - /// The label to display in the placeholder for this section. - label: string, - } - - /// A completion for a slash command argument. - record slash-command-argument-completion { - /// The label to display for this completion. - label: string, - /// The new text that should be inserted into the command when this completion is accepted. - new-text: string, - /// Whether the command should be run when accepting this completion. - run-command: bool, - } -}