aKode fase 5: rinomina interna (crate akode-*, akode-rs/, akode-cli/, binario akode, AKODE_*, ~/.akode, snapshot)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
49
akode-rs/core/src/plugins/injection.rs
Normal file
49
akode-rs/core/src/plugins/injection.rs
Normal file
@@ -0,0 +1,49 @@
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use akode_features::Features;
|
||||
use akode_protocol::models::ResponseItem;
|
||||
|
||||
use crate::context::ContextualUserFragment;
|
||||
use crate::context::PluginInstructions;
|
||||
use crate::plugins::PluginCapabilitySummary;
|
||||
use crate::plugins::render_explicit_plugin_instructions;
|
||||
use akode_mcp::ToolInfo;
|
||||
|
||||
pub(crate) fn build_plugin_injections(
|
||||
mentioned_plugins: &[PluginCapabilitySummary],
|
||||
mcp_tools: &[ToolInfo],
|
||||
features: &Features,
|
||||
model_messages: akode_prompts::ResolvedModelMessages<'_>,
|
||||
) -> Vec<ResponseItem> {
|
||||
if mentioned_plugins.is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
|
||||
let messages = model_messages.selected_plugin();
|
||||
// Turn each explicit plugin mention with available capabilities into a developer hint.
|
||||
mentioned_plugins
|
||||
.iter()
|
||||
.filter_map(|plugin| {
|
||||
let available_mcp_servers = mcp_tools
|
||||
.iter()
|
||||
.filter(|tool| {
|
||||
tool.plugin_display_names
|
||||
.iter()
|
||||
.any(|plugin_name| plugin_name == &plugin.display_name)
|
||||
})
|
||||
.map(|tool| tool.server_name.clone())
|
||||
.collect::<BTreeSet<String>>()
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>();
|
||||
render_explicit_plugin_instructions(
|
||||
plugin,
|
||||
&available_mcp_servers,
|
||||
/*available_apps*/ &[],
|
||||
features,
|
||||
&messages,
|
||||
)
|
||||
.map(PluginInstructions::new)
|
||||
.map(ContextualUserFragment::into)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
Reference in New Issue
Block a user