diff --git a/apps/infrastructure/src/utils.rs b/apps/infrastructure/src/utils.rs index 5feff50..44aed29 100644 --- a/apps/infrastructure/src/utils.rs +++ b/apps/infrastructure/src/utils.rs @@ -259,5 +259,55 @@ pub fn build_rich_context(root: &Path) -> String { } } + // 5. Active Background Jobs + let jobs = crate::bgbash::control::bash_control().list(); + if !jobs.is_empty() { + ctx.push_str("### Active Background Jobs\n```\n"); + for (id, cmd, _) in jobs { + ctx.push_str(&format!("[{}] {}\n", id, cmd)); + } + ctx.push_str("```\n\n"); + } + + // 6. Project Purpose (README) + let readme_path = root.join("README.md"); + if let Ok(content) = std::fs::read_to_string(&readme_path) { + let snippet = if content.len() > 1000 { + format!("{}\n... (truncated)", &content[..1000]) + } else { + content + }; + ctx.push_str(&format!("### Project Purpose (README.md)\n```\n{}\n```\n\n", snippet.trim())); + } + + // 7. Recent Git History & Momentum + if root.join(".git").exists() { + let commits = Command::new("git") + .arg("log") + .arg("-n") + .arg("3") + .arg("--oneline") + .current_dir(root) + .output() + .map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string()) + .unwrap_or_default(); + + if !commits.is_empty() { + ctx.push_str(&format!("### Recent Commits (Momentum)\n```\n{}\n```\n\n", commits)); + } + + let diff = Command::new("git") + .arg("diff") + .arg("--name-only") + .current_dir(root) + .output() + .map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string()) + .unwrap_or_default(); + + if !diff.is_empty() { + ctx.push_str(&format!("### Recently Modified Files (Uncommitted)\n```\n{}\n```\n\n", diff)); + } + } + ctx.trim_end().to_string() }