coda_pm/template.rs
1//! Prompt template data structure.
2//!
3//! Contains `PromptTemplate`, the core data type representing a named
4//! minijinja template with its raw content.
5
6use serde::{Deserialize, Serialize};
7
8/// A named prompt template with its raw minijinja content.
9///
10/// Template names use `/`-separated paths (e.g., `"init/system"`) to
11/// organize templates hierarchically by phase.
12///
13/// # Examples
14///
15/// ```
16/// use coda_pm::PromptTemplate;
17///
18/// let tmpl = PromptTemplate::new("greeting", "Hello, {{ name }}!");
19/// assert_eq!(tmpl.name, "greeting");
20/// assert!(tmpl.content.contains("{{ name }}"));
21/// ```
22#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct PromptTemplate {
24 /// Template identifier (e.g., `"init/system"`, `"run/dev_phase"`).
25 pub name: String,
26
27 /// Raw minijinja template content.
28 pub content: String,
29}
30
31impl PromptTemplate {
32 /// Creates a new prompt template with the given name and content.
33 pub fn new(name: impl Into<String>, content: impl Into<String>) -> Self {
34 Self {
35 name: name.into(),
36 content: content.into(),
37 }
38 }
39}