claude_agent/common/
mod.rs

1mod directory;
2mod file_provider;
3mod frontmatter;
4mod provider;
5mod registry;
6mod source_type;
7
8use std::path::PathBuf;
9
10pub use directory::{is_markdown, is_skill_file, load_files};
11
12/// Get the user's home directory.
13///
14/// Uses `directories` crate for cross-platform compatibility.
15pub fn home_dir() -> Option<PathBuf> {
16    directories::UserDirs::new().map(|d| d.home_dir().to_path_buf())
17}
18pub use file_provider::{
19    DocumentLoader, FileProvider, LookupStrategy, OutputStyleLookupStrategy, SkillLookupStrategy,
20    SubagentLookupStrategy,
21};
22pub use frontmatter::{ParsedDocument, parse_frontmatter};
23pub use provider::{ChainProvider, InMemoryProvider, Provider};
24pub use registry::{BaseRegistry, RegistryItem};
25pub use source_type::SourceType;
26
27pub trait Named {
28    fn name(&self) -> &str;
29}
30
31pub trait ToolRestricted {
32    fn allowed_tools(&self) -> &[String];
33
34    fn has_tool_restrictions(&self) -> bool {
35        !self.allowed_tools().is_empty()
36    }
37
38    fn is_tool_allowed(&self, tool_name: &str) -> bool {
39        crate::tools::is_tool_allowed(self.allowed_tools(), tool_name)
40    }
41}