pub struct PatternLearner { /* private fields */ }Expand description
Learn new tool patterns from usage
Implementations§
Source§impl PatternLearner
impl PatternLearner
Sourcepub fn with_threshold(threshold: u32) -> Self
pub fn with_threshold(threshold: u32) -> Self
Create a new pattern learner with custom promotion threshold
Sourcepub fn observe(
&mut self,
tool_name: String,
command: String,
category: ToolCategory,
)
pub fn observe( &mut self, tool_name: String, command: String, category: ToolCategory, )
Observe a potential new tool pattern
This method records an observation of a tool being used in a specific context. When a tool reaches the promotion threshold, it can be promoted to a learned pattern.
Sourcepub fn promote_candidates(&mut self) -> Vec<LearnedPattern>
pub fn promote_candidates(&mut self) -> Vec<LearnedPattern>
Promote candidates that meet the observation threshold to learned patterns
Returns a list of newly promoted patterns and removes them from candidates.
Sourcepub fn candidate_count(&self) -> usize
pub fn candidate_count(&self) -> usize
Get the current count of candidate patterns
Sourcepub fn save_to_cache(&self, learned_patterns: &[LearnedPattern]) -> Result<()>
pub fn save_to_cache(&self, learned_patterns: &[LearnedPattern]) -> Result<()>
Save learned patterns to cache directory
§Errors
Returns an error if the cache directory cannot be created or the file cannot be written
Sourcepub fn load_from_cache() -> Result<Vec<LearnedPattern>>
pub fn load_from_cache() -> Result<Vec<LearnedPattern>>
Load learned patterns from cache
§Errors
Returns an error if the cache file cannot be read or parsed
Sourcepub fn get_candidates(&self) -> Vec<&CandidatePattern>
pub fn get_candidates(&self) -> Vec<&CandidatePattern>
Get all current candidate patterns (for debugging/inspection)
Trait Implementations§
Source§impl Clone for PatternLearner
impl Clone for PatternLearner
Source§fn clone(&self) -> PatternLearner
fn clone(&self) -> PatternLearner
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PatternLearner
impl Debug for PatternLearner
Source§impl Default for PatternLearner
impl Default for PatternLearner
Source§impl<'de> Deserialize<'de> for PatternLearner
impl<'de> Deserialize<'de> for PatternLearner
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for PatternLearner
impl RefUnwindSafe for PatternLearner
impl Send for PatternLearner
impl Sync for PatternLearner
impl Unpin for PatternLearner
impl UnwindSafe for PatternLearner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more