interplane.Get Omega
Read in your language

spark-crumbs

Deterministic append-only operational event ledger

Brought by drakestapleton

branch main Branches Tags History

spark-crumbs / src / main.rs

113 lines · 3939 bytes Raw Blame History
1use clap::{Parser, Subcommand};
2use spark_crumbs::{add_crumb_whisper, format_dir_crumb_tui, record_crumb_action, seed_directory_tree, sniff_crumb};
3use std::path::PathBuf;
4
5#[derive(Parser, Debug)]
6#[command(name = "spark-crumbs")]
7#[command(author = "AIEN <aien.atlas@proton.me>")]
8#[command(version = "0.1.0")]
9#[command(about = "High-speed native Rust distributed breadcrumb and agent scent engine for Sovereign SparkOS")]
10struct Cli {
11 #[command(subcommand)]
12 command: Commands,
13}
14
15#[derive(Subcommand, Debug)]
16enum Commands {
17 /// Seed .crumb and .crumb.local in a directory or recursively across a repository
18 Seed {
19 #[arg(default_value = ".", help = "Root directory to seed")]
20 dir: PathBuf,
21
22 #[arg(short, long, help = "Recursively seed all subdirectories")]
23 recursive: bool,
24
25 #[arg(short, long, default_value = "AIEN", help = "Agent ID creating the crumb")]
26 agent: String,
27
28 #[arg(short, long, help = "Initial whisper message to plant")]
29 whisper: Option<String>,
30 },
31
32 /// Sniff peer agent scent, recent history, and active whispers for a file or directory
33 Sniff {
34 #[arg(help = "Target file or directory path")]
35 path: PathBuf,
36
37 #[arg(short, long, default_value = "AIEN", help = "Current agent ID")]
38 agent: String,
39 },
40
41 /// Show rich topographic inspection card for a directory
42 Show {
43 #[arg(default_value = ".", help = "Target directory to inspect")]
44 dir: PathBuf,
45 },
46
47 /// Plant an inter-agent whisper message in a directory
48 Whisper {
49 #[arg(default_value = ".", help = "Target directory")]
50 dir: PathBuf,
51
52 #[arg(short, long, help = "Whisper message content")]
53 message: String,
54
55 #[arg(short, long, default_value = "AIEN", help = "Agent ID whispering")]
56 agent: String,
57
58 #[arg(short, long, help = "Optional target file name")]
59 file: Option<String>,
60 },
61
62 /// Record an agent action vector in a directory crumb
63 Record {
64 #[arg(default_value = ".", help = "Target directory")]
65 dir: PathBuf,
66
67 #[arg(short, long, default_value = "AIEN", help = "Agent ID")]
68 agent: String,
69
70 #[arg(short, long, help = "Action type (e.g. edit, test, build, audit)")]
71 action: String,
72
73 #[arg(short, long, help = "Target artifact or file")]
74 target: String,
75
76 #[arg(short, long, help = "Operational intent")]
77 intent: String,
78
79 #[arg(short, long, help = "Vector description")]
80 vector: String,
81 },
82}
83
84fn main() {
85 let cli = Cli::parse();
86
87 match cli.command {
88 Commands::Seed { dir, recursive, agent, whisper } => {
89 println!("Seeding directory crumbs at: {} (recursive: {})", dir.display(), recursive);
90 let count = seed_directory_tree(&dir, recursive, &agent, whisper.as_deref());
91 println!("Seeded {} directory crumbs successfully.", count);
92 }
93 Commands::Sniff { path, agent } => {
94 if let Some(sniff) = sniff_crumb(&path, &agent) {
95 println!("{}", sniff);
96 } else {
97 println!("No active peer scent or whispers detected on '{}'.", path.display());
98 }
99 }
100 Commands::Show { dir } => {
101 let card = format_dir_crumb_tui(&dir);
102 println!("{}", card);
103 }
104 Commands::Whisper { dir, message, agent, file } => {
105 add_crumb_whisper(&dir, &agent, &message, file.as_deref());
106 println!("Planted whisper from [{}] in {}: '{}'", agent, dir.display(), message);
107 }
108 Commands::Record { dir, agent, action, target, intent, vector } => {
109 record_crumb_action(&dir, &agent, "cli-session", &action, &target, &intent, &vector);
110 println!("Recorded action '{}' on '{}' in {}.", action, target, dir.display());
111 }
112 }
113}