vios_app 0.1.1

Small JSON vaults: Argon2id + AES-GCM, with optional AAD binding.
Documentation
// 🧠 compiler_main.rs — EchoScript to VaultMemory Compiler CLI

use std::env;
use std::fs;
use std::path::Path;
use vios_core::echoscript_compiler::compile_echoscript;

fn main() {
    let args: Vec<String> = env::args().collect();

    if args.len() != 2 {
        eprintln!("Usage: compiler_main <input.echo>");
        std::process::exit(1);
    }

    let input_path = &args[1];
    if !Path::new(input_path).exists() {
        eprintln!("❌ File not found: {input_path}");
        std::process::exit(1);
    }

    let content = fs::read_to_string(input_path)
        .unwrap_or_else(|_| panic!("Failed to read EchoScript file: {input_path}"));

    let lines: Vec<String> = content.lines().map(|l| l.to_string()).collect();

    let script = lines.join("\n");
    match compile_echoscript(&script) {
        Ok(vault_memory) => {
            let output_path = format!(
                "{}.vaultmem",
                Path::new(input_path).file_stem().unwrap().to_string_lossy()
            );

            let json = serde_json::to_string_pretty(&vault_memory)
                .expect("Failed to serialize VaultMemory to JSON");

            fs::write(&output_path, json).expect("Failed to write output VaultMemory file");

            println!("✅ VaultMemory saved to: {output_path}");
        }
        Err(e) => {
            eprintln!("❌ Compilation failed: {e}");
            std::process::exit(1);
        }
    }
}