use crate::agent::model_family::ModelFamily;
use crate::agent::prompt::{
DEEPSEEK_GUIDANCE, MEMORY_GUIDANCE, SESSION_SEARCH_GUIDANCE, SKILLS_GUIDANCE, SYSTEM_PROMPT,
TODO_TOOLS_PROMPT,
};
pub(crate) fn append_memory_to_preamble(
preamble: &mut String,
provider: &std::sync::Arc<dyn crate::extras::memory_provider::MemoryProvider>,
) {
tracing::debug!(
target: "dirge::memory",
provider = provider.name(),
"Injecting memory provider prompt block"
);
let block = provider.format_for_system_prompt();
if !block.is_empty() {
preamble.push_str(&block);
}
}
pub(crate) fn append_global_memory_to_preamble(
preamble: &mut String,
provider: &std::sync::Arc<dyn crate::extras::memory_provider::MemoryProvider>,
) {
let block = provider.format_for_system_prompt();
if !block.is_empty() {
preamble.push_str("\n\n## Global memory (cross-project user preferences)\n");
preamble.push_str(&block);
}
}
pub(crate) fn assemble_base_preamble() -> String {
let mut p = SYSTEM_PROMPT.to_string();
p.push('\n');
p.push_str(TODO_TOOLS_PROMPT);
p.push_str(SKILLS_GUIDANCE);
p.push_str(MEMORY_GUIDANCE);
p.push_str(SESSION_SEARCH_GUIDANCE);
p
}
pub(crate) fn model_steering_fragment(family: ModelFamily) -> Option<&'static str> {
if family.is_deepseek_chat() {
Some(DEEPSEEK_GUIDANCE)
} else {
None
}
}
pub(crate) fn append_mode_reminder(preamble: &mut String, prompt_name: &str, plan_exists: bool) {
match prompt_name {
"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" if plan_exists => {
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.",
);
}
_ => {}
}
}