Rust

diff_check

Module

Asking an agent about the difference between two versions of a repository.

Contents

use utopia_agents::DiffCheck;
Rust
pub struct DiffCheck

Compares two versions of a repository with git diff and asks an agent about the difference.

Both sides are copied (or cloned) to temporary directories, the excluded paths are removed, and git diff --no-index compares them. When they differ, the diff (truncated to the most lines the options allow) is put in the prompt ({{diff}}, {{base}}, {{target}}, {{diff_stats}} placeholders; appended when the prompt has no {{diff}}), and the answer comes back.

Rust
use utopia_agents::{DiffCheck, OpenAi};
use utopia_agents::diff_check::{Options, Runner};

let mut adapter = OpenAi::new("sk-...");
let mut options = Options::default();
options.set_exclude_paths(&[".github"]);
let outcome = DiffCheck::new()
    .run(Runner::Adapter(&mut adapter), "/srv/sdk-old", "/srv/sdk-new", "Summarize:\n{{diff}}", &options)
    .await?;
if outcome.has_changes {
    println!("{}", String::from_utf8_lossy(&outcome.response));
}
Compiles in CI; needs a running service to execute.
Also implements Default.
use utopia_agents::diff_check::Options;
Rust
pub struct Options

How a diff check runs.

Also implements Default.
use utopia_agents::diff_check::Outcome;
Rust
pub struct Outcome

The result of a diff check.

use utopia_agents::diff_check::Repository;
Rust
pub struct Repository

A repository to compare: a local directory, or a remote Git URL to clone, at an optional ref.

use utopia_agents::diff_check::Runner;
Rust
pub enum Runner<'a, A>

Who answers: an agent (configured further by the options) or an adapter (wrapped in a new agent).

use utopia_agents::diff_check::Source;
Rust
pub enum Source

What to compare: a path or URL, or a Repository.

Also implements From.