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:
andrea.difonzo
2026-11-17 12:37:52 +01:00
parent e37a0deba9
commit 7c1c6dfa8d
10306 changed files with 748026 additions and 748088 deletions

View File

@@ -0,0 +1,118 @@
//! Temporary cleanup-hook allowlist shared by local and executor plugin discovery.
//! This narrowly authorizes known MCP cleanup calls; it does not verify plugin signatures.
use akode_config::HookHandlerConfig;
use akode_protocol::protocol::HookEventName;
struct BundledHook {
plugin_id: &'static str,
events: &'static [HookEventName],
target: BundledHookTarget,
}
enum BundledHookTarget {
McpServer {
server: &'static str,
tool: &'static str,
},
}
// Keep unsigned plugin exceptions together so they can be removed as signing lands.
const ALLOWLISTED_BUNDLED_HOOKS: &[BundledHook] = &[
BundledHook {
plugin_id: "browser@openai-bundled",
events: &[
HookEventName::Stop,
HookEventName::Interrupt,
HookEventName::SubagentStop,
],
target: BundledHookTarget::McpServer {
server: "node_repl",
tool: "turn_ended",
},
},
BundledHook {
plugin_id: "chrome@openai-bundled",
events: &[
HookEventName::Stop,
HookEventName::Interrupt,
HookEventName::SubagentStop,
],
target: BundledHookTarget::McpServer {
server: "node_repl",
tool: "turn_ended",
},
},
BundledHook {
plugin_id: "chrome-dev@openai-bundled",
events: &[
HookEventName::Stop,
HookEventName::Interrupt,
HookEventName::SubagentStop,
],
target: BundledHookTarget::McpServer {
server: "node_repl",
tool: "turn_ended",
},
},
BundledHook {
plugin_id: "chrome-internal@openai-bundled",
events: &[
HookEventName::Stop,
HookEventName::Interrupt,
HookEventName::SubagentStop,
],
target: BundledHookTarget::McpServer {
server: "node_repl",
tool: "turn_ended",
},
},
BundledHook {
plugin_id: "computer-use@openai-bundled",
events: &[
HookEventName::Stop,
HookEventName::Interrupt,
HookEventName::SubagentStop,
],
target: BundledHookTarget::McpServer {
server: "node_repl",
tool: "turn_ended",
},
},
BundledHook {
plugin_id: "unified-computer-use@openai-bundled",
events: &[
HookEventName::Stop,
HookEventName::Interrupt,
HookEventName::SubagentStop,
],
target: BundledHookTarget::McpServer {
server: "cua_repl",
tool: "turn_ended",
},
},
];
/// Matches a temporary unsigned cleanup exception.
pub fn is_allowlisted_bundled_cleanup_hook(
plugin_id: &str,
event: HookEventName,
matcher: Option<&str>,
handler: &HookHandlerConfig,
) -> bool {
let HookHandlerConfig::McpTool { server, tool, .. } = handler else {
return false;
};
matcher.is_none()
&& ALLOWLISTED_BUNDLED_HOOKS.iter().any(|hook| {
hook.plugin_id == plugin_id
&& hook.events.contains(&event)
&& match hook.target {
BundledHookTarget::McpServer {
server: expected_server,
tool: expected_tool,
} => server == expected_server && tool == expected_tool,
}
})
}

View File

@@ -0,0 +1,70 @@
//! Shared plugin package models, identifiers, and telemetry summaries.
pub use akode_utils_plugins::mention_syntax;
mod bundled_hooks;
mod load_outcome;
pub mod manifest;
use akode_core_plugin_common::plugin_id;
mod provider;
pub use bundled_hooks::is_allowlisted_bundled_cleanup_hook;
use akode_config::HookEventsToml;
use akode_utils_absolute_path::AbsolutePathBuf;
use akode_utils_path_uri::PathUri;
pub use load_outcome::LoadedPlugin;
pub use load_outcome::PluginLoadOutcome;
pub use load_outcome::prompt_safe_plugin_description;
pub use plugin_id::PluginId;
pub use plugin_id::PluginIdError;
pub use plugin_id::validate_plugin_segment;
pub use provider::PluginResourceLocator;
pub use provider::ResolvedPlugin;
pub use provider::ResolvedPluginError;
pub use provider::ResolvedPluginLocation;
use serde_json::Map;
use serde_json::Value;
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct PluginCapabilitySummary {
pub config_name: String,
pub display_name: String,
pub plugin_namespace: Option<String>,
pub description: Option<String>,
pub has_skills: bool,
pub mcp_server_names: Vec<String>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PluginHookSource {
pub plugin_id: PluginId,
pub plugin_root: AbsolutePathBuf,
pub plugin_data_root: AbsolutePathBuf,
pub source_path: AbsolutePathBuf,
pub source_relative_path: String,
pub hooks: HookEventsToml,
}
/// Inline plugin hooks discovered in an executor environment.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ExecutorPluginHookSource {
pub plugin_id: PluginId,
pub environment_id: String,
/// An admitted MCP target can run outside the plugin's source environment.
pub mcp_environment_id: Option<String>,
/// Trusted MCP routing metadata for this cleanup target.
pub mcp_metadata: Option<Map<String, Value>>,
pub plugin_root: PathUri,
pub manifest_path: PathUri,
pub source_relative_path: String,
pub hooks: HookEventsToml,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PluginTelemetryMetadata {
/// Local plugin identifier used by Codex configuration and the plugin cache,
/// when it has been resolved.
pub plugin_id: Option<PluginId>,
pub capability_summary: Option<PluginCapabilitySummary>,
}

View File

@@ -0,0 +1,254 @@
use std::collections::HashMap;
use std::collections::HashSet;
use akode_utils_absolute_path::AbsolutePathBuf;
use akode_utils_path_uri::PathUri;
use akode_utils_plugins::PluginIdentity;
use akode_utils_plugins::PluginSkillRoot;
use akode_utils_plugins::SkillDiscoveryMode;
use crate::PluginCapabilitySummary;
use crate::PluginHookSource;
const MAX_CAPABILITY_SUMMARY_DESCRIPTION_LEN: usize = 1024;
/// A plugin that was loaded from disk, including merged MCP server definitions.
#[derive(Debug, Clone, PartialEq)]
pub struct LoadedPlugin<M> {
pub config_name: String,
pub manifest_name: Option<String>,
pub plugin_namespace: Option<String>,
pub manifest_description: Option<String>,
pub root: AbsolutePathBuf,
pub enabled: bool,
pub skill_roots: Vec<AbsolutePathBuf>,
pub skill_discovery_mode: SkillDiscoveryMode,
pub disabled_skill_paths: HashSet<PathUri>,
pub has_enabled_skills: bool,
pub mcp_servers: HashMap<String, M>,
pub hook_sources: Vec<PluginHookSource>,
pub hook_load_warnings: Vec<String>,
pub error: Option<String>,
}
impl<M> LoadedPlugin<M> {
pub fn is_active(&self) -> bool {
self.enabled && self.error.is_none()
}
pub fn display_name(&self) -> &str {
self.manifest_name.as_deref().unwrap_or(&self.config_name)
}
pub fn is_agent_plugin(&self) -> bool {
self.skill_discovery_mode == SkillDiscoveryMode::DirectChildren
}
}
fn plugin_capability_summary_from_loaded<M>(
plugin: &LoadedPlugin<M>,
) -> Option<PluginCapabilitySummary> {
if !plugin.is_active() {
return None;
}
let mut mcp_server_names: Vec<String> = plugin.mcp_servers.keys().cloned().collect();
mcp_server_names.sort_unstable();
let summary = PluginCapabilitySummary {
config_name: plugin.config_name.clone(),
display_name: plugin.display_name().to_string(),
plugin_namespace: plugin.plugin_namespace.clone(),
description: prompt_safe_plugin_description(plugin.manifest_description.as_deref()),
has_skills: plugin.has_enabled_skills,
mcp_server_names,
};
(summary.has_skills || !summary.mcp_server_names.is_empty()).then_some(summary)
}
/// Normalizes plugin descriptions for inclusion in model-facing capability summaries.
pub fn prompt_safe_plugin_description(description: Option<&str>) -> Option<String> {
let description = description?
.split_whitespace()
.collect::<Vec<_>>()
.join(" ");
if description.is_empty() {
return None;
}
Some(
description
.chars()
.take(MAX_CAPABILITY_SUMMARY_DESCRIPTION_LEN)
.collect(),
)
}
/// Runtime view of loaded plugins and their derived capability summaries.
///
/// Runtime exclusions retain loaded metadata while removing derived capabilities.
#[derive(Debug, Clone, PartialEq)]
pub struct PluginLoadOutcome<M> {
plugins: Vec<LoadedPlugin<M>>,
capability_summaries: Vec<PluginCapabilitySummary>,
}
impl<M: Clone> Default for PluginLoadOutcome<M> {
fn default() -> Self {
Self::from_plugins(Vec::new())
}
}
impl<M: Clone> PluginLoadOutcome<M> {
pub fn from_plugins(plugins: Vec<LoadedPlugin<M>>) -> Self {
let capability_summaries = plugins
.iter()
.filter_map(plugin_capability_summary_from_loaded)
.collect::<Vec<_>>();
Self {
plugins,
capability_summaries,
}
}
/// Marks matching canonical plugin IDs inactive while retaining their loaded metadata.
pub fn without_plugins(mut self, disabled_plugin_ids: &[String]) -> Self {
if disabled_plugin_ids.is_empty() {
return self;
}
for plugin in &mut self.plugins {
if disabled_plugin_ids.contains(&plugin.config_name) {
plugin.enabled = false;
}
}
Self::from_plugins(self.plugins)
}
pub fn effective_plugin_skill_roots(&self) -> Vec<PluginSkillRoot> {
let mut skill_roots = Vec::new();
let mut seen_paths = HashSet::new();
for plugin in self.plugins.iter().filter(|plugin| plugin.is_active()) {
let Some(plugin_namespace) = &plugin.plugin_namespace else {
continue;
};
for path in &plugin.skill_roots {
if seen_paths.insert(path.clone()) {
skill_roots.push(PluginSkillRoot {
path: path.clone(),
plugin_identity: PluginIdentity {
plugin_id: plugin.config_name.clone(),
},
plugin_namespace: plugin_namespace.clone(),
plugin_root: plugin.root.clone(),
discovery_mode: plugin.skill_discovery_mode,
});
}
}
}
skill_roots.sort_unstable_by(|a, b| a.path.cmp(&b.path));
skill_roots
}
pub fn effective_mcp_servers(&self) -> HashMap<String, M> {
let mut mcp_servers = HashMap::new();
for plugin in self.plugins.iter().filter(|plugin| plugin.is_active()) {
for (name, config) in &plugin.mcp_servers {
mcp_servers
.entry(name.clone())
.or_insert_with(|| config.clone());
}
}
mcp_servers
}
pub fn effective_plugin_hook_sources(&self) -> Vec<PluginHookSource> {
self.iter_effective_plugin_hook_sources().cloned().collect()
}
pub fn iter_effective_plugin_hook_sources(&self) -> impl Iterator<Item = &PluginHookSource> {
self.plugins
.iter()
.filter(|plugin| plugin.is_active())
.flat_map(|plugin| plugin.hook_sources.iter())
}
pub fn effective_plugin_hook_warnings(&self) -> Vec<String> {
self.iter_effective_plugin_hook_warnings()
.cloned()
.collect()
}
pub fn iter_effective_plugin_hook_warnings(&self) -> impl Iterator<Item = &String> {
self.plugins
.iter()
.filter(|plugin| plugin.is_active())
.flat_map(|plugin| plugin.hook_load_warnings.iter())
}
pub fn capability_summaries(&self) -> &[PluginCapabilitySummary] {
&self.capability_summaries
}
pub fn plugins(&self) -> &[LoadedPlugin<M>] {
&self.plugins
}
}
#[cfg(test)]
mod tests {
use super::*;
fn test_path(name: &str) -> AbsolutePathBuf {
AbsolutePathBuf::from_absolute_path_checked(std::env::temp_dir().join(name))
.expect("absolute temp path")
}
fn loaded_plugin(config_name: &str, skill_roots: Vec<AbsolutePathBuf>) -> LoadedPlugin<()> {
LoadedPlugin {
config_name: config_name.to_string(),
manifest_name: None,
plugin_namespace: Some(
config_name
.split_once('@')
.map_or(config_name, |(name, _)| name)
.to_string(),
),
manifest_description: None,
root: test_path(config_name),
enabled: true,
skill_roots,
skill_discovery_mode: SkillDiscoveryMode::Recursive,
disabled_skill_paths: HashSet::new(),
has_enabled_skills: true,
mcp_servers: HashMap::new(),
hook_sources: Vec::new(),
hook_load_warnings: Vec::new(),
error: None,
}
}
#[test]
fn effective_plugin_skill_roots_preserves_first_plugin_for_shared_root() {
let shared_root = test_path("shared-skills");
let first_plugin = loaded_plugin("zeta@test", vec![shared_root.clone()]);
let outcome = PluginLoadOutcome::from_plugins(vec![
first_plugin,
loaded_plugin("alpha@test", vec![shared_root.clone()]),
]);
assert_eq!(
outcome.effective_plugin_skill_roots(),
vec![PluginSkillRoot {
path: shared_root,
plugin_identity: PluginIdentity {
plugin_id: "zeta@test".to_string(),
},
plugin_namespace: "zeta".to_string(),
plugin_root: test_path("zeta@test"),
discovery_mode: SkillDiscoveryMode::Recursive,
}]
);
}
}

View File

@@ -0,0 +1,191 @@
use akode_config::HooksFile;
/// Parsed plugin metadata parameterized by its resource locator representation.
///
/// Host loading uses absolute paths, while resolved packages replace them with
/// authority-bound locators before exposing the manifest to consumers.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PluginManifest<Resource> {
pub name: String,
pub version: Option<String>,
pub description: Option<String>,
pub keywords: Vec<String>,
pub paths: PluginManifestPaths<Resource>,
pub interface: Option<PluginManifestInterface<Resource>>,
}
/// Component resources declared by a plugin manifest.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PluginManifestPaths<Resource> {
pub skills: Vec<Resource>,
pub onboarding_skill: Option<Resource>,
pub mcp_servers: Option<PluginManifestMcpServers<Resource>>,
pub hooks: Option<PluginManifestHooks<Resource>>,
}
/// MCP server declarations embedded in or referenced by a plugin manifest.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PluginManifestMcpServers<Resource> {
Path(Resource),
Object(String),
}
/// Hook declarations embedded in or referenced by a plugin manifest.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum PluginManifestHooks<Resource> {
Paths(Vec<Resource>),
Inline(Vec<HooksFile>),
}
/// Optional model- and UI-facing plugin metadata.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PluginManifestInterface<Resource> {
pub display_name: Option<String>,
pub short_description: Option<String>,
pub long_description: Option<String>,
pub developer_name: Option<String>,
pub category: Option<String>,
pub capabilities: Vec<String>,
pub website_url: Option<String>,
pub privacy_policy_url: Option<String>,
pub terms_of_service_url: Option<String>,
pub default_prompt: Option<Vec<String>>,
pub brand_color: Option<String>,
pub composer_icon: Option<Resource>,
pub logo: Option<Resource>,
pub logo_dark: Option<Resource>,
pub screenshots: Vec<Resource>,
}
impl<Resource> Default for PluginManifestInterface<Resource> {
fn default() -> Self {
Self {
display_name: None,
short_description: None,
long_description: None,
developer_name: None,
category: None,
capabilities: Vec::new(),
website_url: None,
privacy_policy_url: None,
terms_of_service_url: None,
default_prompt: None,
brand_color: None,
composer_icon: None,
logo: None,
logo_dark: None,
screenshots: Vec::new(),
}
}
}
impl<Resource> PluginManifest<Resource> {
/// Returns the model- and UI-facing package name, falling back to the manifest name.
pub fn display_name(&self) -> &str {
self.interface
.as_ref()
.and_then(|interface| interface.display_name.as_deref())
.map(str::trim)
.filter(|display_name| !display_name.is_empty())
.unwrap_or(&self.name)
}
/// Maps every path-bearing resource in the manifest.
pub fn try_map_resources<Mapped, Error>(
self,
mut map: impl FnMut(Resource) -> Result<Mapped, Error>,
) -> Result<PluginManifest<Mapped>, Error> {
let PluginManifest {
name,
version,
description,
keywords,
paths,
interface,
} = self;
let PluginManifestPaths {
skills,
onboarding_skill,
mcp_servers,
hooks,
} = paths;
let hooks = match hooks {
Some(PluginManifestHooks::Paths(paths)) => Some(PluginManifestHooks::Paths(
paths
.into_iter()
.map(&mut map)
.collect::<Result<Vec<_>, _>>()?,
)),
Some(PluginManifestHooks::Inline(hooks)) => Some(PluginManifestHooks::Inline(hooks)),
None => None,
};
let mcp_servers = match mcp_servers {
Some(PluginManifestMcpServers::Path(path)) => {
Some(PluginManifestMcpServers::Path(map(path)?))
}
Some(PluginManifestMcpServers::Object(servers)) => {
Some(PluginManifestMcpServers::Object(servers))
}
None => None,
};
let interface = match interface {
Some(interface) => {
let PluginManifestInterface {
display_name,
short_description,
long_description,
developer_name,
category,
capabilities,
website_url,
privacy_policy_url,
terms_of_service_url,
default_prompt,
brand_color,
composer_icon,
logo,
logo_dark,
screenshots,
} = interface;
Some(PluginManifestInterface {
display_name,
short_description,
long_description,
developer_name,
category,
capabilities,
website_url,
privacy_policy_url,
terms_of_service_url,
default_prompt,
brand_color,
composer_icon: composer_icon.map(&mut map).transpose()?,
logo: logo.map(&mut map).transpose()?,
logo_dark: logo_dark.map(&mut map).transpose()?,
screenshots: screenshots
.into_iter()
.map(&mut map)
.collect::<Result<Vec<_>, _>>()?,
})
}
None => None,
};
Ok(PluginManifest {
name,
version,
description,
keywords,
paths: PluginManifestPaths {
skills: skills
.into_iter()
.map(&mut map)
.collect::<Result<Vec<_>, _>>()?,
onboarding_skill: onboarding_skill.map(&mut map).transpose()?,
mcp_servers,
hooks,
},
interface,
})
}
}

View File

@@ -0,0 +1,108 @@
//! Authority-bound plugin descriptors and resource locations.
use crate::manifest::PluginManifest;
use akode_utils_path_uri::PathUri;
use thiserror::Error;
/// A plugin resource paired with the environment that owns its filesystem.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum PluginResourceLocator {
Environment {
/// Environment whose filesystem owns the resource.
environment_id: String,
/// Resource URI within that filesystem.
path: PathUri,
},
}
/// Authority-bound location of a resolved plugin package.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ResolvedPluginLocation {
Environment {
/// Environment whose filesystem owns the package.
environment_id: String,
/// Package root URI within that filesystem.
root: PathUri,
},
}
/// An inert plugin descriptor whose resources retain their source authority.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ResolvedPlugin {
selected_root_id: String,
location: ResolvedPluginLocation,
manifest_path: PluginResourceLocator,
manifest: PluginManifest<PluginResourceLocator>,
}
/// Failure to construct a resolved plugin with internally consistent resources.
#[derive(Clone, Debug, Error, PartialEq, Eq)]
pub enum ResolvedPluginError {
#[error("plugin resource path `{path}` is outside package root `{root}`")]
ResourceOutsideRoot { root: PathUri, path: PathUri },
}
impl ResolvedPlugin {
/// Creates an environment-owned descriptor from a validated plugin manifest.
pub fn from_environment(
selected_root_id: String,
environment_id: String,
root: PathUri,
manifest_path: PathUri,
manifest: PluginManifest<PathUri>,
) -> Result<Self, ResolvedPluginError> {
let manifest_path = environment_resource(&environment_id, &root, manifest_path)?;
let manifest = manifest
.try_map_resources(|path| environment_resource(&environment_id, &root, path))?;
Ok(Self {
selected_root_id,
location: ResolvedPluginLocation::Environment {
environment_id,
root,
},
manifest_path,
manifest,
})
}
/// Returns the opaque ID supplied for the selected capability root.
pub fn selected_root_id(&self) -> &str {
&self.selected_root_id
}
/// Returns the authority-bound package location.
pub fn location(&self) -> &ResolvedPluginLocation {
&self.location
}
/// Returns the manifest resource used to resolve this package.
pub fn manifest_path(&self) -> &PluginResourceLocator {
&self.manifest_path
}
/// Returns package metadata whose resource fields retain their source authority.
pub fn manifest(&self) -> &PluginManifest<PluginResourceLocator> {
&self.manifest
}
}
fn environment_resource(
environment_id: &str,
root: &PathUri,
path: PathUri,
) -> Result<PluginResourceLocator, ResolvedPluginError> {
if !path.starts_with(root) {
return Err(ResolvedPluginError::ResourceOutsideRoot {
root: root.clone(),
path,
});
}
Ok(PluginResourceLocator::Environment {
environment_id: environment_id.to_string(),
path,
})
}
#[cfg(test)]
#[path = "provider_tests.rs"]
mod tests;

View File

@@ -0,0 +1,135 @@
use super::PluginResourceLocator;
use super::ResolvedPlugin;
use super::ResolvedPluginError;
use crate::manifest::PluginManifest;
use crate::manifest::PluginManifestHooks;
use crate::manifest::PluginManifestInterface;
use crate::manifest::PluginManifestMcpServers;
use crate::manifest::PluginManifestPaths;
use akode_utils_absolute_path::AbsolutePathBuf;
use akode_utils_path_uri::PathUri;
use pretty_assertions::assert_eq;
fn absolute(path: impl AsRef<std::path::Path>) -> AbsolutePathBuf {
AbsolutePathBuf::from_absolute_path_checked(path.as_ref()).expect("absolute test path")
}
fn path_uri(path: &AbsolutePathBuf) -> PathUri {
PathUri::from_abs_path(path)
}
fn resource(environment_id: &str, path: &AbsolutePathBuf) -> PluginResourceLocator {
PluginResourceLocator::Environment {
environment_id: environment_id.to_string(),
path: path_uri(path),
}
}
#[test]
fn environment_descriptor_binds_every_manifest_resource() {
let root = absolute(std::env::current_dir().expect("cwd").join("plugin-root"));
let root_uri = path_uri(&root);
let manifest_path = root.join(".codex-plugin/plugin.json");
let skills = root.join("skills");
let mcp_servers = root.join(".mcp.json");
let hooks = root.join("hooks/hooks.json");
let composer_icon = root.join("assets/composer.svg");
let logo = root.join("assets/logo.svg");
let screenshot = root.join("assets/screenshot.png");
let manifest = PluginManifest {
name: "demo".to_string(),
version: None,
description: None,
keywords: Vec::new(),
paths: PluginManifestPaths {
onboarding_skill: None,
skills: vec![path_uri(&skills)],
mcp_servers: Some(PluginManifestMcpServers::Path(path_uri(&mcp_servers))),
hooks: Some(PluginManifestHooks::Paths(vec![path_uri(&hooks)])),
},
interface: Some(PluginManifestInterface {
composer_icon: Some(path_uri(&composer_icon)),
logo: Some(path_uri(&logo)),
screenshots: vec![path_uri(&screenshot)],
..PluginManifestInterface::default()
}),
};
let plugin = ResolvedPlugin::from_environment(
"selected-demo".to_string(),
"executor-1".to_string(),
root_uri,
path_uri(&manifest_path),
manifest,
)
.expect("valid descriptor");
assert_eq!(
plugin.manifest_path(),
&resource("executor-1", &manifest_path)
);
assert_eq!(
plugin.manifest(),
&PluginManifest {
name: "demo".to_string(),
version: None,
description: None,
keywords: Vec::new(),
paths: PluginManifestPaths {
onboarding_skill: None,
skills: vec![resource("executor-1", &skills)],
mcp_servers: Some(PluginManifestMcpServers::Path(resource(
"executor-1",
&mcp_servers,
))),
hooks: Some(PluginManifestHooks::Paths(vec![resource(
"executor-1",
&hooks
)])),
},
interface: Some(PluginManifestInterface {
composer_icon: Some(resource("executor-1", &composer_icon)),
logo: Some(resource("executor-1", &logo)),
screenshots: vec![resource("executor-1", &screenshot)],
..PluginManifestInterface::default()
}),
}
);
}
#[test]
fn environment_descriptor_rejects_resources_outside_package_root() {
let cwd = std::env::current_dir().expect("cwd");
let root = absolute(cwd.join("plugin-root"));
let outside = absolute(cwd.join("outside/.mcp.json"));
let manifest = PluginManifest {
name: "demo".to_string(),
version: None,
description: None,
keywords: Vec::new(),
paths: PluginManifestPaths {
onboarding_skill: None,
skills: Vec::new(),
mcp_servers: Some(PluginManifestMcpServers::Path(path_uri(&outside))),
hooks: None,
},
interface: None,
};
let err = ResolvedPlugin::from_environment(
"selected-demo".to_string(),
"executor-1".to_string(),
path_uri(&root),
path_uri(&root.join(".codex-plugin/plugin.json")),
manifest,
)
.expect_err("outside resource should fail");
assert_eq!(
err,
ResolvedPluginError::ResourceOutsideRoot {
root: path_uri(&root),
path: path_uri(&outside),
}
);
}