Test coverage and headless nvim bug fixes
This commit is contained in:
1 parent
bffc8896f1
commit
4bae4e9c08
9 files changed
+316
-58
No files matched your search
@@ -147,7 +147,16 @@ impl McpTool for CreateRelationsHandler {
|
||||
}
|
||||
|
||||
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> Result<String, String> {
|
||||
let req: CreateRelationsTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let req: CreateRelationsTool = match serde_json::from_value(args.clone()) {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
let err_msg = e.to_string();
|
||||
if err_msg.contains("missing field `from`") || err_msg.contains("missing field `to`") || err_msg.contains("missing field `relation_type`") {
|
||||
return Err(format!("Schema error: {}. Note that the relation schema strictly uses 'from', 'to', and 'relation_type' (not 'source', 'target', or 'relationType'). Please correct your tool call arguments.", err_msg));
|
||||
}
|
||||
return Err(err_msg);
|
||||
}
|
||||
};
|
||||
let mut missing_nodes = std::collections::HashSet::new();
|
||||
state.modify_graph(|g| {
|
||||
for relation in req.relations {
|
||||
@@ -682,6 +691,16 @@ mod tests {
|
||||
});
|
||||
let res = handler.execute(args, state.clone()).await.unwrap();
|
||||
assert_eq!(res, "Relations created");
|
||||
|
||||
// Test semantic LLM schema feedback (User request)
|
||||
let bad_args = json!({
|
||||
"relations": [
|
||||
{"source": "A", "target": "B", "relationType": "knows"}
|
||||
]
|
||||
});
|
||||
let err_res = handler.execute(bad_args, state.clone()).await.unwrap_err();
|
||||
assert!(err_res.contains("Schema error:"));
|
||||
assert!(err_res.contains("strictly uses 'from', 'to', and 'relation_type'"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
Reference in new issue
Block a user