Skip to content
Open
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
397 changes: 7 additions & 390 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions crates/blizz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ anyhow.workspace = true
thiserror.workspace = true
tokio.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_yaml = "0.9"
dirs = "6.0"
reqwest.workspace = true
tempfile = "3.0"
chrono.workspace = true
secrets = { path = "../secrets" }
rpassword = "7.0"
bentley = { path = "../bentley" }

[dev-dependencies]
Expand Down
4 changes: 0 additions & 4 deletions crates/insights/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,8 @@ hf-hub = { version = "0.4", default-features = false, features = ["tokio"], opti
safetensors = { version = "0.6", optional = true }

[dev-dependencies]
assert_cmd = "2.0"
assert_fs = "1.1"
predicates = "3.1"
serial_test = "3.2"
tempfile.workspace = true
mockall.workspace = true

[features]
default = ["ml-features", "download-onnx-binaries"]
Expand Down
32 changes: 28 additions & 4 deletions crates/insights/src/cli/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ pub async fn list_insights(filter: Option<&str>, verbose: bool) -> Result<()> {
}

for (topic, insights) in by_topic {
println!("{} {}", "📂".cyan(), topic.blue().bold());
println!("{}/", topic.blue().bold());

for insight in insights {
if verbose {
println!(" {} {} - {}", "📄".yellow(), insight.name.bold(), insight.overview.dimmed());
println!("- {} - {}", insight.name.bold(), insight.overview.dimmed());
} else {
println!(" {} {}", "📄".yellow(), insight.name.bold());
println!("- {}", insight.name.bold());
}
}
println!();
Expand All @@ -91,14 +91,38 @@ pub async fn list_topics() -> Result<()> {
return Ok(());
}

println!("{} Available topics:", "📂".cyan());
println!("Available topics:");
for topic in response {
println!(" {}", topic.blue());
}

Ok(())
}

pub async fn count_insights() -> Result<()> {
ensure_server_running().await?;

let client = get_client();
let insights_response = client.list_insights(Vec::new()).await?;

// Count unique topics
use std::collections::HashSet;
let mut unique_topics: HashSet<String> = HashSet::new();
let insights = insights_response.insights;

for insight in &insights {
unique_topics.insert(insight.topic.clone());
}

let topic_count = unique_topics.len();
let insight_count = insights.len();

println!("Topics: {}", topic_count.to_string().yellow());
println!("Insights: {}", insight_count.to_string().yellow());

Ok(())
}

pub async fn update_insight(
topic: &str,
name: &str,
Expand Down
3 changes: 3 additions & 0 deletions crates/insights/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ enum Command {
},
/// List all available topics
Topics,
/// Show count of topics and insights
Count,
/// Recompute embeddings for all insights
Index {
/// Force recompute even for insights that already have embeddings
Expand Down Expand Up @@ -119,6 +121,7 @@ async fn handle(command: Command) -> Result<()> {
}
Command::Delete { id, force } => commands::delete_insight(&id.topic, &id.name, force).await,
Command::Topics => commands::list_topics().await,
Command::Count => commands::count_insights().await,
Command::Index { force } => commands::index_insights(force).await,
Command::Logs { limit, level } => commands::logs(limit, &level).await,
}
Expand Down
7 changes: 1 addition & 6 deletions crates/secrets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ dirs = { workspace = true }
bentley = { workspace = true }
clap.workspace = true
dialoguer = { version = "0.11", features = ["password"] }
tokio-util = { version = "0.7", features = ["codec"] }
futures = "0.3"
aes-gcm = "0.10"
rand = "0.9"
base64 = { workspace = true }
native-dialog = "0.9"
sha2 = "0.10"
argon2 = "0.5"
hostname = "0.4"
Expand All @@ -41,10 +37,9 @@ uuid = "1.18"
tempfile = { workspace = true }
hex = "0.4"
temp-env = "0.3"
vfs = "0.12"
rexpect = "0.6"
assert_cmd = "2.0"
predicates = "3.0"
rexpect = "0.6"

[lib]
name = "secrets"
Expand Down
38 changes: 22 additions & 16 deletions crates/secrets/src/bin/keeper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,19 @@ thread_local! {
mod tests {
use super::*;

use assert_cmd::cargo::CommandCargoExt;
use assert_cmd::Command;
use predicates::prelude::*;
use rexpect::session::spawn_command;
use std::process::Command as StdCommand;
use tempfile::TempDir;

/// Convert assert_cmd::Command to std::process::Command for use with rexpect
fn to_std_command(assert_cmd: &Command) -> StdCommand {
let mut std_cmd = StdCommand::new(assert_cmd.get_program());
std_cmd.args(assert_cmd.get_args());
std_cmd.envs(assert_cmd.get_envs().filter_map(|(k, v)| v.map(|v| (k, v))));
std_cmd
}

fn with_temp_env<F, R>(f: F) -> R
where
F: FnOnce(&TempDir) -> R,
Expand Down Expand Up @@ -193,10 +199,10 @@ mod tests {
let test_password = "valid_password_123";

// First, create a vault interactively using rexpect
let mut cmd = StdCommand::cargo_bin("keeper").unwrap();
let mut cmd = Command::cargo_bin("keeper").unwrap();
cmd.env("BLIZZ_HOME", temp_dir.path());

let mut session = spawn_command(cmd, Some(5000)).unwrap();
let mut session = spawn_command(to_std_command(&cmd), Some(5000)).unwrap();

session.exp_string(PROMPT_NO_VAULT_FOUND).unwrap();
session.exp_string(PROMPT_ENTER_NEW_PASSWORD).unwrap();
Expand All @@ -218,7 +224,7 @@ mod tests {
.timeout(std::time::Duration::from_secs(2))
.assert()
.failure()
.stderr(predicate::str::contains(ERROR_PASSWORD_EMPTY));
.stderr(predicates::str::contains(ERROR_PASSWORD_EMPTY));
});

// Test that whitespace-only SECRETS_AUTH is rejected
Expand All @@ -229,7 +235,7 @@ mod tests {
.timeout(std::time::Duration::from_secs(2))
.assert()
.failure()
.stderr(predicate::str::contains(ERROR_PASSWORD_EMPTY));
.stderr(predicates::str::contains(ERROR_PASSWORD_EMPTY));
});
});
}
Expand Down Expand Up @@ -266,10 +272,10 @@ mod tests {
let test_password = "strong_test_password_123";

// Test successful vault creation with matching passwords
let mut cmd = StdCommand::cargo_bin("keeper").unwrap();
let mut cmd = Command::cargo_bin("keeper").unwrap();
cmd.env("BLIZZ_HOME", temp_dir.path());

let mut session = spawn_command(cmd, Some(5000)).unwrap();
let mut session = spawn_command(to_std_command(&cmd), Some(5000)).unwrap();

session.exp_string(PROMPT_NO_VAULT_FOUND).unwrap();
session.exp_string(PROMPT_ENTER_NEW_PASSWORD).unwrap();
Expand All @@ -288,10 +294,10 @@ mod tests {
assert!(vault_path.exists(), "Vault file should exist after creation");

// Test password mismatch during vault creation
let mut cmd2 = StdCommand::cargo_bin("keeper").unwrap();
let mut cmd2 = Command::cargo_bin("keeper").unwrap();
cmd2.env("BLIZZ_HOME", temp_dir.path().join("mismatch_test"));

let mut session2 = spawn_command(cmd2, Some(5000)).unwrap();
let mut session2 = spawn_command(to_std_command(&cmd2), Some(5000)).unwrap();

session2.exp_string("no vault found").unwrap();
session2.exp_string(PROMPT_ENTER_NEW_PASSWORD).unwrap();
Expand All @@ -314,10 +320,10 @@ mod tests {
assert!(!keeper_dir.exists(), "Keeper directory should not exist initially");

// Create vault - should create parent directories
let mut cmd = StdCommand::cargo_bin("keeper").unwrap();
let mut cmd = Command::cargo_bin("keeper").unwrap();
cmd.env("BLIZZ_HOME", temp_dir.path());

let mut session = spawn_command(cmd, Some(5000)).unwrap();
let mut session = spawn_command(to_std_command(&cmd), Some(5000)).unwrap();

session.exp_string(PROMPT_NO_VAULT_FOUND).unwrap();
session.exp_string(PROMPT_ENTER_NEW_PASSWORD).unwrap();
Expand Down Expand Up @@ -348,10 +354,10 @@ mod tests {
let test_password = "ipc_test_password_123";

// First, create a vault with a known password
let mut cmd = StdCommand::cargo_bin("keeper").unwrap();
let mut cmd = Command::cargo_bin("keeper").unwrap();
cmd.env("BLIZZ_HOME", temp_dir.path());

let mut session = spawn_command(cmd, Some(5000)).unwrap();
let mut session = spawn_command(to_std_command(&cmd), Some(5000)).unwrap();

session.exp_string(PROMPT_NO_VAULT_FOUND).unwrap();
session.exp_string(PROMPT_ENTER_NEW_PASSWORD).unwrap();
Expand Down Expand Up @@ -434,10 +440,10 @@ mod tests {
let test_password = "invalid_request_test_123";

// Create a vault and start daemon
let mut cmd = StdCommand::cargo_bin("keeper").unwrap();
let mut cmd = Command::cargo_bin("keeper").unwrap();
cmd.env("BLIZZ_HOME", temp_dir.path());

let mut session = spawn_command(cmd, Some(5000)).unwrap();
let mut session = spawn_command(to_std_command(&cmd), Some(5000)).unwrap();

session.exp_string(PROMPT_NO_VAULT_FOUND).unwrap();
session.exp_string(PROMPT_ENTER_NEW_PASSWORD).unwrap();
Expand Down
1 change: 0 additions & 1 deletion crates/violet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ colored.workspace = true
serde = { workspace = true }
serde_yaml.workspace = true
anyhow.workspace = true
dirs.workspace = true
glob = "0.3"
regex = "1.10"
[dev-dependencies]
Expand Down
Loading