Permet à un plugin de contribuer des commandes slash adossées à une callback, transitant par le registry/contrat unifié (#162) : - sdk/IdeaSDK: manifeste contributes.slashCommands (déclaratif) — pointer bumpé. - domain: source Plugin étendue + effet PluginCallback (la commande ne s'exécute pas directement : elle renvoie une référence à la callback du plugin). - application: registration des commandes plugin dans le registry + exécution renvoyant l'effet PluginCallback ; métadonnées UI suffisantes pour l'autocomplete. - backend + app-tauri: DTO + commandes Tauri listant/invoquant les commandes plugin. - frontend (contrat): types adapters/domain/ports/mock pour pluginCallback et l'invocation avec arguments. L'exécution effective de la callback côté runtime UI est livrée par #166. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
75 lines
2.8 KiB
Rust
75 lines
2.8 KiB
Rust
use app_tauri_lib::dto::{
|
|
PluginAdminDto, PluginContributionSummaryDto, PluginRuntimeContributionCatalogDto,
|
|
PluginRuntimePluginDto,
|
|
};
|
|
use domain::{PluginCapability, PluginContributionSet, PluginLifecycleState, PluginTrustLevel};
|
|
|
|
#[test]
|
|
fn plugin_admin_dto_serialises_exact_contract_shape() {
|
|
let dto = PluginAdminDto {
|
|
id: "dev.acme.gitgraph".to_owned(),
|
|
display_name: "Git Graph".to_owned(),
|
|
publisher: Some("Acme".to_owned()),
|
|
version: "1.2.3".to_owned(),
|
|
description: Some("Graph".to_owned()),
|
|
icon_url: Some("idea-plugin://dev.acme.gitgraph/1.2.3/abc/assets/icon.svg".to_owned()),
|
|
source_kind: "archive".to_owned(),
|
|
source_label: Some("/tmp/gitgraph.ideaplug".to_owned()),
|
|
lifecycle_state: PluginLifecycleState::PendingDisable,
|
|
enabled: false,
|
|
pending_enable_state: Some(false),
|
|
pending_uninstall: false,
|
|
restart_required: true,
|
|
trust_level: PluginTrustLevel::Full,
|
|
contribution_summary: PluginContributionSummaryDto {
|
|
top_level_menus: 1,
|
|
menu_items: 2,
|
|
slash_commands: 3,
|
|
layouts: 3,
|
|
mcp_servers: 4,
|
|
},
|
|
error: None,
|
|
};
|
|
|
|
let value = serde_json::to_value(dto).unwrap();
|
|
assert_eq!(value["displayName"], "Git Graph");
|
|
assert_eq!(value["lifecycleState"], "pending-disable");
|
|
assert_eq!(value["trustLevel"], "full");
|
|
assert_eq!(value["contributionSummary"]["topLevelMenus"], 1);
|
|
assert_eq!(value["contributionSummary"]["slashCommands"], 3);
|
|
}
|
|
|
|
#[test]
|
|
fn runtime_catalog_dto_carries_bundle_hash_and_contributions() {
|
|
let dto = PluginRuntimeContributionCatalogDto {
|
|
plugins: vec![PluginRuntimePluginDto {
|
|
id: "dev.acme.gitgraph".to_owned(),
|
|
display_name: "Git Graph".to_owned(),
|
|
publisher: None,
|
|
version: "1.2.3".to_owned(),
|
|
bundle_url: "idea-plugin://dev.acme.gitgraph/1.2.3/abc/dist/index.js".to_owned(),
|
|
icon_url: None,
|
|
content_hash: "abc".to_owned(),
|
|
capabilities: vec![PluginCapability::Ui, PluginCapability::Tooling],
|
|
activation_scope: domain::PluginActivationScope::Project,
|
|
contributes: PluginContributionSet::default(),
|
|
}],
|
|
};
|
|
|
|
let value = serde_json::to_value(dto).unwrap();
|
|
assert_eq!(
|
|
value["plugins"][0]["bundleUrl"],
|
|
"idea-plugin://dev.acme.gitgraph/1.2.3/abc/dist/index.js"
|
|
);
|
|
assert_eq!(value["plugins"][0]["contentHash"], "abc");
|
|
assert_eq!(
|
|
value["plugins"][0]["capabilities"],
|
|
serde_json::json!(["ui", "tooling"])
|
|
);
|
|
assert_eq!(value["plugins"][0]["activationScope"], "project");
|
|
assert!(value["plugins"][0]["contributes"]["menus"]
|
|
.as_array()
|
|
.unwrap()
|
|
.is_empty());
|
|
}
|