use clap::{Parser, Subcommand};
use std::io::{self, Read};
use std::path::PathBuf;
use semantic_sift_core::{apply_heuristic_sieve, SemanticEngine};
#[derive(Parser)]
#[command(name = "sift-core")]
#[command(version)]
#[command(about = "High-performance context distillation core", long_about = None)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Logs {
#[arg(short, long)]
input: Option<String>,
},
Semantic {
#[arg(short, long)]
input: Option<String>,
#[arg(short, long, default_value_t = 0.5)]
rate: f32,
#[arg(short, long)]
model: Option<PathBuf>,
},
Update {
#[arg(short, long)]
check: bool,
},
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let cli = Cli::parse();
match cli.command {
Commands::Logs { input } => {
let text = match input {
Some(t) => t,
None => {
let mut buffer = String::new();
io::stdin().read_to_string(&mut buffer)?;
buffer
}
};
let result = apply_heuristic_sieve(&text);
println!("{}", result);
}
Commands::Semantic { input, rate, model } => {
let text = match input {
Some(t) => t,
None => {
let mut buffer = String::new();
io::stdin().read_to_string(&mut buffer)?;
buffer
}
};
if let Some(model_path) = model {
let mut engine = SemanticEngine::new(model_path)?;
let result = engine.compress(&text, rate)?;
println!("{}", result);
} else {
let result = apply_heuristic_sieve(&text);
println!("[Semantic-Sift: Heuristic Fallback (no model provided)]");
println!("{}", result);
}
}
Commands::Update { check } => {
if check {
println!("{{ \"current\": \"{}\", \"latest\": \"{}\", \"update_available\": false }}", env!("CARGO_PKG_VERSION"), env!("CARGO_PKG_VERSION"));
} else {
println!("Update functionality is managed by the host application SidecarManager.");
}
}
}
Ok(())
}