vtcode_eval/
environment.rs1pub trait EnvironmentProbe: Send + Sync {
2 fn check(&self, workspace: &std::path::Path) -> bool;
3}
4
5pub struct CommandProbe {
6 command: String,
7 args: Vec<String>,
8}
9impl CommandProbe {
10 pub fn new(command: String, args: Vec<String>) -> Self {
11 Self { command, args }
12 }
13}
14impl EnvironmentProbe for CommandProbe {
15 fn check(&self, workspace: &std::path::Path) -> bool {
16 use std::process::Command;
17 Command::new(&self.command)
18 .args(&self.args)
19 .current_dir(workspace)
20 .output()
21 .map(|o| o.status.success())
22 .unwrap_or(false)
23 }
24}
25
26pub struct FileExistsProbe {
27 path: std::path::PathBuf,
28}
29impl FileExistsProbe {
30 pub fn new(path: std::path::PathBuf) -> Self {
31 Self { path }
32 }
33}
34impl EnvironmentProbe for FileExistsProbe {
35 fn check(&self, _workspace: &std::path::Path) -> bool {
36 self.path.exists()
37 }
38}
39
40pub struct GitCleanProbe;
41impl EnvironmentProbe for GitCleanProbe {
42 fn check(&self, workspace: &std::path::Path) -> bool {
43 use std::process::Command;
44 Command::new("git")
45 .args(["diff", "--quiet"])
46 .current_dir(workspace)
47 .output()
48 .map(|o| o.status.success())
49 .unwrap_or(false)
50 }
51}