refactor: rename WasmBuildable::repo_url to source_dir (#445)

* refactor: rename WasmBuildable::repo_url to source_dir

The field receives a local directory path (e.g. "tools-src/gmail"), not a
URL. Rename to source_dir to accurately reflect its purpose.

Adds #[serde(alias = "repo_url")] for backwards compatibility with any
previously serialized data.

Closes #329

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* refactor: rename extract_url to extract_source

The function can return a local directory path, not just a URL.
Addresses review feedback on PR #445.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
This commit is contained in:
Zaki Manian
2026-03-01 16:36:46 -08:00
committed by GitHub
co-authored by Claude Opus 4.6
parent bb279ad822
commit a21dba0ac1
5 changed files with 23 additions and 22 deletions
+8 -8
View File
@@ -50,14 +50,14 @@ impl OnlineDiscovery {
let mut candidates: Vec<RegistryEntry> = Vec::new();
for entry in patterns {
let url = extract_url(&entry.source);
let url = extract_source(&entry.source);
if seen_urls.insert(url) {
candidates.push(entry);
}
}
for entry in github.unwrap_or_default() {
let url = extract_url(&entry.source);
let url = extract_source(&entry.source);
if seen_urls.insert(url) {
candidates.push(entry);
}
@@ -242,12 +242,12 @@ async fn with_timeout<T>(
tokio::time::timeout(duration, future).await.ok()
}
fn extract_url(source: &ExtensionSource) -> String {
fn extract_source(source: &ExtensionSource) -> String {
match source {
ExtensionSource::McpUrl { url } => url.clone(),
ExtensionSource::Discovered { url } => url.clone(),
ExtensionSource::WasmDownload { wasm_url, .. } => wasm_url.clone(),
ExtensionSource::WasmBuildable { repo_url, .. } => repo_url.clone(),
ExtensionSource::WasmBuildable { source_dir, .. } => source_dir.clone(),
}
}
@@ -286,7 +286,7 @@ struct GitHubRepo {
mod tests {
use crate::extensions::ExtensionSource;
use crate::extensions::discovery::{
OnlineDiscovery, extract_url, titlecase, validate_mcp_url_with_client,
OnlineDiscovery, extract_source, titlecase, validate_mcp_url_with_client,
};
#[test]
@@ -297,16 +297,16 @@ mod tests {
}
#[test]
fn test_extract_url() {
fn test_extract_source() {
let mcp = ExtensionSource::McpUrl {
url: "https://mcp.notion.com".to_string(),
};
assert_eq!(extract_url(&mcp), "https://mcp.notion.com");
assert_eq!(extract_source(&mcp), "https://mcp.notion.com");
let discovered = ExtensionSource::Discovered {
url: "https://example.com".to_string(),
};
assert_eq!(extract_url(&discovered), "https://example.com");
assert_eq!(extract_source(&discovered), "https://example.com");
}
#[tokio::test]
+1 -1
View File
@@ -2743,7 +2743,7 @@ mod tests {
fn make_fallback_source() -> Option<Box<ExtensionSource>> {
Some(Box::new(ExtensionSource::WasmBuildable {
repo_url: "tools-src/test".to_string(),
source_dir: "tools-src/test".to_string(),
build_dir: Some("tools-src/test".to_string()),
crate_name: Some("test-tool".to_string()),
}))
+3 -2
View File
@@ -83,9 +83,10 @@ pub enum ExtensionSource {
#[serde(default)]
capabilities_url: Option<String>,
},
/// Build from source repository.
/// Build from local source directory.
WasmBuildable {
repo_url: String,
#[serde(alias = "repo_url")]
source_dir: String,
#[serde(default)]
build_dir: Option<String>,
/// Crate name used to locate the build artifact binary.
+10 -10
View File
@@ -605,7 +605,7 @@ mod tests {
description: "Telegram Bot API channel".to_string(),
keywords: vec!["messaging".into(), "bot".into()],
source: ExtensionSource::WasmBuildable {
repo_url: "channels-src/telegram".to_string(),
source_dir: "channels-src/telegram".to_string(),
build_dir: Some("channels-src/telegram".to_string()),
crate_name: Some("telegram-channel".to_string()),
},
@@ -620,7 +620,7 @@ mod tests {
description: "Slack WASM tool".to_string(),
keywords: vec!["messaging".into()],
source: ExtensionSource::WasmBuildable {
repo_url: "tools-src/slack".to_string(),
source_dir: "tools-src/slack".to_string(),
build_dir: Some("tools-src/slack".to_string()),
crate_name: Some("slack-tool".to_string()),
},
@@ -683,7 +683,7 @@ mod tests {
description: "Telegram MTProto tool".to_string(),
keywords: vec!["messaging".into()],
source: ExtensionSource::WasmBuildable {
repo_url: "tools-src/telegram".to_string(),
source_dir: "tools-src/telegram".to_string(),
build_dir: Some("tools-src/telegram".to_string()),
crate_name: Some("telegram-tool".to_string()),
},
@@ -697,7 +697,7 @@ mod tests {
description: "Telegram Bot API channel".to_string(),
keywords: vec!["messaging".into(), "bot".into()],
source: ExtensionSource::WasmBuildable {
repo_url: "channels-src/telegram".to_string(),
source_dir: "channels-src/telegram".to_string(),
build_dir: Some("channels-src/telegram".to_string()),
crate_name: Some("telegram-channel".to_string()),
},
@@ -759,7 +759,7 @@ mod tests {
description: "A cached tool".to_string(),
keywords: vec![],
source: ExtensionSource::WasmBuildable {
repo_url: "tools-src/cached".to_string(),
source_dir: "tools-src/cached".to_string(),
build_dir: None,
crate_name: None,
},
@@ -773,7 +773,7 @@ mod tests {
description: "A cached channel".to_string(),
keywords: vec![],
source: ExtensionSource::WasmBuildable {
repo_url: "channels-src/cached".to_string(),
source_dir: "channels-src/cached".to_string(),
build_dir: None,
crate_name: None,
},
@@ -816,7 +816,7 @@ mod tests {
description: "Telegram messaging channel".to_string(),
keywords: vec!["messaging".into()],
source: ExtensionSource::WasmBuildable {
repo_url: "channels-src/telegram".to_string(),
source_dir: "channels-src/telegram".to_string(),
build_dir: None,
crate_name: None,
},
@@ -830,7 +830,7 @@ mod tests {
description: "Telegram API tool".to_string(),
keywords: vec!["messaging".into()],
source: ExtensionSource::WasmBuildable {
repo_url: "tools-src/telegram".to_string(),
source_dir: "tools-src/telegram".to_string(),
build_dir: None,
crate_name: None,
},
@@ -878,7 +878,7 @@ mod tests {
description: "Channel".to_string(),
keywords: vec![],
source: ExtensionSource::WasmBuildable {
repo_url: "x".to_string(),
source_dir: "x".to_string(),
build_dir: None,
crate_name: None,
},
@@ -892,7 +892,7 @@ mod tests {
description: "Tool".to_string(),
keywords: vec![],
source: ExtensionSource::WasmBuildable {
repo_url: "y".to_string(),
source_dir: "y".to_string(),
build_dir: None,
crate_name: None,
},
+1 -1
View File
@@ -155,7 +155,7 @@ impl ExtensionManifest {
/// extension discovery system.
pub fn to_registry_entry(&self) -> RegistryEntry {
let buildable = ExtensionSource::WasmBuildable {
repo_url: self.source.dir.clone(),
source_dir: self.source.dir.clone(),
build_dir: Some(self.source.dir.clone()),
crate_name: Some(self.source.crate_name.clone()),
};