use super::ProbeStack;
use std::path::{Path, PathBuf};
mod agent;
pub use agent::Agent;
#[derive(Debug, thiserror::Error)]
pub enum GitTreeError {
#[error("git invocation failed: {0}")]
Spawn(#[from] std::io::Error),
#[error("git {command} in {repo:?} failed: {stderr}")]
Git {
command: String,
repo: PathBuf,
stderr: String,
},
#[error("malformed git log line: {0:?}")]
LogFormat(String),
#[error("governing config: {0}")]
Governing(String),
}
#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub struct GitTree {
pub commits: Vec<CommitNode>,
pub agents: Vec<Agent>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CommitNode {
pub oid: String,
pub short_oid: String,
pub timestamp_unix: i64,
pub subject: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StepCommit {
pub oid: String,
pub short_oid: String,
pub timestamp_unix: i64,
pub subject: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ToolCall {
pub tool_id: String,
pub name: Option<String>,
pub start_unix: Option<i64>,
pub state: ToolCallState,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ToolCallState {
InFlight,
Complete,
}
impl GitTree {
pub fn from_repo(workspace: &Path) -> Result<Self, GitTreeError> {
ProbeStack::platform().derive(workspace)
}
}