cargo fmt

This commit is contained in:
2026-04-27 22:51:07 +09:00
parent bcaa4645f7
commit 7a0ed7d744
62 changed files with 485 additions and 527 deletions
+5 -4
View File
@@ -45,9 +45,8 @@ struct EditTool {
#[async_trait]
impl Tool for EditTool {
async fn execute(&self, input_json: &str) -> Result<ToolOutput, ToolError> {
let params: EditParams = serde_json::from_str(input_json).map_err(|e| {
ToolError::InvalidArgument(format!("invalid MemoryEdit input: {e}"))
})?;
let params: EditParams = serde_json::from_str(input_json)
.map_err(|e| ToolError::InvalidArgument(format!("invalid MemoryEdit input: {e}")))?;
if params.old_string.is_empty() {
return Err(ToolError::InvalidArgument(
@@ -60,7 +59,9 @@ impl Tool for EditTool {
));
}
let path = params.kind.resolve_path(&self.layout, params.slug.as_deref())?;
let path = params
.kind
.resolve_path(&self.layout, params.slug.as_deref())?;
let current_bytes = std::fs::read(&path).map_err(|e| match e.kind() {
std::io::ErrorKind::NotFound => ToolError::ExecutionFailed(format!(
+4 -7
View File
@@ -20,7 +20,7 @@ use crate::workspace::{RecordKind, WorkspaceLayout};
pub use edit::edit_tool;
pub use read::read_tool;
pub use search::{knowledge_search_tool, memory_search_tool, SearchConfig};
pub use search::{SearchConfig, knowledge_search_tool, memory_search_tool};
pub use write::write_tool;
/// Kinds the memory tools accept as input. `Workflow` is intentionally
@@ -71,13 +71,10 @@ impl MemoryToolKind {
}
other => {
let raw = slug.ok_or_else(|| {
ToolError::InvalidArgument(format!(
"kind={} requires `slug`",
other.as_str()
))
ToolError::InvalidArgument(format!("kind={} requires `slug`", other.as_str()))
})?;
let parsed = Slug::parse(raw)
.map_err(|e| ToolError::InvalidArgument(e.to_string()))?;
let parsed =
Slug::parse(raw).map_err(|e| ToolError::InvalidArgument(e.to_string()))?;
Ok(match other {
Self::Decision => layout.decision_path(&parsed),
Self::Request => layout.request_path(&parsed),
+5 -4
View File
@@ -43,11 +43,12 @@ struct ReadTool {
#[async_trait]
impl Tool for ReadTool {
async fn execute(&self, input_json: &str) -> Result<ToolOutput, ToolError> {
let params: ReadParams = serde_json::from_str(input_json).map_err(|e| {
ToolError::InvalidArgument(format!("invalid MemoryRead input: {e}"))
})?;
let params: ReadParams = serde_json::from_str(input_json)
.map_err(|e| ToolError::InvalidArgument(format!("invalid MemoryRead input: {e}")))?;
let path = params.kind.resolve_path(&self.layout, params.slug.as_deref())?;
let path = params
.kind
.resolve_path(&self.layout, params.slug.as_deref())?;
let bytes = std::fs::read(&path).map_err(|e| match e.kind() {
std::io::ErrorKind::NotFound => {
+3 -6
View File
@@ -116,9 +116,8 @@ struct KnowledgeSearchTool {
#[async_trait]
impl Tool for MemorySearchTool {
async fn execute(&self, input_json: &str) -> Result<ToolOutput, ToolError> {
let params: MemorySearchParams = serde_json::from_str(input_json).map_err(|e| {
ToolError::InvalidArgument(format!("invalid MemorySearch input: {e}"))
})?;
let params: MemorySearchParams = serde_json::from_str(input_json)
.map_err(|e| ToolError::InvalidArgument(format!("invalid MemorySearch input: {e}")))?;
let needle = validate_query(&params.query)?;
let mut hits: Vec<MemoryHit> = Vec::new();
@@ -241,9 +240,7 @@ impl Tool for KnowledgeSearchTool {
fn validate_query(query: &str) -> Result<String, ToolError> {
if query.trim().is_empty() {
return Err(ToolError::InvalidArgument(
"query must not be empty".into(),
));
return Err(ToolError::InvalidArgument("query must not be empty".into()));
}
Ok(query.to_lowercase())
}
+10 -5
View File
@@ -40,11 +40,12 @@ struct WriteTool {
#[async_trait]
impl Tool for WriteTool {
async fn execute(&self, input_json: &str) -> Result<ToolOutput, ToolError> {
let params: WriteParams = serde_json::from_str(input_json).map_err(|e| {
ToolError::InvalidArgument(format!("invalid MemoryWrite input: {e}"))
})?;
let params: WriteParams = serde_json::from_str(input_json)
.map_err(|e| ToolError::InvalidArgument(format!("invalid MemoryWrite input: {e}")))?;
let path = params.kind.resolve_path(&self.layout, params.slug.as_deref())?;
let path = params
.kind
.resolve_path(&self.layout, params.slug.as_deref())?;
let already_exists = path.exists();
let mode = if already_exists {
@@ -72,7 +73,11 @@ impl Tool for WriteTool {
let summary = format!(
"{} {}{}",
if already_exists { "Overwrote" } else { "Created" },
if already_exists {
"Overwrote"
} else {
"Created"
},
path.display(),
warning_tail(&report),
);