diff --git a/rust/crates/api/src/providers/mod.rs b/rust/crates/api/src/providers/mod.rs index fb97900..86871a8 100644 --- a/rust/crates/api/src/providers/mod.rs +++ b/rust/crates/api/src/providers/mod.rs @@ -753,14 +753,14 @@ mod tests { #[test] fn returns_context_window_metadata_for_kimi_models() { // kimi-k2.5 - let k25_limit = model_token_limit("kimi-k2.5") - .expect("kimi-k2.5 should have token limit metadata"); + let k25_limit = + model_token_limit("kimi-k2.5").expect("kimi-k2.5 should have token limit metadata"); assert_eq!(k25_limit.max_output_tokens, 16_384); assert_eq!(k25_limit.context_window_tokens, 256_000); // kimi-k1.5 - let k15_limit = model_token_limit("kimi-k1.5") - .expect("kimi-k1.5 should have token limit metadata"); + let k15_limit = + model_token_limit("kimi-k1.5").expect("kimi-k1.5 should have token limit metadata"); assert_eq!(k15_limit.max_output_tokens, 16_384); assert_eq!(k15_limit.context_window_tokens, 256_000); } @@ -768,11 +768,13 @@ mod tests { #[test] fn kimi_alias_resolves_to_kimi_k25_token_limits() { // The "kimi" alias resolves to "kimi-k2.5" via resolve_model_alias() - let alias_limit = model_token_limit("kimi") - .expect("kimi alias should resolve to kimi-k2.5 limits"); - let direct_limit = model_token_limit("kimi-k2.5") - .expect("kimi-k2.5 should have limits"); - assert_eq!(alias_limit.max_output_tokens, direct_limit.max_output_tokens); + let alias_limit = + model_token_limit("kimi").expect("kimi alias should resolve to kimi-k2.5 limits"); + let direct_limit = model_token_limit("kimi-k2.5").expect("kimi-k2.5 should have limits"); + assert_eq!( + alias_limit.max_output_tokens, + direct_limit.max_output_tokens + ); assert_eq!( alias_limit.context_window_tokens, direct_limit.context_window_tokens diff --git a/rust/crates/api/src/providers/openai_compat.rs b/rust/crates/api/src/providers/openai_compat.rs index 4e4183b..a810502 100644 --- a/rust/crates/api/src/providers/openai_compat.rs +++ b/rust/crates/api/src/providers/openai_compat.rs @@ -2195,9 +2195,16 @@ mod tests { #[test] fn provider_specific_size_limits_are_correct() { - assert_eq!(OpenAiCompatConfig::dashscope().max_request_body_bytes, 6_291_456); // 6MB - assert_eq!(OpenAiCompatConfig::openai().max_request_body_bytes, 104_857_600); // 100MB - assert_eq!(OpenAiCompatConfig::xai().max_request_body_bytes, 52_428_800); // 50MB + assert_eq!( + OpenAiCompatConfig::dashscope().max_request_body_bytes, + 6_291_456 + ); // 6MB + assert_eq!( + OpenAiCompatConfig::openai().max_request_body_bytes, + 104_857_600 + ); // 100MB + assert_eq!(OpenAiCompatConfig::xai().max_request_body_bytes, 52_428_800); + // 50MB } #[test] diff --git a/rust/crates/commands/src/lib.rs b/rust/crates/commands/src/lib.rs index 9d69393..d4f1770 100644 --- a/rust/crates/commands/src/lib.rs +++ b/rust/crates/commands/src/lib.rs @@ -2623,10 +2623,8 @@ fn render_mcp_report_json_for( // runs, the existing serializer adds `status: "ok"` below. match loader.load() { Ok(runtime_config) => { - let mut value = render_mcp_summary_report_json( - cwd, - runtime_config.mcp().servers(), - ); + let mut value = + render_mcp_summary_report_json(cwd, runtime_config.mcp().servers()); if let Some(map) = value.as_object_mut() { map.insert("status".to_string(), Value::String("ok".to_string())); map.insert("config_load_error".to_string(), Value::Null); diff --git a/rust/crates/runtime/src/bash.rs b/rust/crates/runtime/src/bash.rs index e5119cd..86577da 100644 --- a/rust/crates/runtime/src/bash.rs +++ b/rust/crates/runtime/src/bash.rs @@ -172,7 +172,7 @@ async fn execute_bash_async( ) -> io::Result { // Detect and emit ship provenance for git push operations detect_and_emit_ship_prepared(&input.command); - + let mut command = prepare_tokio_command(&input.command, &cwd, &sandbox_status, true); let output_result = if let Some(timeout_ms) = input.timeout { diff --git a/rust/crates/runtime/src/lane_events.rs b/rust/crates/runtime/src/lane_events.rs index 2dcb042..c08b8bb 100644 --- a/rust/crates/runtime/src/lane_events.rs +++ b/rust/crates/runtime/src/lane_events.rs @@ -405,7 +405,10 @@ pub enum BlockedSubphase { #[serde(rename = "blocked.branch_freshness")] BranchFreshness { behind_main: u32 }, #[serde(rename = "blocked.test_hang")] - TestHang { elapsed_secs: u32, test_name: Option }, + TestHang { + elapsed_secs: u32, + test_name: Option, + }, #[serde(rename = "blocked.report_pending")] ReportPending { since_secs: u32 }, } @@ -543,7 +546,8 @@ impl LaneEvent { .with_failure_class(blocker.failure_class) .with_detail(blocker.detail.clone()); if let Some(ref subphase) = blocker.subphase { - event = event.with_data(serde_json::to_value(subphase).expect("subphase should serialize")); + event = + event.with_data(serde_json::to_value(subphase).expect("subphase should serialize")); } event } @@ -554,7 +558,8 @@ impl LaneEvent { .with_failure_class(blocker.failure_class) .with_detail(blocker.detail.clone()); if let Some(ref subphase) = blocker.subphase { - event = event.with_data(serde_json::to_value(subphase).expect("subphase should serialize")); + event = + event.with_data(serde_json::to_value(subphase).expect("subphase should serialize")); } event } @@ -562,8 +567,12 @@ impl LaneEvent { /// Ship prepared — §4.44.5 #[must_use] pub fn ship_prepared(emitted_at: impl Into, provenance: &ShipProvenance) -> Self { - Self::new(LaneEventName::ShipPrepared, LaneEventStatus::Ready, emitted_at) - .with_data(serde_json::to_value(provenance).expect("ship provenance should serialize")) + Self::new( + LaneEventName::ShipPrepared, + LaneEventStatus::Ready, + emitted_at, + ) + .with_data(serde_json::to_value(provenance).expect("ship provenance should serialize")) } /// Ship commits selected — §4.44.5 @@ -573,22 +582,34 @@ impl LaneEvent { commit_count: u32, commit_range: impl Into, ) -> Self { - Self::new(LaneEventName::ShipCommitsSelected, LaneEventStatus::Ready, emitted_at) - .with_detail(format!("{} commits: {}", commit_count, commit_range.into())) + Self::new( + LaneEventName::ShipCommitsSelected, + LaneEventStatus::Ready, + emitted_at, + ) + .with_detail(format!("{} commits: {}", commit_count, commit_range.into())) } /// Ship merged — §4.44.5 #[must_use] pub fn ship_merged(emitted_at: impl Into, provenance: &ShipProvenance) -> Self { - Self::new(LaneEventName::ShipMerged, LaneEventStatus::Completed, emitted_at) - .with_data(serde_json::to_value(provenance).expect("ship provenance should serialize")) + Self::new( + LaneEventName::ShipMerged, + LaneEventStatus::Completed, + emitted_at, + ) + .with_data(serde_json::to_value(provenance).expect("ship provenance should serialize")) } /// Ship pushed to main — §4.44.5 #[must_use] pub fn ship_pushed_main(emitted_at: impl Into, provenance: &ShipProvenance) -> Self { - Self::new(LaneEventName::ShipPushedMain, LaneEventStatus::Completed, emitted_at) - .with_data(serde_json::to_value(provenance).expect("ship provenance should serialize")) + Self::new( + LaneEventName::ShipPushedMain, + LaneEventStatus::Completed, + emitted_at, + ) + .with_data(serde_json::to_value(provenance).expect("ship provenance should serialize")) } #[must_use] diff --git a/rust/crates/runtime/src/session_control.rs b/rust/crates/runtime/src/session_control.rs index 7a612eb..743ae7d 100644 --- a/rust/crates/runtime/src/session_control.rs +++ b/rust/crates/runtime/src/session_control.rs @@ -58,8 +58,8 @@ impl SessionStore { let workspace_root = workspace_root.as_ref(); // #151: canonicalize workspace_root for consistent fingerprinting // across equivalent path representations. - let canonical_workspace = fs::canonicalize(workspace_root) - .unwrap_or_else(|_| workspace_root.to_path_buf()); + let canonical_workspace = + fs::canonicalize(workspace_root).unwrap_or_else(|_| workspace_root.to_path_buf()); let sessions_root = data_dir .as_ref() .join("sessions") @@ -158,10 +158,9 @@ impl SessionStore { } pub fn latest_session(&self) -> Result { - self.list_sessions()? - .into_iter() - .next() - .ok_or_else(|| SessionControlError::Format(format_no_managed_sessions(&self.sessions_root))) + self.list_sessions()?.into_iter().next().ok_or_else(|| { + SessionControlError::Format(format_no_managed_sessions(&self.sessions_root)) + }) } pub fn load_session( diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs index c4ba812..40ca64e 100644 --- a/rust/crates/rusty-claude-cli/src/main.rs +++ b/rust/crates/rusty-claude-cli/src/main.rs @@ -228,8 +228,10 @@ fn main() { // don't need to regex-scrape the prose. let kind = classify_error_kind(&message); if message.contains("`claw --help`") { - eprintln!("[error-kind: {kind}] -error: {message}"); + eprintln!( + "[error-kind: {kind}] +error: {message}" + ); } else { eprintln!( "[error-kind: {kind}] @@ -372,7 +374,12 @@ fn run() -> Result<(), Box> { model_flag_raw, permission_mode, output_format, - } => print_status_snapshot(&model, model_flag_raw.as_deref(), permission_mode, output_format)?, + } => print_status_snapshot( + &model, + model_flag_raw.as_deref(), + permission_mode, + output_format, + )?, CliAction::Sandbox { output_format } => print_sandbox_status_snapshot(output_format)?, CliAction::Prompt { prompt, @@ -412,19 +419,17 @@ fn run() -> Result<(), Box> { CliAction::Config { section, output_format, - } => { - match output_format { - CliOutputFormat::Text => { - println!("{}", render_config_report(section.as_deref())?); - } - CliOutputFormat::Json => { - println!( - "{}", - serde_json::to_string_pretty(&render_config_json(section.as_deref())?)? - ); - } + } => match output_format { + CliOutputFormat::Text => { + println!("{}", render_config_report(section.as_deref())?); } - } + CliOutputFormat::Json => { + println!( + "{}", + serde_json::to_string_pretty(&render_config_json(section.as_deref())?)? + ); + } + }, CliAction::Diff { output_format } => match output_format { CliOutputFormat::Text => { println!("{}", render_diff_report()?); @@ -627,13 +632,7 @@ fn parse_args(args: &[String]) -> Result { } "--help" | "-h" if !rest.is_empty() - && matches!( - rest[0].as_str(), - "prompt" - | "commit" - | "pr" - | "issue" - ) => + && matches!(rest[0].as_str(), "prompt" | "commit" | "pr" | "issue") => { // `--help` following a subcommand that would otherwise forward // the arg to the API (e.g. `claw prompt --help`) should show @@ -844,9 +843,13 @@ fn parse_args(args: &[String]) -> Result { if let Some(action) = parse_local_help_action(&rest) { return action; } - if let Some(action) = - parse_single_word_command_alias(&rest, &model, model_flag_raw.as_deref(), permission_mode_override, output_format) - { + if let Some(action) = parse_single_word_command_alias( + &rest, + &model, + model_flag_raw.as_deref(), + permission_mode_override, + output_format, + ) { return action; } @@ -1312,7 +1315,6 @@ fn suggest_closest_term<'a>(input: &str, candidates: &'a [&'a str]) -> Option<&' ranked_suggestions(input, candidates).into_iter().next() } - fn suggest_similar_subcommand(input: &str) -> Option> { const KNOWN_SUBCOMMANDS: &[&str] = &[ "help", @@ -1342,8 +1344,7 @@ fn suggest_similar_subcommand(input: &str) -> Option> { let prefix_match = common_prefix_len(&normalized_input, &normalized_candidate) >= 4; let substring_match = normalized_candidate.contains(&normalized_input) || normalized_input.contains(&normalized_candidate); - ((distance <= 2) || prefix_match || substring_match) - .then_some((distance, *candidate)) + ((distance <= 2) || prefix_match || substring_match).then_some((distance, *candidate)) }) .collect::>(); ranked.sort_by(|left, right| left.cmp(right).then_with(|| left.1.cmp(right.1))); @@ -1363,7 +1364,6 @@ fn common_prefix_len(left: &str, right: &str) -> usize { .count() } - fn looks_like_subcommand_typo(input: &str) -> bool { !input.is_empty() && input @@ -1472,13 +1472,11 @@ fn validate_model_syntax(model: &str) -> Result<(), String> { err_msg.push_str("\nDid you mean `openai/"); err_msg.push_str(trimmed); err_msg.push_str("`? (Requires OPENAI_API_KEY env var)"); - } - else if trimmed.starts_with("qwen") { + } else if trimmed.starts_with("qwen") { err_msg.push_str("\nDid you mean `qwen/"); err_msg.push_str(trimmed); err_msg.push_str("`? (Requires DASHSCOPE_API_KEY env var)"); - } - else if trimmed.starts_with("grok") { + } else if trimmed.starts_with("grok") { err_msg.push_str("\nDid you mean `xai/"); err_msg.push_str(trimmed); err_msg.push_str("`? (Requires XAI_API_KEY env var)"); @@ -4322,7 +4320,6 @@ impl LiveCli { Ok(()) } - fn run_prompt_compact_json(&mut self, input: &str) -> Result<(), Box> { let (mut runtime, hook_abort_monitor) = self.prepare_turn_runtime(false)?; let mut permission_prompter = CliPermissionPrompter::new(self.permission_mode); @@ -5440,7 +5437,13 @@ fn print_status_snapshot( match output_format { CliOutputFormat::Text => println!( "{}", - format_status_report(&provenance.resolved, usage, permission_mode.as_str(), &context, Some(&provenance)) + format_status_report( + &provenance.resolved, + usage, + permission_mode.as_str(), + &context, + Some(&provenance) + ) ), CliOutputFormat::Json => println!( "{}", @@ -9006,26 +9009,24 @@ fn print_help(output_format: CliOutputFormat) -> Result<(), Box