feat: b5-git-aware — batch 5 wave 2

This commit is contained in:
YeonGyu-Kim
2026-04-07 15:15:42 +09:00
parent 4557a81d2f
commit ef0b870890
4 changed files with 338 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ use std::path::{Path, PathBuf};
use std::process::Command;
use crate::config::{ConfigError, ConfigLoader, RuntimeConfig};
use crate::git_context::GitContext;
/// Errors raised while assembling the final system prompt.
#[derive(Debug)]
@@ -56,7 +57,7 @@ pub struct ProjectContext {
pub current_date: String,
pub git_status: Option<String>,
pub git_diff: Option<String>,
pub git_recent_commits: Option<String>,
pub git_context: Option<GitContext>,
pub instruction_files: Vec<ContextFile>,
}
@@ -72,7 +73,7 @@ impl ProjectContext {
current_date: current_date.into(),
git_status: None,
git_diff: None,
git_recent_commits: None,
git_context: None,
instruction_files,
})
}
@@ -84,7 +85,7 @@ impl ProjectContext {
let mut context = Self::discover(cwd, current_date)?;
context.git_status = read_git_status(&context.cwd);
context.git_diff = read_git_diff(&context.cwd);
context.git_recent_commits = read_git_recent_commits(&context.cwd);
context.git_context = GitContext::detect(&context.cwd);
Ok(context)
}
}
@@ -337,6 +338,13 @@ fn render_project_context(project_context: &ProjectContext) -> String {
lines.push("Git diff snapshot:".to_string());
lines.push(diff.clone());
}
if let Some(git_context) = &project_context.git_context {
let rendered = git_context.render();
if !rendered.is_empty() {
lines.push(String::new());
lines.push(rendered);
}
}
lines.join("\n")
}