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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
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: Sized + AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: Sized + 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 moreimpl<T> MaybeSendSync for T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.