agent-trace 0.1.0

Git-backed document memory, trace continuity, and permissioned writes for agent workflows
Documentation
use crate::git_store::CommitInfo;
use crate::observability::CliOutput;
use crate::store::Store;
use crate::types::{Action, Actor, DocType};
use anyhow::Result;
use std::path::Path;

pub fn run(store_root: &Path, file: &Path, output: &dyn CliOutput) -> Result<()> {
    let mut store = Store::open(store_root)?;

    let doc_type = store
        .manifest
        .find_by_path(file)
        .map(|d| d.doc_type.clone())
        .unwrap_or(DocType::Scratch);

    store.manifest.untrack(file)?;
    store.manifest.save(store_root)?;

    let full_path = store_root.join(file);
    if full_path.exists() {
        std::fs::remove_file(&full_path)?;
    }

    let info = CommitInfo {
        action: Action::Delete,
        files: vec![(file.to_path_buf(), Action::Delete, doc_type)],
        actor: Actor::User,
        summary: format!("rm {}", file.display()),
        agent_name: None,
        session_id: None,
    };
    store.commit(&info)?;

    output.line(&format!("Removed {}", file.display()))?;
    Ok(())
}