Skip to main content

ito_core/harness/
github_copilot.rs

1use super::streaming_cli::CliHarness;
2use super::types::{HarnessName, HarnessRunConfig};
3
4/// Runs the `copilot` CLI in non-interactive print mode (`copilot -p`).
5///
6/// Selected via `ito ralph --harness copilot`; requires the Copilot CLI on PATH.
7///
8/// # Examples
9///
10/// ```
11/// use ito_core::harness::{GitHubCopilotHarness, Harness, HarnessName};
12///
13/// let h = GitHubCopilotHarness;
14/// assert_eq!(h.name(), HarnessName::GithubCopilot);
15/// assert!(h.streams_output());
16/// ```
17#[derive(Debug, Default)]
18pub struct GitHubCopilotHarness;
19
20impl CliHarness for GitHubCopilotHarness {
21    fn harness_name(&self) -> HarnessName {
22        HarnessName::GithubCopilot
23    }
24
25    fn binary(&self) -> &str {
26        "copilot"
27    }
28
29    fn build_args(&self, config: &HarnessRunConfig) -> Vec<String> {
30        let mut args = Vec::new();
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("-p".to_string());
39        args.push(config.prompt.clone());
40        args
41    }
42}
43
44#[cfg(test)]
45#[path = "github_copilot_tests.rs"]
46mod github_copilot_tests;