use std::path::Path;
use std::process::Command;
use super::app_server::build_gemini_acp_command;
use super::backend::{AgentBackend, AgentBackendError, BuildCommandRequest};
pub(super) struct GeminiBackend;
impl AgentBackend for GeminiBackend {
fn setup(&self, _folder: &Path) -> Result<(), AgentBackendError> {
Ok(())
}
fn build_command<'request>(
&'request self,
request: BuildCommandRequest<'request>,
) -> Result<Command, AgentBackendError> {
Ok(build_gemini_acp_command(request.folder, request.model))
}
}
#[cfg(test)]
mod tests {
use tempfile::tempdir;
use super::*;
use crate::channel::AgentRequestKind;
use crate::model::agent::ReasoningLevel;
fn utility_request_kind() -> AgentRequestKind {
AgentRequestKind::UtilityPrompt
}
#[test]
fn test_gemini_setup_creates_no_files() {
let temp_directory = tempdir().expect("failed to create temp dir");
let backend = GeminiBackend;
AgentBackend::setup(&backend, temp_directory.path()).expect("setup should succeed");
assert_eq!(
std::fs::read_dir(temp_directory.path())
.expect("failed to read dir")
.count(),
0
);
}
#[test]
fn test_gemini_build_command_uses_acp_runtime_command() {
let temp_directory = tempdir().expect("failed to create temp dir");
let backend = GeminiBackend;
let command = AgentBackend::build_command(
&backend,
BuildCommandRequest {
attachments: &[],
folder: temp_directory.path(),
main_checkout_root: None,
replay_transcript: None,
model: "gemini-3.5-flash",
prompt: "Generate title",
reasoning_level: ReasoningLevel::default(),
request_kind: &utility_request_kind(),
},
)
.expect("command should build");
let args = command
.get_args()
.map(|arg| arg.to_string_lossy().into_owned())
.collect::<Vec<_>>();
assert_eq!(args, vec!["--acp", "--model", "gemini-3.5-flash"]);
assert_eq!(command.get_current_dir(), Some(temp_directory.path()));
}
}