refactor: address 5-pass audit findings for antipatterns, bottlenecks, memory efficiency, and LLM handlers

This commit is contained in:
Riz Ashraf committed 2026-10-05 21:44:10 +01:00
1 parent 626403900f
commit 924b6d09fa
30 files changed
+1120 -503

No files matched your search

+1 -1
View File
@@ -4,4 +4,4 @@ version = "1.0.0"
edition = "2024"
[dependencies]
tokio = { version = "1.53.1", features = ["io-util"] }
tokio = { version = "1.53.1", features = ["io-util", "macros"] }
+6 -6
View File
@@ -13,10 +13,10 @@ pub async fn read_mcp_message<R: tokio::io::AsyncRead + Unpin>(
return None;
}
if line.starts_with('{') {
let len = line.trim_end().len();
line.truncate(len);
return Some(line);
let trimmed_start = line.trim_start();
if trimmed_start.starts_with('{') {
let trimmed = line.trim();
return Some(trimmed.to_string());
}
let line = line.trim_end();
@@ -35,8 +35,8 @@ pub async fn read_mcp_message<R: tokio::io::AsyncRead + Unpin>(
return None;
}
let mut buffer = vec![0; length];
if stdin.read_exact(&mut buffer).await.is_err() {
let mut buffer = Vec::with_capacity(length);
if stdin.take(length as u64).read_to_end(&mut buffer).await.is_err() || buffer.len() != length {
return None;
}