supercode-frontend-tui 0.4.8

Attachable terminal frontend primitives for Supercode SDK runtimes.
Documentation
use std::fs;
use std::path::{Path, PathBuf};

const PIN: &str = "8604689ec5e3437eb79802d8d72249b7722fbf5b";

fn rust_files(root: &Path, files: &mut Vec<PathBuf>) {
    for entry in fs::read_dir(root).expect("read source directory") {
        let path = entry.expect("read source entry").path();
        if path.is_dir() {
            rust_files(&path, files);
        } else if path.extension().and_then(|ext| ext.to_str()) == Some("rs") {
            files.push(path);
        }
    }
}

#[test]
fn every_derived_module_is_manifested_and_attributed() {
    let crate_root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
    let workspace_root = fs::canonicalize(crate_root.join("../..")).expect("find workspace root");
    let manifest_path = workspace_root.join("docs/legal/codex-frontend-extraction.toml");
    let manifest = fs::read_to_string(&manifest_path).expect("read extraction manifest");

    assert!(manifest.contains(&format!("commit = \"{PIN}\"")));
    assert!(manifest.contains("allow_git_dependencies = false"));
    assert!(manifest.contains("allow_codex_workspace_manifests = false"));

    let mut files = Vec::new();
    rust_files(&crate_root.join("src"), &mut files);
    for path in files {
        let source = fs::read_to_string(&path).expect("read Rust source");
        if !source.starts_with("// Derived from OpenAI Codex:") {
            continue;
        }

        let destination = path
            .strip_prefix(&workspace_root)
            .expect("derived file is in workspace")
            .to_string_lossy()
            .replace('\\', "/");
        assert!(
            manifest.contains(&format!("destination = \"{destination}\"")),
            "derived source missing from provenance manifest: {destination}"
        );
        assert!(source.contains(&format!("// Pinned source: {PIN}")));
        assert!(source.contains("// Copyright 2025 OpenAI"));
        assert!(source.contains("// Licensed under the Apache License, Version 2.0."));
        assert!(source.contains("// Modified by the Supercode contributors"));

        for forbidden in [
            "use codex_",
            "codex_protocol::",
            "codex_config::",
            "codex_rollout::",
            "supercode::Agent",
            "crate::agent::Agent",
        ] {
            assert!(
                !source.contains(forbidden),
                "{destination} crosses the forbidden runtime boundary with `{forbidden}`"
            );
        }
    }
}

#[test]
fn terminal_dependencies_are_registry_releases() {
    let crate_root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
    let workspace_manifest =
        fs::read_to_string(crate_root.join("../../Cargo.toml")).expect("read workspace manifest");
    let crate_manifest =
        fs::read_to_string(crate_root.join("Cargo.toml")).expect("read frontend manifest");

    assert!(workspace_manifest.contains("ratatui = \"0.30\""));
    assert!(workspace_manifest.contains("crossterm = \"0.29\""));
    assert!(!crate_manifest.contains("git ="));
    assert!(!crate_manifest.contains("codex-"));
}