mod component_suffix;
mod field_component;
mod mcp;
mod metadata;
mod rust_syntax;
mod value_change;
pub use component_suffix::{
ComponentSuffix, ComponentSuffixError, component_suffix_from_suffix, is_valid_component_suffix,
validate_component_suffix,
};
pub use field_component::{ComponentFieldName, ComponentShapeUse};
pub use mcp::{
McpInput, McpInputShape, McpPrimitiveKind, McpRangeBoundKind, McpToolMetadataError,
validate_mcp_tool_metadata_text, validate_mcp_tool_name,
};
pub use metadata::{
ComponentCapabilities, ComponentPrototyping, RenderCapability, ValueBindingCapability,
};
pub use rust_syntax::{RustExpr, RustPath, RustSyntaxError, RustSyntaxKind, RustType};
pub use value_change::ValueChange;
pub trait ComponentShapeMetadata {
const PROTOTYPING: ComponentPrototyping = ComponentPrototyping::new();
const CAPABILITIES: ComponentCapabilities = ComponentCapabilities::new();
const MCP_INPUT: McpInput = McpInput::unsupported();
}
pub trait DeclaredComponentShape: ComponentShapeMetadata {}
pub trait ComponentShapeFor<Value>: ComponentShapeMetadata {
const MCP_INPUT: McpInput = <Self as ComponentShapeMetadata>::MCP_INPUT;
}
#[cfg(test)]
mod tests {
use super::{
ComponentShapeFor, ComponentShapeMetadata, McpInput, McpInputShape, McpPrimitiveKind,
};
struct TextShape;
impl ComponentShapeMetadata for TextShape {
const MCP_INPUT: McpInput = McpInput::string();
}
impl ComponentShapeFor<String> for TextShape {}
impl ComponentShapeFor<Vec<String>> for TextShape {
const MCP_INPUT: McpInput = McpInput::string_list();
}
#[test]
fn component_shape_for_inherits_shape_level_mcp_input_by_default() {
assert_eq!(
<TextShape as ComponentShapeFor<String>>::MCP_INPUT.input_shape(),
McpInputShape::Scalar(McpPrimitiveKind::String)
);
}
#[test]
fn component_shape_for_can_override_value_specific_mcp_input() {
assert_eq!(
<TextShape as ComponentShapeFor<Vec<String>>>::MCP_INPUT.input_shape(),
McpInputShape::List(McpPrimitiveKind::String)
);
}
}