caliban_output_styles/lib.rs
1//! Output styles for the caliban agent harness.
2//!
3//! Splices an `<output-style name="...">...</output-style>` block into the
4//! system prompt to nudge the model toward a particular response shape
5//! (explanatory commentary, learning-paced prompts with `TODO(human)`
6//! markers, etc.) without touching tools, permissions, or hooks.
7//!
8//! See `docs/superpowers/specs/2026-05-24-output-styles-design.md` and
9//! `docs/adr/0031-output-styles.md`.
10
11#![allow(clippy::multiple_crate_versions)]
12
13pub mod learning;
14pub mod loader;
15pub mod prefix;
16pub mod registry;
17pub mod style;
18
19pub use learning::{IdentityPostProcessor, LearningPostProcessor, insert_todo_human_markers};
20pub use loader::{
21 DiscoveryRoots, OutputStyleError, default_roots, load_one, load_styles, select_active,
22};
23pub use prefix::OutputStylePrefix;
24pub use registry::OutputStylesRegistry;
25pub use style::{OutputStyle, OutputStyleSource};
26
27/// Environment variable that selects the active output style by name.
28///
29/// Until ADR 0026 lands the settings hierarchy, this env var is the
30/// operator's surface for choosing a style. When unset (or empty), the
31/// built-in `default` style is used.
32pub const ACTIVE_STYLE_ENV: &str = "CALIBAN_OUTPUT_STYLE";
33
34/// Read the requested output-style name from the environment.
35///
36/// Returns `"default"` when [`ACTIVE_STYLE_ENV`] is unset or empty.
37#[must_use]
38pub fn requested_from_env() -> String {
39 std::env::var(ACTIVE_STYLE_ENV)
40 .ok()
41 .filter(|s| !s.trim().is_empty())
42 .unwrap_or_else(|| "default".to_string())
43}