CLI/hippocampus: rename core memory functions to memory_*
Aligns function names with tool names for consistency: - hippocampus: render → memory_render, write → memory_write, etc. - tools/memory.rs: macro no longer prepends memory_ prefix - CLI files: use typed async API throughout (graph.rs, journal.rs, admin.rs) This eliminates the "memory_graph_topology" tool name bug where graph_* and journal_* tools were incorrectly prefixed. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
fa50f1c826
commit
5b07a81aa7
7 changed files with 106 additions and 130 deletions
|
|
@ -4,6 +4,7 @@
|
|||
// link, link-add, link-impact, link-audit, cap-degree,
|
||||
// normalize-strengths, trace, spectral-*, organize, communities.
|
||||
|
||||
use crate::agent::tools::memory;
|
||||
use crate::store;
|
||||
|
||||
pub fn cmd_cap_degree(max_deg: usize) -> Result<(), String> {
|
||||
|
|
@ -14,67 +15,55 @@ pub fn cmd_cap_degree(max_deg: usize) -> Result<(), String> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn cmd_normalize_strengths(apply: bool) -> Result<(), String> {
|
||||
pub async fn cmd_normalize_strengths(apply: bool) -> Result<(), String> {
|
||||
if apply { super::check_dry_run(); }
|
||||
let result = crate::mcp_server::memory_rpc(
|
||||
"graph_normalize_strengths",
|
||||
serde_json::json!({"apply": apply}),
|
||||
).map_err(|e| e.to_string())?;
|
||||
let result = memory::graph_normalize_strengths(None, Some(apply)).await
|
||||
.map_err(|e| e.to_string())?;
|
||||
print!("{}", result);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn cmd_link(key: &[String]) -> Result<(), String> {
|
||||
pub async fn cmd_link(key: &[String]) -> Result<(), String> {
|
||||
if key.is_empty() {
|
||||
return Err("link requires a key".into());
|
||||
}
|
||||
let key = key.join(" ");
|
||||
let result = crate::mcp_server::memory_rpc(
|
||||
"memory_links",
|
||||
serde_json::json!({"key": key}),
|
||||
).map_err(|e| e.to_string())?;
|
||||
let result = memory::memory_links(None, &key).await
|
||||
.map_err(|e| e.to_string())?;
|
||||
print!("{}", result);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn cmd_link_add(source: &str, target: &str, _reason: &[String]) -> Result<(), String> {
|
||||
pub async fn cmd_link_add(source: &str, target: &str, _reason: &[String]) -> Result<(), String> {
|
||||
super::check_dry_run();
|
||||
let result = crate::mcp_server::memory_rpc(
|
||||
"memory_link_add",
|
||||
serde_json::json!({"source": source, "target": target}),
|
||||
).map_err(|e| e.to_string())?;
|
||||
let result = memory::memory_link_add(None, source, target).await
|
||||
.map_err(|e| e.to_string())?;
|
||||
println!("{}", result);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn cmd_link_set(source: &str, target: &str, strength: f32) -> Result<(), String> {
|
||||
pub async fn cmd_link_set(source: &str, target: &str, strength: f32) -> Result<(), String> {
|
||||
super::check_dry_run();
|
||||
let result = crate::mcp_server::memory_rpc(
|
||||
"memory_link_set",
|
||||
serde_json::json!({"source": source, "target": target, "strength": strength}),
|
||||
).map_err(|e| e.to_string())?;
|
||||
let result = memory::memory_link_set(None, source, target, strength).await
|
||||
.map_err(|e| e.to_string())?;
|
||||
println!("{}", result);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn cmd_link_impact(source: &str, target: &str) -> Result<(), String> {
|
||||
let result = crate::mcp_server::memory_rpc(
|
||||
"graph_link_impact",
|
||||
serde_json::json!({"source": source, "target": target}),
|
||||
).map_err(|e| e.to_string())?;
|
||||
pub async fn cmd_link_impact(source: &str, target: &str) -> Result<(), String> {
|
||||
let result = memory::graph_link_impact(None, source, target).await
|
||||
.map_err(|e| e.to_string())?;
|
||||
print!("{}", result);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn cmd_trace(key: &[String]) -> Result<(), String> {
|
||||
pub async fn cmd_trace(key: &[String]) -> Result<(), String> {
|
||||
if key.is_empty() {
|
||||
return Err("trace requires a key".into());
|
||||
}
|
||||
let key = key.join(" ");
|
||||
let result = crate::mcp_server::memory_rpc(
|
||||
"graph_trace",
|
||||
serde_json::json!({"key": key}),
|
||||
).map_err(|e| e.to_string())?;
|
||||
let result = memory::graph_trace(None, &key).await
|
||||
.map_err(|e| e.to_string())?;
|
||||
print!("{}", result);
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -82,11 +71,9 @@ pub fn cmd_trace(key: &[String]) -> Result<(), String> {
|
|||
/// Show communities sorted by isolation (most isolated first).
|
||||
/// Useful for finding poorly-integrated knowledge clusters that need
|
||||
/// organize agents aimed at them.
|
||||
pub fn cmd_communities(top_n: usize, min_size: usize) -> Result<(), String> {
|
||||
let result = crate::mcp_server::memory_rpc(
|
||||
"graph_communities",
|
||||
serde_json::json!({"top_n": top_n, "min_size": min_size}),
|
||||
).map_err(|e| e.to_string())?;
|
||||
pub async fn cmd_communities(top_n: usize, min_size: usize) -> Result<(), String> {
|
||||
let result = memory::graph_communities(None, Some(top_n), Some(min_size)).await
|
||||
.map_err(|e| e.to_string())?;
|
||||
print!("{}", result);
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue