Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ clap = { version = "4", features = ["derive"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
dirs = "6"
owo-colors = "4"
supports-color = "3"

[dev-dependencies]
tempfile = "3"
7 changes: 3 additions & 4 deletions src/collect.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::collections::HashMap;

use crate::{analyze, parser, paths, signals, state};
use owo_colors::OwoColorize;

const GREEN: &str = "\x1b[32m";
const RESET: &str = "\x1b[0m";
use crate::{analyze, parser, paths, signals, state};

pub fn run(trigger: &str) -> Result<(), String> {
let reflections_content = parser::read_or_empty(&paths::reflections_file()?);
Expand Down Expand Up @@ -55,7 +54,7 @@ pub fn run(trigger: &str) -> Result<(), String> {
state::save_analysis(&analysis)?;

// Print summary
println!("{GREEN}✓{RESET} Collected signal vector ({trigger})");
println!("{} Collected signal vector ({trigger})", "✓".green());
print_signal(" vocabulary_diversity", sigs.vocabulary_diversity);
print_signal(" question_generation", sigs.question_generation);
print_signal(" thought_lifecycle", sigs.thought_lifecycle);
Expand Down
24 changes: 12 additions & 12 deletions src/init.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
use std::fs;
use std::path::PathBuf;

use owo_colors::OwoColorize;

use crate::paths;

const PROTOCOL_TEMPLATE: &str = include_str!("../templates/vigil-echo.md");

const PULSE_COMMAND: &str = "vigil-echo pulse";
const COLLECT_COMMAND: &str = "vigil-echo collect --trigger session-end";

const GREEN: &str = "\x1b[32m";
const YELLOW: &str = "\x1b[33m";
const RED: &str = "\x1b[31m";
const BOLD: &str = "\x1b[1m";
const RESET: &str = "\x1b[0m";

enum Status {
Created,
Exists,
Expand All @@ -22,9 +18,9 @@ enum Status {

fn print_status(status: Status, msg: &str) {
match status {
Status::Created => println!(" {GREEN}✓{RESET} {msg}"),
Status::Exists => println!(" {YELLOW}~{RESET} {msg}"),
Status::Error => println!(" {RED}✗{RESET} {msg}"),
Status::Created => println!(" {} {msg}", "✓".green()),
Status::Exists => println!(" {} {msg}", "~".yellow()),
Status::Error => println!(" {} {msg}", "✗".red()),
}
}

Expand Down Expand Up @@ -201,7 +197,10 @@ pub fn run() -> Result<(), String> {
);
}

println!("\n{BOLD}vigil-echo{RESET} — initializing metacognitive monitoring\n");
println!(
"\n{} — initializing metacognitive monitoring\n",
"vigil-echo".bold()
);

// Create directories
let rules_dir = paths::rules_dir()?;
Expand Down Expand Up @@ -229,7 +228,7 @@ pub fn run() -> Result<(), String> {

// Summary
println!(
"\n{BOLD}Setup complete.{RESET} Metacognitive monitoring is ready.\n\n\
"\n{} Metacognitive monitoring is ready.\n\n\
\x20 Signals tracked (Phase 1):\n\
\x20 vocabulary_diversity — Lexical variety in reflections\n\
\x20 question_generation — Active curiosity level\n\
Expand All @@ -241,7 +240,8 @@ pub fn run() -> Result<(), String> {
\x20 Commands:\n\
\x20 vigil-echo status — Cognitive health dashboard\n\
\x20 vigil-echo collect — Manual signal collection\n\
\x20 vigil-echo pulse — Manual pulse injection\n"
\x20 vigil-echo pulse — Manual pulse injection\n",
"Setup complete.".bold()
);

Ok(())
Expand Down
16 changes: 11 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ mod paths;
mod pulse;
mod signals;
mod state;
mod stats;
mod status;

use clap::{Parser, Subcommand};
use owo_colors::OwoColorize;

#[derive(Parser)]
#[command(
Expand Down Expand Up @@ -40,7 +42,11 @@ enum Commands {
/// Inject cognitive health assessment at session start
Pulse,
/// Cognitive health dashboard
Status,
Status {
/// Output in JSON format
#[arg(long)]
json: bool,
},
}

fn main() {
Expand All @@ -56,14 +62,14 @@ fn main() {
c
}
Err(e) => {
eprintln!("\x1b[31m✗\x1b[0m {e}");
eprintln!("{} {e}", "✗".red());
std::process::exit(1);
}
};
let history = match state::load_signals() {
Ok(h) => h,
Err(e) => {
eprintln!("\x1b[31m✗\x1b[0m {e}");
eprintln!("{} {e}", "✗".red());
std::process::exit(1);
}
};
Expand All @@ -77,11 +83,11 @@ fn main() {
}
}
Some(Commands::Pulse) => pulse::run(),
Some(Commands::Status) => status::run(),
Some(Commands::Status { json }) => status::run(json),
};

if let Err(e) = result {
eprintln!("\x1b[31m✗\x1b[0m {e}");
eprintln!("{} {e}", "✗".red());
std::process::exit(1);
}
}
16 changes: 9 additions & 7 deletions src/pulse.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use owo_colors::OwoColorize;

use crate::state::{self, AlertLevel, Trend};

pub fn run() -> Result<(), String> {
Expand Down Expand Up @@ -31,10 +33,10 @@ pub fn run() -> Result<(), String> {

// Format output
let level_str = match &analysis.alert_level {
AlertLevel::Healthy => "\x1b[32mHEALTHY\x1b[0m",
AlertLevel::Watch => "\x1b[33mWATCH\x1b[0m",
AlertLevel::Concern => "\x1b[31mCONCERN\x1b[0m",
AlertLevel::Alert => "\x1b[1;31mALERT\x1b[0m",
AlertLevel::Healthy => format!("{}", "HEALTHY".green()),
AlertLevel::Watch => format!("{}", "WATCH".yellow()),
AlertLevel::Concern => format!("{}", "CONCERN".red()),
AlertLevel::Alert => format!("{}", "ALERT".red().bold()),
};

println!("[VIGIL — Cognitive Health]\n");
Expand All @@ -56,9 +58,9 @@ pub fn run() -> Result<(), String> {
println!();
for (name, trend) in &analysis.signals {
let arrow = match trend.trend {
Trend::Improving => "\x1b[32m↑\x1b[0m",
Trend::Stable => "→",
Trend::Declining => "\x1b[31m↓\x1b[0m",
Trend::Improving => format!("{}", "↑".green()),
Trend::Stable => "→".to_string(),
Trend::Declining => format!("{}", "↓".red()),
};
let val = trend
.current
Expand Down
Loading