truth-mirror 0.7.2

Truthfulness gate and adversarial reviewer harness for AI coding agents.
Documentation
use std::{path::Path, process::Output, time::Duration};

use assert_cmd::Command;

pub fn git_output(repo: &Path, args: &[&str]) -> Output {
    let output = std::process::Command::new("git")
        .args(args)
        .current_dir(repo)
        .output()
        .unwrap();
    assert!(
        output.status.success(),
        "git {args:?} failed\nstdout:\n{}\nstderr:\n{}",
        String::from_utf8_lossy(&output.stdout),
        String::from_utf8_lossy(&output.stderr)
    );
    output
}

pub fn git(repo: &Path, args: &[&str]) {
    git_output(repo, args);
}

pub fn git_stdout(repo: &Path, args: &[&str]) -> String {
    String::from_utf8(git_output(repo, args).stdout)
        .unwrap()
        .trim()
        .to_owned()
}

pub fn truth_mirror(repo: &Path) -> Command {
    let mut command = Command::cargo_bin("truth-mirror").unwrap();
    command.current_dir(repo);
    command.timeout(Duration::from_secs(10));
    command
}

#[cfg(unix)]
pub fn make_executable(path: impl AsRef<Path>) {
    use std::os::unix::fs::PermissionsExt;

    let mut permissions = std::fs::metadata(path.as_ref()).unwrap().permissions();
    permissions.set_mode(0o755);
    std::fs::set_permissions(path, permissions).unwrap();
}

#[cfg(not(unix))]
pub fn make_executable(_path: impl AsRef<Path>) {}