use std::io::Write;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, clap::ValueEnum)]
pub enum HumanJsonFormat {
#[default]
Human,
Json,
}
impl HumanJsonFormat {
pub fn resolve(format: Option<Self>, json_flag: bool) -> (Self, bool) {
let resolved = if json_flag {
Self::Json
} else {
format.unwrap_or(Self::Human)
};
(resolved, resolved == Self::Json)
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, clap::ValueEnum)]
pub enum HumanJsonSarifFormat {
#[default]
Human,
Json,
Sarif,
}
impl HumanJsonSarifFormat {
pub fn resolve(format: Option<Self>, json_flag: bool, sarif_flag: bool) -> (Self, bool, bool) {
let resolved = if json_flag {
Self::Json
} else if sarif_flag {
Self::Sarif
} else {
format.unwrap_or(Self::Human)
};
(resolved, resolved == Self::Json, resolved == Self::Sarif)
}
}
pub(crate) fn offline_env_active() -> bool {
std::env::var("TIRITH_OFFLINE")
.ok()
.map(|v| {
matches!(
v.trim().to_ascii_lowercase().as_str(),
"1" | "true" | "yes" | "on"
)
})
.unwrap_or(false)
}
pub(crate) fn write_json_stdout<T: serde::Serialize>(value: &T, ctx: &str) -> bool {
let mut out = std::io::stdout().lock();
if write_json_to(&mut out, value) {
true
} else {
eprintln!("{ctx}");
false
}
}
fn write_json_to<W: Write, T: serde::Serialize>(out: &mut W, value: &T) -> bool {
serde_json::to_writer_pretty(&mut *out, value).is_ok() && writeln!(out).is_ok()
}
#[cfg(test)]
mod write_json_tests {
use super::write_json_to;
struct FailingWriter;
impl std::io::Write for FailingWriter {
fn write(&mut self, _buf: &[u8]) -> std::io::Result<usize> {
Err(std::io::Error::new(
std::io::ErrorKind::BrokenPipe,
"broken pipe",
))
}
fn flush(&mut self) -> std::io::Result<()> {
Err(std::io::Error::new(
std::io::ErrorKind::BrokenPipe,
"broken pipe",
))
}
}
#[test]
fn write_json_to_reports_failure_on_write_error() {
let mut w = FailingWriter;
assert!(
!write_json_to(&mut w, &serde_json::json!({"signed": true})),
"a writer that errors must make write_json_to return false"
);
}
#[test]
fn write_json_to_succeeds_to_a_buffer() {
let mut buf: Vec<u8> = Vec::new();
assert!(write_json_to(&mut buf, &serde_json::json!({"ok": 1})));
let s = String::from_utf8(buf).unwrap();
assert!(s.contains("\"ok\""));
assert!(s.ends_with('\n'), "a trailing newline must be written");
}
#[test]
fn write_file_atomic_writes_replaces_and_leaves_no_temp() {
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("commands.yaml");
super::write_file_atomic(&path, b"first: true\n", true).unwrap();
assert_eq!(std::fs::read_to_string(&path).unwrap(), "first: true\n");
super::write_file_atomic(&path, b"x\n", true).unwrap();
assert_eq!(std::fs::read_to_string(&path).unwrap(), "x\n");
let entries: Vec<_> = std::fs::read_dir(dir.path())
.unwrap()
.filter_map(|e| e.ok())
.map(|e| e.path())
.collect();
assert_eq!(entries.len(), 1, "no temp file left behind: {entries:?}");
assert_eq!(entries[0], path);
}
#[cfg(unix)]
#[test]
fn write_file_atomic_through_symlink_updates_target_not_link() {
use std::os::unix::fs::symlink;
let dir = tempfile::tempdir().unwrap();
let target_dir = dir.path().join("real");
std::fs::create_dir_all(&target_dir).unwrap();
let target = target_dir.join("config.yaml");
std::fs::write(&target, b"old: true\n").unwrap();
let link = dir.path().join("config.yaml");
symlink(&target, &link).unwrap();
super::write_file_atomic(&link, b"new: true\n", true).unwrap();
assert_eq!(std::fs::read_to_string(&target).unwrap(), "new: true\n");
let link_meta = std::fs::symlink_metadata(&link).unwrap();
assert!(
link_meta.file_type().is_symlink(),
"the destination must remain a symlink, not be clobbered by a regular file"
);
assert_eq!(
std::fs::read_link(&link).unwrap(),
target,
"the symlink must still point at the original target"
);
assert_eq!(std::fs::read_to_string(&link).unwrap(), "new: true\n");
for d in [dir.path(), target_dir.as_path()] {
let extra: Vec<_> = std::fs::read_dir(d)
.unwrap()
.filter_map(|e| e.ok())
.map(|e| e.path())
.filter(|p| p != &link && p != &target && p != &target_dir)
.collect();
assert!(
extra.is_empty(),
"no temp file left behind in {d:?}: {extra:?}"
);
}
}
#[cfg(unix)]
#[test]
fn write_file_atomic_dangling_symlink_falls_back() {
use std::os::unix::fs::symlink;
let dir = tempfile::tempdir().unwrap();
let missing_target = dir.path().join("does-not-exist.yaml");
let link = dir.path().join("config.yaml");
symlink(&missing_target, &link).unwrap();
super::write_file_atomic(&link, b"data: 1\n", true).unwrap();
assert_eq!(std::fs::read_to_string(&link).unwrap(), "data: 1\n");
assert!(
std::fs::symlink_metadata(&link)
.unwrap()
.file_type()
.is_file(),
"a dangling symlink falls back to a regular-file write at the link path"
);
}
#[test]
fn write_file_atomic_no_clobber_preserves_existing_file() {
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("commands.yaml");
super::write_file_atomic(&path, b"original\n", false).unwrap();
assert_eq!(std::fs::read_to_string(&path).unwrap(), "original\n");
let err = super::write_file_atomic(&path, b"clobbered\n", false)
.expect_err("no-clobber write over an existing file must fail");
assert_eq!(err.kind(), std::io::ErrorKind::AlreadyExists);
assert_eq!(
std::fs::read_to_string(&path).unwrap(),
"original\n",
"a failed no-clobber write must leave the existing file untouched"
);
super::write_file_atomic(&path, b"forced\n", true).unwrap();
assert_eq!(std::fs::read_to_string(&path).unwrap(), "forced\n");
let entries: Vec<_> = std::fs::read_dir(dir.path())
.unwrap()
.filter_map(|e| e.ok())
.map(|e| e.path())
.collect();
assert_eq!(entries.len(), 1, "no temp file left behind: {entries:?}");
}
}
pub(crate) fn write_file_atomic(
path: &std::path::Path,
contents: &[u8],
overwrite: bool,
) -> std::io::Result<()> {
let dest = resolve_atomic_dest(path);
let dir = dest
.parent()
.filter(|p| !p.as_os_str().is_empty())
.map(std::path::PathBuf::from)
.unwrap_or_else(|| std::path::PathBuf::from("."));
let mut tmp = tempfile::NamedTempFile::new_in(&dir)?;
tmp.write_all(contents)?;
tmp.flush()?;
tmp.as_file().sync_all()?;
if overwrite {
tmp.persist(&dest).map_err(|e| e.error)?;
} else {
tmp.persist_noclobber(&dest).map_err(|e| e.error)?;
}
tirith_core::util::fsync_parent_dir_logged(&dest, "atomic file write");
Ok(())
}
pub(crate) fn resolve_atomic_dest(path: &std::path::Path) -> std::path::PathBuf {
tirith_core::util::resolve_symlink_target(path)
}
pub(crate) fn shell_join(argv: &[String]) -> String {
if argv.len() == 1 {
return argv[0].clone();
}
fn needs_quoting(s: &str) -> bool {
s.is_empty()
|| !s.bytes().all(|b| {
b.is_ascii_alphanumeric()
|| matches!(
b,
b'-' | b'_' | b'.' | b'/' | b':' | b'=' | b'@' | b',' | b'+' | b'%'
)
})
}
argv.iter()
.map(|a| {
if needs_quoting(a) {
format!("'{}'", a.replace('\'', "'\\''"))
} else {
a.clone()
}
})
.collect::<Vec<_>>()
.join(" ")
}
pub fn suggest_closest<'a>(
query: &str,
candidates: &[&'a str],
max_distance: usize,
) -> Option<&'a str> {
candidates
.iter()
.map(|c| (*c, tirith_core::util::levenshtein(query, c)))
.filter(|(_, d)| *d <= max_distance)
.min_by_key(|(_, d)| *d)
.map(|(c, _)| c)
}
pub fn confirm(prompt: &str, yes: bool) -> bool {
if yes {
return true;
}
if !is_terminal::is_terminal(std::io::stderr()) {
eprintln!("tirith: skipping prompt (not a TTY — use --yes to auto-approve)");
return false;
}
eprint!("{prompt} [y/N] ");
let _ = std::io::stderr().flush();
let mut input = String::new();
match std::io::stdin().read_line(&mut input) {
Ok(_) => matches!(input.trim(), "y" | "Y" | "yes" | "Yes"),
Err(e) => {
eprintln!("tirith: could not read confirmation input: {e}");
false
}
}
}
pub mod agent;
pub mod ai;
pub mod aliases;
pub mod audit;
pub mod baseline;
#[cfg(unix)]
pub mod bash_capability;
pub mod browser;
pub mod browser_host;
pub mod canary;
pub mod check;
pub mod checkpoint;
pub mod clipboard;
pub mod codespaces;
pub mod command_card;
pub mod commands;
pub mod completions;
pub mod context;
pub mod daemon;
pub mod dashboard;
pub mod devcontainer;
pub mod diff;
pub mod doctor;
pub mod ecosystem;
pub mod env_guard;
pub mod exec;
pub mod explain;
pub mod fix;
pub mod gateway;
pub mod hook_event;
pub mod hooks;
pub mod hygiene;
pub mod iac;
pub mod incident;
pub mod init;
pub mod install;
pub mod intent;
pub mod lab;
pub mod last_trigger;
pub mod license_cmd;
pub mod logs;
pub mod lsp;
pub mod manpage;
pub mod mcp;
pub mod mcp_server;
pub mod onboard;
pub mod output_guard;
pub mod package;
pub mod paste;
pub mod path;
pub mod pending;
pub mod persistence;
pub mod policy;
pub mod preview;
pub mod prompt_status;
pub mod receipt;
pub mod rule;
pub mod scan;
pub mod score;
pub mod secret;
pub mod selfupdate;
pub mod share;
pub mod ssh;
pub mod status;
pub mod sudo;
pub mod taint;
pub mod temp_run;
pub mod threatdb_cmd;
pub mod trust;
pub mod view;
pub mod visual_audit;
pub mod warnings;
pub mod why;
pub mod yaml;
#[cfg(unix)]
pub mod fetch;
#[cfg(unix)]
pub mod run;
pub mod setup;
#[cfg(test)]
pub(crate) mod test_harness;
#[cfg(any(test, windows))]
fn trim_wrapping_quotes(value: &str) -> &str {
let bytes = value.as_bytes();
if bytes.len() >= 2
&& ((bytes[0] == b'"' && bytes[bytes.len() - 1] == b'"')
|| (bytes[0] == b'\'' && bytes[bytes.len() - 1] == b'\''))
{
&value[1..value.len() - 1]
} else {
value
}
}
#[cfg(any(test, windows))]
fn parse_shim_target(contents: &str) -> Option<std::path::PathBuf> {
contents.lines().find_map(|line| {
let (key, value) = line.split_once('=')?;
if !key.trim().eq_ignore_ascii_case("path") {
return None;
}
let value = trim_wrapping_quotes(value.trim());
if value.is_empty() {
return None;
}
Some(std::path::PathBuf::from(value))
})
}
#[cfg(any(test, windows))]
fn resolve_shim_target(path: &std::path::Path) -> Option<std::path::PathBuf> {
let mut sidecar = path.to_path_buf();
sidecar.set_extension("shim");
let contents = std::fs::read_to_string(&sidecar).ok()?;
let target = parse_shim_target(&contents)?;
let target = if target.is_relative() {
sidecar.parent()?.join(target)
} else {
target
};
target.canonicalize().ok().or(Some(target))
}
#[cfg(unix)]
fn npm_platform_package() -> Option<&'static str> {
match (std::env::consts::OS, std::env::consts::ARCH) {
("linux", "x86_64") => Some("tirith-linux-x64"),
("linux", "aarch64") => Some("tirith-linux-arm64"),
("macos", "x86_64") => Some("tirith-darwin-x64"),
("macos", "aarch64") => Some("tirith-darwin-arm64"),
_ => None,
}
}
#[cfg(unix)]
fn resolve_npm_wrapper_target(path: &std::path::Path) -> Option<std::path::PathBuf> {
use std::path::Component;
let canonical = path.canonicalize().ok()?;
let components: Vec<Component> = canonical.components().collect();
if components.len() < 4 {
return None;
}
let tail = &components[components.len() - 4..];
let expected = [
Component::Normal("node_modules".as_ref()),
Component::Normal("tirith".as_ref()),
Component::Normal("bin".as_ref()),
Component::Normal("tirith".as_ref()),
];
if tail != expected {
return None;
}
let node_modules = canonical.ancestors().nth(3)?;
let platform = npm_platform_package()?;
let native = node_modules
.join("@sheeki03")
.join(platform)
.join("bin")
.join("tirith");
if !native.is_file() {
return None;
}
native.canonicalize().ok()
}
fn resolve_effective_tirith_target(path: &std::path::Path) -> Option<std::path::PathBuf> {
#[cfg(windows)]
if let Some(target) = resolve_shim_target(path) {
return Some(target);
}
#[cfg(unix)]
if let Some(target) = resolve_npm_wrapper_target(path) {
return Some(target);
}
path.canonicalize().ok()
}
pub fn tirith_path_lookup_command() -> &'static str {
#[cfg(unix)]
{
"which -a tirith"
}
#[cfg(not(unix))]
{
"where.exe tirith"
}
}
pub fn resolve_tirith_on_path() -> Vec<std::path::PathBuf> {
let output = {
#[cfg(unix)]
{
std::process::Command::new("sh")
.args(["-c", "which -a tirith 2>/dev/null"])
.output()
}
#[cfg(not(unix))]
{
std::process::Command::new("where.exe")
.arg("tirith")
.output()
}
};
let output = match output {
Ok(o) if o.status.success() => o,
_ => return Vec::new(),
};
String::from_utf8_lossy(&output.stdout)
.lines()
.filter(|l| !l.is_empty())
.map(std::path::PathBuf::from)
.collect()
}
pub fn find_shadow_binaries() -> Vec<String> {
let our_canonical = std::env::current_exe()
.ok()
.and_then(|p| resolve_effective_tirith_target(&p));
let mut seen = std::collections::HashSet::new();
let mut shadows = Vec::new();
for path in resolve_tirith_on_path() {
let canonical = resolve_effective_tirith_target(&path);
if let (Some(ours), Some(ref theirs)) = (&our_canonical, &canonical) {
if ours == theirs {
continue;
}
}
let key = canonical
.map(|c| c.display().to_string())
.unwrap_or_else(|| path.display().to_string());
if seen.insert(key) {
shadows.push(path.display().to_string());
}
}
shadows
}
static QUIET: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
fn quiet_from_env(val: Option<&str>) -> bool {
matches!(val, Some(v) if v == "1" || v.eq_ignore_ascii_case("true"))
}
pub fn init_quiet(flag: bool) {
let env = quiet_from_env(std::env::var("TIRITH_QUIET").ok().as_deref());
let _ = QUIET.set(flag || env);
}
pub fn is_quiet() -> bool {
*QUIET.get().unwrap_or(&false)
}
pub fn note(msg: impl std::fmt::Display) {
if !is_quiet() {
eprintln!("{msg}");
}
}
pub fn read_stdin_capped(max: u64) -> std::io::Result<Vec<u8>> {
use std::io::Read as _;
let mut buf = Vec::new();
std::io::stdin().take(max + 1).read_to_end(&mut buf)?;
if buf.len() as u64 > max {
return Err(std::io::Error::new(
std::io::ErrorKind::InvalidData,
format!("input exceeds the {max}-byte limit"),
));
}
Ok(buf)
}
fn should_warn_neutralized(
scope: tirith_core::policy::PolicyScope,
neutralized_fields: &[&str],
marker_exists: bool,
) -> bool {
scope == tirith_core::policy::PolicyScope::Repo
&& !neutralized_fields.is_empty()
&& !marker_exists
}
pub fn warn_bad_injection_seeds(policy: &tirith_core::policy::Policy) {
let (_seeds, bad) =
tirith_core::rules::prompt_injection::compile_seeds(&policy.injection_seeds_custom);
for (pattern, error) in &bad {
eprintln!("tirith: warning: invalid injection_seeds_custom regex {pattern:?}: {error}");
}
}
pub fn warn_repo_policy_neutralized(policy: &tirith_core::policy::Policy) {
if policy.scope != tirith_core::policy::PolicyScope::Repo
|| policy.neutralized_fields.is_empty()
{
return;
}
let Some(dir) = tirith_core::policy::state_dir().map(|d| d.join("policy-weakening-warned"))
else {
return;
};
let session = tirith_core::session::resolve_session_id();
let path_key = {
use std::hash::{Hash, Hasher};
let mut h = std::collections::hash_map::DefaultHasher::new();
policy.path.hash(&mut h);
format!("{:016x}", h.finish())
};
let marker = dir.join(format!("{session}-{path_key}"));
if !should_warn_neutralized(policy.scope, &policy.neutralized_fields, marker.exists()) {
return;
}
eprintln!(
"tirith: this repo's .tirith/policy.yaml is tightening-only — the following \
weakening field(s) were ignored: {}.\n See the resolved policy with \
`tirith policy effective`.",
policy.neutralized_fields.join(", ")
);
let _ = std::fs::create_dir_all(&dir);
let _ = std::fs::write(&marker, b"");
}
#[cfg(test)]
mod tests {
use super::{
parse_shim_target, quiet_from_env, resolve_shim_target, shell_join, should_warn_neutralized,
};
use std::fs;
use std::path::PathBuf;
use tirith_core::policy::PolicyScope;
#[test]
fn shell_join_preserves_argv_boundaries() {
let q = |v: &[&str]| shell_join(&v.iter().map(|s| s.to_string()).collect::<Vec<_>>());
assert_eq!(q(&["curl https://x.sh | sh"]), "curl https://x.sh | sh");
assert_eq!(q(&["$(rm -rf /)"]), "$(rm -rf /)");
assert_eq!(q(&["echo", "hello", "world"]), "echo hello world");
assert_eq!(
q(&["curl", "https://example.com/x.sh"]),
"curl https://example.com/x.sh"
);
assert_eq!(
q(&["git", "commit", "-m", "fix; rm -rf /"]),
"git commit -m 'fix; rm -rf /'"
);
assert_eq!(q(&["echo", "it's"]), "echo 'it'\\''s'");
assert_eq!(q(&["x", ""]), "x ''");
}
#[test]
fn parse_shim_target_accepts_unquoted_values() {
let parsed =
parse_shim_target("path = C:\\Users\\alice\\scoop\\apps\\tirith\\current\\tirith.exe");
assert_eq!(
parsed,
Some(PathBuf::from(
"C:\\Users\\alice\\scoop\\apps\\tirith\\current\\tirith.exe"
))
);
}
#[test]
fn parse_shim_target_accepts_case_insensitive_quoted_values() {
let parsed = parse_shim_target("ARGS = --help\r\nPATH = \"/tmp/tirith.exe\"\r\n");
assert_eq!(parsed, Some(PathBuf::from("/tmp/tirith.exe")));
}
#[test]
fn resolve_shim_target_uses_absolute_target_from_sidecar() {
let dir = tempfile::tempdir().unwrap();
let real = dir.path().join("apps/tirith/current/tirith.exe");
let shim = dir.path().join("shims/tirith.exe");
fs::create_dir_all(real.parent().unwrap()).unwrap();
fs::create_dir_all(shim.parent().unwrap()).unwrap();
fs::write(&real, b"real").unwrap();
fs::write(&shim, b"shim").unwrap();
fs::write(
shim.with_extension("shim"),
format!("path = \"{}\"\n", real.display()),
)
.unwrap();
assert_eq!(
resolve_shim_target(&shim).unwrap().canonicalize().unwrap(),
real.canonicalize().unwrap()
);
}
#[test]
fn resolve_shim_target_uses_relative_target_from_sidecar() {
let dir = tempfile::tempdir().unwrap();
let real = dir.path().join("apps/tirith/current/tirith.exe");
let shim = dir.path().join("shims/tirith.exe");
fs::create_dir_all(real.parent().unwrap()).unwrap();
fs::create_dir_all(shim.parent().unwrap()).unwrap();
fs::write(&real, b"real").unwrap();
fs::write(&shim, b"shim").unwrap();
fs::write(
shim.with_extension("shim"),
"path = ../apps/tirith/current/tirith.exe\n",
)
.unwrap();
assert_eq!(
resolve_shim_target(&shim).unwrap().canonicalize().unwrap(),
real.canonicalize().unwrap()
);
}
#[cfg(unix)]
mod npm_wrapper_tests {
use super::super::{npm_platform_package, resolve_npm_wrapper_target};
use std::fs;
use std::os::unix::fs::symlink;
fn build_layout(
root: &std::path::Path,
) -> Option<(std::path::PathBuf, std::path::PathBuf)> {
let platform = npm_platform_package()?;
let wrapper_dir = root.join("lib/node_modules/tirith/bin");
let native_dir = root
.join("lib/node_modules/@sheeki03")
.join(platform)
.join("bin");
let bin_dir = root.join("bin");
fs::create_dir_all(&wrapper_dir).unwrap();
fs::create_dir_all(&native_dir).unwrap();
fs::create_dir_all(&bin_dir).unwrap();
let wrapper = wrapper_dir.join("tirith");
let native = native_dir.join("tirith");
fs::write(&wrapper, b"#!/usr/bin/env node\n// wrapper").unwrap();
fs::write(&native, b"\x7fELF native bytes").unwrap();
let symlinked = bin_dir.join("tirith");
symlink(&wrapper, &symlinked).unwrap();
Some((symlinked, native))
}
#[test]
fn resolve_npm_wrapper_target_via_symlink_resolves_native_binary() {
let dir = tempfile::tempdir().unwrap();
let Some((symlinked, native)) = build_layout(dir.path()) else {
eprintln!("skipping: npm distribution doesn't ship for this Unix target");
return;
};
assert_eq!(
resolve_npm_wrapper_target(&symlinked),
Some(native.canonicalize().unwrap())
);
}
#[test]
fn resolve_npm_wrapper_target_resolves_native_binary_when_called_with_wrapper_path() {
let dir = tempfile::tempdir().unwrap();
let Some((_symlinked, native)) = build_layout(dir.path()) else {
eprintln!("skipping: npm distribution doesn't ship for this Unix target");
return;
};
let wrapper = dir.path().join("lib/node_modules/tirith/bin/tirith");
assert_eq!(
resolve_npm_wrapper_target(&wrapper),
Some(native.canonicalize().unwrap())
);
}
#[test]
fn resolve_npm_wrapper_target_returns_none_when_native_missing() {
let dir = tempfile::tempdir().unwrap();
let wrapper_dir = dir.path().join("lib/node_modules/tirith/bin");
fs::create_dir_all(&wrapper_dir).unwrap();
let wrapper = wrapper_dir.join("tirith");
fs::write(&wrapper, b"wrapper").unwrap();
assert_eq!(resolve_npm_wrapper_target(&wrapper), None);
}
#[test]
fn resolve_npm_wrapper_target_ignores_non_npm_paths() {
let dir = tempfile::tempdir().unwrap();
let pip_dir = dir.path().join("local/bin");
fs::create_dir_all(&pip_dir).unwrap();
let pip = pip_dir.join("tirith");
fs::write(&pip, b"pip-installed").unwrap();
assert_eq!(resolve_npm_wrapper_target(&pip), None);
}
}
#[test]
fn should_warn_neutralized_only_fires_for_repo_with_drops_and_no_marker() {
assert!(should_warn_neutralized(
PolicyScope::Repo,
&["allowlist"],
false
));
assert!(!should_warn_neutralized(
PolicyScope::Repo,
&["allowlist"],
true
));
assert!(!should_warn_neutralized(
PolicyScope::Org,
&["allowlist"],
false
));
assert!(!should_warn_neutralized(PolicyScope::Repo, &[], false));
}
#[test]
fn quiet_from_env_recognizes_only_truthy_values() {
for v in ["1", "true", "TRUE", "True"] {
assert!(quiet_from_env(Some(v)), "{v:?} should be truthy");
}
for v in ["0", "", "yes", "false", "01", " 1"] {
assert!(!quiet_from_env(Some(v)), "{v:?} should NOT be truthy");
}
assert!(!quiet_from_env(None), "unset TIRITH_QUIET is not quiet");
}
}