resolve_file_relative_path

Function resolve_file_relative_path 

Source
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 dependency
  • relative_path - Path from the transitive dep spec (must start with ./ or ../)

§Returns

Canonical absolute path to the dependency.

§Errors

Returns an error if:

  • relative_path doesn’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