claude_agent/common/
mod.rs1mod 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 use directory::{is_markdown, is_skill_file, load_files};
18
19pub fn home_dir() -> Option<PathBuf> {
20 directories::UserDirs::new().map(|d| d.home_dir().to_path_buf())
21}
22pub use file_provider::{
23 DocumentLoader, FileProvider, LookupStrategy, OutputStyleLookupStrategy, SkillLookupStrategy,
24 SubagentLookupStrategy,
25};
26pub use frontmatter::{ParsedDocument, parse_frontmatter, strip_frontmatter};
27pub use index::Index;
28pub use index_registry::{IndexRegistry, LoadedEntry};
29pub use path_matched::PathMatched;
30pub use provider::{ChainProvider, InMemoryProvider, Provider};
31pub use source_type::SourceType;
32pub use tool_matcher::{is_tool_allowed, matches_tool_pattern};
33
34pub trait Named {
35 fn name(&self) -> &str;
36}
37
38pub trait ToolRestricted {
39 fn allowed_tools(&self) -> &[String];
40
41 fn has_tool_restrictions(&self) -> bool {
42 !self.allowed_tools().is_empty()
43 }
44
45 fn is_tool_allowed(&self, tool_name: &str) -> bool {
46 tool_matcher::is_tool_allowed(self.allowed_tools(), tool_name)
47 }
48}