const START_MARKER: &str = "<!-- lean-ctx-solution -->";
const END_MARKER: &str = "<!-- /lean-ctx-solution -->";
const MINIMAL_RULES: &str =
"Prefer the standard library and platform-native capabilities before adding dependencies.";
const BALANCED_RULES: &str = "Solution ladder: skip → reuse → stdlib → native → dependency → one-line → minimum.\nSafety: choose the smallest safe solution; validate inputs and preserve existing behavior.";
const AGGRESSIVE_RULES: &str = "Challenge first: can this be deleted or skipped? Prefer deletion.\nSolution ladder: skip → reuse → stdlib → native → dependency → one-line → minimum.\nSafety: choose the smallest safe solution; validate inputs and preserve existing behavior.";
pub fn solution_rules_block(intensity: &str) -> String {
let rules = match intensity {
"minimal" => MINIMAL_RULES,
"aggressive" => AGGRESSIVE_RULES,
_ => BALANCED_RULES,
};
format!("{START_MARKER}\n{rules}\n{END_MARKER}")
}
pub fn solution_subagent_instructions(_intensity: &str) -> &'static str {
"Challenge the need, reuse existing code, prefer stdlib or native capabilities, and add dependencies only when justified."
}
pub fn solution_compose_hints(config_enabled: bool, project_deps: &[String]) -> String {
if !config_enabled {
return String::new();
}
let mut lines = vec![START_MARKER.to_string()];
if !project_deps.is_empty() {
lines.push(format!("Installed deps: {}", project_deps.join(", ")));
}
lines.push(
"Prefer the standard library and platform-native capabilities before adding dependencies."
.to_string(),
);
lines.push(END_MARKER.to_string());
lines.join("\n")
}
pub fn should_inject(config_enabled: bool, inject_flag: bool) -> bool {
config_enabled && inject_flag
}
#[cfg(test)]
mod tests {
use super::solution_compose_hints;
#[test]
fn compose_hints_include_detected_dependencies() {
let dependencies = ["tokio".to_string(), "serde".to_string()];
let hints = solution_compose_hints(true, &dependencies);
assert!(hints.contains("Installed deps: tokio, serde"));
}
}