bctx-weave 0.1.10

bctx-weave — FilterMesh lens pipeline, CLI interception, domain compression
Documentation
use forge::signal::compactor;

pub fn compress_mypy(raw: &str) -> String {
    let cleaned = compactor::normalise(raw);
    // Strip "Success: no issues found" or collapse to summary
    let out: Vec<&str> = cleaned
        .lines()
        .filter(|l| {
            // Keep error/note lines and summary
            l.contains(": error:")
                || l.contains(": note:")
                || l.contains(": warning:")
                || l.starts_with("Found")
                || l.starts_with("Success:")
        })
        .collect();
    if out.is_empty() {
        cleaned
    } else {
        out.join("\n")
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn mypy_keeps_errors_and_summary() {
        let raw = "foo.py:5: error: Incompatible types\nfoo.py:10: note: See above\nFound 1 error in 1 file (checked 3 source files)\n";
        let out = compress_mypy(raw);
        assert!(out.contains("Incompatible types"), "{out}");
        assert!(out.contains("Found 1 error"), "{out}");
    }

    #[test]
    fn mypy_keeps_success_line() {
        let raw = "Success: no issues found in 5 source files\n";
        let out = compress_mypy(raw);
        assert!(out.contains("Success:"), "{out}");
    }
}