Skip to main content

Module document

Module document 

Source
Expand description

Format-independent document values (dot-path access, typed coercion, and pluggable JSON/TOML/YAML/dotenv/INI backends), ported from agent-first-config. Format-independent document values: dot-path get/set/add/remove, type-directed CLI-string coercion, keyed-list (slug-addressed array) helpers, and typed serde adapters, backed by pluggable JSON/TOML/YAML/dotenv/INI format readers and writers. Ported from the standalone agent-first-config crate.

§Features

JSON support is always compiled in — agent_first_data already depends on serde_json as a core dependency.

  • toml: Enable TOML format support (format-preserving with toml_edit)
  • yaml: Enable YAML format support with CST-backed source-preserving mutation
  • dotenv: Enable source-preserving dotenv format support
  • ini: Enable INI Core v1 format support
  • schema: Enable the CliSchema trait and documentation rendering

This module never redacts values on decode/encode/save — it returns and saves raw values as-is; redaction is the caller’s responsibility.

Re-exports§

pub use coerce::ScalarKind;
pub use coerce::ValueType;
pub use coerce::guard_bare_overwrite;
pub use coerce::scalar_kind;
pub use coerce::value_from_type;
pub use error::DocumentError;
pub use error::DocumentResult;
pub use file::Document;
pub use file::DocumentFile;
pub use keyed::KeyedList;
pub use keyed::add_keyed;
pub use keyed::remove_keyed;
pub use path::join_path;
pub use path::parse_path;
pub use traverse::get_path;
pub use traverse::get_path_ref;
pub use traverse::set_path;
pub use traverse::unset_path;
pub use typed::from_value;
pub use typed::to_value;
pub use value::Value;
pub use format::Format;

Modules§

coerce
CLI-facing value construction for set/add (cli-shell-config-todo.md §3, which supersedes the earlier cli-design-review-todo.md D3): a bare VALUE/FIELD=VALUE is always Value::String with zero coercion — no shape-guessing, no type prefixes. An exact type is requested explicitly via ValueType (set’s --value-type flag); guard_bare_overwrite implements the “异型覆盖守卫” (heterogeneous-overwrite guard) that turns a bare VALUE silently changing an existing scalar’s type into an argument error instead.
error
Error types with context and helpful hints.
file
Format-neutral in-memory document value, plus a file-backed document facade with safe, source-preserving edits.
format
Format detection and backend selection.
keyed
KeyedList operations for slug-based array access.
path
The single path grammar used by every traversal operation.
traverse
Core dot-path traversal for get/set operations.
typed
Fallible serde adapters over the format-independent Value IR.
value
Custom Value type — zero external format dependencies.