Skip to main content

nils_common/
lib.rs

1//! Foundation crate shared across nils-* CLIs.
2//!
3//! Each public module documents its own surface; `crates/nils-common/README.md` carries the
4//! per-module narrative and the consumer index, and
5//! `docs/specs/workspace-shared-crate-boundary-v1.md` carries the boundary contract.
6//!
7//! ## Compatibility rules
8//! - Returns structured results only; user-facing warning/error text stays in caller adapters.
9//! - Exit-code mapping stays in caller crates.
10//! - APIs stay domain-neutral and must not encode crate-specific UX policies.
11//! - Quoting and ANSI differences are expressed via explicit mode/policy parameters.
12//!
13//! ## Determinism contract (Resolved Decision #9)
14//!
15//! `agent-runtime-cli` consumes this crate on its render path, so
16//! `std::collections::HashMap`, `std::time::SystemTime::now`, and
17//! `chrono::Utc::now` are forbidden inside this crate. The crate-wide
18//! `#![deny(...)]` below pairs with `clippy.toml` to make every
19//! violation a build failure. Use `IndexMap` or `BTreeMap` for any map
20//! that wants stable iteration. Source:
21//! `agent-runtime-kit/docs/source/inventory-target-architecture.md`
22//! → Resolved Decision #9.
23#![deny(clippy::disallowed_types, clippy::disallowed_methods)]
24
25pub mod cli_contract;
26pub mod clipboard;
27pub mod diag_output;
28pub mod env;
29pub mod fs;
30pub mod git;
31pub mod markdown;
32pub mod process;
33pub mod provider_runtime;
34pub mod rate_limits_ansi;
35pub mod redact;
36pub mod shell;
37
38pub fn greeting(name: &str) -> String {
39    format!("Hello, {name}!")
40}
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45    use pretty_assertions::assert_eq;
46
47    #[test]
48    fn greeting_formats_name() {
49        let result = greeting("Nils");
50        assert_eq!(result, "Hello, Nils!");
51    }
52}