pub mod builtin;
mod error;
pub mod loader;
mod manager;
mod template;
pub use error::PromptError;
pub use manager::PromptManager;
pub use template::PromptTemplate;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_prompt_manager_render() {
let mut pm = PromptManager::new();
let template = PromptTemplate::new("greeting", "Hello, {{ name }}!");
pm.add_template(template).unwrap();
let result = pm
.render("greeting", minijinja::context!(name => "World"))
.unwrap();
assert_eq!(result, "Hello, World!");
}
#[test]
fn test_should_load_all_builtin_templates_via_with_builtin_templates() {
let pm = PromptManager::with_builtin_templates().unwrap();
assert_eq!(pm.template_count(), builtin::BUILTIN_TEMPLATE_COUNT);
assert!(pm.get_template("init/system").is_some());
assert!(pm.get_template("run/dev_phase").is_some());
assert!(pm.get_template("plan/approve").is_some());
}
#[test]
fn test_should_render_builtin_template() {
let pm = PromptManager::with_builtin_templates().unwrap();
let result = pm.render("init/system", minijinja::context!());
assert!(result.is_ok(), "Failed to render init/system: {result:?}");
assert!(!result.unwrap().is_empty());
}
}