use super::*;
#[test]
fn test_all_prompts_loaded() {
assert!(!SYSTEM_DEFAULT.is_empty());
assert!(!CONTINUATION.is_empty());
assert!(!BOUNDARIES.is_empty());
assert!(!AGENT_EXPLORE.is_empty());
assert!(!AGENT_PLAN.is_empty());
assert!(!AGENT_CODE_REVIEW.is_empty());
assert!(!CONTEXT_COMPACT.is_empty());
assert!(!LLM_PLAN_SYSTEM.is_empty());
assert!(!LLM_GOAL_EXTRACT_SYSTEM.is_empty());
assert!(!LLM_GOAL_CHECK_SYSTEM.is_empty());
assert!(!SKILLS_CATALOG_HEADER.is_empty());
assert!(!PLAN_EXECUTE_GOAL.is_empty());
assert!(!PLAN_EXECUTE_STEP.is_empty());
assert!(!PLAN_FALLBACK_STEP.is_empty());
}
#[test]
fn test_render_template() {
let result = render(
PLAN_EXECUTE_GOAL,
&[("goal", "Build app"), ("steps", "1. Init")],
);
assert!(result.contains("Build app"));
assert!(!result.contains("{goal}"));
}
#[test]
fn test_render_multiple_placeholders() {
let template = "Goal: {goal}\nCriteria: {criteria}\nState: {current_state}";
let result = render(
template,
&[
("goal", "Build a REST API"),
("criteria", "- Endpoint works\n- Tests pass"),
("current_state", "API is deployed"),
],
);
assert!(result.contains("Build a REST API"));
assert!(result.contains("Endpoint works"));
assert!(result.contains("API is deployed"));
}
#[test]
fn test_delegated_agent_prompts_contain_guidelines() {
assert!(AGENT_EXPLORE.contains("Guidelines"));
assert!(AGENT_EXPLORE.contains("read-only"));
assert!(AGENT_PLAN.contains("Guidelines"));
assert!(AGENT_PLAN.contains("read-only"));
}
#[test]
fn test_context_summary_prefix() {
assert!(CONTEXT_SUMMARY_PREFIX.contains("Context Summary"));
}
#[test]
fn test_slots_default_builds_system_default() {
let slots = SystemPromptSlots::default();
let built = slots.build();
assert!(built.contains("Core Behaviour"));
assert!(built.contains("Tool Usage Strategy"));
assert!(built.contains("Completion Criteria"));
assert!(built.contains("Response Format"));
assert!(built.contains("A3S Code"));
assert!(built.contains("## Boundaries"));
assert!(built.contains("untrusted data"));
}
#[test]
fn test_boundaries_injected_for_every_style() {
for style in [
AgentStyle::GeneralPurpose,
AgentStyle::Plan,
AgentStyle::Verification,
AgentStyle::Explore,
AgentStyle::CodeReview,
] {
let built = SystemPromptSlots::default().with_style(style).build();
assert!(
built.contains("## Boundaries"),
"style {style:?} missing Boundaries section"
);
}
}
#[test]
fn test_boundaries_not_duplicated_in_general_purpose() {
assert!(!SYSTEM_DEFAULT.contains("## Boundaries"));
let built = SystemPromptSlots::default().build();
assert_eq!(built.matches("## Boundaries").count(), 1);
}
#[test]
fn test_slots_custom_role_replaces_default() {
let slots = SystemPromptSlots {
role: Some("You are a senior Python developer".to_string()),
..Default::default()
};
let built = slots.build();
assert!(built.contains("You are a senior Python developer"));
assert!(!built.contains("You are A3S Code"));
assert!(built.contains("Core Behaviour"));
assert!(built.contains("Tool Usage Strategy"));
}
#[test]
fn test_slots_custom_guidelines_appended() {
let slots = SystemPromptSlots {
guidelines: Some("Always use type hints. Follow PEP 8.".to_string()),
..Default::default()
};
let built = slots.build();
assert!(built.contains("## Guidelines"));
assert!(built.contains("Always use type hints"));
assert!(built.contains("Core Behaviour"));
}
#[test]
fn test_slots_custom_response_style_replaces_default() {
let slots = SystemPromptSlots {
response_style: Some("Be concise. Use bullet points.".to_string()),
..Default::default()
};
let built = slots.build();
assert!(built.contains("Be concise. Use bullet points."));
assert!(!built.contains("keep progress notes brief and useful"));
assert!(built.contains("Core Behaviour"));
}
#[test]
fn test_slots_extra_appended() {
let slots = SystemPromptSlots {
extra: Some("Remember: always write tests first.".to_string()),
..Default::default()
};
let built = slots.build();
assert!(built.contains("Remember: always write tests first."));
assert!(built.contains("Core Behaviour"));
}
#[test]
fn test_slots_with_extra() {
let slots = SystemPromptSlots::default().with_extra("You are a helpful assistant.");
let built = slots.build();
assert!(built.contains("You are a helpful assistant."));
assert!(built.contains("Core Behaviour"));
assert!(built.contains("Tool Usage Strategy"));
}
#[test]
fn test_slots_all_slots_combined() {
let slots = SystemPromptSlots {
style: None,
role: Some("You are a Rust expert".to_string()),
guidelines: Some("Use clippy. No unwrap.".to_string()),
response_style: Some("Short answers only.".to_string()),
extra: Some("Project uses tokio.".to_string()),
};
let built = slots.build();
assert!(built.contains("You are a Rust expert"));
assert!(built.contains("Core Behaviour"));
assert!(built.contains("## Guidelines"));
assert!(built.contains("Use clippy"));
assert!(built.contains("Short answers only"));
assert!(built.contains("Project uses tokio"));
assert!(!built.contains("keep progress notes brief and useful"));
}
#[test]
fn test_slots_is_empty() {
assert!(SystemPromptSlots::default().is_empty());
assert!(!SystemPromptSlots {
role: Some("test".to_string()),
..Default::default()
}
.is_empty());
assert!(!SystemPromptSlots {
style: Some(AgentStyle::Plan),
..Default::default()
}
.is_empty());
}
#[test]
fn test_agent_style_default_is_general_purpose() {
assert_eq!(AgentStyle::default(), AgentStyle::GeneralPurpose);
}
#[test]
fn test_agent_style_base_prompt() {
assert_eq!(AgentStyle::GeneralPurpose.base_prompt(), SYSTEM_DEFAULT);
assert_eq!(AgentStyle::Plan.base_prompt(), AGENT_PLAN);
assert_eq!(AgentStyle::Explore.base_prompt(), AGENT_EXPLORE);
assert_eq!(AgentStyle::Verification.base_prompt(), AGENT_VERIFICATION);
assert_eq!(AgentStyle::CodeReview.base_prompt(), AGENT_CODE_REVIEW);
}
#[test]
fn test_agent_style_guidelines() {
assert!(AgentStyle::GeneralPurpose.guidelines().is_none());
assert!(AgentStyle::Plan.guidelines().is_none()); assert!(AgentStyle::Explore.guidelines().is_none());
assert!(AgentStyle::Verification.guidelines().is_none());
assert!(AgentStyle::CodeReview.guidelines().is_none());
}
#[test]
fn test_agent_style_builtin_agent_name_mapping() {
assert_eq!(AgentStyle::GeneralPurpose.builtin_agent_name(), "general");
assert_eq!(AgentStyle::Plan.builtin_agent_name(), "plan");
assert_eq!(AgentStyle::Explore.builtin_agent_name(), "explore");
assert_eq!(
AgentStyle::Verification.builtin_agent_name(),
"verification"
);
assert_eq!(AgentStyle::CodeReview.builtin_agent_name(), "review");
}
#[test]
fn test_agent_style_runtime_mode_mapping() {
assert_eq!(AgentStyle::GeneralPurpose.runtime_mode(), "general");
assert_eq!(AgentStyle::Plan.runtime_mode(), "planning");
assert_eq!(AgentStyle::Explore.runtime_mode(), "explore");
assert_eq!(AgentStyle::Verification.runtime_mode(), "verification");
assert_eq!(AgentStyle::CodeReview.runtime_mode(), "code_review");
}
#[test]
fn test_agent_style_detect_plan() {
assert_eq!(
AgentStyle::detect_from_message("Help me plan a new feature"),
AgentStyle::Plan
);
assert_eq!(
AgentStyle::detect_from_message("Design the architecture for this"),
AgentStyle::Plan
);
assert_eq!(
AgentStyle::detect_from_message("What's the implementation approach?"),
AgentStyle::Plan
);
}
#[test]
fn test_agent_style_detect_verification() {
assert_eq!(
AgentStyle::detect_from_message("Verify that this works correctly"),
AgentStyle::Verification
);
assert_eq!(
AgentStyle::detect_from_message("Test the login flow"),
AgentStyle::Verification
);
assert_eq!(
AgentStyle::detect_from_message("Check if the API handles edge cases"),
AgentStyle::Verification
);
}
#[test]
fn test_agent_style_detect_explore() {
assert_eq!(
AgentStyle::detect_from_message("Find all files related to auth"),
AgentStyle::Explore
);
assert_eq!(
AgentStyle::detect_from_message("Where is the user model defined?"),
AgentStyle::Explore
);
assert_eq!(
AgentStyle::detect_from_message("Search for password hashing code"),
AgentStyle::Explore
);
}
#[test]
fn test_agent_style_detect_code_review() {
assert_eq!(
AgentStyle::detect_from_message("Review the PR changes"),
AgentStyle::CodeReview
);
assert_eq!(
AgentStyle::detect_from_message("Analyze this code for best practices"),
AgentStyle::CodeReview
);
assert_eq!(
AgentStyle::detect_from_message("Assess code quality"),
AgentStyle::CodeReview
);
}
#[test]
fn test_agent_style_detect_default_is_general_purpose() {
assert_eq!(
AgentStyle::detect_from_message("Implement the new feature"),
AgentStyle::GeneralPurpose
);
assert_eq!(
AgentStyle::detect_from_message("Write code for the API"),
AgentStyle::GeneralPurpose
);
}
#[test]
fn test_build_with_message_auto_detects_style() {
let slots = SystemPromptSlots::default();
let built = slots.build_with_message("Help me plan a new feature");
assert!(built.contains("planning agent") || built.contains("READ-ONLY"));
}
#[test]
fn test_build_with_message_explicit_style_overrides() {
let slots = SystemPromptSlots {
style: Some(AgentStyle::Verification),
..Default::default()
};
let built = slots.build_with_message("Help me plan a new feature");
assert!(built.contains("adversarial verification specialist"));
}
#[test]
fn test_build_with_message_plan_style() {
let slots = SystemPromptSlots::default();
let built = slots.build_with_message("Design the system architecture");
assert!(built.contains("planning agent") || built.contains("READ-ONLY"));
}
#[test]
fn test_build_with_message_explore_style() {
let slots = SystemPromptSlots::default();
let built = slots.build_with_message("Find all authentication files");
assert!(built.contains("exploration agent") || built.contains("explore"));
}
#[test]
fn test_build_with_message_code_review_style() {
let slots = SystemPromptSlots::default();
let built = slots.build_with_message("Review this code");
assert!(built.contains("code review agent"));
assert!(built.contains("regressions"));
}
#[test]
fn test_builder_methods() {
let slots = SystemPromptSlots::default()
.with_style(AgentStyle::Plan)
.with_role("You are a Python expert")
.with_guidelines("Use type hints")
.with_response_style("Be brief")
.with_extra("Additional instructions");
assert_eq!(slots.style, Some(AgentStyle::Plan));
assert_eq!(slots.role, Some("You are a Python expert".to_string()));
assert_eq!(slots.guidelines, Some("Use type hints".to_string()));
assert_eq!(slots.response_style, Some("Be brief".to_string()));
assert_eq!(slots.extra, Some("Additional instructions".to_string()));
let built = slots.build();
assert!(built.contains("Python expert"));
assert!(built.contains("Use type hints"));
assert!(built.contains("Be brief"));
assert!(built.contains("Additional instructions"));
}
#[test]
fn test_code_review_guidelines_appended() {
let slots = SystemPromptSlots {
style: Some(AgentStyle::CodeReview),
..Default::default()
};
let built = slots.build();
assert!(built.contains("code review agent"));
assert!(built.contains("correctness"));
assert!(built.contains("regressions"));
assert!(built.contains("security"));
}
#[test]
fn test_prompts_do_not_reference_removed_surfaces() {
let prompts = [
SYSTEM_DEFAULT,
AGENT_VERIFICATION,
PRE_ANALYSIS_SYSTEM,
AGENT_EXPLORE,
AGENT_PLAN,
AGENT_CODE_REVIEW,
SKILLS_CATALOG_HEADER,
CONTINUATION,
]
.join("\n")
.to_lowercase();
for removed in [
"orchestrator",
"plugin",
"agentic_search",
"agentic_parse",
"agentic-search",
"agentic-parse",
"manage_skill",
"claude.md",
] {
assert!(
!prompts.contains(removed),
"prompt still references removed surface: {removed}"
);
}
assert!(SYSTEM_DEFAULT.contains("program"));
assert!(SYSTEM_DEFAULT.contains("task"));
assert!(SYSTEM_DEFAULT.contains("parallel_task"));
}