Skip to content

Commit f0c1bba

Browse files
ZhiXiao-Linclaude
andcommitted
style: cargo fmt — fix formatting for CI
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 107c74b commit f0c1bba

17 files changed

Lines changed: 97 additions & 100 deletions

File tree

core/examples/sdk_basic.rs

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ async fn main() -> anyhow::Result<()> {
6868
let workspace2 = tmp2.path().display().to_string();
6969

7070
let session_create = agent_create.session(&workspace2, None)?;
71-
println!("[ok] Session from Agent::create() bound to {}\n", workspace2);
71+
println!(
72+
"[ok] Session from Agent::create() bound to {}\n",
73+
workspace2
74+
);
7275

7376
// ── 4. Tool execution: bash ──────────────────────────────────────────
7477
println!("--- Tool: bash ---");
@@ -97,7 +100,9 @@ async fn main() -> anyhow::Result<()> {
97100

98101
// ── 6. Tool execution via Agent::create() session ────────────────────
99102
println!("\n--- Tool: bash via Agent::create() session ---");
100-
let output2 = session_create.bash("echo 'Hello from Agent::create()'").await?;
103+
let output2 = session_create
104+
.bash("echo 'Hello from Agent::create()'")
105+
.await?;
101106
println!(" output: {}", output2.trim());
102107

103108
// ── 7. Direct tool call: edit ───────────────────────────────────────
@@ -173,7 +178,10 @@ async fn main() -> anyhow::Result<()> {
173178
.await?;
174179
println!(" exit_code: {}", ls_result.exit_code);
175180
assert_eq!(ls_result.exit_code, 0, "ls should succeed");
176-
assert!(ls_result.output.contains("alpha.rs"), "ls should list alpha.rs");
181+
assert!(
182+
ls_result.output.contains("alpha.rs"),
183+
"ls should list alpha.rs"
184+
);
177185
assert!(ls_result.output.contains("subdir"), "ls should list subdir");
178186
println!(" entries:");
179187
for line in ls_result.output.lines().take(6) {
@@ -183,14 +191,14 @@ async fn main() -> anyhow::Result<()> {
183191
// ── 11. Direct tool call: glob ───────────────────────────────────────
184192
println!("\n--- session.tool(\"glob\") ---");
185193
let glob_result = session_new
186-
.tool(
187-
"glob",
188-
serde_json::json!({ "pattern": "*.rs" }),
189-
)
194+
.tool("glob", serde_json::json!({ "pattern": "*.rs" }))
190195
.await?;
191196
println!(" exit_code: {}", glob_result.exit_code);
192197
assert_eq!(glob_result.exit_code, 0, "glob should succeed");
193-
assert!(glob_result.output.contains("alpha.rs"), "glob should find alpha.rs");
198+
assert!(
199+
glob_result.output.contains("alpha.rs"),
200+
"glob should find alpha.rs"
201+
);
194202
println!(" matches: {}", glob_result.output.trim());
195203

196204
// ── 12. Direct tool call: grep ───────────────────────────────────────
@@ -225,7 +233,10 @@ async fn main() -> anyhow::Result<()> {
225233
.await?;
226234
println!(" exit_code: {}", bash_result.exit_code);
227235
assert_eq!(bash_result.exit_code, 0, "bash should succeed");
228-
assert!(bash_result.output.contains("direct tool call"), "bash output check");
236+
assert!(
237+
bash_result.output.contains("direct tool call"),
238+
"bash output check"
239+
);
229240
println!(" output: {}", bash_result.output.trim());
230241

231242
// ── 14. Direct tool call: web_fetch ────────────────────────────────
@@ -275,7 +286,10 @@ async fn main() -> anyhow::Result<()> {
275286
}
276287
} else {
277288
println!(" [soft-fail] web_search returned error (network/proxy issue):");
278-
println!(" {}", search_result.output.lines().next().unwrap_or("(empty)"));
289+
println!(
290+
" {}",
291+
search_result.output.lines().next().unwrap_or("(empty)")
292+
);
279293
}
280294

281295
// ── 16. Direct tool call: cron (full lifecycle) ────────────────────
@@ -323,7 +337,10 @@ async fn main() -> anyhow::Result<()> {
323337
.await?;
324338
println!(" exit_code: {}", add_result.exit_code);
325339
assert_eq!(add_result.exit_code, 0, "cron add should succeed");
326-
println!(" output: {}", add_result.output.lines().next().unwrap_or(""));
340+
println!(
341+
" output: {}",
342+
add_result.output.lines().next().unwrap_or("")
343+
);
327344

328345
// Extract job ID from formatted text output (" ID: <uuid>")
329346
let job_id = add_result
@@ -357,8 +374,14 @@ async fn main() -> anyhow::Result<()> {
357374
.await?;
358375
println!(" exit_code: {}", get_result.exit_code);
359376
assert_eq!(get_result.exit_code, 0, "cron get should succeed");
360-
assert!(get_result.output.contains(&job_name), "get should return our job");
361-
println!(" output: {}", get_result.output.lines().next().unwrap_or(""));
377+
assert!(
378+
get_result.output.contains(&job_name),
379+
"get should return our job"
380+
);
381+
println!(
382+
" output: {}",
383+
get_result.output.lines().next().unwrap_or("")
384+
);
362385

363386
// 16e. pause — pause the job
364387
println!("\n [pause] id={}", job_id);
@@ -394,7 +417,10 @@ async fn main() -> anyhow::Result<()> {
394417
.await?;
395418
println!(" exit_code: {}", run_result.exit_code);
396419
assert_eq!(run_result.exit_code, 0, "cron run should succeed");
397-
println!(" output: {}", run_result.output.lines().next().unwrap_or(""));
420+
println!(
421+
" output: {}",
422+
run_result.output.lines().next().unwrap_or("")
423+
);
398424

399425
// 16h. history — check execution history
400426
println!("\n [history] id={}", job_id);
@@ -406,7 +432,10 @@ async fn main() -> anyhow::Result<()> {
406432
.await?;
407433
println!(" exit_code: {}", history_result.exit_code);
408434
assert_eq!(history_result.exit_code, 0, "cron history should succeed");
409-
println!(" output: {}", history_result.output.lines().next().unwrap_or(""));
435+
println!(
436+
" output: {}",
437+
history_result.output.lines().next().unwrap_or("")
438+
);
410439

411440
// 16i. remove — clean up
412441
println!("\n [remove] id={}", job_id);
@@ -450,7 +479,10 @@ async fn main() -> anyhow::Result<()> {
450479
println!(" session.glob(\"*.rs\"): {:?}", glob_conv);
451480

452481
let grep_conv = session_new.grep("fn ").await?;
453-
println!(" session.grep(\"fn \"): {} lines", grep_conv.lines().count());
482+
println!(
483+
" session.grep(\"fn \"): {} lines",
484+
grep_conv.lines().count()
485+
);
454486

455487
// ── Done ─────────────────────────────────────────────────────────────
456488
println!("\n=== All checks passed ===");

core/examples/sdk_chat.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ async fn main() -> anyhow::Result<()> {
118118
}
119119
}
120120
Err(e) => {
121-
println!("[skip] Model override failed (expected if model not in config): {}", e);
121+
println!(
122+
"[skip] Model override failed (expected if model not in config): {}",
123+
e
124+
);
122125
}
123126
}
124127

core/src/error.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ pub enum CodeError {
7979
/// Non-security code should never panic on a poisoned lock. The data may
8080
/// be in an inconsistent state, but crashing the entire process is worse
8181
/// than serving stale data in a coding agent context.
82-
pub(crate) fn read_or_recover<T>(
83-
lock: &std::sync::RwLock<T>,
84-
) -> std::sync::RwLockReadGuard<'_, T> {
82+
pub(crate) fn read_or_recover<T>(lock: &std::sync::RwLock<T>) -> std::sync::RwLockReadGuard<'_, T> {
8583
lock.read().unwrap_or_else(|p| p.into_inner())
8684
}
8785

core/src/llm/anthropic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
use super::http::{default_http_client, normalize_base_url, HttpClient};
44
use super::types::*;
55
use super::LlmClient;
6+
use crate::retry::{AttemptOutcome, RetryConfig};
67
use anyhow::{Context, Result};
78
use async_trait::async_trait;
8-
use crate::retry::{AttemptOutcome, RetryConfig};
99
use futures::StreamExt;
1010
use serde::Deserialize;
1111
use std::sync::Arc;

core/src/llm/openai.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
use super::http::{default_http_client, normalize_base_url, HttpClient};
44
use super::types::*;
55
use super::LlmClient;
6+
use crate::retry::{AttemptOutcome, RetryConfig};
67
use anyhow::{Context, Result};
78
use async_trait::async_trait;
8-
use crate::retry::{AttemptOutcome, RetryConfig};
99
use futures::StreamExt;
1010
use serde::Deserialize;
1111
use std::sync::Arc;

core/src/llm/tests.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#[cfg(test)]
22
mod tests {
3-
use crate::llm::*;
43
use crate::llm::anthropic::*;
5-
use crate::llm::openai::*;
64
use crate::llm::http::normalize_base_url;
5+
use crate::llm::openai::*;
6+
use crate::llm::*;
77
use crate::retry::RetryConfig;
88
use std::sync::Arc;
99

@@ -497,10 +497,10 @@ mod tests {
497497

498498
#[cfg(test)]
499499
mod extra_llm_tests {
500-
use crate::llm::*;
501500
use crate::llm::anthropic::*;
502-
use crate::llm::openai::*;
503501
use crate::llm::http::normalize_base_url;
502+
use crate::llm::openai::*;
503+
use crate::llm::*;
504504
use crate::retry::RetryConfig;
505505
use std::sync::Arc;
506506

@@ -859,10 +859,10 @@ mod extra_llm_tests {
859859

860860
#[cfg(test)]
861861
mod extra_llm_tests2 {
862-
use crate::llm::*;
863862
use crate::llm::anthropic::*;
864-
use crate::llm::openai::*;
865863
use crate::llm::http::normalize_base_url;
864+
use crate::llm::openai::*;
865+
use crate::llm::*;
866866
use crate::retry::RetryConfig;
867867
use std::sync::Arc;
868868

@@ -2014,10 +2014,10 @@ mod extra_llm_tests2 {
20142014
}
20152015
#[cfg(test)]
20162016
mod extra_llm_tests3 {
2017-
use crate::llm::*;
20182017
use crate::llm::anthropic::*;
2019-
use crate::llm::openai::*;
20202018
use crate::llm::http::normalize_base_url;
2019+
use crate::llm::openai::*;
2020+
use crate::llm::*;
20212021
use crate::retry::RetryConfig;
20222022
use std::sync::Arc;
20232023

core/src/memory.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -902,10 +902,7 @@ mod tests {
902902
max_short_term: 50,
903903
max_working: 5,
904904
};
905-
let memory = AgentMemory::with_config(
906-
Arc::new(InMemoryStore::new()),
907-
config,
908-
);
905+
let memory = AgentMemory::with_config(Arc::new(InMemoryStore::new()), config);
909906
assert_eq!(memory.max_short_term, 50);
910907
assert_eq!(memory.max_working, 5);
911908
assert_eq!(memory.relevance_config.decay_days, 7.0);
@@ -921,10 +918,7 @@ mod tests {
921918
},
922919
..Default::default()
923920
};
924-
let memory = AgentMemory::with_config(
925-
Arc::new(InMemoryStore::new()),
926-
config,
927-
);
921+
let memory = AgentMemory::with_config(Arc::new(InMemoryStore::new()), config);
928922

929923
let item = MemoryItem::new("Test").with_importance(1.0);
930924
let now = Utc::now();

core/src/security/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ impl SecurityGuard {
120120
// Register injection detector hook
121121
if self.config.features.injection_defense {
122122
let hook_id = format!("{}-injection-{}", HOOK_PREFIX, &self.session_id);
123-
let detector = InjectionDetector::new(self.audit_log().clone(), self.session_id.clone());
123+
let detector =
124+
InjectionDetector::new(self.audit_log().clone(), self.session_id.clone());
124125
hook_engine.register(
125126
Hook::new(&hook_id, HookEventType::GenerateStart).with_config(HookConfig {
126127
priority: 1,
@@ -159,7 +160,8 @@ impl SecurityGuard {
159160

160161
/// Lazily initialize and return the audit log
161162
fn audit_log(&self) -> &Arc<AuditLog> {
162-
self.audit_log.get_or_init(|| Arc::new(AuditLog::new(10_000)))
163+
self.audit_log
164+
.get_or_init(|| Arc::new(AuditLog::new(10_000)))
163165
}
164166

165167
/// Classify input text and register any detected sensitive data as tainted

core/src/session/manager.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,4 +1469,3 @@ impl SessionManager {
14691469
Ok(Some(title))
14701470
}
14711471
}
1472-

core/src/session/tests.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#[cfg(test)]
22
mod tests {
3-
use crate::session::*;
4-
use crate::session::manager::*;
53
use crate::hitl::{ConfirmationPolicy, SessionLane, TimeoutAction};
64
use crate::llm::ContentBlock;
75
use crate::permissions::{PermissionDecision, PermissionPolicy};
86
use crate::queue::{
97
ExternalTaskResult, LaneHandlerConfig, SessionQueueConfig, TaskHandlerMode,
108
};
9+
use crate::session::manager::*;
10+
use crate::session::*;
1111
use crate::store::{MemorySessionStore, SessionStore};
1212
use crate::tools::ToolExecutor;
1313
use std::sync::Arc;
@@ -17,9 +17,7 @@ mod tests {
1717
/// `.a3s/` inside the crate directory when running `cargo test`.
1818
fn test_config() -> SessionConfig {
1919
SessionConfig {
20-
workspace: std::env::temp_dir()
21-
.to_string_lossy()
22-
.into_owned(),
20+
workspace: std::env::temp_dir().to_string_lossy().into_owned(),
2321
..SessionConfig::default()
2422
}
2523
}
@@ -1930,10 +1928,10 @@ mod tests {
19301928

19311929
#[cfg(test)]
19321930
mod extra_session_tests {
1933-
use crate::session::*;
1934-
use crate::session::manager::*;
19351931
use crate::llm::ContentBlock;
19361932
use crate::planning::{Task, TaskPriority, TaskStatus};
1933+
use crate::session::manager::*;
1934+
use crate::session::*;
19371935
use crate::store::{MemorySessionStore, SessionStore};
19381936
use crate::tools::ToolExecutor;
19391937
use std::sync::Arc;
@@ -1943,9 +1941,7 @@ mod extra_session_tests {
19431941
/// `.a3s/` inside the crate directory when running `cargo test`.
19441942
fn default_config() -> SessionConfig {
19451943
SessionConfig {
1946-
workspace: std::env::temp_dir()
1947-
.to_string_lossy()
1948-
.into_owned(),
1944+
workspace: std::env::temp_dir().to_string_lossy().into_owned(),
19491945
..SessionConfig::default()
19501946
}
19511947
}

0 commit comments

Comments
 (0)