cleanup: remove dead placeholder code, use RPC for identity loading
- links() in memory.rs: use cached_store() instead of MemoryNode::load()
- identity.rs: use memory_rpc for Store context loading
- defs.rs: delete dead placeholders (topology, nodes/episodes, health, split)
- agents now use {{tool: graph_topology}} etc instead
- prompts.rs: delete unused format_split_plan_node()
Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
2ab4aef19f
commit
de5a6672c3
4 changed files with 11 additions and 74 deletions
|
|
@ -301,7 +301,9 @@ async fn search(args: &serde_json::Value) -> Result<String> {
|
||||||
|
|
||||||
async fn links(args: &serde_json::Value) -> Result<String> {
|
async fn links(args: &serde_json::Value) -> Result<String> {
|
||||||
let key = get_str(args, "key")?;
|
let key = get_str(args, "key")?;
|
||||||
let node = MemoryNode::load(key)
|
let arc = cached_store().await?;
|
||||||
|
let store = arc.lock().await;
|
||||||
|
let node = MemoryNode::from_store(&store, key)
|
||||||
.ok_or_else(|| anyhow::anyhow!("node not found: {}", key))?;
|
.ok_or_else(|| anyhow::anyhow!("node not found: {}", key))?;
|
||||||
let mut out = format!("Neighbors of '{}':\n", key);
|
let mut out = format!("Neighbors of '{}':\n", key);
|
||||||
for (target, strength, is_new) in &node.links {
|
for (target, strength, is_new) in &node.links {
|
||||||
|
|
|
||||||
|
|
@ -92,10 +92,15 @@ fn load_memory_files(memory_project: Option<&Path>, context_groups: &[ContextGro
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ContextSource::Store => {
|
ContextSource::Store => {
|
||||||
// Load from the memory graph store
|
// Load from the memory graph store via RPC
|
||||||
for key in &group.keys {
|
for key in &group.keys {
|
||||||
if let Some(node) = crate::hippocampus::memory::MemoryNode::load(key) {
|
if let Ok(content) = crate::mcp_server::memory_rpc(
|
||||||
memories.push((key.clone(), node.content));
|
"memory_render",
|
||||||
|
serde_json::json!({"key": key, "raw": true}),
|
||||||
|
) {
|
||||||
|
if !content.trim().is_empty() {
|
||||||
|
memories.push((key.clone(), content));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -208,24 +208,6 @@ fn resolve(
|
||||||
count: usize,
|
count: usize,
|
||||||
) -> Option<Resolved> {
|
) -> Option<Resolved> {
|
||||||
match name {
|
match name {
|
||||||
"topology" => Some(Resolved {
|
|
||||||
text: super::prompts::format_topology_header(store, graph),
|
|
||||||
keys: vec![],
|
|
||||||
}),
|
|
||||||
|
|
||||||
"nodes" | "episodes" => {
|
|
||||||
let items = keys_to_replay_items(store, keys, graph);
|
|
||||||
Some(Resolved {
|
|
||||||
text: super::prompts::format_nodes_section(store, &items, graph),
|
|
||||||
keys: vec![], // keys already tracked from query
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
"health" => Some(Resolved {
|
|
||||||
text: super::prompts::format_health_section(store, graph),
|
|
||||||
keys: vec![],
|
|
||||||
}),
|
|
||||||
|
|
||||||
"rename" => {
|
"rename" => {
|
||||||
if !keys.is_empty() {
|
if !keys.is_empty() {
|
||||||
// --target provided: present those keys as candidates
|
// --target provided: present those keys as candidates
|
||||||
|
|
@ -237,14 +219,6 @@ fn resolve(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"split" => {
|
|
||||||
let key = keys.first()?;
|
|
||||||
Some(Resolved {
|
|
||||||
text: super::prompts::format_split_plan_node(store, graph, key),
|
|
||||||
keys: vec![], // key already tracked from query
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// seed — render output for each seed node (content + deduped links)
|
// seed — render output for each seed node (content + deduped links)
|
||||||
"seed" => {
|
"seed" => {
|
||||||
let mut text = String::new();
|
let mut text = String::new();
|
||||||
|
|
|
||||||
|
|
@ -305,50 +305,6 @@ pub(super) fn format_rename_targets(store: &Store, keys: &[String]) -> String {
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Format a single node for split-plan prompt (phase 1)
|
|
||||||
pub(super) fn format_split_plan_node(store: &Store, graph: &Graph, key: &str) -> String {
|
|
||||||
let communities = graph.communities();
|
|
||||||
let node = match store.nodes.get(key) {
|
|
||||||
Some(n) => n,
|
|
||||||
None => return format!("Node '{}' not found\n", key),
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut out = String::new();
|
|
||||||
out.push_str(&format!("### {} ({} chars)\n", key, node.content.len()));
|
|
||||||
|
|
||||||
// Show neighbors grouped by community
|
|
||||||
let neighbors = graph.neighbors(key);
|
|
||||||
if !neighbors.is_empty() {
|
|
||||||
let mut by_community: std::collections::BTreeMap<String, Vec<(&str, f32)>> =
|
|
||||||
std::collections::BTreeMap::new();
|
|
||||||
for (nkey, strength) in &neighbors {
|
|
||||||
let comm = communities.get(nkey.as_str())
|
|
||||||
.map(|c| format!("c{}", c))
|
|
||||||
.unwrap_or_else(|| "unclustered".into());
|
|
||||||
by_community.entry(comm)
|
|
||||||
.or_default()
|
|
||||||
.push((nkey.as_str(), *strength));
|
|
||||||
}
|
|
||||||
|
|
||||||
out.push_str("\nNeighbors by community:\n");
|
|
||||||
for (comm, members) in &by_community {
|
|
||||||
out.push_str(&format!(" {} ({}):", comm, members.len()));
|
|
||||||
for (nkey, strength) in members.iter().take(5) {
|
|
||||||
out.push_str(&format!(" {}({:.2})", nkey, strength));
|
|
||||||
}
|
|
||||||
if members.len() > 5 {
|
|
||||||
out.push_str(&format!(" +{} more", members.len() - 5));
|
|
||||||
}
|
|
||||||
out.push('\n');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Full content
|
|
||||||
out.push_str(&format!("\nContent:\n{}\n\n", node.content));
|
|
||||||
out.push_str("---\n\n");
|
|
||||||
out
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Generate a specific agent prompt with filled-in data.
|
/// Generate a specific agent prompt with filled-in data.
|
||||||
pub fn agent_prompt(store: &Store, agent: &str, count: usize) -> Result<AgentBatch, String> {
|
pub fn agent_prompt(store: &Store, agent: &str, count: usize) -> Result<AgentBatch, String> {
|
||||||
let def = super::defs::get_def(agent)
|
let def = super::defs::get_def(agent)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue