Skip to main content

task_graph_mcp/config/
embedded.rs

1//! Embedded workflow and overlay files.
2//!
3//! These files are compiled into the binary so they're always available,
4//! even when the install directory doesn't exist (e.g., new projects).
5
6/// Embedded workflow YAML files.
7pub mod workflows {
8    pub const HIERARCHICAL: &str = include_str!("../../config/workflow-hierarchical.yaml");
9    pub const KANBAN: &str = include_str!("../../config/workflow-kanban.yaml");
10    pub const PUSH: &str = include_str!("../../config/workflow-push.yaml");
11    pub const RELAY: &str = include_str!("../../config/workflow-relay.yaml");
12    pub const SOLO: &str = include_str!("../../config/workflow-solo.yaml");
13    pub const SPRINT: &str = include_str!("../../config/workflow-sprint.yaml");
14    pub const SWARM: &str = include_str!("../../config/workflow-swarm.yaml");
15
16    /// Get all embedded workflow names and their content.
17    pub fn all() -> Vec<(&'static str, &'static str)> {
18        vec![
19            ("hierarchical", HIERARCHICAL),
20            ("kanban", KANBAN),
21            ("push", PUSH),
22            ("relay", RELAY),
23            ("solo", SOLO),
24            ("sprint", SPRINT),
25            ("swarm", SWARM),
26        ]
27    }
28
29    /// Get embedded workflow by name.
30    pub fn get(name: &str) -> Option<&'static str> {
31        match name {
32            "hierarchical" => Some(HIERARCHICAL),
33            "kanban" => Some(KANBAN),
34            "push" => Some(PUSH),
35            "relay" => Some(RELAY),
36            "solo" => Some(SOLO),
37            "sprint" => Some(SPRINT),
38            "swarm" => Some(SWARM),
39            _ => None,
40        }
41    }
42
43    /// List all embedded workflow names.
44    pub fn names() -> Vec<&'static str> {
45        vec![
46            "hierarchical",
47            "kanban",
48            "push",
49            "relay",
50            "solo",
51            "sprint",
52            "swarm",
53        ]
54    }
55}
56
57/// Embedded overlay YAML files.
58pub mod overlays {
59    pub const GIT: &str = include_str!("../../config/overlay-git.yaml");
60    pub const GIT_WORKTREE: &str = include_str!("../../config/overlay-git-worktree.yaml");
61    pub const GOVERNANCE: &str = include_str!("../../config/overlay-governance.yaml");
62    pub const REASONING: &str = include_str!("../../config/overlay-reasoning.yaml");
63    pub const TROUBLESHOOTING: &str = include_str!("../../config/overlay-troubleshooting.yaml");
64
65    /// Get all embedded overlay names and their content.
66    pub fn all() -> Vec<(&'static str, &'static str)> {
67        vec![
68            ("git", GIT),
69            ("git-worktree", GIT_WORKTREE),
70            ("governance", GOVERNANCE),
71            ("reasoning", REASONING),
72            ("troubleshooting", TROUBLESHOOTING),
73        ]
74    }
75
76    /// Get embedded overlay by name.
77    pub fn get(name: &str) -> Option<&'static str> {
78        match name {
79            "git" => Some(GIT),
80            "git-worktree" => Some(GIT_WORKTREE),
81            "governance" => Some(GOVERNANCE),
82            "reasoning" => Some(REASONING),
83            "troubleshooting" => Some(TROUBLESHOOTING),
84            _ => None,
85        }
86    }
87
88    /// List all embedded overlay names.
89    pub fn names() -> Vec<&'static str> {
90        vec![
91            "git",
92            "git-worktree",
93            "governance",
94            "reasoning",
95            "troubleshooting",
96        ]
97    }
98}
99
100#[cfg(test)]
101mod tests {
102    use super::*;
103
104    #[test]
105    fn test_embedded_workflows_parse() {
106        for (name, content) in workflows::all() {
107            let result: Result<serde_yaml::Value, _> = serde_yaml::from_str(content);
108            assert!(
109                result.is_ok(),
110                "Failed to parse workflow '{}': {:?}",
111                name,
112                result.err()
113            );
114        }
115    }
116
117    #[test]
118    fn test_embedded_overlays_parse() {
119        for (name, content) in overlays::all() {
120            let result: Result<serde_yaml::Value, _> = serde_yaml::from_str(content);
121            assert!(
122                result.is_ok(),
123                "Failed to parse overlay '{}': {:?}",
124                name,
125                result.err()
126            );
127        }
128    }
129
130    #[test]
131    fn test_workflow_get() {
132        assert!(workflows::get("solo").is_some());
133        assert!(workflows::get("swarm").is_some());
134        assert!(workflows::get("nonexistent").is_none());
135    }
136
137    #[test]
138    fn test_overlay_get() {
139        assert!(overlays::get("git").is_some());
140        assert!(overlays::get("troubleshooting").is_some());
141        assert!(overlays::get("nonexistent").is_none());
142    }
143}