pub struct KnowledgeItem {
pub id: String,
pub name: String,
pub description: String,
pub triggers: Vec<String>,
pub category: String,
pub core_content: String,
pub references: Vec<KnowledgeReference>,
pub metadata: HashMap<String, String>,
pub enabled: bool,
pub priority: u32,
}Expand description
A knowledge item represents a specialized area of expertise that can be loaded on-demand to provide context to the agent.
Fields§
§id: StringUnique identifier for this knowledge item
name: StringHuman-readable name
description: StringBrief description with trigger keywords
triggers: Vec<String>Keywords that trigger this knowledge item
category: StringCategory for organization (e.g., “language”, “framework”, “tool”)
core_content: StringCore content (lean, ~80 lines max)
references: Vec<KnowledgeReference>Reference files that can be loaded on-demand
metadata: HashMap<String, String>Metadata for filtering and search
enabled: boolWhether this knowledge is enabled
priority: u32Priority for conflict resolution (higher = more important)
Implementations§
Source§impl KnowledgeItem
impl KnowledgeItem
Sourcepub fn new(
id: impl Into<String>,
name: impl Into<String>,
description: impl Into<String>,
) -> Self
pub fn new( id: impl Into<String>, name: impl Into<String>, description: impl Into<String>, ) -> Self
Create a new knowledge item with minimal required fields
Sourcepub fn with_trigger(self, trigger: impl Into<String>) -> Self
pub fn with_trigger(self, trigger: impl Into<String>) -> Self
Add a trigger keyword
Sourcepub fn with_triggers(
self,
triggers: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn with_triggers( self, triggers: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Add multiple trigger keywords
Sourcepub fn with_category(self, category: impl Into<String>) -> Self
pub fn with_category(self, category: impl Into<String>) -> Self
Set the category
Sourcepub fn with_content(self, content: impl Into<String>) -> Self
pub fn with_content(self, content: impl Into<String>) -> Self
Set the core content
Sourcepub fn with_metadata(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Set a metadata key/value pair (used for attribution, source tracking, filtering, etc.)
Sourcepub fn with_enabled(self, enabled: bool) -> Self
pub fn with_enabled(self, enabled: bool) -> Self
Set whether this item is enabled (note: session-scoped enablement is handled separately).
Sourcepub fn with_priority(self, priority: u32) -> Self
pub fn with_priority(self, priority: u32) -> Self
Set priority for conflict resolution (higher = more important)
Sourcepub fn with_reference(self, reference: KnowledgeReference) -> Self
pub fn with_reference(self, reference: KnowledgeReference) -> Self
Add a reference
Sourcepub fn matches(&self, query: &str) -> Option<KnowledgeMatch>
pub fn matches(&self, query: &str) -> Option<KnowledgeMatch>
Check if this knowledge item matches a query
Trait Implementations§
Source§impl Clone for KnowledgeItem
impl Clone for KnowledgeItem
Source§fn clone(&self) -> KnowledgeItem
fn clone(&self) -> KnowledgeItem
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more