use super::host_prompt::HOST_HEADING;
const HEADING: &str = "\n\n# Agent instructions\n\n";
pub(crate) fn section(text: &str) -> String {
format!("{HEADING}{text}")
}
pub(crate) fn of<'a>(system: &'a str, suffixes: &[&str]) -> Option<&'a str> {
let (_, rest) = system.rsplit_once(HEADING)?;
let rest = rest
.rsplit_once(HOST_HEADING)
.map_or(rest, |(text, _)| text);
Some(
suffixes
.iter()
.find_map(|suffix| rest.strip_suffix(suffix)?.strip_suffix("\n\n"))
.unwrap_or(rest),
)
}
#[cfg(test)]
#[path = "agent_instructions_tests.rs"]
mod tests;