Rinomina: crate akode-*, cartelle akode-rs/ e akode-cli/, binario akode, ~/.akode, AKODE_* (A)
Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
155
akode-rs/tui/src/app/plugin_mentions.rs
Normal file
155
akode-rs/tui/src/app/plugin_mentions.rs
Normal file
@@ -0,0 +1,155 @@
|
||||
//! Plugin mention capability enrichment for the TUI.
|
||||
//!
|
||||
//! Mention inventory comes from app-server `plugin/installed` so loading
|
||||
//! mentions does not fetch the browsable plugin catalog. The API exposes
|
||||
//! plugin-level mention metadata, but not effective per-session capability summaries.
|
||||
|
||||
use super::*;
|
||||
use akode_app_server_protocol::PluginInstalledParams;
|
||||
use akode_app_server_protocol::PluginInstalledResponse;
|
||||
use akode_app_server_protocol::PluginSummary;
|
||||
use akode_app_server_protocol::RequestId;
|
||||
use akode_plugin::PluginCapabilitySummary;
|
||||
|
||||
pub(super) async fn fetch_plugin_mentions(
|
||||
request_handle: AppServerRequestHandle,
|
||||
cwd: PathBuf,
|
||||
) -> Result<Vec<PluginCapabilitySummary>> {
|
||||
let cwd = AbsolutePathBuf::try_from(cwd).wrap_err("plugin installed cwd must be absolute")?;
|
||||
let request_id = RequestId::String(format!("plugin-installed-{}", Uuid::new_v4()));
|
||||
let response = request_handle
|
||||
.request_typed(ClientRequest::PluginInstalled {
|
||||
request_id,
|
||||
params: PluginInstalledParams {
|
||||
cwds: Some(vec![cwd]),
|
||||
install_suggestion_plugin_names: None,
|
||||
},
|
||||
})
|
||||
.await
|
||||
.wrap_err("plugin/installed failed in TUI")?;
|
||||
Ok(plugin_mentions_from_installed_response(response))
|
||||
}
|
||||
|
||||
fn plugin_mentions_from_installed_response(
|
||||
response: PluginInstalledResponse,
|
||||
) -> Vec<PluginCapabilitySummary> {
|
||||
response
|
||||
.marketplaces
|
||||
.into_iter()
|
||||
.flat_map(|marketplace| {
|
||||
let marketplace_name = marketplace.name;
|
||||
marketplace
|
||||
.plugins
|
||||
.into_iter()
|
||||
.filter_map(move |plugin| plugin_mention_from_summary(&marketplace_name, plugin))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn plugin_is_eligible_for_mentions(plugin: &PluginSummary) -> bool {
|
||||
plugin.installed && plugin.enabled
|
||||
}
|
||||
|
||||
fn plugin_mention_from_summary(
|
||||
marketplace_name: &str,
|
||||
plugin: PluginSummary,
|
||||
) -> Option<PluginCapabilitySummary> {
|
||||
if !plugin_is_eligible_for_mentions(&plugin) {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(PluginCapabilitySummary {
|
||||
config_name: plugin.id.clone(),
|
||||
display_name: plugin_mention_display_name(&plugin),
|
||||
plugin_namespace: Some(plugin.name.clone()),
|
||||
description: plugin_mention_description(marketplace_name, &plugin),
|
||||
has_skills: false,
|
||||
mcp_server_names: Vec::new(),
|
||||
})
|
||||
}
|
||||
|
||||
fn plugin_mention_display_name(plugin: &PluginSummary) -> String {
|
||||
plugin
|
||||
.interface
|
||||
.as_ref()
|
||||
.and_then(|interface| interface.display_name.as_deref())
|
||||
.map(str::trim)
|
||||
.filter(|display_name| !display_name.is_empty())
|
||||
.map(str::to_string)
|
||||
.unwrap_or_else(|| plugin.name.clone())
|
||||
}
|
||||
|
||||
fn plugin_mention_description(marketplace_name: &str, plugin: &PluginSummary) -> Option<String> {
|
||||
plugin
|
||||
.interface
|
||||
.as_ref()
|
||||
.and_then(|interface| interface.short_description.as_deref())
|
||||
.map(str::trim)
|
||||
.filter(|description| !description.is_empty())
|
||||
.map(str::to_string)
|
||||
.or_else(|| {
|
||||
let marketplace_name = marketplace_name.trim();
|
||||
(!marketplace_name.is_empty()).then(|| marketplace_name.to_string())
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use akode_app_server_protocol::PluginAuthPolicy;
|
||||
use akode_app_server_protocol::PluginInstallPolicy;
|
||||
use akode_app_server_protocol::PluginMarketplaceEntry;
|
||||
use akode_app_server_protocol::PluginSource;
|
||||
use akode_utils_absolute_path::AbsolutePathBuf;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn plugin_mentions_use_installed_summaries_and_gui_eligibility() {
|
||||
let active = plugin_summary("active");
|
||||
let active_second = plugin_summary("active-second");
|
||||
let mut disabled = plugin_summary("disabled");
|
||||
disabled.enabled = false;
|
||||
let mut uninstalled = plugin_summary("uninstalled");
|
||||
uninstalled.installed = false;
|
||||
|
||||
let response = PluginInstalledResponse {
|
||||
marketplaces: vec![PluginMarketplaceEntry {
|
||||
name: "server-marketplace".to_string(),
|
||||
path: None,
|
||||
interface: None,
|
||||
plugins: vec![active, active_second, disabled, uninstalled],
|
||||
}],
|
||||
marketplace_load_errors: Vec::new(),
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
plugin_mentions_from_installed_response(response),
|
||||
["active", "active-second"].map(|name| PluginCapabilitySummary {
|
||||
config_name: format!("{name}@server-marketplace"),
|
||||
display_name: name.to_string(),
|
||||
plugin_namespace: Some(name.to_string()),
|
||||
description: Some("server-marketplace".to_string()),
|
||||
has_skills: false,
|
||||
mcp_server_names: Vec::new(),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
fn plugin_summary(name: &str) -> PluginSummary {
|
||||
PluginSummary {
|
||||
id: format!("{name}@server-marketplace"),
|
||||
local_version: None,
|
||||
name: name.to_string(),
|
||||
source: PluginSource::Local {
|
||||
path: AbsolutePathBuf::try_from(std::env::temp_dir().join(name))
|
||||
.expect("absolute plugin path"),
|
||||
},
|
||||
installed: true,
|
||||
enabled: true,
|
||||
install_policy: PluginInstallPolicy::Available,
|
||||
auth_policy: PluginAuthPolicy::OnInstall,
|
||||
interface: None,
|
||||
keywords: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user