harvester
Zero-telemetry documentation and knowledge extraction engine
Brought by drakestapleton
| 1 | use clap::{Parser, Subcommand}; |
| 2 | use std::path::PathBuf; |
| 3 | use tracing::{info, Level}; |
| 4 | use tracing_subscriber::FmtSubscriber; |
| 5 | |
| 6 | use spark_harvester::{DatasetExporter, ExtractedPair, ReasoningExtractor}; |
| 7 | |
| 8 | #[derive(Parser)] |
| 9 | #[command(name = "spark-harvester")] |
| 10 | #[command(about = "Native Rust pipeline for harvesting commercial AI reasoning pairs for open weight training")] |
| 11 | struct Cli { |
| 12 | #[command(subcommand)] |
| 13 | command: Commands, |
| 14 | } |
| 15 | |
| 16 | #[derive(Subcommand)] |
| 17 | enum Commands { |
| 18 | /// Extract reasoning pairs from a raw text file or query |
| 19 | Extract { |
| 20 | #[arg(short, long)] |
| 21 | prompt: String, |
| 22 | #[arg(short, long)] |
| 23 | input: String, |
| 24 | #[arg(short, long, default_value = "commercial-lab")] |
| 25 | provider: String, |
| 26 | #[arg(short, long, default_value = "frontier-model")] |
| 27 | model: String, |
| 28 | }, |
| 29 | /// Export extracted training pairs into JSONL |
| 30 | Distill { |
| 31 | #[arg(short, long)] |
| 32 | output: PathBuf, |
| 33 | }, |
| 34 | /// Display pipeline status |
| 35 | Status, |
| 36 | } |
| 37 | |
| 38 | #[tokio::main] |
| 39 | async fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 40 | let subscriber = FmtSubscriber::builder() |
| 41 | .with_max_level(Level::INFO) |
| 42 | .finish(); |
| 43 | tracing::subscriber::set_global_default(subscriber)?; |
| 44 | |
| 45 | let cli = Cli::parse(); |
| 46 | match cli.command { |
| 47 | Commands::Extract { prompt, input, provider, model } => { |
| 48 | let extractor = ReasoningExtractor::new(); |
| 49 | let pair = extractor.extract(&prompt, &input, &provider, &model); |
| 50 | info!("Extracted pair: tokens={}, quality={:.2}", pair.token_count, pair.quality_score); |
| 51 | println!("{}", serde_json::to_string_pretty(&pair)?); |
| 52 | } |
| 53 | Commands::Distill { output } => { |
| 54 | info!("Writing distillation manifest to {:?}", output); |
| 55 | let sample_pair = ExtractedPair { |
| 56 | prompt: "Sovereign AI foundational premise".to_string(), |
| 57 | reasoning: Some("Verify local computation vs centralized extraction".to_string()), |
| 58 | completion: "Human freedom requires local ownership of intelligence.".to_string(), |
| 59 | provider: "community".to_string(), |
| 60 | model: "atlas-sovereign".to_string(), |
| 61 | token_count: 42, |
| 62 | quality_score: 1.0, |
| 63 | }; |
| 64 | let count = DatasetExporter::append_to_jsonl(&output, &[sample_pair])?; |
| 65 | info!("Appended {} pairs to {:?}", count, output); |
| 66 | } |
| 67 | Commands::Status => { |
| 68 | println!("AIEN Sovereign Harvester Pipeline Active"); |
| 69 | println!("Zero Disk Secrets: Enforced via hardware TPM vault (atlas-vault)"); |
| 70 | println!("License: Sovereign Reciprocal Commons License 1.0 (SRCL-1.0)"); |
| 71 | } |
| 72 | } |
| 73 | Ok(()) |
| 74 | } |