supercode-frontend-model 0.4.8

Donor-neutral client state and semantic intents for Supercode frontends.
Documentation
use std::path::{Path, PathBuf};

fn crate_root() -> PathBuf {
    Path::new(env!("CARGO_MANIFEST_DIR")).to_path_buf()
}

#[test]
fn client_model_has_no_renderer_donor_or_runtime_implementation_dependencies() {
    let root = crate_root();
    let manifest = std::fs::read_to_string(root.join("Cargo.toml")).unwrap();
    for forbidden in [
        "ratatui",
        "crossterm",
        "codex",
        "goose",
        "reqwest",
        "tokio",
        "provider",
    ] {
        assert!(
            !manifest.to_ascii_lowercase().contains(forbidden),
            "donor-neutral model depends on `{forbidden}`"
        );
    }
    assert!(manifest.contains("supercode-core"));
    assert!(manifest.contains("default-features = false"));

    let mut source = String::new();
    for entry in std::fs::read_dir(root.join("src")).unwrap() {
        let path = entry.unwrap().path();
        if path.extension().and_then(|value| value.to_str()) == Some("rs") {
            source.push_str(&std::fs::read_to_string(path).unwrap());
        }
    }
    for forbidden in [
        "Agent",
        "Provider",
        "SessionStore",
        "RpcEngine",
        "ReductionLog",
        "Scheduler",
        "SessionFormat",
        "ratatui",
        "crossterm",
    ] {
        assert!(
            !source.contains(forbidden),
            "client model reaches forbidden implementation type `{forbidden}`"
        );
    }
}

#[test]
fn embedded_tui_uses_the_neutral_model_as_its_only_semantic_state_owner() {
    let model_root = crate_root();
    let root = model_root.parent().unwrap();
    let manifest = std::fs::read_to_string(root.join("frontend-tui/Cargo.toml")).unwrap();
    assert!(manifest.contains("supercode-frontend-model"));

    let composer =
        std::fs::read_to_string(root.join("frontend-tui/src/composer/model.rs")).unwrap();
    let transcript =
        std::fs::read_to_string(root.join("frontend-tui/src/transcript/mod.rs")).unwrap();
    assert!(composer.contains("NeutralComposerModel"));
    assert!(transcript.contains("supercode_frontend_model::TranscriptModel"));
    assert!(!root.join("frontend-tui/src/transcript/model.rs").exists());
    assert!(!root
        .join("frontend-tui/src/composer/capabilities.rs")
        .exists());
}