Skip to main content

load_instructions

Function load_instructions 

Source
pub fn load_instructions(
    base_dir: &Path,
    provider_kinds: &[ProviderKind],
    explicit_files: &[PathBuf],
    auto_detect: bool,
) -> Vec<InstructionBlock>
Expand description

Load instruction blocks from provider-specific and explicit files.

base_dir is resolved as the process working directory at startup via std::env::current_dir(). This matches the directory from which the user launches zeph and is therefore the most natural project root for file discovery. Non-git projects are fully supported; git root is not used.

Candidate paths are collected in this order:

  1. Always: base_dir/zeph.md and base_dir/.zeph/zeph.md.
  2. If auto_detect, per-provider paths from detection_paths() for each kind.
  3. explicit_files as provided (trusted — user controls config.toml).

Deduplication uses fs::canonicalize. Paths that do not exist are silently skipped; canonicalize fails on nonexistent paths, so they cannot be deduped via symlinks against existing paths — this is an acceptable edge case documented here.