Add the Review Loop: unattended review-and-fix rounds in the desktop app and in loop phases

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-28 21:09:02 -08:00
1 parent d6a28b5dc8
commit 57567d7a0b
71 files changed
+11331 -443

No files matched your search

+39 -3
View File
@@ -600,11 +600,17 @@ pub fn git_head_short(project: &Path) -> Option<String> {
(run.ok && !hash.is_empty()).then(|| hash.to_string())
}
/// The full hash of `HEAD`, when there is a commit.
pub fn git_head_full(project: &Path) -> Option<String> {
/// The full hash of `HEAD` (40 or 64 hex characters), or why there is none.
pub fn git_head_full(project: &Path) -> Result<String, String> {
let run = run_limited(git(project, &["rev-parse", "HEAD"]), None, QUICK_LIMIT);
let hash = run.output.trim();
(run.ok && !hash.is_empty()).then(|| hash.to_string())
if !run.ok {
return Err("git could not read the current commit".to_string());
}
if !matches!(hash.len(), 40 | 64) || !hash.chars().all(|c| c.is_ascii_hexdigit()) {
return Err("git did not return a full commit id".to_string());
}
Ok(hash.to_string())
}
/// The paths `git status --porcelain=v1 -z` lists (renames name the new path).
@@ -799,6 +805,36 @@ mod tests {
let _ = std::fs::remove_dir_all(&repo);
}
#[test]
fn the_full_head_hash_starts_with_the_short_one() {
if Command::new("git").arg("--version").output().is_err() {
assert!(std::env::var_os("CI").is_none(), "git is not on PATH");
return;
}
let repo = std::env::temp_dir().join(format!("plan2code-head-full-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&repo);
std::fs::create_dir_all(&repo).unwrap();
let git_in = |args: &[&str]| {
let status = Command::new("git")
.args(["-c", "user.name=t", "-c", "user.email=t@example.com"])
.args(args)
.current_dir(&repo)
.status()
.unwrap();
assert!(status.success(), "git {args:?}");
};
git_in(&["init", "-q"]);
assert!(git_head_full(&repo).is_err(), "no commit yet");
std::fs::write(repo.join("a.txt"), "x").unwrap();
git_in(&["add", "-A"]);
git_in(&["commit", "-q", "--no-gpg-sign", "-m", "first"]);
let full = git_head_full(&repo).unwrap();
let short = git_head_short(&repo).unwrap();
assert!(full.starts_with(&short), "{full} / {short}");
assert!(matches!(full.len(), 40 | 64));
let _ = std::fs::remove_dir_all(&repo);
}
#[test]
fn the_commit_message_is_read_from_the_scripts_output_without_a_shell() {
let ok = r#"{"ok":true,"subject":"Add it","message":"Add it\n\nAI Assisted"}"#;