use std::path::{Path, PathBuf};
include!("workspace/paths.rs");
include!("workspace/dir_entry.rs");
pub trait Workspace: Send + Sync {
fn root(&self) -> &Path;
fn read(&self, relative: &Path) -> std::io::Result<String>;
fn read_bytes(&self, relative: &Path) -> std::io::Result<Vec<u8>>;
fn write(&self, relative: &Path, content: &str) -> std::io::Result<()>;
fn write_bytes(&self, relative: &Path, content: &[u8]) -> std::io::Result<()>;
fn append_bytes(&self, relative: &Path, content: &[u8]) -> std::io::Result<()>;
fn exists(&self, relative: &Path) -> bool;
fn is_file(&self, relative: &Path) -> bool;
fn is_dir(&self, relative: &Path) -> bool;
fn remove(&self, relative: &Path) -> std::io::Result<()>;
fn remove_if_exists(&self, relative: &Path) -> std::io::Result<()>;
fn remove_dir_all(&self, relative: &Path) -> std::io::Result<()>;
fn remove_dir_all_if_exists(&self, relative: &Path) -> std::io::Result<()>;
fn create_dir_all(&self, relative: &Path) -> std::io::Result<()>;
fn read_dir(&self, relative: &Path) -> std::io::Result<Vec<DirEntry>>;
fn rename(&self, from: &Path, to: &Path) -> std::io::Result<()>;
fn write_atomic(&self, relative: &Path, content: &str) -> std::io::Result<()>;
fn set_readonly(&self, relative: &Path) -> std::io::Result<()>;
fn set_writable(&self, relative: &Path) -> std::io::Result<()>;
fn absolute(&self, relative: &Path) -> PathBuf {
self.root().join(relative)
}
fn absolute_str(&self, relative: &str) -> String {
self.root().join(relative).display().to_string()
}
fn agent_dir(&self) -> PathBuf {
self.root().join(AGENT_DIR)
}
fn agent_tmp(&self) -> PathBuf {
self.root().join(AGENT_TMP)
}
fn plan_md(&self) -> PathBuf {
self.root().join(PLAN_MD)
}
fn issues_md(&self) -> PathBuf {
self.root().join(ISSUES_MD)
}
fn status_md(&self) -> PathBuf {
self.root().join(STATUS_MD)
}
fn notes_md(&self) -> PathBuf {
self.root().join(NOTES_MD)
}
fn commit_message(&self) -> PathBuf {
self.root().join(COMMIT_MESSAGE_TXT)
}
fn checkpoint(&self) -> PathBuf {
self.root().join(CHECKPOINT_JSON)
}
fn start_commit(&self) -> PathBuf {
self.root().join(START_COMMIT)
}
fn review_baseline(&self) -> PathBuf {
self.root().join(REVIEW_BASELINE_TXT)
}
fn prompt_md(&self) -> PathBuf {
self.root().join(PROMPT_MD)
}
fn prompt_backup(&self) -> PathBuf {
self.root().join(PROMPT_BACKUP)
}
fn agent_config(&self) -> PathBuf {
self.root().join(AGENT_CONFIG_TOML)
}
fn agents_toml(&self) -> PathBuf {
self.root().join(AGENTS_TOML)
}
fn xsd_path(&self, name: &str) -> PathBuf {
self.root().join(format!(".agent/tmp/{name}.xsd"))
}
fn xml_path(&self, name: &str) -> PathBuf {
self.root().join(format!(".agent/tmp/{name}.xml"))
}
fn log_path(&self, name: &str) -> PathBuf {
self.root().join(format!(".agent/logs/{name}"))
}
}
pub mod files;
pub use files::WorkspaceFs;
#[cfg(any(test, feature = "test-utils"))]
pub mod memory_workspace;
#[cfg(any(test, feature = "test-utils"))]
pub use memory_workspace::MemoryWorkspace;
#[cfg(test)]
mod tests {
use super::*;
include!("workspace/tests.rs");
}