llm_coding_tools_core/path/
mod.rs

1//! Path resolution strategies for tool security.
2//!
3//! This module provides [`PathResolver`] trait and implementations:
4//! - [`AbsolutePathResolver`] - Requires absolute paths only
5//! - [`AllowedPathResolver`] - Restricts to allowed directories
6
7mod absolute;
8mod allowed;
9
10pub use absolute::AbsolutePathResolver;
11pub use allowed::AllowedPathResolver;
12
13use crate::error::ToolResult;
14use std::path::PathBuf;
15
16/// Strategy for resolving and validating file paths.
17///
18/// Implementations control whether paths must be absolute, relative to
19/// allowed directories, or follow other constraints.
20pub trait PathResolver: Send + Sync {
21    /// Resolves and validates a path string.
22    ///
23    /// Returns an absolute path (may or may not be canonical) if valid,
24    /// or an error describing the issue.
25    fn resolve(&self, path: &str) -> ToolResult<PathBuf>;
26}