From a8c3c1a6a5a7cae7cd6b94c0b65af06e2bb263ba Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Thu, 5 Feb 2026 13:13:02 +0100 Subject: [PATCH] extension_api: Add `digest` to `GithubReleaseAsset` (#48413) Round 2 of #46269 with conflicts properly resolved. This came up a few times across various extensions. With us about to ship a new API version soon, it might be worth to add. Release Notes: - N/A --------- Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com> --- .../extension_api/wit/since_v0.8.0/github.wit | 2 + .../src/wasm_host/wit/since_v0_0_1.rs | 6 +- .../src/wasm_host/wit/since_v0_0_6.rs | 4 +- .../src/wasm_host/wit/since_v0_1_0.rs | 4 +- .../src/wasm_host/wit/since_v0_2_0.rs | 2 +- .../src/wasm_host/wit/since_v0_3_0.rs | 2 +- .../src/wasm_host/wit/since_v0_4_0.rs | 2 +- .../src/wasm_host/wit/since_v0_5_0.rs | 2 +- .../src/wasm_host/wit/since_v0_6_0.rs | 56 +++++++++++++++++-- .../src/wasm_host/wit/since_v0_8_0.rs | 1 + crates/project/src/agent_server_store.rs | 4 +- 11 files changed, 68 insertions(+), 17 deletions(-) diff --git a/crates/extension_api/wit/since_v0.8.0/github.wit b/crates/extension_api/wit/since_v0.8.0/github.wit index 21cd5d48056af08441d3bb5aa8547edd97a874d7..6d7e5d952ae921925459f475bceb74d6c384d8be 100644 --- a/crates/extension_api/wit/since_v0.8.0/github.wit +++ b/crates/extension_api/wit/since_v0.8.0/github.wit @@ -13,6 +13,8 @@ interface github { name: string, /// The download URL for the asset. download-url: string, + /// The SHA-256 of the release asset if provided by the GitHub API. + digest: option, } /// The options used to filter down GitHub releases. diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_0_1.rs b/crates/extension_host/src/wasm_host/wit/since_v0_0_1.rs index 17d5c00a9ad08507bbad39190fdfe5134fe77aa1..fa7539eec9f454c95782cd0249664693074abfba 100644 --- a/crates/extension_host/src/wasm_host/wit/since_v0_0_1.rs +++ b/crates/extension_host/src/wasm_host/wit/since_v0_0_1.rs @@ -1,4 +1,4 @@ -use super::latest; +use super::{latest, since_v0_6_0}; use crate::wasm_host::WasmState; use crate::wasm_host::wit::since_v0_0_4; use anyhow::Result; @@ -17,7 +17,7 @@ wasmtime::component::bindgen!({ path: "../extension_api/wit/since_v0.0.1", with: { "worktree": ExtensionWorktree, - "zed:extension/github": latest::zed::extension::github, + "zed:extension/github": since_v0_6_0::zed::extension::github, "zed:extension/platform": latest::zed::extension::platform, }, }); @@ -120,7 +120,7 @@ impl ExtensionImports for WasmState { repo: String, options: GithubReleaseOptions, ) -> wasmtime::Result> { - latest::zed::extension::github::Host::latest_github_release(self, repo, options).await + since_v0_6_0::zed::extension::github::Host::latest_github_release(self, repo, options).await } async fn current_platform(&mut self) -> Result<(Os, Architecture)> { diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_0_6.rs b/crates/extension_host/src/wasm_host/wit/since_v0_0_6.rs index 835a2b30fbadd3d54649d075b588fd79532c5186..e5ff0322088470d47e903c4a83794b654bbba531 100644 --- a/crates/extension_host/src/wasm_host/wit/since_v0_0_6.rs +++ b/crates/extension_host/src/wasm_host/wit/since_v0_0_6.rs @@ -1,4 +1,4 @@ -use super::{latest, since_v0_1_0}; +use super::{latest, since_v0_1_0, since_v0_6_0}; use crate::wasm_host::WasmState; use anyhow::Result; use extension::WorktreeDelegate; @@ -15,7 +15,7 @@ wasmtime::component::bindgen!({ path: "../extension_api/wit/since_v0.0.6", with: { "worktree": ExtensionWorktree, - "zed:extension/github": latest::zed::extension::github, + "zed:extension/github": since_v0_6_0::zed::extension::github, "zed:extension/lsp": since_v0_1_0::zed::extension::lsp, "zed:extension/nodejs": latest::zed::extension::nodejs, "zed:extension/platform": latest::zed::extension::platform, diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs index 708583410a3f0b3f6949d08a28d82722ec275f11..daee2f37410efa8fe358013c1aefd011833ac368 100644 --- a/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs +++ b/crates/extension_host/src/wasm_host/wit/since_v0_1_0.rs @@ -21,7 +21,7 @@ use util::rel_path::RelPath; use util::{archive::extract_zip, fs::make_file_executable, maybe}; use wasmtime::component::{Linker, Resource}; -use super::latest; +use super::{latest, since_v0_6_0}; pub const MIN_VERSION: Version = Version::new(0, 1, 0); @@ -33,7 +33,7 @@ wasmtime::component::bindgen!({ "worktree": ExtensionWorktree, "key-value-store": ExtensionKeyValueStore, "zed:extension/http-client/http-response-stream": ExtensionHttpResponseStream, - "zed:extension/github": latest::zed::extension::github, + "zed:extension/github": since_v0_6_0::zed::extension::github, "zed:extension/nodejs": latest::zed::extension::nodejs, "zed:extension/platform": latest::zed::extension::platform, "zed:extension/slash-command": latest::zed::extension::slash_command, diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_2_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_2_0.rs index 316648d9f2fc0594dfac9b6d60ac331f568cd762..074cce73c22d547cd3198a672e6f8cdc5f750d49 100644 --- a/crates/extension_host/src/wasm_host/wit/since_v0_2_0.rs +++ b/crates/extension_host/src/wasm_host/wit/since_v0_2_0.rs @@ -18,7 +18,7 @@ wasmtime::component::bindgen!({ "worktree": ExtensionWorktree, "project": ExtensionProject, "key-value-store": ExtensionKeyValueStore, - "zed:extension/github": latest::zed::extension::github, + "zed:extension/github": since_v0_6_0::zed::extension::github, "zed:extension/http-client": latest::zed::extension::http_client, "zed:extension/lsp": since_v0_6_0::zed::extension::lsp, "zed:extension/nodejs": latest::zed::extension::nodejs, diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_3_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_3_0.rs index 6078c85c4d712c990cf4b89072409b44f6f25833..072ad42f2b9c2f5b3a8556b237f3907052665370 100644 --- a/crates/extension_host/src/wasm_host/wit/since_v0_3_0.rs +++ b/crates/extension_host/src/wasm_host/wit/since_v0_3_0.rs @@ -19,7 +19,7 @@ wasmtime::component::bindgen!({ "project": ExtensionProject, "key-value-store": ExtensionKeyValueStore, "zed:extension/common": latest::zed::extension::common, - "zed:extension/github": latest::zed::extension::github, + "zed:extension/github": since_v0_6_0::zed::extension::github, "zed:extension/http-client": latest::zed::extension::http_client, "zed:extension/lsp": since_v0_6_0::zed::extension::lsp, "zed:extension/nodejs": latest::zed::extension::nodejs, diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_4_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_4_0.rs index ea2e07473b85f2f87afa819e438bf925f2b2469a..4f1d5c6a48c13ff09a5c81e2b43683fa50a7ccec 100644 --- a/crates/extension_host/src/wasm_host/wit/since_v0_4_0.rs +++ b/crates/extension_host/src/wasm_host/wit/since_v0_4_0.rs @@ -19,7 +19,7 @@ wasmtime::component::bindgen!({ "project": ExtensionProject, "key-value-store": ExtensionKeyValueStore, "zed:extension/common": latest::zed::extension::common, - "zed:extension/github": latest::zed::extension::github, + "zed:extension/github": since_v0_6_0::zed::extension::github, "zed:extension/http-client": latest::zed::extension::http_client, "zed:extension/lsp": since_v0_6_0::zed::extension::lsp, "zed:extension/nodejs": latest::zed::extension::nodejs, diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_5_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_5_0.rs index e5ad91368d2a1e17d538b692449173886b55d315..84f73f567750081d406b20025f0b4598cfd0f9af 100644 --- a/crates/extension_host/src/wasm_host/wit/since_v0_5_0.rs +++ b/crates/extension_host/src/wasm_host/wit/since_v0_5_0.rs @@ -19,7 +19,7 @@ wasmtime::component::bindgen!({ "project": ExtensionProject, "key-value-store": ExtensionKeyValueStore, "zed:extension/common": latest::zed::extension::common, - "zed:extension/github": latest::zed::extension::github, + "zed:extension/github": since_v0_6_0::zed::extension::github, "zed:extension/http-client": latest::zed::extension::http_client, "zed:extension/lsp": since_v0_6_0::zed::extension::lsp, "zed:extension/nodejs": latest::zed::extension::nodejs, diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_6_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_6_0.rs index 2ffe86128b3e9076713507f1320cd164bbbe8a98..202bcd6ce959b27b3b7ecf8e15830cb1955ec104 100644 --- a/crates/extension_host/src/wasm_host/wit/since_v0_6_0.rs +++ b/crates/extension_host/src/wasm_host/wit/since_v0_6_0.rs @@ -20,7 +20,6 @@ wasmtime::component::bindgen!({ "project": ExtensionProject, "key-value-store": ExtensionKeyValueStore, "zed:extension/common": latest::zed::extension::common, - "zed:extension/github": latest::zed::extension::github, "zed:extension/http-client": latest::zed::extension::http_client, "zed:extension/nodejs": latest::zed::extension::nodejs, "zed:extension/platform": latest::zed::extension::platform, @@ -106,15 +105,55 @@ impl From for latest::DownloadedFileType { } } -impl From for lsp::Symbol { - fn from(value: latest::lsp::Symbol) -> Self { +impl From for github::GithubReleaseAsset { + fn from(value: latest::github::GithubReleaseAsset) -> Self { Self { name: value.name, - kind: value.kind.into(), + download_url: value.download_url, + } + } +} + +impl From for github::GithubRelease { + fn from(value: latest::github::GithubRelease) -> Self { + Self { + version: value.version, + assets: value.assets.into_iter().map(Into::into).collect(), } } } +impl From for latest::github::GithubReleaseOptions { + fn from(value: github::GithubReleaseOptions) -> Self { + Self { + require_assets: value.require_assets, + pre_release: value.pre_release, + } + } +} + +impl zed::extension::github::Host for WasmState { + async fn github_release_by_tag_name( + &mut self, + repo: String, + tag: String, + ) -> wasmtime::Result> { + latest::github::Host::github_release_by_tag_name(self, repo, tag) + .await + .map(|result| result.map(Into::into)) + } + + async fn latest_github_release( + &mut self, + repo: String, + options: github::GithubReleaseOptions, + ) -> wasmtime::Result> { + latest::github::Host::latest_github_release(self, repo, options.into()) + .await + .map(|result| result.map(Into::into)) + } +} + impl From for lsp::Completion { fn from(value: latest::lsp::Completion) -> Self { Self { @@ -127,6 +166,15 @@ impl From for lsp::Completion { } } +impl From for lsp::Symbol { + fn from(value: latest::lsp::Symbol) -> Self { + Self { + name: value.name, + kind: value.kind.into(), + } + } +} + impl From for lsp::CompletionLabelDetails { fn from(value: latest::lsp::CompletionLabelDetails) -> Self { Self { diff --git a/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs b/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs index 55e24d3723a02383d910d312615bc7ee4894cf23..62738c4129e9e64c133a14300bb9ef98b213af49 100644 --- a/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs +++ b/crates/extension_host/src/wasm_host/wit/since_v0_8_0.rs @@ -786,6 +786,7 @@ impl From<::http_client::github::GithubReleaseAsset> for github::GithubReleaseAs Self { name: value.name, download_url: value.browser_download_url, + digest: value.digest, } } } diff --git a/crates/project/src/agent_server_store.rs b/crates/project/src/agent_server_store.rs index 9ddeb0c948f29e24ddec14be75d89f33214fc05b..3ebb9f1143483d7914b35fbe88ce171e741fe86a 100644 --- a/crates/project/src/agent_server_store.rs +++ b/crates/project/src/agent_server_store.rs @@ -1836,10 +1836,10 @@ impl ExternalAgentServer for LocalExtensionArchiveAgent { release.assets.iter().find(|a| a.name == filename) { // Strip "sha256:" prefix if present - asset.digest.as_ref().and_then(|d| { + asset.digest.as_ref().map(|d| { d.strip_prefix("sha256:") .map(|s| s.to_string()) - .or_else(|| Some(d.clone())) + .unwrap_or_else(|| d.clone()) }) } else { None