pub fn resolve_file_relative_path(
parent_file_path: &Path,
relative_path: &str,
) -> Result<PathBuf>Expand description
Resolves a file-relative path from a transitive dependency.
This function resolves paths that start with ./ or ../ relative to the
directory containing the parent resource file. This provides a unified way to
resolve transitive dependencies for both Git-backed and path-only resources.
§Arguments
parent_file_path- Absolute path to the file declaring the dependencyrelative_path- Path from the transitive dep spec (must start with./or../)
§Returns
Canonical absolute path to the dependency.
§Errors
Returns an error if:
relative_pathdoesn’t start with./or../- The resolved path doesn’t exist
- Canonicalization fails
§Examples
use std::path::Path;
use agpm_cli::utils::resolve_file_relative_path;
let parent = Path::new("/project/agents/helper.md");
let resolved = resolve_file_relative_path(parent, "./snippets/utils.md")?;
// Returns: /project/agents/snippets/utils.md
let resolved = resolve_file_relative_path(parent, "../common/base.md")?;
// Returns: /project/common/base.md