refactor(mcp): strip sse fallback architecture in favor of pure websockets and fix nvim NDJSON bug

This commit is contained in:
Riz Ashraf committed 2026-09-17 15:26:22 +01:00
1 parent 0e29b12ac8
commit 3716c3e698
33 files changed
+2082 -1756

No files matched your search

+83
View File
@@ -145,3 +145,86 @@ impl MemoryIndex {
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
use tempfile::TempDir;
#[test]
fn test_search_index_and_retrieve() {
let temp_dir = TempDir::new().unwrap();
let index = MemoryIndex::new(temp_dir.path()).unwrap();
let entity = Entity {
name: "TestEntity".to_string(),
entity_type: "Component".to_string(),
observations: vec!["This is a test observation".to_string()],
namespace: "global".to_string(),
git_branch: None,
};
index.index_entity(&entity).unwrap();
let task = Task {
id: "task-1".to_string(),
title: "Test Task".to_string(),
description: "Test task description".to_string(),
status: "open".to_string(),
created_at: 0,
updated_at: 0,
git_branch: None, acceptance_criteria: vec![], dependencies: vec![], parent_id: None,
};
index.index_task(&task).unwrap();
let snippet = Snippet {
name: "test_snippet".to_string(),
code: "fn main() {}".to_string(),
language: "rust".to_string(),
description: "A test snippet".to_string(),
updated_at: 0,
};
index.index_snippet(&snippet).unwrap();
let adr = Adr {
id: "adr-1".to_string(),
title: "Test ADR".to_string(),
context: "Test context".to_string(),
decision: "Test decision".to_string(),
consequence: "Test consequence".to_string(),
timestamp: 0,
};
index.index_adr(&adr).unwrap();
index.commit().unwrap();
index.reader.reload().unwrap();
// Test search
let results = index.search("observation", None).unwrap();
assert_eq!(results.len(), 1);
assert_eq!(results[0].0, "TestEntity");
assert_eq!(results[0].1, "entity");
let results = index.search("task", None).unwrap();
assert!(results.iter().any(|r| r.0 == "task-1"));
let results = index.search("snippet", None).unwrap();
assert!(results.iter().any(|r| r.0 == "test_snippet"));
let results = index.search("decision", None).unwrap();
assert!(results.iter().any(|r| r.0 == "adr-1"));
}
#[test]
fn test_search_malformed_query() {
let temp_dir = TempDir::new().unwrap();
let index = MemoryIndex::new(temp_dir.path()).unwrap();
// Malformed lucene query (unclosed parenthesis)
let result = index.search("title: (unclosed", None);
assert!(result.is_err());
// Another malformed query (unclosed quote)
let result2 = index.search("title: \"unclosed", None);
assert!(result2.is_err());
}
}