Gate review-loop command behind feature flag

This commit is contained in:
Cooper Gamble
2026-03-02 14:14:29 -08:00
parent 7709bf32a3
commit 49af46f7d9
18 changed files with 1892 additions and 187 deletions
+6
View File
@@ -397,6 +397,9 @@
"responses_websockets_v2": {
"type": "boolean"
},
"review_loop": {
"type": "boolean"
},
"runtime_metrics": {
"type": "boolean"
},
@@ -1768,6 +1771,9 @@
"responses_websockets_v2": {
"type": "boolean"
},
"review_loop": {
"type": "boolean"
},
"runtime_metrics": {
"type": "boolean"
},
+8
View File
@@ -143,6 +143,8 @@ pub enum Feature {
/// Enable collaboration modes (Plan, Default).
/// Kept for config backward compatibility; behavior is always collaboration-modes-enabled.
CollaborationModes,
/// Enable `/review-loop` command.
ReviewLoop,
/// Enable personality selection in the TUI.
Personality,
/// Enable voice transcription in the TUI composer.
@@ -660,6 +662,12 @@ pub const FEATURES: &[FeatureSpec] = &[
stage: Stage::Stable,
default_enabled: true,
},
FeatureSpec {
id: Feature::ReviewLoop,
key: "review_loop",
stage: Stage::UnderDevelopment,
default_enabled: false,
},
FeatureSpec {
id: Feature::VoiceTranscription,
key: "voice_transcription",
+82
View File
@@ -18,6 +18,8 @@ const BASE_BRANCH_PROMPT: &str = "Review the code changes against the base branc
const COMMIT_PROMPT_WITH_TITLE: &str = "Review the code changes introduced by commit {sha} (\"{title}\"). Provide prioritized, actionable findings.";
const COMMIT_PROMPT: &str =
"Review the code changes introduced by commit {sha}. Provide prioritized, actionable findings.";
const COMMIT_FOLLOW_UP_PROMPT_WITH_TITLE: &str = "Review the cumulative code changes from {sha}^ through HEAD, rooted at commit {sha} (\"{title}\"). Run `git diff {sha}^ HEAD` to inspect the updated stack. Provide prioritized, actionable findings.";
const COMMIT_FOLLOW_UP_PROMPT: &str = "Review the cumulative code changes from {sha}^ through HEAD, rooted at commit {sha}. Run `git diff {sha}^ HEAD` to inspect the updated stack. Provide prioritized, actionable findings.";
pub fn resolve_review_request(
request: ReviewRequest,
@@ -67,6 +69,46 @@ pub fn review_prompt(target: &ReviewTarget, cwd: &Path) -> anyhow::Result<String
}
}
pub fn review_prompt_with_additional_instructions(
target: &ReviewTarget,
cwd: &Path,
additional_instructions: Option<&str>,
) -> anyhow::Result<String> {
let prompt = review_prompt(target, cwd)?;
Ok(append_additional_review_instructions(
prompt,
additional_instructions,
))
}
pub fn commit_follow_up_review_prompt(
sha: &str,
title: Option<&str>,
additional_instructions: Option<&str>,
) -> String {
let prompt = if let Some(title) = title {
COMMIT_FOLLOW_UP_PROMPT_WITH_TITLE
.replace("{sha}", sha)
.replace("{title}", title)
} else {
COMMIT_FOLLOW_UP_PROMPT.replace("{sha}", sha)
};
append_additional_review_instructions(prompt, additional_instructions)
}
fn append_additional_review_instructions(
prompt: String,
additional_instructions: Option<&str>,
) -> String {
let Some(additional_instructions) = additional_instructions.map(str::trim) else {
return prompt;
};
if additional_instructions.is_empty() {
return prompt;
}
format!("{prompt}\n\nAdditional review instructions:\n{additional_instructions}")
}
pub fn user_facing_hint(target: &ReviewTarget) -> String {
match target {
ReviewTarget::UncommittedChanges => "current changes".to_string(),
@@ -91,3 +133,43 @@ impl From<ResolvedReviewRequest> for ReviewRequest {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use pretty_assertions::assert_eq;
#[test]
fn review_prompt_with_additional_instructions_appends_header() {
let cwd = Path::new("/tmp");
let prompt = review_prompt_with_additional_instructions(
&ReviewTarget::UncommittedChanges,
cwd,
Some("Focus on migration safety."),
)
.expect("prompt");
assert_eq!(
prompt,
"Review the current code changes (staged, unstaged, and untracked files) and provide prioritized findings.\n\nAdditional review instructions:\nFocus on migration safety."
);
}
#[test]
fn commit_follow_up_review_prompt_references_cumulative_stack() {
let prompt =
commit_follow_up_review_prompt("abc1234", Some("Add review loop"), Some("Find bugs."));
assert_eq!(
prompt,
"Review the cumulative code changes from abc1234^ through HEAD, rooted at commit abc1234 (\"Add review loop\"). Run `git diff abc1234^ HEAD` to inspect the updated stack. Provide prioritized, actionable findings.\n\nAdditional review instructions:\nFind bugs."
);
}
#[test]
fn commit_follow_up_review_prompt_omits_empty_additional_instructions() {
let prompt = commit_follow_up_review_prompt("abc1234", None, Some(" "));
assert_eq!(
prompt,
"Review the cumulative code changes from abc1234^ through HEAD, rooted at commit abc1234. Run `git diff abc1234^ HEAD` to inspect the updated stack. Provide prioritized, actionable findings."
);
}
}