cargo fmt
This commit is contained in:
@@ -6,7 +6,7 @@ use llm_worker::tool::{Tool, ToolDefinition};
|
||||
use manifest::Scope;
|
||||
use serde_json::json;
|
||||
use tempfile::TempDir;
|
||||
use tools::{Tracker, ScopedFs, builtin_tools};
|
||||
use tools::{ScopedFs, Tracker, builtin_tools};
|
||||
|
||||
struct Registry {
|
||||
entries: Vec<(llm_worker::tool::ToolMeta, Arc<dyn Tool>)>,
|
||||
@@ -54,10 +54,7 @@ async fn unicode_path_and_content() {
|
||||
|
||||
let read = reg.get("Read");
|
||||
let out = read
|
||||
.execute(
|
||||
&json!({ "file_path": file.to_str().unwrap() })
|
||||
.to_string(),
|
||||
)
|
||||
.execute(&json!({ "file_path": file.to_str().unwrap() }).to_string())
|
||||
.await
|
||||
.unwrap();
|
||||
let body = out.content.unwrap();
|
||||
@@ -81,11 +78,9 @@ async fn symlink_to_outside_scope_is_rejected_for_write() {
|
||||
|
||||
// Read tool must work against the symlink (read is unrestricted).
|
||||
let read = reg.get("Read");
|
||||
read.execute(
|
||||
&json!({ "file_path": link.to_str().unwrap() }).to_string(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
read.execute(&json!({ "file_path": link.to_str().unwrap() }).to_string())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Write through the symlink must be rejected because canonicalization
|
||||
// resolves it to outside the scope.
|
||||
|
||||
@@ -11,7 +11,7 @@ use llm_worker::tool::{Tool, ToolDefinition, ToolMeta};
|
||||
use manifest::Scope;
|
||||
use serde_json::json;
|
||||
use tempfile::TempDir;
|
||||
use tools::{Tracker, ScopedFs, builtin_tools};
|
||||
use tools::{ScopedFs, Tracker, builtin_tools};
|
||||
|
||||
struct Registry {
|
||||
entries: Vec<(ToolMeta, Arc<dyn Tool>)>,
|
||||
@@ -50,10 +50,7 @@ async fn call(tool: &Arc<dyn Tool>, input: serde_json::Value) -> llm_worker::too
|
||||
.expect("tool execution failed")
|
||||
}
|
||||
|
||||
async fn call_err(
|
||||
tool: &Arc<dyn Tool>,
|
||||
input: serde_json::Value,
|
||||
) -> llm_worker::tool::ToolError {
|
||||
async fn call_err(tool: &Arc<dyn Tool>, input: serde_json::Value) -> llm_worker::tool::ToolError {
|
||||
tool.execute(&input.to_string())
|
||||
.await
|
||||
.expect_err("expected error")
|
||||
@@ -71,7 +68,11 @@ fn builtin_tools_registers_all_five() {
|
||||
fn meta_has_description_and_schema() {
|
||||
let (_dir, reg) = setup();
|
||||
for (meta, _) in ®.entries {
|
||||
assert!(!meta.description.is_empty(), "{} missing description", meta.name);
|
||||
assert!(
|
||||
!meta.description.is_empty(),
|
||||
"{} missing description",
|
||||
meta.name
|
||||
);
|
||||
// Input schema must be a JSON object
|
||||
assert!(
|
||||
meta.input_schema.is_object(),
|
||||
@@ -283,7 +284,11 @@ async fn tracker_recent_files_tracks_read_write_edit() {
|
||||
std::fs::write(&a, "one\n").unwrap();
|
||||
|
||||
// Read `a` — should appear in recency.
|
||||
call(®.get("Read"), json!({ "file_path": a.to_str().unwrap() })).await;
|
||||
call(
|
||||
®.get("Read"),
|
||||
json!({ "file_path": a.to_str().unwrap() }),
|
||||
)
|
||||
.await;
|
||||
// Write `b` (new file) — should appear ahead of `a`.
|
||||
call(
|
||||
®.get("Write"),
|
||||
@@ -303,8 +308,14 @@ async fn tracker_recent_files_tracks_read_write_edit() {
|
||||
|
||||
let recent = tracker.recent_files(10);
|
||||
assert_eq!(recent.len(), 2);
|
||||
assert!(recent[0].ends_with("a.txt"), "front should be a.txt: {recent:?}");
|
||||
assert!(recent[1].ends_with("b.txt"), "second should be b.txt: {recent:?}");
|
||||
assert!(
|
||||
recent[0].ends_with("a.txt"),
|
||||
"front should be a.txt: {recent:?}"
|
||||
);
|
||||
assert!(
|
||||
recent[1].ends_with("b.txt"),
|
||||
"second should be b.txt: {recent:?}"
|
||||
);
|
||||
}
|
||||
|
||||
// Sanity: unused Path import guard
|
||||
|
||||
Reference in New Issue
Block a user