pub struct ResourceLoader { /* private fields */ }Expand description
Resource loader for all oxi resources
Loads skills, prompts, themes, context files, and system prompts from multiple directories (user-level, project-level, CLI-specified). Supports caching, deduplication, and hot-reload.
Implementations§
Source§impl ResourceLoader
impl ResourceLoader
Sourcepub fn with_options(options: ResourceLoaderOptions) -> Self
pub fn with_options(options: ResourceLoaderOptions) -> Self
Create a resource loader with options
Sourcepub fn with_paths(base_dir: PathBuf, cwd: PathBuf) -> Self
pub fn with_paths(base_dir: PathBuf, cwd: PathBuf) -> Self
Create with custom base and working directory
Sourcepub fn with_base_dir(&mut self, base_dir: PathBuf) -> &mut Self
pub fn with_base_dir(&mut self, base_dir: PathBuf) -> &mut Self
Set base directory
Sourcepub fn add_extension(&mut self, path: PathBuf) -> &mut Self
pub fn add_extension(&mut self, path: PathBuf) -> &mut Self
Add an extension source
Sourcepub fn add_prompt(&mut self, path: PathBuf) -> &mut Self
pub fn add_prompt(&mut self, path: PathBuf) -> &mut Self
Add a prompt source
Sourcepub fn extend_resources(
&mut self,
skill_paths: Vec<(PathBuf, PathMetadata)>,
prompt_paths: Vec<(PathBuf, PathMetadata)>,
theme_paths: Vec<(PathBuf, PathMetadata)>,
)
pub fn extend_resources( &mut self, skill_paths: Vec<(PathBuf, PathMetadata)>, prompt_paths: Vec<(PathBuf, PathMetadata)>, theme_paths: Vec<(PathBuf, PathMetadata)>, )
Extend resources from extension paths
Sourcepub fn try_load_all(&self) -> LoadedResources
pub fn try_load_all(&self) -> LoadedResources
Load all resources, returning default on error
Sourcepub fn load_system_prompt(&self) -> Result<Option<String>, Error>
pub fn load_system_prompt(&self) -> Result<Option<String>, Error>
Load system prompt from SYSTEM.md files
Sourcepub fn load_append_system_prompt(&self) -> Result<Vec<String>, Error>
pub fn load_append_system_prompt(&self) -> Result<Vec<String>, Error>
Load append system prompt from APPEND_SYSTEM.md files
Sourcepub fn load_project_context_files(
&self,
cwd: &Path,
) -> Result<Vec<ContextFile>, Error>
pub fn load_project_context_files( &self, cwd: &Path, ) -> Result<Vec<ContextFile>, Error>
Load project context files (AGENTS.md, CLAUDE.md, etc.)
Sourcepub fn discover_context_files(
&self,
dir: &Path,
) -> Vec<(PathBuf, ContextFileType)>
pub fn discover_context_files( &self, dir: &Path, ) -> Vec<(PathBuf, ContextFileType)>
Discover context files in project and ancestor directories
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Clear the cache
Sourcepub fn is_cache_stale(&self) -> bool
pub fn is_cache_stale(&self) -> bool
Check if cache is stale (any source file was modified since last load)
Sourcepub fn load_if_stale(&self) -> Result<LoadedResources, Error>
pub fn load_if_stale(&self) -> Result<LoadedResources, Error>
Load if cache is stale, otherwise return cached
Sourcepub fn detect_resource_type(path: &Path) -> Option<ResourceType>
pub fn detect_resource_type(path: &Path) -> Option<ResourceType>
Detect the resource type from a path
Sourcepub fn is_valid_resource_path(path: &Path, resource_type: ResourceType) -> bool
pub fn is_valid_resource_path(path: &Path, resource_type: ResourceType) -> bool
Check if a path exists and is a valid resource
Sourcepub fn validate_resource_path(path: &Path) -> Result<ResourceType, String>
pub fn validate_resource_path(path: &Path) -> Result<ResourceType, String>
Validate that a resource path can be loaded
Sourcepub fn get_skills(&self) -> Vec<Skill>
pub fn get_skills(&self) -> Vec<Skill>
Get loaded skills
Sourcepub fn get_themes(&self) -> Vec<Theme>
pub fn get_themes(&self) -> Vec<Theme>
Get loaded themes
Sourcepub fn get_prompts(&self) -> Vec<Prompt>
pub fn get_prompts(&self) -> Vec<Prompt>
Get loaded prompts
Sourcepub fn get_context_files(&self) -> Vec<ContextFile>
pub fn get_context_files(&self) -> Vec<ContextFile>
Get loaded context files
Sourcepub fn get_system_prompt(&self) -> Option<String>
pub fn get_system_prompt(&self) -> Option<String>
Get system prompt
Sourcepub fn get_append_system_prompt(&self) -> Vec<String>
pub fn get_append_system_prompt(&self) -> Vec<String>
Get append system prompt
Sourcepub fn get_agents_files(&self) -> Vec<(PathBuf, String)>
pub fn get_agents_files(&self) -> Vec<(PathBuf, String)>
Get agents files (alias for context files in agent format)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ResourceLoader
impl !RefUnwindSafe for ResourceLoader
impl Send for ResourceLoader
impl Sync for ResourceLoader
impl Unpin for ResourceLoader
impl UnsafeUnpin for ResourceLoader
impl UnwindSafe for ResourceLoader
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> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self file descriptor. Read moreSource§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