Skip to main content

ito_core/harness/
opencode.rs

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