Skip to main content

mur_common/companion/
content_seed.rs

1//! Embedded content pool seed. mur-core 'companion init' copies these to disk;
2//! later phases let users edit on disk; mur-agent-runtime never reads embedded
3//! seed at runtime (it reads the disk copy).
4
5use crate::companion::Situation;
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
9pub struct SituationFile {
10    pub situation: Situation,
11    pub locale: String,
12    pub templates: Vec<TemplateSeed>,
13}
14
15#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
16pub struct TemplateSeed {
17    pub id: String,
18    #[serde(default = "default_weight")]
19    pub weight: f32,
20    pub cooldown_days: u32,
21    #[serde(default)]
22    pub tags: Vec<String>,
23    pub source: String,
24    pub reviewed_by: String,
25    pub prompt_seed: String,
26}
27
28fn default_weight() -> f32 {
29    1.0
30}
31
32pub const MORNING_GREETING_ZH_TW: &str = include_str!("content/morning_greeting.zh-TW.yaml");
33pub const MORNING_GREETING_EN_US: &str = include_str!("content/morning_greeting.en-US.yaml");
34pub const GENTLE_CHECK_IN_ZH_TW: &str = include_str!("content/gentle_check_in.zh-TW.yaml");
35pub const GENTLE_CHECK_IN_EN_US: &str = include_str!("content/gentle_check_in.en-US.yaml");
36pub const SHARE_QUOTE_ZH_TW: &str = include_str!("content/share_quote.zh-TW.yaml");
37pub const SHARE_QUOTE_EN_US: &str = include_str!("content/share_quote.en-US.yaml");
38pub const SHARE_LINK_ZH_TW: &str = include_str!("content/share_link.zh-TW.yaml");
39pub const SHARE_LINK_EN_US: &str = include_str!("content/share_link.en-US.yaml");
40
41/// Returns `(situation, locale, raw_yaml)` for every embedded seed file.
42/// Used by `mur agent companion init` (M1.6+) to seed the user's disk copy.
43pub fn all_seeds() -> Vec<(Situation, &'static str, &'static str)> {
44    use Situation::*;
45    vec![
46        (MorningGreeting, "zh-TW", MORNING_GREETING_ZH_TW),
47        (MorningGreeting, "en-US", MORNING_GREETING_EN_US),
48        (GentleCheckIn, "zh-TW", GENTLE_CHECK_IN_ZH_TW),
49        (GentleCheckIn, "en-US", GENTLE_CHECK_IN_EN_US),
50        (ShareQuote, "zh-TW", SHARE_QUOTE_ZH_TW),
51        (ShareQuote, "en-US", SHARE_QUOTE_EN_US),
52        (ShareLink, "zh-TW", SHARE_LINK_ZH_TW),
53        (ShareLink, "en-US", SHARE_LINK_EN_US),
54    ]
55}
56
57/// Parse the embedded YAML into a typed `SituationFile`.
58pub fn parse(yaml: &str) -> Result<SituationFile, serde_yaml_ng::Error> {
59    serde_yaml_ng::from_str(yaml)
60}