Kanbus

Git-backed project management for people and AI agents.

Rust dotyaml-equivalent crate (design)

Goals

Proposed crate metadata

API sketch

/// Options controlling how YAML is loaded and exported to the environment.
pub struct DotYamlOptions {
    pub prefix: String,            // e.g., "KANBUS_"; required, non-empty
    pub yaml_path: PathBuf,        // required; one file only
    pub dotenv_path: Option<PathBuf>, // default Some(Path::new(".env"))
    pub load_dotenv: bool,         // default true
    pub override_existing: bool,   // default false (never clobber existing env)
}

/// Load YAML and export environment variables.
pub fn load_and_export(options: &DotYamlOptions) -> Result<BTreeMap<String, String>, DotYamlError>;

/// Load YAML into a structured value without exporting env vars.
pub fn load(options: &DotYamlOptions) -> Result<serde_yaml::Value, DotYamlError>;

Semantics

  1. Dotenv first (optional): if load_dotenv, load dotenv file (default .env) but do not override already-set env vars.
  2. Parse YAML: read yaml_path with UTF-8; errors are surfaced verbatim.
  3. Interpolation: resolve {{ VAR|default }} using current env (after dotenv). If VAR missing and no default, treat as empty string.
  4. Flattening: nested keys become uppercase with _ separators; arrays become comma-separated values; booleans become true/false; null becomes empty string.
  5. Export: set env vars only if not present OR if override_existing is true. Return the map of variables actually written.
  6. No fallbacks: only yaml_path is read; no search paths.

Error cases

Testing strategy

Integration notes for Kanbus (Rust)

Open decisions