Skip to main content

ito_core/harness/
codex.rs

1use super::streaming_cli::CliHarness;
2use super::types::{HarnessName, HarnessRunConfig};
3
4/// Runs the `codex` CLI in non-interactive exec mode (`codex exec`).
5///
6/// Selected via `ito ralph --harness codex`; requires the Codex CLI on PATH.
7///
8/// # Examples
9///
10/// ```
11/// use ito_core::harness::{CodexHarness, Harness, HarnessName};
12///
13/// let h = CodexHarness;
14/// assert_eq!(h.name(), HarnessName::Codex);
15/// assert!(h.streams_output());
16/// ```
17#[derive(Debug, Default)]
18pub struct CodexHarness;
19
20impl CliHarness for CodexHarness {
21    fn harness_name(&self) -> HarnessName {
22        HarnessName::Codex
23    }
24
25    fn binary(&self) -> &str {
26        "codex"
27    }
28
29    fn build_args(&self, config: &HarnessRunConfig) -> Vec<String> {
30        let mut args = vec!["exec".to_string()];
31        if let Some(model) = config.model.as_deref() {
32            args.push("--model".to_string());
33            args.push(model.to_string());
34        }
35        if config.allow_all {
36            args.push("--yolo".to_string());
37        }
38        args.push(config.prompt.clone());
39        args
40    }
41}
42
43#[cfg(test)]
44#[path = "codex_tests.rs"]
45mod codex_tests;