sovereign-intelligence
Front door to Drake Stapleton's sovereign stack.
Brought by drakestapleton
sovereign-intelligence / docs / archive / drakestapleton.com-old / crates / site-server / src / agent_status.rs
| 1 | use serde::Deserialize; |
| 2 | use std::fs; |
| 3 | use std::path::Path; |
| 4 | |
| 5 | #[derive(Deserialize, Debug, Clone)] |
| 6 | struct Milestone { |
| 7 | title: String, |
| 8 | #[serde(default)] |
| 9 | status: String, |
| 10 | } |
| 11 | |
| 12 | #[derive(Deserialize, Debug, Clone)] |
| 13 | struct Goal { |
| 14 | title: String, |
| 15 | #[serde(default)] |
| 16 | #[allow(dead_code)] |
| 17 | status: String, |
| 18 | #[serde(default)] |
| 19 | milestones: Vec<Milestone>, |
| 20 | } |
| 21 | |
| 22 | #[derive(Deserialize, Debug, Clone)] |
| 23 | struct GoalsFile { |
| 24 | goals: Vec<Goal>, |
| 25 | } |
| 26 | |
| 27 | pub fn get_active_goal_and_milestone() -> (String, String) { |
| 28 | let goals_path = Path::new("/home/drakestapleton/basecamp/goals.json"); |
| 29 | if let Ok(content) = fs::read_to_string(goals_path) { |
| 30 | if let Ok(data) = serde_json::from_str::<GoalsFile>(&content) { |
| 31 | for goal in data.goals.iter().rev() { |
| 32 | let latest_completed = goal |
| 33 | .milestones |
| 34 | .iter() |
| 35 | .rev() |
| 36 | .find(|m| m.status == "completed" || m.status == "done") |
| 37 | .map(|m| m.title.clone()); |
| 38 | |
| 39 | let active_or_first = goal |
| 40 | .milestones |
| 41 | .iter() |
| 42 | .find(|m| m.status == "in_progress" || m.status == "active") |
| 43 | .map(|m| m.title.clone()); |
| 44 | |
| 45 | let milestone_str = active_or_first |
| 46 | .or(latest_completed) |
| 47 | .unwrap_or_else(|| "Milestone in progress".to_string()); |
| 48 | |
| 49 | return (goal.title.clone(), milestone_str); |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | ( |
| 54 | "Autonomous Sovereign Systems".to_string(), |
| 55 | "Native Rust Server Execution".to_string(), |
| 56 | ) |
| 57 | } |