ci: add GitHub Actions workflows with semantic-release auto-versioning
chore: fix all 702 clippy warnings across codebase - auto-fix 475 via cargo clippy --fix - fix remaining 227 manually: uninlined_format_args, redundant_closure, match_same_arms, underscore_binding, format_push_string, items_after_statements, needless_pass_by_value, clone_on_copy, case_sensitive_extension, single_match/let-else, write_with_newline, and other clippy lints
This commit is contained in:
@@ -43,8 +43,8 @@ impl Tool for Forget {
|
||||
.ok_or_else(|| anyhow!("missing required argument: name"))?;
|
||||
|
||||
Memory::remove(&ctx.memory_dir, name)
|
||||
.map_err(|e| anyhow!("failed to remove memory '{}': {}", name, e))?;
|
||||
.map_err(|e| anyhow!("failed to remove memory '{name}': {e}"))?;
|
||||
|
||||
Ok(format!("removed memory '{}'", name))
|
||||
Ok(format!("removed memory '{name}'"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//! Tool for reading a single memory entry or listing the whole memory index.
|
||||
|
||||
use std::fmt::Write;
|
||||
use serde_json::{json, Value};
|
||||
use anyhow::{Result, anyhow};
|
||||
use super::super::Tool;
|
||||
@@ -39,10 +40,10 @@ impl Tool for Recall {
|
||||
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
|
||||
if let Some(name) = args.get("name").and_then(|v| v.as_str()) {
|
||||
if name.is_empty() {
|
||||
return list_all(ctx);
|
||||
return Ok(list_all(ctx));
|
||||
}
|
||||
let memory = Memory::read(&ctx.memory_dir, name)
|
||||
.map_err(|e| anyhow!("memory '{}' not found: {}", name, e))?;
|
||||
.map_err(|e| anyhow!("memory '{name}' not found: {e}"))?;
|
||||
Ok(format!(
|
||||
"---\nname: {}\ndescription: {}\nkind: {}\nlifecycle: {}\n---\n\n{}",
|
||||
memory.name,
|
||||
@@ -52,7 +53,7 @@ impl Tool for Recall {
|
||||
memory.content,
|
||||
))
|
||||
} else {
|
||||
list_all(ctx)
|
||||
Ok(list_all(ctx))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,18 +64,18 @@ impl Tool for Recall {
|
||||
/// fall back to bare name if the file can't be parsed.
|
||||
///
|
||||
/// Return: `Ok` with the formatted index (never fails; missing dir yields "(no memory entries)").
|
||||
fn list_all(ctx: &ToolCtx) -> Result<String> {
|
||||
fn list_all(ctx: &ToolCtx) -> String {
|
||||
let names = Memory::list(&ctx.memory_dir);
|
||||
if names.is_empty() {
|
||||
return Ok("(no memory entries)".to_string());
|
||||
return "(no memory entries)".to_string();
|
||||
}
|
||||
let mut lines = format!("Memory index ({} entries):\n", names.len());
|
||||
let mut lines = String::new();
|
||||
for name in &names {
|
||||
if let Ok(mem) = Memory::read(&ctx.memory_dir, name) {
|
||||
lines.push_str(&format!("- {} [{}]: {}\n", name, mem.kind, mem.description));
|
||||
let _ = writeln!(lines, "- {} [{}]: {}", name, mem.kind, mem.description);
|
||||
} else {
|
||||
lines.push_str(&format!("- {}\n", name));
|
||||
let _ = writeln!(lines, "- {name}");
|
||||
}
|
||||
}
|
||||
Ok(lines)
|
||||
lines
|
||||
}
|
||||
|
||||
@@ -89,8 +89,8 @@ impl Tool for Remember {
|
||||
};
|
||||
|
||||
memory.write(&ctx.memory_dir)
|
||||
.map_err(|e| anyhow!("failed to write memory '{}': {}", name, e))?;
|
||||
.map_err(|e| anyhow!("failed to write memory '{name}': {e}"))?;
|
||||
|
||||
Ok(format!("saved memory '{}' ({})", name, kind))
|
||||
Ok(format!("saved memory '{name}' ({kind})"))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user