From 8d198767a483a7f27ce8e7d8545db4ac05851eb2 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Tue, 19 May 2026 11:30:48 -0400 Subject: [PATCH 1/2] Inject mode-specific reminders on prompt switch (Phase 8) - Plan mode: reminder to create a detailed plan in PLAN.md - Code mode with existing PLAN.md: reminder to execute the plan step by step - Review modes: reminder to review thoroughly and provide actionable feedback - Code mode without PLAN.md: no additional context injected --- src/agent/builder.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/agent/builder.rs b/src/agent/builder.rs index 7e9a2730..2b969780 100644 --- a/src/agent/builder.rs +++ b/src/agent/builder.rs @@ -107,6 +107,29 @@ pub async fn build_agent_inner( preamble.push_str(&format!("\nGit branch: {}", branch)); } + // Inject mode-specific reminders + if let Some(prompt_name) = &context.current_prompt_name { + match prompt_name.as_str() { + "plan" => { + preamble.push_str("\n\n---\n\nYou are now in PLAN mode. Create a detailed implementation plan. Save it to PLAN.md in the current directory. Analyze the task, break it into concrete steps, consider edge cases and trade-offs. Do NOT write any code or run any commands until the user reviews and approves the plan."); + } + "review" | "review-security" => { + preamble.push_str("\n\n---\n\nYou are now in REVIEW mode. Review the code or plan carefully. Identify bugs, security issues, performance problems, and design flaws. Be thorough and specific. Provide actionable feedback."); + } + "code" => { + let plan_path = std::env::current_dir() + .unwrap_or_else(|_| ".".into()) + .join("PLAN.md"); + if plan_path.exists() { + preamble.push_str(&format!( + "\n\n---\n\nA plan file exists at PLAN.md. Execute the plan step by step. Write and test code following the plan. Report progress after each step. The plan is your guide — follow it closely." + )); + } + } + _ => {} + } + } + let mut builder = AgentBuilder::new(model).preamble(&preamble); let max_tokens = cli.resolve_max_tokens(cfg); From 8ec159b0670183a05bd2b746a03cb754ff9ddcf6 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Tue, 19 May 2026 12:02:20 -0400 Subject: [PATCH 2/2] Fix agent-reminders: use push_str instead of format! with no args MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit format!() with no interpolation args is needless — replaced with push_str. --- src/agent/builder.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/agent/builder.rs b/src/agent/builder.rs index 2b969780..40b463d4 100644 --- a/src/agent/builder.rs +++ b/src/agent/builder.rs @@ -121,9 +121,9 @@ pub async fn build_agent_inner( .unwrap_or_else(|_| ".".into()) .join("PLAN.md"); if plan_path.exists() { - preamble.push_str(&format!( + preamble.push_str( "\n\n---\n\nA plan file exists at PLAN.md. Execute the plan step by step. Write and test code following the plan. Report progress after each step. The plan is your guide — follow it closely." - )); + ); } } _ => {}