vios_app 0.1.1

Small JSON vaults: Argon2id + AES-GCM, with optional AAD binding.
Documentation
use crate::vault_memory::VaultMemory;
use chrono::Utc;

/// 🧠 Compiles EchoScript lines into a structured `VaultMemory` object
pub fn compile_echoscript(lines: Vec<String>) -> Result<VaultMemory, String> {
    let raw_text = lines.join("\n");

    let tone = extract_directive(&raw_text, "::tone:")
        .unwrap_or("neutral")
        .to_string();
    let intent = extract_directive(&raw_text, "::intent:")
        .unwrap_or("unspecified")
        .to_string();
    let reem_code = extract_directive(&raw_text, "::reem:")
        .unwrap_or("R0")
        .to_string();
    let summary = extract_directive(&raw_text, "::summary:")
        .unwrap_or("EchoScript entry")
        .to_string();

    Ok(VaultMemory {
        created_at: Utc::now().to_rfc3339(),
        cia_signature: "unset".into(),
        tone,
        intent,
        reem_code,
        summary,
        voice_log_time: Utc::now().to_rfc3339(),
    })
}

fn extract_directive<'a>(text: &'a str, marker: &'a str) -> Option<&'a str> {
    text.lines()
        .find(|line| line.trim_start().starts_with(marker))
        .map(|line| line.trim_start()[marker.len()..].trim())
}