Skip to main content

claude_agent/common/
mod.rs

1mod content_source;
2mod directory;
3mod file_provider;
4mod frontmatter;
5mod index;
6pub(crate) mod index_loader;
7mod index_registry;
8mod path_matched;
9mod provider;
10pub(crate) mod serde_defaults;
11mod source_type;
12mod tool_matcher;
13
14use std::path::PathBuf;
15
16pub use content_source::ContentSource;
17pub(crate) use directory::{is_markdown, is_skill_file, load_files};
18
19pub(crate) fn home_dir() -> Option<PathBuf> {
20    directories::UserDirs::new().map(|d| d.home_dir().to_path_buf())
21}
22pub(crate) use file_provider::{DocumentLoader, FileProvider, OutputStyleLookupStrategy};
23pub(crate) use frontmatter::{parse_frontmatter, strip_frontmatter};
24pub use index::Index;
25pub use index_registry::{IndexRegistry, LoadedEntry};
26pub use path_matched::PathMatched;
27pub use provider::Provider;
28pub(crate) use provider::{ChainProvider, InMemoryProvider};
29pub use source_type::SourceType;
30pub use tool_matcher::{is_tool_allowed, matches_tool_pattern};
31
32pub trait Named {
33    fn name(&self) -> &str;
34}
35
36pub trait ToolRestricted {
37    fn allowed_tools(&self) -> &[String];
38
39    fn has_tool_restrictions(&self) -> bool {
40        !self.allowed_tools().is_empty()
41    }
42
43    fn is_tool_allowed(&self, tool_name: &str) -> bool {
44        tool_matcher::is_tool_allowed(self.allowed_tools(), tool_name)
45    }
46}