feat: surface ecc2 worktree pressure

This commit is contained in:
Affaan Mustafa
2026-04-08 14:43:42 -07:00
parent 027d77468e
commit 7f2c14ecf8
3 changed files with 203 additions and 11 deletions

View File

@@ -18,6 +18,13 @@ pub struct MergeReadiness {
pub conflicts: Vec<String>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WorktreeHealth {
Clear,
InProgress,
Conflicted,
}
/// Create a new git worktree for an agent session.
pub fn create_for_session(session_id: &str, cfg: &Config) -> Result<WorktreeInfo> {
let repo_root = std::env::current_dir().context("Failed to resolve repository root")?;
@@ -228,6 +235,19 @@ pub fn merge_readiness(worktree: &WorktreeInfo) -> Result<MergeReadiness> {
anyhow::bail!("git merge-tree failed: {stderr}");
}
pub fn health(worktree: &WorktreeInfo) -> Result<WorktreeHealth> {
let merge_readiness = merge_readiness(worktree)?;
if merge_readiness.status == MergeReadinessStatus::Conflicted {
return Ok(WorktreeHealth::Conflicted);
}
if diff_file_preview(worktree, 1)?.is_empty() {
Ok(WorktreeHealth::Clear)
} else {
Ok(WorktreeHealth::InProgress)
}
}
fn git_diff_shortstat(worktree_path: &Path, extra_args: &[&str]) -> Result<Option<String>> {
let mut command = Command::new("git");
command