claude_agent/common/
mod.rs

1mod content_source;
2mod directory;
3mod file_provider;
4mod frontmatter;
5mod index;
6mod index_registry;
7mod path_matched;
8mod provider;
9mod source_type;
10
11use std::path::PathBuf;
12
13pub use content_source::ContentSource;
14pub use directory::{is_markdown, is_skill_file, load_files};
15
16/// Get the user's home directory.
17///
18/// Uses `directories` crate for cross-platform compatibility.
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;
32
33pub trait Named {
34    fn name(&self) -> &str;
35}
36
37pub trait ToolRestricted {
38    fn allowed_tools(&self) -> &[String];
39
40    fn has_tool_restrictions(&self) -> bool {
41        !self.allowed_tools().is_empty()
42    }
43
44    fn is_tool_allowed(&self, tool_name: &str) -> bool {
45        crate::tools::is_tool_allowed(self.allowed_tools(), tool_name)
46    }
47}