use std::path::PathBuf;
pub struct PlanManager {
forge_dir: PathBuf,
}
impl PlanManager {
pub fn new(forge_dir: impl Into<PathBuf>) -> Self {
Self {
forge_dir: forge_dir.into(),
}
}
fn plan_path(&self) -> PathBuf {
self.forge_dir.join("plan.md")
}
pub fn has_plan(&self) -> bool {
self.plan_path().exists()
}
pub fn read_plan(&self) -> anyhow::Result<String> {
Ok(std::fs::read_to_string(self.plan_path())?)
}
pub fn write_plan(&self, content: &str) -> anyhow::Result<()> {
std::fs::create_dir_all(&self.forge_dir)?;
std::fs::write(self.plan_path(), content)?;
Ok(())
}
pub fn generate_template(project_name: &str) -> String {
format!(
"# {project_name} — Master Plan\n\n\
**Generated by:** Forge Orchestrator v0.1.0\n\
**Date:** {date}\n\n\
---\n\n\
## Vision\n\n\
_Describe the project vision here._\n\n\
## Tasks\n\n\
No tasks yet. Run `forge plan --generate` to create tasks from your project context.\n\n\
## Notes\n\n\
_Add any notes about the plan here._\n",
date = chrono::Utc::now().format("%Y-%m-%d"),
)
}
}