chore: fix clippy warnings, add embedding/omni_patch, update telemetry, and ignore temp files
This commit is contained in:
1 parent
495304f3fa
commit
98a1716ac8
23 files changed
+2253
-75
No files matched your search
+68
-40
@@ -138,6 +138,8 @@ impl McpTool for LogErrorFixHandler {
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> Result<String, String> {
|
||||
let req: LogErrorFixTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let text_to_embed = format!("Signature: {}\nSolution: {}", req.signature, req.solution);
|
||||
let embedding = crate::embedding::generate_embedding_async(text_to_embed).await.ok();
|
||||
state.error_fixes.modify(|fixes| {
|
||||
fixes.push(crate::models::ErrorFix {
|
||||
signature: req.signature,
|
||||
@@ -145,6 +147,7 @@ impl McpTool for LogErrorFixHandler {
|
||||
timestamp: crate::handlers::utils::now_secs(),
|
||||
git_commit: req.git_commit,
|
||||
git_branch: req.git_branch,
|
||||
embedding,
|
||||
})
|
||||
});
|
||||
Ok("Error fix logged".to_string())
|
||||
@@ -294,6 +297,8 @@ impl McpTool for LogTechDebtHandler {
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> Result<String, String> {
|
||||
let req: LogTechDebtTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let text_to_embed = format!("Description: {}\nIdeal Solution: {}", req.description, req.ideal_solution);
|
||||
let embedding = crate::embedding::generate_embedding_async(text_to_embed).await.ok();
|
||||
state.tech_debts.modify(|debts| {
|
||||
debts.push(crate::models::TechDebt {
|
||||
id: uuid::Uuid::new_v4().to_string(),
|
||||
@@ -304,6 +309,7 @@ impl McpTool for LogTechDebtHandler {
|
||||
created_at: crate::handlers::utils::now_secs(),
|
||||
git_commit: req.git_commit,
|
||||
git_branch: req.git_branch,
|
||||
embedding,
|
||||
})
|
||||
});
|
||||
Ok("Tech debt logged".to_string())
|
||||
@@ -404,6 +410,8 @@ impl McpTool for OmniSearchHandler {
|
||||
}
|
||||
};
|
||||
println!("OMNI SEARCH MATCHES: {:?}", matches);
|
||||
let q = req.query.clone();
|
||||
let query_emb = crate::embedding::generate_embedding_async(q.clone()).await.unwrap_or_default();
|
||||
|
||||
let kg_json = state.read_graph(|full| {
|
||||
let mut kg_entities = std::collections::HashMap::new();
|
||||
@@ -466,20 +474,27 @@ impl McpTool for OmniSearchHandler {
|
||||
})?;
|
||||
|
||||
let snippets_json = state.snippets.read_with(|all_snippets| {
|
||||
let filtered: Vec<_> = all_snippets
|
||||
.iter()
|
||||
.filter(|s| matched_snippets.contains(s.name.as_str()))
|
||||
.take(limit)
|
||||
.map(|s| {
|
||||
if !include_body {
|
||||
let mut summary = s.clone();
|
||||
summary.code = "".to_string();
|
||||
summary
|
||||
} else {
|
||||
s.clone()
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let mut scored: Vec<_> = all_snippets.iter().map(|s| {
|
||||
let mut score = 0.0;
|
||||
if matched_snippets.contains(s.name.as_str()) || contains_ignore_ascii_case(&s.name, &q) || contains_ignore_ascii_case(&s.description, &q) {
|
||||
score += 1.0;
|
||||
}
|
||||
if let Some(emb) = &s.embedding {
|
||||
score += crate::embedding::cosine_similarity(&query_emb, emb);
|
||||
}
|
||||
(s, score)
|
||||
}).filter(|(_, score)| *score > 0.4).collect();
|
||||
scored.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap_or(std::cmp::Ordering::Equal));
|
||||
|
||||
let filtered: Vec<_> = scored.into_iter().take(limit).map(|(s, _)| {
|
||||
if !include_body {
|
||||
let mut summary = s.clone();
|
||||
summary.code = "".to_string();
|
||||
summary
|
||||
} else {
|
||||
s.clone()
|
||||
}
|
||||
}).collect();
|
||||
serde_json::to_value(&filtered).map_err(|e| e.to_string())
|
||||
})?;
|
||||
|
||||
@@ -505,25 +520,31 @@ impl McpTool for OmniSearchHandler {
|
||||
|
||||
let q = req.query;
|
||||
let tech_debts_json = state.tech_debts.read_with(|debts| {
|
||||
let filtered: Vec<_> = debts
|
||||
.iter()
|
||||
.filter(|d| {
|
||||
req.namespace.as_ref().is_none_or(|ns| d.namespace == *ns)
|
||||
&& (contains_ignore_ascii_case(&d.description, &q)
|
||||
|| contains_ignore_ascii_case(&d.ideal_solution, &q))
|
||||
})
|
||||
.take(limit)
|
||||
.map(|d| {
|
||||
if !include_body {
|
||||
let mut summary = d.clone();
|
||||
summary.description = "".to_string();
|
||||
summary.ideal_solution = "".to_string();
|
||||
summary
|
||||
} else {
|
||||
d.clone()
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let mut scored: Vec<_> = debts.iter().map(|d| {
|
||||
if req.namespace.as_ref().is_some_and(|ns| d.namespace != *ns) {
|
||||
return (d, 0.0);
|
||||
}
|
||||
let mut score = 0.0;
|
||||
if contains_ignore_ascii_case(&d.description, &q) || contains_ignore_ascii_case(&d.ideal_solution, &q) {
|
||||
score += 1.0;
|
||||
}
|
||||
if let Some(emb) = &d.embedding {
|
||||
score += crate::embedding::cosine_similarity(&query_emb, emb);
|
||||
}
|
||||
(d, score)
|
||||
}).filter(|(_, score)| *score > 0.4).collect();
|
||||
scored.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap_or(std::cmp::Ordering::Equal));
|
||||
|
||||
let filtered: Vec<_> = scored.into_iter().take(limit).map(|(d, _)| {
|
||||
if !include_body {
|
||||
let mut summary = d.clone();
|
||||
summary.description = "".to_string();
|
||||
summary.ideal_solution = "".to_string();
|
||||
summary
|
||||
} else {
|
||||
d.clone()
|
||||
}
|
||||
}).collect();
|
||||
serde_json::to_value(&filtered).map_err(|e| e.to_string())
|
||||
})?;
|
||||
|
||||
@@ -549,13 +570,19 @@ impl McpTool for OmniSearchHandler {
|
||||
})?;
|
||||
|
||||
let error_fixes_json = state.error_fixes.read_with(|fixes| {
|
||||
let filtered: Vec<_> = fixes
|
||||
.iter()
|
||||
.filter(|f| {
|
||||
contains_ignore_ascii_case(&f.signature, &q)
|
||||
|| contains_ignore_ascii_case(&f.solution, &q)
|
||||
})
|
||||
.collect();
|
||||
let mut scored: Vec<_> = fixes.iter().map(|f| {
|
||||
let mut score = 0.0;
|
||||
if contains_ignore_ascii_case(&f.signature, &q) || contains_ignore_ascii_case(&f.solution, &q) {
|
||||
score += 1.0;
|
||||
}
|
||||
if let Some(emb) = &f.embedding {
|
||||
score += crate::embedding::cosine_similarity(&query_emb, emb);
|
||||
}
|
||||
(f, score)
|
||||
}).filter(|(_, score)| *score > 0.4).collect();
|
||||
scored.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap_or(std::cmp::Ordering::Equal));
|
||||
|
||||
let filtered: Vec<_> = scored.into_iter().take(limit).map(|(f, _)| f.clone()).collect();
|
||||
serde_json::to_value(&filtered).map_err(|e| e.to_string())
|
||||
})?;
|
||||
|
||||
@@ -800,6 +827,7 @@ mod tests {
|
||||
updated_at: 0,
|
||||
git_branch: None,
|
||||
parent_id: None,
|
||||
expires_at: None,
|
||||
dependencies: vec![],
|
||||
acceptance_criteria: vec![],
|
||||
};
|
||||
|
||||
@@ -25,6 +25,7 @@ impl McpTool for AddStickyNoteHandler {
|
||||
notes.push(StickyNote {
|
||||
timestamp: crate::handlers::utils::now_secs(),
|
||||
content: req.content,
|
||||
expires_at: None,
|
||||
});
|
||||
});
|
||||
Ok("Sticky note added.".to_string())
|
||||
@@ -133,6 +134,7 @@ impl McpTool for LeaveHandoffMemoHandler {
|
||||
content: req.content,
|
||||
namespace: req.namespace,
|
||||
timestamp: crate::handlers::utils::now_secs(),
|
||||
expires_at: None,
|
||||
})
|
||||
});
|
||||
Ok("Handoff memo left".to_string())
|
||||
@@ -220,6 +222,7 @@ impl McpTool for AddSessionSummaryHandler {
|
||||
summary: req.summary,
|
||||
namespace: req.namespace,
|
||||
timestamp: crate::handlers::utils::now_secs(),
|
||||
expires_at: None,
|
||||
})
|
||||
});
|
||||
Ok("Session summary added".to_string())
|
||||
|
||||
@@ -36,6 +36,7 @@ impl McpTool for AddTaskHandler {
|
||||
parent_id: req.parent_id,
|
||||
dependencies: deps,
|
||||
acceptance_criteria: vec![],
|
||||
expires_at: None,
|
||||
};
|
||||
let idx = state.get_search_index();
|
||||
drop(idx.index_task(&task));
|
||||
|
||||
@@ -110,12 +110,15 @@ impl McpTool for StoreSnippetHandler {
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> Result<String, String> {
|
||||
let req: StoreSnippetTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let req_name = req.name.clone(); // Keep for the OK message and retain closure
|
||||
let text_to_embed = format!("Name: {}\nLanguage: {}\nDescription: {}\nCode: {}", req.name, req.language, req.description, req.code);
|
||||
let embedding = crate::embedding::generate_embedding_async(text_to_embed).await.ok();
|
||||
let snippet = Snippet {
|
||||
name: req.name,
|
||||
language: req.language,
|
||||
code: req.code,
|
||||
description: req.description,
|
||||
updated_at: crate::handlers::utils::now_secs(),
|
||||
embedding,
|
||||
};
|
||||
|
||||
let idx = state.get_search_index();
|
||||
|
||||
Reference in new issue
Block a user