cliai 0.1.0

A small Rust library for invoking AI tools through CLI backends like Ollama and GitHub Copilot CLI.
Documentation
use cliai::{AiBackend, Copilot, GenerateRequest};
use std::process::Command;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let output = Command::new("git").args(["diff", "--staged"]).output()?;

    println!(
        "diff --staged output:\n{}",
        String::from_utf8_lossy(&output.stdout)
    );
    println!("Generating commit message...\n");
    let diff = String::from_utf8(output.stdout)?;

    let ai = Copilot::new();

    let prompt = format!("Write a conventional commit message based on:\n\n{}", diff);

    let res = ai.generate(&GenerateRequest {
        prompt,
        instructions: Some("Use conventional commits. Output only the commit message.".into()),
    })?;

    println!("{}", res.text);

    Ok(())
}